From b09af35f2f1cde7649d3ac4a6f5d2af6d97895a0 Mon Sep 17 00:00:00 2001 From: michaelh Date: Mon, 17 Jan 2000 03:23:41 +0000 Subject: [PATCH] Initial revision git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- .version | 1 + COPYING | 339 + Makefile | 152 + Makefile.org | 114 + README | 49 + as/README | 5 + as/doc/README | 460 + as/doc/abstra.doc | 60 + as/doc/appendk.txt | 158 + as/doc/asmlnk.doc | 5726 ++++++++++ as/doc/asxhtm.html | 6477 ++++++++++++ as/doc/format.txt | 123 + as/mcs51/Makefile.aslink | 59 + as/mcs51/Makefile.asx8051 | 59 + as/mcs51/Makefile.in | 111 + as/mcs51/alloc.h | 7 + as/mcs51/asdata.c | 285 + as/mcs51/asexpr.c | 695 ++ as/mcs51/aslex.c | 494 + as/mcs51/aslink.h | 718 ++ as/mcs51/aslink.mak | 263 + as/mcs51/aslist.c | 725 ++ as/mcs51/asm.h | 625 ++ as/mcs51/asmain.c | 1144 ++ as/mcs51/asnoice.c | 122 + as/mcs51/asout.c | 1131 ++ as/mcs51/asstore.c | 45 + as/mcs51/assubr.c | 231 + as/mcs51/assym.c | 436 + as/mcs51/clean.mk | 23 + as/mcs51/conf.mk | 10 + as/mcs51/i51adr.c | 258 + as/mcs51/i51ext.c | 21 + as/mcs51/i51mch.c | 694 ++ as/mcs51/i51pst.c | 471 + as/mcs51/i8051.h | 118 + as/mcs51/lkarea.c | 451 + as/mcs51/lkdata.c | 479 + as/mcs51/lkeval.c | 396 + as/mcs51/lkhead.c | 154 + as/mcs51/lkihx.c | 134 + as/mcs51/lklex.c | 544 + as/mcs51/lklibr.c | 553 + as/mcs51/lklist.c | 1069 ++ as/mcs51/lkmain.c | 1236 +++ as/mcs51/lknoice.c | 246 + as/mcs51/lkrloc.c | 1173 +++ as/mcs51/lks19.c | 123 + as/mcs51/lkstore.c | 51 + as/mcs51/lksym.c | 484 + as/mcs51/string.h | 15 + as/z80/Makefile | 22 + as/z80/alloc.h | 10 + as/z80/asdata.c | 279 + as/z80/asexpr.c | 667 ++ as/z80/aslex.c | 500 + as/z80/aslist.c | 804 ++ as/z80/asm.h | 599 ++ as/z80/asmain.c | 1188 +++ as/z80/asout.c | 1085 ++ as/z80/assubr.c | 255 + as/z80/assym.c | 441 + as/z80/incld1.asm | 10 + as/z80/incld2.asm | 10 + as/z80/incld3.asm | 10 + as/z80/incld4.asm | 10 + as/z80/incld5.asm | 10 + as/z80/itsta.asm | 42 + as/z80/itstb.asm | 42 + as/z80/string.h | 15 + as/z80/tconst.asm | 68 + as/z80/tz80.asm | 1013 ++ as/z80/tz80l.asm | 47 + as/z80/z80.h | 192 + as/z80/z80adr.c | 256 + as/z80/z80ext.c | 27 + as/z80/z80mch.c | 773 ++ as/z80/z80pst.c | 179 + clean.mk | 24 + conf.mk | 16 + configure | 2941 ++++++ configure.in | 206 + debugger/Makefile | 0 debugger/README | 4 + debugger/mcs51/Makefile | 109 + debugger/mcs51/Makefile.dep | 4 + debugger/mcs51/Makefile.in | 108 + debugger/mcs51/break.c | 396 + debugger/mcs51/break.h | 86 + debugger/mcs51/clean.mk | 24 + debugger/mcs51/cmd.c | 1650 +++ debugger/mcs51/cmd.h | 47 + debugger/mcs51/conf.mk | 10 + debugger/mcs51/sdcdb.c | 792 ++ debugger/mcs51/sdcdb.el | 650 ++ debugger/mcs51/sdcdb.h | 230 + debugger/mcs51/sdcdbsrc.el | 1557 +++ debugger/mcs51/simi.c | 456 + debugger/mcs51/simi.h | 44 + debugger/mcs51/symtab.c | 728 ++ debugger/mcs51/symtab.h | 248 + device/README | 5 + device/examples/an429.c | 402 + device/examples/clean.mk | 28 + device/examples/cpu_tools.c | 283 + device/examples/cpu_tools.h | 35 + device/examples/crc.c | 10 + device/examples/crcs.c | 11 + device/examples/itoa.c | 47 + device/examples/ltoa.c | 48 + device/examples/main8051.c | 72 + device/examples/test2.c | 909 ++ device/include/Makefile.in | 88 + device/include/assert.h | 32 + device/include/at89S8252.h | 341 + device/include/at89c55.h | 259 + device/include/at89x1051.h | 183 + device/include/at89x2051.h | 206 + device/include/at89x51.h | 218 + device/include/at89x52.h | 257 + device/include/canc515c.h | 149 + device/include/clean.mk | 22 + device/include/conf.mk | 10 + device/include/ctype.h | 63 + device/include/float.h | 43 + device/include/limits.h | 55 + device/include/malloc.h | 53 + device/include/math.h | 33 + device/include/mcs51/README | 2 + device/include/reg51.h | 145 + device/include/reg515.h | 182 + device/include/reg552.h | 225 + device/include/regc515c.h | 298 + device/include/sab80515.h | 385 + device/include/ser.h | 35 + device/include/ser_ir.h | 41 + device/include/serial.h | 15 + device/include/setjmp.h | 33 + device/include/stdarg.h | 24 + device/include/stdio.h | 42 + device/include/stdlib.h | 37 + device/include/string.h | 74 + device/include/z80/README | 2 + device/lib/Makefile | 146 + device/lib/Makefile.dep | 0 device/lib/Makefile.in | 145 + device/lib/_atoi.c | 49 + device/lib/_atoi.lst | 335 + device/lib/_atoi.sym | 582 + device/lib/_atol.c | 49 + device/lib/_atol.lst | 397 + device/lib/_atol.sym | 641 ++ device/lib/_autobaud.c | 97 + device/lib/_autobaud.lst | 325 + device/lib/_autobaud.sym | 572 + device/lib/_bp.c | 26 + device/lib/_bp.lst | 48 + device/lib/_bp.sym | 355 + device/lib/_char2fs.c | 110 + device/lib/_char2fs.lst | 334 + device/lib/_char2fs.sym | 596 ++ device/lib/_decdptr.c | 36 + device/lib/_decdptr.lst | 70 + device/lib/_decdptr.sym | 371 + device/lib/_divsint.c | 43 + device/lib/_divsint.lst | 180 + device/lib/_divsint.sym | 458 + device/lib/_divslong.c | 35 + device/lib/_divslong.lst | 254 + device/lib/_divslong.sym | 529 + device/lib/_divuint.c | 50 + device/lib/_divuint.lst | 215 + device/lib/_divuint.sym | 487 + device/lib/_divulong.c | 49 + device/lib/_divulong.lst | 319 + device/lib/_divulong.sym | 590 ++ device/lib/_fs2char.c | 97 + device/lib/_fs2char.lst | 432 + device/lib/_fs2char.sym | 690 ++ device/lib/_fs2int.c | 97 + device/lib/_fs2int.lst | 439 + device/lib/_fs2int.sym | 694 ++ device/lib/_fs2long.c | 98 + device/lib/_fs2long.lst | 454 + device/lib/_fs2long.sym | 705 ++ device/lib/_fs2uchar.c | 97 + device/lib/_fs2uchar.lst | 422 + device/lib/_fs2uchar.sym | 680 ++ device/lib/_fs2uint.c | 97 + device/lib/_fs2uint.lst | 436 + device/lib/_fs2uint.sym | 692 ++ device/lib/_fs2ulong.c | 98 + device/lib/_fs2ulong.lst | 451 + device/lib/_fs2ulong.sym | 703 ++ device/lib/_fsadd.c | 102 + device/lib/_fsadd.lst | 1406 +++ device/lib/_fsadd.sym | 1575 +++ device/lib/_fsdiv.c | 139 + device/lib/_fsdiv.lst | 936 ++ device/lib/_fsdiv.sym | 1159 ++ device/lib/_fseq.c | 88 + device/lib/_fseq.lst | 282 + device/lib/_fseq.sym | 555 + device/lib/_fsgt.c | 88 + device/lib/_fsgt.lst | 284 + device/lib/_fsgt.sym | 560 + device/lib/_fslt.c | 88 + device/lib/_fslt.lst | 284 + device/lib/_fslt.sym | 560 + device/lib/_fsmul.c | 126 + device/lib/_fsmul.lst | 936 ++ device/lib/_fsmul.sym | 1179 +++ device/lib/_fsneq.c | 88 + device/lib/_fsneq.lst | 282 + device/lib/_fsneq.sym | 555 + device/lib/_fssub.c | 97 + device/lib/_fssub.lst | 289 + device/lib/_fssub.sym | 570 + device/lib/_gptrget.c | 83 + device/lib/_gptrget.lst | 116 + device/lib/_gptrget.sym | 391 + device/lib/_gptrput.c | 73 + device/lib/_gptrput.lst | 104 + device/lib/_gptrput.sym | 395 + device/lib/_int2fs.c | 111 + device/lib/_int2fs.lst | 340 + device/lib/_int2fs.sym | 602 ++ device/lib/_iscntrl.c | 33 + device/lib/_iscntrl.lst | 94 + device/lib/_iscntrl.sym | 382 + device/lib/_isdigit.c | 32 + device/lib/_isdigit.lst | 94 + device/lib/_isdigit.sym | 383 + device/lib/_isgraph.c | 31 + device/lib/_isgraph.lst | 94 + device/lib/_isgraph.sym | 383 + device/lib/_islower.c | 31 + device/lib/_islower.lst | 94 + device/lib/_islower.sym | 383 + device/lib/_isprint.c | 30 + device/lib/_isprint.lst | 94 + device/lib/_isprint.sym | 383 + device/lib/_ispunct.c | 35 + device/lib/_ispunct.lst | 123 + device/lib/_ispunct.sym | 409 + device/lib/_isspace.c | 35 + device/lib/_isspace.lst | 113 + device/lib/_isspace.sym | 388 + device/lib/_isupper.c | 30 + device/lib/_isupper.lst | 94 + device/lib/_isupper.sym | 383 + device/lib/_isxdigit.c | 34 + device/lib/_isxdigit.lst | 129 + device/lib/_isxdigit.sym | 401 + device/lib/_long2fs.c | 109 + device/lib/_long2fs.lst | 346 + device/lib/_long2fs.sym | 611 ++ device/lib/_memcmp.c | 42 + device/lib/_memcmp.lst | 208 + device/lib/_memcmp.sym | 481 + device/lib/_memcpy.c | 45 + device/lib/_memcpy.lst | 164 + device/lib/_memcpy.sym | 447 + device/lib/_memset.c | 42 + device/lib/_memset.lst | 143 + device/lib/_memset.sym | 429 + device/lib/_modsint.c | 37 + device/lib/_modsint.lst | 178 + device/lib/_modsint.sym | 456 + device/lib/_modslong.c | 35 + device/lib/_modslong.lst | 254 + device/lib/_modslong.sym | 529 + device/lib/_moduint.c | 53 + device/lib/_moduint.lst | 228 + device/lib/_moduint.sym | 495 + device/lib/_modulong.c | 52 + device/lib/_modulong.lst | 328 + device/lib/_modulong.sym | 592 ++ device/lib/_mulsint.c | 37 + device/lib/_mulsint.lst | 178 + device/lib/_mulsint.sym | 456 + device/lib/_muluint.c | 52 + device/lib/_muluint.lst | 133 + device/lib/_muluint.sym | 424 + device/lib/_mululong.c | 87 + device/lib/_mululong.lst | 362 + device/lib/_mululong.sym | 632 ++ device/lib/_muslong.c | 35 + device/lib/_muslong.lst | 254 + device/lib/_muslong.sym | 529 + device/lib/_ser.c | 157 + device/lib/_ser.lst | 636 ++ device/lib/_ser.sym | 781 ++ device/lib/_setjmp.c | 48 + device/lib/_setjmp.lst | 403 + device/lib/_setjmp.sym | 679 ++ device/lib/_spx.c | 26 + device/lib/_spx.lst | 48 + device/lib/_spx.sym | 355 + device/lib/_startup.c | 33 + device/lib/_startup.lst | 65 + device/lib/_startup.sym | 367 + device/lib/_strcat.c | 40 + device/lib/_strcat.lst | 162 + device/lib/_strcat.sym | 443 + device/lib/_strchr.c | 38 + device/lib/_strchr.lst | 159 + device/lib/_strchr.sym | 436 + device/lib/_strcmp.c | 43 + device/lib/_strcmp.lst | 217 + device/lib/_strcmp.sym | 487 + device/lib/_strcpy.c | 36 + device/lib/_strcpy.lst | 143 + device/lib/_strcpy.sym | 433 + device/lib/_strcspn.c | 43 + device/lib/_strcspn.lst | 152 + device/lib/_strcspn.sym | 440 + device/lib/_strlen.c | 35 + device/lib/_strlen.lst | 127 + device/lib/_strlen.sym | 418 + device/lib/_strncat.c | 45 + device/lib/_strncat.lst | 248 + device/lib/_strncat.sym | 518 + device/lib/_strncmp.c | 42 + device/lib/_strncmp.lst | 212 + device/lib/_strncmp.sym | 483 + device/lib/_strncpy.c | 37 + device/lib/_strncpy.lst | 172 + device/lib/_strncpy.sym | 456 + device/lib/_strpbrk.c | 40 + device/lib/_strpbrk.lst | 146 + device/lib/_strpbrk.sym | 434 + device/lib/_strrchr.c | 44 + device/lib/_strrchr.lst | 209 + device/lib/_strrchr.sym | 480 + device/lib/_strspn.c | 44 + device/lib/_strspn.lst | 174 + device/lib/_strspn.sym | 461 + device/lib/_strstr.c | 54 + device/lib/_strstr.lst | 233 + device/lib/_strstr.sym | 492 + device/lib/_strtok.c | 54 + device/lib/_strtok.lst | 223 + device/lib/_strtok.sym | 501 + device/lib/_uchar2fs.c | 110 + device/lib/_uchar2fs.lst | 334 + device/lib/_uchar2fs.sym | 596 ++ device/lib/_uint2fs.c | 110 + device/lib/_uint2fs.lst | 340 + device/lib/_uint2fs.sym | 602 ++ device/lib/_ulong2fs.c | 110 + device/lib/_ulong2fs.lst | 349 + device/lib/_ulong2fs.sym | 612 ++ device/lib/assert.c | 9 + device/lib/assert.lst | 144 + device/lib/assert.sym | 422 + device/lib/clean.mk | 28 + device/lib/conf.mk | 10 + device/lib/incl.mk | 1 + device/lib/large/_atoi.asm | 335 + device/lib/large/_atoi.cdb | 2 + device/lib/large/_atoi.rel | 363 + device/lib/large/_atol.asm | 397 + device/lib/large/_atol.cdb | 2 + device/lib/large/_atol.rel | 439 + device/lib/large/_autobaud.asm | 325 + device/lib/large/_autobaud.cdb | 85 + device/lib/large/_autobaud.rel | 210 + device/lib/large/_bp.asm | 48 + device/lib/large/_bp.cdb | 2 + device/lib/large/_bp.rel | 17 + device/lib/large/_char2fs.asm | 334 + device/lib/large/_char2fs.cdb | 2 + device/lib/large/_char2fs.rel | 345 + device/lib/large/_decdptr.asm | 70 + device/lib/large/_decdptr.cdb | 2 + device/lib/large/_decdptr.rel | 34 + device/lib/large/_divsint.asm | 180 + device/lib/large/_divsint.cdb | 2 + device/lib/large/_divsint.rel | 164 + device/lib/large/_divslong.asm | 254 + device/lib/large/_divslong.cdb | 2 + device/lib/large/_divslong.rel | 265 + device/lib/large/_divuint.asm | 215 + device/lib/large/_divuint.cdb | 2 + device/lib/large/_divuint.rel | 202 + device/lib/large/_divulong.asm | 319 + device/lib/large/_divulong.cdb | 2 + device/lib/large/_divulong.rel | 334 + device/lib/large/_fs2char.asm | 432 + device/lib/large/_fs2char.cdb | 2 + device/lib/large/_fs2char.rel | 487 + device/lib/large/_fs2int.asm | 439 + device/lib/large/_fs2int.cdb | 2 + device/lib/large/_fs2int.rel | 491 + device/lib/large/_fs2long.asm | 454 + device/lib/large/_fs2long.cdb | 2 + device/lib/large/_fs2long.rel | 508 + device/lib/large/_fs2uchar.asm | 422 + device/lib/large/_fs2uchar.cdb | 2 + device/lib/large/_fs2uchar.rel | 473 + device/lib/large/_fs2uint.asm | 436 + device/lib/large/_fs2uint.cdb | 2 + device/lib/large/_fs2uint.rel | 489 + device/lib/large/_fs2ulong.asm | 451 + device/lib/large/_fs2ulong.cdb | 2 + device/lib/large/_fs2ulong.rel | 506 + device/lib/large/_fsadd.asm | 1406 +++ device/lib/large/_fsadd.cdb | 2 + device/lib/large/_fsadd.rel | 1695 +++ device/lib/large/_fsdiv.asm | 936 ++ device/lib/large/_fsdiv.cdb | 2 + device/lib/large/_fsdiv.rel | 1124 ++ device/lib/large/_fseq.asm | 282 + device/lib/large/_fseq.cdb | 2 + device/lib/large/_fseq.rel | 295 + device/lib/large/_fsgt.asm | 284 + device/lib/large/_fsgt.cdb | 2 + device/lib/large/_fsgt.rel | 300 + device/lib/large/_fslt.asm | 284 + device/lib/large/_fslt.cdb | 2 + device/lib/large/_fslt.rel | 300 + device/lib/large/_fsmul.asm | 936 ++ device/lib/large/_fsmul.cdb | 2 + device/lib/large/_fsmul.rel | 1164 ++ device/lib/large/_fsneq.asm | 282 + device/lib/large/_fsneq.cdb | 2 + device/lib/large/_fsneq.rel | 295 + device/lib/large/_fssub.asm | 289 + device/lib/large/_fssub.cdb | 2 + device/lib/large/_fssub.rel | 288 + device/lib/large/_gptrget.asm | 116 + device/lib/large/_gptrget.cdb | 2 + device/lib/large/_gptrget.rel | 72 + device/lib/large/_gptrput.asm | 104 + device/lib/large/_gptrput.cdb | 2 + device/lib/large/_gptrput.rel | 76 + device/lib/large/_int2fs.asm | 340 + device/lib/large/_int2fs.cdb | 2 + device/lib/large/_int2fs.rel | 351 + device/lib/large/_iscntrl.asm | 94 + device/lib/large/_iscntrl.cdb | 2 + device/lib/large/_iscntrl.rel | 62 + device/lib/large/_isdigit.asm | 94 + device/lib/large/_isdigit.cdb | 2 + device/lib/large/_isdigit.rel | 63 + device/lib/large/_isgraph.asm | 94 + device/lib/large/_isgraph.cdb | 2 + device/lib/large/_isgraph.rel | 63 + device/lib/large/_islower.asm | 94 + device/lib/large/_islower.cdb | 2 + device/lib/large/_islower.rel | 63 + device/lib/large/_isprint.asm | 94 + device/lib/large/_isprint.cdb | 2 + device/lib/large/_isprint.rel | 63 + device/lib/large/_ispunct.asm | 123 + device/lib/large/_ispunct.cdb | 2 + device/lib/large/_ispunct.rel | 97 + device/lib/large/_isspace.asm | 113 + device/lib/large/_isspace.cdb | 2 + device/lib/large/_isspace.rel | 84 + device/lib/large/_isupper.asm | 94 + device/lib/large/_isupper.cdb | 2 + device/lib/large/_isupper.rel | 63 + device/lib/large/_isxdigit.asm | 129 + device/lib/large/_isxdigit.cdb | 2 + device/lib/large/_isxdigit.rel | 111 + device/lib/large/_long2fs.asm | 346 + device/lib/large/_long2fs.cdb | 2 + device/lib/large/_long2fs.rel | 359 + device/lib/large/_memcmp.asm | 208 + device/lib/large/_memcmp.cdb | 2 + device/lib/large/_memcmp.rel | 201 + device/lib/large/_memcpy.asm | 164 + device/lib/large/_memcpy.cdb | 2 + device/lib/large/_memcpy.rel | 163 + device/lib/large/_memset.asm | 143 + device/lib/large/_memset.cdb | 2 + device/lib/large/_memset.rel | 129 + device/lib/large/_modsint.asm | 178 + device/lib/large/_modsint.cdb | 2 + device/lib/large/_modsint.rel | 162 + device/lib/large/_modslong.asm | 254 + device/lib/large/_modslong.cdb | 2 + device/lib/large/_modslong.rel | 265 + device/lib/large/_moduint.asm | 228 + device/lib/large/_moduint.cdb | 2 + device/lib/large/_moduint.rel | 214 + device/lib/large/_modulong.asm | 328 + device/lib/large/_modulong.cdb | 2 + device/lib/large/_modulong.rel | 330 + device/lib/large/_mulsint.asm | 178 + device/lib/large/_mulsint.cdb | 2 + device/lib/large/_mulsint.rel | 162 + device/lib/large/_muluint.asm | 133 + device/lib/large/_muluint.cdb | 2 + device/lib/large/_muluint.rel | 105 + device/lib/large/_mululong.asm | 362 + device/lib/large/_mululong.cdb | 2 + device/lib/large/_mululong.rel | 351 + device/lib/large/_muslong.asm | 254 + device/lib/large/_muslong.cdb | 2 + device/lib/large/_muslong.rel | 265 + device/lib/large/_ser.asm | 636 ++ device/lib/large/_ser.cdb | 97 + device/lib/large/_ser.rel | 556 + device/lib/large/_setjmp.asm | 403 + device/lib/large/_setjmp.cdb | 86 + device/lib/large/_setjmp.rel | 306 + device/lib/large/_spx.asm | 48 + device/lib/large/_spx.cdb | 2 + device/lib/large/_spx.rel | 17 + device/lib/large/_startup.asm | 65 + device/lib/large/_startup.cdb | 2 + device/lib/large/_startup.rel | 26 + device/lib/large/_strcat.asm | 162 + device/lib/large/_strcat.cdb | 2 + device/lib/large/_strcat.rel | 156 + device/lib/large/_strchr.asm | 159 + device/lib/large/_strchr.cdb | 2 + device/lib/large/_strchr.rel | 138 + device/lib/large/_strcmp.asm | 217 + device/lib/large/_strcmp.cdb | 2 + device/lib/large/_strcmp.rel | 218 + device/lib/large/_strcpy.asm | 143 + device/lib/large/_strcpy.cdb | 2 + device/lib/large/_strcpy.rel | 130 + device/lib/large/_strcspn.asm | 152 + device/lib/large/_strcspn.cdb | 2 + device/lib/large/_strcspn.rel | 141 + device/lib/large/_strlen.asm | 127 + device/lib/large/_strlen.cdb | 2 + device/lib/large/_strlen.rel | 106 + device/lib/large/_strncat.asm | 248 + device/lib/large/_strncat.cdb | 2 + device/lib/large/_strncat.rel | 263 + device/lib/large/_strncmp.asm | 212 + device/lib/large/_strncmp.cdb | 2 + device/lib/large/_strncmp.rel | 205 + device/lib/large/_strncpy.asm | 172 + device/lib/large/_strncpy.cdb | 2 + device/lib/large/_strncpy.rel | 174 + device/lib/large/_strpbrk.asm | 146 + device/lib/large/_strpbrk.cdb | 2 + device/lib/large/_strpbrk.rel | 131 + device/lib/large/_strrchr.asm | 209 + device/lib/large/_strrchr.cdb | 2 + device/lib/large/_strrchr.rel | 209 + device/lib/large/_strspn.asm | 174 + device/lib/large/_strspn.cdb | 2 + device/lib/large/_strspn.rel | 168 + device/lib/large/_strstr.asm | 233 + device/lib/large/_strstr.cdb | 2 + device/lib/large/_strstr.rel | 243 + device/lib/large/_strtok.asm | 223 + device/lib/large/_strtok.cdb | 2 + device/lib/large/_strtok.rel | 218 + device/lib/large/_uchar2fs.asm | 334 + device/lib/large/_uchar2fs.cdb | 2 + device/lib/large/_uchar2fs.rel | 345 + device/lib/large/_uint2fs.asm | 340 + device/lib/large/_uint2fs.cdb | 2 + device/lib/large/_uint2fs.rel | 351 + device/lib/large/_ulong2fs.asm | 349 + device/lib/large/_ulong2fs.cdb | 2 + device/lib/large/_ulong2fs.rel | 363 + device/lib/large/assert.asm | 138 + device/lib/large/assert.cdb | 3 + device/lib/large/assert.rel | 113 + device/lib/large/malloc.asm | 593 ++ device/lib/large/malloc.cdb | 5 + device/lib/large/malloc.rel | 614 ++ device/lib/large/printf_large.cdb | 1 + device/lib/large/printfl.asm | 1384 +++ device/lib/large/printfl.cdb | 100 + device/lib/large/printfl.rel | 1475 +++ device/lib/large/puts.asm | 148 + device/lib/large/puts.cdb | 2 + device/lib/large/puts.rel | 136 + device/lib/large/ser_ir.asm | 765 ++ device/lib/large/ser_ir.cdb | 96 + device/lib/large/ser_ir.rel | 713 ++ device/lib/large/serial.asm | 515 + device/lib/large/serial.cdb | 98 + device/lib/large/serial.rel | 406 + device/lib/large/vprintf.asm | 1471 +++ device/lib/large/vprintf.cdb | 14 + device/lib/large/vprintf.rel | 1838 ++++ device/lib/libfloat.lib | 20 + device/lib/libint.lib | 6 + device/lib/liblong.lib | 6 + device/lib/libsdcc.lib | 42 + device/lib/malloc.c | 120 + device/lib/malloc.lst | 593 ++ device/lib/malloc.sym | 786 ++ device/lib/mcs51/README | 4 + device/lib/printf_large.c | 50 + device/lib/printfl.c | 214 + device/lib/printfl.lst | 1386 +++ device/lib/printfl.sym | 1407 +++ device/lib/puts.c | 36 + device/lib/puts.lst | 148 + device/lib/puts.sym | 438 + device/lib/ser_ir.c | 141 + device/lib/ser_ir.lst | 765 ++ device/lib/ser_ir.sym | 888 ++ device/lib/serial.c | 89 + device/lib/serial.lst | 515 + device/lib/serial.sym | 701 ++ device/lib/small/_atoi.asm | 247 + device/lib/small/_atoi.cdb | 2 + device/lib/small/_atoi.rel | 268 + device/lib/small/_atol.asm | 271 + device/lib/small/_atol.cdb | 2 + device/lib/small/_atol.rel | 300 + device/lib/small/_autobaud.asm | 325 + device/lib/small/_autobaud.cdb | 85 + device/lib/small/_autobaud.rel | 210 + device/lib/small/_bp.asm | 48 + device/lib/small/_bp.cdb | 2 + device/lib/small/_bp.rel | 17 + device/lib/small/_char2fs.asm | 214 + device/lib/small/_char2fs.cdb | 2 + device/lib/small/_char2fs.rel | 223 + device/lib/small/_decdptr.asm | 70 + device/lib/small/_decdptr.cdb | 2 + device/lib/small/_decdptr.rel | 34 + device/lib/small/_divsint.asm | 150 + device/lib/small/_divsint.cdb | 2 + device/lib/small/_divsint.rel | 130 + device/lib/small/_divslong.asm | 183 + device/lib/small/_divslong.cdb | 2 + device/lib/small/_divslong.rel | 184 + device/lib/small/_divuint.asm | 135 + device/lib/small/_divuint.cdb | 2 + device/lib/small/_divuint.rel | 104 + device/lib/small/_divulong.asm | 187 + device/lib/small/_divulong.cdb | 2 + device/lib/small/_divulong.rel | 184 + device/lib/small/_fs2char.asm | 248 + device/lib/small/_fs2char.cdb | 2 + device/lib/small/_fs2char.rel | 268 + device/lib/small/_fs2int.asm | 251 + device/lib/small/_fs2int.cdb | 2 + device/lib/small/_fs2int.rel | 269 + device/lib/small/_fs2long.asm | 264 + device/lib/small/_fs2long.cdb | 2 + device/lib/small/_fs2long.rel | 278 + device/lib/small/_fs2uchar.asm | 234 + device/lib/small/_fs2uchar.cdb | 2 + device/lib/small/_fs2uchar.rel | 250 + device/lib/small/_fs2uint.asm | 248 + device/lib/small/_fs2uint.cdb | 2 + device/lib/small/_fs2uint.rel | 266 + device/lib/small/_fs2ulong.asm | 264 + device/lib/small/_fs2ulong.cdb | 2 + device/lib/small/_fs2ulong.rel | 276 + device/lib/small/_fsadd.asm | 736 ++ device/lib/small/_fsadd.cdb | 2 + device/lib/small/_fsadd.rel | 934 ++ device/lib/small/_fsdiv.asm | 453 + device/lib/small/_fsdiv.cdb | 2 + device/lib/small/_fsdiv.rel | 554 + device/lib/small/_fseq.asm | 147 + device/lib/small/_fseq.cdb | 2 + device/lib/small/_fseq.rel | 136 + device/lib/small/_fsgt.asm | 149 + device/lib/small/_fsgt.cdb | 2 + device/lib/small/_fsgt.rel | 141 + device/lib/small/_fslt.asm | 149 + device/lib/small/_fslt.cdb | 2 + device/lib/small/_fslt.rel | 141 + device/lib/small/_fsmul.asm | 435 + device/lib/small/_fsmul.cdb | 2 + device/lib/small/_fsmul.rel | 522 + device/lib/small/_fsneq.asm | 147 + device/lib/small/_fsneq.cdb | 2 + device/lib/small/_fsneq.rel | 136 + device/lib/small/_fssub.asm | 140 + device/lib/small/_fssub.cdb | 2 + device/lib/small/_fssub.rel | 136 + device/lib/small/_gptrget.asm | 116 + device/lib/small/_gptrget.cdb | 2 + device/lib/small/_gptrget.rel | 72 + device/lib/small/_gptrput.asm | 104 + device/lib/small/_gptrput.cdb | 2 + device/lib/small/_gptrput.rel | 76 + device/lib/small/_int2fs.asm | 215 + device/lib/small/_int2fs.cdb | 2 + device/lib/small/_int2fs.rel | 224 + device/lib/small/_iscntrl.asm | 87 + device/lib/small/_iscntrl.cdb | 2 + device/lib/small/_iscntrl.rel | 51 + device/lib/small/_isdigit.asm | 87 + device/lib/small/_isdigit.cdb | 2 + device/lib/small/_isdigit.rel | 52 + device/lib/small/_isgraph.asm | 87 + device/lib/small/_isgraph.cdb | 2 + device/lib/small/_isgraph.rel | 52 + device/lib/small/_islower.asm | 87 + device/lib/small/_islower.cdb | 2 + device/lib/small/_islower.rel | 52 + device/lib/small/_isprint.asm | 87 + device/lib/small/_isprint.cdb | 2 + device/lib/small/_isprint.rel | 52 + device/lib/small/_ispunct.asm | 115 + device/lib/small/_ispunct.cdb | 2 + device/lib/small/_ispunct.rel | 87 + device/lib/small/_isspace.asm | 106 + device/lib/small/_isspace.cdb | 2 + device/lib/small/_isspace.rel | 73 + device/lib/small/_isupper.asm | 87 + device/lib/small/_isupper.cdb | 2 + device/lib/small/_isupper.rel | 52 + device/lib/small/_isxdigit.asm | 116 + device/lib/small/_isxdigit.cdb | 2 + device/lib/small/_isxdigit.rel | 94 + device/lib/small/_long2fs.asm | 209 + device/lib/small/_long2fs.cdb | 2 + device/lib/small/_long2fs.rel | 219 + device/lib/small/_memcmp.asm | 160 + device/lib/small/_memcmp.cdb | 2 + device/lib/small/_memcmp.rel | 144 + device/lib/small/_memcpy.asm | 139 + device/lib/small/_memcpy.cdb | 2 + device/lib/small/_memcpy.rel | 137 + device/lib/small/_memset.asm | 113 + device/lib/small/_memset.cdb | 2 + device/lib/small/_memset.rel | 95 + device/lib/small/_modsint.asm | 148 + device/lib/small/_modsint.cdb | 2 + device/lib/small/_modsint.rel | 128 + device/lib/small/_modslong.asm | 183 + device/lib/small/_modslong.cdb | 2 + device/lib/small/_modslong.rel | 184 + device/lib/small/_moduint.asm | 160 + device/lib/small/_moduint.cdb | 2 + device/lib/small/_moduint.rel | 133 + device/lib/small/_modulong.asm | 197 + device/lib/small/_modulong.cdb | 2 + device/lib/small/_modulong.rel | 187 + device/lib/small/_mulsint.asm | 148 + device/lib/small/_mulsint.cdb | 2 + device/lib/small/_mulsint.rel | 128 + device/lib/small/_muluint.asm | 98 + device/lib/small/_muluint.cdb | 2 + device/lib/small/_muluint.rel | 67 + device/lib/small/_mululong.asm | 194 + device/lib/small/_mululong.cdb | 2 + device/lib/small/_mululong.rel | 180 + device/lib/small/_muslong.asm | 183 + device/lib/small/_muslong.cdb | 2 + device/lib/small/_muslong.rel | 184 + device/lib/small/_ser.asm | 584 ++ device/lib/small/_ser.cdb | 97 + device/lib/small/_ser.rel | 487 + device/lib/small/_setjmp.asm | 338 + device/lib/small/_setjmp.cdb | 86 + device/lib/small/_setjmp.rel | 235 + device/lib/small/_spx.asm | 48 + device/lib/small/_spx.cdb | 2 + device/lib/small/_spx.rel | 17 + device/lib/small/_startup.asm | 65 + device/lib/small/_startup.cdb | 2 + device/lib/small/_startup.rel | 26 + device/lib/small/_strcat.asm | 127 + device/lib/small/_strcat.cdb | 2 + device/lib/small/_strcat.rel | 112 + device/lib/small/_strchr.asm | 114 + device/lib/small/_strchr.cdb | 2 + device/lib/small/_strchr.rel | 86 + device/lib/small/_strcmp.asm | 149 + device/lib/small/_strcmp.cdb | 2 + device/lib/small/_strcmp.rel | 136 + device/lib/small/_strcpy.asm | 108 + device/lib/small/_strcpy.cdb | 2 + device/lib/small/_strcpy.rel | 88 + device/lib/small/_strcspn.asm | 125 + device/lib/small/_strcspn.cdb | 2 + device/lib/small/_strcspn.rel | 112 + device/lib/small/_strlen.asm | 96 + device/lib/small/_strlen.cdb | 2 + device/lib/small/_strlen.rel | 67 + device/lib/small/_strncat.asm | 173 + device/lib/small/_strncat.cdb | 2 + device/lib/small/_strncat.rel | 180 + device/lib/small/_strncmp.asm | 156 + device/lib/small/_strncmp.cdb | 2 + device/lib/small/_strncmp.rel | 139 + device/lib/small/_strncpy.asm | 124 + device/lib/small/_strncpy.cdb | 2 + device/lib/small/_strncpy.rel | 112 + device/lib/small/_strpbrk.asm | 119 + device/lib/small/_strpbrk.cdb | 2 + device/lib/small/_strpbrk.rel | 98 + device/lib/small/_strrchr.asm | 142 + device/lib/small/_strrchr.cdb | 2 + device/lib/small/_strrchr.rel | 115 + device/lib/small/_strspn.asm | 134 + device/lib/small/_strspn.cdb | 2 + device/lib/small/_strspn.rel | 123 + device/lib/small/_strstr.asm | 188 + device/lib/small/_strstr.cdb | 2 + device/lib/small/_strstr.rel | 193 + device/lib/small/_strtok.asm | 169 + device/lib/small/_strtok.cdb | 2 + device/lib/small/_strtok.rel | 168 + device/lib/small/_uchar2fs.asm | 214 + device/lib/small/_uchar2fs.cdb | 2 + device/lib/small/_uchar2fs.rel | 223 + device/lib/small/_uint2fs.asm | 215 + device/lib/small/_uint2fs.cdb | 2 + device/lib/small/_uint2fs.rel | 224 + device/lib/small/_ulong2fs.asm | 214 + device/lib/small/_ulong2fs.cdb | 2 + device/lib/small/_ulong2fs.rel | 219 + device/lib/small/assert.asm | 96 + device/lib/small/assert.cdb | 3 + device/lib/small/assert.rel | 71 + device/lib/small/malloc.asm | 490 + device/lib/small/malloc.cdb | 5 + device/lib/small/malloc.rel | 487 + device/lib/small/printf_large.cdb | 1 + device/lib/small/printfl.asm | 1111 ++ device/lib/small/printfl.cdb | 100 + device/lib/small/printfl.rel | 1165 ++ device/lib/small/puts.asm | 125 + device/lib/small/puts.cdb | 2 + device/lib/small/puts.rel | 100 + device/lib/small/ser_ir.asm | 612 ++ device/lib/small/ser_ir.cdb | 96 + device/lib/small/ser_ir.rel | 547 + device/lib/small/serial.asm | 508 + device/lib/small/serial.cdb | 98 + device/lib/small/serial.rel | 394 + device/lib/small/vprintf.asm | 1237 +++ device/lib/small/vprintf.cdb | 14 + device/lib/small/vprintf.rel | 1581 +++ device/lib/vprintf.c | 421 + device/lib/vprintf.lst | 1471 +++ device/lib/vprintf.sym | 1314 +++ device/lib/z80/README | 4 + doc/SDCCBugsFixed.html | 1554 +++ doc/SDCCUdoc-1.html | 62 + doc/SDCCUdoc-10.html | 48 + doc/SDCCUdoc-11.html | 77 + doc/SDCCUdoc-12.html | 27 + doc/SDCCUdoc-13.html | 71 + doc/SDCCUdoc-14.html | 47 + doc/SDCCUdoc-15.html | 48 + doc/SDCCUdoc-16.html | 36 + doc/SDCCUdoc-17.html | 31 + doc/SDCCUdoc-18.html | 95 + doc/SDCCUdoc-19.html | 98 + doc/SDCCUdoc-2.html | 267 + doc/SDCCUdoc-20.html | 257 + doc/SDCCUdoc-21.html | 32 + doc/SDCCUdoc-22.html | 91 + doc/SDCCUdoc-23.html | 46 + doc/SDCCUdoc-24.html | 118 + doc/SDCCUdoc-25.html | 73 + doc/SDCCUdoc-26.html | 27 + doc/SDCCUdoc-27.html | 247 + doc/SDCCUdoc-28.html | 30 + doc/SDCCUdoc-29.html | 33 + doc/SDCCUdoc-3.html | 100 + doc/SDCCUdoc-4.html | 260 + doc/SDCCUdoc-5.html | 55 + doc/SDCCUdoc-6.html | 532 + doc/SDCCUdoc-7.html | 71 + doc/SDCCUdoc-8.html | 106 + doc/SDCCUdoc-9.html | 37 + doc/SDCCUdoc.html | 219 + doc/SDCCUdoc.lyx | 11652 +++++++++++++++++++++ doc/SDCCUdoc.sgml | 2520 +++++ doc/SDCCUdoc.txt | 2620 +++++ doc/SDCCWebPage.html | 399 + doc/avr/avr_design.txt | 107 + doc/cdbfile.html | 388 + doc/cygwininst.txt | 151 + doc/readme.dj | 41 + doc/z80/README | 6 + install-sh | 238 + link/README | 8 + link/z80/Makefile | 21 + link/z80/aslink.h | 713 ++ link/z80/lkarea.c | 431 + link/z80/lkdata.c | 465 + link/z80/lkeval.c | 396 + link/z80/lkgb.c | 190 + link/z80/lkgg.c | 79 + link/z80/lkhead.c | 154 + link/z80/lkihx.c | 134 + link/z80/lklex.c | 569 + link/z80/lklibr.c | 812 ++ link/z80/lklist.c | 1268 +++ link/z80/lkmain.c | 1405 +++ link/z80/lkrloc.c | 1169 +++ link/z80/lks19.c | 123 + link/z80/lksym.c | 494 + main_in.mk | 105 + sdccbuild.sh | 216 + sdccconf_in.h | 30 + sim/README | 6 + src/Makefile.in | 137 + src/README | 8 + src/SDCC.lex | 499 + src/SDCC.y | 1322 +++ src/SDCCBBlock.c | 577 + src/SDCCBBlock.h | 93 + src/SDCCast.c | 3630 +++++++ src/SDCCast.h | 182 + src/SDCCbitv.c | 367 + src/SDCCbitv.h | 60 + src/SDCCcflow.c | 411 + src/SDCCcflow.h | 44 + src/SDCCcse.c | 1435 +++ src/SDCCcse.h | 58 + src/SDCCdflow.c | 368 + src/SDCCdflow.h | 39 + src/SDCCerr.c | 169 + src/SDCCerr.h | 133 + src/SDCCgen51.c | 7383 +++++++++++++ src/SDCCgen51.h | 72 + src/SDCCglobl.h | 229 + src/SDCCglue.c | 1022 ++ src/SDCCglue.h | 32 + src/SDCChasht.c | 398 + src/SDCChasht.h | 113 + src/SDCCicode.c | 3019 ++++++ src/SDCCicode.h | 277 + src/SDCClabel.c | 441 + src/SDCClabel.h | 38 + src/SDCClex.c | 3040 ++++++ src/SDCCloop.c | 1124 ++ src/SDCCloop.h | 60 + src/SDCClrange.c | 523 + src/SDCClrange.h | 34 + src/SDCCmain.c | 1078 ++ src/SDCCmem.c | 776 ++ src/SDCCmem.h | 78 + src/SDCCopt.c | 826 ++ src/SDCCopt.h | 37 + src/SDCCpeeph.awk | 14 + src/SDCCpeeph.c | 721 ++ src/SDCCpeeph.def | 1626 +++ src/SDCCpeeph.h | 56 + src/SDCCpeeph.rul | 1602 +++ src/SDCCptropt.c | 189 + src/SDCCptropt.h | 31 + src/SDCCralloc.c | 2313 ++++ src/SDCCralloc.h | 58 + src/SDCCset.c | 500 + src/SDCCset.h | 95 + src/SDCCsymt.c | 1919 ++++ src/SDCCsymt.h | 422 + src/SDCCval.c | 1291 +++ src/SDCCval.h | 99 + src/SDCCy.c | 3093 ++++++ src/SDCCy.h | 118 + src/clean.mk | 26 + src/conf.mk | 10 + src/spawn.c | 66 + src/spawn.h | 13 + support/README | 5 + support/cpp/1 | 186 + support/cpp/Makefile | 100 + support/cpp/Makefile.dep | 7 + support/cpp/Makefile.in | 99 + support/cpp/Makefile.org | 14 + support/cpp/clean.mk | 24 + support/cpp/conf.mk | 10 + support/cpp/config.h | 4 + support/cpp/cpp.1 | 1 + support/cpp/cpp.aux | 132 + support/cpp/cpp.cps | 66 + support/cpp/cpp.fns | 94 + support/cpp/cpp.info | 75 + support/cpp/cpp.info-1 | 1189 +++ support/cpp/cpp.info-2 | 1032 ++ support/cpp/cpp.info-3 | 466 + support/cpp/cpp.texi | 2856 +++++ support/cpp/cppalloc.c | 60 + support/cpp/cpperror.c | 132 + support/cpp/cppexp.c | 998 ++ support/cpp/cpphash.c | 213 + support/cpp/cpphash.h | 38 + support/cpp/cpplib.c | 7542 +++++++++++++ support/cpp/cpplib.h | 651 ++ support/cpp/cppmain.c | 105 + support/cpp/i386/386bsd.h | 81 + support/cpp/i386/aix386.h | 69 + support/cpp/i386/aix386ng.h | 143 + support/cpp/i386/att.h | 106 + support/cpp/i386/bsd.h | 130 + support/cpp/i386/bsd386.h | 18 + support/cpp/i386/config-nt.sed | 38 + support/cpp/i386/freebsd.h | 250 + support/cpp/i386/gas.h | 155 + support/cpp/i386/gnu.h | 20 + support/cpp/i386/go32.h | 64 + support/cpp/i386/gstabs.h | 9 + support/cpp/i386/i386-aout.h | 34 + support/cpp/i386/i386-coff.h | 97 + support/cpp/i386/i386.c | 3245 ++++++ support/cpp/i386/i386.h | 1934 ++++ support/cpp/i386/i386.md | 5775 ++++++++++ support/cpp/i386/i386iscgas.h | 67 + support/cpp/i386/isc.h | 89 + support/cpp/i386/isccoff.h | 12 + support/cpp/i386/iscdbx.h | 43 + support/cpp/i386/linux-aout.h | 76 + support/cpp/i386/linux-oldld.h | 76 + support/cpp/i386/linux.h | 235 + support/cpp/i386/lynx-ng.h | 37 + support/cpp/i386/lynx.h | 39 + support/cpp/i386/mach.h | 20 + support/cpp/i386/netbsd.h | 80 + support/cpp/i386/next.c | 7 + support/cpp/i386/next.h | 226 + support/cpp/i386/os2.h | 76 + support/cpp/i386/osfelf.h | 79 + support/cpp/i386/osfrose.h | 923 ++ support/cpp/i386/perform.h | 98 + support/cpp/i386/sco.h | 117 + support/cpp/i386/sco4.h | 86 + support/cpp/i386/sco4dbx.h | 81 + support/cpp/i386/scodbx.h | 92 + support/cpp/i386/seq-gas.h | 46 + support/cpp/i386/seq-sysv3.h | 56 + support/cpp/i386/seq2-sysv3.h | 8 + support/cpp/i386/sequent.h | 152 + support/cpp/i386/sol2-c1.asm | 156 + support/cpp/i386/sol2-ci.asm | 51 + support/cpp/i386/sol2-cn.asm | 46 + support/cpp/i386/sol2.h | 91 + support/cpp/i386/sun.h | 83 + support/cpp/i386/sun386.h | 143 + support/cpp/i386/svr3.ifile | 45 + support/cpp/i386/svr3dbx.h | 97 + support/cpp/i386/svr3gas.h | 305 + support/cpp/i386/svr3z.ifile | 45 + support/cpp/i386/sysv3.h | 124 + support/cpp/i386/sysv4.h | 245 + support/cpp/i386/sysv4gdb.h | 7 + support/cpp/i386/t-crtpic | 9 + support/cpp/i386/t-crtstuff | 2 + support/cpp/i386/t-i386bare | 3 + support/cpp/i386/t-iscscodbx | 2 + support/cpp/i386/t-next | 9 + support/cpp/i386/t-sol2 | 32 + support/cpp/i386/t-svr3dbx | 7 + support/cpp/i386/t-vsta | 2 + support/cpp/i386/t-winnt | 2 + support/cpp/i386/tmp | 24 + support/cpp/i386/unix.h | 148 + support/cpp/i386/v3gas.h | 80 + support/cpp/i386/vsta.h | 78 + support/cpp/i386/win-nt.h | 152 + support/cpp/i386/winnt.c | 60 + support/cpp/i386/x-aix | 12 + support/cpp/i386/x-freebsd | 3 + support/cpp/i386/x-isc | 3 + support/cpp/i386/x-isc3 | 4 + support/cpp/i386/x-ncr3000 | 34 + support/cpp/i386/x-next | 3 + support/cpp/i386/x-osfrose | 31 + support/cpp/i386/x-sco | 7 + support/cpp/i386/x-sco4 | 10 + support/cpp/i386/x-sysv3 | 1 + support/cpp/i386/x-vsta | 1 + support/cpp/i386/xm-aix.h | 37 + support/cpp/i386/xm-bsd386.h | 6 + support/cpp/i386/xm-dos.h | 20 + support/cpp/i386/xm-freebsd.h | 4 + support/cpp/i386/xm-gnu.h | 5 + support/cpp/i386/xm-i386.h | 43 + support/cpp/i386/xm-isc.h | 6 + support/cpp/i386/xm-linux.h | 24 + support/cpp/i386/xm-lynx.h | 33 + support/cpp/i386/xm-netbsd.h | 4 + support/cpp/i386/xm-next.h | 5 + support/cpp/i386/xm-os2.h | 57 + support/cpp/i386/xm-osf.h | 32 + support/cpp/i386/xm-sco.h | 22 + support/cpp/i386/xm-sun.h | 27 + support/cpp/i386/xm-sysv3.h | 4 + support/cpp/i386/xm-sysv4.h | 16 + support/cpp/i386/xm-vsta.h | 26 + support/cpp/i386/xm-winnt.h | 24 + support/cpp/tm.h | 1 + support/cpp/winnt/Makefile | 6 + support/cpp/winnt/config-nt.bat | 51 + support/cpp/winnt/config-nt.sed | 130 + support/cpp/winnt/config.h | 1 + support/cpp/winnt/dirent.c | 360 + support/cpp/winnt/dirent.h | 96 + support/cpp/winnt/fixinc-nt.c | 260 + support/cpp/winnt/hconfig.h | 1 + support/cpp/winnt/headers.mak | 51 + support/cpp/winnt/ld.c | 348 + support/cpp/winnt/libgcc.mak | 19 + support/cpp/winnt/mklibgcc.c | 97 + support/cpp/winnt/multilib.h | 1 + support/cpp/winnt/oldnames.c | 47 + support/cpp/winnt/options.h | 1 + support/cpp/winnt/spawnv.c | 71 + support/cpp/winnt/specs.h | 1 + support/cpp/winnt/tconfig.h | 1 + support/cpp/winnt/tm.h | 1 + support/cpp/winnt/tmp | 69 + support/cpp/winnt/win-nt.h | 58 + support/cpp/winnt/x-winnt | 34 + support/cpp/winnt/xm-winnt.h | 69 + support/gc/BCC_MAKEFILE | 82 + support/gc/EMX_MAKEFILE | 141 + support/gc/MacOS.c | 154 + support/gc/MacProjects.sit.hqx | 886 ++ support/gc/Mac_files/MacOS_Test_config.h | 91 + support/gc/Mac_files/MacOS_config.h | 89 + support/gc/Mac_files/dataend.c | 9 + support/gc/Mac_files/datastart.c | 9 + support/gc/Makefile | 417 + support/gc/Makefile.DLLs | 107 + support/gc/Makefile.dj | 436 + support/gc/Makefile.in | 417 + support/gc/Makefile.org | 405 + support/gc/NT_MAKEFILE | 59 + support/gc/NT_THREADS_MAKEFILE | 2087 ++++ support/gc/OS2_MAKEFILE | 45 + support/gc/PCR-Makefile | 68 + support/gc/README | 1517 +++ support/gc/README.Mac | 385 + support/gc/README.OS2 | 6 + support/gc/README.QUICK | 41 + support/gc/README.alpha | 22 + support/gc/README.amiga | 180 + support/gc/README.debugging | 58 + support/gc/README.dj | 12 + support/gc/README.hp | 11 + support/gc/README.linux | 50 + support/gc/README.rs6000 | 9 + support/gc/README.sgi | 41 + support/gc/README.solaris2 | 65 + support/gc/README.uts | 2 + support/gc/README.win32 | 149 + support/gc/SCoptions.amiga | 16 + support/gc/SMakefile.amiga | 48 + support/gc/WCC_MAKEFILE | 196 + support/gc/add_gc_prefix.c | 14 + support/gc/allchblk.c | 726 ++ support/gc/alloc.c | 884 ++ support/gc/alpha_mach_dep.s | 60 + support/gc/barrett_diagram | 106 + support/gc/base_lib | 1 + support/gc/blacklst.c | 291 + support/gc/callprocs | 4 + support/gc/checksums.c | 201 + support/gc/clean.mk | 24 + support/gc/conf.mk | 10 + support/gc/cord/README | 31 + support/gc/cord/SCOPTIONS.amiga | 14 + support/gc/cord/SMakefile.amiga | 20 + support/gc/cord/cord.h | 327 + support/gc/cord/cordbscs.c | 916 ++ support/gc/cord/cordprnt.c | 389 + support/gc/cord/cordtest.c | 228 + support/gc/cord/cordxtra.c | 621 ++ support/gc/cord/de.c | 604 ++ support/gc/cord/de_cmds.h | 33 + support/gc/cord/de_win.ICO | Bin 0 -> 766 bytes support/gc/cord/de_win.RC | 78 + support/gc/cord/de_win.c | 366 + support/gc/cord/de_win.h | 103 + support/gc/cord/ec.h | 70 + support/gc/cord/gc.h | 720 ++ support/gc/cord/private/cord_pos.h | 118 + support/gc/dbg_mlc.c | 799 ++ support/gc/dyn_load.c | 799 ++ support/gc/finalize.c | 758 ++ support/gc/gc.h | 754 ++ support/gc/gc.mak | 2087 ++++ support/gc/gc.man | 80 + support/gc/gc_alloc.h | 380 + support/gc/gc_cpp.cc | 60 + support/gc/gc_cpp.h | 290 + support/gc/gc_hdrs.h | 135 + support/gc/gc_mark.h | 280 + support/gc/gc_priv.h | 1748 ++++ support/gc/gc_private.h | 1 + support/gc/gc_typed.h | 91 + support/gc/gc_watcom.asm | 51 + support/gc/gcc_support.c | 516 + support/gc/gcconfig.h | 1099 ++ support/gc/headers.c | 351 + support/gc/if_mach.c | 25 + support/gc/if_not_there.c | 26 + support/gc/include/cord.h | 327 + support/gc/include/ec.h | 70 + support/gc/include/gc.h | 720 ++ support/gc/include/gc_alloc.h | 380 + support/gc/include/gc_cpp.h | 288 + support/gc/include/gc_inl.h | 103 + support/gc/include/gc_inline.h | 1 + support/gc/include/gc_typed.h | 91 + support/gc/include/javaxfc.h | 41 + support/gc/include/new_gc_alloc.h | 456 + support/gc/include/private/cord_pos.h | 118 + support/gc/include/private/gc_hdrs.h | 133 + support/gc/include/private/gc_priv.h | 1661 +++ support/gc/include/private/gcconfig.h | 1033 ++ support/gc/include/weakpointer.h | 221 + support/gc/irix_threads.c | 674 ++ support/gc/linux_threads.c | 665 ++ support/gc/mach_dep.c | 444 + support/gc/makefile.depend | 0 support/gc/malloc.c | 443 + support/gc/mallocx.c | 375 + support/gc/mark.c | 1161 ++ support/gc/mark_rts.c | 484 + support/gc/mips_sgi_mach_dep.s | 40 + support/gc/mips_ultrix_mach_dep.s | 26 + support/gc/misc.c | 828 ++ support/gc/new_hblk.c | 244 + support/gc/obj_map.c | 142 + support/gc/os_dep.c | 2459 +++++ support/gc/pc_excludes | 15 + support/gc/pcr_interface.c | 173 + support/gc/ptr_chck.c | 326 + support/gc/real_malloc.c | 36 + support/gc/reclaim.c | 739 ++ support/gc/rs6000_mach_dep.s | 105 + support/gc/setjmp_t.c | 115 + support/gc/solaris_pthreads.c | 172 + support/gc/solaris_threads.c | 940 ++ support/gc/solaris_threads.h | 34 + support/gc/sparc_mach_dep.s | 38 + support/gc/sparc_sunos4_mach_dep.s | 38 + support/gc/stubborn.c | 317 + support/gc/test.c | 1263 +++ support/gc/test_cpp.cc | 265 + support/gc/threadlibs.c | 14 + support/gc/typd_mlc.c | 814 ++ support/gc/version.h | 11 + support/gc/weakpointer.h | 221 + support/gc/win32_threads.c | 209 + 1246 files changed, 366089 insertions(+) create mode 100644 .version create mode 100644 COPYING create mode 100644 Makefile create mode 100644 Makefile.org create mode 100644 README create mode 100644 as/README create mode 100644 as/doc/README create mode 100644 as/doc/abstra.doc create mode 100644 as/doc/appendk.txt create mode 100644 as/doc/asmlnk.doc create mode 100644 as/doc/asxhtm.html create mode 100644 as/doc/format.txt create mode 100644 as/mcs51/Makefile.aslink create mode 100644 as/mcs51/Makefile.asx8051 create mode 100644 as/mcs51/Makefile.in create mode 100644 as/mcs51/alloc.h create mode 100644 as/mcs51/asdata.c create mode 100644 as/mcs51/asexpr.c create mode 100644 as/mcs51/aslex.c create mode 100644 as/mcs51/aslink.h create mode 100644 as/mcs51/aslink.mak create mode 100644 as/mcs51/aslist.c create mode 100644 as/mcs51/asm.h create mode 100644 as/mcs51/asmain.c create mode 100644 as/mcs51/asnoice.c create mode 100644 as/mcs51/asout.c create mode 100644 as/mcs51/asstore.c create mode 100644 as/mcs51/assubr.c create mode 100644 as/mcs51/assym.c create mode 100644 as/mcs51/clean.mk create mode 100644 as/mcs51/conf.mk create mode 100644 as/mcs51/i51adr.c create mode 100644 as/mcs51/i51ext.c create mode 100644 as/mcs51/i51mch.c create mode 100644 as/mcs51/i51pst.c create mode 100644 as/mcs51/i8051.h create mode 100644 as/mcs51/lkarea.c create mode 100644 as/mcs51/lkdata.c create mode 100644 as/mcs51/lkeval.c create mode 100644 as/mcs51/lkhead.c create mode 100644 as/mcs51/lkihx.c create mode 100644 as/mcs51/lklex.c create mode 100644 as/mcs51/lklibr.c create mode 100644 as/mcs51/lklist.c create mode 100644 as/mcs51/lkmain.c create mode 100644 as/mcs51/lknoice.c create mode 100644 as/mcs51/lkrloc.c create mode 100644 as/mcs51/lks19.c create mode 100644 as/mcs51/lkstore.c create mode 100644 as/mcs51/lksym.c create mode 100644 as/mcs51/string.h create mode 100644 as/z80/Makefile create mode 100644 as/z80/alloc.h create mode 100644 as/z80/asdata.c create mode 100644 as/z80/asexpr.c create mode 100644 as/z80/aslex.c create mode 100644 as/z80/aslist.c create mode 100644 as/z80/asm.h create mode 100644 as/z80/asmain.c create mode 100644 as/z80/asout.c create mode 100644 as/z80/assubr.c create mode 100644 as/z80/assym.c create mode 100644 as/z80/incld1.asm create mode 100644 as/z80/incld2.asm create mode 100644 as/z80/incld3.asm create mode 100644 as/z80/incld4.asm create mode 100644 as/z80/incld5.asm create mode 100644 as/z80/itsta.asm create mode 100644 as/z80/itstb.asm create mode 100644 as/z80/string.h create mode 100644 as/z80/tconst.asm create mode 100644 as/z80/tz80.asm create mode 100644 as/z80/tz80l.asm create mode 100644 as/z80/z80.h create mode 100644 as/z80/z80adr.c create mode 100644 as/z80/z80ext.c create mode 100644 as/z80/z80mch.c create mode 100644 as/z80/z80pst.c create mode 100644 clean.mk create mode 100644 conf.mk create mode 100755 configure create mode 100755 configure.in create mode 100644 debugger/Makefile create mode 100644 debugger/README create mode 100644 debugger/mcs51/Makefile create mode 100644 debugger/mcs51/Makefile.dep create mode 100644 debugger/mcs51/Makefile.in create mode 100644 debugger/mcs51/break.c create mode 100644 debugger/mcs51/break.h create mode 100644 debugger/mcs51/clean.mk create mode 100644 debugger/mcs51/cmd.c create mode 100644 debugger/mcs51/cmd.h create mode 100644 debugger/mcs51/conf.mk create mode 100644 debugger/mcs51/sdcdb.c create mode 100644 debugger/mcs51/sdcdb.el create mode 100644 debugger/mcs51/sdcdb.h create mode 100644 debugger/mcs51/sdcdbsrc.el create mode 100644 debugger/mcs51/simi.c create mode 100644 debugger/mcs51/simi.h create mode 100644 debugger/mcs51/symtab.c create mode 100644 debugger/mcs51/symtab.h create mode 100644 device/README create mode 100644 device/examples/an429.c create mode 100644 device/examples/clean.mk create mode 100644 device/examples/cpu_tools.c create mode 100644 device/examples/cpu_tools.h create mode 100644 device/examples/crc.c create mode 100644 device/examples/crcs.c create mode 100644 device/examples/itoa.c create mode 100644 device/examples/ltoa.c create mode 100644 device/examples/main8051.c create mode 100644 device/examples/test2.c create mode 100644 device/include/Makefile.in create mode 100644 device/include/assert.h create mode 100644 device/include/at89S8252.h create mode 100644 device/include/at89c55.h create mode 100644 device/include/at89x1051.h create mode 100644 device/include/at89x2051.h create mode 100644 device/include/at89x51.h create mode 100644 device/include/at89x52.h create mode 100644 device/include/canc515c.h create mode 100644 device/include/clean.mk create mode 100644 device/include/conf.mk create mode 100644 device/include/ctype.h create mode 100644 device/include/float.h create mode 100644 device/include/limits.h create mode 100644 device/include/malloc.h create mode 100644 device/include/math.h create mode 100644 device/include/mcs51/README create mode 100644 device/include/reg51.h create mode 100644 device/include/reg515.h create mode 100644 device/include/reg552.h create mode 100644 device/include/regc515c.h create mode 100644 device/include/sab80515.h create mode 100644 device/include/ser.h create mode 100644 device/include/ser_ir.h create mode 100644 device/include/serial.h create mode 100644 device/include/setjmp.h create mode 100644 device/include/stdarg.h create mode 100644 device/include/stdio.h create mode 100644 device/include/stdlib.h create mode 100644 device/include/string.h create mode 100644 device/include/z80/README create mode 100644 device/lib/Makefile create mode 100644 device/lib/Makefile.dep create mode 100644 device/lib/Makefile.in create mode 100644 device/lib/_atoi.c create mode 100644 device/lib/_atoi.lst create mode 100644 device/lib/_atoi.sym create mode 100644 device/lib/_atol.c create mode 100644 device/lib/_atol.lst create mode 100644 device/lib/_atol.sym create mode 100644 device/lib/_autobaud.c create mode 100644 device/lib/_autobaud.lst create mode 100644 device/lib/_autobaud.sym create mode 100644 device/lib/_bp.c create mode 100644 device/lib/_bp.lst create mode 100644 device/lib/_bp.sym create mode 100644 device/lib/_char2fs.c create mode 100644 device/lib/_char2fs.lst create mode 100644 device/lib/_char2fs.sym create mode 100644 device/lib/_decdptr.c create mode 100644 device/lib/_decdptr.lst create mode 100644 device/lib/_decdptr.sym create mode 100644 device/lib/_divsint.c create mode 100644 device/lib/_divsint.lst create mode 100644 device/lib/_divsint.sym create mode 100644 device/lib/_divslong.c create mode 100644 device/lib/_divslong.lst create mode 100644 device/lib/_divslong.sym create mode 100644 device/lib/_divuint.c create mode 100644 device/lib/_divuint.lst create mode 100644 device/lib/_divuint.sym create mode 100644 device/lib/_divulong.c create mode 100644 device/lib/_divulong.lst create mode 100644 device/lib/_divulong.sym create mode 100644 device/lib/_fs2char.c create mode 100644 device/lib/_fs2char.lst create mode 100644 device/lib/_fs2char.sym create mode 100644 device/lib/_fs2int.c create mode 100644 device/lib/_fs2int.lst create mode 100644 device/lib/_fs2int.sym create mode 100644 device/lib/_fs2long.c create mode 100644 device/lib/_fs2long.lst create mode 100644 device/lib/_fs2long.sym create mode 100644 device/lib/_fs2uchar.c create mode 100644 device/lib/_fs2uchar.lst create mode 100644 device/lib/_fs2uchar.sym create mode 100644 device/lib/_fs2uint.c create mode 100644 device/lib/_fs2uint.lst create mode 100644 device/lib/_fs2uint.sym create mode 100644 device/lib/_fs2ulong.c create mode 100644 device/lib/_fs2ulong.lst create mode 100644 device/lib/_fs2ulong.sym create mode 100644 device/lib/_fsadd.c create mode 100644 device/lib/_fsadd.lst create mode 100644 device/lib/_fsadd.sym create mode 100644 device/lib/_fsdiv.c create mode 100644 device/lib/_fsdiv.lst create mode 100644 device/lib/_fsdiv.sym create mode 100644 device/lib/_fseq.c create mode 100644 device/lib/_fseq.lst create mode 100644 device/lib/_fseq.sym create mode 100644 device/lib/_fsgt.c create mode 100644 device/lib/_fsgt.lst create mode 100644 device/lib/_fsgt.sym create mode 100644 device/lib/_fslt.c create mode 100644 device/lib/_fslt.lst create mode 100644 device/lib/_fslt.sym create mode 100644 device/lib/_fsmul.c create mode 100644 device/lib/_fsmul.lst create mode 100644 device/lib/_fsmul.sym create mode 100644 device/lib/_fsneq.c create mode 100644 device/lib/_fsneq.lst create mode 100644 device/lib/_fsneq.sym create mode 100644 device/lib/_fssub.c create mode 100644 device/lib/_fssub.lst create mode 100644 device/lib/_fssub.sym create mode 100644 device/lib/_gptrget.c create mode 100644 device/lib/_gptrget.lst create mode 100644 device/lib/_gptrget.sym create mode 100644 device/lib/_gptrput.c create mode 100644 device/lib/_gptrput.lst create mode 100644 device/lib/_gptrput.sym create mode 100644 device/lib/_int2fs.c create mode 100644 device/lib/_int2fs.lst create mode 100644 device/lib/_int2fs.sym create mode 100644 device/lib/_iscntrl.c create mode 100644 device/lib/_iscntrl.lst create mode 100644 device/lib/_iscntrl.sym create mode 100644 device/lib/_isdigit.c create mode 100644 device/lib/_isdigit.lst create mode 100644 device/lib/_isdigit.sym create mode 100644 device/lib/_isgraph.c create mode 100644 device/lib/_isgraph.lst create mode 100644 device/lib/_isgraph.sym create mode 100644 device/lib/_islower.c create mode 100644 device/lib/_islower.lst create mode 100644 device/lib/_islower.sym create mode 100644 device/lib/_isprint.c create mode 100644 device/lib/_isprint.lst create mode 100644 device/lib/_isprint.sym create mode 100644 device/lib/_ispunct.c create mode 100644 device/lib/_ispunct.lst create mode 100644 device/lib/_ispunct.sym create mode 100644 device/lib/_isspace.c create mode 100644 device/lib/_isspace.lst create mode 100644 device/lib/_isspace.sym create mode 100644 device/lib/_isupper.c create mode 100644 device/lib/_isupper.lst create mode 100644 device/lib/_isupper.sym create mode 100644 device/lib/_isxdigit.c create mode 100644 device/lib/_isxdigit.lst create mode 100644 device/lib/_isxdigit.sym create mode 100644 device/lib/_long2fs.c create mode 100644 device/lib/_long2fs.lst create mode 100644 device/lib/_long2fs.sym create mode 100644 device/lib/_memcmp.c create mode 100644 device/lib/_memcmp.lst create mode 100644 device/lib/_memcmp.sym create mode 100644 device/lib/_memcpy.c create mode 100644 device/lib/_memcpy.lst create mode 100644 device/lib/_memcpy.sym create mode 100644 device/lib/_memset.c create mode 100644 device/lib/_memset.lst create mode 100644 device/lib/_memset.sym create mode 100644 device/lib/_modsint.c create mode 100644 device/lib/_modsint.lst create mode 100644 device/lib/_modsint.sym create mode 100644 device/lib/_modslong.c create mode 100644 device/lib/_modslong.lst create mode 100644 device/lib/_modslong.sym create mode 100644 device/lib/_moduint.c create mode 100644 device/lib/_moduint.lst create mode 100644 device/lib/_moduint.sym create mode 100644 device/lib/_modulong.c create mode 100644 device/lib/_modulong.lst create mode 100644 device/lib/_modulong.sym create mode 100644 device/lib/_mulsint.c create mode 100644 device/lib/_mulsint.lst create mode 100644 device/lib/_mulsint.sym create mode 100644 device/lib/_muluint.c create mode 100644 device/lib/_muluint.lst create mode 100644 device/lib/_muluint.sym create mode 100644 device/lib/_mululong.c create mode 100644 device/lib/_mululong.lst create mode 100644 device/lib/_mululong.sym create mode 100644 device/lib/_muslong.c create mode 100644 device/lib/_muslong.lst create mode 100644 device/lib/_muslong.sym create mode 100644 device/lib/_ser.c create mode 100644 device/lib/_ser.lst create mode 100644 device/lib/_ser.sym create mode 100644 device/lib/_setjmp.c create mode 100644 device/lib/_setjmp.lst create mode 100644 device/lib/_setjmp.sym create mode 100644 device/lib/_spx.c create mode 100644 device/lib/_spx.lst create mode 100644 device/lib/_spx.sym create mode 100644 device/lib/_startup.c create mode 100644 device/lib/_startup.lst create mode 100644 device/lib/_startup.sym create mode 100644 device/lib/_strcat.c create mode 100644 device/lib/_strcat.lst create mode 100644 device/lib/_strcat.sym create mode 100644 device/lib/_strchr.c create mode 100644 device/lib/_strchr.lst create mode 100644 device/lib/_strchr.sym create mode 100644 device/lib/_strcmp.c create mode 100644 device/lib/_strcmp.lst create mode 100644 device/lib/_strcmp.sym create mode 100644 device/lib/_strcpy.c create mode 100644 device/lib/_strcpy.lst create mode 100644 device/lib/_strcpy.sym create mode 100644 device/lib/_strcspn.c create mode 100644 device/lib/_strcspn.lst create mode 100644 device/lib/_strcspn.sym create mode 100644 device/lib/_strlen.c create mode 100644 device/lib/_strlen.lst create mode 100644 device/lib/_strlen.sym create mode 100644 device/lib/_strncat.c create mode 100644 device/lib/_strncat.lst create mode 100644 device/lib/_strncat.sym create mode 100644 device/lib/_strncmp.c create mode 100644 device/lib/_strncmp.lst create mode 100644 device/lib/_strncmp.sym create mode 100644 device/lib/_strncpy.c create mode 100644 device/lib/_strncpy.lst create mode 100644 device/lib/_strncpy.sym create mode 100644 device/lib/_strpbrk.c create mode 100644 device/lib/_strpbrk.lst create mode 100644 device/lib/_strpbrk.sym create mode 100644 device/lib/_strrchr.c create mode 100644 device/lib/_strrchr.lst create mode 100644 device/lib/_strrchr.sym create mode 100644 device/lib/_strspn.c create mode 100644 device/lib/_strspn.lst create mode 100644 device/lib/_strspn.sym create mode 100644 device/lib/_strstr.c create mode 100644 device/lib/_strstr.lst create mode 100644 device/lib/_strstr.sym create mode 100644 device/lib/_strtok.c create mode 100644 device/lib/_strtok.lst create mode 100644 device/lib/_strtok.sym create mode 100644 device/lib/_uchar2fs.c create mode 100644 device/lib/_uchar2fs.lst create mode 100644 device/lib/_uchar2fs.sym create mode 100644 device/lib/_uint2fs.c create mode 100644 device/lib/_uint2fs.lst create mode 100644 device/lib/_uint2fs.sym create mode 100644 device/lib/_ulong2fs.c create mode 100644 device/lib/_ulong2fs.lst create mode 100644 device/lib/_ulong2fs.sym create mode 100644 device/lib/assert.c create mode 100644 device/lib/assert.lst create mode 100644 device/lib/assert.sym create mode 100644 device/lib/clean.mk create mode 100644 device/lib/conf.mk create mode 100644 device/lib/incl.mk create mode 100644 device/lib/large/_atoi.asm create mode 100644 device/lib/large/_atoi.cdb create mode 100644 device/lib/large/_atoi.rel create mode 100644 device/lib/large/_atol.asm create mode 100644 device/lib/large/_atol.cdb create mode 100644 device/lib/large/_atol.rel create mode 100644 device/lib/large/_autobaud.asm create mode 100644 device/lib/large/_autobaud.cdb create mode 100644 device/lib/large/_autobaud.rel create mode 100644 device/lib/large/_bp.asm create mode 100644 device/lib/large/_bp.cdb create mode 100644 device/lib/large/_bp.rel create mode 100644 device/lib/large/_char2fs.asm create mode 100644 device/lib/large/_char2fs.cdb create mode 100644 device/lib/large/_char2fs.rel create mode 100644 device/lib/large/_decdptr.asm create mode 100644 device/lib/large/_decdptr.cdb create mode 100644 device/lib/large/_decdptr.rel create mode 100644 device/lib/large/_divsint.asm create mode 100644 device/lib/large/_divsint.cdb create mode 100644 device/lib/large/_divsint.rel create mode 100644 device/lib/large/_divslong.asm create mode 100644 device/lib/large/_divslong.cdb create mode 100644 device/lib/large/_divslong.rel create mode 100644 device/lib/large/_divuint.asm create mode 100644 device/lib/large/_divuint.cdb create mode 100644 device/lib/large/_divuint.rel create mode 100644 device/lib/large/_divulong.asm create mode 100644 device/lib/large/_divulong.cdb create mode 100644 device/lib/large/_divulong.rel create mode 100644 device/lib/large/_fs2char.asm create mode 100644 device/lib/large/_fs2char.cdb create mode 100644 device/lib/large/_fs2char.rel create mode 100644 device/lib/large/_fs2int.asm create mode 100644 device/lib/large/_fs2int.cdb create mode 100644 device/lib/large/_fs2int.rel create mode 100644 device/lib/large/_fs2long.asm create mode 100644 device/lib/large/_fs2long.cdb create mode 100644 device/lib/large/_fs2long.rel create mode 100644 device/lib/large/_fs2uchar.asm create mode 100644 device/lib/large/_fs2uchar.cdb create mode 100644 device/lib/large/_fs2uchar.rel create mode 100644 device/lib/large/_fs2uint.asm create mode 100644 device/lib/large/_fs2uint.cdb create mode 100644 device/lib/large/_fs2uint.rel create mode 100644 device/lib/large/_fs2ulong.asm create mode 100644 device/lib/large/_fs2ulong.cdb create mode 100644 device/lib/large/_fs2ulong.rel create mode 100644 device/lib/large/_fsadd.asm create mode 100644 device/lib/large/_fsadd.cdb create mode 100644 device/lib/large/_fsadd.rel create mode 100644 device/lib/large/_fsdiv.asm create mode 100644 device/lib/large/_fsdiv.cdb create mode 100644 device/lib/large/_fsdiv.rel create mode 100644 device/lib/large/_fseq.asm create mode 100644 device/lib/large/_fseq.cdb create mode 100644 device/lib/large/_fseq.rel create mode 100644 device/lib/large/_fsgt.asm create mode 100644 device/lib/large/_fsgt.cdb create mode 100644 device/lib/large/_fsgt.rel create mode 100644 device/lib/large/_fslt.asm create mode 100644 device/lib/large/_fslt.cdb create mode 100644 device/lib/large/_fslt.rel create mode 100644 device/lib/large/_fsmul.asm create mode 100644 device/lib/large/_fsmul.cdb create mode 100644 device/lib/large/_fsmul.rel create mode 100644 device/lib/large/_fsneq.asm create mode 100644 device/lib/large/_fsneq.cdb create mode 100644 device/lib/large/_fsneq.rel create mode 100644 device/lib/large/_fssub.asm create mode 100644 device/lib/large/_fssub.cdb create mode 100644 device/lib/large/_fssub.rel create mode 100644 device/lib/large/_gptrget.asm create mode 100644 device/lib/large/_gptrget.cdb create mode 100644 device/lib/large/_gptrget.rel create mode 100644 device/lib/large/_gptrput.asm create mode 100644 device/lib/large/_gptrput.cdb create mode 100644 device/lib/large/_gptrput.rel create mode 100644 device/lib/large/_int2fs.asm create mode 100644 device/lib/large/_int2fs.cdb create mode 100644 device/lib/large/_int2fs.rel create mode 100644 device/lib/large/_iscntrl.asm create mode 100644 device/lib/large/_iscntrl.cdb create mode 100644 device/lib/large/_iscntrl.rel create mode 100644 device/lib/large/_isdigit.asm create mode 100644 device/lib/large/_isdigit.cdb create mode 100644 device/lib/large/_isdigit.rel create mode 100644 device/lib/large/_isgraph.asm create mode 100644 device/lib/large/_isgraph.cdb create mode 100644 device/lib/large/_isgraph.rel create mode 100644 device/lib/large/_islower.asm create mode 100644 device/lib/large/_islower.cdb create mode 100644 device/lib/large/_islower.rel create mode 100644 device/lib/large/_isprint.asm create mode 100644 device/lib/large/_isprint.cdb create mode 100644 device/lib/large/_isprint.rel create mode 100644 device/lib/large/_ispunct.asm create mode 100644 device/lib/large/_ispunct.cdb create mode 100644 device/lib/large/_ispunct.rel create mode 100644 device/lib/large/_isspace.asm create mode 100644 device/lib/large/_isspace.cdb create mode 100644 device/lib/large/_isspace.rel create mode 100644 device/lib/large/_isupper.asm create mode 100644 device/lib/large/_isupper.cdb create mode 100644 device/lib/large/_isupper.rel create mode 100644 device/lib/large/_isxdigit.asm create mode 100644 device/lib/large/_isxdigit.cdb create mode 100644 device/lib/large/_isxdigit.rel create mode 100644 device/lib/large/_long2fs.asm create mode 100644 device/lib/large/_long2fs.cdb create mode 100644 device/lib/large/_long2fs.rel create mode 100644 device/lib/large/_memcmp.asm create mode 100644 device/lib/large/_memcmp.cdb create mode 100644 device/lib/large/_memcmp.rel create mode 100644 device/lib/large/_memcpy.asm create mode 100644 device/lib/large/_memcpy.cdb create mode 100644 device/lib/large/_memcpy.rel create mode 100644 device/lib/large/_memset.asm create mode 100644 device/lib/large/_memset.cdb create mode 100644 device/lib/large/_memset.rel create mode 100644 device/lib/large/_modsint.asm create mode 100644 device/lib/large/_modsint.cdb create mode 100644 device/lib/large/_modsint.rel create mode 100644 device/lib/large/_modslong.asm create mode 100644 device/lib/large/_modslong.cdb create mode 100644 device/lib/large/_modslong.rel create mode 100644 device/lib/large/_moduint.asm create mode 100644 device/lib/large/_moduint.cdb create mode 100644 device/lib/large/_moduint.rel create mode 100644 device/lib/large/_modulong.asm create mode 100644 device/lib/large/_modulong.cdb create mode 100644 device/lib/large/_modulong.rel create mode 100644 device/lib/large/_mulsint.asm create mode 100644 device/lib/large/_mulsint.cdb create mode 100644 device/lib/large/_mulsint.rel create mode 100644 device/lib/large/_muluint.asm create mode 100644 device/lib/large/_muluint.cdb create mode 100644 device/lib/large/_muluint.rel create mode 100644 device/lib/large/_mululong.asm create mode 100644 device/lib/large/_mululong.cdb create mode 100644 device/lib/large/_mululong.rel create mode 100644 device/lib/large/_muslong.asm create mode 100644 device/lib/large/_muslong.cdb create mode 100644 device/lib/large/_muslong.rel create mode 100644 device/lib/large/_ser.asm create mode 100644 device/lib/large/_ser.cdb create mode 100644 device/lib/large/_ser.rel create mode 100644 device/lib/large/_setjmp.asm create mode 100644 device/lib/large/_setjmp.cdb create mode 100644 device/lib/large/_setjmp.rel create mode 100644 device/lib/large/_spx.asm create mode 100644 device/lib/large/_spx.cdb create mode 100644 device/lib/large/_spx.rel create mode 100644 device/lib/large/_startup.asm create mode 100644 device/lib/large/_startup.cdb create mode 100644 device/lib/large/_startup.rel create mode 100644 device/lib/large/_strcat.asm create mode 100644 device/lib/large/_strcat.cdb create mode 100644 device/lib/large/_strcat.rel create mode 100644 device/lib/large/_strchr.asm create mode 100644 device/lib/large/_strchr.cdb create mode 100644 device/lib/large/_strchr.rel create mode 100644 device/lib/large/_strcmp.asm create mode 100644 device/lib/large/_strcmp.cdb create mode 100644 device/lib/large/_strcmp.rel create mode 100644 device/lib/large/_strcpy.asm create mode 100644 device/lib/large/_strcpy.cdb create mode 100644 device/lib/large/_strcpy.rel create mode 100644 device/lib/large/_strcspn.asm create mode 100644 device/lib/large/_strcspn.cdb create mode 100644 device/lib/large/_strcspn.rel create mode 100644 device/lib/large/_strlen.asm create mode 100644 device/lib/large/_strlen.cdb create mode 100644 device/lib/large/_strlen.rel create mode 100644 device/lib/large/_strncat.asm create mode 100644 device/lib/large/_strncat.cdb create mode 100644 device/lib/large/_strncat.rel create mode 100644 device/lib/large/_strncmp.asm create mode 100644 device/lib/large/_strncmp.cdb create mode 100644 device/lib/large/_strncmp.rel create mode 100644 device/lib/large/_strncpy.asm create mode 100644 device/lib/large/_strncpy.cdb create mode 100644 device/lib/large/_strncpy.rel create mode 100644 device/lib/large/_strpbrk.asm create mode 100644 device/lib/large/_strpbrk.cdb create mode 100644 device/lib/large/_strpbrk.rel create mode 100644 device/lib/large/_strrchr.asm create mode 100644 device/lib/large/_strrchr.cdb create mode 100644 device/lib/large/_strrchr.rel create mode 100644 device/lib/large/_strspn.asm create mode 100644 device/lib/large/_strspn.cdb create mode 100644 device/lib/large/_strspn.rel create mode 100644 device/lib/large/_strstr.asm create mode 100644 device/lib/large/_strstr.cdb create mode 100644 device/lib/large/_strstr.rel create mode 100644 device/lib/large/_strtok.asm create mode 100644 device/lib/large/_strtok.cdb create mode 100644 device/lib/large/_strtok.rel create mode 100644 device/lib/large/_uchar2fs.asm create mode 100644 device/lib/large/_uchar2fs.cdb create mode 100644 device/lib/large/_uchar2fs.rel create mode 100644 device/lib/large/_uint2fs.asm create mode 100644 device/lib/large/_uint2fs.cdb create mode 100644 device/lib/large/_uint2fs.rel create mode 100644 device/lib/large/_ulong2fs.asm create mode 100644 device/lib/large/_ulong2fs.cdb create mode 100644 device/lib/large/_ulong2fs.rel create mode 100644 device/lib/large/assert.asm create mode 100644 device/lib/large/assert.cdb create mode 100644 device/lib/large/assert.rel create mode 100644 device/lib/large/malloc.asm create mode 100644 device/lib/large/malloc.cdb create mode 100644 device/lib/large/malloc.rel create mode 100644 device/lib/large/printf_large.cdb create mode 100644 device/lib/large/printfl.asm create mode 100644 device/lib/large/printfl.cdb create mode 100644 device/lib/large/printfl.rel create mode 100644 device/lib/large/puts.asm create mode 100644 device/lib/large/puts.cdb create mode 100644 device/lib/large/puts.rel create mode 100644 device/lib/large/ser_ir.asm create mode 100644 device/lib/large/ser_ir.cdb create mode 100644 device/lib/large/ser_ir.rel create mode 100644 device/lib/large/serial.asm create mode 100644 device/lib/large/serial.cdb create mode 100644 device/lib/large/serial.rel create mode 100644 device/lib/large/vprintf.asm create mode 100644 device/lib/large/vprintf.cdb create mode 100644 device/lib/large/vprintf.rel create mode 100644 device/lib/libfloat.lib create mode 100644 device/lib/libint.lib create mode 100644 device/lib/liblong.lib create mode 100644 device/lib/libsdcc.lib create mode 100644 device/lib/malloc.c create mode 100644 device/lib/malloc.lst create mode 100644 device/lib/malloc.sym create mode 100644 device/lib/mcs51/README create mode 100644 device/lib/printf_large.c create mode 100644 device/lib/printfl.c create mode 100644 device/lib/printfl.lst create mode 100644 device/lib/printfl.sym create mode 100644 device/lib/puts.c create mode 100644 device/lib/puts.lst create mode 100644 device/lib/puts.sym create mode 100644 device/lib/ser_ir.c create mode 100644 device/lib/ser_ir.lst create mode 100644 device/lib/ser_ir.sym create mode 100644 device/lib/serial.c create mode 100644 device/lib/serial.lst create mode 100644 device/lib/serial.sym create mode 100644 device/lib/small/_atoi.asm create mode 100644 device/lib/small/_atoi.cdb create mode 100644 device/lib/small/_atoi.rel create mode 100644 device/lib/small/_atol.asm create mode 100644 device/lib/small/_atol.cdb create mode 100644 device/lib/small/_atol.rel create mode 100644 device/lib/small/_autobaud.asm create mode 100644 device/lib/small/_autobaud.cdb create mode 100644 device/lib/small/_autobaud.rel create mode 100644 device/lib/small/_bp.asm create mode 100644 device/lib/small/_bp.cdb create mode 100644 device/lib/small/_bp.rel create mode 100644 device/lib/small/_char2fs.asm create mode 100644 device/lib/small/_char2fs.cdb create mode 100644 device/lib/small/_char2fs.rel create mode 100644 device/lib/small/_decdptr.asm create mode 100644 device/lib/small/_decdptr.cdb create mode 100644 device/lib/small/_decdptr.rel create mode 100644 device/lib/small/_divsint.asm create mode 100644 device/lib/small/_divsint.cdb create mode 100644 device/lib/small/_divsint.rel create mode 100644 device/lib/small/_divslong.asm create mode 100644 device/lib/small/_divslong.cdb create mode 100644 device/lib/small/_divslong.rel create mode 100644 device/lib/small/_divuint.asm create mode 100644 device/lib/small/_divuint.cdb create mode 100644 device/lib/small/_divuint.rel create mode 100644 device/lib/small/_divulong.asm create mode 100644 device/lib/small/_divulong.cdb create mode 100644 device/lib/small/_divulong.rel create mode 100644 device/lib/small/_fs2char.asm create mode 100644 device/lib/small/_fs2char.cdb create mode 100644 device/lib/small/_fs2char.rel create mode 100644 device/lib/small/_fs2int.asm create mode 100644 device/lib/small/_fs2int.cdb create mode 100644 device/lib/small/_fs2int.rel create mode 100644 device/lib/small/_fs2long.asm create mode 100644 device/lib/small/_fs2long.cdb create mode 100644 device/lib/small/_fs2long.rel create mode 100644 device/lib/small/_fs2uchar.asm create mode 100644 device/lib/small/_fs2uchar.cdb create mode 100644 device/lib/small/_fs2uchar.rel create mode 100644 device/lib/small/_fs2uint.asm create mode 100644 device/lib/small/_fs2uint.cdb create mode 100644 device/lib/small/_fs2uint.rel create mode 100644 device/lib/small/_fs2ulong.asm create mode 100644 device/lib/small/_fs2ulong.cdb create mode 100644 device/lib/small/_fs2ulong.rel create mode 100644 device/lib/small/_fsadd.asm create mode 100644 device/lib/small/_fsadd.cdb create mode 100644 device/lib/small/_fsadd.rel create mode 100644 device/lib/small/_fsdiv.asm create mode 100644 device/lib/small/_fsdiv.cdb create mode 100644 device/lib/small/_fsdiv.rel create mode 100644 device/lib/small/_fseq.asm create mode 100644 device/lib/small/_fseq.cdb create mode 100644 device/lib/small/_fseq.rel create mode 100644 device/lib/small/_fsgt.asm create mode 100644 device/lib/small/_fsgt.cdb create mode 100644 device/lib/small/_fsgt.rel create mode 100644 device/lib/small/_fslt.asm create mode 100644 device/lib/small/_fslt.cdb create mode 100644 device/lib/small/_fslt.rel create mode 100644 device/lib/small/_fsmul.asm create mode 100644 device/lib/small/_fsmul.cdb create mode 100644 device/lib/small/_fsmul.rel create mode 100644 device/lib/small/_fsneq.asm create mode 100644 device/lib/small/_fsneq.cdb create mode 100644 device/lib/small/_fsneq.rel create mode 100644 device/lib/small/_fssub.asm create mode 100644 device/lib/small/_fssub.cdb create mode 100644 device/lib/small/_fssub.rel create mode 100644 device/lib/small/_gptrget.asm create mode 100644 device/lib/small/_gptrget.cdb create mode 100644 device/lib/small/_gptrget.rel create mode 100644 device/lib/small/_gptrput.asm create mode 100644 device/lib/small/_gptrput.cdb create mode 100644 device/lib/small/_gptrput.rel create mode 100644 device/lib/small/_int2fs.asm create mode 100644 device/lib/small/_int2fs.cdb create mode 100644 device/lib/small/_int2fs.rel create mode 100644 device/lib/small/_iscntrl.asm create mode 100644 device/lib/small/_iscntrl.cdb create mode 100644 device/lib/small/_iscntrl.rel create mode 100644 device/lib/small/_isdigit.asm create mode 100644 device/lib/small/_isdigit.cdb create mode 100644 device/lib/small/_isdigit.rel create mode 100644 device/lib/small/_isgraph.asm create mode 100644 device/lib/small/_isgraph.cdb create mode 100644 device/lib/small/_isgraph.rel create mode 100644 device/lib/small/_islower.asm create mode 100644 device/lib/small/_islower.cdb create mode 100644 device/lib/small/_islower.rel create mode 100644 device/lib/small/_isprint.asm create mode 100644 device/lib/small/_isprint.cdb create mode 100644 device/lib/small/_isprint.rel create mode 100644 device/lib/small/_ispunct.asm create mode 100644 device/lib/small/_ispunct.cdb create mode 100644 device/lib/small/_ispunct.rel create mode 100644 device/lib/small/_isspace.asm create mode 100644 device/lib/small/_isspace.cdb create mode 100644 device/lib/small/_isspace.rel create mode 100644 device/lib/small/_isupper.asm create mode 100644 device/lib/small/_isupper.cdb create mode 100644 device/lib/small/_isupper.rel create mode 100644 device/lib/small/_isxdigit.asm create mode 100644 device/lib/small/_isxdigit.cdb create mode 100644 device/lib/small/_isxdigit.rel create mode 100644 device/lib/small/_long2fs.asm create mode 100644 device/lib/small/_long2fs.cdb create mode 100644 device/lib/small/_long2fs.rel create mode 100644 device/lib/small/_memcmp.asm create mode 100644 device/lib/small/_memcmp.cdb create mode 100644 device/lib/small/_memcmp.rel create mode 100644 device/lib/small/_memcpy.asm create mode 100644 device/lib/small/_memcpy.cdb create mode 100644 device/lib/small/_memcpy.rel create mode 100644 device/lib/small/_memset.asm create mode 100644 device/lib/small/_memset.cdb create mode 100644 device/lib/small/_memset.rel create mode 100644 device/lib/small/_modsint.asm create mode 100644 device/lib/small/_modsint.cdb create mode 100644 device/lib/small/_modsint.rel create mode 100644 device/lib/small/_modslong.asm create mode 100644 device/lib/small/_modslong.cdb create mode 100644 device/lib/small/_modslong.rel create mode 100644 device/lib/small/_moduint.asm create mode 100644 device/lib/small/_moduint.cdb create mode 100644 device/lib/small/_moduint.rel create mode 100644 device/lib/small/_modulong.asm create mode 100644 device/lib/small/_modulong.cdb create mode 100644 device/lib/small/_modulong.rel create mode 100644 device/lib/small/_mulsint.asm create mode 100644 device/lib/small/_mulsint.cdb create mode 100644 device/lib/small/_mulsint.rel create mode 100644 device/lib/small/_muluint.asm create mode 100644 device/lib/small/_muluint.cdb create mode 100644 device/lib/small/_muluint.rel create mode 100644 device/lib/small/_mululong.asm create mode 100644 device/lib/small/_mululong.cdb create mode 100644 device/lib/small/_mululong.rel create mode 100644 device/lib/small/_muslong.asm create mode 100644 device/lib/small/_muslong.cdb create mode 100644 device/lib/small/_muslong.rel create mode 100644 device/lib/small/_ser.asm create mode 100644 device/lib/small/_ser.cdb create mode 100644 device/lib/small/_ser.rel create mode 100644 device/lib/small/_setjmp.asm create mode 100644 device/lib/small/_setjmp.cdb create mode 100644 device/lib/small/_setjmp.rel create mode 100644 device/lib/small/_spx.asm create mode 100644 device/lib/small/_spx.cdb create mode 100644 device/lib/small/_spx.rel create mode 100644 device/lib/small/_startup.asm create mode 100644 device/lib/small/_startup.cdb create mode 100644 device/lib/small/_startup.rel create mode 100644 device/lib/small/_strcat.asm create mode 100644 device/lib/small/_strcat.cdb create mode 100644 device/lib/small/_strcat.rel create mode 100644 device/lib/small/_strchr.asm create mode 100644 device/lib/small/_strchr.cdb create mode 100644 device/lib/small/_strchr.rel create mode 100644 device/lib/small/_strcmp.asm create mode 100644 device/lib/small/_strcmp.cdb create mode 100644 device/lib/small/_strcmp.rel create mode 100644 device/lib/small/_strcpy.asm create mode 100644 device/lib/small/_strcpy.cdb create mode 100644 device/lib/small/_strcpy.rel create mode 100644 device/lib/small/_strcspn.asm create mode 100644 device/lib/small/_strcspn.cdb create mode 100644 device/lib/small/_strcspn.rel create mode 100644 device/lib/small/_strlen.asm create mode 100644 device/lib/small/_strlen.cdb create mode 100644 device/lib/small/_strlen.rel create mode 100644 device/lib/small/_strncat.asm create mode 100644 device/lib/small/_strncat.cdb create mode 100644 device/lib/small/_strncat.rel create mode 100644 device/lib/small/_strncmp.asm create mode 100644 device/lib/small/_strncmp.cdb create mode 100644 device/lib/small/_strncmp.rel create mode 100644 device/lib/small/_strncpy.asm create mode 100644 device/lib/small/_strncpy.cdb create mode 100644 device/lib/small/_strncpy.rel create mode 100644 device/lib/small/_strpbrk.asm create mode 100644 device/lib/small/_strpbrk.cdb create mode 100644 device/lib/small/_strpbrk.rel create mode 100644 device/lib/small/_strrchr.asm create mode 100644 device/lib/small/_strrchr.cdb create mode 100644 device/lib/small/_strrchr.rel create mode 100644 device/lib/small/_strspn.asm create mode 100644 device/lib/small/_strspn.cdb create mode 100644 device/lib/small/_strspn.rel create mode 100644 device/lib/small/_strstr.asm create mode 100644 device/lib/small/_strstr.cdb create mode 100644 device/lib/small/_strstr.rel create mode 100644 device/lib/small/_strtok.asm create mode 100644 device/lib/small/_strtok.cdb create mode 100644 device/lib/small/_strtok.rel create mode 100644 device/lib/small/_uchar2fs.asm create mode 100644 device/lib/small/_uchar2fs.cdb create mode 100644 device/lib/small/_uchar2fs.rel create mode 100644 device/lib/small/_uint2fs.asm create mode 100644 device/lib/small/_uint2fs.cdb create mode 100644 device/lib/small/_uint2fs.rel create mode 100644 device/lib/small/_ulong2fs.asm create mode 100644 device/lib/small/_ulong2fs.cdb create mode 100644 device/lib/small/_ulong2fs.rel create mode 100644 device/lib/small/assert.asm create mode 100644 device/lib/small/assert.cdb create mode 100644 device/lib/small/assert.rel create mode 100644 device/lib/small/malloc.asm create mode 100644 device/lib/small/malloc.cdb create mode 100644 device/lib/small/malloc.rel create mode 100644 device/lib/small/printf_large.cdb create mode 100644 device/lib/small/printfl.asm create mode 100644 device/lib/small/printfl.cdb create mode 100644 device/lib/small/printfl.rel create mode 100644 device/lib/small/puts.asm create mode 100644 device/lib/small/puts.cdb create mode 100644 device/lib/small/puts.rel create mode 100644 device/lib/small/ser_ir.asm create mode 100644 device/lib/small/ser_ir.cdb create mode 100644 device/lib/small/ser_ir.rel create mode 100644 device/lib/small/serial.asm create mode 100644 device/lib/small/serial.cdb create mode 100644 device/lib/small/serial.rel create mode 100644 device/lib/small/vprintf.asm create mode 100644 device/lib/small/vprintf.cdb create mode 100644 device/lib/small/vprintf.rel create mode 100644 device/lib/vprintf.c create mode 100644 device/lib/vprintf.lst create mode 100644 device/lib/vprintf.sym create mode 100644 device/lib/z80/README create mode 100644 doc/SDCCBugsFixed.html create mode 100644 doc/SDCCUdoc-1.html create mode 100644 doc/SDCCUdoc-10.html create mode 100644 doc/SDCCUdoc-11.html create mode 100644 doc/SDCCUdoc-12.html create mode 100644 doc/SDCCUdoc-13.html create mode 100644 doc/SDCCUdoc-14.html create mode 100644 doc/SDCCUdoc-15.html create mode 100644 doc/SDCCUdoc-16.html create mode 100644 doc/SDCCUdoc-17.html create mode 100644 doc/SDCCUdoc-18.html create mode 100644 doc/SDCCUdoc-19.html create mode 100644 doc/SDCCUdoc-2.html create mode 100644 doc/SDCCUdoc-20.html create mode 100644 doc/SDCCUdoc-21.html create mode 100644 doc/SDCCUdoc-22.html create mode 100644 doc/SDCCUdoc-23.html create mode 100644 doc/SDCCUdoc-24.html create mode 100644 doc/SDCCUdoc-25.html create mode 100644 doc/SDCCUdoc-26.html create mode 100644 doc/SDCCUdoc-27.html create mode 100644 doc/SDCCUdoc-28.html create mode 100644 doc/SDCCUdoc-29.html create mode 100644 doc/SDCCUdoc-3.html create mode 100644 doc/SDCCUdoc-4.html create mode 100644 doc/SDCCUdoc-5.html create mode 100644 doc/SDCCUdoc-6.html create mode 100644 doc/SDCCUdoc-7.html create mode 100644 doc/SDCCUdoc-8.html create mode 100644 doc/SDCCUdoc-9.html create mode 100644 doc/SDCCUdoc.html create mode 100644 doc/SDCCUdoc.lyx create mode 100644 doc/SDCCUdoc.sgml create mode 100644 doc/SDCCUdoc.txt create mode 100644 doc/SDCCWebPage.html create mode 100644 doc/avr/avr_design.txt create mode 100644 doc/cdbfile.html create mode 100644 doc/cygwininst.txt create mode 100644 doc/readme.dj create mode 100644 doc/z80/README create mode 100755 install-sh create mode 100644 link/README create mode 100644 link/z80/Makefile create mode 100644 link/z80/aslink.h create mode 100644 link/z80/lkarea.c create mode 100644 link/z80/lkdata.c create mode 100644 link/z80/lkeval.c create mode 100644 link/z80/lkgb.c create mode 100644 link/z80/lkgg.c create mode 100644 link/z80/lkhead.c create mode 100644 link/z80/lkihx.c create mode 100644 link/z80/lklex.c create mode 100644 link/z80/lklibr.c create mode 100644 link/z80/lklist.c create mode 100644 link/z80/lkmain.c create mode 100644 link/z80/lkrloc.c create mode 100644 link/z80/lks19.c create mode 100644 link/z80/lksym.c create mode 100644 main_in.mk create mode 100644 sdccbuild.sh create mode 100644 sdccconf_in.h create mode 100644 sim/README create mode 100644 src/Makefile.in create mode 100644 src/README create mode 100644 src/SDCC.lex create mode 100644 src/SDCC.y create mode 100644 src/SDCCBBlock.c create mode 100644 src/SDCCBBlock.h create mode 100644 src/SDCCast.c create mode 100644 src/SDCCast.h create mode 100644 src/SDCCbitv.c create mode 100644 src/SDCCbitv.h create mode 100644 src/SDCCcflow.c create mode 100644 src/SDCCcflow.h create mode 100644 src/SDCCcse.c create mode 100644 src/SDCCcse.h create mode 100644 src/SDCCdflow.c create mode 100644 src/SDCCdflow.h create mode 100644 src/SDCCerr.c create mode 100644 src/SDCCerr.h create mode 100644 src/SDCCgen51.c create mode 100644 src/SDCCgen51.h create mode 100644 src/SDCCglobl.h create mode 100644 src/SDCCglue.c create mode 100644 src/SDCCglue.h create mode 100644 src/SDCChasht.c create mode 100644 src/SDCChasht.h create mode 100644 src/SDCCicode.c create mode 100644 src/SDCCicode.h create mode 100644 src/SDCClabel.c create mode 100644 src/SDCClabel.h create mode 100644 src/SDCClex.c create mode 100644 src/SDCCloop.c create mode 100644 src/SDCCloop.h create mode 100644 src/SDCClrange.c create mode 100644 src/SDCClrange.h create mode 100644 src/SDCCmain.c create mode 100644 src/SDCCmem.c create mode 100644 src/SDCCmem.h create mode 100644 src/SDCCopt.c create mode 100644 src/SDCCopt.h create mode 100644 src/SDCCpeeph.awk create mode 100644 src/SDCCpeeph.c create mode 100644 src/SDCCpeeph.def create mode 100644 src/SDCCpeeph.h create mode 100644 src/SDCCpeeph.rul create mode 100644 src/SDCCptropt.c create mode 100644 src/SDCCptropt.h create mode 100644 src/SDCCralloc.c create mode 100644 src/SDCCralloc.h create mode 100644 src/SDCCset.c create mode 100644 src/SDCCset.h create mode 100644 src/SDCCsymt.c create mode 100644 src/SDCCsymt.h create mode 100644 src/SDCCval.c create mode 100644 src/SDCCval.h create mode 100644 src/SDCCy.c create mode 100644 src/SDCCy.h create mode 100644 src/clean.mk create mode 100644 src/conf.mk create mode 100644 src/spawn.c create mode 100644 src/spawn.h create mode 100644 support/README create mode 100644 support/cpp/1 create mode 100644 support/cpp/Makefile create mode 100644 support/cpp/Makefile.dep create mode 100644 support/cpp/Makefile.in create mode 100644 support/cpp/Makefile.org create mode 100644 support/cpp/clean.mk create mode 100644 support/cpp/conf.mk create mode 100644 support/cpp/config.h create mode 100644 support/cpp/cpp.1 create mode 100644 support/cpp/cpp.aux create mode 100644 support/cpp/cpp.cps create mode 100644 support/cpp/cpp.fns create mode 100644 support/cpp/cpp.info create mode 100644 support/cpp/cpp.info-1 create mode 100644 support/cpp/cpp.info-2 create mode 100644 support/cpp/cpp.info-3 create mode 100644 support/cpp/cpp.texi create mode 100644 support/cpp/cppalloc.c create mode 100644 support/cpp/cpperror.c create mode 100644 support/cpp/cppexp.c create mode 100644 support/cpp/cpphash.c create mode 100644 support/cpp/cpphash.h create mode 100644 support/cpp/cpplib.c create mode 100644 support/cpp/cpplib.h create mode 100644 support/cpp/cppmain.c create mode 100644 support/cpp/i386/386bsd.h create mode 100644 support/cpp/i386/aix386.h create mode 100644 support/cpp/i386/aix386ng.h create mode 100644 support/cpp/i386/att.h create mode 100644 support/cpp/i386/bsd.h create mode 100644 support/cpp/i386/bsd386.h create mode 100644 support/cpp/i386/config-nt.sed create mode 100644 support/cpp/i386/freebsd.h create mode 100644 support/cpp/i386/gas.h create mode 100644 support/cpp/i386/gnu.h create mode 100644 support/cpp/i386/go32.h create mode 100644 support/cpp/i386/gstabs.h create mode 100644 support/cpp/i386/i386-aout.h create mode 100644 support/cpp/i386/i386-coff.h create mode 100644 support/cpp/i386/i386.c create mode 100644 support/cpp/i386/i386.h create mode 100644 support/cpp/i386/i386.md create mode 100644 support/cpp/i386/i386iscgas.h create mode 100644 support/cpp/i386/isc.h create mode 100644 support/cpp/i386/isccoff.h create mode 100644 support/cpp/i386/iscdbx.h create mode 100644 support/cpp/i386/linux-aout.h create mode 100644 support/cpp/i386/linux-oldld.h create mode 100644 support/cpp/i386/linux.h create mode 100644 support/cpp/i386/lynx-ng.h create mode 100644 support/cpp/i386/lynx.h create mode 100644 support/cpp/i386/mach.h create mode 100644 support/cpp/i386/netbsd.h create mode 100644 support/cpp/i386/next.c create mode 100644 support/cpp/i386/next.h create mode 100644 support/cpp/i386/os2.h create mode 100644 support/cpp/i386/osfelf.h create mode 100644 support/cpp/i386/osfrose.h create mode 100644 support/cpp/i386/perform.h create mode 100644 support/cpp/i386/sco.h create mode 100644 support/cpp/i386/sco4.h create mode 100644 support/cpp/i386/sco4dbx.h create mode 100644 support/cpp/i386/scodbx.h create mode 100644 support/cpp/i386/seq-gas.h create mode 100644 support/cpp/i386/seq-sysv3.h create mode 100644 support/cpp/i386/seq2-sysv3.h create mode 100644 support/cpp/i386/sequent.h create mode 100644 support/cpp/i386/sol2-c1.asm create mode 100644 support/cpp/i386/sol2-ci.asm create mode 100644 support/cpp/i386/sol2-cn.asm create mode 100644 support/cpp/i386/sol2.h create mode 100644 support/cpp/i386/sun.h create mode 100644 support/cpp/i386/sun386.h create mode 100644 support/cpp/i386/svr3.ifile create mode 100644 support/cpp/i386/svr3dbx.h create mode 100644 support/cpp/i386/svr3gas.h create mode 100644 support/cpp/i386/svr3z.ifile create mode 100644 support/cpp/i386/sysv3.h create mode 100644 support/cpp/i386/sysv4.h create mode 100644 support/cpp/i386/sysv4gdb.h create mode 100644 support/cpp/i386/t-crtpic create mode 100644 support/cpp/i386/t-crtstuff create mode 100644 support/cpp/i386/t-i386bare create mode 100644 support/cpp/i386/t-iscscodbx create mode 100644 support/cpp/i386/t-next create mode 100644 support/cpp/i386/t-sol2 create mode 100644 support/cpp/i386/t-svr3dbx create mode 100644 support/cpp/i386/t-vsta create mode 100644 support/cpp/i386/t-winnt create mode 100644 support/cpp/i386/tmp create mode 100644 support/cpp/i386/unix.h create mode 100644 support/cpp/i386/v3gas.h create mode 100644 support/cpp/i386/vsta.h create mode 100644 support/cpp/i386/win-nt.h create mode 100644 support/cpp/i386/winnt.c create mode 100644 support/cpp/i386/x-aix create mode 100644 support/cpp/i386/x-freebsd create mode 100644 support/cpp/i386/x-isc create mode 100644 support/cpp/i386/x-isc3 create mode 100644 support/cpp/i386/x-ncr3000 create mode 100644 support/cpp/i386/x-next create mode 100644 support/cpp/i386/x-osfrose create mode 100644 support/cpp/i386/x-sco create mode 100644 support/cpp/i386/x-sco4 create mode 100644 support/cpp/i386/x-sysv3 create mode 100644 support/cpp/i386/x-vsta create mode 100644 support/cpp/i386/xm-aix.h create mode 100644 support/cpp/i386/xm-bsd386.h create mode 100644 support/cpp/i386/xm-dos.h create mode 100644 support/cpp/i386/xm-freebsd.h create mode 100644 support/cpp/i386/xm-gnu.h create mode 100644 support/cpp/i386/xm-i386.h create mode 100644 support/cpp/i386/xm-isc.h create mode 100644 support/cpp/i386/xm-linux.h create mode 100644 support/cpp/i386/xm-lynx.h create mode 100644 support/cpp/i386/xm-netbsd.h create mode 100644 support/cpp/i386/xm-next.h create mode 100644 support/cpp/i386/xm-os2.h create mode 100644 support/cpp/i386/xm-osf.h create mode 100644 support/cpp/i386/xm-sco.h create mode 100644 support/cpp/i386/xm-sun.h create mode 100644 support/cpp/i386/xm-sysv3.h create mode 100644 support/cpp/i386/xm-sysv4.h create mode 100644 support/cpp/i386/xm-vsta.h create mode 100644 support/cpp/i386/xm-winnt.h create mode 100644 support/cpp/tm.h create mode 100644 support/cpp/winnt/Makefile create mode 100755 support/cpp/winnt/config-nt.bat create mode 100644 support/cpp/winnt/config-nt.sed create mode 100644 support/cpp/winnt/config.h create mode 100644 support/cpp/winnt/dirent.c create mode 100644 support/cpp/winnt/dirent.h create mode 100644 support/cpp/winnt/fixinc-nt.c create mode 100644 support/cpp/winnt/hconfig.h create mode 100644 support/cpp/winnt/headers.mak create mode 100644 support/cpp/winnt/ld.c create mode 100644 support/cpp/winnt/libgcc.mak create mode 100644 support/cpp/winnt/mklibgcc.c create mode 100644 support/cpp/winnt/multilib.h create mode 100644 support/cpp/winnt/oldnames.c create mode 100644 support/cpp/winnt/options.h create mode 100644 support/cpp/winnt/spawnv.c create mode 100644 support/cpp/winnt/specs.h create mode 100644 support/cpp/winnt/tconfig.h create mode 100644 support/cpp/winnt/tm.h create mode 100644 support/cpp/winnt/tmp create mode 100644 support/cpp/winnt/win-nt.h create mode 100644 support/cpp/winnt/x-winnt create mode 100644 support/cpp/winnt/xm-winnt.h create mode 100644 support/gc/BCC_MAKEFILE create mode 100644 support/gc/EMX_MAKEFILE create mode 100644 support/gc/MacOS.c create mode 100644 support/gc/MacProjects.sit.hqx create mode 100644 support/gc/Mac_files/MacOS_Test_config.h create mode 100644 support/gc/Mac_files/MacOS_config.h create mode 100644 support/gc/Mac_files/dataend.c create mode 100644 support/gc/Mac_files/datastart.c create mode 100644 support/gc/Makefile create mode 100644 support/gc/Makefile.DLLs create mode 100644 support/gc/Makefile.dj create mode 100644 support/gc/Makefile.in create mode 100644 support/gc/Makefile.org create mode 100644 support/gc/NT_MAKEFILE create mode 100644 support/gc/NT_THREADS_MAKEFILE create mode 100644 support/gc/OS2_MAKEFILE create mode 100644 support/gc/PCR-Makefile create mode 100644 support/gc/README create mode 100644 support/gc/README.Mac create mode 100644 support/gc/README.OS2 create mode 100644 support/gc/README.QUICK create mode 100644 support/gc/README.alpha create mode 100644 support/gc/README.amiga create mode 100644 support/gc/README.debugging create mode 100644 support/gc/README.dj create mode 100644 support/gc/README.hp create mode 100644 support/gc/README.linux create mode 100644 support/gc/README.rs6000 create mode 100644 support/gc/README.sgi create mode 100644 support/gc/README.solaris2 create mode 100644 support/gc/README.uts create mode 100644 support/gc/README.win32 create mode 100644 support/gc/SCoptions.amiga create mode 100644 support/gc/SMakefile.amiga create mode 100644 support/gc/WCC_MAKEFILE create mode 100644 support/gc/add_gc_prefix.c create mode 100644 support/gc/allchblk.c create mode 100644 support/gc/alloc.c create mode 100644 support/gc/alpha_mach_dep.s create mode 100644 support/gc/barrett_diagram create mode 100644 support/gc/base_lib create mode 100644 support/gc/blacklst.c create mode 100755 support/gc/callprocs create mode 100644 support/gc/checksums.c create mode 100644 support/gc/clean.mk create mode 100644 support/gc/conf.mk create mode 100644 support/gc/cord/README create mode 100644 support/gc/cord/SCOPTIONS.amiga create mode 100644 support/gc/cord/SMakefile.amiga create mode 100644 support/gc/cord/cord.h create mode 100644 support/gc/cord/cordbscs.c create mode 100644 support/gc/cord/cordprnt.c create mode 100644 support/gc/cord/cordtest.c create mode 100644 support/gc/cord/cordxtra.c create mode 100644 support/gc/cord/de.c create mode 100644 support/gc/cord/de_cmds.h create mode 100644 support/gc/cord/de_win.ICO create mode 100644 support/gc/cord/de_win.RC create mode 100644 support/gc/cord/de_win.c create mode 100644 support/gc/cord/de_win.h create mode 100644 support/gc/cord/ec.h create mode 100644 support/gc/cord/gc.h create mode 100644 support/gc/cord/private/cord_pos.h create mode 100644 support/gc/dbg_mlc.c create mode 100644 support/gc/dyn_load.c create mode 100644 support/gc/finalize.c create mode 100644 support/gc/gc.h create mode 100644 support/gc/gc.mak create mode 100644 support/gc/gc.man create mode 100644 support/gc/gc_alloc.h create mode 100644 support/gc/gc_cpp.cc create mode 100644 support/gc/gc_cpp.h create mode 100644 support/gc/gc_hdrs.h create mode 100644 support/gc/gc_mark.h create mode 100644 support/gc/gc_priv.h create mode 100644 support/gc/gc_private.h create mode 100644 support/gc/gc_typed.h create mode 100644 support/gc/gc_watcom.asm create mode 100644 support/gc/gcc_support.c create mode 100644 support/gc/gcconfig.h create mode 100644 support/gc/headers.c create mode 100644 support/gc/if_mach.c create mode 100644 support/gc/if_not_there.c create mode 100644 support/gc/include/cord.h create mode 100644 support/gc/include/ec.h create mode 100644 support/gc/include/gc.h create mode 100644 support/gc/include/gc_alloc.h create mode 100644 support/gc/include/gc_cpp.h create mode 100644 support/gc/include/gc_inl.h create mode 100644 support/gc/include/gc_inline.h create mode 100644 support/gc/include/gc_typed.h create mode 100644 support/gc/include/javaxfc.h create mode 100644 support/gc/include/new_gc_alloc.h create mode 100644 support/gc/include/private/cord_pos.h create mode 100644 support/gc/include/private/gc_hdrs.h create mode 100644 support/gc/include/private/gc_priv.h create mode 100644 support/gc/include/private/gcconfig.h create mode 100644 support/gc/include/weakpointer.h create mode 100644 support/gc/irix_threads.c create mode 100644 support/gc/linux_threads.c create mode 100644 support/gc/mach_dep.c create mode 100644 support/gc/makefile.depend create mode 100644 support/gc/malloc.c create mode 100644 support/gc/mallocx.c create mode 100644 support/gc/mark.c create mode 100644 support/gc/mark_rts.c create mode 100644 support/gc/mips_sgi_mach_dep.s create mode 100644 support/gc/mips_ultrix_mach_dep.s create mode 100644 support/gc/misc.c create mode 100644 support/gc/new_hblk.c create mode 100644 support/gc/obj_map.c create mode 100644 support/gc/os_dep.c create mode 100644 support/gc/pc_excludes create mode 100644 support/gc/pcr_interface.c create mode 100644 support/gc/ptr_chck.c create mode 100644 support/gc/real_malloc.c create mode 100644 support/gc/reclaim.c create mode 100644 support/gc/rs6000_mach_dep.s create mode 100644 support/gc/setjmp_t.c create mode 100644 support/gc/solaris_pthreads.c create mode 100644 support/gc/solaris_threads.c create mode 100644 support/gc/solaris_threads.h create mode 100644 support/gc/sparc_mach_dep.s create mode 100644 support/gc/sparc_sunos4_mach_dep.s create mode 100644 support/gc/stubborn.c create mode 100644 support/gc/test.c create mode 100644 support/gc/test_cpp.cc create mode 100644 support/gc/threadlibs.c create mode 100644 support/gc/typd_mlc.c create mode 100644 support/gc/version.h create mode 100644 support/gc/weakpointer.h create mode 100644 support/gc/win32_threads.c diff --git a/.version b/.version new file mode 100644 index 00000000..5ebe3e94 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +2.1.9Ga diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..916d1f0f --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..4c8a0976 --- /dev/null +++ b/Makefile @@ -0,0 +1,152 @@ +# +# +# + +SHELL = /bin/sh +AUTOCONF = autoconf + +PRJDIR = . +PKGS = support/gc support/cpp \ + src as/mcs51 debugger/mcs51 \ + device/include device/lib +PRJS = simulator/mcs51 + +srcdir = . + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf + for pkg in $(PKGS); do $(MAKE) -C $$pkg; done + $(MAKE) -f main.mk all + + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: + $(MAKE) -f main.mk install + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) install; cd ..;\ + done + + +# Deleting all the installed files +# -------------------------------- +uninstall: + $(MAKE) -f main.mk uninstall + @for pkg in $(PKGS); do\ + cd cmd && $(MAKE) uninstall; cd ..;\ + done + + +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + $(MAKE) -f clean.mk clean + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk clean; cd ..;\ + done + @for prj in $(PRJS); do\ + cd $$prj && $(MAKE) clean; cd ..;\ + done + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + $(MAKE) -f clean.mk distclean + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk distclean; cd ..;\ + done + @for prj in $(PRJS); do\ + cd $$prj && $(MAKE) distclean; cd ..;\ + done + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + $(MAKE) -f clean.mk mostlyclean + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk mostlyclean; cd ..;\ + done + @for prj in $(PRJS); do\ + cd $$prj && $(MAKE) mostlyclean; cd ..;\ + done + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, stc. +# ----------------------------------------------------------------------- +realclean: distclean + $(MAKE) -f clean.mk realclean + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk realclean; cd ..;\ + done + @for prj in $(PRJS); do\ + cd $$prj && $(MAKE) realclean; cd ..;\ + done + + +# Creating distribution +# --------------------- +dist: distclean + @if [ -f devel ]; then\ + rm -f devel; mkdist sdcc; touch devel;\ + else\ + mkdist sdcc;\ + fi + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating dependencies +# --------------------- +dep: + $(MAKE) -f main.mk dep + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) dep; cd ..;\ + done + + +# My rules +# -------- + +putcopyright: + 'put(c)' -s $(STARTYEAR) *.cc *.h *.y *.l + + +# Remaking configuration +# ---------------------- +configure: configure.in + $(SHELL) $(AUTOCONF) + +main.mk: $(srcdir)/main_in.mk $(srcdir)/configure.in config.status + $(SHELL) ./config.status + +Makefiles: makefiles + +makefiles: config.status + +config.status: configure + $(SHELL) ./config.status --recheck + +makefiles: + $(SHELL) ./config.status + +freshconf: main.mk + +checkconf: + @if [ -f devel ]; then\ + $(MAKE) freshconf;\ + fi + +# End of Makefile diff --git a/Makefile.org b/Makefile.org new file mode 100644 index 00000000..7f837bbf --- /dev/null +++ b/Makefile.org @@ -0,0 +1,114 @@ +CC=gcc +LEX=flex +YACC=bison +STD_LIB_PATH='"$(SDCCDIR)/sdcc51lib"' +SDCC_INCLUDE_DIR='"$(SDCCDIR)/sdcc51inc"' +GC_DIR=$(SDCCDIR)/gc +LIBSDIRS=-DSTD_LIB_PATH=$(STD_LIB_PATH) -DSTD_LIB='"$(STD_LIB)"' +LIBSDIRS += -DSTD_INT_LIB='"$(STD_INT_LIB)"' -DSTD_LONG_LIB='"$(STD_LONG_LIB)"' +LIBSDIRS += -DSTD_FP_LIB='"$(STD_FP_LIB)"' -DSDCC_INCLUDE_DIR=$(SDCC_INCLUDE_DIR) +CFLAGS=-Wall -ggdb -O2 +#if compiling under linux then uncomment the following line +#LDFLAGS += -Wl,-defsym,_DYNAMIC=0 +TARGETS=$(SDCCDIR)/bin/sdcc +ALLOBJECTS= SDCCy.o SDCClex.o SDCCerr.o SDCChasht.o SDCCmain.o SDCCsymt.o SDCCopt.o +ALLOBJECTS += SDCCast.o SDCCmem.o SDCCval.o SDCCralloc.o SDCCicode.o SDCCbitv.o SDCCset.o +ALLOBJECTS += SDCClabel.o SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o +ALLOBJECTS += SDCClrange.o SDCCptropt.o SDCCgen51.o SDCCpeeph.o SDCCglue.o + +ALLHEADERS=SDCCopt.h SDCCast.h SDCChasht.h SDCCval.h Makefile SDCCerr.h +ALLHEADERS += SDCCglobl.h SDCCmem.h SDCCsymt.h SDCCicode.h SDCCbitv.h SDCCset.h +ALLHEADERS += SDCClabel.h SDCCBBlock.h SDCCloop.h SDCCcse.h SDCCcflow.h SDCCdflow.h +ALLHEADERS += SDCClrange.h SDCCralloc.h SDCCptropt.h + +all:: $(TARGETS) + +clean:: + rm *.o SDCCy.c SDCCy.h SDCClex.c SDCCy.output SDCCpeeph.rul + +SDCCy.c : SDCC.y + $(YACC) -d -v -o SDCCy.c SDCC.y + +SDCClex.o : SDCClex.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCClex.o SDCClex.c + +SDCClex.c : SDCC.lex SDCCy.h + $(LEX) -f -oSDCClex.c SDCC.lex + +SDCCast.o : SDCCast.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCast.o SDCCast.c + +SDCCmem.o : SDCCmem.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCmem.o SDCCmem.c + +SDCCval.o : SDCCval.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCval.o SDCCval.c + +SDCCralloc.o : SDCCralloc.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCralloc.o SDCCralloc.c + +SDCCicode.o : SDCCicode.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCicode.o SDCCicode.c + +SDCCerr.o : SDCCerr.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCerr.o SDCCerr.c + +SDCChasht.o : SDCChasht.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCChasht.o SDCChasht.c + +SDCCmain.o : SDCCmain.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) $(LIBSDIRS) -c -o SDCCmain.o SDCCmain.c + +SDCCsymt.o : SDCCsymt.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCsymt.o SDCCsymt.c + +SDCCy.o : SDCCy.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCy.o SDCCy.c + +SDCCopt.o : SDCCopt.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCopt.o SDCCopt.c + +SDCCbitv.o : SDCCbitv.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCbitv.o SDCCbitv.c + +SDCCset.o : SDCCset.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCset.o SDCCset.c + +SDCClabel.o : SDCClabel.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCClabel.o SDCClabel.c + +SDCCBBlock.o : SDCCBBlock.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCBBlock.o SDCCBBlock.c + +SDCCloop.o : SDCCloop.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCloop.o SDCCloop.c + +SDCCcse.o : SDCCcse.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCcse.o SDCCcse.c + +SDCCcflow.o : SDCCcflow.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCcflow.o SDCCcflow.c + +SDCCdflow.o : SDCCdflow.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCdflow.o SDCCdflow.c + +SDCClrange.o : SDCClrange.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCClrange.o SDCClrange.c + +SDCCptropt.o : SDCCptropt.c $(ALLHEADERS) + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCptropt.o SDCCptropt.c + +SDCCgen51.o : SDCCgen51.c $(ALLHEADERS) SDCCgen51.h SDCCpeeph.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCgen51.o SDCCgen51.c + +SDCCpeeph.rul : SDCCpeeph.def + awk -f SDCCpeeph.awk SDCCpeeph.def > SDCCpeeph.rul + +SDCCpeeph.o : SDCCpeeph.c SDCCpeeph.h SDCChasht.h SDCCglobl.h Makefile SDCCpeeph.rul + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCpeeph.o SDCCpeeph.c + +SDCCglue.o : SDCCglue.c $(ALLHEADERS) SDCCglue.h Makefile + $(CC) $(CFLAGS) $(LDFLAGS) -c -o SDCCglue.o SDCCglue.c + +$(TARGETS): $(ALLOBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) $(LDXFLAGS) -o $@ $(ALLOBJECTS) $(GC_DIR)/gc.a diff --git a/README b/README new file mode 100644 index 00000000..cffec56f --- /dev/null +++ b/README @@ -0,0 +1,49 @@ +Small Device C Compiler (sdcc) +------------------------------ +A C compiler for the Intel mcs51 series and soon the Z80. + +http://sdcc.sourceforge.net/ + +This file is just a stub. It will get better. + +Almost all of this is by Sandeep Dutta +The Z80 port was started by Michael Hope + +Some of the Z80 related files are borrowed from the Gameboy +Development Kit (GBDK) originally by Pascal Felber. + +Roadmap: +-------- +README - This file +COPYING - GPL v2 +as/ - Assembler, derrived from asxxxx +debugger/ +device/ - Device libraries and examples +doc/ - sdcc and port specific documentation +link/ - Linker, also derrived from asxxxx +sim/ - Simulator (mcs51 only) +src/ - Source to the C compiler and ports +support/ - Libraries and apps that may not be provided by your system. + +Most of the port related files are in a subdirectory below the +appropriate module. For example, all compiler z80 related files +are in src/z80, all 8051 (mcs51) specific library files are in +device/lib/mcs51. + +Links: +------ + +* SDCC homepage + http://sdcc.sourceforge.net/ + +* GBDK homepage + http://gbdk.sourceforge.net/ + +* SDCC at Geocities (old) + http://www.geocities.com/ResearchTriangle/Forum/1353/ + +* SDCC mailing list + http://sdcc.listbot.com/ + +* Yahoo! Random link + http://random.yahoo.com/bin/ryl diff --git a/as/README b/as/README new file mode 100644 index 00000000..b0f405ed --- /dev/null +++ b/as/README @@ -0,0 +1,5 @@ +sdcc/as +------- + +Both the z80 and mcs51 assemblers are derrived from the same tree. One +day they may be re-combined. diff --git a/as/doc/README b/as/doc/README new file mode 100644 index 00000000..abaaf35b --- /dev/null +++ b/as/doc/README @@ -0,0 +1,460 @@ +(README 2-Apr-1998 by John Hartman. jhartman@compuserve.com) + +I have made several modifications to the CUG292 assemblers and +linker, beginning with version 1.7 (the most recent I know of). + +The original assembler was written by + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + +To conserve space on my web site, this ZIP file does not include all +of the files in the original CUG292 release. In particular, the +assembler test files and ASSIST monitors have been removed. All source +files and documents are included. The original is widely available +on the net. + +Your comments and bug reports are solicited. + +The changes are of three types +1) bug fixes and small changes +2) an 8051 version of the assembler +3) generation of line and symbol information for NoICE + +======================================================================== +MISCELLANEOUS CHANGES + +* There is a bug in LKMAIN: it tests S_DEF flag in "s_flag". + No one else uses s_flag in the linker - S_DEF is defined in s_type + instead. Presumably LKMAIN should use s_type as well? Changed. + +* There is a portability problem in aslex: the test + while (ctype[c=get()] & ~(SPACE | ILL)) + causes an infinite loop with my (old Zortech) compiler: + ILL = 0x80, SPACE=0. When I read a null at the end of a line, + ctype[] returns "ILL". My compiler sign extends this 0x80 to int 0xFF80. + Sign extend on ~ILL makes 0x7F into 0xFF7F. The result of the AND is + true and we spin. I changed this to + while (ctype[c=get()] & (0xFF - (SPACE|ILL))) + +* I made changes to mlookup() so that mnemonics and pseudo-ops are always + case insensitive, regardless of the CASE_SENSITIVE flag. This simplifies + using the assembler on existing code. + +* The scheme described below for debug information can make for very long + symbol names. Thus, I have modified the assembler and linker to allow + names up to 80 characters, moving the name strings out of the sym struct. + This will save significant heap space over simply increasing NCPS to 80. + +* I have added one module, ASNOICE.C, to each assembler; and one module, + LKNOICE.C, to the linker. My make files are named XSnnnn.MAK for the + asseblers, and XSLINK.MAK for the linker. I have not modified any + of the original make or project files, since I have no means to test + them. + +======================================================================== +8051 ASSEMBLER + +I was somewhat surprised that there was no AS8051 - so I wrote one. +It is comprised of the modules: + i8051.h + i51pst.c + i51mch.c + i51adr.c + i51ext.c + appexdk.txt "Appendix K" about the 8051 for the documentation + +I added four attributes to the .area directive to support +the 8051's multiple address spaces: + CODE for codespace + DATA for internal data + BIT for internal bit-addressable + XDATA for external data. + +These will typically be used as follows (names are examples): + .area IDATA (DATA) + .area IBIT (BIT) + .area MYXDATA (REL,CON,XDATA) + .area MYCODE (REL,CON,CODE) + +The default segment, _CODE, should not be used for the 8051. For +compatibility reasons, _CODE is allocated in "DATA" space. You +should always define an area in the CODE space. + +DETAILS: + +i51mch.c is not especially pretty - it includes some brute-force switch +statements which could, I suspect, be trimmed down by application of +a few appropriate functions. + +The 8051 includes two instructions, AJMP and ACALL, which have eleven +bit destination addresses. The upper three address bits are encoded +into the top three bits of the op-code. In order to achieve this, I +was forced to make changes to several ASxxx and LKxxx modules: + asm.h line 179 equate for R_J11, 583 outr11 prototype + asout.c lines 1087-1132 function outr11: output 11 bit dest + aslink.h line 131 equate for R_J11 + lkrloc.c lines 354-377 link/locate 11 bit destination + +The definition of R_J11 is as (R_WORD | R_BYT2) +A comment in lkrloc says + * R_WORD with the R_BYT2 mode is flagged + * as an 'r' error by the assembler, + * but it is processed here anyway. +This is no longer true, so the code in question is #defined out +in the linker only. I suspect that thie would cause problems +if a module with R_WORD | R_BYT1 by other cause were to be processed. + +I am not entirely happy with outr11 in the case where the destination +is an absolute value. The ideal would be to pass the value thru to the +linker, and resolve at link time whether or not the address is within +2K of the instruction location. Unfortunately, I couldn't figure out +how to pass an absolute value to the linker, as it has no area. Thus, +I interpreted absolute values as being relative to the beginning of the +current area, as is done in the other assemblers for relative branch +instructions. I am less happy with this solution here, as a 2K range +is far larger than the +-128 for a branch instruction. I can envision +code such as + reset = 123 + ... + ajmp reset + +If the ajmp is in a relocatable area, the effect will be not at all what +is desired. If you can offer any other solution, I would appreciate it. + +======================================================================== +SOURCE-LEVEL DEBUG OF ASSEMBLY CODE WITH NoICE + +1) The switch "-j" has been added to the assembler. This causes + assembly lines to generate line number information in the object + file. You may also wish to use the "-a" switch to make all symbols + global. Non-global symbols are not passed to the object file. + +2) The assemblers will pass any line beginning with the characters + ";!" (semi-colon, exclamation point) intact to the object file. + You can use such comments in your assembly modules to embed NoICE + commands in your source code. + +3) The switch "-j" has been added to the linker. This causes a + NoICE debug file, with extension ".NOI" to be created. All symbol + and line number information in the object files, as well as any + ";!" comments will be included. Specifying the -j switch will force + a map file to be produced as well. + +4) The linker will process any line beginning with the characters + ";!" (semi-colon, exclamation point) by removing the ";!" and + passing the remainder of the line to the .NOI file (if any). + This allows NoICE commands to be placed as ";!" comments in + the assembly file, and passed through the assember and linker + to the .NOI file. + +5) If the linker is requested to produce a hex output file (-i or -s + switches), a LOAD command for the hex file will be placed in the + .NOI file (if any). + +6) The linker will output the ";!" lines after all symbols have been + output. Thus, such lines can contain NoICE commands which refer to + symbols by name. + +======================================================================== +SOURCE-LEVEL DEBUG OF C CODE FOR NoICE + +This section is primarily of interest to compiler writers. + +Compilers which produce assembly code can pass debug information +through the assembler and linker to the NoICE command file. In +addition, the linker will provide special processing of symbols +with certain formats described below. + +1) The switch "-j" should NOT be used on assembly files which + represent compiler output. Instead, the compiler should generate + line number symbols for each code-producing source line as + described below. if your project contains a mixture of C and assembly + source files, you may wish to use "-j" on the assembly modules. + +2) The assemblers will pass any line beginning with the characters + ";!" (semi-colon, exclamation point) intact to the .REL file. + The compiler can make use of this fact to pass datatype information + and stack offsets for automatic symbols through the assembler and + linker to NoICE. This is described in detail below. + +3) The switch "-j" has been added to the linker. This causes a + NoICE debug file, with extension ".NOI" to be created. Contents + will be as described below. Specifying the -j switch will force + a map file to be produced as well. + +4) The linker will process any line beginning with the characters + ";!" (semi-colon, exclamation point) by removing the ";!" and + passing the remainder of the line to the .NOI file (if any). + +5) If the linker is requested to produce a hex output file (-i or -s + switches), a LOAD command for the hex file will be placed in the + .NOI file (if any). + +6) The linker will process symbols with names of the form + text + + into NoICE DEFINE (global symbol) commands in the .NOI output file + DEF name symbolvalue + +7) The linker will process symbols with names of the form + text.integer + + into NoICE FILE and LINE (line number) commands in the .NOI output file. + It will assume that "text" is the file name without path or extension, + that "integer" is the decimal line number within the file, and that + the value of the symbol is equal to the address of the first instruction + produced by the line. + +8) The linker will process symbols with names of the form + text.name + + into NoICE FILE and DEFINESCOPED commands in the .NOI file + (if any), to define file-scope variables: + FILE text + DEFS name symbolvalue + +9) The linker will process symbols with names of the form + text.name.name2 + + into NoICE FILE, FUNCTION, and DEFINESCOPED commands in the + .NOI file (if any), to define function-scope variables: + FILE text + FUNC name + DEFS name2 symbolvalue + +10) The linker will process symbols with names of the form + text.name.name2.integer + + into NoICE FILE, FUNCTION, and DEFINESCOPED commands in the + .NOI file (if any), to define function-scope variables, to allow + multiple scopes within a single C function. "Integer" is a scope + number, and should be zero for the first scope, and increment + for each new scope within the function. Since NoICE cannot currently + cope with scope finer than function, it will produce symbols of + the form: + FILE text + FUNC name + DEFS name2_integer symbolvalue + + The trailing "_integer" will be omitted for integer == 0 (function). + +11) The linker will process symbols with names of the form + text.name..FN + + into NoICE FILE, DEFINE, and FUNCTION commands in the .NOI + file (if any), to define the start of a global function: + FILE text + DEF name symbolvalue %code + FUNC name symbolvalue + +12) The linker will process symbols with names of the form + text.name..SFN + + into NoICE FILE, DEFINESCOPED, and SFUNCTION commands in the .NOI + file (if any), to define the start of a file-scope (static) + function: + FILE text + DEFS name symbolvalue %code + SFUNC name symbolvalue + +13) The linker will process symbols with names of the form + text.name..EFN + + into NoICE ENDFUNCTION commands in the .NOI file (if any) to + define the end of a global or file-scope function: + ENDF name symbolvalue + +14) The linker will output the symbols in each "area" or memory + section in order of increasing address. + +15) The linker will output the ";!" lines after all symbols + have been output. + +The features listed above may be used to add full source-level +debug information to assembly files produced by a compiler. The +example file ctest1.c, and the hypothetical ctest1.s produced by +compiling it illustrate this. The comments in the file describe +the information, but would not be present in an actual implementation. + +1) Begin each file with a ";!FILE" specifying the file name and its + original extension (usually ".c"), and with the path if the file is + not in the current directory. + ;!FILE ctest1.c + +2) Define any basic data types: char defaults to S08. Redefine as U08 or + ASCII if you desire. "int" defaults to S16. Redefine if necessary. + ;!DEFT 0 char %ASCII + +3) Define any data structures, typedefs, enums, etc. (C generally + does this per source file. Types will remain in scope unless + redefined). For example, the C structure + + typedef struct { + char c; + int i; + int ai[ 10 ]; + int *pi; + } STR; + + would generate the commands: + ;!STRUCT 0. STR + ;!DEFT 0. c %char + ;!DEFT 1. i %int + ;!DEFT 3. ai %int[10.] + ;!DEFT 23. pi %*int + ;!ENDS 25. + + Since the user can change input radix at will, it is generally + recommended to specify radix explicitly in the ;! commands: by + a trailing "." for decimal, or leading "0x" for hex. + +4) Use ;!FUNC, (or ;!SFUNC), ;!DEFS, and ;!ENDF to define any + function arguments and local variables. The function + void main( void ) + { + /* declare some local variables */ + char lc, *plc; + int *pli; + int *lnpi; + int *lfpi; + ... + + would generate stack-based symbol definitions with their datatypes. + (Note that the stack offsets are not passed to the assembler by + name, as they need not be relocated. Thus, it is the compiler's + duty to generate these. Note that the 68HC11 TSX instruction + increments the value of SP by one. Thus, "SP+nn" should use + "nn" values one greater than for use as offsets from X. + ;!FUNC main + ;!DEFS lfpi SP+6. %*int + ;!DEFS lnpi SP+8. %*int + ;!DEFS pli SP+10. %*int + ;!DEFS plc SP+12. %*char + ;!DEFS lc SP+14. %char + + When all local variables and parameters have been defined, the + function scope must be closed: + ;!ENDF + +5) In general, it is desirable to generate two symbols for each + function: one with an underbar, at the first byte of the + function, so that the disassembler will show it as the destination + of the JSR; and a second without an underbar at the address of + the first source line after stack frame is set up. The latter + will be a common breakpoint location. + + CUG292 can generate global symbols by using a "::" + _main:: + tsx + xgdx + subd #44 + xgdx + txs + +6) Once the stack frame is set up, declare the beginning of the + function body. The value of this symbol is the lowest address + which NoICE will consider to be within the function for scoping + purposes. + ctest1.main..FN:: + +7) Each C source line which produces code should emit a symbol + consisting of the file name without path or extension, followed + by the line number (in decimal) in the C source file. + ctest1.56:: + ldd #6 + std _gestr + +8) Declare the end of the function body. The value of this symbol + is the highest address which NoICE will consider to be within the + function for scoping purposes. The address must be on or before + the RTS, so that it does not overlap the following function. + Normally, the address will be the last C source line in the + function before stack frame is destroyed. + ctest1.main..EFN:: + xgdx + addd #44 + xgdx + txs + rts + +9) Global variables defined in the file, and their datatypes, may be + defined at any time. Debugging is most convenient if the + traditional C leading underbar is omitted. The global declarations + int gi; + STR *pgstr; + + would generate: + ;!DEF gi %*int + gi:: + .blkb 2 + + ;!DEF pgstr %*STR + pgstr:: + .blkb 2 + + Here, the ";!" command defines the datatype, which is unknown to + the assembler, while the "::" defintion defines the value, which + is unknown until link time. + +10) File-scope static variables, and their datatypes, must be defined + between the ;!FILE and the ;!ENDFILE in order to set proper scope. + Debugging is most convenient if the traditional C leading underbar + is omitted. The static declarations + static int si; + static STR sstr; + + would generate: + ;!DEFS si %*int + ctest1.si:: + .blkb 2 + + ;!DEFS sstr %STR + ctest1.sstr:: + .blkb 25 + + We note that while the ;!DEFS must be between ;!FILE and ;!ENDFILE, + the "::" definitions may be elsewhere in the file if it is + convenient, as the symbol name carries the scoping information. + +11) Function-scope static variables, and their datatypes, must be + defined between the ;!FUNC (or ;!SFUNC) and the corresponding + ;!ENDF in order to set proper scope. Debugging is most convenient + if the traditional C leading underbar is omitted. The static + declarations + void main( void ) + { + static int si; + static STR sstr; + + would generate: + ;!FUNC main + + at some point, and then + ;!DEFS si %*int + ctest1.main.si:: + .blkb 2 + + ;!DEFS sstr %STR + ctest1.main.sstr:: + .blkb 25 + + We note that while the ;!DEFS must be between ;!FUNC and ;!ENDF, + the "::" definitions may be elsewhere in the file if it is + convenient, as the symbol name carries the scoping information. + +12) After all code, data, and ;! defintions, declare end of file. + This is necessary to prevent mangled scope when several modules + are linked together. + ;!ENDFILE + + CTEST1.C - sample C source code + CTEST1.S - output from ImageCraft compiler, hand-doctored + to add additional debug information + CTEST2.C - second C module + CTEST2.S - output from ImageCraft compiler, undoctored + CTEST.BAT - assemble and link CTEST1+CTEST2 + +Run CTEST.BAT to produce CTEST1.NOI, a NoICE command file. + +end README diff --git a/as/doc/abstra.doc b/as/doc/abstra.doc new file mode 100644 index 00000000..e6842320 --- /dev/null +++ b/as/doc/abstra.doc @@ -0,0 +1,60 @@ + + + ASxxxx Cross Assemblers, Version 1.7, November 1995 + + Submitted by Alan R. Baldwin, + Kent State University, Kent, Ohio + + Operating System: TSX+, RT-11, MS/DOS, PDOS + or other supporting K&R C. + + Source Langauge: C + + Abstract: + + The ASxxxx assemblers are a series of microprocessor assem- + blers written in the C programming language. This collection + contains cross assemblers for the 6800(6802/6808), 6801(hd6303), + 6804, 6805, 68HC08, 6809, 6811, 68HC16, 8085(8080), + z80(hd64180), H8/3xx, and 6500 series microprocessors. Each as- + sembler has a device specific section which includes: (1) + device description, byte order, and file extension information, + (2) a table of assembler general directives, special directives, + assembler mnemonics and associated operation codes, (3) machine + specific code for processing the device mnemonics, addressing + modes, and special directives. + + The assemblers have a common device independent section which + handles the details of file input/output, symbol table genera- + tion, program/data areas, expression analysis, and assembler + directive processing. + + The assemblers provide the following features: (1) alpha- + betized, formatted symbol table listings, (2) relocatable object + modules, (3) global symbols for linking object modules, (4) con- + ditional assembly directives, (5) reusable local symbols, and + (6) include-file processing. + + The companion program ASLINK is a relocating linker perform- + ing the following functions: (1) bind multiple object modules + into a single memory image, (2) resolve inter-module symbol + references, (3) resolve undefined symbols from specified + librarys of object modules, (4) process absolute, relative, con- + catenated, and overlay attributes in data and program sections, + (5) perform byte and word program-counter relative (pc or pcr) + addressing calculations, (6) define absolute symbol values at + link time, (7) define absolute area base address values at link + time, (8) produce Intel Hex or Motorola S19 output file, (9) + produce a map of the linked memory image, and (10) update the + ASxxxx assembler listing files with the absolute linked ad- + dresses and data. + + The assemblers and linker have been tested using DECUS C + under TSX+ and RT-11, PDOS C V5.4b, and Symantec C/C++ V6.1/V7.0 + under DOS/Windows 3.x. Complete source code and documentation + for the assemblers and linker is included with the distribution. + Additionally, test code for each assembler and several micropro- + cessor monitors ( ASSIST05 for the 6805, MONDEB and ASSIST09 for + the 6809, and BUFFALO 2.5 for the 6811) are included as working + examples of use of these assemblers. + \ No newline at end of file diff --git a/as/doc/appendk.txt b/as/doc/appendk.txt new file mode 100644 index 00000000..ec232962 --- /dev/null +++ b/as/doc/appendk.txt @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + APPENDIX K + + AS8051 ASSEMBLER + + + + + + K.1 8051 REGISTER SET + + The following is a list of the 8051 registers used by AS8051: + + a,b - 8-bit accumulators + r0,r1,r2,r3 - 8-bit registers + r4,r5,r6,r7 + dptr - data pointer + sp - stack pointer + pc - program counter + psw - status word + c - carry (bit in status word) + + + K.2 8051 INSTRUCTION SET + + + The following tables list all 8051 mnemonics recognized + by the AS8051 assembler. The following list specifies the + format for each addressing mode supported by AS8051: + + #data immediate data + byte or word data + + r,r1,r2 register r0,r1,r2,r3,r4,r5,r6, or r7 + + @r indirect on register r0 or r1 + @dptr indirect on data pointer + @a+dptr indirect on accumulator plus data pointer + @a+pc indirect on accumulator plus program counter + + addr direct memory address + + bitaddr bit address + + label call or jump label + + The terms data, addr, bitaddr, and label may all be expressions. + + Note that not all addressing modes are valid with every in- + struction. Refer to the 8051 technical data for valid + modes. + + + K.2.1 Inherent Instructions + + nop + + + K.2.6 Move Instructions + + mov a,#data mov a,addr + mov a,r mov a,@r + + mov r,#data mov r,addr + mov r,a + + mov addr,a mov addr,#data + mov addr,r mov addr,@r + mov addr1,addr2 mov bitaddr,c + + mov @r,#data mov @r,addr + mov @r,a + + mov c,bitaddr + mov dptr,#data + + movc a,@a+dptr movc a,@a+pc + movx a,@dptr movx a,@r + movx @dptr,a movx @r,a + + + K.2.8 Single Operand Instructions + + clr a clr c + clr bitaddr + cpl a cpl c + cpl bitaddr + setb c setb bitaddr + + da a + rr a rrc a + rl a rlc a + swap a + + dec a dec r + dec @r + inc a inc r + inc dptr inc @r + + div ab mul ab + + pop addr push addr + + + K.2.8 Two Operand Instructions + + add a,#data add a,addr + add a,r add a,@r + addc a,#data addc a,addr + addc a,r addc a,@r + subb a,#data subb a,addr + subb a,r subb a,@r + orl a,#data orl a,addr + orl a,r orl a,@r + orl addr,a orl addr,#data + orl c,bitaddr orl c,/bitaddr + anl a,#data anl a,addr + anl a,r anl a,@r + anl addr,a anl addr,#data + anl c,bitaddr anl c,/bitaddr + xrl a,#data xrl a,addr + xrl a,r xrl a,@r + xrl addr,a xrl addr,#data + xrl c,bitaddr xrl c,/bitaddr + xch a,addr xch a,r + xch a,@r xchd a,@r + + + K.2.3 Call and Return Instructions + + acall label lcall label + ret reti + + K.2.4 Jump Instructions + + ajmp label + cjne a,#data,label cjne a,addr,label + cjne r,#data,label cjne @r,#data,label + djnz r,label djnz addr,label + jbc bitadr,label + jb bitadr,label jnb bitadr,label + jc label jnc label + jz label jnz label + jmp @a+dptr + ljmp label sjmp label diff --git a/as/doc/asmlnk.doc b/as/doc/asmlnk.doc new file mode 100644 index 00000000..9da3e8da --- /dev/null +++ b/as/doc/asmlnk.doc @@ -0,0 +1,5726 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + ASxxxx Assemblers + + + and + + + ASLINK Relocating Linker + + + CHAPTER 1 THE ASSEMBLER 1-1 + 1.1 THE ASXXXX ASSEMBLERS 1-1 + 1.1.1 Assembly Pass 1 1-2 + 1.1.2 Assembly Pass 2 1-2 + 1.1.3 Assembly Pass 3 1-2 + 1.2 SOURCE PROGRAM FORMAT 1-3 + 1.2.1 Statement Format 1-3 + 1.2.1.1 Label Field 1-3 + 1.2.1.2 Operator Field 1-5 + 1.2.1.3 Operand Field 1-5 + 1.2.1.4 Comment Field 1-6 + 1.3 SYMBOLS AND EXPRESSIONS 1-6 + 1.3.1 Character Set 1-6 + 1.3.2 User-Defined Symbols 1-10 + 1.3.3 Local Symbols 1-11 + 1.3.4 Current Location Counter 1-12 + 1.3.5 Numbers 1-14 + 1.3.6 Terms 1-14 + 1.3.7 Expressions 1-15 + 1.4 GENERAL ASSEMBLER DIRECTIVES 1-16 + 1.4.1 .module Directive 1-16 + 1.4.2 .title Directive 1-17 + 1.4.3 .sbttl Directive 1-17 + 1.4.4 .page Directive 1-17 + 1.4.5 .byte and .db Directives 1-17 + 1.4.6 .word and .dw Directives 1-18 + 1.4.7 .blkb, .blkw, and .ds Directives 1-18 + 1.4.8 .ascii Directive 1-18 + 1.4.9 .ascis Directive 1-19 + 1.4.10 .asciz Directive 1-19 + 1.4.11 .radix Directive 1-20 + 1.4.12 .even Directive 1-20 + 1.4.13 .odd Directive 1-20 + 1.4.14 .area Directive 1-21 + 1.4.15 .org Directive 1-22 + 1.4.16 .globl Directive 1-23 + 1.4.17 .if, .else, and .endif Directives 1-23 + 1.4.18 .include Directive 1-24 + 1.4.19 .setdp Directive 1-25 + 1.5 INVOKING ASXXXX 1-27 + 1.6 ERRORS 1-28 + 1.7 LISTING FILE 1-29 + 1.8 SYMBOL TABLE FILE 1-30 + 1.9 OBJECT FILE 1-31 + + CHAPTER 2 THE LINKER 2-1 + 2.1 ASLINK RELOCATING LINKER 2-1 + 2.2 INVOKING ASLINK 2-2 + 2.3 LIBRARY PATH(S) AND FILE(S) 2-3 + 2.4 ASLINK PROCESSING 2-4 + 2.5 LINKER INPUT FORMAT 2-5 + 2.5.1 Object Module Format 2-6 + 2.5.2 Header Line 2-6 + 2.5.3 Module Line 2-6 + 2.5.4 Symbol Line 2-6 + 2.5.5 Area Line 2-7 + + + Page ii + + + + 2.5.6 T Line 2-7 + 2.5.7 R Line 2-7 + 2.5.8 P Line 2-8 + 2.6 LINKER ERROR MESSAGES 2-8 + 2.7 INTEL HEX OUTPUT FORMAT 2-11 + 2.8 MOTORLA S1-S9 OUTPUT FORMAT 2-12 + + CHAPTER 3 BUILDING ASXXXX AND ASLINK 3-1 + 3.1 BUILDING AN ASSEMBLER 3-1 + 3.2 BUILDING ASLINK 3-2 + + APPENDIX A AS6800 ASSEMBLER A-1 + A.1 6800 REGISTER SET A-1 + A.2 6800 INSTRUCTION SET A-1 + A.2.1 Inherent Instructions A-2 + A.2.2 Branch Instructions A-2 + A.2.3 Single Operand Instructions A-3 + A.2.4 Double Operand Instructions A-4 + A.2.5 Jump and Jump to Subroutine Instructions A-4 + A.2.6 Long Register Instructions A-5 + + APPENDIX B AS6801 ASSEMBLER B-1 + B.1 .hd6303 DIRECTIVE B-1 + B.2 6801 REGISTER SET B-1 + B.3 6801 INSTRUCTION SET B-1 + B.3.1 Inherent Instructions B-2 + B.3.2 Branch Instructions B-2 + B.3.3 Single Operand Instructions B-3 + B.3.4 Double Operand Instructions B-4 + B.3.5 Jump and Jump to Subroutine Instructions B-5 + B.3.6 Long Register Instructions B-5 + B.3.7 6303 Specific Instructions B-5 + + APPENDIX C AS6804 ASSEMBLER C-1 + C.1 6804 REGISTER SET C-1 + C.2 6804 INSTRUCTION SET C-1 + C.2.1 Inherent Instructions C-2 + C.2.2 Branch Instructions C-2 + C.2.3 Single Operand Instructions C-2 + C.2.4 Jump and Jump to Subroutine Instructions C-2 + C.2.5 Bit Test Instructions C-2 + C.2.6 Load Immediate data Instruction C-3 + C.2.7 6804 Derived Instructions C-3 + + APPENDIX D AS6805 ASSEMBLER D-1 + D.1 6805 REGISTER SET D-1 + D.2 6805 INSTRUCTION SET D-1 + D.2.1 Control Instructions D-2 + D.2.2 Bit Manipulation Instructions D-2 + D.2.3 Branch Instructions D-2 + D.2.4 Read-Modify-Write Instructions D-3 + D.2.5 Register\Memory Instructions D-3 + + + Page iii + + + + D.2.6 Jump and Jump to Subroutine Instructions D-4 + + APPENDIX E AS68HC08 ASSEMBLER E-1 + E.1 68HC08 REGISTER SET E-1 + E.2 68HC08 INSTRUCTION SET E-1 + E.2.1 Control Instructions E-2 + E.2.2 Bit Manipulation Instructions E-2 + E.2.3 Branch Instructions E-3 + E.2.4 Complex Branch Instructions E-3 + E.2.5 Read-Modify-Write Instructions E-4 + E.2.6 Register\Memory Instructions E-5 + E.2.7 Double Operand Move Instruction E-5 + E.2.8 16-Bit Index Register Instructions E-5 + E.2.9 Jump and Jump to Subroutine Instructions E-5 + + APPENDIX F AS6809 ASSEMBLER F-1 + F.1 6809 REGISTER SET F-1 + F.2 6809 INSTRUCTION SET F-1 + F.2.1 Inherent Instructions F-3 + F.2.2 Short Branch Instructions F-3 + F.2.3 Long Branch Instructions F-3 + F.2.4 Single Operand Instructions F-4 + F.2.5 Double Operand Instructions F-5 + F.2.6 D-register Instructions F-5 + F.2.7 Index/Stack Register Instructions F-5 + F.2.8 Jump and Jump to Subroutine Instructions F-6 + F.2.9 Register - Register Instructions F-6 + F.2.10 Condition Code Register Instructions F-6 + F.2.11 6800 Compatibility Instructions F-6 + + APPENDIX G AS6811 ASSEMBLER G-1 + G.1 6811 REGISTER SET G-1 + G.2 6811 INSTRUCTION SET G-1 + G.2.1 Inherent Instructions G-2 + G.2.2 Branch Instructions G-2 + G.2.3 Single Operand Instructions G-3 + G.2.4 Double Operand Instructions G-4 + G.2.5 Bit Manupulation Instructions G-4 + G.2.6 Jump and Jump to Subroutine Instructions G-5 + G.2.7 Long Register Instructions G-5 + + APPENDIX H AS6816 ASSEMBLER H-1 + H.1 6816 REGISTER SET H-1 + H.2 6816 INSTRUCTION SET H-1 + H.2.1 Inherent Instructions H-2 + H.2.2 Push/Pull Multiple Register Instructions H-3 + H.2.3 Short Branch Instructions H-3 + H.2.4 Long Branch Instructions H-3 + H.2.5 Bit Manipulation Instructions H-3 + H.2.6 Single Operand Instructions H-4 + H.2.7 Double Operand Instructions H-5 + H.2.8 Index/Stack Register Instructions H-5 + + + Page iv + + + + H.2.9 Jump and Jump to Subroutine Instructions H-6 + H.2.10 Condition Code Register Instructions H-6 + H.2.11 Multiply and Accumulate Instructions H-6 + + APPENDIX I ASH8 ASSEMBLER I-1 + I.1 H8/3XX REGISTER SET I-1 + I.2 H8/3XX INSTRUCTION SET I-1 + I.2.1 Inherent Instructions I-2 + I.2.2 Branch Instructions I-2 + I.2.3 Single Operand Instructions I-3 + I.2.4 Double Operand Instructions I-4 + I.2.5 Mov Instructions I-5 + I.2.6 Bit Manipulation Instructions I-6 + I.2.7 Extended Bit Manipulation Instructions I-7 + I.2.8 Condition Code Instructions I-7 + I.2.9 Other Instructions I-8 + I.2.10 Jump and Jump to Subroutine Instructions I-8 + + APPENDIX J AS8085 ASSEMBLER J-1 + J.1 8085 REGISTER SET J-1 + J.2 8085 INSTRUCTION SET J-1 + J.2.1 Inherent Instructions J-2 + J.2.2 Register/Memory/Immediate Instructions J-2 + J.2.3 Call and Return Instructions J-2 + J.2.4 Jump Instructions J-2 + J.2.5 Input/Output/Reset Instructions J-3 + J.2.6 Move Instructions J-3 + J.2.7 Other Instructions J-3 + + APPENDIX K ASZ80 ASSEMBLER K-1 + K.1 .hd64 DIRECTIVE K-1 + K.2 Z80 REGISTER SET AND CONDITIONS K-1 + K.3 Z80 INSTRUCTION SET K-2 + K.3.1 Inherent Instructions K-3 + K.3.2 Implicit Operand Instructions K-3 + K.3.3 Load Instruction K-4 + K.3.4 Call/Return Instructions K-4 + K.3.5 Jump and Jump to Subroutine Instructions K-4 + K.3.6 Bit Manipulation Instructions K-5 + K.3.7 Interrupt Mode and Reset Instructions K-5 + K.3.8 Input and Output Instructions K-5 + K.3.9 Register Pair Instructions K-5 + K.3.10 HD64180 Specific Instructions K-6 + + APPENDIX L AS6500 ASSEMBLER L-1 + L.1 ACKNOWLEDGMENT L-1 + L.2 6500 REGISTER SET L-2 + L.3 6500 INSTRUCTION SET L-2 + L.3.1 Processor Specific Directives L-3 + L.3.2 65xx Core Inherent Instructions L-3 + L.3.3 65xx Core Branch Instructions L-3 + L.3.4 65xx Core Single Operand Instructions L-3 + + + Page v + + + + L.3.5 65xx Core Double Operand Instructions L-4 + L.3.6 65xx Core Jump and Jump to Subroutine + Instructions L-4 + L.3.7 65xx Core Miscellaneous X and Y Register + Instructions L-4 + L.3.8 65F11 and 65F12 Specific Instructions L-5 + L.3.9 65C00/21 and 65C29 Specific Instructions L-5 + L.3.10 65C02, 65C102, and 65C112 Specific + Instructions L-6 + + + Page vi + + + + ASxxxx Cross Assemblers, Version 1.7 + + Submitted by: + Alan R. Baldwin, + Physics Dept. + Kent State University + Kent, Ohio 44242 + + Operating System: TSX+, RT-11, PDOS, MS/DOS, Windows 3.x + or other supporting K&R C. + + Source Langauge: C + + The ASxxxx Cross Assembler and Linker package (V1.7 November + 1995) contains cross assemblers for the 6800(6802/6808), + 6801(hd6303), 6804, 6805, 68HC08, 6809, 6811, 68HC16, + 8085(8080), z80(hd64180), H8/3xx, and 6500 series microproces- + sors. Complete source code is provided with the assem- + bler/linker submission. + + + + + + The ASxxxx Cross Assembler and Linker package is available + from Kent State University at shop-pdp.kent.edu by "anonymous" + FTP. + + + Page vii + + + + + + + + + P R E F A C E + + + + + + The ASxxxx assemblers were written following the style of + several cross assemblers found in the Digital Equipment Corpora- + tion Users Society (DECUS) distribution of the C programming + language. The DECUS code was provided with no documentation as + to the input syntax or the output format. Study of the code + revealed that the unknown author of the code had attempted to + formulate an assembler with attributes similiar to those of the + PDP-11 MACRO assembler (without macro's). The incomplete code + from the DECUS C distribution has been largely rewritten, only + the program structure, and C source file organization remains + relatively unchanged. However, I wish to thank the author for + his contribution to this set of assemblers. + + The ASLINK program was written as a companion to the ASxxxx + assemblers, its design and implementation was not derived from + any other work. + + The ASxxxx assemblers and the ASLINK relocating linker are + placed in the Public Domain. Publication or distribution of + these programs for non-commercial use is hereby granted with the + stipulation that the copyright notice be included with all + copies. + + I would greatly appreciate receiving the details of any + changes, additions, or errors pertaining to these programs and + will attempt to incorporate any fixes or generally useful + changes in a future update to these programs. + + + + Alan R. Baldwin + Kent State University + Physics Department + Kent, Ohio 44242 + + + baldwin@shop-pdp.kent.edu + tel: (216) 672 2531 + fax: (216) 672 2959 + + + + + + + + + + + + + + + CHAPTER 1 + + THE ASSEMBLER + + + + + + 1.1 THE ASXXXX ASSEMBLERS + + + The ASxxxx assemblers are a series of microprocessor assem- + blers written in the C programming language. Each assembler has + a device specific section which includes: + + 1. device description, byte order, and file extension in- + formation + + 2. a table of the assembler general directives, special + device directives, assembler mnemonics and associated + operation codes + + 3. machine specific code for processing the device mnemon- + ics, addressing modes, and special directives + + The device specific information is detailed in the appendices. + + The assemblers have a common device independent section which + handles the details of file input/output, symbol table genera- + tion, program/data areas, expression analysis, and assembler + directive processing. + + The assemblers provide the following features: + + 1. Command string control of assembly functions + + 2. Alphabetized, formatted symbol table listing + + 3. Relocatable object modules + + 4. Global symbols for linking object modules + + 5. Conditional assembly directives + + + + THE ASSEMBLER PAGE 1-2 + THE ASXXXX ASSEMBLERS + + + 6. Program sectioning directives + + + ASxxxx assembles one or more source files into a single relo- + catable ascii object file. The output of the ASxxxx assemblers + consists of an ascii relocatable object file(*.rel), an assembly + listing file(*.lst), and a symbol file(*.sym). + + + 1.1.1 Assembly Pass 1 + + + During pass 1, ASxxxx opens all source files and performs a + rudimenatry assembly of each source statement. During this pro- + cess all symbol tables are built, program sections defined, and + number of bytes for each assembled source line is estimated. + + At the end of pass 1 all undefined symbols may be made global + (external) using the ASxxxx switch -g, otherwise undefined sym- + bols will be flagged as errors during succeeding passes. + + + 1.1.2 Assembly Pass 2 + + + During pass 2 the ASxxxx assembler resolves forward refer- + ences and determines the number of bytes for each assembled + line. The number of bytes used by a particular assembler in- + struction may depend upon the addressing mode, whether the in- + struction allows multiple forms based upon the relative distance + to the addressed location, or other factors. Pass 2 resolves + these cases and determines the address of all symbols. + + + 1.1.3 Assembly Pass 3 + + + Pass 3 by the assembler generates the listing file, the relo- + catable output file, and the symbol tables. Also during pass 3 + the errors will be reported. + + The relocatable object file is an ascii file containing sym- + bol references and definitions, program area definitions, and + the relocatable assembled code, the linker ASLINK will use this + information to generate an absolute load file (Motorola or Intel + formats). + + + + + THE ASSEMBLER PAGE 1-3 + SOURCE PROGRAM FORMAT + + + 1.2 SOURCE PROGRAM FORMAT + + + + 1.2.1 Statement Format + + + A source program is composed of assembly-language statements. + Each statement must be completed on one line. A line may con- + tain a maximum of 128 characters, longer lines are truncated and + lost. + + An ASxxxx assembler statement may have as many as four + fields. These fields are identified by their order within the + statement and/or by separating characters between fields. The + general format of the ASxxxx statement is: + + [label:] Operator Operand [;Comment(s)] + + The label and comment fields are optional. The operator and + operand fields are interdependent. The operator field may be an + assembler directive or an assembly mnemonic. The operand field + may be optional or required as defined in the context of the + operator. + + ASxxxx interprets and processes source statements one at a + time. Each statement causes a particular operation to be per- + formed. + + + 1.2.1.1 Label Field - + + A label is a user-defined symbol which is assigned the value + of the current location counter and entered into the user de- + fined symbol table. The current location counter is used by + ASxxxx to assign memory addresses to the source program state- + ments as they are encountered during the assembly process. Thus + a label is a means of symbolically referring to a specific + statement. + + When a program section is absolute, the value of the current + location counter is absolute; its value references an absolute + memory address. Similarly, when a program section is relocat- + able, the value of the current location counter is relocatable. + A relocation bias calculated at link time is added to the ap- + parent value of the current location counter to establish its + effective absolute address at execution time. (The user can + also force the linker to relocate sections defined as absolute. + This may be required under special circumstances.) + + If present, a label must be the first field in a source + statement and must be terminated by a colon (:). For example, + + + THE ASSEMBLER PAGE 1-4 + SOURCE PROGRAM FORMAT + + + if the value of the current location counter is absolute + 01F0(H), the statement: + + abcd: nop + + assigns the value 01F0(H) to the label abcd. If the location + counter value were relocatable, the final value of abcd would be + 01F0(H)+K, where K represents the relocation bias of the program + section, as calculated by the linker at link time. + + More than one label may appear within a single label field. + Each label so specified is assigned the same address value. For + example, if the value of the current location counter is + 1FF0(H), the multiple labels in the following statement are each + assigned the value 1FF0(H): + + abcd: aq: $abc: nop + + Multiple labels may also appear on successive lines. For ex- + ample, the statements + + abcd: + aq: + $abc: nop + + likewise cause the same value to be assigned to all three la- + bels. + + A double colon (::) defines the label as a global symbol. + For example, the statement + + abcd:: nop + + establishes the label abcd as a global symbol. The distinguish- + ing attribute of a global symbol is that it can be referenced + from within an object module other than the module in which the + symbol is defined. References to this label in other modules + are resolved when the modules are linked as a composite execut- + able image. + + The legal characters for defining labels are: + + A through Z + a through z + 0 through 9 + . (Period) + $ (Dollar sign) + _ (underscore) + + A label may be any length, however, only the first eight (8) + characters are significant and, therefore must be unique among + all labels in the source program (not necessarily among + + + THE ASSEMBLER PAGE 1-5 + SOURCE PROGRAM FORMAT + + + separately compiled modules). An error code(s) (m or p) will be + generated in the assembly listing if the first eight characters + in two or more labels are the same. The m code is caused by the + redeclaration of the symbol or its reference by another state- + ment. The p code is generated because the symbols location is + changing on each pass through the source file. + + The label must not start with the characters 0-9, as this + designates a local symbol with special attributes described in a + later section. + + The label must not start with the sequence $$, as this + represents the temporary radix 16 for constants. + + + 1.2.1.2 Operator Field - + + The operator field specifies the action to be performed. It + may consist of an instruction mnemonic (op code) or an assembler + directive. + + When the operator is an instruction mnemonic, a machine in- + struction is generated and the assembler evaluates the addresses + of the operands which follow. When the operator is a directive + ASxxxx performs certain control actions or processing operations + during assembly of the source program. + + Leading and trailing spaces or tabs in the operator field + have no significance; such characters serve only to separate + the operator field from the preceeding and following fields. + + An operator is terminated by a space, tab or end of line. + + + 1.2.1.3 Operand Field - + + When the operator is an instruction mnemonic (op code), the + operand field contains program variables that are to be + evaluated/manipulated by the operator. + + Operands may be expressions or symbols, depending on the + operator. Multiple expressions used in the operand fields may + be separated by a comma. An operand should be preceeded by an + operator field; if it is not, the statement will give an error + (q or o). All operands following instruction mnemonics are + treated as expressions. + + The operand field is terminated by a semicolon when the field + is followed by a comment. For example, in the following + statement: + + label: lda abcd,x ;Comment field + + + THE ASSEMBLER PAGE 1-6 + SOURCE PROGRAM FORMAT + + + + the tab between lda and abcd terminates the operator field and + defines the beginning of the operand field; a comma separates + the operands abcd and x; and a semicolon terminates the operand + field and defines the beginning of the comment field. When no + comment field follows, the operand field is terminated by the + end of the source line. + + + 1.2.1.4 Comment Field - + + The comment field begins with a semicolon and extends through + the end of the line. This field is optional and may contain any + 7-bit ascii character except null. + + Comments do not affect assembly processing or program execu- + tion. + + + 1.3 SYMBOLS AND EXPRESSIONS + + + This section describes the generic components of the ASxxxx + assemblers: the character set, the conventions observed in con- + structing symbols, and the use of numbers, operators, and ex- + pressions. + + + 1.3.1 Character Set + + + The following characters are legal in ASxxxx source programs: + + 1. The letters A through Z. Both upper- and lower-case + letters are acceptable. The assemblers are case sensi- + tive, i.e. ABCD and abcd are different symbols. (The + assemblers can be made case insensitive by recompiling + with the appropriate switches.) + + 2. The digits 0 through 9 + + 3. The characters . (period), $ (dollar sign), and _ (un- + derscore). + + 4. The special characters listed in Tables 1 through 6. + + + Tables 1 through 6 describe the various ASxxxx label and + field terminators, assignment operators, operand separators, as- + sembly, unary, binary, and radix operators. + + + THE ASSEMBLER PAGE 1-7 + SYMBOLS AND EXPRESSIONS + + + Table 1 Label Terminators and Assignment Operators + ---------------------------------------------------------------- + + : Colon Label terminator. + + :: Double colon Label Terminator; defines the + label as a global label. + + = Equal sign Direct assignment operator. + + == Double equal Direct assignment operator; + sign defines the symbol as a global + symbol. + + ---------------------------------------------------------------- + + + + + + Table 2 Field Terminators and Operand Separators + ---------------------------------------------------------------- + + Tab Item or field terminator. + + Space Item or field terminator. + + , Comma Operand field separator. + + ; Semicolon Comment field indicator. + + ---------------------------------------------------------------- + + + + + + Table 3 Assembler Operators + ---------------------------------------------------------------- + + # Number sign Immediate expression indicator. + + . Period Current location counter. + + ( Left parenthesis Expression delimiter. + + ) Right parenthesis Expression delimeter. + + ---------------------------------------------------------------- + + + THE ASSEMBLER PAGE 1-8 + SYMBOLS AND EXPRESSIONS + + + + + + + + Table 4 Unary Operators + ---------------------------------------------------------------- + + < Left bracket Right bracket >FEDC Produces the upper byte + value of the expression. + (FE) + + + Plus sign +A Positive value of A + + - Minus sign -A Produces the negative + (2's complement) of A. + + ~ Tilde ~A Produces the 1's comple- + ment of A. + + ' Single quote 'D Produces the value of + the character D. + + " Double quote "AB Produces the double byte + value for AB. + + \ Backslash '\n Unix style characters + \b, \f, \n, \r, \t + or '\001 or octal byte values. + + ---------------------------------------------------------------- + + + + + + + + THE ASSEMBLER PAGE 1-9 + SYMBOLS AND EXPRESSIONS + + + Table 5 Binary Operators + ---------------------------------------------------------------- + + << Double 0800 << 4 Produces the 4 bit + Left bracket left-shifted value of + 0800. (8000) + + >> Double 0800 >> 4 Produces the 4 bit + Right bracket right-shifted value of + 0800. (0080) + + + Plus sign A + B Arithmetic Addition + operator. + + - Minus sign A - B Arithmetic Subtraction + operator. + + * Asterisk A * B Arithmetic Multiplica- + tion operator. (signed + 16-bit) + + / Slash A / B Arithmetic Division + operator. (signed + 16-bit quotient) + + & Ampersand A & B Logical AND operator. + + | Bar A | B Logical OR operator. + + % Percent sign A % B Modulus operator. + (16-bit value) + + ^ Up arrow or A ^ B EXCLUSIVE OR operator. + circumflex + + ---------------------------------------------------------------- + + + + + + + + THE ASSEMBLER PAGE 1-10 + SYMBOLS AND EXPRESSIONS + + + Table 6 Temporary Radix Operators + ---------------------------------------------------------------- + + $%, 0b, 0B Binary radix operator. + + $&, 0o, 0O, 0q, 0Q Octal radix operator. + + $#, 0d, 0D Decimal radix operator. + + $$, 0h, 0H, 0x, 0X Hexidecimal radix operator. + + + Potential ambiguities arising from the use of 0b and 0d + as temporary radix operators may be circumvented by pre- + ceding all non-prefixed hexidecimal numbers with 00. + Leading 0's are required in any case where the first + hexidecimal digit is abcdef as the assembler will treat + the letter sequence as a label. + + ---------------------------------------------------------------- + + + + + + + + 1.3.2 User-Defined Symbols + + + User-defined symbols are those symbols that are equated to a + specific value through a direct assignment statement or appear + as labels. These symbols are added to the User Symbol Table as + they are encountered during assembly. + + The following rules govern the creation of user-defined symbols: + + 1. Symbols can be composed of alphanumeric characters, + dollar signs ($), periods (.), and underscores (_) + only. + + 2. The first character of a symbol must not be a number + (except in the case of local symbols). + + 3. The first eight characters of a symbol must be unique. + A symbol can be written with more than eight legal + characters, but the ninth and subsequent characters are + ignored. + + 4. Spaces and Tabs must not be embedded within a symbol. + + + + + THE ASSEMBLER PAGE 1-11 + SYMBOLS AND EXPRESSIONS + + + 1.3.3 Local Symbols + + + Local symbols are specially formatted symbols used as labels + within a block of coding that has been delimited as a local sym- + bol block. Local symbols are of the form n$, where n is a + decimal integer from 0 to 255, inclusive. Examples of local + symbols are: + + 1$ + 27$ + 138$ + 244$ + + The range of a local symbol block consists of those state- + ments between two normally constructed symbolic labels. Note + that a statement of the form: + + ALPHA = EXPRESSION + + is a direct assignment statement but does not create a label and + thus does not delimit the range of a local symbol block. + + Note that the range of a local symbol block may extend across + program areas. + + Local symbols provide a convenient means of generating labels + for branch instructions and other such references within local + symbol blocks. Using local symbols reduces the possibility of + symbols with multiple definitions appearing within a user pro- + gram. In addition, the use of local symbols differentiates + entry-point labels from local labels, since local labels cannot + be referenced from outside their respective local symbol blocks. + Thus, local symbols of the same name can appear in other local + symbol blocks without conflict. Local symbols require less sym- + bol table space than normal symbols. Their use is recommended. + + The use of the same local symbol within a local symbol block + will generate one or both of the m or p errors. + + + THE ASSEMBLER PAGE 1-12 + SYMBOLS AND EXPRESSIONS + + + Example of local symbols: + + a: ldx #atable ;get table address + lda #0d48 ;table length + 1$: clr ,x+ ;clear + deca + bne 1$ + + b: ldx #btable ;get table address + lda #0d48 ;table length + 1$: clr ,x+ ;clear + deca + bne 1$ + + + 1.3.4 Current Location Counter + + + The period (.) is the symbol for the current location coun- + ter. When used in the operand field of an instruction, the + period represents the address of the first byte of the + instruction: + + AS: ldx #. ;The period (.) refers to + ;the address of the ldx + ;instruction. + + When used in the operand field of an ASxxxx directive, it + represents the address of the current byte or word: + + QK = 0 + + .word 0xFFFE,.+4,QK ;The operand .+4 in the .word + ;directive represents a value + ;stored in the second of the + ;three words during assembly. + + If we assume the current value of the program counter is + 0H0200, then during assembly, ASxxxx reserves three words of + storage starting at location 0H0200. The first value, a hex- + idecimal constant FFFE, will be stored at location 0H0200. The + second value represented by .+4 will be stored at location + 0H0202, its value will be 0H0206 ( = 0H0202 + 4). The third + value defined by the symbol QK will be placed at location + 0H0204. + + At the beginning of each assembly pass, ASxxxx resets the lo- + cation counter. Normally, consecutive memory locations are as- + signed to each byte of object code generated. However, the + value of the location counter can be changed through a direct + assignment statement of the following form: + + + + THE ASSEMBLER PAGE 1-13 + SYMBOLS AND EXPRESSIONS + + + . = . + expression + + + The new location counter can only be specified relative to + the current location counter. Neglecting to specify the current + program counter along with the expression on the right side of + the assignment operator will generate the (.) error. (Absolute + program areas may use the .org directive to specify the absolute + location of the current program counter.) + + The following coding illustrates the use of the current location + counter: + + .area CODE1 (ABS) ;program area CODE1 + ;is ABSOLUTE + + .org 0H100 ;set location to + ;0H100 absolute + + num1: ldx #.+0H10 ;The label num1 has + ;the value 0H100. + ;X is loaded with + ;0H100 + 0H10 + + .org 0H130 ;location counter + ;set to 0H130 + + num2: ldy #. ;The label num2 has + ;the value 0H130. + ;Y is loaded with + ;value 0H130. + + + .area CODE2 (REL) ;program area CODE2 + ;is RELOCATABLE + + . = . + 0H20 ;Set location counter + ;to relocatable 0H20 of + ;the program section. + + num3: .word 0 ;The label num3 has + ;the value + ;of relocatable 0H20. + + . = . + 0H40 ;will reserve 0H40 + ;bytes of storage as will + .blkb 0H40 ;or + .blkw 0H20 + + The .blkb and .blkw directives are the preferred methods of + allocating space. + + + + THE ASSEMBLER PAGE 1-14 + SYMBOLS AND EXPRESSIONS + + + 1.3.5 Numbers + + + ASxxxx assumes that all numbers in the source program are to + be interpreted in decimal radix unless otherwise specified. The + .radix directive may be used to specify the default as octal, + decimal, or hexidecimal. Individual numbers can be designated + as binary, octal, decimal, or hexidecimal through the temporary + radix prefixes shown in table 6. + + Negative numbers must be preceeded by a minus sign; ASxxxx + translates such numbers into two's complement form. Positive + numbers may (but need not) be preceeded by a plus sign. + + Numbers are always considered to be absolute values, therefor + they are never relocatable. + + + 1.3.6 Terms + + + A term is a component of an expression and may be one of the + following: + + + 1. A number. + + 2. A symbol: + 1. A period (.) specified in an expression causes the + current location counter to be used. + 2. A User-defined symbol. + 3. An undefined symbol is assigned a value of zero and + inserted in the User-Defined symbol table as an un- + defined symbol. + + 3. A single quote followed by a single ascii character, or + a double quote followed by two ascii characters. + + 4. An expression enclosed in parenthesis. Any expression + so enclosed is evaluated and reduced to a single term + before the remainder of the expression in which it ap- + pears is evaluated. Parenthesis, for example, may be + used to alter the left-to-right evaluation of expres- + sions, (as in A*B+C versus A*(B+C)), or to apply a un- + ary operator to an entire expression (as in -(A+B)). + + 5. A unary operator followed by a symbol or number. + + + + + + THE ASSEMBLER PAGE 1-15 + SYMBOLS AND EXPRESSIONS + + + 1.3.7 Expressions + + + Expressions are combinations of terms joined together by + binary operators. Expressions reduce to a 16-bit value. The + evaluation of an expression includes the determination of its + attributes. A resultant expression value may be one of three + types (as described later in this section): relocatable, ab- + solute, and external. + + Expressions are evaluate with an operand hierarchy as follows: + + * / % multiplication, + division, and + modulus first. + + + - addition and + subtraction second. + + << >> left shift and + right shift third. + + ^ exclusive or fourth. + + & logical and fifth. + + | logical or last + + except that unary operators take precedence over binary + operators. + + + A missing or illegal operator terminates the expression + analysis, causing error codes (o) and/or (q) to be generated + depending upon the context of the expression itself. + + At assembly time the value of an external (global) expression + is equal to the value of the absolute part of that expression. + For example, the expression external+4, where 'external' is an + external symbol, has the value of 4. This expression, however, + when evaluated at link time takes on the resolved value of the + symbol 'external', plus 4. + + Expressions, when evaluated by ASxxxx, are one of three + types: relocatable, absolute, or external. The following dis- + tinctions are important: + + 1. An expression is relocatable if its value is fixed re- + lative to the base address of the program area in which + it appears; it will have an offset value added at link + time. Terms that contain labels defined in relocatable + program areas will have a relocatable value; + + + THE ASSEMBLER PAGE 1-16 + SYMBOLS AND EXPRESSIONS + + + similarly, a period (.) in a relocatable program area, + representing the value of the current program location + counter, will also have a relocatable value. + + 2. An expression is absolute if its value is fixed. An + expression whose terms are numbers and ascii characters + will reduce to an absolute value. A relocatable ex- + pression or term minus a relocatable term, where both + elements being evaluated belong to the same program + area, is an absolute expression. This is because every + term in a program area has the same relocation bias. + When one term is subtracted from the other the reloca- + tion bias is zero. + + 3. An expression is external (or global) if it contains a + single global reference (plus or minus an absolute ex- + pression value) that is not defined within the current + program. Thus, an external expression is only par- + tially defined following assembly and must be resolved + at link time. + + + + 1.4 GENERAL ASSEMBLER DIRECTIVES + + + An ASxxxx directive is placed in the operator field of the + source line. Only one directive is allowed per source line. + Each directive may have a blank operand field or one or more + operands. Legal operands differ with each directive. + + + 1.4.1 .module Directive + + Format: + + .module string + + The .module directive causes the string to be included in the + assemblers output file as an identifier for this particular ob- + ject module. The string may be from 1 to 8 characters in + length. Only one identifier is allowed per assembled module. + The main use of this directive is to allow the linker to report + a modules' use of undefined symbols. At link time all undefined + symbols are reported and the modules referencing them are + listed. + + + + + THE ASSEMBLER PAGE 1-17 + GENERAL ASSEMBLER DIRECTIVES + + + 1.4.2 .title Directive + + Format: + + .title string + + The .title directive provides a character string to be placed + on the second line of each page during listing. + + + 1.4.3 .sbttl Directive + + Format: + + .sbttl string + + The .sbttl directive provides a character string to be placed + on the third line of each page during listing. + + + 1.4.4 .page Directive + + Format: + + .page + + The .page directive causes a page ejection with a new heading + to be printed. The new page occurs after the next line of the + source program is processed, this allows an immediately follow- + ing .sbttl directive to appear on the new page. The .page + source line will not appear in the file listing. Paging may be + disabled by invoking the -p directive. + + + 1.4.5 .byte and .db Directives + + Format: + + .byte exp ;Stores the binary value + .db exp ;of the expression in the + ;next byte. + + .byte exp1,exp2,expn ;Stores the binary values + .db exp1,exp2,expn ;of the list of expressions + ;in successive bytes. + + where: exp, represent expressions that will be + exp1, truncated to 8-bits of data. + . Each expression will be calculated + . as a 16-bit word expression, + . the high-order byte will be truncated. + . Multiple expressions must be + + + THE ASSEMBLER PAGE 1-18 + GENERAL ASSEMBLER DIRECTIVES + + + expn separated by commas. + + The .byte or .db directives are used to generate successive + bytes of binary data in the object module. + + + 1.4.6 .word and .dw Directives + + Format: + + .word exp ;Stores the binary value + .dw exp ;of the expression in + ;the next word. + + .word exp1,exp2,expn ;Stores the binary values + .dw exp1,exp2,expn ;of the list of expressions + ;in successive words. + + where: exp, represent expressions that will occupy two + exp1, bytes of data. Each expression will be + . calculated as a 16-bit word expression. + . Multiple expressions must be + expn separated by commas. + + The .word or .dw directives are used to generate successive + words of binary data in the object module. + + + 1.4.7 .blkb, .blkw, and .ds Directives + + Format: + + .blkb N ;reserve N bytes of space + .blkw N ;reserve N words of space + .ds N ;reserve N bytes of space + + The .blkb and .ds directives reserve byte blocks in the ob- + ject module; the .blkw directive reserves word blocks. + + + 1.4.8 .ascii Directive + + Format: + + .ascii /string/ + + where: string is a string of printable ascii characters. + + / / represent the delimiting characters. These + delimiters may be any paired printing + characters, as long as the characters are not + contained within the string itself. If the + + + THE ASSEMBLER PAGE 1-19 + GENERAL ASSEMBLER DIRECTIVES + + + delimiting characters do not match, the .ascii + directive will give the (q) error. + + The .ascii directive places one binary byte of data for each + character in the string into the object module. + + + 1.4.9 .ascis Directive + + Format: + + .ascis /string/ + + where: string is a string of printable ascii characters. + + / / represent the delimiting characters. These + delimiters may be any paired printing + characters, as long as the characters are not + contained within the string itself. If the + delimiting characters do not match, the .ascis + directive will give the (q) error. + + The .ascis directive places one binary byte of data for each + character in the string into the object module. The last + character in the string will have the high order bit set. + + + 1.4.10 .asciz Directive + + Format: + + .asciz /string/ + + where: string is a string of printable ascii characters. + + / / represent the delimiting characters. These + delimiters may be any paired printing + characters, as long as the characters are not + contained within the string itself. If the + delimiting characters do not match, the .asciz + directive will give the (q) error. + + The .asciz directive places one binary byte of data for each + character in the string into the object module. Following all + the character data a zero byte is inserted to terminate the + character string. + + + + + THE ASSEMBLER PAGE 1-20 + GENERAL ASSEMBLER DIRECTIVES + + + 1.4.11 .radix Directive + + Format: + + .radix character + + where: character represents a single character specifying the + default radix to be used for succeeding numbers. + The character may be any one of the following: + + B,b Binary + + O,o Octal + Q,q + + D,d Decimal + 'blank' + + H,h Hexidecimal + X,x + + + 1.4.12 .even Directive + + Format: + + .even + + The .even directive ensures that the current location counter + contains an even boundary value by adding 1 if the current loca- + tion is odd. + + + 1.4.13 .odd Directive + + Format: + + .odd + + The .odd directive ensures that the current location counter + contains an odd boundary value by adding one if the current lo- + cation is even. + + + + + THE ASSEMBLER PAGE 1-21 + GENERAL ASSEMBLER DIRECTIVES + + + 1.4.14 .area Directive + + Format: + + .area name [(options)] + + where: name represents the symbolic name of the program sec- + tion. This name may be the same as any + user-defined symbol as the area names are in- + dependent of all symbols and labels. + + options specify the type of program or data area: + ABS absolute (automatically invokes OVR) + REL relocatable + OVR overlay + CON concatenate + PAG paged area + + + The .area directive provides a means of defining and separat- + ing multiple programming and data sections. The name is the + area label used by the assembler and the linker to collect code + from various separately assembled modules into one section. The + name may be from 1 to 8 characters in length. + + The options are specified within parenthesis and separated by + commas as shown in the following example: + + .area TEST (REL,CON) ;This section is relocatable + ;and concatenated with other + ;sections of this program area. + + .area DATA (REL,OVR) ;This section is relocatable + ;and overlays other sections + ;of this program area. + + .area SYS (ABS,OVR) ;(CON not allowed with ABS) + ;This section is defined as + ;absolute. Absolute sections + ;are always overlayed with + ;other sections of this program + ;area. + + .area PAGE (PAG) ;This is a paged section. The + ;section must be on a 256 byte + ;boundary and its length is + ;checked by the linker to be + ;no larger than 256 bytes. + ;This is useful for direct page + ;areas. + + + + THE ASSEMBLER PAGE 1-22 + GENERAL ASSEMBLER DIRECTIVES + + + The default area type is REL|CON; i.e. a relocatable sec- + tion which is concatenated with other sections of code with the + same area name. The ABS option indicates an absolute area. The + OVR and CON options indicate if program sections of the same + name will overlay each other (start at the same location) or be + concatenated with each other (appended to each other). + + Multiple invocations of the .area directive with the same + name must specify the same options or leave the options field + blank, this defaults to the previously specified options for + this program area. + The ASxxxx assemblers automatically provide two program + sections: + + '. .ABS.' This dumby section contains all absolute + symbols and their values. + + '_CODE' This is the default program/data area. + This program area is of type (REL,CON). + The ASxxxx assemblers also automatically generate two symbols + for each program area: + + 's_' This is the starting address of the pro- + gram area. + + indent -16 'l_' This is the + length of the program area. + + + 1.4.15 .org Directive + + Format: + + .org exp + + where: exp is an absolute expression that becomes the cur- + rent location counter. + + The .org directive is valid only in an absolute program section + and will give a (q) error if used in a relocatable program area. + The .org directive specifies that the current location counter + is to become the specified absolute value. + + + + + THE ASSEMBLER PAGE 1-23 + GENERAL ASSEMBLER DIRECTIVES + + + 1.4.16 .globl Directive + + Format: + + .globl sym1,sym2,...,symn + + where: sym1, represent legal symbolic names. When + sym2,... When multiple symbols are specified, + symn they are separated by commas. + + A .globl directive may also have a label field and/or a com- + ment field. + + The .globl directive is provided to define (and thus provide + linkage to) symbols not otherwise defined as global symbols + within a module. In defining global symbols the directive + .globl J is similar to: + + J == expression or J:: + + Because object modules are linked by global symbols, these + symbols are vital to a program. All internal symbols appearing + within a given program must be defined at the end of pass 1 or + they will be considered undefined. The assembly directive (-g) + can be be invoked to make all undefined symbols global at the + end of pass 1. + + + 1.4.17 .if, .else, and .endif Directives + + Format: + + .if expr + . ;} + . ;} range of true condition + . ;} + .else + . ;} + . ;} range of false condition + . ;} + .endif + + The conditional assembly directives allow you to include or + exclude blocks of source code during the assembly process, based + on the evaluation of the condition test. + + The range of true condition will be processed if the expres- + sion 'expr' is not zero (i.e. true) and the range of false con- + dition will be processed if the expression 'expr' is zero (i.e + false). The range of true condition is optional as is the .else + directive and the range of false condition. The following are + all valid .if/.else/.endif constructions: + + + THE ASSEMBLER PAGE 1-24 + GENERAL ASSEMBLER DIRECTIVES + + + + .if A-4 ;evaluate A-4 + .byte 1,2 ;insert bytes if A-4 is + .endif ;not zero + + .if K+3 ;evaluate K+3 + .else + .byte 3,4 ;insert bytes if K+3 + .endif ;is zero + + .if J&3 ;evaluate J masked by 3 + .byte 12 ;insert this byte if J&3 + .else ;is not zero + .byte 13 ;insert this byte if J&3 + .endif ;is zero + + + The .if/.else/.endif directives may be nested upto 10 levels. + + The .page directive is processed within a false condition + range to allow extended textual information to be incorporated + in the source program with out the need to use the comment + delimiter (;): + + .if 0 + + .page + This text will be bypassed during assembly + but appear in the listing file. + . + . + . + + .endif + + + 1.4.18 .include Directive + + Format: + + .include string + + where: string represents a delimited string that is the file + specification of an ASxxxx source file. + + The .include directive is used to insert a source file within + the source file currently being assembled. When this directive + is encountered, an implicit .page directive is issued. When the + end of the specified source file is reached, an implicit .page + directive is issued and input continues from the previous source + file. The maximum nesting level of source files specified by a + .include directive is five. + + + THE ASSEMBLER PAGE 1-25 + GENERAL ASSEMBLER DIRECTIVES + + + The total number of separately specified .include files is + unlimited as each .include file is opened and then closed during + each pass made by the assembler. + + + 1.4.19 .setdp Directive + + Format: + + .setdp [base [,area]] + + The set direct page directive has a common format in all the + AS68xx assemblers. The .setdp directive is used to inform the + assembler of the current direct page region and the offset ad- + dress within the selected area. The normal invocation methods + are: + + .area DIRECT (PAG) + .setdp + + or + + .setdp 0,DIRECT + + for all the 68xx microprocessors (the 6804 has only the paged + ram area). The commands specify that the direct page is in area + DIRECT and its offset address is 0 (the only valid value for all + but the 6809 microprocessor). Be sure to place the DIRECT area + at address 0 during linking. When the base address and area are + not specified, then zero and the current area are the defaults. + If a .setdp directive is not issued the assembler defaults the + direct page to the area "_CODE" at offset 0. + + The assembler verifies that any local variable used in a + direct variable reference is located in this area. Local vari- + able and constant value direct access addresses are checked to + be within the address range from 0 to 255. + + External direct references are assumed by the assembler to be + in the correct area and have valid offsets. The linker will + check all direct page relocations to verify that they are within + the correct area. + + The 6809 microprocessor allows the selection of the direct + page to be on any 256 byte boundary by loading the appropriate + value into the dp register. Typically one would like to select + the page boundary at link time, one method follows: + + + THE ASSEMBLER PAGE 1-26 + GENERAL ASSEMBLER DIRECTIVES + + + .area DIRECT (PAG) ; define the direct page + .setdp + . + . + . + .area PROGRAM + . + ldd #DIRECT ; load the direct page register + tfr a,dp ; for access to the direct page + + At link time specify the base and global equates to locate the + direct page: + + -b DIRECT = 0x1000 + -g DIRECT = 0x1000 + + Both the area address and offset value must be specified (area + and variable names are independent). The linker will verify + that the relocated direct page accesses are within the direct + page. + The preceeding sequence could be repeated for multiple paged + areas, however an alternate method is to define a non-paged area + and use the .setdp directive to specify the offset value: + + .area DIRECT ; define non-paged area + . + . + . + .area PROGRAM + . + .setdp 0,DIRECT ; direct page area + ldd #DIRECT ; load the direct page register + tfr a,dp ; for access to the direct page + . + . + .setdp 0x100,DIRECT ; direct page area + ldd #DIRECT+0x100 ; load the direct page register + tfr a,dp ; for access to the direct page + + The linker will verify that subsequent direct page references + are in the specified area and offset address range. It is the + programmers responsibility to load the dp register with the cor- + rect page segment corresponding to the .setdp base address + specified. + + For those cases where a single piece of code must access a + defined data structure within a direct page and there are many + pages, define a dumby direct page linked at address 0. This + dumby page is used only to define the variable labels. Then + load the dp register with the real base address but donot use a + .setdp directive. This method is equivalent to indexed + + + THE ASSEMBLER PAGE 1-27 + GENERAL ASSEMBLER DIRECTIVES + + + addressing, where the dp register is the index register and the + direct addressing is the offset. + + + 1.5 INVOKING ASXXXX + + + The ASxxxx assemblers are command line oriented. After the + assembler is started, enter the option(s) and file(s) to assem- + ble following the 'argv:' prompt: + + argv: [-dqxgalosf] file1 [file2 file3 ... file6] + + The options are: + + d decimal listing + q octal listing + x hex listing (default) + + The listing radix affects the + .lst, .rel, and .sym files. + + g undefined symbols made global + a all user symbols made global + + l create list output file1.lst + o create object output file1.rel + s create symbol output file1.sym + + p disable listing pagination + + relocatable reference flagging: + + f by ` in the listing file + ff by mode in the listing file + + The file name for the .lst, .rel, and .sym files is the first + file name specified in the command line. All output files are + ascii text files which may be edited, copied, etc. The output + files are the concatenation of all the input files, if files are + to be assembled independently invoke the assembler for each + file. + + The .rel file contains a radix directive so that the linker + will use the proper conversion for this file. Linked files may + have different radices. + + If the list (l) option is specified without the symbol table + (s) option, the symbol table is placed at the end of the listing + file. + + + + + THE ASSEMBLER PAGE 1-28 + ERRORS + + + 1.6 ERRORS + + + The ASxxxx assemblers provide limited diagnostic error codes + during the assembly process, these errors will be noted in the + listing file and printed on the stderr device. + + The assembler reports the errors on the stderr device as + + ?ASxxxx-Error-<*> in line nnn of filename + + where * is the error code, nnn is the line number, and filename + is the source/include file. + + The errors are: + + (.) This error is caused by an absolute direct assign- + ment of the current location counter + . = expression (incorrect) + rather than the correct + . = . + expression + + (a) Indicates a machine specific addressing or address- + ing mode error. + + (b) Indicates a direct page boundary error. + + (d) Indicates a direct page addressing error. + + (i) Caused by an .include file error or an .if/.endif + mismatch. + + (m) Multiple definitions of the same label, multiple + .module directives, or multiple conflicting attri- + butes in an .area directive. + + (o) Directive or mnemonic error or the use of the .org + directive in a relocatable area. + + (p) Phase error: label location changing between passes + 2 and 3. Normally caused by having more than one + level of forward referencing. + + (q) Questionable syntax: missing or improper operators, + terminators, or delimiters. + + (r) Relocation error: logic operation attempted on a + relocatable term, addition of two relocatable terms, + subtraction of two relocatable terms not within the + same programming area or external symbols. + + (u) Undefined symbol encountered during assembly. + + + THE ASSEMBLER PAGE 1-29 + LISTING FILE + + + 1.7 LISTING FILE + + + The (-l) option produces an ascii output listing file. Each + page of output contains a four line header: + + + 1. The ASxxxx program name and page number + + 2. Title from a .title directive (if any) + + 3. Subtitle from a .sbttl directive (if any) + + 4. Blank line + + + + Each succeeding line contains five fields: + + + 1. Error field (first three characters of line) + + 2. Current location counter + + 3. Generated code in byte format + + 4. Source text line number + + 5. Source text + + + The error field may contain upto 2 error flags indicating any + errors encountered while assembling this line of source code. + + The current location counter field displays the 16-bit pro- + gram position. This field will be in the selected radix. + + The generated code follows the program location. The listing + radix determines the number of bytes that will be displayed in + this field. Hexidecimal listing allows six bytes of data within + the field, decimal and octal allow four bytes within the field. + If more than one field of data is generated from the assembly of + a single line of source code, then the data field is repeated on + successive lines. + + The source text line number is printed in decimal and is fol- + lowed by the source text. + + Two special cases will disable the listing of a line of + source text: + + + + THE ASSEMBLER PAGE 1-30 + LISTING FILE + + + 1. Source line with a .page directive is never listed. + + 2. Source line with a .include file directive is not + listed unless the .include file cannot be opened. + + + Two data field options are available to flag those bytes + which will be relocated by the linker. If the -f option is + specified then each byte to be relocated will be preceeded by + the '`' character. If the -ff option is specified then each + byte to be relocated will be preceeded by one of the following + characters: + + 1. * paged relocation + + 2. u low byte of unsigned word or unsigned byte + + 3. v high byte of unsigned word + + 4. p PCR low byte of word relocation or PCR byte + + 5. q PCR high byte of word relocation + + 6. r low byte relocation or byte relocation + + 7. s high byte relocation + + + + 1.8 SYMBOL TABLE FILE + + + The symbol table has two parts: + + 1. The alphabetically sorted list of symbols and/or labels + defined or referenced in the source program. + + 2. A list of the program areas defined during assembly of + the source program. + + + The sorted list of symbols and/or labels contains the follow- + ing information: + + 1. Program area number (none if absolute value or exter- + nal) + + 2. The symbol or label + + 3. Directly assigned symbol is denoted with an (=) sign + + + + THE ASSEMBLER PAGE 1-31 + SYMBOL TABLE FILE + + + 4. The value of a symbol, location of a label relative to + the program area base address (=0), or a **** indicat- + ing the symbol or label is undefined. + + 5. The characters: G - global, R - relocatable, and X - + external. + + + The list of program areas provides the correspondence between + the program area numbers and the defined program areas, the size + of the program areas, and the area flags (attributes). + + + 1.9 OBJECT FILE + + + The object file is an ascii file containing the information + needed by the linker to bind multiple object modules into a com- + plete loadable memory image. The object module contains the + following designators: + + [XDQ][HL] + X Hexidecimal radix + D Decimal radix + Q Octal radix + + H Most significant byte first + L Least significant byte first + + H Header + M Module + A Area + S Symbol + T Object code + R Relocation information + P Paging information + + Refer to the linker for a detailed description of each of the + designators and the format of the information contained in the + object file. + + + + + + + + + + + + + + + CHAPTER 2 + + THE LINKER + + + + + + 2.1 ASLINK RELOCATING LINKER + + + ASLINK is the companion linker for the ASxxxx assemblers. + + The program ASLINK is a general relocating linker performing + the following functions: + + 1. Bind multiple object modules into a single memory image + + 2. Resolve inter-module symbol references + + 3. Combine code belonging to the same area from multiple + object files into a single contiguous memory region + + 4. Search and import object module libraries for undefined + global variables + + 5. Perform byte and word program counter relative + (pc or pcr) addressing calculations + + 6. Define absolute symbol values at link time + + 7. Define absolute area base address values at link time + + 8. Produce Intel Hex or Motorola S19 output file + + 9. Produce a map of the linked memory image + + 10. Produce an updated listing file with the relocated ad- + dresses and data + + + + + + THE LINKER PAGE 2-2 + INVOKING ASLINK + + + 2.2 INVOKING ASLINK + + + The linker may run in the command line mode or command file + modes. The allowed startup linker commands are: + + -c/-f command line / command file modes + + -p/-n enable/disable echo file.lnk input to stdout + + If command line mode is selected, all linker commands come + from stdin, if the command file mode is selected the commands + are input from the specified file (extension must be .lnk). + + The linker is started via + + ASLINK -(cfpn) + + After invoking the linker the valid options are: + + 1. -i/-s Intel Hex (file.ihx) or Motorola S19 (file.s19) + image output file. + + 2. -m Generate a map file (file.map). This file con- + tains a list of the symbols (by area) with absolute ad- + dresses, sizes of linked areas, and other linking + information. + + 3. -u Generate an updated listing file (file.rst) + derived from the relocated addresses and data from the + linker + + 4. -xdq Specifies the number radix for the map file + (Hexidecimal, Decimal, or Octal). + + 5. fileN Files to be linked. Files may be on the same + line as the above options or on a separate line(s) one + file per line or multiple files separated by spaces or + tabs. + + 6. -b area = expression (one definition per line) + This specifies an area base address where the expres- + sion may contain constants and/or defined symbols from + the linked files. + + 7. -g symbol = expression (one definition per line) + This specifies the value for the symbol where the ex- + pression may contain constants and/or defined symbols + from the linked files. + + 8. -k library directory path + (one definition per line) This specifies one possible + + + THE LINKER PAGE 2-3 + INVOKING ASLINK + + + path to an object library. More than one path is al- + lowed. + + 9. -l library file specification + (one definition per line) This specifies a possible + library file. More than one file is allowed. + + 10. -e or null line, terminates input to the linker. + + + + 2.3 LIBRARY PATH(S) AND FILE(S) + + + The process of resolving undefined symbols after scanning the + input object files includes the scanning of object module + libraries. The linker will search through all combinations of + the library path specifications (input by the -k option) and the + library file specifications (input by the -l option) that lead + to an existing library file. Each library file contains a list + (one file per line) of modules included in this particular + library. Each existing object module is scanned for a match to + the undefined symbol. The first module containing the symbol is + then linked with the previous modules to resolve the symbol de- + finition. The library object modules are rescanned until no + more symbols can be resolved. The scanning algorithm allows + resolution of back references. No errors are reported for non + existant library files or object modules. + + The library file specification may be formed in one of two + ways: + + 1. If the library file contained an absolute path/file + specification then this is the object module's + path/file. + (i.e. C:\...) + + 2. If the library file contains a relative path/file + specification then the concatenation of the path and + this file specification becomes the object module's + path/file. + (i.e. \...) + + + As an example, assume there exists a library file termio.lib + in the syslib directory specifying the following object modules: + + \6809\io_disk first object module + d:\special\io_comm second object module + + and the following parameters were specified to the linker: + + + + THE LINKER PAGE 2-4 + LIBRARY PATH(S) AND FILE(S) + + + -k c:\iosystem\ the first path + -k c:\syslib\ the second path + + -l termio the first library file + -l io the second library file (no such file) + + The linker will attempt to use the following object modules to + resolve any undefined symbols: + + c:\syslib\6809\io_disk.rel (concatenated path/file) + d:\special\io_comm.rel (absolute path/file) + + all other path(s)/file(s) don't exist. (No errors are reported + for non existant path(s)/file(s).) + + + 2.4 ASLINK PROCESSING + + + The linker processes the files in the order they are + presented. The first pass through the input files is used to + define all program areas, the section area sizes, and symbols + defined or referenced. Undefined symbols will initiate a search + of any specified library file(s) and the importing of the module + containing the symbol definition. After the first pass the -b + (area base address) definitions, if any, are processed and the + areas linked. + + The area linking proceeds by first examining the area types + ABS, CON, REL, OVR and PAG. Absolute areas (ABS) from separate + object modules are always overlayed and have been assembled at a + specific address, these are not normally relocated (if a -b com- + mand is used on an absolute area the area will be relocated). + Relative areas (normally defined as REL|CON) have a base address + of 0x0000 as read from the object files, the -b command speci- + fies the beginning address of the area. All subsequent relative + areas will be concatenated with proceeding relative areas. + Where specific ordering is desired, the first linker input file + should have the area definitions in the desired order. At the + completion of the area linking all area addresses and lengths + have been determined. The areas of type PAG are verified to be + on a 256 byte boundary and that the length does not exceed 256 + bytes. Any errors are noted on stderr and in the map file. + + Next the global symbol definitions (-g option), if any, are + processed. The symbol definitions have been delayed until this + point because the absolute addresses of all internal symbols are + known and can be used in the expression calculations. + + Before continuing with the linking process the symbol table + is scanned to determine if any symbols have been referenced but + not defined. Undefined symbols are listed on the stderr device. + + + THE LINKER PAGE 2-5 + ASLINK PROCESSING + + + if a .module directive was included in the assembled file the + module making the reference to this undefined variable will be + printed. + + Constants defined as global in more than one module will be + flagged as multiple definitions if their values are not identi- + cal. + + After the preceeding processes are complete the linker may + output a map file (-m option). This file provides the following + information: + + 1. Global symbol values and label absolute addresses + + 2. Defined areas and there lengths + + 3. Remaining undefined symbols + + 4. List of modules linked + + 5. List of library modules linked + + 6. List of -b and -g definitions + + + + + The final step of the linking process is performed during the + second pass of the input files. As the xxx.rel files are read + the code is relocated by substituting the physical addresses for + the referenced symbols and areas and may be output in Intel or + Motorola formats. The number of files linked and symbols de- + fined/referenced is limited by the processor space available to + build the area/symbol lists. If the -u option is specified then + the listing files (file.lst) associated with the relocation + files (file.rel) are scanned and used to create a new file + (file.rst) which has all addresses and data relocated to their + final values. + + + 2.5 LINKER INPUT FORMAT + + + The linkers' input object file is an ascii file containing + the information needed by the linker to bind multiple object + modules into a complete loadable memory image. + + The object module contains the following designators: + + [XDQ][HL] + X Hexidecimal radix + D Decimal radix + + + THE LINKER PAGE 2-6 + LINKER INPUT FORMAT + + + Q Octal radix + + H Most significant byte first + L Least significant byte first + + H Header + M Module + A Area + S Symbol + T Object code + R Relocation information + P Paging information + + + 2.5.1 Object Module Format + + + The first line of an object module contains the [XDQ][HL] + format specifier (i.e. XH indicates a hexidecimal file with + most significant byte first) for the following designators. + + + 2.5.2 Header Line + + H aa areas gg global symbols + + The header line specifies the number of areas(aa) and the + number of global symbols(gg) defined or referenced in this ob- + ject module segment. + + + 2.5.3 Module Line + + M name + + The module line specifies the module name from which this + header segment was assembled. The module line will not appear + if the .module directive was not used in the source program. + + + 2.5.4 Symbol Line + + S string Defnnnn + + or + + S string Refnnnn + + The symbol line defines (Def) or references (Ref) the symbol + 'string' with the value nnnn. The defined value is relative to + the current area base address. References to constants and + external global symbols will always appear before the first area + + + THE LINKER PAGE 2-7 + LINKER INPUT FORMAT + + + definition. References to external symbols will have a value of + zero. + + + 2.5.5 Area Line + + A label size ss flags ff + + The area line defines the area label, the size (ss) of the + area in bytes, and the area flags (ff). The area flags specify + the ABS, REL, CON, OVR, and PAG parameters: + + OVR/CON (0x04/0x00 i.e. bit position 2) + + ABS/REL (0x08/0x00 i.e. bit position 3) + + PAG (0x10 i.e. bit position 4) + + + 2.5.6 T Line + + T xx xx nn nn nn nn nn ... + + The T line contains the assembled code output by the assem- + bler with xx xx being the offset address from the current area + base address and nn being the assembled instructions and data in + byte format. + + + 2.5.7 R Line + + R 0 0 nn nn n1 n2 xx xx ... + + The R line provides the relocation information to the linker. + The nn nn value is the current area index, i.e. which area the + current values were assembled. Relocation information is en- + coded in groups of 4 bytes: + + 1. n1 is the relocation mode and object format + 1. bit 0 word(0x00)/byte(0x01) + 2. bit 1 relocatable area(0x00)/symbol(0x02) + 3. bit 2 normal(0x00)/PC relative(0x04) relocation + 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for + byte data + 5. bit 4 signed(0x00)/unsigned(0x10) byte data + 6. bit 5 normal(0x00)/page '0'(0x20) reference + 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference + 8. bit 7 LSB byte(0x00)/MSB byte(0x80) with 2-byte + mode + + 2. n2 is a byte index into the corresponding (i.e. pre- + ceeding) T line data (i.e. a pointer to the data to be + + + THE LINKER PAGE 2-8 + LINKER INPUT FORMAT + + + updated by the relocation). The T line data may be + 1-byte or 2-byte byte data format or 2-byte word + format. + + 3. xx xx is the area/symbol index for the area/symbol be- + ing referenced. the corresponding area/symbol is found + in the header area/symbol lists. + + + The groups of 4 bytes are repeated for each item requiring relo- + cation in the preceeding T line. + + + 2.5.8 P Line + + P 0 0 nn nn n1 n2 xx xx + + The P line provides the paging information to the linker as + specified by a .setdp directive. The format of the relocation + information is identical to that of the R line. The correspond- + ing T line has the following information: + T xx xx aa aa bb bb + + Where aa aa is the area reference number which specifies the + selected page area and bb bb is the base address of the page. + bb bb will require relocation processing if the 'n1 n2 xx xx' is + specified in the P line. The linker will verify that the base + address is on a 256 byte boundary and that the page length of an + area defined with the PAG type is not larger than 256 bytes. + + The linker defaults any direct page references to the first + area defined in the input REL file. All ASxxxx assemblers will + specify the _CODE area first, making this the default page area. + + + 2.6 LINKER ERROR MESSAGES + + + The linker provides detailed error messages allowing the pro- + grammer to quickly find the errant code. As the linker com- + pletes pass 1 over the input file(s) it reports any page + boundary or page length errors as follows: + + ?ASlink-Warning-Paged Area PAGE0 Boundary Error + + and/or + + ?ASlink-Warning-Paged Area PAGE0 Length Error + + where PAGE0 is the paged area. + + + + THE LINKER PAGE 2-9 + LINKER ERROR MESSAGES + + + During Pass two the linker reads the T, R, and P lines per- + forming the necessary relocations and outputting the absolute + code. Various errors may be reported during this process + The P line processing can produce only one possible error: + + ?ASlink-Warning-Page Definition Boundary Error + file module pgarea pgoffset + PgDef t6809l t6809l PAGE0 0001 + + The error message specifies the file and module where the .setdp + direct was issued and indicates the page area and the page + offset value determined after relocation. + + + The R line processing produces various errors: + + ?ASlink-Warning-Byte PCR relocation error for symbol bra2 + file module area offset + Refby t6809l t6809l TEST 00FE + Defin tconst tconst . .ABS. 0080 + + ?ASlink-Warning-Unsigned Byte error for symbol two56 + file module area offset + Refby t6800l t6800l DIRECT 0015 + Defin tconst tconst . .ABS. 0100 + + ?ASlink-Warning-Page0 relocation error for symbol ltwo56 + file module area offset + Refby t6800l t6800l DIRECT 000D + Defin tconst tconst DIRECT 0100 + + ?ASlink-Warning-Page Mode relocation error for symbol two56 + file module area offset + Refby t6809l t6809l DIRECT 0005 + Defin tconst tconst . .ABS. 0100 + + ?ASlink-Warning-Page Mode relocation error + file module area offset + Refby t Pagetest PROGRAM 0006 + Defin t Pagetest DIRECT 0100 + + These error messages specify the file, module, area, and offset + within the area of the code referencing (Refby) and defining + (Defin) the symbol. If the symbol is defined in the same module + as the reference the linker is unable to report the symbol name. + The assembler listing file(s) should be examined at the offset + from the specified area to located the offending code. + + The errors are: + + 1. The byte PCR error is caused by exceeding the pc rela- + tive byte branch range. + + + THE LINKER PAGE 2-10 + LINKER ERROR MESSAGES + + + 2. The Unsigned byte error indicates an indexing value was + negative or larger than 255. + + 3. The Page0 error is generated if the direct page vari- + able is not in the page0 range of 0 to 255. + + 4. The page mode error is generated if the direct variable + is not within the current direct page (6809). + + + + THE LINKER Page 2-11 + INTEL HEX OUTPUT FORMAT + + + 2.7 INTEL HEX OUTPUT FORMAT + + Record Mark Field - This field signifies the start of a + record, and consists of an ascii colon + (:). + + Record Length Field - This field consists of two ascii + characters which indicate the number of + data bytes in this record. The + characters are the result of converting + the number of bytes in binary to two + ascii characters, high digit first. An + End of File record contains two ascii + zeros in this field. + + Load Address Field - This field consists of the four ascii + characters which result from converting + the the binary value of the address in + which to begin loading this record. The + order is as follows: + + High digit of high byte of address. + Low digit of high byte of address. + High digit of low byte of address. + Low digit of low byte of address. + + In an End of File record this field con- + sists of either four ascii zeros or the + program entry address. Currently the + entry address option is not supported. + + Record Type Field - This field identifies the record type, + which is either 0 for data records or 1 + for an End of File record. It consists + of two ascii characters, with the high + digit of the record type first, followed + by the low digit of the record type. + + Data Field - This field consists of the actual data, + converted to two ascii characters, high + digit first. There are no data bytes in + the End of File record. + + Checksum Field - The checksum field is the 8 bit binary + sum of the record length field, the load + address field, the record type field, + and the data field. This sum is then + negated (2's complement) and converted + to two ascii characters, high digit + first. + + + THE LINKER Page 2-12 + MOTOROLA S1-S9 OUTPUT FORMAT + + + 2.8 MOTORLA S1-S9 OUTPUT FORMAT + + Record Type Field - This field signifies the start of a + record and identifies the the record + type as follows: + + Ascii S1 - Data Record + Ascii S9 - End of File Record + + Record Length Field - This field specifies the record length + which includes the address, data, and + checksum fields. The 8 bit record + length value is converted to two ascii + characters, high digit first. + + Load Address Field - This field consists of the four ascii + characters which result from converting + the the binary value of the address in + which to begin loading this record. The + order is as follows: + + High digit of high byte of address. + Low digit of high byte of address. + High digit of low byte of address. + Low digit of low byte of address. + + In an End of File record this field con- + sists of either four ascii zeros or the + program entry address. Currently the + entry address option is not supported. + + Data Field - This field consists of the actual data, + converted to two ascii characters, high + digit first. There are no data bytes in + the End of File record. + + Checksum Field - The checksum field is the 8 bit binary + sum of the record length field, the load + address field, and the data field. This + sum is then complemented (1's comple- + ment) and converted to two ascii + characters, high digit first. + + + + + + + + + + + + + + + CHAPTER 3 + + BUILDING ASXXXX AND ASLINK + + + + + The assemblers and linker have been successfully compiled us- + ing the DECUS C (PDP-11) compiler (patch level 9) with + RT-11/TSX+, Eyring Research Institute, Inc. PDOS (680x0) C + V5.4b compiler, and Symantec C/C++ V6.1/V7.0. + + The device specific header file (i.e. m6800.h, m6801.h, + etc.) contains the DECUS C 'BUILD' directives for generating a + command file to compile, assemble, and link the necessary files + to prepare an executable image for a particular assembler. + + + 3.1 BUILDING AN ASSEMBLER + + + The building of a typical assembler (6809 for example) re- + quires the following files: + + 1. M6809.H + 2. M09EXT.C + 3. M09MCH.C + 4. M09ADR.C + 5. M09PST.C + 6. ASM.H + 7. ASMAIN.C + 8. ASLEX.C + 9. ASSYM.C + 10. ASSUBR.C + 11. ASEXPR.C + 12. ASDATA.C + 13. ASLIST.C + 14. ASOUT.C + + + The first five files are the 6809 processor dependent sec- + tions which contain the following: + + + + + BUILDING ASXXXX AND ASLINK PAGE 3-2 + BUILDING AN ASSEMBLER + + + 1. m6809.h - header file containing the machine specific + definitions of constants, variables, structures, and + types + + 2. m09ext - device description, byte order, and file ex- + tension information + + 3. m09pst - a table of the assembler general directives, + special device directives, and assembler mnemonics with + associated operation codes + + 4. m09mch / m09adr - machine specific code for processing + the device mnemonics, addressing modes, and special + directives + + + The remaining nine files provide the device independent sec- + tions which handle the details of file input/output, symbol + table generation, program/data areas, expression analysis, and + assembler directive processing. + + The assembler defaults to the not case sensitive mode. This + may be altered by changing the case sensitivity flag in asm.h to + + /* + * Case Sensitivity Flag + */ + #define CASE_SENSITIVE 1 + + The assemblers and linker should be compiled with the same + case sensitivity option. + + + 3.2 BUILDING ASLINK + + + The building of the linker requires the following files: + + 1. ASLINK.H + 2. LKMAIN.C + 3. LKLEX.C + 4. LKAREA.C + 5. LKHEAD.C + 6. LKSYM.C + 7. LKEVAL.C + 8. LKDATA.C + 9. LKLIST.C + 10. LKRLOC.C + 11. LKLIBR.C + 12. LKS19.C + 13. LKIHX.C + + + + BUILDING ASXXXX AND ASLINK PAGE 3-3 + BUILDING ASLINK + + + The linker defaults to the not case sensitive mode. This may + be altered by changing the case sensitivity flag in aslink.h to + + /* + * Case Sensitivity Flag + */ + #define CASE_SENSITIVE 1 + + The linker and assemblers should be compiled with the same + case sensitivity option. + + + + + + + + + + + + + + + APPENDIX A + + AS6800 ASSEMBLER + + + + + + A.1 6800 REGISTER SET + + The following is a list of the 6800 registers used by AS6800: + + a,b - 8-bit accumulators + x - index register + + + A.2 6800 INSTRUCTION SET + + + The following tables list all 6800/6802/6808 mnemonics recog- + nized by the AS6800 assembler. The designation [] refers to a + required addressing mode argument. The following list specifies + the format for each addressing mode supported by AS6800: + + #data immediate data + byte or word data + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + ,x register indirect addressing + zero offset + + offset,x register indirect addressing + 0 <= offset <= 255 + + ext extended addressing + + label branch label + + The terms data, dir, offset, ext, and label may all be expres- + sions. + + + + AS6800 ASSEMBLER PAGE A-2 + 6800 INSTRUCTION SET + + + Note that not all addressing modes are valid with every in- + struction, refer to the 6800 technical data for valid modes. + + + A.2.1 Inherent Instructions + + aba cba + clc cli + clv daa + des dex + ins inx + nop rti + rts sba + sec sei + sev swi + tab tap + tba tpa + tsx txs + wai + + psha pshb + psh a psh b + pula pulb + pul a pul b + + + A.2.2 Branch Instructions + + bra label bhi label + bls label bcc label + bhs label bcs label + blo label bne label + beq label bvc label + bvs label bpl label + bmi label bge label + blt label bgt label + ble label bsr label + + + AS6800 ASSEMBLER PAGE A-3 + 6800 INSTRUCTION SET + + + A.2.3 Single Operand Instructions + + asla aslb + asl a asl b + asl [] + + asra asrb + asr a asr b + asr [] + + clra clrb + clr a clr b + clr [] + + coma comb + com a com b + com [] + + deca decb + dec a dec b + dec [] + + inca incb + inc a inc b + inc [] + + lsla lslb + lsl a lsl b + lsl [] + + lsra lsrb + lsr a lsr b + lsr [] + + nega negb + neg a neg b + neg [] + + rola rolb + rol a rol b + rol [] + + rora rorb + ror a ror b + ror [] + + tsta tstb + tst a tst b + tst [] + + + AS6800 ASSEMBLER PAGE A-4 + 6800 INSTRUCTION SET + + + A.2.4 Double Operand Instructions + + adca [] adcb [] + adc a [] adc b [] + + adda [] addb [] + add a [] add b [] + + anda [] andb [] + and a [] and b [] + + bita [] bitb [] + bit a [] bit b [] + + cmpa [] cmpb [] + cmp a [] cmp b [] + + eora [] eorb [] + eor a [] eor b [] + + ldaa [] ldab [] + lda a [] lda b [] + + oraa [] orab [] + ora a [] ora b [] + + sbca [] sbcb [] + sbc a [] sbc b [] + + staa [] stab [] + sta a [] sta b [] + + suba [] subb [] + sub a [] sub b [] + + + A.2.5 Jump and Jump to Subroutine Instructions + + jmp [] jsr [] + + + + + AS6800 ASSEMBLER PAGE A-5 + 6800 INSTRUCTION SET + + + A.2.6 Long Register Instructions + + cpx [] + lds [] sts [] + ldx [] stx [] + + + + + + + + + + + + + + + APPENDIX B + + AS6801 ASSEMBLER + + + + + + B.1 .hd6303 DIRECTIVE + + Format: + + .hd6303 + + The .hd6303 directive enables processing of the HD6303 specific + mnemonics not included in the 6801 instruction set. HD6303 + mnemonics encountered without the .hd6303 directive will be + flagged with an 'o' error. + + + B.2 6801 REGISTER SET + + The following is a list of the 6801 registers used by AS6801: + + a,b - 8-bit accumulators + d - 16-bit accumulator + x - index register + + + B.3 6801 INSTRUCTION SET + + + The following tables list all 6801/6303 mnemonics recognized + by the AS6801 assembler. The designation [] refers to a re- + quired addressing mode argument. The following list specifies + the format for each addressing mode supported by AS6801: + + #data immediate data + byte or word data + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + + + AS6801 ASSEMBLER PAGE B-2 + 6801 INSTRUCTION SET + + + ,x register indirect addressing + zero offset + + offset,x register indirect addressing + 0 <= offset <= 255 + + ext extended addressing + + label branch label + + The terms data, dir, offset, ext, and label may all be expres- + sions. + + Note that not all addressing modes are valid with every in- + struction, refer to the 6801/6303 technical data for valid + modes. + + + B.3.1 Inherent Instructions + + aba abx + cba clc + cli clv + daa des + dex ins + inx mul + nop rti + rts sba + sec sei + sev swi + tab tap + tba tpa + tsx txs + wai + + + B.3.2 Branch Instructions + + bra label brn label + bhi label bls label + bcc label bhs label + bcs label blo label + bne label beq label + bvc label bvs label + bpl label bmi label + bge label blt label + bgt label ble label + bsr label + + + AS6801 ASSEMBLER PAGE B-3 + 6801 INSTRUCTION SET + + + B.3.3 Single Operand Instructions + + asla aslb asld + asl a asl b asl d + asl [] + + asra asrb + asr a asr b + asr [] + + clra clrb + clr a clr b + clr [] + + coma comb + com a com b + com [] + + deca decb + dec a dec b + dec [] + + eora eorb + eor a eor b + eor [] + + inca incb + inc a inc b + inc [] + + lsla lslb lsld + lsl a lsl b lsl d + lsl [] + + lsra lsrb lsrd + lsr a lsr b lsr d + lsr [] + + nega negb + neg a neg b + neg [] + + psha pshb pshx + psh a psh b psh x + + pula pulb pulx + pul a pul b pul x + + rola rolb + rol a rol b + rol [] + + + + AS6801 ASSEMBLER PAGE B-4 + 6801 INSTRUCTION SET + + + rora rorb + ror a ror b + ror [] + + tsta tstb + tst a tst b + tst [] + + + B.3.4 Double Operand Instructions + + adca [] adcb [] + adc a [] adc b [] + + adda [] addb [] addd [] + add a [] add b [] add d [] + + anda [] andb [] + and a [] and b [] + + bita [] bitb [] + bit a [] bit b [] + + cmpa [] cmpb [] + cmp a [] cmp b [] + + ldaa [] ldab [] + lda a [] lda b [] + + oraa [] orab [] + ora a [] ora b [] + + sbca [] sbcb [] + sbc a [] sbc b [] + + staa [] stab [] + sta a [] sta b [] + + suba [] subb [] subd [] + sub a [] sub b [] sub d [] + + + + + AS6801 ASSEMBLER PAGE B-5 + 6801 INSTRUCTION SET + + + B.3.5 Jump and Jump to Subroutine Instructions + + jmp [] jsr [] + + + B.3.6 Long Register Instructions + + cpx [] ldd [] + lds [] ldx [] + std [] sts [] + stx [] + + + B.3.7 6303 Specific Instructions + + aim #data, [] eim #data, [] + oim #data, [] tim #data, [] + + xgdx slp + + + + + + + + + + + + + + + APPENDIX C + + AS6804 ASSEMBLER + + + + + Requires the .setdp directive to specify the ram area. + + + C.1 6804 REGISTER SET + + The following is a list of the 6804 registers used by AS6804: + + x,y - index registers + + + C.2 6804 INSTRUCTION SET + + + The following tables list all 6804 mnemonics recognized by + the AS6804 assembler. The designation [] refers to a required + addressing mode argument. The following list specifies the + format for each addressing mode supported by AS6804: + + #data immediate data + byte or word data + + ,x register indirect addressing + + dir direct addressing + (see .setdp directive) + 0 <= dir <= 255 + + ext extended addressing + + label branch label + + The terms data, dir, and ext may be expressions. The label for + the short branchs beq, bne, bcc, and bcs must not be external. + + Note that not all addressing modes are valid with every in- + struction, refer to the 6804 technical data for valid modes. + + + AS6804 ASSEMBLER PAGE C-2 + 6804 INSTRUCTION SET + + + C.2.1 Inherent Instructions + + coma decx + decy incx + incy rola + rti rts + stop tax + tay txa + tya wait + + + C.2.2 Branch Instructions + + bne label beq label + bcc label bcs label + + + C.2.3 Single Operand Instructions + + add [] + and [] + cmp [] + dec [] + inc [] + lda [] + sta [] + sub [] + + + C.2.4 Jump and Jump to Subroutine Instructions + + jsr [] + jmp [] + + + C.2.5 Bit Test Instructions + + brclr #data,[],label + brset #data,[],label + + bclr #label,[] + bset #label,[] + + + + + AS6804 ASSEMBLER PAGE C-3 + 6804 INSTRUCTION SET + + + C.2.6 Load Immediate data Instruction + + mvi [],#data + + + C.2.7 6804 Derived Instructions + + asla + bam label + bap label + bxmi label + bxpl label + bymi label + bypl label + clra + clrx + clry + deca + decx + decy + inca + incx + incy + ldxi #data + ldyi #data + nop + tax + tay + txa + tya + + + + + + + + + + + + + + + APPENDIX D + + AS6805 ASSEMBLER + + + + + + D.1 6805 REGISTER SET + + The following is a list of the 6805 registers used by AS6805: + + a - 8-bit accumulator + x - index register + + + D.2 6805 INSTRUCTION SET + + + The following tables list all 6805 mnemonics recognized by + the AS6805 assembler. The designation [] refers to a required + addressing mode argument. The following list specifies the + format for each addressing mode supported by AS6805: + + #data immediate data + byte or word data + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + ,x register indirect addressing + zero offset + + offset,x register indirect addressing + 0 <= offset <= 255 --- byte mode + 256 <= offset <= 65535 --- word mode + (an externally defined offset uses the + word mode) + + ext extended addressing + + label branch label + + + + AS6805 ASSEMBLER PAGE D-2 + 6805 INSTRUCTION SET + + + The terms data, dir, offset, and ext may all be expressions. + + Note that not all addressing modes are valid with every in- + struction, refer to the 6805 technical data for valid modes. + + + D.2.1 Control Instructions + + clc cli + nop rsp + rti rts + sec sei + stop swi + tax txa + wait + + + D.2.2 Bit Manipulation Instructions + + brset #data,*dir,label + brclr #data,*dir,label + + bset #data,*dir + bclr #data,*dir + + + D.2.3 Branch Instructions + + bra label brn label + bhi label bls label + bcc label bcs label + bne label beq label + bhcc label bhcs label + bpl label bmi label + bmc label bms label + bil label bih label + bsr label + + + AS6805 ASSEMBLER PAGE D-3 + 6805 INSTRUCTION SET + + + D.2.4 Read-Modify-Write Instructions + + nega negx + neg [] + + coma comx + com [] + + lsra lsrx + lsr [] + + rora rorx + ror [] + + asra asrx + asr [] + + lsla lslx + lsl [] + + rola rolx + rol [] + + deca decx + dec [] + + inca incx + inc [] + + tsta tstx + tst [] + + clra clrx + clr [] + + + D.2.5 Register\Memory Instructions + + sub [] cmp [] + sbc [] cpx [] + and [] bit [] + lda [] sta [] + eor [] adc [] + ora [] add [] + ldx [] stx [] + + + AS6805 ASSEMBLER PAGE D-4 + 6805 INSTRUCTION SET + + + D.2.6 Jump and Jump to Subroutine Instructions + + jmp [] jsr [] + + + + + + + + + + + + + + + APPENDIX E + + AS68HC08 ASSEMBLER + + + + + + E.1 68HC08 REGISTER SET + + The following is a list of the 68HC08 registers used by + AS68HC08: + + a - 8-bit accumulator + x - index register + s - stack pointer + + + E.2 68HC08 INSTRUCTION SET + + + The following tables list all 68HC08 mnemonics recognized by + the AS68HC08 assembler. The designation [] refers to a required + addressing mode argument. The following list specifies the + format for each addressing mode supported by AS68HC08: + + #data immediate data + byte or word data + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + ,x register indexed addressing + zero offset + + offset,x register indexed addressing + 0 <= offset <= 255 --- byte mode + 256 <= offset <= 65535 --- word mode + (an externally defined offset uses the + word mode) + + ,x+ register indexed addressing + zero offset with post increment + + + AS68HC08 ASSEMBLER PAGE E-2 + 68HC08 INSTRUCTION SET + + + + offset,x+ register indexed addressing + unsigned byte offset with post increment + + offset,s stack pointer indexed addressing + 0 <= offset <= 255 --- byte mode + 256 <= offset <= 65535 --- word mode + (an externally defined offset uses the + word mode) + + ext extended addressing + + label branch label + + The terms data, dir, offset, and ext may all be expressions. + + Note that not all addressing modes are valid with every in- + struction, refer to the 68HC08 technical data for valid modes. + + + E.2.1 Control Instructions + + clc cli daa div + mul nop nsa psha + pshh pshx pula pulh + pulx rsp rti rts + sec sei stop swi + tap tax tpa tsx + txa txs wait + + + E.2.2 Bit Manipulation Instructions + + brset #data,*dir,label + brclr #data,*dir,label + + bset #data,*dir + bclr #data,*dir + + + AS68HC08 ASSEMBLER PAGE E-3 + 68HC08 INSTRUCTION SET + + + E.2.3 Branch Instructions + + bra label brn label + bhi label bls label + bcc label bcs label + bne label beq label + bhcc label bhcs label + bpl label bmi label + bmc label bms label + bil label bih label + bsr label bge label + blt label bgt label + ble label + + + E.2.4 Complex Branch Instructions + + cbeqa [],label + cbeqx [],label + cbeq [],label + dbnza label + dbnzx label + dbnz [],label + + + AS68HC08 ASSEMBLER PAGE E-4 + 68HC08 INSTRUCTION SET + + + E.2.5 Read-Modify-Write Instructions + + nega negx + neg [] + + coma comx + com [] + + lsra lsrx + lsr [] + + rora rorx + ror [] + + asra asrx + asr [] + + asla aslx + asl [] + + lsla lslx + lsl [] + + rola rolx + rol [] + + deca decx + dec [] + + inca incx + inc [] + + tsta tstx + tst [] + + clra clrx + clr [] clrh + + aix #data + + ais #data + + + AS68HC08 ASSEMBLER PAGE E-5 + 68HC08 INSTRUCTION SET + + + E.2.6 Register\Memory Instructions + + sub [] cmp [] + sbc [] cpx [] + and [] bit [] + lda [] sta [] + eor [] adc [] + ora [] add [] + ldx [] stx [] + + + E.2.7 Double Operand Move Instruction + + mov [],[] + + + E.2.8 16-Bit Index Register Instructions + + cphx [] + ldhx [] + sthx [] + + + E.2.9 Jump and Jump to Subroutine Instructions + + jmp [] jsr [] + + + + + + + + + + + + + + + APPENDIX F + + AS6809 ASSEMBLER + + + + + + F.1 6809 REGISTER SET + + The following is a list of the 6809 registers used by AS6809: + + a,b - 8-bit accumulators + d - 16-bit accumulator + x,y - index registers + s,u - stack pointers + pc - program counter + cc - condition code + dp - direct page + + + F.2 6809 INSTRUCTION SET + + + The following tables list all 6809 mnemonics recognized by + the AS6809 assembler. The designation [] refers to a required + addressing mode argument. The following list specifies the + format for each addressing mode supported by AS6809: + + #data immediate data + byte or word data + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + label branch label + + r,r1,r2 registers + cc,a,b,d,dp,x,y,s,u,pc + + ,-x ,--x register indexed + autodecrement + + + + AS6809 ASSEMBLER PAGE F-2 + 6809 INSTRUCTION SET + + + ,x+ ,x++ register indexed + autoincrement + + ,x register indexed addressing + zero offset + + offset,x register indexed addressing + -16 <= offset <= 15 --- 5-bit + -128 <= offset <= -17 --- 8-bit + 16 <= offset <= 127 --- 8-bit + -32768 <= offset <= -129 --- 16-bit + 128 <= offset <= 32767 --- 16-bit + (external definition of offset + uses 16-bit mode) + + a,x accumulator offset indexed addressing + + ext extended addressing + + ext,pc pc addressing ( pc <- pc + ext ) + + ext,pcr pc relative addressing + + [,--x] register indexed indirect + autodecrement + + [,x++] register indexed indirect + autoincrement + + [,x] register indexed indirect addressing + zero offset + + [offset,x] register indexed indirect addressing + -128 <= offset <= 127 --- 8-bit + -32768 <= offset <= -129 --- 16-bit + 128 <= offset <= 32767 --- 16-bit + (external definition of offset + uses 16-bit mode) + + [a,x] accumulator offset indexed + indirect addressing + + [ext] extended indirect addressing + + [ext,pc] pc indirect addressing + ( [pc <- pc + ext] ) + + [ext,pcr] pc relative indirect addressing + + The terms data, dir, label, offset, and ext may all be expres- + sions. + + + + AS6809 ASSEMBLER PAGE F-3 + 6809 INSTRUCTION SET + + + Note that not all addressing modes are valid with every in- + struction, refer to the 6809 technical data for valid modes. + + + F.2.1 Inherent Instructions + + abx daa + mul nop + rti rts + sex swi + swi1 swi2 + swi3 sync + + + F.2.2 Short Branch Instructions + + bcc label bcs label + beq label bge label + bgt label bhi label + bhis label bhs label + ble label blo label + blos label bls label + blt label bmi label + bne label bpl label + bra label brn label + bvc label bvs label + bsr label + + + F.2.3 Long Branch Instructions + + lbcc label lbcs label + lbeq label lbge label + lbgt label lbhi label + lbhis label lbhs label + lble label lblo label + lblos label lbls label + lblt label lbmi label + lbne label lbpl label + lbra label lbrn label + lbvc label lbvs label + lbsr label + + + AS6809 ASSEMBLER PAGE F-4 + 6809 INSTRUCTION SET + + + F.2.4 Single Operand Instructions + + asla aslb + asl [] + + asra asrb + asr [] + + clra clrb + clr [] + + coma comb + com [] + + deca decb + dec [] + + inca incb + inc [] + + lsla lslb + lsl [] + + lsra lsrb + lsr [] + + nega negb + neg [] + + rola rolb + rol [] + + rora rorb + ror [] + + tsta tstb + tst [] + + + AS6809 ASSEMBLER PAGE F-5 + 6809 INSTRUCTION SET + + + F.2.5 Double Operand Instructions + + adca [] adcb [] + + adda [] addb [] + + anda [] andb [] + + bita [] bitb [] + + cmpa [] cmpb [] + + eora [] eorb [] + + lda [] ldb [] + + ora [] orb [] + + sbca [] sbcb [] + + sta [] stb [] + + suba [] subb [] + + + F.2.6 D-register Instructions + + addd [] subd [] + cmpd [] ldd [] + std [] + + + F.2.7 Index/Stack Register Instructions + + cmps [] cmpu [] + cmpx [] cmpy [] + + lds [] ldu [] + ldx [] ldy [] + + leas [] leau [] + leax [] leay [] + + sts [] stu [] + stx [] sty [] + + pshs r pshu r + puls r pulu r + + + AS6809 ASSEMBLER PAGE F-6 + 6809 INSTRUCTION SET + + + F.2.8 Jump and Jump to Subroutine Instructions + + jmp [] jsr [] + + + F.2.9 Register - Register Instructions + + exg r1,r2 tfr r1,r2 + + + F.2.10 Condition Code Register Instructions + + andcc #data orcc #data + cwai #data + + + F.2.11 6800 Compatibility Instructions + + aba cba + clc cli + clv des + dex ins + inx + ldaa [] ldab [] + oraa [] orab [] + psha pshb + pula pulb + sba sec + sei sev + staa [] stab [] + tab tap + tba tpa + tsx txs + wai + + + + + + + + + + + + + + + APPENDIX G + + AS6811 ASSEMBLER + + + + + + G.1 6811 REGISTER SET + + The following is a list of the 6811 registers used by AS6811: + + a,b - 8-bit accumulators + d - 16-bit accumulator + x,y - index registers + + + G.2 6811 INSTRUCTION SET + + + The following tables list all 6811 mnemonics recognized by + the AS6811 assembler. The designation [] refers to a required + addressing mode argument. The following list specifies the + format for each addressing mode supported by AS6811: + + #data immediate data + byte or word data + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + ,x register indirect addressing + zero offset + + offset,x register indirect addressing + 0 <= offset <= 255 + + ext extended addressing + + label branch label + + The terms data, dir, offset, and ext may all be expressions. + + + + AS6811 ASSEMBLER PAGE G-2 + 6811 INSTRUCTION SET + + + Note that not all addressing modes are valid with every in- + struction, refer to the 6811 technical data for valid modes. + + + G.2.1 Inherent Instructions + + aba abx + aby cba + clc cli + clv daa + des dex + dey fdiv + idiv ins + inx iny + mul nop + rti rts + sba sec + sei sev + stop swi + tab tap + tba tpa + tsx txs + wai xgdx + xgdy + + psha pshb + psh a psh b + pshx pshy + psh x psh y + + pula pulb + pul a pul b + pulx puly + pul x pul y + + + G.2.2 Branch Instructions + + bra label brn label + bhi label bls label + bcc label bhs label + bcs label blo label + bne label beq label + bvc label bvs label + bpl label bmi label + bge label blt label + bgt label ble label + bsr label + + + AS6811 ASSEMBLER PAGE G-3 + 6811 INSTRUCTION SET + + + G.2.3 Single Operand Instructions + + asla aslb asld + asl a asl b asl d + asl [] + + asra asrb + asr a asr b + asr [] + + clra clrb + clr a clr b + clr label + + coma comb + com a com b + com [] + + deca decb + dec a dec b + dec [] + + inca incb + inc a inc b + inc [] + + lsla lslb lsld + lsl a lsl b lsl d + lsl [] + + lsra lsrb lsrd + lsr a lsr b lsr d + lsr [] + + nega negb + neg a neg b + neg [] + + rola rolb + rol a rol b + rol [] + + rora rorb + ror a ror b + ror [] + + tsta tstb + tst a tst b + tst [] + + + AS6811 ASSEMBLER PAGE G-4 + 6811 INSTRUCTION SET + + + G.2.4 Double Operand Instructions + + adca [] adcb [] + adc a [] adc b [] + + adda [] addb [] addd [] + add a [] add b [] add d [] + + anda [] andb [] + and a [] and b [] + + bita [] bitb [] + bit a [] bit b [] + + cmpa [] cmpb [] + cmp a [] cmp b [] + + eora [] eorb [] + eor a [] eor b [] + + ldaa [] ldab [] + lda a [] lda b [] + + oraa [] orab [] + ora a [] ora b [] + + sbca [] sbcb [] + sbc a [] sbc b [] + + staa [] stab [] + sta a [] sta b [] + + suba [] subb [] subd [] + sub a [] sub b [] sub d [] + + + G.2.5 Bit Manupulation Instructions + + bclr [],#data + bset [],#data + + brclr [],#data,label + brset [],#data,label + + + + + AS6811 ASSEMBLER PAGE G-5 + 6811 INSTRUCTION SET + + + G.2.6 Jump and Jump to Subroutine Instructions + + jmp [] jsr [] + + + G.2.7 Long Register Instructions + + cpx [] cpy [] + + ldd [] lds [] + ldx [] ldy [] + + std [] sts [] + stx [] sty [] + + + + + + + + + + + + + + + APPENDIX H + + AS6816 ASSEMBLER + + + + + + H.1 6816 REGISTER SET + + The following is a list of the 6816 registers used by AS6816: + + a,b - 8-bit accumulators + d - 16-bit accumulator + e - 16-bit accumulator + x,y,z - index registers + k - address extension register + s - stack pointer + ccr - condition code + + + H.2 6816 INSTRUCTION SET + + + The following tables list all 6816 mnemonics recognized by + the AS6816 assembler. The designation [] refers to a required + addressing mode argument. The following list specifies the + format for each addressing mode supported by AS6816: + + #data immediate data + byte or word data + + #xo,#yo local immediate data (mac / rmac) + + label branch label + + r register + ccr,a,b,d,e,x,y,z,s + + ,x zero offset register indexed addressing + ,x8 + ,x16 + + offset,x register indexed addressing + + + AS6816 ASSEMBLER PAGE H-2 + 6816 INSTRUCTION SET + + + 0 <= offset <= 255 --- 8-bit + -32768 <= offset <= -1 --- 16-bit + 256 <= offset <= 32767 --- 16-bit + (external definition of offset + uses 16-bit mode) + + offset,x8 unsigned 8-bit offset indexed addressing + offset,x16 signed 16-bit offset indexed addressing + + e,x accumulator offset indexed addressing + + ext extended addressing + + bank 64K bank number (jmp / jsr) + + The terms data, label, offset, bank, and ext may all be expres- + sions. + + Note that not all addressing modes are valid with every in- + struction, refer to the 6816 technical data for valid modes. + + + H.2.1 Inherent Instructions + + aba abx aby abz + ace aced ade adx + ady adz aex aey + aez bgnd cba daa + ediv edivs emul emuls + fdiv fmuls idiv ldhi + lpstop mul nop psha + pshb pshmac pula pulb + pulmac rtr rts sba + sde sted swi sxt + tab tap tba tbek + tbsk tbxk tbyk tbzk + tde tdmsk tdp ted + tedm tekb tem tmer + tmet tmxed tpa tpd + tskb tsx tsy tsz + txkb txs txy txz + tykb tys tyx tyz + tzkb tzs tzx tzy + wai xgab xgde xgdx + xgdy xgdz xgex xgey + xgez + + + AS6816 ASSEMBLER PAGE H-3 + 6816 INSTRUCTION SET + + + H.2.2 Push/Pull Multiple Register Instructions + + pshm r,... pulm r,... + + + H.2.3 Short Branch Instructions + + bcc label bcs label + beq label bge label + bgt label bhi label + bhis label bhs label + ble label blo label + blos label bls label + blt label bmi label + bne label bpl label + bra label brn label + bvc label bvs label + bsr label + + + H.2.4 Long Branch Instructions + + lbcc label lbcs label + lbeq label lbge label + lbgt label lbhi label + lbhis label lbhs label + lble label lblo label + lblos label lbls label + lblt label lbmi label + lbne label lbpl label + lbra label lbrn label + lbvc label lbvs label + lbsr label + + + H.2.5 Bit Manipulation Instructions + + bclr [],#data + bset [],#data + + brclr [],#data,label + brset [],#data,label + + + AS6816 ASSEMBLER PAGE H-4 + 6816 INSTRUCTION SET + + + H.2.6 Single Operand Instructions + + asla aslb + asld asle + aslm + asl [] aslw [] + + asra asrb + asrd asre + asrm + asr [] asrw [] + + clra clrb + clrd clre + clrm + clr [] clrw [] + + coma comb + comd come + com [] comw [] + + deca decb + dec [] decw [] + + inca incb + inc [] incw [] + + lsla lslb + lsld lsle + lslm + lsl [] lslw [] + + lsra lsrb + lsrd lsre + lsr [] lsrw [] + + nega negb + negd nege + neg [] negw [] + + rola rolb + rold role + rol [] rolw [] + + rora rorb + rord rore + ror [] rorw [] + + tsta tstb + tsta tste + tst [] tstw [] + + + AS6816 ASSEMBLER PAGE H-5 + 6816 INSTRUCTION SET + + + H.2.7 Double Operand Instructions + + adca [] adcb [] + adcd [] adce [] + + adda [] addb [] + addd [] adde [] + + anda [] andb [] + andd [] ande [] + + bita [] bitb [] + + cmpa [] cmpb [] + cpd [] cpe [] + + eora [] eorb [] + eord [] eore [] + + ldaa [] ldab [] + ldd [] lde [] + + oraa [] orab [] + ord [] ore [] + + sbca [] sbcb [] + sbcd [] sbce [] + + staa [] stab [] + std [] ste [] + + suba [] subb [] + subd [] sube [] + + + H.2.8 Index/Stack Register Instructions + + cps [] cpx [] + cpy [] cpz [] + + lds [] ldx [] + ldy [] ldz [] + + sts [] stx [] + sty [] stz [] + + + AS6816 ASSEMBLER PAGE H-6 + 6816 INSTRUCTION SET + + + H.2.9 Jump and Jump to Subroutine Instructions + + jmp bank,[] jsr bank,[] + + + H.2.10 Condition Code Register Instructions + + andp #data orp #data + + + H.2.11 Multiply and Accumulate Instructions + + mac #data rmac #data + mac #xo,#yo rmac #xo,#yo + + + + + + + + + + + + + + + APPENDIX I + + ASH8 ASSEMBLER + + + + + + I.1 H8/3XX REGISTER SET + + The following is a list of the H8 registers used by ASH8: + + r0 - r7,sp 16-bit accumulators + r0L - r7L,spL 8-bit accumulators + r0H - r7H,spH 8-bit accumulators + spL,spH,sp stack pointers + ccr condition code + + + I.2 H8/3XX INSTRUCTION SET + + + The following tables list all H8/3xx mnemonics recognized by + the ASH8 assembler. The designation [] refers to a required ad- + dressing mode argument. The following list specifies the format + for each addressing mode supported by ASH8: + + #xx:3 immediate data (3 bit) + #xx:8 immediate data (8 bit) + #xx:16 immediate data (16 bit) + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + label branch label + + + rn registers (16 bit) + r0-r7,sp + + rnB registers (8 bit) + r0H-r7H,r0L-r7L,spH,spL + + + + ASH8 ASSEMBLER PAGE I-2 + H8/3XX INSTRUCTION SET + + + ccr condition code register + + @rn register indirect + + @-rn register indirect (auto pre-decrement) + + @rn+ register indirect (auto post-increment) + + @[offset,rn] register indirect, 16-bit displacement + + @@offset memory indirect, (8-bit address) + + ext extended addressing (16-bit) + + The terms data, dir, label, offset, and ext may all be expres- + sions. + + Note that not all addressing modes are valid with every in- + struction, refer to the H8/3xx technical data for valid modes. + + + I.2.1 Inherent Instructions + + eepmov + nop + sleep + rte + rts + + + I.2.2 Branch Instructions + + bcc label bcs label + beq label bf label + bge label bgt label + bhi label bhis label + bhs label ble label + blo label blos label + bls label blt label + bmi label bne label + bpl label bra label + brn label bt label + bvc label bvs label + bsr label + + + ASH8 ASSEMBLER PAGE I-3 + H8/3XX INSTRUCTION SET + + + I.2.3 Single Operand Instructions + + Free Form + + daa rnB das rnB + + dec rnB inc rnB + + neg rnB not rnB + + rotxl rnB rotxr rnB + + rotl rnB rotr rnB + + shal rnB shar rnB + + shll rnB shlr rnB + + push rn pop rn + + + Byte / Word Form + + daa.b rnB das.b rnB + + dec.b rnB inc.b rnB + + neg.b rnB not.b rnB + + rotxl.b rnB rotxr.b rnB + + rotl.b rnB rotr.b rnB + + shal.b rnB shar.b rnB + + shll.b rnB shlr.b rnB + + push.w rn pop.w rn + + + ASH8 ASSEMBLER PAGE I-4 + H8/3XX INSTRUCTION SET + + + I.2.4 Double Operand Instructions + + Free Form + + add rnB,rnB add #xx:8,rnB + add rn,rn + + cmp rnB,rnB cmp #xx:8,rnB + cmp rn,rn + + sub rnB,rnB + sub rn,rn + + addx rnB,rnB addx #xx:8,rnB + + and rnB,rnB and #xx:8,rnB + and #xx:8,ccr + + or rnB,rnB or #xx:8,rnB + or #xx:8,ccr + + subx rnB,rnB subx #xx:8,rnB + + xor rnB,rnB xor #xx:8,rnB + xor #xx:8,ccr + + + Byte / Word Form + + add.b rnB,rnB add.b #xx:8,rnB + add.w rn,rn + + cmp.b rnB,rnB cmp.b #xx:8,rnB + cmp.w rn,rn + + sub.b rnB,rnB + sub.w rn,rn + + addx.b rnB,rnB addx.b #xx:8,rnB + + and.b rnB,rnB and.b #xx:8,rnB + and.b #xx:8,ccr + + or.b rnB,rnB or.b #xx:8,rnB + or.b #xx:8,ccr + + subx.b rnB,rnB subx.b #xx:8,rnB + + xor.b rnB,rnB xor.b #xx:8,rnB + xor.b #xx:8,ccr + + + ASH8 ASSEMBLER PAGE I-5 + H8/3XX INSTRUCTION SET + + + I.2.5 Mov Instructions + + Free Form + + mov rnB,rnB mov rn,rn + mov #xx:8,rnB mov #xx:16,rn + mov @rn,rnB mov @rn,rn + mov @[offset,rn],rnB mov @[offset,rn],rn + mov @rn+,rnB mov @rn+,rn + mov @dir,rnB + mov dir,rnB + mov *@dir,rnB + mov *dir,rnB + mov @label,rnB mov @label,rn + mov label,rnB mov label,rn + mov rnB,@rn mov rn,@rn + mov rnB,@[offset,rn] mov rn,@[offset,rn] + mov rnB,@-rn mov rn,@-rn + mov rnB,@dir + mov rnB,dir + mov rnB,*@dir + mov rnB,*dir + mov rnB,@label mov rn,@label + mov rnB,label mov rn,label + + + Byte / Word Form + + mov.b rnB,rnB mov.w rn,rn + mov.b #xx:8,rnB mov.w #xx:16,rn + mov.b @rn,rnB mov.w @rn,rn + mov.b @[offset,rn],rnB mov.w @[offset,rn],rn + mov.b @rn+,rnB mov.w @rn+,rn + mov.b @dir,rnB + mov.b dir,rnB + mov.b *@dir,rnB + mov.b *dir,rnB + mov.b @label,rnB mov.w @label,rn + mov.b label,rnB mov.w label,rn + mov.b rnB,@rn mov.w rn,@rn + mov.b rnB,@[offset,rn] mov.w rn,@[offset,rn] + mov.b rnB,@-rn mov.w rn,@-rn + mov.b rnB,@dir + mov.b rnB,dir + mov.b rnB,*@dir + mov.b rnB,*dir + mov.b rnB,@label mov.w rn,@label + mov.b rnB,label mov.w rn,label + + + ASH8 ASSEMBLER PAGE I-6 + H8/3XX INSTRUCTION SET + + + I.2.6 Bit Manipulation Instructions + + bld #xx:3,rnB bld #xx:3,@rn + bld #xx:3,@dir bld #xx:3,dir + bld #xx:3,*@dir bld #xx:3,*dir + + bild #xx:3,rnB bild #xx:3,@rn + bild #xx:3,@dir bild #xx:3,dir + bild #xx:3,*@dir bild #xx:3,*dir + + bst #xx:3,rnB bst #xx:3,@rn + bst #xx:3,@dir bst #xx:3,dir + bst #xx:3,*@dir bst #xx:3,*dir + + bist #xx:3,rnB bist #xx:3,@rn + bist #xx:3,@dir bist #xx:3,dir + bist #xx:3,*@dir bist #xx:3,*dir + + band #xx:3,rnB band #xx:3,@rn + band #xx:3,@dir band #xx:3,dir + band #xx:3,*@dir band #xx:3,*dir + + biand #xx:3,rnB biand #xx:3,@rn + biand #xx:3,@dir biand #xx:3,dir + biand #xx:3,*@dir biand #xx:3,*dir + + bor #xx:3,rnB bor #xx:3,@rn + bor #xx:3,@dir bor #xx:3,dir + bor #xx:3,*@dir bor #xx:3,*dir + + bior #xx:3,rnB bior #xx:3,@rn + bior #xx:3,@dir bior #xx:3,dir + bior #xx:3,*@dir bior #xx:3,*dir + + bxor #xx:3,rnB bxor #xx:3,@rn + bxor #xx:3,@dir bxor #xx:3,dir + bxor #xx:3,*@dir bxor #xx:3,*dir + + bixor #xx:3,rnB bixor #xx:3,@rn + bixor #xx:3,@dir bixor #xx:3,dir + bixor #xx:3,*@dir bixor #xx:3,*dir + + + ASH8 ASSEMBLER PAGE I-7 + H8/3XX INSTRUCTION SET + + + I.2.7 Extended Bit Manipulation Instructions + + bset #xx:3,rnB bset #xx:3,@rn + bset #xx:3,@dir bset #xx:3,dir + bset #xx:3,*@dir bset #xx:3,*dir + bset rnB,rnB bset rnB,@rn + bset rnB,@dir bset rnB,dir + bset rnB,*@dir bset rnB,*dir + + bclr #xx:3,rnB bclr #xx:3,@rn + bclr #xx:3,@dir bclr #xx:3,dir + bclr #xx:3,*@dir bclr #xx:3,*dir + bclr rnB,rnB bclr rnB,@rn + bclr rnB,@dir bclr rnB,dir + bclr rnB,*@dir bclr rnB,*dir + + bnot #xx:3,rnB bnot #xx:3,@rn + bnot #xx:3,@dir bnot #xx:3,dir + bnot #xx:3,*@dir bnot #xx:3,*dir + bnot rnB,rnB bnot rnB,@rn + bnot rnB,@dir bnot rnB,dir + bnot rnB,*@dir bnot rnB,*dir + + btst #xx:3,rnB btst #xx:3,@rn + btst #xx:3,@dir btst #xx:3,dir + btst #xx:3,*@dir btst #xx:3,*dir + btst rnB,rnB btst rnB,@rn + btst rnB,@dir btst rnB,dir + btst rnB,*@dir btst rnB,*dir + + + I.2.8 Condition Code Instructions + + andc #xx:8,ccr andc #xx:8 + and #xx:8,ccr and.b #xx:8,ccr + + ldc #xx:8,ccr ldc #xx:8 + ldc rnB,ccr ldc rnB + + orc #xx:8,ccr orc #xx:8 + or #xx:8,ccr or.b #xx:8,ccr + + xorc #xx:8,ccr xorc #xx:8 + xor #xx:8,ccr xor.b #xx:8,ccr + + stc ccr,rnB stc rnB + + + ASH8 ASSEMBLER PAGE I-8 + H8/3XX INSTRUCTION SET + + + I.2.9 Other Instructions + + divxu rnB,rn divxu.b rnB,rn + + mulxu rnB,rn mulxu.b rnB,rn + + movfpe @label,rnB movfpe label,rnB + movfpe.b @label,rnB movfpe.b label,rnB + + movtpe @label,rnB movtpe label,rnB + movtpe.b @label,rnB movtpe.b label,rnB + + + I.2.10 Jump and Jump to Subroutine Instructions + + jmp @rn jmp @@dir + jmp @label jmp label + + jsr @rn jsr @@dir + jsr @label jsr label + + + + + + + + + + + + + + + APPENDIX J + + AS8085 ASSEMBLER + + + + + + J.1 8085 REGISTER SET + + The following is a list of the 8080/8085 registers used by + AS8085: + + a,b,c,d,e,h,l - 8-bit accumulators + m - memory through (hl) + sp - stack pointer + psw - status word + + + J.2 8085 INSTRUCTION SET + + + The following tables list all 8080/8085 mnemonics recognized + by the AS8085 assembler. The following list specifies the + format for each addressing mode supported by AS8085: + + #data immediate data + byte or word data + + r,r1,r2 register or register pair + psw,a,b,c,d,e,h,l + bc,de,hl,sp,pc + + m memory address using (hl) + + addr direct memory addressing + + label call or jump label + + The terms data, m, addr, and label may be expressions. + + Note that not all addressing modes are valid with every in- + struction, refer to the 8080/8085 technical data for valid + modes. + + + AS8085 ASSEMBLER PAGE J-2 + 8085 INSTRUCTION SET + + + J.2.1 Inherent Instructions + + cma cmc + daa di + ei hlt + nop pchl + ral rar + ret rim + rrc rlc + sim sphl + stc xchg + xthl + + + J.2.2 Register/Memory/Immediate Instructions + + adc r adc m aci #data + add r add m adi #data + ana r ana m ani #data + cmp r cmp m cpi #data + ora r ora m ori #data + sbb r sbb m sbi #data + sub r sub m sui #data + xra r xra m xri #data + + + J.2.3 Call and Return Instructions + + cc label rc + cm label rm + cnc label rnc + cnz label rnz + cp label rp + cpe label rpe + cpo label rpo + cz label rz + call label + + + J.2.4 Jump Instructions + + jc label + jm label + jnc label + jnz label + jp label + jpe label + jpo label + jz label + jmp label + + + AS8085 ASSEMBLER PAGE J-3 + 8085 INSTRUCTION SET + + + J.2.5 Input/Output/Reset Instructions + + in data + out data + rst data + + + J.2.6 Move Instructions + + mov r1,r2 + mov r,m + mov m,r + + mvi r,#data + mvi m,#data + + + J.2.7 Other Instructions + + dcr r dcr m + inr r inr m + + dad r dcx r + inx r ldax r + pop r push r + stax r + + lda addr lhld addr + shld addr sta addr + + lxi r,#data + + + + + + + + + + + + + + + APPENDIX K + + ASZ80 ASSEMBLER + + + + + + K.1 .hd64 DIRECTIVE + + Format: + + .hd64 + + The .hd64 directive enables processing of the HD64180 specific + mnemonics not included in the Z80 instruction set. HD64180 + mnemonics encountered without the .hd64 directive will be + flagged with an 'o' error. + + + K.2 Z80 REGISTER SET AND CONDITIONS + + + The following is a complete list of register designations and + condition mnemonics: + + byte registers - a,b,c,d,e,h,l,i,r + register pairs - af,af',bc,de,hl + word registers - pc,sp,ix,iy + + C - carry bit set + M - sign bit set + NC - carry bit clear + NZ - zero bit clear + P - sign bit clear + PE - parity even + PO - parity odd + Z - zero bit set + + + + + ASZ80 ASSEMBLER PAGE K-2 + Z80 INSTRUCTION SET + + + K.3 Z80 INSTRUCTION SET + + + The following tables list all Z80/HD64180 mnemonics recog- + nized by the ASZ80 assembler. The designation [] refers to a + required addressing mode argument. The following list specifies + the format for each addressing mode supported by ASZ80: + + #data immediate data + byte or word data + + n byte value + + rg a byte register + a,b,c,d,e,h,l + + rp a register pair + bc,de,hl + + (hl) implied addressing or + register indirect addressing + + (label) direct addressing + + offset(ix) indexed addressing with + an offset + + label call/jmp/jr label + + The terms data, dir, offset, and ext may all be expressions. + The terms dir and offset are not allowed to be external refer- + ences. + + Note that not all addressing modes are valid with every in- + struction, refer to the Z80/HD64180 technical data for valid + modes. + + + ASZ80 ASSEMBLER PAGE K-3 + Z80 INSTRUCTION SET + + + K.3.1 Inherent Instructions + + ccf cpd + cpdr cpi + cpir cpl + daa di + ei exx + halt neg + nop reti + retn rla + rlca rld + rra rrca + rrd scf + + + K.3.2 Implicit Operand Instructions + + adc a,[] adc [] + add a,[] add [] + and a,[] and [] + cp a,[] cp [] + dec a,[] dec [] + inc a,[] inc [] + or a,[] or [] + rl a,[] rl [] + rlc a,[] rlc [] + rr a,[] rr [] + rrc a,[] rrc [] + sbc a,[] sbc [] + sla a,[] sla [] + sra a,[] sra [] + srl a,[] srl [] + sub a,[] sub [] + xor a,[] xor [] + + + ASZ80 ASSEMBLER PAGE K-4 + Z80 INSTRUCTION SET + + + K.3.3 Load Instruction + + ld rg,[] ld [],rg + ld (bc),a ld a,(bc) + ld (de),a ld a,(de) + ld (label),a ld a,(label) + ld (label),rp ld rp,(label) + ld i,a ld r,a + ld a,i ld a,r + ld sp,hl ld sp,ix + ld sp,iy ld rp,#data + + ldd lddr + ldi ldir + + + K.3.4 Call/Return Instructions + + call C,label ret C + call M,label ret M + call NC,label ret NC + call NZ,label ret NZ + call P,label ret P + call PE,label ret PE + call PO,label ret PO + call Z,label ret Z + call label ret + + + K.3.5 Jump and Jump to Subroutine Instructions + + jp C,label jp M,label + jp NC,label jp NZ,label + jp P,label jp PE,label + jp PO,label jp Z,label + + jp (hl) jp (ix) + jp (iy) jp label + + djnz label + + jr C,label jr NC,label + jr NZ,label jr Z,label + jr label + + + ASZ80 ASSEMBLER PAGE K-5 + Z80 INSTRUCTION SET + + + K.3.6 Bit Manipulation Instructions + + bit n,[] + res n,[] + set n,[] + + + K.3.7 Interrupt Mode and Reset Instructions + + im n + im n + im n + rst n + + + K.3.8 Input and Output Instructions + + in a,(n) in rg,(c) + ind indr + ini inir + + out (n),a out (c),rg + outd otdr + outi otir + + + K.3.9 Register Pair Instructions + + add hl,rp add ix,rp + add iy,rp + + adc hl,rp sbc hl,rp + + ex (sp),hl ex (sp),ix + ex (sp),iy + ex de,hl + ex af,af' + + push rp pop rp + + + ASZ80 ASSEMBLER PAGE K-6 + Z80 INSTRUCTION SET + + + K.3.10 HD64180 Specific Instructions + + in0 rg,(n) + out0 (n),rg + + otdm otdmr + otim otimr + + mlt bc mlt de + mlt hl mlt sp + + slp + + tst a + tstio #data + + + + + + + + + + + + + + + APPENDIX L + + AS6500 ASSEMBLER + + + + + + L.1 ACKNOWLEDGMENT + + + Thanks to Marko Makela for his contribution of the AS6500 + cross assembler. + + Marko Makela + Sillitie 10 A + 01480 Vantaa + Finland + Internet: Marko.Makela@Helsinki.Fi + EARN/BitNet: msmakela@finuh + + Several additions and modifications were made to his code to + support the following families of 6500 processors: + + (1) 650X and 651X processor family + (2) 65F11 and 65F12 processor family + (3) 65C00/21 and 65C29 processor family + (4) 65C02, 65C102, and 65C112 processor family + + The instruction syntax of this cross assembler contains two + peculiarities: (1) the addressing indirection is denoted by the + square brackets [] and (2) the `bbrx' and `bbsx' instructions + are written `bbr0 memory,label'. + + + + + AS6500 ASSEMBLER PAGE L-2 + 6500 REGISTER SET + + + L.2 6500 REGISTER SET + + The following is a list of the 6500 registers used by AS6500: + + a - 8-bit accumulator + x,y - index registers + + + L.3 6500 INSTRUCTION SET + + + The following tables list all 6500 family mnemonics recog- + nized by the AS6500 assembler. The designation [] refers to a + required addressing mode argument. The following list specifies + the format for each addressing mode supported by AS6500: + + #data immediate data + byte or word data + + *dir direct page addressing + (see .setdp directive) + 0 <= dir <= 255 + + offset,x indexed addressing + offset,y indexed addressing + address = (offset + (x or y)) + + [offset,x] pre-indexed indirect addressing + 0 <= offset <= 255 + address = contents of location + (offset + (x or y)) mod 256 + + [offset],y post-indexed indirect addressing + address = contents of location at offset + plus the value of the y register + + [address] indirect addressing + + ext extended addressing + + label branch label + + address,label direct page memory location + branch label + bbrx and bbsx instruction addressing + + The terms data, dir, offset, address, ext, and label may all be + expressions. + + Note that not all addressing modes are valid with every in- + struction, refer to the 65xx technical data for valid modes. + + + AS6500 ASSEMBLER PAGE L-3 + 6500 INSTRUCTION SET + + + L.3.1 Processor Specific Directives + + + The AS6500 cross assembler has four (4) processor specific + assembler directives which define the target 65xx processor + family: + + .r6500 Core 650X and 651X family (default) + .r65f11 Core plus 65F11 and 65F12 + .r65c00 Core plus 65C00/21 and 65C29 + .r65c02 Core plus 65C02, 65C102, and 65C112 + + + L.3.2 65xx Core Inherent Instructions + + brk clc + cld cli + clv dex + dey inx + iny nop + pha php + pla plp + rti rts + sec sed + sei tax + tay tsx + txa txs + tya + + + L.3.3 65xx Core Branch Instructions + + bcc label bhs label + bcs label blo label + beq label bmi label + bne label bpl label + bvc label bvs label + + + L.3.4 65xx Core Single Operand Instructions + + asl [] + dec [] + inc [] + lsr [] + rol [] + ror [] + + + AS6500 ASSEMBLER PAGE L-4 + 6500 INSTRUCTION SET + + + L.3.5 65xx Core Double Operand Instructions + + adc [] + and [] + bit [] + cmp [] + eor [] + lda [] + ora [] + sbc [] + sta [] + + + L.3.6 65xx Core Jump and Jump to Subroutine Instructions + + jmp [] jsr [] + + + L.3.7 65xx Core Miscellaneous X and Y Register Instructions + + cpx [] + cpy [] + ldx [] + stx [] + ldy [] + sty [] + + + AS6500 ASSEMBLER PAGE L-5 + 6500 INSTRUCTION SET + + + L.3.8 65F11 and 65F12 Specific Instructions + + bbr0 [],label bbr1 [],label + bbr2 [],label bbr3 [],label + bbr4 [],label bbr5 [],label + bbr6 [],label bbr7 [],label + + bbs0 [],label bbs1 [],label + bbs2 [],label bbs3 [],label + bbs4 [],label bbs5 [],label + bbs6 [],label bbs7 [],label + + rmb0 [] rmb1 [] + rmb2 [] rmb3 [] + rmb4 [] rmb5 [] + rmb6 [] rmb7 [] + + smb0 [] smb1 [] + smb2 [] smb3 [] + smb4 [] smb5 [] + smb6 [] smb7 [] + + + L.3.9 65C00/21 and 65C29 Specific Instructions + + bbr0 [],label bbr1 [],label + bbr2 [],label bbr3 [],label + bbr4 [],label bbr5 [],label + bbr6 [],label bbr7 [],label + + bbs0 [],label bbs1 [],label + bbs2 [],label bbs3 [],label + bbs4 [],label bbs5 [],label + bbs6 [],label bbs7 [],label + + bra label + + phx phy + plx ply + + rmb0 [] rmb1 [] + rmb2 [] rmb3 [] + rmb4 [] rmb5 [] + rmb6 [] rmb7 [] + + smb0 [] smb1 [] + smb2 [] smb3 [] + smb4 [] smb5 [] + smb6 [] smb7 [] + + + AS6500 ASSEMBLER PAGE L-6 + 6500 INSTRUCTION SET + + + L.3.10 65C02, 65C102, and 65C112 Specific Instructions + + bbr0 [],label bbr1 [],label + bbr2 [],label bbr3 [],label + bbr4 [],label bbr5 [],label + bbr6 [],label bbr7 [],label + + bbs0 [],label bbs1 [],label + bbs2 [],label bbs3 [],label + bbs4 [],label bbs5 [],label + bbs6 [],label bbs7 [],label + + bra label + + phx phy + plx ply + + rmb0 [] rmb1 [] + rmb2 [] rmb3 [] + rmb4 [] rmb5 [] + rmb6 [] rmb7 [] + + smb0 [] smb1 [] + smb2 [] smb3 [] + smb4 [] smb5 [] + smb6 [] smb7 [] + + stz [] + trb [] + tsb [] + + Additional addressing modes for the following core instruc- + tions are also available with the 65C02, 65C102, and 65C112 pro- + cessors. + + adc [] and [] + cmp [] eor [] + lda [] ora [] + sbc [] sta [] + + bit [] jmp [] + + dec inc + \ No newline at end of file diff --git a/as/doc/asxhtm.html b/as/doc/asxhtm.html new file mode 100644 index 00000000..0d908008 --- /dev/null +++ b/as/doc/asxhtm.html @@ -0,0 +1,6477 @@ + + +ASxxxx Cross Assembler Documentation + + + + + + +

ASxxxx Cross Assembler Documentation

+ + + +
+
+                                ASxxxx Assemblers
+
+
+                                       and
+
+
+                            ASLINK Relocating Linker
+
+
+
+
+                                  Version   2.0
+                                   August 1998
+
+
+                                                                  Page 2
+        
+
+
+         
+                                  P R E F A C E
+
+
+
+
+
+           The  ASxxxx  assemblers  were  written following the style of
+        several cross assemblers found in the Digital Equipment Corpora-
+        tion  Users  Society  (DECUS)  distribution of the C programming
+        language.  The DECUS code was provided with no documentation  as
+        to  the  input  syntax  or the output format.  Study of the code
+        revealed that the unknown author of the code  had  attempted  to
+        formulate  an assembler with attributes similiar to those of the
+        PDP-11 MACRO assembler (without macro's).  The  incomplete  code
+        from  the  DECUS C distribution has been largely rewritten, only
+        the program structure, and C source  file  organization  remains
+        relatively  unchanged.   However, I wish to thank the author for
+        his contribution to this set of assemblers.  
+
+           The  ASLINK  program was written as a companion to the ASxxxx
+        assemblers, its design and implementation was not  derived  from
+        any other work.  
+
+           The  ASxxxx  assemblers  and the ASLINK relocating linker are
+        placed in the Public Domain.   Publication  or  distribution  of
+        these programs for non-commercial use is hereby granted with the
+        stipulation that the  copyright  notice  be  included  with  all
+        copies.  
+
+           I  would  greatly  appreciate  receiving  the  details of any
+        changes, additions, or errors pertaining to these  programs  and
+        will  attempt  to  incorporate  any  fixes  or  generally useful
+        changes in a future update to these programs.  
+
+
+
+                Alan R.  Baldwin 
+                Kent State University 
+                Physics Department 
+                Kent, Ohio 44242 
+                U.S.A.  
+
+
+                http://shop-pdp.kent.edu/ashtml/asxxxx.htm 
+
+                baldwin@shop-pdp.kent.edu 
+                tel:  (330) 672 2531 
+                fax:  (330) 672 2959 
+
+
+                                                                  Page 3
+        
+
+
+         
+
+
+
+
+                             C O N T R I B U T O R S
+
+
+
+
+           Thanks  to  Marko  Makela  for his contribution of the AS6500
+        cross assembler.  
+
+                Marko Makela
+                Sillitie 10 A
+                01480 Vantaa
+                Finland
+                Internet: Marko.Makela@Helsinki.Fi
+                EARN/BitNet: msmakela@finuh
+
+
+
+
+
+           Thanks  to  John  Hartman  for his contribution of the AS8051
+        cross assembler and updates to the ASxxxx and ASLINK internals. 
+
+                John L. Hartman
+                jhartman@compuserve.com
+                http://ourworld.compuserve.com/homepages/jhartman/
+
+
+
+
+
+           Thanks  to  G.   Osborn  for his contributions to LKS19.C and
+        LKIHX.C.  
+
+                G. Osborn
+                gary@s-4.com
+
+
+                                                                  Page 4
+        
+
+
+        ASxxxx Cross Assemblers, Version 2.00, August 1998 
+
+        Submitted by Alan R.  Baldwin, 
+        Kent State University, Kent, Ohio 
+
+        Operating System:  TSX+, RT-11, MS/DOS, PDOS 
+        or other supporting K&R C.  
+
+        Source Langauge:  C 
+
+        Abstract:  
+
+           The  ASxxxx  assemblers are a series of microprocessor assem-
+        blers written in the C programming  language.   This  collection
+        contains cross assemblers for the 6800(6802/6808), 6801(hd6303),
+        6804,  6805,  68HC08,  6809,  68HC11,  68HC12,   68HC16,   8051,
+        8085(8080),  z80(hd64180),  H8/3xx, and 6500 series microproces-
+        sors.  Each  assembler  has  a  device  specific  section  which
+        includes:   (1)  device description, byte order, and file exten-
+        sion information, (2) a table of assembler  general  directives,
+        special directives, assembler mnemonics and associated operation
+        codes, (3) machine  specific  code  for  processing  the  device
+        mnemonics, addressing modes, and special directives.  
+
+           The assemblers have a common device independent section which
+        handles the details of file input/output, symbol  table  genera-
+        tion,  program/data  areas,  expression  analysis, and assembler
+        directive processing.  
+
+           The  assemblers  provide  the following features:  (1) alpha-
+        betized, formatted symbol table listings, (2) relocatable object
+        modules, (3) global symbols for linking object modules, (4) con-
+        ditional assembly directives, (5) reusable  local  symbols,  and
+        (6) include-file processing.  
+
+           The  companion program ASLINK is a relocating linker perform-
+        ing the following functions:  (1) bind multiple  object  modules
+        into  a  single  memory  image,  (2) resolve inter-module symbol
+        references,  (3)  resolve  undefined  symbols   from   specified
+        librarys of object modules, (4) process absolute, relative, con-
+        catenated, and overlay attributes in data and program  sections,
+        (5)  perform  byte and word program-counter relative (pc or pcr)
+        addressing calculations, (6) define absolute  symbol  values  at
+        link  time, (7) define absolute area base address values at link
+        time, (8) produce Intel Hex or Motorola  S19  output  file,  (9)
+        produce  a  map  of the linked memory image, and (10) update the
+        ASxxxx assembler listing files  with  the  absolute  linked  ad-
+        dresses and data.  
+
+           The  assemblers  and  linker  have  been tested using DECUS C
+        under TSX+ and RT-11, PDOS C V5.4b, and Symantec C/C++ V6.1/V7.2
+        under  DOS/Windows  3.x/95.  Complete source code and documenta-
+        tion for the assemblers and linker is included with the  distri-
+        bution.   Additionally, test code for each assembler and several
+        microprocessor monitors ( ASSIST05  for  the  6805,  MONDEB  and
+        ASSIST09  for  the  6809,  and BUFFALO 2.5 for the 6811) are in-
+        cluded as working examples of use of these assemblers.  
+
+
+        CHAPTER 1  THE ASSEMBLER                                     1-1 
+          1.1     THE ASXXXX ASSEMBLERS                              1-1 
+          1.1.1     Assembly Pass 1                                  1-2 
+          1.1.2     Assembly Pass 2                                  1-2 
+          1.1.3     Assembly Pass 3                                  1-2 
+          1.2     SOURCE PROGRAM FORMAT                              1-3 
+          1.2.1     Statement Format                                 1-3 
+          1.2.1.1     Label Field                                    1-3 
+          1.2.1.2     Operator Field                                 1-5 
+          1.2.1.3     Operand Field                                  1-5 
+          1.2.1.4     Comment Field                                  1-6 
+          1.3     SYMBOLS AND EXPRESSIONS                            1-6 
+          1.3.1     Character Set                                    1-6 
+          1.3.2     User-Defined Symbols                            1-10 
+          1.3.3     Local Symbols                                   1-11 
+          1.3.4     Current Location Counter                        1-12 
+          1.3.5     Numbers                                         1-14 
+          1.3.6     Terms                                           1-14 
+          1.3.7     Expressions                                     1-15 
+          1.4     GENERAL ASSEMBLER DIRECTIVES                      1-16 
+          1.4.1     .module Directive                               1-16 
+          1.4.2     .title Directive                                1-17 
+          1.4.3     .sbttl Directive                                1-17 
+          1.4.4     .page Directive                                 1-17 
+          1.4.5     .byte and .db Directives                        1-17 
+          1.4.6     .word and .dw Directives                        1-18 
+          1.4.7     .blkb, .blkw, and .ds Directives                1-18 
+          1.4.8     .ascii Directive                                1-18 
+          1.4.9     .ascis Directive                                1-19 
+          1.4.10    .asciz Directive                                1-19 
+          1.4.11    .radix Directive                                1-20 
+          1.4.12    .even Directive                                 1-20 
+          1.4.13    .odd Directive                                  1-20 
+          1.4.14    .area Directive                                 1-21 
+          1.4.15    .org Directive                                  1-22 
+          1.4.16    .globl Directive                                1-23 
+          1.4.17    .if, .else, and .endif Directives               1-23 
+          1.4.18    .include Directive                              1-24 
+          1.4.19    .setdp Directive                                1-25 
+          1.5     INVOKING ASXXXX                                   1-27 
+          1.6     ERRORS                                            1-28 
+          1.7     LISTING FILE                                      1-29 
+          1.8     SYMBOL TABLE FILE                                 1-30 
+          1.9     OBJECT FILE                                       1-31 
+
+        CHAPTER 2  THE LINKER                                        2-1 
+          2.1     ASLINK RELOCATING LINKER                           2-1 
+          2.2     INVOKING ASLINK                                    2-2 
+          2.3     LIBRARY PATH(S) AND FILE(S)                        2-3 
+          2.4     ASLINK PROCESSING                                  2-4 
+          2.5     LINKER INPUT FORMAT                                2-6 
+          2.5.1     Object Module Format                             2-6 
+          2.5.2     Header Line                                      2-6 
+          2.5.3     Module Line                                      2-7 
+          2.5.4     Symbol Line                                      2-7 
+          2.5.5     Area Line                                        2-7 
+
+
+                                                                 Page ii
+        
+
+
+          2.5.6     T Line                                           2-7 
+          2.5.7     R Line                                           2-8 
+          2.5.8     P Line                                           2-8 
+          2.6     LINKER ERROR MESSAGES                              2-9 
+          2.7     INTEL HEX OUTPUT FORMAT                           2-11 
+          2.8     MOTORLA S1-S9 OUTPUT FORMAT                       2-12 
+
+        CHAPTER 3  BUILDING ASXXXX AND ASLINK                        3-1 
+          3.1     BUILDING AN ASSEMBLER                              3-1 
+          3.2     BUILDING ASLINK                                    3-2 
+
+        APPENDIX A  AS6800 ASSEMBLER                                 A-1 
+          A.1     6800 REGISTER SET                                  A-1 
+          A.2     6800 INSTRUCTION SET                               A-1 
+          A.2.1     Inherent Instructions                            A-2 
+          A.2.2     Branch Instructions                              A-2 
+          A.2.3     Single Operand Instructions                      A-3 
+          A.2.4     Double Operand Instructions                      A-4 
+          A.2.5     Jump and Jump to Subroutine Instructions         A-4 
+          A.2.6     Long Register Instructions                       A-5 
+
+        APPENDIX B  AS6801 ASSEMBLER                                 B-1 
+          B.1     .hd6303 DIRECTIVE                                  B-1 
+          B.2     6801 REGISTER SET                                  B-1 
+          B.3     6801 INSTRUCTION SET                               B-1 
+          B.3.1     Inherent Instructions                            B-2 
+          B.3.2     Branch Instructions                              B-2 
+          B.3.3     Single Operand Instructions                      B-3 
+          B.3.4     Double Operand Instructions                      B-4 
+          B.3.5     Jump and Jump to Subroutine Instructions         B-5 
+          B.3.6     Long Register Instructions                       B-5 
+          B.3.7     6303 Specific Instructions                       B-5 
+
+        APPENDIX C  AS6804 ASSEMBLER                                 C-1 
+          C.1     6804 REGISTER SET                                  C-1 
+          C.2     6804 INSTRUCTION SET                               C-1 
+          C.2.1     Inherent Instructions                            C-2 
+          C.2.2     Branch Instructions                              C-2 
+          C.2.3     Single Operand Instructions                      C-2 
+          C.2.4     Jump and Jump to Subroutine Instructions         C-2 
+          C.2.5     Bit Test Instructions                            C-2 
+          C.2.6     Load Immediate data Instruction                  C-3 
+          C.2.7     6804 Derived Instructions                        C-3 
+
+        APPENDIX D  AS6805 ASSEMBLER                                 D-1 
+          D.1     6805 REGISTER SET                                  D-1 
+          D.2     6805 INSTRUCTION SET                               D-1 
+          D.2.1     Control Instructions                             D-2 
+          D.2.2     Bit Manipulation Instructions                    D-2 
+          D.2.3     Branch Instructions                              D-2 
+          D.2.4     Read-Modify-Write Instructions                   D-3 
+          D.2.5     Register\Memory Instructions                     D-3 
+
+
+                                                                Page iii
+        
+
+
+          D.2.6     Jump and Jump to Subroutine Instructions         D-4 
+
+        APPENDIX E  AS6808 ASSEMBLER                                 E-1 
+          E.1     68HC08 REGISTER SET                                E-1 
+          E.2     68HC08 INSTRUCTION SET                             E-1 
+          E.2.1     Control Instructions                             E-2 
+          E.2.2     Bit Manipulation Instructions                    E-2 
+          E.2.3     Branch Instructions                              E-3 
+          E.2.4     Complex Branch Instructions                      E-3 
+          E.2.5     Read-Modify-Write Instructions                   E-4 
+          E.2.6     Register\Memory Instructions                     E-5 
+          E.2.7     Double Operand Move Instruction                  E-5 
+          E.2.8     16-Bit <H:X> Index Register Instructions         E-5 
+          E.2.9     Jump and Jump to Subroutine Instructions         E-5 
+
+        APPENDIX F  AS6809 ASSEMBLER                                 F-1 
+          F.1     6809 REGISTER SET                                  F-1 
+          F.2     6809 INSTRUCTION SET                               F-1 
+          F.2.1     Inherent Instructions                            F-3 
+          F.2.2     Short Branch Instructions                        F-3 
+          F.2.3     Long Branch Instructions                         F-3 
+          F.2.4     Single Operand Instructions                      F-4 
+          F.2.5     Double Operand Instructions                      F-5 
+          F.2.6     D-register Instructions                          F-5 
+          F.2.7     Index/Stack Register Instructions                F-5 
+          F.2.8     Jump and Jump to Subroutine Instructions         F-6 
+          F.2.9     Register - Register Instructions                 F-6 
+          F.2.10    Condition Code Register Instructions             F-6 
+          F.2.11    6800 Compatibility Instructions                  F-6 
+
+        APPENDIX G  AS6811 ASSEMBLER                                 G-1 
+          G.1     68HC11 REGISTER SET                                G-1 
+          G.2     68HC11 INSTRUCTION SET                             G-1 
+          G.2.1     Inherent Instructions                            G-2 
+          G.2.2     Branch Instructions                              G-2 
+          G.2.3     Single Operand Instructions                      G-3 
+          G.2.4     Double Operand Instructions                      G-4 
+          G.2.5     Bit Manupulation Instructions                    G-4 
+          G.2.6     Jump and Jump to Subroutine Instructions         G-5 
+          G.2.7     Long Register Instructions                       G-5 
+
+        APPENDIX H  AS6812 ASSEMBLER                                 H-1 
+          H.1     68HC12 REGISTER SET                                H-1 
+          H.2     68HC12 INSTRUCTION SET                             H-1 
+          H.2.1     Inherent Instructions                            H-3 
+          H.2.2     Short Branch Instructions                        H-3 
+          H.2.3     Long Branch Instructions                         H-3 
+          H.2.4     Branch on Decrement, Test, or Increment          H-4 
+          H.2.5     Bit Clear and Set Instructions                   H-4 
+          H.2.6     Branch on Bit Clear or Set                       H-4 
+          H.2.7     Single Operand Instructions                      H-5 
+          H.2.8     Double Operand Instructions                      H-6 
+
+
+                                                                 Page iv
+        
+
+
+          H.2.9     Move Instructions                                H-6 
+          H.2.10    D-register Instructions                          H-6 
+          H.2.11    Index/Stack Register Instructions                H-7 
+          H.2.12    Jump and Jump/Call to Subroutine
+                    Instructions                                     H-7 
+          H.2.13    Other Special Instructions                       H-7 
+          H.2.14    Register - Register Instructions                 H-7 
+          H.2.15    Condition Code Register Instructions             H-7 
+          H.2.16    M68HC11 Compatibility Mode Instructions          H-8 
+
+        APPENDIX I  AS6816 ASSEMBLER                                 I-1 
+          I.1     68HC16 REGISTER SET                                I-1 
+          I.2     68HC16 INSTRUCTION SET                             I-1 
+          I.2.1     Inherent Instructions                            I-2 
+          I.2.2     Push/Pull Multiple Register Instructions         I-3 
+          I.2.3     Short Branch Instructions                        I-3 
+          I.2.4     Long Branch Instructions                         I-3 
+          I.2.5     Bit Manipulation Instructions                    I-3 
+          I.2.6     Single Operand Instructions                      I-4 
+          I.2.7     Double Operand Instructions                      I-5 
+          I.2.8     Index/Stack Register Instructions                I-5 
+          I.2.9     Jump and Jump to Subroutine Instructions         I-6 
+          I.2.10    Condition Code Register Instructions             I-6 
+          I.2.11    Multiply and Accumulate Instructions             I-6 
+
+        APPENDIX J  ASH8 ASSEMBLER                                   J-1 
+          J.1     H8/3XX REGISTER SET                                J-1 
+          J.2     H8/3XX INSTRUCTION SET                             J-1 
+          J.2.1     Inherent Instructions                            J-2 
+          J.2.2     Branch Instructions                              J-2 
+          J.2.3     Single Operand Instructions                      J-3 
+          J.2.4     Double Operand Instructions                      J-4 
+          J.2.5     Mov Instructions                                 J-5 
+          J.2.6     Bit Manipulation Instructions                    J-6 
+          J.2.7     Extended Bit Manipulation Instructions           J-7 
+          J.2.8     Condition Code Instructions                      J-7 
+          J.2.9     Other Instructions                               J-8 
+          J.2.10    Jump and Jump to Subroutine Instructions         J-8 
+
+        APPENDIX K  AS8051 ASSEMBLER                                 K-1 
+          K.1     ACKNOWLEDGMENT                                     K-1 
+          K.2     8051 REGISTER SET                                  K-1 
+          K.3     8051 INSTRUCTION SET                               K-2 
+          K.3.1     Inherent Instructions                            K-2 
+          K.3.2     Move Instructions                                K-3 
+          K.3.3     Single Operand Instructions                      K-3 
+          K.3.4     Two Operand Instructions                         K-4 
+          K.3.5     Call and Return Instructions                     K-4 
+          K.3.6     Jump Instructions                                K-4 
+          K.3.7     Predefined Symbols:  SFR Map                     K-5 
+          K.3.8     Predefined Symbols:  SFR Bit Addresses           K-6 
+          K.3.9     Predefined Symbols:  Control Bits                K-7 
+
+
+                                                                  Page v
+        
+
+
+        APPENDIX L  AS8085 ASSEMBLER                                 L-1 
+          L.1     8085 REGISTER SET                                  L-1 
+          L.2     8085 INSTRUCTION SET                               L-1 
+          L.2.1     Inherent Instructions                            L-2 
+          L.2.2     Register/Memory/Immediate Instructions           L-2 
+          L.2.3     Call and Return Instructions                     L-2 
+          L.2.4     Jump Instructions                                L-2 
+          L.2.5     Input/Output/Reset Instructions                  L-3 
+          L.2.6     Move Instructions                                L-3 
+          L.2.7     Other Instructions                               L-3 
+
+        APPENDIX M  ASZ80 ASSEMBLER                                  M-1 
+          M.1     .hd64 DIRECTIVE                                    M-1 
+          M.2     Z80 REGISTER SET AND CONDITIONS                    M-1 
+          M.3     Z80 INSTRUCTION SET                                M-2 
+          M.3.1     Inherent Instructions                            M-3 
+          M.3.2     Implicit Operand Instructions                    M-3 
+          M.3.3     Load Instruction                                 M-4 
+          M.3.4     Call/Return Instructions                         M-4 
+          M.3.5     Jump and Jump to Subroutine Instructions         M-4 
+          M.3.6     Bit Manipulation Instructions                    M-5 
+          M.3.7     Interrupt Mode and Reset Instructions            M-5 
+          M.3.8     Input and Output Instructions                    M-5 
+          M.3.9     Register Pair Instructions                       M-5 
+          M.3.10    HD64180 Specific Instructions                    M-6 
+
+        APPENDIX N  AS6500 ASSEMBLER                                 N-1 
+          N.1     ACKNOWLEDGMENT                                     N-1 
+          N.2     6500 REGISTER SET                                  N-2 
+          N.3     6500 INSTRUCTION SET                               N-2 
+          N.3.1     Processor Specific Directives                    N-3 
+          N.3.2     65xx Core Inherent Instructions                  N-3 
+          N.3.3     65xx Core Branch Instructions                    N-3 
+          N.3.4     65xx Core Single Operand Instructions            N-3 
+          N.3.5     65xx Core Double Operand Instructions            N-4 
+          N.3.6     65xx Core Jump and Jump to Subroutine
+                    Instructions                                     N-4 
+          N.3.7     65xx Core Miscellaneous X and Y Register
+                    Instructions                                     N-4 
+          N.3.8     65F11 and 65F12 Specific Instructions            N-5 
+          N.3.9     65C00/21 and 65C29 Specific Instructions         N-5 
+          N.3.10    65C02, 65C102, and 65C112 Specific
+                    Instructions                                     N-6 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                    CHAPTER 1
+
+                                  THE ASSEMBLER
+
+
+
+
+
+        1.1  THE ASXXXX ASSEMBLERS 
+
+
+           The  ASxxxx  assemblers are a series of microprocessor assem-
+        blers written in the C programming language.  Each assembler has
+        a device specific section which includes:  
+
+             1.  device  description, byte order, and file extension in-
+                 formation 
+
+             2.  a  table  of  the assembler general directives, special
+                 device directives, assembler mnemonics  and  associated
+                 operation codes 
+
+             3.  machine specific code for processing the device mnemon-
+                 ics, addressing modes, and special directives 
+
+        The device specific information is detailed in the appendices.  
+
+           The assemblers have a common device independent section which
+        handles the details of file input/output, symbol  table  genera-
+        tion,  program/data  areas,  expression  analysis, and assembler
+        directive processing.  
+
+        The assemblers provide the following features:  
+
+             1.  Command string control of assembly functions 
+
+             2.  Alphabetized, formatted symbol table listing 
+
+             3.  Relocatable object modules 
+
+             4.  Global symbols for linking object modules 
+
+             5.  Conditional assembly directives 
+
+
+
+        THE ASSEMBLER                                           PAGE 1-2
+        THE ASXXXX ASSEMBLERS
+
+
+             6.  Program sectioning directives 
+
+
+           ASxxxx assembles one or more source files into a single relo-
+        catable ascii object file.  The output of the ASxxxx  assemblers
+        consists of an ascii relocatable object file(*.rel), an assembly
+        listing file(*.lst), and a symbol file(*.sym).  
+
+
+        1.1.1  Assembly Pass 1 
+
+
+           During  pass  1, ASxxxx opens all source files and performs a
+        rudimenatry assembly of each source statement.  During this pro-
+        cess  all symbol tables are built, program sections defined, and
+        number of bytes for each assembled source line is estimated.  
+
+           At the end of pass 1 all undefined symbols may be made global
+        (external) using the ASxxxx switch -g, otherwise undefined  sym-
+        bols will be flagged as errors during succeeding passes.  
+
+
+        1.1.2  Assembly Pass 2 
+
+
+           During  pass  2  the ASxxxx assembler resolves forward refer-
+        ences and determines the number  of  bytes  for  each  assembled
+        line.   The  number  of bytes used by a particular assembler in-
+        struction may depend upon the addressing mode, whether  the  in-
+        struction allows multiple forms based upon the relative distance
+        to the addressed location, or other factors.   Pass  2  resolves
+        these cases and determines the address of all symbols.  
+
+
+        1.1.3  Assembly Pass 3 
+
+
+           Pass 3 by the assembler generates the listing file, the relo-
+        catable output file, and the symbol tables.  Also during pass  3
+        the errors will be reported.  
+
+           The  relocatable object file is an ascii file containing sym-
+        bol references and definitions, program  area  definitions,  and
+        the  relocatable assembled code, the linker ASLINK will use this
+        information to generate an absolute load file (Motorola or Intel
+        formats).  
+
+
+
+
+        THE ASSEMBLER                                           PAGE 1-3
+        SOURCE PROGRAM FORMAT
+
+
+        1.2  SOURCE PROGRAM FORMAT 
+
+
+
+        1.2.1  Statement Format 
+
+
+           A source program is composed of assembly-language statements.
+        Each statement must be completed on one line.  A line  may  con-
+        tain a maximum of 128 characters, longer lines are truncated and
+        lost.  
+
+           An  ASxxxx  assembler  statement  may  have  as  many as four
+        fields.  These fields are identified by their order  within  the
+        statement  and/or  by separating characters between fields.  The
+        general format of the ASxxxx statement is:  
+
+              [label:]  Operator        Operand         [;Comment(s)] 
+
+           The  label and comment fields are optional.  The operator and
+        operand fields are interdependent.  The operator field may be an
+        assembler  directive or an assembly mnemonic.  The operand field
+        may be optional or required as defined in  the  context  of  the
+        operator.  
+
+           ASxxxx  interprets  and  processes source statements one at a
+        time.  Each statement causes a particular operation to  be  per-
+        formed.  
+
+
+        1.2.1.1  Label Field  - 
+
+           A  label is a user-defined symbol which is assigned the value
+        of the current location counter and entered into  the  user  de-
+        fined  symbol  table.   The  current location counter is used by
+        ASxxxx to assign memory addresses to the source  program  state-
+        ments as they are encountered during the assembly process.  Thus
+        a label is a means  of  symbolically  referring  to  a  specific
+        statement.  
+
+           When  a program section is absolute, the value of the current
+        location counter is absolute;  its value references an  absolute
+        memory  address.   Similarly, when a program section is relocat-
+        able, the value of the current location counter is  relocatable.
+        A  relocation  bias  calculated at link time is added to the ap-
+        parent value of the current location counter  to  establish  its
+        effective  absolute  address  at  execution time.  (The user can
+        also force the linker to relocate sections defined as  absolute.
+        This may be required under special circumstances.) 
+
+           If  present,  a  label  must  be  the first field in a source
+        statement and must be terminated by a colon (:).   For  example,
+
+
+        THE ASSEMBLER                                           PAGE 1-4
+        SOURCE PROGRAM FORMAT
+
+
+        if  the  value  of  the  current  location  counter  is absolute
+        01F0(H), the statement:  
+
+              abcd:     nop 
+
+        assigns  the  value  01F0(H) to the label abcd.  If the location
+        counter value were relocatable, the final value of abcd would be
+        01F0(H)+K, where K represents the relocation bias of the program
+        section, as calculated by the linker at link time.  
+
+           More  than  one label may appear within a single label field.
+        Each label so specified is assigned the same address value.  For
+        example,  if  the  value  of  the  current  location  counter is
+        1FF0(H), the multiple labels in the following statement are each
+        assigned the value 1FF0(H):  
+
+              abcd:     aq:     $abc:   nop 
+
+           Multiple labels may also appear on successive lines.  For ex-
+        ample, the statements 
+
+              abcd:  
+              aq:  
+              $abc:     nop 
+
+        likewise  cause  the  same value to be assigned to all three la-
+        bels.  
+
+           A  double  colon  (::)  defines the label as a global symbol.
+        For example, the statement 
+
+              abcd::    nop 
+
+        establishes the label abcd as a global symbol.  The distinguish-
+        ing attribute of a global symbol is that it  can  be  referenced
+        from  within an object module other than the module in which the
+        symbol is defined.  References to this label  in  other  modules
+        are  resolved when the modules are linked as a composite execut-
+        able image.  
+
+        The legal characters for defining labels are:  
+
+                A through Z 
+                a through z 
+                0 through 9 
+                . (Period) 
+                $ (Dollar sign) 
+                _ (underscore) 
+
+           A  label  may  be  any  length,  however  only  the  first 79
+        characters are significant and, therefore must be  unique  among
+        all   labels  in  the  source  program  (not  necessarily  among
+
+
+        THE ASSEMBLER                                           PAGE 1-5
+        SOURCE PROGRAM FORMAT
+
+
+        separately compiled modules).  An error code(s) (m or p) will be
+        generated  in the assembly listing if the first 79 characters in
+        two or more labels are the same.  The m code is  caused  by  the
+        redeclaration  of  the symbol or its reference by another state-
+        ment.  The p code is generated because the symbols  location  is
+        changing on each pass through the source file.  
+
+           The  label  must  not  start with the characters 0-9, as this
+        designates a local symbol with special attributes described in a
+        later section.  
+
+           The  label  must  not  start  with  the  sequence $$, as this
+        represents the temporary radix 16 for constants.  
+
+
+        1.2.1.2  Operator Field  - 
+
+           The  operator field specifies the action to be performed.  It
+        may consist of an instruction mnemonic (op code) or an assembler
+        directive.  
+
+           When  the  operator is an instruction mnemonic, a machine in-
+        struction is generated and the assembler evaluates the addresses
+        of  the operands which follow.  When the operator is a directive
+        ASxxxx performs certain control actions or processing operations
+        during assembly of the source program.  
+
+           Leading  and  trailing  spaces  or tabs in the operator field
+        have no significance;  such characters serve  only  to  separate
+        the operator field from the preceeding and following fields.  
+
+           An operator is terminated by a space, tab or end of line.  
+
+
+        1.2.1.3  Operand Field  - 
+
+           When  the  operator is an instruction mnemonic (op code), the
+        operand  field  contains  program  variables  that  are  to   be
+        evaluated/manipulated by the operator.  
+
+           Operands  may  be  expressions  or  symbols, depending on the
+        operator.  Multiple expressions used in the operand  fields  may
+        be  separated  by a comma.  An operand should be preceeded by an
+        operator field;  if it is not, the statement will give an  error
+        (q  or  o).   All  operands  following instruction mnemonics are
+        treated as expressions.  
+
+           The operand field is terminated by a semicolon when the field
+        is followed  by  a  comment.   For  example,  in  the  following
+        statement:  
+
+              label:    lda     abcd,x          ;Comment field 
+
+
+        THE ASSEMBLER                                           PAGE 1-6
+        SOURCE PROGRAM FORMAT
+
+
+
+        the  tab  between lda and abcd terminates the operator field and
+        defines the beginning of the operand field;  a  comma  separates
+        the operands abcd and x;  and a semicolon terminates the operand
+        field and defines the beginning of the comment field.   When  no
+        comment  field  follows,  the operand field is terminated by the
+        end of the source line.  
+
+
+        1.2.1.4  Comment Field  - 
+
+           The comment field begins with a semicolon and extends through
+        the end of the line.  This field is optional and may contain any
+        7-bit ascii character except null.  
+
+           Comments  do not affect assembly processing or program execu-
+        tion.  
+
+
+        1.3  SYMBOLS AND EXPRESSIONS 
+
+
+           This  section  describes the generic components of the ASxxxx
+        assemblers:  the character set, the conventions observed in con-
+        structing  symbols,  and  the use of numbers, operators, and ex-
+        pressions.  
+
+
+        1.3.1  Character Set 
+
+
+           The following characters are legal in ASxxxx source programs: 
+
+             1.  The  letters  A  through Z.  Both upper- and lower-case
+                 letters are acceptable.  The  assemblers,  by  default,
+                 are  not  case  sensitive,  i.e.  ABCD and abcd are the
+                 same symbols.  (The assemblers can be made case  sensi-
+                 tive by using the -z command line option.) 
+
+             2.  The digits 0 through 9 
+
+             3.  The  characters . (period), $ (dollar sign), and _ (un-
+                 derscore).  
+
+             4.  The special characters listed in Tables 1 through 6.  
+
+
+           Tables  1  through  6  describe  the various ASxxxx label and
+        field terminators, assignment operators, operand separators, as-
+        sembly, unary, binary, and radix operators.  
+
+
+        THE ASSEMBLER                                           PAGE 1-7
+        SYMBOLS AND EXPRESSIONS
+
+
+        Table 1         Label Terminators and Assignment Operators 
+        ---------------------------------------------------------------- 
+
+                :   Colon               Label terminator.  
+
+                ::  Double colon        Label  Terminator;   defines the
+                                        label as a global label.  
+
+                =   Equal sign          Direct assignment operator.  
+
+                ==  Double equal        Direct assignment operator;  
+                    sign                defines  the  symbol as a global
+                                        symbol.  
+
+        ---------------------------------------------------------------- 
+
+
+
+
+
+        Table 2         Field Terminators and Operand Separators 
+        ---------------------------------------------------------------- 
+
+                    Tab                 Item or field terminator.  
+
+                    Space               Item or field terminator.  
+
+                ,   Comma               Operand field separator.  
+
+                ;   Semicolon           Comment field indicator.  
+
+        ---------------------------------------------------------------- 
+
+
+
+
+
+        Table 3         Assembler Operators 
+        ---------------------------------------------------------------- 
+
+                #   Number sign         Immediate expression indicator. 
+
+                .   Period              Current location counter.  
+
+                (   Left parenthesis    Expression delimiter.  
+
+                )   Right parenthesis   Expression delimeter.  
+
+        ---------------------------------------------------------------- 
+
+
+        THE ASSEMBLER                                           PAGE 1-8
+        SYMBOLS AND EXPRESSIONS
+
+
+
+
+
+
+
+        Table 4         Unary Operators 
+        ---------------------------------------------------------------- 
+
+                <   Left bracket        <FEDC   Produces  the lower byte
+                                                value of the expression.
+                                                (DC) 
+
+                >   Right bracket       >FEDC   Produces  the upper byte
+                                                value of the expression.
+                                                (FE) 
+
+                +   Plus sign           +A      Positive value of A 
+
+                -   Minus sign          -A      Produces   the  negative
+                                                (2's complement) of A.  
+
+                ~   Tilde               ~A      Produces the 1's comple-
+                                                ment of A.  
+
+                '   Single quote        'D      Produces  the  value  of
+                                                the character D.  
+
+                "   Double quote        "AB     Produces the double byte
+                                                value for AB.  
+
+                \   Backslash           '\n     Unix style characters 
+                                                \b, \f, \n, \r, \t 
+                                     or '\001   or octal byte values.  
+
+        ---------------------------------------------------------------- 
+
+
+
+
+
+
+
+        THE ASSEMBLER                                           PAGE 1-9
+        SYMBOLS AND EXPRESSIONS
+
+
+        Table 5         Binary Operators 
+        ---------------------------------------------------------------- 
+
+                <<  Double          0800 << 4   Produces the 4 bit 
+                    Left bracket                left-shifted   value  of
+                                                0800.  (8000) 
+
+                >>  Double          0800 >> 4   Produces the 4 bit 
+                    Right bracket               right-shifted  value  of
+                                                0800.  (0080) 
+
+                +   Plus sign       A + B       Arithmetic      Addition
+                                                operator.  
+
+                -   Minus sign      A - B       Arithmetic   Subtraction
+                                                operator.  
+
+                *   Asterisk        A * B       Arithmetic   Multiplica-
+                                                tion operator.   (signed
+                                                16-bit) 
+
+                /   Slash           A / B       Arithmetic      Division
+                                                operator.        (signed
+                                                16-bit quotient) 
+
+                &   Ampersand       A & B       Logical AND operator.  
+
+                |   Bar             A | B       Logical OR operator.  
+
+                %   Percent sign    A % B       Modulus operator.  
+                                                (16-bit value) 
+
+                ^   Up arrow or     A ^ B       EXCLUSIVE OR operator.  
+                    circumflex 
+
+        ---------------------------------------------------------------- 
+
+
+
+
+
+
+
+        THE ASSEMBLER                                          PAGE 1-10
+        SYMBOLS AND EXPRESSIONS
+
+
+        Table 6         Temporary Radix Operators 
+        ---------------------------------------------------------------- 
+
+                $%,   0b, 0B            Binary radix operator.  
+
+                $&,   0o, 0O, 0q, 0Q    Octal radix operator.  
+
+                $#,   0d, 0D            Decimal radix operator.  
+
+                $$,   0h, 0H, 0x, 0X    Hexidecimal radix operator.  
+
+
+                Potential  ambiguities arising from the use of 0b and 0d
+                as temporary radix operators may be circumvented by pre-
+                ceding  all  non-prefixed  hexidecimal  numbers with 00.
+                Leading 0's are required in any  case  where  the  first
+                hexidecimal  digit is abcdef as the assembler will treat
+                the letter sequence as a label.  
+
+        ---------------------------------------------------------------- 
+
+
+
+
+
+
+
+        1.3.2  User-Defined Symbols 
+
+
+           User-defined  symbols are those symbols that are equated to a
+        specific value through a direct assignment statement  or  appear
+        as  labels.  These symbols are added to the User Symbol Table as
+        they are encountered during assembly.  
+
+        The following rules govern the creation of user-defined symbols: 
+
+             1.  Symbols  can  be  composed  of alphanumeric characters,
+                 dollar signs ($),  periods  (.),  and  underscores  (_)
+                 only.  
+
+             2.  The  first  character  of a symbol must not be a number
+                 (except in the case of local symbols).  
+
+             3.  The  first 79 characters of a symbol must be unique.  A
+                 symbol  can  be  written  with  more  than   79   legal
+                 characters,  but the 80th and subsequent characters are
+                 ignored.  
+
+             4.  Spaces and Tabs must not be embedded within a symbol.  
+
+
+
+
+        THE ASSEMBLER                                          PAGE 1-11
+        SYMBOLS AND EXPRESSIONS
+
+
+        1.3.3  Local Symbols 
+
+
+           Local  symbols are specially formatted symbols used as labels
+        within a block of coding that has been delimited as a local sym-
+        bol  block.   Local  symbols  are  of  the form n$, where n is a
+        decimal integer from 0 to 255,  inclusive.   Examples  of  local
+        symbols are:  
+
+              1$ 
+              27$ 
+              138$ 
+              244$ 
+
+           The  range  of  a local symbol block consists of those state-
+        ments between two normally constructed  symbolic  labels.   Note
+        that a statement of the form:  
+
+              ALPHA = EXPRESSION 
+
+        is a direct assignment statement but does not create a label and
+        thus does not delimit the range of a local symbol block.  
+
+           Note that the range of a local symbol block may extend across
+        program areas.  
+
+           Local symbols provide a convenient means of generating labels
+        for branch instructions and other such references  within  local
+        symbol  blocks.   Using local symbols reduces the possibility of
+        symbols with multiple definitions appearing within a  user  pro-
+        gram.   In  addition,  the  use  of local symbols differentiates
+        entry-point labels from local labels, since local labels  cannot
+        be referenced from outside their respective local symbol blocks.
+        Thus, local symbols of the same name can appear in  other  local
+        symbol blocks without conflict.  Local symbols require less sym-
+        bol table space than normal symbols.  Their use is recommended. 
+
+           The  use of the same local symbol within a local symbol block
+        will generate one or both of the m or p errors.  
+
+
+        THE ASSEMBLER                                          PAGE 1-12
+        SYMBOLS AND EXPRESSIONS
+
+
+        Example of local symbols:  
+
+                a:      ldx     #atable ;get table address
+                        lda     #0d48   ;table length
+                1$:     clr     ,x+     ;clear
+                        deca
+                        bne     1$
+                        
+                b:      ldx     #btable ;get table address
+                        lda     #0d48   ;table length
+                1$:     clr     ,x+     ;clear
+                        deca
+                        bne     1$
+
+
+        1.3.4  Current Location Counter 
+
+
+           The  period  (.) is the symbol for the current location coun-
+        ter.  When used in the operand  field  of  an  instruction,  the
+        period   represents  the  address  of  the  first  byte  of  the
+        instruction:  
+
+                AS:     ldx     #.      ;The period (.) refers to
+                                        ;the address of the ldx
+                                        ;instruction.
+
+           When  used  in  the  operand field of an ASxxxx directive, it
+        represents the address of the current byte or word:  
+
+                QK = 0
+        
+                .word   0xFFFE,.+4,QK   ;The operand .+4 in the .word
+                                        ;directive represents a value
+                                        ;stored in the second of the
+                                        ;three words during assembly.
+
+           If  we  assume  the  current  value of the program counter is
+        0H0200, then during assembly, ASxxxx  reserves  three  words  of
+        storage  starting  at  location 0H0200.  The first value, a hex-
+        idecimal constant FFFE, will be stored at location 0H0200.   The
+        second  value  represented  by  .+4  will  be stored at location
+        0H0202, its value will be 0H0206 ( = 0H0202  +  4).   The  third
+        value  defined  by  the  symbol  QK  will  be placed at location
+        0H0204.  
+
+           At the beginning of each assembly pass, ASxxxx resets the lo-
+        cation counter.  Normally, consecutive memory locations are  as-
+        signed  to  each  byte  of  object code generated.  However, the
+        value of the location counter can be changed  through  a  direct
+        assignment statement of the following form:  
+
+
+
+        THE ASSEMBLER                                          PAGE 1-13
+        SYMBOLS AND EXPRESSIONS
+
+
+              . = . + expression 
+
+
+           The  new  location  counter can only be specified relative to
+        the current location counter.  Neglecting to specify the current
+        program  counter  along with the expression on the right side of
+        the assignment operator will generate the (.) error.   (Absolute
+        program areas may use the .org directive to specify the absolute
+        location of the current program counter.) 
+
+        The following coding illustrates the use of the current location
+        counter:  
+
+                .area   CODE1   (ABS)   ;program area CODE1
+                                        ;is ABSOLUTE
+        
+                .org    0H100           ;set location to
+                                        ;0H100 absolute
+        
+        num1:   ldx     #.+0H10         ;The label num1 has
+                                        ;the value 0H100.
+                                        ;X is loaded with
+                                        ;0H100 + 0H10
+        
+                .org    0H130           ;location counter
+                                        ;set to 0H130
+        
+        num2:   ldy     #.              ;The label num2 has
+                                        ;the value 0H130.
+                                        ;Y is loaded with
+                                        ;value 0H130.
+        
+        
+                .area   CODE2   (REL)   ;program area CODE2
+                                        ;is RELOCATABLE
+        
+                . = . + 0H20            ;Set location counter
+                                        ;to relocatable 0H20 of
+                                        ;the program section.
+        
+        num3:   .word   0               ;The label num3 has
+                                        ;the value
+                                        ;of relocatable 0H20.
+        
+                . = . + 0H40            ;will reserve 0H40
+                                        ;bytes of storage as will
+                .blkb   0H40            ;or
+                .blkw   0H20
+
+           The  .blkb  and .blkw directives are the preferred methods of
+        allocating space.  
+
+
+
+        THE ASSEMBLER                                          PAGE 1-14
+        SYMBOLS AND EXPRESSIONS
+
+
+        1.3.5  Numbers 
+
+
+           ASxxxx  assumes that all numbers in the source program are to
+        be interpreted in decimal radix unless otherwise specified.  The
+        .radix  directive  may  be used to specify the default as octal,
+        decimal, or hexidecimal.  Individual numbers can  be  designated
+        as  binary, octal, decimal, or hexidecimal through the temporary
+        radix prefixes shown in table 6.  
+
+           Negative  numbers  must be preceeded by a minus sign;  ASxxxx
+        translates such numbers into two's  complement  form.   Positive
+        numbers may (but need not) be preceeded by a plus sign.  
+
+           Numbers are always considered to be absolute values, therefor
+        they are never relocatable.  
+
+
+        1.3.6  Terms 
+
+
+           A  term is a component of an expression and may be one of the
+        following:  
+
+
+             1.  A number.  
+
+             2.  A symbol:  
+                 1.  A  period (.) specified in an expression causes the
+                     current location counter to be used.  
+                 2.  A User-defined symbol.  
+                 3.  An undefined symbol is assigned a value of zero and
+                     inserted in the User-Defined symbol table as an un-
+                     defined symbol.  
+
+             3.  A single quote followed by a single ascii character, or
+                 a double quote followed by two ascii characters.  
+
+             4.  An  expression enclosed in parenthesis.  Any expression
+                 so enclosed is evaluated and reduced to a  single  term
+                 before  the remainder of the expression in which it ap-
+                 pears is evaluated.  Parenthesis, for example,  may  be
+                 used  to  alter the left-to-right evaluation of expres-
+                 sions, (as in A*B+C versus A*(B+C)), or to apply a  un-
+                 ary operator to an entire expression (as in -(A+B)).  
+
+             5.  A unary operator followed by a symbol or number.  
+
+
+
+
+
+        THE ASSEMBLER                                          PAGE 1-15
+        SYMBOLS AND EXPRESSIONS
+
+
+        1.3.7  Expressions 
+
+
+           Expressions  are  combinations  of  terms  joined together by
+        binary operators.  Expressions reduce to a  16-bit  value.   The
+        evaluation  of  an  expression includes the determination of its
+        attributes.  A resultant expression value may be  one  of  three
+        types  (as  described  later in this section):  relocatable, ab-
+        solute, and external.  
+
+        Expressions are evaluate with an operand hierarchy as follows:  
+
+                *       /       %       multiplication,
+                                        division, and
+                                        modulus first.
+        
+                +       -               addition and
+                                        subtraction second.
+        
+                <<      >>              left shift and
+                                        right shift third.
+        
+                ^                       exclusive or fourth.
+        
+                &                       logical and fifth.
+        
+                |                       logical or last
+        
+                except that unary operators take precedence over binary
+                operators.
+
+
+           A  missing  or  illegal  operator  terminates  the expression
+        analysis, causing error codes (o) and/or  (q)  to  be  generated
+        depending upon the context of the expression itself.  
+
+           At assembly time the value of an external (global) expression
+        is equal to the value of the absolute part of  that  expression.
+        For  example,  the expression external+4, where 'external' is an
+        external symbol, has the value of 4.  This expression,  however,
+        when  evaluated  at link time takes on the resolved value of the
+        symbol 'external', plus 4.  
+
+           Expressions,  when  evaluated  by  ASxxxx,  are  one of three
+        types:  relocatable, absolute, or external.  The following  dis-
+        tinctions are important:  
+
+             1.  An  expression is relocatable if its value is fixed re-
+                 lative to the base address of the program area in which
+                 it appears;  it will have an offset value added at link
+                 time.  Terms that contain labels defined in relocatable
+                 program   areas   will   have   a   relocatable  value;
+
+
+        THE ASSEMBLER                                          PAGE 1-16
+        SYMBOLS AND EXPRESSIONS
+
+
+                 similarly, a period (.) in a relocatable program  area,
+                 representing  the value of the current program location
+                 counter, will also have a relocatable value.  
+
+             2.  An  expression  is  absolute if its value is fixed.  An
+                 expression whose terms are numbers and ascii characters
+                 will  reduce  to  an absolute value.  A relocatable ex-
+                 pression or term minus a relocatable term,  where  both
+                 elements  being  evaluated  belong  to the same program
+                 area, is an absolute expression.  This is because every
+                 term  in  a  program area has the same relocation bias.
+                 When one term is subtracted from the other the  reloca-
+                 tion bias is zero.  
+
+             3.  An  expression is external (or global) if it contains a
+                 single global reference (plus or minus an absolute  ex-
+                 pression  value) that is not defined within the current
+                 program.  Thus, an external  expression  is  only  par-
+                 tially  defined following assembly and must be resolved
+                 at link time.  
+
+
+
+        1.4  GENERAL ASSEMBLER DIRECTIVES 
+
+
+           An  ASxxxx  directive  is placed in the operator field of the
+        source line.  Only one directive is  allowed  per  source  line.
+        Each  directive  may  have  a blank operand field or one or more
+        operands.  Legal operands differ with each directive.  
+
+
+        1.4.1  .module Directive 
+
+        Format:  
+
+                .module string 
+
+           The .module directive causes the string to be included in the
+        assemblers output file as an identifier for this particular  ob-
+        ject  module.   The  string  may  be  from 1 to 79 characters in
+        length.  Only one identifier is allowed  per  assembled  module.
+        The  main use of this directive is to allow the linker to report
+        a modules' use of undefined symbols.  At link time all undefined
+        symbols  are  reported  and  the  modules  referencing  them are
+        listed.  
+
+
+
+
+        THE ASSEMBLER                                          PAGE 1-17
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+        1.4.2  .title Directive 
+
+        Format:  
+
+                .title  string 
+
+           The .title directive provides a character string to be placed
+        on the second line of each page during listing.  
+
+
+        1.4.3  .sbttl Directive 
+
+        Format:  
+
+                .sbttl  string 
+
+           The .sbttl directive provides a character string to be placed
+        on the third line of each page during listing.  
+
+
+        1.4.4  .page Directive 
+
+        Format:  
+
+                .page 
+
+           The .page directive causes a page ejection with a new heading
+        to be printed.  The new page occurs after the next line  of  the
+        source  program is processed, this allows an immediately follow-
+        ing .sbttl directive to appear  on  the  new  page.   The  .page
+        source  line will not appear in the file listing.  Paging may be
+        disabled by invoking the -p directive.  
+
+
+        1.4.5  .byte and .db Directives 
+
+        Format:  
+
+                .byte   exp             ;Stores the binary value
+                .db     exp             ;of the expression in the
+                                        ;next byte.
+        
+                .byte   exp1,exp2,expn  ;Stores the binary values
+                .db     exp1,exp2,expn  ;of the list of expressions
+                                        ;in successive bytes.
+        
+        where:  exp,    represent expressions that will be
+                exp1,   truncated to 8-bits of data.
+                .       Each expression will be calculated
+                .       as a 16-bit word expression,
+                .       the high-order byte will be truncated.
+                .       Multiple expressions must be
+
+
+        THE ASSEMBLER                                          PAGE 1-18
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+                expn    separated by commas.
+
+           The  .byte  or .db directives are used to generate successive
+        bytes of binary data in the object module.  
+
+
+        1.4.6  .word and .dw Directives 
+
+        Format:  
+
+                .word   exp             ;Stores the binary value
+                .dw     exp             ;of the expression in
+                                        ;the next word.
+        
+                .word   exp1,exp2,expn  ;Stores the binary values
+                .dw     exp1,exp2,expn  ;of the list of expressions
+                                        ;in successive words.
+        
+        where:  exp,    represent expressions that will occupy two
+                exp1,   bytes of data. Each expression will be
+                .       calculated as a 16-bit word expression.
+                .       Multiple expressions must be
+                expn    separated by commas.
+
+           The  .word  or .dw directives are used to generate successive
+        words of binary data in the object module.  
+
+
+        1.4.7  .blkb, .blkw, and .ds Directives 
+
+        Format:  
+
+                .blkb   N       ;reserve N bytes of space
+                .blkw   N       ;reserve N words of space
+                .ds     N       ;reserve N bytes of space
+
+           The  .blkb  and .ds directives reserve byte blocks in the ob-
+        ject module;  the .blkw directive reserves word blocks.  
+
+
+        1.4.8  .ascii Directive 
+
+        Format:  
+
+                .ascii  /string/ 
+
+        where:  string  is a string of printable ascii characters.  
+
+                /  /    represent   the  delimiting  characters.   These
+                        delimiters   may   be   any   paired    printing
+                        characters,  as  long  as the characters are not
+                        contained within  the  string  itself.   If  the
+
+
+        THE ASSEMBLER                                          PAGE 1-19
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+                        delimiting  characters  do not match, the .ascii
+                        directive will give the (q) error.  
+
+        The  .ascii  directive  places  one binary byte of data for each
+        character in the string into the object module.  
+
+
+        1.4.9  .ascis Directive 
+
+        Format:  
+
+                .ascis  /string/ 
+
+        where:  string  is a string of printable ascii characters.  
+
+                /  /    represent   the  delimiting  characters.   These
+                        delimiters   may   be   any   paired    printing
+                        characters,  as  long  as the characters are not
+                        contained within  the  string  itself.   If  the
+                        delimiting  characters  do not match, the .ascis
+                        directive will give the (q) error.  
+
+        The  .ascis  directive  places  one binary byte of data for each
+        character in the  string  into  the  object  module.   The  last
+        character in the string will have the high order bit set.  
+
+
+        1.4.10  .asciz Directive 
+
+        Format:  
+
+                .asciz  /string/ 
+
+        where:  string  is a string of printable ascii characters.  
+
+                /  /    represent   the  delimiting  characters.   These
+                        delimiters   may   be   any   paired    printing
+                        characters,  as  long  as the characters are not
+                        contained within  the  string  itself.   If  the
+                        delimiting  characters  do not match, the .asciz
+                        directive will give the (q) error.  
+
+        The  .asciz  directive  places  one binary byte of data for each
+        character in the string into the object module.   Following  all
+        the  character  data  a  zero  byte is inserted to terminate the
+        character string.  
+
+
+
+
+        THE ASSEMBLER                                          PAGE 1-20
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+        1.4.11  .radix Directive 
+
+        Format:  
+
+                .radix  character 
+
+        where:  character  represents  a single character specifying the
+                        default radix to be used for succeeding numbers.
+                        The character may be any one of the following:  
+
+                        B,b     Binary
+        
+                        O,o     Octal
+                        Q,q
+        
+                        D,d     Decimal
+                        'blank'
+        
+                        H,h     Hexidecimal
+                        X,x
+
+
+        1.4.12  .even Directive 
+
+        Format:  
+
+                .even 
+
+           The .even directive ensures that the current location counter
+        contains an even boundary value by adding 1 if the current loca-
+        tion is odd.  
+
+
+        1.4.13  .odd Directive 
+
+        Format:  
+
+                .odd 
+
+           The  .odd directive ensures that the current location counter
+        contains an odd boundary value by adding one if the current  lo-
+        cation is even.  
+
+
+
+
+        THE ASSEMBLER                                          PAGE 1-21
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+        1.4.14  .area Directive 
+
+        Format:  
+
+                .area   name    [(options)] 
+
+        where:  name    represents the symbolic name of the program sec-
+                        tion.   This  name  may  be  the  same  as   any
+                        user-defined  symbol  as  the area names are in-
+                        dependent of all symbols and labels.  
+
+                options specify the type of program or data area:  
+                        ABS     absolute (automatically invokes OVR) 
+                        REL     relocatable 
+                        OVR     overlay 
+                        CON     concatenate 
+                        PAG     paged area 
+
+
+           The .area directive provides a means of defining and separat-
+        ing multiple programming and data sections.   The  name  is  the
+        area  label used by the assembler and the linker to collect code
+        from various separately assembled modules into one section.  The
+        name may be from 1 to 79 characters in length.  
+
+           The options are specified within parenthesis and separated by
+        commas as shown in the following example:  
+
+                .area  TEST  (REL,CON)  ;This section is relocatable
+                                        ;and concatenated with other
+                                        ;sections of this program area.
+        
+                .area  DATA  (REL,OVR)  ;This section is relocatable
+                                        ;and overlays other sections
+                                        ;of this program area.
+        
+                .area  SYS   (ABS,OVR)  ;(CON not allowed with ABS)
+                                        ;This section is defined as
+                                        ;absolute. Absolute sections
+                                        ;are always overlayed with
+                                        ;other sections of this program
+                                        ;area.
+        
+                .area  PAGE  (PAG)      ;This is a paged section. The
+                                        ;section must be on a 256 byte
+                                        ;boundary and its length is
+                                        ;checked by the linker to be
+                                        ;no larger than 256 bytes.
+                                        ;This is useful for direct page
+                                        ;areas.
+
+
+
+        THE ASSEMBLER                                          PAGE 1-22
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+           The  default  area type is REL|CON;  i.e.  a relocatable sec-
+        tion which is concatenated with other sections of code with  the
+        same area name.  The ABS option indicates an absolute area.  The
+        OVR and CON options indicate if program  sections  of  the  same
+        name  will overlay each other (start at the same location) or be
+        concatenated with each other (appended to each other).  
+
+           Multiple  invocations  of  the  .area directive with the same
+        name must specify the same options or leave  the  options  field
+        blank,  this  defaults  to  the previously specified options for
+        this program area.  
+
+        The   ASxxxx   assemblers   automatically  provide  two  program
+        sections:  
+
+                '.  .ABS.'      This dumby section contains all absolute
+                                symbols and their values.  
+
+                '_CODE'         This  is  the default program/data area.
+                                This program area is of type (REL,CON). 
+
+        The  ASxxxx  assemblers  also automatically generate two symbols
+        for each program area:  
+
+                's_<area>'      This is the starting address of the pro-
+                                gram area.  
+
+                                indent  -16  'l_<area>'      This is the
+                                length of the program area.  
+
+        The .area names and options are never case sensitive.  
+
+
+        1.4.15  .org Directive 
+
+        Format:  
+
+                .org    exp 
+
+        where:  exp     is  an absolute expression that becomes the cur-
+                        rent location counter.  
+
+        The  .org directive is valid only in an absolute program section
+        and will give a (q) error if used in a relocatable program area.
+        The  .org  directive specifies that the current location counter
+        is to become the specified absolute value.  
+
+
+
+
+        THE ASSEMBLER                                          PAGE 1-23
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+        1.4.16  .globl Directive 
+
+        Format:  
+
+                .globl  sym1,sym2,...,symn 
+
+        where:  sym1,           represent legal symbolic names. When
+                sym2,...        When multiple symbols are specified,
+                symn            they are separated by commas.
+
+           A  .globl directive may also have a label field and/or a com-
+        ment field.  
+
+           The  .globl directive is provided to define (and thus provide
+        linkage to) symbols not  otherwise  defined  as  global  symbols
+        within  a  module.   In  defining  global  symbols the directive
+        .globl J is similar to:  
+
+              J == expression or J::  
+
+           Because  object  modules  are linked by global symbols, these
+        symbols are vital to a program.  All internal symbols  appearing
+        within  a  given program must be defined at the end of pass 1 or
+        they will be considered undefined.  The assembly directive  (-g)
+        can  be  be  invoked to make all undefined symbols global at the
+        end of pass 1.  
+
+
+        1.4.17  .if, .else, and .endif Directives 
+
+        Format:  
+
+                .if     expr
+                .                       ;}
+                .                       ;} range of true condition
+                .                       ;}
+                .else
+                .                       ;}
+                .                       ;} range of false condition
+                .                       ;}
+                .endif
+
+           The  conditional  assembly directives allow you to include or
+        exclude blocks of source code during the assembly process, based
+        on the evaluation of the condition test.  
+
+           The  range of true condition will be processed if the expres-
+        sion 'expr' is not zero (i.e.  true) and the range of false con-
+        dition  will  be processed if the expression 'expr' is zero (i.e
+        false).  The range of true condition is optional as is the .else
+        directive  and  the range of false condition.  The following are
+        all valid .if/.else/.endif constructions:  
+
+
+        THE ASSEMBLER                                          PAGE 1-24
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+
+                .if     A-4             ;evaluate A-4
+                .byte   1,2             ;insert bytes if A-4 is
+                .endif                  ;not zero
+        
+                .if     K+3             ;evaluate K+3
+                .else
+                .byte   3,4             ;insert bytes if K+3
+                .endif                  ;is zero
+        
+                .if     J&3             ;evaluate J masked by 3
+                .byte   12              ;insert this byte if J&3
+                .else                   ;is not zero
+                .byte   13              ;insert this byte if J&3
+                .endif                  ;is zero
+
+
+        The .if/.else/.endif directives may be nested upto 10 levels.  
+
+           The  .page  directive  is  processed within a false condition
+        range to allow extended textual information to  be  incorporated
+        in  the  source  program  with  out  the need to use the comment
+        delimiter (;):  
+
+                .if     0
+        
+                .page
+                This text will be bypassed during assembly
+                but appear in the listing file.
+                .
+                .
+                .
+        
+                .endif
+
+
+        1.4.18  .include Directive 
+
+        Format:  
+
+                .include        string 
+
+        where:  string  represents  a  delimited string that is the file
+                        specification of an ASxxxx source file.  
+
+           The .include directive is used to insert a source file within
+        the source file currently being assembled.  When this  directive
+        is encountered, an implicit .page directive is issued.  When the
+        end of the specified source file is reached, an  implicit  .page
+        directive is issued and input continues from the previous source
+        file.  The maximum nesting level of source files specified by  a
+        .include directive is five.  
+
+
+        THE ASSEMBLER                                          PAGE 1-25
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+           The  total  number  of separately specified .include files is
+        unlimited as each .include file is opened and then closed during
+        each pass made by the assembler.  
+
+
+        1.4.19  .setdp Directive 
+
+        Format:  
+
+                .setdp [base [,area]] 
+
+        The  set  direct  page  directive has a common format in all the
+        AS68xx assemblers.  The .setdp directive is used to  inform  the
+        assembler  of  the current direct page region and the offset ad-
+        dress within the selected area.  The normal  invocation  methods
+        are:  
+
+                .area   DIRECT  (PAG)
+                .setdp
+        
+                or
+        
+                .setdp  0,DIRECT
+
+        for  all  the  68xx microprocessors (the 6804 has only the paged
+        ram area).  The commands specify that the direct page is in area
+        DIRECT and its offset address is 0 (the only valid value for all
+        but the 6809 microprocessor).  Be sure to place the DIRECT  area
+        at address 0 during linking.  When the base address and area are
+        not specified, then zero and the current area are the  defaults.
+        If  a  .setdp directive is not issued the assembler defaults the
+        direct page to the area "_CODE" at offset 0.  
+
+           The  assembler  verifies  that  any  local variable used in a
+        direct variable reference is located in this area.  Local  vari-
+        able  and  constant value direct access addresses are checked to
+        be within the address range from 0 to 255.  
+
+           External direct references are assumed by the assembler to be
+        in the correct area and have valid  offsets.   The  linker  will
+        check all direct page relocations to verify that they are within
+        the correct area.  
+
+           The  6809  microprocessor  allows the selection of the direct
+        page to be on any 256 byte boundary by loading  the  appropriate
+        value  into the dp register.  Typically one would like to select
+        the page boundary at link time, one method follows:  
+
+
+        THE ASSEMBLER                                          PAGE 1-26
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+                .area   DIRECT  (PAG)   ; define the direct page
+                .setdp
+                .
+                .
+                .
+                .area   PROGRAM
+                .
+                ldd     #DIRECT         ; load the direct page register
+                tfr     a,dp            ; for access to the direct page
+
+        At  link  time specify the base and global equates to locate the
+        direct page:  
+
+                -b DIRECT = 0x1000
+                -g DIRECT = 0x1000
+
+        Both  the  area address and offset value must be specified (area
+        and variable names are independent).   The  linker  will  verify
+        that  the  relocated  direct page accesses are within the direct
+        page.  
+        The  preceeding  sequence  could  be repeated for multiple paged
+        areas, however an alternate method is to define a non-paged area
+        and use the .setdp directive to specify the offset value:  
+
+                .area   DIRECT          ; define non-paged area
+                .
+                .
+                .
+                .area   PROGRAM
+                .
+                .setdp  0,DIRECT        ; direct page area
+                ldd     #DIRECT         ; load the direct page register
+                tfr     a,dp            ; for access to the direct page
+                .
+                .
+                .setdp  0x100,DIRECT    ; direct page area
+                ldd     #DIRECT+0x100   ; load the direct page register
+                tfr     a,dp            ; for access to the direct page
+
+        The  linker  will  verify that subsequent direct page references
+        are in the specified area and offset address range.  It  is  the
+        programmers responsibility to load the dp register with the cor-
+        rect page segment  corresponding  to  the  .setdp  base  address
+        specified.  
+
+           For  those  cases  where a single piece of code must access a
+        defined data structure within a direct page and there  are  many
+        pages,  define  a  dumby  direct page linked at address 0.  This
+        dumby page is used only to define  the  variable  labels.   Then
+        load  the dp register with the real base address but donot use a
+        .setdp  directive.   This  method  is  equivalent   to   indexed
+
+
+        THE ASSEMBLER                                          PAGE 1-27
+        GENERAL ASSEMBLER DIRECTIVES
+
+
+        addressing,  where the dp register is the index register and the
+        direct addressing is the offset.  
+
+
+        1.5  INVOKING ASXXXX 
+
+
+           The  ASxxxx assemblers are command line oriented.  The PC as-
+        semblers are started with the appropriate option(s) and  file(s)
+        to assemble following the assembler name:  
+
+        as6809 [-dqxgalosff] file1 [file2 file3 ...  file6] 
+
+        The options are:  
+
+                d       decimal listing
+                q       octal   listing
+                x       hex     listing (default)
+        
+                        The listing radix affects the
+                        .lst, .rel, and .sym files.
+        
+                g       undefined symbols made global
+                a       all user symbols made global
+        
+                l       create list   output file1.lst
+                o       create object output file1.rel
+                s       create symbol output file1.sym
+        
+                p       disable listing pagination
+                w       wide listing format for symbol table
+        
+                z       enable case sensitivity for symbols
+        
+                        relocatable reference flagging:
+        
+                f       by  `   in the listing file
+                ff      by mode in the listing file
+
+           The file name for the .lst, .rel, and .sym files is the first
+        file name specified in the command line.  All output  files  are
+        ascii  text  files which may be edited, copied, etc.  The output
+        files are the concatenation of all the input files, if files are
+        to  be  assembled  independently  invoke  the assembler for each
+        file.  
+
+           The  .rel  file contains a radix directive so that the linker
+        will use the proper conversion for this file.  Linked files  may
+        have different radices.  
+
+
+
+        THE ASSEMBLER                                          PAGE 1-28
+        INVOKING ASXXXX
+
+
+           If  the list (l) option is specified without the symbol table
+        (s) option, the symbol table is placed at the end of the listing
+        file.  
+
+
+        1.6  ERRORS 
+
+
+           The  ASxxxx assemblers provide limited diagnostic error codes
+        during the assembly process, these errors will be noted  in  the
+        listing file and printed on the stderr device.  
+
+           The assembler reports the errors on the stderr device as 
+
+                ?ASxxxx-Error-<*> in line nnn of filename
+
+        where  * is the error code, nnn is the line number, and filename
+        is the source/include file.  
+
+           The errors are:  
+
+              (.)   This  error  is caused by an absolute direct assign-
+                    ment of the current location counter 
+                          . = expression (incorrect) 
+                    rather than the correct 
+                          . = . + expression 
+
+              (a)   Indicates  a machine specific addressing or address-
+                    ing mode error.  
+
+              (b)   Indicates a direct page boundary error.  
+
+              (d)   Indicates a direct page addressing error.  
+
+              (i)   Caused  by  an  .include file error or an .if/.endif
+                    mismatch.  
+
+              (m)   Multiple  definitions  of  the  same label, multiple
+                    .module directives, or multiple  conflicting  attri-
+                    butes in an .area directive.  
+
+              (o)   Directive  or  mnemonic error or the use of the .org
+                    directive in a relocatable area.  
+
+              (p)   Phase error:  label location changing between passes
+                    2 and 3.  Normally caused by having  more  than  one
+                    level of forward referencing.  
+
+              (q)   Questionable syntax:  missing or improper operators,
+                    terminators, or delimiters.  
+
+              (r)   Relocation  error:   logic  operation attempted on a
+
+
+        THE ASSEMBLER                                          PAGE 1-29
+        ERRORS
+
+
+                    relocatable term, addition of two relocatable terms,
+                    subtraction  of two relocatable terms not within the
+                    same programming area or external symbols.  
+
+              (u)   Undefined symbol encountered during assembly.  
+
+
+        1.7  LISTING FILE 
+
+
+           The  (-l) option produces an ascii output listing file.  Each
+        page of output contains a four line header:  
+
+
+             1.  The ASxxxx program name and page number 
+
+             2.  Title from a .title directive (if any) 
+
+             3.  Subtitle from a .sbttl directive (if any) 
+
+             4.  Blank line 
+
+
+
+        Each succeeding line contains five fields:  
+
+
+             1.  Error field (first three characters of line) 
+
+             2.  Current location counter 
+
+             3.  Generated code in byte format 
+
+             4.  Source text line number 
+
+             5.  Source text 
+
+
+           The error field may contain upto 2 error flags indicating any
+        errors encountered while assembling this line of source code.  
+
+           The  current  location counter field displays the 16-bit pro-
+        gram position.  This field will be in the selected radix.  
+
+           The generated code follows the program location.  The listing
+        radix determines the number of bytes that will be  displayed  in
+        this field.  Hexidecimal listing allows six bytes of data within
+        the field, decimal and octal allow four bytes within the  field.
+        If more than one field of data is generated from the assembly of
+        a single line of source code, then the data field is repeated on
+        successive lines.  
+
+
+
+        THE ASSEMBLER                                          PAGE 1-30
+        LISTING FILE
+
+
+           The source text line number is printed in decimal and is fol-
+        lowed by the source text.  
+
+           Two  special  cases  will  disable  the  listing of a line of
+        source text:  
+
+             1.  Source line with a .page directive is never listed.  
+
+             2.  Source  line  with  a  .include  file  directive is not
+                 listed unless the .include file cannot be opened.  
+
+
+           Two  data  field  options  are  available to flag those bytes
+        which will be relocated by the linker.   If  the  -f  option  is
+        specified  then  each  byte to be relocated will be preceeded by
+        the '`' character.  If the -ff option  is  specified  then  each
+        byte  to  be relocated will be preceeded by one of the following
+        characters:  
+
+             1.  *   paged relocation 
+
+             2.  u   low  byte of unsigned word or unsigned byte 
+
+             3.  v   high byte of unsigned word 
+
+             4.  p   PCR low  byte of word relocation or PCR byte 
+
+             5.  q   PCR high byte of word relocation 
+
+             6.  r   low  byte relocation or byte relocation 
+
+             7.  s   high byte relocation 
+
+
+
+        1.8  SYMBOL TABLE FILE 
+
+
+           The symbol table has two parts:  
+
+             1.  The alphabetically sorted list of symbols and/or labels
+                 defined or referenced in the source program.  
+
+             2.  A  list of the program areas defined during assembly of
+                 the source program.  
+
+
+           The sorted list of symbols and/or labels contains the follow-
+        ing information:  
+
+             1.  Program  area  number (none if absolute value or exter-
+                 nal) 
+
+
+        THE ASSEMBLER                                          PAGE 1-31
+        SYMBOL TABLE FILE
+
+
+             2.  The symbol or label 
+
+             3.  Directly assigned symbol is denoted with an (=) sign 
+
+             4.  The  value of a symbol, location of a label relative to
+                 the program area base address (=0), or a ****  indicat-
+                 ing the symbol or label is undefined.  
+
+             5.  The  characters:   G - global, R - relocatable, and X -
+                 external.  
+
+
+           The list of program areas provides the correspondence between
+        the program area numbers and the defined program areas, the size
+        of the program areas, and the area flags (attributes).  
+
+
+        1.9  OBJECT FILE 
+
+
+           The  object  file is an ascii file containing the information
+        needed by the linker to bind multiple object modules into a com-
+        plete  loadable  memory  image.   The object module contains the
+        following designators:  
+
+                [XDQ][HL]
+                        X       Hexidecimal radix
+                        D       Decimal radix
+                        Q       Octal radix
+        
+                        H       Most significant byte first
+                        L       Least significant byte first
+        
+                H       Header 
+                M       Module
+                A       Area
+                S       Symbol
+                T       Object code
+                R       Relocation information
+                P       Paging information
+
+           Refer to the linker for a detailed description of each of the
+        designators and the format of the information contained  in  the
+        object file.  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                    CHAPTER 2
+
+                                   THE LINKER
+
+
+
+
+
+        2.1  ASLINK RELOCATING LINKER 
+
+
+           ASLINK is the companion linker for the ASxxxx assemblers.  
+
+           The  program ASLINK is a general relocating linker performing
+        the following functions:  
+
+             1.  Bind multiple object modules into a single memory image 
+
+             2.  Resolve inter-module symbol references 
+
+             3.  Combine  code  belonging to the same area from multiple
+                 object files into a single contiguous memory region 
+
+             4.  Search and import object module libraries for undefined
+                 global variables 
+
+             5.  Perform   byte   and   word  program  counter  relative
+                 (pc or pcr) addressing calculations 
+
+             6.  Define absolute symbol values at link time 
+
+             7.  Define absolute area base address values at link time 
+
+             8.  Produce Intel Hex or Motorola S19 output file 
+
+             9.  Produce a map of the linked memory image 
+
+            10.  Produce  an updated listing file with the relocated ad-
+                 dresses and data 
+
+
+
+
+
+        THE LINKER                                              PAGE 2-2
+        INVOKING ASLINK
+
+
+        2.2  INVOKING ASLINK 
+
+
+           The  linker  may run in the command line mode or command file
+        modes.  The allowed startup linker commands are:  
+
+        -c/-f           command line / command file modes 
+
+        -p/-n           enable/disable echo file.lnk input to stdout 
+
+           If  command  line  mode is selected, all linker commands come
+        from stdin, if the command file mode is  selected  the  commands
+        are input from the specified file (extension must be .lnk).  
+
+           Most  sytems require the initial options to be entered on the
+           command line:  
+
+                ASLINK -[cfpn] 
+
+           Some  systems  may  request the arguments after the linker is
+           started at a system specific prompt:  
+
+                ASLINK 
+                argv:  -[cfpn] 
+
+        After invoking the linker the valid options are:  
+
+             1.  -i/-s   Intel Hex (file.ihx) or Motorola S19 (file.s19)
+                 image output file.  
+
+             2.  -z      Specifies that symbol names are case sensitive. 
+
+             3.  -m      Generate a map file (file.map).  This file con-
+                 tains a list of the symbols (by area) with absolute ad-
+                 dresses,  sizes  of  linked  areas,  and  other linking
+                 information.  
+
+             4.  -w      Specifies  that  a  wide listing format be used
+                 for the map file.  
+
+             5.  -xdq    Specifies  the  number  radix  for the map file
+                 (Hexidecimal, Decimal, or Octal).  
+
+             6.  -u      Generate  an  updated  listing  file (file.rst)
+                 derived from the relocated addresses and data from  the
+                 linker 
+
+             7.  fileN   Files  to  be linked.  Files may be on the same
+                 line as the above options or on a separate line(s)  one
+                 file  per line or multiple files separated by spaces or
+                 tabs.  
+
+
+
+        THE LINKER                                              PAGE 2-3
+        INVOKING ASLINK
+
+
+             8.  -b  area = expression (one definition per line) 
+                 This  specifies  an area base address where the expres-
+                 sion may contain constants and/or defined symbols  from
+                 the linked files.  
+
+             9.  -g  symbol = expression (one definition per line) 
+                 This  specifies  the value for the symbol where the ex-
+                 pression may contain constants and/or  defined  symbols
+                 from the linked files.  
+
+            10.  -k  library directory path 
+                 (one  definition  per line) This specifies one possible
+                 path to an object library.  More than one path  is  al-
+                 lowed.  
+
+            11.  -l  library file specification 
+                 (one  definition  per  line)  This specifies a possible
+                 library file.  More than one file is allowed.  
+
+            12.  -e      or null line, terminates input to the linker.  
+
+
+
+        2.3  LIBRARY PATH(S) AND FILE(S) 
+
+
+           The process of resolving undefined symbols after scanning the
+        input object  files  includes  the  scanning  of  object  module
+        libraries.   The  linker will search through all combinations of
+        the library path specifications (input by the -k option) and the
+        library  file  specifications (input by the -l option) that lead
+        to an existing library file.  Each library file contains a  list
+        (one  file  per  line)  of  modules  included in this particular
+        library.  Each existing object module is scanned for a match  to
+        the undefined symbol.  The first module containing the symbol is
+        then linked with the previous modules to resolve the symbol  de-
+        finition.   The  library  object  modules are rescanned until no
+        more symbols can be resolved.   The  scanning  algorithm  allows
+        resolution  of  back references.  No errors are reported for non
+        existant library files or object modules.  
+
+           The  library  file  specification may be formed in one of two
+        ways:  
+
+             1.  If  the  library  file  contained an absolute path/file
+                 specification  then  this  is   the   object   module's
+                 path/file.  
+                 (i.e.  C:\...) 
+
+             2.  If  the  library  file  contains  a  relative path/file
+                 specification then the concatenation of  the  path  and
+
+
+        THE LINKER                                              PAGE 2-4
+        LIBRARY PATH(S) AND FILE(S)
+
+
+                 this  file  specification  becomes  the object module's
+                 path/file.  
+                 (i.e.  \...) 
+
+
+           As  an example, assume there exists a library file termio.lib
+        in the syslib directory specifying the following object modules: 
+
+        \6809\io_disk        first object module 
+        d:\special\io_comm   second object module 
+
+        and the following parameters were specified to the linker:  
+
+        -k c:\iosystem\    the first path 
+        -k c:\syslib\      the second path 
+
+        -l termio          the first library file 
+        -l io              the second library file (no such file) 
+
+        The  linker  will attempt to use the following object modules to
+        resolve any undefined symbols:  
+
+        c:\syslib\6809\io_disk.rel     (concatenated path/file) 
+        d:\special\io_comm.rel         (absolute path/file) 
+
+        all  other path(s)/file(s) don't exist.  (No errors are reported
+        for non existant path(s)/file(s).) 
+
+
+        2.4  ASLINK PROCESSING 
+
+
+           The  linker  processes  the  files  in  the  order  they  are
+        presented.  The first pass through the input files  is  used  to
+        define  all  program  areas, the section area sizes, and symbols
+        defined or referenced.  Undefined symbols will initiate a search
+        of any specified library file(s) and the importing of the module
+        containing the symbol definition.  After the first pass  the  -b
+        (area  base  address) definitions, if any, are processed and the
+        areas linked.  
+
+           The  area  linking proceeds by first examining the area types
+        ABS, CON, REL, OVR and PAG.  Absolute areas (ABS) from  separate
+        object modules are always overlayed and have been assembled at a
+        specific address, these are not normally relocated (if a -b com-
+        mand  is  used  on an absolute area the area will be relocated).
+        Relative areas (normally defined as REL|CON) have a base address
+        of  0x0000  as read from the object files, the -b command speci-
+        fies the beginning address of the area.  All subsequent relative
+        areas  will  be  concatenated  with  proceeding  relative areas.
+        Where specific ordering is desired, the first linker input  file
+        should  have  the area definitions in the desired order.  At the
+
+
+        THE LINKER                                              PAGE 2-5
+        ASLINK PROCESSING
+
+
+        completion of the area linking all area  addresses  and  lengths
+        have  been determined.  The areas of type PAG are verified to be
+        on a 256 byte boundary and that the length does not  exceed  256
+        bytes.  Any errors are noted on stderr and in the map file.  
+
+           Next  the  global symbol definitions (-g option), if any, are
+        processed.  The symbol definitions have been delayed until  this
+        point because the absolute addresses of all internal symbols are
+        known and can be used in the expression calculations.  
+
+           Before  continuing  with the linking process the symbol table
+        is scanned to determine if any symbols have been referenced  but
+        not defined.  Undefined symbols are listed on the stderr device.
+        if a .module directive was included in the  assembled  file  the
+        module  making  the reference to this undefined variable will be
+        printed.  
+
+           Constants  defined  as global in more than one module will be
+        flagged as multiple definitions if their values are not  identi-
+        cal.  
+
+           After  the  preceeding  processes are complete the linker may
+        output a map file (-m option).  This file provides the following
+        information:  
+
+             1.  Global symbol values and label absolute addresses 
+
+             2.  Defined areas and there lengths 
+
+             3.  Remaining undefined symbols 
+
+             4.  List of modules linked 
+
+             5.  List of library modules linked 
+
+             6.  List of -b and -g definitions 
+
+
+
+
+           The final step of the linking process is performed during the
+        second pass of the input files.  As the xxx.rel files  are  read
+        the code is relocated by substituting the physical addresses for
+        the referenced symbols and areas and may be output in  Intel  or
+        Motorola  formats.   The  number of files linked and symbols de-
+        fined/referenced is limited by the processor space available  to
+        build the area/symbol lists.  If the -u option is specified then
+        the listing files  (file.lst)  associated  with  the  relocation
+        files  (file.rel)  are  scanned  and  used  to create a new file
+        (file.rst) which has all addresses and data relocated  to  their
+        final values.  
+
+
+
+        THE LINKER                                              PAGE 2-6
+        LINKER INPUT FORMAT
+
+
+        2.5  LINKER INPUT FORMAT 
+
+
+           The  linkers'  input  object file is an ascii file containing
+        the information needed by the linker  to  bind  multiple  object
+        modules into a complete loadable memory image.  
+
+        The object module contains the following designators:  
+
+                [XDQ][HL]
+                        X       Hexidecimal radix
+                        D       Decimal radix
+                        Q       Octal radix
+        
+                        H       Most significant byte first
+                        L       Least significant byte first
+        
+                H       Header 
+                M       Module
+                A       Area
+                S       Symbol
+                T       Object code
+                R       Relocation information
+                P       Paging information
+
+
+        2.5.1  Object Module Format 
+
+
+           The  first  line  of  an object module contains the [XDQ][HL]
+        format specifier (i.e.  XH indicates  a  hexidecimal  file  with
+        most significant byte first) for the following designators.  
+
+
+        2.5.2  Header Line 
+
+                H aa areas gg global symbols 
+
+           The  header  line  specifies  the number of areas(aa) and the
+        number of global symbols(gg) defined or referenced in  this  ob-
+        ject module segment.  
+
+
+
+
+        THE LINKER                                              PAGE 2-7
+        LINKER INPUT FORMAT
+
+
+        2.5.3  Module Line 
+
+                M name 
+
+           The  module  line  specifies  the module name from which this
+        header segment was assembled.  The module line will  not  appear
+        if the .module directive was not used in the source program.  
+
+
+        2.5.4  Symbol Line 
+
+                S string Defnnnn 
+
+                        or 
+
+                S string Refnnnn 
+
+           The  symbol line defines (Def) or references (Ref) the symbol
+        'string' with the value nnnn.  The defined value is relative  to
+        the  current area base address.  References to constants and ex-
+        ternal global symbols will always appear before the  first  area
+        definition.  References to external symbols will have a value of
+        zero.  
+
+
+        2.5.5  Area Line 
+
+                A label size ss flags ff 
+
+           The  area  line  defines the area label, the size (ss) of the
+        area in bytes, and the area flags (ff).  The area flags  specify
+        the ABS, REL, CON, OVR, and PAG parameters:  
+
+                OVR/CON  (0x04/0x00 i.e.  bit position 2) 
+
+                ABS/REL  (0x08/0x00 i.e.  bit position 3) 
+
+                PAG      (0x10 i.e.  bit position 4) 
+
+
+        2.5.6  T Line 
+
+                T xx xx nn nn nn nn nn ...  
+
+           The  T  line contains the assembled code output by the assem-
+        bler with xx xx being the offset address from the  current  area
+        base address and nn being the assembled instructions and data in
+        byte format.  
+
+
+
+
+        THE LINKER                                              PAGE 2-8
+        LINKER INPUT FORMAT
+
+
+        2.5.7  R Line 
+
+                R 0 0 nn nn n1 n2 xx xx ...  
+
+           The R line provides the relocation information to the linker.
+        The nn nn value is the current area index, i.e.  which area  the
+        current  values  were  assembled.  Relocation information is en-
+        coded in groups of 4 bytes:  
+
+             1.  n1  is  the  relocation mode and object format, for the
+                 adhoc extension modes refer to asxxxx.h or aslink.h 
+                 1.  bit 0  word(0x00)/byte(0x01) 
+                 2.  bit 1  relocatable area(0x00)/symbol(0x02) 
+                 3.  bit 2  normal(0x00)/PC relative(0x04) relocation 
+                 4.  bit 3  1-byte(0x00)/2-byte(0x08)  object format for
+                     byte data 
+                 5.  bit 4  signed(0x00)/unsigned(0x10) byte data 
+                 6.  bit 5  normal(0x00)/page '0'(0x20) reference 
+                 7.  bit 6  normal(0x00)/page 'nnn'(0x40) reference 
+                 8.  bit 7  LSB  byte(0x00)/MSB  byte(0x80)  with 2-byte
+                     mode 
+
+             2.  n2  is  a byte index into the corresponding (i.e.  pre-
+                 ceeding) T line data (i.e.  a pointer to the data to be
+                 updated  by  the  relocation).   The T line data may be
+                 1-byte or  2-byte  byte  data  format  or  2-byte  word
+                 format.  
+
+             3.  xx xx  is the area/symbol index for the area/symbol be-
+                 ing referenced.  the corresponding area/symbol is found
+                 in the header area/symbol lists.  
+
+
+        The groups of 4 bytes are repeated for each item requiring relo-
+        cation in the preceeding T line.  
+
+
+        2.5.8  P Line 
+
+                P 0 0 nn nn n1 n2 xx xx 
+
+           The  P  line provides the paging information to the linker as
+        specified by a .setdp directive.  The format of  the  relocation
+        information is identical to that of the R line.  The correspond-
+        ing T line has the following information:  
+                T xx xx aa aa bb bb 
+
+           Where  aa aa is the area reference number which specifies the
+        selected page area and bb bb is the base address  of  the  page.
+        bb bb will require relocation processing if the 'n1 n2 xx xx' is
+        specified in the P line.  The linker will verify that  the  base
+
+
+        THE LINKER                                              PAGE 2-9
+        LINKER INPUT FORMAT
+
+
+        address is on a 256 byte boundary and that the page length of an
+        area defined with the PAG type is not larger than 256 bytes.  
+
+           The  linker  defaults any direct page references to the first
+        area defined in the input REL file.  All ASxxxx assemblers  will
+        specify the _CODE area first, making this the default page area. 
+
+
+        2.6  LINKER ERROR MESSAGES 
+
+
+           The linker provides detailed error messages allowing the pro-
+        grammer to quickly find the errant code.   As  the  linker  com-
+        pletes  pass 1  over  the  input  file(s)  it  reports  any page
+        boundary or page length errors as follows:  
+
+        ?ASlink-Warning-Paged Area PAGE0 Boundary Error
+        
+        and/or
+        
+        ?ASlink-Warning-Paged Area PAGE0 Length Error
+
+        where PAGE0 is the paged area.  
+
+           During  Pass  two the linker reads the T, R, and P lines per-
+        forming the necessary relocations and  outputting  the  absolute
+        code.  Various errors may be reported during this process 
+        The P line processing can produce only one possible error:  
+
+        ?ASlink-Warning-Page Definition Boundary Error
+                 file        module      pgarea      pgoffset
+          PgDef  t6809l      t6809l      PAGE0       0001
+
+        The error message specifies the file and module where the .setdp
+        direct was issued and indicates  the  page  area  and  the  page
+        offset value determined after relocation.  
+
+
+        The R line processing produces various errors:  
+
+        ?ASlink-Warning-Byte PCR relocation error for symbol  bra2
+                 file        module      area        offset
+          Refby  t6809l      t6809l      TEST        00FE
+          Defin  tconst      tconst      .  .ABS.    0080
+
+        ?ASlink-Warning-Unsigned Byte error for symbol  two56
+                 file        module      area        offset
+          Refby  t6800l      t6800l      DIRECT      0015
+          Defin  tconst      tconst      .  .ABS.    0100
+
+
+        THE LINKER                                             PAGE 2-10
+        LINKER ERROR MESSAGES
+
+
+        ?ASlink-Warning-Page0 relocation error for symbol  ltwo56
+                 file        module      area        offset
+          Refby  t6800l      t6800l      DIRECT      000D
+          Defin  tconst      tconst      DIRECT      0100
+
+        ?ASlink-Warning-Page Mode relocation error for symbol  two56
+                 file        module      area        offset
+          Refby  t6809l      t6809l      DIRECT      0005
+          Defin  tconst      tconst      .  .ABS.    0100
+
+        ?ASlink-Warning-Page Mode relocation error
+                 file        module      area        offset
+          Refby  t           Pagetest    PROGRAM     0006
+          Defin  t           Pagetest    DIRECT      0100
+
+        These  error messages specify the file, module, area, and offset
+        within the area of the code  referencing  (Refby)  and  defining
+        (Defin) the symbol.  If the symbol is defined in the same module
+        as the reference the linker is unable to report the symbol name.
+        The  assembler  listing file(s) should be examined at the offset
+        from the specified area to located the offending code.  
+
+           The errors are:  
+
+             1.  The  byte PCR error is caused by exceeding the pc rela-
+                 tive byte branch range.  
+
+             2.  The Unsigned byte error indicates an indexing value was
+                 negative or larger than 255.  
+
+             3.  The  Page0  error is generated if the direct page vari-
+                 able is not in the page0 range of 0 to 255.  
+
+             4.  The page mode error is generated if the direct variable
+                 is not within the current direct page (6809).  
+
+
+
+        THE LINKER                                             Page 2-11
+        INTEL HEX OUTPUT FORMAT
+
+
+        2.7  INTEL HEX OUTPUT FORMAT 
+
+        Record Mark Field    -  This  field  signifies  the  start  of a
+                                record, and consists of an  ascii  colon
+                                (:).  
+
+        Record Length Field  -  This   field   consists   of  two  ascii
+                                characters which indicate the number  of
+                                data   bytes   in   this   record.   The
+                                characters are the result of  converting
+                                the  number  of  bytes  in binary to two
+                                ascii characters, high digit first.   An
+                                End  of  File  record contains two ascii
+                                zeros in this field.  
+
+        Load Address Field   -  This  field  consists  of the four ascii
+                                characters which result from  converting
+                                the  the  binary value of the address in
+                                which to begin loading this record.  The
+                                order is as follows:  
+
+                                    High digit of high byte of address. 
+                                    Low digit of high byte of address.  
+                                    High digit of low byte of address.  
+                                    Low digit of low byte of address.  
+
+                                In an End of File record this field con-
+                                sists of either four ascii zeros or  the
+                                program  entry  address.   Currently the
+                                entry address option is not supported.  
+
+        Record Type Field    -  This  field  identifies the record type,
+                                which is either 0 for data records or  1
+                                for  an End of File record.  It consists
+                                of two ascii characters, with  the  high
+                                digit of the record type first, followed
+                                by the low digit of the record type.  
+
+        Data Field           -  This  field consists of the actual data,
+                                converted to two ascii characters,  high
+                                digit first.  There are no data bytes in
+                                the End of File record.  
+
+        Checksum Field       -  The  checksum  field is the 8 bit binary
+                                sum of the record length field, the load
+                                address  field,  the  record type field,
+                                and the data field.  This  sum  is  then
+                                negated  (2's  complement) and converted
+                                to  two  ascii  characters,  high  digit
+                                first.  
+
+
+        THE LINKER                                             Page 2-12
+        MOTOROLA S1-S9 OUTPUT FORMAT
+
+
+        2.8  MOTORLA S1-S9 OUTPUT FORMAT 
+
+        Record Type Field    -  This  field  signifies  the  start  of a
+                                record and  identifies  the  the  record
+                                type as follows:  
+
+                                    Ascii S1 - Data Record 
+                                    Ascii S9 - End of File Record 
+
+        Record Length Field  -  This  field  specifies the record length
+                                which includes the  address,  data,  and
+                                checksum   fields.   The  8  bit  record
+                                length value is converted to  two  ascii
+                                characters, high digit first.  
+
+        Load Address Field   -  This  field  consists  of the four ascii
+                                characters which result from  converting
+                                the  the  binary value of the address in
+                                which to begin loading this record.  The
+                                order is as follows:  
+
+                                    High digit of high byte of address. 
+                                    Low digit of high byte of address.  
+                                    High digit of low byte of address.  
+                                    Low digit of low byte of address.  
+
+                                In an End of File record this field con-
+                                sists of either four ascii zeros or  the
+                                program  entry  address.   Currently the
+                                entry address option is not supported.  
+
+        Data Field           -  This  field consists of the actual data,
+                                converted to two ascii characters,  high
+                                digit first.  There are no data bytes in
+                                the End of File record.  
+
+        Checksum Field       -  The  checksum  field is the 8 bit binary
+                                sum of the record length field, the load
+                                address field, and the data field.  This
+                                sum is then  complemented  (1's  comple-
+                                ment)   and   converted   to  two  ascii
+                                characters, high digit first.  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                    CHAPTER 3
+
+                           BUILDING ASXXXX AND ASLINK
+
+
+
+
+           The assemblers and linker have been successfully compiled us-
+        ing  the  DECUS C  (PDP-11)  compiler  (patch  level   9)   with
+        RT-11/TSX+,  Eyring  Research  Institute,  Inc.   PDOS (680x0) C
+        V5.4b compiler, and Symantec C/C++ V6.1/V7.2.  
+
+           The  device  specific  header  file  (i.e.  m6800.h, m6801.h,
+        etc.) contains the DECUS C 'BUILD' directives for  generating  a
+        command  file to compile, assemble, and link the necessary files
+        to prepare an executable image for a particular assembler.  
+
+
+        3.1  BUILDING AN ASSEMBLER 
+
+
+           The  building  of  a typical assembler (6809 for example) re-
+        quires the following files:  
+
+             1.  M6809.H 
+             2.  M09EXT.C 
+             3.  M09MCH.C 
+             4.  M09ADR.C 
+             5.  M09PST.C 
+             6.  ASXXXX.H 
+             7.  ASMAIN.C 
+             8.  ASLEX.C 
+             9.  ASSYM.C 
+            10.  ASSUBR.C 
+            11.  ASEXPR.C 
+            12.  ASDATA.C 
+            13.  ASLIST.C 
+            14.  ASOUT.C 
+
+
+           The  first  five  files are the 6809 processor dependent sec-
+        tions which contain the following:  
+
+
+
+
+        BUILDING ASXXXX AND ASLINK                              PAGE 3-2
+        BUILDING AN ASSEMBLER
+
+
+             1.  m6809.h -  header  file containing the machine specific
+                 definitions of constants,  variables,  structures,  and
+                 types 
+
+             2.  m09ext -  device  description, byte order, and file ex-
+                 tension information 
+
+             3.  m09pst -  a  table of the assembler general directives,
+                 special device directives, and assembler mnemonics with
+                 associated operation codes 
+
+             4.  m09mch / m09adr -  machine specific code for processing
+                 the device mnemonics,  addressing  modes,  and  special
+                 directives 
+
+
+           The  remaining nine files provide the device independent sec-
+        tions which handle the  details  of  file  input/output,  symbol
+        table  generation,  program/data areas, expression analysis, and
+        assembler directive processing.  
+
+
+        3.2  BUILDING ASLINK 
+
+
+           The building of the linker requires the following files:  
+
+             1.  ASLINK.H 
+             2.  LKMAIN.C 
+             3.  LKLEX.C 
+             4.  LKAREA.C 
+             5.  LKHEAD.C 
+             6.  LKSYM.C 
+             7.  LKEVAL.C 
+             8.  LKDATA.C 
+             9.  LKLIST.C 
+            10.  LKRLOC.C 
+            11.  LKLIBR.C 
+            12.  LKS19.C 
+            13.  LKIHX.C 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX A
+
+                                AS6800 ASSEMBLER
+
+
+
+
+
+        A.1  6800 REGISTER SET 
+
+        The following is a list of the 6800 registers used by AS6800:  
+
+                a,b     -       8-bit accumulators
+                x       -       index register
+
+
+        A.2  6800 INSTRUCTION SET 
+
+
+           The following tables list all 6800/6802/6808 mnemonics recog-
+        nized by the AS6800 assembler.  The designation [] refers  to  a
+        required addressing mode argument.  The following list specifies
+        the format for each addressing mode supported by AS6800:  
+
+                #data           immediate data
+                                byte or word data
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+                ,x              register indirect addressing
+                                zero offset
+        
+                offset,x        register indirect addressing
+                                0 <= offset <= 255
+        
+                ext             extended addressing
+        
+                label           branch label
+
+        The  terms  data, dir, offset, ext, and label may all be expres-
+        sions.  
+
+
+
+        AS6800 ASSEMBLER                                        PAGE A-2
+        6800 INSTRUCTION SET
+
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 6800 technical data for valid modes.  
+
+
+        A.2.1  Inherent Instructions 
+
+                aba                     cba
+                clc                     cli
+                clv                     daa
+                des                     dex
+                ins                     inx
+                nop                     rti
+                rts                     sba
+                sec                     sei
+                sev                     swi
+                tab                     tap
+                tba                     tpa
+                tsx                     txs
+                wai
+        
+                psha                    pshb
+                psh a                   psh b
+                pula                    pulb
+                pul a                   pul b
+
+
+        A.2.2  Branch Instructions 
+
+                bra     label           bhi     label
+                bls     label           bcc     label
+                bhs     label           bcs     label
+                blo     label           bne     label
+                beq     label           bvc     label
+                bvs     label           bpl     label
+                bmi     label           bge     label
+                blt     label           bgt     label
+                ble     label           bsr     label
+
+
+        AS6800 ASSEMBLER                                        PAGE A-3
+        6800 INSTRUCTION SET
+
+
+        A.2.3  Single Operand Instructions 
+
+                asla                    aslb
+                asl a                   asl b
+                asl     []
+        
+                asra                    asrb
+                asr a                   asr b
+                asr     []
+        
+                clra                    clrb
+                clr a                   clr b
+                clr     []
+        
+                coma                    comb
+                com a                   com b
+                com     []
+        
+                deca                    decb
+                dec a                   dec b
+                dec     []
+        
+                inca                    incb
+                inc a                   inc b
+                inc     []
+        
+                lsla                    lslb
+                lsl a                   lsl b
+                lsl     []
+        
+                lsra                    lsrb
+                lsr a                   lsr b
+                lsr     []
+        
+                nega                    negb
+                neg a                   neg b
+                neg     []
+        
+                rola                    rolb
+                rol a                   rol b
+                rol     []
+        
+                rora                    rorb
+                ror a                   ror b
+                ror     []
+        
+                tsta                    tstb
+                tst a                   tst b
+                tst     []
+
+
+        AS6800 ASSEMBLER                                        PAGE A-4
+        6800 INSTRUCTION SET
+
+
+        A.2.4  Double Operand Instructions 
+
+                adca    []              adcb    []
+                adc a   []              adc b   []
+        
+                adda    []              addb    []
+                add a   []              add b   []
+        
+                anda    []              andb    []
+                and a   []              and b   []
+        
+                bita    []              bitb    []
+                bit a   []              bit b   []
+        
+                cmpa    []              cmpb    []
+                cmp a   []              cmp b   []
+        
+                eora    []              eorb    []
+                eor a   []              eor b   []
+        
+                ldaa    []              ldab    []
+                lda a   []              lda b   []
+        
+                oraa    []              orab    []
+                ora a   []              ora b   []
+        
+                sbca    []              sbcb    []
+                sbc a   []              sbc b   []
+        
+                staa    []              stab    []
+                sta a   []              sta b   []
+        
+                suba    []              subb    []
+                sub a   []              sub b   []
+
+
+        A.2.5  Jump and Jump to Subroutine Instructions 
+
+                jmp     []              jsr     []
+
+
+
+
+        AS6800 ASSEMBLER                                        PAGE A-5
+        6800 INSTRUCTION SET
+
+
+        A.2.6  Long Register Instructions 
+
+                cpx     []
+                lds     []              sts     []
+                ldx     []              stx     []
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX B
+
+                                AS6801 ASSEMBLER
+
+
+
+
+
+        B.1  .hd6303 DIRECTIVE 
+
+        Format:  
+
+                .hd6303 
+
+        The  .hd6303 directive enables processing of the HD6303 specific
+        mnemonics not included in  the  6801  instruction  set.   HD6303
+        mnemonics  encountered  without  the  .hd6303  directive will be
+        flagged with an 'o' error.  
+
+
+        B.2  6801 REGISTER SET 
+
+        The following is a list of the 6801 registers used by AS6801:  
+
+                a,b     -       8-bit accumulators
+                d       -       16-bit accumulator <a:b>
+                x       -       index register
+
+
+        B.3  6801 INSTRUCTION SET 
+
+
+           The  following tables list all 6801/6303 mnemonics recognized
+        by the AS6801 assembler.  The designation []  refers  to  a  re-
+        quired  addressing  mode argument.  The following list specifies
+        the format for each addressing mode supported by AS6801:  
+
+                #data           immediate data
+                                byte or word data
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+
+
+        AS6801 ASSEMBLER                                        PAGE B-2
+        6801 INSTRUCTION SET
+
+
+                ,x              register indirect addressing
+                                zero offset
+        
+                offset,x        register indirect addressing
+                                0 <= offset <= 255
+        
+                ext             extended addressing
+        
+                label           branch label
+
+        The  terms  data, dir, offset, ext, and label may all be expres-
+        sions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to  the  6801/6303  technical  data  for  valid
+        modes.  
+
+
+        B.3.1  Inherent Instructions 
+
+                aba             abx
+                cba             clc
+                cli             clv
+                daa             des
+                dex             ins
+                inx             mul
+                nop             rti
+                rts             sba
+                sec             sei
+                sev             swi
+                tab             tap
+                tba             tpa
+                tsx             txs
+                wai
+
+
+        B.3.2  Branch Instructions 
+
+                bra     label           brn     label
+                bhi     label           bls     label
+                bcc     label           bhs     label
+                bcs     label           blo     label
+                bne     label           beq     label
+                bvc     label           bvs     label
+                bpl     label           bmi     label
+                bge     label           blt     label
+                bgt     label           ble     label
+                bsr     label
+
+
+        AS6801 ASSEMBLER                                        PAGE B-3
+        6801 INSTRUCTION SET
+
+
+        B.3.3  Single Operand Instructions 
+
+                asla            aslb            asld
+                asl a           asl b           asl d
+                asl     []
+        
+                asra            asrb
+                asr a           asr b
+                asr     []
+        
+                clra            clrb
+                clr a           clr b
+                clr     []
+        
+                coma            comb
+                com a           com b
+                com     []
+        
+                deca            decb
+                dec a           dec b
+                dec     []
+        
+                eora            eorb
+                eor a           eor b
+                eor     []
+        
+                inca            incb
+                inc a           inc b
+                inc     []
+        
+                lsla            lslb            lsld
+                lsl a           lsl b           lsl d
+                lsl     []
+        
+                lsra            lsrb            lsrd
+                lsr a           lsr b           lsr d
+                lsr     []
+        
+                nega            negb
+                neg a           neg b
+                neg     []
+        
+                psha            pshb            pshx
+                psh a           psh b           psh x
+        
+                pula            pulb            pulx
+                pul a           pul b           pul x
+        
+                rola            rolb
+                rol a           rol b
+                rol     []
+        
+
+
+        AS6801 ASSEMBLER                                        PAGE B-4
+        6801 INSTRUCTION SET
+
+
+                rora            rorb
+                ror a           ror b
+                ror     []
+        
+                tsta            tstb
+                tst a           tst b
+                tst     []
+
+
+        B.3.4  Double Operand Instructions 
+
+                adca    []      adcb    []
+                adc a   []      adc b   []
+        
+                adda    []      addb    []      addd    []
+                add a   []      add b   []      add d   []
+        
+                anda    []      andb    []
+                and a   []      and b   []
+        
+                bita    []      bitb    []
+                bit a   []      bit b   []
+        
+                cmpa    []      cmpb    []
+                cmp a   []      cmp b   []
+        
+                ldaa    []      ldab    []
+                lda a   []      lda b   []
+        
+                oraa    []      orab    []
+                ora a   []      ora b   []
+        
+                sbca    []      sbcb    []
+                sbc a   []      sbc b   []
+        
+                staa    []      stab    []
+                sta a   []      sta b   []
+        
+                suba    []      subb    []      subd    []
+                sub a   []      sub b   []      sub d   []
+
+
+
+
+        AS6801 ASSEMBLER                                        PAGE B-5
+        6801 INSTRUCTION SET
+
+
+        B.3.5  Jump and Jump to Subroutine Instructions 
+
+                jmp     []      jsr     []
+
+
+        B.3.6  Long Register Instructions 
+
+                cpx     []      ldd     []
+                lds     []      ldx     []
+                std     []      sts     []
+                stx     []
+
+
+        B.3.7  6303 Specific Instructions 
+
+                aim     #data, []       eim     #data, []
+                oim     #data, []       tim     #data, []
+        
+                xgdx            slp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX C
+
+                                AS6804 ASSEMBLER
+
+
+
+
+           Requires the .setdp directive to specify the ram area.  
+
+
+        C.1  6804 REGISTER SET 
+
+        The following is a list of the 6804 registers used by AS6804:  
+
+                x,y     -       index registers
+
+
+        C.2  6804 INSTRUCTION SET 
+
+
+           The  following  tables  list all 6804 mnemonics recognized by
+        the AS6804 assembler.  The designation [] refers to  a  required
+        addressing  mode  argument.   The  following  list specifies the
+        format for each addressing mode supported by AS6804:  
+
+                #data           immediate data
+                                byte or word data
+        
+                ,x              register indirect addressing
+        
+                dir             direct addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255
+        
+                ext             extended addressing
+        
+                label           branch label
+
+        The  terms data, dir, and ext may be expressions.  The label for
+        the short branchs beq, bne, bcc, and bcs must not be external.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 6804 technical data for valid modes.  
+
+
+        AS6804 ASSEMBLER                                        PAGE C-2
+        6804 INSTRUCTION SET
+
+
+        C.2.1  Inherent Instructions 
+
+                coma            decx
+                decy            incx
+                incy            rola
+                rti             rts
+                stop            tax
+                tay             txa
+                tya             wait
+
+
+        C.2.2  Branch Instructions 
+
+                bne     label           beq     label
+                bcc     label           bcs     label
+
+
+        C.2.3  Single Operand Instructions 
+
+                add     []
+                and     []
+                cmp     []
+                dec     []
+                inc     []
+                lda     []
+                sta     []
+                sub     []
+
+
+        C.2.4  Jump and Jump to Subroutine Instructions 
+
+                jsr     []
+                jmp     []
+
+
+        C.2.5  Bit Test Instructions 
+
+                brclr   #data,[],label
+                brset   #data,[],label
+        
+                bclr    #label,[]
+                bset    #label,[]
+
+
+
+
+        AS6804 ASSEMBLER                                        PAGE C-3
+        6804 INSTRUCTION SET
+
+
+        C.2.6  Load Immediate data Instruction 
+
+                mvi     [],#data
+
+
+        C.2.7  6804 Derived Instructions 
+
+                asla
+                bam     label
+                bap     label
+                bxmi    label
+                bxpl    label
+                bymi    label
+                bypl    label
+                clra
+                clrx
+                clry
+                deca
+                decx
+                decy
+                inca
+                incx
+                incy
+                ldxi    #data
+                ldyi    #data
+                nop
+                tax
+                tay
+                txa
+                tya
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX D
+
+                                AS6805 ASSEMBLER
+
+
+
+
+
+        D.1  6805 REGISTER SET 
+
+        The following is a list of the 6805 registers used by AS6805:  
+
+                a       -       8-bit accumulator
+                x       -       index register
+
+
+        D.2  6805 INSTRUCTION SET 
+
+
+           The  following  tables  list all 6805 mnemonics recognized by
+        the AS6805 assembler.  The designation [] refers to  a  required
+        addressing  mode  argument.   The  following  list specifies the
+        format for each addressing mode supported by AS6805:  
+
+                #data           immediate data
+                                byte or word data
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+                ,x              register indirect addressing
+                                zero offset
+        
+                offset,x        register indirect addressing
+                                  0 <= offset <= 255   --- byte mode
+                                256 <= offset <= 65535 --- word mode
+                                (an externally defined offset uses the
+                                 word mode)
+        
+                ext             extended addressing
+        
+                label           branch label
+
+
+
+        AS6805 ASSEMBLER                                        PAGE D-2
+        6805 INSTRUCTION SET
+
+
+        The terms data, dir, offset, and ext may all be expressions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 6805 technical data for valid modes.  
+
+
+        D.2.1  Control Instructions 
+
+                clc             cli
+                nop             rsp
+                rti             rts
+                sec             sei
+                stop            swi
+                tax             txa
+                wait
+
+
+        D.2.2  Bit Manipulation Instructions 
+
+                brset   #data,*dir,label
+                brclr   #data,*dir,label
+        
+                bset    #data,*dir
+                bclr    #data,*dir
+
+
+        D.2.3  Branch Instructions 
+
+                bra     label           brn     label
+                bhi     label           bls     label
+                bcc     label           bcs     label
+                bne     label           beq     label
+                bhcc    label           bhcs    label
+                bpl     label           bmi     label
+                bmc     label           bms     label
+                bil     label           bih     label
+                bsr     label
+
+
+        AS6805 ASSEMBLER                                        PAGE D-3
+        6805 INSTRUCTION SET
+
+
+        D.2.4  Read-Modify-Write Instructions 
+
+                nega            negx
+                neg     []
+        
+                coma            comx
+                com     []
+        
+                lsra            lsrx
+                lsr     []
+        
+                rora            rorx
+                ror     []
+        
+                asra            asrx
+                asr     []
+        
+                lsla            lslx
+                lsl     []
+        
+                rola            rolx
+                rol     []
+        
+                deca            decx
+                dec     []
+        
+                inca            incx
+                inc     []
+        
+                tsta            tstx
+                tst     []
+        
+                clra            clrx
+                clr     []
+
+
+        D.2.5  Register\Memory Instructions 
+
+                sub     []              cmp     []
+                sbc     []              cpx     []
+                and     []              bit     []
+                lda     []              sta     []
+                eor     []              adc     []
+                ora     []              add     []
+                ldx     []              stx     []
+
+
+        AS6805 ASSEMBLER                                        PAGE D-4
+        6805 INSTRUCTION SET
+
+
+        D.2.6  Jump and Jump to Subroutine Instructions 
+
+                jmp     []              jsr     []
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX E
+
+                                AS6808 ASSEMBLER
+
+
+
+
+
+        E.1  68HC08 REGISTER SET 
+
+        The  following  is  a  list  of  the  68HC08  registers  used by
+        AS68HC08:  
+
+                a       -       8-bit accumulator
+                x       -       index register  <H:X>
+                s       -       stack pointer
+
+
+        E.2  68HC08 INSTRUCTION SET 
+
+
+           The  following tables list all 68HC08 mnemonics recognized by
+        the AS6808 assembler.  The designation [] refers to  a  required
+        addressing  mode  argument.   The  following  list specifies the
+        format for each addressing mode supported by AS6808:  
+
+                #data           immediate data
+                                byte or word data
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+                ,x              register indexed addressing
+                                zero offset
+        
+                offset,x        register indexed addressing
+                                  0 <= offset <= 255   --- byte mode
+                                256 <= offset <= 65535 --- word mode
+                                (an externally defined offset uses the
+                                 word mode)
+        
+                ,x+             register indexed addressing
+                                zero offset with post increment
+
+
+        AS6808 ASSEMBLER                                        PAGE E-2
+        68HC08 INSTRUCTION SET
+
+
+        
+                offset,x+       register indexed addressing
+                                unsigned byte offset with post increment
+        
+                offset,s        stack pointer indexed addressing
+                                  0 <= offset <= 255   --- byte mode
+                                256 <= offset <= 65535 --- word mode
+                                (an externally defined offset uses the
+                                 word mode)
+        
+                ext             extended addressing
+        
+                label           branch label
+
+        The terms data, dir, offset, and ext may all be expressions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 68HC08 technical data for valid modes.  
+
+
+        E.2.1  Control Instructions 
+
+                clc             cli             daa             div
+                mul             nop             nsa             psha
+                pshh            pshx            pula            pulh
+                pulx            rsp             rti             rts
+                sec             sei             stop            swi
+                tap             tax             tpa             tsx
+                txa             txs             wait
+
+
+        E.2.2  Bit Manipulation Instructions 
+
+                brset   #data,*dir,label
+                brclr   #data,*dir,label
+        
+                bset    #data,*dir
+                bclr    #data,*dir
+
+
+        AS6808 ASSEMBLER                                        PAGE E-3
+        68HC08 INSTRUCTION SET
+
+
+        E.2.3  Branch Instructions 
+
+                bra     label           brn     label
+                bhi     label           bls     label
+                bcc     label           bcs     label
+                bne     label           beq     label
+                bhcc    label           bhcs    label
+                bpl     label           bmi     label
+                bmc     label           bms     label
+                bil     label           bih     label
+                bsr     label           bge     label
+                blt     label           bgt     label
+                ble     label
+
+
+        E.2.4  Complex Branch Instructions 
+
+                cbeqa   [],label
+                cbeqx   [],label
+                cbeq    [],label
+                dbnza   label
+                dbnzx   label
+                dbnz    [],label
+
+
+        AS6808 ASSEMBLER                                        PAGE E-4
+        68HC08 INSTRUCTION SET
+
+
+        E.2.5  Read-Modify-Write Instructions 
+
+                nega                    negx
+                neg     []
+        
+                coma                    comx
+                com     []
+        
+                lsra                    lsrx
+                lsr     []
+        
+                rora                    rorx
+                ror     []
+        
+                asra                    asrx
+                asr     []
+        
+                asla                    aslx
+                asl     []
+        
+                lsla                    lslx
+                lsl     []
+        
+                rola                    rolx
+                rol     []
+        
+                deca                    decx
+                dec     []
+        
+                inca                    incx
+                inc     []
+        
+                tsta                    tstx
+                tst     []
+        
+                clra                    clrx
+                clr     []              clrh
+        
+                aix     #data
+        
+                ais     #data
+
+
+        AS6808 ASSEMBLER                                        PAGE E-5
+        68HC08 INSTRUCTION SET
+
+
+        E.2.6  Register\Memory Instructions 
+
+                sub     []              cmp     []
+                sbc     []              cpx     []
+                and     []              bit     []
+                lda     []              sta     []
+                eor     []              adc     []
+                ora     []              add     []
+                ldx     []              stx     []
+
+
+        E.2.7  Double Operand Move Instruction 
+
+                mov     [],[]
+
+
+        E.2.8  16-Bit <H:X> Index Register Instructions 
+
+                cphx    []
+                ldhx    []
+                sthx    []
+
+
+        E.2.9  Jump and Jump to Subroutine Instructions 
+
+                jmp     []              jsr     []
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX F
+
+                                AS6809 ASSEMBLER
+
+
+
+
+
+        F.1  6809 REGISTER SET 
+
+        The following is a list of the 6809 registers used by AS6809:  
+
+                a,b     -       8-bit accumulators
+                d       -       16-bit accumulator <a:b>
+                x,y     -       index registers
+                s,u     -       stack pointers
+                pc      -       program counter
+                cc      -       condition code
+                dp      -       direct page
+
+
+        F.2  6809 INSTRUCTION SET 
+
+
+           The  following  tables  list all 6809 mnemonics recognized by
+        the AS6809 assembler.  The designation [] refers to  a  required
+        addressing  mode  argument.   The  following  list specifies the
+        format for each addressing mode supported by AS6809:  
+
+                #data           immediate data
+                                byte or word data
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+                label           branch label
+        
+                r,r1,r2         registers
+                                cc,a,b,d,dp,x,y,s,u,pc
+        
+                ,-x     ,--x    register indexed
+                                autodecrement
+        
+
+
+        AS6809 ASSEMBLER                                        PAGE F-2
+        6809 INSTRUCTION SET
+
+
+                ,x+     ,x++    register indexed
+                                autoincrement
+        
+                ,x              register indexed addressing
+                                zero offset
+        
+                offset,x        register indexed addressing
+                                   -16 <= offset <= 15    ---  5-bit
+                                  -128 <= offset <= -17   ---  8-bit
+                                    16 <= offset <= 127   ---  8-bit
+                                -32768 <= offset <= -129  --- 16-bit
+                                   128 <= offset <= 32767 --- 16-bit
+                                (external definition of offset
+                                 uses 16-bit mode)
+        
+                a,x             accumulator offset indexed addressing
+        
+                ext             extended addressing
+        
+                ext,pc          pc addressing ( pc <- pc + ext )
+        
+                ext,pcr         pc relative addressing
+                                
+                [,--x]          register indexed indirect
+                                autodecrement
+        
+                [,x++]          register indexed indirect
+                                autoincrement
+        
+                [,x]            register indexed indirect addressing
+                                zero offset
+        
+                [offset,x]      register indexed indirect addressing
+                                  -128 <= offset <= 127   ---  8-bit
+                                -32768 <= offset <= -129  --- 16-bit
+                                   128 <= offset <= 32767 --- 16-bit
+                                (external definition of offset
+                                 uses 16-bit mode)
+        
+                [a,x]           accumulator offset indexed
+                                indirect addressing
+        
+                [ext]           extended indirect addressing
+        
+                [ext,pc]        pc indirect addressing
+                                ( [pc <- pc + ext] )
+        
+                [ext,pcr]       pc relative indirect addressing
+
+        The  terms  data, dir, label, offset, and ext may all be expres-
+        sions.  
+
+
+
+        AS6809 ASSEMBLER                                        PAGE F-3
+        6809 INSTRUCTION SET
+
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 6809 technical data for valid modes.  
+
+
+        F.2.1  Inherent Instructions 
+
+                abx             daa
+                mul             nop
+                rti             rts
+                sex             swi
+                swi1            swi2
+                swi3            sync
+
+
+        F.2.2  Short Branch Instructions 
+
+                bcc     label           bcs     label
+                beq     label           bge     label
+                bgt     label           bhi     label
+                bhis    label           bhs     label
+                ble     label           blo     label
+                blos    label           bls     label
+                blt     label           bmi     label
+                bne     label           bpl     label
+                bra     label           brn     label
+                bvc     label           bvs     label
+                bsr     label
+
+
+        F.2.3  Long Branch Instructions 
+
+                lbcc    label           lbcs    label
+                lbeq    label           lbge    label
+                lbgt    label           lbhi    label
+                lbhis   label           lbhs    label
+                lble    label           lblo    label
+                lblos   label           lbls    label
+                lblt    label           lbmi    label
+                lbne    label           lbpl    label
+                lbra    label           lbrn    label
+                lbvc    label           lbvs    label
+                lbsr    label
+
+
+        AS6809 ASSEMBLER                                        PAGE F-4
+        6809 INSTRUCTION SET
+
+
+        F.2.4  Single Operand Instructions 
+
+                asla            aslb
+                asl     []
+        
+                asra            asrb
+                asr     []
+        
+                clra            clrb
+                clr     []
+        
+                coma            comb
+                com     []
+        
+                deca            decb
+                dec     []
+        
+                inca            incb
+                inc     []
+        
+                lsla            lslb
+                lsl     []
+        
+                lsra            lsrb
+                lsr     []
+        
+                nega            negb
+                neg     []
+        
+                rola            rolb
+                rol     []
+        
+                rora            rorb
+                ror     []
+        
+                tsta            tstb
+                tst     []
+
+
+        AS6809 ASSEMBLER                                        PAGE F-5
+        6809 INSTRUCTION SET
+
+
+        F.2.5  Double Operand Instructions 
+
+                adca    []              adcb    []
+        
+                adda    []              addb    []
+        
+                anda    []              andb    []
+        
+                bita    []              bitb    []
+        
+                cmpa    []              cmpb    []
+        
+                eora    []              eorb    []
+        
+                lda     []              ldb     []
+        
+                ora     []              orb     []
+        
+                sbca    []              sbcb    []
+        
+                sta     []              stb     []
+        
+                suba    []              subb    []
+
+
+        F.2.6  D-register Instructions 
+
+                addd    []              subd    []
+                cmpd    []              ldd     []
+                std     []
+
+
+        F.2.7  Index/Stack Register Instructions 
+
+                cmps    []              cmpu    []
+                cmpx    []              cmpy    []
+        
+                lds     []              ldu     []
+                ldx     []              ldy     []
+        
+                leas    []              leau    []
+                leax    []              leay    []
+        
+                sts     []              stu     []
+                stx     []              sty     []
+        
+                pshs    r               pshu    r
+                puls    r               pulu    r
+
+
+        AS6809 ASSEMBLER                                        PAGE F-6
+        6809 INSTRUCTION SET
+
+
+        F.2.8  Jump and Jump to Subroutine Instructions 
+
+                jmp     []              jsr     []
+
+
+        F.2.9  Register - Register Instructions 
+
+                exg     r1,r2           tfr     r1,r2
+
+
+        F.2.10  Condition Code Register Instructions 
+
+                andcc   #data           orcc    #data
+                cwai    #data
+
+
+        F.2.11  6800 Compatibility Instructions 
+
+                aba             cba
+                clc             cli
+                clv             des
+                dex             ins
+                inx
+                ldaa    []      ldab    []
+                oraa    []      orab    []
+                psha            pshb
+                pula            pulb
+                sba             sec
+                sei             sev
+                staa    []      stab    []
+                tab             tap
+                tba             tpa
+                tsx             txs
+                wai
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX G
+
+                                AS6811 ASSEMBLER
+
+
+
+
+
+        G.1  68HC11 REGISTER SET 
+
+        The following is a list of the 68HC11 registers used by AS6811: 
+
+                a,b     -       8-bit accumulators
+                d       -       16-bit accumulator <a:b>
+                x,y     -       index registers
+
+
+        G.2  68HC11 INSTRUCTION SET 
+
+
+           The  following tables list all 68HC11 mnemonics recognized by
+        the AS6811 assembler.  The designation [] refers to  a  required
+        addressing  mode  argument.   The  following  list specifies the
+        format for each addressing mode supported by AS6811:  
+
+                #data           immediate data
+                                byte or word data
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+                ,x              register indirect addressing
+                                zero offset
+        
+                offset,x        register indirect addressing
+                                0 <= offset <= 255
+        
+                ext             extended addressing
+        
+                label           branch label
+
+        The terms data, dir, offset, and ext may all be expressions.  
+
+
+
+        AS6811 ASSEMBLER                                        PAGE G-2
+        68HC11 INSTRUCTION SET
+
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 68HC11 technical data for valid modes.  
+
+
+        G.2.1  Inherent Instructions 
+
+                aba             abx
+                aby             cba
+                clc             cli
+                clv             daa
+                des             dex
+                dey             fdiv
+                idiv            ins
+                inx             iny
+                mul             nop
+                rti             rts
+                sba             sec
+                sei             sev
+                stop            swi
+                tab             tap
+                tba             tpa
+                tsx             txs
+                wai             xgdx
+                xgdy
+        
+                psha            pshb
+                psh a           psh b
+                pshx            pshy
+                psh x           psh y
+        
+                pula            pulb
+                pul a           pul b
+                pulx            puly
+                pul x           pul y
+
+
+        G.2.2  Branch Instructions 
+
+                bra     label           brn     label
+                bhi     label           bls     label
+                bcc     label           bhs     label
+                bcs     label           blo     label
+                bne     label           beq     label
+                bvc     label           bvs     label
+                bpl     label           bmi     label
+                bge     label           blt     label
+                bgt     label           ble     label
+                bsr     label
+
+
+        AS6811 ASSEMBLER                                        PAGE G-3
+        68HC11 INSTRUCTION SET
+
+
+        G.2.3  Single Operand Instructions 
+
+                asla            aslb            asld
+                asl a           asl b           asl d
+                asl     []
+        
+                asra            asrb
+                asr a           asr b
+                asr     []
+        
+                clra            clrb
+                clr a           clr b
+                clr     label
+        
+                coma            comb
+                com a           com b
+                com     []
+        
+                deca            decb
+                dec a           dec b
+                dec     []
+        
+                inca            incb
+                inc a           inc b
+                inc     []
+        
+                lsla            lslb            lsld
+                lsl a           lsl b           lsl d
+                lsl     []
+        
+                lsra            lsrb            lsrd
+                lsr a           lsr b           lsr d
+                lsr     []
+        
+                nega            negb
+                neg a           neg b
+                neg     []
+        
+                rola            rolb
+                rol a           rol b
+                rol     []
+        
+                rora            rorb
+                ror a           ror b
+                ror     []
+        
+                tsta            tstb
+                tst a           tst b
+                tst     []
+
+
+        AS6811 ASSEMBLER                                        PAGE G-4
+        68HC11 INSTRUCTION SET
+
+
+        G.2.4  Double Operand Instructions 
+
+                adca    []              adcb    []
+                adc a   []              adc b   []
+        
+                adda    []      addb    []      addd    []
+                add a   []      add b   []      add d   []
+        
+                anda    []              andb    []
+                and a   []              and b   []
+        
+                bita    []              bitb    []
+                bit a   []              bit b   []
+        
+                cmpa    []              cmpb    []
+                cmp a   []              cmp b   []
+        
+                eora    []              eorb    []
+                eor a   []              eor b   []
+        
+                ldaa    []              ldab    []
+                lda a   []              lda b   []
+        
+                oraa    []              orab    []
+                ora a   []              ora b   []
+        
+                sbca    []              sbcb    []
+                sbc a   []              sbc b   []
+        
+                staa    []              stab    []
+                sta a   []              sta b   []
+        
+                suba    []      subb    []      subd    []
+                sub a   []      sub b   []      sub d   []
+
+
+        G.2.5  Bit Manupulation Instructions 
+
+                bclr    [],#data
+                bset    [],#data
+        
+                brclr   [],#data,label
+                brset   [],#data,label
+
+
+
+
+        AS6811 ASSEMBLER                                        PAGE G-5
+        68HC11 INSTRUCTION SET
+
+
+        G.2.6  Jump and Jump to Subroutine Instructions 
+
+                jmp     []              jsr     []
+
+
+        G.2.7  Long Register Instructions 
+
+                cpx     []              cpy     []
+        
+                ldd     []              lds     []
+                ldx     []              ldy     []
+        
+                std     []              sts     []
+                stx     []              sty     []
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX H
+
+                                AS6812 ASSEMBLER
+
+
+
+
+
+        H.1  68HC12 REGISTER SET 
+
+        The following is a list of the 68HC12 registers used by AS6812: 
+
+                a,b     -       8-bit accumulators
+                d       -       16-bit accumulator <a:b>
+                x,y     -       index registers
+                sp,s    -       stack pointer
+                pc      -       program counter
+                ccr,cc  -       condition code register
+
+
+        H.2  68HC12 INSTRUCTION SET 
+
+
+           The  following tables list all 68HC12 mnemonics recognized by
+        the AS6812 assembler.  The designation [] refers to  a  required
+        addressing  mode  argument.   The  following  list specifies the
+        format for each addressing mode supported by AS6812:  
+
+                #data           immediate data
+                                byte or word data
+        
+                ext             extended addressing
+        
+                pg              memory page number
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+                label           branch label
+        
+                r,r1,r2         registers
+                                ccr,a,b,d,x,y,sp,pc
+        
+
+
+        AS6812 ASSEMBLER                                        PAGE H-2
+        68HC12 INSTRUCTION SET
+
+
+                -x      x-      register indexed, pre or
+                ,-x     ,x-     post autodecrement by 1
+        
+                n,-x    n,x-    register indexed, pre or
+                                post autodecrement by 1 - 8
+        
+                +x      x+      register indexed, pre or
+                ,+x     ,x+     post autoincrement by 1
+        
+                n,+x    n,x+    register indexed, pre or
+                                post autoincrement by 1 - 8
+        
+                offset,x        register indexed addressing
+                                   -16 <= offset <= 15    ---  5-bit
+                                  -256 <= offset <= -17   ---  9-bit
+                                    16 <= offset <= 255   ---  9-bit
+                                -32768 <= offset <= -257  --- 16-bit
+                                   256 <= offset <= 32767 --- 16-bit
+                                (external definition of offset
+                                 uses 16-bit mode)
+        
+                [offset,x]      register indexed indirect addressing
+                                -32768 <= offset <= 32767 --- 16-bit
+        
+                [,x]            register indexed indirect addressing
+                                zero offset
+        
+                a,x             accumulator offset indexed addressing
+        
+                [d,x]           d accumulator offset indexed
+                                indirect addressing
+
+        The  terms  data, dir, label, offset, and ext may all be expres-
+        sions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 68HC12 technical data for valid modes.  
+
+
+        AS6812 ASSEMBLER                                        PAGE H-3
+        68HC12 INSTRUCTION SET
+
+
+        H.2.1  Inherent Instructions 
+
+                aba             bgnd            cba
+                daa             dex             dey
+                ediv            edivs           emul
+                emuls           fdiv            idiv
+                idivs           inx             iny
+                mem             mul             nop
+                psha            pshb            pshc
+                pshd            pshx            pshy
+                pula            pulb            pulc
+                puld            pulx            puly
+                rev             revw            rtc
+                rti             rts             sba
+                stop            swi             tab
+                tba             wai             wav
+                wavr
+
+
+        H.2.2  Short Branch Instructions 
+
+                bcc     label           bcs     label
+                beq     label           bge     label
+                bgt     label           bhi     label
+                bhis    label           bhs     label
+                ble     label           blo     label
+                blos    label           bls     label
+                blt     label           bmi     label
+                bne     label           bpl     label
+                bra     label           brn     label
+                bvc     label           bvs     label
+                bsr     label
+
+
+        H.2.3  Long Branch Instructions 
+
+                lbcc    label           lbcs    label
+                lbeq    label           lbge    label
+                lbgt    label           lbhi    label
+                lbhis   label           lbhs    label
+                lble    label           lblo    label
+                lblos   label           lbls    label
+                lblt    label           lbmi    label
+                lbne    label           lbpl    label
+                lbra    label           lbrn    label
+                lbvc    label           lbvs    label
+
+
+        AS6812 ASSEMBLER                                        PAGE H-4
+        68HC12 INSTRUCTION SET
+
+
+        H.2.4  Branch on Decrement, Test, or Increment 
+
+                dbeq    r,label         dbne    r,label
+                ibeq    r,label         ibne    r,label
+                tbeq    r,label         tbne    r,label
+
+
+        H.2.5  Bit Clear and Set Instructions 
+
+                bclr    [],#data
+                bset    [],#data
+
+
+        H.2.6  Branch on Bit Clear or Set 
+
+                brclr   [],#data,label
+                brset   [],#data,label
+
+
+        AS6812 ASSEMBLER                                        PAGE H-5
+        68HC12 INSTRUCTION SET
+
+
+        H.2.7  Single Operand Instructions 
+
+                asla            aslb
+                asl     []
+        
+                asra            asrb
+                asr     []
+        
+                clra            clrb
+                clr     []
+        
+                coma            comb
+                com     []
+        
+                deca            decb
+                dec     []
+        
+                inca            incb
+                inc     []
+        
+                lsla            lslb
+                lsl     []
+        
+                lsra            lsrb
+                lsr     []
+        
+                nega            negb
+                neg     []
+        
+                rola            rolb
+                rol     []
+        
+                rora            rorb
+                ror     []
+        
+                tsta            tstb
+                tst     []
+
+
+        AS6812 ASSEMBLER                                        PAGE H-6
+        68HC12 INSTRUCTION SET
+
+
+        H.2.8  Double Operand Instructions 
+
+                adca    []              adcb    []
+        
+                adda    []              addb    []
+        
+                anda    []              andb    []
+        
+                bita    []              bitb    []
+        
+                cmpa    []              cmpb    []
+        
+                eora    []              eorb    []
+        
+                ldaa    []      <=>     lda     []
+        
+                ldab    []      <=>     ldb     []
+        
+                oraa    []      <=>     ora     []
+        
+                orab    []      <=>     orb     []
+        
+                sbca    []              sbcb    []
+        
+                staa    []      <=>     sta     []
+        
+                stab    []      <=>     stb     []
+        
+                suba    []              subb    []
+
+
+        H.2.9  Move Instructions 
+
+                movb    [],[]           movw    [],[]
+
+
+        H.2.10  D-register Instructions 
+
+                addd    []              subd    []
+                cpd     []      <=>     cmpd    []
+                ldd     []              std     []
+
+
+        AS6812 ASSEMBLER                                        PAGE H-7
+        68HC12 INSTRUCTION SET
+
+
+        H.2.11  Index/Stack Register Instructions 
+
+                cps     []      <=>     cmps    []
+                cpx     []      <=>     cmpx    []
+                cpy     []      <=>     cmpy    []
+        
+                lds     []
+                ldx     []              ldy     []
+        
+                leas    []
+                leax    []              leay    []
+        
+                sts     []
+                stx     []              sty     []
+
+
+        H.2.12  Jump and Jump/Call to Subroutine Instructions 
+
+                call    [],pg
+                jmp     []              jsr     []
+
+
+        H.2.13  Other Special Instructions 
+
+                emacs   []
+                emaxd   []              emaxm   []
+                emind   []              eminm   []
+                etbl    []
+                maxa    []              maxm    []
+                mina    []              minm    []
+                tbl     []              trap    #data
+
+
+        H.2.14  Register - Register Instructions 
+
+                exg     r1,r2           sex     r1,r2
+                tfr     r1,r2
+
+
+        H.2.15  Condition Code Register Instructions 
+
+                andcc   #data           orcc    #data
+
+
+        AS6812 ASSEMBLER                                        PAGE H-8
+        68HC12 INSTRUCTION SET
+
+
+        H.2.16  M68HC11 Compatibility Mode Instructions 
+
+                abx             aby             clc
+                cli             clv             des
+                ins             sec             sei
+                sev             tap             tpa
+                tsx             tsy             txs
+                tys             xgdx            xgdy
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX I
+
+                                AS6816 ASSEMBLER
+
+
+
+
+
+        I.1  68HC16 REGISTER SET 
+
+        The following is a list of the 68HC16 registers used by AS6816: 
+
+                a,b     -       8-bit accumulators
+                d       -       16-bit accumulator <a:b>
+                e       -       16-bit accumulator
+                x,y,z   -       index registers
+                k       -       address extension register
+                s       -       stack pointer
+                ccr     -       condition code
+
+
+        I.2  68HC16 INSTRUCTION SET 
+
+
+           The  following tables list all 68HC16 mnemonics recognized by
+        the AS6816 assembler.  The designation [] refers to  a  required
+        addressing  mode  argument.   The  following  list specifies the
+        format for each addressing mode supported by AS6816:  
+
+                #data           immediate data
+                                byte or word data
+        
+                #xo,#yo         local immediate data (mac / rmac)
+        
+                label           branch label
+        
+                r               register
+                                ccr,a,b,d,e,x,y,z,s
+        
+                ,x              zero offset register indexed addressing
+                ,x8
+                ,x16
+        
+                offset,x        register indexed addressing
+
+
+        AS6816 ASSEMBLER                                        PAGE I-2
+        68HC16 INSTRUCTION SET
+
+
+                                     0 <= offset <= 255   ---  8-bit
+                                -32768 <= offset <= -1    --- 16-bit
+                                   256 <= offset <= 32767 --- 16-bit
+                                (external definition of offset
+                                 uses 16-bit mode)
+        
+                offset,x8       unsigned 8-bit offset indexed addressing
+                offset,x16      signed 16-bit offset indexed addressing
+        
+                e,x             accumulator offset indexed addressing
+        
+                ext             extended addressing
+        
+                bank            64K bank number (jmp / jsr)
+
+        The  terms data, label, offset, bank, and ext may all be expres-
+        sions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 6816 technical data for valid modes.  
+
+
+        I.2.1  Inherent Instructions 
+
+                aba             abx             aby             abz
+                ace             aced            ade             adx
+                ady             adz             aex             aey
+                aez             bgnd            cba             daa
+                ediv            edivs           emul            emuls
+                fdiv            fmuls           idiv            ldhi
+                lpstop          mul             nop             psha
+                pshb            pshmac          pula            pulb
+                pulmac          rtr             rts             sba
+                sde             sted            swi             sxt
+                tab             tap             tba             tbek
+                tbsk            tbxk            tbyk            tbzk
+                tde             tdmsk           tdp             ted
+                tedm            tekb            tem             tmer
+                tmet            tmxed           tpa             tpd
+                tskb            tsx             tsy             tsz
+                txkb            txs             txy             txz
+                tykb            tys             tyx             tyz
+                tzkb            tzs             tzx             tzy
+                wai             xgab            xgde            xgdx
+                xgdy            xgdz            xgex            xgey
+                xgez
+
+
+        AS6816 ASSEMBLER                                        PAGE I-3
+        68HC16 INSTRUCTION SET
+
+
+        I.2.2  Push/Pull Multiple Register Instructions 
+
+                pshm    r,...           pulm    r,...
+
+
+        I.2.3  Short Branch Instructions 
+
+                bcc     label           bcs     label
+                beq     label           bge     label
+                bgt     label           bhi     label
+                bhis    label           bhs     label
+                ble     label           blo     label
+                blos    label           bls     label
+                blt     label           bmi     label
+                bne     label           bpl     label
+                bra     label           brn     label
+                bvc     label           bvs     label
+                bsr     label
+
+
+        I.2.4  Long Branch Instructions 
+
+                lbcc    label           lbcs    label
+                lbeq    label           lbge    label
+                lbgt    label           lbhi    label
+                lbhis   label           lbhs    label
+                lble    label           lblo    label
+                lblos   label           lbls    label
+                lblt    label           lbmi    label
+                lbne    label           lbpl    label
+                lbra    label           lbrn    label
+                lbvc    label           lbvs    label
+                lbsr    label
+
+
+        I.2.5  Bit Manipulation Instructions 
+
+                bclr    [],#data
+                bset    [],#data
+        
+                brclr   [],#data,label
+                brset   [],#data,label
+
+
+        AS6816 ASSEMBLER                                        PAGE I-4
+        68HC16 INSTRUCTION SET
+
+
+        I.2.6  Single Operand Instructions 
+
+                asla                    aslb
+                asld                    asle
+                aslm
+                asl     []              aslw    []
+        
+                asra                    asrb
+                asrd                    asre
+                asrm
+                asr     []              asrw    []
+        
+                clra                    clrb
+                clrd                    clre
+                                        clrm
+                clr     []              clrw    []
+        
+                coma                    comb
+                comd                    come
+                com     []              comw    []
+        
+                deca                    decb
+                dec     []              decw    []
+        
+                inca                    incb
+                inc     []              incw    []
+        
+                lsla                    lslb
+                lsld                    lsle
+                lslm
+                lsl     []              lslw    []
+        
+                lsra                    lsrb
+                lsrd                    lsre
+                lsr     []              lsrw    []
+        
+                nega                    negb
+                negd                    nege
+                neg     []              negw    []
+        
+                rola                    rolb
+                rold                    role
+                rol     []              rolw    []
+        
+                rora                    rorb
+                rord                    rore
+                ror     []              rorw    []
+        
+                tsta                    tstb
+                tsta                    tste
+                tst     []              tstw    []
+
+
+        AS6816 ASSEMBLER                                        PAGE I-5
+        68HC16 INSTRUCTION SET
+
+
+        I.2.7  Double Operand Instructions 
+
+                adca    []              adcb    []
+                adcd    []              adce    []
+        
+                adda    []              addb    []
+                addd    []              adde    []
+        
+                anda    []              andb    []
+                andd    []              ande    []
+        
+                bita    []              bitb    []
+        
+                cmpa    []              cmpb    []
+                cpd     []              cpe     []
+        
+                eora    []              eorb    []
+                eord    []              eore    []
+        
+                ldaa    []              ldab    []
+                ldd     []              lde     []
+        
+                oraa    []              orab    []
+                ord     []              ore     []
+        
+                sbca    []              sbcb    []
+                sbcd    []              sbce    []
+        
+                staa    []              stab    []
+                std     []              ste     []
+        
+                suba    []              subb    []
+                subd    []              sube    []
+
+
+        I.2.8  Index/Stack Register Instructions 
+
+                cps     []              cpx     []
+                cpy     []              cpz     []
+        
+                lds     []              ldx     []
+                ldy     []              ldz     []
+        
+                sts     []              stx     []
+                sty     []              stz     []
+
+
+        AS6816 ASSEMBLER                                        PAGE I-6
+        68HC16 INSTRUCTION SET
+
+
+        I.2.9  Jump and Jump to Subroutine Instructions 
+
+                jmp     bank,[]         jsr     bank,[]
+
+
+        I.2.10  Condition Code Register Instructions 
+
+                andp    #data           orp     #data
+
+
+        I.2.11  Multiply and Accumulate Instructions 
+
+                mac     #data           rmac    #data
+                mac     #xo,#yo         rmac    #xo,#yo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX J
+
+                                 ASH8 ASSEMBLER
+
+
+
+
+
+        J.1  H8/3XX REGISTER SET 
+
+        The following is a list of the H8 registers used by ASH8:  
+
+                r0  -  r7,sp            16-bit accumulators
+                r0L -  r7L,spL          8-bit accumulators
+                r0H -  r7H,spH          8-bit accumulators
+                spL,spH,sp              stack pointers
+                ccr                     condition code
+
+
+        J.2  H8/3XX INSTRUCTION SET 
+
+
+           The  following tables list all H8/3xx mnemonics recognized by
+        the ASH8 assembler.  The designation [] refers to a required ad-
+        dressing mode argument.  The following list specifies the format
+        for each addressing mode supported by ASH8:  
+
+                #xx:3           immediate data (3  bit)
+                #xx:8           immediate data (8  bit)
+                #xx:16          immediate data (16 bit)
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0xFF00 <= dir <= 0xFFFF
+        
+                label           branch label
+        
+        
+                rn              registers (16 bit)
+                                r0-r7,sp
+        
+                rnB             registers (8 bit)
+                                r0H-r7H,r0L-r7L,spH,spL
+        
+
+
+        ASH8 ASSEMBLER                                          PAGE J-2
+        H8/3XX INSTRUCTION SET
+
+
+                ccr             condition code register
+        
+                @rn             register indirect
+        
+                @-rn            register indirect (auto pre-decrement)
+        
+                @rn+            register indirect (auto post-increment)
+        
+                @[offset,rn]    register indirect, 16-bit displacement
+        
+                @@offset        memory indirect, (8-bit address)
+        
+                ext             extended addressing (16-bit)
+
+        The  terms  data, dir, label, offset, and ext may all be expres-
+        sions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the H8/3xx technical data for valid modes.  
+
+
+        J.2.1  Inherent Instructions 
+
+                eepmov
+                nop
+                sleep
+                rte
+                rts
+
+
+        J.2.2  Branch Instructions 
+
+                bcc     label                   bcs     label
+                beq     label                   bf      label
+                bge     label                   bgt     label
+                bhi     label                   bhis    label
+                bhs     label                   ble     label
+                blo     label                   blos    label
+                bls     label                   blt     label
+                bmi     label                   bne     label
+                bpl     label                   bra     label
+                brn     label                   bt      label
+                bvc     label                   bvs     label
+                bsr     label
+
+
+        ASH8 ASSEMBLER                                          PAGE J-3
+        H8/3XX INSTRUCTION SET
+
+
+        J.2.3  Single Operand Instructions 
+
+                Free Form
+        
+                daa     rnB                     das     rnB
+        
+                dec     rnB                     inc     rnB
+        
+                neg     rnB                     not     rnB
+        
+                rotxl   rnB                     rotxr   rnB
+        
+                rotl    rnB                     rotr    rnB
+        
+                shal    rnB                     shar    rnB
+        
+                shll    rnB                     shlr    rnB
+        
+                push    rn                      pop     rn
+        
+        
+                Byte / Word Form
+        
+                daa.b   rnB                     das.b   rnB
+        
+                dec.b   rnB                     inc.b   rnB
+        
+                neg.b   rnB                     not.b   rnB
+        
+                rotxl.b rnB                     rotxr.b rnB
+        
+                rotl.b  rnB                     rotr.b  rnB
+        
+                shal.b  rnB                     shar.b  rnB
+        
+                shll.b  rnB                     shlr.b  rnB
+        
+                push.w  rn                      pop.w   rn
+
+
+        ASH8 ASSEMBLER                                          PAGE J-4
+        H8/3XX INSTRUCTION SET
+
+
+        J.2.4  Double Operand Instructions 
+
+                Free Form
+        
+                add     rnB,rnB                 add     #xx:8,rnB
+                add     rn,rn
+                adds    #1,rn                   adds    #2,rn
+                addx    rnB,rnB                 addx    #xx:8,rnB
+        
+                cmp     rnB,rnB                 cmp     #xx:8,rnB
+                cmp     rn,rn
+        
+                sub     rnB,rnB
+                sub     rn,rn
+                subs    #1,rn                   subs    #2,rn
+                subx    rnB,rnB                 subx    #xx:8,rnB
+        
+                and     rnB,rnB                 and     #xx:8,rnB
+                                                and     #xx:8,ccr
+        
+                or      rnB,rnB                 or      #xx:8,rnB
+                                                or      #xx:8,ccr
+        
+                xor     rnB,rnB                 xor     #xx:8,rnB
+                                                xor     #xx:8,ccr
+        
+        
+                Byte / Word Form
+        
+                add.b   rnB,rnB                 add.b   #xx:8,rnB
+                add.w   rn,rn
+        
+                cmp.b   rnB,rnB                 cmp.b   #xx:8,rnB
+                cmp.w   rn,rn
+        
+                sub.b   rnB,rnB
+                sub.w   rn,rn
+        
+                addx.b  rnB,rnB                 addx.b  #xx:8,rnB
+        
+                and.b   rnB,rnB                 and.b   #xx:8,rnB
+                                                and.b   #xx:8,ccr
+        
+                or.b    rnB,rnB                 or.b    #xx:8,rnB
+                                                or.b    #xx:8,ccr
+        
+                subx.b  rnB,rnB                 subx.b  #xx:8,rnB
+        
+                xor.b   rnB,rnB                 xor.b   #xx:8,rnB
+                                                xor.b   #xx:8,ccr
+
+
+        ASH8 ASSEMBLER                                          PAGE J-5
+        H8/3XX INSTRUCTION SET
+
+
+        J.2.5  Mov Instructions 
+
+                Free Form
+        
+                mov     rnB,rnB                 mov     rn,rn
+                mov     #xx:8,rnB               mov     #xx:16,rn
+                mov     @rn,rnB                 mov     @rn,rn
+                mov     @[offset,rn],rnB        mov     @[offset,rn],rn
+                mov     @rn+,rnB                mov     @rn+,rn
+                mov     @dir,rnB
+                mov     dir,rnB
+                mov     *@dir,rnB
+                mov     *dir,rnB
+                mov     @label,rnB              mov     @label,rn
+                mov     label,rnB               mov     label,rn
+                mov     rnB,@rn                 mov     rn,@rn
+                mov     rnB,@[offset,rn]        mov     rn,@[offset,rn]
+                mov     rnB,@-rn                mov     rn,@-rn
+                mov     rnB,@dir
+                mov     rnB,dir
+                mov     rnB,*@dir
+                mov     rnB,*dir
+                mov     rnB,@label              mov     rn,@label
+                mov     rnB,label               mov     rn,label
+        
+        
+                Byte / Word Form
+        
+                mov.b   rnB,rnB                 mov.w   rn,rn
+                mov.b   #xx:8,rnB               mov.w   #xx:16,rn
+                mov.b   @rn,rnB                 mov.w   @rn,rn
+                mov.b   @[offset,rn],rnB        mov.w   @[offset,rn],rn
+                mov.b   @rn+,rnB                mov.w   @rn+,rn
+                mov.b   @dir,rnB
+                mov.b   dir,rnB
+                mov.b   *@dir,rnB
+                mov.b   *dir,rnB
+                mov.b   @label,rnB              mov.w   @label,rn
+                mov.b   label,rnB               mov.w   label,rn
+                mov.b   rnB,@rn                 mov.w   rn,@rn
+                mov.b   rnB,@[offset,rn]        mov.w   rn,@[offset,rn]
+                mov.b   rnB,@-rn                mov.w   rn,@-rn
+                mov.b   rnB,@dir
+                mov.b   rnB,dir
+                mov.b   rnB,*@dir
+                mov.b   rnB,*dir
+                mov.b   rnB,@label              mov.w   rn,@label
+                mov.b   rnB,label               mov.w   rn,label
+
+
+        ASH8 ASSEMBLER                                          PAGE J-6
+        H8/3XX INSTRUCTION SET
+
+
+        J.2.6  Bit Manipulation Instructions 
+
+                bld     #xx:3,rnB               bld     #xx:3,@rn
+                bld     #xx:3,@dir              bld     #xx:3,dir
+                bld     #xx:3,*@dir             bld     #xx:3,*dir
+        
+                bild    #xx:3,rnB               bild    #xx:3,@rn
+                bild    #xx:3,@dir              bild    #xx:3,dir
+                bild    #xx:3,*@dir             bild    #xx:3,*dir
+        
+                bst     #xx:3,rnB               bst     #xx:3,@rn
+                bst     #xx:3,@dir              bst     #xx:3,dir
+                bst     #xx:3,*@dir             bst     #xx:3,*dir
+        
+                bist    #xx:3,rnB               bist    #xx:3,@rn
+                bist    #xx:3,@dir              bist    #xx:3,dir
+                bist    #xx:3,*@dir             bist    #xx:3,*dir
+        
+                band    #xx:3,rnB               band    #xx:3,@rn
+                band    #xx:3,@dir              band    #xx:3,dir
+                band    #xx:3,*@dir             band    #xx:3,*dir
+        
+                biand   #xx:3,rnB               biand   #xx:3,@rn
+                biand   #xx:3,@dir              biand   #xx:3,dir
+                biand   #xx:3,*@dir             biand   #xx:3,*dir
+        
+                bor     #xx:3,rnB               bor     #xx:3,@rn
+                bor     #xx:3,@dir              bor     #xx:3,dir
+                bor     #xx:3,*@dir             bor     #xx:3,*dir
+        
+                bior    #xx:3,rnB               bior    #xx:3,@rn
+                bior    #xx:3,@dir              bior    #xx:3,dir
+                bior    #xx:3,*@dir             bior    #xx:3,*dir
+        
+                bxor    #xx:3,rnB               bxor    #xx:3,@rn
+                bxor    #xx:3,@dir              bxor    #xx:3,dir
+                bxor    #xx:3,*@dir             bxor    #xx:3,*dir
+        
+                bixor   #xx:3,rnB               bixor   #xx:3,@rn
+                bixor   #xx:3,@dir              bixor   #xx:3,dir
+                bixor   #xx:3,*@dir             bixor   #xx:3,*dir
+
+
+        ASH8 ASSEMBLER                                          PAGE J-7
+        H8/3XX INSTRUCTION SET
+
+
+        J.2.7  Extended Bit Manipulation Instructions 
+
+                bset    #xx:3,rnB               bset    #xx:3,@rn
+                bset    #xx:3,@dir              bset    #xx:3,dir
+                bset    #xx:3,*@dir             bset    #xx:3,*dir
+                bset    rnB,rnB                 bset    rnB,@rn
+                bset    rnB,@dir                bset    rnB,dir
+                bset    rnB,*@dir               bset    rnB,*dir
+        
+                bclr    #xx:3,rnB               bclr    #xx:3,@rn
+                bclr    #xx:3,@dir              bclr    #xx:3,dir
+                bclr    #xx:3,*@dir             bclr    #xx:3,*dir
+                bclr    rnB,rnB                 bclr    rnB,@rn
+                bclr    rnB,@dir                bclr    rnB,dir
+                bclr    rnB,*@dir               bclr    rnB,*dir
+        
+                bnot    #xx:3,rnB               bnot    #xx:3,@rn
+                bnot    #xx:3,@dir              bnot    #xx:3,dir
+                bnot    #xx:3,*@dir             bnot    #xx:3,*dir
+                bnot    rnB,rnB                 bnot    rnB,@rn
+                bnot    rnB,@dir                bnot    rnB,dir
+                bnot    rnB,*@dir               bnot    rnB,*dir
+        
+                btst    #xx:3,rnB               btst    #xx:3,@rn
+                btst    #xx:3,@dir              btst    #xx:3,dir
+                btst    #xx:3,*@dir             btst    #xx:3,*dir
+                btst    rnB,rnB                 btst    rnB,@rn
+                btst    rnB,@dir                btst    rnB,dir
+                btst    rnB,*@dir               btst    rnB,*dir
+
+
+        J.2.8  Condition Code Instructions 
+
+                andc    #xx:8,ccr               andc    #xx:8
+                and     #xx:8,ccr               and.b   #xx:8,ccr
+        
+                ldc     #xx:8,ccr               ldc     #xx:8
+                ldc     rnB,ccr                 ldc     rnB
+        
+                orc     #xx:8,ccr               orc     #xx:8
+                or      #xx:8,ccr               or.b    #xx:8,ccr
+        
+                xorc    #xx:8,ccr               xorc    #xx:8
+                xor     #xx:8,ccr               xor.b   #xx:8,ccr
+        
+                stc     ccr,rnB                 stc     rnB
+
+
+        ASH8 ASSEMBLER                                          PAGE J-8
+        H8/3XX INSTRUCTION SET
+
+
+        J.2.9  Other Instructions 
+
+                divxu   rnB,rn                  divxu.b rnB,rn
+        
+                mulxu   rnB,rn                  mulxu.b rnB,rn
+        
+                movfpe  @label,rnB              movfpe  label,rnB
+                movfpe.b  @label,rnB            movfpe.b  label,rnB
+        
+                movtpe  @label,rnB              movtpe  label,rnB
+                movtpe.b  @label,rnB            movtpe.b  label,rnB
+
+
+        J.2.10  Jump and Jump to Subroutine Instructions 
+
+                jmp     @rn                     jmp     @@dir
+                jmp     @label                  jmp     label
+        
+                jsr     @rn                     jsr     @@dir
+                jsr     @label                  jsr     label
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX K
+
+                                AS8051 ASSEMBLER
+
+
+
+
+
+        K.1  ACKNOWLEDGMENT 
+
+
+           Thanks  to  John  Hartman  for his contribution of the AS8051
+        cross assembler.  
+
+                John L. Hartman
+                jhartman@compuserve.com
+
+
+        K.2  8051 REGISTER SET 
+
+        The following is a list of the 8051 registers used by AS8051:  
+
+                a,b             -       8-bit accumulators
+                r0,r1,r2,r3     -       8-bit registers
+                r4,r5,r6,r7
+                dptr            -       data pointer
+                sp              -       stack pointer
+                pc              -       program counter
+                psw             -       status word
+                c               -       carry (bit in status word)
+
+
+        AS8051 ASSEMBLER                                        PAGE K-2
+        8051 REGISTER SET
+
+
+        K.3  8051 INSTRUCTION SET 
+
+
+           The  following  tables  list all 8051 mnemonics recognized by
+        the AS8051 assembler.  The following list specifies  the  format
+        for each addressing mode supported by AS8051:  
+
+                #data           immediate data
+                                byte or word data
+        
+                r,r1,r2         register r0,r1,r2,r3,r4,r5,r6, or r7
+        
+                @r              indirect on register r0 or r1
+                @dptr           indirect on data pointer
+                @a+dptr         indirect on accumulator
+                                plus data pointer
+                @a+pc           indirect on accumulator
+                                plus program counter
+        
+                addr            direct memory address
+        
+                bitaddr         bit address
+        
+                label           call or jump label
+
+        The terms data, addr, bitaddr, and label may all be expressions. 
+
+           Note  that  not all addressing modes are valid with every in-
+        struction.  Refer to the 8051 technical data for valid modes.  
+
+
+        K.3.1  Inherent Instructions 
+
+                nop
+
+
+        AS8051 ASSEMBLER                                        PAGE K-3
+        8051 INSTRUCTION SET
+
+
+        K.3.2  Move Instructions 
+
+                mov     a,#data         mov     a,addr
+                mov     a,r             mov     a,@r
+        
+                mov     r,#data         mov     r,addr
+                mov     r,a
+        
+                mov     addr,a          mov     addr,#data
+                mov     addr,r          mov     addr,@r
+                mov     addr1,addr2     mov     bitaddr,c
+        
+                mov     @r,#data        mov     @r,addr
+                mov     @r,a
+        
+                mov     c,bitaddr
+                mov     dptr,#data
+        
+                movc    a,@a+dptr       movc    a,@a+pc
+                movx    a,@dptr         movx    a,@r
+                movx    @dptr,a         movx    @r,a
+
+
+        K.3.3  Single Operand Instructions 
+
+                clr     a               clr     c
+                clr     bitaddr
+                cpl     a               cpl     c
+                cpl     bitaddr
+                setb    c               setb    bitaddr
+        
+                da      a               
+                rr      a               rrc     a
+                rl      a               rlc     a
+                swap    a
+        
+                dec     a               dec     r
+                dec     @r
+                inc     a               inc     r
+                inc     dptr            inc     @r
+        
+                div     ab              mul     ab
+        
+                pop     addr            push    addr
+
+
+        AS8051 ASSEMBLER                                        PAGE K-4
+        8051 INSTRUCTION SET
+
+
+        K.3.4  Two Operand Instructions 
+
+                add     a,#data         add     a,addr
+                add     a,r             add     a,@r
+                addc    a,#data         addc    a,addr
+                addc    a,r             addc    a,@r
+                subb    a,#data         subb    a,addr
+                subb    a,r             subb    a,@r
+                orl     a,#data         orl     a,addr
+                orl     a,r             orl     a,@r
+                orl     addr,a          orl     addr,#data
+                orl     c,bitaddr       orl     c,/bitaddr
+                anl     a,#data         anl     a,addr
+                anl     a,r             anl     a,@r
+                anl     addr,a          anl     addr,#data
+                anl     c,bitaddr       anl     c,/bitaddr
+                xrl     a,#data         xrl     a,addr
+                xrl     a,r             xrl     a,@r
+                xrl     addr,a          xrl     addr,#data
+                xrl     c,bitaddr       xrl     c,/bitaddr
+                xch     a,addr          xch     a,r
+                xch     a,@r            xchd    a,@r
+
+
+        K.3.5  Call and Return Instructions 
+
+                acall   label           lcall   label
+                ret                     reti
+                in      data
+                out     data
+                rst     data
+
+
+        K.3.6  Jump Instructions 
+
+                ajmp    label
+                cjne    a,#data,label   cjne    a,addr,label
+                cjne    r,#data,label   cjne    @r,#data,label
+                djnz    r,label         djnz    addr,label
+                jbc     bitadr,label
+                jb      bitadr,label    jnb     bitadr,label
+                jc      label           jnc     label
+                jz      label           jnz     label
+                jmp     @a+dptr
+                ljmp    label           sjmp    label
+
+
+        AS8051 ASSEMBLER                                        PAGE K-5
+        8051 INSTRUCTION SET
+
+
+        K.3.7  Predefined Symbols:  SFR Map 
+
+                        --------- 4 Bytes ----------
+                        ----    ----    ----    ----
+                FC                                          FF
+                F8                                          FB
+                F4                                          F7
+                F0      B                                   F3
+                EC                                          EF
+                E8                                          EB
+                E4                                          E7
+                E0      ACC                                 E3
+                DC                                          DF
+                D8                                          DB
+                D4                                          D7
+                D0      PSW                                 D3
+                CC   [  TL2     TH2                     ]   CF
+                C8   [  T2CON           RCAP2L  RCAP2H  ]   CB
+                C4                                          C7
+                C0                                          C3
+                BC                                          BF
+                B8      IP                                  BB
+                B4                                          B7
+                B0      P3                                  B3
+                AC                                          AF
+                A8      IE                                  AB
+                A4                                          A7
+                A0      P2                                  A3
+                9C                                          9F
+                98      SCON    SBUF                        9B
+                94                                          97
+                90      P1                                  93
+                8C      TH0     TH1                         8F
+                88      TCON    TMOD    TL0     TL1         8B
+                84                              PCON        87
+                80      P0      SP      DPL     DPH         83
+        
+                [...] Indicates Resident in 8052, not 8051
+
+
+        AS8051 ASSEMBLER                                        PAGE K-6
+        8051 INSTRUCTION SET
+
+
+        K.3.8  Predefined Symbols:  SFR Bit Addresses 
+
+                        ---------- 4 BITS ----------
+                        ----    ----    ----    ----
+                FC                                          FF
+                F8                                          FB
+                F4      B.4     B.5     B.6     B.7         F7
+                F0      B.0     B.1     B.2     B.3         F3
+                EC                                          EF
+                E8                                          EB
+                E4      ACC.4   ACC.5   ACC.6   ACC.7       E7
+                E0      ACC.0   ACC.1   ACC.2   ACC.3       E3
+                DC                                          DF
+                D8                                          DB
+                D4      PSW.4   PSW.5   PSW.6   PSW.7       D7
+                D0      PSW.0   PSW.1   PSW.2   PSW.3       D3
+                CC   [  T2CON.4 T2CON.5 T2CON.6 T2CON.7 ]   CF
+                C8   [  T2CON.0 T2CON.1 T2CON.2 T2CON.3 ]   CB
+                C4                                          C7
+                C0                                          C3
+                BC      IP.4    IP.5    IP.6    IP.7        BF
+                B8      IP.0    IP.1    IP.2    IP.3        BB
+                B4      P3.4    P3.5    P3.6    P3.7        B7
+                B0      P3.0    P3.1    P3.2    P3.3        B3
+                AC      IE.4    IE.5    EI.6    IE.7        AF
+                A8      IE.0    IE.1    IE.2    IE.3        AB
+                A4      P2.4    P2.5    P2.6    P2.7        A7
+                A0      P2.0    P2.1    P2.2    P2.3        A3
+                9C      SCON.4  SCON.5  SCON.6  SCON.7      9F
+                98      SCON.0  SCON.1  SCON.2  SCON.3      9B
+                94      P1.4    P1.5    P1.6    P1.7        97
+                90      P1.0    P1.1    P1.2    P1.3        93
+                8C      TCON.4  TCON.5  TCON.6  TCON.7      8F
+                88      TCON.0  TCON.1  TCON.2  TCON.3      8B
+                84      P0.4    P0.5    P0.6    P0.7        87
+                80      P0.0    P0.1    P0.2    P0.3        83
+        
+                [...] Indicates Resident in 8052, not 8051
+
+
+        AS8051 ASSEMBLER                                        PAGE K-7
+        8051 INSTRUCTION SET
+
+
+        K.3.9  Predefined Symbols:  Control Bits 
+
+                        ---------- 4 BITS ----------
+                        ----    ----    ----    ----
+                FC                                          FF
+                F8                                          FB
+                F4                                          F7
+                F0                                          F3
+                EC                                          EF
+                E8                                          EB
+                E4                                          E7
+                E0                                          E3
+                DC                                          DF
+                D8                                          DB
+                D4      RS1     F0      AC      CY          D7
+                D0      P               OV      RS0         D3
+                CC   [  TLCK    RCLK    EXF2    TF2     ]   CF
+                C8   [  CPRL2   CT2     TR2     EXEN2   ]   CB
+                C4                                          C7
+                C0                                          C3
+                BC      PS      PT2                         BF
+                B8      PX0     PT0     PX1     PT1         BB
+                B4                                          B7
+                B0      RXD     TXD     INT0    INT1        B3
+                AC      ES      ET2             EA          AF
+                A8      EX0     ET0     EX1     ET1         AB
+                A4                                          A7
+                A0                                          A3
+                9C      REN     SM2     SM1     SM0         9F
+                98      RI      TI      RB8     TB8         9B
+                94                                          97
+                90                                          93
+                8C      TR0     TF0     TR1     TF1         8F
+                88      IT0     IE0     IT1     IE1         8B
+                84                                          87
+                80                                          83
+        
+                [...] Indicates Resident in 8052, not 8051
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX L
+
+                                AS8085 ASSEMBLER
+
+
+
+
+
+        L.1  8085 REGISTER SET 
+
+        The  following  is  a  list  of  the 8080/8085 registers used by
+        AS8085:  
+
+                a,b,c,d,e,h,l   -       8-bit accumulators
+                m               -       memory through (hl)
+                sp              -       stack pointer
+                psw             -       status word
+
+
+        L.2  8085 INSTRUCTION SET 
+
+
+           The  following tables list all 8080/8085 mnemonics recognized
+        by the AS8085  assembler.   The  following  list  specifies  the
+        format for each addressing mode supported by AS8085:  
+
+                #data           immediate data
+                                byte or word data
+        
+                r,r1,r2         register or register pair
+                                psw,a,b,c,d,e,h,l
+                                bc,de,hl,sp,pc
+        
+                m               memory address using (hl)
+        
+                addr            direct memory addressing
+        
+                label           call or jump label
+
+        The terms data, m, addr, and label may be expressions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to  the  8080/8085  technical  data  for  valid
+        modes.  
+
+
+        AS8085 ASSEMBLER                                        PAGE L-2
+        8085 INSTRUCTION SET
+
+
+        L.2.1  Inherent Instructions 
+
+                cma             cmc
+                daa             di
+                ei              hlt
+                nop             pchl
+                ral             rar
+                ret             rim
+                rrc             rlc
+                sim             sphl
+                stc             xchg
+                xthl
+
+
+        L.2.2  Register/Memory/Immediate Instructions 
+
+                adc     r       adc     m       aci     #data
+                add     r       add     m       adi     #data
+                ana     r       ana     m       ani     #data
+                cmp     r       cmp     m       cpi     #data
+                ora     r       ora     m       ori     #data
+                sbb     r       sbb     m       sbi     #data
+                sub     r       sub     m       sui     #data
+                xra     r       xra     m       xri     #data
+
+
+        L.2.3  Call and Return Instructions 
+
+                cc      label           rc
+                cm      label           rm
+                cnc     label           rnc
+                cnz     label           rnz
+                cp      label           rp
+                cpe     label           rpe
+                cpo     label           rpo
+                cz      label           rz
+                call    label
+
+
+        L.2.4  Jump Instructions 
+
+                jc      label
+                jm      label
+                jnc     label
+                jnz     label
+                jp      label
+                jpe     label
+                jpo     label
+                jz      label
+                jmp     label
+
+
+        AS8085 ASSEMBLER                                        PAGE L-3
+        8085 INSTRUCTION SET
+
+
+        L.2.5  Input/Output/Reset Instructions 
+
+                in      data
+                out     data
+                rst     data
+
+
+        L.2.6  Move Instructions 
+
+                mov     r1,r2
+                mov     r,m
+                mov     m,r
+        
+                mvi     r,#data
+                mvi     m,#data
+
+
+        L.2.7  Other Instructions 
+
+                dcr     r               dcr     m
+                inr     r               inr     m
+        
+                dad     r               dcx     r
+                inx     r               ldax    r
+                pop     r               push    r
+                stax    r
+        
+                lda     addr            lhld    addr
+                shld    addr            sta     addr
+        
+                lxi     r,#data
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX M
+
+                                 ASZ80 ASSEMBLER
+
+
+
+
+
+        M.1  .hd64 DIRECTIVE 
+
+        Format:  
+
+                .hd64 
+
+        The  .hd64  directive enables processing of the HD64180 specific
+        mnemonics not included in  the  Z80  instruction  set.   HD64180
+        mnemonics  encountered  without  the  .hd64  directive  will  be
+        flagged with an 'o' error.  
+
+
+        M.2  Z80 REGISTER SET AND CONDITIONS 
+
+
+           The following is a complete list of register designations and
+        condition mnemonics:  
+
+                byte registers  -       a,b,c,d,e,h,l,i,r
+                register pairs  -       af,af',bc,de,hl
+                word registers  -       pc,sp,ix,iy
+        
+                C -     carry bit set
+                M -     sign bit set
+                NC -    carry bit clear
+                NZ -    zero bit clear
+                P -     sign bit clear
+                PE -    parity even
+                PO -    parity odd
+                Z -     zero bit set
+
+
+
+
+        ASZ80 ASSEMBLER                                         PAGE M-2
+        Z80 INSTRUCTION SET
+
+
+        M.3  Z80 INSTRUCTION SET 
+
+
+           The  following  tables  list all Z80/HD64180 mnemonics recog-
+        nized by the ASZ80 assembler.  The designation []  refers  to  a
+        required addressing mode argument.  The following list specifies
+        the format for each addressing mode supported by ASZ80:  
+
+                #data           immediate data
+                                byte or word data
+        
+                n               byte value
+        
+                rg              a byte register
+                                a,b,c,d,e,h,l
+        
+                rp              a register pair
+                                bc,de,hl
+        
+                (hl)            implied addressing or
+                                register indirect addressing
+        
+                (label)         direct addressing
+        
+                offset(ix)      indexed addressing with
+                                an offset
+        
+                label           call/jmp/jr label
+
+        The  terms  data,  dir,  offset, and ext may all be expressions.
+        The terms dir and offset are not allowed to be  external  refer-
+        ences.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the Z80/HD64180  technical  data  for  valid
+        modes.  
+
+
+        ASZ80 ASSEMBLER                                         PAGE M-3
+        Z80 INSTRUCTION SET
+
+
+        M.3.1  Inherent Instructions 
+
+                ccf             cpd
+                cpdr            cpi
+                cpir            cpl
+                daa             di
+                ei              exx
+                halt            neg
+                nop             reti
+                retn            rla
+                rlca            rld
+                rra             rrca
+                rrd             scf
+
+
+        M.3.2  Implicit Operand Instructions 
+
+                adc     a,[]            adc     []
+                add     a,[]            add     []
+                and     a,[]            and     []
+                cp      a,[]            cp      []
+                dec     a,[]            dec     []
+                inc     a,[]            inc     []
+                or      a,[]            or      []
+                rl      a,[]            rl      []
+                rlc     a,[]            rlc     []
+                rr      a,[]            rr      []
+                rrc     a,[]            rrc     []
+                sbc     a,[]            sbc     []
+                sla     a,[]            sla     []
+                sra     a,[]            sra     []
+                srl     a,[]            srl     []
+                sub     a,[]            sub     []
+                xor     a,[]            xor     []
+
+
+        ASZ80 ASSEMBLER                                         PAGE M-4
+        Z80 INSTRUCTION SET
+
+
+        M.3.3  Load Instruction 
+
+                ld      rg,[]           ld      [],rg
+                ld      (bc),a          ld      a,(bc)
+                ld      (de),a          ld      a,(de)
+                ld      (label),a       ld      a,(label)
+                ld      (label),rp      ld      rp,(label)
+                ld      i,a             ld      r,a
+                ld      a,i             ld      a,r
+                ld      sp,hl           ld      sp,ix
+                ld      sp,iy           ld      rp,#data
+        
+                ldd                     lddr
+                ldi                     ldir
+
+
+        M.3.4  Call/Return Instructions 
+
+                call    C,label         ret     C
+                call    M,label         ret     M
+                call    NC,label        ret     NC
+                call    NZ,label        ret     NZ
+                call    P,label         ret     P
+                call    PE,label        ret     PE
+                call    PO,label        ret     PO
+                call    Z,label         ret     Z
+                call    label           ret
+
+
+        M.3.5  Jump and Jump to Subroutine Instructions 
+
+                jp      C,label         jp      M,label
+                jp      NC,label        jp      NZ,label
+                jp      P,label         jp      PE,label
+                jp      PO,label        jp      Z,label
+        
+                jp      (hl)            jp      (ix)
+                jp      (iy)            jp      label
+        
+                djnz    label
+        
+                jr      C,label         jr      NC,label
+                jr      NZ,label        jr      Z,label
+                jr      label
+
+
+        ASZ80 ASSEMBLER                                         PAGE M-5
+        Z80 INSTRUCTION SET
+
+
+        M.3.6  Bit Manipulation Instructions 
+
+                bit     n,[]
+                res     n,[]
+                set     n,[]
+
+
+        M.3.7  Interrupt Mode and Reset Instructions 
+
+                im      n
+                im      n
+                im      n
+                rst     n
+
+
+        M.3.8  Input and Output Instructions 
+
+                in      a,(n)           in      rg,(c)
+                ind                     indr
+                ini                     inir
+        
+                out     (n),a           out     (c),rg
+                outd                    otdr
+                outi                    otir
+
+
+        M.3.9  Register Pair Instructions 
+
+                add     hl,rp           add     ix,rp
+                add     iy,rp
+        
+                adc     hl,rp           sbc     hl,rp
+        
+                ex      (sp),hl         ex      (sp),ix
+                ex      (sp),iy
+                ex      de,hl
+                ex      af,af'
+        
+                push    rp              pop     rp
+
+
+        ASZ80 ASSEMBLER                                         PAGE M-6
+        Z80 INSTRUCTION SET
+
+
+        M.3.10  HD64180 Specific Instructions 
+
+                in0     rg,(n)
+                out0    (n),rg
+        
+                otdm                    otdmr
+                otim                    otimr
+        
+                mlt     bc              mlt     de
+                mlt     hl              mlt     sp
+        
+                slp
+        
+                tst     a
+                tstio   #data
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                   APPENDIX N
+
+                                AS6500 ASSEMBLER
+
+
+
+
+
+        N.1  ACKNOWLEDGMENT 
+
+
+           Thanks  to  Marko  Makela  for his contribution of the AS6500
+        cross assembler.  
+
+                Marko Makela
+                Sillitie 10 A
+                01480 Vantaa
+                Finland
+                Internet: Marko.Makela@Helsinki.Fi
+                EARN/BitNet: msmakela@finuh
+
+           Several  additions and modifications were made to his code to
+        support the following families of 6500 processors:  
+
+                (1)     650X and 651X processor family
+                (2)     65F11 and 65F12 processor family
+                (3)     65C00/21 and 65C29 processor family
+                (4)     65C02, 65C102, and 65C112 processor family
+
+           The  instruction  syntax of this cross assembler contains two
+        peculiarities:  (1) the addressing indirection is denoted by the
+        square  brackets  []  and (2) the `bbrx' and `bbsx' instructions
+        are written `bbr0 memory,label'.  
+
+
+
+
+        AS6500 ASSEMBLER                                        PAGE N-2
+        6500 REGISTER SET
+
+
+        N.2  6500 REGISTER SET 
+
+        The following is a list of the 6500 registers used by AS6500:  
+
+                a       -       8-bit accumulator
+                x,y     -       index registers
+
+
+        N.3  6500 INSTRUCTION SET 
+
+
+           The  following  tables  list all 6500 family mnemonics recog-
+        nized by the AS6500 assembler.  The designation [] refers  to  a
+        required addressing mode argument.  The following list specifies
+        the format for each addressing mode supported by AS6500:  
+
+                #data           immediate data
+                                byte or word data
+        
+                *dir            direct page addressing
+                                (see .setdp directive)
+                                0 <= dir <= 255 
+        
+                offset,x        indexed addressing
+                offset,y        indexed addressing
+                                address = (offset + (x or y))
+        
+                [offset,x]      pre-indexed indirect addressing
+                                0 <= offset <= 255
+                                address = contents of location
+                                    (offset + (x or y)) mod 256
+        
+                [offset],y      post-indexed indirect addressing
+                                address = contents of location at offset
+                                    plus the value of the y register
+        
+                [address]       indirect addressing
+        
+                ext             extended addressing
+        
+                label           branch label
+        
+                address,label   direct page memory location
+                                branch label
+                                bbrx and bbsx instruction addressing
+
+        The  terms data, dir, offset, address, ext, and label may all be
+        expressions.  
+
+           Note  that  not all addressing modes are valid with every in-
+        struction, refer to the 65xx technical data for valid modes.  
+
+
+        AS6500 ASSEMBLER                                        PAGE N-3
+        6500 INSTRUCTION SET
+
+
+        N.3.1  Processor Specific Directives 
+
+
+           The  AS6500  cross  assembler has four (4) processor specific
+        assembler directives which  define  the  target  65xx  processor
+        family:  
+
+                .r6500          Core 650X and 651X family (default)
+                .r65f11         Core plus 65F11 and 65F12
+                .r65c00         Core plus 65C00/21 and 65C29
+                .r65c02         Core plus 65C02, 65C102, and 65C112
+
+
+        N.3.2  65xx Core Inherent Instructions 
+
+                brk                     clc
+                cld                     cli
+                clv                     dex
+                dey                     inx
+                iny                     nop
+                pha                     php
+                pla                     plp
+                rti                     rts
+                sec                     sed
+                sei                     tax
+                tay                     tsx
+                txa                     txs
+                tya
+
+
+        N.3.3  65xx Core Branch Instructions 
+
+                bcc     label           bhs     label
+                bcs     label           blo     label
+                beq     label           bmi     label
+                bne     label           bpl     label
+                bvc     label           bvs     label
+
+
+        N.3.4  65xx Core Single Operand Instructions 
+
+                asl     []
+                dec     []
+                inc     []
+                lsr     []
+                rol     []
+                ror     []
+
+
+        AS6500 ASSEMBLER                                        PAGE N-4
+        6500 INSTRUCTION SET
+
+
+        N.3.5  65xx Core Double Operand Instructions 
+
+                adc     []
+                and     []
+                bit     []
+                cmp     []
+                eor     []
+                lda     []
+                ora     []
+                sbc     []
+                sta     []
+
+
+        N.3.6  65xx Core Jump and Jump to Subroutine Instructions 
+
+                jmp     []              jsr     []
+
+
+        N.3.7  65xx Core Miscellaneous X and Y Register Instructions 
+
+                cpx     []
+                cpy     []
+                ldx     []
+                stx     []
+                ldy     []
+                sty     []
+
+
+        AS6500 ASSEMBLER                                        PAGE N-5
+        6500 INSTRUCTION SET
+
+
+        N.3.8  65F11 and 65F12 Specific Instructions 
+
+                bbr0    [],label                bbr1    [],label
+                bbr2    [],label                bbr3    [],label
+                bbr4    [],label                bbr5    [],label
+                bbr6    [],label                bbr7    [],label
+        
+                bbs0    [],label                bbs1    [],label
+                bbs2    [],label                bbs3    [],label
+                bbs4    [],label                bbs5    [],label
+                bbs6    [],label                bbs7    [],label
+        
+                rmb0    []                      rmb1    []
+                rmb2    []                      rmb3    []
+                rmb4    []                      rmb5    []
+                rmb6    []                      rmb7    []
+        
+                smb0    []                      smb1    []
+                smb2    []                      smb3    []
+                smb4    []                      smb5    []
+                smb6    []                      smb7    []
+
+
+        N.3.9  65C00/21 and 65C29 Specific Instructions 
+
+                bbr0    [],label                bbr1    [],label
+                bbr2    [],label                bbr3    [],label
+                bbr4    [],label                bbr5    [],label
+                bbr6    [],label                bbr7    [],label
+        
+                bbs0    [],label                bbs1    [],label
+                bbs2    [],label                bbs3    [],label
+                bbs4    [],label                bbs5    [],label
+                bbs6    [],label                bbs7    [],label
+        
+                bra     label
+        
+                phx                             phy
+                plx                             ply
+        
+                rmb0    []                      rmb1    []
+                rmb2    []                      rmb3    []
+                rmb4    []                      rmb5    []
+                rmb6    []                      rmb7    []
+        
+                smb0    []                      smb1    []
+                smb2    []                      smb3    []
+                smb4    []                      smb5    []
+                smb6    []                      smb7    []
+
+
+        AS6500 ASSEMBLER                                        PAGE N-6
+        6500 INSTRUCTION SET
+
+
+        N.3.10  65C02, 65C102, and 65C112 Specific Instructions 
+
+                bbr0    [],label                bbr1    [],label
+                bbr2    [],label                bbr3    [],label
+                bbr4    [],label                bbr5    [],label
+                bbr6    [],label                bbr7    [],label
+        
+                bbs0    [],label                bbs1    [],label
+                bbs2    [],label                bbs3    [],label
+                bbs4    [],label                bbs5    [],label
+                bbs6    [],label                bbs7    [],label
+        
+                bra     label
+        
+                phx                             phy
+                plx                             ply
+        
+                rmb0    []                      rmb1    []
+                rmb2    []                      rmb3    []
+                rmb4    []                      rmb5    []
+                rmb6    []                      rmb7    []
+        
+                smb0    []                      smb1    []
+                smb2    []                      smb3    []
+                smb4    []                      smb5    []
+                smb6    []                      smb7    []
+        
+                stz     []
+                trb     []
+                tsb     []
+
+           Additional  addressing  modes for the following core instruc-
+        tions are also available with the 65C02, 65C102, and 65C112 pro-
+        cessors.  
+
+                adc     []                      and     []
+                cmp     []                      eor     []
+                lda     []                      ora     []
+                sbc     []                      sta     []
+        
+                bit     []                      jmp     []
+        
+                dec                             inc
+
+ + + +

+ +... Home Page

+ + diff --git a/as/doc/format.txt b/as/doc/format.txt new file mode 100644 index 00000000..fa73cfe2 --- /dev/null +++ b/as/doc/format.txt @@ -0,0 +1,123 @@ + 2.5.1 Object Module Format + + + The first line of an object module contains the [XDQ][HL] + format specifier (i.e. XH indicates a hexidecimal file with + most significant byte first) for the following designators. + + + 2.5.2 Header Line + + H aa areas gg global symbols + + The header line specifies the number of areas(aa) and the + number of global symbols(gg) defined or referenced in this ob- + ject module segment. + + + 2.5.3 Module Line + + M name + + The module line specifies the module name from which this + header segment was assembled. The module line will not appear + if the .module directive was not used in the source program. + + + 2.5.4 Symbol Line + + S string Defnnnn + + or + + S string Refnnnn + + The symbol line defines (Def) or references (Ref) the symbol + 'string' with the value nnnn. The defined value is relative to + the current area base address. References to constants and + external global symbols will always appear before the first area + definition. References to external symbols will have a value of + zero. + + + 2.5.5 Area Line + + A label size ss flags ff + + The area line defines the area label, the size (ss) of the + area in bytes, and the area flags (ff). The area flags specify + the ABS, REL, CON, OVR, and PAG parameters: + + OVR/CON (0x04/0x00 i.e. bit position 2) + + ABS/REL (0x08/0x00 i.e. bit position 3) + + PAG (0x10 i.e. bit position 4) + + + 2.5.6 T Line + + T xx xx nn nn nn nn nn ... + + The T line contains the assembled code output by the assem- + bler with xx xx being the offset address from the current area + base address and nn being the assembled instructions and data in + byte format. + + + 2.5.7 R Line + + R 0 0 nn nn n1 n2 xx xx ... + + The R line provides the relocation information to the linker. + The nn nn value is the current area index, i.e. which area the + current values were assembled. Relocation information is en- + coded in groups of 4 bytes: + + 1. n1 is the relocation mode and object format + 1. bit 0 word(0x00)/byte(0x01) + 2. bit 1 relocatable area(0x00)/symbol(0x02) + 3. bit 2 normal(0x00)/PC relative(0x04) relocation + 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for + byte data + 5. bit 4 signed(0x00)/unsigned(0x10) byte data + 6. bit 5 normal(0x00)/page '0'(0x20) reference + 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference + 8. bit 7 LSB byte(0x00)/MSB byte(0x80) with 2-byte + mode + + 2. n2 is a byte index into the corresponding (i.e. pre- + ceeding) T line data (i.e. a pointer to the data to be + updated by the relocation). The T line data may be + 1-byte or 2-byte byte data format or 2-byte word + format. + + 3. xx xx is the area/symbol index for the area/symbol be- + ing referenced. the corresponding area/symbol is found + in the header area/symbol lists. + + + The groups of 4 bytes are repeated for each item requiring relo- + cation in the preceeding T line. + + + 2.5.8 P Line + + P 0 0 nn nn n1 n2 xx xx + + The P line provides the paging information to the linker as + specified by a .setdp directive. The format of the relocation + information is identical to that of the R line. The correspond- + ing T line has the following information: + T xx xx aa aa bb bb + + Where aa aa is the area reference number which specifies the + selected page area and bb bb is the base address of the page. + bb bb will require relocation processing if the 'n1 n2 xx xx' is + specified in the P line. The linker will verify that the base + address is on a 256 byte boundary and that the page length of an + area defined with the PAG type is not larger than 256 bytes. + + The linker defaults any direct page references to the first + area defined in the input REL file. All ASxxxx assemblers will + specify the _CODE area first, making this the default page area. diff --git a/as/mcs51/Makefile.aslink b/as/mcs51/Makefile.aslink new file mode 100644 index 00000000..410aab44 --- /dev/null +++ b/as/mcs51/Makefile.aslink @@ -0,0 +1,59 @@ +CC=gcc +LEX=flex +YACC=bison +INCROOT=. +CFLAGS=-ggdb -O2 -I $(INCROOT) +TARGETS=$(SDCCDIR)/bin/aslink +ALLOBJECTS= lkmain.o lkhead.o lkarea.o lkdata.o\ + lkeval.o lklex.o lksym.o lkrloc.o\ + lklibr.o lklist.o lkihx.o lks19.o\ + lkstore.o lknoice.o +all:: $(TARGETS) + +clean:: + rm -f $(TARGETS) $(ALLOBJECTS) + +lkmain.o : lkmain.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkmain.o lkmain.c + +lkhead.o : lkhead.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkhead.o lkhead.c + +lkarea.o : lkarea.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkarea.o lkarea.c + +lkdata.o : lkdata.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkdata.o lkdata.c + +lkeval.o : lkeval.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkeval.o lkeval.c + +lklex.o : lklex.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lklex.o lklex.c + +lksym.o : lksym.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lksym.o lksym.c + +lkrloc.o : lkrloc.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkrloc.o lkrloc.c + +lklibr.o : lklibr.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lklibr.o lklibr.c + +lklist.o : lklist.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lklist.o lklist.c + +lkihx.o : lkihx.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkihx.o lkihx.c + +lks19.o : lks19.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lks19.o lks19.c + +lkstore.o : lkstore.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lkstore.o lkstore.c + +lknoice.o : lknoice.c aslink.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o lknoice.o lknoice.c + +$(TARGETS): $(ALLOBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(ALLOBJECTS) diff --git a/as/mcs51/Makefile.asx8051 b/as/mcs51/Makefile.asx8051 new file mode 100644 index 00000000..316ab864 --- /dev/null +++ b/as/mcs51/Makefile.asx8051 @@ -0,0 +1,59 @@ +CC=gcc +LEX=flex +YACC=bison +INCROOT=. +CFLAGS=-ggdb -O2 -I $(INCROOT) +TARGETS=$(SDCCDIR)/bin/asx8051 +ALLOBJECTS= asmain.o aslex.o assym.o assubr.o asnoice.o \ + asexpr.o asdata.o aslist.o asout.o asstore.o \ + i51ext.o i51pst.o i51mch.o i51adr.o + +all:: $(TARGETS) + +clean:: + rm -f $(TARGETS) $(ALLOBJECTS) + +asmain.o : asmain.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o asmain.o asmain.c + +aslex.o : aslex.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o aslex.o aslex.c + +assym.o : assym.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o assym.o assym.c + +assubr.o : assubr.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o assubr.o assubr.c + +asexpr.o : asexpr.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o asexpr.o asexpr.c + +asdata.o : asdata.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o asdata.o asdata.c + +aslist.o : aslist.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o aslist.o aslist.c + +asout.o : asout.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o asout.o asout.c + +asnoice.o : asnoice.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o asnoice.o asnoice.c + +asstore.o : asstore.c asm.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o asstore.o asstore.c + +i51ext.o : i51ext.c asm.h i8051.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o i51ext.o i51ext.c + +i51pst.o : i51pst.c asm.h i8051.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o i51pst.o i51pst.c + +i51mch.o : i51mch.c asm.h i8051.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o i51mch.o i51mch.c + +i51adr.o : i51adr.c asm.h i8051.h + $(CC) $(CFLAGS) $(LDFLAGS) -c -o i51adr.o i51adr.c + +$(TARGETS): $(ALLOBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(ALLOBJECTS) diff --git a/as/mcs51/Makefile.in b/as/mcs51/Makefile.in new file mode 100644 index 00000000..f77e75d4 --- /dev/null +++ b/as/mcs51/Makefile.in @@ -0,0 +1,111 @@ +# +# +# + +VERSION = @VERSION@ +VERSIONHI = @VERSIONHI@ +VERSIONLO = @VERSIONLO@ +VERSIONP = @VERSIONP@ + +SHELL = /bin/sh +CC = @CC@ +CPP = @CPP@ +INSTALL = @INSTALL@ + +PRJDIR = ../.. + +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +includedir = ${prefix}/include +mandir = ${prefix}/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = ${prefix}/info + +CPPFLAGS = @CPPFLAGS@ -I. -I$(PRJDIR) +CFLAGS = @CFLAGS@ -Wall +M_OR_MM = @M_OR_MM@ +LDFLAGS = @LDFLAGS@ + +ASOBJECTS = asmain.o aslex.o assym.o assubr.o asnoice.o \ + asexpr.o asdata.o aslist.o asout.o asstore.o \ + i51ext.o i51pst.o i51mch.o i51adr.o +ASSOURCES = $(patsubst %.o,%.c,$(ASOBJECTS)) + +LKOBJECTS = lkmain.o lkhead.o lkarea.o lkdata.o \ + lkeval.o lklex.o lksym.o lkrloc.o \ + lklibr.o lklist.o lkihx.o lks19.o \ + lkstore.o lknoice.o +LKSOURCES = $(patsubst %.o,%.c,$(LKOBJECTS)) + +ASX8051 = $(PRJDIR)/bin/asx8051 +ASLINK = $(PRJDIR)/bin/aslink + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(ASX8051) $(ASLINK) + +$(ASX8051): $(ASOBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(ASOBJECTS) + +$(ASLINK): $(LKOBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LKOBJECTS) + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) -s $(ASX8051) $(bindir)/asx8051 + $(INSTALL) -s $(ASLINK) $(bindir)/aslink + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(bindir)/asx8051 $(bindir)/aslink + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(ASSOURCES) $(LKSOURCES) *.h $(PRJDIR)/*.h + $(CPP) $(CPPFLAGS) $(M_OR_MM) $(ASSOURCES) $(LKSOURCES) >Makefile.dep + +include Makefile.dep +include clean.mk + +# My rules +# -------- +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of Makefile diff --git a/as/mcs51/alloc.h b/as/mcs51/alloc.h new file mode 100644 index 00000000..f1b96d60 --- /dev/null +++ b/as/mcs51/alloc.h @@ -0,0 +1,7 @@ +/* alloc.h */ +/* DECUS C */ + +extern char *alloc(); +extern char *malloc(); +extern char *calloc(); +extern char *realloc(); diff --git a/as/mcs51/asdata.c b/as/mcs51/asdata.c new file mode 100644 index 00000000..0ae83f37 --- /dev/null +++ b/as/mcs51/asdata.c @@ -0,0 +1,285 @@ +/* asdata.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - change s_id from [NCPS] to pointer (comment) + * 2-Nov-97 JLH: + * - add jflag for debug control + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module asdata.c + * + * The module asdata.c contains the global constants, + * structures, and variables used in the assembler. + */ + +int aserr; /* ASxxxx error counter + */ +jmp_buf jump_env; /* compiler dependent structure + * used by setjmp() and longjmp() + */ +int inpfil; /* count of assembler + * input files specified + */ +int incfil; /* current file handle index + * for include files + */ +int cfile; /* current file handle index + * of input assembly files + */ +int flevel; /* IF-ELSE-ENDIF flag will be non + * zero for false conditional case + */ +int tlevel; /* current conditional level + */ +int ifcnd[MAXIF+1]; /* array of IF statement condition + * values (0 = FALSE) indexed by tlevel + */ +int iflvl[MAXIF+1]; /* array of IF-ELSE-ENDIF flevel + * values indexed by tlevel + */ + +char afn[FILSPC]; /* afile temporary file name + */ +char srcfn[MAXFIL][FILSPC]; /* array of source file names + */ +int srcline[MAXFIL]; /* source line number + */ +char incfn[MAXINC][FILSPC]; /* array of include file names + */ +int incline[MAXINC]; /* include line number + */ + +int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +int line; /* current assembler source + * line number + */ +int page; /* current page number + */ +int lop; /* current line number on page + */ +int pass; /* assembler pass number + */ +int lflag; /* -l, generate listing flag + */ +int cflag; /* -lc, generate sdcdb debug info + */ +int gflag; /* -g, make undefined symbols global flag + */ +int aflag; /* -a, make all symbols global flag + */ +int jflag; /* -j, generate debug information flag + */ +int oflag; /* -o, generate relocatable output flag + */ +int sflag; /* -s, generate symbol table flag + */ +int pflag; /* -p, enable listing pagination + */ +int xflag; /* -x, listing radix flag + */ +int fflag; /* -f(f), relocations flagged flag + */ +addr_t laddr; /* address of current assembler line + * or value of .if argument + */ +addr_t fuzz; /* tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + */ +int lmode; /* listing mode + */ +char *ep; /* pointer into error list + * array eb[NERR] + */ +char eb[NERR]; /* array of generated error codes + */ +char *ip; /* pointer into the assembler-source + * text line in ib[] + */ +char ib[NINPUT]; /* assembler-source text line + */ +char *cp; /* pointer to assembler output + * array cb[] + */ +char cb[NCODE]; /* array of assembler output values + */ +int *cpt; /* pointer to assembler relocation type + * output array cbt[] + */ +int cbt[NCODE]; /* array of assembler relocation types + * describing the data in cb[] + */ +char tb[NTITL]; /* Title string buffer + */ +char stb[NSBTL]; /* Subtitle string buffer + */ + +char symtbl[] = { "Symbol Table" }; +char aretbl[] = { "Area Table" }; + +char module[NCPS]; /* module name string + */ + +/* + * The mne structure is a linked list of the assembler + * mnemonics and directives. The list of mnemonics and + * directives contained in the device dependent file + * xxxpst.c are hashed and linked into NHASH lists in + * module assym.c by syminit(). The structure contains + * the mnemonic/directive name, a subtype which directs + * the evaluation of this mnemonic/directive, a flag which + * is used to detect the end of the mnemonic/directive + * list in xxxpst.c, and a value which is normally + * associated with the assembler mnemonic base instruction + * value. + * + * struct mne + * { + * struct mne *m_mp; Hash link + * char m_id[NCPS]; Mnemonic + * char m_type; Mnemonic subtype + * char m_flag; Mnemonic flags + * addr_t m_valu; Value + * }; + */ +struct mne *mnehash[NHASH]; + +/* + * The sym structure is a linked list of symbols defined + * in the assembler source files. The first symbol is "." + * defined here. The entry 'struct tsym *s_tsym' + * links any temporary symbols following this symbol and + * preceeding the next normal symbol. The structure also + * contains the symbol's name, type (USER or NEW), flag + * (global, assigned, and multiply defined), a pointer + * to the area structure defining where the symbol is + * located, a reference number assigned by outgsd() in + * asout.c, and the symbols address relative to the base + * address of the area where the symbol is located. + * + * struct sym + * { + * struct sym *s_sp; Hash link + * struct tsym *s_tsym; Temporary symbol link + * char *s_id; Symbol (JLH) + * char s_type; Symbol subtype + * char s_flag; Symbol flags + * struct area *s_area; Area line, 0 if absolute + * int s_ref; Ref. number + * addr_t s_addr; Address + * }; + */ +struct sym sym[] = { + {NULL, NULL, ".", S_USER, S_END, NULL, 0, 0} +}; + +struct sym *symp; /* pointer to a symbol structure + */ +struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ + +/* + * The area structure contains the parameter values for a + * specific program or data section. The area structure + * is a linked list of areas. The initial default area + * is "_CODE" defined here, the next area structure + * will be linked to this structure through the structure + * element 'struct area *a_ep'. The structure contains the + * area name, area reference number ("_CODE" is 0) determined + * by the order of .area directives, area size determined + * from the total code and/or data in an area, area fuzz is + * an variable used to track pass to pass changes in the + * area size caused by variable length instruction formats, + * and area flags which specify the area's relocation type. + * + * struct area + * { + * struct area *a_ap; Area link + * char a_id[NCPS]; Area Name + * int a_ref; Reference number + * addr_t a_size; Area size + * addr_t a_fuzz; Area fuzz + * int a_flag; Area flags + * }; + */ +struct area area[] = { + {NULL, "_CODE", 0, 0, 0, A_CON|A_REL} +}; + +struct area *areap; /* pointer to an area structure + */ + +FILE *lfp; /* list output file handle + */ +FILE *ofp; /* relocation output file handle + */ +FILE *tfp; /* symbol table output file handle + */ +FILE *sfp[MAXFIL]; /* array of assembler-source file handles + */ +FILE *ifp[MAXINC]; /* array of include-file file handles + */ + +/* + * array of character types, one per + * ASCII character + */ +char ctype[128] = { +/*NUL*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*BS*/ ILL, SPACE, ILL, ILL, SPACE, ILL, ILL, ILL, +/*DLE*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*CAN*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*SPC*/ SPACE, ETC, ETC, ETC, LETTER, BINOP, BINOP, ETC, +/*(*/ ETC, ETC, BINOP, BINOP, ETC, BINOP, LETTER, BINOP, +/*0*/ DGT2, DGT2, DGT8, DGT8, DGT8, DGT8, DGT8, DGT8, +/*8*/ DGT10, DGT10, ETC, ETC, BINOP, ETC, BINOP, ETC, +/*@*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*H*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*P*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*X*/ LETTER, LETTER, LETTER, ETC, ETC, ETC, BINOP, LETTER, +/*`*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*h*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*p*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*x*/ LETTER, LETTER, LETTER, ETC, BINOP, ETC, ETC, ETC +}; + +/* + * an array of characters which + * perform the case translation function + */ +char ccase[128] = { +/*NUL*/ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', +/*BS*/ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', +/*DLE*/ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', +/*CAN*/ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', +/*SPC*/ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', +/*(*/ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', +/*0*/ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', +/*8*/ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', +/*@*/ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*H*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*P*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*X*/ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', +/*`*/ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*h*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*p*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*x*/ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177' +}; diff --git a/as/mcs51/asexpr.c b/as/mcs51/asexpr.c new file mode 100644 index 00000000..1a94aa64 --- /dev/null +++ b/as/mcs51/asexpr.c @@ -0,0 +1,695 @@ +/* asexpr.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module asexpr.c + * + * The module asexpr.c contains the routines to evaluate + * arithmetic/numerical expressions. The functions in + * asexpr.c perform a recursive evaluation of the arithmetic + * expression read from the assembler-source text line. + * The expression may include binary/unary operators, brackets, + * symbols, labels, and constants in hexadecimal, decimal, octal + * and binary. Arithmetic operations are prioritized and + * evaluated by normal arithmetic conventions. + * + * asexpr.c contains the following functions: + * VOID abscheck() + * addr_t absexpr() + * VOID clrexpr() + * int digit() + * VOID expr() + * int oprio() + * VOID term() + * + * asexpr.c contains no local/static variables + */ + +/*)Function VOID expr(esp, n) + * + * expr * esp pointer to an expr structure + * int n a firewall priority; all top + * level calls (from the user) + * should be made with n set to 0. + * + * The function expr() evaluates an expression and + * stores its value and relocation information into + * the expr structure supplied by the user. + * + * local variables: + * int c current assembler-source + * text character + * int p current operator priority + * area * ap pointer to an area structure + * exp re internal expr structure + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * VOID abscheck() asexpr.c + * VOID clrexpr() asexpr.c + * VOID expr() asexpr.c + * int getnb() aslex.c + * int oprio() asexpr.c + * VOID qerr() assubr.c + * VOID rerr() assubr.c + * VOID term() asexpr.c + * VOID unget() aslex.c + * + * + * side effects: + * An expression is evaluated modifying the user supplied + * expr structure, a sym structure maybe created for an + * undefined symbol, and the parse of the expression may + * terminate if a 'q' error occurs. + */ + +VOID +expr(esp, n) +register struct expr *esp; +int n; +{ + register int c, p; + struct area *ap; + struct expr re; + + term(esp); + while (ctype[c = getnb()] & BINOP) { + /* + * Handle binary operators + - * / & | % ^ << >> + */ + if ((p = oprio(c)) <= n) + break; + if ((c == '>' || c == '<') && c != get()) + qerr(); + clrexpr(&re); + expr(&re, p); + esp->e_rlcf |= re.e_rlcf; + if (c == '+') { + /* + * esp + re, at least one must be absolute + */ + if (esp->e_base.e_ap == NULL) { + /* + * esp is absolute (constant), + * use area from re + */ + esp->e_base.e_ap = re.e_base.e_ap; + } else + if (re.e_base.e_ap) { + /* + * re should be absolute (constant) + */ + rerr(); + } + if (esp->e_flag && re.e_flag) + rerr(); + if (re.e_flag) + esp->e_flag = 1; + esp->e_addr += re.e_addr; + } else + if (c == '-') { + /* + * esp - re + */ + if ((ap = re.e_base.e_ap) != NULL) { + if (esp->e_base.e_ap == ap) { + esp->e_base.e_ap = NULL; + } else { + rerr(); + } + } + if (re.e_flag) + rerr(); + esp->e_addr -= re.e_addr; + } else { + /* + * Both operands (esp and re) must be constants + */ + /* SD :- moved the abscheck to each case + case and change the right shift operator.. if + right shift by 8 bits of a relocatable address then + the user wants the higher order byte. set the R_MSB + for the expression */ + switch (c) { + + case '*': + abscheck(esp); + abscheck(&re); + esp->e_addr *= re.e_addr; + break; + + case '/': + abscheck(esp); + abscheck(&re); + esp->e_addr /= re.e_addr; + break; + + case '&': + abscheck(esp); + abscheck(&re); + esp->e_addr &= re.e_addr; + break; + + case '|': + abscheck(esp); + abscheck(&re); + esp->e_addr |= re.e_addr; + break; + + case '%': + abscheck(esp); + abscheck(&re); + esp->e_addr %= re.e_addr; + break; + + case '^': + abscheck(esp); + abscheck(&re); + esp->e_addr ^= re.e_addr; + break; + + case '<': + abscheck(esp); + abscheck(&re); + esp->e_addr <<= re.e_addr; + break; + + case '>': + /* SD change here */ + abscheck(&re); + /* if the left is a relative address & + the right side is == 8 then */ + if (esp->e_base.e_ap && re.e_addr == 8) { + esp->e_rlcf |= R_MSB ; + break; + } + /* else continue with the normal processing */ + abscheck(esp); + esp->e_addr >>= re.e_addr; + break; + + default: + qerr(); + break; + } + } + } + unget(c); +} + +/*)Function addr_t absexpr() + * + * The function absexpr() evaluates an expression, verifies it + * is absolute (i.e. not position dependent or relocatable), and + * returns its value. + * + * local variables: + * expr e expr structure + * + * global variables: + * none + * + * functions called: + * VOID abscheck() asexpr.c + * VOID clrexpr() asexpr.c + * VOID expr() asexpr.c + * + * side effects: + * If the expression is not absolute then + * a 'r' error is reported. + */ + +addr_t +absexpr() +{ + struct expr e; + + clrexpr(&e); + expr(&e, 0); + abscheck(&e); + return (e.e_addr); +} + +/*)Function VOID term(esp) + * + * expr * esp pointer to an expr structure + * + * The function term() evaluates a single constant + * or symbol value prefaced by any unary operator + * ( +, -, ~, ', ", >, or < ). This routine is also + * responsible for setting the relocation type to symbol + * based (e.flag != 0) on global references. + * + * local variables: + * int c current character + * char id[] symbol name + * char * jp pointer to assembler-source text + * int n constant evaluation running sum + * int r current evaluation radix + * sym * sp pointer to a sym structure + * tsym * tp pointer to a tsym structure + * int v current digit evaluation + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * sym * symp pointer to a symbol structure + * + * functions called: + * VOID abscheck() asexpr.c + * int digit() asexpr.c + * VOID err() assubr.c + * VOID expr() asexpr.c + * int is_abs() asexpr.c + * int get() aslex.c + * VOID getid() aslex.c + * int getmap() aslex.c + * int getnb() aslex.c + * sym * lookup() assym.c + * VOID qerr() assubr.c + * VOID unget() aslex.c + * + * side effects: + * An arithmetic term is evaluated, a symbol structure + * may be created, term evaluation may be terminated + * by a 'q' error. + */ + +VOID +term(esp) +register struct expr *esp; +{ + register int c, n; + register char *jp; + char id[NCPS]; + struct sym *sp; + struct tsym *tp; + int r=0, v; + + c = getnb(); + /* + * Discard the unary '+' at this point and + * also any reference to numerical arguments + * associated with the '#' prefix. + */ + while (c == '+' || c == '#') { c = getnb(); } + /* + * Evaluate all binary operators + * by recursively calling expr(). + */ + if (c == LFTERM) { + expr(esp, 0); + if (getnb() != RTTERM) + qerr(); + return; + } + if (c == '-') { + expr(esp, 100); + abscheck(esp); + esp->e_addr = -esp->e_addr; + return; + } + if (c == '~') { + expr(esp, 100); + abscheck(esp); + esp->e_addr = ~esp->e_addr; + return; + } + if (c == '\'') { + esp->e_mode = S_USER; + esp->e_addr = getmap(-1)&0377; + return; + } + if (c == '\"') { + esp->e_mode = S_USER; + if (hilo) { + esp->e_addr = (getmap(-1)&0377)<<8; + esp->e_addr |= (getmap(-1)&0377); + } else { + esp->e_addr = (getmap(-1)&0377); + esp->e_addr |= (getmap(-1)&0377)<<8; + } + return; + } + if (c == '>' || c == '<') { + expr(esp, 100); + if (is_abs (esp)) { + /* + * evaluate msb/lsb directly + */ + if (c == '>') + esp->e_addr >>= 8; + esp->e_addr &= 0377; + return; + } else { + /* + * let linker perform msb/lsb, lsb is default + */ + esp->e_rlcf |= R_BYT2; + if (c == '>') + esp->e_rlcf |= R_MSB; + return; + } + } + /* + * Evaluate digit sequences as local symbols + * if followed by a '$' or as constants. + */ + if (ctype[c] & DIGIT) { + esp->e_mode = S_USER; + jp = ip; + while (ctype[(int)*jp] & RAD10) { + jp++; + } + if (*jp == '$') { + n = 0; + while ((v = digit(c, 10)) >= 0) { + n = 10*n + v; + c = get(); + } + tp = symp->s_tsym; + while (tp) { + if (n == tp->t_num) { + esp->e_base.e_ap = tp->t_area; + esp->e_addr = tp->t_addr; + return; + } + tp = tp->t_lnk; + } + /* err('u'); */ + return; + } + r = radix; + if (c == '0') { + c = get(); + switch (c) { + case 'b': + case 'B': + r = 2; + c = get(); + break; + case 'o': + case 'O': + case 'q': + case 'Q': + r = 8; + c = get(); + break; + case 'd': + case 'D': + r = 10; + c = get(); + break; + case 'h': + case 'H': + case 'x': + case 'X': + r = 16; + c = get(); + break; + default: + break; + } + } + n = 0; + while ((v = digit(c, r)) >= 0) { + n = r*n + v; + c = get(); + } + unget(c); + esp->e_addr = n; + return; + } + /* + * Evaluate '$' sequences as a temporary radix + * if followed by a '%', '&', '#', or '$'. + */ + if (c == '$') { + c = get(); + if (c == '%' || c == '&' || c == '#' || c == '$') { + switch (c) { + case '%': + r = 2; + break; + case '&': + r = 8; + break; + case '#': + r = 10; + break; + case '$': + r = 16; + break; + default: + break; + } + c = get(); + n = 0; + while ((v = digit(c, r)) >= 0) { + n = r*n + v; + c = get(); + } + unget(c); + esp->e_mode = S_USER; + esp->e_addr = n; + return; + } + unget(c); + c = '$'; + } + /* + * Evaluate symbols and labels + */ + if (ctype[c] & LETTER) { + esp->e_mode = S_USER; + getid(id, c); + sp = lookup(id); + if (sp->s_type == S_NEW) { + esp->e_addr = 0; + if (sp->s_flag&S_GBL) { + esp->e_flag = 1; + esp->e_base.e_sp = sp; + return; + } + /* err('u'); */ + } else { + esp->e_mode = sp->s_type; + esp->e_addr = sp->s_addr; + esp->e_base.e_ap = sp->s_area; + } + return; + } + /* + * Else not a term. + */ + qerr(); +} + +/*)Function int digit(c, r) + * + * int c digit character + * int r current radix + * + * The function digit() returns the value of c + * in the current radix r. If the c value is not + * a number of the current radix then a -1 is returned. + * + * local variables: + * none + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * none + * + * side effects: + * none + */ + +int +digit(c, r) +register int c, r; +{ + if (r == 16) { + if (ctype[c] & RAD16) { + if (c >= 'A' && c <= 'F') + return (c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + return (c - '0'); + } + } else + if (r == 10) { + if (ctype[c] & RAD10) + return (c - '0'); + } else + if (r == 8) { + if (ctype[c] & RAD8) + return (c - '0'); + } else + if (r == 2) { + if (ctype[c] & RAD2) + return (c - '0'); + } + return (-1); +} + +/*)Function VOID abscheck(esp) + * + * expr * esp pointer to an expr structure + * + * The function abscheck() tests the evaluation of an + * expression to verify it is absolute. If the evaluation + * is relocatable then an 'r' error is noted and the expression + * made absolute. + * + * Note: The area type (i.e. ABS) is not checked because + * the linker can be told to explicitly relocate an + * absolute area. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * VOID rerr() assubr.c + * + * side effects: + * The expression may be changed to absolute and the + * 'r' error invoked. + */ + +VOID +abscheck(esp) +register struct expr *esp; +{ + if (esp->e_flag || esp->e_base.e_ap) { + esp->e_flag = 0; + esp->e_base.e_ap = NULL; + rerr(); + } +} + +/*)Function int is_abs(esp) + * + * expr * esp pointer to an expr structure + * + * The function is_abs() tests the evaluation of an + * expression to verify it is absolute. If the evaluation + * is absolute then 1 is returned, else 0 is returned. + * + * Note: The area type (i.e. ABS) is not checked because + * the linker can be told to explicitly relocate an + * absolute area. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +is_abs (esp) +register struct expr *esp; +{ + if (esp->e_flag || esp->e_base.e_ap) { + return(0); + } + return(1); +} + +/*)Function int oprio(c) + * + * int c operator character + * + * The function oprio() returns a relative priority + * for all valid unary and binary operators. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +oprio(c) +register int c; +{ + if (c == '*' || c == '/' || c == '%') + return (10); + if (c == '+' || c == '-') + return (7); + if (c == '<' || c == '>') + return (5); + if (c == '^') + return (4); + if (c == '&') + return (3); + if (c == '|') + return (1); + return (0); +} + +/*)Function VOID clrexpr(esp) + * + * expr * esp pointer to expression structure + * + * The function clrexpr() clears the expression structure. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * expression structure cleared. + */ + +VOID +clrexpr(esp) +register struct expr *esp; +{ + esp->e_mode = 0; + esp->e_flag = 0; + esp->e_addr = 0; + esp->e_base.e_ap = NULL; + esp->e_rlcf = 0; +} diff --git a/as/mcs51/aslex.c b/as/mcs51/aslex.c new file mode 100644 index 00000000..4cbcda62 --- /dev/null +++ b/as/mcs51/aslex.c @@ -0,0 +1,494 @@ +/* aslex.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH bug in getst(): sign extend on ~(SPACE|ILL) + * causes infinite loop + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module aslex.c + * + * The module aslex.c includes the general lexical + * analysis routines for the assembler. + * + * aslex.c contains the following functions: + * char endline() + * char get() + * VOID getid(id,c) + * int getline() + * int getmap() + * char getnb() + * VOID getst() + * int more() + * VOID unget(c) + * + * aslex.c contains no local/static variables + */ + +/*)Function VOID getid(id,c) + * + * char * id a pointer to a string of + * maximum length NCPS + * int c mode flag + * >=0 this is first character to + * copy to the string buffer + * <0 skip white space, first + * character must be a LETTER + * + * The function getid() scans the current assembler-source text line + * from the current position copying the next LETTER | DIGIT string + * into the external string buffer (id). The string ends when a non + * LETTER or DIGIT character is found. The maximum number of + * characters copied is NCPS. If the input string is larger than + * NCPS characters then the string is truncated, if the input string + * is shorter than NCPS characters then the string is NULL filled. + * If the mode argument (c) is >=0 then (c) is the first character + * copied to the string buffer, if (c) is <0 then intervening white + * space (SPACES and TABS) are skipped and the first character found + * must be a LETTER else a 'q' error terminates the parse of this + * assembler-source text line. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() aslex.c + * char getnb() aslex.c + * VOID unget() aslex.c + * + * side effects: + * use of getnb(), get(), and unget() updates the + * global pointer ip, the position in the current + * assembler-source text line. + */ + +VOID +getid(id, c) +register int c; +char *id; +{ + register char *p; + + if (c < 0) { + c = getnb(); + if ((ctype[c] & LETTER) == 0) + qerr(); + } + p = id; + do { + if (p < &id[NCPS]) + *p++ = c; + } while (ctype[c=get()] & (LETTER|DIGIT)); + unget(c); + while (p < &id[NCPS]) + *p++ = 0; +} + +/*)Function VOID getst(id,c) + * + * char * id a pointer to a string of + * maximum length NCPS + * int c mode flag + * >=0 this is first character to + * copy to the string buffer + * <0 skip white space, first + * character must be a LETTER + * + * The function getnbid() scans the current assembler-source text line + * from the current position copying the next character string into + * the external string buffer (id). The string ends when a SPACE or + * ILL character is found. The maximum number of + * characters copied is NCPS. If the input string is larger than + * NCPS characters then the string is truncated, if the input string + * is shorter than NCPS characters then the string is NULL filled. + * If the mode argument (c) is >=0 then (c) is the first character + * copied to the string buffer, if (c) is <0 then intervening white + * space (SPACES and TABS) are skipped and the first character found + * must be a LETTER else a 'q' error terminates the parse of this + * assembler-source text line. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() aslex.c + * char getnb() aslex.c + * VOID unget() aslex.c + * + * side effects: + * use of getnb(), get(), and unget() updates the + * global pointer ip, the position in the current + * assembler-source text line. + */ + +VOID +getst(id, c) +register int c; +char *id; +{ + register char *p; + + if (c < 0) { + c = getnb(); + if ((ctype[c] & LETTER) == 0) + qerr(); + } + p = id; + do { + if (p < &id[NCPS]) + *p++ = c; + } while (ctype[c=get()] & (0xFF - (SPACE|ILL))); + unget(c); + while (p < &id[NCPS]) + *p++ = 0; +} + +/*)Function char getnb() + * + * The function getnb() scans the current assembler-source + * text line returning the first character not a SPACE or TAB. + * + * local variables: + * int c current character from + * assembler-source text line + * + * global variables: + * none + * + * called functions: + * char get() aslex.c + * + * side effects: + * use of get() updates the global pointer ip, the position + * in the current assembler-source text line + */ + +char +getnb() +{ + register int c; + + while ((c=get()) == ' ' || c == '\t') + ; + return (c); +} + +/*)Function char get() + * + * The function get() returns the next character in the + * assembler-source text line, at the end of the line a + * NULL character is returned. + * + * local variables: + * int c current character from + * assembler-source text line + * + * global variables: + * char * ip pointer into the current + * assembler-source text line + * + * called functions: + * none + * + * side effects: + * updates ip to the next character position in the + * assembler-source text line. If ip is at the end of the + * line, ip is not updated. + */ + +char +get() +{ + register int c; + + if ((c = *ip) != 0) + ++ip; + return (c); +} + +/*)Function VOID unget(c) + * + * int c value of last character read from + * assembler-source text line + * + * If (c) is not a NULL character then the global pointer ip + * is updated to point to the preceeding character in the + * assembler-source text line. + * + * NOTE: This function does not push the character (c) + * back into the assembler-source text line, only + * the pointer ip is changed. + * + * local variables: + * int c last character read from + * assembler-source text line + * + * global variables: + * char * ip position into the current + * assembler-source text line + * + * called functions: + * none + * + * side effects: + * ip decremented by 1 character position + */ + +VOID +unget(c) +{ + if (c) + if (ip != ib) + --ip; +} + +/*)Function int getmap(d) + * + * int d value to compare with the + * assembler-source text line character + * + * The function getmap() converts the 'C' style characters \b, \f, + * \n, \r, and \t to their equivalent ascii values and also + * converts 'C' style octal constants '\123' to their equivalent + * numeric values. If the first character is equivalent to (d) then + * a (-1) is returned, if the end of the line is detected then + * a 'q' error terminates the parse for this line, or if the first + * character is not a \ then the character value is returned. + * + * local variables: + * int c value of character from the + * assembler-source text line + * int n looping counter + * int v current value of numeric conversion + * + * global variables: + * none + * + * called functions: + * char get() aslex.c + * + * side effects: + * use of get() updates the global pointer ip the position + * in the current assembler-source text line + */ + +int +getmap(d) +{ + register int c, n, v; + + if ((c=get()) == '\0') + qerr(); + if (c == d) + return (-1); + if (c == '\\') { + c = get(); + switch (c) { + + case 'b': + c = '\b'; + break; + + case 'f': + c = '\f'; + break; + + case 'n': + c = '\n'; + break; + + case 'r': + c = '\r'; + break; + + case 't': + c = '\t'; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + n = 0; + v = 0; + while (++n<=3 && c>='0' && c<='7') { + v = (v<<3) + c - '0'; + c = get(); + } + unget(c); + c = v; + break; + } + } + return (c); +} + +/*)Function int getline() + * + * The function getline() reads a line of assembler-source text + * from an assembly source text file or an include file. + * Lines of text are processed from assembler-source files until + * all files have been read. If an include file is opened then + * lines of text are read from the include file (or nested + * include file) until the end of the include file is found. + * The input text line is copied into the global string ib[] + * and converted to a NULL terminated string. The function + * getline() returns a (1) after succesfully reading a line + * or a (0) if all files have been read. + * + * local variables: + * int i string length + * + * global variables: + * char ib[] string buffer containing + * assembler-source text line + * char ifp[] array of file handles for + * include files + * int incfil index for ifp[] specifies + * active include file + * int incline[] array of include file + * line numbers + * char sfp[] array of file handles for + * assembler source files + * int cfile index for sfp[] specifies + * active source file + * int srcline[] array of source file + * line numbers + * int inpfil maximum input file index + * + * called functions: + * int fclose() c-library + * char * fgets() c-library + * int strlen() c-library + * + * side effects: + * include file will be closed at detection of end of file. + * the next sequential source file may be selected. + * the global file indexes incfil or cfile may be changed. + * The respective source line or include line counter + * will be updated. + */ + +int +getline() +{ +register int i; + +loop: if (incfil >= 0) { + if (fgets(ib, sizeof ib, ifp[incfil]) == NULL) { + fclose(ifp[incfil--]); + lop = NLPP; + goto loop; + } else { + ++incline[incfil]; + } + } else { + if (fgets(ib, sizeof ib, sfp[cfile]) == NULL) { + if (++cfile <= inpfil) { + srcline[cfile] = 0; + goto loop; + } + return (0); + } else { + ++srcline[cfile]; + } + } + i = strlen(ib) - 1; + if (ib[i] == '\n') + ib[i] = 0; + return (1); +} + +/*)Function int more() + * + * The function more() scans the assembler-source text line + * skipping white space (SPACES and TABS) and returns a (0) + * if the end of the line or a comment delimeter (;) is found, + * or a (1) if their are additional characters in the line. + * + * local variables: + * int c next character from the + * assembler-source text line + * + * global variables: + * none + * + * called functions: + * char getnb() aslex.c + * VOID unget() aslex.c + * + * side effects: + * use of getnb() and unget() updates the global pointer ip + * the position in the current assembler-source text line + */ + +int +more() +{ + register int c; + + c = getnb(); + unget(c); + return( (c == '\0' || c == ';') ? 0 : 1 ); +} + +/*)Function char endline() + * + * The function endline() scans the assembler-source text line + * skipping white space (SPACES and TABS) and returns the next + * character or a (0) if the end of the line is found or a + * comment delimiter (;) is found. + * + * local variables: + * int c next character from the + * assembler-source text line + * + * global variables: + * none + * + * called functions: + * char getnb() aslex.c + * + * side effects: + * use of getnb() updates the global pointer ip the + * position in the current assembler-source text line + */ + +char +endline() +{ + register int c; + + c = getnb(); + return( (c == '\0' || c == ';') ? 0 : c ); +} diff --git a/as/mcs51/aslink.h b/as/mcs51/aslink.h new file mode 100644 index 00000000..77f84c82 --- /dev/null +++ b/as/mcs51/aslink.h @@ -0,0 +1,718 @@ +/* aslink.h */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - add proto for StoreString + * - change s_id from [NCPS] to pointer + * - change NCPS to 80 + * - case sensitive + * - add R_J11 for 8051 assembler + * 31-Oct-97 JLH: + * - add jflag and jfp for NoICE output + * 30-Jan-98 JLH: + * - add memory space flags to a_flag for 8051 + */ + +#define VERSION "V01.70 + NoICE + SDCC Feb 1999" + +/* + * Case Sensitivity Flag + */ +#define CASE_SENSITIVE 1 + +/*)Module asmlnk.h + * + * The module asmlnk.h contains the definitions for constants, + * structures, global variables, and LKxxxx functions + * contained in the LKxxxx.c files. + */ + +/*)BUILD + $(PROGRAM) = ASLINK + $(INCLUDE) = ASLINK.H + $(FILES) = { + LKMAIN.C + LKLEX.C + LKAREA.C + LKHEAD.C + LKSYM.C + LKEVAL.C + LKDATA.C + LKLIST.C + LKRLOC.C + LKLIBR.C + LKS19.C + LKIHX.C + } + $(STACK) = 2000 +*/ + +/* DECUS C void definition */ +/* File/extension seperator */ + +#ifdef decus +#define VOID char +#define FSEPX '.' +#endif + +/* PDOS C void definition */ +/* File/extension seperator */ + +#ifdef PDOS +#define VOID char +#define FSEPX ':' +#endif + +/* Default void definition */ +/* File/extension seperator */ + +#ifndef VOID +#define VOID void +#define FSEPX '.' +#define OTHERSYSTEM +#endif + +/* + * This file defines the format of the + * relocatable binary file. + */ + +#define NCPS 80 /* characters per symbol (JLH: change from 8) */ +#define NDATA 16 /* actual data */ +#define NINPUT 128 /* Input buffer size */ +#define NHASH 64 /* Buckets in hash table */ +#define HMASK 077 /* Hash mask */ +#define NLPP 60 /* Lines per page */ +#define NTXT 16 /* T values */ +#define FILSPC 80 /* File spec length */ + +/* + * The "R_" relocation constants define values used in + * generating the assembler relocation output data for + * areas, symbols, and code. + * + * + * Relocation types. + * + * 7 6 5 4 3 2 1 0 + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * | MSB | PAGn| PAG0| USGN| BYT2| PCR | SYM | BYT | + * +-----+-----+-----+-----+-----+-----+-----+-----+ + */ + +#define R_WORD 0000 /* 16 bit */ +#define R_BYTE 0001 /* 8 bit */ + +#define R_AREA 0000 /* Base type */ +#define R_SYM 0002 + +#define R_NORM 0000 /* PC adjust */ +#define R_PCR 0004 + +#define R_BYT1 0000 /* Byte count for R_BYTE = 1 */ +#define R_BYT2 0010 /* Byte count for R_BYTE = 2 */ + +#define R_SGND 0000 /* Signed value */ +#define R_USGN 0020 /* Unsigned value */ + +#define R_NOPAG 0000 /* Page Mode */ +#define R_PAG0 0040 /* Page '0' */ +#define R_PAG 0100 /* Page 'nnn' */ + +/* + * Valid for R_BYT2: + */ +#define R_LSB 0000 /* output low byte */ +#define R_MSB 0200 /* output high byte */ + +#define R_J11 (R_WORD|R_BYT2) /* JLH: 11 bit JMP and CALL (8051) */ + +/* + * Global symbol types. + */ +#define S_REF 1 /* referenced */ +#define S_DEF 2 /* defined */ + +/* + * Area type flags + */ +#define A_CON 0000 /* concatenate */ +#define A_OVR 0004 /* overlay */ +#define A_REL 0000 /* relocatable */ +#define A_ABS 0010 /* absolute */ +#define A_NOPAG 0000 /* non-paged */ +#define A_PAG 0020 /* paged */ + +/* Additional flags for 8051 address spaces */ +#define A_DATA 0000 /* data space (default)*/ +#define A_CODE 0040 /* code space */ +#define A_XDATA 0100 /* external data space */ +#define A_BIT 0200 /* bit addressable space */ + +/* + * File types + */ +#define F_STD 1 /* stdin */ +#define F_LNK 2 /* File.lnk */ +#define F_REL 3 /* File.rel */ + +/* + * General assembler address type + */ +typedef unsigned int addr_t; + +/* + * The structures of head, area, areax, and sym are created + * as the REL files are read during the first pass of the + * linker. The struct head is created upon encountering a + * H directive in the REL file. The structure contains a + * link to a link file structure (struct lfile) which describes + * the file containing the H directive, the number of data/code + * areas contained in this header segment, the number of + * symbols referenced/defined in this header segment, a pointer + * to an array of pointers to areax structures (struct areax) + * created as each A directive is read, and a pointer to an + * array of pointers to symbol structures (struct sym) for + * all referenced/defined symbols. As H directives are read + * from the REL files a linked list of head structures is + * created by placing a link to the new head structure + * in the previous head structure. + */ +struct head +{ + struct head *h_hp; /* Header link */ + struct lfile *h_lfile;/* Associated file */ + int h_narea; /* # of areas */ + struct areax **a_list; /* Area list */ + int h_nglob; /* # of global symbols */ + struct sym **s_list; /* Globle symbol list */ + char m_id[NCPS]; /* Module name */ +}; + +/* + * A structure area is created for each 'unique' data/code + * area definition found as the REL files are read. The + * struct area contains the name of the area, a flag byte + * which contains the area attributes (REL/CON/OVR/ABS), + * an area subtype (not used in this assembler), and the + * area base address and total size which will be filled + * in at the end of the first pass through the REL files. + * As A directives are read from the REL files a linked + * list of unique area structures is created by placing a + * link to the new area structure in the previous area structure. + */ +struct area +{ + struct area *a_ap; /* Area link */ + struct areax *a_axp; /* Area extension link */ + addr_t a_addr; /* Beginning address of area */ + addr_t a_size; /* Total size of the area */ + char a_type; /* Area subtype */ + char a_flag; /* Flag byte */ + char a_id[NCPS]; /* Name */ +}; + +/* + * An areax structure is created for every A directive found + * while reading the REL files. The struct areax contains a + * link to the 'unique' area structure referenced by the A + * directive and to the head structure this area segment is + * a part of. The size of this area segment as read from the + * A directive is placed in the areax structure. The beginning + * address of this segment will be filled in at the end of the + * first pass through the REL files. As A directives are read + * from the REL files a linked list of areax structures is + * created for each unique area. The final areax linked + * list has at its head the 'unique' area structure linked + * to the linked areax structures (one areax structure for + * each A directive for this area). + */ +struct areax +{ + struct areax *a_axp; /* Area extension link */ + struct area *a_bap; /* Base area link */ + struct head *a_bhp; /* Base header link */ + addr_t a_addr; /* Beginning address of section */ + addr_t a_size; /* Size of the area in section */ +}; + +/* + * A sym structure is created for every unique symbol + * referenced/defined while reading the REL files. The + * struct sym contains the symbol's name, a flag value + * (not used in this linker), a symbol type denoting + * referenced/defined, and an address which is loaded + * with the relative address within the area in which + * the symbol was defined. The sym structure also + * contains a link to the area where the symbol was defined. + * The sym structures are linked into linked lists using + * the symbol link element. + */ +struct sym +{ + struct sym *s_sp; /* Symbol link */ + struct areax *s_axp; /* Symbol area link */ + char s_type; /* Symbol subtype */ + char s_flag; /* Flag byte */ + addr_t s_addr; /* Address */ + char *s_id; /* Name: JLH change from [NCPS] */ +}; + +/* + * The structure lfile contains a pointer to a + * file specification string, the file type, and + * a link to the next lfile structure. + */ +struct lfile +{ + struct lfile *f_flp; /* lfile link */ + int f_type; /* File type */ + char *f_idp; /* Pointer to file spec */ +}; + +/* + * The struct base contains a pointer to a + * base definition string and a link to the next + * base structure. + */ +struct base +{ + struct base *b_base; /* Base link */ + char *b_strp; /* String pointer */ +}; + +/* + * The struct globl contains a pointer to a + * global definition string and a link to the next + * global structure. + */ +struct globl +{ + struct globl *g_globl; /* Global link */ + char *g_strp; /* String pointer */ +}; + +/* + * A structure sdp is created for each 'unique' paged + * area definition found as the REL files are read. + * As P directives are read from the REL files a linked + * list of unique sdp structures is created by placing a + * link to the new sdp structure in the previous area structure. + */ +struct sdp +{ + struct area *s_area; /* Paged Area link */ + struct areax *s_areax; /* Paged Area Extension Link */ + addr_t s_addr; /* Page address offset */ +}; + +/* + * The structure rerr is loaded with the information + * required to report an error during the linking + * process. The structure contains an index value + * which selects the areax structure from the header + * areax structure list, a mode value which selects + * symbol or area relocation, the base address in the + * area section, an area/symbol list index value, and + * an area/symbol offset value. + */ +struct rerr +{ + int aindex; /* Linking area */ + int mode; /* Relocation mode */ + addr_t rtbase; /* Base address in section */ + int rindex; /* Area/Symbol reloaction index */ + addr_t rval; /* Area/Symbol offset value */ +}; + +/* + * The structure lbpath is created for each library + * path specification input by the -k option. The + * lbpath structures are linked into a list using + * the next link element. + */ +struct lbpath { + struct lbpath *next; + char *path; +}; + +/* + * The structure lbname is created for all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file. The element path points to + * the path string, element libfil points to the library + * file string, and the element libspc is the concatenation + * of the valid path and libfil strings. + * + * The lbpath structures are linked into a list + * using the next link element. + * + * Each library file contains a list of object files + * that are contained in the particular library. e.g.: + * + * \iolib\termio + * \inilib\termio + * + * Only one specification per line is allowed. + */ +struct lbname { + struct lbname *next; + char *path; + char *libfil; + char *libspc; +}; + +/* + * The function fndsym() searches through all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file for a symbol definition. + * + * The structure lbfile is created for the first library + * object file which contains the definition for the + * specified undefined symbol. + * + * The element libspc points to the library file path specification + * and element relfil points to the object file specification string. + * The element filspc is the complete path/file specification for + * the library file to be imported into the linker. The + * file specicifation may be formed in one of two ways: + * + * (1) If the library file contained an absolute + * path/file specification then this becomes filspc. + * (i.e. C:\...) + * + * (2) If the library file contains a relative path/file + * specification then the concatenation of the path + * and this file specification becomes filspc. + * (i.e. \...) + * + * The lbpath structures are linked into a list + * using the next link element. + */ +struct lbfile { + struct lbfile *next; + char *libspc; + char *relfil; + char *filspc; +}; + +/* + * External Definitions for all Global Variables + */ + +extern char *_abs_; /* = { ". .ABS." }; + */ +extern int lkerr; /* ASLink error flag + */ +extern char *ip; /* pointer into the REL file + * text line in ib[] + */ +extern char ib[NINPUT]; /* REL file text line + */ +extern char *rp; /* pointer into the LST file + * text line in rb[] + */ +extern char rb[NINPUT]; /* LST file text line being + * address relocated + */ +extern char ctype[]; /* array of character types, one per + * ASCII character + */ + +/* + * Character Type Definitions + */ +#define SPACE 0000 +#define ETC 0000 +#define LETTER 0001 +#define DIGIT 0002 +#define BINOP 0004 +#define RAD2 0010 +#define RAD8 0020 +#define RAD10 0040 +#define RAD16 0100 +#define ILL 0200 + +#define DGT2 DIGIT|RAD16|RAD10|RAD8|RAD2 +#define DGT8 DIGIT|RAD16|RAD10|RAD8 +#define DGT10 DIGIT|RAD16|RAD10 +#define LTR16 LETTER|RAD16 + +#if CASE_SENSITIVE +#else +extern char ccase[]; /* an array of characters which + * perform the case translation function + */ +#endif + +extern struct lfile *filep; /* The pointers (lfile *) filep, + * (lfile *) cfp, and (FILE *) sfp + * are used in conjunction with + * the routine getline() to read + * asmlnk commands from + * (1) the standard input or + * (2) or a command file + * and to read the REL files + * sequentially as defined by the + * asmlnk input commands. + * + * The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + */ +extern struct lfile *cfp; /* The pointer *cfp points to the + * current lfile structure + */ +extern struct lfile *startp;/* asmlnk startup file structure + */ +extern struct lfile *linkp; /* pointer to first lfile structure + * containing an input REL file + * specification + */ +extern struct lfile *lfp; /* pointer to current lfile structure + * being processed by parse() + */ +extern struct head *headp; /* The pointer to the first + * head structure of a linked list + */ +extern struct head *hp; /* Pointer to the current + * head structure + */ +extern struct area *areap; /* The pointer to the first + * area structure of a linked list + */ +extern struct area *ap; /* Pointer to the current + * area structure + */ +extern struct areax *axp; /* Pointer to the current + * areax structure + */ +extern struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ +extern struct base *basep; /* The pointer to the first + * base structure + */ +extern struct base *bsp; /* Pointer to the current + * base structure + */ +extern struct globl *globlp;/* The pointer to the first + * globl structure + */ +extern struct globl *gsp; /* Pointer to the current + * globl structure + */ +extern struct sdp sdp; /* Base Paged structure + */ +extern struct rerr rerr; /* Structure containing the + * linker error information + */ +extern FILE *ofp; /* Linker Output file handle + */ +extern FILE *mfp; /* Map output file handle + */ +extern FILE *jfp; /* NoICE output file handle + */ +extern FILE *rfp; /* File handle for output + * address relocated ASxxxx + * listing file + */ +extern FILE *sfp; /* The file handle sfp points to the + * currently open file + */ +extern FILE *tfp; /* File handle for input + * ASxxxx listing file + */ +extern FILE *dfp; /* File handle for debug info output + */ +extern int dflag; /* Output debug information flag + */ +extern int oflag; /* Output file type flag + */ +extern int mflag; /* Map output flag + */ +extern int jflag; /* NoICE output flag + */ +extern int xflag; /* Map file radix type flag + */ +extern int pflag; /* print linker command file flag + */ +extern int uflag; /* Listing relocation flag + */ +extern int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +extern int line; /* current line number + */ +extern int page; /* current page number + */ +extern int lop; /* current line number on page + */ +extern int pass; /* linker pass number + */ +extern int rtcnt; /* count of elements in the + * rtval[] and rtflg[] arrays + */ +extern addr_t rtval[]; /* data associated with relocation + */ +extern int rtflg[]; /* indicates if rtval[] value is + * to be sent to the output file. + * (always set in this linker) + */ +extern int hilo; /* REL file byte ordering + */ +extern int gline; /* LST file relocation active + * for current line + */ +extern int gcntr; /* LST file relocation active + * counter + */ +extern struct lbpath *lbphead; /* pointer to the first + * library path structure + */ +extern struct lbname *lbnhead; /* pointer to the first + * library name structure + */ +extern struct lbfile *lbfhead; /* pointer to the first + * library file structure + */ +extern addr_t iram_size; /* internal ram size + */ + + +/* C Library function definitions */ +/* for reference only +extern VOID exit(); +extern int fclose(); +extern char * fgets(); +extern FILE * fopen(); +extern int fprintf(); +extern VOID free(); +extern VOID * malloc(); +extern char putc(); +extern char * strcpy(); +extern int strlen(); +extern char * strncpy(); +*/ + +/* Program function definitions */ + +/* lkmain.c */ +extern FILE * afile(); +extern VOID bassav(); +extern VOID gblsav(); +extern VOID iramsav(); +extern VOID iramcheck(); +extern VOID link(); +extern VOID lkexit(); +extern int main(); +extern VOID map(); +extern int parse(); +extern VOID setbas(); +extern VOID setgbl(); +extern VOID usage(); +extern VOID copyfile(); + +/* lklex.c */ +extern char endline(); +extern char get(); +extern VOID getfid(); +extern VOID getid(); +extern int getline(); +extern int getmap(); +extern char getnb(); +extern int more(); +extern VOID skip(); +extern VOID unget(); + +/* lkarea.c */ +extern VOID lkparea(); +extern VOID lnkarea(); +extern VOID lnksect(); +extern VOID newarea(); + +/* lkhead.c */ +extern VOID module(); +extern VOID newhead(); + +/* lksym.c */ +extern int hash(); +extern struct sym * lkpsym(); +extern VOID * new(); +extern struct sym * newsym(); +extern VOID symdef(); +extern int symeq(); +extern VOID syminit(); +extern VOID symmod(); +extern addr_t symval(); + +/* lkeval.c */ +extern int digit(); +extern addr_t eval(); +extern addr_t expr(); +extern int oprio(); +extern addr_t term(); + +/* lklist.c */ +extern int dgt(); +extern VOID lkulist(); +extern VOID lkalist(); +extern VOID lkglist(); +extern VOID lstarea(); +extern VOID newpag(); +extern VOID slew(); + +/* lkrloc.c */ +extern addr_t adb_b(); +extern addr_t adb_hi(); +extern addr_t adb_lo(); +extern addr_t adw_w(); +extern addr_t adw_hi(); +extern addr_t adw_lo(); +extern addr_t evword(); +extern VOID rele(); +extern VOID reloc(); +extern VOID relt(); +extern VOID relr(); +extern VOID relp(); +extern VOID relerr(); +extern char * errmsg[]; +extern VOID errdmp(); +extern VOID relerp(); +extern VOID erpdmp(); +extern VOID prntval(); + +/* lklibr.c */ +extern VOID addfile(); +extern VOID addlib(); +extern VOID addpath(); +extern int fndsym(); +extern VOID library(); +extern VOID loadfile(); +extern VOID search(); + +/* lks19.c */ +extern VOID s19(); + +/* lkihx.c */ +extern VOID ihx(); + +/* lkstore.c */ +extern char *StoreString( char *str ); + +/* lknoice.c */ +extern void DefineNoICE( char *name, addr_t value, int page ); + +/* SD added this to change + strcmpi --> strcmp (strcmpi NOT ANSI) */ +#define strcmpi strcmp diff --git a/as/mcs51/aslink.mak b/as/mcs51/aslink.mak new file mode 100644 index 00000000..300803d9 --- /dev/null +++ b/as/mcs51/aslink.mak @@ -0,0 +1,263 @@ +ORIGIN = Symantec C++ +ORIGIN_VER = Version 7.00 +VERSION = RELEASE + +!IFDEF SUB_DEBUG +DEBUG = $(SUB_DEBUG) +NDEBUG = !$(SUB_DEBUG) +!ELSE +DEBUG = 0 +NDEBUG = 1 +!ENDIF + +PROJ = ASLINK +APPTYPE = DOS EXE +PROJTYPE = EXE + +CC = SC +CPP = SPP +MAKE = SMAKE +RC = RCC +HC = HC31 +ASM = SC +DISASM = OBJ2ASM +LNK = LINK +DLLS = + +HEADERS = ..\linksrc\aslink.h + +DEFFILE = ASLINK.DEF + +!IF $(DEBUG) +OUTPUTDIR = . +CREATEOUTPUTDIR = +TARGETDIR = . +CREATETARGETDIR = + +LIBS = + +CFLAGS = -A -Jm -J -ms -o+time -S -2 -a2 -c +LFLAGS = /PACKF +DEFINES = -D_DEBUG=1 +!ELSE +OUTPUTDIR = . +CREATEOUTPUTDIR = +TARGETDIR = . +CREATETARGETDIR = + +LIBS = + +CFLAGS = -A -Jm -J -ms -o+time -S -2 -a2 -c +LFLAGS = /PACKF +DEFINES = +!ENDIF + +HFLAGS = $(CFLAGS) +MFLAGS = MASTERPROJ=$(PROJ) +LIBFLAGS = /C +RESFLAGS = +DEBUGGERFLAGS = -LOADSYMBOLS +AFLAGS = $(CFLAGS) +HELPFLAGS = + +MODEL = S + +PAR = PROJS BATS OBJS + +RCDEFINES = + +LIBDIRS = + +INCLUDES = -Ic:\asxxxx\linksrc + +INCLUDEDOBJS = + +OBJS = $(OUTPUTDIR)\lkarea.OBJ $(OUTPUTDIR)\lkdata.OBJ $(OUTPUTDIR)\lkeval.OBJ \ + $(OUTPUTDIR)\lkhead.OBJ $(OUTPUTDIR)\lkihx.OBJ $(OUTPUTDIR)\lklex.OBJ $(OUTPUTDIR)\lklibr.OBJ \ + $(OUTPUTDIR)\lklist.OBJ $(OUTPUTDIR)\lkmain.OBJ $(OUTPUTDIR)\lkrloc.OBJ $(OUTPUTDIR)\lks19.OBJ \ + $(OUTPUTDIR)\lksym.OBJ + +RCFILES = + +RESFILES = + +SYMS = + +HELPFILES = + +BATS = + +.SUFFIXES: .C .CP .CPP .CXX .CC .H .HPP .HXX .COM .EXE .DLL .LIB .RTF .DLG .ASM .RES .RC .OBJ + +.C.OBJ: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$*.obj $*.c + +.CPP.OBJ: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$*.obj $*.cpp + +.CXX.OBJ: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$*.obj $*.cxx + +.CC.OBJ: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$*.obj $*.cc + +.CP.OBJ: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$*.obj $*.cp + +.H.SYM: + $(CC) $(HFLAGS) $(DEFINES) $(INCLUDES) -HF -o$(*B).sym $*.h + +.HPP.SYM: + $(CC) $(HFLAGS) $(DEFINES) $(INCLUDES) -HF -o$(*B).sym $*.hpp + +.HXX.SYM: + $(CC) $(HFLAGS) $(DEFINES) $(INCLUDES) -HF -o$(*B).sym $*.hxx + +.C.EXP: + $(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) $*.c -o$*.lst + +.CPP.EXP: + $(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) $*.cpp -o$*.lst + +.CXX.EXP: + $(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) $*.cxx -o$*.lst + +.CP.EXP: + $(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) $*.cp -o$*.lst + +.CC.EXP: + $(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) $*.cc -o$*.lst + +.ASM.EXP: + $(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) $*.asm -o$*.lst + +.OBJ.COD: + $(DISASM) $*.OBJ >$*.cod + +.OBJ.EXE: + $(LNK) $(LFLAGS) @$(PROJ).LNK + +.RTF.HLP: + $(HC) $(HELPFLAGS) $*.HPJ + +.ASM.OBJ: + $(ASM) $(AFLAGS) $(DEFINES) $(INCLUDES) -o$*.obj $*.asm + +.RC.RES: + $(RC) $(RCDEFINES) $(RESFLAGS) $(INCLUDES) $*.rc -o$*.res + +.DLG.RES: + echo ^#include "windows.h" >$$$*.rc + echo ^IF EXIST "$*.h" >>$$$*.rc + echo ^#include "$*.h" >>$$$*.rc + echo ^#include "$*.dlg" >>$$$*.rc + $(RC) $(RCDEFINES) $(RESFLAGS) $(INCLUDES) $$$*.rc + -del $*.res + -ren $$$*.res $*.res + + + +all: createdir $(PRECOMPILE) $(SYMS) $(OBJS) $(INCLUDEDOBJS) $(POSTCOMPILE) $(TARGETDIR)\$(PROJ).$(PROJTYPE) $(POSTLINK) _done + +createdir: + $(CREATEOUTPUTDIR) + $(CREATETARGETDIR) + +$(TARGETDIR)\$(PROJ).$(PROJTYPE): $(OBJS) $(INCLUDEDOBJS) $(RCFILES) $(RESFILES) $(HELPFILES) + $(LNK) $(LFLAGS) @$(PROJ).LNK; + -del $(TARGETDIR)\$(PROJ).$(PROJTYPE) + -ren $(TARGETDIR)\$$SCW$$.$(PROJTYPE) $(PROJ).$(PROJTYPE) + -echo $(TARGETDIR)\$(PROJ).$(PROJTYPE) built + +_done: + -echo $(PROJ).$(PROJTYPE) done + +buildall: clean all + + +clean: + -del $(TARGETDIR)\$$SCW$$.$(PROJTYPE) + -del $(TARGETDIR)\$(PROJ).CLE + -del $(OUTPUTDIR)\SCPH.SYM + -del $(OBJS) + +cleanres: + +res: cleanres $(RCFILES) all + + +link: + $(LNK) $(LFLAGS) @$(PROJ).LNK; + -del $(TARGETDIR)\$(PROJ).$(PROJTYPE) + -ren $(TARGETDIR)\$$SCW$$.$(PROJTYPE) $(PROJ).$(PROJTYPE) + + + + +!IF EXIST (ASLINK.dpd) +!INCLUDE ASLINK.dpd +!ENDIF + + + +$(OUTPUTDIR)\lkarea.OBJ: ..\linksrc\lkarea.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lkarea.obj ..\linksrc\lkarea.c + + + +$(OUTPUTDIR)\lkdata.OBJ: ..\linksrc\lkdata.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lkdata.obj ..\linksrc\lkdata.c + + + +$(OUTPUTDIR)\lkeval.OBJ: ..\linksrc\lkeval.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lkeval.obj ..\linksrc\lkeval.c + + + +$(OUTPUTDIR)\lkhead.OBJ: ..\linksrc\lkhead.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lkhead.obj ..\linksrc\lkhead.c + + + +$(OUTPUTDIR)\lkihx.OBJ: ..\linksrc\lkihx.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lkihx.obj ..\linksrc\lkihx.c + + + +$(OUTPUTDIR)\lklex.OBJ: ..\linksrc\lklex.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lklex.obj ..\linksrc\lklex.c + + + +$(OUTPUTDIR)\lklibr.OBJ: ..\linksrc\lklibr.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lklibr.obj ..\linksrc\lklibr.c + + + +$(OUTPUTDIR)\lklist.OBJ: ..\linksrc\lklist.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lklist.obj ..\linksrc\lklist.c + + + +$(OUTPUTDIR)\lkmain.OBJ: ..\linksrc\lkmain.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lkmain.obj ..\linksrc\lkmain.c + + + +$(OUTPUTDIR)\lkrloc.OBJ: ..\linksrc\lkrloc.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lkrloc.obj ..\linksrc\lkrloc.c + + + +$(OUTPUTDIR)\lks19.OBJ: ..\linksrc\lks19.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lks19.obj ..\linksrc\lks19.c + + + +$(OUTPUTDIR)\lksym.OBJ: ..\linksrc\lksym.c + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o$(OUTPUTDIR)\lksym.obj ..\linksrc\lksym.c + + + + diff --git a/as/mcs51/aslist.c b/as/mcs51/aslist.c new file mode 100644 index 00000000..3288c18f --- /dev/null +++ b/as/mcs51/aslist.c @@ -0,0 +1,725 @@ +/* aslist.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - lstsym: show s_id as string rather than array [NCPS] + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module aslist.c + * + * The module aslist.c contains all the functions used + * to generate the assembler list and symbol output files. + * + * aslist.c contains the following functions: + * VOID list() + * VOID list1() + * VOID list2() + * VOID slew() + * VOID lstsym() + * + * The module aslist.c contains no local/static variables + */ + +/*)Function VOID list() + * + * The function list() generates the listing output + * which includes the input source, line numbers, + * and generated code. Numerical output may be selected + * as hexadecimal, decimal, or octal. + * + * local variables: + * int * wp pointer to the assembled data bytes + * int * wpt pointer to the data byte mode + * int nb computed number of assembled bytes + * + * global variables: + * int cb[] array of assembler output values + * int cbt[] array of assembler relocation types + * describing the data in cb[] + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * char eb[] array of generated error codes + * char * ep pointer into error list + * array eb[] + * char ib[] assembler-source text line + * FILE * lfp list output file handle + * int line current assembler source line number + * int lmode listing mode + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * VOID list1() aslist.c + * int putc() c_library + * VOID slew() asslist.c + * + * side effects: + * Listing or symbol output updated. + */ + +VOID +list() +{ + register char *wp; + register int *wpt; + register int nb; + + if (lfp == NULL || lmode == NLIST) + return; + + /* + * Get Correct Line Number + */ + if (incfil >= 0) { + line = incline[incfil]; + if (line == 0) { + if (incfil > 0) { + line = incline[incfil-1]; + } else { + line = srcline[cfile]; + } + } + } else { + line = srcline[cfile]; + } + + /* + * Move to next line. + */ + slew(lfp, pflag); + + /* + * Output a maximum of NERR error codes with listing. + */ + while (ep < &eb[NERR]) + *ep++ = ' '; + fprintf(lfp, "%.2s", eb); + + /* + * Source listing only option. + */ + if (lmode == SLIST) { + fprintf(lfp, "%24s%5u %s\n", "", line, ib); + return; + } + if (lmode == ALIST) { + outchk(HUGE,HUGE); + } + + /* + * HEX output Option. + */ + if (xflag == 0) { /* HEX */ + /* + * Equate only + */ + if (lmode == ELIST) { + fprintf(lfp, "%18s%04X", "", laddr); + fprintf(lfp, " %5u %s\n", line, ib); + return; + } + + /* + * Address (with allocation) + */ + fprintf(lfp, " %04X", laddr); + if (lmode == ALIST || lmode == BLIST) { + fprintf(lfp, "%19s%5u %s\n", "", line, ib); + outdot(); + return; + } + wp = cb; + wpt = cbt; + nb = (int) (cp - cb); + + /* + * First line of output for this source line with data. + */ + list1(wp, wpt, nb, 1); + fprintf(lfp, " %5u %s\n", line, ib); + + /* + * Subsequent lines of output if more data. + */ + while ((nb -= 6) > 0) { + wp += 6; + wpt += 6; + slew(lfp, 0); + fprintf(lfp, "%7s", ""); + list1(wp, wpt, nb, 0); + putc('\n', lfp); + } + } else + /* + * OCTAL output Option. + */ + if (xflag == 1) { /* OCTAL */ + /* + * Equate only + */ + if (lmode == ELIST) { + fprintf(lfp, "%16s%06o", "", laddr); + fprintf(lfp, " %5u %s\n", line, ib); + return; + } + + /* + * Address (with allocation) + */ + fprintf(lfp, " %06o", laddr); + if (lmode == ALIST || lmode == BLIST) { + fprintf(lfp, "%17s%5u %s\n", "", line, ib); + outdot(); + return; + } + wp = cb; + wpt = cbt; + nb = (int) (cp - cb); + + /* + * First line of output for this source line with data. + */ + list1(wp, wpt, nb, 1); + fprintf(lfp, " %5u %s\n", line, ib); + + /* + * Subsequent lines of output if more data. + */ + while ((nb -= 4) > 0) { + wp += 4; + wpt += 4; + slew(lfp, 0); + fprintf(lfp, "%9s", ""); + list1(wp, wpt, nb, 0); + putc('\n', lfp); + } + } else + /* + * DECIMAL output Option. + */ + if (xflag == 2) { /* DECIMAL */ + /* + * Equate only + */ + if (lmode == ELIST) { + fprintf(lfp, "%16s%05u", "", laddr); + fprintf(lfp, " %5u %s\n", line, ib); + return; + } + + /* + * Address (with allocation) + */ + fprintf(lfp, " %05u", laddr); + if (lmode == ALIST || lmode == BLIST) { + fprintf(lfp, "%17s%5u %s\n", "", line, ib); + outdot(); + return; + } + wp = cb; + wpt = cbt; + nb = (int) (cp - cb); + + /* + * First line of output for this source line with data. + */ + list1(wp, wpt, nb, 1); + fprintf(lfp, " %5u %s\n", line, ib); + + /* + * Subsequent lines of output if more data. + */ + while ((nb -= 4) > 0) { + wp += 4; + wpt += 4; + slew(lfp, 0); + fprintf(lfp, "%9s", ""); + list1(wp, wpt, nb, 0); + putc('\n', lfp); + } + } +} + +/*)Function VOID list1(wp, wpt, nw, f) + * + * int f fill blank fields (1) + * int nb number of data bytes + * int * wp pointer to data bytes + * int * wpt pointer to data byte mode + * + * local variables: + * int i loop counter + * + * global variables: + * int xflag -x, listing radix flag + * + * functions called: + * VOID list2() asslist.c + * int fprintf() c_library + * + * side effects: + * Data formatted and output to listing. + */ + +VOID +list1(wp, wpt, nb, f) +register char *wp; +register int *wpt, nb, f; +{ + register int i; + + /* + * HEX output Option. + */ + if (xflag == 0) { /* HEX */ + /* + * Bound number of words to HEX maximum per line. + */ + if (nb > 6) + nb = 6; + + /* + * Output bytes. + */ + for (i=0; i 4) + nb = 4; + + /* + * Output bytes. + */ + for (i=0; i 4) + nb = 4; + + /* + * Output bytes. + */ + for (i=0; i= 2) { + if (t & R_RELOC) { + if (t & (R_PAG0|R_PAG)) { + c = '*'; + } else if (t & R_USGN) { + c = 'u'; + } else if (t & R_PCR) { + c = 'p'; + } else { + c = 'r'; + } + if (t & R_HIGH) c += 1; + } + } + + /* + * Output the selected mode. + */ + putc(c, lfp); +} + +/*)Function VOID slew(fp, flag) + * + * FILE * fp file handle for listing + * int flag enable pagination + * + * The function slew() increments the page line count. + * If the page overflows and pagination is enabled: + * 1) put out a page skip, + * 2) a title, + * 3) a subtitle, + * 4) and reset the line count. + * + * local variables: + * none + * + * global variables: + * char cpu[] cpu type string + * int lop current line number on page + * int page current page number + * char stb[] Subtitle string buffer + * char tb[] Title string buffer + * + * functions called: + * int fprintf() c_library + * + * side effects: + * Increments page line counter, on overflow + * a new page header is output to the listing file. + */ + +VOID +slew(fp,flag) +FILE *fp; +int flag; +{ + if ((lop++ >= NLPP) && flag) { + fprintf(fp, "\fASxxxx Assembler %s (%s), page %u.\n", + VERSION, cpu, ++page); + fprintf(fp, "%s\n", tb); + fprintf(fp, "%s\n\n", stb); + lop = 5; + } +} + +/*)Function VOID lstsym(fp) + * + * FILE * fp file handle for output + * + * The function lstsym() outputs alphabetically + * sorted symbol and area tables. + * + * local variables: + * int c temporary + * int i loop counter + * int j temporary + * int k temporary + * char * ptr pointer to an id string + * int nmsym number of symbols + * int narea number of areas + * sym * sp pointer to symbol structure + * sym ** p pointer to an array of + * pointers to symbol structures + * area * ap pointer to an area structure + * + * global variables: + * area * areap pointer to an area structure + * char aretbl[] string "Area Table" + * sym dot defined as sym[0] + * char stb[] Subtitle string buffer + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * char symtbl[] string "Symbol Table" + * FILE * tfp symbol table output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * int putc() c_library + * VOID slew() aslist.c + * int strcmp() c_library + * char * strcpy() c_library + * + * side effects: + * Symbol and area tables output. + */ + +VOID +lstsym(fp) +FILE *fp; +{ + register int c, i, j, k; + register char *ptr; + int nmsym, narea; + struct sym *sp; + struct sym **p; + struct area *ap; + + /* + * Symbol Table Header + */ + strcpy(stb, &symtbl[0]); + lop = NLPP; + if (fp == tfp) + page = 0; + slew(fp, 1); + + /* + * Find number of symbols + */ + nmsym = 0; + for (i=0; is_sp; + } + } + if (nmsym == 0) + goto atable; + + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ((p = (struct sym **) malloc(sizeof((struct sym *) sp)*nmsym)) + == NULL) { + fprintf(fp, "Insufficient space to build Symbol Table.\n"); + return; + } + nmsym = 0; + for (i=0; is_sp; + } + } + + /* + * Bubble Sort on Symbol Table Array + */ + j = 1; + c = nmsym - 1; + while (j) { + j = 0; + for (i=0; is_id[0],&p[i+1]->s_id[0]) > 0) { + j = 1; + sp = p[i+1]; + p[i+1] = p[i]; + p[i] = sp; + } + } + } + + /* + * Symbol Table Output + */ + for (i=0; is_area) { + j = sp->s_area->a_ref; + if (xflag == 0) { + fprintf(fp, " %2X ", j); + } else + if (xflag == 1) { + fprintf(fp, "%3o ", j); + } else + if (xflag == 2) { + fprintf(fp, "%3u ", j); + } + } else { + fprintf(fp, " "); + } + ptr = &sp->s_id[0]; + fprintf(fp, "%-60s", ptr ); /* JLH */ + + if (sp->s_flag & S_ASG) { + putc('=', fp); + } else { + putc(' ', fp); + } + if (sp->s_type == S_NEW) { + if (xflag == 0) { + fprintf(fp, " **** "); + } else + if (xflag == 1) { + fprintf(fp, "****** "); + } else + if (xflag == 2) { + fprintf(fp, " ***** "); + } + } else { + j = sp->s_addr; + if (xflag == 0) { + fprintf(fp, " %04X ", j); + } else + if (xflag == 1) { + fprintf(fp, "%06o ", j); + } else + if (xflag == 2) { + fprintf(fp, " %05u ", j); + } + } + j = 0; + if (sp->s_flag & S_GBL) { + putc('G', fp); + ++j; + } + if (sp->s_area != NULL) { + putc('R', fp); + ++j; + } + if (sp->s_type == S_NEW) { + putc('X', fp); + ++j; + } +#if NCPS-8 + putc('\n', fp); + slew(fp, 0); + ++i; +#else + if (++i % 3 == 0) { + putc('\n', fp); + slew(fp, pflag); + } else + if (i < nmsym) { + while (j++ < 4) + putc(' ', fp); + fprintf(fp, "| "); + } +#endif + } + putc('\n', fp); + + /* + * Area Table Header + */ + +atable: + strcpy(stb, &aretbl[0]); + lop = NLPP; + slew(fp, 1); + + /* + * Area Table Output + */ + narea = 0; + ap = areap; + while (ap) { + ++narea; + ap = ap->a_ap; + } + for (i=0; ia_ap; + j = ap->a_ref; + if (xflag == 0) { + fprintf(fp, " %2X ", j); + } else + if (xflag == 1) { + fprintf(fp, " %3o ", j); + } else + if (xflag == 2) { + fprintf(fp, " %3u ", j); + } + ptr = &ap->a_id[0]; + while (ptr < &ap->a_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, fp); + } else { + putc(' ', fp); + } + } + j = ap->a_size; + k = ap->a_flag; + if (xflag==0) { + fprintf(fp, " size %4X flags %X\n", j, k); + } else + if (xflag==1) { + fprintf(fp, " size %6o flags %o\n", j, k); + } else + if (xflag==2) { + fprintf(fp, " size %5u flags %u\n", j, k); + } + } +} diff --git a/as/mcs51/asm.h b/as/mcs51/asm.h new file mode 100644 index 00000000..e0229054 --- /dev/null +++ b/as/mcs51/asm.h @@ -0,0 +1,625 @@ +/* asm.h */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - add proto for StoreString + * - change s_id from [NCPS] to pointer + * - change m_id from [NCPS] to pointer + * - change NCPS to 80 + * - case sensitive + * - add R_J11 for 8051 assembler + * - add outr11 prototype for 8051 assembler + * - always define "ccase" + * 2-Nov-97 JLH: + * - add jflag for debug control + * - prototypes for DefineNoICE_Line + * 30-Jan-98 JLH: + * - add memory space flags to a_flag for 8051 + */ + +#define VERSION "V01.70 + NoICE + SDCC mods Feb-1999" + +/* + * Case Sensitivity Flag + */ +#define CASE_SENSITIVE 1 + +/*)Module asm.h + * + * The module asm.h contains the definitions for constants, + * structures, global variables, and ASxxxx functions + * contained in the ASxxxx.c files. The two functions + * and three global variables from the machine dependent + * files are also defined. + */ + +/* + * compiler/operating system specific definitions + */ + +/* DECUS C void definition */ +/* File/extension seperator */ + +#ifdef decus +#define VOID char +#define FSEPX '.' +#endif + +/* PDOS C void definition */ +/* File/extension seperator */ + +#ifdef PDOS +#define VOID char +#define FSEPX ':' +#endif + +/* Default void definition */ +/* File/extension seperator */ + +#ifndef VOID +#define VOID void +#define FSEPX '.' +#define OTHERSYSTEM +#endif + +/* + * Assembler definitions. + */ +#define LFTERM '(' /* Left expression delimeter */ +#define RTTERM ')' /* Right expression delimeter */ + +#define NCPS 80 /* Chars. per symbol (JLH: change from 8) */ +#define HUGE 1000 /* A huge number */ +#define NERR 3 /* Errors per line */ +#define NINPUT 128 /* Input buffer size */ +#define NCODE 128 /* Listing code buffer size */ +#define NTITL 64 /* Title buffer size */ +#define NSBTL 64 /* SubTitle buffer size */ +#define NHASH 64 /* Buckets in hash table */ +#define HMASK 077 /* Hash mask */ +#define NLPP 60 /* Lines per page */ +#define MAXFIL 6 /* Maximum command line input files */ +#define MAXINC 6 /* Maximum nesting of include files */ +#define MAXIF 10 /* Maximum nesting of if/else/endif */ +#define FILSPC 80 /* Chars. in filespec */ + +#define NLIST 0 /* No listing */ +#define SLIST 1 /* Source only */ +#define ALIST 2 /* Address only */ +#define BLIST 3 /* Address only with allocation */ +#define CLIST 4 /* Code */ +#define ELIST 5 /* Equate only */ + +#define dot sym[0] /* Dot, current loc */ +#define dca area[0] /* Dca, default code area */ + + +typedef unsigned int addr_t; + +/* + * The area structure contains the parameter values for a + * specific program or data section. The area structure + * is a linked list of areas. The initial default area + * is "_CODE" defined in asdata.c, the next area structure + * will be linked to this structure through the structure + * element 'struct area *a_ap'. The structure contains the + * area name, area reference number ("_CODE" is 0) determined + * by the order of .area directives, area size determined + * from the total code and/or data in an area, area fuzz is + * a variable used to track pass to pass changes in the + * area size caused by variable length instruction formats, + * and area flags which specify the area's relocation type. + */ +struct area +{ + struct area *a_ap; /* Area link */ + char a_id[NCPS]; /* Area Name */ + int a_ref; /* Ref. number */ + addr_t a_size; /* Area size */ + addr_t a_fuzz; /* Area fuzz */ + int a_flag; /* Area flags */ +}; + +/* + * The "A_" area constants define values used in + * generating the assembler area output data. + * + * Area flags + * + * 7 6 5 4 3 2 1 0 + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * | BIT |XDATA|DATA | PAG | ABS | OVR | | | + * +-----+-----+-----+-----+-----+-----+-----+-----+ + */ + +#define A_CON 0000 /* Concatenating */ +#define A_OVR 0004 /* Overlaying */ +#define A_REL 0000 /* Relocatable */ +#define A_ABS 0010 /* absolute */ +#define A_NOPAG 0000 /* Non-Paged */ +#define A_PAG 0020 /* Paged */ + +/* Additional flags for 8051 address spaces */ +#define A_DATA 0000 /* data space (default)*/ +#define A_CODE 0040 /* code space */ +#define A_XDATA 0100 /* external data space */ +#define A_BIT 0200 /* bit addressable space */ + +/* + * The "R_" relocation constants define values used in + * generating the assembler relocation output data for + * areas, symbols, and code. + * + * Relocation flags + * + * 7 6 5 4 3 2 1 0 + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * | MSB | PAGn| PAG0| USGN| BYT2| PCR | SYM | BYT | + * +-----+-----+-----+-----+-----+-----+-----+-----+ + */ + +#define R_WORD 0000 /* 16 bit */ +#define R_BYTE 0001 /* 8 bit */ + +#define R_AREA 0000 /* Base type */ +#define R_SYM 0002 + +#define R_NORM 0000 /* PC adjust */ +#define R_PCR 0004 + +#define R_BYT1 0000 /* Byte count for R_BYTE = 1 */ +#define R_BYT2 0010 /* Byte count for R_BYTE = 2 */ + +#define R_SGND 0000 /* Signed Byte */ +#define R_USGN 0020 /* Unsigned Byte */ + +#define R_NOPAG 0000 /* Page Mode */ +#define R_PAG0 0040 /* Page '0' */ +#define R_PAG 0100 /* Page 'nnn' */ + +#define R_LSB 0000 /* low byte */ +#define R_MSB 0200 /* high byte */ + +#define R_J11 (R_WORD|R_BYT2) /* JLH: 11 bit JMP and CALL (8051) */ + +/* + * Listing Control Flags + */ + +#define R_HIGH 0040000 /* High Byte */ +#define R_RELOC 0100000 /* Relocation */ + +#define R_DEF 00 /* Global def. */ +#define R_REF 01 /* Global ref. */ +#define R_REL 00 /* Relocatable */ +#define R_ABS 02 /* Absolute */ +#define R_GBL 00 /* Global */ +#define R_LCL 04 /* Local */ + +/* + * The mne structure is a linked list of the assembler + * mnemonics and directives. The list of mnemonics and + * directives contained in the device dependent file + * xxxpst.c are hashed and linked into NHASH lists in + * module assym.c by syminit(). The structure contains + * the mnemonic/directive name, a subtype which directs + * the evaluation of this mnemonic/directive, a flag which + * is used to detect the end of the mnemonic/directive + * list in xxxpst.c, and a value which is normally + * associated with the assembler mnemonic base instruction + * value. + */ +struct mne +{ + struct mne *m_mp; /* Hash link */ + char *m_id; /* Mnemonic JLH: change from [NCPS] */ + char m_type; /* Mnemonic subtype */ + char m_flag; /* Mnemonic flags */ + addr_t m_valu; /* Value */ +}; + +/* + * The sym structure is a linked list of symbols defined + * in the assembler source files. The first symbol is "." + * defined in asdata.c. The entry 'struct tsym *s_tsym' + * links any temporary symbols following this symbol and + * preceeding the next normal symbol. The structure also + * contains the symbol's name, type (USER or NEW), flag + * (global, assigned, and multiply defined), a pointer + * to the area structure defining where the symbol is + * located, a reference number assigned by outgsd() in + * asout.c, and the symbols address relative to the base + * address of the area where the symbol is located. + */ +struct sym +{ + struct sym *s_sp; /* Hash link */ + struct tsym *s_tsym; /* Temporary symbol link */ + char *s_id; /* Symbol: JLH change from [NCPS] */ + char s_type; /* Symbol subtype */ + char s_flag; /* Symbol flags */ + struct area *s_area; /* Area line, 0 if absolute */ + int s_ref; /* Ref. number */ + addr_t s_addr; /* Address */ +}; + +#define S_GBL 01 /* Global */ +#define S_ASG 02 /* Assigned */ +#define S_MDF 04 /* Mult. def */ +#define S_END 010 /* End mark for pst. */ + +#define S_NEW 0 /* New name */ +#define S_USER 1 /* User name */ + /* unused slot */ + /* unused slot */ + /* unused slot */ + +#define S_BYTE 5 /* .byte */ +#define S_WORD 6 /* .word */ +#define S_ASCII 7 /* .ascii */ +#define S_ASCIZ 8 /* .asciz */ +#define S_BLK 9 /* .blkb or .blkw */ +#define S_INCL 10 /* .include */ +#define S_DAREA 11 /* .area */ +#define S_ATYP 12 /* .area type */ +#define S_AREA 13 /* .area name */ +#define S_GLOBL 14 /* .globl */ +#define S_PAGE 15 /* .page */ +#define S_TITLE 16 /* .title */ +#define S_SBTL 17 /* .sbttl */ +#define S_IF 18 /* .if */ +#define S_ELSE 19 /* .else */ +#define S_ENDIF 20 /* .endif */ +#define S_EVEN 21 /* .even */ +#define S_ODD 22 /* .odd */ +#define S_RADIX 23 /* .radix */ +#define S_ORG 24 /* .org */ +#define S_MODUL 25 /* .module */ +#define S_ASCIS 26 /* .ascis */ + + +/* + * The tsym structure is a linked list of temporary + * symbols defined in the assembler source files following + * a normal symbol. The structure contains the temporary + * symbols number, a flag (multiply defined), a pointer to the + * area structure defining where the temporary structure + * is located, and the temporary symbol's address relative + * to the base address of the area where the symbol + * is located. + */ +struct tsym +{ + struct tsym *t_lnk; /* Link to next */ +/* sandeep changed to 'int' from 'char' */ +/* this will increase the number temp symbols + that can be defined from 255 to INT_MAX */ + int t_num; /* 0-INT_MAX$ */ + int t_flg; /* flags */ + + struct area *t_area; /* Area */ + addr_t t_addr; /* Address */ +}; + +/* + * External Definitions for all Global Variables + */ + +extern int aserr; /* ASxxxx error counter + */ +extern jmp_buf jump_env; /* compiler dependent structure + * used by setjmp() and longjmp() + */ +extern int inpfil; /* count of assembler + * input files specified + */ +extern int incfil; /* current file handle index + * for include files + */ +extern int cfile; /* current file handle index + * of input assembly files + */ +extern int flevel; /* IF-ELSE-ENDIF flag will be non + * zero for false conditional case + */ +extern int tlevel; /* current conditional level + */ +extern int ifcnd[MAXIF+1]; /* array of IF statement condition + * values (0 = FALSE) indexed by tlevel + */ +extern int iflvl[MAXIF+1]; /* array of IF-ELSE-ENDIF flevel + * values indexed by tlevel + */ +extern char + afn[FILSPC]; /* afile() temporary filespec + */ +extern char + srcfn[MAXFIL][FILSPC]; /* array of source file names + */ +extern int + srcline[MAXFIL]; /* current source file line + */ +extern char + incfn[MAXINC][FILSPC]; /* array of include file names + */ +extern int + incline[MAXINC]; /* current include file line + */ +extern int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +extern int line; /* current assembler source + * line number + */ +extern int page; /* current page number + */ +extern int lop; /* current line number on page + */ +extern int pass; /* assembler pass number + */ +extern int lflag; /* -l, generate listing flag + */ +extern int cflag; /* -c, generate sdcdb debug information + */ +extern int gflag; /* -g, make undefined symbols global flag + */ +extern int aflag; /* -a, make all symbols global flag + */ +extern int jflag; /* -j, generate debug information flag + */ +extern int oflag; /* -o, generate relocatable output flag + */ +extern int sflag; /* -s, generate symbol table flag + */ +extern int pflag; /* -p, enable listing pagination + */ +extern int xflag; /* -x, listing radix flag + */ +extern int fflag; /* -f(f), relocations flagged flag + */ +extern addr_t laddr; /* address of current assembler line + * or value of .if argument + */ +extern addr_t fuzz; /* tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + */ +extern int lmode; /* listing mode + */ +extern struct area area[]; /* array of 1 area + */ +extern struct area *areap; /* pointer to an area structure + */ +extern struct sym sym[]; /* array of 1 symbol + */ +extern struct sym *symp; /* pointer to a symbol structure + */ +extern struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ +extern struct mne *mnehash[NHASH]; /* array of pointers to NHASH + * linked mnemonic/directive lists + */ +extern char *ep; /* pointer into error list + * array eb[NERR] + */ +extern char eb[NERR]; /* array of generated error codes + */ +extern char *ip; /* pointer into the assembler-source + * text line in ib[] + */ +extern char ib[NINPUT]; /* assembler-source text line + */ +extern char *cp; /* pointer to assembler output + * array cb[] + */ +extern char cb[NCODE]; /* array of assembler output values + */ +extern int *cpt; /* pointer to assembler relocation type + * output array cbt[] + */ +extern int cbt[NCODE]; /* array of assembler relocation types + * describing the data in cb[] + */ +extern char tb[NTITL]; /* Title string buffer + */ +extern char stb[NSBTL]; /* Subtitle string buffer + */ +extern char symtbl[]; /* string "Symbol Table" + */ +extern char aretbl[]; /* string "Area Table" + */ +extern char module[NCPS]; /* module name string + */ +extern FILE *lfp; /* list output file handle + */ +extern FILE *ofp; /* relocation output file handle + */ +extern FILE *tfp; /* symbol table output file handle + */ +extern FILE *sfp[MAXFIL]; /* array of assembler-source file handles + */ +extern FILE *ifp[MAXINC]; /* array of include-file file handles + */ +extern char ctype[128]; /* array of character types, one per + * ASCII character + */ + +extern char ccase[128]; /* an array of characters which + * perform the case translation function + */ +/* + * Definitions for Character Types + */ +#define SPACE 0000 +#define ETC 0000 +#define LETTER 0001 +#define DIGIT 0002 +#define BINOP 0004 +#define RAD2 0010 +#define RAD8 0020 +#define RAD10 0040 +#define RAD16 0100 +#define ILL 0200 + +#define DGT2 DIGIT|RAD16|RAD10|RAD8|RAD2 +#define DGT8 DIGIT|RAD16|RAD10|RAD8 +#define DGT10 DIGIT|RAD16|RAD10 +#define LTR16 LETTER|RAD16 + +/* + * The exp structure is used to return the evaluation + * of an expression. The structure supports three valid + * cases: + * (1) The expression evaluates to a constant, + * mode = S_USER, flag = 0, addr contains the + * constant, and base = NULL. + * (2) The expression evaluates to a defined symbol + * plus or minus a constant, mode = S_USER, + * flag = 0, addr contains the constant, and + * base = pointer to area symbol. + * (3) The expression evaluates to a external + * global symbol plus or minus a constant, + * mode = S_NEW, flag = 1, addr contains the + * constant, and base = pointer to symbol. + */ +struct expr +{ + char e_mode; /* Address mode */ + char e_flag; /* Symbol flag */ + addr_t e_addr; /* Address */ + union { + struct area *e_ap; + struct sym *e_sp; + } e_base; /* Rel. base */ + char e_rlcf; /* Rel. flags */ +}; + +/* C Library functions */ +/* for reference only +extern VOID exit(); +extern int fclose(); +extern char * fgets(); +extern FILE * fopen(); +extern int fprintf(); +extern VOID longjmp(); +extern VOID * malloc(); +extern int printf(); +extern char putc(); +extern int rewind(); +extern int setjmp(); +extern int strcmp(); +extern char * strcpy(); +extern int strlen(); +extern char * strncpy(); +*/ + +/* Machine independent functions */ + +/* asmain.c */ +extern FILE * afile(); +extern VOID asexit(); +extern VOID asmbl(); +extern int main(); +extern VOID newdot(); +extern VOID phase(); +extern VOID usage(); + +/* aslex.c */ +extern char endline(); +extern char get(); +extern VOID getid(); +extern int getline(); +extern int getmap(); +extern char getnb(); +extern VOID getst(); +extern int more(); +extern VOID unget(); + +/* assym.c */ +extern struct area * alookup(); +extern struct mne * mlookup(); +extern int hash(); +extern struct sym * lookup(); +extern VOID * new(); +extern int symeq(); +extern VOID syminit(); +extern VOID symglob(); +extern VOID allglob(); + +/* assubr.c */ +extern VOID aerr(); +extern VOID diag(); +extern VOID err(); +extern char * geterr(); +extern VOID qerr(); +extern VOID rerr(); + +/* asexpr.c */ +extern VOID abscheck(); +extern addr_t absexpr(); +extern VOID clrexpr(); +extern int digit(); +extern int is_abs(); +extern VOID expr(); +extern int oprio(); +extern VOID term(); + +/* aslist.c */ +extern VOID list(); +extern VOID list1(); +extern VOID list2(); +extern VOID lstsym(); +extern VOID slew(); + +/* asout.c */ +extern int hibyte(); +extern int lobyte(); +extern VOID out(); +extern VOID outab(); +extern VOID outarea(); +extern VOID outaw(); +extern VOID outall(); +extern VOID outdot(); +extern VOID outbuf(); +extern VOID outchk(); +extern VOID outgsd(); +extern VOID outrb(); +extern VOID outrw(); +extern VOID outsym(); +extern VOID out_lb(); +extern VOID out_lw(); +extern VOID out_rw(); +extern VOID out_tw(); +extern VOID outr11(); /* JLH */ + +/* asstore.c */ +extern char *StoreString( char *str ); + +/* asnoice.c */ +extern void DefineNoICE_Line(); +extern void DefineCDB_Line(); + +/* Machine dependent variables */ + +extern char * cpu; +extern char * dsft; +extern int hilo; +extern struct mne mne[]; + +/* Machine dependent functions */ + +extern VOID machin(); +extern VOID minit(); + +/* SD added THIS define to change + strcmpi --> strcmp (strcmpi is NOT ANSI) */ +#define strcmpi strcmp diff --git a/as/mcs51/asmain.c b/as/mcs51/asmain.c new file mode 100644 index 00000000..854d0437 --- /dev/null +++ b/as/mcs51/asmain.c @@ -0,0 +1,1144 @@ +/* asmain.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 29-Oct-97 JLH pass ";!" comments to output file + */ + +#include +#include +#include +#include +#include "asm.h" + +extern VOID machine(struct mne *); +/*)Module asmain.c + * + * The module asmain.c includes the command argument parser, + * the three pass sequencer, and the machine independent + * assembler parsing code. + * + * asmain.c contains the following functions: + * VOID main(argc, argv) + * VOID asexit() + * VOID asmbl() + * FILE * afile(fn, ft, wf) + * VOID newdot(nap) + * VOID phase(ap, a) + * VOID usage() + * + * asmain.c contains the array char *usetxt[] which + * references the usage text strings printed by usage(). + */ + +/*)Function VOID main(argc, argv) + * + * int argc argument count + * char * argv array of pointers to argument strings + * + * The function main() is the entry point to the assembler. + * The purpose of main() is to (1) parse the command line + * arguments for options and source file specifications and + * (2) to process the source files through the 3 pass assembler. + * Before each assembler pass various variables are initialized + * and source files are rewound to their beginning. During each + * assembler pass each assembler-source text line is processed. + * After each assembler pass the assembler information is flushed + * to any opened output files and the if-else-endif processing + * is checked for proper termination. + * + * The function main() is also responsible for opening all + * output files (REL, LST, and SYM), sequencing the global (-g) + * and all-global (-a) variable definitions, and dumping the + * REL file header information. + * + * local variables: + * char * p pointer to argument string + * int c character from argument string + * int i argument loop counter + * area * ap pointer to area structure + * + * global variables: + * int aflag -a, make all symbols global flag + * char afn[] afile() constructed filespec + * area * areap pointer to an area structure + * int cb[] array of assembler output values + * int cbt[] array of assembler relocation types + * describing the data in cb[] + * int cfile current file handle index + * of input assembly files + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * char eb[] array of generated error codes + * char * ep pointer into error list array eb[] + * int fflag -f(f), relocations flagged flag + * int flevel IF-ELSE-ENDIF flag will be non + * zero for false conditional case + * addr_t fuzz tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + * int gflag -g, make undefined symbols global flag + * char ib[] assembler-source text line + * int inpfil count of assembler + * input files specified + * int ifcnd[] array of IF statement condition + * values (0 = FALSE) indexed by tlevel + * int iflvl[] array of IF-ELSE-ENDIF flevel + * values indexed by tlevel + * int incfil current file handle index + * for include files + * char * ip pointer into the assembler-source + * text line in ib[] + * jmp_buf jump_env compiler dependent structure + * used by setjmp() and longjmp() + * int lflag -l, generate listing flag + * int line current assembler source + * line number + * int lop current line number on page + * int oflag -o, generate relocatable output flag + * int jflag -j, generate debug info flag + * int page current page number + * int pflag enable listing pagination + * int pass assembler pass number + * int radix current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + * int sflag -s, generate symbol table flag + * char srcfn[][] array of source file names + * int srcline[] current source file line + * char stb[] Subtitle string buffer + * sym * symp pointer to a symbol structure + * int tlevel current conditional level + * int xflag -x, listing radix flag + * FILE * lfp list output file handle + * FILE * ofp relocation output file handle + * FILE * tfp symbol table output file handle + * FILE * sfp[] array of assembler-source file handles + * + * called functions: + * FILE * afile() asmain.c + * VOID allglob() assym.c + * VOID asexit() asmain.c + * VOID diag() assubr.c + * VOID err() assubr.c + * int fprintf() c-library + * int getline() aslex.c + * VOID list() aslist.c + * VOID lstsym() aslist.c + * VOID minit() ___mch.c + * VOID newdot() asmain.c + * VOID outchk() asout.c + * VOID outgsd() asout.c + * int rewind() c-library + * int setjmp() c-library + * VOID symglob() assym.c + * VOID syminit() assym.c + * VOID usage() asmain.c + * + * side effects: + * Completion of main() completes the assembly process. + * REL, LST, and/or SYM files may be generated. + */ + +int +main(argc, argv) +char *argv[]; +{ + register char *p; + register int c, i; + struct area *ap; + + /*fprintf(stdout, "\n");*/ + inpfil = -1; + pflag = 1; + for (i=1; i= 0) + usage(); + ++p; + while ((c = *p++) != 0) + switch(c) { + + case 'a': + case 'A': + ++aflag; + break; + + case 'c': + case 'C': + ++cflag; + break; + + case 'g': + case 'G': + ++gflag; + break; + + case 'j': /* JLH: debug info */ + case 'J': + ++jflag; + ++oflag; /* force object */ + break; + + case 'l': + case 'L': + ++lflag; + break; + + case 'o': + case 'O': + ++oflag; + break; + + case 's': + case 'S': + ++sflag; + break; + + case 'p': + case 'P': + pflag = 0; + break; + + case 'x': + case 'X': + xflag = 0; + break; + + case 'q': + case 'Q': + xflag = 1; + break; + + case 'd': + case 'D': + xflag = 2; + break; + + case 'f': + case 'F': + ++fflag; + break; + + default: + usage(); + } + } else { + if (++inpfil == MAXFIL) { + fprintf(stderr, "too many input files\n"); + asexit(1); + } + sfp[inpfil] = afile(p, "", 0); + strcpy(srcfn[inpfil],afn); + if (inpfil == 0) { + if (lflag) + lfp = afile(p, "lst", 1); + if (oflag) + ofp = afile(p, "rel", 1); + if (sflag) + tfp = afile(p, "sym", 1); + } + } + } + if (inpfil < 0) + usage(); + syminit(); + for (pass=0; pass<3; ++pass) { + if (gflag && pass == 1) + symglob(); + if (aflag && pass == 1) + allglob(); + if (oflag && pass == 2) + outgsd(); + flevel = 0; + tlevel = 0; + ifcnd[0] = 0; + iflvl[0] = 0; + radix = 10; + srcline[0] = 0; + page = 0; + stb[0] = 0; + lop = NLPP; + cfile = 0; + incfil = -1; + for (i = 0; i <= inpfil; i++) + rewind(sfp[i]); + ap = areap; + while (ap) { + ap->a_fuzz = 0; + ap->a_size = 0; + ap = ap->a_ap; + } + fuzz = 0; + dot.s_addr = 0; + dot.s_area = &dca; + symp = ˙ + minit(); + while (getline()) { + cp = cb; + cpt = cbt; + ep = eb; + ip = ib; + + /* JLH: if line begins with ";!", then + * pass this comment on to the output file + */ + if (oflag && (pass == 1) && + (ip[0] == ';') && (ip[1] == '!')) + { + fprintf(ofp, "%s\n", ip ); + } + + if (setjmp(jump_env) == 0) + asmbl(); + + if (pass == 2) { + diag(); + list(); + } + } + newdot(dot.s_area); /* Flush area info */ + if (flevel || tlevel) + err('i'); + } + if (oflag) + outchk(HUGE, HUGE); /* Flush */ + if (sflag) { + lstsym(tfp); + } else + if (lflag) { + lstsym(lfp); + } + asexit(aserr); + return 0; +} + +/*)Function VOID asexit(i) + * + * int i exit code + * + * The function asexit() explicitly closes all open + * files and then terminates the program. + * + * local variables: + * int j loop counter + * + * global variables: + * FILE * ifp[] array of include-file file handles + * FILE * lfp list output file handle + * FILE * ofp relocation output file handle + * FILE * tfp symbol table output file handle + * FILE * sfp[] array of assembler-source file handles + * + * functions called: + * int fclose() c-library + * VOID exit() c-library + * + * side effects: + * All files closed. Program terminates. + */ + +VOID +asexit(i) +int i; +{ + int j; + + if (lfp != NULL) fclose(lfp); + if (ofp != NULL) fclose(ofp); + if (tfp != NULL) fclose(tfp); + + for (j=0; j= 0) { + n = 10*n + d; + c = get(); + } + if (c != '$' || get() != ':') + qerr(); + tp = symp->s_tsym; + if (pass == 0) { + while (tp) { + if (n == tp->t_num) { + tp->t_flg |= S_MDF; + break; + } + tp = tp->t_lnk; + } + if (tp == NULL) { + tp=(struct tsym *) new (sizeof(struct tsym)); + tp->t_lnk = symp->s_tsym; + tp->t_num = n; + tp->t_flg = 0; + tp->t_area = dot.s_area; + tp->t_addr = dot.s_addr; + symp->s_tsym = tp; + } + } else { + while (tp) { + if (n == tp->t_num) { + break; + } + tp = tp->t_lnk; + } + if (tp) { + if (pass == 1) { + fuzz = tp->t_addr - dot.s_addr; + tp->t_area = dot.s_area; + tp->t_addr = dot.s_addr; + } else { + phase(tp->t_area, tp->t_addr); + if (tp->t_flg & S_MDF) + err('m'); + } + } else { + err('u'); + } + } + lmode = ALIST; + goto loop; + } + /* + * If the first character is a letter then assume a lable, + * symbol, assembler directive, or assembler mnemonic is + * being processed. + */ + if ((ctype[c] & LETTER) == 0) { + if (flevel) { + return; + } else { + qerr(); + } + } + getid(id, c); + c = getnb(); + /* + * If the next character is a : then a label is being processed. + * A double :: defines a global label. If this is new label + * then create a symbol structure. + * pass 0: + * Flag multiply defined labels. + * pass 1: + * Load area, address, and fuzz values + * into structure symp. + * pass 2: + * Check for assembler phase error and + * multiply defined error. + */ + if (c == ':') { + if (flevel) + return; + if ((c = get()) != ':') { + unget(c); + c = 0; + } + symp = lookup(id); + if (symp == &dot) + err('.'); + if (pass == 0) + if ((symp->s_type != S_NEW) && + ((symp->s_flag & S_ASG) == 0)) + symp->s_flag |= S_MDF; + if (pass != 2) { + fuzz = symp->s_addr - dot.s_addr; + symp->s_type = S_USER; + symp->s_area = dot.s_area; + symp->s_addr = dot.s_addr; + } else { + if (symp->s_flag & S_MDF) + err('m'); + phase(symp->s_area, symp->s_addr); + } + if (c) { + symp->s_flag |= S_GBL; + } + lmode = ALIST; + goto loop; + } + /* + * If the next character is a = then an equate is being processed. + * A double == defines a global equate. If this is new variable + * then create a symbol structure. + */ + if (c == '=') { + if (flevel) + return; + if ((c = get()) != '=') { + unget(c); + c = 0; + } + clrexpr(&e1); + expr(&e1, 0); + sp = lookup(id); + if (sp == &dot) { + outall(); + if (e1.e_flag || e1.e_base.e_ap != dot.s_area) + err('.'); + } else + if (sp->s_type != S_NEW && (sp->s_flag & S_ASG) == 0) { + err('m'); + } + sp->s_type = S_USER; + sp->s_area = e1.e_base.e_ap; + sp->s_addr = laddr = e1.e_addr; + sp->s_flag |= S_ASG; + if (c) { + sp->s_flag |= S_GBL; + } + lmode = ELIST; + goto loop; + } + unget(c); + lmode = flevel ? SLIST : CLIST; + if ((mp = mlookup(id)) == NULL) { + if (!flevel) + err('o'); + return; + } + /* + * If we have gotten this far then we have found an + * assembler directive or an assembler mnemonic. + * + * Check for .if, .else, .endif, and .page directives + * which are not controlled by the conditional flags + */ + switch (mp->m_type) { + + case S_IF: + n = absexpr(); + if (tlevel < MAXIF) { + ++tlevel; + ifcnd[tlevel] = n; + iflvl[tlevel] = flevel; + if (n == 0) { + ++flevel; + } + } else { + err('i'); + } + lmode = ELIST; + laddr = n; + return; + + case S_ELSE: + if (ifcnd[tlevel]) { + if (++flevel > (iflvl[tlevel]+1)) { + err('i'); + } + } else { + if (--flevel < iflvl[tlevel]) { + err('i'); + } + } + lmode = SLIST; + return; + + case S_ENDIF: + if (tlevel) { + flevel = iflvl[tlevel--]; + } else { + err('i'); + } + lmode = SLIST; + return; + + case S_PAGE: + lop = NLPP; + lmode = NLIST; + return; + + default: + break; + } + if (flevel) + return; + /* + * If we are not in a false state for .if/.else then + * process the assembler directives here. + */ + switch (mp->m_type) { + + case S_EVEN: + outall(); + laddr = dot.s_addr = (dot.s_addr + 1) & ~1; + lmode = ALIST; + break; + + case S_ODD: + outall(); + laddr = dot.s_addr |= 1; + lmode = ALIST; + break; + + case S_BYTE: + case S_WORD: + do { + clrexpr(&e1); + expr(&e1, 0); + if (mp->m_type == S_BYTE) { + outrb(&e1, R_NORM); + } else { + outrw(&e1, R_NORM); + } + } while ((c = getnb()) == ','); + unget(c); + break; + + case S_ASCII: + case S_ASCIZ: + if ((d = getnb()) == '\0') + qerr(); + while ((c = getmap(d)) >= 0) + outab(c); + if (mp->m_type == S_ASCIZ) + outab(0); + break; + + case S_ASCIS: + if ((d = getnb()) == '\0') + qerr(); + c = getmap(d); + while (c >= 0) { + if ((n = getmap(d)) >= 0) { + outab(c); + } else { + outab(c | 0x80); + } + c = n; + } + break; + + case S_BLK: + clrexpr(&e1); + expr(&e1, 0); + outchk(HUGE,HUGE); + dot.s_addr += e1.e_addr*mp->m_valu; + lmode = BLIST; + break; + + case S_TITLE: + p = tb; + if ((c = getnb()) != 0) { + do { + if (p < &tb[NTITL-1]) + *p++ = c; + } while ((c = get()) != 0); + } + *p = 0; + unget(c); + lmode = SLIST; + break; + + case S_SBTL: + p = stb; + if ((c = getnb()) != 0) { + do { + if (p < &stb[NSBTL-1]) + *p++ = c; + } while ((c = get()) != 0); + } + *p = 0; + unget(c); + lmode = SLIST; + break; + + case S_MODUL: + getst(id, -1); + if (pass == 0) { + if (module[0]) { + err('m'); + } else { + strncpy(module, id, NCPS); + } + } + lmode = SLIST; + break; + + case S_GLOBL: + do { + getid(id, -1); + sp = lookup(id); + sp->s_flag |= S_GBL; + } while ((c = getnb()) == ','); + unget(c); + lmode = SLIST; + break; + + case S_DAREA: + getid(id, -1); + uaf = 0; + uf = A_CON|A_REL; + if ((c = getnb()) == '(') { + do { + getid(opt, -1); + mp = mlookup(opt); + if (mp && mp->m_type == S_ATYP) { + ++uaf; + uf |= mp->m_valu; + } else { + err('u'); + } + } while ((c = getnb()) == ','); + if (c != ')') + qerr(); + } else { + unget(c); + } + if ((ap = alookup(id)) != NULL) { + if (uaf && uf != ap->a_flag) + err('m'); + if (ap->a_flag & A_OVR) { + ap->a_size = 0; + ap->a_fuzz=0; + } + } else { + ap = (struct area *) new (sizeof(struct area)); + ap->a_ap = areap; + strncpy(ap->a_id, id, NCPS); + ap->a_ref = areap->a_ref + 1; + ap->a_size = 0; + ap->a_fuzz = 0; + ap->a_flag = uaf ? uf : (A_CON|A_REL); + areap = ap; + } + newdot(ap); + lmode = SLIST; + break; + + case S_ORG: + if (dot.s_area->a_flag & A_ABS) { + outall(); + laddr = dot.s_addr = absexpr(); + } else { + err('o'); + } + outall(); + lmode = ALIST; + break; + + case S_RADIX: + if (more()) { + switch (getnb()) { + case 'b': + case 'B': + radix = 2; + break; + case '@': + case 'o': + case 'O': + case 'q': + case 'Q': + radix = 8; + break; + case 'd': + case 'D': + radix = 10; + break; + case 'h': + case 'H': + case 'x': + case 'X': + radix = 16; + break; + default: + radix = 10; + qerr(); + break; + } + } else { + radix = 10; + } + lmode = SLIST; + break; + + case S_INCL: + d = getnb(); + p = fn; + while ((c = get()) != d) { + if (p < &fn[FILSPC-1]) { + *p++ = c; + } else { + break; + } + } + *p = 0; + if (++incfil == MAXINC || + (ifp[incfil] = fopen(fn, "r")) == NULL) { + --incfil; + err('i'); + } else { + lop = NLPP; + incline[incfil] = 0; + strcpy(incfn[incfil],fn); + } + lmode = SLIST; + break; + + /* + * If not an assembler directive then go to + * the machine dependent function which handles + * all the assembler mnemonics. + */ + default: + machine(mp); + /* if cdb information the generate the line info */ + if (cflag && (pass == 1)) + DefineCDB_Line(); + + /* JLH: if -j, generate a line number symbol */ + if (jflag && (pass == 1)) + { + DefineNoICE_Line(); + } + + } + goto loop; +} + +/*)Function FILE * afile(fn, ft, wf) + * + * char * fn file specification string + * char * ft file type string + * int wf read(0)/write(1) flag + * + * The function afile() opens a file for reading or writing. + * (1) If the file type specification string ft + * is not NULL then a file specification is + * constructed with the file path\name in fn + * and the extension in ft. + * (2) If the file type specification string ft + * is NULL then the file specification is + * constructed from fn. If fn does not have + * a file type then the default source file + * type dsft is appended to the file specification. + * + * afile() returns a file handle for the opened file or aborts + * the assembler on an open error. + * + * local variables: + * int c character value + * FILE * fp filehandle for opened file + * char * p1 pointer to filespec string fn + * char * p2 pointer to filespec string fb + * char * p3 pointer to filetype string ft + * + * global variables: + * char afn[] afile() constructed filespec + * char dsft[] default assembler file type string + * char afn[] constructed file specification string + * + * functions called: + * VOID asexit() asmain.c + * FILE * fopen() c_library + * int fprintf() c_library + * + * side effects: + * File is opened for read or write. + */ + +FILE * +afile(fn, ft, wf) +char *fn; +char *ft; +int wf; +{ + register char *p1, *p2, *p3; + register int c; + FILE *fp; + + p1 = fn; + p2 = afn; + p3 = ft; + while ((c = *p1++) != 0 && c != FSEPX) { + if (p2 < &afn[FILSPC-4]) + *p2++ = c; + } + *p2++ = FSEPX; + if (*p3 == 0) { + if (c == FSEPX) { + p3 = p1; + } else { + p3 = dsft; + } + } + while ((c = *p3++) != 0) { + if (p2 < &afn[FILSPC-1]) + *p2++ = c; + } + *p2++ = 0; + if ((fp = fopen(afn, wf?"w":"r")) == NULL) { + fprintf(stderr, "%s: cannot %s.\n", afn, wf?"create":"open"); + asexit(1); + } + return (fp); +} + +/*)Function VOID newdot(nap) + * + * area * nap pointer to the new area structure + * + * The function newdot(): + * (1) copies the current values of fuzz and the last + * address into the current area referenced by dot + * (2) loads dot with the pointer to the new area and + * loads the fuzz and last address parameters + * (3) outall() is called to flush any remaining + * bufferred code from the old area to the output + * + * local variables: + * area * oap pointer to old area + * + * global variables: + * sym dot defined as sym[0] + * addr_t fuzz tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + * + * functions called: + * none + * + * side effects: + * Current area saved, new area loaded, buffers flushed. + */ + +VOID +newdot(nap) +register struct area *nap; +{ + register struct area *oap; + + oap = dot.s_area; + oap->a_fuzz = fuzz; + oap->a_size = dot.s_addr; + fuzz = nap->a_fuzz; + dot.s_area = nap; + dot.s_addr = nap->a_size; + outall(); +} + +/*)Function VOID phase(ap, a) + * + * area * ap pointer to area + * addr_t a address in area + * + * Function phase() compares the area ap and address a + * with the current area dot.s_area and address dot.s_addr + * to determine if the position of the symbol has changed + * between assembler passes. + * + * local variables: + * none + * + * global varaibles: + * sym * dot defined as sym[0] + * + * functions called: + * none + * + * side effects: + * The p error is invoked if the area and/or address + * has changed. + */ + +VOID +phase(ap, a) +struct area *ap; +addr_t a; +{ + if (ap != dot.s_area || a != dot.s_addr) + err('p'); +} + +char *usetxt[] = { + "Usage: [-dqxjgalopsf] file1 [file2 file3 ...]", + " d decimal listing", + " q octal listing", + " x hex listing (default)", + " j add line number and debug information to file", /* JLH */ + " g undefined symbols made global", + " a all user symbols made global", + " l create list output file1[LST]", + " o create object output file1[REL]", + " s create symbol output file1[SYM]", + " p disable listing pagination", + " f flag relocatable references by ` in listing file", + " ff flag relocatable references by mode in listing file", + "", + 0 +}; + +/*)Function VOID usage() + * + * The function usage() outputs to the stderr device the + * assembler name and version and a list of valid assembler options. + * + * local variables: + * char ** dp pointer to an array of + * text string pointers. + * + * global variables: + * char cpu[] assembler type string + * char * usetxt[] array of string pointers + * + * functions called: + * VOID asexit() asmain.c + * int fprintf() c_library + * + * side effects: + * program is terminated + */ + +VOID +usage() +{ + register char **dp; + + fprintf(stderr, "\nASxxxx Assembler %s (%s)\n\n", VERSION, cpu); + for (dp = usetxt; *dp; dp++) + fprintf(stderr, "%s\n", *dp); + asexit(1); +} diff --git a/as/mcs51/asnoice.c b/as/mcs51/asnoice.c new file mode 100644 index 00000000..a9465426 --- /dev/null +++ b/as/mcs51/asnoice.c @@ -0,0 +1,122 @@ +/* asnoice.c */ + +/* + * Extensions to CUG 292 assembler ASxxxx to produce NoICE debug files + * + * 3-Nov-1997 by John Hartman + */ + +#include +#include +#include +#include +#include "asm.h" + +/* Return basic file name without path or extension */ +static char* BaseFileName( int fileNumber ); + +char* BaseFileName( int fileNumber ) +{ + static int prevFile = -1; + static char baseName[ FILSPC ]; + + char *p1, *p2; + + if (fileNumber != prevFile) + { + prevFile = fileNumber; + + p1 = srcfn[prevFile]; + + /* issue a FILE command with full path and extension */ + fprintf( ofp, ";!FILE %s\n", p1 ); + + /* Name starts after any colon or backslash (DOS) */ + p2 = strrchr( p1, '\\' ); + if (p2 == NULL) p2 = strrchr( p1, ':' ); + if (p2 == NULL) p2 = p1-1; + strcpy( baseName, p2+1 ); + + /* Name ends at any separator */ + p2 = strrchr( baseName, FSEPX ); + if (p2 != NULL) *p2 = 0; + /* SD comment this out since not a ANSI Function */ + /* strupr( baseName ); */ + } + return baseName; +} + +/* Define a symbol for current location: FILE.line# */ +void DefineNoICE_Line() +{ + char name[ NCPS ]; + struct sym *pSym; + + /* symbol is FILE.nnn */ + sprintf( name, "%s.%u", BaseFileName( cfile ), srcline[ cfile ] ); + + pSym = lookup( name ); + pSym->s_type = S_USER; + pSym->s_area = dot.s_area; + pSym->s_addr = laddr; + pSym->s_flag |= S_GBL; +} + +/* Define a symbol for current location: A$FILE$line# */ +void DefineCDB_Line() +{ + char name[ NCPS ]; + struct sym *pSym; + + /* symbol is FILE.nnn */ + sprintf( name, "A$%s$%u", BaseFileName( cfile ), srcline[ cfile ] ); + + pSym = lookup( name ); + pSym->s_type = S_USER; + pSym->s_area = dot.s_area; + pSym->s_addr = laddr; + pSym->s_flag |= S_GBL; +} + +#if 0 +OLD VERSION +/* Define a symbol for current location: FILE.line# */ +void DefineNoICE_Line() +{ + static int prevFile = -1; + static struct area *pPrevArea = NULL; + static char baseName[ FILSPC ]; + + int j; + char *p1, *p2; + + /* Get outfilename without extension for use as base symbol name */ + if (baseName[0] == 0) + { + p1 = srcfn[0]; + p2 = baseName; + while ((*p1 != 0) && (*p1 != FSEPX)) + { + *p2++ = *p1++; + } + *p2 = 0; + /* SD Commented this out since it is not a + ASNI Function */ + /* strupr( baseName ); */ + } + + if ((cfile != prevFile) || (dot.s_area != pPrevArea)) + { + prevFile = cfile; + pPrevArea = dot.s_area; + + /* file or area change: issue FILE command with base @ */ + fprintf( ofp, ";!FILE %s %s_%s\n", srcfn[ cfile ], + baseName, + dot.s_area->a_id ); + } + + fprintf( ofp, ";!LINE %u. 0x%X\n", srcline[ cfile ], laddr ); +} + +#endif diff --git a/as/mcs51/asout.c b/as/mcs51/asout.c new file mode 100644 index 00000000..b581ca3a --- /dev/null +++ b/as/mcs51/asout.c @@ -0,0 +1,1131 @@ +/* asout.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - outsym: show s_id as string rather than array [NCPS] + * - Added outr11 to support 8051's 11 bit destination address + */ + +#include +#include +#include +#include +#include "asm.h" + + +/*)Module asout.c + * + * The module asout.c contains all the functions used to + * generate the .REL assembler output file. + * + * + * The assemblers' output object file is an ascii file containing + * the information needed by the linker to bind multiple object + * modules into a complete loadable memory image. + * + * The object module contains the following designators: + * + * [XDQ][HL] + * X Hexadecimal radix + * D Decimal radix + * Q Octal radix + * + * H Most significant byte first + * L Least significant byte first + * + * H Header + * M Module + * A Area + * S Symbol + * T Object code + * R Relocation information + * P Paging information + * + * + * (1) Radix Line + * + * The first line of an object module contains the [XDQ][HL] + * format specifier (i.e. XH indicates a hexadecimal file with + * most significant byte first) for the following designators. + * + * + * (2) Header Line + * + * H aa areas gg global symbols + * + * The header line specifies the number of areas(aa) and the + * number of global symbols(gg) defined or referenced in this ob- + * ject module segment. + * + * + * (3) Module Line + * + * M name + * + * The module line specifies the module name from which this + * header segment was assembled. The module line will not appear + * if the .module directive was not used in the source program. + * + * + * (4) Symbol Line + * + * S string Defnnnn + * + * or + * + * S string Refnnnn + * + * The symbol line defines (Def) or references (Ref) the symbol + * 'string' with the value nnnn. The defined value is relative to + * the current area base address. References to constants and ex- + * ternal global symbols will always appear before the first area + * definition. References to external symbols will have a value of + * zero. + * + * + * (5) Area Line + * + * A label size ss flags ff + * + * The area line defines the area label, the size (ss) of the + * area in bytes, and the area flags (ff). The area flags specify + * the ABS, REL, CON, OVR, and PAG parameters: + * + * OVR/CON (0x04/0x00 i.e. bit position 2) + * + * ABS/REL (0x08/0x00 i.e. bit position 3) + * + * PAG (0x10 i.e. bit position 4) + * + * + * (6) T Line + * + * T xx xx nn nn nn nn nn ... + * + * The T line contains the assembled code output by the assem- + * bler with xx xx being the offset address from the current area + * base address and nn being the assembled instructions and data in + * byte format. + * + * + * (7) R Line + * + * R 0 0 nn nn n1 n2 xx xx ... + * + * The R line provides the relocation information to the linker. + * The nn nn value is the current area index, i.e. which area the + * current values were assembled. Relocation information is en- + * coded in groups of 4 bytes: + * + * 1. n1 is the relocation mode and object format + * 1. bit 0 word(0x00)/byte(0x01) + * 2. bit 1 relocatable area(0x00)/symbol(0x02) + * 3. bit 2 normal(0x00)/PC relative(0x04) relocation + * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for + * byte data + * 5. bit 4 signed(0x00)/unsigned(0x10) byte data + * 6. bit 5 normal(0x00)/page '0'(0x20) reference + * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference + * 8. bit 7 normal(0x00)/MSB of value + * + * 2. n2 is a byte index into the corresponding (i.e. pre- + * ceeding) T line data (i.e. a pointer to the data to be + * updated by the relocation). The T line data may be + * 1-byte or 2-byte byte data format or 2-byte word + * format. + * + * 3. xx xx is the area/symbol index for the area/symbol be- + * ing referenced. the corresponding area/symbol is found + * in the header area/symbol lists. + * + * + * The groups of 4 bytes are repeated for each item requiring relo- + * cation in the preceeding T line. + * + * + * (8) P Line + * + * P 0 0 nn nn n1 n2 xx xx + * + * The P line provides the paging information to the linker as + * specified by a .setdp directive. The format of the relocation + * information is identical to that of the R line. The correspond- + * ing T line has the following information: + * T xx xx aa aa bb bb + * + * Where aa aa is the area reference number which specifies the + * selected page area and bb bb is the base address of the page. + * bb bb will require relocation processing if the 'n1 n2 xx xx' is + * specified in the P line. The linker will verify that the base + * address is on a 256 byte boundary and that the page length of an + * area defined with the PAG type is not larger than 256 bytes. + * + * The linker defaults any direct page references to the first + * area defined in the input REL file. All ASxxxx assemblers will + * specify the _CODE area first, making this the default page area. + * + * + * asout.c contains the following functions: + * int lobyte() + * int hibyte() + * VOID out() + * VOID outab() + * VOID outall() + * VOID outarea() + * VOID outaw() + * VOID outbuf() + * VOID outchk() + * VOID outdot() + * VOID outdp() + * VOID outgsd() + * VOID outrb() + * VOID outrw() + * VOID outsym() + * VOID out_lb() + * VOID out_lw() + * VOID out_rw() + * VOID out_tw() + * + * The module asout.c contains the following local variables: + * int rel[] relocation data for code/data array + * int * relp pointer to rel array + * int txt[] assembled code/data array + * int * txtp pointer to txt array + */ + +#define NTXT 16 +#define NREL 16 + +char txt[NTXT]; +char rel[NREL]; + +char *txtp = { &txt[0] }; +char *relp = { &rel[0] }; + +/*)Function VOID outab(b) + * + * int b assembler data word + * + * The function outab() processes a single word of + * assembled data in absolute format. + * + * local variables: + * int * txtp pointer to data word + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outchk() asout.c + * VOID out_lb() asout.c + * + * side effects: + * The current assembly address is incremented by 1. + */ + +VOID +outab(b) +{ + if (pass == 2) { + out_lb(b,0); + if (oflag) { + outchk(1, 0); + *txtp++ = lobyte(b); + } + } + ++dot.s_addr; +} + +/*)Function VOID outaw(w) + * + * int w assembler data word + * + * The function outaw() processes a single word of + * assembled data in absolute format. + * + * local variables: + * int * txtp pointer to data word + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outchk() asout.c + * VOID out_lw() asout.c + * + * side effects: + * The current assembly address is incremented by 2. + */ + +VOID +outaw(w) +{ + if (pass == 2) { + out_lw(w,0); + if (oflag) { + outchk(2, 0); + out_tw(w); + } + } + dot.s_addr += 2; +} + +/*)Function VOID outrb(esp, r) + * + * expr * esp pointer to expr structure + * int r relocation mode + * + * The function outrb() processes a byte of generated code + * in either absolute or relocatable format dependent upon + * the data contained in the expr structure esp. If the + * .REL output is enabled then the appropriate information + * is loaded into the txt and rel buffers. + * + * local variables: + * int n symbol/area reference number + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID aerr() assubr.c + * VOID outchk() asout.c + * VOID out_lb() asout.c + * VOID out_rb() asout.c + * VOID out_tb() asout.c + * + * side effects: + * The current assembly address is incremented by 1. + */ + +VOID +outrb(esp, r) +register struct expr *esp; +int r; +{ + register int n; + + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + out_lb(lobyte(esp->e_addr),0); + if (oflag) { + outchk(1, 0); + *txtp++ = lobyte(esp->e_addr); + } + } else { + r |= R_BYTE | R_BYT2 | esp->e_rlcf; + if (r & R_MSB) { + out_lb(hibyte(esp->e_addr),r|R_RELOC|R_HIGH); + } else { + out_lb(lobyte(esp->e_addr),r|R_RELOC); + } + if (oflag) { + outchk(2, 4); + out_tw(esp->e_addr); + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + *relp++ = r; + *relp++ = txtp - txt - 2; + out_rw(n); + } + } + } + ++dot.s_addr; +} + +/*)Function VOID outrw(esp, r) + * + * expr * esp pointer to expr structure + * int r relocation mode + * + * The function outrw() processes a word of generated code + * in either absolute or relocatable format dependent upon + * the data contained in the expr structure esp. If the + * .REL output is enabled then the appropriate information + * is loaded into the txt and rel buffers. + * + * local variables: + * int n symbol/area reference number + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID aerr() assubr.c + * VOID outchk() asout.c + * VOID out_lw() asout.c + * VOID out_rw() asout.c + * VOID out_tw() asout.c + * + * side effects: + * The current assembly address is incremented by 2. + */ + +VOID +outrw(esp, r) +register struct expr *esp; +int r; +{ + register int n; + + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + out_lw(esp->e_addr,0); + if (oflag) { + outchk(2, 0); + out_tw(esp->e_addr); + } + } else { + r |= R_WORD | esp->e_rlcf; + if (r & R_BYT2) { + rerr(); + if (r & R_MSB) { + out_lw(hibyte(esp->e_addr),r|R_RELOC); + } else { + out_lw(lobyte(esp->e_addr),r|R_RELOC); + } + } else { + out_lw(esp->e_addr,r|R_RELOC); + } + if (oflag) { + outchk(2, 4); + out_tw(esp->e_addr); + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + *relp++ = r; + *relp++ = txtp - txt - 2; + out_rw(n); + } + } + } + dot.s_addr += 2; +} + +/*)Function VOID outdp(carea, esp) + * + * area * carea pointer to current area strcuture + * expr * esp pointer to expr structure + * + * The function outdp() flushes the output buffer and + * outputs paging information to the .REL file. + * + * local variables: + * int n symbol/area reference number + * int r relocation mode + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outbuf() asout.c + * VOID outchk() asout.c + * VOID out_rw() asout.c + * VOID out_tw() asout.c + * + * side effects: + * Output buffer flushed to .REL fiel. + * Paging information dumped to .REL file. + */ + +VOID +outdp(carea, esp) +register struct area *carea; +register struct expr *esp; +{ + register int n, r; + + if (oflag && pass==2) { + outchk(HUGE,HUGE); + out_tw(carea->a_ref); + out_tw(esp->e_addr); + if (esp->e_flag || esp->e_base.e_ap!=NULL) { + r = R_WORD; + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + *relp++ = r; + *relp++ = txtp - txt - 2; + out_rw(n); + } + outbuf("P"); + } +} + +/*)Function VOID outall() + * + * The function outall() will output any bufferred assembled + * data and relocation information (during pass 2 if the .REL + * output has been enabled). + * + * local variables: + * none + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outbuf() asout.c + * + * side effects: + * assembled data and relocation buffers will be cleared. + */ + +VOID +outall() +{ + if (oflag && pass==2) + outbuf("R"); +} + +/*)Function VOID outdot() + * + * The function outdot() outputs information about the + * current program counter value (during pass 2 if the .REL + * output has been enabled). + * + * local variables: + * none + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * int fprintf() c_library + * VOID out() asout.c + * + * side effects: + * assembled data and relocation buffers will be cleared. + */ + +VOID +outdot() +{ + if (oflag && pass==2) { + fprintf(ofp, "T"); + out(txt,(int) (txtp-txt)); + fprintf(ofp, "\n"); + fprintf(ofp, "R"); + out(rel,(int) (relp-rel)); + fprintf(ofp, "\n"); + txtp = txt; + relp = rel; + } +} + +/*)Function outchk(nt, nr) + * + * int nr number of additional relocation words + * int nt number of additional data words + * + * The function outchk() checks the data and relocation buffers + * for space to insert the nt data words and nr relocation words. + * If space is not available then output the current data and + * initialize the data buffers to receive the new data. + * + * local variables: + * area * ap pointer to an area structure + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * + * functions called: + * VOID outbuf() asout.c + * + * side effects: + * Data and relocation buffers may be emptied and initialized. + */ + +VOID +outchk(nt, nr) +{ + register struct area *ap; + + if (txtp+nt > &txt[NTXT] || relp+nr > &rel[NREL]) { + outbuf("R"); + } + if (txtp == txt) { + out_tw(dot.s_addr); + if ((ap = dot.s_area) != NULL) { + *relp++ = R_WORD|R_AREA; + *relp++ = 0; + out_rw(ap->a_ref); + } + } +} + +/*)Function VOID outbuf() + * + * The function outbuf() will output any bufferred data + * and relocation information to the .REL file. The output + * buffer pointers and counters are initialized. + * + * local variables: + * int rel[] relocation data for code/data array + * int * relp pointer to rel array + * int txt[] assembled code/data array + * int * txtp pointer to txt array + * + * global variables: + * FILE * ofp relocation output file handle + * + * functions called: + * VOID out() asout.c + * + * side effects: + * All bufferred data written to .REL file and + * buffer pointers and counters initialized. + */ + +VOID +outbuf(s) +char *s; +{ + if (txtp > &txt[2]) { + fprintf(ofp, "T"); + out(txt,(int) (txtp-txt)); + fprintf(ofp, "\n"); + fprintf(ofp, "%s", s); + out(rel,(int) (relp-rel)); + fprintf(ofp, "\n"); + } + txtp = txt; + relp = rel; +} + +/*)Function VOID outgsd() + * + * The function outgsd() performs the following: + * (1) outputs the .REL file radix + * (2) outputs the header specifying the number + * of areas and global symbols + * (3) outputs the module name + * (4) set the reference number and output a symbol line + * for all external global variables and absolutes + * (5) output an area name, set reference number and output + * a symbol line for all global relocatables in the area. + * Repeat this proceedure for all areas. + * + * local variables: + * area * ap pointer to an area structure + * sym * sp pointer to a sym structure + * int i loop counter + * int j loop counter + * int c string character value + * int narea number of code areas + * char * ptr string pointer + * int nglob number of global symbols + * int rn symbol reference number + * + * global variables: + * area * areap pointer to an area structure + * char module[] module name string + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * VOID outarea() asout.c + * VOID outsym() asout.c + * int putc() c_library + * + * side effects: + * All symbols are given reference numbers, all symbol + * and area information is output to the .REL file. + */ + +VOID +outgsd() +{ + register struct area *ap; + register struct sym *sp; + register int i, j; + char *ptr; + int c, narea, nglob, rn; + + /* + * Number of areas + */ + narea = areap->a_ref + 1; + + /* + * Number of global references/absolutes + */ + nglob = 0; + for (i = 0; i < NHASH; ++i) { + sp = symhash[i]; + while (sp) { + if (sp->s_flag&S_GBL) + ++nglob; + sp = sp->s_sp; + } + } + + /* + * Output Radix and number of areas and symbols + */ + if (xflag == 0) { + fprintf(ofp, "X%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %X areas %X global symbols\n", narea, nglob); + } else + if (xflag == 1) { + fprintf(ofp, "Q%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %o areas %o global symbols\n", narea, nglob); + } else + if (xflag == 2) { + fprintf(ofp, "D%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %u areas %u global symbols\n", narea, nglob); + } + + /* + * Module name + */ + if (module[0]) { + fprintf(ofp, "M "); + ptr = &module[0]; + while (ptr < &module[NCPS]) { + if ((c = *ptr++) != 0) + putc(c, ofp); + } + putc('\n', ofp); + } + + /* + * Global references and absolutes. + */ + rn = 0; + for (i=0; is_area==NULL && sp->s_flag&S_GBL) { + sp->s_ref = rn++; + outsym(sp); + } + sp = sp->s_sp; + } + } + + /* + * Global relocatables. + */ + for (i=0; ia_ref != i) + ap = ap->a_ap; + outarea(ap); + for (j=0; js_area==ap && sp->s_flag&S_GBL) { + sp->s_ref = rn++; + outsym(sp); + } + sp = sp->s_sp; + } + } + } +} + +/*)Function VOID outarea(ap) + * + * area * ap pointer to an area structure + * + * The function outarea() outputs the A line to the .REL + * file. The A line contains the area's name, size, and + * attributes. + * + * local variables: + * char * ptr pointer to area id string + * int c character value + * + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * int putc() c_library + * + * side effects: + * The A line is sent to the .REL file. + */ + +VOID +outarea(ap) +register struct area *ap; +{ + register char *ptr; + register int c; + + fprintf(ofp, "A "); + ptr = &ap->a_id[0]; + while (ptr < &ap->a_id[NCPS]) { + if ((c = *ptr++) != 0) + putc(c, ofp); + } + if (xflag == 0) { + fprintf(ofp, " size %X flags %X\n", ap->a_size, ap->a_flag); + } else + if (xflag == 1) { + fprintf(ofp, " size %o flags %o\n", ap->a_size, ap->a_flag); + } else + if (xflag == 2) { + fprintf(ofp, " size %u flags %u\n", ap->a_size, ap->a_flag); + } +} + +/*)Function VOID outsym(sp) + * + * sym * sp pointer to a sym structure + * + * The function outsym() outputs the S line to the .REL + * file. The S line contains the symbols name and whether the + * the symbol is defined or referenced. + * + * local variables: + * char * ptr pointer to symbol id string + * int c character value + * + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * int putc() c_library + * + * side effects: + * The S line is sent to the .REL file. + */ + +VOID +outsym(sp) +register struct sym *sp; +{ + register char *ptr; + + fprintf(ofp, "S "); + ptr = &sp->s_id[0]; + fprintf(ofp, "%s", ptr ); + fprintf(ofp, " %s", sp->s_type==S_NEW ? "Ref" : "Def"); + if (xflag == 0) { + fprintf(ofp, "%04X\n", sp->s_addr); + } else + if (xflag == 1) { + fprintf(ofp, "%06o\n", sp->s_addr); + } else + if (xflag == 2) { + fprintf(ofp, "%05u\n", sp->s_addr); + } +} + +/*)Function VOID out(p, n) + * + * int n number of words to output + * int * p pointer to data words + * + * The function out() outputs the data words to the .REL file + * int the specified radix. + * + * local variables: + * none + * + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * + * side effects: + * Data is sent to the .REL file. + */ + +VOID +out(p, n) +register char *p; +register int n; +{ + while (n--) { + if (xflag == 0) { + fprintf(ofp, " %02X", (*p++)&0377); + } else + if (xflag == 1) { + fprintf(ofp, " %03o", (*p++)&0377); + } else + if (xflag == 2) { + fprintf(ofp, " %03u", (*p++)&0377); + } + } +} + +/*)Function VOID out_lb(b, t) + * + * int b assembled data + * int t relocation type + * + * The function out_lb() copies the assembled data and + * its relocation type to the list data buffers. + * + * local variables: + * none + * + * global variables: + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * + * functions called: + * none + * + * side effects: + * Pointers to data and relocation buffers incremented by 1. + */ + +VOID +out_lb(b,t) +register int b,t; +{ + if (cp < &cb[NCODE]) { + *cp++ = b; + *cpt++ = t; + } +} + +/*)Function VOID out_lw(n, t) + * + * int n assembled data + * int t relocation type + * + * The function out_lw() copies the assembled data and + * its relocation type to the list data buffers. + * + * local variables: + * none + * + * global variables: + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * + * functions called: + * none + * + * side effects: + * Pointers to data and relocation buffers incremented by 2. + */ + +VOID +out_lw(n,t) +register int n,t; +{ + if (hilo) { + out_lb(hibyte(n),t ? t|R_HIGH : 0); + out_lb(lobyte(n),t); + } else { + out_lb(lobyte(n),t); + out_lb(hibyte(n),t ? t|R_HIGH : 0); + } +} + +/*)Function VOID out_rw(n) + * + * int n data word + * + * The function out_rw() outputs the relocation (R) + * data word as two bytes ordered according to hilo. + * + * local variables: + * int * relp pointer to rel array + * + * global variables: + * none + * + * functions called: + * int lobyte() asout.c + * int hibyte() asout.c + * + * side effects: + * Pointer to relocation buffer incremented by 2. + */ + +VOID +out_rw(n) +register int n; +{ + if (hilo) { + *relp++ = hibyte(n); + *relp++ = lobyte(n); + } else { + *relp++ = lobyte(n); + *relp++ = hibyte(n); + } +} + +/*)Function VOID out_tw(n) + * + * int n data word + * + * The function out_tw() outputs the text (T) + * data word as two bytes ordered according to hilo. + * + * local variables: + * int * txtp pointer to txt array + * + * global variables: + * none + * + * functions called: + * int lobyte() asout.c + * int hibyte() asout.c + * + * side effects: + * Pointer to relocation buffer incremented by 2. + */ + +VOID +out_tw(n) +register int n; +{ + if (hilo) { + *txtp++ = hibyte(n); + *txtp++ = lobyte(n); + } else { + *txtp++ = lobyte(n); + *txtp++ = hibyte(n); + } +} + +/*)Function int lobyte(n) + * + * int n data word + * + * The function lobyte() returns the lower byte of + * integer n. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +lobyte(n) +{ + return (n&0377); +} + +/*)Function int hibyte(n) + * + * int n data word + * + * The function hibyte() returns the higher byte of + * integer n. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +hibyte(n) +{ + return ((n>>8)&0377); +} + +/* + * JLH: Output relocatable 11 bit jump/call + * + * This function is derived from outrw(), adding the parameter for the + * 11 bit address. This form of address is used only on the 8051 and 8048. + */ +VOID +outr11(esp, op, r) +register struct expr *esp; +int op; +int r; +{ + register int n; + + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + /* equated absolute destination. Assume value + * relative to current area */ + esp->e_base.e_ap = dot.s_area; + } + + /* Relocatable destination. Build THREE + * byte output: relocatable word, followed + * by op-code. Linker will combine them. + * Listing shows only the address. + */ + r |= R_WORD | esp->e_rlcf; + out_lw(esp->e_addr,r|R_RELOC); + if (oflag) { + outchk(3, 4); + out_tw(esp->e_addr); + *txtp++ = op; + + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + *relp++ = r; + *relp++ = txtp - txt - 3; + out_rw(n); + } + } + dot.s_addr += 2; +} diff --git a/as/mcs51/asstore.c b/as/mcs51/asstore.c new file mode 100644 index 00000000..0bccc91a --- /dev/null +++ b/as/mcs51/asstore.c @@ -0,0 +1,45 @@ +/* strstore.c */ + +#include +#include +#include +#include +#include "asm.h" + +/* + * Allocate space for "str", copy str into new space + * Return a pointer to the allocated name, or NULL if out of memory + */ +char *StoreString( char *str ) +{ + /* To avoid wasting memory headers on small allocations, we + / allocate a big chunk and parcel it out as required. + / These static variables remember our hunk + */ + #define STR_STORE_HUNK 2000 + static char *pNextFree = NULL; + static int bytesLeft = 0; + + int length; + char *pStoredString; + + length = strlen( str ) + 1; /* what we need, including null */ + + if (length > bytesLeft) + { + /* no space. Allocate a new hunk. We lose the pointer to any + / old hunk. We don't care, as the names are never deleted. + */ + pNextFree = (char*)new( STR_STORE_HUNK ); + bytesLeft = STR_STORE_HUNK; + } + + /* Copy the name and terminating null into the name store */ + pStoredString = pNextFree; + memcpy( pStoredString, str, length ); + + pNextFree += length; + bytesLeft -= length; + + return pStoredString; +} diff --git a/as/mcs51/assubr.c b/as/mcs51/assubr.c new file mode 100644 index 00000000..d276061f --- /dev/null +++ b/as/mcs51/assubr.c @@ -0,0 +1,231 @@ +/* assubr.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module assubr.c + * + * The module assubr.c contains the error + * processing routines. + * + * assubr.c contains the following functions: + * VOID aerr() + * VOID diag() + * VOID err() + * VOID qerr() + * VOID rerr() + * + * assubr.c contains the local array of *error[] + */ + +/*)Function VOID err(c) + * + * int c error type character + * + * The function err() logs the error code character + * suppressing duplicate errors. If the error code + * is 'q' then the parse of the current assembler-source + * text line is terminated. + * + * local variables: + * char * p pointer to the error array + * + * global variables: + * char eb[] array of generated error codes + * + * functions called: + * VOID longjmp() c_library + * + * side effects: + * The error code may be inserted into the + * error code array eb[] or the parse terminated. + */ + +VOID +err(c) +register int c; +{ + register char *p; + + aserr++; + p = eb; + while (p < ep) + if (*p++ == c) + return; + if (p < &eb[NERR]) { + *p++ = c; + ep = p; + } + if (c == 'q') + longjmp(jump_env, -1); +} + +/*)Function VOID diag() + * + * The function diag() prints any error codes and + * the source line number to the stderr output device. + * + * local variables: + * char * p pointer to error code array eb[] + * + * global variables: + * int cfile current source file index + * char eb[] array of generated error codes + * char * ep pointer into error list + * int incfile current include file index + * char incfn[] array of include file names + * int incline[] array of include line numbers + * char srcfn[] array of source file names + * int srcline[] array of source line numbers + * FILE * stderr c_library + * + * functions called: + * int fprintf() c_library + * char * geterr() assubr.c + * + * side effects: + * none + */ + +VOID +diag() +{ + register char *p,*errstr; + + if (eb != ep) { + p = eb; + fprintf(stderr, "?ASxxxx-Error-<"); + while (p < ep) { + fprintf(stderr, "%c", *p++); + } + fprintf(stderr, "> in line "); + if (incfil >= 0) { + fprintf(stderr, "%d", incline[incfil]); + fprintf(stderr, " of %s\n", incfn[incfil]); + } else { + fprintf(stderr, "%d", srcline[cfile]); + fprintf(stderr, " of %s\n", srcfn[cfile]); + } + p = eb; + while (p < ep) { + if ((errstr = geterr(*p++)) != NULL) { + fprintf(stderr, " %s\n", errstr); + } + } + } +} + +/*)Functions: VOID aerr() + * VOID qerr() + * VOID rerr() + * + * The functions aerr(), qerr(), and rerr() report their + * respective error type. These are included only for + * convenience. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * VOID err() assubr.c + * + * side effects: + * The appropriate error code is inserted into the + * error array and the parse may be terminated. + */ + +/* + * Note an 'r' error. + */ +VOID +rerr() +{ + err('r'); +} + +/* + * Note an 'a' error. + */ +VOID +aerr() +{ + err('a'); +} + +/* + * Note a 'q' error. + */ +VOID +qerr() +{ + err('q'); +} + +/* + * ASxxxx assembler errors + */ +char *errors[] = { + "<.> use \". = . + \" not \". = \"", + " machine specific addressing or addressing mode error", + " direct page boundary error", + " direct page addressing error", + " .include file error or an .if/.endif mismatch", + " multiple definitions error", + " .org in REL area or directive / mnemonic error", + "

phase error: label location changing between passes 2 and 3", + " missing or improper operators, terminators, or delimiters", + " relocation error", + " undefined symbol encountered during assembly", + NULL +}; + +/*)Function: char *getarr(c) + * + * int c the error code character + * + * The function geterr() scans the list of errors returning the + * error string corresponding to the input error character. + * + * local variables: + * int i error index counter + * + * global variables: + * char *errors[] array of pointers to the + * error strings + * + * functions called: + * none + * + * side effects: + * A pointer to the appropriate + * error code string is returned. + */ +char * +geterr(c) +int c; +{ + int i; + + for (i=0; errors[i]!=NULL; i++) { + if (c == errors[i][1]) { + return(errors[i]); + } + } + return(NULL); +} + diff --git a/as/mcs51/assym.c b/as/mcs51/assym.c new file mode 100644 index 00000000..38be7ffb --- /dev/null +++ b/as/mcs51/assym.c @@ -0,0 +1,436 @@ +/* assym.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - lookup: Use StoreString for sym construction + * - change symeq() to do length-independent string compare + * - change hash() to do length-independent hash calculation + * 29-Oct-97 JLH: + * - make mnemonics case insensitive ALWAYS + * - make hash() case-insensitive always + * - replace symeq() call in mlookup with strcmpi + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module assym.c + * + * The module assym.c contains the functions that operate + * on the mnemonic/directive and symbol structures. + * + * assym.c contains the following functions: + * VOID allglob() + * area * alookup() + * int hash() + * sym * lookup() + * mne * mlookup() + * VOID * new() + * int symeq() + * VOID syminit() + * VOID symglob() + * + * assym.c contains no local/static variables. + */ + +/*)Function VOID syminit() + * + * The function syminit() is called early in the game + * to set up the hashtables. First all buckets in a + * table are cleared. Then a pass is made through + * the respective symbol lists, linking them into + * their hash buckets. Finally the base area pointer + * is set to 'dca'. + * + * local variables: + * int h computed hash value + * mne * mp pointer to a mne structure + * mne ** mpp pointer to an array of + * mne structure pointers + * sym * sp pointer to a sym structure + * sym ** spp pointer to an array of + * sym structure pointers + * + * global variables: + * area area[] single elememt area array + * area dca defined as area[0] + * mne * mnehash[] array of pointers to NHASH + * linked mnemonic/directive lists + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * (1) The symbol hash tables are initialized, + * the only defined symbol is '.'. + * (2) The mnemonic/directive hash tables are + * initialized with the assembler directives + * and mnemonics found in the machine dependent + * file ___pst.c. + * (3) The area pointer is initialized to dca (area[0]). + */ + +VOID +syminit() +{ + register struct mne *mp; + struct mne **mpp; + register struct sym *sp; + struct sym **spp; + register int h; + + mpp = &mnehash[0]; + while (mpp < &mnehash[NHASH]) + *mpp++ = NULL; + mp = &mne[0]; + for (;;) { + h = hash(mp->m_id); + mp->m_mp = mnehash[h]; + mnehash[h] = mp; + if (mp->m_flag&S_END) + break; + ++mp; + } + + spp = &symhash[0]; + while (spp < &symhash[NHASH]) + *spp++ = NULL; + sp = &sym[0]; + for (;;) { + h = hash(sp->s_id); + sp->s_sp = symhash[h]; + symhash[h] = sp; + if (sp->s_flag&S_END) + break; + ++sp; + } + + areap = &dca; +} + +/*)Function area * alookup(id) + * + * char * id area name string + * + * The function alookup() searches the area list for a + * match with id. If the area is defined then a pointer + * to this area is returned else a NULL is returned. + * + * local variables: + * area * ap pointer to area structure + * + * global variables: + * area * areap pointer to an area structure + * + * functions called: + * int symeq() assym.c + * + * side effects: + * none + */ + +struct area * +alookup(id) +char *id; +{ + register struct area *ap; + + ap = areap; + while (ap) { + if (symeq(id, ap->a_id)) { + return (ap); + } + ap = ap->a_ap; + } + return(NULL); +} + +/*)Function mne * mlookup(id) + * + * char * id mnemonic/directive name string + * + * The function mlookup() searches the mnemonic/directive + * hash tables for a match returning a pointer to the + * mne structure else it returns a NULL. + * + * local variables: + * mne * mp pointer to mne structure + * int h calculated hash value + * + * global variables: + * mne * mnehash[] array of pointers to NHASH + * linked mnemonic/directive lists + * + * functions called: + * none + * + * side effects: + * none + */ + +struct mne * +mlookup(id) +char *id; +{ + register struct mne *mp; + register int h; + + h = hash(id); + mp = mnehash[h]; + while (mp) { + if (strcmpi(id, mp->m_id) == 0) /* JLH: case insensitive */ + return (mp); + mp = mp->m_mp; + } + return (NULL); +} + +/*)Function sym * lookup(id) + * + * char * id symbol name string + * + * The function lookup() searches the symbol hash tables for + * a symbol name match returning a pointer to the sym structure. + * If the symbol is not found then a sym structure is created, + * initialized, and linked to the appropriate hash table. + * A pointer to this new sym structure is returned. + * + * local variables: + * int h computed hash value + * sym * sp pointer to a sym structure + * + * global varaibles: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * int hash() assym.c + * VOID * new() assym.c + * int symeq() assym.c + * + * side effects: + * If the function new() fails to allocate space + * for the new sym structure the assembly terminates. + */ + +struct sym * +lookup(id) +char *id; +{ + register struct sym *sp; + register int h; + + h = hash(id); + sp = symhash[h]; + while (sp) { + if (symeq(id, sp->s_id)) + return (sp); + sp = sp->s_sp; + } + sp = (struct sym *) new (sizeof(struct sym)); + sp->s_sp = symhash[h]; + symhash[h] = sp; + sp->s_tsym = NULL; + sp->s_id = StoreString( id ); /* JLH */ + sp->s_type = S_NEW; + sp->s_flag = 0; + sp->s_area = NULL; + sp->s_ref = 0; + sp->s_addr = 0; + return (sp); +} + +/*)Function VOID symglob() + * + * The function symglob() will mark all symbols of + * type S_NEW as global. Called at the beginning of pass 1 + * if the assembly option -g was specified. + * + * local variables: + * sym * sp pointer to a sym structure + * int i loop index + * + * global variables: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * Symbol types changed. + */ + +VOID +symglob() +{ + register struct sym *sp; + register int i; + + for (i=0; is_type == S_NEW) + sp->s_flag |= S_GBL; + sp = sp->s_sp; + } + } +} + +/*)Function VOID allglob() + * + * The function allglob() will mark all symbols of + * type S_USER as global. Called at the beginning of pass 1 + * if the assembly option -a was specified. + * + * local variables: + * sym * sp pointer to a sym structure + * int i loop index + * + * global variables: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * Symbol types changed. + */ + +VOID +allglob() +{ + register struct sym *sp; + register int i; + + for (i=0; is_type == S_USER) + sp->s_flag |= S_GBL; + sp = sp->s_sp; + } + } +} + +/*)Function int symeq(p1, p2) + * + * char * p1 name string + * char * p2 name string + * + * The function symeq() compares the two name strings for a match. + * The return value is 1 for a match and 0 for no match. + * + * local variables: + * int h loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + * + */ + +int +symeq(p1, p2) +register char *p1, *p2; +{ +#if CASE_SENSITIVE + return (strcmp( p1, p2 ) == 0); +#else + return (strcmpi( p1, p2 ) == 0); +#endif +} + +/*)Function int hash(p) + * + * char * p pointer to string to hash + * + * The function hash() computes a hash code using the sum + * of all characters mod table size algorithm. + * + * local variables: + * int h accumulated character sum + * int n loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + */ + +int +hash(p) +register char *p; +{ + register int h; + + h = 0; + while (*p) { + /* JLH: case insensitive hash: Doesn't much affect + * hashing, and allows same function for mnemonics and symbols + */ + h += ccase[(int)*p++]; + } + return (h&HMASK); +} + +/*)Function VOID * new(n) + * + * unsigned int n allocation size in bytes + * + * The function new() allocates n bytes of space and returns + * a pointer to this memory. If no space is available the + * assembly is terminated. + * + * local variables: + * VOID * p a general pointer + * + * global variables: + * none + * + * functions called: + * VOID asexit() asmain.c + * int fprintf() c_library + * VOID * malloc() c_library + * + * side effects: + * Memory is allocated, if allocation fails + * the assembly is terminated. + */ + +VOID * +new(n) +unsigned int n; +{ + register VOID *p; + + if ((p = (VOID *) malloc(n)) == NULL) { + fprintf(stderr, "Out of space!\n"); + asexit(1); + } + return (p); +} diff --git a/as/mcs51/clean.mk b/as/mcs51/clean.mk new file mode 100644 index 00000000..4704a9b3 --- /dev/null +++ b/as/mcs51/clean.mk @@ -0,0 +1,23 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f $(PRJDIR)/asx8051 $(PRJDIR)/aslink asx8051 aslink + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/as/mcs51/conf.mk b/as/mcs51/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/as/mcs51/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/as/mcs51/i51adr.c b/as/mcs51/i51adr.c new file mode 100644 index 00000000..62ef33dc --- /dev/null +++ b/as/mcs51/i51adr.c @@ -0,0 +1,258 @@ +/* i51adr.c */ + +/* + * (C) Copyright 1989,1990 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * Ported from 8085 to 8051 by John Hartman 30-Apr-1995 + * Continued, 29-May-95 + */ + +#include +#include +#include "asm.h" +#include "i8051.h" + +extern int admode (struct adsym *); + +struct adsym reg51[] = { /* R0 thru R7 registers */ +{ "R0", R0}, +{ "R1", R1}, +{ "R2", R2}, +{ "R3", R3}, +{ "R4", R4}, +{ "R5", R5}, +{ "R6", R6}, +{ "R7", R7}, +{ "A", A}, +{ "DPTR", DPTR}, +{ "PC", PC}, +{ "C", C}, +{ "AB", AB}, +{ "r0", R0}, +{ "r1", R1}, +{ "r2", R2}, +{ "r3", R3}, +{ "r4", R4}, +{ "r5", R5}, +{ "r6", R6}, +{ "r7", R7}, +{ "a", A}, +{ "dptr", DPTR}, +{ "pc", PC}, +{ "c", C}, +{ "ab", AB}, +{ "", 0x00} +}; + +/* Classify argument as to address mode */ +int +addr(esp) +register struct expr *esp; +{ + register int c; + register unsigned rd; + + if ((c = getnb()) == '#') { + /* Immediate mode */ + expr(esp, 0); + esp->e_mode = S_IMMED; + } + else if (c == '@') { + /* choices are @R0, @R1, @DPTR, @A+PC, @A+DPTR */ + switch (reg()) { + case R0: + esp->e_mode = S_AT_R; + esp->e_addr = R0; + break; + case R1: + esp->e_mode = S_AT_R; + esp->e_addr = R1; + break; + case DPTR: + esp->e_mode = S_AT_DP; + esp->e_addr = DPTR; + break; + case A: + if (getnb() == '+') { + rd = reg(); + if (rd == PC) { + esp->e_mode = S_AT_APC; + esp->e_addr = 0; + } else if (rd == DPTR) { + esp->e_mode = S_AT_ADP; + esp->e_addr = 0; + } else { + aerr(); + } + } else + aerr(); + break; + } + + esp->e_flag = 0; + esp->e_base.e_ap = NULL; + } + else if (c == '*') { + /* Force direct page */ + expr(esp, 0); + esp->e_mode = S_DIR; + if (esp->e_addr & ~0xFF) + err('d'); + } + else if (c == '/') { + /* Force inverted bit */ + expr(esp, 0); + esp->e_mode = S_NOT_BIT; + if (esp->e_addr & ~0xFF) + err('d'); + } + else { + unget(c); + + /* try for register: A, AB, R0-R7, DPTR, PC, Cy */ + if ((esp->e_addr = admode(reg51)) != -1) { + switch (esp->e_addr) { + case A: + esp->e_mode = S_A; + break; + case AB: + esp->e_mode = S_RAB; + break; + case DPTR: + esp->e_mode = S_DPTR; + break; + case PC: + esp->e_mode = S_PC; + break; + case C: + esp->e_mode = S_C; + break; + default: + /* R0-R7 */ + esp->e_mode = S_REG; + } + } else { + /* Must be an expression */ + expr(esp, 0); + if ((!esp->e_flag) + && (esp->e_base.e_ap==NULL) + && !(esp->e_addr & ~0xFF)) { + esp->e_mode = S_DIR; + } else { + esp->e_mode = S_EXT; + } + } + } + return (esp->e_mode); +} + + +/* + * any --- does str contain c? + */ +int +any(c,str) +char c, *str; +{ + while (*str) + if(*str++ == c) + return(1); + return(0); +} + +int +srch(str) +register char *str; +{ + register char *ptr; + ptr = ip; + +#if CASE_SENSITIVE + while (*ptr && *str) { + if(*ptr != *str) + break; + ptr++; + str++; + } + if (*ptr == *str) { + ip = ptr; + return(1); + } +#else + while (*ptr && *str) { + if(ccase[*ptr] != ccase[*str]) + break; + ptr++; + str++; + } + if (ccase[*ptr] == ccase[*str]) { + ip = ptr; + return(1); + } +#endif + + if (!*str) + if (any(*ptr," \t\n,];")) { + ip = ptr; + return(1); + } + return(0); +} + +/* + * Enter admode() to search a specific addressing mode table + * for a match. Return the addressing value on a match or + * -1 for no match. + */ +int +admode(sp) +register struct adsym *sp; +{ + register char *ptr; + register int i; + unget(getnb()); + i = 0; + while ( *(ptr = (char *) &sp[i]) ) { + if (srch(ptr)) { + return(sp[i].a_val); + } + i++; + } + return(-1); +} + +/* + * srch --- does string match ? + */ + +/* + * Read a register name. Return register value, -1 if no register found + */ +int +reg() +{ + register struct mne *mp; + char id[NCPS]; + + getid(id, -1); + if ((mp = mlookup(id))==NULL) { + aerr(); + return (-1); + } + switch (mp->m_type) { + case S_A: + case S_AB: + case S_DPTR: + case S_PC: + case S_REG: + return (mp->m_valu); + + default: + return (-1); + } +} diff --git a/as/mcs51/i51ext.c b/as/mcs51/i51ext.c new file mode 100644 index 00000000..ca04fd11 --- /dev/null +++ b/as/mcs51/i51ext.c @@ -0,0 +1,21 @@ +/* i51ext.c */ + +/* + * (C) Copyright 1989,1990 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * Ported from 8085 to 8051 by John Hartman 30-Apr-1995 + */ + +#include +#include +#include "asm.h" +#include "i8051.h" + +char *cpu = "Intel 8051"; +int hilo = 1; +char *dsft = "ASM"; diff --git a/as/mcs51/i51mch.c b/as/mcs51/i51mch.c new file mode 100644 index 00000000..e90d01a7 --- /dev/null +++ b/as/mcs51/i51mch.c @@ -0,0 +1,694 @@ +/* i85mch.c */ + +/* + * (C) Copyright 1989,1990 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 Ported from 8085 to 8051 by John Hartman + */ + +#include +#include +#include "asm.h" +#include "i8051.h" + +extern int addr(struct expr *); +/* + * Process machine ops. + */ +VOID +machine(mp) +struct mne *mp; +{ + register unsigned op; + register int t, t1, v1; + struct expr e, e1; + + clrexpr(&e); + clrexpr(&e1); + + op = mp->m_valu; + switch (mp->m_type) { + + case S_INH: + outab(op); + break; + + case S_JMP11: + /* 11 bit destination. Top 3 bits become the MSBs of + / the op-code. + */ + expr(&e, 0); + outr11(&e, op, R_J11); + break; + + case S_JMP16: + expr(&e, 0); + outab(op); + outrw(&e, 0); + break; + + case S_ACC: + t = addr(&e); + if (t != S_A) + aerr(); + outab(op); + break; + + case S_TYP1: + /* A, direct, @R0, @R1, R0 to R7. "INC" also allows DPTR */ + t = addr(&e); + + switch (t) { + case S_A: + outab(op + 4); + break; + + case S_DIR: + case S_EXT: + /* Direct is also legal */ + outab(op + 5); + outrb(&e, R_PAG0); + break; + + case S_AT_R: + outab(op + 6 + e.e_addr); + break; + + case S_REG: + outab(op + 8 + e.e_addr); + break; + + case S_DPTR: + if (op != 0) + /* only INC (op=0) has DPTR mode */ + aerr(); + else + outab( 0xA3); + break; + + default: + aerr(); + } + break; + + case S_TYP2: + /* A,#imm; A,direct; A,@R0; A,@R1; A,R0 to A,R7 */ + t = addr(&e); + if (t != S_A) + aerr(); + comma(); + t1 = addr(&e1); + + switch (t1) { + case S_IMMED: + outab(op + 4); + outrb(&e1, 0); + break; + + case S_DIR: + case S_EXT: + outab(op + 5); + outrb(&e1, R_PAG0); + break; + + case S_AT_R: + outab(op + 6 + e1.e_addr); + break; + + case S_REG: + outab(op + 8 + (e1.e_addr)); + break; + + default: + aerr(); + } + break; + + case S_TYP3: + /* dir,A; dir,#imm; + * A,#imm; A,direct; A,@R0; A,@R1; A,R0 to A,R7 + * C,direct; C,/direct + */ + t = addr(&e); + comma(); + t1 = addr(&e1); + + switch (t) { + case S_DIR: + case S_EXT: + switch (t1) { + case S_A: + outab(op + 2); + outrb(&e, R_PAG0); + break; + + case S_IMMED: + outab(op + 3); + outrb(&e, 0); + outrb(&e1, 0); + break; + default: + aerr(); + } + break; + + case S_A: + switch (t1) { + case S_IMMED: + outab(op + 4); + outrb(&e1, 0); + break; + + case S_DIR: + case S_EXT: + outab(op + 5); + outrb(&e1, R_PAG0); + break; + + case S_AT_R: + outab(op + 6 + e1.e_addr); + break; + + case S_REG: + outab(op + 8 + e1.e_addr); + break; + + default: + aerr(); + } + break; + + case S_C: + /* XRL has no boolean version. Trap it */ + if (op == 0x60) + aerr(); + + switch (t1) { + case S_DIR: + case S_EXT: + outab(op + 0x32); + outrb(&e1, R_PAG0); + break; + + case S_NOT_BIT: + outab(op + 0x60); + outrb(&e1, 0); + break; + + default: + aerr(); + } + break; + + default: + aerr(); + } + break; + + case S_TYP4: + /* A,direct; A,@R0; A,@R1; A,R0 to A,R7 */ + t = addr(&e); + if (t != S_A) + aerr(); + comma(); + t1 = addr(&e1); + + switch (t1) { + case S_DIR: + case S_EXT: + outab(op + 5); + outrb(&e1, R_PAG0); + break; + + case S_AT_R: + outab(op + 6 + e1.e_addr); + break; + + case S_REG: + outab(op + 8 + e1.e_addr); + break; + + default: + aerr(); + } + break; + + /* MOV instruction, all modes */ + case S_MOV: + t = addr(&e); + comma(); + t1 = addr(&e1); + + switch (t) { + case S_A: + switch (t1) { + case S_IMMED: + outab(0x74); + outrb(&e1, 0); + break; + + case S_DIR: + case S_EXT: + outab(0xE5); + outrb(&e1, R_PAG0); + break; + + case S_AT_R: + outab(0xE6 + e1.e_addr); + break; + + case S_REG: + outab(0xE8 + e1.e_addr); + break; + + default: + aerr(); + } + break; + + case S_REG: + switch (t1) { + case S_A: + outab(0xF8 + e.e_addr); + break; + + case S_IMMED: + outab(0x78 + e.e_addr); + outrb(&e1, 0); + break; + + case S_DIR: + case S_EXT: + outab(0xA8 + e.e_addr); + outrb(&e1, R_PAG0); + break; + + default: + aerr(); + } + break; + + case S_DIR: + case S_EXT: + switch (t1) { + case S_A: + outab(0xF5); + outrb(&e, R_PAG0); + break; + + case S_IMMED: + outab(0x75); + outrb(&e, R_PAG0); + outrb(&e1, 0); + break; + + case S_DIR: + case S_EXT: + outab(0x85); + outrb(&e1, R_PAG0); + outrb(&e, R_PAG0); + break; + + case S_AT_R: + outab(0x86 + e1.e_addr); + outrb(&e, R_PAG0); + break; + + case S_REG: + outab(0x88 + e1.e_addr); + outrb(&e, R_PAG0); + break; + + case S_C: + outab(0x92); + outrb(&e, R_PAG0); + break; + + default: + aerr(); + } + break; + + case S_AT_R: + switch (t1) { + case S_IMMED: + outab(0x76 + e.e_addr); + outrb(&e1, 0); + break; + + case S_DIR: + case S_EXT: + outab(0xA6 + e.e_addr); + outrb(&e1, R_PAG0); + break; + + case S_A: + outab(0xF6 + e.e_addr); + break; + + default: + aerr(); + } + break; + + case S_C: + if ((t1 != S_DIR) && (t1 != S_EXT)) + aerr(); + outab(0xA2); + outrb(&e1, R_PAG0); + break; + + case S_DPTR: + if (t1 != S_IMMED) + aerr(); + outab(0x90); + outrw(&e1, 0); + break; + + default: + aerr(); + } + break; + + case S_BITBR: + /* Branch on bit set/clear */ + t = addr(&e); + if ((t != S_DIR) && (t != S_EXT)) + aerr(); + outab(op); + outrb(&e, R_PAG0); + + comma(); + expr(&e1, 0); + if (e1.e_base.e_ap == NULL || e1.e_base.e_ap == dot.s_area) { + if ( e1.e_addr == dot.s_addr) + v1 = -3; + else + v1 = e1.e_addr - dot.s_addr - 1; + /* if ((v1 < -128) || (v1 > 127)) + aerr(); */ + outab(v1); + } else { + outrb(&e1, R_PCR); + } + if (e1.e_mode != S_USER) + rerr(); + break; + + case S_BR: + /* Relative branch */ + outab(op); + expr(&e1, 0); + if (e1.e_base.e_ap == NULL || e1.e_base.e_ap == dot.s_area) { + if ( e1.e_addr == dot.s_addr) + v1 = -2; + else + v1 = e1.e_addr - dot.s_addr - 1; + /* if ((v1 < -128) || (v1 > 127)) + aerr();*/ + outab(v1); + } else { + outrb(&e1, R_PCR); + } + if (e1.e_mode != S_USER) + rerr(); + break; + + case S_CJNE: + /* A,#; A,dir; @R0,#; @R1,#; Rn,# */ + t = addr(&e); + comma(); + t1 = addr(&e1); + switch (t) { + case S_A: + if (t1 == S_IMMED) { + outab(op + 4); + outrb(&e1, 0); + } + else if ((t1 == S_DIR) || (t1 == S_EXT)) { + outab(op + 5); + outrb(&e1, R_PAG0); + } + else + aerr(); + break; + + case S_AT_R: + outab(op + 6 + e.e_addr); + if (t1 != S_IMMED) + aerr(); + outrb(&e1, 0); + break; + + case S_REG: + outab(op + 8 + e.e_addr); + if (t1 != S_IMMED) + aerr(); + outrb(&e1, 0); + break; + + default: + aerr(); + } + + /* branch destination */ + comma(); + expr(&e1, 0); + if (e1.e_base.e_ap == NULL || e1.e_base.e_ap == dot.s_area) { + if ( e1.e_addr == dot.s_addr) + v1 = -3; + else + v1 = e1.e_addr - dot.s_addr - 1; + /* if ((v1 < -128) || (v1 > 127)) + aerr(); */ + outab(v1); + } else { + outrb(&e1, R_PCR); + } + if (e1.e_mode != S_USER) + rerr(); + break; + + case S_DJNZ: + /* Dir,dest; Reg,dest */ + t = addr(&e); + switch (t) { + + case S_DIR: + case S_EXT: + outab(op + 5); + outrb(&e, R_PAG0); + break; + + case S_REG: + outab(op + 8 + e.e_addr); + break; + + default: + aerr(); + } + + /* branch destination */ + comma(); + expr(&e1, 0); + if (e1.e_base.e_ap == NULL || e1.e_base.e_ap == dot.s_area) { + if ( e1.e_addr == dot.s_addr) + v1 = -2; + else + v1 = e1.e_addr - dot.s_addr - 1; + /* if ((v1 < -128) || (v1 > 127)) + aerr(); */ + outab(v1); + } else { + outrb(&e1, R_PCR); + } + if (e1.e_mode != S_USER) + rerr(); + break; + + case S_JMP: + /* @A+DPTR */ + t = addr(&e); + if (t != S_AT_ADP) + aerr(); + outab(op); + break; + + case S_MOVC: + /* A,@A+DPTR A,@A+PC */ + t = addr(&e); + if (t != S_A) + aerr(); + comma(); + t1 = addr(&e1); + if (t1 == S_AT_ADP) + outab(0x93); + else if (t1 == S_AT_APC) + outab(0x83); + else + aerr(); + break; + + case S_MOVX: + /* A,@DPTR A,@R0 A,@R1 @DPTR,A @R0,A @R1,A */ + t = addr(&e); + comma(); + t1 = addr(&e1); + + switch (t) { + case S_A: + switch (t1) { + case S_AT_DP: + outab(0xE0); + break; + case S_AT_R: + outab(0xE2 + e1.e_addr); + break; + default: + aerr(); + } + break; + + case S_AT_DP: + if (t1 == S_A) + outab(0xF0); + else + aerr(); + break; + + case S_AT_R: + if (t1 == S_A) + outab(0xF2 + e.e_addr); + else + aerr(); + break; + + default: + aerr(); + } + break; + + /* MUL/DIV A,B */ + case S_AB: + t = addr(&e); + if (t != S_RAB) aerr(); + outab(op); + break; + + /* CLR or CPL: A, C, or bit */ + case S_ACBIT: + t = addr(&e); + switch (t) { + case S_A: + if (op == 0xB2) + outab(0xF4); + else + outab(0xE4); + break; + + case S_C: + outab(op+1); + break; + + case S_DIR: + case S_EXT: + outab(op); + outrb(&e, R_PAG0); + break; + + default: + aerr(); + } + break; + + /* SETB C or bit */ + case S_SETB: + t = addr(&e); + switch (t) { + case S_C: + outab(op+1); + break; + + case S_DIR: + case S_EXT: + outab(op); + outrb(&e, R_PAG0); + break; + + default: + aerr(); + } + break; + + /* direct */ + case S_DIRECT: + t = addr(&e); + if ((t != S_DIR) && (t != S_EXT)) { + aerr(); + break; + } + outab(op); + outrb(&e, R_PAG0); + break; + + /* XCHD A,@Rn */ + case S_XCHD: + t = addr(&e); + if (t != S_A) + aerr(); + comma(); + t1 = addr(&e1); + switch (t1) { + case S_AT_R: + outab(op + e1.e_addr); + break; + default: + aerr(); + } + break; + + default: + err('o'); + } +} + +/* + * Is the next character a comma ? + */ +int +comma() +{ + if (getnb() != ',') + qerr(); + return(1); +} + + /* + * Machine specific initialization + */ + VOID + minit() + { + static int beenHere=0; /* set non-zero if we have done that... */ + struct sym *sp; + struct PreDef *pd; + + /* First time only, add the pe-defined symbols to the symbol table*/ + if (beenHere == 0) { + pd = preDef; + while (*pd->id) { + sp = lookup(pd->id); + if (sp->s_type == S_NEW) { + sp->s_addr = pd->value; + sp->s_type = S_DIR; + } + pd++; + } + beenHere = 1; + } +} diff --git a/as/mcs51/i51pst.c b/as/mcs51/i51pst.c new file mode 100644 index 00000000..f084ca60 --- /dev/null +++ b/as/mcs51/i51pst.c @@ -0,0 +1,471 @@ +/* i85pst.c */ + +/* + * (C) Copyright 1989,1990 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 Ported from 8085 to 8051 by John Hartman + * 30-Jan-98 JLH: add memory-space flags for .AREA + */ + +#include +#include +#include "asm.h" +#include "i8051.h" + +struct mne mne[] = { + + /* machine */ + + /* system */ + + { NULL, "CON", S_ATYP, 0, A_CON}, + { NULL, "OVR", S_ATYP, 0, A_OVR}, + { NULL, "REL", S_ATYP, 0, A_REL}, + { NULL, "ABS", S_ATYP, 0, A_ABS|A_OVR}, + { NULL, "NOPAG", S_ATYP, 0, A_NOPAG}, + { NULL, "PAG", S_ATYP, 0, A_PAG}, + + { NULL, "CODE", S_ATYP, 0, A_CODE}, + { NULL, "DATA", S_ATYP, 0, A_DATA}, + { NULL, "XDATA", S_ATYP, 0, A_XDATA}, + { NULL, "BIT", S_ATYP, 0, A_BIT}, + + { NULL, ".byte", S_BYTE, 0, 0}, + { NULL, ".db", S_BYTE, 0, 0}, + { NULL, ".word", S_WORD, 0, 0}, + { NULL, ".dw", S_WORD, 0, 0}, + { NULL, ".ascii", S_ASCII, 0, 0}, + { NULL, ".asciz", S_ASCIZ, 0, 0}, + { NULL, ".blkb", S_BLK, 0, 1}, + { NULL, ".ds", S_BLK, 0, 1}, + { NULL, ".blkw", S_BLK, 0, 2}, + { NULL, ".page", S_PAGE, 0, 0}, + { NULL, ".title", S_TITLE, 0, 0}, + { NULL, ".sbttl", S_SBTL, 0, 0}, + { NULL, ".globl", S_GLOBL, 0, 0}, + { NULL, ".area", S_DAREA, 0, 0}, + { NULL, ".even", S_EVEN, 0, 0}, + { NULL, ".odd", S_ODD, 0, 0}, + { NULL, ".if", S_IF, 0, 0}, + { NULL, ".else", S_ELSE, 0, 0}, + { NULL, ".endif", S_ENDIF, 0, 0}, + { NULL, ".include", S_INCL, 0, 0}, + { NULL, ".radix", S_RADIX, 0, 0}, + { NULL, ".org", S_ORG, 0, 0}, + { NULL, ".module", S_MODUL, 0, 0}, + { NULL, ".ascis", S_ASCIS, 0, 0}, + + /* 8051 */ + + { NULL, "a", S_A, 0, A}, + { NULL, "ab", S_AB, 0, 0}, + { NULL, "dptr", S_DPTR, 0, DPTR}, + { NULL, "pc", S_PC, 0, PC}, + { NULL, "r0", S_REG, 0, R0}, + { NULL, "r1", S_REG, 0, R1}, + { NULL, "r2", S_REG, 0, R2}, + { NULL, "r3", S_REG, 0, R3}, + { NULL, "r4", S_REG, 0, R4}, + { NULL, "r5", S_REG, 0, R5}, + { NULL, "r6", S_REG, 0, R6}, + { NULL, "r7", S_REG, 0, R7}, + + { NULL, "nop", S_INH, 0, 0x00}, + { NULL, "ret", S_INH, 0, 0x22}, + { NULL, "reti", S_INH, 0, 0x32}, + + { NULL, "ajmp", S_JMP11, 0, 0x01}, + { NULL, "acall", S_JMP11, 0, 0x11}, + { NULL, "ljmp", S_JMP16, 0, 0x02}, + { NULL, "lcall", S_JMP16, 0, 0x12}, + + { NULL, "rr", S_ACC, 0, 0x03}, + { NULL, "rrc", S_ACC, 0, 0x13}, + { NULL, "rl", S_ACC, 0, 0x23}, + { NULL, "rlc", S_ACC, 0, 0x33}, + { NULL, "swap", S_ACC, 0, 0xC4}, + { NULL, "da", S_ACC, 0, 0xD4}, + + { NULL, "inc", S_TYP1, 0, 0x00}, + { NULL, "dec", S_TYP1, 0, 0x10}, + + { NULL, "add", S_TYP2, 0, 0x20}, + { NULL, "addc", S_TYP2, 0, 0x30}, + { NULL, "subb", S_TYP2, 0, 0x90}, + + { NULL, "orl", S_TYP3, 0, 0x40}, + { NULL, "anl", S_TYP3, 0, 0x50}, + { NULL, "xrl", S_TYP3, 0, 0x60}, + + { NULL, "xch", S_TYP4, 0, 0xC0}, + + { NULL, "mov", S_MOV, 0, 0x00}, + + { NULL, "jbc", S_BITBR, 0, 0x10}, + { NULL, "jb", S_BITBR, 0, 0x20}, + { NULL, "jnb", S_BITBR, 0, 0x30}, + + { NULL, "jc", S_BR, 0, 0x40}, + { NULL, "jnc", S_BR, 0, 0x50}, + { NULL, "jz", S_BR, 0, 0x60}, + { NULL, "jnz", S_BR, 0, 0x70}, + { NULL, "sjmp", S_BR, 0, 0x80}, + + { NULL, "cjne", S_CJNE, 0, 0xB0}, + { NULL, "djnz", S_DJNZ, 0, 0xD0}, + { NULL, "jmp", S_JMP, 0, 0x73}, + { NULL, "movc", S_MOVC, 0, 0x83}, + { NULL, "movx", S_MOVX, 0, 0x00}, + { NULL, "div", S_AB, 0, 0x84}, + { NULL, "mul", S_AB, 0, 0xA4}, + { NULL, "clr", S_ACBIT, 0, 0xC2}, + { NULL, "cpl", S_ACBIT, 0, 0xB2}, + { NULL, "setb", S_SETB, 0, 0xD2}, + { NULL, "push", S_DIRECT, 0, 0xC0}, + { NULL, "pop", S_DIRECT, 0, 0xD0}, + { NULL, "xchd", S_XCHD, S_END, 0xD6} +}; + +struct PreDef preDef[] = { + {"AC", 0x00D6}, + {"ac", 0x00D6}, + {"A", 0x00D6}, + {"a", 0x00D6}, + {"ACC", 0x00E0}, + {"acc", 0x00E0}, + {"ACC.0", 0x00E0}, + {"ACC.1", 0x00E1}, + {"ACC.2", 0x00E2}, + {"ACC.3", 0x00E3}, + {"ACC.4", 0x00E4}, + {"ACC.5", 0x00E5}, + {"ACC.6", 0x00E6}, + {"ACC.7", 0x00E7}, + {"acc.0", 0x00E0}, + {"acc.1", 0x00E1}, + {"acc.2", 0x00E2}, + {"acc.3", 0x00E3}, + {"acc.4", 0x00E4}, + {"acc.5", 0x00E5}, + {"acc.6", 0x00E6}, + {"acc.7", 0x00E7}, + {"B", 0x00F0}, + {"B.0", 0x00F0}, + {"B.1", 0x00F1}, + {"B.2", 0x00F2}, + {"B.3", 0x00F3}, + {"B.4", 0x00F4}, + {"B.5", 0x00F5}, + {"B.6", 0x00F6}, + {"B.7", 0x00F7}, + {"b", 0x00F0}, + {"b.0", 0x00F0}, + {"b.1", 0x00F1}, + {"b.2", 0x00F2}, + {"b.3", 0x00F3}, + {"b.4", 0x00F4}, + {"b.5", 0x00F5}, + {"b.6", 0x00F6}, + {"b.7", 0x00F7}, + {"CPRL2", 0x00C8}, + {"cprl2", 0x00C8}, + {"CT2", 0x00C9}, + {"ct2", 0x00C9}, + {"CY", 0x00D7}, + {"cy", 0x00D7}, + {"DPH", 0x0083}, + {"DPL", 0x0082}, + {"dph", 0x0083}, + {"dpl", 0x0082}, + {"EA", 0x00AF}, + {"ea", 0x00AF}, + {"ES", 0x00AC}, + {"es", 0x00AC}, + {"ET0", 0x00A9}, + {"et0", 0x00A9}, + {"ET1", 0x00AB}, + {"et1", 0x00AB}, + {"ET2", 0x00AD}, + {"et2", 0x00AD}, + {"EX0", 0x00A8}, + {"ex0", 0x00A8}, + {"EX1", 0x00AA}, + {"ex1", 0x00AA}, + {"EXEN2", 0x00CB}, + {"exen2", 0x00CB}, + {"EXF2", 0x00CE}, + {"exf2", 0x00CE}, + {"F0", 0x00D5}, + {"f0", 0x00D5}, + {"IE", 0x00A8}, + {"IE.0", 0x00A8}, + {"IE.1", 0x00A9}, + {"IE.2", 0x00AA}, + {"IE.3", 0x00AB}, + {"IE.4", 0x00AC}, + {"IE.5", 0x00AD}, + {"IE.7", 0x00AF}, + {"ie", 0x00A8}, + {"ie.0", 0x00A8}, + {"ie.1", 0x00A9}, + {"ie.2", 0x00AA}, + {"ie.3", 0x00AB}, + {"ie.4", 0x00AC}, + {"ie.5", 0x00AD}, + {"ie.7", 0x00AF}, + {"IE0", 0x0089}, + {"ie0", 0x0089}, + {"IE1", 0x008B}, + {"ie1", 0x008B}, + {"INT0", 0x00B2}, + {"int0", 0x00B2}, + {"INT1", 0x00B3}, + {"int1", 0x00B3}, + {"IP", 0x00B8}, + {"IP.0", 0x00B8}, + {"IP.1", 0x00B9}, + {"IP.2", 0x00BA}, + {"IP.3", 0x00BB}, + {"IP.4", 0x00BC}, + {"IP.5", 0x00BD}, + {"ip", 0x00B8}, + {"ip.0", 0x00B8}, + {"ip.1", 0x00B9}, + {"ip.2", 0x00BA}, + {"ip.3", 0x00BB}, + {"ip.4", 0x00BC}, + {"ip.5", 0x00BD}, + {"IT0", 0x0088}, + {"it0", 0x0088}, + {"IT1", 0x008A}, + {"it1", 0x008A}, + {"OV", 0x00D2}, + {"ov", 0x00D2}, + {"P", 0x00D0}, + {"p", 0x00D0}, + {"P0", 0x0080}, + {"P0.0", 0x0080}, + {"P0.1", 0x0081}, + {"P0.2", 0x0082}, + {"P0.3", 0x0083}, + {"P0.4", 0x0084}, + {"P0.5", 0x0085}, + {"P0.6", 0x0086}, + {"P0.7", 0x0087}, + {"p0", 0x0080}, + {"p0.0", 0x0080}, + {"p0.1", 0x0081}, + {"p0.2", 0x0082}, + {"p0.3", 0x0083}, + {"p0.4", 0x0084}, + {"p0.5", 0x0085}, + {"p0.6", 0x0086}, + {"p0.7", 0x0087}, + {"P1", 0x0090}, + {"P1.0", 0x0090}, + {"P1.1", 0x0091}, + {"P1.2", 0x0092}, + {"P1.3", 0x0093}, + {"P1.4", 0x0094}, + {"P1.5", 0x0095}, + {"P1.6", 0x0096}, + {"P1.7", 0x0097}, + {"p1", 0x0090}, + {"p1.0", 0x0090}, + {"p1.1", 0x0091}, + {"p1.2", 0x0092}, + {"p1.3", 0x0093}, + {"p1.4", 0x0094}, + {"p1.5", 0x0095}, + {"p1.6", 0x0096}, + {"p1.7", 0x0097}, + {"P2", 0x00A0}, + {"P2.0", 0x00A0}, + {"P2.1", 0x00A1}, + {"P2.2", 0x00A2}, + {"P2.3", 0x00A3}, + {"P2.4", 0x00A4}, + {"P2.5", 0x00A5}, + {"P2.6", 0x00A6}, + {"P2.7", 0x00A7}, + {"p2", 0x00A0}, + {"p2.0", 0x00A0}, + {"p2.1", 0x00A1}, + {"p2.2", 0x00A2}, + {"p2.3", 0x00A3}, + {"p2.4", 0x00A4}, + {"p2.5", 0x00A5}, + {"p2.6", 0x00A6}, + {"p2.7", 0x00A7}, + {"P3", 0x00B0}, + {"P3.0", 0x00B0}, + {"P3.1", 0x00B1}, + {"P3.2", 0x00B2}, + {"P3.3", 0x00B3}, + {"P3.4", 0x00B4}, + {"P3.5", 0x00B5}, + {"P3.6", 0x00B6}, + {"P3.7", 0x00B7}, + {"p3", 0x00B0}, + {"p3.0", 0x00B0}, + {"p3.1", 0x00B1}, + {"p3.2", 0x00B2}, + {"p3.3", 0x00B3}, + {"p3.4", 0x00B4}, + {"p3.5", 0x00B5}, + {"p3.6", 0x00B6}, + {"p3.7", 0x00B7}, + {"PCON", 0x0087}, + {"pcon", 0x0087}, + {"PS", 0x00BC}, + {"ps", 0x00BC}, + {"PSW", 0x00D0}, + {"PSW.0", 0x00D0}, + {"PSW.1", 0x00D1}, + {"PSW.2", 0x00D2}, + {"PSW.3", 0x00D3}, + {"PSW.4", 0x00D4}, + {"PSW.5", 0x00D5}, + {"PSW.6", 0x00D6}, + {"PSW.7", 0x00D7}, + {"psw", 0x00D0}, + {"psw.0", 0x00D0}, + {"psw.1", 0x00D1}, + {"psw.2", 0x00D2}, + {"psw.3", 0x00D3}, + {"psw.4", 0x00D4}, + {"psw.5", 0x00D5}, + {"psw.6", 0x00D6}, + {"psw.7", 0x00D7}, + {"PT0", 0x00B9}, + {"pt0", 0x00B9}, + {"PT1", 0x00BB}, + {"pt1", 0x00BB}, + {"PT2", 0x00BD}, + {"pt2", 0x00BD}, + {"PX0", 0x00B8}, + {"px0", 0x00B8}, + {"PX1", 0x00BA}, + {"px1", 0x00BA}, + {"RB8", 0x009A}, + {"rb8", 0x009A}, + {"RCAP2H", 0x00CB}, + {"rcap2h", 0x00CB}, + {"RCAP2L", 0x00CA}, + {"rcap2l", 0x00CA}, + {"RCLK", 0x00CD}, + {"rclk", 0x00CD}, + {"REN", 0x009C}, + {"ren", 0x009C}, + {"RI", 0x0098}, + {"ri", 0x0098}, + {"RS0", 0x00D3}, + {"rs0", 0x00D3}, + {"RS1", 0x00D4}, + {"rs1", 0x00D4}, + {"rxd", 0x00B0}, + {"RXD", 0x00B0}, + {"SBUF", 0x0099}, + {"sbuf", 0x0099}, + {"SCON", 0x0098}, + {"SCON.0", 0x0098}, + {"SCON.1", 0x0099}, + {"SCON.2", 0x009A}, + {"SCON.3", 0x009B}, + {"SCON.4", 0x009C}, + {"SCON.5", 0x009D}, + {"SCON.6", 0x009E}, + {"SCON.7", 0x009F}, + {"scon", 0x0098}, + {"scon.0", 0x0098}, + {"scon.1", 0x0099}, + {"scon.2", 0x009A}, + {"scon.3", 0x009B}, + {"scon.4", 0x009C}, + {"scon.5", 0x009D}, + {"scon.6", 0x009E}, + {"scon.7", 0x009F}, + {"SM0", 0x009F}, + {"sm0", 0x009F}, + {"SM1", 0x009E}, + {"sm1", 0x009E}, + {"SM2", 0x009D}, + {"sm2", 0x009D}, + {"SP", 0x0081}, + {"sp", 0x0081}, + {"T2CON", 0x00C8}, + {"T2CON.0",0x00C8}, + {"T2CON.1",0x00C9}, + {"T2CON.2",0x00CA}, + {"T2CON.3",0x00CB}, + {"T2CON.4",0x00CC}, + {"T2CON.5",0x00CD}, + {"T2CON.6",0x00CE}, + {"T2CON.7",0x00CF}, + {"t2con", 0x00C8}, + {"t2con.0",0x00C8}, + {"t2con.1",0x00C9}, + {"t2con.2",0x00CA}, + {"t2con.3",0x00CB}, + {"t2con.4",0x00CC}, + {"t2con.5",0x00CD}, + {"t2con.6",0x00CE}, + {"t2con.7",0x00CF}, + {"TB8", 0x009B}, + {"tb8", 0x009B}, + {"TCLK", 0x00CC}, + {"tclk", 0x00CC}, + {"TCON", 0x0088}, + {"TCON.0", 0x0088}, + {"TCON.1", 0x0089}, + {"TCON.2", 0x008A}, + {"TCON.3", 0x008B}, + {"TCON.4", 0x008C}, + {"TCON.5", 0x008D}, + {"TCON.6", 0x008E}, + {"TCON.7", 0x008F}, + {"tcon", 0x0088}, + {"tcon.0", 0x0088}, + {"tcon.1", 0x0089}, + {"tcon.2", 0x008A}, + {"tcon.3", 0x008B}, + {"tcon.4", 0x008C}, + {"tcon.5", 0x008D}, + {"tcon.6", 0x008E}, + {"tcon.7", 0x008F}, + {"TF0", 0x008D}, + {"tf0", 0x008D}, + {"TF1", 0x008F}, + {"tf1", 0x008F}, + {"TF2", 0x00CF}, + {"tf2", 0x00CF}, + {"TH0", 0x008C}, + {"th0", 0x008C}, + {"TH1", 0x008D}, + {"th1", 0x008D}, + {"TH2", 0x00CD}, + {"th2", 0x00CD}, + {"TI", 0x0099}, + {"ti", 0x0099}, + {"TL0", 0x008A}, + {"tl0", 0x008A}, + {"TL1", 0x008B}, + {"tl1", 0x008B}, + {"TL2", 0x00CC}, + {"tl2", 0x00CC}, + {"TMOD", 0x0089}, + {"tmod", 0x0089}, + {"TR0", 0x008C}, + {"tr0", 0x008C}, + {"TR1", 0x008E}, + {"tr1", 0x008E}, + {"TR2", 0x00CA}, + {"tr2", 0x00CA}, + {"TXD", 0x00B1}, + {"txd", 0x00B1}, +}; diff --git a/as/mcs51/i8051.h b/as/mcs51/i8051.h new file mode 100644 index 00000000..ac3e726a --- /dev/null +++ b/as/mcs51/i8051.h @@ -0,0 +1,118 @@ +/* i8051.h */ + +/* + * (C) Copyright 1989,1990 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * Ported from 8085 to 8051 by John Hartman 30-Apr-1995 + * Continued, 2-Jun-95 + */ + +/*)BUILD + $(PROGRAM) = AS8051 + $(INCLUDE) = { + ASM.H + I8051.H + } + $(FILES) = { + I51EXT.C + I51MCH.C + I51PST.C + ASMAIN.C + ASLEX.C + ASSYM.C + ASSUBR.C + ASEXPR.C + ASDATA.C + ASLIST.C + ASOUT.C + } + $(STACK) = 2000 +*/ + +/* + * Symbol types. + */ +#define S_INH 50 /* One byte inherent */ +#define S_JMP11 51 /* Jump and call 11 bit. */ +#define S_JMP16 52 /* Jump and call 16 bit */ +#define S_ACC 53 /* Accumulator */ +#define S_TYP1 54 /* Type 1 (inc and dec) */ +#define S_TYP2 55 /* Type 2 (arith ops) */ +#define S_TYP3 56 /* Type 3 (logic ops) */ +#define S_TYP4 57 /* Type 4 (XCH) */ +#define S_MOV 58 /* MOV */ +#define S_BITBR 59 /* bit branch */ +#define S_BR 60 /* branch */ +#define S_ACBIT 61 /* CLR, CPL */ +#define S_CJNE 62 /* CJNE */ +#define S_DJNZ 63 /* DJNZ */ +#define S_JMP 64 /* JMP */ +#define S_MOVC 65 /* MOVC */ +#define S_MOVX 66 /* MOVX */ +#define S_AB 67 /* AB (div and mul) */ +#define S_CPL 68 /* CPL */ +#define S_SETB 69 /* SETB */ +#define S_DIRECT 70 /* DIRECT (pusha and pop) */ +#define S_XCHD 71 /* XCHD */ + +/* Addressing modes */ +#define S_A 30 /* A */ +/* #define S_B 31 */ /* B */ +#define S_C 32 /* C (carry) */ +#define S_RAB 33 /* AB */ +#define S_DPTR 34 /* DPTR */ +#define S_REG 35 /* Register R0-R7 */ +#define S_IMMED 36 /* immediate */ +#define S_DIR 37 /* direct */ +#define S_EXT 38 /* extended */ +#define S_PC 39 /* PC (for addressing mode) */ + +#define S_AT_R 40 /* @R0 or @R1 */ +#define S_AT_DP 41 /* @DPTR */ +#define S_AT_APC 42 /* @A+PC */ +#define S_AT_ADP 43 /* @A+DPTR */ +#define S_NOT_BIT 44 /* /BIT (/DIR) */ + +/* + * Registers. Value == address in RAM, except for PC + */ +#define R0 0 +#define R1 1 +#define R2 2 +#define R3 3 +#define R4 4 +#define R5 5 +#define R6 6 +#define R7 7 +#define A 0xE0 +#define DPTR 0x82 +#define PC 0xFF /* dummy number for register ID only */ +#define AB 0xFE /* dummy number for register ID only */ +#define C 0xFD /* dummy number for register ID only */ + +struct adsym +{ + char a_str[5]; /* addressing string (length for DPTR+null)*/ + int a_val; /* addressing mode value */ +}; + +/* pre-defined symbol structure: name and value */ +struct PreDef +{ + char id[NCPS]; + int value; +}; +extern struct PreDef preDef[]; + + /* machine dependent functions */ + + /* i51mch.c */ +extern int comma(); +extern VOID machin(); +extern VOID minit(); +extern int reg(); diff --git a/as/mcs51/lkarea.c b/as/mcs51/lkarea.c new file mode 100644 index 00000000..b535f259 --- /dev/null +++ b/as/mcs51/lkarea.c @@ -0,0 +1,451 @@ +/* lkarea.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 3-Nov-97 JLH: + * - change lkparea to use a_type == 0 as "virgin area" flag + * 02-Apr-98 JLH: add code to link 8051 data spaces + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkarea.c + * + * The module lkarea.c contains the functions which + * create and link together all area definitions read + * from the .rel file(s). + * + * lkarea.c contains the following functions: + * VOID lnkarea() + * VOID lnksect() + * VOID lkparea() + * VOID newarea() + * + * lkarea.c contains no global variables. + */ + +/*)Function VOID newarea() + * + * The function newarea() creates and/or modifies area + * and areax structures for each A directive read from + * the .rel file(s). The function lkparea() is called + * to find tha area structure associated with this name. + * If the area does not yet exist then a new area + * structure is created and linked to any existing + * linked area structures. The area flags are copied + * into the area flag variable. For each occurence of + * an A directive an areax structure is created and + * linked to the areax structures associated with this + * area. The size of this area section is placed into + * the areax structure. The flag value for all subsequent + * area definitions for the same area are compared and + * flagged as an error if they are not identical. + * The areax structure created for every occurence of + * an A directive is loaded with a pointer to the base + * area structure and a pointer to the associated + * head structure. And finally, a pointer to this + * areax structure is loaded into the list of areax + * structures in the head structure. Refer to lkdata.c + * for details of the structures and their linkage. + * + * local variables: + * areax **halp pointer to an array of pointers + * int i counter, loop variable, value + * char id[] id string + * int narea number of areas in this head structure + * areax * taxp pointer to an areax structure + * to areax structures + * + * global variables: + * area *ap Pointer to the current + * area structure + * areax *axp Pointer to the current + * areax structure + * head *hp Pointer to the current + * head structure + * int lkerr error flag + * + * functions called: + * addr_t eval() lkeval.c + * VOID exit() c_library + * int fprintf() c_library + * VOID getid() lklex.c + * VOID lkparea() lkarea.c + * VOID skip() lklex.c + * + * side effects: + * The area and areax structures are created and + * linked with the appropriate head structures. + * Failure to allocate area or areax structure + * space will terminate the linker. Other internal + * errors most likely caused by corrupted .rel + * files will also terminate the linker. + */ + +/* + * Create an area entry. + * + * A xxxxxx size nnnn flags mm + * | | | + * | | `-- ap->a_flag + * | `------------- axp->a_size + * `------------------------- ap->a_id + * + */ +VOID +newarea() +{ + register int i, narea; + struct areax *taxp; + struct areax **halp; + char id[NCPS]; + + /* + * Create Area entry + */ + getid(id, -1); + lkparea(id); + /* + * Evaluate area size + */ + skip(-1); + axp->a_size = eval(); + /* + * Evaluate flags + */ + skip(-1); + i = 0; + taxp = ap->a_axp; + while (taxp->a_axp) { + ++i; + taxp = taxp->a_axp; + } + if (i == 0) { + ap->a_flag = eval(); + } else { + i = eval(); +/* if (i && (ap->a_flag != i)) { */ +/* fprintf(stderr, "Conflicting flags in area %8s\n", id); */ +/* lkerr++; */ +/* } */ + } + /* + * Place pointer in header area list + */ + if (headp == NULL) { + fprintf(stderr, "No header defined\n"); + lkexit(1); + } + narea = hp->h_narea; + halp = hp->a_list; + for (i=0; i < narea ;++i) { + if (halp[i] == NULL) { + halp[i] = taxp; + return; + } + } + fprintf(stderr, "Header area list overflow\n"); + lkexit(1); +} + +/*)Function VOID lkparea(id) + * + * char * id pointer to the area name string + * + * The function lkparea() searches the linked area structures + * for a name match. If the name is not found then an area + * structure is created. An areax structure is created and + * appended to the areax structures linked to the area structure. + * The associated base area and head structure pointers are + * loaded into the areax structure. + * + * local variables: + * area * tap pointer to an area structure + * areax * taxp pointer to an areax structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * areax *axp Pointer to the current + * areax structure + * + * functions called: + * VOID * new() lksym() + * char * strcpy() c_library + * int symeq() lksym.c + * + * side effects: + * Area and/or areax structures are created. + * Failure to allocate space for created structures + * will terminate the linker. + */ + +VOID +lkparea(id) +char *id; +{ + register struct area *tap; + register struct areax *taxp; + + ap = areap; + axp = (struct areax *) new (sizeof(struct areax)); + while (ap) { + if (symeq(id, ap->a_id)) { + taxp = ap->a_axp; + while (taxp->a_axp) + taxp = taxp->a_axp; + taxp->a_axp = axp; + axp->a_bap = ap; + axp->a_bhp = hp; + return; + } + ap = ap->a_ap; + } + ap = (struct area *) new (sizeof(struct area)); + if (areap == NULL) { + areap = ap; + } else { + tap = areap; + while (tap->a_ap) + tap = tap->a_ap; + tap->a_ap = ap; + } + ap->a_axp = axp; + axp->a_bap = ap; + axp->a_bhp = hp; + strncpy(ap->a_id, id, NCPS); + ap->a_addr = 0; +} + +/*)Function VOID lnkarea() + * + * The function lnkarea() resolves all area addresses. + * The function evaluates each area structure (and all + * the associated areax structures) in sequence. The + * linking process supports four (4) possible area types: + * + * ABS/OVR - All sections (each individual areax + * section) starts at the identical base + * area address overlaying all other + * areax sections for this area. The + * size of the area is largest of the area + * sections. + * + * ABS/CON - All sections (each individual areax + * section) are concatenated with the + * first section starting at the base + * area address. The size of the area + * is the sum of the section sizes. + * + * NOTE: Multiple absolute (ABS) areas are + * never concatenated with each other, + * thus absolute area A and absolute area + * B will overlay each other if they begin + * at the same location (the default is + * always address 0 for absolute areas). + * + * REL/OVR - All sections (each individual areax + * section) starts at the identical base + * area address overlaying all other + * areax sections for this area. The + * size of the area is largest of the area + * sections. + * + * REL/CON - All sections (each individual areax + * section) are concatenated with the + * first section starting at the base + * area address. The size of the area + * is the sum of the section sizes. + * + * NOTE: Relocatable (REL) areas ae always concatenated + * with each other, thus relocatable area B + * (defined after area A) will follow + * relocatable area A independent of the + * starting address of area A. Within a + * specific area each areax section may be + * overlayed or concatenated with other + * areax sections. + * + * + * If a base address for an area is specified then the + * area will start at that address. Any relocatable + * areas defined subsequently will be concatenated to the + * previous relocatable area if it does not have a base + * address specified. + * + * The names s_ and l_ are created to + * define the starting address and length of each area. + * + * local variables: + * addr_t rloc ;current relocation address + * char temp[] ;temporary string + * struct symbol *sp ;symbol structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * + * functions called: + * int fprintf() c_library + * VOID lnksect() lkarea.c + * symbol *lkpsym() lksysm.c + * char * strncpy() c_library + * int symeq() lksysm.c + * + * side effects: + * All area and areax addresses and sizes are + * determined and saved in their respective + * structures. + */ + +/* + * Resolve all area addresses. + */ +VOID +lnkarea() +{ + addr_t rloc[4]; + int locIndex; + char temp[NCPS]; + struct sym *sp; + + rloc[0] = rloc[1] = rloc[2] = rloc[3] = 0; + ap = areap; + while (ap) { + if (ap->a_flag&A_ABS) { + /* + * Absolute sections + */ + lnksect(ap); + } else { + /* Determine memory space */ + locIndex = 0; + if (ap->a_flag & A_CODE) { + locIndex = 1; + } + if (ap->a_flag & A_XDATA) { + locIndex = 2; + } + if (ap->a_flag & A_BIT) { + locIndex = 3; + } + /* + * Relocatable sections + */ + if (ap->a_type == 0) { /* JLH */ + ap->a_addr = rloc[ locIndex ]; + ap->a_type = 1; + } + lnksect(ap); + rloc[ locIndex ] = ap->a_addr + ap->a_size; + } + + /* + * Create symbols called: + * s_ the start address of the area + * l_ the length of the area + */ + + if (! symeq(ap->a_id, _abs_)) { + strncpy(temp+2,ap->a_id,NCPS-2); + *(temp+1) = '_'; + + *temp = 's'; + sp = lkpsym(temp, 1); + sp->s_addr = ap->a_addr ; + /* sp->s_axp = ap->a_axp; JLH: was NULL; */ + sp->s_type |= S_DEF; + + *temp = 'l'; + sp = lkpsym(temp, 1); + sp->s_addr = ap->a_size; + sp->s_axp = NULL; + sp->s_type |= S_DEF; + + } + ap = ap->a_ap; + } +} + +/*)Function VOID lnksect() + * + * area * tap pointer to an area structure + * + * The function lnksect() is the function called by + * lnkarea() to resolve the areax addresses. Refer + * to the function lnkarea() for more detail. Pageing + * boundary and length errors will be reported by this + * function. + * + * local variables: + * addr_t size size of area + * addr_t addr address of area + * areax * taxp pointer to an areax structure + * + * global variables: + * int lkerr error flag + * + * functions called: + * none + * + * side effects: + * All area and areax addresses and sizes area determined + * and linked into the structures. + */ + +VOID +lnksect(tap) +register struct area *tap; +{ + register addr_t size, addr; + register struct areax *taxp; + + size = 0; + addr = tap->a_addr; + if ((tap->a_flag&A_PAG) && (addr & 0xFF)) { + fprintf(stderr, + "\n?ASlink-Warning-Paged Area %8s Boundary Error\n", tap->a_id); + lkerr++; + } + taxp = tap->a_axp; + if (tap->a_flag&A_OVR) { + /* + * Overlayed sections + */ + while (taxp) { + taxp->a_addr = addr; + if (taxp->a_size > size) + size = taxp->a_size; + taxp = taxp->a_axp; + } + } else { + /* + * Concatenated sections + */ + while (taxp) { + taxp->a_addr = addr; + addr += taxp->a_size; + size += taxp->a_size; + taxp = taxp->a_axp; + } + } + tap->a_size = size; + if ((tap->a_flag&A_PAG) && (size > 256)) { + fprintf(stderr, + "\n?ASlink-Warning-Paged Area %8s Length Error\n", tap->a_id); + lkerr++; + } +} diff --git a/as/mcs51/lkdata.c b/as/mcs51/lkdata.c new file mode 100644 index 00000000..87a51e7e --- /dev/null +++ b/as/mcs51/lkdata.c @@ -0,0 +1,479 @@ +/* lkdata.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - change s_id from [NCPS] to pointer (comment) + * 31-Oct-97 JLH: + * - add jflag and jfp for NoICE output + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkdata.c + * + * The module lkdata contains the global variables + * and structures used in the linker aslink. + */ + +/* + * Definitions for all Global Variables + */ + +char *_abs_ = { ". .ABS." }; + +int lkerr; /* Linker error flag + */ +char *ip; /* Pointer into the REL file text line in ib[] + */ +char ib[NINPUT]; /* REL file text line + */ +char *rp; /* pointer into the LST file + * text line in rb[] + */ +char rb[NINPUT]; /* LST file text line being + * address relocated + */ +int dflag; /* Debug information output flag + */ +int oflag; /* Output file type flag + */ +int mflag; /* Map output flag + */ +int aflag; /* Overlapping area warning flag + */ +int jflag; /* NoICE output flag + */ +int xflag; /* Map file radix type flag + */ +int pflag; /* print linker command file flag + */ +int uflag; /* Listing relocation flag + */ +int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +int line; /* current line number + */ +int page; /* current page number + */ +int lop; /* current line number on page + */ +int pass; /* linker pass number + */ +int rtcnt; /* count of elements in the + * rtval[] and rtflg[] arrays + */ +addr_t rtval[NTXT]; /* data associated with relocation + */ +int rtflg[NTXT]; /* indicates if rtval[] value is + * to be sent to the output file. + * (always set in this linker) + */ +int hilo; /* REL file byte ordering + */ +int gline; /* LST file relocation active + * for current line + */ +int gcntr; /* LST file relocation active + * counter + */ +addr_t iram_size; /* internal ram size + */ + +/* + * The structure lfile contains a pointer to a + * file specification string, the file type, and + * a link to the next lfile structure. + * + * struct lfile + * { + * struct lfile *f_flp; lfile link + * int f_type; File type + * char *f_idp; Pointer to file spec + * }; + */ +struct lfile *filep; /* The pointers (lfile *) filep, + * (lfile *) cfp, and (FILE *) sfp + * are used in conjunction with + * the routine getline() to read + * asmlnk commands from + * (1) the standard input or + * (2) or a command file + * and to read the REL files + * sequentially as defined by the + * asmlnk input commands. + * + * The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + */ +struct lfile *cfp; /* The pointer *cfp points to the + * current lfile structure + */ +struct lfile *startp;/* asmlnk startup file structure + */ +struct lfile *linkp; /* pointer to first lfile structure + * containing an input REL file + * specification + */ +struct lfile *lfp; /* pointer to current lfile structure + * being processed by parse() + */ +FILE *ofp; /* Output file handle + * for word formats + */ +FILE *mfp; /* Map output file handle + */ +FILE *jfp; /* NoICE output file handle + */ +FILE *rfp; /* File handle for output + * address relocated ASxxxx + * listing file + */ +FILE *sfp; /* The file handle sfp points to the + * currently open file + */ +FILE *tfp; /* File handle for input + * ASxxxx listing file + */ +FILE *dfp = NULL ; /* + * File handle for debug + * information output file + */ +/* + * The structures of head, area, areax, and sym are created + * as the REL files are read during the first pass of the + * linker. The struct head is created upon encountering a + * H directive in the REL file. The structure contains a + * link to a link file structure (struct lfile) which describes + * the file containing the H directive, the number of data/code + * areas contained in this header segment, the number of + * symbols referenced/defined in this header segment, a pointer + * to an array of pointers to areax structures (struct areax) + * created as each A directive is read, and a pointer to an + * array of pointers to symbol structures (struct sym) for + * all referenced/defined symbols. As H directives are read + * from the REL files a linked list of head structures is + * created by placing a link to the new head structure + * in the previous head structure. + * + * struct head + * { + * struct head *h_hp; Header link + * struct lfile *h_lfile; Associated file + * int h_narea; # of areas + * struct areax **a_list; Area list + * int h_nglob; # of global symbols + * struct sym **s_list; Global symbol list + * char m_id[NCPS]; Module name + * }; + */ +struct head *headp; /* The pointer to the first + * head structure of a linked list + */ +struct head *hp; /* Pointer to the current + * head structure + */ + +/* + * A structure area is created for each 'unique' data/code + * area definition found as the REL files are read. The + * struct area contains the name of the area, a flag byte + * which contains the area attributes (REL/CON/OVR/ABS), + * an area subtype (not used in this assembler), and the + * area base address and total size which will be filled + * in at the end of the first pass through the REL files. + * As A directives are read from the REL files a linked + * list of unique area structures is created by placing a + * link to the new area structure in the previous area structure. + * + * struct area + * { + * struct area *a_ap; Area link + * struct areax *a_axp; Area extension link + * addr_t a_addr; Beginning address of area + * addr_t a_size; Total size of the area + * char a_type; Area subtype + * char a_flag; Flag byte + * char a_id[NCPS]; Name + * }; + */ +struct area *areap; /* The pointer to the first + * area structure of a linked list + */ +struct area *ap; /* Pointer to the current + * area structure + */ + +/* + * An areax structure is created for every A directive found + * while reading the REL files. The struct areax contains a + * link to the 'unique' area structure referenced by the A + * directive and to the head structure this area segment is + * a part of. The size of this area segment as read from the + * A directive is placed in the areax structure. The beginning + * address of this segment will be filled in at the end of the + * first pass through the REL files. As A directives are read + * from the REL files a linked list of areax structures is + * created for each unique area. The final areax linked + * list has at its head the 'unique' area structure linked + * to the linked areax structures (one areax structure for + * each A directive for this area). + * + * struct areax + * { + * struct areax *a_axp; Area extension link + * struct area *a_bap; Base area link + * struct head *a_bhp; Base header link + * addr_t a_addr; Beginning address of section + * addr_t a_size; Size of the area in section + * }; + */ +struct areax *axp; /* Pointer to the current + * areax structure + */ + +/* + * A sym structure is created for every unique symbol + * referenced/defined while reading the REL files. The + * struct sym contains the symbol's name, a flag value + * (not used in this linker), a symbol type denoting + * referenced/defined, and an address which is loaded + * with the relative address within the area in which + * the symbol was defined. The sym structure also + * contains a link to the area where the symbol was defined. + * The sym structures are linked into linked lists using + * the symbol link element. + * + * struct sym + * { + * struct sym *s_sp; Symbol link + * struct areax *s_axp; Symbol area link + * char s_type; Symbol subtype + * char s_flag; Flag byte + * addr_t s_addr; Address + * char *s_id; Name (JLH) + * }; + */ +struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ +/* + * The struct base contains a pointer to a + * base definition string and a link to the next + * base structure. + * + * struct base + * { + * struct base *b_base; Base link + * char *b_strp; String pointer + * }; + */ +struct base *basep; /* The pointer to the first + * base structure + */ +struct base *bsp; /* Pointer to the current + * base structure + */ + +/* + * The struct globl contains a pointer to a + * global definition string and a link to the next + * global structure. + * + * struct globl + * { + * struct globl *g_globl; Global link + * char *g_strp; String pointer + * }; + */ +struct globl *globlp;/* The pointer to the first + * globl structure + */ +struct globl *gsp; /* Pointer to the current + * globl structure + */ + +/* + * A structure sdp is created for each 'unique' paged + * area definition found as the REL files are read. + * As P directives are read from the REL files a linked + * list of unique sdp structures is created by placing a + * link to the new sdp structure in the previous area structure. + * + * struct sdp + * { + * struct area *s_area; Paged Area link + * struct areax *s_areax; Paged Area Extension Link + * addr_t s_addr; Page address offset + * }; + */ +struct sdp sdp; /* Base Page Structure */ + +/* + * The structure rerr is loaded with the information + * required to report an error during the linking + * process. The structure contains an index value + * which selects the areax structure from the header + * areax structure list, a mode value which selects + * symbol or area relocation, the base address in the + * area section, an area/symbol list index value, and + * an area/symbol offset value. + * + * struct rerr + * { + * int aindex; Linking area + * int mode; Relocation mode + * addr_t rtbase; Base address in section + * int rindex; Area/Symbol reloaction index + * addr_t rval; Area/Symbol offset value + * }; + */ +struct rerr rerr; /* Structure containing the + * linker error information + */ + +/* + * The structure lbpath is created for each library + * path specification input by the -k option. The + * lbpath structures are linked into a list using + * the next link element. + * + * struct lbpath { + * struct lbpath *next; + * char *path; + * }; + */ +struct lbpath *lbphead; /* pointer to the first + * library path structure + */ + +/* + * The structure lbname is created for all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file. The element path points to + * the path string, element libfil points to the library + * file string, and the element libspc is the concatenation + * of the valid path and libfil strings. + * + * The lbpath structures are linked into a list + * using the next link element. + * + * Each library file contains a list of object files + * that are contained in the particular library. e.g.: + * + * \iolib\termio + * \inilib\termio + * + * Only one specification per line is allowed. + * + * struct lbname { + * struct lbname *next; + * char *path; + * char *libfil; + * char *libspc; + * }; + */ +struct lbname *lbnhead; /* pointer to the first + * library name structure + */ + +/* + * The function fndsym() searches through all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file for a symbol definition. + * + * The structure lbfile is created for the first library + * object file which contains the definition for the + * specified undefined symbol. + * + * The element libspc points to the library file path specification + * and element relfil points to the object file specification string. + * The element filspc is the complete path/file specification for + * the library file to be imported into the linker. The + * file specicifation may be formed in one of two ways: + * + * (1) If the library file contained an absolute + * path/file specification then this becomes filspc. + * (i.e. C:\...) + * + * (2) If the library file contains a relative path/file + * specification then the concatenation of the path + * and this file specification becomes filspc. + * (i.e. \...) + * + * The lbpath structures are linked into a list + * using the next link element. + * + * struct lbfile { + * struct lbfile *next; + * char *libspc; + * char *relfil; + * char *filspc; + * }; + */ +struct lbfile *lbfhead; /* pointer to the first + * library file structure + */ + +/* + * array of character types, one per + * ASCII character + */ +char ctype[128] = { +/*NUL*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*BS*/ ILL, SPACE, ILL, ILL, SPACE, ILL, ILL, ILL, +/*DLE*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*CAN*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*SPC*/ SPACE, ETC, ETC, ETC, LETTER, BINOP, BINOP, ETC, +/*(*/ ETC, ETC, BINOP, BINOP, ETC, BINOP, LETTER, BINOP, +/*0*/ DGT2, DGT2, DGT8, DGT8, DGT8, DGT8, DGT8, DGT8, +/*8*/ DGT10, DGT10, ETC, ETC, BINOP, ETC, BINOP, ETC, +/*@*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*H*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*P*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*X*/ LETTER, LETTER, LETTER, ETC, ETC, ETC, BINOP, LETTER, +/*`*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*h*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*p*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*x*/ LETTER, LETTER, LETTER, ETC, BINOP, ETC, ETC, ETC +}; + +/* + * an array of characters which + * perform the case translation function + */ +#if CASE_SENSITIVE +#else +char ccase[128] = { +/*NUL*/ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', +/*BS*/ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', +/*DLE*/ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', +/*CAN*/ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', +/*SPC*/ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', +/*(*/ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', +/*0*/ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', +/*8*/ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', +/*@*/ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*H*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*P*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*X*/ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', +/*`*/ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*h*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*p*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*x*/ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177' +}; +#endif diff --git a/as/mcs51/lkeval.c b/as/mcs51/lkeval.c new file mode 100644 index 00000000..9ae71773 --- /dev/null +++ b/as/mcs51/lkeval.c @@ -0,0 +1,396 @@ +/* lkeval.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkeval.c + * + * The module lkeval.c contains the routines to evaluate + * arithmetic/numerical expressions. The functions in + * lkeval.c perform a recursive evaluation of the arithmetic + * expression read from the input text line. + * The expression may include binary/unary operators, brackets, + * symbols, labels, and constants in hexadecimal, decimal, octal + * and binary. Arithmetic operations are prioritized and + * evaluated by normal arithmetic conventions. + * + * lkeval.c contains the following functions: + * int digit() + * addr_t eval() + * addr_t expr() + * int oprio() + * addr_t term() + * + * lkeval.c contains no local/static variables + */ + +/*)Function addr_t eval() + * + * The function eval() evaluates a character string to a + * numerical value. + * + * local variables: + * int c character from input string + * int v value of character in current radix + * addr_t n evaluation value + * + * global variables: + * int radix current number conversion radix + * + * functions called: + * int digit() lkeval.c + * char get() lklex.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * Input test is scanned and evaluated to a + * numerical value. + */ + +addr_t +eval() +{ + register int c, v; + register addr_t n; + + c = getnb(); + n = 0; + while ((v = digit(c, radix)) >= 0) { + n = n*radix + v; + c = get(); + } + unget(c); + return(n); +} + +/*)Function addr_t expr(n) + * + * int n a firewall priority; all top + * level calls (from the user) + * should be made with n set to 0. + * + * The function expr() evaluates an expression and + * returns the value. + * + * local variables: + * int c current input text character + * int p current operator priority + * addr_t v value returned by term() + * addr_t ve value returned by a + * recursive call to expr() + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * int lkerr error flag + * FILE * stderr c_library + * + * functions called: + * VOID expr() lkeval.c + * int fprintf() c_library + * int getnb() lklex.c + * int oprio() lkeval.c + * VOID term() lkeval.c + * VOID unget() lklex.c + * + * + * side effects: + * An expression is evaluated by scanning the input + * text string. + */ + +addr_t +expr (n) +{ + register int c, p; + register addr_t v, ve; + + v = term(); + while (ctype[c = getnb()] & BINOP) { + if ((p = oprio(c)) <= n) + break; + if ((c == '>' || c == '<') && c != get()) { + fprintf(stderr, "Invalid expression"); + lkerr++; + return(v); + } + ve = expr(p); + if (c == '+') { + v += ve; + } else + if (c == '-') { + v -= ve; + } else { + switch (c) { + + case '*': + v *= ve; + break; + + case '/': + v /= ve; + break; + + case '&': + v &= ve; + break; + + case '|': + v |= ve; + break; + + case '%': + v %= ve; + break; + + case '^': + v ^= ve; + break; + + case '<': + v <<= ve; + break; + + case '>': + v >>= ve; + break; + } + } + } + unget(c); + return(v); +} + +/*)Function addr_t term() + * + * The function term() evaluates a single constant + * or symbol value prefaced by any unary operator + * ( +, -, ~, ', ", >, or < ). + * + * local variables: + * int c current character + * char id[] symbol name + * int n value of digit in current radix + * int r current evaluation radix + * sym * sp pointer to a sym structure + * addr_t v evaluation value + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * int lkerr error flag + * + * functions called: + * int digit() lkeval.c + * VOID expr() lkeval.c + * int fprintf() c_library + * int get() lklex.c + * VOID getid() lklex.c + * int getmap() lklex.c + * int getnb() lklex.c + * sym * lkpsym() lksym.c + * addr_t symval() lksym.c + * VOID unget() lklex.c + * + * side effects: + * An arithmetic term is evaluated by scanning input text. + */ + +addr_t +term() +{ + register int c, r, n; + register addr_t v; + struct sym *sp; + char id[NCPS]; + + c = getnb(); + if (c == '#') { c = getnb(); } + if (c == '(') { + v = expr(0); + if (getnb() != ')') { + fprintf(stderr, "Missing delimiter"); + lkerr++; + } + return(v); + } + if (c == '-') { + return(-expr(100)); + } + if (c == '~') { + return(~expr(100)); + } + if (c == '\'') { + return(getmap(-1)&0377); + } + if (c == '\"') { + if (hilo) { + v = (getmap(-1)&0377)<<8; + v |= getmap(-1)&0377; + } else { + v = getmap(-1)&0377; + v |= (getmap(-1)&0377)<<8; + } + return(v); + } + if (c == '>' || c == '<') { + v = expr(100); + if (c == '>') + v >>= 8; + return(v&0377); + } + if (ctype[c] & DIGIT) { + r = 10; + if (c == '0') { + c = get(); + switch (c) { + case 'b': + case 'B': + r = 2; + c = get(); + break; + case '@': + case 'o': + case 'O': + case 'q': + case 'Q': + r = 8; + c = get(); + break; + case 'd': + case 'D': + r = 10; + c = get(); + break; + case 'h': + case 'H': + case 'x': + case 'X': + r = 16; + c = get(); + break; + default: + break; + } + } + v = 0; + while ((n = digit(c, r)) >= 0) { + v = r*v + n; + c = get(); + } + unget(c); + return(v); + } + if (ctype[c] & LETTER) { + getid(id, c); + if ((sp = lkpsym(id, 0)) == NULL) { + fprintf(stderr, "Undefined symbol %8s\n", id); + lkerr++; + return(0); + } else { + return(symval(sp)); + } + } +} + +/*)Function int digit(c, r) + * + * int c digit character + * int r current radix + * + * The function digit() returns the value of c + * in the current radix r. If the c value is not + * a number of the current radix then a -1 is returned. + * + * local variables: + * none + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * none + * + * side effects: + * none + */ + +int +digit(c, r) +register int c, r; +{ + if (r == 16) { + if (ctype[c] & RAD16) { + if (c >= 'A' && c <= 'F') + return (c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + return (c - '0'); + } + } else + if (r == 10) { + if (ctype[c] & RAD10) + return (c - '0'); + } else + if (r == 8) { + if (ctype[c] & RAD8) + return (c - '0'); + } else + if (r == 2) { + if (ctype[c] & RAD2) + return (c - '0'); + } + return (-1); +} + +/*)Function int oprio(c) + * + * int c operator character + * + * The function oprio() returns a relative priority + * for all valid unary and binary operators. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +oprio(c) +register int c; +{ + if (c == '*' || c == '/' || c == '%') + return (10); + if (c == '+' || c == '-') + return (7); + if (c == '<' || c == '>') + return (5); + if (c == '^') + return (4); + if (c == '&') + return (3); + if (c == '|') + return (1); + return (0); +} diff --git a/as/mcs51/lkhead.c b/as/mcs51/lkhead.c new file mode 100644 index 00000000..69e77376 --- /dev/null +++ b/as/mcs51/lkhead.c @@ -0,0 +1,154 @@ +/* lkhead.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*Module lkhead.c + * + * The module lkhead.c contains the function newhead() which + * creates a head structure and the function module() which + * loads the module name into the current head structure. + * + * lkhead.c contains the following functions: + * VOID newhead() + * VOID module() + * + * lkhead.c contains no local variables. + */ + +/*)Function VOID newhead() + * + * The function newhead() creates a head structure. All head + * structures are linked to form a linked list of head structures + * with the current head structure at the tail of the list. + * + * local variables: + * int i evaluation value + * head * thp temporary pointer + * to a header structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * lfile *cfp The pointer *cfp points to the + * current lfile structure + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * + * functions called: + * addr_t expr() lkeval.c + * VOID * new() lksym.c + * VOID lkparea() lkarea.c + * + * side effects: + * A new head structure is created and linked to any + * existing linked head structure. The head structure + * parameters of file handle, number of areas, and number + * of global symbols are loaded into the structure. + * The default area "_abs_" is created when the first + * head structure is created and an areax structure is + * created for every head structure called. + */ + +/* + * Create a new header entry. + * + * H n areas n global symbols + * | | + * | `---- hp->h_nglob + * `------------ hp->h_narea + * + */ +VOID +newhead() +{ + register int i; + struct head *thp; + + hp = (struct head *) new (sizeof(struct head)); + if (headp == NULL) { + headp = hp; + } else { + thp = headp; + while (thp->h_hp) + thp = thp->h_hp; + thp->h_hp = hp; + } + /* + * Set file pointer + */ + hp->h_lfile = cfp; + /* + * Evaluate and build Area pointer list + */ + i = hp->h_narea = eval(); + if (i) + hp->a_list = (struct areax **) new (i*sizeof(struct areax *)); + /* + * Evaluate and build Global symbol pointer list + */ + skip(-1); + i = hp->h_nglob = eval(); + if (i) + hp->s_list = (struct sym **) new (i*sizeof(struct sym *)); + /* + * Setup Absolute DEF linkage. + */ + lkparea(_abs_); + ap->a_flag = A_ABS|A_OVR; +} + +/*)Function VOID module() + * + * The function module() copies the module name into + * the current head structure. + * + * local variables: + * char id[] module id string + * + * global variables: + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * int lkerr error flag + * FILE * stderr c_library + * + * functions called: + * int fprintf() c_library + * VOID getid() lklex.c + * char * strncpy() c_library + * + * side effects: + * The module name is copied into the head structure. + */ + +/* + * Module Name + */ +VOID +module() +{ + char id[NCPS]; + + if (headp) { + getid(id, -1); + strncpy(hp->m_id, id, NCPS); + } else { + fprintf(stderr, "No header defined\n"); + lkerr++; + } +} diff --git a/as/mcs51/lkihx.c b/as/mcs51/lkihx.c new file mode 100644 index 00000000..d849c165 --- /dev/null +++ b/as/mcs51/lkihx.c @@ -0,0 +1,134 @@ +/* lkihx.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkihx.c + * + * The module lkihx.c contains the function to + * output the relocated object code in the + * Intel Hex format. + * + * lkihx.c contains the following function: + * VOID ihx(i) + * + * lkihx.c contains no local variables. + */ + +/*Intel Hex Format + * Record Mark Field - This field signifies the start of a + * record, and consists of an ascii colon + * (:). + * + * Record Length Field - This field consists of two ascii + * characters which indicate the number of + * data bytes in this record. The + * characters are the result of converting + * the number of bytes in binary to two + * ascii characters, high digit first. An + * End of File record contains two ascii + * zeros in this field. + * + * Load Address Field - This field consists of the four ascii + * characters which result from converting + * the the binary value of the address in + * which to begin loading this record. The + * order is as follows: + * + * High digit of high byte of address. + * Low digit of high byte of address. + * High digit of low byte of address. + * Low digit of low byte of address. + * + * In an End of File record this field con- + * sists of either four ascii zeros or the + * program entry address. Currently the + * entry address option is not supported. + * + * Record Type Field - This field identifies the record type, + * which is either 0 for data records or 1 + * for an End of File record. It consists + * of two ascii characters, with the high + * digit of the record type first, followed + * by the low digit of the record type. + * + * Data Field - This field consists of the actual data, + * converted to two ascii characters, high + * digit first. There are no data bytes in + * the End of File record. + * + * Checksum Field - The checksum field is the 8 bit binary + * sum of the record length field, the load + * address field, the record type field, + * and the data field. This sum is then + * negated (2's complement) and converted + * to two ascii characters, high digit + * first. + */ + +/*)Function ihx(i) + * + * int i 0 - process data + * 1 - end of data + * + * The function ihx() outputs the relocated data + * in the standard Intel Hex format. + * + * local variables: + * addr_t chksum byte checksum + * + * global variables: + * int hilo byte order + * FILE * ofp output file handle + * int rtcnt count of data words + * int rtflg[] output the data flag + * addr_t rtval[] relocated data + * + * functions called: + * int fprintf() c_library + * + * side effects: + * The data is output to the file defined by ofp. + */ + +VOID +ihx(i) +{ + register addr_t chksum; + + if (i) { + if (hilo == 0) { + chksum = rtval[0]; + rtval[0] = rtval[1]; + rtval[1] = chksum; + } + for (i = 0, chksum = -2; i < rtcnt; i++) { + if (rtflg[i]) + chksum++; + } + fprintf(ofp, ":%02X", chksum); + for (i = 0; i < rtcnt ; i++) { + if (rtflg[i]) { + fprintf(ofp, "%02X", rtval[i]); + chksum += rtval[i]; + } + if (i == 1) { + fprintf(ofp, "00"); + } + } + fprintf(ofp, "%02X\n", (-chksum) & 0xff); + } else { + fprintf(ofp, ":00000001FF\n"); + } +} diff --git a/as/mcs51/lklex.c b/as/mcs51/lklex.c new file mode 100644 index 00000000..15e6c5ab --- /dev/null +++ b/as/mcs51/lklex.c @@ -0,0 +1,544 @@ +/* lklex.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lklex.c + * + * The module lklex.c contains the general lexical analysis + * functions used to scan the text lines from the .rel files. + * + * lklex.c contains the fllowing functions: + * char endline() + * char get() + * VOID getfid() + * VOID getid() + * int getline() + * int getmap() + * char getnb() + * int more() + * VOID skip() + * VOID unget() + * + * lklex.c contains no local variables. + */ + +/*)Function VOID getid(id,c) + * + * char * id a pointer to a string of + * maximum length NCPS + * int c mode flag + * >=0 this is first character to + * copy to the string buffer + * <0 skip white space + * + * The function getid() scans the current input text line + * from the current position copying the next LETTER | DIGIT string + * into the external string buffer (id). The string ends when a non + * LETTER or DIGIT character is found. The maximum number of + * characters copied is NCPS. If the input string is larger than + * NCPS characters then the string is truncated, if the input string + * is shorter than NCPS characters then the string is NULL filled. + * If the mode argument (c) is >=0 then (c) is the first character + * copied to the string buffer, if (c) is <0 then intervening white + * space (SPACES and TABS) are skipped. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() lklex.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * use of getnb(), get(), and unget() updates the + * global pointer ip the position in the current + * input text line. + */ + +VOID +getid(id, c) +register int c; +char *id; +{ + register char *p; + + if (c < 0) { + c = getnb(); + } + p = id; + do { + if (p < &id[NCPS]) + *p++ = c; + } while (ctype[c=get()] & (LETTER|DIGIT)); + unget(c); + while (p < &id[NCPS]) + *p++ = 0; +} + +/*)Function VOID getfid(fid,c) + * + * char * str a pointer to a string of + * maximum length FILSPC + * int c this is first character to + * copy to the string buffer + * + * The function getfid() scans the current input text line + * from the current position copying the next string + * into the external string buffer (str). The string ends when a + * non SPACE type character is found. The maximum number of + * characters copied is FILSPC. If the input string is larger than + * FILSPC characters then the string is truncated, if the input string + * is shorter than FILSPC characters then the string is NULL filled. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() lklex.c + * + * side effects: + * use of get() updates the global pointer ip + * the position in the current input text line. + */ + +VOID +getfid(str, c) +register int c; +char *str; +{ + register char *p; + + p = str; + do { + if (p < &str[FILSPC-1]) + *p++ = c; + c = get(); + } while (c && (ctype[c] != SPACE)); + while (p < &str[FILSPC]) + *p++ = 0; +} + +/*)Function char getnb() + * + * The function getnb() scans the current input text + * line returning the first character not a SPACE or TAB. + * + * local variables: + * int c current character from input + * + * global variables: + * none + * + * called functions: + * char get() lklex.c + * + * side effects: + * use of get() updates the global pointer ip, the position + * in the current input text line + */ + +char +getnb() +{ + register int c; + + while ((c=get())==' ' || c=='\t') + ; + return (c); +} + +/*)Function VOID skip() + * + * The function skip() scans the input text skipping all + * letters and digits. + * + * local variables: + * none + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * char get() lklex.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * Input letters and digits are skipped. + */ + +VOID +skip(c) +register int c; +{ + if (c < 0) + c = getnb(); + while (ctype[c=get()] & (LETTER|DIGIT)) { ; } + unget(c); +} + +/*)Function char get() + * + * The function get() returns the next character in the + * input text line, at the end of the line a + * NULL character is returned. + * + * local variables: + * int c current character from + * input text line + * + * global variables: + * char * ip pointer into the current + * input text line + * + * called functions: + * none + * + * side effects: + * updates ip to the next character position in the + * input text line. If ip is at the end of the + * line, ip is not updated. + */ + +char +get() +{ + register int c; + + if ((c = *ip) != 0) + ++ip; + return (c); +} + +/*)Function VOID unget(c) + * + * int c value of last character + * read from input text line + * + * If (c) is not a NULL character then the global pointer ip + * is updated to point to the preceeding character in the + * input text line. + * + * NOTE: This function does not push the character (c) + * back into the input text line, only + * the pointer ip is changed. + * + * local variables: + * int c last character read + * from input text line + * + * global variables: + * char * ip position into the current + * input text line + * + * called functions: + * none + * + * side effects: + * ip decremented by 1 character position + */ + +VOID +unget(c) +{ + if (c != 0) + --ip; +} + +/*)Function int getmap(d) + * + * int d value to compare with the + * input text line character + * + * The function getmap() converts the 'C' style characters \b, \f, + * \n, \r, and \t to their equivalent ascii values and also + * converts 'C' style octal constants '\123' to their equivalent + * numeric values. If the first character is equivalent to (d) then + * a (-1) is returned, if the end of the line is detected then + * a 'q' error terminates the parse for this line, or if the first + * character is not a \ then the character value is returned. + * + * local variables: + * int c value of character + * from input text line + * int n looping counter + * int v current value of numeric conversion + * + * global variables: + * none + * + * called functions: + * char get() lklex.c + * VOID unget() lklex.c + * + * side effects: + * use of get() updates the global pointer ip the position + * in the current input text line + */ + +int +getmap(d) +{ + register int c, n, v; + + if ((c = get()) == '\0') + return (-1); + if (c == d) + return (-1); + if (c == '\\') { + c = get(); + switch (c) { + + case 'b': + c = '\b'; + break; + + case 'f': + c = '\f'; + break; + + case 'n': + c = '\n'; + break; + + case 'r': + c = '\r'; + break; + + case 't': + c = '\t'; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + n = 0; + v = 0; + while (++n<=3 && c>='0' && c<='7') { + v = (v<<3) + c - '0'; + c = get(); + } + unget(c); + c = v; + break; + } + } + return (c); +} + +/*)Function int getline() + * + * The function getline() reads a line of input text from a + * .rel source text file, a .lnk command file or from stdin. + * Lines of text are processed from a single .lnk file or + * multiple .rel files until all files have been read. + * The input text line is copied into the global string ib[] + * and converted to a NULL terminated string. The function + * getline() returns a (1) after succesfully reading a line + * or a (0) if all files have been read. + * This function also opens each input .lst file and output + * .rst file as each .rel file is processed. + * + * local variables: + * int i string length + * int ftype file type + * char * fid file name + * + * global variables: + * lfile *cfp The pointer *cfp points to the + * current lfile structure + * lfile *filep The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + * int gline get a line from the LST file + * to translate for the RST file + * char ib[NINPUT] REL file text line + * int pass linker pass number + * int pflag print linker command file flag + * FILE *rfp The file handle to the current + * output RST file + * FILE *sfp The file handle sfp points to the + * currently open file + * FILE * stdin c_library + * FILE * stdout c_library + * FILE *tfp The file handle to the current + * LST file being scanned + * int uflag update listing flag + * + * called functions: + * FILE * afile() lkmain.c + * int fclose() c_library + * char * fgets() c_library + * int fprintf() c_library + * VOID lkulist() lklist.c + * VOID lkexit() lkmain.c + * int strlen() c_library + * + * side effects: + * The input stream is scanned. The .rel files will be + * opened and closed sequentially scanning each in turn. + */ + +int +getline() +{ + register int i, ftype; + register char *fid; + +loop: if (pflag && cfp && cfp->f_type == F_STD) + fprintf(stdout, "ASlink >> "); + + if (sfp == NULL || fgets(ib, sizeof ib, sfp) == NULL) { + if (sfp) { + fclose(sfp); + sfp = NULL; + lkulist(0); + } + if (cfp == NULL) { + cfp = filep; + } else { + cfp = cfp->f_flp; + } + if (cfp) { + ftype = cfp->f_type; + fid = cfp->f_idp; + if (ftype == F_STD) { + sfp = stdin; + } else + if (ftype == F_LNK) { + sfp = afile(fid, "lnk", 0); + } else + if (ftype == F_REL) { + sfp = afile(fid, "rel", 0); + /* if a .cdb file exists then copy it over */ + if (dflag && sfp && dfp && pass == 0) { + FILE *xfp = afile(fid,"cdb",0); + if (xfp) { + copyfile(dfp,xfp); + fclose(xfp); + } + } + if (uflag && pass != 0) { + if ((tfp = afile(fid, "lst", 0)) != NULL) { + if ((rfp = afile(fid, "rst", 1)) == NULL) { + fclose(tfp); + tfp = NULL; + } + } + } + gline = 1; + } else { + fprintf(stderr, "Invalid file type\n"); + lkexit(1); + } + if (sfp == NULL) { + lkexit(1); + } + goto loop; + } else { + filep = NULL; + return(0); + } + } + i = strlen(ib) - 1; + if (ib[i] == '\n') + ib[i] = 0; + return (1); +} + +/*)Function int more() + * + * The function more() scans the input text line + * skipping white space (SPACES and TABS) and returns a (0) + * if the end of the line or a comment delimeter (;) is found, + * or a (1) if their are additional characters in the line. + * + * local variables: + * int c next character from + * the input text line + * + * global variables: + * none + * + * called functions: + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * use of getnb() and unget() updates the global pointer ip + * the position in the current input text line + */ + +int +more() +{ + register int c; + + c = getnb(); + unget(c); + return( (c == '\0' || c == ';') ? 0 : 1 ); +} + +/*)Function char endline() + * + * The function endline() scans the input text line + * skipping white space (SPACES and TABS) and returns the next + * character or a (0) if the end of the line is found or a + * comment delimiter (;) is found. + * + * local variables: + * int c next character from + * the input text line + * + * global variables: + * none + * + * called functions: + * char getnb() lklex.c + * + * side effects: + * Use of getnb() updates the global pointer ip the + * position in the current input text line. + */ + +char +endline() +{ + register int c; + + c = getnb(); + return( (c == '\0' || c == ';') ? 0 : c ); +} diff --git a/as/mcs51/lklibr.c b/as/mcs51/lklibr.c new file mode 100644 index 00000000..7be36101 --- /dev/null +++ b/as/mcs51/lklibr.c @@ -0,0 +1,553 @@ +/* lklibr.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * With contributions for the + * object libraries from + * Ken Hornstein + * kenh@cmf.nrl.navy.mil + * + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lklibr.c + * + * The module lklibr.c contains the functions which + * (1) specify the path(s) to library files [.LIB] + * (2) specify the library file(s) [.LIB] to search + * (3) search the library files for specific symbols + * and link the module containing this symbol + * + * lklibr.c contains the following functions: + * VOID addpath() + * VOID addlib() + * VOID addfile() + * VOID search() + * VOID fndsym() + * VOID library() + * VOID loadfile() + * + */ + +/*)Function VOID addpath() + * + * The function addpath() creates a linked structure containing + * the paths to various object module library files. + * + * local variables: + * lbpath *lbph pointer to new path structure + * lbpath *lbp temporary pointer + * + * global variables: + * lbpath *lbphead The pointer to the first + * path structure + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * An lbpath structure may be created. + */ + +VOID +addpath() +{ + struct lbpath *lbph, *lbp; + + lbph = (struct lbpath *) new (sizeof(struct lbpath)); + if (lbphead == NULL) { + lbphead = lbph; + } else { + lbp = lbphead; + while (lbp->next) + lbp = lbp->next; + lbp->next = lbph; + } + unget(getnb()); + lbph->path = (char *) new (strlen(ip)+1); + strcpy(lbph->path, ip); +} + +/*)Function VOID addlib() + * + * The function addlib() tests for the existance of a + * library path structure to determine the method of + * adding this library file to the library search structure. + * + * This function calls the function addfile() to actually + * add the library file to the search list. + * + * local variables: + * lbpath *lbph pointer to path structure + * + * global variables: + * lbpath *lbphead The pointer to the first + * path structure + * + * functions called: + * VOID addfile() lklibr.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * The function addfile() may add the file to + * the library search list. + */ + +VOID +addlib() +{ + struct lbpath *lbph; + + unget(getnb()); + + if (lbphead == NULL) { + addfile(NULL,ip); + return; + } + for (lbph=lbphead; lbph; lbph=lbph->next) { + addfile(lbph->path,ip); + } +} + +/*)Function VOID addfile(path,libfil) + * + * char *path library path specification + * char *libfil library file specification + * + * The function addfile() searches for the library file + * by concatenating the path and libfil specifications. + * if the library is found, an lbname structure is created + * and linked to any previously defined structures. This + * linked list is used by the function fndsym() to attempt + * to find any undefined symbols. + * + * The function does not give report an error on invalid + * path / file specifications or if the file is not found. + * + * local variables: + * lbname *lbnh pointer to new name structure + * lbname *lbn temporary pointer + * + * global variables: + * lbname *lbnhead The pointer to the first + * path structure + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * An lbname structure may be created. + */ + +VOID +addfile(path,libfil) +char *path; +char *libfil; +{ + FILE *fp; + char *str; + struct lbname *lbnh, *lbn; + + if ((path != NULL) && (strchr(libfil,':') == NULL)){ + str = (char *) new (strlen(path) + strlen(libfil) + 6); + strcpy(str,path); +#ifdef OTHERSYSTEM + if (str[strlen(str)-1] != '/') { + strcat(str,"/"); + } +#endif + } else { + str = (char *) new (strlen(libfil) + 5); + } +#ifdef OTHERSYSTEM + if (libfil[0] == '/') { libfil++; } +#endif + strcat(str,libfil); + if(strchr(str,FSEPX) == NULL) { + sprintf(&str[strlen(str)], "%clib", FSEPX); + } + if ((fp = fopen(str, "r")) != NULL) { + fclose(fp); + lbnh = (struct lbname *) new (sizeof(struct lbname)); + if (lbnhead == NULL) { + lbnhead = lbnh; + } else { + lbn = lbnhead; + while (lbn->next) + lbn = lbn->next; + lbn->next = lbnh; + } + if ((path != NULL) && (strchr(libfil,':') == NULL)){ + lbnh->path = path; + } + lbnh->libfil = (char *) new (strlen(libfil) + 1); + strcpy(lbnh->libfil,libfil); + lbnh->libspc = str; + fprintf(stderr,"library file %s\n",str); + } else { + free(str); + } +} + +/*)Function VOID search() + * + * The function search() looks through all the symbol tables + * at the end of pass 1. If any undefined symbols are found + * then the function fndsym() is called. Function fndsym() + * searches any specified library files to automagically + * import the object modules containing the needed symbol. + * + * After a symbol is found and imported by the function + * fndsym() the symbol tables are again searched. The + * symbol tables are search until no more symbols can be + * resolved within the library files. This ensures that + * back references from one library module to another are + * also resolved. + * + * local variables: + * int i temporary counter + * sym *sp pointer to a symbol structure + * int symfnd found a symbol flag + * + * global variables: + * sym *symhash[] array of pointers to symbol tables + * + * functions called: + * int fndsym() lklibr.c + * + * side effects: + * If a symbol is found then the library object module + * containing the symbol will be imported and linked. + */ + +VOID +search() +{ + register struct sym *sp; + register int i,symfnd; + + /* + * Look for undefined symbols. Keep + * searching until no more symbols are resolved. + */ + symfnd = 1; + while (symfnd) { + symfnd = 0; + /* + * Look through all the symbols + */ + for (i=0; is_type & S_DEF) == 0) { + if (fndsym(sp->s_id)) { + symfnd++; + } + } + sp = sp->s_sp; + } + } + } +} + +/*)Function VOID fndsym(name) + * + * char *name symbol name to find + * + * The function fndsym() searches through all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file. + * + * The file specicifation may be formed in one of two ways: + * + * (1) If the library file contained an absolute + * path/file specification then this becomes filspc. + * (i.e. C:\...) + * + * (2) If the library file contains a relative path/file + * specification then the concatenation of the path + * and this file specification becomes filspc. + * (i.e. \...) + * + * The structure lbfile is created for the first library + * object file which contains the definition for the + * specified undefined symbol. + * + * If the library file [.LIB] contains file specifications for + * non existant files, no errors are returned. + * + * local variables: + * char buf[] [.REL] file input line + * char c [.REL] file input character + * FILE *fp file handle for object file + * lbfile *lbf temporary pointer + * lbfile *lbfh pointer to lbfile structure + * FILE *libfp file handle for library file + * lbname *lbnh pointer to lbname structure + * char *path file specification path + * char relfil[] [.REL] file specification + * char *str combined path and file specification + * char symname[] [.REL] file symbol string + * + * global variables: + * lbname *lbnhead The pointer to the first + * name structure + * lbfile *lbfhead The pointer to the first + * file structure + * + * functions called: + * int fclose() c_library + * int fgets() c_library + * FILE *fopen() c_library + * VOID free() c_library + * char getnb() lklex.c + * VOID lkexit() lkmain.c + * VOID loadfile() lklibr.c + * VOID * new() lksym.c + * char * sprintf() c_library + * int sscanf() c_library + * char * strcat() c_library + * char * strchr() c_library + * char * strcpy() c_library + * int strlen() c_library + * int strncmp() c_library + * VOID unget() lklex.c + * + * side effects: + * If the symbol is found then a new lbfile structure + * is created and added to the linked list of lbfile + * structures. The file containing the found symbol + * is linked. + */ + +int +fndsym(name) +char *name; +{ + FILE *libfp, *fp; + struct lbname *lbnh; + struct lbfile *lbfh, *lbf; + char relfil[NINPUT+2]; + char buf[NINPUT+2]; + char symname[NINPUT]; + char *path,*str; + char c; + + /* + * Search through every library in the linked list "lbnhead". + */ + +/*1*/ for (lbnh=lbnhead; lbnh; lbnh=lbnh->next) { + if ((libfp = fopen(lbnh->libspc, "r")) == NULL) { + fprintf(stderr, "Cannot open library file %s\n", + lbnh->libspc); + lkexit(1); + } + path = lbnh->path; + + /* + * Read in a line from the library file. + * This is the relative file specification + * for a .REL file in this library. + */ + +/*2*/ while (fgets(relfil, NINPUT, libfp) != NULL) { + relfil[NINPUT+1] = '\0'; + relfil[strlen(relfil) - 1] = '\0'; + if (path != NULL) { + str = (char *) new (strlen(path)+strlen(relfil)+6); + strcpy(str,path); +#ifdef OTHERSYSTEM + if (str[strlen(str)-1] != '/') { + strcat(str,"/"); + } +#endif + } else { + str = (char *) new (strlen(relfil) + 5); + } + if (relfil[0] == '\\') { + strcat(str,relfil+1); + } else { + strcat(str,relfil); + } + if(strchr(str,FSEPX) == NULL) { + sprintf(&str[strlen(str)], "%crel", FSEPX); + } +/*3*/ if ((fp = fopen(str, "r")) != NULL) { + + /* + * Read in the object file. Look for lines that + * begin with "S" and end with "D". These are + * symbol table definitions. If we find one, see + * if it is our symbol. Make sure we only read in + * our object file and don't go into the next one. + */ + +/*4*/ while (fgets(buf, NINPUT, fp) != NULL) { + + buf[NINPUT+1] = '\0'; + buf[strlen(buf) - 1] = '\0'; + + /* + * Skip everything that's not a symbol record. + */ + if (buf[0] != 'S') + continue; + + /* + * When a 'T line' is found terminate file scan. + * All 'S line's preceed 'T line's in .REL files. + */ + if (buf[0] == 'T') + break; + + sscanf(buf, "S %s %c", symname, &c); + + /* + * If we find a symbol definition for the + * symbol we're looking for, load in the + * file and add it to lbfhead so it gets + * loaded on pass number 2. + */ +/*5*/ if (strncmp(symname, name, NCPS) == 0 && c == 'D') { + + lbfh = (struct lbfile *) new (sizeof(struct lbfile)); + if (lbfhead == NULL) { + lbfhead = lbfh; + } else { + lbf = lbfhead; + while (lbf->next) + lbf = lbf->next; + lbf->next = lbfh; + } + lbfh->libspc = lbnh->libspc; + lbfh->filspc = str; + lbfh->relfil = (char *) new (strlen(relfil) + 1); + strcpy(lbfh->relfil,relfil); + fclose(fp); + fclose(libfp); + /* if cdb information required & cdb file present */ + if (dflag && dfp) { + FILE *xfp = afile(str,"cdb",0); + if (xfp) { + copyfile(dfp,xfp); + fclose(xfp); + } + } + loadfile(str); + return (1); + +/*5*/ } + +/*4*/ } + fclose(fp); +/*3*/ } + + free(str); +/*2*/ } + fclose(libfp); +/*1*/ } + return(0); +} + +/*)Function VOID library() + * + * The function library() links all the library object files + * contained in the lbfile structures. + * + * local variables: + * lbfile *lbfh pointer to lbfile structure + * + * global variables: + * lbfile *lbfhead pointer to first lbfile structure + * + * functions called: + * VOID loadfile lklibr.c + * + * side effects: + * Links all files contained in the lbfile structures. + */ + +VOID +library() +{ + struct lbfile *lbfh; + + for (lbfh=lbfhead; lbfh; lbfh=lbfh->next) { + loadfile(lbfh->filspc); + } +} + +/*)Function VOID loadfile(filspc) + * + * char *filspc library object file specification + * + * The function loadfile() links the library object module. + * + * local variables: + * FILE *fp file handle + * int i input line length + * char str[] file input line + * + * global variables: + * char *ip pointer to linker input string + * + * functions called: + * int fclose() c_library + * int fgets() c_library + * FILE * fopen() c_library + * VOID link() lkmain.c + * int strlen() c_library + * + * side effects: + * If file exists it is linked. + */ + +VOID +loadfile(filspc) +char *filspc; +{ + FILE *fp; + char str[NINPUT+2]; + int i; + + if ((fp = fopen(filspc,"r")) != NULL) { + while (fgets(str, NINPUT, fp) != NULL) { + str[NINPUT+1] = '\0'; + i = strlen(str) - 1; + if (str[i] == '\n') + str[i] = '\0'; + ip = str; + link(); + } + fclose(fp); + } +} diff --git a/as/mcs51/lklist.c b/as/mcs51/lklist.c new file mode 100644 index 00000000..5ac3f07b --- /dev/null +++ b/as/mcs51/lklist.c @@ -0,0 +1,1069 @@ +/* lklist.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - lstarea: show s_id as string rather than array [NCPS] + * - lstarea: show a_id as string rather than array [NCPS] + * 31-Oct-97 JLH: add NoICE output file genration in lstarea + * 02-Apr-98 JLH: add XDATA, DATA, BIT flags to area output + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lklist.c + * + * The module lklist.c contains the functions which + * output the linker .map file and produce a relocated + * listing .rst file. + * + * lklist.c contains the following functions: + * int dgt() + * VOID lstarea() + * VOID lkulist() + * VOID lkalist() + * VOID lkglist() + * VOID newpag() + * VOID slew() + * + * lklist.c contains no local variables. + */ + +/*)Function VOID slew(fp) + * + * FILE * fp output file handle + * + * The function slew() increments the page line counter. + * If the number of lines exceeds the maximum number of + * lines per page then a page skip and a page header are + * output. + * + * local variables: + * int i loop counter + * + * global variables: + * int lop current line number on page + * int xflag Map file radix type flag + * + * functions called: + * int fprintf() c_library + * VOID newpag() lklist.c + * + * side effects: + * The page line and the page count may be updated. + */ + +VOID +slew(fp) +FILE *fp; +{ + register int i; + + if (lop++ >= NLPP) { + newpag(fp); + if (xflag == 0) { + fprintf(fp, "Hexadecimal\n\n"); + } else + if (xflag == 1) { + fprintf(fp, "Octal\n\n"); + } else + if (xflag == 2) { + fprintf(fp, "Decimal\n\n"); + } + fprintf(fp, "Area Addr Size"); + fprintf(fp, " Decimal Bytes (Attributes)\n"); + for(i=0;i<4;++i) + fprintf(fp, " Value--Global"); + fprintf(fp, "\n\n"); + lop += 6; + } +} + +/*)Function VOID newpag() + * + * The function newpag() outputs a page skip, writes the + * first page header line, sets the line count to 1, and + * increments the page counter. + * + * local variables: + * none + * + * global variables: + * int lop current line number on page + * int page current page number + * + * functions called: + * int fprintf() c_library + * + * side effects: + * The page and line counters are updated. + */ + +VOID +newpag(fp) +FILE *fp; +{ + fprintf(fp, "\fASxxxx Linker %s, page %u.\n", VERSION, ++page); + lop = 1; +} + +#if NCPS-8 + +/* NCPS != 8 */ +/*)Function VOID lstarea(xp) + * + * area * xp pointer to an area structure + * + * The function lstarea() creates the linker map output for + * the area specified by pointer xp. The generated output + * area header includes the area name, starting address, + * size of area, number of words (in decimal), and the + * area attributes. The symbols defined in this area are + * sorted by ascending address and output one per line + * in the selected radix. + * + * local variables: + * areax * oxp pointer to an area extension structure + * int c character value + * int i loop counter + * int j bubble sort update status + * char * ptr pointer to an id string + * int nmsym number of symbols in area + * addr_t a0 temporary + * addr_t ai temporary + * addr_t aj temporary + * sym * sp pointer to a symbol structure + * sym ** p pointer to an array of + * pointers to symbol structures + * + * global variables: + * FILE *mfp Map output file handle + * sym *symhash[NHASH] array of pointers to NHASH + * linked symbol lists + * int xflag Map file radix type flag + * + * functions called: + * int fprintf() c_library + * VOID free() c_library + * char * malloc() c_library + * char putc() c_library + * VOID slew() lklist.c + * + * side effects: + * Map output generated. + */ + +VOID +lstarea(xp) +struct area *xp; +{ + register struct areax *oxp; + register int i, j; + register char *ptr; + int nmsym; + addr_t a0, ai, aj; + struct sym *sp; + struct sym **p; + int memPage; + + putc('\n', mfp); + if (xflag == 0) { + fprintf(mfp, "Hexadecimal\n\n"); + } else + if (xflag == 1) { + fprintf(mfp, "Octal\n\n"); + } else + if (xflag == 2) { + fprintf(mfp, "Decimal\n\n"); + } + fprintf(mfp, "Area "); + fprintf(mfp, "Addr Size Decimal Bytes (Attributes)\n"); + fprintf(mfp, "-------------------------------- "); + fprintf(mfp, "---- ---- ------- ----- ------------\n"); + /* + * Output Area Header + */ + ptr = &xp->a_id[0]; + fprintf(mfp, "%-32s", ptr ); /* JLH: width matches --- above */ + ai = xp->a_addr; + aj = xp->a_size; + if (xflag == 0) { + fprintf(mfp, " %04X %04X", ai, aj); + } else + if (xflag == 1) { + fprintf(mfp, " %06o %06o", ai, aj); + } else + if (xflag == 2) { + fprintf(mfp, " %05u %05u", ai, aj); + } + fprintf(mfp, " = %6u. bytes ", aj); + if (xp->a_flag & A_ABS) { + fprintf(mfp, "(ABS"); + } else { + fprintf(mfp, "(REL"); + } + if (xp->a_flag & A_OVR) { + fprintf(mfp, ",OVR"); + } else { + fprintf(mfp, ",CON"); + } + if (xp->a_flag & A_PAG) { + fprintf(mfp, ",PAG"); + } + + memPage = 0x00; + if (xp->a_flag & A_CODE) { + fprintf(mfp, ",CODE"); + memPage = 0x0C; + } + if (xp->a_flag & A_XDATA) { + fprintf(mfp, ",XDATA"); + memPage = 0x0D; + } + if (xp->a_flag & A_BIT) { + fprintf(mfp, ",BIT"); + memPage = 0x0B; + } + fprintf(mfp, ")"); + if (xp->a_flag & A_PAG) { + ai = (ai & 0xFF); + aj = (aj > 256); + if (ai || aj) { fprintf(mfp, " "); } + if (ai) { fprintf(mfp, " Boundary"); } + if (ai & aj) { fprintf(mfp, " /"); } + if (aj) { fprintf(mfp, " Length"); } + if (ai || aj) { fprintf(mfp, " Error"); } + } + + /* + * Find number of symbols in area + */ + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) + ++nmsym; + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + if (nmsym == 0) { + putc('\n', mfp); + return; + } + + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) + == NULL) { + fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); + return; + } + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) { + p[nmsym++] = sp; + } + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Bubble Sort of Addresses in Symbol Table Array + */ + j = 1; + while (j) { + j = 0; + sp = p[0]; + a0 = sp->s_addr + sp->s_axp->a_addr; + for (i=1; is_addr + sp->s_axp->a_addr; + if (a0 > ai) { + j = 1; + p[i] = p[i-1]; + p[i-1] = sp; + } + a0 = ai; + } + } + + /* + * Symbol Table Output + */ + + i = 0; + fprintf(mfp, "\n\n"); + fprintf(mfp, " Value Global\n"); + fprintf(mfp, " -------- --------------------------------"); + while (i < nmsym) { + fprintf(mfp, "\n"); + if (memPage != 0) + fprintf(mfp, " %02X:", memPage); + else + fprintf(mfp, " "); + + sp = p[i]; + aj = sp->s_addr + sp->s_axp->a_addr; + if (xflag == 0) { + fprintf(mfp, "%04X ", aj); + } else + if (xflag == 1) { + fprintf(mfp, "%06o ", aj); + } else + if (xflag == 2) { + fprintf(mfp, "%05u ", aj); + } + ptr = &sp->s_id[0]; + fprintf(mfp, "%s", ptr ); + + /* if cdb flag set the output cdb Information + and the symbol has a '$' sign in it then */ + if (dflag && + strchr(ptr,'$')) + fprintf(dfp,"L:%s:%X\n",ptr,aj); + /* NoICE output of symbol */ + if (jflag) DefineNoICE( ptr, aj, memPage ); + + i++; + } + putc('\n', mfp); + free(p); +} + +#else + +/* NCPS == 8 */ +/*)Function VOID lstarea(xp) + * + * area * xp pointer to an area structure + * + * The function lstarea() creates the linker map output for + * the area specified by pointer xp. The generated output + * area header includes the area name, starting address, + * size of area, number of words (in decimal), and the + * area attributes. The symbols defined in this area are + * sorted by ascending address and output four per line + * in the selected radix. + * + * local variables: + * areax * oxp pointer to an area extension structure + * int c character value + * int i loop counter + * int j bubble sort update status + * char * ptr pointer to an id string + * int nmsym number of symbols in area + * addr_t a0 temporary + * addr_t ai temporary + * addr_t aj temporary + * sym * sp pointer to a symbol structure + * sym ** p pointer to an array of + * pointers to symbol structures + * + * global variables: + * FILE *mfp Map output file handle + * sym *symhash[NHASH] array of pointers to NHASH + * linked symbol lists + * int xflag Map file radix type flag + * + * functions called: + * int fprintf() c_library + * VOID free() c_library + * char * malloc() c_library + * char putc() c_library + * VOID slew() lklist.c + * + * side effects: + * Map output generated. + */ + +VOID +lstarea(xp) +struct area *xp; +{ + register struct areax *oxp; + register c, i, j; + register char *ptr; + int nmsym; + addr_t a0, ai, aj; + struct sym *sp; + struct sym **p; + int page; + + putc('\n', mfp); + slew(mfp); + /* + * Output Area Header + */ + ptr = &xp->a_id[0]; + while (ptr < &xp->a_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, mfp); + } else { + putc(' ', mfp); + } + } + ai = xp->a_addr; + aj = xp->a_size; + if (xflag == 0) { + fprintf(mfp, " %04X %04X", ai, aj); + } else + if (xflag == 1) { + fprintf(mfp, " %06o %06o", ai, aj); + } else + if (xflag == 2) { + fprintf(mfp, " %05u %05u", ai, aj); + } + fprintf(mfp, " = %6u. bytes ", aj); + if (xp->a_flag & A_ABS) { + fprintf(mfp, "(ABS"); + } else { + fprintf(mfp, "(REL"); + } + if (xp->a_flag & A_OVR) { + fprintf(mfp, ",OVR"); + } else { + fprintf(mfp, ",CON"); + } + if (xp->a_flag & A_PAG) { + fprintf(mfp, ",PAG"); + } + + page = 0x00; + if (xp->a_flag & A_CODE) { + fprintf(mfp, ",CODE"); + memPage = 0x0C; + } + if (xp->a_flag & A_XDATA) { + fprintf(mfp, ",XDATA"); + memPage = 0x0D; + } + if (xp->a_flag & A_BIT) { + fprintf(mfp, ",BIT"); + memPage = 0x0B; + } + fprintf(mfp, ")"); + if (xp->a_flag & A_PAG) { + ai = (ai & 0xFF); + aj = (aj > 256); + if (ai || aj) { fprintf(mfp, " "); } + if (ai) { fprintf(mfp, " Boundary"); } + if (ai & aj) { fprintf(mfp, " /"); } + if (aj) { fprintf(mfp, " Length"); } + if (ai || aj) { fprintf(mfp, " Error"); } + } + + /* + * Find number of symbols in area + */ + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) + ++nmsym; + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + if (nmsym == 0) { + putc('\n', mfp); + slew(mfp); + return; + } + + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) + == NULL) { + fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); + slew(mfp); + return; + } + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) { + p[nmsym++] = sp; + } + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Bubble Sort of Addresses in Symbol Table Array + */ + j = 1; + while (j) { + j = 0; + sp = p[0]; + a0 = sp->s_addr + sp->s_axp->a_addr; + for (i=1; is_addr + sp->s_axp->a_addr; + if (a0 > ai) { + j = 1; + p[i] = p[i-1]; + p[i-1] = sp; + } + a0 = ai; + } + } + + /* + * Symbol Table Output + */ + i = 0; + while (i < nmsym) { + fprintf(mfp, "\n"); + slew(mfp); + fprintf(mfp, " "); + sp = p[i]; + aj = sp->s_addr + sp->s_axp->a_addr; + if (xflag == 0) { + fprintf(mfp, " %04X ", aj); + } else + if (xflag == 1) { + fprintf(mfp, "%06o ", aj); + } else + if (xflag == 2) { + fprintf(mfp, " %05u ", aj); + } + ptr = &sp->s_id[0]; + fprintf(mfp, "%s", ptr ); + + /* NoICE output of symbol */ + if (jflag) DefineNoICE( ptr, aj, memPage ); + } + putc('\n', mfp); + free(p); + slew(mfp); +} +#endif + +/*)Function VOID lkulist(i) + * + * int i i # 0 process LST to RST file + * i = 0 copy remainder of LST file + * to RST file and close files + * + * The function lkulist() creates a relocated listing (.rst) + * output file from the ASxxxx assembler listing (.lst) + * files. The .lst file's program address and code bytes + * are changed to reflect the changes made by ASlink as + * the .rel files are combined into a single relocated + * output file. + * + * local variables: + * addr_t pc current program counter address + * + * global variables: + * int hilo byte order + * int gline get a line from the LST file + * to translate for the RST file + * char rb[] read listing file text line + * FILE *rfp The file handle to the current + * output RST file + * int rtcnt count of data words + * int rtflg[] output the data flag + * addr_t rtval[] relocated data + * FILE *tfp The file handle to the current + * LST file being scanned + * + * functions called: + * int fclose() c_library + * int fgets() c_library + * int fprintf() c_library + * VOID lkalist() lklist.c + * VOID lkglist() lklist.c + * + * side effects: + * A .rst file is created for each available .lst + * file associated with a .rel file. + */ + +VOID +lkulist(i) +int i; +{ + addr_t pc; + + /* + * Exit if listing file is not open + */ + if (tfp == NULL) + return; + + /* + * Normal processing of LST to RST + */ + if (i) { + /* + * Evaluate current code address + */ + if (hilo == 0) { + pc = ((rtval[1] & 0xFF) << 8) + (rtval[0] & 0xFF); + } else { + pc = ((rtval[0] & 0xFF) << 8) + (rtval[1] & 0xFF); + } + + /* + * Line with only address + */ + if (rtcnt == 2) { + lkalist(pc); + + /* + * Line with address and code + */ + } else { + for (i=2; i < rtcnt; i++) { + if (rtflg[i]) { + lkglist(pc++, rtval[i] & 0xFF); + } + } + } + + /* + * Copy remainder of LST to RST + */ + } else { + if (gline == 0) + fprintf(rfp, "%s", rb); + + while (fgets(rb, sizeof(rb), tfp) != 0) { + fprintf(rfp, "%s", rb); + } + fclose(tfp); + tfp = NULL; + fclose(rfp); + rfp = NULL; + } +} + +/*)Function VOID lkalist(pc) + * + * int pc current program counter value + * + * The function lkalist() performs the following functions: + * + * (1) if the value of gline = 0 then the current listing + * file line is copied to the relocated listing file output. + * + * (2) the listing file is read line by line and copied to + * the relocated listing file until a valid source + * line number and a program counter value of the correct + * radix is found. The new relocated pc value is substituted + * and the line is written to the RST file. + * + * local variables: + * int i loop counter + * char str[] temporary string + * + * global variables: + * int gcntr data byte counter + * int gline get a line from the LST file + * to translate for the RST file + * char rb[] read listing file text line + * char *rp pointer to listing file text line + * FILE *rfp The file handle to the current + * output RST file + * FILE *tfp The file handle to the current + * LST file being scanned + * + * functions called: + * int dgt() lklist.c + * int fclose() c_library + * int fgets() c_library + * int fprintf() c_library + * int sprintf() c_library + * char * strncpy() c_library + * + * side effects: + * Lines of the LST file are copied to the RST file, + * the last line copied has the code address + * updated to reflect the program relocation. + */ + +VOID +lkalist(pc) +addr_t pc; +{ + char str[8]; + int i; + + /* + * Exit if listing file is not open + */ +loop: if (tfp == NULL) + return; + + /* + * Copy current LST to RST + */ + if (gline == 0) { + fprintf(rfp, "%s", rb); + gline = 1; + } + + /* + * Clear text line buffer + */ + for (i=0,rp=rb; i +#include +#include +#include "aslink.h" + + +/*)Module lkmain.c + * + * The module lkmain.c contains the functions which + * (1) input the linker options, parameters, and specifications + * (2) perform a two pass link + * (3) produce the appropriate linked data output and/or + * link map file and/or relocated listing files. + * + * lkmain.c contains the following functions: + * FILE * afile(fn,ft,wf) + * VOID bassav() + * VOID gblsav() + * VOID link() + * VOID lkexit() + * VOID main(argc,argv) + * VOID map() + * int parse() + * VOID setbas() + * VOID setgbl() + * VOID usage() + * + * lkmain.c contains the following local variables: + * char * usetext[] array of pointers to the + * command option tect lines + * + */ + +/*)Function VOID main(argc,argv) + * + * int argc number of command line arguments + 1 + * char * argv[] array of pointers to the command line + * arguments + * + * The function main() evaluates the command line arguments to + * determine if the linker parameters are to input through 'stdin' + * or read from a command file. The functiond getline() and parse() + * are to input and evaluate the linker parameters. The linking process + * proceeds by making the first pass through each .rel file in the order + * presented to the linker. At the end of the first pass the setbase(), + * lnkarea(), setgbl(), and symdef() functions are called to evaluate + * the base address terms, link all areas, define global variables, + * and look for undefined symbols. Following these routines a linker + * map file may be produced and the linker output files may be opened. + * The second pass through the .rel files will output the linked data + * in one of the four supported formats. + * + * local variables: + * char * p pointer to an argument string + * int c character from argument string + * int i loop counter + * + * global variables: + * text line in ib[] + * lfile *cfp The pointer *cfp points to the + * current lfile structure + * char ctype[] array of character types, one per + * ASCII character + * lfile *filep The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + * head *hp Pointer to the current + * head structure + * char ib[NINPUT] .rel file text line + * char *ip pointer into the .rel file + * lfile *linkp pointer to first lfile structure + * containing an input .rel file + * specification + * int lkerr error flag + * int mflag Map output flag + * int oflag Output file type flag + * FILE *ofp Output file handle + * for word formats + * FILE *ofph Output file handle + * for high byte format + * FILE *ofpl Output file handle + * for low byte format + * int pass linker pass number + * int pflag print linker command file flag + * int radix current number conversion radix + * FILE *sfp The file handle sfp points to the + * currently open file + * lfile *startp asmlnk startup file structure + * FILE * stdin c_library + * FILE * stdout c_library + * + * functions called: + * FILE * afile() lkmain.c + * int fclose() c_library + * int fprintf() c_library + * int getline() lklex.c + * VOID library() lklibr.c + * VOID link() lkmain.c + * VOID lkexit() lkmain.c + * VOID lnkarea() lkarea.c + * VOID map() lkmain.c + * VOID new() lksym.c + * int parse() lkmain.c + * VOID reloc() lkreloc.c + * VOID search() lklibr.c + * VOID setbas() lkmain.c + * VOID setgbl() lkmain.c + * VOID symdef() lksym.c + * VOID usage() lkmain.c + * + * side effects: + * Completion of main() completes the linking process + * and may produce a map file (.map) and/or a linked + * data files (.ihx or .s19) and/or one or more + * relocated listing files (.rst). + */ + +int +main(argc, argv) +char *argv[]; +{ + register char *p; + register int c, i; + + fprintf(stdout, "\n"); + + startp = (struct lfile *) new (sizeof (struct lfile)); + + pflag = 1; + for (i=1; if_type = F_STD; + break; + + case 'f': + case 'F': + startp->f_type = F_LNK; + break; + + case 'n': + case 'N': + pflag = 0; + break; + + case 'p': + case 'P': + pflag = 1; + break; + + default: + usage(); + } + } + } else { + if (startp->f_type == F_LNK) { + startp->f_idp = p; + } + } + } + if (startp->f_type == 0) + usage(); + if (startp->f_type == F_LNK && startp->f_idp == NULL) + usage(); + + cfp = NULL; + sfp = NULL; + filep = startp; + while (1) { + ip = ib; + if (getline() == 0) + break; + if (pflag && sfp != stdin) + fprintf(stdout, "%s\n", ip); + if (*ip == '\0' || parse()) + break; + } + + if (sfp) { + fclose(sfp); + sfp = NULL; + } + + if (linkp == NULL) + usage(); + + syminit(); + + if (dflag){ + dfp = afile("temp", "cdb", 1); + if (dfp == NULL) + lkexit(1); + } + + for (pass=0; pass<2; ++pass) { + cfp = NULL; + sfp = NULL; + filep = linkp; + hp = NULL; + radix = 10; + + while (getline()) { + ip = ib; + + /* pass any "magic comments" to NoICE output */ + if ((ip[0] == ';') && (ip[1] == '!') && jfp) { + fprintf( jfp, "%s\n", &ip[2] ); + } + link(); + } + if (pass == 0) { + /* + * Search libraries for global symbols + */ + search(); + /* + * Set area base addresses. + */ + setbas(); + /* + * Link all area addresses. + */ + lnkarea(); + /* + * Process global definitions. + */ + setgbl(); + /* + * Check for undefined globals. + */ + symdef(stderr); + + /* Open NoICE output file if requested */ + if (jflag) { + jfp = afile(linkp->f_idp, "NOI", 1); + if (jfp == NULL) { + lkexit(1); + } + } + + /* + * Output Link Map if requested, + * or if NoICE output requested (since NoICE + * file is generated in part by map() processing) + */ + if (mflag || jflag) + map(); + + if (iram_size) + iramcheck(); + + /* + * Open output file + */ + if (oflag == 1) { + ofp = afile(linkp->f_idp, "ihx", 1); + if (ofp == NULL) { + lkexit(1); + } + /* include NoICE command to load hex file */ + if (jfp) fprintf( jfp, "LOAD %s.IHX\n", linkp->f_idp ); + + } else + if (oflag == 2) { + ofp = afile(linkp->f_idp, "S19", 1); + if (ofp == NULL) { + lkexit(1); + } + /* include NoICE command to load hex file */ + if (jfp) fprintf( jfp, "LOAD %s.S19\n", linkp->f_idp ); + } + } else { + /* + * Link in library files + */ + library(); + reloc('E'); + } + } + lkexit(lkerr); + return 0; +} + +/*)Function VOID lkexit(i) + * + * int i exit code + * + * The function lkexit() explicitly closes all open + * files and then terminates the program. + * + * local variables: + * none + * + * global variables: + * FILE * mfp file handle for .map + * FILE * ofp file handle for .ihx/.s19 + * FILE * rfp file hanlde for .rst + * FILE * sfp file handle for .rel + * FILE * tfp file handle for .lst + * + * functions called: + * int fclose() c_library + * VOID exit() c_library + * + * side effects: + * All files closed. Program terminates. + */ + +VOID +lkexit(i) +int i; +{ + if (mfp != NULL) fclose(mfp); + if (jfp != NULL) fclose(jfp); + if (ofp != NULL) fclose(ofp); + if (rfp != NULL) fclose(rfp); + if (sfp != NULL) fclose(sfp); + if (tfp != NULL) fclose(tfp); + if (dfp != NULL) { + FILE *xfp = afile(linkp->f_idp,"cdb",1); + dfp = freopen("temp.cdb","r",dfp); + copyfile(xfp,dfp); + fclose(xfp); + fclose(dfp); + unlink("temp.cdb"); + } + exit(i); +} + +/*)Function link() + * + * The function link() evaluates the directives for each line of + * text read from the .rel file(s). The valid directives processed + * are: + * X, D, Q, H, M, A, S, T, R, and P. + * + * local variables: + * int c first non blank character of a line + * + * global variables: + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * int pass linker pass number + * int radix current number conversion radix + * + * functions called: + * char endline() lklex.c + * VOID module() lkhead.c + * VOID newarea() lkarea.c + * VOID newhead() lkhead.c + * sym * newsym() lksym.c + * VOID reloc() lkreloc.c + * + * side effects: + * Head, area, and symbol structures are created and + * the radix is set as the .rel file(s) are read. + */ + +VOID +link() +{ + register int c; + + if ((c=endline()) == 0) { return; } + switch (c) { + + case 'X': + radix = 16; + break; + + case 'D': + radix = 10; + break; + + case 'Q': + radix = 8; + break; + + case 'H': + if (pass == 0) { + newhead(); + } else { + if (hp == 0) { + hp = headp; + } else { + hp = hp->h_hp; + } + } + sdp.s_area = NULL; + sdp.s_areax = NULL; + sdp.s_addr = 0; + break; + + case 'M': + if (pass == 0) + module(); + break; + + case 'A': + if (pass == 0) + newarea(); + if (sdp.s_area == NULL) { + sdp.s_area = areap; + sdp.s_areax = areap->a_axp; + sdp.s_addr = 0; + } + break; + + case 'S': + if (pass == 0) + newsym(); + break; + + case 'T': + case 'R': + case 'P': + if (pass == 0) + break; + reloc(c); + break; + + default: + break; + } + if (c == 'X' || c == 'D' || c == 'Q') { + if ((c = get()) == 'H') { + hilo = 1; + } else + if (c == 'L') { + hilo = 0; + } + } +} + + +/*)Function VOID map() + * + * The function map() opens the output map file and calls the various + * routines to + * (1) output the variables in each area, + * (2) list the files processed with module names, + * (3) list the libraries file processed, + * (4) list base address definitions, + * (5) list global variable definitions, and + * (6) list any undefined variables. + * + * local variables: + * int i counter + * head * hdp pointer to head structure + * lbfile *lbfh pointer to library file structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * base *basep The pointer to the first + * base structure + * base *bsp Pointer to the current + * base structure + * lfile *filep The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + * globl *globlp The pointer to the first + * globl structure + * globl *gsp Pointer to the current + * globl structure + * head *headp The pointer to the first + * head structure of a linked list + * lbfile *lbfhead The pointer to the first + * lbfile structure of a linked list + * lfile *linkp pointer to first lfile structure + * containing an input REL file + * specification + * int lop current line number on page + * FILE *mfp Map output file handle + * int page current page number + * + * functions called: + * FILE * afile() lkmain.c + * int fprintf() c_library + * VOID lkexit() lkmain.c + * VOID lstarea() lklist.c + * VOID newpag() lklist.c + * VOID symdef() lksym.c + * + * side effects: + * The map file is created. + */ + +VOID +map() +{ + register int i; + register struct head *hdp; + register struct lbfile *lbfh; + + /* + * Open Map File + */ + mfp = afile(linkp->f_idp, "map", 1); + if (mfp == NULL) { + lkexit(1); + } + + /* + * Output Map Area Lists + */ + page = 0; + lop = NLPP; + ap = areap; + while (ap) { + lstarea(ap); + ap = ap->a_ap; + } + /* + * List Linked Files + */ + newpag(mfp); + fprintf(mfp, "\nFiles Linked [ module(s) ]\n\n"); + hdp = headp; + filep = linkp; + while (filep) { + fprintf(mfp, "%-16s", filep->f_idp); + i = 0; + while ((hdp != NULL) && (hdp->h_lfile == filep)) { + if (i % 5) { + fprintf(mfp, ", %8.8s", hdp->m_id); + } else { + if (i) { + fprintf(mfp, ",\n%20s%8.8s", "", hdp->m_id); + } else { + fprintf(mfp, " [ %8.8s", hdp->m_id); + } + } + hdp = hdp->h_hp; + i++; + } + if (i) + fprintf(mfp, " ]"); + fprintf(mfp, "\n"); + filep = filep->f_flp; + } + /* + * List Linked Libraries + */ + if (lbfhead != NULL) { + fprintf(mfp, + "\nLibraries Linked [ object file ]\n\n"); + for (lbfh=lbfhead; lbfh; lbfh=lbfh->next) { + fprintf(mfp, "%-32s [ %16.16s ]\n", + lbfh->libspc, lbfh->relfil); + } + fprintf(mfp, "\n"); + } + /* + * List Base Address Definitions + */ + if (basep) { + newpag(mfp); + fprintf(mfp, "\nUser Base Address Definitions\n\n"); + bsp = basep; + while (bsp) { + fprintf(mfp, "%s\n", bsp->b_strp); + bsp = bsp->b_base; + } + } + /* + * List Global Definitions + */ + if (globlp) { + newpag(mfp); + fprintf(mfp, "\nUser Global Definitions\n\n"); + gsp = globlp; + while (gsp) { + fprintf(mfp, "%s\n", gsp->g_strp); + gsp = gsp->g_globl; + } + } + fprintf(mfp, "\n\f"); + symdef(mfp); +} + +/*)Function int parse() + * + * The function parse() evaluates all command line or file input + * linker directives and updates the appropriate variables. + * + * local variables: + * int c character value + * char fid[] file id string + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * lfile *lfp pointer to current lfile structure + * being processed by parse() + * lfile *linkp pointer to first lfile structure + * containing an input REL file + * specification + * int mflag Map output flag + * int oflag Output file type flag + * int pflag print linker command file flag + * FILE * stderr c_library + * int uflag Relocated listing flag + * int xflag Map file radix type flag + * + * Functions called: + * VOID addlib() lklibr.c + * VOID addpath() lklibr.c + * VOID bassav() lkmain.c + * int fprintf() c_library + * VOID gblsav() lkmain.c + * VOID getfid() lklex.c + * char getnb() lklex.c + * VOID lkexit() lkmain.c + * char * strcpy() c_library + * int strlen() c_library + * + * side effects: + * Various linker flags are updated and the linked + * structure lfile is created. + */ + +int +parse() +{ + register int c; + char fid[NINPUT]; + + while ((c = getnb()) != 0) { + if ( c == '-') { + while (ctype[c=get()] & LETTER) { + switch(c) { + + case 'i': + case 'I': + oflag = 1; + break; + + case 's': + case 'S': + oflag = 2; + break; + + case 'm': + case 'M': + ++mflag; + break; + + case 'j': + case 'J': + jflag = 1; + break; + + case 'u': + case 'U': + uflag = 1; + break; + + case 'x': + case 'X': + xflag = 0; + break; + + case 'q': + case 'Q': + xflag = 1; + break; + + case 'd': + case 'D': + xflag = 2; + break; + + case 'e': + case 'E': + return(1); + + case 'n': + case 'N': + pflag = 0; + break; + + case 'p': + case 'P': + pflag = 1; + break; + + case 'b': + case 'B': + bassav(); + return(0); + + case 'g': + case 'G': + gblsav(); + return(0); + + case 'k': + case 'K': + addpath(); + return(0); + + case 'l': + case 'L': + addlib(); + return(0); + + case 'a': + case 'A': + iramsav(); + return(0); + + case 'z': + case 'Z': + dflag = 1; + return(0); + default: + fprintf(stderr, "Invalid option\n"); + lkexit(1); + } + } + } else + if (ctype[c] & ILL) { + fprintf(stderr, "Invalid input"); + lkexit(1); + } else { + if (linkp == NULL) { + linkp = (struct lfile *) + new (sizeof (struct lfile)); + lfp = linkp; + } else { + lfp->f_flp = (struct lfile *) + new (sizeof (struct lfile)); + lfp = lfp->f_flp; + } + getfid(fid, c); + lfp->f_idp = (char *) new (strlen(fid)+1); + strcpy(lfp->f_idp, fid); + lfp->f_type = F_REL; + } + } + return(0); +} + +/*)Function VOID bassav() + * + * The function bassav() creates a linked structure containing + * the base address strings input to the linker. + * + * local variables: + * none + * + * global variables: + * base *basep The pointer to the first + * base structure + * base *bsp Pointer to the current + * base structure + * char *ip pointer into the REL file + * text line in ib[] + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * The basep structure is created. + */ + +VOID +bassav() +{ + if (basep == NULL) { + basep = (struct base *) + new (sizeof (struct base)); + bsp = basep; + } else { + bsp->b_base = (struct base *) + new (sizeof (struct base)); + bsp = bsp->b_base; + } + unget(getnb()); + bsp->b_strp = (char *) new (strlen(ip)+1); + strcpy(bsp->b_strp, ip); +} + +/*)Function VOID setbas() + * + * The function setbas() scans the base address lines in hte + * basep structure, evaluates the arguments, and sets beginning + * address of the specified areas. + * + * local variables: + * int v expression value + * char id[] base id string + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * base *basep The pointer to the first + * base structure + * base *bsp Pointer to the current + * base structure + * char *ip pointer into the REL file + * text line in ib[] + * int lkerr error flag + * + * functions called: + * addr_t expr() lkeval.c + * int fprintf() c_library + * VOID getid() lklex.c + * char getnb() lklex.c + * int symeq() lksym.c + * + * side effects: + * The base address of an area is set. + */ + +VOID +setbas() +{ + register int v; + char id[NCPS]; + + bsp = basep; + while (bsp) { + ip = bsp->b_strp; + getid(id, -1); + if (getnb() == '=') { + v = expr(0); + for (ap = areap; ap != NULL; ap = ap->a_ap) { + if (symeq(id, ap->a_id)) + break; + } + if (ap == NULL) { + fprintf(stderr, + "No definition of area %s\n", id); + lkerr++; + } else { + ap->a_addr = v; + ap->a_type = 1; /* JLH: value set */ + } + } else { + fprintf(stderr, "No '=' in base expression"); + lkerr++; + } + bsp = bsp->b_base; + } +} + +/*)Function VOID gblsav() + * + * The function gblsav() creates a linked structure containing + * the global variable strings input to the linker. + * + * local variable: + * none + * + * global variables: + * globl *globlp The pointer to the first + * globl structure + * globl *gsp Pointer to the current + * globl structure + * char *ip pointer into the REL file + * text line in ib[] + * int lkerr error flag + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * The globlp structure is created. + */ + +VOID +gblsav() +{ + if (globlp == NULL) { + globlp = (struct globl *) + new (sizeof (struct globl)); + gsp = globlp; + } else { + gsp->g_globl = (struct globl *) + new (sizeof (struct globl)); + gsp = gsp->g_globl; + } + unget(getnb()); + gsp->g_strp = (char *) new (strlen(ip)+1); + strcpy(gsp->g_strp, ip); +} + +/*)Function VOID setgbl() + * + * The function setgbl() scans the global variable lines in hte + * globlp structure, evaluates the arguments, and sets a variable + * to this value. + * + * local variables: + * int v expression value + * char id[] base id string + * sym * sp pointer to a symbol structure + * + * global variables: + * char *ip pointer into the REL file + * text line in ib[] + * globl *globlp The pointer to the first + * globl structure + * globl *gsp Pointer to the current + * globl structure + * FILE * stderr c_library + * int lkerr error flag + * + * functions called: + * addr_t expr() lkeval.c + * int fprintf() c_library + * VOID getid() lklex.c + * char getnb() lklex.c + * sym * lkpsym() lksym.c + * + * side effects: + * The value of a variable is set. + */ + +VOID +setgbl() +{ + register int v; + register struct sym *sp; + char id[NCPS]; + + gsp = globlp; + while (gsp) { + ip = gsp->g_strp; + getid(id, -1); + if (getnb() == '=') { + v = expr(0); + sp = lkpsym(id, 0); + if (sp == NULL) { + fprintf(stderr, + "No definition of symbol %s\n", id); + lkerr++; + } else { + if (sp->s_flag & S_DEF) { + fprintf(stderr, + "Redefinition of symbol %s\n", id); + lkerr++; + sp->s_axp = NULL; + } + sp->s_addr = v; + sp->s_type |= S_DEF; + } + } else { + fprintf(stderr, "No '=' in global expression"); + lkerr++; + } + gsp = gsp->g_globl; + } +} + +/*)Function FILE * afile(fn,, ft, wf) + * + * char * fn file specification string + * char * ft file type string + * int wf read(0)/write(1) flag + * + * The function afile() opens a file for reading or writing. + * (1) If the file type specification string ft + * is not NULL then a file specification is + * constructed with the file path\name in fn + * and the extension in ft. + * (2) If the file type specification string ft + * is NULL then the file specification is + * constructed from fn. If fn does not have + * a file type then the default .rel file + * type is appended to the file specification. + * + * afile() returns a file handle for the opened file or aborts + * the assembler on an open error. + * + * local variables: + * int c character value + * char fb[] constructed file specification string + * FILE * fp filehandle for opened file + * char * p1 pointer to filespec string fn + * char * p2 pointer to filespec string fb + * char * p3 pointer to filetype string ft + * + * global variables: + * int lkerr error flag + * + * functions called: + * FILE * fopen() c_library + * int fprintf() c_library + * + * side effects: + * File is opened for read or write. + */ + +FILE * +afile(fn, ft, wf) +char *fn; +char *ft; +{ + register char *p1, *p2, *p3; + register int c; + FILE *fp; + char fb[FILSPC]; + char *omode = (wf ? (wf == 2 ? "a" : "w") : "r"); + + p1 = fn; + p2 = fb; + p3 = ft; + while ((c = *p1++) != 0 && c != FSEPX) { + if (p2 < &fb[FILSPC-4]) + *p2++ = c; + } + *p2++ = FSEPX; + if (*p3 == 0) { + if (c == FSEPX) { + p3 = p1; + } else { + p3 = "rel"; + } + } + while ((c = *p3++) != 0) { + if (p2 < &fb[FILSPC-1]) + *p2++ = c; + } + *p2++ = 0; + if ((fp = fopen(fb, omode)) == NULL) { + if (strcmp(ft,"cdb")) { + fprintf(stderr, "%s: cannot %s.\n", fb, wf?"create":"open"); + lkerr++; + } + } + return (fp); +} + +/*)Function VOID iramsav() + * + * The function iramsav() stores the size of the chip's internal RAM. + * This is used after linking to check that variable assignment to this + * dataspace didn't overflow into adjoining segments. Variables in the + * DSEG, OSEG, and ISEG are assigned to this dataspace. + * + * local variables: + * none + * + * global variables: + * char *ip pointer into the REL file + * text line in ib[] + * unsigned int size of chip's internal + * iram_size RAM segment + * + * functions called: + * char getnb() lklex.c + * VOID unget() lklex.c + * addr_t expr() lkeval.c + * + * side effects: + * The iram_size may be modified. + */ + +VOID +iramsav() +{ + unget(getnb()); + if (ip && *ip) + //iram_size = atoi(ip); + iram_size = expr(0); /* evaluate size expression */ + else + iram_size = 128; /* Default is 128 (0x80) bytes */ +} + +/*)Function VOID iramcheck() + * + * The function iramcheck() is used at the end of linking to check that + * the internal RAM area wasn't overflowed by too many variable + * assignments. Variables in the DSEG, ISEG, and OSEG are assigned to + * the chip's internal RAM. + * + * local variables: + * none + * + * global variables: + * unsigned int size of chip's internal + * iram_size RAM segment + * struct area linked list of memory + * *areap areas + * + * functions called: + * + * side effects: + */ + +VOID +iramcheck() +{ + register unsigned int last_addr; + register struct area *ap; + + for (ap = areap; ap; ap=ap->a_ap) { + if ((ap->a_size != 0) && + (!strcmp(ap->a_id, "DSEG") || + !strcmp(ap->a_id, "OSEG") || + !strcmp(ap->a_id, "ISEG") + ) + ) + { + last_addr = ap->a_addr + ap->a_size - 1; + if (last_addr >= iram_size) + fprintf(stderr, + "\nWARNING! Segment %s extends past the end\n" + " of internal RAM. Check map file.\n", + ap->a_id); + } + } +} + +char *usetxt[] = { + "Startup:", + " -c Command line input", + " -f file[LNK] File input", + " -p Prompt and echo of file[LNK] to stdout (default)", + " -n No echo of file[LNK] to stdout", +/* "Usage: [-Options] file [file ...]", */ + "Libraries:", + " -k Library path specification, one per -k", + " -l Library file specification, one per -l", + "Relocation:", + " -b area base address = expression", + " -g global symbol = expression", + "Map format:", + " -m Map output generated as file[MAP]", + " -x Hexadecimal (default), -d Decimal, -q Octal", + "Output:", + " -i Intel Hex as file[IHX]", + " -s Motorola S19 as file[S19]", + " -j Produce NoICE debug as file[NOI]", + " -z Produce SDCdb debug as file[cdb]", +/* "List:", */ + " -u Update listing file(s) with link data as file(s)[.RST]", + "Miscellaneous:\n" + " -a [iram-size] Check for internal RAM overflow", + "End:", + " -e or null line terminates input", + 0 +}; + +/*)Function VOID usage() + * + * The function usage() outputs to the stderr device the + * assembler name and version and a list of valid assembler options. + * + * local variables: + * char ** dp pointer to an array of + * text string pointers. + * + * global variables: + * FILE * stderr c_library + * + * functions called: + * int fprintf() c_library + * + * side effects: + * none + */ + +VOID +usage() +{ + register char **dp; + + fprintf(stderr, "\nASxxxx Linker %s\n\n", VERSION); + for (dp = usetxt; *dp; dp++) + fprintf(stderr, "%s\n", *dp); + lkexit(1); +} + +/*)Function VOID copyfile() + * + * FILE *dest destination file + * FILE *src source file + * + * function will copy source file to destination file + * + * + * functions called: + * int fgetc() c_library + * int fputc() c_library + * + * side effects: + * none + */ +VOID copyfile (dest,src) +FILE *src,*dest ; +{ + int ch; + while ((ch = fgetc(src)) != EOF) { + + fputc(ch,dest); + } +} diff --git a/as/mcs51/lknoice.c b/as/mcs51/lknoice.c new file mode 100644 index 00000000..22e2d96c --- /dev/null +++ b/as/mcs51/lknoice.c @@ -0,0 +1,246 @@ +/* lknoice.c */ + +/* + * Extensions to CUG 292 linker ASLINK to produce NoICE debug files + * + * 31-Oct-1997 by John Hartman + * 30-Jan-98 JLH add page to DefineNoICE for 8051 + * 2-Feb-98 JLH Allow optional .nest on local vars - C scoping rules... + */ + +#include +#include +#include +#include +#include "aslink.h" + +static void DefineGlobal( char *name, addr_t value, int page ); +static void DefineScoped( char *name, addr_t value, int page ); +static void DefineFile( char *name, addr_t value, int page ); +static void DefineFunction( char *name, addr_t value, int page ); +static void DefineStaticFunction( char *name, addr_t value, int page ); +static void DefineEndFunction( addr_t value, int page ); +static void DefineLine( char *lineString, addr_t value, int page ); +static void PagedAddress( addr_t value, int page ); + +/* + * Called from lstarea in lklist.c for each symbol. + * + * Generates appropriate NoICE commands into output file, if any is open + * + */ +void DefineNoICE( char *name, addr_t value, int page ) +{ + char token1[NCPS]; /* parse for file.function.symbol */ + char token2[NCPS]; + char token3[NCPS]; + // char token4[NCPS]; + char sep1, sep2; + int j, level; + + /* no output if file is not open */ + if (jfp == NULL) return; + + j = sscanf( name, "%[^.]%c%[^.]%c%s", + token1, &sep1, token2, &sep2, token3 ); + switch (j) + { + /* file.function.symbol, or file.function..SPECIAL */ + case 5: + DefineFile( token1, 0, 0 ); + if (token3[0] == '.') + { + if (strcmp( token3, ".FN" ) == 0) + { + /* Global function */ + DefineFunction( token2, value, page ); + } + else if (strcmp( token3, ".SFN" ) == 0) + { + /* Static (file-scope) function */ + DefineStaticFunction( token2, value, page ); + } + else if (strcmp( token3, ".EFN" ) == 0) + { + /* End of function */ + DefineEndFunction( value, page ); + } + } + else + { + /* Function-scope var. */ + DefineFunction( token2, 0, 0 ); + + /* Look for optional level integer */ + j = sscanf( token3, "%[^.]%c%u", token1, &sep1, &level ); + if ((j == 3) && (level != 0)) + { + sprintf( &token1[ strlen(token1) ], "_%u", level ); + } + DefineScoped( token1, value, page ); + } + break; + + /* file.func. is illegal */ + case 4: + break; + + /* either file.symbol or file.line# */ + case 3: + DefineFile( token1, 0, 0 ); + if ((token2[0] >= '0') && (token2[0] <= '9')) + { + /* Line number */ + DefineLine( token2, value, page ); + } + else + { + /* File-scope symbol. (Kill any function) */ + DefineEndFunction( 0, 0 ); + DefineScoped( token2, value, page ); + } + break; + + /* symbol. is illegal */ + case 2: + break; + + /* just a symbol */ + case 1: + DefineGlobal( token1, value, page ); + break; + } +} + +static char currentFile[NCPS]; +static char currentFunction[NCPS]; + +/* + * static function: + * Define "name" as a global symbol + */ +void DefineGlobal( char *name, addr_t value, int page ) +{ + fprintf( jfp, "DEF %s ", name ); + PagedAddress( value, page ); +} + +/* + * static function: + * Define "name" as a static (scoped) symbol + */ +void DefineScoped( char *name, addr_t value, int page ) +{ + fprintf( jfp, "DEFS %s ", name ); + PagedAddress( value, page ); +} + +/* + * static function: + * Define "name" as the current file + */ +void DefineFile( char *name, addr_t value, int page ) +{ + if (strcmpi( name, currentFile ) != 0) + { + strcpy( currentFile, name ); + if (value != 0) + { + fprintf( jfp, "FILE %s ", name ); + PagedAddress( value, page ); + } + else + { + fprintf( jfp, "FILE %s\n", name ); + } + } +} + +/* + * static function: + * Define "name" as the current function + */ +void DefineFunction( char *name, addr_t value, int page ) +{ + if (strcmpi( name, currentFunction ) != 0) + { + strcpy( currentFunction, name ); + if (value != 0) + { + fprintf( jfp, "DEF %s ", name ); + PagedAddress( value, page ); + fprintf( jfp, "FUNC %s ", name ); + PagedAddress( value, page ); + } + else + { + fprintf( jfp, "FUNC %s\n", name ); + } + } +} + +/* + * static function: + * Define "name" as the current static (scoped) function + */ +void DefineStaticFunction( char *name, addr_t value, int page ) +{ + if (strcmpi( name, currentFunction ) != 0) + { + strcpy( currentFunction, name ); + if (value != 0) + { + fprintf( jfp, "DEFS %s ", name ); + PagedAddress( value, page ); + fprintf( jfp, "SFUNC %s ", name ); + PagedAddress( value, page ); + } + else + { + fprintf( jfp, "SFUNC %s\n", name ); + } + } +} + +/* + * static function: + * Define the end of the current function + */ +void DefineEndFunction( addr_t value, int page ) +{ + if (currentFunction[0] != 0) + { + if (value != 0) + { + fprintf( jfp, "ENDF " ); + PagedAddress( value, page ); + } + else + { + fprintf( jfp, "ENDF\n" ); + } + + currentFunction[0] = 0; + } +} + +/* + * static function: + * Define "lineNumber" as a line in the current file + */ +void DefineLine( char *lineString, addr_t value, int page ) +{ + int indigit, lineNumber = 0; + + while( (indigit=digit( *lineString++, 10 )) >= 0) + { + lineNumber = 10*lineNumber + indigit; + } + fprintf( jfp, "LINE %u ", lineNumber ); + PagedAddress( value, page ); +} + +void PagedAddress( addr_t value, int page ) +{ + fprintf( jfp, "%X:0x%X\n", page, value ); +} diff --git a/as/mcs51/lkrloc.c b/as/mcs51/lkrloc.c new file mode 100644 index 00000000..37af57a2 --- /dev/null +++ b/as/mcs51/lkrloc.c @@ -0,0 +1,1173 @@ +/* lkrloc.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 29-Oct-97 JLH: + * - errdmp: show s_id as string rather than array [NCPS] + * - relr: add support for 11 bit 8051 addressing + * 02-Apr-98 JLH: don't output empty hex records + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkrloc.c + * + * The module lkrloc.c contains the functions which + * perform the relocation calculations. + * + * lkrloc.c contains the following functions: + * addr_t adb_b() + * addr_t adb_lo() + * addr_t adb_hi() + * addr_t adw_w() + * addr_t adw_lo() + * addr_t adw_hi() + * VOID erpdmp() + * VOID errdmp() + * addr_t evword() + * VOID prntval() + * VOID rele() + * VOID relerr() + * VOID relerp() + * VOID reloc() + * VOID relp() + * VOID relr() + * VOID relt() + * + * lkrloc.c the local variable errmsg[]. + * + */ + +/*)Function VOID reloc(c) + * + * char c process code + * + * The function reloc() calls a particular relocation + * function determined by the process code. + * + * local variable: + * none + * + * global variables: + * int lkerr error flag + * + * called functions: + * int fprintf() c_library + * VOID rele() lkrloc.c + * VOID relp() lkrloc.c + * VOID relr() lkrloc.c + * VOId relt() lkrloc.c + * + * side effects: + * Refer to the called relocation functions. + * + */ + +VOID +reloc(c) +char c; +{ + switch(c) { + + case 'T': + relt(); + break; + + case 'R': + relr(); + break; + + case 'P': + relp(); + break; + + case 'E': + rele(); + break; + + default: + fprintf(stderr, "Undefined Relocation Operation\n"); + lkerr++; + break; + + } +} + + +/*)Function VOID relt() + * + * The function relt() evaluates a T line read by + * the linker. Each byte value read is saved in the + * rtval[] array, rtflg[] is set, and the number of + * evaluations is maintained in rtcnt. + * + * T Line + * + * T xx xx nn nn nn nn nn ... + * + * + * In: "T n0 n1 n2 n3 ... nn" + * + * Out: 0 1 2 .. rtcnt + * +----+----+----+----+----+ + * rtval | n0 | n1 | n2 | .. | nn | + * +----+----+----+----+----+ + * rtflag| 1 | 1 | 1 | 1 | 1 | + * +----+----+----+----+----+ + * + * The T line contains the assembled code output by the assem- + * bler with xx xx being the offset address from the current area + * base address and nn being the assembled instructions and data in + * byte format. + * + * local variable: + * none + * + * global variables: + * int rtcnt number of values evaluated + * int rtflg[] array of evaluation flags + * int rtval[] array of evaluation values + * + * called functions: + * int eval() lkeval.c + * int more() lklex.c + * + * side effects: + * Linker input T line evaluated. + * + */ + +VOID +relt() +{ + rtcnt = 0; + while (more()) { + if (rtcnt < NTXT) { + rtval[rtcnt] = eval(); + rtflg[rtcnt] = 1; + rtcnt++; + } + } +} + +/*)Function VOID relr() + * + * The function relr() evaluates a R line read by + * the linker. The R line data is combined with the + * previous T line data to perform the relocation of + * code and data bytes. The S19 / IHX output and + * translation of the LST files to RST files may be + * performed. + * + * R Line + * + * R 0 0 nn nn n1 n2 xx xx ... + * + * The R line provides the relocation information to the linker. + * The nn nn value is the current area index, i.e. which area the + * current values were assembled. Relocation information is en- + * coded in groups of 4 bytes: + * + * 1. n1 is the relocation mode and object format + * 1. bit 0 word(0x00)/byte(0x01) + * 2. bit 1 relocatable area(0x00)/symbol(0x02) + * 3. bit 2 normal(0x00)/PC relative(0x04) relocation + * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for + * byte data + * 5. bit 4 signed(0x00)/unsigned(0x10) byte data + * 6. bit 5 normal(0x00)/page '0'(0x20) reference + * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference + * + * 2. n2 is a byte index into the corresponding (i.e. pre- + * ceeding) T line data (i.e. a pointer to the data to be + * updated by the relocation). The T line data may be + * 1-byte or 2-byte byte data format or 2-byte word + * format. + * + * 3. xx xx is the area/symbol index for the area/symbol be- + * ing referenced. the corresponding area/symbol is found + * in the header area/symbol lists. + * + * The groups of 4 bytes are repeated for each item requiring relo- + * cation in the preceeding T line. + * + * local variable: + * areax **a pointer to array of area pointers + * int aindex area index + * char *errmsg[] array of pointers to error strings + * int error error code + * int lkerr error flag + * int mode relocation mode + * adrr_t paga paging base area address + * addr_t pags paging symbol address + * addr_t pc relocated base address + * addr_t r PCR relocation value + * addr_t reli relocation initial value + * addr_t relv relocation final value + * int rindex symbol / area index + * addr_t rtbase base code address + * addr_t rtofst rtval[] index offset + * int rtp index into T data + * sym **s pointer to array of symbol pointers + * + * global variables: + * head *hp pointer to the head structure + * rerr rerr linker error structure + * FILE *stderr standard error device + * + * called functions: + * addr_t adb_b() lkrloc.c + * addr_t adb_lo() lkrloc.c + * addr_t adb_hi() lkrloc.c + * addr_t adw_w() lkrloc.c + * addr_t evword() lkrloc.c + * int eval() lkeval.c + * int fprintf() c_library + * VOID ihx() lkihx.c + * int lkulist lklist.c + * int more() lklex.c + * VOID relerr() lkrloc.c + * VOID s19() lks19.c + * int symval() lksym.c + * + * side effects: + * The R and T lines are combined to produce + * relocated code and data. Output S19 / IHX + * and relocated listing files may be produced. + * + */ + +VOID +relr() +{ + register int mode; + register addr_t reli, relv; + int aindex, rindex, rtp, error; + addr_t r, rtbase, rtofst, paga, pags, pc; + struct areax **a; + struct sym **s; + + /* + * Get area and symbol lists + */ + a = hp->a_list; + s = hp->s_list; + + /* + * Verify Area Mode + */ + if (eval() != (R_WORD | R_AREA) || eval()) { + fprintf(stderr, "R input error\n"); + lkerr++; + } + + /* + * Get area pointer + */ + aindex = evword(); + if (aindex >= hp->h_narea) { + fprintf(stderr, "R area error\n"); + lkerr++; + return; + } + + /* + * Base values + */ + rtbase = adw_w(0, 0); + rtofst = 2; + + /* + * Relocate address + */ + pc = adw_w(a[aindex]->a_addr, 0); + + /* + * Do remaining relocations + */ + while (more()) { + error = 0; + mode = eval(); + rtp = eval(); + rindex = evword(); + + /* + * R_SYM or R_AREA references + */ + if (mode & R_SYM) { + if (rindex >= hp->h_nglob) { + fprintf(stderr, "R symbol error\n"); + lkerr++; + return; + } + reli = symval(s[rindex]); + } else { + if (rindex >= hp->h_narea) { + fprintf(stderr, "R area error\n"); + lkerr++; + return; + } + reli = a[rindex]->a_addr; + } + + /* + * R_PCR addressing + */ + if (mode & R_PCR) { + if (mode & R_BYTE) { + reli -= (pc + (rtp-rtofst) + 1); + } else { + reli -= (pc + (rtp-rtofst) + 2); + } + } + + /* + * R_PAG0 or R_PAG addressing + */ + if (mode & (R_PAG0|R_PAG)) { + paga = sdp.s_area->a_addr; + pags = sdp.s_addr; + reli -= paga + pags; + } + + /* + * R_BYTE or R_WORD operation + */ + if (mode & R_BYTE) { + if (mode & R_BYT2) { + if (mode & R_MSB) { + relv = adb_hi(reli, rtp); + } else { + relv = adb_lo(reli, rtp); + } + } else { + relv = adb_b(reli, rtp); + } + } else if (mode & R_J11) { + /* JLH: 11 bit jump destination for 8051. Forms + / two byte instruction with op-code bits + / in the MIDDLE! + / rtp points at 3 byte locus: first two + / will get the instructiion. third one + / has raw op-code. + */ + + /* Calculate absolute destination + / relv must be on same 2K page as pc + */ + relv = adw_w(reli, rtp); + + if ((relv & ~0x7ff) != ((pc + rtp - rtofst) & ~0x7ff)) { + error = 2; + } + + /* Merge MSB (byte 0) with op-code, ignoring + / top 5 bits of address. Then hide the op-code + */ + rtval[rtp] = ((rtval[rtp] & 0x07)<<5) | rtval[rtp+2]; + rtflg[rtp+2] = 0; + rtofst += 1; + } else { + /* + * R_WORD with the R_BYT2 mode is flagged + * as an 'r' error by the assembler, + * but it is processed here anyway. + */ +#if 0 + /* JLH: R_WORD and R_BYT2 together is now subsumed by R_J11 */ + if (mode & R_BYT2) { + + if (mode & R_MSB) { + relv = adw_hi(reli, rtp); + } else { + relv = adw_lo(reli, rtp); + } + } else { + relv = adw_w(reli, rtp); + } +#else + relv = adw_w(reli, rtp); +#endif + } + + /* + * R_BYTE with R_BYT2 offset adjust + */ + if (mode & R_BYTE) { + if (mode & R_BYT2) { + rtofst += 1; + } + } + + /* + * Unsigned Byte Checking + */ + if (mode & R_USGN && mode & R_BYTE && relv & ~0xFF) + error = 1; + + /* + * PCR Relocation Error Checking + */ + if (mode & R_PCR && mode & R_BYTE) { + r = relv & ~0x7F; + if (r != (addr_t) ~0x7F && r != 0) + error = 2; + } + + /* + * Page Relocation Error Checking + */ + /* if (mode & R_PAG0 && (relv & ~0xFF || paga || pags)) + error = 3;*/ + if (mode & R_PAG && (relv & ~0xFF)) + error = 4; + + /* + * Error Processing + */ + if (error) { + rerr.aindex = aindex; + rerr.mode = mode; + rerr.rtbase = rtbase + rtp - rtofst - 1; + rerr.rindex = rindex; + rerr.rval = relv - reli; + relerr(errmsg[error-1]); + } + } + if (uflag != 0) { + lkulist(1); + } + + /* JLH: output only if data (beyond two byte address) */ + if ((oflag == 1) && (rtcnt > 2)) { + ihx(1); + } else + if ((oflag == 2) && (rtcnt > 2)) { + s19(1); + } +} + +char *errmsg[] = { + "Unsigned Byte error", + "Byte PCR relocation error", + "Page0 relocation error", + "Page Mode relocation error" +}; + + +/*)Function VOID relp() + * + * The function relp() evaluates a P line read by + * the linker. The P line data is combined with the + * previous T line data to set the base page address + * and test the paging boundary and length. + * + * P Line + * + * P 0 0 nn nn n1 n2 xx xx + * + * The P line provides the paging information to the linker as + * specified by a .setdp directive. The format of the relocation + * information is identical to that of the R line. The correspond- + * ing T line has the following information: + * T xx xx aa aa bb bb + * + * Where aa aa is the area reference number which specifies the + * selected page area and bb bb is the base address of the page. + * bb bb will require relocation processing if the 'n1 n2 xx xx' is + * specified in the P line. The linker will verify that the base + * address is on a 256 byte boundary and that the page length of an + * area defined with the PAG type is not larger than 256 bytes. + * + * local variable: + * areax **a pointer to array of area pointers + * int aindex area index + * int mode relocation mode + * addr_t relv relocation value + * int rindex symbol / area index + * int rtp index into T data + * sym **s pointer to array of symbol pointers + * + * global variables: + * head *hp pointer to the head structure + * int lkerr error flag + * sdp sdp base page structure + * FILE *stderr standard error device + * + * called functions: + * addr_t adw_w() lkrloc.c + * addr_t evword() lkrloc.c + * int eval() lkeval.c + * int fprintf() c_library + * int more() lklex.c + * int symval() lksym.c + * + * side effects: + * The P and T lines are combined to set + * the base page address and report any + * paging errors. + * + */ + +VOID +relp() +{ + register int aindex, rindex; + int mode, rtp; + addr_t relv; + struct areax **a; + struct sym **s; + + /* + * Get area and symbol lists + */ + a = hp->a_list; + s = hp->s_list; + + /* + * Verify Area Mode + */ + if (eval() != (R_WORD | R_AREA) || eval()) { + fprintf(stderr, "P input error\n"); + lkerr++; + } + + /* + * Get area pointer + */ + aindex = evword(); + if (aindex >= hp->h_narea) { + fprintf(stderr, "P area error\n"); + lkerr++; + return; + } + + /* + * Do remaining relocations + */ + while (more()) { + mode = eval(); + rtp = eval(); + rindex = evword(); + + /* + * R_SYM or R_AREA references + */ + if (mode & R_SYM) { + if (rindex >= hp->h_nglob) { + fprintf(stderr, "P symbol error\n"); + lkerr++; + return; + } + relv = symval(s[rindex]); + } else { + if (rindex >= hp->h_narea) { + fprintf(stderr, "P area error\n"); + lkerr++; + return; + } + relv = a[rindex]->a_addr; + } + adw_w(relv, rtp); + } + + /* + * Paged values + */ + aindex = adw_w(0,2); + if (aindex >= hp->h_narea) { + fprintf(stderr, "P area error\n"); + lkerr++; + return; + } + sdp.s_areax = a[aindex]; + sdp.s_area = sdp.s_areax->a_bap; + sdp.s_addr = adw_w(0,4); + if (sdp.s_area->a_addr & 0xFF || sdp.s_addr & 0xFF) + relerp("Page Definition Boundary Error"); +} + +/*)Function VOID rele() + * + * The function rele() closes all open output files + * at the end of the linking process. + * + * local variable: + * none + * + * global variables: + * int oflag output type flag + * int uflag relocation listing flag + * + * called functions: + * VOID ihx() lkihx.c + * VOID lkulist() lklist.c + * VOID s19() lks19.c + * + * side effects: + * All open output files are closed. + * + */ + +VOID +rele() +{ + if (uflag != 0) { + lkulist(0); + } + if (oflag == 1) { + ihx(0); + } else + if (oflag == 2) { + s19(0); + } +} + +/*)Function addr_t evword() + * + * The function evword() combines two byte values + * into a single word value. + * + * local variable: + * addr_t v temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * int eval() lkeval.c + * + * side effects: + * Relocation text line is scanned to combine + * two byte values into a single word value. + * + */ + +addr_t +evword() +{ + register addr_t v; + + if (hilo) { + v = (eval() << 8); + v += eval(); + } else { + v = eval(); + v += (eval() << 8); + } + return(v); +} + +/*)Function addr_t adb_b(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adb_b() adds the value of v to + * the single byte value contained in rtval[i]. + * The new value of rtval[i] is returned. + * + * local variable: + * none + * + * global variables: + * none + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * + */ + +addr_t +adb_b(v, i) +register addr_t v; +register int i; +{ + return(rtval[i] += v); +} + +/*)Function addr_t adb_lo(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adb_lo() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The MSB rtflg[] is cleared. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The rtflg[] value corresponding to the + * MSB of the word value is cleared to reflect + * the fact that the LSB is the selected byte. + * + */ + +addr_t +adb_lo(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * Remove Hi byte + */ + if (hilo) { + rtflg[i] = 0; + } else { + rtflg[i+1] = 0; + } + return (j); +} + +/*)Function addr_t adb_hi(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adb_hi() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The LSB rtflg[] is cleared. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The rtflg[] value corresponding to the + * LSB of the word value is cleared to reflect + * the fact that the MSB is the selected byte. + * + */ + +addr_t +adb_hi(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * Remove Lo byte + */ + if (hilo) { + rtflg[i+1] = 0; + } else { + rtflg[i] = 0; + } + return (j); +} + +/*)Function addr_t adw_w(v, i) + * + * int v value to add to word + * int i rtval[] index + * + * The function adw_w() adds the value of v to the + * word value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The word value of rtval[] is changed. + * + */ + +addr_t +adw_w(v, i) +register addr_t v; +register int i; +{ + register addr_t j; + + if (hilo) { + j = v + (rtval[i] << 8) + (rtval[i+1] & 0xff); + rtval[i] = (j >> 8) & 0xff; + rtval[i+1] = j & 0xff; + } else { + j = v + (rtval[i] & 0xff) + (rtval[i+1] << 8); + rtval[i] = j & 0xff; + rtval[i+1] = (j >> 8) & 0xff; + } + return(j); +} + +/*)Function addr_t adw_lo(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adw_lo() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The MSB rtval[] is zeroed. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The MSB of the word value is cleared to reflect + * the fact that the LSB is the selected byte. + * + */ + +addr_t +adw_lo(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * Clear Hi byte + */ + if (hilo) { + rtval[i] = 0; + } else { + rtval[i+1] = 0; + } + return (j); +} + +/*)Function addr_t adw_hi(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adw_hi() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The MSB and LSB values are interchanged. + * The MSB rtval[] is zeroed. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The MSB and LSB values are interchanged and + * then the MSB cleared. + * + */ + +addr_t +adw_hi(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * LSB = MSB, Clear MSB + */ + if (hilo) { + rtval[i+1] = rtval[i]; + rtval[i] = 0; + } else { + rtval[i] = rtval[i+1]; + rtval[i+1] = 0; + } + return (j); +} + +/*)Function VOID relerr(str) + * + * char *str error string + * + * The function relerr() outputs the error string to + * stderr and to the map file (if it is open). + * + * local variable: + * none + * + * global variables: + * FILE *mfp handle for the map file + * + * called functions: + * VOID errdmp() lkrloc.c + * + * side effects: + * Error message inserted into map file. + * + */ + +VOID +relerr(str) +char *str; +{ + errdmp(stderr, str); + if (mfp) + errdmp(mfp, str); +} + +/*)Function VOID errdmp(fptr, str) + * + * FILE *fptr output file handle + * char *str error string + * + * The function errdmp() outputs the error string str + * to the device specified by fptr. Additional information + * is output about the definition and referencing of + * the symbol / area error. + * + * local variable: + * int mode error mode + * int aindex area index + * int lkerr error flag + * int rindex error index + * sym **s pointer to array of symbol pointers + * areax **a pointer to array of area pointers + * areax *raxp error area extension pointer + * + * global variables: + * sdp sdp base page structure + * + * called functions: + * int fprintf() c_library + * VOID prntval() lkrloc.c + * + * side effects: + * Error reported. + * + */ + +VOID +errdmp(fptr, str) +FILE *fptr; +char *str; +{ + int mode, aindex, rindex; + struct sym **s; + struct areax **a; + struct areax *raxp; + + a = hp->a_list; + s = hp->s_list; + + mode = rerr.mode; + aindex = rerr.aindex; + rindex = rerr.rindex; + + /* + * Print Error + */ + fprintf(fptr, "\n?ASlink-Warning-%s", str); + lkerr++; + + /* + * Print symbol if symbol based + */ + if (mode & R_SYM) { + fprintf(fptr, " for symbol %s\n", + &s[rindex]->s_id[0]); + } else { + fprintf(fptr, "\n"); + } + + /* + * Print Ref Info + */ + fprintf(fptr, + " file module area offset\n"); + fprintf(fptr, + " Refby %-8.8s %-8.8s %-8.8s ", + hp->h_lfile->f_idp, + &hp->m_id[0], + &a[aindex]->a_bap->a_id[0]); + prntval(fptr, rerr.rtbase); + + /* + * Print Def Info + */ + if (mode & R_SYM) { + raxp = s[rindex]->s_axp; + } else { + raxp = a[rindex]; + } + fprintf(fptr, + " Defin %-8.8s %-8.8s %-8.8s ", + raxp->a_bhp->h_lfile->f_idp, + &raxp->a_bhp->m_id[0], + &raxp->a_bap->a_id[0]); + if (mode & R_SYM) { + prntval(fptr, s[rindex]->s_addr); + } else { + prntval(fptr, rerr.rval); + } +} + +/*)Function VOID prntval(fptr, v) + * + * FILE *fptr output file handle + * addr_t v value to output + * + * The function prntval() outputs the value v, in the + * currently selected radix, to the device specified + * by fptr. + * + * local variable: + * none + * + * global variables: + * int xflag current radix + * + * called functions: + * int fprintf() c_library + * + * side effects: + * none + * + */ + +VOID +prntval(fptr, v) +FILE *fptr; +addr_t v; +{ + if (xflag == 0) { + fprintf(fptr, "%04X\n", v); + } else + if (xflag == 1) { + fprintf(fptr, "%06o\n", v); + } else + if (xflag == 2) { + fprintf(fptr, "%05u\n", v); + } +} + +/*)Function VOID relerp(str) + * + * char *str error string + * + * The function relerp() outputs the paging error string to + * stderr and to the map file (if it is open). + * + * local variable: + * none + * + * global variables: + * FILE *mfp handle for the map file + * + * called functions: + * VOID erpdmp() lkrloc.c + * + * side effects: + * Error message inserted into map file. + * + */ + +VOID +relerp(str) +char *str; +{ + erpdmp(stderr, str); + if (mfp) + erpdmp(mfp, str); +} + +/*)Function VOID erpdmp(fptr, str) + * + * FILE *fptr output file handle + * char *str error string + * + * The function erpdmp() outputs the error string str + * to the device specified by fptr. + * + * local variable: + * head *thp pointer to head structure + * + * global variables: + * int lkerr error flag + * sdp sdp base page structure + * + * called functions: + * int fprintf() c_library + * VOID prntval() lkrloc.c + * + * side effects: + * Error reported. + * + */ + +VOID +erpdmp(fptr, str) +FILE *fptr; +char *str; +{ + register struct head *thp; + + thp = sdp.s_areax->a_bhp; + + /* + * Print Error + */ + fprintf(fptr, "\n?ASlink-Warning-%s\n", str); + lkerr++; + + /* + * Print PgDef Info + */ + fprintf(fptr, + " file module pgarea pgoffset\n"); + fprintf(fptr, + " PgDef %-8.8s %-8.8s %-8.8s ", + thp->h_lfile->f_idp, + &thp->m_id[0], + &sdp.s_area->a_id[0]); + prntval(fptr, sdp.s_area->a_addr + sdp.s_addr); +} diff --git a/as/mcs51/lks19.c b/as/mcs51/lks19.c new file mode 100644 index 00000000..cfbb5d18 --- /dev/null +++ b/as/mcs51/lks19.c @@ -0,0 +1,123 @@ +/* lks19.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lks19.c + * + * The module lks19.c contains the function to + * output the relocated object code in the + * Motorola S19 format. + * + * lks19.c contains the following function: + * VOID s19(i) + * + * lks19.c contains no local variables. + */ + +/*)S19 Format + * Record Type Field - This field signifies the start of a + * record and identifies the the record + * type as follows: + * + * Ascii S1 - Data Record + * Ascii S9 - End of File Record + * + * Record Length Field - This field specifies the record length + * which includes the address, data, and + * checksum fields. The 8 bit record + * length value is converted to two ascii + * characters, high digit first. + * + * Load Address Field - This field consists of the four ascii + * characters which result from converting + * the the binary value of the address in + * which to begin loading this record. The + * order is as follows: + * + * High digit of high byte of address. + * Low digit of high byte of address. + * High digit of low byte of address. + * Low digit of low byte of address. + * + * In an End of File record this field con- + * sists of either four ascii zeros or the + * program entry address. Currently the + * entry address option is not supported. + * + * Data Field - This field consists of the actual data, + * converted to two ascii characters, high + * digit first. There are no data bytes in + * the End of File record. + * + * Checksum Field - The checksum field is the 8 bit binary + * sum of the record length field, the load + * address field, and the data field. This + * sum is then complemented (1's comple- + * ment) and converted to two ascii + * characters, high digit first. + */ + +/*)Function s19(i) + * + * int i 0 - process data + * 1 - end of data + * + * The function s19() outputs the relocated data + * in the standard Motorola S19 format. + * + * local variables: + * addr_t chksum byte checksum + * + * global variables: + * int hilo byte order + * FILE * ofp output file handle + * int rtcnt count of data words + * int rtflg[] output the data flag + * addr_t rtval[] relocated data + * + * functions called: + * int fprintf() c_library + * + * side effects: + * The data is output to the file defined by ofp. + */ + +VOID +s19(i) +{ + register addr_t chksum; + + if (i) { + if (hilo == 0) { + chksum = rtval[0]; + rtval[0] = rtval[1]; + rtval[1] = chksum; + } + for (i = 0, chksum = 1; i < rtcnt; i++) { + if (rtflg[i]) + chksum++; + } + fprintf(ofp, "S1%02X", chksum); + for (i = 0; i < rtcnt ; i++) { + if (rtflg[i]) { + fprintf(ofp, "%02X", rtval[i]); + chksum += rtval[i]; + } + } + fprintf(ofp, "%02X\n", (-chksum-1) & 0xff); + } else { + fprintf(ofp, "S9030000FC\n"); + } +} diff --git a/as/mcs51/lkstore.c b/as/mcs51/lkstore.c new file mode 100644 index 00000000..69ffd002 --- /dev/null +++ b/as/mcs51/lkstore.c @@ -0,0 +1,51 @@ +/* lkstore.c */ + +/* + * Allocated string storage module. + * + * 31-Oct-1997 by John Hartman + */ + +#include +#include +#include +#include +#include "aslink.h" + +/* + * Allocate space for "str", copy str into new space + * Return a pointer to the allocated name, or NULL if out of memory + */ +char *StoreString( char *str ) +{ + /* To avoid wasting memory headers on small allocations, we + / allocate a big chunk and parcel it out as required. + / These static variables remember our hunk + */ + #define STR_STORE_HUNK 2000 + static char *pNextFree = NULL; + static int bytesLeft = 0; + + int length; + char *pStoredString; + + length = strlen( str ) + 1; /* what we need, including null */ + + if (length > bytesLeft) + { + /* no space. Allocate a new hunk. We lose the pointer to any + / old hunk. We don't care, as the names are never deleted. + */ + pNextFree = (char*)new( STR_STORE_HUNK ); + bytesLeft = STR_STORE_HUNK; + } + + /* Copy the name and terminating null into the name store */ + pStoredString = pNextFree; + memcpy( pStoredString, str, length ); + + pNextFree += length; + bytesLeft -= length; + + return pStoredString; +} diff --git a/as/mcs51/lksym.c b/as/mcs51/lksym.c new file mode 100644 index 00000000..5e259e35 --- /dev/null +++ b/as/mcs51/lksym.c @@ -0,0 +1,484 @@ +/* lksym.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * 28-Oct-97 JLH: + * - lkpsym: Use StoreString for sym construction + * - change symeq() to do length-independent string compare + * - change hash() to do length-independent hash calculation + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lksym.c + * + * The module lksym.c contains the functions that operate + * on the symbol structures. + * + * lksym.c contains the following functions: + * int hash() + * sym * lkpsym() + * VOID * new() + * sym * newsym() + * VOID symdef() + * int symeq() + * VOID syminit() + * VOID symmod() + * addr_t symval() + * + * lksym.c contains no local/static variables. + */ + +/*)Function VOID syminit() + * + * The function syminit() is called to clear the hashtable. + * + * local variables: + * int h computed hash value + * sym ** spp pointer to an array of + * sym structure pointers + * + * global variables: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * (1) The symbol hash tables are cleared + */ + +VOID +syminit() +{ + // register int h; + struct sym **spp; + + spp = &symhash[0]; + while (spp < &symhash[NHASH]) + *spp++ = NULL; +} + +/*)Function sym * newsym() + * + * The function newsym() is called to evaluate the symbol + * definition/reference directive from the .rel file(s). + * If the symbol is not found in the symbol table a new + * symbol structure is created. Evaluation of the + * directive determines if this is a reference or a definition. + * Multiple definitions of the same variable will be flagged + * as an error if the values are not identical. A symbol + * definition places the symbol value and area extension + * into the symbols data structure. And finally, a pointer + * to the symbol structure is placed into the head structure + * symbol list. Refer to the description of the header, symbol, + * area, and areax structures in lkdata.c for structure and + * linkage details. + * + * local variables: + * int c character from input text + * int i evaluation value + * char id[] symbol name + * int nglob number of symbols in this header + * sym * tsp pointer to symbol structure + * sym ** s list of pointers to symbol structures + * + * global variables: + * areax *axp Pointer to the current + * areax structure + * head *headp The pointer to the first + * head structure of a linked list + * int lkerr error flag + * + * functions called: + * addr_t eval() lkeval.c + * VOID exit() c_library + * int fprintf() c_library + * char get() lklex.c + * char getnb() lklex.c + * sym * lkpsym() lksym.c + * + * side effects: + * A symbol structure is created and/or modified. + * If structure space allocation fails linker will abort. + * Several severe errors (these are internal errors + * indicating a corrupted .rel file or corrupted + * assembler or linker) will terminated the linker. + */ + +/* + * Find/Create a global symbol entry. + * + * S xxxxxx Defnnnn + * | | | + * | | `-- sp->s_addr + * | `----- sp->s_type + * `------------ sp->s_id + * + */ +struct sym * +newsym() +{ + register int c, i, nglob; + struct sym *tsp; + struct sym **s; + char id[NCPS]; + + getid(id, -1); + tsp = lkpsym(id, 1); + c = getnb();get();get(); + if (c == 'R') { + tsp->s_type |= S_REF; + if (eval()) { + fprintf(stderr, "Non zero S_REF\n"); + lkerr++; + } + } else + if (c == 'D') { + i = eval(); + if (tsp->s_type & S_DEF && tsp->s_addr != i) { + fprintf(stderr, "Multiple definition of %8s\n", id); + lkerr++; + } + tsp->s_type |= S_DEF; + /* + * Set value and area extension link. + */ + tsp->s_addr = i; + tsp->s_axp = axp; + } else { + fprintf(stderr, "Invalid symbol type %c for %8s\n", c, id); + lkexit(1); + } + /* + * Place pointer in header symbol list + */ + if (headp == NULL) { + fprintf(stderr, "No header defined\n"); + lkexit(1); + } + nglob = hp->h_nglob; + s = hp->s_list; + for (i=0; i < nglob ;++i) { + if (s[i] == NULL) { + s[i] = tsp; + return(tsp); + } + } + fprintf(stderr, "Header symbol list overflow\n"); + lkexit(1); +} + +/*)Function sym * lkpsym(id,f) + * + * char * id symbol name string + * int f f == 0, lookup only + * f != 0, create if not found + * + * The function lookup() searches the symbol hash tables for + * a symbol name match returning a pointer to the sym structure. + * If the symbol is not found then a sym structure is created, + * initialized, and linked to the appropriate hash table if f != 0. + * A pointer to this new sym structure is returned or a NULL + * pointer is returned if f == 0. + * + * local variables: + * int h computed hash value + * sym * sp pointer to a sym structure + * + * global varaibles: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * int hash() lksym.c + * VOID * new() lksym.c + * int symeq() lksym.c + * + * side effects: + * If the function new() fails to allocate space + * for the new sym structure the linker terminates. + */ + +struct sym * +lkpsym(id, f) +char *id; +{ + register struct sym *sp; + register int h; + + h = hash(id); + sp = symhash[h]; + while (sp != NULL) { + if (symeq(id, sp->s_id)) + return (sp); + sp = sp->s_sp; + } + if (f == 0) + return (NULL); + sp = (struct sym *) new (sizeof(struct sym)); + sp->s_sp = symhash[h]; + symhash[h] = sp; + sp->s_id = StoreString( id ); /* JLH */ + return (sp); +} + +/*)Function addr_t symval(tsp) + * + * sym * tsp pointer to a symbol structure + * + * The function symval() returns the value of the + * relocated symbol by adding the variable definition + * value to the areax base address. + * + * local variables: + * addr_t val relocated address value + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +addr_t +symval(tsp) +register struct sym *tsp; +{ + register addr_t val; + + val = tsp->s_addr; + if (tsp->s_axp) { + val += tsp->s_axp->a_addr; + } + return(val); +} + +/*)Function VOID symdef(fp) + * + * FILE * fp file handle for output + * + * The function symdef() scans the hashed symbol table + * searching for variables referenced but not defined. + * Undefined variables are linked to the default + * area "_CODE" and reported as referenced by the + * appropriate module. + * + * local variables: + * int i hash table index loop variable + * sym * sp pointer to linked symbol structure + * + * global variables: + * area *areap The pointer to the first + * area structure of a linked list + * sym *symhash[NHASH] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * symmod() lksym.c + * + * side effects: + * Undefined variables have their areas set to "_CODE". + */ + +VOID +symdef(fp) +FILE *fp; +{ + register struct sym *sp; + register int i; + + for (i=0; is_axp == NULL) + sp->s_axp = areap->a_axp; + if ((sp->s_type & S_DEF) == 0) + symmod(fp, sp); + sp = sp->s_sp; + } + } +} + +/*)Function VOID symmod(fp,tsp) + * + * FILE * fp output file handle + * sym * tsp pointer to a symbol structure + * + * The function symmod() scans the header structures + * searching for a reference to the symbol structure + * pointer to by tsp. The function then generates an error + * message whichs names the module having referenced the + * undefined variable. + * + * local variables: + * int i loop counter + * sym ** p pointer to a list of pointers + * to symbol structures + * + * global variables: + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * int lkerr error flag + * + * functions called: + * int fprintf() c_library + * + * side effects: + * Error output generated. + */ + +VOID +symmod(fp, tsp) +FILE *fp; +struct sym *tsp; +{ + register int i; + struct sym **p; + + if ((hp = headp) != NULL) { + while(hp) { + p = hp->s_list; + for (i=0; ih_nglob; ++i) { + if (p[i] == tsp) { + fprintf(fp, "\n?ASlink-Warning-Undefined Global '%s' ", tsp->s_id); + fprintf(fp, "referenced by module '%s'\n", hp->m_id); + lkerr++; + } + } + hp = hp->h_hp; + } + } +} + +/*)Function int symeq(p1, p2) + * + * char * p1 name string + * char * p2 name string + * + * The function symeq() compares the two name strings for a match. + * The return value is 1 for a match and 0 for no match. + * + * local variables: + * int h loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + * + */ + +int +symeq(p1, p2) +register char *p1, *p2; +{ +#if CASE_SENSITIVE + return (strcmp( p1, p2 ) == 0); +#else + return (strcmpi( p1, p2 ) == 0); +#endif +} + +/*)Function int hash(p) + * + * char * p pointer to string to hash + * + * The function hash() computes a hash code using the sum + * of all characters mod table size algorithm. + * + * local variables: + * int h accumulated character sum + * int n loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + * + */ + +int +hash(p) +register char *p; +{ + register int h; + + h = 0; + while (*p) { + +#if CASE_SENSITIVE + h += *p++; +#else + h += ccase[*p++]; +#endif + + }; + return (h&HMASK); +} + +/*)Function VOID * new(n) + * + * unsigned int n allocation size in bytes + * + * The function new() allocates n bytes of space and returns + * a pointer to this memory. If no space is available the + * linker is terminated. + * + * local variables: + * char * p a general pointer + * char * q a general pointer + * + * global variables: + * none + * + * functions called: + * int fprintf() c_library + * VOID * malloc() c_library + * + * side effects: + * Memory is allocated, if allocation fails + * the linker is terminated. + */ + +VOID * +new(n) +unsigned int n; +{ + register char *p,*q; + register unsigned int i; + + if ((p = (char *) malloc(n)) == NULL) { + fprintf(stderr, "Out of space!\n"); + lkexit(1); + } + for (i=0,q=p; i +#include +#include +#include +#include "asm.h" + +/*)Module asdata.c + * + * The module asdata.c contains the global constants, + * structures, and variables used in the assembler. + */ + +int aserr; /* ASxxxx error counter + */ +jmp_buf jump_env; /* compiler dependent structure + * used by setjmp() and longjmp() + */ +int inpfil; /* count of assembler + * input files specified + */ +int incfil; /* current file handle index + * for include files + */ +int cfile; /* current file handle index + * of input assembly files + */ +int flevel; /* IF-ELSE-ENDIF flag will be non + * zero for false conditional case + */ +int tlevel; /* current conditional level + */ +int ifcnd[MAXIF+1]; /* array of IF statement condition + * values (0 = FALSE) indexed by tlevel + */ +int iflvl[MAXIF+1]; /* array of IF-ELSE-ENDIF flevel + * values indexed by tlevel + */ + +char afn[FILSPC]; /* afile temporary file name + */ +char srcfn[MAXFIL][FILSPC]; /* array of source file names + */ +int srcline[MAXFIL]; /* source line number + */ +char incfn[MAXINC][FILSPC]; /* array of include file names + */ +int incline[MAXINC]; /* include line number + */ + +int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +int line; /* current assembler source + * line number + */ +int page; /* current page number + */ +int lop; /* current line number on page + */ +int pass; /* assembler pass number + */ +int lflag; /* -l, generate listing flag + */ +int gflag; /* -g, make undefined symbols global flag + */ +int aflag; /* -a, make all symbols global flag + */ +int oflag; /* -o, generate relocatable output flag + */ +int sflag; /* -s, generate symbol table flag + */ +int pflag; /* -p, enable listing pagination + */ +int xflag; /* -x, listing radix flag + */ +int fflag; /* -f(f), relocations flagged flag + */ +addr_t laddr; /* address of current assembler line + * or value of .if argument + */ +addr_t fuzz; /* tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + */ +int lmode; /* listing mode + */ +char *ep; /* pointer into error list + * array eb[NERR] + */ +char eb[NERR]; /* array of generated error codes + */ +char *ip; /* pointer into the assembler-source + * text line in ib[] + */ +char ib[NINPUT]; /* assembler-source text line + */ +char *cp; /* pointer to assembler output + * array cb[] + */ +char cb[NCODE]; /* array of assembler output values + */ +int *cpt; /* pointer to assembler relocation type + * output array cbt[] + */ +int cbt[NCODE]; /* array of assembler relocation types + * describing the data in cb[] + */ +char tb[NTITL]; /* Title string buffer + */ +char stb[NSBTL]; /* Subtitle string buffer + */ + +char symtbl[] = { "Symbol Table" }; +char aretbl[] = { "Area Table" }; + +char module[NCPS]; /* module name string + */ + +/* + * The mne structure is a linked list of the assembler + * mnemonics and directives. The list of mnemonics and + * directives contained in the device dependent file + * xxxpst.c are hashed and linked into NHASH lists in + * module assym.c by syminit(). The structure contains + * the mnemonic/directive name, a subtype which directs + * the evaluation of this mnemonic/directive, a flag which + * is used to detect the end of the mnemonic/directive + * list in xxxpst.c, and a value which is normally + * associated with the assembler mnemonic base instruction + * value. + * + * struct mne + * { + * struct mne *m_mp; Hash link + * char m_id[NCPS]; Mnemonic + * char m_type; Mnemonic subtype + * char m_flag; Mnemonic flags + * addr_t m_valu; Value + * }; + */ +struct mne *mnehash[NHASH]; + +/* + * The sym structure is a linked list of symbols defined + * in the assembler source files. The first symbol is "." + * defined here. The entry 'struct tsym *s_tsym' + * links any temporary symbols following this symbol and + * preceeding the next normal symbol. The structure also + * contains the symbol's name, type (USER or NEW), flag + * (global, assigned, and multiply defined), a pointer + * to the area structure defining where the symbol is + * located, a reference number assigned by outgsd() in + * asout.c, and the symbols address relative to the base + * address of the area where the symbol is located. + * + * struct sym + * { + * struct sym *s_sp; Hash link + * struct tsym *s_tsym; Temporary symbol link + * char s_id[NCPS]; Symbol + * char s_type; Symbol subtype + * char s_flag; Symbol flags + * struct area *s_area; Area line, 0 if absolute + * int s_ref; Ref. number + * addr_t s_addr; Address + * }; + */ +struct sym sym[] = { + NULL, NULL, ".", S_USER, S_END, NULL, 0, 0 +}; + +struct sym *symp; /* pointer to a symbol structure + */ +struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ + +/* + * The area structure contains the parameter values for a + * specific program or data section. The area structure + * is a linked list of areas. The initial default area + * is "_CODE" defined here, the next area structure + * will be linked to this structure through the structure + * element 'struct area *a_ep'. The structure contains the + * area name, area reference number ("_CODE" is 0) determined + * by the order of .area directives, area size determined + * from the total code and/or data in an area, area fuzz is + * an variable used to track pass to pass changes in the + * area size caused by variable length instruction formats, + * and area flags which specify the area's relocation type. + * + * struct area + * { + * struct area *a_ap; Area link + * char a_id[NCPS]; Area Name + * int a_ref; Reference number + * addr_t a_size; Area size + * addr_t a_fuzz; Area fuzz + * int a_flag; Area flags + * }; + */ +struct area area[] = { + NULL, "_CODE", 0, 0, 0, A_CON|A_REL +}; + +struct area *areap; /* pointer to an area structure + */ + +FILE *lfp; /* list output file handle + */ +FILE *ofp; /* relocation output file handle + */ +FILE *tfp; /* symbol table output file handle + */ +FILE *sfp[MAXFIL]; /* array of assembler-source file handles + */ +FILE *ifp[MAXINC]; /* array of include-file file handles + */ + +/* + * array of character types, one per + * ASCII character + */ +char ctype[128] = { +/*NUL*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*BS*/ ILL, SPACE, ILL, ILL, SPACE, ILL, ILL, ILL, +/*DLE*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*CAN*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*SPC*/ SPACE, ETC, ETC, ETC, LETTER, BINOP, BINOP, ETC, +/*(*/ ETC, ETC, BINOP, BINOP, ETC, BINOP, LETTER, BINOP, +/*0*/ DGT2, DGT2, DGT8, DGT8, DGT8, DGT8, DGT8, DGT8, +/*8*/ DGT10, DGT10, ETC, ETC, BINOP, ETC, BINOP, ETC, +/*@*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*H*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*P*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*X*/ LETTER, LETTER, LETTER, ETC, ETC, ETC, BINOP, LETTER, +/*`*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*h*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*p*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*x*/ LETTER, LETTER, LETTER, ETC, BINOP, ETC, ETC, ETC +}; + +/* + * an array of characters which + * perform the case translation function + */ +#if CASE_SENSITIVE +#else +char ccase[128] = { +/*NUL*/ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', +/*BS*/ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', +/*DLE*/ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', +/*CAN*/ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', +/*SPC*/ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', +/*(*/ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', +/*0*/ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', +/*8*/ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', +/*@*/ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*H*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*P*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*X*/ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', +/*`*/ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*h*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*p*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*x*/ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177' +}; +#endif diff --git a/as/z80/asexpr.c b/as/z80/asexpr.c new file mode 100644 index 00000000..f610022e --- /dev/null +++ b/as/z80/asexpr.c @@ -0,0 +1,667 @@ +/* asexpr.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module asexpr.c + * + * The module asexpr.c contains the routines to evaluate + * arithmetic/numerical expressions. The functions in + * asexpr.c perform a recursive evaluation of the arithmetic + * expression read from the assembler-source text line. + * The expression may include binary/unary operators, brackets, + * symbols, labels, and constants in hexadecimal, decimal, octal + * and binary. Arithmetic operations are prioritized and + * evaluated by normal arithmetic conventions. + * + * asexpr.c contains the following functions: + * VOID abscheck() + * addr_t absexpr() + * VOID clrexpr() + * int digit() + * VOID expr() + * int oprio() + * VOID term() + * + * asexpr.c contains no local/static variables + */ + +/*)Function VOID expr(esp, n) + * + * expr * esp pointer to an expr structure + * int n a firewall priority; all top + * level calls (from the user) + * should be made with n set to 0. + * + * The function expr() evaluates an expression and + * stores its value and relocation information into + * the expr structure supplied by the user. + * + * local variables: + * int c current assembler-source + * text character + * int p current operator priority + * area * ap pointer to an area structure + * exp re internal expr structure + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * VOID abscheck() asexpr.c + * VOID clrexpr() asexpr.c + * VOID expr() asexpr.c + * int getnb() aslex.c + * int oprio() asexpr.c + * VOID qerr() assubr.c + * VOID rerr() assubr.c + * VOID term() asexpr.c + * VOID unget() aslex.c + * + * + * side effects: + * An expression is evaluated modifying the user supplied + * expr structure, a sym structure maybe created for an + * undefined symbol, and the parse of the expression may + * terminate if a 'q' error occurs. + */ + +VOID +expr(esp, n) +register struct expr *esp; +int n; +{ + register c, d, p; + struct area *ap; + struct expr re; + + term(esp); + while (ctype[c = getnb()] & BINOP) { + /* + * Handle binary operators + - * / & | % ^ << >> + */ + if ((p = oprio(c)) <= n) + break; + if ((c == '>' || c == '<') && c != get()) + qerr(); + clrexpr(&re); + expr(&re, p); + esp->e_rlcf |= re.e_rlcf; + if (c == '+') { + /* + * esp + re, at least one must be absolute + */ + if (esp->e_base.e_ap == NULL) { + /* + * esp is absolute (constant), + * use area from re + */ + esp->e_base.e_ap = re.e_base.e_ap; + } else + if (re.e_base.e_ap) { + /* + * re should be absolute (constant) + */ + rerr(); + } + if (esp->e_flag && re.e_flag) + rerr(); + if (re.e_flag) + esp->e_flag = 1; + esp->e_addr += re.e_addr; + } else + if (c == '-') { + /* + * esp - re + */ + if ((ap = re.e_base.e_ap) != NULL) { + if (esp->e_base.e_ap == ap) { + esp->e_base.e_ap = NULL; + } else { + rerr(); + } + } + if (re.e_flag) + rerr(); + esp->e_addr -= re.e_addr; + } else { + /* + * Both operands (esp and re) must be constants + */ + abscheck(esp); + abscheck(&re); + switch (c) { + + case '*': + esp->e_addr *= re.e_addr; + break; + + case '/': + esp->e_addr /= re.e_addr; + break; + + case '&': + esp->e_addr &= re.e_addr; + break; + + case '|': + esp->e_addr |= re.e_addr; + break; + + case '%': + esp->e_addr %= re.e_addr; + break; + + case '^': + esp->e_addr ^= re.e_addr; + break; + + case '<': + esp->e_addr <<= re.e_addr; + break; + + case '>': + esp->e_addr >>= re.e_addr; + break; + + default: + qerr(); + break; + } + } + } + unget(c); +} + +/*)Function addr_t absexpr() + * + * The function absexpr() evaluates an expression, verifies it + * is absolute (i.e. not position dependent or relocatable), and + * returns its value. + * + * local variables: + * expr e expr structure + * + * global variables: + * none + * + * functions called: + * VOID abscheck() asexpr.c + * VOID clrexpr() asexpr.c + * VOID expr() asexpr.c + * + * side effects: + * If the expression is not absolute then + * a 'r' error is reported. + */ + +addr_t +absexpr() +{ + struct expr e; + + clrexpr(&e); + expr(&e, 0); + abscheck(&e); + return (e.e_addr); +} + +/*)Function VOID term(esp) + * + * expr * esp pointer to an expr structure + * + * The function term() evaluates a single constant + * or symbol value prefaced by any unary operator + * ( +, -, ~, ', ", >, or < ). This routine is also + * responsible for setting the relocation type to symbol + * based (e.flag != 0) on global references. + * + * local variables: + * int c current character + * char id[] symbol name + * char * jp pointer to assembler-source text + * int n constant evaluation running sum + * int r current evaluation radix + * sym * sp pointer to a sym structure + * tsym * tp pointer to a tsym structure + * int v current digit evaluation + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * sym * symp pointer to a symbol structure + * + * functions called: + * VOID abscheck() asexpr.c + * int digit() asexpr.c + * VOID err() assubr.c + * VOID expr() asexpr.c + * int is_abs() asexpr.c + * int get() aslex.c + * VOID getid() aslex.c + * int getmap() aslex.c + * int getnb() aslex.c + * sym * lookup() assym.c + * VOID qerr() assubr.c + * VOID unget() aslex.c + * + * side effects: + * An arithmetic term is evaluated, a symbol structure + * may be created, term evaluation may be terminated + * by a 'q' error. + */ + +VOID +term(esp) +register struct expr *esp; +{ + register c, n; + register char *jp; + char id[NCPS]; + struct sym *sp; + struct tsym *tp; + int r, v; + + c = getnb(); + /* + * Discard the unary '+' at this point and + * also any reference to numerical arguments + * associated with the '#' prefix. + */ + while (c == '+' || c == '#') { c = getnb(); } + /* + * Evaluate all binary operators + * by recursively calling expr(). + */ + if (c == LFTERM) { + expr(esp, 0); + if (getnb() != RTTERM) + qerr(); + return; + } + if (c == '-') { + expr(esp, 100); + abscheck(esp); + esp->e_addr = -esp->e_addr; + return; + } + if (c == '~') { + expr(esp, 100); + abscheck(esp); + esp->e_addr = ~esp->e_addr; + return; + } + if (c == '\'') { + esp->e_mode = S_USER; + esp->e_addr = getmap(-1)&0377; + return; + } + if (c == '\"') { + esp->e_mode = S_USER; + if (hilo) { + esp->e_addr = (getmap(-1)&0377)<<8; + esp->e_addr |= (getmap(-1)&0377); + } else { + esp->e_addr = (getmap(-1)&0377); + esp->e_addr |= (getmap(-1)&0377)<<8; + } + return; + } + if (c == '>' || c == '<') { + expr(esp, 100); + if (is_abs (esp)) { + /* + * evaluate msb/lsb directly + */ + if (c == '>') + esp->e_addr >>= 8; + esp->e_addr &= 0377; + return; + } else { + /* + * let linker perform msb/lsb, lsb is default + */ + esp->e_rlcf |= R_BYT2; + if (c == '>') + esp->e_rlcf |= R_MSB; + return; + } + } + /* + * Evaluate digit sequences as local symbols + * if followed by a '$' or as constants. + */ + if (ctype[c] & DIGIT) { + esp->e_mode = S_USER; + jp = ip; + while (ctype[*jp] & RAD10) { + jp++; + } + if (*jp == '$') { + n = 0; + while ((v = digit(c, 10)) >= 0) { + n = 10*n + v; + c = get(); + } + tp = symp->s_tsym; + while (tp) { + if (n == tp->t_num) { + esp->e_base.e_ap = tp->t_area; + esp->e_addr = tp->t_addr; + return; + } + tp = tp->t_lnk; + } + err('u'); + return; + } + r = radix; + if (c == '0') { + c = get(); + switch (c) { + case 'b': + case 'B': + r = 2; + c = get(); + break; + case 'o': + case 'O': + case 'q': + case 'Q': + r = 8; + c = get(); + break; + case 'd': + case 'D': + r = 10; + c = get(); + break; + case 'h': + case 'H': + case 'x': + case 'X': + r = 16; + c = get(); + break; + default: + break; + } + } + n = 0; + while ((v = digit(c, r)) >= 0) { + n = r*n + v; + c = get(); + } + unget(c); + esp->e_addr = n; + return; + } + /* + * Evaluate '$' sequences as a temporary radix + * if followed by a '%', '&', '#', or '$'. + */ + if (c == '$') { + c = get(); + if (c == '%' || c == '&' || c == '#' || c == '$') { + switch (c) { + case '%': + r = 2; + break; + case '&': + r = 8; + break; + case '#': + r = 10; + break; + case '$': + r = 16; + break; + default: + break; + } + c = get(); + n = 0; + while ((v = digit(c, r)) >= 0) { + n = r*n + v; + c = get(); + } + unget(c); + esp->e_mode = S_USER; + esp->e_addr = n; + return; + } + unget(c); + c = '$'; + } + /* + * Evaluate symbols and labels + */ + if (ctype[c] & LETTER) { + esp->e_mode = S_USER; + getid(id, c); + sp = lookup(id); + if (sp->s_type == S_NEW) { + if (sp->s_flag&S_GBL) { + esp->e_flag = 1; + esp->e_base.e_sp = sp; + return; + } + err('u'); + } else { + esp->e_mode = sp->s_type; + esp->e_addr = sp->s_addr; + esp->e_base.e_ap = sp->s_area; + } + return; + } + /* + * Else not a term. + */ + qerr(); +} + +/*)Function int digit(c, r) + * + * int c digit character + * int r current radix + * + * The function digit() returns the value of c + * in the current radix r. If the c value is not + * a number of the current radix then a -1 is returned. + * + * local variables: + * none + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * none + * + * side effects: + * none + */ + +int +digit(c, r) +register c, r; +{ + if (r == 16) { + if (ctype[c] & RAD16) { + if (c >= 'A' && c <= 'F') + return (c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + return (c - '0'); + } + } else + if (r == 10) { + if (ctype[c] & RAD10) + return (c - '0'); + } else + if (r == 8) { + if (ctype[c] & RAD8) + return (c - '0'); + } else + if (r == 2) { + if (ctype[c] & RAD2) + return (c - '0'); + } + return (-1); +} + +/*)Function VOID abscheck(esp) + * + * expr * esp pointer to an expr structure + * + * The function abscheck() tests the evaluation of an + * expression to verify it is absolute. If the evaluation + * is relocatable then an 'r' error is noted and the expression + * made absolute. + * + * Note: The area type (i.e. ABS) is not checked because + * the linker can be told to explicitly relocate an + * absolute area. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * VOID rerr() assubr.c + * + * side effects: + * The expression may be changed to absolute and the + * 'r' error invoked. + */ + +VOID +abscheck(esp) +register struct expr *esp; +{ + if (esp->e_flag || esp->e_base.e_ap) { + esp->e_flag = 0; + esp->e_base.e_ap = NULL; + rerr(); + } +} + +/*)Function int is_abs(esp) + * + * expr * esp pointer to an expr structure + * + * The function is_abs() tests the evaluation of an + * expression to verify it is absolute. If the evaluation + * is absolute then 1 is returned, else 0 is returned. + * + * Note: The area type (i.e. ABS) is not checked because + * the linker can be told to explicitly relocate an + * absolute area. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +is_abs (esp) +register struct expr *esp; +{ + if (esp->e_flag || esp->e_base.e_ap) { + return(0); + } + return(1); +} + +/*)Function int oprio(c) + * + * int c operator character + * + * The function oprio() returns a relative priority + * for all valid unary and binary operators. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +oprio(c) +register c; +{ + if (c == '*' || c == '/' || c == '%') + return (10); + if (c == '+' || c == '-') + return (7); + if (c == '<' || c == '>') + return (5); + if (c == '^') + return (4); + if (c == '&') + return (3); + if (c == '|') + return (1); + return (0); +} + +/*)Function VOID clrexpr(esp) + * + * expr * esp pointer to expression structure + * + * The function clrexpr() clears the expression structure. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * expression structure cleared. + */ + +VOID +clrexpr(esp) +register struct expr *esp; +{ + esp->e_mode = 0; + esp->e_flag = 0; + esp->e_addr = 0; + esp->e_base.e_ap = NULL; + esp->e_rlcf = 0; +} diff --git a/as/z80/aslex.c b/as/z80/aslex.c new file mode 100644 index 00000000..3fadd787 --- /dev/null +++ b/as/z80/aslex.c @@ -0,0 +1,500 @@ +/* aslex.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber, M. Hope + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module aslex.c + * + * The module aslex.c includes the general lexical + * analysis routines for the assembler. + * + * aslex.c contains the following functions: + * char endline() + * char get() + * VOID getid(id,c) + * int getline() + * int getmap() + * char getnb() + * VOID getst() + * int more() + * VOID unget(c) + * + * aslex.c contains no local/static variables + */ + +/*)Function VOID getid(id,c) + * + * char * id a pointer to a string of + * maximum length NCPS + * int c mode flag + * >=0 this is first character to + * copy to the string buffer + * <0 skip white space, first + * character must be a LETTER + * + * The function getid() scans the current assembler-source text line + * from the current position copying the next LETTER | DIGIT string + * into the external string buffer (id). The string ends when a non + * LETTER or DIGIT character is found. The maximum number of + * characters copied is NCPS. If the input string is larger than + * NCPS characters then the string is truncated, if the input string + * is shorter than NCPS characters then the string is NULL filled. + * If the mode argument (c) is >=0 then (c) is the first character + * copied to the string buffer, if (c) is <0 then intervening white + * space (SPACES and TABS) are skipped and the first character found + * must be a LETTER else a 'q' error terminates the parse of this + * assembler-source text line. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() aslex.c + * char getnb() aslex.c + * VOID unget() aslex.c + * + * side effects: + * use of getnb(), get(), and unget() updates the + * global pointer ip, the position in the current + * assembler-source text line. + */ + +VOID +getid(id, c) +register c; +char *id; +{ + register char *p; + + if (c < 0) { + c = getnb(); + if ((ctype[c] & LETTER) == 0) + qerr(); + } + p = id; + do { + if (p < &id[NCPS]) + *p++ = c; + } while (ctype[c=get()] & (LETTER|DIGIT)); + unget(c); + while (p < &id[NCPS]) + *p++ = 0; +} + +/*)Function VOID getst(id,c) + * + * char * id a pointer to a string of + * maximum length NCPS + * int c mode flag + * >=0 this is first character to + * copy to the string buffer + * <0 skip white space, first + * character must be a LETTER + * + * The function getnbid() scans the current assembler-source text line + * from the current position copying the next character string into + * the external string buffer (id). The string ends when a SPACE or + * ILL character is found. The maximum number of + * characters copied is NCPS. If the input string is larger than + * NCPS characters then the string is truncated, if the input string + * is shorter than NCPS characters then the string is NULL filled. + * If the mode argument (c) is >=0 then (c) is the first character + * copied to the string buffer, if (c) is <0 then intervening white + * space (SPACES and TABS) are skipped and the first character found + * must be a LETTER else a 'q' error terminates the parse of this + * assembler-source text line. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() aslex.c + * char getnb() aslex.c + * VOID unget() aslex.c + * + * side effects: + * use of getnb(), get(), and unget() updates the + * global pointer ip, the position in the current + * assembler-source text line. + */ + +VOID +getst(id, c) +register c; +char *id; +{ + register char *p; + + if (c < 0) { + c = getnb(); + if ((ctype[c] & LETTER) == 0) + qerr(); + } + p = id; + do { + if (p < &id[NCPS]) + *p++ = c; + } while (ctype[c=get()] & ~(SPACE|ILL)); + unget(c); + while (p < &id[NCPS]) + *p++ = 0; +} + +/*)Function char getnb() + * + * The function getnb() scans the current assembler-source + * text line returning the first character not a SPACE or TAB. + * + * local variables: + * int c current character from + * assembler-source text line + * + * global variables: + * none + * + * called functions: + * char get() aslex.c + * + * side effects: + * use of get() updates the global pointer ip, the position + * in the current assembler-source text line + */ + +char +getnb() +{ + register c; + + while ((c=get()) == ' ' || c == '\t') + ; + return (c); +} + +/*)Function char get() + * + * The function get() returns the next character in the + * assembler-source text line, at the end of the line a + * NULL character is returned. + * + * local variables: + * int c current character from + * assembler-source text line + * + * global variables: + * char * ip pointer into the current + * assembler-source text line + * + * called functions: + * none + * + * side effects: + * updates ip to the next character position in the + * assembler-source text line. If ip is at the end of the + * line, ip is not updated. + */ + +char +get() +{ + register c; + + if ((c = *ip) != 0) + ++ip; + return (c); +} + +/*)Function VOID unget(c) + * + * int c value of last character read from + * assembler-source text line + * + * If (c) is not a NULL character then the global pointer ip + * is updated to point to the preceeding character in the + * assembler-source text line. + * + * NOTE: This function does not push the character (c) + * back into the assembler-source text line, only + * the pointer ip is changed. + * + * local variables: + * int c last character read from + * assembler-source text line + * + * global variables: + * char * ip position into the current + * assembler-source text line + * + * called functions: + * none + * + * side effects: + * ip decremented by 1 character position + */ + +VOID +unget(c) +{ + if (c) + if (ip != ib) + --ip; +} + +/*)Function int getmap(d) + * + * int d value to compare with the + * assembler-source text line character + * + * The function getmap() converts the 'C' style characters \b, \f, + * \n, \r, and \t to their equivalent ascii values and also + * converts 'C' style octal constants '\123' to their equivalent + * numeric values. If the first character is equivalent to (d) then + * a (-1) is returned, if the end of the line is detected then + * a 'q' error terminates the parse for this line, or if the first + * character is not a \ then the character value is returned. + * + * local variables: + * int c value of character from the + * assembler-source text line + * int n looping counter + * int v current value of numeric conversion + * + * global variables: + * none + * + * called functions: + * char get() aslex.c + * + * side effects: + * use of get() updates the global pointer ip the position + * in the current assembler-source text line + */ + +int +getmap(d) +{ + register c, n, v; + + if ((c=get()) == '\0') + qerr(); + if (c == d) + return (-1); + if (c == '\\') { + c = get(); + switch (c) { + + case 'b': + c = '\b'; + break; + + case 'f': + c = '\f'; + break; + + case 'n': + c = '\n'; + break; + + case 'r': + c = '\r'; + break; + + case 't': + c = '\t'; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + n = 0; + v = 0; + while (++n<=3 && c>='0' && c<='7') { + v = (v<<3) + c - '0'; + c = get(); + } + unget(c); + c = v; + break; + } + } + return (c); +} + +/*)Function int getline() + * + * The function getline() reads a line of assembler-source text + * from an assembly source text file or an include file. + * Lines of text are processed from assembler-source files until + * all files have been read. If an include file is opened then + * lines of text are read from the include file (or nested + * include file) until the end of the include file is found. + * The input text line is copied into the global string ib[] + * and converted to a NULL terminated string. The function + * getline() returns a (1) after succesfully reading a line + * or a (0) if all files have been read. + * + * local variables: + * int i string length + * + * global variables: + * char ib[] string buffer containing + * assembler-source text line + * char ifp[] array of file handles for + * include files + * int incfil index for ifp[] specifies + * active include file + * int incline[] array of include file + * line numbers + * char sfp[] array of file handles for + * assembler source files + * int cfile index for sfp[] specifies + * active source file + * int srcline[] array of source file + * line numbers + * int inpfil maximum input file index + * + * called functions: + * int fclose() c-library + * char * fgets() c-library + * int strlen() c-library + * + * side effects: + * include file will be closed at detection of end of file. + * the next sequential source file may be selected. + * the global file indexes incfil or cfile may be changed. + * The respective source line or include line counter + * will be updated. + */ + +int +getline() +{ +register i; + +loop: if (incfil >= 0) { + if (fgets(ib, sizeof ib, ifp[incfil]) == NULL) { +#ifdef SDK + fclose(ifp[incfil]); + ifp[incfil--] = NULL; +#else /* SDK */ + fclose(ifp[incfil--]); +#endif /* SDK */ + lop = NLPP; + goto loop; + } else { + ++incline[incfil]; + } + } else { + if (fgets(ib, sizeof ib, sfp[cfile]) == NULL) { + if (++cfile <= inpfil) { + srcline[cfile] = 0; + goto loop; + } + return (0); + } else { + ++srcline[cfile]; + } + } + i = strlen(ib) - 1; + if (ib[i] == '\n') + ib[i] = 0; + return (1); +} + +/*)Function int more() + * + * The function more() scans the assembler-source text line + * skipping white space (SPACES and TABS) and returns a (0) + * if the end of the line or a comment delimeter (;) is found, + * or a (1) if their are additional characters in the line. + * + * local variables: + * int c next character from the + * assembler-source text line + * + * global variables: + * none + * + * called functions: + * char getnb() aslex.c + * VOID unget() aslex.c + * + * side effects: + * use of getnb() and unget() updates the global pointer ip + * the position in the current assembler-source text line + */ + +int +more() +{ + register c; + + c = getnb(); + unget(c); + return( (c == '\0' || c == ';') ? 0 : 1 ); +} + +/*)Function char endline() + * + * The function endline() scans the assembler-source text line + * skipping white space (SPACES and TABS) and returns the next + * character or a (0) if the end of the line is found or a + * comment delimiter (;) is found. + * + * local variables: + * int c next character from the + * assembler-source text line + * + * global variables: + * none + * + * called functions: + * char getnb() aslex.c + * + * side effects: + * use of getnb() updates the global pointer ip the + * position in the current assembler-source text line + */ + +char +endline() +{ + register c; + + c = getnb(); + return( (c == '\0' || c == ';') ? 0 : c ); +} diff --git a/as/z80/aslist.c b/as/z80/aslist.c new file mode 100644 index 00000000..845f728d --- /dev/null +++ b/as/z80/aslist.c @@ -0,0 +1,804 @@ +/* aslist.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module aslist.c + * + * The module aslist.c contains all the functions used + * to generate the assembler list and symbol output files. + * + * aslist.c contains the following functions: + * VOID list() + * VOID list1() + * VOID list2() + * VOID slew() + * VOID lstsym() + * + * The module aslist.c contains no local/static variables + */ + +/*)Function VOID list() + * + * The function list() generates the listing output + * which includes the input source, line numbers, + * and generated code. Numerical output may be selected + * as hexadecimal, decimal, or octal. + * + * local variables: + * int * wp pointer to the assembled data bytes + * int * wpt pointer to the data byte mode + * int nb computed number of assembled bytes + * + * global variables: + * int cb[] array of assembler output values + * int cbt[] array of assembler relocation types + * describing the data in cb[] + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * char eb[] array of generated error codes + * char * ep pointer into error list + * array eb[] + * char ib[] assembler-source text line + * FILE * lfp list output file handle + * int line current assembler source line number + * int lmode listing mode + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * VOID list1() aslist.c + * int putc() c_library + * VOID slew() asslist.c + * + * side effects: + * Listing or symbol output updated. + */ + +#ifndef MLH_LST +VOID +list() +{ + register char *wp; + register int *wpt; + register nb; + + if (lfp == NULL || lmode == NLIST) + return; + + /* + * Get Correct Line Number + */ + if (incfil >= 0) { + line = incline[incfil]; + if (line == 0) { + if (incfil > 0) { + line = incline[incfil-1]; + } else { + line = srcline[cfile]; + } + } + } else { + line = srcline[cfile]; + } + + /* + * Move to next line. + */ + slew(lfp, pflag); + + /* + * Output a maximum of NERR error codes with listing. + */ + while (ep < &eb[NERR]) + *ep++ = ' '; + fprintf(lfp, "%.2s", eb); + + /* + * Source listing only option. + */ + if (lmode == SLIST) { + fprintf(lfp, "%24s%5u %s\n", "", line, ib); + return; + } +#ifndef SDK + if (lmode == ALIST) { + outchk(HUGE,HUGE); + } +#endif + + /* + * HEX output Option. + */ + if (xflag == 0) { /* HEX */ + /* + * Equate only + */ + if (lmode == ELIST) { + fprintf(lfp, "%18s%04X", "", laddr); + fprintf(lfp, " %5u %s\n", line, ib); + return; + } + + /* + * Address (with allocation) + */ + fprintf(lfp, " %04X", laddr); + if (lmode == ALIST || lmode == BLIST) { + fprintf(lfp, "%19s%5u %s\n", "", line, ib); +#ifndef SDK + outdot(); +#endif + return; + } + wp = cb; + wpt = cbt; + nb = (int) (cp - cb); + + /* + * First line of output for this source line with data. + */ + list1(wp, wpt, nb, 1); + fprintf(lfp, " %5u %s\n", line, ib); + + /* + * Subsequent lines of output if more data. + */ + while ((nb -= 6) > 0) { + wp += 6; + wpt += 6; + slew(lfp, 0); + fprintf(lfp, "%7s", ""); + list1(wp, wpt, nb, 0); + putc('\n', lfp); + } + } else + /* + * OCTAL output Option. + */ + if (xflag == 1) { /* OCTAL */ + /* + * Equate only + */ + if (lmode == ELIST) { + fprintf(lfp, "%16s%06o", "", laddr); + fprintf(lfp, " %5u %s\n", line, ib); + return; + } + + /* + * Address (with allocation) + */ + fprintf(lfp, " %06o", laddr); + if (lmode == ALIST || lmode == BLIST) { + fprintf(lfp, "%17s%5u %s\n", "", line, ib); +#ifndef SDK + outdot(); +#endif + return; + } + wp = cb; + wpt = cbt; + nb = (int) (cp - cb); + + /* + * First line of output for this source line with data. + */ + list1(wp, wpt, nb, 1); + fprintf(lfp, " %5u %s\n", line, ib); + + /* + * Subsequent lines of output if more data. + */ + while ((nb -= 4) > 0) { + wp += 4; + wpt += 4; + slew(lfp, 0); + fprintf(lfp, "%9s", ""); + list1(wp, wpt, nb, 0); + putc('\n', lfp); + } + } else + /* + * DECIMAL output Option. + */ + if (xflag == 2) { /* DECIMAL */ + /* + * Equate only + */ + if (lmode == ELIST) { + fprintf(lfp, "%16s%05u", "", laddr); + fprintf(lfp, " %5u %s\n", line, ib); + return; + } + + /* + * Address (with allocation) + */ + fprintf(lfp, " %05u", laddr); + if (lmode == ALIST || lmode == BLIST) { + fprintf(lfp, "%17s%5u %s\n", "", line, ib); +#ifndef SDK + outdot(); +#endif + return; + } + wp = cb; + wpt = cbt; + nb = (int) (cp - cb); + + /* + * First line of output for this source line with data. + */ + list1(wp, wpt, nb, 1); + fprintf(lfp, " %5u %s\n", line, ib); + + /* + * Subsequent lines of output if more data. + */ + while ((nb -= 4) > 0) { + wp += 4; + wpt += 4; + slew(lfp, 0); + fprintf(lfp, "%9s", ""); + list1(wp, wpt, nb, 0); + putc('\n', lfp); + } + } +} +#else +VOID +list() +{ + register char *wp; + register int *wpt; + register nb; + + if (lfp == NULL || lmode == NLIST) + return; + + /* + * Get Correct Line Number + */ + if (incfil >= 0) { + line = incline[incfil]; + if (line == 0) { + if (incfil > 0) { + line = incline[incfil-1]; + } else { + line = srcline[cfile]; + } + } + } else { + line = srcline[cfile]; + } + + /* + * HEX output Option. + */ + /* Output filename relative_address line_number */ + + if (incfil >= 0) { + fprintf(lfp, "%s ", incfn[incfil]); + } + else { + fprintf(lfp, "%s ", srcfn[cfile]); + } + fprintf(lfp, "%u %04X\n", line, laddr); +#if 0 + wp = cb; + wpt = cbt; + nb = (int) (cp - cb); + + /* + * First line of output for this source line with data. + */ + list1(wp, wpt, nb, 1); + fprintf(lfp, " %5u %s\n", line, ib); + + /* + * Subsequent lines of output if more data. + */ + while ((nb -= 6) > 0) { + wp += 6; + wpt += 6; + slew(lfp, 0); + fprintf(lfp, "%7s", ""); + list1(wp, wpt, nb, 0); + putc('\n', lfp); + } +#endif +} +#endif /* MLH_LST */ + +/*)Function VOID list1(wp, wpt, nw, f) + * + * int f fill blank fields (1) + * int nb number of data bytes + * int * wp pointer to data bytes + * int * wpt pointer to data byte mode + * + * local variables: + * int i loop counter + * + * global variables: + * int xflag -x, listing radix flag + * + * functions called: + * VOID list2() asslist.c + * int fprintf() c_library + * + * side effects: + * Data formatted and output to listing. + */ + +VOID +list1(wp, wpt, nb, f) +register char *wp; +register int *wpt, nb, f; +{ + register i; + + /* + * HEX output Option. + */ + if (xflag == 0) { /* HEX */ + /* + * Bound number of words to HEX maximum per line. + */ + if (nb > 6) + nb = 6; + + /* + * Output bytes. + */ + for (i=0; i 4) + nb = 4; + + /* + * Output bytes. + */ + for (i=0; i 4) + nb = 4; + + /* + * Output bytes. + */ + for (i=0; i= 2) { + if (t & R_RELOC) { + if (t & (R_PAG0|R_PAG)) { + c = '*'; + } else if (t & R_USGN) { + c = 'u'; + } else if (t & R_PCR) { + c = 'p'; + } else { + c = 'r'; + } + if (t & R_HIGH) c += 1; + } + } + + /* + * Output the selected mode. + */ + putc(c, lfp); +} + +/*)Function VOID slew(fp, flag) + * + * FILE * fp file handle for listing + * int flag enable pagination + * + * The function slew() increments the page line count. + * If the page overflows and pagination is enabled: + * 1) put out a page skip, + * 2) a title, + * 3) a subtitle, + * 4) and reset the line count. + * + * local variables: + * none + * + * global variables: + * char cpu[] cpu type string + * int lop current line number on page + * int page current page number + * char stb[] Subtitle string buffer + * char tb[] Title string buffer + * + * functions called: + * int fprintf() c_library + * + * side effects: + * Increments page line counter, on overflow + * a new page header is output to the listing file. + */ + +VOID +slew(fp,flag) +FILE *fp; +int flag; +{ + if ((lop++ >= NLPP) && flag) { + fprintf(fp, "\fASxxxx Assembler %s (%s), page %u.\n", + VERSION, cpu, ++page); + fprintf(fp, "%s\n", tb); + fprintf(fp, "%s\n\n", stb); + lop = 5; + } +} + +/*)Function VOID lstsym(fp) + * + * FILE * fp file handle for output + * + * The function lstsym() outputs alphabetically + * sorted symbol and area tables. + * + * local variables: + * int c temporary + * int i loop counter + * int j temporary + * int k temporary + * char * ptr pointer to an id string + * int nmsym number of symbols + * int narea number of areas + * sym * sp pointer to symbol structure + * sym ** p pointer to an array of + * pointers to symbol structures + * area * ap pointer to an area structure + * + * global variables: + * area * areap pointer to an area structure + * char aretbl[] string "Area Table" + * sym dot defined as sym[0] + * char stb[] Subtitle string buffer + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * char symtbl[] string "Symbol Table" + * FILE * tfp symbol table output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * int putc() c_library + * VOID slew() aslist.c + * int strcmp() c_library + * char * strcpy() c_library + * + * side effects: + * Symbol and area tables output. + */ + +VOID +lstsym(fp) +FILE *fp; +{ + register int c, i, j, k; + register char *ptr; + int nmsym, narea; + struct sym *sp; + struct sym **p; + struct area *ap; + + /* + * Symbol Table Header + */ + strcpy(stb, &symtbl[0]); + lop = NLPP; + if (fp == tfp) + page = 0; + slew(fp, 1); + + /* + * Find number of symbols + */ + nmsym = 0; + for (i=0; is_sp; + } + } + if (nmsym == 0) + goto atable; + + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ((p = (struct sym **) malloc(sizeof((struct sym *) sp)*nmsym)) + == NULL) { + fprintf(fp, "Insufficient space to build Symbol Table.\n"); + return; + } + nmsym = 0; + for (i=0; is_sp; + } + } + + /* + * Bubble Sort on Symbol Table Array + */ + j = 1; + c = nmsym - 1; + while (j) { + j = 0; + for (i=0; is_id[0],&p[i+1]->s_id[0]) > 0) { + j = 1; + sp = p[i+1]; + p[i+1] = p[i]; + p[i] = sp; + } + } + } + + /* + * Symbol Table Output + */ + for (i=0; is_area) { + j = sp->s_area->a_ref; + if (xflag == 0) { + fprintf(fp, " %2X ", j); + } else + if (xflag == 1) { + fprintf(fp, "%3o ", j); + } else + if (xflag == 2) { + fprintf(fp, "%3u ", j); + } + } else { + fprintf(fp, " "); + } + ptr = &sp->s_id[0]; + while (ptr < &sp->s_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, fp); + } else { + putc(' ', fp); + } + } + if (sp->s_flag & S_ASG) { + putc('=', fp); + } else { + putc(' ', fp); + } + if (sp->s_type == S_NEW) { + if (xflag == 0) { + fprintf(fp, " **** "); + } else + if (xflag == 1) { + fprintf(fp, "****** "); + } else + if (xflag == 2) { + fprintf(fp, " ***** "); + } + } else { + j = sp->s_addr; + if (xflag == 0) { + fprintf(fp, " %04X ", j); + } else + if (xflag == 1) { + fprintf(fp, "%06o ", j); + } else + if (xflag == 2) { + fprintf(fp, " %05u ", j); + } + } + j = 0; + if (sp->s_flag & S_GBL) { + putc('G', fp); + ++j; + } + if (sp->s_area != NULL) { + putc('R', fp); + ++j; + } + if (sp->s_type == S_NEW) { + putc('X', fp); + ++j; + } +#if NCPS-8 + putc('\n', fp); + slew(fp, 0); + ++i; +#else + if (++i % 3 == 0) { + putc('\n', fp); + slew(fp, pflag); + } else + if (i < nmsym) { + while (j++ < 4) + putc(' ', fp); + fprintf(fp, "| "); + } +#endif + } + putc('\n', fp); + + /* + * Area Table Header + */ + +atable: + strcpy(stb, &aretbl[0]); + lop = NLPP; + slew(fp, 1); + + /* + * Area Table Output + */ + narea = 0; + ap = areap; + while (ap) { + ++narea; + ap = ap->a_ap; + } + for (i=0; ia_ap; + j = ap->a_ref; + if (xflag == 0) { + fprintf(fp, " %2X ", j); + } else + if (xflag == 1) { + fprintf(fp, " %3o ", j); + } else + if (xflag == 2) { + fprintf(fp, " %3u ", j); + } + ptr = &ap->a_id[0]; + while (ptr < &ap->a_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, fp); + } else { + putc(' ', fp); + } + } + j = ap->a_size; + k = ap->a_flag; + if (xflag==0) { + fprintf(fp, " size %4X flags %X\n", j, k); + } else + if (xflag==1) { + fprintf(fp, " size %6o flags %o\n", j, k); + } else + if (xflag==2) { + fprintf(fp, " size %5u flags %u\n", j, k); + } + } +} diff --git a/as/z80/asm.h b/as/z80/asm.h new file mode 100644 index 00000000..00c33f3a --- /dev/null +++ b/as/z80/asm.h @@ -0,0 +1,599 @@ +/* asm.h */ + +/* + * (C) Copyright 1989-1996 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#define VERSION "V01.75" + +/* + * Case Sensitivity Flag + */ +#define CASE_SENSITIVE 0 + +/*)Module asm.h + * + * The module asm.h contains the definitions for constants, + * structures, global variables, and ASxxxx functions + * contained in the ASxxxx.c files. The two functions + * and three global variables from the machine dependent + * files are also defined. + */ + +/* + * compiler/operating system specific definitions + */ + +/* DECUS C void definition */ +/* File/extension seperator */ + +#ifdef decus +#define VOID char +#define FSEPX '.' +#endif + +/* PDOS C void definition */ +/* File/extension seperator */ + +#ifdef PDOS +#define VOID char +#define FSEPX ':' +#endif + +/* Default void definition */ +/* File/extension seperator */ + +#ifndef VOID +#define VOID void +#define FSEPX '.' +#define OTHERSYSTEM +#endif + +/* + * Assembler definitions. + */ +#define LFTERM '(' /* Left expression delimeter */ +#define RTTERM ')' /* Right expression delimeter */ + +#ifdef SDK +#define NCPS 32 /* characters per symbol */ +#else /* SDK */ +#define NCPS 8 /* Chars. per symbol */ +#endif /* SDK */ +/* #define NCPS 32 */ /* Chars. per symbol */ +#define HUGE 1000 /* A huge number */ +#define NERR 3 /* Errors per line */ +#define NINPUT 128 /* Input buffer size */ +#define NCODE 128 /* Listing code buffer size */ +#define NTITL 64 /* Title buffer size */ +#define NSBTL 64 /* SubTitle buffer size */ +#define NHASH 64 /* Buckets in hash table */ +#define HMASK 077 /* Hash mask */ +#define NLPP 60 /* Lines per page */ +#define MAXFIL 6 /* Maximum command line input files */ +#define MAXINC 6 /* Maximum nesting of include files */ +#define MAXIF 10 /* Maximum nesting of if/else/endif */ +#define FILSPC 80 /* Chars. in filespec */ + +#define NLIST 0 /* No listing */ +#define SLIST 1 /* Source only */ +#define ALIST 2 /* Address only */ +#define BLIST 3 /* Address only with allocation */ +#define CLIST 4 /* Code */ +#define ELIST 5 /* Equate only */ + +#define dot sym[0] /* Dot, current loc */ +#define dca area[0] /* Dca, default code area */ + + +typedef unsigned int addr_t; + +/* + * The area structure contains the parameter values for a + * specific program or data section. The area structure + * is a linked list of areas. The initial default area + * is "_CODE" defined in asdata.c, the next area structure + * will be linked to this structure through the structure + * element 'struct area *a_ap'. The structure contains the + * area name, area reference number ("_CODE" is 0) determined + * by the order of .area directives, area size determined + * from the total code and/or data in an area, area fuzz is + * a variable used to track pass to pass changes in the + * area size caused by variable length instruction formats, + * and area flags which specify the area's relocation type. + */ +struct area +{ + struct area *a_ap; /* Area link */ + char a_id[NCPS]; /* Area Name */ + int a_ref; /* Ref. number */ + addr_t a_size; /* Area size */ + addr_t a_fuzz; /* Area fuzz */ + int a_flag; /* Area flags */ +}; + +/* + * The "A_" area constants define values used in + * generating the assembler area output data. + * + * Area flags + * + * 7 6 5 4 3 2 1 0 + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * | | | | PAG | ABS | OVR | | | + * +-----+-----+-----+-----+-----+-----+-----+-----+ + */ + +#define A_CON 000 /* Concatenating */ +#define A_OVR 004 /* Overlaying */ +#define A_REL 000 /* Relocatable */ +#define A_ABS 010 /* absolute */ +#define A_NOPAG 000 /* Non-Paged */ +#define A_PAG 020 /* Paged */ + +/* + * The "R_" relocation constants define values used in + * generating the assembler relocation output data for + * areas, symbols, and code. + * + * Relocation flags + * + * 7 6 5 4 3 2 1 0 + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * | MSB | PAGn| PAG0| USGN| BYT2| PCR | SYM | BYT | + * +-----+-----+-----+-----+-----+-----+-----+-----+ + */ + +#define R_WORD 0000 /* 16 bit */ +#define R_BYTE 0001 /* 8 bit */ + +#define R_AREA 0000 /* Base type */ +#define R_SYM 0002 + +#define R_NORM 0000 /* PC adjust */ +#define R_PCR 0004 + +#define R_BYT1 0000 /* Byte count for R_BYTE = 1 */ +#define R_BYT2 0010 /* Byte count for R_BYTE = 2 */ + +#define R_SGND 0000 /* Signed Byte */ +#define R_USGN 0020 /* Unsigned Byte */ + +#define R_NOPAG 0000 /* Page Mode */ +#define R_PAG0 0040 /* Page '0' */ +#define R_PAG 0100 /* Page 'nnn' */ + +#define R_LSB 0000 /* low byte */ +#define R_MSB 0200 /* high byte */ + +/* + * Listing Control Flags + */ + +#define R_HIGH 0040000 /* High Byte */ +#define R_RELOC 0100000 /* Relocation */ + +#define R_DEF 00 /* Global def. */ +#define R_REF 01 /* Global ref. */ +#define R_REL 00 /* Relocatable */ +#define R_ABS 02 /* Absolute */ +#define R_GBL 00 /* Global */ +#define R_LCL 04 /* Local */ + +/* + * The mne structure is a linked list of the assembler + * mnemonics and directives. The list of mnemonics and + * directives contained in the device dependent file + * xxxpst.c are hashed and linked into NHASH lists in + * module assym.c by syminit(). The structure contains + * the mnemonic/directive name, a subtype which directs + * the evaluation of this mnemonic/directive, a flag which + * is used to detect the end of the mnemonic/directive + * list in xxxpst.c, and a value which is normally + * associated with the assembler mnemonic base instruction + * value. + */ +struct mne +{ + struct mne *m_mp; /* Hash link */ + char m_id[NCPS]; /* Mnemonic */ + char m_type; /* Mnemonic subtype */ + char m_flag; /* Mnemonic flags */ + addr_t m_valu; /* Value */ +}; + +/* + * The sym structure is a linked list of symbols defined + * in the assembler source files. The first symbol is "." + * defined in asdata.c. The entry 'struct tsym *s_tsym' + * links any temporary symbols following this symbol and + * preceeding the next normal symbol. The structure also + * contains the symbol's name, type (USER or NEW), flag + * (global, assigned, and multiply defined), a pointer + * to the area structure defining where the symbol is + * located, a reference number assigned by outgsd() in + * asout.c, and the symbols address relative to the base + * address of the area where the symbol is located. + */ +struct sym +{ + struct sym *s_sp; /* Hash link */ + struct tsym *s_tsym; /* Temporary symbol link */ + char s_id[NCPS]; /* Symbol */ + char s_type; /* Symbol subtype */ + char s_flag; /* Symbol flags */ + struct area *s_area; /* Area line, 0 if absolute */ + int s_ref; /* Ref. number */ + addr_t s_addr; /* Address */ +}; + +#define S_GBL 01 /* Global */ +#define S_ASG 02 /* Assigned */ +#define S_MDF 04 /* Mult. def */ +#define S_END 010 /* End mark for pst. */ + +#define S_NEW 0 /* New name */ +#define S_USER 1 /* User name */ + /* unused slot */ + /* unused slot */ + /* unused slot */ + +#define S_BYTE 5 /* .byte */ +#define S_WORD 6 /* .word */ +#define S_ASCII 7 /* .ascii */ +#define S_ASCIZ 8 /* .asciz */ +#define S_BLK 9 /* .blkb or .blkw */ +#define S_INCL 10 /* .include */ +#define S_DAREA 11 /* .area */ +#define S_ATYP 12 /* .area type */ +#define S_AREA 13 /* .area name */ +#define S_GLOBL 14 /* .globl */ +#define S_PAGE 15 /* .page */ +#define S_TITLE 16 /* .title */ +#define S_SBTL 17 /* .sbttl */ +#define S_IF 18 /* .if */ +#define S_ELSE 19 /* .else */ +#define S_ENDIF 20 /* .endif */ +#define S_EVEN 21 /* .even */ +#define S_ODD 22 /* .odd */ +#define S_RADIX 23 /* .radix */ +#define S_ORG 24 /* .org */ +#define S_MODUL 25 /* .module */ +#define S_ASCIS 26 /* .ascis */ +#ifdef SDK +# define S_FLOAT 27 /* .df */ +#endif + +/* + * The tsym structure is a linked list of temporary + * symbols defined in the assembler source files following + * a normal symbol. The structure contains the temporary + * symbols number, a flag (multiply defined), a pointer to the + * area structure defining where the temporary structure + * is located, and the temporary symbol's address relative + * to the base address of the area where the symbol + * is located. + */ +struct tsym +{ + struct tsym *t_lnk; /* Link to next */ + char t_num; /* 0-255$ */ + char t_flg; /* flags */ + struct area *t_area; /* Area */ + addr_t t_addr; /* Address */ +}; + +/* + * External Definitions for all Global Variables + */ + +extern int aserr; /* ASxxxx error counter + */ +extern jmp_buf jump_env; /* compiler dependent structure + * used by setjmp() and longjmp() + */ +extern int inpfil; /* count of assembler + * input files specified + */ +extern int incfil; /* current file handle index + * for include files + */ +extern int cfile; /* current file handle index + * of input assembly files + */ +extern int flevel; /* IF-ELSE-ENDIF flag will be non + * zero for false conditional case + */ +extern int tlevel; /* current conditional level + */ +extern int ifcnd[MAXIF+1]; /* array of IF statement condition + * values (0 = FALSE) indexed by tlevel + */ +extern int iflvl[MAXIF+1]; /* array of IF-ELSE-ENDIF flevel + * values indexed by tlevel + */ +extern char + afn[FILSPC]; /* afile() temporary filespec + */ +extern char + srcfn[MAXFIL][FILSPC]; /* array of source file names + */ +extern int + srcline[MAXFIL]; /* current source file line + */ +extern char + incfn[MAXINC][FILSPC]; /* array of include file names + */ +extern int + incline[MAXINC]; /* current include file line + */ +extern int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +extern int line; /* current assembler source + * line number + */ +extern int page; /* current page number + */ +extern int lop; /* current line number on page + */ +extern int pass; /* assembler pass number + */ +extern int lflag; /* -l, generate listing flag + */ +extern int gflag; /* -g, make undefined symbols global flag + */ +extern int aflag; /* -a, make all symbols global flag + */ +extern int oflag; /* -o, generate relocatable output flag + */ +extern int sflag; /* -s, generate symbol table flag + */ +extern int pflag; /* -p, enable listing pagination + */ +extern int xflag; /* -x, listing radix flag + */ +extern int fflag; /* -f(f), relocations flagged flag + */ +extern addr_t laddr; /* address of current assembler line + * or value of .if argument + */ +extern addr_t fuzz; /* tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + */ +extern int lmode; /* listing mode + */ +extern struct area area[]; /* array of 1 area + */ +extern struct area *areap; /* pointer to an area structure + */ +extern struct sym sym[]; /* array of 1 symbol + */ +extern struct sym *symp; /* pointer to a symbol structure + */ +extern struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ +extern struct mne *mnehash[NHASH]; /* array of pointers to NHASH + * linked mnemonic/directive lists + */ +extern char *ep; /* pointer into error list + * array eb[NERR] + */ +extern char eb[NERR]; /* array of generated error codes + */ +extern char *ip; /* pointer into the assembler-source + * text line in ib[] + */ +extern char ib[NINPUT]; /* assembler-source text line + */ +extern char *cp; /* pointer to assembler output + * array cb[] + */ +extern char cb[NCODE]; /* array of assembler output values + */ +extern int *cpt; /* pointer to assembler relocation type + * output array cbt[] + */ +extern int cbt[NCODE]; /* array of assembler relocation types + * describing the data in cb[] + */ +extern char tb[NTITL]; /* Title string buffer + */ +extern char stb[NSBTL]; /* Subtitle string buffer + */ +extern char symtbl[]; /* string "Symbol Table" + */ +extern char aretbl[]; /* string "Area Table" + */ +extern char module[NCPS]; /* module name string + */ +extern FILE *lfp; /* list output file handle + */ +extern FILE *ofp; /* relocation output file handle + */ +extern FILE *tfp; /* symbol table output file handle + */ +extern FILE *sfp[MAXFIL]; /* array of assembler-source file handles + */ +extern FILE *ifp[MAXINC]; /* array of include-file file handles + */ +extern char ctype[128]; /* array of character types, one per + * ASCII character + */ + +#if CASE_SENSITIVE +#else +extern char ccase[128]; /* an array of characters which + * perform the case translation function + */ +#endif + +/* + * Definitions for Character Types + */ +#define SPACE 0000 +#define ETC 0000 +#define LETTER 0001 +#define DIGIT 0002 +#define BINOP 0004 +#define RAD2 0010 +#define RAD8 0020 +#define RAD10 0040 +#define RAD16 0100 +#define ILL 0200 + +#define DGT2 DIGIT|RAD16|RAD10|RAD8|RAD2 +#define DGT8 DIGIT|RAD16|RAD10|RAD8 +#define DGT10 DIGIT|RAD16|RAD10 +#define LTR16 LETTER|RAD16 + +/* + * The exp structure is used to return the evaluation + * of an expression. The structure supports three valid + * cases: + * (1) The expression evaluates to a constant, + * mode = S_USER, flag = 0, addr contains the + * constant, and base = NULL. + * (2) The expression evaluates to a defined symbol + * plus or minus a constant, mode = S_USER, + * flag = 0, addr contains the constant, and + * base = pointer to area symbol. + * (3) The expression evaluates to a external + * global symbol plus or minus a constant, + * mode = S_NEW, flag = 1, addr contains the + * constant, and base = pointer to symbol. + */ +struct expr +{ + char e_mode; /* Address mode */ + char e_flag; /* Symbol flag */ + addr_t e_addr; /* Address */ + union { + struct area *e_ap; + struct sym *e_sp; + } e_base; /* Rel. base */ + char e_rlcf; /* Rel. flags */ +}; + +/* C Library functions */ +/* for reference only +extern VOID exit(); +extern int fclose(); +extern char * fgets(); +extern FILE * fopen(); +extern int fprintf(); +extern VOID longjmp(); +extern VOID * malloc(); +extern int printf(); +extern char putc(); +extern int rewind(); +extern int setjmp(); +extern int strcmp(); +extern char * strcpy(); +extern int strlen(); +extern char * strncpy(); +*/ + +/* Machine independent functions */ + +/* asmain.c */ +extern FILE * afile(); +extern VOID asexit(); +extern VOID asmbl(); +extern VOID main(); +extern VOID newdot(); +extern VOID phase(); +extern VOID usage(); + +/* aslex.c */ +extern char endline(); +extern char get(); +extern VOID getid(); +extern int getline(); +extern int getmap(); +extern char getnb(); +extern VOID getst(); +extern int more(); +extern VOID unget(); + +/* assym.c */ +extern struct area * alookup(); +extern struct mne * mlookup(); +extern int hash(); +extern struct sym * lookup(); +extern VOID * new(); +extern int symeq(); +extern VOID syminit(); +extern VOID symglob(); +extern VOID allglob(); + +/* assubr.c */ +extern VOID aerr(); +extern VOID diag(); +extern VOID err(); +extern char * geterr(); +extern VOID qerr(); +extern VOID rerr(); + +/* asexpr.c */ +extern VOID abscheck(); +extern addr_t absexpr(); +extern VOID clrexpr(); +extern int digit(); +extern int is_abs(); +extern VOID expr(); +extern int oprio(); +extern VOID term(); + +/* aslist.c */ +extern VOID list(); +extern VOID list1(); +extern VOID list2(); +extern VOID lstsym(); +extern VOID slew(); + +/* asout.c */ +extern int hibyte(); +extern int lobyte(); +extern VOID out(); +extern VOID outab(); +extern VOID outarea(); +extern VOID outaw(); +extern VOID outall(); +extern VOID outdot(); +extern VOID outbuf(); +extern VOID outchk(); +extern VOID outgsd(); +extern VOID outrb(); +extern VOID outrw(); +extern VOID outsym(); +extern VOID out_lb(); +extern VOID out_lw(); +extern VOID out_rw(); +extern VOID out_tw(); + + +/* Machine dependent variables */ + +extern char * cpu; +extern char * dsft; +extern int hilo; +extern struct mne mne[]; + +/* Machine dependent functions */ + +extern VOID machin(); +extern VOID minit(); + diff --git a/as/z80/asmain.c b/as/z80/asmain.c new file mode 100644 index 00000000..d407b3eb --- /dev/null +++ b/as/z80/asmain.c @@ -0,0 +1,1188 @@ +/* asmain.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include +#include +#ifdef SDK +#include +#include +#undef HUGE +#endif +#include "asm.h" + +/*)Module asmain.c + * + * The module asmain.c includes the command argument parser, + * the three pass sequencer, and the machine independent + * assembler parsing code. + * + * asmain.c contains the following functions: + * VOID main(argc, argv) + * VOID asexit() + * VOID asmbl() + * FILE * afile(fn, ft, wf) + * VOID newdot(nap) + * VOID phase(ap, a) + * VOID usage() + * + * asmain.c contains the array char *usetxt[] which + * references the usage text strings printed by usage(). + */ + +/*)Function VOID main(argc, argv) + * + * int argc argument count + * char * argv array of pointers to argument strings + * + * The function main() is the entry point to the assembler. + * The purpose of main() is to (1) parse the command line + * arguments for options and source file specifications and + * (2) to process the source files through the 3 pass assembler. + * Before each assembler pass various variables are initialized + * and source files are rewound to their beginning. During each + * assembler pass each assembler-source text line is processed. + * After each assembler pass the assembler information is flushed + * to any opened output files and the if-else-endif processing + * is checked for proper termination. + * + * The function main() is also responsible for opening all + * output files (REL, LST, and SYM), sequencing the global (-g) + * and all-global (-a) variable definitions, and dumping the + * REL file header information. + * + * local variables: + * char * p pointer to argument string + * int c character from argument string + * int i argument loop counter + * area * ap pointer to area structure + * + * global variables: + * int aflag -a, make all symbols global flag + * char afn[] afile() constructed filespec + * area * areap pointer to an area structure + * int cb[] array of assembler output values + * int cbt[] array of assembler relocation types + * describing the data in cb[] + * int cfile current file handle index + * of input assembly files + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * char eb[] array of generated error codes + * char * ep pointer into error list array eb[] + * int fflag -f(f), relocations flagged flag + * int flevel IF-ELSE-ENDIF flag will be non + * zero for false conditional case + * addr_t fuzz tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + * int gflag -g, make undefined symbols global flag + * char ib[] assembler-source text line + * int inpfil count of assembler + * input files specified + * int ifcnd[] array of IF statement condition + * values (0 = FALSE) indexed by tlevel + * int iflvl[] array of IF-ELSE-ENDIF flevel + * values indexed by tlevel + * int incfil current file handle index + * for include files + * char * ip pointer into the assembler-source + * text line in ib[] + * jmp_buf jump_env compiler dependent structure + * used by setjmp() and longjmp() + * int lflag -l, generate listing flag + * int line current assembler source + * line number + * int lop current line number on page + * int oflag -o, generate relocatable output flag + * int page current page number + * int pflag enable listing pagination + * int pass assembler pass number + * int radix current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + * int sflag -s, generate symbol table flag + * char srcfn[][] array of source file names + * int srcline[] current source file line + * char stb[] Subtitle string buffer + * sym * symp pointer to a symbol structure + * int tlevel current conditional level + * int xflag -x, listing radix flag + * FILE * lfp list output file handle + * FILE * ofp relocation output file handle + * FILE * tfp symbol table output file handle + * FILE * sfp[] array of assembler-source file handles + * + * called functions: + * FILE * afile() asmain.c + * VOID allglob() assym.c + * VOID asexit() asmain.c + * VOID diag() assubr.c + * VOID err() assubr.c + * int fprintf() c-library + * int getline() aslex.c + * VOID list() aslist.c + * VOID lstsym() aslist.c + * VOID minit() ___mch.c + * VOID newdot() asmain.c + * VOID outchk() asout.c + * VOID outgsd() asout.c + * int rewind() c-library + * int setjmp() c-library + * VOID symglob() assym.c + * VOID syminit() assym.c + * VOID usage() asmain.c + * + * side effects: + * Completion of main() completes the assembly process. + * REL, LST, and/or SYM files may be generated. + */ + +VOID +main(argc, argv) +char *argv[]; +{ + register char *p; + register c, i; + struct area *ap; + +#ifdef SDK + inpfil = -2; +#else /* SDK */ + fprintf(stdout, "\n"); + inpfil = -1; +#endif /* SDK */ + pflag = 1; + for (i=1; i= 0) + usage(); + ++p; + while ((c = *p++) != 0) + switch(c) { + + case 'a': + case 'A': + ++aflag; + break; + + case 'g': + case 'G': + ++gflag; + break; + + case 'l': + case 'L': + ++lflag; + break; + + case 'o': + case 'O': + ++oflag; + break; + + case 's': + case 'S': + ++sflag; + break; + + case 'p': + case 'P': + pflag = 0; + break; + + case 'x': + case 'X': + xflag = 0; + break; + + case 'q': + case 'Q': + xflag = 1; + break; + + case 'd': + case 'D': + xflag = 2; + break; + + case 'f': + case 'F': + ++fflag; + break; + + default: + usage(); + } + } else { +#ifdef SDK + if(inpfil != -2) { +#endif /* SDK */ + if (++inpfil == MAXFIL) { + fprintf(stderr, "too many input files\n"); + asexit(1); + } + sfp[inpfil] = afile(p, "", 0); + strcpy(srcfn[inpfil],afn); +#ifdef SDK + } else + inpfil++; + if (inpfil == -1) { + if (lflag) + lfp = afile(p, "lst", 1); + if (oflag) + ofp = afile(p, "", 1); + if (sflag) + tfp = afile(p, "sym", 1); + } +#else /* SDK */ + if (inpfil == 0) { + if (lflag) + lfp = afile(p, "LST", 1); + if (oflag) + ofp = afile(p, "REL", 1); + if (sflag) + tfp = afile(p, "SYM", 1); + } +#endif /* SDK */ + } + } + if (inpfil < 0) + usage(); + syminit(); + for (pass=0; pass<3; ++pass) { + if (gflag && pass == 1) + symglob(); + if (aflag && pass == 1) + allglob(); + if (oflag && pass == 2) + outgsd(); + flevel = 0; + tlevel = 0; + ifcnd[0] = 0; + iflvl[0] = 0; + radix = 10; + srcline[0] = 0; + page = 0; + stb[0] = 0; + lop = NLPP; + cfile = 0; + incfil = -1; + for (i = 0; i <= inpfil; i++) + rewind(sfp[i]); + ap = areap; + while (ap) { + ap->a_fuzz = 0; + ap->a_size = 0; + ap = ap->a_ap; + } + fuzz = 0; + dot.s_addr = 0; + dot.s_area = &dca; + symp = ˙ + minit(); + while (getline()) { + cp = cb; + cpt = cbt; + ep = eb; + ip = ib; + if (setjmp(jump_env) == 0) + asmbl(); + if (pass == 2) { + diag(); + list(); + } + } + newdot(dot.s_area); /* Flush area info */ + if (flevel || tlevel) + err('i'); + } + if (oflag) + outchk(HUGE, HUGE); /* Flush */ + if (sflag) { + lstsym(tfp); + } else + if (lflag) { + lstsym(lfp); + } + asexit(aserr); +} + +/*)Function VOID asexit(i) + * + * int i exit code + * + * The function asexit() explicitly closes all open + * files and then terminates the program. + * + * local variables: + * int j loop counter + * + * global variables: + * FILE * ifp[] array of include-file file handles + * FILE * lfp list output file handle + * FILE * ofp relocation output file handle + * FILE * tfp symbol table output file handle + * FILE * sfp[] array of assembler-source file handles + * + * functions called: + * int fclose() c-library + * VOID exit() c-library + * + * side effects: + * All files closed. Program terminates. + */ + +VOID +asexit(i) +int i; +{ + int j; + + if (lfp != NULL) fclose(lfp); + if (ofp != NULL) fclose(ofp); + if (tfp != NULL) fclose(tfp); + + for (j=0; j= 0) { + n = 10*n + d; + c = get(); + } + if (c != '$' || get() != ':') + qerr(); + tp = symp->s_tsym; + if (pass == 0) { + while (tp) { + if (n == tp->t_num) { + tp->t_flg |= S_MDF; + break; + } + tp = tp->t_lnk; + } + if (tp == NULL) { + tp=(struct tsym *) new (sizeof(struct tsym)); + tp->t_lnk = symp->s_tsym; + tp->t_num = n; + tp->t_flg = 0; + tp->t_area = dot.s_area; + tp->t_addr = dot.s_addr; + symp->s_tsym = tp; + } + } else { + while (tp) { + if (n == tp->t_num) { + break; + } + tp = tp->t_lnk; + } + if (tp) { + if (pass == 1) { + fuzz = tp->t_addr - dot.s_addr; + tp->t_area = dot.s_area; + tp->t_addr = dot.s_addr; + } else { + phase(tp->t_area, tp->t_addr); + if (tp->t_flg & S_MDF) + err('m'); + } + } else { + err('u'); + } + } + lmode = ALIST; + goto loop; + } + /* + * If the first character is a letter then assume a lable, + * symbol, assembler directive, or assembler mnemonic is + * being processed. + */ + if ((ctype[c] & LETTER) == 0) + if (flevel) { + return; + } else { + qerr(); + } + getid(id, c); + c = getnb(); + /* + * If the next character is a : then a label is being processed. + * A double :: defines a global label. If this is new label + * then create a symbol structure. + * pass 0: + * Flag multiply defined labels. + * pass 1: + * Load area, address, and fuzz values + * into structure symp. + * pass 2: + * Check for assembler phase error and + * multiply defined error. + */ + if (c == ':') { + if (flevel) + return; + if ((c = get()) != ':') { + unget(c); + c = 0; + } + symp = lookup(id); + if (symp == &dot) + err('.'); + if (pass == 0) + if ((symp->s_type != S_NEW) && + ((symp->s_flag & S_ASG) == 0)) + symp->s_flag |= S_MDF; + if (pass != 2) { + fuzz = symp->s_addr - dot.s_addr; + symp->s_type = S_USER; + symp->s_area = dot.s_area; + symp->s_addr = dot.s_addr; + } else { + if (symp->s_flag & S_MDF) + err('m'); + phase(symp->s_area, symp->s_addr); + } + if (c) { + symp->s_flag |= S_GBL; + } + lmode = ALIST; + goto loop; + } + /* + * If the next character is a = then an equate is being processed. + * A double == defines a global equate. If this is new variable + * then create a symbol structure. + */ + if (c == '=') { + if (flevel) + return; + if ((c = get()) != '=') { + unget(c); + c = 0; + } + clrexpr(&e1); + expr(&e1, 0); + sp = lookup(id); + if (sp == &dot) { + outall(); + if (e1.e_flag || e1.e_base.e_ap != dot.s_area) + err('.'); + } else + if (sp->s_type != S_NEW && (sp->s_flag & S_ASG) == 0) { + err('m'); + } + sp->s_type = S_USER; + sp->s_area = e1.e_base.e_ap; + sp->s_addr = laddr = e1.e_addr; + sp->s_flag |= S_ASG; + if (c) { + sp->s_flag |= S_GBL; + } + lmode = ELIST; + goto loop; + } + unget(c); + lmode = flevel ? SLIST : CLIST; + if ((mp = mlookup(id)) == NULL) { + if (!flevel) + err('o'); + return; + } + /* + * If we have gotten this far then we have found an + * assembler directive or an assembler mnemonic. + * + * Check for .if, .else, .endif, and .page directives + * which are not controlled by the conditional flags + */ + switch (mp->m_type) { + + case S_IF: + n = absexpr(); + if (tlevel < MAXIF) { + ++tlevel; + ifcnd[tlevel] = n; + iflvl[tlevel] = flevel; + if (n == 0) { + ++flevel; + } + } else { + err('i'); + } + lmode = ELIST; + laddr = n; + return; + + case S_ELSE: + if (ifcnd[tlevel]) { + if (++flevel > (iflvl[tlevel]+1)) { + err('i'); + } + } else { + if (--flevel < iflvl[tlevel]) { + err('i'); + } + } + lmode = SLIST; + return; + + case S_ENDIF: + if (tlevel) { + flevel = iflvl[tlevel--]; + } else { + err('i'); + } + lmode = SLIST; + return; + + case S_PAGE: + lop = NLPP; + lmode = NLIST; + return; + + default: + break; + } + if (flevel) + return; + /* + * If we are not in a false state for .if/.else then + * process the assembler directives here. + */ + switch (mp->m_type) { + + case S_EVEN: + outall(); + laddr = dot.s_addr = (dot.s_addr + 1) & ~1; + lmode = ALIST; + break; + + case S_ODD: + outall(); + laddr = dot.s_addr |= 1; + lmode = ALIST; + break; + + case S_BYTE: + case S_WORD: + do { + clrexpr(&e1); + expr(&e1, 0); + if (mp->m_type == S_BYTE) { + outrb(&e1, R_NORM); + } else { + outrw(&e1, R_NORM); + } + } while ((c = getnb()) == ','); + unget(c); + break; + +#ifdef SDK + case S_FLOAT: + do { + getid( readbuffer, ' ' ); /* Hack :) */ + if ((c=getnb())=='.') + { + getid(&readbuffer[strlen(readbuffer)],'.'); + } + else + unget(c); + + f1 = strtod( readbuffer, (char **)NULL ); + /* Convert f1 to a gb-lib type fp + * 24 bit mantissa followed by 7 bit exp and 1 bit sign + */ + + if (f1!=0) + { + + f2 = floor(log(fabs(f1))/log(2))+1; + mantissa = (0x1000000*fabs(f1))/exp(f2*log(2)); + mantissa &=0xffffff; + exponent = f2 + 0x40; + if (f1<0) + exponent |=0x80; + } + + else + { + mantissa=0; + exponent=0; + } + + outab(mantissa&0xff); + outab((mantissa>>8)&0xff); + outab((mantissa>>16)&0xff); + outab(exponent&0xff); + + } while ((c = getnb()) == ','); + unget(c); + break; +#endif + + case S_ASCII: + case S_ASCIZ: + if ((d = getnb()) == '\0') + qerr(); + while ((c = getmap(d)) >= 0) + outab(c); + if (mp->m_type == S_ASCIZ) + outab(0); + break; + + case S_ASCIS: + if ((d = getnb()) == '\0') + qerr(); + c = getmap(d); + while (c >= 0) { + if ((n = getmap(d)) >= 0) { + outab(c); + } else { + outab(c | 0x80); + } + c = n; + } + break; + + case S_BLK: + clrexpr(&e1); + expr(&e1, 0); + dot.s_addr += e1.e_addr*mp->m_valu; + outchk(HUGE,HUGE); + lmode = BLIST; + break; + + case S_TITLE: + p = tb; + if ((c = getnb()) != 0) { + do { + if (p < &tb[NTITL-1]) + *p++ = c; + } while ((c = get()) != 0); + } + *p = 0; + unget(c); + lmode = SLIST; + break; + + case S_SBTL: + p = stb; + if ((c = getnb()) != 0) { + do { + if (p < &stb[NSBTL-1]) + *p++ = c; + } while ((c = get()) != 0); + } + *p = 0; + unget(c); + lmode = SLIST; + break; + + case S_MODUL: + getst(id, -1); + if (pass == 0) { + if (module[0]) { + err('m'); + } else { + strncpy(module, id, NCPS); + } + } + lmode = SLIST; + break; + + case S_GLOBL: + do { + getid(id, -1); + sp = lookup(id); + sp->s_flag |= S_GBL; + } while ((c = getnb()) == ','); + unget(c); + lmode = SLIST; + break; + + case S_DAREA: + getid(id, -1); + uaf = 0; + uf = A_CON|A_REL; + if ((c = getnb()) == '(') { + do { + getid(opt, -1); + mp = mlookup(opt); + if (mp && mp->m_type == S_ATYP) { + ++uaf; + uf |= mp->m_valu; + } else { + err('u'); + } + } while ((c = getnb()) == ','); + if (c != ')') + qerr(); + } else { + unget(c); + } + if ((ap = alookup(id)) != NULL) { + if (uaf && uf != ap->a_flag) + err('m'); + } else { + ap = (struct area *) new (sizeof(struct area)); + ap->a_ap = areap; + strncpy(ap->a_id, id, NCPS); + ap->a_ref = areap->a_ref + 1; + ap->a_size = 0; + ap->a_fuzz = 0; + ap->a_flag = uaf ? uf : (A_CON|A_REL); + areap = ap; + } + newdot(ap); + lmode = SLIST; + break; + + case S_ORG: + if (dot.s_area->a_flag & A_ABS) { + outall(); + laddr = dot.s_addr = absexpr(); + } else { + err('o'); + } + outall(); + lmode = ALIST; + break; + + case S_RADIX: + if (more()) { + switch (getnb()) { + case 'b': + case 'B': + radix = 2; + break; + case '@': + case 'o': + case 'O': + case 'q': + case 'Q': + radix = 8; + break; + case 'd': + case 'D': + radix = 10; + break; + case 'h': + case 'H': + case 'x': + case 'X': + radix = 16; + break; + default: + radix = 10; + qerr(); + break; + } + } else { + radix = 10; + } + lmode = SLIST; + break; + + case S_INCL: + d = getnb(); + p = fn; + while ((c = get()) != d) { + if (p < &fn[FILSPC-1]) { + *p++ = c; + } else { + break; + } + } + *p = 0; + if (++incfil == MAXINC || + (ifp[incfil] = fopen(fn, "r")) == NULL) { + --incfil; + err('i'); + } else { + lop = NLPP; + incline[incfil] = 0; + strcpy(incfn[incfil],fn); + } + lmode = SLIST; + break; + + /* + * If not an assembler directive then go to + * the machine dependent function which handles + * all the assembler mnemonics. + */ + default: + machine(mp); + } + goto loop; +} + +/*)Function FILE * afile(fn, ft, wf) + * + * char * fn file specification string + * char * ft file type string + * int wf read(0)/write(1) flag + * + * The function afile() opens a file for reading or writing. + * (1) If the file type specification string ft + * is not NULL then a file specification is + * constructed with the file path\name in fn + * and the extension in ft. + * (2) If the file type specification string ft + * is NULL then the file specification is + * constructed from fn. If fn does not have + * a file type then the default source file + * type dsft is appended to the file specification. + * + * afile() returns a file handle for the opened file or aborts + * the assembler on an open error. + * + * local variables: + * int c character value + * FILE * fp filehandle for opened file + * char * p1 pointer to filespec string fn + * char * p2 pointer to filespec string fb + * char * p3 pointer to filetype string ft + * + * global variables: + * char afn[] afile() constructed filespec + * char dsft[] default assembler file type string + * char afn[] constructed file specification string + * + * functions called: + * VOID asexit() asmain.c + * FILE * fopen() c_library + * int fprintf() c_library + * + * side effects: + * File is opened for read or write. + */ + +FILE * +afile(fn, ft, wf) +char *fn; +char *ft; +int wf; +{ + register char *p1, *p2, *p3; + register c; + FILE *fp; + + p1 = fn; + p2 = afn; + p3 = ft; + while ((c = *p1++) != 0 && c != FSEPX) { + if (p2 < &afn[FILSPC-4]) + *p2++ = c; + } + *p2++ = FSEPX; + if (*p3 == 0) { + if (c == FSEPX) { + p3 = p1; + } else { + p3 = dsft; + } + } + while ((c = *p3++) != 0) { + if (p2 < &afn[FILSPC-1]) + *p2++ = c; + } + *p2++ = 0; + if ((fp = fopen(afn, wf?"w":"r")) == NULL) { + fprintf(stderr, "%s: cannot %s.\n", afn, wf?"create":"open"); + asexit(1); + } + return (fp); +} + +/*)Function VOID newdot(nap) + * + * area * nap pointer to the new area structure + * + * The function newdot(): + * (1) copies the current values of fuzz and the last + * address into the current area referenced by dot + * (2) loads dot with the pointer to the new area and + * loads the fuzz and last address parameters + * (3) outall() is called to flush any remaining + * bufferred code from the old area to the output + * + * local variables: + * area * oap pointer to old area + * + * global variables: + * sym dot defined as sym[0] + * addr_t fuzz tracks pass to pass changes in the + * address of symbols caused by + * variable length instruction formats + * + * functions called: + * none + * + * side effects: + * Current area saved, new area loaded, buffers flushed. + */ + +VOID +newdot(nap) +register struct area *nap; +{ + register struct area *oap; + + oap = dot.s_area; + oap->a_fuzz = fuzz; + oap->a_size = dot.s_addr; + fuzz = nap->a_fuzz; + dot.s_area = nap; + dot.s_addr = nap->a_size; + outall(); +} + +/*)Function VOID phase(ap, a) + * + * area * ap pointer to area + * addr_t a address in area + * + * Function phase() compares the area ap and address a + * with the current area dot.s_area and address dot.s_addr + * to determine if the position of the symbol has changed + * between assembler passes. + * + * local variables: + * none + * + * global varaibles: + * sym * dot defined as sym[0] + * + * functions called: + * none + * + * side effects: + * The p error is invoked if the area and/or address + * has changed. + */ + +VOID +phase(ap, a) +struct area *ap; +addr_t a; +{ + if (ap != dot.s_area || a != dot.s_addr) + err('p'); +} + +char *usetxt[] = { +#ifdef SDK + "Usage: [-dqxgalopsf] outfile file1 [file2 file3 ...]", +#else /* SDK */ + "Usage: [-dqxgalopsf] file1 [file2 file3 ...]", +#endif /* SDK */ + " d decimal listing", + " q octal listing", + " x hex listing (default)", + " g undefined symbols made global", + " a all user symbols made global", +#ifdef SDK + " l create list output outfile[LST]", + " o create object output outfile[o]", + " s create symbol output outfile[SYM]", +#else /* SDK */ + " l create list output file1[LST]", + " o create object output file1[REL]", + " s create symbol output file1[SYM]", +#endif /* SDK */ + " p disable listing pagination", + " f flag relocatable references by ` in listing file", + " ff flag relocatable references by mode in listing file", + "", + 0 +}; + +/*)Function VOID usage() + * + * The function usage() outputs to the stderr device the + * assembler name and version and a list of valid assembler options. + * + * local variables: + * char ** dp pointer to an array of + * text string pointers. + * + * global variables: + * char cpu[] assembler type string + * char * usetxt[] array of string pointers + * + * functions called: + * VOID asexit() asmain.c + * int fprintf() c_library + * + * side effects: + * program is terminated + */ + +VOID +usage() +{ + register char **dp; + + fprintf(stderr, "\nASxxxx Assembler %s (%s)\n\n", VERSION, cpu); + for (dp = usetxt; *dp; dp++) + fprintf(stderr, "%s\n", *dp); + asexit(1); +} diff --git a/as/z80/asout.c b/as/z80/asout.c new file mode 100644 index 00000000..eaf066fc --- /dev/null +++ b/as/z80/asout.c @@ -0,0 +1,1085 @@ +/* asout.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include +#include "asm.h" + + +/*)Module asout.c + * + * The module asout.c contains all the functions used to + * generate the .REL assembler output file. + * + * + * The assemblers' output object file is an ascii file containing + * the information needed by the linker to bind multiple object + * modules into a complete loadable memory image. + * + * The object module contains the following designators: + * + * [XDQ][HL] + * X Hexidecimal radix + * D Decimal radix + * Q Octal radix + * + * H Most significant byte first + * L Least significant byte first + * + * H Header + * M Module + * A Area + * S Symbol + * T Object code + * R Relocation information + * P Paging information + * + * + * (1) Radix Line + * + * The first line of an object module contains the [XDQ][HL] + * format specifier (i.e. XH indicates a hexidecimal file with + * most significant byte first) for the following designators. + * + * + * (2) Header Line + * + * H aa areas gg global symbols + * + * The header line specifies the number of areas(aa) and the + * number of global symbols(gg) defined or referenced in this ob- + * ject module segment. + * + * + * (3) Module Line + * + * M name + * + * The module line specifies the module name from which this + * header segment was assembled. The module line will not appear + * if the .module directive was not used in the source program. + * + * + * (4) Symbol Line + * + * S string Defnnnn + * + * or + * + * S string Refnnnn + * + * The symbol line defines (Def) or references (Ref) the symbol + * 'string' with the value nnnn. The defined value is relative to + * the current area base address. References to constants and ex- + * ternal global symbols will always appear before the first area + * definition. References to external symbols will have a value of + * zero. + * + * + * (5) Area Line + * + * A label size ss flags ff + * + * The area line defines the area label, the size (ss) of the + * area in bytes, and the area flags (ff). The area flags specify + * the ABS, REL, CON, OVR, and PAG parameters: + * + * OVR/CON (0x04/0x00 i.e. bit position 2) + * + * ABS/REL (0x08/0x00 i.e. bit position 3) + * + * PAG (0x10 i.e. bit position 4) + * + * + * (6) T Line + * + * T xx xx nn nn nn nn nn ... + * + * The T line contains the assembled code output by the assem- + * bler with xx xx being the offset address from the current area + * base address and nn being the assembled instructions and data in + * byte format. + * + * + * (7) R Line + * + * R 0 0 nn nn n1 n2 xx xx ... + * + * The R line provides the relocation information to the linker. + * The nn nn value is the current area index, i.e. which area the + * current values were assembled. Relocation information is en- + * coded in groups of 4 bytes: + * + * 1. n1 is the relocation mode and object format + * 1. bit 0 word(0x00)/byte(0x01) + * 2. bit 1 relocatable area(0x00)/symbol(0x02) + * 3. bit 2 normal(0x00)/PC relative(0x04) relocation + * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for + * byte data + * 5. bit 4 signed(0x00)/unsigned(0x10) byte data + * 6. bit 5 normal(0x00)/page '0'(0x20) reference + * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference + * 8. bit 7 normal(0x00)/MSB of value + * + * 2. n2 is a byte index into the corresponding (i.e. pre- + * ceeding) T line data (i.e. a pointer to the data to be + * updated by the relocation). The T line data may be + * 1-byte or 2-byte byte data format or 2-byte word + * format. + * + * 3. xx xx is the area/symbol index for the area/symbol be- + * ing referenced. the corresponding area/symbol is found + * in the header area/symbol lists. + * + * + * The groups of 4 bytes are repeated for each item requiring relo- + * cation in the preceeding T line. + * + * + * (8) P Line + * + * P 0 0 nn nn n1 n2 xx xx + * + * The P line provides the paging information to the linker as + * specified by a .setdp directive. The format of the relocation + * information is identical to that of the R line. The correspond- + * ing T line has the following information: + * T xx xx aa aa bb bb + * + * Where aa aa is the area reference number which specifies the + * selected page area and bb bb is the base address of the page. + * bb bb will require relocation processing if the 'n1 n2 xx xx' is + * specified in the P line. The linker will verify that the base + * address is on a 256 byte boundary and that the page length of an + * area defined with the PAG type is not larger than 256 bytes. + * + * The linker defaults any direct page references to the first + * area defined in the input REL file. All ASxxxx assemblers will + * specify the _CODE area first, making this the default page area. + * + * + * asout.c contains the following functions: + * int lobyte() + * int hibyte() + * VOID out() + * VOID outab() + * VOID outall() + * VOID outarea() + * VOID outaw() + * VOID outbuf() + * VOID outchk() + * VOID outdot() + * VOID outdp() + * VOID outgsd() + * VOID outrb() + * VOID outrw() + * VOID outsym() + * VOID out_lb() + * VOID out_lw() + * VOID out_rw() + * VOID out_tw() + * + * The module asout.c contains the following local variables: + * int rel[] relocation data for code/data array + * int * relp pointer to rel array + * int txt[] assembled code/data array + * int * txtp pointer to txt array + */ + +#define NTXT 16 +#define NREL 16 + +char txt[NTXT]; +char rel[NREL]; + +char *txtp = { &txt[0] }; +char *relp = { &rel[0] }; + +/*)Function VOID outab(b) + * + * int b assembler data word + * + * The function outab() processes a single word of + * assembled data in absolute format. + * + * local variables: + * int * txtp pointer to data word + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outchk() asout.c + * VOID out_lb() asout.c + * + * side effects: + * The current assembly address is incremented by 1. + */ + +VOID +outab(b) +{ + if (pass == 2) { + out_lb(b,0); + if (oflag) { + outchk(1, 0); + *txtp++ = lobyte(b); + } + } + ++dot.s_addr; +} + +/*)Function VOID outaw(w) + * + * int w assembler data word + * + * The function outaw() processes a single word of + * assembled data in absolute format. + * + * local variables: + * int * txtp pointer to data word + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outchk() asout.c + * VOID out_lw() asout.c + * + * side effects: + * The current assembly address is incremented by 2. + */ + +VOID +outaw(w) +{ + if (pass == 2) { + out_lw(w,0); + if (oflag) { + outchk(2, 0); + out_tw(w); + } + } + dot.s_addr += 2; +} + +/*)Function VOID outrb(esp, r) + * + * expr * esp pointer to expr structure + * int r relocation mode + * + * The function outrb() processes a byte of generated code + * in either absolute or relocatable format dependent upon + * the data contained in the expr structure esp. If the + * .REL output is enabled then the appropriate information + * is loaded into the txt and rel buffers. + * + * local variables: + * int n symbol/area reference number + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID aerr() assubr.c + * VOID outchk() asout.c + * VOID out_lb() asout.c + * VOID out_rb() asout.c + * VOID out_tb() asout.c + * + * side effects: + * The current assembly address is incremented by 1. + */ + +VOID +outrb(esp, r) +register struct expr *esp; +int r; +{ + register n; + + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + out_lb(lobyte(esp->e_addr),0); + if (oflag) { + outchk(1, 0); + *txtp++ = lobyte(esp->e_addr); + } + } else { + r |= R_BYTE | R_BYT2 | esp->e_rlcf; + if (r & R_MSB) { + out_lb(hibyte(esp->e_addr),r|R_RELOC|R_HIGH); + } else { + out_lb(lobyte(esp->e_addr),r|R_RELOC); + } + if (oflag) { + outchk(2, 4); + out_tw(esp->e_addr); + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + *relp++ = r; + *relp++ = txtp - txt - 2; + out_rw(n); + } + } + } + ++dot.s_addr; +} + +/*)Function VOID outrw(esp, r) + * + * expr * esp pointer to expr structure + * int r relocation mode + * + * The function outrw() processes a word of generated code + * in either absolute or relocatable format dependent upon + * the data contained in the expr structure esp. If the + * .REL output is enabled then the appropriate information + * is loaded into the txt and rel buffers. + * + * local variables: + * int n symbol/area reference number + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID aerr() assubr.c + * VOID outchk() asout.c + * VOID out_lw() asout.c + * VOID out_rw() asout.c + * VOID out_tw() asout.c + * + * side effects: + * The current assembly address is incremented by 2. + */ + +VOID +outrw(esp, r) +register struct expr *esp; +int r; +{ + register n; + + if (pass == 2) { + if (esp->e_flag==0 && esp->e_base.e_ap==NULL) { + out_lw(esp->e_addr,0); + if (oflag) { + outchk(2, 0); + out_tw(esp->e_addr); + } + } else { + r |= R_WORD | esp->e_rlcf; + if (r & R_BYT2) { + rerr(); + if (r & R_MSB) { + out_lw(hibyte(esp->e_addr),r|R_RELOC); + } else { + out_lw(lobyte(esp->e_addr),r|R_RELOC); + } + } else { + out_lw(esp->e_addr,r|R_RELOC); + } + if (oflag) { + outchk(2, 4); + out_tw(esp->e_addr); + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + *relp++ = r; + *relp++ = txtp - txt - 2; + out_rw(n); + } + } + } + dot.s_addr += 2; +} + +/*)Function VOID outdp(carea, esp) + * + * area * carea pointer to current area strcuture + * expr * esp pointer to expr structure + * + * The function outdp() flushes the output buffer and + * outputs paging information to the .REL file. + * + * local variables: + * int n symbol/area reference number + * int r relocation mode + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outbuf() asout.c + * VOID outchk() asout.c + * VOID out_rw() asout.c + * VOID out_tw() asout.c + * + * side effects: + * Output buffer flushed to .REL fiel. + * Paging information dumped to .REL file. + */ + +VOID +outdp(carea, esp) +register struct area *carea; +register struct expr *esp; +{ + register n, r; + + if (oflag && pass==2) { + outchk(HUGE,HUGE); + out_tw(carea->a_ref); + out_tw(esp->e_addr); + if (esp->e_flag || esp->e_base.e_ap!=NULL) { + r = R_WORD; + if (esp->e_flag) { + n = esp->e_base.e_sp->s_ref; + r |= R_SYM; + } else { + n = esp->e_base.e_ap->a_ref; + } + *relp++ = r; + *relp++ = txtp - txt - 2; + out_rw(n); + } + outbuf("P"); + } +} + +/*)Function VOID outall() + * + * The function outall() will output any bufferred assembled + * data and relocation information (during pass 2 if the .REL + * output has been enabled). + * + * local variables: + * none + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * VOID outbuf() asout.c + * + * side effects: + * assembled data and relocation buffers will be cleared. + */ + +VOID +outall() +{ + if (oflag && pass==2) + outbuf("R"); +} + +/*)Function VOID outdot() + * + * The function outdot() outputs information about the + * current program counter value (during pass 2 if the .REL + * output has been enabled). + * + * local variables: + * none + * + * global variables: + * int oflag -o, generate relocatable output flag + * int pass assembler pass number + * + * functions called: + * int fprintf() c_library + * VOID out() asout.c + * + * side effects: + * assembled data and relocation buffers will be cleared. + */ + +VOID +outdot() +{ + if (oflag && pass==2) { + fprintf(ofp, "T"); + out(txt,(int) (txtp-txt)); + fprintf(ofp, "\n"); + fprintf(ofp, "R"); + out(rel,(int) (relp-rel)); + fprintf(ofp, "\n"); + txtp = txt; + relp = rel; + } +} + +/*)Function outchk(nt, nr) + * + * int nr number of additional relocation words + * int nt number of additional data words + * + * The function outchk() checks the data and relocation buffers + * for space to insert the nt data words and nr relocation words. + * If space is not available then output the current data and + * initialize the data buffers to receive the new data. + * + * local variables: + * area * ap pointer to an area structure + * int * relp pointer to rel array + * int * txtp pointer to txt array + * + * global variables: + * sym dot defined as sym[0] + * + * functions called: + * VOID outbuf() asout.c + * + * side effects: + * Data and relocation buffers may be emptied and initialized. + */ + +VOID +outchk(nt, nr) +{ + register struct area *ap; + + if (txtp+nt > &txt[NTXT] || relp+nr > &rel[NREL]) { + outbuf("R"); + } + if (txtp == txt) { + out_tw(dot.s_addr); + if ((ap = dot.s_area) != NULL) { + *relp++ = R_WORD|R_AREA; + *relp++ = 0; + out_rw(ap->a_ref); + } + } +} + +/*)Function VOID outbuf() + * + * The function outbuf() will output any bufferred data + * and relocation information to the .REL file. The output + * buffer pointers and counters are initialized. + * + * local variables: + * int rel[] relocation data for code/data array + * int * relp pointer to rel array + * int txt[] assembled code/data array + * int * txtp pointer to txt array + * + * global variables: + * FILE * ofp relocation output file handle + * + * functions called: + * VOID out() asout.c + * + * side effects: + * All bufferred data written to .REL file and + * buffer pointers and counters initialized. + */ + +VOID +outbuf(s) +char *s; +{ + if (txtp > &txt[2]) { + fprintf(ofp, "T"); + out(txt,(int) (txtp-txt)); + fprintf(ofp, "\n"); + fprintf(ofp, s); + out(rel,(int) (relp-rel)); + fprintf(ofp, "\n"); + } + txtp = txt; + relp = rel; +} + +/*)Function VOID outgsd() + * + * The function outgsd() performs the following: + * (1) outputs the .REL file radix + * (2) outputs the header specifying the number + * of areas and global symbols + * (3) outputs the module name + * (4) set the reference number and output a symbol line + * for all external global variables and absolutes + * (5) output an area name, set reference number and output + * a symbol line for all global relocatables in the area. + * Repeat this proceedure for all areas. + * + * local variables: + * area * ap pointer to an area structure + * sym * sp pointer to a sym structure + * int i loop counter + * int j loop counter + * int c string character value + * int narea number of code areas + * char * ptr string pointer + * int nglob number of global symbols + * int rn symbol reference number + * + * global variables: + * area * areap pointer to an area structure + * char module[] module name string + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * VOID outarea() asout.c + * VOID outsym() asout.c + * int putc() c_library + * + * side effects: + * All symbols are given reference numbers, all symbol + * and area information is output to the .REL file. + */ + +VOID +outgsd() +{ + register struct area *ap; + register struct sym *sp; + register i, j; + char *ptr; + int c, narea, nglob, rn; + + /* + * Number of areas + */ + narea = areap->a_ref + 1; + + /* + * Number of global references/absolutes + */ + nglob = 0; + for (i = 0; i < NHASH; ++i) { + sp = symhash[i]; + while (sp) { + if (sp->s_flag&S_GBL) + ++nglob; + sp = sp->s_sp; + } + } + + /* + * Output Radix and number of areas and symbols + */ + if (xflag == 0) { + fprintf(ofp, "X%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %X areas %X global symbols\n", narea, nglob); + } else + if (xflag == 1) { + fprintf(ofp, "Q%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %o areas %o global symbols\n", narea, nglob); + } else + if (xflag == 2) { + fprintf(ofp, "D%c\n", hilo ? 'H' : 'L'); + fprintf(ofp, "H %u areas %u global symbols\n", narea, nglob); + } + + /* + * Module name + */ + if (module[0]) { + fprintf(ofp, "M "); + ptr = &module[0]; + while (ptr < &module[NCPS]) { + if ((c = *ptr++) != 0) + putc(c, ofp); + } + putc('\n', ofp); + } + + /* + * Global references and absolutes. + */ + rn = 0; + for (i=0; is_area==NULL && sp->s_flag&S_GBL) { + sp->s_ref = rn++; + outsym(sp); + } + sp = sp->s_sp; + } + } + + /* + * Global relocatables. + */ + for (i=0; ia_ref != i) + ap = ap->a_ap; + outarea(ap); + for (j=0; js_area==ap && sp->s_flag&S_GBL) { + sp->s_ref = rn++; + outsym(sp); + } + sp = sp->s_sp; + } + } + } +} + +/*)Function VOID outarea(ap) + * + * area * ap pointer to an area structure + * + * The function outarea() outputs the A line to the .REL + * file. The A line contains the area's name, size, and + * attributes. + * + * local variables: + * char * ptr pointer to area id string + * int c character value + * + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * int putc() c_library + * + * side effects: + * The A line is sent to the .REL file. + */ + +VOID +outarea(ap) +register struct area *ap; +{ + register char *ptr; + register c; + + fprintf(ofp, "A "); + ptr = &ap->a_id[0]; + while (ptr < &ap->a_id[NCPS]) { + if ((c = *ptr++) != 0) + putc(c, ofp); + } + if (xflag == 0) { + fprintf(ofp, " size %X flags %X\n", ap->a_size, ap->a_flag); + } else + if (xflag == 1) { + fprintf(ofp, " size %o flags %o\n", ap->a_size, ap->a_flag); + } else + if (xflag == 2) { + fprintf(ofp, " size %u flags %u\n", ap->a_size, ap->a_flag); + } +} + +/*)Function VOID outsym(sp) + * + * sym * sp pointer to a sym structure + * + * The function outsym() outputs the S line to the .REL + * file. The S line contains the symbols name and whether the + * the symbol is defined or referenced. + * + * local variables: + * char * ptr pointer to symbol id string + * int c character value + * + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * int putc() c_library + * + * side effects: + * The S line is sent to the .REL file. + */ + +VOID +outsym(sp) +register struct sym *sp; +{ + register char *ptr; + register c; + + fprintf(ofp, "S "); + ptr = &sp->s_id[0]; + while (ptr < &sp->s_id[NCPS]) { + if ((c = *ptr++) != 0) + putc(c, ofp); + } + fprintf(ofp, " %s", sp->s_type==S_NEW ? "Ref" : "Def"); + if (xflag == 0) { + fprintf(ofp, "%04X\n", sp->s_addr); + } else + if (xflag == 1) { + fprintf(ofp, "%06o\n", sp->s_addr); + } else + if (xflag == 2) { + fprintf(ofp, "%05u\n", sp->s_addr); + } +} + +/*)Function VOID out(p, n) + * + * int n number of words to output + * int * p pointer to data words + * + * The function out() outputs the data words to the .REL file + * int the specified radix. + * + * local variables: + * none + * + * global variables: + * FILE * ofp relocation output file handle + * int xflag -x, listing radix flag + * + * functions called: + * int fprintf() c_library + * + * side effects: + * Data is sent to the .REL file. + */ + +VOID +out(p, n) +register char *p; +register n; +{ + while (n--) { + if (xflag == 0) { + fprintf(ofp, " %02X", (*p++)&0377); + } else + if (xflag == 1) { + fprintf(ofp, " %03o", (*p++)&0377); + } else + if (xflag == 2) { + fprintf(ofp, " %03u", (*p++)&0377); + } + } +} + +/*)Function VOID out_lb(b, t) + * + * int b assembled data + * int t relocation type + * + * The function out_lb() copies the assembled data and + * its relocation type to the list data buffers. + * + * local variables: + * none + * + * global variables: + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * + * functions called: + * none + * + * side effects: + * Pointers to data and relocation buffers incremented by 1. + */ + +VOID +out_lb(b,t) +register b,t; +{ + if (cp < &cb[NCODE]) { + *cp++ = b; + *cpt++ = t; + } +} + +/*)Function VOID out_lw(n, t) + * + * int n assembled data + * int t relocation type + * + * The function out_lw() copies the assembled data and + * its relocation type to the list data buffers. + * + * local variables: + * none + * + * global variables: + * int * cp pointer to assembler output array cb[] + * int * cpt pointer to assembler relocation type + * output array cbt[] + * + * functions called: + * none + * + * side effects: + * Pointers to data and relocation buffers incremented by 2. + */ + +VOID +out_lw(n,t) +register n,t; +{ + if (hilo) { + out_lb(hibyte(n),t ? t|R_HIGH : 0); + out_lb(lobyte(n),t); + } else { + out_lb(lobyte(n),t); + out_lb(hibyte(n),t ? t|R_HIGH : 0); + } +} + +/*)Function VOID out_rw(n) + * + * int n data word + * + * The function out_rw() outputs the relocation (R) + * data word as two bytes ordered according to hilo. + * + * local variables: + * int * relp pointer to rel array + * + * global variables: + * none + * + * functions called: + * int lobyte() asout.c + * int hibyte() asout.c + * + * side effects: + * Pointer to relocation buffer incremented by 2. + */ + +VOID +out_rw(n) +register n; +{ + if (hilo) { + *relp++ = hibyte(n); + *relp++ = lobyte(n); + } else { + *relp++ = lobyte(n); + *relp++ = hibyte(n); + } +} + +/*)Function VOID out_tw(n) + * + * int n data word + * + * The function out_tw() outputs the text (T) + * data word as two bytes ordered according to hilo. + * + * local variables: + * int * txtp pointer to txt array + * + * global variables: + * none + * + * functions called: + * int lobyte() asout.c + * int hibyte() asout.c + * + * side effects: + * Pointer to relocation buffer incremented by 2. + */ + +VOID +out_tw(n) +register n; +{ + if (hilo) { + *txtp++ = hibyte(n); + *txtp++ = lobyte(n); + } else { + *txtp++ = lobyte(n); + *txtp++ = hibyte(n); + } +} + +/*)Function int lobyte(n) + * + * int n data word + * + * The function lobyte() returns the lower byte of + * integer n. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +lobyte(n) +{ + return (n&0377); +} + +/*)Function int hibyte(n) + * + * int n data word + * + * The function hibyte() returns the higher byte of + * integer n. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +hibyte(n) +{ + return ((n>>8)&0377); +} + diff --git a/as/z80/assubr.c b/as/z80/assubr.c new file mode 100644 index 00000000..7302a4ff --- /dev/null +++ b/as/z80/assubr.c @@ -0,0 +1,255 @@ +/* assubr.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber, M. Hope + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module assubr.c + * + * The module assubr.c contains the error + * processing routines. + * + * assubr.c contains the following functions: + * VOID aerr() + * VOID diag() + * VOID err() + * VOID qerr() + * VOID rerr() + * + * assubr.c contains the local array of *error[] + */ + +/*)Function VOID err(c) + * + * int c error type character + * + * The function err() logs the error code character + * suppressing duplicate errors. If the error code + * is 'q' then the parse of the current assembler-source + * text line is terminated. + * + * local variables: + * char * p pointer to the error array + * + * global variables: + * char eb[] array of generated error codes + * + * functions called: + * VOID longjmp() c_library + * + * side effects: + * The error code may be inserted into the + * error code array eb[] or the parse terminated. + */ + +VOID +err(c) +register c; +{ + register char *p; + +#ifndef SDK + aserr++; +#endif /* SDK */ + p = eb; + while (p < ep) + if (*p++ == c) + return; + if (p < &eb[NERR]) { + *p++ = c; + ep = p; + } + if (c == 'q') + longjmp(jump_env, -1); +} + +/*)Function VOID diag() + * + * The function diag() prints any error codes and + * the source line number to the stderr output device. + * + * local variables: + * char * p pointer to error code array eb[] + * + * global variables: + * int cfile current source file index + * char eb[] array of generated error codes + * char * ep pointer into error list + * int incfile current include file index + * char incfn[] array of include file names + * int incline[] array of include line numbers + * char srcfn[] array of source file names + * int srcline[] array of source line numbers + * FILE * stderr c_library + * + * functions called: + * int fprintf() c_library + * char * geterr() assubr.c + * + * side effects: + * none + */ + +VOID +diag() +{ + register char *p,*errstr; + + if (eb != ep) { + p = eb; +#ifndef SDK + fprintf(stderr, "?ASxxxx-Error-<"); + while (p < ep) { + fprintf(stderr, "%c", *p++); + } + fprintf(stderr, "> in line "); + if (incfil >= 0) { + fprintf(stderr, "%d", incline[incfil]); + fprintf(stderr, " of %s\n", incfn[incfil]); + } else { + fprintf(stderr, "%d", srcline[cfile]); + fprintf(stderr, " of %s\n", srcfn[cfile]); + } + p = eb; +#endif /* SDK */ + while (p < ep) { + if ((errstr = geterr(*p++)) != NULL) { +#ifdef SDK + /* Modified to conform to gcc error standard, M. Hope, 7 Feb 98. */ + if (incfil >= 0) { + fprintf(stderr, "%s:", incfn[incfil]); + fprintf(stderr, "%d: Error:", incline[incfil]); + } + else { + fprintf(stderr, "%s:", srcfn[cfile]); + fprintf(stderr, "%d: Error:", srcline[cfile]); + } + fprintf(stderr, " %s\n", errstr); +#else + fprintf(stderr, " %s\n", errstr); +#endif /* SDK */ + } + } +#ifdef SDK + aserr++; +#endif /* SDK */ + } +} + +/*)Functions: VOID aerr() + * VOID qerr() + * VOID rerr() + * + * The functions aerr(), qerr(), and rerr() report their + * respective error type. These are included only for + * convenience. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * VOID err() assubr.c + * + * side effects: + * The appropriate error code is inserted into the + * error array and the parse may be terminated. + */ + +/* + * Note an 'r' error. + */ +VOID +rerr() +{ + err('r'); +} + +/* + * Note an 'a' error. + */ +VOID +aerr() +{ + err('a'); +} + +/* + * Note a 'q' error. + */ +VOID +qerr() +{ + err('q'); +} + +/* + * ASxxxx assembler errors + */ +char *errors[] = { + "<.> use \". = . + \" not \". = \"", + " machine specific addressing or addressing mode error", + " direct page boundary error", + " direct page addressing error", + " .include file error or an .if/.endif mismatch", + " multiple definitions error", + " .org in REL area or directive / mnemonic error", + "

phase error: label location changing between passes 2 and 3", + " missing or improper operators, terminators, or delimiters", + " relocation error", + " undefined symbol encountered during assembly", + NULL +}; + +/*)Function: char *getarr(c) + * + * int c the error code character + * + * The function geterr() scans the list of errors returning the + * error string corresponding to the input error character. + * + * local variables: + * int i error index counter + * + * global variables: + * char *errors[] array of pointers to the + * error strings + * + * functions called: + * none + * + * side effects: + * A pointer to the appropriate + * error code string is returned. + */ +char * +geterr(c) +int c; +{ + int i; + + for (i=0; errors[i]!=NULL; i++) { + if (c == errors[i][1]) { + return(errors[i]); + } + } + return(NULL); +} + diff --git a/as/z80/assym.c b/as/z80/assym.c new file mode 100644 index 00000000..8b8a6ae1 --- /dev/null +++ b/as/z80/assym.c @@ -0,0 +1,441 @@ +/* assym.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include +#include "asm.h" + +/*)Module assym.c + * + * The module assym.c contains the functions that operate + * on the mnemonic/directive and symbol structures. + * + * assym.c contains the following functions: + * VOID allglob() + * area * alookup() + * int hash() + * sym * lookup() + * mne * mlookup() + * VOID * new() + * int symeq() + * VOID syminit() + * VOID symglob() + * + * assym.c contains no local/static variables. + */ + +/*)Function VOID syminit() + * + * The function syminit() is called early in the game + * to set up the hashtables. First all buckets in a + * table are cleared. Then a pass is made through + * the respective symbol lists, linking them into + * their hash buckets. Finally the base area pointer + * is set to 'dca'. + * + * local variables: + * int h computed hash value + * mne * mp pointer to a mne structure + * mne ** mpp pointer to an array of + * mne structure pointers + * sym * sp pointer to a sym structure + * sym ** spp pointer to an array of + * sym structure pointers + * + * global variables: + * area area[] single elememt area array + * area dca defined as area[0] + * mne * mnehash[] array of pointers to NHASH + * linked mnemonic/directive lists + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * (1) The symbol hash tables are initialized, + * the only defined symbol is '.'. + * (2) The mnemonic/directive hash tables are + * initialized with the assembler directives + * and mnemonics found in the machine dependent + * file ___pst.c. + * (3) The area pointer is initialized to dca (area[0]). + */ + +VOID +syminit() +{ + register struct mne *mp; + struct mne **mpp; + register struct sym *sp; + struct sym **spp; + register h; + + mpp = &mnehash[0]; + while (mpp < &mnehash[NHASH]) + *mpp++ = NULL; + mp = &mne[0]; + for (;;) { + h = hash(mp->m_id); + mp->m_mp = mnehash[h]; + mnehash[h] = mp; + if (mp->m_flag&S_END) + break; + ++mp; + } + + spp = &symhash[0]; + while (spp < &symhash[NHASH]) + *spp++ = NULL; + sp = &sym[0]; + for (;;) { + h = hash(sp->s_id); + sp->s_sp = symhash[h]; + symhash[h] = sp; + if (sp->s_flag&S_END) + break; + ++sp; + } + + areap = &dca; +} + +/*)Function area * alookup(id) + * + * char * id area name string + * + * The function alookup() searches the area list for a + * match with id. If the area is defined then a pointer + * to this area is returned else a NULL is returned. + * + * local variables: + * area * ap pointer to area structure + * + * global variables: + * area * areap pointer to an area structure + * + * functions called: + * int symeq() assym.c + * + * side effects: + * none + */ + +struct area * +alookup(id) +char *id; +{ + register struct area *ap; + + ap = areap; + while (ap) { + if (symeq(id, ap->a_id)) { + return (ap); + } + ap = ap->a_ap; + } + return(NULL); +} + +/*)Function mne * mlookup(id) + * + * char * id mnemonic/directive name string + * + * The function mlookup() searches the mnemonic/directive + * hash tables for a match returning a pointer to the + * mne structure else it returns a NULL. + * + * local variables: + * mne * mp pointer to mne structure + * int h calculated hash value + * + * global variables: + * mne * mnehash[] array of pointers to NHASH + * linked mnemonic/directive lists + * + * functions called: + * none + * + * side effects: + * none + */ + +struct mne * +mlookup(id) +char *id; +{ + register struct mne *mp; + register h; + + h = hash(id); + mp = mnehash[h]; + while (mp) { + if (symeq(id, mp->m_id)) + return (mp); + mp = mp->m_mp; + } + return (NULL); +} + +/*)Function sym * lookup(id) + * + * char * id symbol name string + * + * The function lookup() searches the symbol hash tables for + * a symbol name match returning a pointer to the sym structure. + * If the symbol is not found then a sym structure is created, + * initialized, and linked to the appropriate hash table. + * A pointer to this new sym structure is returned. + * + * local variables: + * int h computed hash value + * sym * sp pointer to a sym structure + * + * global varaibles: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * int hash() assym.c + * VOID * new() assym.c + * int symeq() assym.c + * + * side effects: + * If the function new() fails to allocate space + * for the new sym structure the assembly terminates. + */ + +struct sym * +lookup(id) +char *id; +{ + register struct sym *sp; + register h; + + h = hash(id); + sp = symhash[h]; + while (sp) { + if (symeq(id, sp->s_id)) + return (sp); + sp = sp->s_sp; + } + sp = (struct sym *) new (sizeof(struct sym)); + sp->s_sp = symhash[h]; + symhash[h] = sp; + sp->s_tsym = NULL; + strncpy(sp->s_id, id, NCPS); + sp->s_type = S_NEW; + sp->s_flag = 0; + sp->s_area = NULL; + sp->s_ref = 0; + sp->s_addr = 0; + return (sp); +} + +/*)Function VOID symglob() + * + * The function symglob() will mark all symbols of + * type S_NEW as global. Called at the beginning of pass 1 + * if the assembly option -g was specified. + * + * local variables: + * sym * sp pointer to a sym structure + * int i loop index + * + * global variables: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * Symbol types changed. + */ + +VOID +symglob() +{ + register struct sym *sp; + register i; + + for (i=0; is_type == S_NEW) + sp->s_flag |= S_GBL; + sp = sp->s_sp; + } + } +} + +/*)Function VOID allglob() + * + * The function allglob() will mark all symbols of + * type S_USER as global. Called at the beginning of pass 1 + * if the assembly option -a was specified. + * + * local variables: + * sym * sp pointer to a sym structure + * int i loop index + * + * global variables: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * Symbol types changed. + */ + +VOID +allglob() +{ + register struct sym *sp; + register i; + + for (i=0; is_type == S_USER) + sp->s_flag |= S_GBL; + sp = sp->s_sp; + } + } +} + +/*)Function int symeq(p1, p2) + * + * char * p1 name string + * char * p2 name string + * + * The function symeq() compares the two name strings for a match. + * The return value is 1 for a match and 0 for no match. + * + * local variables: + * int h loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + * + */ + +int +symeq(p1, p2) +register char *p1, *p2; +{ + register n; + + n = NCPS; + do { + +#if CASE_SENSITIVE + if (*p1++ != *p2++) + return (0); +#else + if (ccase[*p1++] != ccase[*p2++]) + return (0); +#endif + + } while (--n); + return (1); +} + +/*)Function int hash(p) + * + * char * p pointer to string to hash + * + * The function hash() computes a hash code using the sum + * of all characters mod table size algorithm. + * + * local variables: + * int h accumulated character sum + * int n loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + */ + +int +hash(p) +register char *p; +{ + register h, n; + + h = 0; + n = NCPS; + do { + +#if CASE_SENSITIVE + h += *p++; +#else + h += ccase[*p++]; +#endif + + } while (--n); + return (h&HMASK); +} + +/*)Function VOID * new(n) + * + * unsigned int n allocation size in bytes + * + * The function new() allocates n bytes of space and returns + * a pointer to this memory. If no space is available the + * assembly is terminated. + * + * local variables: + * VOID * p a general pointer + * + * global variables: + * none + * + * functions called: + * VOID asexit() asmain.c + * int fprintf() c_library + * VOID * malloc() c_library + * + * side effects: + * Memory is allocated, if allocation fails + * the assembly is terminated. + */ + +VOID * +new(n) +unsigned int n; +{ + register VOID *p; + + if ((p = (VOID *) malloc(n)) == NULL) { + fprintf(stderr, "Out of space!\n"); + asexit(1); + } + return (p); +} diff --git a/as/z80/incld1.asm b/as/z80/incld1.asm new file mode 100644 index 00000000..6994f274 --- /dev/null +++ b/as/z80/incld1.asm @@ -0,0 +1,10 @@ + xxx ;1 + .include "incld2.asm" ;2 + ;3 + ;4 + ;5 + xxx ;6 + ;7 + ;8 + ;9 + ;10 diff --git a/as/z80/incld2.asm b/as/z80/incld2.asm new file mode 100644 index 00000000..2c33ce88 --- /dev/null +++ b/as/z80/incld2.asm @@ -0,0 +1,10 @@ + ;1 + xxx ;2 + .include "incld3.asm" ;3 + ;4 + ;5 + ;6 + xxx ;7 + ;8 + ;9 + ;10 diff --git a/as/z80/incld3.asm b/as/z80/incld3.asm new file mode 100644 index 00000000..0c66f55a --- /dev/null +++ b/as/z80/incld3.asm @@ -0,0 +1,10 @@ + ;1 + ;2 + xxx ;3 + .include "incld4.asm" ;4 + ;5 + ;6 + ;7 + xxx ;8 + ;9 + ;10 diff --git a/as/z80/incld4.asm b/as/z80/incld4.asm new file mode 100644 index 00000000..0fc64c54 --- /dev/null +++ b/as/z80/incld4.asm @@ -0,0 +1,10 @@ + ;1 + ;2 + ;3 + xxx ;4 + .include "incld5.asm" ;5 + ;6 + ;7 + ;8 + xxx ;9 + ;10 diff --git a/as/z80/incld5.asm b/as/z80/incld5.asm new file mode 100644 index 00000000..9392a007 --- /dev/null +++ b/as/z80/incld5.asm @@ -0,0 +1,10 @@ + ;1 + ;2 + ;3 + ;4 + xxx ;5 + .include "incldx.asm" ;6 + ;7 + ;8 + ;9 + xxx ;10 diff --git a/as/z80/itsta.asm b/as/z80/itsta.asm new file mode 100644 index 00000000..c87c4fc2 --- /dev/null +++ b/as/z80/itsta.asm @@ -0,0 +1,42 @@ + .include "incld1.asm" ;1 + ;2 + ;3 + ;4 + ;5 + ;6 + ;7 + ;8 + ;9 + ;10 + xxx ;11 +; +; This is a simple test of the error reporting +; for source and include files. +; +; assemble inctst: +; asxxxx itsta itstb +; +; ?ASxxxx-E- in line 1 of incld1.asm +; ?ASxxxx-E- in line 2 of incld2.asm +; ?ASxxxx-E- in line 3 of incld3.asm +; ?ASxxxx-E- in line 4 of incld4.asm +; ?ASxxxx-E- in line 5 of incld5.asm +; ?ASxxxx-E- in line 6 of incld5.asm +; ?ASxxxx-E- in line 10 of incld5.asm +; ?ASxxxx-E- in line 9 of incld4.asm +; ?ASxxxx-E- in line 8 of incld3.asm +; ?ASxxxx-E- in line 7 of incld2.asm +; ?ASxxxx-E- in line 6 of incld1.asm +; ?ASxxxx-E- in line 11 of itsta.asm +; ?ASxxxx-E- in line 1 of incld1.asm +; ?ASxxxx-E- in line 2 of incld2.asm +; ?ASxxxx-E- in line 3 of incld3.asm +; ?ASxxxx-E- in line 4 of incld4.asm +; ?ASxxxx-E- in line 5 of incld5.asm +; ?ASxxxx-E- in line 6 of incld5.asm +; ?ASxxxx-E- in line 10 of incld5.asm +; ?ASxxxx-E- in line 9 of incld4.asm +; ?ASxxxx-E- in line 8 of incld3.asm +; ?ASxxxx-E- in line 7 of incld2.asm +; ?ASxxxx-E- in line 6 of incld1.asm +; ?ASxxxx-E- in line 11 of itstb.asm diff --git a/as/z80/itstb.asm b/as/z80/itstb.asm new file mode 100644 index 00000000..c87c4fc2 --- /dev/null +++ b/as/z80/itstb.asm @@ -0,0 +1,42 @@ + .include "incld1.asm" ;1 + ;2 + ;3 + ;4 + ;5 + ;6 + ;7 + ;8 + ;9 + ;10 + xxx ;11 +; +; This is a simple test of the error reporting +; for source and include files. +; +; assemble inctst: +; asxxxx itsta itstb +; +; ?ASxxxx-E- in line 1 of incld1.asm +; ?ASxxxx-E- in line 2 of incld2.asm +; ?ASxxxx-E- in line 3 of incld3.asm +; ?ASxxxx-E- in line 4 of incld4.asm +; ?ASxxxx-E- in line 5 of incld5.asm +; ?ASxxxx-E- in line 6 of incld5.asm +; ?ASxxxx-E- in line 10 of incld5.asm +; ?ASxxxx-E- in line 9 of incld4.asm +; ?ASxxxx-E- in line 8 of incld3.asm +; ?ASxxxx-E- in line 7 of incld2.asm +; ?ASxxxx-E- in line 6 of incld1.asm +; ?ASxxxx-E- in line 11 of itsta.asm +; ?ASxxxx-E- in line 1 of incld1.asm +; ?ASxxxx-E- in line 2 of incld2.asm +; ?ASxxxx-E- in line 3 of incld3.asm +; ?ASxxxx-E- in line 4 of incld4.asm +; ?ASxxxx-E- in line 5 of incld5.asm +; ?ASxxxx-E- in line 6 of incld5.asm +; ?ASxxxx-E- in line 10 of incld5.asm +; ?ASxxxx-E- in line 9 of incld4.asm +; ?ASxxxx-E- in line 8 of incld3.asm +; ?ASxxxx-E- in line 7 of incld2.asm +; ?ASxxxx-E- in line 6 of incld1.asm +; ?ASxxxx-E- in line 11 of itstb.asm diff --git a/as/z80/string.h b/as/z80/string.h new file mode 100644 index 00000000..fdcd2116 --- /dev/null +++ b/as/z80/string.h @@ -0,0 +1,15 @@ +/* STRING.H */ +/* DECUC C */ + +extern char * strcat(); +extern char * strchr(); +extern int strcmp(); +extern char * strcpy(); +extern int streq(); +extern int strlen(); +extern char * strncat(); +extern int strncmp(); +extern char * strncpy(); +extern int strneq(); +extern char * strrchr(); + diff --git a/as/z80/tconst.asm b/as/z80/tconst.asm new file mode 100644 index 00000000..c8f254bc --- /dev/null +++ b/as/z80/tconst.asm @@ -0,0 +1,68 @@ + .title Assembler Link Test Constants + + .module tconst + + .area TEST (ABS,OVR) + + bra1 == 0 ; branching constants + bra2 == 0x80 + bra3 == 0x182 + bra4 == 0x204 + + .blkb 0x7E ;bra1: + .blkb 0x02 + .blkb 0x7F ;bra2: + .blkb 0x02 + .blkb 0x02 + .blkb 0x7F + .blkb 0x00 ;bra3: + .blkb 0x02 + .blkb 0x80 + .blkb 0x00 ;bra4: + + .globl bra5,bra6,bra7,bra8 + + ; branching labels +bra5: .blkb 0x7E ;bra5: + .blkb 0x02 +bra6: .blkb 0x7F ;bra6: + .blkb 0x02 + .blkb 0x02 + .blkb 0x7F +bra7: .blkb 0x00 ;bra7: + .blkb 0x02 + .blkb 0x80 +bra8: .blkb 0x00 ;bra8: + + + ; 12-Bit numbers are considered valid if: + ; 1) the most significant 4 bits of the 16-bit number are zero + ; 2) the most significant 4 bits of the 16-bit number are all ones + + n0FFF == 0x0FFF ;largest positive + n1000 == 0x1000 ;+1 + + nF000 == 0xF000 ;largest negative + nEFFF == 0xEFFF ;-1 + + + .area DIRECT (ABS,OVR) + .setdp + + boundary == 0x101 + + minus1 == -1 ; paging / indexing constants + zero == 0 + two55 == 0d255 + two56 == 0d256 + five11 == 0d511 + five12 == 0d512 + + + .globl lzero,ltwo55,ltwo56,lminus1 + +lzero: .blkb 0x00FF ; paging labels +ltwo55: .blkb 0x0001 +ltwo56: .blkb 0xFEFF +lminus1:.blkb 0d0000 + diff --git a/as/z80/tz80.asm b/as/z80/tz80.asm new file mode 100644 index 00000000..a33edc21 --- /dev/null +++ b/as/z80/tz80.asm @@ -0,0 +1,1013 @@ + .title Test of Z80 / HD64180 assembler + + offset = 0x55 ;arbitrary constants + n = 0x20 + nn = 0x0584 + + ; notes: + ; Leading 'a' operand is optional. + ; If offset is ommitted 0 is assumed. + + ;*********************************************************** + ; add with carry to 'a' + adc a,(hl) ;8E + adc a,offset(ix) ;DD 8E 55 + adc a,offset(iy) ;FD 8E 55 + adc a,a ;8F + adc a,b ;88 + adc a,c ;89 + adc a,d ;8A + adc a,e ;8B + adc a,h ;8C + adc a,l ;8D + adc a,#n ;CE 20 + ;*********************************************************** + adc (hl) ;8E + adc offset(ix) ;DD 8E 55 + adc offset(iy) ;FD 8E 55 + adc a ;8F + adc b ;88 + adc c ;89 + adc d ;8A + adc e ;8B + adc h ;8C + adc l ;8D + adc #n ;CE 20 + ;*********************************************************** + ; add with carry register pair to 'hl' + adc hl,bc ;ED 4A + adc hl,de ;ED 5A + adc hl,hl ;ED 6A + adc hl,sp ;ED 7A + ;*********************************************************** + ; add operand to 'a' + add a,(hl) ;86 + add a,offset(ix) ;DD 86 55 + add a,offset(iy) ;FD 86 55 + add a,a ;87 + add a,b ;80 + add a,c ;81 + add a,d ;82 + add a,e ;83 + add a,h ;84 + add a,l ;85 + add a,#n ;C6 20 + ;*********************************************************** + ; add register pair to 'hl' + add hl,bc ;09 + add hl,de ;19 + add hl,hl ;29 + add hl,sp ;39 + ;*********************************************************** + ; add register pair to 'ix' + add ix,bc ;DD 09 + add ix,de ;DD 19 + add ix,ix ;DD 29 + add ix,sp ;DD 39 + ;*********************************************************** + ; add register pair to 'iy' + add iy,bc ;FD 09 + add iy,de ;FD 19 + add iy,iy ;FD 29 + add iy,sp ;FD 39 + ;*********************************************************** + ; logical 'and' operand with 'a' + and a,(hl) ;A6 + and a,offset(ix) ;DD A6 55 + and a,offset(iy) ;FD A6 55 + and a,a ;A7 + and a,b ;A0 + and a,c ;A1 + and a,d ;A2 + and a,e ;A3 + and a,h ;A4 + and a,l ;A5 + and a,#n ;E6 20 + ;*********************************************************** + ; test bit of location or register + bit 0,(hl) ;CB 46 + bit 0,offset(ix) ;DD CB 55 46 + bit 0,offset(iy) ;FD CB 55 46 + bit 0,a ;CB 47 + bit 0,b ;CB 40 + bit 0,c ;CB 41 + bit 0,d ;CB 42 + bit 0,e ;CB 43 + bit 0,h ;CB 44 + bit 0,l ;CB 45 + bit 1,(hl) ;CB 4E + bit 1,offset(ix) ;DD CB 55 4E + bit 1,offset(iy) ;FD CB 55 4E + bit 1,a ;CB 4F + bit 1,b ;CB 48 + bit 1,c ;CB 49 + bit 1,d ;CB 4A + bit 1,e ;CB 4B + bit 1,h ;CB 4C + bit 1,l ;CB 4D + bit 2,(hl) ;CB 56 + bit 2,offset(ix) ;DD CB 55 56 + bit 2,offset(iy) ;FD CB 55 56 + bit 2,a ;CB 57 + bit 2,b ;CB 50 + bit 2,c ;CB 51 + bit 2,d ;CB 52 + bit 2,e ;CB 53 + bit 2,h ;CB 54 + bit 2,l ;CB 55 + bit 3,(hl) ;CB 5E + bit 3,offset(ix) ;DD CB 55 5E + bit 3,offset(iy) ;FD CB 55 5E + bit 3,a ;CB 5F + bit 3,b ;CB 58 + bit 3,c ;CB 59 + bit 3,d ;CB 5A + bit 3,e ;CB 5B + bit 3,h ;CB 5C + bit 3,l ;CB 5D + bit 4,(hl) ;CB 66 + bit 4,offset(ix) ;DD CB 55 66 + bit 4,offset(iy) ;FD CB 55 66 + bit 4,a ;CB 67 + bit 4,b ;CB 60 + bit 4,c ;CB 61 + bit 4,d ;CB 62 + bit 4,e ;CB 63 + bit 4,h ;CB 64 + bit 4,l ;CB 65 + bit 5,(hl) ;CB 6E + bit 5,offset(ix) ;DD CB 55 6E + bit 5,offset(iy) ;FD CB 55 6E + bit 5,a ;CB 6F + bit 5,b ;CB 68 + bit 5,c ;CB 69 + bit 5,d ;CB 6A + bit 5,e ;CB 6B + bit 5,h ;CB 6C + bit 5,l ;CB 6D + bit 6,(hl) ;CB 76 + bit 6,offset(ix) ;DD CB 55 76 + bit 6,offset(iy) ;FD CB 55 76 + bit 6,a ;CB 77 + bit 6,b ;CB 70 + bit 6,c ;CB 71 + bit 6,d ;CB 72 + bit 6,e ;CB 73 + bit 6,h ;CB 74 + bit 6,l ;CB 75 + bit 7,(hl) ;CB 7E + bit 7,offset(ix) ;DD CB 55 7E + bit 7,offset(iy) ;FD CB 55 7E + bit 7,a ;CB 7F + bit 7,b ;CB 78 + bit 7,c ;CB 79 + bit 7,d ;CB 7A + bit 7,e ;CB 7B + bit 7,h ;CB 7C + bit 7,l ;CB 7D + ;*********************************************************** + ; call subroutine at nn if condition is true + call C,nn ;DC 84 05 + call M,nn ;FC 84 05 + call NC,nn ;D4 84 05 + call NZ,nn ;C4 84 05 + call P,nn ;F4 84 05 + call PE,nn ;EC 84 05 + call PO,nn ;E4 84 05 + call Z,nn ;CC 84 05 + ;*********************************************************** + ; unconditional call to subroutine at nn + call nn ;CD 84 05 + ;*********************************************************** + ; complement carry flag + ccf ;3F + ;*********************************************************** + ; compare operand with 'a' + cp a,(hl) ;BE + cp a,offset(ix) ;DD BE 55 + cp a,offset(iy) ;FD BE 55 + cp a,a ;BF + cp a,b ;B8 + cp a,c ;B9 + cp a,d ;BA + cp a,e ;BB + cp a,h ;BC + cp a,l ;BD + cp a,#n ;FE 20 + ;*********************************************************** + ; compare location (hl) and 'a' + ; decrement 'hl' and 'bc' + cpd ;ED A9 + ;*********************************************************** + ; compare location (hl) and 'a' + ; decrement 'hl' and 'bc' + ; repeat until 'bc' = 0 + cpdr ;ED B9 + ;*********************************************************** + ; compare location (hl) and 'a' + ; increment 'hl' and decrement 'bc' + cpi ;ED A1 + ;*********************************************************** + ; compare location (hl) and 'a' + ; increment 'hl' and decrement 'bc' + ; repeat until 'bc' = 0 + cpir ;ED B1 + ;*********************************************************** + ; 1's complement of 'a' + cpl ;2F + ;*********************************************************** + ; decimal adjust 'a' + daa ;27 + ;*********************************************************** + ; decrement operand + dec (hl) ;35 + dec offset(ix) ;DD 35 55 + dec offset(iy) ;FD 35 55 + dec a ;3D + dec b ;05 + dec bc ;0B + dec c ;0D + dec d ;15 + dec de ;1B + dec e ;1D + dec h ;25 + dec hl ;2B + dec ix ;DD 2B + dec iy ;FD 2B + dec l ;2D + dec sp ;3B + ;*********************************************************** + ; disable interrupts + di ;F3 + ;*********************************************************** + ; decrement b and jump relative if b # 0 + djnz .+0x12 ;10 10 + ;*********************************************************** + ; enable interrupts + ei ;FB + ;*********************************************************** + ; exchange location and (sp) + ex (sp),hl ;E3 + ex (sp),ix ;DD E3 + ex (sp),iy ;FD E3 + ;*********************************************************** + ; exchange af and af' + ex af,af' ;08 + ;*********************************************************** + ; exchange de and hl + ex de,hl ;EB + ;*********************************************************** + ; exchange: + ; bc <-> bc' + ; de <-> de' + ; hl <-> hl' + exx ;D9 + ;*********************************************************** + ; halt (wait for interrupt or reset) + halt ;76 + ;*********************************************************** + ; set interrupt mode + im 0 ;ED 46 + im 1 ;ED 56 + im 2 ;ED 5E + ;*********************************************************** + ; load 'a' with input from device n + in a,(n) ;DB 20 + ;*********************************************************** + ; load register with input from (c) + in a,(c) ;ED 78 + in b,(c) ;ED 40 + in c,(c) ;ED 48 + in d,(c) ;ED 50 + in e,(c) ;ED 58 + in h,(c) ;ED 60 + in l,(c) ;ED 68 + ;*********************************************************** + ; increment operand + inc (hl) ;34 + inc offset(ix) ;DD 34 55 + inc offset(iy) ;FD 34 55 + inc a ;3C + inc b ;04 + inc bc ;03 + inc c ;0C + inc d ;14 + inc de ;13 + inc e ;1C + inc h ;24 + inc hl ;23 + inc ix ;DD 23 + inc iy ;FD 23 + inc l ;2C + inc sp ;33 + ;*********************************************************** + ; load location (hl) with input + ; from port (c) + ; decrement 'hl' and 'b' + ind ;ED AA + ;*********************************************************** + ; load location (hl) with input + ; from port (c) + ; decrement 'hl' and 'b' + ; repeat until 'b' = 0 + indr ;ED BA + ;*********************************************************** + ; load location (hl) with input + ; from port (c) + ; increment 'hl' and decrement 'b' + ini ;ED A2 + ;*********************************************************** + ; load location (hl) with input + ; from port (c) + ; increment 'hl' and decrement 'b' + ; repeat until 'b' = 0 + inir ;ED B2 + ;*********************************************************** + ; unconditional jump to location nn + jp nn ;C3 84 05 + jp (hl) ;E9 + jp (ix) ;DD E9 + jp (iy) ;FD E9 + ;*********************************************************** + ; jump to location if condition is true + jp C,nn ;DA 84 05 + jp M,nn ;FA 84 05 + jp NC,nn ;D2 84 05 + jp NZ,nn ;C2 84 05 + jp P,nn ;F2 84 05 + jp PE,nn ;EA 84 05 + jp PO,nn ;E2 84 05 + jp Z,nn ;CA 84 05 + ;*********************************************************** + ; unconditional jump relative to PC+e + jr jr1+0x10 ;18 10 + ;*********************************************************** + ; jump relative to PC+e if condition is true +jr1: jr C,jr2+0x10 ;38 10 +jr2: jr NC,jr3+0x10 ;30 10 +jr3: jr NZ,jr4+0x10 ;20 10 +jr4: jr Z,jr5+0x10 ;28 10 +jr5: + ;*********************************************************** + ; load source to destination + ld a,(hl) ;7E + ld a,offset(ix) ;DD 7E 55 + ld a,offset(iy) ;FD 7E 55 + ld a,a ;7F + ld a,b ;78 + ld a,c ;79 + ld a,d ;7A + ld a,e ;7B + ld a,h ;7C + ld a,l ;7D + ld a,#n ;3E 20 + ld b,(hl) ;46 + ld b,offset(ix) ;DD 46 55 + ld b,offset(iy) ;FD 46 55 + ld b,a ;47 + ld b,b ;40 + ld b,c ;41 + ld b,d ;42 + ld b,e ;43 + ld b,h ;44 + ld b,l ;45 + ld b,#n ;06 20 + ld c,(hl) ;4E + ld c,offset(ix) ;DD 4E 55 + ld c,offset(iy) ;FD 4E 55 + ld c,a ;4F + ld c,b ;48 + ld c,c ;49 + ld c,d ;4A + ld c,e ;4B + ld c,h ;4C + ld c,l ;4D + ld c,#n ;0E 20 + ld d,(hl) ;56 + ld d,offset(ix) ;DD 56 55 + ld d,offset(iy) ;FD 56 55 + ld d,a ;57 + ld d,b ;50 + ld d,c ;51 + ld d,d ;52 + ld d,e ;53 + ld d,h ;54 + ld d,l ;55 + ld d,#n ;16 20 + ld e,(hl) ;5E + ld e,offset(ix) ;DD 5E 55 + ld e,offset(iy) ;FD 5E 55 + ld e,a ;5F + ld e,b ;58 + ld e,c ;59 + ld e,d ;5A + ld e,e ;5B + ld e,h ;5C + ld e,l ;5D + ld e,#n ;1E 20 + ld h,(hl) ;66 + ld h,offset(ix) ;DD 66 55 + ld h,offset(iy) ;FD 66 55 + ld h,a ;67 + ld h,b ;60 + ld h,c ;61 + ld h,d ;62 + ld h,e ;63 + ld h,h ;64 + ld h,l ;65 + ld h,#n ;26 20 + ld l,(hl) ;6E + ld l,offset(ix) ;DD 6E 55 + ld l,offset(iy) ;FD 6E 55 + ld l,a ;6F + ld l,b ;68 + ld l,c ;69 + ld l,d ;6A + ld l,e ;6B + ld l,h ;6C + ld l,l ;6D + ld l,#n ;2E 20 + ;*********************************************************** + ld i,a ;ED 47 + ld r,a ;ED 4F + ld a,i ;ED 57 + ld a,r ;ED 5F + ;*********************************************************** + ld (bc),a ;02 + ld (de),a ;12 + ld a,(bc) ;0A + ld a,(de) ;1A + ;*********************************************************** + ld (hl),a ;77 + ld (hl),b ;70 + ld (hl),c ;71 + ld (hl),d ;72 + ld (hl),e ;73 + ld (hl),h ;74 + ld (hl),l ;75 + ld (hl),#n ;36 20 + ;*********************************************************** + ld offset(ix),a ;DD 77 55 + ld offset(ix),b ;DD 70 55 + ld offset(ix),c ;DD 71 55 + ld offset(ix),d ;DD 72 55 + ld offset(ix),e ;DD 73 55 + ld offset(ix),h ;DD 74 55 + ld offset(ix),l ;DD 75 55 + ld offset(ix),#n ;DD 36 55 20 + ;*********************************************************** + ld offset(iy),a ;FD 77 55 + ld offset(iy),b ;FD 70 55 + ld offset(iy),c ;FD 71 55 + ld offset(iy),d ;FD 72 55 + ld offset(iy),e ;FD 73 55 + ld offset(iy),h ;FD 74 55 + ld offset(iy),l ;FD 75 55 + ld offset(iy),#n ;FD 36 55 20 + ;*********************************************************** + ld (nn),a ;32 84 05 + ld (nn),bc ;ED 43 84 05 + ld (nn),de ;ED 53 84 05 + ld (nn),hl ;22 84 05 + ld (nn),sp ;ED 73 84 05 + ld (nn),ix ;DD 22 84 05 + ld (nn),iy ;FD 22 84 05 + ;*********************************************************** + ld a,(nn) ;3A 84 05 + ld bc,(nn) ;ED 4B 84 05 + ld de,(nn) ;ED 5B 84 05 + ld hl,(nn) ;2A 84 05 + ld sp,(nn) ;ED 7B 84 05 + ld ix,(nn) ;DD 2A 84 05 + ld iy,(nn) ;FD 2A 84 05 + ;*********************************************************** + ld bc,#nn ;01 84 05 + ld de,#nn ;11 84 05 + ld hl,#nn ;21 84 05 + ld sp,#nn ;31 84 05 + ld ix,#nn ;DD 21 84 05 + ld iy,#nn ;FD 21 84 05 + ;*********************************************************** + ld sp,hl ;F9 + ld sp,ix ;DD F9 + ld sp,iy ;FD F9 + ;*********************************************************** + ; load location (hl) + ; with location (de) + ; decrement de, hl + ; decrement bc + ldd ;ED A8 + ;*********************************************************** + ; load location (hl) + ; with location (de) + ; decrement de, hl + ; decrement bc + ; repeat until bc = 0 + lddr ;ED B8 + ;*********************************************************** + ; load location (hl) + ; with location (de) + ; increment de, hl + ; decrement bc + ldi ;ED A0 + ;*********************************************************** + ; load location (hl) + ; with location (de) + ; increment de, hl + ; decrement bc + ; repeat until bc = 0 + ldir ;ED B0 + ;*********************************************************** + ; 2's complement of 'a' + neg ;ED 44 + ;*********************************************************** + ; no operation + nop ;00 + ;*********************************************************** + ; logical 'or' operand with 'a' + or a,(hl) ;B6 + or a,offset(ix) ;DD B6 55 + or a,offset(iy) ;FD B6 55 + or a,a ;B7 + or a,b ;B0 + or a,c ;B1 + or a,d ;B2 + or a,e ;B3 + or a,h ;B4 + or a,l ;B5 + or a,#n ;F6 20 + ;*********************************************************** + ; load output port (c) + ; with location (hl) + ; decrement hl and decrement b + ; repeat until b = 0 + otdr ;ED BB + ;*********************************************************** + ; load output port (c) + ; with location (hl) + ; increment hl and decrement b + ; repeat until b = 0 + otir ;ED B3 + ;*********************************************************** + ; load output port (c) with reg + out (c),a ;ED 79 + out (c),b ;ED 41 + out (c),c ;ED 49 + out (c),d ;ED 51 + out (c),e ;ED 59 + out (c),h ;ED 61 + out (c),l ;ED 69 + ;*********************************************************** + ; load output port (n) with 'a' + out (n),a ;D3 20 + ;*********************************************************** + ; load output port (c) + ; with location (hl) + ; decrement hl and decrement b + outd ;ED AB + ;*********************************************************** + ; load output port (c) + ; with location (hl) + ; increment hl and decrement b + outi ;ED A3 + ;*********************************************************** + ; load destination with top of stack + pop af ;F1 + pop bc ;C1 + pop de ;D1 + pop hl ;E1 + pop ix ;DD E1 + pop iy ;FD E1 + ;*********************************************************** + ; put source on stack + push af ;F5 + push bc ;C5 + push de ;D5 + push hl ;E5 + push ix ;DD E5 + push iy ;FD E5 + ;*********************************************************** + ; reset bit of location or register + res 0,(hl) ;CB 86 + res 0,offset(ix) ;DD CB 55 86 + res 0,offset(iy) ;FD CB 55 86 + res 0,a ;CB 87 + res 0,b ;CB 80 + res 0,c ;CB 81 + res 0,d ;CB 82 + res 0,e ;CB 83 + res 0,h ;CB 84 + res 0,l ;CB 85 + res 1,(hl) ;CB 8E + res 1,offset(ix) ;DD CB 55 8E + res 1,offset(iy) ;FD CB 55 8E + res 1,a ;CB 8F + res 1,b ;CB 88 + res 1,c ;CB 89 + res 1,d ;CB 8A + res 1,e ;CB 8B + res 1,h ;CB 8C + res 1,l ;CB 8D + res 2,(hl) ;CB 96 + res 2,offset(ix) ;DD CB 55 96 + res 2,offset(iy) ;FD CB 55 96 + res 2,a ;CB 97 + res 2,b ;CB 90 + res 2,c ;CB 91 + res 2,d ;CB 92 + res 2,e ;CB 93 + res 2,h ;CB 94 + res 2,l ;CB 95 + res 3,(hl) ;CB 9E + res 3,offset(ix) ;DD CB 55 9E + res 3,offset(iy) ;FD CB 55 9E + res 3,a ;CB 9F + res 3,b ;CB 98 + res 3,c ;CB 99 + res 3,d ;CB 9A + res 3,e ;CB 9B + res 3,h ;CB 9C + res 3,l ;CB 9D + res 4,(hl) ;CB A6 + res 4,offset(ix) ;DD CB 55 A6 + res 4,offset(iy) ;FD CB 55 A6 + res 4,a ;CB A7 + res 4,b ;CB A0 + res 4,c ;CB A1 + res 4,d ;CB A2 + res 4,e ;CB A3 + res 4,h ;CB A4 + res 4,l ;CB A5 + res 5,(hl) ;CB AE + res 5,offset(ix) ;DD CB 55 AE + res 5,offset(iy) ;FD CB 55 AE + res 5,a ;CB AF + res 5,b ;CB A8 + res 5,c ;CB A9 + res 5,d ;CB AA + res 5,e ;CB AB + res 5,h ;CB AC + res 5,l ;CB AD + res 6,(hl) ;CB B6 + res 6,offset(ix) ;DD CB 55 B6 + res 6,offset(iy) ;FD CB 55 B6 + res 6,a ;CB B7 + res 6,b ;CB B0 + res 6,c ;CB B1 + res 6,d ;CB B2 + res 6,e ;CB B3 + res 6,h ;CB B4 + res 6,l ;CB B5 + res 7,(hl) ;CB BE + res 7,offset(ix) ;DD CB 55 BE + res 7,offset(iy) ;FD CB 55 BE + res 7,a ;CB BF + res 7,b ;CB B8 + res 7,c ;CB B9 + res 7,d ;CB BA + res 7,e ;CB BB + res 7,h ;CB BC + res 7,l ;CB BD + ;*********************************************************** + ; return from subroutine + ret ;C9 + ;*********************************************************** + ; return from subroutine if condition is true + ret C ;D8 + ret M ;F8 + ret NC ;D0 + ret NZ ;C0 + ret P ;F0 + ret PE ;E8 + ret PO ;E0 + ret Z ;C8 + ;*********************************************************** + ; return from interrupt + reti ;ED 4D + ;*********************************************************** + ; return from non-maskable interrupt + retn ;ED 45 + ;*********************************************************** + ; rotate left through carry + rl a,(hl) ;CB 16 + rl a,offset(ix) ;DD CB 55 16 + rl a,offset(iy) ;FD CB 55 16 + rl a,a ;CB 17 + rl a,b ;CB 10 + rl a,c ;CB 11 + rl a,d ;CB 12 + rl a,e ;CB 13 + rl a,h ;CB 14 + rl a,l ;CB 15 + ;*********************************************************** + ; rotate left 'a' with carry + rla ;17 + ;*********************************************************** + ; rotate left circular + rlc a,(hl) ;CB 06 + rlc a,offset(ix) ;DD CB 55 06 + rlc a,offset(iy) ;FD CB 55 06 + rlc a,a ;CB 07 + rlc a,b ;CB 00 + rlc a,c ;CB 01 + rlc a,d ;CB 02 + rlc a,e ;CB 03 + rlc a,h ;CB 04 + rlc a,l ;CB 05 + ;*********************************************************** + ; rotate left 'a' circular + rlca ;07 + ;*********************************************************** + ; rotate digit left and right + ; between 'a' and location (hl) + rld ;ED 6F + ;*********************************************************** + ; rotate right through carry + rr a,(hl) ;CB 1E + rr a,offset(ix) ;DD CB 55 1E + rr a,offset(iy) ;FD CB 55 1E + rr a,a ;CB 1F + rr a,b ;CB 18 + rr a,c ;CB 19 + rr a,d ;CB 1A + rr a,e ;CB 1B + rr a,h ;CB 1C + rr a,l ;CB 1D + ;*********************************************************** + ; rotate 'a' right with carry + rra ;1F + ;*********************************************************** + ; rotate right circular + rrc a,(hl) ;CB 0E + rrc a,offset(ix) ;DD CB 55 0E + rrc a,offset(iy) ;FD CB 55 0E + rrc a,a ;CB 0F + rrc a,b ;CB 08 + rrc a,c ;CB 09 + rrc a,d ;CB 0A + rrc a,e ;CB 0B + rrc a,h ;CB 0C + rrc a,l ;CB 0D + ;*********************************************************** + ; rotate 'a' right circular + rrca ;0F + ;*********************************************************** + ; rotate digit right and left + ; between 'a' and location (hl) + rrd ;ED 67 + ;*********************************************************** + ; restart location + rst 0x00 ;C7 + rst 0x08 ;CF + rst 0x10 ;D7 + rst 0x18 ;DF + rst 0x20 ;E7 + rst 0x28 ;EF + rst 0x30 ;F7 + rst 0x38 ;FF + ;*********************************************************** + ; subtract with carry to 'a' + sbc a,(hl) ;9E + sbc a,offset(ix) ;DD 9E 55 + sbc a,offset(iy) ;FD 9E 55 + sbc a,a ;9F + sbc a,b ;98 + sbc a,c ;99 + sbc a,d ;9A + sbc a,e ;9B + sbc a,h ;9C + sbc a,l ;9D + sbc a,#n ;DE 20 + ;*********************************************************** + ; add with carry register pair to 'hl' + sbc hl,bc ;ED 42 + sbc hl,de ;ED 52 + sbc hl,hl ;ED 62 + sbc hl,sp ;ED 72 + ;*********************************************************** + ; set carry flag (C=1) + scf ;37 + ;*********************************************************** + ; set bit of location or register + set 0,(hl) ;CB C6 + set 0,offset(ix) ;DD CB 55 C6 + set 0,offset(iy) ;FD CB 55 C6 + set 0,a ;CB C7 + set 0,b ;CB C0 + set 0,c ;CB C1 + set 0,d ;CB C2 + set 0,e ;CB C3 + set 0,h ;CB C4 + set 0,l ;CB C5 + set 1,(hl) ;CB CE + set 1,offset(ix) ;DD CB 55 CE + set 1,offset(iy) ;FD CB 55 CE + set 1,a ;CB CF + set 1,b ;CB C8 + set 1,c ;CB C9 + set 1,d ;CB CA + set 1,e ;CB CB + set 1,h ;CB CC + set 1,l ;CB CD + set 2,(hl) ;CB D6 + set 2,offset(ix) ;DD CB 55 D6 + set 2,offset(iy) ;FD CB 55 D6 + set 2,a ;CB D7 + set 2,b ;CB D0 + set 2,c ;CB D1 + set 2,d ;CB D2 + set 2,e ;CB D3 + set 2,h ;CB D4 + set 2,l ;CB D5 + set 3,(hl) ;CB DE + set 3,offset(ix) ;DD CB 55 DE + set 3,offset(iy) ;FD CB 55 DE + set 3,a ;CB DF + set 3,b ;CB D8 + set 3,c ;CB D9 + set 3,d ;CB DA + set 3,e ;CB DB + set 3,h ;CB DC + set 3,l ;CB DD + set 4,(hl) ;CB E6 + set 4,offset(ix) ;DD CB 55 E6 + set 4,offset(iy) ;FD CB 55 E6 + set 4,a ;CB E7 + set 4,b ;CB E0 + set 4,c ;CB E1 + set 4,d ;CB E2 + set 4,e ;CB E3 + set 4,h ;CB E4 + set 4,l ;CB E5 + set 5,(hl) ;CB EE + set 5,offset(ix) ;DD CB 55 EE + set 5,offset(iy) ;FD CB 55 EE + set 5,a ;CB EF + set 5,b ;CB E8 + set 5,c ;CB E9 + set 5,d ;CB EA + set 5,e ;CB EB + set 5,h ;CB EC + set 5,l ;CB ED + set 6,(hl) ;CB F6 + set 6,offset(ix) ;DD CB 55 F6 + set 6,offset(iy) ;FD CB 55 F6 + set 6,a ;CB F7 + set 6,b ;CB F0 + set 6,c ;CB F1 + set 6,d ;CB F2 + set 6,e ;CB F3 + set 6,h ;CB F4 + set 6,l ;CB F5 + set 7,(hl) ;CB FE + set 7,offset(ix) ;DD CB 55 FE + set 7,offset(iy) ;FD CB 55 FE + set 7,a ;CB FF + set 7,b ;CB F8 + set 7,c ;CB F9 + set 7,d ;CB FA + set 7,e ;CB FB + set 7,h ;CB FC + set 7,l ;CB FD + ;*********************************************************** + ; shift operand left arithmetic + sla a,(hl) ;CB 26 + sla a,offset(ix) ;DD CB 55 26 + sla a,offset(iy) ;FD CB 55 26 + sla a,a ;CB 27 + sla a,b ;CB 20 + sla a,c ;CB 21 + sla a,d ;CB 22 + sla a,e ;CB 23 + sla a,h ;CB 24 + sla a,l ;CB 25 + ;*********************************************************** + ; shift operand right arithmetic + sra a,(hl) ;CB 2E + sra a,offset(ix) ;DD CB 55 2E + sra a,offset(iy) ;FD CB 55 2E + sra a,a ;CB 2F + sra a,b ;CB 28 + sra a,c ;CB 29 + sra a,d ;CB 2A + sra a,e ;CB 2B + sra a,h ;CB 2C + sra a,l ;CB 2D + ;*********************************************************** + ; shift operand right logical + srl a,(hl) ;CB 3E + srl a,offset(ix) ;DD CB 55 3E + srl a,offset(iy) ;FD CB 55 3E + srl a,a ;CB 3F + srl a,b ;CB 38 + srl a,c ;CB 39 + srl a,d ;CB 3A + srl a,e ;CB 3B + srl a,h ;CB 3C + srl a,l ;CB 3D + ;*********************************************************** + ; subtract operand from 'a' + sub a,(hl) ;96 + sub a,offset(ix) ;DD 96 55 + sub a,offset(iy) ;FD 96 55 + sub a,a ;97 + sub a,b ;90 + sub a,c ;91 + sub a,d ;92 + sub a,e ;93 + sub a,h ;94 + sub a,l ;95 + sub a,#n ;D6 20 + ;*********************************************************** + ; logical 'xor' operand with 'a' + xor a,(hl) ;AE + xor a,offset(ix) ;DD AE 55 + xor a,offset(iy) ;FD AE 55 + xor a,a ;AF + xor a,b ;A8 + xor a,c ;A9 + xor a,d ;AA + xor a,e ;AB + xor a,h ;AC + xor a,l ;AD + xor a,#n ;EE 20 + + .page + ;*********************************************************** + ; Hitachi HD64180 Codes + ;*********************************************************** + + .hd64 + + ;*********************************************************** + ; load register with input from port (n) + in0 a,(n) ;ED 38 20 + in0 b,(n) ;ED 00 20 + in0 c,(n) ;ED 08 20 + in0 d,(n) ;ED 10 20 + in0 e,(n) ;ED 18 20 + in0 h,(n) ;ED 20 20 + in0 l,(n) ;ED 28 20 + ;*********************************************************** + ; multiplication of each half + ; of the specified register pair + ; with the 16-bit result going to + ; the specified register pair + mlt bc ;ED 4C + mlt de ;ED 5C + mlt hl ;ED 6C + mlt sp ;ED 7C + ;*********************************************************** + ; load output port (c) with + ; location (hl), + ; decrement hl and b + ; decrement c + otdm ;ED 8B + ;*********************************************************** + ; load output port (c) with + ; location (hl), + ; decrement hl and c + ; decrement b + ; repeat until b = 0 + otdmr ;ED 9B + ;*********************************************************** + ; load output port (c) with + ; location (hl), + ; increment hl and b + ; decrement c + otim ;ED 83 + ;*********************************************************** + ; load output port (c) with + ; location (hl), + ; increment hl and c + ; decrement b + ; repeat until b = 0 + otimr ;ED 93 + ;*********************************************************** + ; load output port (n) from register + out0 (n),a ;ED 39 20 + out0 (n),b ;ED 01 20 + out0 (n),c ;ED 09 20 + out0 (n),d ;ED 11 20 + out0 (n),e ;ED 19 20 + out0 (n),h ;ED 21 20 + out0 (n),l ;ED 29 20 + ;*********************************************************** + ; enter sleep mode + slp ;ED 76 + ;*********************************************************** + ; non-destructive'and' with accumulator and specified operand + tst a ;ED 3C + tst b ;ED 04 + tst c ;ED 0C + tst d ;ED 14 + tst e ;ED 1C + tst h ;ED 24 + tst l ;ED 2C + tst #n ;ED 64 20 + tst (hl) ;ED 34 + ;*********************************************************** + ; non-destructive 'and' of n and the contents of port (c) + tstio #n ;ED 74 20 + ;*********************************************************** + diff --git a/as/z80/tz80l.asm b/as/z80/tz80l.asm new file mode 100644 index 00000000..aec2ba2f --- /dev/null +++ b/as/z80/tz80l.asm @@ -0,0 +1,47 @@ + .sbttl Assembler Link Tests + + .module tz80l + + ; This file and TCONST.ASM should be assembled and linked. + ; + ; ASZ80 -XGOL TZ80L + ; ASZ80 -XGOL TCONST + ; + ; ASLINK -C + ; -XMS + ; TZ80L + ; TCONST + ; -E + ; + ; The following tests verify the correct processing of + ; external references for the branches. + ; + ; *L signifies an error will be reported at link time. + + ; branch test must be first + + .area TEST (ABS,OVR) + + .blkb 0x7E ;bra1: + jr C,bra1 ; 38 00 [38 80] + .blkb 0x7F ;bra2: + jr C,bra2 ;*L 38 00 [38 7F] + jr C,bra3 ; 38 00 [38 7F] + .blkb 0x7F + .blkb 0x00 ;bra3: + jr C,bra4 ;*L 38 00 [38 [80] + .blkb 0x80 + .blkb 0x00 ;bra4: + + .blkb 0x7E ;bra5: + jr C,bra5 ; 38 00 [38 80] + .blkb 0x7F ;bra6: + jr C,bra6 ;*L 38 00 [38 7F] + jr C,bra7 ; 38 00 [38 7F] + .blkb 0x7F + .blkb 0x00 ;bra7: + jr C,bra8 ;*L 38 00 [38 [80] + .blkb 0x80 + .blkb 0x00 ;bra8: + + diff --git a/as/z80/z80.h b/as/z80/z80.h new file mode 100644 index 00000000..da163f8d --- /dev/null +++ b/as/z80/z80.h @@ -0,0 +1,192 @@ +/* z80.h */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +/*)BUILD + $(PROGRAM) = ASZ80 + $(INCLUDE) = { + ASM.H + Z80.H + } + $(FILES) = { + Z80EXT.C + Z80MCH.C + Z80ADR.C + Z80PST.C + ASMAIN.C + ASLEX.C + ASSYM.C + ASSUBR.C + ASEXPR.C + ASDATA.C + ASLIST.C + ASOUT.C + } + $(STACK) = 2000 +*/ + +/* + * Indirect Addressing delimeters + */ +#define LFIND '(' +#define RTIND ')' + +/* + * Registers + */ +#define B 0 +#define C 1 +#define D 2 +#define E 3 +#define H 4 +#define L 5 +#define A 7 + +#define I 0107 +#define R 0117 + +#define BC 0 +#define DE 1 +#define HL 2 +#define SP 3 +#define AF 4 +#ifndef GAMEBOY +#define IX 5 +#define IY 6 +#else /* GAMEBOY */ +#define HLD 5 +#define HLI 6 +#endif /* GAMEBOY */ + +/* + * Conditional definitions + */ +#define NZ 0 +#define Z 1 +#define NC 2 +#define CS 3 +#ifndef GAMEBOY +#define PO 4 +#define PE 5 +#define P 6 +#define M 7 +#endif /* GAMEBOY */ + +/* + * Symbol types + */ +#define S_IMMED 30 +#define S_R8 31 +#define S_R8X 32 +#define S_R16 33 +#define S_R16X 34 +#define S_CND 35 +#define S_FLAG 36 + +/* + * Indexing modes + */ +#define S_INDB 40 +#define S_IDC 41 +#define S_INDR 50 +#define S_IDBC 50 +#define S_IDDE 51 +#define S_IDHL 52 +#define S_IDSP 53 +#ifndef GAMEBOY +#define S_IDIX 55 +#define S_IDIY 56 +#else /* GAMEBOY */ +#define S_IDHLD 55 +#define S_IDHLI 56 +#endif /* GAMEBOY */ +#define S_INDM 57 + +/* + * Instruction types + */ +#define S_LD 60 +#define S_CALL 61 +#define S_JP 62 +#define S_JR 63 +#define S_RET 64 +#define S_BIT 65 +#define S_INC 66 +#define S_DEC 67 +#define S_ADD 68 +#define S_ADC 69 +#define S_AND 70 +#ifndef GAMEBOY +#define S_EX 71 +#endif /* GAMEBOY */ +#define S_PUSH 72 +#ifndef GAMEBOY +#define S_IN 73 +#define S_OUT 74 +#endif /* GAMEBOY */ +#define S_RL 75 +#define S_RST 76 +#define S_IM 77 +#define S_INH1 78 +#ifndef GAMEBOY +#define S_INH2 79 +#define S_DJNZ 80 +#endif /* GAMEBOY */ +#define S_SUB 81 +#define S_SBC 82 +#ifdef GAMEBOY +#define S_STOP 83 +#define S_LDH 84 +#define S_LDA 85 +#define S_LDHL 86 +#endif /* GAMEBOY */ + +/* + * HD64180 Instructions + */ +#define X_HD64 90 +#define X_INH2 91 +#define X_IN 92 +#define X_OUT 93 +#define X_MLT 94 +#define X_TST 95 +#define X_TSTIO 96 + +struct adsym +{ + char a_str[4]; /* addressing string */ + int a_val; /* addressing mode value */ +}; + +extern struct adsym R8[]; +extern struct adsym R8X[]; +extern struct adsym R16[]; +extern struct adsym R16X[]; +extern struct adsym CND[]; + + /* machine dependent functions */ + + /* z80adr.c */ +extern int addr(); +extern int admode(); +extern int any(); +extern int srch(); + + /* z80mch.c */ +extern int comma(); +extern int genop(); +extern int gixiy(); +extern VOID machin(); +extern VOID minit(); + diff --git a/as/z80/z80adr.c b/as/z80/z80adr.c new file mode 100644 index 00000000..038adb8f --- /dev/null +++ b/as/z80/z80adr.c @@ -0,0 +1,256 @@ +/* z80adr.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include "asm.h" +#include "z80.h" + +/* + * Read an address specifier. Pack the + * address information into the supplied + * `expr' structure. Return the mode of + * the address. + * + * This addr(esp) routine performs the following addressing decoding: + * + * address mode flag addr base + * #n S_IMMED 0 n NULL + * label s_type ---- s_addr s_area + * [REG] S_IND+icode 0 0 NULL + * [label] S_INDM ---- s_addr s_area + * offset[REG] S_IND+icode ---- offset ---- + */ +int +addr(esp) +register struct expr *esp; +{ + register c, mode, indx; + + if ((c = getnb()) == '#') { + expr(esp, 0); + esp->e_mode = S_IMMED; + } else + if (c == LFIND) { + if ((indx = admode(R8)) != 0) { + mode = S_INDB; + } else + if ((indx = admode(R16)) != 0) { + mode = S_INDR; + } else + if ((indx = admode(R8X)) != 0) { + mode = S_R8X; + aerr(); + } else + if ((indx = admode(R16X)) != 0) { + mode = S_R16X; + aerr(); + } else { + expr(esp, 0); + esp->e_mode = S_INDM; + } + if (indx) { + esp->e_mode = mode + indx&0xFF; + esp->e_base.e_ap = NULL; + } + if ((c = getnb()) != RTIND) + qerr(); + } else { + unget(c); + if ((indx = admode(R8)) != 0) { + mode = S_R8; + } else + if ((indx = admode(R16)) != 0) { + mode = S_R16; + } else + if ((indx = admode(R8X)) != 0) { + mode = S_R8X; + } else + if ((indx = admode(R16X)) != 0) { + mode = S_R16X; + } else { + expr(esp, 0); + esp->e_mode = S_USER; + } + if (indx) { + esp->e_addr = indx&0xFF; + esp->e_mode = mode; + esp->e_base.e_ap = NULL; + } + if ((c = getnb()) == LFIND) { +#ifndef GAMEBOY + if ((indx=admode(R16))!=0 + && ((indx&0xFF)==IX || (indx&0xFF)==IY)) { +#else /* GAMEBOY */ + if ((indx=admode(R16))!=0) { +#endif /* GAMEBOY */ + esp->e_mode = S_INDR + (indx&0xFF); + } else { + aerr(); + } + if ((c = getnb()) != RTIND) + qerr(); + } else { + unget(c); + } + } + return (esp->e_mode); +} + +/* + * Enter admode() to search a specific addressing mode table + * for a match. Return the addressing value on a match or + * zero for no match. + */ +int +admode(sp) +register struct adsym *sp; +{ + register char *ptr; + register int i; + register char *ips; + + ips = ip; + unget(getnb()); + + i = 0; + while ( *(ptr = (char *) &sp[i]) ) { + if (srch(ptr)) { + return(sp[i].a_val); + } + i++; + } + ip = ips; + return(0); +} + +/* + * srch --- does string match ? + */ +int +srch(str) +register char *str; +{ + register char *ptr; + ptr = ip; + +#if CASE_SENSITIVE + while (*ptr && *str) { + if (*ptr != *str) + break; + ptr++; + str++; + } + if (*ptr == *str) { + ip = ptr; + return(1); + } +#else + while (*ptr && *str) { + if (ccase[*ptr] != ccase[*str]) + break; + ptr++; + str++; + } + if (ccase[*ptr] == ccase[*str]) { + ip = ptr; + return(1); + } +#endif + + if (!*str) + if (any(*ptr," \t\n,);")) { + ip = ptr; + return(1); + } + return(0); +} + +/* + * any --- does str contain c? + */ +int +any(c,str) +char c, *str; +{ + while (*str) + if(*str++ == c) + return(1); + return(0); +} + +/* + * Registers + */ + +struct adsym R8[] = { + "b", B|0400, + "c", C|0400, + "d", D|0400, + "e", E|0400, + "h", H|0400, + "l", L|0400, + "a", A|0400, + "", 0000 +}; + +struct adsym R8X[] = { + "i", I|0400, + "r", R|0400, + "", 0000 +}; + +struct adsym R16[] = { + "bc", BC|0400, + "de", DE|0400, + "hl", HL|0400, + "sp", SP|0400, +#ifndef GAMEBOY + "ix", IX|0400, + "iy", IY|0400, +#else /* GAMEBOY */ + "hl-", HLD|0400, + "hl+", HLI|0400, + "hld", HLD|0400, + "hli", HLI|0400, +#endif /* GAMEBOY */ + "", 0000 +}; + +struct adsym R16X[] = { + "af", AF|0400, +#ifndef GAMEBOY + "af'", AF|0400, +#endif /* GAMEBOY */ + "", 0000 +}; + +/* + * Conditional definitions + */ + +struct adsym CND[] = { + "NZ", NZ|0400, + "Z", Z |0400, + "NC", NC|0400, + "C", CS|0400, +#ifndef GAMEBOY + "PO", PO|0400, + "PE", PE|0400, + "P", P |0400, + "M", M |0400, +#endif /* GAMEBOY */ + "", 0000 +}; diff --git a/as/z80/z80ext.c b/as/z80/z80ext.c new file mode 100644 index 00000000..4ae945a9 --- /dev/null +++ b/as/z80/z80ext.c @@ -0,0 +1,27 @@ +/* z80ext.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include "asm.h" +#include "z80.h" + +#ifndef GAMEBOY +char *cpu = "Zilog Z80 / Hitachi HD64180"; +#else /* GAMEBOY */ +char *cpu = "GameBoy Z80-like CPU"; +#endif /* GAMEBOY */ +int hilo = 0; +char *dsft = "ASM"; diff --git a/as/z80/z80mch.c b/as/z80/z80mch.c new file mode 100644 index 00000000..78508748 --- /dev/null +++ b/as/z80/z80mch.c @@ -0,0 +1,773 @@ +/* z80mch.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include "asm.h" +#include "z80.h" + +char imtab[3] = { 0x46, 0x56, 0x5E }; +#ifndef GAMEBOY +int hd64; +#endif /* GAMEBOY */ + +/* + * Process a machine op. + */ +VOID +machine(mp) +struct mne *mp; +{ + register op, t1, t2; + struct expr e1, e2; + int rf, v1, v2; + + clrexpr(&e1); + clrexpr(&e2); + op = mp->m_valu; + rf = mp->m_type; +#ifndef GAMEBOY + if (!hd64 && rf>X_HD64) + rf = 0; +#endif /* GAMEBOY */ + switch (rf) { + + case S_INH1: + outab(op); + break; + +#ifndef GAMEBOY + case S_INH2: + outab(0xED); + outab(op); + break; +#endif /* GAMEBOY */ + + case S_RET: + if (more()) { + if ((v1 = admode(CND)) != 0) { + outab(op | v1<<3); + } else { + qerr(); + } + } else { + outab(0xC9); + } + break; + + case S_PUSH: + if (admode(R16X)) { + outab(op+0x30); + break; + } else + if ((v1 = admode(R16)) != 0 && (v1 &= 0xFF) != SP) { + if (v1 != gixiy(v1)) { + outab(op+0x20); + break; + } + outab(op | v1<<4); + break; + } + aerr(); + break; + + case S_RST: + v1 = absexpr(); + if (v1 & ~0x38) { + aerr(); + v1 = 0; + } + outab(op|v1); + break; + + case S_IM: + expr(&e1, 0); + abscheck(&e1); + if (e1.e_addr > 2) { + aerr(); + e1.e_addr = 0; + } + outab(op); + outab(imtab[e1.e_addr]); + break; + + case S_BIT: + expr(&e1, 0); + t1 = 0; + v1 = e1.e_addr; + if (v1 > 7) { + ++t1; + v1 &= 0x07; + } + op |= (v1<<3); + comma(); + addr(&e2); + abscheck(&e1); + if (genop(0xCB, op, &e2, 0) || t1) + aerr(); + break; + + case S_RL: + t1 = 0; + t2 = addr(&e2); + if (more()) { + if ((t2 != S_R8) || (e2.e_addr != A)) + ++t1; + comma(); + t2 = addr(&e2); + } + if (genop(0xCB, op, &e2, 0) || t1) + aerr(); + break; + + case S_AND: + case S_SUB: + t1 = 0; + t2 = addr(&e2); + if (more()) { + if ((t2 != S_R8) || (e2.e_addr != A)) + ++t1; + comma(); + t2 = addr(&e2); + } + if (genop(0, op, &e2, 1) || t1) + aerr(); + break; + + case S_ADD: + case S_ADC: + case S_SBC: + t1 = addr(&e1); + t2 = 0; + if (more()) { + comma(); + t2 = addr(&e2); + } + if (t2 == 0) { + if (genop(0, op, &e1, 1)) + aerr(); + break; + } + if ((t1 == S_R8) && (e1.e_addr == A)) { + if (genop(0, op, &e2, 1)) + aerr(); + break; + } + if ((t1 == S_R16) && (t2 == S_R16)) { +#ifndef GAMEBOY + if (rf == S_ADD) + op = 0x09; + if (rf == S_ADC) + op = 0x4A; + if (rf == S_SBC) + op = 0x42; + v1 = e1.e_addr; + v2 = e2.e_addr; + if ((v1 == HL) && (v2 <= SP)) { + if (rf != S_ADD) + outab(0xED); + outab(op | (v2<<4)); + break; + } + if (rf != S_ADD) { + aerr(); + break; + } + if ((v1 == IX) && (v2 != HL) && (v2 != IY)) { + if (v2 == IX) + v2 = HL; + outab(0xDD); + outab(op | (v2<<4)); + break; + } + if ((v1 == IY) && (v2 != HL) && (v2 != IX)) { + if (v2 == IY) + v2 = HL; + outab(0xFD); + outab(op | (v2<<4)); + break; + } + } +#else /* GAMEBOY */ + v1 = e1.e_addr; + v2 = e2.e_addr; + if ((v1 == HL) && (v2 <= SP) && (rf == S_ADD)) { + outab(0x09 | (v2<<4)); + break; + } + } + /* + * 0xE8 : ADD SP,#n + */ + if ((rf == S_ADD) && (t1 == S_R16) && (e1.e_addr == SP) && (t2 == S_IMMED)) { + outab(0xE8); + outrb(&e2,0); + break; + } +#endif /* GAMEBOY */ + aerr(); + break; + + case S_LD: + t1 = addr(&e1); + comma(); + t2 = addr(&e2); + if (t1 == S_R8) { + v1 = op | e1.e_addr<<3; + if (genop(0, v1, &e2, 0) == 0) + break; + if (t2 == S_IMMED) { + outab(e1.e_addr<<3 | 0x06); + outrb(&e2,0); + break; + } + } + v1 = e1.e_addr; + v2 = e2.e_addr; + if ((t1 == S_R16) && (t2 == S_IMMED)) { + v1 = gixiy(v1); + outab(0x01|v1<<4); + outrw(&e2, 0); + break; + } +#ifndef GAMEBOY + if ((t1 == S_R16) && (t2 == S_INDM)) { + if (gixiy(v1) == HL) { + outab(0x2A); + } else { + outab(0xED); + outab(0x4B | v1<<4); + } + outrw(&e2, 0); + break; + } + if ((t1 == S_INDM) && (t2 == S_R16)) { + if (gixiy(v2) == HL) { + outab(0x22); + } else { + outab(0xED); + outab(0x43 | v2<<4); + } + outrw(&e1, 0); + break; + } + if ((t1 == S_R8) && (v1 == A) && (t2 == S_INDM)) { + outab(0x3A); + outrw(&e2, 0); + break; + } + if ((t1 == S_INDM) && (t2 == S_R8) && (v2 == A)) { + outab(0x32); + outrw(&e1, 0); + break; + } +#endif /* GAMEBOY */ + if ((t2 == S_R8) && (gixiy(t1) == S_IDHL)) { + outab(0x70|v2); + if (t1 != S_IDHL) + outrb(&e1, 0); + break; + } + if ((t2 == S_IMMED) && (gixiy(t1) == S_IDHL)) { + outab(0x36); + if (t1 != S_IDHL) + outrb(&e1, 0); + outrb(&e2, 0); + break; + } +#ifndef GAMEBOY + if ((t1 == S_R8X) && (t2 == S_R8) && (v2 == A)) { + outab(0xED); + outab(v1); + break; + } + if ((t1 == S_R8) && (v1 == A) && (t2 == S_R8X)) { + outab(0xED); + outab(v2|0x10); + break; + } +#endif /* GAMEBOY */ + if ((t1 == S_R16) && (v1 == SP)) { + if ((t2 == S_R16) && (gixiy(v2) == HL)) { + outab(0xF9); + break; + } + } + if ((t1 == S_R8) && (v1 == A)) { + if ((t2 == S_IDBC) || (t2 == S_IDDE)) { + outab(0x0A | (t2-S_INDR)<<4); + break; + } + } + if ((t2 == S_R8) && (v2 == A)) { + if ((t1 == S_IDBC) || (t1 == S_IDDE)) { + outab(0x02 | (t1-S_INDR)<<4); + break; + } + } +#ifdef GAMEBOY + /* + * 0x08 : LD (nn),SP + */ + if ((t1 == S_INDM) && (t2 == S_R16) && (v2 == SP)) { + outab(0x08); + outrw(&e1, 0); + break; + } + /* + * 0xEA : LD (nn),A + * 0xFA : LD A,(nn) + */ + if ((t1 == S_INDM) && (t2 == S_R8) && (v2 == A)) { + outab(0xEA); + outrw(&e1, 0); + break; + } + if ((t2 == S_INDM) && (t1 == S_R8) && (v1 == A)) { + outab(0xFA); + outrw(&e2, 0); + break; + } + /* + * 0x32 : LD (HL-),A + * 0x3A : LD A,(HL-) + */ + if ((t1 == S_R8) && (v1 == A) && (t2 == S_IDHLD)) { + outab(0x3A); + break; + } + if ((t2 == S_R8) && (v2 == A) && (t1 == S_IDHLD)) { + outab(0x32); + break; + } + /* + * 0x22 : LD (HL+),A + * 0x2A : LD A,(HL+) + */ + if ((t1 == S_R8) && (v1 == A) && (t2 == S_IDHLI)) { + outab(0x2A); + break; + } + if ((t2 == S_R8) && (v2 == A) && (t1 == S_IDHLI)) { + outab(0x22); + break; + } +#endif /* GAMEBOY */ + aerr(); + break; + + +#ifdef GAMEBOY + case S_STOP: /* 0x10 */ + /* + * 0x10 : STOP + */ + outab(op); + outab(0x00); + break; + + + case S_LDH: /* 0xE0 */ + /* + * 0xE0 : LDH (n),A = LD ($FF00+n),A + * 0xE2 : LDH (C),A = LD ($FF00+C),A + * 0xF0 : LDH A,(n) = LD A,($FF00+n) + * 0xF2 : LDH A,(C) = LD A,($FF00+C) + */ + t1 = addr(&e1); + comma(); + t2 = addr(&e2); + if ((t1 == S_INDM) && (t2 == S_R8) && (e2.e_addr == A)) { + outab(0xE0); + outrb(&e1, 0); + break; + } + if ((t1 == S_IDC) && (t2 == S_R8) && (e2.e_addr == A)) { + outab(0xE2); + break; + } + if ((t2 == S_INDM) && (t1 == S_R8) && (e1.e_addr == A)) { + outab(0xF0); + outrb(&e2, 0); + break; + } + if ((t2 == S_IDC) && (t1 == S_R8) && (e1.e_addr == A)) { + outab(0xF2); + break; + } + aerr(); + break; + + + case S_LDA: /* 0xE8 */ + /* + * 0xE8 : LDA SP,#n(SP) + * 0xF8 : LDA HL,#n(SP) + */ + t1 = addr(&e1); + comma(); + t2 = addr(&e2); + if ((t1 == S_R16) && (e1.e_addr == SP) && (t2 == S_INDR+SP)) { + outab(0xE8); + outrb(&e2,0); + break; + } + if ((t1 == S_R16) && (e1.e_addr == HL) && (t2 == S_INDR+SP)) { + outab(0xF8); + outrb(&e2,0); + break; + } + aerr(); + break; + + + case S_LDHL: /* 0xF8 */ + /* + * 0xF8 : LDHL SP,#n + */ + t1 = addr(&e1); + comma(); + t2 = addr(&e2); + if ((t1 == S_R16) && (e1.e_addr == SP) && (t2 == S_IMMED)) { + outab(0xF8); + outrb(&e2,0); + break; + } + aerr(); + break; +#endif /* GAMEBOY */ + + +#ifndef GAMEBOY + case S_EX: + t1 = addr(&e1); + comma(); + t2 = addr(&e2); + if (t2 == S_R16) { + v1 = e1.e_addr; + v2 = e2.e_addr; + if ((t1 == S_IDSP) && (v1 == 0)) { + if (gixiy(v2) == HL) { + outab(op); + break; + } + } + if (t1 == S_R16) { + if ((v1 == DE) && (v2 == HL)) { + outab(0xEB); + break; + } + } + } + if ((t1 == S_R16X) && (t2 == S_R16X)) { + outab(0x08); + break; + } + aerr(); + break; + + case S_IN: + case S_OUT: + if (rf == S_IN) { + t1 = addr(&e1); + comma(); + t2 = addr(&e2); + } else { + t2 = addr(&e2); + comma(); + t1 = addr(&e1); + } + v1 = e1.e_addr; + v2 = e2.e_addr; + if (t1 == S_R8) { + if ((v1 == A) && (t2 == S_INDM)) { + outab(op); + outab(v2); + break; + } + if (t2 == S_IDC) { + outab(0xED); + outab(((rf == S_IN) ? 0x40 : 0x41) + (v1<<3)); + break; + } + } + aerr(); + break; +#endif /* GAMEBOY */ + + case S_DEC: + case S_INC: + t1 = addr(&e1); + v1 = e1.e_addr; + if (t1 == S_R8) { + outab(op|(v1<<3)); + break; + } + if (t1 == S_IDHL) { + outab(op|0x30); + break; + } + if (t1 != gixiy(t1)) { + outab(op|0x30); + outrb(&e1,0); + break; + } + if (t1 == S_R16) { + v1 = gixiy(v1); + if (rf == S_INC) { + outab(0x03|(v1<<4)); + break; + } + if (rf == S_DEC) { + outab(0x0B|(v1<<4)); + break; + } + } + aerr(); + break; + +#ifndef GAMEBOY + case S_DJNZ: + case S_JR: + if ((v1 = admode(CND)) != 0 && rf != S_DJNZ) { +#else GAMEBOY + case S_JR: + if ((v1 = admode(CND)) != 0) { +#endif /* GAMEBOY */ + if ((v1 &= 0xFF) <= 0x18) { + op += (v1+1)<<3; + } else { + aerr(); + } + comma(); + } + expr(&e2, 0); + outab(op); + if (e2.e_base.e_ap == NULL || e2.e_base.e_ap == dot.s_area) { + v2 = e2.e_addr - dot.s_addr - 1; + if ((v2 < -128) || (v2 > 127)) + aerr(); + outab(v2); + } else { + outrb(&e2, R_PCR); + } + if (e2.e_mode != S_USER) + rerr(); + break; + + case S_CALL: + if ((v1 = admode(CND)) != 0) { + op |= (v1&0xFF)<<3; + comma(); + } else { + op = 0xCD; + } + expr(&e1, 0); + outab(op); + outrw(&e1, 0); + break; + + case S_JP: + if ((v1 = admode(CND)) != 0) { + op |= (v1&0xFF)<<3; + comma(); + expr(&e1, 0); + outab(op); + outrw(&e1, 0); + break; + } + t1 = addr(&e1); + if (t1 == S_USER) { + outab(0xC3); + outrw(&e1, 0); + break; + } + if ((e1.e_addr == 0) && (gixiy(t1) == S_IDHL)) { + outab(0xE9); + break; + } + aerr(); + break; + +#ifndef GAMEBOY + case X_HD64: + ++hd64; + break; + + case X_INH2: + outab(0xED); + outab(op); + break; + + case X_IN: + case X_OUT: + if (rf == X_IN) { + t1 = addr(&e1); + comma(); + t2 = addr(&e2); + } else { + t2 = addr(&e2); + comma(); + t1 = addr(&e1); + } + if ((t1 == S_R8) && (t2 == S_INDM)) { + outab(0xED); + outab(op | e1.e_addr<<3); + outrb(&e2, 0); + break; + } + aerr(); + break; + + case X_MLT: + t1 = addr(&e1); + if ((t1 == S_R16) && ((v1 = e1.e_addr) <= SP)) { + outab(0xED); + outab(op | v1<<4); + break; + } + aerr(); + break; + + case X_TST: + t1 = addr(&e1); + if (t1 == S_R8) { + outab(0xED); + outab(op | e1.e_addr<<3); + break; + } + if (t1 == S_IDHL) { + outab(0xED); + outab(0x34); + break; + } + if (t1 == S_IMMED) { + outab(0xED); + outab(0x64); + outrb(&e1, 0); + break; + } + aerr(); + break; + + case X_TSTIO: + t1 = addr(&e1); + if (t1 == S_IMMED) { + outab(0xED); + outab(op); + outrb(&e1, 0); + break; + } + aerr(); + break; +#endif /* GAMEBOY */ + + default: + err('o'); + } +} + +/* + * general addressing evaluation + * return(0) if general addressing mode output, else + * return(esp->e_mode) + */ +int +genop(pop, op, esp, f) +register int pop, op; +register struct expr *esp; +int f; +{ + register int t1; + if ((t1 = esp->e_mode) == S_R8) { + if (pop) + outab(pop); + outab(op|esp->e_addr); + return(0); + } + if (t1 == S_IDHL) { + if (pop) + outab(pop); + outab(op|0x06); + return(0); + } + if (gixiy(t1) == S_IDHL) { + if (pop) { + outab(pop); + outrb(esp,0); + outab(op|0x06); + } else { + outab(op|0x06); + outrb(esp,0); + } + return(0); + } + if ((t1 == S_IMMED) && (f)) { + if (pop) + outab(pop); + outab(op|0x46); + outrb(esp,0); + return(0); + } + return(t1); +} + +/* + * IX and IY prebyte check + */ +int +gixiy(v) +int v; +{ +#ifndef GAMEBOY + if (v == IX) { + v = HL; + outab(0xDD); + } else if (v == IY) { + v = HL; + outab(0xFD); + } else if (v == S_IDIX) { + v = S_IDHL; + outab(0xDD); + } else if (v == S_IDIY) { + v = S_IDHL; + outab(0xFD); + } +#endif /* GAMEBOY */ + return(v); +} + +/* + * The next character must be a + * comma. + */ +int +comma() +{ + if (getnb() != ',') + qerr(); + return(1); +} + +/* + * Machine dependent initialization + */ +VOID +minit() +{ +#ifndef GAMEBOY + hd64 = 0; +#endif /* GAMEBOY */ +} diff --git a/as/z80/z80pst.c b/as/z80/z80pst.c new file mode 100644 index 00000000..55a68dc3 --- /dev/null +++ b/as/z80/z80pst.c @@ -0,0 +1,179 @@ +/* z80pst.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include "asm.h" +#include "z80.h" + +struct mne mne[] = { + + /* machine */ + + /* system */ + + NULL, "CON", S_ATYP, 0, A_CON, + NULL, "OVR", S_ATYP, 0, A_OVR, + NULL, "REL", S_ATYP, 0, A_REL, + NULL, "ABS", S_ATYP, 0, A_ABS|A_OVR, + NULL, "NOPAG", S_ATYP, 0, A_NOPAG, + NULL, "PAG", S_ATYP, 0, A_PAG, + + NULL, ".byte", S_BYTE, 0, 0, + NULL, ".db", S_BYTE, 0, 0, + NULL, ".word", S_WORD, 0, 0, + NULL, ".dw", S_WORD, 0, 0, + NULL, ".df", S_FLOAT, 0, 0, + NULL, ".ascii", S_ASCII, 0, 0, + NULL, ".asciz", S_ASCIZ, 0, 0, + NULL, ".blkb", S_BLK, 0, 1, + NULL, ".ds", S_BLK, 0, 1, + NULL, ".blkw", S_BLK, 0, 2, + NULL, ".page", S_PAGE, 0, 0, + NULL, ".title", S_TITLE, 0, 0, + NULL, ".sbttl", S_SBTL, 0, 0, + NULL, ".globl", S_GLOBL, 0, 0, + NULL, ".area", S_DAREA, 0, 0, + NULL, ".even", S_EVEN, 0, 0, + NULL, ".odd", S_ODD, 0, 0, + NULL, ".if", S_IF, 0, 0, + NULL, ".else", S_ELSE, 0, 0, + NULL, ".endif", S_ENDIF, 0, 0, + NULL, ".include", S_INCL, 0, 0, + NULL, ".radix", S_RADIX, 0, 0, + NULL, ".org", S_ORG, 0, 0, + NULL, ".module", S_MODUL, 0, 0, + NULL, ".ascis", S_ASCIS, 0, 0, + + /* z80 / hd64180 */ + + NULL, "ld", S_LD, 0, 0x40, + + NULL, "call", S_CALL, 0, 0xC4, + NULL, "jp", S_JP, 0, 0xC2, + NULL, "jr", S_JR, 0, 0x18, +#ifndef GAMEBOY + NULL, "djnz", S_DJNZ, 0, 0x10, +#endif /* GAMEBOY */ + NULL, "ret", S_RET, 0, 0xC0, + + NULL, "bit", S_BIT, 0, 0x40, + NULL, "res", S_BIT, 0, 0x80, + NULL, "set", S_BIT, 0, 0xC0, + + NULL, "inc", S_INC, 0, 0x04, + NULL, "dec", S_DEC, 0, 0x05, + + NULL, "add", S_ADD, 0, 0x80, + NULL, "adc", S_ADC, 0, 0x88, + NULL, "sub", S_SUB, 0, 0x90, + NULL, "sbc", S_SBC, 0, 0x98, + + NULL, "and", S_AND, 0, 0xA0, + NULL, "cp", S_AND, 0, 0xB8, + NULL, "or", S_AND, 0, 0xB0, + NULL, "xor", S_AND, 0, 0xA8, + +#ifndef GAMEBOY + NULL, "ex", S_EX, 0, 0xE3, +#endif /* GAMEBOY */ + + NULL, "push", S_PUSH, 0, 0xC5, + NULL, "pop", S_PUSH, 0, 0xC1, + +#ifndef GAMEBOY + NULL, "in", S_IN, 0, 0xDB, + NULL, "out", S_OUT, 0, 0xD3, +#endif /* GAMEBOY */ + + NULL, "rl", S_RL, 0, 0x10, + NULL, "rlc", S_RL, 0, 0x00, + NULL, "rr", S_RL, 0, 0x18, + NULL, "rrc", S_RL, 0, 0x08, + NULL, "sla", S_RL, 0, 0x20, + NULL, "sra", S_RL, 0, 0x28, + NULL, "srl", S_RL, 0, 0x38, + + NULL, "rst", S_RST, 0, 0xC7, + +#ifndef GAMEBOY + NULL, "im", S_IM, 0, 0xED, +#endif /* GAMEBOY */ + + NULL, "ccf", S_INH1, 0, 0x3F, + NULL, "cpl", S_INH1, 0, 0x2F, + NULL, "daa", S_INH1, 0, 0x27, + NULL, "di", S_INH1, 0, 0xF3, + NULL, "ei", S_INH1, 0, 0xFB, +#ifndef GAMEBOY + NULL, "exx", S_INH1, 0, 0xD9, +#endif /* GAMEBOY */ + NULL, "nop", S_INH1, 0, 0x00, + NULL, "halt", S_INH1, 0, 0x76, + NULL, "rla", S_INH1, 0, 0x17, + NULL, "rlca", S_INH1, 0, 0x07, + NULL, "rra", S_INH1, 0, 0x1F, + NULL, "rrca", S_INH1, 0, 0x0F, + NULL, "scf", S_INH1, 0, 0x37, + +#ifndef GAMEBOY + NULL, "cpd", S_INH2, 0, 0xA9, + NULL, "cpdr", S_INH2, 0, 0xB9, + NULL, "cpi", S_INH2, 0, 0xA1, + NULL, "cpir", S_INH2, 0, 0xB1, + NULL, "ind", S_INH2, 0, 0xAA, + NULL, "indr", S_INH2, 0, 0xBA, + NULL, "ini", S_INH2, 0, 0xA2, + NULL, "inir", S_INH2, 0, 0xB2, + NULL, "ldd", S_INH2, 0, 0xA8, + NULL, "lddr", S_INH2, 0, 0xB8, + NULL, "ldi", S_INH2, 0, 0xA0, + NULL, "ldir", S_INH2, 0, 0xB0, + NULL, "neg", S_INH2, 0, 0x44, + NULL, "otdr", S_INH2, 0, 0xBB, + NULL, "otir", S_INH2, 0, 0xB3, + NULL, "outd", S_INH2, 0, 0xAB, + NULL, "outi", S_INH2, 0, 0xA3, + NULL, "reti", S_INH2, 0, 0x4D, + NULL, "retn", S_INH2, 0, 0x45, + NULL, "rld", S_INH2, 0, 0x6F, + NULL, "rrd", S_INH2, 0, 0x67, + + /* 64180 */ + + NULL, ".hd64", X_HD64, 0, 0, + + NULL, "otdm", X_INH2, 0, 0x8B, + NULL, "otdmr", X_INH2, 0, 0x9B, + NULL, "otim", X_INH2, 0, 0x83, + NULL, "otimr", X_INH2, 0, 0x93, + NULL, "slp", X_INH2, 0, 0x76, + + NULL, "in0", X_IN, 0, 0x00, + NULL, "out0", X_OUT, 0, 0x01, + + NULL, "mlt", X_MLT, 0, 0x4C, + + NULL, "tst", X_TST, 0, 0x04, + NULL, "tstio", X_TSTIO, S_END, 0x74 +#else /* GAMEBOY */ + NULL, "stop", S_STOP, 0, 0x10, + NULL, "swap", S_RL, 0, 0x30, + NULL, "reti", S_INH1, 0, 0xD9, + NULL, "ldh", S_LDH, 0, 0xE0, + NULL, "lda", S_LDA, 0, 0xE8, + NULL, "ldhl", S_LDHL, S_END, 0xF8 +#endif /* GAMEBOY */ +}; diff --git a/clean.mk b/clean.mk new file mode 100644 index 00000000..154ae72d --- /dev/null +++ b/clean.mk @@ -0,0 +1,24 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f bin/* + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f config.cache config.log config.status + rm -f sdccconf.h main.mk *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/conf.mk b/conf.mk new file mode 100644 index 00000000..b7d8f08e --- /dev/null +++ b/conf.mk @@ -0,0 +1,16 @@ +# +# Makefile targets to remake configuration +# + +freshconf: $(srcdir)/configure main.mk + +$(srcdir)/configure: $(srcdir)/configure.in + cd $(srcdir) && $(SHELL) autoconf + +main.mk: $(srcdir)/main_in.mk $(srcdir)/configure.in + $(SHELL) ./config.status + +config.status: $(srcdir)/configure + $(SHELL) ./config.status --recheck + +# End of conf.mk diff --git a/configure b/configure new file mode 100755 index 00000000..77b4483e --- /dev/null +++ b/configure @@ -0,0 +1,2941 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +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' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +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 + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # 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 ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$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" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) 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) + # 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 << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --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 +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$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) + 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 ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + 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 "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# 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 + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=Makefile + +# 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_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + 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 "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# 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 "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + + +for ac_prog in mawk gawk 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:532: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AWK="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +AWK="$ac_cv_prog_AWK" +if test -n "$AWK"; then + echo "$ac_t""$AWK" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$AWK" && break +done + + +echo $ac_n "checking version of the package""... $ac_c" 1>&6 +echo "configure:563: checking version of the package" >&5 +if test -f .version; then + VERSION=`cat .version` +elif test -f ../.version; then + VERSION=`cat ../.version` +else + VERSION="0.0.0" +fi +VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'` +VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'` +VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'` +echo "$ac_t""${VERSION}" 1>&6 + + + + +cat >> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <&6 +echo "configure:605: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:635: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +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 $# -gt 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 + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:686: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:718: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 729 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:760: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:765: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:793: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&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 + +for ac_prog in $CCC c++ g++ gcc CC cxx cc++ 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:829: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CXX="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CXX="$ac_cv_prog_CXX" +if test -n "$CXX"; then + echo "$ac_t""$CXX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CXX" && break +done +test -n "$CXX" || CXX="gcc" + + +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:861: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 + +ac_ext=C +# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cxx_cross + +cat > conftest.$ac_ext << EOF + +#line 872 "configure" +#include "confdefs.h" + +int main(){return(0);} +EOF +if { (eval echo configure:877: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cxx_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cxx_cross=no + else + ac_cv_prog_cxx_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cxx_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 +if test $ac_cv_prog_cxx_works = no; then + { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:903: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 +cross_compiling=$ac_cv_prog_cxx_cross + +echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 +echo "configure:908: checking whether we are using GNU C++" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.C <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gxx=yes +else + ac_cv_prog_gxx=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gxx" 1>&6 + +if test $ac_cv_prog_gxx = yes; then + GXX=yes +else + GXX= +fi + +ac_test_CXXFLAGS="${CXXFLAGS+set}" +ac_save_CXXFLAGS="$CXXFLAGS" +CXXFLAGS= +echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 +echo "configure:936: checking whether ${CXX-g++} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.cc +if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then + ac_cv_prog_cxx_g=yes +else + ac_cv_prog_cxx_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS="$ac_save_CXXFLAGS" +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:968: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:989: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1023: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +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 + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$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 +# 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" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1078: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/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 + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +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 "$ac_t""$INSTALL" 1>&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_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1133: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +for ac_prog in 'bison -y' byacc +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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1165: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_YACC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +YACC="$ac_cv_prog_YACC" +if test -n "$YACC"; then + echo "$ac_t""$YACC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +# Extract the first word of "flex", so it can be a program name with args. +set dummy flex; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1198: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LEX="flex" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_LEX" && ac_cv_prog_LEX="lex" +fi +fi +LEX="$ac_cv_prog_LEX" +if test -n "$LEX"; then + echo "$ac_t""$LEX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$LEXLIB" +then + case "$LEX" in + flex*) ac_lib=fl ;; + *) ac_lib=l ;; + esac + echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 +echo "configure:1232: checking for yywrap in -l$ac_lib" >&5 +ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l$ac_lib $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LEXLIB="-l$ac_lib" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +# Extract the first word of "autoconf", so it can be a program name with args. +set dummy autoconf; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1276: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AUTOCONF'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AUTOCONF"; then + ac_cv_prog_AUTOCONF="$AUTOCONF" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AUTOCONF="autoconf" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AUTOCONF" && ac_cv_prog_AUTOCONF=":" +fi +fi +AUTOCONF="$ac_cv_prog_AUTOCONF" +if test -n "$AUTOCONF"; then + echo "$ac_t""$AUTOCONF" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +# Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1306: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AS="as" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AS" && ac_cv_prog_AS=":" +fi +fi +AS="$ac_cv_prog_AS" +if test -n "$AS"; then + echo "$ac_t""$AS" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +# Extract the first word of "cp", so it can be a program name with args. +set dummy cp; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1336: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CP"; then + ac_cv_prog_CP="$CP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CP="cp" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_CP" && ac_cv_prog_CP=":" +fi +fi +CP="$ac_cv_prog_CP" +if test -n "$CP"; then + echo "$ac_t""$CP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + + +# Checking for header files. +# =========================================================================== +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1375: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1388: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + 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 < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + 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 < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#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); } + +EOF +if { (eval echo configure:1455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +for ac_hdr in getopt.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1482: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1492: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1522: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1532: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in endian.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1562: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1572: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in sys/isa_defs.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1602: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1612: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in sys/socket.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1642: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1652: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 +echo "configure:1683: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> +int main() { +DIR *dirp = 0; +; return 0; } +EOF +if { (eval echo configure:1696: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 +echo "configure:1721: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldir $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -ldir" +else + echo "$ac_t""no" 1>&6 +fi + +else +echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 +echo "configure:1762: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lx $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lx" +else + echo "$ac_t""no" 1>&6 +fi + +fi + + +# This must be after CPP + +echo $ac_n "checking which header file defines FD_ macros""... $ac_c" 1>&6 +echo "configure:1807: checking which header file defines FD_ macros" >&5 +if eval "test \"`echo '$''{'s51_cv_fd'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + sdcc_cv_fd="unknown" +cat > conftest.$ac_ext < +#ifdef FD_ZERO +yes +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "yes" >/dev/null 2>&1; then + rm -rf conftest* + sdcc_cv_fd="" +fi +rm -f conftest* + +cat > conftest.$ac_ext < +#ifdef FD_ZERO +yes +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "yes" >/dev/null 2>&1; then + rm -rf conftest* + sdcc_cv_fd="" +fi +rm -f conftest* + +cat > conftest.$ac_ext < +#ifdef FD_ZERO +yes +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "yes" >/dev/null 2>&1; then + rm -rf conftest* + sdcc_cv_fd="" +fi +rm -f conftest* + +fi + +echo "$ac_t""$s51_cv_fd" 1>&6 + +cat >> confdefs.h <<\EOF +#define FD_HEADER_OK 0 +EOF + +if echo $sdcc_cv_fd|grep time >/dev/null 2>&1; then +cat >> confdefs.h <<\EOF +#define FD_NEED_TIME_H 1 +EOF + +cat >> confdefs.h <<\EOF +#define FD_HEADER_OK 1 +EOF + +else +cat >> confdefs.h <<\EOF +#define FD_NEED_TIME_H 0 +EOF + +fi +if echo $sdcc_cv_fd|grep types >/dev/null 2>&1; then +cat >> confdefs.h <<\EOF +#define FD_NEED_TYPES_H 1 +EOF + +cat >> confdefs.h <<\EOF +#define FD_HEADER_OK 1 +EOF + +else +cat >> confdefs.h <<\EOF +#define FD_NEED_TYPES_H 0 +EOF + +fi +if echo $sdcc_cv_fd|grep select >/dev/null 2>&1; then +cat >> confdefs.h <<\EOF +#define FD_NEED_SELECT_H 1 +EOF + +cat >> confdefs.h <<\EOF +#define FD_HEADER_OK 1 +EOF + +else +cat >> confdefs.h <<\EOF +#define FD_NEED_SELECT_H 0 +EOF + +fi + +cat >> confdefs.h <&6 +echo "configure:1925: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* 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(); + +int main() { + +/* 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 +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in strchr memcpy +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1980: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* 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(); + +int main() { + +/* 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 +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2008: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in fgets +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2035: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* 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(); + +int main() { + +/* 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 +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2063: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in yylex +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2090: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* 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(); + +int main() { + +/* 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 +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + +# check if -lsocket && -lxnet is required to compile socket stuff + +echo $ac_n "checking for library containing socket""... $ac_c" 1>&6 +echo "configure:2146: checking for library containing socket" >&5 +if eval "test \"`echo '$''{'ac_cv_search_socket'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_func_search_save_LIBS="$LIBS" +ac_cv_search_socket="no" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_socket="none required" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +test "$ac_cv_search_socket" = "no" && for i in socket; do +LIBS="-l$i $ac_func_search_save_LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_socket="-l$i" +break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +LIBS="$ac_func_search_save_LIBS" +fi + +echo "$ac_t""$ac_cv_search_socket" 1>&6 +if test "$ac_cv_search_socket" != "no"; then + test "$ac_cv_search_socket" = "none required" || LIBS="$ac_cv_search_socket $LIBS" + +else : + +fi + +echo $ac_n "checking for library containing inet_addr""... $ac_c" 1>&6 +echo "configure:2208: checking for library containing inet_addr" >&5 +if eval "test \"`echo '$''{'ac_cv_search_inet_addr'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_func_search_save_LIBS="$LIBS" +ac_cv_search_inet_addr="no" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_inet_addr="none required" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +test "$ac_cv_search_inet_addr" = "no" && for i in nsl xnet; do +LIBS="-l$i $ac_func_search_save_LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_inet_addr="-l$i" +break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +LIBS="$ac_func_search_save_LIBS" +fi + +echo "$ac_t""$ac_cv_search_inet_addr" 1>&6 +if test "$ac_cv_search_inet_addr" != "no"; then + test "$ac_cv_search_inet_addr" = "none required" || LIBS="$ac_cv_search_inet_addr $LIBS" + +else : + +fi + +# Macro definitions +################### + +# DD_COPT macro checks if the compiler specified as the 1st parameter +# supports option specified as the 2nd parameter +# For example: DD_CPORT(CXX, fPIC) + + + + +# Checking characteristics of compilers and other programs +# -------------------------------------------------------- +echo $ac_n "checking whether preprocessor accepts -MM or -M""... $ac_c" 1>&6 +echo "configure:2282: checking whether preprocessor accepts -MM or -M" >&5 +if eval "test \"`echo '$''{'sdcc_cv_MM'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo "#include " >_test_.c +echo "" >>_test_.c +$CPP -v -MM _test_.c 1>&5 2>&5 +if test "$?" = "0"; then + sdcc_cv_MM="-MM" +else + sdcc_cv_MM="-M" +fi +rm -f _test_.* +fi + +echo "$ac_t""$sdcc_cv_MM" 1>&6 +M_OR_MM=$sdcc_cv_MM + + +# This is the first time when CFLAGS are set/modified!! + +echo $ac_n "checking whether $CC accepts -ggdb""... $ac_c" 1>&6 +echo "configure:2304: checking whether $CC accepts -ggdb" >&5 +if eval "test \"`echo '$''{'sdcc_cv_CCggdb'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat >_test_.c < +void main(void) {} +EOF +$CC -v -ggdb -c _test_.c 1>&5 2>&5 +if test "$?" = "0"; then + sdcc_cv_CCggdb="yes" +else + sdcc_cv_CCggdb="no" +fi +rm -f _test_.* a.out +fi + +echo "$ac_t""$sdcc_cv_CCggdb" 1>&6 + +if test "$sdcc_cv_CCggdb" = "yes"; then + CFLAGS="-ggdb -O2" +fi + + +echo $ac_n "checking whether $CC accepts -pipe""... $ac_c" 1>&6 +echo "configure:2329: checking whether $CC accepts -pipe" >&5 +if eval "test \"`echo '$''{'sdcc_cv_CCpipe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat >_test_.c < +void main(void) {} +EOF +$CC -v -pipe -c _test_.c 1>&5 2>&5 +if test "$?" = "0"; then + sdcc_cv_CCpipe="yes" +else + sdcc_cv_CCpipe="no" +fi +rm -f _test_.* a.out +fi + +echo "$ac_t""$sdcc_cv_CCpipe" 1>&6 + +if test "$sdcc_cv_CCpipe" = "yes"; then + CFLAGS="$CFLAGS -pipe" +fi + + +# Checks for typedefs, structures, and compiler characteristics. +# =========================================================================== +echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 +echo "configure:2356: checking return type of signal handlers" >&5 +if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int main() { +int i; +; return 0; } +EOF +if { (eval echo configure:2378: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_type_signal=void +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_type_signal=int +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_type_signal" 1>&6 +cat >> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h <> confdefs.h < confcache <<\EOF +# 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. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# 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 \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "main.mk:main_in.mk +support/gc/Makefile +src/Makefile +as/mcs51/Makefile +support/cpp/Makefile +device/include/Makefile +device/lib/Makefile +debugger/mcs51/Makefile + sdccconf.h:sdccconf_in.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@AWK@%$AWK%g +s%@VERSION@%$VERSION%g +s%@VERSIONHI@%$VERSIONHI%g +s%@VERSIONLO@%$VERSIONLO%g +s%@VERSIONP@%$VERSIONP%g +s%@CC@%$CC%g +s%@CXX@%$CXX%g +s%@CPP@%$CPP%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@RANLIB@%$RANLIB%g +s%@YACC@%$YACC%g +s%@LEX@%$LEX%g +s%@LEXLIB@%$LEXLIB%g +s%@AUTOCONF@%$AUTOCONF%g +s%@AS@%$AS%g +s%@CP@%$CP%g +s%@M_OR_MM@%$M_OR_MM%g +s%@subdirs@%$subdirs%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# 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_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # 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" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + +if test "$no_recursion" != yes; then + + # Remove --cache-file and --srcdir arguments so they do not pile up. + ac_sub_configure_args= + ac_prev= + for ac_arg in $ac_configure_args; do + if test -n "$ac_prev"; then + ac_prev= + continue + fi + case "$ac_arg" in + -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=*) + ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + ;; + *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; + esac + done + + for ac_config_dir in s51.src; do + + # Do not complain, so a configure script can configure whichever + # parts of a large source tree are present. + if test ! -d $srcdir/$ac_config_dir; then + continue + fi + + echo configuring in $ac_config_dir + + case "$srcdir" in + .) ;; + *) + if test -d ./$ac_config_dir || mkdir ./$ac_config_dir; then :; + else + { echo "configure: error: can not create `pwd`/$ac_config_dir" 1>&2; exit 1; } + fi + ;; + esac + + ac_popdir=`pwd` + cd $ac_config_dir + + # A "../" for each directory in /$ac_config_dir. + ac_dots=`echo $ac_config_dir|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'` + + case "$srcdir" in + .) # No --srcdir option. We are building in place. + ac_sub_srcdir=$srcdir ;; + /*) # Absolute path. + ac_sub_srcdir=$srcdir/$ac_config_dir ;; + *) # Relative path. + ac_sub_srcdir=$ac_dots$srcdir/$ac_config_dir ;; + esac + + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_sub_srcdir/configure; then + ac_sub_configure=$ac_sub_srcdir/configure + elif test -f $ac_sub_srcdir/configure.in; then + ac_sub_configure=$ac_configure + else + echo "configure: warning: no configuration information is in $ac_config_dir" 1>&2 + ac_sub_configure= + fi + + # The recursion is here. + if test -n "$ac_sub_configure"; then + + # Make the cache file name correct relative to the subdirectory. + case "$cache_file" in + /*) ac_sub_cache_file=$cache_file ;; + *) # Relative path. + ac_sub_cache_file="$ac_dots$cache_file" ;; + esac + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" + # The eval makes quoting arguments work. + if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir + then : + else + { echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; } + fi + fi + + cd $ac_popdir + done +fi + + +# End of configure/configure.in diff --git a/configure.in b/configure.in new file mode 100755 index 00000000..5fe04135 --- /dev/null +++ b/configure.in @@ -0,0 +1,206 @@ +#!/bin/sh + +AC_INIT(Makefile) +AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h) + +AC_PROG_AWK + +AC_MSG_CHECKING(version of the package) +if test -f .version; then + VERSION=`cat .version` +elif test -f ../.version; then + VERSION=`cat ../.version` +else + VERSION="0.0.0" +fi +VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'` +VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'` +VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'` +AC_MSG_RESULT(${VERSION}) +AC_SUBST(VERSION) +AC_SUBST(VERSIONHI) +AC_SUBST(VERSIONLO) +AC_SUBST(VERSIONP) +AC_DEFINE_UNQUOTED(SDCC_VERSION_LO, ${VERSIONLO}) +AC_DEFINE_UNQUOTED(SDCC_VERSION_HI, ${VERSIONHI}) +AC_DEFINE_UNQUOTED(SDCC_VERSION_P, ${VERSIONP}) +AC_DEFINE_UNQUOTED(SDCC_VERSION_STR, "${VERSION}") +sdcc_cv_version=$VERSION +sdcc_cv_versionhi=$VERSIONHI +sdcc_cv_versionlo=$VERSIONLO +sdcc_cv_versionp=$VERSIONP + +# Required programs +#------------------- +AC_PROG_CC +AC_PROG_CXX +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_RANLIB +AC_PROG_YACC(bison, :) +AC_PROG_LEX(flex, :) +AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, :) +AC_CHECK_PROG(AS, as, as, :) +AC_CHECK_PROG(CP, cp, cp, :) + +AC_LANG_C + +# Checking for header files. +# =========================================================================== +AC_HEADER_STDC +AC_CHECK_HEADERS(getopt.h) +AC_CHECK_HEADERS(unistd.h) +AC_CHECK_HEADERS(endian.h) +AC_CHECK_HEADERS(sys/isa_defs.h) +AC_CHECK_HEADERS(sys/socket.h) +AC_HEADER_DIRENT + +# This must be after CPP + +AC_CACHE_CHECK(which header file defines FD_ macros, s51_cv_fd, +[sdcc_cv_fd="unknown" +AC_EGREP_CPP(yes, [ +#include +#ifdef FD_ZERO +yes +#endif], sdcc_cv_fd="") +AC_EGREP_CPP(yes, [ +#include +#ifdef FD_ZERO +yes +#endif], sdcc_cv_fd="") +AC_EGREP_CPP(yes, [ +#include +#ifdef FD_ZERO +yes +#endif], sdcc_cv_fd="")]) + +AC_DEFINE(FD_HEADER_OK, 0) +if echo $sdcc_cv_fd|grep time >/dev/null 2>&1; then +AC_DEFINE(FD_NEED_TIME_H, 1) +AC_DEFINE(FD_HEADER_OK, 1) +else +AC_DEFINE(FD_NEED_TIME_H, 0) +fi +if echo $sdcc_cv_fd|grep types >/dev/null 2>&1; then +AC_DEFINE(FD_NEED_TYPES_H, 1) +AC_DEFINE(FD_HEADER_OK, 1) +else +AC_DEFINE(FD_NEED_TYPES_H, 0) +fi +if echo $sdcc_cv_fd|grep select >/dev/null 2>&1; then +AC_DEFINE(FD_NEED_SELECT_H, 1) +AC_DEFINE(FD_HEADER_OK, 1) +else +AC_DEFINE(FD_NEED_SELECT_H, 0) +fi + +AC_DEFINE_UNQUOTED(HEADER_FD, ${sdcc_cv_fd}) + + +# Checking for functions +# =========================================================================== +AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup) +AC_CHECK_FUNCS(strchr memcpy) +dnl AC_CHECK_FUNCS(getline) +dnl AC_CHECK_FUNCS(getdelim) +AC_CHECK_FUNCS(fgets) +AC_CHECK_FUNCS(yylex) + +# check if -lsocket && -lxnet is required to compile socket stuff +AC_SEARCH_LIBS(socket,socket) +AC_SEARCH_LIBS(inet_addr,nsl xnet) + +# Macro definitions +################### + +# DD_COPT macro checks if the compiler specified as the 1st parameter +# supports option specified as the 2nd parameter +# For example: DD_CPORT(CXX, fPIC) + +AC_DEFUN(DD_COPT, [ +AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2, +cat >_test_.c < +void main(void) {} +EOF +$$1 -v -$2 -c _test_.c 1>&5 2>&5 +if test "$?" = "0"; then + sdcc_cv_$1$2="yes" +else + sdcc_cv_$1$2="no" +fi +rm -f _test_.* a.out) +]) + + +# Checking characteristics of compilers and other programs +# -------------------------------------------------------- +AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM, +echo "#include " >_test_.c +echo "" >>_test_.c +$CPP -v -MM _test_.c 1>&5 2>&5 +if test "$?" = "0"; then + sdcc_cv_MM="-MM" +else + sdcc_cv_MM="-M" +fi +rm -f _test_.*) +M_OR_MM=$sdcc_cv_MM +AC_SUBST(M_OR_MM) + +# This is the first time when CFLAGS are set/modified!! +DD_COPT(CC, ggdb) +if test "$sdcc_cv_CCggdb" = "yes"; then + CFLAGS="-ggdb -O2" +fi + +DD_COPT(CC, pipe) +if test "$sdcc_cv_CCpipe" = "yes"; then + CFLAGS="$CFLAGS -pipe" +fi + + +# Checks for typedefs, structures, and compiler characteristics. +# =========================================================================== +AC_TYPE_SIGNAL + +# +# +if test "${prefix}" = "NONE"; then + prefix="/usr/local" +fi + +config_in=`pwd` +if test "${datadir}" = "\${prefix}/share"; then + sdcc_datadir=${prefix}/share +else + sdcc_datadir=${datadir} +fi +AC_DEFINE_UNQUOTED(STANDARD_INCLUDE_DIR, "${sdcc_datadir}/sdcc51inc") +AC_DEFINE_UNQUOTED(SDCC_INCLUDE_DIR, "${sdcc_datadir}/sdcc51inc") +AC_DEFINE_UNQUOTED(SDCC_LIB_DIR, "${sdcc_datadir}/sdcc51lib") +AC_DEFINE_UNQUOTED(STD_LIB, "libsdcc") +AC_DEFINE_UNQUOTED(STD_INT_LIB, "libint") +AC_DEFINE_UNQUOTED(STD_LONG_LIB, "liblong") +AC_DEFINE_UNQUOTED(STD_FP_LIB, "libfloat") + +AC_DEFINE_UNQUOTED(PREFIX, "${prefix}") +AC_DEFINE_UNQUOTED(DATADIR, "${sdcc_datadir}") +AC_DEFINE_UNQUOTED(SRCDIR, "${config_in}") + + +# Generating output files +# =========================================================================== +AC_CONFIG_SUBDIRS(s51.src) +AC_OUTPUT(main.mk:main_in.mk +support/gc/Makefile +src/Makefile +as/mcs51/Makefile +support/cpp/Makefile +device/include/Makefile +device/lib/Makefile +debugger/mcs51/Makefile +) + +# End of configure/configure.in diff --git a/debugger/Makefile b/debugger/Makefile new file mode 100644 index 00000000..e69de29b diff --git a/debugger/README b/debugger/README new file mode 100644 index 00000000..b9e1031d --- /dev/null +++ b/debugger/README @@ -0,0 +1,4 @@ +sdcc/debugger +------------- + +I (MLH) no nothing about this directory :) diff --git a/debugger/mcs51/Makefile b/debugger/mcs51/Makefile new file mode 100644 index 00000000..eab2e77a --- /dev/null +++ b/debugger/mcs51/Makefile @@ -0,0 +1,109 @@ +# Generated automatically from Makefile.in by configure. +# +# +# + +VERSION = 2.1.9Ga +VERSIONHI = 2 +VERSIONLO = 1 +VERSIONP = 9Ga + +SHELL = /bin/sh +CC = gcc +CPP = gcc -E +INSTALL = /usr/bin/install -c + +PRJDIR = ../.. + +srcdir = . +prefix = /usr/local +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +includedir = ${prefix}/include +mandir = ${prefix}/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = ${prefix}/info + +STD_INC = @sdcc_include_dir@ +CPPFLAGS = -I. -I$(PRJDIR) -I$(PRJDIR)/support +CFLAGS = -ggdb -O2 -pipe +M_OR_MM = -MM +LDFLAGS = +LIBS = -lgc +LIBDIRS = -L$(PRJDIR)/support/gc + + +OBJECTS = sdcdb.o symtab.o simi.o $(PRJDIR)/src/SDCCset.o \ + break.o cmd.o $(PRJDIR)/src/SDCChasht.o +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) + +TARGET = $(PRJDIR)/bin/sdcdb + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(TARGET) + +$(PRJDIR)/support/gc/libgc.a: + cd $(PRJDIR)/support/gc && $(MAKE) + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) -s $(TARGET) $(bindir)/sdcdb + cp $(PRJDIR)/sdcdb/sdcdb.el $(bindir)/sdcdb.el + cp $(PRJDIR)/sdcdb/sdcdbsrc.el $(bindir)/sdcdbsrc.el + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(bindir)/sdcdb + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) *.h $(PRJDIR)/*.h + $(CPP) $(CPPFLAGS) $(M_OR_MM) $(SOURCES) >Makefile.dep + +include Makefile.dep +include clean.mk + +# My rules +# -------- +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBDIRS) $(LIBS) + +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of cpp/Makefile diff --git a/debugger/mcs51/Makefile.dep b/debugger/mcs51/Makefile.dep new file mode 100644 index 00000000..6349d2f1 --- /dev/null +++ b/debugger/mcs51/Makefile.dep @@ -0,0 +1,4 @@ +SDCCset.o: ../../src/SDCCset.c ../../src/SDCCset.h \ + ../../support/gc/gc.h +SDCChasht.o: ../../src/SDCChasht.c ../../src/SDCChasht.h \ + ../../support/gc/gc.h diff --git a/debugger/mcs51/Makefile.in b/debugger/mcs51/Makefile.in new file mode 100644 index 00000000..01e777b0 --- /dev/null +++ b/debugger/mcs51/Makefile.in @@ -0,0 +1,108 @@ +# +# +# + +VERSION = @VERSION@ +VERSIONHI = @VERSIONHI@ +VERSIONLO = @VERSIONLO@ +VERSIONP = @VERSIONP@ + +SHELL = /bin/sh +CC = @CC@ +CPP = @CPP@ +INSTALL = @INSTALL@ + +PRJDIR = ../.. + +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +includedir = ${prefix}/include +mandir = ${prefix}/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = ${prefix}/info + +STD_INC = @sdcc_include_dir@ +CPPFLAGS = @CPPFLAGS@ -I. -I$(PRJDIR) -I$(PRJDIR)/support +CFLAGS = @CFLAGS@ +M_OR_MM = @M_OR_MM@ +LDFLAGS = @LDFLAGS@ +LIBS = -lgc @LIBS@ +LIBDIRS = -L$(PRJDIR)/support/gc + + +OBJECTS = sdcdb.o symtab.o simi.o $(PRJDIR)/src/SDCCset.o \ + break.o cmd.o $(PRJDIR)/src/SDCChasht.o +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) + +TARGET = $(PRJDIR)/bin/sdcdb + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(TARGET) + +$(PRJDIR)/support/gc/libgc.a: + cd $(PRJDIR)/support/gc && $(MAKE) + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) -s $(TARGET) $(bindir)/sdcdb + cp $(PRJDIR)/sdcdb/sdcdb.el $(bindir)/sdcdb.el + cp $(PRJDIR)/sdcdb/sdcdbsrc.el $(bindir)/sdcdbsrc.el + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(bindir)/sdcdb + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) *.h $(PRJDIR)/*.h + $(CPP) $(CPPFLAGS) $(M_OR_MM) $(SOURCES) >Makefile.dep + +include Makefile.dep +include clean.mk + +# My rules +# -------- +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBDIRS) $(LIBS) + +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of cpp/Makefile diff --git a/debugger/mcs51/break.c b/debugger/mcs51/break.c new file mode 100644 index 00000000..6e85b04b --- /dev/null +++ b/debugger/mcs51/break.c @@ -0,0 +1,396 @@ +/*------------------------------------------------------------------------- + break.c - Source file for break point management + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" +#include "symtab.h" +#include "break.h" + +static hTab *bptable = NULL; +char userBpPresent = 0; +/* call stack can be 1024 deep */ +STACK_DCL(callStack,function *,1024); + +/*-----------------------------------------------------------------*/ +/* setBreakPoint - creates an entry in the break point table */ +/*-----------------------------------------------------------------*/ +int setBreakPoint (unsigned addr, char addrType, char bpType, + int (*callBack)(unsigned,char,char,int,context *) , + char *fileName, int lineno) +{ + breakp *bp, *bpl; + static long bpnum = 0; + char simbuf[50]; + + /* allocate & init a new bp */ + ALLOC(bp,sizeof(breakp)); + bp->addr = addr; + bp->addrType = addrType; + bp->bpType = bpType; + bp->callBack = callBack; + bp->bpnum = (bpType == USER ? ++bpnum : 0); + bp->filename = fileName; + bp->lineno = lineno; + + /* if this is an user break point then + check if there already exists one for this address */ + if (bpType == USER) { + for ( bpl = hTabFirstItemWK(bptable,addr) ; bpl; + bpl = hTabNextItemWK(bptable)) { + + /* if also a user break point then issue Note : */ + if (bpl->bpType == USER) + fprintf(stderr,"Note: breakpoint %d also set at pc 0x%x\n", + bpl->bpnum,bpl->addr); + } + + fprintf(stderr,"Breakpoint %d at 0x%x: file %s, line %d.\n", + bp->bpnum, addr, fileName, lineno); + + userBpPresent++; + } + + /* if a break point does not already exist then + send command to simulator to add one */ + if (!hTabSearch(bptable,addr)) + /* send the break command to the simulator */ + simSetBP (addr); + + + /* now add the break point to list */ + hTabAddItem(&bptable,addr,bp); + + return bp->bpnum ; +} + +/*-----------------------------------------------------------------*/ +/* deleteSTEPbp - deletes all step break points */ +/*-----------------------------------------------------------------*/ +void deleteSTEPbp () +{ + breakp *bp; + int k; + + /* for break points delete if they are STEP */ + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) { + + /* if this is a step then delete */ + if (bp->bpType == STEP) { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) + simClearBP (bp->addr); + + GC_free(bp); + } + } + +} + +/*-----------------------------------------------------------------*/ +/* deleteNEXTbp - deletes all step break points */ +/*-----------------------------------------------------------------*/ +void deleteNEXTbp () +{ + breakp *bp; + int k; + char simcmd[50]; + + /* for break points delete if they are NEXT */ + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) { + + /* if this is a step then delete */ + if (bp->bpType == NEXT) { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) { + simClearBP(bp->addr); + + } + + GC_free(bp); + } + } + +} + +/*-----------------------------------------------------------------*/ +/* deleteUSERbp - deletes USER break point with number */ +/*-----------------------------------------------------------------*/ +void deleteUSERbp (int bpnum) +{ + breakp *bp; + int k; + char simcmd[50]; + + /* for break points delete if they are STEP */ + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) { + + /* if this is a user then delete if break + point matches or bpnumber == -1 (meaning delete + all user break points */ + if (bp->bpType == USER && ( bp->bpnum == bpnum || bpnum == -1)) { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) { + simClearBP (bp->addr); + + } + fprintf(stdout,"Deleted breakpoint %d\n", + bp->bpnum); + userBpPresent --; + if (bpnum == -1) + continue ; + else + break; + } + } + + if (!bp && bpnum != -1) + fprintf(stderr,"No breakpoint number %d.\n",bpnum); +} + +/*-----------------------------------------------------------------*/ +/* listUSERbp - list all user break points */ +/*-----------------------------------------------------------------*/ +void listUSERbp () +{ + breakp *bp; + int k; + + /* if there are none then say so & return */ + if (!userBpPresent) { + fprintf(stdout,"No breakpoints.\n"); + return ; + } + fprintf(stdout,"Num Address What\n"); + for ( bp = hTabFirstItem(bptable,&k) ; bp ; + bp = hTabNextItem(bptable,&k)) { + + if (bp->bpType == USER ) { + fprintf(stdout,"%-3d 0x%04x at %s:%d\n", + bp->bpnum,bp->addr, + bp->filename,bp->lineno); + + } + } +} + +/*-----------------------------------------------------------------*/ +/* simStopBPCB - simulator stopped break point */ +/*-----------------------------------------------------------------*/ +static int simStopBPCB( unsigned int addr) +{ + fprintf(stdout,"Simulator stopped at Address 0x%04x\n",addr); + fprintf(stdout,"%s",simResponse()); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* clearUSERbp - deletes USER break point at address */ +/*-----------------------------------------------------------------*/ +void clearUSERbp ( unsigned int addr ) +{ + breakp *bp; + char simcmd[50]; + + /* for break points delete if they are STEP */ + for ( bp = hTabFirstItemWK(bptable,addr); bp ; + bp = hTabNextItemWK(bptable)) { + + /* if this is a step then delete */ + if (bp->bpType == USER) { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) { + simClearBP(bp->addr); + + } + fprintf(stdout,"Deleted breakpoint %d\n", + bp->bpnum); + userBpPresent-- ; + break; + } + } + + if (!bp) + fprintf(stderr,"No breakpoint at address 0x%x.\n",addr); +} + +/*-----------------------------------------------------------------*/ +/* dispatchCB - will lookup the bp table and dispatch the cb funcs */ +/*-----------------------------------------------------------------*/ +int dispatchCB (unsigned addr, context *ctxt) +{ + breakp *bp; + int rv =0; + + /* if no break points set for this address + then use a simulator stop break point */ + if ((bp = hTabFirstItemWK(bptable,addr)) == NULL) { + return simStopBPCB(addr); + } + + /* dispatch the call back functions */ + for (; bp; bp = hTabNextItemWK(bptable)) { + + rv += (*bp->callBack)(addr,bp->addrType, + bp->bpType,bp->bpnum,ctxt); + + } + + return rv; +} + +/*-----------------------------------------------------------------*/ +/* fentryCB - callback function for function entry */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(fentryCB) +{ + /* add the current function into the call stack */ + STACK_PUSH(callStack,ctxt->func); + + /* will have to add code here to get the value of SP + which will be used to display the value of local variables + and parameters on the stack */ + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* fexitCB - call back for function exit */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(fexitCB) +{ + /* pop the top most from the call stack */ + STACK_POP(callStack); + return 0; +} +/*-----------------------------------------------------------------*/ +/* userBpCB - call back function for user break points */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(userBpCB) +{ + if (srcMode == SRC_CMODE) { + fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", + bpnum, + ctxt->func->sym->name, + ctxt->func->mod->c_name, + ctxt->cline); + if (ctxt->func->mod && ctxt->cline > 0) + fprintf(stdout,"%d\t%s",ctxt->cline, + ctxt->func->mod->cLines[ctxt->cline]->src); + } else { + fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", + bpnum, + ctxt->func->sym->name, + ctxt->func->mod->asm_name, + ctxt->asmline); + if (ctxt->func->mod && ctxt->asmline > 0) + fprintf(stdout,"%d\t%s",ctxt->asmline, + ctxt->func->mod->asmLines[ctxt->asmline]->src); + } + + return 1; +} + +/*-----------------------------------------------------------------*/ +/* stepBpCB - call back function for step break points */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(stepBpCB) +{ + static function *lfunc = NULL; + + if (srcMode == SRC_CMODE) { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->c_name, + ctxt->cline); + + if (ctxt->func->mod && ctxt->cline > 0) { + fprintf(stdout,"%d\t%s",ctxt->cline , + ctxt->func->mod->cLines[ctxt->cline]->src); + } + } else { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->asm_name, + ctxt->asmline); + + if (ctxt->func->mod && ctxt->cline > 0) { + fprintf(stdout,"%d\t%s",ctxt->asmline , + ctxt->func->mod->asmLines[ctxt->asmline]->src); + } + } + lfunc = ctxt->func; + + deleteSTEPbp(); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* nextBpCB - call back function for next break points */ +/*-----------------------------------------------------------------*/ +BP_CALLBACK(nextBpCB) +{ + static function *lfunc = NULL; + + if (srcMode == SRC_CMODE) { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->c_name, + ctxt->cline); + + if (ctxt->func->mod && ctxt->cline > 0) + fprintf(stdout,"%d\t%s",ctxt->cline, + ctxt->func->mod->cLines[ctxt->cline]->src); + } else { + if ((lfunc && lfunc != ctxt->func) || !lfunc) + fprintf(stdout,"%s () at %s:%d\n", + ctxt->func->sym->name, + ctxt->func->mod->asm_name, + ctxt->asmline); + + if (ctxt->func->mod && ctxt->asmline > 0) + fprintf(stdout,"%d\t%s",ctxt->asmline, + ctxt->func->mod->asmLines[ctxt->asmline]->src); + + } + lfunc = ctxt->func; + + deleteNEXTbp(); + return 1; +} diff --git a/debugger/mcs51/break.h b/debugger/mcs51/break.h new file mode 100644 index 00000000..7b6d9893 --- /dev/null +++ b/debugger/mcs51/break.h @@ -0,0 +1,86 @@ +/*------------------------------------------------------------------------- + break.h - Header file for break point management + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCDB_BREAK_H +#define SDCDB_BREAK_H + +#include "simi.h" + +/* break point type */ +enum { + DATA = 1, + CODE , + A_CODE , + USER , + STEP , + NEXT , + FENTRY , + FEXIT}; + + +typedef struct breakp +{ + unsigned addr; /* address of break point */ + int bpnum ; /* break point number */ + char addrType; /* data or code */ + char bpType ; /* bp type USER/ LOGICAL */ + char *filename; /* file name */ + int lineno ; /* lineno */ + int (*callBack) + (unsigned,char,char,int,context *);/* address of call back function */ +} breakp; + + +#define BP_CALLBACK(func) \ + int func (unsigned addr, \ + char addrType, \ + char bpType , \ + int bpnum ,\ + context *ctxt) + +#define EXTERN_BP_CALLBACK(func) \ + extern int func (unsigned addr, \ + char addrType, \ + char bpType , \ + int bpnum ,\ + context *ctxt) + +extern char userBpPresent; +int setBreakPoint (unsigned , char , char, + int (*callBack)(unsigned,char,char,int,context *),char *, int); + +void clearUSERbp ( unsigned int ); +void deleteSTEPbp(); +void deleteNEXTbp(); +void deleteUSERbp(int); +int dispatchCB (unsigned, context *); +void listUSERbp (); + +/* call back functions */ +EXTERN_BP_CALLBACK(fexitCB); +EXTERN_BP_CALLBACK(fentryCB); +EXTERN_BP_CALLBACK(userBpCB); +EXTERN_BP_CALLBACK(stepBpCB); +EXTERN_BP_CALLBACK(nextBpCB); + +#endif diff --git a/debugger/mcs51/clean.mk b/debugger/mcs51/clean.mk new file mode 100644 index 00000000..ae043fc0 --- /dev/null +++ b/debugger/mcs51/clean.mk @@ -0,0 +1,24 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f $(PRJDIR)/bin/sdcdb + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f config.cache config.log config.status + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/debugger/mcs51/cmd.c b/debugger/mcs51/cmd.c new file mode 100644 index 00000000..89dfe6a5 --- /dev/null +++ b/debugger/mcs51/cmd.c @@ -0,0 +1,1650 @@ +/*------------------------------------------------------------------------- + cmd.c - source file for debugger command execution + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" +#include "symtab.h" +#include "simi.h" +#include "break.h" +#include "cmd.h" + +int listLines = 10; +EXTERN_STACK_DCL(callStack,function *,1024); + +static char *copying= +" GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. +^L + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The \"Program\", below, +refers to any such program or work, and a \"work based on the Program\" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term \"modification\".) Each licensee is addressed as \"you\". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. +^L + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and \"any +later version\", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. +"; +static char *warranty= +" NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. +"; + +static void printTypeInfo(link *); +static void printValAggregates (symbol *,link *,char,unsigned int); + +int srcMode = SRC_CMODE ; + +/*-----------------------------------------------------------------*/ +/* funcWithName - returns function with name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcWithName) +{ + function *func = item; + V_ARG(char *,name); + V_ARG(function **,funcp); + + if (*funcp) + return 0; + + if (strcmp(func->sym->name,name) == 0) { + *funcp = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* setBPatModLine - set break point at the line specified for the */ +/*-----------------------------------------------------------------*/ +static void setBPatModLine (module *mod, int line) +{ + /* look for the first executable line after the line + specified & get the break point there */ + if (srcMode == SRC_CMODE && line > mod->ncLines) { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->c_name); + return ; + } + + if (srcMode == SRC_AMODE && line > mod->nasmLines) { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->asm_name); + return ; + } + + for ( ; line < (srcMode == SRC_CMODE ? mod->ncLines : mod->nasmLines ) ; + line++ ) { + if (srcMode == SRC_CMODE) { + if (mod->cLines[line]->addr) { + setBreakPoint (mod->cLines[line]->addr, CODE, USER, + userBpCB, mod->c_name, line); + break; + } + } + else { + if (mod->asmLines[line]->addr) { + setBreakPoint (mod->asmLines[line]->addr, CODE, USER, + userBpCB, mod->asm_name, line); + break; + } + } + } + + return; +} + +/*-----------------------------------------------------------------*/ +/* clearBPatModLine - clr break point at the line specified */ +/*-----------------------------------------------------------------*/ +static void clearBPatModLine (module *mod, int line) +{ + /* look for the first executable line after the line + specified & get the break point there */ + if (srcMode == SRC_CMODE && line > mod->ncLines) { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->c_name); + return ; + } + + if (srcMode == SRC_AMODE && line > mod->ncLines) { + fprintf(stderr,"No line %d in file \"%s\".\n", + line,mod->c_name); + return ; + } + + for ( ; line < (srcMode == SRC_CMODE ? mod->ncLines : mod->nasmLines ) ; + line++ ) { + if (srcMode == SRC_CMODE) + if (mod->cLines[line]->addr) { + clearUSERbp (mod->cLines[line]->addr); + break; + } + else + if (mod->asmLines[line]->addr) { + clearUSERbp (mod->asmLines[line]->addr); + break; + } + } + + return; +} + +/*-----------------------------------------------------------------*/ +/* funcWithNameModule - returns functions with a name module combo */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcWithNameModule) +{ + function *func = item; + V_ARG(char *,fname); + V_ARG(char *,mname); + V_ARG(function **,funcp); + + if (*funcp) + return 0; + + if (strcmp(func->sym->name,fname) == 0 && + strcmp(func->mod->c_name,mname) == 0) { + *funcp = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* funcInAddr - given an address returns the function */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcInAddr) +{ + function *func = item; + V_ARG(unsigned int,addr); + V_ARG(function **,funcp); + + if (*funcp) + return 0; + + /* in the address range */ + if (func->sym->addr <= addr && + func->sym->eaddr >= addr) { + + *funcp = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* setStepBp - will set STEP Bp @ function entry points */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setStepBp) +{ + function *func = item; + + if (func->sym && func->sym->addr ) { + + /* set the entry break point */ + setBreakPoint (func->sym->addr , CODE , STEP , + stepBpCB ,func->mod->c_name , func->entryline); + + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* setStepEPBp - sets a given type of bp @ the execution point */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setStepEPBp) +{ + exePoint *ep = item; + V_ARG(int,bptype); + V_ARG(char *,mname); + + setBreakPoint (ep->addr, CODE, bptype, + stepBpCB, mname, ep->line); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* setNextEPBp - sets a given type of bp @ the execution point */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setNextEPBp) +{ + exePoint *ep = item; + V_ARG(int,bptype); + V_ARG(char *,mname); + + setBreakPoint (ep->addr, CODE, bptype, + nextBpCB, mname, ep->line); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* lineAtAddr - for execution points returns the one with addr */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(lineAtAddr) +{ + exePoint *ep = item; + V_ARG(unsigned int,addr); + V_ARG(int *,line); + V_ARG(int *,block); + V_ARG(int *,level); + + /* address must be an exact match */ + if (ep->addr == addr) { + *line = ep->line; + if (block) + *block = ep->block ; + if (level) + *level = ep->level ; + return 1; + } + + return 0; + +} + +/*-----------------------------------------------------------------*/ +/* discoverContext - find out the current context of the bp */ +/*-----------------------------------------------------------------*/ +context *discoverContext (unsigned addr) +{ + function *func = NULL; + int line = 0; + + /* find the function we are in */ + if (!applyToSet(functions,funcInAddr,addr,&func)) + return NULL; + + currCtxt->func = func; + currCtxt->addr = func->laddr = addr; + currCtxt->modName = func->modName; + + /* find the c line number */ + if(applyToSet(func->cfpoints,lineAtAddr,addr, + &line,&currCtxt->block,&currCtxt->level)) + currCtxt->cline = func->lline = line; + else + currCtxt->cline = func->exitline; + + /* find the asm line number */ + line = 0; + if (applyToSet(func->afpoints,lineAtAddr,addr, + &line,NULL,NULL)) + currCtxt->asmline = line; + else + currCtxt->asmline = -1; + + return currCtxt ; +} + + +/*-----------------------------------------------------------------*/ +/* simGo - send 'go' cmd to simulator and wait till a break occurs */ +/*-----------------------------------------------------------------*/ +void simGo (unsigned int gaddr) +{ + unsigned int addr ; + context *ctxt; + int rv; + top: + addr = simGoTillBp (gaddr); + + /* got the pc for the break point now first + discover the program context i.e. module, function + linenumber of the source etc, etc etc */ + ctxt = discoverContext (addr); + + /* dispatch all the break point call back functions */ + rv = dispatchCB (addr,ctxt); + + ret: + + /* the dispatch call back function will return + non-zero if an user break point has been hit + if not then we continue with the execution + of the program */ + if (!rv) { + gaddr = -1; + goto top ; + } + +} + +/*-----------------------------------------------------------------*/ +/* cmdSetUserBp - set break point at the user specified location */ +/*-----------------------------------------------------------------*/ +int cmdSetUserBp (char *s, context *cctxt) +{ + char *bp ; + function *func = NULL; + + /* user break point location specification can be of the following + forms + a) - break point at current location + b) lineno - number of the current module + c) filename:lineno - line number of the given file + e) filename:function- function X in file Y (useful for static functions) + f) function - function entry point + */ + + if (!cctxt) { + fprintf(stdout,"No symbol table is loaded. Use the \"file\" command.\n"); + return 0; + } + /* white space skip */ + while (*s && isspace(*s)) s++; + + /* null terminate it after stripping trailing blanks*/ + bp = s + strlen(s); + while (bp != s && isspace(*bp)) bp--; + *bp = '\0'; + + /* case a) nothing */ + /* if nothing given then current location : we know + the current execution location from the currentContext */ + if (! *s ) { + + /* if current context is known */ + if (cctxt->func) { + if (srcMode == SRC_CMODE) + /* set the break point */ + setBreakPoint ( cctxt->addr , CODE , USER , userBpCB , + cctxt->func->mod->c_name, cctxt->cline); + else + setBreakPoint ( cctxt->addr , CODE , USER , userBpCB , + cctxt->func->mod->asm_name, cctxt->asmline); + + } + else + fprintf(stderr,"No default breakpoint address now.\n"); + + goto ret ; + } + + /* case b) lineno */ + /* check if line number */ + if (isdigit(*s)) { + /* get the lineno */ + int line = atoi(s); + + /* if current context not present then we must get the module + which has main & set the break point @ line number provided + of that module : if current context known then set the bp + at the line number given for the current module + */ + if (cctxt->func) { + if (!cctxt->func->mod) { + if (!applyToSet(functions,funcWithName,"main")) + fprintf(stderr,"Function \"main\" not defined.\n"); + else + setBPatModLine(func->mod,line); + } else + setBPatModLine(cctxt->func->mod,line); + } else { + fprintf(stdout,"No symbol information currently\n"); + } + + goto ret; + } + + if ((bp = strchr(s,':'))) { + + module *mod = NULL; + *bp = '\0'; + + if (srcMode == SRC_CMODE) { + if (!applyToSet(modules,moduleWithCName,s,&mod)) { + fprintf (stderr,"No source file named %s.\n",s); + goto ret; + } + } else { + if (!applyToSet(modules,moduleWithAsmName,s,&mod)) { + fprintf (stderr,"No source file named %s.\n",s); + goto ret; + } + } + + /* case c) filename:lineno */ + if (isdigit(*(bp +1))) { + + setBPatModLine (mod,atoi(bp+1)); + goto ret; + + } + /* case d) filename:function */ + if (!applyToSet(functions,funcWithNameModule,bp+1,s,&func)) + fprintf(stderr,"Function \"%s\" not defined.\n",bp+1); + else + setBPatModLine (mod, + (srcMode == SRC_CMODE ? + func->entryline : + func->aentryline)); + + goto ret; + } + + /* case e) function */ + if (!applyToSet(functions,funcWithName,s,&func)) + fprintf(stderr,"Function \"%s\" not defined.\n",s); + else + setBPatModLine(func->mod, + (srcMode == SRC_CMODE ? + func->entryline : + func->aentryline)); + + ret: + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdListAsm - list assembler source code */ +/*-----------------------------------------------------------------*/ +int cmdListAsm (char *s, context *cctxt) +{ + fprintf(stderr,"'listasm' command not yet implemented\n"); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdSetOption - set debugger options */ +/*-----------------------------------------------------------------*/ +int cmdSetOption (char *s, context *cctxt) +{ + while (*s && isspace(*s)) s++; + if (strncmp(s,"srcmode",7) == 0 ) { + if (srcMode == SRC_CMODE) + srcMode = SRC_AMODE; + else + srcMode = SRC_CMODE; + fprintf(stderr,"source mode set to '%s'\n", + (srcMode == SRC_CMODE ? "C" : "asm")); + return 0; + } + + fprintf(stderr,"'set %s' command not yet implemented\n",s); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdContinue - continue till next break point */ +/*-----------------------------------------------------------------*/ +int cmdContinue (char *s, context *cctxt) +{ + if (!cctxt || !cctxt->func) { + fprintf(stdout,"The program is not being run.\n"); + return 0; + } + + fprintf(stdout,"Continuing.\n"); + simGo(-1); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdDelUserBp - delete user break point */ +/*-----------------------------------------------------------------*/ +int cmdDelUserBp (char *s, context *cctxt) +{ + int bpnum ; + while (isspace(*s)) s++; + + if (!*s ) { + if (userBpPresent) { + char buffer[10]; + fprintf (stdout,"Delete all breakpoints? (y or n) "); + fflush(stdout); + fgets(buffer,sizeof(buffer),stdin); + if (toupper(buffer[0]) == 'Y') + deleteUSERbp(-1); + } + return 0; + } + + /* determine the break point number */ + if (sscanf(s,"%d",&bpnum) == 1) + deleteUSERbp(bpnum); + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdStep - single step thru C source file */ +/*-----------------------------------------------------------------*/ +int cmdStep (char *s, context *cctxt) +{ + function *func = NULL; + + if (!cctxt || !cctxt->func || !cctxt->func->mod) + fprintf(stdout,"The program is not being run.\n"); + else { + /* if we are @ the end of a function then set + break points at execution points of the + function in the call stack... */ + if (cctxt->addr == cctxt->func->sym->eaddr) { + if ((func = STACK_PEEK(callStack))) { + if (srcMode == SRC_CMODE) + applyToSet (func->cfpoints,setStepEPBp,STEP, + func->mod->c_name); + else + applyToSet (func->afpoints,setStepEPBp,STEP, + func->mod->asm_name); + } + } else { + /* set breakpoints at all function entry points + and all exepoints of this functions & for + all functions one up in the call stack */ + + /* all function entry points */ + applyToSet(functions,setStepBp); + + if (srcMode == SRC_CMODE) { + /* for all execution points in this function */ + applyToSet(cctxt->func->cfpoints,setStepEPBp,STEP, + cctxt->func->mod->c_name); + + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , + stepBpCB, cctxt->func->mod->c_name, + cctxt->func->exitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) { + applyToSet (func->cfpoints,setStepEPBp,STEP, + func->mod->c_name); + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, STEP , + stepBpCB, func->mod->c_name, + func->exitline); + } + } else { + /* for all execution points in this function */ + applyToSet(cctxt->func->afpoints,setStepEPBp,STEP, + cctxt->func->mod->asm_name); + + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , + stepBpCB, cctxt->func->mod->asm_name, + cctxt->func->aexitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) { + + applyToSet (func->afpoints,setStepEPBp,STEP, + func->mod->asm_name); + + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, STEP , + stepBpCB, func->mod->asm_name, + func->aexitline); + } + } + } + + simGo(-1); + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdNext - next executable C statement file */ +/*-----------------------------------------------------------------*/ +int cmdNext (char *s, context *cctxt) +{ + function *func = NULL; + /* next is almost the same as step except we don't + we don't set break point for all function entry + points */ + if (!cctxt || !cctxt->func || !cctxt->func->mod) + fprintf(stdout,"The program is not being run.\n"); + else { + + /* if we are @ the end of a function then set + break points at execution points of the + function in the call stack... */ + if (cctxt->addr == cctxt->func->sym->eaddr) { + if ((func = STACK_PEEK(callStack))) { + if (srcMode == SRC_CMODE) + applyToSet (func->cfpoints,setStepEPBp,STEP, + func->mod->c_name); + else + applyToSet (func->afpoints,setStepEPBp,STEP, + func->mod->asm_name); + } + } else { + if (srcMode == SRC_CMODE) { + /* for all execution points in this function */ + applyToSet(cctxt->func->cfpoints,setNextEPBp,NEXT, + cctxt->func->mod->c_name); + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , + nextBpCB, cctxt->func->mod->c_name, + cctxt->func->exitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) { + applyToSet (func->cfpoints,setNextEPBp,NEXT , + func->mod->c_name); + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, NEXT , + stepBpCB, func->mod->c_name, + func->exitline); + } + } else { + /* for all execution points in this function */ + applyToSet(cctxt->func->afpoints,setNextEPBp,NEXT, + cctxt->func->mod->asm_name); + /* set a break point @ the current function's + exit */ + setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , + nextBpCB, cctxt->func->mod->asm_name, + cctxt->func->aexitline); + + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) { + applyToSet (func->cfpoints,setNextEPBp,NEXT , + func->mod->asm_name); + /* set bp @ callers exit point */ + setBreakPoint (func->sym->eaddr, CODE, NEXT , + stepBpCB, func->mod->asm_name, + func->aexitline); + } + } + simGo(-1); + } + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdRun - run till next break point */ +/*-----------------------------------------------------------------*/ +int cmdRun (char *s, context *cctxt) +{ + char buff[10]; + if (!cctxt || !cctxt->func || !cctxt->func->mod) { + fprintf(stdout,"Starting program\n"); + simGo(0); + } else { + + fprintf(stdout, + "The program being debugged has been started already.\n"); + fprintf(stdout,"Start it from the beginning? (y or n) "); + fflush(stdout); + + fgets(buff,sizeof(buff),stdin); + if (toupper(buff[0]) == 'Y') { + simReset(); + simGo(0); + } + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* infoStack - print call stack information */ +/*-----------------------------------------------------------------*/ +static void infoStack(context *ctxt) +{ + function *func ; + int i = 0 ; + + STACK_STARTWALK(callStack) ; + while ((func = STACK_WALK(callStack))) { + + fprintf(stdout,"#%d 0x%04x %s () at %s:%d\n",i++, + func->laddr,func->sym->name, + func->mod->c_name,func->lline); + } + +} + +/*-----------------------------------------------------------------*/ +/* cmdInfo - info command */ +/*-----------------------------------------------------------------*/ +int cmdInfo (char *s, context *cctxt) +{ + while (isspace(*s)) s++; + + /* list all break points */ + if (strcmp(s,"break") == 0) { + listUSERbp(); + return 0; + } + + /* info frame same as frame */ + if (strcmp(s,"frame") == 0) { + cmdFrame (s,cctxt); + return 0; + } + + /* info stack display call stack */ + if (strcmp(s,"stack") == 0) { + infoStack(cctxt); + return 0; + } + + /* info stack display call stack */ + if (strcmp(s,"registers") == 0) { + fprintf(stdout,"%s",simRegs()); + return 0; + } + + fprintf(stdout,"Undefined info command: \"%s\". Try \"help\n",s); + return 0; + +} + +/*-----------------------------------------------------------------*/ +/* cmdQuit - quit debugging */ +/*-----------------------------------------------------------------*/ +int cmdQuit (char *s, context *cctxt) +{ + if (simactive) + closeSimulator(); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* cmdListSrc - list src */ +/*-----------------------------------------------------------------*/ +int cmdListSrc (char *s, context *cctxt) +{ + static int currline = 0; + int i =0 ; + int pline = 0; + static module *mod = NULL; + int llines = listLines; + + while (*s && isspace(*s)) s++; + + /* if the user has spcified line numer then the line number + can be of the following formats + LINE - just line number + FILE:LINE - filename line number + FUNCTION - list a function + FILE:FUNCTION - function in file */ + if (!cctxt || !cctxt->func || !cctxt->func->mod) { + fprintf(stdout,"No symbol table is loaded. Use the \"file\" command.\n"); + return 0; + } + if (*s) { + /* case a) LINE */ + if (isdigit(*s)) { + sscanf(s,"%d",&pline); + mod = cctxt->func->mod; + } + else { + char *bp; + function *func = NULL; + + /* if ':' present then FILE:LINE || FILE:FUNCTION */ + if ((bp = strchr(s,':'))) { + *bp = '\0'; + bp ++; + if (isdigit(*bp)) { + /* FILE:LINE */ + if (srcMode == SRC_CMODE) { + if (!applyToSet(modules,moduleWithCName,s,&mod)) { + fprintf (stderr,"No source file named %s.\n",s); + return 0; + } + } else { + if (!applyToSet(modules,moduleWithAsmName,s,&mod)) { + fprintf (stderr,"No source file named %s.\n",s); + return 0; + } + } + sscanf(bp,"%d",&pline); + } else { + /* FILE:FUCTION */ + if (!applyToSet(functions,funcWithNameModule,bp,s,&func)) { + fprintf(stdout,"Function \"%s\" not defined.\n",bp); + return 0; + } + mod = func->mod; + if (srcMode == SRC_CMODE) { + pline = func->entryline; + llines = func->exitline - func->entryline + 1; + } else { + pline = func->aentryline; + llines = func->aexitline - func->aentryline + 1; + } + } + } + else { + /* FUNCTION */ + if (!applyToSet(functions,funcWithName,s,&func)) { + fprintf(stderr,"Function \"%s\" not defined.\n",s); + return 0; + } + else { + mod = func->mod; + if (srcMode == SRC_CMODE) { + pline = func->entryline; + llines = func->exitline - func->entryline + 1; + } else { + pline = func->aentryline; + llines = func->aexitline - func->aentryline + 1; + } + } + } + } + } else { + /* if no line specified & we had listed + before then continue from that listing */ + if (currline) + pline = currline ; + else { + mod = cctxt->func->mod; + if (srcMode == SRC_CMODE) + pline = cctxt->cline; + else + pline = cctxt->asmline; + } + } + + for ( i = 0 ; i < llines ; i++ ) { + if (srcMode == SRC_CMODE) { + if ( (pline + i) >= mod->ncLines ) + break; + fprintf(stdout,"%d\t%s",pline + i, + mod->cLines[pline +i]->src); + } else { + if ( (pline + i) >= mod->nasmLines ) + break; + fprintf(stdout,"%d\t%s",pline + i, + mod->asmLines[pline +i]->src); + } + } + currline = pline + i ; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* printValBasic - print value of basic types */ +/*-----------------------------------------------------------------*/ +static void printValBasic(symbol *sym,unsigned addr,char mem, int size) +{ + union { + float f; + unsigned long val; + long sval; + struct { + short lo; + short hi; + } i; + unsigned char b[4]; + }v; + union { + unsigned char b[4]; + }v1; + + v.val = simGetValue(addr,mem,size); + /* if this a floating point number then */ + if (IS_FLOAT(sym->type)) + fprintf(stdout,"%f",v.f); + else + if (IS_PTR(sym->type)) + fprintf(stdout,"0x%x",v.val); + else + if (IS_SPEC(sym->type) && IS_INTEGRAL(sym->type)) { + if (IS_CHAR(sym->etype)) + fprintf(stdout,"'%c' %d 0x%x",v.val,v.val,v.val); + else + if (IS_INT(sym->etype)) + if (IS_LONG(sym->etype)) + if (SPEC_USIGN(sym->etype)) + fprintf(stdout,"%d 0x%x",v.val,v.val); + else + fprintf(stdout,"%d 0x%x",v.sval,v.sval); + else + fprintf(stdout,"%d 0x%x",v.i.lo,v.i.lo); + else + fprintf(stdout,"0x%x",v.val); + } else + fprintf(stdout,"0x%x",v.val); + + +} + +/*-----------------------------------------------------------------*/ +/* printValFunc - prints function values */ +/*-----------------------------------------------------------------*/ +static void printValFunc (symbol *sym) +{ + fprintf(stdout,"print function not yet implemented\n"); +} + +/*-----------------------------------------------------------------*/ +/* printArrayValue - will print the values of array elements */ +/*-----------------------------------------------------------------*/ +static void printArrayValue (symbol *sym, char space, unsigned int addr) +{ + link *elem_type = sym->type->next; + int i; + + fprintf(stdout," { "); + for (i = 0 ; i < DCL_ELEM(sym->type) ; i++) { + if (IS_AGGREGATE(elem_type)) { + printValAggregates(sym,elem_type,space,addr); + } else { + printValBasic(sym,addr,space,getSize(elem_type)); + } + addr += getSize(elem_type); + if (i != DCL_ELEM(sym->type) -1) + fprintf(stdout,","); + } + + fprintf(stdout,"}\n"); +} + +/*-----------------------------------------------------------------*/ +/* printStructValue - prints structures elements */ +/*-----------------------------------------------------------------*/ +static void printStructValue (symbol *sym,link *type, char space, unsigned int addr) +{ + symbol *fields = SPEC_STRUCT(type)->fields; + + fprintf(stdout," { "); + while (fields) { + fprintf(stdout,"%s = ",fields->name); + if (IS_AGGREGATE(fields->type)) { + printValAggregates(fields,fields->type,space, addr); + } else { + printValBasic(fields,addr,space,getSize(fields->type)); + } + addr += getSize(fields->type); + fields = fields->next; + } + fprintf(stdout,"}\n"); +} + +/*-----------------------------------------------------------------*/ +/* printValAggregates - print value of aggregates */ +/*-----------------------------------------------------------------*/ +static void printValAggregates (symbol *sym, link *type,char space,unsigned int addr) +{ + + if (IS_ARRAY(type)) { + printArrayValue(sym, space, addr); + return ; + } + + if (IS_STRUCT(type)) { + printStructValue(sym,sym->type,space, addr); + return; + } +} + +/*-----------------------------------------------------------------*/ +/* printSymValue - print value of a symbol */ +/*-----------------------------------------------------------------*/ +static void printSymValue (symbol *sym, context *cctxt) +{ + static int stack = 1; + unsigned long val; + /* if it is on stack then compute address & fall thru */ + if (sym->isonstack) { + symbol *bp = symLookup("bp",cctxt); + if (!bp) { + fprintf(stdout,"cannot determine stack frame\n"); + return ; + } + + sym->addr = simGetValue(bp->addr,bp->addrspace,bp->size) + + sym->offset ; + } + + /* get the value from the simulator and + print it */ + fprintf(stdout,"$%d = ",stack++); + /* arrays & structures first */ + if (IS_AGGREGATE(sym->type)) + printValAggregates(sym,sym->type,sym->addrspace,sym->addr); + else + /* functions */ + if (IS_FUNC(sym->type)) + printValFunc(sym); + else { + printValBasic(sym,sym->addr,sym->addrspace,sym->size); + fprintf(stdout,"\n"); + } +} + +/*-----------------------------------------------------------------*/ +/* printStructInfo - print out structure information */ +/*-----------------------------------------------------------------*/ +static void printStructInfo (structdef *sdef) +{ + symbol *field = sdef->fields ; + int i = 0 ; + + while (field) { + i += field->offset; + field = field->next; + } + + fprintf(stdout,"%s %s {\n",(i ? "struct" : "union" ), sdef->tag); + field = sdef->fields; + while (field) { + printTypeInfo (field->type); + fprintf(stdout," %s ;\n",field->name); + field = field->next ; + } + + fprintf(stdout,"}\n"); + +} + +/*-----------------------------------------------------------------*/ +/* printTypeInfo - print out the type information */ +/*-----------------------------------------------------------------*/ +static void printTypeInfo(link *p) +{ + if (!p) + return ; + + if (IS_DECL(p)) { + switch (DCL_TYPE(p)) { + case FUNCTION: + printTypeInfo (p->next); + fprintf(stdout,"()"); + break; + case ARRAY: + printTypeInfo (p->next); + fprintf(stdout,"[%d]",DCL_ELEM(p)); + break; + + case IPOINTER: + case PPOINTER: + case POINTER: + printTypeInfo (p->next); + fprintf(stdout,"(_near *)"); + break; + + case FPOINTER: + printTypeInfo (p->next); + fprintf(stdout,"(_xdata *)"); + break; + + case CPOINTER: + printTypeInfo( p->next); + fprintf(stdout,"(_code *)"); + break; + + case GPOINTER: + printTypeInfo( p->next); + fprintf(stdout,"(_generic *)"); + break; + } + } else { + switch (SPEC_NOUN(p)) { /* depending on the specifier type */ + case V_INT: + (IS_LONG(p) ? fputs("long ",stdout) : + ( IS_SHORT(p) ? fputs("short ",stdout) : + fputs("int ",stdout))) ; + break; + case V_FLOAT: + fputs("float ",stdout); + break; + + case V_CHAR: + fputs ("char ",stdout); + break; + + case V_VOID: + fputs("void ",stdout); + break; + + case V_STRUCT: + printStructInfo (SPEC_STRUCT(p)); + break; + + case V_SBIT: + fputs("sbit ",stdout); + break; + + case V_BIT: + fprintf(stdout,": %d" ,SPEC_BLEN(p)); + break; + } + } +} + +/*-----------------------------------------------------------------*/ +/* cmdPrint - print value of variable */ +/*-----------------------------------------------------------------*/ +int cmdPrint (char *s, context *cctxt) +{ + symbol *sym ; + char *bp = s+strlen(s) -1; + + while (isspace(*s)) s++; + if (!*s) return 0; + while (isspace(*bp)) bp--; + bp++ ; + *bp = '\0'; + + if (!cctxt || !cctxt->func) { + fprintf(stdout,"No symbol \"%s\" in current context.\n", + s); + return 0; + } + if ((sym = symLookup(s,cctxt))) { + printSymValue(sym,cctxt); + } else { + fprintf(stdout, + "No symbol \"%s\" in current context.\n", + s); + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdPrintType - print type of a variable */ +/*-----------------------------------------------------------------*/ +int cmdPrintType (char *s, context *cctxt) +{ + symbol *sym ; + char *bp = s+strlen(s) -1; + + while (isspace(*s)) s++; + if (!*s) return 0; + while (isspace(*bp)) bp--; + bp++ ; + *bp = '\0'; + + if (!cctxt || !cctxt->func) { + fprintf(stdout,"No symbol \"%s\" in current context.\n", + s); + return 0; + } + + if ((sym = symLookup(s,cctxt))) { + printTypeInfo(sym->type); + fprintf(stdout,"\n"); + } else { + fprintf(stdout, + "No symbol \"%s\" in current context.\n", + s); + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdClrUserBp - clear user break point */ +/*-----------------------------------------------------------------*/ +int cmdClrUserBp (char *s, context *cctxt) +{ + char *bp ; + function *func = NULL; + + /* clear break point location specification can be of the following + forms + a) - break point at current location + b) lineno - number of the current module + c) filename:lineno - line number of the given file + e) filename:function- function X in file Y (useful for static functions) + f) function - function entry point + */ + + if (!cctxt) { + fprintf(stdout,"No symbol table is loaded. Use the \"file\" command.\n"); + return 0; + } + + /* white space skip */ + while (*s && isspace(*s)) s++; + + /* null terminate it after stripping trailing blanks*/ + bp = s + strlen(s); + while (bp != s && isspace(*bp)) bp--; + *bp = '\0'; + + /* case a) nothing */ + /* if nothing given then current location : we know + the current execution location from the currentContext */ + if (! *s ) { + + /* if current context is known */ + if (cctxt->func) + /* clear the break point @ current location */ + clearUSERbp (cctxt->addr); + else + fprintf(stderr,"No default breakpoint address now.\n"); + + goto ret ; + } + + /* case b) lineno */ + /* check if line number */ + if (isdigit(*s)) { + /* get the lineno */ + int line = atoi(s); + + /* if current context not present then we must get the module + which has main & set the break point @ line number provided + of that module : if current context known then set the bp + at the line number given for the current module + */ + if (cctxt->func) { + if (!cctxt->func->mod) { + if (!applyToSet(functions,funcWithName,"main")) + fprintf(stderr,"Function \"main\" not defined.\n"); + else + clearBPatModLine(func->mod,line); + } else + clearBPatModLine(cctxt->func->mod,line); + } + + goto ret; + } + + if ((bp = strchr(s,':'))) { + + module *mod = NULL; + *bp = '\0'; + + if (!applyToSet(modules,moduleWithCName,s,&mod)) { + fprintf (stderr,"No source file named %s.\n",s); + goto ret; + } + + /* case c) filename:lineno */ + if (isdigit(*(bp +1))) { + + clearBPatModLine (mod,atoi(bp+1)); + goto ret; + + } + /* case d) filename:function */ + if (!applyToSet(functions,funcWithNameModule,bp+1,s,&func)) + fprintf(stderr,"Function \"%s\" not defined.\n",bp+1); + else + clearBPatModLine (mod,func->entryline); + + goto ret; + } + + /* case e) function */ + if (!applyToSet(functions,funcWithName,s,&func)) + fprintf(stderr,"Function \"%s\" not defined.\n",s); + else + clearBPatModLine(func->mod,func->entryline); + + ret: + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* cmdSimulator - send command to simulator */ +/*-----------------------------------------------------------------*/ +int cmdSimulator (char *s, context *cctxt) +{ + sendSim(s); + sendSim("\n"); + waitForSim(); + fprintf(stdout,"%s",simResponse()); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdFrame - Frame command */ +/*-----------------------------------------------------------------*/ +int cmdFrame (char *s, context *cctxt) +{ + function *func ; + + if ((func = STACK_PEEK(callStack))) { + fprintf(stdout,"#0 %s () at %s:%d\n", + func->sym->name,func->mod->c_name,cctxt->cline); + + if (cctxt->cline < func->mod->ncLines) + fprintf(stdout,"%d\t%s", + cctxt->cline, + func->mod->cLines[cctxt->cline]->src); + } else + fprintf(stdout,"No stack.\n"); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdFinish - exec till end of current function */ +/*-----------------------------------------------------------------*/ +int cmdFinish (char *s, context *ctxt) +{ + if (!ctxt || ! ctxt->func) { + fprintf(stdout,"The program is not running.\n"); + return 0; + } + + if (srcMode == SRC_CMODE) { + setBreakPoint (ctxt->func->sym->eaddr, CODE, STEP, + stepBpCB, ctxt->func->mod->c_name, + ctxt->func->exitline); + } else { + setBreakPoint (ctxt->func->sym->eaddr, CODE, STEP, + stepBpCB, ctxt->func->mod->asm_name, + ctxt->func->aexitline); + } + + simGo(-1); + return 0; + +} + + +/*-----------------------------------------------------------------*/ +/* cmdShow - show command */ +/*-----------------------------------------------------------------*/ +int cmdShow (char *s, context *cctxt) +{ + /* skip white space */ + while (*s && isspace(*s)) s++ ; + + if (strcmp(s,"copying") == 0) { + fputs(copying,stdout); + return 0; + } + + if (strcmp(s,"warranty") == 0) { + fputs(warranty,stdout); + return 0; + } + + return 0; +} + diff --git a/debugger/mcs51/cmd.h b/debugger/mcs51/cmd.h new file mode 100644 index 00000000..ad53cd16 --- /dev/null +++ b/debugger/mcs51/cmd.h @@ -0,0 +1,47 @@ +/*------------------------------------------------------------------------- + cmd.h - header file for debugger command execution + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCDB_CMD_H +#define SDCDB_CMD_H +/* forward definition for command functions */ +extern int cmdSetUserBp (char *, context *); +extern int cmdClrUserBp (char *, context *); +extern int cmdHelp (char *, context *); +extern int cmdListSrc (char *, context *); +extern int cmdListAsm (char *, context *); +extern int cmdSetOption (char *, context *); +extern int cmdContinue (char *, context *); +extern int cmdDelUserBp (char *, context *); +extern int cmdStep (char *, context *); +extern int cmdRun (char *, context *); +extern int cmdNext (char *, context *); +extern int cmdPrint (char *, context *); +extern int cmdFrame (char *, context *); +extern int cmdSimulator (char *, context *); +extern int cmdQuit (char *, context *); +extern int cmdPrintType (char *, context *); +extern int cmdFile (char *, context *); +extern int cmdInfo (char *, context *); +extern int cmdShow (char *, context *); +extern int cmdFinish (char *, context *); +#endif diff --git a/debugger/mcs51/conf.mk b/debugger/mcs51/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/debugger/mcs51/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/debugger/mcs51/sdcdb.c b/debugger/mcs51/sdcdb.c new file mode 100644 index 00000000..d86dcfc8 --- /dev/null +++ b/debugger/mcs51/sdcdb.c @@ -0,0 +1,792 @@ +/*------------------------------------------------------------------------- + sdcdb.c - main source file for sdcdb debugger + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" +#include "symtab.h" +#include "simi.h" +#include "break.h" +#include "cmd.h" + +char *currModName = NULL; +cdbrecs *recsRoot = NULL ; +set *modules = NULL; /* set of all modules */ +set *functions = NULL ; /* set of functions */ +set *symbols = NULL ; /* set of symbols */ +int nStructs = 0 ; +structdef **structs = NULL ; /* all structures */ +int nLinkrecs = 0; +linkrec **linkrecs = NULL; /* all linkage editor records */ +context *currCtxt = NULL; +short fullname = 0; +char *ssdirl = SDCC_LIB_DIR ":" SDCC_LIB_DIR "/small" ; +char *simArgs[8]; +int nsimArgs = 0; + +/* command table */ +struct cmdtab +{ + char *cmd ; /* command the user will enter */ + int (*cmdfunc)(char *,context *); /* function to execute when command is entered */ + char *htxt ; /* short help text */ + +} cmdTab[] = { + /* NOTE:- the search is done from the top, so "break" should + precede the synonym "b" */ + /* break point */ + { "break" , cmdSetUserBp , + "{b}reak\t\t\t [LINE | FILE:LINE | FILE:FUNCTION | FUNCTION]\n", + }, + { "b" , cmdSetUserBp , NULL }, + + { "clear" , cmdClrUserBp , + "{cl}ear\t\t\t [LINE | FILE:LINE | FILE:FUNCTION | FUNCTION]\n" + }, + { "cl" , cmdClrUserBp , NULL }, + + { "continue" , cmdContinue , + "{c}ontinue\t\t Continue program being debugged, after breakpoint.\n" + }, + { "c" , cmdContinue , NULL }, + + { "delete" , cmdDelUserBp , + "{d}elete n\t\t clears break point number n\n" + }, + { "d" , cmdDelUserBp , NULL }, + + { "help" , cmdHelp , + "{h|?}elp\t\t this message\n" + }, + { "?" , cmdHelp , NULL }, + { "h" , cmdHelp , NULL }, + + { "info" , cmdInfo , + "info\n" + "\t {break}\t list all break points\n" + "\t {stack}\t information about call stack\n" + "\t {frame}\t current frame information\n" + "\t {registers}\t display value of all registers\n" + }, + + { "listasm" , cmdListAsm , + "listasm {la}\t\t list assembler code for the current C line\n" + }, + { "la" , cmdListAsm , NULL }, + { "list" , cmdListSrc , + "{l}ist\t\t\t [LINE | FILE:LINE | FILE:FUNCTION | FUNCTION]\n" + }, + { "l" , cmdListSrc , NULL }, + { "show" , cmdShow , + "show\n" + "\t {copying}\t copying & distribution terms\n" + "\t {warranty}\t warranty information\n" + }, + { "set" , cmdSetOption , NULL }, + { "step" , cmdStep , + "{s}tep\t\t\t Step program until it reaches a different source line.\n" + }, + { "s" , cmdStep , NULL }, + { "next" , cmdNext , + "{n}ext\t\t\t Step program, proceeding through subroutine calls.\n" + }, + { "n" , cmdNext , NULL }, + { "run" , cmdRun , + "{r}un\t\t\t Start debugged program. \n" + }, + { "r" , cmdRun , NULL }, + { "ptype" , cmdPrintType , + "{pt}ype \t print type information of a variable\n" + }, + { "pt" , cmdPrintType , NULL }, + { "print" , cmdPrint , + "{p}rint \t print value of given variable\n" + }, + { "p" , cmdPrint , NULL }, + { "file" , cmdFile , + "file \t\t load symbolic information from \n" + }, + { "frame" , cmdFrame , + "{fr}ame\t\t\t print information about the current Stack\n" + }, + { "finish" , cmdFinish , + "{fi}nish\t\t execute till return of current function\n" + }, + { "fi" , cmdFinish , NULL }, + { "fr" , cmdFrame , NULL }, + { "f" , cmdFrame , NULL }, + { "!" , cmdSimulator , + "!\t send a command directly to the simulator\n" + }, + { "quit" , cmdQuit , + "{q}uit\t\t\t \"Watch me now. Iam going Down. My name is Bobby Brown\"\n" + }, + { "q" , cmdQuit , NULL } +}; + +/*-----------------------------------------------------------------*/ +/* alloccpy - allocate copy and return a new string */ +/*-----------------------------------------------------------------*/ +char *alloccpy ( char *s, int size) +{ + char *d; + + if (!size) + return NULL; + + ALLOC(d,size+1); + memcpy(d,s,size); + d[size] = '\0'; + + return d; +} + +/*-----------------------------------------------------------------*/ +/* resize - resizes array of type with new size */ +/*-----------------------------------------------------------------*/ +void **resize (void **array, int newSize) +{ + void **vptr; + + if (array) + vptr = GC_realloc(array,newSize*(sizeof(void **))); + else + vptr = GC_malloc(sizeof(void **)); + + if (!vptr) { + fprintf(stderr,"sdcdb: out of memory \n"); + exit(1); + } + + return vptr; + +} + +/*-----------------------------------------------------------------*/ +/* readCdb - reads the cdb files & puts the records into cdbLine */ +/* linked list */ +/*-----------------------------------------------------------------*/ +static int readCdb (FILE *file) +{ + cdbrecs *currl ; + char buffer[1024]; + char *bp ; + + if (!(bp = fgets(buffer,sizeof(buffer),file))) + return 0; + + ALLOC(currl,sizeof(cdbrecs)); + recsRoot = currl ; + + while (1) { + + /* make sure this is a cdb record */ + if (strchr("STLFM",*bp) && *(bp+1) == ':') { + /* depending on the record type */ + + switch (*bp) { + case 'S': + /* symbol record */ + currl->type = SYM_REC; + break; + case 'T': + currl->type = STRUCT_REC; + break; + case 'L': + currl->type = LNK_REC; + break; + case 'F': + currl->type = FUNC_REC; + break; + case 'M': + currl->type = MOD_REC ; + } + + bp += 2; + ALLOC(currl->line,strlen(bp)); + strncpy(currl->line,bp,strlen(bp)-1); + currl->line[strlen(bp)-1] = '\0'; + } + + if (!(bp = fgets(buffer,sizeof(buffer),file))) + break; + + if (feof(file)) + break; + + ALLOC(currl->next,sizeof(cdbrecs)); + currl = currl->next; + } + + return (recsRoot->line ? 1 : 0); +} + +/*-----------------------------------------------------------------*/ +/* searchDirsFname - search directory list & return the filename */ +/*-----------------------------------------------------------------*/ +char *searchDirsFname (char *fname) +{ + char *dirs , *sdirs; + FILE *rfile = NULL; + char buffer[128]; + + /* first try the current directory */ + if ((rfile = fopen(fname,"r"))) { + fclose(rfile); + return strdup(fname) ; + } + + if (!ssdirl) + return strdup(fname); + + /* make a copy of the source directories */ + dirs = sdirs = strdup(ssdirl); + + /* assume that the separator is ':' + and try for each directory in the search list */ + dirs = strtok(dirs,":"); + while (dirs) { + if (dirs[strlen(dirs)] == '/') + sprintf(buffer,"%s%s",dirs,fname); + else + sprintf(buffer,"%s/%s",dirs,fname); + if ((rfile = fopen(buffer,"r"))) + break ; + dirs = strtok(NULL,":"); + } + + free(sdirs); + if (rfile) { + fclose(rfile); + return strdup(buffer); + } else + return strdup(fname); +} + +/*-----------------------------------------------------------------*/ +/* searchDirsFopen - go thru list of directories for filename given*/ +/*-----------------------------------------------------------------*/ +FILE *searchDirsFopen(char *fname) +{ + char *dirs , *sdirs; + FILE *rfile = NULL; + char buffer[128]; + + /* first try the current directory */ + if ((rfile = fopen(fname,"r"))) + return rfile; + + if (!ssdirl) + return NULL; + /* make a copy of the source directories */ + dirs = sdirs = strdup(ssdirl); + + /* assume that the separator is ':' + and try for each directory in the search list */ + dirs = strtok(dirs,":"); + while (dirs) { + sprintf(buffer,"%s/%s",dirs,fname); + if ((rfile = fopen(buffer,"r"))) + break ; + dirs = strtok(NULL,":"); + } + + free(sdirs); + return rfile ; + +} + +/*-----------------------------------------------------------------*/ +/* loadFile - loads a file into module buffer */ +/*-----------------------------------------------------------------*/ +srcLine **loadFile (char *name, int *nlines) +{ + FILE *mfile ; + char buffer[512]; + char *bp; + srcLine **slines = NULL; + + + if (!(mfile = searchDirsFopen(name))) { + fprintf(stderr,"sdcdb: cannot open module %s -- use '--directory= option\n",name); + return NULL; + } + + while ((bp = fgets(buffer,sizeof(buffer),mfile))) { + (*nlines)++; + + slines = (srcLine **)resize((void **)slines,*nlines); + + ALLOC(slines[(*nlines)-1],sizeof(srcLine)); + slines[(*nlines)-1]->src = alloccpy(bp,strlen(bp)); + } + + fclose(mfile); + return slines; +} + + +/*-----------------------------------------------------------------*/ +/* loadModules - reads the source files into module structure */ +/*-----------------------------------------------------------------*/ +static void loadModules () +{ + cdbrecs *loop; + module *currMod; + char *rs; + + /* go thru the records & find out the module + records & load the modules specified */ + for ( loop = recsRoot ; loop ; loop = loop->next ) { + + switch (loop->type) { + /* for module records do */ + case MOD_REC: + currMod = parseModule(loop->line,TRUE); + currModName = currMod->name ; + + currMod->cfullname = searchDirsFname(currMod->c_name); + + /* load it into buffer */ + currMod->cLines = loadFile (currMod->c_name, + &currMod->ncLines); + + /* do the same for the assembler file */ + currMod->afullname = searchDirsFname(currMod->asm_name); + currMod->asmLines=loadFile (currMod->asm_name, + &currMod->nasmLines); + break; + + /* if this is a function record */ + case FUNC_REC: + parseFunc(loop->line); + break; + + /* if this is a structure record */ + case STRUCT_REC: + parseStruct(loop->line); + break; + + /* if symbol then parse the symbol */ + case SYM_REC: + parseSymbol(loop->line,&rs); + break; + + case LNK_REC: + parseLnkRec(loop->line); + break; + } + } +} + +/*-----------------------------------------------------------------*/ +/* functionPoints - determine the execution points within a func */ +/*-----------------------------------------------------------------*/ +static void functionPoints () +{ + function *func; + symbol *sym; + + /* for all functions do */ + for ( func = setFirstItem(functions); func; + func = setNextItem(functions)) { + int j ; + module *mod; + + sym = func->sym; + +#ifdef SDCDB_DEBUG + printf("func '%s' has entry '%x' exit '%x'\n", + func->sym->name, + func->sym->addr, + func->sym->eaddr); +#endif + if (!func->sym->addr && !func->sym->eaddr) + continue ; + + /* for all source lines in the module find + the ones with address >= start and <= end + and put them in the point */ + mod = NULL ; + if (! applyToSet(modules,moduleWithName,func->modName,&mod)) + continue ; + func->mod = mod ; + func->entryline= INT_MAX; + func->exitline = 0; + func->aentryline = INT_MAX ; + func->aexitline = 0; + + /* do it for the C Lines first */ + for ( j = 0 ; j < mod->ncLines ; j++ ) { + if (mod->cLines[j]->addr >= sym->addr && + mod->cLines[j]->addr <= sym->eaddr ) { + + exePoint *ep ; + + /* add it to the execution point */ + if (func->entryline > j) + func->entryline = j; + + if (func->exitline < j) + func->exitline = j; + + ALLOC(ep,sizeof(exePoint)); + ep->addr = mod->cLines[j]->addr ; + ep->line = j; + ep->block= mod->cLines[j]->block; + ep->level= mod->cLines[j]->level; + addSet(&func->cfpoints,ep); + } + } + + /* do the same for asm execution points */ + for ( j = 0 ; j < mod->nasmLines ; j++ ) { + if (mod->asmLines[j]->addr >= sym->addr && + mod->asmLines[j]->addr <= sym->eaddr ) { + + exePoint *ep ; + /* add it to the execution point */ + if (func->aentryline > j) + func->aentryline = j; + + if (func->aexitline < j) + func->aexitline = j; + + /* add it to the execution point */ + ALLOC(ep,sizeof(exePoint)); + ep->addr = mod->asmLines[j]->addr ; + ep->line = j; + addSet(&func->afpoints,ep); + } + } + +#ifdef SDCDB_DEBUG + printf("function '%s' has the following C exePoints\n", + func->sym->name); + { + exePoint *ep; + + for (ep = setFirstItem(func->cfpoints); ep; + ep = setNextItem(func->cfpoints)) + fprintf (stdout,"{%x,%d} %s",ep->addr,ep->line,mod->cLines[ep->line]->src); + + fprintf(stdout," and the following ASM exePoints\n"); + for (ep = setFirstItem(func->afpoints); ep; + ep = setNextItem(func->afpoints)) + fprintf (stdout,"{%x,%d} %s",ep->addr,ep->line,mod->asmLines[ep->line]->src); + + } +#endif + } +} + + +/*-----------------------------------------------------------------*/ +/* setEntryExitBP - set the entry & exit Break Points for functions*/ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(setEntryExitBP) +{ + function *func = item; + + if (func->sym && func->sym->addr && func->sym->eaddr) { + + /* set the entry break point */ + setBreakPoint (func->sym->addr , CODE , FENTRY , + fentryCB ,func->mod->c_name , func->entryline); + + /* set the exit break point */ + setBreakPoint (func->sym->eaddr , CODE , FEXIT , + fexitCB ,func->mod->c_name , func->exitline ); + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdFile - load file into the debugger */ +/*-----------------------------------------------------------------*/ +int cmdFile (char *s,context *cctxt) +{ + FILE *cdbFile; + char buffer[128]; + char *bp; + + while (isspace(*s)) s++; + if (!*s) { + fprintf(stdout,"No exec file now.\nNo symbol file now.\n"); + return 0; + } + + sprintf(buffer,"%s.cdb",s); + /* try creating the cdbfile */ + if (!(cdbFile = searchDirsFopen(buffer))) { + fprintf(stdout,"Cannot open file\"%s\"",buffer); + return 0; + } + + /* allocate for context */ + ALLOC(currCtxt ,sizeof(context)); + + /* readin the debug information */ + if (!readCdb (cdbFile)) { + fprintf(stdout,"No symbolic information found in file %s.cdb\n",s); + return 0; + } + + /* parse and load the modules required */ + loadModules(); + + /* determine the execution points for this + module */ + functionPoints(); + + /* start the simulator & setup connection to it */ + openSimulator((char **)simArgs,nsimArgs); + fprintf(stdout,"%s",simResponse()); + /* now send the filename to be loaded to the simulator */ + sprintf(buffer,"%s.ihx",s); + bp=searchDirsFname(buffer); + simLoadFile(bp); + free(bp); + + /*set the break points + required by the debugger . i.e. the function entry + and function exit break points */ + applyToSet(functions,setEntryExitBP); + + /* ad we are done */ + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cmdHelp - help command */ +/*-----------------------------------------------------------------*/ +int cmdHelp (char *s, context *cctxt) +{ + int i ; + + for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) { + + /* command string matches */ + if (cmdTab[i].htxt) + fprintf(stdout,"%s",cmdTab[i].htxt); + } + + return 0; +} + +#define MAX_CMD_LEN 512 +char *prompt = "(sdcdb) "; +char cmdbuff[MAX_CMD_LEN]; + +/*-----------------------------------------------------------------*/ +/* interpretCmd - interpret and do the command */ +/*-----------------------------------------------------------------*/ +int interpretCmd (char *s) +{ + static char *pcmd = NULL; + int i ; + int rv = 0 ; + /* if nothing & previous command exists then + execute the previous command again */ + if (*s == '\n' && pcmd) + strcpy(s,pcmd); + /* if previous command exists & is different + from the current command then copy it */ + if (pcmd) { + if (strcmp(pcmd,s)) { + free(pcmd); + pcmd = strdup(s); + } + } else + pcmd = strdup(s); + /* lookup the command table and do the + task required */ + strtok(s,"\n"); + + for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) { + + /* command string matches */ + if (strncmp(s,cmdTab[i].cmd,strlen(cmdTab[i].cmd)) == 0) { + if (!cmdTab[i].cmdfunc) + return 1; + rv = (*cmdTab[i].cmdfunc)(s + strlen(cmdTab[i].cmd),currCtxt); + + /* if full name then give the file name & position */ + if (fullname && currCtxt && currCtxt->func) { + if (srcMode == SRC_CMODE) + fprintf(stdout,"\032\032%s:%d:1\n", + currCtxt->func->mod->cfullname, + currCtxt->cline+1); + else + fprintf(stdout,"\032\032%s:%d:1\n", + currCtxt->func->mod->afullname, + currCtxt->asmline+1); + } + goto ret; + } + } + + fprintf(stdout,"Undefined command: \"%s\". Try \"help\".\n",s); + ret: + return rv; +} + +/*-----------------------------------------------------------------*/ +/* commandLoop - the main command loop */ +/*-----------------------------------------------------------------*/ +void commandLoop() +{ + + while (1) { + fprintf(stdout,"%s",prompt); + fflush(stdout); + + if (fgets(cmdbuff,sizeof(cmdbuff),stdin) == NULL) + break; + + if (interpretCmd(cmdbuff)) + break; + + } +} + +/*-----------------------------------------------------------------*/ +/* printVersionInfo - print the version information */ +/*-----------------------------------------------------------------*/ +static void printVersionInfo() +{ + fprintf(stdout, + "SDCDB is free software and you are welcome to distribute copies of it\n" + "under certain conditions; type \"show copying\" to see the conditions.\n" + "There is absolutely no warranty for SDCDB; type \"show warranty\" for details.\n" + "SDCDB 0.8 . Copyright (C) 1999 Sandeep Dutta (sandeep.dutta@usa.net)\n" + "Type ? for help\n"); + +} + +/*-----------------------------------------------------------------*/ +/* parseCmdLine - parse the commandline arguments */ +/*-----------------------------------------------------------------*/ +static void parseCmdLine (int argc, char **argv) +{ + int i ; + char *filename = NULL; + char buffer[100]; + for ( i = 1; i < argc ; i++) { + fprintf(stdout,"%s\n",argv[i]); + + /* if this is an option */ + if (argv[i][0] == '-') { + + /* if directory then mark directory */ + if (strncmp(argv[i],"--directory=",12) == 0) { + if (!ssdirl) + ssdirl = &argv[i][12]; + else { + char *p = malloc(strlen(ssdirl)+strlen(&argv[i][12])+2); + strcat(strcat(strcpy(p,&argv[i][12]),":"),ssdirl); + ssdirl = p; + } + continue; + } + + if (strncmp(argv[i],"-fullname",9) == 0) { + fullname = TRUE; + continue; + } + + if (strcmp(argv[i],"-cd") == 0) { + i++; + chdir(argv[i]); + continue; + } + + if (strncmp(argv[i],"-cd=",4) == 0) { + chdir(argv[i][4]); + continue; + } + + /* the simulator arguments */ + + /* cpu */ + if (strcmp(argv[i],"-t") == 0 || + strcmp(argv[i],"-cpu") == 0) { + + simArgs[nsimArgs++] = "-t"; + simArgs[nsimArgs++] = strdup(argv[++i]); + continue ; + } + + /* XTAL Frequency */ + if (strcmp(argv[i],"-X") == 0 || + strcmp(argv[i],"-frequency") == 0) { + simArgs[nsimArgs++] = "-X"; + simArgs[nsimArgs++] = strdup(argv[++i]); + continue ; + } + + /* serial port */ + if (strcmp(argv[i],"-s") == 0) { + simArgs[nsimArgs++] = "-s"; + simArgs[nsimArgs++] = strdup(argv[++i]); + continue ; + } + + if (strcmp(argv[i],"-S") == 0) { + simArgs[nsimArgs++] = "-s"; + simArgs[nsimArgs++] = strdup(argv[++i]); + continue ; + } + + fprintf(stderr,"unknown option %s --- ignored\n", + argv[i]); + } else { + /* must be file name */ + if (filename) { + fprintf(stderr,"too many filenames .. parameter '%s' ignored\n", + argv[i]); + continue ; + } + + filename = strtok(argv[i],"."); + + } + } + + if (filename) + cmdFile(filename,NULL); +} + +/*-----------------------------------------------------------------*/ +/* main - */ +/*-----------------------------------------------------------------*/ + +int main ( int argc, char **argv) +{ + printVersionInfo(); + /* parse command line */ + parseCmdLine(argc,argv); + + commandLoop(); + + return 0; +} diff --git a/debugger/mcs51/sdcdb.el b/debugger/mcs51/sdcdb.el new file mode 100644 index 00000000..6919b1cf --- /dev/null +++ b/debugger/mcs51/sdcdb.el @@ -0,0 +1,650 @@ +;;; sdcdb.el --- run sdcdb under Emacs + +;; Author: W. Schelter, University of Texas +;; wfs@rascal.ics.utexas.edu +;; Rewritten by rms. +;; Keywords: c, unix, tools, debugging + +;; Some ideas are due to Masanobu. + +;; This file is part of XEmacs. + +;; XEmacs 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, or (at your option) +;; any later version. + +;; XEmacs 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 XEmacs; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. + +;;; Synched up with: Not in FSF + +;;; Commentary: + +;; Description of SDCDB interface: + +;; A facility is provided for the simultaneous display of the source code +;; in one window, while using sdcdb to step through a function in the +;; other. A small arrow in the source window, indicates the current +;; line. + +;; Starting up: + +;; In order to use this facility, invoke the command SDCDB to obtain a +;; shell window with the appropriate command bindings. You will be asked +;; for the name of a file to run. Sdcdb will be invoked on this file, in a +;; window named *sdcdb-foo* if the file is foo. + +;; M-s steps by one line, and redisplays the source file and line. + +;; You may easily create additional commands and bindings to interact +;; with the display. For example to put the sdcdb command next on \M-n +;; (def-sdcdb next "\M-n") + +;; This causes the emacs command sdcdb-next to be defined, and runs +;; sdcdb-display-frame after the command. + +;; sdcdb-display-frame is the basic display function. It tries to display +;; in the other window, the file and line corresponding to the current +;; position in the sdcdb window. For example after a sdcdb-step, it would +;; display the line corresponding to the position for the last step. Or +;; if you have done a backtrace in the sdcdb buffer, and move the cursor +;; into one of the frames, it would display the position corresponding to +;; that frame. + +;; sdcdb-display-frame is invoked automatically when a filename-and-line-number +;; appears in the output. + +;;; Code: + +(require 'comint) +(require 'shell) + +(condition-case nil + (if (featurep 'toolbar) + (require 'eos-toolbar "sun-eos-toolbar")) + (error nil)) + +(defvar sdcdb-last-frame) +(defvar sdcdb-delete-prompt-marker) +(defvar sdcdb-filter-accumulator) +(defvar sdcdb-last-frame-displayed-p) +(defvar sdcdb-arrow-extent nil) +(or (fboundp 'make-glyph) (fset 'make-glyph 'identity)) ; work w/ pre beta v12 +(defvar sdcdb-arrow-glyph (make-glyph "=>")) + +(make-face 'sdcdb-arrow-face) +(or (face-differs-from-default-p 'sdcdb-arrow-face) + ;; Usually has a better default value than highlight does + (copy-face 'isearch 'sdcdb-arrow-face)) + +;; Hooks can side-effect extent arg to change extent properties +(defvar sdcdb-arrow-extent-hooks '()) + +(defvar sdcdb-prompt-pattern "^>\\|^(.*sdcdb[+]?) *\\|^---Type to.*--- *" + "A regexp to recognize the prompt for sdcdb or sdcdb+.") + +(defvar sdcdb-mode-map nil + "Keymap for sdcdb-mode.") + +(defvar sdcdb-toolbar nil) + +(if sdcdb-mode-map + nil + (setq sdcdb-mode-map (make-sparse-keymap)) + (set-keymap-name sdcdb-mode-map 'sdcdb-mode-map) + (set-keymap-parents sdcdb-mode-map (list comint-mode-map)) + (define-key sdcdb-mode-map "\C-l" 'sdcdb-refresh) + (define-key sdcdb-mode-map "\C-c\C-c" 'sdcdb-control-c-subjob) + (define-key sdcdb-mode-map "\t" 'comint-dynamic-complete) + (define-key sdcdb-mode-map "\M-?" 'comint-dynamic-list-completions)) + +(define-key ctl-x-map " " 'sdcdb-break) +(define-key ctl-x-map "&" 'send-sdcdb-command) + +;;Of course you may use `def-sdcdb' with any other sdcdb command, including +;;user defined ones. + +(defmacro def-sdcdb (name key &optional doc &rest forms) + (let* ((fun (intern (format "sdcdb-%s" name))) + (cstr (list 'if '(not (= 1 arg)) + (list 'format "%s %s" name 'arg) + name))) + (list 'progn + (nconc (list 'defun fun '(arg) + (or doc "") + '(interactive "p") + (list 'sdcdb-call cstr)) + forms) + (and key (list 'define-key 'sdcdb-mode-map key (list 'quote fun)))))) + +(def-sdcdb "step" "\M-s" "Step one source line with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "stepi" "\M-i" "Step one instruction with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "finish" "\C-c\C-f" "Finish executing current function" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "run" nil "Run the current program" + (sdcdb-delete-arrow-extent)) + +;;"next" and "cont" were bound to M-n and M-c in Emacs 18, but these are +;;poor choices, since M-n is used for history navigation and M-c is +;;capitalize-word. These are defined without key bindings so that users +;;may choose their own bindings. +(def-sdcdb "next" "\C-c\C-n" "Step one source line (skip functions)" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "cont" "\C-c\M-c" "Proceed with the program" + (sdcdb-delete-arrow-extent)) + +(def-sdcdb "up" "\C-c<" "Go up N stack frames (numeric arg) with display") +(def-sdcdb "down" "\C-c>" "Go down N stack frames (numeric arg) with display") + +(defvar sdcdb-display-mode nil + "Minor mode for sdcdb frame display") +(or (assq 'sdcdb-display-mode minor-mode-alist) + (setq minor-mode-alist + (purecopy + (append minor-mode-alist + '((sdcdb-display-mode " Frame")))))) + +(defun sdcdb-display-mode (&optional arg) + "Toggle SDCDB Frame display mode +With arg, turn display mode on if and only if arg is positive. +In the display minor mode, source file are displayed in another +window for repective \\[sdcdb-display-frame] commands." + (interactive "P") + (setq sdcdb-display-mode (if (null arg) + (not sdcdb-display-mode) + (> (prefix-numeric-value arg) 0)))) + +;; Using cc-mode's syntax table is broken. +(defvar sdcdb-mode-syntax-table nil + "Syntax table for SDCDB mode.") + +;; This is adapted from CC Mode 5.11. +(unless sdcdb-mode-syntax-table + (setq sdcdb-mode-syntax-table (make-syntax-table)) + ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS! + (modify-syntax-entry ?_ "_" sdcdb-mode-syntax-table) + (modify-syntax-entry ?\\ "\\" sdcdb-mode-syntax-table) + (modify-syntax-entry ?+ "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?- "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?= "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?% "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?< "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?> "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?& "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?| "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?\' "\"" sdcdb-mode-syntax-table) + ;; add extra comment syntax + (modify-syntax-entry ?/ ". 14" sdcdb-mode-syntax-table) + (modify-syntax-entry ?* ". 23" sdcdb-mode-syntax-table)) + + +(defun sdcdb-mode () + "Major mode for interacting with an inferior Sdcdb process. +The following commands are available: + +\\{sdcdb-mode-map} + +\\[sdcdb-display-frame] displays in the other window +the last line referred to in the sdcdb buffer. See also +\\[sdcdb-display-mode]. + +\\[sdcdb-step],\\[sdcdb-next], and \\[sdcdb-nexti] in the sdcdb window, +call sdcdb to step,next or nexti and then update the other window +with the current file and position. + +If you are in a source file, you may select a point to break +at, by doing \\[sdcdb-break]. + +Commands: +Many commands are inherited from comint mode. +Additionally we have: + +\\[sdcdb-display-frame] display frames file in other window +\\[sdcdb-step] advance one line in program +\\[send-sdcdb-command] used for special printing of an arg at the current point. +C-x SPACE sets break point at current line." + (interactive) + (comint-mode) + (use-local-map sdcdb-mode-map) + (set-syntax-table sdcdb-mode-syntax-table) + (make-local-variable 'sdcdb-last-frame-displayed-p) + (make-local-variable 'sdcdb-last-frame) + (make-local-variable 'sdcdb-delete-prompt-marker) + (make-local-variable 'sdcdb-display-mode) + (make-local-variable' sdcdb-filter-accumulator) + (setq sdcdb-last-frame nil + sdcdb-delete-prompt-marker nil + sdcdb-filter-accumulator nil + sdcdb-display-mode t + major-mode 'sdcdb-mode + mode-name "Inferior SDCDB" + comint-prompt-regexp sdcdb-prompt-pattern + sdcdb-last-frame-displayed-p t) + (set (make-local-variable 'shell-dirtrackp) t) + ;;(make-local-variable 'sdcdb-arrow-extent) + (and (extentp sdcdb-arrow-extent) + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil) + ;; XEmacs change: + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdb-delete-arrow-extent nil t) + (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) + (run-hooks 'sdcdb-mode-hook)) + +(defun sdcdb-delete-arrow-extent () + (let ((inhibit-quit t)) + (if sdcdb-arrow-extent + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil))) + +(defvar current-sdcdb-buffer nil) + +;;;###autoload +(defvar sdcdb-command-name "sdcdb" + "Pathname for executing sdcdb.") + +;;;###autoload +(defun sdcdb (path &optional corefile) + "Run sdcdb on program FILE in buffer *sdcdb-FILE*. +The directory containing FILE becomes the initial working directory +and source-file directory for SDCDB. If you wish to change this, use +the SDCDB commands `cd DIR' and `directory'." + (interactive "FRun sdcdb on file: ") + (setq path (file-truename (expand-file-name path))) + (let ((file (file-name-nondirectory path))) + (switch-to-buffer (concat "*sdcdb-" file "*")) + (setq default-directory (file-name-directory path)) + (or (bolp) (newline)) + (insert "Current directory is " default-directory "\n") + (apply 'make-comint + (concat "sdcdb-" file) + (substitute-in-file-name sdcdb-command-name) + nil + "-fullname" + "-cd" default-directory + file + (and corefile (list corefile))) + (set-process-filter (get-buffer-process (current-buffer)) 'sdcdb-filter) + (set-process-sentinel (get-buffer-process (current-buffer)) 'sdcdb-sentinel) + ;; XEmacs change: turn on sdcdb mode after setting up the proc filters + ;; for the benefit of shell-font.el + (sdcdb-mode) + (sdcdb-set-buffer))) + +;;;###autoload +(defun sdcdb-with-core (file corefile) + "Debug a program using a corefile." + (interactive "fProgram to debug: \nfCore file to use: ") + (sdcdb file corefile)) + +(defun sdcdb-set-buffer () + (cond ((eq major-mode 'sdcdb-mode) + (setq current-sdcdb-buffer (current-buffer)) + (if (featurep 'eos-toolbar) + (set-specifier default-toolbar (cons (current-buffer) + sdcdb-toolbar)))))) + + +;; This function is responsible for inserting output from SDCDB +;; into the buffer. +;; Aside from inserting the text, it notices and deletes +;; each filename-and-line-number; +;; that SDCDB prints to identify the selected frame. +;; It records the filename and line number, and maybe displays that file. +(defun sdcdb-filter (proc string) + (let ((inhibit-quit t)) + (save-current-buffer + (set-buffer (process-buffer proc)) + (if sdcdb-filter-accumulator + (sdcdb-filter-accumulate-marker + proc (concat sdcdb-filter-accumulator string)) + (sdcdb-filter-scan-input proc string))))) + +(defun sdcdb-filter-accumulate-marker (proc string) + (setq sdcdb-filter-accumulator nil) + (if (> (length string) 1) + (if (= (aref string 1) ?\032) + (let ((end (string-match "\n" string))) + (if end + (progn + (let* ((first-colon (string-match ":" string 2)) + (second-colon + (string-match ":" string (1+ first-colon)))) + (setq sdcdb-last-frame + (cons (substring string 2 first-colon) + (string-to-int + (substring string (1+ first-colon) + second-colon))))) + (setq sdcdb-last-frame-displayed-p nil) + (sdcdb-filter-scan-input proc + (substring string (1+ end)))) + (setq sdcdb-filter-accumulator string))) + (sdcdb-filter-insert proc "\032") + (sdcdb-filter-scan-input proc (substring string 1))) + (setq sdcdb-filter-accumulator string))) + +(defun sdcdb-filter-scan-input (proc string) + (if (equal string "") + (setq sdcdb-filter-accumulator nil) + (let ((start (string-match "\032" string))) + (if start + (progn (sdcdb-filter-insert proc (substring string 0 start)) + (sdcdb-filter-accumulate-marker proc + (substring string start))) + (sdcdb-filter-insert proc string))))) + +(defun sdcdb-filter-insert (proc string) + (let ((moving (= (point) (process-mark proc))) + (output-after-point (< (point) (process-mark proc)))) + (save-excursion + ;; Insert the text, moving the process-marker. + (goto-char (process-mark proc)) + (insert-before-markers string) + (set-marker (process-mark proc) (point)) + (sdcdb-maybe-delete-prompt) + ;; Check for a filename-and-line number. + (sdcdb-display-frame + ;; Don't display the specified file + ;; unless (1) point is at or after the position where output appears + ;; and (2) this buffer is on the screen. + (or output-after-point + (not (get-buffer-window (current-buffer)))) + ;; Display a file only when a new filename-and-line-number appears. + t)) + (if moving (goto-char (process-mark proc)))) + + (let (s) + (if (and (should-use-dialog-box-p) + (setq s (or (string-match " (y or n) *\\'" string) + (string-match " (yes or no) *\\'" string)))) + (sdcdb-mouse-prompt-hack (substring string 0 s) (current-buffer)))) + ) + +(defun sdcdb-mouse-prompt-hack (prompt buffer) + (popup-dialog-box + (list prompt + (vector "Yes" (list 'sdcdb-mouse-prompt-hack-answer 't buffer) t) + (vector "No" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + nil + (vector "Cancel" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + ))) + +(defun sdcdb-mouse-prompt-hack-answer (answer buffer) + (let ((b (current-buffer))) + (unwind-protect + (progn + (set-buffer buffer) + (goto-char (process-mark (get-buffer-process buffer))) + (delete-region (point) (point-max)) + (insert (if answer "yes" "no")) + (comint-send-input)) + (set-buffer b)))) + +(defun sdcdb-sentinel (proc msg) + (cond ((null (buffer-name (process-buffer proc))) + ;; buffer killed + ;; Stop displaying an arrow in a source file. + ;(setq overlay-arrow-position nil) -- done by kill-buffer-hook + (set-process-buffer proc nil)) + ((memq (process-status proc) '(signal exit)) + ;; Stop displaying an arrow in a source file. + (sdcdb-delete-arrow-extent) + ;; Fix the mode line. + (setq modeline-process + (concat ": sdcdb " (symbol-name (process-status proc)))) + (let* ((obuf (current-buffer))) + ;; save-excursion isn't the right thing if + ;; process-buffer is current-buffer + (unwind-protect + (progn + ;; Write something in *compilation* and hack its mode line, + (set-buffer (process-buffer proc)) + ;; Force mode line redisplay soon + (set-buffer-modified-p (buffer-modified-p)) + (if (eobp) + (insert ?\n mode-name " " msg) + (save-excursion + (goto-char (point-max)) + (insert ?\n mode-name " " msg))) + ;; If buffer and mode line will show that the process + ;; is dead, we can delete it now. Otherwise it + ;; will stay around until M-x list-processes. + (delete-process proc)) + ;; Restore old buffer, but don't restore old point + ;; if obuf is the sdcdb buffer. + (set-buffer obuf)))))) + + +(defun sdcdb-refresh (&optional arg) + "Fix up a possibly garbled display, and redraw the arrow." + (interactive "P") + (recenter arg) + (sdcdb-display-frame)) + +(defun sdcdb-display-frame (&optional nodisplay noauto) + "Find, obey and delete the last filename-and-line marker from SDCDB. +The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n. +Obeying it means displaying in another window the specified file and line." + (interactive) + (sdcdb-set-buffer) + (and sdcdb-last-frame (not nodisplay) + sdcdb-display-mode + (or (not sdcdb-last-frame-displayed-p) (not noauto)) + (progn (sdcdb-display-line (car sdcdb-last-frame) (cdr sdcdb-last-frame)) + (setq sdcdb-last-frame-displayed-p t)))) + +;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen +;; and that its line LINE is visible. +;; Put the overlay-arrow on the line LINE in that buffer. + +(defun sdcdb-display-line (true-file line &optional select-method) + ;; FILE to display + ;; LINE number to highlight and make visible + ;; SELECT-METHOD 'source, 'debugger, or 'none. (default is 'debugger) + (and (null select-method) (setq select-method 'debugger)) + (let* ((pre-display-buffer-function nil) ; screw it, put it all in one screen + (pop-up-windows t) + (source-buffer (find-file-noselect true-file)) + (source-window (display-buffer source-buffer)) + (debugger-window (get-buffer-window current-sdcdb-buffer)) + (extent sdcdb-arrow-extent) + pos) + ;; XEmacs change: make sure we find a window displaying the source file + ;; even if we are already sitting in it when a breakpoint is hit. + ;; Otherwise the t argument to display-buffer will prevent it from being + ;; displayed. + (save-excursion + (cond ((eq select-method 'debugger) + ;; might not already be displayed + (setq debugger-window (display-buffer current-sdcdb-buffer)) + (select-window debugger-window)) + ((eq select-method 'source) + (select-window source-window)))) + (and extent + (not (eq (extent-object extent) source-buffer)) + (setq extent (delete-extent extent))) + (or extent + (progn + (setq extent (make-extent 1 1 source-buffer)) + (set-extent-face extent 'sdcdb-arrow-face) + (set-extent-begin-glyph extent sdcdb-arrow-glyph) + (set-extent-begin-glyph-layout extent 'whitespace) + (set-extent-priority extent 2000) + (setq sdcdb-arrow-extent extent))) + (save-current-buffer + (set-buffer source-buffer) + (save-restriction + (widen) + (goto-line line) + (set-window-point source-window (point)) + (setq pos (point)) + (end-of-line) + (set-extent-endpoints extent pos (point)) + (run-hook-with-args 'sdcdb-arrow-extent-hooks extent)) + (cond ((or (< pos (point-min)) (> pos (point-max))) + (widen) + (goto-char pos)))) + ;; Added by Stig. It caused lots of problems for several users + ;; and since its purpose is unclear it is getting commented out. + ;;(and debugger-window + ;; (set-window-point debugger-window pos)) + )) + +(defun sdcdb-call (command) + "Invoke sdcdb COMMAND displaying source in other window." + (interactive) + (goto-char (point-max)) + ;; Record info on the last prompt in the buffer and its position. + ;; This is used in sdcdb-maybe-delete-prompt + ;; to prevent multiple prompts from accumulating. + (save-excursion + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (let ((pt (point))) + (beginning-of-line) + (setq sdcdb-delete-prompt-marker + (if (= (point) pt) + nil + (list (point-marker) (- pt (point)) + (buffer-substring (point) pt)))))) + (sdcdb-set-buffer) + (process-send-string (get-buffer-process current-sdcdb-buffer) + (concat command "\n"))) + +(defun sdcdb-maybe-delete-prompt () + (if sdcdb-delete-prompt-marker + ;; Get the string that we used as the prompt before. + (let ((prompt (nth 2 sdcdb-delete-prompt-marker)) + (length (nth 1 sdcdb-delete-prompt-marker))) + ;; Position after it. + (goto-char (+ (car sdcdb-delete-prompt-marker) length)) + ;; Delete any duplicates of it which follow right after. + (while (and (<= (+ (point) length) (point-max)) + (string= prompt + (buffer-substring (point) (+ (point) length)))) + (delete-region (point) (+ (point) length))) + ;; If that didn't take us to where output is arriving, + ;; we have encountered something other than a prompt, + ;; so stop trying to delete any more prompts. + (if (not (= (point) + (process-mark (get-buffer-process current-sdcdb-buffer)))) + (progn + (set-marker (car sdcdb-delete-prompt-marker) nil) + (setq sdcdb-delete-prompt-marker nil)))))) + +(defun sdcdb-break (temp) + "Set SDCDB breakpoint at this source line. With ARG set temporary breakpoint." + (interactive "P") + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat (if temp "tbreak " "break ") file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-clear () + "Set SDCDB breakpoint at this source line." + (interactive) + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat "clear " file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-read-address() + "Return a string containing the core-address found in the buffer at point." + (save-excursion + (let ((pt (point)) found begin) + (setq found (if (search-backward "0x" (- pt 7) t)(point))) + (cond (found (forward-char 2) + (buffer-substring found + (progn (re-search-forward "[^0-9a-f]") + (forward-char -1) + (point)))) + (t (setq begin (progn (re-search-backward "[^0-9]") (forward-char 1) + (point))) + (forward-char 1) + (re-search-forward "[^0-9]") + (forward-char -1) + (buffer-substring begin (point))))))) + + +(defvar sdcdb-commands nil + "List of strings or functions used by send-sdcdb-command. +It is for customization by you.") + +(defun send-sdcdb-command (arg) + + "This command reads the number where the cursor is positioned. It + then inserts this ADDR at the end of the sdcdb buffer. A numeric arg + selects the ARG'th member COMMAND of the list sdcdb-print-command. If + COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise + (funcall COMMAND ADDR) is inserted. eg. \"p (rtx)%s->fld[0].rtint\" + is a possible string to be a member of sdcdb-commands. " + + + (interactive "P") + (let (comm addr) + (if arg (setq comm (nth arg sdcdb-commands))) + (setq addr (sdcdb-read-address)) + (if (eq (current-buffer) current-sdcdb-buffer) + (set-mark (point))) + (cond (comm + (setq comm + (if (stringp comm) (format comm addr) (funcall comm addr)))) + (t (setq comm addr))) + (switch-to-buffer current-sdcdb-buffer) + (goto-char (point-max)) + (insert comm))) + +(fset 'sdcdb-control-c-subjob 'comint-interrupt-subjob) + +;(defun sdcdb-control-c-subjob () +; "Send a Control-C to the subprocess." +; (interactive) +; (process-send-string (get-buffer-process (current-buffer)) +; "\C-c")) + +(defun sdcdb-toolbar-break () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-break nil))) + +(defun sdcdb-toolbar-clear () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-clear))) + +(provide 'sdcdb) + +;;; sdcdb.el ends here diff --git a/debugger/mcs51/sdcdb.h b/debugger/mcs51/sdcdb.h new file mode 100644 index 00000000..ad535b2c --- /dev/null +++ b/debugger/mcs51/sdcdb.h @@ -0,0 +1,230 @@ +/*------------------------------------------------------------------------- + sdcdb.h - Header file used by ALL source files for the debugger + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCDB_H +#define SDCDB_H + +/* #define SDCDB_DEBUG */ + +#include +#include +#include +#include +#include +#include "sdccconf.h" +#ifdef _NO_GC + +#define GC_malloc malloc +#define GC_free free +#define GC_realloc realloc + +#else + +#include "gc/gc.h" + +#endif + +#include "src/SDCCset.h" +#include "src/SDCChasht.h" + +#define TRUE 1 +#define FALSE !TRUE + +typedef short bool; + +#ifndef max +#define max(a,b) (a > b ? a : b) +#endif + +#ifndef min +#define min(a,b) (a < b ? a : b) +#endif + +#ifndef ALLOC +#define ALLOC(x,sz) if (!(x = GC_malloc(sz))) \ + { \ + fprintf(stderr,"sdcdb: out of memory\n"); \ + exit (1); \ + } +#endif + +/* generalpurpose stack related macros */ +#define STACK_DCL(stack,type,size) \ + typedef type t_##stack ; \ + t_##stack stack[size] ; \ + t_##stack (*p_##stack) = stack + (size); \ + t_##stack (*w_##stack) ; + +/* define extern stack */ +#define EXTERN_STACK_DCL(stack,type,size) \ + typedef type t_##stack ; \ + extern t_##stack stack[size] ; \ + extern t_##stack *p_##stack; \ + extern t_##stack *w_##stack; + +#define STACK_FULL(stack) ((p_##stack) <= stack ) +#define STACK_EMPTY(stack) ((p_##stack) >= (stack + \ + sizeof(stack)/sizeof(*stack)) ) + +#define STACK_PUSH_(stack,x) (*--p_##stack = (x)) +#define STACK_POP_(stack) (*p_##stack++) + +#define STACK_PUSH(stack,x) (STACK_FULL(stack) \ + ?((t_##stack)(long)(STACK_ERR(1))) \ + : STACK_PUSH_(stack,x) ) + +#define STACK_POP(stack) (STACK_EMPTY(stack) \ + ?((t_##stack)(long)(STACK_ERR(0))) \ + : STACK_POP_(stack) ) + +#define STACK_PEEK(stack) (STACK_EMPTY(stack) \ + ?((t_##stack) NULL) \ + : *p_##stack ) + +#define STACK_PPEEK(stack) (((p_##stack + 1) >= (stack + \ + sizeof(stack)/sizeof(*stack))) \ + ?((t_##stack) NULL) \ + : *(p_##stack + 1) ) + +#define STACK_ERR(o) ( o \ + ? fprintf(stderr,"stack Overflow\n")\ + : fprintf(stderr,"stack underflow\n")) + +#define STACK_STARTWALK(stack) (w_##stack = p_##stack) + +#define STACK_WALK(stack) (w_##stack >= (stack + sizeof(stack)/sizeof(*stack)) \ + ? NULL : *w_##stack++ ) + +#include "../sdcc.src/SDCCbitv.h" + +enum { + SYM_REC = 1, + LNK_REC , + FUNC_REC , + STRUCT_REC, + MOD_REC +}; + +enum { SRC_CMODE = 1, SRC_AMODE }; + +/*-----------------------------------------------------------------*/ +/* source line structure */ +/*-----------------------------------------------------------------*/ +typedef struct srcLine +{ + unsigned addr ; + short block, level; /* scope information */ + char *src ; + +} srcLine ; + +/*-----------------------------------------------------------------*/ +/* structure for cdb record */ +/*-----------------------------------------------------------------*/ +typedef struct cdbrecs { + char type ; /* type of line */ + char *line; /* contents of line */ + struct cdbrecs *next; /* next in chain */ +} cdbrecs ; + +/*-----------------------------------------------------------------*/ +/* module definition */ +/*-----------------------------------------------------------------*/ +typedef struct module { + char *cfullname ; /* full name Includeing path for the module */ + char *afullname; /* fullname of assembly file */ + char *name ; /* name of module */ + char *c_name; /* c filename */ + char *asm_name; /* asm file name */ + int ncLines; /* number of lines in this module */ + int nasmLines; /* # of lines in the assembler file */ + srcLine **cLines; /* actual source lines */ + srcLine **asmLines; /* actual assembler source lines*/ +} module; + +/*-----------------------------------------------------------------*/ +/* execution point definition */ +/*-----------------------------------------------------------------*/ +typedef struct exePoint +{ + unsigned addr ; + int line ; + short block , level ; +} exePoint ; + +/*-----------------------------------------------------------------*/ +/* definition for a function */ +/*-----------------------------------------------------------------*/ +typedef struct function { + struct symbol *sym ;/* pointer to symbol for function */ + char *modName ;/* module name */ + module *mod ;/* module for this function */ + int entryline ;/* first line in the function */ + int aentryline ; + int exitline ;/* last line in the function */ + int aexitline ; + set *cfpoints ;/* set of all C execution points in func */ + set *afpoints ;/* set of all ASM execution points in func */ + unsigned int laddr ;/* last executed address */ + int lline ;/* last executed linenumber */ +} function ; + +/*-----------------------------------------------------------------*/ +/* link record defintion */ +/*-----------------------------------------------------------------*/ +typedef struct linkrec { + char type; /* type of linker rec */ + unsigned addr ; /* address specified by the linker rec */ + char *name ; /* name specified by linker rec */ +} linkrec; + +/*-----------------------------------------------------------------*/ +/* program context */ +/*-----------------------------------------------------------------*/ +typedef struct context { + function *func; /* current function we are in */ + char *modName; /* name of the module */ + unsigned int addr ; /* current pc */ + int cline ; /* current c line number */ + int asmline; /* current asm line number */ + int block ; /* current block number */ + int level ; /* current level number */ +} context ; + +extern cdbrecs *recsRoot ; +extern context *currCtxt ; +extern set *modules ; /* set of modules */ +extern set *functions; /* set of functions */ +extern set *symbols ; /* set of symbols */ + +extern int nStructs ; +extern struct structdef **structs ; /* all structures */ +extern char *ssdirl; /* source directory search path */ +void **resize (void **, int ); +char *alloccpy(char *,int ); +srcLine **loadFile (char *name, int *nlines); +extern short fullname; +extern int srcMode; +char *searchDirsFname (char *); + +#endif diff --git a/debugger/mcs51/sdcdbsrc.el b/debugger/mcs51/sdcdbsrc.el new file mode 100644 index 00000000..7b3f7b96 --- /dev/null +++ b/debugger/mcs51/sdcdbsrc.el @@ -0,0 +1,1557 @@ +;;; sdcdbsrc.el -- Source-based (as opposed to comint-based) debugger +;; interaction mode eventually, this will be unified with GUD +;; (after gud works reliably w/ XEmacs...) +;; Keywords: c, unix, tools, debugging + +;; Copyright (C) 1990 Debby Ayers , and +;; Rich Schaefer +;; Copyright (C) 1994, 1995 Tinker Systems and INS Engineering Corp. +;; +;; Copyright (C) 1999 Sandeep Dutta +;; +;; This file is part of XEmacs. +;; +;; XEmacs 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. +;; +;; XEmacs 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 XEmacs; if not, write to the Free Software +;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +;; Based upon code for version18 by Debra Ayers + +;;; SDCDBSRC:: +;;; Sdcdbsrc extends the emacs SDCDB interface to accept sdcdb commands issued +;;; from the source code buffer. Sdcdbsrc behaves similar to sdcdb except +;;; now most debugging may be done from the source code using the *sdcdb* +;;; buffer to view output. Supports a point and click model under X to +;;; evaluate source code expressions (no more typing long variable names). +;;; +;;; Supports C source at the moment but C++ support will be added if there +;;; is sufficient interest. +;;; + +;; SDCDBSRC::Sdcdb Source Mode Interface description. +;; Sdcdbsrc extends the emacs SDCDB interface to accept sdcdb commands issued +;; from the source code buffer. Sdcdbsrc behaves similar to sdcdb except now all +;; debugging may be done from the currently focused source buffer using +;; the *sdcdb* buffer to view output. + +;; When source files are displayed through sdcdbsrc, buffers are put in +;; sdcdbsrc-mode minor mode. This mode puts the buffer in read-only state +;; and sets up a special key and mouse map to invoke communication with +;; the current sdcdb process. The minor mode may be toggled on/off as needed. +;; (ESC-T) + +;; C-expressions may be evaluated by sdcdbsrc by simply pointing at text in the +;; current source buffer with the mouse or by centering the cursor over text +;; and typing a single key command. ('p' for print, '*' for print *). + +;; As code is debugged and new buffers are displayed, the focus of sdcdbsrc +;; follows to each new source buffer. Makes debugging fun. (sound like a +;; commercial or what!) +;; + +;; Current Listing :: +;;key binding Comment +;;--- ------- ------- +;; +;; r sdcdb-return-from-src SDCDB return command +;; n sdcdb-next-from-src SDCDB next command +;; b sdcdb-back-from-src SDCDB back command +;; w sdcdb-where-from-src SDCDB where command +;; f sdcdb-finish-from-src SDCDB finish command +;; u sdcdb-up-from-src SDCDB up command +;; d sdcdb-down-from-src SDCDB down command +;; c sdcdb-cont-from-src SDCDB continue command +;; i sdcdb-stepi-from-src SDCDB step instruction command +;; s sdcdb-step-from-src SDCDB step command +;; ? sdcdb-whatis-c-sexp SDCDB whatis command for data at +;; buffer point +;; x sdcdbsrc-delete SDCDB Delete all breakpoints if no arg +;; given or delete arg (C-u arg x) +;; m sdcdbsrc-frame SDCDB Display current frame if no arg, +;; given or display frame arg +;; * sdcdb-*print-c-sexp SDCDB print * command for data at +;; buffer point +;; ! sdcdbsrc-goto-sdcdb Goto the SDCDB output buffer +;; p sdcdb-print-c-sexp SDCDB print * command for data at +;; buffer point +;; g sdcdbsrc-goto-sdcdb Goto the SDCDB output buffer +;; t sdcdbsrc-mode Toggles Sdcdbsrc mode (turns it off) +;; +;; C-c C-f sdcdb-finish-from-src SDCDB finish command +;; +;; C-x SPC sdcdb-break Set break for line with point +;; ESC t sdcdbsrc-mode Toggle Sdcdbsrc mode +;; ESC m sdcdbsrc-srcmode Toggle list mode +;; +;; Local Bindings for buffer when you exit Sdcdbsrc minor mode +;; +;; C-x SPC sdcdb-break Set break for line with point +;; ESC t sdcdbsrc-mode Toggle Sdcdbsrc mode +;; + +;;; (eval-when-compile +;;; (or noninteractive +;;; (progn +;;; (message "ONLY compile sdcdbsrc except with -batch because of advice") +;;; (ding) +;;; ))) +;;; sdcdb.el --- run sdcdb under Emacs + +;; Author: W. Schelter, University of Texas +;; wfs@rascal.ics.utexas.edu +;; Rewritten by rms. +;; Keywords: c, unix, tools, debugging + +;; Some ideas are due to Masanobu. + +;; This file is part of XEmacs. + +;; XEmacs 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, or (at your option) +;; any later version. + +;; XEmacs 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 XEmacs; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. + +;;; Synched up with: Not in FSF + +;;; Commentary: + +;; Description of SDCDB interface: + +;; A facility is provided for the simultaneous display of the source code +;; in one window, while using sdcdb to step through a function in the +;; other. A small arrow in the source window, indicates the current +;; line. + +;; Starting up: + +;; In order to use this facility, invoke the command SDCDB to obtain a +;; shell window with the appropriate command bindings. You will be asked +;; for the name of a file to run. Sdcdb will be invoked on this file, in a +;; window named *sdcdb-foo* if the file is foo. + +;; M-s steps by one line, and redisplays the source file and line. + +;; You may easily create additional commands and bindings to interact +;; with the display. For example to put the sdcdb command next on \M-n +;; (def-sdcdb next "\M-n") + +;; This causes the emacs command sdcdb-next to be defined, and runs +;; sdcdb-display-frame after the command. + +;; sdcdb-display-frame is the basic display function. It tries to display +;; in the other window, the file and line corresponding to the current +;; position in the sdcdb window. For example after a sdcdb-step, it would +;; display the line corresponding to the position for the last step. Or +;; if you have done a backtrace in the sdcdb buffer, and move the cursor +;; into one of the frames, it would display the position corresponding to +;; that frame. + +;; sdcdb-display-frame is invoked automatically when a filename-and-line-number +;; appears in the output. + +;;; Code: + +(require 'comint) +(require 'shell) + +(condition-case nil + (if (featurep 'toolbar) + (require 'eos-toolbar "sun-eos-toolbar")) + (error nil)) + +(defvar sdcdb-last-frame) +(defvar sdcdb-delete-prompt-marker) +(defvar sdcdb-filter-accumulator) +(defvar sdcdb-last-frame-displayed-p) +(defvar sdcdb-arrow-extent nil) +(or (fboundp 'make-glyph) (fset 'make-glyph 'identity)) ; work w/ pre beta v12 +(defvar sdcdb-arrow-glyph (make-glyph "=>")) + +(make-face 'sdcdb-arrow-face) +(or (face-differs-from-default-p 'sdcdb-arrow-face) + ;; Usually has a better default value than highlight does + (copy-face 'isearch 'sdcdb-arrow-face)) + +;; Hooks can side-effect extent arg to change extent properties +(defvar sdcdb-arrow-extent-hooks '()) + +(defvar sdcdb-prompt-pattern "^>\\|^(.*sdcdb[+]?) *\\|^---Type to.*--- *" + "A regexp to recognize the prompt for sdcdb or sdcdb+.") + +(defvar sdcdb-mode-map nil + "Keymap for sdcdb-mode.") + +(defvar sdcdb-toolbar nil) + +(if sdcdb-mode-map + nil + (setq sdcdb-mode-map (make-sparse-keymap)) + (set-keymap-name sdcdb-mode-map 'sdcdb-mode-map) + (set-keymap-parents sdcdb-mode-map (list comint-mode-map)) + (define-key sdcdb-mode-map "\C-l" 'sdcdb-refresh) + (define-key sdcdb-mode-map "\C-c\C-c" 'sdcdb-control-c-subjob) + (define-key sdcdb-mode-map "\t" 'comint-dynamic-complete) + (define-key sdcdb-mode-map "\M-?" 'comint-dynamic-list-completions)) + +(define-key ctl-x-map " " 'sdcdb-break) +(define-key ctl-x-map "&" 'send-sdcdb-command) + +;;Of course you may use `def-sdcdb' with any other sdcdb command, including +;;user defined ones. + +(defmacro def-sdcdb (name key &optional doc &rest forms) + (let* ((fun (intern (format "sdcdb-%s" name))) + (cstr (list 'if '(not (= 1 arg)) + (list 'format "%s %s" name 'arg) + name))) + (list 'progn + (nconc (list 'defun fun '(arg) + (or doc "") + '(interactive "p") + (list 'sdcdb-call cstr)) + forms) + (and key (list 'define-key 'sdcdb-mode-map key (list 'quote fun)))))) + +(def-sdcdb "step" "\M-s" "Step one source line with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "stepi" "\M-i" "Step one instruction with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "finish" "\C-c\C-f" "Finish executing current function" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "run" nil "Run the current program" + (sdcdb-delete-arrow-extent)) + +;;"next" and "cont" were bound to M-n and M-c in Emacs 18, but these are +;;poor choices, since M-n is used for history navigation and M-c is +;;capitalize-word. These are defined without key bindings so that users +;;may choose their own bindings. +(def-sdcdb "next" "\C-c\C-n" "Step one source line (skip functions)" + (sdcdb-delete-arrow-extent)) +(def-sdcdb "cont" "\C-c\M-c" "Proceed with the program" + (sdcdb-delete-arrow-extent)) + +(def-sdcdb "up" "\C-c<" "Go up N stack frames (numeric arg) with display") +(def-sdcdb "down" "\C-c>" "Go down N stack frames (numeric arg) with display") + +(defvar sdcdb-display-mode nil + "Minor mode for sdcdb frame display") +(or (assq 'sdcdb-display-mode minor-mode-alist) + (setq minor-mode-alist + (purecopy + (append minor-mode-alist + '((sdcdb-display-mode " Frame")))))) + +(defun sdcdb-display-mode (&optional arg) + "Toggle SDCDB Frame display mode +With arg, turn display mode on if and only if arg is positive. +In the display minor mode, source file are displayed in another +window for repective \\[sdcdb-display-frame] commands." + (interactive "P") + (setq sdcdb-display-mode (if (null arg) + (not sdcdb-display-mode) + (> (prefix-numeric-value arg) 0)))) + +;; Using cc-mode's syntax table is broken. +(defvar sdcdb-mode-syntax-table nil + "Syntax table for SDCDB mode.") + +;; This is adapted from CC Mode 5.11. +(unless sdcdb-mode-syntax-table + (setq sdcdb-mode-syntax-table (make-syntax-table)) + ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS! + (modify-syntax-entry ?_ "_" sdcdb-mode-syntax-table) + (modify-syntax-entry ?\\ "\\" sdcdb-mode-syntax-table) + (modify-syntax-entry ?+ "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?- "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?= "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?% "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?< "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?> "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?& "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?| "." sdcdb-mode-syntax-table) + (modify-syntax-entry ?\' "\"" sdcdb-mode-syntax-table) + ;; add extra comment syntax + (modify-syntax-entry ?/ ". 14" sdcdb-mode-syntax-table) + (modify-syntax-entry ?* ". 23" sdcdb-mode-syntax-table)) + + +(defun sdcdb-mode () + "Major mode for interacting with an inferior Sdcdb process. +The following commands are available: + +\\{sdcdb-mode-map} + +\\[sdcdb-display-frame] displays in the other window +the last line referred to in the sdcdb buffer. See also +\\[sdcdb-display-mode]. + +\\[sdcdb-step],\\[sdcdb-next], and \\[sdcdb-nexti] in the sdcdb window, +call sdcdb to step,next or nexti and then update the other window +with the current file and position. + +If you are in a source file, you may select a point to break +at, by doing \\[sdcdb-break]. + +Commands: +Many commands are inherited from comint mode. +Additionally we have: + +\\[sdcdb-display-frame] display frames file in other window +\\[sdcdb-step] advance one line in program +\\[send-sdcdb-command] used for special printing of an arg at the current point. +C-x SPACE sets break point at current line." + (interactive) + (comint-mode) + (use-local-map sdcdb-mode-map) + (set-syntax-table sdcdb-mode-syntax-table) + (make-local-variable 'sdcdb-last-frame-displayed-p) + (make-local-variable 'sdcdb-last-frame) + (make-local-variable 'sdcdb-delete-prompt-marker) + (make-local-variable 'sdcdb-display-mode) + (make-local-variable' sdcdb-filter-accumulator) + (setq sdcdb-last-frame nil + sdcdb-delete-prompt-marker nil + sdcdb-filter-accumulator nil + sdcdb-display-mode t + major-mode 'sdcdb-mode + mode-name "Inferior SDCDB" + comint-prompt-regexp sdcdb-prompt-pattern + sdcdb-last-frame-displayed-p t) + (set (make-local-variable 'shell-dirtrackp) t) + ;;(make-local-variable 'sdcdb-arrow-extent) + (and (extentp sdcdb-arrow-extent) + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil) + ;; XEmacs change: + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdb-delete-arrow-extent nil t) + (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) + (run-hooks 'sdcdb-mode-hook)) + +(defun sdcdb-delete-arrow-extent () + (let ((inhibit-quit t)) + (if sdcdb-arrow-extent + (delete-extent sdcdb-arrow-extent)) + (setq sdcdb-arrow-extent nil))) + +(defvar current-sdcdb-buffer nil) + +;;;###autoload +(defvar sdcdb-command-name "sdcdb" + "Pathname for executing sdcdb.") +;; +;; default values should be changed as needed +;; +(defvar sdcdbsrc-cpu-type "51") +(defvar sdcdbsrc-frequency "11059200") +(defvar sdcdbsrc-serial nil) + +;;;###autoload +(defun sdcdb (path &optional corefile) + "Run sdcdb on program FILE in buffer *sdcdb-FILE*. +The directory containing FILE becomes the initial working directory +and source-file directory for SDCDB. If you wish to change this, use +the SDCDB commands `cd DIR' and `directory'." + (interactive "FRun sdcdb on file: ") + (setq path (file-truename (expand-file-name path))) + (let ((file (file-name-nondirectory path))) + (switch-to-buffer (concat "*sdcdb-" file "*")) + (setq default-directory (file-name-directory path)) + (or (bolp) (newline)) + (insert "Current directory is " default-directory "\n") + (apply 'make-comint + (concat "sdcdb-" file) + (substitute-in-file-name sdcdb-command-name) + nil + "-cpu" + sdcdbsrc-cpu-type + "-X" + sdcdbsrc-frequency + "-fullname" + file + (and corefile (list corefile))) + (set-process-filter (get-buffer-process (current-buffer)) 'sdcdb-filter) + (set-process-sentinel (get-buffer-process (current-buffer)) 'sdcdb-sentinel) + ;; XEmacs change: turn on sdcdb mode after setting up the proc filters + ;; for the benefit of shell-font.el + (sdcdb-mode) + (sdcdb-set-buffer))) + +;;;###autoload +(defun sdcdb-with-core (file corefile) + "Debug a program using a corefile." + (interactive "fProgram to debug: \nfCore file to use: ") + (sdcdb file corefile)) + +(defun sdcdb-set-buffer () + (cond ((eq major-mode 'sdcdb-mode) + (setq current-sdcdb-buffer (current-buffer)) + (if (featurep 'eos-toolbar) + (set-specifier default-toolbar (cons (current-buffer) + sdcdb-toolbar)))))) + + +;; This function is responsible for inserting output from SDCDB +;; into the buffer. +;; Aside from inserting the text, it notices and deletes +;; each filename-and-line-number; +;; that SDCDB prints to identify the selected frame. +;; It records the filename and line number, and maybe displays that file. +(defun sdcdb-filter (proc string) + (let ((inhibit-quit t)) + (save-current-buffer + (set-buffer (process-buffer proc)) + (if sdcdb-filter-accumulator + (sdcdb-filter-accumulate-marker + proc (concat sdcdb-filter-accumulator string)) + (sdcdb-filter-scan-input proc string))))) + +(defun sdcdb-filter-accumulate-marker (proc string) + (setq sdcdb-filter-accumulator nil) + (if (> (length string) 1) + (if (= (aref string 1) ?\032) + (let ((end (string-match "\n" string))) + (if end + (progn + (let* ((first-colon (string-match ":" string 2)) + (second-colon + (string-match ":" string (1+ first-colon)))) + (setq sdcdb-last-frame + (cons (substring string 2 first-colon) + (string-to-int + (substring string (1+ first-colon) + second-colon))))) + (setq sdcdb-last-frame-displayed-p nil) + (sdcdb-filter-scan-input proc + (substring string (1+ end)))) + (setq sdcdb-filter-accumulator string))) + (sdcdb-filter-insert proc "\032") + (sdcdb-filter-scan-input proc (substring string 1))) + (setq sdcdb-filter-accumulator string))) + +(defun sdcdb-filter-scan-input (proc string) + (if (equal string "") + (setq sdcdb-filter-accumulator nil) + (let ((start (string-match "\032" string))) + (if start + (progn (sdcdb-filter-insert proc (substring string 0 start)) + (sdcdb-filter-accumulate-marker proc + (substring string start))) + (sdcdb-filter-insert proc string))))) + +(defun sdcdb-filter-insert (proc string) + (let ((moving (= (point) (process-mark proc))) + (output-after-point (< (point) (process-mark proc)))) + (save-excursion + ;; Insert the text, moving the process-marker. + (goto-char (process-mark proc)) + (insert-before-markers string) + (set-marker (process-mark proc) (point)) + (sdcdb-maybe-delete-prompt) + ;; Check for a filename-and-line number. + (sdcdb-display-frame + ;; Don't display the specified file + ;; unless (1) point is at or after the position where output appears + ;; and (2) this buffer is on the screen. + (or output-after-point + (not (get-buffer-window (current-buffer)))) + ;; Display a file only when a new filename-and-line-number appears. + t)) + (if moving (goto-char (process-mark proc)))) + + (let (s) + (if (and (should-use-dialog-box-p) + (setq s (or (string-match " (y or n) *\\'" string) + (string-match " (yes or no) *\\'" string)))) + (sdcdb-mouse-prompt-hack (substring string 0 s) (current-buffer)))) + ) + +(defun sdcdb-mouse-prompt-hack (prompt buffer) + (popup-dialog-box + (list prompt + (vector "Yes" (list 'sdcdb-mouse-prompt-hack-answer 't buffer) t) + (vector "No" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + nil + (vector "Cancel" (list 'sdcdb-mouse-prompt-hack-answer 'nil buffer) t) + ))) + +(defun sdcdb-mouse-prompt-hack-answer (answer buffer) + (let ((b (current-buffer))) + (unwind-protect + (progn + (set-buffer buffer) + (goto-char (process-mark (get-buffer-process buffer))) + (delete-region (point) (point-max)) + (insert (if answer "yes" "no")) + (comint-send-input)) + (set-buffer b)))) + +(defun sdcdb-sentinel (proc msg) + (cond ((null (buffer-name (process-buffer proc))) + ;; buffer killed + ;; Stop displaying an arrow in a source file. + ;(setq overlay-arrow-position nil) -- done by kill-buffer-hook + (set-process-buffer proc nil)) + ((memq (process-status proc) '(signal exit)) + ;; Stop displaying an arrow in a source file. + (sdcdb-delete-arrow-extent) + ;; Fix the mode line. + (setq modeline-process + (concat ": sdcdb " (symbol-name (process-status proc)))) + (let* ((obuf (current-buffer))) + ;; save-excursion isn't the right thing if + ;; process-buffer is current-buffer + (unwind-protect + (progn + ;; Write something in *compilation* and hack its mode line, + (set-buffer (process-buffer proc)) + ;; Force mode line redisplay soon + (set-buffer-modified-p (buffer-modified-p)) + (if (eobp) + (insert ?\n mode-name " " msg) + (save-excursion + (goto-char (point-max)) + (insert ?\n mode-name " " msg))) + ;; If buffer and mode line will show that the process + ;; is dead, we can delete it now. Otherwise it + ;; will stay around until M-x list-processes. + (delete-process proc)) + ;; Restore old buffer, but don't restore old point + ;; if obuf is the sdcdb buffer. + (set-buffer obuf)))))) + + +(defun sdcdb-refresh (&optional arg) + "Fix up a possibly garbled display, and redraw the arrow." + (interactive "P") + (recenter arg) + (sdcdb-display-frame)) + +(defun sdcdb-display-frame (&optional nodisplay noauto) + "Find, obey and delete the last filename-and-line marker from SDCDB. +The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n. +Obeying it means displaying in another window the specified file and line." + (interactive) + (sdcdb-set-buffer) + (and sdcdb-last-frame (not nodisplay) + sdcdb-display-mode + (or (not sdcdb-last-frame-displayed-p) (not noauto)) + (progn (sdcdb-display-line (car sdcdb-last-frame) (cdr sdcdb-last-frame)) + (setq sdcdb-last-frame-displayed-p t)))) + +;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen +;; and that its line LINE is visible. +;; Put the overlay-arrow on the line LINE in that buffer. + +(defun sdcdb-display-line (true-file line &optional select-method) + ;; FILE to display + ;; LINE number to highlight and make visible + ;; SELECT-METHOD 'source, 'debugger, or 'none. (default is 'debugger) + (and (null select-method) (setq select-method 'debugger)) + (let* ((pre-display-buffer-function nil) ; screw it, put it all in one screen + (pop-up-windows t) + (source-buffer (find-file-noselect true-file)) + (source-window (display-buffer source-buffer)) + (debugger-window (get-buffer-window current-sdcdb-buffer)) + (extent sdcdb-arrow-extent) + pos) + ;; XEmacs change: make sure we find a window displaying the source file + ;; even if we are already sitting in it when a breakpoint is hit. + ;; Otherwise the t argument to display-buffer will prevent it from being + ;; displayed. + (save-excursion + (cond ((eq select-method 'debugger) + ;; might not already be displayed + (setq debugger-window (display-buffer current-sdcdb-buffer)) + (select-window debugger-window)) + ((eq select-method 'source) + (select-window source-window)))) + (and extent + (not (eq (extent-object extent) source-buffer)) + (setq extent (delete-extent extent))) + (or extent + (progn + (setq extent (make-extent 1 1 source-buffer)) + (set-extent-face extent 'sdcdb-arrow-face) + (set-extent-begin-glyph extent sdcdb-arrow-glyph) + (set-extent-begin-glyph-layout extent 'whitespace) + (set-extent-priority extent 2000) + (setq sdcdb-arrow-extent extent))) + (save-current-buffer + (set-buffer source-buffer) + (save-restriction + (widen) + (goto-line line) + (set-window-point source-window (point)) + (setq pos (point)) + (end-of-line) + (set-extent-endpoints extent pos (point)) + (run-hook-with-args 'sdcdb-arrow-extent-hooks extent)) + (cond ((or (< pos (point-min)) (> pos (point-max))) + (widen) + (goto-char pos)))) + ;; Added by Stig. It caused lots of problems for several users + ;; and since its purpose is unclear it is getting commented out. + ;;(and debugger-window + ;; (set-window-point debugger-window pos)) + )) + +(defun sdcdb-call (command) + "Invoke sdcdb COMMAND displaying source in other window." + (interactive) + (goto-char (point-max)) + ;; Record info on the last prompt in the buffer and its position. + ;; This is used in sdcdb-maybe-delete-prompt + ;; to prevent multiple prompts from accumulating. + (save-excursion + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (let ((pt (point))) + (beginning-of-line) + (setq sdcdb-delete-prompt-marker + (if (= (point) pt) + nil + (list (point-marker) (- pt (point)) + (buffer-substring (point) pt)))))) + (sdcdb-set-buffer) + (process-send-string (get-buffer-process current-sdcdb-buffer) + (concat command "\n"))) + +(defun sdcdb-maybe-delete-prompt () + (if sdcdb-delete-prompt-marker + ;; Get the string that we used as the prompt before. + (let ((prompt (nth 2 sdcdb-delete-prompt-marker)) + (length (nth 1 sdcdb-delete-prompt-marker))) + ;; Position after it. + (goto-char (+ (car sdcdb-delete-prompt-marker) length)) + ;; Delete any duplicates of it which follow right after. + (while (and (<= (+ (point) length) (point-max)) + (string= prompt + (buffer-substring (point) (+ (point) length)))) + (delete-region (point) (+ (point) length))) + ;; If that didn't take us to where output is arriving, + ;; we have encountered something other than a prompt, + ;; so stop trying to delete any more prompts. + (if (not (= (point) + (process-mark (get-buffer-process current-sdcdb-buffer)))) + (progn + (set-marker (car sdcdb-delete-prompt-marker) nil) + (setq sdcdb-delete-prompt-marker nil)))))) + +(defun sdcdb-break (temp) + "Set SDCDB breakpoint at this source line. With ARG set temporary breakpoint." + (interactive "P") + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat (if temp "tbreak " "break ") file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-clear () + "Set SDCDB breakpoint at this source line." + (interactive) + (let* ((file-name (file-name-nondirectory buffer-file-name)) + (line (save-restriction + (widen) + (beginning-of-line) + (1+ (count-lines 1 (point))))) + (cmd (concat "clear " file-name ":" + (int-to-string line)))) + (set-buffer current-sdcdb-buffer) + (goto-char (process-mark (get-buffer-process current-sdcdb-buffer))) + (delete-region (point) (point-max)) + (insert cmd) + (comint-send-input) + ;;(process-send-string (get-buffer-process current-sdcdb-buffer) cmd) + )) + +(defun sdcdb-read-address() + "Return a string containing the core-address found in the buffer at point." + (save-excursion + (let ((pt (point)) found begin) + (setq found (if (search-backward "0x" (- pt 7) t)(point))) + (cond (found (forward-char 2) + (buffer-substring found + (progn (re-search-forward "[^0-9a-f]") + (forward-char -1) + (point)))) + (t (setq begin (progn (re-search-backward "[^0-9]") (forward-char 1) + (point))) + (forward-char 1) + (re-search-forward "[^0-9]") + (forward-char -1) + (buffer-substring begin (point))))))) + + +(defvar sdcdb-commands nil + "List of strings or functions used by send-sdcdb-command. +It is for customization by you.") + +(defun send-sdcdb-command (arg) + + "This command reads the number where the cursor is positioned. It + then inserts this ADDR at the end of the sdcdb buffer. A numeric arg + selects the ARG'th member COMMAND of the list sdcdb-print-command. If + COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise + (funcall COMMAND ADDR) is inserted. eg. \"p (rtx)%s->fld[0].rtint\" + is a possible string to be a member of sdcdb-commands. " + + + (interactive "P") + (let (comm addr) + (if arg (setq comm (nth arg sdcdb-commands))) + (setq addr (sdcdb-read-address)) + (if (eq (current-buffer) current-sdcdb-buffer) + (set-mark (point))) + (cond (comm + (setq comm + (if (stringp comm) (format comm addr) (funcall comm addr)))) + (t (setq comm addr))) + (switch-to-buffer current-sdcdb-buffer) + (goto-char (point-max)) + (insert comm))) + +(fset 'sdcdb-control-c-subjob 'comint-interrupt-subjob) + +;(defun sdcdb-control-c-subjob () +; "Send a Control-C to the subprocess." +; (interactive) +; (process-send-string (get-buffer-process (current-buffer)) +; "\C-c")) + +(defun sdcdb-toolbar-break () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-break nil))) + +(defun sdcdb-toolbar-clear () + (interactive) + (save-excursion + (message (car sdcdb-last-frame)) + (set-buffer (find-file-noselect (car sdcdb-last-frame))) + (sdcdb-clear))) + +(provide 'sdcdb) + +(require 'sdcdb "sdcdb") ; NOT gud! (yet...) + +(defvar sdcdbsrc-active-p t + "*Set to nil if you do not want source files put in sdcdbsrc-mode") + +(defvar sdcdbsrc-call-p nil + "True if sdcdb command issued from a source buffer") + +(defvar sdcdbsrc-associated-buffer nil + "Buffer name of attached sdcdb process") + +(defvar sdcdbsrc-mode nil + "Indicates whether buffer is in sdcdbsrc-mode or not") +(make-variable-buffer-local 'sdcdbsrc-mode) + +(defvar sdcdbsrc-global-mode nil + "Indicates whether global sdcdbsrc bindings are in effect or not") + +(defvar sdcdb-prompt-pattern "^[^)#$%>\n]*[)#$%>] *" + "A regexp for matching the end of the sdcdb prompt") + +(defvar eos::toolbar-toggle-srcmode + + (toolbar-make-button-list + (expand-file-name "recycle.xbm" eos::toolbar-icon-directory)) + "A Run icon pair.") +;;; bindings + +(defvar sdcdbsrc-global-map + (let ((map (make-sparse-keymap))) + (set-keymap-name map 'sdcdbsrc-global-map) + (define-key map "\C-x " 'sdcdb-break) + (define-key map "\M-\C-t" 'sdcdbsrc-mode) + (define-key map "\M-\C-g" 'sdcdbsrc-goto-sdcdb) + (define-key map "\M-m" 'sdcdbsrc-srcmode) + ;; middle button to select and print expressions... + (define-key map '(meta button2) 'sdcdbsrc-print-csexp) + (define-key map '(meta shift button2) 'sdcdbsrc-*print-csexp) + ;; left button to position breakpoints + (define-key map '(meta button1) 'sdcdbsrc-set-break) + (define-key map '(meta shift button1) 'sdcdbsrc-set-tbreak-continue) + map) + "Global minor keymap that is active whenever sdcdbsrc is running.") + +(add-minor-mode 'sdcdbsrc-global-mode " SdcdbGlobal" sdcdbsrc-global-map) + +(defvar sdcdbsrc-mode-map + (let ((map (make-sparse-keymap))) + (suppress-keymap map) + (set-keymap-name map 'sdcdbsrc-mode-map) + ;; inherit keys from global sdcdbsrc map just in case that somehow gets turned off. + (set-keymap-parents map (list sdcdbsrc-global-map)) + (define-key map "\C-x\C-q" 'sdcdbsrc-mode) ; toggle read-only + (define-key map "\C-c\C-c" 'sdcdbsrc-mode) + (define-key map "b" 'sdcdb-break) + (define-key map "g" 'sdcdbsrc-goto-sdcdb) + (define-key map "!" 'sdcdbsrc-goto-sdcdb) + (define-key map "p" 'sdcdb-print-c-sexp) + (define-key map "*" 'sdcdb-*print-c-sexp) + (define-key map "?" 'sdcdb-whatis-c-sexp) + (define-key map "R" 'sdcdbsrc-reset) + map) + "Minor keymap for buffers in sdcdbsrc-mode") + +(add-minor-mode 'sdcdbsrc-mode " SdcdbSrc" sdcdbsrc-mode-map) + +(defvar sdcdbsrc-toolbar + '([eos::toolbar-stop-at-icon + sdcdb-break + t + "Stop at selected position"] + [eos::toolbar-stop-in-icon + sdcdb-break + t + "Stop in function whose name is selected"] + [eos::toolbar-clear-at-icon + sdcdb-clear + t + "Clear at selected position"] + [eos::toolbar-evaluate-icon + sdcdb-print-c-sexp + t + "Evaluate selected expression; shows in separate XEmacs frame"] + [eos::toolbar-run-icon + sdcdbsrc-run + t + "Run current program"] + [eos::toolbar-cont-icon + sdcdbsrc-cont + t + "Continue current program"] + [eos::toolbar-step-into-icon + sdcdbsrc-step + t + "Step into (aka step)"] + [eos::toolbar-step-over-icon + sdcdbsrc-next + t + "Step over (aka next)"] + [eos::toolbar-fix-icon + nil + nil + "Fix (not available with sdcdb)"] + [eos::toolbar-build-icon + toolbar-compile + t + "Build (aka make -NYI)"] + [eos::toolbar-toggle-srcmode + sdcdbsrc-srcmode + t + "Toggle Source C <-> Asm"] + )) + +(defmacro def-sdcdb-from-src (sdcdb-command key &optional doc &rest forms) + "Create a function that will call SDCDB-COMMAND with KEY." + (let* ((fname (format "sdcdbsrc-%s" sdcdb-command)) + (cstr (list 'if 'arg + (list 'format "%s %s" sdcdb-command '(prefix-numeric-value arg)) + sdcdb-command)) + fun) + (while (string-match " " fname) + (aset fname (match-beginning 0) ?-)) + (setq fun (intern fname)) + + (list 'progn + (nconc (list 'defun fun '(arg) + (or doc "") + '(interactive "P") + (list 'sdcdb-call-from-src cstr)) + forms) + (list 'define-key 'sdcdbsrc-mode-map key (list 'quote fun))))) + +(def-sdcdb-from-src "step" "s" "Step one instruction in src" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "stepi" "i" "Step one source line (skip functions)" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "cont" "c" "Continue with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "down" "d" "Go down N stack frames (numeric arg) ") +(def-sdcdb-from-src "up" "u" "Go up N stack frames (numeric arg)") +(def-sdcdb-from-src "finish" "f" "Finish frame") +(def-sdcdb-from-src "where" "w" "Display (N frames of) backtrace") +(def-sdcdb-from-src "next" "n" "Step one line with display" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "run" "r" "Run program from start" + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "return" "R" "Return from selected stack frame") +(def-sdcdb-from-src "disable" "x" "Disable all breakpoints") +(def-sdcdb-from-src "delete" "X" "Delete all breakpoints") +(def-sdcdb-from-src "quit" "Q" "Quit sdcdb." + (sdcdb-delete-arrow-extent)) +(def-sdcdb-from-src "info locals" "l" "Show local variables") +(def-sdcdb-from-src "info break" "B" "Show breakpoints") +(def-sdcdb-from-src "" "\r" "Repeat last command") +(def-sdcdb-from-src "frame" "m" "Show frame if no arg, with arg go to frame") + +;;; code + +;;;###autoload +(defun sdcdbsrc (path &optional core-or-pid) + "Activates a sdcdb session with sdcdbsrc-mode turned on. A numeric prefix +argument can be used to specify a running process to attach, and a non-numeric +prefix argument will cause you to be prompted for a core file to debug." + (interactive (let ((file (read-file-name "Program to debug: " nil nil t))) + (cond ((numberp current-prefix-arg) + (list file (int-to-string current-prefix-arg))) + (current-prefix-arg + (list file (read-file-name "Core file: " nil nil t))) + (t (list file))) + )) + ;; FIXME - this is perhaps an uncool thing to do --Stig + (delete-other-windows) + (split-window-vertically) + (other-window 0) + + (sdcdb path core-or-pid) + (local-set-key 'button2 'sdcdbsrc-select-or-yank) + (setq mode-motion-hook 'sdcdbsrc-mode-motion) + ;; XEmacs change: + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdbsrc-reset nil t)) + +(defun sdcdbsrc-global-mode () + ;; this can be used as a hook for sdcdb-mode.... + (or current-sdcdb-buffer + (and (eq major-mode 'sdcdb-mode) ; doesn't work w/ energize yet + (setq current-sdcdb-buffer (current-buffer)) + ;; XEmacs change: + (progn + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'sdcdbsrc-reset nil t))) + (error "Cannot determine current-sdcdb-buffer")) +;;; (set-process-filter +;;; (get-buffer-process current-sdcdb-buffer) 'sdcdbsrc-mode-filter) +;;; (set-process-sentinel +;;; (get-buffer-process current-sdcdb-buffer) 'sdcdbsrc-mode-sentinel) + ;; sdcdbsrc-global-mode was set to t here but that tended to piss + ;; people off + (setq sdcdbsrc-global-mode nil + sdcdbsrc-active-p t + sdcdbsrc-call-p nil + sdcdbsrc-mode nil) + (message "Gbd source mode active")) + +(add-hook 'sdcdb-mode-hook 'sdcdbsrc-global-mode) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Sdcdb Source minor mode. +;;; + +(defvar sdcdbsrc-associated-buffer nil + "The sdcdb buffer to send commands to.") +(defvar sdcdbsrc-initial-readonly 'undefined + "read-only status of buffer when not in sdcdbsrc-mode") +(defvar sdcdbsrc-old-toolbar nil + "saved toolbar for buffer") + +(defun sdcdbsrc-mode (arg &optional quiet) + "Minor mode for interacting with sdcdb from a c source file. +With arg, turn sdcdbsrc-mode on iff arg is positive. In sdcdbsrc-mode, +you may send an associated sdcdb buffer commands from the current buffer +containing c source code." + (interactive "P") + (setq sdcdbsrc-mode + (if (null arg) + (not sdcdbsrc-mode) + (> (prefix-numeric-value arg) 0))) + + (cond (sdcdbsrc-mode + (cond ((not (local-variable-p 'sdcdbsrc-initial-readonly (current-buffer))) + (set (make-local-variable 'sdcdbsrc-initial-readonly) + buffer-read-only) + (set (make-local-variable 'sdcdbsrc-associated-buffer) + current-sdcdb-buffer) + (if (featurep 'toolbar) + (set (make-local-variable 'sdcdbsrc-old-toolbar) + (specifier-specs default-toolbar (current-buffer)))) + ) + ) + (if (featurep 'toolbar) + (set-specifier default-toolbar (cons (current-buffer) + sdcdbsrc-toolbar))) + (setq buffer-read-only t) + (or quiet (message "Entering sdcdbsrc-mode..."))) + (t + (and (local-variable-p 'sdcdbsrc-initial-readonly (current-buffer)) + (progn + (if (featurep 'toolbar) + (if sdcdbsrc-old-toolbar + (set-specifier default-toolbar + (cons (current-buffer) + sdcdbsrc-old-toolbar)) + (remove-specifier default-toolbar (current-buffer)))) + (kill-local-variable 'sdcdbsrc-old-toolbar) + (setq buffer-read-only sdcdbsrc-initial-readonly) + (kill-local-variable 'sdcdbsrc-initial-readonly) + (kill-local-variable 'sdcdbsrc-associated-buffer) + )) + (or quiet (message "Exiting sdcdbsrc-mode...")))) + (redraw-modeline t)) + +;; +;; Sends commands to sdcdb process. + +(defun sdcdb-call-from-src (command) + "Send associated sdcdb process COMMAND displaying source in this window." + (setq sdcdbsrc-call-p t) + (let ((src-win (selected-window)) + (buf (or sdcdbsrc-associated-buffer current-sdcdb-buffer))) + (or (buffer-name buf) + (error "SDCDB buffer deleted")) + (pop-to-buffer buf) + (goto-char (point-max)) + (beginning-of-line) + ;; Go past sdcdb prompt + (re-search-forward + sdcdb-prompt-pattern (save-excursion (end-of-line) (point)) t) + ;; Delete any not-supposed-to-be-there text + (delete-region (point) (point-max)) + (insert command) + (comint-send-input) + (select-window src-win) + )) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; +;;; Define Commands for SDCDB SRC Mode Buffer +;;; + +;;; ;; #### - move elsewhere +(or (fboundp 'event-buffer) + (defun event-buffer (event) + "Return buffer assocaited with EVENT, or nil." + (let ((win (event-window event))) + (and win (window-buffer win))))) + +(defun set-sdcdbsrc-mode-motion-extent (st en action) + ;; by Stig@hackvan.com + (let ((ex (make-extent st en))) + (set-extent-face ex 'highlight) + (set-extent-property ex 'sdcdbsrc t) + (set-extent-property ex 'action action) + (setq mode-motion-extent ex))) + +(defun nuke-mode-motion-extent () + ;; by Stig@hackvan.com + (cond (mode-motion-extent + (delete-extent mode-motion-extent) + (setq mode-motion-extent nil)))) + +(defun looking-at-any (regex-list) + ;; by Stig@hackvan.com + (catch 'found + (while regex-list + (and (looking-at (car regex-list)) + (throw 'found t)) + (setq regex-list (cdr regex-list))))) + +(defconst sdcdb-breakpoint-patterns + '( + ;; when execution stops... + ;;Breakpoint 1, XlwMenuRedisplay (w=0x4d2e00, ev=0xefffe3f8, region=0x580e60) + ;; at /net/stig/src/xemacs/lwlib/xlwmenu.c:2518 + "^[BW][ra][et][ac][kh]point [0-9]+, .*\\(\n\\s .*\\)*" + ;; output of the breakpoint command: + ;;Breakpoint 1 at 0x19f5c8: file /net/stig/src/xemacs/lwlib/xlwmenu.c, line 2715. + "^[BW][ra][et][ac][kh]point [0-9]+ at .*: file \\([^ ,\n]+\\), line \\([0-9]+\\)." + ;;Num Type Disp Enb Address What + ;;1 breakpoint keep y 0x0019ee60 in XlwMenuRedisplay + ;; at /net/stig/src/xemacs/lwlib/xlwmenu.c:2518 + "^[0-9]+\\s +[bw][ra][et][ac][kh]point.* in .*\\(\n\\s +\\)?at [^ :\n]+:[0-9]+\\(\n\\s .*\\)*" + ) + "list of patterns to match sdcdb's various ways of displaying a breakpoint") + +(defun sdcdbsrc-make-breakpoint-action (string) + ;; by Stig@hackvan.com + (if (or (string-match "file \\([^ ,\n]+\\), line \\([0-9]+\\)" string) + (string-match "at \\([^ :\n]+\\):\\([0-9]+\\)" string)) + (list 'sdcdbsrc-display + (match-string 1 string) + (string-to-int (match-string 2 string))))) + +(defconst sdcdb-stack-frame-pattern + ;;#9 0x62f08 in emacs_Xt_next_event (emacs_event=0x4cf804) + ;; at /net/stig/src/xemacs/src/event-Xt.c:1778 + "^#\\([0-9]+\\)\\s +\\(0x[0-9a-f]+ in .*\\|.*\\sw+.* (.*) at .*\\)\\(\n\\s .*\\)*" + "matches the first line of a sdcdb stack frame and all continuation lines. +subex 1 is frame number.") + +(defun sdcdbsrc-mode-motion (ee) + ;; by Stig@hackvan.com + (save-excursion + (set-buffer (event-buffer ee)) + (save-excursion + (if (not (event-point ee)) + (nuke-mode-motion-extent) + (goto-char (event-point ee)) + (beginning-of-line) + (while (and (not (bobp)) (eq ? (char-syntax (following-char)))) + (forward-line -1)) + (if (extent-at (point) (current-buffer) 'sdcdbsrc) + nil + (nuke-mode-motion-extent) + (cond ((looking-at-any sdcdb-breakpoint-patterns) + (set-sdcdbsrc-mode-motion-extent + (match-beginning 0) + (match-end 0) + (sdcdbsrc-make-breakpoint-action (match-string 0)))) + ((looking-at sdcdb-stack-frame-pattern) + (set-sdcdbsrc-mode-motion-extent + (match-beginning 0) + (match-end 0) + (list 'sdcdbsrc-frame + (string-to-int (match-string 1))))) + ))) + ))) + +(defun sdcdbsrc-display (file line) + ;; by Stig@hackvan.com + (select-window (display-buffer (find-file-noselect file))) + (goto-line line)) + +(defun click-inside-selection-p (click) + (or (click-inside-extent-p click primary-selection-extent) + (click-inside-extent-p click zmacs-region-extent) + )) + +(defun click-inside-extent-p (click extent) + "Returns non-nil if the button event is within the bounds of the primary +selection-extent, nil otherwise." + ;; stig@hackvan.com + (let ((ewin (event-window click)) + (epnt (event-point click))) + (and ewin + epnt + extent + (eq (window-buffer ewin) + (extent-object extent)) + (extent-start-position extent) + (> epnt (extent-start-position extent)) + (> (extent-end-position extent) epnt)))) + +(defun point-inside-extent-p (extent) + "Returns non-nil if the point is within or just after the bounds of the +primary selection-extent, nil otherwise." + ;; stig@hackvan.com + (and extent ; FIXME - I'm such a sinner... + (eq (current-buffer) + (extent-object extent)) + (> (point) (extent-start-position extent)) + (>= (extent-end-position extent) (point)))) + +(defun sdcdbsrc-select-or-yank (ee) + ;; by Stig@hackvan.com + (interactive "e") + (let ((action (save-excursion + (set-buffer (event-buffer ee)) + (and mode-motion-extent + (click-inside-extent-p ee mode-motion-extent) + (extent-property mode-motion-extent 'action))) + )) + (if action + (eval action) + (mouse-yank ee)))) + +(defvar sdcdb-print-format "" + "Set this variable to a valid format string to print c-sexps in a +different way (hex,octal, etc).") + +(defun sdcdb-print-c-sexp () + "Find the nearest c-mode sexp. Send it to sdcdb with print command." + (interactive) + (let* ((tag (find-c-sexp)) + (command (concat "print " sdcdb-print-format tag))) + (sdcdb-call-from-src command))) + +(defun sdcdbsrc-srcmode () + "Toggle between assembler & C source modes." + (sdcdb-call-from-src "set srcmode")) + +(defun sdcdb-*print-c-sexp () + "Find the nearest c-mode sexp. Send it to sdcdb with the print * command." + (interactive) + (let* ((tag (find-c-sexp)) + (command (concat "print " sdcdb-print-format "*" tag))) + (sdcdb-call-from-src command))) + +(defun sdcdb-whatis-c-sexp () + "Find the nearest c-mode sexp. Send it to sdcdb with the whatis command. " + (interactive) + (let* ((tag (sdcdbsrc-selection-or-sexp)) + (command (concat "ptype " tag))) + (sdcdb-call-from-src command))) + +(defun sdcdbsrc-goto-sdcdb () + "Hop back and forth between the sdcdb interaction buffer and the sdcdb source +buffer. " + ;; by Stig@hackvan.com + (interactive) + (let ((gbuf (or sdcdbsrc-associated-buffer current-sdcdb-buffer))) + (cond ((eq (current-buffer) gbuf) + (and sdcdb-arrow-extent + (extent-object sdcdb-arrow-extent) + (progn (pop-to-buffer (extent-object sdcdb-arrow-extent)) + (goto-char (extent-start-position sdcdb-arrow-extent))))) + ((buffer-name gbuf) (pop-to-buffer gbuf)) + ((y-or-n-p "No debugger. Start a new one? ") + (call-interactively 'sdcdbsrc)) + (t (error "No sdcdb buffer.")) + ))) + +(defvar sdcdbsrc-last-src-buffer nil) + +(defun sdcdbsrc-goto-src () + (interactive) + (let* ((valid (and sdcdbsrc-last-src-buffer + (memq sdcdbsrc-last-src-buffer (buffer-list)))) + (win (and valid + (get-buffer-window sdcdbsrc-last-src-buffer)))) + (cond (win (select-window win)) + (valid (pop-to-buffer sdcdbsrc-last-src-buffer))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; +;;; The following functions are used to extract the closest surrounding +;;; c expression from point +;;; +(defun back-sexp () + "Version of backward-sexp that catches errors" + (condition-case nil + (backward-sexp) + (error t))) + +(defun forw-sexp () + "Version of forward-sexp that catches errors" + (condition-case nil + (forward-sexp) + (error t))) + +(defun sexp-compound-sep (span-start span-end) + "Returns '.' for '->' & '.', returns ' ' for white space, +returns '?' for other puctuation" + (let ((result ? ) + (syntax)) + (while (< span-start span-end) + (setq syntax (char-syntax (char-after span-start))) + (cond + ((= syntax ? ) t) + ((= syntax ?.) (setq syntax (char-after span-start)) + (cond + ((= syntax ?.) (setq result ?.)) + ((and (= syntax ?-) (= (char-after (+ span-start 1)) ?>)) + (setq result ?.) + (setq span-start (+ span-start 1))) + (t (setq span-start span-end) + (setq result ??))))) + (setq span-start (+ span-start 1))) + result + ) + ) + +(defun sexp-compound (first second) + "Returns non-nil if the concatenation of two S-EXPs result in a Single C +token. The two S-EXPs are represented as a cons cells, where the car +specifies the point in the current buffer that marks the begging of the +S-EXP and the cdr specifies the character after the end of the S-EXP +Link S-Exps of the form: + Sexp -> SexpC + Sexp . Sexp + Sexp (Sexp) Maybe exclude if first Sexp is: if, while, do, for, switch + Sexp [Sexp] + (Sexp) Sexp + [Sexp] Sexp" + (let ((span-start (cdr first)) + (span-end (car second)) + (syntax)) + (setq syntax (sexp-compound-sep span-start span-end)) + (cond + ((= (car first) (car second)) nil) + ((= (cdr first) (cdr second)) nil) + ((= syntax ?.) t) + ((= syntax ? ) + (setq span-start (char-after (- span-start 1))) + (setq span-end (char-after span-end)) + (cond + ((= span-start ?) ) t ) + ((= span-start ?] ) t ) + ((= span-end ?( ) t ) + ((= span-end ?[ ) t ) + (t nil)) + ) + (t nil)) + ) + ) + +(defun sexp-cur () + "Returns the S-EXP that Point is a member, Point is set to begging of S-EXP. +The S-EXPs is represented as a cons cell, where the car specifies the point in +the current buffer that marks the begging of the S-EXP and the cdr specifies +the character after the end of the S-EXP" + (let ((p (point)) (begin) (end)) + (back-sexp) + (setq begin (point)) + (forw-sexp) + (setq end (point)) + (if (>= p end) + (progn + (setq begin p) + (goto-char p) + (forw-sexp) + (setq end (point)) + ) + ) + (goto-char begin) + (cons begin end) + ) + ) + +(defun sexp-prev () + "Returns the previous S-EXP, Point is set to begging of that S-EXP. +The S-EXPs is represented as a cons cell, where the car specifies the point in +the current buffer that marks the begging of the S-EXP and the cdr specifies +the character after the end of the S-EXP" + (let ((begin) (end)) + (back-sexp) + (setq begin (point)) + (forw-sexp) + (setq end (point)) + (goto-char begin) + (cons begin end)) +) + +(defun sexp-next () + "Returns the following S-EXP, Point is set to begging of that S-EXP. +The S-EXPs is represented as a cons cell, where the car specifies the point in +the current buffer that marks the begging of the S-EXP and the cdr specifies +the character after the end of the S-EXP" + (let ((begin) (end)) + (forw-sexp) + (forw-sexp) + (setq end (point)) + (back-sexp) + (setq begin (point)) + (cons begin end) + ) + ) + +(defun find-c-sexp () + "Returns the Complex S-EXP that surrounds Point" + (interactive) + (save-excursion + (let ((p) (sexp) (test-sexp)) + (setq p (point)) + (setq sexp (sexp-cur)) + (setq test-sexp (sexp-prev)) + (while (sexp-compound test-sexp sexp) + (setq sexp (cons (car test-sexp) (cdr sexp))) + (goto-char (car sexp)) + (setq test-sexp (sexp-prev)) + ) + (goto-char p) + (setq test-sexp (sexp-next)) + (while (sexp-compound sexp test-sexp) + (setq sexp (cons (car sexp) (cdr test-sexp))) + (setq test-sexp (sexp-next)) + ) + (buffer-substring (car sexp) (cdr sexp)) + ) + ) + ) + +(defun sdcdbsrc-selection-or-sexp (&optional ee) + ;; FIXME - fix this docstring + "If the EVENT is within the primary selection, then return the selected +text, otherwise parse the expression at the point of the mouse click and +return that. If EVENT is nil, then return the C sexp at point." + ;; stig@hackvan.com + (cond ((or (and ee (click-inside-selection-p ee)) + (and (not ee) (point-inside-selection-p))) + (replace-in-string (extent-string primary-selection-extent) "\n\\s *" " ")) + (ee + (sdcdbsrc-get-csexp-at-click ee)) + (t + (find-c-sexp)) + )) + +(defun sdcdbsrc-get-csexp-at-click (ee) + "Returns the containing s-expression located at the mouse cursor to point." + ;; " + ;; by Stig@hackvan.com + (let ((ewin (event-window ee)) + (epnt (event-point ee))) + (or (and ewin epnt) + (error "Must click within a window")) + (save-excursion + (set-buffer (window-buffer ewin)) + (save-excursion + (goto-char epnt) + (find-c-sexp))))) + +(defun sdcdbsrc-print-csexp (&optional ee) + (interactive) + (or ee (setq ee current-mouse-event)) + (sdcdb-call-from-src + (concat "print " sdcdb-print-format (sdcdbsrc-selection-or-sexp ee)))) + +(defun sdcdbsrc-*print-csexp (&optional ee) + (interactive) + (or ee (setq ee current-mouse-event)) + (sdcdb-call-from-src + (concat "print *" sdcdb-print-format (sdcdbsrc-selection-or-sexp ee)))) + +;; (defun sdcdbsrc-print-region (arg) +;; (let (( command (concat "print " sdcdb-print-format (x-get-cut-buffer)))) +;; (sdcdb-call-from-src command))) +;; +;; (defun sdcdbsrc-*print-region (arg) +;; (let (( command (concat "print *" sdcdb-print-format (x-get-cut-buffer)))) +;; (sdcdb-call-from-src command))) + +(defun sdcdbsrc-file:lno () + "returns \"file:lno\" specification for location of point. " + ;; by Stig@hackvan.com + (format "%s:%d" + (file-name-nondirectory buffer-file-name) + (save-restriction + (widen) + (1+ (count-lines (point-min) + (save-excursion (beginning-of-line) (point))))) + )) + +(defun sdcdbsrc-set-break (ee) + "Sets a breakpoint. Click on the selection and it will set a breakpoint +using the selected text. Click anywhere in a source file, and it will set +a breakpoint at that line number of that file." + ;; by Stig@hackvan.com + ;; there is already sdcdb-break, so this only needs to work with mouse clicks. + (interactive "e") + (sdcdb-call-from-src + (concat "break " + (if (click-inside-selection-p ee) + (extent-string primary-selection-extent) + (mouse-set-point ee) + (or buffer-file-name (error "No file in window")) + (- (sdcdbsrc-file:lno) 1) + )))) + +(defun sdcdbsrc-set-tbreak-continue (&optional ee) + "Set a temporary breakpoint at the position of the mouse click and then +continues. This can be bound to either a key or a mouse button." + ;; by Stig@hackvan.com + (interactive) + (or ee (setq ee current-mouse-event)) + (and ee (mouse-set-point ee)) + (sdcdb-call-from-src (concat "tbreak " (sdcdbsrc-file:lno))) + (sdcdb-call-from-src "c")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Functions extended from sdcdb.el for sdcdbsrc. +;; +;; sdcdbsrc-set-buffer - added a check to set buffer to sdcdbsrc-associated-buffer +;; to handle multiple sdcdb sessions being driven from src +;; files. + +(require 'advice) + +(defadvice sdcdb-set-buffer (after sdcdbsrc activate) ; () + "Advised to work from a source buffer instead of just the sdcdb buffer." + ;; by Stig@hackvan.com + ;; the operations below have tests which are disjoint from the tests in + ;; the original `sdcdb-set-buffer'. Current-sdcdb-buffer cannot be set twice. + (and sdcdbsrc-call-p + sdcdbsrc-associated-buffer + (setq current-sdcdb-buffer sdcdbsrc-associated-buffer))) + +(defadvice sdcdb-display-line (around sdcdbsrc activate) + ;; (true-file line &optional select-method) + "Advised to select the source buffer instead of the sdcdb-buffer" + ;; by Stig@hackvan.com + (ad-set-arg 2 'source) ; tell it not to select the sdcdb window + ad-do-it + (save-excursion + (let* ((buf (extent-object sdcdb-arrow-extent)) + (win (get-buffer-window buf))) + (setq sdcdbsrc-last-src-buffer buf) + (select-window win) + (set-window-point win (extent-start-position sdcdb-arrow-extent)) + (set-buffer buf)) + (and sdcdbsrc-active-p + (not sdcdbsrc-mode) + (not (eq (current-buffer) current-sdcdb-buffer)) + (sdcdbsrc-mode 1)))) + +(defadvice sdcdb-filter (after sdcdbsrc activate) ; (proc string) + ;; by Stig@hackvan.com + ;; if we got a sdcdb prompt and it wasn't a sdcdbsrc command, then it's sdcdb + ;; hitting a breakpoint or having a core dump, so bounce back to the sdcdb + ;; window. + (let* ((selbuf (window-buffer (selected-window))) + win) + ;; if we're at a sdcdb prompt, then display the buffer + (and (save-match-data (string-match sdcdb-prompt-pattern (ad-get-arg 1))) + (prog1 + (not sdcdbsrc-call-p) + (setq sdcdbsrc-call-p nil)) + (setq win (display-buffer current-sdcdb-buffer)) + ;; if we're not in either the source buffer or the sdcdb buffer, + ;; then select the window too... + (not (eq selbuf current-sdcdb-buffer)) + (not (eq selbuf sdcdbsrc-last-src-buffer)) + (progn + (ding nil 'warp) + (select-window win))) + )) + +(defun sdcdbsrc-reset () + ;; tidy house and turn off sdcdbsrc-mode in all buffers + ;; by Stig@hackvan.com + (sdcdb-delete-arrow-extent) + (setq sdcdbsrc-global-mode nil) + (mapcar #'(lambda (buffer) + (set-buffer buffer) + (cond ((eq sdcdbsrc-associated-buffer current-sdcdb-buffer) + (sdcdbsrc-mode -1)))) + (buffer-list))) + +(defadvice sdcdb-sentinel (after sdcdbsrc freeze) ; (proc msg) + ;; by Stig@hackvan.com + (sdcdbsrc-reset) + (message "Sdcdbsrc finished")) + +(provide 'sdcdbsrc) diff --git a/debugger/mcs51/simi.c b/debugger/mcs51/simi.c new file mode 100644 index 00000000..16e25b7e --- /dev/null +++ b/debugger/mcs51/simi.c @@ -0,0 +1,456 @@ +/*------------------------------------------------------------------------- + simi.c - source file for simulator interaction + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "sdcdb.h" +#include "simi.h" + +#ifdef HAVE_SYS_SOCKET_H +#include +#include +#include +#include +#include +#include +#else +#error "Cannot build debugger without socket support" +#endif +FILE *simin ; /* stream for simulator input */ +FILE *simout; /* stream for simulator output */ + +int sock ; /* socket descriptor to comm with simulator */ +pid_t simPid; +static char simibuff[MAX_SIM_BUFF]; /* sim buffer */ +static char regBuff[MAX_SIM_BUFF]; +static char *sbp = simibuff; /* simulator buffer pointer */ +extern char **environ; +char simactive = 0; +/*-----------------------------------------------------------------*/ +/* readSim - reads one character into simulator buffer */ +/*-----------------------------------------------------------------*/ +void readSim(int resetp) +{ + int ch ; + /* if reset required then point to beginning of buffer */ + if (resetp) + sbp = simibuff; + +#ifdef SDCDB_DEBUG + fprintf(stderr,"stderr--> reading from sim\n"); +#endif + + while ((ch = fgetc(simin))) { +#ifdef SDCDB_DEBUG + fputc(ch,stdout); +#endif + *sbp++ = ch; + } +#ifdef SDCDB_DEBUG + fprintf(stderr,"stderr--> reading from sim done\n"); +#endif + + *sbp = '\0'; +} + +/*-----------------------------------------------------------------*/ +/* waitForSim - wait till simulator is done its job */ +/*-----------------------------------------------------------------*/ +void waitForSim() +{ + readSim(TRUE); +} + +/*-----------------------------------------------------------------*/ +/* openSimulator - create a pipe to talk to simulator */ +/*-----------------------------------------------------------------*/ +void openSimulator (char **args, int nargs) +{ + struct sockaddr_in sin; + int retry = 0; + int i ; + char *simargs[32] = { "s51","-P","-r 9756", NULL }; + + /* create the arguments */ + for ( i = 0 ; i < nargs ;i++) { + simargs[i+3] = args[i]; + } + simargs[i+3]= NULL; + + /* fork and start the simulator as a subprocess */ + if ((simPid = fork())) { +#ifdef SDCDB_DEBUG + printf("simulator pid %d\n",(int) simPid); +#endif + } + else { + + /* we are in the child process : start the simulator */ + if (execvp("s51",simargs) < 0) { + perror("cannot exec simulator"); + exit(1); + } + } + + try_connect: + sock = socket(AF_INET,SOCK_STREAM,0); + + memset(&sin,0,sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = inet_addr("127.0.0.1"); + sin.sin_port = htons(9756); + + sleep(1); + /* connect to the simulator */ + if (connect(sock,(struct sockaddr *) &sin, sizeof(sin)) < 0) { + /* if failed then wait 1 second & try again + do this for 10 secs only */ + if (retry < 10) { + retry ++; + sleep (1); + goto try_connect; + } + perror("connect failed :"); + exit(1); + } + /* go the socket now turn it into a file handle */ + if (!(simin = fdopen(sock,"r"))) { + fprintf(stderr,"cannot open socket for read\n"); + exit(1); + } + + if (!(simout = fdopen(sock,"w"))) { + fprintf(stderr,"cannot open socket for write\n"); + exit(1); + } + + /* now that we have opend wait for the prompt */ + waitForSim(); + simactive = 1; +} +/*-----------------------------------------------------------------*/ +/* simResponse - returns buffer to simulator's response */ +/*-----------------------------------------------------------------*/ +char *simResponse() +{ + return simibuff; +} + +/*-----------------------------------------------------------------*/ +/* sendSim - sends a command to the simuator */ +/*-----------------------------------------------------------------*/ +void sendSim(char *s) +{ + fputs(s,simout); + fflush(simout); +} + +/*-----------------------------------------------------------------*/ +/* simGetValue - get value @ address for mem space */ +/*-----------------------------------------------------------------*/ +unsigned long simGetValue (unsigned int addr,char mem, int size) +{ + unsigned int b[4] = {0,0,0,0}; /* can be a max of four bytes long */ + char i; + char *prefix; + char buffer[20]; + char *resp; + + switch (mem) { + case 'A': + prefix = "dx"; + break; + case 'B': + prefix = "di"; + break; + case 'C': + case 'D': + prefix = "dch"; + break; + case 'E': + case 'G': + prefix = "di"; + break; + case 'F': + prefix = "dx"; + break; + case 'H': + case 'J': + prefix = "db" ; + break; + case 'I': + prefix = "ds" ; + break; + } + + /* create the simulator command */ + sprintf(buffer,"%s 0x%x \n",prefix,addr); + sendSim(buffer); + waitForSim(); + resp = simResponse(); + + /* got the response we need to parse it the response + is of the form + [address] [v] [v] [v] ... special case in + case of bit variables which case it becomes + [address] [assembler bit address] [v] */ + /* first skip thru white space */ + while (isspace(*resp)) resp++ ; + + /* then make the branch for bit variables */ + /* skip thru the address part */ + while (isxdigit(*resp)) resp++; + + if (!strcmp(prefix,"db")) { + + /* skip white space */ + while (isspace(*resp)) resp++ ; + + /* skip thru the assembler bit address */ + while (!isspace(*resp)) resp++; + + /* white space */ + while (isspace(*resp)) resp++ ; + + /* scan in the value */ + sscanf(resp,"%d",&b[0]); + } else { + + for (i = 0 ; i < size ; i++ ) { + /* skip white space */ + while (isspace(*resp)) resp++ ; + + sscanf(resp,"%x",&b[i]); + + /* skip */ + while (isxdigit(*resp)) resp++; + } + } + + return b[0] | b[1] << 8 | b[2] << 16 | b[3] << 24 ; + +} + +/*-----------------------------------------------------------------*/ +/* simSetBP - set break point for a given address */ +/*-----------------------------------------------------------------*/ +void simSetBP (unsigned int addr) +{ + char buff[50]; + + sprintf(buff,"break 0x%x\n",addr); + sendSim(buff); + waitForSim(); +} + +/*-----------------------------------------------------------------*/ +/* simClearBP - clear a break point */ +/*-----------------------------------------------------------------*/ +void simClearBP (unsigned int addr) +{ + char buff[50]; + + sprintf(buff,"clear 0x%x\n",addr); + sendSim(buff); + waitForSim(); +} + +/*-----------------------------------------------------------------*/ +/* simLoadFile - load the simulator file */ +/*-----------------------------------------------------------------*/ +void simLoadFile (char *s) +{ + char buff[128]; + + sprintf(buff,"l %s\n",s); + printf(buff); + sendSim(buff); + waitForSim(); +} + +/*-----------------------------------------------------------------*/ +/* simGoTillBp - send 'go' to simulator till a bp then return addr */ +/*-----------------------------------------------------------------*/ +unsigned int simGoTillBp ( unsigned int gaddr) +{ + char *sr, *svr; + unsigned addr ; + char *sfmt; + + if (gaddr != -1) { + char buf[20]; + sprintf(buf,"g 0x%x\n",gaddr); + sendSim(buf); + } else + sendSim ("g\n"); + + waitForSim(); + + /* get the simulator response */ + svr = sr = strdup(simResponse()); + + /* figure out the address of the break point the simulators + response in a break point situation is of the form + [... F* ] + we will ignore till we get F* then parse the address */ + while (*sr) { + + if (strncmp(sr,"Stop at",7) == 0) { + sr += 7; + sfmt = "%x"; + break; + } + + if (*sr == 'F' && ( *(sr+1) == '*' || *(sr+1) == ' ')) { + sr += 2; + sfmt = "%x"; + break; + } + sr++; + } + + if (!*sr) return 0; + + while (isspace(*sr)) sr++ ; + + if (sscanf(sr,sfmt,&addr) != 1) + return 0; + else + return addr; + + +} + +/*-----------------------------------------------------------------*/ +/* simReset - reset the simulator */ +/*-----------------------------------------------------------------*/ +void simReset () +{ + sendSim("res\n"); + waitForSim(); +} + +/*-----------------------------------------------------------------*/ +/* getValueStr - read a value followed by a string = */ +/*-----------------------------------------------------------------*/ +static unsigned int getValueStr (char *src,char *cstr) +{ + int i = strlen(cstr); + int rv; + /* look for the string */ + if (! (src = strstr(src,cstr))) + return 0; + + src += i; + if (!*src) return 0; + + /* look for the digit */ + while (*src && !isxdigit(*src)) src++; + sscanf(src,"%x",&rv); + return rv; +} + +/*-----------------------------------------------------------------*/ +/* simRegs - returns value of registers */ +/*-----------------------------------------------------------------*/ +char *simRegs() +{ + char *resp ; + unsigned int rv; + char *rb = regBuff; + int i; + + sendSim("dr\n"); + waitForSim(); + /* make it some more readable */ + resp = simResponse(); + + /* the response is of the form + XXXXXX R0 R1 R2 R3 R4 R5 R6 R7 ........ + XXXXXX XX . ACC=0xxx dd cc B=0xxx dd cc DPTR= 0xxxxx @DPTR= 0xxx dd cc + XXXXXX XX . PSW= 0xxx CY=[1|0] AC=[0|1] OV=[0|1] P=[1|0] */ + memset(regBuff,0,sizeof(regBuff)); + /* skip the first numerics */ + while (*resp && !isxdigit(*resp)) resp++; + while (*resp && isxdigit(*resp)) resp++; + + /* now get the eight registers */ + for (i = 0 ; i < 7 ; i++) { + while (*resp && isspace(*resp)) resp++; + if (!*resp) + break; + rv = strtol(resp,&resp,16); + sprintf(rb,"R%d : 0x%02X %d %c\n",i,rv,rv,(isprint(rv) ? rv : '.')); + rb += strlen(rb); + } + + if (!*resp) return regBuff; + + /* skip till end of line */ + while (*resp && *resp != '\n') resp++; + while (*resp && !isxdigit(*resp)) resp++; + while (*resp && isxdigit(*resp)) resp++; + + /* accumulator value */ + rv = getValueStr(resp,"ACC"); + sprintf(rb,"ACC : 0x%02X %d %c\n",rv,rv,(isprint(rv) ? rv : '.')); + rb += strlen(rb); + + /* value of B */ + rv = getValueStr(resp,"B="); + sprintf(rb,"B : 0x%02X %d %c\n",rv,rv,(isprint(rv) ? rv : '.')); + rb += strlen(rb); + + rv = getValueStr(resp,"DPTR="); + sprintf(rb,"DPTR: 0x%04X %d\n",rv,rv); + rb += strlen(rb); + + rv = getValueStr(resp,"@DPTR="); + sprintf(rb,"@DPTR: 0x%02X %d %c\n", rv,rv,(isprint(rv) ? rv : '.')); + rb += strlen(rb); + + sprintf(rb,"PSW : 0x%02X | CY : %d | AC : %d | OV : %d | P : %d\n", + getValueStr(resp,"PSW="), + getValueStr(resp,"CY="), + getValueStr(resp,"AC="), + getValueStr(resp,"OV="), + getValueStr(resp,"P=")); + + return regBuff; + + + +} + +/*-----------------------------------------------------------------*/ +/* closeSimulator - close connection to simulator */ +/*-----------------------------------------------------------------*/ +void closeSimulator () +{ + + sendSim("q\n"); + kill (simPid,SIGKILL); + fclose (simin); + fclose (simout); + shutdown(sock,2); + close(sock); + +} diff --git a/debugger/mcs51/simi.h b/debugger/mcs51/simi.h new file mode 100644 index 00000000..9e1f8c34 --- /dev/null +++ b/debugger/mcs51/simi.h @@ -0,0 +1,44 @@ +/*------------------------------------------------------------------------- + simi.h - Header file for simulator interaction + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SIMI_H +#define SIMI_H + +#define MAX_SIM_BUFF 8*1024 +#define SIMNAME "s51" +extern char simactive; +void openSimulator (char **,int); +void waitForSim (); +void closeSimulator (); +void sendSim(char *); +char *simResponse(); +void simSetBP (unsigned int); +void simClearBP (unsigned int); +void simLoadFile(char *); +void simReset (); +char *simRegs() ; +unsigned int simGoTillBp (unsigned int); +unsigned long simGetValue (unsigned int ,char , int ); + +#endif diff --git a/debugger/mcs51/symtab.c b/debugger/mcs51/symtab.c new file mode 100644 index 00000000..3ea0e8fd --- /dev/null +++ b/debugger/mcs51/symtab.c @@ -0,0 +1,728 @@ +/*------------------------------------------------------------------------- + symtab.c - Header file for symbol table for sdcdb ( debugger ) + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "sdcdb.h" +#include "symtab.h" + +extern char *currModName ; +structdef *structWithName (char *); + +/*------------------------------------------------------------------*/ +/* getSize - returns size of a type chain in bits */ +/*------------------------------------------------------------------*/ +unsigned int getSize ( link *p ) +{ + /* if nothing return 0 */ + if ( ! p ) + return 0 ; + + if ( IS_SPEC(p) ) { /* if this is the specifier then */ + + switch (SPEC_NOUN(p)) { /* depending on the specifier type */ + case V_INT: + return (IS_LONG(p) ? LONGSIZE : ( IS_SHORT(p) ? SHORTSIZE: INTSIZE)) ; + case V_FLOAT: + return FLOATSIZE ; + case V_CHAR: + return CHARSIZE ; + case V_VOID: + return 0 ; + case V_STRUCT: + return SPEC_STRUCT(p)->size ; + case V_LABEL: + return 0 ; + case V_SBIT: + return BITSIZE ; + case V_BIT: + return ((SPEC_BLEN(p) / 8) + (SPEC_BLEN(p) % 8 ? 1 : 0)) ; + default : + return 0 ; + } + } + + /* this is a specifier */ + switch (DCL_TYPE(p)) { + case FUNCTION: + return 2; + case ARRAY: + return DCL_ELEM(p) * getSize (p->next) ; + case IPOINTER: + case PPOINTER: + case POINTER: + return ( PTRSIZE ) ; + case FPOINTER: + case CPOINTER: + return ( FPTRSIZE ); + case GPOINTER: + return ( GPTRSIZE ); + + default : + return 0 ; + } +} + + +/*-----------------------------------------------------------------*/ +/* parseFunc - creates a function record entry */ +/*-----------------------------------------------------------------*/ +void parseFunc (char *line) +{ + function *func ; + char *rs; + int i; + ALLOC(func,sizeof(function)); + func->sym = parseSymbol(line,&rs); + func->sym->isfunc = 1; + func->modName = currModName ; + while(*rs != ',') rs++; + rs++; + sscanf(rs,"%d,%d,%d",&i, + &(SPEC_INTN(func->sym->etype)), + &(SPEC_BANK(func->sym->etype))); + SPEC_INTRTN(func->sym->etype) = i; + addSet(&functions,func); +} + +/*-----------------------------------------------------------------*/ +/* parseTypeInfo - parse the type info of a symbol expects the type*/ +/* info to be of the form */ +/* ({}size = strtol (s,&bp,10); + /* bp now points to '}' ... go past it */ + s = ++bp; + while (*s != ')') { /* till we reach the end */ + link *type; + ALLOC(type,sizeof(link)); + if (*s == ',') s++; + + /* is a declarator */ + if (*s == 'D') { + s++; + switch (*s) { + case 'F': + DCL_TYPE(type) = FUNCTION; + s++; + break; + case 'G': + DCL_TYPE(type) = GPOINTER; + s++; + break; + case 'C': + DCL_TYPE(type) = CPOINTER; + s++; + break; + case 'X': + DCL_TYPE(type) = FPOINTER; + s++; + break; + case 'D': + DCL_TYPE(type) = POINTER; + s++; + break; + case 'I': + DCL_TYPE(type) = IPOINTER; + s++; + break; + case 'P': + DCL_TYPE(type) = PPOINTER; + s++; + break; + case 'A': + s++; + DCL_TYPE(type) = ARRAY ; + DCL_ELEM(type) = strtol(s,&s,10); + break; + } + } else { + /* is a specifier */ + type->class = SPECIFIER ; + s++; + switch (*s) { + case 'L': + SPEC_NOUN(type) = V_INT; + SPEC_LONG(type) = 1; + s++; + break; + case 'I': + SPEC_NOUN(type) = V_INT; + s++; + break; + case 'S': + case 'C': + SPEC_NOUN(type) = V_CHAR ; + s++; + break; + case 'V': + SPEC_NOUN(type) = V_VOID; + s++; + break; + case 'F': + SPEC_NOUN(type) = V_FLOAT; + s++; + break; + case 'T': + s++; + SPEC_NOUN(type) = V_STRUCT; + { + char *ss = strtok(strdup(s),",):"); + + SPEC_STRUCT(type) = structWithName(ss); + free(ss); + } + break; + case 'X': + s++; + SPEC_NOUN(type) = V_SBIT; + break; + case 'B': + SPEC_NOUN(type) = V_BIT; + s++; + SPEC_BSTR(type) = strtol(s,&s,10); + s++; + SPEC_BLEN(type) = strtol(s,&s,10); + break; + } + while (*s != ':') s++; + s++; + if (*s++ == 'S') + SPEC_USIGN(type) = 0; + else + SPEC_USIGN(type) = 1; + + } + + /* add the type to the symbol's type chain */ + if (sym->type) + sym->etype = sym->etype->next = type; + else + sym->type = sym->etype = type; + } + + return ++s; + +} + +/*-----------------------------------------------------------------*/ +/* symFromRec - parse a symbol record and extract and create a sym */ +/* expects the input string to be of the form */ +/* {G|F|L}'$''$' */ +/* '$' */ +/*-----------------------------------------------------------------*/ +symbol *parseSymbol (char *s, char **rs) +{ + symbol *nsym ; + char *bp = s; + + ALLOC(nsym,sizeof(symbol)); + + /* copy over the mangled name */ + while (*bp != '(') bp++; + bp -= 1; + nsym->rname = alloccpy(s,bp - s); + + /* if this is a Global Symbol */ + nsym->scopetype = *s; + s++ ; + if (nsym->scopetype != 'G') { + /* get the function name it is local to */ + bp = s; + while (*s != '$') s++; + nsym->sname = alloccpy(bp,s - bp); + } + + /* next get the name */ + bp = ++s; + while ( *s != '$' ) s++; + nsym->name = alloccpy(bp,s - bp); + + s++; + /* get the level number */ + nsym->level = strtol (s,&bp,10); + s = ++bp; + /* skip the '$' & get the block number */ + nsym->block = strtol (s,&bp,10); + + s = parseTypeInfo(nsym,bp); + + /* get the address space after going past the comma */ + s++; + nsym->addrspace =*s; + + s+= 2; + nsym->isonstack = strtol(s,&s,10); + /* get the stack offset */ + s++; + nsym->offset = strtol(s,&s,10); + *rs = s; + + addSet(&symbols,nsym); + + return nsym; +} + + +/*-----------------------------------------------------------------*/ +/* parseStruct - parses a structure record expected in format */ +/* {F}$[()()()...] */ +/*-----------------------------------------------------------------*/ +structdef *parseStruct (char *s) +{ + structdef *nsdef ; + char *bp; + char *name; + symbol *fields = NULL; + + while (*s != '$') s++; + + bp =++s; + while (*s != '[') s++ ; + name = alloccpy(bp,s - bp); + nsdef = structWithName(name); + nsdef->fields = NULL; + s++; + while (*s && *s != ']') { + int offset ; + symbol *sym ; + while (!isdigit(*s)) s++; + offset = strtol(s,&s,10); + while (*s != ':') s++; + s++; + sym = parseSymbol(s,&s); + sym->offset = offset ; + s += 3; + if (!fields) + fields = nsdef->fields = sym; + else + fields = fields->next = sym; + + } + + return nsdef; +} + +/*-----------------------------------------------------------------*/ +/* parseModule - creates a module with a given name */ +/*-----------------------------------------------------------------*/ +module *parseModule (char *s, bool createName ) +{ + module *nmod ; + char buffer[512]; + + ALLOC(nmod,sizeof(module)); + + addSet (&modules,nmod); + + + /* create copy file name */ + nmod->name = s; + + if (createName) { + sprintf(buffer,"%s.c",s); + + ALLOC(nmod->c_name,strlen(buffer)+1); + strcpy(nmod->c_name,buffer); + + sprintf(buffer,"%s.asm",s); + ALLOC(nmod->asm_name,strlen(buffer)+1); + strcpy(nmod->asm_name,buffer); + } + + return nmod; +} + +/*-----------------------------------------------------------------*/ +/* moduleWithName - finds and returns a module with a given name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(moduleWithName) +{ + module *mod = item; + V_ARG(char *,s); + V_ARG(module **,rmod); + + if (*rmod) + return 0; + + if (strcmp(mod->name,s) == 0) { + *rmod = mod ; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* moduleWithCName - finds and returns a module with a given c_name*/ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(moduleWithCName) +{ + module *mod = item; + V_ARG(char *,s); + V_ARG(module **,rmod); + + if (*rmod) + return 0; + if (strcmp(mod->c_name,s) == 0) { + *rmod = mod; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* moduleWithAsmName - finds & returns a module with given asm_name*/ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(moduleWithAsmName) +{ + module *mod = item; + V_ARG(char *,s); + V_ARG(module **,rmod); + + if (*rmod) + return 0; + if (strcmp(mod->asm_name,s) == 0) { + *rmod = mod; + return 1; + } + + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* structWithName - returns a structure with a given name */ +/*-----------------------------------------------------------------*/ +structdef *structWithName (char *s) +{ + int i; + structdef *nsdef ; + + /* go thru the struct table looking for a match */ + for ( i = 0 ; i < nStructs ; i++ ) { + + if (strcmp(currModName,structs[i]->sname) == 0 && + strcmp(s,structs[i]->tag) == 0) + return structs[i]; + } + + ALLOC(nsdef,sizeof(structdef)); + nsdef->tag = alloccpy(s,strlen(s)); + nsdef->sname = currModName ; + + nStructs++; + structs = (struct structdef **)resize((void **)structs,nStructs); + structs[nStructs-1] = nsdef; + return nsdef; +} + +/*-----------------------------------------------------------------*/ +/* symWithRName - look for symbol with mangled name = parm */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(symWithRName) +{ + symbol *sym = item; + V_ARG(char *,s); + V_ARG(symbol **,rsym); + + if (*rsym) + return 0; + + if (strcmp(sym->rname,s) == 0) { + *rsym = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* funcWithRName - look for function with name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(funcWithRName) +{ + function *func = item; + V_ARG(char *,s); + V_ARG(function **,rfunc); + + if (*rfunc) + return 0; + + if (strcmp(func->sym->rname,s) == 0) { + *rfunc = func; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* symLocal - local symbol respecting blocks & levels */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(symLocal) +{ + symbol *sym = item; + V_ARG(char *,name); + V_ARG(char *,sname); + V_ARG(int ,block); + V_ARG(int ,level); + V_ARG(symbol **,rsym); + + if (strcmp(name,sym->name) == 0 && /* name matches */ + sym->scopetype != 'G' && /* local scope */ + (sym->sname && strcmp(sym->sname,sname) == 0) && /* scope == specified scope */ + sym->block <= block && /* block & level kindo matches */ + sym->level <= level) { + + /* if a symbol was previously found then + sure that ones block & level are less + then this one */ + if (*rsym && (*rsym)->block >= block && + (*rsym)->level >= level) + return 0; + + *rsym = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* symGlobal - return global symbol of name */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(symGlobal) +{ + symbol *sym = item; + V_ARG(char *,name); + V_ARG(symbol **,rsym); + + if (*rsym) + return 0; + + /* simple :: global & name matches */ + if (sym->scopetype == 'G' && + strcmp(sym->name,name) == 0) { + *rsym = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* symLookup - determine symbol from name & context */ +/*-----------------------------------------------------------------*/ +symbol *symLookup (char *name, context *ctxt) +{ + symbol *sym = NULL ; + + /* first try & find a local variable for the + given name */ + if ( applyToSet(symbols,symLocal, + name, + ctxt->func->sym->name, + ctxt->block, + ctxt->level, + &sym)) + return sym; + + sym = NULL; + /* then try local to this module */ + if (applyToSet(symbols,symLocal, + name, + ctxt->func->mod->name, + 0,0,&sym)) + return sym; + sym = NULL; + /* no:: try global */ + if ( applyToSet(symbols,symGlobal,name,&sym)) + return sym; + + /* cannot find return null */ + return NULL; +} + +/*-----------------------------------------------------------------*/ +/* lnkFuncEnd - link record for end of function */ +/*-----------------------------------------------------------------*/ +static void lnkFuncEnd (char *s) +{ + char sname[128], *bp = sname; + function *func; + + /* copy till we get to a ':' */ + while ( *s != ':' ) + *bp++ = *s++; + bp -= 1; + *bp = '\0'; + + func = NULL; + if (!applyToSet(functions,funcWithRName,sname,&func)) + return ; + + s++; + sscanf(s,"%x",&func->sym->eaddr); +#ifdef SDCDB_DEBUG + printf("%s(eaddr%x)\n",func->sym->name,func->sym->eaddr); +#endif +} + +/*-----------------------------------------------------------------*/ +/* lnkSymRec - record for a symbol */ +/*-----------------------------------------------------------------*/ +static void lnkSymRec (char *s) +{ + char sname[128], *bp = sname; + symbol *sym; + + /* copy till we get to a ':' */ + while ( *s != ':') + *bp++ = *s++; + bp -= 1; + *bp = '\0'; + + + sym = NULL; + if (!applyToSet(symbols,symWithRName,sname,&sym)) + return ; + + s++; + sscanf(s,"%x",&sym->addr); +#ifdef SDCDB_DEBUG + printf("%s(%x)\n",sym->name,sym->addr); +#endif +} + +/*-----------------------------------------------------------------*/ +/* lnkAsmSrc - process linker record for asm sources */ +/*-----------------------------------------------------------------*/ +static void lnkAsmSrc (char *s) +{ + char mname[128], *bp = mname; + int line ; + unsigned addr; + module *mod = NULL; + + /* input will be of format + filename$:

*/ + while (*s != '$' && *s != '.') + *bp++ = *s++; + *bp = '\0'; + /* skip to line stuff */ + while (*s != '$') s++; + + if (!applyToSet(modules,moduleWithName,mname,&mod)) + return ; + + if (sscanf(s,"$%d:%x",&line,&addr) != 2) + return ; + + line--; + if (line < mod->nasmLines) { + mod->asmLines[line]->addr = addr; +#ifdef SDCDB_DEBUG + printf("%s(%d:%x) %s",mod->asm_name,line,addr,mod->asmLines[line]->src); +#endif + } +} + +/*-----------------------------------------------------------------*/ +/* lnkCSrc - process linker output for c source */ +/*-----------------------------------------------------------------*/ +static void lnkCSrc (char *s) +{ + char mname[128], *bp = mname; + int block,level,line; + unsigned int addr; + module *mod ; + + /* input will be of format + filename.ext$$$:
*/ + /* get the module name */ + while (*s != '$' ) + *bp++ = *s++; + *bp = '\0'; + /* skip the extension */ + while (*s != '$') s++; + + if (sscanf(s,"$%d$%d$%d:%x", + &line,&level,&block,&addr) != 4) + return ; + + mod = NULL; + if (!applyToSet(modules,moduleWithCName,mname,&mod)) { + mod = parseModule(mname,FALSE); + mod->c_name = alloccpy(mname,strlen(mname)); + mod->cfullname=searchDirsFname(mod->c_name); + mod->cLines = loadFile(mod->c_name,&mod->ncLines); + } + + line--; + if (line < mod->ncLines && line > 0) { + mod->cLines[line]->addr = addr; + mod->cLines[line]->block = block; + mod->cLines[line]->level = level; +#ifdef SDCDB_DEBUG + printf("%s(%d:%x) %s",mod->c_name, + line+1,addr,mod->cLines[line]->src); +#endif + } + return; + +} + +/*-----------------------------------------------------------------*/ +/* parseLnkRec - parses a linker generated record */ +/*-----------------------------------------------------------------*/ +void parseLnkRec (char *s) +{ + /* link records can be several types + dpeneding on the type do */ + + switch (*s) { + + /* c source line address */ + case 'C': + lnkCSrc(s+2); + break; + /* assembler source address */ + case 'A': + lnkAsmSrc(s+2); + break; + + case 'X': + lnkFuncEnd(s+1); + break; + + default : + lnkSymRec(s); + break; + } +} diff --git a/debugger/mcs51/symtab.h b/debugger/mcs51/symtab.h new file mode 100644 index 00000000..42047609 --- /dev/null +++ b/debugger/mcs51/symtab.h @@ -0,0 +1,248 @@ +/*------------------------------------------------------------------------- + symtab.h - Header file for symbol table for sdcdb ( debugger ) + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SYMTAB_H +#define SYMTAB_H + +#define MAX_NEST_LEVEL 256 +#define SDCC_NAME_MAX 64 + +typedef struct structdef { + char *tag ; /* tag part of structure */ + unsigned char level ; /* Nesting level */ + struct symbol *fields ; /* pointer to fields */ + unsigned size ; /* sizeof the table in bytes */ + char *sname ; /* scope name */ + char scopetype ; /* scope type 'G' or 'F' */ +} structdef ; + +/* noun definitions */ +enum { V_INT = 0, + V_FLOAT , + V_CHAR , + V_VOID , + V_STRUCT , + V_LABEL , + V_BIT , + V_SBIT }; + +/* storage class */ +enum { S_FIXED = 0, + S_AUTO , + S_REGISTER , + S_CONSTANT , + S_SFR , + S_SBIT , + S_CODE , + S_XDATA , + S_DATA , + S_IDATA , + S_PDATA , + S_LITERAL , + S_STACK , + S_XSTACK , + S_BIT }; + +/* specifier is the last in the type-chain */ +typedef struct specifier { + unsigned noun ; /* CHAR INT STRUCTURE LABEL */ + unsigned sclass ; /* REGISTER,AUTO,FIX,CONSTANT */ + unsigned _long : 1 ; /* 1=long */ + unsigned _short: 1 ; /* 1=short int */ + unsigned _unsigned: 1 ; /* 1=unsigned, 0=signed */ + unsigned _static: 1 ; /* 1=static keyword found */ + unsigned _extern: 1 ; /* 1=extern found */ + unsigned _absadr: 1 ; /* absolute address specfied */ + unsigned _reent : 1 ; /* function is reentrant */ + unsigned _intrtn: 1 ; /* this is an interrupt routin*/ + unsigned _rbank : 1 ; /* seperate register bank */ + unsigned _volatile : 1; /* is marked as volatile */ + unsigned _const:1 ; /* is a constant */ + unsigned _critical:1 ; /* critical function */ + unsigned _typedef :1 ; /* is typedefed */ + unsigned _IntNo ; /* 1=Interrupt svc routine */ + short _regbank ; /* register bank 2b used */ + unsigned _addr ; /* address of symbol */ + unsigned _stack ; /* stack offset for stacked v */ + unsigned _bitStart ; /* bit start position */ + int _bitLength ; /* bit length */ + + struct structdef *v_struct; /* structure pointer */ +} specifier ; + +/* types of declarators */ +enum { POINTER = 0, /* pointer to near data */ + FPOINTER , /* pointer to far data */ + CPOINTER , /* pointer to code space */ + GPOINTER , /* _generic pointer */ + PPOINTER , /* paged area pointer */ + IPOINTER , /* pointer to upper 128 bytes */ + UPOINTER , /* unknown pointer used only when parsing */ + ARRAY , + FUNCTION }; + +typedef struct declarator { + short dcl_type; /* POINTER,ARRAY or FUNCTION */ + short num_elem; /* # of elems if type==array */ + short ptr_const :1; /* pointer is constant */ + short ptr_volatile:1; /* pointer is volatile */ + struct link *tspec; /* pointer type specifier */ +} declarator ; + +#define DECLARATOR 0 +#define SPECIFIER 1 + +typedef struct link { + unsigned class : 1 ; /* DECLARATOR or SPECIFIER */ + unsigned tdef : 1 ; /* current link created by */ + /* typedef if this flag is set*/ + union { + specifier s ; /* if CLASS == SPECIFIER */ + declarator d ; /* if CLASS == DECLARATOR */ + } select ; + + struct link *next ; /* next element on the chain */ +} link ; + +typedef struct symbol { + char *name ; + + short size ; + short level ; /* declration lev,fld offset */ + short block ; /* sequential block # of defintion */ + short isonstack ; /* is the variable on stack */ + unsigned isfunc :1 ; /* is a functions */ + unsigned offset ; /* offset from top if struct */ + unsigned addr ; /* address if the symbol */ + unsigned eaddr ; /* end address for functions */ + char addr_type ; /* which address space */ + link *type ; /* start of type chain */ + link *etype ; /* end of type chain */ + char scopetype ; /* 'G' global, 'F' - file, 'L' local */ + char *sname ; /* if 'F' or 'L' then scope name */ + char *rname ; /* real name i.e. mangled beyond recognition */ + char addrspace ; /* address space designator */ + struct symbol *next ; +} symbol ; + +/* size's in bytes */ +#define CHARSIZE 1 +#define SHORTSIZE 1 +#define INTSIZE 2 +#define LONGSIZE 4 +#define PTRSIZE 1 +#define FPTRSIZE 2 +#define GPTRSIZE 3 +#define BITSIZE 1 +#define FLOATSIZE 4 +#define MAXBASESIZE 4 + +/* Easy Access Macros */ +#define DCL_TYPE(l) l->select.d.dcl_type +#define DCL_ELEM(l) l->select.d.num_elem +#define DCL_PTR_CONST(l) l->select.d.ptr_const +#define DCL_PTR_VOLATILE(l) l->select.d.ptr_volatile +#define DCL_TSPEC(l) l->select.d.tspec +#define SPEC_NOUN(x) x->select.s.noun +#define SPEC_LONG(x) x->select.s._long +#define SPEC_SHORT(x) x->select.s._short +#define SPEC_USIGN(x) x->select.s._unsigned +#define SPEC_SCLS(x) x->select.s.sclass +#define SPEC_OCLS(x) x->select.s.oclass +#define SPEC_STAT(x) x->select.s._static +#define SPEC_EXTR(x) x->select.s._extern +#define SPEC_CODE(x) x->select.s._codesg +#define SPEC_RENT(x) x->select.s._reent +#define SPEC_INTN(x) x->select.s._IntNo +#define SPEC_ABSA(x) x->select.s._absadr +#define SPEC_BANK(x) x->select.s._regbank +#define SPEC_ADDR(x) x->select.s._addr +#define SPEC_STAK(x) x->select.s._stack +#define SPEC_CVAL(x) x->select.s.const_val +#define SPEC_BSTR(x) x->select.s._bitStart +#define SPEC_BLEN(x) x->select.s._bitLength +#define SPEC_BNKF(x) x->select.s._rbank +#define SPEC_INTRTN(x) x->select.s._intrtn +#define SPEC_CRTCL(x) x->select.s._critical +#define SPEC_VOLATILE(x) x->select.s._volatile +#define SPEC_CONST(x) x->select.s._const +#define SPEC_STRUCT(x) x->select.s.v_struct +#define SPEC_TYPEDEF(x) x->select.s._typedef + +/* type check macros */ +#define IS_DECL(x) ( x && x->class == DECLARATOR ) +#define IS_SPEC(x) ( x && x->class == SPECIFIER ) +#define IS_ARRAY(x) (IS_DECL(x) && DCL_TYPE(x) == ARRAY) +#define IS_PTR(x) (IS_DECL(x) && (DCL_TYPE(x) == POINTER || \ + DCL_TYPE(x) == FPOINTER || \ + DCL_TYPE(x) == GPOINTER || \ + DCL_TYPE(x) == IPOINTER || \ + DCL_TYPE(x) == PPOINTER || \ + DCL_TYPE(x) == CPOINTER || \ + DCL_TYPE(x) == UPOINTER )) +#define IS_PTR_CONST(x) (IS_PTR(x) && DCL_PTR_CONST(x)) +#define IS_FARPTR(x) (IS_DECL(x) && DCL_TYPE(x) == FPOINTER) +#define IS_GENPTR(x) (IS_DECL(x) && DCL_TYPE(x) == GPOINTER) +#define IS_FUNC(x) (IS_DECL(x) && DCL_TYPE(x) == FUNCTION) +#define IS_LONG(x) (IS_SPEC(x) && x->select.s._long) +#define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short) +#define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef) +#define IS_CONSTANT(x) (IS_SPEC(x) && (x->select.s.sclass == S_CONSTANT ||\ + x->select.s._const == 1)) +#define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT) +#define IS_ABSOLUTE(x) (IS_SPEC(x) && x->select.s._absadr ) +#define IS_REGISTER(x) (IS_SPEC(x) && SPEC_SCLS(x) == S_REGISTER) +#define IS_RENT(x) (IS_SPEC(x) && x->select.s._reent ) +#define IS_STATIC(x) (IS_SPEC(x) && SPEC_STAT(x)) +#define IS_INT(x) (IS_SPEC(x) && x->select.s.noun == V_INT) +#define IS_VOID(x) (IS_SPEC(x) && x->select.s.noun == V_VOID) +#define IS_CHAR(x) (IS_SPEC(x) && x->select.s.noun == V_CHAR) +#define IS_EXTERN(x) (IS_SPEC(x) && x->select.s._extern) +#define IS_VOLATILE(x) (IS_SPEC(x) && x->select.s._volatile ) +#define IS_INTEGRAL(x) (IS_SPEC(x) && (x->select.s.noun == V_INT || \ + x->select.s.noun == V_CHAR || \ + x->select.s.noun == V_BIT || \ + x->select.s.noun == V_SBIT )) +#define IS_BITFIELD(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT)) +#define IS_BITVAR(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT || \ + x->select.s.noun == V_SBIT )) +#define IS_FLOAT(x) (IS_SPEC(x) && x->select.s.noun == V_FLOAT) +#define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x)) +#define IS_AGGREGATE(x) (IS_ARRAY(x) || IS_STRUCT(x)) +#define IS_LITERAL(x) (IS_SPEC(x) && x->select.s.sclass == S_LITERAL) +#define IS_ISR(x) (IS_SPEC(x) && SPEC_INTRTN(x)) + + +symbol *parseSymbol (char *, char **); +structdef *parseStruct (char *); +void parseFunc (char *); +module *parseModule (char *, bool ); +void parseLnkRec (char *); +symbol *symLookup (char *,context *); + +DEFSETFUNC(moduleWithName); +DEFSETFUNC(moduleWithCName); +DEFSETFUNC(moduleWithAsmName); +unsigned int getSize ( link * ); + +#endif diff --git a/device/README b/device/README new file mode 100644 index 00000000..224c364c --- /dev/null +++ b/device/README @@ -0,0 +1,5 @@ +sdcc/device +----------- + +This directory contains all device only files i.e. a basic C library, +headers, and set of examples. diff --git a/device/examples/an429.c b/device/examples/an429.c new file mode 100644 index 00000000..019d773b --- /dev/null +++ b/device/examples/an429.c @@ -0,0 +1,402 @@ +/* + this program the flow of air through a rotary flowmeter + and displays the calculated cfm. the output of the meter + is a small duty cycle pulse, the period of repatition of + which if proportional to the flow. the flow is compensated + for changes in pressure and temperature to maintain + calibration. if the flow exceeds an adjustable setpoint + it energizes a 2 form c relay for user application use. +*/ + +#include + +#define ZERO_K 2730 /* 0 degress centigrade in kelvin */ +#define ONE_TENTH_CFM 4444444L /* 1/10 cfm in microseconds */ +#define STD_TEMP 2980 /* 25 degrees centigrade in kelvin */ +#define STD_ATM 147 /* one atmosphere in tenths psi */ +#define LOWEST_CFM 0x40 /* maximun period from meter 0x400000 */ +#define START_ADC0 0x28 /* commands to start appropriate */ +#define START_ADC1 0x29 /* a/d conversion cycle */ +#define START_ADC2 0x2a /* */ +#define START_ADC3 0x2b /* */ +#define START_ADC4 0x2c /* */ +#define ADCI 0x10 /* a/d converter status flags */ +#define ADCS 0x08 /* */ +#define FREERUN_I 0x10 /* */ +#define SEG_A 0x01 /* P3 position for display segment 'a' */ +#define CFM 0x01 /* P3 position for 'cfm' led */ +#define SEG_B 0x02 /* P3 position for display segment 'b' */ +#define DEGREES 0x02 /* P3 position for 'degrees' led */ +#define SEG_C 0x04 /* P3 position for display segment 'c' */ +#define PSI 0x04 /* P3 position for 'psi' led */ +#define SEG_D 0x08 /* P3 position for display segment 'd' */ +#define SETPOINT 0x08 /* P3 position for 'setpoint' led */ +#define SEG_E 0x10 /* P3 position for display segment 'e' */ +#define SEG_F 0x20 /* P3 position for display segment 'f' */ +#define SEG_G 0x40 /* P3 position for display segment 'g' */ +#define SEG_DP 0x80 /* P3 position for display decimal pt. */ + +typedef unsigned char byte; /* type define objects with */ +typedef unsigned int word; /* more classical microprocessor */ +typedef unsigned long l_word; /* meaning */ + +#define TRUE 1 /* define logical true / false */ +#define FALSE 0 /* values for bit variables */ + + +/* + define look-up table of possible seven segment display + characters possible to display. table contents need to + be inverted before use to be compatible with U2 (udn2585a) +*/ + +code byte segments[] = +{ + SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F , /* 0 */ + SEG_B | SEG_C , /* 1 */ + SEG_A | SEG_B | SEG_D | SEG_E | SEG_G, /* 2 */ + SEG_A | SEG_B | SEG_C | SEG_D | SEG_G, /* 3 */ + SEG_B | SEG_C | SEG_F | SEG_G, /* 4 */ + SEG_A | SEG_C | SEG_D | SEG_F | SEG_G, /* 5 */ + SEG_A | SEG_C | SEG_D | SEG_E | SEG_F | SEG_G, /* 6 */ + SEG_A | SEG_B | SEG_C , /* 7 */ + SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F | SEG_G, /* 8 */ + SEG_A | SEG_B | SEG_C | SEG_D | SEG_F | SEG_G, /* 9 */ + SEG_A | SEG_D | SEG_E | SEG_F | SEG_G /* error */ +}; + +sbit RELAY = 0x96; /* active hi to turn on setpoint relay */ +sbit STROBE_0 = 0x80; /* active hi to enable status led's */ +sbit STROBE_1 = 0x81; /* active hi to enable display cr15 */ +sbit STROBE_2 = 0x82; /* active hi to enable display cr14 */ +sbit NO_FLOW = 0x83; /* flag set when no flow detected */ +sbit STROBE_3 = 0x84; /* active hi to enable display cr13 */ +sbit SEL_0 = 0x93; /* active low inputs used to select */ +sbit SEL_1 = 0x94; /* mode being displayed */ +sbit INTR = 0x95; /* */ +sbit UPDATE = 0x97; /* flag set when time to update display */ +data word cfm; /* gas flow in tenths of a cfm */ +data word setpoint; /* relay setpoint in tenths of a cfm */ +data word degree_c; /* temperature in tenths centagrade */ +data l_word corr; /* intermediate calculation value */ +data word psi; /* pressupe in tenths of a psi */ +data byte display0; /* variables to hold values for the */ +data byte display1; /* displays during refresh */ +data byte display2; /* */ +data byte display3; /* */ +data byte disp_pntr; /* pointer to next display to enable */ +data byte refresh; /* counter determines display updates */ +data byte high; /* bits 16 - 23 of flow period */ +data byte middle; /* bits 8 - 15 of flow period */ +data byte low; /* bits 0 - 7 of flow period */ +data byte ticks; /* incremented by timer overflow */ + +/* + use the free-running I timer to multiplex the led displays + at approx. 1000 hz. +*/ + +void multiplex() interrupt 3 +{ + switch(disp_pntr) + { + case 0x00: + STROBE_3 = FALSE; /* turn off display cr13 */ + P3 = 0xff; /* turn off all segments */ + P3 = display0; /* load segments for led's */ + STROBE_0 = TRUE; /* turn on status led's */ + disp_pntr = 1; /* increment pointer to dsiplay */ + break; + case 0x01: + STROBE_0 = FALSE; /* turn off status led's */ + P3 = 0xff; /* turn off all segments */ + P3 = display1; /* load segments for tenths */ + STROBE_1 = TRUE; /* turn on display cr15 */ + disp_pntr = 2; /* increment pointer to dsiplay */ + break; + case 0x02: + STROBE_1 = FALSE; /* turn off display cr15 */ + P3 = 0xff; /* turn off all segments */ + P3 = display2; /* load segments for units */ + STROBE_2 = TRUE; /* turn on display cr14 */ + disp_pntr = 3; /* increment pointer to dsiplay */ + break; + case 0x03: + STROBE_2 = FALSE; /* turn off display cr14 */ + P3 = 0xff; /* turn off all segments */ + P3 = display3; /* load segments for tens */ + STROBE_3 = TRUE; /* turn on display cr13 */ + disp_pntr = 0; /* increment pointer to dsiplay */ + break; + } +} + +/* + use the free running pwm prescaler to generate + interrupts every 92 hz. every 32nd interrupt + set the UPDATE flag to enable the reading of + the command switches, and updating of the led + display contents. +*/ +void read_switch() interrupt 6 +{ + if(refresh++ == 32) + { UPDATE = TRUE; + refresh = 0; + } +} + +/* + whenever the timer overflows from 0xffff to 0x0000 + increment the variable 'ticks' which represent the + highest order (16 - 23) bits of the gas flow period + in microseconds. if the variable 'ticks' is greater + than the period representing a flow of < 0.1 cfm + then set the NO_FLOW flag to enable display of 00.0 +*/ + +void overflow() interrupt 1 +{ + if(++ticks > LOWEST_CFM) + { + cfm = 0; + ticks = 0; + NO_FLOW = TRUE; + } +} + +/* + an external interrupt generated by a tach pulse + from the flowmeter reads the current value of the + timer into variables 'low' and 'middle', and then + resets the timers. the 'ticks' variable described + above is also copied to variable 'high', and then + reset to zero. the NO_FLOW flag is cleared to + enable display of the calculated cfm. +*/ + +void calc_cfm() interrupt 0 +{ + low = TL0; + TL0 = 0; + middle = TH0; + TH0 = 0; + high = ticks; + ticks = 0; + NO_FLOW = FALSE; +} + +void main() +{ + RELAY = 0; /* initialize output pins */ + INTR = 1; + UPDATE = 1; + STROBE_0 = 0; + STROBE_1 = 0; + STROBE_2 = 0; + STROBE_3 = 0; + NO_FLOW = 0; + TL0 = 0; /* timer 0 period 0x10000 u_seconds */ + TH0 = 0; + PWMP = 255; /* pwm timer interrupt at 92 hz */ + TR0 = 1; /* enable timer 0 */ + IT0 = 1; /* INT0 is edge active */ + ticks = 0; /* initialize variables */ + cfm = 0; + low = 0; + middle = 0; + high = 0; + degree_c = 250; + psi = 147; + corr = 0; + refresh = 0; + disp_pntr = 0; + IEN0 = 0xab; /* enable intrrupts */ +#ifdef MY +/* + main execution loop, executes forever. +*/ + + while(1) + { + +/* + calculate base cfm rate - first create long word representing + flow rate period in microseconds. then subtract out the time + overhead in servicing the routine 'calc_cfm'. then divide the + period into the period for 1/10 cfm, to get flow rate in 1/10 + cfm resolution. +*/ + + corr = high * 0x10000L; + corr += (middle * 0x100L); + corr += low; + corr = ONE_TENTH_CFM / corr; + +/* + read temperature - measure output from the LM35 sensor, + scaled by the AMP-02. the scaling results in a range + of 0 to 51.0 degrees centigrade, in 0.2 degree steps. +*/ + + ADCON = START_ADC1; + while(ADCON & ADCS) ; + degree_c = ((word)ADDATH) << 8 | ADDATL; + degree_c *= 2; + +/* + compensate cfm rate for temperature - convert temperature + into degrees kelvin, then divide it into the measured flow + rate multiplied by the calibration temperature of the flow- + meter in degrees kelvin. (nominal 25 degrees centigrade) +*/ + + corr *= STD_TEMP; + corr /= (ZERO_K + degree_c); + +/* + read pressure - measure output of the KP100A pressure trans- + ducer, scaled by the AMP_02. the scaling results in a range + of 0 to 25.5 psi, in 1/10 psi steps. +*/ + + ADCON = START_ADC0; + while(ADCON & ADCS) ; + psi = ((word) ADDATH << 8) | ADDATL; + +/* + compensate cfm rate for pressure - multiply measured pres- + sure and the calculated flow rate, and then divide it by + the standard atmospheric pressure at sea-level. (nominal + 14.7 psi) + +*/ + + corr *= psi; + corr /= STD_ATM; + cfm = corr; + +/* + read setpoint pot to obtain setpoint in the range of + 0 - 25.5 cfm in 1/10 cfm steps. +*/ + + ADCON = START_ADC2; + while(ADCON & ADCS) ; + setpoint = ADAT; + +/* + test if cfm rate greater or equal to the + setpoint, and if so then energize relay +*/ + + if(setpoint > cfm) + RELAY = 0; + else + RELAY = 1; + +/* + test if update flag has been set, and if so reset flag. +*/ + + if(UPDATE) + { + UPDATE = 0; + +/* + then test if the no flow flag has been set. if so then + display 00.0 cfm +*/ + + if(NO_FLOW) + { + display0 = ~CFM; + display1 = ~segments[0]; + display2 = ~(segments[0] | SEG_DP); + display3 = ~segments[0]; + } + +/* + if the no flow flag was not set then read the display + select switches, and display the appropriate data. +*/ + + else if(SEL_0) + { + if(SEL_1) + { + +/* + if no swich is depressed then the default display is + the flow rate in cfm. test the flowrate is greater than + or equal to 30 cfm then display the overrange message + EEE else the flow in XX.X format. +*/ + + if(cfm <= 300) + { + display0 = ~CFM; + display1 = ~segments[cfm % 10]; + cfm /= 10; + display2 = ~(segments[cfm % 10]); + cfm /= 10; + display3 = ~segments[cfm % 10]; + } + else + { + display0 = ~CFM; + display1 = ~segments[10]; + display2 = ~segments[10]; + display3 = ~segments[10]; + } + } + +/* + if switch 1 is depressed then display temperature. +*/ + + else + { + display0 = ~DEGREES; + display1 = ~segments[degree_c % 10]; + degree_c /= 10; + display2 = ~(segments[degree_c % 10] | SEG_DP); + degree_c /= 10; + display3 = ~segments[degree_c % 10]; + } + } + else + { + +/* + if switch 2 depressed then display the pressure. +*/ + + if(SEL_1) + { + display0 = ~PSI; + display1 = ~segments[psi % 10]; + psi /= 10; + display2 = ~(segments[psi % 10] | SEG_DP); + psi /= 10; + display3 = ~segments[psi % 10]; + } + +/* + if switch 3 depressed then display the setpoint. +*/ + + else + { + display0 = ~SETPOINT; + display1 = ~segments[setpoint % 10]; + setpoint /= 10; + display2 = ~(segments[setpoint % 10] | SEG_DP); + setpoint /= 10; + display3 = ~segments[setpoint % 10]; + } + } + } + } +#endif +} diff --git a/device/examples/clean.mk b/device/examples/clean.mk new file mode 100644 index 00000000..8b2f39bd --- /dev/null +++ b/device/examples/clean.mk @@ -0,0 +1,28 @@ +include incl.mk + +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] *.rel *.lst *.sym *.asm *.ihx *.dump* + rm -f .[a-z]*~ + rm -f *.dump* + for model in $(MODELS); do \ + rm -rf $$model; \ + done + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/device/examples/cpu_tools.c b/device/examples/cpu_tools.c new file mode 100644 index 00000000..2dd2cba4 --- /dev/null +++ b/device/examples/cpu_tools.c @@ -0,0 +1,283 @@ +/*------------------------------------------------------------------------- + CPU depending Declarations + + Written By - Dipl.-Ing. (FH) Michael Schmitt + Bug-Fix Oct 15 1999 + mschmitt@mainz-online.de + michael.schmitt@t-online.de + + Thanks to Josef Wolf for the serial io functions + via interrupts + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +// This file contains CPU depending utilities +// some of these parts are taken from sources made public by the sdcc project +// special thanks to sandeep for his great work and all other + +// First some usseful definitions +#define FALSE 0 +#define TRUE !FALSE + +// here is a definition of a single nop command as it has to be declared under keil-C and sdcc +#ifdef SDCC + #define NOP _asm nop _endasm +#else + // This is for Keil-C + #define NOP _nop_() +#endif + +// =========================================================================================== +// Here are some CPU depending definitions that have to checked + +#ifndef EXTENDED_CPU_IDLE +void CpuIdle( void ) +{ + PCON |= 0x01; /* Setting IDL-Bit of Register PCON */ +} +#else + #define CpuIdle() PCON |= 0x01; PCON |= 0x20 // start the idle mode... +#endif + +void WatchDog( void ) +{ + // no watchdog yet +} + + +// =========================================================================================== +// Serial IO using the internal UART in interrupt mode +#ifdef SERIAL_VIA_INTERRUPT + +#define SERIAL_IS_DEFINED + + // Transmit Buffersize +#ifndef SERIAL_VIA_INTERRUPT_XBUFLEN + #error "SERIAL_VIA_INTERRUPT_XBUFLEN not defined using default" + #define SERIAL_VIA_INTERRUPT_XBUFLEN 8 +#endif + + // Receive Buffer Size +#ifndef SERIAL_VIA_INTERRUPT_RBUFLEN + #error "SERIAL_VIA_INTERRUPT_RBUFLEN not defined using default" + #define SERIAL_VIA_INTERRUPT_RBUFLEN 8 +#endif + +// for interrupt mode we implement a ring buffer +volatile xdata static unsigned char SERIAL_VIA_INTERRUPT_RBUF[SERIAL_VIA_INTERRUPT_RBUFLEN]; +volatile xdata static unsigned char SERIAL_VIA_INTERRUPT_XBUF[SERIAL_VIA_INTERRUPT_XBUFLEN]; +volatile static unsigned char SERIAL_VIA_INTERRUPT_RCNT; +volatile static unsigned char SERIAL_VIA_INTERRUPT_XCNT; +volatile static unsigned char SERIAL_VIA_INTERRUPT_RPOS; +volatile static unsigned char SERIAL_VIA_INTERRUPT_XPOS; +volatile static unsigned char SERIAL_VIA_INTERRUPT_BUSY; + +#endif // SERIAL_VIA_INTERRUPT + +#ifdef SERIAL_VIA_POLLING + #define SERIAL_IS_DEFINED +#endif // SERIAL_VIA_POLLING + +#ifdef SERIAL_IS_DEFINED + // Here are some definitions about the desired serial interface + #ifndef CPUCLKHZ + #error "CPUCLKHZ is not defined !" + #endif + #ifndef BAUDRATE + #error "BAUDRATE is not defined !" + #endif + + #define TIMER1MODE2RELOADVALUE (256-(1*CPUCLKHZ/32/12/BAUDRATE)) +#endif // SERIAL_IS_DEFINED + +#ifdef SERIAL_VIA_INTERRUPT +void ser_handler (void) interrupt 4 +{ + if (RI) { + RI = 0; + /* don't overwrite chars already in buffer */ + if (SERIAL_VIA_INTERRUPT_RCNT < SERIAL_VIA_INTERRUPT_RBUFLEN) + SERIAL_VIA_INTERRUPT_RBUF [(SERIAL_VIA_INTERRUPT_RPOS+SERIAL_VIA_INTERRUPT_RCNT++) % SERIAL_VIA_INTERRUPT_RBUFLEN] = SBUF; + } + if (TI) { + TI = 0; + if (SERIAL_VIA_INTERRUPT_BUSY = SERIAL_VIA_INTERRUPT_XCNT) { /* Assignment, _not_ comparison! */ + SERIAL_VIA_INTERRUPT_XCNT--; + SBUF = SERIAL_VIA_INTERRUPT_XBUF [SERIAL_VIA_INTERRUPT_XPOS++]; + if (SERIAL_VIA_INTERRUPT_XPOS >= SERIAL_VIA_INTERRUPT_XBUFLEN) + SERIAL_VIA_INTERRUPT_XPOS = 0; + } + } +} + +void putchar( char Byte ) +{ + while (SERIAL_VIA_INTERRUPT_XCNT >= SERIAL_VIA_INTERRUPT_XBUFLEN) /* wait for room in buffer */ + { + WatchDog(); + CpuIdle(); + } + ES = 0; + if (SERIAL_VIA_INTERRUPT_BUSY) { + SERIAL_VIA_INTERRUPT_XBUF[(SERIAL_VIA_INTERRUPT_XPOS+SERIAL_VIA_INTERRUPT_XCNT++) % SERIAL_VIA_INTERRUPT_XBUFLEN] = Byte; + } else { + SBUF = Byte; + SERIAL_VIA_INTERRUPT_BUSY = 1; + } + ES = 1; +} + +unsigned char getchar( void ) +{ + unsigned char c; + while (!SERIAL_VIA_INTERRUPT_RCNT) /* wait for character */ + { + WatchDog(); + CpuIdle(); + } + ES = 0; + SERIAL_VIA_INTERRUPT_RCNT--; + c = SERIAL_VIA_INTERRUPT_RBUF [SERIAL_VIA_INTERRUPT_RPOS++]; + if (SERIAL_VIA_INTERRUPT_RPOS >= SERIAL_VIA_INTERRUPT_RBUFLEN) + SERIAL_VIA_INTERRUPT_RPOS = 0; + ES = 1; + return (c); +} +#endif + +// =========================================================================================== +// Now the Internal UART Handling if Polling Method is used +#ifdef SERIAL_VIA_POLLING +void putchar( char Byte ) +{ + while( !TI ) /* wait for TI==1 */ + { + WatchDog(); + CpuIdle(); + } + SBUF = Byte; + TI = 0; +} + +unsigned char getchar( void ) +{ + while( !RI ) /* wait for RI==1 */ + { + WatchDog(); + CpuIdle(); + } + RI=0; + return (SBUF); +} +#endif + +// =========================================================================================== +// System Timer +#ifdef USE_SYSTEM_TIMER + +volatile unsigned long SystemTicks1msec; + +// Here are the definitions of the 1kHz Timer 0 +// used for delay( xx_msec ) +#ifndef CPUCLKHZ +#error "CPUCLKHZ is not defined !" +#endif + +#define TIMER0INTSPERSECOND 1000 +#define TIMER0MODE1RELOADVALUE (-((CPUCLKHZ/TIMER0INTSPERSECOND)/12)) + +void delayMsec( unsigned long delayTime ) +{ + delayTime += SystemTicks1msec; + while( SystemTicks1msec < delayTime ) + { + CpuIdle(); + } +} + +void timer0_isr (void) interrupt 1 +{ + /* Interruptrate will be slightly slower than wanted */ + /* because TL0 is not 0 here, not bug-fix yet */ + TL0 = (TIMER0MODE1RELOADVALUE & 0x00FF); + TH0 = (TIMER0MODE1RELOADVALUE >> 8); + SystemTicks1msec++; +} +#endif // USE_SYSTEM_TIMER + +// =========================================================================================== +// Global Hardware Init +void init_hardware( void ) +{ +#ifdef USE_SYSTEM_TIMER + SystemTicks1msec = 0x0; +#endif // USE_SYSTEM_TIMER + + EA = 0; /* Disable ALL Ints */ + ES = 0; /* Disable Serial Int */ + ET1 = 0; /* Disable Timer 1 Int */ + EX1 = 0; /* Disable External Interrupt 1 */ + ET0 = 0; /* Disable Timer 0 Int */ + EX0 = 0; /* Disable External Interrupt 0 */ + + TR1 = 0; /* Stop Timer 1 */ + TR0 = 0; /* Stop Timer 0 */ + +#ifdef SERIAL_VIA_INTERRUPT + SERIAL_VIA_INTERRUPT_RCNT = SERIAL_VIA_INTERRUPT_XCNT = SERIAL_VIA_INTERRUPT_RPOS = SERIAL_VIA_INTERRUPT_XPOS = 0; /* init buffers */ + SERIAL_VIA_INTERRUPT_BUSY = 0; +#endif + +#ifdef SERIAL_IS_DEFINED + /* Init UART 9600Baud 8-Bit using Timer 1 in Mode 2*/ + /* Set Reload Values for CPU-Clk and BaudRate */ + TH1 = TIMER1MODE2RELOADVALUE; + TL1 = TIMER1MODE2RELOADVALUE; + TMOD &= 0x0f; /* First we set Timer 1 */ + TMOD |= 0x20; /* Setting Timer 1 as GATE=0 TIMER and MODE 2 8-bit auto reload */ + TR1 = 1; /* Enabling Timer 1 */ +#endif + +#ifdef USE_SYSTEM_TIMER + /* Init Timer 0 as Software Interrupt for 1mSec Timer */ + TL0 = (TIMER0MODE1RELOADVALUE & 0x00FF); + TH0 = (TIMER0MODE1RELOADVALUE >> 8); + TMOD &= 0xf0; /* Now Timer 0 */ + TMOD |= 0x01; /* Setting Timer 0 as GATE=0 TIMER and MODE 1 16-bit Timer mode */ + TR0 = 1; /* Enabling Timer 0 */ +#endif + +#ifdef SERIAL_IS_DEFINED + SCON = 0x40; /* Init Serial Port as 8-Bit UART with variable Baudrate */ + SCON |= 0x10; /* Enabling Serial reception */ + SCON |= 0x02; /* Setting TI-Bit */ +#endif + +#ifdef USE_SYSTEM_TIMER + TR0 = 1; /* Start Timer 0 */ + ET0 = 1; /* Enable Timer 0 Interrupt */ +#endif + +#ifdef SERIAL_VIA_INTERRUPT + ES = 1; /* Enable Serial Interrupt */ +#endif + EA = 1; /* Enable all Enabled Interrupts */ + +} diff --git a/device/examples/cpu_tools.h b/device/examples/cpu_tools.h new file mode 100644 index 00000000..99f95cf2 --- /dev/null +++ b/device/examples/cpu_tools.h @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + CPU depending Declarations Header file + + Written By - Dipl.-Ing. (FH) Michael Schmitt + Bug-Fix Oct 15 1999 + mschmitt@mainz-online.de + michael.schmitt@t-online.de + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +void CpuIdle( void ); +void WatchDog( void ); +void init_hardware( void ); +void delayMsec( unsigned long delayTime ); +void timer0_isr (void) interrupt 1; +void ser_handler (void) interrupt 4; +void putchar( char Byte ); +unsigned char getchar( void ); diff --git a/device/examples/crc.c b/device/examples/crc.c new file mode 100644 index 00000000..97594e1b --- /dev/null +++ b/device/examples/crc.c @@ -0,0 +1,10 @@ +typedef unsigned char byte; + +byte accum_checksum(byte cs, byte val) +{ + unsigned int tmp; + + tmp = ((cs<<7) | (cs>>1)) + val; + + return (byte)tmp + ((byte) (tmp>>8) & 1); +} diff --git a/device/examples/crcs.c b/device/examples/crcs.c new file mode 100644 index 00000000..7736d508 --- /dev/null +++ b/device/examples/crcs.c @@ -0,0 +1,11 @@ +#include +typedef unsigned char byte; + +byte accum_checksum(byte cs, byte val) +{ + register unsigned char tmp; + + tmp = ((cs<<1) | (cs>>7)) + val; + + return (CY ? ( tmp + 1 ) : tmp); +} diff --git a/device/examples/itoa.c b/device/examples/itoa.c new file mode 100644 index 00000000..a3c7d1b7 --- /dev/null +++ b/device/examples/itoa.c @@ -0,0 +1,47 @@ +/*------------------------------------------------------------------------- + integer to string conversion + + Written by: Bela Torok, 1999 + bela.torok@kssg.ch + usage: + + uitoa(unsigned int value, char* string, int radix) + itoa(int value, char* string, int radix) + + value -> Number to be converted + string -> Result + radix -> Base of value (e.g.: 2 for binary, 10 for decimal, 16 for hex) +---------------------------------------------------------------------------*/ + +#define NUMBER_OF_DIGITS 16 /* space for NUMBER_OF_DIGITS + '\0' */ + +void uitoa(unsigned int value, char* string, int radix) +{ +unsigned char index, i; + + index = NUMBER_OF_DIGITS; + i = 0; + + do { + string[--index] = '0' + (value % radix); + if ( string[index] > '9') string[index] += 'A' - ':'; /* continue with A, B,.. */ + value /= radix; + } while (value != 0); + + do { + string[i++] = string[index++]; + } while ( index < NUMBER_OF_DIGITS ); + + string[i] = 0; /* string terminator */ +} + +void itoa(int value, char* string, int radix) +{ + if (value < 0 && radix == 10) { + *string++ = '-'; + uitoa(-value, string, radix); + } + else { + uitoa(value, string, radix); + } +} \ No newline at end of file diff --git a/device/examples/ltoa.c b/device/examples/ltoa.c new file mode 100644 index 00000000..f5be64ff --- /dev/null +++ b/device/examples/ltoa.c @@ -0,0 +1,48 @@ +/*------------------------------------------------------------------------- + integer to string conversion + + Written by: Bela Torok, 1999 + bela.torok@kssg.ch + usage: + + ultoa(unsigned long value, char* string, int radix) + ltoa(long value, char* string, int radix) + + value -> Number to be converted + string -> Result + radix -> Base of value (e.g.: 2 for binary, 10 for decimal, 16 for hex) +---------------------------------------------------------------------------*/ + +#define NUMBER_OF_DIGITS 32 + +void ultoa(unsigned long value, char* string, int radix) +{ +unsigned char index; +char buffer[NUMBER_OF_DIGITS]; /* space for NUMBER_OF_DIGITS + '\0' */ + + index = NUMBER_OF_DIGITS; + + do { + buffer[--index] = '0' + (value % radix); + if ( buffer[index] > '9') buffer[index] += 'A' - ':'; /* continue with A, B,... */ + value /= radix; + } while (value != 0); + + do { + *string++ = buffer[index++]; + } while ( index < NUMBER_OF_DIGITS ); + + *string = 0; /* string terminator */ +} + +void ltoa(long value, char* string, int radix) +{ + if (value < 0 && radix == 10) { + *string++ = '-'; + ultoa(-value, string, radix); + } + else { + ultoa(value, string, radix); + } +} + diff --git a/device/examples/main8051.c b/device/examples/main8051.c new file mode 100644 index 00000000..377cd151 --- /dev/null +++ b/device/examples/main8051.c @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------- + CPU Startup Code + + Written By - Dipl.-Ing. (FH) Michael Schmitt + Bug-Fix Oct 15 1999 + mschmitt@mainz-online.de + michael.schmitt@t-online.de + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +/* here are some definition about the CPU */ +#include +#define CPUCLKHZ 11059200 +//#define CPUCLKHZ 24000000 +#define BAUDRATE 9600 + +// For serial com. we use the internal UART and data exchange is done by interrupt and not via polling +#define SERIAL_VIA_INTERRUPT +#define SERIAL_VIA_INTERRUPT_XBUFLEN 64 +#define SERIAL_VIA_INTERRUPT_RBUFLEN 4 +//#define SERIAL_VIA_POLLING + +// include a 1msec timer +#define USE_SYSTEM_TIMER + +// all 8051-CPU utils can be found here +#include "cpu_tools.h" +#include "cpu_tools.c" + +// that is needed for printf, will be removed after the debug version + +// if the following files are copied to the local folder, enable the next two lines and comment out +// the two lines above +//#include "vprintf.c" +//#include "printf_large.c" + +//#include "harddisk.c" + +void main() +{ + // This has to be done first + init_hardware(); + + + printf( "\n\r<<< RESET >>>\r\n" ); + + printf( "\n\rStartTime : " ); + printf( "%ld \n\r",SystemTicks1msec ); + + while( 1 ) + { + printf( "\r%ld ", SystemTicks1msec); + delayMsec( 999 ); + } +} diff --git a/device/examples/test2.c b/device/examples/test2.c new file mode 100644 index 00000000..2a51e35f --- /dev/null +++ b/device/examples/test2.c @@ -0,0 +1,909 @@ +/******************************************************************************/ +/* */ +/* 2HACES.C */ +/* */ +/******************************************************************************/ +void watchdog(); +unsigned char codigo(unsigned char, unsigned char, unsigned char, unsigned char); +void contestar(); +void inicializar_registros(); +void bajo_consumo(); +unsigned char recibir_trama(); +unsigned char contestar_si_error(); +void configurar_haz0(unsigned char, unsigned char); +void configurar_haz1(unsigned char, unsigned char); +void telec_actualizacion(); +void telec_conformacion(unsigned char); +void telec_temperatura(); +void telec_pet_Estado(); + +/* Fichero de definición de direcciones de memoria + asignadas a los diferentes registros */ +#include "reg51.h" + +/* Direcciones de los puertos P4 y P5 y del TIMER3*/ +sfr P4 = 0xC0; +sfr P5 = 0xC4; +sfr TIMER3 = 0xFF; +sfr ADCON = 0xD8; +sfr ADAT = 0xD7; + +/* Dirección del bit que indica que hay una conversión A/D preparada */ +#define AD_FIN 0x10 + +/* + Valores que utilizamos para obtener el código de Hamming de los mensajes. + El mensaje es de 29 bits (4 bytes) y la redundancia la tomamos de 11 bits. + La matriz de Hamming asociada será por tanto de tamaño (11x29) bits. + En las matrices siguiente colocamos la expresión hexadecimal de cada + una de las columnas de la matriz de Hamming. La obtención de los bits de + redundancia asociados a un mensaje los obtendremos haciendo la operación XOR + entre las columnas de la matriz de Hamming correspondientes a los '1' de los 29 + bits del mensaje. Esto es más eficiente que realizar el producto matricial. + Como la memoria está organizada en bytes, utilizamos dos matrices. En una de ellas, + "Hamming_H", colocamos las tres primeras filas de la matriz de Hamming y en la otra, + "Hamming_L", las 8 filas restantes. +*/ + +#define Hamming_H0 0x0 +#define Hamming_H1 0x1 +#define Hamming_H2 0x2 +#define Hamming_H3 0x1 +#define Hamming_H4 0x6 +#define Hamming_H5 0x5 +#define Hamming_H6 0x2 +#define Hamming_H7 0x7 +#define Hamming_H8 0x8 +#define Hamming_H9 0x3 +#define Hamming_H10 0x9 +#define Hamming_H11 0x6 +#define Hamming_H12 0x2 +#define Hamming_H13 0x9 +#define Hamming_H14 0x4 +#define Hamming_H15 0x4 +#define Hamming_H16 0x3 +#define Hamming_H17 0x8 +#define Hamming_H18 0x7 +#define Hamming_H19 0x6 +#define Hamming_H20 0x0 +#define Hamming_H21 0x8 +#define Hamming_H22 0x7 +#define Hamming_H23 0x6 +#define Hamming_H24 0x9 +#define Hamming_H25 0x2 +#define Hamming_H26 0x3 +#define Hamming_H27 0x7 +#define Hamming_H28 0x3 +#define Hamming_H29 0x3 +#define Hamming_H30 0x3 +#define Hamming_H31 0x3 + + +/* Dirección del bit que inicia la conversión A/D */ +#define AD_INI 0x08 + + +/* Valores booleanos */ +#define TRUE 0x01 +#define FALSE 0x00 + + +/* Máscaras utilizadas para identificar los telecomandos */ +#define CONFORMACION 0xC0 + /* Telecomando que procesan todos los Subarrays. Se cambia el apuntamiento de la antena */ + +#define ACTUALIZACION 0x80 + /* Telecomando en el que se envía a un Subarray el próximo estado de uno de los haces */ + +#define TEMPERATURA 0x00 + /* Telecomando en el que se solicita a un Subarray la temperatura del módulo T/R */ + +#define PETICION_ESTADO 0x40 + /* Telecomando en el que se solicita a un Subarray el estado de programación de un haz */ + + +/* Valores booleanos utilizados en las rutinas de recepción de tramas */ +#define TIEMPO_EXCEDIDO 0x01 +#define TIEMPO_NO_EXCEDIDO 0x00 + + +/* Asociamos etiquetas a los identificadores que utiliza el + compilador para designar algunos registros del micro */ +#define ACUMULADOR ACC +#define BUFFER_SERIE SBUF +#define DATO_RECIBIDO RI +#define DATO_ENVIADO TI +#define PARIDAD_ACC P +#define BIT_PARIDAD_REC RB8 +#define BIT_PARIDAD_TRA TB8 + + +/* Sustituimos por etiquetas algunas operaciones sencillas */ +#define obtener_direc_mensaje (BYTE[0] & 0x3F) +#define direccion_CONFORMACION (BYTE[1] & 0x3F) +#define obtener_tipo_mensaje (BYTE[0] & 0xC0) +#define direc_subarray ((P5 & 0x7E) >> 1) + + +/* DECLARACION DE VARIABLES */ +volatile unsigned char int_serie; +unsigned char BYTE[5]; +unsigned char BYTE_MENSAJE[3]; +volatile unsigned char ERROR_PARIDAD; + + +/* + Matriz que utilizamos para almacenar los estados predefinidos. + En las posiciones pares (0,2,4,...) están los códigos de amplitud y en las + impares (1,3,5,...) los de fase. +*/ +unsigned char tabla_estados[20]; + + +/* + Matriz en la que almacenamos los índices a la tabla de estados correspondientes a la programación + actual de los dos haces. Los índices tienen 11 bits de longitud. El contenido de la matriz es + + estado_haces[0] --> haz 0, i10...i3 + estado_haces[1] --> haz 0, i2...i0 + estado_haces[2] --> haz 1, i10...i3 + estado_haces[3] --> haz 1, i2...i0 +*/ +unsigned char estado_haces[4]; + + +/* + Función principal +*/ +void main() +{ + unsigned char direc_mensaje; + unsigned char TIMEOUT; + unsigned char mensaje; + unsigned char ERROR; + unsigned char DIRECCION_SUBARRAY; + + inicializar_registros(); + + /* Obtenemos la dirección del subarray */ + DIRECCION_SUBARRAY = direc_subarray; + + /* bucle del programa */ + while(1) + { + /* Bandera que utilizamos para determinar si la interrupción + que se produce se ha originado en el puerto serie */ + int_serie = 0; + + /* El micro entra en modo de bajo consumo mientras no se + produzca actividad en el puerto serie */ + while(int_serie == 0) + bajo_consumo(); + + /* Se ha detectado actividad en el bus de telecomandos. Capturamos la trama */ + TIMEOUT = recibir_trama(); + + /* Si no se ha excedido el tiempo límite se procede a identificar el mensaje recibido */ + if (TIMEOUT == FALSE) + { + mensaje = obtener_tipo_mensaje; + direc_mensaje = obtener_direc_mensaje; + + if (direc_mensaje == DIRECCION_SUBARRAY) + ERROR = contestar_si_error(); + + /* Si no ha habido error en la recepción se procesa el telecomando */ + if (ERROR == FALSE) + { + switch(mensaje) + { + case CONFORMACION : telec_conformacion(DIRECCION_SUBARRAY); + + break; + + case ACTUALIZACION : if (direc_mensaje == DIRECCION_SUBARRAY) + telec_actualizacion(); + + break; + + case TEMPERATURA : if (direc_mensaje == DIRECCION_SUBARRAY) + telec_temperatura(); + + break; + + case PETICION_ESTADO : if (direc_mensaje == DIRECCION_SUBARRAY) + telec_pet_Estado(); + + break; + } + } + } + } + +} + + +/* + Subrutina que actualiza el TIMER3 con el que se implementa la función WATCHDOG. + Esta función se habilita conectando un pin externo a nivel bajo, y funciona de + forma independiente al código que se ejecuta en el micro. Cuando el TIMER3 llega + al final de la cuenta se produce un RESET del micro, por tanto, hay que habilitar + un mecanismo de recarga del CONTADOR de forma que entre dos recargas no medie un + tiempo mayor al que emplea la cuenta. + Este tiempo oscila (para la frecuencia de reloj que utilizamos, 11.059 MHz) entre + 2.22 ms para una cuenta mínima y 569 ms para una cuenta máxima. + Aquí usaremos el CONTADOR con cuenta máxima, para lo cual, dado que la cuenta + es ascendente, el valor de recarga es 0. + La recarga la haremos utilizando la interrupción que provoca el TIMER0 al llegar al + final de la cuenta. +*/ +void watchdog() +{ + PCON |= 0x10; + /*TIMER3 = 0x00;*/ +} + + +/* + Subrutina que atiende a la interrupción provocada por la UART del puerto serie + cuando se ha recibido o enviado un carácter. + En esta subrutina lo único que hacemos es poner el valor 1 en la variable 'int_serie' + para indicar que la interrupción ocurrida es debida al puerto serie. Esto es necesario + porque el micro sale del estado de bajo consumo mediante cualquier interrupción, y sólo + queremos que lo haga cuando haya actividad en el puerto serie, de forma que si se produce + alguna otra interrupción el micro chequea esta variable y si está a 0 vuelve a entrar en + el estado de bajo consumo. + + La variable 'int_serie' se pone a cero siempre justo antes de entrar en el modo de bajo + consumo, y es únicamente en esta subrutina donde se pone a valor uno. +*/ +void sint(void) interrupt 4 using 2 +{ + int_serie = 1; +} + + +/* + Subrutina que atiende a la interrupción provocada por el TIMER0. + Utilizamos esta interrupción para recargar el TIMER3 que relacionado con la operación del + WATCHDOG. + Esta interrupción se produce (para la frecuencia de reloj que utilizamos, 11.059 MHz) cada + 71.12 ms, lo que supone un margen de seguridad amplio frente a los 569 ms que emplea el + TIMER3 en realizar una cuenta. +*/ +void tint() interrupt 1 using 1 +{ + /* Llamamos a la subrutina que actualiza el TIMER3 del 'watchdog' */ + watchdog(); +} + + +/* + Función que implementa la codificación de Hamming (40,32) del mensaje + (tc1, tc2, tc3, tc4). + La función devuelve la redundancia del mensaje de entrada en las variables "red" + Como ya hemos comentado al declarar la matriz 'Hamming', para no realizar producto de matriz + por vector para calcular la redundancia, almacenamos la matriz generadora de Hamming como dos + vectores de valores hexadecimales de longitud 29. + Para obtener la redundancia lo que hacemos es realizar la operación XOR entre los valores del + vectores "Hamming_H" cuyo índice coincide con los índices de los dígitos igual a '1' + en la palabra mensaje. + Para encontrar estos índices comparamos cada uno de los 4 bytes de que se compone el mensaje + con las potencias de dos (2^7, 2^6, ... , 2^1, 2^0). +*/ +unsigned char codigo(unsigned char tc1,unsigned char tc2,unsigned char tc3,unsigned char tc4) +{ + unsigned char red; + + if (tc1 != 0x00) + { + if (tc1 & 128) red ^= Hamming_H0; + if (tc1 & 64 ) red ^= Hamming_H1; + if (tc1 & 32 ) red ^= Hamming_H2; + if (tc1 & 16 ) red ^= Hamming_H3; + if (tc1 & 8 ) red ^= Hamming_H4; + if (tc1 & 4 ) red ^= Hamming_H5; + if (tc1 & 2 ) red ^= Hamming_H6; + if (tc1 & 1 ) red ^= Hamming_H7; + } + + if (tc2 != 0x00) + { + if (tc2 & 128) red ^= Hamming_H8; + if (tc2 & 64 ) red ^= Hamming_H9; + if (tc2 & 32 ) red ^= Hamming_H10; + if (tc2 & 16 ) red ^= Hamming_H11; + if (tc2 & 8 ) red ^= Hamming_H12; + if (tc2 & 4 ) red ^= Hamming_H13; + if (tc2 & 2 ) red ^= Hamming_H14; + if (tc2 & 1 ) red ^= Hamming_H15; + } + + if (tc3 != 0x00) + { + if (tc3 & 128) red ^= Hamming_H16; + if (tc3 & 64 ) red ^= Hamming_H17; + if (tc3 & 32 ) red ^= Hamming_H18; + if (tc3 & 16 ) red ^= Hamming_H19; + if (tc3 & 8 ) red ^= Hamming_H20; + if (tc3 & 4 ) red ^= Hamming_H21; + if (tc3 & 2 ) red ^= Hamming_H22; + if (tc3 & 1 ) red ^= Hamming_H23; + } + + if (tc4 != 0x00) + { + if (tc4 & 128) red ^= Hamming_H24; + if (tc4 & 64 ) red ^= Hamming_H25; + if (tc4 & 32 ) red ^= Hamming_H26; + if (tc4 & 16 ) red ^= Hamming_H27; + if (tc4 & 8 ) red ^= Hamming_H28; + if (tc4 & 4 ) red ^= Hamming_H29; + if (tc4 & 2 ) red ^= Hamming_H30; + if (tc4 & 1 ) red ^= Hamming_H31; + } + + return(red); +} + + +/* + Subrutina que implementa el envío de mensajes en respuesta a los telecomandos recibidos. + Los mensajes enviados son siempre de dos bytes más el byte de redundancia del código de Hamming. + Para utilizar el mismo código en transmisión que en recepción, se añade un tercer byte con valor + 0 cuando se calcula la redundancia del mensaje a enviar. Esto mismo hace el módulo que recibe + los mensajes que envían los subarrays para chequear la corrección de dichos mensajes. + + El proceso de envío es el siguiente. + + - Activar el 'driver' de transmisión. + + - Enviar 3 bytes del mensaje: + * Calcular la paridad de cada byte y colarla en el registro de la UART etiquetado como + 'BIT_PARIDAD_TRA'. + * Colocar el byte a transmitir en el registro de salida 'BUFFER_SERIE'. + * Esperar que la UART indique en la bandera 'DATO_ENVIADO' que se ha enviado un byte + antes de enviar el siguiente. + + - Desactivar el 'driver' de transmisión. + + Para evitar que por alguna eventualidad la UART no actualice la bandera 'DATO_ENVIADO' y el + programa quede indefinidamente esperando, utilizamos la variable 'CONTADOR' que se incrementa + cada vez que hacemos una comprobación de la bandera. Cuando se llega a un valor límite no + se hacen mas comprobaciones y se sigue enviando el resto del mensaje. + Podríamos haber optado por abortar la transmisión en el caso de se llegue al valor límite de + la cuenta, porque esto indicaría que se ha producido un error. Sin embargo continuamos la + transmisión dejando que recaiga sobre el módulo que recibe los mensajes la responsabilidad de + actuar frente a la detección de un error. + Esto no supone ningún riesgo grave porque los mensajes de respuesta a telecomandos no afectan + al estado de apuntamiento de la antena. +*/ +void contestar() +{ + unsigned char CONTADOR; + int num_byte; + /* + Paridad impar. Metemos el bit de paridad en BIT_PARIDAD_TRA antes de mandar un byte. + En el "flag" PARIDAD_ACC tenemos la paridad del dato que hay en el ACUMULADOR. + Como la paridad es impar lo negamos + */ + + /* Activar driver transmisión: + (P3.2 a 0) */ + P3 &= 0xFB; + + for (num_byte = 0; num_byte <3; num_byte ++) + { + ACUMULADOR = BYTE_MENSAJE[num_byte]; + BIT_PARIDAD_TRA = ~PARIDAD_ACC; + BUFFER_SERIE = ACUMULADOR; + + /* Esperamos que el dato sea enviado */ + CONTADOR = 0; + while ((DATO_ENVIADO == 0) && (CONTADOR < 254)) + CONTADOR++; + + /* Desactivamos el flag */ + DATO_ENVIADO = 0; + } + + /* Desactivar driver */ + P3 |= 0x04; +} + + +/* + Subrutina que se ejecuta al comenzar a funcionar el microcontrolador + y que adecua al cometido que ha de realizar el micro los valores en + algunos registros. +*/ +void inicializar_registros() +{ + /* Registro de interrupciones: + habilitamos la interrupción del TIMER0 */ + IP =0x82; + + /* Puerto serie */ + /* fosc = 11.059 MHz */ + /* Transmisión a 9600 baudios */ + PCON = 0x00; + TMOD = 0x21; + SCON = 0xD0; + + /* Registros de los 'timers' */ + /* Timer 1 en 'auto-reload' para generar velocidad transmisión */ + /* Usamos el TIMER0 para recargar el TIMER3 mientras se */ + /* espera un nuevo comando */ + /* El TIMER1 se usa para generar el 'baud-rate' */ + /* Los timers son de 16 bits. */ + TH1 = 0xFD; + TL1 = 0x00; + TH0 = 0xFF; + TL0 = 0x00; + + /* Activamos los 'timers' */ + TR1 = 0x1; + TR0 = 0x1; +} + + +/* + Subrutina que hace que el micro entre en estado de bajo consumo +*/ +void bajo_consumo() +{ + /* Habilitamos la interrupción del puerto serie */ + IE = 0x92; + + /* Activamos el modo 'idle' de bajo consumo. De este modo se sale + cuando se produce alguna interrupción */ + PCON |= 1; + + /* Esta instrucción se ejecuta una vez que se ha salido del modo 'idle' + Deshabilitamos la interrupción del puerto serie */ + IE = 0x82; +} + +/* + Subrutina que realiza la recepción de los telecomandos. Todos tienen una longitud de 4 bytes + más el byte del código de Hamming. + Los bytes recibidos los coloca la UART en el registro 'BUFFER_SERIE', y el programa los coloca en las + variables 'BYTE0...4'. + La recepción de cada byte supone esperar que la bandera 'DATO_RECIBIDO' sea actualizada por la UART. + Para evitar que por alguna eventualidad el programa pudiera quedar indefinidamente esperando que se + actualizara dicha bandera se utiliza el mismo método que en la subrutina de enviar mensajes, la variable + 'CONTADOR' se incrementa a cada comprobación que se hace de la bandera. Si se alcanza un valor límite, + en este caso, y a diferencia de la subrutina de transmisión, se aborta la recepción y se devuelve el valor + 'TIEMPO_EXCEDIDO' indicando que ha habido un error en la recepción. + En este caso si que es obligado abortar el proceso puesto que de no hacerlo se podría provocar un + funcionamiento incorrecto de la antena al ejecutar comandos erróneos. + + A cada byte recibido se le comprueba si la paridad es la correcta. Caso de no serlo se actualiza la variable + global 'ERROR_PARIDAD' que evitará que se procesen telecomandos erróneos. Un error de paridad detectado no + aborta la recepción. Lo que se hace es que una vez acabada se envía un mensaje indicando el error detectado. +*/ +unsigned char recibir_trama() +{ + /* + Variable que utilizaremos para evitar que el programa + se quede esperando si se produce una interrupción en + el puerto serie, pero no llega ningún dato + */ + unsigned char CONTADOR; + + /* Indice del byte que se está recibiendo */ + unsigned char num_byte; + + /* Ponemos a cero el indicador de error en la paridad de los datos recibidos */ + ERROR_PARIDAD = 0; + + /* Bucle de recepción */ + for (num_byte = 0; num_byte < 5; num_byte ++) + { + CONTADOR = 0; + + /* esperamos que haya un dato válido */ + while((DATO_RECIBIDO == 0) && (CONTADOR < 254)) + CONTADOR++; + + /* Si no ha llegado ningún dato salimos de la función y devolvemos una señal indicándolo */ + if (CONTADOR == 254) + return TIEMPO_EXCEDIDO; + + /* Desactivamos el "flag" */ + DATO_RECIBIDO = 0; + + /* Almacenamos el dato que ha llegado */ + BYTE[num_byte] = BUFFER_SERIE; + ACUMULADOR = BYTE[num_byte]; + + /* Determinamos la paridad del dato recibido. 'PARIDAD_ACC' indica si el dato en el acumulador + tiene paridad par. Por tanto, habrá un error de paridad cuando la paridad recibida sea la misma + que indica 'PARIDAD_ACC' */ + if (BIT_PARIDAD_REC == PARIDAD_ACC) + ERROR_PARIDAD = 1; + } + + + /* transmisión terminada */ + return TIEMPO_NO_EXCEDIDO; +} + + +/* + Subrutina que envía un mensaje de error si ha ocurrido alguna de las dos situaciones siguientes: + + - Se ha detectado un error de paridad en al recepción de algún byte del último telecomando. + + - El código de Hamming recibido no coincide con el que realmente corresponde a los cuatro bytes + del mensaje recibido. + + En cada ocasión únicamente contesta un Subarray puesto que cada telecomando lleve incluido un campo + que identifica al Subarray direccionado, incluso cuando el telecomando es global. En este último caso + la dirección del Subarray está en el segundo byte del mensaje y en el resto de los casos en el primero. + La subrutina devuelve un indicador de si ha habido error. +*/ +unsigned char contestar_si_error() +{ + BYTE_MENSAJE[2] = codigo(BYTE[0], BYTE[1], BYTE[2], BYTE[3]); + + if ((ERROR_PARIDAD == 1) || (BYTE[4] != BYTE_MENSAJE[2])) + { + BYTE_MENSAJE[0] = BYTE_MENSAJE[1] = BYTE_MENSAJE[1] = 0x00; + contestar(); + return TRUE; + } + + else + return FALSE; +} + + +/**********************************************************************************/ +/* MAPEADO DE LAS LINEAS DE CONTROL DE LOS DOS HACES CON LOS PUERTOS DEL MICRO */ +/* */ +/* Simbolización: Haz 1, bit 2 de Amplitud -> H1A2 */ +/* Haz 0, bit 0 de Fase -> H0F0 */ +/* */ +/* | BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7 | */ +/* | | | | | | | | | */ +/* PUERTO 0 -> P0 | H0A9 | | | | | | | | */ +/* | | | | | | | | | */ +/* PUERTO 1 -> P1 | H1F0 | H1F1 | H1F2 | H1F3 | H1F4 | H0F0 | H0F1 | H0F2 | */ +/* | | | | | | | | | */ +/* PUERTO 2 -> P2 | H0A0 | H0A1 | H0A2 | H0A3 | H0A4 | H0A5 | H0A6 | H0A7 | */ +/* | | | | | | | | | */ +/* PUERTO 3 -> P3 | | | | H1A8 | H1A9 | H0F3 | H0F4 | H0A8 | */ +/* | | | | | | | | | */ +/* PUERTO 4 -> P4 | H1A0 | H1A1 | H1A2 | H1A3 | H1A4 | H1A5 | H1A6 | H1A7 | */ +/* */ +/**********************************************************************************/ + + +/* + Subrutina que configura el HAZ 0. + Los valores de las líneas H9..H0 se obtienen según las siguientes expresiones: + + H9 <-- ~A0 + H8 <-- (~A3 & A2) | (A3 & A1) + H7 <-- (~A3 & A1) | (A3 & A2) + H6 <-- A3 | (A1 & ~A2) + H5 <-- A3 | A2 + H4 <-- ~A1 + H3 <-- ~A2 + H2 <-- ~A3 + H1 <-- A4 + H0 <-- ~A4 + + donde, '~', '|' y '&' representan la negación, la operación OR y la operación AND + binaria, respectivamente. +*/ +void configurar_haz0(unsigned char amplitud, unsigned char fase) +{ + unsigned char conf_P2 = 0x00; + + /* ponemos a cero los bits de los puertos que vamos a cambiar mediante una operación 'OR' */ + P0 &= 0xFE; + P1 &= 0x1F; + P3 &= 0x1F; + + /* H0 */ + conf_P2 |= (~(amplitud & 0x10))* 0x01; + + /* H1 */ + conf_P2 |= (amplitud & 0x10) * 0x02; + + /* H2 */ + conf_P2 |= (~(amplitud & 0x08))* 0x04; + + /* H3 */ + conf_P2 |= (~(amplitud & 0x04))* 0x08; + + /* H4 */ + conf_P2 |= (~(amplitud & 0x02))* 0x10; + + /* H5 */ + conf_P2 |= ((amplitud & 0x08) | (amplitud & 0x04))* 0x20; + + /* H6 */ + conf_P2 |= ((amplitud & 0x08) | ((amplitud & 0x02)&(~(amplitud & 0x04))))* 0x40; + + /* H7 */ + conf_P2 |= (((amplitud & 0x08)&(amplitud & 0x04)) | ((amplitud & 0x02)&(~(amplitud & 0x08))))* 0x80; + + /* H8 */ + P3 |= (((amplitud & 0x08)&(amplitud & 0x02)) | ((amplitud & 0x04)&(~(amplitud & 0x08))))* 0x80; + /* H9 */ + P0 |= (~(amplitud & 0x01)) * 0x01; + + /* Actualizamos el puerto P2 */ + P2 = conf_P2; + + /* Actualizamos el puerto P1 */ + P1 |= (fase & 0x07) << 5; + + /* Actualizamos el puerto P3 */ + P3 |= (fase & 0x18) << 2; +} + + +/* + Subrutina que configura el HAZ 1. +*/ +void configurar_haz1(unsigned char amplitud, unsigned char fase) +{ + unsigned char conf_P4 = 0x00; + + /* ponemos a cero los bits de los puertos que vamos a cambiar mediante una operación 'OR' */ + P1 &= 0xE0; + P3 &= 0xE7; + + /* H0 */ + conf_P4 |= (~(amplitud & 0x10))* 0x01; + + /* H1 */ + conf_P4 |= (amplitud & 0x10) * 0x02; + + /* H2 */ + conf_P4 |= (~(amplitud & 0x08))* 0x04; + + /* H3 */ + conf_P4 |= (~(amplitud & 0x04))* 0x08; + + /* H4 */ + conf_P4 |= (~(amplitud & 0x02))* 0x10; + + /* H5 */ + conf_P4 |= ((amplitud & 0x08) | (amplitud & 0x04))* 0x20; + + /* H6 */ + conf_P4 |= ((amplitud & 0x08) | ((amplitud & 0x02)&(~(amplitud & 0x04))))* 0x40; + + /* H7 */ + conf_P4 |= (((amplitud & 0x08)&(amplitud & 0x04)) | ((amplitud & 0x02)&(~(amplitud & 0x08))))* 0x80; + + /* H8 */ + P3 |= (((amplitud & 0x08)&(amplitud & 0x02)) | ((amplitud & 0x04)&(~(amplitud & 0x08))))* 0x08; + /* H9 */ + P3 |= (~(amplitud & 0x01)) * 0x10; + + /* Actualizamos el puerto P4 */ + P4 = conf_P4; + + /* Actualizamos el puerto P1 */ + P1 |= fase; +} + + +/* + Telecomando en el que se envía a un Subarray concreto para actualizar uno de los estados de programación + predefinidos. + El índice del estado consta de bits contenidos en BYTE1 + Los 10 bits de la palabra del nuevo estado están en: + 5 bits de amplitud en BYTE2[4..0] + 5 bits de fase en BYTE3[7..3] +*/ +void telec_actualizacion() +{ + unsigned char fase, amplitud, fila, columna, i, p; + + /* Obtenemos la columna correspondiente al estado que se actualiza */ + /* dentro de la matriztabla_estados */ + columna = 1 << (BYTE[1] & 0x07); + + /* Obtenemos la fila */ + fila = (BYTE[1] >> 3) * 0x0A; + + /* Obtenemos el valor de la fase */ + fase = BYTE[3]; + + /* Obtenemos el valor de la amplitud */ + amplitud = BYTE[2]; + + /* Actualizamos la tabla */ + for (i = 0x00, p = 0x01; i < 0x05; i++, p <<= 1) + { + /* Colocamos un '0' en todas las posiciones correspondientes */ + /* al estado */ + tabla_estados[fila+i ] &= 0xFF ^ columna; + tabla_estados[fila+i+5] &= 0xFF ^ columna; + + /* Según el valor de amplitud y fase colocamos un '1' en las */ + /* posiciones correspondientes */ + if (amplitud & p) tabla_estados[fila+i ] |= columna; + if (fase & p) tabla_estados[fila+i+5] |= columna; + } + + + /* Contestamos indicando que no ha habido error. + Los bytes del mensaje de respuesta son 0xFC y 0x00, + y completa la palabra código Hamming el byte 0x76. + */ + BYTE_MENSAJE[0] = 0xFF; + BYTE_MENSAJE[1] = 0x00; + BYTE_MENSAJE[2] = 0x76; + contestar(); +} + + +/* + Subrutina que actualiza con la nueva programación las líneas de control de la red desfasadora + y atenuadora. + La variable 'haz_conformado' contiene la información sobre el haz que hay que reprogramar. +*/ +void telec_conformacion(unsigned char DIRECCION_SUBARRAY) +{ + unsigned char haz_conformado, amplitud = 0x00, fase = 0x00, fila, columna, i, p; + + /* Obtenemos la columna dentro de la matriz tabla_estados */ + columna = 1 << (BYTE[1] & 0x07); + + /* Obtenemos la fila */ + fila = (BYTE[1] >> 3) * 0x0A; + + /* Obtenemos el haz que se reprograma */ + haz_conformado = BYTE[3]; + + /* Obtenemos los valores de las palabras de amplitud y fase */ + for (i = 0x00, p = 0x01; i < 0x05; i++, p <<= 1) + { + if (tabla_estados[fila+i ] & columna) amplitud |= p; + if (tabla_estados[fila+i+5] & columna) fase |= p; + } + + /* Colocamos los valores correspondientes en + las líneas de control */ + if (haz_conformado == 0x00) + { + estado_haces[0] = amplitud; + estado_haces[1] = fase; + configurar_haz0(amplitud, fase); + } + + if (haz_conformado == 0x01) + { + estado_haces[2] = amplitud; + estado_haces[3] = fase; + configurar_haz1(amplitud, fase); + } + + /* Contestar, si corresponde, que no habido error */ + if (direccion_CONFORMACION == DIRECCION_SUBARRAY) + { + BYTE_MENSAJE[0] = 0xFF; + BYTE_MENSAJE[1] = 0x00; + BYTE_MENSAJE[2] = 0x76; + contestar(); + } +} + + +/* + Subrutina que realiza la adquisición de la temperatura del módulo T/R. + La conversión analógica es de 10 bits. + El mensaje se compone de dos bytes más el código de Hamming con la siguiente distribución: + + MSB LSB + BYTE1 : 0 0 0 0 0 0 T9 T8 + BYTE2 : T7 T6 T5 T4 T3 T2 T1 T0 + BYTE3 : H7 H6 H5 H4 H3 H2 H1 H0 + + donde T9..T0 son los 10 bits de la lectura de la temperatura y + H7..H0 son los 8 bits de la redundancia de Hamming. +*/ +void telec_temperatura() +{ + unsigned char CONTADOR; + + /* Reseteamos el registro de control del conversor A/D */ + ADCON = 0x00; + + /* Activar la conversión A/D */ + ADCON = ADCON | AD_INI; + + /* Esperamos a que termine el muestreo. + Con la variable contador establecemos un tiempo límite de espera */ + CONTADOR = 0; + while (((ADCON & AD_FIN) == 0) || (CONTADOR == 250)) + CONTADOR++; + + /* Si se ha superado el tiempo de espera enviamos mensaje de error */ + if (CONTADOR == 250) + { + BYTE_MENSAJE[0] = BYTE_MENSAJE[1] = BYTE_MENSAJE[2] = 0x00; + contestar(); + return; + } + + /* Realizamos la lectura del conversor */ + BYTE_MENSAJE[0] = (ADCON & 0xC0) >> 6; + BYTE_MENSAJE[1] = ADAT; + + /* Calculamos la palabra código */ + BYTE_MENSAJE[2] = codigo(BYTE_MENSAJE[0], BYTE_MENSAJE[1], 0x00, 0x00); + + /* Enviamos respuesta */ + contestar(); +} + + +/* + Subrutina que implementa dos funciones: + + - Envía un mensaje en respuesta a un telecomando de petición de estado con la + programación actual del haz solicitado, información que está contenida en la + variable 'tabla_estados' en la forma siguiente: + * tabla_haces_prog[2*haz] <- Amplitud (5bits) + * tabla_haces_prog[2*haz+1] <- Fase (5bits) + + El mensaje se compone de dos bytes más el código de Hamming con la siguiente distribución: + + MSB LSB + BYTE1 : 0 0 0 A4 A3 A2 A1 A0 + BYTE2 : 0 0 0 F4 F3 F2 F1 F0 + BYTE3 : H7 H6 H5 H4 H3 H2 H1 H0 + + - Provoca un RESET del microcontrolador cuando el telecomando de petición de temperatura + tiene el segundo byte igual a 0xFF. + Este RESET intencionado se utiliza cuando el módulo que distribuye los mensajes a los distintos + subarrays detecta que hay un error en el bus de telemedidas que persiste cuando se dirige a un + subarray en particular, o bien hay un subarray que no contesta. Estas anomalías posiblemente son + debidas a que un subarray por cualquier motivo desconocido ha sufrido un error en la posición de + memoria donde almacena la dirección que lo identifica, de forma que hay dos subarrays con la misma + dirección o bien un subarray tiene una dirección no válida (superior a 51, dirección máxima). +*/ +void telec_pet_Estado() +{ + unsigned char haz; + + /* Comprobamos si se trata de un comando de reset */ + /* En caso afirmativo entramos en un bucle vacío */ + /* para que se provoque un reset */ + if (BYTE[1] == 0xFF) + { + /* + Deshabilitamos las interrupciones de forma que el TIMER0 no + pueda activar la rutina 'watchdog()' y se produzca un RESET. + */ + IE = 0x00; + + /* Bucle infinito */ + while(1); + } + + + /* Si el telecomando es efectivamente de petición */ + /* de estado obtenemos el haz direccionado */ + haz = BYTE[2]; + + /* Construimos los bytes de respuesta */ + BYTE_MENSAJE[0] = estado_haces[2*haz]; + BYTE_MENSAJE[1] = estado_haces[2*haz+1]; + + BYTE_MENSAJE[2] = codigo(BYTE_MENSAJE[0], BYTE_MENSAJE[1], 0x00, 0x00); + + /* Enviamos mensaje de respuesta */ + contestar(); +} + + diff --git a/device/include/Makefile.in b/device/include/Makefile.in new file mode 100644 index 00000000..c98bd125 --- /dev/null +++ b/device/include/Makefile.in @@ -0,0 +1,88 @@ +# +# +# + +VERSION = @VERSION@ +VERSIONHI = @VERSIONHI@ +VERSIONLO = @VERSIONLO@ +VERSIONP = @VERSIONP@ + +SHELL = /bin/sh +CPP = @CPP@ +INSTALL = @INSTALL@ +CP = @CP@ + +PRJDIR = .. + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +datadir = @datadir@ +includedir = @includedir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = @infodir@ +srcdir = @srcdir@ + +CPPFLAGS = @CPPFLAGS@ -I$(PRJDIR) + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: + + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(CP) *.h $(datadir)/sdcc51inc/ + + +# Deleting all the installed files +# -------------------------------- +uninstall: + for hdr in *.h; do rm -f $(datadir)/$$hdr; done + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + [ -d $(datadir)/sdcc51inc ] || mkdir -p $(datadir)/sdcc51inc + + +# Creating dependencies +# --------------------- +dep: #Makefile.dep + +#Makefile.dep: +# $(CPP) $(CPPFLAGS) $(M_OR_MM) *.c >main.dep + +#include Makefile.dep +include clean.mk + +# My rules +# -------- + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \ + freshconf;\ + fi + +# End of main_in.mk/main.mk + diff --git a/device/include/assert.h b/device/include/assert.h new file mode 100644 index 00000000..eed3ff40 --- /dev/null +++ b/device/include/assert.h @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------- + assert.h - header file for assert ANSI routine + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCC_ASSERT_H +#define SDCC_ASSERT_H + +void _assert(char *, const char *, unsigned int); +#define assert(x) ((x) == 0 ? _assert(#x, __FILE__, __LINE__):(void)0) + + +#endif diff --git a/device/include/at89S8252.h b/device/include/at89S8252.h new file mode 100644 index 00000000..e3bd458e --- /dev/null +++ b/device/include/at89S8252.h @@ -0,0 +1,341 @@ +/*------------------------------------------------------------------------- + Register Declarations for ATMEL 89S8252 and 89LS8252 Processors + + Written By - Dipl.-Ing. (FH) Michael Schmitt + mschmitt@mainz-online.de + michael.schmitt@t-online.de + + Bug-Fix Jun 29 1999 + + Additional definitions Nov 23 1999 + by Bernd Krueger-Knauber + + based on reg51.h by Sandeep Dutta sandeep.dutta@usa.net + KEIL C compatible definitions are included + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef AT89S8252_H +#define AT89S8252_H + +/* BYTE addressable registers */ +sfr at 0x80 P0 ; +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x82 DP0L ; /* as called by Atmel */ +sfr at 0x83 DPH ; +sfr at 0x83 DP0H ; /* as called by Atmel */ +sfr at 0x84 DP1L ; /* at89S8252 specific register */ +sfr at 0x85 DP1H ; /* at89S8252 specific register */ +sfr at 0x86 SPDR ; /* at89S8252 specific register */ +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0x90 P1 ; +sfr at 0x96 WMCON ; /* at89S8252 specific register */ +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; +sfr at 0xA0 P2 ; +sfr at 0xA8 IE ; +sfr at 0xAA SPSR ; /* at89S8252 specific register */ +sfr at 0xB0 P3 ; +sfr at 0xB8 IP ; +sfr at 0xC8 T2CON ; +sfr at 0xC9 T2MOD ; +sfr at 0xCA RCAP2L ; +sfr at 0xCB RCAP2H ; +sfr at 0xCC TL2 ; +sfr at 0xCD TH2 ; +sfr at 0xD0 PSW ; +sfr at 0xD5 SPCR ; /* at89S8252 specific register */ +sfr at 0xE0 ACC ; +sfr at 0xE0 A ; +sfr at 0xF0 B ; + + +/* BIT addressable registers */ +/* P0 */ +sbit at 0x80 P0_0 ; +sbit at 0x81 P0_1 ; +sbit at 0x82 P0_2 ; +sbit at 0x83 P0_3 ; +sbit at 0x84 P0_4 ; +sbit at 0x85 P0_5 ; +sbit at 0x86 P0_6 ; +sbit at 0x87 P0_7 ; + +/* TCON */ +sbit at 0x88 IT0 ; +sbit at 0x89 IE0 ; +sbit at 0x8A IT1 ; +sbit at 0x8B IE1 ; +sbit at 0x8C TR0 ; +sbit at 0x8D TF0 ; +sbit at 0x8E TR1 ; +sbit at 0x8F TF1 ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +sbit at 0x90 T2 ; +sbit at 0x91 T2EX ; + +/* P1 SPI portpins */ +sbit at 0x94 SS; /* SPI: SS - Slave port select input */ +sbit at 0x95 MOSI; /* SPI: MOSI - Master data output, slave data input */ +sbit at 0x96 MISO; /* SPI: MISO - Master data input, slave data output */ +sbit at 0x97 SCK; /* SPI: SCK - Master clock output, slave clock input */ + + +/* SCON */ +sbit at 0x98 RI ; +sbit at 0x99 TI ; +sbit at 0x9A RB8 ; +sbit at 0x9B TB8 ; +sbit at 0x9C REN ; +sbit at 0x9D SM2 ; +sbit at 0x9E SM1 ; +sbit at 0x9F SM0 ; + +/* P2 */ +sbit at 0xA0 P2_0 ; +sbit at 0xA1 P2_1 ; +sbit at 0xA2 P2_2 ; +sbit at 0xA3 P2_3 ; +sbit at 0xA4 P2_4 ; +sbit at 0xA5 P2_5 ; +sbit at 0xA6 P2_6 ; +sbit at 0xA7 P2_7 ; + +/* IE */ +sbit at 0xA8 EX0 ; +sbit at 0xA9 ET0 ; +sbit at 0xAA EX1 ; +sbit at 0xAB ET1 ; +sbit at 0xAC ES ; +sbit at 0xAD ET2 ; +sbit at 0xAF EA ; + +/* P3 */ +sbit at 0xB0 P3_0 ; +sbit at 0xB1 P3_1 ; +sbit at 0xB2 P3_2 ; +sbit at 0xB3 P3_3 ; +sbit at 0xB4 P3_4 ; +sbit at 0xB5 P3_5 ; +sbit at 0xB6 P3_6 ; +sbit at 0xB7 P3_7 ; + +sbit at 0xB0 RXD ; +sbit at 0xB1 TXD ; +sbit at 0xB2 INT0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB4 T0 ; +sbit at 0xB5 T1 ; +sbit at 0xB6 WR ; +sbit at 0xB7 RD ; + +/* IP */ +sbit at 0xB8 PX0 ; +sbit at 0xB9 PT0 ; +sbit at 0xBA PX1 ; +sbit at 0xBB PT1 ; +sbit at 0xBC PS ; +sbit at 0xBD PT2 ; + +/* T2CON */ +sbit at 0xC8 T2CON_0 ; +sbit at 0xC9 T2CON_1 ; +sbit at 0xCA T2CON_2 ; +sbit at 0xCB T2CON_3 ; +sbit at 0xCC T2CON_4 ; +sbit at 0xCD T2CON_5 ; +sbit at 0xCE T2CON_6 ; +sbit at 0xCF T2CON_7 ; + +sbit at 0xC8 CP_RL2 ; +sbit at 0xC9 C_T2 ; +sbit at 0xCA TR2 ; +sbit at 0xCB EXEN2 ; +sbit at 0xCC TCLK ; +sbit at 0xCD RCLK ; +sbit at 0xCE EXF2 ; +sbit at 0xCF TF2 ; + +/* PSW */ +sbit at 0xD0 P ; +sbit at 0xD1 FL ; +sbit at 0xD2 OV ; +sbit at 0xD3 RS0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD5 F0 ; +sbit at 0xD6 AC ; +sbit at 0xD7 CY ; + +/* B */ +sbit at 0xF0 BREG_F0 ; +sbit at 0xF1 BREG_F1 ; +sbit at 0xF2 BREG_F2 ; +sbit at 0xF3 BREG_F3 ; +sbit at 0xF4 BREG_F4 ; +sbit at 0xF5 BREG_F5 ; +sbit at 0xF6 BREG_F6 ; +sbit at 0xF7 BREG_F7 ; + + +/* BIT definitions for bits that are not directly accessible */ +/* PCON bits */ +#define IDL 0x01 +#define PD 0x02 +#define GF0 0x04 +#define GF1 0x08 +#define SMOD 0x80 + +#define IDL_ 0x01 +#define PD_ 0x02 +#define GF0_ 0x04 +#define GF1_ 0x08 +#define SMOD_ 0x80 + +/* TMOD bits */ +#define M0_0 0x01 +#define M1_0 0x02 +#define C_T0 0x04 +#define GATE0 0x08 +#define M0_1 0x10 +#define M1_1 0x20 +#define C_T1 0x40 +#define GATE1 0x80 + +#define M0_0_ 0x01 +#define M1_0_ 0x02 +#define C_T0_ 0x04 +#define GATE0_ 0x08 +#define M0_1_ 0x10 +#define M1_1_ 0x20 +#define C_T1_ 0x40 +#define GATE1_ 0x80 + +#define T0_M0 0x01 +#define T0_M1 0x02 +#define T0_CT 0x04 +#define T0_GATE 0x08 +#define T1_M0 0x10 +#define T1_M1 0x20 +#define T1_CT 0x40 +#define T1_GATE 0x80 + +#define T0_M0_ 0x01 +#define T0_M1_ 0x02 +#define T0_CT_ 0x04 +#define T0_GATE_ 0x08 +#define T1_M0_ 0x10 +#define T1_M1_ 0x20 +#define T1_CT_ 0x40 +#define T1_GATE_ 0x80 + +#define T0_MASK 0x0F +#define T1_MASK 0xF0 + +#define T0_MASK_ 0x0F +#define T1_MASK_ 0xF0 + +/* T2MOD bits */ +#define DCEN 0x01 +#define T2OE 0x02 + +#define DCEN_ 0x01 +#define T2OE_ 0x02 + +/* WMCON bits */ +#define WMCON_WDTEN 0x01 +#define WMCON_WDTRST 0x02 +#define WMCON_DPS 0x04 +#define WMCON_EEMEN 0x08 +#define WMCON_EEMWE 0x10 +#define WMCON_PS0 0x20 +#define WMCON_PS1 0x40 +#define WMCON_PS2 0x80 + +/* SPCR-SPI bits */ +#define SPCR_SPR0 0x01 +#define SPCR_SPR1 0x02 +#define SPCR_CPHA 0x04 +#define SPCR_CPOL 0x08 +#define SPCR_MSTR 0x10 +#define SPCR_DORD 0x20 +#define SPCR_SPE 0x40 +#define SPCR_SPIE 0x80 + +/* SPSR-SPI bits */ +#define SPSR_WCOL 0x40 +#define SPSR_SPIF 0x80 + +/* SPDR-SPI bits */ +#define SPDR_SPD0 0x10 +#define SPDR_SPD1 0x20 +#define SPDR_SPD2 0x40 +#define SPDR_SPD3 0x80 +#define SPDR_SPD4 0x10 +#define SPDR_SPD5 0x20 +#define SPDR_SPD6 0x40 +#define SPDR_SPD7 0x80 + +/* Interrupt numbers: address = (number * 8) + 3 */ +#define IE0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define EX0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define TF0_VECTOR 1 /* 0x0b timer 0 */ +#define IE1_VECTOR 2 /* 0x13 external interrupt 1 */ +#define EX1_VECTOR 2 /* 0x13 external interrupt 1 */ +#define TF1_VECTOR 3 /* 0x1b timer 1 */ +#define SI0_VECTOR 4 /* 0x23 serial port 0 */ +#define TF2_VECTOR 5 /* 0x2B timer 2 */ +#define EX2_VECTOR 5 /* 0x2B external interrupt 2 */ + + +/* This is one of the addons comming from Bernd Krueger-Knauber */ + +/* ALE (0x8E) Bit Values */ +sfr at 0x8E ALE; /* at89S8252 specific register */ + +/* Macro to enable and disable the toggling of the ALE-pin (EMV) */ + +/* Explanation : Orignal Intel 8051 Cores (Atmel has to use the */ +/* Intel Core) have a festure that ALE is only active during */ +/* MOVX or MOVC instruction. Otherwise the ALE-Pin is weakly */ +/* pulled high. This can be used to force some external devices */ +/* into stanby mode and reduced EMI noise */ + +#define ALE_OFF ALE = ALE | 0x01 +#define ALE_ON ALE = ALE & 0xFE + +#endif + diff --git a/device/include/at89c55.h b/device/include/at89c55.h new file mode 100644 index 00000000..50da56f7 --- /dev/null +++ b/device/include/at89c55.h @@ -0,0 +1,259 @@ + +/*------------------------------------------------------------------------- + Register Declarations for ATMEL 89x55 Processors + + Written By - Bernd Bartmann + Bernd.Bartmann@picard.isdn.cs.tu-berlin.de (1999) + based on reg51.h by Sandeep Dutta sandeep.dutta@usa.net + KEIL C compatible definitions are included + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef AT89x55_H +#define AT89x55_H + +/* BYTE addressable registers */ +sfr at 0x80 P0 ; +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0x90 P1 ; +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; +sfr at 0xA0 P2 ; +sfr at 0xA8 IE ; +sfr at 0xB0 P3 ; +sfr at 0xB8 IP ; +sfr at 0xC8 T2CON ; +sfr at 0xC9 T2MOD ; +sfr at 0xCA RCAP2L ; +sfr at 0xCB RCAP2H ; +sfr at 0xCC TL2 ; +sfr at 0xCD TH2 ; +sfr at 0xD0 PSW ; +sfr at 0xE0 ACC ; +sfr at 0xE0 A ; +sfr at 0xF0 B ; + + +/* BIT addressable registers */ +/* P0 */ +sbit at 0x80 P0_0 ; +sbit at 0x81 P0_1 ; +sbit at 0x82 P0_2 ; +sbit at 0x83 P0_3 ; +sbit at 0x84 P0_4 ; +sbit at 0x85 P0_5 ; +sbit at 0x86 P0_6 ; +sbit at 0x87 P0_7 ; + +/* TCON */ +sbit at 0x88 IT0 ; +sbit at 0x89 IE0 ; +sbit at 0x8A IT1 ; +sbit at 0x8B IE1 ; +sbit at 0x8C TR0 ; +sbit at 0x8D TF0 ; +sbit at 0x8E TR1 ; +sbit at 0x8F TF1 ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +sbit at 0x90 T2 ; +sbit at 0x91 T2EX ; + +/* SCON */ +sbit at 0x98 RI ; +sbit at 0x99 TI ; +sbit at 0x9A RB8 ; +sbit at 0x9B TB8 ; +sbit at 0x9C REN ; +sbit at 0x9D SM2 ; +sbit at 0x9E SM1 ; +sbit at 0x9F SM0 ; + +/* P2 */ +sbit at 0xA0 P2_0 ; +sbit at 0xA1 P2_1 ; +sbit at 0xA2 P2_2 ; +sbit at 0xA3 P2_3 ; +sbit at 0xA4 P2_4 ; +sbit at 0xA5 P2_5 ; +sbit at 0xA6 P2_6 ; +sbit at 0xA7 P2_7 ; + +/* IE */ +sbit at 0xA8 EX0 ; +sbit at 0xA9 ET0 ; +sbit at 0xAA EX1 ; +sbit at 0xAB ET1 ; +sbit at 0xAC ES ; +sbit at 0xAD ET2 ; +sbit at 0xAF EA ; + +/* P3 */ +sbit at 0xB0 P3_0 ; +sbit at 0xB1 P3_1 ; +sbit at 0xB2 P3_2 ; +sbit at 0xB3 P3_3 ; +sbit at 0xB4 P3_4 ; +sbit at 0xB5 P3_5 ; +sbit at 0xB6 P3_6 ; +sbit at 0xB7 P3_7 ; + +sbit at 0xB0 RXD ; +sbit at 0xB1 TXD ; +sbit at 0xB2 INT0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB4 T0 ; +sbit at 0xB5 T1 ; +sbit at 0xB6 WR ; +sbit at 0xB7 RD ; + +/* IP */ +sbit at 0xB8 PX0 ; +sbit at 0xB9 PT0 ; +sbit at 0xBA PX1 ; +sbit at 0xBB PT1 ; +sbit at 0xBC PS ; +sbit at 0xBD PT2 ; + +/* T2CON */ +sbit at 0xC8 T2CON_0 ; +sbit at 0xC9 T2CON_1 ; +sbit at 0xCA T2CON_2 ; +sbit at 0xCB T2CON_3 ; +sbit at 0xCC T2CON_4 ; +sbit at 0xCD T2CON_5 ; +sbit at 0xCE T2CON_6 ; +sbit at 0xCF T2CON_7 ; + +sbit at 0xC8 CP_RL2 ; +sbit at 0xC9 C_T2 ; +sbit at 0xCA TR2 ; +sbit at 0xCB EXEN2 ; +sbit at 0xCC TCLK ; +sbit at 0xCD RCLK ; +sbit at 0xCE EXF2 ; +sbit at 0xCF TF2 ; + +/* PSW */ +sbit at 0xD0 P ; +sbit at 0xD1 FL ; +sbit at 0xD2 OV ; +sbit at 0xD3 RS0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD5 F0 ; +sbit at 0xD6 AC ; +sbit at 0xD7 CY ; + + +/* BIT definitions for bits that are not directly accessible */ +/* PCON bits */ +#define IDL 0x01 +#define PD 0x02 +#define GF0 0x04 +#define GF1 0x08 +#define SMOD 0x80 + +#define IDL_ 0x01 +#define PD_ 0x02 +#define GF0_ 0x04 +#define GF1_ 0x08 +#define SMOD_ 0x80 + +/* TMOD bits */ +#define M0_0 0x01 +#define M1_0 0x02 +#define C_T0 0x04 +#define GATE0 0x08 +#define M0_1 0x10 +#define M1_1 0x20 +#define C_T1 0x40 +#define GATE1 0x80 + +#define M0_0_ 0x01 +#define M1_0_ 0x02 +#define C_T0_ 0x04 +#define GATE0_ 0x08 +#define M0_1_ 0x10 +#define M1_1_ 0x20 +#define C_T1_ 0x40 +#define GATE1_ 0x80 + +#define T0_M0 0x01 +#define T0_M1 0x02 +#define T0_CT 0x04 +#define T0_GATE 0x08 +#define T1_M0 0x10 +#define T1_M1 0x20 +#define T1_CT 0x40 +#define T1_GATE 0x80 + +#define T0_M0_ 0x01 +#define T0_M1_ 0x02 +#define T0_CT_ 0x04 +#define T0_GATE_ 0x08 +#define T1_M0_ 0x10 +#define T1_M1_ 0x20 +#define T1_CT_ 0x40 +#define T1_GATE_ 0x80 + +#define T0_MASK 0x0F +#define T1_MASK 0xF0 + +#define T0_MASK_ 0x0F +#define T1_MASK_ 0xF0 + +/* T2MOD bits */ +#define DCEN 0x01 +#define T2OE 0x02 + +#define DCEN_ 0x01 +#define T2OE_ 0x02 + + +/* Interrupt numbers: address = (number * 8) + 3 */ +#define IE0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define TF0_VECTOR 1 /* 0x0b timer 0 */ +#define IE1_VECTOR 2 /* 0x13 external interrupt 1 */ +#define TF1_VECTOR 3 /* 0x1b timer 1 */ +#define SI0_VECTOR 4 /* 0x23 serial port 0 */ +#define TF2_VECTOR 5 /* 0x2B timer 2 */ +#define EX2_VECTOR 5 /* 0x2B external interrupt 2 */ + +#endif + + diff --git a/device/include/at89x1051.h b/device/include/at89x1051.h new file mode 100644 index 00000000..88ade8eb --- /dev/null +++ b/device/include/at89x1051.h @@ -0,0 +1,183 @@ +/*------------------------------------------------------------------------- + Register Declarations for ATMEL 89c1051 Processors + + Written By - Bernd Bartmann + Bernd.Bartmann@picard.isdn.cs.tu-berlin.de (1999) + based on reg51.h by Sandeep Dutta sandeep.dutta@usa.net + KEIL C compatible definitions are included + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef AT891051_H +#define AT891051_H + +/* BYTE addressable registers */ +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8C TH0 ; +sfr at 0x90 P1 ; +sfr at 0xA8 IE ; +sfr at 0xB0 P3 ; +sfr at 0xB8 IP ; +sfr at 0xD0 PSW ; +sfr at 0xE0 ACC ; +sfr at 0xE0 A ; +sfr at 0xF0 B ; + + +/* BIT addressable registers */ +/* TCON */ +sbit at 0x88 IT0 ; +sbit at 0x89 IE0 ; +sbit at 0x8A IT1 ; +sbit at 0x8B IE1 ; +sbit at 0x8C TR0 ; +sbit at 0x8D TF0 ; +sbit at 0x8E TR1 ; +sbit at 0x8F TF1 ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +sbit at 0x90 AIN0 ; +sbit at 0x91 AIN1 ; + +/* IE */ +sbit at 0xA8 EX0 ; +sbit at 0xA9 ET0 ; +sbit at 0xAA EX1 ; +sbit at 0xAF EA ; + +/* P3 */ +sbit at 0xB0 P3_0 ; +sbit at 0xB1 P3_1 ; +sbit at 0xB2 P3_2 ; +sbit at 0xB3 P3_3 ; +sbit at 0xB4 P3_4 ; +sbit at 0xB5 P3_5 ; +sbit at 0xB7 P3_7 ; + +sbit at 0xB2 INT0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB4 T0 ; +sbit at 0xB6 AOUT ; + +/* IP */ +sbit at 0xB8 PX0 ; +sbit at 0xB9 PT0 ; +sbit at 0xBA PX1 ; +sbit at 0xBB PT1 ; +sbit at 0xBC PS ; + +/* PSW */ +sbit at 0xD0 P ; +sbit at 0xD1 FL ; +sbit at 0xD2 OV ; +sbit at 0xD3 RS0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD5 F0 ; +sbit at 0xD6 AC ; +sbit at 0xD7 CY ; + + +/* BIT definitions for bits that are not directly accessible */ +/* PCON bits */ +#define IDL 0x01 +#define STOP 0x02 +#define EWT 0x04 +#define EPFW 0x08 +#define WTR 0x10 +#define PFW 0x20 +#define POR 0x40 +#define SMOD 0x80 + +#define IDL_ 0x01 +#define STOP_ 0x02 +#define EWT_ 0x04 +#define EPFW_ 0x08 +#define WTR_ 0x10 +#define PFW_ 0x20 +#define POR_ 0x40 +#define SMOD_ 0x80 + +/* TMOD bits */ +#define M0_0 0x01 +#define M1_0 0x02 +#define C_T0 0x04 +#define GATE0 0x08 +#define M0_1 0x10 +#define M1_1 0x20 +#define C_T1 0x40 +#define GATE1 0x80 + +#define M0_0_ 0x01 +#define M1_0_ 0x02 +#define C_T0_ 0x04 +#define GATE0_ 0x08 +#define M0_1_ 0x10 +#define M1_1_ 0x20 +#define C_T1_ 0x40 +#define GATE1_ 0x80 + +#define T0_M0 0x01 +#define T0_M1 0x02 +#define T0_CT 0x04 +#define T0_GATE 0x08 +#define T1_M0 0x10 +#define T1_M1 0x20 +#define T1_CT 0x40 +#define T1_GATE 0x80 + +#define T0_M0_ 0x01 +#define T0_M1_ 0x02 +#define T0_CT_ 0x04 +#define T0_GATE_ 0x08 +#define T1_M0_ 0x10 +#define T1_M1_ 0x20 +#define T1_CT_ 0x40 +#define T1_GATE_ 0x80 + +#define T0_MASK 0x0F +#define T1_MASK 0xF0 + +#define T0_MASK_ 0x0F +#define T1_MASK_ 0xF0 + + +/* Interrupt numbers: address = (number * 8) + 3 */ +#define IE0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define TF0_VECTOR 1 /* 0x0b timer 0 */ +#define IE1_VECTOR 2 /* 0x13 external interrupt 1 */ + +#endif + + diff --git a/device/include/at89x2051.h b/device/include/at89x2051.h new file mode 100644 index 00000000..0d1f6318 --- /dev/null +++ b/device/include/at89x2051.h @@ -0,0 +1,206 @@ + +/*------------------------------------------------------------------------- + Register Declarations for ATMEL 89c2051 Processors + + Written By - Bernd Bartmann + Bernd.Bartmann@picard.isdn.cs.tu-berlin.de (1999) + based on reg51.h by Sandeep Dutta sandeep.dutta@usa.net + KEIL C compatible definitions are included + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef AT892051_H +#define AT892051_H + +/* BYTE addressable registers */ +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0x90 P1 ; +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; +sfr at 0xA8 IE ; +sfr at 0xB0 P3 ; +sfr at 0xB8 IP ; +sfr at 0xD0 PSW ; +sfr at 0xE0 ACC ; +sfr at 0xE0 A ; +sfr at 0xF0 B ; + + +/* BIT addressable registers */ +/* TCON */ +sbit at 0x88 IT0 ; +sbit at 0x89 IE0 ; +sbit at 0x8A IT1 ; +sbit at 0x8B IE1 ; +sbit at 0x8C TR0 ; +sbit at 0x8D TF0 ; +sbit at 0x8E TR1 ; +sbit at 0x8F TF1 ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +sbit at 0x90 AIN0 ; +sbit at 0x91 AIN1 ; + +/* SCON */ +sbit at 0x98 RI ; +sbit at 0x99 TI ; +sbit at 0x9A RB8 ; +sbit at 0x9B TB8 ; +sbit at 0x9C REN ; +sbit at 0x9D SM2 ; +sbit at 0x9E SM1 ; +sbit at 0x9F SM0 ; + +/* IE */ +sbit at 0xA8 EX0 ; +sbit at 0xA9 ET0 ; +sbit at 0xAA EX1 ; +sbit at 0xAB ET1 ; +sbit at 0xAC ES ; +sbit at 0xAD ET2 ; +sbit at 0xAF EA ; + +/* P3 */ +sbit at 0xB0 P3_0 ; +sbit at 0xB1 P3_1 ; +sbit at 0xB2 P3_2 ; +sbit at 0xB3 P3_3 ; +sbit at 0xB4 P3_4 ; +sbit at 0xB5 P3_5 ; +sbit at 0xB7 P3_7 ; + +sbit at 0xB0 RXD ; +sbit at 0xB1 TXD ; +sbit at 0xB2 INT0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB4 T0 ; +sbit at 0xB5 T1 ; +sbit at 0xB6 AOUT ; + +/* IP */ +sbit at 0xB8 PX0 ; +sbit at 0xB9 PT0 ; +sbit at 0xBA PX1 ; +sbit at 0xBB PT1 ; +sbit at 0xBC PS ; + +/* PSW */ +sbit at 0xD0 P ; +sbit at 0xD1 FL ; +sbit at 0xD2 OV ; +sbit at 0xD3 RS0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD5 F0 ; +sbit at 0xD6 AC ; +sbit at 0xD7 CY ; + + +/* BIT definitions for bits that are not directly accessible */ +/* PCON bits */ +#define IDL 0x01 +#define STOP 0x02 +#define EWT 0x04 +#define EPFW 0x08 +#define WTR 0x10 +#define PFW 0x20 +#define POR 0x40 +#define SMOD 0x80 + +#define IDL_ 0x01 +#define STOP_ 0x02 +#define EWT_ 0x04 +#define EPFW_ 0x08 +#define WTR_ 0x10 +#define PFW_ 0x20 +#define POR_ 0x40 +#define SMOD_ 0x80 + +/* TMOD bits */ +#define M0_0 0x01 +#define M1_0 0x02 +#define C_T0 0x04 +#define GATE0 0x08 +#define M0_1 0x10 +#define M1_1 0x20 +#define C_T1 0x40 +#define GATE1 0x80 + +#define M0_0_ 0x01 +#define M1_0_ 0x02 +#define C_T0_ 0x04 +#define GATE0_ 0x08 +#define M0_1_ 0x10 +#define M1_1_ 0x20 +#define C_T1_ 0x40 +#define GATE1_ 0x80 + +#define T0_M0 0x01 +#define T0_M1 0x02 +#define T0_CT 0x04 +#define T0_GATE 0x08 +#define T1_M0 0x10 +#define T1_M1 0x20 +#define T1_CT 0x40 +#define T1_GATE 0x80 + +#define T0_M0_ 0x01 +#define T0_M1_ 0x02 +#define T0_CT_ 0x04 +#define T0_GATE_ 0x08 +#define T1_M0_ 0x10 +#define T1_M1_ 0x20 +#define T1_CT_ 0x40 +#define T1_GATE_ 0x80 + +#define T0_MASK 0x0F +#define T1_MASK 0xF0 + +#define T0_MASK_ 0x0F +#define T1_MASK_ 0xF0 + + +/* Interrupt numbers: address = (number * 8) + 3 */ +#define IE0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define TF0_VECTOR 1 /* 0x0b timer 0 */ +#define IE1_VECTOR 2 /* 0x13 external interrupt 1 */ +#define TF1_VECTOR 3 /* 0x1b timer 1 */ +#define SI0_VECTOR 4 /* 0x23 serial port 0 */ + +#endif + + diff --git a/device/include/at89x51.h b/device/include/at89x51.h new file mode 100644 index 00000000..5c763685 --- /dev/null +++ b/device/include/at89x51.h @@ -0,0 +1,218 @@ +/*------------------------------------------------------------------------- + Register Declarations for ATMEL 89x51 Processors + + Written By - Bernd Bartmann + Bernd.Bartmann@picard.isdn.cs.tu-berlin.de (1999) + based on reg51.h by Sandeep Dutta sandeep.dutta@usa.net + KEIL C compatible definitions are included + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef AT89x51_H +#define AT89x51_H + +/* BYTE addressable registers */ +sfr at 0x80 P0 ; +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0x90 P1 ; +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; +sfr at 0xA0 P2 ; +sfr at 0xA8 IE ; +sfr at 0xB0 P3 ; +sfr at 0xB8 IP ; +sfr at 0xD0 PSW ; +sfr at 0xE0 ACC ; +sfr at 0xE0 A ; +sfr at 0xF0 B ; + + +/* BIT addressable registers */ +/* P0 */ +sbit at 0x80 P0_0 ; +sbit at 0x81 P0_1 ; +sbit at 0x82 P0_2 ; +sbit at 0x83 P0_3 ; +sbit at 0x84 P0_4 ; +sbit at 0x85 P0_5 ; +sbit at 0x86 P0_6 ; +sbit at 0x87 P0_7 ; + +/* TCON */ +sbit at 0x88 IT0 ; +sbit at 0x89 IE0 ; +sbit at 0x8A IT1 ; +sbit at 0x8B IE1 ; +sbit at 0x8C TR0 ; +sbit at 0x8D TF0 ; +sbit at 0x8E TR1 ; +sbit at 0x8F TF1 ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +/* SCON */ +sbit at 0x98 RI ; +sbit at 0x99 TI ; +sbit at 0x9A RB8 ; +sbit at 0x9B TB8 ; +sbit at 0x9C REN ; +sbit at 0x9D SM2 ; +sbit at 0x9E SM1 ; +sbit at 0x9F SM0 ; + +/* P2 */ +sbit at 0xA0 P2_0 ; +sbit at 0xA1 P2_1 ; +sbit at 0xA2 P2_2 ; +sbit at 0xA3 P2_3 ; +sbit at 0xA4 P2_4 ; +sbit at 0xA5 P2_5 ; +sbit at 0xA6 P2_6 ; +sbit at 0xA7 P2_7 ; + +/* IE */ +sbit at 0xA8 EX0 ; +sbit at 0xA9 ET0 ; +sbit at 0xAA EX1 ; +sbit at 0xAB ET1 ; +sbit at 0xAC ES ; +sbit at 0xAF EA ; + +/* P3 */ +sbit at 0xB0 P3_0 ; +sbit at 0xB1 P3_1 ; +sbit at 0xB2 P3_2 ; +sbit at 0xB3 P3_3 ; +sbit at 0xB4 P3_4 ; +sbit at 0xB5 P3_5 ; +sbit at 0xB6 P3_6 ; +sbit at 0xB7 P3_7 ; + +sbit at 0xB0 RXD ; +sbit at 0xB1 TXD ; +sbit at 0xB2 INT0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB4 T0 ; +sbit at 0xB5 T1 ; +sbit at 0xB6 WR ; +sbit at 0xB7 RD ; + +/* IP */ +sbit at 0xB8 PX0 ; +sbit at 0xB9 PT0 ; +sbit at 0xBA PX1 ; +sbit at 0xBB PT1 ; +sbit at 0xBC PS ; + +/* PSW */ +sbit at 0xD0 P ; +sbit at 0xD1 FL ; +sbit at 0xD2 OV ; +sbit at 0xD3 RS0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD5 F0 ; +sbit at 0xD6 AC ; +sbit at 0xD7 CY ; + + +/* BIT definitions for bits that are not directly accessible */ +/* PCON bits */ +#define IDL 0x01 +#define PD 0x02 +#define GF0 0x04 +#define GF1 0x08 +#define SMOD 0x80 + +#define IDL_ 0x01 +#define PD_ 0x02 +#define GF0_ 0x04 +#define GF1_ 0x08 +#define SMOD_ 0x80 + +/* TMOD bits */ +#define M0_0 0x01 +#define M1_0 0x02 +#define C_T0 0x04 +#define GATE0 0x08 +#define M0_1 0x10 +#define M1_1 0x20 +#define C_T1 0x40 +#define GATE1 0x80 + +#define M0_0_ 0x01 +#define M1_0_ 0x02 +#define C_T0_ 0x04 +#define GATE0_ 0x08 +#define M0_1_ 0x10 +#define M1_1_ 0x20 +#define C_T1_ 0x40 +#define GATE1_ 0x80 + +#define T0_M0 0x01 +#define T0_M1 0x02 +#define T0_CT 0x04 +#define T0_GATE 0x08 +#define T1_M0 0x10 +#define T1_M1 0x20 +#define T1_CT 0x40 +#define T1_GATE 0x80 + +#define T0_M0_ 0x01 +#define T0_M1_ 0x02 +#define T0_CT_ 0x04 +#define T0_GATE_ 0x08 +#define T1_M0_ 0x10 +#define T1_M1_ 0x20 +#define T1_CT_ 0x40 +#define T1_GATE_ 0x80 + +#define T0_MASK 0x0F +#define T1_MASK 0xF0 + +#define T0_MASK_ 0x0F +#define T1_MASK_ 0xF0 + + +/* Interrupt numbers: address = (number * 8) + 3 */ +#define IE0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define TF0_VECTOR 1 /* 0x0b timer 0 */ +#define IE1_VECTOR 2 /* 0x13 external interrupt 1 */ +#define TF1_VECTOR 3 /* 0x1b timer 1 */ +#define SI0_VECTOR 4 /* 0x23 serial port 0 */ + +#endif + diff --git a/device/include/at89x52.h b/device/include/at89x52.h new file mode 100644 index 00000000..060b1a6a --- /dev/null +++ b/device/include/at89x52.h @@ -0,0 +1,257 @@ +/*------------------------------------------------------------------------- + Register Declarations for ATMEL 89x52 Processors + + Written By - Bernd Bartmann + Bernd.Bartmann@picard.isdn.cs.tu-berlin.de (1999) + based on reg51.h by Sandeep Dutta sandeep.dutta@usa.net + KEIL C compatible definitions are included + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef AT89x52_H +#define AT89x52_H + +/* BYTE addressable registers */ +sfr at 0x80 P0 ; +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0x90 P1 ; +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; +sfr at 0xA0 P2 ; +sfr at 0xA8 IE ; +sfr at 0xB0 P3 ; +sfr at 0xB8 IP ; +sfr at 0xC8 T2CON ; +sfr at 0xC9 T2MOD ; +sfr at 0xCA RCAP2L ; +sfr at 0xCB RCAP2H ; +sfr at 0xCC TL2 ; +sfr at 0xCD TH2 ; +sfr at 0xD0 PSW ; +sfr at 0xE0 ACC ; +sfr at 0xE0 A ; +sfr at 0xF0 B ; + + +/* BIT addressable registers */ +/* P0 */ +sbit at 0x80 P0_0 ; +sbit at 0x81 P0_1 ; +sbit at 0x82 P0_2 ; +sbit at 0x83 P0_3 ; +sbit at 0x84 P0_4 ; +sbit at 0x85 P0_5 ; +sbit at 0x86 P0_6 ; +sbit at 0x87 P0_7 ; + +/* TCON */ +sbit at 0x88 IT0 ; +sbit at 0x89 IE0 ; +sbit at 0x8A IT1 ; +sbit at 0x8B IE1 ; +sbit at 0x8C TR0 ; +sbit at 0x8D TF0 ; +sbit at 0x8E TR1 ; +sbit at 0x8F TF1 ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +sbit at 0x90 T2 ; +sbit at 0x91 T2EX ; + +/* SCON */ +sbit at 0x98 RI ; +sbit at 0x99 TI ; +sbit at 0x9A RB8 ; +sbit at 0x9B TB8 ; +sbit at 0x9C REN ; +sbit at 0x9D SM2 ; +sbit at 0x9E SM1 ; +sbit at 0x9F SM0 ; + +/* P2 */ +sbit at 0xA0 P2_0 ; +sbit at 0xA1 P2_1 ; +sbit at 0xA2 P2_2 ; +sbit at 0xA3 P2_3 ; +sbit at 0xA4 P2_4 ; +sbit at 0xA5 P2_5 ; +sbit at 0xA6 P2_6 ; +sbit at 0xA7 P2_7 ; + +/* IE */ +sbit at 0xA8 EX0 ; +sbit at 0xA9 ET0 ; +sbit at 0xAA EX1 ; +sbit at 0xAB ET1 ; +sbit at 0xAC ES ; +sbit at 0xAD ET2 ; +sbit at 0xAF EA ; + +/* P3 */ +sbit at 0xB0 P3_0 ; +sbit at 0xB1 P3_1 ; +sbit at 0xB2 P3_2 ; +sbit at 0xB3 P3_3 ; +sbit at 0xB4 P3_4 ; +sbit at 0xB5 P3_5 ; +sbit at 0xB6 P3_6 ; +sbit at 0xB7 P3_7 ; + +sbit at 0xB0 RXD ; +sbit at 0xB1 TXD ; +sbit at 0xB2 INT0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB4 T0 ; +sbit at 0xB5 T1 ; +sbit at 0xB6 WR ; +sbit at 0xB7 RD ; + +/* IP */ +sbit at 0xB8 PX0 ; +sbit at 0xB9 PT0 ; +sbit at 0xBA PX1 ; +sbit at 0xBB PT1 ; +sbit at 0xBC PS ; +sbit at 0xBD PT2 ; + +/* T2CON */ +sbit at 0xC8 T2CON_0 ; +sbit at 0xC9 T2CON_1 ; +sbit at 0xCA T2CON_2 ; +sbit at 0xCB T2CON_3 ; +sbit at 0xCC T2CON_4 ; +sbit at 0xCD T2CON_5 ; +sbit at 0xCE T2CON_6 ; +sbit at 0xCF T2CON_7 ; + +sbit at 0xC8 CP_RL2 ; +sbit at 0xC9 C_T2 ; +sbit at 0xCA TR2 ; +sbit at 0xCB EXEN2 ; +sbit at 0xCC TCLK ; +sbit at 0xCD RCLK ; +sbit at 0xCE EXF2 ; +sbit at 0xCF TF2 ; + +/* PSW */ +sbit at 0xD0 P ; +sbit at 0xD1 FL ; +sbit at 0xD2 OV ; +sbit at 0xD3 RS0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD5 F0 ; +sbit at 0xD6 AC ; +sbit at 0xD7 CY ; + + +/* BIT definitions for bits that are not directly accessible */ +/* PCON bits */ +#define IDL 0x01 +#define PD 0x02 +#define GF0 0x04 +#define GF1 0x08 +#define SMOD 0x80 + +#define IDL_ 0x01 +#define PD_ 0x02 +#define GF0_ 0x04 +#define GF1_ 0x08 +#define SMOD_ 0x80 + +/* TMOD bits */ +#define M0_0 0x01 +#define M1_0 0x02 +#define C_T0 0x04 +#define GATE0 0x08 +#define M0_1 0x10 +#define M1_1 0x20 +#define C_T1 0x40 +#define GATE1 0x80 + +#define M0_0_ 0x01 +#define M1_0_ 0x02 +#define C_T0_ 0x04 +#define GATE0_ 0x08 +#define M0_1_ 0x10 +#define M1_1_ 0x20 +#define C_T1_ 0x40 +#define GATE1_ 0x80 + +#define T0_M0 0x01 +#define T0_M1 0x02 +#define T0_CT 0x04 +#define T0_GATE 0x08 +#define T1_M0 0x10 +#define T1_M1 0x20 +#define T1_CT 0x40 +#define T1_GATE 0x80 + +#define T0_M0_ 0x01 +#define T0_M1_ 0x02 +#define T0_CT_ 0x04 +#define T0_GATE_ 0x08 +#define T1_M0_ 0x10 +#define T1_M1_ 0x20 +#define T1_CT_ 0x40 +#define T1_GATE_ 0x80 + +#define T0_MASK 0x0F +#define T1_MASK 0xF0 + +#define T0_MASK_ 0x0F +#define T1_MASK_ 0xF0 + +/* T2MOD bits */ +#define DCEN 0x01 +#define T2OE 0x02 + +#define DCEN_ 0x01 +#define T2OE_ 0x02 + + +/* Interrupt numbers: address = (number * 8) + 3 */ +#define IE0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define TF0_VECTOR 1 /* 0x0b timer 0 */ +#define IE1_VECTOR 2 /* 0x13 external interrupt 1 */ +#define TF1_VECTOR 3 /* 0x1b timer 1 */ +#define SI0_VECTOR 4 /* 0x23 serial port 0 */ +#define TF2_VECTOR 5 /* 0x2B timer 2 */ +#define EX2_VECTOR 5 /* 0x2B external interrupt 2 */ + +#endif + diff --git a/device/include/canc515c.h b/device/include/canc515c.h new file mode 100644 index 00000000..c7459eef --- /dev/null +++ b/device/include/canc515c.h @@ -0,0 +1,149 @@ +/***************************************************************************** +|* +|* MODULE: canc515c.h +|* +|* This file contains definitions for the builtin CAN-Bus Controller of +|* the Siemens c515c controller +|* +****************************************************************************/ + +#ifndef _CANC515C_H +#define _CANC515C_H + +/* define CPU_CLK_10MHZ or CPU_CLK_8MHZ to select the right values for */ +/* the bit timing registers */ + +#define CPU_CLK_10MHZ + +/* address of can controller in xmem */ +#define CAN_CTRL 0xf700 + +/* size of message buffer including 1 dummy byte at end */ +#define CAN_MSG_SZ 0x10 + +/* register offset definitions */ +#define CR 0 +#define SR 1 +#define IR 2 + +#define BT_0 4 +#define BT_1 5 +#define GMS_0 6 +#define GMS_1 7 +#define GME_0 8 +#define GME_1 9 +#define GME_2 0xa +#define GME_3 0xb +#define MSG15MSK_0 0xc +#define MSG15MSK_1 0xd +#define MSG15MSK_2 0xe +#define MSG15MSK_3 0xf + +/* register offsets in message buffer */ +#define MCR_0 0 +#define MCR_1 1 +#define ARB_0 2 +#define ARB_1 3 +#define ARB_2 4 +#define ARB_3 5 +#define MCFG 6 +/* beginning of message data */ +#define DATA 7 + +/* bits in cntr_x registers */ +#define MSGVAL 0x80 +#define TXIE 0x20 +#define RXIE 0x8 +#define INTPND 0x2 +#define RMTPND 0x80 +#define TXRQST 0x20 +#define MSGLST 0x8 +#define CPUUPD 0x8 +#define NEWDAT 0x2 + +/* macros for setting and resetting above bits, see Siemens documentation */ +#define MCR_BIT_SET(p,x) ((p) = (0xff & ~((x) >> 1))) +#define MCR_BIT_RES(p,x) ((p) = (0xff & ~(x))) + +/* direction = transmit in mcfg */ +#define DIR_TRANSMIT 0x8 + +/* constants for bit timing registers */ +/* 8 MHZ */ +#ifdef CPU_CLK_8MHZ +#define BT_0_125K 0x3 +#define BT_1_125K 0x1c +#define BT_0_250K 0x1 +#define BT_1_250K 0x1c +#define BT_0_500K 0x0 +#define BT_1_500K 0x1c +#define BT_0_1M 0x0 +#define BT_1_1M 0x14 +#endif +/* dito, 10 MHZ */ +#ifdef CPU_CLK_10MHZ +#define BT_0_125K 0x3 +#define BT_1_125K 0x1c +#define BT_0_250K 0x1 +#define BT_1_250K 0x1c +#define BT_0_500K 0x0 +#define BT_1_500K 0x2f +#define BT_0_1M 0x0 +#define BT_1_1M 0x25 +#endif + +/* Control register bits */ + +#define CINIT 0x1 +#define IE 0x2 +#define SIE 0x4 +#define EIE 0x8 + +#define CCE 0x40 + +/* status register bits */ +#define LEC0 0x1 +#define LEC1 0x2 +#define LEC2 0x4 +#define TXOK 0x8 +#define RXOK 0x10 +#define WAKE 0x20 +#define WARN 0x40 +#define BOFF 0x80 + + +typedef struct can_msg +{ + unsigned char mcr_0; + unsigned char mcr_1; + unsigned char arb_0; + unsigned char arb_1; + unsigned char arb_2; + unsigned char arb_3; + unsigned char mcfg; + unsigned char data_bytes[8]; + unsigned char dummy; +} *can_msgp; + +xdata at CAN_CTRL struct +{ + unsigned char cr; + unsigned char sr; + unsigned char ir; + unsigned char res0; + unsigned char bt_0; + unsigned char bt_1; + unsigned char gms_0; + unsigned char gme_1; + unsigned char gme_0; + unsigned char gme_1; + unsigned char gme_2; + unsigned char gme_3; + unsigned char msg15msk_0; + unsigned char msg15msk_1; + unsigned char msg15msk_2; + unsigned char msg15msk_3; + struct can_msg msgbufs[15]; +} can_ctrl; + +#endif /* _CANC515C */ diff --git a/device/include/clean.mk b/device/include/clean.mk new file mode 100644 index 00000000..74b12cbe --- /dev/null +++ b/device/include/clean.mk @@ -0,0 +1,22 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/device/include/conf.mk b/device/include/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/device/include/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/device/include/ctype.h b/device/include/ctype.h new file mode 100644 index 00000000..4eb9215c --- /dev/null +++ b/device/include/ctype.h @@ -0,0 +1,63 @@ +/*------------------------------------------------------------------------- + ctype.h - ANSI functions forward declarations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __SDC51_CTYPE_H +#define __SDC51_CTYPE_H 1 + +#define isalnum(x) (isalpha(x) || isdigit(x)) +#define isalpha(x) (isupper(x) || islower(c)) + +#ifdef SDCC_STACK_AUTO +#warning Make sure you recompile _is*.c files as 'reentrant' + +extern char iscntrl (unsigned char ) reentrant ; +extern char isdigit (unsigned char ) reentrant ; +extern char isgraph (unsigned char ) reentrant ; +extern char islower (unsigned char ) reentrant ; +extern char isupper (unsigned char ) reentrant ; +extern char isprint (unsigned char ) reentrant ; +extern char ispunct (unsigned char ) reentrant ; +extern char isspace (unsigned char ) reentrant ; +extern char isxdigit (unsigned char ) reentrant ; + +#else + +extern char iscntrl (unsigned char ) ; +extern char isdigit (unsigned char ) ; +extern char isgraph (unsigned char ) ; +extern char islower (unsigned char ) ; +extern char isupper (unsigned char ) ; +extern char isprint (unsigned char ) ; +extern char ispunct (unsigned char ) ; +extern char isspace (unsigned char ) ; +extern char isxdigit (unsigned char ) ; + +#endif +#endif + + + + + + diff --git a/device/include/float.h b/device/include/float.h new file mode 100644 index 00000000..f76ba54c --- /dev/null +++ b/device/include/float.h @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------- + float.h - ANSI functions forward declarations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __SDC51_FLOAT_H +#define __SDC51_FLOAT_H 1 +#define FLT_RADIX 2 +#define FLT_MANT_DIG 24 +#define FLT_EPSILON 1.192092896E-07F +#define FLT_DIG 6 +#define FLT_MIN_EXP (-125) +#define FLT_MIN 1.175494351E-38F +#define FLT_MIN_10_EXP (-37) +#define FLT_MAX_EXP (+128) +#define FLT_MAX 3.402823466E+38F +#define FLT_MAX_10_EXP (+38) + +#endif + + + + + diff --git a/device/include/limits.h b/device/include/limits.h new file mode 100644 index 00000000..f067287b --- /dev/null +++ b/device/include/limits.h @@ -0,0 +1,55 @@ +/*------------------------------------------------------------------------- + limits.h - ANSI defines constants for sizes of integral types + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __SDC51_LIMITS_H +#define __SDC51_LIMITS_H 1 + +#define CHAR_BIT 8 /* bits in a char */ +#define CHAR_MAX 127 +#define CHAR_MIN -128 +#define SCHAR_MAX CHAR_MAX +#define SCHAR_MIN CHAR_MIN +#define UCHAR_MAX 255 +#define UCHAR_MIN 0 +#define SHRT_MAX CHAR_MAX +#define SHRT_MIN CHAR_MIN +#define USHRT_MAX UCHAR_MAX +#define USHRT_MIN UCHAR_MIN +#define INT_MIN -32768 +#define INT_MAX 32767 +#define UINT_MAX 65535 +#define UINT_MIN 0 +#define LONG_MIN -2147483648 +#define LONG_MAX 2147483647 +#define ULONG_MAX 4294967295 +#define ULONG_MIN 0 + + +#endif + + + + + + diff --git a/device/include/malloc.h b/device/include/malloc.h new file mode 100644 index 00000000..91bfb32f --- /dev/null +++ b/device/include/malloc.h @@ -0,0 +1,53 @@ +/*------------------------------------------------------------------------- + malloc.h - malloc header file + + Written By - Written by Dmitry S. Obukhov, 1997 dso@usa.net + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +/* malloc.h */ +#define MEMHEADER struct MAH// Memory Allocation Header + +#ifndef __SDCC51_MALLOC_H +#define __SDCC51_MALLOC_H + +MEMHEADER +{ + MEMHEADER _xdata * next; + MEMHEADER _xdata * prev; + unsigned int len; + unsigned char mem[1]; +}; + +#ifdef SDCC_STACK_AUTO +#warning Make sure you recompile malloc.c as 'reentrant' + +extern void init_dynamic_memory(MEMHEADER xdata * , unsigned int ) reentrant; +extern void xdata * malloc (unsigned int ) reentrant; +extern void free (void * xdata p) reentrant; + +#else + +extern void init_dynamic_memory(MEMHEADER xdata * , unsigned int ); +extern void xdata * malloc (unsigned int ); +extern void free (void xdata * p); + +#endif + +#endif diff --git a/device/include/math.h b/device/include/math.h new file mode 100644 index 00000000..dc237d1c --- /dev/null +++ b/device/include/math.h @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------- + math.h - ANSI functions forward declarations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __SDC51_MATH_H +#define __SDC51_MATH_H 1 +#error Floating point not yet completely implemented +#endif + + + + + diff --git a/device/include/mcs51/README b/device/include/mcs51/README new file mode 100644 index 00000000..89fef239 --- /dev/null +++ b/device/include/mcs51/README @@ -0,0 +1,2 @@ +sdcc/device/lib/mcs51 +--------------------- diff --git a/device/include/reg51.h b/device/include/reg51.h new file mode 100644 index 00000000..e5fad867 --- /dev/null +++ b/device/include/reg51.h @@ -0,0 +1,145 @@ +/*------------------------------------------------------------------------- + Register Declarations for 8051 Processor + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef REG51_H +#define REG51_H + +/* BYTE Register */ +sfr at 0x80 P0 ; +sfr at 0x90 P1 ; +sfr at 0xA0 P2 ; +sfr at 0xB0 P3 ; +sfr at 0xD0 PSW ; +sfr at 0xE0 ACC ; +sfr at 0xF0 B ; +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0x8E AUXR ; +sfr at 0xA8 IE ; +sfr at 0xB8 IP ; +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; + + +/* BIT Register */ +/* PSW */ +sbit at 0xD7 CY ; +sbit at 0xD6 AC ; +sbit at 0xD5 F0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD3 RS0 ; +sbit at 0xD2 OV ; +sbit at 0xD0 P ; + +/* TCON */ +sbit at 0x8F TF1 ; +sbit at 0x8E TR1 ; +sbit at 0x8D TF0 ; +sbit at 0x8C TR0 ; +sbit at 0x8B IE1 ; +sbit at 0x8A IT1 ; +sbit at 0x89 IE0 ; +sbit at 0x88 IT0 ; + +/* IE */ +sbit at 0xAF EA ; +sbit at 0xAC ES ; +sbit at 0xAB ET1 ; +sbit at 0xAA EX1 ; +sbit at 0xA9 ET0 ; +sbit at 0xA8 EX0 ; + +/* IP */ +sbit at 0xBC PS ; +sbit at 0xBB PT1 ; +sbit at 0xBA PX1 ; +sbit at 0xB9 PT0 ; +sbit at 0xB8 PX0 ; + +/* P3 */ +sbit at 0xB7 RD ; +sbit at 0xB6 WR ; +sbit at 0xB5 T1 ; +sbit at 0xB4 T0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB2 INT0 ; +sbit at 0xB1 TXD ; +sbit at 0xB0 RXD ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +/* SCON */ +sbit at 0x9F SM0 ; +sbit at 0x9E SM1 ; +sbit at 0x9D SM2 ; +sbit at 0x9C REN ; +sbit at 0x9B TB8 ; +sbit at 0x9A RB8 ; +sbit at 0x99 TI ; +sbit at 0x98 RI ; + +/* TMOD bits */ +#define GATE1 (1<<7) +#define C_T1 (1<<6) +#define M1_1 (1<<5) +#define M0_1 (1<<4) +#define GATE0 (1<<3) +#define C_T0 (1<<2) +#define M1_0 (1<<1) +#define M0_0 (1<<0) + +/* T2CON */ +sfr at 0xC8 T2CON ; + +/* T2CON bits */ +sbit at 0xC8 T2CON_0 ; +sbit at 0xC9 T2CON_1 ; +sbit at 0xCA T2CON_2 ; +sbit at 0xCB T2CON_3 ; +sbit at 0xCC T2CON_4 ; +sbit at 0xCD T2CON_5 ; +sbit at 0xCE T2CON_6 ; +sbit at 0xCF T2CON_7 ; + +/* RCAP2 L & H */ +sfr at 0xCB RCAP2H; +sfr at 0xCA RCAP2L; + +#endif diff --git a/device/include/reg515.h b/device/include/reg515.h new file mode 100644 index 00000000..8dfb9612 --- /dev/null +++ b/device/include/reg515.h @@ -0,0 +1,182 @@ +/*------------------------------------------------------------------------- + Register Declarations for Siemens 80c515/535 Processor + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) as reg51.h + Modified for Siemens chip by - G.J.Kruizinga (1999) + + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef REG515_H +#define REG515_H + +/* BYTE Register */ +/* Port Registers */ +sfr at 0x80 P0 ; +sfr at 0x90 P1 ; +sfr at 0xA0 P2 ; +sfr at 0xB0 P3 ; +sfr at 0xE8 P4 ; +sfr at 0xF8 P5 ; + +/* MCU Registers */ +sfr at 0xD0 PSW ; +sfr at 0xE0 ACC ; +sfr at 0xF0 B ; +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0xA8 IEN0 ; +sfr at 0xB8 IEN1 ; +sfr at 0xA9 IP0 ; +sfr at 0xB9 IP1 ; +sfr at 0xC0 IRCON; + +/* Power Control Registers */ +sfr at 0x87 PCON ; + +/* Timer Control Registers */ +sfr at 0x88 TCON ; +sfr at 0xC8 T2CON; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0xCC TL2 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0xCD TH2 ; +sfr at 0xC1 CCEN ; +sfr at 0xC2 CCL1 ; +sfr at 0xC4 CCL2 ; +sfr at 0xC6 CCL3 ; +sfr at 0xC3 CCH1 ; +sfr at 0xC5 CCH2 ; +sfr at 0xC7 CCH3 ; +sfr at 0xCA CRCL ; +sfr at 0xCB CRCH ; + +/* Serial Control Registers */ +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; + +/* AD Converter Control Registers */ +sfr at 0xD8 ADCON; +sfr at 0xD9 ADDAT; +sfr at 0xDA DAPR ; + + +/* BIT Register */ +/* PSW */ +sbit at 0xD7 CY ; +sbit at 0xD6 AC ; +sbit at 0xD5 F0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD3 RS0 ; +sbit at 0xD2 OV ; +sbit at 0xD0 P ; + +/* TCON */ +sbit at 0x8F TF1 ; +sbit at 0x8E TR1 ; +sbit at 0x8D TF0 ; +sbit at 0x8C TR0 ; +sbit at 0x8B IE1 ; +sbit at 0x8A IT1 ; +sbit at 0x89 IE0 ; +sbit at 0x88 IT0 ; + +/* T2CON */ +sbit at 0xCF T2PS ; +sbit at 0xCE I3FR ; +sbit at 0xCD I2FR ; +sbit at 0xCC T2R1 ; +sbit at 0xCB T2R0 ; +sbit at 0xCA T2CM ; +sbit at 0xC9 T2I1 ; +sbit at 0xC8 T2I0 ; + +/* IEN0 */ +sbit at 0xAF EA ; +sbit at 0xAC ES ; +sbit at 0xAB ET1 ; +sbit at 0xAA EX1 ; +sbit at 0xA9 ET0 ; +sbit at 0xA8 EX0 ; + +/* IEN1 */ +sbit at 0xBF EXEN2; +sbit at 0xBE SWDT ; +sbit at 0xBD EX6 ; +sbit at 0xBC EX5 ; +sbit at 0xBB EX4 ; +sbit at 0xBA EX3 ; +sbit at 0xB9 EX2 ; +sbit at 0xB8 EADC ; + +/* P3 */ +sbit at 0xB7 RD ; +sbit at 0xB6 WR ; +sbit at 0xB5 T1 ; +sbit at 0xB4 T0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB2 INT0 ; +sbit at 0xB1 TXD ; +sbit at 0xB0 RXD ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +/* SCON */ +sbit at 0x9F SM0 ; +sbit at 0x9E SM1 ; +sbit at 0x9D SM2 ; +sbit at 0x9C REN ; +sbit at 0x9B TB8 ; +sbit at 0x9A RB8 ; +sbit at 0x99 TI ; +sbit at 0x98 RI ; + +/* ADCON */ +sbit at 0xDF BD ; +sbit at 0xDE ADCLK; +sbit at 0xDC BSY ; +sbit at 0xDB ADM ; +sbit at 0xDA MX2 ; +sbit at 0xD9 MX1 ; +sbit at 0xD8 MX0 ; + +/* IRCON */ +sbit at 0xC7 EXF2 ; +sbit at 0xC6 TF2 ; +sbit at 0xC5 IEX6 ; +sbit at 0xC4 IEX5 ; +sbit at 0xC3 IEX4 ; +sbit at 0xC2 IEX3 ; +sbit at 0xC1 IEX2 ; +sbit at 0xC0 IADC ; + +#endif diff --git a/device/include/reg552.h b/device/include/reg552.h new file mode 100644 index 00000000..50d230a4 --- /dev/null +++ b/device/include/reg552.h @@ -0,0 +1,225 @@ +/*------------------------------------------------------------------------- + Register Declarations for 80c552 Processor + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef REG552_H +#define REG552_H + +/* BYTE Register */ +sfr P0 = 0x80; +sfr P1 = 0x90; +sfr P2 = 0xA0; +sfr P3 = 0xB0; +sfr P4 = 0xC0; +sfr P5 = 0xC4; + +sfr PSW = 0xD0; +sfr ACC = 0xE0; +sfr B = 0xF0; +sfr SP = 0x81; +sfr DPL = 0x82; +sfr DPH = 0x83; +sfr PCON = 0x87; +sfr TCON = 0x88; +sfr TMOD = 0x89; +sfr TL0 = 0x8A; +sfr TL1 = 0x8B; +sfr TH0 = 0x8C; +sfr TH1 = 0x8D; +sfr IEN0 = 0xA8; +sfr IEN1 = 0xE8; +sfr IP0 = 0xB8; +sfr IP1 = 0xF8; +sfr S0CON = 0x98; +sfr S0BUF = 0x99; +sfr CML0 = 0xA9; +sfr CML1 = 0xAA; +sfr CML2 = 0xAB; +sfr CTL0 = 0xAC; +sfr CTL1 = 0xAD; +sfr CTL2 = 0xAE; +sfr CTL3 = 0xAF; + +sfr ADCON = 0xC5; +sfr ADCH = 0xC6; +sfr TM2IR = 0xC8; +sfr CMH0 = 0xC9; +sfr CMH1 = 0xCA; +sfr CMH2 = 0xCB; +sfr CTH0 = 0xCC; +sfr CTH1 = 0xCD; +sfr CTH2 = 0xCE; +sfr CTH3 = 0xCF; + +sfr S1CON = 0xD8; +sfr S1STA = 0xD9; +sfr S1DAT = 0xDA; +sfr S1ADR = 0xDB; + +sfr TM2CON = 0xEA; +sfr CTCON = 0xEB; +sfr TML2 = 0xEC; +sfr TMH2 = 0xED; +sfr STE = 0xEE; +sfr RTE = 0xEF; +sfr PWM0 = 0xFC; +sfr PWM1 = 0xFD; +sfr PWMP = 0xFE; +sfr T3 = 0xFF; + + +/* BIT Register */ +/* PSW */ +sbit CY = 0xD7; +sbit AC = 0xD6; +sbit F0 = 0xD5; +sbit RS1 = 0xD4; +sbit RS0 = 0xD3; +sbit OV = 0xD2; +sbit P = 0xD0; + +/* TCON */ +sbit TF1 = 0x8F; +sbit TR1 = 0x8E; +sbit TF0 = 0x8D; +sbit TR0 = 0x8C; +sbit IE1 = 0x8B; +sbit IT1 = 0x8A; +sbit IE0 = 0x89; +sbit IT0 = 0x88; + +/* IEN0 */ +sbit EA = 0xAF; +sbit EAD = 0xAE; +sbit ES1 = 0xAD; +sbit ES0 = 0xAC; +sbit ET1 = 0xAB; +sbit EX1 = 0xAA; +sbit ET0 = 0xA9; +sbit EX0 = 0xA8; + +/* IEN1 */ +sbit ET2 = 0xEF; +sbit ECM2 = 0xEE; +sbit ECM1 = 0xED; +sbit ECM0 = 0xEC; +sbit ECT3 = 0xEB; +sbit ECT2 = 0xEA; +sbit ECT1 = 0xE9; +sbit ECT0 = 0xE8; + +/* IP0 */ +sbit PAD = 0xBE; +sbit PS1 = 0xBD; +sbit PS0 = 0xBC; +sbit PT1 = 0xBB; +sbit PX1 = 0xBA; +sbit PT0 = 0xB9; +sbit PX0 = 0xB8; + +/* IP1 */ +sbit PT2 = 0xFF; +sbit PCM2 = 0xFE; +sbit PCM1 = 0xFD; +sbit PCM0 = 0xFC; +sbit PCT3 = 0xFB; +sbit PCT2 = 0xFA; +sbit PCT1 = 0xF9; +sbit PCT0 = 0xF8; + +/* P1 */ +sbit SDA = 0x97; +sbit SCL = 0x96; +sbit RT2 = 0x95; +sbit T2 = 0x94; +sbit CT3I = 0x93; +sbit CT2I = 0x92; +sbit CT1I = 0x91; +sbit CT0I = 0x90; + +/* P3 */ +sbit RD = 0xB7; +sbit WR = 0xB6; +sbit T1 = 0xB5; +sbit T0 = 0xB4; +sbit INT1 = 0xB3; +sbit INT0 = 0xB2; +sbit TXD = 0xB1; +sbit RXD = 0xB0; + +/* P4 */ +sbit CMT1 = 0xC7; +sbit CMT0 = 0xC6; +sbit CMSR5 = 0xC5; +sbit CMSR4 = 0xC4; +sbit CMSR3 = 0xC3; +sbit CMSR2 = 0xC2; +sbit CMSR1 = 0xC1; +sbit CMSR0 = 0xC0; + +/* S0CON */ +sbit SM0 = 0x9F; +sbit SM1 = 0x9E; +sbit SM2 = 0x9D; +sbit REN = 0x9C; +sbit TB8 = 0x9B; +sbit RB8 = 0x9A; +sbit TI = 0x99; +sbit RI = 0x98; + +/* TM2IR */ +sbit T2OV = 0xCF; +sbit CMI2 = 0xCE; +sbit CMI1 = 0xCD; +sbit CMI0 = 0xCC; +sbit CTI3 = 0xCB; +sbit CTI2 = 0xCA; +sbit CTI1 = 0xC9; +sbit CTI0 = 0xC8; + +/* S1CON */ +sbit CR0 = 0xD8; +sbit CR1 = 0xD9; +sbit AA = 0xDA; +sbit SI = 0xDB; +sbit STO = 0xDC; +sbit STA = 0xDD; +sbit ENS1 = 0xDE; + +/* T2CON */ +sfr at 0xC8 T2CON ; + +/* T2CON bits */ +sbit at 0xC8 T2CON_0 ; +sbit at 0xC9 T2CON_1 ; +sbit at 0xCA T2CON_2 ; +sbit at 0xCB T2CON_3 ; +sbit at 0xCC T2CON_4 ; +sbit at 0xCD T2CON_5 ; +sbit at 0xCE T2CON_6 ; +sbit at 0xCF T2CON_7 ; + +/* RCAP2 L & H */ +sfr at 0xCB RCAP2H; +sfr at 0xCA RCAP2L; +#endif diff --git a/device/include/regc515c.h b/device/include/regc515c.h new file mode 100644 index 00000000..2a56b357 --- /dev/null +++ b/device/include/regc515c.h @@ -0,0 +1,298 @@ +/***************************************************************************** +|* +|* MODULE: regc515c.h +|* + ****************************************************************************/ + +#ifndef _REGC515C_H +#define _REGC515C_H + +/* Byte registers in numerical order */ + +sfr at 0x80 P0; +sfr at 0x81 SP; +sfr at 0x82 DPL; +sfr at 0x83 DPH; +sfr at 0x86 WDTREL; +sfr at 0x87 PCON; +sfr at 0x88 TCON; +sfr at 0x88 PCON1; +sfr at 0x89 TMOD; +sfr at 0x8A TL0; +sfr at 0x8B TL1; +sfr at 0x8C TH0; +sfr at 0x8D TH1; +sfr at 0x90 P1; +sfr at 0x91 XPAGE; +sfr at 0x92 DPSEL; +sfr at 0x93 SSCCON; +sfr at 0x94 STB; +sfr at 0x95 SRB; +sfr at 0x96 SSCMOD; +sfr at 0x98 SCON; +sfr at 0x99 SBUF; +sfr at 0x9A IEN2; +sfr at 0xA0 P2; +sfr at 0xA8 IEN0; +sfr at 0xA9 IP0; +sfr at 0xAA SRELL; +sfr at 0xAB SCF; +sfr at 0xAC SCIEN; +sfr at 0xB0 P3; +sfr at 0xB1 SYSCON; +sfr at 0xB8 IEN1; +sfr at 0xB9 IP1; +sfr at 0xBA SRELH; +sfr at 0xC0 IRCON; +sfr at 0xC1 CCEN; +sfr at 0xC2 CCL1; +sfr at 0xC3 CCH1; +sfr at 0xC4 CCL2; +sfr at 0xC5 CCH2; +sfr at 0xC6 CCL3; +sfr at 0xC7 CCH3; +sfr at 0xC8 T2CON; +sfr at 0xCA CRCL; +sfr at 0xCB CRCH; +sfr at 0xCC TL2; +sfr at 0xCD TH2; +sfr at 0xD0 PSW; +sfr at 0xD8 ADCON0; +sfr at 0xD9 ADDATH; +sfr at 0xDA ADDATL; +sfr at 0xDB P6; +sfr at 0xDC ADCON1; +sfr at 0xE0 ACC; +sfr at 0xE8 P4; +sfr at 0xF0 B; +sfr at 0xF8 P5; +sfr at 0xF8 DIR5; +sfr at 0xFA P7; + + +/* defining bits in SFR P0 */ +sbit at 0x80 P0_0; +sbit at 0x81 P0_1; +sbit at 0x82 P0_2; +sbit at 0x83 P0_3; +sbit at 0x84 P0_4; +sbit at 0x85 P0_5; +sbit at 0x86 P0_6; +sbit at 0x87 P0_7; + + + +/* defining bits in SFR PCON1 */ +sbit at 0x88 IT0; +sbit at 0x89 IE0; +sbit at 0x8a IT1; +sbit at 0x8b IE1; +sbit at 0x8c TR0; +sbit at 0x8d TF0; +sbit at 0x8e TR1; +sbit at 0x8f TF1; +sbit at 0x8f EWPD; + + + +/* defining bits in SFR P1 */ +sbit at 0x90 P1_0; +sbit at 0x90 INT3; +sbit at 0x91 P1_1; +sbit at 0x91 INT4; +sbit at 0x92 P1_2; +sbit at 0x92 INT5; +sbit at 0x93 P1_3; +sbit at 0x93 INT6; +sbit at 0x94 P1_4; +sbit at 0x94 INT2; +sbit at 0x95 P1_5; +sbit at 0x95 T2EX; +sbit at 0x96 P1_6; +sbit at 0x96 CLKOUT; +sbit at 0x97 P1_7; +sbit at 0x97 T2; + + + +/* defining bits in SFR SCON */ +sbit at 0x98 RI; +sbit at 0x99 TI; +sbit at 0x9a RB8; +sbit at 0x9b TB8; +sbit at 0x9c REN; +sbit at 0x9d SM2; +sbit at 0x9e SM1; +sbit at 0x9f SM0; + + + +/* defining bits in SFR P2 */ +sbit at 0xa0 P2_0; +sbit at 0xa1 P2_1; +sbit at 0xa2 P2_2; +sbit at 0xa3 P2_3; +sbit at 0xa4 P2_4; +sbit at 0xa5 P2_5; +sbit at 0xa6 P2_6; +sbit at 0xa7 P2_7; + + + +/* defining bits in SFR IEN0 */ +sbit at 0xa8 EX0; +sbit at 0xa9 ET0; +sbit at 0xaa EX1; +sbit at 0xab ET1; +sbit at 0xac ES; +sbit at 0xad ET2; +sbit at 0xae WDT; +sbit at 0xaf EA; + + + +/* defining bits in SFR P3 */ +sbit at 0xb0 P3_0; +sbit at 0xb0 RXD; +sbit at 0xb1 P3_1; +sbit at 0xb1 TXD; +sbit at 0xb2 P3_2; +sbit at 0xb2 INT0; +sbit at 0xb3 P3_3; +sbit at 0xb3 INT1; +sbit at 0xb4 P3_4; +sbit at 0xb4 T0; +sbit at 0xb5 P3_5; +sbit at 0xb5 T1; +sbit at 0xb6 P3_6; +sbit at 0xb6 WR; +sbit at 0xb7 P3_7; +sbit at 0xb7 RD; + + + +/* defining bits in SFR IEN1 */ +sbit at 0xb8 EADC; +sbit at 0xb9 EX2; +sbit at 0xba EX3; +sbit at 0xbb EX4; +sbit at 0xbc EX5; +sbit at 0xbd EX6; +sbit at 0xbe SWDT; +sbit at 0xbf EXEN2; + + + +/* defining bits in SFR IRCON */ +sbit at 0xc0 IADC; +sbit at 0xc1 IEX2; +sbit at 0xc2 IEX3; +sbit at 0xc3 IEX4; +sbit at 0xc4 IEX5; +sbit at 0xc5 IEX6; +sbit at 0xc6 TF2; +sbit at 0xc7 EXF2; + + + +/* defining bits in SFR T2CON */ +sbit at 0xc8 T2I0; +sbit at 0xc9 T2I1; +sbit at 0xca T2CM; +sbit at 0xcb T2R0; +sbit at 0xcc T2R1; +sbit at 0xcd I2FR; +sbit at 0xce I3FR; +sbit at 0xcf T2PS; + + + +/* defining bits in SFR PSW */ +sbit at 0xd0 P; +sbit at 0xd1 F1; +sbit at 0xd2 OV; +sbit at 0xd3 RS0; +sbit at 0xd4 RS1; +sbit at 0xd5 F0; +sbit at 0xd6 AC; +sbit at 0xd7 CY; + + + +/* defining bits in SFR ADCON0 */ +sbit at 0xd8 MX0; +sbit at 0xd9 MX1; +sbit at 0xda MX2; +sbit at 0xdb ADM; +sbit at 0xdc BSY; +sbit at 0xdd ADEX; +sbit at 0xde CLK; +sbit at 0xdf BD; + + + +/* defining bits in SFR ACC */ +sbit at 0xe0 ACC_0; +sbit at 0xe1 ACC_1; +sbit at 0xe2 ACC_2; +sbit at 0xe3 ACC_3; +sbit at 0xe4 ACC_4; +sbit at 0xe5 ACC_5; +sbit at 0xe6 ACC_6; +sbit at 0xe7 ACC_7; + + + +/* defining bits in SFR P4 */ +sbit at 0xe8 P4_0; +sbit at 0xe8 ADST; +sbit at 0xe9 P4_1; +sbit at 0xe9 SCLK; +sbit at 0xea P4_2; +sbit at 0xea SRI; +sbit at 0xeb P4_3; +sbit at 0xeb STO; +sbit at 0xec P4_4; +sbit at 0xec SLS; +sbit at 0xed P4_5; +sbit at 0xed INT8; +sbit at 0xee P4_6; +sbit at 0xee TXDC; +sbit at 0xef P4_7; +sbit at 0xef RXDC; + + + +/* defining bits in SFR B */ +sbit at 0xf0 B_0; +sbit at 0xf1 B_1; +sbit at 0xf2 B_2; +sbit at 0xf3 B_3; +sbit at 0xf4 B_4; +sbit at 0xf5 B_5; +sbit at 0xf6 B_6; +sbit at 0xf7 B_7; + + + +/* defining bits in SFR DIR5 */ +sbit at 0xf8 P5_0; +sbit at 0xf9 P5_1; +sbit at 0xfa P5_2; +sbit at 0xfb P5_3; +sbit at 0xfc P5_4; +sbit at 0xfd P5_5; +sbit at 0xfe P5_6; +sbit at 0xff P5_7; +sbit at 0xf8 DIR5_0; +sbit at 0xf9 DIR5_1; +sbit at 0xfa DIR5_2; +sbit at 0xfb DIR5_3; +sbit at 0xfc DIR5_4; +sbit at 0xfd DIR5_5; +sbit at 0xfe DIR5_6; +sbit at 0xff DIR5_7; + +#endif /* _REGC515C_H */ + + diff --git a/device/include/sab80515.h b/device/include/sab80515.h new file mode 100644 index 00000000..d23dd495 --- /dev/null +++ b/device/include/sab80515.h @@ -0,0 +1,385 @@ +/*------------------------------------------------------------------------- + Register Declarations for SIEMENS SAB 80515 Processor + + Written By - Bela Torok + Bela.Torokt@kssg.ch + based on reg51.h by Sandeep Dutta sandeep.dutta@usa.net + KEIL C compatible definitions are included + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SAB80515_H +#define SAB80515_H + +/* BYTE addressable registers */ +sfr at 0x80 P0 ; +sfr at 0x81 SP ; +sfr at 0x82 DPL ; +sfr at 0x83 DPH ; +sfr at 0x87 PCON ; +sfr at 0x88 TCON ; +sfr at 0x89 TMOD ; +sfr at 0x8A TL0 ; +sfr at 0x8B TL1 ; +sfr at 0x8C TH0 ; +sfr at 0x8D TH1 ; +sfr at 0x90 P1 ; +sfr at 0x98 SCON ; +sfr at 0x99 SBUF ; +sfr at 0xA0 P2 ; +sfr at 0xA8 IE ; +sfr at 0xA8 IEN0 ; /* as called by Siemens */ +sfr at 0xA9 IP0 ; /* interrupt priority register - SAB80515 specific */ +sfr at 0xB0 P3 ; +sfr at 0xB8 IEN1 ; /* interrupt enable register - SAB80515 specific */ +sfr at 0xB9 IP1 ; /* interrupt priority register as called by Siemens */ +sfr at 0xC0 IRCON ; /* interrupt control register - SAB80515 specific */ +sfr at 0xC1 CCEN ; /* compare/capture enable register */ +sfr at 0xC2 CCL1 ; /* compare/capture register 1, low byte */ +sfr at 0xC3 CCH1 ; /* compare/capture register 1, high byte */ +sfr at 0xC4 CCL2 ; /* compare/capture register 2, low byte */ +sfr at 0xC5 CCH2 ; /* compare/capture register 2, high byte */ +sfr at 0xC6 CCL3 ; /* compare/capture register 3, low byte */ +sfr at 0xC7 CCH3 ; /* compare/capture register 3, high byte */ +sfr at 0xC8 T2CON ; +sfr at 0xCA CRCL ; /* compare/reload/capture register, low byte */ +sfr at 0xCB CRCH ; /* compare/reload/capture register, high byte */ +sfr at 0xCC TL2 ; +sfr at 0xCD TH2 ; +sfr at 0xD0 PSW ; +sfr at 0xD8 ADCON ; /* A/D-converter control register */ +sfr at 0xD9 ADDAT ; /* A/D-converter data register */ +sfr at 0xD8 DAPR ; /* D/A-converter program register */ +sfr at 0xE0 ACC ; +sfr at 0xE0 A ; +sfr at 0xE8 P4 ; /* Port 4 - SAB80515 specific */ +sfr at 0xF0 B ; +sfr at 0xF8 P5 ; /* Port 5 - SAB80515 specific */ + + +/* BIT addressable registers */ +/* P0 */ +sbit at 0x80 P0_0 ; +sbit at 0x81 P0_1 ; +sbit at 0x82 P0_2 ; +sbit at 0x83 P0_3 ; +sbit at 0x84 P0_4 ; +sbit at 0x85 P0_5 ; +sbit at 0x86 P0_6 ; +sbit at 0x87 P0_7 ; + +/* TCON */ +sbit at 0x88 IT0 ; +sbit at 0x89 IE0 ; +sbit at 0x8A IT1 ; +sbit at 0x8B IE1 ; +sbit at 0x8C TR0 ; +sbit at 0x8D TF0 ; +sbit at 0x8E TR1 ; +sbit at 0x8F TF1 ; + +/* P1 */ +sbit at 0x90 P1_0 ; +sbit at 0x91 P1_1 ; +sbit at 0x92 P1_2 ; +sbit at 0x93 P1_3 ; +sbit at 0x94 P1_4 ; +sbit at 0x95 P1_5 ; +sbit at 0x96 P1_6 ; +sbit at 0x97 P1_7 ; + +sbit at 0x90 INT3_CC0 ; /* P1 alternate functions - SAB80515 specific */ +sbit at 0x91 INT4_CC1 ; +sbit at 0x92 INT5_CC2 ; +sbit at 0x93 INT6_CC3 ; +sbit at 0x94 INT2 ; +sbit at 0x95 T2EX ; +sbit at 0x96 CLKOUT ; +sbit at 0x97 T2 ; + +/* SCON */ +sbit at 0x98 RI ; +sbit at 0x99 TI ; +sbit at 0x9A RB8 ; +sbit at 0x9B TB8 ; +sbit at 0x9C REN ; +sbit at 0x9D SM2 ; +sbit at 0x9E SM1 ; +sbit at 0x9F SM0 ; + +/* P2 */ +sbit at 0xA0 P2_0 ; +sbit at 0xA1 P2_1 ; +sbit at 0xA2 P2_2 ; +sbit at 0xA3 P2_3 ; +sbit at 0xA4 P2_4 ; +sbit at 0xA5 P2_5 ; +sbit at 0xA6 P2_6 ; +sbit at 0xA7 P2_7 ; + +/* IEN0 */ +sbit at 0xA8 EX0 ; +sbit at 0xA9 ET0 ; +sbit at 0xAA EX1 ; +sbit at 0xAB ET1 ; +sbit at 0xAC ES ; +sbit at 0xAD ET2 ; +sbit at 0xAE WDT ; /* watchdog timer reset - SAB80515 specific */ +sbit at 0xAF EA ; + +sbit at 0xAF EAL ; /* EA as called by Siemens */ + +/* P3 */ +sbit at 0xB0 P3_0 ; +sbit at 0xB1 P3_1 ; +sbit at 0xB2 P3_2 ; +sbit at 0xB3 P3_3 ; +sbit at 0xB4 P3_4 ; +sbit at 0xB5 P3_5 ; +sbit at 0xB6 P3_6 ; +sbit at 0xB7 P3_7 ; + +sbit at 0xB0 RXD ; +sbit at 0xB1 TXD ; +sbit at 0xB2 INT0 ; +sbit at 0xB3 INT1 ; +sbit at 0xB4 T0 ; +sbit at 0xB5 T1 ; +sbit at 0xB6 WR ; +sbit at 0xB7 RD ; + +/* IEN1 */ +sbit at 0xB8 EADC ; /* A/D converter interrupt enable */ +sbit at 0xB9 EX2 ; +sbit at 0xBA EX3 ; +sbit at 0xBB EX4 ; +sbit at 0xBC EX5 ; +sbit at 0xBD EX6 ; +sbit at 0xBE SWDT ; /* watchdog timer start/reset */ +sbit at 0xBF EXEN2 ; /* timer2 external reload interrupt enable */ + +/* IRCON */ +sbit at 0xC0 IADC ; /* A/D converter irq flag */ +sbit at 0xC1 IEX2 ; /* external interrupt edge detect flag */ +sbit at 0xC2 IEX3 ; +sbit at 0xC3 IEX4 ; +sbit at 0xC4 IEX5 ; +sbit at 0xC5 IEX6 ; +sbit at 0xC6 TF2 ; /* timer 2 owerflow flag */ +sbit at 0xC7 EXF2 ; /* timer2 reload flag */ + +/* T2CON */ +sbit at 0xC8 T2CON_0 ; +sbit at 0xC9 T2CON_1 ; +sbit at 0xCA T2CON_2 ; +sbit at 0xCB T2CON_3 ; +sbit at 0xCC T2CON_4 ; +sbit at 0xCD T2CON_5 ; +sbit at 0xCE T2CON_6 ; +sbit at 0xCF T2CON_7 ; + +sbit at 0xC8 T2I0 ; +sbit at 0xC9 T2I1 ; +sbit at 0xCA T2CM ; +sbit at 0xCB T2R0 ; +sbit at 0xCC T2R1 ; +sbit at 0xCD I2FR ; +sbit at 0xCE I3FR ; +sbit at 0xCF T2PS ; + + +/* PSW */ +sbit at 0xD0 P ; +sbit at 0xD1 FL ; +sbit at 0xD2 OV ; +sbit at 0xD3 RS0 ; +sbit at 0xD4 RS1 ; +sbit at 0xD5 F0 ; +sbit at 0xD6 AC ; +sbit at 0xD7 CY ; + +sbit at 0xD1 F1 ; + +/* ADCON */ +sbit at 0xD8 MX0 ; +sbit at 0xD9 MX1 ; +sbit at 0xDA MX2 ; +sbit at 0xDB ADM ; +sbit at 0xDC BSY ; + +sbit at 0xDE CLK ; +sbit at 0xDF BD ; + +/* A */ +sbit at 0xA0 AREG_F0 ; +sbit at 0xA1 AREG_F1 ; +sbit at 0xA2 AREG_F2 ; +sbit at 0xA3 AREG_F3 ; +sbit at 0xA4 AREG_F4 ; +sbit at 0xA5 AREG_F5 ; +sbit at 0xA6 AREG_F6 ; +sbit at 0xA7 AREG_F7 ; + +/* P4 */ +sbit at 0xE8 P4_0 ; +sbit at 0xE9 P4_1 ; +sbit at 0xEA P4_2 ; +sbit at 0xEB P4_3 ; +sbit at 0xEC P4_4 ; +sbit at 0xED P4_5 ; +sbit at 0xEE P4_6 ; +sbit at 0xEF P4_7 ; + +/* B */ +sbit at 0xF0 BREG_F0 ; +sbit at 0xF1 BREG_F1 ; +sbit at 0xF2 BREG_F2 ; +sbit at 0xF3 BREG_F3 ; +sbit at 0xF4 BREG_F4 ; +sbit at 0xF5 BREG_F5 ; +sbit at 0xF6 BREG_F6 ; +sbit at 0xF7 BREG_F7 ; + +/* P5 */ +sbit at 0xF8 P5_0 ; +sbit at 0xF9 P5_1 ; +sbit at 0xFA P5_2 ; +sbit at 0xFB P5_3 ; +sbit at 0xFC P5_4 ; +sbit at 0xFD P5_5 ; +sbit at 0xFE P5_6 ; +sbit at 0xFF P5_7 ; + +/* BIT definitions for bits that are not directly accessible */ +/* PCON bits */ +#define IDL 0x01 +#define PD 0x02 +#define GF0 0x04 +#define GF1 0x08 +#define SMOD 0x80 + +#define IDL_ 0x01 +#define PD_ 0x02 +#define GF0_ 0x04 +#define GF1_ 0x08 +#define SMOD_ 0x80 + +/* TMOD bits */ +#define M0_0 0x01 +#define M1_0 0x02 +#define C_T0 0x04 +#define GATE0 0x08 +#define M0_1 0x10 +#define M1_1 0x20 +#define C_T1 0x40 +#define GATE1 0x80 + +#define M0_0_ 0x01 +#define M1_0_ 0x02 +#define C_T0_ 0x04 +#define GATE0_ 0x08 +#define M0_1_ 0x10 +#define M1_1_ 0x20 +#define C_T1_ 0x40 +#define GATE1_ 0x80 + +#define T0_M0 0x01 +#define T0_M1 0x02 +#define T0_CT 0x04 +#define T0_GATE 0x08 +#define T1_M0 0x10 +#define T1_M1 0x20 +#define T1_CT 0x40 +#define T1_GATE 0x80 + +#define T0_M0_ 0x01 +#define T0_M1_ 0x02 +#define T0_CT_ 0x04 +#define T0_GATE_ 0x08 +#define T1_M0_ 0x10 +#define T1_M1_ 0x20 +#define T1_CT_ 0x40 +#define T1_GATE_ 0x80 + +#define T0_MASK 0x0F +#define T1_MASK 0xF0 + +#define T0_MASK_ 0x0F +#define T1_MASK_ 0xF0 + +/* T2MOD bits */ +#define DCEN 0x01 +#define T2OE 0x02 + +#define DCEN_ 0x01 +#define T2OE_ 0x02 + +/* WMCON bits */ +#define WMCON_WDTEN 0x01 +#define WMCON_WDTRST 0x02 +#define WMCON_DPS 0x04 +#define WMCON_EEMEN 0x08 +#define WMCON_EEMWE 0x10 +#define WMCON_PS0 0x20 +#define WMCON_PS1 0x40 +#define WMCON_PS2 0x80 + +/* SPCR-SPI bits */ +#define SPCR_SPR0 0x01 +#define SPCR_SPR1 0x02 +#define SPCR_CPHA 0x04 +#define SPCR_CPOL 0x08 +#define SPCR_MSTR 0x10 +#define SPCR_DORD 0x20 +#define SPCR_SPE 0x40 +#define SPCR_SPIE 0x80 + +/* SPSR-SPI bits */ +#define SPSR_WCOL 0x40 +#define SPSR_SPIF 0x80 + +/* SPDR-SPI bits */ +#define SPDR_SPD0 0x10 +#define SPDR_SPD1 0x20 +#define SPDR_SPD2 0x40 +#define SPDR_SPD3 0x80 +#define SPDR_SPD4 0x10 +#define SPDR_SPD5 0x20 +#define SPDR_SPD6 0x40 +#define SPDR_SPD7 0x80 + +/* Interrupt numbers: address = (number * 8) + 3 */ +#define IE0_VECTOR 0 /* 0x03 external interrupt 0 */ +#define TF0_VECTOR 1 /* 0x0b timer 0 */ +#define IE1_VECTOR 2 /* 0x13 external interrupt 1 */ +#define TF1_VECTOR 3 /* 0x1b timer 1 */ +#define SI0_VECTOR 4 /* 0x23 serial port 0 */ +#define TF2_VECTOR 5 /* 0x2B timer 2 */ +#define EX2_VECTOR 5 /* 0x2B external interrupt 2 */ + +#define IADC_VECTOR 8 /* 0x43 A/D converter interrupt */ +#define IEX2_VECTOR 9 /* 0x4B external interrupt 2 */ +#define IEX3_VECTOR 10 /* 0x53 external interrupt 3 */ +#define IEX4_VECTOR 11 /* 0x5B external interrupt 4 */ +#define IEX5_VECTOR 12 /* 0x63 external interrupt 5 */ +#define IEX6_VECTOR 13 /* 0x6B external interrupt 6 */ + +#endif + diff --git a/device/include/ser.h b/device/include/ser.h new file mode 100644 index 00000000..1bf5bd59 --- /dev/null +++ b/device/include/ser.h @@ -0,0 +1,35 @@ +/*KA****************************************************************** +* PROJECT: PLOne/8052 +********************************************************************** +* FILE: ser.h +********************************************************************** +* CHANGES: +* date author description +* -------------------------------------------------------------------- +* 04/26/99 we update +* 04/27/99 we add comments/header +********************************************************************** +* DESCRIPTION: +* This file is the header to be included by modules which use the +* ser.c module. +********************************************************************** +* FUNCTIONS DECLARED: +* see ser.c +********************************************************************** +* COMPILE TIME OPTIONS: - +* DEBUG OPTIONS: - +******************************************************************KE*/ +/* $Id$ */ + +#ifndef _SER_H_ +#define _SER_H_ + +void ser_init(void); +void ser_interrupt_handler(void) interrupt 4 using 1; +void ser_putc(unsigned char); +unsigned char ser_getc(void); +void ser_printString(char *String); +short ser_charAvail(void); + +/*********************End of File************************************/ +#endif diff --git a/device/include/ser_ir.h b/device/include/ser_ir.h new file mode 100644 index 00000000..55c70a7a --- /dev/null +++ b/device/include/ser_ir.h @@ -0,0 +1,41 @@ +/*------------------------------------------------------------------------- + ser_ir.h - header file for serial routines + + Written By - Josef Wolf (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + +-------------------------------------------------------------------------*/ +/* call this one first on startup */ +void ser_init (void); + +/* the following ones should be obvious */ +void ser_putc (unsigned char c); +void ser_puts (unsigned char *s); +void ser_gets (unsigned char *s, unsigned char len); +unsigned char ser_getc (void); + +/* return the number of chars that can be received/transmitted without +* blocking. +*/ +unsigned char ser_can_rcv (void); +unsigned char ser_can_xmt (void); + +/* needs to be defined somewhere :-() */ +void ser_handler (void) interrupt 4; diff --git a/device/include/serial.h b/device/include/serial.h new file mode 100644 index 00000000..a5cca406 --- /dev/null +++ b/device/include/serial.h @@ -0,0 +1,15 @@ +//---------------------------------------------------------------------------- +//Written by Dmitry S. Obukhov, 1996 +// dso@usa.net +//---------------------------------------------------------------------------- +//This module implements serial interrupt handler and IO routinwes using +//two 256 byte cyclic buffers. Bit variables can be used as flags for +//real-time kernel tasks +//Last modified 6 Apr 97 +//---------------------------------------------------------------------------- + +void serial_init(void); +void serial_interrupt_handler(void) interrupt 4 using 1; +void serial_putc(unsigned char); +unsigned char serial_getc(void); +void autobaud(); diff --git a/device/include/setjmp.h b/device/include/setjmp.h new file mode 100644 index 00000000..29c86a98 --- /dev/null +++ b/device/include/setjmp.h @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------- + setjmp.h - header file for setjmp & longjmp ANSI routines + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCC_SETJMP_H +#define SDCC_SETJMP_H + +typedef unsigned char jmp_buf[3]; + +int setjmp (unsigned char _generic *); +int longjmp(unsigned char _generic *,int); + +#endif diff --git a/device/include/stdarg.h b/device/include/stdarg.h new file mode 100644 index 00000000..aa2a8615 --- /dev/null +++ b/device/include/stdarg.h @@ -0,0 +1,24 @@ +/*-----------------------------------------------------------------------------------*/ +/* stdarg.h - ANSI macros for variable parameter list */ +/*-----------------------------------------------------------------------------------*/ + +#ifndef __SDC51_STDARG_H +#define __SDC51_STDARG_H 1 + +#ifdef SDCC_USE_XSTACK + +typedef unsigned char _pdata * va_list ; +#define va_arg(marker,type) *((type _data * )(marker -= sizeof(type))) +#define va_start(marker,first) { marker = (va_list) ((char _pdata * )&first) ; } + +#else + +typedef unsigned char _data * va_list ; +#define va_arg(marker,type) *((type _data * )(marker -= sizeof(type))) +#define va_start(marker,first) { marker = (va_list) ((char _data * )&first) ; } + +#endif + +#define va_end(marker) marker = (va_list) 0; + +#endif diff --git a/device/include/stdio.h b/device/include/stdio.h new file mode 100644 index 00000000..14b575af --- /dev/null +++ b/device/include/stdio.h @@ -0,0 +1,42 @@ +/*------------------------------------------------------------------------- + stdio.h - ANSI functions forward declarations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __SDC51_STDIO_H +#define __SDC51_STDIO_H 1 + +#include + +extern printf_small (char *,...) reentrant; +extern printf (const char *,...) reentrant; +extern int vprintf (const char *, va_list); +extern int sprintf (const char *, const char *, ...) reentrant; +extern int vsprintf (const char *, const char *, va_list); +extern int puts(const char *); +#endif + + + + + + diff --git a/device/include/stdlib.h b/device/include/stdlib.h new file mode 100644 index 00000000..baa85a84 --- /dev/null +++ b/device/include/stdlib.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + stdlib.h - ANSI functions forward declarations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __SDC51_STDLIB_H +#define __SDC51_STDLIB_H 1 + +extern int atoi (char *); +extern long atol (char *); + +#endif + + + + + + diff --git a/device/include/string.h b/device/include/string.h new file mode 100644 index 00000000..356d2f01 --- /dev/null +++ b/device/include/string.h @@ -0,0 +1,74 @@ +/*------------------------------------------------------------------------- + string.h - ANSI functions forward declarations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + + +#ifndef __SDC51_STRING_H +#define __SDC51_STRING_H 1 + +#define memmove memcpy + +#ifdef SDCC_STACK_AUTO +#warning Make sure you recompiled _str*.c and _mem*.c library functions as 'reentrant' + +extern char _generic *strcpy (char _generic *, char _generic *) reentrant ; +extern char _generic *strncpy(char _generic *, char _generic *,int ) reentrant ; +extern char _generic *strcat (char _generic *, char _generic *) reentrant ; +extern char _generic *strncat(char _generic *, char _generic *,int ) reentrant ; +extern int strcmp (char _generic *, char _generic *) reentrant ; +extern int strncmp(char _generic *, char _generic *,int ) reentrant ; +extern char _generic *strchr (char _generic *, char ) reentrant ; +extern char _generic *strrchr(char _generic *, char ) reentrant ; +extern int strspn (char _generic *, char _generic *) reentrant ; +extern int strcspn(char _generic *, char _generic *) reentrant ; +extern char _generic *strpbrk(char _generic *, char _generic *) reentrant ; +extern char _generic *strstr (char _generic *, char _generic *) reentrant ; +extern int strlen (char _generic * ) reentrant ; +extern char _generic *strtok (char _generic *, char _generic *) reentrant ; +extern void _generic *memcpy (void _generic *, void _generic *, int ) reentrant ; +extern int memcmp (void _generic *, void _generic *, int ) reentrant ; +extern void _generic *memset (void _generic *, unsigned char , int ) reentrant ; + +#else + +extern char _generic *strcpy (char _generic *, char _generic *) ; +extern char _generic *strncpy(char _generic *, char _generic *,int ) ; +extern char _generic *strcat (char _generic *, char _generic *) ; +extern char _generic *strncat(char _generic *, char _generic *,int ) ; +extern int strcmp (char _generic *, char _generic *) ; +extern int strncmp(char _generic *, char _generic *,int ) ; +extern char _generic *strchr (char _generic *, char ) ; +extern char _generic *strrchr(char _generic *, char ) ; +extern int strspn (char _generic *, char _generic *) ; +extern int strcspn(char _generic *, char _generic *) ; +extern char _generic *strpbrk(char _generic *, char _generic *) ; +extern char _generic *strstr (char _generic *, char _generic *) ; +extern int strlen (char _generic * ) ; +extern char _generic *strtok (char _generic *, char _generic *) ; +extern void _generic *memcpy (void _generic *, void _generic *, int ) ; +extern int memcmp (void _generic *, void _generic *, int ) ; +extern void _generic *memset (void _generic *, unsigned char , int ) ; + +#endif + +#endif diff --git a/device/include/z80/README b/device/include/z80/README new file mode 100644 index 00000000..460ed2d8 --- /dev/null +++ b/device/include/z80/README @@ -0,0 +1,2 @@ +sdcc/device/lib/z80 +--------------------- diff --git a/device/lib/Makefile b/device/lib/Makefile new file mode 100644 index 00000000..f5c06cc7 --- /dev/null +++ b/device/lib/Makefile @@ -0,0 +1,146 @@ +# Generated automatically from Makefile.in by configure. +# +# +# + +VERSION = 2.1.9Ga +VERSIONHI = 2 +VERSIONLO = 1 +VERSIONP = 9Ga + +SHELL = /bin/sh +CPP = gcc -E +INSTALL = /usr/bin/install -c +CP = cp + +PRJDIR = ../.. +INCDIR = $(PRJDIR)/device/include + +CC = $(PRJDIR)/bin/sdcc +CPP = $(PRJDIR)/bin/sdcpp + +prefix = /usr/local +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +includedir = ${prefix}/include +mandir = ${prefix}/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = ${prefix}/info +srcdir = . + +CPPFLAGS = -I$(INCDIR) +CFLAGS = + +OBJECTS = _atoi.rel _atol.rel _autobaud.rel _bp.rel _char2fs.rel \ + _decdptr.rel _divsint.rel _divslong.rel _divuint.rel \ + _divulong.rel _fs2char.rel _fs2int.rel _fs2long.rel \ + _fs2uchar.rel _fs2uint.rel _fs2ulong.rel _fsadd.rel \ + _fsdiv.rel _fseq.rel _fsgt.rel _fslt.rel _fsmul.rel \ + _fsneq.rel _fssub.rel _gptrget.rel _gptrput.rel \ + _int2fs.rel _iscntrl.rel _isdigit.rel _isgraph.rel \ + _islower.rel _isprint.rel _ispunct.rel _isspace.rel \ + _isupper.rel _isxdigit.rel _long2fs.rel _memcmp.rel \ + _memcpy.rel _memset.rel _modsint.rel _modslong.rel \ + _moduint.rel _modulong.rel _mulsint.rel _muluint.rel \ + _mululong.rel _muslong.rel _ser.rel _setjmp.rel \ + _spx.rel _startup.rel _strchr.rel _strcmp.rel _strcpy.rel \ + _strcspn.rel _strlen.rel _strncat.rel _strncmp.rel \ + _strncpy.rel _strpbrk.rel _strrchr.rel _strspn.rel \ + _strstr.rel _strtok.rel _uchar2fs.rel _uint2fs.rel \ + _ulong2fs.rel malloc.rel serial.rel ser_ir.rel printfl.rel \ + printf_large.rel vprintf.rel puts.rel assert.rel _strcat.rel +SOURCES = $(patsubst %.rel,%.c,$(OBJECTS)) + +include incl.mk + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf models + +objects: $(OBJECTS) + +models: + for model in $(MODELS); do \ + mkdir $$model; \ + $(MAKE) CFLAGS="$(CFLAGS) --model-$$model" objects; \ + mv *.rel $$model; \ + mv *.asm $$model; \ + mv *.cdb $$model; \ + done + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: installdirs + $(CP) *.c $(datadir)/sdcc51lib/ + for model in $(MODELS); do \ + [ -d $$model ] || $(MAKE) all; \ + $(CP) $$model/*.rel *.lib $(datadir)/sdcc51lib/$$model/; \ + $(CP) $$model/*.asm $(datadir)/sdcc51lib/$$model/; \ + $(CP) $$model/*.cdb $(datadir)/sdcc51lib/$$model/; \ + done + + +# Deleting all the installed files +# -------------------------------- +uninstall: + for hdr in *.h; do rm -f $(datadir)/$$hdr; done + for model i $(MODELS); do \ + rm -rf $(datadir)/sdcc51lib/$$model; \ + done + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + [ -d $(datadir)/sdcc51lib ] || mkdir -p $(datadir)/sdcc51lib + for model in $(MODELS); do \ + [ -d $(datadir)/sdcc51lib/$$model ] || \ + mkdir -p $(datadir)/sdcc51lib/$$model; \ + done + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) $(INCDIR)/*.h + for i in $(SOURCES); do \ + $(CPP) -M $(CPPFLAGS) $$i $${i}.dep; \ + cat $${i}.dep >>Makefile.dep; \ + rm $${i}.dep; \ + done + +include Makefile.dep +include clean.mk + +# My rules +# -------- + +.SUFFIXES: .rel + +.c.rel: + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \ + freshconf;\ + fi + +# End of main_in.mk/main.mk diff --git a/device/lib/Makefile.dep b/device/lib/Makefile.dep new file mode 100644 index 00000000..e69de29b diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in new file mode 100644 index 00000000..289ec1d2 --- /dev/null +++ b/device/lib/Makefile.in @@ -0,0 +1,145 @@ +# +# +# + +VERSION = @VERSION@ +VERSIONHI = @VERSIONHI@ +VERSIONLO = @VERSIONLO@ +VERSIONP = @VERSIONP@ + +SHELL = /bin/sh +CPP = @CPP@ +INSTALL = @INSTALL@ +CP = @CP@ + +PRJDIR = ../.. +INCDIR = $(PRJDIR)/device/include + +CC = $(PRJDIR)/bin/sdcc +CPP = $(PRJDIR)/bin/sdcpp + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +datadir = @datadir@ +includedir = @includedir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = @infodir@ +srcdir = @srcdir@ + +CPPFLAGS = -I$(INCDIR) +CFLAGS = + +OBJECTS = _atoi.rel _atol.rel _autobaud.rel _bp.rel _char2fs.rel \ + _decdptr.rel _divsint.rel _divslong.rel _divuint.rel \ + _divulong.rel _fs2char.rel _fs2int.rel _fs2long.rel \ + _fs2uchar.rel _fs2uint.rel _fs2ulong.rel _fsadd.rel \ + _fsdiv.rel _fseq.rel _fsgt.rel _fslt.rel _fsmul.rel \ + _fsneq.rel _fssub.rel _gptrget.rel _gptrput.rel \ + _int2fs.rel _iscntrl.rel _isdigit.rel _isgraph.rel \ + _islower.rel _isprint.rel _ispunct.rel _isspace.rel \ + _isupper.rel _isxdigit.rel _long2fs.rel _memcmp.rel \ + _memcpy.rel _memset.rel _modsint.rel _modslong.rel \ + _moduint.rel _modulong.rel _mulsint.rel _muluint.rel \ + _mululong.rel _muslong.rel _ser.rel _setjmp.rel \ + _spx.rel _startup.rel _strchr.rel _strcmp.rel _strcpy.rel \ + _strcspn.rel _strlen.rel _strncat.rel _strncmp.rel \ + _strncpy.rel _strpbrk.rel _strrchr.rel _strspn.rel \ + _strstr.rel _strtok.rel _uchar2fs.rel _uint2fs.rel \ + _ulong2fs.rel malloc.rel serial.rel ser_ir.rel printfl.rel \ + printf_large.rel vprintf.rel puts.rel assert.rel _strcat.rel +SOURCES = $(patsubst %.rel,%.c,$(OBJECTS)) + +include incl.mk + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf models + +objects: $(OBJECTS) + +models: + for model in $(MODELS); do \ + mkdir $$model; \ + $(MAKE) CFLAGS="$(CFLAGS) --model-$$model" objects; \ + mv *.rel $$model; \ + mv *.asm $$model; \ + mv *.cdb $$model; \ + done + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: installdirs + $(CP) *.c $(datadir)/sdcc51lib/ + for model in $(MODELS); do \ + [ -d $$model ] || $(MAKE) all; \ + $(CP) $$model/*.rel *.lib $(datadir)/sdcc51lib/$$model/; \ + $(CP) $$model/*.asm $(datadir)/sdcc51lib/$$model/; \ + $(CP) $$model/*.cdb $(datadir)/sdcc51lib/$$model/; \ + done + + +# Deleting all the installed files +# -------------------------------- +uninstall: + for hdr in *.h; do rm -f $(datadir)/$$hdr; done + for model i $(MODELS); do \ + rm -rf $(datadir)/sdcc51lib/$$model; \ + done + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + [ -d $(datadir)/sdcc51lib ] || mkdir -p $(datadir)/sdcc51lib + for model in $(MODELS); do \ + [ -d $(datadir)/sdcc51lib/$$model ] || \ + mkdir -p $(datadir)/sdcc51lib/$$model; \ + done + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) $(INCDIR)/*.h + for i in $(SOURCES); do \ + $(CPP) -M $(CPPFLAGS) $$i $${i}.dep; \ + cat $${i}.dep >>Makefile.dep; \ + rm $${i}.dep; \ + done + +include Makefile.dep +include clean.mk + +# My rules +# -------- + +.SUFFIXES: .rel + +.c.rel: + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \ + freshconf;\ + fi + +# End of main_in.mk/main.mk diff --git a/device/lib/_atoi.c b/device/lib/_atoi.c new file mode 100644 index 00000000..0c0036b0 --- /dev/null +++ b/device/lib/_atoi.c @@ -0,0 +1,49 @@ +/*--------------------------------------------------------------------- + atoi - convert a string to an integer and return it + + written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +int atoi(char * s) +{ + register int rv=0; + register char sign = 0; + + /* skip till we find either a digit or '+' or '-' */ + while (*s) { + if (*s <= '9' && *s >= '0') + break; + if (*s == '-' || *s == '+') + break; + s++; + } + + sign = (*s == '-'); + if (*s == '-' || *s == '+') s++; + + while (*s && *s >= '0' && *s <= '9') { + rv = (rv * 10) + (*s - '0'); + s++; + } + + return (sign ? -rv : rv); +} + diff --git a/device/lib/_atoi.lst b/device/lib/_atoi.lst new file mode 100644 index 00000000..cb6fccb9 --- /dev/null +++ b/device/lib/_atoi.lst @@ -0,0 +1,335 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _atoi + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _atoi + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _atoi_s_1_1: + 0000 38 .ds 0x0003 + 0003 39 _atoi_rv_1_1: + 0003 40 .ds 0x0002 + 41 ;-------------------------------------------------------- + 42 ; global & static initialisations + 43 ;-------------------------------------------------------- + 44 .area GSINIT (CODE) + 45 ;-------------------------------------------------------- + 46 ; code + 47 ;-------------------------------------------------------- + 48 .area CSEG (CODE) + 0000 49 G$atoi$0$0 ==. + 50 ; _atoi.c 25 + 51 ; ----------------------------------------- + 52 ; function atoi + 53 ; ----------------------------------------- + 0000 54 _atoi: + 0002 55 ar2 = 0x02 + 0003 56 ar3 = 0x03 + 0004 57 ar4 = 0x04 + 0005 58 ar5 = 0x05 + 0006 59 ar6 = 0x06 + 0007 60 ar7 = 0x07 + 0000 61 ar0 = 0x00 + 0001 62 ar1 = 0x01 + 63 ; _atoi.c 0 + 0000 C0 F0 64 push b + 0002 C0 83 65 push dph + 0004 C0 82 66 push dpl + 0006 90s00r00 67 mov dptr,#_atoi_s_1_1 + 0009 D0 E0 68 pop acc + 000B F0 69 movx @dptr,a + 000C D0 E0 70 pop acc + 000E A3 71 inc dptr + 000F F0 72 movx @dptr,a + 0010 D0 E0 73 pop acc + 0012 A3 74 inc dptr + 0013 F0 75 movx @dptr,a + 76 ; _atoi.c 27 + 0014 90s00r03 77 mov dptr,#_atoi_rv_1_1 + 0017 E4 78 clr a + 0018 A3 79 inc dptr + 0019 F0 80 movx @dptr,a + 001A 12s00r00 81 lcall __decdptr + 001D F0 82 movx @dptr,a + 83 ; _atoi.c 31 + 001E 90s00r00 84 mov dptr,#_atoi_s_1_1 + 0021 E0 85 movx a,@dptr + 0022 FA 86 mov r2,a + 0023 A3 87 inc dptr + 0024 E0 88 movx a,@dptr + 0025 FB 89 mov r3,a + 0026 A3 90 inc dptr + 0027 E0 91 movx a,@dptr + 0028 FC 92 mov r4,a + 0029 93 00107$: + 0029 8A 82 94 mov dpl,r2 + 002B 8B 83 95 mov dph,r3 + 002D 8C F0 96 mov b,r4 + 002F 12s00r00 97 lcall __gptrget + 98 ; Peephole 105 removed redundant mov + 0032 FD 99 mov r5,a + 100 ; Peephole 110 removed ljmp by inverse jump logic + 0033 60 30 101 jz 00109$ + 0035 102 00133$: + 103 ; _atoi.c 32 + 0035 C3 104 clr c + 105 ; Peephole 159 avoided xrl during execution + 0036 74 B9 106 mov a,#(0x39 ^ 0x80) + 0038 8D F0 107 mov b,r5 + 003A 63 F0 80 108 xrl b,#0x80 + 003D 95 F0 109 subb a,b + 110 ; Peephole 132 changed ljmp to sjmp + 111 ; Peephole 160 removed sjmp by inverse jump logic + 003F 40 08 112 jc 00102$ + 0041 113 00134$: + 0041 C3 114 clr c + 0042 ED 115 mov a,r5 + 0043 64 80 116 xrl a,#0x80 + 0045 94 B0 117 subb a,#0xb0 + 118 ; Peephole 108 removed ljmp by inverse jump logic + 0047 50 1C 119 jnc 00109$ + 0049 120 00135$: + 121 ; _atoi.c 33 + 0049 122 00102$: + 123 ; _atoi.c 34 + 0049 BD 2D 02 124 cjne r5,#0x2d,00136$ + 125 ; Peephole 132 changed ljmp to sjmp + 004C 80 17 126 sjmp 00109$ + 004E 127 00136$: + 004E BD 2B 02 128 cjne r5,#0x2b,00137$ + 129 ; Peephole 132 changed ljmp to sjmp + 0051 80 12 130 sjmp 00109$ + 0053 131 00137$: + 132 ; _atoi.c 36 + 0053 0A 133 inc r2 + 0054 BA 00 01 134 cjne r2,#0x00,00138$ + 0057 0B 135 inc r3 + 0058 136 00138$: + 0058 90s00r00 137 mov dptr,#_atoi_s_1_1 + 005B EA 138 mov a,r2 + 005C F0 139 movx @dptr,a + 005D A3 140 inc dptr + 005E EB 141 mov a,r3 + 005F F0 142 movx @dptr,a + 0060 A3 143 inc dptr + 0061 EC 144 mov a,r4 + 0062 F0 145 movx @dptr,a + 146 ; Peephole 132 changed ljmp to sjmp + 0063 80 C4 147 sjmp 00107$ + 0065 148 00109$: + 149 ; _atoi.c 39 + 0065 90s00r00 150 mov dptr,#_atoi_s_1_1 + 0068 EA 151 mov a,r2 + 0069 F0 152 movx @dptr,a + 006A A3 153 inc dptr + 006B EB 154 mov a,r3 + 006C F0 155 movx @dptr,a + 006D A3 156 inc dptr + 006E EC 157 mov a,r4 + 006F F0 158 movx @dptr,a + 0070 8A 82 159 mov dpl,r2 + 0072 8B 83 160 mov dph,r3 + 0074 8C F0 161 mov b,r4 + 0076 12s00r00 162 lcall __gptrget + 0079 FD 163 mov r5,a + 007A BD 2D 04 164 cjne r5,#0x2d,00139$ + 007D 74 01 165 mov a,#0x01 + 007F 80 01 166 sjmp 00140$ + 0081 167 00139$: + 0081 E4 168 clr a + 0082 169 00140$: + 170 ; _atoi.c 40 + 171 ; Peephole 105 removed redundant mov + 0082 FE 172 mov r6,a + 173 ; Peephole 109 removed ljmp by inverse jump logic + 0083 70 03 174 jnz 00110$ + 0085 175 00141$: + 176 ; Peephole 132 changed ljmp to sjmp + 177 ; Peephole 199 optimized misc jump sequence + 0085 BD 2B 0E 178 cjne r5,#0x2b,00131$ + 179 ; Peephole 201 removed redundant sjmp + 0088 180 00142$: + 0088 181 00143$: + 0088 182 00110$: + 0088 90s00r00 183 mov dptr,#_atoi_s_1_1 + 008B 74 01 184 mov a,#0x01 + 008D 2A 185 add a,r2 + 008E F0 186 movx @dptr,a + 187 ; Peephole 180 changed mov to clr + 008F E4 188 clr a + 0090 3B 189 addc a,r3 + 0091 A3 190 inc dptr + 0092 F0 191 movx @dptr,a + 0093 A3 192 inc dptr + 0094 EC 193 mov a,r4 + 0095 F0 194 movx @dptr,a + 195 ; _atoi.c 42 + 0096 196 00131$: + 0096 90s00r00 197 mov dptr,#_atoi_s_1_1 + 0099 E0 198 movx a,@dptr + 009A FA 199 mov r2,a + 009B A3 200 inc dptr + 009C E0 201 movx a,@dptr + 009D FB 202 mov r3,a + 009E A3 203 inc dptr + 009F E0 204 movx a,@dptr + 00A0 FC 205 mov r4,a + 00A1 206 00115$: + 00A1 8A 82 207 mov dpl,r2 + 00A3 8B 83 208 mov dph,r3 + 00A5 8C F0 209 mov b,r4 + 00A7 12s00r00 210 lcall __gptrget + 211 ; Peephole 105 removed redundant mov + 00AA FD 212 mov r5,a + 00AB 70 03 213 jnz 00144$ + 00AD 02s01r22 214 ljmp 00117$ + 00B0 215 00144$: + 00B0 C3 216 clr c + 00B1 ED 217 mov a,r5 + 00B2 64 80 218 xrl a,#0x80 + 00B4 94 B0 219 subb a,#0xb0 + 00B6 50 03 220 jnc 00145$ + 00B8 02s01r22 221 ljmp 00117$ + 00BB 222 00145$: + 00BB C3 223 clr c + 224 ; Peephole 159 avoided xrl during execution + 00BC 74 B9 225 mov a,#(0x39 ^ 0x80) + 00BE 8D F0 226 mov b,r5 + 00C0 63 F0 80 227 xrl b,#0x80 + 00C3 95 F0 228 subb a,b + 00C5 50 03 229 jnc 00146$ + 00C7 02s01r22 230 ljmp 00117$ + 00CA 231 00146$: + 232 ; _atoi.c 43 + 00CA 90s00r03 233 mov dptr,#_atoi_rv_1_1 + 00CD E0 234 movx a,@dptr + 00CE FF 235 mov r7,a + 00CF A3 236 inc dptr + 00D0 E0 237 movx a,@dptr + 00D1 F8 238 mov r0,a + 00D2 90s00r00 239 mov dptr,#__mulsint_PARM_2 + 00D5 E4 240 clr a + 00D6 A3 241 inc dptr + 00D7 F0 242 movx @dptr,a + 00D8 12s00r00 243 lcall __decdptr + 00DB 74 0A 244 mov a,#0x0a + 00DD F0 245 movx @dptr,a + 00DE C0 02 246 push ar2 + 00E0 C0 03 247 push ar3 + 00E2 C0 04 248 push ar4 + 00E4 C0 05 249 push ar5 + 00E6 C0 06 250 push ar6 + 00E8 8F 82 251 mov dpl,r7 + 00EA 88 83 252 mov dph,r0 + 00EC 12s00r00 253 lcall __mulsint + 00EF AF 82 254 mov r7,dpl + 00F1 A8 83 255 mov r0,dph + 00F3 D0 06 256 pop ar6 + 00F5 D0 05 257 pop ar5 + 00F7 D0 04 258 pop ar4 + 00F9 D0 03 259 pop ar3 + 00FB D0 02 260 pop ar2 + 00FD ED 261 mov a,r5 + 00FE 24 D0 262 add a,#0xd0 + 0100 FD 263 mov r5,a + 264 ; Peephole 180 changed mov to clr + 0101 E4 265 clr a + 0102 34 FF 266 addc a,#0xff + 0104 F9 267 mov r1,a + 0105 90s00r03 268 mov dptr,#_atoi_rv_1_1 + 0108 ED 269 mov a,r5 + 0109 2F 270 add a,r7 + 010A F0 271 movx @dptr,a + 010B E9 272 mov a,r1 + 010C 38 273 addc a,r0 + 010D A3 274 inc dptr + 010E F0 275 movx @dptr,a + 276 ; _atoi.c 44 + 010F 0A 277 inc r2 + 0110 BA 00 01 278 cjne r2,#0x00,00147$ + 0113 0B 279 inc r3 + 0114 280 00147$: + 0114 90s00r00 281 mov dptr,#_atoi_s_1_1 + 0117 EA 282 mov a,r2 + 0118 F0 283 movx @dptr,a + 0119 A3 284 inc dptr + 011A EB 285 mov a,r3 + 011B F0 286 movx @dptr,a + 011C A3 287 inc dptr + 011D EC 288 mov a,r4 + 011E F0 289 movx @dptr,a + 011F 02s00rA1 290 ljmp 00115$ + 0122 291 00117$: + 292 ; _atoi.c 47 + 0122 90s00r00 293 mov dptr,#_atoi_s_1_1 + 0125 EA 294 mov a,r2 + 0126 F0 295 movx @dptr,a + 0127 A3 296 inc dptr + 0128 EB 297 mov a,r3 + 0129 F0 298 movx @dptr,a + 012A A3 299 inc dptr + 012B EC 300 mov a,r4 + 012C F0 301 movx @dptr,a + 012D EE 302 mov a,r6 + 303 ; Peephole 110 removed ljmp by inverse jump logic + 012E 60 11 304 jz 00120$ + 0130 305 00148$: + 0130 90s00r03 306 mov dptr,#_atoi_rv_1_1 + 0133 E0 307 movx a,@dptr + 0134 FA 308 mov r2,a + 0135 A3 309 inc dptr + 0136 E0 310 movx a,@dptr + 0137 FB 311 mov r3,a + 0138 C3 312 clr c + 0139 E4 313 clr a + 013A 9A 314 subb a,r2 + 013B FA 315 mov r2,a + 013C E4 316 clr a + 013D 9B 317 subb a,r3 + 013E FB 318 mov r3,a + 319 ; Peephole 132 changed ljmp to sjmp + 013F 80 08 320 sjmp 00121$ + 0141 321 00120$: + 0141 90s00r03 322 mov dptr,#_atoi_rv_1_1 + 0144 E0 323 movx a,@dptr + 0145 FA 324 mov r2,a + 0146 A3 325 inc dptr + 0147 E0 326 movx a,@dptr + 0148 FB 327 mov r3,a + 0149 328 00121$: + 0149 8A 82 329 mov dpl,r2 + 014B 8B 83 330 mov dph,r3 + 014D 331 00118$: + 014D 332 C$_atoi.c$48$1$1 ==. + 014D 333 XG$atoi$0$0 ==. + 014D 22 334 ret + 335 .area CSEG (CODE) diff --git a/device/lib/_atoi.sym b/device/lib/_atoi.sym new file mode 100644 index 00000000..d5731137 --- /dev/null +++ b/device/lib/_atoi.sym @@ -0,0 +1,582 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_atoi$101 0033 GR + 7 A$_atoi$104 0035 GR + 7 A$_atoi$106 0036 GR + 7 A$_atoi$107 0038 GR + 7 A$_atoi$108 003A GR + 7 A$_atoi$109 003D GR + 7 A$_atoi$112 003F GR + 7 A$_atoi$114 0041 GR + 7 A$_atoi$115 0042 GR + 7 A$_atoi$116 0043 GR + 7 A$_atoi$117 0045 GR + 7 A$_atoi$119 0047 GR + 7 A$_atoi$124 0049 GR + 7 A$_atoi$126 004C GR + 7 A$_atoi$128 004E GR + 7 A$_atoi$130 0051 GR + 7 A$_atoi$133 0053 GR + 7 A$_atoi$134 0054 GR + 7 A$_atoi$135 0057 GR + 7 A$_atoi$137 0058 GR + 7 A$_atoi$138 005B GR + 7 A$_atoi$139 005C GR + 7 A$_atoi$140 005D GR + 7 A$_atoi$141 005E GR + 7 A$_atoi$142 005F GR + 7 A$_atoi$143 0060 GR + 7 A$_atoi$144 0061 GR + 7 A$_atoi$145 0062 GR + 7 A$_atoi$147 0063 GR + 7 A$_atoi$150 0065 GR + 7 A$_atoi$151 0068 GR + 7 A$_atoi$152 0069 GR + 7 A$_atoi$153 006A GR + 7 A$_atoi$154 006B GR + 7 A$_atoi$155 006C GR + 7 A$_atoi$156 006D GR + 7 A$_atoi$157 006E GR + 7 A$_atoi$158 006F GR + 7 A$_atoi$159 0070 GR + 7 A$_atoi$160 0072 GR + 7 A$_atoi$161 0074 GR + 7 A$_atoi$162 0076 GR + 7 A$_atoi$163 0079 GR + 7 A$_atoi$164 007A GR + 7 A$_atoi$165 007D GR + 7 A$_atoi$166 007F GR + 7 A$_atoi$168 0081 GR + 7 A$_atoi$172 0082 GR + 7 A$_atoi$174 0083 GR + 7 A$_atoi$178 0085 GR + 7 A$_atoi$183 0088 GR + 7 A$_atoi$184 008B GR + 7 A$_atoi$185 008D GR + 7 A$_atoi$186 008E GR + 7 A$_atoi$188 008F GR + 7 A$_atoi$189 0090 GR + 7 A$_atoi$190 0091 GR + 7 A$_atoi$191 0092 GR + 7 A$_atoi$192 0093 GR + 7 A$_atoi$193 0094 GR + 7 A$_atoi$194 0095 GR + 7 A$_atoi$197 0096 GR + 7 A$_atoi$198 0099 GR + 7 A$_atoi$199 009A GR + 7 A$_atoi$200 009B GR + 7 A$_atoi$201 009C GR + 7 A$_atoi$202 009D GR + 7 A$_atoi$203 009E GR + 7 A$_atoi$204 009F GR + 7 A$_atoi$205 00A0 GR + 7 A$_atoi$207 00A1 GR + 7 A$_atoi$208 00A3 GR + 7 A$_atoi$209 00A5 GR + 7 A$_atoi$210 00A7 GR + 7 A$_atoi$212 00AA GR + 7 A$_atoi$213 00AB GR + 7 A$_atoi$214 00AD GR + 7 A$_atoi$216 00B0 GR + 7 A$_atoi$217 00B1 GR + 7 A$_atoi$218 00B2 GR + 7 A$_atoi$219 00B4 GR + 7 A$_atoi$220 00B6 GR + 7 A$_atoi$221 00B8 GR + 7 A$_atoi$223 00BB GR + 7 A$_atoi$225 00BC GR + 7 A$_atoi$226 00BE GR + 7 A$_atoi$227 00C0 GR + 7 A$_atoi$228 00C3 GR + 7 A$_atoi$229 00C5 GR + 7 A$_atoi$230 00C7 GR + 7 A$_atoi$233 00CA GR + 7 A$_atoi$234 00CD GR + 7 A$_atoi$235 00CE GR + 7 A$_atoi$236 00CF GR + 7 A$_atoi$237 00D0 GR + 7 A$_atoi$238 00D1 GR + 7 A$_atoi$239 00D2 GR + 7 A$_atoi$240 00D5 GR + 7 A$_atoi$241 00D6 GR + 7 A$_atoi$242 00D7 GR + 7 A$_atoi$243 00D8 GR + 7 A$_atoi$244 00DB GR + 7 A$_atoi$245 00DD GR + 7 A$_atoi$246 00DE GR + 7 A$_atoi$247 00E0 GR + 7 A$_atoi$248 00E2 GR + 7 A$_atoi$249 00E4 GR + 7 A$_atoi$250 00E6 GR + 7 A$_atoi$251 00E8 GR + 7 A$_atoi$252 00EA GR + 7 A$_atoi$253 00EC GR + 7 A$_atoi$254 00EF GR + 7 A$_atoi$255 00F1 GR + 7 A$_atoi$256 00F3 GR + 7 A$_atoi$257 00F5 GR + 7 A$_atoi$258 00F7 GR + 7 A$_atoi$259 00F9 GR + 7 A$_atoi$260 00FB GR + 7 A$_atoi$261 00FD GR + 7 A$_atoi$262 00FE GR + 7 A$_atoi$263 0100 GR + 7 A$_atoi$265 0101 GR + 7 A$_atoi$266 0102 GR + 7 A$_atoi$267 0104 GR + 7 A$_atoi$268 0105 GR + 7 A$_atoi$269 0108 GR + 7 A$_atoi$270 0109 GR + 7 A$_atoi$271 010A GR + 7 A$_atoi$272 010B GR + 7 A$_atoi$273 010C GR + 7 A$_atoi$274 010D GR + 7 A$_atoi$275 010E GR + 7 A$_atoi$277 010F GR + 7 A$_atoi$278 0110 GR + 7 A$_atoi$279 0113 GR + 7 A$_atoi$281 0114 GR + 7 A$_atoi$282 0117 GR + 7 A$_atoi$283 0118 GR + 7 A$_atoi$284 0119 GR + 7 A$_atoi$285 011A GR + 7 A$_atoi$286 011B GR + 7 A$_atoi$287 011C GR + 7 A$_atoi$288 011D GR + 7 A$_atoi$289 011E GR + 7 A$_atoi$290 011F GR + 7 A$_atoi$293 0122 GR + 7 A$_atoi$294 0125 GR + 7 A$_atoi$295 0126 GR + 7 A$_atoi$296 0127 GR + 7 A$_atoi$297 0128 GR + 7 A$_atoi$298 0129 GR + 7 A$_atoi$299 012A GR + 7 A$_atoi$300 012B GR + 7 A$_atoi$301 012C GR + 7 A$_atoi$302 012D GR + 7 A$_atoi$304 012E GR + 7 A$_atoi$306 0130 GR + 7 A$_atoi$307 0133 GR + 7 A$_atoi$308 0134 GR + 7 A$_atoi$309 0135 GR + 7 A$_atoi$310 0136 GR + 7 A$_atoi$311 0137 GR + 7 A$_atoi$312 0138 GR + 7 A$_atoi$313 0139 GR + 7 A$_atoi$314 013A GR + 7 A$_atoi$315 013B GR + 7 A$_atoi$316 013C GR + 7 A$_atoi$317 013D GR + 7 A$_atoi$318 013E GR + 7 A$_atoi$320 013F GR + 7 A$_atoi$322 0141 GR + 7 A$_atoi$323 0144 GR + 7 A$_atoi$324 0145 GR + 7 A$_atoi$325 0146 GR + 7 A$_atoi$326 0147 GR + 7 A$_atoi$327 0148 GR + 7 A$_atoi$329 0149 GR + 7 A$_atoi$330 014B GR + 7 A$_atoi$334 014D GR + 7 A$_atoi$64 0000 GR + 7 A$_atoi$65 0002 GR + 7 A$_atoi$66 0004 GR + 7 A$_atoi$67 0006 GR + 7 A$_atoi$68 0009 GR + 7 A$_atoi$69 000B GR + 7 A$_atoi$70 000C GR + 7 A$_atoi$71 000E GR + 7 A$_atoi$72 000F GR + 7 A$_atoi$73 0010 GR + 7 A$_atoi$74 0012 GR + 7 A$_atoi$75 0013 GR + 7 A$_atoi$77 0014 GR + 7 A$_atoi$78 0017 GR + 7 A$_atoi$79 0018 GR + 7 A$_atoi$80 0019 GR + 7 A$_atoi$81 001A GR + 7 A$_atoi$82 001D GR + 7 A$_atoi$84 001E GR + 7 A$_atoi$85 0021 GR + 7 A$_atoi$86 0022 GR + 7 A$_atoi$87 0023 GR + 7 A$_atoi$88 0024 GR + 7 A$_atoi$89 0025 GR + 7 A$_atoi$90 0026 GR + 7 A$_atoi$91 0027 GR + 7 A$_atoi$92 0028 GR + 7 A$_atoi$94 0029 GR + 7 A$_atoi$95 002B GR + 7 A$_atoi$96 002D GR + 7 A$_atoi$97 002F GR + 7 A$_atoi$99 0032 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_atoi.c$48$1$1 = 014D GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$atoi$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$atoi$0$0 = 014D GR + __decdptr **** GX + __gptrget **** GX + __mulsint **** GX + __mulsint_PARM_2 **** GX + 7 _atoi 0000 GR + 5 _atoi_rv_1_1 0003 R + 5 _atoi_s_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 5 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 14E flags 20 diff --git a/device/lib/_atol.c b/device/lib/_atol.c new file mode 100644 index 00000000..9655c275 --- /dev/null +++ b/device/lib/_atol.c @@ -0,0 +1,49 @@ +/*--------------------------------------------------------------------- + atol - convert a string to long integer and return it + + written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +long atol(char * s) +{ + register long rv=0; + register char sign = 0; + + /* skip till we find either a digit or '+' or '-' */ + while (*s) { + if (*s <= '9' && *s >= '0') + break; + if (*s == '-' || *s == '+') + break; + s++; + } + + sign = (*s == '-'); + if (*s == '-' || *s == '+') s++; + + while (*s && *s >= '0' && *s <= '9') { + rv = (rv * 10) + (*s - '0'); + s++; + } + + return (sign ? -rv : rv); +} + diff --git a/device/lib/_atol.lst b/device/lib/_atol.lst new file mode 100644 index 00000000..839f144a --- /dev/null +++ b/device/lib/_atol.lst @@ -0,0 +1,397 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _atol + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _atol + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 _atol_sloc0_1_0: + 0000 22 .ds 0x0004 + 23 ;-------------------------------------------------------- + 24 ; overlayable items in internal ram + 25 ;-------------------------------------------------------- + 26 .area OSEG (OVR,DATA) + 27 ;-------------------------------------------------------- + 28 ; indirectly addressable internal ram data + 29 ;-------------------------------------------------------- + 30 .area ISEG (DATA) + 31 ;-------------------------------------------------------- + 32 ; bit data + 33 ;-------------------------------------------------------- + 34 .area BSEG (BIT) + 35 ;-------------------------------------------------------- + 36 ; external ram data + 37 ;-------------------------------------------------------- + 38 .area XSEG (XDATA) + 0000 39 _atol_s_1_1: + 0000 40 .ds 0x0003 + 0003 41 _atol_rv_1_1: + 0003 42 .ds 0x0004 + 43 ;-------------------------------------------------------- + 44 ; global & static initialisations + 45 ;-------------------------------------------------------- + 46 .area GSINIT (CODE) + 47 ;-------------------------------------------------------- + 48 ; code + 49 ;-------------------------------------------------------- + 50 .area CSEG (CODE) + 0000 51 G$atol$0$0 ==. + 52 ; _atol.c 25 + 53 ; ----------------------------------------- + 54 ; function atol + 55 ; ----------------------------------------- + 0000 56 _atol: + 0002 57 ar2 = 0x02 + 0003 58 ar3 = 0x03 + 0004 59 ar4 = 0x04 + 0005 60 ar5 = 0x05 + 0006 61 ar6 = 0x06 + 0007 62 ar7 = 0x07 + 0000 63 ar0 = 0x00 + 0001 64 ar1 = 0x01 + 65 ; _atol.c 0 + 0000 C0 F0 66 push b + 0002 C0 83 67 push dph + 0004 C0 82 68 push dpl + 0006 90s00r00 69 mov dptr,#_atol_s_1_1 + 0009 D0 E0 70 pop acc + 000B F0 71 movx @dptr,a + 000C D0 E0 72 pop acc + 000E A3 73 inc dptr + 000F F0 74 movx @dptr,a + 0010 D0 E0 75 pop acc + 0012 A3 76 inc dptr + 0013 F0 77 movx @dptr,a + 78 ; _atol.c 27 + 0014 90s00r03 79 mov dptr,#_atol_rv_1_1 + 0017 E4 80 clr a + 0018 A3 81 inc dptr + 0019 A3 82 inc dptr + 001A A3 83 inc dptr + 001B F0 84 movx @dptr,a + 001C 12s00r00 85 lcall __decdptr + 001F F0 86 movx @dptr,a + 0020 12s00r00 87 lcall __decdptr + 0023 F0 88 movx @dptr,a + 0024 12s00r00 89 lcall __decdptr + 0027 F0 90 movx @dptr,a + 91 ; _atol.c 31 + 0028 90s00r00 92 mov dptr,#_atol_s_1_1 + 002B E0 93 movx a,@dptr + 002C FA 94 mov r2,a + 002D A3 95 inc dptr + 002E E0 96 movx a,@dptr + 002F FB 97 mov r3,a + 0030 A3 98 inc dptr + 0031 E0 99 movx a,@dptr + 0032 FC 100 mov r4,a + 0033 101 00107$: + 0033 8A 82 102 mov dpl,r2 + 0035 8B 83 103 mov dph,r3 + 0037 8C F0 104 mov b,r4 + 0039 12s00r00 105 lcall __gptrget + 106 ; Peephole 105 removed redundant mov + 003C FD 107 mov r5,a + 108 ; Peephole 110 removed ljmp by inverse jump logic + 003D 60 30 109 jz 00109$ + 003F 110 00133$: + 111 ; _atol.c 32 + 003F C3 112 clr c + 113 ; Peephole 159 avoided xrl during execution + 0040 74 B9 114 mov a,#(0x39 ^ 0x80) + 0042 8D F0 115 mov b,r5 + 0044 63 F0 80 116 xrl b,#0x80 + 0047 95 F0 117 subb a,b + 118 ; Peephole 132 changed ljmp to sjmp + 119 ; Peephole 160 removed sjmp by inverse jump logic + 0049 40 08 120 jc 00102$ + 004B 121 00134$: + 004B C3 122 clr c + 004C ED 123 mov a,r5 + 004D 64 80 124 xrl a,#0x80 + 004F 94 B0 125 subb a,#0xb0 + 126 ; Peephole 108 removed ljmp by inverse jump logic + 0051 50 1C 127 jnc 00109$ + 0053 128 00135$: + 129 ; _atol.c 33 + 0053 130 00102$: + 131 ; _atol.c 34 + 0053 BD 2D 02 132 cjne r5,#0x2d,00136$ + 133 ; Peephole 132 changed ljmp to sjmp + 0056 80 17 134 sjmp 00109$ + 0058 135 00136$: + 0058 BD 2B 02 136 cjne r5,#0x2b,00137$ + 137 ; Peephole 132 changed ljmp to sjmp + 005B 80 12 138 sjmp 00109$ + 005D 139 00137$: + 140 ; _atol.c 36 + 005D 0A 141 inc r2 + 005E BA 00 01 142 cjne r2,#0x00,00138$ + 0061 0B 143 inc r3 + 0062 144 00138$: + 0062 90s00r00 145 mov dptr,#_atol_s_1_1 + 0065 EA 146 mov a,r2 + 0066 F0 147 movx @dptr,a + 0067 A3 148 inc dptr + 0068 EB 149 mov a,r3 + 0069 F0 150 movx @dptr,a + 006A A3 151 inc dptr + 006B EC 152 mov a,r4 + 006C F0 153 movx @dptr,a + 154 ; Peephole 132 changed ljmp to sjmp + 006D 80 C4 155 sjmp 00107$ + 006F 156 00109$: + 157 ; _atol.c 39 + 006F 90s00r00 158 mov dptr,#_atol_s_1_1 + 0072 EA 159 mov a,r2 + 0073 F0 160 movx @dptr,a + 0074 A3 161 inc dptr + 0075 EB 162 mov a,r3 + 0076 F0 163 movx @dptr,a + 0077 A3 164 inc dptr + 0078 EC 165 mov a,r4 + 0079 F0 166 movx @dptr,a + 007A 8A 82 167 mov dpl,r2 + 007C 8B 83 168 mov dph,r3 + 007E 8C F0 169 mov b,r4 + 0080 12s00r00 170 lcall __gptrget + 0083 FD 171 mov r5,a + 0084 BD 2D 04 172 cjne r5,#0x2d,00139$ + 0087 74 01 173 mov a,#0x01 + 0089 80 01 174 sjmp 00140$ + 008B 175 00139$: + 008B E4 176 clr a + 008C 177 00140$: + 178 ; _atol.c 40 + 179 ; Peephole 105 removed redundant mov + 008C FE 180 mov r6,a + 181 ; Peephole 109 removed ljmp by inverse jump logic + 008D 70 03 182 jnz 00110$ + 008F 183 00141$: + 184 ; Peephole 132 changed ljmp to sjmp + 185 ; Peephole 199 optimized misc jump sequence + 008F BD 2B 0E 186 cjne r5,#0x2b,00131$ + 187 ; Peephole 201 removed redundant sjmp + 0092 188 00142$: + 0092 189 00143$: + 0092 190 00110$: + 0092 90s00r00 191 mov dptr,#_atol_s_1_1 + 0095 74 01 192 mov a,#0x01 + 0097 2A 193 add a,r2 + 0098 F0 194 movx @dptr,a + 195 ; Peephole 180 changed mov to clr + 0099 E4 196 clr a + 009A 3B 197 addc a,r3 + 009B A3 198 inc dptr + 009C F0 199 movx @dptr,a + 009D A3 200 inc dptr + 009E EC 201 mov a,r4 + 009F F0 202 movx @dptr,a + 203 ; _atol.c 42 + 00A0 204 00131$: + 00A0 90s00r00 205 mov dptr,#_atol_s_1_1 + 00A3 E0 206 movx a,@dptr + 00A4 FA 207 mov r2,a + 00A5 A3 208 inc dptr + 00A6 E0 209 movx a,@dptr + 00A7 FB 210 mov r3,a + 00A8 A3 211 inc dptr + 00A9 E0 212 movx a,@dptr + 00AA FC 213 mov r4,a + 00AB 214 00115$: + 00AB 8A 82 215 mov dpl,r2 + 00AD 8B 83 216 mov dph,r3 + 00AF 8C F0 217 mov b,r4 + 00B1 12s00r00 218 lcall __gptrget + 219 ; Peephole 105 removed redundant mov + 00B4 FD 220 mov r5,a + 00B5 70 03 221 jnz 00144$ + 00B7 02s01r5E 222 ljmp 00117$ + 00BA 223 00144$: + 00BA C3 224 clr c + 00BB ED 225 mov a,r5 + 00BC 64 80 226 xrl a,#0x80 + 00BE 94 B0 227 subb a,#0xb0 + 00C0 50 03 228 jnc 00145$ + 00C2 02s01r5E 229 ljmp 00117$ + 00C5 230 00145$: + 00C5 C3 231 clr c + 232 ; Peephole 159 avoided xrl during execution + 00C6 74 B9 233 mov a,#(0x39 ^ 0x80) + 00C8 8D F0 234 mov b,r5 + 00CA 63 F0 80 235 xrl b,#0x80 + 00CD 95 F0 236 subb a,b + 00CF 50 03 237 jnc 00146$ + 00D1 02s01r5E 238 ljmp 00117$ + 00D4 239 00146$: + 240 ; _atol.c 43 + 00D4 C0 06 241 push ar6 + 00D6 90s00r03 242 mov dptr,#_atol_rv_1_1 + 00D9 E0 243 movx a,@dptr + 00DA FF 244 mov r7,a + 00DB A3 245 inc dptr + 00DC E0 246 movx a,@dptr + 00DD F8 247 mov r0,a + 00DE A3 248 inc dptr + 00DF E0 249 movx a,@dptr + 00E0 F9 250 mov r1,a + 00E1 A3 251 inc dptr + 00E2 E0 252 movx a,@dptr + 00E3 FE 253 mov r6,a + 00E4 90s00r00 254 mov dptr,#__mulslong_PARM_2 + 00E7 E4 255 clr a + 00E8 A3 256 inc dptr + 00E9 A3 257 inc dptr + 00EA A3 258 inc dptr + 00EB F0 259 movx @dptr,a + 00EC 12s00r00 260 lcall __decdptr + 00EF F0 261 movx @dptr,a + 00F0 12s00r00 262 lcall __decdptr + 00F3 F0 263 movx @dptr,a + 00F4 12s00r00 264 lcall __decdptr + 00F7 74 0A 265 mov a,#0x0a + 00F9 F0 266 movx @dptr,a + 00FA C0 02 267 push ar2 + 00FC C0 03 268 push ar3 + 00FE C0 04 269 push ar4 + 0100 C0 05 270 push ar5 + 0102 C0 06 271 push ar6 + 0104 8F 82 272 mov dpl,r7 + 0106 88 83 273 mov dph,r0 + 0108 89 F0 274 mov b,r1 + 010A EE 275 mov a,r6 + 010B 12s00r00 276 lcall __mulslong + 010E 85 82*00 277 mov _atol_sloc0_1_0,dpl + 0111 85 83*01 278 mov (_atol_sloc0_1_0 + 1),dph + 0114 85 F0*02 279 mov (_atol_sloc0_1_0 + 2),b + 0117 F5*03 280 mov (_atol_sloc0_1_0 + 3),a + 0119 D0 06 281 pop ar6 + 011B D0 05 282 pop ar5 + 011D D0 04 283 pop ar4 + 011F D0 03 284 pop ar3 + 0121 D0 02 285 pop ar2 + 0123 ED 286 mov a,r5 + 0124 24 D0 287 add a,#0xd0 + 0126 FD 288 mov r5,a + 289 ; Peephole 180 changed mov to clr + 0127 E4 290 clr a + 0128 34 FF 291 addc a,#0xff + 012A FE 292 mov r6,a + 293 ; Peephole 180 changed mov to clr + 012B E4 294 clr a + 012C 34 FF 295 addc a,#0xff + 012E FF 296 mov r7,a + 297 ; Peephole 180 changed mov to clr + 012F E4 298 clr a + 0130 34 FF 299 addc a,#0xff + 0132 F8 300 mov r0,a + 0133 90s00r03 301 mov dptr,#_atol_rv_1_1 + 0136 ED 302 mov a,r5 + 0137 25*00 303 add a,_atol_sloc0_1_0 + 0139 F0 304 movx @dptr,a + 013A EE 305 mov a,r6 + 013B 35*01 306 addc a,(_atol_sloc0_1_0 + 1) + 013D A3 307 inc dptr + 013E F0 308 movx @dptr,a + 013F EF 309 mov a,r7 + 0140 35*02 310 addc a,(_atol_sloc0_1_0 + 2) + 0142 A3 311 inc dptr + 0143 F0 312 movx @dptr,a + 0144 E8 313 mov a,r0 + 0145 35*03 314 addc a,(_atol_sloc0_1_0 + 3) + 0147 A3 315 inc dptr + 0148 F0 316 movx @dptr,a + 317 ; _atol.c 44 + 0149 0A 318 inc r2 + 014A BA 00 01 319 cjne r2,#0x00,00147$ + 014D 0B 320 inc r3 + 014E 321 00147$: + 014E 90s00r00 322 mov dptr,#_atol_s_1_1 + 0151 EA 323 mov a,r2 + 0152 F0 324 movx @dptr,a + 0153 A3 325 inc dptr + 0154 EB 326 mov a,r3 + 0155 F0 327 movx @dptr,a + 0156 A3 328 inc dptr + 0157 EC 329 mov a,r4 + 0158 F0 330 movx @dptr,a + 0159 D0 06 331 pop ar6 + 015B 02s00rAB 332 ljmp 00115$ + 015E 333 00117$: + 334 ; _atol.c 47 + 015E 90s00r00 335 mov dptr,#_atol_s_1_1 + 0161 EA 336 mov a,r2 + 0162 F0 337 movx @dptr,a + 0163 A3 338 inc dptr + 0164 EB 339 mov a,r3 + 0165 F0 340 movx @dptr,a + 0166 A3 341 inc dptr + 0167 EC 342 mov a,r4 + 0168 F0 343 movx @dptr,a + 0169 EE 344 mov a,r6 + 345 ; Peephole 110 removed ljmp by inverse jump logic + 016A 60 1D 346 jz 00120$ + 016C 347 00148$: + 016C 90s00r03 348 mov dptr,#_atol_rv_1_1 + 016F E0 349 movx a,@dptr + 0170 FA 350 mov r2,a + 0171 A3 351 inc dptr + 0172 E0 352 movx a,@dptr + 0173 FB 353 mov r3,a + 0174 A3 354 inc dptr + 0175 E0 355 movx a,@dptr + 0176 FC 356 mov r4,a + 0177 A3 357 inc dptr + 0178 E0 358 movx a,@dptr + 0179 FD 359 mov r5,a + 017A C3 360 clr c + 017B E4 361 clr a + 017C 9A 362 subb a,r2 + 017D FA 363 mov r2,a + 017E E4 364 clr a + 017F 9B 365 subb a,r3 + 0180 FB 366 mov r3,a + 0181 E4 367 clr a + 0182 9C 368 subb a,r4 + 0183 FC 369 mov r4,a + 0184 E4 370 clr a + 0185 9D 371 subb a,r5 + 0186 FD 372 mov r5,a + 373 ; Peephole 132 changed ljmp to sjmp + 0187 80 0E 374 sjmp 00121$ + 0189 375 00120$: + 0189 90s00r03 376 mov dptr,#_atol_rv_1_1 + 018C E0 377 movx a,@dptr + 018D FA 378 mov r2,a + 018E A3 379 inc dptr + 018F E0 380 movx a,@dptr + 0190 FB 381 mov r3,a + 0191 A3 382 inc dptr + 0192 E0 383 movx a,@dptr + 0193 FC 384 mov r4,a + 0194 A3 385 inc dptr + 0195 E0 386 movx a,@dptr + 0196 FD 387 mov r5,a + 0197 388 00121$: + 0197 8A 82 389 mov dpl,r2 + 0199 8B 83 390 mov dph,r3 + 019B 8C F0 391 mov b,r4 + 019D ED 392 mov a,r5 + 019E 393 00118$: + 019E 394 C$_atol.c$48$1$1 ==. + 019E 395 XG$atol$0$0 ==. + 019E 22 396 ret + 397 .area CSEG (CODE) diff --git a/device/lib/_atol.sym b/device/lib/_atol.sym new file mode 100644 index 00000000..b1afdfd6 --- /dev/null +++ b/device/lib/_atol.sym @@ -0,0 +1,641 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_atol$100 0032 GR + 7 A$_atol$102 0033 GR + 7 A$_atol$103 0035 GR + 7 A$_atol$104 0037 GR + 7 A$_atol$105 0039 GR + 7 A$_atol$107 003C GR + 7 A$_atol$109 003D GR + 7 A$_atol$112 003F GR + 7 A$_atol$114 0040 GR + 7 A$_atol$115 0042 GR + 7 A$_atol$116 0044 GR + 7 A$_atol$117 0047 GR + 7 A$_atol$120 0049 GR + 7 A$_atol$122 004B GR + 7 A$_atol$123 004C GR + 7 A$_atol$124 004D GR + 7 A$_atol$125 004F GR + 7 A$_atol$127 0051 GR + 7 A$_atol$132 0053 GR + 7 A$_atol$134 0056 GR + 7 A$_atol$136 0058 GR + 7 A$_atol$138 005B GR + 7 A$_atol$141 005D GR + 7 A$_atol$142 005E GR + 7 A$_atol$143 0061 GR + 7 A$_atol$145 0062 GR + 7 A$_atol$146 0065 GR + 7 A$_atol$147 0066 GR + 7 A$_atol$148 0067 GR + 7 A$_atol$149 0068 GR + 7 A$_atol$150 0069 GR + 7 A$_atol$151 006A GR + 7 A$_atol$152 006B GR + 7 A$_atol$153 006C GR + 7 A$_atol$155 006D GR + 7 A$_atol$158 006F GR + 7 A$_atol$159 0072 GR + 7 A$_atol$160 0073 GR + 7 A$_atol$161 0074 GR + 7 A$_atol$162 0075 GR + 7 A$_atol$163 0076 GR + 7 A$_atol$164 0077 GR + 7 A$_atol$165 0078 GR + 7 A$_atol$166 0079 GR + 7 A$_atol$167 007A GR + 7 A$_atol$168 007C GR + 7 A$_atol$169 007E GR + 7 A$_atol$170 0080 GR + 7 A$_atol$171 0083 GR + 7 A$_atol$172 0084 GR + 7 A$_atol$173 0087 GR + 7 A$_atol$174 0089 GR + 7 A$_atol$176 008B GR + 7 A$_atol$180 008C GR + 7 A$_atol$182 008D GR + 7 A$_atol$186 008F GR + 7 A$_atol$191 0092 GR + 7 A$_atol$192 0095 GR + 7 A$_atol$193 0097 GR + 7 A$_atol$194 0098 GR + 7 A$_atol$196 0099 GR + 7 A$_atol$197 009A GR + 7 A$_atol$198 009B GR + 7 A$_atol$199 009C GR + 7 A$_atol$200 009D GR + 7 A$_atol$201 009E GR + 7 A$_atol$202 009F GR + 7 A$_atol$205 00A0 GR + 7 A$_atol$206 00A3 GR + 7 A$_atol$207 00A4 GR + 7 A$_atol$208 00A5 GR + 7 A$_atol$209 00A6 GR + 7 A$_atol$210 00A7 GR + 7 A$_atol$211 00A8 GR + 7 A$_atol$212 00A9 GR + 7 A$_atol$213 00AA GR + 7 A$_atol$215 00AB GR + 7 A$_atol$216 00AD GR + 7 A$_atol$217 00AF GR + 7 A$_atol$218 00B1 GR + 7 A$_atol$220 00B4 GR + 7 A$_atol$221 00B5 GR + 7 A$_atol$222 00B7 GR + 7 A$_atol$224 00BA GR + 7 A$_atol$225 00BB GR + 7 A$_atol$226 00BC GR + 7 A$_atol$227 00BE GR + 7 A$_atol$228 00C0 GR + 7 A$_atol$229 00C2 GR + 7 A$_atol$231 00C5 GR + 7 A$_atol$233 00C6 GR + 7 A$_atol$234 00C8 GR + 7 A$_atol$235 00CA GR + 7 A$_atol$236 00CD GR + 7 A$_atol$237 00CF GR + 7 A$_atol$238 00D1 GR + 7 A$_atol$241 00D4 GR + 7 A$_atol$242 00D6 GR + 7 A$_atol$243 00D9 GR + 7 A$_atol$244 00DA GR + 7 A$_atol$245 00DB GR + 7 A$_atol$246 00DC GR + 7 A$_atol$247 00DD GR + 7 A$_atol$248 00DE GR + 7 A$_atol$249 00DF GR + 7 A$_atol$250 00E0 GR + 7 A$_atol$251 00E1 GR + 7 A$_atol$252 00E2 GR + 7 A$_atol$253 00E3 GR + 7 A$_atol$254 00E4 GR + 7 A$_atol$255 00E7 GR + 7 A$_atol$256 00E8 GR + 7 A$_atol$257 00E9 GR + 7 A$_atol$258 00EA GR + 7 A$_atol$259 00EB GR + 7 A$_atol$260 00EC GR + 7 A$_atol$261 00EF GR + 7 A$_atol$262 00F0 GR + 7 A$_atol$263 00F3 GR + 7 A$_atol$264 00F4 GR + 7 A$_atol$265 00F7 GR + 7 A$_atol$266 00F9 GR + 7 A$_atol$267 00FA GR + 7 A$_atol$268 00FC GR + 7 A$_atol$269 00FE GR + 7 A$_atol$270 0100 GR + 7 A$_atol$271 0102 GR + 7 A$_atol$272 0104 GR + 7 A$_atol$273 0106 GR + 7 A$_atol$274 0108 GR + 7 A$_atol$275 010A GR + 7 A$_atol$276 010B GR + 7 A$_atol$277 010E GR + 7 A$_atol$278 0111 GR + 7 A$_atol$279 0114 GR + 7 A$_atol$280 0117 GR + 7 A$_atol$281 0119 GR + 7 A$_atol$282 011B GR + 7 A$_atol$283 011D GR + 7 A$_atol$284 011F GR + 7 A$_atol$285 0121 GR + 7 A$_atol$286 0123 GR + 7 A$_atol$287 0124 GR + 7 A$_atol$288 0126 GR + 7 A$_atol$290 0127 GR + 7 A$_atol$291 0128 GR + 7 A$_atol$292 012A GR + 7 A$_atol$294 012B GR + 7 A$_atol$295 012C GR + 7 A$_atol$296 012E GR + 7 A$_atol$298 012F GR + 7 A$_atol$299 0130 GR + 7 A$_atol$300 0132 GR + 7 A$_atol$301 0133 GR + 7 A$_atol$302 0136 GR + 7 A$_atol$303 0137 GR + 7 A$_atol$304 0139 GR + 7 A$_atol$305 013A GR + 7 A$_atol$306 013B GR + 7 A$_atol$307 013D GR + 7 A$_atol$308 013E GR + 7 A$_atol$309 013F GR + 7 A$_atol$310 0140 GR + 7 A$_atol$311 0142 GR + 7 A$_atol$312 0143 GR + 7 A$_atol$313 0144 GR + 7 A$_atol$314 0145 GR + 7 A$_atol$315 0147 GR + 7 A$_atol$316 0148 GR + 7 A$_atol$318 0149 GR + 7 A$_atol$319 014A GR + 7 A$_atol$320 014D GR + 7 A$_atol$322 014E GR + 7 A$_atol$323 0151 GR + 7 A$_atol$324 0152 GR + 7 A$_atol$325 0153 GR + 7 A$_atol$326 0154 GR + 7 A$_atol$327 0155 GR + 7 A$_atol$328 0156 GR + 7 A$_atol$329 0157 GR + 7 A$_atol$330 0158 GR + 7 A$_atol$331 0159 GR + 7 A$_atol$332 015B GR + 7 A$_atol$335 015E GR + 7 A$_atol$336 0161 GR + 7 A$_atol$337 0162 GR + 7 A$_atol$338 0163 GR + 7 A$_atol$339 0164 GR + 7 A$_atol$340 0165 GR + 7 A$_atol$341 0166 GR + 7 A$_atol$342 0167 GR + 7 A$_atol$343 0168 GR + 7 A$_atol$344 0169 GR + 7 A$_atol$346 016A GR + 7 A$_atol$348 016C GR + 7 A$_atol$349 016F GR + 7 A$_atol$350 0170 GR + 7 A$_atol$351 0171 GR + 7 A$_atol$352 0172 GR + 7 A$_atol$353 0173 GR + 7 A$_atol$354 0174 GR + 7 A$_atol$355 0175 GR + 7 A$_atol$356 0176 GR + 7 A$_atol$357 0177 GR + 7 A$_atol$358 0178 GR + 7 A$_atol$359 0179 GR + 7 A$_atol$360 017A GR + 7 A$_atol$361 017B GR + 7 A$_atol$362 017C GR + 7 A$_atol$363 017D GR + 7 A$_atol$364 017E GR + 7 A$_atol$365 017F GR + 7 A$_atol$366 0180 GR + 7 A$_atol$367 0181 GR + 7 A$_atol$368 0182 GR + 7 A$_atol$369 0183 GR + 7 A$_atol$370 0184 GR + 7 A$_atol$371 0185 GR + 7 A$_atol$372 0186 GR + 7 A$_atol$374 0187 GR + 7 A$_atol$376 0189 GR + 7 A$_atol$377 018C GR + 7 A$_atol$378 018D GR + 7 A$_atol$379 018E GR + 7 A$_atol$380 018F GR + 7 A$_atol$381 0190 GR + 7 A$_atol$382 0191 GR + 7 A$_atol$383 0192 GR + 7 A$_atol$384 0193 GR + 7 A$_atol$385 0194 GR + 7 A$_atol$386 0195 GR + 7 A$_atol$387 0196 GR + 7 A$_atol$389 0197 GR + 7 A$_atol$390 0199 GR + 7 A$_atol$391 019B GR + 7 A$_atol$392 019D GR + 7 A$_atol$396 019E GR + 7 A$_atol$66 0000 GR + 7 A$_atol$67 0002 GR + 7 A$_atol$68 0004 GR + 7 A$_atol$69 0006 GR + 7 A$_atol$70 0009 GR + 7 A$_atol$71 000B GR + 7 A$_atol$72 000C GR + 7 A$_atol$73 000E GR + 7 A$_atol$74 000F GR + 7 A$_atol$75 0010 GR + 7 A$_atol$76 0012 GR + 7 A$_atol$77 0013 GR + 7 A$_atol$79 0014 GR + 7 A$_atol$80 0017 GR + 7 A$_atol$81 0018 GR + 7 A$_atol$82 0019 GR + 7 A$_atol$83 001A GR + 7 A$_atol$84 001B GR + 7 A$_atol$85 001C GR + 7 A$_atol$86 001F GR + 7 A$_atol$87 0020 GR + 7 A$_atol$88 0023 GR + 7 A$_atol$89 0024 GR + 7 A$_atol$90 0027 GR + 7 A$_atol$92 0028 GR + 7 A$_atol$93 002B GR + 7 A$_atol$94 002C GR + 7 A$_atol$95 002D GR + 7 A$_atol$96 002E GR + 7 A$_atol$97 002F GR + 7 A$_atol$98 0030 GR + 7 A$_atol$99 0031 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_atol.c$48$1$1 = 019E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$atol$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$atol$0$0 = 019E GR + __decdptr **** GX + __gptrget **** GX + __mulslong **** GX + __mulslong_PARM_2 **** GX + 7 _atol 0000 GR + 5 _atol_rv_1_1 0003 R + 5 _atol_s_1_1 0000 R + 1 _atol_sloc0_1_0 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 4 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 7 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 19F flags 20 diff --git a/device/lib/_autobaud.c b/device/lib/_autobaud.c new file mode 100644 index 00000000..6799f916 --- /dev/null +++ b/device/lib/_autobaud.c @@ -0,0 +1,97 @@ +/*------------------------------------------------------------------------- + + _autobaud.c - automatic baud rate detection routine. Adapted for + sdcc compiler from Paul Stoffregen's autobaud.asm + the original assembly code can be found at + http://www.ece.orst.edu/~paul/8051-goodies/autobaud.html + + written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + -------------------------------------------------------------------------*/ +#include +/* +; To set the baud rate, use this formula or use autobaud() +; baud_const = 256 - (crystal / (12 * 16 * baud)) */ + +/* +;to do automatic baud rate detection, we assume the user will +;press the carriage return, which will cause this bit pattern +;to appear on port 3 pin 0 (CR = ascii code 13, assume 8N1 format) +; +; 0 1 0 1 1 0 0 0 0 1 +; | | | | +; start bit----+ +--lsb msb--+ +----stop bit +; +;we'll start timer #1 in 16 bit mode at the transition between the +;start bit and the LSB and stop it between the MBS and stop bit. +;That will give approx the number of cpu cycles for 8 bits. Divide +;by 8 for one bit and by 16 since the built-in UART takes 16 timer +;overflows for each bit. We need to be careful about roundoff during +;division and the result has to be inverted since timer #1 counts up. Of +;course, timer #1 gets used in 8-bit auto reload mode for generating the +;built-in UART's baud rate once we know what the reload value should be. +*/ + +void autobaud () +{ + + /* get timer #1 ready for action (16 bit mode) */ + TMOD=0x11; + TCON = 0; + TH1 = TL1 = 0; + + /* wait for start bit */ +autobaud2: + while(RXD) ; + + /* check it a few more times to make + sure we don't trigger on some noise*/ + if (RXD) goto autobaud2; + if (RXD) goto autobaud2; + if (RXD) goto autobaud2; + if (RXD) goto autobaud2; + + /* wait for bit #0 to begin */ + while (!RXD); + TR1 = 1; /* start the timer */ + while (RXD); // wait for bit #1 to begin + while(!RXD); // wait for bit #2 to begin + while(RXD); // wait for bit #4 to begin + while (!RXD); // wait for stop bit to begin + TR1 = 0; // stop timing + + /* ;grab bit 7... it's the lsb we want */ + TH1 = (TH1 << 1) | (TL1 >> 7); + + /* round off if necessary */ + TH1 = (TH1 << 1) | ((TL1 >> 6) & 0x01); + + /* invert since timer #1 will count up */ + TH1 = ~TH1; + + /* now TH1 has the correct reload value (I hope) */ + TH1++ ; + + TL1 = TH1; + TMOD = 0x21 ; // set timer #1 for 8 bit auto-reload + PCON = 0x80 ; // configure built-in uart + SCON = 0x52 ; +} + diff --git a/device/lib/_autobaud.lst b/device/lib/_autobaud.lst new file mode 100644 index 00000000..c84d57ff --- /dev/null +++ b/device/lib/_autobaud.lst @@ -0,0 +1,325 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _autobaud + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _autobaud + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 0080 14 G$P0$0$0 == 0x0080 + 0080 15 _P0 = 0x0080 + 0090 16 G$P1$0$0 == 0x0090 + 0090 17 _P1 = 0x0090 + 00A0 18 G$P2$0$0 == 0x00a0 + 00A0 19 _P2 = 0x00a0 + 00B0 20 G$P3$0$0 == 0x00b0 + 00B0 21 _P3 = 0x00b0 + 00D0 22 G$PSW$0$0 == 0x00d0 + 00D0 23 _PSW = 0x00d0 + 00E0 24 G$ACC$0$0 == 0x00e0 + 00E0 25 _ACC = 0x00e0 + 00F0 26 G$B$0$0 == 0x00f0 + 00F0 27 _B = 0x00f0 + 0081 28 G$SP$0$0 == 0x0081 + 0081 29 _SP = 0x0081 + 0082 30 G$DPL$0$0 == 0x0082 + 0082 31 _DPL = 0x0082 + 0083 32 G$DPH$0$0 == 0x0083 + 0083 33 _DPH = 0x0083 + 0087 34 G$PCON$0$0 == 0x0087 + 0087 35 _PCON = 0x0087 + 0088 36 G$TCON$0$0 == 0x0088 + 0088 37 _TCON = 0x0088 + 0089 38 G$TMOD$0$0 == 0x0089 + 0089 39 _TMOD = 0x0089 + 008A 40 G$TL0$0$0 == 0x008a + 008A 41 _TL0 = 0x008a + 008B 42 G$TL1$0$0 == 0x008b + 008B 43 _TL1 = 0x008b + 008C 44 G$TH0$0$0 == 0x008c + 008C 45 _TH0 = 0x008c + 008D 46 G$TH1$0$0 == 0x008d + 008D 47 _TH1 = 0x008d + 008E 48 G$AUXR$0$0 == 0x008e + 008E 49 _AUXR = 0x008e + 00A8 50 G$IE$0$0 == 0x00a8 + 00A8 51 _IE = 0x00a8 + 00B8 52 G$IP$0$0 == 0x00b8 + 00B8 53 _IP = 0x00b8 + 0098 54 G$SCON$0$0 == 0x0098 + 0098 55 _SCON = 0x0098 + 0099 56 G$SBUF$0$0 == 0x0099 + 0099 57 _SBUF = 0x0099 + 00C8 58 G$T2CON$0$0 == 0x00c8 + 00C8 59 _T2CON = 0x00c8 + 00CB 60 G$RCAP2H$0$0 == 0x00cb + 00CB 61 _RCAP2H = 0x00cb + 00CA 62 G$RCAP2L$0$0 == 0x00ca + 00CA 63 _RCAP2L = 0x00ca + 64 ;-------------------------------------------------------- + 65 ; special function bits + 66 ;-------------------------------------------------------- + 00D7 67 G$CY$0$0 == 0x00d7 + 00D7 68 _CY = 0x00d7 + 00D6 69 G$AC$0$0 == 0x00d6 + 00D6 70 _AC = 0x00d6 + 00D5 71 G$F0$0$0 == 0x00d5 + 00D5 72 _F0 = 0x00d5 + 00D4 73 G$RS1$0$0 == 0x00d4 + 00D4 74 _RS1 = 0x00d4 + 00D3 75 G$RS0$0$0 == 0x00d3 + 00D3 76 _RS0 = 0x00d3 + 00D2 77 G$OV$0$0 == 0x00d2 + 00D2 78 _OV = 0x00d2 + 00D0 79 G$P$0$0 == 0x00d0 + 00D0 80 _P = 0x00d0 + 008F 81 G$TF1$0$0 == 0x008f + 008F 82 _TF1 = 0x008f + 008E 83 G$TR1$0$0 == 0x008e + 008E 84 _TR1 = 0x008e + 008D 85 G$TF0$0$0 == 0x008d + 008D 86 _TF0 = 0x008d + 008C 87 G$TR0$0$0 == 0x008c + 008C 88 _TR0 = 0x008c + 008B 89 G$IE1$0$0 == 0x008b + 008B 90 _IE1 = 0x008b + 008A 91 G$IT1$0$0 == 0x008a + 008A 92 _IT1 = 0x008a + 0089 93 G$IE0$0$0 == 0x0089 + 0089 94 _IE0 = 0x0089 + 0088 95 G$IT0$0$0 == 0x0088 + 0088 96 _IT0 = 0x0088 + 00AF 97 G$EA$0$0 == 0x00af + 00AF 98 _EA = 0x00af + 00AC 99 G$ES$0$0 == 0x00ac + 00AC 100 _ES = 0x00ac + 00AB 101 G$ET1$0$0 == 0x00ab + 00AB 102 _ET1 = 0x00ab + 00AA 103 G$EX1$0$0 == 0x00aa + 00AA 104 _EX1 = 0x00aa + 00A9 105 G$ET0$0$0 == 0x00a9 + 00A9 106 _ET0 = 0x00a9 + 00A8 107 G$EX0$0$0 == 0x00a8 + 00A8 108 _EX0 = 0x00a8 + 00BC 109 G$PS$0$0 == 0x00bc + 00BC 110 _PS = 0x00bc + 00BB 111 G$PT1$0$0 == 0x00bb + 00BB 112 _PT1 = 0x00bb + 00BA 113 G$PX1$0$0 == 0x00ba + 00BA 114 _PX1 = 0x00ba + 00B9 115 G$PT0$0$0 == 0x00b9 + 00B9 116 _PT0 = 0x00b9 + 00B8 117 G$PX0$0$0 == 0x00b8 + 00B8 118 _PX0 = 0x00b8 + 00B7 119 G$RD$0$0 == 0x00b7 + 00B7 120 _RD = 0x00b7 + 00B6 121 G$WR$0$0 == 0x00b6 + 00B6 122 _WR = 0x00b6 + 00B5 123 G$T1$0$0 == 0x00b5 + 00B5 124 _T1 = 0x00b5 + 00B4 125 G$T0$0$0 == 0x00b4 + 00B4 126 _T0 = 0x00b4 + 00B3 127 G$INT1$0$0 == 0x00b3 + 00B3 128 _INT1 = 0x00b3 + 00B2 129 G$INT0$0$0 == 0x00b2 + 00B2 130 _INT0 = 0x00b2 + 00B1 131 G$TXD$0$0 == 0x00b1 + 00B1 132 _TXD = 0x00b1 + 00B0 133 G$RXD$0$0 == 0x00b0 + 00B0 134 _RXD = 0x00b0 + 0090 135 G$P1_0$0$0 == 0x0090 + 0090 136 _P1_0 = 0x0090 + 0091 137 G$P1_1$0$0 == 0x0091 + 0091 138 _P1_1 = 0x0091 + 0092 139 G$P1_2$0$0 == 0x0092 + 0092 140 _P1_2 = 0x0092 + 0093 141 G$P1_3$0$0 == 0x0093 + 0093 142 _P1_3 = 0x0093 + 0094 143 G$P1_4$0$0 == 0x0094 + 0094 144 _P1_4 = 0x0094 + 0095 145 G$P1_5$0$0 == 0x0095 + 0095 146 _P1_5 = 0x0095 + 0096 147 G$P1_6$0$0 == 0x0096 + 0096 148 _P1_6 = 0x0096 + 0097 149 G$P1_7$0$0 == 0x0097 + 0097 150 _P1_7 = 0x0097 + 009F 151 G$SM0$0$0 == 0x009f + 009F 152 _SM0 = 0x009f + 009E 153 G$SM1$0$0 == 0x009e + 009E 154 _SM1 = 0x009e + 009D 155 G$SM2$0$0 == 0x009d + 009D 156 _SM2 = 0x009d + 009C 157 G$REN$0$0 == 0x009c + 009C 158 _REN = 0x009c + 009B 159 G$TB8$0$0 == 0x009b + 009B 160 _TB8 = 0x009b + 009A 161 G$RB8$0$0 == 0x009a + 009A 162 _RB8 = 0x009a + 0099 163 G$TI$0$0 == 0x0099 + 0099 164 _TI = 0x0099 + 0098 165 G$RI$0$0 == 0x0098 + 0098 166 _RI = 0x0098 + 00C8 167 G$T2CON_0$0$0 == 0x00c8 + 00C8 168 _T2CON_0 = 0x00c8 + 00C9 169 G$T2CON_1$0$0 == 0x00c9 + 00C9 170 _T2CON_1 = 0x00c9 + 00CA 171 G$T2CON_2$0$0 == 0x00ca + 00CA 172 _T2CON_2 = 0x00ca + 00CB 173 G$T2CON_3$0$0 == 0x00cb + 00CB 174 _T2CON_3 = 0x00cb + 00CC 175 G$T2CON_4$0$0 == 0x00cc + 00CC 176 _T2CON_4 = 0x00cc + 00CD 177 G$T2CON_5$0$0 == 0x00cd + 00CD 178 _T2CON_5 = 0x00cd + 00CE 179 G$T2CON_6$0$0 == 0x00ce + 00CE 180 _T2CON_6 = 0x00ce + 00CF 181 G$T2CON_7$0$0 == 0x00cf + 00CF 182 _T2CON_7 = 0x00cf + 183 ;-------------------------------------------------------- + 184 ; internal ram data + 185 ;-------------------------------------------------------- + 186 .area DSEG (DATA) + 187 ;-------------------------------------------------------- + 188 ; overlayable items in internal ram + 189 ;-------------------------------------------------------- + 190 .area OSEG (OVR,DATA) + 191 ;-------------------------------------------------------- + 192 ; indirectly addressable internal ram data + 193 ;-------------------------------------------------------- + 194 .area ISEG (DATA) + 195 ;-------------------------------------------------------- + 196 ; bit data + 197 ;-------------------------------------------------------- + 198 .area BSEG (BIT) + 199 ;-------------------------------------------------------- + 200 ; external ram data + 201 ;-------------------------------------------------------- + 202 .area XSEG (XDATA) + 203 ;-------------------------------------------------------- + 204 ; global & static initialisations + 205 ;-------------------------------------------------------- + 206 .area GSINIT (CODE) + 207 ;-------------------------------------------------------- + 208 ; code + 209 ;-------------------------------------------------------- + 210 .area CSEG (CODE) + 0000 211 G$autobaud$0$0 ==. + 212 ; _autobaud.c 52 + 213 ; ----------------------------------------- + 214 ; function autobaud + 215 ; ----------------------------------------- + 0000 216 _autobaud: + 0002 217 ar2 = 0x02 + 0003 218 ar3 = 0x03 + 0004 219 ar4 = 0x04 + 0005 220 ar5 = 0x05 + 0006 221 ar6 = 0x06 + 0007 222 ar7 = 0x07 + 0000 223 ar0 = 0x00 + 0001 224 ar1 = 0x01 + 225 ; _autobaud.c 56 + 0000 75 89 11 226 mov _TMOD,#0x11 + 227 ; _autobaud.c 57 + 0003 75 88 00 228 mov _TCON,#0x00 + 229 ; _autobaud.c 58 + 0006 75 8B 00 230 mov _TL1,#0x00 + 0009 75 8D 00 231 mov _TH1,#0x00 + 232 ; _autobaud.c 62 + 000C 233 00101$: + 234 ; Peephole 112 removed ljmp by inverse jump logic + 000C 20 B0 FD 235 jb _RXD,00101$ + 000F 236 00142$: + 237 ; _autobaud.c 66 + 238 ; Peephole 112 removed ljmp by inverse jump logic + 000F 20 B0 FA 239 jb _RXD,00101$ + 0012 240 00143$: + 241 ; _autobaud.c 67 + 242 ; Peephole 112 removed ljmp by inverse jump logic + 0012 20 B0 F7 243 jb _RXD,00101$ + 0015 244 00144$: + 245 ; _autobaud.c 68 + 246 ; Peephole 112 removed ljmp by inverse jump logic + 0015 20 B0 F4 247 jb _RXD,00101$ + 0018 248 00145$: + 249 ; _autobaud.c 69 + 250 ; Peephole 112 removed ljmp by inverse jump logic + 0018 20 B0 F1 251 jb _RXD,00101$ + 001B 252 00146$: + 253 ; _autobaud.c 72 + 001B 254 00113$: + 255 ; Peephole 111 removed ljmp by inverse jump logic + 001B 30 B0 FD 256 jnb _RXD,00113$ + 001E 257 00147$: + 258 ; _autobaud.c 73 + 001E D2 8E 259 setb _TR1 + 260 ; _autobaud.c 74 + 0020 261 00116$: + 262 ; Peephole 112 removed ljmp by inverse jump logic + 0020 20 B0 FD 263 jb _RXD,00116$ + 0023 264 00148$: + 265 ; _autobaud.c 75 + 0023 266 00119$: + 267 ; Peephole 111 removed ljmp by inverse jump logic + 0023 30 B0 FD 268 jnb _RXD,00119$ + 0026 269 00149$: + 270 ; _autobaud.c 76 + 0026 271 00122$: + 272 ; Peephole 112 removed ljmp by inverse jump logic + 0026 20 B0 FD 273 jb _RXD,00122$ + 0029 274 00150$: + 275 ; _autobaud.c 77 + 0029 276 00125$: + 277 ; Peephole 111 removed ljmp by inverse jump logic + 0029 30 B0 FD 278 jnb _RXD,00125$ + 002C 279 00151$: + 280 ; _autobaud.c 78 + 002C C2 8E 281 clr _TR1 + 282 ; _autobaud.c 81 + 002E E5 8D 283 mov a,_TH1 + 0030 25 E0 284 add a,acc + 0032 FA 285 mov r2,a + 0033 E5 8B 286 mov a,_TL1 + 0035 23 287 rl a + 0036 54 01 288 anl a,#0x01 + 289 ; Peephole 105 removed redundant mov + 0038 FB 290 mov r3,a + 0039 4A 291 orl a,r2 + 292 ; _autobaud.c 84 + 293 ; Peephole 105 removed redundant mov + 003A F5 8D 294 mov _TH1,a + 003C 25 E0 295 add a,acc + 003E FA 296 mov r2,a + 003F E5 8B 297 mov a,_TL1 + 0041 23 298 rl a + 0042 23 299 rl a + 300 ; Peephole 139 removed redundant mov + 301 ; Peephole 183 avoided anl during execution + 0043 54 01 302 anl a,#(0x03 & 0x01) + 0045 FB 303 mov r3,a + 0046 4A 304 orl a,r2 + 305 ; _autobaud.c 87 + 306 ; Peephole 105 removed redundant mov + 307 ; Peephole 184 removed redundant mov + 0047 F4 308 cpl a + 309 ; _autobaud.c 90 + 310 ; Peephole 185 changed order of increment (acc incremented also!) + 0048 04 311 inc a + 0049 F5 8D 312 mov _TH1,a + 313 ; _autobaud.c 92 + 004B 85 8D 8B 314 mov _TL1,_TH1 + 315 ; _autobaud.c 93 + 004E 75 89 21 316 mov _TMOD,#0x21 + 317 ; _autobaud.c 94 + 0051 75 87 80 318 mov _PCON,#0x80 + 319 ; _autobaud.c 95 + 0054 75 98 52 320 mov _SCON,#0x52 + 0057 321 00128$: + 0057 322 C$_autobaud.c$96$1$1 ==. + 0057 323 XG$autobaud$0$0 ==. + 0057 22 324 ret + 325 .area CSEG (CODE) diff --git a/device/lib/_autobaud.sym b/device/lib/_autobaud.sym new file mode 100644 index 00000000..3fe926cf --- /dev/null +++ b/device/lib/_autobaud.sym @@ -0,0 +1,572 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_autobaud$226 0000 GR + 7 A$_autobaud$228 0003 GR + 7 A$_autobaud$230 0006 GR + 7 A$_autobaud$231 0009 GR + 7 A$_autobaud$235 000C GR + 7 A$_autobaud$239 000F GR + 7 A$_autobaud$243 0012 GR + 7 A$_autobaud$247 0015 GR + 7 A$_autobaud$251 0018 GR + 7 A$_autobaud$256 001B GR + 7 A$_autobaud$259 001E GR + 7 A$_autobaud$263 0020 GR + 7 A$_autobaud$268 0023 GR + 7 A$_autobaud$273 0026 GR + 7 A$_autobaud$278 0029 GR + 7 A$_autobaud$281 002C GR + 7 A$_autobaud$283 002E GR + 7 A$_autobaud$284 0030 GR + 7 A$_autobaud$285 0032 GR + 7 A$_autobaud$286 0033 GR + 7 A$_autobaud$287 0035 GR + 7 A$_autobaud$288 0036 GR + 7 A$_autobaud$290 0038 GR + 7 A$_autobaud$291 0039 GR + 7 A$_autobaud$294 003A GR + 7 A$_autobaud$295 003C GR + 7 A$_autobaud$296 003E GR + 7 A$_autobaud$297 003F GR + 7 A$_autobaud$298 0041 GR + 7 A$_autobaud$299 0042 GR + 7 A$_autobaud$302 0043 GR + 7 A$_autobaud$303 0045 GR + 7 A$_autobaud$304 0046 GR + 7 A$_autobaud$308 0047 GR + 7 A$_autobaud$311 0048 GR + 7 A$_autobaud$312 0049 GR + 7 A$_autobaud$314 004B GR + 7 A$_autobaud$316 004E GR + 7 A$_autobaud$318 0051 GR + 7 A$_autobaud$320 0054 GR + 7 A$_autobaud$324 0057 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_autobaud.c$96$1$1 = 0057 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + G$AC$0$0 = 00D6 G + G$ACC$0$0 = 00E0 G + G$AUXR$0$0 = 008E G + G$B$0$0 = 00F0 G + G$CY$0$0 = 00D7 G + G$DPH$0$0 = 0083 G + G$DPL$0$0 = 0082 G + G$EA$0$0 = 00AF G + G$ES$0$0 = 00AC G + G$ET0$0$0 = 00A9 G + G$ET1$0$0 = 00AB G + G$EX0$0$0 = 00A8 G + G$EX1$0$0 = 00AA G + G$F0$0$0 = 00D5 G + G$IE$0$0 = 00A8 G + G$IE0$0$0 = 0089 G + G$IE1$0$0 = 008B G + G$INT0$0$0 = 00B2 G + G$INT1$0$0 = 00B3 G + G$IP$0$0 = 00B8 G + G$IT0$0$0 = 0088 G + G$IT1$0$0 = 008A G + G$OV$0$0 = 00D2 G + G$P$0$0 = 00D0 G + G$P0$0$0 = 0080 G + G$P1$0$0 = 0090 G + G$P1_0$0$0 = 0090 G + G$P1_1$0$0 = 0091 G + G$P1_2$0$0 = 0092 G + G$P1_3$0$0 = 0093 G + G$P1_4$0$0 = 0094 G + G$P1_5$0$0 = 0095 G + G$P1_6$0$0 = 0096 G + G$P1_7$0$0 = 0097 G + G$P2$0$0 = 00A0 G + G$P3$0$0 = 00B0 G + G$PCON$0$0 = 0087 G + G$PS$0$0 = 00BC G + G$PSW$0$0 = 00D0 G + G$PT0$0$0 = 00B9 G + G$PT1$0$0 = 00BB G + G$PX0$0$0 = 00B8 G + G$PX1$0$0 = 00BA G + G$RB8$0$0 = 009A G + G$RCAP2H$0$0 = 00CB G + G$RCAP2L$0$0 = 00CA G + G$RD$0$0 = 00B7 G + G$REN$0$0 = 009C G + G$RI$0$0 = 0098 G + G$RS0$0$0 = 00D3 G + G$RS1$0$0 = 00D4 G + G$RXD$0$0 = 00B0 G + G$SBUF$0$0 = 0099 G + G$SCON$0$0 = 0098 G + G$SM0$0$0 = 009F G + G$SM1$0$0 = 009E G + G$SM2$0$0 = 009D G + G$SP$0$0 = 0081 G + G$T0$0$0 = 00B4 G + G$T1$0$0 = 00B5 G + G$T2CON$0$0 = 00C8 G + G$T2CON_0$0$0 = 00C8 G + G$T2CON_1$0$0 = 00C9 G + G$T2CON_2$0$0 = 00CA G + G$T2CON_3$0$0 = 00CB G + G$T2CON_4$0$0 = 00CC G + G$T2CON_5$0$0 = 00CD G + G$T2CON_6$0$0 = 00CE G + G$T2CON_7$0$0 = 00CF G + G$TB8$0$0 = 009B G + G$TCON$0$0 = 0088 G + G$TF0$0$0 = 008D G + G$TF1$0$0 = 008F G + G$TH0$0$0 = 008C G + G$TH1$0$0 = 008D G + G$TI$0$0 = 0099 G + G$TL0$0$0 = 008A G + G$TL1$0$0 = 008B G + G$TMOD$0$0 = 0089 G + G$TR0$0$0 = 008C G + G$TR1$0$0 = 008E G + G$TXD$0$0 = 00B1 G + G$WR$0$0 = 00B6 G + 7 G$autobaud$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$autobaud$0$0 = 0057 GR + _AC = 00D6 + _ACC = 00E0 + _AUXR = 008E + _B = 00F0 + _CY = 00D7 + _DPH = 0083 + _DPL = 0082 + _EA = 00AF + _ES = 00AC + _ET0 = 00A9 + _ET1 = 00AB + _EX0 = 00A8 + _EX1 = 00AA + _F0 = 00D5 + _IE = 00A8 + _IE0 = 0089 + _IE1 = 008B + _INT0 = 00B2 + _INT1 = 00B3 + _IP = 00B8 + _IT0 = 0088 + _IT1 = 008A + _OV = 00D2 + _P = 00D0 + _P0 = 0080 + _P1 = 0090 + _P1_0 = 0090 + _P1_1 = 0091 + _P1_2 = 0092 + _P1_3 = 0093 + _P1_4 = 0094 + _P1_5 = 0095 + _P1_6 = 0096 + _P1_7 = 0097 + _P2 = 00A0 + _P3 = 00B0 + _PCON = 0087 + _PS = 00BC + _PSW = 00D0 + _PT0 = 00B9 + _PT1 = 00BB + _PX0 = 00B8 + _PX1 = 00BA + _RB8 = 009A + _RCAP2H = 00CB + _RCAP2L = 00CA + _RD = 00B7 + _REN = 009C + _RI = 0098 + _RS0 = 00D3 + _RS1 = 00D4 + _RXD = 00B0 + _SBUF = 0099 + _SCON = 0098 + _SM0 = 009F + _SM1 = 009E + _SM2 = 009D + _SP = 0081 + _T0 = 00B4 + _T1 = 00B5 + _T2CON = 00C8 + _T2CON_0 = 00C8 + _T2CON_1 = 00C9 + _T2CON_2 = 00CA + _T2CON_3 = 00CB + _T2CON_4 = 00CC + _T2CON_5 = 00CD + _T2CON_6 = 00CE + _T2CON_7 = 00CF + _TB8 = 009B + _TCON = 0088 + _TF0 = 008D + _TF1 = 008F + _TH0 = 008C + _TH1 = 008D + _TI = 0099 + _TL0 = 008A + _TL1 = 008B + _TMOD = 0089 + _TR0 = 008C + _TR1 = 008E + _TXD = 00B1 + _WR = 00B6 + 7 _autobaud 0000 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 0 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 58 flags 20 diff --git a/device/lib/_bp.c b/device/lib/_bp.c new file mode 100644 index 00000000..96294aec --- /dev/null +++ b/device/lib/_bp.c @@ -0,0 +1,26 @@ +/*------------------------------------------------------------------------- + + _bp.c :- just declares bp as a variable + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +data unsigned char bp ; diff --git a/device/lib/_bp.lst b/device/lib/_bp.lst new file mode 100644 index 00000000..5b8c0507 --- /dev/null +++ b/device/lib/_bp.lst @@ -0,0 +1,48 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _bp + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _bp + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 G$bp$0$0==. + 0000 22 _bp: + 0000 23 .ds 0x0001 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 40 ;-------------------------------------------------------- + 41 ; global & static initialisations + 42 ;-------------------------------------------------------- + 43 .area GSINIT (CODE) + 44 ;-------------------------------------------------------- + 45 ; code + 46 ;-------------------------------------------------------- + 47 .area CSEG (CODE) + 48 .area CSEG (CODE) diff --git a/device/lib/_bp.sym b/device/lib/_bp.sym new file mode 100644 index 00000000..1f3c60a1 --- /dev/null +++ b/device/lib/_bp.sym @@ -0,0 +1,355 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 1 G$bp$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 1 _bp 0000 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 1 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 0 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 0 flags 20 diff --git a/device/lib/_char2fs.c b/device/lib/_char2fs.c new file mode 100644 index 00000000..ec3e12dc --- /dev/null +++ b/device/lib/_char2fs.c @@ -0,0 +1,110 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +float +__char2fs (char a ) +{ + long sign = 0; + int exp = 24 + EXCESS; + volatile union float_long fl; + long a1 = a; + + if (!a1) + { + fl.l = 0; + return (fl.f); + } + + if (a1 < 0) + { + sign = SIGNBIT; + a1 = -a1; + } + + while (a1 < HIDDEN) + { + a1 <<= 1; + exp--; + } + + a1 &= ~HIDDEN; + /* pack up and go home */ + fl.l = PACK(sign,(unsigned long)exp, a1); + + return (fl.f); +} diff --git a/device/lib/_char2fs.lst b/device/lib/_char2fs.lst new file mode 100644 index 00000000..62059d62 --- /dev/null +++ b/device/lib/_char2fs.lst @@ -0,0 +1,334 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _char2fs + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___char2fs + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___char2fs_sloc0_1_0: + 0000 22 .ds 0x0002 + 0002 23 ___char2fs_sloc1_1_0: + 0002 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___char2fs_a_1_1: + 0000 42 .ds 0x0001 + 0001 43 ___char2fs_sign_1_1: + 0001 44 .ds 0x0004 + 0005 45 ___char2fs_fl_1_1: + 0005 46 .ds 0x0004 + 0009 47 ___char2fs_a1_1_1: + 0009 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__char2fs$0$0 ==. + 58 ; _char2fs.c 80 + 59 ; ----------------------------------------- + 60 ; function __char2fs + 61 ; ----------------------------------------- + 0000 62 ___char2fs: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _char2fs.c 109 + 0000 C0 82 72 push dpl + 0002 90s00r00 73 mov dptr,#___char2fs_a_1_1 + 0005 D0 E0 74 pop acc + 0007 F0 75 movx @dptr,a + 76 ; _char2fs.c 82 + 0008 90s00r01 77 mov dptr,#___char2fs_sign_1_1 + 000B E4 78 clr a + 000C A3 79 inc dptr + 000D A3 80 inc dptr + 000E A3 81 inc dptr + 000F F0 82 movx @dptr,a + 0010 12s00r00 83 lcall __decdptr + 0013 F0 84 movx @dptr,a + 0014 12s00r00 85 lcall __decdptr + 0017 F0 86 movx @dptr,a + 0018 12s00r00 87 lcall __decdptr + 001B F0 88 movx @dptr,a + 89 ; _char2fs.c 85 + 001C 90s00r00 90 mov dptr,#___char2fs_a_1_1 + 001F E0 91 movx a,@dptr + 92 ; Peephole 105 removed redundant mov + 0020 FA 93 mov r2,a + 0021 33 94 rlc a + 0022 95 E0 95 subb a,acc + 0024 FB 96 mov r3,a + 0025 FC 97 mov r4,a + 0026 FD 98 mov r5,a + 0027 90s00r09 99 mov dptr,#___char2fs_a1_1_1 + 002A EA 100 mov a,r2 + 002B F0 101 movx @dptr,a + 002C A3 102 inc dptr + 002D EB 103 mov a,r3 + 002E F0 104 movx @dptr,a + 002F A3 105 inc dptr + 0030 EC 106 mov a,r4 + 0031 F0 107 movx @dptr,a + 0032 A3 108 inc dptr + 0033 ED 109 mov a,r5 + 0034 F0 110 movx @dptr,a + 111 ; _char2fs.c 87 + 0035 EA 112 mov a,r2 + 0036 4B 113 orl a,r3 + 0037 4C 114 orl a,r4 + 0038 4D 115 orl a,r5 + 116 ; Peephole 109 removed ljmp by inverse jump logic + 0039 70 23 117 jnz 00102$ + 003B 118 00114$: + 119 ; _char2fs.c 89 + 003B 90s00r05 120 mov dptr,#(___char2fs_fl_1_1) + 121 ; Peephole 101 removed redundant mov + 122 ; Peephole 180 changed mov to clr + 003E E4 123 clr a + 003F F0 124 movx @dptr,a + 0040 A3 125 inc dptr + 0041 F0 126 movx @dptr,a + 0042 A3 127 inc dptr + 128 ; Peephole 101 removed redundant mov + 129 ; Peephole 180 changed mov to clr + 0043 E4 130 clr a + 0044 F0 131 movx @dptr,a + 0045 A3 132 inc dptr + 0046 F0 133 movx @dptr,a + 134 ; _char2fs.c 90 + 0047 90s00r05 135 mov dptr,#(___char2fs_fl_1_1) + 004A E0 136 movx a,@dptr + 004B FE 137 mov r6,a + 004C A3 138 inc dptr + 004D E0 139 movx a,@dptr + 004E FF 140 mov r7,a + 004F A3 141 inc dptr + 0050 E0 142 movx a,@dptr + 0051 F8 143 mov r0,a + 0052 A3 144 inc dptr + 0053 E0 145 movx a,@dptr + 146 ; Peephole 191 removed redundant mov + 0054 F9 147 mov r1,a + 0055 8E 82 148 mov dpl,r6 + 0057 8F 83 149 mov dph,r7 + 0059 88 F0 150 mov b,r0 + 005B 02s01r3B 151 ljmp 00108$ + 005E 152 00102$: + 153 ; _char2fs.c 93 + 005E ED 154 mov a,r5 + 155 ; Peephole 111 removed ljmp by inverse jump logic + 005F 30 E7 21 156 jnb acc.7,00113$ + 0062 157 00115$: + 158 ; _char2fs.c 95 + 0062 90s00r01 159 mov dptr,#___char2fs_sign_1_1 + 160 ; Peephole 101 removed redundant mov + 161 ; Peephole 180 changed mov to clr + 0065 E4 162 clr a + 0066 F0 163 movx @dptr,a + 0067 A3 164 inc dptr + 0068 F0 165 movx @dptr,a + 0069 A3 166 inc dptr + 167 ; Peephole 180 changed mov to clr + 006A E4 168 clr a + 006B F0 169 movx @dptr,a + 006C A3 170 inc dptr + 006D 74 80 171 mov a,#0x80 + 006F F0 172 movx @dptr,a + 173 ; _char2fs.c 96 + 0070 90s00r09 174 mov dptr,#___char2fs_a1_1_1 + 0073 C3 175 clr c + 0074 E4 176 clr a + 0075 9A 177 subb a,r2 + 0076 F0 178 movx @dptr,a + 0077 E4 179 clr a + 0078 9B 180 subb a,r3 + 0079 A3 181 inc dptr + 007A F0 182 movx @dptr,a + 007B E4 183 clr a + 007C 9C 184 subb a,r4 + 007D A3 185 inc dptr + 007E F0 186 movx @dptr,a + 007F E4 187 clr a + 0080 9D 188 subb a,r5 + 0081 A3 189 inc dptr + 0082 F0 190 movx @dptr,a + 191 ; _char2fs.c 99 + 0083 192 00113$: + 0083 E4 193 clr a + 0084 F5*01 194 mov (___char2fs_sloc0_1_0 + 1),a + 0086 75*00 96 195 mov ___char2fs_sloc0_1_0,#0x96 + 0089 196 00105$: + 0089 90s00r09 197 mov dptr,#___char2fs_a1_1_1 + 008C E0 198 movx a,@dptr + 008D FC 199 mov r4,a + 008E A3 200 inc dptr + 008F E0 201 movx a,@dptr + 0090 FD 202 mov r5,a + 0091 A3 203 inc dptr + 0092 E0 204 movx a,@dptr + 0093 FE 205 mov r6,a + 0094 A3 206 inc dptr + 0095 E0 207 movx a,@dptr + 0096 FF 208 mov r7,a + 0097 C3 209 clr c + 0098 EC 210 mov a,r4 + 0099 94 00 211 subb a,#0x00 + 009B ED 212 mov a,r5 + 009C 94 00 213 subb a,#0x00 + 009E EE 214 mov a,r6 + 009F 94 80 215 subb a,#0x80 + 00A1 EF 216 mov a,r7 + 00A2 94 00 217 subb a,#0x00 + 218 ; Peephole 108 removed ljmp by inverse jump logic + 00A4 50 27 219 jnc 00107$ + 00A6 220 00116$: + 221 ; _char2fs.c 101 + 00A6 EC 222 mov a,r4 + 00A7 25 E0 223 add a,acc + 00A9 F8 224 mov r0,a + 00AA ED 225 mov a,r5 + 00AB 33 226 rlc a + 00AC F9 227 mov r1,a + 00AD EE 228 mov a,r6 + 00AE 33 229 rlc a + 00AF FA 230 mov r2,a + 00B0 EF 231 mov a,r7 + 00B1 33 232 rlc a + 00B2 FB 233 mov r3,a + 00B3 90s00r09 234 mov dptr,#___char2fs_a1_1_1 + 00B6 E8 235 mov a,r0 + 00B7 F0 236 movx @dptr,a + 00B8 A3 237 inc dptr + 00B9 E9 238 mov a,r1 + 00BA F0 239 movx @dptr,a + 00BB A3 240 inc dptr + 00BC EA 241 mov a,r2 + 00BD F0 242 movx @dptr,a + 00BE A3 243 inc dptr + 00BF EB 244 mov a,r3 + 00C0 F0 245 movx @dptr,a + 246 ; _char2fs.c 102 + 00C1 15*00 247 dec ___char2fs_sloc0_1_0 + 00C3 74 FF 248 mov a,#0xff + 00C5 B5*00 02 249 cjne a,___char2fs_sloc0_1_0,00117$ + 00C8 15*01 250 dec (___char2fs_sloc0_1_0 + 1) + 00CA 251 00117$: + 00CA 02s00r89 252 ljmp 00105$ + 00CD 253 00107$: + 254 ; _char2fs.c 105 + 00CD 53 06 7F 255 anl ar6,#0x7f + 256 ; _char2fs.c 107 + 00D0 AA*00 257 mov r2,___char2fs_sloc0_1_0 + 00D2 AB*01 258 mov r3,(___char2fs_sloc0_1_0 + 1) + 00D4 78 00 259 mov r0,#0x00 + 00D6 79 00 260 mov r1,#0x00 + 00D8 8A*04 261 mov (___char2fs_sloc1_1_0 + 2),r2 + 00DA EB 262 mov a,r3 + 00DB 54 01 263 anl a,#0x01 + 00DD A2 E0 264 mov c,acc.0 + 00DF C5*04 265 xch a,(___char2fs_sloc1_1_0 + 2) + 00E1 13 266 rrc a + 00E2 C5*04 267 xch a,(___char2fs_sloc1_1_0 + 2) + 00E4 13 268 rrc a + 00E5 C5*04 269 xch a,(___char2fs_sloc1_1_0 + 2) + 00E7 F5*05 270 mov (___char2fs_sloc1_1_0 + 3),a + 00E9 75*03 00 271 mov (___char2fs_sloc1_1_0 + 1),#0x00 + 00EC 75*02 00 272 mov ___char2fs_sloc1_1_0,#0x00 + 00EF 90s00r01 273 mov dptr,#___char2fs_sign_1_1 + 00F2 E0 274 movx a,@dptr + 00F3 FA 275 mov r2,a + 00F4 A3 276 inc dptr + 00F5 E0 277 movx a,@dptr + 00F6 FB 278 mov r3,a + 00F7 A3 279 inc dptr + 00F8 E0 280 movx a,@dptr + 00F9 F8 281 mov r0,a + 00FA A3 282 inc dptr + 00FB E0 283 movx a,@dptr + 00FC F9 284 mov r1,a + 00FD E5*02 285 mov a,___char2fs_sloc1_1_0 + 00FF 42 02 286 orl ar2,a + 0101 E5*03 287 mov a,(___char2fs_sloc1_1_0 + 1) + 0103 42 03 288 orl ar3,a + 0105 E5*04 289 mov a,(___char2fs_sloc1_1_0 + 2) + 0107 42 00 290 orl ar0,a + 0109 E5*05 291 mov a,(___char2fs_sloc1_1_0 + 3) + 010B 42 01 292 orl ar1,a + 010D EA 293 mov a,r2 + 010E 42 04 294 orl ar4,a + 0110 EB 295 mov a,r3 + 0111 42 05 296 orl ar5,a + 0113 E8 297 mov a,r0 + 0114 42 06 298 orl ar6,a + 0116 E9 299 mov a,r1 + 0117 42 07 300 orl ar7,a + 0119 90s00r05 301 mov dptr,#(___char2fs_fl_1_1) + 011C EC 302 mov a,r4 + 011D F0 303 movx @dptr,a + 011E A3 304 inc dptr + 011F ED 305 mov a,r5 + 0120 F0 306 movx @dptr,a + 0121 A3 307 inc dptr + 0122 EE 308 mov a,r6 + 0123 F0 309 movx @dptr,a + 0124 A3 310 inc dptr + 0125 EF 311 mov a,r7 + 0126 F0 312 movx @dptr,a + 313 ; _char2fs.c 109 + 0127 90s00r05 314 mov dptr,#(___char2fs_fl_1_1) + 012A E0 315 movx a,@dptr + 012B FA 316 mov r2,a + 012C A3 317 inc dptr + 012D E0 318 movx a,@dptr + 012E FB 319 mov r3,a + 012F A3 320 inc dptr + 0130 E0 321 movx a,@dptr + 0131 FC 322 mov r4,a + 0132 A3 323 inc dptr + 0133 E0 324 movx a,@dptr + 325 ; Peephole 191 removed redundant mov + 0134 FD 326 mov r5,a + 0135 8A 82 327 mov dpl,r2 + 0137 8B 83 328 mov dph,r3 + 0139 8C F0 329 mov b,r4 + 013B 330 00108$: + 013B 331 C$_char2fs.c$110$1$1 ==. + 013B 332 XG$__char2fs$0$0 ==. + 013B 22 333 ret + 334 .area CSEG (CODE) diff --git a/device/lib/_char2fs.sym b/device/lib/_char2fs.sym new file mode 100644 index 00000000..a3d378cf --- /dev/null +++ b/device/lib/_char2fs.sym @@ -0,0 +1,596 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_char2fs$100 002A GR + 7 A$_char2fs$101 002B GR + 7 A$_char2fs$102 002C GR + 7 A$_char2fs$103 002D GR + 7 A$_char2fs$104 002E GR + 7 A$_char2fs$105 002F GR + 7 A$_char2fs$106 0030 GR + 7 A$_char2fs$107 0031 GR + 7 A$_char2fs$108 0032 GR + 7 A$_char2fs$109 0033 GR + 7 A$_char2fs$110 0034 GR + 7 A$_char2fs$112 0035 GR + 7 A$_char2fs$113 0036 GR + 7 A$_char2fs$114 0037 GR + 7 A$_char2fs$115 0038 GR + 7 A$_char2fs$117 0039 GR + 7 A$_char2fs$120 003B GR + 7 A$_char2fs$123 003E GR + 7 A$_char2fs$124 003F GR + 7 A$_char2fs$125 0040 GR + 7 A$_char2fs$126 0041 GR + 7 A$_char2fs$127 0042 GR + 7 A$_char2fs$130 0043 GR + 7 A$_char2fs$131 0044 GR + 7 A$_char2fs$132 0045 GR + 7 A$_char2fs$133 0046 GR + 7 A$_char2fs$135 0047 GR + 7 A$_char2fs$136 004A GR + 7 A$_char2fs$137 004B GR + 7 A$_char2fs$138 004C GR + 7 A$_char2fs$139 004D GR + 7 A$_char2fs$140 004E GR + 7 A$_char2fs$141 004F GR + 7 A$_char2fs$142 0050 GR + 7 A$_char2fs$143 0051 GR + 7 A$_char2fs$144 0052 GR + 7 A$_char2fs$145 0053 GR + 7 A$_char2fs$147 0054 GR + 7 A$_char2fs$148 0055 GR + 7 A$_char2fs$149 0057 GR + 7 A$_char2fs$150 0059 GR + 7 A$_char2fs$151 005B GR + 7 A$_char2fs$154 005E GR + 7 A$_char2fs$156 005F GR + 7 A$_char2fs$159 0062 GR + 7 A$_char2fs$162 0065 GR + 7 A$_char2fs$163 0066 GR + 7 A$_char2fs$164 0067 GR + 7 A$_char2fs$165 0068 GR + 7 A$_char2fs$166 0069 GR + 7 A$_char2fs$168 006A GR + 7 A$_char2fs$169 006B GR + 7 A$_char2fs$170 006C GR + 7 A$_char2fs$171 006D GR + 7 A$_char2fs$172 006F GR + 7 A$_char2fs$174 0070 GR + 7 A$_char2fs$175 0073 GR + 7 A$_char2fs$176 0074 GR + 7 A$_char2fs$177 0075 GR + 7 A$_char2fs$178 0076 GR + 7 A$_char2fs$179 0077 GR + 7 A$_char2fs$180 0078 GR + 7 A$_char2fs$181 0079 GR + 7 A$_char2fs$182 007A GR + 7 A$_char2fs$183 007B GR + 7 A$_char2fs$184 007C GR + 7 A$_char2fs$185 007D GR + 7 A$_char2fs$186 007E GR + 7 A$_char2fs$187 007F GR + 7 A$_char2fs$188 0080 GR + 7 A$_char2fs$189 0081 GR + 7 A$_char2fs$190 0082 GR + 7 A$_char2fs$193 0083 GR + 7 A$_char2fs$194 0084 GR + 7 A$_char2fs$195 0086 GR + 7 A$_char2fs$197 0089 GR + 7 A$_char2fs$198 008C GR + 7 A$_char2fs$199 008D GR + 7 A$_char2fs$200 008E GR + 7 A$_char2fs$201 008F GR + 7 A$_char2fs$202 0090 GR + 7 A$_char2fs$203 0091 GR + 7 A$_char2fs$204 0092 GR + 7 A$_char2fs$205 0093 GR + 7 A$_char2fs$206 0094 GR + 7 A$_char2fs$207 0095 GR + 7 A$_char2fs$208 0096 GR + 7 A$_char2fs$209 0097 GR + 7 A$_char2fs$210 0098 GR + 7 A$_char2fs$211 0099 GR + 7 A$_char2fs$212 009B GR + 7 A$_char2fs$213 009C GR + 7 A$_char2fs$214 009E GR + 7 A$_char2fs$215 009F GR + 7 A$_char2fs$216 00A1 GR + 7 A$_char2fs$217 00A2 GR + 7 A$_char2fs$219 00A4 GR + 7 A$_char2fs$222 00A6 GR + 7 A$_char2fs$223 00A7 GR + 7 A$_char2fs$224 00A9 GR + 7 A$_char2fs$225 00AA GR + 7 A$_char2fs$226 00AB GR + 7 A$_char2fs$227 00AC GR + 7 A$_char2fs$228 00AD GR + 7 A$_char2fs$229 00AE GR + 7 A$_char2fs$230 00AF GR + 7 A$_char2fs$231 00B0 GR + 7 A$_char2fs$232 00B1 GR + 7 A$_char2fs$233 00B2 GR + 7 A$_char2fs$234 00B3 GR + 7 A$_char2fs$235 00B6 GR + 7 A$_char2fs$236 00B7 GR + 7 A$_char2fs$237 00B8 GR + 7 A$_char2fs$238 00B9 GR + 7 A$_char2fs$239 00BA GR + 7 A$_char2fs$240 00BB GR + 7 A$_char2fs$241 00BC GR + 7 A$_char2fs$242 00BD GR + 7 A$_char2fs$243 00BE GR + 7 A$_char2fs$244 00BF GR + 7 A$_char2fs$245 00C0 GR + 7 A$_char2fs$247 00C1 GR + 7 A$_char2fs$248 00C3 GR + 7 A$_char2fs$249 00C5 GR + 7 A$_char2fs$250 00C8 GR + 7 A$_char2fs$252 00CA GR + 7 A$_char2fs$255 00CD GR + 7 A$_char2fs$257 00D0 GR + 7 A$_char2fs$258 00D2 GR + 7 A$_char2fs$259 00D4 GR + 7 A$_char2fs$260 00D6 GR + 7 A$_char2fs$261 00D8 GR + 7 A$_char2fs$262 00DA GR + 7 A$_char2fs$263 00DB GR + 7 A$_char2fs$264 00DD GR + 7 A$_char2fs$265 00DF GR + 7 A$_char2fs$266 00E1 GR + 7 A$_char2fs$267 00E2 GR + 7 A$_char2fs$268 00E4 GR + 7 A$_char2fs$269 00E5 GR + 7 A$_char2fs$270 00E7 GR + 7 A$_char2fs$271 00E9 GR + 7 A$_char2fs$272 00EC GR + 7 A$_char2fs$273 00EF GR + 7 A$_char2fs$274 00F2 GR + 7 A$_char2fs$275 00F3 GR + 7 A$_char2fs$276 00F4 GR + 7 A$_char2fs$277 00F5 GR + 7 A$_char2fs$278 00F6 GR + 7 A$_char2fs$279 00F7 GR + 7 A$_char2fs$280 00F8 GR + 7 A$_char2fs$281 00F9 GR + 7 A$_char2fs$282 00FA GR + 7 A$_char2fs$283 00FB GR + 7 A$_char2fs$284 00FC GR + 7 A$_char2fs$285 00FD GR + 7 A$_char2fs$286 00FF GR + 7 A$_char2fs$287 0101 GR + 7 A$_char2fs$288 0103 GR + 7 A$_char2fs$289 0105 GR + 7 A$_char2fs$290 0107 GR + 7 A$_char2fs$291 0109 GR + 7 A$_char2fs$292 010B GR + 7 A$_char2fs$293 010D GR + 7 A$_char2fs$294 010E GR + 7 A$_char2fs$295 0110 GR + 7 A$_char2fs$296 0111 GR + 7 A$_char2fs$297 0113 GR + 7 A$_char2fs$298 0114 GR + 7 A$_char2fs$299 0116 GR + 7 A$_char2fs$300 0117 GR + 7 A$_char2fs$301 0119 GR + 7 A$_char2fs$302 011C GR + 7 A$_char2fs$303 011D GR + 7 A$_char2fs$304 011E GR + 7 A$_char2fs$305 011F GR + 7 A$_char2fs$306 0120 GR + 7 A$_char2fs$307 0121 GR + 7 A$_char2fs$308 0122 GR + 7 A$_char2fs$309 0123 GR + 7 A$_char2fs$310 0124 GR + 7 A$_char2fs$311 0125 GR + 7 A$_char2fs$312 0126 GR + 7 A$_char2fs$314 0127 GR + 7 A$_char2fs$315 012A GR + 7 A$_char2fs$316 012B GR + 7 A$_char2fs$317 012C GR + 7 A$_char2fs$318 012D GR + 7 A$_char2fs$319 012E GR + 7 A$_char2fs$320 012F GR + 7 A$_char2fs$321 0130 GR + 7 A$_char2fs$322 0131 GR + 7 A$_char2fs$323 0132 GR + 7 A$_char2fs$324 0133 GR + 7 A$_char2fs$326 0134 GR + 7 A$_char2fs$327 0135 GR + 7 A$_char2fs$328 0137 GR + 7 A$_char2fs$329 0139 GR + 7 A$_char2fs$333 013B GR + 7 A$_char2fs$72 0000 GR + 7 A$_char2fs$73 0002 GR + 7 A$_char2fs$74 0005 GR + 7 A$_char2fs$75 0007 GR + 7 A$_char2fs$77 0008 GR + 7 A$_char2fs$78 000B GR + 7 A$_char2fs$79 000C GR + 7 A$_char2fs$80 000D GR + 7 A$_char2fs$81 000E GR + 7 A$_char2fs$82 000F GR + 7 A$_char2fs$83 0010 GR + 7 A$_char2fs$84 0013 GR + 7 A$_char2fs$85 0014 GR + 7 A$_char2fs$86 0017 GR + 7 A$_char2fs$87 0018 GR + 7 A$_char2fs$88 001B GR + 7 A$_char2fs$90 001C GR + 7 A$_char2fs$91 001F GR + 7 A$_char2fs$93 0020 GR + 7 A$_char2fs$94 0021 GR + 7 A$_char2fs$95 0022 GR + 7 A$_char2fs$96 0024 GR + 7 A$_char2fs$97 0025 GR + 7 A$_char2fs$98 0026 GR + 7 A$_char2fs$99 0027 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_char2fs.c$110$1$1 = 013B GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__char2fs$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__char2fs$0$0 = 013B GR + 7 ___char2fs 0000 GR + 5 ___char2fs_a1_1_1 0009 R + 5 ___char2fs_a_1_1 0000 R + 5 ___char2fs_fl_1_1 0005 R + 5 ___char2fs_sign_1_1 0001 R + 1 ___char2fs_sloc0_1_0 0000 R + 1 ___char2fs_sloc1_1_0 0002 R + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size D flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 13C flags 20 diff --git a/device/lib/_decdptr.c b/device/lib/_decdptr.c new file mode 100644 index 00000000..56acec51 --- /dev/null +++ b/device/lib/_decdptr.c @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------- + + _decdptr.c :- decrement dptr by 1 + + Ecrit par - Jean-Louis Vern jlvern@writeme.com (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +unsigned char _decdptr () +{ + _asm + xch a,dpl + jnz 00001$ + dec dph +00001$: + dec a + xch a,dpl + _endasm ; +} diff --git a/device/lib/_decdptr.lst b/device/lib/_decdptr.lst new file mode 100644 index 00000000..977f6254 --- /dev/null +++ b/device/lib/_decdptr.lst @@ -0,0 +1,70 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _decdptr + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __decdptr + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 37 ;-------------------------------------------------------- + 38 ; global & static initialisations + 39 ;-------------------------------------------------------- + 40 .area GSINIT (CODE) + 41 ;-------------------------------------------------------- + 42 ; code + 43 ;-------------------------------------------------------- + 44 .area CSEG (CODE) + 0000 45 G$_decdptr$0$0 ==. + 46 ; _decdptr.c 26 + 47 ; ----------------------------------------- + 48 ; function _decdptr + 49 ; ----------------------------------------- + 0000 50 __decdptr: + 0002 51 ar2 = 0x02 + 0003 52 ar3 = 0x03 + 0004 53 ar4 = 0x04 + 0005 54 ar5 = 0x05 + 0006 55 ar6 = 0x06 + 0007 56 ar7 = 0x07 + 0000 57 ar0 = 0x00 + 0001 58 ar1 = 0x01 + 59 ; _decdptr.c 35 + 0000 C5 82 60 xch a,dpl + 0002 70 02 61 jnz 00001$ + 0004 15 83 62 dec dph + 0006 63 00001$: + 0006 14 64 dec a + 0007 C5 82 65 xch a,dpl + 0009 66 00101$: + 0009 67 C$_decdptr.c$36$1$1 ==. + 0009 68 XG$_decdptr$0$0 ==. + 0009 22 69 ret + 70 .area CSEG (CODE) diff --git a/device/lib/_decdptr.sym b/device/lib/_decdptr.sym new file mode 100644 index 00000000..c9f6ab3c --- /dev/null +++ b/device/lib/_decdptr.sym @@ -0,0 +1,371 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_decdptr$60 0000 GR + 7 A$_decdptr$61 0002 GR + 7 A$_decdptr$62 0004 GR + 7 A$_decdptr$64 0006 GR + 7 A$_decdptr$65 0007 GR + 7 A$_decdptr$69 0009 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_decdptr.c$36$1$1 = 0009 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_decdptr$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_decdptr$0$0 = 0009 GR + 7 __decdptr 0000 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 0 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size A flags 20 diff --git a/device/lib/_divsint.c b/device/lib/_divsint.c new file mode 100644 index 00000000..4defb60e --- /dev/null +++ b/device/lib/_divsint.c @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------- + + _divsint.c :- routine for signed int (16 bit) division. just calls + routine for unsigned division after sign adjustment + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +int _divsint (int a, int b) +#ifndef SDCC_STACK_AUTO + critical +#endif +{ + register int r; + + r = _divuint((a < 0 ? -a : a), + (b < 0 ? -b : b)); + if ( (a < 0) ^ (b < 0)) { + + return -r; + } + else { + + return r; + } +} diff --git a/device/lib/_divsint.lst b/device/lib/_divsint.lst new file mode 100644 index 00000000..5bbd41c6 --- /dev/null +++ b/device/lib/_divsint.lst @@ -0,0 +1,180 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _divsint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __divsint_PARM_2 + 11 .globl __divsint + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 __divsint_PARM_2: + 0000 39 .ds 0x0002 + 0002 40 __divsint_a_1_1: + 0002 41 .ds 0x0002 + 42 ;-------------------------------------------------------- + 43 ; global & static initialisations + 44 ;-------------------------------------------------------- + 45 .area GSINIT (CODE) + 46 ;-------------------------------------------------------- + 47 ; code + 48 ;-------------------------------------------------------- + 49 .area CSEG (CODE) + 0000 50 G$_divsint$0$0 ==. + 51 ; _divsint.c 26 + 52 ; ----------------------------------------- + 53 ; function _divsint + 54 ; ----------------------------------------- + 0000 55 __divsint: + 0000 C2 AF 56 clr ea + 0002 57 ar2 = 0x02 + 0003 58 ar3 = 0x03 + 0004 59 ar4 = 0x04 + 0005 60 ar5 = 0x05 + 0006 61 ar6 = 0x06 + 0007 62 ar7 = 0x07 + 0000 63 ar0 = 0x00 + 0001 64 ar1 = 0x01 + 65 ; _divsint.c 0 + 0002 C0 83 66 push dph + 0004 C0 82 67 push dpl + 0006 90s00r02 68 mov dptr,#__divsint_a_1_1 + 0009 D0 E0 69 pop acc + 000B F0 70 movx @dptr,a + 000C D0 E0 71 pop acc + 000E A3 72 inc dptr + 000F F0 73 movx @dptr,a + 74 ; _divsint.c 33 + 0010 90s00r02 75 mov dptr,#__divsint_a_1_1 + 0013 E0 76 movx a,@dptr + 0014 FA 77 mov r2,a + 0015 A3 78 inc dptr + 0016 E0 79 movx a,@dptr + 80 ; Peephole 105 removed redundant mov + 0017 FB 81 mov r3,a + 82 ; Peephole 111 removed ljmp by inverse jump logic + 0018 30 E7 09 83 jnb acc.7,00106$ + 001B 84 00113$: + 001B C3 85 clr c + 001C E4 86 clr a + 001D 9A 87 subb a,r2 + 001E FC 88 mov r4,a + 001F E4 89 clr a + 0020 9B 90 subb a,r3 + 0021 FD 91 mov r5,a + 92 ; Peephole 132 changed ljmp to sjmp + 0022 80 04 93 sjmp 00107$ + 0024 94 00106$: + 0024 8A 04 95 mov ar4,r2 + 0026 8B 05 96 mov ar5,r3 + 0028 97 00107$: + 0028 8C 02 98 mov ar2,r4 + 002A 8D 03 99 mov ar3,r5 + 100 ; _divsint.c 34 + 002C 90s00r00 101 mov dptr,#__divsint_PARM_2 + 002F E0 102 movx a,@dptr + 0030 FC 103 mov r4,a + 0031 A3 104 inc dptr + 0032 E0 105 movx a,@dptr + 106 ; Peephole 105 removed redundant mov + 0033 FD 107 mov r5,a + 0034 33 108 rlc a + 0035 E4 109 clr a + 0036 33 110 rlc a + 111 ; Peephole 105 removed redundant mov + 0037 FE 112 mov r6,a + 113 ; Peephole 110 removed ljmp by inverse jump logic + 0038 60 09 114 jz 00108$ + 003A 115 00114$: + 003A C3 116 clr c + 003B E4 117 clr a + 003C 9C 118 subb a,r4 + 003D FF 119 mov r7,a + 003E E4 120 clr a + 003F 9D 121 subb a,r5 + 0040 F8 122 mov r0,a + 123 ; Peephole 132 changed ljmp to sjmp + 0041 80 04 124 sjmp 00109$ + 0043 125 00108$: + 0043 8C 07 126 mov ar7,r4 + 0045 8D 00 127 mov ar0,r5 + 0047 128 00109$: + 0047 90s00r00 129 mov dptr,#__divuint_PARM_2 + 004A EF 130 mov a,r7 + 004B F0 131 movx @dptr,a + 004C A3 132 inc dptr + 004D E8 133 mov a,r0 + 004E F0 134 movx @dptr,a + 004F C0 06 135 push ar6 + 0051 8A 82 136 mov dpl,r2 + 0053 8B 83 137 mov dph,r3 + 0055 12s00r00 138 lcall __divuint + 0058 AA 82 139 mov r2,dpl + 005A AB 83 140 mov r3,dph + 005C D0 06 141 pop ar6 + 142 ; _divsint.c 35 + 005E 90s00r02 143 mov dptr,#__divsint_a_1_1 + 0061 E0 144 movx a,@dptr + 0062 FC 145 mov r4,a + 0063 A3 146 inc dptr + 0064 E0 147 movx a,@dptr + 148 ; Peephole 105 removed redundant mov + 0065 FD 149 mov r5,a + 0066 33 150 rlc a + 0067 E4 151 clr a + 0068 33 152 rlc a + 0069 FC 153 mov r4,a + 006A EE 154 mov a,r6 + 006B 65 04 155 xrl a,ar4 + 156 ; Peephole 110 removed ljmp by inverse jump logic + 006D 60 0D 157 jz 00102$ + 006F 158 00115$: + 159 ; _divsint.c 37 + 006F C3 160 clr c + 0070 E4 161 clr a + 0071 9A 162 subb a,r2 + 0072 FC 163 mov r4,a + 0073 E4 164 clr a + 0074 9B 165 subb a,r3 + 0075 FE 166 mov r6,a + 0076 8C 82 167 mov dpl,r4 + 0078 8E 83 168 mov dph,r6 + 169 ; Peephole 132 changed ljmp to sjmp + 007A 80 04 170 sjmp 00104$ + 007C 171 00102$: + 172 ; _divsint.c 41 + 007C 8A 82 173 mov dpl,r2 + 007E 8B 83 174 mov dph,r3 + 0080 175 00104$: + 0080 D2 AF 176 setb ea + 0082 177 C$_divsint.c$43$1$1 ==. + 0082 178 XG$_divsint$0$0 ==. + 0082 22 179 ret + 180 .area CSEG (CODE) diff --git a/device/lib/_divsint.sym b/device/lib/_divsint.sym new file mode 100644 index 00000000..e99e3a53 --- /dev/null +++ b/device/lib/_divsint.sym @@ -0,0 +1,458 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_divsint$101 002C GR + 7 A$_divsint$102 002F GR + 7 A$_divsint$103 0030 GR + 7 A$_divsint$104 0031 GR + 7 A$_divsint$105 0032 GR + 7 A$_divsint$107 0033 GR + 7 A$_divsint$108 0034 GR + 7 A$_divsint$109 0035 GR + 7 A$_divsint$110 0036 GR + 7 A$_divsint$112 0037 GR + 7 A$_divsint$114 0038 GR + 7 A$_divsint$116 003A GR + 7 A$_divsint$117 003B GR + 7 A$_divsint$118 003C GR + 7 A$_divsint$119 003D GR + 7 A$_divsint$120 003E GR + 7 A$_divsint$121 003F GR + 7 A$_divsint$122 0040 GR + 7 A$_divsint$124 0041 GR + 7 A$_divsint$126 0043 GR + 7 A$_divsint$127 0045 GR + 7 A$_divsint$129 0047 GR + 7 A$_divsint$130 004A GR + 7 A$_divsint$131 004B GR + 7 A$_divsint$132 004C GR + 7 A$_divsint$133 004D GR + 7 A$_divsint$134 004E GR + 7 A$_divsint$135 004F GR + 7 A$_divsint$136 0051 GR + 7 A$_divsint$137 0053 GR + 7 A$_divsint$138 0055 GR + 7 A$_divsint$139 0058 GR + 7 A$_divsint$140 005A GR + 7 A$_divsint$141 005C GR + 7 A$_divsint$143 005E GR + 7 A$_divsint$144 0061 GR + 7 A$_divsint$145 0062 GR + 7 A$_divsint$146 0063 GR + 7 A$_divsint$147 0064 GR + 7 A$_divsint$149 0065 GR + 7 A$_divsint$150 0066 GR + 7 A$_divsint$151 0067 GR + 7 A$_divsint$152 0068 GR + 7 A$_divsint$153 0069 GR + 7 A$_divsint$154 006A GR + 7 A$_divsint$155 006B GR + 7 A$_divsint$157 006D GR + 7 A$_divsint$160 006F GR + 7 A$_divsint$161 0070 GR + 7 A$_divsint$162 0071 GR + 7 A$_divsint$163 0072 GR + 7 A$_divsint$164 0073 GR + 7 A$_divsint$165 0074 GR + 7 A$_divsint$166 0075 GR + 7 A$_divsint$167 0076 GR + 7 A$_divsint$168 0078 GR + 7 A$_divsint$170 007A GR + 7 A$_divsint$173 007C GR + 7 A$_divsint$174 007E GR + 7 A$_divsint$176 0080 GR + 7 A$_divsint$179 0082 GR + 7 A$_divsint$56 0000 GR + 7 A$_divsint$66 0002 GR + 7 A$_divsint$67 0004 GR + 7 A$_divsint$68 0006 GR + 7 A$_divsint$69 0009 GR + 7 A$_divsint$70 000B GR + 7 A$_divsint$71 000C GR + 7 A$_divsint$72 000E GR + 7 A$_divsint$73 000F GR + 7 A$_divsint$75 0010 GR + 7 A$_divsint$76 0013 GR + 7 A$_divsint$77 0014 GR + 7 A$_divsint$78 0015 GR + 7 A$_divsint$79 0016 GR + 7 A$_divsint$81 0017 GR + 7 A$_divsint$83 0018 GR + 7 A$_divsint$85 001B GR + 7 A$_divsint$86 001C GR + 7 A$_divsint$87 001D GR + 7 A$_divsint$88 001E GR + 7 A$_divsint$89 001F GR + 7 A$_divsint$90 0020 GR + 7 A$_divsint$91 0021 GR + 7 A$_divsint$93 0022 GR + 7 A$_divsint$95 0024 GR + 7 A$_divsint$96 0026 GR + 7 A$_divsint$98 0028 GR + 7 A$_divsint$99 002A GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_divsint.c$43$1$1 = 0082 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_divsint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_divsint$0$0 = 0082 GR + 7 __divsint 0000 GR + 5 __divsint_PARM_2 0000 GR + 5 __divsint_a_1_1 0002 R + __divuint **** GX + __divuint_PARM_2 **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 4 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 83 flags 20 diff --git a/device/lib/_divslong.c b/device/lib/_divslong.c new file mode 100644 index 00000000..a14b7cb6 --- /dev/null +++ b/device/lib/_divslong.c @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + _divslong.c - routine for division of 32 bit signed long + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +long _divslong (long a, long b) +{ + long r; + + r = _divulong((a < 0 ? -a : a), + (b < 0 ? -b : b)); + if ( (a < 0) ^ (b < 0)) + return -r; + else + return r; +} diff --git a/device/lib/_divslong.lst b/device/lib/_divslong.lst new file mode 100644 index 00000000..aefcd840 --- /dev/null +++ b/device/lib/_divslong.lst @@ -0,0 +1,254 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _divslong + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __divslong_PARM_2 + 11 .globl __divslong + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 __divslong_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 __divslong_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 __divslong_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 __divslong_a_1_1: + 0004 45 .ds 0x0004 + 46 ;-------------------------------------------------------- + 47 ; global & static initialisations + 48 ;-------------------------------------------------------- + 49 .area GSINIT (CODE) + 50 ;-------------------------------------------------------- + 51 ; code + 52 ;-------------------------------------------------------- + 53 .area CSEG (CODE) + 0000 54 G$_divslong$0$0 ==. + 55 ; _divslong.c 25 + 56 ; ----------------------------------------- + 57 ; function _divslong + 58 ; ----------------------------------------- + 0000 59 __divslong: + 0002 60 ar2 = 0x02 + 0003 61 ar3 = 0x03 + 0004 62 ar4 = 0x04 + 0005 63 ar5 = 0x05 + 0006 64 ar6 = 0x06 + 0007 65 ar7 = 0x07 + 0000 66 ar0 = 0x00 + 0001 67 ar1 = 0x01 + 68 ; _divslong.c 0 + 0000 C0 E0 69 push acc + 0002 C0 F0 70 push b + 0004 C0 83 71 push dph + 0006 C0 82 72 push dpl + 0008 90s00r04 73 mov dptr,#__divslong_a_1_1 + 000B D0 E0 74 pop acc + 000D F0 75 movx @dptr,a + 000E D0 E0 76 pop acc + 0010 A3 77 inc dptr + 0011 F0 78 movx @dptr,a + 0012 D0 E0 79 pop acc + 0014 A3 80 inc dptr + 0015 F0 81 movx @dptr,a + 0016 D0 E0 82 pop acc + 0018 A3 83 inc dptr + 0019 F0 84 movx @dptr,a + 85 ; _divslong.c 29 + 001A 90s00r04 86 mov dptr,#__divslong_a_1_1 + 001D E0 87 movx a,@dptr + 001E FA 88 mov r2,a + 001F A3 89 inc dptr + 0020 E0 90 movx a,@dptr + 0021 FB 91 mov r3,a + 0022 A3 92 inc dptr + 0023 E0 93 movx a,@dptr + 0024 FC 94 mov r4,a + 0025 A3 95 inc dptr + 0026 E0 96 movx a,@dptr + 97 ; Peephole 105 removed redundant mov + 0027 FD 98 mov r5,a + 99 ; Peephole 111 removed ljmp by inverse jump logic + 0028 30 E7 0F 100 jnb acc.7,00106$ + 002B 101 00113$: + 002B C3 102 clr c + 002C E4 103 clr a + 002D 9A 104 subb a,r2 + 002E FE 105 mov r6,a + 002F E4 106 clr a + 0030 9B 107 subb a,r3 + 0031 FF 108 mov r7,a + 0032 E4 109 clr a + 0033 9C 110 subb a,r4 + 0034 F8 111 mov r0,a + 0035 E4 112 clr a + 0036 9D 113 subb a,r5 + 0037 F9 114 mov r1,a + 115 ; Peephole 132 changed ljmp to sjmp + 0038 80 08 116 sjmp 00107$ + 003A 117 00106$: + 003A 8A 06 118 mov ar6,r2 + 003C 8B 07 119 mov ar7,r3 + 003E 8C 00 120 mov ar0,r4 + 0040 8D 01 121 mov ar1,r5 + 0042 122 00107$: + 0042 8E*00 123 mov __divslong_sloc0_1_0,r6 + 0044 8F*01 124 mov (__divslong_sloc0_1_0 + 1),r7 + 0046 88*02 125 mov (__divslong_sloc0_1_0 + 2),r0 + 0048 89*03 126 mov (__divslong_sloc0_1_0 + 3),r1 + 127 ; _divslong.c 30 + 004A 90s00r00 128 mov dptr,#__divslong_PARM_2 + 004D E0 129 movx a,@dptr + 004E FE 130 mov r6,a + 004F A3 131 inc dptr + 0050 E0 132 movx a,@dptr + 0051 FF 133 mov r7,a + 0052 A3 134 inc dptr + 0053 E0 135 movx a,@dptr + 0054 F8 136 mov r0,a + 0055 A3 137 inc dptr + 0056 E0 138 movx a,@dptr + 139 ; Peephole 105 removed redundant mov + 0057 F9 140 mov r1,a + 0058 33 141 rlc a + 0059 E4 142 clr a + 005A 33 143 rlc a + 144 ; Peephole 105 removed redundant mov + 005B FA 145 mov r2,a + 146 ; Peephole 110 removed ljmp by inverse jump logic + 005C 60 13 147 jz 00108$ + 005E 148 00114$: + 005E C3 149 clr c + 005F E4 150 clr a + 0060 9E 151 subb a,r6 + 0061 F5*04 152 mov __divslong_sloc1_1_0,a + 0063 E4 153 clr a + 0064 9F 154 subb a,r7 + 0065 F5*05 155 mov (__divslong_sloc1_1_0 + 1),a + 0067 E4 156 clr a + 0068 98 157 subb a,r0 + 0069 F5*06 158 mov (__divslong_sloc1_1_0 + 2),a + 006B E4 159 clr a + 006C 99 160 subb a,r1 + 006D F5*07 161 mov (__divslong_sloc1_1_0 + 3),a + 162 ; Peephole 132 changed ljmp to sjmp + 006F 80 08 163 sjmp 00109$ + 0071 164 00108$: + 0071 8E*04 165 mov __divslong_sloc1_1_0,r6 + 0073 8F*05 166 mov (__divslong_sloc1_1_0 + 1),r7 + 0075 88*06 167 mov (__divslong_sloc1_1_0 + 2),r0 + 0077 89*07 168 mov (__divslong_sloc1_1_0 + 3),r1 + 0079 169 00109$: + 0079 90s00r00 170 mov dptr,#__divulong_PARM_2 + 007C E5*04 171 mov a,__divslong_sloc1_1_0 + 007E F0 172 movx @dptr,a + 007F A3 173 inc dptr + 0080 E5*05 174 mov a,(__divslong_sloc1_1_0 + 1) + 0082 F0 175 movx @dptr,a + 0083 A3 176 inc dptr + 0084 E5*06 177 mov a,(__divslong_sloc1_1_0 + 2) + 0086 F0 178 movx @dptr,a + 0087 A3 179 inc dptr + 0088 E5*07 180 mov a,(__divslong_sloc1_1_0 + 3) + 008A F0 181 movx @dptr,a + 008B C0 02 182 push ar2 + 008D 85*00 82 183 mov dpl,__divslong_sloc0_1_0 + 0090 85*01 83 184 mov dph,(__divslong_sloc0_1_0 + 1) + 0093 85*02 F0 185 mov b,(__divslong_sloc0_1_0 + 2) + 0096 E5*03 186 mov a,(__divslong_sloc0_1_0 + 3) + 0098 12s00r00 187 lcall __divulong + 009B AB 82 188 mov r3,dpl + 009D AC 83 189 mov r4,dph + 009F AD F0 190 mov r5,b + 00A1 FE 191 mov r6,a + 00A2 D0 02 192 pop ar2 + 193 ; _divslong.c 31 + 00A4 C0 03 194 push ar3 + 00A6 C0 04 195 push ar4 + 00A8 C0 05 196 push ar5 + 00AA C0 06 197 push ar6 + 00AC 90s00r04 198 mov dptr,#__divslong_a_1_1 + 00AF E0 199 movx a,@dptr + 00B0 FF 200 mov r7,a + 00B1 A3 201 inc dptr + 00B2 E0 202 movx a,@dptr + 00B3 F8 203 mov r0,a + 00B4 A3 204 inc dptr + 00B5 E0 205 movx a,@dptr + 00B6 F9 206 mov r1,a + 00B7 A3 207 inc dptr + 00B8 E0 208 movx a,@dptr + 209 ; Peephole 105 removed redundant mov + 00B9 FB 210 mov r3,a + 00BA 33 211 rlc a + 00BB E4 212 clr a + 00BC 33 213 rlc a + 00BD FF 214 mov r7,a + 00BE EA 215 mov a,r2 + 00BF 65 07 216 xrl a,ar7 + 00C1 D0 06 217 pop ar6 + 00C3 D0 05 218 pop ar5 + 00C5 D0 04 219 pop ar4 + 00C7 D0 03 220 pop ar3 + 221 ; Peephole 110 removed ljmp by inverse jump logic + 00C9 60 1C 222 jz 00102$ + 00CB 223 00115$: + 224 ; _divslong.c 32 + 00CB C3 225 clr c + 00CC E4 226 clr a + 00CD 9B 227 subb a,r3 + 00CE F5*04 228 mov __divslong_sloc1_1_0,a + 00D0 E4 229 clr a + 00D1 9C 230 subb a,r4 + 00D2 F5*05 231 mov (__divslong_sloc1_1_0 + 1),a + 00D4 E4 232 clr a + 00D5 9D 233 subb a,r5 + 00D6 F5*06 234 mov (__divslong_sloc1_1_0 + 2),a + 00D8 E4 235 clr a + 00D9 9E 236 subb a,r6 + 237 ; Peephole 191 removed redundant mov + 00DA F5*07 238 mov (__divslong_sloc1_1_0 + 3),a + 00DC 85*04 82 239 mov dpl,__divslong_sloc1_1_0 + 00DF 85*05 83 240 mov dph,(__divslong_sloc1_1_0 + 1) + 00E2 85*06 F0 241 mov b,(__divslong_sloc1_1_0 + 2) + 242 ; Peephole 132 changed ljmp to sjmp + 00E5 80 07 243 sjmp 00104$ + 00E7 244 00102$: + 245 ; _divslong.c 34 + 00E7 8B 82 246 mov dpl,r3 + 00E9 8C 83 247 mov dph,r4 + 00EB 8D F0 248 mov b,r5 + 00ED EE 249 mov a,r6 + 00EE 250 00104$: + 00EE 251 C$_divslong.c$35$1$1 ==. + 00EE 252 XG$_divslong$0$0 ==. + 00EE 22 253 ret + 254 .area CSEG (CODE) diff --git a/device/lib/_divslong.sym b/device/lib/_divslong.sym new file mode 100644 index 00000000..2397563c --- /dev/null +++ b/device/lib/_divslong.sym @@ -0,0 +1,529 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_divslong$100 0028 GR + 7 A$_divslong$102 002B GR + 7 A$_divslong$103 002C GR + 7 A$_divslong$104 002D GR + 7 A$_divslong$105 002E GR + 7 A$_divslong$106 002F GR + 7 A$_divslong$107 0030 GR + 7 A$_divslong$108 0031 GR + 7 A$_divslong$109 0032 GR + 7 A$_divslong$110 0033 GR + 7 A$_divslong$111 0034 GR + 7 A$_divslong$112 0035 GR + 7 A$_divslong$113 0036 GR + 7 A$_divslong$114 0037 GR + 7 A$_divslong$116 0038 GR + 7 A$_divslong$118 003A GR + 7 A$_divslong$119 003C GR + 7 A$_divslong$120 003E GR + 7 A$_divslong$121 0040 GR + 7 A$_divslong$123 0042 GR + 7 A$_divslong$124 0044 GR + 7 A$_divslong$125 0046 GR + 7 A$_divslong$126 0048 GR + 7 A$_divslong$128 004A GR + 7 A$_divslong$129 004D GR + 7 A$_divslong$130 004E GR + 7 A$_divslong$131 004F GR + 7 A$_divslong$132 0050 GR + 7 A$_divslong$133 0051 GR + 7 A$_divslong$134 0052 GR + 7 A$_divslong$135 0053 GR + 7 A$_divslong$136 0054 GR + 7 A$_divslong$137 0055 GR + 7 A$_divslong$138 0056 GR + 7 A$_divslong$140 0057 GR + 7 A$_divslong$141 0058 GR + 7 A$_divslong$142 0059 GR + 7 A$_divslong$143 005A GR + 7 A$_divslong$145 005B GR + 7 A$_divslong$147 005C GR + 7 A$_divslong$149 005E GR + 7 A$_divslong$150 005F GR + 7 A$_divslong$151 0060 GR + 7 A$_divslong$152 0061 GR + 7 A$_divslong$153 0063 GR + 7 A$_divslong$154 0064 GR + 7 A$_divslong$155 0065 GR + 7 A$_divslong$156 0067 GR + 7 A$_divslong$157 0068 GR + 7 A$_divslong$158 0069 GR + 7 A$_divslong$159 006B GR + 7 A$_divslong$160 006C GR + 7 A$_divslong$161 006D GR + 7 A$_divslong$163 006F GR + 7 A$_divslong$165 0071 GR + 7 A$_divslong$166 0073 GR + 7 A$_divslong$167 0075 GR + 7 A$_divslong$168 0077 GR + 7 A$_divslong$170 0079 GR + 7 A$_divslong$171 007C GR + 7 A$_divslong$172 007E GR + 7 A$_divslong$173 007F GR + 7 A$_divslong$174 0080 GR + 7 A$_divslong$175 0082 GR + 7 A$_divslong$176 0083 GR + 7 A$_divslong$177 0084 GR + 7 A$_divslong$178 0086 GR + 7 A$_divslong$179 0087 GR + 7 A$_divslong$180 0088 GR + 7 A$_divslong$181 008A GR + 7 A$_divslong$182 008B GR + 7 A$_divslong$183 008D GR + 7 A$_divslong$184 0090 GR + 7 A$_divslong$185 0093 GR + 7 A$_divslong$186 0096 GR + 7 A$_divslong$187 0098 GR + 7 A$_divslong$188 009B GR + 7 A$_divslong$189 009D GR + 7 A$_divslong$190 009F GR + 7 A$_divslong$191 00A1 GR + 7 A$_divslong$192 00A2 GR + 7 A$_divslong$194 00A4 GR + 7 A$_divslong$195 00A6 GR + 7 A$_divslong$196 00A8 GR + 7 A$_divslong$197 00AA GR + 7 A$_divslong$198 00AC GR + 7 A$_divslong$199 00AF GR + 7 A$_divslong$200 00B0 GR + 7 A$_divslong$201 00B1 GR + 7 A$_divslong$202 00B2 GR + 7 A$_divslong$203 00B3 GR + 7 A$_divslong$204 00B4 GR + 7 A$_divslong$205 00B5 GR + 7 A$_divslong$206 00B6 GR + 7 A$_divslong$207 00B7 GR + 7 A$_divslong$208 00B8 GR + 7 A$_divslong$210 00B9 GR + 7 A$_divslong$211 00BA GR + 7 A$_divslong$212 00BB GR + 7 A$_divslong$213 00BC GR + 7 A$_divslong$214 00BD GR + 7 A$_divslong$215 00BE GR + 7 A$_divslong$216 00BF GR + 7 A$_divslong$217 00C1 GR + 7 A$_divslong$218 00C3 GR + 7 A$_divslong$219 00C5 GR + 7 A$_divslong$220 00C7 GR + 7 A$_divslong$222 00C9 GR + 7 A$_divslong$225 00CB GR + 7 A$_divslong$226 00CC GR + 7 A$_divslong$227 00CD GR + 7 A$_divslong$228 00CE GR + 7 A$_divslong$229 00D0 GR + 7 A$_divslong$230 00D1 GR + 7 A$_divslong$231 00D2 GR + 7 A$_divslong$232 00D4 GR + 7 A$_divslong$233 00D5 GR + 7 A$_divslong$234 00D6 GR + 7 A$_divslong$235 00D8 GR + 7 A$_divslong$236 00D9 GR + 7 A$_divslong$238 00DA GR + 7 A$_divslong$239 00DC GR + 7 A$_divslong$240 00DF GR + 7 A$_divslong$241 00E2 GR + 7 A$_divslong$243 00E5 GR + 7 A$_divslong$246 00E7 GR + 7 A$_divslong$247 00E9 GR + 7 A$_divslong$248 00EB GR + 7 A$_divslong$249 00ED GR + 7 A$_divslong$253 00EE GR + 7 A$_divslong$69 0000 GR + 7 A$_divslong$70 0002 GR + 7 A$_divslong$71 0004 GR + 7 A$_divslong$72 0006 GR + 7 A$_divslong$73 0008 GR + 7 A$_divslong$74 000B GR + 7 A$_divslong$75 000D GR + 7 A$_divslong$76 000E GR + 7 A$_divslong$77 0010 GR + 7 A$_divslong$78 0011 GR + 7 A$_divslong$79 0012 GR + 7 A$_divslong$80 0014 GR + 7 A$_divslong$81 0015 GR + 7 A$_divslong$82 0016 GR + 7 A$_divslong$83 0018 GR + 7 A$_divslong$84 0019 GR + 7 A$_divslong$86 001A GR + 7 A$_divslong$87 001D GR + 7 A$_divslong$88 001E GR + 7 A$_divslong$89 001F GR + 7 A$_divslong$90 0020 GR + 7 A$_divslong$91 0021 GR + 7 A$_divslong$92 0022 GR + 7 A$_divslong$93 0023 GR + 7 A$_divslong$94 0024 GR + 7 A$_divslong$95 0025 GR + 7 A$_divslong$96 0026 GR + 7 A$_divslong$98 0027 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_divslong.c$35$1$1 = 00EE GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_divslong$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_divslong$0$0 = 00EE GR + 7 __divslong 0000 GR + 5 __divslong_PARM_2 0000 GR + 5 __divslong_a_1_1 0004 R + 1 __divslong_sloc0_1_0 0000 R + 1 __divslong_sloc1_1_0 0004 R + __divulong **** GX + __divulong_PARM_2 **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size EF flags 20 diff --git a/device/lib/_divuint.c b/device/lib/_divuint.c new file mode 100644 index 00000000..2226f97c --- /dev/null +++ b/device/lib/_divuint.c @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + + _divuint.c :- routine for unsigned int (16 bit) division + + Ecrit par - Jean-Louis Vern . jlvern@writeme.com (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1) + +unsigned int _divuint (unsigned int a, unsigned int b) +{ + unsigned int reste = 0 ; + unsigned short count = 16; + bit c; + + do{ + // reste:a <- 0; + c = MSB_SET(a); + a <<= 1; + reste <<= 1; + if(c) + reste |= 1; + + if(reste >= b){ + reste -= b; + // a <- (result = 1) + a |= 1; + } + } while(--count); + + return a; +} diff --git a/device/lib/_divuint.lst b/device/lib/_divuint.lst new file mode 100644 index 00000000..61ada6ad --- /dev/null +++ b/device/lib/_divuint.lst @@ -0,0 +1,215 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _divuint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __divuint_PARM_2 + 11 .globl __divuint + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 0000 34 __divuint_c_1_1: + 0000 35 .ds 0x0001 + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 __divuint_PARM_2: + 0000 41 .ds 0x0002 + 0002 42 __divuint_a_1_1: + 0002 43 .ds 0x0002 + 0004 44 __divuint_reste_1_1: + 0004 45 .ds 0x0002 + 0006 46 __divuint_count_1_1: + 0006 47 .ds 0x0001 + 48 ;-------------------------------------------------------- + 49 ; global & static initialisations + 50 ;-------------------------------------------------------- + 51 .area GSINIT (CODE) + 52 ;-------------------------------------------------------- + 53 ; code + 54 ;-------------------------------------------------------- + 55 .area CSEG (CODE) + 0000 56 G$_divuint$0$0 ==. + 57 ; _divuint.c 28 + 58 ; ----------------------------------------- + 59 ; function _divuint + 60 ; ----------------------------------------- + 0000 61 __divuint: + 0002 62 ar2 = 0x02 + 0003 63 ar3 = 0x03 + 0004 64 ar4 = 0x04 + 0005 65 ar5 = 0x05 + 0006 66 ar6 = 0x06 + 0007 67 ar7 = 0x07 + 0000 68 ar0 = 0x00 + 0001 69 ar1 = 0x01 + 70 ; _divuint.c 49 + 0000 C0 83 71 push dph + 0002 C0 82 72 push dpl + 0004 90s00r02 73 mov dptr,#__divuint_a_1_1 + 0007 D0 E0 74 pop acc + 0009 F0 75 movx @dptr,a + 000A D0 E0 76 pop acc + 000C A3 77 inc dptr + 000D F0 78 movx @dptr,a + 79 ; _divuint.c 30 + 000E 90s00r04 80 mov dptr,#__divuint_reste_1_1 + 0011 E4 81 clr a + 0012 A3 82 inc dptr + 0013 F0 83 movx @dptr,a + 0014 12s00r00 84 lcall __decdptr + 0017 F0 85 movx @dptr,a + 86 ; _divuint.c 31 + 0018 90s00r06 87 mov dptr,#__divuint_count_1_1 + 001B 74 10 88 mov a,#0x10 + 001D F0 89 movx @dptr,a + 90 ; _divuint.c 34 + 001E 90s00r00 91 mov dptr,#__divuint_PARM_2 + 0021 E0 92 movx a,@dptr + 0022 FA 93 mov r2,a + 0023 A3 94 inc dptr + 0024 E0 95 movx a,@dptr + 0025 FB 96 mov r3,a + 0026 97 00105$: + 98 ; _divuint.c 36 + 0026 90s00r02 99 mov dptr,#__divuint_a_1_1 + 0029 E0 100 movx a,@dptr + 002A FC 101 mov r4,a + 002B A3 102 inc dptr + 002C E0 103 movx a,@dptr + 104 ; Peephole 105 removed redundant mov + 002D FD 105 mov r5,a + 002E 23 106 rl a + 002F 54 01 107 anl a,#0x01 + 0031 FE 108 mov r6,a + 109 ; _divuint.c 37 + 0032 ED 110 mov a,r5 + 0033 CC 111 xch a,r4 + 0034 25 E0 112 add a,acc + 0036 CC 113 xch a,r4 + 0037 33 114 rlc a + 0038 FD 115 mov r5,a + 0039 90s00r02 116 mov dptr,#__divuint_a_1_1 + 003C EC 117 mov a,r4 + 003D F0 118 movx @dptr,a + 003E A3 119 inc dptr + 003F ED 120 mov a,r5 + 0040 F0 121 movx @dptr,a + 122 ; _divuint.c 38 + 0041 90s00r04 123 mov dptr,#__divuint_reste_1_1 + 0044 E0 124 movx a,@dptr + 0045 FF 125 mov r7,a + 0046 A3 126 inc dptr + 0047 E0 127 movx a,@dptr + 128 ; Peephole 105 removed redundant mov + 0048 F8 129 mov r0,a + 0049 CF 130 xch a,r7 + 004A 25 E0 131 add a,acc + 004C CF 132 xch a,r7 + 004D 33 133 rlc a + 004E F8 134 mov r0,a + 004F 90s00r04 135 mov dptr,#__divuint_reste_1_1 + 0052 EF 136 mov a,r7 + 0053 F0 137 movx @dptr,a + 0054 A3 138 inc dptr + 0055 E8 139 mov a,r0 + 0056 F0 140 movx @dptr,a + 141 ; _divuint.c 39 + 0057 EE 142 mov a,r6 + 143 ; Peephole 110 removed ljmp by inverse jump logic + 0058 60 0A 144 jz 00102$ + 005A 145 00114$: + 146 ; _divuint.c 40 + 005A 90s00r04 147 mov dptr,#__divuint_reste_1_1 + 005D 74 01 148 mov a,#0x01 + 005F 4F 149 orl a,r7 + 0060 F0 150 movx @dptr,a + 0061 A3 151 inc dptr + 0062 E8 152 mov a,r0 + 0063 F0 153 movx @dptr,a + 0064 154 00102$: + 155 ; _divuint.c 42 + 0064 90s00r04 156 mov dptr,#__divuint_reste_1_1 + 0067 E0 157 movx a,@dptr + 0068 FE 158 mov r6,a + 0069 A3 159 inc dptr + 006A E0 160 movx a,@dptr + 006B FF 161 mov r7,a + 006C C3 162 clr c + 006D EE 163 mov a,r6 + 006E 9A 164 subb a,r2 + 006F EF 165 mov a,r7 + 0070 9B 166 subb a,r3 + 167 ; Peephole 132 changed ljmp to sjmp + 168 ; Peephole 160 removed sjmp by inverse jump logic + 0071 40 15 169 jc 00106$ + 0073 170 00115$: + 171 ; _divuint.c 43 + 0073 90s00r04 172 mov dptr,#__divuint_reste_1_1 + 0076 C3 173 clr c + 0077 EE 174 mov a,r6 + 0078 9A 175 subb a,r2 + 0079 F0 176 movx @dptr,a + 007A EF 177 mov a,r7 + 007B 9B 178 subb a,r3 + 007C A3 179 inc dptr + 007D F0 180 movx @dptr,a + 181 ; _divuint.c 45 + 007E 90s00r02 182 mov dptr,#__divuint_a_1_1 + 0081 74 01 183 mov a,#0x01 + 0083 4C 184 orl a,r4 + 0084 F0 185 movx @dptr,a + 0085 A3 186 inc dptr + 0086 ED 187 mov a,r5 + 0087 F0 188 movx @dptr,a + 0088 189 00106$: + 190 ; _divuint.c 47 + 0088 90s00r06 191 mov dptr,#__divuint_count_1_1 + 008B E0 192 movx a,@dptr + 008C 24 FF 193 add a,#0xff + 194 ; Peephole 100 removed redundant mov + 008E FC 195 mov r4,a + 008F 90s00r06 196 mov dptr,#__divuint_count_1_1 + 0092 F0 197 movx @dptr,a + 0093 EC 198 mov a,r4 + 0094 60 03 199 jz 00116$ + 0096 02s00r26 200 ljmp 00105$ + 0099 201 00116$: + 202 ; _divuint.c 49 + 0099 90s00r02 203 mov dptr,#__divuint_a_1_1 + 009C E0 204 movx a,@dptr + 009D FA 205 mov r2,a + 009E A3 206 inc dptr + 009F E0 207 movx a,@dptr + 00A0 FB 208 mov r3,a + 00A1 8A 82 209 mov dpl,r2 + 00A3 8B 83 210 mov dph,r3 + 00A5 211 00108$: + 00A5 212 C$_divuint.c$50$1$1 ==. + 00A5 213 XG$_divuint$0$0 ==. + 00A5 22 214 ret + 215 .area CSEG (CODE) diff --git a/device/lib/_divuint.sym b/device/lib/_divuint.sym new file mode 100644 index 00000000..ef22feb3 --- /dev/null +++ b/device/lib/_divuint.sym @@ -0,0 +1,487 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_divuint$100 0029 GR + 7 A$_divuint$101 002A GR + 7 A$_divuint$102 002B GR + 7 A$_divuint$103 002C GR + 7 A$_divuint$105 002D GR + 7 A$_divuint$106 002E GR + 7 A$_divuint$107 002F GR + 7 A$_divuint$108 0031 GR + 7 A$_divuint$110 0032 GR + 7 A$_divuint$111 0033 GR + 7 A$_divuint$112 0034 GR + 7 A$_divuint$113 0036 GR + 7 A$_divuint$114 0037 GR + 7 A$_divuint$115 0038 GR + 7 A$_divuint$116 0039 GR + 7 A$_divuint$117 003C GR + 7 A$_divuint$118 003D GR + 7 A$_divuint$119 003E GR + 7 A$_divuint$120 003F GR + 7 A$_divuint$121 0040 GR + 7 A$_divuint$123 0041 GR + 7 A$_divuint$124 0044 GR + 7 A$_divuint$125 0045 GR + 7 A$_divuint$126 0046 GR + 7 A$_divuint$127 0047 GR + 7 A$_divuint$129 0048 GR + 7 A$_divuint$130 0049 GR + 7 A$_divuint$131 004A GR + 7 A$_divuint$132 004C GR + 7 A$_divuint$133 004D GR + 7 A$_divuint$134 004E GR + 7 A$_divuint$135 004F GR + 7 A$_divuint$136 0052 GR + 7 A$_divuint$137 0053 GR + 7 A$_divuint$138 0054 GR + 7 A$_divuint$139 0055 GR + 7 A$_divuint$140 0056 GR + 7 A$_divuint$142 0057 GR + 7 A$_divuint$144 0058 GR + 7 A$_divuint$147 005A GR + 7 A$_divuint$148 005D GR + 7 A$_divuint$149 005F GR + 7 A$_divuint$150 0060 GR + 7 A$_divuint$151 0061 GR + 7 A$_divuint$152 0062 GR + 7 A$_divuint$153 0063 GR + 7 A$_divuint$156 0064 GR + 7 A$_divuint$157 0067 GR + 7 A$_divuint$158 0068 GR + 7 A$_divuint$159 0069 GR + 7 A$_divuint$160 006A GR + 7 A$_divuint$161 006B GR + 7 A$_divuint$162 006C GR + 7 A$_divuint$163 006D GR + 7 A$_divuint$164 006E GR + 7 A$_divuint$165 006F GR + 7 A$_divuint$166 0070 GR + 7 A$_divuint$169 0071 GR + 7 A$_divuint$172 0073 GR + 7 A$_divuint$173 0076 GR + 7 A$_divuint$174 0077 GR + 7 A$_divuint$175 0078 GR + 7 A$_divuint$176 0079 GR + 7 A$_divuint$177 007A GR + 7 A$_divuint$178 007B GR + 7 A$_divuint$179 007C GR + 7 A$_divuint$180 007D GR + 7 A$_divuint$182 007E GR + 7 A$_divuint$183 0081 GR + 7 A$_divuint$184 0083 GR + 7 A$_divuint$185 0084 GR + 7 A$_divuint$186 0085 GR + 7 A$_divuint$187 0086 GR + 7 A$_divuint$188 0087 GR + 7 A$_divuint$191 0088 GR + 7 A$_divuint$192 008B GR + 7 A$_divuint$193 008C GR + 7 A$_divuint$195 008E GR + 7 A$_divuint$196 008F GR + 7 A$_divuint$197 0092 GR + 7 A$_divuint$198 0093 GR + 7 A$_divuint$199 0094 GR + 7 A$_divuint$200 0096 GR + 7 A$_divuint$203 0099 GR + 7 A$_divuint$204 009C GR + 7 A$_divuint$205 009D GR + 7 A$_divuint$206 009E GR + 7 A$_divuint$207 009F GR + 7 A$_divuint$208 00A0 GR + 7 A$_divuint$209 00A1 GR + 7 A$_divuint$210 00A3 GR + 7 A$_divuint$214 00A5 GR + 7 A$_divuint$71 0000 GR + 7 A$_divuint$72 0002 GR + 7 A$_divuint$73 0004 GR + 7 A$_divuint$74 0007 GR + 7 A$_divuint$75 0009 GR + 7 A$_divuint$76 000A GR + 7 A$_divuint$77 000C GR + 7 A$_divuint$78 000D GR + 7 A$_divuint$80 000E GR + 7 A$_divuint$81 0011 GR + 7 A$_divuint$82 0012 GR + 7 A$_divuint$83 0013 GR + 7 A$_divuint$84 0014 GR + 7 A$_divuint$85 0017 GR + 7 A$_divuint$87 0018 GR + 7 A$_divuint$88 001B GR + 7 A$_divuint$89 001D GR + 7 A$_divuint$91 001E GR + 7 A$_divuint$92 0021 GR + 7 A$_divuint$93 0022 GR + 7 A$_divuint$94 0023 GR + 7 A$_divuint$95 0024 GR + 7 A$_divuint$96 0025 GR + 7 A$_divuint$99 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_divuint.c$50$1$1 = 00A5 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_divuint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_divuint$0$0 = 00A5 GR + __decdptr **** GX + 7 __divuint 0000 GR + 5 __divuint_PARM_2 0000 GR + 5 __divuint_a_1_1 0002 R + 4 __divuint_c_1_1 0000 R + 5 __divuint_count_1_1 0006 R + 5 __divuint_reste_1_1 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 1 flags 80 + 5 XSEG size 7 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size A6 flags 20 diff --git a/device/lib/_divulong.c b/device/lib/_divulong.c new file mode 100644 index 00000000..6b3311ff --- /dev/null +++ b/device/lib/_divulong.c @@ -0,0 +1,49 @@ +/*------------------------------------------------------------------------- + _divulong.c - routine for division of 32 bit unsigned long + + Ecrit par - Jean-Louis Vern . jlvern@writeme.com (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1) + +unsigned long _divulong (unsigned long a, unsigned long b) +{ + unsigned long reste = 0L; + unsigned char count = 32; + short c; + + do{ + // reste:a <- 0; + c = MSB_SET(a); + a <<= 1; + reste <<= 1; + if(c) + reste |= 1L; + + if(reste >= b){ + reste -= b; + // a <- (result = 1) + a |= 1L; + } + } while(--count); + + return a; +} diff --git a/device/lib/_divulong.lst b/device/lib/_divulong.lst new file mode 100644 index 00000000..ec71eb34 --- /dev/null +++ b/device/lib/_divulong.lst @@ -0,0 +1,319 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _divulong + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __divulong_PARM_2 + 11 .globl __divulong + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 __divulong_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 __divulong_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 __divulong_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 __divulong_a_1_1: + 0004 45 .ds 0x0004 + 0008 46 __divulong_reste_1_1: + 0008 47 .ds 0x0004 + 000C 48 __divulong_count_1_1: + 000C 49 .ds 0x0001 + 50 ;-------------------------------------------------------- + 51 ; global & static initialisations + 52 ;-------------------------------------------------------- + 53 .area GSINIT (CODE) + 54 ;-------------------------------------------------------- + 55 ; code + 56 ;-------------------------------------------------------- + 57 .area CSEG (CODE) + 0000 58 G$_divulong$0$0 ==. + 59 ; _divulong.c 27 + 60 ; ----------------------------------------- + 61 ; function _divulong + 62 ; ----------------------------------------- + 0000 63 __divulong: + 0002 64 ar2 = 0x02 + 0003 65 ar3 = 0x03 + 0004 66 ar4 = 0x04 + 0005 67 ar5 = 0x05 + 0006 68 ar6 = 0x06 + 0007 69 ar7 = 0x07 + 0000 70 ar0 = 0x00 + 0001 71 ar1 = 0x01 + 72 ; _divulong.c 48 + 0000 C0 E0 73 push acc + 0002 C0 F0 74 push b + 0004 C0 83 75 push dph + 0006 C0 82 76 push dpl + 0008 90s00r04 77 mov dptr,#__divulong_a_1_1 + 000B D0 E0 78 pop acc + 000D F0 79 movx @dptr,a + 000E D0 E0 80 pop acc + 0010 A3 81 inc dptr + 0011 F0 82 movx @dptr,a + 0012 D0 E0 83 pop acc + 0014 A3 84 inc dptr + 0015 F0 85 movx @dptr,a + 0016 D0 E0 86 pop acc + 0018 A3 87 inc dptr + 0019 F0 88 movx @dptr,a + 89 ; _divulong.c 29 + 001A 90s00r08 90 mov dptr,#__divulong_reste_1_1 + 001D E4 91 clr a + 001E A3 92 inc dptr + 001F A3 93 inc dptr + 0020 A3 94 inc dptr + 0021 F0 95 movx @dptr,a + 0022 12s00r00 96 lcall __decdptr + 0025 F0 97 movx @dptr,a + 0026 12s00r00 98 lcall __decdptr + 0029 F0 99 movx @dptr,a + 002A 12s00r00 100 lcall __decdptr + 002D F0 101 movx @dptr,a + 102 ; _divulong.c 30 + 002E 90s00r0C 103 mov dptr,#__divulong_count_1_1 + 0031 74 20 104 mov a,#0x20 + 0033 F0 105 movx @dptr,a + 106 ; _divulong.c 33 + 0034 90s00r00 107 mov dptr,#__divulong_PARM_2 + 0037 E0 108 movx a,@dptr + 0038 F5*00 109 mov __divulong_sloc0_1_0,a + 003A A3 110 inc dptr + 003B E0 111 movx a,@dptr + 003C F5*01 112 mov (__divulong_sloc0_1_0 + 1),a + 003E A3 113 inc dptr + 003F E0 114 movx a,@dptr + 0040 F5*02 115 mov (__divulong_sloc0_1_0 + 2),a + 0042 A3 116 inc dptr + 0043 E0 117 movx a,@dptr + 0044 F5*03 118 mov (__divulong_sloc0_1_0 + 3),a + 0046 119 00105$: + 120 ; _divulong.c 35 + 0046 90s00r04 121 mov dptr,#__divulong_a_1_1 + 0049 E0 122 movx a,@dptr + 004A FE 123 mov r6,a + 004B A3 124 inc dptr + 004C E0 125 movx a,@dptr + 004D FF 126 mov r7,a + 004E A3 127 inc dptr + 004F E0 128 movx a,@dptr + 0050 F8 129 mov r0,a + 0051 A3 130 inc dptr + 0052 E0 131 movx a,@dptr + 132 ; Peephole 105 removed redundant mov + 0053 F9 133 mov r1,a + 0054 23 134 rl a + 0055 54 01 135 anl a,#0x01 + 0057 FA 136 mov r2,a + 137 ; _divulong.c 36 + 0058 EE 138 mov a,r6 + 0059 25 E0 139 add a,acc + 005B FE 140 mov r6,a + 005C EF 141 mov a,r7 + 005D 33 142 rlc a + 005E FC 143 mov r4,a + 005F E8 144 mov a,r0 + 0060 33 145 rlc a + 0061 FD 146 mov r5,a + 0062 E9 147 mov a,r1 + 0063 33 148 rlc a + 0064 FB 149 mov r3,a + 0065 90s00r04 150 mov dptr,#__divulong_a_1_1 + 0068 EE 151 mov a,r6 + 0069 F0 152 movx @dptr,a + 006A A3 153 inc dptr + 006B EC 154 mov a,r4 + 006C F0 155 movx @dptr,a + 006D A3 156 inc dptr + 006E ED 157 mov a,r5 + 006F F0 158 movx @dptr,a + 0070 A3 159 inc dptr + 0071 EB 160 mov a,r3 + 0072 F0 161 movx @dptr,a + 162 ; _divulong.c 37 + 0073 C0 06 163 push ar6 + 0075 C0 04 164 push ar4 + 0077 C0 05 165 push ar5 + 0079 C0 03 166 push ar3 + 007B 90s00r08 167 mov dptr,#__divulong_reste_1_1 + 007E E0 168 movx a,@dptr + 007F FF 169 mov r7,a + 0080 A3 170 inc dptr + 0081 E0 171 movx a,@dptr + 0082 F8 172 mov r0,a + 0083 A3 173 inc dptr + 0084 E0 174 movx a,@dptr + 0085 F9 175 mov r1,a + 0086 A3 176 inc dptr + 0087 E0 177 movx a,@dptr + 0088 FB 178 mov r3,a + 0089 EF 179 mov a,r7 + 008A 25 E0 180 add a,acc + 008C F5*04 181 mov __divulong_sloc1_1_0,a + 008E E8 182 mov a,r0 + 008F 33 183 rlc a + 0090 F5*05 184 mov (__divulong_sloc1_1_0 + 1),a + 0092 E9 185 mov a,r1 + 0093 33 186 rlc a + 0094 F5*06 187 mov (__divulong_sloc1_1_0 + 2),a + 0096 EB 188 mov a,r3 + 0097 33 189 rlc a + 0098 F5*07 190 mov (__divulong_sloc1_1_0 + 3),a + 009A 90s00r08 191 mov dptr,#__divulong_reste_1_1 + 009D E5*04 192 mov a,__divulong_sloc1_1_0 + 009F F0 193 movx @dptr,a + 00A0 A3 194 inc dptr + 00A1 E5*05 195 mov a,(__divulong_sloc1_1_0 + 1) + 00A3 F0 196 movx @dptr,a + 00A4 A3 197 inc dptr + 00A5 E5*06 198 mov a,(__divulong_sloc1_1_0 + 2) + 00A7 F0 199 movx @dptr,a + 00A8 A3 200 inc dptr + 00A9 E5*07 201 mov a,(__divulong_sloc1_1_0 + 3) + 00AB F0 202 movx @dptr,a + 203 ; _divulong.c 38 + 00AC D0 03 204 pop ar3 + 00AE D0 05 205 pop ar5 + 00B0 D0 04 206 pop ar4 + 00B2 D0 06 207 pop ar6 + 00B4 EA 208 mov a,r2 + 209 ; Peephole 110 removed ljmp by inverse jump logic + 00B5 60 14 210 jz 00102$ + 00B7 211 00114$: + 212 ; _divulong.c 39 + 00B7 90s00r08 213 mov dptr,#__divulong_reste_1_1 + 00BA 74 01 214 mov a,#0x01 + 00BC 45*04 215 orl a,__divulong_sloc1_1_0 + 00BE F0 216 movx @dptr,a + 00BF A3 217 inc dptr + 00C0 E5*05 218 mov a,(__divulong_sloc1_1_0 + 1) + 00C2 F0 219 movx @dptr,a + 00C3 A3 220 inc dptr + 00C4 E5*06 221 mov a,(__divulong_sloc1_1_0 + 2) + 00C6 F0 222 movx @dptr,a + 00C7 A3 223 inc dptr + 00C8 E5*07 224 mov a,(__divulong_sloc1_1_0 + 3) + 00CA F0 225 movx @dptr,a + 00CB 226 00102$: + 227 ; _divulong.c 41 + 00CB 90s00r08 228 mov dptr,#__divulong_reste_1_1 + 00CE E0 229 movx a,@dptr + 00CF FA 230 mov r2,a + 00D0 A3 231 inc dptr + 00D1 E0 232 movx a,@dptr + 00D2 FF 233 mov r7,a + 00D3 A3 234 inc dptr + 00D4 E0 235 movx a,@dptr + 00D5 F8 236 mov r0,a + 00D6 A3 237 inc dptr + 00D7 E0 238 movx a,@dptr + 00D8 F9 239 mov r1,a + 00D9 C3 240 clr c + 00DA EA 241 mov a,r2 + 00DB 95*00 242 subb a,__divulong_sloc0_1_0 + 00DD EF 243 mov a,r7 + 00DE 95*01 244 subb a,(__divulong_sloc0_1_0 + 1) + 00E0 E8 245 mov a,r0 + 00E1 95*02 246 subb a,(__divulong_sloc0_1_0 + 2) + 00E3 E9 247 mov a,r1 + 00E4 95*03 248 subb a,(__divulong_sloc0_1_0 + 3) + 249 ; Peephole 132 changed ljmp to sjmp + 250 ; Peephole 160 removed sjmp by inverse jump logic + 00E6 40 27 251 jc 00106$ + 00E8 252 00115$: + 253 ; _divulong.c 42 + 00E8 90s00r08 254 mov dptr,#__divulong_reste_1_1 + 00EB C3 255 clr c + 00EC EA 256 mov a,r2 + 00ED 95*00 257 subb a,__divulong_sloc0_1_0 + 00EF F0 258 movx @dptr,a + 00F0 EF 259 mov a,r7 + 00F1 95*01 260 subb a,(__divulong_sloc0_1_0 + 1) + 00F3 A3 261 inc dptr + 00F4 F0 262 movx @dptr,a + 00F5 E8 263 mov a,r0 + 00F6 95*02 264 subb a,(__divulong_sloc0_1_0 + 2) + 00F8 A3 265 inc dptr + 00F9 F0 266 movx @dptr,a + 00FA E9 267 mov a,r1 + 00FB 95*03 268 subb a,(__divulong_sloc0_1_0 + 3) + 00FD A3 269 inc dptr + 00FE F0 270 movx @dptr,a + 271 ; _divulong.c 44 + 00FF 90s00r04 272 mov dptr,#__divulong_a_1_1 + 0102 74 01 273 mov a,#0x01 + 0104 4E 274 orl a,r6 + 0105 F0 275 movx @dptr,a + 0106 A3 276 inc dptr + 0107 EC 277 mov a,r4 + 0108 F0 278 movx @dptr,a + 0109 A3 279 inc dptr + 010A ED 280 mov a,r5 + 010B F0 281 movx @dptr,a + 010C A3 282 inc dptr + 010D EB 283 mov a,r3 + 010E F0 284 movx @dptr,a + 010F 285 00106$: + 286 ; _divulong.c 46 + 010F 90s00r0C 287 mov dptr,#__divulong_count_1_1 + 0112 E0 288 movx a,@dptr + 0113 24 FF 289 add a,#0xff + 290 ; Peephole 100 removed redundant mov + 0115 FA 291 mov r2,a + 0116 90s00r0C 292 mov dptr,#__divulong_count_1_1 + 0119 F0 293 movx @dptr,a + 011A EA 294 mov a,r2 + 011B 60 03 295 jz 00116$ + 011D 02s00r46 296 ljmp 00105$ + 0120 297 00116$: + 298 ; _divulong.c 48 + 0120 90s00r04 299 mov dptr,#__divulong_a_1_1 + 0123 E0 300 movx a,@dptr + 0124 FA 301 mov r2,a + 0125 A3 302 inc dptr + 0126 E0 303 movx a,@dptr + 0127 FB 304 mov r3,a + 0128 A3 305 inc dptr + 0129 E0 306 movx a,@dptr + 012A FC 307 mov r4,a + 012B A3 308 inc dptr + 012C E0 309 movx a,@dptr + 310 ; Peephole 191 removed redundant mov + 012D FD 311 mov r5,a + 012E 8A 82 312 mov dpl,r2 + 0130 8B 83 313 mov dph,r3 + 0132 8C F0 314 mov b,r4 + 0134 315 00108$: + 0134 316 C$_divulong.c$49$1$1 ==. + 0134 317 XG$_divulong$0$0 ==. + 0134 22 318 ret + 319 .area CSEG (CODE) diff --git a/device/lib/_divulong.sym b/device/lib/_divulong.sym new file mode 100644 index 00000000..f57b7e73 --- /dev/null +++ b/device/lib/_divulong.sym @@ -0,0 +1,590 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_divulong$100 002A GR + 7 A$_divulong$101 002D GR + 7 A$_divulong$103 002E GR + 7 A$_divulong$104 0031 GR + 7 A$_divulong$105 0033 GR + 7 A$_divulong$107 0034 GR + 7 A$_divulong$108 0037 GR + 7 A$_divulong$109 0038 GR + 7 A$_divulong$110 003A GR + 7 A$_divulong$111 003B GR + 7 A$_divulong$112 003C GR + 7 A$_divulong$113 003E GR + 7 A$_divulong$114 003F GR + 7 A$_divulong$115 0040 GR + 7 A$_divulong$116 0042 GR + 7 A$_divulong$117 0043 GR + 7 A$_divulong$118 0044 GR + 7 A$_divulong$121 0046 GR + 7 A$_divulong$122 0049 GR + 7 A$_divulong$123 004A GR + 7 A$_divulong$124 004B GR + 7 A$_divulong$125 004C GR + 7 A$_divulong$126 004D GR + 7 A$_divulong$127 004E GR + 7 A$_divulong$128 004F GR + 7 A$_divulong$129 0050 GR + 7 A$_divulong$130 0051 GR + 7 A$_divulong$131 0052 GR + 7 A$_divulong$133 0053 GR + 7 A$_divulong$134 0054 GR + 7 A$_divulong$135 0055 GR + 7 A$_divulong$136 0057 GR + 7 A$_divulong$138 0058 GR + 7 A$_divulong$139 0059 GR + 7 A$_divulong$140 005B GR + 7 A$_divulong$141 005C GR + 7 A$_divulong$142 005D GR + 7 A$_divulong$143 005E GR + 7 A$_divulong$144 005F GR + 7 A$_divulong$145 0060 GR + 7 A$_divulong$146 0061 GR + 7 A$_divulong$147 0062 GR + 7 A$_divulong$148 0063 GR + 7 A$_divulong$149 0064 GR + 7 A$_divulong$150 0065 GR + 7 A$_divulong$151 0068 GR + 7 A$_divulong$152 0069 GR + 7 A$_divulong$153 006A GR + 7 A$_divulong$154 006B GR + 7 A$_divulong$155 006C GR + 7 A$_divulong$156 006D GR + 7 A$_divulong$157 006E GR + 7 A$_divulong$158 006F GR + 7 A$_divulong$159 0070 GR + 7 A$_divulong$160 0071 GR + 7 A$_divulong$161 0072 GR + 7 A$_divulong$163 0073 GR + 7 A$_divulong$164 0075 GR + 7 A$_divulong$165 0077 GR + 7 A$_divulong$166 0079 GR + 7 A$_divulong$167 007B GR + 7 A$_divulong$168 007E GR + 7 A$_divulong$169 007F GR + 7 A$_divulong$170 0080 GR + 7 A$_divulong$171 0081 GR + 7 A$_divulong$172 0082 GR + 7 A$_divulong$173 0083 GR + 7 A$_divulong$174 0084 GR + 7 A$_divulong$175 0085 GR + 7 A$_divulong$176 0086 GR + 7 A$_divulong$177 0087 GR + 7 A$_divulong$178 0088 GR + 7 A$_divulong$179 0089 GR + 7 A$_divulong$180 008A GR + 7 A$_divulong$181 008C GR + 7 A$_divulong$182 008E GR + 7 A$_divulong$183 008F GR + 7 A$_divulong$184 0090 GR + 7 A$_divulong$185 0092 GR + 7 A$_divulong$186 0093 GR + 7 A$_divulong$187 0094 GR + 7 A$_divulong$188 0096 GR + 7 A$_divulong$189 0097 GR + 7 A$_divulong$190 0098 GR + 7 A$_divulong$191 009A GR + 7 A$_divulong$192 009D GR + 7 A$_divulong$193 009F GR + 7 A$_divulong$194 00A0 GR + 7 A$_divulong$195 00A1 GR + 7 A$_divulong$196 00A3 GR + 7 A$_divulong$197 00A4 GR + 7 A$_divulong$198 00A5 GR + 7 A$_divulong$199 00A7 GR + 7 A$_divulong$200 00A8 GR + 7 A$_divulong$201 00A9 GR + 7 A$_divulong$202 00AB GR + 7 A$_divulong$204 00AC GR + 7 A$_divulong$205 00AE GR + 7 A$_divulong$206 00B0 GR + 7 A$_divulong$207 00B2 GR + 7 A$_divulong$208 00B4 GR + 7 A$_divulong$210 00B5 GR + 7 A$_divulong$213 00B7 GR + 7 A$_divulong$214 00BA GR + 7 A$_divulong$215 00BC GR + 7 A$_divulong$216 00BE GR + 7 A$_divulong$217 00BF GR + 7 A$_divulong$218 00C0 GR + 7 A$_divulong$219 00C2 GR + 7 A$_divulong$220 00C3 GR + 7 A$_divulong$221 00C4 GR + 7 A$_divulong$222 00C6 GR + 7 A$_divulong$223 00C7 GR + 7 A$_divulong$224 00C8 GR + 7 A$_divulong$225 00CA GR + 7 A$_divulong$228 00CB GR + 7 A$_divulong$229 00CE GR + 7 A$_divulong$230 00CF GR + 7 A$_divulong$231 00D0 GR + 7 A$_divulong$232 00D1 GR + 7 A$_divulong$233 00D2 GR + 7 A$_divulong$234 00D3 GR + 7 A$_divulong$235 00D4 GR + 7 A$_divulong$236 00D5 GR + 7 A$_divulong$237 00D6 GR + 7 A$_divulong$238 00D7 GR + 7 A$_divulong$239 00D8 GR + 7 A$_divulong$240 00D9 GR + 7 A$_divulong$241 00DA GR + 7 A$_divulong$242 00DB GR + 7 A$_divulong$243 00DD GR + 7 A$_divulong$244 00DE GR + 7 A$_divulong$245 00E0 GR + 7 A$_divulong$246 00E1 GR + 7 A$_divulong$247 00E3 GR + 7 A$_divulong$248 00E4 GR + 7 A$_divulong$251 00E6 GR + 7 A$_divulong$254 00E8 GR + 7 A$_divulong$255 00EB GR + 7 A$_divulong$256 00EC GR + 7 A$_divulong$257 00ED GR + 7 A$_divulong$258 00EF GR + 7 A$_divulong$259 00F0 GR + 7 A$_divulong$260 00F1 GR + 7 A$_divulong$261 00F3 GR + 7 A$_divulong$262 00F4 GR + 7 A$_divulong$263 00F5 GR + 7 A$_divulong$264 00F6 GR + 7 A$_divulong$265 00F8 GR + 7 A$_divulong$266 00F9 GR + 7 A$_divulong$267 00FA GR + 7 A$_divulong$268 00FB GR + 7 A$_divulong$269 00FD GR + 7 A$_divulong$270 00FE GR + 7 A$_divulong$272 00FF GR + 7 A$_divulong$273 0102 GR + 7 A$_divulong$274 0104 GR + 7 A$_divulong$275 0105 GR + 7 A$_divulong$276 0106 GR + 7 A$_divulong$277 0107 GR + 7 A$_divulong$278 0108 GR + 7 A$_divulong$279 0109 GR + 7 A$_divulong$280 010A GR + 7 A$_divulong$281 010B GR + 7 A$_divulong$282 010C GR + 7 A$_divulong$283 010D GR + 7 A$_divulong$284 010E GR + 7 A$_divulong$287 010F GR + 7 A$_divulong$288 0112 GR + 7 A$_divulong$289 0113 GR + 7 A$_divulong$291 0115 GR + 7 A$_divulong$292 0116 GR + 7 A$_divulong$293 0119 GR + 7 A$_divulong$294 011A GR + 7 A$_divulong$295 011B GR + 7 A$_divulong$296 011D GR + 7 A$_divulong$299 0120 GR + 7 A$_divulong$300 0123 GR + 7 A$_divulong$301 0124 GR + 7 A$_divulong$302 0125 GR + 7 A$_divulong$303 0126 GR + 7 A$_divulong$304 0127 GR + 7 A$_divulong$305 0128 GR + 7 A$_divulong$306 0129 GR + 7 A$_divulong$307 012A GR + 7 A$_divulong$308 012B GR + 7 A$_divulong$309 012C GR + 7 A$_divulong$311 012D GR + 7 A$_divulong$312 012E GR + 7 A$_divulong$313 0130 GR + 7 A$_divulong$314 0132 GR + 7 A$_divulong$318 0134 GR + 7 A$_divulong$73 0000 GR + 7 A$_divulong$74 0002 GR + 7 A$_divulong$75 0004 GR + 7 A$_divulong$76 0006 GR + 7 A$_divulong$77 0008 GR + 7 A$_divulong$78 000B GR + 7 A$_divulong$79 000D GR + 7 A$_divulong$80 000E GR + 7 A$_divulong$81 0010 GR + 7 A$_divulong$82 0011 GR + 7 A$_divulong$83 0012 GR + 7 A$_divulong$84 0014 GR + 7 A$_divulong$85 0015 GR + 7 A$_divulong$86 0016 GR + 7 A$_divulong$87 0018 GR + 7 A$_divulong$88 0019 GR + 7 A$_divulong$90 001A GR + 7 A$_divulong$91 001D GR + 7 A$_divulong$92 001E GR + 7 A$_divulong$93 001F GR + 7 A$_divulong$94 0020 GR + 7 A$_divulong$95 0021 GR + 7 A$_divulong$96 0022 GR + 7 A$_divulong$97 0025 GR + 7 A$_divulong$98 0026 GR + 7 A$_divulong$99 0029 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_divulong.c$49$1$1 = 0134 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_divulong$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_divulong$0$0 = 0134 GR + __decdptr **** GX + 7 __divulong 0000 GR + 5 __divulong_PARM_2 0000 GR + 5 __divulong_a_1_1 0004 R + 5 __divulong_count_1_1 000C R + 5 __divulong_reste_1_1 0008 R + 1 __divulong_sloc0_1_0 0000 R + 1 __divulong_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size D flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 135 flags 20 diff --git a/device/lib/_fs2char.c b/device/lib/_fs2char.c new file mode 100644 index 00000000..7fc73ec1 --- /dev/null +++ b/device/lib/_fs2char.c @@ -0,0 +1,97 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* convert double to int */ +char +__fs2char (float a1) +{ + volatile union float_long fl1; + volatile int exp; + volatile long l; + + fl1.f = a1; + + if (!fl1.l) + return (0); + + exp = EXP (fl1.l) - EXCESS - 24; + l = MANT (fl1.l); + + if (exp > 0) + return (0x7F | SIGN(fl1.l)); /* largest integer */ + + /* shift down until exp = 0 or l = 0 */ + if (exp < 0 && exp > -25 && l) + l >>= -exp; + else + return (0); + + return (SIGN(fl1.l) ? -l : l); +} diff --git a/device/lib/_fs2char.lst b/device/lib/_fs2char.lst new file mode 100644 index 00000000..e6aaef97 --- /dev/null +++ b/device/lib/_fs2char.lst @@ -0,0 +1,432 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fs2char + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fs2char + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___fs2char_sloc0_1_0: + 0000 22 .ds 0x0004 + 0004 23 ___fs2char_sloc1_1_0: + 0004 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___fs2char_a1_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___fs2char_fl1_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___fs2char_exp_1_1: + 0008 46 .ds 0x0002 + 000A 47 ___fs2char_l_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__fs2char$0$0 ==. + 58 ; _fs2char.c 73 + 59 ; ----------------------------------------- + 60 ; function __fs2char + 61 ; ----------------------------------------- + 0000 62 ___fs2char: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _fs2char.c 96 + 0000 C0 E0 72 push acc + 0002 C0 F0 73 push b + 0004 C0 83 74 push dph + 0006 C0 82 75 push dpl + 0008 90s00r00 76 mov dptr,#___fs2char_a1_1_1 + 000B D0 E0 77 pop acc + 000D F0 78 movx @dptr,a + 000E D0 E0 79 pop acc + 0010 A3 80 inc dptr + 0011 F0 81 movx @dptr,a + 0012 D0 E0 82 pop acc + 0014 A3 83 inc dptr + 0015 F0 84 movx @dptr,a + 0016 D0 E0 85 pop acc + 0018 A3 86 inc dptr + 0019 F0 87 movx @dptr,a + 88 ; _fs2char.c 79 + 001A 90s00r00 89 mov dptr,#___fs2char_a1_1_1 + 001D E0 90 movx a,@dptr + 001E FA 91 mov r2,a + 001F A3 92 inc dptr + 0020 E0 93 movx a,@dptr + 0021 FB 94 mov r3,a + 0022 A3 95 inc dptr + 0023 E0 96 movx a,@dptr + 0024 FC 97 mov r4,a + 0025 A3 98 inc dptr + 0026 E0 99 movx a,@dptr + 0027 FD 100 mov r5,a + 0028 90s00r04 101 mov dptr,#(___fs2char_fl1_1_1) + 002B EA 102 mov a,r2 + 002C F0 103 movx @dptr,a + 002D A3 104 inc dptr + 002E EB 105 mov a,r3 + 002F F0 106 movx @dptr,a + 0030 A3 107 inc dptr + 0031 EC 108 mov a,r4 + 0032 F0 109 movx @dptr,a + 0033 A3 110 inc dptr + 0034 ED 111 mov a,r5 + 0035 F0 112 movx @dptr,a + 113 ; _fs2char.c 81 + 0036 90s00r04 114 mov dptr,#(___fs2char_fl1_1_1) + 0039 E0 115 movx a,@dptr + 003A FA 116 mov r2,a + 003B A3 117 inc dptr + 003C E0 118 movx a,@dptr + 003D FB 119 mov r3,a + 003E A3 120 inc dptr + 003F E0 121 movx a,@dptr + 0040 FC 122 mov r4,a + 0041 A3 123 inc dptr + 0042 E0 124 movx a,@dptr + 0043 FD 125 mov r5,a + 0044 EA 126 mov a,r2 + 0045 4B 127 orl a,r3 + 0046 4C 128 orl a,r4 + 0047 4D 129 orl a,r5 + 130 ; Peephole 109 removed ljmp by inverse jump logic + 0048 70 06 131 jnz 00102$ + 004A 132 00120$: + 133 ; _fs2char.c 82 + 004A 75 82 00 134 mov dpl,#0x00 + 004D 02s01rE3 135 ljmp 00110$ + 0050 136 00102$: + 137 ; _fs2char.c 84 + 0050 90s00r04 138 mov dptr,#(___fs2char_fl1_1_1) + 0053 E0 139 movx a,@dptr + 0054 FA 140 mov r2,a + 0055 A3 141 inc dptr + 0056 E0 142 movx a,@dptr + 0057 FB 143 mov r3,a + 0058 A3 144 inc dptr + 0059 E0 145 movx a,@dptr + 005A FC 146 mov r4,a + 005B A3 147 inc dptr + 005C E0 148 movx a,@dptr + 005D FD 149 mov r5,a + 005E 8C 02 150 mov ar2,r4 + 0060 ED 151 mov a,r5 + 0061 A2 E7 152 mov c,acc.7 + 0063 CA 153 xch a,r2 + 0064 33 154 rlc a + 0065 CA 155 xch a,r2 + 0066 33 156 rlc a + 0067 CA 157 xch a,r2 + 0068 54 01 158 anl a,#0x01 + 006A 30 E0 02 159 jnb acc.0,00121$ + 006D 44 FE 160 orl a,#0xfe + 006F 161 00121$: + 006F FB 162 mov r3,a + 0070 33 163 rlc a + 0071 95 E0 164 subb a,acc + 0073 FC 165 mov r4,a + 0074 FD 166 mov r5,a + 0075 EA 167 mov a,r2 + 0076 75 F0 00 168 mov b,#0x00 + 0079 24 6A 169 add a,#0x6a + 007B FA 170 mov r2,a + 007C E5 F0 171 mov a,b + 007E 34 FF 172 addc a,#0xff + 0080 FB 173 mov r3,a + 0081 90s00r08 174 mov dptr,#___fs2char_exp_1_1 + 0084 EA 175 mov a,r2 + 0085 F0 176 movx @dptr,a + 0086 A3 177 inc dptr + 0087 EB 178 mov a,r3 + 0088 F0 179 movx @dptr,a + 180 ; _fs2char.c 85 + 0089 90s00r04 181 mov dptr,#(___fs2char_fl1_1_1) + 008C E0 182 movx a,@dptr + 008D FA 183 mov r2,a + 008E A3 184 inc dptr + 008F E0 185 movx a,@dptr + 0090 FB 186 mov r3,a + 0091 A3 187 inc dptr + 0092 E0 188 movx a,@dptr + 0093 FE 189 mov r6,a + 0094 A3 190 inc dptr + 0095 E0 191 movx a,@dptr + 0096 FF 192 mov r7,a + 0097 53 06 7F 193 anl ar6,#0x7f + 009A 7F 00 194 mov r7,#0x00 + 009C 90s00r0A 195 mov dptr,#___fs2char_l_1_1 + 009F EA 196 mov a,r2 + 00A0 F0 197 movx @dptr,a + 00A1 A3 198 inc dptr + 00A2 EB 199 mov a,r3 + 00A3 F0 200 movx @dptr,a + 00A4 74 80 201 mov a,#0x80 + 00A6 4E 202 orl a,r6 + 00A7 A3 203 inc dptr + 00A8 F0 204 movx @dptr,a + 00A9 A3 205 inc dptr + 00AA EF 206 mov a,r7 + 00AB F0 207 movx @dptr,a + 208 ; _fs2char.c 87 + 00AC 90s00r08 209 mov dptr,#___fs2char_exp_1_1 + 00AF E0 210 movx a,@dptr + 00B0 FA 211 mov r2,a + 00B1 A3 212 inc dptr + 00B2 E0 213 movx a,@dptr + 00B3 FB 214 mov r3,a + 00B4 C3 215 clr c + 216 ; Peephole 180 changed mov to clr + 00B5 E4 217 clr a + 00B6 9A 218 subb a,r2 + 219 ; Peephole 159 avoided xrl during execution + 00B7 74 80 220 mov a,#(0x00 ^ 0x80) + 00B9 8B F0 221 mov b,r3 + 00BB 63 F0 80 222 xrl b,#0x80 + 00BE 95 F0 223 subb a,b + 224 ; Peephole 108 removed ljmp by inverse jump logic + 00C0 50 1A 225 jnc 00104$ + 00C2 226 00122$: + 227 ; _fs2char.c 88 + 00C2 90s00r04 228 mov dptr,#(___fs2char_fl1_1_1) + 00C5 E0 229 movx a,@dptr + 00C6 FA 230 mov r2,a + 00C7 A3 231 inc dptr + 00C8 E0 232 movx a,@dptr + 00C9 FB 233 mov r3,a + 00CA A3 234 inc dptr + 00CB E0 235 movx a,@dptr + 00CC FE 236 mov r6,a + 00CD A3 237 inc dptr + 00CE E0 238 movx a,@dptr + 239 ; Peephole 105 removed redundant mov + 00CF FF 240 mov r7,a + 00D0 23 241 rl a + 00D1 54 01 242 anl a,#0x01 + 00D3 FA 243 mov r2,a + 00D4 43 02 7F 244 orl ar2,#0x7f + 00D7 8A 82 245 mov dpl,r2 + 00D9 02s01rE3 246 ljmp 00110$ + 00DC 247 00104$: + 248 ; _fs2char.c 91 + 00DC 90s00r08 249 mov dptr,#___fs2char_exp_1_1 + 00DF E0 250 movx a,@dptr + 00E0 FA 251 mov r2,a + 00E1 A3 252 inc dptr + 00E2 E0 253 movx a,@dptr + 254 ; Peephole 105 removed redundant mov + 00E3 F8 255 mov r0,a + 00E4 20 E7 03 256 jb acc.7,00123$ + 00E7 02s01r7F 257 ljmp 00106$ + 00EA 258 00123$: + 00EA 90s00r08 259 mov dptr,#___fs2char_exp_1_1 + 00ED E0 260 movx a,@dptr + 00EE FA 261 mov r2,a + 00EF A3 262 inc dptr + 00F0 E0 263 movx a,@dptr + 00F1 F8 264 mov r0,a + 00F2 C3 265 clr c + 00F3 74 E7 266 mov a,#0xe7 + 00F5 9A 267 subb a,r2 + 268 ; Peephole 159 avoided xrl during execution + 00F6 74 7F 269 mov a,#(0xff ^ 0x80) + 00F8 88 F0 270 mov b,r0 + 00FA 63 F0 80 271 xrl b,#0x80 + 00FD 95 F0 272 subb a,b + 00FF 40 03 273 jc 00124$ + 0101 02s01r7F 274 ljmp 00106$ + 0104 275 00124$: + 0104 90s00r0A 276 mov dptr,#___fs2char_l_1_1 + 0107 E0 277 movx a,@dptr + 0108 F5*00 278 mov ___fs2char_sloc0_1_0,a + 010A A3 279 inc dptr + 010B E0 280 movx a,@dptr + 010C F5*01 281 mov (___fs2char_sloc0_1_0 + 1),a + 010E A3 282 inc dptr + 010F E0 283 movx a,@dptr + 0110 F5*02 284 mov (___fs2char_sloc0_1_0 + 2),a + 0112 A3 285 inc dptr + 0113 E0 286 movx a,@dptr + 0114 F5*03 287 mov (___fs2char_sloc0_1_0 + 3),a + 0116 E5*00 288 mov a,___fs2char_sloc0_1_0 + 0118 45*01 289 orl a,(___fs2char_sloc0_1_0 + 1) + 011A 45*02 290 orl a,(___fs2char_sloc0_1_0 + 2) + 011C 45*03 291 orl a,(___fs2char_sloc0_1_0 + 3) + 011E 70 03 292 jnz 00125$ + 0120 02s01r7F 293 ljmp 00106$ + 0123 294 00125$: + 295 ; _fs2char.c 92 + 0123 90s00r08 296 mov dptr,#___fs2char_exp_1_1 + 0126 E0 297 movx a,@dptr + 0127 FA 298 mov r2,a + 0128 A3 299 inc dptr + 0129 E0 300 movx a,@dptr + 012A F8 301 mov r0,a + 012B C3 302 clr c + 012C E4 303 clr a + 012D 9A 304 subb a,r2 + 012E F5*00 305 mov ___fs2char_sloc0_1_0,a + 0130 E4 306 clr a + 0131 98 307 subb a,r0 + 0132 F5*01 308 mov (___fs2char_sloc0_1_0 + 1),a + 0134 90s00r0A 309 mov dptr,#___fs2char_l_1_1 + 0137 E0 310 movx a,@dptr + 0138 F5*04 311 mov ___fs2char_sloc1_1_0,a + 013A A3 312 inc dptr + 013B E0 313 movx a,@dptr + 013C F5*05 314 mov (___fs2char_sloc1_1_0 + 1),a + 013E A3 315 inc dptr + 013F E0 316 movx a,@dptr + 0140 F5*06 317 mov (___fs2char_sloc1_1_0 + 2),a + 0142 A3 318 inc dptr + 0143 E0 319 movx a,@dptr + 0144 F5*07 320 mov (___fs2char_sloc1_1_0 + 3),a + 0146 85*00 F0 321 mov b,___fs2char_sloc0_1_0 + 0149 05 F0 322 inc b + 014B E5*07 323 mov a,(___fs2char_sloc1_1_0 + 3) + 014D 33 324 rlc a + 014E 92 D2 325 mov ov,c + 0150 80 16 326 sjmp 00127$ + 0152 327 00126$: + 0152 A2 D2 328 mov c,ov + 0154 E5*07 329 mov a,(___fs2char_sloc1_1_0 + 3) + 0156 13 330 rrc a + 0157 F5*07 331 mov (___fs2char_sloc1_1_0 + 3),a + 0159 E5*06 332 mov a,(___fs2char_sloc1_1_0 + 2) + 015B 13 333 rrc a + 015C F5*06 334 mov (___fs2char_sloc1_1_0 + 2),a + 015E E5*05 335 mov a,(___fs2char_sloc1_1_0 + 1) + 0160 13 336 rrc a + 0161 F5*05 337 mov (___fs2char_sloc1_1_0 + 1),a + 0163 E5*04 338 mov a,___fs2char_sloc1_1_0 + 0165 13 339 rrc a + 0166 F5*04 340 mov ___fs2char_sloc1_1_0,a + 0168 341 00127$: + 0168 D5 F0 E7 342 djnz b,00126$ + 016B 90s00r0A 343 mov dptr,#___fs2char_l_1_1 + 016E E5*04 344 mov a,___fs2char_sloc1_1_0 + 0170 F0 345 movx @dptr,a + 0171 A3 346 inc dptr + 0172 E5*05 347 mov a,(___fs2char_sloc1_1_0 + 1) + 0174 F0 348 movx @dptr,a + 0175 A3 349 inc dptr + 0176 E5*06 350 mov a,(___fs2char_sloc1_1_0 + 2) + 0178 F0 351 movx @dptr,a + 0179 A3 352 inc dptr + 017A E5*07 353 mov a,(___fs2char_sloc1_1_0 + 3) + 017C F0 354 movx @dptr,a + 355 ; Peephole 132 changed ljmp to sjmp + 017D 80 06 356 sjmp 00107$ + 017F 357 00106$: + 358 ; _fs2char.c 94 + 017F 75 82 00 359 mov dpl,#0x00 + 0182 02s01rE3 360 ljmp 00110$ + 0185 361 00107$: + 362 ; _fs2char.c 96 + 0185 90s00r04 363 mov dptr,#(___fs2char_fl1_1_1) + 0188 E0 364 movx a,@dptr + 0189 F5*04 365 mov ___fs2char_sloc1_1_0,a + 018B A3 366 inc dptr + 018C E0 367 movx a,@dptr + 018D F5*05 368 mov (___fs2char_sloc1_1_0 + 1),a + 018F A3 369 inc dptr + 0190 E0 370 movx a,@dptr + 0191 F5*06 371 mov (___fs2char_sloc1_1_0 + 2),a + 0193 A3 372 inc dptr + 0194 E0 373 movx a,@dptr + 374 ; Peephole 105 removed redundant mov + 0195 F5*07 375 mov (___fs2char_sloc1_1_0 + 3),a + 0197 23 376 rl a + 0198 54 01 377 anl a,#0x01 + 378 ; Peephole 105 removed redundant mov + 019A FA 379 mov r2,a + 380 ; Peephole 110 removed ljmp by inverse jump logic + 019B 60 29 381 jz 00112$ + 019D 382 00128$: + 019D 90s00r0A 383 mov dptr,#___fs2char_l_1_1 + 01A0 E0 384 movx a,@dptr + 01A1 F5*04 385 mov ___fs2char_sloc1_1_0,a + 01A3 A3 386 inc dptr + 01A4 E0 387 movx a,@dptr + 01A5 F5*05 388 mov (___fs2char_sloc1_1_0 + 1),a + 01A7 A3 389 inc dptr + 01A8 E0 390 movx a,@dptr + 01A9 F5*06 391 mov (___fs2char_sloc1_1_0 + 2),a + 01AB A3 392 inc dptr + 01AC E0 393 movx a,@dptr + 01AD F5*07 394 mov (___fs2char_sloc1_1_0 + 3),a + 01AF C3 395 clr c + 01B0 E4 396 clr a + 01B1 95*04 397 subb a,___fs2char_sloc1_1_0 + 01B3 F5*04 398 mov ___fs2char_sloc1_1_0,a + 01B5 E4 399 clr a + 01B6 95*05 400 subb a,(___fs2char_sloc1_1_0 + 1) + 01B8 F5*05 401 mov (___fs2char_sloc1_1_0 + 1),a + 01BA E4 402 clr a + 01BB 95*06 403 subb a,(___fs2char_sloc1_1_0 + 2) + 01BD F5*06 404 mov (___fs2char_sloc1_1_0 + 2),a + 01BF E4 405 clr a + 01C0 95*07 406 subb a,(___fs2char_sloc1_1_0 + 3) + 01C2 F5*07 407 mov (___fs2char_sloc1_1_0 + 3),a + 408 ; Peephole 132 changed ljmp to sjmp + 01C4 80 12 409 sjmp 00113$ + 01C6 410 00112$: + 01C6 90s00r0A 411 mov dptr,#___fs2char_l_1_1 + 01C9 E0 412 movx a,@dptr + 01CA F5*04 413 mov ___fs2char_sloc1_1_0,a + 01CC A3 414 inc dptr + 01CD E0 415 movx a,@dptr + 01CE F5*05 416 mov (___fs2char_sloc1_1_0 + 1),a + 01D0 A3 417 inc dptr + 01D1 E0 418 movx a,@dptr + 01D2 F5*06 419 mov (___fs2char_sloc1_1_0 + 2),a + 01D4 A3 420 inc dptr + 01D5 E0 421 movx a,@dptr + 01D6 F5*07 422 mov (___fs2char_sloc1_1_0 + 3),a + 01D8 423 00113$: + 01D8 85*04 82 424 mov dpl,___fs2char_sloc1_1_0 + 01DB 85*05 83 425 mov dph,(___fs2char_sloc1_1_0 + 1) + 01DE 85*06 F0 426 mov b,(___fs2char_sloc1_1_0 + 2) + 01E1 E5*07 427 mov a,(___fs2char_sloc1_1_0 + 3) + 01E3 428 00110$: + 01E3 429 C$_fs2char.c$97$1$1 ==. + 01E3 430 XG$__fs2char$0$0 ==. + 01E3 22 431 ret + 432 .area CSEG (CODE) diff --git a/device/lib/_fs2char.sym b/device/lib/_fs2char.sym new file mode 100644 index 00000000..f0bf4eb2 --- /dev/null +++ b/device/lib/_fs2char.sym @@ -0,0 +1,690 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fs2char$100 0027 GR + 7 A$_fs2char$101 0028 GR + 7 A$_fs2char$102 002B GR + 7 A$_fs2char$103 002C GR + 7 A$_fs2char$104 002D GR + 7 A$_fs2char$105 002E GR + 7 A$_fs2char$106 002F GR + 7 A$_fs2char$107 0030 GR + 7 A$_fs2char$108 0031 GR + 7 A$_fs2char$109 0032 GR + 7 A$_fs2char$110 0033 GR + 7 A$_fs2char$111 0034 GR + 7 A$_fs2char$112 0035 GR + 7 A$_fs2char$114 0036 GR + 7 A$_fs2char$115 0039 GR + 7 A$_fs2char$116 003A GR + 7 A$_fs2char$117 003B GR + 7 A$_fs2char$118 003C GR + 7 A$_fs2char$119 003D GR + 7 A$_fs2char$120 003E GR + 7 A$_fs2char$121 003F GR + 7 A$_fs2char$122 0040 GR + 7 A$_fs2char$123 0041 GR + 7 A$_fs2char$124 0042 GR + 7 A$_fs2char$125 0043 GR + 7 A$_fs2char$126 0044 GR + 7 A$_fs2char$127 0045 GR + 7 A$_fs2char$128 0046 GR + 7 A$_fs2char$129 0047 GR + 7 A$_fs2char$131 0048 GR + 7 A$_fs2char$134 004A GR + 7 A$_fs2char$135 004D GR + 7 A$_fs2char$138 0050 GR + 7 A$_fs2char$139 0053 GR + 7 A$_fs2char$140 0054 GR + 7 A$_fs2char$141 0055 GR + 7 A$_fs2char$142 0056 GR + 7 A$_fs2char$143 0057 GR + 7 A$_fs2char$144 0058 GR + 7 A$_fs2char$145 0059 GR + 7 A$_fs2char$146 005A GR + 7 A$_fs2char$147 005B GR + 7 A$_fs2char$148 005C GR + 7 A$_fs2char$149 005D GR + 7 A$_fs2char$150 005E GR + 7 A$_fs2char$151 0060 GR + 7 A$_fs2char$152 0061 GR + 7 A$_fs2char$153 0063 GR + 7 A$_fs2char$154 0064 GR + 7 A$_fs2char$155 0065 GR + 7 A$_fs2char$156 0066 GR + 7 A$_fs2char$157 0067 GR + 7 A$_fs2char$158 0068 GR + 7 A$_fs2char$159 006A GR + 7 A$_fs2char$160 006D GR + 7 A$_fs2char$162 006F GR + 7 A$_fs2char$163 0070 GR + 7 A$_fs2char$164 0071 GR + 7 A$_fs2char$165 0073 GR + 7 A$_fs2char$166 0074 GR + 7 A$_fs2char$167 0075 GR + 7 A$_fs2char$168 0076 GR + 7 A$_fs2char$169 0079 GR + 7 A$_fs2char$170 007B GR + 7 A$_fs2char$171 007C GR + 7 A$_fs2char$172 007E GR + 7 A$_fs2char$173 0080 GR + 7 A$_fs2char$174 0081 GR + 7 A$_fs2char$175 0084 GR + 7 A$_fs2char$176 0085 GR + 7 A$_fs2char$177 0086 GR + 7 A$_fs2char$178 0087 GR + 7 A$_fs2char$179 0088 GR + 7 A$_fs2char$181 0089 GR + 7 A$_fs2char$182 008C GR + 7 A$_fs2char$183 008D GR + 7 A$_fs2char$184 008E GR + 7 A$_fs2char$185 008F GR + 7 A$_fs2char$186 0090 GR + 7 A$_fs2char$187 0091 GR + 7 A$_fs2char$188 0092 GR + 7 A$_fs2char$189 0093 GR + 7 A$_fs2char$190 0094 GR + 7 A$_fs2char$191 0095 GR + 7 A$_fs2char$192 0096 GR + 7 A$_fs2char$193 0097 GR + 7 A$_fs2char$194 009A GR + 7 A$_fs2char$195 009C GR + 7 A$_fs2char$196 009F GR + 7 A$_fs2char$197 00A0 GR + 7 A$_fs2char$198 00A1 GR + 7 A$_fs2char$199 00A2 GR + 7 A$_fs2char$200 00A3 GR + 7 A$_fs2char$201 00A4 GR + 7 A$_fs2char$202 00A6 GR + 7 A$_fs2char$203 00A7 GR + 7 A$_fs2char$204 00A8 GR + 7 A$_fs2char$205 00A9 GR + 7 A$_fs2char$206 00AA GR + 7 A$_fs2char$207 00AB GR + 7 A$_fs2char$209 00AC GR + 7 A$_fs2char$210 00AF GR + 7 A$_fs2char$211 00B0 GR + 7 A$_fs2char$212 00B1 GR + 7 A$_fs2char$213 00B2 GR + 7 A$_fs2char$214 00B3 GR + 7 A$_fs2char$215 00B4 GR + 7 A$_fs2char$217 00B5 GR + 7 A$_fs2char$218 00B6 GR + 7 A$_fs2char$220 00B7 GR + 7 A$_fs2char$221 00B9 GR + 7 A$_fs2char$222 00BB GR + 7 A$_fs2char$223 00BE GR + 7 A$_fs2char$225 00C0 GR + 7 A$_fs2char$228 00C2 GR + 7 A$_fs2char$229 00C5 GR + 7 A$_fs2char$230 00C6 GR + 7 A$_fs2char$231 00C7 GR + 7 A$_fs2char$232 00C8 GR + 7 A$_fs2char$233 00C9 GR + 7 A$_fs2char$234 00CA GR + 7 A$_fs2char$235 00CB GR + 7 A$_fs2char$236 00CC GR + 7 A$_fs2char$237 00CD GR + 7 A$_fs2char$238 00CE GR + 7 A$_fs2char$240 00CF GR + 7 A$_fs2char$241 00D0 GR + 7 A$_fs2char$242 00D1 GR + 7 A$_fs2char$243 00D3 GR + 7 A$_fs2char$244 00D4 GR + 7 A$_fs2char$245 00D7 GR + 7 A$_fs2char$246 00D9 GR + 7 A$_fs2char$249 00DC GR + 7 A$_fs2char$250 00DF GR + 7 A$_fs2char$251 00E0 GR + 7 A$_fs2char$252 00E1 GR + 7 A$_fs2char$253 00E2 GR + 7 A$_fs2char$255 00E3 GR + 7 A$_fs2char$256 00E4 GR + 7 A$_fs2char$257 00E7 GR + 7 A$_fs2char$259 00EA GR + 7 A$_fs2char$260 00ED GR + 7 A$_fs2char$261 00EE GR + 7 A$_fs2char$262 00EF GR + 7 A$_fs2char$263 00F0 GR + 7 A$_fs2char$264 00F1 GR + 7 A$_fs2char$265 00F2 GR + 7 A$_fs2char$266 00F3 GR + 7 A$_fs2char$267 00F5 GR + 7 A$_fs2char$269 00F6 GR + 7 A$_fs2char$270 00F8 GR + 7 A$_fs2char$271 00FA GR + 7 A$_fs2char$272 00FD GR + 7 A$_fs2char$273 00FF GR + 7 A$_fs2char$274 0101 GR + 7 A$_fs2char$276 0104 GR + 7 A$_fs2char$277 0107 GR + 7 A$_fs2char$278 0108 GR + 7 A$_fs2char$279 010A GR + 7 A$_fs2char$280 010B GR + 7 A$_fs2char$281 010C GR + 7 A$_fs2char$282 010E GR + 7 A$_fs2char$283 010F GR + 7 A$_fs2char$284 0110 GR + 7 A$_fs2char$285 0112 GR + 7 A$_fs2char$286 0113 GR + 7 A$_fs2char$287 0114 GR + 7 A$_fs2char$288 0116 GR + 7 A$_fs2char$289 0118 GR + 7 A$_fs2char$290 011A GR + 7 A$_fs2char$291 011C GR + 7 A$_fs2char$292 011E GR + 7 A$_fs2char$293 0120 GR + 7 A$_fs2char$296 0123 GR + 7 A$_fs2char$297 0126 GR + 7 A$_fs2char$298 0127 GR + 7 A$_fs2char$299 0128 GR + 7 A$_fs2char$300 0129 GR + 7 A$_fs2char$301 012A GR + 7 A$_fs2char$302 012B GR + 7 A$_fs2char$303 012C GR + 7 A$_fs2char$304 012D GR + 7 A$_fs2char$305 012E GR + 7 A$_fs2char$306 0130 GR + 7 A$_fs2char$307 0131 GR + 7 A$_fs2char$308 0132 GR + 7 A$_fs2char$309 0134 GR + 7 A$_fs2char$310 0137 GR + 7 A$_fs2char$311 0138 GR + 7 A$_fs2char$312 013A GR + 7 A$_fs2char$313 013B GR + 7 A$_fs2char$314 013C GR + 7 A$_fs2char$315 013E GR + 7 A$_fs2char$316 013F GR + 7 A$_fs2char$317 0140 GR + 7 A$_fs2char$318 0142 GR + 7 A$_fs2char$319 0143 GR + 7 A$_fs2char$320 0144 GR + 7 A$_fs2char$321 0146 GR + 7 A$_fs2char$322 0149 GR + 7 A$_fs2char$323 014B GR + 7 A$_fs2char$324 014D GR + 7 A$_fs2char$325 014E GR + 7 A$_fs2char$326 0150 GR + 7 A$_fs2char$328 0152 GR + 7 A$_fs2char$329 0154 GR + 7 A$_fs2char$330 0156 GR + 7 A$_fs2char$331 0157 GR + 7 A$_fs2char$332 0159 GR + 7 A$_fs2char$333 015B GR + 7 A$_fs2char$334 015C GR + 7 A$_fs2char$335 015E GR + 7 A$_fs2char$336 0160 GR + 7 A$_fs2char$337 0161 GR + 7 A$_fs2char$338 0163 GR + 7 A$_fs2char$339 0165 GR + 7 A$_fs2char$340 0166 GR + 7 A$_fs2char$342 0168 GR + 7 A$_fs2char$343 016B GR + 7 A$_fs2char$344 016E GR + 7 A$_fs2char$345 0170 GR + 7 A$_fs2char$346 0171 GR + 7 A$_fs2char$347 0172 GR + 7 A$_fs2char$348 0174 GR + 7 A$_fs2char$349 0175 GR + 7 A$_fs2char$350 0176 GR + 7 A$_fs2char$351 0178 GR + 7 A$_fs2char$352 0179 GR + 7 A$_fs2char$353 017A GR + 7 A$_fs2char$354 017C GR + 7 A$_fs2char$356 017D GR + 7 A$_fs2char$359 017F GR + 7 A$_fs2char$360 0182 GR + 7 A$_fs2char$363 0185 GR + 7 A$_fs2char$364 0188 GR + 7 A$_fs2char$365 0189 GR + 7 A$_fs2char$366 018B GR + 7 A$_fs2char$367 018C GR + 7 A$_fs2char$368 018D GR + 7 A$_fs2char$369 018F GR + 7 A$_fs2char$370 0190 GR + 7 A$_fs2char$371 0191 GR + 7 A$_fs2char$372 0193 GR + 7 A$_fs2char$373 0194 GR + 7 A$_fs2char$375 0195 GR + 7 A$_fs2char$376 0197 GR + 7 A$_fs2char$377 0198 GR + 7 A$_fs2char$379 019A GR + 7 A$_fs2char$381 019B GR + 7 A$_fs2char$383 019D GR + 7 A$_fs2char$384 01A0 GR + 7 A$_fs2char$385 01A1 GR + 7 A$_fs2char$386 01A3 GR + 7 A$_fs2char$387 01A4 GR + 7 A$_fs2char$388 01A5 GR + 7 A$_fs2char$389 01A7 GR + 7 A$_fs2char$390 01A8 GR + 7 A$_fs2char$391 01A9 GR + 7 A$_fs2char$392 01AB GR + 7 A$_fs2char$393 01AC GR + 7 A$_fs2char$394 01AD GR + 7 A$_fs2char$395 01AF GR + 7 A$_fs2char$396 01B0 GR + 7 A$_fs2char$397 01B1 GR + 7 A$_fs2char$398 01B3 GR + 7 A$_fs2char$399 01B5 GR + 7 A$_fs2char$400 01B6 GR + 7 A$_fs2char$401 01B8 GR + 7 A$_fs2char$402 01BA GR + 7 A$_fs2char$403 01BB GR + 7 A$_fs2char$404 01BD GR + 7 A$_fs2char$405 01BF GR + 7 A$_fs2char$406 01C0 GR + 7 A$_fs2char$407 01C2 GR + 7 A$_fs2char$409 01C4 GR + 7 A$_fs2char$411 01C6 GR + 7 A$_fs2char$412 01C9 GR + 7 A$_fs2char$413 01CA GR + 7 A$_fs2char$414 01CC GR + 7 A$_fs2char$415 01CD GR + 7 A$_fs2char$416 01CE GR + 7 A$_fs2char$417 01D0 GR + 7 A$_fs2char$418 01D1 GR + 7 A$_fs2char$419 01D2 GR + 7 A$_fs2char$420 01D4 GR + 7 A$_fs2char$421 01D5 GR + 7 A$_fs2char$422 01D6 GR + 7 A$_fs2char$424 01D8 GR + 7 A$_fs2char$425 01DB GR + 7 A$_fs2char$426 01DE GR + 7 A$_fs2char$427 01E1 GR + 7 A$_fs2char$431 01E3 GR + 7 A$_fs2char$72 0000 GR + 7 A$_fs2char$73 0002 GR + 7 A$_fs2char$74 0004 GR + 7 A$_fs2char$75 0006 GR + 7 A$_fs2char$76 0008 GR + 7 A$_fs2char$77 000B GR + 7 A$_fs2char$78 000D GR + 7 A$_fs2char$79 000E GR + 7 A$_fs2char$80 0010 GR + 7 A$_fs2char$81 0011 GR + 7 A$_fs2char$82 0012 GR + 7 A$_fs2char$83 0014 GR + 7 A$_fs2char$84 0015 GR + 7 A$_fs2char$85 0016 GR + 7 A$_fs2char$86 0018 GR + 7 A$_fs2char$87 0019 GR + 7 A$_fs2char$89 001A GR + 7 A$_fs2char$90 001D GR + 7 A$_fs2char$91 001E GR + 7 A$_fs2char$92 001F GR + 7 A$_fs2char$93 0020 GR + 7 A$_fs2char$94 0021 GR + 7 A$_fs2char$95 0022 GR + 7 A$_fs2char$96 0023 GR + 7 A$_fs2char$97 0024 GR + 7 A$_fs2char$98 0025 GR + 7 A$_fs2char$99 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fs2char.c$97$1$1 = 01E3 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fs2char$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fs2char$0$0 = 01E3 GR + 7 ___fs2char 0000 GR + 5 ___fs2char_a1_1_1 0000 R + 5 ___fs2char_exp_1_1 0008 R + 5 ___fs2char_fl1_1_1 0004 R + 5 ___fs2char_l_1_1 000A R + 1 ___fs2char_sloc0_1_0 0000 R + 1 ___fs2char_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 1E4 flags 20 diff --git a/device/lib/_fs2int.c b/device/lib/_fs2int.c new file mode 100644 index 00000000..d9192c42 --- /dev/null +++ b/device/lib/_fs2int.c @@ -0,0 +1,97 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* convert double to int */ +int +__fs2int (float a1) +{ + volatile union float_long fl1; + volatile int exp; + volatile long l; + + fl1.f = a1; + + if (!fl1.l) + return (0); + + exp = EXP (fl1.l) - EXCESS - 24; + l = MANT (fl1.l); + + if (exp > 0) + return (0x7F | SIGN(fl1.l)); /* largest integer */ + + /* shift down until exp = 0 or l = 0 */ + if (exp < 0 && exp > -25 && l) + l >>= -exp; + else + return (0); + + return (SIGN(fl1.l) ? -l : l); +} diff --git a/device/lib/_fs2int.lst b/device/lib/_fs2int.lst new file mode 100644 index 00000000..2a21f151 --- /dev/null +++ b/device/lib/_fs2int.lst @@ -0,0 +1,439 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fs2int + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fs2int + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___fs2int_sloc0_1_0: + 0000 22 .ds 0x0004 + 0004 23 ___fs2int_sloc1_1_0: + 0004 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___fs2int_a1_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___fs2int_fl1_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___fs2int_exp_1_1: + 0008 46 .ds 0x0002 + 000A 47 ___fs2int_l_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__fs2int$0$0 ==. + 58 ; _fs2int.c 73 + 59 ; ----------------------------------------- + 60 ; function __fs2int + 61 ; ----------------------------------------- + 0000 62 ___fs2int: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _fs2int.c 0 + 0000 C0 E0 72 push acc + 0002 C0 F0 73 push b + 0004 C0 83 74 push dph + 0006 C0 82 75 push dpl + 0008 90s00r00 76 mov dptr,#___fs2int_a1_1_1 + 000B D0 E0 77 pop acc + 000D F0 78 movx @dptr,a + 000E D0 E0 79 pop acc + 0010 A3 80 inc dptr + 0011 F0 81 movx @dptr,a + 0012 D0 E0 82 pop acc + 0014 A3 83 inc dptr + 0015 F0 84 movx @dptr,a + 0016 D0 E0 85 pop acc + 0018 A3 86 inc dptr + 0019 F0 87 movx @dptr,a + 88 ; _fs2int.c 79 + 001A 90s00r00 89 mov dptr,#___fs2int_a1_1_1 + 001D E0 90 movx a,@dptr + 001E FA 91 mov r2,a + 001F A3 92 inc dptr + 0020 E0 93 movx a,@dptr + 0021 FB 94 mov r3,a + 0022 A3 95 inc dptr + 0023 E0 96 movx a,@dptr + 0024 FC 97 mov r4,a + 0025 A3 98 inc dptr + 0026 E0 99 movx a,@dptr + 0027 FD 100 mov r5,a + 0028 90s00r04 101 mov dptr,#(___fs2int_fl1_1_1) + 002B EA 102 mov a,r2 + 002C F0 103 movx @dptr,a + 002D A3 104 inc dptr + 002E EB 105 mov a,r3 + 002F F0 106 movx @dptr,a + 0030 A3 107 inc dptr + 0031 EC 108 mov a,r4 + 0032 F0 109 movx @dptr,a + 0033 A3 110 inc dptr + 0034 ED 111 mov a,r5 + 0035 F0 112 movx @dptr,a + 113 ; _fs2int.c 81 + 0036 90s00r04 114 mov dptr,#(___fs2int_fl1_1_1) + 0039 E0 115 movx a,@dptr + 003A FA 116 mov r2,a + 003B A3 117 inc dptr + 003C E0 118 movx a,@dptr + 003D FB 119 mov r3,a + 003E A3 120 inc dptr + 003F E0 121 movx a,@dptr + 0040 FC 122 mov r4,a + 0041 A3 123 inc dptr + 0042 E0 124 movx a,@dptr + 0043 FD 125 mov r5,a + 0044 EA 126 mov a,r2 + 0045 4B 127 orl a,r3 + 0046 4C 128 orl a,r4 + 0047 4D 129 orl a,r5 + 130 ; Peephole 109 removed ljmp by inverse jump logic + 0048 70 06 131 jnz 00102$ + 004A 132 00120$: + 133 ; _fs2int.c 82 + 134 ; Peephole 181 used 16 bit load of dptr + 004A 90 00 00 135 mov dptr,#0x0000 + 004D 02s01rE5 136 ljmp 00110$ + 0050 137 00102$: + 138 ; _fs2int.c 84 + 0050 90s00r04 139 mov dptr,#(___fs2int_fl1_1_1) + 0053 E0 140 movx a,@dptr + 0054 FA 141 mov r2,a + 0055 A3 142 inc dptr + 0056 E0 143 movx a,@dptr + 0057 FB 144 mov r3,a + 0058 A3 145 inc dptr + 0059 E0 146 movx a,@dptr + 005A FC 147 mov r4,a + 005B A3 148 inc dptr + 005C E0 149 movx a,@dptr + 005D FD 150 mov r5,a + 005E 8C 02 151 mov ar2,r4 + 0060 ED 152 mov a,r5 + 0061 A2 E7 153 mov c,acc.7 + 0063 CA 154 xch a,r2 + 0064 33 155 rlc a + 0065 CA 156 xch a,r2 + 0066 33 157 rlc a + 0067 CA 158 xch a,r2 + 0068 54 01 159 anl a,#0x01 + 006A 30 E0 02 160 jnb acc.0,00121$ + 006D 44 FE 161 orl a,#0xfe + 006F 162 00121$: + 006F FB 163 mov r3,a + 0070 33 164 rlc a + 0071 95 E0 165 subb a,acc + 0073 FC 166 mov r4,a + 0074 FD 167 mov r5,a + 0075 EA 168 mov a,r2 + 0076 75 F0 00 169 mov b,#0x00 + 0079 24 6A 170 add a,#0x6a + 007B FA 171 mov r2,a + 007C E5 F0 172 mov a,b + 007E 34 FF 173 addc a,#0xff + 0080 FB 174 mov r3,a + 0081 90s00r08 175 mov dptr,#___fs2int_exp_1_1 + 0084 EA 176 mov a,r2 + 0085 F0 177 movx @dptr,a + 0086 A3 178 inc dptr + 0087 EB 179 mov a,r3 + 0088 F0 180 movx @dptr,a + 181 ; _fs2int.c 85 + 0089 90s00r04 182 mov dptr,#(___fs2int_fl1_1_1) + 008C E0 183 movx a,@dptr + 008D FA 184 mov r2,a + 008E A3 185 inc dptr + 008F E0 186 movx a,@dptr + 0090 FB 187 mov r3,a + 0091 A3 188 inc dptr + 0092 E0 189 movx a,@dptr + 0093 FE 190 mov r6,a + 0094 A3 191 inc dptr + 0095 E0 192 movx a,@dptr + 0096 FF 193 mov r7,a + 0097 53 06 7F 194 anl ar6,#0x7f + 009A 7F 00 195 mov r7,#0x00 + 009C 90s00r0A 196 mov dptr,#___fs2int_l_1_1 + 009F EA 197 mov a,r2 + 00A0 F0 198 movx @dptr,a + 00A1 A3 199 inc dptr + 00A2 EB 200 mov a,r3 + 00A3 F0 201 movx @dptr,a + 00A4 74 80 202 mov a,#0x80 + 00A6 4E 203 orl a,r6 + 00A7 A3 204 inc dptr + 00A8 F0 205 movx @dptr,a + 00A9 A3 206 inc dptr + 00AA EF 207 mov a,r7 + 00AB F0 208 movx @dptr,a + 209 ; _fs2int.c 87 + 00AC 90s00r08 210 mov dptr,#___fs2int_exp_1_1 + 00AF E0 211 movx a,@dptr + 00B0 FA 212 mov r2,a + 00B1 A3 213 inc dptr + 00B2 E0 214 movx a,@dptr + 00B3 FB 215 mov r3,a + 00B4 C3 216 clr c + 217 ; Peephole 180 changed mov to clr + 00B5 E4 218 clr a + 00B6 9A 219 subb a,r2 + 220 ; Peephole 159 avoided xrl during execution + 00B7 74 80 221 mov a,#(0x00 ^ 0x80) + 00B9 8B F0 222 mov b,r3 + 00BB 63 F0 80 223 xrl b,#0x80 + 00BE 95 F0 224 subb a,b + 225 ; Peephole 108 removed ljmp by inverse jump logic + 00C0 50 1F 226 jnc 00104$ + 00C2 227 00122$: + 228 ; _fs2int.c 88 + 00C2 90s00r04 229 mov dptr,#(___fs2int_fl1_1_1) + 00C5 E0 230 movx a,@dptr + 00C6 FA 231 mov r2,a + 00C7 A3 232 inc dptr + 00C8 E0 233 movx a,@dptr + 00C9 FB 234 mov r3,a + 00CA A3 235 inc dptr + 00CB E0 236 movx a,@dptr + 00CC FE 237 mov r6,a + 00CD A3 238 inc dptr + 00CE E0 239 movx a,@dptr + 240 ; Peephole 105 removed redundant mov + 00CF FF 241 mov r7,a + 00D0 23 242 rl a + 00D1 54 01 243 anl a,#0x01 + 244 ; Peephole 140 removed redundant mov + 00D3 44 7F 245 orl a,#0x7f + 00D5 FA 246 mov r2,a + 00D6 33 247 rlc a + 00D7 95 E0 248 subb a,acc + 00D9 F8 249 mov r0,a + 00DA 8A 82 250 mov dpl,r2 + 00DC 88 83 251 mov dph,r0 + 00DE 02s01rE5 252 ljmp 00110$ + 00E1 253 00104$: + 254 ; _fs2int.c 91 + 00E1 90s00r08 255 mov dptr,#___fs2int_exp_1_1 + 00E4 E0 256 movx a,@dptr + 00E5 FA 257 mov r2,a + 00E6 A3 258 inc dptr + 00E7 E0 259 movx a,@dptr + 260 ; Peephole 105 removed redundant mov + 00E8 F8 261 mov r0,a + 00E9 20 E7 03 262 jb acc.7,00123$ + 00EC 02s01r84 263 ljmp 00106$ + 00EF 264 00123$: + 00EF 90s00r08 265 mov dptr,#___fs2int_exp_1_1 + 00F2 E0 266 movx a,@dptr + 00F3 FA 267 mov r2,a + 00F4 A3 268 inc dptr + 00F5 E0 269 movx a,@dptr + 00F6 F8 270 mov r0,a + 00F7 C3 271 clr c + 00F8 74 E7 272 mov a,#0xe7 + 00FA 9A 273 subb a,r2 + 274 ; Peephole 159 avoided xrl during execution + 00FB 74 7F 275 mov a,#(0xff ^ 0x80) + 00FD 88 F0 276 mov b,r0 + 00FF 63 F0 80 277 xrl b,#0x80 + 0102 95 F0 278 subb a,b + 0104 40 03 279 jc 00124$ + 0106 02s01r84 280 ljmp 00106$ + 0109 281 00124$: + 0109 90s00r0A 282 mov dptr,#___fs2int_l_1_1 + 010C E0 283 movx a,@dptr + 010D F5*00 284 mov ___fs2int_sloc0_1_0,a + 010F A3 285 inc dptr + 0110 E0 286 movx a,@dptr + 0111 F5*01 287 mov (___fs2int_sloc0_1_0 + 1),a + 0113 A3 288 inc dptr + 0114 E0 289 movx a,@dptr + 0115 F5*02 290 mov (___fs2int_sloc0_1_0 + 2),a + 0117 A3 291 inc dptr + 0118 E0 292 movx a,@dptr + 0119 F5*03 293 mov (___fs2int_sloc0_1_0 + 3),a + 011B E5*00 294 mov a,___fs2int_sloc0_1_0 + 011D 45*01 295 orl a,(___fs2int_sloc0_1_0 + 1) + 011F 45*02 296 orl a,(___fs2int_sloc0_1_0 + 2) + 0121 45*03 297 orl a,(___fs2int_sloc0_1_0 + 3) + 0123 70 03 298 jnz 00125$ + 0125 02s01r84 299 ljmp 00106$ + 0128 300 00125$: + 301 ; _fs2int.c 92 + 0128 90s00r08 302 mov dptr,#___fs2int_exp_1_1 + 012B E0 303 movx a,@dptr + 012C FA 304 mov r2,a + 012D A3 305 inc dptr + 012E E0 306 movx a,@dptr + 012F F8 307 mov r0,a + 0130 C3 308 clr c + 0131 E4 309 clr a + 0132 9A 310 subb a,r2 + 0133 F5*00 311 mov ___fs2int_sloc0_1_0,a + 0135 E4 312 clr a + 0136 98 313 subb a,r0 + 0137 F5*01 314 mov (___fs2int_sloc0_1_0 + 1),a + 0139 90s00r0A 315 mov dptr,#___fs2int_l_1_1 + 013C E0 316 movx a,@dptr + 013D F5*04 317 mov ___fs2int_sloc1_1_0,a + 013F A3 318 inc dptr + 0140 E0 319 movx a,@dptr + 0141 F5*05 320 mov (___fs2int_sloc1_1_0 + 1),a + 0143 A3 321 inc dptr + 0144 E0 322 movx a,@dptr + 0145 F5*06 323 mov (___fs2int_sloc1_1_0 + 2),a + 0147 A3 324 inc dptr + 0148 E0 325 movx a,@dptr + 0149 F5*07 326 mov (___fs2int_sloc1_1_0 + 3),a + 014B 85*00 F0 327 mov b,___fs2int_sloc0_1_0 + 014E 05 F0 328 inc b + 0150 E5*07 329 mov a,(___fs2int_sloc1_1_0 + 3) + 0152 33 330 rlc a + 0153 92 D2 331 mov ov,c + 0155 80 16 332 sjmp 00127$ + 0157 333 00126$: + 0157 A2 D2 334 mov c,ov + 0159 E5*07 335 mov a,(___fs2int_sloc1_1_0 + 3) + 015B 13 336 rrc a + 015C F5*07 337 mov (___fs2int_sloc1_1_0 + 3),a + 015E E5*06 338 mov a,(___fs2int_sloc1_1_0 + 2) + 0160 13 339 rrc a + 0161 F5*06 340 mov (___fs2int_sloc1_1_0 + 2),a + 0163 E5*05 341 mov a,(___fs2int_sloc1_1_0 + 1) + 0165 13 342 rrc a + 0166 F5*05 343 mov (___fs2int_sloc1_1_0 + 1),a + 0168 E5*04 344 mov a,___fs2int_sloc1_1_0 + 016A 13 345 rrc a + 016B F5*04 346 mov ___fs2int_sloc1_1_0,a + 016D 347 00127$: + 016D D5 F0 E7 348 djnz b,00126$ + 0170 90s00r0A 349 mov dptr,#___fs2int_l_1_1 + 0173 E5*04 350 mov a,___fs2int_sloc1_1_0 + 0175 F0 351 movx @dptr,a + 0176 A3 352 inc dptr + 0177 E5*05 353 mov a,(___fs2int_sloc1_1_0 + 1) + 0179 F0 354 movx @dptr,a + 017A A3 355 inc dptr + 017B E5*06 356 mov a,(___fs2int_sloc1_1_0 + 2) + 017D F0 357 movx @dptr,a + 017E A3 358 inc dptr + 017F E5*07 359 mov a,(___fs2int_sloc1_1_0 + 3) + 0181 F0 360 movx @dptr,a + 361 ; Peephole 132 changed ljmp to sjmp + 0182 80 06 362 sjmp 00107$ + 0184 363 00106$: + 364 ; _fs2int.c 94 + 365 ; Peephole 181 used 16 bit load of dptr + 0184 90 00 00 366 mov dptr,#0x0000 + 0187 02s01rE5 367 ljmp 00110$ + 018A 368 00107$: + 369 ; _fs2int.c 96 + 018A 90s00r04 370 mov dptr,#(___fs2int_fl1_1_1) + 018D E0 371 movx a,@dptr + 018E F5*04 372 mov ___fs2int_sloc1_1_0,a + 0190 A3 373 inc dptr + 0191 E0 374 movx a,@dptr + 0192 F5*05 375 mov (___fs2int_sloc1_1_0 + 1),a + 0194 A3 376 inc dptr + 0195 E0 377 movx a,@dptr + 0196 F5*06 378 mov (___fs2int_sloc1_1_0 + 2),a + 0198 A3 379 inc dptr + 0199 E0 380 movx a,@dptr + 381 ; Peephole 105 removed redundant mov + 019A F5*07 382 mov (___fs2int_sloc1_1_0 + 3),a + 019C 23 383 rl a + 019D 54 01 384 anl a,#0x01 + 385 ; Peephole 105 removed redundant mov + 019F FA 386 mov r2,a + 387 ; Peephole 110 removed ljmp by inverse jump logic + 01A0 60 29 388 jz 00112$ + 01A2 389 00128$: + 01A2 90s00r0A 390 mov dptr,#___fs2int_l_1_1 + 01A5 E0 391 movx a,@dptr + 01A6 F5*04 392 mov ___fs2int_sloc1_1_0,a + 01A8 A3 393 inc dptr + 01A9 E0 394 movx a,@dptr + 01AA F5*05 395 mov (___fs2int_sloc1_1_0 + 1),a + 01AC A3 396 inc dptr + 01AD E0 397 movx a,@dptr + 01AE F5*06 398 mov (___fs2int_sloc1_1_0 + 2),a + 01B0 A3 399 inc dptr + 01B1 E0 400 movx a,@dptr + 01B2 F5*07 401 mov (___fs2int_sloc1_1_0 + 3),a + 01B4 C3 402 clr c + 01B5 E4 403 clr a + 01B6 95*04 404 subb a,___fs2int_sloc1_1_0 + 01B8 F5*04 405 mov ___fs2int_sloc1_1_0,a + 01BA E4 406 clr a + 01BB 95*05 407 subb a,(___fs2int_sloc1_1_0 + 1) + 01BD F5*05 408 mov (___fs2int_sloc1_1_0 + 1),a + 01BF E4 409 clr a + 01C0 95*06 410 subb a,(___fs2int_sloc1_1_0 + 2) + 01C2 F5*06 411 mov (___fs2int_sloc1_1_0 + 2),a + 01C4 E4 412 clr a + 01C5 95*07 413 subb a,(___fs2int_sloc1_1_0 + 3) + 01C7 F5*07 414 mov (___fs2int_sloc1_1_0 + 3),a + 415 ; Peephole 132 changed ljmp to sjmp + 01C9 80 12 416 sjmp 00113$ + 01CB 417 00112$: + 01CB 90s00r0A 418 mov dptr,#___fs2int_l_1_1 + 01CE E0 419 movx a,@dptr + 01CF F5*04 420 mov ___fs2int_sloc1_1_0,a + 01D1 A3 421 inc dptr + 01D2 E0 422 movx a,@dptr + 01D3 F5*05 423 mov (___fs2int_sloc1_1_0 + 1),a + 01D5 A3 424 inc dptr + 01D6 E0 425 movx a,@dptr + 01D7 F5*06 426 mov (___fs2int_sloc1_1_0 + 2),a + 01D9 A3 427 inc dptr + 01DA E0 428 movx a,@dptr + 01DB F5*07 429 mov (___fs2int_sloc1_1_0 + 3),a + 01DD 430 00113$: + 01DD AA*04 431 mov r2,___fs2int_sloc1_1_0 + 01DF A8*05 432 mov r0,(___fs2int_sloc1_1_0 + 1) + 01E1 8A 82 433 mov dpl,r2 + 01E3 88 83 434 mov dph,r0 + 01E5 435 00110$: + 01E5 436 C$_fs2int.c$97$1$1 ==. + 01E5 437 XG$__fs2int$0$0 ==. + 01E5 22 438 ret + 439 .area CSEG (CODE) diff --git a/device/lib/_fs2int.sym b/device/lib/_fs2int.sym new file mode 100644 index 00000000..e1872420 --- /dev/null +++ b/device/lib/_fs2int.sym @@ -0,0 +1,694 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fs2int$100 0027 GR + 7 A$_fs2int$101 0028 GR + 7 A$_fs2int$102 002B GR + 7 A$_fs2int$103 002C GR + 7 A$_fs2int$104 002D GR + 7 A$_fs2int$105 002E GR + 7 A$_fs2int$106 002F GR + 7 A$_fs2int$107 0030 GR + 7 A$_fs2int$108 0031 GR + 7 A$_fs2int$109 0032 GR + 7 A$_fs2int$110 0033 GR + 7 A$_fs2int$111 0034 GR + 7 A$_fs2int$112 0035 GR + 7 A$_fs2int$114 0036 GR + 7 A$_fs2int$115 0039 GR + 7 A$_fs2int$116 003A GR + 7 A$_fs2int$117 003B GR + 7 A$_fs2int$118 003C GR + 7 A$_fs2int$119 003D GR + 7 A$_fs2int$120 003E GR + 7 A$_fs2int$121 003F GR + 7 A$_fs2int$122 0040 GR + 7 A$_fs2int$123 0041 GR + 7 A$_fs2int$124 0042 GR + 7 A$_fs2int$125 0043 GR + 7 A$_fs2int$126 0044 GR + 7 A$_fs2int$127 0045 GR + 7 A$_fs2int$128 0046 GR + 7 A$_fs2int$129 0047 GR + 7 A$_fs2int$131 0048 GR + 7 A$_fs2int$135 004A GR + 7 A$_fs2int$136 004D GR + 7 A$_fs2int$139 0050 GR + 7 A$_fs2int$140 0053 GR + 7 A$_fs2int$141 0054 GR + 7 A$_fs2int$142 0055 GR + 7 A$_fs2int$143 0056 GR + 7 A$_fs2int$144 0057 GR + 7 A$_fs2int$145 0058 GR + 7 A$_fs2int$146 0059 GR + 7 A$_fs2int$147 005A GR + 7 A$_fs2int$148 005B GR + 7 A$_fs2int$149 005C GR + 7 A$_fs2int$150 005D GR + 7 A$_fs2int$151 005E GR + 7 A$_fs2int$152 0060 GR + 7 A$_fs2int$153 0061 GR + 7 A$_fs2int$154 0063 GR + 7 A$_fs2int$155 0064 GR + 7 A$_fs2int$156 0065 GR + 7 A$_fs2int$157 0066 GR + 7 A$_fs2int$158 0067 GR + 7 A$_fs2int$159 0068 GR + 7 A$_fs2int$160 006A GR + 7 A$_fs2int$161 006D GR + 7 A$_fs2int$163 006F GR + 7 A$_fs2int$164 0070 GR + 7 A$_fs2int$165 0071 GR + 7 A$_fs2int$166 0073 GR + 7 A$_fs2int$167 0074 GR + 7 A$_fs2int$168 0075 GR + 7 A$_fs2int$169 0076 GR + 7 A$_fs2int$170 0079 GR + 7 A$_fs2int$171 007B GR + 7 A$_fs2int$172 007C GR + 7 A$_fs2int$173 007E GR + 7 A$_fs2int$174 0080 GR + 7 A$_fs2int$175 0081 GR + 7 A$_fs2int$176 0084 GR + 7 A$_fs2int$177 0085 GR + 7 A$_fs2int$178 0086 GR + 7 A$_fs2int$179 0087 GR + 7 A$_fs2int$180 0088 GR + 7 A$_fs2int$182 0089 GR + 7 A$_fs2int$183 008C GR + 7 A$_fs2int$184 008D GR + 7 A$_fs2int$185 008E GR + 7 A$_fs2int$186 008F GR + 7 A$_fs2int$187 0090 GR + 7 A$_fs2int$188 0091 GR + 7 A$_fs2int$189 0092 GR + 7 A$_fs2int$190 0093 GR + 7 A$_fs2int$191 0094 GR + 7 A$_fs2int$192 0095 GR + 7 A$_fs2int$193 0096 GR + 7 A$_fs2int$194 0097 GR + 7 A$_fs2int$195 009A GR + 7 A$_fs2int$196 009C GR + 7 A$_fs2int$197 009F GR + 7 A$_fs2int$198 00A0 GR + 7 A$_fs2int$199 00A1 GR + 7 A$_fs2int$200 00A2 GR + 7 A$_fs2int$201 00A3 GR + 7 A$_fs2int$202 00A4 GR + 7 A$_fs2int$203 00A6 GR + 7 A$_fs2int$204 00A7 GR + 7 A$_fs2int$205 00A8 GR + 7 A$_fs2int$206 00A9 GR + 7 A$_fs2int$207 00AA GR + 7 A$_fs2int$208 00AB GR + 7 A$_fs2int$210 00AC GR + 7 A$_fs2int$211 00AF GR + 7 A$_fs2int$212 00B0 GR + 7 A$_fs2int$213 00B1 GR + 7 A$_fs2int$214 00B2 GR + 7 A$_fs2int$215 00B3 GR + 7 A$_fs2int$216 00B4 GR + 7 A$_fs2int$218 00B5 GR + 7 A$_fs2int$219 00B6 GR + 7 A$_fs2int$221 00B7 GR + 7 A$_fs2int$222 00B9 GR + 7 A$_fs2int$223 00BB GR + 7 A$_fs2int$224 00BE GR + 7 A$_fs2int$226 00C0 GR + 7 A$_fs2int$229 00C2 GR + 7 A$_fs2int$230 00C5 GR + 7 A$_fs2int$231 00C6 GR + 7 A$_fs2int$232 00C7 GR + 7 A$_fs2int$233 00C8 GR + 7 A$_fs2int$234 00C9 GR + 7 A$_fs2int$235 00CA GR + 7 A$_fs2int$236 00CB GR + 7 A$_fs2int$237 00CC GR + 7 A$_fs2int$238 00CD GR + 7 A$_fs2int$239 00CE GR + 7 A$_fs2int$241 00CF GR + 7 A$_fs2int$242 00D0 GR + 7 A$_fs2int$243 00D1 GR + 7 A$_fs2int$245 00D3 GR + 7 A$_fs2int$246 00D5 GR + 7 A$_fs2int$247 00D6 GR + 7 A$_fs2int$248 00D7 GR + 7 A$_fs2int$249 00D9 GR + 7 A$_fs2int$250 00DA GR + 7 A$_fs2int$251 00DC GR + 7 A$_fs2int$252 00DE GR + 7 A$_fs2int$255 00E1 GR + 7 A$_fs2int$256 00E4 GR + 7 A$_fs2int$257 00E5 GR + 7 A$_fs2int$258 00E6 GR + 7 A$_fs2int$259 00E7 GR + 7 A$_fs2int$261 00E8 GR + 7 A$_fs2int$262 00E9 GR + 7 A$_fs2int$263 00EC GR + 7 A$_fs2int$265 00EF GR + 7 A$_fs2int$266 00F2 GR + 7 A$_fs2int$267 00F3 GR + 7 A$_fs2int$268 00F4 GR + 7 A$_fs2int$269 00F5 GR + 7 A$_fs2int$270 00F6 GR + 7 A$_fs2int$271 00F7 GR + 7 A$_fs2int$272 00F8 GR + 7 A$_fs2int$273 00FA GR + 7 A$_fs2int$275 00FB GR + 7 A$_fs2int$276 00FD GR + 7 A$_fs2int$277 00FF GR + 7 A$_fs2int$278 0102 GR + 7 A$_fs2int$279 0104 GR + 7 A$_fs2int$280 0106 GR + 7 A$_fs2int$282 0109 GR + 7 A$_fs2int$283 010C GR + 7 A$_fs2int$284 010D GR + 7 A$_fs2int$285 010F GR + 7 A$_fs2int$286 0110 GR + 7 A$_fs2int$287 0111 GR + 7 A$_fs2int$288 0113 GR + 7 A$_fs2int$289 0114 GR + 7 A$_fs2int$290 0115 GR + 7 A$_fs2int$291 0117 GR + 7 A$_fs2int$292 0118 GR + 7 A$_fs2int$293 0119 GR + 7 A$_fs2int$294 011B GR + 7 A$_fs2int$295 011D GR + 7 A$_fs2int$296 011F GR + 7 A$_fs2int$297 0121 GR + 7 A$_fs2int$298 0123 GR + 7 A$_fs2int$299 0125 GR + 7 A$_fs2int$302 0128 GR + 7 A$_fs2int$303 012B GR + 7 A$_fs2int$304 012C GR + 7 A$_fs2int$305 012D GR + 7 A$_fs2int$306 012E GR + 7 A$_fs2int$307 012F GR + 7 A$_fs2int$308 0130 GR + 7 A$_fs2int$309 0131 GR + 7 A$_fs2int$310 0132 GR + 7 A$_fs2int$311 0133 GR + 7 A$_fs2int$312 0135 GR + 7 A$_fs2int$313 0136 GR + 7 A$_fs2int$314 0137 GR + 7 A$_fs2int$315 0139 GR + 7 A$_fs2int$316 013C GR + 7 A$_fs2int$317 013D GR + 7 A$_fs2int$318 013F GR + 7 A$_fs2int$319 0140 GR + 7 A$_fs2int$320 0141 GR + 7 A$_fs2int$321 0143 GR + 7 A$_fs2int$322 0144 GR + 7 A$_fs2int$323 0145 GR + 7 A$_fs2int$324 0147 GR + 7 A$_fs2int$325 0148 GR + 7 A$_fs2int$326 0149 GR + 7 A$_fs2int$327 014B GR + 7 A$_fs2int$328 014E GR + 7 A$_fs2int$329 0150 GR + 7 A$_fs2int$330 0152 GR + 7 A$_fs2int$331 0153 GR + 7 A$_fs2int$332 0155 GR + 7 A$_fs2int$334 0157 GR + 7 A$_fs2int$335 0159 GR + 7 A$_fs2int$336 015B GR + 7 A$_fs2int$337 015C GR + 7 A$_fs2int$338 015E GR + 7 A$_fs2int$339 0160 GR + 7 A$_fs2int$340 0161 GR + 7 A$_fs2int$341 0163 GR + 7 A$_fs2int$342 0165 GR + 7 A$_fs2int$343 0166 GR + 7 A$_fs2int$344 0168 GR + 7 A$_fs2int$345 016A GR + 7 A$_fs2int$346 016B GR + 7 A$_fs2int$348 016D GR + 7 A$_fs2int$349 0170 GR + 7 A$_fs2int$350 0173 GR + 7 A$_fs2int$351 0175 GR + 7 A$_fs2int$352 0176 GR + 7 A$_fs2int$353 0177 GR + 7 A$_fs2int$354 0179 GR + 7 A$_fs2int$355 017A GR + 7 A$_fs2int$356 017B GR + 7 A$_fs2int$357 017D GR + 7 A$_fs2int$358 017E GR + 7 A$_fs2int$359 017F GR + 7 A$_fs2int$360 0181 GR + 7 A$_fs2int$362 0182 GR + 7 A$_fs2int$366 0184 GR + 7 A$_fs2int$367 0187 GR + 7 A$_fs2int$370 018A GR + 7 A$_fs2int$371 018D GR + 7 A$_fs2int$372 018E GR + 7 A$_fs2int$373 0190 GR + 7 A$_fs2int$374 0191 GR + 7 A$_fs2int$375 0192 GR + 7 A$_fs2int$376 0194 GR + 7 A$_fs2int$377 0195 GR + 7 A$_fs2int$378 0196 GR + 7 A$_fs2int$379 0198 GR + 7 A$_fs2int$380 0199 GR + 7 A$_fs2int$382 019A GR + 7 A$_fs2int$383 019C GR + 7 A$_fs2int$384 019D GR + 7 A$_fs2int$386 019F GR + 7 A$_fs2int$388 01A0 GR + 7 A$_fs2int$390 01A2 GR + 7 A$_fs2int$391 01A5 GR + 7 A$_fs2int$392 01A6 GR + 7 A$_fs2int$393 01A8 GR + 7 A$_fs2int$394 01A9 GR + 7 A$_fs2int$395 01AA GR + 7 A$_fs2int$396 01AC GR + 7 A$_fs2int$397 01AD GR + 7 A$_fs2int$398 01AE GR + 7 A$_fs2int$399 01B0 GR + 7 A$_fs2int$400 01B1 GR + 7 A$_fs2int$401 01B2 GR + 7 A$_fs2int$402 01B4 GR + 7 A$_fs2int$403 01B5 GR + 7 A$_fs2int$404 01B6 GR + 7 A$_fs2int$405 01B8 GR + 7 A$_fs2int$406 01BA GR + 7 A$_fs2int$407 01BB GR + 7 A$_fs2int$408 01BD GR + 7 A$_fs2int$409 01BF GR + 7 A$_fs2int$410 01C0 GR + 7 A$_fs2int$411 01C2 GR + 7 A$_fs2int$412 01C4 GR + 7 A$_fs2int$413 01C5 GR + 7 A$_fs2int$414 01C7 GR + 7 A$_fs2int$416 01C9 GR + 7 A$_fs2int$418 01CB GR + 7 A$_fs2int$419 01CE GR + 7 A$_fs2int$420 01CF GR + 7 A$_fs2int$421 01D1 GR + 7 A$_fs2int$422 01D2 GR + 7 A$_fs2int$423 01D3 GR + 7 A$_fs2int$424 01D5 GR + 7 A$_fs2int$425 01D6 GR + 7 A$_fs2int$426 01D7 GR + 7 A$_fs2int$427 01D9 GR + 7 A$_fs2int$428 01DA GR + 7 A$_fs2int$429 01DB GR + 7 A$_fs2int$431 01DD GR + 7 A$_fs2int$432 01DF GR + 7 A$_fs2int$433 01E1 GR + 7 A$_fs2int$434 01E3 GR + 7 A$_fs2int$438 01E5 GR + 7 A$_fs2int$72 0000 GR + 7 A$_fs2int$73 0002 GR + 7 A$_fs2int$74 0004 GR + 7 A$_fs2int$75 0006 GR + 7 A$_fs2int$76 0008 GR + 7 A$_fs2int$77 000B GR + 7 A$_fs2int$78 000D GR + 7 A$_fs2int$79 000E GR + 7 A$_fs2int$80 0010 GR + 7 A$_fs2int$81 0011 GR + 7 A$_fs2int$82 0012 GR + 7 A$_fs2int$83 0014 GR + 7 A$_fs2int$84 0015 GR + 7 A$_fs2int$85 0016 GR + 7 A$_fs2int$86 0018 GR + 7 A$_fs2int$87 0019 GR + 7 A$_fs2int$89 001A GR + 7 A$_fs2int$90 001D GR + 7 A$_fs2int$91 001E GR + 7 A$_fs2int$92 001F GR + 7 A$_fs2int$93 0020 GR + 7 A$_fs2int$94 0021 GR + 7 A$_fs2int$95 0022 GR + 7 A$_fs2int$96 0023 GR + 7 A$_fs2int$97 0024 GR + 7 A$_fs2int$98 0025 GR + 7 A$_fs2int$99 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fs2int.c$97$1$1 = 01E5 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fs2int$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fs2int$0$0 = 01E5 GR + 7 ___fs2int 0000 GR + 5 ___fs2int_a1_1_1 0000 R + 5 ___fs2int_exp_1_1 0008 R + 5 ___fs2int_fl1_1_1 0004 R + 5 ___fs2int_l_1_1 000A R + 1 ___fs2int_sloc0_1_0 0000 R + 1 ___fs2int_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 1E6 flags 20 diff --git a/device/lib/_fs2long.c b/device/lib/_fs2long.c new file mode 100644 index 00000000..ded945f3 --- /dev/null +++ b/device/lib/_fs2long.c @@ -0,0 +1,98 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* convert double to int */ +long +__fs2long (float a1) +{ + volatile union float_long fl1; + volatile int exp; + volatile long l; + + fl1.f = a1; + + if (!fl1.l) + return (0); + + exp = EXP (fl1.l) - EXCESS - 24; + l = MANT (fl1.l); + + if (exp > 0) + return (0x7F | SIGN(fl1.l)); /* largest integer */ + + /* shift down until exp = 0 or l = 0 */ + if (exp < 0 && exp > -25 && l) + l >>= -exp; + else + return (0); + + return (SIGN(fl1.l) ? -l : l); +} + diff --git a/device/lib/_fs2long.lst b/device/lib/_fs2long.lst new file mode 100644 index 00000000..04962f38 --- /dev/null +++ b/device/lib/_fs2long.lst @@ -0,0 +1,454 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fs2long + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fs2long + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___fs2long_sloc0_1_0: + 0000 22 .ds 0x0004 + 0004 23 ___fs2long_sloc1_1_0: + 0004 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___fs2long_a1_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___fs2long_fl1_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___fs2long_exp_1_1: + 0008 46 .ds 0x0002 + 000A 47 ___fs2long_l_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__fs2long$0$0 ==. + 58 ; _fs2long.c 73 + 59 ; ----------------------------------------- + 60 ; function __fs2long + 61 ; ----------------------------------------- + 0000 62 ___fs2long: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _fs2long.c 0 + 0000 C0 E0 72 push acc + 0002 C0 F0 73 push b + 0004 C0 83 74 push dph + 0006 C0 82 75 push dpl + 0008 90s00r00 76 mov dptr,#___fs2long_a1_1_1 + 000B D0 E0 77 pop acc + 000D F0 78 movx @dptr,a + 000E D0 E0 79 pop acc + 0010 A3 80 inc dptr + 0011 F0 81 movx @dptr,a + 0012 D0 E0 82 pop acc + 0014 A3 83 inc dptr + 0015 F0 84 movx @dptr,a + 0016 D0 E0 85 pop acc + 0018 A3 86 inc dptr + 0019 F0 87 movx @dptr,a + 88 ; _fs2long.c 79 + 001A 90s00r00 89 mov dptr,#___fs2long_a1_1_1 + 001D E0 90 movx a,@dptr + 001E FA 91 mov r2,a + 001F A3 92 inc dptr + 0020 E0 93 movx a,@dptr + 0021 FB 94 mov r3,a + 0022 A3 95 inc dptr + 0023 E0 96 movx a,@dptr + 0024 FC 97 mov r4,a + 0025 A3 98 inc dptr + 0026 E0 99 movx a,@dptr + 0027 FD 100 mov r5,a + 0028 90s00r04 101 mov dptr,#(___fs2long_fl1_1_1) + 002B EA 102 mov a,r2 + 002C F0 103 movx @dptr,a + 002D A3 104 inc dptr + 002E EB 105 mov a,r3 + 002F F0 106 movx @dptr,a + 0030 A3 107 inc dptr + 0031 EC 108 mov a,r4 + 0032 F0 109 movx @dptr,a + 0033 A3 110 inc dptr + 0034 ED 111 mov a,r5 + 0035 F0 112 movx @dptr,a + 113 ; _fs2long.c 81 + 0036 90s00r04 114 mov dptr,#(___fs2long_fl1_1_1) + 0039 E0 115 movx a,@dptr + 003A FA 116 mov r2,a + 003B A3 117 inc dptr + 003C E0 118 movx a,@dptr + 003D FB 119 mov r3,a + 003E A3 120 inc dptr + 003F E0 121 movx a,@dptr + 0040 FC 122 mov r4,a + 0041 A3 123 inc dptr + 0042 E0 124 movx a,@dptr + 0043 FD 125 mov r5,a + 0044 EA 126 mov a,r2 + 0045 4B 127 orl a,r3 + 0046 4C 128 orl a,r4 + 0047 4D 129 orl a,r5 + 130 ; Peephole 109 removed ljmp by inverse jump logic + 0048 70 0A 131 jnz 00102$ + 004A 132 00120$: + 133 ; _fs2long.c 82 + 134 ; Peephole 3.a changed mov to clr + 135 ; Peephole 3.b changed mov to clr + 136 ; Peephole 3.b changed mov to clr + 004A E4 137 clr a + 004B F5 82 138 mov dpl,a + 004D F5 83 139 mov dph,a + 004F F5 F0 140 mov b,a + 0051 02s01rFE 141 ljmp 00110$ + 0054 142 00102$: + 143 ; _fs2long.c 84 + 0054 90s00r04 144 mov dptr,#(___fs2long_fl1_1_1) + 0057 E0 145 movx a,@dptr + 0058 FA 146 mov r2,a + 0059 A3 147 inc dptr + 005A E0 148 movx a,@dptr + 005B FB 149 mov r3,a + 005C A3 150 inc dptr + 005D E0 151 movx a,@dptr + 005E FC 152 mov r4,a + 005F A3 153 inc dptr + 0060 E0 154 movx a,@dptr + 0061 FD 155 mov r5,a + 0062 8C 02 156 mov ar2,r4 + 0064 ED 157 mov a,r5 + 0065 A2 E7 158 mov c,acc.7 + 0067 CA 159 xch a,r2 + 0068 33 160 rlc a + 0069 CA 161 xch a,r2 + 006A 33 162 rlc a + 006B CA 163 xch a,r2 + 006C 54 01 164 anl a,#0x01 + 006E 30 E0 02 165 jnb acc.0,00121$ + 0071 44 FE 166 orl a,#0xfe + 0073 167 00121$: + 0073 FB 168 mov r3,a + 0074 33 169 rlc a + 0075 95 E0 170 subb a,acc + 0077 FC 171 mov r4,a + 0078 FD 172 mov r5,a + 0079 EA 173 mov a,r2 + 007A 75 F0 00 174 mov b,#0x00 + 007D 24 6A 175 add a,#0x6a + 007F FA 176 mov r2,a + 0080 E5 F0 177 mov a,b + 0082 34 FF 178 addc a,#0xff + 0084 FB 179 mov r3,a + 0085 90s00r08 180 mov dptr,#___fs2long_exp_1_1 + 0088 EA 181 mov a,r2 + 0089 F0 182 movx @dptr,a + 008A A3 183 inc dptr + 008B EB 184 mov a,r3 + 008C F0 185 movx @dptr,a + 186 ; _fs2long.c 85 + 008D 90s00r04 187 mov dptr,#(___fs2long_fl1_1_1) + 0090 E0 188 movx a,@dptr + 0091 FA 189 mov r2,a + 0092 A3 190 inc dptr + 0093 E0 191 movx a,@dptr + 0094 FB 192 mov r3,a + 0095 A3 193 inc dptr + 0096 E0 194 movx a,@dptr + 0097 FE 195 mov r6,a + 0098 A3 196 inc dptr + 0099 E0 197 movx a,@dptr + 009A FF 198 mov r7,a + 009B 53 06 7F 199 anl ar6,#0x7f + 009E 7F 00 200 mov r7,#0x00 + 00A0 90s00r0A 201 mov dptr,#___fs2long_l_1_1 + 00A3 EA 202 mov a,r2 + 00A4 F0 203 movx @dptr,a + 00A5 A3 204 inc dptr + 00A6 EB 205 mov a,r3 + 00A7 F0 206 movx @dptr,a + 00A8 74 80 207 mov a,#0x80 + 00AA 4E 208 orl a,r6 + 00AB A3 209 inc dptr + 00AC F0 210 movx @dptr,a + 00AD A3 211 inc dptr + 00AE EF 212 mov a,r7 + 00AF F0 213 movx @dptr,a + 214 ; _fs2long.c 87 + 00B0 90s00r08 215 mov dptr,#___fs2long_exp_1_1 + 00B3 E0 216 movx a,@dptr + 00B4 FA 217 mov r2,a + 00B5 A3 218 inc dptr + 00B6 E0 219 movx a,@dptr + 00B7 FB 220 mov r3,a + 00B8 C3 221 clr c + 222 ; Peephole 180 changed mov to clr + 00B9 E4 223 clr a + 00BA 9A 224 subb a,r2 + 225 ; Peephole 159 avoided xrl during execution + 00BB 74 80 226 mov a,#(0x00 ^ 0x80) + 00BD 8B F0 227 mov b,r3 + 00BF 63 F0 80 228 xrl b,#0x80 + 00C2 95 F0 229 subb a,b + 230 ; Peephole 108 removed ljmp by inverse jump logic + 00C4 50 2D 231 jnc 00104$ + 00C6 232 00122$: + 233 ; _fs2long.c 88 + 00C6 90s00r04 234 mov dptr,#(___fs2long_fl1_1_1) + 00C9 E0 235 movx a,@dptr + 00CA FA 236 mov r2,a + 00CB A3 237 inc dptr + 00CC E0 238 movx a,@dptr + 00CD FB 239 mov r3,a + 00CE A3 240 inc dptr + 00CF E0 241 movx a,@dptr + 00D0 FE 242 mov r6,a + 00D1 A3 243 inc dptr + 00D2 E0 244 movx a,@dptr + 245 ; Peephole 105 removed redundant mov + 00D3 FF 246 mov r7,a + 00D4 23 247 rl a + 00D5 54 01 248 anl a,#0x01 + 00D7 FA 249 mov r2,a + 00D8 43 02 7F 250 orl ar2,#0x7f + 00DB 8A*00 251 mov ___fs2long_sloc0_1_0,r2 + 00DD EA 252 mov a,r2 + 00DE 33 253 rlc a + 00DF 95 E0 254 subb a,acc + 00E1 F5*01 255 mov (___fs2long_sloc0_1_0 + 1),a + 00E3 F5*02 256 mov (___fs2long_sloc0_1_0 + 2),a + 257 ; Peephole 191 removed redundant mov + 00E5 F5*03 258 mov (___fs2long_sloc0_1_0 + 3),a + 00E7 85*00 82 259 mov dpl,___fs2long_sloc0_1_0 + 00EA 85*01 83 260 mov dph,(___fs2long_sloc0_1_0 + 1) + 00ED 85*02 F0 261 mov b,(___fs2long_sloc0_1_0 + 2) + 00F0 02s01rFE 262 ljmp 00110$ + 00F3 263 00104$: + 264 ; _fs2long.c 91 + 00F3 90s00r08 265 mov dptr,#___fs2long_exp_1_1 + 00F6 E0 266 movx a,@dptr + 00F7 FA 267 mov r2,a + 00F8 A3 268 inc dptr + 00F9 E0 269 movx a,@dptr + 270 ; Peephole 105 removed redundant mov + 00FA F8 271 mov r0,a + 00FB 20 E7 03 272 jb acc.7,00123$ + 00FE 02s01r96 273 ljmp 00106$ + 0101 274 00123$: + 0101 90s00r08 275 mov dptr,#___fs2long_exp_1_1 + 0104 E0 276 movx a,@dptr + 0105 FA 277 mov r2,a + 0106 A3 278 inc dptr + 0107 E0 279 movx a,@dptr + 0108 F8 280 mov r0,a + 0109 C3 281 clr c + 010A 74 E7 282 mov a,#0xe7 + 010C 9A 283 subb a,r2 + 284 ; Peephole 159 avoided xrl during execution + 010D 74 7F 285 mov a,#(0xff ^ 0x80) + 010F 88 F0 286 mov b,r0 + 0111 63 F0 80 287 xrl b,#0x80 + 0114 95 F0 288 subb a,b + 0116 40 03 289 jc 00124$ + 0118 02s01r96 290 ljmp 00106$ + 011B 291 00124$: + 011B 90s00r0A 292 mov dptr,#___fs2long_l_1_1 + 011E E0 293 movx a,@dptr + 011F F5*00 294 mov ___fs2long_sloc0_1_0,a + 0121 A3 295 inc dptr + 0122 E0 296 movx a,@dptr + 0123 F5*01 297 mov (___fs2long_sloc0_1_0 + 1),a + 0125 A3 298 inc dptr + 0126 E0 299 movx a,@dptr + 0127 F5*02 300 mov (___fs2long_sloc0_1_0 + 2),a + 0129 A3 301 inc dptr + 012A E0 302 movx a,@dptr + 012B F5*03 303 mov (___fs2long_sloc0_1_0 + 3),a + 012D E5*00 304 mov a,___fs2long_sloc0_1_0 + 012F 45*01 305 orl a,(___fs2long_sloc0_1_0 + 1) + 0131 45*02 306 orl a,(___fs2long_sloc0_1_0 + 2) + 0133 45*03 307 orl a,(___fs2long_sloc0_1_0 + 3) + 0135 70 03 308 jnz 00125$ + 0137 02s01r96 309 ljmp 00106$ + 013A 310 00125$: + 311 ; _fs2long.c 92 + 013A 90s00r08 312 mov dptr,#___fs2long_exp_1_1 + 013D E0 313 movx a,@dptr + 013E FA 314 mov r2,a + 013F A3 315 inc dptr + 0140 E0 316 movx a,@dptr + 0141 F8 317 mov r0,a + 0142 C3 318 clr c + 0143 E4 319 clr a + 0144 9A 320 subb a,r2 + 0145 F5*00 321 mov ___fs2long_sloc0_1_0,a + 0147 E4 322 clr a + 0148 98 323 subb a,r0 + 0149 F5*01 324 mov (___fs2long_sloc0_1_0 + 1),a + 014B 90s00r0A 325 mov dptr,#___fs2long_l_1_1 + 014E E0 326 movx a,@dptr + 014F F5*04 327 mov ___fs2long_sloc1_1_0,a + 0151 A3 328 inc dptr + 0152 E0 329 movx a,@dptr + 0153 F5*05 330 mov (___fs2long_sloc1_1_0 + 1),a + 0155 A3 331 inc dptr + 0156 E0 332 movx a,@dptr + 0157 F5*06 333 mov (___fs2long_sloc1_1_0 + 2),a + 0159 A3 334 inc dptr + 015A E0 335 movx a,@dptr + 015B F5*07 336 mov (___fs2long_sloc1_1_0 + 3),a + 015D 85*00 F0 337 mov b,___fs2long_sloc0_1_0 + 0160 05 F0 338 inc b + 0162 E5*07 339 mov a,(___fs2long_sloc1_1_0 + 3) + 0164 33 340 rlc a + 0165 92 D2 341 mov ov,c + 0167 80 16 342 sjmp 00127$ + 0169 343 00126$: + 0169 A2 D2 344 mov c,ov + 016B E5*07 345 mov a,(___fs2long_sloc1_1_0 + 3) + 016D 13 346 rrc a + 016E F5*07 347 mov (___fs2long_sloc1_1_0 + 3),a + 0170 E5*06 348 mov a,(___fs2long_sloc1_1_0 + 2) + 0172 13 349 rrc a + 0173 F5*06 350 mov (___fs2long_sloc1_1_0 + 2),a + 0175 E5*05 351 mov a,(___fs2long_sloc1_1_0 + 1) + 0177 13 352 rrc a + 0178 F5*05 353 mov (___fs2long_sloc1_1_0 + 1),a + 017A E5*04 354 mov a,___fs2long_sloc1_1_0 + 017C 13 355 rrc a + 017D F5*04 356 mov ___fs2long_sloc1_1_0,a + 017F 357 00127$: + 017F D5 F0 E7 358 djnz b,00126$ + 0182 90s00r0A 359 mov dptr,#___fs2long_l_1_1 + 0185 E5*04 360 mov a,___fs2long_sloc1_1_0 + 0187 F0 361 movx @dptr,a + 0188 A3 362 inc dptr + 0189 E5*05 363 mov a,(___fs2long_sloc1_1_0 + 1) + 018B F0 364 movx @dptr,a + 018C A3 365 inc dptr + 018D E5*06 366 mov a,(___fs2long_sloc1_1_0 + 2) + 018F F0 367 movx @dptr,a + 0190 A3 368 inc dptr + 0191 E5*07 369 mov a,(___fs2long_sloc1_1_0 + 3) + 0193 F0 370 movx @dptr,a + 371 ; Peephole 132 changed ljmp to sjmp + 0194 80 0A 372 sjmp 00107$ + 0196 373 00106$: + 374 ; _fs2long.c 94 + 375 ; Peephole 3.a changed mov to clr + 376 ; Peephole 3.b changed mov to clr + 377 ; Peephole 3.b changed mov to clr + 0196 E4 378 clr a + 0197 F5 82 379 mov dpl,a + 0199 F5 83 380 mov dph,a + 019B F5 F0 381 mov b,a + 019D 02s01rFE 382 ljmp 00110$ + 01A0 383 00107$: + 384 ; _fs2long.c 96 + 01A0 90s00r04 385 mov dptr,#(___fs2long_fl1_1_1) + 01A3 E0 386 movx a,@dptr + 01A4 F5*04 387 mov ___fs2long_sloc1_1_0,a + 01A6 A3 388 inc dptr + 01A7 E0 389 movx a,@dptr + 01A8 F5*05 390 mov (___fs2long_sloc1_1_0 + 1),a + 01AA A3 391 inc dptr + 01AB E0 392 movx a,@dptr + 01AC F5*06 393 mov (___fs2long_sloc1_1_0 + 2),a + 01AE A3 394 inc dptr + 01AF E0 395 movx a,@dptr + 396 ; Peephole 105 removed redundant mov + 01B0 F5*07 397 mov (___fs2long_sloc1_1_0 + 3),a + 01B2 23 398 rl a + 01B3 54 01 399 anl a,#0x01 + 400 ; Peephole 105 removed redundant mov + 01B5 FA 401 mov r2,a + 402 ; Peephole 110 removed ljmp by inverse jump logic + 01B6 60 29 403 jz 00112$ + 01B8 404 00128$: + 01B8 90s00r0A 405 mov dptr,#___fs2long_l_1_1 + 01BB E0 406 movx a,@dptr + 01BC F5*04 407 mov ___fs2long_sloc1_1_0,a + 01BE A3 408 inc dptr + 01BF E0 409 movx a,@dptr + 01C0 F5*05 410 mov (___fs2long_sloc1_1_0 + 1),a + 01C2 A3 411 inc dptr + 01C3 E0 412 movx a,@dptr + 01C4 F5*06 413 mov (___fs2long_sloc1_1_0 + 2),a + 01C6 A3 414 inc dptr + 01C7 E0 415 movx a,@dptr + 01C8 F5*07 416 mov (___fs2long_sloc1_1_0 + 3),a + 01CA C3 417 clr c + 01CB E4 418 clr a + 01CC 95*04 419 subb a,___fs2long_sloc1_1_0 + 01CE F5*04 420 mov ___fs2long_sloc1_1_0,a + 01D0 E4 421 clr a + 01D1 95*05 422 subb a,(___fs2long_sloc1_1_0 + 1) + 01D3 F5*05 423 mov (___fs2long_sloc1_1_0 + 1),a + 01D5 E4 424 clr a + 01D6 95*06 425 subb a,(___fs2long_sloc1_1_0 + 2) + 01D8 F5*06 426 mov (___fs2long_sloc1_1_0 + 2),a + 01DA E4 427 clr a + 01DB 95*07 428 subb a,(___fs2long_sloc1_1_0 + 3) + 01DD F5*07 429 mov (___fs2long_sloc1_1_0 + 3),a + 430 ; Peephole 132 changed ljmp to sjmp + 01DF 80 12 431 sjmp 00113$ + 01E1 432 00112$: + 01E1 90s00r0A 433 mov dptr,#___fs2long_l_1_1 + 01E4 E0 434 movx a,@dptr + 01E5 F5*04 435 mov ___fs2long_sloc1_1_0,a + 01E7 A3 436 inc dptr + 01E8 E0 437 movx a,@dptr + 01E9 F5*05 438 mov (___fs2long_sloc1_1_0 + 1),a + 01EB A3 439 inc dptr + 01EC E0 440 movx a,@dptr + 01ED F5*06 441 mov (___fs2long_sloc1_1_0 + 2),a + 01EF A3 442 inc dptr + 01F0 E0 443 movx a,@dptr + 01F1 F5*07 444 mov (___fs2long_sloc1_1_0 + 3),a + 01F3 445 00113$: + 01F3 85*04 82 446 mov dpl,___fs2long_sloc1_1_0 + 01F6 85*05 83 447 mov dph,(___fs2long_sloc1_1_0 + 1) + 01F9 85*06 F0 448 mov b,(___fs2long_sloc1_1_0 + 2) + 01FC E5*07 449 mov a,(___fs2long_sloc1_1_0 + 3) + 01FE 450 00110$: + 01FE 451 C$_fs2long.c$97$1$1 ==. + 01FE 452 XG$__fs2long$0$0 ==. + 01FE 22 453 ret + 454 .area CSEG (CODE) diff --git a/device/lib/_fs2long.sym b/device/lib/_fs2long.sym new file mode 100644 index 00000000..b1af2f0e --- /dev/null +++ b/device/lib/_fs2long.sym @@ -0,0 +1,705 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fs2long$100 0027 GR + 7 A$_fs2long$101 0028 GR + 7 A$_fs2long$102 002B GR + 7 A$_fs2long$103 002C GR + 7 A$_fs2long$104 002D GR + 7 A$_fs2long$105 002E GR + 7 A$_fs2long$106 002F GR + 7 A$_fs2long$107 0030 GR + 7 A$_fs2long$108 0031 GR + 7 A$_fs2long$109 0032 GR + 7 A$_fs2long$110 0033 GR + 7 A$_fs2long$111 0034 GR + 7 A$_fs2long$112 0035 GR + 7 A$_fs2long$114 0036 GR + 7 A$_fs2long$115 0039 GR + 7 A$_fs2long$116 003A GR + 7 A$_fs2long$117 003B GR + 7 A$_fs2long$118 003C GR + 7 A$_fs2long$119 003D GR + 7 A$_fs2long$120 003E GR + 7 A$_fs2long$121 003F GR + 7 A$_fs2long$122 0040 GR + 7 A$_fs2long$123 0041 GR + 7 A$_fs2long$124 0042 GR + 7 A$_fs2long$125 0043 GR + 7 A$_fs2long$126 0044 GR + 7 A$_fs2long$127 0045 GR + 7 A$_fs2long$128 0046 GR + 7 A$_fs2long$129 0047 GR + 7 A$_fs2long$131 0048 GR + 7 A$_fs2long$137 004A GR + 7 A$_fs2long$138 004B GR + 7 A$_fs2long$139 004D GR + 7 A$_fs2long$140 004F GR + 7 A$_fs2long$141 0051 GR + 7 A$_fs2long$144 0054 GR + 7 A$_fs2long$145 0057 GR + 7 A$_fs2long$146 0058 GR + 7 A$_fs2long$147 0059 GR + 7 A$_fs2long$148 005A GR + 7 A$_fs2long$149 005B GR + 7 A$_fs2long$150 005C GR + 7 A$_fs2long$151 005D GR + 7 A$_fs2long$152 005E GR + 7 A$_fs2long$153 005F GR + 7 A$_fs2long$154 0060 GR + 7 A$_fs2long$155 0061 GR + 7 A$_fs2long$156 0062 GR + 7 A$_fs2long$157 0064 GR + 7 A$_fs2long$158 0065 GR + 7 A$_fs2long$159 0067 GR + 7 A$_fs2long$160 0068 GR + 7 A$_fs2long$161 0069 GR + 7 A$_fs2long$162 006A GR + 7 A$_fs2long$163 006B GR + 7 A$_fs2long$164 006C GR + 7 A$_fs2long$165 006E GR + 7 A$_fs2long$166 0071 GR + 7 A$_fs2long$168 0073 GR + 7 A$_fs2long$169 0074 GR + 7 A$_fs2long$170 0075 GR + 7 A$_fs2long$171 0077 GR + 7 A$_fs2long$172 0078 GR + 7 A$_fs2long$173 0079 GR + 7 A$_fs2long$174 007A GR + 7 A$_fs2long$175 007D GR + 7 A$_fs2long$176 007F GR + 7 A$_fs2long$177 0080 GR + 7 A$_fs2long$178 0082 GR + 7 A$_fs2long$179 0084 GR + 7 A$_fs2long$180 0085 GR + 7 A$_fs2long$181 0088 GR + 7 A$_fs2long$182 0089 GR + 7 A$_fs2long$183 008A GR + 7 A$_fs2long$184 008B GR + 7 A$_fs2long$185 008C GR + 7 A$_fs2long$187 008D GR + 7 A$_fs2long$188 0090 GR + 7 A$_fs2long$189 0091 GR + 7 A$_fs2long$190 0092 GR + 7 A$_fs2long$191 0093 GR + 7 A$_fs2long$192 0094 GR + 7 A$_fs2long$193 0095 GR + 7 A$_fs2long$194 0096 GR + 7 A$_fs2long$195 0097 GR + 7 A$_fs2long$196 0098 GR + 7 A$_fs2long$197 0099 GR + 7 A$_fs2long$198 009A GR + 7 A$_fs2long$199 009B GR + 7 A$_fs2long$200 009E GR + 7 A$_fs2long$201 00A0 GR + 7 A$_fs2long$202 00A3 GR + 7 A$_fs2long$203 00A4 GR + 7 A$_fs2long$204 00A5 GR + 7 A$_fs2long$205 00A6 GR + 7 A$_fs2long$206 00A7 GR + 7 A$_fs2long$207 00A8 GR + 7 A$_fs2long$208 00AA GR + 7 A$_fs2long$209 00AB GR + 7 A$_fs2long$210 00AC GR + 7 A$_fs2long$211 00AD GR + 7 A$_fs2long$212 00AE GR + 7 A$_fs2long$213 00AF GR + 7 A$_fs2long$215 00B0 GR + 7 A$_fs2long$216 00B3 GR + 7 A$_fs2long$217 00B4 GR + 7 A$_fs2long$218 00B5 GR + 7 A$_fs2long$219 00B6 GR + 7 A$_fs2long$220 00B7 GR + 7 A$_fs2long$221 00B8 GR + 7 A$_fs2long$223 00B9 GR + 7 A$_fs2long$224 00BA GR + 7 A$_fs2long$226 00BB GR + 7 A$_fs2long$227 00BD GR + 7 A$_fs2long$228 00BF GR + 7 A$_fs2long$229 00C2 GR + 7 A$_fs2long$231 00C4 GR + 7 A$_fs2long$234 00C6 GR + 7 A$_fs2long$235 00C9 GR + 7 A$_fs2long$236 00CA GR + 7 A$_fs2long$237 00CB GR + 7 A$_fs2long$238 00CC GR + 7 A$_fs2long$239 00CD GR + 7 A$_fs2long$240 00CE GR + 7 A$_fs2long$241 00CF GR + 7 A$_fs2long$242 00D0 GR + 7 A$_fs2long$243 00D1 GR + 7 A$_fs2long$244 00D2 GR + 7 A$_fs2long$246 00D3 GR + 7 A$_fs2long$247 00D4 GR + 7 A$_fs2long$248 00D5 GR + 7 A$_fs2long$249 00D7 GR + 7 A$_fs2long$250 00D8 GR + 7 A$_fs2long$251 00DB GR + 7 A$_fs2long$252 00DD GR + 7 A$_fs2long$253 00DE GR + 7 A$_fs2long$254 00DF GR + 7 A$_fs2long$255 00E1 GR + 7 A$_fs2long$256 00E3 GR + 7 A$_fs2long$258 00E5 GR + 7 A$_fs2long$259 00E7 GR + 7 A$_fs2long$260 00EA GR + 7 A$_fs2long$261 00ED GR + 7 A$_fs2long$262 00F0 GR + 7 A$_fs2long$265 00F3 GR + 7 A$_fs2long$266 00F6 GR + 7 A$_fs2long$267 00F7 GR + 7 A$_fs2long$268 00F8 GR + 7 A$_fs2long$269 00F9 GR + 7 A$_fs2long$271 00FA GR + 7 A$_fs2long$272 00FB GR + 7 A$_fs2long$273 00FE GR + 7 A$_fs2long$275 0101 GR + 7 A$_fs2long$276 0104 GR + 7 A$_fs2long$277 0105 GR + 7 A$_fs2long$278 0106 GR + 7 A$_fs2long$279 0107 GR + 7 A$_fs2long$280 0108 GR + 7 A$_fs2long$281 0109 GR + 7 A$_fs2long$282 010A GR + 7 A$_fs2long$283 010C GR + 7 A$_fs2long$285 010D GR + 7 A$_fs2long$286 010F GR + 7 A$_fs2long$287 0111 GR + 7 A$_fs2long$288 0114 GR + 7 A$_fs2long$289 0116 GR + 7 A$_fs2long$290 0118 GR + 7 A$_fs2long$292 011B GR + 7 A$_fs2long$293 011E GR + 7 A$_fs2long$294 011F GR + 7 A$_fs2long$295 0121 GR + 7 A$_fs2long$296 0122 GR + 7 A$_fs2long$297 0123 GR + 7 A$_fs2long$298 0125 GR + 7 A$_fs2long$299 0126 GR + 7 A$_fs2long$300 0127 GR + 7 A$_fs2long$301 0129 GR + 7 A$_fs2long$302 012A GR + 7 A$_fs2long$303 012B GR + 7 A$_fs2long$304 012D GR + 7 A$_fs2long$305 012F GR + 7 A$_fs2long$306 0131 GR + 7 A$_fs2long$307 0133 GR + 7 A$_fs2long$308 0135 GR + 7 A$_fs2long$309 0137 GR + 7 A$_fs2long$312 013A GR + 7 A$_fs2long$313 013D GR + 7 A$_fs2long$314 013E GR + 7 A$_fs2long$315 013F GR + 7 A$_fs2long$316 0140 GR + 7 A$_fs2long$317 0141 GR + 7 A$_fs2long$318 0142 GR + 7 A$_fs2long$319 0143 GR + 7 A$_fs2long$320 0144 GR + 7 A$_fs2long$321 0145 GR + 7 A$_fs2long$322 0147 GR + 7 A$_fs2long$323 0148 GR + 7 A$_fs2long$324 0149 GR + 7 A$_fs2long$325 014B GR + 7 A$_fs2long$326 014E GR + 7 A$_fs2long$327 014F GR + 7 A$_fs2long$328 0151 GR + 7 A$_fs2long$329 0152 GR + 7 A$_fs2long$330 0153 GR + 7 A$_fs2long$331 0155 GR + 7 A$_fs2long$332 0156 GR + 7 A$_fs2long$333 0157 GR + 7 A$_fs2long$334 0159 GR + 7 A$_fs2long$335 015A GR + 7 A$_fs2long$336 015B GR + 7 A$_fs2long$337 015D GR + 7 A$_fs2long$338 0160 GR + 7 A$_fs2long$339 0162 GR + 7 A$_fs2long$340 0164 GR + 7 A$_fs2long$341 0165 GR + 7 A$_fs2long$342 0167 GR + 7 A$_fs2long$344 0169 GR + 7 A$_fs2long$345 016B GR + 7 A$_fs2long$346 016D GR + 7 A$_fs2long$347 016E GR + 7 A$_fs2long$348 0170 GR + 7 A$_fs2long$349 0172 GR + 7 A$_fs2long$350 0173 GR + 7 A$_fs2long$351 0175 GR + 7 A$_fs2long$352 0177 GR + 7 A$_fs2long$353 0178 GR + 7 A$_fs2long$354 017A GR + 7 A$_fs2long$355 017C GR + 7 A$_fs2long$356 017D GR + 7 A$_fs2long$358 017F GR + 7 A$_fs2long$359 0182 GR + 7 A$_fs2long$360 0185 GR + 7 A$_fs2long$361 0187 GR + 7 A$_fs2long$362 0188 GR + 7 A$_fs2long$363 0189 GR + 7 A$_fs2long$364 018B GR + 7 A$_fs2long$365 018C GR + 7 A$_fs2long$366 018D GR + 7 A$_fs2long$367 018F GR + 7 A$_fs2long$368 0190 GR + 7 A$_fs2long$369 0191 GR + 7 A$_fs2long$370 0193 GR + 7 A$_fs2long$372 0194 GR + 7 A$_fs2long$378 0196 GR + 7 A$_fs2long$379 0197 GR + 7 A$_fs2long$380 0199 GR + 7 A$_fs2long$381 019B GR + 7 A$_fs2long$382 019D GR + 7 A$_fs2long$385 01A0 GR + 7 A$_fs2long$386 01A3 GR + 7 A$_fs2long$387 01A4 GR + 7 A$_fs2long$388 01A6 GR + 7 A$_fs2long$389 01A7 GR + 7 A$_fs2long$390 01A8 GR + 7 A$_fs2long$391 01AA GR + 7 A$_fs2long$392 01AB GR + 7 A$_fs2long$393 01AC GR + 7 A$_fs2long$394 01AE GR + 7 A$_fs2long$395 01AF GR + 7 A$_fs2long$397 01B0 GR + 7 A$_fs2long$398 01B2 GR + 7 A$_fs2long$399 01B3 GR + 7 A$_fs2long$401 01B5 GR + 7 A$_fs2long$403 01B6 GR + 7 A$_fs2long$405 01B8 GR + 7 A$_fs2long$406 01BB GR + 7 A$_fs2long$407 01BC GR + 7 A$_fs2long$408 01BE GR + 7 A$_fs2long$409 01BF GR + 7 A$_fs2long$410 01C0 GR + 7 A$_fs2long$411 01C2 GR + 7 A$_fs2long$412 01C3 GR + 7 A$_fs2long$413 01C4 GR + 7 A$_fs2long$414 01C6 GR + 7 A$_fs2long$415 01C7 GR + 7 A$_fs2long$416 01C8 GR + 7 A$_fs2long$417 01CA GR + 7 A$_fs2long$418 01CB GR + 7 A$_fs2long$419 01CC GR + 7 A$_fs2long$420 01CE GR + 7 A$_fs2long$421 01D0 GR + 7 A$_fs2long$422 01D1 GR + 7 A$_fs2long$423 01D3 GR + 7 A$_fs2long$424 01D5 GR + 7 A$_fs2long$425 01D6 GR + 7 A$_fs2long$426 01D8 GR + 7 A$_fs2long$427 01DA GR + 7 A$_fs2long$428 01DB GR + 7 A$_fs2long$429 01DD GR + 7 A$_fs2long$431 01DF GR + 7 A$_fs2long$433 01E1 GR + 7 A$_fs2long$434 01E4 GR + 7 A$_fs2long$435 01E5 GR + 7 A$_fs2long$436 01E7 GR + 7 A$_fs2long$437 01E8 GR + 7 A$_fs2long$438 01E9 GR + 7 A$_fs2long$439 01EB GR + 7 A$_fs2long$440 01EC GR + 7 A$_fs2long$441 01ED GR + 7 A$_fs2long$442 01EF GR + 7 A$_fs2long$443 01F0 GR + 7 A$_fs2long$444 01F1 GR + 7 A$_fs2long$446 01F3 GR + 7 A$_fs2long$447 01F6 GR + 7 A$_fs2long$448 01F9 GR + 7 A$_fs2long$449 01FC GR + 7 A$_fs2long$453 01FE GR + 7 A$_fs2long$72 0000 GR + 7 A$_fs2long$73 0002 GR + 7 A$_fs2long$74 0004 GR + 7 A$_fs2long$75 0006 GR + 7 A$_fs2long$76 0008 GR + 7 A$_fs2long$77 000B GR + 7 A$_fs2long$78 000D GR + 7 A$_fs2long$79 000E GR + 7 A$_fs2long$80 0010 GR + 7 A$_fs2long$81 0011 GR + 7 A$_fs2long$82 0012 GR + 7 A$_fs2long$83 0014 GR + 7 A$_fs2long$84 0015 GR + 7 A$_fs2long$85 0016 GR + 7 A$_fs2long$86 0018 GR + 7 A$_fs2long$87 0019 GR + 7 A$_fs2long$89 001A GR + 7 A$_fs2long$90 001D GR + 7 A$_fs2long$91 001E GR + 7 A$_fs2long$92 001F GR + 7 A$_fs2long$93 0020 GR + 7 A$_fs2long$94 0021 GR + 7 A$_fs2long$95 0022 GR + 7 A$_fs2long$96 0023 GR + 7 A$_fs2long$97 0024 GR + 7 A$_fs2long$98 0025 GR + 7 A$_fs2long$99 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fs2long.c$97$1$1 = 01FE GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fs2long$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fs2long$0$0 = 01FE GR + 7 ___fs2long 0000 GR + 5 ___fs2long_a1_1_1 0000 R + 5 ___fs2long_exp_1_1 0008 R + 5 ___fs2long_fl1_1_1 0004 R + 5 ___fs2long_l_1_1 000A R + 1 ___fs2long_sloc0_1_0 0000 R + 1 ___fs2long_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 1FF flags 20 diff --git a/device/lib/_fs2uchar.c b/device/lib/_fs2uchar.c new file mode 100644 index 00000000..6c669ad2 --- /dev/null +++ b/device/lib/_fs2uchar.c @@ -0,0 +1,97 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int)0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* convert double to int */ +unsigned char +__fs2uchar (float a1) +{ + volatile union float_long fl1; + volatile int exp; + volatile long l; + + fl1.f = a1; + + if (!fl1.l) + return (0); + + exp = EXP (fl1.l) - EXCESS - 24; + l = MANT (fl1.l); + + if (exp > 0) + return (0x7F | SIGN(fl1.l)); /* largest integer */ + + /* shift down until exp = 0 or l = 0 */ + if (exp < 0 && exp > -25 && l) + l >>= -exp; + else + return (0); + + return (SIGN(fl1.l) ? -(unsigned char)l : (unsigned char)l); +} diff --git a/device/lib/_fs2uchar.lst b/device/lib/_fs2uchar.lst new file mode 100644 index 00000000..8d4b4447 --- /dev/null +++ b/device/lib/_fs2uchar.lst @@ -0,0 +1,422 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fs2uchar + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fs2uchar + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___fs2uchar_sloc0_1_0: + 0000 22 .ds 0x0004 + 0004 23 ___fs2uchar_sloc1_1_0: + 0004 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___fs2uchar_a1_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___fs2uchar_fl1_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___fs2uchar_exp_1_1: + 0008 46 .ds 0x0002 + 000A 47 ___fs2uchar_l_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__fs2uchar$0$0 ==. + 58 ; _fs2uchar.c 73 + 59 ; ----------------------------------------- + 60 ; function __fs2uchar + 61 ; ----------------------------------------- + 0000 62 ___fs2uchar: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _fs2uchar.c 0 + 0000 C0 E0 72 push acc + 0002 C0 F0 73 push b + 0004 C0 83 74 push dph + 0006 C0 82 75 push dpl + 0008 90s00r00 76 mov dptr,#___fs2uchar_a1_1_1 + 000B D0 E0 77 pop acc + 000D F0 78 movx @dptr,a + 000E D0 E0 79 pop acc + 0010 A3 80 inc dptr + 0011 F0 81 movx @dptr,a + 0012 D0 E0 82 pop acc + 0014 A3 83 inc dptr + 0015 F0 84 movx @dptr,a + 0016 D0 E0 85 pop acc + 0018 A3 86 inc dptr + 0019 F0 87 movx @dptr,a + 88 ; _fs2uchar.c 79 + 001A 90s00r00 89 mov dptr,#___fs2uchar_a1_1_1 + 001D E0 90 movx a,@dptr + 001E FA 91 mov r2,a + 001F A3 92 inc dptr + 0020 E0 93 movx a,@dptr + 0021 FB 94 mov r3,a + 0022 A3 95 inc dptr + 0023 E0 96 movx a,@dptr + 0024 FC 97 mov r4,a + 0025 A3 98 inc dptr + 0026 E0 99 movx a,@dptr + 0027 FD 100 mov r5,a + 0028 90s00r04 101 mov dptr,#(___fs2uchar_fl1_1_1) + 002B EA 102 mov a,r2 + 002C F0 103 movx @dptr,a + 002D A3 104 inc dptr + 002E EB 105 mov a,r3 + 002F F0 106 movx @dptr,a + 0030 A3 107 inc dptr + 0031 EC 108 mov a,r4 + 0032 F0 109 movx @dptr,a + 0033 A3 110 inc dptr + 0034 ED 111 mov a,r5 + 0035 F0 112 movx @dptr,a + 113 ; _fs2uchar.c 81 + 0036 90s00r04 114 mov dptr,#(___fs2uchar_fl1_1_1) + 0039 E0 115 movx a,@dptr + 003A FA 116 mov r2,a + 003B A3 117 inc dptr + 003C E0 118 movx a,@dptr + 003D FB 119 mov r3,a + 003E A3 120 inc dptr + 003F E0 121 movx a,@dptr + 0040 FC 122 mov r4,a + 0041 A3 123 inc dptr + 0042 E0 124 movx a,@dptr + 0043 FD 125 mov r5,a + 0044 EA 126 mov a,r2 + 0045 4B 127 orl a,r3 + 0046 4C 128 orl a,r4 + 0047 4D 129 orl a,r5 + 130 ; Peephole 109 removed ljmp by inverse jump logic + 0048 70 06 131 jnz 00102$ + 004A 132 00120$: + 133 ; _fs2uchar.c 82 + 004A 75 82 00 134 mov dpl,#0x00 + 004D 02s01rD0 135 ljmp 00110$ + 0050 136 00102$: + 137 ; _fs2uchar.c 84 + 0050 90s00r04 138 mov dptr,#(___fs2uchar_fl1_1_1) + 0053 E0 139 movx a,@dptr + 0054 FA 140 mov r2,a + 0055 A3 141 inc dptr + 0056 E0 142 movx a,@dptr + 0057 FB 143 mov r3,a + 0058 A3 144 inc dptr + 0059 E0 145 movx a,@dptr + 005A FC 146 mov r4,a + 005B A3 147 inc dptr + 005C E0 148 movx a,@dptr + 005D FD 149 mov r5,a + 005E 8C 02 150 mov ar2,r4 + 0060 ED 151 mov a,r5 + 0061 A2 E7 152 mov c,acc.7 + 0063 CA 153 xch a,r2 + 0064 33 154 rlc a + 0065 CA 155 xch a,r2 + 0066 33 156 rlc a + 0067 CA 157 xch a,r2 + 0068 54 01 158 anl a,#0x01 + 006A 30 E0 02 159 jnb acc.0,00121$ + 006D 44 FE 160 orl a,#0xfe + 006F 161 00121$: + 006F FB 162 mov r3,a + 0070 33 163 rlc a + 0071 95 E0 164 subb a,acc + 0073 FC 165 mov r4,a + 0074 FD 166 mov r5,a + 0075 EA 167 mov a,r2 + 0076 75 F0 00 168 mov b,#0x00 + 0079 24 6A 169 add a,#0x6a + 007B FA 170 mov r2,a + 007C E5 F0 171 mov a,b + 007E 34 FF 172 addc a,#0xff + 0080 FB 173 mov r3,a + 0081 90s00r08 174 mov dptr,#___fs2uchar_exp_1_1 + 0084 EA 175 mov a,r2 + 0085 F0 176 movx @dptr,a + 0086 A3 177 inc dptr + 0087 EB 178 mov a,r3 + 0088 F0 179 movx @dptr,a + 180 ; _fs2uchar.c 85 + 0089 90s00r04 181 mov dptr,#(___fs2uchar_fl1_1_1) + 008C E0 182 movx a,@dptr + 008D FA 183 mov r2,a + 008E A3 184 inc dptr + 008F E0 185 movx a,@dptr + 0090 FB 186 mov r3,a + 0091 A3 187 inc dptr + 0092 E0 188 movx a,@dptr + 0093 FE 189 mov r6,a + 0094 A3 190 inc dptr + 0095 E0 191 movx a,@dptr + 0096 FF 192 mov r7,a + 0097 53 06 7F 193 anl ar6,#0x7f + 009A 7F 00 194 mov r7,#0x00 + 009C 90s00r0A 195 mov dptr,#___fs2uchar_l_1_1 + 009F EA 196 mov a,r2 + 00A0 F0 197 movx @dptr,a + 00A1 A3 198 inc dptr + 00A2 EB 199 mov a,r3 + 00A3 F0 200 movx @dptr,a + 00A4 74 80 201 mov a,#0x80 + 00A6 4E 202 orl a,r6 + 00A7 A3 203 inc dptr + 00A8 F0 204 movx @dptr,a + 00A9 A3 205 inc dptr + 00AA EF 206 mov a,r7 + 00AB F0 207 movx @dptr,a + 208 ; _fs2uchar.c 87 + 00AC 90s00r08 209 mov dptr,#___fs2uchar_exp_1_1 + 00AF E0 210 movx a,@dptr + 00B0 FA 211 mov r2,a + 00B1 A3 212 inc dptr + 00B2 E0 213 movx a,@dptr + 00B3 FB 214 mov r3,a + 00B4 C3 215 clr c + 216 ; Peephole 180 changed mov to clr + 00B5 E4 217 clr a + 00B6 9A 218 subb a,r2 + 219 ; Peephole 159 avoided xrl during execution + 00B7 74 80 220 mov a,#(0x00 ^ 0x80) + 00B9 8B F0 221 mov b,r3 + 00BB 63 F0 80 222 xrl b,#0x80 + 00BE 95 F0 223 subb a,b + 224 ; Peephole 108 removed ljmp by inverse jump logic + 00C0 50 1A 225 jnc 00104$ + 00C2 226 00122$: + 227 ; _fs2uchar.c 88 + 00C2 90s00r04 228 mov dptr,#(___fs2uchar_fl1_1_1) + 00C5 E0 229 movx a,@dptr + 00C6 FA 230 mov r2,a + 00C7 A3 231 inc dptr + 00C8 E0 232 movx a,@dptr + 00C9 FB 233 mov r3,a + 00CA A3 234 inc dptr + 00CB E0 235 movx a,@dptr + 00CC FE 236 mov r6,a + 00CD A3 237 inc dptr + 00CE E0 238 movx a,@dptr + 239 ; Peephole 105 removed redundant mov + 00CF FF 240 mov r7,a + 00D0 23 241 rl a + 00D1 54 01 242 anl a,#0x01 + 00D3 FA 243 mov r2,a + 00D4 43 02 7F 244 orl ar2,#0x7f + 00D7 8A 82 245 mov dpl,r2 + 00D9 02s01rD0 246 ljmp 00110$ + 00DC 247 00104$: + 248 ; _fs2uchar.c 91 + 00DC 90s00r08 249 mov dptr,#___fs2uchar_exp_1_1 + 00DF E0 250 movx a,@dptr + 00E0 FA 251 mov r2,a + 00E1 A3 252 inc dptr + 00E2 E0 253 movx a,@dptr + 254 ; Peephole 105 removed redundant mov + 00E3 F8 255 mov r0,a + 00E4 20 E7 03 256 jb acc.7,00123$ + 00E7 02s01r7F 257 ljmp 00106$ + 00EA 258 00123$: + 00EA 90s00r08 259 mov dptr,#___fs2uchar_exp_1_1 + 00ED E0 260 movx a,@dptr + 00EE FA 261 mov r2,a + 00EF A3 262 inc dptr + 00F0 E0 263 movx a,@dptr + 00F1 F8 264 mov r0,a + 00F2 C3 265 clr c + 00F3 74 E7 266 mov a,#0xe7 + 00F5 9A 267 subb a,r2 + 268 ; Peephole 159 avoided xrl during execution + 00F6 74 7F 269 mov a,#(0xff ^ 0x80) + 00F8 88 F0 270 mov b,r0 + 00FA 63 F0 80 271 xrl b,#0x80 + 00FD 95 F0 272 subb a,b + 00FF 40 03 273 jc 00124$ + 0101 02s01r7F 274 ljmp 00106$ + 0104 275 00124$: + 0104 90s00r0A 276 mov dptr,#___fs2uchar_l_1_1 + 0107 E0 277 movx a,@dptr + 0108 F5*00 278 mov ___fs2uchar_sloc0_1_0,a + 010A A3 279 inc dptr + 010B E0 280 movx a,@dptr + 010C F5*01 281 mov (___fs2uchar_sloc0_1_0 + 1),a + 010E A3 282 inc dptr + 010F E0 283 movx a,@dptr + 0110 F5*02 284 mov (___fs2uchar_sloc0_1_0 + 2),a + 0112 A3 285 inc dptr + 0113 E0 286 movx a,@dptr + 0114 F5*03 287 mov (___fs2uchar_sloc0_1_0 + 3),a + 0116 E5*00 288 mov a,___fs2uchar_sloc0_1_0 + 0118 45*01 289 orl a,(___fs2uchar_sloc0_1_0 + 1) + 011A 45*02 290 orl a,(___fs2uchar_sloc0_1_0 + 2) + 011C 45*03 291 orl a,(___fs2uchar_sloc0_1_0 + 3) + 011E 70 03 292 jnz 00125$ + 0120 02s01r7F 293 ljmp 00106$ + 0123 294 00125$: + 295 ; _fs2uchar.c 92 + 0123 90s00r08 296 mov dptr,#___fs2uchar_exp_1_1 + 0126 E0 297 movx a,@dptr + 0127 FA 298 mov r2,a + 0128 A3 299 inc dptr + 0129 E0 300 movx a,@dptr + 012A F8 301 mov r0,a + 012B C3 302 clr c + 012C E4 303 clr a + 012D 9A 304 subb a,r2 + 012E F5*00 305 mov ___fs2uchar_sloc0_1_0,a + 0130 E4 306 clr a + 0131 98 307 subb a,r0 + 0132 F5*01 308 mov (___fs2uchar_sloc0_1_0 + 1),a + 0134 90s00r0A 309 mov dptr,#___fs2uchar_l_1_1 + 0137 E0 310 movx a,@dptr + 0138 F5*04 311 mov ___fs2uchar_sloc1_1_0,a + 013A A3 312 inc dptr + 013B E0 313 movx a,@dptr + 013C F5*05 314 mov (___fs2uchar_sloc1_1_0 + 1),a + 013E A3 315 inc dptr + 013F E0 316 movx a,@dptr + 0140 F5*06 317 mov (___fs2uchar_sloc1_1_0 + 2),a + 0142 A3 318 inc dptr + 0143 E0 319 movx a,@dptr + 0144 F5*07 320 mov (___fs2uchar_sloc1_1_0 + 3),a + 0146 85*00 F0 321 mov b,___fs2uchar_sloc0_1_0 + 0149 05 F0 322 inc b + 014B E5*07 323 mov a,(___fs2uchar_sloc1_1_0 + 3) + 014D 33 324 rlc a + 014E 92 D2 325 mov ov,c + 0150 80 16 326 sjmp 00127$ + 0152 327 00126$: + 0152 A2 D2 328 mov c,ov + 0154 E5*07 329 mov a,(___fs2uchar_sloc1_1_0 + 3) + 0156 13 330 rrc a + 0157 F5*07 331 mov (___fs2uchar_sloc1_1_0 + 3),a + 0159 E5*06 332 mov a,(___fs2uchar_sloc1_1_0 + 2) + 015B 13 333 rrc a + 015C F5*06 334 mov (___fs2uchar_sloc1_1_0 + 2),a + 015E E5*05 335 mov a,(___fs2uchar_sloc1_1_0 + 1) + 0160 13 336 rrc a + 0161 F5*05 337 mov (___fs2uchar_sloc1_1_0 + 1),a + 0163 E5*04 338 mov a,___fs2uchar_sloc1_1_0 + 0165 13 339 rrc a + 0166 F5*04 340 mov ___fs2uchar_sloc1_1_0,a + 0168 341 00127$: + 0168 D5 F0 E7 342 djnz b,00126$ + 016B 90s00r0A 343 mov dptr,#___fs2uchar_l_1_1 + 016E E5*04 344 mov a,___fs2uchar_sloc1_1_0 + 0170 F0 345 movx @dptr,a + 0171 A3 346 inc dptr + 0172 E5*05 347 mov a,(___fs2uchar_sloc1_1_0 + 1) + 0174 F0 348 movx @dptr,a + 0175 A3 349 inc dptr + 0176 E5*06 350 mov a,(___fs2uchar_sloc1_1_0 + 2) + 0178 F0 351 movx @dptr,a + 0179 A3 352 inc dptr + 017A E5*07 353 mov a,(___fs2uchar_sloc1_1_0 + 3) + 017C F0 354 movx @dptr,a + 355 ; Peephole 132 changed ljmp to sjmp + 017D 80 06 356 sjmp 00107$ + 017F 357 00106$: + 358 ; _fs2uchar.c 94 + 017F 75 82 00 359 mov dpl,#0x00 + 0182 02s01rD0 360 ljmp 00110$ + 0185 361 00107$: + 362 ; _fs2uchar.c 96 + 0185 90s00r04 363 mov dptr,#(___fs2uchar_fl1_1_1) + 0188 E0 364 movx a,@dptr + 0189 F5*04 365 mov ___fs2uchar_sloc1_1_0,a + 018B A3 366 inc dptr + 018C E0 367 movx a,@dptr + 018D F5*05 368 mov (___fs2uchar_sloc1_1_0 + 1),a + 018F A3 369 inc dptr + 0190 E0 370 movx a,@dptr + 0191 F5*06 371 mov (___fs2uchar_sloc1_1_0 + 2),a + 0193 A3 372 inc dptr + 0194 E0 373 movx a,@dptr + 374 ; Peephole 105 removed redundant mov + 0195 F5*07 375 mov (___fs2uchar_sloc1_1_0 + 3),a + 0197 23 376 rl a + 0198 54 01 377 anl a,#0x01 + 378 ; Peephole 105 removed redundant mov + 019A FA 379 mov r2,a + 380 ; Peephole 110 removed ljmp by inverse jump logic + 019B 60 1B 381 jz 00112$ + 019D 382 00128$: + 019D 90s00r0A 383 mov dptr,#___fs2uchar_l_1_1 + 01A0 E0 384 movx a,@dptr + 01A1 F5*04 385 mov ___fs2uchar_sloc1_1_0,a + 01A3 A3 386 inc dptr + 01A4 E0 387 movx a,@dptr + 01A5 F5*05 388 mov (___fs2uchar_sloc1_1_0 + 1),a + 01A7 A3 389 inc dptr + 01A8 E0 390 movx a,@dptr + 01A9 F5*06 391 mov (___fs2uchar_sloc1_1_0 + 2),a + 01AB A3 392 inc dptr + 01AC E0 393 movx a,@dptr + 01AD F5*07 394 mov (___fs2uchar_sloc1_1_0 + 3),a + 01AF AA*04 395 mov r2,___fs2uchar_sloc1_1_0 + 01B1 C3 396 clr c + 01B2 E4 397 clr a + 01B3 9A 398 subb a,r2 + 01B4 F5*04 399 mov ___fs2uchar_sloc1_1_0,a + 400 ; Peephole 132 changed ljmp to sjmp + 01B6 80 15 401 sjmp 00113$ + 01B8 402 00112$: + 01B8 90s00r0A 403 mov dptr,#___fs2uchar_l_1_1 + 01BB E0 404 movx a,@dptr + 01BC F5*00 405 mov ___fs2uchar_sloc0_1_0,a + 01BE A3 406 inc dptr + 01BF E0 407 movx a,@dptr + 01C0 F5*01 408 mov (___fs2uchar_sloc0_1_0 + 1),a + 01C2 A3 409 inc dptr + 01C3 E0 410 movx a,@dptr + 01C4 F5*02 411 mov (___fs2uchar_sloc0_1_0 + 2),a + 01C6 A3 412 inc dptr + 01C7 E0 413 movx a,@dptr + 01C8 F5*03 414 mov (___fs2uchar_sloc0_1_0 + 3),a + 01CA 85*00*04 415 mov ___fs2uchar_sloc1_1_0,___fs2uchar_sloc0_1_0 + 01CD 416 00113$: + 01CD 85*04 82 417 mov dpl,___fs2uchar_sloc1_1_0 + 01D0 418 00110$: + 01D0 419 C$_fs2uchar.c$97$1$1 ==. + 01D0 420 XG$__fs2uchar$0$0 ==. + 01D0 22 421 ret + 422 .area CSEG (CODE) diff --git a/device/lib/_fs2uchar.sym b/device/lib/_fs2uchar.sym new file mode 100644 index 00000000..b7eba593 --- /dev/null +++ b/device/lib/_fs2uchar.sym @@ -0,0 +1,680 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fs2uchar$100 0027 GR + 7 A$_fs2uchar$101 0028 GR + 7 A$_fs2uchar$102 002B GR + 7 A$_fs2uchar$103 002C GR + 7 A$_fs2uchar$104 002D GR + 7 A$_fs2uchar$105 002E GR + 7 A$_fs2uchar$106 002F GR + 7 A$_fs2uchar$107 0030 GR + 7 A$_fs2uchar$108 0031 GR + 7 A$_fs2uchar$109 0032 GR + 7 A$_fs2uchar$110 0033 GR + 7 A$_fs2uchar$111 0034 GR + 7 A$_fs2uchar$112 0035 GR + 7 A$_fs2uchar$114 0036 GR + 7 A$_fs2uchar$115 0039 GR + 7 A$_fs2uchar$116 003A GR + 7 A$_fs2uchar$117 003B GR + 7 A$_fs2uchar$118 003C GR + 7 A$_fs2uchar$119 003D GR + 7 A$_fs2uchar$120 003E GR + 7 A$_fs2uchar$121 003F GR + 7 A$_fs2uchar$122 0040 GR + 7 A$_fs2uchar$123 0041 GR + 7 A$_fs2uchar$124 0042 GR + 7 A$_fs2uchar$125 0043 GR + 7 A$_fs2uchar$126 0044 GR + 7 A$_fs2uchar$127 0045 GR + 7 A$_fs2uchar$128 0046 GR + 7 A$_fs2uchar$129 0047 GR + 7 A$_fs2uchar$131 0048 GR + 7 A$_fs2uchar$134 004A GR + 7 A$_fs2uchar$135 004D GR + 7 A$_fs2uchar$138 0050 GR + 7 A$_fs2uchar$139 0053 GR + 7 A$_fs2uchar$140 0054 GR + 7 A$_fs2uchar$141 0055 GR + 7 A$_fs2uchar$142 0056 GR + 7 A$_fs2uchar$143 0057 GR + 7 A$_fs2uchar$144 0058 GR + 7 A$_fs2uchar$145 0059 GR + 7 A$_fs2uchar$146 005A GR + 7 A$_fs2uchar$147 005B GR + 7 A$_fs2uchar$148 005C GR + 7 A$_fs2uchar$149 005D GR + 7 A$_fs2uchar$150 005E GR + 7 A$_fs2uchar$151 0060 GR + 7 A$_fs2uchar$152 0061 GR + 7 A$_fs2uchar$153 0063 GR + 7 A$_fs2uchar$154 0064 GR + 7 A$_fs2uchar$155 0065 GR + 7 A$_fs2uchar$156 0066 GR + 7 A$_fs2uchar$157 0067 GR + 7 A$_fs2uchar$158 0068 GR + 7 A$_fs2uchar$159 006A GR + 7 A$_fs2uchar$160 006D GR + 7 A$_fs2uchar$162 006F GR + 7 A$_fs2uchar$163 0070 GR + 7 A$_fs2uchar$164 0071 GR + 7 A$_fs2uchar$165 0073 GR + 7 A$_fs2uchar$166 0074 GR + 7 A$_fs2uchar$167 0075 GR + 7 A$_fs2uchar$168 0076 GR + 7 A$_fs2uchar$169 0079 GR + 7 A$_fs2uchar$170 007B GR + 7 A$_fs2uchar$171 007C GR + 7 A$_fs2uchar$172 007E GR + 7 A$_fs2uchar$173 0080 GR + 7 A$_fs2uchar$174 0081 GR + 7 A$_fs2uchar$175 0084 GR + 7 A$_fs2uchar$176 0085 GR + 7 A$_fs2uchar$177 0086 GR + 7 A$_fs2uchar$178 0087 GR + 7 A$_fs2uchar$179 0088 GR + 7 A$_fs2uchar$181 0089 GR + 7 A$_fs2uchar$182 008C GR + 7 A$_fs2uchar$183 008D GR + 7 A$_fs2uchar$184 008E GR + 7 A$_fs2uchar$185 008F GR + 7 A$_fs2uchar$186 0090 GR + 7 A$_fs2uchar$187 0091 GR + 7 A$_fs2uchar$188 0092 GR + 7 A$_fs2uchar$189 0093 GR + 7 A$_fs2uchar$190 0094 GR + 7 A$_fs2uchar$191 0095 GR + 7 A$_fs2uchar$192 0096 GR + 7 A$_fs2uchar$193 0097 GR + 7 A$_fs2uchar$194 009A GR + 7 A$_fs2uchar$195 009C GR + 7 A$_fs2uchar$196 009F GR + 7 A$_fs2uchar$197 00A0 GR + 7 A$_fs2uchar$198 00A1 GR + 7 A$_fs2uchar$199 00A2 GR + 7 A$_fs2uchar$200 00A3 GR + 7 A$_fs2uchar$201 00A4 GR + 7 A$_fs2uchar$202 00A6 GR + 7 A$_fs2uchar$203 00A7 GR + 7 A$_fs2uchar$204 00A8 GR + 7 A$_fs2uchar$205 00A9 GR + 7 A$_fs2uchar$206 00AA GR + 7 A$_fs2uchar$207 00AB GR + 7 A$_fs2uchar$209 00AC GR + 7 A$_fs2uchar$210 00AF GR + 7 A$_fs2uchar$211 00B0 GR + 7 A$_fs2uchar$212 00B1 GR + 7 A$_fs2uchar$213 00B2 GR + 7 A$_fs2uchar$214 00B3 GR + 7 A$_fs2uchar$215 00B4 GR + 7 A$_fs2uchar$217 00B5 GR + 7 A$_fs2uchar$218 00B6 GR + 7 A$_fs2uchar$220 00B7 GR + 7 A$_fs2uchar$221 00B9 GR + 7 A$_fs2uchar$222 00BB GR + 7 A$_fs2uchar$223 00BE GR + 7 A$_fs2uchar$225 00C0 GR + 7 A$_fs2uchar$228 00C2 GR + 7 A$_fs2uchar$229 00C5 GR + 7 A$_fs2uchar$230 00C6 GR + 7 A$_fs2uchar$231 00C7 GR + 7 A$_fs2uchar$232 00C8 GR + 7 A$_fs2uchar$233 00C9 GR + 7 A$_fs2uchar$234 00CA GR + 7 A$_fs2uchar$235 00CB GR + 7 A$_fs2uchar$236 00CC GR + 7 A$_fs2uchar$237 00CD GR + 7 A$_fs2uchar$238 00CE GR + 7 A$_fs2uchar$240 00CF GR + 7 A$_fs2uchar$241 00D0 GR + 7 A$_fs2uchar$242 00D1 GR + 7 A$_fs2uchar$243 00D3 GR + 7 A$_fs2uchar$244 00D4 GR + 7 A$_fs2uchar$245 00D7 GR + 7 A$_fs2uchar$246 00D9 GR + 7 A$_fs2uchar$249 00DC GR + 7 A$_fs2uchar$250 00DF GR + 7 A$_fs2uchar$251 00E0 GR + 7 A$_fs2uchar$252 00E1 GR + 7 A$_fs2uchar$253 00E2 GR + 7 A$_fs2uchar$255 00E3 GR + 7 A$_fs2uchar$256 00E4 GR + 7 A$_fs2uchar$257 00E7 GR + 7 A$_fs2uchar$259 00EA GR + 7 A$_fs2uchar$260 00ED GR + 7 A$_fs2uchar$261 00EE GR + 7 A$_fs2uchar$262 00EF GR + 7 A$_fs2uchar$263 00F0 GR + 7 A$_fs2uchar$264 00F1 GR + 7 A$_fs2uchar$265 00F2 GR + 7 A$_fs2uchar$266 00F3 GR + 7 A$_fs2uchar$267 00F5 GR + 7 A$_fs2uchar$269 00F6 GR + 7 A$_fs2uchar$270 00F8 GR + 7 A$_fs2uchar$271 00FA GR + 7 A$_fs2uchar$272 00FD GR + 7 A$_fs2uchar$273 00FF GR + 7 A$_fs2uchar$274 0101 GR + 7 A$_fs2uchar$276 0104 GR + 7 A$_fs2uchar$277 0107 GR + 7 A$_fs2uchar$278 0108 GR + 7 A$_fs2uchar$279 010A GR + 7 A$_fs2uchar$280 010B GR + 7 A$_fs2uchar$281 010C GR + 7 A$_fs2uchar$282 010E GR + 7 A$_fs2uchar$283 010F GR + 7 A$_fs2uchar$284 0110 GR + 7 A$_fs2uchar$285 0112 GR + 7 A$_fs2uchar$286 0113 GR + 7 A$_fs2uchar$287 0114 GR + 7 A$_fs2uchar$288 0116 GR + 7 A$_fs2uchar$289 0118 GR + 7 A$_fs2uchar$290 011A GR + 7 A$_fs2uchar$291 011C GR + 7 A$_fs2uchar$292 011E GR + 7 A$_fs2uchar$293 0120 GR + 7 A$_fs2uchar$296 0123 GR + 7 A$_fs2uchar$297 0126 GR + 7 A$_fs2uchar$298 0127 GR + 7 A$_fs2uchar$299 0128 GR + 7 A$_fs2uchar$300 0129 GR + 7 A$_fs2uchar$301 012A GR + 7 A$_fs2uchar$302 012B GR + 7 A$_fs2uchar$303 012C GR + 7 A$_fs2uchar$304 012D GR + 7 A$_fs2uchar$305 012E GR + 7 A$_fs2uchar$306 0130 GR + 7 A$_fs2uchar$307 0131 GR + 7 A$_fs2uchar$308 0132 GR + 7 A$_fs2uchar$309 0134 GR + 7 A$_fs2uchar$310 0137 GR + 7 A$_fs2uchar$311 0138 GR + 7 A$_fs2uchar$312 013A GR + 7 A$_fs2uchar$313 013B GR + 7 A$_fs2uchar$314 013C GR + 7 A$_fs2uchar$315 013E GR + 7 A$_fs2uchar$316 013F GR + 7 A$_fs2uchar$317 0140 GR + 7 A$_fs2uchar$318 0142 GR + 7 A$_fs2uchar$319 0143 GR + 7 A$_fs2uchar$320 0144 GR + 7 A$_fs2uchar$321 0146 GR + 7 A$_fs2uchar$322 0149 GR + 7 A$_fs2uchar$323 014B GR + 7 A$_fs2uchar$324 014D GR + 7 A$_fs2uchar$325 014E GR + 7 A$_fs2uchar$326 0150 GR + 7 A$_fs2uchar$328 0152 GR + 7 A$_fs2uchar$329 0154 GR + 7 A$_fs2uchar$330 0156 GR + 7 A$_fs2uchar$331 0157 GR + 7 A$_fs2uchar$332 0159 GR + 7 A$_fs2uchar$333 015B GR + 7 A$_fs2uchar$334 015C GR + 7 A$_fs2uchar$335 015E GR + 7 A$_fs2uchar$336 0160 GR + 7 A$_fs2uchar$337 0161 GR + 7 A$_fs2uchar$338 0163 GR + 7 A$_fs2uchar$339 0165 GR + 7 A$_fs2uchar$340 0166 GR + 7 A$_fs2uchar$342 0168 GR + 7 A$_fs2uchar$343 016B GR + 7 A$_fs2uchar$344 016E GR + 7 A$_fs2uchar$345 0170 GR + 7 A$_fs2uchar$346 0171 GR + 7 A$_fs2uchar$347 0172 GR + 7 A$_fs2uchar$348 0174 GR + 7 A$_fs2uchar$349 0175 GR + 7 A$_fs2uchar$350 0176 GR + 7 A$_fs2uchar$351 0178 GR + 7 A$_fs2uchar$352 0179 GR + 7 A$_fs2uchar$353 017A GR + 7 A$_fs2uchar$354 017C GR + 7 A$_fs2uchar$356 017D GR + 7 A$_fs2uchar$359 017F GR + 7 A$_fs2uchar$360 0182 GR + 7 A$_fs2uchar$363 0185 GR + 7 A$_fs2uchar$364 0188 GR + 7 A$_fs2uchar$365 0189 GR + 7 A$_fs2uchar$366 018B GR + 7 A$_fs2uchar$367 018C GR + 7 A$_fs2uchar$368 018D GR + 7 A$_fs2uchar$369 018F GR + 7 A$_fs2uchar$370 0190 GR + 7 A$_fs2uchar$371 0191 GR + 7 A$_fs2uchar$372 0193 GR + 7 A$_fs2uchar$373 0194 GR + 7 A$_fs2uchar$375 0195 GR + 7 A$_fs2uchar$376 0197 GR + 7 A$_fs2uchar$377 0198 GR + 7 A$_fs2uchar$379 019A GR + 7 A$_fs2uchar$381 019B GR + 7 A$_fs2uchar$383 019D GR + 7 A$_fs2uchar$384 01A0 GR + 7 A$_fs2uchar$385 01A1 GR + 7 A$_fs2uchar$386 01A3 GR + 7 A$_fs2uchar$387 01A4 GR + 7 A$_fs2uchar$388 01A5 GR + 7 A$_fs2uchar$389 01A7 GR + 7 A$_fs2uchar$390 01A8 GR + 7 A$_fs2uchar$391 01A9 GR + 7 A$_fs2uchar$392 01AB GR + 7 A$_fs2uchar$393 01AC GR + 7 A$_fs2uchar$394 01AD GR + 7 A$_fs2uchar$395 01AF GR + 7 A$_fs2uchar$396 01B1 GR + 7 A$_fs2uchar$397 01B2 GR + 7 A$_fs2uchar$398 01B3 GR + 7 A$_fs2uchar$399 01B4 GR + 7 A$_fs2uchar$401 01B6 GR + 7 A$_fs2uchar$403 01B8 GR + 7 A$_fs2uchar$404 01BB GR + 7 A$_fs2uchar$405 01BC GR + 7 A$_fs2uchar$406 01BE GR + 7 A$_fs2uchar$407 01BF GR + 7 A$_fs2uchar$408 01C0 GR + 7 A$_fs2uchar$409 01C2 GR + 7 A$_fs2uchar$410 01C3 GR + 7 A$_fs2uchar$411 01C4 GR + 7 A$_fs2uchar$412 01C6 GR + 7 A$_fs2uchar$413 01C7 GR + 7 A$_fs2uchar$414 01C8 GR + 7 A$_fs2uchar$415 01CA GR + 7 A$_fs2uchar$417 01CD GR + 7 A$_fs2uchar$421 01D0 GR + 7 A$_fs2uchar$72 0000 GR + 7 A$_fs2uchar$73 0002 GR + 7 A$_fs2uchar$74 0004 GR + 7 A$_fs2uchar$75 0006 GR + 7 A$_fs2uchar$76 0008 GR + 7 A$_fs2uchar$77 000B GR + 7 A$_fs2uchar$78 000D GR + 7 A$_fs2uchar$79 000E GR + 7 A$_fs2uchar$80 0010 GR + 7 A$_fs2uchar$81 0011 GR + 7 A$_fs2uchar$82 0012 GR + 7 A$_fs2uchar$83 0014 GR + 7 A$_fs2uchar$84 0015 GR + 7 A$_fs2uchar$85 0016 GR + 7 A$_fs2uchar$86 0018 GR + 7 A$_fs2uchar$87 0019 GR + 7 A$_fs2uchar$89 001A GR + 7 A$_fs2uchar$90 001D GR + 7 A$_fs2uchar$91 001E GR + 7 A$_fs2uchar$92 001F GR + 7 A$_fs2uchar$93 0020 GR + 7 A$_fs2uchar$94 0021 GR + 7 A$_fs2uchar$95 0022 GR + 7 A$_fs2uchar$96 0023 GR + 7 A$_fs2uchar$97 0024 GR + 7 A$_fs2uchar$98 0025 GR + 7 A$_fs2uchar$99 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fs2uchar.c$97$1$1 = 01D0 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fs2uchar$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fs2uchar$0$0 = 01D0 GR + 7 ___fs2uchar 0000 GR + 5 ___fs2uchar_a1_1_1 0000 R + 5 ___fs2uchar_exp_1_1 0008 R + 5 ___fs2uchar_fl1_1_1 0004 R + 5 ___fs2uchar_l_1_1 000A R + 1 ___fs2uchar_sloc0_1_0 0000 R + 1 ___fs2uchar_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 1D1 flags 20 diff --git a/device/lib/_fs2uint.c b/device/lib/_fs2uint.c new file mode 100644 index 00000000..b49df3f4 --- /dev/null +++ b/device/lib/_fs2uint.c @@ -0,0 +1,97 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* convert double to int */ +unsigned int +__fs2uint (float a1) +{ + volatile union float_long fl1; + volatile int exp; + volatile long l; + + fl1.f = a1; + + if (!fl1.l) + return (0); + + exp = EXP (fl1.l) - EXCESS - 24; + l = MANT (fl1.l); + + if (exp > 0) + return (0x7F | SIGN(fl1.l)); /* largest integer */ + + /* shift down until exp = 0 or l = 0 */ + if (exp < 0 && exp > -25 && l) + l >>= -exp; + else + return (0); + + return (SIGN(fl1.l) ? -l : l); +} diff --git a/device/lib/_fs2uint.lst b/device/lib/_fs2uint.lst new file mode 100644 index 00000000..c41a9550 --- /dev/null +++ b/device/lib/_fs2uint.lst @@ -0,0 +1,436 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fs2uint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fs2uint + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___fs2uint_sloc0_1_0: + 0000 22 .ds 0x0004 + 0004 23 ___fs2uint_sloc1_1_0: + 0004 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___fs2uint_a1_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___fs2uint_fl1_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___fs2uint_exp_1_1: + 0008 46 .ds 0x0002 + 000A 47 ___fs2uint_l_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__fs2uint$0$0 ==. + 58 ; _fs2uint.c 73 + 59 ; ----------------------------------------- + 60 ; function __fs2uint + 61 ; ----------------------------------------- + 0000 62 ___fs2uint: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _fs2uint.c 0 + 0000 C0 E0 72 push acc + 0002 C0 F0 73 push b + 0004 C0 83 74 push dph + 0006 C0 82 75 push dpl + 0008 90s00r00 76 mov dptr,#___fs2uint_a1_1_1 + 000B D0 E0 77 pop acc + 000D F0 78 movx @dptr,a + 000E D0 E0 79 pop acc + 0010 A3 80 inc dptr + 0011 F0 81 movx @dptr,a + 0012 D0 E0 82 pop acc + 0014 A3 83 inc dptr + 0015 F0 84 movx @dptr,a + 0016 D0 E0 85 pop acc + 0018 A3 86 inc dptr + 0019 F0 87 movx @dptr,a + 88 ; _fs2uint.c 79 + 001A 90s00r00 89 mov dptr,#___fs2uint_a1_1_1 + 001D E0 90 movx a,@dptr + 001E FA 91 mov r2,a + 001F A3 92 inc dptr + 0020 E0 93 movx a,@dptr + 0021 FB 94 mov r3,a + 0022 A3 95 inc dptr + 0023 E0 96 movx a,@dptr + 0024 FC 97 mov r4,a + 0025 A3 98 inc dptr + 0026 E0 99 movx a,@dptr + 0027 FD 100 mov r5,a + 0028 90s00r04 101 mov dptr,#(___fs2uint_fl1_1_1) + 002B EA 102 mov a,r2 + 002C F0 103 movx @dptr,a + 002D A3 104 inc dptr + 002E EB 105 mov a,r3 + 002F F0 106 movx @dptr,a + 0030 A3 107 inc dptr + 0031 EC 108 mov a,r4 + 0032 F0 109 movx @dptr,a + 0033 A3 110 inc dptr + 0034 ED 111 mov a,r5 + 0035 F0 112 movx @dptr,a + 113 ; _fs2uint.c 81 + 0036 90s00r04 114 mov dptr,#(___fs2uint_fl1_1_1) + 0039 E0 115 movx a,@dptr + 003A FA 116 mov r2,a + 003B A3 117 inc dptr + 003C E0 118 movx a,@dptr + 003D FB 119 mov r3,a + 003E A3 120 inc dptr + 003F E0 121 movx a,@dptr + 0040 FC 122 mov r4,a + 0041 A3 123 inc dptr + 0042 E0 124 movx a,@dptr + 0043 FD 125 mov r5,a + 0044 EA 126 mov a,r2 + 0045 4B 127 orl a,r3 + 0046 4C 128 orl a,r4 + 0047 4D 129 orl a,r5 + 130 ; Peephole 109 removed ljmp by inverse jump logic + 0048 70 06 131 jnz 00102$ + 004A 132 00120$: + 133 ; _fs2uint.c 82 + 134 ; Peephole 181 used 16 bit load of dptr + 004A 90 00 00 135 mov dptr,#0x0000 + 004D 02s01rE4 136 ljmp 00110$ + 0050 137 00102$: + 138 ; _fs2uint.c 84 + 0050 90s00r04 139 mov dptr,#(___fs2uint_fl1_1_1) + 0053 E0 140 movx a,@dptr + 0054 FA 141 mov r2,a + 0055 A3 142 inc dptr + 0056 E0 143 movx a,@dptr + 0057 FB 144 mov r3,a + 0058 A3 145 inc dptr + 0059 E0 146 movx a,@dptr + 005A FC 147 mov r4,a + 005B A3 148 inc dptr + 005C E0 149 movx a,@dptr + 005D FD 150 mov r5,a + 005E 8C 02 151 mov ar2,r4 + 0060 ED 152 mov a,r5 + 0061 A2 E7 153 mov c,acc.7 + 0063 CA 154 xch a,r2 + 0064 33 155 rlc a + 0065 CA 156 xch a,r2 + 0066 33 157 rlc a + 0067 CA 158 xch a,r2 + 0068 54 01 159 anl a,#0x01 + 006A 30 E0 02 160 jnb acc.0,00121$ + 006D 44 FE 161 orl a,#0xfe + 006F 162 00121$: + 006F FB 163 mov r3,a + 0070 33 164 rlc a + 0071 95 E0 165 subb a,acc + 0073 FC 166 mov r4,a + 0074 FD 167 mov r5,a + 0075 EA 168 mov a,r2 + 0076 75 F0 00 169 mov b,#0x00 + 0079 24 6A 170 add a,#0x6a + 007B FA 171 mov r2,a + 007C E5 F0 172 mov a,b + 007E 34 FF 173 addc a,#0xff + 0080 FB 174 mov r3,a + 0081 90s00r08 175 mov dptr,#___fs2uint_exp_1_1 + 0084 EA 176 mov a,r2 + 0085 F0 177 movx @dptr,a + 0086 A3 178 inc dptr + 0087 EB 179 mov a,r3 + 0088 F0 180 movx @dptr,a + 181 ; _fs2uint.c 85 + 0089 90s00r04 182 mov dptr,#(___fs2uint_fl1_1_1) + 008C E0 183 movx a,@dptr + 008D FA 184 mov r2,a + 008E A3 185 inc dptr + 008F E0 186 movx a,@dptr + 0090 FB 187 mov r3,a + 0091 A3 188 inc dptr + 0092 E0 189 movx a,@dptr + 0093 FE 190 mov r6,a + 0094 A3 191 inc dptr + 0095 E0 192 movx a,@dptr + 0096 FF 193 mov r7,a + 0097 53 06 7F 194 anl ar6,#0x7f + 009A 7F 00 195 mov r7,#0x00 + 009C 90s00r0A 196 mov dptr,#___fs2uint_l_1_1 + 009F EA 197 mov a,r2 + 00A0 F0 198 movx @dptr,a + 00A1 A3 199 inc dptr + 00A2 EB 200 mov a,r3 + 00A3 F0 201 movx @dptr,a + 00A4 74 80 202 mov a,#0x80 + 00A6 4E 203 orl a,r6 + 00A7 A3 204 inc dptr + 00A8 F0 205 movx @dptr,a + 00A9 A3 206 inc dptr + 00AA EF 207 mov a,r7 + 00AB F0 208 movx @dptr,a + 209 ; _fs2uint.c 87 + 00AC 90s00r08 210 mov dptr,#___fs2uint_exp_1_1 + 00AF E0 211 movx a,@dptr + 00B0 FA 212 mov r2,a + 00B1 A3 213 inc dptr + 00B2 E0 214 movx a,@dptr + 00B3 FB 215 mov r3,a + 00B4 C3 216 clr c + 217 ; Peephole 180 changed mov to clr + 00B5 E4 218 clr a + 00B6 9A 219 subb a,r2 + 220 ; Peephole 159 avoided xrl during execution + 00B7 74 80 221 mov a,#(0x00 ^ 0x80) + 00B9 8B F0 222 mov b,r3 + 00BB 63 F0 80 223 xrl b,#0x80 + 00BE 95 F0 224 subb a,b + 225 ; Peephole 108 removed ljmp by inverse jump logic + 00C0 50 1E 226 jnc 00104$ + 00C2 227 00122$: + 228 ; _fs2uint.c 88 + 00C2 90s00r04 229 mov dptr,#(___fs2uint_fl1_1_1) + 00C5 E0 230 movx a,@dptr + 00C6 FA 231 mov r2,a + 00C7 A3 232 inc dptr + 00C8 E0 233 movx a,@dptr + 00C9 FB 234 mov r3,a + 00CA A3 235 inc dptr + 00CB E0 236 movx a,@dptr + 00CC FE 237 mov r6,a + 00CD A3 238 inc dptr + 00CE E0 239 movx a,@dptr + 240 ; Peephole 105 removed redundant mov + 00CF FF 241 mov r7,a + 00D0 23 242 rl a + 00D1 54 01 243 anl a,#0x01 + 00D3 FA 244 mov r2,a + 00D4 43 02 7F 245 orl ar2,#0x7f + 00D7 78 00 246 mov r0,#0x00 + 00D9 8A 82 247 mov dpl,r2 + 00DB 88 83 248 mov dph,r0 + 00DD 02s01rE4 249 ljmp 00110$ + 00E0 250 00104$: + 251 ; _fs2uint.c 91 + 00E0 90s00r08 252 mov dptr,#___fs2uint_exp_1_1 + 00E3 E0 253 movx a,@dptr + 00E4 FA 254 mov r2,a + 00E5 A3 255 inc dptr + 00E6 E0 256 movx a,@dptr + 257 ; Peephole 105 removed redundant mov + 00E7 F8 258 mov r0,a + 00E8 20 E7 03 259 jb acc.7,00123$ + 00EB 02s01r83 260 ljmp 00106$ + 00EE 261 00123$: + 00EE 90s00r08 262 mov dptr,#___fs2uint_exp_1_1 + 00F1 E0 263 movx a,@dptr + 00F2 FA 264 mov r2,a + 00F3 A3 265 inc dptr + 00F4 E0 266 movx a,@dptr + 00F5 F8 267 mov r0,a + 00F6 C3 268 clr c + 00F7 74 E7 269 mov a,#0xe7 + 00F9 9A 270 subb a,r2 + 271 ; Peephole 159 avoided xrl during execution + 00FA 74 7F 272 mov a,#(0xff ^ 0x80) + 00FC 88 F0 273 mov b,r0 + 00FE 63 F0 80 274 xrl b,#0x80 + 0101 95 F0 275 subb a,b + 0103 40 03 276 jc 00124$ + 0105 02s01r83 277 ljmp 00106$ + 0108 278 00124$: + 0108 90s00r0A 279 mov dptr,#___fs2uint_l_1_1 + 010B E0 280 movx a,@dptr + 010C F5*00 281 mov ___fs2uint_sloc0_1_0,a + 010E A3 282 inc dptr + 010F E0 283 movx a,@dptr + 0110 F5*01 284 mov (___fs2uint_sloc0_1_0 + 1),a + 0112 A3 285 inc dptr + 0113 E0 286 movx a,@dptr + 0114 F5*02 287 mov (___fs2uint_sloc0_1_0 + 2),a + 0116 A3 288 inc dptr + 0117 E0 289 movx a,@dptr + 0118 F5*03 290 mov (___fs2uint_sloc0_1_0 + 3),a + 011A E5*00 291 mov a,___fs2uint_sloc0_1_0 + 011C 45*01 292 orl a,(___fs2uint_sloc0_1_0 + 1) + 011E 45*02 293 orl a,(___fs2uint_sloc0_1_0 + 2) + 0120 45*03 294 orl a,(___fs2uint_sloc0_1_0 + 3) + 0122 70 03 295 jnz 00125$ + 0124 02s01r83 296 ljmp 00106$ + 0127 297 00125$: + 298 ; _fs2uint.c 92 + 0127 90s00r08 299 mov dptr,#___fs2uint_exp_1_1 + 012A E0 300 movx a,@dptr + 012B FA 301 mov r2,a + 012C A3 302 inc dptr + 012D E0 303 movx a,@dptr + 012E F8 304 mov r0,a + 012F C3 305 clr c + 0130 E4 306 clr a + 0131 9A 307 subb a,r2 + 0132 F5*00 308 mov ___fs2uint_sloc0_1_0,a + 0134 E4 309 clr a + 0135 98 310 subb a,r0 + 0136 F5*01 311 mov (___fs2uint_sloc0_1_0 + 1),a + 0138 90s00r0A 312 mov dptr,#___fs2uint_l_1_1 + 013B E0 313 movx a,@dptr + 013C F5*04 314 mov ___fs2uint_sloc1_1_0,a + 013E A3 315 inc dptr + 013F E0 316 movx a,@dptr + 0140 F5*05 317 mov (___fs2uint_sloc1_1_0 + 1),a + 0142 A3 318 inc dptr + 0143 E0 319 movx a,@dptr + 0144 F5*06 320 mov (___fs2uint_sloc1_1_0 + 2),a + 0146 A3 321 inc dptr + 0147 E0 322 movx a,@dptr + 0148 F5*07 323 mov (___fs2uint_sloc1_1_0 + 3),a + 014A 85*00 F0 324 mov b,___fs2uint_sloc0_1_0 + 014D 05 F0 325 inc b + 014F E5*07 326 mov a,(___fs2uint_sloc1_1_0 + 3) + 0151 33 327 rlc a + 0152 92 D2 328 mov ov,c + 0154 80 16 329 sjmp 00127$ + 0156 330 00126$: + 0156 A2 D2 331 mov c,ov + 0158 E5*07 332 mov a,(___fs2uint_sloc1_1_0 + 3) + 015A 13 333 rrc a + 015B F5*07 334 mov (___fs2uint_sloc1_1_0 + 3),a + 015D E5*06 335 mov a,(___fs2uint_sloc1_1_0 + 2) + 015F 13 336 rrc a + 0160 F5*06 337 mov (___fs2uint_sloc1_1_0 + 2),a + 0162 E5*05 338 mov a,(___fs2uint_sloc1_1_0 + 1) + 0164 13 339 rrc a + 0165 F5*05 340 mov (___fs2uint_sloc1_1_0 + 1),a + 0167 E5*04 341 mov a,___fs2uint_sloc1_1_0 + 0169 13 342 rrc a + 016A F5*04 343 mov ___fs2uint_sloc1_1_0,a + 016C 344 00127$: + 016C D5 F0 E7 345 djnz b,00126$ + 016F 90s00r0A 346 mov dptr,#___fs2uint_l_1_1 + 0172 E5*04 347 mov a,___fs2uint_sloc1_1_0 + 0174 F0 348 movx @dptr,a + 0175 A3 349 inc dptr + 0176 E5*05 350 mov a,(___fs2uint_sloc1_1_0 + 1) + 0178 F0 351 movx @dptr,a + 0179 A3 352 inc dptr + 017A E5*06 353 mov a,(___fs2uint_sloc1_1_0 + 2) + 017C F0 354 movx @dptr,a + 017D A3 355 inc dptr + 017E E5*07 356 mov a,(___fs2uint_sloc1_1_0 + 3) + 0180 F0 357 movx @dptr,a + 358 ; Peephole 132 changed ljmp to sjmp + 0181 80 06 359 sjmp 00107$ + 0183 360 00106$: + 361 ; _fs2uint.c 94 + 362 ; Peephole 181 used 16 bit load of dptr + 0183 90 00 00 363 mov dptr,#0x0000 + 0186 02s01rE4 364 ljmp 00110$ + 0189 365 00107$: + 366 ; _fs2uint.c 96 + 0189 90s00r04 367 mov dptr,#(___fs2uint_fl1_1_1) + 018C E0 368 movx a,@dptr + 018D F5*04 369 mov ___fs2uint_sloc1_1_0,a + 018F A3 370 inc dptr + 0190 E0 371 movx a,@dptr + 0191 F5*05 372 mov (___fs2uint_sloc1_1_0 + 1),a + 0193 A3 373 inc dptr + 0194 E0 374 movx a,@dptr + 0195 F5*06 375 mov (___fs2uint_sloc1_1_0 + 2),a + 0197 A3 376 inc dptr + 0198 E0 377 movx a,@dptr + 378 ; Peephole 105 removed redundant mov + 0199 F5*07 379 mov (___fs2uint_sloc1_1_0 + 3),a + 019B 23 380 rl a + 019C 54 01 381 anl a,#0x01 + 382 ; Peephole 105 removed redundant mov + 019E FA 383 mov r2,a + 384 ; Peephole 110 removed ljmp by inverse jump logic + 019F 60 29 385 jz 00112$ + 01A1 386 00128$: + 01A1 90s00r0A 387 mov dptr,#___fs2uint_l_1_1 + 01A4 E0 388 movx a,@dptr + 01A5 F5*04 389 mov ___fs2uint_sloc1_1_0,a + 01A7 A3 390 inc dptr + 01A8 E0 391 movx a,@dptr + 01A9 F5*05 392 mov (___fs2uint_sloc1_1_0 + 1),a + 01AB A3 393 inc dptr + 01AC E0 394 movx a,@dptr + 01AD F5*06 395 mov (___fs2uint_sloc1_1_0 + 2),a + 01AF A3 396 inc dptr + 01B0 E0 397 movx a,@dptr + 01B1 F5*07 398 mov (___fs2uint_sloc1_1_0 + 3),a + 01B3 C3 399 clr c + 01B4 E4 400 clr a + 01B5 95*04 401 subb a,___fs2uint_sloc1_1_0 + 01B7 F5*04 402 mov ___fs2uint_sloc1_1_0,a + 01B9 E4 403 clr a + 01BA 95*05 404 subb a,(___fs2uint_sloc1_1_0 + 1) + 01BC F5*05 405 mov (___fs2uint_sloc1_1_0 + 1),a + 01BE E4 406 clr a + 01BF 95*06 407 subb a,(___fs2uint_sloc1_1_0 + 2) + 01C1 F5*06 408 mov (___fs2uint_sloc1_1_0 + 2),a + 01C3 E4 409 clr a + 01C4 95*07 410 subb a,(___fs2uint_sloc1_1_0 + 3) + 01C6 F5*07 411 mov (___fs2uint_sloc1_1_0 + 3),a + 412 ; Peephole 132 changed ljmp to sjmp + 01C8 80 12 413 sjmp 00113$ + 01CA 414 00112$: + 01CA 90s00r0A 415 mov dptr,#___fs2uint_l_1_1 + 01CD E0 416 movx a,@dptr + 01CE F5*04 417 mov ___fs2uint_sloc1_1_0,a + 01D0 A3 418 inc dptr + 01D1 E0 419 movx a,@dptr + 01D2 F5*05 420 mov (___fs2uint_sloc1_1_0 + 1),a + 01D4 A3 421 inc dptr + 01D5 E0 422 movx a,@dptr + 01D6 F5*06 423 mov (___fs2uint_sloc1_1_0 + 2),a + 01D8 A3 424 inc dptr + 01D9 E0 425 movx a,@dptr + 01DA F5*07 426 mov (___fs2uint_sloc1_1_0 + 3),a + 01DC 427 00113$: + 01DC AA*04 428 mov r2,___fs2uint_sloc1_1_0 + 01DE A8*05 429 mov r0,(___fs2uint_sloc1_1_0 + 1) + 01E0 8A 82 430 mov dpl,r2 + 01E2 88 83 431 mov dph,r0 + 01E4 432 00110$: + 01E4 433 C$_fs2uint.c$97$1$1 ==. + 01E4 434 XG$__fs2uint$0$0 ==. + 01E4 22 435 ret + 436 .area CSEG (CODE) diff --git a/device/lib/_fs2uint.sym b/device/lib/_fs2uint.sym new file mode 100644 index 00000000..3f42b2a2 --- /dev/null +++ b/device/lib/_fs2uint.sym @@ -0,0 +1,692 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fs2uint$100 0027 GR + 7 A$_fs2uint$101 0028 GR + 7 A$_fs2uint$102 002B GR + 7 A$_fs2uint$103 002C GR + 7 A$_fs2uint$104 002D GR + 7 A$_fs2uint$105 002E GR + 7 A$_fs2uint$106 002F GR + 7 A$_fs2uint$107 0030 GR + 7 A$_fs2uint$108 0031 GR + 7 A$_fs2uint$109 0032 GR + 7 A$_fs2uint$110 0033 GR + 7 A$_fs2uint$111 0034 GR + 7 A$_fs2uint$112 0035 GR + 7 A$_fs2uint$114 0036 GR + 7 A$_fs2uint$115 0039 GR + 7 A$_fs2uint$116 003A GR + 7 A$_fs2uint$117 003B GR + 7 A$_fs2uint$118 003C GR + 7 A$_fs2uint$119 003D GR + 7 A$_fs2uint$120 003E GR + 7 A$_fs2uint$121 003F GR + 7 A$_fs2uint$122 0040 GR + 7 A$_fs2uint$123 0041 GR + 7 A$_fs2uint$124 0042 GR + 7 A$_fs2uint$125 0043 GR + 7 A$_fs2uint$126 0044 GR + 7 A$_fs2uint$127 0045 GR + 7 A$_fs2uint$128 0046 GR + 7 A$_fs2uint$129 0047 GR + 7 A$_fs2uint$131 0048 GR + 7 A$_fs2uint$135 004A GR + 7 A$_fs2uint$136 004D GR + 7 A$_fs2uint$139 0050 GR + 7 A$_fs2uint$140 0053 GR + 7 A$_fs2uint$141 0054 GR + 7 A$_fs2uint$142 0055 GR + 7 A$_fs2uint$143 0056 GR + 7 A$_fs2uint$144 0057 GR + 7 A$_fs2uint$145 0058 GR + 7 A$_fs2uint$146 0059 GR + 7 A$_fs2uint$147 005A GR + 7 A$_fs2uint$148 005B GR + 7 A$_fs2uint$149 005C GR + 7 A$_fs2uint$150 005D GR + 7 A$_fs2uint$151 005E GR + 7 A$_fs2uint$152 0060 GR + 7 A$_fs2uint$153 0061 GR + 7 A$_fs2uint$154 0063 GR + 7 A$_fs2uint$155 0064 GR + 7 A$_fs2uint$156 0065 GR + 7 A$_fs2uint$157 0066 GR + 7 A$_fs2uint$158 0067 GR + 7 A$_fs2uint$159 0068 GR + 7 A$_fs2uint$160 006A GR + 7 A$_fs2uint$161 006D GR + 7 A$_fs2uint$163 006F GR + 7 A$_fs2uint$164 0070 GR + 7 A$_fs2uint$165 0071 GR + 7 A$_fs2uint$166 0073 GR + 7 A$_fs2uint$167 0074 GR + 7 A$_fs2uint$168 0075 GR + 7 A$_fs2uint$169 0076 GR + 7 A$_fs2uint$170 0079 GR + 7 A$_fs2uint$171 007B GR + 7 A$_fs2uint$172 007C GR + 7 A$_fs2uint$173 007E GR + 7 A$_fs2uint$174 0080 GR + 7 A$_fs2uint$175 0081 GR + 7 A$_fs2uint$176 0084 GR + 7 A$_fs2uint$177 0085 GR + 7 A$_fs2uint$178 0086 GR + 7 A$_fs2uint$179 0087 GR + 7 A$_fs2uint$180 0088 GR + 7 A$_fs2uint$182 0089 GR + 7 A$_fs2uint$183 008C GR + 7 A$_fs2uint$184 008D GR + 7 A$_fs2uint$185 008E GR + 7 A$_fs2uint$186 008F GR + 7 A$_fs2uint$187 0090 GR + 7 A$_fs2uint$188 0091 GR + 7 A$_fs2uint$189 0092 GR + 7 A$_fs2uint$190 0093 GR + 7 A$_fs2uint$191 0094 GR + 7 A$_fs2uint$192 0095 GR + 7 A$_fs2uint$193 0096 GR + 7 A$_fs2uint$194 0097 GR + 7 A$_fs2uint$195 009A GR + 7 A$_fs2uint$196 009C GR + 7 A$_fs2uint$197 009F GR + 7 A$_fs2uint$198 00A0 GR + 7 A$_fs2uint$199 00A1 GR + 7 A$_fs2uint$200 00A2 GR + 7 A$_fs2uint$201 00A3 GR + 7 A$_fs2uint$202 00A4 GR + 7 A$_fs2uint$203 00A6 GR + 7 A$_fs2uint$204 00A7 GR + 7 A$_fs2uint$205 00A8 GR + 7 A$_fs2uint$206 00A9 GR + 7 A$_fs2uint$207 00AA GR + 7 A$_fs2uint$208 00AB GR + 7 A$_fs2uint$210 00AC GR + 7 A$_fs2uint$211 00AF GR + 7 A$_fs2uint$212 00B0 GR + 7 A$_fs2uint$213 00B1 GR + 7 A$_fs2uint$214 00B2 GR + 7 A$_fs2uint$215 00B3 GR + 7 A$_fs2uint$216 00B4 GR + 7 A$_fs2uint$218 00B5 GR + 7 A$_fs2uint$219 00B6 GR + 7 A$_fs2uint$221 00B7 GR + 7 A$_fs2uint$222 00B9 GR + 7 A$_fs2uint$223 00BB GR + 7 A$_fs2uint$224 00BE GR + 7 A$_fs2uint$226 00C0 GR + 7 A$_fs2uint$229 00C2 GR + 7 A$_fs2uint$230 00C5 GR + 7 A$_fs2uint$231 00C6 GR + 7 A$_fs2uint$232 00C7 GR + 7 A$_fs2uint$233 00C8 GR + 7 A$_fs2uint$234 00C9 GR + 7 A$_fs2uint$235 00CA GR + 7 A$_fs2uint$236 00CB GR + 7 A$_fs2uint$237 00CC GR + 7 A$_fs2uint$238 00CD GR + 7 A$_fs2uint$239 00CE GR + 7 A$_fs2uint$241 00CF GR + 7 A$_fs2uint$242 00D0 GR + 7 A$_fs2uint$243 00D1 GR + 7 A$_fs2uint$244 00D3 GR + 7 A$_fs2uint$245 00D4 GR + 7 A$_fs2uint$246 00D7 GR + 7 A$_fs2uint$247 00D9 GR + 7 A$_fs2uint$248 00DB GR + 7 A$_fs2uint$249 00DD GR + 7 A$_fs2uint$252 00E0 GR + 7 A$_fs2uint$253 00E3 GR + 7 A$_fs2uint$254 00E4 GR + 7 A$_fs2uint$255 00E5 GR + 7 A$_fs2uint$256 00E6 GR + 7 A$_fs2uint$258 00E7 GR + 7 A$_fs2uint$259 00E8 GR + 7 A$_fs2uint$260 00EB GR + 7 A$_fs2uint$262 00EE GR + 7 A$_fs2uint$263 00F1 GR + 7 A$_fs2uint$264 00F2 GR + 7 A$_fs2uint$265 00F3 GR + 7 A$_fs2uint$266 00F4 GR + 7 A$_fs2uint$267 00F5 GR + 7 A$_fs2uint$268 00F6 GR + 7 A$_fs2uint$269 00F7 GR + 7 A$_fs2uint$270 00F9 GR + 7 A$_fs2uint$272 00FA GR + 7 A$_fs2uint$273 00FC GR + 7 A$_fs2uint$274 00FE GR + 7 A$_fs2uint$275 0101 GR + 7 A$_fs2uint$276 0103 GR + 7 A$_fs2uint$277 0105 GR + 7 A$_fs2uint$279 0108 GR + 7 A$_fs2uint$280 010B GR + 7 A$_fs2uint$281 010C GR + 7 A$_fs2uint$282 010E GR + 7 A$_fs2uint$283 010F GR + 7 A$_fs2uint$284 0110 GR + 7 A$_fs2uint$285 0112 GR + 7 A$_fs2uint$286 0113 GR + 7 A$_fs2uint$287 0114 GR + 7 A$_fs2uint$288 0116 GR + 7 A$_fs2uint$289 0117 GR + 7 A$_fs2uint$290 0118 GR + 7 A$_fs2uint$291 011A GR + 7 A$_fs2uint$292 011C GR + 7 A$_fs2uint$293 011E GR + 7 A$_fs2uint$294 0120 GR + 7 A$_fs2uint$295 0122 GR + 7 A$_fs2uint$296 0124 GR + 7 A$_fs2uint$299 0127 GR + 7 A$_fs2uint$300 012A GR + 7 A$_fs2uint$301 012B GR + 7 A$_fs2uint$302 012C GR + 7 A$_fs2uint$303 012D GR + 7 A$_fs2uint$304 012E GR + 7 A$_fs2uint$305 012F GR + 7 A$_fs2uint$306 0130 GR + 7 A$_fs2uint$307 0131 GR + 7 A$_fs2uint$308 0132 GR + 7 A$_fs2uint$309 0134 GR + 7 A$_fs2uint$310 0135 GR + 7 A$_fs2uint$311 0136 GR + 7 A$_fs2uint$312 0138 GR + 7 A$_fs2uint$313 013B GR + 7 A$_fs2uint$314 013C GR + 7 A$_fs2uint$315 013E GR + 7 A$_fs2uint$316 013F GR + 7 A$_fs2uint$317 0140 GR + 7 A$_fs2uint$318 0142 GR + 7 A$_fs2uint$319 0143 GR + 7 A$_fs2uint$320 0144 GR + 7 A$_fs2uint$321 0146 GR + 7 A$_fs2uint$322 0147 GR + 7 A$_fs2uint$323 0148 GR + 7 A$_fs2uint$324 014A GR + 7 A$_fs2uint$325 014D GR + 7 A$_fs2uint$326 014F GR + 7 A$_fs2uint$327 0151 GR + 7 A$_fs2uint$328 0152 GR + 7 A$_fs2uint$329 0154 GR + 7 A$_fs2uint$331 0156 GR + 7 A$_fs2uint$332 0158 GR + 7 A$_fs2uint$333 015A GR + 7 A$_fs2uint$334 015B GR + 7 A$_fs2uint$335 015D GR + 7 A$_fs2uint$336 015F GR + 7 A$_fs2uint$337 0160 GR + 7 A$_fs2uint$338 0162 GR + 7 A$_fs2uint$339 0164 GR + 7 A$_fs2uint$340 0165 GR + 7 A$_fs2uint$341 0167 GR + 7 A$_fs2uint$342 0169 GR + 7 A$_fs2uint$343 016A GR + 7 A$_fs2uint$345 016C GR + 7 A$_fs2uint$346 016F GR + 7 A$_fs2uint$347 0172 GR + 7 A$_fs2uint$348 0174 GR + 7 A$_fs2uint$349 0175 GR + 7 A$_fs2uint$350 0176 GR + 7 A$_fs2uint$351 0178 GR + 7 A$_fs2uint$352 0179 GR + 7 A$_fs2uint$353 017A GR + 7 A$_fs2uint$354 017C GR + 7 A$_fs2uint$355 017D GR + 7 A$_fs2uint$356 017E GR + 7 A$_fs2uint$357 0180 GR + 7 A$_fs2uint$359 0181 GR + 7 A$_fs2uint$363 0183 GR + 7 A$_fs2uint$364 0186 GR + 7 A$_fs2uint$367 0189 GR + 7 A$_fs2uint$368 018C GR + 7 A$_fs2uint$369 018D GR + 7 A$_fs2uint$370 018F GR + 7 A$_fs2uint$371 0190 GR + 7 A$_fs2uint$372 0191 GR + 7 A$_fs2uint$373 0193 GR + 7 A$_fs2uint$374 0194 GR + 7 A$_fs2uint$375 0195 GR + 7 A$_fs2uint$376 0197 GR + 7 A$_fs2uint$377 0198 GR + 7 A$_fs2uint$379 0199 GR + 7 A$_fs2uint$380 019B GR + 7 A$_fs2uint$381 019C GR + 7 A$_fs2uint$383 019E GR + 7 A$_fs2uint$385 019F GR + 7 A$_fs2uint$387 01A1 GR + 7 A$_fs2uint$388 01A4 GR + 7 A$_fs2uint$389 01A5 GR + 7 A$_fs2uint$390 01A7 GR + 7 A$_fs2uint$391 01A8 GR + 7 A$_fs2uint$392 01A9 GR + 7 A$_fs2uint$393 01AB GR + 7 A$_fs2uint$394 01AC GR + 7 A$_fs2uint$395 01AD GR + 7 A$_fs2uint$396 01AF GR + 7 A$_fs2uint$397 01B0 GR + 7 A$_fs2uint$398 01B1 GR + 7 A$_fs2uint$399 01B3 GR + 7 A$_fs2uint$400 01B4 GR + 7 A$_fs2uint$401 01B5 GR + 7 A$_fs2uint$402 01B7 GR + 7 A$_fs2uint$403 01B9 GR + 7 A$_fs2uint$404 01BA GR + 7 A$_fs2uint$405 01BC GR + 7 A$_fs2uint$406 01BE GR + 7 A$_fs2uint$407 01BF GR + 7 A$_fs2uint$408 01C1 GR + 7 A$_fs2uint$409 01C3 GR + 7 A$_fs2uint$410 01C4 GR + 7 A$_fs2uint$411 01C6 GR + 7 A$_fs2uint$413 01C8 GR + 7 A$_fs2uint$415 01CA GR + 7 A$_fs2uint$416 01CD GR + 7 A$_fs2uint$417 01CE GR + 7 A$_fs2uint$418 01D0 GR + 7 A$_fs2uint$419 01D1 GR + 7 A$_fs2uint$420 01D2 GR + 7 A$_fs2uint$421 01D4 GR + 7 A$_fs2uint$422 01D5 GR + 7 A$_fs2uint$423 01D6 GR + 7 A$_fs2uint$424 01D8 GR + 7 A$_fs2uint$425 01D9 GR + 7 A$_fs2uint$426 01DA GR + 7 A$_fs2uint$428 01DC GR + 7 A$_fs2uint$429 01DE GR + 7 A$_fs2uint$430 01E0 GR + 7 A$_fs2uint$431 01E2 GR + 7 A$_fs2uint$435 01E4 GR + 7 A$_fs2uint$72 0000 GR + 7 A$_fs2uint$73 0002 GR + 7 A$_fs2uint$74 0004 GR + 7 A$_fs2uint$75 0006 GR + 7 A$_fs2uint$76 0008 GR + 7 A$_fs2uint$77 000B GR + 7 A$_fs2uint$78 000D GR + 7 A$_fs2uint$79 000E GR + 7 A$_fs2uint$80 0010 GR + 7 A$_fs2uint$81 0011 GR + 7 A$_fs2uint$82 0012 GR + 7 A$_fs2uint$83 0014 GR + 7 A$_fs2uint$84 0015 GR + 7 A$_fs2uint$85 0016 GR + 7 A$_fs2uint$86 0018 GR + 7 A$_fs2uint$87 0019 GR + 7 A$_fs2uint$89 001A GR + 7 A$_fs2uint$90 001D GR + 7 A$_fs2uint$91 001E GR + 7 A$_fs2uint$92 001F GR + 7 A$_fs2uint$93 0020 GR + 7 A$_fs2uint$94 0021 GR + 7 A$_fs2uint$95 0022 GR + 7 A$_fs2uint$96 0023 GR + 7 A$_fs2uint$97 0024 GR + 7 A$_fs2uint$98 0025 GR + 7 A$_fs2uint$99 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fs2uint.c$97$1$1 = 01E4 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fs2uint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fs2uint$0$0 = 01E4 GR + 7 ___fs2uint 0000 GR + 5 ___fs2uint_a1_1_1 0000 R + 5 ___fs2uint_exp_1_1 0008 R + 5 ___fs2uint_fl1_1_1 0004 R + 5 ___fs2uint_l_1_1 000A R + 1 ___fs2uint_sloc0_1_0 0000 R + 1 ___fs2uint_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 1E5 flags 20 diff --git a/device/lib/_fs2ulong.c b/device/lib/_fs2ulong.c new file mode 100644 index 00000000..48730bca --- /dev/null +++ b/device/lib/_fs2ulong.c @@ -0,0 +1,98 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* convert double to int */ +unsigned long +__fs2ulong (float a1) +{ + volatile union float_long fl1; + volatile int exp; + volatile long l; + + fl1.f = a1; + + if (!fl1.l) + return (0); + + exp = EXP (fl1.l) - EXCESS - 24; + l = MANT (fl1.l); + + if (exp > 0) + return (0x7F | SIGN(fl1.l)); /* largest integer */ + + /* shift down until exp = 0 or l = 0 */ + if (exp < 0 && exp > -25 && l) + l >>= -exp; + else + return (0); + + return (SIGN(fl1.l) ? -l : l); +} + diff --git a/device/lib/_fs2ulong.lst b/device/lib/_fs2ulong.lst new file mode 100644 index 00000000..8c74909b --- /dev/null +++ b/device/lib/_fs2ulong.lst @@ -0,0 +1,451 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fs2ulong + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fs2ulong + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___fs2ulong_sloc0_1_0: + 0000 22 .ds 0x0004 + 0004 23 ___fs2ulong_sloc1_1_0: + 0004 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___fs2ulong_a1_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___fs2ulong_fl1_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___fs2ulong_exp_1_1: + 0008 46 .ds 0x0002 + 000A 47 ___fs2ulong_l_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__fs2ulong$0$0 ==. + 58 ; _fs2ulong.c 73 + 59 ; ----------------------------------------- + 60 ; function __fs2ulong + 61 ; ----------------------------------------- + 0000 62 ___fs2ulong: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _fs2ulong.c 0 + 0000 C0 E0 72 push acc + 0002 C0 F0 73 push b + 0004 C0 83 74 push dph + 0006 C0 82 75 push dpl + 0008 90s00r00 76 mov dptr,#___fs2ulong_a1_1_1 + 000B D0 E0 77 pop acc + 000D F0 78 movx @dptr,a + 000E D0 E0 79 pop acc + 0010 A3 80 inc dptr + 0011 F0 81 movx @dptr,a + 0012 D0 E0 82 pop acc + 0014 A3 83 inc dptr + 0015 F0 84 movx @dptr,a + 0016 D0 E0 85 pop acc + 0018 A3 86 inc dptr + 0019 F0 87 movx @dptr,a + 88 ; _fs2ulong.c 79 + 001A 90s00r00 89 mov dptr,#___fs2ulong_a1_1_1 + 001D E0 90 movx a,@dptr + 001E FA 91 mov r2,a + 001F A3 92 inc dptr + 0020 E0 93 movx a,@dptr + 0021 FB 94 mov r3,a + 0022 A3 95 inc dptr + 0023 E0 96 movx a,@dptr + 0024 FC 97 mov r4,a + 0025 A3 98 inc dptr + 0026 E0 99 movx a,@dptr + 0027 FD 100 mov r5,a + 0028 90s00r04 101 mov dptr,#(___fs2ulong_fl1_1_1) + 002B EA 102 mov a,r2 + 002C F0 103 movx @dptr,a + 002D A3 104 inc dptr + 002E EB 105 mov a,r3 + 002F F0 106 movx @dptr,a + 0030 A3 107 inc dptr + 0031 EC 108 mov a,r4 + 0032 F0 109 movx @dptr,a + 0033 A3 110 inc dptr + 0034 ED 111 mov a,r5 + 0035 F0 112 movx @dptr,a + 113 ; _fs2ulong.c 81 + 0036 90s00r04 114 mov dptr,#(___fs2ulong_fl1_1_1) + 0039 E0 115 movx a,@dptr + 003A FA 116 mov r2,a + 003B A3 117 inc dptr + 003C E0 118 movx a,@dptr + 003D FB 119 mov r3,a + 003E A3 120 inc dptr + 003F E0 121 movx a,@dptr + 0040 FC 122 mov r4,a + 0041 A3 123 inc dptr + 0042 E0 124 movx a,@dptr + 0043 FD 125 mov r5,a + 0044 EA 126 mov a,r2 + 0045 4B 127 orl a,r3 + 0046 4C 128 orl a,r4 + 0047 4D 129 orl a,r5 + 130 ; Peephole 109 removed ljmp by inverse jump logic + 0048 70 0A 131 jnz 00102$ + 004A 132 00120$: + 133 ; _fs2ulong.c 82 + 134 ; Peephole 3.a changed mov to clr + 135 ; Peephole 3.b changed mov to clr + 136 ; Peephole 3.b changed mov to clr + 004A E4 137 clr a + 004B F5 82 138 mov dpl,a + 004D F5 83 139 mov dph,a + 004F F5 F0 140 mov b,a + 0051 02s01rFF 141 ljmp 00110$ + 0054 142 00102$: + 143 ; _fs2ulong.c 84 + 0054 90s00r04 144 mov dptr,#(___fs2ulong_fl1_1_1) + 0057 E0 145 movx a,@dptr + 0058 FA 146 mov r2,a + 0059 A3 147 inc dptr + 005A E0 148 movx a,@dptr + 005B FB 149 mov r3,a + 005C A3 150 inc dptr + 005D E0 151 movx a,@dptr + 005E FC 152 mov r4,a + 005F A3 153 inc dptr + 0060 E0 154 movx a,@dptr + 0061 FD 155 mov r5,a + 0062 8C 02 156 mov ar2,r4 + 0064 ED 157 mov a,r5 + 0065 A2 E7 158 mov c,acc.7 + 0067 CA 159 xch a,r2 + 0068 33 160 rlc a + 0069 CA 161 xch a,r2 + 006A 33 162 rlc a + 006B CA 163 xch a,r2 + 006C 54 01 164 anl a,#0x01 + 006E 30 E0 02 165 jnb acc.0,00121$ + 0071 44 FE 166 orl a,#0xfe + 0073 167 00121$: + 0073 FB 168 mov r3,a + 0074 33 169 rlc a + 0075 95 E0 170 subb a,acc + 0077 FC 171 mov r4,a + 0078 FD 172 mov r5,a + 0079 EA 173 mov a,r2 + 007A 75 F0 00 174 mov b,#0x00 + 007D 24 6A 175 add a,#0x6a + 007F FA 176 mov r2,a + 0080 E5 F0 177 mov a,b + 0082 34 FF 178 addc a,#0xff + 0084 FB 179 mov r3,a + 0085 90s00r08 180 mov dptr,#___fs2ulong_exp_1_1 + 0088 EA 181 mov a,r2 + 0089 F0 182 movx @dptr,a + 008A A3 183 inc dptr + 008B EB 184 mov a,r3 + 008C F0 185 movx @dptr,a + 186 ; _fs2ulong.c 85 + 008D 90s00r04 187 mov dptr,#(___fs2ulong_fl1_1_1) + 0090 E0 188 movx a,@dptr + 0091 FA 189 mov r2,a + 0092 A3 190 inc dptr + 0093 E0 191 movx a,@dptr + 0094 FB 192 mov r3,a + 0095 A3 193 inc dptr + 0096 E0 194 movx a,@dptr + 0097 FE 195 mov r6,a + 0098 A3 196 inc dptr + 0099 E0 197 movx a,@dptr + 009A FF 198 mov r7,a + 009B 53 06 7F 199 anl ar6,#0x7f + 009E 7F 00 200 mov r7,#0x00 + 00A0 90s00r0A 201 mov dptr,#___fs2ulong_l_1_1 + 00A3 EA 202 mov a,r2 + 00A4 F0 203 movx @dptr,a + 00A5 A3 204 inc dptr + 00A6 EB 205 mov a,r3 + 00A7 F0 206 movx @dptr,a + 00A8 74 80 207 mov a,#0x80 + 00AA 4E 208 orl a,r6 + 00AB A3 209 inc dptr + 00AC F0 210 movx @dptr,a + 00AD A3 211 inc dptr + 00AE EF 212 mov a,r7 + 00AF F0 213 movx @dptr,a + 214 ; _fs2ulong.c 87 + 00B0 90s00r08 215 mov dptr,#___fs2ulong_exp_1_1 + 00B3 E0 216 movx a,@dptr + 00B4 FA 217 mov r2,a + 00B5 A3 218 inc dptr + 00B6 E0 219 movx a,@dptr + 00B7 FB 220 mov r3,a + 00B8 C3 221 clr c + 222 ; Peephole 180 changed mov to clr + 00B9 E4 223 clr a + 00BA 9A 224 subb a,r2 + 225 ; Peephole 159 avoided xrl during execution + 00BB 74 80 226 mov a,#(0x00 ^ 0x80) + 00BD 8B F0 227 mov b,r3 + 00BF 63 F0 80 228 xrl b,#0x80 + 00C2 95 F0 229 subb a,b + 230 ; Peephole 108 removed ljmp by inverse jump logic + 00C4 50 2E 231 jnc 00104$ + 00C6 232 00122$: + 233 ; _fs2ulong.c 88 + 00C6 90s00r04 234 mov dptr,#(___fs2ulong_fl1_1_1) + 00C9 E0 235 movx a,@dptr + 00CA FA 236 mov r2,a + 00CB A3 237 inc dptr + 00CC E0 238 movx a,@dptr + 00CD FB 239 mov r3,a + 00CE A3 240 inc dptr + 00CF E0 241 movx a,@dptr + 00D0 FE 242 mov r6,a + 00D1 A3 243 inc dptr + 00D2 E0 244 movx a,@dptr + 245 ; Peephole 105 removed redundant mov + 00D3 FF 246 mov r7,a + 00D4 23 247 rl a + 00D5 54 01 248 anl a,#0x01 + 00D7 FA 249 mov r2,a + 00D8 43 02 7F 250 orl ar2,#0x7f + 00DB 8A*00 251 mov ___fs2ulong_sloc0_1_0,r2 + 00DD 75*01 00 252 mov (___fs2ulong_sloc0_1_0 + 1),#0x00 + 00E0 75*02 00 253 mov (___fs2ulong_sloc0_1_0 + 2),#0x00 + 00E3 75*03 00 254 mov (___fs2ulong_sloc0_1_0 + 3),#0x00 + 00E6 85*00 82 255 mov dpl,___fs2ulong_sloc0_1_0 + 00E9 85*01 83 256 mov dph,(___fs2ulong_sloc0_1_0 + 1) + 00EC 85*02 F0 257 mov b,(___fs2ulong_sloc0_1_0 + 2) + 00EF E5*03 258 mov a,(___fs2ulong_sloc0_1_0 + 3) + 00F1 02s01rFF 259 ljmp 00110$ + 00F4 260 00104$: + 261 ; _fs2ulong.c 91 + 00F4 90s00r08 262 mov dptr,#___fs2ulong_exp_1_1 + 00F7 E0 263 movx a,@dptr + 00F8 FA 264 mov r2,a + 00F9 A3 265 inc dptr + 00FA E0 266 movx a,@dptr + 267 ; Peephole 105 removed redundant mov + 00FB F8 268 mov r0,a + 00FC 20 E7 03 269 jb acc.7,00123$ + 00FF 02s01r97 270 ljmp 00106$ + 0102 271 00123$: + 0102 90s00r08 272 mov dptr,#___fs2ulong_exp_1_1 + 0105 E0 273 movx a,@dptr + 0106 FA 274 mov r2,a + 0107 A3 275 inc dptr + 0108 E0 276 movx a,@dptr + 0109 F8 277 mov r0,a + 010A C3 278 clr c + 010B 74 E7 279 mov a,#0xe7 + 010D 9A 280 subb a,r2 + 281 ; Peephole 159 avoided xrl during execution + 010E 74 7F 282 mov a,#(0xff ^ 0x80) + 0110 88 F0 283 mov b,r0 + 0112 63 F0 80 284 xrl b,#0x80 + 0115 95 F0 285 subb a,b + 0117 40 03 286 jc 00124$ + 0119 02s01r97 287 ljmp 00106$ + 011C 288 00124$: + 011C 90s00r0A 289 mov dptr,#___fs2ulong_l_1_1 + 011F E0 290 movx a,@dptr + 0120 F5*00 291 mov ___fs2ulong_sloc0_1_0,a + 0122 A3 292 inc dptr + 0123 E0 293 movx a,@dptr + 0124 F5*01 294 mov (___fs2ulong_sloc0_1_0 + 1),a + 0126 A3 295 inc dptr + 0127 E0 296 movx a,@dptr + 0128 F5*02 297 mov (___fs2ulong_sloc0_1_0 + 2),a + 012A A3 298 inc dptr + 012B E0 299 movx a,@dptr + 012C F5*03 300 mov (___fs2ulong_sloc0_1_0 + 3),a + 012E E5*00 301 mov a,___fs2ulong_sloc0_1_0 + 0130 45*01 302 orl a,(___fs2ulong_sloc0_1_0 + 1) + 0132 45*02 303 orl a,(___fs2ulong_sloc0_1_0 + 2) + 0134 45*03 304 orl a,(___fs2ulong_sloc0_1_0 + 3) + 0136 70 03 305 jnz 00125$ + 0138 02s01r97 306 ljmp 00106$ + 013B 307 00125$: + 308 ; _fs2ulong.c 92 + 013B 90s00r08 309 mov dptr,#___fs2ulong_exp_1_1 + 013E E0 310 movx a,@dptr + 013F FA 311 mov r2,a + 0140 A3 312 inc dptr + 0141 E0 313 movx a,@dptr + 0142 F8 314 mov r0,a + 0143 C3 315 clr c + 0144 E4 316 clr a + 0145 9A 317 subb a,r2 + 0146 F5*00 318 mov ___fs2ulong_sloc0_1_0,a + 0148 E4 319 clr a + 0149 98 320 subb a,r0 + 014A F5*01 321 mov (___fs2ulong_sloc0_1_0 + 1),a + 014C 90s00r0A 322 mov dptr,#___fs2ulong_l_1_1 + 014F E0 323 movx a,@dptr + 0150 F5*04 324 mov ___fs2ulong_sloc1_1_0,a + 0152 A3 325 inc dptr + 0153 E0 326 movx a,@dptr + 0154 F5*05 327 mov (___fs2ulong_sloc1_1_0 + 1),a + 0156 A3 328 inc dptr + 0157 E0 329 movx a,@dptr + 0158 F5*06 330 mov (___fs2ulong_sloc1_1_0 + 2),a + 015A A3 331 inc dptr + 015B E0 332 movx a,@dptr + 015C F5*07 333 mov (___fs2ulong_sloc1_1_0 + 3),a + 015E 85*00 F0 334 mov b,___fs2ulong_sloc0_1_0 + 0161 05 F0 335 inc b + 0163 E5*07 336 mov a,(___fs2ulong_sloc1_1_0 + 3) + 0165 33 337 rlc a + 0166 92 D2 338 mov ov,c + 0168 80 16 339 sjmp 00127$ + 016A 340 00126$: + 016A A2 D2 341 mov c,ov + 016C E5*07 342 mov a,(___fs2ulong_sloc1_1_0 + 3) + 016E 13 343 rrc a + 016F F5*07 344 mov (___fs2ulong_sloc1_1_0 + 3),a + 0171 E5*06 345 mov a,(___fs2ulong_sloc1_1_0 + 2) + 0173 13 346 rrc a + 0174 F5*06 347 mov (___fs2ulong_sloc1_1_0 + 2),a + 0176 E5*05 348 mov a,(___fs2ulong_sloc1_1_0 + 1) + 0178 13 349 rrc a + 0179 F5*05 350 mov (___fs2ulong_sloc1_1_0 + 1),a + 017B E5*04 351 mov a,___fs2ulong_sloc1_1_0 + 017D 13 352 rrc a + 017E F5*04 353 mov ___fs2ulong_sloc1_1_0,a + 0180 354 00127$: + 0180 D5 F0 E7 355 djnz b,00126$ + 0183 90s00r0A 356 mov dptr,#___fs2ulong_l_1_1 + 0186 E5*04 357 mov a,___fs2ulong_sloc1_1_0 + 0188 F0 358 movx @dptr,a + 0189 A3 359 inc dptr + 018A E5*05 360 mov a,(___fs2ulong_sloc1_1_0 + 1) + 018C F0 361 movx @dptr,a + 018D A3 362 inc dptr + 018E E5*06 363 mov a,(___fs2ulong_sloc1_1_0 + 2) + 0190 F0 364 movx @dptr,a + 0191 A3 365 inc dptr + 0192 E5*07 366 mov a,(___fs2ulong_sloc1_1_0 + 3) + 0194 F0 367 movx @dptr,a + 368 ; Peephole 132 changed ljmp to sjmp + 0195 80 0A 369 sjmp 00107$ + 0197 370 00106$: + 371 ; _fs2ulong.c 94 + 372 ; Peephole 3.a changed mov to clr + 373 ; Peephole 3.b changed mov to clr + 374 ; Peephole 3.b changed mov to clr + 0197 E4 375 clr a + 0198 F5 82 376 mov dpl,a + 019A F5 83 377 mov dph,a + 019C F5 F0 378 mov b,a + 019E 02s01rFF 379 ljmp 00110$ + 01A1 380 00107$: + 381 ; _fs2ulong.c 96 + 01A1 90s00r04 382 mov dptr,#(___fs2ulong_fl1_1_1) + 01A4 E0 383 movx a,@dptr + 01A5 F5*04 384 mov ___fs2ulong_sloc1_1_0,a + 01A7 A3 385 inc dptr + 01A8 E0 386 movx a,@dptr + 01A9 F5*05 387 mov (___fs2ulong_sloc1_1_0 + 1),a + 01AB A3 388 inc dptr + 01AC E0 389 movx a,@dptr + 01AD F5*06 390 mov (___fs2ulong_sloc1_1_0 + 2),a + 01AF A3 391 inc dptr + 01B0 E0 392 movx a,@dptr + 393 ; Peephole 105 removed redundant mov + 01B1 F5*07 394 mov (___fs2ulong_sloc1_1_0 + 3),a + 01B3 23 395 rl a + 01B4 54 01 396 anl a,#0x01 + 397 ; Peephole 105 removed redundant mov + 01B6 FA 398 mov r2,a + 399 ; Peephole 110 removed ljmp by inverse jump logic + 01B7 60 29 400 jz 00112$ + 01B9 401 00128$: + 01B9 90s00r0A 402 mov dptr,#___fs2ulong_l_1_1 + 01BC E0 403 movx a,@dptr + 01BD F5*04 404 mov ___fs2ulong_sloc1_1_0,a + 01BF A3 405 inc dptr + 01C0 E0 406 movx a,@dptr + 01C1 F5*05 407 mov (___fs2ulong_sloc1_1_0 + 1),a + 01C3 A3 408 inc dptr + 01C4 E0 409 movx a,@dptr + 01C5 F5*06 410 mov (___fs2ulong_sloc1_1_0 + 2),a + 01C7 A3 411 inc dptr + 01C8 E0 412 movx a,@dptr + 01C9 F5*07 413 mov (___fs2ulong_sloc1_1_0 + 3),a + 01CB C3 414 clr c + 01CC E4 415 clr a + 01CD 95*04 416 subb a,___fs2ulong_sloc1_1_0 + 01CF F5*04 417 mov ___fs2ulong_sloc1_1_0,a + 01D1 E4 418 clr a + 01D2 95*05 419 subb a,(___fs2ulong_sloc1_1_0 + 1) + 01D4 F5*05 420 mov (___fs2ulong_sloc1_1_0 + 1),a + 01D6 E4 421 clr a + 01D7 95*06 422 subb a,(___fs2ulong_sloc1_1_0 + 2) + 01D9 F5*06 423 mov (___fs2ulong_sloc1_1_0 + 2),a + 01DB E4 424 clr a + 01DC 95*07 425 subb a,(___fs2ulong_sloc1_1_0 + 3) + 01DE F5*07 426 mov (___fs2ulong_sloc1_1_0 + 3),a + 427 ; Peephole 132 changed ljmp to sjmp + 01E0 80 12 428 sjmp 00113$ + 01E2 429 00112$: + 01E2 90s00r0A 430 mov dptr,#___fs2ulong_l_1_1 + 01E5 E0 431 movx a,@dptr + 01E6 F5*04 432 mov ___fs2ulong_sloc1_1_0,a + 01E8 A3 433 inc dptr + 01E9 E0 434 movx a,@dptr + 01EA F5*05 435 mov (___fs2ulong_sloc1_1_0 + 1),a + 01EC A3 436 inc dptr + 01ED E0 437 movx a,@dptr + 01EE F5*06 438 mov (___fs2ulong_sloc1_1_0 + 2),a + 01F0 A3 439 inc dptr + 01F1 E0 440 movx a,@dptr + 01F2 F5*07 441 mov (___fs2ulong_sloc1_1_0 + 3),a + 01F4 442 00113$: + 01F4 85*04 82 443 mov dpl,___fs2ulong_sloc1_1_0 + 01F7 85*05 83 444 mov dph,(___fs2ulong_sloc1_1_0 + 1) + 01FA 85*06 F0 445 mov b,(___fs2ulong_sloc1_1_0 + 2) + 01FD E5*07 446 mov a,(___fs2ulong_sloc1_1_0 + 3) + 01FF 447 00110$: + 01FF 448 C$_fs2ulong.c$97$1$1 ==. + 01FF 449 XG$__fs2ulong$0$0 ==. + 01FF 22 450 ret + 451 .area CSEG (CODE) diff --git a/device/lib/_fs2ulong.sym b/device/lib/_fs2ulong.sym new file mode 100644 index 00000000..ef9ff0b2 --- /dev/null +++ b/device/lib/_fs2ulong.sym @@ -0,0 +1,703 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fs2ulong$100 0027 GR + 7 A$_fs2ulong$101 0028 GR + 7 A$_fs2ulong$102 002B GR + 7 A$_fs2ulong$103 002C GR + 7 A$_fs2ulong$104 002D GR + 7 A$_fs2ulong$105 002E GR + 7 A$_fs2ulong$106 002F GR + 7 A$_fs2ulong$107 0030 GR + 7 A$_fs2ulong$108 0031 GR + 7 A$_fs2ulong$109 0032 GR + 7 A$_fs2ulong$110 0033 GR + 7 A$_fs2ulong$111 0034 GR + 7 A$_fs2ulong$112 0035 GR + 7 A$_fs2ulong$114 0036 GR + 7 A$_fs2ulong$115 0039 GR + 7 A$_fs2ulong$116 003A GR + 7 A$_fs2ulong$117 003B GR + 7 A$_fs2ulong$118 003C GR + 7 A$_fs2ulong$119 003D GR + 7 A$_fs2ulong$120 003E GR + 7 A$_fs2ulong$121 003F GR + 7 A$_fs2ulong$122 0040 GR + 7 A$_fs2ulong$123 0041 GR + 7 A$_fs2ulong$124 0042 GR + 7 A$_fs2ulong$125 0043 GR + 7 A$_fs2ulong$126 0044 GR + 7 A$_fs2ulong$127 0045 GR + 7 A$_fs2ulong$128 0046 GR + 7 A$_fs2ulong$129 0047 GR + 7 A$_fs2ulong$131 0048 GR + 7 A$_fs2ulong$137 004A GR + 7 A$_fs2ulong$138 004B GR + 7 A$_fs2ulong$139 004D GR + 7 A$_fs2ulong$140 004F GR + 7 A$_fs2ulong$141 0051 GR + 7 A$_fs2ulong$144 0054 GR + 7 A$_fs2ulong$145 0057 GR + 7 A$_fs2ulong$146 0058 GR + 7 A$_fs2ulong$147 0059 GR + 7 A$_fs2ulong$148 005A GR + 7 A$_fs2ulong$149 005B GR + 7 A$_fs2ulong$150 005C GR + 7 A$_fs2ulong$151 005D GR + 7 A$_fs2ulong$152 005E GR + 7 A$_fs2ulong$153 005F GR + 7 A$_fs2ulong$154 0060 GR + 7 A$_fs2ulong$155 0061 GR + 7 A$_fs2ulong$156 0062 GR + 7 A$_fs2ulong$157 0064 GR + 7 A$_fs2ulong$158 0065 GR + 7 A$_fs2ulong$159 0067 GR + 7 A$_fs2ulong$160 0068 GR + 7 A$_fs2ulong$161 0069 GR + 7 A$_fs2ulong$162 006A GR + 7 A$_fs2ulong$163 006B GR + 7 A$_fs2ulong$164 006C GR + 7 A$_fs2ulong$165 006E GR + 7 A$_fs2ulong$166 0071 GR + 7 A$_fs2ulong$168 0073 GR + 7 A$_fs2ulong$169 0074 GR + 7 A$_fs2ulong$170 0075 GR + 7 A$_fs2ulong$171 0077 GR + 7 A$_fs2ulong$172 0078 GR + 7 A$_fs2ulong$173 0079 GR + 7 A$_fs2ulong$174 007A GR + 7 A$_fs2ulong$175 007D GR + 7 A$_fs2ulong$176 007F GR + 7 A$_fs2ulong$177 0080 GR + 7 A$_fs2ulong$178 0082 GR + 7 A$_fs2ulong$179 0084 GR + 7 A$_fs2ulong$180 0085 GR + 7 A$_fs2ulong$181 0088 GR + 7 A$_fs2ulong$182 0089 GR + 7 A$_fs2ulong$183 008A GR + 7 A$_fs2ulong$184 008B GR + 7 A$_fs2ulong$185 008C GR + 7 A$_fs2ulong$187 008D GR + 7 A$_fs2ulong$188 0090 GR + 7 A$_fs2ulong$189 0091 GR + 7 A$_fs2ulong$190 0092 GR + 7 A$_fs2ulong$191 0093 GR + 7 A$_fs2ulong$192 0094 GR + 7 A$_fs2ulong$193 0095 GR + 7 A$_fs2ulong$194 0096 GR + 7 A$_fs2ulong$195 0097 GR + 7 A$_fs2ulong$196 0098 GR + 7 A$_fs2ulong$197 0099 GR + 7 A$_fs2ulong$198 009A GR + 7 A$_fs2ulong$199 009B GR + 7 A$_fs2ulong$200 009E GR + 7 A$_fs2ulong$201 00A0 GR + 7 A$_fs2ulong$202 00A3 GR + 7 A$_fs2ulong$203 00A4 GR + 7 A$_fs2ulong$204 00A5 GR + 7 A$_fs2ulong$205 00A6 GR + 7 A$_fs2ulong$206 00A7 GR + 7 A$_fs2ulong$207 00A8 GR + 7 A$_fs2ulong$208 00AA GR + 7 A$_fs2ulong$209 00AB GR + 7 A$_fs2ulong$210 00AC GR + 7 A$_fs2ulong$211 00AD GR + 7 A$_fs2ulong$212 00AE GR + 7 A$_fs2ulong$213 00AF GR + 7 A$_fs2ulong$215 00B0 GR + 7 A$_fs2ulong$216 00B3 GR + 7 A$_fs2ulong$217 00B4 GR + 7 A$_fs2ulong$218 00B5 GR + 7 A$_fs2ulong$219 00B6 GR + 7 A$_fs2ulong$220 00B7 GR + 7 A$_fs2ulong$221 00B8 GR + 7 A$_fs2ulong$223 00B9 GR + 7 A$_fs2ulong$224 00BA GR + 7 A$_fs2ulong$226 00BB GR + 7 A$_fs2ulong$227 00BD GR + 7 A$_fs2ulong$228 00BF GR + 7 A$_fs2ulong$229 00C2 GR + 7 A$_fs2ulong$231 00C4 GR + 7 A$_fs2ulong$234 00C6 GR + 7 A$_fs2ulong$235 00C9 GR + 7 A$_fs2ulong$236 00CA GR + 7 A$_fs2ulong$237 00CB GR + 7 A$_fs2ulong$238 00CC GR + 7 A$_fs2ulong$239 00CD GR + 7 A$_fs2ulong$240 00CE GR + 7 A$_fs2ulong$241 00CF GR + 7 A$_fs2ulong$242 00D0 GR + 7 A$_fs2ulong$243 00D1 GR + 7 A$_fs2ulong$244 00D2 GR + 7 A$_fs2ulong$246 00D3 GR + 7 A$_fs2ulong$247 00D4 GR + 7 A$_fs2ulong$248 00D5 GR + 7 A$_fs2ulong$249 00D7 GR + 7 A$_fs2ulong$250 00D8 GR + 7 A$_fs2ulong$251 00DB GR + 7 A$_fs2ulong$252 00DD GR + 7 A$_fs2ulong$253 00E0 GR + 7 A$_fs2ulong$254 00E3 GR + 7 A$_fs2ulong$255 00E6 GR + 7 A$_fs2ulong$256 00E9 GR + 7 A$_fs2ulong$257 00EC GR + 7 A$_fs2ulong$258 00EF GR + 7 A$_fs2ulong$259 00F1 GR + 7 A$_fs2ulong$262 00F4 GR + 7 A$_fs2ulong$263 00F7 GR + 7 A$_fs2ulong$264 00F8 GR + 7 A$_fs2ulong$265 00F9 GR + 7 A$_fs2ulong$266 00FA GR + 7 A$_fs2ulong$268 00FB GR + 7 A$_fs2ulong$269 00FC GR + 7 A$_fs2ulong$270 00FF GR + 7 A$_fs2ulong$272 0102 GR + 7 A$_fs2ulong$273 0105 GR + 7 A$_fs2ulong$274 0106 GR + 7 A$_fs2ulong$275 0107 GR + 7 A$_fs2ulong$276 0108 GR + 7 A$_fs2ulong$277 0109 GR + 7 A$_fs2ulong$278 010A GR + 7 A$_fs2ulong$279 010B GR + 7 A$_fs2ulong$280 010D GR + 7 A$_fs2ulong$282 010E GR + 7 A$_fs2ulong$283 0110 GR + 7 A$_fs2ulong$284 0112 GR + 7 A$_fs2ulong$285 0115 GR + 7 A$_fs2ulong$286 0117 GR + 7 A$_fs2ulong$287 0119 GR + 7 A$_fs2ulong$289 011C GR + 7 A$_fs2ulong$290 011F GR + 7 A$_fs2ulong$291 0120 GR + 7 A$_fs2ulong$292 0122 GR + 7 A$_fs2ulong$293 0123 GR + 7 A$_fs2ulong$294 0124 GR + 7 A$_fs2ulong$295 0126 GR + 7 A$_fs2ulong$296 0127 GR + 7 A$_fs2ulong$297 0128 GR + 7 A$_fs2ulong$298 012A GR + 7 A$_fs2ulong$299 012B GR + 7 A$_fs2ulong$300 012C GR + 7 A$_fs2ulong$301 012E GR + 7 A$_fs2ulong$302 0130 GR + 7 A$_fs2ulong$303 0132 GR + 7 A$_fs2ulong$304 0134 GR + 7 A$_fs2ulong$305 0136 GR + 7 A$_fs2ulong$306 0138 GR + 7 A$_fs2ulong$309 013B GR + 7 A$_fs2ulong$310 013E GR + 7 A$_fs2ulong$311 013F GR + 7 A$_fs2ulong$312 0140 GR + 7 A$_fs2ulong$313 0141 GR + 7 A$_fs2ulong$314 0142 GR + 7 A$_fs2ulong$315 0143 GR + 7 A$_fs2ulong$316 0144 GR + 7 A$_fs2ulong$317 0145 GR + 7 A$_fs2ulong$318 0146 GR + 7 A$_fs2ulong$319 0148 GR + 7 A$_fs2ulong$320 0149 GR + 7 A$_fs2ulong$321 014A GR + 7 A$_fs2ulong$322 014C GR + 7 A$_fs2ulong$323 014F GR + 7 A$_fs2ulong$324 0150 GR + 7 A$_fs2ulong$325 0152 GR + 7 A$_fs2ulong$326 0153 GR + 7 A$_fs2ulong$327 0154 GR + 7 A$_fs2ulong$328 0156 GR + 7 A$_fs2ulong$329 0157 GR + 7 A$_fs2ulong$330 0158 GR + 7 A$_fs2ulong$331 015A GR + 7 A$_fs2ulong$332 015B GR + 7 A$_fs2ulong$333 015C GR + 7 A$_fs2ulong$334 015E GR + 7 A$_fs2ulong$335 0161 GR + 7 A$_fs2ulong$336 0163 GR + 7 A$_fs2ulong$337 0165 GR + 7 A$_fs2ulong$338 0166 GR + 7 A$_fs2ulong$339 0168 GR + 7 A$_fs2ulong$341 016A GR + 7 A$_fs2ulong$342 016C GR + 7 A$_fs2ulong$343 016E GR + 7 A$_fs2ulong$344 016F GR + 7 A$_fs2ulong$345 0171 GR + 7 A$_fs2ulong$346 0173 GR + 7 A$_fs2ulong$347 0174 GR + 7 A$_fs2ulong$348 0176 GR + 7 A$_fs2ulong$349 0178 GR + 7 A$_fs2ulong$350 0179 GR + 7 A$_fs2ulong$351 017B GR + 7 A$_fs2ulong$352 017D GR + 7 A$_fs2ulong$353 017E GR + 7 A$_fs2ulong$355 0180 GR + 7 A$_fs2ulong$356 0183 GR + 7 A$_fs2ulong$357 0186 GR + 7 A$_fs2ulong$358 0188 GR + 7 A$_fs2ulong$359 0189 GR + 7 A$_fs2ulong$360 018A GR + 7 A$_fs2ulong$361 018C GR + 7 A$_fs2ulong$362 018D GR + 7 A$_fs2ulong$363 018E GR + 7 A$_fs2ulong$364 0190 GR + 7 A$_fs2ulong$365 0191 GR + 7 A$_fs2ulong$366 0192 GR + 7 A$_fs2ulong$367 0194 GR + 7 A$_fs2ulong$369 0195 GR + 7 A$_fs2ulong$375 0197 GR + 7 A$_fs2ulong$376 0198 GR + 7 A$_fs2ulong$377 019A GR + 7 A$_fs2ulong$378 019C GR + 7 A$_fs2ulong$379 019E GR + 7 A$_fs2ulong$382 01A1 GR + 7 A$_fs2ulong$383 01A4 GR + 7 A$_fs2ulong$384 01A5 GR + 7 A$_fs2ulong$385 01A7 GR + 7 A$_fs2ulong$386 01A8 GR + 7 A$_fs2ulong$387 01A9 GR + 7 A$_fs2ulong$388 01AB GR + 7 A$_fs2ulong$389 01AC GR + 7 A$_fs2ulong$390 01AD GR + 7 A$_fs2ulong$391 01AF GR + 7 A$_fs2ulong$392 01B0 GR + 7 A$_fs2ulong$394 01B1 GR + 7 A$_fs2ulong$395 01B3 GR + 7 A$_fs2ulong$396 01B4 GR + 7 A$_fs2ulong$398 01B6 GR + 7 A$_fs2ulong$400 01B7 GR + 7 A$_fs2ulong$402 01B9 GR + 7 A$_fs2ulong$403 01BC GR + 7 A$_fs2ulong$404 01BD GR + 7 A$_fs2ulong$405 01BF GR + 7 A$_fs2ulong$406 01C0 GR + 7 A$_fs2ulong$407 01C1 GR + 7 A$_fs2ulong$408 01C3 GR + 7 A$_fs2ulong$409 01C4 GR + 7 A$_fs2ulong$410 01C5 GR + 7 A$_fs2ulong$411 01C7 GR + 7 A$_fs2ulong$412 01C8 GR + 7 A$_fs2ulong$413 01C9 GR + 7 A$_fs2ulong$414 01CB GR + 7 A$_fs2ulong$415 01CC GR + 7 A$_fs2ulong$416 01CD GR + 7 A$_fs2ulong$417 01CF GR + 7 A$_fs2ulong$418 01D1 GR + 7 A$_fs2ulong$419 01D2 GR + 7 A$_fs2ulong$420 01D4 GR + 7 A$_fs2ulong$421 01D6 GR + 7 A$_fs2ulong$422 01D7 GR + 7 A$_fs2ulong$423 01D9 GR + 7 A$_fs2ulong$424 01DB GR + 7 A$_fs2ulong$425 01DC GR + 7 A$_fs2ulong$426 01DE GR + 7 A$_fs2ulong$428 01E0 GR + 7 A$_fs2ulong$430 01E2 GR + 7 A$_fs2ulong$431 01E5 GR + 7 A$_fs2ulong$432 01E6 GR + 7 A$_fs2ulong$433 01E8 GR + 7 A$_fs2ulong$434 01E9 GR + 7 A$_fs2ulong$435 01EA GR + 7 A$_fs2ulong$436 01EC GR + 7 A$_fs2ulong$437 01ED GR + 7 A$_fs2ulong$438 01EE GR + 7 A$_fs2ulong$439 01F0 GR + 7 A$_fs2ulong$440 01F1 GR + 7 A$_fs2ulong$441 01F2 GR + 7 A$_fs2ulong$443 01F4 GR + 7 A$_fs2ulong$444 01F7 GR + 7 A$_fs2ulong$445 01FA GR + 7 A$_fs2ulong$446 01FD GR + 7 A$_fs2ulong$450 01FF GR + 7 A$_fs2ulong$72 0000 GR + 7 A$_fs2ulong$73 0002 GR + 7 A$_fs2ulong$74 0004 GR + 7 A$_fs2ulong$75 0006 GR + 7 A$_fs2ulong$76 0008 GR + 7 A$_fs2ulong$77 000B GR + 7 A$_fs2ulong$78 000D GR + 7 A$_fs2ulong$79 000E GR + 7 A$_fs2ulong$80 0010 GR + 7 A$_fs2ulong$81 0011 GR + 7 A$_fs2ulong$82 0012 GR + 7 A$_fs2ulong$83 0014 GR + 7 A$_fs2ulong$84 0015 GR + 7 A$_fs2ulong$85 0016 GR + 7 A$_fs2ulong$86 0018 GR + 7 A$_fs2ulong$87 0019 GR + 7 A$_fs2ulong$89 001A GR + 7 A$_fs2ulong$90 001D GR + 7 A$_fs2ulong$91 001E GR + 7 A$_fs2ulong$92 001F GR + 7 A$_fs2ulong$93 0020 GR + 7 A$_fs2ulong$94 0021 GR + 7 A$_fs2ulong$95 0022 GR + 7 A$_fs2ulong$96 0023 GR + 7 A$_fs2ulong$97 0024 GR + 7 A$_fs2ulong$98 0025 GR + 7 A$_fs2ulong$99 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fs2ulong.c$97$1$1 = 01FF GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fs2ulong$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fs2ulong$0$0 = 01FF GR + 7 ___fs2ulong 0000 GR + 5 ___fs2ulong_a1_1_1 0000 R + 5 ___fs2ulong_exp_1_1 0008 R + 5 ___fs2ulong_fl1_1_1 0004 R + 5 ___fs2ulong_l_1_1 000A R + 1 ___fs2ulong_sloc0_1_0 0000 R + 1 ___fs2ulong_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 200 flags 20 diff --git a/device/lib/_fsadd.c b/device/lib/_fsadd.c new file mode 100644 index 00000000..be0b44fc --- /dev/null +++ b/device/lib/_fsadd.c @@ -0,0 +1,102 @@ +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int)0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; +/* add two floats */ +float +__fsadd (float a1, float a2) +{ + volatile long mant1, mant2; + volatile union float_long fl1, fl2; + volatile int exp1, exp2; + volatile long sign = 0; + + fl1.f = a1; + fl2.f = a2; + + /* check for zero args */ + if (!fl1.l) + return (fl2.f); + if (!fl2.l) + return (fl1.f); + + exp1 = EXP (fl1.l); + exp2 = EXP (fl2.l); + + if (exp1 > exp2 + 25) + return (fl1.l); + if (exp2 > exp1 + 25) + return (fl2.l); + + /* do everything in excess precision so's we can round later */ + mant1 = MANT (fl1.l) << 6; + mant2 = MANT (fl2.l) << 6; + + if (SIGN (fl1.l)) + mant1 = -mant1; + if (SIGN (fl2.l)) + mant2 = -mant2; + + if (exp1 > exp2) + { + mant2 >>= exp1 - exp2; + } + else + { + mant1 >>= exp2 - exp1; + exp1 = exp2; + } + mant1 += mant2; + + if (mant1 < 0) + { + mant1 = -mant1; + sign = SIGNBIT; + } + else if (!mant1) + return (0); + + /* normalize up */ + while (!(mant1 & (unsigned long) 0xE0000000)) + { + mant1 <<= 1; + exp1--; + } + + /* normalize down? */ + if (mant1 & (unsigned long)(1 << 30)) + { + mant1 >>= 1 ; + exp1++; + } + + /* round to even */ + mant1 += (mant1 & (unsigned long)0x40) ? (unsigned long) 0x20 : (unsigned long) 0x1F; + + /* normalize down? */ + if (mant1 & (unsigned long)(1 << 30)) + { + mant1 >>= 1; + exp1++; + } + + /* lose extra precision */ + mant1 >>= 6; + + /* turn off hidden bit */ + mant1 &= ~HIDDEN; + + /* pack up and go home */ + fl1.l = PACK (sign, (unsigned long) exp1, mant1); + return (fl1.f); +} diff --git a/device/lib/_fsadd.lst b/device/lib/_fsadd.lst new file mode 100644 index 00000000..093579ae --- /dev/null +++ b/device/lib/_fsadd.lst @@ -0,0 +1,1406 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:25 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fsadd + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fsadd_PARM_2 + 11 .globl ___fsadd + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 ___fsadd_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 ___fsadd_sloc1_1_0: + 0004 25 .ds 0x0002 + 0006 26 ___fsadd_sloc2_1_0: + 0006 27 .ds 0x0004 + 28 ;-------------------------------------------------------- + 29 ; overlayable items in internal ram + 30 ;-------------------------------------------------------- + 31 .area OSEG (OVR,DATA) + 32 ;-------------------------------------------------------- + 33 ; indirectly addressable internal ram data + 34 ;-------------------------------------------------------- + 35 .area ISEG (DATA) + 36 ;-------------------------------------------------------- + 37 ; bit data + 38 ;-------------------------------------------------------- + 39 .area BSEG (BIT) + 40 ;-------------------------------------------------------- + 41 ; external ram data + 42 ;-------------------------------------------------------- + 43 .area XSEG (XDATA) + 0000 44 ___fsadd_PARM_2: + 0000 45 .ds 0x0004 + 0004 46 ___fsadd_a1_1_1: + 0004 47 .ds 0x0004 + 0008 48 ___fsadd_mant1_1_1: + 0008 49 .ds 0x0004 + 000C 50 ___fsadd_mant2_1_1: + 000C 51 .ds 0x0004 + 0010 52 ___fsadd_fl1_1_1: + 0010 53 .ds 0x0004 + 0014 54 ___fsadd_fl2_1_1: + 0014 55 .ds 0x0004 + 0018 56 ___fsadd_exp1_1_1: + 0018 57 .ds 0x0002 + 001A 58 ___fsadd_exp2_1_1: + 001A 59 .ds 0x0002 + 001C 60 ___fsadd_sign_1_1: + 001C 61 .ds 0x0004 + 62 ;-------------------------------------------------------- + 63 ; global & static initialisations + 64 ;-------------------------------------------------------- + 65 .area GSINIT (CODE) + 66 ;-------------------------------------------------------- + 67 ; code + 68 ;-------------------------------------------------------- + 69 .area CSEG (CODE) + 0000 70 G$__fsadd$0$0 ==. + 71 ; _fsadd.c 17 + 72 ; ----------------------------------------- + 73 ; function __fsadd + 74 ; ----------------------------------------- + 0000 75 ___fsadd: + 0002 76 ar2 = 0x02 + 0003 77 ar3 = 0x03 + 0004 78 ar4 = 0x04 + 0005 79 ar5 = 0x05 + 0006 80 ar6 = 0x06 + 0007 81 ar7 = 0x07 + 0000 82 ar0 = 0x00 + 0001 83 ar1 = 0x01 + 84 ; _fsadd.c 101 + 0000 C0 E0 85 push acc + 0002 C0 F0 86 push b + 0004 C0 83 87 push dph + 0006 C0 82 88 push dpl + 0008 90s00r04 89 mov dptr,#___fsadd_a1_1_1 + 000B D0 E0 90 pop acc + 000D F0 91 movx @dptr,a + 000E D0 E0 92 pop acc + 0010 A3 93 inc dptr + 0011 F0 94 movx @dptr,a + 0012 D0 E0 95 pop acc + 0014 A3 96 inc dptr + 0015 F0 97 movx @dptr,a + 0016 D0 E0 98 pop acc + 0018 A3 99 inc dptr + 0019 F0 100 movx @dptr,a + 101 ; _fsadd.c 22 + 001A 90s00r1C 102 mov dptr,#___fsadd_sign_1_1 + 001D E4 103 clr a + 001E A3 104 inc dptr + 001F A3 105 inc dptr + 0020 A3 106 inc dptr + 0021 F0 107 movx @dptr,a + 0022 12s00r00 108 lcall __decdptr + 0025 F0 109 movx @dptr,a + 0026 12s00r00 110 lcall __decdptr + 0029 F0 111 movx @dptr,a + 002A 12s00r00 112 lcall __decdptr + 002D F0 113 movx @dptr,a + 114 ; _fsadd.c 24 + 002E 90s00r04 115 mov dptr,#___fsadd_a1_1_1 + 0031 E0 116 movx a,@dptr + 0032 FA 117 mov r2,a + 0033 A3 118 inc dptr + 0034 E0 119 movx a,@dptr + 0035 FB 120 mov r3,a + 0036 A3 121 inc dptr + 0037 E0 122 movx a,@dptr + 0038 FC 123 mov r4,a + 0039 A3 124 inc dptr + 003A E0 125 movx a,@dptr + 003B FD 126 mov r5,a + 003C 90s00r10 127 mov dptr,#(___fsadd_fl1_1_1) + 003F EA 128 mov a,r2 + 0040 F0 129 movx @dptr,a + 0041 A3 130 inc dptr + 0042 EB 131 mov a,r3 + 0043 F0 132 movx @dptr,a + 0044 A3 133 inc dptr + 0045 EC 134 mov a,r4 + 0046 F0 135 movx @dptr,a + 0047 A3 136 inc dptr + 0048 ED 137 mov a,r5 + 0049 F0 138 movx @dptr,a + 139 ; _fsadd.c 25 + 004A 90s00r00 140 mov dptr,#___fsadd_PARM_2 + 004D E0 141 movx a,@dptr + 004E FA 142 mov r2,a + 004F A3 143 inc dptr + 0050 E0 144 movx a,@dptr + 0051 FB 145 mov r3,a + 0052 A3 146 inc dptr + 0053 E0 147 movx a,@dptr + 0054 FC 148 mov r4,a + 0055 A3 149 inc dptr + 0056 E0 150 movx a,@dptr + 0057 FD 151 mov r5,a + 0058 90s00r14 152 mov dptr,#(___fsadd_fl2_1_1) + 005B EA 153 mov a,r2 + 005C F0 154 movx @dptr,a + 005D A3 155 inc dptr + 005E EB 156 mov a,r3 + 005F F0 157 movx @dptr,a + 0060 A3 158 inc dptr + 0061 EC 159 mov a,r4 + 0062 F0 160 movx @dptr,a + 0063 A3 161 inc dptr + 0064 ED 162 mov a,r5 + 0065 F0 163 movx @dptr,a + 164 ; _fsadd.c 28 + 0066 90s00r10 165 mov dptr,#(___fsadd_fl1_1_1) + 0069 E0 166 movx a,@dptr + 006A FA 167 mov r2,a + 006B A3 168 inc dptr + 006C E0 169 movx a,@dptr + 006D FB 170 mov r3,a + 006E A3 171 inc dptr + 006F E0 172 movx a,@dptr + 0070 FC 173 mov r4,a + 0071 A3 174 inc dptr + 0072 E0 175 movx a,@dptr + 0073 FD 176 mov r5,a + 0074 EA 177 mov a,r2 + 0075 4B 178 orl a,r3 + 0076 4C 179 orl a,r4 + 0077 4D 180 orl a,r5 + 181 ; Peephole 109 removed ljmp by inverse jump logic + 0078 70 17 182 jnz 00102$ + 007A 183 00146$: + 184 ; _fsadd.c 29 + 007A 90s00r14 185 mov dptr,#(___fsadd_fl2_1_1) + 007D E0 186 movx a,@dptr + 007E FA 187 mov r2,a + 007F A3 188 inc dptr + 0080 E0 189 movx a,@dptr + 0081 FB 190 mov r3,a + 0082 A3 191 inc dptr + 0083 E0 192 movx a,@dptr + 0084 FC 193 mov r4,a + 0085 A3 194 inc dptr + 0086 E0 195 movx a,@dptr + 196 ; Peephole 191 removed redundant mov + 0087 FD 197 mov r5,a + 0088 8A 82 198 mov dpl,r2 + 008A 8B 83 199 mov dph,r3 + 008C 8C F0 200 mov b,r4 + 008E 02s07r14 201 ljmp 00128$ + 0091 202 00102$: + 203 ; _fsadd.c 30 + 0091 90s00r14 204 mov dptr,#(___fsadd_fl2_1_1) + 0094 E0 205 movx a,@dptr + 0095 FA 206 mov r2,a + 0096 A3 207 inc dptr + 0097 E0 208 movx a,@dptr + 0098 FB 209 mov r3,a + 0099 A3 210 inc dptr + 009A E0 211 movx a,@dptr + 009B FC 212 mov r4,a + 009C A3 213 inc dptr + 009D E0 214 movx a,@dptr + 009E FD 215 mov r5,a + 009F EA 216 mov a,r2 + 00A0 4B 217 orl a,r3 + 00A1 4C 218 orl a,r4 + 00A2 4D 219 orl a,r5 + 220 ; Peephole 109 removed ljmp by inverse jump logic + 00A3 70 17 221 jnz 00104$ + 00A5 222 00147$: + 223 ; _fsadd.c 31 + 00A5 90s00r10 224 mov dptr,#(___fsadd_fl1_1_1) + 00A8 E0 225 movx a,@dptr + 00A9 FA 226 mov r2,a + 00AA A3 227 inc dptr + 00AB E0 228 movx a,@dptr + 00AC FB 229 mov r3,a + 00AD A3 230 inc dptr + 00AE E0 231 movx a,@dptr + 00AF FC 232 mov r4,a + 00B0 A3 233 inc dptr + 00B1 E0 234 movx a,@dptr + 235 ; Peephole 191 removed redundant mov + 00B2 FD 236 mov r5,a + 00B3 8A 82 237 mov dpl,r2 + 00B5 8B 83 238 mov dph,r3 + 00B7 8C F0 239 mov b,r4 + 00B9 02s07r14 240 ljmp 00128$ + 00BC 241 00104$: + 242 ; _fsadd.c 33 + 00BC 90s00r10 243 mov dptr,#(___fsadd_fl1_1_1) + 00BF E0 244 movx a,@dptr + 00C0 FA 245 mov r2,a + 00C1 A3 246 inc dptr + 00C2 E0 247 movx a,@dptr + 00C3 FB 248 mov r3,a + 00C4 A3 249 inc dptr + 00C5 E0 250 movx a,@dptr + 00C6 FC 251 mov r4,a + 00C7 A3 252 inc dptr + 00C8 E0 253 movx a,@dptr + 00C9 FD 254 mov r5,a + 00CA 8C 02 255 mov ar2,r4 + 00CC ED 256 mov a,r5 + 00CD A2 E7 257 mov c,acc.7 + 00CF CA 258 xch a,r2 + 00D0 33 259 rlc a + 00D1 CA 260 xch a,r2 + 00D2 33 261 rlc a + 00D3 CA 262 xch a,r2 + 00D4 54 01 263 anl a,#0x01 + 00D6 30 E0 02 264 jnb acc.0,00148$ + 00D9 44 FE 265 orl a,#0xfe + 00DB 266 00148$: + 00DB FB 267 mov r3,a + 00DC 33 268 rlc a + 00DD 95 E0 269 subb a,acc + 00DF FC 270 mov r4,a + 00E0 FD 271 mov r5,a + 00E1 90s00r18 272 mov dptr,#___fsadd_exp1_1_1 + 00E4 EA 273 mov a,r2 + 00E5 F0 274 movx @dptr,a + 00E6 A3 275 inc dptr + 276 ; Peephole 180 changed mov to clr + 00E7 E4 277 clr a + 00E8 F0 278 movx @dptr,a + 279 ; _fsadd.c 34 + 00E9 90s00r14 280 mov dptr,#(___fsadd_fl2_1_1) + 00EC E0 281 movx a,@dptr + 00ED FA 282 mov r2,a + 00EE A3 283 inc dptr + 00EF E0 284 movx a,@dptr + 00F0 FB 285 mov r3,a + 00F1 A3 286 inc dptr + 00F2 E0 287 movx a,@dptr + 00F3 FE 288 mov r6,a + 00F4 A3 289 inc dptr + 00F5 E0 290 movx a,@dptr + 00F6 FF 291 mov r7,a + 00F7 8E 02 292 mov ar2,r6 + 00F9 EF 293 mov a,r7 + 00FA A2 E7 294 mov c,acc.7 + 00FC CA 295 xch a,r2 + 00FD 33 296 rlc a + 00FE CA 297 xch a,r2 + 00FF 33 298 rlc a + 0100 CA 299 xch a,r2 + 0101 54 01 300 anl a,#0x01 + 0103 30 E0 02 301 jnb acc.0,00149$ + 0106 44 FE 302 orl a,#0xfe + 0108 303 00149$: + 0108 FB 304 mov r3,a + 0109 33 305 rlc a + 010A 95 E0 306 subb a,acc + 010C FE 307 mov r6,a + 010D FF 308 mov r7,a + 010E 90s00r1A 309 mov dptr,#___fsadd_exp2_1_1 + 0111 EA 310 mov a,r2 + 0112 F0 311 movx @dptr,a + 0113 A3 312 inc dptr + 313 ; Peephole 180 changed mov to clr + 0114 E4 314 clr a + 0115 F0 315 movx @dptr,a + 316 ; _fsadd.c 36 + 0116 90s00r1A 317 mov dptr,#___fsadd_exp2_1_1 + 0119 E0 318 movx a,@dptr + 011A FA 319 mov r2,a + 011B A3 320 inc dptr + 011C E0 321 movx a,@dptr + 011D FB 322 mov r3,a + 011E 74 19 323 mov a,#0x19 + 0120 2A 324 add a,r2 + 0121 FA 325 mov r2,a + 326 ; Peephole 180 changed mov to clr + 0122 E4 327 clr a + 0123 3B 328 addc a,r3 + 0124 FB 329 mov r3,a + 0125 90s00r18 330 mov dptr,#___fsadd_exp1_1_1 + 0128 E0 331 movx a,@dptr + 0129 F8 332 mov r0,a + 012A A3 333 inc dptr + 012B E0 334 movx a,@dptr + 012C F9 335 mov r1,a + 012D C3 336 clr c + 012E EA 337 mov a,r2 + 012F 98 338 subb a,r0 + 0130 EB 339 mov a,r3 + 0131 64 80 340 xrl a,#0x80 + 0133 89 F0 341 mov b,r1 + 0135 63 F0 80 342 xrl b,#0x80 + 0138 95 F0 343 subb a,b + 344 ; Peephole 108 removed ljmp by inverse jump logic + 013A 50 27 345 jnc 00106$ + 013C 346 00150$: + 347 ; _fsadd.c 37 + 013C 90s00r10 348 mov dptr,#(___fsadd_fl1_1_1) + 013F E0 349 movx a,@dptr + 0140 FA 350 mov r2,a + 0141 A3 351 inc dptr + 0142 E0 352 movx a,@dptr + 0143 FB 353 mov r3,a + 0144 A3 354 inc dptr + 0145 E0 355 movx a,@dptr + 0146 F8 356 mov r0,a + 0147 A3 357 inc dptr + 0148 E0 358 movx a,@dptr + 359 ; Peephole 191 removed redundant mov + 0149 F9 360 mov r1,a + 014A 8A 82 361 mov dpl,r2 + 014C 8B 83 362 mov dph,r3 + 014E 88 F0 363 mov b,r0 + 0150 12s00r00 364 lcall ___long2fs + 0153 AA 82 365 mov r2,dpl + 0155 AB 83 366 mov r3,dph + 0157 A8 F0 367 mov r0,b + 368 ; Peephole 191 removed redundant mov + 0159 F9 369 mov r1,a + 015A 8A 82 370 mov dpl,r2 + 015C 8B 83 371 mov dph,r3 + 015E 88 F0 372 mov b,r0 + 0160 02s07r14 373 ljmp 00128$ + 0163 374 00106$: + 375 ; _fsadd.c 38 + 0163 90s00r18 376 mov dptr,#___fsadd_exp1_1_1 + 0166 E0 377 movx a,@dptr + 0167 FA 378 mov r2,a + 0168 A3 379 inc dptr + 0169 E0 380 movx a,@dptr + 016A FB 381 mov r3,a + 016B 74 19 382 mov a,#0x19 + 016D 2A 383 add a,r2 + 016E FA 384 mov r2,a + 385 ; Peephole 180 changed mov to clr + 016F E4 386 clr a + 0170 3B 387 addc a,r3 + 0171 FB 388 mov r3,a + 0172 90s00r1A 389 mov dptr,#___fsadd_exp2_1_1 + 0175 E0 390 movx a,@dptr + 0176 F8 391 mov r0,a + 0177 A3 392 inc dptr + 0178 E0 393 movx a,@dptr + 0179 F9 394 mov r1,a + 017A C3 395 clr c + 017B EA 396 mov a,r2 + 017C 98 397 subb a,r0 + 017D EB 398 mov a,r3 + 017E 64 80 399 xrl a,#0x80 + 0180 89 F0 400 mov b,r1 + 0182 63 F0 80 401 xrl b,#0x80 + 0185 95 F0 402 subb a,b + 403 ; Peephole 108 removed ljmp by inverse jump logic + 0187 50 27 404 jnc 00108$ + 0189 405 00151$: + 406 ; _fsadd.c 39 + 0189 90s00r14 407 mov dptr,#(___fsadd_fl2_1_1) + 018C E0 408 movx a,@dptr + 018D FA 409 mov r2,a + 018E A3 410 inc dptr + 018F E0 411 movx a,@dptr + 0190 FB 412 mov r3,a + 0191 A3 413 inc dptr + 0192 E0 414 movx a,@dptr + 0193 F8 415 mov r0,a + 0194 A3 416 inc dptr + 0195 E0 417 movx a,@dptr + 418 ; Peephole 191 removed redundant mov + 0196 F9 419 mov r1,a + 0197 8A 82 420 mov dpl,r2 + 0199 8B 83 421 mov dph,r3 + 019B 88 F0 422 mov b,r0 + 019D 12s00r00 423 lcall ___long2fs + 01A0 AA 82 424 mov r2,dpl + 01A2 AB 83 425 mov r3,dph + 01A4 A8 F0 426 mov r0,b + 427 ; Peephole 191 removed redundant mov + 01A6 F9 428 mov r1,a + 01A7 8A 82 429 mov dpl,r2 + 01A9 8B 83 430 mov dph,r3 + 01AB 88 F0 431 mov b,r0 + 01AD 02s07r14 432 ljmp 00128$ + 01B0 433 00108$: + 434 ; _fsadd.c 42 + 01B0 90s00r10 435 mov dptr,#(___fsadd_fl1_1_1) + 01B3 E0 436 movx a,@dptr + 01B4 FA 437 mov r2,a + 01B5 A3 438 inc dptr + 01B6 E0 439 movx a,@dptr + 01B7 FB 440 mov r3,a + 01B8 A3 441 inc dptr + 01B9 E0 442 movx a,@dptr + 01BA F8 443 mov r0,a + 01BB A3 444 inc dptr + 01BC E0 445 movx a,@dptr + 01BD F9 446 mov r1,a + 01BE 53 00 7F 447 anl ar0,#0x7f + 01C1 79 00 448 mov r1,#0x00 + 01C3 43 00 80 449 orl ar0,#0x80 + 01C6 E9 450 mov a,r1 + 01C7 54 03 451 anl a,#0x03 + 01C9 A2 E0 452 mov c,acc.0 + 01CB C8 453 xch a,r0 + 01CC 13 454 rrc a + 01CD C8 455 xch a,r0 + 01CE 13 456 rrc a + 01CF C8 457 xch a,r0 + 01D0 13 458 rrc a + 01D1 C8 459 xch a,r0 + 01D2 13 460 rrc a + 01D3 C8 461 xch a,r0 + 01D4 F9 462 mov r1,a + 01D5 EB 463 mov a,r3 + 01D6 03 464 rr a + 01D7 03 465 rr a + 01D8 54 3F 466 anl a,#0x3f + 01DA 48 467 orl a,r0 + 01DB F8 468 mov r0,a + 01DC EB 469 mov a,r3 + 01DD 54 03 470 anl a,#0x03 + 01DF A2 E0 471 mov c,acc.0 + 01E1 CA 472 xch a,r2 + 01E2 13 473 rrc a + 01E3 CA 474 xch a,r2 + 01E4 13 475 rrc a + 01E5 CA 476 xch a,r2 + 01E6 13 477 rrc a + 01E7 CA 478 xch a,r2 + 01E8 13 479 rrc a + 01E9 CA 480 xch a,r2 + 01EA FB 481 mov r3,a + 01EB 90s00r08 482 mov dptr,#___fsadd_mant1_1_1 + 01EE EA 483 mov a,r2 + 01EF F0 484 movx @dptr,a + 01F0 A3 485 inc dptr + 01F1 EB 486 mov a,r3 + 01F2 F0 487 movx @dptr,a + 01F3 A3 488 inc dptr + 01F4 E8 489 mov a,r0 + 01F5 F0 490 movx @dptr,a + 01F6 A3 491 inc dptr + 01F7 E9 492 mov a,r1 + 01F8 F0 493 movx @dptr,a + 494 ; _fsadd.c 43 + 01F9 90s00r14 495 mov dptr,#(___fsadd_fl2_1_1) + 01FC E0 496 movx a,@dptr + 01FD FA 497 mov r2,a + 01FE A3 498 inc dptr + 01FF E0 499 movx a,@dptr + 0200 FB 500 mov r3,a + 0201 A3 501 inc dptr + 0202 E0 502 movx a,@dptr + 0203 F8 503 mov r0,a + 0204 A3 504 inc dptr + 0205 E0 505 movx a,@dptr + 0206 F9 506 mov r1,a + 0207 53 00 7F 507 anl ar0,#0x7f + 020A 79 00 508 mov r1,#0x00 + 020C 43 00 80 509 orl ar0,#0x80 + 020F E9 510 mov a,r1 + 0210 54 03 511 anl a,#0x03 + 0212 A2 E0 512 mov c,acc.0 + 0214 C8 513 xch a,r0 + 0215 13 514 rrc a + 0216 C8 515 xch a,r0 + 0217 13 516 rrc a + 0218 C8 517 xch a,r0 + 0219 13 518 rrc a + 021A C8 519 xch a,r0 + 021B 13 520 rrc a + 021C C8 521 xch a,r0 + 021D F9 522 mov r1,a + 021E EB 523 mov a,r3 + 021F 03 524 rr a + 0220 03 525 rr a + 0221 54 3F 526 anl a,#0x3f + 0223 48 527 orl a,r0 + 0224 F8 528 mov r0,a + 0225 EB 529 mov a,r3 + 0226 54 03 530 anl a,#0x03 + 0228 A2 E0 531 mov c,acc.0 + 022A CA 532 xch a,r2 + 022B 13 533 rrc a + 022C CA 534 xch a,r2 + 022D 13 535 rrc a + 022E CA 536 xch a,r2 + 022F 13 537 rrc a + 0230 CA 538 xch a,r2 + 0231 13 539 rrc a + 0232 CA 540 xch a,r2 + 0233 FB 541 mov r3,a + 0234 90s00r0C 542 mov dptr,#___fsadd_mant2_1_1 + 0237 EA 543 mov a,r2 + 0238 F0 544 movx @dptr,a + 0239 A3 545 inc dptr + 023A EB 546 mov a,r3 + 023B F0 547 movx @dptr,a + 023C A3 548 inc dptr + 023D E8 549 mov a,r0 + 023E F0 550 movx @dptr,a + 023F A3 551 inc dptr + 0240 E9 552 mov a,r1 + 0241 F0 553 movx @dptr,a + 554 ; _fsadd.c 45 + 0242 90s00r10 555 mov dptr,#(___fsadd_fl1_1_1) + 0245 E0 556 movx a,@dptr + 0246 FA 557 mov r2,a + 0247 A3 558 inc dptr + 0248 E0 559 movx a,@dptr + 0249 FB 560 mov r3,a + 024A A3 561 inc dptr + 024B E0 562 movx a,@dptr + 024C F8 563 mov r0,a + 024D A3 564 inc dptr + 024E E0 565 movx a,@dptr + 566 ; Peephole 105 removed redundant mov + 024F F9 567 mov r1,a + 0250 23 568 rl a + 0251 54 01 569 anl a,#0x01 + 570 ; Peephole 105 removed redundant mov + 0253 FA 571 mov r2,a + 572 ; Peephole 110 removed ljmp by inverse jump logic + 0254 60 29 573 jz 00110$ + 0256 574 00152$: + 575 ; _fsadd.c 46 + 0256 90s00r08 576 mov dptr,#___fsadd_mant1_1_1 + 0259 E0 577 movx a,@dptr + 025A F5*00 578 mov ___fsadd_sloc0_1_0,a + 025C A3 579 inc dptr + 025D E0 580 movx a,@dptr + 025E F5*01 581 mov (___fsadd_sloc0_1_0 + 1),a + 0260 A3 582 inc dptr + 0261 E0 583 movx a,@dptr + 0262 F5*02 584 mov (___fsadd_sloc0_1_0 + 2),a + 0264 A3 585 inc dptr + 0265 E0 586 movx a,@dptr + 0266 F5*03 587 mov (___fsadd_sloc0_1_0 + 3),a + 0268 90s00r08 588 mov dptr,#___fsadd_mant1_1_1 + 026B C3 589 clr c + 026C E4 590 clr a + 026D 95*00 591 subb a,___fsadd_sloc0_1_0 + 026F F0 592 movx @dptr,a + 0270 E4 593 clr a + 0271 95*01 594 subb a,(___fsadd_sloc0_1_0 + 1) + 0273 A3 595 inc dptr + 0274 F0 596 movx @dptr,a + 0275 E4 597 clr a + 0276 95*02 598 subb a,(___fsadd_sloc0_1_0 + 2) + 0278 A3 599 inc dptr + 0279 F0 600 movx @dptr,a + 027A E4 601 clr a + 027B 95*03 602 subb a,(___fsadd_sloc0_1_0 + 3) + 027D A3 603 inc dptr + 027E F0 604 movx @dptr,a + 027F 605 00110$: + 606 ; _fsadd.c 47 + 027F 90s00r14 607 mov dptr,#(___fsadd_fl2_1_1) + 0282 E0 608 movx a,@dptr + 0283 F5*00 609 mov ___fsadd_sloc0_1_0,a + 0285 A3 610 inc dptr + 0286 E0 611 movx a,@dptr + 0287 F5*01 612 mov (___fsadd_sloc0_1_0 + 1),a + 0289 A3 613 inc dptr + 028A E0 614 movx a,@dptr + 028B F5*02 615 mov (___fsadd_sloc0_1_0 + 2),a + 028D A3 616 inc dptr + 028E E0 617 movx a,@dptr + 618 ; Peephole 105 removed redundant mov + 028F F5*03 619 mov (___fsadd_sloc0_1_0 + 3),a + 0291 23 620 rl a + 0292 54 01 621 anl a,#0x01 + 622 ; Peephole 105 removed redundant mov + 0294 FA 623 mov r2,a + 624 ; Peephole 110 removed ljmp by inverse jump logic + 0295 60 29 625 jz 00112$ + 0297 626 00153$: + 627 ; _fsadd.c 48 + 0297 90s00r0C 628 mov dptr,#___fsadd_mant2_1_1 + 029A E0 629 movx a,@dptr + 029B F5*00 630 mov ___fsadd_sloc0_1_0,a + 029D A3 631 inc dptr + 029E E0 632 movx a,@dptr + 029F F5*01 633 mov (___fsadd_sloc0_1_0 + 1),a + 02A1 A3 634 inc dptr + 02A2 E0 635 movx a,@dptr + 02A3 F5*02 636 mov (___fsadd_sloc0_1_0 + 2),a + 02A5 A3 637 inc dptr + 02A6 E0 638 movx a,@dptr + 02A7 F5*03 639 mov (___fsadd_sloc0_1_0 + 3),a + 02A9 90s00r0C 640 mov dptr,#___fsadd_mant2_1_1 + 02AC C3 641 clr c + 02AD E4 642 clr a + 02AE 95*00 643 subb a,___fsadd_sloc0_1_0 + 02B0 F0 644 movx @dptr,a + 02B1 E4 645 clr a + 02B2 95*01 646 subb a,(___fsadd_sloc0_1_0 + 1) + 02B4 A3 647 inc dptr + 02B5 F0 648 movx @dptr,a + 02B6 E4 649 clr a + 02B7 95*02 650 subb a,(___fsadd_sloc0_1_0 + 2) + 02B9 A3 651 inc dptr + 02BA F0 652 movx @dptr,a + 02BB E4 653 clr a + 02BC 95*03 654 subb a,(___fsadd_sloc0_1_0 + 3) + 02BE A3 655 inc dptr + 02BF F0 656 movx @dptr,a + 02C0 657 00112$: + 658 ; _fsadd.c 50 + 02C0 90s00r1A 659 mov dptr,#___fsadd_exp2_1_1 + 02C3 E0 660 movx a,@dptr + 02C4 F5*00 661 mov ___fsadd_sloc0_1_0,a + 02C6 A3 662 inc dptr + 02C7 E0 663 movx a,@dptr + 02C8 F5*01 664 mov (___fsadd_sloc0_1_0 + 1),a + 02CA 90s00r18 665 mov dptr,#___fsadd_exp1_1_1 + 02CD E0 666 movx a,@dptr + 02CE F5*04 667 mov ___fsadd_sloc1_1_0,a + 02D0 A3 668 inc dptr + 02D1 E0 669 movx a,@dptr + 02D2 F5*05 670 mov (___fsadd_sloc1_1_0 + 1),a + 02D4 C3 671 clr c + 02D5 E5*00 672 mov a,___fsadd_sloc0_1_0 + 02D7 95*04 673 subb a,___fsadd_sloc1_1_0 + 02D9 E5*01 674 mov a,(___fsadd_sloc0_1_0 + 1) + 02DB 64 80 675 xrl a,#0x80 + 02DD 85*05 F0 676 mov b,(___fsadd_sloc1_1_0 + 1) + 02E0 63 F0 80 677 xrl b,#0x80 + 02E3 95 F0 678 subb a,b + 02E5 40 03 679 jc 00154$ + 02E7 02s03r57 680 ljmp 00114$ + 02EA 681 00154$: + 682 ; _fsadd.c 52 + 02EA 90s00r1A 683 mov dptr,#___fsadd_exp2_1_1 + 02ED E0 684 movx a,@dptr + 02EE F5*04 685 mov ___fsadd_sloc1_1_0,a + 02F0 A3 686 inc dptr + 02F1 E0 687 movx a,@dptr + 02F2 F5*05 688 mov (___fsadd_sloc1_1_0 + 1),a + 02F4 90s00r18 689 mov dptr,#___fsadd_exp1_1_1 + 02F7 E0 690 movx a,@dptr + 02F8 F5*00 691 mov ___fsadd_sloc0_1_0,a + 02FA A3 692 inc dptr + 02FB E0 693 movx a,@dptr + 02FC F5*01 694 mov (___fsadd_sloc0_1_0 + 1),a + 02FE C3 695 clr c + 02FF E5*00 696 mov a,___fsadd_sloc0_1_0 + 0301 95*04 697 subb a,___fsadd_sloc1_1_0 + 0303 F5*04 698 mov ___fsadd_sloc1_1_0,a + 0305 E5*01 699 mov a,(___fsadd_sloc0_1_0 + 1) + 0307 95*05 700 subb a,(___fsadd_sloc1_1_0 + 1) + 0309 F5*05 701 mov (___fsadd_sloc1_1_0 + 1),a + 030B 90s00r0C 702 mov dptr,#___fsadd_mant2_1_1 + 030E E0 703 movx a,@dptr + 030F F5*00 704 mov ___fsadd_sloc0_1_0,a + 0311 A3 705 inc dptr + 0312 E0 706 movx a,@dptr + 0313 F5*01 707 mov (___fsadd_sloc0_1_0 + 1),a + 0315 A3 708 inc dptr + 0316 E0 709 movx a,@dptr + 0317 F5*02 710 mov (___fsadd_sloc0_1_0 + 2),a + 0319 A3 711 inc dptr + 031A E0 712 movx a,@dptr + 031B F5*03 713 mov (___fsadd_sloc0_1_0 + 3),a + 031D 85*04 F0 714 mov b,___fsadd_sloc1_1_0 + 0320 05 F0 715 inc b + 0322 E5*03 716 mov a,(___fsadd_sloc0_1_0 + 3) + 0324 33 717 rlc a + 0325 92 D2 718 mov ov,c + 0327 80 16 719 sjmp 00156$ + 0329 720 00155$: + 0329 A2 D2 721 mov c,ov + 032B E5*03 722 mov a,(___fsadd_sloc0_1_0 + 3) + 032D 13 723 rrc a + 032E F5*03 724 mov (___fsadd_sloc0_1_0 + 3),a + 0330 E5*02 725 mov a,(___fsadd_sloc0_1_0 + 2) + 0332 13 726 rrc a + 0333 F5*02 727 mov (___fsadd_sloc0_1_0 + 2),a + 0335 E5*01 728 mov a,(___fsadd_sloc0_1_0 + 1) + 0337 13 729 rrc a + 0338 F5*01 730 mov (___fsadd_sloc0_1_0 + 1),a + 033A E5*00 731 mov a,___fsadd_sloc0_1_0 + 033C 13 732 rrc a + 033D F5*00 733 mov ___fsadd_sloc0_1_0,a + 033F 734 00156$: + 033F D5 F0 E7 735 djnz b,00155$ + 0342 90s00r0C 736 mov dptr,#___fsadd_mant2_1_1 + 0345 E5*00 737 mov a,___fsadd_sloc0_1_0 + 0347 F0 738 movx @dptr,a + 0348 A3 739 inc dptr + 0349 E5*01 740 mov a,(___fsadd_sloc0_1_0 + 1) + 034B F0 741 movx @dptr,a + 034C A3 742 inc dptr + 034D E5*02 743 mov a,(___fsadd_sloc0_1_0 + 2) + 034F F0 744 movx @dptr,a + 0350 A3 745 inc dptr + 0351 E5*03 746 mov a,(___fsadd_sloc0_1_0 + 3) + 0353 F0 747 movx @dptr,a + 0354 02s03rD5 748 ljmp 00115$ + 0357 749 00114$: + 750 ; _fsadd.c 56 + 0357 90s00r18 751 mov dptr,#___fsadd_exp1_1_1 + 035A E0 752 movx a,@dptr + 035B F5*04 753 mov ___fsadd_sloc1_1_0,a + 035D A3 754 inc dptr + 035E E0 755 movx a,@dptr + 035F F5*05 756 mov (___fsadd_sloc1_1_0 + 1),a + 0361 90s00r1A 757 mov dptr,#___fsadd_exp2_1_1 + 0364 E0 758 movx a,@dptr + 0365 F5*00 759 mov ___fsadd_sloc0_1_0,a + 0367 A3 760 inc dptr + 0368 E0 761 movx a,@dptr + 0369 F5*01 762 mov (___fsadd_sloc0_1_0 + 1),a + 036B C3 763 clr c + 036C E5*00 764 mov a,___fsadd_sloc0_1_0 + 036E 95*04 765 subb a,___fsadd_sloc1_1_0 + 0370 F5*04 766 mov ___fsadd_sloc1_1_0,a + 0372 E5*01 767 mov a,(___fsadd_sloc0_1_0 + 1) + 0374 95*05 768 subb a,(___fsadd_sloc1_1_0 + 1) + 0376 F5*05 769 mov (___fsadd_sloc1_1_0 + 1),a + 0378 90s00r08 770 mov dptr,#___fsadd_mant1_1_1 + 037B E0 771 movx a,@dptr + 037C F5*00 772 mov ___fsadd_sloc0_1_0,a + 037E A3 773 inc dptr + 037F E0 774 movx a,@dptr + 0380 F5*01 775 mov (___fsadd_sloc0_1_0 + 1),a + 0382 A3 776 inc dptr + 0383 E0 777 movx a,@dptr + 0384 F5*02 778 mov (___fsadd_sloc0_1_0 + 2),a + 0386 A3 779 inc dptr + 0387 E0 780 movx a,@dptr + 0388 F5*03 781 mov (___fsadd_sloc0_1_0 + 3),a + 038A 85*04 F0 782 mov b,___fsadd_sloc1_1_0 + 038D 05 F0 783 inc b + 038F E5*03 784 mov a,(___fsadd_sloc0_1_0 + 3) + 0391 33 785 rlc a + 0392 92 D2 786 mov ov,c + 0394 80 16 787 sjmp 00158$ + 0396 788 00157$: + 0396 A2 D2 789 mov c,ov + 0398 E5*03 790 mov a,(___fsadd_sloc0_1_0 + 3) + 039A 13 791 rrc a + 039B F5*03 792 mov (___fsadd_sloc0_1_0 + 3),a + 039D E5*02 793 mov a,(___fsadd_sloc0_1_0 + 2) + 039F 13 794 rrc a + 03A0 F5*02 795 mov (___fsadd_sloc0_1_0 + 2),a + 03A2 E5*01 796 mov a,(___fsadd_sloc0_1_0 + 1) + 03A4 13 797 rrc a + 03A5 F5*01 798 mov (___fsadd_sloc0_1_0 + 1),a + 03A7 E5*00 799 mov a,___fsadd_sloc0_1_0 + 03A9 13 800 rrc a + 03AA F5*00 801 mov ___fsadd_sloc0_1_0,a + 03AC 802 00158$: + 03AC D5 F0 E7 803 djnz b,00157$ + 03AF 90s00r08 804 mov dptr,#___fsadd_mant1_1_1 + 03B2 E5*00 805 mov a,___fsadd_sloc0_1_0 + 03B4 F0 806 movx @dptr,a + 03B5 A3 807 inc dptr + 03B6 E5*01 808 mov a,(___fsadd_sloc0_1_0 + 1) + 03B8 F0 809 movx @dptr,a + 03B9 A3 810 inc dptr + 03BA E5*02 811 mov a,(___fsadd_sloc0_1_0 + 2) + 03BC F0 812 movx @dptr,a + 03BD A3 813 inc dptr + 03BE E5*03 814 mov a,(___fsadd_sloc0_1_0 + 3) + 03C0 F0 815 movx @dptr,a + 816 ; _fsadd.c 57 + 03C1 90s00r1A 817 mov dptr,#___fsadd_exp2_1_1 + 03C4 E0 818 movx a,@dptr + 03C5 F5*04 819 mov ___fsadd_sloc1_1_0,a + 03C7 A3 820 inc dptr + 03C8 E0 821 movx a,@dptr + 03C9 F5*05 822 mov (___fsadd_sloc1_1_0 + 1),a + 03CB 90s00r18 823 mov dptr,#___fsadd_exp1_1_1 + 03CE E5*04 824 mov a,___fsadd_sloc1_1_0 + 03D0 F0 825 movx @dptr,a + 03D1 A3 826 inc dptr + 03D2 E5*05 827 mov a,(___fsadd_sloc1_1_0 + 1) + 03D4 F0 828 movx @dptr,a + 03D5 829 00115$: + 830 ; _fsadd.c 59 + 03D5 90s00r0C 831 mov dptr,#___fsadd_mant2_1_1 + 03D8 E0 832 movx a,@dptr + 03D9 F5*00 833 mov ___fsadd_sloc0_1_0,a + 03DB A3 834 inc dptr + 03DC E0 835 movx a,@dptr + 03DD F5*01 836 mov (___fsadd_sloc0_1_0 + 1),a + 03DF A3 837 inc dptr + 03E0 E0 838 movx a,@dptr + 03E1 F5*02 839 mov (___fsadd_sloc0_1_0 + 2),a + 03E3 A3 840 inc dptr + 03E4 E0 841 movx a,@dptr + 03E5 F5*03 842 mov (___fsadd_sloc0_1_0 + 3),a + 03E7 90s00r08 843 mov dptr,#___fsadd_mant1_1_1 + 03EA E0 844 movx a,@dptr + 03EB F5*06 845 mov ___fsadd_sloc2_1_0,a + 03ED A3 846 inc dptr + 03EE E0 847 movx a,@dptr + 03EF F5*07 848 mov (___fsadd_sloc2_1_0 + 1),a + 03F1 A3 849 inc dptr + 03F2 E0 850 movx a,@dptr + 03F3 F5*08 851 mov (___fsadd_sloc2_1_0 + 2),a + 03F5 A3 852 inc dptr + 03F6 E0 853 movx a,@dptr + 03F7 F5*09 854 mov (___fsadd_sloc2_1_0 + 3),a + 03F9 90s00r08 855 mov dptr,#___fsadd_mant1_1_1 + 03FC E5*00 856 mov a,___fsadd_sloc0_1_0 + 03FE 25*06 857 add a,___fsadd_sloc2_1_0 + 0400 F0 858 movx @dptr,a + 0401 E5*01 859 mov a,(___fsadd_sloc0_1_0 + 1) + 0403 35*07 860 addc a,(___fsadd_sloc2_1_0 + 1) + 0405 A3 861 inc dptr + 0406 F0 862 movx @dptr,a + 0407 E5*02 863 mov a,(___fsadd_sloc0_1_0 + 2) + 0409 35*08 864 addc a,(___fsadd_sloc2_1_0 + 2) + 040B A3 865 inc dptr + 040C F0 866 movx @dptr,a + 040D E5*03 867 mov a,(___fsadd_sloc0_1_0 + 3) + 040F 35*09 868 addc a,(___fsadd_sloc2_1_0 + 3) + 0411 A3 869 inc dptr + 0412 F0 870 movx @dptr,a + 871 ; _fsadd.c 61 + 0413 90s00r08 872 mov dptr,#___fsadd_mant1_1_1 + 0416 E0 873 movx a,@dptr + 0417 F5*06 874 mov ___fsadd_sloc2_1_0,a + 0419 A3 875 inc dptr + 041A E0 876 movx a,@dptr + 041B F5*07 877 mov (___fsadd_sloc2_1_0 + 1),a + 041D A3 878 inc dptr + 041E E0 879 movx a,@dptr + 041F F5*08 880 mov (___fsadd_sloc2_1_0 + 2),a + 0421 A3 881 inc dptr + 0422 E0 882 movx a,@dptr + 883 ; Peephole 105 removed redundant mov + 0423 F5*09 884 mov (___fsadd_sloc2_1_0 + 3),a + 885 ; Peephole 111 removed ljmp by inverse jump logic + 0425 30 E7 39 886 jnb acc.7,00119$ + 0428 887 00159$: + 888 ; _fsadd.c 63 + 0428 90s00r08 889 mov dptr,#___fsadd_mant1_1_1 + 042B E0 890 movx a,@dptr + 042C F5*06 891 mov ___fsadd_sloc2_1_0,a + 042E A3 892 inc dptr + 042F E0 893 movx a,@dptr + 0430 F5*07 894 mov (___fsadd_sloc2_1_0 + 1),a + 0432 A3 895 inc dptr + 0433 E0 896 movx a,@dptr + 0434 F5*08 897 mov (___fsadd_sloc2_1_0 + 2),a + 0436 A3 898 inc dptr + 0437 E0 899 movx a,@dptr + 0438 F5*09 900 mov (___fsadd_sloc2_1_0 + 3),a + 043A 90s00r08 901 mov dptr,#___fsadd_mant1_1_1 + 043D C3 902 clr c + 043E E4 903 clr a + 043F 95*06 904 subb a,___fsadd_sloc2_1_0 + 0441 F0 905 movx @dptr,a + 0442 E4 906 clr a + 0443 95*07 907 subb a,(___fsadd_sloc2_1_0 + 1) + 0445 A3 908 inc dptr + 0446 F0 909 movx @dptr,a + 0447 E4 910 clr a + 0448 95*08 911 subb a,(___fsadd_sloc2_1_0 + 2) + 044A A3 912 inc dptr + 044B F0 913 movx @dptr,a + 044C E4 914 clr a + 044D 95*09 915 subb a,(___fsadd_sloc2_1_0 + 3) + 044F A3 916 inc dptr + 0450 F0 917 movx @dptr,a + 918 ; _fsadd.c 64 + 0451 90s00r1C 919 mov dptr,#___fsadd_sign_1_1 + 920 ; Peephole 101 removed redundant mov + 921 ; Peephole 180 changed mov to clr + 0454 E4 922 clr a + 0455 F0 923 movx @dptr,a + 0456 A3 924 inc dptr + 0457 F0 925 movx @dptr,a + 0458 A3 926 inc dptr + 927 ; Peephole 180 changed mov to clr + 0459 E4 928 clr a + 045A F0 929 movx @dptr,a + 045B A3 930 inc dptr + 045C 74 80 931 mov a,#0x80 + 045E F0 932 movx @dptr,a + 933 ; Peephole 132 changed ljmp to sjmp + 045F 80 26 934 sjmp 00121$ + 0461 935 00119$: + 936 ; _fsadd.c 66 + 0461 90s00r08 937 mov dptr,#___fsadd_mant1_1_1 + 0464 E0 938 movx a,@dptr + 0465 F5*06 939 mov ___fsadd_sloc2_1_0,a + 0467 A3 940 inc dptr + 0468 E0 941 movx a,@dptr + 0469 F5*07 942 mov (___fsadd_sloc2_1_0 + 1),a + 046B A3 943 inc dptr + 046C E0 944 movx a,@dptr + 046D F5*08 945 mov (___fsadd_sloc2_1_0 + 2),a + 046F A3 946 inc dptr + 0470 E0 947 movx a,@dptr + 0471 F5*09 948 mov (___fsadd_sloc2_1_0 + 3),a + 0473 E5*06 949 mov a,___fsadd_sloc2_1_0 + 0475 45*07 950 orl a,(___fsadd_sloc2_1_0 + 1) + 0477 45*08 951 orl a,(___fsadd_sloc2_1_0 + 2) + 0479 45*09 952 orl a,(___fsadd_sloc2_1_0 + 3) + 953 ; Peephole 109 removed ljmp by inverse jump logic + 047B 70 0A 954 jnz 00121$ + 047D 955 00160$: + 956 ; _fsadd.c 67 + 957 ; Peephole 3.a changed mov to clr + 958 ; Peephole 3.b changed mov to clr + 959 ; Peephole 3.b changed mov to clr + 047D E4 960 clr a + 047E F5 82 961 mov dpl,a + 0480 F5 83 962 mov dph,a + 0482 F5 F0 963 mov b,a + 0484 02s07r14 964 ljmp 00128$ + 965 ; _fsadd.c 70 + 0487 966 00121$: + 0487 90s00r08 967 mov dptr,#___fsadd_mant1_1_1 + 048A E0 968 movx a,@dptr + 048B F5*06 969 mov ___fsadd_sloc2_1_0,a + 048D A3 970 inc dptr + 048E E0 971 movx a,@dptr + 048F F5*07 972 mov (___fsadd_sloc2_1_0 + 1),a + 0491 A3 973 inc dptr + 0492 E0 974 movx a,@dptr + 0493 F5*08 975 mov (___fsadd_sloc2_1_0 + 2),a + 0495 A3 976 inc dptr + 0496 E0 977 movx a,@dptr + 978 ; Peephole 105 removed redundant mov + 0497 F5*09 979 mov (___fsadd_sloc2_1_0 + 3),a + 0499 54 E0 980 anl a,#0xe0 + 981 ; Peephole 162 removed sjmp by inverse jump logic + 049B 60 03 982 jz 00162$ + 049D 983 00161$: + 049D 02s04rF4 984 ljmp 00123$ + 04A0 985 00162$: + 986 ; _fsadd.c 72 + 04A0 90s00r08 987 mov dptr,#___fsadd_mant1_1_1 + 04A3 E0 988 movx a,@dptr + 04A4 F5*06 989 mov ___fsadd_sloc2_1_0,a + 04A6 A3 990 inc dptr + 04A7 E0 991 movx a,@dptr + 04A8 F5*07 992 mov (___fsadd_sloc2_1_0 + 1),a + 04AA A3 993 inc dptr + 04AB E0 994 movx a,@dptr + 04AC F5*08 995 mov (___fsadd_sloc2_1_0 + 2),a + 04AE A3 996 inc dptr + 04AF E0 997 movx a,@dptr + 04B0 F5*09 998 mov (___fsadd_sloc2_1_0 + 3),a + 04B2 E5*06 999 mov a,___fsadd_sloc2_1_0 + 04B4 25 E0 1000 add a,acc + 04B6 F5*06 1001 mov ___fsadd_sloc2_1_0,a + 04B8 E5*07 1002 mov a,(___fsadd_sloc2_1_0 + 1) + 04BA 33 1003 rlc a + 04BB F5*07 1004 mov (___fsadd_sloc2_1_0 + 1),a + 04BD E5*08 1005 mov a,(___fsadd_sloc2_1_0 + 2) + 04BF 33 1006 rlc a + 04C0 F5*08 1007 mov (___fsadd_sloc2_1_0 + 2),a + 04C2 E5*09 1008 mov a,(___fsadd_sloc2_1_0 + 3) + 04C4 33 1009 rlc a + 04C5 F5*09 1010 mov (___fsadd_sloc2_1_0 + 3),a + 04C7 90s00r08 1011 mov dptr,#___fsadd_mant1_1_1 + 04CA E5*06 1012 mov a,___fsadd_sloc2_1_0 + 04CC F0 1013 movx @dptr,a + 04CD A3 1014 inc dptr + 04CE E5*07 1015 mov a,(___fsadd_sloc2_1_0 + 1) + 04D0 F0 1016 movx @dptr,a + 04D1 A3 1017 inc dptr + 04D2 E5*08 1018 mov a,(___fsadd_sloc2_1_0 + 2) + 04D4 F0 1019 movx @dptr,a + 04D5 A3 1020 inc dptr + 04D6 E5*09 1021 mov a,(___fsadd_sloc2_1_0 + 3) + 04D8 F0 1022 movx @dptr,a + 1023 ; _fsadd.c 73 + 04D9 90s00r18 1024 mov dptr,#___fsadd_exp1_1_1 + 04DC E0 1025 movx a,@dptr + 04DD 24 FF 1026 add a,#0xff + 04DF F5*06 1027 mov ___fsadd_sloc2_1_0,a + 04E1 A3 1028 inc dptr + 04E2 E0 1029 movx a,@dptr + 04E3 34 FF 1030 addc a,#0xff + 04E5 F5*07 1031 mov (___fsadd_sloc2_1_0 + 1),a + 04E7 90s00r18 1032 mov dptr,#___fsadd_exp1_1_1 + 04EA E5*06 1033 mov a,___fsadd_sloc2_1_0 + 04EC F0 1034 movx @dptr,a + 04ED A3 1035 inc dptr + 04EE E5*07 1036 mov a,(___fsadd_sloc2_1_0 + 1) + 04F0 F0 1037 movx @dptr,a + 04F1 02s04r87 1038 ljmp 00121$ + 04F4 1039 00123$: + 1040 ; _fsadd.c 77 + 04F4 90s00r08 1041 mov dptr,#___fsadd_mant1_1_1 + 04F7 E0 1042 movx a,@dptr + 04F8 F5*06 1043 mov ___fsadd_sloc2_1_0,a + 04FA A3 1044 inc dptr + 04FB E0 1045 movx a,@dptr + 04FC F5*07 1046 mov (___fsadd_sloc2_1_0 + 1),a + 04FE A3 1047 inc dptr + 04FF E0 1048 movx a,@dptr + 0500 F5*08 1049 mov (___fsadd_sloc2_1_0 + 2),a + 0502 A3 1050 inc dptr + 0503 E0 1051 movx a,@dptr + 1052 ; Peephole 105 removed redundant mov + 0504 F5*09 1053 mov (___fsadd_sloc2_1_0 + 3),a + 1054 ; Peephole 111 removed ljmp by inverse jump logic + 0506 30 E6 42 1055 jnb acc.6,00125$ + 0509 1056 00163$: + 1057 ; _fsadd.c 79 + 0509 90s00r08 1058 mov dptr,#___fsadd_mant1_1_1 + 050C E0 1059 movx a,@dptr + 050D F5*06 1060 mov ___fsadd_sloc2_1_0,a + 050F A3 1061 inc dptr + 0510 E0 1062 movx a,@dptr + 0511 F5*07 1063 mov (___fsadd_sloc2_1_0 + 1),a + 0513 A3 1064 inc dptr + 0514 E0 1065 movx a,@dptr + 0515 F5*08 1066 mov (___fsadd_sloc2_1_0 + 2),a + 0517 A3 1067 inc dptr + 0518 E0 1068 movx a,@dptr + 1069 ; Peephole 105 removed redundant mov + 0519 F5*09 1070 mov (___fsadd_sloc2_1_0 + 3),a + 051B A2 E7 1071 mov c,acc.7 + 051D 13 1072 rrc a + 051E F5*09 1073 mov (___fsadd_sloc2_1_0 + 3),a + 0520 E5*08 1074 mov a,(___fsadd_sloc2_1_0 + 2) + 0522 13 1075 rrc a + 0523 F5*08 1076 mov (___fsadd_sloc2_1_0 + 2),a + 0525 E5*07 1077 mov a,(___fsadd_sloc2_1_0 + 1) + 0527 13 1078 rrc a + 0528 F5*07 1079 mov (___fsadd_sloc2_1_0 + 1),a + 052A E5*06 1080 mov a,___fsadd_sloc2_1_0 + 052C 13 1081 rrc a + 1082 ; Peephole 100 removed redundant mov + 052D F5*06 1083 mov ___fsadd_sloc2_1_0,a + 052F 90s00r08 1084 mov dptr,#___fsadd_mant1_1_1 + 0532 F0 1085 movx @dptr,a + 0533 A3 1086 inc dptr + 0534 E5*07 1087 mov a,(___fsadd_sloc2_1_0 + 1) + 0536 F0 1088 movx @dptr,a + 0537 A3 1089 inc dptr + 0538 E5*08 1090 mov a,(___fsadd_sloc2_1_0 + 2) + 053A F0 1091 movx @dptr,a + 053B A3 1092 inc dptr + 053C E5*09 1093 mov a,(___fsadd_sloc2_1_0 + 3) + 053E F0 1094 movx @dptr,a + 1095 ; _fsadd.c 80 + 053F 90s00r18 1096 mov dptr,#___fsadd_exp1_1_1 + 0542 E0 1097 movx a,@dptr + 0543 24 01 1098 add a,#0x01 + 0545 F0 1099 movx @dptr,a + 0546 A3 1100 inc dptr + 0547 E0 1101 movx a,@dptr + 0548 34 00 1102 addc a,#0x00 + 054A F0 1103 movx @dptr,a + 054B 1104 00125$: + 1105 ; _fsadd.c 84 + 054B 90s00r08 1106 mov dptr,#___fsadd_mant1_1_1 + 054E E0 1107 movx a,@dptr + 054F F5*06 1108 mov ___fsadd_sloc2_1_0,a + 0551 A3 1109 inc dptr + 0552 E0 1110 movx a,@dptr + 0553 F5*07 1111 mov (___fsadd_sloc2_1_0 + 1),a + 0555 A3 1112 inc dptr + 0556 E0 1113 movx a,@dptr + 0557 F5*08 1114 mov (___fsadd_sloc2_1_0 + 2),a + 0559 A3 1115 inc dptr + 055A E0 1116 movx a,@dptr + 055B F5*09 1117 mov (___fsadd_sloc2_1_0 + 3),a + 055D E5*06 1118 mov a,___fsadd_sloc2_1_0 + 1119 ; Peephole 111 removed ljmp by inverse jump logic + 055F 30 E6 0C 1120 jnb acc.6,00130$ + 0562 1121 00164$: + 0562 E4 1122 clr a + 0563 F5*09 1123 mov (___fsadd_sloc2_1_0 + 3),a + 0565 F5*08 1124 mov (___fsadd_sloc2_1_0 + 2),a + 0567 F5*07 1125 mov (___fsadd_sloc2_1_0 + 1),a + 0569 75*06 20 1126 mov ___fsadd_sloc2_1_0,#0x20 + 1127 ; Peephole 132 changed ljmp to sjmp + 056C 80 0A 1128 sjmp 00131$ + 056E 1129 00130$: + 056E E4 1130 clr a + 056F F5*09 1131 mov (___fsadd_sloc2_1_0 + 3),a + 0571 F5*08 1132 mov (___fsadd_sloc2_1_0 + 2),a + 0573 F5*07 1133 mov (___fsadd_sloc2_1_0 + 1),a + 0575 75*06 1F 1134 mov ___fsadd_sloc2_1_0,#0x1f + 0578 1135 00131$: + 0578 90s00r08 1136 mov dptr,#___fsadd_mant1_1_1 + 057B E0 1137 movx a,@dptr + 057C F5*00 1138 mov ___fsadd_sloc0_1_0,a + 057E A3 1139 inc dptr + 057F E0 1140 movx a,@dptr + 0580 F5*01 1141 mov (___fsadd_sloc0_1_0 + 1),a + 0582 A3 1142 inc dptr + 0583 E0 1143 movx a,@dptr + 0584 F5*02 1144 mov (___fsadd_sloc0_1_0 + 2),a + 0586 A3 1145 inc dptr + 0587 E0 1146 movx a,@dptr + 0588 F5*03 1147 mov (___fsadd_sloc0_1_0 + 3),a + 058A 90s00r08 1148 mov dptr,#___fsadd_mant1_1_1 + 058D E5*06 1149 mov a,___fsadd_sloc2_1_0 + 058F 25*00 1150 add a,___fsadd_sloc0_1_0 + 0591 F0 1151 movx @dptr,a + 0592 E5*07 1152 mov a,(___fsadd_sloc2_1_0 + 1) + 0594 35*01 1153 addc a,(___fsadd_sloc0_1_0 + 1) + 0596 A3 1154 inc dptr + 0597 F0 1155 movx @dptr,a + 0598 E5*08 1156 mov a,(___fsadd_sloc2_1_0 + 2) + 059A 35*02 1157 addc a,(___fsadd_sloc0_1_0 + 2) + 059C A3 1158 inc dptr + 059D F0 1159 movx @dptr,a + 059E E5*09 1160 mov a,(___fsadd_sloc2_1_0 + 3) + 05A0 35*03 1161 addc a,(___fsadd_sloc0_1_0 + 3) + 05A2 A3 1162 inc dptr + 05A3 F0 1163 movx @dptr,a + 1164 ; _fsadd.c 87 + 05A4 90s00r08 1165 mov dptr,#___fsadd_mant1_1_1 + 05A7 E0 1166 movx a,@dptr + 05A8 F5*06 1167 mov ___fsadd_sloc2_1_0,a + 05AA A3 1168 inc dptr + 05AB E0 1169 movx a,@dptr + 05AC F5*07 1170 mov (___fsadd_sloc2_1_0 + 1),a + 05AE A3 1171 inc dptr + 05AF E0 1172 movx a,@dptr + 05B0 F5*08 1173 mov (___fsadd_sloc2_1_0 + 2),a + 05B2 A3 1174 inc dptr + 05B3 E0 1175 movx a,@dptr + 1176 ; Peephole 105 removed redundant mov + 05B4 F5*09 1177 mov (___fsadd_sloc2_1_0 + 3),a + 1178 ; Peephole 111 removed ljmp by inverse jump logic + 05B6 30 E6 42 1179 jnb acc.6,00127$ + 05B9 1180 00165$: + 1181 ; _fsadd.c 89 + 05B9 90s00r08 1182 mov dptr,#___fsadd_mant1_1_1 + 05BC E0 1183 movx a,@dptr + 05BD F5*06 1184 mov ___fsadd_sloc2_1_0,a + 05BF A3 1185 inc dptr + 05C0 E0 1186 movx a,@dptr + 05C1 F5*07 1187 mov (___fsadd_sloc2_1_0 + 1),a + 05C3 A3 1188 inc dptr + 05C4 E0 1189 movx a,@dptr + 05C5 F5*08 1190 mov (___fsadd_sloc2_1_0 + 2),a + 05C7 A3 1191 inc dptr + 05C8 E0 1192 movx a,@dptr + 1193 ; Peephole 105 removed redundant mov + 05C9 F5*09 1194 mov (___fsadd_sloc2_1_0 + 3),a + 05CB A2 E7 1195 mov c,acc.7 + 05CD 13 1196 rrc a + 05CE F5*09 1197 mov (___fsadd_sloc2_1_0 + 3),a + 05D0 E5*08 1198 mov a,(___fsadd_sloc2_1_0 + 2) + 05D2 13 1199 rrc a + 05D3 F5*08 1200 mov (___fsadd_sloc2_1_0 + 2),a + 05D5 E5*07 1201 mov a,(___fsadd_sloc2_1_0 + 1) + 05D7 13 1202 rrc a + 05D8 F5*07 1203 mov (___fsadd_sloc2_1_0 + 1),a + 05DA E5*06 1204 mov a,___fsadd_sloc2_1_0 + 05DC 13 1205 rrc a + 1206 ; Peephole 100 removed redundant mov + 05DD F5*06 1207 mov ___fsadd_sloc2_1_0,a + 05DF 90s00r08 1208 mov dptr,#___fsadd_mant1_1_1 + 05E2 F0 1209 movx @dptr,a + 05E3 A3 1210 inc dptr + 05E4 E5*07 1211 mov a,(___fsadd_sloc2_1_0 + 1) + 05E6 F0 1212 movx @dptr,a + 05E7 A3 1213 inc dptr + 05E8 E5*08 1214 mov a,(___fsadd_sloc2_1_0 + 2) + 05EA F0 1215 movx @dptr,a + 05EB A3 1216 inc dptr + 05EC E5*09 1217 mov a,(___fsadd_sloc2_1_0 + 3) + 05EE F0 1218 movx @dptr,a + 1219 ; _fsadd.c 90 + 05EF 90s00r18 1220 mov dptr,#___fsadd_exp1_1_1 + 05F2 E0 1221 movx a,@dptr + 05F3 24 01 1222 add a,#0x01 + 05F5 F0 1223 movx @dptr,a + 05F6 A3 1224 inc dptr + 05F7 E0 1225 movx a,@dptr + 05F8 34 00 1226 addc a,#0x00 + 05FA F0 1227 movx @dptr,a + 05FB 1228 00127$: + 1229 ; _fsadd.c 94 + 05FB 90s00r08 1230 mov dptr,#___fsadd_mant1_1_1 + 05FE E0 1231 movx a,@dptr + 05FF F5*06 1232 mov ___fsadd_sloc2_1_0,a + 0601 A3 1233 inc dptr + 0602 E0 1234 movx a,@dptr + 0603 F5*07 1235 mov (___fsadd_sloc2_1_0 + 1),a + 0605 A3 1236 inc dptr + 0606 E0 1237 movx a,@dptr + 0607 F5*08 1238 mov (___fsadd_sloc2_1_0 + 2),a + 0609 A3 1239 inc dptr + 060A E0 1240 movx a,@dptr + 060B F5*09 1241 mov (___fsadd_sloc2_1_0 + 3),a + 060D E5*07 1242 mov a,(___fsadd_sloc2_1_0 + 1) + 060F A2 E7 1243 mov c,acc.7 + 0611 C5*06 1244 xch a,___fsadd_sloc2_1_0 + 0613 33 1245 rlc a + 0614 C5*06 1246 xch a,___fsadd_sloc2_1_0 + 0616 33 1247 rlc a + 0617 C5*06 1248 xch a,___fsadd_sloc2_1_0 + 0619 33 1249 rlc a + 061A C5*06 1250 xch a,___fsadd_sloc2_1_0 + 061C 33 1251 rlc a + 061D C5*06 1252 xch a,___fsadd_sloc2_1_0 + 061F 54 03 1253 anl a,#0x03 + 0621 F5*07 1254 mov (___fsadd_sloc2_1_0 + 1),a + 0623 E5*08 1255 mov a,(___fsadd_sloc2_1_0 + 2) + 0625 25 E0 1256 add a,acc + 0627 25 E0 1257 add a,acc + 0629 45*07 1258 orl a,(___fsadd_sloc2_1_0 + 1) + 062B F5*07 1259 mov (___fsadd_sloc2_1_0 + 1),a + 062D E5*09 1260 mov a,(___fsadd_sloc2_1_0 + 3) + 062F A2 E7 1261 mov c,acc.7 + 0631 C5*08 1262 xch a,(___fsadd_sloc2_1_0 + 2) + 0633 33 1263 rlc a + 0634 C5*08 1264 xch a,(___fsadd_sloc2_1_0 + 2) + 0636 33 1265 rlc a + 0637 C5*08 1266 xch a,(___fsadd_sloc2_1_0 + 2) + 0639 33 1267 rlc a + 063A C5*08 1268 xch a,(___fsadd_sloc2_1_0 + 2) + 063C 33 1269 rlc a + 063D C5*08 1270 xch a,(___fsadd_sloc2_1_0 + 2) + 063F 54 03 1271 anl a,#0x03 + 0641 30 E1 02 1272 jnb acc.1,00166$ + 0644 44 FC 1273 orl a,#0xfc + 0646 1274 00166$: + 0646 F5*09 1275 mov (___fsadd_sloc2_1_0 + 3),a + 0648 90s00r08 1276 mov dptr,#___fsadd_mant1_1_1 + 064B E5*06 1277 mov a,___fsadd_sloc2_1_0 + 064D F0 1278 movx @dptr,a + 064E A3 1279 inc dptr + 064F E5*07 1280 mov a,(___fsadd_sloc2_1_0 + 1) + 0651 F0 1281 movx @dptr,a + 0652 A3 1282 inc dptr + 0653 E5*08 1283 mov a,(___fsadd_sloc2_1_0 + 2) + 0655 F0 1284 movx @dptr,a + 0656 A3 1285 inc dptr + 0657 E5*09 1286 mov a,(___fsadd_sloc2_1_0 + 3) + 0659 F0 1287 movx @dptr,a + 1288 ; _fsadd.c 97 + 065A 90s00r08 1289 mov dptr,#___fsadd_mant1_1_1 + 065D E0 1290 movx a,@dptr + 065E F5*06 1291 mov ___fsadd_sloc2_1_0,a + 0660 A3 1292 inc dptr + 0661 E0 1293 movx a,@dptr + 0662 F5*07 1294 mov (___fsadd_sloc2_1_0 + 1),a + 0664 A3 1295 inc dptr + 0665 E0 1296 movx a,@dptr + 0666 F5*08 1297 mov (___fsadd_sloc2_1_0 + 2),a + 0668 A3 1298 inc dptr + 0669 E0 1299 movx a,@dptr + 066A F5*09 1300 mov (___fsadd_sloc2_1_0 + 3),a + 066C 90s00r08 1301 mov dptr,#___fsadd_mant1_1_1 + 066F E5*06 1302 mov a,___fsadd_sloc2_1_0 + 0671 F0 1303 movx @dptr,a + 0672 A3 1304 inc dptr + 0673 E5*07 1305 mov a,(___fsadd_sloc2_1_0 + 1) + 0675 F0 1306 movx @dptr,a + 0676 74 7F 1307 mov a,#0x7f + 0678 55*08 1308 anl a,(___fsadd_sloc2_1_0 + 2) + 067A A3 1309 inc dptr + 067B F0 1310 movx @dptr,a + 067C A3 1311 inc dptr + 067D E5*09 1312 mov a,(___fsadd_sloc2_1_0 + 3) + 067F F0 1313 movx @dptr,a + 1314 ; _fsadd.c 100 + 0680 90s00r18 1315 mov dptr,#___fsadd_exp1_1_1 + 0683 E0 1316 movx a,@dptr + 0684 F5*06 1317 mov ___fsadd_sloc2_1_0,a + 0686 A3 1318 inc dptr + 0687 E0 1319 movx a,@dptr + 0688 F5*07 1320 mov (___fsadd_sloc2_1_0 + 1),a + 068A 85*06*08 1321 mov (___fsadd_sloc2_1_0 + 2),___fsadd_sloc2_1_0 + 068D E5*07 1322 mov a,(___fsadd_sloc2_1_0 + 1) + 068F 54 01 1323 anl a,#0x01 + 0691 A2 E0 1324 mov c,acc.0 + 0693 C5*08 1325 xch a,(___fsadd_sloc2_1_0 + 2) + 0695 13 1326 rrc a + 0696 C5*08 1327 xch a,(___fsadd_sloc2_1_0 + 2) + 0698 13 1328 rrc a + 0699 C5*08 1329 xch a,(___fsadd_sloc2_1_0 + 2) + 069B F5*09 1330 mov (___fsadd_sloc2_1_0 + 3),a + 069D 75*07 00 1331 mov (___fsadd_sloc2_1_0 + 1),#0x00 + 06A0 75*06 00 1332 mov ___fsadd_sloc2_1_0,#0x00 + 06A3 90s00r1C 1333 mov dptr,#___fsadd_sign_1_1 + 06A6 E0 1334 movx a,@dptr + 06A7 F5*00 1335 mov ___fsadd_sloc0_1_0,a + 06A9 A3 1336 inc dptr + 06AA E0 1337 movx a,@dptr + 06AB F5*01 1338 mov (___fsadd_sloc0_1_0 + 1),a + 06AD A3 1339 inc dptr + 06AE E0 1340 movx a,@dptr + 06AF F5*02 1341 mov (___fsadd_sloc0_1_0 + 2),a + 06B1 A3 1342 inc dptr + 06B2 E0 1343 movx a,@dptr + 06B3 F5*03 1344 mov (___fsadd_sloc0_1_0 + 3),a + 06B5 E5*00 1345 mov a,___fsadd_sloc0_1_0 + 06B7 42*06 1346 orl ___fsadd_sloc2_1_0,a + 06B9 E5*01 1347 mov a,(___fsadd_sloc0_1_0 + 1) + 06BB 42*07 1348 orl (___fsadd_sloc2_1_0 + 1),a + 06BD E5*02 1349 mov a,(___fsadd_sloc0_1_0 + 2) + 06BF 42*08 1350 orl (___fsadd_sloc2_1_0 + 2),a + 06C1 E5*03 1351 mov a,(___fsadd_sloc0_1_0 + 3) + 06C3 42*09 1352 orl (___fsadd_sloc2_1_0 + 3),a + 06C5 90s00r08 1353 mov dptr,#___fsadd_mant1_1_1 + 06C8 E0 1354 movx a,@dptr + 06C9 F5*00 1355 mov ___fsadd_sloc0_1_0,a + 06CB A3 1356 inc dptr + 06CC E0 1357 movx a,@dptr + 06CD F5*01 1358 mov (___fsadd_sloc0_1_0 + 1),a + 06CF A3 1359 inc dptr + 06D0 E0 1360 movx a,@dptr + 06D1 F5*02 1361 mov (___fsadd_sloc0_1_0 + 2),a + 06D3 A3 1362 inc dptr + 06D4 E0 1363 movx a,@dptr + 06D5 F5*03 1364 mov (___fsadd_sloc0_1_0 + 3),a + 06D7 E5*00 1365 mov a,___fsadd_sloc0_1_0 + 06D9 42*06 1366 orl ___fsadd_sloc2_1_0,a + 06DB E5*01 1367 mov a,(___fsadd_sloc0_1_0 + 1) + 06DD 42*07 1368 orl (___fsadd_sloc2_1_0 + 1),a + 06DF E5*02 1369 mov a,(___fsadd_sloc0_1_0 + 2) + 06E1 42*08 1370 orl (___fsadd_sloc2_1_0 + 2),a + 06E3 E5*03 1371 mov a,(___fsadd_sloc0_1_0 + 3) + 06E5 42*09 1372 orl (___fsadd_sloc2_1_0 + 3),a + 06E7 90s00r10 1373 mov dptr,#(___fsadd_fl1_1_1) + 06EA E5*06 1374 mov a,___fsadd_sloc2_1_0 + 06EC F0 1375 movx @dptr,a + 06ED A3 1376 inc dptr + 06EE E5*07 1377 mov a,(___fsadd_sloc2_1_0 + 1) + 06F0 F0 1378 movx @dptr,a + 06F1 A3 1379 inc dptr + 06F2 E5*08 1380 mov a,(___fsadd_sloc2_1_0 + 2) + 06F4 F0 1381 movx @dptr,a + 06F5 A3 1382 inc dptr + 06F6 E5*09 1383 mov a,(___fsadd_sloc2_1_0 + 3) + 06F8 F0 1384 movx @dptr,a + 1385 ; _fsadd.c 101 + 06F9 90s00r10 1386 mov dptr,#(___fsadd_fl1_1_1) + 06FC E0 1387 movx a,@dptr + 06FD F5*06 1388 mov ___fsadd_sloc2_1_0,a + 06FF A3 1389 inc dptr + 0700 E0 1390 movx a,@dptr + 0701 F5*07 1391 mov (___fsadd_sloc2_1_0 + 1),a + 0703 A3 1392 inc dptr + 0704 E0 1393 movx a,@dptr + 0705 F5*08 1394 mov (___fsadd_sloc2_1_0 + 2),a + 0707 A3 1395 inc dptr + 0708 E0 1396 movx a,@dptr + 1397 ; Peephole 191 removed redundant mov + 0709 F5*09 1398 mov (___fsadd_sloc2_1_0 + 3),a + 070B 85*06 82 1399 mov dpl,___fsadd_sloc2_1_0 + 070E 85*07 83 1400 mov dph,(___fsadd_sloc2_1_0 + 1) + 0711 85*08 F0 1401 mov b,(___fsadd_sloc2_1_0 + 2) + 0714 1402 00128$: + 0714 1403 C$_fsadd.c$102$1$1 ==. + 0714 1404 XG$__fsadd$0$0 ==. + 0714 22 1405 ret + 1406 .area CSEG (CODE) diff --git a/device/lib/_fsadd.sym b/device/lib/_fsadd.sym new file mode 100644 index 00000000..b20252a7 --- /dev/null +++ b/device/lib/_fsadd.sym @@ -0,0 +1,1575 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fsadd$100 0019 GR + 7 A$_fsadd$1000 04B4 GR + 7 A$_fsadd$1001 04B6 GR + 7 A$_fsadd$1002 04B8 GR + 7 A$_fsadd$1003 04BA GR + 7 A$_fsadd$1004 04BB GR + 7 A$_fsadd$1005 04BD GR + 7 A$_fsadd$1006 04BF GR + 7 A$_fsadd$1007 04C0 GR + 7 A$_fsadd$1008 04C2 GR + 7 A$_fsadd$1009 04C4 GR + 7 A$_fsadd$1010 04C5 GR + 7 A$_fsadd$1011 04C7 GR + 7 A$_fsadd$1012 04CA GR + 7 A$_fsadd$1013 04CC GR + 7 A$_fsadd$1014 04CD GR + 7 A$_fsadd$1015 04CE GR + 7 A$_fsadd$1016 04D0 GR + 7 A$_fsadd$1017 04D1 GR + 7 A$_fsadd$1018 04D2 GR + 7 A$_fsadd$1019 04D4 GR + 7 A$_fsadd$102 001A GR + 7 A$_fsadd$1020 04D5 GR + 7 A$_fsadd$1021 04D6 GR + 7 A$_fsadd$1022 04D8 GR + 7 A$_fsadd$1024 04D9 GR + 7 A$_fsadd$1025 04DC GR + 7 A$_fsadd$1026 04DD GR + 7 A$_fsadd$1027 04DF GR + 7 A$_fsadd$1028 04E1 GR + 7 A$_fsadd$1029 04E2 GR + 7 A$_fsadd$103 001D GR + 7 A$_fsadd$1030 04E3 GR + 7 A$_fsadd$1031 04E5 GR + 7 A$_fsadd$1032 04E7 GR + 7 A$_fsadd$1033 04EA GR + 7 A$_fsadd$1034 04EC GR + 7 A$_fsadd$1035 04ED GR + 7 A$_fsadd$1036 04EE GR + 7 A$_fsadd$1037 04F0 GR + 7 A$_fsadd$1038 04F1 GR + 7 A$_fsadd$104 001E GR + 7 A$_fsadd$1041 04F4 GR + 7 A$_fsadd$1042 04F7 GR + 7 A$_fsadd$1043 04F8 GR + 7 A$_fsadd$1044 04FA GR + 7 A$_fsadd$1045 04FB GR + 7 A$_fsadd$1046 04FC GR + 7 A$_fsadd$1047 04FE GR + 7 A$_fsadd$1048 04FF GR + 7 A$_fsadd$1049 0500 GR + 7 A$_fsadd$105 001F GR + 7 A$_fsadd$1050 0502 GR + 7 A$_fsadd$1051 0503 GR + 7 A$_fsadd$1053 0504 GR + 7 A$_fsadd$1055 0506 GR + 7 A$_fsadd$1058 0509 GR + 7 A$_fsadd$1059 050C GR + 7 A$_fsadd$106 0020 GR + 7 A$_fsadd$1060 050D GR + 7 A$_fsadd$1061 050F GR + 7 A$_fsadd$1062 0510 GR + 7 A$_fsadd$1063 0511 GR + 7 A$_fsadd$1064 0513 GR + 7 A$_fsadd$1065 0514 GR + 7 A$_fsadd$1066 0515 GR + 7 A$_fsadd$1067 0517 GR + 7 A$_fsadd$1068 0518 GR + 7 A$_fsadd$107 0021 GR + 7 A$_fsadd$1070 0519 GR + 7 A$_fsadd$1071 051B GR + 7 A$_fsadd$1072 051D GR + 7 A$_fsadd$1073 051E GR + 7 A$_fsadd$1074 0520 GR + 7 A$_fsadd$1075 0522 GR + 7 A$_fsadd$1076 0523 GR + 7 A$_fsadd$1077 0525 GR + 7 A$_fsadd$1078 0527 GR + 7 A$_fsadd$1079 0528 GR + 7 A$_fsadd$108 0022 GR + 7 A$_fsadd$1080 052A GR + 7 A$_fsadd$1081 052C GR + 7 A$_fsadd$1083 052D GR + 7 A$_fsadd$1084 052F GR + 7 A$_fsadd$1085 0532 GR + 7 A$_fsadd$1086 0533 GR + 7 A$_fsadd$1087 0534 GR + 7 A$_fsadd$1088 0536 GR + 7 A$_fsadd$1089 0537 GR + 7 A$_fsadd$109 0025 GR + 7 A$_fsadd$1090 0538 GR + 7 A$_fsadd$1091 053A GR + 7 A$_fsadd$1092 053B GR + 7 A$_fsadd$1093 053C GR + 7 A$_fsadd$1094 053E GR + 7 A$_fsadd$1096 053F GR + 7 A$_fsadd$1097 0542 GR + 7 A$_fsadd$1098 0543 GR + 7 A$_fsadd$1099 0545 GR + 7 A$_fsadd$110 0026 GR + 7 A$_fsadd$1100 0546 GR + 7 A$_fsadd$1101 0547 GR + 7 A$_fsadd$1102 0548 GR + 7 A$_fsadd$1103 054A GR + 7 A$_fsadd$1106 054B GR + 7 A$_fsadd$1107 054E GR + 7 A$_fsadd$1108 054F GR + 7 A$_fsadd$1109 0551 GR + 7 A$_fsadd$111 0029 GR + 7 A$_fsadd$1110 0552 GR + 7 A$_fsadd$1111 0553 GR + 7 A$_fsadd$1112 0555 GR + 7 A$_fsadd$1113 0556 GR + 7 A$_fsadd$1114 0557 GR + 7 A$_fsadd$1115 0559 GR + 7 A$_fsadd$1116 055A GR + 7 A$_fsadd$1117 055B GR + 7 A$_fsadd$1118 055D GR + 7 A$_fsadd$112 002A GR + 7 A$_fsadd$1120 055F GR + 7 A$_fsadd$1122 0562 GR + 7 A$_fsadd$1123 0563 GR + 7 A$_fsadd$1124 0565 GR + 7 A$_fsadd$1125 0567 GR + 7 A$_fsadd$1126 0569 GR + 7 A$_fsadd$1128 056C GR + 7 A$_fsadd$113 002D GR + 7 A$_fsadd$1130 056E GR + 7 A$_fsadd$1131 056F GR + 7 A$_fsadd$1132 0571 GR + 7 A$_fsadd$1133 0573 GR + 7 A$_fsadd$1134 0575 GR + 7 A$_fsadd$1136 0578 GR + 7 A$_fsadd$1137 057B GR + 7 A$_fsadd$1138 057C GR + 7 A$_fsadd$1139 057E GR + 7 A$_fsadd$1140 057F GR + 7 A$_fsadd$1141 0580 GR + 7 A$_fsadd$1142 0582 GR + 7 A$_fsadd$1143 0583 GR + 7 A$_fsadd$1144 0584 GR + 7 A$_fsadd$1145 0586 GR + 7 A$_fsadd$1146 0587 GR + 7 A$_fsadd$1147 0588 GR + 7 A$_fsadd$1148 058A GR + 7 A$_fsadd$1149 058D GR + 7 A$_fsadd$115 002E GR + 7 A$_fsadd$1150 058F GR + 7 A$_fsadd$1151 0591 GR + 7 A$_fsadd$1152 0592 GR + 7 A$_fsadd$1153 0594 GR + 7 A$_fsadd$1154 0596 GR + 7 A$_fsadd$1155 0597 GR + 7 A$_fsadd$1156 0598 GR + 7 A$_fsadd$1157 059A GR + 7 A$_fsadd$1158 059C GR + 7 A$_fsadd$1159 059D GR + 7 A$_fsadd$116 0031 GR + 7 A$_fsadd$1160 059E GR + 7 A$_fsadd$1161 05A0 GR + 7 A$_fsadd$1162 05A2 GR + 7 A$_fsadd$1163 05A3 GR + 7 A$_fsadd$1165 05A4 GR + 7 A$_fsadd$1166 05A7 GR + 7 A$_fsadd$1167 05A8 GR + 7 A$_fsadd$1168 05AA GR + 7 A$_fsadd$1169 05AB GR + 7 A$_fsadd$117 0032 GR + 7 A$_fsadd$1170 05AC GR + 7 A$_fsadd$1171 05AE GR + 7 A$_fsadd$1172 05AF GR + 7 A$_fsadd$1173 05B0 GR + 7 A$_fsadd$1174 05B2 GR + 7 A$_fsadd$1175 05B3 GR + 7 A$_fsadd$1177 05B4 GR + 7 A$_fsadd$1179 05B6 GR + 7 A$_fsadd$118 0033 GR + 7 A$_fsadd$1182 05B9 GR + 7 A$_fsadd$1183 05BC GR + 7 A$_fsadd$1184 05BD GR + 7 A$_fsadd$1185 05BF GR + 7 A$_fsadd$1186 05C0 GR + 7 A$_fsadd$1187 05C1 GR + 7 A$_fsadd$1188 05C3 GR + 7 A$_fsadd$1189 05C4 GR + 7 A$_fsadd$119 0034 GR + 7 A$_fsadd$1190 05C5 GR + 7 A$_fsadd$1191 05C7 GR + 7 A$_fsadd$1192 05C8 GR + 7 A$_fsadd$1194 05C9 GR + 7 A$_fsadd$1195 05CB GR + 7 A$_fsadd$1196 05CD GR + 7 A$_fsadd$1197 05CE GR + 7 A$_fsadd$1198 05D0 GR + 7 A$_fsadd$1199 05D2 GR + 7 A$_fsadd$120 0035 GR + 7 A$_fsadd$1200 05D3 GR + 7 A$_fsadd$1201 05D5 GR + 7 A$_fsadd$1202 05D7 GR + 7 A$_fsadd$1203 05D8 GR + 7 A$_fsadd$1204 05DA GR + 7 A$_fsadd$1205 05DC GR + 7 A$_fsadd$1207 05DD GR + 7 A$_fsadd$1208 05DF GR + 7 A$_fsadd$1209 05E2 GR + 7 A$_fsadd$121 0036 GR + 7 A$_fsadd$1210 05E3 GR + 7 A$_fsadd$1211 05E4 GR + 7 A$_fsadd$1212 05E6 GR + 7 A$_fsadd$1213 05E7 GR + 7 A$_fsadd$1214 05E8 GR + 7 A$_fsadd$1215 05EA GR + 7 A$_fsadd$1216 05EB GR + 7 A$_fsadd$1217 05EC GR + 7 A$_fsadd$1218 05EE GR + 7 A$_fsadd$122 0037 GR + 7 A$_fsadd$1220 05EF GR + 7 A$_fsadd$1221 05F2 GR + 7 A$_fsadd$1222 05F3 GR + 7 A$_fsadd$1223 05F5 GR + 7 A$_fsadd$1224 05F6 GR + 7 A$_fsadd$1225 05F7 GR + 7 A$_fsadd$1226 05F8 GR + 7 A$_fsadd$1227 05FA GR + 7 A$_fsadd$123 0038 GR + 7 A$_fsadd$1230 05FB GR + 7 A$_fsadd$1231 05FE GR + 7 A$_fsadd$1232 05FF GR + 7 A$_fsadd$1233 0601 GR + 7 A$_fsadd$1234 0602 GR + 7 A$_fsadd$1235 0603 GR + 7 A$_fsadd$1236 0605 GR + 7 A$_fsadd$1237 0606 GR + 7 A$_fsadd$1238 0607 GR + 7 A$_fsadd$1239 0609 GR + 7 A$_fsadd$124 0039 GR + 7 A$_fsadd$1240 060A GR + 7 A$_fsadd$1241 060B GR + 7 A$_fsadd$1242 060D GR + 7 A$_fsadd$1243 060F GR + 7 A$_fsadd$1244 0611 GR + 7 A$_fsadd$1245 0613 GR + 7 A$_fsadd$1246 0614 GR + 7 A$_fsadd$1247 0616 GR + 7 A$_fsadd$1248 0617 GR + 7 A$_fsadd$1249 0619 GR + 7 A$_fsadd$125 003A GR + 7 A$_fsadd$1250 061A GR + 7 A$_fsadd$1251 061C GR + 7 A$_fsadd$1252 061D GR + 7 A$_fsadd$1253 061F GR + 7 A$_fsadd$1254 0621 GR + 7 A$_fsadd$1255 0623 GR + 7 A$_fsadd$1256 0625 GR + 7 A$_fsadd$1257 0627 GR + 7 A$_fsadd$1258 0629 GR + 7 A$_fsadd$1259 062B GR + 7 A$_fsadd$126 003B GR + 7 A$_fsadd$1260 062D GR + 7 A$_fsadd$1261 062F GR + 7 A$_fsadd$1262 0631 GR + 7 A$_fsadd$1263 0633 GR + 7 A$_fsadd$1264 0634 GR + 7 A$_fsadd$1265 0636 GR + 7 A$_fsadd$1266 0637 GR + 7 A$_fsadd$1267 0639 GR + 7 A$_fsadd$1268 063A GR + 7 A$_fsadd$1269 063C GR + 7 A$_fsadd$127 003C GR + 7 A$_fsadd$1270 063D GR + 7 A$_fsadd$1271 063F GR + 7 A$_fsadd$1272 0641 GR + 7 A$_fsadd$1273 0644 GR + 7 A$_fsadd$1275 0646 GR + 7 A$_fsadd$1276 0648 GR + 7 A$_fsadd$1277 064B GR + 7 A$_fsadd$1278 064D GR + 7 A$_fsadd$1279 064E GR + 7 A$_fsadd$128 003F GR + 7 A$_fsadd$1280 064F GR + 7 A$_fsadd$1281 0651 GR + 7 A$_fsadd$1282 0652 GR + 7 A$_fsadd$1283 0653 GR + 7 A$_fsadd$1284 0655 GR + 7 A$_fsadd$1285 0656 GR + 7 A$_fsadd$1286 0657 GR + 7 A$_fsadd$1287 0659 GR + 7 A$_fsadd$1289 065A GR + 7 A$_fsadd$129 0040 GR + 7 A$_fsadd$1290 065D GR + 7 A$_fsadd$1291 065E GR + 7 A$_fsadd$1292 0660 GR + 7 A$_fsadd$1293 0661 GR + 7 A$_fsadd$1294 0662 GR + 7 A$_fsadd$1295 0664 GR + 7 A$_fsadd$1296 0665 GR + 7 A$_fsadd$1297 0666 GR + 7 A$_fsadd$1298 0668 GR + 7 A$_fsadd$1299 0669 GR + 7 A$_fsadd$130 0041 GR + 7 A$_fsadd$1300 066A GR + 7 A$_fsadd$1301 066C GR + 7 A$_fsadd$1302 066F GR + 7 A$_fsadd$1303 0671 GR + 7 A$_fsadd$1304 0672 GR + 7 A$_fsadd$1305 0673 GR + 7 A$_fsadd$1306 0675 GR + 7 A$_fsadd$1307 0676 GR + 7 A$_fsadd$1308 0678 GR + 7 A$_fsadd$1309 067A GR + 7 A$_fsadd$131 0042 GR + 7 A$_fsadd$1310 067B GR + 7 A$_fsadd$1311 067C GR + 7 A$_fsadd$1312 067D GR + 7 A$_fsadd$1313 067F GR + 7 A$_fsadd$1315 0680 GR + 7 A$_fsadd$1316 0683 GR + 7 A$_fsadd$1317 0684 GR + 7 A$_fsadd$1318 0686 GR + 7 A$_fsadd$1319 0687 GR + 7 A$_fsadd$132 0043 GR + 7 A$_fsadd$1320 0688 GR + 7 A$_fsadd$1321 068A GR + 7 A$_fsadd$1322 068D GR + 7 A$_fsadd$1323 068F GR + 7 A$_fsadd$1324 0691 GR + 7 A$_fsadd$1325 0693 GR + 7 A$_fsadd$1326 0695 GR + 7 A$_fsadd$1327 0696 GR + 7 A$_fsadd$1328 0698 GR + 7 A$_fsadd$1329 0699 GR + 7 A$_fsadd$133 0044 GR + 7 A$_fsadd$1330 069B GR + 7 A$_fsadd$1331 069D GR + 7 A$_fsadd$1332 06A0 GR + 7 A$_fsadd$1333 06A3 GR + 7 A$_fsadd$1334 06A6 GR + 7 A$_fsadd$1335 06A7 GR + 7 A$_fsadd$1336 06A9 GR + 7 A$_fsadd$1337 06AA GR + 7 A$_fsadd$1338 06AB GR + 7 A$_fsadd$1339 06AD GR + 7 A$_fsadd$134 0045 GR + 7 A$_fsadd$1340 06AE GR + 7 A$_fsadd$1341 06AF GR + 7 A$_fsadd$1342 06B1 GR + 7 A$_fsadd$1343 06B2 GR + 7 A$_fsadd$1344 06B3 GR + 7 A$_fsadd$1345 06B5 GR + 7 A$_fsadd$1346 06B7 GR + 7 A$_fsadd$1347 06B9 GR + 7 A$_fsadd$1348 06BB GR + 7 A$_fsadd$1349 06BD GR + 7 A$_fsadd$135 0046 GR + 7 A$_fsadd$1350 06BF GR + 7 A$_fsadd$1351 06C1 GR + 7 A$_fsadd$1352 06C3 GR + 7 A$_fsadd$1353 06C5 GR + 7 A$_fsadd$1354 06C8 GR + 7 A$_fsadd$1355 06C9 GR + 7 A$_fsadd$1356 06CB GR + 7 A$_fsadd$1357 06CC GR + 7 A$_fsadd$1358 06CD GR + 7 A$_fsadd$1359 06CF GR + 7 A$_fsadd$136 0047 GR + 7 A$_fsadd$1360 06D0 GR + 7 A$_fsadd$1361 06D1 GR + 7 A$_fsadd$1362 06D3 GR + 7 A$_fsadd$1363 06D4 GR + 7 A$_fsadd$1364 06D5 GR + 7 A$_fsadd$1365 06D7 GR + 7 A$_fsadd$1366 06D9 GR + 7 A$_fsadd$1367 06DB GR + 7 A$_fsadd$1368 06DD GR + 7 A$_fsadd$1369 06DF GR + 7 A$_fsadd$137 0048 GR + 7 A$_fsadd$1370 06E1 GR + 7 A$_fsadd$1371 06E3 GR + 7 A$_fsadd$1372 06E5 GR + 7 A$_fsadd$1373 06E7 GR + 7 A$_fsadd$1374 06EA GR + 7 A$_fsadd$1375 06EC GR + 7 A$_fsadd$1376 06ED GR + 7 A$_fsadd$1377 06EE GR + 7 A$_fsadd$1378 06F0 GR + 7 A$_fsadd$1379 06F1 GR + 7 A$_fsadd$138 0049 GR + 7 A$_fsadd$1380 06F2 GR + 7 A$_fsadd$1381 06F4 GR + 7 A$_fsadd$1382 06F5 GR + 7 A$_fsadd$1383 06F6 GR + 7 A$_fsadd$1384 06F8 GR + 7 A$_fsadd$1386 06F9 GR + 7 A$_fsadd$1387 06FC GR + 7 A$_fsadd$1388 06FD GR + 7 A$_fsadd$1389 06FF GR + 7 A$_fsadd$1390 0700 GR + 7 A$_fsadd$1391 0701 GR + 7 A$_fsadd$1392 0703 GR + 7 A$_fsadd$1393 0704 GR + 7 A$_fsadd$1394 0705 GR + 7 A$_fsadd$1395 0707 GR + 7 A$_fsadd$1396 0708 GR + 7 A$_fsadd$1398 0709 GR + 7 A$_fsadd$1399 070B GR + 7 A$_fsadd$140 004A GR + 7 A$_fsadd$1400 070E GR + 7 A$_fsadd$1401 0711 GR + 7 A$_fsadd$1405 0714 GR + 7 A$_fsadd$141 004D GR + 7 A$_fsadd$142 004E GR + 7 A$_fsadd$143 004F GR + 7 A$_fsadd$144 0050 GR + 7 A$_fsadd$145 0051 GR + 7 A$_fsadd$146 0052 GR + 7 A$_fsadd$147 0053 GR + 7 A$_fsadd$148 0054 GR + 7 A$_fsadd$149 0055 GR + 7 A$_fsadd$150 0056 GR + 7 A$_fsadd$151 0057 GR + 7 A$_fsadd$152 0058 GR + 7 A$_fsadd$153 005B GR + 7 A$_fsadd$154 005C GR + 7 A$_fsadd$155 005D GR + 7 A$_fsadd$156 005E GR + 7 A$_fsadd$157 005F GR + 7 A$_fsadd$158 0060 GR + 7 A$_fsadd$159 0061 GR + 7 A$_fsadd$160 0062 GR + 7 A$_fsadd$161 0063 GR + 7 A$_fsadd$162 0064 GR + 7 A$_fsadd$163 0065 GR + 7 A$_fsadd$165 0066 GR + 7 A$_fsadd$166 0069 GR + 7 A$_fsadd$167 006A GR + 7 A$_fsadd$168 006B GR + 7 A$_fsadd$169 006C GR + 7 A$_fsadd$170 006D GR + 7 A$_fsadd$171 006E GR + 7 A$_fsadd$172 006F GR + 7 A$_fsadd$173 0070 GR + 7 A$_fsadd$174 0071 GR + 7 A$_fsadd$175 0072 GR + 7 A$_fsadd$176 0073 GR + 7 A$_fsadd$177 0074 GR + 7 A$_fsadd$178 0075 GR + 7 A$_fsadd$179 0076 GR + 7 A$_fsadd$180 0077 GR + 7 A$_fsadd$182 0078 GR + 7 A$_fsadd$185 007A GR + 7 A$_fsadd$186 007D GR + 7 A$_fsadd$187 007E GR + 7 A$_fsadd$188 007F GR + 7 A$_fsadd$189 0080 GR + 7 A$_fsadd$190 0081 GR + 7 A$_fsadd$191 0082 GR + 7 A$_fsadd$192 0083 GR + 7 A$_fsadd$193 0084 GR + 7 A$_fsadd$194 0085 GR + 7 A$_fsadd$195 0086 GR + 7 A$_fsadd$197 0087 GR + 7 A$_fsadd$198 0088 GR + 7 A$_fsadd$199 008A GR + 7 A$_fsadd$200 008C GR + 7 A$_fsadd$201 008E GR + 7 A$_fsadd$204 0091 GR + 7 A$_fsadd$205 0094 GR + 7 A$_fsadd$206 0095 GR + 7 A$_fsadd$207 0096 GR + 7 A$_fsadd$208 0097 GR + 7 A$_fsadd$209 0098 GR + 7 A$_fsadd$210 0099 GR + 7 A$_fsadd$211 009A GR + 7 A$_fsadd$212 009B GR + 7 A$_fsadd$213 009C GR + 7 A$_fsadd$214 009D GR + 7 A$_fsadd$215 009E GR + 7 A$_fsadd$216 009F GR + 7 A$_fsadd$217 00A0 GR + 7 A$_fsadd$218 00A1 GR + 7 A$_fsadd$219 00A2 GR + 7 A$_fsadd$221 00A3 GR + 7 A$_fsadd$224 00A5 GR + 7 A$_fsadd$225 00A8 GR + 7 A$_fsadd$226 00A9 GR + 7 A$_fsadd$227 00AA GR + 7 A$_fsadd$228 00AB GR + 7 A$_fsadd$229 00AC GR + 7 A$_fsadd$230 00AD GR + 7 A$_fsadd$231 00AE GR + 7 A$_fsadd$232 00AF GR + 7 A$_fsadd$233 00B0 GR + 7 A$_fsadd$234 00B1 GR + 7 A$_fsadd$236 00B2 GR + 7 A$_fsadd$237 00B3 GR + 7 A$_fsadd$238 00B5 GR + 7 A$_fsadd$239 00B7 GR + 7 A$_fsadd$240 00B9 GR + 7 A$_fsadd$243 00BC GR + 7 A$_fsadd$244 00BF GR + 7 A$_fsadd$245 00C0 GR + 7 A$_fsadd$246 00C1 GR + 7 A$_fsadd$247 00C2 GR + 7 A$_fsadd$248 00C3 GR + 7 A$_fsadd$249 00C4 GR + 7 A$_fsadd$250 00C5 GR + 7 A$_fsadd$251 00C6 GR + 7 A$_fsadd$252 00C7 GR + 7 A$_fsadd$253 00C8 GR + 7 A$_fsadd$254 00C9 GR + 7 A$_fsadd$255 00CA GR + 7 A$_fsadd$256 00CC GR + 7 A$_fsadd$257 00CD GR + 7 A$_fsadd$258 00CF GR + 7 A$_fsadd$259 00D0 GR + 7 A$_fsadd$260 00D1 GR + 7 A$_fsadd$261 00D2 GR + 7 A$_fsadd$262 00D3 GR + 7 A$_fsadd$263 00D4 GR + 7 A$_fsadd$264 00D6 GR + 7 A$_fsadd$265 00D9 GR + 7 A$_fsadd$267 00DB GR + 7 A$_fsadd$268 00DC GR + 7 A$_fsadd$269 00DD GR + 7 A$_fsadd$270 00DF GR + 7 A$_fsadd$271 00E0 GR + 7 A$_fsadd$272 00E1 GR + 7 A$_fsadd$273 00E4 GR + 7 A$_fsadd$274 00E5 GR + 7 A$_fsadd$275 00E6 GR + 7 A$_fsadd$277 00E7 GR + 7 A$_fsadd$278 00E8 GR + 7 A$_fsadd$280 00E9 GR + 7 A$_fsadd$281 00EC GR + 7 A$_fsadd$282 00ED GR + 7 A$_fsadd$283 00EE GR + 7 A$_fsadd$284 00EF GR + 7 A$_fsadd$285 00F0 GR + 7 A$_fsadd$286 00F1 GR + 7 A$_fsadd$287 00F2 GR + 7 A$_fsadd$288 00F3 GR + 7 A$_fsadd$289 00F4 GR + 7 A$_fsadd$290 00F5 GR + 7 A$_fsadd$291 00F6 GR + 7 A$_fsadd$292 00F7 GR + 7 A$_fsadd$293 00F9 GR + 7 A$_fsadd$294 00FA GR + 7 A$_fsadd$295 00FC GR + 7 A$_fsadd$296 00FD GR + 7 A$_fsadd$297 00FE GR + 7 A$_fsadd$298 00FF GR + 7 A$_fsadd$299 0100 GR + 7 A$_fsadd$300 0101 GR + 7 A$_fsadd$301 0103 GR + 7 A$_fsadd$302 0106 GR + 7 A$_fsadd$304 0108 GR + 7 A$_fsadd$305 0109 GR + 7 A$_fsadd$306 010A GR + 7 A$_fsadd$307 010C GR + 7 A$_fsadd$308 010D GR + 7 A$_fsadd$309 010E GR + 7 A$_fsadd$310 0111 GR + 7 A$_fsadd$311 0112 GR + 7 A$_fsadd$312 0113 GR + 7 A$_fsadd$314 0114 GR + 7 A$_fsadd$315 0115 GR + 7 A$_fsadd$317 0116 GR + 7 A$_fsadd$318 0119 GR + 7 A$_fsadd$319 011A GR + 7 A$_fsadd$320 011B GR + 7 A$_fsadd$321 011C GR + 7 A$_fsadd$322 011D GR + 7 A$_fsadd$323 011E GR + 7 A$_fsadd$324 0120 GR + 7 A$_fsadd$325 0121 GR + 7 A$_fsadd$327 0122 GR + 7 A$_fsadd$328 0123 GR + 7 A$_fsadd$329 0124 GR + 7 A$_fsadd$330 0125 GR + 7 A$_fsadd$331 0128 GR + 7 A$_fsadd$332 0129 GR + 7 A$_fsadd$333 012A GR + 7 A$_fsadd$334 012B GR + 7 A$_fsadd$335 012C GR + 7 A$_fsadd$336 012D GR + 7 A$_fsadd$337 012E GR + 7 A$_fsadd$338 012F GR + 7 A$_fsadd$339 0130 GR + 7 A$_fsadd$340 0131 GR + 7 A$_fsadd$341 0133 GR + 7 A$_fsadd$342 0135 GR + 7 A$_fsadd$343 0138 GR + 7 A$_fsadd$345 013A GR + 7 A$_fsadd$348 013C GR + 7 A$_fsadd$349 013F GR + 7 A$_fsadd$350 0140 GR + 7 A$_fsadd$351 0141 GR + 7 A$_fsadd$352 0142 GR + 7 A$_fsadd$353 0143 GR + 7 A$_fsadd$354 0144 GR + 7 A$_fsadd$355 0145 GR + 7 A$_fsadd$356 0146 GR + 7 A$_fsadd$357 0147 GR + 7 A$_fsadd$358 0148 GR + 7 A$_fsadd$360 0149 GR + 7 A$_fsadd$361 014A GR + 7 A$_fsadd$362 014C GR + 7 A$_fsadd$363 014E GR + 7 A$_fsadd$364 0150 GR + 7 A$_fsadd$365 0153 GR + 7 A$_fsadd$366 0155 GR + 7 A$_fsadd$367 0157 GR + 7 A$_fsadd$369 0159 GR + 7 A$_fsadd$370 015A GR + 7 A$_fsadd$371 015C GR + 7 A$_fsadd$372 015E GR + 7 A$_fsadd$373 0160 GR + 7 A$_fsadd$376 0163 GR + 7 A$_fsadd$377 0166 GR + 7 A$_fsadd$378 0167 GR + 7 A$_fsadd$379 0168 GR + 7 A$_fsadd$380 0169 GR + 7 A$_fsadd$381 016A GR + 7 A$_fsadd$382 016B GR + 7 A$_fsadd$383 016D GR + 7 A$_fsadd$384 016E GR + 7 A$_fsadd$386 016F GR + 7 A$_fsadd$387 0170 GR + 7 A$_fsadd$388 0171 GR + 7 A$_fsadd$389 0172 GR + 7 A$_fsadd$390 0175 GR + 7 A$_fsadd$391 0176 GR + 7 A$_fsadd$392 0177 GR + 7 A$_fsadd$393 0178 GR + 7 A$_fsadd$394 0179 GR + 7 A$_fsadd$395 017A GR + 7 A$_fsadd$396 017B GR + 7 A$_fsadd$397 017C GR + 7 A$_fsadd$398 017D GR + 7 A$_fsadd$399 017E GR + 7 A$_fsadd$400 0180 GR + 7 A$_fsadd$401 0182 GR + 7 A$_fsadd$402 0185 GR + 7 A$_fsadd$404 0187 GR + 7 A$_fsadd$407 0189 GR + 7 A$_fsadd$408 018C GR + 7 A$_fsadd$409 018D GR + 7 A$_fsadd$410 018E GR + 7 A$_fsadd$411 018F GR + 7 A$_fsadd$412 0190 GR + 7 A$_fsadd$413 0191 GR + 7 A$_fsadd$414 0192 GR + 7 A$_fsadd$415 0193 GR + 7 A$_fsadd$416 0194 GR + 7 A$_fsadd$417 0195 GR + 7 A$_fsadd$419 0196 GR + 7 A$_fsadd$420 0197 GR + 7 A$_fsadd$421 0199 GR + 7 A$_fsadd$422 019B GR + 7 A$_fsadd$423 019D GR + 7 A$_fsadd$424 01A0 GR + 7 A$_fsadd$425 01A2 GR + 7 A$_fsadd$426 01A4 GR + 7 A$_fsadd$428 01A6 GR + 7 A$_fsadd$429 01A7 GR + 7 A$_fsadd$430 01A9 GR + 7 A$_fsadd$431 01AB GR + 7 A$_fsadd$432 01AD GR + 7 A$_fsadd$435 01B0 GR + 7 A$_fsadd$436 01B3 GR + 7 A$_fsadd$437 01B4 GR + 7 A$_fsadd$438 01B5 GR + 7 A$_fsadd$439 01B6 GR + 7 A$_fsadd$440 01B7 GR + 7 A$_fsadd$441 01B8 GR + 7 A$_fsadd$442 01B9 GR + 7 A$_fsadd$443 01BA GR + 7 A$_fsadd$444 01BB GR + 7 A$_fsadd$445 01BC GR + 7 A$_fsadd$446 01BD GR + 7 A$_fsadd$447 01BE GR + 7 A$_fsadd$448 01C1 GR + 7 A$_fsadd$449 01C3 GR + 7 A$_fsadd$450 01C6 GR + 7 A$_fsadd$451 01C7 GR + 7 A$_fsadd$452 01C9 GR + 7 A$_fsadd$453 01CB GR + 7 A$_fsadd$454 01CC GR + 7 A$_fsadd$455 01CD GR + 7 A$_fsadd$456 01CE GR + 7 A$_fsadd$457 01CF GR + 7 A$_fsadd$458 01D0 GR + 7 A$_fsadd$459 01D1 GR + 7 A$_fsadd$460 01D2 GR + 7 A$_fsadd$461 01D3 GR + 7 A$_fsadd$462 01D4 GR + 7 A$_fsadd$463 01D5 GR + 7 A$_fsadd$464 01D6 GR + 7 A$_fsadd$465 01D7 GR + 7 A$_fsadd$466 01D8 GR + 7 A$_fsadd$467 01DA GR + 7 A$_fsadd$468 01DB GR + 7 A$_fsadd$469 01DC GR + 7 A$_fsadd$470 01DD GR + 7 A$_fsadd$471 01DF GR + 7 A$_fsadd$472 01E1 GR + 7 A$_fsadd$473 01E2 GR + 7 A$_fsadd$474 01E3 GR + 7 A$_fsadd$475 01E4 GR + 7 A$_fsadd$476 01E5 GR + 7 A$_fsadd$477 01E6 GR + 7 A$_fsadd$478 01E7 GR + 7 A$_fsadd$479 01E8 GR + 7 A$_fsadd$480 01E9 GR + 7 A$_fsadd$481 01EA GR + 7 A$_fsadd$482 01EB GR + 7 A$_fsadd$483 01EE GR + 7 A$_fsadd$484 01EF GR + 7 A$_fsadd$485 01F0 GR + 7 A$_fsadd$486 01F1 GR + 7 A$_fsadd$487 01F2 GR + 7 A$_fsadd$488 01F3 GR + 7 A$_fsadd$489 01F4 GR + 7 A$_fsadd$490 01F5 GR + 7 A$_fsadd$491 01F6 GR + 7 A$_fsadd$492 01F7 GR + 7 A$_fsadd$493 01F8 GR + 7 A$_fsadd$495 01F9 GR + 7 A$_fsadd$496 01FC GR + 7 A$_fsadd$497 01FD GR + 7 A$_fsadd$498 01FE GR + 7 A$_fsadd$499 01FF GR + 7 A$_fsadd$500 0200 GR + 7 A$_fsadd$501 0201 GR + 7 A$_fsadd$502 0202 GR + 7 A$_fsadd$503 0203 GR + 7 A$_fsadd$504 0204 GR + 7 A$_fsadd$505 0205 GR + 7 A$_fsadd$506 0206 GR + 7 A$_fsadd$507 0207 GR + 7 A$_fsadd$508 020A GR + 7 A$_fsadd$509 020C GR + 7 A$_fsadd$510 020F GR + 7 A$_fsadd$511 0210 GR + 7 A$_fsadd$512 0212 GR + 7 A$_fsadd$513 0214 GR + 7 A$_fsadd$514 0215 GR + 7 A$_fsadd$515 0216 GR + 7 A$_fsadd$516 0217 GR + 7 A$_fsadd$517 0218 GR + 7 A$_fsadd$518 0219 GR + 7 A$_fsadd$519 021A GR + 7 A$_fsadd$520 021B GR + 7 A$_fsadd$521 021C GR + 7 A$_fsadd$522 021D GR + 7 A$_fsadd$523 021E GR + 7 A$_fsadd$524 021F GR + 7 A$_fsadd$525 0220 GR + 7 A$_fsadd$526 0221 GR + 7 A$_fsadd$527 0223 GR + 7 A$_fsadd$528 0224 GR + 7 A$_fsadd$529 0225 GR + 7 A$_fsadd$530 0226 GR + 7 A$_fsadd$531 0228 GR + 7 A$_fsadd$532 022A GR + 7 A$_fsadd$533 022B GR + 7 A$_fsadd$534 022C GR + 7 A$_fsadd$535 022D GR + 7 A$_fsadd$536 022E GR + 7 A$_fsadd$537 022F GR + 7 A$_fsadd$538 0230 GR + 7 A$_fsadd$539 0231 GR + 7 A$_fsadd$540 0232 GR + 7 A$_fsadd$541 0233 GR + 7 A$_fsadd$542 0234 GR + 7 A$_fsadd$543 0237 GR + 7 A$_fsadd$544 0238 GR + 7 A$_fsadd$545 0239 GR + 7 A$_fsadd$546 023A GR + 7 A$_fsadd$547 023B GR + 7 A$_fsadd$548 023C GR + 7 A$_fsadd$549 023D GR + 7 A$_fsadd$550 023E GR + 7 A$_fsadd$551 023F GR + 7 A$_fsadd$552 0240 GR + 7 A$_fsadd$553 0241 GR + 7 A$_fsadd$555 0242 GR + 7 A$_fsadd$556 0245 GR + 7 A$_fsadd$557 0246 GR + 7 A$_fsadd$558 0247 GR + 7 A$_fsadd$559 0248 GR + 7 A$_fsadd$560 0249 GR + 7 A$_fsadd$561 024A GR + 7 A$_fsadd$562 024B GR + 7 A$_fsadd$563 024C GR + 7 A$_fsadd$564 024D GR + 7 A$_fsadd$565 024E GR + 7 A$_fsadd$567 024F GR + 7 A$_fsadd$568 0250 GR + 7 A$_fsadd$569 0251 GR + 7 A$_fsadd$571 0253 GR + 7 A$_fsadd$573 0254 GR + 7 A$_fsadd$576 0256 GR + 7 A$_fsadd$577 0259 GR + 7 A$_fsadd$578 025A GR + 7 A$_fsadd$579 025C GR + 7 A$_fsadd$580 025D GR + 7 A$_fsadd$581 025E GR + 7 A$_fsadd$582 0260 GR + 7 A$_fsadd$583 0261 GR + 7 A$_fsadd$584 0262 GR + 7 A$_fsadd$585 0264 GR + 7 A$_fsadd$586 0265 GR + 7 A$_fsadd$587 0266 GR + 7 A$_fsadd$588 0268 GR + 7 A$_fsadd$589 026B GR + 7 A$_fsadd$590 026C GR + 7 A$_fsadd$591 026D GR + 7 A$_fsadd$592 026F GR + 7 A$_fsadd$593 0270 GR + 7 A$_fsadd$594 0271 GR + 7 A$_fsadd$595 0273 GR + 7 A$_fsadd$596 0274 GR + 7 A$_fsadd$597 0275 GR + 7 A$_fsadd$598 0276 GR + 7 A$_fsadd$599 0278 GR + 7 A$_fsadd$600 0279 GR + 7 A$_fsadd$601 027A GR + 7 A$_fsadd$602 027B GR + 7 A$_fsadd$603 027D GR + 7 A$_fsadd$604 027E GR + 7 A$_fsadd$607 027F GR + 7 A$_fsadd$608 0282 GR + 7 A$_fsadd$609 0283 GR + 7 A$_fsadd$610 0285 GR + 7 A$_fsadd$611 0286 GR + 7 A$_fsadd$612 0287 GR + 7 A$_fsadd$613 0289 GR + 7 A$_fsadd$614 028A GR + 7 A$_fsadd$615 028B GR + 7 A$_fsadd$616 028D GR + 7 A$_fsadd$617 028E GR + 7 A$_fsadd$619 028F GR + 7 A$_fsadd$620 0291 GR + 7 A$_fsadd$621 0292 GR + 7 A$_fsadd$623 0294 GR + 7 A$_fsadd$625 0295 GR + 7 A$_fsadd$628 0297 GR + 7 A$_fsadd$629 029A GR + 7 A$_fsadd$630 029B GR + 7 A$_fsadd$631 029D GR + 7 A$_fsadd$632 029E GR + 7 A$_fsadd$633 029F GR + 7 A$_fsadd$634 02A1 GR + 7 A$_fsadd$635 02A2 GR + 7 A$_fsadd$636 02A3 GR + 7 A$_fsadd$637 02A5 GR + 7 A$_fsadd$638 02A6 GR + 7 A$_fsadd$639 02A7 GR + 7 A$_fsadd$640 02A9 GR + 7 A$_fsadd$641 02AC GR + 7 A$_fsadd$642 02AD GR + 7 A$_fsadd$643 02AE GR + 7 A$_fsadd$644 02B0 GR + 7 A$_fsadd$645 02B1 GR + 7 A$_fsadd$646 02B2 GR + 7 A$_fsadd$647 02B4 GR + 7 A$_fsadd$648 02B5 GR + 7 A$_fsadd$649 02B6 GR + 7 A$_fsadd$650 02B7 GR + 7 A$_fsadd$651 02B9 GR + 7 A$_fsadd$652 02BA GR + 7 A$_fsadd$653 02BB GR + 7 A$_fsadd$654 02BC GR + 7 A$_fsadd$655 02BE GR + 7 A$_fsadd$656 02BF GR + 7 A$_fsadd$659 02C0 GR + 7 A$_fsadd$660 02C3 GR + 7 A$_fsadd$661 02C4 GR + 7 A$_fsadd$662 02C6 GR + 7 A$_fsadd$663 02C7 GR + 7 A$_fsadd$664 02C8 GR + 7 A$_fsadd$665 02CA GR + 7 A$_fsadd$666 02CD GR + 7 A$_fsadd$667 02CE GR + 7 A$_fsadd$668 02D0 GR + 7 A$_fsadd$669 02D1 GR + 7 A$_fsadd$670 02D2 GR + 7 A$_fsadd$671 02D4 GR + 7 A$_fsadd$672 02D5 GR + 7 A$_fsadd$673 02D7 GR + 7 A$_fsadd$674 02D9 GR + 7 A$_fsadd$675 02DB GR + 7 A$_fsadd$676 02DD GR + 7 A$_fsadd$677 02E0 GR + 7 A$_fsadd$678 02E3 GR + 7 A$_fsadd$679 02E5 GR + 7 A$_fsadd$680 02E7 GR + 7 A$_fsadd$683 02EA GR + 7 A$_fsadd$684 02ED GR + 7 A$_fsadd$685 02EE GR + 7 A$_fsadd$686 02F0 GR + 7 A$_fsadd$687 02F1 GR + 7 A$_fsadd$688 02F2 GR + 7 A$_fsadd$689 02F4 GR + 7 A$_fsadd$690 02F7 GR + 7 A$_fsadd$691 02F8 GR + 7 A$_fsadd$692 02FA GR + 7 A$_fsadd$693 02FB GR + 7 A$_fsadd$694 02FC GR + 7 A$_fsadd$695 02FE GR + 7 A$_fsadd$696 02FF GR + 7 A$_fsadd$697 0301 GR + 7 A$_fsadd$698 0303 GR + 7 A$_fsadd$699 0305 GR + 7 A$_fsadd$700 0307 GR + 7 A$_fsadd$701 0309 GR + 7 A$_fsadd$702 030B GR + 7 A$_fsadd$703 030E GR + 7 A$_fsadd$704 030F GR + 7 A$_fsadd$705 0311 GR + 7 A$_fsadd$706 0312 GR + 7 A$_fsadd$707 0313 GR + 7 A$_fsadd$708 0315 GR + 7 A$_fsadd$709 0316 GR + 7 A$_fsadd$710 0317 GR + 7 A$_fsadd$711 0319 GR + 7 A$_fsadd$712 031A GR + 7 A$_fsadd$713 031B GR + 7 A$_fsadd$714 031D GR + 7 A$_fsadd$715 0320 GR + 7 A$_fsadd$716 0322 GR + 7 A$_fsadd$717 0324 GR + 7 A$_fsadd$718 0325 GR + 7 A$_fsadd$719 0327 GR + 7 A$_fsadd$721 0329 GR + 7 A$_fsadd$722 032B GR + 7 A$_fsadd$723 032D GR + 7 A$_fsadd$724 032E GR + 7 A$_fsadd$725 0330 GR + 7 A$_fsadd$726 0332 GR + 7 A$_fsadd$727 0333 GR + 7 A$_fsadd$728 0335 GR + 7 A$_fsadd$729 0337 GR + 7 A$_fsadd$730 0338 GR + 7 A$_fsadd$731 033A GR + 7 A$_fsadd$732 033C GR + 7 A$_fsadd$733 033D GR + 7 A$_fsadd$735 033F GR + 7 A$_fsadd$736 0342 GR + 7 A$_fsadd$737 0345 GR + 7 A$_fsadd$738 0347 GR + 7 A$_fsadd$739 0348 GR + 7 A$_fsadd$740 0349 GR + 7 A$_fsadd$741 034B GR + 7 A$_fsadd$742 034C GR + 7 A$_fsadd$743 034D GR + 7 A$_fsadd$744 034F GR + 7 A$_fsadd$745 0350 GR + 7 A$_fsadd$746 0351 GR + 7 A$_fsadd$747 0353 GR + 7 A$_fsadd$748 0354 GR + 7 A$_fsadd$751 0357 GR + 7 A$_fsadd$752 035A GR + 7 A$_fsadd$753 035B GR + 7 A$_fsadd$754 035D GR + 7 A$_fsadd$755 035E GR + 7 A$_fsadd$756 035F GR + 7 A$_fsadd$757 0361 GR + 7 A$_fsadd$758 0364 GR + 7 A$_fsadd$759 0365 GR + 7 A$_fsadd$760 0367 GR + 7 A$_fsadd$761 0368 GR + 7 A$_fsadd$762 0369 GR + 7 A$_fsadd$763 036B GR + 7 A$_fsadd$764 036C GR + 7 A$_fsadd$765 036E GR + 7 A$_fsadd$766 0370 GR + 7 A$_fsadd$767 0372 GR + 7 A$_fsadd$768 0374 GR + 7 A$_fsadd$769 0376 GR + 7 A$_fsadd$770 0378 GR + 7 A$_fsadd$771 037B GR + 7 A$_fsadd$772 037C GR + 7 A$_fsadd$773 037E GR + 7 A$_fsadd$774 037F GR + 7 A$_fsadd$775 0380 GR + 7 A$_fsadd$776 0382 GR + 7 A$_fsadd$777 0383 GR + 7 A$_fsadd$778 0384 GR + 7 A$_fsadd$779 0386 GR + 7 A$_fsadd$780 0387 GR + 7 A$_fsadd$781 0388 GR + 7 A$_fsadd$782 038A GR + 7 A$_fsadd$783 038D GR + 7 A$_fsadd$784 038F GR + 7 A$_fsadd$785 0391 GR + 7 A$_fsadd$786 0392 GR + 7 A$_fsadd$787 0394 GR + 7 A$_fsadd$789 0396 GR + 7 A$_fsadd$790 0398 GR + 7 A$_fsadd$791 039A GR + 7 A$_fsadd$792 039B GR + 7 A$_fsadd$793 039D GR + 7 A$_fsadd$794 039F GR + 7 A$_fsadd$795 03A0 GR + 7 A$_fsadd$796 03A2 GR + 7 A$_fsadd$797 03A4 GR + 7 A$_fsadd$798 03A5 GR + 7 A$_fsadd$799 03A7 GR + 7 A$_fsadd$800 03A9 GR + 7 A$_fsadd$801 03AA GR + 7 A$_fsadd$803 03AC GR + 7 A$_fsadd$804 03AF GR + 7 A$_fsadd$805 03B2 GR + 7 A$_fsadd$806 03B4 GR + 7 A$_fsadd$807 03B5 GR + 7 A$_fsadd$808 03B6 GR + 7 A$_fsadd$809 03B8 GR + 7 A$_fsadd$810 03B9 GR + 7 A$_fsadd$811 03BA GR + 7 A$_fsadd$812 03BC GR + 7 A$_fsadd$813 03BD GR + 7 A$_fsadd$814 03BE GR + 7 A$_fsadd$815 03C0 GR + 7 A$_fsadd$817 03C1 GR + 7 A$_fsadd$818 03C4 GR + 7 A$_fsadd$819 03C5 GR + 7 A$_fsadd$820 03C7 GR + 7 A$_fsadd$821 03C8 GR + 7 A$_fsadd$822 03C9 GR + 7 A$_fsadd$823 03CB GR + 7 A$_fsadd$824 03CE GR + 7 A$_fsadd$825 03D0 GR + 7 A$_fsadd$826 03D1 GR + 7 A$_fsadd$827 03D2 GR + 7 A$_fsadd$828 03D4 GR + 7 A$_fsadd$831 03D5 GR + 7 A$_fsadd$832 03D8 GR + 7 A$_fsadd$833 03D9 GR + 7 A$_fsadd$834 03DB GR + 7 A$_fsadd$835 03DC GR + 7 A$_fsadd$836 03DD GR + 7 A$_fsadd$837 03DF GR + 7 A$_fsadd$838 03E0 GR + 7 A$_fsadd$839 03E1 GR + 7 A$_fsadd$840 03E3 GR + 7 A$_fsadd$841 03E4 GR + 7 A$_fsadd$842 03E5 GR + 7 A$_fsadd$843 03E7 GR + 7 A$_fsadd$844 03EA GR + 7 A$_fsadd$845 03EB GR + 7 A$_fsadd$846 03ED GR + 7 A$_fsadd$847 03EE GR + 7 A$_fsadd$848 03EF GR + 7 A$_fsadd$849 03F1 GR + 7 A$_fsadd$85 0000 GR + 7 A$_fsadd$850 03F2 GR + 7 A$_fsadd$851 03F3 GR + 7 A$_fsadd$852 03F5 GR + 7 A$_fsadd$853 03F6 GR + 7 A$_fsadd$854 03F7 GR + 7 A$_fsadd$855 03F9 GR + 7 A$_fsadd$856 03FC GR + 7 A$_fsadd$857 03FE GR + 7 A$_fsadd$858 0400 GR + 7 A$_fsadd$859 0401 GR + 7 A$_fsadd$86 0002 GR + 7 A$_fsadd$860 0403 GR + 7 A$_fsadd$861 0405 GR + 7 A$_fsadd$862 0406 GR + 7 A$_fsadd$863 0407 GR + 7 A$_fsadd$864 0409 GR + 7 A$_fsadd$865 040B GR + 7 A$_fsadd$866 040C GR + 7 A$_fsadd$867 040D GR + 7 A$_fsadd$868 040F GR + 7 A$_fsadd$869 0411 GR + 7 A$_fsadd$87 0004 GR + 7 A$_fsadd$870 0412 GR + 7 A$_fsadd$872 0413 GR + 7 A$_fsadd$873 0416 GR + 7 A$_fsadd$874 0417 GR + 7 A$_fsadd$875 0419 GR + 7 A$_fsadd$876 041A GR + 7 A$_fsadd$877 041B GR + 7 A$_fsadd$878 041D GR + 7 A$_fsadd$879 041E GR + 7 A$_fsadd$88 0006 GR + 7 A$_fsadd$880 041F GR + 7 A$_fsadd$881 0421 GR + 7 A$_fsadd$882 0422 GR + 7 A$_fsadd$884 0423 GR + 7 A$_fsadd$886 0425 GR + 7 A$_fsadd$889 0428 GR + 7 A$_fsadd$89 0008 GR + 7 A$_fsadd$890 042B GR + 7 A$_fsadd$891 042C GR + 7 A$_fsadd$892 042E GR + 7 A$_fsadd$893 042F GR + 7 A$_fsadd$894 0430 GR + 7 A$_fsadd$895 0432 GR + 7 A$_fsadd$896 0433 GR + 7 A$_fsadd$897 0434 GR + 7 A$_fsadd$898 0436 GR + 7 A$_fsadd$899 0437 GR + 7 A$_fsadd$90 000B GR + 7 A$_fsadd$900 0438 GR + 7 A$_fsadd$901 043A GR + 7 A$_fsadd$902 043D GR + 7 A$_fsadd$903 043E GR + 7 A$_fsadd$904 043F GR + 7 A$_fsadd$905 0441 GR + 7 A$_fsadd$906 0442 GR + 7 A$_fsadd$907 0443 GR + 7 A$_fsadd$908 0445 GR + 7 A$_fsadd$909 0446 GR + 7 A$_fsadd$91 000D GR + 7 A$_fsadd$910 0447 GR + 7 A$_fsadd$911 0448 GR + 7 A$_fsadd$912 044A GR + 7 A$_fsadd$913 044B GR + 7 A$_fsadd$914 044C GR + 7 A$_fsadd$915 044D GR + 7 A$_fsadd$916 044F GR + 7 A$_fsadd$917 0450 GR + 7 A$_fsadd$919 0451 GR + 7 A$_fsadd$92 000E GR + 7 A$_fsadd$922 0454 GR + 7 A$_fsadd$923 0455 GR + 7 A$_fsadd$924 0456 GR + 7 A$_fsadd$925 0457 GR + 7 A$_fsadd$926 0458 GR + 7 A$_fsadd$928 0459 GR + 7 A$_fsadd$929 045A GR + 7 A$_fsadd$93 0010 GR + 7 A$_fsadd$930 045B GR + 7 A$_fsadd$931 045C GR + 7 A$_fsadd$932 045E GR + 7 A$_fsadd$934 045F GR + 7 A$_fsadd$937 0461 GR + 7 A$_fsadd$938 0464 GR + 7 A$_fsadd$939 0465 GR + 7 A$_fsadd$94 0011 GR + 7 A$_fsadd$940 0467 GR + 7 A$_fsadd$941 0468 GR + 7 A$_fsadd$942 0469 GR + 7 A$_fsadd$943 046B GR + 7 A$_fsadd$944 046C GR + 7 A$_fsadd$945 046D GR + 7 A$_fsadd$946 046F GR + 7 A$_fsadd$947 0470 GR + 7 A$_fsadd$948 0471 GR + 7 A$_fsadd$949 0473 GR + 7 A$_fsadd$95 0012 GR + 7 A$_fsadd$950 0475 GR + 7 A$_fsadd$951 0477 GR + 7 A$_fsadd$952 0479 GR + 7 A$_fsadd$954 047B GR + 7 A$_fsadd$96 0014 GR + 7 A$_fsadd$960 047D GR + 7 A$_fsadd$961 047E GR + 7 A$_fsadd$962 0480 GR + 7 A$_fsadd$963 0482 GR + 7 A$_fsadd$964 0484 GR + 7 A$_fsadd$967 0487 GR + 7 A$_fsadd$968 048A GR + 7 A$_fsadd$969 048B GR + 7 A$_fsadd$97 0015 GR + 7 A$_fsadd$970 048D GR + 7 A$_fsadd$971 048E GR + 7 A$_fsadd$972 048F GR + 7 A$_fsadd$973 0491 GR + 7 A$_fsadd$974 0492 GR + 7 A$_fsadd$975 0493 GR + 7 A$_fsadd$976 0495 GR + 7 A$_fsadd$977 0496 GR + 7 A$_fsadd$979 0497 GR + 7 A$_fsadd$98 0016 GR + 7 A$_fsadd$980 0499 GR + 7 A$_fsadd$982 049B GR + 7 A$_fsadd$984 049D GR + 7 A$_fsadd$987 04A0 GR + 7 A$_fsadd$988 04A3 GR + 7 A$_fsadd$989 04A4 GR + 7 A$_fsadd$99 0018 GR + 7 A$_fsadd$990 04A6 GR + 7 A$_fsadd$991 04A7 GR + 7 A$_fsadd$992 04A8 GR + 7 A$_fsadd$993 04AA GR + 7 A$_fsadd$994 04AB GR + 7 A$_fsadd$995 04AC GR + 7 A$_fsadd$996 04AE GR + 7 A$_fsadd$997 04AF GR + 7 A$_fsadd$998 04B0 GR + 7 A$_fsadd$999 04B2 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fsadd.c$102$1$1 = 0714 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fsadd$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fsadd$0$0 = 0714 GR + 7 ___fsadd 0000 GR + 5 ___fsadd_PARM_2 0000 GR + 5 ___fsadd_a1_1_1 0004 R + 5 ___fsadd_exp1_1_1 0018 R + 5 ___fsadd_exp2_1_1 001A R + 5 ___fsadd_fl1_1_1 0010 R + 5 ___fsadd_fl2_1_1 0014 R + 5 ___fsadd_mant1_1_1 0008 R + 5 ___fsadd_mant2_1_1 000C R + 5 ___fsadd_sign_1_1 001C R + 1 ___fsadd_sloc0_1_0 0000 R + 1 ___fsadd_sloc1_1_0 0004 R + 1 ___fsadd_sloc2_1_0 0006 R + ___long2fs **** GX + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size A flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 20 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 715 flags 20 diff --git a/device/lib/_fsdiv.c b/device/lib/_fsdiv.c new file mode 100644 index 00000000..e56e4dda --- /dev/null +++ b/device/lib/_fsdiv.c @@ -0,0 +1,139 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int)0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* divide two floats */ +float +__fsdiv (float a1, float a2) +{ + volatile union float_long fl1, fl2; + volatile long result; + volatile unsigned long mask; + volatile long mant1, mant2; + volatile int exp ; + short sign; + + fl1.f = a1; + fl2.f = a2; + + /* subtract exponents */ + exp = EXP (fl1.l) ; + exp -= EXP (fl2.l); + exp += EXCESS; + + /* compute sign */ + sign = SIGN (fl1.l) ^ SIGN (fl2.l); + + /* divide by zero??? */ + if (!fl2.l) + /* return NaN or -NaN */ + return (-1.0); + + /* numerator zero??? */ + if (!fl1.l) + return (0); + + /* now get mantissas */ + mant1 = MANT (fl1.l); + mant2 = MANT (fl2.l); + + /* this assures we have 25 bits of precision in the end */ + if (mant1 < mant2) + { + mant1 <<= 1; + exp--; + } + + /* now we perform repeated subtraction of fl2.l from fl1.l */ + mask = 0x1000000; + result = 0; + while (mask) + { + if (mant1 >= mant2) + { + result |= mask; + mant1 -= mant2; + } + mant1 <<= 1; + mask >>= 1; + } + + /* round */ + result += 1; + + /* normalize down */ + exp++; + result >>= 1; + + result &= ~HIDDEN; + + /* pack up and go home */ + fl1.l = PACK (sign, (unsigned long) exp, result); + return (fl1.f); +} diff --git a/device/lib/_fsdiv.lst b/device/lib/_fsdiv.lst new file mode 100644 index 00000000..e76b4719 --- /dev/null +++ b/device/lib/_fsdiv.lst @@ -0,0 +1,936 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:26 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fsdiv + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fsdiv_PARM_2 + 11 .globl ___fsdiv + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 ___fsdiv_sloc0_1_0: + 0000 23 .ds 0x0001 + 0001 24 ___fsdiv_sloc1_1_0: + 0001 25 .ds 0x0004 + 0005 26 ___fsdiv_sloc2_1_0: + 0005 27 .ds 0x0004 + 0009 28 ___fsdiv_sloc3_1_0: + 0009 29 .ds 0x0004 + 30 ;-------------------------------------------------------- + 31 ; overlayable items in internal ram + 32 ;-------------------------------------------------------- + 33 .area OSEG (OVR,DATA) + 34 ;-------------------------------------------------------- + 35 ; indirectly addressable internal ram data + 36 ;-------------------------------------------------------- + 37 .area ISEG (DATA) + 38 ;-------------------------------------------------------- + 39 ; bit data + 40 ;-------------------------------------------------------- + 41 .area BSEG (BIT) + 42 ;-------------------------------------------------------- + 43 ; external ram data + 44 ;-------------------------------------------------------- + 45 .area XSEG (XDATA) + 0000 46 ___fsdiv_PARM_2: + 0000 47 .ds 0x0004 + 0004 48 ___fsdiv_a1_1_1: + 0004 49 .ds 0x0004 + 0008 50 ___fsdiv_fl1_1_1: + 0008 51 .ds 0x0004 + 000C 52 ___fsdiv_fl2_1_1: + 000C 53 .ds 0x0004 + 0010 54 ___fsdiv_result_1_1: + 0010 55 .ds 0x0004 + 0014 56 ___fsdiv_mask_1_1: + 0014 57 .ds 0x0004 + 0018 58 ___fsdiv_mant1_1_1: + 0018 59 .ds 0x0004 + 001C 60 ___fsdiv_mant2_1_1: + 001C 61 .ds 0x0004 + 0020 62 ___fsdiv_exp_1_1: + 0020 63 .ds 0x0002 + 64 ;-------------------------------------------------------- + 65 ; global & static initialisations + 66 ;-------------------------------------------------------- + 67 .area GSINIT (CODE) + 68 ;-------------------------------------------------------- + 69 ; code + 70 ;-------------------------------------------------------- + 71 .area CSEG (CODE) + 0000 72 G$__fsdiv$0$0 ==. + 73 ; _fsdiv.c 73 + 74 ; ----------------------------------------- + 75 ; function __fsdiv + 76 ; ----------------------------------------- + 0000 77 ___fsdiv: + 0002 78 ar2 = 0x02 + 0003 79 ar3 = 0x03 + 0004 80 ar4 = 0x04 + 0005 81 ar5 = 0x05 + 0006 82 ar6 = 0x06 + 0007 83 ar7 = 0x07 + 0000 84 ar0 = 0x00 + 0001 85 ar1 = 0x01 + 86 ; _fsdiv.c 138 + 0000 C0 E0 87 push acc + 0002 C0 F0 88 push b + 0004 C0 83 89 push dph + 0006 C0 82 90 push dpl + 0008 90s00r04 91 mov dptr,#___fsdiv_a1_1_1 + 000B D0 E0 92 pop acc + 000D F0 93 movx @dptr,a + 000E D0 E0 94 pop acc + 0010 A3 95 inc dptr + 0011 F0 96 movx @dptr,a + 0012 D0 E0 97 pop acc + 0014 A3 98 inc dptr + 0015 F0 99 movx @dptr,a + 0016 D0 E0 100 pop acc + 0018 A3 101 inc dptr + 0019 F0 102 movx @dptr,a + 103 ; _fsdiv.c 82 + 001A 90s00r04 104 mov dptr,#___fsdiv_a1_1_1 + 001D E0 105 movx a,@dptr + 001E FA 106 mov r2,a + 001F A3 107 inc dptr + 0020 E0 108 movx a,@dptr + 0021 FB 109 mov r3,a + 0022 A3 110 inc dptr + 0023 E0 111 movx a,@dptr + 0024 FC 112 mov r4,a + 0025 A3 113 inc dptr + 0026 E0 114 movx a,@dptr + 0027 FD 115 mov r5,a + 0028 90s00r08 116 mov dptr,#(___fsdiv_fl1_1_1) + 002B EA 117 mov a,r2 + 002C F0 118 movx @dptr,a + 002D A3 119 inc dptr + 002E EB 120 mov a,r3 + 002F F0 121 movx @dptr,a + 0030 A3 122 inc dptr + 0031 EC 123 mov a,r4 + 0032 F0 124 movx @dptr,a + 0033 A3 125 inc dptr + 0034 ED 126 mov a,r5 + 0035 F0 127 movx @dptr,a + 128 ; _fsdiv.c 83 + 0036 90s00r00 129 mov dptr,#___fsdiv_PARM_2 + 0039 E0 130 movx a,@dptr + 003A FA 131 mov r2,a + 003B A3 132 inc dptr + 003C E0 133 movx a,@dptr + 003D FB 134 mov r3,a + 003E A3 135 inc dptr + 003F E0 136 movx a,@dptr + 0040 FC 137 mov r4,a + 0041 A3 138 inc dptr + 0042 E0 139 movx a,@dptr + 0043 FD 140 mov r5,a + 0044 90s00r0C 141 mov dptr,#(___fsdiv_fl2_1_1) + 0047 EA 142 mov a,r2 + 0048 F0 143 movx @dptr,a + 0049 A3 144 inc dptr + 004A EB 145 mov a,r3 + 004B F0 146 movx @dptr,a + 004C A3 147 inc dptr + 004D EC 148 mov a,r4 + 004E F0 149 movx @dptr,a + 004F A3 150 inc dptr + 0050 ED 151 mov a,r5 + 0051 F0 152 movx @dptr,a + 153 ; _fsdiv.c 86 + 0052 90s00r08 154 mov dptr,#(___fsdiv_fl1_1_1) + 0055 E0 155 movx a,@dptr + 0056 FA 156 mov r2,a + 0057 A3 157 inc dptr + 0058 E0 158 movx a,@dptr + 0059 FB 159 mov r3,a + 005A A3 160 inc dptr + 005B E0 161 movx a,@dptr + 005C FC 162 mov r4,a + 005D A3 163 inc dptr + 005E E0 164 movx a,@dptr + 005F FD 165 mov r5,a + 0060 8C 02 166 mov ar2,r4 + 0062 ED 167 mov a,r5 + 0063 A2 E7 168 mov c,acc.7 + 0065 CA 169 xch a,r2 + 0066 33 170 rlc a + 0067 CA 171 xch a,r2 + 0068 33 172 rlc a + 0069 CA 173 xch a,r2 + 006A 54 01 174 anl a,#0x01 + 006C 30 E0 02 175 jnb acc.0,00120$ + 006F 44 FE 176 orl a,#0xfe + 0071 177 00120$: + 0071 FB 178 mov r3,a + 0072 33 179 rlc a + 0073 95 E0 180 subb a,acc + 0075 FC 181 mov r4,a + 0076 FD 182 mov r5,a + 0077 90s00r20 183 mov dptr,#___fsdiv_exp_1_1 + 007A EA 184 mov a,r2 + 007B F0 185 movx @dptr,a + 007C A3 186 inc dptr + 187 ; Peephole 180 changed mov to clr + 007D E4 188 clr a + 007E F0 189 movx @dptr,a + 190 ; _fsdiv.c 87 + 007F 90s00r0C 191 mov dptr,#(___fsdiv_fl2_1_1) + 0082 E0 192 movx a,@dptr + 0083 FA 193 mov r2,a + 0084 A3 194 inc dptr + 0085 E0 195 movx a,@dptr + 0086 FB 196 mov r3,a + 0087 A3 197 inc dptr + 0088 E0 198 movx a,@dptr + 0089 FE 199 mov r6,a + 008A A3 200 inc dptr + 008B E0 201 movx a,@dptr + 008C FF 202 mov r7,a + 008D 8E 02 203 mov ar2,r6 + 008F EF 204 mov a,r7 + 0090 A2 E7 205 mov c,acc.7 + 0092 CA 206 xch a,r2 + 0093 33 207 rlc a + 0094 CA 208 xch a,r2 + 0095 33 209 rlc a + 0096 CA 210 xch a,r2 + 0097 54 01 211 anl a,#0x01 + 0099 30 E0 02 212 jnb acc.0,00121$ + 009C 44 FE 213 orl a,#0xfe + 009E 214 00121$: + 009E FB 215 mov r3,a + 009F 33 216 rlc a + 00A0 95 E0 217 subb a,acc + 00A2 FE 218 mov r6,a + 00A3 FF 219 mov r7,a + 00A4 7B 00 220 mov r3,#0x00 + 00A6 90s00r20 221 mov dptr,#___fsdiv_exp_1_1 + 00A9 E0 222 movx a,@dptr + 00AA F8 223 mov r0,a + 00AB A3 224 inc dptr + 00AC E0 225 movx a,@dptr + 00AD F9 226 mov r1,a + 00AE 90s00r20 227 mov dptr,#___fsdiv_exp_1_1 + 00B1 C3 228 clr c + 00B2 E8 229 mov a,r0 + 00B3 9A 230 subb a,r2 + 00B4 F0 231 movx @dptr,a + 00B5 E9 232 mov a,r1 + 00B6 9B 233 subb a,r3 + 00B7 A3 234 inc dptr + 00B8 F0 235 movx @dptr,a + 236 ; _fsdiv.c 88 + 00B9 90s00r20 237 mov dptr,#___fsdiv_exp_1_1 + 00BC E0 238 movx a,@dptr + 00BD FA 239 mov r2,a + 00BE A3 240 inc dptr + 00BF E0 241 movx a,@dptr + 00C0 FB 242 mov r3,a + 00C1 90s00r20 243 mov dptr,#___fsdiv_exp_1_1 + 00C4 74 7E 244 mov a,#0x7e + 00C6 2A 245 add a,r2 + 00C7 F0 246 movx @dptr,a + 247 ; Peephole 180 changed mov to clr + 00C8 E4 248 clr a + 00C9 3B 249 addc a,r3 + 00CA A3 250 inc dptr + 00CB F0 251 movx @dptr,a + 252 ; _fsdiv.c 91 + 00CC 90s00r08 253 mov dptr,#(___fsdiv_fl1_1_1) + 00CF E0 254 movx a,@dptr + 00D0 FA 255 mov r2,a + 00D1 A3 256 inc dptr + 00D2 E0 257 movx a,@dptr + 00D3 FB 258 mov r3,a + 00D4 A3 259 inc dptr + 00D5 E0 260 movx a,@dptr + 00D6 F8 261 mov r0,a + 00D7 A3 262 inc dptr + 00D8 E0 263 movx a,@dptr + 264 ; Peephole 105 removed redundant mov + 00D9 F9 265 mov r1,a + 00DA 23 266 rl a + 00DB 54 01 267 anl a,#0x01 + 00DD F5*00 268 mov ___fsdiv_sloc0_1_0,a + 00DF 90s00r0C 269 mov dptr,#(___fsdiv_fl2_1_1) + 00E2 E0 270 movx a,@dptr + 00E3 F5*01 271 mov ___fsdiv_sloc1_1_0,a + 00E5 A3 272 inc dptr + 00E6 E0 273 movx a,@dptr + 00E7 F5*02 274 mov (___fsdiv_sloc1_1_0 + 1),a + 00E9 A3 275 inc dptr + 00EA E0 276 movx a,@dptr + 00EB F5*03 277 mov (___fsdiv_sloc1_1_0 + 2),a + 00ED A3 278 inc dptr + 00EE E0 279 movx a,@dptr + 280 ; Peephole 105 removed redundant mov + 00EF F5*04 281 mov (___fsdiv_sloc1_1_0 + 3),a + 00F1 23 282 rl a + 00F2 54 01 283 anl a,#0x01 + 284 ; Peephole 105 removed redundant mov + 00F4 FA 285 mov r2,a + 00F5 65*00 286 xrl a,___fsdiv_sloc0_1_0 + 00F7 F5*01 287 mov ___fsdiv_sloc1_1_0,a + 288 ; _fsdiv.c 94 + 00F9 90s00r0C 289 mov dptr,#(___fsdiv_fl2_1_1) + 00FC E0 290 movx a,@dptr + 00FD F5*05 291 mov ___fsdiv_sloc2_1_0,a + 00FF A3 292 inc dptr + 0100 E0 293 movx a,@dptr + 0101 F5*06 294 mov (___fsdiv_sloc2_1_0 + 1),a + 0103 A3 295 inc dptr + 0104 E0 296 movx a,@dptr + 0105 F5*07 297 mov (___fsdiv_sloc2_1_0 + 2),a + 0107 A3 298 inc dptr + 0108 E0 299 movx a,@dptr + 0109 F5*08 300 mov (___fsdiv_sloc2_1_0 + 3),a + 010B E5*05 301 mov a,___fsdiv_sloc2_1_0 + 010D 45*06 302 orl a,(___fsdiv_sloc2_1_0 + 1) + 010F 45*07 303 orl a,(___fsdiv_sloc2_1_0 + 2) + 0111 45*08 304 orl a,(___fsdiv_sloc2_1_0 + 3) + 305 ; Peephole 109 removed ljmp by inverse jump logic + 0113 70 0B 306 jnz 00102$ + 0115 307 00122$: + 308 ; _fsdiv.c 96 + 309 ; Peephole 181 used 16 bit load of dptr + 0115 90 00 00 310 mov dptr,#0x0000 + 0118 75 F0 80 311 mov b,#0x80 + 011B 74 BF 312 mov a,#0xbf + 011D 02s04rBF 313 ljmp 00112$ + 0120 314 00102$: + 315 ; _fsdiv.c 99 + 0120 90s00r08 316 mov dptr,#(___fsdiv_fl1_1_1) + 0123 E0 317 movx a,@dptr + 0124 F5*05 318 mov ___fsdiv_sloc2_1_0,a + 0126 A3 319 inc dptr + 0127 E0 320 movx a,@dptr + 0128 F5*06 321 mov (___fsdiv_sloc2_1_0 + 1),a + 012A A3 322 inc dptr + 012B E0 323 movx a,@dptr + 012C F5*07 324 mov (___fsdiv_sloc2_1_0 + 2),a + 012E A3 325 inc dptr + 012F E0 326 movx a,@dptr + 0130 F5*08 327 mov (___fsdiv_sloc2_1_0 + 3),a + 0132 E5*05 328 mov a,___fsdiv_sloc2_1_0 + 0134 45*06 329 orl a,(___fsdiv_sloc2_1_0 + 1) + 0136 45*07 330 orl a,(___fsdiv_sloc2_1_0 + 2) + 0138 45*08 331 orl a,(___fsdiv_sloc2_1_0 + 3) + 332 ; Peephole 109 removed ljmp by inverse jump logic + 013A 70 0A 333 jnz 00104$ + 013C 334 00123$: + 335 ; _fsdiv.c 100 + 336 ; Peephole 3.a changed mov to clr + 337 ; Peephole 3.b changed mov to clr + 338 ; Peephole 3.b changed mov to clr + 013C E4 339 clr a + 013D F5 82 340 mov dpl,a + 013F F5 83 341 mov dph,a + 0141 F5 F0 342 mov b,a + 0143 02s04rBF 343 ljmp 00112$ + 0146 344 00104$: + 345 ; _fsdiv.c 103 + 0146 90s00r08 346 mov dptr,#(___fsdiv_fl1_1_1) + 0149 E0 347 movx a,@dptr + 014A F5*05 348 mov ___fsdiv_sloc2_1_0,a + 014C A3 349 inc dptr + 014D E0 350 movx a,@dptr + 014E F5*06 351 mov (___fsdiv_sloc2_1_0 + 1),a + 0150 A3 352 inc dptr + 0151 E0 353 movx a,@dptr + 0152 F5*07 354 mov (___fsdiv_sloc2_1_0 + 2),a + 0154 A3 355 inc dptr + 0155 E0 356 movx a,@dptr + 0156 F5*08 357 mov (___fsdiv_sloc2_1_0 + 3),a + 0158 53r07 7F 358 anl (___fsdiv_sloc2_1_0 + 2),#0x7f + 015B 75*08 00 359 mov (___fsdiv_sloc2_1_0 + 3),#0x00 + 015E 90s00r18 360 mov dptr,#___fsdiv_mant1_1_1 + 0161 E5*05 361 mov a,___fsdiv_sloc2_1_0 + 0163 F0 362 movx @dptr,a + 0164 A3 363 inc dptr + 0165 E5*06 364 mov a,(___fsdiv_sloc2_1_0 + 1) + 0167 F0 365 movx @dptr,a + 0168 74 80 366 mov a,#0x80 + 016A 45*07 367 orl a,(___fsdiv_sloc2_1_0 + 2) + 016C A3 368 inc dptr + 016D F0 369 movx @dptr,a + 016E A3 370 inc dptr + 016F E5*08 371 mov a,(___fsdiv_sloc2_1_0 + 3) + 0171 F0 372 movx @dptr,a + 373 ; _fsdiv.c 104 + 0172 90s00r0C 374 mov dptr,#(___fsdiv_fl2_1_1) + 0175 E0 375 movx a,@dptr + 0176 F5*05 376 mov ___fsdiv_sloc2_1_0,a + 0178 A3 377 inc dptr + 0179 E0 378 movx a,@dptr + 017A F5*06 379 mov (___fsdiv_sloc2_1_0 + 1),a + 017C A3 380 inc dptr + 017D E0 381 movx a,@dptr + 017E F5*07 382 mov (___fsdiv_sloc2_1_0 + 2),a + 0180 A3 383 inc dptr + 0181 E0 384 movx a,@dptr + 0182 F5*08 385 mov (___fsdiv_sloc2_1_0 + 3),a + 0184 53r07 7F 386 anl (___fsdiv_sloc2_1_0 + 2),#0x7f + 0187 75*08 00 387 mov (___fsdiv_sloc2_1_0 + 3),#0x00 + 018A 90s00r1C 388 mov dptr,#___fsdiv_mant2_1_1 + 018D E5*05 389 mov a,___fsdiv_sloc2_1_0 + 018F F0 390 movx @dptr,a + 0190 A3 391 inc dptr + 0191 E5*06 392 mov a,(___fsdiv_sloc2_1_0 + 1) + 0193 F0 393 movx @dptr,a + 0194 74 80 394 mov a,#0x80 + 0196 45*07 395 orl a,(___fsdiv_sloc2_1_0 + 2) + 0198 A3 396 inc dptr + 0199 F0 397 movx @dptr,a + 019A A3 398 inc dptr + 019B E5*08 399 mov a,(___fsdiv_sloc2_1_0 + 3) + 019D F0 400 movx @dptr,a + 401 ; _fsdiv.c 107 + 019E 90s00r1C 402 mov dptr,#___fsdiv_mant2_1_1 + 01A1 E0 403 movx a,@dptr + 01A2 F5*05 404 mov ___fsdiv_sloc2_1_0,a + 01A4 A3 405 inc dptr + 01A5 E0 406 movx a,@dptr + 01A6 F5*06 407 mov (___fsdiv_sloc2_1_0 + 1),a + 01A8 A3 408 inc dptr + 01A9 E0 409 movx a,@dptr + 01AA F5*07 410 mov (___fsdiv_sloc2_1_0 + 2),a + 01AC A3 411 inc dptr + 01AD E0 412 movx a,@dptr + 01AE F5*08 413 mov (___fsdiv_sloc2_1_0 + 3),a + 01B0 90s00r18 414 mov dptr,#___fsdiv_mant1_1_1 + 01B3 E0 415 movx a,@dptr + 01B4 F5*09 416 mov ___fsdiv_sloc3_1_0,a + 01B6 A3 417 inc dptr + 01B7 E0 418 movx a,@dptr + 01B8 F5*0A 419 mov (___fsdiv_sloc3_1_0 + 1),a + 01BA A3 420 inc dptr + 01BB E0 421 movx a,@dptr + 01BC F5*0B 422 mov (___fsdiv_sloc3_1_0 + 2),a + 01BE A3 423 inc dptr + 01BF E0 424 movx a,@dptr + 01C0 F5*0C 425 mov (___fsdiv_sloc3_1_0 + 3),a + 01C2 C3 426 clr c + 01C3 E5*09 427 mov a,___fsdiv_sloc3_1_0 + 01C5 95*05 428 subb a,___fsdiv_sloc2_1_0 + 01C7 E5*0A 429 mov a,(___fsdiv_sloc3_1_0 + 1) + 01C9 95*06 430 subb a,(___fsdiv_sloc2_1_0 + 1) + 01CB E5*0B 431 mov a,(___fsdiv_sloc3_1_0 + 2) + 01CD 95*07 432 subb a,(___fsdiv_sloc2_1_0 + 2) + 01CF E5*0C 433 mov a,(___fsdiv_sloc3_1_0 + 3) + 01D1 64 80 434 xrl a,#0x80 + 01D3 85*08 F0 435 mov b,(___fsdiv_sloc2_1_0 + 3) + 01D6 63 F0 80 436 xrl b,#0x80 + 01D9 95 F0 437 subb a,b + 01DB 40 03 438 jc 00124$ + 01DD 02s02r31 439 ljmp 00106$ + 01E0 440 00124$: + 441 ; _fsdiv.c 109 + 01E0 90s00r18 442 mov dptr,#___fsdiv_mant1_1_1 + 01E3 E0 443 movx a,@dptr + 01E4 F5*09 444 mov ___fsdiv_sloc3_1_0,a + 01E6 A3 445 inc dptr + 01E7 E0 446 movx a,@dptr + 01E8 F5*0A 447 mov (___fsdiv_sloc3_1_0 + 1),a + 01EA A3 448 inc dptr + 01EB E0 449 movx a,@dptr + 01EC F5*0B 450 mov (___fsdiv_sloc3_1_0 + 2),a + 01EE A3 451 inc dptr + 01EF E0 452 movx a,@dptr + 01F0 F5*0C 453 mov (___fsdiv_sloc3_1_0 + 3),a + 01F2 E5*09 454 mov a,___fsdiv_sloc3_1_0 + 01F4 25 E0 455 add a,acc + 01F6 F5*09 456 mov ___fsdiv_sloc3_1_0,a + 01F8 E5*0A 457 mov a,(___fsdiv_sloc3_1_0 + 1) + 01FA 33 458 rlc a + 01FB F5*0A 459 mov (___fsdiv_sloc3_1_0 + 1),a + 01FD E5*0B 460 mov a,(___fsdiv_sloc3_1_0 + 2) + 01FF 33 461 rlc a + 0200 F5*0B 462 mov (___fsdiv_sloc3_1_0 + 2),a + 0202 E5*0C 463 mov a,(___fsdiv_sloc3_1_0 + 3) + 0204 33 464 rlc a + 0205 F5*0C 465 mov (___fsdiv_sloc3_1_0 + 3),a + 0207 90s00r18 466 mov dptr,#___fsdiv_mant1_1_1 + 020A E5*09 467 mov a,___fsdiv_sloc3_1_0 + 020C F0 468 movx @dptr,a + 020D A3 469 inc dptr + 020E E5*0A 470 mov a,(___fsdiv_sloc3_1_0 + 1) + 0210 F0 471 movx @dptr,a + 0211 A3 472 inc dptr + 0212 E5*0B 473 mov a,(___fsdiv_sloc3_1_0 + 2) + 0214 F0 474 movx @dptr,a + 0215 A3 475 inc dptr + 0216 E5*0C 476 mov a,(___fsdiv_sloc3_1_0 + 3) + 0218 F0 477 movx @dptr,a + 478 ; _fsdiv.c 110 + 0219 90s00r20 479 mov dptr,#___fsdiv_exp_1_1 + 021C E0 480 movx a,@dptr + 021D 24 FF 481 add a,#0xff + 021F F5*09 482 mov ___fsdiv_sloc3_1_0,a + 0221 A3 483 inc dptr + 0222 E0 484 movx a,@dptr + 0223 34 FF 485 addc a,#0xff + 0225 F5*0A 486 mov (___fsdiv_sloc3_1_0 + 1),a + 0227 90s00r20 487 mov dptr,#___fsdiv_exp_1_1 + 022A E5*09 488 mov a,___fsdiv_sloc3_1_0 + 022C F0 489 movx @dptr,a + 022D A3 490 inc dptr + 022E E5*0A 491 mov a,(___fsdiv_sloc3_1_0 + 1) + 0230 F0 492 movx @dptr,a + 0231 493 00106$: + 494 ; _fsdiv.c 114 + 0231 90s00r14 495 mov dptr,#___fsdiv_mask_1_1 + 496 ; Peephole 101 removed redundant mov + 497 ; Peephole 180 changed mov to clr + 0234 E4 498 clr a + 0235 F0 499 movx @dptr,a + 0236 A3 500 inc dptr + 0237 F0 501 movx @dptr,a + 0238 A3 502 inc dptr + 503 ; Peephole 180 changed mov to clr + 0239 E4 504 clr a + 023A F0 505 movx @dptr,a + 023B A3 506 inc dptr + 023C 74 01 507 mov a,#0x01 + 023E F0 508 movx @dptr,a + 509 ; _fsdiv.c 115 + 023F 90s00r10 510 mov dptr,#___fsdiv_result_1_1 + 0242 E4 511 clr a + 0243 A3 512 inc dptr + 0244 A3 513 inc dptr + 0245 A3 514 inc dptr + 0246 F0 515 movx @dptr,a + 0247 12s00r00 516 lcall __decdptr + 024A F0 517 movx @dptr,a + 024B 12s00r00 518 lcall __decdptr + 024E F0 519 movx @dptr,a + 024F 12s00r00 520 lcall __decdptr + 0252 F0 521 movx @dptr,a + 522 ; _fsdiv.c 116 + 0253 523 00109$: + 0253 90s00r14 524 mov dptr,#___fsdiv_mask_1_1 + 0256 E0 525 movx a,@dptr + 0257 F5*09 526 mov ___fsdiv_sloc3_1_0,a + 0259 A3 527 inc dptr + 025A E0 528 movx a,@dptr + 025B F5*0A 529 mov (___fsdiv_sloc3_1_0 + 1),a + 025D A3 530 inc dptr + 025E E0 531 movx a,@dptr + 025F F5*0B 532 mov (___fsdiv_sloc3_1_0 + 2),a + 0261 A3 533 inc dptr + 0262 E0 534 movx a,@dptr + 0263 F5*0C 535 mov (___fsdiv_sloc3_1_0 + 3),a + 0265 E5*09 536 mov a,___fsdiv_sloc3_1_0 + 0267 45*0A 537 orl a,(___fsdiv_sloc3_1_0 + 1) + 0269 45*0B 538 orl a,(___fsdiv_sloc3_1_0 + 2) + 026B 45*0C 539 orl a,(___fsdiv_sloc3_1_0 + 3) + 026D 70 03 540 jnz 00125$ + 026F 02s03rA2 541 ljmp 00111$ + 0272 542 00125$: + 543 ; _fsdiv.c 118 + 0272 90s00r1C 544 mov dptr,#___fsdiv_mant2_1_1 + 0275 E0 545 movx a,@dptr + 0276 F5*09 546 mov ___fsdiv_sloc3_1_0,a + 0278 A3 547 inc dptr + 0279 E0 548 movx a,@dptr + 027A F5*0A 549 mov (___fsdiv_sloc3_1_0 + 1),a + 027C A3 550 inc dptr + 027D E0 551 movx a,@dptr + 027E F5*0B 552 mov (___fsdiv_sloc3_1_0 + 2),a + 0280 A3 553 inc dptr + 0281 E0 554 movx a,@dptr + 0282 F5*0C 555 mov (___fsdiv_sloc3_1_0 + 3),a + 0284 90s00r18 556 mov dptr,#___fsdiv_mant1_1_1 + 0287 E0 557 movx a,@dptr + 0288 F5*05 558 mov ___fsdiv_sloc2_1_0,a + 028A A3 559 inc dptr + 028B E0 560 movx a,@dptr + 028C F5*06 561 mov (___fsdiv_sloc2_1_0 + 1),a + 028E A3 562 inc dptr + 028F E0 563 movx a,@dptr + 0290 F5*07 564 mov (___fsdiv_sloc2_1_0 + 2),a + 0292 A3 565 inc dptr + 0293 E0 566 movx a,@dptr + 0294 F5*08 567 mov (___fsdiv_sloc2_1_0 + 3),a + 0296 C3 568 clr c + 0297 E5*05 569 mov a,___fsdiv_sloc2_1_0 + 0299 95*09 570 subb a,___fsdiv_sloc3_1_0 + 029B E5*06 571 mov a,(___fsdiv_sloc2_1_0 + 1) + 029D 95*0A 572 subb a,(___fsdiv_sloc3_1_0 + 1) + 029F E5*07 573 mov a,(___fsdiv_sloc2_1_0 + 2) + 02A1 95*0B 574 subb a,(___fsdiv_sloc3_1_0 + 2) + 02A3 E5*08 575 mov a,(___fsdiv_sloc2_1_0 + 3) + 02A5 64 80 576 xrl a,#0x80 + 02A7 85*0C F0 577 mov b,(___fsdiv_sloc3_1_0 + 3) + 02AA 63 F0 80 578 xrl b,#0x80 + 02AD 95 F0 579 subb a,b + 02AF 50 03 580 jnc 00126$ + 02B1 02s03r31 581 ljmp 00108$ + 02B4 582 00126$: + 583 ; _fsdiv.c 120 + 02B4 90s00r14 584 mov dptr,#___fsdiv_mask_1_1 + 02B7 E0 585 movx a,@dptr + 02B8 F5*09 586 mov ___fsdiv_sloc3_1_0,a + 02BA A3 587 inc dptr + 02BB E0 588 movx a,@dptr + 02BC F5*0A 589 mov (___fsdiv_sloc3_1_0 + 1),a + 02BE A3 590 inc dptr + 02BF E0 591 movx a,@dptr + 02C0 F5*0B 592 mov (___fsdiv_sloc3_1_0 + 2),a + 02C2 A3 593 inc dptr + 02C3 E0 594 movx a,@dptr + 02C4 F5*0C 595 mov (___fsdiv_sloc3_1_0 + 3),a + 02C6 90s00r10 596 mov dptr,#___fsdiv_result_1_1 + 02C9 E0 597 movx a,@dptr + 02CA F5*05 598 mov ___fsdiv_sloc2_1_0,a + 02CC A3 599 inc dptr + 02CD E0 600 movx a,@dptr + 02CE F5*06 601 mov (___fsdiv_sloc2_1_0 + 1),a + 02D0 A3 602 inc dptr + 02D1 E0 603 movx a,@dptr + 02D2 F5*07 604 mov (___fsdiv_sloc2_1_0 + 2),a + 02D4 A3 605 inc dptr + 02D5 E0 606 movx a,@dptr + 02D6 F5*08 607 mov (___fsdiv_sloc2_1_0 + 3),a + 02D8 90s00r10 608 mov dptr,#___fsdiv_result_1_1 + 02DB E5*09 609 mov a,___fsdiv_sloc3_1_0 + 02DD 45*05 610 orl a,___fsdiv_sloc2_1_0 + 02DF F0 611 movx @dptr,a + 02E0 E5*0A 612 mov a,(___fsdiv_sloc3_1_0 + 1) + 02E2 45*06 613 orl a,(___fsdiv_sloc2_1_0 + 1) + 02E4 A3 614 inc dptr + 02E5 F0 615 movx @dptr,a + 02E6 E5*0B 616 mov a,(___fsdiv_sloc3_1_0 + 2) + 02E8 45*07 617 orl a,(___fsdiv_sloc2_1_0 + 2) + 02EA A3 618 inc dptr + 02EB F0 619 movx @dptr,a + 02EC E5*0C 620 mov a,(___fsdiv_sloc3_1_0 + 3) + 02EE 45*08 621 orl a,(___fsdiv_sloc2_1_0 + 3) + 02F0 A3 622 inc dptr + 02F1 F0 623 movx @dptr,a + 624 ; _fsdiv.c 121 + 02F2 90s00r1C 625 mov dptr,#___fsdiv_mant2_1_1 + 02F5 E0 626 movx a,@dptr + 02F6 F5*09 627 mov ___fsdiv_sloc3_1_0,a + 02F8 A3 628 inc dptr + 02F9 E0 629 movx a,@dptr + 02FA F5*0A 630 mov (___fsdiv_sloc3_1_0 + 1),a + 02FC A3 631 inc dptr + 02FD E0 632 movx a,@dptr + 02FE F5*0B 633 mov (___fsdiv_sloc3_1_0 + 2),a + 0300 A3 634 inc dptr + 0301 E0 635 movx a,@dptr + 0302 F5*0C 636 mov (___fsdiv_sloc3_1_0 + 3),a + 0304 90s00r18 637 mov dptr,#___fsdiv_mant1_1_1 + 0307 E0 638 movx a,@dptr + 0308 F5*05 639 mov ___fsdiv_sloc2_1_0,a + 030A A3 640 inc dptr + 030B E0 641 movx a,@dptr + 030C F5*06 642 mov (___fsdiv_sloc2_1_0 + 1),a + 030E A3 643 inc dptr + 030F E0 644 movx a,@dptr + 0310 F5*07 645 mov (___fsdiv_sloc2_1_0 + 2),a + 0312 A3 646 inc dptr + 0313 E0 647 movx a,@dptr + 0314 F5*08 648 mov (___fsdiv_sloc2_1_0 + 3),a + 0316 90s00r18 649 mov dptr,#___fsdiv_mant1_1_1 + 0319 C3 650 clr c + 031A E5*05 651 mov a,___fsdiv_sloc2_1_0 + 031C 95*09 652 subb a,___fsdiv_sloc3_1_0 + 031E F0 653 movx @dptr,a + 031F E5*06 654 mov a,(___fsdiv_sloc2_1_0 + 1) + 0321 95*0A 655 subb a,(___fsdiv_sloc3_1_0 + 1) + 0323 A3 656 inc dptr + 0324 F0 657 movx @dptr,a + 0325 E5*07 658 mov a,(___fsdiv_sloc2_1_0 + 2) + 0327 95*0B 659 subb a,(___fsdiv_sloc3_1_0 + 2) + 0329 A3 660 inc dptr + 032A F0 661 movx @dptr,a + 032B E5*08 662 mov a,(___fsdiv_sloc2_1_0 + 3) + 032D 95*0C 663 subb a,(___fsdiv_sloc3_1_0 + 3) + 032F A3 664 inc dptr + 0330 F0 665 movx @dptr,a + 0331 666 00108$: + 667 ; _fsdiv.c 123 + 0331 90s00r18 668 mov dptr,#___fsdiv_mant1_1_1 + 0334 E0 669 movx a,@dptr + 0335 F5*09 670 mov ___fsdiv_sloc3_1_0,a + 0337 A3 671 inc dptr + 0338 E0 672 movx a,@dptr + 0339 F5*0A 673 mov (___fsdiv_sloc3_1_0 + 1),a + 033B A3 674 inc dptr + 033C E0 675 movx a,@dptr + 033D F5*0B 676 mov (___fsdiv_sloc3_1_0 + 2),a + 033F A3 677 inc dptr + 0340 E0 678 movx a,@dptr + 0341 F5*0C 679 mov (___fsdiv_sloc3_1_0 + 3),a + 0343 E5*09 680 mov a,___fsdiv_sloc3_1_0 + 0345 25 E0 681 add a,acc + 0347 F5*09 682 mov ___fsdiv_sloc3_1_0,a + 0349 E5*0A 683 mov a,(___fsdiv_sloc3_1_0 + 1) + 034B 33 684 rlc a + 034C F5*0A 685 mov (___fsdiv_sloc3_1_0 + 1),a + 034E E5*0B 686 mov a,(___fsdiv_sloc3_1_0 + 2) + 0350 33 687 rlc a + 0351 F5*0B 688 mov (___fsdiv_sloc3_1_0 + 2),a + 0353 E5*0C 689 mov a,(___fsdiv_sloc3_1_0 + 3) + 0355 33 690 rlc a + 0356 F5*0C 691 mov (___fsdiv_sloc3_1_0 + 3),a + 0358 90s00r18 692 mov dptr,#___fsdiv_mant1_1_1 + 035B E5*09 693 mov a,___fsdiv_sloc3_1_0 + 035D F0 694 movx @dptr,a + 035E A3 695 inc dptr + 035F E5*0A 696 mov a,(___fsdiv_sloc3_1_0 + 1) + 0361 F0 697 movx @dptr,a + 0362 A3 698 inc dptr + 0363 E5*0B 699 mov a,(___fsdiv_sloc3_1_0 + 2) + 0365 F0 700 movx @dptr,a + 0366 A3 701 inc dptr + 0367 E5*0C 702 mov a,(___fsdiv_sloc3_1_0 + 3) + 0369 F0 703 movx @dptr,a + 704 ; _fsdiv.c 124 + 036A 90s00r14 705 mov dptr,#___fsdiv_mask_1_1 + 036D E0 706 movx a,@dptr + 036E F5*09 707 mov ___fsdiv_sloc3_1_0,a + 0370 A3 708 inc dptr + 0371 E0 709 movx a,@dptr + 0372 F5*0A 710 mov (___fsdiv_sloc3_1_0 + 1),a + 0374 A3 711 inc dptr + 0375 E0 712 movx a,@dptr + 0376 F5*0B 713 mov (___fsdiv_sloc3_1_0 + 2),a + 0378 A3 714 inc dptr + 0379 E0 715 movx a,@dptr + 716 ; Peephole 106 removed redundant mov + 037A F5*0C 717 mov (___fsdiv_sloc3_1_0 + 3),a + 037C C3 718 clr c + 037D 13 719 rrc a + 037E F5*0C 720 mov (___fsdiv_sloc3_1_0 + 3),a + 0380 E5*0B 721 mov a,(___fsdiv_sloc3_1_0 + 2) + 0382 13 722 rrc a + 0383 F5*0B 723 mov (___fsdiv_sloc3_1_0 + 2),a + 0385 E5*0A 724 mov a,(___fsdiv_sloc3_1_0 + 1) + 0387 13 725 rrc a + 0388 F5*0A 726 mov (___fsdiv_sloc3_1_0 + 1),a + 038A E5*09 727 mov a,___fsdiv_sloc3_1_0 + 038C 13 728 rrc a + 729 ; Peephole 100 removed redundant mov + 038D F5*09 730 mov ___fsdiv_sloc3_1_0,a + 038F 90s00r14 731 mov dptr,#___fsdiv_mask_1_1 + 0392 F0 732 movx @dptr,a + 0393 A3 733 inc dptr + 0394 E5*0A 734 mov a,(___fsdiv_sloc3_1_0 + 1) + 0396 F0 735 movx @dptr,a + 0397 A3 736 inc dptr + 0398 E5*0B 737 mov a,(___fsdiv_sloc3_1_0 + 2) + 039A F0 738 movx @dptr,a + 039B A3 739 inc dptr + 039C E5*0C 740 mov a,(___fsdiv_sloc3_1_0 + 3) + 039E F0 741 movx @dptr,a + 039F 02s02r53 742 ljmp 00109$ + 03A2 743 00111$: + 744 ; _fsdiv.c 128 + 03A2 90s00r10 745 mov dptr,#___fsdiv_result_1_1 + 03A5 E0 746 movx a,@dptr + 03A6 F5*09 747 mov ___fsdiv_sloc3_1_0,a + 03A8 A3 748 inc dptr + 03A9 E0 749 movx a,@dptr + 03AA F5*0A 750 mov (___fsdiv_sloc3_1_0 + 1),a + 03AC A3 751 inc dptr + 03AD E0 752 movx a,@dptr + 03AE F5*0B 753 mov (___fsdiv_sloc3_1_0 + 2),a + 03B0 A3 754 inc dptr + 03B1 E0 755 movx a,@dptr + 03B2 F5*0C 756 mov (___fsdiv_sloc3_1_0 + 3),a + 03B4 90s00r10 757 mov dptr,#___fsdiv_result_1_1 + 03B7 74 01 758 mov a,#0x01 + 03B9 25*09 759 add a,___fsdiv_sloc3_1_0 + 03BB F0 760 movx @dptr,a + 761 ; Peephole 180 changed mov to clr + 03BC E4 762 clr a + 03BD 35*0A 763 addc a,(___fsdiv_sloc3_1_0 + 1) + 03BF A3 764 inc dptr + 03C0 F0 765 movx @dptr,a + 766 ; Peephole 180 changed mov to clr + 03C1 E4 767 clr a + 03C2 35*0B 768 addc a,(___fsdiv_sloc3_1_0 + 2) + 03C4 A3 769 inc dptr + 03C5 F0 770 movx @dptr,a + 771 ; Peephole 180 changed mov to clr + 03C6 E4 772 clr a + 03C7 35*0C 773 addc a,(___fsdiv_sloc3_1_0 + 3) + 03C9 A3 774 inc dptr + 03CA F0 775 movx @dptr,a + 776 ; _fsdiv.c 131 + 03CB 90s00r20 777 mov dptr,#___fsdiv_exp_1_1 + 03CE E0 778 movx a,@dptr + 03CF 24 01 779 add a,#0x01 + 03D1 F0 780 movx @dptr,a + 03D2 A3 781 inc dptr + 03D3 E0 782 movx a,@dptr + 03D4 34 00 783 addc a,#0x00 + 03D6 F0 784 movx @dptr,a + 785 ; _fsdiv.c 132 + 03D7 90s00r10 786 mov dptr,#___fsdiv_result_1_1 + 03DA E0 787 movx a,@dptr + 03DB F5*09 788 mov ___fsdiv_sloc3_1_0,a + 03DD A3 789 inc dptr + 03DE E0 790 movx a,@dptr + 03DF F5*0A 791 mov (___fsdiv_sloc3_1_0 + 1),a + 03E1 A3 792 inc dptr + 03E2 E0 793 movx a,@dptr + 03E3 F5*0B 794 mov (___fsdiv_sloc3_1_0 + 2),a + 03E5 A3 795 inc dptr + 03E6 E0 796 movx a,@dptr + 797 ; Peephole 105 removed redundant mov + 03E7 F5*0C 798 mov (___fsdiv_sloc3_1_0 + 3),a + 03E9 A2 E7 799 mov c,acc.7 + 03EB 13 800 rrc a + 03EC F5*0C 801 mov (___fsdiv_sloc3_1_0 + 3),a + 03EE E5*0B 802 mov a,(___fsdiv_sloc3_1_0 + 2) + 03F0 13 803 rrc a + 03F1 F5*0B 804 mov (___fsdiv_sloc3_1_0 + 2),a + 03F3 E5*0A 805 mov a,(___fsdiv_sloc3_1_0 + 1) + 03F5 13 806 rrc a + 03F6 F5*0A 807 mov (___fsdiv_sloc3_1_0 + 1),a + 03F8 E5*09 808 mov a,___fsdiv_sloc3_1_0 + 03FA 13 809 rrc a + 810 ; Peephole 100 removed redundant mov + 03FB F5*09 811 mov ___fsdiv_sloc3_1_0,a + 03FD 90s00r10 812 mov dptr,#___fsdiv_result_1_1 + 0400 F0 813 movx @dptr,a + 0401 A3 814 inc dptr + 0402 E5*0A 815 mov a,(___fsdiv_sloc3_1_0 + 1) + 0404 F0 816 movx @dptr,a + 0405 A3 817 inc dptr + 0406 E5*0B 818 mov a,(___fsdiv_sloc3_1_0 + 2) + 0408 F0 819 movx @dptr,a + 0409 A3 820 inc dptr + 040A E5*0C 821 mov a,(___fsdiv_sloc3_1_0 + 3) + 040C F0 822 movx @dptr,a + 823 ; _fsdiv.c 134 + 040D 90s00r10 824 mov dptr,#___fsdiv_result_1_1 + 0410 E0 825 movx a,@dptr + 0411 F5*09 826 mov ___fsdiv_sloc3_1_0,a + 0413 A3 827 inc dptr + 0414 E0 828 movx a,@dptr + 0415 F5*0A 829 mov (___fsdiv_sloc3_1_0 + 1),a + 0417 A3 830 inc dptr + 0418 E0 831 movx a,@dptr + 0419 F5*0B 832 mov (___fsdiv_sloc3_1_0 + 2),a + 041B A3 833 inc dptr + 041C E0 834 movx a,@dptr + 041D F5*0C 835 mov (___fsdiv_sloc3_1_0 + 3),a + 041F 90s00r10 836 mov dptr,#___fsdiv_result_1_1 + 0422 E5*09 837 mov a,___fsdiv_sloc3_1_0 + 0424 F0 838 movx @dptr,a + 0425 A3 839 inc dptr + 0426 E5*0A 840 mov a,(___fsdiv_sloc3_1_0 + 1) + 0428 F0 841 movx @dptr,a + 0429 74 7F 842 mov a,#0x7f + 042B 55*0B 843 anl a,(___fsdiv_sloc3_1_0 + 2) + 042D A3 844 inc dptr + 042E F0 845 movx @dptr,a + 042F A3 846 inc dptr + 0430 E5*0C 847 mov a,(___fsdiv_sloc3_1_0 + 3) + 0432 F0 848 movx @dptr,a + 849 ; _fsdiv.c 137 + 0433 90s00r20 850 mov dptr,#___fsdiv_exp_1_1 + 0436 E0 851 movx a,@dptr + 0437 F5*09 852 mov ___fsdiv_sloc3_1_0,a + 0439 A3 853 inc dptr + 043A E0 854 movx a,@dptr + 043B F5*0A 855 mov (___fsdiv_sloc3_1_0 + 1),a + 043D 85*09*0B 856 mov (___fsdiv_sloc3_1_0 + 2),___fsdiv_sloc3_1_0 + 0440 E5*0A 857 mov a,(___fsdiv_sloc3_1_0 + 1) + 0442 54 01 858 anl a,#0x01 + 0444 A2 E0 859 mov c,acc.0 + 0446 C5*0B 860 xch a,(___fsdiv_sloc3_1_0 + 2) + 0448 13 861 rrc a + 0449 C5*0B 862 xch a,(___fsdiv_sloc3_1_0 + 2) + 044B 13 863 rrc a + 044C C5*0B 864 xch a,(___fsdiv_sloc3_1_0 + 2) + 044E F5*0C 865 mov (___fsdiv_sloc3_1_0 + 3),a + 0450 75*0A 00 866 mov (___fsdiv_sloc3_1_0 + 1),#0x00 + 0453 75*09 00 867 mov ___fsdiv_sloc3_1_0,#0x00 + 0456 85*01*05 868 mov ___fsdiv_sloc2_1_0,___fsdiv_sloc1_1_0 + 869 ; Peephole 3.c changed mov to clr + 870 ; Peephole 3.b changed mov to clr + 0459 E4 871 clr a + 045A F5*06 872 mov (___fsdiv_sloc2_1_0 + 1),a + 045C F5*07 873 mov (___fsdiv_sloc2_1_0 + 2),a + 045E F5*08 874 mov (___fsdiv_sloc2_1_0 + 3),a + 0460 E5*05 875 mov a,___fsdiv_sloc2_1_0 + 0462 42*09 876 orl ___fsdiv_sloc3_1_0,a + 0464 E5*06 877 mov a,(___fsdiv_sloc2_1_0 + 1) + 0466 42*0A 878 orl (___fsdiv_sloc3_1_0 + 1),a + 0468 E5*07 879 mov a,(___fsdiv_sloc2_1_0 + 2) + 046A 42*0B 880 orl (___fsdiv_sloc3_1_0 + 2),a + 046C E5*08 881 mov a,(___fsdiv_sloc2_1_0 + 3) + 046E 42*0C 882 orl (___fsdiv_sloc3_1_0 + 3),a + 0470 90s00r10 883 mov dptr,#___fsdiv_result_1_1 + 0473 E0 884 movx a,@dptr + 0474 F5*05 885 mov ___fsdiv_sloc2_1_0,a + 0476 A3 886 inc dptr + 0477 E0 887 movx a,@dptr + 0478 F5*06 888 mov (___fsdiv_sloc2_1_0 + 1),a + 047A A3 889 inc dptr + 047B E0 890 movx a,@dptr + 047C F5*07 891 mov (___fsdiv_sloc2_1_0 + 2),a + 047E A3 892 inc dptr + 047F E0 893 movx a,@dptr + 0480 F5*08 894 mov (___fsdiv_sloc2_1_0 + 3),a + 0482 E5*05 895 mov a,___fsdiv_sloc2_1_0 + 0484 42*09 896 orl ___fsdiv_sloc3_1_0,a + 0486 E5*06 897 mov a,(___fsdiv_sloc2_1_0 + 1) + 0488 42*0A 898 orl (___fsdiv_sloc3_1_0 + 1),a + 048A E5*07 899 mov a,(___fsdiv_sloc2_1_0 + 2) + 048C 42*0B 900 orl (___fsdiv_sloc3_1_0 + 2),a + 048E E5*08 901 mov a,(___fsdiv_sloc2_1_0 + 3) + 0490 42*0C 902 orl (___fsdiv_sloc3_1_0 + 3),a + 0492 90s00r08 903 mov dptr,#(___fsdiv_fl1_1_1) + 0495 E5*09 904 mov a,___fsdiv_sloc3_1_0 + 0497 F0 905 movx @dptr,a + 0498 A3 906 inc dptr + 0499 E5*0A 907 mov a,(___fsdiv_sloc3_1_0 + 1) + 049B F0 908 movx @dptr,a + 049C A3 909 inc dptr + 049D E5*0B 910 mov a,(___fsdiv_sloc3_1_0 + 2) + 049F F0 911 movx @dptr,a + 04A0 A3 912 inc dptr + 04A1 E5*0C 913 mov a,(___fsdiv_sloc3_1_0 + 3) + 04A3 F0 914 movx @dptr,a + 915 ; _fsdiv.c 138 + 04A4 90s00r08 916 mov dptr,#(___fsdiv_fl1_1_1) + 04A7 E0 917 movx a,@dptr + 04A8 F5*09 918 mov ___fsdiv_sloc3_1_0,a + 04AA A3 919 inc dptr + 04AB E0 920 movx a,@dptr + 04AC F5*0A 921 mov (___fsdiv_sloc3_1_0 + 1),a + 04AE A3 922 inc dptr + 04AF E0 923 movx a,@dptr + 04B0 F5*0B 924 mov (___fsdiv_sloc3_1_0 + 2),a + 04B2 A3 925 inc dptr + 04B3 E0 926 movx a,@dptr + 927 ; Peephole 191 removed redundant mov + 04B4 F5*0C 928 mov (___fsdiv_sloc3_1_0 + 3),a + 04B6 85*09 82 929 mov dpl,___fsdiv_sloc3_1_0 + 04B9 85*0A 83 930 mov dph,(___fsdiv_sloc3_1_0 + 1) + 04BC 85*0B F0 931 mov b,(___fsdiv_sloc3_1_0 + 2) + 04BF 932 00112$: + 04BF 933 C$_fsdiv.c$139$1$1 ==. + 04BF 934 XG$__fsdiv$0$0 ==. + 04BF 22 935 ret + 936 .area CSEG (CODE) diff --git a/device/lib/_fsdiv.sym b/device/lib/_fsdiv.sym new file mode 100644 index 00000000..146574e2 --- /dev/null +++ b/device/lib/_fsdiv.sym @@ -0,0 +1,1159 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fsdiv$100 0016 GR + 7 A$_fsdiv$101 0018 GR + 7 A$_fsdiv$102 0019 GR + 7 A$_fsdiv$104 001A GR + 7 A$_fsdiv$105 001D GR + 7 A$_fsdiv$106 001E GR + 7 A$_fsdiv$107 001F GR + 7 A$_fsdiv$108 0020 GR + 7 A$_fsdiv$109 0021 GR + 7 A$_fsdiv$110 0022 GR + 7 A$_fsdiv$111 0023 GR + 7 A$_fsdiv$112 0024 GR + 7 A$_fsdiv$113 0025 GR + 7 A$_fsdiv$114 0026 GR + 7 A$_fsdiv$115 0027 GR + 7 A$_fsdiv$116 0028 GR + 7 A$_fsdiv$117 002B GR + 7 A$_fsdiv$118 002C GR + 7 A$_fsdiv$119 002D GR + 7 A$_fsdiv$120 002E GR + 7 A$_fsdiv$121 002F GR + 7 A$_fsdiv$122 0030 GR + 7 A$_fsdiv$123 0031 GR + 7 A$_fsdiv$124 0032 GR + 7 A$_fsdiv$125 0033 GR + 7 A$_fsdiv$126 0034 GR + 7 A$_fsdiv$127 0035 GR + 7 A$_fsdiv$129 0036 GR + 7 A$_fsdiv$130 0039 GR + 7 A$_fsdiv$131 003A GR + 7 A$_fsdiv$132 003B GR + 7 A$_fsdiv$133 003C GR + 7 A$_fsdiv$134 003D GR + 7 A$_fsdiv$135 003E GR + 7 A$_fsdiv$136 003F GR + 7 A$_fsdiv$137 0040 GR + 7 A$_fsdiv$138 0041 GR + 7 A$_fsdiv$139 0042 GR + 7 A$_fsdiv$140 0043 GR + 7 A$_fsdiv$141 0044 GR + 7 A$_fsdiv$142 0047 GR + 7 A$_fsdiv$143 0048 GR + 7 A$_fsdiv$144 0049 GR + 7 A$_fsdiv$145 004A GR + 7 A$_fsdiv$146 004B GR + 7 A$_fsdiv$147 004C GR + 7 A$_fsdiv$148 004D GR + 7 A$_fsdiv$149 004E GR + 7 A$_fsdiv$150 004F GR + 7 A$_fsdiv$151 0050 GR + 7 A$_fsdiv$152 0051 GR + 7 A$_fsdiv$154 0052 GR + 7 A$_fsdiv$155 0055 GR + 7 A$_fsdiv$156 0056 GR + 7 A$_fsdiv$157 0057 GR + 7 A$_fsdiv$158 0058 GR + 7 A$_fsdiv$159 0059 GR + 7 A$_fsdiv$160 005A GR + 7 A$_fsdiv$161 005B GR + 7 A$_fsdiv$162 005C GR + 7 A$_fsdiv$163 005D GR + 7 A$_fsdiv$164 005E GR + 7 A$_fsdiv$165 005F GR + 7 A$_fsdiv$166 0060 GR + 7 A$_fsdiv$167 0062 GR + 7 A$_fsdiv$168 0063 GR + 7 A$_fsdiv$169 0065 GR + 7 A$_fsdiv$170 0066 GR + 7 A$_fsdiv$171 0067 GR + 7 A$_fsdiv$172 0068 GR + 7 A$_fsdiv$173 0069 GR + 7 A$_fsdiv$174 006A GR + 7 A$_fsdiv$175 006C GR + 7 A$_fsdiv$176 006F GR + 7 A$_fsdiv$178 0071 GR + 7 A$_fsdiv$179 0072 GR + 7 A$_fsdiv$180 0073 GR + 7 A$_fsdiv$181 0075 GR + 7 A$_fsdiv$182 0076 GR + 7 A$_fsdiv$183 0077 GR + 7 A$_fsdiv$184 007A GR + 7 A$_fsdiv$185 007B GR + 7 A$_fsdiv$186 007C GR + 7 A$_fsdiv$188 007D GR + 7 A$_fsdiv$189 007E GR + 7 A$_fsdiv$191 007F GR + 7 A$_fsdiv$192 0082 GR + 7 A$_fsdiv$193 0083 GR + 7 A$_fsdiv$194 0084 GR + 7 A$_fsdiv$195 0085 GR + 7 A$_fsdiv$196 0086 GR + 7 A$_fsdiv$197 0087 GR + 7 A$_fsdiv$198 0088 GR + 7 A$_fsdiv$199 0089 GR + 7 A$_fsdiv$200 008A GR + 7 A$_fsdiv$201 008B GR + 7 A$_fsdiv$202 008C GR + 7 A$_fsdiv$203 008D GR + 7 A$_fsdiv$204 008F GR + 7 A$_fsdiv$205 0090 GR + 7 A$_fsdiv$206 0092 GR + 7 A$_fsdiv$207 0093 GR + 7 A$_fsdiv$208 0094 GR + 7 A$_fsdiv$209 0095 GR + 7 A$_fsdiv$210 0096 GR + 7 A$_fsdiv$211 0097 GR + 7 A$_fsdiv$212 0099 GR + 7 A$_fsdiv$213 009C GR + 7 A$_fsdiv$215 009E GR + 7 A$_fsdiv$216 009F GR + 7 A$_fsdiv$217 00A0 GR + 7 A$_fsdiv$218 00A2 GR + 7 A$_fsdiv$219 00A3 GR + 7 A$_fsdiv$220 00A4 GR + 7 A$_fsdiv$221 00A6 GR + 7 A$_fsdiv$222 00A9 GR + 7 A$_fsdiv$223 00AA GR + 7 A$_fsdiv$224 00AB GR + 7 A$_fsdiv$225 00AC GR + 7 A$_fsdiv$226 00AD GR + 7 A$_fsdiv$227 00AE GR + 7 A$_fsdiv$228 00B1 GR + 7 A$_fsdiv$229 00B2 GR + 7 A$_fsdiv$230 00B3 GR + 7 A$_fsdiv$231 00B4 GR + 7 A$_fsdiv$232 00B5 GR + 7 A$_fsdiv$233 00B6 GR + 7 A$_fsdiv$234 00B7 GR + 7 A$_fsdiv$235 00B8 GR + 7 A$_fsdiv$237 00B9 GR + 7 A$_fsdiv$238 00BC GR + 7 A$_fsdiv$239 00BD GR + 7 A$_fsdiv$240 00BE GR + 7 A$_fsdiv$241 00BF GR + 7 A$_fsdiv$242 00C0 GR + 7 A$_fsdiv$243 00C1 GR + 7 A$_fsdiv$244 00C4 GR + 7 A$_fsdiv$245 00C6 GR + 7 A$_fsdiv$246 00C7 GR + 7 A$_fsdiv$248 00C8 GR + 7 A$_fsdiv$249 00C9 GR + 7 A$_fsdiv$250 00CA GR + 7 A$_fsdiv$251 00CB GR + 7 A$_fsdiv$253 00CC GR + 7 A$_fsdiv$254 00CF GR + 7 A$_fsdiv$255 00D0 GR + 7 A$_fsdiv$256 00D1 GR + 7 A$_fsdiv$257 00D2 GR + 7 A$_fsdiv$258 00D3 GR + 7 A$_fsdiv$259 00D4 GR + 7 A$_fsdiv$260 00D5 GR + 7 A$_fsdiv$261 00D6 GR + 7 A$_fsdiv$262 00D7 GR + 7 A$_fsdiv$263 00D8 GR + 7 A$_fsdiv$265 00D9 GR + 7 A$_fsdiv$266 00DA GR + 7 A$_fsdiv$267 00DB GR + 7 A$_fsdiv$268 00DD GR + 7 A$_fsdiv$269 00DF GR + 7 A$_fsdiv$270 00E2 GR + 7 A$_fsdiv$271 00E3 GR + 7 A$_fsdiv$272 00E5 GR + 7 A$_fsdiv$273 00E6 GR + 7 A$_fsdiv$274 00E7 GR + 7 A$_fsdiv$275 00E9 GR + 7 A$_fsdiv$276 00EA GR + 7 A$_fsdiv$277 00EB GR + 7 A$_fsdiv$278 00ED GR + 7 A$_fsdiv$279 00EE GR + 7 A$_fsdiv$281 00EF GR + 7 A$_fsdiv$282 00F1 GR + 7 A$_fsdiv$283 00F2 GR + 7 A$_fsdiv$285 00F4 GR + 7 A$_fsdiv$286 00F5 GR + 7 A$_fsdiv$287 00F7 GR + 7 A$_fsdiv$289 00F9 GR + 7 A$_fsdiv$290 00FC GR + 7 A$_fsdiv$291 00FD GR + 7 A$_fsdiv$292 00FF GR + 7 A$_fsdiv$293 0100 GR + 7 A$_fsdiv$294 0101 GR + 7 A$_fsdiv$295 0103 GR + 7 A$_fsdiv$296 0104 GR + 7 A$_fsdiv$297 0105 GR + 7 A$_fsdiv$298 0107 GR + 7 A$_fsdiv$299 0108 GR + 7 A$_fsdiv$300 0109 GR + 7 A$_fsdiv$301 010B GR + 7 A$_fsdiv$302 010D GR + 7 A$_fsdiv$303 010F GR + 7 A$_fsdiv$304 0111 GR + 7 A$_fsdiv$306 0113 GR + 7 A$_fsdiv$310 0115 GR + 7 A$_fsdiv$311 0118 GR + 7 A$_fsdiv$312 011B GR + 7 A$_fsdiv$313 011D GR + 7 A$_fsdiv$316 0120 GR + 7 A$_fsdiv$317 0123 GR + 7 A$_fsdiv$318 0124 GR + 7 A$_fsdiv$319 0126 GR + 7 A$_fsdiv$320 0127 GR + 7 A$_fsdiv$321 0128 GR + 7 A$_fsdiv$322 012A GR + 7 A$_fsdiv$323 012B GR + 7 A$_fsdiv$324 012C GR + 7 A$_fsdiv$325 012E GR + 7 A$_fsdiv$326 012F GR + 7 A$_fsdiv$327 0130 GR + 7 A$_fsdiv$328 0132 GR + 7 A$_fsdiv$329 0134 GR + 7 A$_fsdiv$330 0136 GR + 7 A$_fsdiv$331 0138 GR + 7 A$_fsdiv$333 013A GR + 7 A$_fsdiv$339 013C GR + 7 A$_fsdiv$340 013D GR + 7 A$_fsdiv$341 013F GR + 7 A$_fsdiv$342 0141 GR + 7 A$_fsdiv$343 0143 GR + 7 A$_fsdiv$346 0146 GR + 7 A$_fsdiv$347 0149 GR + 7 A$_fsdiv$348 014A GR + 7 A$_fsdiv$349 014C GR + 7 A$_fsdiv$350 014D GR + 7 A$_fsdiv$351 014E GR + 7 A$_fsdiv$352 0150 GR + 7 A$_fsdiv$353 0151 GR + 7 A$_fsdiv$354 0152 GR + 7 A$_fsdiv$355 0154 GR + 7 A$_fsdiv$356 0155 GR + 7 A$_fsdiv$357 0156 GR + 7 A$_fsdiv$358 0158 GR + 7 A$_fsdiv$359 015B GR + 7 A$_fsdiv$360 015E GR + 7 A$_fsdiv$361 0161 GR + 7 A$_fsdiv$362 0163 GR + 7 A$_fsdiv$363 0164 GR + 7 A$_fsdiv$364 0165 GR + 7 A$_fsdiv$365 0167 GR + 7 A$_fsdiv$366 0168 GR + 7 A$_fsdiv$367 016A GR + 7 A$_fsdiv$368 016C GR + 7 A$_fsdiv$369 016D GR + 7 A$_fsdiv$370 016E GR + 7 A$_fsdiv$371 016F GR + 7 A$_fsdiv$372 0171 GR + 7 A$_fsdiv$374 0172 GR + 7 A$_fsdiv$375 0175 GR + 7 A$_fsdiv$376 0176 GR + 7 A$_fsdiv$377 0178 GR + 7 A$_fsdiv$378 0179 GR + 7 A$_fsdiv$379 017A GR + 7 A$_fsdiv$380 017C GR + 7 A$_fsdiv$381 017D GR + 7 A$_fsdiv$382 017E GR + 7 A$_fsdiv$383 0180 GR + 7 A$_fsdiv$384 0181 GR + 7 A$_fsdiv$385 0182 GR + 7 A$_fsdiv$386 0184 GR + 7 A$_fsdiv$387 0187 GR + 7 A$_fsdiv$388 018A GR + 7 A$_fsdiv$389 018D GR + 7 A$_fsdiv$390 018F GR + 7 A$_fsdiv$391 0190 GR + 7 A$_fsdiv$392 0191 GR + 7 A$_fsdiv$393 0193 GR + 7 A$_fsdiv$394 0194 GR + 7 A$_fsdiv$395 0196 GR + 7 A$_fsdiv$396 0198 GR + 7 A$_fsdiv$397 0199 GR + 7 A$_fsdiv$398 019A GR + 7 A$_fsdiv$399 019B GR + 7 A$_fsdiv$400 019D GR + 7 A$_fsdiv$402 019E GR + 7 A$_fsdiv$403 01A1 GR + 7 A$_fsdiv$404 01A2 GR + 7 A$_fsdiv$405 01A4 GR + 7 A$_fsdiv$406 01A5 GR + 7 A$_fsdiv$407 01A6 GR + 7 A$_fsdiv$408 01A8 GR + 7 A$_fsdiv$409 01A9 GR + 7 A$_fsdiv$410 01AA GR + 7 A$_fsdiv$411 01AC GR + 7 A$_fsdiv$412 01AD GR + 7 A$_fsdiv$413 01AE GR + 7 A$_fsdiv$414 01B0 GR + 7 A$_fsdiv$415 01B3 GR + 7 A$_fsdiv$416 01B4 GR + 7 A$_fsdiv$417 01B6 GR + 7 A$_fsdiv$418 01B7 GR + 7 A$_fsdiv$419 01B8 GR + 7 A$_fsdiv$420 01BA GR + 7 A$_fsdiv$421 01BB GR + 7 A$_fsdiv$422 01BC GR + 7 A$_fsdiv$423 01BE GR + 7 A$_fsdiv$424 01BF GR + 7 A$_fsdiv$425 01C0 GR + 7 A$_fsdiv$426 01C2 GR + 7 A$_fsdiv$427 01C3 GR + 7 A$_fsdiv$428 01C5 GR + 7 A$_fsdiv$429 01C7 GR + 7 A$_fsdiv$430 01C9 GR + 7 A$_fsdiv$431 01CB GR + 7 A$_fsdiv$432 01CD GR + 7 A$_fsdiv$433 01CF GR + 7 A$_fsdiv$434 01D1 GR + 7 A$_fsdiv$435 01D3 GR + 7 A$_fsdiv$436 01D6 GR + 7 A$_fsdiv$437 01D9 GR + 7 A$_fsdiv$438 01DB GR + 7 A$_fsdiv$439 01DD GR + 7 A$_fsdiv$442 01E0 GR + 7 A$_fsdiv$443 01E3 GR + 7 A$_fsdiv$444 01E4 GR + 7 A$_fsdiv$445 01E6 GR + 7 A$_fsdiv$446 01E7 GR + 7 A$_fsdiv$447 01E8 GR + 7 A$_fsdiv$448 01EA GR + 7 A$_fsdiv$449 01EB GR + 7 A$_fsdiv$450 01EC GR + 7 A$_fsdiv$451 01EE GR + 7 A$_fsdiv$452 01EF GR + 7 A$_fsdiv$453 01F0 GR + 7 A$_fsdiv$454 01F2 GR + 7 A$_fsdiv$455 01F4 GR + 7 A$_fsdiv$456 01F6 GR + 7 A$_fsdiv$457 01F8 GR + 7 A$_fsdiv$458 01FA GR + 7 A$_fsdiv$459 01FB GR + 7 A$_fsdiv$460 01FD GR + 7 A$_fsdiv$461 01FF GR + 7 A$_fsdiv$462 0200 GR + 7 A$_fsdiv$463 0202 GR + 7 A$_fsdiv$464 0204 GR + 7 A$_fsdiv$465 0205 GR + 7 A$_fsdiv$466 0207 GR + 7 A$_fsdiv$467 020A GR + 7 A$_fsdiv$468 020C GR + 7 A$_fsdiv$469 020D GR + 7 A$_fsdiv$470 020E GR + 7 A$_fsdiv$471 0210 GR + 7 A$_fsdiv$472 0211 GR + 7 A$_fsdiv$473 0212 GR + 7 A$_fsdiv$474 0214 GR + 7 A$_fsdiv$475 0215 GR + 7 A$_fsdiv$476 0216 GR + 7 A$_fsdiv$477 0218 GR + 7 A$_fsdiv$479 0219 GR + 7 A$_fsdiv$480 021C GR + 7 A$_fsdiv$481 021D GR + 7 A$_fsdiv$482 021F GR + 7 A$_fsdiv$483 0221 GR + 7 A$_fsdiv$484 0222 GR + 7 A$_fsdiv$485 0223 GR + 7 A$_fsdiv$486 0225 GR + 7 A$_fsdiv$487 0227 GR + 7 A$_fsdiv$488 022A GR + 7 A$_fsdiv$489 022C GR + 7 A$_fsdiv$490 022D GR + 7 A$_fsdiv$491 022E GR + 7 A$_fsdiv$492 0230 GR + 7 A$_fsdiv$495 0231 GR + 7 A$_fsdiv$498 0234 GR + 7 A$_fsdiv$499 0235 GR + 7 A$_fsdiv$500 0236 GR + 7 A$_fsdiv$501 0237 GR + 7 A$_fsdiv$502 0238 GR + 7 A$_fsdiv$504 0239 GR + 7 A$_fsdiv$505 023A GR + 7 A$_fsdiv$506 023B GR + 7 A$_fsdiv$507 023C GR + 7 A$_fsdiv$508 023E GR + 7 A$_fsdiv$510 023F GR + 7 A$_fsdiv$511 0242 GR + 7 A$_fsdiv$512 0243 GR + 7 A$_fsdiv$513 0244 GR + 7 A$_fsdiv$514 0245 GR + 7 A$_fsdiv$515 0246 GR + 7 A$_fsdiv$516 0247 GR + 7 A$_fsdiv$517 024A GR + 7 A$_fsdiv$518 024B GR + 7 A$_fsdiv$519 024E GR + 7 A$_fsdiv$520 024F GR + 7 A$_fsdiv$521 0252 GR + 7 A$_fsdiv$524 0253 GR + 7 A$_fsdiv$525 0256 GR + 7 A$_fsdiv$526 0257 GR + 7 A$_fsdiv$527 0259 GR + 7 A$_fsdiv$528 025A GR + 7 A$_fsdiv$529 025B GR + 7 A$_fsdiv$530 025D GR + 7 A$_fsdiv$531 025E GR + 7 A$_fsdiv$532 025F GR + 7 A$_fsdiv$533 0261 GR + 7 A$_fsdiv$534 0262 GR + 7 A$_fsdiv$535 0263 GR + 7 A$_fsdiv$536 0265 GR + 7 A$_fsdiv$537 0267 GR + 7 A$_fsdiv$538 0269 GR + 7 A$_fsdiv$539 026B GR + 7 A$_fsdiv$540 026D GR + 7 A$_fsdiv$541 026F GR + 7 A$_fsdiv$544 0272 GR + 7 A$_fsdiv$545 0275 GR + 7 A$_fsdiv$546 0276 GR + 7 A$_fsdiv$547 0278 GR + 7 A$_fsdiv$548 0279 GR + 7 A$_fsdiv$549 027A GR + 7 A$_fsdiv$550 027C GR + 7 A$_fsdiv$551 027D GR + 7 A$_fsdiv$552 027E GR + 7 A$_fsdiv$553 0280 GR + 7 A$_fsdiv$554 0281 GR + 7 A$_fsdiv$555 0282 GR + 7 A$_fsdiv$556 0284 GR + 7 A$_fsdiv$557 0287 GR + 7 A$_fsdiv$558 0288 GR + 7 A$_fsdiv$559 028A GR + 7 A$_fsdiv$560 028B GR + 7 A$_fsdiv$561 028C GR + 7 A$_fsdiv$562 028E GR + 7 A$_fsdiv$563 028F GR + 7 A$_fsdiv$564 0290 GR + 7 A$_fsdiv$565 0292 GR + 7 A$_fsdiv$566 0293 GR + 7 A$_fsdiv$567 0294 GR + 7 A$_fsdiv$568 0296 GR + 7 A$_fsdiv$569 0297 GR + 7 A$_fsdiv$570 0299 GR + 7 A$_fsdiv$571 029B GR + 7 A$_fsdiv$572 029D GR + 7 A$_fsdiv$573 029F GR + 7 A$_fsdiv$574 02A1 GR + 7 A$_fsdiv$575 02A3 GR + 7 A$_fsdiv$576 02A5 GR + 7 A$_fsdiv$577 02A7 GR + 7 A$_fsdiv$578 02AA GR + 7 A$_fsdiv$579 02AD GR + 7 A$_fsdiv$580 02AF GR + 7 A$_fsdiv$581 02B1 GR + 7 A$_fsdiv$584 02B4 GR + 7 A$_fsdiv$585 02B7 GR + 7 A$_fsdiv$586 02B8 GR + 7 A$_fsdiv$587 02BA GR + 7 A$_fsdiv$588 02BB GR + 7 A$_fsdiv$589 02BC GR + 7 A$_fsdiv$590 02BE GR + 7 A$_fsdiv$591 02BF GR + 7 A$_fsdiv$592 02C0 GR + 7 A$_fsdiv$593 02C2 GR + 7 A$_fsdiv$594 02C3 GR + 7 A$_fsdiv$595 02C4 GR + 7 A$_fsdiv$596 02C6 GR + 7 A$_fsdiv$597 02C9 GR + 7 A$_fsdiv$598 02CA GR + 7 A$_fsdiv$599 02CC GR + 7 A$_fsdiv$600 02CD GR + 7 A$_fsdiv$601 02CE GR + 7 A$_fsdiv$602 02D0 GR + 7 A$_fsdiv$603 02D1 GR + 7 A$_fsdiv$604 02D2 GR + 7 A$_fsdiv$605 02D4 GR + 7 A$_fsdiv$606 02D5 GR + 7 A$_fsdiv$607 02D6 GR + 7 A$_fsdiv$608 02D8 GR + 7 A$_fsdiv$609 02DB GR + 7 A$_fsdiv$610 02DD GR + 7 A$_fsdiv$611 02DF GR + 7 A$_fsdiv$612 02E0 GR + 7 A$_fsdiv$613 02E2 GR + 7 A$_fsdiv$614 02E4 GR + 7 A$_fsdiv$615 02E5 GR + 7 A$_fsdiv$616 02E6 GR + 7 A$_fsdiv$617 02E8 GR + 7 A$_fsdiv$618 02EA GR + 7 A$_fsdiv$619 02EB GR + 7 A$_fsdiv$620 02EC GR + 7 A$_fsdiv$621 02EE GR + 7 A$_fsdiv$622 02F0 GR + 7 A$_fsdiv$623 02F1 GR + 7 A$_fsdiv$625 02F2 GR + 7 A$_fsdiv$626 02F5 GR + 7 A$_fsdiv$627 02F6 GR + 7 A$_fsdiv$628 02F8 GR + 7 A$_fsdiv$629 02F9 GR + 7 A$_fsdiv$630 02FA GR + 7 A$_fsdiv$631 02FC GR + 7 A$_fsdiv$632 02FD GR + 7 A$_fsdiv$633 02FE GR + 7 A$_fsdiv$634 0300 GR + 7 A$_fsdiv$635 0301 GR + 7 A$_fsdiv$636 0302 GR + 7 A$_fsdiv$637 0304 GR + 7 A$_fsdiv$638 0307 GR + 7 A$_fsdiv$639 0308 GR + 7 A$_fsdiv$640 030A GR + 7 A$_fsdiv$641 030B GR + 7 A$_fsdiv$642 030C GR + 7 A$_fsdiv$643 030E GR + 7 A$_fsdiv$644 030F GR + 7 A$_fsdiv$645 0310 GR + 7 A$_fsdiv$646 0312 GR + 7 A$_fsdiv$647 0313 GR + 7 A$_fsdiv$648 0314 GR + 7 A$_fsdiv$649 0316 GR + 7 A$_fsdiv$650 0319 GR + 7 A$_fsdiv$651 031A GR + 7 A$_fsdiv$652 031C GR + 7 A$_fsdiv$653 031E GR + 7 A$_fsdiv$654 031F GR + 7 A$_fsdiv$655 0321 GR + 7 A$_fsdiv$656 0323 GR + 7 A$_fsdiv$657 0324 GR + 7 A$_fsdiv$658 0325 GR + 7 A$_fsdiv$659 0327 GR + 7 A$_fsdiv$660 0329 GR + 7 A$_fsdiv$661 032A GR + 7 A$_fsdiv$662 032B GR + 7 A$_fsdiv$663 032D GR + 7 A$_fsdiv$664 032F GR + 7 A$_fsdiv$665 0330 GR + 7 A$_fsdiv$668 0331 GR + 7 A$_fsdiv$669 0334 GR + 7 A$_fsdiv$670 0335 GR + 7 A$_fsdiv$671 0337 GR + 7 A$_fsdiv$672 0338 GR + 7 A$_fsdiv$673 0339 GR + 7 A$_fsdiv$674 033B GR + 7 A$_fsdiv$675 033C GR + 7 A$_fsdiv$676 033D GR + 7 A$_fsdiv$677 033F GR + 7 A$_fsdiv$678 0340 GR + 7 A$_fsdiv$679 0341 GR + 7 A$_fsdiv$680 0343 GR + 7 A$_fsdiv$681 0345 GR + 7 A$_fsdiv$682 0347 GR + 7 A$_fsdiv$683 0349 GR + 7 A$_fsdiv$684 034B GR + 7 A$_fsdiv$685 034C GR + 7 A$_fsdiv$686 034E GR + 7 A$_fsdiv$687 0350 GR + 7 A$_fsdiv$688 0351 GR + 7 A$_fsdiv$689 0353 GR + 7 A$_fsdiv$690 0355 GR + 7 A$_fsdiv$691 0356 GR + 7 A$_fsdiv$692 0358 GR + 7 A$_fsdiv$693 035B GR + 7 A$_fsdiv$694 035D GR + 7 A$_fsdiv$695 035E GR + 7 A$_fsdiv$696 035F GR + 7 A$_fsdiv$697 0361 GR + 7 A$_fsdiv$698 0362 GR + 7 A$_fsdiv$699 0363 GR + 7 A$_fsdiv$700 0365 GR + 7 A$_fsdiv$701 0366 GR + 7 A$_fsdiv$702 0367 GR + 7 A$_fsdiv$703 0369 GR + 7 A$_fsdiv$705 036A GR + 7 A$_fsdiv$706 036D GR + 7 A$_fsdiv$707 036E GR + 7 A$_fsdiv$708 0370 GR + 7 A$_fsdiv$709 0371 GR + 7 A$_fsdiv$710 0372 GR + 7 A$_fsdiv$711 0374 GR + 7 A$_fsdiv$712 0375 GR + 7 A$_fsdiv$713 0376 GR + 7 A$_fsdiv$714 0378 GR + 7 A$_fsdiv$715 0379 GR + 7 A$_fsdiv$717 037A GR + 7 A$_fsdiv$718 037C GR + 7 A$_fsdiv$719 037D GR + 7 A$_fsdiv$720 037E GR + 7 A$_fsdiv$721 0380 GR + 7 A$_fsdiv$722 0382 GR + 7 A$_fsdiv$723 0383 GR + 7 A$_fsdiv$724 0385 GR + 7 A$_fsdiv$725 0387 GR + 7 A$_fsdiv$726 0388 GR + 7 A$_fsdiv$727 038A GR + 7 A$_fsdiv$728 038C GR + 7 A$_fsdiv$730 038D GR + 7 A$_fsdiv$731 038F GR + 7 A$_fsdiv$732 0392 GR + 7 A$_fsdiv$733 0393 GR + 7 A$_fsdiv$734 0394 GR + 7 A$_fsdiv$735 0396 GR + 7 A$_fsdiv$736 0397 GR + 7 A$_fsdiv$737 0398 GR + 7 A$_fsdiv$738 039A GR + 7 A$_fsdiv$739 039B GR + 7 A$_fsdiv$740 039C GR + 7 A$_fsdiv$741 039E GR + 7 A$_fsdiv$742 039F GR + 7 A$_fsdiv$745 03A2 GR + 7 A$_fsdiv$746 03A5 GR + 7 A$_fsdiv$747 03A6 GR + 7 A$_fsdiv$748 03A8 GR + 7 A$_fsdiv$749 03A9 GR + 7 A$_fsdiv$750 03AA GR + 7 A$_fsdiv$751 03AC GR + 7 A$_fsdiv$752 03AD GR + 7 A$_fsdiv$753 03AE GR + 7 A$_fsdiv$754 03B0 GR + 7 A$_fsdiv$755 03B1 GR + 7 A$_fsdiv$756 03B2 GR + 7 A$_fsdiv$757 03B4 GR + 7 A$_fsdiv$758 03B7 GR + 7 A$_fsdiv$759 03B9 GR + 7 A$_fsdiv$760 03BB GR + 7 A$_fsdiv$762 03BC GR + 7 A$_fsdiv$763 03BD GR + 7 A$_fsdiv$764 03BF GR + 7 A$_fsdiv$765 03C0 GR + 7 A$_fsdiv$767 03C1 GR + 7 A$_fsdiv$768 03C2 GR + 7 A$_fsdiv$769 03C4 GR + 7 A$_fsdiv$770 03C5 GR + 7 A$_fsdiv$772 03C6 GR + 7 A$_fsdiv$773 03C7 GR + 7 A$_fsdiv$774 03C9 GR + 7 A$_fsdiv$775 03CA GR + 7 A$_fsdiv$777 03CB GR + 7 A$_fsdiv$778 03CE GR + 7 A$_fsdiv$779 03CF GR + 7 A$_fsdiv$780 03D1 GR + 7 A$_fsdiv$781 03D2 GR + 7 A$_fsdiv$782 03D3 GR + 7 A$_fsdiv$783 03D4 GR + 7 A$_fsdiv$784 03D6 GR + 7 A$_fsdiv$786 03D7 GR + 7 A$_fsdiv$787 03DA GR + 7 A$_fsdiv$788 03DB GR + 7 A$_fsdiv$789 03DD GR + 7 A$_fsdiv$790 03DE GR + 7 A$_fsdiv$791 03DF GR + 7 A$_fsdiv$792 03E1 GR + 7 A$_fsdiv$793 03E2 GR + 7 A$_fsdiv$794 03E3 GR + 7 A$_fsdiv$795 03E5 GR + 7 A$_fsdiv$796 03E6 GR + 7 A$_fsdiv$798 03E7 GR + 7 A$_fsdiv$799 03E9 GR + 7 A$_fsdiv$800 03EB GR + 7 A$_fsdiv$801 03EC GR + 7 A$_fsdiv$802 03EE GR + 7 A$_fsdiv$803 03F0 GR + 7 A$_fsdiv$804 03F1 GR + 7 A$_fsdiv$805 03F3 GR + 7 A$_fsdiv$806 03F5 GR + 7 A$_fsdiv$807 03F6 GR + 7 A$_fsdiv$808 03F8 GR + 7 A$_fsdiv$809 03FA GR + 7 A$_fsdiv$811 03FB GR + 7 A$_fsdiv$812 03FD GR + 7 A$_fsdiv$813 0400 GR + 7 A$_fsdiv$814 0401 GR + 7 A$_fsdiv$815 0402 GR + 7 A$_fsdiv$816 0404 GR + 7 A$_fsdiv$817 0405 GR + 7 A$_fsdiv$818 0406 GR + 7 A$_fsdiv$819 0408 GR + 7 A$_fsdiv$820 0409 GR + 7 A$_fsdiv$821 040A GR + 7 A$_fsdiv$822 040C GR + 7 A$_fsdiv$824 040D GR + 7 A$_fsdiv$825 0410 GR + 7 A$_fsdiv$826 0411 GR + 7 A$_fsdiv$827 0413 GR + 7 A$_fsdiv$828 0414 GR + 7 A$_fsdiv$829 0415 GR + 7 A$_fsdiv$830 0417 GR + 7 A$_fsdiv$831 0418 GR + 7 A$_fsdiv$832 0419 GR + 7 A$_fsdiv$833 041B GR + 7 A$_fsdiv$834 041C GR + 7 A$_fsdiv$835 041D GR + 7 A$_fsdiv$836 041F GR + 7 A$_fsdiv$837 0422 GR + 7 A$_fsdiv$838 0424 GR + 7 A$_fsdiv$839 0425 GR + 7 A$_fsdiv$840 0426 GR + 7 A$_fsdiv$841 0428 GR + 7 A$_fsdiv$842 0429 GR + 7 A$_fsdiv$843 042B GR + 7 A$_fsdiv$844 042D GR + 7 A$_fsdiv$845 042E GR + 7 A$_fsdiv$846 042F GR + 7 A$_fsdiv$847 0430 GR + 7 A$_fsdiv$848 0432 GR + 7 A$_fsdiv$850 0433 GR + 7 A$_fsdiv$851 0436 GR + 7 A$_fsdiv$852 0437 GR + 7 A$_fsdiv$853 0439 GR + 7 A$_fsdiv$854 043A GR + 7 A$_fsdiv$855 043B GR + 7 A$_fsdiv$856 043D GR + 7 A$_fsdiv$857 0440 GR + 7 A$_fsdiv$858 0442 GR + 7 A$_fsdiv$859 0444 GR + 7 A$_fsdiv$860 0446 GR + 7 A$_fsdiv$861 0448 GR + 7 A$_fsdiv$862 0449 GR + 7 A$_fsdiv$863 044B GR + 7 A$_fsdiv$864 044C GR + 7 A$_fsdiv$865 044E GR + 7 A$_fsdiv$866 0450 GR + 7 A$_fsdiv$867 0453 GR + 7 A$_fsdiv$868 0456 GR + 7 A$_fsdiv$87 0000 GR + 7 A$_fsdiv$871 0459 GR + 7 A$_fsdiv$872 045A GR + 7 A$_fsdiv$873 045C GR + 7 A$_fsdiv$874 045E GR + 7 A$_fsdiv$875 0460 GR + 7 A$_fsdiv$876 0462 GR + 7 A$_fsdiv$877 0464 GR + 7 A$_fsdiv$878 0466 GR + 7 A$_fsdiv$879 0468 GR + 7 A$_fsdiv$88 0002 GR + 7 A$_fsdiv$880 046A GR + 7 A$_fsdiv$881 046C GR + 7 A$_fsdiv$882 046E GR + 7 A$_fsdiv$883 0470 GR + 7 A$_fsdiv$884 0473 GR + 7 A$_fsdiv$885 0474 GR + 7 A$_fsdiv$886 0476 GR + 7 A$_fsdiv$887 0477 GR + 7 A$_fsdiv$888 0478 GR + 7 A$_fsdiv$889 047A GR + 7 A$_fsdiv$89 0004 GR + 7 A$_fsdiv$890 047B GR + 7 A$_fsdiv$891 047C GR + 7 A$_fsdiv$892 047E GR + 7 A$_fsdiv$893 047F GR + 7 A$_fsdiv$894 0480 GR + 7 A$_fsdiv$895 0482 GR + 7 A$_fsdiv$896 0484 GR + 7 A$_fsdiv$897 0486 GR + 7 A$_fsdiv$898 0488 GR + 7 A$_fsdiv$899 048A GR + 7 A$_fsdiv$90 0006 GR + 7 A$_fsdiv$900 048C GR + 7 A$_fsdiv$901 048E GR + 7 A$_fsdiv$902 0490 GR + 7 A$_fsdiv$903 0492 GR + 7 A$_fsdiv$904 0495 GR + 7 A$_fsdiv$905 0497 GR + 7 A$_fsdiv$906 0498 GR + 7 A$_fsdiv$907 0499 GR + 7 A$_fsdiv$908 049B GR + 7 A$_fsdiv$909 049C GR + 7 A$_fsdiv$91 0008 GR + 7 A$_fsdiv$910 049D GR + 7 A$_fsdiv$911 049F GR + 7 A$_fsdiv$912 04A0 GR + 7 A$_fsdiv$913 04A1 GR + 7 A$_fsdiv$914 04A3 GR + 7 A$_fsdiv$916 04A4 GR + 7 A$_fsdiv$917 04A7 GR + 7 A$_fsdiv$918 04A8 GR + 7 A$_fsdiv$919 04AA GR + 7 A$_fsdiv$92 000B GR + 7 A$_fsdiv$920 04AB GR + 7 A$_fsdiv$921 04AC GR + 7 A$_fsdiv$922 04AE GR + 7 A$_fsdiv$923 04AF GR + 7 A$_fsdiv$924 04B0 GR + 7 A$_fsdiv$925 04B2 GR + 7 A$_fsdiv$926 04B3 GR + 7 A$_fsdiv$928 04B4 GR + 7 A$_fsdiv$929 04B6 GR + 7 A$_fsdiv$93 000D GR + 7 A$_fsdiv$930 04B9 GR + 7 A$_fsdiv$931 04BC GR + 7 A$_fsdiv$935 04BF GR + 7 A$_fsdiv$94 000E GR + 7 A$_fsdiv$95 0010 GR + 7 A$_fsdiv$96 0011 GR + 7 A$_fsdiv$97 0012 GR + 7 A$_fsdiv$98 0014 GR + 7 A$_fsdiv$99 0015 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fsdiv.c$139$1$1 = 04BF GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fsdiv$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fsdiv$0$0 = 04BF GR + 7 ___fsdiv 0000 GR + 5 ___fsdiv_PARM_2 0000 GR + 5 ___fsdiv_a1_1_1 0004 R + 5 ___fsdiv_exp_1_1 0020 R + 5 ___fsdiv_fl1_1_1 0008 R + 5 ___fsdiv_fl2_1_1 000C R + 5 ___fsdiv_mant1_1_1 0018 R + 5 ___fsdiv_mant2_1_1 001C R + 5 ___fsdiv_mask_1_1 0014 R + 5 ___fsdiv_result_1_1 0010 R + 1 ___fsdiv_sloc0_1_0 0000 R + 1 ___fsdiv_sloc1_1_0 0001 R + 1 ___fsdiv_sloc2_1_0 0005 R + 1 ___fsdiv_sloc3_1_0 0009 R + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size D flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 22 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 4C0 flags 20 diff --git a/device/lib/_fseq.c b/device/lib/_fseq.c new file mode 100644 index 00000000..fd2e8fe7 --- /dev/null +++ b/device/lib/_fseq.c @@ -0,0 +1,88 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsgined long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int)0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* compare two floats */ +char +__fseq (float a1, float a2) +{ + volatile union float_long fl1, fl2; + + fl1.f = a1; + fl2.f = a2; + + if (SIGN (fl1.l) && SIGN (fl2.l)) + { + fl1.l ^= SIGNBIT; + fl2.l ^= SIGNBIT; + } + if (fl1.l == fl2.l) + return (1); + return (0); +} diff --git a/device/lib/_fseq.lst b/device/lib/_fseq.lst new file mode 100644 index 00000000..86db1a77 --- /dev/null +++ b/device/lib/_fseq.lst @@ -0,0 +1,282 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:27 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fseq + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fseq_PARM_2 + 11 .globl ___fseq + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 ___fseq_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 ___fseq_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 ___fseq_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 ___fseq_a1_1_1: + 0004 45 .ds 0x0004 + 0008 46 ___fseq_fl1_1_1: + 0008 47 .ds 0x0004 + 000C 48 ___fseq_fl2_1_1: + 000C 49 .ds 0x0004 + 50 ;-------------------------------------------------------- + 51 ; global & static initialisations + 52 ;-------------------------------------------------------- + 53 .area GSINIT (CODE) + 54 ;-------------------------------------------------------- + 55 ; code + 56 ;-------------------------------------------------------- + 57 .area CSEG (CODE) + 0000 58 G$__fseq$0$0 ==. + 59 ; _fseq.c 73 + 60 ; ----------------------------------------- + 61 ; function __fseq + 62 ; ----------------------------------------- + 0000 63 ___fseq: + 0002 64 ar2 = 0x02 + 0003 65 ar3 = 0x03 + 0004 66 ar4 = 0x04 + 0005 67 ar5 = 0x05 + 0006 68 ar6 = 0x06 + 0007 69 ar7 = 0x07 + 0000 70 ar0 = 0x00 + 0001 71 ar1 = 0x01 + 72 ; _fseq.c 87 + 0000 C0 E0 73 push acc + 0002 C0 F0 74 push b + 0004 C0 83 75 push dph + 0006 C0 82 76 push dpl + 0008 90s00r04 77 mov dptr,#___fseq_a1_1_1 + 000B D0 E0 78 pop acc + 000D F0 79 movx @dptr,a + 000E D0 E0 80 pop acc + 0010 A3 81 inc dptr + 0011 F0 82 movx @dptr,a + 0012 D0 E0 83 pop acc + 0014 A3 84 inc dptr + 0015 F0 85 movx @dptr,a + 0016 D0 E0 86 pop acc + 0018 A3 87 inc dptr + 0019 F0 88 movx @dptr,a + 89 ; _fseq.c 77 + 001A 90s00r04 90 mov dptr,#___fseq_a1_1_1 + 001D E0 91 movx a,@dptr + 001E FA 92 mov r2,a + 001F A3 93 inc dptr + 0020 E0 94 movx a,@dptr + 0021 FB 95 mov r3,a + 0022 A3 96 inc dptr + 0023 E0 97 movx a,@dptr + 0024 FC 98 mov r4,a + 0025 A3 99 inc dptr + 0026 E0 100 movx a,@dptr + 0027 FD 101 mov r5,a + 0028 90s00r08 102 mov dptr,#(___fseq_fl1_1_1) + 002B EA 103 mov a,r2 + 002C F0 104 movx @dptr,a + 002D A3 105 inc dptr + 002E EB 106 mov a,r3 + 002F F0 107 movx @dptr,a + 0030 A3 108 inc dptr + 0031 EC 109 mov a,r4 + 0032 F0 110 movx @dptr,a + 0033 A3 111 inc dptr + 0034 ED 112 mov a,r5 + 0035 F0 113 movx @dptr,a + 114 ; _fseq.c 78 + 0036 90s00r00 115 mov dptr,#___fseq_PARM_2 + 0039 E0 116 movx a,@dptr + 003A FA 117 mov r2,a + 003B A3 118 inc dptr + 003C E0 119 movx a,@dptr + 003D FB 120 mov r3,a + 003E A3 121 inc dptr + 003F E0 122 movx a,@dptr + 0040 FC 123 mov r4,a + 0041 A3 124 inc dptr + 0042 E0 125 movx a,@dptr + 0043 FD 126 mov r5,a + 0044 90s00r0C 127 mov dptr,#(___fseq_fl2_1_1) + 0047 EA 128 mov a,r2 + 0048 F0 129 movx @dptr,a + 0049 A3 130 inc dptr + 004A EB 131 mov a,r3 + 004B F0 132 movx @dptr,a + 004C A3 133 inc dptr + 004D EC 134 mov a,r4 + 004E F0 135 movx @dptr,a + 004F A3 136 inc dptr + 0050 ED 137 mov a,r5 + 0051 F0 138 movx @dptr,a + 139 ; _fseq.c 80 + 0052 90s00r08 140 mov dptr,#(___fseq_fl1_1_1) + 0055 E0 141 movx a,@dptr + 0056 FA 142 mov r2,a + 0057 A3 143 inc dptr + 0058 E0 144 movx a,@dptr + 0059 FB 145 mov r3,a + 005A A3 146 inc dptr + 005B E0 147 movx a,@dptr + 005C FC 148 mov r4,a + 005D A3 149 inc dptr + 005E E0 150 movx a,@dptr + 151 ; Peephole 105 removed redundant mov + 005F FD 152 mov r5,a + 0060 23 153 rl a + 0061 54 01 154 anl a,#0x01 + 155 ; Peephole 105 removed redundant mov + 0063 FA 156 mov r2,a + 0064 70 03 157 jnz 00111$ + 0066 02s00rCE 158 ljmp 00102$ + 0069 159 00111$: + 0069 90s00r0C 160 mov dptr,#(___fseq_fl2_1_1) + 006C E0 161 movx a,@dptr + 006D FA 162 mov r2,a + 006E A3 163 inc dptr + 006F E0 164 movx a,@dptr + 0070 FE 165 mov r6,a + 0071 A3 166 inc dptr + 0072 E0 167 movx a,@dptr + 0073 FF 168 mov r7,a + 0074 A3 169 inc dptr + 0075 E0 170 movx a,@dptr + 171 ; Peephole 105 removed redundant mov + 0076 F8 172 mov r0,a + 0077 23 173 rl a + 0078 54 01 174 anl a,#0x01 + 175 ; Peephole 105 removed redundant mov + 007A FA 176 mov r2,a + 007B 70 03 177 jnz 00112$ + 007D 02s00rCE 178 ljmp 00102$ + 0080 179 00112$: + 180 ; _fseq.c 82 + 0080 90s00r08 181 mov dptr,#(___fseq_fl1_1_1) + 0083 E0 182 movx a,@dptr + 0084 F5*00 183 mov ___fseq_sloc0_1_0,a + 0086 A3 184 inc dptr + 0087 E0 185 movx a,@dptr + 0088 F5*01 186 mov (___fseq_sloc0_1_0 + 1),a + 008A A3 187 inc dptr + 008B E0 188 movx a,@dptr + 008C F5*02 189 mov (___fseq_sloc0_1_0 + 2),a + 008E A3 190 inc dptr + 008F E0 191 movx a,@dptr + 0090 F5*03 192 mov (___fseq_sloc0_1_0 + 3),a + 0092 63r03 80 193 xrl (___fseq_sloc0_1_0 + 3),#0x80 + 0095 90s00r08 194 mov dptr,#(___fseq_fl1_1_1) + 0098 E5*00 195 mov a,___fseq_sloc0_1_0 + 009A F0 196 movx @dptr,a + 009B A3 197 inc dptr + 009C E5*01 198 mov a,(___fseq_sloc0_1_0 + 1) + 009E F0 199 movx @dptr,a + 009F A3 200 inc dptr + 00A0 E5*02 201 mov a,(___fseq_sloc0_1_0 + 2) + 00A2 F0 202 movx @dptr,a + 00A3 A3 203 inc dptr + 00A4 E5*03 204 mov a,(___fseq_sloc0_1_0 + 3) + 00A6 F0 205 movx @dptr,a + 206 ; _fseq.c 83 + 00A7 90s00r0C 207 mov dptr,#(___fseq_fl2_1_1) + 00AA E0 208 movx a,@dptr + 00AB F5*00 209 mov ___fseq_sloc0_1_0,a + 00AD A3 210 inc dptr + 00AE E0 211 movx a,@dptr + 00AF F5*01 212 mov (___fseq_sloc0_1_0 + 1),a + 00B1 A3 213 inc dptr + 00B2 E0 214 movx a,@dptr + 00B3 F5*02 215 mov (___fseq_sloc0_1_0 + 2),a + 00B5 A3 216 inc dptr + 00B6 E0 217 movx a,@dptr + 00B7 F5*03 218 mov (___fseq_sloc0_1_0 + 3),a + 00B9 63r03 80 219 xrl (___fseq_sloc0_1_0 + 3),#0x80 + 00BC 90s00r0C 220 mov dptr,#(___fseq_fl2_1_1) + 00BF E5*00 221 mov a,___fseq_sloc0_1_0 + 00C1 F0 222 movx @dptr,a + 00C2 A3 223 inc dptr + 00C3 E5*01 224 mov a,(___fseq_sloc0_1_0 + 1) + 00C5 F0 225 movx @dptr,a + 00C6 A3 226 inc dptr + 00C7 E5*02 227 mov a,(___fseq_sloc0_1_0 + 2) + 00C9 F0 228 movx @dptr,a + 00CA A3 229 inc dptr + 00CB E5*03 230 mov a,(___fseq_sloc0_1_0 + 3) + 00CD F0 231 movx @dptr,a + 00CE 232 00102$: + 233 ; _fseq.c 85 + 00CE 90s00r08 234 mov dptr,#(___fseq_fl1_1_1) + 00D1 E0 235 movx a,@dptr + 00D2 F5*00 236 mov ___fseq_sloc0_1_0,a + 00D4 A3 237 inc dptr + 00D5 E0 238 movx a,@dptr + 00D6 F5*01 239 mov (___fseq_sloc0_1_0 + 1),a + 00D8 A3 240 inc dptr + 00D9 E0 241 movx a,@dptr + 00DA F5*02 242 mov (___fseq_sloc0_1_0 + 2),a + 00DC A3 243 inc dptr + 00DD E0 244 movx a,@dptr + 00DE F5*03 245 mov (___fseq_sloc0_1_0 + 3),a + 00E0 90s00r0C 246 mov dptr,#(___fseq_fl2_1_1) + 00E3 E0 247 movx a,@dptr + 00E4 F5*04 248 mov ___fseq_sloc1_1_0,a + 00E6 A3 249 inc dptr + 00E7 E0 250 movx a,@dptr + 00E8 F5*05 251 mov (___fseq_sloc1_1_0 + 1),a + 00EA A3 252 inc dptr + 00EB E0 253 movx a,@dptr + 00EC F5*06 254 mov (___fseq_sloc1_1_0 + 2),a + 00EE A3 255 inc dptr + 00EF E0 256 movx a,@dptr + 00F0 F5*07 257 mov (___fseq_sloc1_1_0 + 3),a + 00F2 E5*00 258 mov a,___fseq_sloc0_1_0 + 259 ; Peephole 132 changed ljmp to sjmp + 260 ; Peephole 193 optimized misc jump sequence + 00F4 B5*04 14 261 cjne a,___fseq_sloc1_1_0,00105$ + 00F7 E5*01 262 mov a,(___fseq_sloc0_1_0 + 1) + 00F9 B5*05 0F 263 cjne a,(___fseq_sloc1_1_0 + 1),00105$ + 00FC E5*02 264 mov a,(___fseq_sloc0_1_0 + 2) + 00FE B5*06 0A 265 cjne a,(___fseq_sloc1_1_0 + 2),00105$ + 0101 E5*03 266 mov a,(___fseq_sloc0_1_0 + 3) + 0103 B5*07 05 267 cjne a,(___fseq_sloc1_1_0 + 3),00105$ + 268 ; Peephole 201 removed redundant sjmp + 0106 269 00113$: + 0106 270 00114$: + 271 ; _fseq.c 86 + 0106 75 82 01 272 mov dpl,#0x01 + 273 ; Peephole 132 changed ljmp to sjmp + 0109 80 03 274 sjmp 00106$ + 010B 275 00105$: + 276 ; _fseq.c 87 + 010B 75 82 00 277 mov dpl,#0x00 + 010E 278 00106$: + 010E 279 C$_fseq.c$88$1$1 ==. + 010E 280 XG$__fseq$0$0 ==. + 010E 22 281 ret + 282 .area CSEG (CODE) diff --git a/device/lib/_fseq.sym b/device/lib/_fseq.sym new file mode 100644 index 00000000..758e173c --- /dev/null +++ b/device/lib/_fseq.sym @@ -0,0 +1,555 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fseq$100 0026 GR + 7 A$_fseq$101 0027 GR + 7 A$_fseq$102 0028 GR + 7 A$_fseq$103 002B GR + 7 A$_fseq$104 002C GR + 7 A$_fseq$105 002D GR + 7 A$_fseq$106 002E GR + 7 A$_fseq$107 002F GR + 7 A$_fseq$108 0030 GR + 7 A$_fseq$109 0031 GR + 7 A$_fseq$110 0032 GR + 7 A$_fseq$111 0033 GR + 7 A$_fseq$112 0034 GR + 7 A$_fseq$113 0035 GR + 7 A$_fseq$115 0036 GR + 7 A$_fseq$116 0039 GR + 7 A$_fseq$117 003A GR + 7 A$_fseq$118 003B GR + 7 A$_fseq$119 003C GR + 7 A$_fseq$120 003D GR + 7 A$_fseq$121 003E GR + 7 A$_fseq$122 003F GR + 7 A$_fseq$123 0040 GR + 7 A$_fseq$124 0041 GR + 7 A$_fseq$125 0042 GR + 7 A$_fseq$126 0043 GR + 7 A$_fseq$127 0044 GR + 7 A$_fseq$128 0047 GR + 7 A$_fseq$129 0048 GR + 7 A$_fseq$130 0049 GR + 7 A$_fseq$131 004A GR + 7 A$_fseq$132 004B GR + 7 A$_fseq$133 004C GR + 7 A$_fseq$134 004D GR + 7 A$_fseq$135 004E GR + 7 A$_fseq$136 004F GR + 7 A$_fseq$137 0050 GR + 7 A$_fseq$138 0051 GR + 7 A$_fseq$140 0052 GR + 7 A$_fseq$141 0055 GR + 7 A$_fseq$142 0056 GR + 7 A$_fseq$143 0057 GR + 7 A$_fseq$144 0058 GR + 7 A$_fseq$145 0059 GR + 7 A$_fseq$146 005A GR + 7 A$_fseq$147 005B GR + 7 A$_fseq$148 005C GR + 7 A$_fseq$149 005D GR + 7 A$_fseq$150 005E GR + 7 A$_fseq$152 005F GR + 7 A$_fseq$153 0060 GR + 7 A$_fseq$154 0061 GR + 7 A$_fseq$156 0063 GR + 7 A$_fseq$157 0064 GR + 7 A$_fseq$158 0066 GR + 7 A$_fseq$160 0069 GR + 7 A$_fseq$161 006C GR + 7 A$_fseq$162 006D GR + 7 A$_fseq$163 006E GR + 7 A$_fseq$164 006F GR + 7 A$_fseq$165 0070 GR + 7 A$_fseq$166 0071 GR + 7 A$_fseq$167 0072 GR + 7 A$_fseq$168 0073 GR + 7 A$_fseq$169 0074 GR + 7 A$_fseq$170 0075 GR + 7 A$_fseq$172 0076 GR + 7 A$_fseq$173 0077 GR + 7 A$_fseq$174 0078 GR + 7 A$_fseq$176 007A GR + 7 A$_fseq$177 007B GR + 7 A$_fseq$178 007D GR + 7 A$_fseq$181 0080 GR + 7 A$_fseq$182 0083 GR + 7 A$_fseq$183 0084 GR + 7 A$_fseq$184 0086 GR + 7 A$_fseq$185 0087 GR + 7 A$_fseq$186 0088 GR + 7 A$_fseq$187 008A GR + 7 A$_fseq$188 008B GR + 7 A$_fseq$189 008C GR + 7 A$_fseq$190 008E GR + 7 A$_fseq$191 008F GR + 7 A$_fseq$192 0090 GR + 7 A$_fseq$193 0092 GR + 7 A$_fseq$194 0095 GR + 7 A$_fseq$195 0098 GR + 7 A$_fseq$196 009A GR + 7 A$_fseq$197 009B GR + 7 A$_fseq$198 009C GR + 7 A$_fseq$199 009E GR + 7 A$_fseq$200 009F GR + 7 A$_fseq$201 00A0 GR + 7 A$_fseq$202 00A2 GR + 7 A$_fseq$203 00A3 GR + 7 A$_fseq$204 00A4 GR + 7 A$_fseq$205 00A6 GR + 7 A$_fseq$207 00A7 GR + 7 A$_fseq$208 00AA GR + 7 A$_fseq$209 00AB GR + 7 A$_fseq$210 00AD GR + 7 A$_fseq$211 00AE GR + 7 A$_fseq$212 00AF GR + 7 A$_fseq$213 00B1 GR + 7 A$_fseq$214 00B2 GR + 7 A$_fseq$215 00B3 GR + 7 A$_fseq$216 00B5 GR + 7 A$_fseq$217 00B6 GR + 7 A$_fseq$218 00B7 GR + 7 A$_fseq$219 00B9 GR + 7 A$_fseq$220 00BC GR + 7 A$_fseq$221 00BF GR + 7 A$_fseq$222 00C1 GR + 7 A$_fseq$223 00C2 GR + 7 A$_fseq$224 00C3 GR + 7 A$_fseq$225 00C5 GR + 7 A$_fseq$226 00C6 GR + 7 A$_fseq$227 00C7 GR + 7 A$_fseq$228 00C9 GR + 7 A$_fseq$229 00CA GR + 7 A$_fseq$230 00CB GR + 7 A$_fseq$231 00CD GR + 7 A$_fseq$234 00CE GR + 7 A$_fseq$235 00D1 GR + 7 A$_fseq$236 00D2 GR + 7 A$_fseq$237 00D4 GR + 7 A$_fseq$238 00D5 GR + 7 A$_fseq$239 00D6 GR + 7 A$_fseq$240 00D8 GR + 7 A$_fseq$241 00D9 GR + 7 A$_fseq$242 00DA GR + 7 A$_fseq$243 00DC GR + 7 A$_fseq$244 00DD GR + 7 A$_fseq$245 00DE GR + 7 A$_fseq$246 00E0 GR + 7 A$_fseq$247 00E3 GR + 7 A$_fseq$248 00E4 GR + 7 A$_fseq$249 00E6 GR + 7 A$_fseq$250 00E7 GR + 7 A$_fseq$251 00E8 GR + 7 A$_fseq$252 00EA GR + 7 A$_fseq$253 00EB GR + 7 A$_fseq$254 00EC GR + 7 A$_fseq$255 00EE GR + 7 A$_fseq$256 00EF GR + 7 A$_fseq$257 00F0 GR + 7 A$_fseq$258 00F2 GR + 7 A$_fseq$261 00F4 GR + 7 A$_fseq$262 00F7 GR + 7 A$_fseq$263 00F9 GR + 7 A$_fseq$264 00FC GR + 7 A$_fseq$265 00FE GR + 7 A$_fseq$266 0101 GR + 7 A$_fseq$267 0103 GR + 7 A$_fseq$272 0106 GR + 7 A$_fseq$274 0109 GR + 7 A$_fseq$277 010B GR + 7 A$_fseq$281 010E GR + 7 A$_fseq$73 0000 GR + 7 A$_fseq$74 0002 GR + 7 A$_fseq$75 0004 GR + 7 A$_fseq$76 0006 GR + 7 A$_fseq$77 0008 GR + 7 A$_fseq$78 000B GR + 7 A$_fseq$79 000D GR + 7 A$_fseq$80 000E GR + 7 A$_fseq$81 0010 GR + 7 A$_fseq$82 0011 GR + 7 A$_fseq$83 0012 GR + 7 A$_fseq$84 0014 GR + 7 A$_fseq$85 0015 GR + 7 A$_fseq$86 0016 GR + 7 A$_fseq$87 0018 GR + 7 A$_fseq$88 0019 GR + 7 A$_fseq$90 001A GR + 7 A$_fseq$91 001D GR + 7 A$_fseq$92 001E GR + 7 A$_fseq$93 001F GR + 7 A$_fseq$94 0020 GR + 7 A$_fseq$95 0021 GR + 7 A$_fseq$96 0022 GR + 7 A$_fseq$97 0023 GR + 7 A$_fseq$98 0024 GR + 7 A$_fseq$99 0025 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fseq.c$88$1$1 = 010E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fseq$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fseq$0$0 = 010E GR + 7 ___fseq 0000 GR + 5 ___fseq_PARM_2 0000 GR + 5 ___fseq_a1_1_1 0004 R + 5 ___fseq_fl1_1_1 0008 R + 5 ___fseq_fl2_1_1 000C R + 1 ___fseq_sloc0_1_0 0000 R + 1 ___fseq_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 10 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 10F flags 20 diff --git a/device/lib/_fsgt.c b/device/lib/_fsgt.c new file mode 100644 index 00000000..106df0c0 --- /dev/null +++ b/device/lib/_fsgt.c @@ -0,0 +1,88 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* compare two floats */ +char +__fsgt (float a1, float a2) +{ + volatile union float_long fl1, fl2; + + fl1.f = a1; + fl2.f = a2; + + if (SIGN (fl1.l) && SIGN (fl2.l)) + { + fl1.l ^= SIGNBIT; + fl2.l ^= SIGNBIT; + } + if (fl1.l > fl2.l) + return (1); + return (0); +} diff --git a/device/lib/_fsgt.lst b/device/lib/_fsgt.lst new file mode 100644 index 00000000..52a90f37 --- /dev/null +++ b/device/lib/_fsgt.lst @@ -0,0 +1,284 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:27 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fsgt + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fsgt_PARM_2 + 11 .globl ___fsgt + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 ___fsgt_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 ___fsgt_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 ___fsgt_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 ___fsgt_a1_1_1: + 0004 45 .ds 0x0004 + 0008 46 ___fsgt_fl1_1_1: + 0008 47 .ds 0x0004 + 000C 48 ___fsgt_fl2_1_1: + 000C 49 .ds 0x0004 + 50 ;-------------------------------------------------------- + 51 ; global & static initialisations + 52 ;-------------------------------------------------------- + 53 .area GSINIT (CODE) + 54 ;-------------------------------------------------------- + 55 ; code + 56 ;-------------------------------------------------------- + 57 .area CSEG (CODE) + 0000 58 G$__fsgt$0$0 ==. + 59 ; _fsgt.c 73 + 60 ; ----------------------------------------- + 61 ; function __fsgt + 62 ; ----------------------------------------- + 0000 63 ___fsgt: + 0002 64 ar2 = 0x02 + 0003 65 ar3 = 0x03 + 0004 66 ar4 = 0x04 + 0005 67 ar5 = 0x05 + 0006 68 ar6 = 0x06 + 0007 69 ar7 = 0x07 + 0000 70 ar0 = 0x00 + 0001 71 ar1 = 0x01 + 72 ; _fsgt.c 87 + 0000 C0 E0 73 push acc + 0002 C0 F0 74 push b + 0004 C0 83 75 push dph + 0006 C0 82 76 push dpl + 0008 90s00r04 77 mov dptr,#___fsgt_a1_1_1 + 000B D0 E0 78 pop acc + 000D F0 79 movx @dptr,a + 000E D0 E0 80 pop acc + 0010 A3 81 inc dptr + 0011 F0 82 movx @dptr,a + 0012 D0 E0 83 pop acc + 0014 A3 84 inc dptr + 0015 F0 85 movx @dptr,a + 0016 D0 E0 86 pop acc + 0018 A3 87 inc dptr + 0019 F0 88 movx @dptr,a + 89 ; _fsgt.c 77 + 001A 90s00r04 90 mov dptr,#___fsgt_a1_1_1 + 001D E0 91 movx a,@dptr + 001E FA 92 mov r2,a + 001F A3 93 inc dptr + 0020 E0 94 movx a,@dptr + 0021 FB 95 mov r3,a + 0022 A3 96 inc dptr + 0023 E0 97 movx a,@dptr + 0024 FC 98 mov r4,a + 0025 A3 99 inc dptr + 0026 E0 100 movx a,@dptr + 0027 FD 101 mov r5,a + 0028 90s00r08 102 mov dptr,#(___fsgt_fl1_1_1) + 002B EA 103 mov a,r2 + 002C F0 104 movx @dptr,a + 002D A3 105 inc dptr + 002E EB 106 mov a,r3 + 002F F0 107 movx @dptr,a + 0030 A3 108 inc dptr + 0031 EC 109 mov a,r4 + 0032 F0 110 movx @dptr,a + 0033 A3 111 inc dptr + 0034 ED 112 mov a,r5 + 0035 F0 113 movx @dptr,a + 114 ; _fsgt.c 78 + 0036 90s00r00 115 mov dptr,#___fsgt_PARM_2 + 0039 E0 116 movx a,@dptr + 003A FA 117 mov r2,a + 003B A3 118 inc dptr + 003C E0 119 movx a,@dptr + 003D FB 120 mov r3,a + 003E A3 121 inc dptr + 003F E0 122 movx a,@dptr + 0040 FC 123 mov r4,a + 0041 A3 124 inc dptr + 0042 E0 125 movx a,@dptr + 0043 FD 126 mov r5,a + 0044 90s00r0C 127 mov dptr,#(___fsgt_fl2_1_1) + 0047 EA 128 mov a,r2 + 0048 F0 129 movx @dptr,a + 0049 A3 130 inc dptr + 004A EB 131 mov a,r3 + 004B F0 132 movx @dptr,a + 004C A3 133 inc dptr + 004D EC 134 mov a,r4 + 004E F0 135 movx @dptr,a + 004F A3 136 inc dptr + 0050 ED 137 mov a,r5 + 0051 F0 138 movx @dptr,a + 139 ; _fsgt.c 80 + 0052 90s00r08 140 mov dptr,#(___fsgt_fl1_1_1) + 0055 E0 141 movx a,@dptr + 0056 FA 142 mov r2,a + 0057 A3 143 inc dptr + 0058 E0 144 movx a,@dptr + 0059 FB 145 mov r3,a + 005A A3 146 inc dptr + 005B E0 147 movx a,@dptr + 005C FC 148 mov r4,a + 005D A3 149 inc dptr + 005E E0 150 movx a,@dptr + 151 ; Peephole 105 removed redundant mov + 005F FD 152 mov r5,a + 0060 23 153 rl a + 0061 54 01 154 anl a,#0x01 + 155 ; Peephole 105 removed redundant mov + 0063 FA 156 mov r2,a + 0064 70 03 157 jnz 00111$ + 0066 02s00rCE 158 ljmp 00102$ + 0069 159 00111$: + 0069 90s00r0C 160 mov dptr,#(___fsgt_fl2_1_1) + 006C E0 161 movx a,@dptr + 006D FA 162 mov r2,a + 006E A3 163 inc dptr + 006F E0 164 movx a,@dptr + 0070 FE 165 mov r6,a + 0071 A3 166 inc dptr + 0072 E0 167 movx a,@dptr + 0073 FF 168 mov r7,a + 0074 A3 169 inc dptr + 0075 E0 170 movx a,@dptr + 171 ; Peephole 105 removed redundant mov + 0076 F8 172 mov r0,a + 0077 23 173 rl a + 0078 54 01 174 anl a,#0x01 + 175 ; Peephole 105 removed redundant mov + 007A FA 176 mov r2,a + 007B 70 03 177 jnz 00112$ + 007D 02s00rCE 178 ljmp 00102$ + 0080 179 00112$: + 180 ; _fsgt.c 82 + 0080 90s00r08 181 mov dptr,#(___fsgt_fl1_1_1) + 0083 E0 182 movx a,@dptr + 0084 F5*00 183 mov ___fsgt_sloc0_1_0,a + 0086 A3 184 inc dptr + 0087 E0 185 movx a,@dptr + 0088 F5*01 186 mov (___fsgt_sloc0_1_0 + 1),a + 008A A3 187 inc dptr + 008B E0 188 movx a,@dptr + 008C F5*02 189 mov (___fsgt_sloc0_1_0 + 2),a + 008E A3 190 inc dptr + 008F E0 191 movx a,@dptr + 0090 F5*03 192 mov (___fsgt_sloc0_1_0 + 3),a + 0092 63r03 80 193 xrl (___fsgt_sloc0_1_0 + 3),#0x80 + 0095 90s00r08 194 mov dptr,#(___fsgt_fl1_1_1) + 0098 E5*00 195 mov a,___fsgt_sloc0_1_0 + 009A F0 196 movx @dptr,a + 009B A3 197 inc dptr + 009C E5*01 198 mov a,(___fsgt_sloc0_1_0 + 1) + 009E F0 199 movx @dptr,a + 009F A3 200 inc dptr + 00A0 E5*02 201 mov a,(___fsgt_sloc0_1_0 + 2) + 00A2 F0 202 movx @dptr,a + 00A3 A3 203 inc dptr + 00A4 E5*03 204 mov a,(___fsgt_sloc0_1_0 + 3) + 00A6 F0 205 movx @dptr,a + 206 ; _fsgt.c 83 + 00A7 90s00r0C 207 mov dptr,#(___fsgt_fl2_1_1) + 00AA E0 208 movx a,@dptr + 00AB F5*00 209 mov ___fsgt_sloc0_1_0,a + 00AD A3 210 inc dptr + 00AE E0 211 movx a,@dptr + 00AF F5*01 212 mov (___fsgt_sloc0_1_0 + 1),a + 00B1 A3 213 inc dptr + 00B2 E0 214 movx a,@dptr + 00B3 F5*02 215 mov (___fsgt_sloc0_1_0 + 2),a + 00B5 A3 216 inc dptr + 00B6 E0 217 movx a,@dptr + 00B7 F5*03 218 mov (___fsgt_sloc0_1_0 + 3),a + 00B9 63r03 80 219 xrl (___fsgt_sloc0_1_0 + 3),#0x80 + 00BC 90s00r0C 220 mov dptr,#(___fsgt_fl2_1_1) + 00BF E5*00 221 mov a,___fsgt_sloc0_1_0 + 00C1 F0 222 movx @dptr,a + 00C2 A3 223 inc dptr + 00C3 E5*01 224 mov a,(___fsgt_sloc0_1_0 + 1) + 00C5 F0 225 movx @dptr,a + 00C6 A3 226 inc dptr + 00C7 E5*02 227 mov a,(___fsgt_sloc0_1_0 + 2) + 00C9 F0 228 movx @dptr,a + 00CA A3 229 inc dptr + 00CB E5*03 230 mov a,(___fsgt_sloc0_1_0 + 3) + 00CD F0 231 movx @dptr,a + 00CE 232 00102$: + 233 ; _fsgt.c 85 + 00CE 90s00r08 234 mov dptr,#(___fsgt_fl1_1_1) + 00D1 E0 235 movx a,@dptr + 00D2 F5*00 236 mov ___fsgt_sloc0_1_0,a + 00D4 A3 237 inc dptr + 00D5 E0 238 movx a,@dptr + 00D6 F5*01 239 mov (___fsgt_sloc0_1_0 + 1),a + 00D8 A3 240 inc dptr + 00D9 E0 241 movx a,@dptr + 00DA F5*02 242 mov (___fsgt_sloc0_1_0 + 2),a + 00DC A3 243 inc dptr + 00DD E0 244 movx a,@dptr + 00DE F5*03 245 mov (___fsgt_sloc0_1_0 + 3),a + 00E0 90s00r0C 246 mov dptr,#(___fsgt_fl2_1_1) + 00E3 E0 247 movx a,@dptr + 00E4 F5*04 248 mov ___fsgt_sloc1_1_0,a + 00E6 A3 249 inc dptr + 00E7 E0 250 movx a,@dptr + 00E8 F5*05 251 mov (___fsgt_sloc1_1_0 + 1),a + 00EA A3 252 inc dptr + 00EB E0 253 movx a,@dptr + 00EC F5*06 254 mov (___fsgt_sloc1_1_0 + 2),a + 00EE A3 255 inc dptr + 00EF E0 256 movx a,@dptr + 00F0 F5*07 257 mov (___fsgt_sloc1_1_0 + 3),a + 00F2 C3 258 clr c + 00F3 E5*04 259 mov a,___fsgt_sloc1_1_0 + 00F5 95*00 260 subb a,___fsgt_sloc0_1_0 + 00F7 E5*05 261 mov a,(___fsgt_sloc1_1_0 + 1) + 00F9 95*01 262 subb a,(___fsgt_sloc0_1_0 + 1) + 00FB E5*06 263 mov a,(___fsgt_sloc1_1_0 + 2) + 00FD 95*02 264 subb a,(___fsgt_sloc0_1_0 + 2) + 00FF E5*07 265 mov a,(___fsgt_sloc1_1_0 + 3) + 0101 64 80 266 xrl a,#0x80 + 0103 85*03 F0 267 mov b,(___fsgt_sloc0_1_0 + 3) + 0106 63 F0 80 268 xrl b,#0x80 + 0109 95 F0 269 subb a,b + 270 ; Peephole 108 removed ljmp by inverse jump logic + 010B 50 05 271 jnc 00105$ + 010D 272 00113$: + 273 ; _fsgt.c 86 + 010D 75 82 01 274 mov dpl,#0x01 + 275 ; Peephole 132 changed ljmp to sjmp + 0110 80 03 276 sjmp 00106$ + 0112 277 00105$: + 278 ; _fsgt.c 87 + 0112 75 82 00 279 mov dpl,#0x00 + 0115 280 00106$: + 0115 281 C$_fsgt.c$88$1$1 ==. + 0115 282 XG$__fsgt$0$0 ==. + 0115 22 283 ret + 284 .area CSEG (CODE) diff --git a/device/lib/_fsgt.sym b/device/lib/_fsgt.sym new file mode 100644 index 00000000..ffc29cce --- /dev/null +++ b/device/lib/_fsgt.sym @@ -0,0 +1,560 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fsgt$100 0026 GR + 7 A$_fsgt$101 0027 GR + 7 A$_fsgt$102 0028 GR + 7 A$_fsgt$103 002B GR + 7 A$_fsgt$104 002C GR + 7 A$_fsgt$105 002D GR + 7 A$_fsgt$106 002E GR + 7 A$_fsgt$107 002F GR + 7 A$_fsgt$108 0030 GR + 7 A$_fsgt$109 0031 GR + 7 A$_fsgt$110 0032 GR + 7 A$_fsgt$111 0033 GR + 7 A$_fsgt$112 0034 GR + 7 A$_fsgt$113 0035 GR + 7 A$_fsgt$115 0036 GR + 7 A$_fsgt$116 0039 GR + 7 A$_fsgt$117 003A GR + 7 A$_fsgt$118 003B GR + 7 A$_fsgt$119 003C GR + 7 A$_fsgt$120 003D GR + 7 A$_fsgt$121 003E GR + 7 A$_fsgt$122 003F GR + 7 A$_fsgt$123 0040 GR + 7 A$_fsgt$124 0041 GR + 7 A$_fsgt$125 0042 GR + 7 A$_fsgt$126 0043 GR + 7 A$_fsgt$127 0044 GR + 7 A$_fsgt$128 0047 GR + 7 A$_fsgt$129 0048 GR + 7 A$_fsgt$130 0049 GR + 7 A$_fsgt$131 004A GR + 7 A$_fsgt$132 004B GR + 7 A$_fsgt$133 004C GR + 7 A$_fsgt$134 004D GR + 7 A$_fsgt$135 004E GR + 7 A$_fsgt$136 004F GR + 7 A$_fsgt$137 0050 GR + 7 A$_fsgt$138 0051 GR + 7 A$_fsgt$140 0052 GR + 7 A$_fsgt$141 0055 GR + 7 A$_fsgt$142 0056 GR + 7 A$_fsgt$143 0057 GR + 7 A$_fsgt$144 0058 GR + 7 A$_fsgt$145 0059 GR + 7 A$_fsgt$146 005A GR + 7 A$_fsgt$147 005B GR + 7 A$_fsgt$148 005C GR + 7 A$_fsgt$149 005D GR + 7 A$_fsgt$150 005E GR + 7 A$_fsgt$152 005F GR + 7 A$_fsgt$153 0060 GR + 7 A$_fsgt$154 0061 GR + 7 A$_fsgt$156 0063 GR + 7 A$_fsgt$157 0064 GR + 7 A$_fsgt$158 0066 GR + 7 A$_fsgt$160 0069 GR + 7 A$_fsgt$161 006C GR + 7 A$_fsgt$162 006D GR + 7 A$_fsgt$163 006E GR + 7 A$_fsgt$164 006F GR + 7 A$_fsgt$165 0070 GR + 7 A$_fsgt$166 0071 GR + 7 A$_fsgt$167 0072 GR + 7 A$_fsgt$168 0073 GR + 7 A$_fsgt$169 0074 GR + 7 A$_fsgt$170 0075 GR + 7 A$_fsgt$172 0076 GR + 7 A$_fsgt$173 0077 GR + 7 A$_fsgt$174 0078 GR + 7 A$_fsgt$176 007A GR + 7 A$_fsgt$177 007B GR + 7 A$_fsgt$178 007D GR + 7 A$_fsgt$181 0080 GR + 7 A$_fsgt$182 0083 GR + 7 A$_fsgt$183 0084 GR + 7 A$_fsgt$184 0086 GR + 7 A$_fsgt$185 0087 GR + 7 A$_fsgt$186 0088 GR + 7 A$_fsgt$187 008A GR + 7 A$_fsgt$188 008B GR + 7 A$_fsgt$189 008C GR + 7 A$_fsgt$190 008E GR + 7 A$_fsgt$191 008F GR + 7 A$_fsgt$192 0090 GR + 7 A$_fsgt$193 0092 GR + 7 A$_fsgt$194 0095 GR + 7 A$_fsgt$195 0098 GR + 7 A$_fsgt$196 009A GR + 7 A$_fsgt$197 009B GR + 7 A$_fsgt$198 009C GR + 7 A$_fsgt$199 009E GR + 7 A$_fsgt$200 009F GR + 7 A$_fsgt$201 00A0 GR + 7 A$_fsgt$202 00A2 GR + 7 A$_fsgt$203 00A3 GR + 7 A$_fsgt$204 00A4 GR + 7 A$_fsgt$205 00A6 GR + 7 A$_fsgt$207 00A7 GR + 7 A$_fsgt$208 00AA GR + 7 A$_fsgt$209 00AB GR + 7 A$_fsgt$210 00AD GR + 7 A$_fsgt$211 00AE GR + 7 A$_fsgt$212 00AF GR + 7 A$_fsgt$213 00B1 GR + 7 A$_fsgt$214 00B2 GR + 7 A$_fsgt$215 00B3 GR + 7 A$_fsgt$216 00B5 GR + 7 A$_fsgt$217 00B6 GR + 7 A$_fsgt$218 00B7 GR + 7 A$_fsgt$219 00B9 GR + 7 A$_fsgt$220 00BC GR + 7 A$_fsgt$221 00BF GR + 7 A$_fsgt$222 00C1 GR + 7 A$_fsgt$223 00C2 GR + 7 A$_fsgt$224 00C3 GR + 7 A$_fsgt$225 00C5 GR + 7 A$_fsgt$226 00C6 GR + 7 A$_fsgt$227 00C7 GR + 7 A$_fsgt$228 00C9 GR + 7 A$_fsgt$229 00CA GR + 7 A$_fsgt$230 00CB GR + 7 A$_fsgt$231 00CD GR + 7 A$_fsgt$234 00CE GR + 7 A$_fsgt$235 00D1 GR + 7 A$_fsgt$236 00D2 GR + 7 A$_fsgt$237 00D4 GR + 7 A$_fsgt$238 00D5 GR + 7 A$_fsgt$239 00D6 GR + 7 A$_fsgt$240 00D8 GR + 7 A$_fsgt$241 00D9 GR + 7 A$_fsgt$242 00DA GR + 7 A$_fsgt$243 00DC GR + 7 A$_fsgt$244 00DD GR + 7 A$_fsgt$245 00DE GR + 7 A$_fsgt$246 00E0 GR + 7 A$_fsgt$247 00E3 GR + 7 A$_fsgt$248 00E4 GR + 7 A$_fsgt$249 00E6 GR + 7 A$_fsgt$250 00E7 GR + 7 A$_fsgt$251 00E8 GR + 7 A$_fsgt$252 00EA GR + 7 A$_fsgt$253 00EB GR + 7 A$_fsgt$254 00EC GR + 7 A$_fsgt$255 00EE GR + 7 A$_fsgt$256 00EF GR + 7 A$_fsgt$257 00F0 GR + 7 A$_fsgt$258 00F2 GR + 7 A$_fsgt$259 00F3 GR + 7 A$_fsgt$260 00F5 GR + 7 A$_fsgt$261 00F7 GR + 7 A$_fsgt$262 00F9 GR + 7 A$_fsgt$263 00FB GR + 7 A$_fsgt$264 00FD GR + 7 A$_fsgt$265 00FF GR + 7 A$_fsgt$266 0101 GR + 7 A$_fsgt$267 0103 GR + 7 A$_fsgt$268 0106 GR + 7 A$_fsgt$269 0109 GR + 7 A$_fsgt$271 010B GR + 7 A$_fsgt$274 010D GR + 7 A$_fsgt$276 0110 GR + 7 A$_fsgt$279 0112 GR + 7 A$_fsgt$283 0115 GR + 7 A$_fsgt$73 0000 GR + 7 A$_fsgt$74 0002 GR + 7 A$_fsgt$75 0004 GR + 7 A$_fsgt$76 0006 GR + 7 A$_fsgt$77 0008 GR + 7 A$_fsgt$78 000B GR + 7 A$_fsgt$79 000D GR + 7 A$_fsgt$80 000E GR + 7 A$_fsgt$81 0010 GR + 7 A$_fsgt$82 0011 GR + 7 A$_fsgt$83 0012 GR + 7 A$_fsgt$84 0014 GR + 7 A$_fsgt$85 0015 GR + 7 A$_fsgt$86 0016 GR + 7 A$_fsgt$87 0018 GR + 7 A$_fsgt$88 0019 GR + 7 A$_fsgt$90 001A GR + 7 A$_fsgt$91 001D GR + 7 A$_fsgt$92 001E GR + 7 A$_fsgt$93 001F GR + 7 A$_fsgt$94 0020 GR + 7 A$_fsgt$95 0021 GR + 7 A$_fsgt$96 0022 GR + 7 A$_fsgt$97 0023 GR + 7 A$_fsgt$98 0024 GR + 7 A$_fsgt$99 0025 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fsgt.c$88$1$1 = 0115 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fsgt$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fsgt$0$0 = 0115 GR + 7 ___fsgt 0000 GR + 5 ___fsgt_PARM_2 0000 GR + 5 ___fsgt_a1_1_1 0004 R + 5 ___fsgt_fl1_1_1 0008 R + 5 ___fsgt_fl2_1_1 000C R + 1 ___fsgt_sloc0_1_0 0000 R + 1 ___fsgt_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 10 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 116 flags 20 diff --git a/device/lib/_fslt.c b/device/lib/_fslt.c new file mode 100644 index 00000000..e22a5ead --- /dev/null +++ b/device/lib/_fslt.c @@ -0,0 +1,88 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsgined long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int)0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* compare two floats */ +char +__fslt (float a1, float a2) +{ + volatile union float_long fl1, fl2; + + fl1.f = a1; + fl2.f = a2; + + if (SIGN (fl1.l) && SIGN (fl2.l)) + { + fl1.l ^= SIGNBIT; + fl2.l ^= SIGNBIT; + } + if (fl1.l < fl2.l) + return (1); + return (0); +} diff --git a/device/lib/_fslt.lst b/device/lib/_fslt.lst new file mode 100644 index 00000000..6016b098 --- /dev/null +++ b/device/lib/_fslt.lst @@ -0,0 +1,284 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:27 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fslt + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fslt_PARM_2 + 11 .globl ___fslt + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 ___fslt_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 ___fslt_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 ___fslt_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 ___fslt_a1_1_1: + 0004 45 .ds 0x0004 + 0008 46 ___fslt_fl1_1_1: + 0008 47 .ds 0x0004 + 000C 48 ___fslt_fl2_1_1: + 000C 49 .ds 0x0004 + 50 ;-------------------------------------------------------- + 51 ; global & static initialisations + 52 ;-------------------------------------------------------- + 53 .area GSINIT (CODE) + 54 ;-------------------------------------------------------- + 55 ; code + 56 ;-------------------------------------------------------- + 57 .area CSEG (CODE) + 0000 58 G$__fslt$0$0 ==. + 59 ; _fslt.c 73 + 60 ; ----------------------------------------- + 61 ; function __fslt + 62 ; ----------------------------------------- + 0000 63 ___fslt: + 0002 64 ar2 = 0x02 + 0003 65 ar3 = 0x03 + 0004 66 ar4 = 0x04 + 0005 67 ar5 = 0x05 + 0006 68 ar6 = 0x06 + 0007 69 ar7 = 0x07 + 0000 70 ar0 = 0x00 + 0001 71 ar1 = 0x01 + 72 ; _fslt.c 87 + 0000 C0 E0 73 push acc + 0002 C0 F0 74 push b + 0004 C0 83 75 push dph + 0006 C0 82 76 push dpl + 0008 90s00r04 77 mov dptr,#___fslt_a1_1_1 + 000B D0 E0 78 pop acc + 000D F0 79 movx @dptr,a + 000E D0 E0 80 pop acc + 0010 A3 81 inc dptr + 0011 F0 82 movx @dptr,a + 0012 D0 E0 83 pop acc + 0014 A3 84 inc dptr + 0015 F0 85 movx @dptr,a + 0016 D0 E0 86 pop acc + 0018 A3 87 inc dptr + 0019 F0 88 movx @dptr,a + 89 ; _fslt.c 77 + 001A 90s00r04 90 mov dptr,#___fslt_a1_1_1 + 001D E0 91 movx a,@dptr + 001E FA 92 mov r2,a + 001F A3 93 inc dptr + 0020 E0 94 movx a,@dptr + 0021 FB 95 mov r3,a + 0022 A3 96 inc dptr + 0023 E0 97 movx a,@dptr + 0024 FC 98 mov r4,a + 0025 A3 99 inc dptr + 0026 E0 100 movx a,@dptr + 0027 FD 101 mov r5,a + 0028 90s00r08 102 mov dptr,#(___fslt_fl1_1_1) + 002B EA 103 mov a,r2 + 002C F0 104 movx @dptr,a + 002D A3 105 inc dptr + 002E EB 106 mov a,r3 + 002F F0 107 movx @dptr,a + 0030 A3 108 inc dptr + 0031 EC 109 mov a,r4 + 0032 F0 110 movx @dptr,a + 0033 A3 111 inc dptr + 0034 ED 112 mov a,r5 + 0035 F0 113 movx @dptr,a + 114 ; _fslt.c 78 + 0036 90s00r00 115 mov dptr,#___fslt_PARM_2 + 0039 E0 116 movx a,@dptr + 003A FA 117 mov r2,a + 003B A3 118 inc dptr + 003C E0 119 movx a,@dptr + 003D FB 120 mov r3,a + 003E A3 121 inc dptr + 003F E0 122 movx a,@dptr + 0040 FC 123 mov r4,a + 0041 A3 124 inc dptr + 0042 E0 125 movx a,@dptr + 0043 FD 126 mov r5,a + 0044 90s00r0C 127 mov dptr,#(___fslt_fl2_1_1) + 0047 EA 128 mov a,r2 + 0048 F0 129 movx @dptr,a + 0049 A3 130 inc dptr + 004A EB 131 mov a,r3 + 004B F0 132 movx @dptr,a + 004C A3 133 inc dptr + 004D EC 134 mov a,r4 + 004E F0 135 movx @dptr,a + 004F A3 136 inc dptr + 0050 ED 137 mov a,r5 + 0051 F0 138 movx @dptr,a + 139 ; _fslt.c 80 + 0052 90s00r08 140 mov dptr,#(___fslt_fl1_1_1) + 0055 E0 141 movx a,@dptr + 0056 FA 142 mov r2,a + 0057 A3 143 inc dptr + 0058 E0 144 movx a,@dptr + 0059 FB 145 mov r3,a + 005A A3 146 inc dptr + 005B E0 147 movx a,@dptr + 005C FC 148 mov r4,a + 005D A3 149 inc dptr + 005E E0 150 movx a,@dptr + 151 ; Peephole 105 removed redundant mov + 005F FD 152 mov r5,a + 0060 23 153 rl a + 0061 54 01 154 anl a,#0x01 + 155 ; Peephole 105 removed redundant mov + 0063 FA 156 mov r2,a + 0064 70 03 157 jnz 00111$ + 0066 02s00rCE 158 ljmp 00102$ + 0069 159 00111$: + 0069 90s00r0C 160 mov dptr,#(___fslt_fl2_1_1) + 006C E0 161 movx a,@dptr + 006D FA 162 mov r2,a + 006E A3 163 inc dptr + 006F E0 164 movx a,@dptr + 0070 FE 165 mov r6,a + 0071 A3 166 inc dptr + 0072 E0 167 movx a,@dptr + 0073 FF 168 mov r7,a + 0074 A3 169 inc dptr + 0075 E0 170 movx a,@dptr + 171 ; Peephole 105 removed redundant mov + 0076 F8 172 mov r0,a + 0077 23 173 rl a + 0078 54 01 174 anl a,#0x01 + 175 ; Peephole 105 removed redundant mov + 007A FA 176 mov r2,a + 007B 70 03 177 jnz 00112$ + 007D 02s00rCE 178 ljmp 00102$ + 0080 179 00112$: + 180 ; _fslt.c 82 + 0080 90s00r08 181 mov dptr,#(___fslt_fl1_1_1) + 0083 E0 182 movx a,@dptr + 0084 F5*00 183 mov ___fslt_sloc0_1_0,a + 0086 A3 184 inc dptr + 0087 E0 185 movx a,@dptr + 0088 F5*01 186 mov (___fslt_sloc0_1_0 + 1),a + 008A A3 187 inc dptr + 008B E0 188 movx a,@dptr + 008C F5*02 189 mov (___fslt_sloc0_1_0 + 2),a + 008E A3 190 inc dptr + 008F E0 191 movx a,@dptr + 0090 F5*03 192 mov (___fslt_sloc0_1_0 + 3),a + 0092 63r03 80 193 xrl (___fslt_sloc0_1_0 + 3),#0x80 + 0095 90s00r08 194 mov dptr,#(___fslt_fl1_1_1) + 0098 E5*00 195 mov a,___fslt_sloc0_1_0 + 009A F0 196 movx @dptr,a + 009B A3 197 inc dptr + 009C E5*01 198 mov a,(___fslt_sloc0_1_0 + 1) + 009E F0 199 movx @dptr,a + 009F A3 200 inc dptr + 00A0 E5*02 201 mov a,(___fslt_sloc0_1_0 + 2) + 00A2 F0 202 movx @dptr,a + 00A3 A3 203 inc dptr + 00A4 E5*03 204 mov a,(___fslt_sloc0_1_0 + 3) + 00A6 F0 205 movx @dptr,a + 206 ; _fslt.c 83 + 00A7 90s00r0C 207 mov dptr,#(___fslt_fl2_1_1) + 00AA E0 208 movx a,@dptr + 00AB F5*00 209 mov ___fslt_sloc0_1_0,a + 00AD A3 210 inc dptr + 00AE E0 211 movx a,@dptr + 00AF F5*01 212 mov (___fslt_sloc0_1_0 + 1),a + 00B1 A3 213 inc dptr + 00B2 E0 214 movx a,@dptr + 00B3 F5*02 215 mov (___fslt_sloc0_1_0 + 2),a + 00B5 A3 216 inc dptr + 00B6 E0 217 movx a,@dptr + 00B7 F5*03 218 mov (___fslt_sloc0_1_0 + 3),a + 00B9 63r03 80 219 xrl (___fslt_sloc0_1_0 + 3),#0x80 + 00BC 90s00r0C 220 mov dptr,#(___fslt_fl2_1_1) + 00BF E5*00 221 mov a,___fslt_sloc0_1_0 + 00C1 F0 222 movx @dptr,a + 00C2 A3 223 inc dptr + 00C3 E5*01 224 mov a,(___fslt_sloc0_1_0 + 1) + 00C5 F0 225 movx @dptr,a + 00C6 A3 226 inc dptr + 00C7 E5*02 227 mov a,(___fslt_sloc0_1_0 + 2) + 00C9 F0 228 movx @dptr,a + 00CA A3 229 inc dptr + 00CB E5*03 230 mov a,(___fslt_sloc0_1_0 + 3) + 00CD F0 231 movx @dptr,a + 00CE 232 00102$: + 233 ; _fslt.c 85 + 00CE 90s00r08 234 mov dptr,#(___fslt_fl1_1_1) + 00D1 E0 235 movx a,@dptr + 00D2 F5*00 236 mov ___fslt_sloc0_1_0,a + 00D4 A3 237 inc dptr + 00D5 E0 238 movx a,@dptr + 00D6 F5*01 239 mov (___fslt_sloc0_1_0 + 1),a + 00D8 A3 240 inc dptr + 00D9 E0 241 movx a,@dptr + 00DA F5*02 242 mov (___fslt_sloc0_1_0 + 2),a + 00DC A3 243 inc dptr + 00DD E0 244 movx a,@dptr + 00DE F5*03 245 mov (___fslt_sloc0_1_0 + 3),a + 00E0 90s00r0C 246 mov dptr,#(___fslt_fl2_1_1) + 00E3 E0 247 movx a,@dptr + 00E4 F5*04 248 mov ___fslt_sloc1_1_0,a + 00E6 A3 249 inc dptr + 00E7 E0 250 movx a,@dptr + 00E8 F5*05 251 mov (___fslt_sloc1_1_0 + 1),a + 00EA A3 252 inc dptr + 00EB E0 253 movx a,@dptr + 00EC F5*06 254 mov (___fslt_sloc1_1_0 + 2),a + 00EE A3 255 inc dptr + 00EF E0 256 movx a,@dptr + 00F0 F5*07 257 mov (___fslt_sloc1_1_0 + 3),a + 00F2 C3 258 clr c + 00F3 E5*00 259 mov a,___fslt_sloc0_1_0 + 00F5 95*04 260 subb a,___fslt_sloc1_1_0 + 00F7 E5*01 261 mov a,(___fslt_sloc0_1_0 + 1) + 00F9 95*05 262 subb a,(___fslt_sloc1_1_0 + 1) + 00FB E5*02 263 mov a,(___fslt_sloc0_1_0 + 2) + 00FD 95*06 264 subb a,(___fslt_sloc1_1_0 + 2) + 00FF E5*03 265 mov a,(___fslt_sloc0_1_0 + 3) + 0101 64 80 266 xrl a,#0x80 + 0103 85*07 F0 267 mov b,(___fslt_sloc1_1_0 + 3) + 0106 63 F0 80 268 xrl b,#0x80 + 0109 95 F0 269 subb a,b + 270 ; Peephole 108 removed ljmp by inverse jump logic + 010B 50 05 271 jnc 00105$ + 010D 272 00113$: + 273 ; _fslt.c 86 + 010D 75 82 01 274 mov dpl,#0x01 + 275 ; Peephole 132 changed ljmp to sjmp + 0110 80 03 276 sjmp 00106$ + 0112 277 00105$: + 278 ; _fslt.c 87 + 0112 75 82 00 279 mov dpl,#0x00 + 0115 280 00106$: + 0115 281 C$_fslt.c$88$1$1 ==. + 0115 282 XG$__fslt$0$0 ==. + 0115 22 283 ret + 284 .area CSEG (CODE) diff --git a/device/lib/_fslt.sym b/device/lib/_fslt.sym new file mode 100644 index 00000000..60c539a6 --- /dev/null +++ b/device/lib/_fslt.sym @@ -0,0 +1,560 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fslt$100 0026 GR + 7 A$_fslt$101 0027 GR + 7 A$_fslt$102 0028 GR + 7 A$_fslt$103 002B GR + 7 A$_fslt$104 002C GR + 7 A$_fslt$105 002D GR + 7 A$_fslt$106 002E GR + 7 A$_fslt$107 002F GR + 7 A$_fslt$108 0030 GR + 7 A$_fslt$109 0031 GR + 7 A$_fslt$110 0032 GR + 7 A$_fslt$111 0033 GR + 7 A$_fslt$112 0034 GR + 7 A$_fslt$113 0035 GR + 7 A$_fslt$115 0036 GR + 7 A$_fslt$116 0039 GR + 7 A$_fslt$117 003A GR + 7 A$_fslt$118 003B GR + 7 A$_fslt$119 003C GR + 7 A$_fslt$120 003D GR + 7 A$_fslt$121 003E GR + 7 A$_fslt$122 003F GR + 7 A$_fslt$123 0040 GR + 7 A$_fslt$124 0041 GR + 7 A$_fslt$125 0042 GR + 7 A$_fslt$126 0043 GR + 7 A$_fslt$127 0044 GR + 7 A$_fslt$128 0047 GR + 7 A$_fslt$129 0048 GR + 7 A$_fslt$130 0049 GR + 7 A$_fslt$131 004A GR + 7 A$_fslt$132 004B GR + 7 A$_fslt$133 004C GR + 7 A$_fslt$134 004D GR + 7 A$_fslt$135 004E GR + 7 A$_fslt$136 004F GR + 7 A$_fslt$137 0050 GR + 7 A$_fslt$138 0051 GR + 7 A$_fslt$140 0052 GR + 7 A$_fslt$141 0055 GR + 7 A$_fslt$142 0056 GR + 7 A$_fslt$143 0057 GR + 7 A$_fslt$144 0058 GR + 7 A$_fslt$145 0059 GR + 7 A$_fslt$146 005A GR + 7 A$_fslt$147 005B GR + 7 A$_fslt$148 005C GR + 7 A$_fslt$149 005D GR + 7 A$_fslt$150 005E GR + 7 A$_fslt$152 005F GR + 7 A$_fslt$153 0060 GR + 7 A$_fslt$154 0061 GR + 7 A$_fslt$156 0063 GR + 7 A$_fslt$157 0064 GR + 7 A$_fslt$158 0066 GR + 7 A$_fslt$160 0069 GR + 7 A$_fslt$161 006C GR + 7 A$_fslt$162 006D GR + 7 A$_fslt$163 006E GR + 7 A$_fslt$164 006F GR + 7 A$_fslt$165 0070 GR + 7 A$_fslt$166 0071 GR + 7 A$_fslt$167 0072 GR + 7 A$_fslt$168 0073 GR + 7 A$_fslt$169 0074 GR + 7 A$_fslt$170 0075 GR + 7 A$_fslt$172 0076 GR + 7 A$_fslt$173 0077 GR + 7 A$_fslt$174 0078 GR + 7 A$_fslt$176 007A GR + 7 A$_fslt$177 007B GR + 7 A$_fslt$178 007D GR + 7 A$_fslt$181 0080 GR + 7 A$_fslt$182 0083 GR + 7 A$_fslt$183 0084 GR + 7 A$_fslt$184 0086 GR + 7 A$_fslt$185 0087 GR + 7 A$_fslt$186 0088 GR + 7 A$_fslt$187 008A GR + 7 A$_fslt$188 008B GR + 7 A$_fslt$189 008C GR + 7 A$_fslt$190 008E GR + 7 A$_fslt$191 008F GR + 7 A$_fslt$192 0090 GR + 7 A$_fslt$193 0092 GR + 7 A$_fslt$194 0095 GR + 7 A$_fslt$195 0098 GR + 7 A$_fslt$196 009A GR + 7 A$_fslt$197 009B GR + 7 A$_fslt$198 009C GR + 7 A$_fslt$199 009E GR + 7 A$_fslt$200 009F GR + 7 A$_fslt$201 00A0 GR + 7 A$_fslt$202 00A2 GR + 7 A$_fslt$203 00A3 GR + 7 A$_fslt$204 00A4 GR + 7 A$_fslt$205 00A6 GR + 7 A$_fslt$207 00A7 GR + 7 A$_fslt$208 00AA GR + 7 A$_fslt$209 00AB GR + 7 A$_fslt$210 00AD GR + 7 A$_fslt$211 00AE GR + 7 A$_fslt$212 00AF GR + 7 A$_fslt$213 00B1 GR + 7 A$_fslt$214 00B2 GR + 7 A$_fslt$215 00B3 GR + 7 A$_fslt$216 00B5 GR + 7 A$_fslt$217 00B6 GR + 7 A$_fslt$218 00B7 GR + 7 A$_fslt$219 00B9 GR + 7 A$_fslt$220 00BC GR + 7 A$_fslt$221 00BF GR + 7 A$_fslt$222 00C1 GR + 7 A$_fslt$223 00C2 GR + 7 A$_fslt$224 00C3 GR + 7 A$_fslt$225 00C5 GR + 7 A$_fslt$226 00C6 GR + 7 A$_fslt$227 00C7 GR + 7 A$_fslt$228 00C9 GR + 7 A$_fslt$229 00CA GR + 7 A$_fslt$230 00CB GR + 7 A$_fslt$231 00CD GR + 7 A$_fslt$234 00CE GR + 7 A$_fslt$235 00D1 GR + 7 A$_fslt$236 00D2 GR + 7 A$_fslt$237 00D4 GR + 7 A$_fslt$238 00D5 GR + 7 A$_fslt$239 00D6 GR + 7 A$_fslt$240 00D8 GR + 7 A$_fslt$241 00D9 GR + 7 A$_fslt$242 00DA GR + 7 A$_fslt$243 00DC GR + 7 A$_fslt$244 00DD GR + 7 A$_fslt$245 00DE GR + 7 A$_fslt$246 00E0 GR + 7 A$_fslt$247 00E3 GR + 7 A$_fslt$248 00E4 GR + 7 A$_fslt$249 00E6 GR + 7 A$_fslt$250 00E7 GR + 7 A$_fslt$251 00E8 GR + 7 A$_fslt$252 00EA GR + 7 A$_fslt$253 00EB GR + 7 A$_fslt$254 00EC GR + 7 A$_fslt$255 00EE GR + 7 A$_fslt$256 00EF GR + 7 A$_fslt$257 00F0 GR + 7 A$_fslt$258 00F2 GR + 7 A$_fslt$259 00F3 GR + 7 A$_fslt$260 00F5 GR + 7 A$_fslt$261 00F7 GR + 7 A$_fslt$262 00F9 GR + 7 A$_fslt$263 00FB GR + 7 A$_fslt$264 00FD GR + 7 A$_fslt$265 00FF GR + 7 A$_fslt$266 0101 GR + 7 A$_fslt$267 0103 GR + 7 A$_fslt$268 0106 GR + 7 A$_fslt$269 0109 GR + 7 A$_fslt$271 010B GR + 7 A$_fslt$274 010D GR + 7 A$_fslt$276 0110 GR + 7 A$_fslt$279 0112 GR + 7 A$_fslt$283 0115 GR + 7 A$_fslt$73 0000 GR + 7 A$_fslt$74 0002 GR + 7 A$_fslt$75 0004 GR + 7 A$_fslt$76 0006 GR + 7 A$_fslt$77 0008 GR + 7 A$_fslt$78 000B GR + 7 A$_fslt$79 000D GR + 7 A$_fslt$80 000E GR + 7 A$_fslt$81 0010 GR + 7 A$_fslt$82 0011 GR + 7 A$_fslt$83 0012 GR + 7 A$_fslt$84 0014 GR + 7 A$_fslt$85 0015 GR + 7 A$_fslt$86 0016 GR + 7 A$_fslt$87 0018 GR + 7 A$_fslt$88 0019 GR + 7 A$_fslt$90 001A GR + 7 A$_fslt$91 001D GR + 7 A$_fslt$92 001E GR + 7 A$_fslt$93 001F GR + 7 A$_fslt$94 0020 GR + 7 A$_fslt$95 0021 GR + 7 A$_fslt$96 0022 GR + 7 A$_fslt$97 0023 GR + 7 A$_fslt$98 0024 GR + 7 A$_fslt$99 0025 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fslt.c$88$1$1 = 0115 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fslt$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fslt$0$0 = 0115 GR + 7 ___fslt 0000 GR + 5 ___fslt_PARM_2 0000 GR + 5 ___fslt_a1_1_1 0004 R + 5 ___fslt_fl1_1_1 0008 R + 5 ___fslt_fl2_1_1 000C R + 1 ___fslt_sloc0_1_0 0000 R + 1 ___fslt_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 10 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 116 flags 20 diff --git a/device/lib/_fsmul.c b/device/lib/_fsmul.c new file mode 100644 index 00000000..48c92ed5 --- /dev/null +++ b/device/lib/_fsmul.c @@ -0,0 +1,126 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +/* multiply two floats */ +float +__fsmul (float a1, float a2) +{ + volatile union float_long fl1, fl2; + volatile unsigned long result; + volatile int exp; + short sign; + + fl1.f = a1; + fl2.f = a2; + + if (!fl1.l || !fl2.l) + return (0); + + /* compute sign and exponent */ + sign = SIGN (fl1.l) ^ SIGN (fl2.l); + exp = EXP (fl1.l) - EXCESS; + exp += EXP (fl2.l); + + fl1.l = MANT (fl1.l); + fl2.l = MANT (fl2.l); + + /* the multiply is done as one 16x16 multiply and two 16x8 multiples */ + result = (fl1.l >> 8) * (fl2.l >> 8); + result += ((fl1.l & (unsigned long) 0xFF) * (fl2.l >> 8)) >> 8; + result += ((fl2.l & (unsigned long) 0xFF) * (fl1.l >> 8)) >> 8; + + if (result & (unsigned long)0x80000000) + { + /* round */ + result += 0x80; + result >>= 8; + } + else + { + /* round */ + result += 0x40; + result >>= 7; + exp--; + } + + result &= ~HIDDEN; + + /* pack up and go home */ + fl1.l = PACK (sign ? ((unsigned long) 0x80000000) : 0 , (unsigned long)exp, result); + return (fl1.f); +} diff --git a/device/lib/_fsmul.lst b/device/lib/_fsmul.lst new file mode 100644 index 00000000..9b19bc6c --- /dev/null +++ b/device/lib/_fsmul.lst @@ -0,0 +1,936 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fsmul + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fsmul_PARM_2 + 11 .globl ___fsmul + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 ___fsmul_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 ___fsmul_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 ___fsmul_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 ___fsmul_a1_1_1: + 0004 45 .ds 0x0004 + 0008 46 ___fsmul_fl1_1_1: + 0008 47 .ds 0x0004 + 000C 48 ___fsmul_fl2_1_1: + 000C 49 .ds 0x0004 + 0010 50 ___fsmul_result_1_1: + 0010 51 .ds 0x0004 + 0014 52 ___fsmul_exp_1_1: + 0014 53 .ds 0x0002 + 0016 54 ___fsmul_sign_1_1: + 0016 55 .ds 0x0001 + 56 ;-------------------------------------------------------- + 57 ; global & static initialisations + 58 ;-------------------------------------------------------- + 59 .area GSINIT (CODE) + 60 ;-------------------------------------------------------- + 61 ; code + 62 ;-------------------------------------------------------- + 63 .area CSEG (CODE) + 0000 64 G$__fsmul$0$0 ==. + 65 ; _fsmul.c 81 + 66 ; ----------------------------------------- + 67 ; function __fsmul + 68 ; ----------------------------------------- + 0000 69 ___fsmul: + 0002 70 ar2 = 0x02 + 0003 71 ar3 = 0x03 + 0004 72 ar4 = 0x04 + 0005 73 ar5 = 0x05 + 0006 74 ar6 = 0x06 + 0007 75 ar7 = 0x07 + 0000 76 ar0 = 0x00 + 0001 77 ar1 = 0x01 + 78 ; _fsmul.c 125 + 0000 C0 E0 79 push acc + 0002 C0 F0 80 push b + 0004 C0 83 81 push dph + 0006 C0 82 82 push dpl + 0008 90s00r04 83 mov dptr,#___fsmul_a1_1_1 + 000B D0 E0 84 pop acc + 000D F0 85 movx @dptr,a + 000E D0 E0 86 pop acc + 0010 A3 87 inc dptr + 0011 F0 88 movx @dptr,a + 0012 D0 E0 89 pop acc + 0014 A3 90 inc dptr + 0015 F0 91 movx @dptr,a + 0016 D0 E0 92 pop acc + 0018 A3 93 inc dptr + 0019 F0 94 movx @dptr,a + 95 ; _fsmul.c 88 + 001A 90s00r04 96 mov dptr,#___fsmul_a1_1_1 + 001D E0 97 movx a,@dptr + 001E FA 98 mov r2,a + 001F A3 99 inc dptr + 0020 E0 100 movx a,@dptr + 0021 FB 101 mov r3,a + 0022 A3 102 inc dptr + 0023 E0 103 movx a,@dptr + 0024 FC 104 mov r4,a + 0025 A3 105 inc dptr + 0026 E0 106 movx a,@dptr + 0027 FD 107 mov r5,a + 0028 90s00r08 108 mov dptr,#(___fsmul_fl1_1_1) + 002B EA 109 mov a,r2 + 002C F0 110 movx @dptr,a + 002D A3 111 inc dptr + 002E EB 112 mov a,r3 + 002F F0 113 movx @dptr,a + 0030 A3 114 inc dptr + 0031 EC 115 mov a,r4 + 0032 F0 116 movx @dptr,a + 0033 A3 117 inc dptr + 0034 ED 118 mov a,r5 + 0035 F0 119 movx @dptr,a + 120 ; _fsmul.c 89 + 0036 90s00r00 121 mov dptr,#___fsmul_PARM_2 + 0039 E0 122 movx a,@dptr + 003A FA 123 mov r2,a + 003B A3 124 inc dptr + 003C E0 125 movx a,@dptr + 003D FB 126 mov r3,a + 003E A3 127 inc dptr + 003F E0 128 movx a,@dptr + 0040 FC 129 mov r4,a + 0041 A3 130 inc dptr + 0042 E0 131 movx a,@dptr + 0043 FD 132 mov r5,a + 0044 90s00r0C 133 mov dptr,#(___fsmul_fl2_1_1) + 0047 EA 134 mov a,r2 + 0048 F0 135 movx @dptr,a + 0049 A3 136 inc dptr + 004A EB 137 mov a,r3 + 004B F0 138 movx @dptr,a + 004C A3 139 inc dptr + 004D EC 140 mov a,r4 + 004E F0 141 movx @dptr,a + 004F A3 142 inc dptr + 0050 ED 143 mov a,r5 + 0051 F0 144 movx @dptr,a + 145 ; _fsmul.c 91 + 0052 90s00r08 146 mov dptr,#(___fsmul_fl1_1_1) + 0055 E0 147 movx a,@dptr + 0056 FA 148 mov r2,a + 0057 A3 149 inc dptr + 0058 E0 150 movx a,@dptr + 0059 FB 151 mov r3,a + 005A A3 152 inc dptr + 005B E0 153 movx a,@dptr + 005C FC 154 mov r4,a + 005D A3 155 inc dptr + 005E E0 156 movx a,@dptr + 005F FD 157 mov r5,a + 0060 EA 158 mov a,r2 + 0061 4B 159 orl a,r3 + 0062 4C 160 orl a,r4 + 0063 4D 161 orl a,r5 + 162 ; Peephole 110 removed ljmp by inverse jump logic + 0064 60 14 163 jz 00101$ + 0066 164 00114$: + 0066 90s00r0C 165 mov dptr,#(___fsmul_fl2_1_1) + 0069 E0 166 movx a,@dptr + 006A FA 167 mov r2,a + 006B A3 168 inc dptr + 006C E0 169 movx a,@dptr + 006D FB 170 mov r3,a + 006E A3 171 inc dptr + 006F E0 172 movx a,@dptr + 0070 FC 173 mov r4,a + 0071 A3 174 inc dptr + 0072 E0 175 movx a,@dptr + 0073 FD 176 mov r5,a + 0074 EA 177 mov a,r2 + 0075 4B 178 orl a,r3 + 0076 4C 179 orl a,r4 + 0077 4D 180 orl a,r5 + 181 ; Peephole 109 removed ljmp by inverse jump logic + 0078 70 0A 182 jnz 00102$ + 007A 183 00115$: + 007A 184 00101$: + 185 ; _fsmul.c 92 + 186 ; Peephole 3.a changed mov to clr + 187 ; Peephole 3.b changed mov to clr + 188 ; Peephole 3.b changed mov to clr + 007A E4 189 clr a + 007B F5 82 190 mov dpl,a + 007D F5 83 191 mov dph,a + 007F F5 F0 192 mov b,a + 0081 02s05r25 193 ljmp 00107$ + 0084 194 00102$: + 195 ; _fsmul.c 95 + 0084 90s00r08 196 mov dptr,#(___fsmul_fl1_1_1) + 0087 E0 197 movx a,@dptr + 0088 FA 198 mov r2,a + 0089 A3 199 inc dptr + 008A E0 200 movx a,@dptr + 008B FB 201 mov r3,a + 008C A3 202 inc dptr + 008D E0 203 movx a,@dptr + 008E FC 204 mov r4,a + 008F A3 205 inc dptr + 0090 E0 206 movx a,@dptr + 207 ; Peephole 105 removed redundant mov + 0091 FD 208 mov r5,a + 0092 23 209 rl a + 0093 54 01 210 anl a,#0x01 + 0095 FA 211 mov r2,a + 0096 90s00r0C 212 mov dptr,#(___fsmul_fl2_1_1) + 0099 E0 213 movx a,@dptr + 009A FE 214 mov r6,a + 009B A3 215 inc dptr + 009C E0 216 movx a,@dptr + 009D FF 217 mov r7,a + 009E A3 218 inc dptr + 009F E0 219 movx a,@dptr + 00A0 F8 220 mov r0,a + 00A1 A3 221 inc dptr + 00A2 E0 222 movx a,@dptr + 223 ; Peephole 105 removed redundant mov + 00A3 F9 224 mov r1,a + 00A4 23 225 rl a + 00A5 54 01 226 anl a,#0x01 + 00A7 FE 227 mov r6,a + 00A8 90s00r16 228 mov dptr,#___fsmul_sign_1_1 + 00AB EE 229 mov a,r6 + 00AC 65 02 230 xrl a,ar2 + 00AE F0 231 movx @dptr,a + 232 ; _fsmul.c 96 + 00AF 90s00r08 233 mov dptr,#(___fsmul_fl1_1_1) + 00B2 E0 234 movx a,@dptr + 00B3 F5*00 235 mov ___fsmul_sloc0_1_0,a + 00B5 A3 236 inc dptr + 00B6 E0 237 movx a,@dptr + 00B7 F5*01 238 mov (___fsmul_sloc0_1_0 + 1),a + 00B9 A3 239 inc dptr + 00BA E0 240 movx a,@dptr + 00BB F5*02 241 mov (___fsmul_sloc0_1_0 + 2),a + 00BD A3 242 inc dptr + 00BE E0 243 movx a,@dptr + 00BF F5*03 244 mov (___fsmul_sloc0_1_0 + 3),a + 00C1 85*02*00 245 mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 2) + 00C4 E5*03 246 mov a,(___fsmul_sloc0_1_0 + 3) + 00C6 A2 E7 247 mov c,acc.7 + 00C8 C5*00 248 xch a,___fsmul_sloc0_1_0 + 00CA 33 249 rlc a + 00CB C5*00 250 xch a,___fsmul_sloc0_1_0 + 00CD 33 251 rlc a + 00CE C5*00 252 xch a,___fsmul_sloc0_1_0 + 00D0 54 01 253 anl a,#0x01 + 00D2 30 E0 02 254 jnb acc.0,00116$ + 00D5 44 FE 255 orl a,#0xfe + 00D7 256 00116$: + 00D7 F5*01 257 mov (___fsmul_sloc0_1_0 + 1),a + 00D9 33 258 rlc a + 00DA 95 E0 259 subb a,acc + 00DC F5*02 260 mov (___fsmul_sloc0_1_0 + 2),a + 00DE F5*03 261 mov (___fsmul_sloc0_1_0 + 3),a + 00E0 AA*00 262 mov r2,___fsmul_sloc0_1_0 + 00E2 AE*01 263 mov r6,(___fsmul_sloc0_1_0 + 1) + 00E4 EA 264 mov a,r2 + 00E5 75 F0 00 265 mov b,#0x00 + 00E8 24 82 266 add a,#0x82 + 00EA FA 267 mov r2,a + 00EB E5 F0 268 mov a,b + 00ED 34 FF 269 addc a,#0xff + 00EF FE 270 mov r6,a + 00F0 90s00r14 271 mov dptr,#___fsmul_exp_1_1 + 00F3 EA 272 mov a,r2 + 00F4 F0 273 movx @dptr,a + 00F5 A3 274 inc dptr + 00F6 EE 275 mov a,r6 + 00F7 F0 276 movx @dptr,a + 277 ; _fsmul.c 97 + 00F8 90s00r0C 278 mov dptr,#(___fsmul_fl2_1_1) + 00FB E0 279 movx a,@dptr + 00FC F5*00 280 mov ___fsmul_sloc0_1_0,a + 00FE A3 281 inc dptr + 00FF E0 282 movx a,@dptr + 0100 F5*01 283 mov (___fsmul_sloc0_1_0 + 1),a + 0102 A3 284 inc dptr + 0103 E0 285 movx a,@dptr + 0104 F5*02 286 mov (___fsmul_sloc0_1_0 + 2),a + 0106 A3 287 inc dptr + 0107 E0 288 movx a,@dptr + 0108 F5*03 289 mov (___fsmul_sloc0_1_0 + 3),a + 010A 85*02*00 290 mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 2) + 010D E5*03 291 mov a,(___fsmul_sloc0_1_0 + 3) + 010F A2 E7 292 mov c,acc.7 + 0111 C5*00 293 xch a,___fsmul_sloc0_1_0 + 0113 33 294 rlc a + 0114 C5*00 295 xch a,___fsmul_sloc0_1_0 + 0116 33 296 rlc a + 0117 C5*00 297 xch a,___fsmul_sloc0_1_0 + 0119 54 01 298 anl a,#0x01 + 011B 30 E0 02 299 jnb acc.0,00117$ + 011E 44 FE 300 orl a,#0xfe + 0120 301 00117$: + 0120 F5*01 302 mov (___fsmul_sloc0_1_0 + 1),a + 0122 33 303 rlc a + 0123 95 E0 304 subb a,acc + 0125 F5*02 305 mov (___fsmul_sloc0_1_0 + 2),a + 0127 F5*03 306 mov (___fsmul_sloc0_1_0 + 3),a + 0129 AA*00 307 mov r2,___fsmul_sloc0_1_0 + 012B AE*01 308 mov r6,(___fsmul_sloc0_1_0 + 1) + 012D 8A*00 309 mov ___fsmul_sloc0_1_0,r2 + 012F 75*01 00 310 mov (___fsmul_sloc0_1_0 + 1),#0x00 + 0132 90s00r14 311 mov dptr,#___fsmul_exp_1_1 + 0135 E0 312 movx a,@dptr + 0136 FA 313 mov r2,a + 0137 A3 314 inc dptr + 0138 E0 315 movx a,@dptr + 0139 FE 316 mov r6,a + 013A 90s00r14 317 mov dptr,#___fsmul_exp_1_1 + 013D E5*00 318 mov a,___fsmul_sloc0_1_0 + 013F 2A 319 add a,r2 + 0140 F0 320 movx @dptr,a + 0141 E5*01 321 mov a,(___fsmul_sloc0_1_0 + 1) + 0143 3E 322 addc a,r6 + 0144 A3 323 inc dptr + 0145 F0 324 movx @dptr,a + 325 ; _fsmul.c 99 + 0146 90s00r08 326 mov dptr,#(___fsmul_fl1_1_1) + 0149 E0 327 movx a,@dptr + 014A F5*00 328 mov ___fsmul_sloc0_1_0,a + 014C A3 329 inc dptr + 014D E0 330 movx a,@dptr + 014E F5*01 331 mov (___fsmul_sloc0_1_0 + 1),a + 0150 A3 332 inc dptr + 0151 E0 333 movx a,@dptr + 0152 F5*02 334 mov (___fsmul_sloc0_1_0 + 2),a + 0154 A3 335 inc dptr + 0155 E0 336 movx a,@dptr + 0156 F5*03 337 mov (___fsmul_sloc0_1_0 + 3),a + 0158 53r02 7F 338 anl (___fsmul_sloc0_1_0 + 2),#0x7f + 015B 75*03 00 339 mov (___fsmul_sloc0_1_0 + 3),#0x00 + 015E 43r02 80 340 orl (___fsmul_sloc0_1_0 + 2),#0x80 + 0161 90s00r08 341 mov dptr,#(___fsmul_fl1_1_1) + 0164 E5*00 342 mov a,___fsmul_sloc0_1_0 + 0166 F0 343 movx @dptr,a + 0167 A3 344 inc dptr + 0168 E5*01 345 mov a,(___fsmul_sloc0_1_0 + 1) + 016A F0 346 movx @dptr,a + 016B A3 347 inc dptr + 016C E5*02 348 mov a,(___fsmul_sloc0_1_0 + 2) + 016E F0 349 movx @dptr,a + 016F A3 350 inc dptr + 0170 E5*03 351 mov a,(___fsmul_sloc0_1_0 + 3) + 0172 F0 352 movx @dptr,a + 353 ; _fsmul.c 100 + 0173 90s00r0C 354 mov dptr,#(___fsmul_fl2_1_1) + 0176 E0 355 movx a,@dptr + 0177 F5*00 356 mov ___fsmul_sloc0_1_0,a + 0179 A3 357 inc dptr + 017A E0 358 movx a,@dptr + 017B F5*01 359 mov (___fsmul_sloc0_1_0 + 1),a + 017D A3 360 inc dptr + 017E E0 361 movx a,@dptr + 017F F5*02 362 mov (___fsmul_sloc0_1_0 + 2),a + 0181 A3 363 inc dptr + 0182 E0 364 movx a,@dptr + 0183 F5*03 365 mov (___fsmul_sloc0_1_0 + 3),a + 0185 53r02 7F 366 anl (___fsmul_sloc0_1_0 + 2),#0x7f + 0188 75*03 00 367 mov (___fsmul_sloc0_1_0 + 3),#0x00 + 018B 43r02 80 368 orl (___fsmul_sloc0_1_0 + 2),#0x80 + 018E 90s00r0C 369 mov dptr,#(___fsmul_fl2_1_1) + 0191 E5*00 370 mov a,___fsmul_sloc0_1_0 + 0193 F0 371 movx @dptr,a + 0194 A3 372 inc dptr + 0195 E5*01 373 mov a,(___fsmul_sloc0_1_0 + 1) + 0197 F0 374 movx @dptr,a + 0198 A3 375 inc dptr + 0199 E5*02 376 mov a,(___fsmul_sloc0_1_0 + 2) + 019B F0 377 movx @dptr,a + 019C A3 378 inc dptr + 019D E5*03 379 mov a,(___fsmul_sloc0_1_0 + 3) + 019F F0 380 movx @dptr,a + 381 ; _fsmul.c 103 + 01A0 90s00r08 382 mov dptr,#(___fsmul_fl1_1_1) + 01A3 E0 383 movx a,@dptr + 01A4 F5*00 384 mov ___fsmul_sloc0_1_0,a + 01A6 A3 385 inc dptr + 01A7 E0 386 movx a,@dptr + 01A8 F5*01 387 mov (___fsmul_sloc0_1_0 + 1),a + 01AA A3 388 inc dptr + 01AB E0 389 movx a,@dptr + 01AC F5*02 390 mov (___fsmul_sloc0_1_0 + 2),a + 01AE A3 391 inc dptr + 01AF E0 392 movx a,@dptr + 01B0 F5*03 393 mov (___fsmul_sloc0_1_0 + 3),a + 01B2 85*01*00 394 mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 1) + 01B5 85*02*01 395 mov (___fsmul_sloc0_1_0 + 1),(___fsmul_sloc0_1_0 + 2) + 01B8 E5*03 396 mov a,(___fsmul_sloc0_1_0 + 3) + 01BA F5*02 397 mov (___fsmul_sloc0_1_0 + 2),a + 01BC 33 398 rlc a + 01BD 95 E0 399 subb a,acc + 01BF F5*03 400 mov (___fsmul_sloc0_1_0 + 3),a + 01C1 90s00r0C 401 mov dptr,#(___fsmul_fl2_1_1) + 01C4 E0 402 movx a,@dptr + 01C5 F5*04 403 mov ___fsmul_sloc1_1_0,a + 01C7 A3 404 inc dptr + 01C8 E0 405 movx a,@dptr + 01C9 F5*05 406 mov (___fsmul_sloc1_1_0 + 1),a + 01CB A3 407 inc dptr + 01CC E0 408 movx a,@dptr + 01CD F5*06 409 mov (___fsmul_sloc1_1_0 + 2),a + 01CF A3 410 inc dptr + 01D0 E0 411 movx a,@dptr + 01D1 F5*07 412 mov (___fsmul_sloc1_1_0 + 3),a + 01D3 85*05*04 413 mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + 01D6 85*06*05 414 mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + 01D9 E5*07 415 mov a,(___fsmul_sloc1_1_0 + 3) + 01DB F5*06 416 mov (___fsmul_sloc1_1_0 + 2),a + 01DD 33 417 rlc a + 01DE 95 E0 418 subb a,acc + 01E0 F5*07 419 mov (___fsmul_sloc1_1_0 + 3),a + 01E2 90s00r00 420 mov dptr,#__mulslong_PARM_2 + 01E5 E5*04 421 mov a,___fsmul_sloc1_1_0 + 01E7 F0 422 movx @dptr,a + 01E8 A3 423 inc dptr + 01E9 E5*05 424 mov a,(___fsmul_sloc1_1_0 + 1) + 01EB F0 425 movx @dptr,a + 01EC A3 426 inc dptr + 01ED E5*06 427 mov a,(___fsmul_sloc1_1_0 + 2) + 01EF F0 428 movx @dptr,a + 01F0 A3 429 inc dptr + 01F1 E5*07 430 mov a,(___fsmul_sloc1_1_0 + 3) + 01F3 F0 431 movx @dptr,a + 01F4 85*00 82 432 mov dpl,___fsmul_sloc0_1_0 + 01F7 85*01 83 433 mov dph,(___fsmul_sloc0_1_0 + 1) + 01FA 85*02 F0 434 mov b,(___fsmul_sloc0_1_0 + 2) + 01FD E5*03 435 mov a,(___fsmul_sloc0_1_0 + 3) + 01FF 12s00r00 436 lcall __mulslong + 0202 85 82*04 437 mov ___fsmul_sloc1_1_0,dpl + 0205 85 83*05 438 mov (___fsmul_sloc1_1_0 + 1),dph + 0208 85 F0*06 439 mov (___fsmul_sloc1_1_0 + 2),b + 020B F5*07 440 mov (___fsmul_sloc1_1_0 + 3),a + 020D 90s00r10 441 mov dptr,#___fsmul_result_1_1 + 0210 E5*04 442 mov a,___fsmul_sloc1_1_0 + 0212 F0 443 movx @dptr,a + 0213 A3 444 inc dptr + 0214 E5*05 445 mov a,(___fsmul_sloc1_1_0 + 1) + 0216 F0 446 movx @dptr,a + 0217 A3 447 inc dptr + 0218 E5*06 448 mov a,(___fsmul_sloc1_1_0 + 2) + 021A F0 449 movx @dptr,a + 021B A3 450 inc dptr + 021C E5*07 451 mov a,(___fsmul_sloc1_1_0 + 3) + 021E F0 452 movx @dptr,a + 453 ; _fsmul.c 104 + 021F 90s00r08 454 mov dptr,#(___fsmul_fl1_1_1) + 0222 E0 455 movx a,@dptr + 0223 F5*04 456 mov ___fsmul_sloc1_1_0,a + 0225 A3 457 inc dptr + 0226 E0 458 movx a,@dptr + 0227 F5*05 459 mov (___fsmul_sloc1_1_0 + 1),a + 0229 A3 460 inc dptr + 022A E0 461 movx a,@dptr + 022B F5*06 462 mov (___fsmul_sloc1_1_0 + 2),a + 022D A3 463 inc dptr + 022E E0 464 movx a,@dptr + 022F F5*07 465 mov (___fsmul_sloc1_1_0 + 3),a + 0231 75*05 00 466 mov (___fsmul_sloc1_1_0 + 1),#0x00 + 0234 75*06 00 467 mov (___fsmul_sloc1_1_0 + 2),#0x00 + 0237 75*07 00 468 mov (___fsmul_sloc1_1_0 + 3),#0x00 + 023A 90s00r0C 469 mov dptr,#(___fsmul_fl2_1_1) + 023D E0 470 movx a,@dptr + 023E F5*00 471 mov ___fsmul_sloc0_1_0,a + 0240 A3 472 inc dptr + 0241 E0 473 movx a,@dptr + 0242 F5*01 474 mov (___fsmul_sloc0_1_0 + 1),a + 0244 A3 475 inc dptr + 0245 E0 476 movx a,@dptr + 0246 F5*02 477 mov (___fsmul_sloc0_1_0 + 2),a + 0248 A3 478 inc dptr + 0249 E0 479 movx a,@dptr + 024A F5*03 480 mov (___fsmul_sloc0_1_0 + 3),a + 024C 85*01*00 481 mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 1) + 024F 85*02*01 482 mov (___fsmul_sloc0_1_0 + 1),(___fsmul_sloc0_1_0 + 2) + 0252 E5*03 483 mov a,(___fsmul_sloc0_1_0 + 3) + 0254 F5*02 484 mov (___fsmul_sloc0_1_0 + 2),a + 0256 33 485 rlc a + 0257 95 E0 486 subb a,acc + 0259 F5*03 487 mov (___fsmul_sloc0_1_0 + 3),a + 025B 90s00r00 488 mov dptr,#__mululong_PARM_2 + 025E E5*00 489 mov a,___fsmul_sloc0_1_0 + 0260 F0 490 movx @dptr,a + 0261 A3 491 inc dptr + 0262 E5*01 492 mov a,(___fsmul_sloc0_1_0 + 1) + 0264 F0 493 movx @dptr,a + 0265 A3 494 inc dptr + 0266 E5*02 495 mov a,(___fsmul_sloc0_1_0 + 2) + 0268 F0 496 movx @dptr,a + 0269 A3 497 inc dptr + 026A E5*03 498 mov a,(___fsmul_sloc0_1_0 + 3) + 026C F0 499 movx @dptr,a + 026D 85*04 82 500 mov dpl,___fsmul_sloc1_1_0 + 0270 85*05 83 501 mov dph,(___fsmul_sloc1_1_0 + 1) + 0273 85*06 F0 502 mov b,(___fsmul_sloc1_1_0 + 2) + 0276 E5*07 503 mov a,(___fsmul_sloc1_1_0 + 3) + 0278 12s00r00 504 lcall __mululong + 027B 85 82*04 505 mov ___fsmul_sloc1_1_0,dpl + 027E 85 83*05 506 mov (___fsmul_sloc1_1_0 + 1),dph + 0281 85 F0*06 507 mov (___fsmul_sloc1_1_0 + 2),b + 0284 F5*07 508 mov (___fsmul_sloc1_1_0 + 3),a + 0286 85*05*04 509 mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + 0289 85*06*05 510 mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + 028C 85*07*06 511 mov (___fsmul_sloc1_1_0 + 2),(___fsmul_sloc1_1_0 + 3) + 028F 75*07 00 512 mov (___fsmul_sloc1_1_0 + 3),#0x00 + 0292 90s00r10 513 mov dptr,#___fsmul_result_1_1 + 0295 E0 514 movx a,@dptr + 0296 F5*00 515 mov ___fsmul_sloc0_1_0,a + 0298 A3 516 inc dptr + 0299 E0 517 movx a,@dptr + 029A F5*01 518 mov (___fsmul_sloc0_1_0 + 1),a + 029C A3 519 inc dptr + 029D E0 520 movx a,@dptr + 029E F5*02 521 mov (___fsmul_sloc0_1_0 + 2),a + 02A0 A3 522 inc dptr + 02A1 E0 523 movx a,@dptr + 02A2 F5*03 524 mov (___fsmul_sloc0_1_0 + 3),a + 02A4 90s00r10 525 mov dptr,#___fsmul_result_1_1 + 02A7 E5*04 526 mov a,___fsmul_sloc1_1_0 + 02A9 25*00 527 add a,___fsmul_sloc0_1_0 + 02AB F0 528 movx @dptr,a + 02AC E5*05 529 mov a,(___fsmul_sloc1_1_0 + 1) + 02AE 35*01 530 addc a,(___fsmul_sloc0_1_0 + 1) + 02B0 A3 531 inc dptr + 02B1 F0 532 movx @dptr,a + 02B2 E5*06 533 mov a,(___fsmul_sloc1_1_0 + 2) + 02B4 35*02 534 addc a,(___fsmul_sloc0_1_0 + 2) + 02B6 A3 535 inc dptr + 02B7 F0 536 movx @dptr,a + 02B8 E5*07 537 mov a,(___fsmul_sloc1_1_0 + 3) + 02BA 35*03 538 addc a,(___fsmul_sloc0_1_0 + 3) + 02BC A3 539 inc dptr + 02BD F0 540 movx @dptr,a + 541 ; _fsmul.c 105 + 02BE 90s00r0C 542 mov dptr,#(___fsmul_fl2_1_1) + 02C1 E0 543 movx a,@dptr + 02C2 F5*04 544 mov ___fsmul_sloc1_1_0,a + 02C4 A3 545 inc dptr + 02C5 E0 546 movx a,@dptr + 02C6 F5*05 547 mov (___fsmul_sloc1_1_0 + 1),a + 02C8 A3 548 inc dptr + 02C9 E0 549 movx a,@dptr + 02CA F5*06 550 mov (___fsmul_sloc1_1_0 + 2),a + 02CC A3 551 inc dptr + 02CD E0 552 movx a,@dptr + 02CE F5*07 553 mov (___fsmul_sloc1_1_0 + 3),a + 02D0 75*05 00 554 mov (___fsmul_sloc1_1_0 + 1),#0x00 + 02D3 75*06 00 555 mov (___fsmul_sloc1_1_0 + 2),#0x00 + 02D6 75*07 00 556 mov (___fsmul_sloc1_1_0 + 3),#0x00 + 02D9 90s00r08 557 mov dptr,#(___fsmul_fl1_1_1) + 02DC E0 558 movx a,@dptr + 02DD F5*00 559 mov ___fsmul_sloc0_1_0,a + 02DF A3 560 inc dptr + 02E0 E0 561 movx a,@dptr + 02E1 F5*01 562 mov (___fsmul_sloc0_1_0 + 1),a + 02E3 A3 563 inc dptr + 02E4 E0 564 movx a,@dptr + 02E5 F5*02 565 mov (___fsmul_sloc0_1_0 + 2),a + 02E7 A3 566 inc dptr + 02E8 E0 567 movx a,@dptr + 02E9 F5*03 568 mov (___fsmul_sloc0_1_0 + 3),a + 02EB 85*01*00 569 mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 1) + 02EE 85*02*01 570 mov (___fsmul_sloc0_1_0 + 1),(___fsmul_sloc0_1_0 + 2) + 02F1 E5*03 571 mov a,(___fsmul_sloc0_1_0 + 3) + 02F3 F5*02 572 mov (___fsmul_sloc0_1_0 + 2),a + 02F5 33 573 rlc a + 02F6 95 E0 574 subb a,acc + 02F8 F5*03 575 mov (___fsmul_sloc0_1_0 + 3),a + 02FA 90s00r00 576 mov dptr,#__mululong_PARM_2 + 02FD E5*00 577 mov a,___fsmul_sloc0_1_0 + 02FF F0 578 movx @dptr,a + 0300 A3 579 inc dptr + 0301 E5*01 580 mov a,(___fsmul_sloc0_1_0 + 1) + 0303 F0 581 movx @dptr,a + 0304 A3 582 inc dptr + 0305 E5*02 583 mov a,(___fsmul_sloc0_1_0 + 2) + 0307 F0 584 movx @dptr,a + 0308 A3 585 inc dptr + 0309 E5*03 586 mov a,(___fsmul_sloc0_1_0 + 3) + 030B F0 587 movx @dptr,a + 030C 85*04 82 588 mov dpl,___fsmul_sloc1_1_0 + 030F 85*05 83 589 mov dph,(___fsmul_sloc1_1_0 + 1) + 0312 85*06 F0 590 mov b,(___fsmul_sloc1_1_0 + 2) + 0315 E5*07 591 mov a,(___fsmul_sloc1_1_0 + 3) + 0317 12s00r00 592 lcall __mululong + 031A 85 82*04 593 mov ___fsmul_sloc1_1_0,dpl + 031D 85 83*05 594 mov (___fsmul_sloc1_1_0 + 1),dph + 0320 85 F0*06 595 mov (___fsmul_sloc1_1_0 + 2),b + 0323 F5*07 596 mov (___fsmul_sloc1_1_0 + 3),a + 0325 85*05*04 597 mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + 0328 85*06*05 598 mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + 032B 85*07*06 599 mov (___fsmul_sloc1_1_0 + 2),(___fsmul_sloc1_1_0 + 3) + 032E 75*07 00 600 mov (___fsmul_sloc1_1_0 + 3),#0x00 + 0331 90s00r10 601 mov dptr,#___fsmul_result_1_1 + 0334 E0 602 movx a,@dptr + 0335 F5*00 603 mov ___fsmul_sloc0_1_0,a + 0337 A3 604 inc dptr + 0338 E0 605 movx a,@dptr + 0339 F5*01 606 mov (___fsmul_sloc0_1_0 + 1),a + 033B A3 607 inc dptr + 033C E0 608 movx a,@dptr + 033D F5*02 609 mov (___fsmul_sloc0_1_0 + 2),a + 033F A3 610 inc dptr + 0340 E0 611 movx a,@dptr + 0341 F5*03 612 mov (___fsmul_sloc0_1_0 + 3),a + 0343 90s00r10 613 mov dptr,#___fsmul_result_1_1 + 0346 E5*04 614 mov a,___fsmul_sloc1_1_0 + 0348 25*00 615 add a,___fsmul_sloc0_1_0 + 034A F0 616 movx @dptr,a + 034B E5*05 617 mov a,(___fsmul_sloc1_1_0 + 1) + 034D 35*01 618 addc a,(___fsmul_sloc0_1_0 + 1) + 034F A3 619 inc dptr + 0350 F0 620 movx @dptr,a + 0351 E5*06 621 mov a,(___fsmul_sloc1_1_0 + 2) + 0353 35*02 622 addc a,(___fsmul_sloc0_1_0 + 2) + 0355 A3 623 inc dptr + 0356 F0 624 movx @dptr,a + 0357 E5*07 625 mov a,(___fsmul_sloc1_1_0 + 3) + 0359 35*03 626 addc a,(___fsmul_sloc0_1_0 + 3) + 035B A3 627 inc dptr + 035C F0 628 movx @dptr,a + 629 ; _fsmul.c 107 + 035D 90s00r10 630 mov dptr,#___fsmul_result_1_1 + 0360 E0 631 movx a,@dptr + 0361 F5*04 632 mov ___fsmul_sloc1_1_0,a + 0363 A3 633 inc dptr + 0364 E0 634 movx a,@dptr + 0365 F5*05 635 mov (___fsmul_sloc1_1_0 + 1),a + 0367 A3 636 inc dptr + 0368 E0 637 movx a,@dptr + 0369 F5*06 638 mov (___fsmul_sloc1_1_0 + 2),a + 036B A3 639 inc dptr + 036C E0 640 movx a,@dptr + 641 ; Peephole 105 removed redundant mov + 036D F5*07 642 mov (___fsmul_sloc1_1_0 + 3),a + 036F 20 E7 03 643 jb acc.7,00118$ + 0372 02s03rD1 644 ljmp 00105$ + 0375 645 00118$: + 646 ; _fsmul.c 110 + 0375 90s00r10 647 mov dptr,#___fsmul_result_1_1 + 0378 E0 648 movx a,@dptr + 0379 F5*04 649 mov ___fsmul_sloc1_1_0,a + 037B A3 650 inc dptr + 037C E0 651 movx a,@dptr + 037D F5*05 652 mov (___fsmul_sloc1_1_0 + 1),a + 037F A3 653 inc dptr + 0380 E0 654 movx a,@dptr + 0381 F5*06 655 mov (___fsmul_sloc1_1_0 + 2),a + 0383 A3 656 inc dptr + 0384 E0 657 movx a,@dptr + 0385 F5*07 658 mov (___fsmul_sloc1_1_0 + 3),a + 0387 90s00r10 659 mov dptr,#___fsmul_result_1_1 + 038A 74 80 660 mov a,#0x80 + 038C 25*04 661 add a,___fsmul_sloc1_1_0 + 038E F0 662 movx @dptr,a + 663 ; Peephole 180 changed mov to clr + 038F E4 664 clr a + 0390 35*05 665 addc a,(___fsmul_sloc1_1_0 + 1) + 0392 A3 666 inc dptr + 0393 F0 667 movx @dptr,a + 668 ; Peephole 180 changed mov to clr + 0394 E4 669 clr a + 0395 35*06 670 addc a,(___fsmul_sloc1_1_0 + 2) + 0397 A3 671 inc dptr + 0398 F0 672 movx @dptr,a + 673 ; Peephole 180 changed mov to clr + 0399 E4 674 clr a + 039A 35*07 675 addc a,(___fsmul_sloc1_1_0 + 3) + 039C A3 676 inc dptr + 039D F0 677 movx @dptr,a + 678 ; _fsmul.c 111 + 039E 90s00r10 679 mov dptr,#___fsmul_result_1_1 + 03A1 E0 680 movx a,@dptr + 03A2 F5*04 681 mov ___fsmul_sloc1_1_0,a + 03A4 A3 682 inc dptr + 03A5 E0 683 movx a,@dptr + 03A6 F5*05 684 mov (___fsmul_sloc1_1_0 + 1),a + 03A8 A3 685 inc dptr + 03A9 E0 686 movx a,@dptr + 03AA F5*06 687 mov (___fsmul_sloc1_1_0 + 2),a + 03AC A3 688 inc dptr + 03AD E0 689 movx a,@dptr + 03AE F5*07 690 mov (___fsmul_sloc1_1_0 + 3),a + 03B0 85*05*04 691 mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + 03B3 85*06*05 692 mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + 03B6 85*07*06 693 mov (___fsmul_sloc1_1_0 + 2),(___fsmul_sloc1_1_0 + 3) + 03B9 75*07 00 694 mov (___fsmul_sloc1_1_0 + 3),#0x00 + 03BC 90s00r10 695 mov dptr,#___fsmul_result_1_1 + 03BF E5*04 696 mov a,___fsmul_sloc1_1_0 + 03C1 F0 697 movx @dptr,a + 03C2 A3 698 inc dptr + 03C3 E5*05 699 mov a,(___fsmul_sloc1_1_0 + 1) + 03C5 F0 700 movx @dptr,a + 03C6 A3 701 inc dptr + 03C7 E5*06 702 mov a,(___fsmul_sloc1_1_0 + 2) + 03C9 F0 703 movx @dptr,a + 03CA A3 704 inc dptr + 03CB E5*07 705 mov a,(___fsmul_sloc1_1_0 + 3) + 03CD F0 706 movx @dptr,a + 03CE 02s04r5A 707 ljmp 00106$ + 03D1 708 00105$: + 709 ; _fsmul.c 116 + 03D1 90s00r10 710 mov dptr,#___fsmul_result_1_1 + 03D4 E0 711 movx a,@dptr + 03D5 F5*04 712 mov ___fsmul_sloc1_1_0,a + 03D7 A3 713 inc dptr + 03D8 E0 714 movx a,@dptr + 03D9 F5*05 715 mov (___fsmul_sloc1_1_0 + 1),a + 03DB A3 716 inc dptr + 03DC E0 717 movx a,@dptr + 03DD F5*06 718 mov (___fsmul_sloc1_1_0 + 2),a + 03DF A3 719 inc dptr + 03E0 E0 720 movx a,@dptr + 03E1 F5*07 721 mov (___fsmul_sloc1_1_0 + 3),a + 03E3 90s00r10 722 mov dptr,#___fsmul_result_1_1 + 03E6 74 40 723 mov a,#0x40 + 03E8 25*04 724 add a,___fsmul_sloc1_1_0 + 03EA F0 725 movx @dptr,a + 726 ; Peephole 180 changed mov to clr + 03EB E4 727 clr a + 03EC 35*05 728 addc a,(___fsmul_sloc1_1_0 + 1) + 03EE A3 729 inc dptr + 03EF F0 730 movx @dptr,a + 731 ; Peephole 180 changed mov to clr + 03F0 E4 732 clr a + 03F1 35*06 733 addc a,(___fsmul_sloc1_1_0 + 2) + 03F3 A3 734 inc dptr + 03F4 F0 735 movx @dptr,a + 736 ; Peephole 180 changed mov to clr + 03F5 E4 737 clr a + 03F6 35*07 738 addc a,(___fsmul_sloc1_1_0 + 3) + 03F8 A3 739 inc dptr + 03F9 F0 740 movx @dptr,a + 741 ; _fsmul.c 117 + 03FA 90s00r10 742 mov dptr,#___fsmul_result_1_1 + 03FD E0 743 movx a,@dptr + 03FE F5*04 744 mov ___fsmul_sloc1_1_0,a + 0400 A3 745 inc dptr + 0401 E0 746 movx a,@dptr + 0402 F5*05 747 mov (___fsmul_sloc1_1_0 + 1),a + 0404 A3 748 inc dptr + 0405 E0 749 movx a,@dptr + 0406 F5*06 750 mov (___fsmul_sloc1_1_0 + 2),a + 0408 A3 751 inc dptr + 0409 E0 752 movx a,@dptr + 040A F5*07 753 mov (___fsmul_sloc1_1_0 + 3),a + 040C E5*05 754 mov a,(___fsmul_sloc1_1_0 + 1) + 040E A2 E7 755 mov c,acc.7 + 0410 C5*04 756 xch a,___fsmul_sloc1_1_0 + 0412 33 757 rlc a + 0413 C5*04 758 xch a,___fsmul_sloc1_1_0 + 0415 33 759 rlc a + 0416 C5*04 760 xch a,___fsmul_sloc1_1_0 + 0418 54 01 761 anl a,#0x01 + 041A F5*05 762 mov (___fsmul_sloc1_1_0 + 1),a + 041C E5*06 763 mov a,(___fsmul_sloc1_1_0 + 2) + 041E 25 E0 764 add a,acc + 0420 45*05 765 orl a,(___fsmul_sloc1_1_0 + 1) + 0422 F5*05 766 mov (___fsmul_sloc1_1_0 + 1),a + 0424 E5*07 767 mov a,(___fsmul_sloc1_1_0 + 3) + 0426 A2 E7 768 mov c,acc.7 + 0428 C5*06 769 xch a,(___fsmul_sloc1_1_0 + 2) + 042A 33 770 rlc a + 042B C5*06 771 xch a,(___fsmul_sloc1_1_0 + 2) + 042D 33 772 rlc a + 042E C5*06 773 xch a,(___fsmul_sloc1_1_0 + 2) + 0430 54 01 774 anl a,#0x01 + 0432 F5*07 775 mov (___fsmul_sloc1_1_0 + 3),a + 0434 90s00r10 776 mov dptr,#___fsmul_result_1_1 + 0437 E5*04 777 mov a,___fsmul_sloc1_1_0 + 0439 F0 778 movx @dptr,a + 043A A3 779 inc dptr + 043B E5*05 780 mov a,(___fsmul_sloc1_1_0 + 1) + 043D F0 781 movx @dptr,a + 043E A3 782 inc dptr + 043F E5*06 783 mov a,(___fsmul_sloc1_1_0 + 2) + 0441 F0 784 movx @dptr,a + 0442 A3 785 inc dptr + 0443 E5*07 786 mov a,(___fsmul_sloc1_1_0 + 3) + 0445 F0 787 movx @dptr,a + 788 ; _fsmul.c 118 + 0446 90s00r14 789 mov dptr,#___fsmul_exp_1_1 + 0449 E0 790 movx a,@dptr + 044A 24 FF 791 add a,#0xff + 044C FA 792 mov r2,a + 044D A3 793 inc dptr + 044E E0 794 movx a,@dptr + 044F 34 FF 795 addc a,#0xff + 0451 FE 796 mov r6,a + 0452 90s00r14 797 mov dptr,#___fsmul_exp_1_1 + 0455 EA 798 mov a,r2 + 0456 F0 799 movx @dptr,a + 0457 A3 800 inc dptr + 0458 EE 801 mov a,r6 + 0459 F0 802 movx @dptr,a + 045A 803 00106$: + 804 ; _fsmul.c 121 + 045A 90s00r10 805 mov dptr,#___fsmul_result_1_1 + 045D E0 806 movx a,@dptr + 045E F5*04 807 mov ___fsmul_sloc1_1_0,a + 0460 A3 808 inc dptr + 0461 E0 809 movx a,@dptr + 0462 F5*05 810 mov (___fsmul_sloc1_1_0 + 1),a + 0464 A3 811 inc dptr + 0465 E0 812 movx a,@dptr + 0466 F5*06 813 mov (___fsmul_sloc1_1_0 + 2),a + 0468 A3 814 inc dptr + 0469 E0 815 movx a,@dptr + 046A F5*07 816 mov (___fsmul_sloc1_1_0 + 3),a + 046C 90s00r10 817 mov dptr,#___fsmul_result_1_1 + 046F E5*04 818 mov a,___fsmul_sloc1_1_0 + 0471 F0 819 movx @dptr,a + 0472 A3 820 inc dptr + 0473 E5*05 821 mov a,(___fsmul_sloc1_1_0 + 1) + 0475 F0 822 movx @dptr,a + 0476 74 7F 823 mov a,#0x7f + 0478 55*06 824 anl a,(___fsmul_sloc1_1_0 + 2) + 047A A3 825 inc dptr + 047B F0 826 movx @dptr,a + 047C A3 827 inc dptr + 047D E5*07 828 mov a,(___fsmul_sloc1_1_0 + 3) + 047F F0 829 movx @dptr,a + 830 ; _fsmul.c 124 + 0480 90s00r16 831 mov dptr,#___fsmul_sign_1_1 + 0483 E0 832 movx a,@dptr + 833 ; Peephole 105 removed redundant mov + 0484 FA 834 mov r2,a + 835 ; Peephole 110 removed ljmp by inverse jump logic + 0485 60 0E 836 jz 00109$ + 0487 837 00119$: + 0487 75*04 00 838 mov ___fsmul_sloc1_1_0,#0x00 + 048A 75*05 00 839 mov (___fsmul_sloc1_1_0 + 1),#0x00 + 048D 75*06 00 840 mov (___fsmul_sloc1_1_0 + 2),#0x00 + 0490 75*07 80 841 mov (___fsmul_sloc1_1_0 + 3),#0x80 + 842 ; Peephole 132 changed ljmp to sjmp + 0493 80 09 843 sjmp 00110$ + 0495 844 00109$: + 0495 E4 845 clr a + 0496 F5*07 846 mov (___fsmul_sloc1_1_0 + 3),a + 0498 F5*06 847 mov (___fsmul_sloc1_1_0 + 2),a + 049A F5*05 848 mov (___fsmul_sloc1_1_0 + 1),a + 049C F5*04 849 mov ___fsmul_sloc1_1_0,a + 049E 850 00110$: + 049E 90s00r14 851 mov dptr,#___fsmul_exp_1_1 + 04A1 E0 852 movx a,@dptr + 04A2 FA 853 mov r2,a + 04A3 A3 854 inc dptr + 04A4 E0 855 movx a,@dptr + 04A5 FE 856 mov r6,a + 04A6 8A*00 857 mov ___fsmul_sloc0_1_0,r2 + 04A8 8E*01 858 mov (___fsmul_sloc0_1_0 + 1),r6 + 04AA 75*02 00 859 mov (___fsmul_sloc0_1_0 + 2),#0x00 + 04AD 75*03 00 860 mov (___fsmul_sloc0_1_0 + 3),#0x00 + 04B0 85*00*02 861 mov (___fsmul_sloc0_1_0 + 2),___fsmul_sloc0_1_0 + 04B3 E5*01 862 mov a,(___fsmul_sloc0_1_0 + 1) + 04B5 54 01 863 anl a,#0x01 + 04B7 A2 E0 864 mov c,acc.0 + 04B9 C5*02 865 xch a,(___fsmul_sloc0_1_0 + 2) + 04BB 13 866 rrc a + 04BC C5*02 867 xch a,(___fsmul_sloc0_1_0 + 2) + 04BE 13 868 rrc a + 04BF C5*02 869 xch a,(___fsmul_sloc0_1_0 + 2) + 04C1 F5*03 870 mov (___fsmul_sloc0_1_0 + 3),a + 871 ; Peephole 3.c changed mov to clr + 04C3 E4 872 clr a + 04C4 F5*01 873 mov (___fsmul_sloc0_1_0 + 1),a + 874 ; Peephole 105 removed redundant mov + 04C6 F5*00 875 mov ___fsmul_sloc0_1_0,a + 04C8 42*04 876 orl ___fsmul_sloc1_1_0,a + 04CA E5*01 877 mov a,(___fsmul_sloc0_1_0 + 1) + 04CC 42*05 878 orl (___fsmul_sloc1_1_0 + 1),a + 04CE E5*02 879 mov a,(___fsmul_sloc0_1_0 + 2) + 04D0 42*06 880 orl (___fsmul_sloc1_1_0 + 2),a + 04D2 E5*03 881 mov a,(___fsmul_sloc0_1_0 + 3) + 04D4 42*07 882 orl (___fsmul_sloc1_1_0 + 3),a + 04D6 90s00r10 883 mov dptr,#___fsmul_result_1_1 + 04D9 E0 884 movx a,@dptr + 04DA F5*00 885 mov ___fsmul_sloc0_1_0,a + 04DC A3 886 inc dptr + 04DD E0 887 movx a,@dptr + 04DE F5*01 888 mov (___fsmul_sloc0_1_0 + 1),a + 04E0 A3 889 inc dptr + 04E1 E0 890 movx a,@dptr + 04E2 F5*02 891 mov (___fsmul_sloc0_1_0 + 2),a + 04E4 A3 892 inc dptr + 04E5 E0 893 movx a,@dptr + 04E6 F5*03 894 mov (___fsmul_sloc0_1_0 + 3),a + 04E8 E5*00 895 mov a,___fsmul_sloc0_1_0 + 04EA 42*04 896 orl ___fsmul_sloc1_1_0,a + 04EC E5*01 897 mov a,(___fsmul_sloc0_1_0 + 1) + 04EE 42*05 898 orl (___fsmul_sloc1_1_0 + 1),a + 04F0 E5*02 899 mov a,(___fsmul_sloc0_1_0 + 2) + 04F2 42*06 900 orl (___fsmul_sloc1_1_0 + 2),a + 04F4 E5*03 901 mov a,(___fsmul_sloc0_1_0 + 3) + 04F6 42*07 902 orl (___fsmul_sloc1_1_0 + 3),a + 04F8 90s00r08 903 mov dptr,#(___fsmul_fl1_1_1) + 04FB E5*04 904 mov a,___fsmul_sloc1_1_0 + 04FD F0 905 movx @dptr,a + 04FE A3 906 inc dptr + 04FF E5*05 907 mov a,(___fsmul_sloc1_1_0 + 1) + 0501 F0 908 movx @dptr,a + 0502 A3 909 inc dptr + 0503 E5*06 910 mov a,(___fsmul_sloc1_1_0 + 2) + 0505 F0 911 movx @dptr,a + 0506 A3 912 inc dptr + 0507 E5*07 913 mov a,(___fsmul_sloc1_1_0 + 3) + 0509 F0 914 movx @dptr,a + 915 ; _fsmul.c 125 + 050A 90s00r08 916 mov dptr,#(___fsmul_fl1_1_1) + 050D E0 917 movx a,@dptr + 050E F5*04 918 mov ___fsmul_sloc1_1_0,a + 0510 A3 919 inc dptr + 0511 E0 920 movx a,@dptr + 0512 F5*05 921 mov (___fsmul_sloc1_1_0 + 1),a + 0514 A3 922 inc dptr + 0515 E0 923 movx a,@dptr + 0516 F5*06 924 mov (___fsmul_sloc1_1_0 + 2),a + 0518 A3 925 inc dptr + 0519 E0 926 movx a,@dptr + 927 ; Peephole 191 removed redundant mov + 051A F5*07 928 mov (___fsmul_sloc1_1_0 + 3),a + 051C 85*04 82 929 mov dpl,___fsmul_sloc1_1_0 + 051F 85*05 83 930 mov dph,(___fsmul_sloc1_1_0 + 1) + 0522 85*06 F0 931 mov b,(___fsmul_sloc1_1_0 + 2) + 0525 932 00107$: + 0525 933 C$_fsmul.c$126$1$1 ==. + 0525 934 XG$__fsmul$0$0 ==. + 0525 22 935 ret + 936 .area CSEG (CODE) diff --git a/device/lib/_fsmul.sym b/device/lib/_fsmul.sym new file mode 100644 index 00000000..2cff64df --- /dev/null +++ b/device/lib/_fsmul.sym @@ -0,0 +1,1179 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fsmul$100 0020 GR + 7 A$_fsmul$101 0021 GR + 7 A$_fsmul$102 0022 GR + 7 A$_fsmul$103 0023 GR + 7 A$_fsmul$104 0024 GR + 7 A$_fsmul$105 0025 GR + 7 A$_fsmul$106 0026 GR + 7 A$_fsmul$107 0027 GR + 7 A$_fsmul$108 0028 GR + 7 A$_fsmul$109 002B GR + 7 A$_fsmul$110 002C GR + 7 A$_fsmul$111 002D GR + 7 A$_fsmul$112 002E GR + 7 A$_fsmul$113 002F GR + 7 A$_fsmul$114 0030 GR + 7 A$_fsmul$115 0031 GR + 7 A$_fsmul$116 0032 GR + 7 A$_fsmul$117 0033 GR + 7 A$_fsmul$118 0034 GR + 7 A$_fsmul$119 0035 GR + 7 A$_fsmul$121 0036 GR + 7 A$_fsmul$122 0039 GR + 7 A$_fsmul$123 003A GR + 7 A$_fsmul$124 003B GR + 7 A$_fsmul$125 003C GR + 7 A$_fsmul$126 003D GR + 7 A$_fsmul$127 003E GR + 7 A$_fsmul$128 003F GR + 7 A$_fsmul$129 0040 GR + 7 A$_fsmul$130 0041 GR + 7 A$_fsmul$131 0042 GR + 7 A$_fsmul$132 0043 GR + 7 A$_fsmul$133 0044 GR + 7 A$_fsmul$134 0047 GR + 7 A$_fsmul$135 0048 GR + 7 A$_fsmul$136 0049 GR + 7 A$_fsmul$137 004A GR + 7 A$_fsmul$138 004B GR + 7 A$_fsmul$139 004C GR + 7 A$_fsmul$140 004D GR + 7 A$_fsmul$141 004E GR + 7 A$_fsmul$142 004F GR + 7 A$_fsmul$143 0050 GR + 7 A$_fsmul$144 0051 GR + 7 A$_fsmul$146 0052 GR + 7 A$_fsmul$147 0055 GR + 7 A$_fsmul$148 0056 GR + 7 A$_fsmul$149 0057 GR + 7 A$_fsmul$150 0058 GR + 7 A$_fsmul$151 0059 GR + 7 A$_fsmul$152 005A GR + 7 A$_fsmul$153 005B GR + 7 A$_fsmul$154 005C GR + 7 A$_fsmul$155 005D GR + 7 A$_fsmul$156 005E GR + 7 A$_fsmul$157 005F GR + 7 A$_fsmul$158 0060 GR + 7 A$_fsmul$159 0061 GR + 7 A$_fsmul$160 0062 GR + 7 A$_fsmul$161 0063 GR + 7 A$_fsmul$163 0064 GR + 7 A$_fsmul$165 0066 GR + 7 A$_fsmul$166 0069 GR + 7 A$_fsmul$167 006A GR + 7 A$_fsmul$168 006B GR + 7 A$_fsmul$169 006C GR + 7 A$_fsmul$170 006D GR + 7 A$_fsmul$171 006E GR + 7 A$_fsmul$172 006F GR + 7 A$_fsmul$173 0070 GR + 7 A$_fsmul$174 0071 GR + 7 A$_fsmul$175 0072 GR + 7 A$_fsmul$176 0073 GR + 7 A$_fsmul$177 0074 GR + 7 A$_fsmul$178 0075 GR + 7 A$_fsmul$179 0076 GR + 7 A$_fsmul$180 0077 GR + 7 A$_fsmul$182 0078 GR + 7 A$_fsmul$189 007A GR + 7 A$_fsmul$190 007B GR + 7 A$_fsmul$191 007D GR + 7 A$_fsmul$192 007F GR + 7 A$_fsmul$193 0081 GR + 7 A$_fsmul$196 0084 GR + 7 A$_fsmul$197 0087 GR + 7 A$_fsmul$198 0088 GR + 7 A$_fsmul$199 0089 GR + 7 A$_fsmul$200 008A GR + 7 A$_fsmul$201 008B GR + 7 A$_fsmul$202 008C GR + 7 A$_fsmul$203 008D GR + 7 A$_fsmul$204 008E GR + 7 A$_fsmul$205 008F GR + 7 A$_fsmul$206 0090 GR + 7 A$_fsmul$208 0091 GR + 7 A$_fsmul$209 0092 GR + 7 A$_fsmul$210 0093 GR + 7 A$_fsmul$211 0095 GR + 7 A$_fsmul$212 0096 GR + 7 A$_fsmul$213 0099 GR + 7 A$_fsmul$214 009A GR + 7 A$_fsmul$215 009B GR + 7 A$_fsmul$216 009C GR + 7 A$_fsmul$217 009D GR + 7 A$_fsmul$218 009E GR + 7 A$_fsmul$219 009F GR + 7 A$_fsmul$220 00A0 GR + 7 A$_fsmul$221 00A1 GR + 7 A$_fsmul$222 00A2 GR + 7 A$_fsmul$224 00A3 GR + 7 A$_fsmul$225 00A4 GR + 7 A$_fsmul$226 00A5 GR + 7 A$_fsmul$227 00A7 GR + 7 A$_fsmul$228 00A8 GR + 7 A$_fsmul$229 00AB GR + 7 A$_fsmul$230 00AC GR + 7 A$_fsmul$231 00AE GR + 7 A$_fsmul$233 00AF GR + 7 A$_fsmul$234 00B2 GR + 7 A$_fsmul$235 00B3 GR + 7 A$_fsmul$236 00B5 GR + 7 A$_fsmul$237 00B6 GR + 7 A$_fsmul$238 00B7 GR + 7 A$_fsmul$239 00B9 GR + 7 A$_fsmul$240 00BA GR + 7 A$_fsmul$241 00BB GR + 7 A$_fsmul$242 00BD GR + 7 A$_fsmul$243 00BE GR + 7 A$_fsmul$244 00BF GR + 7 A$_fsmul$245 00C1 GR + 7 A$_fsmul$246 00C4 GR + 7 A$_fsmul$247 00C6 GR + 7 A$_fsmul$248 00C8 GR + 7 A$_fsmul$249 00CA GR + 7 A$_fsmul$250 00CB GR + 7 A$_fsmul$251 00CD GR + 7 A$_fsmul$252 00CE GR + 7 A$_fsmul$253 00D0 GR + 7 A$_fsmul$254 00D2 GR + 7 A$_fsmul$255 00D5 GR + 7 A$_fsmul$257 00D7 GR + 7 A$_fsmul$258 00D9 GR + 7 A$_fsmul$259 00DA GR + 7 A$_fsmul$260 00DC GR + 7 A$_fsmul$261 00DE GR + 7 A$_fsmul$262 00E0 GR + 7 A$_fsmul$263 00E2 GR + 7 A$_fsmul$264 00E4 GR + 7 A$_fsmul$265 00E5 GR + 7 A$_fsmul$266 00E8 GR + 7 A$_fsmul$267 00EA GR + 7 A$_fsmul$268 00EB GR + 7 A$_fsmul$269 00ED GR + 7 A$_fsmul$270 00EF GR + 7 A$_fsmul$271 00F0 GR + 7 A$_fsmul$272 00F3 GR + 7 A$_fsmul$273 00F4 GR + 7 A$_fsmul$274 00F5 GR + 7 A$_fsmul$275 00F6 GR + 7 A$_fsmul$276 00F7 GR + 7 A$_fsmul$278 00F8 GR + 7 A$_fsmul$279 00FB GR + 7 A$_fsmul$280 00FC GR + 7 A$_fsmul$281 00FE GR + 7 A$_fsmul$282 00FF GR + 7 A$_fsmul$283 0100 GR + 7 A$_fsmul$284 0102 GR + 7 A$_fsmul$285 0103 GR + 7 A$_fsmul$286 0104 GR + 7 A$_fsmul$287 0106 GR + 7 A$_fsmul$288 0107 GR + 7 A$_fsmul$289 0108 GR + 7 A$_fsmul$290 010A GR + 7 A$_fsmul$291 010D GR + 7 A$_fsmul$292 010F GR + 7 A$_fsmul$293 0111 GR + 7 A$_fsmul$294 0113 GR + 7 A$_fsmul$295 0114 GR + 7 A$_fsmul$296 0116 GR + 7 A$_fsmul$297 0117 GR + 7 A$_fsmul$298 0119 GR + 7 A$_fsmul$299 011B GR + 7 A$_fsmul$300 011E GR + 7 A$_fsmul$302 0120 GR + 7 A$_fsmul$303 0122 GR + 7 A$_fsmul$304 0123 GR + 7 A$_fsmul$305 0125 GR + 7 A$_fsmul$306 0127 GR + 7 A$_fsmul$307 0129 GR + 7 A$_fsmul$308 012B GR + 7 A$_fsmul$309 012D GR + 7 A$_fsmul$310 012F GR + 7 A$_fsmul$311 0132 GR + 7 A$_fsmul$312 0135 GR + 7 A$_fsmul$313 0136 GR + 7 A$_fsmul$314 0137 GR + 7 A$_fsmul$315 0138 GR + 7 A$_fsmul$316 0139 GR + 7 A$_fsmul$317 013A GR + 7 A$_fsmul$318 013D GR + 7 A$_fsmul$319 013F GR + 7 A$_fsmul$320 0140 GR + 7 A$_fsmul$321 0141 GR + 7 A$_fsmul$322 0143 GR + 7 A$_fsmul$323 0144 GR + 7 A$_fsmul$324 0145 GR + 7 A$_fsmul$326 0146 GR + 7 A$_fsmul$327 0149 GR + 7 A$_fsmul$328 014A GR + 7 A$_fsmul$329 014C GR + 7 A$_fsmul$330 014D GR + 7 A$_fsmul$331 014E GR + 7 A$_fsmul$332 0150 GR + 7 A$_fsmul$333 0151 GR + 7 A$_fsmul$334 0152 GR + 7 A$_fsmul$335 0154 GR + 7 A$_fsmul$336 0155 GR + 7 A$_fsmul$337 0156 GR + 7 A$_fsmul$338 0158 GR + 7 A$_fsmul$339 015B GR + 7 A$_fsmul$340 015E GR + 7 A$_fsmul$341 0161 GR + 7 A$_fsmul$342 0164 GR + 7 A$_fsmul$343 0166 GR + 7 A$_fsmul$344 0167 GR + 7 A$_fsmul$345 0168 GR + 7 A$_fsmul$346 016A GR + 7 A$_fsmul$347 016B GR + 7 A$_fsmul$348 016C GR + 7 A$_fsmul$349 016E GR + 7 A$_fsmul$350 016F GR + 7 A$_fsmul$351 0170 GR + 7 A$_fsmul$352 0172 GR + 7 A$_fsmul$354 0173 GR + 7 A$_fsmul$355 0176 GR + 7 A$_fsmul$356 0177 GR + 7 A$_fsmul$357 0179 GR + 7 A$_fsmul$358 017A GR + 7 A$_fsmul$359 017B GR + 7 A$_fsmul$360 017D GR + 7 A$_fsmul$361 017E GR + 7 A$_fsmul$362 017F GR + 7 A$_fsmul$363 0181 GR + 7 A$_fsmul$364 0182 GR + 7 A$_fsmul$365 0183 GR + 7 A$_fsmul$366 0185 GR + 7 A$_fsmul$367 0188 GR + 7 A$_fsmul$368 018B GR + 7 A$_fsmul$369 018E GR + 7 A$_fsmul$370 0191 GR + 7 A$_fsmul$371 0193 GR + 7 A$_fsmul$372 0194 GR + 7 A$_fsmul$373 0195 GR + 7 A$_fsmul$374 0197 GR + 7 A$_fsmul$375 0198 GR + 7 A$_fsmul$376 0199 GR + 7 A$_fsmul$377 019B GR + 7 A$_fsmul$378 019C GR + 7 A$_fsmul$379 019D GR + 7 A$_fsmul$380 019F GR + 7 A$_fsmul$382 01A0 GR + 7 A$_fsmul$383 01A3 GR + 7 A$_fsmul$384 01A4 GR + 7 A$_fsmul$385 01A6 GR + 7 A$_fsmul$386 01A7 GR + 7 A$_fsmul$387 01A8 GR + 7 A$_fsmul$388 01AA GR + 7 A$_fsmul$389 01AB GR + 7 A$_fsmul$390 01AC GR + 7 A$_fsmul$391 01AE GR + 7 A$_fsmul$392 01AF GR + 7 A$_fsmul$393 01B0 GR + 7 A$_fsmul$394 01B2 GR + 7 A$_fsmul$395 01B5 GR + 7 A$_fsmul$396 01B8 GR + 7 A$_fsmul$397 01BA GR + 7 A$_fsmul$398 01BC GR + 7 A$_fsmul$399 01BD GR + 7 A$_fsmul$400 01BF GR + 7 A$_fsmul$401 01C1 GR + 7 A$_fsmul$402 01C4 GR + 7 A$_fsmul$403 01C5 GR + 7 A$_fsmul$404 01C7 GR + 7 A$_fsmul$405 01C8 GR + 7 A$_fsmul$406 01C9 GR + 7 A$_fsmul$407 01CB GR + 7 A$_fsmul$408 01CC GR + 7 A$_fsmul$409 01CD GR + 7 A$_fsmul$410 01CF GR + 7 A$_fsmul$411 01D0 GR + 7 A$_fsmul$412 01D1 GR + 7 A$_fsmul$413 01D3 GR + 7 A$_fsmul$414 01D6 GR + 7 A$_fsmul$415 01D9 GR + 7 A$_fsmul$416 01DB GR + 7 A$_fsmul$417 01DD GR + 7 A$_fsmul$418 01DE GR + 7 A$_fsmul$419 01E0 GR + 7 A$_fsmul$420 01E2 GR + 7 A$_fsmul$421 01E5 GR + 7 A$_fsmul$422 01E7 GR + 7 A$_fsmul$423 01E8 GR + 7 A$_fsmul$424 01E9 GR + 7 A$_fsmul$425 01EB GR + 7 A$_fsmul$426 01EC GR + 7 A$_fsmul$427 01ED GR + 7 A$_fsmul$428 01EF GR + 7 A$_fsmul$429 01F0 GR + 7 A$_fsmul$430 01F1 GR + 7 A$_fsmul$431 01F3 GR + 7 A$_fsmul$432 01F4 GR + 7 A$_fsmul$433 01F7 GR + 7 A$_fsmul$434 01FA GR + 7 A$_fsmul$435 01FD GR + 7 A$_fsmul$436 01FF GR + 7 A$_fsmul$437 0202 GR + 7 A$_fsmul$438 0205 GR + 7 A$_fsmul$439 0208 GR + 7 A$_fsmul$440 020B GR + 7 A$_fsmul$441 020D GR + 7 A$_fsmul$442 0210 GR + 7 A$_fsmul$443 0212 GR + 7 A$_fsmul$444 0213 GR + 7 A$_fsmul$445 0214 GR + 7 A$_fsmul$446 0216 GR + 7 A$_fsmul$447 0217 GR + 7 A$_fsmul$448 0218 GR + 7 A$_fsmul$449 021A GR + 7 A$_fsmul$450 021B GR + 7 A$_fsmul$451 021C GR + 7 A$_fsmul$452 021E GR + 7 A$_fsmul$454 021F GR + 7 A$_fsmul$455 0222 GR + 7 A$_fsmul$456 0223 GR + 7 A$_fsmul$457 0225 GR + 7 A$_fsmul$458 0226 GR + 7 A$_fsmul$459 0227 GR + 7 A$_fsmul$460 0229 GR + 7 A$_fsmul$461 022A GR + 7 A$_fsmul$462 022B GR + 7 A$_fsmul$463 022D GR + 7 A$_fsmul$464 022E GR + 7 A$_fsmul$465 022F GR + 7 A$_fsmul$466 0231 GR + 7 A$_fsmul$467 0234 GR + 7 A$_fsmul$468 0237 GR + 7 A$_fsmul$469 023A GR + 7 A$_fsmul$470 023D GR + 7 A$_fsmul$471 023E GR + 7 A$_fsmul$472 0240 GR + 7 A$_fsmul$473 0241 GR + 7 A$_fsmul$474 0242 GR + 7 A$_fsmul$475 0244 GR + 7 A$_fsmul$476 0245 GR + 7 A$_fsmul$477 0246 GR + 7 A$_fsmul$478 0248 GR + 7 A$_fsmul$479 0249 GR + 7 A$_fsmul$480 024A GR + 7 A$_fsmul$481 024C GR + 7 A$_fsmul$482 024F GR + 7 A$_fsmul$483 0252 GR + 7 A$_fsmul$484 0254 GR + 7 A$_fsmul$485 0256 GR + 7 A$_fsmul$486 0257 GR + 7 A$_fsmul$487 0259 GR + 7 A$_fsmul$488 025B GR + 7 A$_fsmul$489 025E GR + 7 A$_fsmul$490 0260 GR + 7 A$_fsmul$491 0261 GR + 7 A$_fsmul$492 0262 GR + 7 A$_fsmul$493 0264 GR + 7 A$_fsmul$494 0265 GR + 7 A$_fsmul$495 0266 GR + 7 A$_fsmul$496 0268 GR + 7 A$_fsmul$497 0269 GR + 7 A$_fsmul$498 026A GR + 7 A$_fsmul$499 026C GR + 7 A$_fsmul$500 026D GR + 7 A$_fsmul$501 0270 GR + 7 A$_fsmul$502 0273 GR + 7 A$_fsmul$503 0276 GR + 7 A$_fsmul$504 0278 GR + 7 A$_fsmul$505 027B GR + 7 A$_fsmul$506 027E GR + 7 A$_fsmul$507 0281 GR + 7 A$_fsmul$508 0284 GR + 7 A$_fsmul$509 0286 GR + 7 A$_fsmul$510 0289 GR + 7 A$_fsmul$511 028C GR + 7 A$_fsmul$512 028F GR + 7 A$_fsmul$513 0292 GR + 7 A$_fsmul$514 0295 GR + 7 A$_fsmul$515 0296 GR + 7 A$_fsmul$516 0298 GR + 7 A$_fsmul$517 0299 GR + 7 A$_fsmul$518 029A GR + 7 A$_fsmul$519 029C GR + 7 A$_fsmul$520 029D GR + 7 A$_fsmul$521 029E GR + 7 A$_fsmul$522 02A0 GR + 7 A$_fsmul$523 02A1 GR + 7 A$_fsmul$524 02A2 GR + 7 A$_fsmul$525 02A4 GR + 7 A$_fsmul$526 02A7 GR + 7 A$_fsmul$527 02A9 GR + 7 A$_fsmul$528 02AB GR + 7 A$_fsmul$529 02AC GR + 7 A$_fsmul$530 02AE GR + 7 A$_fsmul$531 02B0 GR + 7 A$_fsmul$532 02B1 GR + 7 A$_fsmul$533 02B2 GR + 7 A$_fsmul$534 02B4 GR + 7 A$_fsmul$535 02B6 GR + 7 A$_fsmul$536 02B7 GR + 7 A$_fsmul$537 02B8 GR + 7 A$_fsmul$538 02BA GR + 7 A$_fsmul$539 02BC GR + 7 A$_fsmul$540 02BD GR + 7 A$_fsmul$542 02BE GR + 7 A$_fsmul$543 02C1 GR + 7 A$_fsmul$544 02C2 GR + 7 A$_fsmul$545 02C4 GR + 7 A$_fsmul$546 02C5 GR + 7 A$_fsmul$547 02C6 GR + 7 A$_fsmul$548 02C8 GR + 7 A$_fsmul$549 02C9 GR + 7 A$_fsmul$550 02CA GR + 7 A$_fsmul$551 02CC GR + 7 A$_fsmul$552 02CD GR + 7 A$_fsmul$553 02CE GR + 7 A$_fsmul$554 02D0 GR + 7 A$_fsmul$555 02D3 GR + 7 A$_fsmul$556 02D6 GR + 7 A$_fsmul$557 02D9 GR + 7 A$_fsmul$558 02DC GR + 7 A$_fsmul$559 02DD GR + 7 A$_fsmul$560 02DF GR + 7 A$_fsmul$561 02E0 GR + 7 A$_fsmul$562 02E1 GR + 7 A$_fsmul$563 02E3 GR + 7 A$_fsmul$564 02E4 GR + 7 A$_fsmul$565 02E5 GR + 7 A$_fsmul$566 02E7 GR + 7 A$_fsmul$567 02E8 GR + 7 A$_fsmul$568 02E9 GR + 7 A$_fsmul$569 02EB GR + 7 A$_fsmul$570 02EE GR + 7 A$_fsmul$571 02F1 GR + 7 A$_fsmul$572 02F3 GR + 7 A$_fsmul$573 02F5 GR + 7 A$_fsmul$574 02F6 GR + 7 A$_fsmul$575 02F8 GR + 7 A$_fsmul$576 02FA GR + 7 A$_fsmul$577 02FD GR + 7 A$_fsmul$578 02FF GR + 7 A$_fsmul$579 0300 GR + 7 A$_fsmul$580 0301 GR + 7 A$_fsmul$581 0303 GR + 7 A$_fsmul$582 0304 GR + 7 A$_fsmul$583 0305 GR + 7 A$_fsmul$584 0307 GR + 7 A$_fsmul$585 0308 GR + 7 A$_fsmul$586 0309 GR + 7 A$_fsmul$587 030B GR + 7 A$_fsmul$588 030C GR + 7 A$_fsmul$589 030F GR + 7 A$_fsmul$590 0312 GR + 7 A$_fsmul$591 0315 GR + 7 A$_fsmul$592 0317 GR + 7 A$_fsmul$593 031A GR + 7 A$_fsmul$594 031D GR + 7 A$_fsmul$595 0320 GR + 7 A$_fsmul$596 0323 GR + 7 A$_fsmul$597 0325 GR + 7 A$_fsmul$598 0328 GR + 7 A$_fsmul$599 032B GR + 7 A$_fsmul$600 032E GR + 7 A$_fsmul$601 0331 GR + 7 A$_fsmul$602 0334 GR + 7 A$_fsmul$603 0335 GR + 7 A$_fsmul$604 0337 GR + 7 A$_fsmul$605 0338 GR + 7 A$_fsmul$606 0339 GR + 7 A$_fsmul$607 033B GR + 7 A$_fsmul$608 033C GR + 7 A$_fsmul$609 033D GR + 7 A$_fsmul$610 033F GR + 7 A$_fsmul$611 0340 GR + 7 A$_fsmul$612 0341 GR + 7 A$_fsmul$613 0343 GR + 7 A$_fsmul$614 0346 GR + 7 A$_fsmul$615 0348 GR + 7 A$_fsmul$616 034A GR + 7 A$_fsmul$617 034B GR + 7 A$_fsmul$618 034D GR + 7 A$_fsmul$619 034F GR + 7 A$_fsmul$620 0350 GR + 7 A$_fsmul$621 0351 GR + 7 A$_fsmul$622 0353 GR + 7 A$_fsmul$623 0355 GR + 7 A$_fsmul$624 0356 GR + 7 A$_fsmul$625 0357 GR + 7 A$_fsmul$626 0359 GR + 7 A$_fsmul$627 035B GR + 7 A$_fsmul$628 035C GR + 7 A$_fsmul$630 035D GR + 7 A$_fsmul$631 0360 GR + 7 A$_fsmul$632 0361 GR + 7 A$_fsmul$633 0363 GR + 7 A$_fsmul$634 0364 GR + 7 A$_fsmul$635 0365 GR + 7 A$_fsmul$636 0367 GR + 7 A$_fsmul$637 0368 GR + 7 A$_fsmul$638 0369 GR + 7 A$_fsmul$639 036B GR + 7 A$_fsmul$640 036C GR + 7 A$_fsmul$642 036D GR + 7 A$_fsmul$643 036F GR + 7 A$_fsmul$644 0372 GR + 7 A$_fsmul$647 0375 GR + 7 A$_fsmul$648 0378 GR + 7 A$_fsmul$649 0379 GR + 7 A$_fsmul$650 037B GR + 7 A$_fsmul$651 037C GR + 7 A$_fsmul$652 037D GR + 7 A$_fsmul$653 037F GR + 7 A$_fsmul$654 0380 GR + 7 A$_fsmul$655 0381 GR + 7 A$_fsmul$656 0383 GR + 7 A$_fsmul$657 0384 GR + 7 A$_fsmul$658 0385 GR + 7 A$_fsmul$659 0387 GR + 7 A$_fsmul$660 038A GR + 7 A$_fsmul$661 038C GR + 7 A$_fsmul$662 038E GR + 7 A$_fsmul$664 038F GR + 7 A$_fsmul$665 0390 GR + 7 A$_fsmul$666 0392 GR + 7 A$_fsmul$667 0393 GR + 7 A$_fsmul$669 0394 GR + 7 A$_fsmul$670 0395 GR + 7 A$_fsmul$671 0397 GR + 7 A$_fsmul$672 0398 GR + 7 A$_fsmul$674 0399 GR + 7 A$_fsmul$675 039A GR + 7 A$_fsmul$676 039C GR + 7 A$_fsmul$677 039D GR + 7 A$_fsmul$679 039E GR + 7 A$_fsmul$680 03A1 GR + 7 A$_fsmul$681 03A2 GR + 7 A$_fsmul$682 03A4 GR + 7 A$_fsmul$683 03A5 GR + 7 A$_fsmul$684 03A6 GR + 7 A$_fsmul$685 03A8 GR + 7 A$_fsmul$686 03A9 GR + 7 A$_fsmul$687 03AA GR + 7 A$_fsmul$688 03AC GR + 7 A$_fsmul$689 03AD GR + 7 A$_fsmul$690 03AE GR + 7 A$_fsmul$691 03B0 GR + 7 A$_fsmul$692 03B3 GR + 7 A$_fsmul$693 03B6 GR + 7 A$_fsmul$694 03B9 GR + 7 A$_fsmul$695 03BC GR + 7 A$_fsmul$696 03BF GR + 7 A$_fsmul$697 03C1 GR + 7 A$_fsmul$698 03C2 GR + 7 A$_fsmul$699 03C3 GR + 7 A$_fsmul$700 03C5 GR + 7 A$_fsmul$701 03C6 GR + 7 A$_fsmul$702 03C7 GR + 7 A$_fsmul$703 03C9 GR + 7 A$_fsmul$704 03CA GR + 7 A$_fsmul$705 03CB GR + 7 A$_fsmul$706 03CD GR + 7 A$_fsmul$707 03CE GR + 7 A$_fsmul$710 03D1 GR + 7 A$_fsmul$711 03D4 GR + 7 A$_fsmul$712 03D5 GR + 7 A$_fsmul$713 03D7 GR + 7 A$_fsmul$714 03D8 GR + 7 A$_fsmul$715 03D9 GR + 7 A$_fsmul$716 03DB GR + 7 A$_fsmul$717 03DC GR + 7 A$_fsmul$718 03DD GR + 7 A$_fsmul$719 03DF GR + 7 A$_fsmul$720 03E0 GR + 7 A$_fsmul$721 03E1 GR + 7 A$_fsmul$722 03E3 GR + 7 A$_fsmul$723 03E6 GR + 7 A$_fsmul$724 03E8 GR + 7 A$_fsmul$725 03EA GR + 7 A$_fsmul$727 03EB GR + 7 A$_fsmul$728 03EC GR + 7 A$_fsmul$729 03EE GR + 7 A$_fsmul$730 03EF GR + 7 A$_fsmul$732 03F0 GR + 7 A$_fsmul$733 03F1 GR + 7 A$_fsmul$734 03F3 GR + 7 A$_fsmul$735 03F4 GR + 7 A$_fsmul$737 03F5 GR + 7 A$_fsmul$738 03F6 GR + 7 A$_fsmul$739 03F8 GR + 7 A$_fsmul$740 03F9 GR + 7 A$_fsmul$742 03FA GR + 7 A$_fsmul$743 03FD GR + 7 A$_fsmul$744 03FE GR + 7 A$_fsmul$745 0400 GR + 7 A$_fsmul$746 0401 GR + 7 A$_fsmul$747 0402 GR + 7 A$_fsmul$748 0404 GR + 7 A$_fsmul$749 0405 GR + 7 A$_fsmul$750 0406 GR + 7 A$_fsmul$751 0408 GR + 7 A$_fsmul$752 0409 GR + 7 A$_fsmul$753 040A GR + 7 A$_fsmul$754 040C GR + 7 A$_fsmul$755 040E GR + 7 A$_fsmul$756 0410 GR + 7 A$_fsmul$757 0412 GR + 7 A$_fsmul$758 0413 GR + 7 A$_fsmul$759 0415 GR + 7 A$_fsmul$760 0416 GR + 7 A$_fsmul$761 0418 GR + 7 A$_fsmul$762 041A GR + 7 A$_fsmul$763 041C GR + 7 A$_fsmul$764 041E GR + 7 A$_fsmul$765 0420 GR + 7 A$_fsmul$766 0422 GR + 7 A$_fsmul$767 0424 GR + 7 A$_fsmul$768 0426 GR + 7 A$_fsmul$769 0428 GR + 7 A$_fsmul$770 042A GR + 7 A$_fsmul$771 042B GR + 7 A$_fsmul$772 042D GR + 7 A$_fsmul$773 042E GR + 7 A$_fsmul$774 0430 GR + 7 A$_fsmul$775 0432 GR + 7 A$_fsmul$776 0434 GR + 7 A$_fsmul$777 0437 GR + 7 A$_fsmul$778 0439 GR + 7 A$_fsmul$779 043A GR + 7 A$_fsmul$780 043B GR + 7 A$_fsmul$781 043D GR + 7 A$_fsmul$782 043E GR + 7 A$_fsmul$783 043F GR + 7 A$_fsmul$784 0441 GR + 7 A$_fsmul$785 0442 GR + 7 A$_fsmul$786 0443 GR + 7 A$_fsmul$787 0445 GR + 7 A$_fsmul$789 0446 GR + 7 A$_fsmul$79 0000 GR + 7 A$_fsmul$790 0449 GR + 7 A$_fsmul$791 044A GR + 7 A$_fsmul$792 044C GR + 7 A$_fsmul$793 044D GR + 7 A$_fsmul$794 044E GR + 7 A$_fsmul$795 044F GR + 7 A$_fsmul$796 0451 GR + 7 A$_fsmul$797 0452 GR + 7 A$_fsmul$798 0455 GR + 7 A$_fsmul$799 0456 GR + 7 A$_fsmul$80 0002 GR + 7 A$_fsmul$800 0457 GR + 7 A$_fsmul$801 0458 GR + 7 A$_fsmul$802 0459 GR + 7 A$_fsmul$805 045A GR + 7 A$_fsmul$806 045D GR + 7 A$_fsmul$807 045E GR + 7 A$_fsmul$808 0460 GR + 7 A$_fsmul$809 0461 GR + 7 A$_fsmul$81 0004 GR + 7 A$_fsmul$810 0462 GR + 7 A$_fsmul$811 0464 GR + 7 A$_fsmul$812 0465 GR + 7 A$_fsmul$813 0466 GR + 7 A$_fsmul$814 0468 GR + 7 A$_fsmul$815 0469 GR + 7 A$_fsmul$816 046A GR + 7 A$_fsmul$817 046C GR + 7 A$_fsmul$818 046F GR + 7 A$_fsmul$819 0471 GR + 7 A$_fsmul$82 0006 GR + 7 A$_fsmul$820 0472 GR + 7 A$_fsmul$821 0473 GR + 7 A$_fsmul$822 0475 GR + 7 A$_fsmul$823 0476 GR + 7 A$_fsmul$824 0478 GR + 7 A$_fsmul$825 047A GR + 7 A$_fsmul$826 047B GR + 7 A$_fsmul$827 047C GR + 7 A$_fsmul$828 047D GR + 7 A$_fsmul$829 047F GR + 7 A$_fsmul$83 0008 GR + 7 A$_fsmul$831 0480 GR + 7 A$_fsmul$832 0483 GR + 7 A$_fsmul$834 0484 GR + 7 A$_fsmul$836 0485 GR + 7 A$_fsmul$838 0487 GR + 7 A$_fsmul$839 048A GR + 7 A$_fsmul$84 000B GR + 7 A$_fsmul$840 048D GR + 7 A$_fsmul$841 0490 GR + 7 A$_fsmul$843 0493 GR + 7 A$_fsmul$845 0495 GR + 7 A$_fsmul$846 0496 GR + 7 A$_fsmul$847 0498 GR + 7 A$_fsmul$848 049A GR + 7 A$_fsmul$849 049C GR + 7 A$_fsmul$85 000D GR + 7 A$_fsmul$851 049E GR + 7 A$_fsmul$852 04A1 GR + 7 A$_fsmul$853 04A2 GR + 7 A$_fsmul$854 04A3 GR + 7 A$_fsmul$855 04A4 GR + 7 A$_fsmul$856 04A5 GR + 7 A$_fsmul$857 04A6 GR + 7 A$_fsmul$858 04A8 GR + 7 A$_fsmul$859 04AA GR + 7 A$_fsmul$86 000E GR + 7 A$_fsmul$860 04AD GR + 7 A$_fsmul$861 04B0 GR + 7 A$_fsmul$862 04B3 GR + 7 A$_fsmul$863 04B5 GR + 7 A$_fsmul$864 04B7 GR + 7 A$_fsmul$865 04B9 GR + 7 A$_fsmul$866 04BB GR + 7 A$_fsmul$867 04BC GR + 7 A$_fsmul$868 04BE GR + 7 A$_fsmul$869 04BF GR + 7 A$_fsmul$87 0010 GR + 7 A$_fsmul$870 04C1 GR + 7 A$_fsmul$872 04C3 GR + 7 A$_fsmul$873 04C4 GR + 7 A$_fsmul$875 04C6 GR + 7 A$_fsmul$876 04C8 GR + 7 A$_fsmul$877 04CA GR + 7 A$_fsmul$878 04CC GR + 7 A$_fsmul$879 04CE GR + 7 A$_fsmul$88 0011 GR + 7 A$_fsmul$880 04D0 GR + 7 A$_fsmul$881 04D2 GR + 7 A$_fsmul$882 04D4 GR + 7 A$_fsmul$883 04D6 GR + 7 A$_fsmul$884 04D9 GR + 7 A$_fsmul$885 04DA GR + 7 A$_fsmul$886 04DC GR + 7 A$_fsmul$887 04DD GR + 7 A$_fsmul$888 04DE GR + 7 A$_fsmul$889 04E0 GR + 7 A$_fsmul$89 0012 GR + 7 A$_fsmul$890 04E1 GR + 7 A$_fsmul$891 04E2 GR + 7 A$_fsmul$892 04E4 GR + 7 A$_fsmul$893 04E5 GR + 7 A$_fsmul$894 04E6 GR + 7 A$_fsmul$895 04E8 GR + 7 A$_fsmul$896 04EA GR + 7 A$_fsmul$897 04EC GR + 7 A$_fsmul$898 04EE GR + 7 A$_fsmul$899 04F0 GR + 7 A$_fsmul$90 0014 GR + 7 A$_fsmul$900 04F2 GR + 7 A$_fsmul$901 04F4 GR + 7 A$_fsmul$902 04F6 GR + 7 A$_fsmul$903 04F8 GR + 7 A$_fsmul$904 04FB GR + 7 A$_fsmul$905 04FD GR + 7 A$_fsmul$906 04FE GR + 7 A$_fsmul$907 04FF GR + 7 A$_fsmul$908 0501 GR + 7 A$_fsmul$909 0502 GR + 7 A$_fsmul$91 0015 GR + 7 A$_fsmul$910 0503 GR + 7 A$_fsmul$911 0505 GR + 7 A$_fsmul$912 0506 GR + 7 A$_fsmul$913 0507 GR + 7 A$_fsmul$914 0509 GR + 7 A$_fsmul$916 050A GR + 7 A$_fsmul$917 050D GR + 7 A$_fsmul$918 050E GR + 7 A$_fsmul$919 0510 GR + 7 A$_fsmul$92 0016 GR + 7 A$_fsmul$920 0511 GR + 7 A$_fsmul$921 0512 GR + 7 A$_fsmul$922 0514 GR + 7 A$_fsmul$923 0515 GR + 7 A$_fsmul$924 0516 GR + 7 A$_fsmul$925 0518 GR + 7 A$_fsmul$926 0519 GR + 7 A$_fsmul$928 051A GR + 7 A$_fsmul$929 051C GR + 7 A$_fsmul$93 0018 GR + 7 A$_fsmul$930 051F GR + 7 A$_fsmul$931 0522 GR + 7 A$_fsmul$935 0525 GR + 7 A$_fsmul$94 0019 GR + 7 A$_fsmul$96 001A GR + 7 A$_fsmul$97 001D GR + 7 A$_fsmul$98 001E GR + 7 A$_fsmul$99 001F GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fsmul.c$126$1$1 = 0525 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fsmul$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fsmul$0$0 = 0525 GR + 7 ___fsmul 0000 GR + 5 ___fsmul_PARM_2 0000 GR + 5 ___fsmul_a1_1_1 0004 R + 5 ___fsmul_exp_1_1 0014 R + 5 ___fsmul_fl1_1_1 0008 R + 5 ___fsmul_fl2_1_1 000C R + 5 ___fsmul_result_1_1 0010 R + 5 ___fsmul_sign_1_1 0016 R + 1 ___fsmul_sloc0_1_0 0000 R + 1 ___fsmul_sloc1_1_0 0004 R + __mulslong **** GX + __mulslong_PARM_2 **** GX + __mululong **** GX + __mululong_PARM_2 **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 17 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 526 flags 20 diff --git a/device/lib/_fsneq.c b/device/lib/_fsneq.c new file mode 100644 index 00000000..8d74dee7 --- /dev/null +++ b/device/lib/_fsneq.c @@ -0,0 +1,88 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +union float_long + { + float f; + long l; + }; + +/* compare two floats */ +char +__fsneq (float a1, float a2) +{ + volatile union float_long fl1, fl2; + + fl1.f = a1; + fl2.f = a2; + + if (SIGN (fl1.l) && SIGN (fl2.l)) + { + fl1.l ^= SIGNBIT; + fl2.l ^= SIGNBIT; + } + if (fl1.l == fl2.l) + return (0); + return (1); +} diff --git a/device/lib/_fsneq.lst b/device/lib/_fsneq.lst new file mode 100644 index 00000000..e69bca99 --- /dev/null +++ b/device/lib/_fsneq.lst @@ -0,0 +1,282 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fsneq + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fsneq_PARM_2 + 11 .globl ___fsneq + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 ___fsneq_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 ___fsneq_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 ___fsneq_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 ___fsneq_a1_1_1: + 0004 45 .ds 0x0004 + 0008 46 ___fsneq_fl1_1_1: + 0008 47 .ds 0x0004 + 000C 48 ___fsneq_fl2_1_1: + 000C 49 .ds 0x0004 + 50 ;-------------------------------------------------------- + 51 ; global & static initialisations + 52 ;-------------------------------------------------------- + 53 .area GSINIT (CODE) + 54 ;-------------------------------------------------------- + 55 ; code + 56 ;-------------------------------------------------------- + 57 .area CSEG (CODE) + 0000 58 G$__fsneq$0$0 ==. + 59 ; _fsneq.c 73 + 60 ; ----------------------------------------- + 61 ; function __fsneq + 62 ; ----------------------------------------- + 0000 63 ___fsneq: + 0002 64 ar2 = 0x02 + 0003 65 ar3 = 0x03 + 0004 66 ar4 = 0x04 + 0005 67 ar5 = 0x05 + 0006 68 ar6 = 0x06 + 0007 69 ar7 = 0x07 + 0000 70 ar0 = 0x00 + 0001 71 ar1 = 0x01 + 72 ; _fsneq.c 87 + 0000 C0 E0 73 push acc + 0002 C0 F0 74 push b + 0004 C0 83 75 push dph + 0006 C0 82 76 push dpl + 0008 90s00r04 77 mov dptr,#___fsneq_a1_1_1 + 000B D0 E0 78 pop acc + 000D F0 79 movx @dptr,a + 000E D0 E0 80 pop acc + 0010 A3 81 inc dptr + 0011 F0 82 movx @dptr,a + 0012 D0 E0 83 pop acc + 0014 A3 84 inc dptr + 0015 F0 85 movx @dptr,a + 0016 D0 E0 86 pop acc + 0018 A3 87 inc dptr + 0019 F0 88 movx @dptr,a + 89 ; _fsneq.c 77 + 001A 90s00r04 90 mov dptr,#___fsneq_a1_1_1 + 001D E0 91 movx a,@dptr + 001E FA 92 mov r2,a + 001F A3 93 inc dptr + 0020 E0 94 movx a,@dptr + 0021 FB 95 mov r3,a + 0022 A3 96 inc dptr + 0023 E0 97 movx a,@dptr + 0024 FC 98 mov r4,a + 0025 A3 99 inc dptr + 0026 E0 100 movx a,@dptr + 0027 FD 101 mov r5,a + 0028 90s00r08 102 mov dptr,#(___fsneq_fl1_1_1) + 002B EA 103 mov a,r2 + 002C F0 104 movx @dptr,a + 002D A3 105 inc dptr + 002E EB 106 mov a,r3 + 002F F0 107 movx @dptr,a + 0030 A3 108 inc dptr + 0031 EC 109 mov a,r4 + 0032 F0 110 movx @dptr,a + 0033 A3 111 inc dptr + 0034 ED 112 mov a,r5 + 0035 F0 113 movx @dptr,a + 114 ; _fsneq.c 78 + 0036 90s00r00 115 mov dptr,#___fsneq_PARM_2 + 0039 E0 116 movx a,@dptr + 003A FA 117 mov r2,a + 003B A3 118 inc dptr + 003C E0 119 movx a,@dptr + 003D FB 120 mov r3,a + 003E A3 121 inc dptr + 003F E0 122 movx a,@dptr + 0040 FC 123 mov r4,a + 0041 A3 124 inc dptr + 0042 E0 125 movx a,@dptr + 0043 FD 126 mov r5,a + 0044 90s00r0C 127 mov dptr,#(___fsneq_fl2_1_1) + 0047 EA 128 mov a,r2 + 0048 F0 129 movx @dptr,a + 0049 A3 130 inc dptr + 004A EB 131 mov a,r3 + 004B F0 132 movx @dptr,a + 004C A3 133 inc dptr + 004D EC 134 mov a,r4 + 004E F0 135 movx @dptr,a + 004F A3 136 inc dptr + 0050 ED 137 mov a,r5 + 0051 F0 138 movx @dptr,a + 139 ; _fsneq.c 80 + 0052 90s00r08 140 mov dptr,#(___fsneq_fl1_1_1) + 0055 E0 141 movx a,@dptr + 0056 FA 142 mov r2,a + 0057 A3 143 inc dptr + 0058 E0 144 movx a,@dptr + 0059 FB 145 mov r3,a + 005A A3 146 inc dptr + 005B E0 147 movx a,@dptr + 005C FC 148 mov r4,a + 005D A3 149 inc dptr + 005E E0 150 movx a,@dptr + 151 ; Peephole 105 removed redundant mov + 005F FD 152 mov r5,a + 0060 23 153 rl a + 0061 54 01 154 anl a,#0x01 + 155 ; Peephole 105 removed redundant mov + 0063 FA 156 mov r2,a + 0064 70 03 157 jnz 00111$ + 0066 02s00rCE 158 ljmp 00102$ + 0069 159 00111$: + 0069 90s00r0C 160 mov dptr,#(___fsneq_fl2_1_1) + 006C E0 161 movx a,@dptr + 006D FA 162 mov r2,a + 006E A3 163 inc dptr + 006F E0 164 movx a,@dptr + 0070 FE 165 mov r6,a + 0071 A3 166 inc dptr + 0072 E0 167 movx a,@dptr + 0073 FF 168 mov r7,a + 0074 A3 169 inc dptr + 0075 E0 170 movx a,@dptr + 171 ; Peephole 105 removed redundant mov + 0076 F8 172 mov r0,a + 0077 23 173 rl a + 0078 54 01 174 anl a,#0x01 + 175 ; Peephole 105 removed redundant mov + 007A FA 176 mov r2,a + 007B 70 03 177 jnz 00112$ + 007D 02s00rCE 178 ljmp 00102$ + 0080 179 00112$: + 180 ; _fsneq.c 82 + 0080 90s00r08 181 mov dptr,#(___fsneq_fl1_1_1) + 0083 E0 182 movx a,@dptr + 0084 F5*00 183 mov ___fsneq_sloc0_1_0,a + 0086 A3 184 inc dptr + 0087 E0 185 movx a,@dptr + 0088 F5*01 186 mov (___fsneq_sloc0_1_0 + 1),a + 008A A3 187 inc dptr + 008B E0 188 movx a,@dptr + 008C F5*02 189 mov (___fsneq_sloc0_1_0 + 2),a + 008E A3 190 inc dptr + 008F E0 191 movx a,@dptr + 0090 F5*03 192 mov (___fsneq_sloc0_1_0 + 3),a + 0092 63r03 80 193 xrl (___fsneq_sloc0_1_0 + 3),#0x80 + 0095 90s00r08 194 mov dptr,#(___fsneq_fl1_1_1) + 0098 E5*00 195 mov a,___fsneq_sloc0_1_0 + 009A F0 196 movx @dptr,a + 009B A3 197 inc dptr + 009C E5*01 198 mov a,(___fsneq_sloc0_1_0 + 1) + 009E F0 199 movx @dptr,a + 009F A3 200 inc dptr + 00A0 E5*02 201 mov a,(___fsneq_sloc0_1_0 + 2) + 00A2 F0 202 movx @dptr,a + 00A3 A3 203 inc dptr + 00A4 E5*03 204 mov a,(___fsneq_sloc0_1_0 + 3) + 00A6 F0 205 movx @dptr,a + 206 ; _fsneq.c 83 + 00A7 90s00r0C 207 mov dptr,#(___fsneq_fl2_1_1) + 00AA E0 208 movx a,@dptr + 00AB F5*00 209 mov ___fsneq_sloc0_1_0,a + 00AD A3 210 inc dptr + 00AE E0 211 movx a,@dptr + 00AF F5*01 212 mov (___fsneq_sloc0_1_0 + 1),a + 00B1 A3 213 inc dptr + 00B2 E0 214 movx a,@dptr + 00B3 F5*02 215 mov (___fsneq_sloc0_1_0 + 2),a + 00B5 A3 216 inc dptr + 00B6 E0 217 movx a,@dptr + 00B7 F5*03 218 mov (___fsneq_sloc0_1_0 + 3),a + 00B9 63r03 80 219 xrl (___fsneq_sloc0_1_0 + 3),#0x80 + 00BC 90s00r0C 220 mov dptr,#(___fsneq_fl2_1_1) + 00BF E5*00 221 mov a,___fsneq_sloc0_1_0 + 00C1 F0 222 movx @dptr,a + 00C2 A3 223 inc dptr + 00C3 E5*01 224 mov a,(___fsneq_sloc0_1_0 + 1) + 00C5 F0 225 movx @dptr,a + 00C6 A3 226 inc dptr + 00C7 E5*02 227 mov a,(___fsneq_sloc0_1_0 + 2) + 00C9 F0 228 movx @dptr,a + 00CA A3 229 inc dptr + 00CB E5*03 230 mov a,(___fsneq_sloc0_1_0 + 3) + 00CD F0 231 movx @dptr,a + 00CE 232 00102$: + 233 ; _fsneq.c 85 + 00CE 90s00r08 234 mov dptr,#(___fsneq_fl1_1_1) + 00D1 E0 235 movx a,@dptr + 00D2 F5*00 236 mov ___fsneq_sloc0_1_0,a + 00D4 A3 237 inc dptr + 00D5 E0 238 movx a,@dptr + 00D6 F5*01 239 mov (___fsneq_sloc0_1_0 + 1),a + 00D8 A3 240 inc dptr + 00D9 E0 241 movx a,@dptr + 00DA F5*02 242 mov (___fsneq_sloc0_1_0 + 2),a + 00DC A3 243 inc dptr + 00DD E0 244 movx a,@dptr + 00DE F5*03 245 mov (___fsneq_sloc0_1_0 + 3),a + 00E0 90s00r0C 246 mov dptr,#(___fsneq_fl2_1_1) + 00E3 E0 247 movx a,@dptr + 00E4 F5*04 248 mov ___fsneq_sloc1_1_0,a + 00E6 A3 249 inc dptr + 00E7 E0 250 movx a,@dptr + 00E8 F5*05 251 mov (___fsneq_sloc1_1_0 + 1),a + 00EA A3 252 inc dptr + 00EB E0 253 movx a,@dptr + 00EC F5*06 254 mov (___fsneq_sloc1_1_0 + 2),a + 00EE A3 255 inc dptr + 00EF E0 256 movx a,@dptr + 00F0 F5*07 257 mov (___fsneq_sloc1_1_0 + 3),a + 00F2 E5*00 258 mov a,___fsneq_sloc0_1_0 + 259 ; Peephole 132 changed ljmp to sjmp + 260 ; Peephole 193 optimized misc jump sequence + 00F4 B5*04 14 261 cjne a,___fsneq_sloc1_1_0,00105$ + 00F7 E5*01 262 mov a,(___fsneq_sloc0_1_0 + 1) + 00F9 B5*05 0F 263 cjne a,(___fsneq_sloc1_1_0 + 1),00105$ + 00FC E5*02 264 mov a,(___fsneq_sloc0_1_0 + 2) + 00FE B5*06 0A 265 cjne a,(___fsneq_sloc1_1_0 + 2),00105$ + 0101 E5*03 266 mov a,(___fsneq_sloc0_1_0 + 3) + 0103 B5*07 05 267 cjne a,(___fsneq_sloc1_1_0 + 3),00105$ + 268 ; Peephole 201 removed redundant sjmp + 0106 269 00113$: + 0106 270 00114$: + 271 ; _fsneq.c 86 + 0106 75 82 00 272 mov dpl,#0x00 + 273 ; Peephole 132 changed ljmp to sjmp + 0109 80 03 274 sjmp 00106$ + 010B 275 00105$: + 276 ; _fsneq.c 87 + 010B 75 82 01 277 mov dpl,#0x01 + 010E 278 00106$: + 010E 279 C$_fsneq.c$88$1$1 ==. + 010E 280 XG$__fsneq$0$0 ==. + 010E 22 281 ret + 282 .area CSEG (CODE) diff --git a/device/lib/_fsneq.sym b/device/lib/_fsneq.sym new file mode 100644 index 00000000..a9bcc9b6 --- /dev/null +++ b/device/lib/_fsneq.sym @@ -0,0 +1,555 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fsneq$100 0026 GR + 7 A$_fsneq$101 0027 GR + 7 A$_fsneq$102 0028 GR + 7 A$_fsneq$103 002B GR + 7 A$_fsneq$104 002C GR + 7 A$_fsneq$105 002D GR + 7 A$_fsneq$106 002E GR + 7 A$_fsneq$107 002F GR + 7 A$_fsneq$108 0030 GR + 7 A$_fsneq$109 0031 GR + 7 A$_fsneq$110 0032 GR + 7 A$_fsneq$111 0033 GR + 7 A$_fsneq$112 0034 GR + 7 A$_fsneq$113 0035 GR + 7 A$_fsneq$115 0036 GR + 7 A$_fsneq$116 0039 GR + 7 A$_fsneq$117 003A GR + 7 A$_fsneq$118 003B GR + 7 A$_fsneq$119 003C GR + 7 A$_fsneq$120 003D GR + 7 A$_fsneq$121 003E GR + 7 A$_fsneq$122 003F GR + 7 A$_fsneq$123 0040 GR + 7 A$_fsneq$124 0041 GR + 7 A$_fsneq$125 0042 GR + 7 A$_fsneq$126 0043 GR + 7 A$_fsneq$127 0044 GR + 7 A$_fsneq$128 0047 GR + 7 A$_fsneq$129 0048 GR + 7 A$_fsneq$130 0049 GR + 7 A$_fsneq$131 004A GR + 7 A$_fsneq$132 004B GR + 7 A$_fsneq$133 004C GR + 7 A$_fsneq$134 004D GR + 7 A$_fsneq$135 004E GR + 7 A$_fsneq$136 004F GR + 7 A$_fsneq$137 0050 GR + 7 A$_fsneq$138 0051 GR + 7 A$_fsneq$140 0052 GR + 7 A$_fsneq$141 0055 GR + 7 A$_fsneq$142 0056 GR + 7 A$_fsneq$143 0057 GR + 7 A$_fsneq$144 0058 GR + 7 A$_fsneq$145 0059 GR + 7 A$_fsneq$146 005A GR + 7 A$_fsneq$147 005B GR + 7 A$_fsneq$148 005C GR + 7 A$_fsneq$149 005D GR + 7 A$_fsneq$150 005E GR + 7 A$_fsneq$152 005F GR + 7 A$_fsneq$153 0060 GR + 7 A$_fsneq$154 0061 GR + 7 A$_fsneq$156 0063 GR + 7 A$_fsneq$157 0064 GR + 7 A$_fsneq$158 0066 GR + 7 A$_fsneq$160 0069 GR + 7 A$_fsneq$161 006C GR + 7 A$_fsneq$162 006D GR + 7 A$_fsneq$163 006E GR + 7 A$_fsneq$164 006F GR + 7 A$_fsneq$165 0070 GR + 7 A$_fsneq$166 0071 GR + 7 A$_fsneq$167 0072 GR + 7 A$_fsneq$168 0073 GR + 7 A$_fsneq$169 0074 GR + 7 A$_fsneq$170 0075 GR + 7 A$_fsneq$172 0076 GR + 7 A$_fsneq$173 0077 GR + 7 A$_fsneq$174 0078 GR + 7 A$_fsneq$176 007A GR + 7 A$_fsneq$177 007B GR + 7 A$_fsneq$178 007D GR + 7 A$_fsneq$181 0080 GR + 7 A$_fsneq$182 0083 GR + 7 A$_fsneq$183 0084 GR + 7 A$_fsneq$184 0086 GR + 7 A$_fsneq$185 0087 GR + 7 A$_fsneq$186 0088 GR + 7 A$_fsneq$187 008A GR + 7 A$_fsneq$188 008B GR + 7 A$_fsneq$189 008C GR + 7 A$_fsneq$190 008E GR + 7 A$_fsneq$191 008F GR + 7 A$_fsneq$192 0090 GR + 7 A$_fsneq$193 0092 GR + 7 A$_fsneq$194 0095 GR + 7 A$_fsneq$195 0098 GR + 7 A$_fsneq$196 009A GR + 7 A$_fsneq$197 009B GR + 7 A$_fsneq$198 009C GR + 7 A$_fsneq$199 009E GR + 7 A$_fsneq$200 009F GR + 7 A$_fsneq$201 00A0 GR + 7 A$_fsneq$202 00A2 GR + 7 A$_fsneq$203 00A3 GR + 7 A$_fsneq$204 00A4 GR + 7 A$_fsneq$205 00A6 GR + 7 A$_fsneq$207 00A7 GR + 7 A$_fsneq$208 00AA GR + 7 A$_fsneq$209 00AB GR + 7 A$_fsneq$210 00AD GR + 7 A$_fsneq$211 00AE GR + 7 A$_fsneq$212 00AF GR + 7 A$_fsneq$213 00B1 GR + 7 A$_fsneq$214 00B2 GR + 7 A$_fsneq$215 00B3 GR + 7 A$_fsneq$216 00B5 GR + 7 A$_fsneq$217 00B6 GR + 7 A$_fsneq$218 00B7 GR + 7 A$_fsneq$219 00B9 GR + 7 A$_fsneq$220 00BC GR + 7 A$_fsneq$221 00BF GR + 7 A$_fsneq$222 00C1 GR + 7 A$_fsneq$223 00C2 GR + 7 A$_fsneq$224 00C3 GR + 7 A$_fsneq$225 00C5 GR + 7 A$_fsneq$226 00C6 GR + 7 A$_fsneq$227 00C7 GR + 7 A$_fsneq$228 00C9 GR + 7 A$_fsneq$229 00CA GR + 7 A$_fsneq$230 00CB GR + 7 A$_fsneq$231 00CD GR + 7 A$_fsneq$234 00CE GR + 7 A$_fsneq$235 00D1 GR + 7 A$_fsneq$236 00D2 GR + 7 A$_fsneq$237 00D4 GR + 7 A$_fsneq$238 00D5 GR + 7 A$_fsneq$239 00D6 GR + 7 A$_fsneq$240 00D8 GR + 7 A$_fsneq$241 00D9 GR + 7 A$_fsneq$242 00DA GR + 7 A$_fsneq$243 00DC GR + 7 A$_fsneq$244 00DD GR + 7 A$_fsneq$245 00DE GR + 7 A$_fsneq$246 00E0 GR + 7 A$_fsneq$247 00E3 GR + 7 A$_fsneq$248 00E4 GR + 7 A$_fsneq$249 00E6 GR + 7 A$_fsneq$250 00E7 GR + 7 A$_fsneq$251 00E8 GR + 7 A$_fsneq$252 00EA GR + 7 A$_fsneq$253 00EB GR + 7 A$_fsneq$254 00EC GR + 7 A$_fsneq$255 00EE GR + 7 A$_fsneq$256 00EF GR + 7 A$_fsneq$257 00F0 GR + 7 A$_fsneq$258 00F2 GR + 7 A$_fsneq$261 00F4 GR + 7 A$_fsneq$262 00F7 GR + 7 A$_fsneq$263 00F9 GR + 7 A$_fsneq$264 00FC GR + 7 A$_fsneq$265 00FE GR + 7 A$_fsneq$266 0101 GR + 7 A$_fsneq$267 0103 GR + 7 A$_fsneq$272 0106 GR + 7 A$_fsneq$274 0109 GR + 7 A$_fsneq$277 010B GR + 7 A$_fsneq$281 010E GR + 7 A$_fsneq$73 0000 GR + 7 A$_fsneq$74 0002 GR + 7 A$_fsneq$75 0004 GR + 7 A$_fsneq$76 0006 GR + 7 A$_fsneq$77 0008 GR + 7 A$_fsneq$78 000B GR + 7 A$_fsneq$79 000D GR + 7 A$_fsneq$80 000E GR + 7 A$_fsneq$81 0010 GR + 7 A$_fsneq$82 0011 GR + 7 A$_fsneq$83 0012 GR + 7 A$_fsneq$84 0014 GR + 7 A$_fsneq$85 0015 GR + 7 A$_fsneq$86 0016 GR + 7 A$_fsneq$87 0018 GR + 7 A$_fsneq$88 0019 GR + 7 A$_fsneq$90 001A GR + 7 A$_fsneq$91 001D GR + 7 A$_fsneq$92 001E GR + 7 A$_fsneq$93 001F GR + 7 A$_fsneq$94 0020 GR + 7 A$_fsneq$95 0021 GR + 7 A$_fsneq$96 0022 GR + 7 A$_fsneq$97 0023 GR + 7 A$_fsneq$98 0024 GR + 7 A$_fsneq$99 0025 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fsneq.c$88$1$1 = 010E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fsneq$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fsneq$0$0 = 010E GR + 7 ___fsneq 0000 GR + 5 ___fsneq_PARM_2 0000 GR + 5 ___fsneq_a1_1_1 0004 R + 5 ___fsneq_fl1_1_1 0008 R + 5 ___fsneq_fl2_1_1 000C R + 1 ___fsneq_sloc0_1_0 0000 R + 1 ___fsneq_sloc1_1_0 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 10 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 10F flags 20 diff --git a/device/lib/_fssub.c b/device/lib/_fssub.c new file mode 100644 index 00000000..43e10b29 --- /dev/null +++ b/device/lib/_fssub.c @@ -0,0 +1,97 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +/* subtract two floats */ +float +__fssub (float a1, float a2) +{ + volatile union float_long fl1, fl2; + + fl1.f = a1; + fl2.f = a2; + + /* check for zero args */ + if (!fl2.l) + return (fl1.f); + if (!fl1.l) + return (-fl2.f); + + /* twiddle sign bit and add */ + fl2.l ^= SIGNBIT; + return fl1.f + fl2.f; +} diff --git a/device/lib/_fssub.lst b/device/lib/_fssub.lst new file mode 100644 index 00000000..52dcd24f --- /dev/null +++ b/device/lib/_fssub.lst @@ -0,0 +1,289 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _fssub + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___fssub_PARM_2 + 11 .globl ___fssub + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 ___fssub_PARM_2: + 0000 39 .ds 0x0004 + 0004 40 ___fssub_a1_1_1: + 0004 41 .ds 0x0004 + 0008 42 ___fssub_fl1_1_1: + 0008 43 .ds 0x0004 + 000C 44 ___fssub_fl2_1_1: + 000C 45 .ds 0x0004 + 46 ;-------------------------------------------------------- + 47 ; global & static initialisations + 48 ;-------------------------------------------------------- + 49 .area GSINIT (CODE) + 50 ;-------------------------------------------------------- + 51 ; code + 52 ;-------------------------------------------------------- + 53 .area CSEG (CODE) + 0000 54 G$__fssub$0$0 ==. + 55 ; _fssub.c 81 + 56 ; ----------------------------------------- + 57 ; function __fssub + 58 ; ----------------------------------------- + 0000 59 ___fssub: + 0002 60 ar2 = 0x02 + 0003 61 ar3 = 0x03 + 0004 62 ar4 = 0x04 + 0005 63 ar5 = 0x05 + 0006 64 ar6 = 0x06 + 0007 65 ar7 = 0x07 + 0000 66 ar0 = 0x00 + 0001 67 ar1 = 0x01 + 68 ; _fssub.c 96 + 0000 C0 E0 69 push acc + 0002 C0 F0 70 push b + 0004 C0 83 71 push dph + 0006 C0 82 72 push dpl + 0008 90s00r04 73 mov dptr,#___fssub_a1_1_1 + 000B D0 E0 74 pop acc + 000D F0 75 movx @dptr,a + 000E D0 E0 76 pop acc + 0010 A3 77 inc dptr + 0011 F0 78 movx @dptr,a + 0012 D0 E0 79 pop acc + 0014 A3 80 inc dptr + 0015 F0 81 movx @dptr,a + 0016 D0 E0 82 pop acc + 0018 A3 83 inc dptr + 0019 F0 84 movx @dptr,a + 85 ; _fssub.c 85 + 001A 90s00r04 86 mov dptr,#___fssub_a1_1_1 + 001D E0 87 movx a,@dptr + 001E FA 88 mov r2,a + 001F A3 89 inc dptr + 0020 E0 90 movx a,@dptr + 0021 FB 91 mov r3,a + 0022 A3 92 inc dptr + 0023 E0 93 movx a,@dptr + 0024 FC 94 mov r4,a + 0025 A3 95 inc dptr + 0026 E0 96 movx a,@dptr + 0027 FD 97 mov r5,a + 0028 90s00r08 98 mov dptr,#(___fssub_fl1_1_1) + 002B EA 99 mov a,r2 + 002C F0 100 movx @dptr,a + 002D A3 101 inc dptr + 002E EB 102 mov a,r3 + 002F F0 103 movx @dptr,a + 0030 A3 104 inc dptr + 0031 EC 105 mov a,r4 + 0032 F0 106 movx @dptr,a + 0033 A3 107 inc dptr + 0034 ED 108 mov a,r5 + 0035 F0 109 movx @dptr,a + 110 ; _fssub.c 86 + 0036 90s00r00 111 mov dptr,#___fssub_PARM_2 + 0039 E0 112 movx a,@dptr + 003A FA 113 mov r2,a + 003B A3 114 inc dptr + 003C E0 115 movx a,@dptr + 003D FB 116 mov r3,a + 003E A3 117 inc dptr + 003F E0 118 movx a,@dptr + 0040 FC 119 mov r4,a + 0041 A3 120 inc dptr + 0042 E0 121 movx a,@dptr + 0043 FD 122 mov r5,a + 0044 90s00r0C 123 mov dptr,#(___fssub_fl2_1_1) + 0047 EA 124 mov a,r2 + 0048 F0 125 movx @dptr,a + 0049 A3 126 inc dptr + 004A EB 127 mov a,r3 + 004B F0 128 movx @dptr,a + 004C A3 129 inc dptr + 004D EC 130 mov a,r4 + 004E F0 131 movx @dptr,a + 004F A3 132 inc dptr + 0050 ED 133 mov a,r5 + 0051 F0 134 movx @dptr,a + 135 ; _fssub.c 89 + 0052 90s00r0C 136 mov dptr,#(___fssub_fl2_1_1) + 0055 E0 137 movx a,@dptr + 0056 FA 138 mov r2,a + 0057 A3 139 inc dptr + 0058 E0 140 movx a,@dptr + 0059 FB 141 mov r3,a + 005A A3 142 inc dptr + 005B E0 143 movx a,@dptr + 005C FC 144 mov r4,a + 005D A3 145 inc dptr + 005E E0 146 movx a,@dptr + 005F FD 147 mov r5,a + 0060 EA 148 mov a,r2 + 0061 4B 149 orl a,r3 + 0062 4C 150 orl a,r4 + 0063 4D 151 orl a,r5 + 152 ; Peephole 109 removed ljmp by inverse jump logic + 0064 70 17 153 jnz 00102$ + 0066 154 00109$: + 155 ; _fssub.c 90 + 0066 90s00r08 156 mov dptr,#(___fssub_fl1_1_1) + 0069 E0 157 movx a,@dptr + 006A FA 158 mov r2,a + 006B A3 159 inc dptr + 006C E0 160 movx a,@dptr + 006D FB 161 mov r3,a + 006E A3 162 inc dptr + 006F E0 163 movx a,@dptr + 0070 FC 164 mov r4,a + 0071 A3 165 inc dptr + 0072 E0 166 movx a,@dptr + 167 ; Peephole 191 removed redundant mov + 0073 FD 168 mov r5,a + 0074 8A 82 169 mov dpl,r2 + 0076 8B 83 170 mov dph,r3 + 0078 8C F0 171 mov b,r4 + 007A 02s00rFE 172 ljmp 00105$ + 007D 173 00102$: + 174 ; _fssub.c 91 + 007D 90s00r08 175 mov dptr,#(___fssub_fl1_1_1) + 0080 E0 176 movx a,@dptr + 0081 FA 177 mov r2,a + 0082 A3 178 inc dptr + 0083 E0 179 movx a,@dptr + 0084 FB 180 mov r3,a + 0085 A3 181 inc dptr + 0086 E0 182 movx a,@dptr + 0087 FC 183 mov r4,a + 0088 A3 184 inc dptr + 0089 E0 185 movx a,@dptr + 008A FD 186 mov r5,a + 008B EA 187 mov a,r2 + 008C 4B 188 orl a,r3 + 008D 4C 189 orl a,r4 + 008E 4D 190 orl a,r5 + 191 ; Peephole 109 removed ljmp by inverse jump logic + 008F 70 1A 192 jnz 00104$ + 0091 193 00110$: + 194 ; _fssub.c 92 + 0091 90s00r0C 195 mov dptr,#(___fssub_fl2_1_1) + 0094 E0 196 movx a,@dptr + 0095 FA 197 mov r2,a + 0096 A3 198 inc dptr + 0097 E0 199 movx a,@dptr + 0098 FB 200 mov r3,a + 0099 A3 201 inc dptr + 009A E0 202 movx a,@dptr + 009B FC 203 mov r4,a + 009C A3 204 inc dptr + 009D E0 205 movx a,@dptr + 206 ; Peephole 105 removed redundant mov + 009E FD 207 mov r5,a + 009F B2 E7 208 cpl acc.7 + 209 ; Peephole 191 removed redundant mov + 00A1 FD 210 mov r5,a + 00A2 8A 82 211 mov dpl,r2 + 00A4 8B 83 212 mov dph,r3 + 00A6 8C F0 213 mov b,r4 + 00A8 02s00rFE 214 ljmp 00105$ + 00AB 215 00104$: + 216 ; _fssub.c 95 + 00AB 90s00r0C 217 mov dptr,#(___fssub_fl2_1_1) + 00AE E0 218 movx a,@dptr + 00AF FA 219 mov r2,a + 00B0 A3 220 inc dptr + 00B1 E0 221 movx a,@dptr + 00B2 FB 222 mov r3,a + 00B3 A3 223 inc dptr + 00B4 E0 224 movx a,@dptr + 00B5 FC 225 mov r4,a + 00B6 A3 226 inc dptr + 00B7 E0 227 movx a,@dptr + 00B8 FD 228 mov r5,a + 00B9 63 05 80 229 xrl ar5,#0x80 + 00BC 90s00r0C 230 mov dptr,#(___fssub_fl2_1_1) + 00BF EA 231 mov a,r2 + 00C0 F0 232 movx @dptr,a + 00C1 A3 233 inc dptr + 00C2 EB 234 mov a,r3 + 00C3 F0 235 movx @dptr,a + 00C4 A3 236 inc dptr + 00C5 EC 237 mov a,r4 + 00C6 F0 238 movx @dptr,a + 00C7 A3 239 inc dptr + 00C8 ED 240 mov a,r5 + 00C9 F0 241 movx @dptr,a + 242 ; _fssub.c 96 + 00CA 90s00r08 243 mov dptr,#(___fssub_fl1_1_1) + 00CD E0 244 movx a,@dptr + 00CE FA 245 mov r2,a + 00CF A3 246 inc dptr + 00D0 E0 247 movx a,@dptr + 00D1 FB 248 mov r3,a + 00D2 A3 249 inc dptr + 00D3 E0 250 movx a,@dptr + 00D4 FC 251 mov r4,a + 00D5 A3 252 inc dptr + 00D6 E0 253 movx a,@dptr + 00D7 FD 254 mov r5,a + 00D8 90s00r0C 255 mov dptr,#(___fssub_fl2_1_1) + 00DB E0 256 movx a,@dptr + 00DC FE 257 mov r6,a + 00DD A3 258 inc dptr + 00DE E0 259 movx a,@dptr + 00DF FF 260 mov r7,a + 00E0 A3 261 inc dptr + 00E1 E0 262 movx a,@dptr + 00E2 F8 263 mov r0,a + 00E3 A3 264 inc dptr + 00E4 E0 265 movx a,@dptr + 00E5 F9 266 mov r1,a + 00E6 90s00r00 267 mov dptr,#___fsadd_PARM_2 + 00E9 EE 268 mov a,r6 + 00EA F0 269 movx @dptr,a + 00EB A3 270 inc dptr + 00EC EF 271 mov a,r7 + 00ED F0 272 movx @dptr,a + 00EE A3 273 inc dptr + 00EF E8 274 mov a,r0 + 00F0 F0 275 movx @dptr,a + 00F1 A3 276 inc dptr + 00F2 E9 277 mov a,r1 + 00F3 F0 278 movx @dptr,a + 00F4 8A 82 279 mov dpl,r2 + 00F6 8B 83 280 mov dph,r3 + 00F8 8C F0 281 mov b,r4 + 00FA ED 282 mov a,r5 + 00FB 12s00r00 283 lcall ___fsadd + 00FE 284 C$_fssub.c$97$1$1 ==. + 00FE 285 XG$__fssub$0$0 ==. + 286 ; Peephole 156 removed misc moves via dph, dpl, b, a before return + 00FE 287 00105$: + 00FE 22 288 ret + 289 .area CSEG (CODE) diff --git a/device/lib/_fssub.sym b/device/lib/_fssub.sym new file mode 100644 index 00000000..f851cf6a --- /dev/null +++ b/device/lib/_fssub.sym @@ -0,0 +1,570 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_fssub$100 002C GR + 7 A$_fssub$101 002D GR + 7 A$_fssub$102 002E GR + 7 A$_fssub$103 002F GR + 7 A$_fssub$104 0030 GR + 7 A$_fssub$105 0031 GR + 7 A$_fssub$106 0032 GR + 7 A$_fssub$107 0033 GR + 7 A$_fssub$108 0034 GR + 7 A$_fssub$109 0035 GR + 7 A$_fssub$111 0036 GR + 7 A$_fssub$112 0039 GR + 7 A$_fssub$113 003A GR + 7 A$_fssub$114 003B GR + 7 A$_fssub$115 003C GR + 7 A$_fssub$116 003D GR + 7 A$_fssub$117 003E GR + 7 A$_fssub$118 003F GR + 7 A$_fssub$119 0040 GR + 7 A$_fssub$120 0041 GR + 7 A$_fssub$121 0042 GR + 7 A$_fssub$122 0043 GR + 7 A$_fssub$123 0044 GR + 7 A$_fssub$124 0047 GR + 7 A$_fssub$125 0048 GR + 7 A$_fssub$126 0049 GR + 7 A$_fssub$127 004A GR + 7 A$_fssub$128 004B GR + 7 A$_fssub$129 004C GR + 7 A$_fssub$130 004D GR + 7 A$_fssub$131 004E GR + 7 A$_fssub$132 004F GR + 7 A$_fssub$133 0050 GR + 7 A$_fssub$134 0051 GR + 7 A$_fssub$136 0052 GR + 7 A$_fssub$137 0055 GR + 7 A$_fssub$138 0056 GR + 7 A$_fssub$139 0057 GR + 7 A$_fssub$140 0058 GR + 7 A$_fssub$141 0059 GR + 7 A$_fssub$142 005A GR + 7 A$_fssub$143 005B GR + 7 A$_fssub$144 005C GR + 7 A$_fssub$145 005D GR + 7 A$_fssub$146 005E GR + 7 A$_fssub$147 005F GR + 7 A$_fssub$148 0060 GR + 7 A$_fssub$149 0061 GR + 7 A$_fssub$150 0062 GR + 7 A$_fssub$151 0063 GR + 7 A$_fssub$153 0064 GR + 7 A$_fssub$156 0066 GR + 7 A$_fssub$157 0069 GR + 7 A$_fssub$158 006A GR + 7 A$_fssub$159 006B GR + 7 A$_fssub$160 006C GR + 7 A$_fssub$161 006D GR + 7 A$_fssub$162 006E GR + 7 A$_fssub$163 006F GR + 7 A$_fssub$164 0070 GR + 7 A$_fssub$165 0071 GR + 7 A$_fssub$166 0072 GR + 7 A$_fssub$168 0073 GR + 7 A$_fssub$169 0074 GR + 7 A$_fssub$170 0076 GR + 7 A$_fssub$171 0078 GR + 7 A$_fssub$172 007A GR + 7 A$_fssub$175 007D GR + 7 A$_fssub$176 0080 GR + 7 A$_fssub$177 0081 GR + 7 A$_fssub$178 0082 GR + 7 A$_fssub$179 0083 GR + 7 A$_fssub$180 0084 GR + 7 A$_fssub$181 0085 GR + 7 A$_fssub$182 0086 GR + 7 A$_fssub$183 0087 GR + 7 A$_fssub$184 0088 GR + 7 A$_fssub$185 0089 GR + 7 A$_fssub$186 008A GR + 7 A$_fssub$187 008B GR + 7 A$_fssub$188 008C GR + 7 A$_fssub$189 008D GR + 7 A$_fssub$190 008E GR + 7 A$_fssub$192 008F GR + 7 A$_fssub$195 0091 GR + 7 A$_fssub$196 0094 GR + 7 A$_fssub$197 0095 GR + 7 A$_fssub$198 0096 GR + 7 A$_fssub$199 0097 GR + 7 A$_fssub$200 0098 GR + 7 A$_fssub$201 0099 GR + 7 A$_fssub$202 009A GR + 7 A$_fssub$203 009B GR + 7 A$_fssub$204 009C GR + 7 A$_fssub$205 009D GR + 7 A$_fssub$207 009E GR + 7 A$_fssub$208 009F GR + 7 A$_fssub$210 00A1 GR + 7 A$_fssub$211 00A2 GR + 7 A$_fssub$212 00A4 GR + 7 A$_fssub$213 00A6 GR + 7 A$_fssub$214 00A8 GR + 7 A$_fssub$217 00AB GR + 7 A$_fssub$218 00AE GR + 7 A$_fssub$219 00AF GR + 7 A$_fssub$220 00B0 GR + 7 A$_fssub$221 00B1 GR + 7 A$_fssub$222 00B2 GR + 7 A$_fssub$223 00B3 GR + 7 A$_fssub$224 00B4 GR + 7 A$_fssub$225 00B5 GR + 7 A$_fssub$226 00B6 GR + 7 A$_fssub$227 00B7 GR + 7 A$_fssub$228 00B8 GR + 7 A$_fssub$229 00B9 GR + 7 A$_fssub$230 00BC GR + 7 A$_fssub$231 00BF GR + 7 A$_fssub$232 00C0 GR + 7 A$_fssub$233 00C1 GR + 7 A$_fssub$234 00C2 GR + 7 A$_fssub$235 00C3 GR + 7 A$_fssub$236 00C4 GR + 7 A$_fssub$237 00C5 GR + 7 A$_fssub$238 00C6 GR + 7 A$_fssub$239 00C7 GR + 7 A$_fssub$240 00C8 GR + 7 A$_fssub$241 00C9 GR + 7 A$_fssub$243 00CA GR + 7 A$_fssub$244 00CD GR + 7 A$_fssub$245 00CE GR + 7 A$_fssub$246 00CF GR + 7 A$_fssub$247 00D0 GR + 7 A$_fssub$248 00D1 GR + 7 A$_fssub$249 00D2 GR + 7 A$_fssub$250 00D3 GR + 7 A$_fssub$251 00D4 GR + 7 A$_fssub$252 00D5 GR + 7 A$_fssub$253 00D6 GR + 7 A$_fssub$254 00D7 GR + 7 A$_fssub$255 00D8 GR + 7 A$_fssub$256 00DB GR + 7 A$_fssub$257 00DC GR + 7 A$_fssub$258 00DD GR + 7 A$_fssub$259 00DE GR + 7 A$_fssub$260 00DF GR + 7 A$_fssub$261 00E0 GR + 7 A$_fssub$262 00E1 GR + 7 A$_fssub$263 00E2 GR + 7 A$_fssub$264 00E3 GR + 7 A$_fssub$265 00E4 GR + 7 A$_fssub$266 00E5 GR + 7 A$_fssub$267 00E6 GR + 7 A$_fssub$268 00E9 GR + 7 A$_fssub$269 00EA GR + 7 A$_fssub$270 00EB GR + 7 A$_fssub$271 00EC GR + 7 A$_fssub$272 00ED GR + 7 A$_fssub$273 00EE GR + 7 A$_fssub$274 00EF GR + 7 A$_fssub$275 00F0 GR + 7 A$_fssub$276 00F1 GR + 7 A$_fssub$277 00F2 GR + 7 A$_fssub$278 00F3 GR + 7 A$_fssub$279 00F4 GR + 7 A$_fssub$280 00F6 GR + 7 A$_fssub$281 00F8 GR + 7 A$_fssub$282 00FA GR + 7 A$_fssub$283 00FB GR + 7 A$_fssub$288 00FE GR + 7 A$_fssub$69 0000 GR + 7 A$_fssub$70 0002 GR + 7 A$_fssub$71 0004 GR + 7 A$_fssub$72 0006 GR + 7 A$_fssub$73 0008 GR + 7 A$_fssub$74 000B GR + 7 A$_fssub$75 000D GR + 7 A$_fssub$76 000E GR + 7 A$_fssub$77 0010 GR + 7 A$_fssub$78 0011 GR + 7 A$_fssub$79 0012 GR + 7 A$_fssub$80 0014 GR + 7 A$_fssub$81 0015 GR + 7 A$_fssub$82 0016 GR + 7 A$_fssub$83 0018 GR + 7 A$_fssub$84 0019 GR + 7 A$_fssub$86 001A GR + 7 A$_fssub$87 001D GR + 7 A$_fssub$88 001E GR + 7 A$_fssub$89 001F GR + 7 A$_fssub$90 0020 GR + 7 A$_fssub$91 0021 GR + 7 A$_fssub$92 0022 GR + 7 A$_fssub$93 0023 GR + 7 A$_fssub$94 0024 GR + 7 A$_fssub$95 0025 GR + 7 A$_fssub$96 0026 GR + 7 A$_fssub$97 0027 GR + 7 A$_fssub$98 0028 GR + 7 A$_fssub$99 002B GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_fssub.c$97$1$1 = 00FE GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__fssub$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__fssub$0$0 = 00FE GR + ___fsadd **** GX + ___fsadd_PARM_2 **** GX + 7 ___fssub 0000 GR + 5 ___fssub_PARM_2 0000 GR + 5 ___fssub_a1_1_1 0004 R + 5 ___fssub_fl1_1_1 0008 R + 5 ___fssub_fl2_1_1 000C R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 10 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size FF flags 20 diff --git a/device/lib/_gptrget.c b/device/lib/_gptrget.c new file mode 100644 index 00000000..b0bd72a5 --- /dev/null +++ b/device/lib/_gptrget.c @@ -0,0 +1,83 @@ +/*------------------------------------------------------------------------- + + _gptrget.c :- get value for a generic pointer + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +unsigned char _gptrget () +{ + _asm + ; save values passed + xch a,r0 + push acc + ; + ; depending on the pointer type + ; + mov a,b + jz 00001$ + dec a + jz 00002$ + dec a + jz 00003$ + dec a + jz 00004$ + ; + ; any other value for type + ; return xFF + mov a,#0xff + sjmp 00005$ + ; + ; Pointer to data space + ; + 00001$: + mov r0,dpl ; use only low order address + mov a,@r0 + sjmp 00005$ + ; + ; pointer to xternal data + ; + 00002$: + movx a,@dptr + sjmp 00005$ +; +; pointer to code area +; + 00003$: + clr a + movc a,@a+dptr + sjmp 00005$ +; +; pointer to xternal stack +; + 00004$: + mov r0,dpl + movx a,@r0 +; +; restore and return +; + 00005$: + mov r0,a + pop acc + xch a,r0 + _endasm ; + +} diff --git a/device/lib/_gptrget.lst b/device/lib/_gptrget.lst new file mode 100644 index 00000000..f244b85c --- /dev/null +++ b/device/lib/_gptrget.lst @@ -0,0 +1,116 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _gptrget + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __gptrget + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 37 ;-------------------------------------------------------- + 38 ; global & static initialisations + 39 ;-------------------------------------------------------- + 40 .area GSINIT (CODE) + 41 ;-------------------------------------------------------- + 42 ; code + 43 ;-------------------------------------------------------- + 44 .area CSEG (CODE) + 0000 45 G$_gptrget$0$0 ==. + 46 ; _gptrget.c 26 + 47 ; ----------------------------------------- + 48 ; function _gptrget + 49 ; ----------------------------------------- + 0000 50 __gptrget: + 0002 51 ar2 = 0x02 + 0003 52 ar3 = 0x03 + 0004 53 ar4 = 0x04 + 0005 54 ar5 = 0x05 + 0006 55 ar6 = 0x06 + 0007 56 ar7 = 0x07 + 0000 57 ar0 = 0x00 + 0001 58 ar1 = 0x01 + 59 ; _gptrget.c 81 + 60 ; save values passed + 0000 C8 61 xch a,r0 + 0001 C0 E0 62 push acc + 63 ; + 64 ; depending on the pointer type + 65 ; + 0003 E5 F0 66 mov a,b + 0005 60 0D 67 jz 00001$ + 0007 14 68 dec a + 0008 60 0F 69 jz 00002$ + 000A 14 70 dec a + 000B 60 0F 71 jz 00003$ + 000D 14 72 dec a + 000E 60 10 73 jz 00004$ + 74 ; + 75 ; any other value for type + 76 ; return xFF + 0010 74 FF 77 mov a,#0xff + 0012 80 0F 78 sjmp 00005$ + 79 ; + 80 ; Pointer to data space + 81 ; + 0014 82 00001$: + 0014 A8 82 83 mov r0,dpl ; use only low order address + 0016 E6 84 mov a,@r0 + 0017 80 0A 85 sjmp 00005$ + 86 ; + 87 ; pointer to xternal data + 88 ; + 0019 89 00002$: + 0019 E0 90 movx a,@dptr + 001A 80 07 91 sjmp 00005$ + 92 ; + 93 ; pointer to code area + 94 ; + 001C 95 00003$: + 001C E4 96 clr a + 001D 93 97 movc a,@a+dptr + 001E 80 03 98 sjmp 00005$ + 99 ; + 100 ; pointer to xternal stack + 101 ; + 0020 102 00004$: + 0020 A8 82 103 mov r0,dpl + 0022 E2 104 movx a,@r0 + 105 ; + 106 ; restore and return + 107 ; + 0023 108 00005$: + 0023 F8 109 mov r0,a + 0024 D0 E0 110 pop acc + 0026 C8 111 xch a,r0 + 0027 112 00101$: + 0027 113 C$_gptrget.c$83$1$1 ==. + 0027 114 XG$_gptrget$0$0 ==. + 0027 22 115 ret + 116 .area CSEG (CODE) diff --git a/device/lib/_gptrget.sym b/device/lib/_gptrget.sym new file mode 100644 index 00000000..b20b3686 --- /dev/null +++ b/device/lib/_gptrget.sym @@ -0,0 +1,391 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_gptrget$103 0020 GR + 7 A$_gptrget$104 0022 GR + 7 A$_gptrget$109 0023 GR + 7 A$_gptrget$110 0024 GR + 7 A$_gptrget$111 0026 GR + 7 A$_gptrget$115 0027 GR + 7 A$_gptrget$61 0000 GR + 7 A$_gptrget$62 0001 GR + 7 A$_gptrget$66 0003 GR + 7 A$_gptrget$67 0005 GR + 7 A$_gptrget$68 0007 GR + 7 A$_gptrget$69 0008 GR + 7 A$_gptrget$70 000A GR + 7 A$_gptrget$71 000B GR + 7 A$_gptrget$72 000D GR + 7 A$_gptrget$73 000E GR + 7 A$_gptrget$77 0010 GR + 7 A$_gptrget$78 0012 GR + 7 A$_gptrget$83 0014 GR + 7 A$_gptrget$84 0016 GR + 7 A$_gptrget$85 0017 GR + 7 A$_gptrget$90 0019 GR + 7 A$_gptrget$91 001A GR + 7 A$_gptrget$96 001C GR + 7 A$_gptrget$97 001D GR + 7 A$_gptrget$98 001E GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_gptrget.c$83$1$1 = 0027 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_gptrget$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_gptrget$0$0 = 0027 GR + 7 __gptrget 0000 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 0 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 28 flags 20 diff --git a/device/lib/_gptrput.c b/device/lib/_gptrput.c new file mode 100644 index 00000000..0f4fd6e7 --- /dev/null +++ b/device/lib/_gptrput.c @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------- + + _gptrput.c :- put value for a generic pointer + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +unsigned char _gptrput () +{ + _asm + xch a,r0 + push acc + xch a,r0 + push acc + ; + ; depending on the pointer type + ; + mov a,b + jz 00001$ + dec a + jz 00002$ + dec a + jz 00003$ + dec a + jz 00004$ + pop acc + sjmp 00005$ +; +; store into near space +; + 00001$: + pop acc + mov r0,dpl + mov @r0,a + sjmp 00005$ + + 00002$: + pop acc + movx @dptr,a + sjmp 00005$ + + 00003$: + pop acc ; do nothing + sjmp 00005$ + + 00004$: + pop acc + mov r0,dpl + movx @r0,a + 00005$: + xch a,r0 + pop acc + xch a,r0 +_endasm; +} diff --git a/device/lib/_gptrput.lst b/device/lib/_gptrput.lst new file mode 100644 index 00000000..0f6503a8 --- /dev/null +++ b/device/lib/_gptrput.lst @@ -0,0 +1,104 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _gptrput + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __gptrput + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 37 ;-------------------------------------------------------- + 38 ; global & static initialisations + 39 ;-------------------------------------------------------- + 40 .area GSINIT (CODE) + 41 ;-------------------------------------------------------- + 42 ; code + 43 ;-------------------------------------------------------- + 44 .area CSEG (CODE) + 0000 45 G$_gptrput$0$0 ==. + 46 ; _gptrput.c 26 + 47 ; ----------------------------------------- + 48 ; function _gptrput + 49 ; ----------------------------------------- + 0000 50 __gptrput: + 0002 51 ar2 = 0x02 + 0003 52 ar3 = 0x03 + 0004 53 ar4 = 0x04 + 0005 54 ar5 = 0x05 + 0006 55 ar6 = 0x06 + 0007 56 ar7 = 0x07 + 0000 57 ar0 = 0x00 + 0001 58 ar1 = 0x01 + 59 ; _gptrput.c 72 + 0000 C8 60 xch a,r0 + 0001 C0 E0 61 push acc + 0003 C8 62 xch a,r0 + 0004 C0 E0 63 push acc + 64 ; + 65 ; depending on the pointer type + 66 ; + 0006 E5 F0 67 mov a,b + 0008 60 0D 68 jz 00001$ + 000A 14 69 dec a + 000B 60 11 70 jz 00002$ + 000D 14 71 dec a + 000E 60 13 72 jz 00003$ + 0010 14 73 dec a + 0011 60 14 74 jz 00004$ + 0013 D0 E0 75 pop acc + 0015 80 15 76 sjmp 00005$ + 77 ; + 78 ; store into near space + 79 ; + 0017 80 00001$: + 0017 D0 E0 81 pop acc + 0019 A8 82 82 mov r0,dpl + 001B F6 83 mov @r0,a + 001C 80 0E 84 sjmp 00005$ + 001E 85 00002$: + 001E D0 E0 86 pop acc + 0020 F0 87 movx @dptr,a + 0021 80 09 88 sjmp 00005$ + 0023 89 00003$: + 0023 D0 E0 90 pop acc ; do nothing + 0025 80 05 91 sjmp 00005$ + 0027 92 00004$: + 0027 D0 E0 93 pop acc + 0029 A8 82 94 mov r0,dpl + 002B F2 95 movx @r0,a + 002C 96 00005$: + 002C C8 97 xch a,r0 + 002D D0 E0 98 pop acc + 002F C8 99 xch a,r0 + 0030 100 00101$: + 0030 101 C$_gptrput.c$73$1$1 ==. + 0030 102 XG$_gptrput$0$0 ==. + 0030 22 103 ret + 104 .area CSEG (CODE) diff --git a/device/lib/_gptrput.sym b/device/lib/_gptrput.sym new file mode 100644 index 00000000..6675b6d0 --- /dev/null +++ b/device/lib/_gptrput.sym @@ -0,0 +1,395 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_gptrput$103 0030 GR + 7 A$_gptrput$60 0000 GR + 7 A$_gptrput$61 0001 GR + 7 A$_gptrput$62 0003 GR + 7 A$_gptrput$63 0004 GR + 7 A$_gptrput$67 0006 GR + 7 A$_gptrput$68 0008 GR + 7 A$_gptrput$69 000A GR + 7 A$_gptrput$70 000B GR + 7 A$_gptrput$71 000D GR + 7 A$_gptrput$72 000E GR + 7 A$_gptrput$73 0010 GR + 7 A$_gptrput$74 0011 GR + 7 A$_gptrput$75 0013 GR + 7 A$_gptrput$76 0015 GR + 7 A$_gptrput$81 0017 GR + 7 A$_gptrput$82 0019 GR + 7 A$_gptrput$83 001B GR + 7 A$_gptrput$84 001C GR + 7 A$_gptrput$86 001E GR + 7 A$_gptrput$87 0020 GR + 7 A$_gptrput$88 0021 GR + 7 A$_gptrput$90 0023 GR + 7 A$_gptrput$91 0025 GR + 7 A$_gptrput$93 0027 GR + 7 A$_gptrput$94 0029 GR + 7 A$_gptrput$95 002B GR + 7 A$_gptrput$97 002C GR + 7 A$_gptrput$98 002D GR + 7 A$_gptrput$99 002F GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_gptrput.c$73$1$1 = 0030 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_gptrput$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_gptrput$0$0 = 0030 GR + 7 __gptrput 0000 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 0 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 31 flags 20 diff --git a/device/lib/_int2fs.c b/device/lib/_int2fs.c new file mode 100644 index 00000000..fff10c17 --- /dev/null +++ b/device/lib/_int2fs.c @@ -0,0 +1,111 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x0FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +float +__int2fs (int a ) +{ + long sign = 0; + int exp = 24 + EXCESS; + volatile union float_long fl; + long a1 = a; + + if (!a1) + { + fl.l = 0; + return (fl.f); + } + + if (a1 < 0) + { + sign = SIGNBIT; + a1 = -a1; + } + + while (a1 < HIDDEN) + { + a1 <<= 1; + exp--; + } + + a1 &= ~HIDDEN ; + + /* pack up and go home */ + fl.l = PACK(sign,(unsigned long)exp, a1); + + return (fl.f); +} diff --git a/device/lib/_int2fs.lst b/device/lib/_int2fs.lst new file mode 100644 index 00000000..16f68034 --- /dev/null +++ b/device/lib/_int2fs.lst @@ -0,0 +1,340 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _int2fs + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___int2fs + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___int2fs_sloc0_1_0: + 0000 22 .ds 0x0002 + 0002 23 ___int2fs_sloc1_1_0: + 0002 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___int2fs_a_1_1: + 0000 42 .ds 0x0002 + 0002 43 ___int2fs_sign_1_1: + 0002 44 .ds 0x0004 + 0006 45 ___int2fs_fl_1_1: + 0006 46 .ds 0x0004 + 000A 47 ___int2fs_a1_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__int2fs$0$0 ==. + 58 ; _int2fs.c 80 + 59 ; ----------------------------------------- + 60 ; function __int2fs + 61 ; ----------------------------------------- + 0000 62 ___int2fs: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _int2fs.c 110 + 0000 C0 83 72 push dph + 0002 C0 82 73 push dpl + 0004 90s00r00 74 mov dptr,#___int2fs_a_1_1 + 0007 D0 E0 75 pop acc + 0009 F0 76 movx @dptr,a + 000A D0 E0 77 pop acc + 000C A3 78 inc dptr + 000D F0 79 movx @dptr,a + 80 ; _int2fs.c 82 + 000E 90s00r02 81 mov dptr,#___int2fs_sign_1_1 + 0011 E4 82 clr a + 0012 A3 83 inc dptr + 0013 A3 84 inc dptr + 0014 A3 85 inc dptr + 0015 F0 86 movx @dptr,a + 0016 12s00r00 87 lcall __decdptr + 0019 F0 88 movx @dptr,a + 001A 12s00r00 89 lcall __decdptr + 001D F0 90 movx @dptr,a + 001E 12s00r00 91 lcall __decdptr + 0021 F0 92 movx @dptr,a + 93 ; _int2fs.c 85 + 0022 90s00r00 94 mov dptr,#___int2fs_a_1_1 + 0025 E0 95 movx a,@dptr + 0026 FA 96 mov r2,a + 0027 A3 97 inc dptr + 0028 E0 98 movx a,@dptr + 99 ; Peephole 105 removed redundant mov + 0029 FB 100 mov r3,a + 002A 33 101 rlc a + 002B 95 E0 102 subb a,acc + 002D FC 103 mov r4,a + 002E FD 104 mov r5,a + 002F 90s00r0A 105 mov dptr,#___int2fs_a1_1_1 + 0032 EA 106 mov a,r2 + 0033 F0 107 movx @dptr,a + 0034 A3 108 inc dptr + 0035 EB 109 mov a,r3 + 0036 F0 110 movx @dptr,a + 0037 A3 111 inc dptr + 0038 EC 112 mov a,r4 + 0039 F0 113 movx @dptr,a + 003A A3 114 inc dptr + 003B ED 115 mov a,r5 + 003C F0 116 movx @dptr,a + 117 ; _int2fs.c 87 + 003D EA 118 mov a,r2 + 003E 4B 119 orl a,r3 + 003F 4C 120 orl a,r4 + 0040 4D 121 orl a,r5 + 122 ; Peephole 109 removed ljmp by inverse jump logic + 0041 70 23 123 jnz 00102$ + 0043 124 00114$: + 125 ; _int2fs.c 89 + 0043 90s00r06 126 mov dptr,#(___int2fs_fl_1_1) + 127 ; Peephole 101 removed redundant mov + 128 ; Peephole 180 changed mov to clr + 0046 E4 129 clr a + 0047 F0 130 movx @dptr,a + 0048 A3 131 inc dptr + 0049 F0 132 movx @dptr,a + 004A A3 133 inc dptr + 134 ; Peephole 101 removed redundant mov + 135 ; Peephole 180 changed mov to clr + 004B E4 136 clr a + 004C F0 137 movx @dptr,a + 004D A3 138 inc dptr + 004E F0 139 movx @dptr,a + 140 ; _int2fs.c 90 + 004F 90s00r06 141 mov dptr,#(___int2fs_fl_1_1) + 0052 E0 142 movx a,@dptr + 0053 FE 143 mov r6,a + 0054 A3 144 inc dptr + 0055 E0 145 movx a,@dptr + 0056 FF 146 mov r7,a + 0057 A3 147 inc dptr + 0058 E0 148 movx a,@dptr + 0059 F8 149 mov r0,a + 005A A3 150 inc dptr + 005B E0 151 movx a,@dptr + 152 ; Peephole 191 removed redundant mov + 005C F9 153 mov r1,a + 005D 8E 82 154 mov dpl,r6 + 005F 8F 83 155 mov dph,r7 + 0061 88 F0 156 mov b,r0 + 0063 02s01r43 157 ljmp 00108$ + 0066 158 00102$: + 159 ; _int2fs.c 93 + 0066 ED 160 mov a,r5 + 161 ; Peephole 111 removed ljmp by inverse jump logic + 0067 30 E7 21 162 jnb acc.7,00113$ + 006A 163 00115$: + 164 ; _int2fs.c 95 + 006A 90s00r02 165 mov dptr,#___int2fs_sign_1_1 + 166 ; Peephole 101 removed redundant mov + 167 ; Peephole 180 changed mov to clr + 006D E4 168 clr a + 006E F0 169 movx @dptr,a + 006F A3 170 inc dptr + 0070 F0 171 movx @dptr,a + 0071 A3 172 inc dptr + 173 ; Peephole 180 changed mov to clr + 0072 E4 174 clr a + 0073 F0 175 movx @dptr,a + 0074 A3 176 inc dptr + 0075 74 80 177 mov a,#0x80 + 0077 F0 178 movx @dptr,a + 179 ; _int2fs.c 96 + 0078 90s00r0A 180 mov dptr,#___int2fs_a1_1_1 + 007B C3 181 clr c + 007C E4 182 clr a + 007D 9A 183 subb a,r2 + 007E F0 184 movx @dptr,a + 007F E4 185 clr a + 0080 9B 186 subb a,r3 + 0081 A3 187 inc dptr + 0082 F0 188 movx @dptr,a + 0083 E4 189 clr a + 0084 9C 190 subb a,r4 + 0085 A3 191 inc dptr + 0086 F0 192 movx @dptr,a + 0087 E4 193 clr a + 0088 9D 194 subb a,r5 + 0089 A3 195 inc dptr + 008A F0 196 movx @dptr,a + 197 ; _int2fs.c 99 + 008B 198 00113$: + 008B E4 199 clr a + 008C F5*01 200 mov (___int2fs_sloc0_1_0 + 1),a + 008E 75*00 96 201 mov ___int2fs_sloc0_1_0,#0x96 + 0091 202 00105$: + 0091 90s00r0A 203 mov dptr,#___int2fs_a1_1_1 + 0094 E0 204 movx a,@dptr + 0095 FC 205 mov r4,a + 0096 A3 206 inc dptr + 0097 E0 207 movx a,@dptr + 0098 FD 208 mov r5,a + 0099 A3 209 inc dptr + 009A E0 210 movx a,@dptr + 009B FE 211 mov r6,a + 009C A3 212 inc dptr + 009D E0 213 movx a,@dptr + 009E FF 214 mov r7,a + 009F C3 215 clr c + 00A0 EC 216 mov a,r4 + 00A1 94 00 217 subb a,#0x00 + 00A3 ED 218 mov a,r5 + 00A4 94 00 219 subb a,#0x00 + 00A6 EE 220 mov a,r6 + 00A7 94 80 221 subb a,#0x80 + 00A9 EF 222 mov a,r7 + 00AA 94 00 223 subb a,#0x00 + 224 ; Peephole 108 removed ljmp by inverse jump logic + 00AC 50 27 225 jnc 00107$ + 00AE 226 00116$: + 227 ; _int2fs.c 101 + 00AE EC 228 mov a,r4 + 00AF 25 E0 229 add a,acc + 00B1 F8 230 mov r0,a + 00B2 ED 231 mov a,r5 + 00B3 33 232 rlc a + 00B4 F9 233 mov r1,a + 00B5 EE 234 mov a,r6 + 00B6 33 235 rlc a + 00B7 FA 236 mov r2,a + 00B8 EF 237 mov a,r7 + 00B9 33 238 rlc a + 00BA FB 239 mov r3,a + 00BB 90s00r0A 240 mov dptr,#___int2fs_a1_1_1 + 00BE E8 241 mov a,r0 + 00BF F0 242 movx @dptr,a + 00C0 A3 243 inc dptr + 00C1 E9 244 mov a,r1 + 00C2 F0 245 movx @dptr,a + 00C3 A3 246 inc dptr + 00C4 EA 247 mov a,r2 + 00C5 F0 248 movx @dptr,a + 00C6 A3 249 inc dptr + 00C7 EB 250 mov a,r3 + 00C8 F0 251 movx @dptr,a + 252 ; _int2fs.c 102 + 00C9 15*00 253 dec ___int2fs_sloc0_1_0 + 00CB 74 FF 254 mov a,#0xff + 00CD B5*00 02 255 cjne a,___int2fs_sloc0_1_0,00117$ + 00D0 15*01 256 dec (___int2fs_sloc0_1_0 + 1) + 00D2 257 00117$: + 00D2 02s00r91 258 ljmp 00105$ + 00D5 259 00107$: + 260 ; _int2fs.c 105 + 00D5 53 06 7F 261 anl ar6,#0x7f + 262 ; _int2fs.c 108 + 00D8 AA*00 263 mov r2,___int2fs_sloc0_1_0 + 00DA AB*01 264 mov r3,(___int2fs_sloc0_1_0 + 1) + 00DC 78 00 265 mov r0,#0x00 + 00DE 79 00 266 mov r1,#0x00 + 00E0 8A*04 267 mov (___int2fs_sloc1_1_0 + 2),r2 + 00E2 EB 268 mov a,r3 + 00E3 54 01 269 anl a,#0x01 + 00E5 A2 E0 270 mov c,acc.0 + 00E7 C5*04 271 xch a,(___int2fs_sloc1_1_0 + 2) + 00E9 13 272 rrc a + 00EA C5*04 273 xch a,(___int2fs_sloc1_1_0 + 2) + 00EC 13 274 rrc a + 00ED C5*04 275 xch a,(___int2fs_sloc1_1_0 + 2) + 00EF F5*05 276 mov (___int2fs_sloc1_1_0 + 3),a + 00F1 75*03 00 277 mov (___int2fs_sloc1_1_0 + 1),#0x00 + 00F4 75*02 00 278 mov ___int2fs_sloc1_1_0,#0x00 + 00F7 90s00r02 279 mov dptr,#___int2fs_sign_1_1 + 00FA E0 280 movx a,@dptr + 00FB FA 281 mov r2,a + 00FC A3 282 inc dptr + 00FD E0 283 movx a,@dptr + 00FE FB 284 mov r3,a + 00FF A3 285 inc dptr + 0100 E0 286 movx a,@dptr + 0101 F8 287 mov r0,a + 0102 A3 288 inc dptr + 0103 E0 289 movx a,@dptr + 0104 F9 290 mov r1,a + 0105 E5*02 291 mov a,___int2fs_sloc1_1_0 + 0107 42 02 292 orl ar2,a + 0109 E5*03 293 mov a,(___int2fs_sloc1_1_0 + 1) + 010B 42 03 294 orl ar3,a + 010D E5*04 295 mov a,(___int2fs_sloc1_1_0 + 2) + 010F 42 00 296 orl ar0,a + 0111 E5*05 297 mov a,(___int2fs_sloc1_1_0 + 3) + 0113 42 01 298 orl ar1,a + 0115 EA 299 mov a,r2 + 0116 42 04 300 orl ar4,a + 0118 EB 301 mov a,r3 + 0119 42 05 302 orl ar5,a + 011B E8 303 mov a,r0 + 011C 42 06 304 orl ar6,a + 011E E9 305 mov a,r1 + 011F 42 07 306 orl ar7,a + 0121 90s00r06 307 mov dptr,#(___int2fs_fl_1_1) + 0124 EC 308 mov a,r4 + 0125 F0 309 movx @dptr,a + 0126 A3 310 inc dptr + 0127 ED 311 mov a,r5 + 0128 F0 312 movx @dptr,a + 0129 A3 313 inc dptr + 012A EE 314 mov a,r6 + 012B F0 315 movx @dptr,a + 012C A3 316 inc dptr + 012D EF 317 mov a,r7 + 012E F0 318 movx @dptr,a + 319 ; _int2fs.c 110 + 012F 90s00r06 320 mov dptr,#(___int2fs_fl_1_1) + 0132 E0 321 movx a,@dptr + 0133 FA 322 mov r2,a + 0134 A3 323 inc dptr + 0135 E0 324 movx a,@dptr + 0136 FB 325 mov r3,a + 0137 A3 326 inc dptr + 0138 E0 327 movx a,@dptr + 0139 FC 328 mov r4,a + 013A A3 329 inc dptr + 013B E0 330 movx a,@dptr + 331 ; Peephole 191 removed redundant mov + 013C FD 332 mov r5,a + 013D 8A 82 333 mov dpl,r2 + 013F 8B 83 334 mov dph,r3 + 0141 8C F0 335 mov b,r4 + 0143 336 00108$: + 0143 337 C$_int2fs.c$111$1$1 ==. + 0143 338 XG$__int2fs$0$0 ==. + 0143 22 339 ret + 340 .area CSEG (CODE) diff --git a/device/lib/_int2fs.sym b/device/lib/_int2fs.sym new file mode 100644 index 00000000..cf804c5b --- /dev/null +++ b/device/lib/_int2fs.sym @@ -0,0 +1,602 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_int2fs$100 0029 GR + 7 A$_int2fs$101 002A GR + 7 A$_int2fs$102 002B GR + 7 A$_int2fs$103 002D GR + 7 A$_int2fs$104 002E GR + 7 A$_int2fs$105 002F GR + 7 A$_int2fs$106 0032 GR + 7 A$_int2fs$107 0033 GR + 7 A$_int2fs$108 0034 GR + 7 A$_int2fs$109 0035 GR + 7 A$_int2fs$110 0036 GR + 7 A$_int2fs$111 0037 GR + 7 A$_int2fs$112 0038 GR + 7 A$_int2fs$113 0039 GR + 7 A$_int2fs$114 003A GR + 7 A$_int2fs$115 003B GR + 7 A$_int2fs$116 003C GR + 7 A$_int2fs$118 003D GR + 7 A$_int2fs$119 003E GR + 7 A$_int2fs$120 003F GR + 7 A$_int2fs$121 0040 GR + 7 A$_int2fs$123 0041 GR + 7 A$_int2fs$126 0043 GR + 7 A$_int2fs$129 0046 GR + 7 A$_int2fs$130 0047 GR + 7 A$_int2fs$131 0048 GR + 7 A$_int2fs$132 0049 GR + 7 A$_int2fs$133 004A GR + 7 A$_int2fs$136 004B GR + 7 A$_int2fs$137 004C GR + 7 A$_int2fs$138 004D GR + 7 A$_int2fs$139 004E GR + 7 A$_int2fs$141 004F GR + 7 A$_int2fs$142 0052 GR + 7 A$_int2fs$143 0053 GR + 7 A$_int2fs$144 0054 GR + 7 A$_int2fs$145 0055 GR + 7 A$_int2fs$146 0056 GR + 7 A$_int2fs$147 0057 GR + 7 A$_int2fs$148 0058 GR + 7 A$_int2fs$149 0059 GR + 7 A$_int2fs$150 005A GR + 7 A$_int2fs$151 005B GR + 7 A$_int2fs$153 005C GR + 7 A$_int2fs$154 005D GR + 7 A$_int2fs$155 005F GR + 7 A$_int2fs$156 0061 GR + 7 A$_int2fs$157 0063 GR + 7 A$_int2fs$160 0066 GR + 7 A$_int2fs$162 0067 GR + 7 A$_int2fs$165 006A GR + 7 A$_int2fs$168 006D GR + 7 A$_int2fs$169 006E GR + 7 A$_int2fs$170 006F GR + 7 A$_int2fs$171 0070 GR + 7 A$_int2fs$172 0071 GR + 7 A$_int2fs$174 0072 GR + 7 A$_int2fs$175 0073 GR + 7 A$_int2fs$176 0074 GR + 7 A$_int2fs$177 0075 GR + 7 A$_int2fs$178 0077 GR + 7 A$_int2fs$180 0078 GR + 7 A$_int2fs$181 007B GR + 7 A$_int2fs$182 007C GR + 7 A$_int2fs$183 007D GR + 7 A$_int2fs$184 007E GR + 7 A$_int2fs$185 007F GR + 7 A$_int2fs$186 0080 GR + 7 A$_int2fs$187 0081 GR + 7 A$_int2fs$188 0082 GR + 7 A$_int2fs$189 0083 GR + 7 A$_int2fs$190 0084 GR + 7 A$_int2fs$191 0085 GR + 7 A$_int2fs$192 0086 GR + 7 A$_int2fs$193 0087 GR + 7 A$_int2fs$194 0088 GR + 7 A$_int2fs$195 0089 GR + 7 A$_int2fs$196 008A GR + 7 A$_int2fs$199 008B GR + 7 A$_int2fs$200 008C GR + 7 A$_int2fs$201 008E GR + 7 A$_int2fs$203 0091 GR + 7 A$_int2fs$204 0094 GR + 7 A$_int2fs$205 0095 GR + 7 A$_int2fs$206 0096 GR + 7 A$_int2fs$207 0097 GR + 7 A$_int2fs$208 0098 GR + 7 A$_int2fs$209 0099 GR + 7 A$_int2fs$210 009A GR + 7 A$_int2fs$211 009B GR + 7 A$_int2fs$212 009C GR + 7 A$_int2fs$213 009D GR + 7 A$_int2fs$214 009E GR + 7 A$_int2fs$215 009F GR + 7 A$_int2fs$216 00A0 GR + 7 A$_int2fs$217 00A1 GR + 7 A$_int2fs$218 00A3 GR + 7 A$_int2fs$219 00A4 GR + 7 A$_int2fs$220 00A6 GR + 7 A$_int2fs$221 00A7 GR + 7 A$_int2fs$222 00A9 GR + 7 A$_int2fs$223 00AA GR + 7 A$_int2fs$225 00AC GR + 7 A$_int2fs$228 00AE GR + 7 A$_int2fs$229 00AF GR + 7 A$_int2fs$230 00B1 GR + 7 A$_int2fs$231 00B2 GR + 7 A$_int2fs$232 00B3 GR + 7 A$_int2fs$233 00B4 GR + 7 A$_int2fs$234 00B5 GR + 7 A$_int2fs$235 00B6 GR + 7 A$_int2fs$236 00B7 GR + 7 A$_int2fs$237 00B8 GR + 7 A$_int2fs$238 00B9 GR + 7 A$_int2fs$239 00BA GR + 7 A$_int2fs$240 00BB GR + 7 A$_int2fs$241 00BE GR + 7 A$_int2fs$242 00BF GR + 7 A$_int2fs$243 00C0 GR + 7 A$_int2fs$244 00C1 GR + 7 A$_int2fs$245 00C2 GR + 7 A$_int2fs$246 00C3 GR + 7 A$_int2fs$247 00C4 GR + 7 A$_int2fs$248 00C5 GR + 7 A$_int2fs$249 00C6 GR + 7 A$_int2fs$250 00C7 GR + 7 A$_int2fs$251 00C8 GR + 7 A$_int2fs$253 00C9 GR + 7 A$_int2fs$254 00CB GR + 7 A$_int2fs$255 00CD GR + 7 A$_int2fs$256 00D0 GR + 7 A$_int2fs$258 00D2 GR + 7 A$_int2fs$261 00D5 GR + 7 A$_int2fs$263 00D8 GR + 7 A$_int2fs$264 00DA GR + 7 A$_int2fs$265 00DC GR + 7 A$_int2fs$266 00DE GR + 7 A$_int2fs$267 00E0 GR + 7 A$_int2fs$268 00E2 GR + 7 A$_int2fs$269 00E3 GR + 7 A$_int2fs$270 00E5 GR + 7 A$_int2fs$271 00E7 GR + 7 A$_int2fs$272 00E9 GR + 7 A$_int2fs$273 00EA GR + 7 A$_int2fs$274 00EC GR + 7 A$_int2fs$275 00ED GR + 7 A$_int2fs$276 00EF GR + 7 A$_int2fs$277 00F1 GR + 7 A$_int2fs$278 00F4 GR + 7 A$_int2fs$279 00F7 GR + 7 A$_int2fs$280 00FA GR + 7 A$_int2fs$281 00FB GR + 7 A$_int2fs$282 00FC GR + 7 A$_int2fs$283 00FD GR + 7 A$_int2fs$284 00FE GR + 7 A$_int2fs$285 00FF GR + 7 A$_int2fs$286 0100 GR + 7 A$_int2fs$287 0101 GR + 7 A$_int2fs$288 0102 GR + 7 A$_int2fs$289 0103 GR + 7 A$_int2fs$290 0104 GR + 7 A$_int2fs$291 0105 GR + 7 A$_int2fs$292 0107 GR + 7 A$_int2fs$293 0109 GR + 7 A$_int2fs$294 010B GR + 7 A$_int2fs$295 010D GR + 7 A$_int2fs$296 010F GR + 7 A$_int2fs$297 0111 GR + 7 A$_int2fs$298 0113 GR + 7 A$_int2fs$299 0115 GR + 7 A$_int2fs$300 0116 GR + 7 A$_int2fs$301 0118 GR + 7 A$_int2fs$302 0119 GR + 7 A$_int2fs$303 011B GR + 7 A$_int2fs$304 011C GR + 7 A$_int2fs$305 011E GR + 7 A$_int2fs$306 011F GR + 7 A$_int2fs$307 0121 GR + 7 A$_int2fs$308 0124 GR + 7 A$_int2fs$309 0125 GR + 7 A$_int2fs$310 0126 GR + 7 A$_int2fs$311 0127 GR + 7 A$_int2fs$312 0128 GR + 7 A$_int2fs$313 0129 GR + 7 A$_int2fs$314 012A GR + 7 A$_int2fs$315 012B GR + 7 A$_int2fs$316 012C GR + 7 A$_int2fs$317 012D GR + 7 A$_int2fs$318 012E GR + 7 A$_int2fs$320 012F GR + 7 A$_int2fs$321 0132 GR + 7 A$_int2fs$322 0133 GR + 7 A$_int2fs$323 0134 GR + 7 A$_int2fs$324 0135 GR + 7 A$_int2fs$325 0136 GR + 7 A$_int2fs$326 0137 GR + 7 A$_int2fs$327 0138 GR + 7 A$_int2fs$328 0139 GR + 7 A$_int2fs$329 013A GR + 7 A$_int2fs$330 013B GR + 7 A$_int2fs$332 013C GR + 7 A$_int2fs$333 013D GR + 7 A$_int2fs$334 013F GR + 7 A$_int2fs$335 0141 GR + 7 A$_int2fs$339 0143 GR + 7 A$_int2fs$72 0000 GR + 7 A$_int2fs$73 0002 GR + 7 A$_int2fs$74 0004 GR + 7 A$_int2fs$75 0007 GR + 7 A$_int2fs$76 0009 GR + 7 A$_int2fs$77 000A GR + 7 A$_int2fs$78 000C GR + 7 A$_int2fs$79 000D GR + 7 A$_int2fs$81 000E GR + 7 A$_int2fs$82 0011 GR + 7 A$_int2fs$83 0012 GR + 7 A$_int2fs$84 0013 GR + 7 A$_int2fs$85 0014 GR + 7 A$_int2fs$86 0015 GR + 7 A$_int2fs$87 0016 GR + 7 A$_int2fs$88 0019 GR + 7 A$_int2fs$89 001A GR + 7 A$_int2fs$90 001D GR + 7 A$_int2fs$91 001E GR + 7 A$_int2fs$92 0021 GR + 7 A$_int2fs$94 0022 GR + 7 A$_int2fs$95 0025 GR + 7 A$_int2fs$96 0026 GR + 7 A$_int2fs$97 0027 GR + 7 A$_int2fs$98 0028 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_int2fs.c$111$1$1 = 0143 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__int2fs$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__int2fs$0$0 = 0143 GR + 7 ___int2fs 0000 GR + 5 ___int2fs_a1_1_1 000A R + 5 ___int2fs_a_1_1 0000 R + 5 ___int2fs_fl_1_1 0006 R + 5 ___int2fs_sign_1_1 0002 R + 1 ___int2fs_sloc0_1_0 0000 R + 1 ___int2fs_sloc1_1_0 0002 R + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 144 flags 20 diff --git a/device/lib/_iscntrl.c b/device/lib/_iscntrl.c new file mode 100644 index 00000000..3cb5cdeb --- /dev/null +++ b/device/lib/_iscntrl.c @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------- + _iscntrl.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#define REG_UCHAR register unsigned char + +char iscntrl(unsigned char c) +{ + + if ( c <= '\x1F' || c == '\x7f') + return 1; + return 0; +} diff --git a/device/lib/_iscntrl.lst b/device/lib/_iscntrl.lst new file mode 100644 index 00000000..4ebf0857 --- /dev/null +++ b/device/lib/_iscntrl.lst @@ -0,0 +1,94 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _iscntrl + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _iscntrl + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _iscntrl_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$iscntrl$0$0 ==. + 48 ; _iscntrl.c 27 + 49 ; ----------------------------------------- + 50 ; function iscntrl + 51 ; ----------------------------------------- + 0000 52 _iscntrl: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _iscntrl.c 32 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_iscntrl_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _iscntrl.c 30 + 0008 90s00r00 67 mov dptr,#_iscntrl_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D C3 70 clr c + 000E 74 1F 71 mov a,#0x1f + 0010 9A 72 subb a,r2 + 73 ; Peephole 108 removed ljmp by inverse jump logic + 0011 50 03 74 jnc 00101$ + 0013 75 00107$: + 76 ; Peephole 132 changed ljmp to sjmp + 77 ; Peephole 199 optimized misc jump sequence + 0013 BA 7F 05 78 cjne r2,#0x7f,00102$ + 79 ; Peephole 201 removed redundant sjmp + 0016 80 00108$: + 0016 81 00109$: + 0016 82 00101$: + 83 ; _iscntrl.c 31 + 0016 75 82 01 84 mov dpl,#0x01 + 85 ; Peephole 132 changed ljmp to sjmp + 0019 80 03 86 sjmp 00104$ + 001B 87 00102$: + 88 ; _iscntrl.c 32 + 001B 75 82 00 89 mov dpl,#0x00 + 001E 90 00104$: + 001E 91 C$_iscntrl.c$33$1$1 ==. + 001E 92 XG$iscntrl$0$0 ==. + 001E 22 93 ret + 94 .area CSEG (CODE) diff --git a/device/lib/_iscntrl.sym b/device/lib/_iscntrl.sym new file mode 100644 index 00000000..55f1b535 --- /dev/null +++ b/device/lib/_iscntrl.sym @@ -0,0 +1,382 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_iscntrl$62 0000 GR + 7 A$_iscntrl$63 0002 GR + 7 A$_iscntrl$64 0005 GR + 7 A$_iscntrl$65 0007 GR + 7 A$_iscntrl$67 0008 GR + 7 A$_iscntrl$68 000B GR + 7 A$_iscntrl$69 000C GR + 7 A$_iscntrl$70 000D GR + 7 A$_iscntrl$71 000E GR + 7 A$_iscntrl$72 0010 GR + 7 A$_iscntrl$74 0011 GR + 7 A$_iscntrl$78 0013 GR + 7 A$_iscntrl$84 0016 GR + 7 A$_iscntrl$86 0019 GR + 7 A$_iscntrl$89 001B GR + 7 A$_iscntrl$93 001E GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_iscntrl.c$33$1$1 = 001E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$iscntrl$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$iscntrl$0$0 = 001E GR + 7 _iscntrl 0000 GR + 5 _iscntrl_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 1F flags 20 diff --git a/device/lib/_isdigit.c b/device/lib/_isdigit.c new file mode 100644 index 00000000..176ed89b --- /dev/null +++ b/device/lib/_isdigit.c @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------- + _isdigit.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + + +char isdigit( unsigned char c) +{ + + if ( c >= '0' && c <= '9' ) + return 1; + return 0; +} diff --git a/device/lib/_isdigit.lst b/device/lib/_isdigit.lst new file mode 100644 index 00000000..a153cf10 --- /dev/null +++ b/device/lib/_isdigit.lst @@ -0,0 +1,94 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _isdigit + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _isdigit + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _isdigit_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$isdigit$0$0 ==. + 48 ; _isdigit.c 26 + 49 ; ----------------------------------------- + 50 ; function isdigit + 51 ; ----------------------------------------- + 0000 52 _isdigit: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _isdigit.c 31 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_isdigit_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _isdigit.c 29 + 0008 90s00r00 67 mov dptr,#_isdigit_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D BA 30 00 70 cjne r2,#0x30,00108$ + 0010 71 00108$: + 72 ; Peephole 132 changed ljmp to sjmp + 73 ; Peephole 160 removed sjmp by inverse jump logic + 0010 40 0B 74 jc 00102$ + 0012 75 00109$: + 0012 C3 76 clr c + 0013 74 39 77 mov a,#0x39 + 0015 9A 78 subb a,r2 + 79 ; Peephole 132 changed ljmp to sjmp + 80 ; Peephole 160 removed sjmp by inverse jump logic + 0016 40 05 81 jc 00102$ + 0018 82 00110$: + 83 ; _isdigit.c 30 + 0018 75 82 01 84 mov dpl,#0x01 + 85 ; Peephole 132 changed ljmp to sjmp + 001B 80 03 86 sjmp 00104$ + 001D 87 00102$: + 88 ; _isdigit.c 31 + 001D 75 82 00 89 mov dpl,#0x00 + 0020 90 00104$: + 0020 91 C$_isdigit.c$32$1$1 ==. + 0020 92 XG$isdigit$0$0 ==. + 0020 22 93 ret + 94 .area CSEG (CODE) diff --git a/device/lib/_isdigit.sym b/device/lib/_isdigit.sym new file mode 100644 index 00000000..fc2f8438 --- /dev/null +++ b/device/lib/_isdigit.sym @@ -0,0 +1,383 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_isdigit$62 0000 GR + 7 A$_isdigit$63 0002 GR + 7 A$_isdigit$64 0005 GR + 7 A$_isdigit$65 0007 GR + 7 A$_isdigit$67 0008 GR + 7 A$_isdigit$68 000B GR + 7 A$_isdigit$69 000C GR + 7 A$_isdigit$70 000D GR + 7 A$_isdigit$74 0010 GR + 7 A$_isdigit$76 0012 GR + 7 A$_isdigit$77 0013 GR + 7 A$_isdigit$78 0015 GR + 7 A$_isdigit$81 0016 GR + 7 A$_isdigit$84 0018 GR + 7 A$_isdigit$86 001B GR + 7 A$_isdigit$89 001D GR + 7 A$_isdigit$93 0020 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_isdigit.c$32$1$1 = 0020 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$isdigit$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$isdigit$0$0 = 0020 GR + 7 _isdigit 0000 GR + 5 _isdigit_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 21 flags 20 diff --git a/device/lib/_isgraph.c b/device/lib/_isgraph.c new file mode 100644 index 00000000..7dd2b324 --- /dev/null +++ b/device/lib/_isgraph.c @@ -0,0 +1,31 @@ +/*------------------------------------------------------------------------- + _isgraph.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +char isgraph( unsigned char c) +{ + + if ( c >= '\x21' && c <= '\x7e' ) + return 1; + return 0; +} diff --git a/device/lib/_isgraph.lst b/device/lib/_isgraph.lst new file mode 100644 index 00000000..33c84c74 --- /dev/null +++ b/device/lib/_isgraph.lst @@ -0,0 +1,94 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _isgraph + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _isgraph + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _isgraph_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$isgraph$0$0 ==. + 48 ; _isgraph.c 25 + 49 ; ----------------------------------------- + 50 ; function isgraph + 51 ; ----------------------------------------- + 0000 52 _isgraph: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _isgraph.c 30 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_isgraph_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _isgraph.c 28 + 0008 90s00r00 67 mov dptr,#_isgraph_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D BA 21 00 70 cjne r2,#0x21,00108$ + 0010 71 00108$: + 72 ; Peephole 132 changed ljmp to sjmp + 73 ; Peephole 160 removed sjmp by inverse jump logic + 0010 40 0B 74 jc 00102$ + 0012 75 00109$: + 0012 C3 76 clr c + 0013 74 7E 77 mov a,#0x7e + 0015 9A 78 subb a,r2 + 79 ; Peephole 132 changed ljmp to sjmp + 80 ; Peephole 160 removed sjmp by inverse jump logic + 0016 40 05 81 jc 00102$ + 0018 82 00110$: + 83 ; _isgraph.c 29 + 0018 75 82 01 84 mov dpl,#0x01 + 85 ; Peephole 132 changed ljmp to sjmp + 001B 80 03 86 sjmp 00104$ + 001D 87 00102$: + 88 ; _isgraph.c 30 + 001D 75 82 00 89 mov dpl,#0x00 + 0020 90 00104$: + 0020 91 C$_isgraph.c$31$1$1 ==. + 0020 92 XG$isgraph$0$0 ==. + 0020 22 93 ret + 94 .area CSEG (CODE) diff --git a/device/lib/_isgraph.sym b/device/lib/_isgraph.sym new file mode 100644 index 00000000..b7134ea0 --- /dev/null +++ b/device/lib/_isgraph.sym @@ -0,0 +1,383 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_isgraph$62 0000 GR + 7 A$_isgraph$63 0002 GR + 7 A$_isgraph$64 0005 GR + 7 A$_isgraph$65 0007 GR + 7 A$_isgraph$67 0008 GR + 7 A$_isgraph$68 000B GR + 7 A$_isgraph$69 000C GR + 7 A$_isgraph$70 000D GR + 7 A$_isgraph$74 0010 GR + 7 A$_isgraph$76 0012 GR + 7 A$_isgraph$77 0013 GR + 7 A$_isgraph$78 0015 GR + 7 A$_isgraph$81 0016 GR + 7 A$_isgraph$84 0018 GR + 7 A$_isgraph$86 001B GR + 7 A$_isgraph$89 001D GR + 7 A$_isgraph$93 0020 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_isgraph.c$31$1$1 = 0020 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$isgraph$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$isgraph$0$0 = 0020 GR + 7 _isgraph 0000 GR + 5 _isgraph_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 21 flags 20 diff --git a/device/lib/_islower.c b/device/lib/_islower.c new file mode 100644 index 00000000..72c697ac --- /dev/null +++ b/device/lib/_islower.c @@ -0,0 +1,31 @@ +/*------------------------------------------------------------------------- + _islower.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +char islower(unsigned char c) +{ + + if ( c >= 'a' && c <= 'z' ) + return 1; + return 0; +} diff --git a/device/lib/_islower.lst b/device/lib/_islower.lst new file mode 100644 index 00000000..b8f35679 --- /dev/null +++ b/device/lib/_islower.lst @@ -0,0 +1,94 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _islower + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _islower + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _islower_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$islower$0$0 ==. + 48 ; _islower.c 25 + 49 ; ----------------------------------------- + 50 ; function islower + 51 ; ----------------------------------------- + 0000 52 _islower: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _islower.c 30 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_islower_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _islower.c 28 + 0008 90s00r00 67 mov dptr,#_islower_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D BA 61 00 70 cjne r2,#0x61,00108$ + 0010 71 00108$: + 72 ; Peephole 132 changed ljmp to sjmp + 73 ; Peephole 160 removed sjmp by inverse jump logic + 0010 40 0B 74 jc 00102$ + 0012 75 00109$: + 0012 C3 76 clr c + 0013 74 7A 77 mov a,#0x7a + 0015 9A 78 subb a,r2 + 79 ; Peephole 132 changed ljmp to sjmp + 80 ; Peephole 160 removed sjmp by inverse jump logic + 0016 40 05 81 jc 00102$ + 0018 82 00110$: + 83 ; _islower.c 29 + 0018 75 82 01 84 mov dpl,#0x01 + 85 ; Peephole 132 changed ljmp to sjmp + 001B 80 03 86 sjmp 00104$ + 001D 87 00102$: + 88 ; _islower.c 30 + 001D 75 82 00 89 mov dpl,#0x00 + 0020 90 00104$: + 0020 91 C$_islower.c$31$1$1 ==. + 0020 92 XG$islower$0$0 ==. + 0020 22 93 ret + 94 .area CSEG (CODE) diff --git a/device/lib/_islower.sym b/device/lib/_islower.sym new file mode 100644 index 00000000..cf73ec79 --- /dev/null +++ b/device/lib/_islower.sym @@ -0,0 +1,383 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_islower$62 0000 GR + 7 A$_islower$63 0002 GR + 7 A$_islower$64 0005 GR + 7 A$_islower$65 0007 GR + 7 A$_islower$67 0008 GR + 7 A$_islower$68 000B GR + 7 A$_islower$69 000C GR + 7 A$_islower$70 000D GR + 7 A$_islower$74 0010 GR + 7 A$_islower$76 0012 GR + 7 A$_islower$77 0013 GR + 7 A$_islower$78 0015 GR + 7 A$_islower$81 0016 GR + 7 A$_islower$84 0018 GR + 7 A$_islower$86 001B GR + 7 A$_islower$89 001D GR + 7 A$_islower$93 0020 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_islower.c$31$1$1 = 0020 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$islower$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$islower$0$0 = 0020 GR + 7 _islower 0000 GR + 5 _islower_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 21 flags 20 diff --git a/device/lib/_isprint.c b/device/lib/_isprint.c new file mode 100644 index 00000000..37fe47e2 --- /dev/null +++ b/device/lib/_isprint.c @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + _isprint.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +char isprint (unsigned char c) +{ + + if ( c >= '\x20' && c <= '\x7e') + return 1; + return 0; +} diff --git a/device/lib/_isprint.lst b/device/lib/_isprint.lst new file mode 100644 index 00000000..fcbf1a12 --- /dev/null +++ b/device/lib/_isprint.lst @@ -0,0 +1,94 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _isprint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _isprint + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _isprint_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$isprint$0$0 ==. + 48 ; _isprint.c 24 + 49 ; ----------------------------------------- + 50 ; function isprint + 51 ; ----------------------------------------- + 0000 52 _isprint: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _isprint.c 29 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_isprint_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _isprint.c 27 + 0008 90s00r00 67 mov dptr,#_isprint_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D BA 20 00 70 cjne r2,#0x20,00108$ + 0010 71 00108$: + 72 ; Peephole 132 changed ljmp to sjmp + 73 ; Peephole 160 removed sjmp by inverse jump logic + 0010 40 0B 74 jc 00102$ + 0012 75 00109$: + 0012 C3 76 clr c + 0013 74 7E 77 mov a,#0x7e + 0015 9A 78 subb a,r2 + 79 ; Peephole 132 changed ljmp to sjmp + 80 ; Peephole 160 removed sjmp by inverse jump logic + 0016 40 05 81 jc 00102$ + 0018 82 00110$: + 83 ; _isprint.c 28 + 0018 75 82 01 84 mov dpl,#0x01 + 85 ; Peephole 132 changed ljmp to sjmp + 001B 80 03 86 sjmp 00104$ + 001D 87 00102$: + 88 ; _isprint.c 29 + 001D 75 82 00 89 mov dpl,#0x00 + 0020 90 00104$: + 0020 91 C$_isprint.c$30$1$1 ==. + 0020 92 XG$isprint$0$0 ==. + 0020 22 93 ret + 94 .area CSEG (CODE) diff --git a/device/lib/_isprint.sym b/device/lib/_isprint.sym new file mode 100644 index 00000000..3f37cdbe --- /dev/null +++ b/device/lib/_isprint.sym @@ -0,0 +1,383 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_isprint$62 0000 GR + 7 A$_isprint$63 0002 GR + 7 A$_isprint$64 0005 GR + 7 A$_isprint$65 0007 GR + 7 A$_isprint$67 0008 GR + 7 A$_isprint$68 000B GR + 7 A$_isprint$69 000C GR + 7 A$_isprint$70 000D GR + 7 A$_isprint$74 0010 GR + 7 A$_isprint$76 0012 GR + 7 A$_isprint$77 0013 GR + 7 A$_isprint$78 0015 GR + 7 A$_isprint$81 0016 GR + 7 A$_isprint$84 0018 GR + 7 A$_isprint$86 001B GR + 7 A$_isprint$89 001D GR + 7 A$_isprint$93 0020 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_isprint.c$30$1$1 = 0020 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$isprint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$isprint$0$0 = 0020 GR + 7 _isprint 0000 GR + 5 _isprint_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 21 flags 20 diff --git a/device/lib/_ispunct.c b/device/lib/_ispunct.c new file mode 100644 index 00000000..925af1ff --- /dev/null +++ b/device/lib/_ispunct.c @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + _ispunct.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "ctype.h" +char ispunct (unsigned char c) +{ + + if (isprint (c) && + !islower(c) && + !isupper(c) && + c != ' ' && + !isdigit(c)) + return 1; + return 0; +} diff --git a/device/lib/_ispunct.lst b/device/lib/_ispunct.lst new file mode 100644 index 00000000..9cb02fa4 --- /dev/null +++ b/device/lib/_ispunct.lst @@ -0,0 +1,123 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _ispunct + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _ispunct + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _ispunct_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$ispunct$0$0 ==. + 48 ; _ispunct.c 25 + 49 ; ----------------------------------------- + 50 ; function ispunct + 51 ; ----------------------------------------- + 0000 52 _ispunct: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _ispunct.c 34 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_ispunct_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _ispunct.c 28 + 0008 90s00r00 67 mov dptr,#_ispunct_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D C0 02 70 push ar2 + 000F 8A 82 71 mov dpl,r2 + 0011 12s00r00 72 lcall _isprint + 0014 AB 82 73 mov r3,dpl + 0016 D0 02 74 pop ar2 + 0018 EB 75 mov a,r3 + 76 ; Peephole 110 removed ljmp by inverse jump logic + 0019 60 30 77 jz 00102$ + 001B 78 00114$: + 79 ; _ispunct.c 29 + 001B C0 02 80 push ar2 + 001D 8A 82 81 mov dpl,r2 + 001F 12s00r00 82 lcall _islower + 0022 AB 82 83 mov r3,dpl + 0024 D0 02 84 pop ar2 + 0026 EB 85 mov a,r3 + 86 ; Peephole 109 removed ljmp by inverse jump logic + 0027 70 22 87 jnz 00102$ + 0029 88 00115$: + 89 ; _ispunct.c 30 + 0029 C0 02 90 push ar2 + 002B 8A 82 91 mov dpl,r2 + 002D 12s00r00 92 lcall _isupper + 0030 AB 82 93 mov r3,dpl + 0032 D0 02 94 pop ar2 + 0034 EB 95 mov a,r3 + 96 ; Peephole 109 removed ljmp by inverse jump logic + 0035 70 14 97 jnz 00102$ + 0037 98 00116$: + 99 ; _ispunct.c 31 + 0037 BA 20 02 100 cjne r2,#0x20,00117$ + 101 ; Peephole 132 changed ljmp to sjmp + 003A 80 0F 102 sjmp 00102$ + 003C 103 00117$: + 104 ; _ispunct.c 32 + 003C 8A 82 105 mov dpl,r2 + 003E 12s00r00 106 lcall _isdigit + 0041 AA 82 107 mov r2,dpl + 0043 EA 108 mov a,r2 + 109 ; Peephole 109 removed ljmp by inverse jump logic + 0044 70 05 110 jnz 00102$ + 0046 111 00118$: + 112 ; _ispunct.c 33 + 0046 75 82 01 113 mov dpl,#0x01 + 114 ; Peephole 132 changed ljmp to sjmp + 0049 80 03 115 sjmp 00107$ + 004B 116 00102$: + 117 ; _ispunct.c 34 + 004B 75 82 00 118 mov dpl,#0x00 + 004E 119 00107$: + 004E 120 C$_ispunct.c$35$1$1 ==. + 004E 121 XG$ispunct$0$0 ==. + 004E 22 122 ret + 123 .area CSEG (CODE) diff --git a/device/lib/_ispunct.sym b/device/lib/_ispunct.sym new file mode 100644 index 00000000..a6139d89 --- /dev/null +++ b/device/lib/_ispunct.sym @@ -0,0 +1,409 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_ispunct$100 0037 GR + 7 A$_ispunct$102 003A GR + 7 A$_ispunct$105 003C GR + 7 A$_ispunct$106 003E GR + 7 A$_ispunct$107 0041 GR + 7 A$_ispunct$108 0043 GR + 7 A$_ispunct$110 0044 GR + 7 A$_ispunct$113 0046 GR + 7 A$_ispunct$115 0049 GR + 7 A$_ispunct$118 004B GR + 7 A$_ispunct$122 004E GR + 7 A$_ispunct$62 0000 GR + 7 A$_ispunct$63 0002 GR + 7 A$_ispunct$64 0005 GR + 7 A$_ispunct$65 0007 GR + 7 A$_ispunct$67 0008 GR + 7 A$_ispunct$68 000B GR + 7 A$_ispunct$69 000C GR + 7 A$_ispunct$70 000D GR + 7 A$_ispunct$71 000F GR + 7 A$_ispunct$72 0011 GR + 7 A$_ispunct$73 0014 GR + 7 A$_ispunct$74 0016 GR + 7 A$_ispunct$75 0018 GR + 7 A$_ispunct$77 0019 GR + 7 A$_ispunct$80 001B GR + 7 A$_ispunct$81 001D GR + 7 A$_ispunct$82 001F GR + 7 A$_ispunct$83 0022 GR + 7 A$_ispunct$84 0024 GR + 7 A$_ispunct$85 0026 GR + 7 A$_ispunct$87 0027 GR + 7 A$_ispunct$90 0029 GR + 7 A$_ispunct$91 002B GR + 7 A$_ispunct$92 002D GR + 7 A$_ispunct$93 0030 GR + 7 A$_ispunct$94 0032 GR + 7 A$_ispunct$95 0034 GR + 7 A$_ispunct$97 0035 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_ispunct.c$35$1$1 = 004E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$ispunct$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$ispunct$0$0 = 004E GR + _isdigit **** GX + _islower **** GX + _isprint **** GX + 7 _ispunct 0000 GR + 5 _ispunct_c_1_1 0000 R + _isupper **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 4F flags 20 diff --git a/device/lib/_isspace.c b/device/lib/_isspace.c new file mode 100644 index 00000000..d5c6455e --- /dev/null +++ b/device/lib/_isspace.c @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + _isppace.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +char isspace (unsigned char c) +{ + + if ( c == ' ' || + c == '\f' || + c == '\n' || + c == '\r' || + c == '\t' || + c == '\v' ) + return 1; + return 0; +} diff --git a/device/lib/_isspace.lst b/device/lib/_isspace.lst new file mode 100644 index 00000000..6ae43fa9 --- /dev/null +++ b/device/lib/_isspace.lst @@ -0,0 +1,113 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _isspace + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _isspace + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _isspace_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$isspace$0$0 ==. + 48 ; _isspace.c 24 + 49 ; ----------------------------------------- + 50 ; function isspace + 51 ; ----------------------------------------- + 0000 52 _isspace: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _isspace.c 34 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_isspace_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _isspace.c 27 + 0008 90s00r00 67 mov dptr,#_isspace_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D BA 20 02 70 cjne r2,#0x20,00115$ + 71 ; Peephole 132 changed ljmp to sjmp + 0010 80 17 72 sjmp 00101$ + 0012 73 00115$: + 74 ; _isspace.c 28 + 0012 BA 0C 02 75 cjne r2,#0x0c,00116$ + 76 ; Peephole 132 changed ljmp to sjmp + 0015 80 12 77 sjmp 00101$ + 0017 78 00116$: + 79 ; _isspace.c 29 + 0017 BA 0A 02 80 cjne r2,#0x0a,00117$ + 81 ; Peephole 132 changed ljmp to sjmp + 001A 80 0D 82 sjmp 00101$ + 001C 83 00117$: + 84 ; _isspace.c 30 + 001C BA 0D 02 85 cjne r2,#0x0d,00118$ + 86 ; Peephole 132 changed ljmp to sjmp + 001F 80 08 87 sjmp 00101$ + 0021 88 00118$: + 89 ; _isspace.c 31 + 0021 BA 09 02 90 cjne r2,#0x09,00119$ + 91 ; Peephole 132 changed ljmp to sjmp + 0024 80 03 92 sjmp 00101$ + 0026 93 00119$: + 94 ; _isspace.c 32 + 95 ; Peephole 132 changed ljmp to sjmp + 96 ; Peephole 199 optimized misc jump sequence + 0026 BA 0B 05 97 cjne r2,#0x0b,00102$ + 98 ; Peephole 201 removed redundant sjmp + 0029 99 00120$: + 0029 100 00121$: + 0029 101 00101$: + 102 ; _isspace.c 33 + 0029 75 82 01 103 mov dpl,#0x01 + 104 ; Peephole 132 changed ljmp to sjmp + 002C 80 03 105 sjmp 00108$ + 002E 106 00102$: + 107 ; _isspace.c 34 + 002E 75 82 00 108 mov dpl,#0x00 + 0031 109 00108$: + 0031 110 C$_isspace.c$35$1$1 ==. + 0031 111 XG$isspace$0$0 ==. + 0031 22 112 ret + 113 .area CSEG (CODE) diff --git a/device/lib/_isspace.sym b/device/lib/_isspace.sym new file mode 100644 index 00000000..c61a28a1 --- /dev/null +++ b/device/lib/_isspace.sym @@ -0,0 +1,388 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_isspace$103 0029 GR + 7 A$_isspace$105 002C GR + 7 A$_isspace$108 002E GR + 7 A$_isspace$112 0031 GR + 7 A$_isspace$62 0000 GR + 7 A$_isspace$63 0002 GR + 7 A$_isspace$64 0005 GR + 7 A$_isspace$65 0007 GR + 7 A$_isspace$67 0008 GR + 7 A$_isspace$68 000B GR + 7 A$_isspace$69 000C GR + 7 A$_isspace$70 000D GR + 7 A$_isspace$72 0010 GR + 7 A$_isspace$75 0012 GR + 7 A$_isspace$77 0015 GR + 7 A$_isspace$80 0017 GR + 7 A$_isspace$82 001A GR + 7 A$_isspace$85 001C GR + 7 A$_isspace$87 001F GR + 7 A$_isspace$90 0021 GR + 7 A$_isspace$92 0024 GR + 7 A$_isspace$97 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_isspace.c$35$1$1 = 0031 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$isspace$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$isspace$0$0 = 0031 GR + 7 _isspace 0000 GR + 5 _isspace_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 32 flags 20 diff --git a/device/lib/_isupper.c b/device/lib/_isupper.c new file mode 100644 index 00000000..b2505b56 --- /dev/null +++ b/device/lib/_isupper.c @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + _isupper.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + char isupper (unsigned char c) +{ + + if ( c >= 'A' && c <= 'Z') + return 1; + return 0; +} diff --git a/device/lib/_isupper.lst b/device/lib/_isupper.lst new file mode 100644 index 00000000..f7a64893 --- /dev/null +++ b/device/lib/_isupper.lst @@ -0,0 +1,94 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _isupper + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _isupper + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _isupper_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$isupper$0$0 ==. + 48 ; _isupper.c 24 + 49 ; ----------------------------------------- + 50 ; function isupper + 51 ; ----------------------------------------- + 0000 52 _isupper: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _isupper.c 29 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_isupper_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _isupper.c 27 + 0008 90s00r00 67 mov dptr,#_isupper_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D BA 41 00 70 cjne r2,#0x41,00108$ + 0010 71 00108$: + 72 ; Peephole 132 changed ljmp to sjmp + 73 ; Peephole 160 removed sjmp by inverse jump logic + 0010 40 0B 74 jc 00102$ + 0012 75 00109$: + 0012 C3 76 clr c + 0013 74 5A 77 mov a,#0x5a + 0015 9A 78 subb a,r2 + 79 ; Peephole 132 changed ljmp to sjmp + 80 ; Peephole 160 removed sjmp by inverse jump logic + 0016 40 05 81 jc 00102$ + 0018 82 00110$: + 83 ; _isupper.c 28 + 0018 75 82 01 84 mov dpl,#0x01 + 85 ; Peephole 132 changed ljmp to sjmp + 001B 80 03 86 sjmp 00104$ + 001D 87 00102$: + 88 ; _isupper.c 29 + 001D 75 82 00 89 mov dpl,#0x00 + 0020 90 00104$: + 0020 91 C$_isupper.c$30$1$1 ==. + 0020 92 XG$isupper$0$0 ==. + 0020 22 93 ret + 94 .area CSEG (CODE) diff --git a/device/lib/_isupper.sym b/device/lib/_isupper.sym new file mode 100644 index 00000000..226b73c5 --- /dev/null +++ b/device/lib/_isupper.sym @@ -0,0 +1,383 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_isupper$62 0000 GR + 7 A$_isupper$63 0002 GR + 7 A$_isupper$64 0005 GR + 7 A$_isupper$65 0007 GR + 7 A$_isupper$67 0008 GR + 7 A$_isupper$68 000B GR + 7 A$_isupper$69 000C GR + 7 A$_isupper$70 000D GR + 7 A$_isupper$74 0010 GR + 7 A$_isupper$76 0012 GR + 7 A$_isupper$77 0013 GR + 7 A$_isupper$78 0015 GR + 7 A$_isupper$81 0016 GR + 7 A$_isupper$84 0018 GR + 7 A$_isupper$86 001B GR + 7 A$_isupper$89 001D GR + 7 A$_isupper$93 0020 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_isupper.c$30$1$1 = 0020 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$isupper$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$isupper$0$0 = 0020 GR + 7 _isupper 0000 GR + 5 _isupper_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 21 flags 20 diff --git a/device/lib/_isxdigit.c b/device/lib/_isxdigit.c new file mode 100644 index 00000000..6c8240b4 --- /dev/null +++ b/device/lib/_isxdigit.c @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + _isxdigit.c - part of ctype.h + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +char isxdigit (unsigned char c) +{ + + if (( c >= '0' && c <= '9') || + ( c >= 'a' && c <= 'f') || + ( c >= 'A' && c <= 'F')) + return 1; + return 0; + +} + diff --git a/device/lib/_isxdigit.lst b/device/lib/_isxdigit.lst new file mode 100644 index 00000000..2f6dbb3a --- /dev/null +++ b/device/lib/_isxdigit.lst @@ -0,0 +1,129 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _isxdigit + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _isxdigit + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _isxdigit_c_1_1: + 0000 38 .ds 0x0001 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$isxdigit$0$0 ==. + 48 ; _isxdigit.c 24 + 49 ; ----------------------------------------- + 50 ; function isxdigit + 51 ; ----------------------------------------- + 0000 52 _isxdigit: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _isxdigit.c 31 + 0000 C0 82 62 push dpl + 0002 90s00r00 63 mov dptr,#_isxdigit_c_1_1 + 0005 D0 E0 64 pop acc + 0007 F0 65 movx @dptr,a + 66 ; _isxdigit.c 27 + 0008 90s00r00 67 mov dptr,#_isxdigit_c_1_1 + 000B E0 68 movx a,@dptr + 000C FA 69 mov r2,a + 000D BA 30 00 70 cjne r2,#0x30,00113$ + 0010 71 00113$: + 72 ; Peephole 132 changed ljmp to sjmp + 73 ; Peephole 160 removed sjmp by inverse jump logic + 0010 40 06 74 jc 00105$ + 0012 75 00114$: + 0012 C3 76 clr c + 0013 74 39 77 mov a,#0x39 + 0015 9A 78 subb a,r2 + 79 ; Peephole 108 removed ljmp by inverse jump logic + 0016 50 20 80 jnc 00101$ + 0018 81 00115$: + 0018 82 00105$: + 83 ; _isxdigit.c 28 + 0018 90s00r00 84 mov dptr,#_isxdigit_c_1_1 + 001B E0 85 movx a,@dptr + 001C FA 86 mov r2,a + 001D BA 61 00 87 cjne r2,#0x61,00116$ + 0020 88 00116$: + 89 ; Peephole 132 changed ljmp to sjmp + 90 ; Peephole 160 removed sjmp by inverse jump logic + 0020 40 06 91 jc 00107$ + 0022 92 00117$: + 0022 C3 93 clr c + 0023 74 66 94 mov a,#0x66 + 0025 9A 95 subb a,r2 + 96 ; Peephole 108 removed ljmp by inverse jump logic + 0026 50 10 97 jnc 00101$ + 0028 98 00118$: + 0028 99 00107$: + 100 ; _isxdigit.c 29 + 0028 90s00r00 101 mov dptr,#_isxdigit_c_1_1 + 002B E0 102 movx a,@dptr + 002C FA 103 mov r2,a + 002D BA 41 00 104 cjne r2,#0x41,00119$ + 0030 105 00119$: + 106 ; Peephole 132 changed ljmp to sjmp + 107 ; Peephole 160 removed sjmp by inverse jump logic + 0030 40 0B 108 jc 00102$ + 0032 109 00120$: + 0032 C3 110 clr c + 0033 74 46 111 mov a,#0x46 + 0035 9A 112 subb a,r2 + 113 ; Peephole 132 changed ljmp to sjmp + 114 ; Peephole 160 removed sjmp by inverse jump logic + 0036 40 05 115 jc 00102$ + 0038 116 00121$: + 0038 117 00101$: + 118 ; _isxdigit.c 30 + 0038 75 82 01 119 mov dpl,#0x01 + 120 ; Peephole 132 changed ljmp to sjmp + 003B 80 03 121 sjmp 00108$ + 003D 122 00102$: + 123 ; _isxdigit.c 31 + 003D 75 82 00 124 mov dpl,#0x00 + 0040 125 00108$: + 0040 126 C$_isxdigit.c$33$1$1 ==. + 0040 127 XG$isxdigit$0$0 ==. + 0040 22 128 ret + 129 .area CSEG (CODE) diff --git a/device/lib/_isxdigit.sym b/device/lib/_isxdigit.sym new file mode 100644 index 00000000..ea0b89e5 --- /dev/null +++ b/device/lib/_isxdigit.sym @@ -0,0 +1,401 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_isxdigit$101 0028 GR + 7 A$_isxdigit$102 002B GR + 7 A$_isxdigit$103 002C GR + 7 A$_isxdigit$104 002D GR + 7 A$_isxdigit$108 0030 GR + 7 A$_isxdigit$110 0032 GR + 7 A$_isxdigit$111 0033 GR + 7 A$_isxdigit$112 0035 GR + 7 A$_isxdigit$115 0036 GR + 7 A$_isxdigit$119 0038 GR + 7 A$_isxdigit$121 003B GR + 7 A$_isxdigit$124 003D GR + 7 A$_isxdigit$128 0040 GR + 7 A$_isxdigit$62 0000 GR + 7 A$_isxdigit$63 0002 GR + 7 A$_isxdigit$64 0005 GR + 7 A$_isxdigit$65 0007 GR + 7 A$_isxdigit$67 0008 GR + 7 A$_isxdigit$68 000B GR + 7 A$_isxdigit$69 000C GR + 7 A$_isxdigit$70 000D GR + 7 A$_isxdigit$74 0010 GR + 7 A$_isxdigit$76 0012 GR + 7 A$_isxdigit$77 0013 GR + 7 A$_isxdigit$78 0015 GR + 7 A$_isxdigit$80 0016 GR + 7 A$_isxdigit$84 0018 GR + 7 A$_isxdigit$85 001B GR + 7 A$_isxdigit$86 001C GR + 7 A$_isxdigit$87 001D GR + 7 A$_isxdigit$91 0020 GR + 7 A$_isxdigit$93 0022 GR + 7 A$_isxdigit$94 0023 GR + 7 A$_isxdigit$95 0025 GR + 7 A$_isxdigit$97 0026 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_isxdigit.c$33$1$1 = 0040 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$isxdigit$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$isxdigit$0$0 = 0040 GR + 7 _isxdigit 0000 GR + 5 _isxdigit_c_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 1 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 41 flags 20 diff --git a/device/lib/_long2fs.c b/device/lib/_long2fs.c new file mode 100644 index 00000000..cd24f219 --- /dev/null +++ b/device/lib/_long2fs.c @@ -0,0 +1,109 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23) & (unsigned int)0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +float +__long2fs (long a1 ) +{ + long sign = 0; + int exp = 24 + EXCESS; + volatile union float_long fl; + + if (!a1) + { + fl.l = 0; + return (fl.f); + } + + if (a1 < 0) + { + sign = SIGNBIT; + a1 = -a1; + } + + while (a1 < HIDDEN) + { + a1 <<= 1; + exp--; + } + + a1 &= ~HIDDEN; + /* pack up and go home */ + fl.l = PACK(sign,(unsigned long)exp, a1); + + return (fl.f); +} diff --git a/device/lib/_long2fs.lst b/device/lib/_long2fs.lst new file mode 100644 index 00000000..14911367 --- /dev/null +++ b/device/lib/_long2fs.lst @@ -0,0 +1,346 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _long2fs + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___long2fs + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___long2fs_sloc0_1_0: + 0000 22 .ds 0x0002 + 0002 23 ___long2fs_sloc1_1_0: + 0002 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___long2fs_a1_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___long2fs_sign_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___long2fs_fl_1_1: + 0008 46 .ds 0x0004 + 47 ;-------------------------------------------------------- + 48 ; global & static initialisations + 49 ;-------------------------------------------------------- + 50 .area GSINIT (CODE) + 51 ;-------------------------------------------------------- + 52 ; code + 53 ;-------------------------------------------------------- + 54 .area CSEG (CODE) + 0000 55 G$__long2fs$0$0 ==. + 56 ; _long2fs.c 80 + 57 ; ----------------------------------------- + 58 ; function __long2fs + 59 ; ----------------------------------------- + 0000 60 ___long2fs: + 0002 61 ar2 = 0x02 + 0003 62 ar3 = 0x03 + 0004 63 ar4 = 0x04 + 0005 64 ar5 = 0x05 + 0006 65 ar6 = 0x06 + 0007 66 ar7 = 0x07 + 0000 67 ar0 = 0x00 + 0001 68 ar1 = 0x01 + 69 ; _long2fs.c 108 + 0000 C0 E0 70 push acc + 0002 C0 F0 71 push b + 0004 C0 83 72 push dph + 0006 C0 82 73 push dpl + 0008 90s00r00 74 mov dptr,#___long2fs_a1_1_1 + 000B D0 E0 75 pop acc + 000D F0 76 movx @dptr,a + 000E D0 E0 77 pop acc + 0010 A3 78 inc dptr + 0011 F0 79 movx @dptr,a + 0012 D0 E0 80 pop acc + 0014 A3 81 inc dptr + 0015 F0 82 movx @dptr,a + 0016 D0 E0 83 pop acc + 0018 A3 84 inc dptr + 0019 F0 85 movx @dptr,a + 86 ; _long2fs.c 82 + 001A 90s00r04 87 mov dptr,#___long2fs_sign_1_1 + 001D E4 88 clr a + 001E A3 89 inc dptr + 001F A3 90 inc dptr + 0020 A3 91 inc dptr + 0021 F0 92 movx @dptr,a + 0022 12s00r00 93 lcall __decdptr + 0025 F0 94 movx @dptr,a + 0026 12s00r00 95 lcall __decdptr + 0029 F0 96 movx @dptr,a + 002A 12s00r00 97 lcall __decdptr + 002D F0 98 movx @dptr,a + 99 ; _long2fs.c 86 + 002E 90s00r00 100 mov dptr,#___long2fs_a1_1_1 + 0031 E0 101 movx a,@dptr + 0032 FA 102 mov r2,a + 0033 A3 103 inc dptr + 0034 E0 104 movx a,@dptr + 0035 FB 105 mov r3,a + 0036 A3 106 inc dptr + 0037 E0 107 movx a,@dptr + 0038 FC 108 mov r4,a + 0039 A3 109 inc dptr + 003A E0 110 movx a,@dptr + 003B FD 111 mov r5,a + 003C EA 112 mov a,r2 + 003D 4B 113 orl a,r3 + 003E 4C 114 orl a,r4 + 003F 4D 115 orl a,r5 + 116 ; Peephole 109 removed ljmp by inverse jump logic + 0040 70 23 117 jnz 00102$ + 0042 118 00114$: + 119 ; _long2fs.c 88 + 0042 90s00r08 120 mov dptr,#(___long2fs_fl_1_1) + 121 ; Peephole 101 removed redundant mov + 122 ; Peephole 180 changed mov to clr + 0045 E4 123 clr a + 0046 F0 124 movx @dptr,a + 0047 A3 125 inc dptr + 0048 F0 126 movx @dptr,a + 0049 A3 127 inc dptr + 128 ; Peephole 101 removed redundant mov + 129 ; Peephole 180 changed mov to clr + 004A E4 130 clr a + 004B F0 131 movx @dptr,a + 004C A3 132 inc dptr + 004D F0 133 movx @dptr,a + 134 ; _long2fs.c 89 + 004E 90s00r08 135 mov dptr,#(___long2fs_fl_1_1) + 0051 E0 136 movx a,@dptr + 0052 FE 137 mov r6,a + 0053 A3 138 inc dptr + 0054 E0 139 movx a,@dptr + 0055 FF 140 mov r7,a + 0056 A3 141 inc dptr + 0057 E0 142 movx a,@dptr + 0058 F8 143 mov r0,a + 0059 A3 144 inc dptr + 005A E0 145 movx a,@dptr + 146 ; Peephole 191 removed redundant mov + 005B F9 147 mov r1,a + 005C 8E 82 148 mov dpl,r6 + 005E 8F 83 149 mov dph,r7 + 0060 88 F0 150 mov b,r0 + 0062 02s01r50 151 ljmp 00108$ + 0065 152 00102$: + 153 ; _long2fs.c 92 + 0065 ED 154 mov a,r5 + 155 ; Peephole 111 removed ljmp by inverse jump logic + 0066 30 E7 21 156 jnb acc.7,00113$ + 0069 157 00115$: + 158 ; _long2fs.c 94 + 0069 90s00r04 159 mov dptr,#___long2fs_sign_1_1 + 160 ; Peephole 101 removed redundant mov + 161 ; Peephole 180 changed mov to clr + 006C E4 162 clr a + 006D F0 163 movx @dptr,a + 006E A3 164 inc dptr + 006F F0 165 movx @dptr,a + 0070 A3 166 inc dptr + 167 ; Peephole 180 changed mov to clr + 0071 E4 168 clr a + 0072 F0 169 movx @dptr,a + 0073 A3 170 inc dptr + 0074 74 80 171 mov a,#0x80 + 0076 F0 172 movx @dptr,a + 173 ; _long2fs.c 95 + 0077 90s00r00 174 mov dptr,#___long2fs_a1_1_1 + 007A C3 175 clr c + 007B E4 176 clr a + 007C 9A 177 subb a,r2 + 007D F0 178 movx @dptr,a + 007E E4 179 clr a + 007F 9B 180 subb a,r3 + 0080 A3 181 inc dptr + 0081 F0 182 movx @dptr,a + 0082 E4 183 clr a + 0083 9C 184 subb a,r4 + 0084 A3 185 inc dptr + 0085 F0 186 movx @dptr,a + 0086 E4 187 clr a + 0087 9D 188 subb a,r5 + 0088 A3 189 inc dptr + 0089 F0 190 movx @dptr,a + 191 ; _long2fs.c 98 + 008A 192 00113$: + 008A E4 193 clr a + 008B F5*01 194 mov (___long2fs_sloc0_1_0 + 1),a + 008D 75*00 96 195 mov ___long2fs_sloc0_1_0,#0x96 + 0090 196 00105$: + 0090 90s00r00 197 mov dptr,#___long2fs_a1_1_1 + 0093 E0 198 movx a,@dptr + 0094 FC 199 mov r4,a + 0095 A3 200 inc dptr + 0096 E0 201 movx a,@dptr + 0097 FD 202 mov r5,a + 0098 A3 203 inc dptr + 0099 E0 204 movx a,@dptr + 009A FE 205 mov r6,a + 009B A3 206 inc dptr + 009C E0 207 movx a,@dptr + 009D FF 208 mov r7,a + 009E C3 209 clr c + 009F EC 210 mov a,r4 + 00A0 94 00 211 subb a,#0x00 + 00A2 ED 212 mov a,r5 + 00A3 94 00 213 subb a,#0x00 + 00A5 EE 214 mov a,r6 + 00A6 94 80 215 subb a,#0x80 + 00A8 EF 216 mov a,r7 + 00A9 94 00 217 subb a,#0x00 + 218 ; Peephole 108 removed ljmp by inverse jump logic + 00AB 50 27 219 jnc 00107$ + 00AD 220 00116$: + 221 ; _long2fs.c 100 + 00AD EC 222 mov a,r4 + 00AE 25 E0 223 add a,acc + 00B0 F8 224 mov r0,a + 00B1 ED 225 mov a,r5 + 00B2 33 226 rlc a + 00B3 F9 227 mov r1,a + 00B4 EE 228 mov a,r6 + 00B5 33 229 rlc a + 00B6 FA 230 mov r2,a + 00B7 EF 231 mov a,r7 + 00B8 33 232 rlc a + 00B9 FB 233 mov r3,a + 00BA 90s00r00 234 mov dptr,#___long2fs_a1_1_1 + 00BD E8 235 mov a,r0 + 00BE F0 236 movx @dptr,a + 00BF A3 237 inc dptr + 00C0 E9 238 mov a,r1 + 00C1 F0 239 movx @dptr,a + 00C2 A3 240 inc dptr + 00C3 EA 241 mov a,r2 + 00C4 F0 242 movx @dptr,a + 00C5 A3 243 inc dptr + 00C6 EB 244 mov a,r3 + 00C7 F0 245 movx @dptr,a + 246 ; _long2fs.c 101 + 00C8 15*00 247 dec ___long2fs_sloc0_1_0 + 00CA 74 FF 248 mov a,#0xff + 00CC B5*00 02 249 cjne a,___long2fs_sloc0_1_0,00117$ + 00CF 15*01 250 dec (___long2fs_sloc0_1_0 + 1) + 00D1 251 00117$: + 00D1 02s00r90 252 ljmp 00105$ + 00D4 253 00107$: + 254 ; _long2fs.c 104 + 00D4 53 06 7F 255 anl ar6,#0x7f + 00D7 90s00r00 256 mov dptr,#___long2fs_a1_1_1 + 00DA EC 257 mov a,r4 + 00DB F0 258 movx @dptr,a + 00DC A3 259 inc dptr + 00DD ED 260 mov a,r5 + 00DE F0 261 movx @dptr,a + 00DF A3 262 inc dptr + 00E0 EE 263 mov a,r6 + 00E1 F0 264 movx @dptr,a + 00E2 A3 265 inc dptr + 00E3 EF 266 mov a,r7 + 00E4 F0 267 movx @dptr,a + 268 ; _long2fs.c 106 + 00E5 AA*00 269 mov r2,___long2fs_sloc0_1_0 + 00E7 AB*01 270 mov r3,(___long2fs_sloc0_1_0 + 1) + 00E9 78 00 271 mov r0,#0x00 + 00EB 79 00 272 mov r1,#0x00 + 00ED 8A*04 273 mov (___long2fs_sloc1_1_0 + 2),r2 + 00EF EB 274 mov a,r3 + 00F0 54 01 275 anl a,#0x01 + 00F2 A2 E0 276 mov c,acc.0 + 00F4 C5*04 277 xch a,(___long2fs_sloc1_1_0 + 2) + 00F6 13 278 rrc a + 00F7 C5*04 279 xch a,(___long2fs_sloc1_1_0 + 2) + 00F9 13 280 rrc a + 00FA C5*04 281 xch a,(___long2fs_sloc1_1_0 + 2) + 00FC F5*05 282 mov (___long2fs_sloc1_1_0 + 3),a + 00FE 75*03 00 283 mov (___long2fs_sloc1_1_0 + 1),#0x00 + 0101 75*02 00 284 mov ___long2fs_sloc1_1_0,#0x00 + 0104 90s00r04 285 mov dptr,#___long2fs_sign_1_1 + 0107 E0 286 movx a,@dptr + 0108 FA 287 mov r2,a + 0109 A3 288 inc dptr + 010A E0 289 movx a,@dptr + 010B FB 290 mov r3,a + 010C A3 291 inc dptr + 010D E0 292 movx a,@dptr + 010E F8 293 mov r0,a + 010F A3 294 inc dptr + 0110 E0 295 movx a,@dptr + 0111 F9 296 mov r1,a + 0112 E5*02 297 mov a,___long2fs_sloc1_1_0 + 0114 42 02 298 orl ar2,a + 0116 E5*03 299 mov a,(___long2fs_sloc1_1_0 + 1) + 0118 42 03 300 orl ar3,a + 011A E5*04 301 mov a,(___long2fs_sloc1_1_0 + 2) + 011C 42 00 302 orl ar0,a + 011E E5*05 303 mov a,(___long2fs_sloc1_1_0 + 3) + 0120 42 01 304 orl ar1,a + 0122 EA 305 mov a,r2 + 0123 42 04 306 orl ar4,a + 0125 EB 307 mov a,r3 + 0126 42 05 308 orl ar5,a + 0128 E8 309 mov a,r0 + 0129 42 06 310 orl ar6,a + 012B E9 311 mov a,r1 + 012C 42 07 312 orl ar7,a + 012E 90s00r08 313 mov dptr,#(___long2fs_fl_1_1) + 0131 EC 314 mov a,r4 + 0132 F0 315 movx @dptr,a + 0133 A3 316 inc dptr + 0134 ED 317 mov a,r5 + 0135 F0 318 movx @dptr,a + 0136 A3 319 inc dptr + 0137 EE 320 mov a,r6 + 0138 F0 321 movx @dptr,a + 0139 A3 322 inc dptr + 013A EF 323 mov a,r7 + 013B F0 324 movx @dptr,a + 325 ; _long2fs.c 108 + 013C 90s00r08 326 mov dptr,#(___long2fs_fl_1_1) + 013F E0 327 movx a,@dptr + 0140 FA 328 mov r2,a + 0141 A3 329 inc dptr + 0142 E0 330 movx a,@dptr + 0143 FB 331 mov r3,a + 0144 A3 332 inc dptr + 0145 E0 333 movx a,@dptr + 0146 FC 334 mov r4,a + 0147 A3 335 inc dptr + 0148 E0 336 movx a,@dptr + 337 ; Peephole 191 removed redundant mov + 0149 FD 338 mov r5,a + 014A 8A 82 339 mov dpl,r2 + 014C 8B 83 340 mov dph,r3 + 014E 8C F0 341 mov b,r4 + 0150 342 00108$: + 0150 343 C$_long2fs.c$109$1$1 ==. + 0150 344 XG$__long2fs$0$0 ==. + 0150 22 345 ret + 346 .area CSEG (CODE) diff --git a/device/lib/_long2fs.sym b/device/lib/_long2fs.sym new file mode 100644 index 00000000..6ceb5aa0 --- /dev/null +++ b/device/lib/_long2fs.sym @@ -0,0 +1,611 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_long2fs$100 002E GR + 7 A$_long2fs$101 0031 GR + 7 A$_long2fs$102 0032 GR + 7 A$_long2fs$103 0033 GR + 7 A$_long2fs$104 0034 GR + 7 A$_long2fs$105 0035 GR + 7 A$_long2fs$106 0036 GR + 7 A$_long2fs$107 0037 GR + 7 A$_long2fs$108 0038 GR + 7 A$_long2fs$109 0039 GR + 7 A$_long2fs$110 003A GR + 7 A$_long2fs$111 003B GR + 7 A$_long2fs$112 003C GR + 7 A$_long2fs$113 003D GR + 7 A$_long2fs$114 003E GR + 7 A$_long2fs$115 003F GR + 7 A$_long2fs$117 0040 GR + 7 A$_long2fs$120 0042 GR + 7 A$_long2fs$123 0045 GR + 7 A$_long2fs$124 0046 GR + 7 A$_long2fs$125 0047 GR + 7 A$_long2fs$126 0048 GR + 7 A$_long2fs$127 0049 GR + 7 A$_long2fs$130 004A GR + 7 A$_long2fs$131 004B GR + 7 A$_long2fs$132 004C GR + 7 A$_long2fs$133 004D GR + 7 A$_long2fs$135 004E GR + 7 A$_long2fs$136 0051 GR + 7 A$_long2fs$137 0052 GR + 7 A$_long2fs$138 0053 GR + 7 A$_long2fs$139 0054 GR + 7 A$_long2fs$140 0055 GR + 7 A$_long2fs$141 0056 GR + 7 A$_long2fs$142 0057 GR + 7 A$_long2fs$143 0058 GR + 7 A$_long2fs$144 0059 GR + 7 A$_long2fs$145 005A GR + 7 A$_long2fs$147 005B GR + 7 A$_long2fs$148 005C GR + 7 A$_long2fs$149 005E GR + 7 A$_long2fs$150 0060 GR + 7 A$_long2fs$151 0062 GR + 7 A$_long2fs$154 0065 GR + 7 A$_long2fs$156 0066 GR + 7 A$_long2fs$159 0069 GR + 7 A$_long2fs$162 006C GR + 7 A$_long2fs$163 006D GR + 7 A$_long2fs$164 006E GR + 7 A$_long2fs$165 006F GR + 7 A$_long2fs$166 0070 GR + 7 A$_long2fs$168 0071 GR + 7 A$_long2fs$169 0072 GR + 7 A$_long2fs$170 0073 GR + 7 A$_long2fs$171 0074 GR + 7 A$_long2fs$172 0076 GR + 7 A$_long2fs$174 0077 GR + 7 A$_long2fs$175 007A GR + 7 A$_long2fs$176 007B GR + 7 A$_long2fs$177 007C GR + 7 A$_long2fs$178 007D GR + 7 A$_long2fs$179 007E GR + 7 A$_long2fs$180 007F GR + 7 A$_long2fs$181 0080 GR + 7 A$_long2fs$182 0081 GR + 7 A$_long2fs$183 0082 GR + 7 A$_long2fs$184 0083 GR + 7 A$_long2fs$185 0084 GR + 7 A$_long2fs$186 0085 GR + 7 A$_long2fs$187 0086 GR + 7 A$_long2fs$188 0087 GR + 7 A$_long2fs$189 0088 GR + 7 A$_long2fs$190 0089 GR + 7 A$_long2fs$193 008A GR + 7 A$_long2fs$194 008B GR + 7 A$_long2fs$195 008D GR + 7 A$_long2fs$197 0090 GR + 7 A$_long2fs$198 0093 GR + 7 A$_long2fs$199 0094 GR + 7 A$_long2fs$200 0095 GR + 7 A$_long2fs$201 0096 GR + 7 A$_long2fs$202 0097 GR + 7 A$_long2fs$203 0098 GR + 7 A$_long2fs$204 0099 GR + 7 A$_long2fs$205 009A GR + 7 A$_long2fs$206 009B GR + 7 A$_long2fs$207 009C GR + 7 A$_long2fs$208 009D GR + 7 A$_long2fs$209 009E GR + 7 A$_long2fs$210 009F GR + 7 A$_long2fs$211 00A0 GR + 7 A$_long2fs$212 00A2 GR + 7 A$_long2fs$213 00A3 GR + 7 A$_long2fs$214 00A5 GR + 7 A$_long2fs$215 00A6 GR + 7 A$_long2fs$216 00A8 GR + 7 A$_long2fs$217 00A9 GR + 7 A$_long2fs$219 00AB GR + 7 A$_long2fs$222 00AD GR + 7 A$_long2fs$223 00AE GR + 7 A$_long2fs$224 00B0 GR + 7 A$_long2fs$225 00B1 GR + 7 A$_long2fs$226 00B2 GR + 7 A$_long2fs$227 00B3 GR + 7 A$_long2fs$228 00B4 GR + 7 A$_long2fs$229 00B5 GR + 7 A$_long2fs$230 00B6 GR + 7 A$_long2fs$231 00B7 GR + 7 A$_long2fs$232 00B8 GR + 7 A$_long2fs$233 00B9 GR + 7 A$_long2fs$234 00BA GR + 7 A$_long2fs$235 00BD GR + 7 A$_long2fs$236 00BE GR + 7 A$_long2fs$237 00BF GR + 7 A$_long2fs$238 00C0 GR + 7 A$_long2fs$239 00C1 GR + 7 A$_long2fs$240 00C2 GR + 7 A$_long2fs$241 00C3 GR + 7 A$_long2fs$242 00C4 GR + 7 A$_long2fs$243 00C5 GR + 7 A$_long2fs$244 00C6 GR + 7 A$_long2fs$245 00C7 GR + 7 A$_long2fs$247 00C8 GR + 7 A$_long2fs$248 00CA GR + 7 A$_long2fs$249 00CC GR + 7 A$_long2fs$250 00CF GR + 7 A$_long2fs$252 00D1 GR + 7 A$_long2fs$255 00D4 GR + 7 A$_long2fs$256 00D7 GR + 7 A$_long2fs$257 00DA GR + 7 A$_long2fs$258 00DB GR + 7 A$_long2fs$259 00DC GR + 7 A$_long2fs$260 00DD GR + 7 A$_long2fs$261 00DE GR + 7 A$_long2fs$262 00DF GR + 7 A$_long2fs$263 00E0 GR + 7 A$_long2fs$264 00E1 GR + 7 A$_long2fs$265 00E2 GR + 7 A$_long2fs$266 00E3 GR + 7 A$_long2fs$267 00E4 GR + 7 A$_long2fs$269 00E5 GR + 7 A$_long2fs$270 00E7 GR + 7 A$_long2fs$271 00E9 GR + 7 A$_long2fs$272 00EB GR + 7 A$_long2fs$273 00ED GR + 7 A$_long2fs$274 00EF GR + 7 A$_long2fs$275 00F0 GR + 7 A$_long2fs$276 00F2 GR + 7 A$_long2fs$277 00F4 GR + 7 A$_long2fs$278 00F6 GR + 7 A$_long2fs$279 00F7 GR + 7 A$_long2fs$280 00F9 GR + 7 A$_long2fs$281 00FA GR + 7 A$_long2fs$282 00FC GR + 7 A$_long2fs$283 00FE GR + 7 A$_long2fs$284 0101 GR + 7 A$_long2fs$285 0104 GR + 7 A$_long2fs$286 0107 GR + 7 A$_long2fs$287 0108 GR + 7 A$_long2fs$288 0109 GR + 7 A$_long2fs$289 010A GR + 7 A$_long2fs$290 010B GR + 7 A$_long2fs$291 010C GR + 7 A$_long2fs$292 010D GR + 7 A$_long2fs$293 010E GR + 7 A$_long2fs$294 010F GR + 7 A$_long2fs$295 0110 GR + 7 A$_long2fs$296 0111 GR + 7 A$_long2fs$297 0112 GR + 7 A$_long2fs$298 0114 GR + 7 A$_long2fs$299 0116 GR + 7 A$_long2fs$300 0118 GR + 7 A$_long2fs$301 011A GR + 7 A$_long2fs$302 011C GR + 7 A$_long2fs$303 011E GR + 7 A$_long2fs$304 0120 GR + 7 A$_long2fs$305 0122 GR + 7 A$_long2fs$306 0123 GR + 7 A$_long2fs$307 0125 GR + 7 A$_long2fs$308 0126 GR + 7 A$_long2fs$309 0128 GR + 7 A$_long2fs$310 0129 GR + 7 A$_long2fs$311 012B GR + 7 A$_long2fs$312 012C GR + 7 A$_long2fs$313 012E GR + 7 A$_long2fs$314 0131 GR + 7 A$_long2fs$315 0132 GR + 7 A$_long2fs$316 0133 GR + 7 A$_long2fs$317 0134 GR + 7 A$_long2fs$318 0135 GR + 7 A$_long2fs$319 0136 GR + 7 A$_long2fs$320 0137 GR + 7 A$_long2fs$321 0138 GR + 7 A$_long2fs$322 0139 GR + 7 A$_long2fs$323 013A GR + 7 A$_long2fs$324 013B GR + 7 A$_long2fs$326 013C GR + 7 A$_long2fs$327 013F GR + 7 A$_long2fs$328 0140 GR + 7 A$_long2fs$329 0141 GR + 7 A$_long2fs$330 0142 GR + 7 A$_long2fs$331 0143 GR + 7 A$_long2fs$332 0144 GR + 7 A$_long2fs$333 0145 GR + 7 A$_long2fs$334 0146 GR + 7 A$_long2fs$335 0147 GR + 7 A$_long2fs$336 0148 GR + 7 A$_long2fs$338 0149 GR + 7 A$_long2fs$339 014A GR + 7 A$_long2fs$340 014C GR + 7 A$_long2fs$341 014E GR + 7 A$_long2fs$345 0150 GR + 7 A$_long2fs$70 0000 GR + 7 A$_long2fs$71 0002 GR + 7 A$_long2fs$72 0004 GR + 7 A$_long2fs$73 0006 GR + 7 A$_long2fs$74 0008 GR + 7 A$_long2fs$75 000B GR + 7 A$_long2fs$76 000D GR + 7 A$_long2fs$77 000E GR + 7 A$_long2fs$78 0010 GR + 7 A$_long2fs$79 0011 GR + 7 A$_long2fs$80 0012 GR + 7 A$_long2fs$81 0014 GR + 7 A$_long2fs$82 0015 GR + 7 A$_long2fs$83 0016 GR + 7 A$_long2fs$84 0018 GR + 7 A$_long2fs$85 0019 GR + 7 A$_long2fs$87 001A GR + 7 A$_long2fs$88 001D GR + 7 A$_long2fs$89 001E GR + 7 A$_long2fs$90 001F GR + 7 A$_long2fs$91 0020 GR + 7 A$_long2fs$92 0021 GR + 7 A$_long2fs$93 0022 GR + 7 A$_long2fs$94 0025 GR + 7 A$_long2fs$95 0026 GR + 7 A$_long2fs$96 0029 GR + 7 A$_long2fs$97 002A GR + 7 A$_long2fs$98 002D GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_long2fs.c$109$1$1 = 0150 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__long2fs$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__long2fs$0$0 = 0150 GR + 7 ___long2fs 0000 GR + 5 ___long2fs_a1_1_1 0000 R + 5 ___long2fs_fl_1_1 0008 R + 5 ___long2fs_sign_1_1 0004 R + 1 ___long2fs_sloc0_1_0 0000 R + 1 ___long2fs_sloc1_1_0 0002 R + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size C flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 151 flags 20 diff --git a/device/lib/_memcmp.c b/device/lib/_memcmp.c new file mode 100644 index 00000000..9131f137 --- /dev/null +++ b/device/lib/_memcmp.c @@ -0,0 +1,42 @@ +/*------------------------------------------------------------------------- + _memcmp.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +int memcmp ( + void _generic * buf1, + void _generic * buf2, + int count + ) +{ + if (!count) + return(0); + + while ( --count && *((char _generic *)buf1) == *((char _generic *)buf2) ) { + buf1 = (char _generic *)buf1 + 1; + buf2 = (char _generic *)buf2 + 1; + } + + return( *((unsigned char _generic *)buf1) - *((unsigned char _generic *)buf2) ); +} diff --git a/device/lib/_memcmp.lst b/device/lib/_memcmp.lst new file mode 100644 index 00000000..44c0c045 --- /dev/null +++ b/device/lib/_memcmp.lst @@ -0,0 +1,208 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _memcmp + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _memcmp_PARM_3 + 11 .globl _memcmp_PARM_2 + 12 .globl _memcmp + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 16 ;-------------------------------------------------------- + 17 ; special function bits + 18 ;-------------------------------------------------------- + 19 ;-------------------------------------------------------- + 20 ; internal ram data + 21 ;-------------------------------------------------------- + 22 .area DSEG (DATA) + 23 ;-------------------------------------------------------- + 24 ; overlayable items in internal ram + 25 ;-------------------------------------------------------- + 26 .area OSEG (OVR,DATA) + 27 ;-------------------------------------------------------- + 28 ; indirectly addressable internal ram data + 29 ;-------------------------------------------------------- + 30 .area ISEG (DATA) + 31 ;-------------------------------------------------------- + 32 ; bit data + 33 ;-------------------------------------------------------- + 34 .area BSEG (BIT) + 35 ;-------------------------------------------------------- + 36 ; external ram data + 37 ;-------------------------------------------------------- + 38 .area XSEG (XDATA) + 0000 39 _memcmp_PARM_2: + 0000 40 .ds 0x0003 + 0003 41 _memcmp_PARM_3: + 0003 42 .ds 0x0002 + 0005 43 _memcmp_buf1_1_1: + 0005 44 .ds 0x0003 + 45 ;-------------------------------------------------------- + 46 ; global & static initialisations + 47 ;-------------------------------------------------------- + 48 .area GSINIT (CODE) + 49 ;-------------------------------------------------------- + 50 ; code + 51 ;-------------------------------------------------------- + 52 .area CSEG (CODE) + 0000 53 G$memcmp$0$0 ==. + 54 ; _memcmp.c 27 + 55 ; ----------------------------------------- + 56 ; function memcmp + 57 ; ----------------------------------------- + 0000 58 _memcmp: + 0002 59 ar2 = 0x02 + 0003 60 ar3 = 0x03 + 0004 61 ar4 = 0x04 + 0005 62 ar5 = 0x05 + 0006 63 ar6 = 0x06 + 0007 64 ar7 = 0x07 + 0000 65 ar0 = 0x00 + 0001 66 ar1 = 0x01 + 67 ; _memcmp.c 0 + 0000 C0 F0 68 push b + 0002 C0 83 69 push dph + 0004 C0 82 70 push dpl + 0006 90s00r05 71 mov dptr,#_memcmp_buf1_1_1 + 0009 D0 E0 72 pop acc + 000B F0 73 movx @dptr,a + 000C D0 E0 74 pop acc + 000E A3 75 inc dptr + 000F F0 76 movx @dptr,a + 0010 D0 E0 77 pop acc + 0012 A3 78 inc dptr + 0013 F0 79 movx @dptr,a + 80 ; _memcmp.c 33 + 0014 90s00r03 81 mov dptr,#_memcmp_PARM_3 + 0017 E0 82 movx a,@dptr + 0018 FA 83 mov r2,a + 0019 A3 84 inc dptr + 001A E0 85 movx a,@dptr + 86 ; Peephole 135 removed redundant mov + 001B FB 87 mov r3,a + 001C 4A 88 orl a,r2 + 89 ; Peephole 109 removed ljmp by inverse jump logic + 001D 70 06 90 jnz 00112$ + 001F 91 00113$: + 92 ; _memcmp.c 34 + 93 ; Peephole 181 used 16 bit load of dptr + 001F 90 00 00 94 mov dptr,#0x0000 + 0022 02s00rAC 95 ljmp 00107$ + 96 ; _memcmp.c 36 + 0025 97 00112$: + 0025 90s00r05 98 mov dptr,#_memcmp_buf1_1_1 + 0028 E0 99 movx a,@dptr + 0029 FA 100 mov r2,a + 002A A3 101 inc dptr + 002B E0 102 movx a,@dptr + 002C FB 103 mov r3,a + 002D A3 104 inc dptr + 002E E0 105 movx a,@dptr + 002F FC 106 mov r4,a + 0030 90s00r00 107 mov dptr,#_memcmp_PARM_2 + 0033 E0 108 movx a,@dptr + 0034 FD 109 mov r5,a + 0035 A3 110 inc dptr + 0036 E0 111 movx a,@dptr + 0037 FE 112 mov r6,a + 0038 A3 113 inc dptr + 0039 E0 114 movx a,@dptr + 003A FF 115 mov r7,a + 003B 116 00104$: + 003B 90s00r03 117 mov dptr,#_memcmp_PARM_3 + 003E E0 118 movx a,@dptr + 003F 24 FF 119 add a,#0xff + 0041 F8 120 mov r0,a + 0042 A3 121 inc dptr + 0043 E0 122 movx a,@dptr + 0044 34 FF 123 addc a,#0xff + 0046 F9 124 mov r1,a + 0047 90s00r03 125 mov dptr,#_memcmp_PARM_3 + 004A E8 126 mov a,r0 + 004B F0 127 movx @dptr,a + 004C A3 128 inc dptr + 004D E9 129 mov a,r1 + 004E F0 130 movx @dptr,a + 004F E8 131 mov a,r0 + 0050 49 132 orl a,r1 + 133 ; Peephole 110 removed ljmp by inverse jump logic + 0051 60 2F 134 jz 00106$ + 0053 135 00114$: + 0053 8D 82 136 mov dpl,r5 + 0055 8E 83 137 mov dph,r6 + 0057 8F F0 138 mov b,r7 + 0059 12s00r00 139 lcall __gptrget + 005C F8 140 mov r0,a + 005D 8A 82 141 mov dpl,r2 + 005F 8B 83 142 mov dph,r3 + 0061 8C F0 143 mov b,r4 + 0063 12s00r00 144 lcall __gptrget + 145 ; Peephole 105 removed redundant mov + 0066 F9 146 mov r1,a + 147 ; Peephole 132 changed ljmp to sjmp + 148 ; Peephole 199 optimized misc jump sequence + 0067 B5 00 18 149 cjne a,ar0,00106$ + 150 ; Peephole 201 removed redundant sjmp + 006A 151 00115$: + 006A 152 00116$: + 153 ; _memcmp.c 37 + 006A 0A 154 inc r2 + 006B BA 00 01 155 cjne r2,#0x00,00117$ + 006E 0B 156 inc r3 + 006F 157 00117$: + 006F 90s00r05 158 mov dptr,#_memcmp_buf1_1_1 + 0072 EA 159 mov a,r2 + 0073 F0 160 movx @dptr,a + 0074 A3 161 inc dptr + 0075 EB 162 mov a,r3 + 0076 F0 163 movx @dptr,a + 0077 A3 164 inc dptr + 0078 EC 165 mov a,r4 + 0079 F0 166 movx @dptr,a + 167 ; _memcmp.c 38 + 007A 0D 168 inc r5 + 007B BD 00 01 169 cjne r5,#0x00,00118$ + 007E 0E 170 inc r6 + 007F 171 00118$: + 007F 02s00r3B 172 ljmp 00104$ + 0082 173 00106$: + 174 ; _memcmp.c 41 + 0082 90s00r05 175 mov dptr,#_memcmp_buf1_1_1 + 0085 EA 176 mov a,r2 + 0086 F0 177 movx @dptr,a + 0087 A3 178 inc dptr + 0088 EB 179 mov a,r3 + 0089 F0 180 movx @dptr,a + 008A A3 181 inc dptr + 008B EC 182 mov a,r4 + 008C F0 183 movx @dptr,a + 008D 8D 82 184 mov dpl,r5 + 008F 8E 83 185 mov dph,r6 + 0091 8F F0 186 mov b,r7 + 0093 12s00r00 187 lcall __gptrget + 0096 FD 188 mov r5,a + 0097 8A 82 189 mov dpl,r2 + 0099 8B 83 190 mov dph,r3 + 009B 8C F0 191 mov b,r4 + 009D 12s00r00 192 lcall __gptrget + 193 ; Peephole 106 removed redundant mov + 00A0 FA 194 mov r2,a + 00A1 C3 195 clr c + 00A2 9D 196 subb a,r5 + 00A3 FA 197 mov r2,a + 198 ; Peephole 180 changed mov to clr + 00A4 E4 199 clr a + 00A5 94 00 200 subb a,#0x00 + 00A7 FD 201 mov r5,a + 00A8 8A 82 202 mov dpl,r2 + 00AA 8D 83 203 mov dph,r5 + 00AC 204 00107$: + 00AC 205 C$_memcmp.c$42$1$1 ==. + 00AC 206 XG$memcmp$0$0 ==. + 00AC 22 207 ret + 208 .area CSEG (CODE) diff --git a/device/lib/_memcmp.sym b/device/lib/_memcmp.sym new file mode 100644 index 00000000..de3dd2fe --- /dev/null +++ b/device/lib/_memcmp.sym @@ -0,0 +1,481 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_memcmp$100 0029 GR + 7 A$_memcmp$101 002A GR + 7 A$_memcmp$102 002B GR + 7 A$_memcmp$103 002C GR + 7 A$_memcmp$104 002D GR + 7 A$_memcmp$105 002E GR + 7 A$_memcmp$106 002F GR + 7 A$_memcmp$107 0030 GR + 7 A$_memcmp$108 0033 GR + 7 A$_memcmp$109 0034 GR + 7 A$_memcmp$110 0035 GR + 7 A$_memcmp$111 0036 GR + 7 A$_memcmp$112 0037 GR + 7 A$_memcmp$113 0038 GR + 7 A$_memcmp$114 0039 GR + 7 A$_memcmp$115 003A GR + 7 A$_memcmp$117 003B GR + 7 A$_memcmp$118 003E GR + 7 A$_memcmp$119 003F GR + 7 A$_memcmp$120 0041 GR + 7 A$_memcmp$121 0042 GR + 7 A$_memcmp$122 0043 GR + 7 A$_memcmp$123 0044 GR + 7 A$_memcmp$124 0046 GR + 7 A$_memcmp$125 0047 GR + 7 A$_memcmp$126 004A GR + 7 A$_memcmp$127 004B GR + 7 A$_memcmp$128 004C GR + 7 A$_memcmp$129 004D GR + 7 A$_memcmp$130 004E GR + 7 A$_memcmp$131 004F GR + 7 A$_memcmp$132 0050 GR + 7 A$_memcmp$134 0051 GR + 7 A$_memcmp$136 0053 GR + 7 A$_memcmp$137 0055 GR + 7 A$_memcmp$138 0057 GR + 7 A$_memcmp$139 0059 GR + 7 A$_memcmp$140 005C GR + 7 A$_memcmp$141 005D GR + 7 A$_memcmp$142 005F GR + 7 A$_memcmp$143 0061 GR + 7 A$_memcmp$144 0063 GR + 7 A$_memcmp$146 0066 GR + 7 A$_memcmp$149 0067 GR + 7 A$_memcmp$154 006A GR + 7 A$_memcmp$155 006B GR + 7 A$_memcmp$156 006E GR + 7 A$_memcmp$158 006F GR + 7 A$_memcmp$159 0072 GR + 7 A$_memcmp$160 0073 GR + 7 A$_memcmp$161 0074 GR + 7 A$_memcmp$162 0075 GR + 7 A$_memcmp$163 0076 GR + 7 A$_memcmp$164 0077 GR + 7 A$_memcmp$165 0078 GR + 7 A$_memcmp$166 0079 GR + 7 A$_memcmp$168 007A GR + 7 A$_memcmp$169 007B GR + 7 A$_memcmp$170 007E GR + 7 A$_memcmp$172 007F GR + 7 A$_memcmp$175 0082 GR + 7 A$_memcmp$176 0085 GR + 7 A$_memcmp$177 0086 GR + 7 A$_memcmp$178 0087 GR + 7 A$_memcmp$179 0088 GR + 7 A$_memcmp$180 0089 GR + 7 A$_memcmp$181 008A GR + 7 A$_memcmp$182 008B GR + 7 A$_memcmp$183 008C GR + 7 A$_memcmp$184 008D GR + 7 A$_memcmp$185 008F GR + 7 A$_memcmp$186 0091 GR + 7 A$_memcmp$187 0093 GR + 7 A$_memcmp$188 0096 GR + 7 A$_memcmp$189 0097 GR + 7 A$_memcmp$190 0099 GR + 7 A$_memcmp$191 009B GR + 7 A$_memcmp$192 009D GR + 7 A$_memcmp$194 00A0 GR + 7 A$_memcmp$195 00A1 GR + 7 A$_memcmp$196 00A2 GR + 7 A$_memcmp$197 00A3 GR + 7 A$_memcmp$199 00A4 GR + 7 A$_memcmp$200 00A5 GR + 7 A$_memcmp$201 00A7 GR + 7 A$_memcmp$202 00A8 GR + 7 A$_memcmp$203 00AA GR + 7 A$_memcmp$207 00AC GR + 7 A$_memcmp$68 0000 GR + 7 A$_memcmp$69 0002 GR + 7 A$_memcmp$70 0004 GR + 7 A$_memcmp$71 0006 GR + 7 A$_memcmp$72 0009 GR + 7 A$_memcmp$73 000B GR + 7 A$_memcmp$74 000C GR + 7 A$_memcmp$75 000E GR + 7 A$_memcmp$76 000F GR + 7 A$_memcmp$77 0010 GR + 7 A$_memcmp$78 0012 GR + 7 A$_memcmp$79 0013 GR + 7 A$_memcmp$81 0014 GR + 7 A$_memcmp$82 0017 GR + 7 A$_memcmp$83 0018 GR + 7 A$_memcmp$84 0019 GR + 7 A$_memcmp$85 001A GR + 7 A$_memcmp$87 001B GR + 7 A$_memcmp$88 001C GR + 7 A$_memcmp$90 001D GR + 7 A$_memcmp$94 001F GR + 7 A$_memcmp$95 0022 GR + 7 A$_memcmp$98 0025 GR + 7 A$_memcmp$99 0028 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_memcmp.c$42$1$1 = 00AC GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$memcmp$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$memcmp$0$0 = 00AC GR + __gptrget **** GX + 7 _memcmp 0000 GR + 5 _memcmp_PARM_2 0000 GR + 5 _memcmp_PARM_3 0003 GR + 5 _memcmp_buf1_1_1 0005 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size AD flags 20 diff --git a/device/lib/_memcpy.c b/device/lib/_memcpy.c new file mode 100644 index 00000000..e1d07700 --- /dev/null +++ b/device/lib/_memcpy.c @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------- + _memcpy.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +void _generic * memcpy ( + void _generic * dst, + void _generic * src, + int count + ) +{ + void _generic * ret = dst; + char _generic * d = dst; + char _generic * s = src; + + /* + * copy from lower addresses to higher addresses + */ + while (count--) { + *d++ = *s++; + } + + return(ret); +} diff --git a/device/lib/_memcpy.lst b/device/lib/_memcpy.lst new file mode 100644 index 00000000..1b79be5f --- /dev/null +++ b/device/lib/_memcpy.lst @@ -0,0 +1,164 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _memcpy + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _memcpy_PARM_3 + 11 .globl _memcpy_PARM_2 + 12 .globl _memcpy + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 16 ;-------------------------------------------------------- + 17 ; special function bits + 18 ;-------------------------------------------------------- + 19 ;-------------------------------------------------------- + 20 ; internal ram data + 21 ;-------------------------------------------------------- + 22 .area DSEG (DATA) + 0000 23 _memcpy_sloc0_1_0: + 0000 24 .ds 0x0003 + 0003 25 _memcpy_sloc1_1_0: + 0003 26 .ds 0x0003 + 27 ;-------------------------------------------------------- + 28 ; overlayable items in internal ram + 29 ;-------------------------------------------------------- + 30 .area OSEG (OVR,DATA) + 31 ;-------------------------------------------------------- + 32 ; indirectly addressable internal ram data + 33 ;-------------------------------------------------------- + 34 .area ISEG (DATA) + 35 ;-------------------------------------------------------- + 36 ; bit data + 37 ;-------------------------------------------------------- + 38 .area BSEG (BIT) + 39 ;-------------------------------------------------------- + 40 ; external ram data + 41 ;-------------------------------------------------------- + 42 .area XSEG (XDATA) + 0000 43 _memcpy_PARM_2: + 0000 44 .ds 0x0003 + 0003 45 _memcpy_PARM_3: + 0003 46 .ds 0x0002 + 0005 47 _memcpy_dst_1_1: + 0005 48 .ds 0x0003 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$memcpy$0$0 ==. + 58 ; _memcpy.c 27 + 59 ; ----------------------------------------- + 60 ; function memcpy + 61 ; ----------------------------------------- + 0000 62 _memcpy: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _memcpy.c 44 + 0000 C0 F0 72 push b + 0002 C0 83 73 push dph + 0004 C0 82 74 push dpl + 0006 90s00r05 75 mov dptr,#_memcpy_dst_1_1 + 0009 D0 E0 76 pop acc + 000B F0 77 movx @dptr,a + 000C D0 E0 78 pop acc + 000E A3 79 inc dptr + 000F F0 80 movx @dptr,a + 0010 D0 E0 81 pop acc + 0012 A3 82 inc dptr + 0013 F0 83 movx @dptr,a + 84 ; _memcpy.c 33 + 0014 90s00r05 85 mov dptr,#_memcpy_dst_1_1 + 0017 E0 86 movx a,@dptr + 0018 F5*03 87 mov _memcpy_sloc1_1_0,a + 001A A3 88 inc dptr + 001B E0 89 movx a,@dptr + 001C F5*04 90 mov (_memcpy_sloc1_1_0 + 1),a + 001E A3 91 inc dptr + 001F E0 92 movx a,@dptr + 0020 F5*05 93 mov (_memcpy_sloc1_1_0 + 2),a + 94 ; _memcpy.c 35 + 0022 90s00r00 95 mov dptr,#_memcpy_PARM_2 + 0025 E0 96 movx a,@dptr + 0026 F5*00 97 mov _memcpy_sloc0_1_0,a + 0028 A3 98 inc dptr + 0029 E0 99 movx a,@dptr + 002A F5*01 100 mov (_memcpy_sloc0_1_0 + 1),a + 002C A3 101 inc dptr + 002D E0 102 movx a,@dptr + 002E F5*02 103 mov (_memcpy_sloc0_1_0 + 2),a + 104 ; _memcpy.c 40 + 0030 A8*03 105 mov r0,_memcpy_sloc1_1_0 + 0032 A9*04 106 mov r1,(_memcpy_sloc1_1_0 + 1) + 0034 AD*05 107 mov r5,(_memcpy_sloc1_1_0 + 2) + 0036 90s00r03 108 mov dptr,#_memcpy_PARM_3 + 0039 E0 109 movx a,@dptr + 003A FB 110 mov r3,a + 003B A3 111 inc dptr + 003C E0 112 movx a,@dptr + 003D FC 113 mov r4,a + 003E 114 00101$: + 003E 8B 02 115 mov ar2,r3 + 0040 8C 06 116 mov ar6,r4 + 0042 1B 117 dec r3 + 0043 BB FF 01 118 cjne r3,#0xff,00108$ + 0046 1C 119 dec r4 + 0047 120 00108$: + 0047 EA 121 mov a,r2 + 0048 4E 122 orl a,r6 + 123 ; Peephole 110 removed ljmp by inverse jump logic + 0049 60 33 124 jz 00103$ + 004B 125 00109$: + 126 ; _memcpy.c 41 + 004B C0 03 127 push ar3 + 004D C0 04 128 push ar4 + 004F 88 02 129 mov ar2,r0 + 0051 89 06 130 mov ar6,r1 + 0053 8D 07 131 mov ar7,r5 + 0055 08 132 inc r0 + 0056 B8 00 01 133 cjne r0,#0x00,00110$ + 0059 09 134 inc r1 + 005A 135 00110$: + 005A 85*00 82 136 mov dpl,_memcpy_sloc0_1_0 + 005D 85*01 83 137 mov dph,(_memcpy_sloc0_1_0 + 1) + 0060 85*02 F0 138 mov b,(_memcpy_sloc0_1_0 + 2) + 0063 05*00 139 inc _memcpy_sloc0_1_0 + 0065 E4 140 clr a + 0066 B5*00 02 141 cjne a,_memcpy_sloc0_1_0,00111$ + 0069 05*01 142 inc (_memcpy_sloc0_1_0 + 1) + 006B 143 00111$: + 006B 12s00r00 144 lcall __gptrget + 145 ; Peephole 191 removed redundant mov + 006E FB 146 mov r3,a + 006F 8A 82 147 mov dpl,r2 + 0071 8E 83 148 mov dph,r6 + 0073 8F F0 149 mov b,r7 + 0075 12s00r00 150 lcall __gptrput + 0078 D0 04 151 pop ar4 + 007A D0 03 152 pop ar3 + 153 ; Peephole 132 changed ljmp to sjmp + 007C 80 C0 154 sjmp 00101$ + 007E 155 00103$: + 156 ; _memcpy.c 44 + 007E 85*03 82 157 mov dpl,_memcpy_sloc1_1_0 + 0081 85*04 83 158 mov dph,(_memcpy_sloc1_1_0 + 1) + 0084 85*05 F0 159 mov b,(_memcpy_sloc1_1_0 + 2) + 0087 160 00104$: + 0087 161 C$_memcpy.c$45$1$1 ==. + 0087 162 XG$memcpy$0$0 ==. + 0087 22 163 ret + 164 .area CSEG (CODE) diff --git a/device/lib/_memcpy.sym b/device/lib/_memcpy.sym new file mode 100644 index 00000000..f238a74e --- /dev/null +++ b/device/lib/_memcpy.sym @@ -0,0 +1,447 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_memcpy$100 002A GR + 7 A$_memcpy$101 002C GR + 7 A$_memcpy$102 002D GR + 7 A$_memcpy$103 002E GR + 7 A$_memcpy$105 0030 GR + 7 A$_memcpy$106 0032 GR + 7 A$_memcpy$107 0034 GR + 7 A$_memcpy$108 0036 GR + 7 A$_memcpy$109 0039 GR + 7 A$_memcpy$110 003A GR + 7 A$_memcpy$111 003B GR + 7 A$_memcpy$112 003C GR + 7 A$_memcpy$113 003D GR + 7 A$_memcpy$115 003E GR + 7 A$_memcpy$116 0040 GR + 7 A$_memcpy$117 0042 GR + 7 A$_memcpy$118 0043 GR + 7 A$_memcpy$119 0046 GR + 7 A$_memcpy$121 0047 GR + 7 A$_memcpy$122 0048 GR + 7 A$_memcpy$124 0049 GR + 7 A$_memcpy$127 004B GR + 7 A$_memcpy$128 004D GR + 7 A$_memcpy$129 004F GR + 7 A$_memcpy$130 0051 GR + 7 A$_memcpy$131 0053 GR + 7 A$_memcpy$132 0055 GR + 7 A$_memcpy$133 0056 GR + 7 A$_memcpy$134 0059 GR + 7 A$_memcpy$136 005A GR + 7 A$_memcpy$137 005D GR + 7 A$_memcpy$138 0060 GR + 7 A$_memcpy$139 0063 GR + 7 A$_memcpy$140 0065 GR + 7 A$_memcpy$141 0066 GR + 7 A$_memcpy$142 0069 GR + 7 A$_memcpy$144 006B GR + 7 A$_memcpy$146 006E GR + 7 A$_memcpy$147 006F GR + 7 A$_memcpy$148 0071 GR + 7 A$_memcpy$149 0073 GR + 7 A$_memcpy$150 0075 GR + 7 A$_memcpy$151 0078 GR + 7 A$_memcpy$152 007A GR + 7 A$_memcpy$154 007C GR + 7 A$_memcpy$157 007E GR + 7 A$_memcpy$158 0081 GR + 7 A$_memcpy$159 0084 GR + 7 A$_memcpy$163 0087 GR + 7 A$_memcpy$72 0000 GR + 7 A$_memcpy$73 0002 GR + 7 A$_memcpy$74 0004 GR + 7 A$_memcpy$75 0006 GR + 7 A$_memcpy$76 0009 GR + 7 A$_memcpy$77 000B GR + 7 A$_memcpy$78 000C GR + 7 A$_memcpy$79 000E GR + 7 A$_memcpy$80 000F GR + 7 A$_memcpy$81 0010 GR + 7 A$_memcpy$82 0012 GR + 7 A$_memcpy$83 0013 GR + 7 A$_memcpy$85 0014 GR + 7 A$_memcpy$86 0017 GR + 7 A$_memcpy$87 0018 GR + 7 A$_memcpy$88 001A GR + 7 A$_memcpy$89 001B GR + 7 A$_memcpy$90 001C GR + 7 A$_memcpy$91 001E GR + 7 A$_memcpy$92 001F GR + 7 A$_memcpy$93 0020 GR + 7 A$_memcpy$95 0022 GR + 7 A$_memcpy$96 0025 GR + 7 A$_memcpy$97 0026 GR + 7 A$_memcpy$98 0028 GR + 7 A$_memcpy$99 0029 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_memcpy.c$45$1$1 = 0087 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$memcpy$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$memcpy$0$0 = 0087 GR + __gptrget **** GX + __gptrput **** GX + 7 _memcpy 0000 GR + 5 _memcpy_PARM_2 0000 GR + 5 _memcpy_PARM_3 0003 GR + 5 _memcpy_dst_1_1 0005 R + 1 _memcpy_sloc0_1_0 0000 R + 1 _memcpy_sloc1_1_0 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 88 flags 20 diff --git a/device/lib/_memset.c b/device/lib/_memset.c new file mode 100644 index 00000000..6f02bd85 --- /dev/null +++ b/device/lib/_memset.c @@ -0,0 +1,42 @@ +/*------------------------------------------------------------------------- + _memset.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +void _generic *memset ( + void _generic * buf, + unsigned char ch , + int count + ) +{ + register unsigned char _generic *ret = buf; + + while (count--) { + *(unsigned char _generic *) ret = ch; + ret = ((unsigned char _generic *) ret) + 1; + } + + return buf ; +} + diff --git a/device/lib/_memset.lst b/device/lib/_memset.lst new file mode 100644 index 00000000..532d9aad --- /dev/null +++ b/device/lib/_memset.lst @@ -0,0 +1,143 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _memset + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _memset_PARM_3 + 11 .globl _memset_PARM_2 + 12 .globl _memset + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 16 ;-------------------------------------------------------- + 17 ; special function bits + 18 ;-------------------------------------------------------- + 19 ;-------------------------------------------------------- + 20 ; internal ram data + 21 ;-------------------------------------------------------- + 22 .area DSEG (DATA) + 23 ;-------------------------------------------------------- + 24 ; overlayable items in internal ram + 25 ;-------------------------------------------------------- + 26 .area OSEG (OVR,DATA) + 27 ;-------------------------------------------------------- + 28 ; indirectly addressable internal ram data + 29 ;-------------------------------------------------------- + 30 .area ISEG (DATA) + 31 ;-------------------------------------------------------- + 32 ; bit data + 33 ;-------------------------------------------------------- + 34 .area BSEG (BIT) + 35 ;-------------------------------------------------------- + 36 ; external ram data + 37 ;-------------------------------------------------------- + 38 .area XSEG (XDATA) + 0000 39 _memset_PARM_2: + 0000 40 .ds 0x0001 + 0001 41 _memset_PARM_3: + 0001 42 .ds 0x0002 + 0003 43 _memset_buf_1_1: + 0003 44 .ds 0x0003 + 45 ;-------------------------------------------------------- + 46 ; global & static initialisations + 47 ;-------------------------------------------------------- + 48 .area GSINIT (CODE) + 49 ;-------------------------------------------------------- + 50 ; code + 51 ;-------------------------------------------------------- + 52 .area CSEG (CODE) + 0000 53 G$memset$0$0 ==. + 54 ; _memset.c 27 + 55 ; ----------------------------------------- + 56 ; function memset + 57 ; ----------------------------------------- + 0000 58 _memset: + 0002 59 ar2 = 0x02 + 0003 60 ar3 = 0x03 + 0004 61 ar4 = 0x04 + 0005 62 ar5 = 0x05 + 0006 63 ar6 = 0x06 + 0007 64 ar7 = 0x07 + 0000 65 ar0 = 0x00 + 0001 66 ar1 = 0x01 + 67 ; _memset.c 40 + 0000 C0 F0 68 push b + 0002 C0 83 69 push dph + 0004 C0 82 70 push dpl + 0006 90s00r03 71 mov dptr,#_memset_buf_1_1 + 0009 D0 E0 72 pop acc + 000B F0 73 movx @dptr,a + 000C D0 E0 74 pop acc + 000E A3 75 inc dptr + 000F F0 76 movx @dptr,a + 0010 D0 E0 77 pop acc + 0012 A3 78 inc dptr + 0013 F0 79 movx @dptr,a + 80 ; _memset.c 33 + 0014 90s00r03 81 mov dptr,#_memset_buf_1_1 + 0017 E0 82 movx a,@dptr + 0018 FA 83 mov r2,a + 0019 A3 84 inc dptr + 001A E0 85 movx a,@dptr + 001B FB 86 mov r3,a + 001C A3 87 inc dptr + 001D E0 88 movx a,@dptr + 001E FC 89 mov r4,a + 90 ; _memset.c 35 + 001F 90s00r00 91 mov dptr,#_memset_PARM_2 + 0022 E0 92 movx a,@dptr + 0023 FD 93 mov r5,a + 0024 90s00r01 94 mov dptr,#_memset_PARM_3 + 0027 E0 95 movx a,@dptr + 0028 FE 96 mov r6,a + 0029 A3 97 inc dptr + 002A E0 98 movx a,@dptr + 002B FF 99 mov r7,a + 002C 100 00101$: + 002C 8E 00 101 mov ar0,r6 + 002E 8F 01 102 mov ar1,r7 + 0030 1E 103 dec r6 + 0031 BE FF 01 104 cjne r6,#0xff,00108$ + 0034 1F 105 dec r7 + 0035 106 00108$: + 0035 E8 107 mov a,r0 + 0036 49 108 orl a,r1 + 109 ; Peephole 110 removed ljmp by inverse jump logic + 0037 60 11 110 jz 00103$ + 0039 111 00109$: + 112 ; _memset.c 36 + 0039 8A 82 113 mov dpl,r2 + 003B 8B 83 114 mov dph,r3 + 003D 8C F0 115 mov b,r4 + 003F ED 116 mov a,r5 + 0040 12s00r00 117 lcall __gptrput + 118 ; _memset.c 37 + 0043 0A 119 inc r2 + 0044 BA 00 01 120 cjne r2,#0x00,00110$ + 0047 0B 121 inc r3 + 0048 122 00110$: + 123 ; Peephole 132 changed ljmp to sjmp + 0048 80 E2 124 sjmp 00101$ + 004A 125 00103$: + 126 ; _memset.c 40 + 004A 90s00r03 127 mov dptr,#_memset_buf_1_1 + 004D E0 128 movx a,@dptr + 004E FA 129 mov r2,a + 004F A3 130 inc dptr + 0050 E0 131 movx a,@dptr + 0051 FB 132 mov r3,a + 0052 A3 133 inc dptr + 0053 E0 134 movx a,@dptr + 0054 FC 135 mov r4,a + 0055 8A 82 136 mov dpl,r2 + 0057 8B 83 137 mov dph,r3 + 0059 8C F0 138 mov b,r4 + 005B 139 00104$: + 005B 140 C$_memset.c$41$1$1 ==. + 005B 141 XG$memset$0$0 ==. + 005B 22 142 ret + 143 .area CSEG (CODE) diff --git a/device/lib/_memset.sym b/device/lib/_memset.sym new file mode 100644 index 00000000..c6d34d30 --- /dev/null +++ b/device/lib/_memset.sym @@ -0,0 +1,429 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_memset$101 002C GR + 7 A$_memset$102 002E GR + 7 A$_memset$103 0030 GR + 7 A$_memset$104 0031 GR + 7 A$_memset$105 0034 GR + 7 A$_memset$107 0035 GR + 7 A$_memset$108 0036 GR + 7 A$_memset$110 0037 GR + 7 A$_memset$113 0039 GR + 7 A$_memset$114 003B GR + 7 A$_memset$115 003D GR + 7 A$_memset$116 003F GR + 7 A$_memset$117 0040 GR + 7 A$_memset$119 0043 GR + 7 A$_memset$120 0044 GR + 7 A$_memset$121 0047 GR + 7 A$_memset$124 0048 GR + 7 A$_memset$127 004A GR + 7 A$_memset$128 004D GR + 7 A$_memset$129 004E GR + 7 A$_memset$130 004F GR + 7 A$_memset$131 0050 GR + 7 A$_memset$132 0051 GR + 7 A$_memset$133 0052 GR + 7 A$_memset$134 0053 GR + 7 A$_memset$135 0054 GR + 7 A$_memset$136 0055 GR + 7 A$_memset$137 0057 GR + 7 A$_memset$138 0059 GR + 7 A$_memset$142 005B GR + 7 A$_memset$68 0000 GR + 7 A$_memset$69 0002 GR + 7 A$_memset$70 0004 GR + 7 A$_memset$71 0006 GR + 7 A$_memset$72 0009 GR + 7 A$_memset$73 000B GR + 7 A$_memset$74 000C GR + 7 A$_memset$75 000E GR + 7 A$_memset$76 000F GR + 7 A$_memset$77 0010 GR + 7 A$_memset$78 0012 GR + 7 A$_memset$79 0013 GR + 7 A$_memset$81 0014 GR + 7 A$_memset$82 0017 GR + 7 A$_memset$83 0018 GR + 7 A$_memset$84 0019 GR + 7 A$_memset$85 001A GR + 7 A$_memset$86 001B GR + 7 A$_memset$87 001C GR + 7 A$_memset$88 001D GR + 7 A$_memset$89 001E GR + 7 A$_memset$91 001F GR + 7 A$_memset$92 0022 GR + 7 A$_memset$93 0023 GR + 7 A$_memset$94 0024 GR + 7 A$_memset$95 0027 GR + 7 A$_memset$96 0028 GR + 7 A$_memset$97 0029 GR + 7 A$_memset$98 002A GR + 7 A$_memset$99 002B GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_memset.c$41$1$1 = 005B GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$memset$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$memset$0$0 = 005B GR + __gptrput **** GX + 7 _memset 0000 GR + 5 _memset_PARM_2 0000 GR + 5 _memset_PARM_3 0001 GR + 5 _memset_buf_1_1 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 6 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 5C flags 20 diff --git a/device/lib/_modsint.c b/device/lib/_modsint.c new file mode 100644 index 00000000..eaac0a20 --- /dev/null +++ b/device/lib/_modsint.c @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + + _modsint.c :- routine for signed int (16 bit) modulus + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +int _modsint (int a, int b) +{ + register int r; + + r = _moduint((a < 0 ? -a : a), + (b < 0 ? -b : b)); + + if ( (a < 0) ^ (b < 0)) + return -r; + else + return r; +} diff --git a/device/lib/_modsint.lst b/device/lib/_modsint.lst new file mode 100644 index 00000000..6286d079 --- /dev/null +++ b/device/lib/_modsint.lst @@ -0,0 +1,178 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _modsint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __modsint_PARM_2 + 11 .globl __modsint + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 __modsint_PARM_2: + 0000 39 .ds 0x0002 + 0002 40 __modsint_a_1_1: + 0002 41 .ds 0x0002 + 42 ;-------------------------------------------------------- + 43 ; global & static initialisations + 44 ;-------------------------------------------------------- + 45 .area GSINIT (CODE) + 46 ;-------------------------------------------------------- + 47 ; code + 48 ;-------------------------------------------------------- + 49 .area CSEG (CODE) + 0000 50 G$_modsint$0$0 ==. + 51 ; _modsint.c 26 + 52 ; ----------------------------------------- + 53 ; function _modsint + 54 ; ----------------------------------------- + 0000 55 __modsint: + 0002 56 ar2 = 0x02 + 0003 57 ar3 = 0x03 + 0004 58 ar4 = 0x04 + 0005 59 ar5 = 0x05 + 0006 60 ar6 = 0x06 + 0007 61 ar7 = 0x07 + 0000 62 ar0 = 0x00 + 0001 63 ar1 = 0x01 + 64 ; _modsint.c 0 + 0000 C0 83 65 push dph + 0002 C0 82 66 push dpl + 0004 90s00r02 67 mov dptr,#__modsint_a_1_1 + 0007 D0 E0 68 pop acc + 0009 F0 69 movx @dptr,a + 000A D0 E0 70 pop acc + 000C A3 71 inc dptr + 000D F0 72 movx @dptr,a + 73 ; _modsint.c 30 + 000E 90s00r02 74 mov dptr,#__modsint_a_1_1 + 0011 E0 75 movx a,@dptr + 0012 FA 76 mov r2,a + 0013 A3 77 inc dptr + 0014 E0 78 movx a,@dptr + 79 ; Peephole 105 removed redundant mov + 0015 FB 80 mov r3,a + 81 ; Peephole 111 removed ljmp by inverse jump logic + 0016 30 E7 09 82 jnb acc.7,00106$ + 0019 83 00113$: + 0019 C3 84 clr c + 001A E4 85 clr a + 001B 9A 86 subb a,r2 + 001C FC 87 mov r4,a + 001D E4 88 clr a + 001E 9B 89 subb a,r3 + 001F FD 90 mov r5,a + 91 ; Peephole 132 changed ljmp to sjmp + 0020 80 04 92 sjmp 00107$ + 0022 93 00106$: + 0022 8A 04 94 mov ar4,r2 + 0024 8B 05 95 mov ar5,r3 + 0026 96 00107$: + 0026 8C 02 97 mov ar2,r4 + 0028 8D 03 98 mov ar3,r5 + 99 ; _modsint.c 31 + 002A 90s00r00 100 mov dptr,#__modsint_PARM_2 + 002D E0 101 movx a,@dptr + 002E FC 102 mov r4,a + 002F A3 103 inc dptr + 0030 E0 104 movx a,@dptr + 105 ; Peephole 105 removed redundant mov + 0031 FD 106 mov r5,a + 0032 33 107 rlc a + 0033 E4 108 clr a + 0034 33 109 rlc a + 110 ; Peephole 105 removed redundant mov + 0035 FE 111 mov r6,a + 112 ; Peephole 110 removed ljmp by inverse jump logic + 0036 60 09 113 jz 00108$ + 0038 114 00114$: + 0038 C3 115 clr c + 0039 E4 116 clr a + 003A 9C 117 subb a,r4 + 003B FF 118 mov r7,a + 003C E4 119 clr a + 003D 9D 120 subb a,r5 + 003E F8 121 mov r0,a + 122 ; Peephole 132 changed ljmp to sjmp + 003F 80 04 123 sjmp 00109$ + 0041 124 00108$: + 0041 8C 07 125 mov ar7,r4 + 0043 8D 00 126 mov ar0,r5 + 0045 127 00109$: + 0045 90s00r00 128 mov dptr,#__moduint_PARM_2 + 0048 EF 129 mov a,r7 + 0049 F0 130 movx @dptr,a + 004A A3 131 inc dptr + 004B E8 132 mov a,r0 + 004C F0 133 movx @dptr,a + 004D C0 06 134 push ar6 + 004F 8A 82 135 mov dpl,r2 + 0051 8B 83 136 mov dph,r3 + 0053 12s00r00 137 lcall __moduint + 0056 AA 82 138 mov r2,dpl + 0058 AB 83 139 mov r3,dph + 005A D0 06 140 pop ar6 + 141 ; _modsint.c 33 + 005C 90s00r02 142 mov dptr,#__modsint_a_1_1 + 005F E0 143 movx a,@dptr + 0060 FC 144 mov r4,a + 0061 A3 145 inc dptr + 0062 E0 146 movx a,@dptr + 147 ; Peephole 105 removed redundant mov + 0063 FD 148 mov r5,a + 0064 33 149 rlc a + 0065 E4 150 clr a + 0066 33 151 rlc a + 0067 FC 152 mov r4,a + 0068 EE 153 mov a,r6 + 0069 65 04 154 xrl a,ar4 + 155 ; Peephole 110 removed ljmp by inverse jump logic + 006B 60 0D 156 jz 00102$ + 006D 157 00115$: + 158 ; _modsint.c 34 + 006D C3 159 clr c + 006E E4 160 clr a + 006F 9A 161 subb a,r2 + 0070 FC 162 mov r4,a + 0071 E4 163 clr a + 0072 9B 164 subb a,r3 + 0073 FE 165 mov r6,a + 0074 8C 82 166 mov dpl,r4 + 0076 8E 83 167 mov dph,r6 + 168 ; Peephole 132 changed ljmp to sjmp + 0078 80 04 169 sjmp 00104$ + 007A 170 00102$: + 171 ; _modsint.c 36 + 007A 8A 82 172 mov dpl,r2 + 007C 8B 83 173 mov dph,r3 + 007E 174 00104$: + 007E 175 C$_modsint.c$37$1$1 ==. + 007E 176 XG$_modsint$0$0 ==. + 007E 22 177 ret + 178 .area CSEG (CODE) diff --git a/device/lib/_modsint.sym b/device/lib/_modsint.sym new file mode 100644 index 00000000..8d5cf70e --- /dev/null +++ b/device/lib/_modsint.sym @@ -0,0 +1,456 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_modsint$100 002A GR + 7 A$_modsint$101 002D GR + 7 A$_modsint$102 002E GR + 7 A$_modsint$103 002F GR + 7 A$_modsint$104 0030 GR + 7 A$_modsint$106 0031 GR + 7 A$_modsint$107 0032 GR + 7 A$_modsint$108 0033 GR + 7 A$_modsint$109 0034 GR + 7 A$_modsint$111 0035 GR + 7 A$_modsint$113 0036 GR + 7 A$_modsint$115 0038 GR + 7 A$_modsint$116 0039 GR + 7 A$_modsint$117 003A GR + 7 A$_modsint$118 003B GR + 7 A$_modsint$119 003C GR + 7 A$_modsint$120 003D GR + 7 A$_modsint$121 003E GR + 7 A$_modsint$123 003F GR + 7 A$_modsint$125 0041 GR + 7 A$_modsint$126 0043 GR + 7 A$_modsint$128 0045 GR + 7 A$_modsint$129 0048 GR + 7 A$_modsint$130 0049 GR + 7 A$_modsint$131 004A GR + 7 A$_modsint$132 004B GR + 7 A$_modsint$133 004C GR + 7 A$_modsint$134 004D GR + 7 A$_modsint$135 004F GR + 7 A$_modsint$136 0051 GR + 7 A$_modsint$137 0053 GR + 7 A$_modsint$138 0056 GR + 7 A$_modsint$139 0058 GR + 7 A$_modsint$140 005A GR + 7 A$_modsint$142 005C GR + 7 A$_modsint$143 005F GR + 7 A$_modsint$144 0060 GR + 7 A$_modsint$145 0061 GR + 7 A$_modsint$146 0062 GR + 7 A$_modsint$148 0063 GR + 7 A$_modsint$149 0064 GR + 7 A$_modsint$150 0065 GR + 7 A$_modsint$151 0066 GR + 7 A$_modsint$152 0067 GR + 7 A$_modsint$153 0068 GR + 7 A$_modsint$154 0069 GR + 7 A$_modsint$156 006B GR + 7 A$_modsint$159 006D GR + 7 A$_modsint$160 006E GR + 7 A$_modsint$161 006F GR + 7 A$_modsint$162 0070 GR + 7 A$_modsint$163 0071 GR + 7 A$_modsint$164 0072 GR + 7 A$_modsint$165 0073 GR + 7 A$_modsint$166 0074 GR + 7 A$_modsint$167 0076 GR + 7 A$_modsint$169 0078 GR + 7 A$_modsint$172 007A GR + 7 A$_modsint$173 007C GR + 7 A$_modsint$177 007E GR + 7 A$_modsint$65 0000 GR + 7 A$_modsint$66 0002 GR + 7 A$_modsint$67 0004 GR + 7 A$_modsint$68 0007 GR + 7 A$_modsint$69 0009 GR + 7 A$_modsint$70 000A GR + 7 A$_modsint$71 000C GR + 7 A$_modsint$72 000D GR + 7 A$_modsint$74 000E GR + 7 A$_modsint$75 0011 GR + 7 A$_modsint$76 0012 GR + 7 A$_modsint$77 0013 GR + 7 A$_modsint$78 0014 GR + 7 A$_modsint$80 0015 GR + 7 A$_modsint$82 0016 GR + 7 A$_modsint$84 0019 GR + 7 A$_modsint$85 001A GR + 7 A$_modsint$86 001B GR + 7 A$_modsint$87 001C GR + 7 A$_modsint$88 001D GR + 7 A$_modsint$89 001E GR + 7 A$_modsint$90 001F GR + 7 A$_modsint$92 0020 GR + 7 A$_modsint$94 0022 GR + 7 A$_modsint$95 0024 GR + 7 A$_modsint$97 0026 GR + 7 A$_modsint$98 0028 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_modsint.c$37$1$1 = 007E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_modsint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_modsint$0$0 = 007E GR + 7 __modsint 0000 GR + 5 __modsint_PARM_2 0000 GR + 5 __modsint_a_1_1 0002 R + __moduint **** GX + __moduint_PARM_2 **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 4 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 7F flags 20 diff --git a/device/lib/_modslong.c b/device/lib/_modslong.c new file mode 100644 index 00000000..98e42f9d --- /dev/null +++ b/device/lib/_modslong.c @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + _modslong.c - routine for modulus of 32 bit signed long + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +long _modslong (long a, long b) +{ + long r; + + r = _modulong((a < 0 ? -a : a), + (b < 0 ? -b : b)); + + if ( (a < 0) ^ (b < 0)) + return -r; + else + return r; +} diff --git a/device/lib/_modslong.lst b/device/lib/_modslong.lst new file mode 100644 index 00000000..1e461f89 --- /dev/null +++ b/device/lib/_modslong.lst @@ -0,0 +1,254 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _modslong + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __modslong_PARM_2 + 11 .globl __modslong + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 __modslong_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 __modslong_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 __modslong_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 __modslong_a_1_1: + 0004 45 .ds 0x0004 + 46 ;-------------------------------------------------------- + 47 ; global & static initialisations + 48 ;-------------------------------------------------------- + 49 .area GSINIT (CODE) + 50 ;-------------------------------------------------------- + 51 ; code + 52 ;-------------------------------------------------------- + 53 .area CSEG (CODE) + 0000 54 G$_modslong$0$0 ==. + 55 ; _modslong.c 24 + 56 ; ----------------------------------------- + 57 ; function _modslong + 58 ; ----------------------------------------- + 0000 59 __modslong: + 0002 60 ar2 = 0x02 + 0003 61 ar3 = 0x03 + 0004 62 ar4 = 0x04 + 0005 63 ar5 = 0x05 + 0006 64 ar6 = 0x06 + 0007 65 ar7 = 0x07 + 0000 66 ar0 = 0x00 + 0001 67 ar1 = 0x01 + 68 ; _modslong.c 0 + 0000 C0 E0 69 push acc + 0002 C0 F0 70 push b + 0004 C0 83 71 push dph + 0006 C0 82 72 push dpl + 0008 90s00r04 73 mov dptr,#__modslong_a_1_1 + 000B D0 E0 74 pop acc + 000D F0 75 movx @dptr,a + 000E D0 E0 76 pop acc + 0010 A3 77 inc dptr + 0011 F0 78 movx @dptr,a + 0012 D0 E0 79 pop acc + 0014 A3 80 inc dptr + 0015 F0 81 movx @dptr,a + 0016 D0 E0 82 pop acc + 0018 A3 83 inc dptr + 0019 F0 84 movx @dptr,a + 85 ; _modslong.c 28 + 001A 90s00r04 86 mov dptr,#__modslong_a_1_1 + 001D E0 87 movx a,@dptr + 001E FA 88 mov r2,a + 001F A3 89 inc dptr + 0020 E0 90 movx a,@dptr + 0021 FB 91 mov r3,a + 0022 A3 92 inc dptr + 0023 E0 93 movx a,@dptr + 0024 FC 94 mov r4,a + 0025 A3 95 inc dptr + 0026 E0 96 movx a,@dptr + 97 ; Peephole 105 removed redundant mov + 0027 FD 98 mov r5,a + 99 ; Peephole 111 removed ljmp by inverse jump logic + 0028 30 E7 0F 100 jnb acc.7,00106$ + 002B 101 00113$: + 002B C3 102 clr c + 002C E4 103 clr a + 002D 9A 104 subb a,r2 + 002E FE 105 mov r6,a + 002F E4 106 clr a + 0030 9B 107 subb a,r3 + 0031 FF 108 mov r7,a + 0032 E4 109 clr a + 0033 9C 110 subb a,r4 + 0034 F8 111 mov r0,a + 0035 E4 112 clr a + 0036 9D 113 subb a,r5 + 0037 F9 114 mov r1,a + 115 ; Peephole 132 changed ljmp to sjmp + 0038 80 08 116 sjmp 00107$ + 003A 117 00106$: + 003A 8A 06 118 mov ar6,r2 + 003C 8B 07 119 mov ar7,r3 + 003E 8C 00 120 mov ar0,r4 + 0040 8D 01 121 mov ar1,r5 + 0042 122 00107$: + 0042 8E*00 123 mov __modslong_sloc0_1_0,r6 + 0044 8F*01 124 mov (__modslong_sloc0_1_0 + 1),r7 + 0046 88*02 125 mov (__modslong_sloc0_1_0 + 2),r0 + 0048 89*03 126 mov (__modslong_sloc0_1_0 + 3),r1 + 127 ; _modslong.c 29 + 004A 90s00r00 128 mov dptr,#__modslong_PARM_2 + 004D E0 129 movx a,@dptr + 004E FE 130 mov r6,a + 004F A3 131 inc dptr + 0050 E0 132 movx a,@dptr + 0051 FF 133 mov r7,a + 0052 A3 134 inc dptr + 0053 E0 135 movx a,@dptr + 0054 F8 136 mov r0,a + 0055 A3 137 inc dptr + 0056 E0 138 movx a,@dptr + 139 ; Peephole 105 removed redundant mov + 0057 F9 140 mov r1,a + 0058 33 141 rlc a + 0059 E4 142 clr a + 005A 33 143 rlc a + 144 ; Peephole 105 removed redundant mov + 005B FA 145 mov r2,a + 146 ; Peephole 110 removed ljmp by inverse jump logic + 005C 60 13 147 jz 00108$ + 005E 148 00114$: + 005E C3 149 clr c + 005F E4 150 clr a + 0060 9E 151 subb a,r6 + 0061 F5*04 152 mov __modslong_sloc1_1_0,a + 0063 E4 153 clr a + 0064 9F 154 subb a,r7 + 0065 F5*05 155 mov (__modslong_sloc1_1_0 + 1),a + 0067 E4 156 clr a + 0068 98 157 subb a,r0 + 0069 F5*06 158 mov (__modslong_sloc1_1_0 + 2),a + 006B E4 159 clr a + 006C 99 160 subb a,r1 + 006D F5*07 161 mov (__modslong_sloc1_1_0 + 3),a + 162 ; Peephole 132 changed ljmp to sjmp + 006F 80 08 163 sjmp 00109$ + 0071 164 00108$: + 0071 8E*04 165 mov __modslong_sloc1_1_0,r6 + 0073 8F*05 166 mov (__modslong_sloc1_1_0 + 1),r7 + 0075 88*06 167 mov (__modslong_sloc1_1_0 + 2),r0 + 0077 89*07 168 mov (__modslong_sloc1_1_0 + 3),r1 + 0079 169 00109$: + 0079 90s00r00 170 mov dptr,#__modulong_PARM_2 + 007C E5*04 171 mov a,__modslong_sloc1_1_0 + 007E F0 172 movx @dptr,a + 007F A3 173 inc dptr + 0080 E5*05 174 mov a,(__modslong_sloc1_1_0 + 1) + 0082 F0 175 movx @dptr,a + 0083 A3 176 inc dptr + 0084 E5*06 177 mov a,(__modslong_sloc1_1_0 + 2) + 0086 F0 178 movx @dptr,a + 0087 A3 179 inc dptr + 0088 E5*07 180 mov a,(__modslong_sloc1_1_0 + 3) + 008A F0 181 movx @dptr,a + 008B C0 02 182 push ar2 + 008D 85*00 82 183 mov dpl,__modslong_sloc0_1_0 + 0090 85*01 83 184 mov dph,(__modslong_sloc0_1_0 + 1) + 0093 85*02 F0 185 mov b,(__modslong_sloc0_1_0 + 2) + 0096 E5*03 186 mov a,(__modslong_sloc0_1_0 + 3) + 0098 12s00r00 187 lcall __modulong + 009B AB 82 188 mov r3,dpl + 009D AC 83 189 mov r4,dph + 009F AD F0 190 mov r5,b + 00A1 FE 191 mov r6,a + 00A2 D0 02 192 pop ar2 + 193 ; _modslong.c 31 + 00A4 C0 03 194 push ar3 + 00A6 C0 04 195 push ar4 + 00A8 C0 05 196 push ar5 + 00AA C0 06 197 push ar6 + 00AC 90s00r04 198 mov dptr,#__modslong_a_1_1 + 00AF E0 199 movx a,@dptr + 00B0 FF 200 mov r7,a + 00B1 A3 201 inc dptr + 00B2 E0 202 movx a,@dptr + 00B3 F8 203 mov r0,a + 00B4 A3 204 inc dptr + 00B5 E0 205 movx a,@dptr + 00B6 F9 206 mov r1,a + 00B7 A3 207 inc dptr + 00B8 E0 208 movx a,@dptr + 209 ; Peephole 105 removed redundant mov + 00B9 FB 210 mov r3,a + 00BA 33 211 rlc a + 00BB E4 212 clr a + 00BC 33 213 rlc a + 00BD FF 214 mov r7,a + 00BE EA 215 mov a,r2 + 00BF 65 07 216 xrl a,ar7 + 00C1 D0 06 217 pop ar6 + 00C3 D0 05 218 pop ar5 + 00C5 D0 04 219 pop ar4 + 00C7 D0 03 220 pop ar3 + 221 ; Peephole 110 removed ljmp by inverse jump logic + 00C9 60 1C 222 jz 00102$ + 00CB 223 00115$: + 224 ; _modslong.c 32 + 00CB C3 225 clr c + 00CC E4 226 clr a + 00CD 9B 227 subb a,r3 + 00CE F5*04 228 mov __modslong_sloc1_1_0,a + 00D0 E4 229 clr a + 00D1 9C 230 subb a,r4 + 00D2 F5*05 231 mov (__modslong_sloc1_1_0 + 1),a + 00D4 E4 232 clr a + 00D5 9D 233 subb a,r5 + 00D6 F5*06 234 mov (__modslong_sloc1_1_0 + 2),a + 00D8 E4 235 clr a + 00D9 9E 236 subb a,r6 + 237 ; Peephole 191 removed redundant mov + 00DA F5*07 238 mov (__modslong_sloc1_1_0 + 3),a + 00DC 85*04 82 239 mov dpl,__modslong_sloc1_1_0 + 00DF 85*05 83 240 mov dph,(__modslong_sloc1_1_0 + 1) + 00E2 85*06 F0 241 mov b,(__modslong_sloc1_1_0 + 2) + 242 ; Peephole 132 changed ljmp to sjmp + 00E5 80 07 243 sjmp 00104$ + 00E7 244 00102$: + 245 ; _modslong.c 34 + 00E7 8B 82 246 mov dpl,r3 + 00E9 8C 83 247 mov dph,r4 + 00EB 8D F0 248 mov b,r5 + 00ED EE 249 mov a,r6 + 00EE 250 00104$: + 00EE 251 C$_modslong.c$35$1$1 ==. + 00EE 252 XG$_modslong$0$0 ==. + 00EE 22 253 ret + 254 .area CSEG (CODE) diff --git a/device/lib/_modslong.sym b/device/lib/_modslong.sym new file mode 100644 index 00000000..97795c7c --- /dev/null +++ b/device/lib/_modslong.sym @@ -0,0 +1,529 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_modslong$100 0028 GR + 7 A$_modslong$102 002B GR + 7 A$_modslong$103 002C GR + 7 A$_modslong$104 002D GR + 7 A$_modslong$105 002E GR + 7 A$_modslong$106 002F GR + 7 A$_modslong$107 0030 GR + 7 A$_modslong$108 0031 GR + 7 A$_modslong$109 0032 GR + 7 A$_modslong$110 0033 GR + 7 A$_modslong$111 0034 GR + 7 A$_modslong$112 0035 GR + 7 A$_modslong$113 0036 GR + 7 A$_modslong$114 0037 GR + 7 A$_modslong$116 0038 GR + 7 A$_modslong$118 003A GR + 7 A$_modslong$119 003C GR + 7 A$_modslong$120 003E GR + 7 A$_modslong$121 0040 GR + 7 A$_modslong$123 0042 GR + 7 A$_modslong$124 0044 GR + 7 A$_modslong$125 0046 GR + 7 A$_modslong$126 0048 GR + 7 A$_modslong$128 004A GR + 7 A$_modslong$129 004D GR + 7 A$_modslong$130 004E GR + 7 A$_modslong$131 004F GR + 7 A$_modslong$132 0050 GR + 7 A$_modslong$133 0051 GR + 7 A$_modslong$134 0052 GR + 7 A$_modslong$135 0053 GR + 7 A$_modslong$136 0054 GR + 7 A$_modslong$137 0055 GR + 7 A$_modslong$138 0056 GR + 7 A$_modslong$140 0057 GR + 7 A$_modslong$141 0058 GR + 7 A$_modslong$142 0059 GR + 7 A$_modslong$143 005A GR + 7 A$_modslong$145 005B GR + 7 A$_modslong$147 005C GR + 7 A$_modslong$149 005E GR + 7 A$_modslong$150 005F GR + 7 A$_modslong$151 0060 GR + 7 A$_modslong$152 0061 GR + 7 A$_modslong$153 0063 GR + 7 A$_modslong$154 0064 GR + 7 A$_modslong$155 0065 GR + 7 A$_modslong$156 0067 GR + 7 A$_modslong$157 0068 GR + 7 A$_modslong$158 0069 GR + 7 A$_modslong$159 006B GR + 7 A$_modslong$160 006C GR + 7 A$_modslong$161 006D GR + 7 A$_modslong$163 006F GR + 7 A$_modslong$165 0071 GR + 7 A$_modslong$166 0073 GR + 7 A$_modslong$167 0075 GR + 7 A$_modslong$168 0077 GR + 7 A$_modslong$170 0079 GR + 7 A$_modslong$171 007C GR + 7 A$_modslong$172 007E GR + 7 A$_modslong$173 007F GR + 7 A$_modslong$174 0080 GR + 7 A$_modslong$175 0082 GR + 7 A$_modslong$176 0083 GR + 7 A$_modslong$177 0084 GR + 7 A$_modslong$178 0086 GR + 7 A$_modslong$179 0087 GR + 7 A$_modslong$180 0088 GR + 7 A$_modslong$181 008A GR + 7 A$_modslong$182 008B GR + 7 A$_modslong$183 008D GR + 7 A$_modslong$184 0090 GR + 7 A$_modslong$185 0093 GR + 7 A$_modslong$186 0096 GR + 7 A$_modslong$187 0098 GR + 7 A$_modslong$188 009B GR + 7 A$_modslong$189 009D GR + 7 A$_modslong$190 009F GR + 7 A$_modslong$191 00A1 GR + 7 A$_modslong$192 00A2 GR + 7 A$_modslong$194 00A4 GR + 7 A$_modslong$195 00A6 GR + 7 A$_modslong$196 00A8 GR + 7 A$_modslong$197 00AA GR + 7 A$_modslong$198 00AC GR + 7 A$_modslong$199 00AF GR + 7 A$_modslong$200 00B0 GR + 7 A$_modslong$201 00B1 GR + 7 A$_modslong$202 00B2 GR + 7 A$_modslong$203 00B3 GR + 7 A$_modslong$204 00B4 GR + 7 A$_modslong$205 00B5 GR + 7 A$_modslong$206 00B6 GR + 7 A$_modslong$207 00B7 GR + 7 A$_modslong$208 00B8 GR + 7 A$_modslong$210 00B9 GR + 7 A$_modslong$211 00BA GR + 7 A$_modslong$212 00BB GR + 7 A$_modslong$213 00BC GR + 7 A$_modslong$214 00BD GR + 7 A$_modslong$215 00BE GR + 7 A$_modslong$216 00BF GR + 7 A$_modslong$217 00C1 GR + 7 A$_modslong$218 00C3 GR + 7 A$_modslong$219 00C5 GR + 7 A$_modslong$220 00C7 GR + 7 A$_modslong$222 00C9 GR + 7 A$_modslong$225 00CB GR + 7 A$_modslong$226 00CC GR + 7 A$_modslong$227 00CD GR + 7 A$_modslong$228 00CE GR + 7 A$_modslong$229 00D0 GR + 7 A$_modslong$230 00D1 GR + 7 A$_modslong$231 00D2 GR + 7 A$_modslong$232 00D4 GR + 7 A$_modslong$233 00D5 GR + 7 A$_modslong$234 00D6 GR + 7 A$_modslong$235 00D8 GR + 7 A$_modslong$236 00D9 GR + 7 A$_modslong$238 00DA GR + 7 A$_modslong$239 00DC GR + 7 A$_modslong$240 00DF GR + 7 A$_modslong$241 00E2 GR + 7 A$_modslong$243 00E5 GR + 7 A$_modslong$246 00E7 GR + 7 A$_modslong$247 00E9 GR + 7 A$_modslong$248 00EB GR + 7 A$_modslong$249 00ED GR + 7 A$_modslong$253 00EE GR + 7 A$_modslong$69 0000 GR + 7 A$_modslong$70 0002 GR + 7 A$_modslong$71 0004 GR + 7 A$_modslong$72 0006 GR + 7 A$_modslong$73 0008 GR + 7 A$_modslong$74 000B GR + 7 A$_modslong$75 000D GR + 7 A$_modslong$76 000E GR + 7 A$_modslong$77 0010 GR + 7 A$_modslong$78 0011 GR + 7 A$_modslong$79 0012 GR + 7 A$_modslong$80 0014 GR + 7 A$_modslong$81 0015 GR + 7 A$_modslong$82 0016 GR + 7 A$_modslong$83 0018 GR + 7 A$_modslong$84 0019 GR + 7 A$_modslong$86 001A GR + 7 A$_modslong$87 001D GR + 7 A$_modslong$88 001E GR + 7 A$_modslong$89 001F GR + 7 A$_modslong$90 0020 GR + 7 A$_modslong$91 0021 GR + 7 A$_modslong$92 0022 GR + 7 A$_modslong$93 0023 GR + 7 A$_modslong$94 0024 GR + 7 A$_modslong$95 0025 GR + 7 A$_modslong$96 0026 GR + 7 A$_modslong$98 0027 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_modslong.c$35$1$1 = 00EE GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_modslong$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_modslong$0$0 = 00EE GR + 7 __modslong 0000 GR + 5 __modslong_PARM_2 0000 GR + 5 __modslong_a_1_1 0004 R + 1 __modslong_sloc0_1_0 0000 R + 1 __modslong_sloc1_1_0 0004 R + __modulong **** GX + __modulong_PARM_2 **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size EF flags 20 diff --git a/device/lib/_moduint.c b/device/lib/_moduint.c new file mode 100644 index 00000000..49fd28ea --- /dev/null +++ b/device/lib/_moduint.c @@ -0,0 +1,53 @@ +/*------------------------------------------------------------------------- + + _moduint.c :- routine for unsigned int (16 bit) modulus + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + Bug fixes by Martijn van Balen, aed@iae.nl + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1) + +unsigned int _moduint (unsigned int a ,unsigned int b) +{ + unsigned short count = 0; + + + while (!MSB_SET(b)) { + b <<= 1; + if (b > a) + { + b >>=1; + break; + } + count++; + } + + do { + if (b <= a) { + a -= b; + } + b >>= 1; + } while (count--); + + return a; +} diff --git a/device/lib/_moduint.lst b/device/lib/_moduint.lst new file mode 100644 index 00000000..cc53e551 --- /dev/null +++ b/device/lib/_moduint.lst @@ -0,0 +1,228 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _moduint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __moduint_PARM_2 + 11 .globl __moduint + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 __moduint_PARM_2: + 0000 39 .ds 0x0002 + 0002 40 __moduint_a_1_1: + 0002 41 .ds 0x0002 + 0004 42 __moduint_count_1_1: + 0004 43 .ds 0x0001 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$_moduint$0$0 ==. + 53 ; _moduint.c 30 + 54 ; ----------------------------------------- + 55 ; function _moduint + 56 ; ----------------------------------------- + 0000 57 __moduint: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _moduint.c 52 + 0000 C0 83 67 push dph + 0002 C0 82 68 push dpl + 0004 90s00r02 69 mov dptr,#__moduint_a_1_1 + 0007 D0 E0 70 pop acc + 0009 F0 71 movx @dptr,a + 000A D0 E0 72 pop acc + 000C A3 73 inc dptr + 000D F0 74 movx @dptr,a + 75 ; _moduint.c 32 + 000E 90s00r04 76 mov dptr,#__moduint_count_1_1 + 77 ; Peephole 180 changed mov to clr + 0011 E4 78 clr a + 0012 F0 79 movx @dptr,a + 80 ; _moduint.c 35 + 0013 90s00r02 81 mov dptr,#__moduint_a_1_1 + 0016 E0 82 movx a,@dptr + 0017 FA 83 mov r2,a + 0018 A3 84 inc dptr + 0019 E0 85 movx a,@dptr + 001A FB 86 mov r3,a + 001B 7C 00 87 mov r4,#0x00 + 001D 88 00103$: + 001D 90s00r00 89 mov dptr,#__moduint_PARM_2 + 0020 E0 90 movx a,@dptr + 0021 FD 91 mov r5,a + 0022 A3 92 inc dptr + 0023 E0 93 movx a,@dptr + 94 ; Peephole 105 removed redundant mov + 0024 FE 95 mov r6,a + 0025 23 96 rl a + 0026 54 01 97 anl a,#0x01 + 98 ; Peephole 105 removed redundant mov + 0028 FF 99 mov r7,a + 100 ; Peephole 109 removed ljmp by inverse jump logic + 0029 70 30 101 jnz 00117$ + 002B 102 00119$: + 103 ; _moduint.c 36 + 002B EE 104 mov a,r6 + 002C CD 105 xch a,r5 + 002D 25 E0 106 add a,acc + 002F CD 107 xch a,r5 + 0030 33 108 rlc a + 0031 FE 109 mov r6,a + 0032 90s00r00 110 mov dptr,#__moduint_PARM_2 + 0035 ED 111 mov a,r5 + 0036 F0 112 movx @dptr,a + 0037 A3 113 inc dptr + 0038 EE 114 mov a,r6 + 0039 F0 115 movx @dptr,a + 116 ; _moduint.c 37 + 003A C3 117 clr c + 003B EA 118 mov a,r2 + 003C 9D 119 subb a,r5 + 003D EB 120 mov a,r3 + 003E 9E 121 subb a,r6 + 122 ; Peephole 108 removed ljmp by inverse jump logic + 003F 50 11 123 jnc 00102$ + 0041 124 00120$: + 125 ; _moduint.c 39 + 0041 EE 126 mov a,r6 + 0042 C3 127 clr c + 0043 13 128 rrc a + 0044 CD 129 xch a,r5 + 0045 13 130 rrc a + 0046 CD 131 xch a,r5 + 0047 FE 132 mov r6,a + 0048 90s00r00 133 mov dptr,#__moduint_PARM_2 + 004B ED 134 mov a,r5 + 004C F0 135 movx @dptr,a + 004D A3 136 inc dptr + 004E EE 137 mov a,r6 + 004F F0 138 movx @dptr,a + 139 ; _moduint.c 40 + 140 ; Peephole 132 changed ljmp to sjmp + 0050 80 09 141 sjmp 00117$ + 0052 142 00102$: + 143 ; _moduint.c 42 + 0052 0C 144 inc r4 + 0053 90s00r04 145 mov dptr,#__moduint_count_1_1 + 0056 EC 146 mov a,r4 + 0057 F0 147 movx @dptr,a + 0058 02s00r1D 148 ljmp 00103$ + 149 ; _moduint.c 45 + 005B 150 00117$: + 005B 90s00r04 151 mov dptr,#__moduint_count_1_1 + 005E E0 152 movx a,@dptr + 005F FA 153 mov r2,a + 0060 154 00108$: + 155 ; _moduint.c 46 + 0060 90s00r02 156 mov dptr,#__moduint_a_1_1 + 0063 E0 157 movx a,@dptr + 0064 FB 158 mov r3,a + 0065 A3 159 inc dptr + 0066 E0 160 movx a,@dptr + 0067 FC 161 mov r4,a + 0068 90s00r00 162 mov dptr,#__moduint_PARM_2 + 006B E0 163 movx a,@dptr + 006C FD 164 mov r5,a + 006D A3 165 inc dptr + 006E E0 166 movx a,@dptr + 006F FE 167 mov r6,a + 0070 C3 168 clr c + 0071 EB 169 mov a,r3 + 0072 9D 170 subb a,r5 + 0073 EC 171 mov a,r4 + 0074 9E 172 subb a,r6 + 173 ; Peephole 132 changed ljmp to sjmp + 174 ; Peephole 160 removed sjmp by inverse jump logic + 0075 40 0B 175 jc 00107$ + 0077 176 00121$: + 177 ; _moduint.c 47 + 0077 90s00r02 178 mov dptr,#__moduint_a_1_1 + 007A C3 179 clr c + 007B EB 180 mov a,r3 + 007C 9D 181 subb a,r5 + 007D F0 182 movx @dptr,a + 007E EC 183 mov a,r4 + 007F 9E 184 subb a,r6 + 0080 A3 185 inc dptr + 0081 F0 186 movx @dptr,a + 0082 187 00107$: + 188 ; _moduint.c 49 + 0082 90s00r00 189 mov dptr,#__moduint_PARM_2 + 0085 E0 190 movx a,@dptr + 0086 FB 191 mov r3,a + 0087 A3 192 inc dptr + 0088 E0 193 movx a,@dptr + 194 ; Peephole 105 removed redundant mov + 0089 FC 195 mov r4,a + 008A C3 196 clr c + 008B 13 197 rrc a + 008C CB 198 xch a,r3 + 008D 13 199 rrc a + 008E CB 200 xch a,r3 + 008F FC 201 mov r4,a + 0090 90s00r00 202 mov dptr,#__moduint_PARM_2 + 0093 EB 203 mov a,r3 + 0094 F0 204 movx @dptr,a + 0095 A3 205 inc dptr + 0096 EC 206 mov a,r4 + 0097 F0 207 movx @dptr,a + 208 ; _moduint.c 50 + 0098 8A 03 209 mov ar3,r2 + 009A 1A 210 dec r2 + 009B EB 211 mov a,r3 + 009C 60 03 212 jz 00122$ + 009E 02s00r60 213 ljmp 00108$ + 00A1 214 00122$: + 215 ; _moduint.c 52 + 00A1 90s00r02 216 mov dptr,#__moduint_a_1_1 + 00A4 E0 217 movx a,@dptr + 00A5 FA 218 mov r2,a + 00A6 A3 219 inc dptr + 00A7 E0 220 movx a,@dptr + 00A8 FB 221 mov r3,a + 00A9 8A 82 222 mov dpl,r2 + 00AB 8B 83 223 mov dph,r3 + 00AD 224 00111$: + 00AD 225 C$_moduint.c$53$1$1 ==. + 00AD 226 XG$_moduint$0$0 ==. + 00AD 22 227 ret + 228 .area CSEG (CODE) diff --git a/device/lib/_moduint.sym b/device/lib/_moduint.sym new file mode 100644 index 00000000..ab02448c --- /dev/null +++ b/device/lib/_moduint.sym @@ -0,0 +1,495 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_moduint$101 0029 GR + 7 A$_moduint$104 002B GR + 7 A$_moduint$105 002C GR + 7 A$_moduint$106 002D GR + 7 A$_moduint$107 002F GR + 7 A$_moduint$108 0030 GR + 7 A$_moduint$109 0031 GR + 7 A$_moduint$110 0032 GR + 7 A$_moduint$111 0035 GR + 7 A$_moduint$112 0036 GR + 7 A$_moduint$113 0037 GR + 7 A$_moduint$114 0038 GR + 7 A$_moduint$115 0039 GR + 7 A$_moduint$117 003A GR + 7 A$_moduint$118 003B GR + 7 A$_moduint$119 003C GR + 7 A$_moduint$120 003D GR + 7 A$_moduint$121 003E GR + 7 A$_moduint$123 003F GR + 7 A$_moduint$126 0041 GR + 7 A$_moduint$127 0042 GR + 7 A$_moduint$128 0043 GR + 7 A$_moduint$129 0044 GR + 7 A$_moduint$130 0045 GR + 7 A$_moduint$131 0046 GR + 7 A$_moduint$132 0047 GR + 7 A$_moduint$133 0048 GR + 7 A$_moduint$134 004B GR + 7 A$_moduint$135 004C GR + 7 A$_moduint$136 004D GR + 7 A$_moduint$137 004E GR + 7 A$_moduint$138 004F GR + 7 A$_moduint$141 0050 GR + 7 A$_moduint$144 0052 GR + 7 A$_moduint$145 0053 GR + 7 A$_moduint$146 0056 GR + 7 A$_moduint$147 0057 GR + 7 A$_moduint$148 0058 GR + 7 A$_moduint$151 005B GR + 7 A$_moduint$152 005E GR + 7 A$_moduint$153 005F GR + 7 A$_moduint$156 0060 GR + 7 A$_moduint$157 0063 GR + 7 A$_moduint$158 0064 GR + 7 A$_moduint$159 0065 GR + 7 A$_moduint$160 0066 GR + 7 A$_moduint$161 0067 GR + 7 A$_moduint$162 0068 GR + 7 A$_moduint$163 006B GR + 7 A$_moduint$164 006C GR + 7 A$_moduint$165 006D GR + 7 A$_moduint$166 006E GR + 7 A$_moduint$167 006F GR + 7 A$_moduint$168 0070 GR + 7 A$_moduint$169 0071 GR + 7 A$_moduint$170 0072 GR + 7 A$_moduint$171 0073 GR + 7 A$_moduint$172 0074 GR + 7 A$_moduint$175 0075 GR + 7 A$_moduint$178 0077 GR + 7 A$_moduint$179 007A GR + 7 A$_moduint$180 007B GR + 7 A$_moduint$181 007C GR + 7 A$_moduint$182 007D GR + 7 A$_moduint$183 007E GR + 7 A$_moduint$184 007F GR + 7 A$_moduint$185 0080 GR + 7 A$_moduint$186 0081 GR + 7 A$_moduint$189 0082 GR + 7 A$_moduint$190 0085 GR + 7 A$_moduint$191 0086 GR + 7 A$_moduint$192 0087 GR + 7 A$_moduint$193 0088 GR + 7 A$_moduint$195 0089 GR + 7 A$_moduint$196 008A GR + 7 A$_moduint$197 008B GR + 7 A$_moduint$198 008C GR + 7 A$_moduint$199 008D GR + 7 A$_moduint$200 008E GR + 7 A$_moduint$201 008F GR + 7 A$_moduint$202 0090 GR + 7 A$_moduint$203 0093 GR + 7 A$_moduint$204 0094 GR + 7 A$_moduint$205 0095 GR + 7 A$_moduint$206 0096 GR + 7 A$_moduint$207 0097 GR + 7 A$_moduint$209 0098 GR + 7 A$_moduint$210 009A GR + 7 A$_moduint$211 009B GR + 7 A$_moduint$212 009C GR + 7 A$_moduint$213 009E GR + 7 A$_moduint$216 00A1 GR + 7 A$_moduint$217 00A4 GR + 7 A$_moduint$218 00A5 GR + 7 A$_moduint$219 00A6 GR + 7 A$_moduint$220 00A7 GR + 7 A$_moduint$221 00A8 GR + 7 A$_moduint$222 00A9 GR + 7 A$_moduint$223 00AB GR + 7 A$_moduint$227 00AD GR + 7 A$_moduint$67 0000 GR + 7 A$_moduint$68 0002 GR + 7 A$_moduint$69 0004 GR + 7 A$_moduint$70 0007 GR + 7 A$_moduint$71 0009 GR + 7 A$_moduint$72 000A GR + 7 A$_moduint$73 000C GR + 7 A$_moduint$74 000D GR + 7 A$_moduint$76 000E GR + 7 A$_moduint$78 0011 GR + 7 A$_moduint$79 0012 GR + 7 A$_moduint$81 0013 GR + 7 A$_moduint$82 0016 GR + 7 A$_moduint$83 0017 GR + 7 A$_moduint$84 0018 GR + 7 A$_moduint$85 0019 GR + 7 A$_moduint$86 001A GR + 7 A$_moduint$87 001B GR + 7 A$_moduint$89 001D GR + 7 A$_moduint$90 0020 GR + 7 A$_moduint$91 0021 GR + 7 A$_moduint$92 0022 GR + 7 A$_moduint$93 0023 GR + 7 A$_moduint$95 0024 GR + 7 A$_moduint$96 0025 GR + 7 A$_moduint$97 0026 GR + 7 A$_moduint$99 0028 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_moduint.c$53$1$1 = 00AD GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_moduint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_moduint$0$0 = 00AD GR + 7 __moduint 0000 GR + 5 __moduint_PARM_2 0000 GR + 5 __moduint_a_1_1 0002 R + 5 __moduint_count_1_1 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 5 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size AE flags 20 diff --git a/device/lib/_modulong.c b/device/lib/_modulong.c new file mode 100644 index 00000000..8b56a726 --- /dev/null +++ b/device/lib/_modulong.c @@ -0,0 +1,52 @@ +/*------------------------------------------------------------------------- + _modulong.c - routine for modulus of 32 bit unsigned long + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + Bug fixes by Martijn van Balen, aed@iae.nl + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1) + +unsigned long _modulong (unsigned long a ,unsigned long b) +{ + unsigned short count = 0; + + + while (!MSB_SET(b)) { + b <<= 1; + if (b > a) + { + b >>=1; + break; + } + count++; + } + + do { + if (b <= a) { + a -= b; + } + b >>= 1; + } while (count--); + + return a; +} diff --git a/device/lib/_modulong.lst b/device/lib/_modulong.lst new file mode 100644 index 00000000..82147b38 --- /dev/null +++ b/device/lib/_modulong.lst @@ -0,0 +1,328 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _modulong + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __modulong_PARM_2 + 11 .globl __modulong + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 __modulong_sloc0_1_0: + 0000 23 .ds 0x0004 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 __modulong_PARM_2: + 0000 41 .ds 0x0004 + 0004 42 __modulong_a_1_1: + 0004 43 .ds 0x0004 + 0008 44 __modulong_count_1_1: + 0008 45 .ds 0x0001 + 46 ;-------------------------------------------------------- + 47 ; global & static initialisations + 48 ;-------------------------------------------------------- + 49 .area GSINIT (CODE) + 50 ;-------------------------------------------------------- + 51 ; code + 52 ;-------------------------------------------------------- + 53 .area CSEG (CODE) + 0000 54 G$_modulong$0$0 ==. + 55 ; _modulong.c 29 + 56 ; ----------------------------------------- + 57 ; function _modulong + 58 ; ----------------------------------------- + 0000 59 __modulong: + 0002 60 ar2 = 0x02 + 0003 61 ar3 = 0x03 + 0004 62 ar4 = 0x04 + 0005 63 ar5 = 0x05 + 0006 64 ar6 = 0x06 + 0007 65 ar7 = 0x07 + 0000 66 ar0 = 0x00 + 0001 67 ar1 = 0x01 + 68 ; _modulong.c 51 + 0000 C0 E0 69 push acc + 0002 C0 F0 70 push b + 0004 C0 83 71 push dph + 0006 C0 82 72 push dpl + 0008 90s00r04 73 mov dptr,#__modulong_a_1_1 + 000B D0 E0 74 pop acc + 000D F0 75 movx @dptr,a + 000E D0 E0 76 pop acc + 0010 A3 77 inc dptr + 0011 F0 78 movx @dptr,a + 0012 D0 E0 79 pop acc + 0014 A3 80 inc dptr + 0015 F0 81 movx @dptr,a + 0016 D0 E0 82 pop acc + 0018 A3 83 inc dptr + 0019 F0 84 movx @dptr,a + 85 ; _modulong.c 31 + 001A 90s00r08 86 mov dptr,#__modulong_count_1_1 + 87 ; Peephole 180 changed mov to clr + 001D E4 88 clr a + 001E F0 89 movx @dptr,a + 90 ; _modulong.c 34 + 001F 90s00r04 91 mov dptr,#__modulong_a_1_1 + 0022 E0 92 movx a,@dptr + 0023 F5*00 93 mov __modulong_sloc0_1_0,a + 0025 A3 94 inc dptr + 0026 E0 95 movx a,@dptr + 0027 F5*01 96 mov (__modulong_sloc0_1_0 + 1),a + 0029 A3 97 inc dptr + 002A E0 98 movx a,@dptr + 002B F5*02 99 mov (__modulong_sloc0_1_0 + 2),a + 002D A3 100 inc dptr + 002E E0 101 movx a,@dptr + 002F F5*03 102 mov (__modulong_sloc0_1_0 + 3),a + 0031 7E 00 103 mov r6,#0x00 + 0033 104 00103$: + 0033 90s00r00 105 mov dptr,#__modulong_PARM_2 + 0036 E0 106 movx a,@dptr + 0037 FF 107 mov r7,a + 0038 A3 108 inc dptr + 0039 E0 109 movx a,@dptr + 003A F8 110 mov r0,a + 003B A3 111 inc dptr + 003C E0 112 movx a,@dptr + 003D F9 113 mov r1,a + 003E A3 114 inc dptr + 003F E0 115 movx a,@dptr + 116 ; Peephole 105 removed redundant mov + 0040 FA 117 mov r2,a + 0041 23 118 rl a + 0042 54 01 119 anl a,#0x01 + 120 ; Peephole 105 removed redundant mov + 0044 FB 121 mov r3,a + 0045 60 03 122 jz 00119$ + 0047 02s00r99 123 ljmp 00117$ + 004A 124 00119$: + 125 ; _modulong.c 35 + 004A EF 126 mov a,r7 + 004B 25 E0 127 add a,acc + 004D FD 128 mov r5,a + 004E E8 129 mov a,r0 + 004F 33 130 rlc a + 0050 FB 131 mov r3,a + 0051 E9 132 mov a,r1 + 0052 33 133 rlc a + 0053 FC 134 mov r4,a + 0054 EA 135 mov a,r2 + 0055 33 136 rlc a + 0056 FA 137 mov r2,a + 0057 90s00r00 138 mov dptr,#__modulong_PARM_2 + 005A ED 139 mov a,r5 + 005B F0 140 movx @dptr,a + 005C A3 141 inc dptr + 005D EB 142 mov a,r3 + 005E F0 143 movx @dptr,a + 005F A3 144 inc dptr + 0060 EC 145 mov a,r4 + 0061 F0 146 movx @dptr,a + 0062 A3 147 inc dptr + 0063 EA 148 mov a,r2 + 0064 F0 149 movx @dptr,a + 150 ; _modulong.c 36 + 0065 C3 151 clr c + 0066 E5*00 152 mov a,__modulong_sloc0_1_0 + 0068 9D 153 subb a,r5 + 0069 E5*01 154 mov a,(__modulong_sloc0_1_0 + 1) + 006B 9B 155 subb a,r3 + 006C E5*02 156 mov a,(__modulong_sloc0_1_0 + 2) + 006E 9C 157 subb a,r4 + 006F E5*03 158 mov a,(__modulong_sloc0_1_0 + 3) + 0071 9A 159 subb a,r2 + 160 ; Peephole 108 removed ljmp by inverse jump logic + 0072 50 1C 161 jnc 00102$ + 0074 162 00120$: + 163 ; _modulong.c 38 + 0074 C3 164 clr c + 0075 EA 165 mov a,r2 + 0076 13 166 rrc a + 0077 FA 167 mov r2,a + 0078 EC 168 mov a,r4 + 0079 13 169 rrc a + 007A FC 170 mov r4,a + 007B EB 171 mov a,r3 + 007C 13 172 rrc a + 007D FB 173 mov r3,a + 007E ED 174 mov a,r5 + 007F 13 175 rrc a + 176 ; Peephole 100 removed redundant mov + 0080 FD 177 mov r5,a + 0081 90s00r00 178 mov dptr,#__modulong_PARM_2 + 0084 F0 179 movx @dptr,a + 0085 A3 180 inc dptr + 0086 EB 181 mov a,r3 + 0087 F0 182 movx @dptr,a + 0088 A3 183 inc dptr + 0089 EC 184 mov a,r4 + 008A F0 185 movx @dptr,a + 008B A3 186 inc dptr + 008C EA 187 mov a,r2 + 008D F0 188 movx @dptr,a + 189 ; _modulong.c 39 + 190 ; Peephole 132 changed ljmp to sjmp + 008E 80 09 191 sjmp 00117$ + 0090 192 00102$: + 193 ; _modulong.c 41 + 0090 0E 194 inc r6 + 0091 90s00r08 195 mov dptr,#__modulong_count_1_1 + 0094 EE 196 mov a,r6 + 0095 F0 197 movx @dptr,a + 0096 02s00r33 198 ljmp 00103$ + 199 ; _modulong.c 44 + 0099 200 00117$: + 0099 90s00r08 201 mov dptr,#__modulong_count_1_1 + 009C E0 202 movx a,@dptr + 009D F5*00 203 mov __modulong_sloc0_1_0,a + 009F 204 00108$: + 205 ; _modulong.c 45 + 009F 90s00r04 206 mov dptr,#__modulong_a_1_1 + 00A2 E0 207 movx a,@dptr + 00A3 FB 208 mov r3,a + 00A4 A3 209 inc dptr + 00A5 E0 210 movx a,@dptr + 00A6 FC 211 mov r4,a + 00A7 A3 212 inc dptr + 00A8 E0 213 movx a,@dptr + 00A9 FD 214 mov r5,a + 00AA A3 215 inc dptr + 00AB E0 216 movx a,@dptr + 00AC FE 217 mov r6,a + 00AD 90s00r00 218 mov dptr,#__modulong_PARM_2 + 00B0 E0 219 movx a,@dptr + 00B1 FF 220 mov r7,a + 00B2 A3 221 inc dptr + 00B3 E0 222 movx a,@dptr + 00B4 F8 223 mov r0,a + 00B5 A3 224 inc dptr + 00B6 E0 225 movx a,@dptr + 00B7 F9 226 mov r1,a + 00B8 A3 227 inc dptr + 00B9 E0 228 movx a,@dptr + 00BA FA 229 mov r2,a + 00BB C3 230 clr c + 00BC EB 231 mov a,r3 + 00BD 9F 232 subb a,r7 + 00BE EC 233 mov a,r4 + 00BF 98 234 subb a,r0 + 00C0 ED 235 mov a,r5 + 00C1 99 236 subb a,r1 + 00C2 EE 237 mov a,r6 + 00C3 9A 238 subb a,r2 + 239 ; Peephole 132 changed ljmp to sjmp + 240 ; Peephole 160 removed sjmp by inverse jump logic + 00C4 40 13 241 jc 00107$ + 00C6 242 00121$: + 243 ; _modulong.c 46 + 00C6 90s00r04 244 mov dptr,#__modulong_a_1_1 + 00C9 C3 245 clr c + 00CA EB 246 mov a,r3 + 00CB 9F 247 subb a,r7 + 00CC F0 248 movx @dptr,a + 00CD EC 249 mov a,r4 + 00CE 98 250 subb a,r0 + 00CF A3 251 inc dptr + 00D0 F0 252 movx @dptr,a + 00D1 ED 253 mov a,r5 + 00D2 99 254 subb a,r1 + 00D3 A3 255 inc dptr + 00D4 F0 256 movx @dptr,a + 00D5 EE 257 mov a,r6 + 00D6 9A 258 subb a,r2 + 00D7 A3 259 inc dptr + 00D8 F0 260 movx @dptr,a + 00D9 261 00107$: + 262 ; _modulong.c 48 + 00D9 90s00r00 263 mov dptr,#__modulong_PARM_2 + 00DC E0 264 movx a,@dptr + 00DD FA 265 mov r2,a + 00DE A3 266 inc dptr + 00DF E0 267 movx a,@dptr + 00E0 FB 268 mov r3,a + 00E1 A3 269 inc dptr + 00E2 E0 270 movx a,@dptr + 00E3 FC 271 mov r4,a + 00E4 A3 272 inc dptr + 00E5 E0 273 movx a,@dptr + 274 ; Peephole 106 removed redundant mov + 00E6 FD 275 mov r5,a + 00E7 C3 276 clr c + 00E8 13 277 rrc a + 00E9 FD 278 mov r5,a + 00EA EC 279 mov a,r4 + 00EB 13 280 rrc a + 00EC FC 281 mov r4,a + 00ED EB 282 mov a,r3 + 00EE 13 283 rrc a + 00EF FB 284 mov r3,a + 00F0 EA 285 mov a,r2 + 00F1 13 286 rrc a + 287 ; Peephole 100 removed redundant mov + 00F2 FA 288 mov r2,a + 00F3 90s00r00 289 mov dptr,#__modulong_PARM_2 + 00F6 F0 290 movx @dptr,a + 00F7 A3 291 inc dptr + 00F8 EB 292 mov a,r3 + 00F9 F0 293 movx @dptr,a + 00FA A3 294 inc dptr + 00FB EC 295 mov a,r4 + 00FC F0 296 movx @dptr,a + 00FD A3 297 inc dptr + 00FE ED 298 mov a,r5 + 00FF F0 299 movx @dptr,a + 300 ; _modulong.c 49 + 0100 AA*00 301 mov r2,__modulong_sloc0_1_0 + 0102 15*00 302 dec __modulong_sloc0_1_0 + 0104 EA 303 mov a,r2 + 0105 60 03 304 jz 00122$ + 0107 02s00r9F 305 ljmp 00108$ + 010A 306 00122$: + 307 ; _modulong.c 51 + 010A 90s00r04 308 mov dptr,#__modulong_a_1_1 + 010D E0 309 movx a,@dptr + 010E FA 310 mov r2,a + 010F A3 311 inc dptr + 0110 E0 312 movx a,@dptr + 0111 FB 313 mov r3,a + 0112 A3 314 inc dptr + 0113 E0 315 movx a,@dptr + 0114 FC 316 mov r4,a + 0115 A3 317 inc dptr + 0116 E0 318 movx a,@dptr + 319 ; Peephole 191 removed redundant mov + 0117 FD 320 mov r5,a + 0118 8A 82 321 mov dpl,r2 + 011A 8B 83 322 mov dph,r3 + 011C 8C F0 323 mov b,r4 + 011E 324 00111$: + 011E 325 C$_modulong.c$52$1$1 ==. + 011E 326 XG$_modulong$0$0 ==. + 011E 22 327 ret + 328 .area CSEG (CODE) diff --git a/device/lib/_modulong.sym b/device/lib/_modulong.sym new file mode 100644 index 00000000..c23134ef --- /dev/null +++ b/device/lib/_modulong.sym @@ -0,0 +1,592 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_modulong$100 002D GR + 7 A$_modulong$101 002E GR + 7 A$_modulong$102 002F GR + 7 A$_modulong$103 0031 GR + 7 A$_modulong$105 0033 GR + 7 A$_modulong$106 0036 GR + 7 A$_modulong$107 0037 GR + 7 A$_modulong$108 0038 GR + 7 A$_modulong$109 0039 GR + 7 A$_modulong$110 003A GR + 7 A$_modulong$111 003B GR + 7 A$_modulong$112 003C GR + 7 A$_modulong$113 003D GR + 7 A$_modulong$114 003E GR + 7 A$_modulong$115 003F GR + 7 A$_modulong$117 0040 GR + 7 A$_modulong$118 0041 GR + 7 A$_modulong$119 0042 GR + 7 A$_modulong$121 0044 GR + 7 A$_modulong$122 0045 GR + 7 A$_modulong$123 0047 GR + 7 A$_modulong$126 004A GR + 7 A$_modulong$127 004B GR + 7 A$_modulong$128 004D GR + 7 A$_modulong$129 004E GR + 7 A$_modulong$130 004F GR + 7 A$_modulong$131 0050 GR + 7 A$_modulong$132 0051 GR + 7 A$_modulong$133 0052 GR + 7 A$_modulong$134 0053 GR + 7 A$_modulong$135 0054 GR + 7 A$_modulong$136 0055 GR + 7 A$_modulong$137 0056 GR + 7 A$_modulong$138 0057 GR + 7 A$_modulong$139 005A GR + 7 A$_modulong$140 005B GR + 7 A$_modulong$141 005C GR + 7 A$_modulong$142 005D GR + 7 A$_modulong$143 005E GR + 7 A$_modulong$144 005F GR + 7 A$_modulong$145 0060 GR + 7 A$_modulong$146 0061 GR + 7 A$_modulong$147 0062 GR + 7 A$_modulong$148 0063 GR + 7 A$_modulong$149 0064 GR + 7 A$_modulong$151 0065 GR + 7 A$_modulong$152 0066 GR + 7 A$_modulong$153 0068 GR + 7 A$_modulong$154 0069 GR + 7 A$_modulong$155 006B GR + 7 A$_modulong$156 006C GR + 7 A$_modulong$157 006E GR + 7 A$_modulong$158 006F GR + 7 A$_modulong$159 0071 GR + 7 A$_modulong$161 0072 GR + 7 A$_modulong$164 0074 GR + 7 A$_modulong$165 0075 GR + 7 A$_modulong$166 0076 GR + 7 A$_modulong$167 0077 GR + 7 A$_modulong$168 0078 GR + 7 A$_modulong$169 0079 GR + 7 A$_modulong$170 007A GR + 7 A$_modulong$171 007B GR + 7 A$_modulong$172 007C GR + 7 A$_modulong$173 007D GR + 7 A$_modulong$174 007E GR + 7 A$_modulong$175 007F GR + 7 A$_modulong$177 0080 GR + 7 A$_modulong$178 0081 GR + 7 A$_modulong$179 0084 GR + 7 A$_modulong$180 0085 GR + 7 A$_modulong$181 0086 GR + 7 A$_modulong$182 0087 GR + 7 A$_modulong$183 0088 GR + 7 A$_modulong$184 0089 GR + 7 A$_modulong$185 008A GR + 7 A$_modulong$186 008B GR + 7 A$_modulong$187 008C GR + 7 A$_modulong$188 008D GR + 7 A$_modulong$191 008E GR + 7 A$_modulong$194 0090 GR + 7 A$_modulong$195 0091 GR + 7 A$_modulong$196 0094 GR + 7 A$_modulong$197 0095 GR + 7 A$_modulong$198 0096 GR + 7 A$_modulong$201 0099 GR + 7 A$_modulong$202 009C GR + 7 A$_modulong$203 009D GR + 7 A$_modulong$206 009F GR + 7 A$_modulong$207 00A2 GR + 7 A$_modulong$208 00A3 GR + 7 A$_modulong$209 00A4 GR + 7 A$_modulong$210 00A5 GR + 7 A$_modulong$211 00A6 GR + 7 A$_modulong$212 00A7 GR + 7 A$_modulong$213 00A8 GR + 7 A$_modulong$214 00A9 GR + 7 A$_modulong$215 00AA GR + 7 A$_modulong$216 00AB GR + 7 A$_modulong$217 00AC GR + 7 A$_modulong$218 00AD GR + 7 A$_modulong$219 00B0 GR + 7 A$_modulong$220 00B1 GR + 7 A$_modulong$221 00B2 GR + 7 A$_modulong$222 00B3 GR + 7 A$_modulong$223 00B4 GR + 7 A$_modulong$224 00B5 GR + 7 A$_modulong$225 00B6 GR + 7 A$_modulong$226 00B7 GR + 7 A$_modulong$227 00B8 GR + 7 A$_modulong$228 00B9 GR + 7 A$_modulong$229 00BA GR + 7 A$_modulong$230 00BB GR + 7 A$_modulong$231 00BC GR + 7 A$_modulong$232 00BD GR + 7 A$_modulong$233 00BE GR + 7 A$_modulong$234 00BF GR + 7 A$_modulong$235 00C0 GR + 7 A$_modulong$236 00C1 GR + 7 A$_modulong$237 00C2 GR + 7 A$_modulong$238 00C3 GR + 7 A$_modulong$241 00C4 GR + 7 A$_modulong$244 00C6 GR + 7 A$_modulong$245 00C9 GR + 7 A$_modulong$246 00CA GR + 7 A$_modulong$247 00CB GR + 7 A$_modulong$248 00CC GR + 7 A$_modulong$249 00CD GR + 7 A$_modulong$250 00CE GR + 7 A$_modulong$251 00CF GR + 7 A$_modulong$252 00D0 GR + 7 A$_modulong$253 00D1 GR + 7 A$_modulong$254 00D2 GR + 7 A$_modulong$255 00D3 GR + 7 A$_modulong$256 00D4 GR + 7 A$_modulong$257 00D5 GR + 7 A$_modulong$258 00D6 GR + 7 A$_modulong$259 00D7 GR + 7 A$_modulong$260 00D8 GR + 7 A$_modulong$263 00D9 GR + 7 A$_modulong$264 00DC GR + 7 A$_modulong$265 00DD GR + 7 A$_modulong$266 00DE GR + 7 A$_modulong$267 00DF GR + 7 A$_modulong$268 00E0 GR + 7 A$_modulong$269 00E1 GR + 7 A$_modulong$270 00E2 GR + 7 A$_modulong$271 00E3 GR + 7 A$_modulong$272 00E4 GR + 7 A$_modulong$273 00E5 GR + 7 A$_modulong$275 00E6 GR + 7 A$_modulong$276 00E7 GR + 7 A$_modulong$277 00E8 GR + 7 A$_modulong$278 00E9 GR + 7 A$_modulong$279 00EA GR + 7 A$_modulong$280 00EB GR + 7 A$_modulong$281 00EC GR + 7 A$_modulong$282 00ED GR + 7 A$_modulong$283 00EE GR + 7 A$_modulong$284 00EF GR + 7 A$_modulong$285 00F0 GR + 7 A$_modulong$286 00F1 GR + 7 A$_modulong$288 00F2 GR + 7 A$_modulong$289 00F3 GR + 7 A$_modulong$290 00F6 GR + 7 A$_modulong$291 00F7 GR + 7 A$_modulong$292 00F8 GR + 7 A$_modulong$293 00F9 GR + 7 A$_modulong$294 00FA GR + 7 A$_modulong$295 00FB GR + 7 A$_modulong$296 00FC GR + 7 A$_modulong$297 00FD GR + 7 A$_modulong$298 00FE GR + 7 A$_modulong$299 00FF GR + 7 A$_modulong$301 0100 GR + 7 A$_modulong$302 0102 GR + 7 A$_modulong$303 0104 GR + 7 A$_modulong$304 0105 GR + 7 A$_modulong$305 0107 GR + 7 A$_modulong$308 010A GR + 7 A$_modulong$309 010D GR + 7 A$_modulong$310 010E GR + 7 A$_modulong$311 010F GR + 7 A$_modulong$312 0110 GR + 7 A$_modulong$313 0111 GR + 7 A$_modulong$314 0112 GR + 7 A$_modulong$315 0113 GR + 7 A$_modulong$316 0114 GR + 7 A$_modulong$317 0115 GR + 7 A$_modulong$318 0116 GR + 7 A$_modulong$320 0117 GR + 7 A$_modulong$321 0118 GR + 7 A$_modulong$322 011A GR + 7 A$_modulong$323 011C GR + 7 A$_modulong$327 011E GR + 7 A$_modulong$69 0000 GR + 7 A$_modulong$70 0002 GR + 7 A$_modulong$71 0004 GR + 7 A$_modulong$72 0006 GR + 7 A$_modulong$73 0008 GR + 7 A$_modulong$74 000B GR + 7 A$_modulong$75 000D GR + 7 A$_modulong$76 000E GR + 7 A$_modulong$77 0010 GR + 7 A$_modulong$78 0011 GR + 7 A$_modulong$79 0012 GR + 7 A$_modulong$80 0014 GR + 7 A$_modulong$81 0015 GR + 7 A$_modulong$82 0016 GR + 7 A$_modulong$83 0018 GR + 7 A$_modulong$84 0019 GR + 7 A$_modulong$86 001A GR + 7 A$_modulong$88 001D GR + 7 A$_modulong$89 001E GR + 7 A$_modulong$91 001F GR + 7 A$_modulong$92 0022 GR + 7 A$_modulong$93 0023 GR + 7 A$_modulong$94 0025 GR + 7 A$_modulong$95 0026 GR + 7 A$_modulong$96 0027 GR + 7 A$_modulong$97 0029 GR + 7 A$_modulong$98 002A GR + 7 A$_modulong$99 002B GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_modulong.c$52$1$1 = 011E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_modulong$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_modulong$0$0 = 011E GR + 7 __modulong 0000 GR + 5 __modulong_PARM_2 0000 GR + 5 __modulong_a_1_1 0004 R + 5 __modulong_count_1_1 0008 R + 1 __modulong_sloc0_1_0 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 4 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 9 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 11F flags 20 diff --git a/device/lib/_mulsint.c b/device/lib/_mulsint.c new file mode 100644 index 00000000..f13025b2 --- /dev/null +++ b/device/lib/_mulsint.c @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + + _mulsint.c :- routine for signed int (16 bit) multiplication + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +int _mulsint (int a, int b) +{ + register int r; + + r = _muluint ( ((a < 0) ? -a : a), + ((b < 0) ? -b : b) ); + + if ( (a < 0) ^ (b < 0)) + return -r; + else + return r; +} diff --git a/device/lib/_mulsint.lst b/device/lib/_mulsint.lst new file mode 100644 index 00000000..10ba563a --- /dev/null +++ b/device/lib/_mulsint.lst @@ -0,0 +1,178 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _mulsint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __mulsint_PARM_2 + 11 .globl __mulsint + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 __mulsint_PARM_2: + 0000 39 .ds 0x0002 + 0002 40 __mulsint_a_1_1: + 0002 41 .ds 0x0002 + 42 ;-------------------------------------------------------- + 43 ; global & static initialisations + 44 ;-------------------------------------------------------- + 45 .area GSINIT (CODE) + 46 ;-------------------------------------------------------- + 47 ; code + 48 ;-------------------------------------------------------- + 49 .area CSEG (CODE) + 0000 50 G$_mulsint$0$0 ==. + 51 ; _mulsint.c 26 + 52 ; ----------------------------------------- + 53 ; function _mulsint + 54 ; ----------------------------------------- + 0000 55 __mulsint: + 0002 56 ar2 = 0x02 + 0003 57 ar3 = 0x03 + 0004 58 ar4 = 0x04 + 0005 59 ar5 = 0x05 + 0006 60 ar6 = 0x06 + 0007 61 ar7 = 0x07 + 0000 62 ar0 = 0x00 + 0001 63 ar1 = 0x01 + 64 ; _mulsint.c 0 + 0000 C0 83 65 push dph + 0002 C0 82 66 push dpl + 0004 90s00r02 67 mov dptr,#__mulsint_a_1_1 + 0007 D0 E0 68 pop acc + 0009 F0 69 movx @dptr,a + 000A D0 E0 70 pop acc + 000C A3 71 inc dptr + 000D F0 72 movx @dptr,a + 73 ; _mulsint.c 30 + 000E 90s00r02 74 mov dptr,#__mulsint_a_1_1 + 0011 E0 75 movx a,@dptr + 0012 FA 76 mov r2,a + 0013 A3 77 inc dptr + 0014 E0 78 movx a,@dptr + 79 ; Peephole 105 removed redundant mov + 0015 FB 80 mov r3,a + 81 ; Peephole 111 removed ljmp by inverse jump logic + 0016 30 E7 09 82 jnb acc.7,00106$ + 0019 83 00113$: + 0019 C3 84 clr c + 001A E4 85 clr a + 001B 9A 86 subb a,r2 + 001C FC 87 mov r4,a + 001D E4 88 clr a + 001E 9B 89 subb a,r3 + 001F FD 90 mov r5,a + 91 ; Peephole 132 changed ljmp to sjmp + 0020 80 04 92 sjmp 00107$ + 0022 93 00106$: + 0022 8A 04 94 mov ar4,r2 + 0024 8B 05 95 mov ar5,r3 + 0026 96 00107$: + 0026 8C 02 97 mov ar2,r4 + 0028 8D 03 98 mov ar3,r5 + 99 ; _mulsint.c 31 + 002A 90s00r00 100 mov dptr,#__mulsint_PARM_2 + 002D E0 101 movx a,@dptr + 002E FC 102 mov r4,a + 002F A3 103 inc dptr + 0030 E0 104 movx a,@dptr + 105 ; Peephole 105 removed redundant mov + 0031 FD 106 mov r5,a + 0032 33 107 rlc a + 0033 E4 108 clr a + 0034 33 109 rlc a + 110 ; Peephole 105 removed redundant mov + 0035 FE 111 mov r6,a + 112 ; Peephole 110 removed ljmp by inverse jump logic + 0036 60 09 113 jz 00108$ + 0038 114 00114$: + 0038 C3 115 clr c + 0039 E4 116 clr a + 003A 9C 117 subb a,r4 + 003B FF 118 mov r7,a + 003C E4 119 clr a + 003D 9D 120 subb a,r5 + 003E F8 121 mov r0,a + 122 ; Peephole 132 changed ljmp to sjmp + 003F 80 04 123 sjmp 00109$ + 0041 124 00108$: + 0041 8C 07 125 mov ar7,r4 + 0043 8D 00 126 mov ar0,r5 + 0045 127 00109$: + 0045 90s00r00 128 mov dptr,#__muluint_PARM_2 + 0048 EF 129 mov a,r7 + 0049 F0 130 movx @dptr,a + 004A A3 131 inc dptr + 004B E8 132 mov a,r0 + 004C F0 133 movx @dptr,a + 004D C0 06 134 push ar6 + 004F 8A 82 135 mov dpl,r2 + 0051 8B 83 136 mov dph,r3 + 0053 12s00r00 137 lcall __muluint + 0056 AA 82 138 mov r2,dpl + 0058 AB 83 139 mov r3,dph + 005A D0 06 140 pop ar6 + 141 ; _mulsint.c 33 + 005C 90s00r02 142 mov dptr,#__mulsint_a_1_1 + 005F E0 143 movx a,@dptr + 0060 FC 144 mov r4,a + 0061 A3 145 inc dptr + 0062 E0 146 movx a,@dptr + 147 ; Peephole 105 removed redundant mov + 0063 FD 148 mov r5,a + 0064 33 149 rlc a + 0065 E4 150 clr a + 0066 33 151 rlc a + 0067 FC 152 mov r4,a + 0068 EE 153 mov a,r6 + 0069 65 04 154 xrl a,ar4 + 155 ; Peephole 110 removed ljmp by inverse jump logic + 006B 60 0D 156 jz 00102$ + 006D 157 00115$: + 158 ; _mulsint.c 34 + 006D C3 159 clr c + 006E E4 160 clr a + 006F 9A 161 subb a,r2 + 0070 FC 162 mov r4,a + 0071 E4 163 clr a + 0072 9B 164 subb a,r3 + 0073 FE 165 mov r6,a + 0074 8C 82 166 mov dpl,r4 + 0076 8E 83 167 mov dph,r6 + 168 ; Peephole 132 changed ljmp to sjmp + 0078 80 04 169 sjmp 00104$ + 007A 170 00102$: + 171 ; _mulsint.c 36 + 007A 8A 82 172 mov dpl,r2 + 007C 8B 83 173 mov dph,r3 + 007E 174 00104$: + 007E 175 C$_mulsint.c$37$1$1 ==. + 007E 176 XG$_mulsint$0$0 ==. + 007E 22 177 ret + 178 .area CSEG (CODE) diff --git a/device/lib/_mulsint.sym b/device/lib/_mulsint.sym new file mode 100644 index 00000000..e3a150a7 --- /dev/null +++ b/device/lib/_mulsint.sym @@ -0,0 +1,456 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_mulsint$100 002A GR + 7 A$_mulsint$101 002D GR + 7 A$_mulsint$102 002E GR + 7 A$_mulsint$103 002F GR + 7 A$_mulsint$104 0030 GR + 7 A$_mulsint$106 0031 GR + 7 A$_mulsint$107 0032 GR + 7 A$_mulsint$108 0033 GR + 7 A$_mulsint$109 0034 GR + 7 A$_mulsint$111 0035 GR + 7 A$_mulsint$113 0036 GR + 7 A$_mulsint$115 0038 GR + 7 A$_mulsint$116 0039 GR + 7 A$_mulsint$117 003A GR + 7 A$_mulsint$118 003B GR + 7 A$_mulsint$119 003C GR + 7 A$_mulsint$120 003D GR + 7 A$_mulsint$121 003E GR + 7 A$_mulsint$123 003F GR + 7 A$_mulsint$125 0041 GR + 7 A$_mulsint$126 0043 GR + 7 A$_mulsint$128 0045 GR + 7 A$_mulsint$129 0048 GR + 7 A$_mulsint$130 0049 GR + 7 A$_mulsint$131 004A GR + 7 A$_mulsint$132 004B GR + 7 A$_mulsint$133 004C GR + 7 A$_mulsint$134 004D GR + 7 A$_mulsint$135 004F GR + 7 A$_mulsint$136 0051 GR + 7 A$_mulsint$137 0053 GR + 7 A$_mulsint$138 0056 GR + 7 A$_mulsint$139 0058 GR + 7 A$_mulsint$140 005A GR + 7 A$_mulsint$142 005C GR + 7 A$_mulsint$143 005F GR + 7 A$_mulsint$144 0060 GR + 7 A$_mulsint$145 0061 GR + 7 A$_mulsint$146 0062 GR + 7 A$_mulsint$148 0063 GR + 7 A$_mulsint$149 0064 GR + 7 A$_mulsint$150 0065 GR + 7 A$_mulsint$151 0066 GR + 7 A$_mulsint$152 0067 GR + 7 A$_mulsint$153 0068 GR + 7 A$_mulsint$154 0069 GR + 7 A$_mulsint$156 006B GR + 7 A$_mulsint$159 006D GR + 7 A$_mulsint$160 006E GR + 7 A$_mulsint$161 006F GR + 7 A$_mulsint$162 0070 GR + 7 A$_mulsint$163 0071 GR + 7 A$_mulsint$164 0072 GR + 7 A$_mulsint$165 0073 GR + 7 A$_mulsint$166 0074 GR + 7 A$_mulsint$167 0076 GR + 7 A$_mulsint$169 0078 GR + 7 A$_mulsint$172 007A GR + 7 A$_mulsint$173 007C GR + 7 A$_mulsint$177 007E GR + 7 A$_mulsint$65 0000 GR + 7 A$_mulsint$66 0002 GR + 7 A$_mulsint$67 0004 GR + 7 A$_mulsint$68 0007 GR + 7 A$_mulsint$69 0009 GR + 7 A$_mulsint$70 000A GR + 7 A$_mulsint$71 000C GR + 7 A$_mulsint$72 000D GR + 7 A$_mulsint$74 000E GR + 7 A$_mulsint$75 0011 GR + 7 A$_mulsint$76 0012 GR + 7 A$_mulsint$77 0013 GR + 7 A$_mulsint$78 0014 GR + 7 A$_mulsint$80 0015 GR + 7 A$_mulsint$82 0016 GR + 7 A$_mulsint$84 0019 GR + 7 A$_mulsint$85 001A GR + 7 A$_mulsint$86 001B GR + 7 A$_mulsint$87 001C GR + 7 A$_mulsint$88 001D GR + 7 A$_mulsint$89 001E GR + 7 A$_mulsint$90 001F GR + 7 A$_mulsint$92 0020 GR + 7 A$_mulsint$94 0022 GR + 7 A$_mulsint$95 0024 GR + 7 A$_mulsint$97 0026 GR + 7 A$_mulsint$98 0028 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_mulsint.c$37$1$1 = 007E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_mulsint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_mulsint$0$0 = 007E GR + 7 __mulsint 0000 GR + 5 __mulsint_PARM_2 0000 GR + 5 __mulsint_a_1_1 0002 R + __muluint **** GX + __muluint_PARM_2 **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 4 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 7F flags 20 diff --git a/device/lib/_muluint.c b/device/lib/_muluint.c new file mode 100644 index 00000000..143183e6 --- /dev/null +++ b/device/lib/_muluint.c @@ -0,0 +1,52 @@ +/*------------------------------------------------------------------------- + + _muluint.c :- routine for unsigned int (16 bit) multiplication + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +union uu { + struct { unsigned short lo,hi ;} s; + unsigned int t; +} ; + + +unsigned int _muluint (unsigned int a, unsigned int b) +{ +#ifdef SDCC_MODEL_LARGE + union uu _xdata *x; + union uu _xdata *y; + union uu t; + x = (union uu _xdata *)&a; + y = (union uu _xdata *)&b; +#else + register union uu _near *x; + register union uu _near *y; + union uu t; + x = (union uu _near *)&a; + y = (union uu _near *)&b; +#endif + + t.t = x->s.lo * y->s.lo; + t.s.hi += (x->s.lo * y->s.hi) + (x->s.hi * y->s.lo); + + return t.t; +} diff --git a/device/lib/_muluint.lst b/device/lib/_muluint.lst new file mode 100644 index 00000000..3eafd155 --- /dev/null +++ b/device/lib/_muluint.lst @@ -0,0 +1,133 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _muluint + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __muluint_PARM_2 + 11 .globl __muluint + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 __muluint_PARM_2: + 0000 39 .ds 0x0002 + 0002 40 __muluint_a_1_1: + 0002 41 .ds 0x0002 + 0004 42 __muluint_t_1_1: + 0004 43 .ds 0x0002 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$_muluint$0$0 ==. + 53 ; _muluint.c 32 + 54 ; ----------------------------------------- + 55 ; function _muluint + 56 ; ----------------------------------------- + 0000 57 __muluint: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _muluint.c 51 + 0000 C0 83 67 push dph + 0002 C0 82 68 push dpl + 0004 90s00r02 69 mov dptr,#__muluint_a_1_1 + 0007 D0 E0 70 pop acc + 0009 F0 71 movx @dptr,a + 000A D0 E0 72 pop acc + 000C A3 73 inc dptr + 000D F0 74 movx @dptr,a + 75 ; _muluint.c 38 + 76 ; _muluint.c 39 + 77 ; _muluint.c 48 + 000E 90s00r02 78 mov dptr,#(__muluint_a_1_1) + 0011 E0 79 movx a,@dptr + 0012 FA 80 mov r2,a + 0013 90s00r00 81 mov dptr,#(__muluint_PARM_2) + 0016 E0 82 movx a,@dptr + 0017 FB 83 mov r3,a + 0018 8B F0 84 mov b,r3 + 001A EA 85 mov a,r2 + 001B A4 86 mul ab + 001C FC 87 mov r4,a + 001D AD F0 88 mov r5,b + 001F 90s00r04 89 mov dptr,#(__muluint_t_1_1) + 0022 EC 90 mov a,r4 + 0023 F0 91 movx @dptr,a + 0024 A3 92 inc dptr + 0025 ED 93 mov a,r5 + 0026 F0 94 movx @dptr,a + 95 ; _muluint.c 49 + 0027 90s00r05 96 mov dptr,#(0x0001 + __muluint_t_1_1) + 002A E0 97 movx a,@dptr + 002B FC 98 mov r4,a + 002C 90s00r01 99 mov dptr,#(0x0001 + __muluint_PARM_2) + 002F E0 100 movx a,@dptr + 0030 FD 101 mov r5,a + 0031 8D F0 102 mov b,r5 + 0033 EA 103 mov a,r2 + 0034 A4 104 mul ab + 0035 FA 105 mov r2,a + 0036 90s00r03 106 mov dptr,#(0x0001 + __muluint_a_1_1) + 0039 E0 107 movx a,@dptr + 003A FD 108 mov r5,a + 003B 8B F0 109 mov b,r3 + 003D ED 110 mov a,r5 + 003E A4 111 mul ab + 112 ; Peephole 105 removed redundant mov + 003F FB 113 mov r3,a + 0040 2A 114 add a,r2 + 0041 2C 115 add a,r4 + 116 ; Peephole 100 removed redundant mov + 0042 FC 117 mov r4,a + 0043 90s00r05 118 mov dptr,#(0x0001 + __muluint_t_1_1) + 0046 F0 119 movx @dptr,a + 120 ; _muluint.c 51 + 0047 90s00r04 121 mov dptr,#(__muluint_t_1_1) + 004A E0 122 movx a,@dptr + 004B FA 123 mov r2,a + 004C A3 124 inc dptr + 004D E0 125 movx a,@dptr + 004E FB 126 mov r3,a + 004F 8A 82 127 mov dpl,r2 + 0051 8B 83 128 mov dph,r3 + 0053 129 00101$: + 0053 130 C$_muluint.c$52$1$1 ==. + 0053 131 XG$_muluint$0$0 ==. + 0053 22 132 ret + 133 .area CSEG (CODE) diff --git a/device/lib/_muluint.sym b/device/lib/_muluint.sym new file mode 100644 index 00000000..4784fad1 --- /dev/null +++ b/device/lib/_muluint.sym @@ -0,0 +1,424 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_muluint$100 002F GR + 7 A$_muluint$101 0030 GR + 7 A$_muluint$102 0031 GR + 7 A$_muluint$103 0033 GR + 7 A$_muluint$104 0034 GR + 7 A$_muluint$105 0035 GR + 7 A$_muluint$106 0036 GR + 7 A$_muluint$107 0039 GR + 7 A$_muluint$108 003A GR + 7 A$_muluint$109 003B GR + 7 A$_muluint$110 003D GR + 7 A$_muluint$111 003E GR + 7 A$_muluint$113 003F GR + 7 A$_muluint$114 0040 GR + 7 A$_muluint$115 0041 GR + 7 A$_muluint$117 0042 GR + 7 A$_muluint$118 0043 GR + 7 A$_muluint$119 0046 GR + 7 A$_muluint$121 0047 GR + 7 A$_muluint$122 004A GR + 7 A$_muluint$123 004B GR + 7 A$_muluint$124 004C GR + 7 A$_muluint$125 004D GR + 7 A$_muluint$126 004E GR + 7 A$_muluint$127 004F GR + 7 A$_muluint$128 0051 GR + 7 A$_muluint$132 0053 GR + 7 A$_muluint$67 0000 GR + 7 A$_muluint$68 0002 GR + 7 A$_muluint$69 0004 GR + 7 A$_muluint$70 0007 GR + 7 A$_muluint$71 0009 GR + 7 A$_muluint$72 000A GR + 7 A$_muluint$73 000C GR + 7 A$_muluint$74 000D GR + 7 A$_muluint$78 000E GR + 7 A$_muluint$79 0011 GR + 7 A$_muluint$80 0012 GR + 7 A$_muluint$81 0013 GR + 7 A$_muluint$82 0016 GR + 7 A$_muluint$83 0017 GR + 7 A$_muluint$84 0018 GR + 7 A$_muluint$85 001A GR + 7 A$_muluint$86 001B GR + 7 A$_muluint$87 001C GR + 7 A$_muluint$88 001D GR + 7 A$_muluint$89 001F GR + 7 A$_muluint$90 0022 GR + 7 A$_muluint$91 0023 GR + 7 A$_muluint$92 0024 GR + 7 A$_muluint$93 0025 GR + 7 A$_muluint$94 0026 GR + 7 A$_muluint$96 0027 GR + 7 A$_muluint$97 002A GR + 7 A$_muluint$98 002B GR + 7 A$_muluint$99 002C GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_muluint.c$52$1$1 = 0053 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_muluint$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_muluint$0$0 = 0053 GR + 7 __muluint 0000 GR + 5 __muluint_PARM_2 0000 GR + 5 __muluint_a_1_1 0002 R + 5 __muluint_t_1_1 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 6 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 54 flags 20 diff --git a/device/lib/_mululong.c b/device/lib/_mululong.c new file mode 100644 index 00000000..56820874 --- /dev/null +++ b/device/lib/_mululong.c @@ -0,0 +1,87 @@ +/*------------------------------------------------------------------------- + _mululong.c - routine for multiplication of 32 bit unsigned long + + Written By - Jean Louis VERN jlvern@writeme.com (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +struct some_struct { + int a ; + char b; + long c ;}; +union bil { + struct {unsigned char b0,b1,b2,b3 ;} b; + struct {unsigned int lo,hi ;} i; + unsigned long l; + struct { unsigned char b0; unsigned int i12; unsigned char b3;} bi; +} ; +#ifdef SDCC_MODEL_LARGE +#define bcast(x) ((union bil _xdata *)&(x)) +#else +#define bcast(x) ((union bil _near *)&(x)) +#endif + +/* + 3 2 1 0 + X 3 2 1 0 + ---------------------------- + 0.3 0.2 0.1 0.0 + 1.3 1.2 1.1 1.0 + 2.3 2.2 2.1 2.0 + 3.3 3.2 3.1 3.0 + ---------------------------- + |3.3|1.3|0.2|0.0| A + |2.3|0.3|0.1| B + |3.2|1.2|1.0| C + |2.2|1.1| D + |3.1|2.0| E + |2.1| F + |3.0| G + |-------> only this side 32 x 32 -> 32 +*/ +unsigned long _mululong (unsigned long a, unsigned long b) +{ + union bil t; + + t.i.hi = bcast(a)->b.b0 * bcast(b)->b.b2; // A + t.i.lo = bcast(a)->b.b0 * bcast(b)->b.b0; // A + t.b.b3 += (unsigned char)(bcast(a)->b.b3 * + bcast(b)->b.b0); // G + t.b.b3 += (unsigned char)(bcast(a)->b.b2 * + bcast(b)->b.b1); // F + t.i.hi += (unsigned int)(bcast(a)->b.b2 * bcast(b)->b.b0); // E <- b lost in .lst + // bcast(a)->i.hi is free ! + t.i.hi += (unsigned int)(bcast(a)->b.b1 * bcast(b)->b.b1); // D <- b lost in .lst + + bcast(a)->bi.b3 = (unsigned char)(bcast(a)->b.b1 * + bcast(b)->b.b2); + bcast(a)->bi.i12 = bcast(a)->b.b1 * + bcast(b)->b.b0; // C + + bcast(b)->bi.b3 = (unsigned char)(bcast(a)->b.b0 * + bcast(b)->b.b3); + bcast(b)->bi.i12 = bcast(a)->b.b0 * + bcast(b)->b.b1; // B + bcast(b)->bi.b0 = 0; // B + bcast(a)->bi.b0 = 0; // C + t.l += a; + + return t.l + b; +} diff --git a/device/lib/_mululong.lst b/device/lib/_mululong.lst new file mode 100644 index 00000000..6c6806be --- /dev/null +++ b/device/lib/_mululong.lst @@ -0,0 +1,362 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _mululong + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __mululong_PARM_2 + 11 .globl __mululong + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 __mululong_PARM_2: + 0000 39 .ds 0x0004 + 0004 40 __mululong_a_1_1: + 0004 41 .ds 0x0004 + 0008 42 __mululong_t_1_1: + 0008 43 .ds 0x0004 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$_mululong$0$0 ==. + 53 ; _mululong.c 59 + 54 ; ----------------------------------------- + 55 ; function _mululong + 56 ; ----------------------------------------- + 0000 57 __mululong: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _mululong.c 86 + 0000 C0 E0 67 push acc + 0002 C0 F0 68 push b + 0004 C0 83 69 push dph + 0006 C0 82 70 push dpl + 0008 90s00r04 71 mov dptr,#__mululong_a_1_1 + 000B D0 E0 72 pop acc + 000D F0 73 movx @dptr,a + 000E D0 E0 74 pop acc + 0010 A3 75 inc dptr + 0011 F0 76 movx @dptr,a + 0012 D0 E0 77 pop acc + 0014 A3 78 inc dptr + 0015 F0 79 movx @dptr,a + 0016 D0 E0 80 pop acc + 0018 A3 81 inc dptr + 0019 F0 82 movx @dptr,a + 83 ; _mululong.c 63 + 001A 90s00r04 84 mov dptr,#(__mululong_a_1_1) + 001D E0 85 movx a,@dptr + 001E FA 86 mov r2,a + 001F 90s00r02 87 mov dptr,#(0x0002 + __mululong_PARM_2) + 0022 E0 88 movx a,@dptr + 0023 FB 89 mov r3,a + 0024 8B F0 90 mov b,r3 + 0026 EA 91 mov a,r2 + 0027 A4 92 mul ab + 0028 FB 93 mov r3,a + 0029 AC F0 94 mov r4,b + 002B 90s00r0A 95 mov dptr,#(0x0002 + __mululong_t_1_1) + 002E EB 96 mov a,r3 + 002F F0 97 movx @dptr,a + 0030 A3 98 inc dptr + 0031 EC 99 mov a,r4 + 0032 F0 100 movx @dptr,a + 101 ; _mululong.c 64 + 0033 90s00r00 102 mov dptr,#(__mululong_PARM_2) + 0036 E0 103 movx a,@dptr + 0037 FB 104 mov r3,a + 0038 8B F0 105 mov b,r3 + 003A EA 106 mov a,r2 + 003B A4 107 mul ab + 003C FC 108 mov r4,a + 003D AD F0 109 mov r5,b + 003F 90s00r08 110 mov dptr,#(__mululong_t_1_1) + 0042 EC 111 mov a,r4 + 0043 F0 112 movx @dptr,a + 0044 A3 113 inc dptr + 0045 ED 114 mov a,r5 + 0046 F0 115 movx @dptr,a + 116 ; _mululong.c 65 + 0047 90s00r0B 117 mov dptr,#(0x0003 + __mululong_t_1_1) + 004A E0 118 movx a,@dptr + 004B FC 119 mov r4,a + 004C 90s00r07 120 mov dptr,#(0x0003 + __mululong_a_1_1) + 004F E0 121 movx a,@dptr + 0050 FD 122 mov r5,a + 123 ; _mululong.c 66 + 0051 8B F0 124 mov b,r3 + 0053 ED 125 mov a,r5 + 0054 A4 126 mul ab + 127 ; Peephole 105 removed redundant mov + 0055 FD 128 mov r5,a + 0056 2C 129 add a,r4 + 130 ; Peephole 100 removed redundant mov + 0057 FC 131 mov r4,a + 0058 90s00r0B 132 mov dptr,#(0x0003 + __mululong_t_1_1) + 005B F0 133 movx @dptr,a + 134 ; _mululong.c 67 + 005C 90s00r0B 135 mov dptr,#(0x0003 + __mululong_t_1_1) + 005F E0 136 movx a,@dptr + 0060 FC 137 mov r4,a + 0061 90s00r06 138 mov dptr,#(0x0002 + __mululong_a_1_1) + 0064 E0 139 movx a,@dptr + 0065 FD 140 mov r5,a + 141 ; _mululong.c 68 + 0066 90s00r01 142 mov dptr,#(0x0001 + __mululong_PARM_2) + 0069 E0 143 movx a,@dptr + 006A FE 144 mov r6,a + 006B 8E F0 145 mov b,r6 + 006D ED 146 mov a,r5 + 006E A4 147 mul ab + 148 ; Peephole 105 removed redundant mov + 006F FD 149 mov r5,a + 0070 2C 150 add a,r4 + 151 ; Peephole 100 removed redundant mov + 0071 FC 152 mov r4,a + 0072 90s00r0B 153 mov dptr,#(0x0003 + __mululong_t_1_1) + 0075 F0 154 movx @dptr,a + 155 ; _mululong.c 69 + 0076 90s00r0A 156 mov dptr,#(0x0002 + __mululong_t_1_1) + 0079 E0 157 movx a,@dptr + 007A FC 158 mov r4,a + 007B A3 159 inc dptr + 007C E0 160 movx a,@dptr + 007D FD 161 mov r5,a + 007E 90s00r06 162 mov dptr,#(0x0002 + __mululong_a_1_1) + 0081 E0 163 movx a,@dptr + 0082 FE 164 mov r6,a + 0083 8B F0 165 mov b,r3 + 0085 EE 166 mov a,r6 + 0086 A4 167 mul ab + 0087 FE 168 mov r6,a + 0088 AF F0 169 mov r7,b + 008A EE 170 mov a,r6 + 008B 2C 171 add a,r4 + 008C FC 172 mov r4,a + 008D EF 173 mov a,r7 + 008E 3D 174 addc a,r5 + 008F FD 175 mov r5,a + 0090 90s00r0A 176 mov dptr,#(0x0002 + __mululong_t_1_1) + 0093 EC 177 mov a,r4 + 0094 F0 178 movx @dptr,a + 0095 A3 179 inc dptr + 0096 ED 180 mov a,r5 + 0097 F0 181 movx @dptr,a + 182 ; _mululong.c 71 + 0098 90s00r0A 183 mov dptr,#(0x0002 + __mululong_t_1_1) + 009B E0 184 movx a,@dptr + 009C FC 185 mov r4,a + 009D A3 186 inc dptr + 009E E0 187 movx a,@dptr + 009F FD 188 mov r5,a + 00A0 90s00r05 189 mov dptr,#(0x0001 + __mululong_a_1_1) + 00A3 E0 190 movx a,@dptr + 00A4 FE 191 mov r6,a + 00A5 90s00r01 192 mov dptr,#(0x0001 + __mululong_PARM_2) + 00A8 E0 193 movx a,@dptr + 00A9 FF 194 mov r7,a + 00AA 8F F0 195 mov b,r7 + 00AC EE 196 mov a,r6 + 00AD A4 197 mul ab + 00AE FF 198 mov r7,a + 00AF AE F0 199 mov r6,b + 00B1 EF 200 mov a,r7 + 00B2 2C 201 add a,r4 + 00B3 FC 202 mov r4,a + 00B4 EE 203 mov a,r6 + 00B5 3D 204 addc a,r5 + 00B6 FD 205 mov r5,a + 00B7 90s00r0A 206 mov dptr,#(0x0002 + __mululong_t_1_1) + 00BA EC 207 mov a,r4 + 00BB F0 208 movx @dptr,a + 00BC A3 209 inc dptr + 00BD ED 210 mov a,r5 + 00BE F0 211 movx @dptr,a + 212 ; _mululong.c 73 + 00BF 90s00r05 213 mov dptr,#(0x0001 + __mululong_a_1_1) + 00C2 E0 214 movx a,@dptr + 00C3 FC 215 mov r4,a + 216 ; _mululong.c 74 + 00C4 90s00r02 217 mov dptr,#(0x0002 + __mululong_PARM_2) + 00C7 E0 218 movx a,@dptr + 00C8 FD 219 mov r5,a + 00C9 8D F0 220 mov b,r5 + 00CB EC 221 mov a,r4 + 00CC A4 222 mul ab + 223 ; Peephole 100 removed redundant mov + 00CD FC 224 mov r4,a + 00CE 90s00r07 225 mov dptr,#(0x0003 + __mululong_a_1_1) + 00D1 F0 226 movx @dptr,a + 227 ; _mululong.c 75 + 00D2 90s00r05 228 mov dptr,#(0x0001 + __mululong_a_1_1) + 00D5 E0 229 movx a,@dptr + 00D6 FC 230 mov r4,a + 231 ; _mululong.c 76 + 00D7 8B F0 232 mov b,r3 + 00D9 EC 233 mov a,r4 + 00DA A4 234 mul ab + 00DB FB 235 mov r3,a + 00DC AD F0 236 mov r5,b + 00DE 90s00r05 237 mov dptr,#(0x0001 + __mululong_a_1_1) + 00E1 EB 238 mov a,r3 + 00E2 F0 239 movx @dptr,a + 00E3 A3 240 inc dptr + 00E4 ED 241 mov a,r5 + 00E5 F0 242 movx @dptr,a + 243 ; _mululong.c 78 + 244 ; _mululong.c 79 + 00E6 90s00r03 245 mov dptr,#(0x0003 + __mululong_PARM_2) + 00E9 E0 246 movx a,@dptr + 00EA FB 247 mov r3,a + 00EB 8B F0 248 mov b,r3 + 00ED EA 249 mov a,r2 + 00EE A4 250 mul ab + 251 ; Peephole 100 removed redundant mov + 00EF FB 252 mov r3,a + 00F0 90s00r03 253 mov dptr,#(0x0003 + __mululong_PARM_2) + 00F3 F0 254 movx @dptr,a + 255 ; _mululong.c 81 + 00F4 90s00r01 256 mov dptr,#(0x0001 + __mululong_PARM_2) + 00F7 E0 257 movx a,@dptr + 00F8 FB 258 mov r3,a + 00F9 8B F0 259 mov b,r3 + 00FB EA 260 mov a,r2 + 00FC A4 261 mul ab + 00FD FA 262 mov r2,a + 00FE AC F0 263 mov r4,b + 0100 90s00r01 264 mov dptr,#(0x0001 + __mululong_PARM_2) + 0103 EA 265 mov a,r2 + 0104 F0 266 movx @dptr,a + 0105 A3 267 inc dptr + 0106 EC 268 mov a,r4 + 0107 F0 269 movx @dptr,a + 270 ; _mululong.c 82 + 0108 90s00r00 271 mov dptr,#(__mululong_PARM_2) + 272 ; Peephole 180 changed mov to clr + 010B E4 273 clr a + 010C F0 274 movx @dptr,a + 275 ; _mululong.c 83 + 010D 90s00r04 276 mov dptr,#(__mululong_a_1_1) + 277 ; Peephole 180 changed mov to clr + 0110 E4 278 clr a + 0111 F0 279 movx @dptr,a + 280 ; _mululong.c 84 + 0112 90s00r08 281 mov dptr,#(__mululong_t_1_1) + 0115 E0 282 movx a,@dptr + 0116 FA 283 mov r2,a + 0117 A3 284 inc dptr + 0118 E0 285 movx a,@dptr + 0119 FB 286 mov r3,a + 011A A3 287 inc dptr + 011B E0 288 movx a,@dptr + 011C FC 289 mov r4,a + 011D A3 290 inc dptr + 011E E0 291 movx a,@dptr + 011F FD 292 mov r5,a + 0120 90s00r04 293 mov dptr,#__mululong_a_1_1 + 0123 E0 294 movx a,@dptr + 0124 FE 295 mov r6,a + 0125 A3 296 inc dptr + 0126 E0 297 movx a,@dptr + 0127 FF 298 mov r7,a + 0128 A3 299 inc dptr + 0129 E0 300 movx a,@dptr + 012A F8 301 mov r0,a + 012B A3 302 inc dptr + 012C E0 303 movx a,@dptr + 012D F9 304 mov r1,a + 012E EE 305 mov a,r6 + 012F 2A 306 add a,r2 + 0130 FA 307 mov r2,a + 0131 EF 308 mov a,r7 + 0132 3B 309 addc a,r3 + 0133 FB 310 mov r3,a + 0134 E8 311 mov a,r0 + 0135 3C 312 addc a,r4 + 0136 FC 313 mov r4,a + 0137 E9 314 mov a,r1 + 0138 3D 315 addc a,r5 + 0139 FD 316 mov r5,a + 013A 90s00r08 317 mov dptr,#(__mululong_t_1_1) + 013D EA 318 mov a,r2 + 013E F0 319 movx @dptr,a + 013F A3 320 inc dptr + 0140 EB 321 mov a,r3 + 0141 F0 322 movx @dptr,a + 0142 A3 323 inc dptr + 0143 EC 324 mov a,r4 + 0144 F0 325 movx @dptr,a + 0145 A3 326 inc dptr + 0146 ED 327 mov a,r5 + 0147 F0 328 movx @dptr,a + 329 ; _mululong.c 86 + 0148 90s00r00 330 mov dptr,#__mululong_PARM_2 + 014B E0 331 movx a,@dptr + 014C FE 332 mov r6,a + 014D A3 333 inc dptr + 014E E0 334 movx a,@dptr + 014F FF 335 mov r7,a + 0150 A3 336 inc dptr + 0151 E0 337 movx a,@dptr + 0152 F8 338 mov r0,a + 0153 A3 339 inc dptr + 0154 E0 340 movx a,@dptr + 0155 F9 341 mov r1,a + 0156 EE 342 mov a,r6 + 0157 2A 343 add a,r2 + 0158 FA 344 mov r2,a + 0159 EF 345 mov a,r7 + 015A 3B 346 addc a,r3 + 015B FB 347 mov r3,a + 015C E8 348 mov a,r0 + 015D 3C 349 addc a,r4 + 015E FC 350 mov r4,a + 015F E9 351 mov a,r1 + 0160 3D 352 addc a,r5 + 353 ; Peephole 191 removed redundant mov + 0161 FD 354 mov r5,a + 0162 8A 82 355 mov dpl,r2 + 0164 8B 83 356 mov dph,r3 + 0166 8C F0 357 mov b,r4 + 0168 358 00101$: + 0168 359 C$_mululong.c$87$1$1 ==. + 0168 360 XG$_mululong$0$0 ==. + 0168 22 361 ret + 362 .area CSEG (CODE) diff --git a/device/lib/_mululong.sym b/device/lib/_mululong.sym new file mode 100644 index 00000000..e2ba72bc --- /dev/null +++ b/device/lib/_mululong.sym @@ -0,0 +1,632 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_mululong$100 0032 GR + 7 A$_mululong$102 0033 GR + 7 A$_mululong$103 0036 GR + 7 A$_mululong$104 0037 GR + 7 A$_mululong$105 0038 GR + 7 A$_mululong$106 003A GR + 7 A$_mululong$107 003B GR + 7 A$_mululong$108 003C GR + 7 A$_mululong$109 003D GR + 7 A$_mululong$110 003F GR + 7 A$_mululong$111 0042 GR + 7 A$_mululong$112 0043 GR + 7 A$_mululong$113 0044 GR + 7 A$_mululong$114 0045 GR + 7 A$_mululong$115 0046 GR + 7 A$_mululong$117 0047 GR + 7 A$_mululong$118 004A GR + 7 A$_mululong$119 004B GR + 7 A$_mululong$120 004C GR + 7 A$_mululong$121 004F GR + 7 A$_mululong$122 0050 GR + 7 A$_mululong$124 0051 GR + 7 A$_mululong$125 0053 GR + 7 A$_mululong$126 0054 GR + 7 A$_mululong$128 0055 GR + 7 A$_mululong$129 0056 GR + 7 A$_mululong$131 0057 GR + 7 A$_mululong$132 0058 GR + 7 A$_mululong$133 005B GR + 7 A$_mululong$135 005C GR + 7 A$_mululong$136 005F GR + 7 A$_mululong$137 0060 GR + 7 A$_mululong$138 0061 GR + 7 A$_mululong$139 0064 GR + 7 A$_mululong$140 0065 GR + 7 A$_mululong$142 0066 GR + 7 A$_mululong$143 0069 GR + 7 A$_mululong$144 006A GR + 7 A$_mululong$145 006B GR + 7 A$_mululong$146 006D GR + 7 A$_mululong$147 006E GR + 7 A$_mululong$149 006F GR + 7 A$_mululong$150 0070 GR + 7 A$_mululong$152 0071 GR + 7 A$_mululong$153 0072 GR + 7 A$_mululong$154 0075 GR + 7 A$_mululong$156 0076 GR + 7 A$_mululong$157 0079 GR + 7 A$_mululong$158 007A GR + 7 A$_mululong$159 007B GR + 7 A$_mululong$160 007C GR + 7 A$_mululong$161 007D GR + 7 A$_mululong$162 007E GR + 7 A$_mululong$163 0081 GR + 7 A$_mululong$164 0082 GR + 7 A$_mululong$165 0083 GR + 7 A$_mululong$166 0085 GR + 7 A$_mululong$167 0086 GR + 7 A$_mululong$168 0087 GR + 7 A$_mululong$169 0088 GR + 7 A$_mululong$170 008A GR + 7 A$_mululong$171 008B GR + 7 A$_mululong$172 008C GR + 7 A$_mululong$173 008D GR + 7 A$_mululong$174 008E GR + 7 A$_mululong$175 008F GR + 7 A$_mululong$176 0090 GR + 7 A$_mululong$177 0093 GR + 7 A$_mululong$178 0094 GR + 7 A$_mululong$179 0095 GR + 7 A$_mululong$180 0096 GR + 7 A$_mululong$181 0097 GR + 7 A$_mululong$183 0098 GR + 7 A$_mululong$184 009B GR + 7 A$_mululong$185 009C GR + 7 A$_mululong$186 009D GR + 7 A$_mululong$187 009E GR + 7 A$_mululong$188 009F GR + 7 A$_mululong$189 00A0 GR + 7 A$_mululong$190 00A3 GR + 7 A$_mululong$191 00A4 GR + 7 A$_mululong$192 00A5 GR + 7 A$_mululong$193 00A8 GR + 7 A$_mululong$194 00A9 GR + 7 A$_mululong$195 00AA GR + 7 A$_mululong$196 00AC GR + 7 A$_mululong$197 00AD GR + 7 A$_mululong$198 00AE GR + 7 A$_mululong$199 00AF GR + 7 A$_mululong$200 00B1 GR + 7 A$_mululong$201 00B2 GR + 7 A$_mululong$202 00B3 GR + 7 A$_mululong$203 00B4 GR + 7 A$_mululong$204 00B5 GR + 7 A$_mululong$205 00B6 GR + 7 A$_mululong$206 00B7 GR + 7 A$_mululong$207 00BA GR + 7 A$_mululong$208 00BB GR + 7 A$_mululong$209 00BC GR + 7 A$_mululong$210 00BD GR + 7 A$_mululong$211 00BE GR + 7 A$_mululong$213 00BF GR + 7 A$_mululong$214 00C2 GR + 7 A$_mululong$215 00C3 GR + 7 A$_mululong$217 00C4 GR + 7 A$_mululong$218 00C7 GR + 7 A$_mululong$219 00C8 GR + 7 A$_mululong$220 00C9 GR + 7 A$_mululong$221 00CB GR + 7 A$_mululong$222 00CC GR + 7 A$_mululong$224 00CD GR + 7 A$_mululong$225 00CE GR + 7 A$_mululong$226 00D1 GR + 7 A$_mululong$228 00D2 GR + 7 A$_mululong$229 00D5 GR + 7 A$_mululong$230 00D6 GR + 7 A$_mululong$232 00D7 GR + 7 A$_mululong$233 00D9 GR + 7 A$_mululong$234 00DA GR + 7 A$_mululong$235 00DB GR + 7 A$_mululong$236 00DC GR + 7 A$_mululong$237 00DE GR + 7 A$_mululong$238 00E1 GR + 7 A$_mululong$239 00E2 GR + 7 A$_mululong$240 00E3 GR + 7 A$_mululong$241 00E4 GR + 7 A$_mululong$242 00E5 GR + 7 A$_mululong$245 00E6 GR + 7 A$_mululong$246 00E9 GR + 7 A$_mululong$247 00EA GR + 7 A$_mululong$248 00EB GR + 7 A$_mululong$249 00ED GR + 7 A$_mululong$250 00EE GR + 7 A$_mululong$252 00EF GR + 7 A$_mululong$253 00F0 GR + 7 A$_mululong$254 00F3 GR + 7 A$_mululong$256 00F4 GR + 7 A$_mululong$257 00F7 GR + 7 A$_mululong$258 00F8 GR + 7 A$_mululong$259 00F9 GR + 7 A$_mululong$260 00FB GR + 7 A$_mululong$261 00FC GR + 7 A$_mululong$262 00FD GR + 7 A$_mululong$263 00FE GR + 7 A$_mululong$264 0100 GR + 7 A$_mululong$265 0103 GR + 7 A$_mululong$266 0104 GR + 7 A$_mululong$267 0105 GR + 7 A$_mululong$268 0106 GR + 7 A$_mululong$269 0107 GR + 7 A$_mululong$271 0108 GR + 7 A$_mululong$273 010B GR + 7 A$_mululong$274 010C GR + 7 A$_mululong$276 010D GR + 7 A$_mululong$278 0110 GR + 7 A$_mululong$279 0111 GR + 7 A$_mululong$281 0112 GR + 7 A$_mululong$282 0115 GR + 7 A$_mululong$283 0116 GR + 7 A$_mululong$284 0117 GR + 7 A$_mululong$285 0118 GR + 7 A$_mululong$286 0119 GR + 7 A$_mululong$287 011A GR + 7 A$_mululong$288 011B GR + 7 A$_mululong$289 011C GR + 7 A$_mululong$290 011D GR + 7 A$_mululong$291 011E GR + 7 A$_mululong$292 011F GR + 7 A$_mululong$293 0120 GR + 7 A$_mululong$294 0123 GR + 7 A$_mululong$295 0124 GR + 7 A$_mululong$296 0125 GR + 7 A$_mululong$297 0126 GR + 7 A$_mululong$298 0127 GR + 7 A$_mululong$299 0128 GR + 7 A$_mululong$300 0129 GR + 7 A$_mululong$301 012A GR + 7 A$_mululong$302 012B GR + 7 A$_mululong$303 012C GR + 7 A$_mululong$304 012D GR + 7 A$_mululong$305 012E GR + 7 A$_mululong$306 012F GR + 7 A$_mululong$307 0130 GR + 7 A$_mululong$308 0131 GR + 7 A$_mululong$309 0132 GR + 7 A$_mululong$310 0133 GR + 7 A$_mululong$311 0134 GR + 7 A$_mululong$312 0135 GR + 7 A$_mululong$313 0136 GR + 7 A$_mululong$314 0137 GR + 7 A$_mululong$315 0138 GR + 7 A$_mululong$316 0139 GR + 7 A$_mululong$317 013A GR + 7 A$_mululong$318 013D GR + 7 A$_mululong$319 013E GR + 7 A$_mululong$320 013F GR + 7 A$_mululong$321 0140 GR + 7 A$_mululong$322 0141 GR + 7 A$_mululong$323 0142 GR + 7 A$_mululong$324 0143 GR + 7 A$_mululong$325 0144 GR + 7 A$_mululong$326 0145 GR + 7 A$_mululong$327 0146 GR + 7 A$_mululong$328 0147 GR + 7 A$_mululong$330 0148 GR + 7 A$_mululong$331 014B GR + 7 A$_mululong$332 014C GR + 7 A$_mululong$333 014D GR + 7 A$_mululong$334 014E GR + 7 A$_mululong$335 014F GR + 7 A$_mululong$336 0150 GR + 7 A$_mululong$337 0151 GR + 7 A$_mululong$338 0152 GR + 7 A$_mululong$339 0153 GR + 7 A$_mululong$340 0154 GR + 7 A$_mululong$341 0155 GR + 7 A$_mululong$342 0156 GR + 7 A$_mululong$343 0157 GR + 7 A$_mululong$344 0158 GR + 7 A$_mululong$345 0159 GR + 7 A$_mululong$346 015A GR + 7 A$_mululong$347 015B GR + 7 A$_mululong$348 015C GR + 7 A$_mululong$349 015D GR + 7 A$_mululong$350 015E GR + 7 A$_mululong$351 015F GR + 7 A$_mululong$352 0160 GR + 7 A$_mululong$354 0161 GR + 7 A$_mululong$355 0162 GR + 7 A$_mululong$356 0164 GR + 7 A$_mululong$357 0166 GR + 7 A$_mululong$361 0168 GR + 7 A$_mululong$67 0000 GR + 7 A$_mululong$68 0002 GR + 7 A$_mululong$69 0004 GR + 7 A$_mululong$70 0006 GR + 7 A$_mululong$71 0008 GR + 7 A$_mululong$72 000B GR + 7 A$_mululong$73 000D GR + 7 A$_mululong$74 000E GR + 7 A$_mululong$75 0010 GR + 7 A$_mululong$76 0011 GR + 7 A$_mululong$77 0012 GR + 7 A$_mululong$78 0014 GR + 7 A$_mululong$79 0015 GR + 7 A$_mululong$80 0016 GR + 7 A$_mululong$81 0018 GR + 7 A$_mululong$82 0019 GR + 7 A$_mululong$84 001A GR + 7 A$_mululong$85 001D GR + 7 A$_mululong$86 001E GR + 7 A$_mululong$87 001F GR + 7 A$_mululong$88 0022 GR + 7 A$_mululong$89 0023 GR + 7 A$_mululong$90 0024 GR + 7 A$_mululong$91 0026 GR + 7 A$_mululong$92 0027 GR + 7 A$_mululong$93 0028 GR + 7 A$_mululong$94 0029 GR + 7 A$_mululong$95 002B GR + 7 A$_mululong$96 002E GR + 7 A$_mululong$97 002F GR + 7 A$_mululong$98 0030 GR + 7 A$_mululong$99 0031 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_mululong.c$87$1$1 = 0168 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_mululong$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_mululong$0$0 = 0168 GR + 7 __mululong 0000 GR + 5 __mululong_PARM_2 0000 GR + 5 __mululong_a_1_1 0004 R + 5 __mululong_t_1_1 0008 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size C flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 169 flags 20 diff --git a/device/lib/_muslong.c b/device/lib/_muslong.c new file mode 100644 index 00000000..d135fd43 --- /dev/null +++ b/device/lib/_muslong.c @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + _mulslong.c - routine for multiplication of 32 bit signed long + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +long _mulslong (long a, long b) +{ + long r; + + r = _mululong ( ((a < 0) ? -a : a), + ((b < 0) ? -b : b) ); + + if ( (a < 0) ^ (b < 0)) + return -r; + else + return r; +} diff --git a/device/lib/_muslong.lst b/device/lib/_muslong.lst new file mode 100644 index 00000000..5603431c --- /dev/null +++ b/device/lib/_muslong.lst @@ -0,0 +1,254 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _muslong + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __mulslong_PARM_2 + 11 .globl __mulslong + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 __mulslong_sloc0_1_0: + 0000 23 .ds 0x0004 + 0004 24 __mulslong_sloc1_1_0: + 0004 25 .ds 0x0004 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 __mulslong_PARM_2: + 0000 43 .ds 0x0004 + 0004 44 __mulslong_a_1_1: + 0004 45 .ds 0x0004 + 46 ;-------------------------------------------------------- + 47 ; global & static initialisations + 48 ;-------------------------------------------------------- + 49 .area GSINIT (CODE) + 50 ;-------------------------------------------------------- + 51 ; code + 52 ;-------------------------------------------------------- + 53 .area CSEG (CODE) + 0000 54 G$_mulslong$0$0 ==. + 55 ; _muslong.c 24 + 56 ; ----------------------------------------- + 57 ; function _mulslong + 58 ; ----------------------------------------- + 0000 59 __mulslong: + 0002 60 ar2 = 0x02 + 0003 61 ar3 = 0x03 + 0004 62 ar4 = 0x04 + 0005 63 ar5 = 0x05 + 0006 64 ar6 = 0x06 + 0007 65 ar7 = 0x07 + 0000 66 ar0 = 0x00 + 0001 67 ar1 = 0x01 + 68 ; _muslong.c 0 + 0000 C0 E0 69 push acc + 0002 C0 F0 70 push b + 0004 C0 83 71 push dph + 0006 C0 82 72 push dpl + 0008 90s00r04 73 mov dptr,#__mulslong_a_1_1 + 000B D0 E0 74 pop acc + 000D F0 75 movx @dptr,a + 000E D0 E0 76 pop acc + 0010 A3 77 inc dptr + 0011 F0 78 movx @dptr,a + 0012 D0 E0 79 pop acc + 0014 A3 80 inc dptr + 0015 F0 81 movx @dptr,a + 0016 D0 E0 82 pop acc + 0018 A3 83 inc dptr + 0019 F0 84 movx @dptr,a + 85 ; _muslong.c 28 + 001A 90s00r04 86 mov dptr,#__mulslong_a_1_1 + 001D E0 87 movx a,@dptr + 001E FA 88 mov r2,a + 001F A3 89 inc dptr + 0020 E0 90 movx a,@dptr + 0021 FB 91 mov r3,a + 0022 A3 92 inc dptr + 0023 E0 93 movx a,@dptr + 0024 FC 94 mov r4,a + 0025 A3 95 inc dptr + 0026 E0 96 movx a,@dptr + 97 ; Peephole 105 removed redundant mov + 0027 FD 98 mov r5,a + 99 ; Peephole 111 removed ljmp by inverse jump logic + 0028 30 E7 0F 100 jnb acc.7,00106$ + 002B 101 00113$: + 002B C3 102 clr c + 002C E4 103 clr a + 002D 9A 104 subb a,r2 + 002E FE 105 mov r6,a + 002F E4 106 clr a + 0030 9B 107 subb a,r3 + 0031 FF 108 mov r7,a + 0032 E4 109 clr a + 0033 9C 110 subb a,r4 + 0034 F8 111 mov r0,a + 0035 E4 112 clr a + 0036 9D 113 subb a,r5 + 0037 F9 114 mov r1,a + 115 ; Peephole 132 changed ljmp to sjmp + 0038 80 08 116 sjmp 00107$ + 003A 117 00106$: + 003A 8A 06 118 mov ar6,r2 + 003C 8B 07 119 mov ar7,r3 + 003E 8C 00 120 mov ar0,r4 + 0040 8D 01 121 mov ar1,r5 + 0042 122 00107$: + 0042 8E*00 123 mov __mulslong_sloc0_1_0,r6 + 0044 8F*01 124 mov (__mulslong_sloc0_1_0 + 1),r7 + 0046 88*02 125 mov (__mulslong_sloc0_1_0 + 2),r0 + 0048 89*03 126 mov (__mulslong_sloc0_1_0 + 3),r1 + 127 ; _muslong.c 29 + 004A 90s00r00 128 mov dptr,#__mulslong_PARM_2 + 004D E0 129 movx a,@dptr + 004E FE 130 mov r6,a + 004F A3 131 inc dptr + 0050 E0 132 movx a,@dptr + 0051 FF 133 mov r7,a + 0052 A3 134 inc dptr + 0053 E0 135 movx a,@dptr + 0054 F8 136 mov r0,a + 0055 A3 137 inc dptr + 0056 E0 138 movx a,@dptr + 139 ; Peephole 105 removed redundant mov + 0057 F9 140 mov r1,a + 0058 33 141 rlc a + 0059 E4 142 clr a + 005A 33 143 rlc a + 144 ; Peephole 105 removed redundant mov + 005B FA 145 mov r2,a + 146 ; Peephole 110 removed ljmp by inverse jump logic + 005C 60 13 147 jz 00108$ + 005E 148 00114$: + 005E C3 149 clr c + 005F E4 150 clr a + 0060 9E 151 subb a,r6 + 0061 F5*04 152 mov __mulslong_sloc1_1_0,a + 0063 E4 153 clr a + 0064 9F 154 subb a,r7 + 0065 F5*05 155 mov (__mulslong_sloc1_1_0 + 1),a + 0067 E4 156 clr a + 0068 98 157 subb a,r0 + 0069 F5*06 158 mov (__mulslong_sloc1_1_0 + 2),a + 006B E4 159 clr a + 006C 99 160 subb a,r1 + 006D F5*07 161 mov (__mulslong_sloc1_1_0 + 3),a + 162 ; Peephole 132 changed ljmp to sjmp + 006F 80 08 163 sjmp 00109$ + 0071 164 00108$: + 0071 8E*04 165 mov __mulslong_sloc1_1_0,r6 + 0073 8F*05 166 mov (__mulslong_sloc1_1_0 + 1),r7 + 0075 88*06 167 mov (__mulslong_sloc1_1_0 + 2),r0 + 0077 89*07 168 mov (__mulslong_sloc1_1_0 + 3),r1 + 0079 169 00109$: + 0079 90s00r00 170 mov dptr,#__mululong_PARM_2 + 007C E5*04 171 mov a,__mulslong_sloc1_1_0 + 007E F0 172 movx @dptr,a + 007F A3 173 inc dptr + 0080 E5*05 174 mov a,(__mulslong_sloc1_1_0 + 1) + 0082 F0 175 movx @dptr,a + 0083 A3 176 inc dptr + 0084 E5*06 177 mov a,(__mulslong_sloc1_1_0 + 2) + 0086 F0 178 movx @dptr,a + 0087 A3 179 inc dptr + 0088 E5*07 180 mov a,(__mulslong_sloc1_1_0 + 3) + 008A F0 181 movx @dptr,a + 008B C0 02 182 push ar2 + 008D 85*00 82 183 mov dpl,__mulslong_sloc0_1_0 + 0090 85*01 83 184 mov dph,(__mulslong_sloc0_1_0 + 1) + 0093 85*02 F0 185 mov b,(__mulslong_sloc0_1_0 + 2) + 0096 E5*03 186 mov a,(__mulslong_sloc0_1_0 + 3) + 0098 12s00r00 187 lcall __mululong + 009B AB 82 188 mov r3,dpl + 009D AC 83 189 mov r4,dph + 009F AD F0 190 mov r5,b + 00A1 FE 191 mov r6,a + 00A2 D0 02 192 pop ar2 + 193 ; _muslong.c 31 + 00A4 C0 03 194 push ar3 + 00A6 C0 04 195 push ar4 + 00A8 C0 05 196 push ar5 + 00AA C0 06 197 push ar6 + 00AC 90s00r04 198 mov dptr,#__mulslong_a_1_1 + 00AF E0 199 movx a,@dptr + 00B0 FF 200 mov r7,a + 00B1 A3 201 inc dptr + 00B2 E0 202 movx a,@dptr + 00B3 F8 203 mov r0,a + 00B4 A3 204 inc dptr + 00B5 E0 205 movx a,@dptr + 00B6 F9 206 mov r1,a + 00B7 A3 207 inc dptr + 00B8 E0 208 movx a,@dptr + 209 ; Peephole 105 removed redundant mov + 00B9 FB 210 mov r3,a + 00BA 33 211 rlc a + 00BB E4 212 clr a + 00BC 33 213 rlc a + 00BD FF 214 mov r7,a + 00BE EA 215 mov a,r2 + 00BF 65 07 216 xrl a,ar7 + 00C1 D0 06 217 pop ar6 + 00C3 D0 05 218 pop ar5 + 00C5 D0 04 219 pop ar4 + 00C7 D0 03 220 pop ar3 + 221 ; Peephole 110 removed ljmp by inverse jump logic + 00C9 60 1C 222 jz 00102$ + 00CB 223 00115$: + 224 ; _muslong.c 32 + 00CB C3 225 clr c + 00CC E4 226 clr a + 00CD 9B 227 subb a,r3 + 00CE F5*04 228 mov __mulslong_sloc1_1_0,a + 00D0 E4 229 clr a + 00D1 9C 230 subb a,r4 + 00D2 F5*05 231 mov (__mulslong_sloc1_1_0 + 1),a + 00D4 E4 232 clr a + 00D5 9D 233 subb a,r5 + 00D6 F5*06 234 mov (__mulslong_sloc1_1_0 + 2),a + 00D8 E4 235 clr a + 00D9 9E 236 subb a,r6 + 237 ; Peephole 191 removed redundant mov + 00DA F5*07 238 mov (__mulslong_sloc1_1_0 + 3),a + 00DC 85*04 82 239 mov dpl,__mulslong_sloc1_1_0 + 00DF 85*05 83 240 mov dph,(__mulslong_sloc1_1_0 + 1) + 00E2 85*06 F0 241 mov b,(__mulslong_sloc1_1_0 + 2) + 242 ; Peephole 132 changed ljmp to sjmp + 00E5 80 07 243 sjmp 00104$ + 00E7 244 00102$: + 245 ; _muslong.c 34 + 00E7 8B 82 246 mov dpl,r3 + 00E9 8C 83 247 mov dph,r4 + 00EB 8D F0 248 mov b,r5 + 00ED EE 249 mov a,r6 + 00EE 250 00104$: + 00EE 251 C$_muslong.c$35$1$1 ==. + 00EE 252 XG$_mulslong$0$0 ==. + 00EE 22 253 ret + 254 .area CSEG (CODE) diff --git a/device/lib/_muslong.sym b/device/lib/_muslong.sym new file mode 100644 index 00000000..57fc6c19 --- /dev/null +++ b/device/lib/_muslong.sym @@ -0,0 +1,529 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_muslong$100 0028 GR + 7 A$_muslong$102 002B GR + 7 A$_muslong$103 002C GR + 7 A$_muslong$104 002D GR + 7 A$_muslong$105 002E GR + 7 A$_muslong$106 002F GR + 7 A$_muslong$107 0030 GR + 7 A$_muslong$108 0031 GR + 7 A$_muslong$109 0032 GR + 7 A$_muslong$110 0033 GR + 7 A$_muslong$111 0034 GR + 7 A$_muslong$112 0035 GR + 7 A$_muslong$113 0036 GR + 7 A$_muslong$114 0037 GR + 7 A$_muslong$116 0038 GR + 7 A$_muslong$118 003A GR + 7 A$_muslong$119 003C GR + 7 A$_muslong$120 003E GR + 7 A$_muslong$121 0040 GR + 7 A$_muslong$123 0042 GR + 7 A$_muslong$124 0044 GR + 7 A$_muslong$125 0046 GR + 7 A$_muslong$126 0048 GR + 7 A$_muslong$128 004A GR + 7 A$_muslong$129 004D GR + 7 A$_muslong$130 004E GR + 7 A$_muslong$131 004F GR + 7 A$_muslong$132 0050 GR + 7 A$_muslong$133 0051 GR + 7 A$_muslong$134 0052 GR + 7 A$_muslong$135 0053 GR + 7 A$_muslong$136 0054 GR + 7 A$_muslong$137 0055 GR + 7 A$_muslong$138 0056 GR + 7 A$_muslong$140 0057 GR + 7 A$_muslong$141 0058 GR + 7 A$_muslong$142 0059 GR + 7 A$_muslong$143 005A GR + 7 A$_muslong$145 005B GR + 7 A$_muslong$147 005C GR + 7 A$_muslong$149 005E GR + 7 A$_muslong$150 005F GR + 7 A$_muslong$151 0060 GR + 7 A$_muslong$152 0061 GR + 7 A$_muslong$153 0063 GR + 7 A$_muslong$154 0064 GR + 7 A$_muslong$155 0065 GR + 7 A$_muslong$156 0067 GR + 7 A$_muslong$157 0068 GR + 7 A$_muslong$158 0069 GR + 7 A$_muslong$159 006B GR + 7 A$_muslong$160 006C GR + 7 A$_muslong$161 006D GR + 7 A$_muslong$163 006F GR + 7 A$_muslong$165 0071 GR + 7 A$_muslong$166 0073 GR + 7 A$_muslong$167 0075 GR + 7 A$_muslong$168 0077 GR + 7 A$_muslong$170 0079 GR + 7 A$_muslong$171 007C GR + 7 A$_muslong$172 007E GR + 7 A$_muslong$173 007F GR + 7 A$_muslong$174 0080 GR + 7 A$_muslong$175 0082 GR + 7 A$_muslong$176 0083 GR + 7 A$_muslong$177 0084 GR + 7 A$_muslong$178 0086 GR + 7 A$_muslong$179 0087 GR + 7 A$_muslong$180 0088 GR + 7 A$_muslong$181 008A GR + 7 A$_muslong$182 008B GR + 7 A$_muslong$183 008D GR + 7 A$_muslong$184 0090 GR + 7 A$_muslong$185 0093 GR + 7 A$_muslong$186 0096 GR + 7 A$_muslong$187 0098 GR + 7 A$_muslong$188 009B GR + 7 A$_muslong$189 009D GR + 7 A$_muslong$190 009F GR + 7 A$_muslong$191 00A1 GR + 7 A$_muslong$192 00A2 GR + 7 A$_muslong$194 00A4 GR + 7 A$_muslong$195 00A6 GR + 7 A$_muslong$196 00A8 GR + 7 A$_muslong$197 00AA GR + 7 A$_muslong$198 00AC GR + 7 A$_muslong$199 00AF GR + 7 A$_muslong$200 00B0 GR + 7 A$_muslong$201 00B1 GR + 7 A$_muslong$202 00B2 GR + 7 A$_muslong$203 00B3 GR + 7 A$_muslong$204 00B4 GR + 7 A$_muslong$205 00B5 GR + 7 A$_muslong$206 00B6 GR + 7 A$_muslong$207 00B7 GR + 7 A$_muslong$208 00B8 GR + 7 A$_muslong$210 00B9 GR + 7 A$_muslong$211 00BA GR + 7 A$_muslong$212 00BB GR + 7 A$_muslong$213 00BC GR + 7 A$_muslong$214 00BD GR + 7 A$_muslong$215 00BE GR + 7 A$_muslong$216 00BF GR + 7 A$_muslong$217 00C1 GR + 7 A$_muslong$218 00C3 GR + 7 A$_muslong$219 00C5 GR + 7 A$_muslong$220 00C7 GR + 7 A$_muslong$222 00C9 GR + 7 A$_muslong$225 00CB GR + 7 A$_muslong$226 00CC GR + 7 A$_muslong$227 00CD GR + 7 A$_muslong$228 00CE GR + 7 A$_muslong$229 00D0 GR + 7 A$_muslong$230 00D1 GR + 7 A$_muslong$231 00D2 GR + 7 A$_muslong$232 00D4 GR + 7 A$_muslong$233 00D5 GR + 7 A$_muslong$234 00D6 GR + 7 A$_muslong$235 00D8 GR + 7 A$_muslong$236 00D9 GR + 7 A$_muslong$238 00DA GR + 7 A$_muslong$239 00DC GR + 7 A$_muslong$240 00DF GR + 7 A$_muslong$241 00E2 GR + 7 A$_muslong$243 00E5 GR + 7 A$_muslong$246 00E7 GR + 7 A$_muslong$247 00E9 GR + 7 A$_muslong$248 00EB GR + 7 A$_muslong$249 00ED GR + 7 A$_muslong$253 00EE GR + 7 A$_muslong$69 0000 GR + 7 A$_muslong$70 0002 GR + 7 A$_muslong$71 0004 GR + 7 A$_muslong$72 0006 GR + 7 A$_muslong$73 0008 GR + 7 A$_muslong$74 000B GR + 7 A$_muslong$75 000D GR + 7 A$_muslong$76 000E GR + 7 A$_muslong$77 0010 GR + 7 A$_muslong$78 0011 GR + 7 A$_muslong$79 0012 GR + 7 A$_muslong$80 0014 GR + 7 A$_muslong$81 0015 GR + 7 A$_muslong$82 0016 GR + 7 A$_muslong$83 0018 GR + 7 A$_muslong$84 0019 GR + 7 A$_muslong$86 001A GR + 7 A$_muslong$87 001D GR + 7 A$_muslong$88 001E GR + 7 A$_muslong$89 001F GR + 7 A$_muslong$90 0020 GR + 7 A$_muslong$91 0021 GR + 7 A$_muslong$92 0022 GR + 7 A$_muslong$93 0023 GR + 7 A$_muslong$94 0024 GR + 7 A$_muslong$95 0025 GR + 7 A$_muslong$96 0026 GR + 7 A$_muslong$98 0027 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_muslong.c$35$1$1 = 00EE GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_mulslong$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_mulslong$0$0 = 00EE GR + 7 __mulslong 0000 GR + 5 __mulslong_PARM_2 0000 GR + 5 __mulslong_a_1_1 0004 R + 1 __mulslong_sloc0_1_0 0000 R + 1 __mulslong_sloc1_1_0 0004 R + __mululong **** GX + __mululong_PARM_2 **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 8 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size EF flags 20 diff --git a/device/lib/_ser.c b/device/lib/_ser.c new file mode 100644 index 00000000..7a9504ca --- /dev/null +++ b/device/lib/_ser.c @@ -0,0 +1,157 @@ +/*KA****************************************************************** +* PROJECT: PL-One/8052 +********************************************************************** +* FILE: ser.c +********************************************************************** +* CHANGES: +* date author description +* -------------------------------------------------------------------- +* 04/26/99 we final +* 04/27/99 we comments +********************************************************************** +* DESCRIPTION: +* This file contains a simple interrupt driven serial driver with +* buffer (no check for overflow!!!). +********************************************************************** +* FUNCTIONS DECLARED: +* ser_init Initialization; must be called first +* ser_putc output one char on the serial line +* ser_getc return a char if one has been received, else 0 +* ser_printString print a 0-terminated string +* ser_charAvail return 1 if a char arrived on serial line +********************************************************************** +* NOTE: +* Remember to enable all interrupts (EA=1) outside of this module!! +********************************************************************** +* COMPILE TIME OPTIONS: - +* DEBUG OPTIONS: - +******************************************************************KE*/ +/* $Id$ */ + + +#include + +#include "ser.h" + +#define NON_BLOCKING + +unsigned char xdata ser_txIndexIn; +unsigned char xdata ser_txIndexOut; +unsigned char xdata ser_rxIndexIn; +unsigned char xdata ser_rxIndexOut; + +unsigned char xdata ser_txBuffer[0x100]; +unsigned char xdata ser_rxBuffer[0x100]; + +static bit ser_txBusy; + +void +ser_init(void) +{ + ES = 0; + + ser_txBusy = 0; + + ser_txIndexIn = 0; + ser_txIndexOut = 0; + ser_rxIndexIn = 0; + ser_rxIndexOut = 0; + + T2CON = 0x30; + + /* Baudrate = 19200, oscillator frq. of my processor is 21.4772 MHz */ + RCAP2H = 0xFF; + RCAP2L = 0xDD; + + /* enable counter */ + T2CON = 0x34; + + SCON = 0x50; + + if (TI) { + TI = 0; + } + if (RI) { + RI = 0; + } + + ES=1; +} + +void +ser_interrupt_handler(void) interrupt 4 using 1 +{ + ES=0; + + if (TI) { + TI = 0; + if (ser_txIndexIn == ser_txIndexOut) { + ser_txBusy = 0; + } + else { + SBUF = ser_txBuffer[ser_txIndexOut++]; + } + } + + if (RI) { + RI = 0; + ser_rxBuffer[ser_rxIndexIn++] = SBUF; + } + + ES=1; +} + +void +ser_putc(unsigned char c) +{ + ES=0; + + if (ser_txBusy) { + ser_txBuffer[ser_txIndexIn++] = c; + } + else { + ser_txBusy = 1; + SBUF = c; + } + + ES=1; +} + +unsigned char +ser_getc(void) +{ + char tmp; + +#ifdef NON_BLOCKING + if (ser_rxIndexIn != ser_rxIndexOut) { + tmp = ser_rxBuffer[ser_rxIndexOut++]; + } + else { + tmp = 0; + } +#endif + + return(tmp); +} + +void +ser_printString(char *String) +{ + while (*String) { + ser_putc(*String++); + } +} + +short +ser_charAvail(void) +{ + short ret = 0; + + if (ser_rxIndexIn != ser_rxIndexOut) { + ret = 1; + } + + return(ret); +} + +/*********************End of File************************************/ diff --git a/device/lib/_ser.lst b/device/lib/_ser.lst new file mode 100644 index 00000000..8a5bda93 --- /dev/null +++ b/device/lib/_ser.lst @@ -0,0 +1,636 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _ser + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _ser_charAvail + 11 .globl _ser_printString + 12 .globl _ser_getc + 13 .globl _ser_putc + 14 .globl _ser_interrupt_handler + 15 .globl _ser_init + 16 .globl _ser_rxBuffer + 17 .globl _ser_txBuffer + 18 .globl _ser_rxIndexOut + 19 .globl _ser_rxIndexIn + 20 .globl _ser_txIndexOut + 21 .globl _ser_txIndexIn + 22 ;-------------------------------------------------------- + 23 ; special function registers + 24 ;-------------------------------------------------------- + 0080 25 G$P0$0$0 == 0x0080 + 0080 26 _P0 = 0x0080 + 0090 27 G$P1$0$0 == 0x0090 + 0090 28 _P1 = 0x0090 + 00A0 29 G$P2$0$0 == 0x00a0 + 00A0 30 _P2 = 0x00a0 + 00B0 31 G$P3$0$0 == 0x00b0 + 00B0 32 _P3 = 0x00b0 + 00D0 33 G$PSW$0$0 == 0x00d0 + 00D0 34 _PSW = 0x00d0 + 00E0 35 G$ACC$0$0 == 0x00e0 + 00E0 36 _ACC = 0x00e0 + 00F0 37 G$B$0$0 == 0x00f0 + 00F0 38 _B = 0x00f0 + 0081 39 G$SP$0$0 == 0x0081 + 0081 40 _SP = 0x0081 + 0082 41 G$DPL$0$0 == 0x0082 + 0082 42 _DPL = 0x0082 + 0083 43 G$DPH$0$0 == 0x0083 + 0083 44 _DPH = 0x0083 + 0087 45 G$PCON$0$0 == 0x0087 + 0087 46 _PCON = 0x0087 + 0088 47 G$TCON$0$0 == 0x0088 + 0088 48 _TCON = 0x0088 + 0089 49 G$TMOD$0$0 == 0x0089 + 0089 50 _TMOD = 0x0089 + 008A 51 G$TL0$0$0 == 0x008a + 008A 52 _TL0 = 0x008a + 008B 53 G$TL1$0$0 == 0x008b + 008B 54 _TL1 = 0x008b + 008C 55 G$TH0$0$0 == 0x008c + 008C 56 _TH0 = 0x008c + 008D 57 G$TH1$0$0 == 0x008d + 008D 58 _TH1 = 0x008d + 008E 59 G$AUXR$0$0 == 0x008e + 008E 60 _AUXR = 0x008e + 00A8 61 G$IE$0$0 == 0x00a8 + 00A8 62 _IE = 0x00a8 + 00B8 63 G$IP$0$0 == 0x00b8 + 00B8 64 _IP = 0x00b8 + 0098 65 G$SCON$0$0 == 0x0098 + 0098 66 _SCON = 0x0098 + 0099 67 G$SBUF$0$0 == 0x0099 + 0099 68 _SBUF = 0x0099 + 00C8 69 G$T2CON$0$0 == 0x00c8 + 00C8 70 _T2CON = 0x00c8 + 00CB 71 G$RCAP2H$0$0 == 0x00cb + 00CB 72 _RCAP2H = 0x00cb + 00CA 73 G$RCAP2L$0$0 == 0x00ca + 00CA 74 _RCAP2L = 0x00ca + 75 ;-------------------------------------------------------- + 76 ; special function bits + 77 ;-------------------------------------------------------- + 00D7 78 G$CY$0$0 == 0x00d7 + 00D7 79 _CY = 0x00d7 + 00D6 80 G$AC$0$0 == 0x00d6 + 00D6 81 _AC = 0x00d6 + 00D5 82 G$F0$0$0 == 0x00d5 + 00D5 83 _F0 = 0x00d5 + 00D4 84 G$RS1$0$0 == 0x00d4 + 00D4 85 _RS1 = 0x00d4 + 00D3 86 G$RS0$0$0 == 0x00d3 + 00D3 87 _RS0 = 0x00d3 + 00D2 88 G$OV$0$0 == 0x00d2 + 00D2 89 _OV = 0x00d2 + 00D0 90 G$P$0$0 == 0x00d0 + 00D0 91 _P = 0x00d0 + 008F 92 G$TF1$0$0 == 0x008f + 008F 93 _TF1 = 0x008f + 008E 94 G$TR1$0$0 == 0x008e + 008E 95 _TR1 = 0x008e + 008D 96 G$TF0$0$0 == 0x008d + 008D 97 _TF0 = 0x008d + 008C 98 G$TR0$0$0 == 0x008c + 008C 99 _TR0 = 0x008c + 008B 100 G$IE1$0$0 == 0x008b + 008B 101 _IE1 = 0x008b + 008A 102 G$IT1$0$0 == 0x008a + 008A 103 _IT1 = 0x008a + 0089 104 G$IE0$0$0 == 0x0089 + 0089 105 _IE0 = 0x0089 + 0088 106 G$IT0$0$0 == 0x0088 + 0088 107 _IT0 = 0x0088 + 00AF 108 G$EA$0$0 == 0x00af + 00AF 109 _EA = 0x00af + 00AC 110 G$ES$0$0 == 0x00ac + 00AC 111 _ES = 0x00ac + 00AB 112 G$ET1$0$0 == 0x00ab + 00AB 113 _ET1 = 0x00ab + 00AA 114 G$EX1$0$0 == 0x00aa + 00AA 115 _EX1 = 0x00aa + 00A9 116 G$ET0$0$0 == 0x00a9 + 00A9 117 _ET0 = 0x00a9 + 00A8 118 G$EX0$0$0 == 0x00a8 + 00A8 119 _EX0 = 0x00a8 + 00BC 120 G$PS$0$0 == 0x00bc + 00BC 121 _PS = 0x00bc + 00BB 122 G$PT1$0$0 == 0x00bb + 00BB 123 _PT1 = 0x00bb + 00BA 124 G$PX1$0$0 == 0x00ba + 00BA 125 _PX1 = 0x00ba + 00B9 126 G$PT0$0$0 == 0x00b9 + 00B9 127 _PT0 = 0x00b9 + 00B8 128 G$PX0$0$0 == 0x00b8 + 00B8 129 _PX0 = 0x00b8 + 00B7 130 G$RD$0$0 == 0x00b7 + 00B7 131 _RD = 0x00b7 + 00B6 132 G$WR$0$0 == 0x00b6 + 00B6 133 _WR = 0x00b6 + 00B5 134 G$T1$0$0 == 0x00b5 + 00B5 135 _T1 = 0x00b5 + 00B4 136 G$T0$0$0 == 0x00b4 + 00B4 137 _T0 = 0x00b4 + 00B3 138 G$INT1$0$0 == 0x00b3 + 00B3 139 _INT1 = 0x00b3 + 00B2 140 G$INT0$0$0 == 0x00b2 + 00B2 141 _INT0 = 0x00b2 + 00B1 142 G$TXD$0$0 == 0x00b1 + 00B1 143 _TXD = 0x00b1 + 00B0 144 G$RXD$0$0 == 0x00b0 + 00B0 145 _RXD = 0x00b0 + 0090 146 G$P1_0$0$0 == 0x0090 + 0090 147 _P1_0 = 0x0090 + 0091 148 G$P1_1$0$0 == 0x0091 + 0091 149 _P1_1 = 0x0091 + 0092 150 G$P1_2$0$0 == 0x0092 + 0092 151 _P1_2 = 0x0092 + 0093 152 G$P1_3$0$0 == 0x0093 + 0093 153 _P1_3 = 0x0093 + 0094 154 G$P1_4$0$0 == 0x0094 + 0094 155 _P1_4 = 0x0094 + 0095 156 G$P1_5$0$0 == 0x0095 + 0095 157 _P1_5 = 0x0095 + 0096 158 G$P1_6$0$0 == 0x0096 + 0096 159 _P1_6 = 0x0096 + 0097 160 G$P1_7$0$0 == 0x0097 + 0097 161 _P1_7 = 0x0097 + 009F 162 G$SM0$0$0 == 0x009f + 009F 163 _SM0 = 0x009f + 009E 164 G$SM1$0$0 == 0x009e + 009E 165 _SM1 = 0x009e + 009D 166 G$SM2$0$0 == 0x009d + 009D 167 _SM2 = 0x009d + 009C 168 G$REN$0$0 == 0x009c + 009C 169 _REN = 0x009c + 009B 170 G$TB8$0$0 == 0x009b + 009B 171 _TB8 = 0x009b + 009A 172 G$RB8$0$0 == 0x009a + 009A 173 _RB8 = 0x009a + 0099 174 G$TI$0$0 == 0x0099 + 0099 175 _TI = 0x0099 + 0098 176 G$RI$0$0 == 0x0098 + 0098 177 _RI = 0x0098 + 00C8 178 G$T2CON_0$0$0 == 0x00c8 + 00C8 179 _T2CON_0 = 0x00c8 + 00C9 180 G$T2CON_1$0$0 == 0x00c9 + 00C9 181 _T2CON_1 = 0x00c9 + 00CA 182 G$T2CON_2$0$0 == 0x00ca + 00CA 183 _T2CON_2 = 0x00ca + 00CB 184 G$T2CON_3$0$0 == 0x00cb + 00CB 185 _T2CON_3 = 0x00cb + 00CC 186 G$T2CON_4$0$0 == 0x00cc + 00CC 187 _T2CON_4 = 0x00cc + 00CD 188 G$T2CON_5$0$0 == 0x00cd + 00CD 189 _T2CON_5 = 0x00cd + 00CE 190 G$T2CON_6$0$0 == 0x00ce + 00CE 191 _T2CON_6 = 0x00ce + 00CF 192 G$T2CON_7$0$0 == 0x00cf + 00CF 193 _T2CON_7 = 0x00cf + 194 ;-------------------------------------------------------- + 195 ; internal ram data + 196 ;-------------------------------------------------------- + 197 .area DSEG (DATA) + 198 ;-------------------------------------------------------- + 199 ; overlayable items in internal ram + 200 ;-------------------------------------------------------- + 201 .area OSEG (OVR,DATA) + 202 ;-------------------------------------------------------- + 203 ; indirectly addressable internal ram data + 204 ;-------------------------------------------------------- + 205 .area ISEG (DATA) + 206 ;-------------------------------------------------------- + 207 ; bit data + 208 ;-------------------------------------------------------- + 209 .area BSEG (BIT) + 0000 210 F_ser$ser_txBusy$0$0==. + 0000 211 _ser_txBusy: + 0000 212 .ds 0x0001 + 213 ;-------------------------------------------------------- + 214 ; external ram data + 215 ;-------------------------------------------------------- + 216 .area XSEG (XDATA) + 0000 217 G$ser_txIndexIn$0$0==. + 0000 218 _ser_txIndexIn: + 0000 219 .ds 0x0001 + 0001 220 G$ser_txIndexOut$0$0==. + 0001 221 _ser_txIndexOut: + 0001 222 .ds 0x0001 + 0002 223 G$ser_rxIndexIn$0$0==. + 0002 224 _ser_rxIndexIn: + 0002 225 .ds 0x0001 + 0003 226 G$ser_rxIndexOut$0$0==. + 0003 227 _ser_rxIndexOut: + 0003 228 .ds 0x0001 + 0004 229 G$ser_txBuffer$0$0==. + 0004 230 _ser_txBuffer: + 0004 231 .ds 0x0100 + 0104 232 G$ser_rxBuffer$0$0==. + 0104 233 _ser_rxBuffer: + 0104 234 .ds 0x0100 + 0204 235 _ser_putc_c_1_1: + 0204 236 .ds 0x0001 + 0205 237 _ser_getc_tmp_1_1: + 0205 238 .ds 0x0001 + 0206 239 _ser_printString_String_1_1: + 0206 240 .ds 0x0003 + 0209 241 _ser_charAvail_ret_1_1: + 0209 242 .ds 0x0001 + 243 ;-------------------------------------------------------- + 244 ; global & static initialisations + 245 ;-------------------------------------------------------- + 246 .area GSINIT (CODE) + 247 ;-------------------------------------------------------- + 248 ; code + 249 ;-------------------------------------------------------- + 250 .area CSEG (CODE) + 0000 251 G$ser_init$0$0 ==. + 252 ; _ser.c 49 + 253 ; ----------------------------------------- + 254 ; function ser_init + 255 ; ----------------------------------------- + 0000 256 _ser_init: + 0002 257 ar2 = 0x02 + 0003 258 ar3 = 0x03 + 0004 259 ar4 = 0x04 + 0005 260 ar5 = 0x05 + 0006 261 ar6 = 0x06 + 0007 262 ar7 = 0x07 + 0000 263 ar0 = 0x00 + 0001 264 ar1 = 0x01 + 265 ; _ser.c 51 + 0000 C2 AC 266 clr _ES + 267 ; _ser.c 53 + 0002 C2*00 268 clr _ser_txBusy + 269 ; _ser.c 55 + 0004 90s00r00 270 mov dptr,#_ser_txIndexIn + 271 ; Peephole 180 changed mov to clr + 0007 E4 272 clr a + 0008 F0 273 movx @dptr,a + 274 ; _ser.c 56 + 0009 90s00r01 275 mov dptr,#_ser_txIndexOut + 276 ; Peephole 180 changed mov to clr + 000C E4 277 clr a + 000D F0 278 movx @dptr,a + 279 ; _ser.c 57 + 000E 90s00r02 280 mov dptr,#_ser_rxIndexIn + 281 ; Peephole 180 changed mov to clr + 0011 E4 282 clr a + 0012 F0 283 movx @dptr,a + 284 ; _ser.c 58 + 0013 90s00r03 285 mov dptr,#_ser_rxIndexOut + 286 ; Peephole 180 changed mov to clr + 0016 E4 287 clr a + 0017 F0 288 movx @dptr,a + 289 ; _ser.c 60 + 0018 75 C8 30 290 mov _T2CON,#0x30 + 291 ; _ser.c 63 + 001B 75 CB FF 292 mov _RCAP2H,#0xff + 293 ; _ser.c 64 + 001E 75 CA DD 294 mov _RCAP2L,#0xdd + 295 ; _ser.c 67 + 0021 75 C8 34 296 mov _T2CON,#0x34 + 297 ; _ser.c 69 + 0024 75 98 50 298 mov _SCON,#0x50 + 299 ; _ser.c 71 + 300 ; Peephole 111 removed ljmp by inverse jump logic + 0027 30 99 02 301 jnb _TI,00102$ + 002A 302 00109$: + 303 ; _ser.c 72 + 002A C2 99 304 clr _TI + 002C 305 00102$: + 306 ; _ser.c 74 + 307 ; Peephole 111 removed ljmp by inverse jump logic + 002C 30 98 02 308 jnb _RI,00104$ + 002F 309 00110$: + 310 ; _ser.c 75 + 002F C2 98 311 clr _RI + 0031 312 00104$: + 313 ; _ser.c 78 + 0031 D2 AC 314 setb _ES + 0033 315 00105$: + 0033 316 C$_ser.c$79$1$1 ==. + 0033 317 XG$ser_init$0$0 ==. + 0033 22 318 ret + 0034 319 G$ser_interrupt_handler$0$0 ==. + 320 ; _ser.c 82 + 321 ; ----------------------------------------- + 322 ; function ser_interrupt_handler + 323 ; ----------------------------------------- + 0034 324 _ser_interrupt_handler: + 000A 325 ar2 = 0x0a + 000B 326 ar3 = 0x0b + 000C 327 ar4 = 0x0c + 000D 328 ar5 = 0x0d + 000E 329 ar6 = 0x0e + 000F 330 ar7 = 0x0f + 0008 331 ar0 = 0x08 + 0009 332 ar1 = 0x09 + 0034 C0 E0 333 push acc + 0036 C0 F0 334 push b + 0038 C0 82 335 push dpl + 003A C0 83 336 push dph + 003C C0 D0 337 push psw + 003E 75 D0 08 338 mov psw,#0x08 + 339 ; _ser.c 84 + 0041 C2 AC 340 clr _ES + 341 ; _ser.c 86 + 342 ; Peephole 111 removed ljmp by inverse jump logic + 0043 30 99 27 343 jnb _TI,00105$ + 0046 344 00113$: + 345 ; _ser.c 87 + 0046 C2 99 346 clr _TI + 347 ; _ser.c 88 + 0048 90s00r01 348 mov dptr,#_ser_txIndexOut + 004B E0 349 movx a,@dptr + 004C FA 350 mov r2,a + 004D 90s00r00 351 mov dptr,#_ser_txIndexIn + 0050 E0 352 movx a,@dptr + 353 ; Peephole 105 removed redundant mov + 0051 FB 354 mov r3,a + 355 ; Peephole 132 changed ljmp to sjmp + 356 ; Peephole 199 optimized misc jump sequence + 0052 B5 0A 04 357 cjne a,ar2,00102$ + 358 ; Peephole 201 removed redundant sjmp + 0055 359 00114$: + 0055 360 00115$: + 361 ; _ser.c 89 + 0055 C2*00 362 clr _ser_txBusy + 363 ; Peephole 132 changed ljmp to sjmp + 0057 80 14 364 sjmp 00105$ + 0059 365 00102$: + 366 ; _ser.c 92 + 0059 90s00r01 367 mov dptr,#_ser_txIndexOut + 005C 74 01 368 mov a,#0x01 + 005E 2A 369 add a,r2 + 005F F0 370 movx @dptr,a + 0060 EA 371 mov a,r2 + 0061 24r04 372 add a,#_ser_txBuffer + 0063 F5 82 373 mov dpl,a + 374 ; Peephole 180 changed mov to clr + 0065 E4 375 clr a + 0066 34s00 376 addc a,#(_ser_txBuffer >> 8) + 0068 F5 83 377 mov dph,a + 006A E0 378 movx a,@dptr + 006B F5 99 379 mov _SBUF,a + 006D 380 00105$: + 381 ; _ser.c 96 + 382 ; Peephole 111 removed ljmp by inverse jump logic + 006D 30 98 1B 383 jnb _RI,00107$ + 0070 384 00116$: + 385 ; _ser.c 97 + 0070 C2 98 386 clr _RI + 387 ; _ser.c 98 + 0072 90s00r02 388 mov dptr,#_ser_rxIndexIn + 0075 E0 389 movx a,@dptr + 0076 FA 390 mov r2,a + 0077 90s00r02 391 mov dptr,#_ser_rxIndexIn + 007A 74 01 392 mov a,#0x01 + 007C 2A 393 add a,r2 + 007D F0 394 movx @dptr,a + 007E EA 395 mov a,r2 + 007F 24r04 396 add a,#_ser_rxBuffer + 0081 F5 82 397 mov dpl,a + 398 ; Peephole 180 changed mov to clr + 0083 E4 399 clr a + 0084 34s01 400 addc a,#(_ser_rxBuffer >> 8) + 0086 F5 83 401 mov dph,a + 0088 E5 99 402 mov a,_SBUF + 008A F0 403 movx @dptr,a + 008B 404 00107$: + 405 ; _ser.c 101 + 008B D2 AC 406 setb _ES + 008D 407 00108$: + 008D D0 D0 408 pop psw + 008F D0 83 409 pop dph + 0091 D0 82 410 pop dpl + 0093 D0 F0 411 pop b + 0095 D0 E0 412 pop acc + 0097 413 C$_ser.c$102$1$1 ==. + 0097 414 XG$ser_interrupt_handler$0$0 ==. + 0097 32 415 reti + 0098 416 G$ser_putc$0$0 ==. + 417 ; _ser.c 105 + 418 ; ----------------------------------------- + 419 ; function ser_putc + 420 ; ----------------------------------------- + 0098 421 _ser_putc: + 0002 422 ar2 = 0x02 + 0003 423 ar3 = 0x03 + 0004 424 ar4 = 0x04 + 0005 425 ar5 = 0x05 + 0006 426 ar6 = 0x06 + 0007 427 ar7 = 0x07 + 0000 428 ar0 = 0x00 + 0001 429 ar1 = 0x01 + 430 ; _ser.c 117 + 0098 C0 82 431 push dpl + 009A 90s02r04 432 mov dptr,#_ser_putc_c_1_1 + 009D D0 E0 433 pop acc + 009F F0 434 movx @dptr,a + 435 ; _ser.c 107 + 00A0 C2 AC 436 clr _ES + 437 ; _ser.c 109 + 438 ; Peephole 111 removed ljmp by inverse jump logic + 00A2 30*00 20 439 jnb _ser_txBusy,00102$ + 00A5 440 00107$: + 441 ; _ser.c 110 + 00A5 90s00r00 442 mov dptr,#_ser_txIndexIn + 00A8 E0 443 movx a,@dptr + 00A9 FA 444 mov r2,a + 00AA 90s00r00 445 mov dptr,#_ser_txIndexIn + 00AD 74 01 446 mov a,#0x01 + 00AF 2A 447 add a,r2 + 00B0 F0 448 movx @dptr,a + 00B1 EA 449 mov a,r2 + 00B2 24r04 450 add a,#_ser_txBuffer + 00B4 FA 451 mov r2,a + 452 ; Peephole 180 changed mov to clr + 00B5 E4 453 clr a + 00B6 34s00 454 addc a,#(_ser_txBuffer >> 8) + 00B8 FB 455 mov r3,a + 00B9 90s02r04 456 mov dptr,#_ser_putc_c_1_1 + 00BC E0 457 movx a,@dptr + 458 ; Peephole 136 removed redundant moves + 00BD FC 459 mov r4,a + 00BE 8A 82 460 mov dpl,r2 + 00C0 8B 83 461 mov dph,r3 + 00C2 F0 462 movx @dptr,a + 463 ; Peephole 132 changed ljmp to sjmp + 00C3 80 08 464 sjmp 00103$ + 00C5 465 00102$: + 466 ; _ser.c 113 + 00C5 D2*00 467 setb _ser_txBusy + 468 ; _ser.c 114 + 00C7 90s02r04 469 mov dptr,#_ser_putc_c_1_1 + 00CA E0 470 movx a,@dptr + 00CB F5 99 471 mov _SBUF,a + 00CD 472 00103$: + 473 ; _ser.c 117 + 00CD D2 AC 474 setb _ES + 00CF 475 00104$: + 00CF 476 C$_ser.c$118$1$1 ==. + 00CF 477 XG$ser_putc$0$0 ==. + 00CF 22 478 ret + 00D0 479 G$ser_getc$0$0 ==. + 480 ; _ser.c 121 + 481 ; ----------------------------------------- + 482 ; function ser_getc + 483 ; ----------------------------------------- + 00D0 484 _ser_getc: + 485 ; _ser.c 126 + 00D0 90s00r03 486 mov dptr,#_ser_rxIndexOut + 00D3 E0 487 movx a,@dptr + 00D4 FA 488 mov r2,a + 00D5 90s00r02 489 mov dptr,#_ser_rxIndexIn + 00D8 E0 490 movx a,@dptr + 491 ; Peephole 105 removed redundant mov + 00D9 FB 492 mov r3,a + 00DA B5 02 02 493 cjne a,ar2,00107$ + 494 ; Peephole 132 changed ljmp to sjmp + 00DD 80 19 495 sjmp 00102$ + 00DF 496 00107$: + 497 ; _ser.c 127 + 00DF 90s00r03 498 mov dptr,#_ser_rxIndexOut + 00E2 74 01 499 mov a,#0x01 + 00E4 2A 500 add a,r2 + 00E5 F0 501 movx @dptr,a + 00E6 EA 502 mov a,r2 + 00E7 24r04 503 add a,#_ser_rxBuffer + 00E9 F5 82 504 mov dpl,a + 505 ; Peephole 180 changed mov to clr + 00EB E4 506 clr a + 00EC 34s01 507 addc a,#(_ser_rxBuffer >> 8) + 00EE F5 83 508 mov dph,a + 00F0 E0 509 movx a,@dptr + 510 ; Peephole 100 removed redundant mov + 00F1 FA 511 mov r2,a + 00F2 90s02r05 512 mov dptr,#_ser_getc_tmp_1_1 + 00F5 F0 513 movx @dptr,a + 514 ; Peephole 132 changed ljmp to sjmp + 00F6 80 05 515 sjmp 00103$ + 00F8 516 00102$: + 517 ; _ser.c 130 + 00F8 90s02r05 518 mov dptr,#_ser_getc_tmp_1_1 + 519 ; Peephole 180 changed mov to clr + 00FB E4 520 clr a + 00FC F0 521 movx @dptr,a + 00FD 522 00103$: + 523 ; _ser.c 134 + 00FD 90s02r05 524 mov dptr,#_ser_getc_tmp_1_1 + 0100 E0 525 movx a,@dptr + 0101 FA 526 mov r2,a + 0102 8A 82 527 mov dpl,r2 + 0104 528 00104$: + 0104 529 C$_ser.c$135$1$1 ==. + 0104 530 XG$ser_getc$0$0 ==. + 0104 22 531 ret + 0105 532 G$ser_printString$0$0 ==. + 533 ; _ser.c 138 + 534 ; ----------------------------------------- + 535 ; function ser_printString + 536 ; ----------------------------------------- + 0105 537 _ser_printString: + 538 ; _ser.c 0 + 0105 C0 F0 539 push b + 0107 C0 83 540 push dph + 0109 C0 82 541 push dpl + 010B 90s02r06 542 mov dptr,#_ser_printString_String_1_1 + 010E D0 E0 543 pop acc + 0110 F0 544 movx @dptr,a + 0111 D0 E0 545 pop acc + 0113 A3 546 inc dptr + 0114 F0 547 movx @dptr,a + 0115 D0 E0 548 pop acc + 0117 A3 549 inc dptr + 0118 F0 550 movx @dptr,a + 551 ; _ser.c 140 + 0119 90s02r06 552 mov dptr,#_ser_printString_String_1_1 + 011C E0 553 movx a,@dptr + 011D FA 554 mov r2,a + 011E A3 555 inc dptr + 011F E0 556 movx a,@dptr + 0120 FB 557 mov r3,a + 0121 A3 558 inc dptr + 0122 E0 559 movx a,@dptr + 0123 FC 560 mov r4,a + 0124 561 00101$: + 0124 8A 82 562 mov dpl,r2 + 0126 8B 83 563 mov dph,r3 + 0128 8C F0 564 mov b,r4 + 012A 12s00r00 565 lcall __gptrget + 012D FD 566 mov r5,a + 012E 90s02r06 567 mov dptr,#_ser_printString_String_1_1 + 0131 EA 568 mov a,r2 + 0132 F0 569 movx @dptr,a + 0133 A3 570 inc dptr + 0134 EB 571 mov a,r3 + 0135 F0 572 movx @dptr,a + 0136 A3 573 inc dptr + 0137 EC 574 mov a,r4 + 0138 F0 575 movx @dptr,a + 0139 ED 576 mov a,r5 + 577 ; Peephole 110 removed ljmp by inverse jump logic + 013A 60 18 578 jz 00104$ + 013C 579 00108$: + 580 ; _ser.c 141 + 013C 0A 581 inc r2 + 013D BA 00 01 582 cjne r2,#0x00,00109$ + 0140 0B 583 inc r3 + 0141 584 00109$: + 0141 C0 02 585 push ar2 + 0143 C0 03 586 push ar3 + 0145 C0 04 587 push ar4 + 0147 8D 82 588 mov dpl,r5 + 0149 12s00r98 589 lcall _ser_putc + 014C D0 04 590 pop ar4 + 014E D0 03 591 pop ar3 + 0150 D0 02 592 pop ar2 + 593 ; Peephole 132 changed ljmp to sjmp + 0152 80 D0 594 sjmp 00101$ + 0154 595 00104$: + 0154 596 C$_ser.c$143$1$1 ==. + 0154 597 XG$ser_printString$0$0 ==. + 0154 22 598 ret + 0155 599 G$ser_charAvail$0$0 ==. + 600 ; _ser.c 146 + 601 ; ----------------------------------------- + 602 ; function ser_charAvail + 603 ; ----------------------------------------- + 0155 604 _ser_charAvail: + 605 ; _ser.c 148 + 0155 90s02r09 606 mov dptr,#_ser_charAvail_ret_1_1 + 607 ; Peephole 180 changed mov to clr + 0158 E4 608 clr a + 0159 F0 609 movx @dptr,a + 610 ; _ser.c 150 + 015A 90s00r03 611 mov dptr,#_ser_rxIndexOut + 015D E0 612 movx a,@dptr + 015E FA 613 mov r2,a + 015F 90s00r02 614 mov dptr,#_ser_rxIndexIn + 0162 E0 615 movx a,@dptr + 616 ; Peephole 105 removed redundant mov + 0163 FB 617 mov r3,a + 0164 B5 02 02 618 cjne a,ar2,00106$ + 619 ; Peephole 132 changed ljmp to sjmp + 0167 80 06 620 sjmp 00102$ + 0169 621 00106$: + 622 ; _ser.c 151 + 0169 90s02r09 623 mov dptr,#_ser_charAvail_ret_1_1 + 016C 74 01 624 mov a,#0x01 + 016E F0 625 movx @dptr,a + 016F 626 00102$: + 627 ; _ser.c 154 + 016F 90s02r09 628 mov dptr,#_ser_charAvail_ret_1_1 + 0172 E0 629 movx a,@dptr + 0173 FA 630 mov r2,a + 0174 8A 82 631 mov dpl,r2 + 0176 632 00103$: + 0176 633 C$_ser.c$155$1$1 ==. + 0176 634 XG$ser_charAvail$0$0 ==. + 0176 22 635 ret + 636 .area CSEG (CODE) diff --git a/device/lib/_ser.sym b/device/lib/_ser.sym new file mode 100644 index 00000000..abeb145e --- /dev/null +++ b/device/lib/_ser.sym @@ -0,0 +1,781 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_ser$266 0000 GR + 7 A$_ser$268 0002 GR + 7 A$_ser$270 0004 GR + 7 A$_ser$272 0007 GR + 7 A$_ser$273 0008 GR + 7 A$_ser$275 0009 GR + 7 A$_ser$277 000C GR + 7 A$_ser$278 000D GR + 7 A$_ser$280 000E GR + 7 A$_ser$282 0011 GR + 7 A$_ser$283 0012 GR + 7 A$_ser$285 0013 GR + 7 A$_ser$287 0016 GR + 7 A$_ser$288 0017 GR + 7 A$_ser$290 0018 GR + 7 A$_ser$292 001B GR + 7 A$_ser$294 001E GR + 7 A$_ser$296 0021 GR + 7 A$_ser$298 0024 GR + 7 A$_ser$301 0027 GR + 7 A$_ser$304 002A GR + 7 A$_ser$308 002C GR + 7 A$_ser$311 002F GR + 7 A$_ser$314 0031 GR + 7 A$_ser$318 0033 GR + 7 A$_ser$333 0034 GR + 7 A$_ser$334 0036 GR + 7 A$_ser$335 0038 GR + 7 A$_ser$336 003A GR + 7 A$_ser$337 003C GR + 7 A$_ser$338 003E GR + 7 A$_ser$340 0041 GR + 7 A$_ser$343 0043 GR + 7 A$_ser$346 0046 GR + 7 A$_ser$348 0048 GR + 7 A$_ser$349 004B GR + 7 A$_ser$350 004C GR + 7 A$_ser$351 004D GR + 7 A$_ser$352 0050 GR + 7 A$_ser$354 0051 GR + 7 A$_ser$357 0052 GR + 7 A$_ser$362 0055 GR + 7 A$_ser$364 0057 GR + 7 A$_ser$367 0059 GR + 7 A$_ser$368 005C GR + 7 A$_ser$369 005E GR + 7 A$_ser$370 005F GR + 7 A$_ser$371 0060 GR + 7 A$_ser$372 0061 GR + 7 A$_ser$373 0063 GR + 7 A$_ser$375 0065 GR + 7 A$_ser$376 0066 GR + 7 A$_ser$377 0068 GR + 7 A$_ser$378 006A GR + 7 A$_ser$379 006B GR + 7 A$_ser$383 006D GR + 7 A$_ser$386 0070 GR + 7 A$_ser$388 0072 GR + 7 A$_ser$389 0075 GR + 7 A$_ser$390 0076 GR + 7 A$_ser$391 0077 GR + 7 A$_ser$392 007A GR + 7 A$_ser$393 007C GR + 7 A$_ser$394 007D GR + 7 A$_ser$395 007E GR + 7 A$_ser$396 007F GR + 7 A$_ser$397 0081 GR + 7 A$_ser$399 0083 GR + 7 A$_ser$400 0084 GR + 7 A$_ser$401 0086 GR + 7 A$_ser$402 0088 GR + 7 A$_ser$403 008A GR + 7 A$_ser$406 008B GR + 7 A$_ser$408 008D GR + 7 A$_ser$409 008F GR + 7 A$_ser$410 0091 GR + 7 A$_ser$411 0093 GR + 7 A$_ser$412 0095 GR + 7 A$_ser$415 0097 GR + 7 A$_ser$431 0098 GR + 7 A$_ser$432 009A GR + 7 A$_ser$433 009D GR + 7 A$_ser$434 009F GR + 7 A$_ser$436 00A0 GR + 7 A$_ser$439 00A2 GR + 7 A$_ser$442 00A5 GR + 7 A$_ser$443 00A8 GR + 7 A$_ser$444 00A9 GR + 7 A$_ser$445 00AA GR + 7 A$_ser$446 00AD GR + 7 A$_ser$447 00AF GR + 7 A$_ser$448 00B0 GR + 7 A$_ser$449 00B1 GR + 7 A$_ser$450 00B2 GR + 7 A$_ser$451 00B4 GR + 7 A$_ser$453 00B5 GR + 7 A$_ser$454 00B6 GR + 7 A$_ser$455 00B8 GR + 7 A$_ser$456 00B9 GR + 7 A$_ser$457 00BC GR + 7 A$_ser$459 00BD GR + 7 A$_ser$460 00BE GR + 7 A$_ser$461 00C0 GR + 7 A$_ser$462 00C2 GR + 7 A$_ser$464 00C3 GR + 7 A$_ser$467 00C5 GR + 7 A$_ser$469 00C7 GR + 7 A$_ser$470 00CA GR + 7 A$_ser$471 00CB GR + 7 A$_ser$474 00CD GR + 7 A$_ser$478 00CF GR + 7 A$_ser$486 00D0 GR + 7 A$_ser$487 00D3 GR + 7 A$_ser$488 00D4 GR + 7 A$_ser$489 00D5 GR + 7 A$_ser$490 00D8 GR + 7 A$_ser$492 00D9 GR + 7 A$_ser$493 00DA GR + 7 A$_ser$495 00DD GR + 7 A$_ser$498 00DF GR + 7 A$_ser$499 00E2 GR + 7 A$_ser$500 00E4 GR + 7 A$_ser$501 00E5 GR + 7 A$_ser$502 00E6 GR + 7 A$_ser$503 00E7 GR + 7 A$_ser$504 00E9 GR + 7 A$_ser$506 00EB GR + 7 A$_ser$507 00EC GR + 7 A$_ser$508 00EE GR + 7 A$_ser$509 00F0 GR + 7 A$_ser$511 00F1 GR + 7 A$_ser$512 00F2 GR + 7 A$_ser$513 00F5 GR + 7 A$_ser$515 00F6 GR + 7 A$_ser$518 00F8 GR + 7 A$_ser$520 00FB GR + 7 A$_ser$521 00FC GR + 7 A$_ser$524 00FD GR + 7 A$_ser$525 0100 GR + 7 A$_ser$526 0101 GR + 7 A$_ser$527 0102 GR + 7 A$_ser$531 0104 GR + 7 A$_ser$539 0105 GR + 7 A$_ser$540 0107 GR + 7 A$_ser$541 0109 GR + 7 A$_ser$542 010B GR + 7 A$_ser$543 010E GR + 7 A$_ser$544 0110 GR + 7 A$_ser$545 0111 GR + 7 A$_ser$546 0113 GR + 7 A$_ser$547 0114 GR + 7 A$_ser$548 0115 GR + 7 A$_ser$549 0117 GR + 7 A$_ser$550 0118 GR + 7 A$_ser$552 0119 GR + 7 A$_ser$553 011C GR + 7 A$_ser$554 011D GR + 7 A$_ser$555 011E GR + 7 A$_ser$556 011F GR + 7 A$_ser$557 0120 GR + 7 A$_ser$558 0121 GR + 7 A$_ser$559 0122 GR + 7 A$_ser$560 0123 GR + 7 A$_ser$562 0124 GR + 7 A$_ser$563 0126 GR + 7 A$_ser$564 0128 GR + 7 A$_ser$565 012A GR + 7 A$_ser$566 012D GR + 7 A$_ser$567 012E GR + 7 A$_ser$568 0131 GR + 7 A$_ser$569 0132 GR + 7 A$_ser$570 0133 GR + 7 A$_ser$571 0134 GR + 7 A$_ser$572 0135 GR + 7 A$_ser$573 0136 GR + 7 A$_ser$574 0137 GR + 7 A$_ser$575 0138 GR + 7 A$_ser$576 0139 GR + 7 A$_ser$578 013A GR + 7 A$_ser$581 013C GR + 7 A$_ser$582 013D GR + 7 A$_ser$583 0140 GR + 7 A$_ser$585 0141 GR + 7 A$_ser$586 0143 GR + 7 A$_ser$587 0145 GR + 7 A$_ser$588 0147 GR + 7 A$_ser$589 0149 GR + 7 A$_ser$590 014C GR + 7 A$_ser$591 014E GR + 7 A$_ser$592 0150 GR + 7 A$_ser$594 0152 GR + 7 A$_ser$598 0154 GR + 7 A$_ser$606 0155 GR + 7 A$_ser$608 0158 GR + 7 A$_ser$609 0159 GR + 7 A$_ser$611 015A GR + 7 A$_ser$612 015D GR + 7 A$_ser$613 015E GR + 7 A$_ser$614 015F GR + 7 A$_ser$615 0162 GR + 7 A$_ser$617 0163 GR + 7 A$_ser$618 0164 GR + 7 A$_ser$620 0167 GR + 7 A$_ser$623 0169 GR + 7 A$_ser$624 016C GR + 7 A$_ser$625 016E GR + 7 A$_ser$628 016F GR + 7 A$_ser$629 0172 GR + 7 A$_ser$630 0173 GR + 7 A$_ser$631 0174 GR + 7 A$_ser$635 0176 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_ser.c$102$1$1 = 0097 GR + 7 C$_ser.c$118$1$1 = 00CF GR + 7 C$_ser.c$135$1$1 = 0104 GR + 7 C$_ser.c$143$1$1 = 0154 GR + 7 C$_ser.c$155$1$1 = 0176 GR + 7 C$_ser.c$79$1$1 = 0033 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 4 F_ser$ser_txBusy$0$0 = 0000 GR + G$AC$0$0 = 00D6 G + G$ACC$0$0 = 00E0 G + G$AUXR$0$0 = 008E G + G$B$0$0 = 00F0 G + G$CY$0$0 = 00D7 G + G$DPH$0$0 = 0083 G + G$DPL$0$0 = 0082 G + G$EA$0$0 = 00AF G + G$ES$0$0 = 00AC G + G$ET0$0$0 = 00A9 G + G$ET1$0$0 = 00AB G + G$EX0$0$0 = 00A8 G + G$EX1$0$0 = 00AA G + G$F0$0$0 = 00D5 G + G$IE$0$0 = 00A8 G + G$IE0$0$0 = 0089 G + G$IE1$0$0 = 008B G + G$INT0$0$0 = 00B2 G + G$INT1$0$0 = 00B3 G + G$IP$0$0 = 00B8 G + G$IT0$0$0 = 0088 G + G$IT1$0$0 = 008A G + G$OV$0$0 = 00D2 G + G$P$0$0 = 00D0 G + G$P0$0$0 = 0080 G + G$P1$0$0 = 0090 G + G$P1_0$0$0 = 0090 G + G$P1_1$0$0 = 0091 G + G$P1_2$0$0 = 0092 G + G$P1_3$0$0 = 0093 G + G$P1_4$0$0 = 0094 G + G$P1_5$0$0 = 0095 G + G$P1_6$0$0 = 0096 G + G$P1_7$0$0 = 0097 G + G$P2$0$0 = 00A0 G + G$P3$0$0 = 00B0 G + G$PCON$0$0 = 0087 G + G$PS$0$0 = 00BC G + G$PSW$0$0 = 00D0 G + G$PT0$0$0 = 00B9 G + G$PT1$0$0 = 00BB G + G$PX0$0$0 = 00B8 G + G$PX1$0$0 = 00BA G + G$RB8$0$0 = 009A G + G$RCAP2H$0$0 = 00CB G + G$RCAP2L$0$0 = 00CA G + G$RD$0$0 = 00B7 G + G$REN$0$0 = 009C G + G$RI$0$0 = 0098 G + G$RS0$0$0 = 00D3 G + G$RS1$0$0 = 00D4 G + G$RXD$0$0 = 00B0 G + G$SBUF$0$0 = 0099 G + G$SCON$0$0 = 0098 G + G$SM0$0$0 = 009F G + G$SM1$0$0 = 009E G + G$SM2$0$0 = 009D G + G$SP$0$0 = 0081 G + G$T0$0$0 = 00B4 G + G$T1$0$0 = 00B5 G + G$T2CON$0$0 = 00C8 G + G$T2CON_0$0$0 = 00C8 G + G$T2CON_1$0$0 = 00C9 G + G$T2CON_2$0$0 = 00CA G + G$T2CON_3$0$0 = 00CB G + G$T2CON_4$0$0 = 00CC G + G$T2CON_5$0$0 = 00CD G + G$T2CON_6$0$0 = 00CE G + G$T2CON_7$0$0 = 00CF G + G$TB8$0$0 = 009B G + G$TCON$0$0 = 0088 G + G$TF0$0$0 = 008D G + G$TF1$0$0 = 008F G + G$TH0$0$0 = 008C G + G$TH1$0$0 = 008D G + G$TI$0$0 = 0099 G + G$TL0$0$0 = 008A G + G$TL1$0$0 = 008B G + G$TMOD$0$0 = 0089 G + G$TR0$0$0 = 008C G + G$TR1$0$0 = 008E G + G$TXD$0$0 = 00B1 G + G$WR$0$0 = 00B6 G + 7 G$ser_charAvail$0$0 = 0155 GR + 7 G$ser_getc$0$0 = 00D0 GR + 7 G$ser_init$0$0 = 0000 GR + 7 G$ser_interrupt_handler$0$0 = 0034 GR + 7 G$ser_printString$0$0 = 0105 GR + 7 G$ser_putc$0$0 = 0098 GR + 5 G$ser_rxBuffer$0$0 = 0104 GR + 5 G$ser_rxIndexIn$0$0 = 0002 GR + 5 G$ser_rxIndexOut$0$0 = 0003 GR + 5 G$ser_txBuffer$0$0 = 0004 GR + 5 G$ser_txIndexIn$0$0 = 0000 GR + 5 G$ser_txIndexOut$0$0 = 0001 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$ser_charAvail$0$0 = 0176 GR + 7 XG$ser_getc$0$0 = 0104 GR + 7 XG$ser_init$0$0 = 0033 GR + 7 XG$ser_interrupt_handler$0$0 = 0097 GR + 7 XG$ser_printString$0$0 = 0154 GR + 7 XG$ser_putc$0$0 = 00CF GR + _AC = 00D6 + _ACC = 00E0 + _AUXR = 008E + _B = 00F0 + _CY = 00D7 + _DPH = 0083 + _DPL = 0082 + _EA = 00AF + _ES = 00AC + _ET0 = 00A9 + _ET1 = 00AB + _EX0 = 00A8 + _EX1 = 00AA + _F0 = 00D5 + _IE = 00A8 + _IE0 = 0089 + _IE1 = 008B + _INT0 = 00B2 + _INT1 = 00B3 + _IP = 00B8 + _IT0 = 0088 + _IT1 = 008A + _OV = 00D2 + _P = 00D0 + _P0 = 0080 + _P1 = 0090 + _P1_0 = 0090 + _P1_1 = 0091 + _P1_2 = 0092 + _P1_3 = 0093 + _P1_4 = 0094 + _P1_5 = 0095 + _P1_6 = 0096 + _P1_7 = 0097 + _P2 = 00A0 + _P3 = 00B0 + _PCON = 0087 + _PS = 00BC + _PSW = 00D0 + _PT0 = 00B9 + _PT1 = 00BB + _PX0 = 00B8 + _PX1 = 00BA + _RB8 = 009A + _RCAP2H = 00CB + _RCAP2L = 00CA + _RD = 00B7 + _REN = 009C + _RI = 0098 + _RS0 = 00D3 + _RS1 = 00D4 + _RXD = 00B0 + _SBUF = 0099 + _SCON = 0098 + _SM0 = 009F + _SM1 = 009E + _SM2 = 009D + _SP = 0081 + _T0 = 00B4 + _T1 = 00B5 + _T2CON = 00C8 + _T2CON_0 = 00C8 + _T2CON_1 = 00C9 + _T2CON_2 = 00CA + _T2CON_3 = 00CB + _T2CON_4 = 00CC + _T2CON_5 = 00CD + _T2CON_6 = 00CE + _T2CON_7 = 00CF + _TB8 = 009B + _TCON = 0088 + _TF0 = 008D + _TF1 = 008F + _TH0 = 008C + _TH1 = 008D + _TI = 0099 + _TL0 = 008A + _TL1 = 008B + _TMOD = 0089 + _TR0 = 008C + _TR1 = 008E + _TXD = 00B1 + _WR = 00B6 + __gptrget **** GX + 7 _ser_charAvail 0155 GR + 5 _ser_charAvail_ret_1_1 0209 R + 7 _ser_getc 00D0 GR + 5 _ser_getc_tmp_1_1 0205 R + 7 _ser_init 0000 GR + 7 _ser_interrupt_handler 0034 GR + 7 _ser_printString 0105 GR + 5 _ser_printString_String_1_1 0206 R + 7 _ser_putc 0098 GR + 5 _ser_putc_c_1_1 0204 R + 5 _ser_rxBuffer 0104 GR + 5 _ser_rxIndexIn 0002 GR + 5 _ser_rxIndexOut 0003 GR + 5 _ser_txBuffer 0004 GR + 4 _ser_txBusy 0000 R + 5 _ser_txIndexIn 0000 GR + 5 _ser_txIndexOut 0001 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 1 flags 80 + 5 XSEG size 20A flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 177 flags 20 diff --git a/device/lib/_setjmp.c b/device/lib/_setjmp.c new file mode 100644 index 00000000..89fad212 --- /dev/null +++ b/device/lib/_setjmp.c @@ -0,0 +1,48 @@ +/*------------------------------------------------------------------------- + setjmp.c - source file for ANSI routines setjmp & longjmp + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include + + + +int longjmp (unsigned char _generic *bp, int rv) +{ + unsigned char lsp; + lsp = *(bp+2); + *((unsigned char data *) lsp) = *bp++; + *((unsigned char data *) lsp - 1) = *bp; + SP = lsp; + return rv; +} + +int setjmp( unsigned char _generic *bp) { + + /* registers would have been saved on the + stack anyway so we need to save SP + and the return address */ + *bp++ = *((unsigned char data *) SP ); + *bp++ = *((unsigned char data *)SP - 1); + *bp = SP; + return 0; + +} diff --git a/device/lib/_setjmp.lst b/device/lib/_setjmp.lst new file mode 100644 index 00000000..349355be --- /dev/null +++ b/device/lib/_setjmp.lst @@ -0,0 +1,403 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _setjmp + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _setjmp + 11 .globl _longjmp + 12 .globl _longjmp_PARM_2 + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 0080 16 G$P0$0$0 == 0x0080 + 0080 17 _P0 = 0x0080 + 0090 18 G$P1$0$0 == 0x0090 + 0090 19 _P1 = 0x0090 + 00A0 20 G$P2$0$0 == 0x00a0 + 00A0 21 _P2 = 0x00a0 + 00B0 22 G$P3$0$0 == 0x00b0 + 00B0 23 _P3 = 0x00b0 + 00D0 24 G$PSW$0$0 == 0x00d0 + 00D0 25 _PSW = 0x00d0 + 00E0 26 G$ACC$0$0 == 0x00e0 + 00E0 27 _ACC = 0x00e0 + 00F0 28 G$B$0$0 == 0x00f0 + 00F0 29 _B = 0x00f0 + 0081 30 G$SP$0$0 == 0x0081 + 0081 31 _SP = 0x0081 + 0082 32 G$DPL$0$0 == 0x0082 + 0082 33 _DPL = 0x0082 + 0083 34 G$DPH$0$0 == 0x0083 + 0083 35 _DPH = 0x0083 + 0087 36 G$PCON$0$0 == 0x0087 + 0087 37 _PCON = 0x0087 + 0088 38 G$TCON$0$0 == 0x0088 + 0088 39 _TCON = 0x0088 + 0089 40 G$TMOD$0$0 == 0x0089 + 0089 41 _TMOD = 0x0089 + 008A 42 G$TL0$0$0 == 0x008a + 008A 43 _TL0 = 0x008a + 008B 44 G$TL1$0$0 == 0x008b + 008B 45 _TL1 = 0x008b + 008C 46 G$TH0$0$0 == 0x008c + 008C 47 _TH0 = 0x008c + 008D 48 G$TH1$0$0 == 0x008d + 008D 49 _TH1 = 0x008d + 008E 50 G$AUXR$0$0 == 0x008e + 008E 51 _AUXR = 0x008e + 00A8 52 G$IE$0$0 == 0x00a8 + 00A8 53 _IE = 0x00a8 + 00B8 54 G$IP$0$0 == 0x00b8 + 00B8 55 _IP = 0x00b8 + 0098 56 G$SCON$0$0 == 0x0098 + 0098 57 _SCON = 0x0098 + 0099 58 G$SBUF$0$0 == 0x0099 + 0099 59 _SBUF = 0x0099 + 00C8 60 G$T2CON$0$0 == 0x00c8 + 00C8 61 _T2CON = 0x00c8 + 00CB 62 G$RCAP2H$0$0 == 0x00cb + 00CB 63 _RCAP2H = 0x00cb + 00CA 64 G$RCAP2L$0$0 == 0x00ca + 00CA 65 _RCAP2L = 0x00ca + 66 ;-------------------------------------------------------- + 67 ; special function bits + 68 ;-------------------------------------------------------- + 00D7 69 G$CY$0$0 == 0x00d7 + 00D7 70 _CY = 0x00d7 + 00D6 71 G$AC$0$0 == 0x00d6 + 00D6 72 _AC = 0x00d6 + 00D5 73 G$F0$0$0 == 0x00d5 + 00D5 74 _F0 = 0x00d5 + 00D4 75 G$RS1$0$0 == 0x00d4 + 00D4 76 _RS1 = 0x00d4 + 00D3 77 G$RS0$0$0 == 0x00d3 + 00D3 78 _RS0 = 0x00d3 + 00D2 79 G$OV$0$0 == 0x00d2 + 00D2 80 _OV = 0x00d2 + 00D0 81 G$P$0$0 == 0x00d0 + 00D0 82 _P = 0x00d0 + 008F 83 G$TF1$0$0 == 0x008f + 008F 84 _TF1 = 0x008f + 008E 85 G$TR1$0$0 == 0x008e + 008E 86 _TR1 = 0x008e + 008D 87 G$TF0$0$0 == 0x008d + 008D 88 _TF0 = 0x008d + 008C 89 G$TR0$0$0 == 0x008c + 008C 90 _TR0 = 0x008c + 008B 91 G$IE1$0$0 == 0x008b + 008B 92 _IE1 = 0x008b + 008A 93 G$IT1$0$0 == 0x008a + 008A 94 _IT1 = 0x008a + 0089 95 G$IE0$0$0 == 0x0089 + 0089 96 _IE0 = 0x0089 + 0088 97 G$IT0$0$0 == 0x0088 + 0088 98 _IT0 = 0x0088 + 00AF 99 G$EA$0$0 == 0x00af + 00AF 100 _EA = 0x00af + 00AC 101 G$ES$0$0 == 0x00ac + 00AC 102 _ES = 0x00ac + 00AB 103 G$ET1$0$0 == 0x00ab + 00AB 104 _ET1 = 0x00ab + 00AA 105 G$EX1$0$0 == 0x00aa + 00AA 106 _EX1 = 0x00aa + 00A9 107 G$ET0$0$0 == 0x00a9 + 00A9 108 _ET0 = 0x00a9 + 00A8 109 G$EX0$0$0 == 0x00a8 + 00A8 110 _EX0 = 0x00a8 + 00BC 111 G$PS$0$0 == 0x00bc + 00BC 112 _PS = 0x00bc + 00BB 113 G$PT1$0$0 == 0x00bb + 00BB 114 _PT1 = 0x00bb + 00BA 115 G$PX1$0$0 == 0x00ba + 00BA 116 _PX1 = 0x00ba + 00B9 117 G$PT0$0$0 == 0x00b9 + 00B9 118 _PT0 = 0x00b9 + 00B8 119 G$PX0$0$0 == 0x00b8 + 00B8 120 _PX0 = 0x00b8 + 00B7 121 G$RD$0$0 == 0x00b7 + 00B7 122 _RD = 0x00b7 + 00B6 123 G$WR$0$0 == 0x00b6 + 00B6 124 _WR = 0x00b6 + 00B5 125 G$T1$0$0 == 0x00b5 + 00B5 126 _T1 = 0x00b5 + 00B4 127 G$T0$0$0 == 0x00b4 + 00B4 128 _T0 = 0x00b4 + 00B3 129 G$INT1$0$0 == 0x00b3 + 00B3 130 _INT1 = 0x00b3 + 00B2 131 G$INT0$0$0 == 0x00b2 + 00B2 132 _INT0 = 0x00b2 + 00B1 133 G$TXD$0$0 == 0x00b1 + 00B1 134 _TXD = 0x00b1 + 00B0 135 G$RXD$0$0 == 0x00b0 + 00B0 136 _RXD = 0x00b0 + 0090 137 G$P1_0$0$0 == 0x0090 + 0090 138 _P1_0 = 0x0090 + 0091 139 G$P1_1$0$0 == 0x0091 + 0091 140 _P1_1 = 0x0091 + 0092 141 G$P1_2$0$0 == 0x0092 + 0092 142 _P1_2 = 0x0092 + 0093 143 G$P1_3$0$0 == 0x0093 + 0093 144 _P1_3 = 0x0093 + 0094 145 G$P1_4$0$0 == 0x0094 + 0094 146 _P1_4 = 0x0094 + 0095 147 G$P1_5$0$0 == 0x0095 + 0095 148 _P1_5 = 0x0095 + 0096 149 G$P1_6$0$0 == 0x0096 + 0096 150 _P1_6 = 0x0096 + 0097 151 G$P1_7$0$0 == 0x0097 + 0097 152 _P1_7 = 0x0097 + 009F 153 G$SM0$0$0 == 0x009f + 009F 154 _SM0 = 0x009f + 009E 155 G$SM1$0$0 == 0x009e + 009E 156 _SM1 = 0x009e + 009D 157 G$SM2$0$0 == 0x009d + 009D 158 _SM2 = 0x009d + 009C 159 G$REN$0$0 == 0x009c + 009C 160 _REN = 0x009c + 009B 161 G$TB8$0$0 == 0x009b + 009B 162 _TB8 = 0x009b + 009A 163 G$RB8$0$0 == 0x009a + 009A 164 _RB8 = 0x009a + 0099 165 G$TI$0$0 == 0x0099 + 0099 166 _TI = 0x0099 + 0098 167 G$RI$0$0 == 0x0098 + 0098 168 _RI = 0x0098 + 00C8 169 G$T2CON_0$0$0 == 0x00c8 + 00C8 170 _T2CON_0 = 0x00c8 + 00C9 171 G$T2CON_1$0$0 == 0x00c9 + 00C9 172 _T2CON_1 = 0x00c9 + 00CA 173 G$T2CON_2$0$0 == 0x00ca + 00CA 174 _T2CON_2 = 0x00ca + 00CB 175 G$T2CON_3$0$0 == 0x00cb + 00CB 176 _T2CON_3 = 0x00cb + 00CC 177 G$T2CON_4$0$0 == 0x00cc + 00CC 178 _T2CON_4 = 0x00cc + 00CD 179 G$T2CON_5$0$0 == 0x00cd + 00CD 180 _T2CON_5 = 0x00cd + 00CE 181 G$T2CON_6$0$0 == 0x00ce + 00CE 182 _T2CON_6 = 0x00ce + 00CF 183 G$T2CON_7$0$0 == 0x00cf + 00CF 184 _T2CON_7 = 0x00cf + 185 ;-------------------------------------------------------- + 186 ; internal ram data + 187 ;-------------------------------------------------------- + 188 .area DSEG (DATA) + 0000 189 _setjmp_sloc0_1_0: + 0000 190 .ds 0x0003 + 191 ;-------------------------------------------------------- + 192 ; overlayable items in internal ram + 193 ;-------------------------------------------------------- + 194 .area OSEG (OVR,DATA) + 195 ;-------------------------------------------------------- + 196 ; indirectly addressable internal ram data + 197 ;-------------------------------------------------------- + 198 .area ISEG (DATA) + 199 ;-------------------------------------------------------- + 200 ; bit data + 201 ;-------------------------------------------------------- + 202 .area BSEG (BIT) + 203 ;-------------------------------------------------------- + 204 ; external ram data + 205 ;-------------------------------------------------------- + 206 .area XSEG (XDATA) + 0000 207 _longjmp_PARM_2: + 0000 208 .ds 0x0002 + 0002 209 _longjmp_bp_1_1: + 0002 210 .ds 0x0003 + 0005 211 _setjmp_bp_1_1: + 0005 212 .ds 0x0003 + 213 ;-------------------------------------------------------- + 214 ; global & static initialisations + 215 ;-------------------------------------------------------- + 216 .area GSINIT (CODE) + 217 ;-------------------------------------------------------- + 218 ; code + 219 ;-------------------------------------------------------- + 220 .area CSEG (CODE) + 0000 221 G$longjmp$0$0 ==. + 222 ; _setjmp.c 28 + 223 ; ----------------------------------------- + 224 ; function longjmp + 225 ; ----------------------------------------- + 0000 226 _longjmp: + 0002 227 ar2 = 0x02 + 0003 228 ar3 = 0x03 + 0004 229 ar4 = 0x04 + 0005 230 ar5 = 0x05 + 0006 231 ar6 = 0x06 + 0007 232 ar7 = 0x07 + 0000 233 ar0 = 0x00 + 0001 234 ar1 = 0x01 + 235 ; _setjmp.c 35 + 0000 C0 F0 236 push b + 0002 C0 83 237 push dph + 0004 C0 82 238 push dpl + 0006 90s00r02 239 mov dptr,#_longjmp_bp_1_1 + 0009 D0 E0 240 pop acc + 000B F0 241 movx @dptr,a + 000C D0 E0 242 pop acc + 000E A3 243 inc dptr + 000F F0 244 movx @dptr,a + 0010 D0 E0 245 pop acc + 0012 A3 246 inc dptr + 0013 F0 247 movx @dptr,a + 248 ; _setjmp.c 31 + 0014 90s00r02 249 mov dptr,#_longjmp_bp_1_1 + 0017 E0 250 movx a,@dptr + 0018 FA 251 mov r2,a + 0019 A3 252 inc dptr + 001A E0 253 movx a,@dptr + 001B FB 254 mov r3,a + 001C A3 255 inc dptr + 001D E0 256 movx a,@dptr + 001E FC 257 mov r4,a + 001F 74 02 258 mov a,#0x02 + 0021 2A 259 add a,r2 + 0022 F5 82 260 mov dpl,a + 261 ; Peephole 180 changed mov to clr + 0024 E4 262 clr a + 0025 3B 263 addc a,r3 + 0026 F5 83 264 mov dph,a + 0028 8C F0 265 mov b,r4 + 002A 12s00r00 266 lcall __gptrget + 002D FD 267 mov r5,a + 268 ; _setjmp.c 32 + 002E 8D 00 269 mov ar0,r5 + 0030 74 01 270 mov a,#0x01 + 0032 2A 271 add a,r2 + 0033 FE 272 mov r6,a + 273 ; Peephole 180 changed mov to clr + 0034 E4 274 clr a + 0035 3B 275 addc a,r3 + 0036 FF 276 mov r7,a + 0037 8C 01 277 mov ar1,r4 + 0039 90s00r02 278 mov dptr,#_longjmp_bp_1_1 + 003C EE 279 mov a,r6 + 003D F0 280 movx @dptr,a + 003E A3 281 inc dptr + 003F EF 282 mov a,r7 + 0040 F0 283 movx @dptr,a + 0041 A3 284 inc dptr + 0042 E9 285 mov a,r1 + 0043 F0 286 movx @dptr,a + 0044 8A 82 287 mov dpl,r2 + 0046 8B 83 288 mov dph,r3 + 0048 8C F0 289 mov b,r4 + 004A 12s00r00 290 lcall __gptrget + 291 ; Peephole 192 used a instead of ar2 as source + 004D FA 292 mov r2,a + 004E F6 293 mov @r0,a + 294 ; _setjmp.c 33 + 004F 18 295 dec r0 + 0050 8E 82 296 mov dpl,r6 + 0052 8F 83 297 mov dph,r7 + 0054 89 F0 298 mov b,r1 + 0056 12s00r00 299 lcall __gptrget + 300 ; Peephole 192 used a instead of ar6 as source + 0059 FE 301 mov r6,a + 005A F6 302 mov @r0,a + 303 ; _setjmp.c 34 + 005B 8D 81 304 mov _SP,r5 + 305 ; _setjmp.c 35 + 005D 90s00r00 306 mov dptr,#_longjmp_PARM_2 + 0060 E0 307 movx a,@dptr + 0061 FA 308 mov r2,a + 0062 A3 309 inc dptr + 0063 E0 310 movx a,@dptr + 0064 FD 311 mov r5,a + 0065 8A 82 312 mov dpl,r2 + 0067 8D 83 313 mov dph,r5 + 0069 314 00101$: + 0069 315 C$_setjmp.c$36$1$1 ==. + 0069 316 XG$longjmp$0$0 ==. + 0069 22 317 ret + 006A 318 G$setjmp$0$0 ==. + 319 ; _setjmp.c 38 + 320 ; ----------------------------------------- + 321 ; function setjmp + 322 ; ----------------------------------------- + 006A 323 _setjmp: + 324 ; _setjmp.c 0 + 006A C0 F0 325 push b + 006C C0 83 326 push dph + 006E C0 82 327 push dpl + 0070 90s00r05 328 mov dptr,#_setjmp_bp_1_1 + 0073 D0 E0 329 pop acc + 0075 F0 330 movx @dptr,a + 0076 D0 E0 331 pop acc + 0078 A3 332 inc dptr + 0079 F0 333 movx @dptr,a + 007A D0 E0 334 pop acc + 007C A3 335 inc dptr + 007D F0 336 movx @dptr,a + 337 ; _setjmp.c 43 + 007E 90s00r05 338 mov dptr,#_setjmp_bp_1_1 + 0081 E0 339 movx a,@dptr + 0082 FA 340 mov r2,a + 0083 A3 341 inc dptr + 0084 E0 342 movx a,@dptr + 0085 FB 343 mov r3,a + 0086 A3 344 inc dptr + 0087 E0 345 movx a,@dptr + 0088 FC 346 mov r4,a + 0089 74 01 347 mov a,#0x01 + 008B 2A 348 add a,r2 + 008C F5*00 349 mov _setjmp_sloc0_1_0,a + 350 ; Peephole 180 changed mov to clr + 008E E4 351 clr a + 008F 3B 352 addc a,r3 + 0090 F5*01 353 mov (_setjmp_sloc0_1_0 + 1),a + 0092 8C*02 354 mov (_setjmp_sloc0_1_0 + 2),r4 + 0094 A8 81 355 mov r0,_SP + 0096 86 05 356 mov ar5,@r0 + 0098 8A 82 357 mov dpl,r2 + 009A 8B 83 358 mov dph,r3 + 009C 8C F0 359 mov b,r4 + 009E ED 360 mov a,r5 + 009F 12s00r00 361 lcall __gptrput + 362 ; _setjmp.c 44 + 00A2 74 01 363 mov a,#0x01 + 00A4 25*00 364 add a,_setjmp_sloc0_1_0 + 00A6 FA 365 mov r2,a + 366 ; Peephole 180 changed mov to clr + 00A7 E4 367 clr a + 00A8 35*01 368 addc a,(_setjmp_sloc0_1_0 + 1) + 00AA FB 369 mov r3,a + 00AB AC*02 370 mov r4,(_setjmp_sloc0_1_0 + 2) + 00AD 90s00r05 371 mov dptr,#_setjmp_bp_1_1 + 00B0 EA 372 mov a,r2 + 00B1 F0 373 movx @dptr,a + 00B2 A3 374 inc dptr + 00B3 EB 375 mov a,r3 + 00B4 F0 376 movx @dptr,a + 00B5 A3 377 inc dptr + 00B6 EC 378 mov a,r4 + 00B7 F0 379 movx @dptr,a + 00B8 AD 81 380 mov r5,_SP + 00BA ED 381 mov a,r5 + 00BB 24 FF 382 add a,#0xff + 00BD F8 383 mov r0,a + 00BE 86 05 384 mov ar5,@r0 + 00C0 85*00 82 385 mov dpl,_setjmp_sloc0_1_0 + 00C3 85*01 83 386 mov dph,(_setjmp_sloc0_1_0 + 1) + 00C6 85*02 F0 387 mov b,(_setjmp_sloc0_1_0 + 2) + 00C9 ED 388 mov a,r5 + 00CA 12s00r00 389 lcall __gptrput + 390 ; _setjmp.c 45 + 00CD 8A 82 391 mov dpl,r2 + 00CF 8B 83 392 mov dph,r3 + 00D1 8C F0 393 mov b,r4 + 00D3 E5 81 394 mov a,_SP + 00D5 12s00r00 395 lcall __gptrput + 396 ; _setjmp.c 46 + 397 ; Peephole 181 used 16 bit load of dptr + 00D8 90 00 00 398 mov dptr,#0x0000 + 00DB 399 00101$: + 00DB 400 C$_setjmp.c$48$1$1 ==. + 00DB 401 XG$setjmp$0$0 ==. + 00DB 22 402 ret + 403 .area CSEG (CODE) diff --git a/device/lib/_setjmp.sym b/device/lib/_setjmp.sym new file mode 100644 index 00000000..28c18a3d --- /dev/null +++ b/device/lib/_setjmp.sym @@ -0,0 +1,679 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_setjmp$236 0000 GR + 7 A$_setjmp$237 0002 GR + 7 A$_setjmp$238 0004 GR + 7 A$_setjmp$239 0006 GR + 7 A$_setjmp$240 0009 GR + 7 A$_setjmp$241 000B GR + 7 A$_setjmp$242 000C GR + 7 A$_setjmp$243 000E GR + 7 A$_setjmp$244 000F GR + 7 A$_setjmp$245 0010 GR + 7 A$_setjmp$246 0012 GR + 7 A$_setjmp$247 0013 GR + 7 A$_setjmp$249 0014 GR + 7 A$_setjmp$250 0017 GR + 7 A$_setjmp$251 0018 GR + 7 A$_setjmp$252 0019 GR + 7 A$_setjmp$253 001A GR + 7 A$_setjmp$254 001B GR + 7 A$_setjmp$255 001C GR + 7 A$_setjmp$256 001D GR + 7 A$_setjmp$257 001E GR + 7 A$_setjmp$258 001F GR + 7 A$_setjmp$259 0021 GR + 7 A$_setjmp$260 0022 GR + 7 A$_setjmp$262 0024 GR + 7 A$_setjmp$263 0025 GR + 7 A$_setjmp$264 0026 GR + 7 A$_setjmp$265 0028 GR + 7 A$_setjmp$266 002A GR + 7 A$_setjmp$267 002D GR + 7 A$_setjmp$269 002E GR + 7 A$_setjmp$270 0030 GR + 7 A$_setjmp$271 0032 GR + 7 A$_setjmp$272 0033 GR + 7 A$_setjmp$274 0034 GR + 7 A$_setjmp$275 0035 GR + 7 A$_setjmp$276 0036 GR + 7 A$_setjmp$277 0037 GR + 7 A$_setjmp$278 0039 GR + 7 A$_setjmp$279 003C GR + 7 A$_setjmp$280 003D GR + 7 A$_setjmp$281 003E GR + 7 A$_setjmp$282 003F GR + 7 A$_setjmp$283 0040 GR + 7 A$_setjmp$284 0041 GR + 7 A$_setjmp$285 0042 GR + 7 A$_setjmp$286 0043 GR + 7 A$_setjmp$287 0044 GR + 7 A$_setjmp$288 0046 GR + 7 A$_setjmp$289 0048 GR + 7 A$_setjmp$290 004A GR + 7 A$_setjmp$292 004D GR + 7 A$_setjmp$293 004E GR + 7 A$_setjmp$295 004F GR + 7 A$_setjmp$296 0050 GR + 7 A$_setjmp$297 0052 GR + 7 A$_setjmp$298 0054 GR + 7 A$_setjmp$299 0056 GR + 7 A$_setjmp$301 0059 GR + 7 A$_setjmp$302 005A GR + 7 A$_setjmp$304 005B GR + 7 A$_setjmp$306 005D GR + 7 A$_setjmp$307 0060 GR + 7 A$_setjmp$308 0061 GR + 7 A$_setjmp$309 0062 GR + 7 A$_setjmp$310 0063 GR + 7 A$_setjmp$311 0064 GR + 7 A$_setjmp$312 0065 GR + 7 A$_setjmp$313 0067 GR + 7 A$_setjmp$317 0069 GR + 7 A$_setjmp$325 006A GR + 7 A$_setjmp$326 006C GR + 7 A$_setjmp$327 006E GR + 7 A$_setjmp$328 0070 GR + 7 A$_setjmp$329 0073 GR + 7 A$_setjmp$330 0075 GR + 7 A$_setjmp$331 0076 GR + 7 A$_setjmp$332 0078 GR + 7 A$_setjmp$333 0079 GR + 7 A$_setjmp$334 007A GR + 7 A$_setjmp$335 007C GR + 7 A$_setjmp$336 007D GR + 7 A$_setjmp$338 007E GR + 7 A$_setjmp$339 0081 GR + 7 A$_setjmp$340 0082 GR + 7 A$_setjmp$341 0083 GR + 7 A$_setjmp$342 0084 GR + 7 A$_setjmp$343 0085 GR + 7 A$_setjmp$344 0086 GR + 7 A$_setjmp$345 0087 GR + 7 A$_setjmp$346 0088 GR + 7 A$_setjmp$347 0089 GR + 7 A$_setjmp$348 008B GR + 7 A$_setjmp$349 008C GR + 7 A$_setjmp$351 008E GR + 7 A$_setjmp$352 008F GR + 7 A$_setjmp$353 0090 GR + 7 A$_setjmp$354 0092 GR + 7 A$_setjmp$355 0094 GR + 7 A$_setjmp$356 0096 GR + 7 A$_setjmp$357 0098 GR + 7 A$_setjmp$358 009A GR + 7 A$_setjmp$359 009C GR + 7 A$_setjmp$360 009E GR + 7 A$_setjmp$361 009F GR + 7 A$_setjmp$363 00A2 GR + 7 A$_setjmp$364 00A4 GR + 7 A$_setjmp$365 00A6 GR + 7 A$_setjmp$367 00A7 GR + 7 A$_setjmp$368 00A8 GR + 7 A$_setjmp$369 00AA GR + 7 A$_setjmp$370 00AB GR + 7 A$_setjmp$371 00AD GR + 7 A$_setjmp$372 00B0 GR + 7 A$_setjmp$373 00B1 GR + 7 A$_setjmp$374 00B2 GR + 7 A$_setjmp$375 00B3 GR + 7 A$_setjmp$376 00B4 GR + 7 A$_setjmp$377 00B5 GR + 7 A$_setjmp$378 00B6 GR + 7 A$_setjmp$379 00B7 GR + 7 A$_setjmp$380 00B8 GR + 7 A$_setjmp$381 00BA GR + 7 A$_setjmp$382 00BB GR + 7 A$_setjmp$383 00BD GR + 7 A$_setjmp$384 00BE GR + 7 A$_setjmp$385 00C0 GR + 7 A$_setjmp$386 00C3 GR + 7 A$_setjmp$387 00C6 GR + 7 A$_setjmp$388 00C9 GR + 7 A$_setjmp$389 00CA GR + 7 A$_setjmp$391 00CD GR + 7 A$_setjmp$392 00CF GR + 7 A$_setjmp$393 00D1 GR + 7 A$_setjmp$394 00D3 GR + 7 A$_setjmp$395 00D5 GR + 7 A$_setjmp$398 00D8 GR + 7 A$_setjmp$402 00DB GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_setjmp.c$36$1$1 = 0069 GR + 7 C$_setjmp.c$48$1$1 = 00DB GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + G$AC$0$0 = 00D6 G + G$ACC$0$0 = 00E0 G + G$AUXR$0$0 = 008E G + G$B$0$0 = 00F0 G + G$CY$0$0 = 00D7 G + G$DPH$0$0 = 0083 G + G$DPL$0$0 = 0082 G + G$EA$0$0 = 00AF G + G$ES$0$0 = 00AC G + G$ET0$0$0 = 00A9 G + G$ET1$0$0 = 00AB G + G$EX0$0$0 = 00A8 G + G$EX1$0$0 = 00AA G + G$F0$0$0 = 00D5 G + G$IE$0$0 = 00A8 G + G$IE0$0$0 = 0089 G + G$IE1$0$0 = 008B G + G$INT0$0$0 = 00B2 G + G$INT1$0$0 = 00B3 G + G$IP$0$0 = 00B8 G + G$IT0$0$0 = 0088 G + G$IT1$0$0 = 008A G + G$OV$0$0 = 00D2 G + G$P$0$0 = 00D0 G + G$P0$0$0 = 0080 G + G$P1$0$0 = 0090 G + G$P1_0$0$0 = 0090 G + G$P1_1$0$0 = 0091 G + G$P1_2$0$0 = 0092 G + G$P1_3$0$0 = 0093 G + G$P1_4$0$0 = 0094 G + G$P1_5$0$0 = 0095 G + G$P1_6$0$0 = 0096 G + G$P1_7$0$0 = 0097 G + G$P2$0$0 = 00A0 G + G$P3$0$0 = 00B0 G + G$PCON$0$0 = 0087 G + G$PS$0$0 = 00BC G + G$PSW$0$0 = 00D0 G + G$PT0$0$0 = 00B9 G + G$PT1$0$0 = 00BB G + G$PX0$0$0 = 00B8 G + G$PX1$0$0 = 00BA G + G$RB8$0$0 = 009A G + G$RCAP2H$0$0 = 00CB G + G$RCAP2L$0$0 = 00CA G + G$RD$0$0 = 00B7 G + G$REN$0$0 = 009C G + G$RI$0$0 = 0098 G + G$RS0$0$0 = 00D3 G + G$RS1$0$0 = 00D4 G + G$RXD$0$0 = 00B0 G + G$SBUF$0$0 = 0099 G + G$SCON$0$0 = 0098 G + G$SM0$0$0 = 009F G + G$SM1$0$0 = 009E G + G$SM2$0$0 = 009D G + G$SP$0$0 = 0081 G + G$T0$0$0 = 00B4 G + G$T1$0$0 = 00B5 G + G$T2CON$0$0 = 00C8 G + G$T2CON_0$0$0 = 00C8 G + G$T2CON_1$0$0 = 00C9 G + G$T2CON_2$0$0 = 00CA G + G$T2CON_3$0$0 = 00CB G + G$T2CON_4$0$0 = 00CC G + G$T2CON_5$0$0 = 00CD G + G$T2CON_6$0$0 = 00CE G + G$T2CON_7$0$0 = 00CF G + G$TB8$0$0 = 009B G + G$TCON$0$0 = 0088 G + G$TF0$0$0 = 008D G + G$TF1$0$0 = 008F G + G$TH0$0$0 = 008C G + G$TH1$0$0 = 008D G + G$TI$0$0 = 0099 G + G$TL0$0$0 = 008A G + G$TL1$0$0 = 008B G + G$TMOD$0$0 = 0089 G + G$TR0$0$0 = 008C G + G$TR1$0$0 = 008E G + G$TXD$0$0 = 00B1 G + G$WR$0$0 = 00B6 G + 7 G$longjmp$0$0 = 0000 GR + 7 G$setjmp$0$0 = 006A GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$longjmp$0$0 = 0069 GR + 7 XG$setjmp$0$0 = 00DB GR + _AC = 00D6 + _ACC = 00E0 + _AUXR = 008E + _B = 00F0 + _CY = 00D7 + _DPH = 0083 + _DPL = 0082 + _EA = 00AF + _ES = 00AC + _ET0 = 00A9 + _ET1 = 00AB + _EX0 = 00A8 + _EX1 = 00AA + _F0 = 00D5 + _IE = 00A8 + _IE0 = 0089 + _IE1 = 008B + _INT0 = 00B2 + _INT1 = 00B3 + _IP = 00B8 + _IT0 = 0088 + _IT1 = 008A + _OV = 00D2 + _P = 00D0 + _P0 = 0080 + _P1 = 0090 + _P1_0 = 0090 + _P1_1 = 0091 + _P1_2 = 0092 + _P1_3 = 0093 + _P1_4 = 0094 + _P1_5 = 0095 + _P1_6 = 0096 + _P1_7 = 0097 + _P2 = 00A0 + _P3 = 00B0 + _PCON = 0087 + _PS = 00BC + _PSW = 00D0 + _PT0 = 00B9 + _PT1 = 00BB + _PX0 = 00B8 + _PX1 = 00BA + _RB8 = 009A + _RCAP2H = 00CB + _RCAP2L = 00CA + _RD = 00B7 + _REN = 009C + _RI = 0098 + _RS0 = 00D3 + _RS1 = 00D4 + _RXD = 00B0 + _SBUF = 0099 + _SCON = 0098 + _SM0 = 009F + _SM1 = 009E + _SM2 = 009D + _SP = 0081 + _T0 = 00B4 + _T1 = 00B5 + _T2CON = 00C8 + _T2CON_0 = 00C8 + _T2CON_1 = 00C9 + _T2CON_2 = 00CA + _T2CON_3 = 00CB + _T2CON_4 = 00CC + _T2CON_5 = 00CD + _T2CON_6 = 00CE + _T2CON_7 = 00CF + _TB8 = 009B + _TCON = 0088 + _TF0 = 008D + _TF1 = 008F + _TH0 = 008C + _TH1 = 008D + _TI = 0099 + _TL0 = 008A + _TL1 = 008B + _TMOD = 0089 + _TR0 = 008C + _TR1 = 008E + _TXD = 00B1 + _WR = 00B6 + __gptrget **** GX + __gptrput **** GX + 7 _longjmp 0000 GR + 5 _longjmp_PARM_2 0000 GR + 5 _longjmp_bp_1_1 0002 R + 7 _setjmp 006A GR + 5 _setjmp_bp_1_1 0005 R + 1 _setjmp_sloc0_1_0 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 3 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size DC flags 20 diff --git a/device/lib/_spx.c b/device/lib/_spx.c new file mode 100644 index 00000000..07a61e7e --- /dev/null +++ b/device/lib/_spx.c @@ -0,0 +1,26 @@ +/*------------------------------------------------------------------------- + + _spx.c :- just declares bp as a variable + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +data unsigned char spx ; diff --git a/device/lib/_spx.lst b/device/lib/_spx.lst new file mode 100644 index 00000000..eded27c3 --- /dev/null +++ b/device/lib/_spx.lst @@ -0,0 +1,48 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _spx + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _spx + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 G$spx$0$0==. + 0000 22 _spx: + 0000 23 .ds 0x0001 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 40 ;-------------------------------------------------------- + 41 ; global & static initialisations + 42 ;-------------------------------------------------------- + 43 .area GSINIT (CODE) + 44 ;-------------------------------------------------------- + 45 ; code + 46 ;-------------------------------------------------------- + 47 .area CSEG (CODE) + 48 .area CSEG (CODE) diff --git a/device/lib/_spx.sym b/device/lib/_spx.sym new file mode 100644 index 00000000..d8386ad2 --- /dev/null +++ b/device/lib/_spx.sym @@ -0,0 +1,355 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 1 G$spx$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 1 _spx 0000 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 1 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 0 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 0 flags 20 diff --git a/device/lib/_startup.c b/device/lib/_startup.c new file mode 100644 index 00000000..6c4df698 --- /dev/null +++ b/device/lib/_startup.c @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------- + _startup.c - startup routine for sdcc + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +/* External startup code can be written in C + here .. Special usage if this routine + returns a non-zero value then global & + static variable initialisation will be skipped */ + +unsigned char _sdcc_external_startup () +{ + return 0; +} diff --git a/device/lib/_startup.lst b/device/lib/_startup.lst new file mode 100644 index 00000000..ff2e541d --- /dev/null +++ b/device/lib/_startup.lst @@ -0,0 +1,65 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _startup + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __sdcc_external_startup + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 37 ;-------------------------------------------------------- + 38 ; global & static initialisations + 39 ;-------------------------------------------------------- + 40 .area GSINIT (CODE) + 41 ;-------------------------------------------------------- + 42 ; code + 43 ;-------------------------------------------------------- + 44 .area CSEG (CODE) + 0000 45 G$_sdcc_external_startup$0$0 ==. + 46 ; _startup.c 30 + 47 ; ----------------------------------------- + 48 ; function _sdcc_external_startup + 49 ; ----------------------------------------- + 0000 50 __sdcc_external_startup: + 0002 51 ar2 = 0x02 + 0003 52 ar3 = 0x03 + 0004 53 ar4 = 0x04 + 0005 54 ar5 = 0x05 + 0006 55 ar6 = 0x06 + 0007 56 ar7 = 0x07 + 0000 57 ar0 = 0x00 + 0001 58 ar1 = 0x01 + 59 ; _startup.c 32 + 0000 75 82 00 60 mov dpl,#0x00 + 0003 61 00101$: + 0003 62 C$_startup.c$33$1$1 ==. + 0003 63 XG$_sdcc_external_startup$0$0 ==. + 0003 22 64 ret + 65 .area CSEG (CODE) diff --git a/device/lib/_startup.sym b/device/lib/_startup.sym new file mode 100644 index 00000000..dd95fb0c --- /dev/null +++ b/device/lib/_startup.sym @@ -0,0 +1,367 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_startup$60 0000 GR + 7 A$_startup$64 0003 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_startup.c$33$1$1 = 0003 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$_sdcc_external_startup$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_sdcc_external_startup$0$0 = 0003 GR + 7 __sdcc_external_startup 0000 GR + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 0 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 4 flags 20 diff --git a/device/lib/_strcat.c b/device/lib/_strcat.c new file mode 100644 index 00000000..827fdb01 --- /dev/null +++ b/device/lib/_strcat.c @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------- + _strncat.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 +char _generic * strcat ( + char _generic * dst, + char _generic * src + ) +{ + char _generic * cp = dst; + + while( *cp ) + cp++; /* find end of dst */ + + while( *cp++ = *src++ ) ; /* Copy src to end of dst */ + + return( dst ); /* return dst */ + +} diff --git a/device/lib/_strcat.lst b/device/lib/_strcat.lst new file mode 100644 index 00000000..8c67c77f --- /dev/null +++ b/device/lib/_strcat.lst @@ -0,0 +1,162 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:40 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strcat + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strcat_PARM_2 + 11 .globl _strcat + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strcat_sloc0_1_0: + 0000 23 .ds 0x0003 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 _strcat_PARM_2: + 0000 41 .ds 0x0003 + 0003 42 _strcat_dst_1_1: + 0003 43 .ds 0x0003 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$strcat$0$0 ==. + 53 ; _strcat.c 26 + 54 ; ----------------------------------------- + 55 ; function strcat + 56 ; ----------------------------------------- + 0000 57 _strcat: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _strcat.c 38 + 0000 C0 F0 67 push b + 0002 C0 83 68 push dph + 0004 C0 82 69 push dpl + 0006 90s00r03 70 mov dptr,#_strcat_dst_1_1 + 0009 D0 E0 71 pop acc + 000B F0 72 movx @dptr,a + 000C D0 E0 73 pop acc + 000E A3 74 inc dptr + 000F F0 75 movx @dptr,a + 0010 D0 E0 76 pop acc + 0012 A3 77 inc dptr + 0013 F0 78 movx @dptr,a + 79 ; _strcat.c 31 + 0014 90s00r03 80 mov dptr,#_strcat_dst_1_1 + 0017 E0 81 movx a,@dptr + 0018 FA 82 mov r2,a + 0019 A3 83 inc dptr + 001A E0 84 movx a,@dptr + 001B FB 85 mov r3,a + 001C A3 86 inc dptr + 001D E0 87 movx a,@dptr + 001E FC 88 mov r4,a + 89 ; _strcat.c 33 + 001F 90 00101$: + 001F 8A 82 91 mov dpl,r2 + 0021 8B 83 92 mov dph,r3 + 0023 8C F0 93 mov b,r4 + 0025 12s00r00 94 lcall __gptrget + 95 ; Peephole 105 removed redundant mov + 0028 FD 96 mov r5,a + 97 ; Peephole 110 removed ljmp by inverse jump logic + 0029 60 07 98 jz 00111$ + 002B 99 00113$: + 100 ; _strcat.c 34 + 002B 0A 101 inc r2 + 002C BA 00 01 102 cjne r2,#0x00,00114$ + 002F 0B 103 inc r3 + 0030 104 00114$: + 105 ; _strcat.c 36 + 106 ; Peephole 132 changed ljmp to sjmp + 0030 80 ED 107 sjmp 00101$ + 0032 108 00111$: + 0032 90s00r00 109 mov dptr,#_strcat_PARM_2 + 0035 E0 110 movx a,@dptr + 0036 F5*00 111 mov _strcat_sloc0_1_0,a + 0038 A3 112 inc dptr + 0039 E0 113 movx a,@dptr + 003A F5*01 114 mov (_strcat_sloc0_1_0 + 1),a + 003C A3 115 inc dptr + 003D E0 116 movx a,@dptr + 003E F5*02 117 mov (_strcat_sloc0_1_0 + 2),a + 0040 118 00104$: + 0040 8A 00 119 mov ar0,r2 + 0042 8B 01 120 mov ar1,r3 + 0044 8C 05 121 mov ar5,r4 + 0046 0A 122 inc r2 + 0047 BA 00 01 123 cjne r2,#0x00,00115$ + 004A 0B 124 inc r3 + 004B 125 00115$: + 004B 85*00 82 126 mov dpl,_strcat_sloc0_1_0 + 004E 85*01 83 127 mov dph,(_strcat_sloc0_1_0 + 1) + 0051 85*02 F0 128 mov b,(_strcat_sloc0_1_0 + 2) + 0054 05*00 129 inc _strcat_sloc0_1_0 + 0056 E4 130 clr a + 0057 B5*00 02 131 cjne a,_strcat_sloc0_1_0,00116$ + 005A 05*01 132 inc (_strcat_sloc0_1_0 + 1) + 005C 133 00116$: + 005C 12s00r00 134 lcall __gptrget + 135 ; Peephole 190 removed redundant mov + 136 ; Peephole 191 removed redundant mov + 005F FE 137 mov r6,a + 0060 88 82 138 mov dpl,r0 + 0062 89 83 139 mov dph,r1 + 0064 8D F0 140 mov b,r5 + 0066 12s00r00 141 lcall __gptrput + 142 ; Peephole 109 removed ljmp by inverse jump logic + 0069 70 D5 143 jnz 00104$ + 006B 144 00117$: + 145 ; _strcat.c 38 + 006B 90s00r03 146 mov dptr,#_strcat_dst_1_1 + 006E E0 147 movx a,@dptr + 006F FA 148 mov r2,a + 0070 A3 149 inc dptr + 0071 E0 150 movx a,@dptr + 0072 FB 151 mov r3,a + 0073 A3 152 inc dptr + 0074 E0 153 movx a,@dptr + 0075 FC 154 mov r4,a + 0076 8A 82 155 mov dpl,r2 + 0078 8B 83 156 mov dph,r3 + 007A 8C F0 157 mov b,r4 + 007C 158 00107$: + 007C 159 C$_strcat.c$40$1$1 ==. + 007C 160 XG$strcat$0$0 ==. + 007C 22 161 ret + 162 .area CSEG (CODE) diff --git a/device/lib/_strcat.sym b/device/lib/_strcat.sym new file mode 100644 index 00000000..f11de604 --- /dev/null +++ b/device/lib/_strcat.sym @@ -0,0 +1,443 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strcat$101 002B GR + 7 A$_strcat$102 002C GR + 7 A$_strcat$103 002F GR + 7 A$_strcat$107 0030 GR + 7 A$_strcat$109 0032 GR + 7 A$_strcat$110 0035 GR + 7 A$_strcat$111 0036 GR + 7 A$_strcat$112 0038 GR + 7 A$_strcat$113 0039 GR + 7 A$_strcat$114 003A GR + 7 A$_strcat$115 003C GR + 7 A$_strcat$116 003D GR + 7 A$_strcat$117 003E GR + 7 A$_strcat$119 0040 GR + 7 A$_strcat$120 0042 GR + 7 A$_strcat$121 0044 GR + 7 A$_strcat$122 0046 GR + 7 A$_strcat$123 0047 GR + 7 A$_strcat$124 004A GR + 7 A$_strcat$126 004B GR + 7 A$_strcat$127 004E GR + 7 A$_strcat$128 0051 GR + 7 A$_strcat$129 0054 GR + 7 A$_strcat$130 0056 GR + 7 A$_strcat$131 0057 GR + 7 A$_strcat$132 005A GR + 7 A$_strcat$134 005C GR + 7 A$_strcat$137 005F GR + 7 A$_strcat$138 0060 GR + 7 A$_strcat$139 0062 GR + 7 A$_strcat$140 0064 GR + 7 A$_strcat$141 0066 GR + 7 A$_strcat$143 0069 GR + 7 A$_strcat$146 006B GR + 7 A$_strcat$147 006E GR + 7 A$_strcat$148 006F GR + 7 A$_strcat$149 0070 GR + 7 A$_strcat$150 0071 GR + 7 A$_strcat$151 0072 GR + 7 A$_strcat$152 0073 GR + 7 A$_strcat$153 0074 GR + 7 A$_strcat$154 0075 GR + 7 A$_strcat$155 0076 GR + 7 A$_strcat$156 0078 GR + 7 A$_strcat$157 007A GR + 7 A$_strcat$161 007C GR + 7 A$_strcat$67 0000 GR + 7 A$_strcat$68 0002 GR + 7 A$_strcat$69 0004 GR + 7 A$_strcat$70 0006 GR + 7 A$_strcat$71 0009 GR + 7 A$_strcat$72 000B GR + 7 A$_strcat$73 000C GR + 7 A$_strcat$74 000E GR + 7 A$_strcat$75 000F GR + 7 A$_strcat$76 0010 GR + 7 A$_strcat$77 0012 GR + 7 A$_strcat$78 0013 GR + 7 A$_strcat$80 0014 GR + 7 A$_strcat$81 0017 GR + 7 A$_strcat$82 0018 GR + 7 A$_strcat$83 0019 GR + 7 A$_strcat$84 001A GR + 7 A$_strcat$85 001B GR + 7 A$_strcat$86 001C GR + 7 A$_strcat$87 001D GR + 7 A$_strcat$88 001E GR + 7 A$_strcat$91 001F GR + 7 A$_strcat$92 0021 GR + 7 A$_strcat$93 0023 GR + 7 A$_strcat$94 0025 GR + 7 A$_strcat$96 0028 GR + 7 A$_strcat$98 0029 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strcat.c$40$1$1 = 007C GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strcat$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strcat$0$0 = 007C GR + __gptrget **** GX + __gptrput **** GX + 7 _strcat 0000 GR + 5 _strcat_PARM_2 0000 GR + 5 _strcat_dst_1_1 0003 R + 1 _strcat_sloc0_1_0 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 3 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 6 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 7D flags 20 diff --git a/device/lib/_strchr.c b/device/lib/_strchr.c new file mode 100644 index 00000000..58bcb358 --- /dev/null +++ b/device/lib/_strchr.c @@ -0,0 +1,38 @@ +/*------------------------------------------------------------------------- + _strchr.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +char _generic * strchr ( + char _generic * string, + char ch + ) +{ + while (*string && *string != ch) + string++; + + if (*string == ch) + return(string); + return ( NULL ); +} diff --git a/device/lib/_strchr.lst b/device/lib/_strchr.lst new file mode 100644 index 00000000..c91c1677 --- /dev/null +++ b/device/lib/_strchr.lst @@ -0,0 +1,159 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strchr + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strchr_PARM_2 + 11 .globl _strchr + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 _strchr_PARM_2: + 0000 39 .ds 0x0001 + 0001 40 _strchr_string_1_1: + 0001 41 .ds 0x0003 + 42 ;-------------------------------------------------------- + 43 ; global & static initialisations + 44 ;-------------------------------------------------------- + 45 .area GSINIT (CODE) + 46 ;-------------------------------------------------------- + 47 ; code + 48 ;-------------------------------------------------------- + 49 .area CSEG (CODE) + 0000 50 G$strchr$0$0 ==. + 51 ; _strchr.c 27 + 52 ; ----------------------------------------- + 53 ; function strchr + 54 ; ----------------------------------------- + 0000 55 _strchr: + 0002 56 ar2 = 0x02 + 0003 57 ar3 = 0x03 + 0004 58 ar4 = 0x04 + 0005 59 ar5 = 0x05 + 0006 60 ar6 = 0x06 + 0007 61 ar7 = 0x07 + 0000 62 ar0 = 0x00 + 0001 63 ar1 = 0x01 + 64 ; _strchr.c 0 + 0000 C0 F0 65 push b + 0002 C0 83 66 push dph + 0004 C0 82 67 push dpl + 0006 90s00r01 68 mov dptr,#_strchr_string_1_1 + 0009 D0 E0 69 pop acc + 000B F0 70 movx @dptr,a + 000C D0 E0 71 pop acc + 000E A3 72 inc dptr + 000F F0 73 movx @dptr,a + 0010 D0 E0 74 pop acc + 0012 A3 75 inc dptr + 0013 F0 76 movx @dptr,a + 77 ; _strchr.c 32 + 0014 90s00r00 78 mov dptr,#_strchr_PARM_2 + 0017 E0 79 movx a,@dptr + 0018 FA 80 mov r2,a + 0019 90s00r01 81 mov dptr,#_strchr_string_1_1 + 001C E0 82 movx a,@dptr + 001D FB 83 mov r3,a + 001E A3 84 inc dptr + 001F E0 85 movx a,@dptr + 0020 FC 86 mov r4,a + 0021 A3 87 inc dptr + 0022 E0 88 movx a,@dptr + 0023 FD 89 mov r5,a + 0024 90 00102$: + 0024 8B 82 91 mov dpl,r3 + 0026 8C 83 92 mov dph,r4 + 0028 8D F0 93 mov b,r5 + 002A 12s00r00 94 lcall __gptrget + 95 ; Peephole 105 removed redundant mov + 002D FE 96 mov r6,a + 97 ; Peephole 110 removed ljmp by inverse jump logic + 002E 60 18 98 jz 00104$ + 0030 99 00113$: + 0030 EE 100 mov a,r6 + 0031 B5 02 02 101 cjne a,ar2,00114$ + 102 ; Peephole 132 changed ljmp to sjmp + 0034 80 12 103 sjmp 00104$ + 0036 104 00114$: + 105 ; _strchr.c 33 + 0036 0B 106 inc r3 + 0037 BB 00 01 107 cjne r3,#0x00,00115$ + 003A 0C 108 inc r4 + 003B 109 00115$: + 003B 90s00r01 110 mov dptr,#_strchr_string_1_1 + 003E EB 111 mov a,r3 + 003F F0 112 movx @dptr,a + 0040 A3 113 inc dptr + 0041 EC 114 mov a,r4 + 0042 F0 115 movx @dptr,a + 0043 A3 116 inc dptr + 0044 ED 117 mov a,r5 + 0045 F0 118 movx @dptr,a + 119 ; Peephole 132 changed ljmp to sjmp + 0046 80 DC 120 sjmp 00102$ + 0048 121 00104$: + 122 ; _strchr.c 35 + 0048 90s00r01 123 mov dptr,#_strchr_string_1_1 + 004B EB 124 mov a,r3 + 004C F0 125 movx @dptr,a + 004D A3 126 inc dptr + 004E EC 127 mov a,r4 + 004F F0 128 movx @dptr,a + 0050 A3 129 inc dptr + 0051 ED 130 mov a,r5 + 0052 F0 131 movx @dptr,a + 0053 8B 82 132 mov dpl,r3 + 0055 8C 83 133 mov dph,r4 + 0057 8D F0 134 mov b,r5 + 0059 12s00r00 135 lcall __gptrget + 136 ; Peephole 105 removed redundant mov + 005C FE 137 mov r6,a + 138 ; Peephole 132 changed ljmp to sjmp + 139 ; Peephole 199 optimized misc jump sequence + 005D B5 02 08 140 cjne a,ar2,00106$ + 141 ; Peephole 201 removed redundant sjmp + 0060 142 00116$: + 0060 143 00117$: + 144 ; _strchr.c 36 + 0060 8B 82 145 mov dpl,r3 + 0062 8C 83 146 mov dph,r4 + 0064 8D F0 147 mov b,r5 + 148 ; Peephole 132 changed ljmp to sjmp + 0066 80 06 149 sjmp 00107$ + 0068 150 00106$: + 151 ; _strchr.c 37 + 152 ; Peephole 181 used 16 bit load of dptr + 0068 90 00 00 153 mov dptr,#0x0000 + 006B 75 F0 00 154 mov b,#0x00 + 006E 155 00107$: + 006E 156 C$_strchr.c$38$1$1 ==. + 006E 157 XG$strchr$0$0 ==. + 006E 22 158 ret + 159 .area CSEG (CODE) diff --git a/device/lib/_strchr.sym b/device/lib/_strchr.sym new file mode 100644 index 00000000..287316b1 --- /dev/null +++ b/device/lib/_strchr.sym @@ -0,0 +1,436 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strchr$100 0030 GR + 7 A$_strchr$101 0031 GR + 7 A$_strchr$103 0034 GR + 7 A$_strchr$106 0036 GR + 7 A$_strchr$107 0037 GR + 7 A$_strchr$108 003A GR + 7 A$_strchr$110 003B GR + 7 A$_strchr$111 003E GR + 7 A$_strchr$112 003F GR + 7 A$_strchr$113 0040 GR + 7 A$_strchr$114 0041 GR + 7 A$_strchr$115 0042 GR + 7 A$_strchr$116 0043 GR + 7 A$_strchr$117 0044 GR + 7 A$_strchr$118 0045 GR + 7 A$_strchr$120 0046 GR + 7 A$_strchr$123 0048 GR + 7 A$_strchr$124 004B GR + 7 A$_strchr$125 004C GR + 7 A$_strchr$126 004D GR + 7 A$_strchr$127 004E GR + 7 A$_strchr$128 004F GR + 7 A$_strchr$129 0050 GR + 7 A$_strchr$130 0051 GR + 7 A$_strchr$131 0052 GR + 7 A$_strchr$132 0053 GR + 7 A$_strchr$133 0055 GR + 7 A$_strchr$134 0057 GR + 7 A$_strchr$135 0059 GR + 7 A$_strchr$137 005C GR + 7 A$_strchr$140 005D GR + 7 A$_strchr$145 0060 GR + 7 A$_strchr$146 0062 GR + 7 A$_strchr$147 0064 GR + 7 A$_strchr$149 0066 GR + 7 A$_strchr$153 0068 GR + 7 A$_strchr$154 006B GR + 7 A$_strchr$158 006E GR + 7 A$_strchr$65 0000 GR + 7 A$_strchr$66 0002 GR + 7 A$_strchr$67 0004 GR + 7 A$_strchr$68 0006 GR + 7 A$_strchr$69 0009 GR + 7 A$_strchr$70 000B GR + 7 A$_strchr$71 000C GR + 7 A$_strchr$72 000E GR + 7 A$_strchr$73 000F GR + 7 A$_strchr$74 0010 GR + 7 A$_strchr$75 0012 GR + 7 A$_strchr$76 0013 GR + 7 A$_strchr$78 0014 GR + 7 A$_strchr$79 0017 GR + 7 A$_strchr$80 0018 GR + 7 A$_strchr$81 0019 GR + 7 A$_strchr$82 001C GR + 7 A$_strchr$83 001D GR + 7 A$_strchr$84 001E GR + 7 A$_strchr$85 001F GR + 7 A$_strchr$86 0020 GR + 7 A$_strchr$87 0021 GR + 7 A$_strchr$88 0022 GR + 7 A$_strchr$89 0023 GR + 7 A$_strchr$91 0024 GR + 7 A$_strchr$92 0026 GR + 7 A$_strchr$93 0028 GR + 7 A$_strchr$94 002A GR + 7 A$_strchr$96 002D GR + 7 A$_strchr$98 002E GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strchr.c$38$1$1 = 006E GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strchr$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strchr$0$0 = 006E GR + __gptrget **** GX + 7 _strchr 0000 GR + 5 _strchr_PARM_2 0000 GR + 5 _strchr_string_1_1 0001 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 4 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 6F flags 20 diff --git a/device/lib/_strcmp.c b/device/lib/_strcmp.c new file mode 100644 index 00000000..fbf56537 --- /dev/null +++ b/device/lib/_strcmp.c @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------- + _strcmp.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +int strcmp ( + char _generic *src, + char _generic *dst + ) +{ + register int ret = 0 ; + + while( ! (ret = *src - *dst) && *dst) + ++src, ++dst; + + if ( ret < 0 ) + ret = -1 ; + else if ( ret > 0 ) + ret = 1 ; + + return( ret ); +} diff --git a/device/lib/_strcmp.lst b/device/lib/_strcmp.lst new file mode 100644 index 00000000..c35749f1 --- /dev/null +++ b/device/lib/_strcmp.lst @@ -0,0 +1,217 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strcmp + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strcmp_PARM_2 + 11 .globl _strcmp + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strcmp_sloc0_1_0: + 0000 23 .ds 0x0001 + 0001 24 _strcmp_sloc1_1_0: + 0001 25 .ds 0x0003 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 _strcmp_PARM_2: + 0000 43 .ds 0x0003 + 0003 44 _strcmp_src_1_1: + 0003 45 .ds 0x0003 + 0006 46 _strcmp_ret_1_1: + 0006 47 .ds 0x0002 + 48 ;-------------------------------------------------------- + 49 ; global & static initialisations + 50 ;-------------------------------------------------------- + 51 .area GSINIT (CODE) + 52 ;-------------------------------------------------------- + 53 ; code + 54 ;-------------------------------------------------------- + 55 .area CSEG (CODE) + 0000 56 G$strcmp$0$0 ==. + 57 ; _strcmp.c 27 + 58 ; ----------------------------------------- + 59 ; function strcmp + 60 ; ----------------------------------------- + 0000 61 _strcmp: + 0002 62 ar2 = 0x02 + 0003 63 ar3 = 0x03 + 0004 64 ar4 = 0x04 + 0005 65 ar5 = 0x05 + 0006 66 ar6 = 0x06 + 0007 67 ar7 = 0x07 + 0000 68 ar0 = 0x00 + 0001 69 ar1 = 0x01 + 70 ; _strcmp.c 42 + 0000 C0 F0 71 push b + 0002 C0 83 72 push dph + 0004 C0 82 73 push dpl + 0006 90s00r03 74 mov dptr,#_strcmp_src_1_1 + 0009 D0 E0 75 pop acc + 000B F0 76 movx @dptr,a + 000C D0 E0 77 pop acc + 000E A3 78 inc dptr + 000F F0 79 movx @dptr,a + 0010 D0 E0 80 pop acc + 0012 A3 81 inc dptr + 0013 F0 82 movx @dptr,a + 83 ; _strcmp.c 34 + 0014 90s00r03 84 mov dptr,#_strcmp_src_1_1 + 0017 E0 85 movx a,@dptr + 0018 FA 86 mov r2,a + 0019 A3 87 inc dptr + 001A E0 88 movx a,@dptr + 001B FB 89 mov r3,a + 001C A3 90 inc dptr + 001D E0 91 movx a,@dptr + 001E FC 92 mov r4,a + 001F 90s00r00 93 mov dptr,#_strcmp_PARM_2 + 0022 E0 94 movx a,@dptr + 0023 F5*01 95 mov _strcmp_sloc1_1_0,a + 0025 A3 96 inc dptr + 0026 E0 97 movx a,@dptr + 0027 F5*02 98 mov (_strcmp_sloc1_1_0 + 1),a + 0029 A3 99 inc dptr + 002A E0 100 movx a,@dptr + 002B F5*03 101 mov (_strcmp_sloc1_1_0 + 2),a + 002D 102 00102$: + 002D 85*01 82 103 mov dpl,_strcmp_sloc1_1_0 + 0030 85*02 83 104 mov dph,(_strcmp_sloc1_1_0 + 1) + 0033 85*03 F0 105 mov b,(_strcmp_sloc1_1_0 + 2) + 0036 12s00r00 106 lcall __gptrget + 0039 F5*00 107 mov _strcmp_sloc0_1_0,a + 003B 8A 82 108 mov dpl,r2 + 003D 8B 83 109 mov dph,r3 + 003F 8C F0 110 mov b,r4 + 0041 12s00r00 111 lcall __gptrget + 112 ; Peephole 106 removed redundant mov + 0044 F9 113 mov r1,a + 0045 C3 114 clr c + 0046 95*00 115 subb a,_strcmp_sloc0_1_0 + 116 ; Peephole 166 removed redundant mov + 0048 F9 117 mov r1,a + 0049 89 00 118 mov ar0,r1 + 004B 33 119 rlc a + 004C 95 E0 120 subb a,acc + 004E FD 121 mov r5,a + 004F 90s00r06 122 mov dptr,#_strcmp_ret_1_1 + 0052 E8 123 mov a,r0 + 0053 F0 124 movx @dptr,a + 0054 A3 125 inc dptr + 0055 ED 126 mov a,r5 + 0056 F0 127 movx @dptr,a + 0057 E9 128 mov a,r1 + 129 ; Peephole 109 removed ljmp by inverse jump logic + 0058 70 1E 130 jnz 00104$ + 005A 131 00117$: + 005A E5*00 132 mov a,_strcmp_sloc0_1_0 + 133 ; Peephole 110 removed ljmp by inverse jump logic + 005C 60 1A 134 jz 00104$ + 005E 135 00118$: + 136 ; _strcmp.c 35 + 005E 0A 137 inc r2 + 005F BA 00 01 138 cjne r2,#0x00,00119$ + 0062 0B 139 inc r3 + 0063 140 00119$: + 0063 90s00r03 141 mov dptr,#_strcmp_src_1_1 + 0066 EA 142 mov a,r2 + 0067 F0 143 movx @dptr,a + 0068 A3 144 inc dptr + 0069 EB 145 mov a,r3 + 006A F0 146 movx @dptr,a + 006B A3 147 inc dptr + 006C EC 148 mov a,r4 + 006D F0 149 movx @dptr,a + 006E 05*01 150 inc _strcmp_sloc1_1_0 + 0070 E4 151 clr a + 0071 B5*01 02 152 cjne a,_strcmp_sloc1_1_0,00120$ + 0074 05*02 153 inc (_strcmp_sloc1_1_0 + 1) + 0076 154 00120$: + 155 ; Peephole 132 changed ljmp to sjmp + 0076 80 B5 156 sjmp 00102$ + 0078 157 00104$: + 158 ; _strcmp.c 37 + 0078 90s00r03 159 mov dptr,#_strcmp_src_1_1 + 007B EA 160 mov a,r2 + 007C F0 161 movx @dptr,a + 007D A3 162 inc dptr + 007E EB 163 mov a,r3 + 007F F0 164 movx @dptr,a + 0080 A3 165 inc dptr + 0081 EC 166 mov a,r4 + 0082 F0 167 movx @dptr,a + 0083 ED 168 mov a,r5 + 169 ; Peephole 111 removed ljmp by inverse jump logic + 0084 30 E7 0A 170 jnb acc.7,00108$ + 0087 171 00121$: + 172 ; _strcmp.c 38 + 0087 90s00r06 173 mov dptr,#_strcmp_ret_1_1 + 174 ; Peephole 101 removed redundant mov + 008A 74 FF 175 mov a,#0xff + 008C F0 176 movx @dptr,a + 008D A3 177 inc dptr + 008E F0 178 movx @dptr,a + 179 ; Peephole 132 changed ljmp to sjmp + 008F 80 1A 180 sjmp 00109$ + 0091 181 00108$: + 182 ; _strcmp.c 39 + 0091 C3 183 clr c + 184 ; Peephole 180 changed mov to clr + 0092 E4 185 clr a + 0093 98 186 subb a,r0 + 187 ; Peephole 159 avoided xrl during execution + 0094 74 80 188 mov a,#(0x00 ^ 0x80) + 0096 8D F0 189 mov b,r5 + 0098 63 F0 80 190 xrl b,#0x80 + 009B 95 F0 191 subb a,b + 192 ; Peephole 108 removed ljmp by inverse jump logic + 009D 50 0C 193 jnc 00109$ + 009F 194 00122$: + 195 ; _strcmp.c 40 + 009F 90s00r06 196 mov dptr,#_strcmp_ret_1_1 + 00A2 E4 197 clr a + 00A3 A3 198 inc dptr + 00A4 F0 199 movx @dptr,a + 00A5 12s00r00 200 lcall __decdptr + 00A8 74 01 201 mov a,#0x01 + 00AA F0 202 movx @dptr,a + 00AB 203 00109$: + 204 ; _strcmp.c 42 + 00AB 90s00r06 205 mov dptr,#_strcmp_ret_1_1 + 00AE E0 206 movx a,@dptr + 00AF FA 207 mov r2,a + 00B0 A3 208 inc dptr + 00B1 E0 209 movx a,@dptr + 00B2 FB 210 mov r3,a + 00B3 8A 82 211 mov dpl,r2 + 00B5 8B 83 212 mov dph,r3 + 00B7 213 00110$: + 00B7 214 C$_strcmp.c$43$1$1 ==. + 00B7 215 XG$strcmp$0$0 ==. + 00B7 22 216 ret + 217 .area CSEG (CODE) diff --git a/device/lib/_strcmp.sym b/device/lib/_strcmp.sym new file mode 100644 index 00000000..bd519774 --- /dev/null +++ b/device/lib/_strcmp.sym @@ -0,0 +1,487 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strcmp$100 002A GR + 7 A$_strcmp$101 002B GR + 7 A$_strcmp$103 002D GR + 7 A$_strcmp$104 0030 GR + 7 A$_strcmp$105 0033 GR + 7 A$_strcmp$106 0036 GR + 7 A$_strcmp$107 0039 GR + 7 A$_strcmp$108 003B GR + 7 A$_strcmp$109 003D GR + 7 A$_strcmp$110 003F GR + 7 A$_strcmp$111 0041 GR + 7 A$_strcmp$113 0044 GR + 7 A$_strcmp$114 0045 GR + 7 A$_strcmp$115 0046 GR + 7 A$_strcmp$117 0048 GR + 7 A$_strcmp$118 0049 GR + 7 A$_strcmp$119 004B GR + 7 A$_strcmp$120 004C GR + 7 A$_strcmp$121 004E GR + 7 A$_strcmp$122 004F GR + 7 A$_strcmp$123 0052 GR + 7 A$_strcmp$124 0053 GR + 7 A$_strcmp$125 0054 GR + 7 A$_strcmp$126 0055 GR + 7 A$_strcmp$127 0056 GR + 7 A$_strcmp$128 0057 GR + 7 A$_strcmp$130 0058 GR + 7 A$_strcmp$132 005A GR + 7 A$_strcmp$134 005C GR + 7 A$_strcmp$137 005E GR + 7 A$_strcmp$138 005F GR + 7 A$_strcmp$139 0062 GR + 7 A$_strcmp$141 0063 GR + 7 A$_strcmp$142 0066 GR + 7 A$_strcmp$143 0067 GR + 7 A$_strcmp$144 0068 GR + 7 A$_strcmp$145 0069 GR + 7 A$_strcmp$146 006A GR + 7 A$_strcmp$147 006B GR + 7 A$_strcmp$148 006C GR + 7 A$_strcmp$149 006D GR + 7 A$_strcmp$150 006E GR + 7 A$_strcmp$151 0070 GR + 7 A$_strcmp$152 0071 GR + 7 A$_strcmp$153 0074 GR + 7 A$_strcmp$156 0076 GR + 7 A$_strcmp$159 0078 GR + 7 A$_strcmp$160 007B GR + 7 A$_strcmp$161 007C GR + 7 A$_strcmp$162 007D GR + 7 A$_strcmp$163 007E GR + 7 A$_strcmp$164 007F GR + 7 A$_strcmp$165 0080 GR + 7 A$_strcmp$166 0081 GR + 7 A$_strcmp$167 0082 GR + 7 A$_strcmp$168 0083 GR + 7 A$_strcmp$170 0084 GR + 7 A$_strcmp$173 0087 GR + 7 A$_strcmp$175 008A GR + 7 A$_strcmp$176 008C GR + 7 A$_strcmp$177 008D GR + 7 A$_strcmp$178 008E GR + 7 A$_strcmp$180 008F GR + 7 A$_strcmp$183 0091 GR + 7 A$_strcmp$185 0092 GR + 7 A$_strcmp$186 0093 GR + 7 A$_strcmp$188 0094 GR + 7 A$_strcmp$189 0096 GR + 7 A$_strcmp$190 0098 GR + 7 A$_strcmp$191 009B GR + 7 A$_strcmp$193 009D GR + 7 A$_strcmp$196 009F GR + 7 A$_strcmp$197 00A2 GR + 7 A$_strcmp$198 00A3 GR + 7 A$_strcmp$199 00A4 GR + 7 A$_strcmp$200 00A5 GR + 7 A$_strcmp$201 00A8 GR + 7 A$_strcmp$202 00AA GR + 7 A$_strcmp$205 00AB GR + 7 A$_strcmp$206 00AE GR + 7 A$_strcmp$207 00AF GR + 7 A$_strcmp$208 00B0 GR + 7 A$_strcmp$209 00B1 GR + 7 A$_strcmp$210 00B2 GR + 7 A$_strcmp$211 00B3 GR + 7 A$_strcmp$212 00B5 GR + 7 A$_strcmp$216 00B7 GR + 7 A$_strcmp$71 0000 GR + 7 A$_strcmp$72 0002 GR + 7 A$_strcmp$73 0004 GR + 7 A$_strcmp$74 0006 GR + 7 A$_strcmp$75 0009 GR + 7 A$_strcmp$76 000B GR + 7 A$_strcmp$77 000C GR + 7 A$_strcmp$78 000E GR + 7 A$_strcmp$79 000F GR + 7 A$_strcmp$80 0010 GR + 7 A$_strcmp$81 0012 GR + 7 A$_strcmp$82 0013 GR + 7 A$_strcmp$84 0014 GR + 7 A$_strcmp$85 0017 GR + 7 A$_strcmp$86 0018 GR + 7 A$_strcmp$87 0019 GR + 7 A$_strcmp$88 001A GR + 7 A$_strcmp$89 001B GR + 7 A$_strcmp$90 001C GR + 7 A$_strcmp$91 001D GR + 7 A$_strcmp$92 001E GR + 7 A$_strcmp$93 001F GR + 7 A$_strcmp$94 0022 GR + 7 A$_strcmp$95 0023 GR + 7 A$_strcmp$96 0025 GR + 7 A$_strcmp$97 0026 GR + 7 A$_strcmp$98 0027 GR + 7 A$_strcmp$99 0029 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strcmp.c$43$1$1 = 00B7 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strcmp$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strcmp$0$0 = 00B7 GR + __decdptr **** GX + __gptrget **** GX + 7 _strcmp 0000 GR + 5 _strcmp_PARM_2 0000 GR + 5 _strcmp_ret_1_1 0006 R + 1 _strcmp_sloc0_1_0 0000 R + 1 _strcmp_sloc1_1_0 0001 R + 5 _strcmp_src_1_1 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 4 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size B8 flags 20 diff --git a/device/lib/_strcpy.c b/device/lib/_strcpy.c new file mode 100644 index 00000000..40437caa --- /dev/null +++ b/device/lib/_strcpy.c @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------- + _strcpy.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +char _generic *strcpy ( + char _generic *d, + char _generic *s) +{ + register char _generic *d1 = d; + + while (*d1++ = *s++) ; + + return d; +} diff --git a/device/lib/_strcpy.lst b/device/lib/_strcpy.lst new file mode 100644 index 00000000..87292175 --- /dev/null +++ b/device/lib/_strcpy.lst @@ -0,0 +1,143 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strcpy + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strcpy_PARM_2 + 11 .globl _strcpy + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strcpy_sloc0_1_0: + 0000 23 .ds 0x0003 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 _strcpy_PARM_2: + 0000 41 .ds 0x0003 + 0003 42 _strcpy_d_1_1: + 0003 43 .ds 0x0003 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$strcpy$0$0 ==. + 53 ; _strcpy.c 27 + 54 ; ----------------------------------------- + 55 ; function strcpy + 56 ; ----------------------------------------- + 0000 57 _strcpy: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _strcpy.c 35 + 0000 C0 F0 67 push b + 0002 C0 83 68 push dph + 0004 C0 82 69 push dpl + 0006 90s00r03 70 mov dptr,#_strcpy_d_1_1 + 0009 D0 E0 71 pop acc + 000B F0 72 movx @dptr,a + 000C D0 E0 73 pop acc + 000E A3 74 inc dptr + 000F F0 75 movx @dptr,a + 0010 D0 E0 76 pop acc + 0012 A3 77 inc dptr + 0013 F0 78 movx @dptr,a + 79 ; _strcpy.c 31 + 0014 90s00r03 80 mov dptr,#_strcpy_d_1_1 + 0017 E0 81 movx a,@dptr + 0018 FA 82 mov r2,a + 0019 A3 83 inc dptr + 001A E0 84 movx a,@dptr + 001B FB 85 mov r3,a + 001C A3 86 inc dptr + 001D E0 87 movx a,@dptr + 001E FC 88 mov r4,a + 89 ; _strcpy.c 33 + 001F 90s00r00 90 mov dptr,#_strcpy_PARM_2 + 0022 E0 91 movx a,@dptr + 0023 F5*00 92 mov _strcpy_sloc0_1_0,a + 0025 A3 93 inc dptr + 0026 E0 94 movx a,@dptr + 0027 F5*01 95 mov (_strcpy_sloc0_1_0 + 1),a + 0029 A3 96 inc dptr + 002A E0 97 movx a,@dptr + 002B F5*02 98 mov (_strcpy_sloc0_1_0 + 2),a + 002D 99 00101$: + 002D 8A 00 100 mov ar0,r2 + 002F 8B 01 101 mov ar1,r3 + 0031 8C 05 102 mov ar5,r4 + 0033 0A 103 inc r2 + 0034 BA 00 01 104 cjne r2,#0x00,00108$ + 0037 0B 105 inc r3 + 0038 106 00108$: + 0038 85*00 82 107 mov dpl,_strcpy_sloc0_1_0 + 003B 85*01 83 108 mov dph,(_strcpy_sloc0_1_0 + 1) + 003E 85*02 F0 109 mov b,(_strcpy_sloc0_1_0 + 2) + 0041 05*00 110 inc _strcpy_sloc0_1_0 + 0043 E4 111 clr a + 0044 B5*00 02 112 cjne a,_strcpy_sloc0_1_0,00109$ + 0047 05*01 113 inc (_strcpy_sloc0_1_0 + 1) + 0049 114 00109$: + 0049 12s00r00 115 lcall __gptrget + 116 ; Peephole 190 removed redundant mov + 117 ; Peephole 191 removed redundant mov + 004C FE 118 mov r6,a + 004D 88 82 119 mov dpl,r0 + 004F 89 83 120 mov dph,r1 + 0051 8D F0 121 mov b,r5 + 0053 12s00r00 122 lcall __gptrput + 123 ; Peephole 109 removed ljmp by inverse jump logic + 0056 70 D5 124 jnz 00101$ + 0058 125 00110$: + 126 ; _strcpy.c 35 + 0058 90s00r03 127 mov dptr,#_strcpy_d_1_1 + 005B E0 128 movx a,@dptr + 005C FA 129 mov r2,a + 005D A3 130 inc dptr + 005E E0 131 movx a,@dptr + 005F FB 132 mov r3,a + 0060 A3 133 inc dptr + 0061 E0 134 movx a,@dptr + 0062 FC 135 mov r4,a + 0063 8A 82 136 mov dpl,r2 + 0065 8B 83 137 mov dph,r3 + 0067 8C F0 138 mov b,r4 + 0069 139 00104$: + 0069 140 C$_strcpy.c$36$1$1 ==. + 0069 141 XG$strcpy$0$0 ==. + 0069 22 142 ret + 143 .area CSEG (CODE) diff --git a/device/lib/_strcpy.sym b/device/lib/_strcpy.sym new file mode 100644 index 00000000..3fed90b8 --- /dev/null +++ b/device/lib/_strcpy.sym @@ -0,0 +1,433 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strcpy$100 002D GR + 7 A$_strcpy$101 002F GR + 7 A$_strcpy$102 0031 GR + 7 A$_strcpy$103 0033 GR + 7 A$_strcpy$104 0034 GR + 7 A$_strcpy$105 0037 GR + 7 A$_strcpy$107 0038 GR + 7 A$_strcpy$108 003B GR + 7 A$_strcpy$109 003E GR + 7 A$_strcpy$110 0041 GR + 7 A$_strcpy$111 0043 GR + 7 A$_strcpy$112 0044 GR + 7 A$_strcpy$113 0047 GR + 7 A$_strcpy$115 0049 GR + 7 A$_strcpy$118 004C GR + 7 A$_strcpy$119 004D GR + 7 A$_strcpy$120 004F GR + 7 A$_strcpy$121 0051 GR + 7 A$_strcpy$122 0053 GR + 7 A$_strcpy$124 0056 GR + 7 A$_strcpy$127 0058 GR + 7 A$_strcpy$128 005B GR + 7 A$_strcpy$129 005C GR + 7 A$_strcpy$130 005D GR + 7 A$_strcpy$131 005E GR + 7 A$_strcpy$132 005F GR + 7 A$_strcpy$133 0060 GR + 7 A$_strcpy$134 0061 GR + 7 A$_strcpy$135 0062 GR + 7 A$_strcpy$136 0063 GR + 7 A$_strcpy$137 0065 GR + 7 A$_strcpy$138 0067 GR + 7 A$_strcpy$142 0069 GR + 7 A$_strcpy$67 0000 GR + 7 A$_strcpy$68 0002 GR + 7 A$_strcpy$69 0004 GR + 7 A$_strcpy$70 0006 GR + 7 A$_strcpy$71 0009 GR + 7 A$_strcpy$72 000B GR + 7 A$_strcpy$73 000C GR + 7 A$_strcpy$74 000E GR + 7 A$_strcpy$75 000F GR + 7 A$_strcpy$76 0010 GR + 7 A$_strcpy$77 0012 GR + 7 A$_strcpy$78 0013 GR + 7 A$_strcpy$80 0014 GR + 7 A$_strcpy$81 0017 GR + 7 A$_strcpy$82 0018 GR + 7 A$_strcpy$83 0019 GR + 7 A$_strcpy$84 001A GR + 7 A$_strcpy$85 001B GR + 7 A$_strcpy$86 001C GR + 7 A$_strcpy$87 001D GR + 7 A$_strcpy$88 001E GR + 7 A$_strcpy$90 001F GR + 7 A$_strcpy$91 0022 GR + 7 A$_strcpy$92 0023 GR + 7 A$_strcpy$93 0025 GR + 7 A$_strcpy$94 0026 GR + 7 A$_strcpy$95 0027 GR + 7 A$_strcpy$96 0029 GR + 7 A$_strcpy$97 002A GR + 7 A$_strcpy$98 002B GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strcpy.c$36$1$1 = 0069 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strcpy$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strcpy$0$0 = 0069 GR + __gptrget **** GX + __gptrput **** GX + 7 _strcpy 0000 GR + 5 _strcpy_PARM_2 0000 GR + 5 _strcpy_d_1_1 0003 R + 1 _strcpy_sloc0_1_0 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 3 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 6 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 6A flags 20 diff --git a/device/lib/_strcspn.c b/device/lib/_strcspn.c new file mode 100644 index 00000000..cc03e8f5 --- /dev/null +++ b/device/lib/_strcspn.c @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------- + _strcspn.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +int strcspn ( + char _generic * string , + char _generic * control + ) +{ + register int count = 0 ; + register char ch ; + + while (ch = *string) { + if (strchr(control,ch)) + break; + else + count++ ; + } + + return count ; +} diff --git a/device/lib/_strcspn.lst b/device/lib/_strcspn.lst new file mode 100644 index 00000000..d4ff3871 --- /dev/null +++ b/device/lib/_strcspn.lst @@ -0,0 +1,152 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strcspn + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strcspn_PARM_2 + 11 .globl _strcspn + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strcspn_sloc0_1_0: + 0000 23 .ds 0x0003 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 _strcspn_PARM_2: + 0000 41 .ds 0x0003 + 0003 42 _strcspn_string_1_1: + 0003 43 .ds 0x0003 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$strcspn$0$0 ==. + 53 ; _strcspn.c 27 + 54 ; ----------------------------------------- + 55 ; function strcspn + 56 ; ----------------------------------------- + 0000 57 _strcspn: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _strcspn.c 42 + 0000 C0 F0 67 push b + 0002 C0 83 68 push dph + 0004 C0 82 69 push dpl + 0006 90s00r03 70 mov dptr,#_strcspn_string_1_1 + 0009 D0 E0 71 pop acc + 000B F0 72 movx @dptr,a + 000C D0 E0 73 pop acc + 000E A3 74 inc dptr + 000F F0 75 movx @dptr,a + 0010 D0 E0 76 pop acc + 0012 A3 77 inc dptr + 0013 F0 78 movx @dptr,a + 79 ; _strcspn.c 35 + 0014 90s00r00 80 mov dptr,#_strcspn_PARM_2 + 0017 E0 81 movx a,@dptr + 0018 F5*00 82 mov _strcspn_sloc0_1_0,a + 001A A3 83 inc dptr + 001B E0 84 movx a,@dptr + 001C F5*01 85 mov (_strcspn_sloc0_1_0 + 1),a + 001E A3 86 inc dptr + 001F E0 87 movx a,@dptr + 0020 F5*02 88 mov (_strcspn_sloc0_1_0 + 2),a + 0022 90s00r03 89 mov dptr,#_strcspn_string_1_1 + 0025 E0 90 movx a,@dptr + 0026 FD 91 mov r5,a + 0027 A3 92 inc dptr + 0028 E0 93 movx a,@dptr + 0029 FE 94 mov r6,a + 002A A3 95 inc dptr + 002B E0 96 movx a,@dptr + 002C FF 97 mov r7,a + 002D 78 00 98 mov r0,#0x00 + 002F 79 00 99 mov r1,#0x00 + 0031 100 00104$: + 0031 8D 82 101 mov dpl,r5 + 0033 8E 83 102 mov dph,r6 + 0035 8F F0 103 mov b,r7 + 0037 12s00r00 104 lcall __gptrget + 105 ; Peephole 105 removed redundant mov + 003A FA 106 mov r2,a + 107 ; Peephole 110 removed ljmp by inverse jump logic + 003B 60 37 108 jz 00106$ + 003D 109 00112$: + 110 ; _strcspn.c 36 + 003D 90s00r00 111 mov dptr,#_strchr_PARM_2 + 0040 EA 112 mov a,r2 + 0041 F0 113 movx @dptr,a + 0042 C0 05 114 push ar5 + 0044 C0 06 115 push ar6 + 0046 C0 07 116 push ar7 + 0048 C0 00 117 push ar0 + 004A C0 01 118 push ar1 + 004C 85*00 82 119 mov dpl,_strcspn_sloc0_1_0 + 004F 85*01 83 120 mov dph,(_strcspn_sloc0_1_0 + 1) + 0052 85*02 F0 121 mov b,(_strcspn_sloc0_1_0 + 2) + 0055 12s00r00 122 lcall _strchr + 0058 AA 82 123 mov r2,dpl + 005A AB 83 124 mov r3,dph + 005C AC F0 125 mov r4,b + 005E D0 01 126 pop ar1 + 0060 D0 00 127 pop ar0 + 0062 D0 07 128 pop ar7 + 0064 D0 06 129 pop ar6 + 0066 D0 05 130 pop ar5 + 0068 EA 131 mov a,r2 + 0069 4B 132 orl a,r3 + 006A 4C 133 orl a,r4 + 134 ; Peephole 109 removed ljmp by inverse jump logic + 006B 70 07 135 jnz 00106$ + 006D 136 00113$: + 137 ; _strcspn.c 39 + 006D 08 138 inc r0 + 006E B8 00 01 139 cjne r0,#0x00,00114$ + 0071 09 140 inc r1 + 0072 141 00114$: + 142 ; Peephole 132 changed ljmp to sjmp + 0072 80 BD 143 sjmp 00104$ + 0074 144 00106$: + 145 ; _strcspn.c 42 + 0074 88 82 146 mov dpl,r0 + 0076 89 83 147 mov dph,r1 + 0078 148 00107$: + 0078 149 C$_strcspn.c$43$1$1 ==. + 0078 150 XG$strcspn$0$0 ==. + 0078 22 151 ret + 152 .area CSEG (CODE) diff --git a/device/lib/_strcspn.sym b/device/lib/_strcspn.sym new file mode 100644 index 00000000..f8f2baaa --- /dev/null +++ b/device/lib/_strcspn.sym @@ -0,0 +1,440 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strcspn$101 0031 GR + 7 A$_strcspn$102 0033 GR + 7 A$_strcspn$103 0035 GR + 7 A$_strcspn$104 0037 GR + 7 A$_strcspn$106 003A GR + 7 A$_strcspn$108 003B GR + 7 A$_strcspn$111 003D GR + 7 A$_strcspn$112 0040 GR + 7 A$_strcspn$113 0041 GR + 7 A$_strcspn$114 0042 GR + 7 A$_strcspn$115 0044 GR + 7 A$_strcspn$116 0046 GR + 7 A$_strcspn$117 0048 GR + 7 A$_strcspn$118 004A GR + 7 A$_strcspn$119 004C GR + 7 A$_strcspn$120 004F GR + 7 A$_strcspn$121 0052 GR + 7 A$_strcspn$122 0055 GR + 7 A$_strcspn$123 0058 GR + 7 A$_strcspn$124 005A GR + 7 A$_strcspn$125 005C GR + 7 A$_strcspn$126 005E GR + 7 A$_strcspn$127 0060 GR + 7 A$_strcspn$128 0062 GR + 7 A$_strcspn$129 0064 GR + 7 A$_strcspn$130 0066 GR + 7 A$_strcspn$131 0068 GR + 7 A$_strcspn$132 0069 GR + 7 A$_strcspn$133 006A GR + 7 A$_strcspn$135 006B GR + 7 A$_strcspn$138 006D GR + 7 A$_strcspn$139 006E GR + 7 A$_strcspn$140 0071 GR + 7 A$_strcspn$143 0072 GR + 7 A$_strcspn$146 0074 GR + 7 A$_strcspn$147 0076 GR + 7 A$_strcspn$151 0078 GR + 7 A$_strcspn$67 0000 GR + 7 A$_strcspn$68 0002 GR + 7 A$_strcspn$69 0004 GR + 7 A$_strcspn$70 0006 GR + 7 A$_strcspn$71 0009 GR + 7 A$_strcspn$72 000B GR + 7 A$_strcspn$73 000C GR + 7 A$_strcspn$74 000E GR + 7 A$_strcspn$75 000F GR + 7 A$_strcspn$76 0010 GR + 7 A$_strcspn$77 0012 GR + 7 A$_strcspn$78 0013 GR + 7 A$_strcspn$80 0014 GR + 7 A$_strcspn$81 0017 GR + 7 A$_strcspn$82 0018 GR + 7 A$_strcspn$83 001A GR + 7 A$_strcspn$84 001B GR + 7 A$_strcspn$85 001C GR + 7 A$_strcspn$86 001E GR + 7 A$_strcspn$87 001F GR + 7 A$_strcspn$88 0020 GR + 7 A$_strcspn$89 0022 GR + 7 A$_strcspn$90 0025 GR + 7 A$_strcspn$91 0026 GR + 7 A$_strcspn$92 0027 GR + 7 A$_strcspn$93 0028 GR + 7 A$_strcspn$94 0029 GR + 7 A$_strcspn$95 002A GR + 7 A$_strcspn$96 002B GR + 7 A$_strcspn$97 002C GR + 7 A$_strcspn$98 002D GR + 7 A$_strcspn$99 002F GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strcspn.c$43$1$1 = 0078 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strcspn$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strcspn$0$0 = 0078 GR + __gptrget **** GX + _strchr **** GX + _strchr_PARM_2 **** GX + 7 _strcspn 0000 GR + 5 _strcspn_PARM_2 0000 GR + 1 _strcspn_sloc0_1_0 0000 R + 5 _strcspn_string_1_1 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 3 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 6 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 79 flags 20 diff --git a/device/lib/_strlen.c b/device/lib/_strlen.c new file mode 100644 index 00000000..33895fe0 --- /dev/null +++ b/device/lib/_strlen.c @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + _strcpy.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +int strlen ( char _generic *str ) +{ + register int i = 0 ; + + while (*str++) + i++ ; + + return i; +} diff --git a/device/lib/_strlen.lst b/device/lib/_strlen.lst new file mode 100644 index 00000000..866f5278 --- /dev/null +++ b/device/lib/_strlen.lst @@ -0,0 +1,127 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strlen + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strlen + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _strlen_str_1_1: + 0000 38 .ds 0x0003 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$strlen$0$0 ==. + 48 ; _strlen.c 27 + 49 ; ----------------------------------------- + 50 ; function strlen + 51 ; ----------------------------------------- + 0000 52 _strlen: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; _strlen.c 34 + 0000 C0 F0 62 push b + 0002 C0 83 63 push dph + 0004 C0 82 64 push dpl + 0006 90s00r00 65 mov dptr,#_strlen_str_1_1 + 0009 D0 E0 66 pop acc + 000B F0 67 movx @dptr,a + 000C D0 E0 68 pop acc + 000E A3 69 inc dptr + 000F F0 70 movx @dptr,a + 0010 D0 E0 71 pop acc + 0012 A3 72 inc dptr + 0013 F0 73 movx @dptr,a + 74 ; _strlen.c 31 + 0014 7A 00 75 mov r2,#0x00 + 0016 7B 00 76 mov r3,#0x00 + 0018 90s00r00 77 mov dptr,#_strlen_str_1_1 + 001B E0 78 movx a,@dptr + 001C FC 79 mov r4,a + 001D A3 80 inc dptr + 001E E0 81 movx a,@dptr + 001F FD 82 mov r5,a + 0020 A3 83 inc dptr + 0021 E0 84 movx a,@dptr + 0022 FE 85 mov r6,a + 0023 86 00101$: + 0023 8C 07 87 mov ar7,r4 + 0025 8D 00 88 mov ar0,r5 + 0027 8E 01 89 mov ar1,r6 + 0029 0C 90 inc r4 + 002A BC 00 01 91 cjne r4,#0x00,00108$ + 002D 0D 92 inc r5 + 002E 93 00108$: + 002E 90s00r00 94 mov dptr,#_strlen_str_1_1 + 0031 EC 95 mov a,r4 + 0032 F0 96 movx @dptr,a + 0033 A3 97 inc dptr + 0034 ED 98 mov a,r5 + 0035 F0 99 movx @dptr,a + 0036 A3 100 inc dptr + 0037 EE 101 mov a,r6 + 0038 F0 102 movx @dptr,a + 0039 8F 82 103 mov dpl,r7 + 003B 88 83 104 mov dph,r0 + 003D 89 F0 105 mov b,r1 + 003F 12s00r00 106 lcall __gptrget + 107 ; Peephole 105 removed redundant mov + 0042 FF 108 mov r7,a + 109 ; Peephole 110 removed ljmp by inverse jump logic + 0043 60 07 110 jz 00103$ + 0045 111 00109$: + 112 ; _strlen.c 32 + 0045 0A 113 inc r2 + 0046 BA 00 01 114 cjne r2,#0x00,00110$ + 0049 0B 115 inc r3 + 004A 116 00110$: + 117 ; Peephole 132 changed ljmp to sjmp + 004A 80 D7 118 sjmp 00101$ + 004C 119 00103$: + 120 ; _strlen.c 34 + 004C 8A 82 121 mov dpl,r2 + 004E 8B 83 122 mov dph,r3 + 0050 123 00104$: + 0050 124 C$_strlen.c$35$1$1 ==. + 0050 125 XG$strlen$0$0 ==. + 0050 22 126 ret + 127 .area CSEG (CODE) diff --git a/device/lib/_strlen.sym b/device/lib/_strlen.sym new file mode 100644 index 00000000..bb3a7f02 --- /dev/null +++ b/device/lib/_strlen.sym @@ -0,0 +1,418 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strlen$100 0036 GR + 7 A$_strlen$101 0037 GR + 7 A$_strlen$102 0038 GR + 7 A$_strlen$103 0039 GR + 7 A$_strlen$104 003B GR + 7 A$_strlen$105 003D GR + 7 A$_strlen$106 003F GR + 7 A$_strlen$108 0042 GR + 7 A$_strlen$110 0043 GR + 7 A$_strlen$113 0045 GR + 7 A$_strlen$114 0046 GR + 7 A$_strlen$115 0049 GR + 7 A$_strlen$118 004A GR + 7 A$_strlen$121 004C GR + 7 A$_strlen$122 004E GR + 7 A$_strlen$126 0050 GR + 7 A$_strlen$62 0000 GR + 7 A$_strlen$63 0002 GR + 7 A$_strlen$64 0004 GR + 7 A$_strlen$65 0006 GR + 7 A$_strlen$66 0009 GR + 7 A$_strlen$67 000B GR + 7 A$_strlen$68 000C GR + 7 A$_strlen$69 000E GR + 7 A$_strlen$70 000F GR + 7 A$_strlen$71 0010 GR + 7 A$_strlen$72 0012 GR + 7 A$_strlen$73 0013 GR + 7 A$_strlen$75 0014 GR + 7 A$_strlen$76 0016 GR + 7 A$_strlen$77 0018 GR + 7 A$_strlen$78 001B GR + 7 A$_strlen$79 001C GR + 7 A$_strlen$80 001D GR + 7 A$_strlen$81 001E GR + 7 A$_strlen$82 001F GR + 7 A$_strlen$83 0020 GR + 7 A$_strlen$84 0021 GR + 7 A$_strlen$85 0022 GR + 7 A$_strlen$87 0023 GR + 7 A$_strlen$88 0025 GR + 7 A$_strlen$89 0027 GR + 7 A$_strlen$90 0029 GR + 7 A$_strlen$91 002A GR + 7 A$_strlen$92 002D GR + 7 A$_strlen$94 002E GR + 7 A$_strlen$95 0031 GR + 7 A$_strlen$96 0032 GR + 7 A$_strlen$97 0033 GR + 7 A$_strlen$98 0034 GR + 7 A$_strlen$99 0035 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strlen.c$35$1$1 = 0050 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strlen$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strlen$0$0 = 0050 GR + __gptrget **** GX + 7 _strlen 0000 GR + 5 _strlen_str_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 3 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 51 flags 20 diff --git a/device/lib/_strncat.c b/device/lib/_strncat.c new file mode 100644 index 00000000..2a588892 --- /dev/null +++ b/device/lib/_strncat.c @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------- + _strncat.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +char _generic * strncat ( + char _generic * front, + char _generic * back, + int count + ) +{ + char _generic *start = front; + + while (*front++); + + front--; + + while (count--) + if (!(*front++ = *back++)) + return(start); + + *front = '\0'; + return(start); +} diff --git a/device/lib/_strncat.lst b/device/lib/_strncat.lst new file mode 100644 index 00000000..b5c6c2cc --- /dev/null +++ b/device/lib/_strncat.lst @@ -0,0 +1,248 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strncat + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strncat_PARM_3 + 11 .globl _strncat_PARM_2 + 12 .globl _strncat + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 16 ;-------------------------------------------------------- + 17 ; special function bits + 18 ;-------------------------------------------------------- + 19 ;-------------------------------------------------------- + 20 ; internal ram data + 21 ;-------------------------------------------------------- + 22 .area DSEG (DATA) + 0000 23 _strncat_sloc0_1_0: + 0000 24 .ds 0x0003 + 0003 25 _strncat_sloc1_1_0: + 0003 26 .ds 0x0003 + 0006 27 _strncat_sloc2_1_0: + 0006 28 .ds 0x0003 + 29 ;-------------------------------------------------------- + 30 ; overlayable items in internal ram + 31 ;-------------------------------------------------------- + 32 .area OSEG (OVR,DATA) + 33 ;-------------------------------------------------------- + 34 ; indirectly addressable internal ram data + 35 ;-------------------------------------------------------- + 36 .area ISEG (DATA) + 37 ;-------------------------------------------------------- + 38 ; bit data + 39 ;-------------------------------------------------------- + 40 .area BSEG (BIT) + 41 ;-------------------------------------------------------- + 42 ; external ram data + 43 ;-------------------------------------------------------- + 44 .area XSEG (XDATA) + 0000 45 _strncat_PARM_2: + 0000 46 .ds 0x0003 + 0003 47 _strncat_PARM_3: + 0003 48 .ds 0x0002 + 0005 49 _strncat_front_1_1: + 0005 50 .ds 0x0003 + 51 ;-------------------------------------------------------- + 52 ; global & static initialisations + 53 ;-------------------------------------------------------- + 54 .area GSINIT (CODE) + 55 ;-------------------------------------------------------- + 56 ; code + 57 ;-------------------------------------------------------- + 58 .area CSEG (CODE) + 0000 59 G$strncat$0$0 ==. + 60 ; _strncat.c 27 + 61 ; ----------------------------------------- + 62 ; function strncat + 63 ; ----------------------------------------- + 0000 64 _strncat: + 0002 65 ar2 = 0x02 + 0003 66 ar3 = 0x03 + 0004 67 ar4 = 0x04 + 0005 68 ar5 = 0x05 + 0006 69 ar6 = 0x06 + 0007 70 ar7 = 0x07 + 0000 71 ar0 = 0x00 + 0001 72 ar1 = 0x01 + 73 ; _strncat.c 44 + 0000 C0 F0 74 push b + 0002 C0 83 75 push dph + 0004 C0 82 76 push dpl + 0006 90s00r05 77 mov dptr,#_strncat_front_1_1 + 0009 D0 E0 78 pop acc + 000B F0 79 movx @dptr,a + 000C D0 E0 80 pop acc + 000E A3 81 inc dptr + 000F F0 82 movx @dptr,a + 0010 D0 E0 83 pop acc + 0012 A3 84 inc dptr + 0013 F0 85 movx @dptr,a + 86 ; _strncat.c 33 + 0014 90s00r05 87 mov dptr,#_strncat_front_1_1 + 0017 E0 88 movx a,@dptr + 0018 F5*00 89 mov _strncat_sloc0_1_0,a + 001A A3 90 inc dptr + 001B E0 91 movx a,@dptr + 001C F5*01 92 mov (_strncat_sloc0_1_0 + 1),a + 001E A3 93 inc dptr + 001F E0 94 movx a,@dptr + 0020 F5*02 95 mov (_strncat_sloc0_1_0 + 2),a + 96 ; _strncat.c 35 + 0022 97 00101$: + 0022 90s00r05 98 mov dptr,#_strncat_front_1_1 + 0025 E0 99 movx a,@dptr + 0026 FD 100 mov r5,a + 0027 A3 101 inc dptr + 0028 E0 102 movx a,@dptr + 0029 FE 103 mov r6,a + 002A A3 104 inc dptr + 002B E0 105 movx a,@dptr + 002C FF 106 mov r7,a + 002D 74 01 107 mov a,#0x01 + 002F 2D 108 add a,r5 + 0030 F8 109 mov r0,a + 110 ; Peephole 180 changed mov to clr + 0031 E4 111 clr a + 0032 3E 112 addc a,r6 + 0033 F9 113 mov r1,a + 0034 8F 02 114 mov ar2,r7 + 0036 90s00r05 115 mov dptr,#_strncat_front_1_1 + 0039 E8 116 mov a,r0 + 003A F0 117 movx @dptr,a + 003B A3 118 inc dptr + 003C E9 119 mov a,r1 + 003D F0 120 movx @dptr,a + 003E A3 121 inc dptr + 003F EA 122 mov a,r2 + 0040 F0 123 movx @dptr,a + 0041 8D 82 124 mov dpl,r5 + 0043 8E 83 125 mov dph,r6 + 0045 8F F0 126 mov b,r7 + 0047 12s00r00 127 lcall __gptrget + 128 ; Peephole 105 removed redundant mov + 004A FD 129 mov r5,a + 130 ; Peephole 109 removed ljmp by inverse jump logic + 004B 70 D5 131 jnz 00101$ + 004D 132 00116$: + 133 ; _strncat.c 37 + 004D E8 134 mov a,r0 + 004E 24 FF 135 add a,#0xff + 0050 FC 136 mov r4,a + 0051 E9 137 mov a,r1 + 0052 34 FF 138 addc a,#0xff + 0054 FB 139 mov r3,a + 0055 90s00r05 140 mov dptr,#_strncat_front_1_1 + 0058 EC 141 mov a,r4 + 0059 F0 142 movx @dptr,a + 005A A3 143 inc dptr + 005B EB 144 mov a,r3 + 005C F0 145 movx @dptr,a + 005D A3 146 inc dptr + 005E EA 147 mov a,r2 + 005F F0 148 movx @dptr,a + 149 ; _strncat.c 39 + 0060 8C*06 150 mov _strncat_sloc2_1_0,r4 + 0062 8B*07 151 mov (_strncat_sloc2_1_0 + 1),r3 + 0064 8A*08 152 mov (_strncat_sloc2_1_0 + 2),r2 + 0066 90s00r00 153 mov dptr,#_strncat_PARM_2 + 0069 E0 154 movx a,@dptr + 006A F5*03 155 mov _strncat_sloc1_1_0,a + 006C A3 156 inc dptr + 006D E0 157 movx a,@dptr + 006E F5*04 158 mov (_strncat_sloc1_1_0 + 1),a + 0070 A3 159 inc dptr + 0071 E0 160 movx a,@dptr + 0072 F5*05 161 mov (_strncat_sloc1_1_0 + 2),a + 0074 90s00r03 162 mov dptr,#_strncat_PARM_3 + 0077 E0 163 movx a,@dptr + 0078 FD 164 mov r5,a + 0079 A3 165 inc dptr + 007A E0 166 movx a,@dptr + 007B F8 167 mov r0,a + 007C 168 00106$: + 007C 8D 01 169 mov ar1,r5 + 007E 88 02 170 mov ar2,r0 + 0080 1D 171 dec r5 + 0081 BD FF 01 172 cjne r5,#0xff,00117$ + 0084 18 173 dec r0 + 0085 174 00117$: + 0085 E9 175 mov a,r1 + 0086 4A 176 orl a,r2 + 177 ; Peephole 110 removed ljmp by inverse jump logic + 0087 60 47 178 jz 00108$ + 0089 179 00118$: + 180 ; _strncat.c 40 + 0089 AA*06 181 mov r2,_strncat_sloc2_1_0 + 008B AB*07 182 mov r3,(_strncat_sloc2_1_0 + 1) + 008D AC*08 183 mov r4,(_strncat_sloc2_1_0 + 2) + 008F 05*06 184 inc _strncat_sloc2_1_0 + 0091 E4 185 clr a + 0092 B5*06 02 186 cjne a,_strncat_sloc2_1_0,00119$ + 0095 05*07 187 inc (_strncat_sloc2_1_0 + 1) + 0097 188 00119$: + 0097 90s00r05 189 mov dptr,#_strncat_front_1_1 + 009A E5*06 190 mov a,_strncat_sloc2_1_0 + 009C F0 191 movx @dptr,a + 009D A3 192 inc dptr + 009E E5*07 193 mov a,(_strncat_sloc2_1_0 + 1) + 00A0 F0 194 movx @dptr,a + 00A1 A3 195 inc dptr + 00A2 E5*08 196 mov a,(_strncat_sloc2_1_0 + 2) + 00A4 F0 197 movx @dptr,a + 00A5 85*03 82 198 mov dpl,_strncat_sloc1_1_0 + 00A8 85*04 83 199 mov dph,(_strncat_sloc1_1_0 + 1) + 00AB 85*05 F0 200 mov b,(_strncat_sloc1_1_0 + 2) + 00AE 05*03 201 inc _strncat_sloc1_1_0 + 00B0 E4 202 clr a + 00B1 B5*03 02 203 cjne a,_strncat_sloc1_1_0,00120$ + 00B4 05*04 204 inc (_strncat_sloc1_1_0 + 1) + 00B6 205 00120$: + 00B6 12s00r00 206 lcall __gptrget + 207 ; Peephole 190 removed redundant mov + 208 ; Peephole 191 removed redundant mov + 00B9 F9 209 mov r1,a + 00BA 8A 82 210 mov dpl,r2 + 00BC 8B 83 211 mov dph,r3 + 00BE 8C F0 212 mov b,r4 + 00C0 12s00r00 213 lcall __gptrput + 214 ; Peephole 109 removed ljmp by inverse jump logic + 00C3 70 B7 215 jnz 00106$ + 00C5 216 00121$: + 217 ; _strncat.c 41 + 00C5 85*00 82 218 mov dpl,_strncat_sloc0_1_0 + 00C8 85*01 83 219 mov dph,(_strncat_sloc0_1_0 + 1) + 00CB 85*02 F0 220 mov b,(_strncat_sloc0_1_0 + 2) + 221 ; Peephole 132 changed ljmp to sjmp + 00CE 80 1E 222 sjmp 00109$ + 00D0 223 00108$: + 224 ; _strncat.c 43 + 00D0 90s00r05 225 mov dptr,#_strncat_front_1_1 + 00D3 E0 226 movx a,@dptr + 00D4 FA 227 mov r2,a + 00D5 A3 228 inc dptr + 00D6 E0 229 movx a,@dptr + 00D7 FB 230 mov r3,a + 00D8 A3 231 inc dptr + 00D9 E0 232 movx a,@dptr + 00DA FC 233 mov r4,a + 00DB 8A 82 234 mov dpl,r2 + 00DD 8B 83 235 mov dph,r3 + 00DF 8C F0 236 mov b,r4 + 237 ; Peephole 180 changed mov to clr + 00E1 E4 238 clr a + 00E2 12s00r00 239 lcall __gptrput + 240 ; _strncat.c 44 + 00E5 85*00 82 241 mov dpl,_strncat_sloc0_1_0 + 00E8 85*01 83 242 mov dph,(_strncat_sloc0_1_0 + 1) + 00EB 85*02 F0 243 mov b,(_strncat_sloc0_1_0 + 2) + 00EE 244 00109$: + 00EE 245 C$_strncat.c$45$1$1 ==. + 00EE 246 XG$strncat$0$0 ==. + 00EE 22 247 ret + 248 .area CSEG (CODE) diff --git a/device/lib/_strncat.sym b/device/lib/_strncat.sym new file mode 100644 index 00000000..b4598db8 --- /dev/null +++ b/device/lib/_strncat.sym @@ -0,0 +1,518 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strncat$100 0026 GR + 7 A$_strncat$101 0027 GR + 7 A$_strncat$102 0028 GR + 7 A$_strncat$103 0029 GR + 7 A$_strncat$104 002A GR + 7 A$_strncat$105 002B GR + 7 A$_strncat$106 002C GR + 7 A$_strncat$107 002D GR + 7 A$_strncat$108 002F GR + 7 A$_strncat$109 0030 GR + 7 A$_strncat$111 0031 GR + 7 A$_strncat$112 0032 GR + 7 A$_strncat$113 0033 GR + 7 A$_strncat$114 0034 GR + 7 A$_strncat$115 0036 GR + 7 A$_strncat$116 0039 GR + 7 A$_strncat$117 003A GR + 7 A$_strncat$118 003B GR + 7 A$_strncat$119 003C GR + 7 A$_strncat$120 003D GR + 7 A$_strncat$121 003E GR + 7 A$_strncat$122 003F GR + 7 A$_strncat$123 0040 GR + 7 A$_strncat$124 0041 GR + 7 A$_strncat$125 0043 GR + 7 A$_strncat$126 0045 GR + 7 A$_strncat$127 0047 GR + 7 A$_strncat$129 004A GR + 7 A$_strncat$131 004B GR + 7 A$_strncat$134 004D GR + 7 A$_strncat$135 004E GR + 7 A$_strncat$136 0050 GR + 7 A$_strncat$137 0051 GR + 7 A$_strncat$138 0052 GR + 7 A$_strncat$139 0054 GR + 7 A$_strncat$140 0055 GR + 7 A$_strncat$141 0058 GR + 7 A$_strncat$142 0059 GR + 7 A$_strncat$143 005A GR + 7 A$_strncat$144 005B GR + 7 A$_strncat$145 005C GR + 7 A$_strncat$146 005D GR + 7 A$_strncat$147 005E GR + 7 A$_strncat$148 005F GR + 7 A$_strncat$150 0060 GR + 7 A$_strncat$151 0062 GR + 7 A$_strncat$152 0064 GR + 7 A$_strncat$153 0066 GR + 7 A$_strncat$154 0069 GR + 7 A$_strncat$155 006A GR + 7 A$_strncat$156 006C GR + 7 A$_strncat$157 006D GR + 7 A$_strncat$158 006E GR + 7 A$_strncat$159 0070 GR + 7 A$_strncat$160 0071 GR + 7 A$_strncat$161 0072 GR + 7 A$_strncat$162 0074 GR + 7 A$_strncat$163 0077 GR + 7 A$_strncat$164 0078 GR + 7 A$_strncat$165 0079 GR + 7 A$_strncat$166 007A GR + 7 A$_strncat$167 007B GR + 7 A$_strncat$169 007C GR + 7 A$_strncat$170 007E GR + 7 A$_strncat$171 0080 GR + 7 A$_strncat$172 0081 GR + 7 A$_strncat$173 0084 GR + 7 A$_strncat$175 0085 GR + 7 A$_strncat$176 0086 GR + 7 A$_strncat$178 0087 GR + 7 A$_strncat$181 0089 GR + 7 A$_strncat$182 008B GR + 7 A$_strncat$183 008D GR + 7 A$_strncat$184 008F GR + 7 A$_strncat$185 0091 GR + 7 A$_strncat$186 0092 GR + 7 A$_strncat$187 0095 GR + 7 A$_strncat$189 0097 GR + 7 A$_strncat$190 009A GR + 7 A$_strncat$191 009C GR + 7 A$_strncat$192 009D GR + 7 A$_strncat$193 009E GR + 7 A$_strncat$194 00A0 GR + 7 A$_strncat$195 00A1 GR + 7 A$_strncat$196 00A2 GR + 7 A$_strncat$197 00A4 GR + 7 A$_strncat$198 00A5 GR + 7 A$_strncat$199 00A8 GR + 7 A$_strncat$200 00AB GR + 7 A$_strncat$201 00AE GR + 7 A$_strncat$202 00B0 GR + 7 A$_strncat$203 00B1 GR + 7 A$_strncat$204 00B4 GR + 7 A$_strncat$206 00B6 GR + 7 A$_strncat$209 00B9 GR + 7 A$_strncat$210 00BA GR + 7 A$_strncat$211 00BC GR + 7 A$_strncat$212 00BE GR + 7 A$_strncat$213 00C0 GR + 7 A$_strncat$215 00C3 GR + 7 A$_strncat$218 00C5 GR + 7 A$_strncat$219 00C8 GR + 7 A$_strncat$220 00CB GR + 7 A$_strncat$222 00CE GR + 7 A$_strncat$225 00D0 GR + 7 A$_strncat$226 00D3 GR + 7 A$_strncat$227 00D4 GR + 7 A$_strncat$228 00D5 GR + 7 A$_strncat$229 00D6 GR + 7 A$_strncat$230 00D7 GR + 7 A$_strncat$231 00D8 GR + 7 A$_strncat$232 00D9 GR + 7 A$_strncat$233 00DA GR + 7 A$_strncat$234 00DB GR + 7 A$_strncat$235 00DD GR + 7 A$_strncat$236 00DF GR + 7 A$_strncat$238 00E1 GR + 7 A$_strncat$239 00E2 GR + 7 A$_strncat$241 00E5 GR + 7 A$_strncat$242 00E8 GR + 7 A$_strncat$243 00EB GR + 7 A$_strncat$247 00EE GR + 7 A$_strncat$74 0000 GR + 7 A$_strncat$75 0002 GR + 7 A$_strncat$76 0004 GR + 7 A$_strncat$77 0006 GR + 7 A$_strncat$78 0009 GR + 7 A$_strncat$79 000B GR + 7 A$_strncat$80 000C GR + 7 A$_strncat$81 000E GR + 7 A$_strncat$82 000F GR + 7 A$_strncat$83 0010 GR + 7 A$_strncat$84 0012 GR + 7 A$_strncat$85 0013 GR + 7 A$_strncat$87 0014 GR + 7 A$_strncat$88 0017 GR + 7 A$_strncat$89 0018 GR + 7 A$_strncat$90 001A GR + 7 A$_strncat$91 001B GR + 7 A$_strncat$92 001C GR + 7 A$_strncat$93 001E GR + 7 A$_strncat$94 001F GR + 7 A$_strncat$95 0020 GR + 7 A$_strncat$98 0022 GR + 7 A$_strncat$99 0025 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strncat.c$45$1$1 = 00EE GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strncat$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strncat$0$0 = 00EE GR + __gptrget **** GX + __gptrput **** GX + 7 _strncat 0000 GR + 5 _strncat_PARM_2 0000 GR + 5 _strncat_PARM_3 0003 GR + 5 _strncat_front_1_1 0005 R + 1 _strncat_sloc0_1_0 0000 R + 1 _strncat_sloc1_1_0 0003 R + 1 _strncat_sloc2_1_0 0006 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 9 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size EF flags 20 diff --git a/device/lib/_strncmp.c b/device/lib/_strncmp.c new file mode 100644 index 00000000..65307281 --- /dev/null +++ b/device/lib/_strncmp.c @@ -0,0 +1,42 @@ +/*------------------------------------------------------------------------- + _strncmp.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +int strncmp ( + char _generic * first, + char _generic * last, + int count + ) +{ + if (!count) + return(0); + + while (--count && *first && *first == *last) { + first++; + last++; + } + + return( *first - *last ); +} diff --git a/device/lib/_strncmp.lst b/device/lib/_strncmp.lst new file mode 100644 index 00000000..4da9ca7b --- /dev/null +++ b/device/lib/_strncmp.lst @@ -0,0 +1,212 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strncmp + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strncmp_PARM_3 + 11 .globl _strncmp_PARM_2 + 12 .globl _strncmp + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 16 ;-------------------------------------------------------- + 17 ; special function bits + 18 ;-------------------------------------------------------- + 19 ;-------------------------------------------------------- + 20 ; internal ram data + 21 ;-------------------------------------------------------- + 22 .area DSEG (DATA) + 23 ;-------------------------------------------------------- + 24 ; overlayable items in internal ram + 25 ;-------------------------------------------------------- + 26 .area OSEG (OVR,DATA) + 27 ;-------------------------------------------------------- + 28 ; indirectly addressable internal ram data + 29 ;-------------------------------------------------------- + 30 .area ISEG (DATA) + 31 ;-------------------------------------------------------- + 32 ; bit data + 33 ;-------------------------------------------------------- + 34 .area BSEG (BIT) + 35 ;-------------------------------------------------------- + 36 ; external ram data + 37 ;-------------------------------------------------------- + 38 .area XSEG (XDATA) + 0000 39 _strncmp_PARM_2: + 0000 40 .ds 0x0003 + 0003 41 _strncmp_PARM_3: + 0003 42 .ds 0x0002 + 0005 43 _strncmp_first_1_1: + 0005 44 .ds 0x0003 + 45 ;-------------------------------------------------------- + 46 ; global & static initialisations + 47 ;-------------------------------------------------------- + 48 .area GSINIT (CODE) + 49 ;-------------------------------------------------------- + 50 ; code + 51 ;-------------------------------------------------------- + 52 .area CSEG (CODE) + 0000 53 G$strncmp$0$0 ==. + 54 ; _strncmp.c 27 + 55 ; ----------------------------------------- + 56 ; function strncmp + 57 ; ----------------------------------------- + 0000 58 _strncmp: + 0002 59 ar2 = 0x02 + 0003 60 ar3 = 0x03 + 0004 61 ar4 = 0x04 + 0005 62 ar5 = 0x05 + 0006 63 ar6 = 0x06 + 0007 64 ar7 = 0x07 + 0000 65 ar0 = 0x00 + 0001 66 ar1 = 0x01 + 67 ; _strncmp.c 0 + 0000 C0 F0 68 push b + 0002 C0 83 69 push dph + 0004 C0 82 70 push dpl + 0006 90s00r05 71 mov dptr,#_strncmp_first_1_1 + 0009 D0 E0 72 pop acc + 000B F0 73 movx @dptr,a + 000C D0 E0 74 pop acc + 000E A3 75 inc dptr + 000F F0 76 movx @dptr,a + 0010 D0 E0 77 pop acc + 0012 A3 78 inc dptr + 0013 F0 79 movx @dptr,a + 80 ; _strncmp.c 33 + 0014 90s00r03 81 mov dptr,#_strncmp_PARM_3 + 0017 E0 82 movx a,@dptr + 0018 FA 83 mov r2,a + 0019 A3 84 inc dptr + 001A E0 85 movx a,@dptr + 86 ; Peephole 135 removed redundant mov + 001B FB 87 mov r3,a + 001C 4A 88 orl a,r2 + 89 ; Peephole 109 removed ljmp by inverse jump logic + 001D 70 06 90 jnz 00114$ + 001F 91 00115$: + 92 ; _strncmp.c 34 + 93 ; Peephole 181 used 16 bit load of dptr + 001F 90 00 00 94 mov dptr,#0x0000 + 0022 02s00rAF 95 ljmp 00108$ + 96 ; _strncmp.c 36 + 0025 97 00114$: + 0025 90s00r05 98 mov dptr,#_strncmp_first_1_1 + 0028 E0 99 movx a,@dptr + 0029 FA 100 mov r2,a + 002A A3 101 inc dptr + 002B E0 102 movx a,@dptr + 002C FB 103 mov r3,a + 002D A3 104 inc dptr + 002E E0 105 movx a,@dptr + 002F FC 106 mov r4,a + 0030 90s00r00 107 mov dptr,#_strncmp_PARM_2 + 0033 E0 108 movx a,@dptr + 0034 FD 109 mov r5,a + 0035 A3 110 inc dptr + 0036 E0 111 movx a,@dptr + 0037 FE 112 mov r6,a + 0038 A3 113 inc dptr + 0039 E0 114 movx a,@dptr + 003A FF 115 mov r7,a + 003B 116 00105$: + 003B 90s00r03 117 mov dptr,#_strncmp_PARM_3 + 003E E0 118 movx a,@dptr + 003F 24 FF 119 add a,#0xff + 0041 F8 120 mov r0,a + 0042 A3 121 inc dptr + 0043 E0 122 movx a,@dptr + 0044 34 FF 123 addc a,#0xff + 0046 F9 124 mov r1,a + 0047 90s00r03 125 mov dptr,#_strncmp_PARM_3 + 004A E8 126 mov a,r0 + 004B F0 127 movx @dptr,a + 004C A3 128 inc dptr + 004D E9 129 mov a,r1 + 004E F0 130 movx @dptr,a + 004F E8 131 mov a,r0 + 0050 49 132 orl a,r1 + 133 ; Peephole 110 removed ljmp by inverse jump logic + 0051 60 32 134 jz 00107$ + 0053 135 00116$: + 0053 8A 82 136 mov dpl,r2 + 0055 8B 83 137 mov dph,r3 + 0057 8C F0 138 mov b,r4 + 0059 12s00r00 139 lcall __gptrget + 140 ; Peephole 105 removed redundant mov + 005C F8 141 mov r0,a + 142 ; Peephole 110 removed ljmp by inverse jump logic + 005D 60 26 143 jz 00107$ + 005F 144 00117$: + 005F 8D 82 145 mov dpl,r5 + 0061 8E 83 146 mov dph,r6 + 0063 8F F0 147 mov b,r7 + 0065 12s00r00 148 lcall __gptrget + 0068 F9 149 mov r1,a + 0069 E8 150 mov a,r0 + 151 ; Peephole 132 changed ljmp to sjmp + 152 ; Peephole 199 optimized misc jump sequence + 006A B5 01 18 153 cjne a,ar1,00107$ + 154 ; Peephole 201 removed redundant sjmp + 006D 155 00118$: + 006D 156 00119$: + 157 ; _strncmp.c 37 + 006D 0A 158 inc r2 + 006E BA 00 01 159 cjne r2,#0x00,00120$ + 0071 0B 160 inc r3 + 0072 161 00120$: + 0072 90s00r05 162 mov dptr,#_strncmp_first_1_1 + 0075 EA 163 mov a,r2 + 0076 F0 164 movx @dptr,a + 0077 A3 165 inc dptr + 0078 EB 166 mov a,r3 + 0079 F0 167 movx @dptr,a + 007A A3 168 inc dptr + 007B EC 169 mov a,r4 + 007C F0 170 movx @dptr,a + 171 ; _strncmp.c 38 + 007D 0D 172 inc r5 + 007E BD 00 01 173 cjne r5,#0x00,00121$ + 0081 0E 174 inc r6 + 0082 175 00121$: + 0082 02s00r3B 176 ljmp 00105$ + 0085 177 00107$: + 178 ; _strncmp.c 41 + 0085 90s00r05 179 mov dptr,#_strncmp_first_1_1 + 0088 EA 180 mov a,r2 + 0089 F0 181 movx @dptr,a + 008A A3 182 inc dptr + 008B EB 183 mov a,r3 + 008C F0 184 movx @dptr,a + 008D A3 185 inc dptr + 008E EC 186 mov a,r4 + 008F F0 187 movx @dptr,a + 0090 8D 82 188 mov dpl,r5 + 0092 8E 83 189 mov dph,r6 + 0094 8F F0 190 mov b,r7 + 0096 12s00r00 191 lcall __gptrget + 0099 FD 192 mov r5,a + 009A 8A 82 193 mov dpl,r2 + 009C 8B 83 194 mov dph,r3 + 009E 8C F0 195 mov b,r4 + 00A0 12s00r00 196 lcall __gptrget + 197 ; Peephole 106 removed redundant mov + 00A3 FA 198 mov r2,a + 00A4 C3 199 clr c + 00A5 9D 200 subb a,r5 + 00A6 FA 201 mov r2,a + 202 ; Peephole 180 changed mov to clr + 00A7 E4 203 clr a + 00A8 94 00 204 subb a,#0x00 + 00AA FD 205 mov r5,a + 00AB 8A 82 206 mov dpl,r2 + 00AD 8D 83 207 mov dph,r5 + 00AF 208 00108$: + 00AF 209 C$_strncmp.c$42$1$1 ==. + 00AF 210 XG$strncmp$0$0 ==. + 00AF 22 211 ret + 212 .area CSEG (CODE) diff --git a/device/lib/_strncmp.sym b/device/lib/_strncmp.sym new file mode 100644 index 00000000..838153a1 --- /dev/null +++ b/device/lib/_strncmp.sym @@ -0,0 +1,483 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strncmp$100 0029 GR + 7 A$_strncmp$101 002A GR + 7 A$_strncmp$102 002B GR + 7 A$_strncmp$103 002C GR + 7 A$_strncmp$104 002D GR + 7 A$_strncmp$105 002E GR + 7 A$_strncmp$106 002F GR + 7 A$_strncmp$107 0030 GR + 7 A$_strncmp$108 0033 GR + 7 A$_strncmp$109 0034 GR + 7 A$_strncmp$110 0035 GR + 7 A$_strncmp$111 0036 GR + 7 A$_strncmp$112 0037 GR + 7 A$_strncmp$113 0038 GR + 7 A$_strncmp$114 0039 GR + 7 A$_strncmp$115 003A GR + 7 A$_strncmp$117 003B GR + 7 A$_strncmp$118 003E GR + 7 A$_strncmp$119 003F GR + 7 A$_strncmp$120 0041 GR + 7 A$_strncmp$121 0042 GR + 7 A$_strncmp$122 0043 GR + 7 A$_strncmp$123 0044 GR + 7 A$_strncmp$124 0046 GR + 7 A$_strncmp$125 0047 GR + 7 A$_strncmp$126 004A GR + 7 A$_strncmp$127 004B GR + 7 A$_strncmp$128 004C GR + 7 A$_strncmp$129 004D GR + 7 A$_strncmp$130 004E GR + 7 A$_strncmp$131 004F GR + 7 A$_strncmp$132 0050 GR + 7 A$_strncmp$134 0051 GR + 7 A$_strncmp$136 0053 GR + 7 A$_strncmp$137 0055 GR + 7 A$_strncmp$138 0057 GR + 7 A$_strncmp$139 0059 GR + 7 A$_strncmp$141 005C GR + 7 A$_strncmp$143 005D GR + 7 A$_strncmp$145 005F GR + 7 A$_strncmp$146 0061 GR + 7 A$_strncmp$147 0063 GR + 7 A$_strncmp$148 0065 GR + 7 A$_strncmp$149 0068 GR + 7 A$_strncmp$150 0069 GR + 7 A$_strncmp$153 006A GR + 7 A$_strncmp$158 006D GR + 7 A$_strncmp$159 006E GR + 7 A$_strncmp$160 0071 GR + 7 A$_strncmp$162 0072 GR + 7 A$_strncmp$163 0075 GR + 7 A$_strncmp$164 0076 GR + 7 A$_strncmp$165 0077 GR + 7 A$_strncmp$166 0078 GR + 7 A$_strncmp$167 0079 GR + 7 A$_strncmp$168 007A GR + 7 A$_strncmp$169 007B GR + 7 A$_strncmp$170 007C GR + 7 A$_strncmp$172 007D GR + 7 A$_strncmp$173 007E GR + 7 A$_strncmp$174 0081 GR + 7 A$_strncmp$176 0082 GR + 7 A$_strncmp$179 0085 GR + 7 A$_strncmp$180 0088 GR + 7 A$_strncmp$181 0089 GR + 7 A$_strncmp$182 008A GR + 7 A$_strncmp$183 008B GR + 7 A$_strncmp$184 008C GR + 7 A$_strncmp$185 008D GR + 7 A$_strncmp$186 008E GR + 7 A$_strncmp$187 008F GR + 7 A$_strncmp$188 0090 GR + 7 A$_strncmp$189 0092 GR + 7 A$_strncmp$190 0094 GR + 7 A$_strncmp$191 0096 GR + 7 A$_strncmp$192 0099 GR + 7 A$_strncmp$193 009A GR + 7 A$_strncmp$194 009C GR + 7 A$_strncmp$195 009E GR + 7 A$_strncmp$196 00A0 GR + 7 A$_strncmp$198 00A3 GR + 7 A$_strncmp$199 00A4 GR + 7 A$_strncmp$200 00A5 GR + 7 A$_strncmp$201 00A6 GR + 7 A$_strncmp$203 00A7 GR + 7 A$_strncmp$204 00A8 GR + 7 A$_strncmp$205 00AA GR + 7 A$_strncmp$206 00AB GR + 7 A$_strncmp$207 00AD GR + 7 A$_strncmp$211 00AF GR + 7 A$_strncmp$68 0000 GR + 7 A$_strncmp$69 0002 GR + 7 A$_strncmp$70 0004 GR + 7 A$_strncmp$71 0006 GR + 7 A$_strncmp$72 0009 GR + 7 A$_strncmp$73 000B GR + 7 A$_strncmp$74 000C GR + 7 A$_strncmp$75 000E GR + 7 A$_strncmp$76 000F GR + 7 A$_strncmp$77 0010 GR + 7 A$_strncmp$78 0012 GR + 7 A$_strncmp$79 0013 GR + 7 A$_strncmp$81 0014 GR + 7 A$_strncmp$82 0017 GR + 7 A$_strncmp$83 0018 GR + 7 A$_strncmp$84 0019 GR + 7 A$_strncmp$85 001A GR + 7 A$_strncmp$87 001B GR + 7 A$_strncmp$88 001C GR + 7 A$_strncmp$90 001D GR + 7 A$_strncmp$94 001F GR + 7 A$_strncmp$95 0022 GR + 7 A$_strncmp$98 0025 GR + 7 A$_strncmp$99 0028 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strncmp.c$42$1$1 = 00AF GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strncmp$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strncmp$0$0 = 00AF GR + __gptrget **** GX + 7 _strncmp 0000 GR + 5 _strncmp_PARM_2 0000 GR + 5 _strncmp_PARM_3 0003 GR + 5 _strncmp_first_1_1 0005 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size B0 flags 20 diff --git a/device/lib/_strncpy.c b/device/lib/_strncpy.c new file mode 100644 index 00000000..f67aa7d0 --- /dev/null +++ b/device/lib/_strncpy.c @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + _strncpy.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +char _generic *strncpy ( + char _generic *d , + char _generic *s , + int n ) +{ + register char _generic *d1 = d; + + while ( n-- ) + *d++ = *s++ ; + return d1; +} diff --git a/device/lib/_strncpy.lst b/device/lib/_strncpy.lst new file mode 100644 index 00000000..915303f2 --- /dev/null +++ b/device/lib/_strncpy.lst @@ -0,0 +1,172 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strncpy + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strncpy_PARM_3 + 11 .globl _strncpy_PARM_2 + 12 .globl _strncpy + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 16 ;-------------------------------------------------------- + 17 ; special function bits + 18 ;-------------------------------------------------------- + 19 ;-------------------------------------------------------- + 20 ; internal ram data + 21 ;-------------------------------------------------------- + 22 .area DSEG (DATA) + 0000 23 _strncpy_sloc0_1_0: + 0000 24 .ds 0x0003 + 0003 25 _strncpy_sloc1_1_0: + 0003 26 .ds 0x0003 + 27 ;-------------------------------------------------------- + 28 ; overlayable items in internal ram + 29 ;-------------------------------------------------------- + 30 .area OSEG (OVR,DATA) + 31 ;-------------------------------------------------------- + 32 ; indirectly addressable internal ram data + 33 ;-------------------------------------------------------- + 34 .area ISEG (DATA) + 35 ;-------------------------------------------------------- + 36 ; bit data + 37 ;-------------------------------------------------------- + 38 .area BSEG (BIT) + 39 ;-------------------------------------------------------- + 40 ; external ram data + 41 ;-------------------------------------------------------- + 42 .area XSEG (XDATA) + 0000 43 _strncpy_PARM_2: + 0000 44 .ds 0x0003 + 0003 45 _strncpy_PARM_3: + 0003 46 .ds 0x0002 + 0005 47 _strncpy_d_1_1: + 0005 48 .ds 0x0003 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$strncpy$0$0 ==. + 58 ; _strncpy.c 27 + 59 ; ----------------------------------------- + 60 ; function strncpy + 61 ; ----------------------------------------- + 0000 62 _strncpy: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _strncpy.c 36 + 0000 C0 F0 72 push b + 0002 C0 83 73 push dph + 0004 C0 82 74 push dpl + 0006 90s00r05 75 mov dptr,#_strncpy_d_1_1 + 0009 D0 E0 76 pop acc + 000B F0 77 movx @dptr,a + 000C D0 E0 78 pop acc + 000E A3 79 inc dptr + 000F F0 80 movx @dptr,a + 0010 D0 E0 81 pop acc + 0012 A3 82 inc dptr + 0013 F0 83 movx @dptr,a + 84 ; _strncpy.c 32 + 0014 90s00r05 85 mov dptr,#_strncpy_d_1_1 + 0017 E0 86 movx a,@dptr + 0018 F5*00 87 mov _strncpy_sloc0_1_0,a + 001A A3 88 inc dptr + 001B E0 89 movx a,@dptr + 001C F5*01 90 mov (_strncpy_sloc0_1_0 + 1),a + 001E A3 91 inc dptr + 001F E0 92 movx a,@dptr + 0020 F5*02 93 mov (_strncpy_sloc0_1_0 + 2),a + 94 ; _strncpy.c 34 + 0022 AD*00 95 mov r5,_strncpy_sloc0_1_0 + 0024 AE*01 96 mov r6,(_strncpy_sloc0_1_0 + 1) + 0026 AF*02 97 mov r7,(_strncpy_sloc0_1_0 + 2) + 0028 90s00r00 98 mov dptr,#_strncpy_PARM_2 + 002B E0 99 movx a,@dptr + 002C F5*03 100 mov _strncpy_sloc1_1_0,a + 002E A3 101 inc dptr + 002F E0 102 movx a,@dptr + 0030 F5*04 103 mov (_strncpy_sloc1_1_0 + 1),a + 0032 A3 104 inc dptr + 0033 E0 105 movx a,@dptr + 0034 F5*05 106 mov (_strncpy_sloc1_1_0 + 2),a + 0036 90s00r03 107 mov dptr,#_strncpy_PARM_3 + 0039 E0 108 movx a,@dptr + 003A FB 109 mov r3,a + 003B A3 110 inc dptr + 003C E0 111 movx a,@dptr + 003D FC 112 mov r4,a + 003E 113 00101$: + 003E 8B 02 114 mov ar2,r3 + 0040 8C 00 115 mov ar0,r4 + 0042 1B 116 dec r3 + 0043 BB FF 01 117 cjne r3,#0xff,00108$ + 0046 1C 118 dec r4 + 0047 119 00108$: + 0047 90s00r05 120 mov dptr,#_strncpy_d_1_1 + 004A ED 121 mov a,r5 + 004B F0 122 movx @dptr,a + 004C A3 123 inc dptr + 004D EE 124 mov a,r6 + 004E F0 125 movx @dptr,a + 004F A3 126 inc dptr + 0050 EF 127 mov a,r7 + 0051 F0 128 movx @dptr,a + 0052 EA 129 mov a,r2 + 0053 48 130 orl a,r0 + 131 ; Peephole 110 removed ljmp by inverse jump logic + 0054 60 33 132 jz 00103$ + 0056 133 00109$: + 134 ; _strncpy.c 35 + 0056 C0 03 135 push ar3 + 0058 C0 04 136 push ar4 + 005A 8D 02 137 mov ar2,r5 + 005C 8E 00 138 mov ar0,r6 + 005E 8F 01 139 mov ar1,r7 + 0060 0D 140 inc r5 + 0061 BD 00 01 141 cjne r5,#0x00,00110$ + 0064 0E 142 inc r6 + 0065 143 00110$: + 0065 85*03 82 144 mov dpl,_strncpy_sloc1_1_0 + 0068 85*04 83 145 mov dph,(_strncpy_sloc1_1_0 + 1) + 006B 85*05 F0 146 mov b,(_strncpy_sloc1_1_0 + 2) + 006E 05*03 147 inc _strncpy_sloc1_1_0 + 0070 E4 148 clr a + 0071 B5*03 02 149 cjne a,_strncpy_sloc1_1_0,00111$ + 0074 05*04 150 inc (_strncpy_sloc1_1_0 + 1) + 0076 151 00111$: + 0076 12s00r00 152 lcall __gptrget + 153 ; Peephole 191 removed redundant mov + 0079 FB 154 mov r3,a + 007A 8A 82 155 mov dpl,r2 + 007C 88 83 156 mov dph,r0 + 007E 89 F0 157 mov b,r1 + 0080 12s00r00 158 lcall __gptrput + 0083 D0 04 159 pop ar4 + 0085 D0 03 160 pop ar3 + 161 ; Peephole 132 changed ljmp to sjmp + 0087 80 B5 162 sjmp 00101$ + 0089 163 00103$: + 164 ; _strncpy.c 36 + 0089 85*00 82 165 mov dpl,_strncpy_sloc0_1_0 + 008C 85*01 83 166 mov dph,(_strncpy_sloc0_1_0 + 1) + 008F 85*02 F0 167 mov b,(_strncpy_sloc0_1_0 + 2) + 0092 168 00104$: + 0092 169 C$_strncpy.c$37$1$1 ==. + 0092 170 XG$strncpy$0$0 ==. + 0092 22 171 ret + 172 .area CSEG (CODE) diff --git a/device/lib/_strncpy.sym b/device/lib/_strncpy.sym new file mode 100644 index 00000000..8e850e4c --- /dev/null +++ b/device/lib/_strncpy.sym @@ -0,0 +1,456 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strncpy$100 002C GR + 7 A$_strncpy$101 002E GR + 7 A$_strncpy$102 002F GR + 7 A$_strncpy$103 0030 GR + 7 A$_strncpy$104 0032 GR + 7 A$_strncpy$105 0033 GR + 7 A$_strncpy$106 0034 GR + 7 A$_strncpy$107 0036 GR + 7 A$_strncpy$108 0039 GR + 7 A$_strncpy$109 003A GR + 7 A$_strncpy$110 003B GR + 7 A$_strncpy$111 003C GR + 7 A$_strncpy$112 003D GR + 7 A$_strncpy$114 003E GR + 7 A$_strncpy$115 0040 GR + 7 A$_strncpy$116 0042 GR + 7 A$_strncpy$117 0043 GR + 7 A$_strncpy$118 0046 GR + 7 A$_strncpy$120 0047 GR + 7 A$_strncpy$121 004A GR + 7 A$_strncpy$122 004B GR + 7 A$_strncpy$123 004C GR + 7 A$_strncpy$124 004D GR + 7 A$_strncpy$125 004E GR + 7 A$_strncpy$126 004F GR + 7 A$_strncpy$127 0050 GR + 7 A$_strncpy$128 0051 GR + 7 A$_strncpy$129 0052 GR + 7 A$_strncpy$130 0053 GR + 7 A$_strncpy$132 0054 GR + 7 A$_strncpy$135 0056 GR + 7 A$_strncpy$136 0058 GR + 7 A$_strncpy$137 005A GR + 7 A$_strncpy$138 005C GR + 7 A$_strncpy$139 005E GR + 7 A$_strncpy$140 0060 GR + 7 A$_strncpy$141 0061 GR + 7 A$_strncpy$142 0064 GR + 7 A$_strncpy$144 0065 GR + 7 A$_strncpy$145 0068 GR + 7 A$_strncpy$146 006B GR + 7 A$_strncpy$147 006E GR + 7 A$_strncpy$148 0070 GR + 7 A$_strncpy$149 0071 GR + 7 A$_strncpy$150 0074 GR + 7 A$_strncpy$152 0076 GR + 7 A$_strncpy$154 0079 GR + 7 A$_strncpy$155 007A GR + 7 A$_strncpy$156 007C GR + 7 A$_strncpy$157 007E GR + 7 A$_strncpy$158 0080 GR + 7 A$_strncpy$159 0083 GR + 7 A$_strncpy$160 0085 GR + 7 A$_strncpy$162 0087 GR + 7 A$_strncpy$165 0089 GR + 7 A$_strncpy$166 008C GR + 7 A$_strncpy$167 008F GR + 7 A$_strncpy$171 0092 GR + 7 A$_strncpy$72 0000 GR + 7 A$_strncpy$73 0002 GR + 7 A$_strncpy$74 0004 GR + 7 A$_strncpy$75 0006 GR + 7 A$_strncpy$76 0009 GR + 7 A$_strncpy$77 000B GR + 7 A$_strncpy$78 000C GR + 7 A$_strncpy$79 000E GR + 7 A$_strncpy$80 000F GR + 7 A$_strncpy$81 0010 GR + 7 A$_strncpy$82 0012 GR + 7 A$_strncpy$83 0013 GR + 7 A$_strncpy$85 0014 GR + 7 A$_strncpy$86 0017 GR + 7 A$_strncpy$87 0018 GR + 7 A$_strncpy$88 001A GR + 7 A$_strncpy$89 001B GR + 7 A$_strncpy$90 001C GR + 7 A$_strncpy$91 001E GR + 7 A$_strncpy$92 001F GR + 7 A$_strncpy$93 0020 GR + 7 A$_strncpy$95 0022 GR + 7 A$_strncpy$96 0024 GR + 7 A$_strncpy$97 0026 GR + 7 A$_strncpy$98 0028 GR + 7 A$_strncpy$99 002B GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strncpy.c$37$1$1 = 0092 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strncpy$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strncpy$0$0 = 0092 GR + __gptrget **** GX + __gptrput **** GX + 7 _strncpy 0000 GR + 5 _strncpy_PARM_2 0000 GR + 5 _strncpy_PARM_3 0003 GR + 5 _strncpy_d_1_1 0005 R + 1 _strncpy_sloc0_1_0 0000 R + 1 _strncpy_sloc1_1_0 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 93 flags 20 diff --git a/device/lib/_strpbrk.c b/device/lib/_strpbrk.c new file mode 100644 index 00000000..6152783d --- /dev/null +++ b/device/lib/_strpbrk.c @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------- + _strpbrk.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +char _generic *strpbrk ( + char _generic *string , + char _generic *control + ) +{ + register char ch ; + + while ( ch = *string ) { + if (strchr (control, ch )) + return string ; + } + + return (NULL); +} diff --git a/device/lib/_strpbrk.lst b/device/lib/_strpbrk.lst new file mode 100644 index 00000000..34d3b12d --- /dev/null +++ b/device/lib/_strpbrk.lst @@ -0,0 +1,146 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strpbrk + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strpbrk_PARM_2 + 11 .globl _strpbrk + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strpbrk_sloc0_1_0: + 0000 23 .ds 0x0003 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 _strpbrk_PARM_2: + 0000 41 .ds 0x0003 + 0003 42 _strpbrk_string_1_1: + 0003 43 .ds 0x0003 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$strpbrk$0$0 ==. + 53 ; _strpbrk.c 27 + 54 ; ----------------------------------------- + 55 ; function strpbrk + 56 ; ----------------------------------------- + 0000 57 _strpbrk: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _strpbrk.c 0 + 0000 C0 F0 67 push b + 0002 C0 83 68 push dph + 0004 C0 82 69 push dpl + 0006 90s00r03 70 mov dptr,#_strpbrk_string_1_1 + 0009 D0 E0 71 pop acc + 000B F0 72 movx @dptr,a + 000C D0 E0 73 pop acc + 000E A3 74 inc dptr + 000F F0 75 movx @dptr,a + 0010 D0 E0 76 pop acc + 0012 A3 77 inc dptr + 0013 F0 78 movx @dptr,a + 79 ; _strpbrk.c 34 + 0014 90s00r00 80 mov dptr,#_strpbrk_PARM_2 + 0017 E0 81 movx a,@dptr + 0018 F5*00 82 mov _strpbrk_sloc0_1_0,a + 001A A3 83 inc dptr + 001B E0 84 movx a,@dptr + 001C F5*01 85 mov (_strpbrk_sloc0_1_0 + 1),a + 001E A3 86 inc dptr + 001F E0 87 movx a,@dptr + 0020 F5*02 88 mov (_strpbrk_sloc0_1_0 + 2),a + 0022 90s00r03 89 mov dptr,#_strpbrk_string_1_1 + 0025 E0 90 movx a,@dptr + 0026 FD 91 mov r5,a + 0027 A3 92 inc dptr + 0028 E0 93 movx a,@dptr + 0029 FE 94 mov r6,a + 002A A3 95 inc dptr + 002B E0 96 movx a,@dptr + 002C FF 97 mov r7,a + 002D 98 00103$: + 002D 8D 82 99 mov dpl,r5 + 002F 8E 83 100 mov dph,r6 + 0031 8F F0 101 mov b,r7 + 0033 12s00r00 102 lcall __gptrget + 103 ; Peephole 105 removed redundant mov + 0036 F8 104 mov r0,a + 105 ; Peephole 110 removed ljmp by inverse jump logic + 0037 60 30 106 jz 00105$ + 0039 107 00111$: + 108 ; _strpbrk.c 35 + 0039 90s00r00 109 mov dptr,#_strchr_PARM_2 + 003C E8 110 mov a,r0 + 003D F0 111 movx @dptr,a + 003E C0 05 112 push ar5 + 0040 C0 06 113 push ar6 + 0042 C0 07 114 push ar7 + 0044 85*00 82 115 mov dpl,_strpbrk_sloc0_1_0 + 0047 85*01 83 116 mov dph,(_strpbrk_sloc0_1_0 + 1) + 004A 85*02 F0 117 mov b,(_strpbrk_sloc0_1_0 + 2) + 004D 12s00r00 118 lcall _strchr + 0050 A8 82 119 mov r0,dpl + 0052 A9 83 120 mov r1,dph + 0054 AA F0 121 mov r2,b + 0056 D0 07 122 pop ar7 + 0058 D0 06 123 pop ar6 + 005A D0 05 124 pop ar5 + 005C E8 125 mov a,r0 + 005D 49 126 orl a,r1 + 005E 4A 127 orl a,r2 + 128 ; Peephole 110 removed ljmp by inverse jump logic + 005F 60 CC 129 jz 00103$ + 0061 130 00112$: + 131 ; _strpbrk.c 36 + 0061 8D 82 132 mov dpl,r5 + 0063 8E 83 133 mov dph,r6 + 0065 8F F0 134 mov b,r7 + 135 ; Peephole 132 changed ljmp to sjmp + 0067 80 06 136 sjmp 00106$ + 0069 137 00105$: + 138 ; _strpbrk.c 39 + 139 ; Peephole 181 used 16 bit load of dptr + 0069 90 00 00 140 mov dptr,#0x0000 + 006C 75 F0 00 141 mov b,#0x00 + 006F 142 00106$: + 006F 143 C$_strpbrk.c$40$1$1 ==. + 006F 144 XG$strpbrk$0$0 ==. + 006F 22 145 ret + 146 .area CSEG (CODE) diff --git a/device/lib/_strpbrk.sym b/device/lib/_strpbrk.sym new file mode 100644 index 00000000..5442856c --- /dev/null +++ b/device/lib/_strpbrk.sym @@ -0,0 +1,434 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strpbrk$100 002F GR + 7 A$_strpbrk$101 0031 GR + 7 A$_strpbrk$102 0033 GR + 7 A$_strpbrk$104 0036 GR + 7 A$_strpbrk$106 0037 GR + 7 A$_strpbrk$109 0039 GR + 7 A$_strpbrk$110 003C GR + 7 A$_strpbrk$111 003D GR + 7 A$_strpbrk$112 003E GR + 7 A$_strpbrk$113 0040 GR + 7 A$_strpbrk$114 0042 GR + 7 A$_strpbrk$115 0044 GR + 7 A$_strpbrk$116 0047 GR + 7 A$_strpbrk$117 004A GR + 7 A$_strpbrk$118 004D GR + 7 A$_strpbrk$119 0050 GR + 7 A$_strpbrk$120 0052 GR + 7 A$_strpbrk$121 0054 GR + 7 A$_strpbrk$122 0056 GR + 7 A$_strpbrk$123 0058 GR + 7 A$_strpbrk$124 005A GR + 7 A$_strpbrk$125 005C GR + 7 A$_strpbrk$126 005D GR + 7 A$_strpbrk$127 005E GR + 7 A$_strpbrk$129 005F GR + 7 A$_strpbrk$132 0061 GR + 7 A$_strpbrk$133 0063 GR + 7 A$_strpbrk$134 0065 GR + 7 A$_strpbrk$136 0067 GR + 7 A$_strpbrk$140 0069 GR + 7 A$_strpbrk$141 006C GR + 7 A$_strpbrk$145 006F GR + 7 A$_strpbrk$67 0000 GR + 7 A$_strpbrk$68 0002 GR + 7 A$_strpbrk$69 0004 GR + 7 A$_strpbrk$70 0006 GR + 7 A$_strpbrk$71 0009 GR + 7 A$_strpbrk$72 000B GR + 7 A$_strpbrk$73 000C GR + 7 A$_strpbrk$74 000E GR + 7 A$_strpbrk$75 000F GR + 7 A$_strpbrk$76 0010 GR + 7 A$_strpbrk$77 0012 GR + 7 A$_strpbrk$78 0013 GR + 7 A$_strpbrk$80 0014 GR + 7 A$_strpbrk$81 0017 GR + 7 A$_strpbrk$82 0018 GR + 7 A$_strpbrk$83 001A GR + 7 A$_strpbrk$84 001B GR + 7 A$_strpbrk$85 001C GR + 7 A$_strpbrk$86 001E GR + 7 A$_strpbrk$87 001F GR + 7 A$_strpbrk$88 0020 GR + 7 A$_strpbrk$89 0022 GR + 7 A$_strpbrk$90 0025 GR + 7 A$_strpbrk$91 0026 GR + 7 A$_strpbrk$92 0027 GR + 7 A$_strpbrk$93 0028 GR + 7 A$_strpbrk$94 0029 GR + 7 A$_strpbrk$95 002A GR + 7 A$_strpbrk$96 002B GR + 7 A$_strpbrk$97 002C GR + 7 A$_strpbrk$99 002D GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strpbrk.c$40$1$1 = 006F GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strpbrk$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strpbrk$0$0 = 006F GR + __gptrget **** GX + _strchr **** GX + _strchr_PARM_2 **** GX + 7 _strpbrk 0000 GR + 5 _strpbrk_PARM_2 0000 GR + 1 _strpbrk_sloc0_1_0 0000 R + 5 _strpbrk_string_1_1 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 3 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 6 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 70 flags 20 diff --git a/device/lib/_strrchr.c b/device/lib/_strrchr.c new file mode 100644 index 00000000..b044c90b --- /dev/null +++ b/device/lib/_strrchr.c @@ -0,0 +1,44 @@ +/*------------------------------------------------------------------------- + _strrchr.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +char _generic * strrchr ( + char _generic * string, + char ch + ) +{ + char _generic *start = string; + + while (*string++) /* find end of string */ + ; + /* search towards front */ + while (--string != start && *string != ch) + ; + + if (*string == ch) /* char found ? */ + return( (char _generic *)string ); + + return (NULL) ; +} diff --git a/device/lib/_strrchr.lst b/device/lib/_strrchr.lst new file mode 100644 index 00000000..07857e21 --- /dev/null +++ b/device/lib/_strrchr.lst @@ -0,0 +1,209 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strrchr + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strrchr_PARM_2 + 11 .globl _strrchr + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strrchr_sloc0_1_0: + 0000 23 .ds 0x0001 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 _strrchr_PARM_2: + 0000 41 .ds 0x0001 + 0001 42 _strrchr_string_1_1: + 0001 43 .ds 0x0003 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$strrchr$0$0 ==. + 53 ; _strrchr.c 27 + 54 ; ----------------------------------------- + 55 ; function strrchr + 56 ; ----------------------------------------- + 0000 57 _strrchr: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _strrchr.c 0 + 0000 C0 F0 67 push b + 0002 C0 83 68 push dph + 0004 C0 82 69 push dpl + 0006 90s00r01 70 mov dptr,#_strrchr_string_1_1 + 0009 D0 E0 71 pop acc + 000B F0 72 movx @dptr,a + 000C D0 E0 73 pop acc + 000E A3 74 inc dptr + 000F F0 75 movx @dptr,a + 0010 D0 E0 76 pop acc + 0012 A3 77 inc dptr + 0013 F0 78 movx @dptr,a + 79 ; _strrchr.c 32 + 0014 90s00r01 80 mov dptr,#_strrchr_string_1_1 + 0017 E0 81 movx a,@dptr + 0018 FA 82 mov r2,a + 0019 A3 83 inc dptr + 001A E0 84 movx a,@dptr + 001B FB 85 mov r3,a + 001C A3 86 inc dptr + 001D E0 87 movx a,@dptr + 001E FC 88 mov r4,a + 89 ; _strrchr.c 34 + 001F 8A 05 90 mov ar5,r2 + 0021 8B 06 91 mov ar6,r3 + 0023 8C 07 92 mov ar7,r4 + 0025 93 00101$: + 0025 C0 02 94 push ar2 + 0027 C0 03 95 push ar3 + 0029 C0 04 96 push ar4 + 002B 8D 00 97 mov ar0,r5 + 002D 8E 01 98 mov ar1,r6 + 002F 8F 02 99 mov ar2,r7 + 0031 0D 100 inc r5 + 0032 BD 00 01 101 cjne r5,#0x00,00116$ + 0035 0E 102 inc r6 + 0036 103 00116$: + 0036 90s00r01 104 mov dptr,#_strrchr_string_1_1 + 0039 ED 105 mov a,r5 + 003A F0 106 movx @dptr,a + 003B A3 107 inc dptr + 003C EE 108 mov a,r6 + 003D F0 109 movx @dptr,a + 003E A3 110 inc dptr + 003F EF 111 mov a,r7 + 0040 F0 112 movx @dptr,a + 0041 88 82 113 mov dpl,r0 + 0043 89 83 114 mov dph,r1 + 0045 8A F0 115 mov b,r2 + 0047 12s00r00 116 lcall __gptrget + 004A F8 117 mov r0,a + 004B D0 04 118 pop ar4 + 004D D0 03 119 pop ar3 + 004F D0 02 120 pop ar2 + 0051 E8 121 mov a,r0 + 122 ; Peephole 109 removed ljmp by inverse jump logic + 0052 70 D1 123 jnz 00101$ + 0054 124 00117$: + 125 ; _strrchr.c 37 + 0054 90s00r00 126 mov dptr,#_strrchr_PARM_2 + 0057 E0 127 movx a,@dptr + 0058 F5*00 128 mov _strrchr_sloc0_1_0,a + 005A 129 00105$: + 005A 90s00r01 130 mov dptr,#_strrchr_string_1_1 + 005D E0 131 movx a,@dptr + 005E 24 FF 132 add a,#0xff + 0060 FE 133 mov r6,a + 0061 A3 134 inc dptr + 0062 E0 135 movx a,@dptr + 0063 34 FF 136 addc a,#0xff + 0065 FF 137 mov r7,a + 0066 A3 138 inc dptr + 0067 E0 139 movx a,@dptr + 0068 F8 140 mov r0,a + 0069 90s00r01 141 mov dptr,#_strrchr_string_1_1 + 006C EE 142 mov a,r6 + 006D F0 143 movx @dptr,a + 006E A3 144 inc dptr + 006F EF 145 mov a,r7 + 0070 F0 146 movx @dptr,a + 0071 A3 147 inc dptr + 0072 E8 148 mov a,r0 + 0073 F0 149 movx @dptr,a + 0074 EE 150 mov a,r6 + 0075 B5 02 0A 151 cjne a,ar2,00118$ + 0078 EF 152 mov a,r7 + 0079 B5 03 06 153 cjne a,ar3,00118$ + 007C E8 154 mov a,r0 + 007D B5 04 02 155 cjne a,ar4,00118$ + 156 ; Peephole 132 changed ljmp to sjmp + 0080 80 20 157 sjmp 00107$ + 0082 158 00118$: + 0082 C0 02 159 push ar2 + 0084 C0 03 160 push ar3 + 0086 C0 04 161 push ar4 + 0088 8E 82 162 mov dpl,r6 + 008A 8F 83 163 mov dph,r7 + 008C 88 F0 164 mov b,r0 + 008E 12s00r00 165 lcall __gptrget + 166 ; Peephole 105 removed redundant mov + 0091 FA 167 mov r2,a + 0092 B5*00 04 168 cjne a,_strrchr_sloc0_1_0,00119$ + 0095 74 01 169 mov a,#0x01 + 0097 80 01 170 sjmp 00120$ + 0099 171 00119$: + 0099 E4 172 clr a + 009A 173 00120$: + 009A D0 04 174 pop ar4 + 009C D0 03 175 pop ar3 + 009E D0 02 176 pop ar2 + 177 ; Peephole 110 removed ljmp by inverse jump logic + 00A0 60 B8 178 jz 00105$ + 00A2 179 00121$: + 00A2 180 00107$: + 181 ; _strrchr.c 40 + 00A2 8E 82 182 mov dpl,r6 + 00A4 8F 83 183 mov dph,r7 + 00A6 88 F0 184 mov b,r0 + 00A8 12s00r00 185 lcall __gptrget + 186 ; Peephole 105 removed redundant mov + 00AB FD 187 mov r5,a + 188 ; Peephole 132 changed ljmp to sjmp + 189 ; Peephole 199 optimized misc jump sequence + 00AC B5*00 08 190 cjne a,_strrchr_sloc0_1_0,00109$ + 191 ; Peephole 201 removed redundant sjmp + 00AF 192 00122$: + 00AF 193 00123$: + 194 ; _strrchr.c 41 + 00AF 8E 82 195 mov dpl,r6 + 00B1 8F 83 196 mov dph,r7 + 00B3 88 F0 197 mov b,r0 + 198 ; Peephole 132 changed ljmp to sjmp + 00B5 80 06 199 sjmp 00110$ + 00B7 200 00109$: + 201 ; _strrchr.c 43 + 202 ; Peephole 181 used 16 bit load of dptr + 00B7 90 00 00 203 mov dptr,#0x0000 + 00BA 75 F0 00 204 mov b,#0x00 + 00BD 205 00110$: + 00BD 206 C$_strrchr.c$44$1$1 ==. + 00BD 207 XG$strrchr$0$0 ==. + 00BD 22 208 ret + 209 .area CSEG (CODE) diff --git a/device/lib/_strrchr.sym b/device/lib/_strrchr.sym new file mode 100644 index 00000000..eed05e14 --- /dev/null +++ b/device/lib/_strrchr.sym @@ -0,0 +1,480 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strrchr$100 0031 GR + 7 A$_strrchr$101 0032 GR + 7 A$_strrchr$102 0035 GR + 7 A$_strrchr$104 0036 GR + 7 A$_strrchr$105 0039 GR + 7 A$_strrchr$106 003A GR + 7 A$_strrchr$107 003B GR + 7 A$_strrchr$108 003C GR + 7 A$_strrchr$109 003D GR + 7 A$_strrchr$110 003E GR + 7 A$_strrchr$111 003F GR + 7 A$_strrchr$112 0040 GR + 7 A$_strrchr$113 0041 GR + 7 A$_strrchr$114 0043 GR + 7 A$_strrchr$115 0045 GR + 7 A$_strrchr$116 0047 GR + 7 A$_strrchr$117 004A GR + 7 A$_strrchr$118 004B GR + 7 A$_strrchr$119 004D GR + 7 A$_strrchr$120 004F GR + 7 A$_strrchr$121 0051 GR + 7 A$_strrchr$123 0052 GR + 7 A$_strrchr$126 0054 GR + 7 A$_strrchr$127 0057 GR + 7 A$_strrchr$128 0058 GR + 7 A$_strrchr$130 005A GR + 7 A$_strrchr$131 005D GR + 7 A$_strrchr$132 005E GR + 7 A$_strrchr$133 0060 GR + 7 A$_strrchr$134 0061 GR + 7 A$_strrchr$135 0062 GR + 7 A$_strrchr$136 0063 GR + 7 A$_strrchr$137 0065 GR + 7 A$_strrchr$138 0066 GR + 7 A$_strrchr$139 0067 GR + 7 A$_strrchr$140 0068 GR + 7 A$_strrchr$141 0069 GR + 7 A$_strrchr$142 006C GR + 7 A$_strrchr$143 006D GR + 7 A$_strrchr$144 006E GR + 7 A$_strrchr$145 006F GR + 7 A$_strrchr$146 0070 GR + 7 A$_strrchr$147 0071 GR + 7 A$_strrchr$148 0072 GR + 7 A$_strrchr$149 0073 GR + 7 A$_strrchr$150 0074 GR + 7 A$_strrchr$151 0075 GR + 7 A$_strrchr$152 0078 GR + 7 A$_strrchr$153 0079 GR + 7 A$_strrchr$154 007C GR + 7 A$_strrchr$155 007D GR + 7 A$_strrchr$157 0080 GR + 7 A$_strrchr$159 0082 GR + 7 A$_strrchr$160 0084 GR + 7 A$_strrchr$161 0086 GR + 7 A$_strrchr$162 0088 GR + 7 A$_strrchr$163 008A GR + 7 A$_strrchr$164 008C GR + 7 A$_strrchr$165 008E GR + 7 A$_strrchr$167 0091 GR + 7 A$_strrchr$168 0092 GR + 7 A$_strrchr$169 0095 GR + 7 A$_strrchr$170 0097 GR + 7 A$_strrchr$172 0099 GR + 7 A$_strrchr$174 009A GR + 7 A$_strrchr$175 009C GR + 7 A$_strrchr$176 009E GR + 7 A$_strrchr$178 00A0 GR + 7 A$_strrchr$182 00A2 GR + 7 A$_strrchr$183 00A4 GR + 7 A$_strrchr$184 00A6 GR + 7 A$_strrchr$185 00A8 GR + 7 A$_strrchr$187 00AB GR + 7 A$_strrchr$190 00AC GR + 7 A$_strrchr$195 00AF GR + 7 A$_strrchr$196 00B1 GR + 7 A$_strrchr$197 00B3 GR + 7 A$_strrchr$199 00B5 GR + 7 A$_strrchr$203 00B7 GR + 7 A$_strrchr$204 00BA GR + 7 A$_strrchr$208 00BD GR + 7 A$_strrchr$67 0000 GR + 7 A$_strrchr$68 0002 GR + 7 A$_strrchr$69 0004 GR + 7 A$_strrchr$70 0006 GR + 7 A$_strrchr$71 0009 GR + 7 A$_strrchr$72 000B GR + 7 A$_strrchr$73 000C GR + 7 A$_strrchr$74 000E GR + 7 A$_strrchr$75 000F GR + 7 A$_strrchr$76 0010 GR + 7 A$_strrchr$77 0012 GR + 7 A$_strrchr$78 0013 GR + 7 A$_strrchr$80 0014 GR + 7 A$_strrchr$81 0017 GR + 7 A$_strrchr$82 0018 GR + 7 A$_strrchr$83 0019 GR + 7 A$_strrchr$84 001A GR + 7 A$_strrchr$85 001B GR + 7 A$_strrchr$86 001C GR + 7 A$_strrchr$87 001D GR + 7 A$_strrchr$88 001E GR + 7 A$_strrchr$90 001F GR + 7 A$_strrchr$91 0021 GR + 7 A$_strrchr$92 0023 GR + 7 A$_strrchr$94 0025 GR + 7 A$_strrchr$95 0027 GR + 7 A$_strrchr$96 0029 GR + 7 A$_strrchr$97 002B GR + 7 A$_strrchr$98 002D GR + 7 A$_strrchr$99 002F GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strrchr.c$44$1$1 = 00BD GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strrchr$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strrchr$0$0 = 00BD GR + __gptrget **** GX + 7 _strrchr 0000 GR + 5 _strrchr_PARM_2 0000 GR + 1 _strrchr_sloc0_1_0 0000 R + 5 _strrchr_string_1_1 0001 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 1 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 4 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size BE flags 20 diff --git a/device/lib/_strspn.c b/device/lib/_strspn.c new file mode 100644 index 00000000..b725383c --- /dev/null +++ b/device/lib/_strspn.c @@ -0,0 +1,44 @@ +/*------------------------------------------------------------------------- + _strspn.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +int strspn ( + char _generic * string, + char _generic * control + ) +{ + register int count = 0; + register char ch ; + + while (ch = *string) { + if ( strchr(control,ch) ) + count++ ; + else + break ; + string++ ; + } + + return count ; +} diff --git a/device/lib/_strspn.lst b/device/lib/_strspn.lst new file mode 100644 index 00000000..ad019b85 --- /dev/null +++ b/device/lib/_strspn.lst @@ -0,0 +1,174 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strspn + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strspn_PARM_2 + 11 .globl _strspn + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strspn_sloc0_1_0: + 0000 23 .ds 0x0003 + 24 ;-------------------------------------------------------- + 25 ; overlayable items in internal ram + 26 ;-------------------------------------------------------- + 27 .area OSEG (OVR,DATA) + 28 ;-------------------------------------------------------- + 29 ; indirectly addressable internal ram data + 30 ;-------------------------------------------------------- + 31 .area ISEG (DATA) + 32 ;-------------------------------------------------------- + 33 ; bit data + 34 ;-------------------------------------------------------- + 35 .area BSEG (BIT) + 36 ;-------------------------------------------------------- + 37 ; external ram data + 38 ;-------------------------------------------------------- + 39 .area XSEG (XDATA) + 0000 40 _strspn_PARM_2: + 0000 41 .ds 0x0003 + 0003 42 _strspn_string_1_1: + 0003 43 .ds 0x0003 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$strspn$0$0 ==. + 53 ; _strspn.c 27 + 54 ; ----------------------------------------- + 55 ; function strspn + 56 ; ----------------------------------------- + 0000 57 _strspn: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _strspn.c 43 + 0000 C0 F0 67 push b + 0002 C0 83 68 push dph + 0004 C0 82 69 push dpl + 0006 90s00r03 70 mov dptr,#_strspn_string_1_1 + 0009 D0 E0 71 pop acc + 000B F0 72 movx @dptr,a + 000C D0 E0 73 pop acc + 000E A3 74 inc dptr + 000F F0 75 movx @dptr,a + 0010 D0 E0 76 pop acc + 0012 A3 77 inc dptr + 0013 F0 78 movx @dptr,a + 79 ; _strspn.c 35 + 0014 90s00r00 80 mov dptr,#_strspn_PARM_2 + 0017 E0 81 movx a,@dptr + 0018 F5*00 82 mov _strspn_sloc0_1_0,a + 001A A3 83 inc dptr + 001B E0 84 movx a,@dptr + 001C F5*01 85 mov (_strspn_sloc0_1_0 + 1),a + 001E A3 86 inc dptr + 001F E0 87 movx a,@dptr + 0020 F5*02 88 mov (_strspn_sloc0_1_0 + 2),a + 0022 7D 00 89 mov r5,#0x00 + 0024 7E 00 90 mov r6,#0x00 + 0026 90s00r03 91 mov dptr,#_strspn_string_1_1 + 0029 E0 92 movx a,@dptr + 002A FF 93 mov r7,a + 002B A3 94 inc dptr + 002C E0 95 movx a,@dptr + 002D F8 96 mov r0,a + 002E A3 97 inc dptr + 002F E0 98 movx a,@dptr + 0030 F9 99 mov r1,a + 0031 100 00104$: + 0031 8F 82 101 mov dpl,r7 + 0033 88 83 102 mov dph,r0 + 0035 89 F0 103 mov b,r1 + 0037 12s00r00 104 lcall __gptrget + 105 ; Peephole 105 removed redundant mov + 003A FA 106 mov r2,a + 107 ; Peephole 110 removed ljmp by inverse jump logic + 003B 60 48 108 jz 00106$ + 003D 109 00112$: + 110 ; _strspn.c 36 + 003D 90s00r00 111 mov dptr,#_strchr_PARM_2 + 0040 EA 112 mov a,r2 + 0041 F0 113 movx @dptr,a + 0042 C0 05 114 push ar5 + 0044 C0 06 115 push ar6 + 0046 C0 07 116 push ar7 + 0048 C0 00 117 push ar0 + 004A C0 01 118 push ar1 + 004C 85*00 82 119 mov dpl,_strspn_sloc0_1_0 + 004F 85*01 83 120 mov dph,(_strspn_sloc0_1_0 + 1) + 0052 85*02 F0 121 mov b,(_strspn_sloc0_1_0 + 2) + 0055 12s00r00 122 lcall _strchr + 0058 AA 82 123 mov r2,dpl + 005A AB 83 124 mov r3,dph + 005C AC F0 125 mov r4,b + 005E D0 01 126 pop ar1 + 0060 D0 00 127 pop ar0 + 0062 D0 07 128 pop ar7 + 0064 D0 06 129 pop ar6 + 0066 D0 05 130 pop ar5 + 0068 EA 131 mov a,r2 + 0069 4B 132 orl a,r3 + 006A 4C 133 orl a,r4 + 134 ; Peephole 110 removed ljmp by inverse jump logic + 006B 60 18 135 jz 00106$ + 006D 136 00113$: + 137 ; _strspn.c 37 + 006D 0D 138 inc r5 + 006E BD 00 01 139 cjne r5,#0x00,00114$ + 0071 0E 140 inc r6 + 0072 141 00114$: + 142 ; _strspn.c 40 + 0072 0F 143 inc r7 + 0073 BF 00 01 144 cjne r7,#0x00,00115$ + 0076 08 145 inc r0 + 0077 146 00115$: + 0077 90s00r03 147 mov dptr,#_strspn_string_1_1 + 007A EF 148 mov a,r7 + 007B F0 149 movx @dptr,a + 007C A3 150 inc dptr + 007D E8 151 mov a,r0 + 007E F0 152 movx @dptr,a + 007F A3 153 inc dptr + 0080 E9 154 mov a,r1 + 0081 F0 155 movx @dptr,a + 0082 02s00r31 156 ljmp 00104$ + 0085 157 00106$: + 158 ; _strspn.c 43 + 0085 90s00r03 159 mov dptr,#_strspn_string_1_1 + 0088 EF 160 mov a,r7 + 0089 F0 161 movx @dptr,a + 008A A3 162 inc dptr + 008B E8 163 mov a,r0 + 008C F0 164 movx @dptr,a + 008D A3 165 inc dptr + 008E E9 166 mov a,r1 + 008F F0 167 movx @dptr,a + 0090 8D 82 168 mov dpl,r5 + 0092 8E 83 169 mov dph,r6 + 0094 170 00107$: + 0094 171 C$_strspn.c$44$1$1 ==. + 0094 172 XG$strspn$0$0 ==. + 0094 22 173 ret + 174 .area CSEG (CODE) diff --git a/device/lib/_strspn.sym b/device/lib/_strspn.sym new file mode 100644 index 00000000..49fc17f0 --- /dev/null +++ b/device/lib/_strspn.sym @@ -0,0 +1,461 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strspn$101 0031 GR + 7 A$_strspn$102 0033 GR + 7 A$_strspn$103 0035 GR + 7 A$_strspn$104 0037 GR + 7 A$_strspn$106 003A GR + 7 A$_strspn$108 003B GR + 7 A$_strspn$111 003D GR + 7 A$_strspn$112 0040 GR + 7 A$_strspn$113 0041 GR + 7 A$_strspn$114 0042 GR + 7 A$_strspn$115 0044 GR + 7 A$_strspn$116 0046 GR + 7 A$_strspn$117 0048 GR + 7 A$_strspn$118 004A GR + 7 A$_strspn$119 004C GR + 7 A$_strspn$120 004F GR + 7 A$_strspn$121 0052 GR + 7 A$_strspn$122 0055 GR + 7 A$_strspn$123 0058 GR + 7 A$_strspn$124 005A GR + 7 A$_strspn$125 005C GR + 7 A$_strspn$126 005E GR + 7 A$_strspn$127 0060 GR + 7 A$_strspn$128 0062 GR + 7 A$_strspn$129 0064 GR + 7 A$_strspn$130 0066 GR + 7 A$_strspn$131 0068 GR + 7 A$_strspn$132 0069 GR + 7 A$_strspn$133 006A GR + 7 A$_strspn$135 006B GR + 7 A$_strspn$138 006D GR + 7 A$_strspn$139 006E GR + 7 A$_strspn$140 0071 GR + 7 A$_strspn$143 0072 GR + 7 A$_strspn$144 0073 GR + 7 A$_strspn$145 0076 GR + 7 A$_strspn$147 0077 GR + 7 A$_strspn$148 007A GR + 7 A$_strspn$149 007B GR + 7 A$_strspn$150 007C GR + 7 A$_strspn$151 007D GR + 7 A$_strspn$152 007E GR + 7 A$_strspn$153 007F GR + 7 A$_strspn$154 0080 GR + 7 A$_strspn$155 0081 GR + 7 A$_strspn$156 0082 GR + 7 A$_strspn$159 0085 GR + 7 A$_strspn$160 0088 GR + 7 A$_strspn$161 0089 GR + 7 A$_strspn$162 008A GR + 7 A$_strspn$163 008B GR + 7 A$_strspn$164 008C GR + 7 A$_strspn$165 008D GR + 7 A$_strspn$166 008E GR + 7 A$_strspn$167 008F GR + 7 A$_strspn$168 0090 GR + 7 A$_strspn$169 0092 GR + 7 A$_strspn$173 0094 GR + 7 A$_strspn$67 0000 GR + 7 A$_strspn$68 0002 GR + 7 A$_strspn$69 0004 GR + 7 A$_strspn$70 0006 GR + 7 A$_strspn$71 0009 GR + 7 A$_strspn$72 000B GR + 7 A$_strspn$73 000C GR + 7 A$_strspn$74 000E GR + 7 A$_strspn$75 000F GR + 7 A$_strspn$76 0010 GR + 7 A$_strspn$77 0012 GR + 7 A$_strspn$78 0013 GR + 7 A$_strspn$80 0014 GR + 7 A$_strspn$81 0017 GR + 7 A$_strspn$82 0018 GR + 7 A$_strspn$83 001A GR + 7 A$_strspn$84 001B GR + 7 A$_strspn$85 001C GR + 7 A$_strspn$86 001E GR + 7 A$_strspn$87 001F GR + 7 A$_strspn$88 0020 GR + 7 A$_strspn$89 0022 GR + 7 A$_strspn$90 0024 GR + 7 A$_strspn$91 0026 GR + 7 A$_strspn$92 0029 GR + 7 A$_strspn$93 002A GR + 7 A$_strspn$94 002B GR + 7 A$_strspn$95 002C GR + 7 A$_strspn$96 002D GR + 7 A$_strspn$97 002E GR + 7 A$_strspn$98 002F GR + 7 A$_strspn$99 0030 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strspn.c$44$1$1 = 0094 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strspn$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strspn$0$0 = 0094 GR + __gptrget **** GX + _strchr **** GX + _strchr_PARM_2 **** GX + 7 _strspn 0000 GR + 5 _strspn_PARM_2 0000 GR + 1 _strspn_sloc0_1_0 0000 R + 5 _strspn_string_1_1 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 3 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 6 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 95 flags 20 diff --git a/device/lib/_strstr.c b/device/lib/_strstr.c new file mode 100644 index 00000000..0d6bdc89 --- /dev/null +++ b/device/lib/_strstr.c @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------- + _strstr.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +char _generic * strstr ( + char _generic * str1, + char _generic * str2 + ) +{ + char _generic *cp = str1; + char _generic *s1; + char _generic *s2; + + if ( !*str2 ) + return str1; + + while (*cp) + { + s1 = cp; + s2 = str2; + + while ( *s1 && *s2 && !(*s1-*s2) ) + s1++, s2++; + + if (!*s2) + return(cp); + + cp++; + } + + return (NULL) ; +} diff --git a/device/lib/_strstr.lst b/device/lib/_strstr.lst new file mode 100644 index 00000000..d58484d4 --- /dev/null +++ b/device/lib/_strstr.lst @@ -0,0 +1,233 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strstr + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strstr_PARM_2 + 11 .globl _strstr + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 0000 22 _strstr_sloc0_1_0: + 0000 23 .ds 0x0003 + 0003 24 _strstr_sloc1_1_0: + 0003 25 .ds 0x0003 + 26 ;-------------------------------------------------------- + 27 ; overlayable items in internal ram + 28 ;-------------------------------------------------------- + 29 .area OSEG (OVR,DATA) + 30 ;-------------------------------------------------------- + 31 ; indirectly addressable internal ram data + 32 ;-------------------------------------------------------- + 33 .area ISEG (DATA) + 34 ;-------------------------------------------------------- + 35 ; bit data + 36 ;-------------------------------------------------------- + 37 .area BSEG (BIT) + 38 ;-------------------------------------------------------- + 39 ; external ram data + 40 ;-------------------------------------------------------- + 41 .area XSEG (XDATA) + 0000 42 _strstr_PARM_2: + 0000 43 .ds 0x0003 + 0003 44 _strstr_str1_1_1: + 0003 45 .ds 0x0003 + 0006 46 _strstr_cp_1_1: + 0006 47 .ds 0x0003 + 48 ;-------------------------------------------------------- + 49 ; global & static initialisations + 50 ;-------------------------------------------------------- + 51 .area GSINIT (CODE) + 52 ;-------------------------------------------------------- + 53 ; code + 54 ;-------------------------------------------------------- + 55 .area CSEG (CODE) + 0000 56 G$strstr$0$0 ==. + 57 ; _strstr.c 27 + 58 ; ----------------------------------------- + 59 ; function strstr + 60 ; ----------------------------------------- + 0000 61 _strstr: + 0002 62 ar2 = 0x02 + 0003 63 ar3 = 0x03 + 0004 64 ar4 = 0x04 + 0005 65 ar5 = 0x05 + 0006 66 ar6 = 0x06 + 0007 67 ar7 = 0x07 + 0000 68 ar0 = 0x00 + 0001 69 ar1 = 0x01 + 70 ; _strstr.c 0 + 0000 C0 F0 71 push b + 0002 C0 83 72 push dph + 0004 C0 82 73 push dpl + 0006 90s00r03 74 mov dptr,#_strstr_str1_1_1 + 0009 D0 E0 75 pop acc + 000B F0 76 movx @dptr,a + 000C D0 E0 77 pop acc + 000E A3 78 inc dptr + 000F F0 79 movx @dptr,a + 0010 D0 E0 80 pop acc + 0012 A3 81 inc dptr + 0013 F0 82 movx @dptr,a + 83 ; _strstr.c 32 + 0014 90s00r03 84 mov dptr,#_strstr_str1_1_1 + 0017 E0 85 movx a,@dptr + 0018 FA 86 mov r2,a + 0019 A3 87 inc dptr + 001A E0 88 movx a,@dptr + 001B FB 89 mov r3,a + 001C A3 90 inc dptr + 001D E0 91 movx a,@dptr + 001E FC 92 mov r4,a + 001F 90s00r06 93 mov dptr,#_strstr_cp_1_1 + 0022 EA 94 mov a,r2 + 0023 F0 95 movx @dptr,a + 0024 A3 96 inc dptr + 0025 EB 97 mov a,r3 + 0026 F0 98 movx @dptr,a + 0027 A3 99 inc dptr + 0028 EC 100 mov a,r4 + 0029 F0 101 movx @dptr,a + 102 ; _strstr.c 36 + 002A 90s00r00 103 mov dptr,#_strstr_PARM_2 + 002D E0 104 movx a,@dptr + 002E F5*00 105 mov _strstr_sloc0_1_0,a + 0030 A3 106 inc dptr + 0031 E0 107 movx a,@dptr + 0032 F5*01 108 mov (_strstr_sloc0_1_0 + 1),a + 0034 A3 109 inc dptr + 0035 E0 110 movx a,@dptr + 0036 F5*02 111 mov (_strstr_sloc0_1_0 + 2),a + 0038 85*00 82 112 mov dpl,_strstr_sloc0_1_0 + 003B 85*01 83 113 mov dph,(_strstr_sloc0_1_0 + 1) + 003E 85*02 F0 114 mov b,(_strstr_sloc0_1_0 + 2) + 0041 12s00r00 115 lcall __gptrget + 116 ; Peephole 105 removed redundant mov + 0044 F8 117 mov r0,a + 118 ; Peephole 109 removed ljmp by inverse jump logic + 0045 70 09 119 jnz 00122$ + 0047 120 00123$: + 121 ; _strstr.c 37 + 0047 8A 82 122 mov dpl,r2 + 0049 8B 83 123 mov dph,r3 + 004B 8C F0 124 mov b,r4 + 004D 02s00rD2 125 ljmp 00113$ + 126 ; _strstr.c 39 + 0050 127 00122$: + 0050 128 00110$: + 0050 8A 82 129 mov dpl,r2 + 0052 8B 83 130 mov dph,r3 + 0054 8C F0 131 mov b,r4 + 0056 12s00r00 132 lcall __gptrget + 133 ; Peephole 105 removed redundant mov + 0059 F8 134 mov r0,a + 005A 70 03 135 jnz 00124$ + 005C 02s00rCC 136 ljmp 00112$ + 005F 137 00124$: + 138 ; _strstr.c 44 + 005F 8A*03 139 mov _strstr_sloc1_1_0,r2 + 0061 8B*04 140 mov (_strstr_sloc1_1_0 + 1),r3 + 0063 8C*05 141 mov (_strstr_sloc1_1_0 + 2),r4 + 0065 AE*00 142 mov r6,_strstr_sloc0_1_0 + 0067 AF*01 143 mov r7,(_strstr_sloc0_1_0 + 1) + 0069 AD*02 144 mov r5,(_strstr_sloc0_1_0 + 2) + 006B 145 00105$: + 006B 85*03 82 146 mov dpl,_strstr_sloc1_1_0 + 006E 85*04 83 147 mov dph,(_strstr_sloc1_1_0 + 1) + 0071 85*05 F0 148 mov b,(_strstr_sloc1_1_0 + 2) + 0074 12s00r00 149 lcall __gptrget + 150 ; Peephole 105 removed redundant mov + 0077 F8 151 mov r0,a + 152 ; Peephole 110 removed ljmp by inverse jump logic + 0078 60 20 153 jz 00107$ + 007A 154 00125$: + 007A 8E 82 155 mov dpl,r6 + 007C 8F 83 156 mov dph,r7 + 007E 8D F0 157 mov b,r5 + 0080 12s00r00 158 lcall __gptrget + 159 ; Peephole 105 removed redundant mov + 0083 F9 160 mov r1,a + 161 ; Peephole 110 removed ljmp by inverse jump logic + 0084 60 14 162 jz 00107$ + 0086 163 00126$: + 0086 C3 164 clr c + 0087 E8 165 mov a,r0 + 0088 99 166 subb a,r1 + 167 ; Peephole 109 removed ljmp by inverse jump logic + 0089 70 0F 168 jnz 00107$ + 008B 169 00127$: + 170 ; _strstr.c 45 + 008B 05*03 171 inc _strstr_sloc1_1_0 + 008D E4 172 clr a + 008E B5*03 02 173 cjne a,_strstr_sloc1_1_0,00128$ + 0091 05*04 174 inc (_strstr_sloc1_1_0 + 1) + 0093 175 00128$: + 0093 0E 176 inc r6 + 0094 BE 00 01 177 cjne r6,#0x00,00129$ + 0097 0F 178 inc r7 + 0098 179 00129$: + 180 ; Peephole 132 changed ljmp to sjmp + 0098 80 D1 181 sjmp 00105$ + 009A 182 00107$: + 183 ; _strstr.c 47 + 009A 8E 82 184 mov dpl,r6 + 009C 8F 83 185 mov dph,r7 + 009E 8D F0 186 mov b,r5 + 00A0 12s00r00 187 lcall __gptrget + 188 ; Peephole 105 removed redundant mov + 00A3 FE 189 mov r6,a + 190 ; Peephole 109 removed ljmp by inverse jump logic + 00A4 70 13 191 jnz 00109$ + 00A6 192 00130$: + 193 ; _strstr.c 48 + 00A6 90s00r06 194 mov dptr,#_strstr_cp_1_1 + 00A9 E0 195 movx a,@dptr + 00AA FE 196 mov r6,a + 00AB A3 197 inc dptr + 00AC E0 198 movx a,@dptr + 00AD F8 199 mov r0,a + 00AE A3 200 inc dptr + 00AF E0 201 movx a,@dptr + 00B0 F9 202 mov r1,a + 00B1 8E 82 203 mov dpl,r6 + 00B3 88 83 204 mov dph,r0 + 00B5 89 F0 205 mov b,r1 + 206 ; Peephole 132 changed ljmp to sjmp + 00B7 80 19 207 sjmp 00113$ + 00B9 208 00109$: + 209 ; _strstr.c 50 + 00B9 0A 210 inc r2 + 00BA BA 00 01 211 cjne r2,#0x00,00131$ + 00BD 0B 212 inc r3 + 00BE 213 00131$: + 00BE 90s00r06 214 mov dptr,#_strstr_cp_1_1 + 00C1 EA 215 mov a,r2 + 00C2 F0 216 movx @dptr,a + 00C3 A3 217 inc dptr + 00C4 EB 218 mov a,r3 + 00C5 F0 219 movx @dptr,a + 00C6 A3 220 inc dptr + 00C7 EC 221 mov a,r4 + 00C8 F0 222 movx @dptr,a + 00C9 02s00r50 223 ljmp 00110$ + 00CC 224 00112$: + 225 ; _strstr.c 53 + 226 ; Peephole 181 used 16 bit load of dptr + 00CC 90 00 00 227 mov dptr,#0x0000 + 00CF 75 F0 00 228 mov b,#0x00 + 00D2 229 00113$: + 00D2 230 C$_strstr.c$54$1$1 ==. + 00D2 231 XG$strstr$0$0 ==. + 00D2 22 232 ret + 233 .area CSEG (CODE) diff --git a/device/lib/_strstr.sym b/device/lib/_strstr.sym new file mode 100644 index 00000000..9f2a14c3 --- /dev/null +++ b/device/lib/_strstr.sym @@ -0,0 +1,492 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strstr$100 0028 GR + 7 A$_strstr$101 0029 GR + 7 A$_strstr$103 002A GR + 7 A$_strstr$104 002D GR + 7 A$_strstr$105 002E GR + 7 A$_strstr$106 0030 GR + 7 A$_strstr$107 0031 GR + 7 A$_strstr$108 0032 GR + 7 A$_strstr$109 0034 GR + 7 A$_strstr$110 0035 GR + 7 A$_strstr$111 0036 GR + 7 A$_strstr$112 0038 GR + 7 A$_strstr$113 003B GR + 7 A$_strstr$114 003E GR + 7 A$_strstr$115 0041 GR + 7 A$_strstr$117 0044 GR + 7 A$_strstr$119 0045 GR + 7 A$_strstr$122 0047 GR + 7 A$_strstr$123 0049 GR + 7 A$_strstr$124 004B GR + 7 A$_strstr$125 004D GR + 7 A$_strstr$129 0050 GR + 7 A$_strstr$130 0052 GR + 7 A$_strstr$131 0054 GR + 7 A$_strstr$132 0056 GR + 7 A$_strstr$134 0059 GR + 7 A$_strstr$135 005A GR + 7 A$_strstr$136 005C GR + 7 A$_strstr$139 005F GR + 7 A$_strstr$140 0061 GR + 7 A$_strstr$141 0063 GR + 7 A$_strstr$142 0065 GR + 7 A$_strstr$143 0067 GR + 7 A$_strstr$144 0069 GR + 7 A$_strstr$146 006B GR + 7 A$_strstr$147 006E GR + 7 A$_strstr$148 0071 GR + 7 A$_strstr$149 0074 GR + 7 A$_strstr$151 0077 GR + 7 A$_strstr$153 0078 GR + 7 A$_strstr$155 007A GR + 7 A$_strstr$156 007C GR + 7 A$_strstr$157 007E GR + 7 A$_strstr$158 0080 GR + 7 A$_strstr$160 0083 GR + 7 A$_strstr$162 0084 GR + 7 A$_strstr$164 0086 GR + 7 A$_strstr$165 0087 GR + 7 A$_strstr$166 0088 GR + 7 A$_strstr$168 0089 GR + 7 A$_strstr$171 008B GR + 7 A$_strstr$172 008D GR + 7 A$_strstr$173 008E GR + 7 A$_strstr$174 0091 GR + 7 A$_strstr$176 0093 GR + 7 A$_strstr$177 0094 GR + 7 A$_strstr$178 0097 GR + 7 A$_strstr$181 0098 GR + 7 A$_strstr$184 009A GR + 7 A$_strstr$185 009C GR + 7 A$_strstr$186 009E GR + 7 A$_strstr$187 00A0 GR + 7 A$_strstr$189 00A3 GR + 7 A$_strstr$191 00A4 GR + 7 A$_strstr$194 00A6 GR + 7 A$_strstr$195 00A9 GR + 7 A$_strstr$196 00AA GR + 7 A$_strstr$197 00AB GR + 7 A$_strstr$198 00AC GR + 7 A$_strstr$199 00AD GR + 7 A$_strstr$200 00AE GR + 7 A$_strstr$201 00AF GR + 7 A$_strstr$202 00B0 GR + 7 A$_strstr$203 00B1 GR + 7 A$_strstr$204 00B3 GR + 7 A$_strstr$205 00B5 GR + 7 A$_strstr$207 00B7 GR + 7 A$_strstr$210 00B9 GR + 7 A$_strstr$211 00BA GR + 7 A$_strstr$212 00BD GR + 7 A$_strstr$214 00BE GR + 7 A$_strstr$215 00C1 GR + 7 A$_strstr$216 00C2 GR + 7 A$_strstr$217 00C3 GR + 7 A$_strstr$218 00C4 GR + 7 A$_strstr$219 00C5 GR + 7 A$_strstr$220 00C6 GR + 7 A$_strstr$221 00C7 GR + 7 A$_strstr$222 00C8 GR + 7 A$_strstr$223 00C9 GR + 7 A$_strstr$227 00CC GR + 7 A$_strstr$228 00CF GR + 7 A$_strstr$232 00D2 GR + 7 A$_strstr$71 0000 GR + 7 A$_strstr$72 0002 GR + 7 A$_strstr$73 0004 GR + 7 A$_strstr$74 0006 GR + 7 A$_strstr$75 0009 GR + 7 A$_strstr$76 000B GR + 7 A$_strstr$77 000C GR + 7 A$_strstr$78 000E GR + 7 A$_strstr$79 000F GR + 7 A$_strstr$80 0010 GR + 7 A$_strstr$81 0012 GR + 7 A$_strstr$82 0013 GR + 7 A$_strstr$84 0014 GR + 7 A$_strstr$85 0017 GR + 7 A$_strstr$86 0018 GR + 7 A$_strstr$87 0019 GR + 7 A$_strstr$88 001A GR + 7 A$_strstr$89 001B GR + 7 A$_strstr$90 001C GR + 7 A$_strstr$91 001D GR + 7 A$_strstr$92 001E GR + 7 A$_strstr$93 001F GR + 7 A$_strstr$94 0022 GR + 7 A$_strstr$95 0023 GR + 7 A$_strstr$96 0024 GR + 7 A$_strstr$97 0025 GR + 7 A$_strstr$98 0026 GR + 7 A$_strstr$99 0027 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strstr.c$54$1$1 = 00D2 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strstr$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strstr$0$0 = 00D2 GR + __gptrget **** GX + 7 _strstr 0000 GR + 5 _strstr_PARM_2 0000 GR + 5 _strstr_cp_1_1 0006 R + 1 _strstr_sloc0_1_0 0000 R + 1 _strstr_sloc1_1_0 0003 R + 5 _strstr_str1_1_1 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 9 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size D3 flags 20 diff --git a/device/lib/_strtok.c b/device/lib/_strtok.c new file mode 100644 index 00000000..b3193d4e --- /dev/null +++ b/device/lib/_strtok.c @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------- + _strtok.c - part of string library functions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "string.h" +#define NULL (void *)0 + +#ifdef SDCC_MODEL_LARGE +#pragma NOINDUCTION +#pragma NOINVARIANT +#endif + +char _generic *strtok ( + char _generic *str , + char _generic *control + ) +{ + static char _generic *s ; + register char _generic *s1 ; + + if ( str ) + s = str ; + + s1 = s ; + + while (*s) { + if (strchr(control,*s)) { + *s++ = '\0'; + return s1 ; + } + s++ ; + } + return (NULL); +} + diff --git a/device/lib/_strtok.lst b/device/lib/_strtok.lst new file mode 100644 index 00000000..a6ee0a5b --- /dev/null +++ b/device/lib/_strtok.lst @@ -0,0 +1,223 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _strtok + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _strtok_PARM_2 + 11 .globl _strtok + 12 ;-------------------------------------------------------- + 13 ; special function registers + 14 ;-------------------------------------------------------- + 15 ;-------------------------------------------------------- + 16 ; special function bits + 17 ;-------------------------------------------------------- + 18 ;-------------------------------------------------------- + 19 ; internal ram data + 20 ;-------------------------------------------------------- + 21 .area DSEG (DATA) + 22 ;-------------------------------------------------------- + 23 ; overlayable items in internal ram + 24 ;-------------------------------------------------------- + 25 .area OSEG (OVR,DATA) + 26 ;-------------------------------------------------------- + 27 ; indirectly addressable internal ram data + 28 ;-------------------------------------------------------- + 29 .area ISEG (DATA) + 30 ;-------------------------------------------------------- + 31 ; bit data + 32 ;-------------------------------------------------------- + 33 .area BSEG (BIT) + 34 ;-------------------------------------------------------- + 35 ; external ram data + 36 ;-------------------------------------------------------- + 37 .area XSEG (XDATA) + 0000 38 _strtok_PARM_2: + 0000 39 .ds 0x0003 + 0003 40 _strtok_str_1_1: + 0003 41 .ds 0x0003 + 0006 42 _strtok_s_1_1: + 0006 43 .ds 0x0003 + 44 ;-------------------------------------------------------- + 45 ; global & static initialisations + 46 ;-------------------------------------------------------- + 47 .area GSINIT (CODE) + 48 ;-------------------------------------------------------- + 49 ; code + 50 ;-------------------------------------------------------- + 51 .area CSEG (CODE) + 0000 52 G$strtok$0$0 ==. + 53 ; _strtok.c 32 + 54 ; ----------------------------------------- + 55 ; function strtok + 56 ; ----------------------------------------- + 0000 57 _strtok: + 0002 58 ar2 = 0x02 + 0003 59 ar3 = 0x03 + 0004 60 ar4 = 0x04 + 0005 61 ar5 = 0x05 + 0006 62 ar6 = 0x06 + 0007 63 ar7 = 0x07 + 0000 64 ar0 = 0x00 + 0001 65 ar1 = 0x01 + 66 ; _strtok.c 0 + 0000 C0 F0 67 push b + 0002 C0 83 68 push dph + 0004 C0 82 69 push dpl + 0006 90s00r03 70 mov dptr,#_strtok_str_1_1 + 0009 D0 E0 71 pop acc + 000B F0 72 movx @dptr,a + 000C D0 E0 73 pop acc + 000E A3 74 inc dptr + 000F F0 75 movx @dptr,a + 0010 D0 E0 76 pop acc + 0012 A3 77 inc dptr + 0013 F0 78 movx @dptr,a + 79 ; _strtok.c 40 + 0014 90s00r03 80 mov dptr,#_strtok_str_1_1 + 0017 E0 81 movx a,@dptr + 0018 FA 82 mov r2,a + 0019 A3 83 inc dptr + 001A E0 84 movx a,@dptr + 001B FB 85 mov r3,a + 001C A3 86 inc dptr + 001D E0 87 movx a,@dptr + 001E FC 88 mov r4,a + 001F EA 89 mov a,r2 + 0020 4B 90 orl a,r3 + 0021 4C 91 orl a,r4 + 92 ; Peephole 110 removed ljmp by inverse jump logic + 0022 60 0B 93 jz 00102$ + 0024 94 00114$: + 95 ; _strtok.c 41 + 0024 90s00r06 96 mov dptr,#_strtok_s_1_1 + 0027 EA 97 mov a,r2 + 0028 F0 98 movx @dptr,a + 0029 A3 99 inc dptr + 002A EB 100 mov a,r3 + 002B F0 101 movx @dptr,a + 002C A3 102 inc dptr + 002D EC 103 mov a,r4 + 002E F0 104 movx @dptr,a + 002F 105 00102$: + 106 ; _strtok.c 43 + 002F 90s00r06 107 mov dptr,#_strtok_s_1_1 + 0032 E0 108 movx a,@dptr + 0033 FA 109 mov r2,a + 0034 A3 110 inc dptr + 0035 E0 111 movx a,@dptr + 0036 FB 112 mov r3,a + 0037 A3 113 inc dptr + 0038 E0 114 movx a,@dptr + 0039 FC 115 mov r4,a + 116 ; _strtok.c 45 + 003A 117 00105$: + 003A 90s00r06 118 mov dptr,#_strtok_s_1_1 + 003D E0 119 movx a,@dptr + 003E FD 120 mov r5,a + 003F A3 121 inc dptr + 0040 E0 122 movx a,@dptr + 0041 FE 123 mov r6,a + 0042 A3 124 inc dptr + 0043 E0 125 movx a,@dptr + 0044 FF 126 mov r7,a + 0045 8D 82 127 mov dpl,r5 + 0047 8E 83 128 mov dph,r6 + 0049 8F F0 129 mov b,r7 + 004B 12s00r00 130 lcall __gptrget + 131 ; Peephole 105 removed redundant mov + 004E F8 132 mov r0,a + 004F 70 03 133 jnz 00115$ + 0051 02s00rC1 134 ljmp 00107$ + 0054 135 00115$: + 136 ; _strtok.c 46 + 0054 C0 02 137 push ar2 + 0056 C0 03 138 push ar3 + 0058 C0 04 139 push ar4 + 005A 90s00r00 140 mov dptr,#_strtok_PARM_2 + 005D E0 141 movx a,@dptr + 005E F9 142 mov r1,a + 005F A3 143 inc dptr + 0060 E0 144 movx a,@dptr + 0061 FA 145 mov r2,a + 0062 A3 146 inc dptr + 0063 E0 147 movx a,@dptr + 0064 FB 148 mov r3,a + 0065 90s00r00 149 mov dptr,#_strchr_PARM_2 + 0068 E8 150 mov a,r0 + 0069 F0 151 movx @dptr,a + 006A C0 05 152 push ar5 + 006C C0 06 153 push ar6 + 006E C0 07 154 push ar7 + 0070 89 82 155 mov dpl,r1 + 0072 8A 83 156 mov dph,r2 + 0074 8B F0 157 mov b,r3 + 0076 12s00r00 158 lcall _strchr + 0079 AA 82 159 mov r2,dpl + 007B AB 83 160 mov r3,dph + 007D AC F0 161 mov r4,b + 007F D0 07 162 pop ar7 + 0081 D0 06 163 pop ar6 + 0083 D0 05 164 pop ar5 + 0085 EA 165 mov a,r2 + 0086 4B 166 orl a,r3 + 0087 4C 167 orl a,r4 + 0088 D0 04 168 pop ar4 + 008A D0 03 169 pop ar3 + 008C D0 02 170 pop ar2 + 171 ; Peephole 110 removed ljmp by inverse jump logic + 008E 60 20 172 jz 00104$ + 0090 173 00116$: + 174 ; _strtok.c 47 + 0090 90s00r06 175 mov dptr,#_strtok_s_1_1 + 0093 74 01 176 mov a,#0x01 + 0095 2D 177 add a,r5 + 0096 F0 178 movx @dptr,a + 179 ; Peephole 180 changed mov to clr + 0097 E4 180 clr a + 0098 3E 181 addc a,r6 + 0099 A3 182 inc dptr + 009A F0 183 movx @dptr,a + 009B A3 184 inc dptr + 009C EF 185 mov a,r7 + 009D F0 186 movx @dptr,a + 009E 8D 82 187 mov dpl,r5 + 00A0 8E 83 188 mov dph,r6 + 00A2 8F F0 189 mov b,r7 + 190 ; Peephole 180 changed mov to clr + 00A4 E4 191 clr a + 00A5 12s00r00 192 lcall __gptrput + 193 ; _strtok.c 48 + 00A8 8A 82 194 mov dpl,r2 + 00AA 8B 83 195 mov dph,r3 + 00AC 8C F0 196 mov b,r4 + 197 ; Peephole 132 changed ljmp to sjmp + 00AE 80 17 198 sjmp 00108$ + 00B0 199 00104$: + 200 ; _strtok.c 50 + 00B0 90s00r06 201 mov dptr,#_strtok_s_1_1 + 00B3 74 01 202 mov a,#0x01 + 00B5 2D 203 add a,r5 + 00B6 F0 204 movx @dptr,a + 205 ; Peephole 180 changed mov to clr + 00B7 E4 206 clr a + 00B8 3E 207 addc a,r6 + 00B9 A3 208 inc dptr + 00BA F0 209 movx @dptr,a + 00BB A3 210 inc dptr + 00BC EF 211 mov a,r7 + 00BD F0 212 movx @dptr,a + 00BE 02s00r3A 213 ljmp 00105$ + 00C1 214 00107$: + 215 ; _strtok.c 52 + 216 ; Peephole 181 used 16 bit load of dptr + 00C1 90 00 00 217 mov dptr,#0x0000 + 00C4 75 F0 00 218 mov b,#0x00 + 00C7 219 00108$: + 00C7 220 C$_strtok.c$53$1$1 ==. + 00C7 221 XG$strtok$0$0 ==. + 00C7 22 222 ret + 223 .area CSEG (CODE) diff --git a/device/lib/_strtok.sym b/device/lib/_strtok.sym new file mode 100644 index 00000000..cdc73a08 --- /dev/null +++ b/device/lib/_strtok.sym @@ -0,0 +1,501 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_strtok$100 002A GR + 7 A$_strtok$101 002B GR + 7 A$_strtok$102 002C GR + 7 A$_strtok$103 002D GR + 7 A$_strtok$104 002E GR + 7 A$_strtok$107 002F GR + 7 A$_strtok$108 0032 GR + 7 A$_strtok$109 0033 GR + 7 A$_strtok$110 0034 GR + 7 A$_strtok$111 0035 GR + 7 A$_strtok$112 0036 GR + 7 A$_strtok$113 0037 GR + 7 A$_strtok$114 0038 GR + 7 A$_strtok$115 0039 GR + 7 A$_strtok$118 003A GR + 7 A$_strtok$119 003D GR + 7 A$_strtok$120 003E GR + 7 A$_strtok$121 003F GR + 7 A$_strtok$122 0040 GR + 7 A$_strtok$123 0041 GR + 7 A$_strtok$124 0042 GR + 7 A$_strtok$125 0043 GR + 7 A$_strtok$126 0044 GR + 7 A$_strtok$127 0045 GR + 7 A$_strtok$128 0047 GR + 7 A$_strtok$129 0049 GR + 7 A$_strtok$130 004B GR + 7 A$_strtok$132 004E GR + 7 A$_strtok$133 004F GR + 7 A$_strtok$134 0051 GR + 7 A$_strtok$137 0054 GR + 7 A$_strtok$138 0056 GR + 7 A$_strtok$139 0058 GR + 7 A$_strtok$140 005A GR + 7 A$_strtok$141 005D GR + 7 A$_strtok$142 005E GR + 7 A$_strtok$143 005F GR + 7 A$_strtok$144 0060 GR + 7 A$_strtok$145 0061 GR + 7 A$_strtok$146 0062 GR + 7 A$_strtok$147 0063 GR + 7 A$_strtok$148 0064 GR + 7 A$_strtok$149 0065 GR + 7 A$_strtok$150 0068 GR + 7 A$_strtok$151 0069 GR + 7 A$_strtok$152 006A GR + 7 A$_strtok$153 006C GR + 7 A$_strtok$154 006E GR + 7 A$_strtok$155 0070 GR + 7 A$_strtok$156 0072 GR + 7 A$_strtok$157 0074 GR + 7 A$_strtok$158 0076 GR + 7 A$_strtok$159 0079 GR + 7 A$_strtok$160 007B GR + 7 A$_strtok$161 007D GR + 7 A$_strtok$162 007F GR + 7 A$_strtok$163 0081 GR + 7 A$_strtok$164 0083 GR + 7 A$_strtok$165 0085 GR + 7 A$_strtok$166 0086 GR + 7 A$_strtok$167 0087 GR + 7 A$_strtok$168 0088 GR + 7 A$_strtok$169 008A GR + 7 A$_strtok$170 008C GR + 7 A$_strtok$172 008E GR + 7 A$_strtok$175 0090 GR + 7 A$_strtok$176 0093 GR + 7 A$_strtok$177 0095 GR + 7 A$_strtok$178 0096 GR + 7 A$_strtok$180 0097 GR + 7 A$_strtok$181 0098 GR + 7 A$_strtok$182 0099 GR + 7 A$_strtok$183 009A GR + 7 A$_strtok$184 009B GR + 7 A$_strtok$185 009C GR + 7 A$_strtok$186 009D GR + 7 A$_strtok$187 009E GR + 7 A$_strtok$188 00A0 GR + 7 A$_strtok$189 00A2 GR + 7 A$_strtok$191 00A4 GR + 7 A$_strtok$192 00A5 GR + 7 A$_strtok$194 00A8 GR + 7 A$_strtok$195 00AA GR + 7 A$_strtok$196 00AC GR + 7 A$_strtok$198 00AE GR + 7 A$_strtok$201 00B0 GR + 7 A$_strtok$202 00B3 GR + 7 A$_strtok$203 00B5 GR + 7 A$_strtok$204 00B6 GR + 7 A$_strtok$206 00B7 GR + 7 A$_strtok$207 00B8 GR + 7 A$_strtok$208 00B9 GR + 7 A$_strtok$209 00BA GR + 7 A$_strtok$210 00BB GR + 7 A$_strtok$211 00BC GR + 7 A$_strtok$212 00BD GR + 7 A$_strtok$213 00BE GR + 7 A$_strtok$217 00C1 GR + 7 A$_strtok$218 00C4 GR + 7 A$_strtok$222 00C7 GR + 7 A$_strtok$67 0000 GR + 7 A$_strtok$68 0002 GR + 7 A$_strtok$69 0004 GR + 7 A$_strtok$70 0006 GR + 7 A$_strtok$71 0009 GR + 7 A$_strtok$72 000B GR + 7 A$_strtok$73 000C GR + 7 A$_strtok$74 000E GR + 7 A$_strtok$75 000F GR + 7 A$_strtok$76 0010 GR + 7 A$_strtok$77 0012 GR + 7 A$_strtok$78 0013 GR + 7 A$_strtok$80 0014 GR + 7 A$_strtok$81 0017 GR + 7 A$_strtok$82 0018 GR + 7 A$_strtok$83 0019 GR + 7 A$_strtok$84 001A GR + 7 A$_strtok$85 001B GR + 7 A$_strtok$86 001C GR + 7 A$_strtok$87 001D GR + 7 A$_strtok$88 001E GR + 7 A$_strtok$89 001F GR + 7 A$_strtok$90 0020 GR + 7 A$_strtok$91 0021 GR + 7 A$_strtok$93 0022 GR + 7 A$_strtok$96 0024 GR + 7 A$_strtok$97 0027 GR + 7 A$_strtok$98 0028 GR + 7 A$_strtok$99 0029 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_strtok.c$53$1$1 = 00C7 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$strtok$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$strtok$0$0 = 00C7 GR + __gptrget **** GX + __gptrput **** GX + _strchr **** GX + _strchr_PARM_2 **** GX + 7 _strtok 0000 GR + 5 _strtok_PARM_2 0000 GR + 5 _strtok_s_1_1 0006 R + 5 _strtok_str_1_1 0003 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 9 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size C8 flags 20 diff --git a/device/lib/_uchar2fs.c b/device/lib/_uchar2fs.c new file mode 100644 index 00000000..d7b74b27 --- /dev/null +++ b/device/lib/_uchar2fs.c @@ -0,0 +1,110 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +float +__uchar2fs (unsigned char a ) +{ + long sign = 0; + int exp = 24 + EXCESS; + volatile union float_long fl; + long a1 = a; + + if (!a1) + { + fl.l = 0; + return (fl.f); + } + + if (a1 < 0) + { + sign = SIGNBIT; + a1 = -a1; + } + + while (a1 < HIDDEN) + { + a1 <<= 1; + exp--; + } + + a1 &= ~HIDDEN; + /* pack up and go home */ + fl.l = PACK(sign,(unsigned long)exp, a1); + + return (fl.f); +} diff --git a/device/lib/_uchar2fs.lst b/device/lib/_uchar2fs.lst new file mode 100644 index 00000000..34cb7012 --- /dev/null +++ b/device/lib/_uchar2fs.lst @@ -0,0 +1,334 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _uchar2fs + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___uchar2fs + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___uchar2fs_sloc0_1_0: + 0000 22 .ds 0x0002 + 0002 23 ___uchar2fs_sloc1_1_0: + 0002 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___uchar2fs_a_1_1: + 0000 42 .ds 0x0001 + 0001 43 ___uchar2fs_sign_1_1: + 0001 44 .ds 0x0004 + 0005 45 ___uchar2fs_fl_1_1: + 0005 46 .ds 0x0004 + 0009 47 ___uchar2fs_a1_1_1: + 0009 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__uchar2fs$0$0 ==. + 58 ; _uchar2fs.c 80 + 59 ; ----------------------------------------- + 60 ; function __uchar2fs + 61 ; ----------------------------------------- + 0000 62 ___uchar2fs: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _uchar2fs.c 109 + 0000 C0 82 72 push dpl + 0002 90s00r00 73 mov dptr,#___uchar2fs_a_1_1 + 0005 D0 E0 74 pop acc + 0007 F0 75 movx @dptr,a + 76 ; _uchar2fs.c 82 + 0008 90s00r01 77 mov dptr,#___uchar2fs_sign_1_1 + 000B E4 78 clr a + 000C A3 79 inc dptr + 000D A3 80 inc dptr + 000E A3 81 inc dptr + 000F F0 82 movx @dptr,a + 0010 12s00r00 83 lcall __decdptr + 0013 F0 84 movx @dptr,a + 0014 12s00r00 85 lcall __decdptr + 0017 F0 86 movx @dptr,a + 0018 12s00r00 87 lcall __decdptr + 001B F0 88 movx @dptr,a + 89 ; _uchar2fs.c 85 + 001C 90s00r00 90 mov dptr,#___uchar2fs_a_1_1 + 001F E0 91 movx a,@dptr + 92 ; Peephole 105 removed redundant mov + 0020 FA 93 mov r2,a + 0021 33 94 rlc a + 0022 95 E0 95 subb a,acc + 0024 FB 96 mov r3,a + 0025 FC 97 mov r4,a + 0026 FD 98 mov r5,a + 0027 90s00r09 99 mov dptr,#___uchar2fs_a1_1_1 + 002A EA 100 mov a,r2 + 002B F0 101 movx @dptr,a + 002C A3 102 inc dptr + 002D EB 103 mov a,r3 + 002E F0 104 movx @dptr,a + 002F A3 105 inc dptr + 0030 EC 106 mov a,r4 + 0031 F0 107 movx @dptr,a + 0032 A3 108 inc dptr + 0033 ED 109 mov a,r5 + 0034 F0 110 movx @dptr,a + 111 ; _uchar2fs.c 87 + 0035 EA 112 mov a,r2 + 0036 4B 113 orl a,r3 + 0037 4C 114 orl a,r4 + 0038 4D 115 orl a,r5 + 116 ; Peephole 109 removed ljmp by inverse jump logic + 0039 70 23 117 jnz 00102$ + 003B 118 00114$: + 119 ; _uchar2fs.c 89 + 003B 90s00r05 120 mov dptr,#(___uchar2fs_fl_1_1) + 121 ; Peephole 101 removed redundant mov + 122 ; Peephole 180 changed mov to clr + 003E E4 123 clr a + 003F F0 124 movx @dptr,a + 0040 A3 125 inc dptr + 0041 F0 126 movx @dptr,a + 0042 A3 127 inc dptr + 128 ; Peephole 101 removed redundant mov + 129 ; Peephole 180 changed mov to clr + 0043 E4 130 clr a + 0044 F0 131 movx @dptr,a + 0045 A3 132 inc dptr + 0046 F0 133 movx @dptr,a + 134 ; _uchar2fs.c 90 + 0047 90s00r05 135 mov dptr,#(___uchar2fs_fl_1_1) + 004A E0 136 movx a,@dptr + 004B FE 137 mov r6,a + 004C A3 138 inc dptr + 004D E0 139 movx a,@dptr + 004E FF 140 mov r7,a + 004F A3 141 inc dptr + 0050 E0 142 movx a,@dptr + 0051 F8 143 mov r0,a + 0052 A3 144 inc dptr + 0053 E0 145 movx a,@dptr + 146 ; Peephole 191 removed redundant mov + 0054 F9 147 mov r1,a + 0055 8E 82 148 mov dpl,r6 + 0057 8F 83 149 mov dph,r7 + 0059 88 F0 150 mov b,r0 + 005B 02s01r3B 151 ljmp 00108$ + 005E 152 00102$: + 153 ; _uchar2fs.c 93 + 005E ED 154 mov a,r5 + 155 ; Peephole 111 removed ljmp by inverse jump logic + 005F 30 E7 21 156 jnb acc.7,00113$ + 0062 157 00115$: + 158 ; _uchar2fs.c 95 + 0062 90s00r01 159 mov dptr,#___uchar2fs_sign_1_1 + 160 ; Peephole 101 removed redundant mov + 161 ; Peephole 180 changed mov to clr + 0065 E4 162 clr a + 0066 F0 163 movx @dptr,a + 0067 A3 164 inc dptr + 0068 F0 165 movx @dptr,a + 0069 A3 166 inc dptr + 167 ; Peephole 180 changed mov to clr + 006A E4 168 clr a + 006B F0 169 movx @dptr,a + 006C A3 170 inc dptr + 006D 74 80 171 mov a,#0x80 + 006F F0 172 movx @dptr,a + 173 ; _uchar2fs.c 96 + 0070 90s00r09 174 mov dptr,#___uchar2fs_a1_1_1 + 0073 C3 175 clr c + 0074 E4 176 clr a + 0075 9A 177 subb a,r2 + 0076 F0 178 movx @dptr,a + 0077 E4 179 clr a + 0078 9B 180 subb a,r3 + 0079 A3 181 inc dptr + 007A F0 182 movx @dptr,a + 007B E4 183 clr a + 007C 9C 184 subb a,r4 + 007D A3 185 inc dptr + 007E F0 186 movx @dptr,a + 007F E4 187 clr a + 0080 9D 188 subb a,r5 + 0081 A3 189 inc dptr + 0082 F0 190 movx @dptr,a + 191 ; _uchar2fs.c 99 + 0083 192 00113$: + 0083 E4 193 clr a + 0084 F5*01 194 mov (___uchar2fs_sloc0_1_0 + 1),a + 0086 75*00 96 195 mov ___uchar2fs_sloc0_1_0,#0x96 + 0089 196 00105$: + 0089 90s00r09 197 mov dptr,#___uchar2fs_a1_1_1 + 008C E0 198 movx a,@dptr + 008D FC 199 mov r4,a + 008E A3 200 inc dptr + 008F E0 201 movx a,@dptr + 0090 FD 202 mov r5,a + 0091 A3 203 inc dptr + 0092 E0 204 movx a,@dptr + 0093 FE 205 mov r6,a + 0094 A3 206 inc dptr + 0095 E0 207 movx a,@dptr + 0096 FF 208 mov r7,a + 0097 C3 209 clr c + 0098 EC 210 mov a,r4 + 0099 94 00 211 subb a,#0x00 + 009B ED 212 mov a,r5 + 009C 94 00 213 subb a,#0x00 + 009E EE 214 mov a,r6 + 009F 94 80 215 subb a,#0x80 + 00A1 EF 216 mov a,r7 + 00A2 94 00 217 subb a,#0x00 + 218 ; Peephole 108 removed ljmp by inverse jump logic + 00A4 50 27 219 jnc 00107$ + 00A6 220 00116$: + 221 ; _uchar2fs.c 101 + 00A6 EC 222 mov a,r4 + 00A7 25 E0 223 add a,acc + 00A9 F8 224 mov r0,a + 00AA ED 225 mov a,r5 + 00AB 33 226 rlc a + 00AC F9 227 mov r1,a + 00AD EE 228 mov a,r6 + 00AE 33 229 rlc a + 00AF FA 230 mov r2,a + 00B0 EF 231 mov a,r7 + 00B1 33 232 rlc a + 00B2 FB 233 mov r3,a + 00B3 90s00r09 234 mov dptr,#___uchar2fs_a1_1_1 + 00B6 E8 235 mov a,r0 + 00B7 F0 236 movx @dptr,a + 00B8 A3 237 inc dptr + 00B9 E9 238 mov a,r1 + 00BA F0 239 movx @dptr,a + 00BB A3 240 inc dptr + 00BC EA 241 mov a,r2 + 00BD F0 242 movx @dptr,a + 00BE A3 243 inc dptr + 00BF EB 244 mov a,r3 + 00C0 F0 245 movx @dptr,a + 246 ; _uchar2fs.c 102 + 00C1 15*00 247 dec ___uchar2fs_sloc0_1_0 + 00C3 74 FF 248 mov a,#0xff + 00C5 B5*00 02 249 cjne a,___uchar2fs_sloc0_1_0,00117$ + 00C8 15*01 250 dec (___uchar2fs_sloc0_1_0 + 1) + 00CA 251 00117$: + 00CA 02s00r89 252 ljmp 00105$ + 00CD 253 00107$: + 254 ; _uchar2fs.c 105 + 00CD 53 06 7F 255 anl ar6,#0x7f + 256 ; _uchar2fs.c 107 + 00D0 AA*00 257 mov r2,___uchar2fs_sloc0_1_0 + 00D2 AB*01 258 mov r3,(___uchar2fs_sloc0_1_0 + 1) + 00D4 78 00 259 mov r0,#0x00 + 00D6 79 00 260 mov r1,#0x00 + 00D8 8A*04 261 mov (___uchar2fs_sloc1_1_0 + 2),r2 + 00DA EB 262 mov a,r3 + 00DB 54 01 263 anl a,#0x01 + 00DD A2 E0 264 mov c,acc.0 + 00DF C5*04 265 xch a,(___uchar2fs_sloc1_1_0 + 2) + 00E1 13 266 rrc a + 00E2 C5*04 267 xch a,(___uchar2fs_sloc1_1_0 + 2) + 00E4 13 268 rrc a + 00E5 C5*04 269 xch a,(___uchar2fs_sloc1_1_0 + 2) + 00E7 F5*05 270 mov (___uchar2fs_sloc1_1_0 + 3),a + 00E9 75*03 00 271 mov (___uchar2fs_sloc1_1_0 + 1),#0x00 + 00EC 75*02 00 272 mov ___uchar2fs_sloc1_1_0,#0x00 + 00EF 90s00r01 273 mov dptr,#___uchar2fs_sign_1_1 + 00F2 E0 274 movx a,@dptr + 00F3 FA 275 mov r2,a + 00F4 A3 276 inc dptr + 00F5 E0 277 movx a,@dptr + 00F6 FB 278 mov r3,a + 00F7 A3 279 inc dptr + 00F8 E0 280 movx a,@dptr + 00F9 F8 281 mov r0,a + 00FA A3 282 inc dptr + 00FB E0 283 movx a,@dptr + 00FC F9 284 mov r1,a + 00FD E5*02 285 mov a,___uchar2fs_sloc1_1_0 + 00FF 42 02 286 orl ar2,a + 0101 E5*03 287 mov a,(___uchar2fs_sloc1_1_0 + 1) + 0103 42 03 288 orl ar3,a + 0105 E5*04 289 mov a,(___uchar2fs_sloc1_1_0 + 2) + 0107 42 00 290 orl ar0,a + 0109 E5*05 291 mov a,(___uchar2fs_sloc1_1_0 + 3) + 010B 42 01 292 orl ar1,a + 010D EA 293 mov a,r2 + 010E 42 04 294 orl ar4,a + 0110 EB 295 mov a,r3 + 0111 42 05 296 orl ar5,a + 0113 E8 297 mov a,r0 + 0114 42 06 298 orl ar6,a + 0116 E9 299 mov a,r1 + 0117 42 07 300 orl ar7,a + 0119 90s00r05 301 mov dptr,#(___uchar2fs_fl_1_1) + 011C EC 302 mov a,r4 + 011D F0 303 movx @dptr,a + 011E A3 304 inc dptr + 011F ED 305 mov a,r5 + 0120 F0 306 movx @dptr,a + 0121 A3 307 inc dptr + 0122 EE 308 mov a,r6 + 0123 F0 309 movx @dptr,a + 0124 A3 310 inc dptr + 0125 EF 311 mov a,r7 + 0126 F0 312 movx @dptr,a + 313 ; _uchar2fs.c 109 + 0127 90s00r05 314 mov dptr,#(___uchar2fs_fl_1_1) + 012A E0 315 movx a,@dptr + 012B FA 316 mov r2,a + 012C A3 317 inc dptr + 012D E0 318 movx a,@dptr + 012E FB 319 mov r3,a + 012F A3 320 inc dptr + 0130 E0 321 movx a,@dptr + 0131 FC 322 mov r4,a + 0132 A3 323 inc dptr + 0133 E0 324 movx a,@dptr + 325 ; Peephole 191 removed redundant mov + 0134 FD 326 mov r5,a + 0135 8A 82 327 mov dpl,r2 + 0137 8B 83 328 mov dph,r3 + 0139 8C F0 329 mov b,r4 + 013B 330 00108$: + 013B 331 C$_uchar2fs.c$110$1$1 ==. + 013B 332 XG$__uchar2fs$0$0 ==. + 013B 22 333 ret + 334 .area CSEG (CODE) diff --git a/device/lib/_uchar2fs.sym b/device/lib/_uchar2fs.sym new file mode 100644 index 00000000..e6bfcfbc --- /dev/null +++ b/device/lib/_uchar2fs.sym @@ -0,0 +1,596 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_uchar2fs$100 002A GR + 7 A$_uchar2fs$101 002B GR + 7 A$_uchar2fs$102 002C GR + 7 A$_uchar2fs$103 002D GR + 7 A$_uchar2fs$104 002E GR + 7 A$_uchar2fs$105 002F GR + 7 A$_uchar2fs$106 0030 GR + 7 A$_uchar2fs$107 0031 GR + 7 A$_uchar2fs$108 0032 GR + 7 A$_uchar2fs$109 0033 GR + 7 A$_uchar2fs$110 0034 GR + 7 A$_uchar2fs$112 0035 GR + 7 A$_uchar2fs$113 0036 GR + 7 A$_uchar2fs$114 0037 GR + 7 A$_uchar2fs$115 0038 GR + 7 A$_uchar2fs$117 0039 GR + 7 A$_uchar2fs$120 003B GR + 7 A$_uchar2fs$123 003E GR + 7 A$_uchar2fs$124 003F GR + 7 A$_uchar2fs$125 0040 GR + 7 A$_uchar2fs$126 0041 GR + 7 A$_uchar2fs$127 0042 GR + 7 A$_uchar2fs$130 0043 GR + 7 A$_uchar2fs$131 0044 GR + 7 A$_uchar2fs$132 0045 GR + 7 A$_uchar2fs$133 0046 GR + 7 A$_uchar2fs$135 0047 GR + 7 A$_uchar2fs$136 004A GR + 7 A$_uchar2fs$137 004B GR + 7 A$_uchar2fs$138 004C GR + 7 A$_uchar2fs$139 004D GR + 7 A$_uchar2fs$140 004E GR + 7 A$_uchar2fs$141 004F GR + 7 A$_uchar2fs$142 0050 GR + 7 A$_uchar2fs$143 0051 GR + 7 A$_uchar2fs$144 0052 GR + 7 A$_uchar2fs$145 0053 GR + 7 A$_uchar2fs$147 0054 GR + 7 A$_uchar2fs$148 0055 GR + 7 A$_uchar2fs$149 0057 GR + 7 A$_uchar2fs$150 0059 GR + 7 A$_uchar2fs$151 005B GR + 7 A$_uchar2fs$154 005E GR + 7 A$_uchar2fs$156 005F GR + 7 A$_uchar2fs$159 0062 GR + 7 A$_uchar2fs$162 0065 GR + 7 A$_uchar2fs$163 0066 GR + 7 A$_uchar2fs$164 0067 GR + 7 A$_uchar2fs$165 0068 GR + 7 A$_uchar2fs$166 0069 GR + 7 A$_uchar2fs$168 006A GR + 7 A$_uchar2fs$169 006B GR + 7 A$_uchar2fs$170 006C GR + 7 A$_uchar2fs$171 006D GR + 7 A$_uchar2fs$172 006F GR + 7 A$_uchar2fs$174 0070 GR + 7 A$_uchar2fs$175 0073 GR + 7 A$_uchar2fs$176 0074 GR + 7 A$_uchar2fs$177 0075 GR + 7 A$_uchar2fs$178 0076 GR + 7 A$_uchar2fs$179 0077 GR + 7 A$_uchar2fs$180 0078 GR + 7 A$_uchar2fs$181 0079 GR + 7 A$_uchar2fs$182 007A GR + 7 A$_uchar2fs$183 007B GR + 7 A$_uchar2fs$184 007C GR + 7 A$_uchar2fs$185 007D GR + 7 A$_uchar2fs$186 007E GR + 7 A$_uchar2fs$187 007F GR + 7 A$_uchar2fs$188 0080 GR + 7 A$_uchar2fs$189 0081 GR + 7 A$_uchar2fs$190 0082 GR + 7 A$_uchar2fs$193 0083 GR + 7 A$_uchar2fs$194 0084 GR + 7 A$_uchar2fs$195 0086 GR + 7 A$_uchar2fs$197 0089 GR + 7 A$_uchar2fs$198 008C GR + 7 A$_uchar2fs$199 008D GR + 7 A$_uchar2fs$200 008E GR + 7 A$_uchar2fs$201 008F GR + 7 A$_uchar2fs$202 0090 GR + 7 A$_uchar2fs$203 0091 GR + 7 A$_uchar2fs$204 0092 GR + 7 A$_uchar2fs$205 0093 GR + 7 A$_uchar2fs$206 0094 GR + 7 A$_uchar2fs$207 0095 GR + 7 A$_uchar2fs$208 0096 GR + 7 A$_uchar2fs$209 0097 GR + 7 A$_uchar2fs$210 0098 GR + 7 A$_uchar2fs$211 0099 GR + 7 A$_uchar2fs$212 009B GR + 7 A$_uchar2fs$213 009C GR + 7 A$_uchar2fs$214 009E GR + 7 A$_uchar2fs$215 009F GR + 7 A$_uchar2fs$216 00A1 GR + 7 A$_uchar2fs$217 00A2 GR + 7 A$_uchar2fs$219 00A4 GR + 7 A$_uchar2fs$222 00A6 GR + 7 A$_uchar2fs$223 00A7 GR + 7 A$_uchar2fs$224 00A9 GR + 7 A$_uchar2fs$225 00AA GR + 7 A$_uchar2fs$226 00AB GR + 7 A$_uchar2fs$227 00AC GR + 7 A$_uchar2fs$228 00AD GR + 7 A$_uchar2fs$229 00AE GR + 7 A$_uchar2fs$230 00AF GR + 7 A$_uchar2fs$231 00B0 GR + 7 A$_uchar2fs$232 00B1 GR + 7 A$_uchar2fs$233 00B2 GR + 7 A$_uchar2fs$234 00B3 GR + 7 A$_uchar2fs$235 00B6 GR + 7 A$_uchar2fs$236 00B7 GR + 7 A$_uchar2fs$237 00B8 GR + 7 A$_uchar2fs$238 00B9 GR + 7 A$_uchar2fs$239 00BA GR + 7 A$_uchar2fs$240 00BB GR + 7 A$_uchar2fs$241 00BC GR + 7 A$_uchar2fs$242 00BD GR + 7 A$_uchar2fs$243 00BE GR + 7 A$_uchar2fs$244 00BF GR + 7 A$_uchar2fs$245 00C0 GR + 7 A$_uchar2fs$247 00C1 GR + 7 A$_uchar2fs$248 00C3 GR + 7 A$_uchar2fs$249 00C5 GR + 7 A$_uchar2fs$250 00C8 GR + 7 A$_uchar2fs$252 00CA GR + 7 A$_uchar2fs$255 00CD GR + 7 A$_uchar2fs$257 00D0 GR + 7 A$_uchar2fs$258 00D2 GR + 7 A$_uchar2fs$259 00D4 GR + 7 A$_uchar2fs$260 00D6 GR + 7 A$_uchar2fs$261 00D8 GR + 7 A$_uchar2fs$262 00DA GR + 7 A$_uchar2fs$263 00DB GR + 7 A$_uchar2fs$264 00DD GR + 7 A$_uchar2fs$265 00DF GR + 7 A$_uchar2fs$266 00E1 GR + 7 A$_uchar2fs$267 00E2 GR + 7 A$_uchar2fs$268 00E4 GR + 7 A$_uchar2fs$269 00E5 GR + 7 A$_uchar2fs$270 00E7 GR + 7 A$_uchar2fs$271 00E9 GR + 7 A$_uchar2fs$272 00EC GR + 7 A$_uchar2fs$273 00EF GR + 7 A$_uchar2fs$274 00F2 GR + 7 A$_uchar2fs$275 00F3 GR + 7 A$_uchar2fs$276 00F4 GR + 7 A$_uchar2fs$277 00F5 GR + 7 A$_uchar2fs$278 00F6 GR + 7 A$_uchar2fs$279 00F7 GR + 7 A$_uchar2fs$280 00F8 GR + 7 A$_uchar2fs$281 00F9 GR + 7 A$_uchar2fs$282 00FA GR + 7 A$_uchar2fs$283 00FB GR + 7 A$_uchar2fs$284 00FC GR + 7 A$_uchar2fs$285 00FD GR + 7 A$_uchar2fs$286 00FF GR + 7 A$_uchar2fs$287 0101 GR + 7 A$_uchar2fs$288 0103 GR + 7 A$_uchar2fs$289 0105 GR + 7 A$_uchar2fs$290 0107 GR + 7 A$_uchar2fs$291 0109 GR + 7 A$_uchar2fs$292 010B GR + 7 A$_uchar2fs$293 010D GR + 7 A$_uchar2fs$294 010E GR + 7 A$_uchar2fs$295 0110 GR + 7 A$_uchar2fs$296 0111 GR + 7 A$_uchar2fs$297 0113 GR + 7 A$_uchar2fs$298 0114 GR + 7 A$_uchar2fs$299 0116 GR + 7 A$_uchar2fs$300 0117 GR + 7 A$_uchar2fs$301 0119 GR + 7 A$_uchar2fs$302 011C GR + 7 A$_uchar2fs$303 011D GR + 7 A$_uchar2fs$304 011E GR + 7 A$_uchar2fs$305 011F GR + 7 A$_uchar2fs$306 0120 GR + 7 A$_uchar2fs$307 0121 GR + 7 A$_uchar2fs$308 0122 GR + 7 A$_uchar2fs$309 0123 GR + 7 A$_uchar2fs$310 0124 GR + 7 A$_uchar2fs$311 0125 GR + 7 A$_uchar2fs$312 0126 GR + 7 A$_uchar2fs$314 0127 GR + 7 A$_uchar2fs$315 012A GR + 7 A$_uchar2fs$316 012B GR + 7 A$_uchar2fs$317 012C GR + 7 A$_uchar2fs$318 012D GR + 7 A$_uchar2fs$319 012E GR + 7 A$_uchar2fs$320 012F GR + 7 A$_uchar2fs$321 0130 GR + 7 A$_uchar2fs$322 0131 GR + 7 A$_uchar2fs$323 0132 GR + 7 A$_uchar2fs$324 0133 GR + 7 A$_uchar2fs$326 0134 GR + 7 A$_uchar2fs$327 0135 GR + 7 A$_uchar2fs$328 0137 GR + 7 A$_uchar2fs$329 0139 GR + 7 A$_uchar2fs$333 013B GR + 7 A$_uchar2fs$72 0000 GR + 7 A$_uchar2fs$73 0002 GR + 7 A$_uchar2fs$74 0005 GR + 7 A$_uchar2fs$75 0007 GR + 7 A$_uchar2fs$77 0008 GR + 7 A$_uchar2fs$78 000B GR + 7 A$_uchar2fs$79 000C GR + 7 A$_uchar2fs$80 000D GR + 7 A$_uchar2fs$81 000E GR + 7 A$_uchar2fs$82 000F GR + 7 A$_uchar2fs$83 0010 GR + 7 A$_uchar2fs$84 0013 GR + 7 A$_uchar2fs$85 0014 GR + 7 A$_uchar2fs$86 0017 GR + 7 A$_uchar2fs$87 0018 GR + 7 A$_uchar2fs$88 001B GR + 7 A$_uchar2fs$90 001C GR + 7 A$_uchar2fs$91 001F GR + 7 A$_uchar2fs$93 0020 GR + 7 A$_uchar2fs$94 0021 GR + 7 A$_uchar2fs$95 0022 GR + 7 A$_uchar2fs$96 0024 GR + 7 A$_uchar2fs$97 0025 GR + 7 A$_uchar2fs$98 0026 GR + 7 A$_uchar2fs$99 0027 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_uchar2fs.c$110$1$1 = 013B GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__uchar2fs$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__uchar2fs$0$0 = 013B GR + 7 ___uchar2fs 0000 GR + 5 ___uchar2fs_a1_1_1 0009 R + 5 ___uchar2fs_a_1_1 0000 R + 5 ___uchar2fs_fl_1_1 0005 R + 5 ___uchar2fs_sign_1_1 0001 R + 1 ___uchar2fs_sloc0_1_0 0000 R + 1 ___uchar2fs_sloc1_1_0 0002 R + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size D flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 13C flags 20 diff --git a/device/lib/_uint2fs.c b/device/lib/_uint2fs.c new file mode 100644 index 00000000..03d13408 --- /dev/null +++ b/device/lib/_uint2fs.c @@ -0,0 +1,110 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23) & (unsigned int)0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +float +__uint2fs (unsigned int a ) +{ + long sign = 0; + int exp = 24 + EXCESS; + volatile union float_long fl; + long a1 = a; + + if (!a1) + { + fl.l = 0; + return (fl.f); + } + + if (a1 < 0) + { + sign = SIGNBIT; + a1 = -a1; + } + + while (a1 < HIDDEN) + { + a1 <<= 1; + exp--; + } + + a1 &= ~HIDDEN ; + /* pack up and go home */ + fl.l = PACK(sign,(unsigned long)exp, a1); + + return (fl.f); +} diff --git a/device/lib/_uint2fs.lst b/device/lib/_uint2fs.lst new file mode 100644 index 00000000..fa2360f8 --- /dev/null +++ b/device/lib/_uint2fs.lst @@ -0,0 +1,340 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _uint2fs + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___uint2fs + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___uint2fs_sloc0_1_0: + 0000 22 .ds 0x0002 + 0002 23 ___uint2fs_sloc1_1_0: + 0002 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___uint2fs_a_1_1: + 0000 42 .ds 0x0002 + 0002 43 ___uint2fs_sign_1_1: + 0002 44 .ds 0x0004 + 0006 45 ___uint2fs_fl_1_1: + 0006 46 .ds 0x0004 + 000A 47 ___uint2fs_a1_1_1: + 000A 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__uint2fs$0$0 ==. + 58 ; _uint2fs.c 80 + 59 ; ----------------------------------------- + 60 ; function __uint2fs + 61 ; ----------------------------------------- + 0000 62 ___uint2fs: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _uint2fs.c 109 + 0000 C0 83 72 push dph + 0002 C0 82 73 push dpl + 0004 90s00r00 74 mov dptr,#___uint2fs_a_1_1 + 0007 D0 E0 75 pop acc + 0009 F0 76 movx @dptr,a + 000A D0 E0 77 pop acc + 000C A3 78 inc dptr + 000D F0 79 movx @dptr,a + 80 ; _uint2fs.c 82 + 000E 90s00r02 81 mov dptr,#___uint2fs_sign_1_1 + 0011 E4 82 clr a + 0012 A3 83 inc dptr + 0013 A3 84 inc dptr + 0014 A3 85 inc dptr + 0015 F0 86 movx @dptr,a + 0016 12s00r00 87 lcall __decdptr + 0019 F0 88 movx @dptr,a + 001A 12s00r00 89 lcall __decdptr + 001D F0 90 movx @dptr,a + 001E 12s00r00 91 lcall __decdptr + 0021 F0 92 movx @dptr,a + 93 ; _uint2fs.c 85 + 0022 90s00r00 94 mov dptr,#___uint2fs_a_1_1 + 0025 E0 95 movx a,@dptr + 0026 FA 96 mov r2,a + 0027 A3 97 inc dptr + 0028 E0 98 movx a,@dptr + 99 ; Peephole 105 removed redundant mov + 0029 FB 100 mov r3,a + 002A 33 101 rlc a + 002B 95 E0 102 subb a,acc + 002D FC 103 mov r4,a + 002E FD 104 mov r5,a + 002F 90s00r0A 105 mov dptr,#___uint2fs_a1_1_1 + 0032 EA 106 mov a,r2 + 0033 F0 107 movx @dptr,a + 0034 A3 108 inc dptr + 0035 EB 109 mov a,r3 + 0036 F0 110 movx @dptr,a + 0037 A3 111 inc dptr + 0038 EC 112 mov a,r4 + 0039 F0 113 movx @dptr,a + 003A A3 114 inc dptr + 003B ED 115 mov a,r5 + 003C F0 116 movx @dptr,a + 117 ; _uint2fs.c 87 + 003D EA 118 mov a,r2 + 003E 4B 119 orl a,r3 + 003F 4C 120 orl a,r4 + 0040 4D 121 orl a,r5 + 122 ; Peephole 109 removed ljmp by inverse jump logic + 0041 70 23 123 jnz 00102$ + 0043 124 00114$: + 125 ; _uint2fs.c 89 + 0043 90s00r06 126 mov dptr,#(___uint2fs_fl_1_1) + 127 ; Peephole 101 removed redundant mov + 128 ; Peephole 180 changed mov to clr + 0046 E4 129 clr a + 0047 F0 130 movx @dptr,a + 0048 A3 131 inc dptr + 0049 F0 132 movx @dptr,a + 004A A3 133 inc dptr + 134 ; Peephole 101 removed redundant mov + 135 ; Peephole 180 changed mov to clr + 004B E4 136 clr a + 004C F0 137 movx @dptr,a + 004D A3 138 inc dptr + 004E F0 139 movx @dptr,a + 140 ; _uint2fs.c 90 + 004F 90s00r06 141 mov dptr,#(___uint2fs_fl_1_1) + 0052 E0 142 movx a,@dptr + 0053 FE 143 mov r6,a + 0054 A3 144 inc dptr + 0055 E0 145 movx a,@dptr + 0056 FF 146 mov r7,a + 0057 A3 147 inc dptr + 0058 E0 148 movx a,@dptr + 0059 F8 149 mov r0,a + 005A A3 150 inc dptr + 005B E0 151 movx a,@dptr + 152 ; Peephole 191 removed redundant mov + 005C F9 153 mov r1,a + 005D 8E 82 154 mov dpl,r6 + 005F 8F 83 155 mov dph,r7 + 0061 88 F0 156 mov b,r0 + 0063 02s01r43 157 ljmp 00108$ + 0066 158 00102$: + 159 ; _uint2fs.c 93 + 0066 ED 160 mov a,r5 + 161 ; Peephole 111 removed ljmp by inverse jump logic + 0067 30 E7 21 162 jnb acc.7,00113$ + 006A 163 00115$: + 164 ; _uint2fs.c 95 + 006A 90s00r02 165 mov dptr,#___uint2fs_sign_1_1 + 166 ; Peephole 101 removed redundant mov + 167 ; Peephole 180 changed mov to clr + 006D E4 168 clr a + 006E F0 169 movx @dptr,a + 006F A3 170 inc dptr + 0070 F0 171 movx @dptr,a + 0071 A3 172 inc dptr + 173 ; Peephole 180 changed mov to clr + 0072 E4 174 clr a + 0073 F0 175 movx @dptr,a + 0074 A3 176 inc dptr + 0075 74 80 177 mov a,#0x80 + 0077 F0 178 movx @dptr,a + 179 ; _uint2fs.c 96 + 0078 90s00r0A 180 mov dptr,#___uint2fs_a1_1_1 + 007B C3 181 clr c + 007C E4 182 clr a + 007D 9A 183 subb a,r2 + 007E F0 184 movx @dptr,a + 007F E4 185 clr a + 0080 9B 186 subb a,r3 + 0081 A3 187 inc dptr + 0082 F0 188 movx @dptr,a + 0083 E4 189 clr a + 0084 9C 190 subb a,r4 + 0085 A3 191 inc dptr + 0086 F0 192 movx @dptr,a + 0087 E4 193 clr a + 0088 9D 194 subb a,r5 + 0089 A3 195 inc dptr + 008A F0 196 movx @dptr,a + 197 ; _uint2fs.c 99 + 008B 198 00113$: + 008B E4 199 clr a + 008C F5*01 200 mov (___uint2fs_sloc0_1_0 + 1),a + 008E 75*00 96 201 mov ___uint2fs_sloc0_1_0,#0x96 + 0091 202 00105$: + 0091 90s00r0A 203 mov dptr,#___uint2fs_a1_1_1 + 0094 E0 204 movx a,@dptr + 0095 FC 205 mov r4,a + 0096 A3 206 inc dptr + 0097 E0 207 movx a,@dptr + 0098 FD 208 mov r5,a + 0099 A3 209 inc dptr + 009A E0 210 movx a,@dptr + 009B FE 211 mov r6,a + 009C A3 212 inc dptr + 009D E0 213 movx a,@dptr + 009E FF 214 mov r7,a + 009F C3 215 clr c + 00A0 EC 216 mov a,r4 + 00A1 94 00 217 subb a,#0x00 + 00A3 ED 218 mov a,r5 + 00A4 94 00 219 subb a,#0x00 + 00A6 EE 220 mov a,r6 + 00A7 94 80 221 subb a,#0x80 + 00A9 EF 222 mov a,r7 + 00AA 94 00 223 subb a,#0x00 + 224 ; Peephole 108 removed ljmp by inverse jump logic + 00AC 50 27 225 jnc 00107$ + 00AE 226 00116$: + 227 ; _uint2fs.c 101 + 00AE EC 228 mov a,r4 + 00AF 25 E0 229 add a,acc + 00B1 F8 230 mov r0,a + 00B2 ED 231 mov a,r5 + 00B3 33 232 rlc a + 00B4 F9 233 mov r1,a + 00B5 EE 234 mov a,r6 + 00B6 33 235 rlc a + 00B7 FA 236 mov r2,a + 00B8 EF 237 mov a,r7 + 00B9 33 238 rlc a + 00BA FB 239 mov r3,a + 00BB 90s00r0A 240 mov dptr,#___uint2fs_a1_1_1 + 00BE E8 241 mov a,r0 + 00BF F0 242 movx @dptr,a + 00C0 A3 243 inc dptr + 00C1 E9 244 mov a,r1 + 00C2 F0 245 movx @dptr,a + 00C3 A3 246 inc dptr + 00C4 EA 247 mov a,r2 + 00C5 F0 248 movx @dptr,a + 00C6 A3 249 inc dptr + 00C7 EB 250 mov a,r3 + 00C8 F0 251 movx @dptr,a + 252 ; _uint2fs.c 102 + 00C9 15*00 253 dec ___uint2fs_sloc0_1_0 + 00CB 74 FF 254 mov a,#0xff + 00CD B5*00 02 255 cjne a,___uint2fs_sloc0_1_0,00117$ + 00D0 15*01 256 dec (___uint2fs_sloc0_1_0 + 1) + 00D2 257 00117$: + 00D2 02s00r91 258 ljmp 00105$ + 00D5 259 00107$: + 260 ; _uint2fs.c 105 + 00D5 53 06 7F 261 anl ar6,#0x7f + 262 ; _uint2fs.c 107 + 00D8 AA*00 263 mov r2,___uint2fs_sloc0_1_0 + 00DA AB*01 264 mov r3,(___uint2fs_sloc0_1_0 + 1) + 00DC 78 00 265 mov r0,#0x00 + 00DE 79 00 266 mov r1,#0x00 + 00E0 8A*04 267 mov (___uint2fs_sloc1_1_0 + 2),r2 + 00E2 EB 268 mov a,r3 + 00E3 54 01 269 anl a,#0x01 + 00E5 A2 E0 270 mov c,acc.0 + 00E7 C5*04 271 xch a,(___uint2fs_sloc1_1_0 + 2) + 00E9 13 272 rrc a + 00EA C5*04 273 xch a,(___uint2fs_sloc1_1_0 + 2) + 00EC 13 274 rrc a + 00ED C5*04 275 xch a,(___uint2fs_sloc1_1_0 + 2) + 00EF F5*05 276 mov (___uint2fs_sloc1_1_0 + 3),a + 00F1 75*03 00 277 mov (___uint2fs_sloc1_1_0 + 1),#0x00 + 00F4 75*02 00 278 mov ___uint2fs_sloc1_1_0,#0x00 + 00F7 90s00r02 279 mov dptr,#___uint2fs_sign_1_1 + 00FA E0 280 movx a,@dptr + 00FB FA 281 mov r2,a + 00FC A3 282 inc dptr + 00FD E0 283 movx a,@dptr + 00FE FB 284 mov r3,a + 00FF A3 285 inc dptr + 0100 E0 286 movx a,@dptr + 0101 F8 287 mov r0,a + 0102 A3 288 inc dptr + 0103 E0 289 movx a,@dptr + 0104 F9 290 mov r1,a + 0105 E5*02 291 mov a,___uint2fs_sloc1_1_0 + 0107 42 02 292 orl ar2,a + 0109 E5*03 293 mov a,(___uint2fs_sloc1_1_0 + 1) + 010B 42 03 294 orl ar3,a + 010D E5*04 295 mov a,(___uint2fs_sloc1_1_0 + 2) + 010F 42 00 296 orl ar0,a + 0111 E5*05 297 mov a,(___uint2fs_sloc1_1_0 + 3) + 0113 42 01 298 orl ar1,a + 0115 EA 299 mov a,r2 + 0116 42 04 300 orl ar4,a + 0118 EB 301 mov a,r3 + 0119 42 05 302 orl ar5,a + 011B E8 303 mov a,r0 + 011C 42 06 304 orl ar6,a + 011E E9 305 mov a,r1 + 011F 42 07 306 orl ar7,a + 0121 90s00r06 307 mov dptr,#(___uint2fs_fl_1_1) + 0124 EC 308 mov a,r4 + 0125 F0 309 movx @dptr,a + 0126 A3 310 inc dptr + 0127 ED 311 mov a,r5 + 0128 F0 312 movx @dptr,a + 0129 A3 313 inc dptr + 012A EE 314 mov a,r6 + 012B F0 315 movx @dptr,a + 012C A3 316 inc dptr + 012D EF 317 mov a,r7 + 012E F0 318 movx @dptr,a + 319 ; _uint2fs.c 109 + 012F 90s00r06 320 mov dptr,#(___uint2fs_fl_1_1) + 0132 E0 321 movx a,@dptr + 0133 FA 322 mov r2,a + 0134 A3 323 inc dptr + 0135 E0 324 movx a,@dptr + 0136 FB 325 mov r3,a + 0137 A3 326 inc dptr + 0138 E0 327 movx a,@dptr + 0139 FC 328 mov r4,a + 013A A3 329 inc dptr + 013B E0 330 movx a,@dptr + 331 ; Peephole 191 removed redundant mov + 013C FD 332 mov r5,a + 013D 8A 82 333 mov dpl,r2 + 013F 8B 83 334 mov dph,r3 + 0141 8C F0 335 mov b,r4 + 0143 336 00108$: + 0143 337 C$_uint2fs.c$110$1$1 ==. + 0143 338 XG$__uint2fs$0$0 ==. + 0143 22 339 ret + 340 .area CSEG (CODE) diff --git a/device/lib/_uint2fs.sym b/device/lib/_uint2fs.sym new file mode 100644 index 00000000..061ba585 --- /dev/null +++ b/device/lib/_uint2fs.sym @@ -0,0 +1,602 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_uint2fs$100 0029 GR + 7 A$_uint2fs$101 002A GR + 7 A$_uint2fs$102 002B GR + 7 A$_uint2fs$103 002D GR + 7 A$_uint2fs$104 002E GR + 7 A$_uint2fs$105 002F GR + 7 A$_uint2fs$106 0032 GR + 7 A$_uint2fs$107 0033 GR + 7 A$_uint2fs$108 0034 GR + 7 A$_uint2fs$109 0035 GR + 7 A$_uint2fs$110 0036 GR + 7 A$_uint2fs$111 0037 GR + 7 A$_uint2fs$112 0038 GR + 7 A$_uint2fs$113 0039 GR + 7 A$_uint2fs$114 003A GR + 7 A$_uint2fs$115 003B GR + 7 A$_uint2fs$116 003C GR + 7 A$_uint2fs$118 003D GR + 7 A$_uint2fs$119 003E GR + 7 A$_uint2fs$120 003F GR + 7 A$_uint2fs$121 0040 GR + 7 A$_uint2fs$123 0041 GR + 7 A$_uint2fs$126 0043 GR + 7 A$_uint2fs$129 0046 GR + 7 A$_uint2fs$130 0047 GR + 7 A$_uint2fs$131 0048 GR + 7 A$_uint2fs$132 0049 GR + 7 A$_uint2fs$133 004A GR + 7 A$_uint2fs$136 004B GR + 7 A$_uint2fs$137 004C GR + 7 A$_uint2fs$138 004D GR + 7 A$_uint2fs$139 004E GR + 7 A$_uint2fs$141 004F GR + 7 A$_uint2fs$142 0052 GR + 7 A$_uint2fs$143 0053 GR + 7 A$_uint2fs$144 0054 GR + 7 A$_uint2fs$145 0055 GR + 7 A$_uint2fs$146 0056 GR + 7 A$_uint2fs$147 0057 GR + 7 A$_uint2fs$148 0058 GR + 7 A$_uint2fs$149 0059 GR + 7 A$_uint2fs$150 005A GR + 7 A$_uint2fs$151 005B GR + 7 A$_uint2fs$153 005C GR + 7 A$_uint2fs$154 005D GR + 7 A$_uint2fs$155 005F GR + 7 A$_uint2fs$156 0061 GR + 7 A$_uint2fs$157 0063 GR + 7 A$_uint2fs$160 0066 GR + 7 A$_uint2fs$162 0067 GR + 7 A$_uint2fs$165 006A GR + 7 A$_uint2fs$168 006D GR + 7 A$_uint2fs$169 006E GR + 7 A$_uint2fs$170 006F GR + 7 A$_uint2fs$171 0070 GR + 7 A$_uint2fs$172 0071 GR + 7 A$_uint2fs$174 0072 GR + 7 A$_uint2fs$175 0073 GR + 7 A$_uint2fs$176 0074 GR + 7 A$_uint2fs$177 0075 GR + 7 A$_uint2fs$178 0077 GR + 7 A$_uint2fs$180 0078 GR + 7 A$_uint2fs$181 007B GR + 7 A$_uint2fs$182 007C GR + 7 A$_uint2fs$183 007D GR + 7 A$_uint2fs$184 007E GR + 7 A$_uint2fs$185 007F GR + 7 A$_uint2fs$186 0080 GR + 7 A$_uint2fs$187 0081 GR + 7 A$_uint2fs$188 0082 GR + 7 A$_uint2fs$189 0083 GR + 7 A$_uint2fs$190 0084 GR + 7 A$_uint2fs$191 0085 GR + 7 A$_uint2fs$192 0086 GR + 7 A$_uint2fs$193 0087 GR + 7 A$_uint2fs$194 0088 GR + 7 A$_uint2fs$195 0089 GR + 7 A$_uint2fs$196 008A GR + 7 A$_uint2fs$199 008B GR + 7 A$_uint2fs$200 008C GR + 7 A$_uint2fs$201 008E GR + 7 A$_uint2fs$203 0091 GR + 7 A$_uint2fs$204 0094 GR + 7 A$_uint2fs$205 0095 GR + 7 A$_uint2fs$206 0096 GR + 7 A$_uint2fs$207 0097 GR + 7 A$_uint2fs$208 0098 GR + 7 A$_uint2fs$209 0099 GR + 7 A$_uint2fs$210 009A GR + 7 A$_uint2fs$211 009B GR + 7 A$_uint2fs$212 009C GR + 7 A$_uint2fs$213 009D GR + 7 A$_uint2fs$214 009E GR + 7 A$_uint2fs$215 009F GR + 7 A$_uint2fs$216 00A0 GR + 7 A$_uint2fs$217 00A1 GR + 7 A$_uint2fs$218 00A3 GR + 7 A$_uint2fs$219 00A4 GR + 7 A$_uint2fs$220 00A6 GR + 7 A$_uint2fs$221 00A7 GR + 7 A$_uint2fs$222 00A9 GR + 7 A$_uint2fs$223 00AA GR + 7 A$_uint2fs$225 00AC GR + 7 A$_uint2fs$228 00AE GR + 7 A$_uint2fs$229 00AF GR + 7 A$_uint2fs$230 00B1 GR + 7 A$_uint2fs$231 00B2 GR + 7 A$_uint2fs$232 00B3 GR + 7 A$_uint2fs$233 00B4 GR + 7 A$_uint2fs$234 00B5 GR + 7 A$_uint2fs$235 00B6 GR + 7 A$_uint2fs$236 00B7 GR + 7 A$_uint2fs$237 00B8 GR + 7 A$_uint2fs$238 00B9 GR + 7 A$_uint2fs$239 00BA GR + 7 A$_uint2fs$240 00BB GR + 7 A$_uint2fs$241 00BE GR + 7 A$_uint2fs$242 00BF GR + 7 A$_uint2fs$243 00C0 GR + 7 A$_uint2fs$244 00C1 GR + 7 A$_uint2fs$245 00C2 GR + 7 A$_uint2fs$246 00C3 GR + 7 A$_uint2fs$247 00C4 GR + 7 A$_uint2fs$248 00C5 GR + 7 A$_uint2fs$249 00C6 GR + 7 A$_uint2fs$250 00C7 GR + 7 A$_uint2fs$251 00C8 GR + 7 A$_uint2fs$253 00C9 GR + 7 A$_uint2fs$254 00CB GR + 7 A$_uint2fs$255 00CD GR + 7 A$_uint2fs$256 00D0 GR + 7 A$_uint2fs$258 00D2 GR + 7 A$_uint2fs$261 00D5 GR + 7 A$_uint2fs$263 00D8 GR + 7 A$_uint2fs$264 00DA GR + 7 A$_uint2fs$265 00DC GR + 7 A$_uint2fs$266 00DE GR + 7 A$_uint2fs$267 00E0 GR + 7 A$_uint2fs$268 00E2 GR + 7 A$_uint2fs$269 00E3 GR + 7 A$_uint2fs$270 00E5 GR + 7 A$_uint2fs$271 00E7 GR + 7 A$_uint2fs$272 00E9 GR + 7 A$_uint2fs$273 00EA GR + 7 A$_uint2fs$274 00EC GR + 7 A$_uint2fs$275 00ED GR + 7 A$_uint2fs$276 00EF GR + 7 A$_uint2fs$277 00F1 GR + 7 A$_uint2fs$278 00F4 GR + 7 A$_uint2fs$279 00F7 GR + 7 A$_uint2fs$280 00FA GR + 7 A$_uint2fs$281 00FB GR + 7 A$_uint2fs$282 00FC GR + 7 A$_uint2fs$283 00FD GR + 7 A$_uint2fs$284 00FE GR + 7 A$_uint2fs$285 00FF GR + 7 A$_uint2fs$286 0100 GR + 7 A$_uint2fs$287 0101 GR + 7 A$_uint2fs$288 0102 GR + 7 A$_uint2fs$289 0103 GR + 7 A$_uint2fs$290 0104 GR + 7 A$_uint2fs$291 0105 GR + 7 A$_uint2fs$292 0107 GR + 7 A$_uint2fs$293 0109 GR + 7 A$_uint2fs$294 010B GR + 7 A$_uint2fs$295 010D GR + 7 A$_uint2fs$296 010F GR + 7 A$_uint2fs$297 0111 GR + 7 A$_uint2fs$298 0113 GR + 7 A$_uint2fs$299 0115 GR + 7 A$_uint2fs$300 0116 GR + 7 A$_uint2fs$301 0118 GR + 7 A$_uint2fs$302 0119 GR + 7 A$_uint2fs$303 011B GR + 7 A$_uint2fs$304 011C GR + 7 A$_uint2fs$305 011E GR + 7 A$_uint2fs$306 011F GR + 7 A$_uint2fs$307 0121 GR + 7 A$_uint2fs$308 0124 GR + 7 A$_uint2fs$309 0125 GR + 7 A$_uint2fs$310 0126 GR + 7 A$_uint2fs$311 0127 GR + 7 A$_uint2fs$312 0128 GR + 7 A$_uint2fs$313 0129 GR + 7 A$_uint2fs$314 012A GR + 7 A$_uint2fs$315 012B GR + 7 A$_uint2fs$316 012C GR + 7 A$_uint2fs$317 012D GR + 7 A$_uint2fs$318 012E GR + 7 A$_uint2fs$320 012F GR + 7 A$_uint2fs$321 0132 GR + 7 A$_uint2fs$322 0133 GR + 7 A$_uint2fs$323 0134 GR + 7 A$_uint2fs$324 0135 GR + 7 A$_uint2fs$325 0136 GR + 7 A$_uint2fs$326 0137 GR + 7 A$_uint2fs$327 0138 GR + 7 A$_uint2fs$328 0139 GR + 7 A$_uint2fs$329 013A GR + 7 A$_uint2fs$330 013B GR + 7 A$_uint2fs$332 013C GR + 7 A$_uint2fs$333 013D GR + 7 A$_uint2fs$334 013F GR + 7 A$_uint2fs$335 0141 GR + 7 A$_uint2fs$339 0143 GR + 7 A$_uint2fs$72 0000 GR + 7 A$_uint2fs$73 0002 GR + 7 A$_uint2fs$74 0004 GR + 7 A$_uint2fs$75 0007 GR + 7 A$_uint2fs$76 0009 GR + 7 A$_uint2fs$77 000A GR + 7 A$_uint2fs$78 000C GR + 7 A$_uint2fs$79 000D GR + 7 A$_uint2fs$81 000E GR + 7 A$_uint2fs$82 0011 GR + 7 A$_uint2fs$83 0012 GR + 7 A$_uint2fs$84 0013 GR + 7 A$_uint2fs$85 0014 GR + 7 A$_uint2fs$86 0015 GR + 7 A$_uint2fs$87 0016 GR + 7 A$_uint2fs$88 0019 GR + 7 A$_uint2fs$89 001A GR + 7 A$_uint2fs$90 001D GR + 7 A$_uint2fs$91 001E GR + 7 A$_uint2fs$92 0021 GR + 7 A$_uint2fs$94 0022 GR + 7 A$_uint2fs$95 0025 GR + 7 A$_uint2fs$96 0026 GR + 7 A$_uint2fs$97 0027 GR + 7 A$_uint2fs$98 0028 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_uint2fs.c$110$1$1 = 0143 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__uint2fs$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__uint2fs$0$0 = 0143 GR + 7 ___uint2fs 0000 GR + 5 ___uint2fs_a1_1_1 000A R + 5 ___uint2fs_a_1_1 0000 R + 5 ___uint2fs_fl_1_1 0006 R + 5 ___uint2fs_sign_1_1 0002 R + 1 ___uint2fs_sloc0_1_0 0000 R + 1 ___uint2fs_sloc1_1_0 0002 R + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size E flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 144 flags 20 diff --git a/device/lib/_ulong2fs.c b/device/lib/_ulong2fs.c new file mode 100644 index 00000000..77869f6d --- /dev/null +++ b/device/lib/_ulong2fs.c @@ -0,0 +1,110 @@ +/* +** libgcc support for software floating point. +** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. +** Permission is granted to do *anything* you want with this file, +** commercial or otherwise, provided this message remains intact. So there! +** I would appreciate receiving any updates/patches/changes that anyone +** makes, and am willing to be the repository for said changes (am I +** making a big mistake?). + +Warning! Only single-precision is actually implemented. This file +won't really be much use until double-precision is supported. + +However, once that is done, this file might eventually become a +replacement for libgcc1.c. It might also make possible +cross-compilation for an IEEE target machine from a non-IEEE +host such as a VAX. + +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu. + + +** +** Pat Wood +** Pipeline Associates, Inc. +** pipeline!phw@motown.com or +** sun!pipeline!phw or +** uunet!motown!pipeline!phw +** +** 05/01/91 -- V1.0 -- first release to gcc mailing lists +** 05/04/91 -- V1.1 -- added float and double prototypes and return values +** -- fixed problems with adding and subtracting zero +** -- fixed rounding in truncdfsf2 +** -- fixed SWAP define and tested on 386 +*/ + +/* +** The following are routines that replace the libgcc soft floating point +** routines that are called automatically when -msoft-float is selected. +** The support single and double precision IEEE format, with provisions +** for byte-swapped machines (tested on 386). Some of the double-precision +** routines work at full precision, but most of the hard ones simply punt +** and call the single precision routines, producing a loss of accuracy. +** long long support is not assumed or included. +** Overall accuracy is close to IEEE (actually 68882) for single-precision +** arithmetic. I think there may still be a 1 in 1000 chance of a bit +** being rounded the wrong way during a multiply. I'm not fussy enough to +** bother with it, but if anyone is, knock yourself out. +** +** Efficiency has only been addressed where it was obvious that something +** would make a big difference. Anyone who wants to do this right for +** best speed should go in and rewrite in assembler. +** +** I have tested this only on a 68030 workstation and 386/ix integrated +** in with -msoft-float. +*/ + +/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126 +#define SIGNBIT ((unsigned long)0x80000000) +#define HIDDEN (unsigned long)(1 << 23) +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) +#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) + +/* the following deal with IEEE double-precision numbers */ +#define EXCESSD 1022 +#define HIDDEND (1 << 20) +#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) +#define SIGND(fp) ((fp.l.upper) & SIGNBIT) +#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \ + (fp.l.lower >> 22)) + +union float_long + { + float f; + long l; + }; + +float +__ulong2fs (unsigned long a ) +{ + long sign = 0; + int exp = 24 + EXCESS; + volatile union float_long fl; + long a1 = a; + + if (!a1) + { + fl.l = 0; + return (fl.f); + } + + if (a1 < 0) + { + sign = SIGNBIT; + a1 = -a1; + } + + while (a1 < HIDDEN) + { + a1 <<= 1; + exp--; + } + + a1 &= ~HIDDEN ; + /* pack up and go home */ + fl.l = PACK(sign,(unsigned long)exp, a1); + + return (fl.f); +} diff --git a/device/lib/_ulong2fs.lst b/device/lib/_ulong2fs.lst new file mode 100644 index 00000000..c7cbd683 --- /dev/null +++ b/device/lib/_ulong2fs.lst @@ -0,0 +1,349 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module _ulong2fs + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl ___ulong2fs + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 0000 21 ___ulong2fs_sloc0_1_0: + 0000 22 .ds 0x0002 + 0002 23 ___ulong2fs_sloc1_1_0: + 0002 24 .ds 0x0004 + 25 ;-------------------------------------------------------- + 26 ; overlayable items in internal ram + 27 ;-------------------------------------------------------- + 28 .area OSEG (OVR,DATA) + 29 ;-------------------------------------------------------- + 30 ; indirectly addressable internal ram data + 31 ;-------------------------------------------------------- + 32 .area ISEG (DATA) + 33 ;-------------------------------------------------------- + 34 ; bit data + 35 ;-------------------------------------------------------- + 36 .area BSEG (BIT) + 37 ;-------------------------------------------------------- + 38 ; external ram data + 39 ;-------------------------------------------------------- + 40 .area XSEG (XDATA) + 0000 41 ___ulong2fs_a_1_1: + 0000 42 .ds 0x0004 + 0004 43 ___ulong2fs_sign_1_1: + 0004 44 .ds 0x0004 + 0008 45 ___ulong2fs_fl_1_1: + 0008 46 .ds 0x0004 + 000C 47 ___ulong2fs_a1_1_1: + 000C 48 .ds 0x0004 + 49 ;-------------------------------------------------------- + 50 ; global & static initialisations + 51 ;-------------------------------------------------------- + 52 .area GSINIT (CODE) + 53 ;-------------------------------------------------------- + 54 ; code + 55 ;-------------------------------------------------------- + 56 .area CSEG (CODE) + 0000 57 G$__ulong2fs$0$0 ==. + 58 ; _ulong2fs.c 80 + 59 ; ----------------------------------------- + 60 ; function __ulong2fs + 61 ; ----------------------------------------- + 0000 62 ___ulong2fs: + 0002 63 ar2 = 0x02 + 0003 64 ar3 = 0x03 + 0004 65 ar4 = 0x04 + 0005 66 ar5 = 0x05 + 0006 67 ar6 = 0x06 + 0007 68 ar7 = 0x07 + 0000 69 ar0 = 0x00 + 0001 70 ar1 = 0x01 + 71 ; _ulong2fs.c 109 + 0000 C0 E0 72 push acc + 0002 C0 F0 73 push b + 0004 C0 83 74 push dph + 0006 C0 82 75 push dpl + 0008 90s00r00 76 mov dptr,#___ulong2fs_a_1_1 + 000B D0 E0 77 pop acc + 000D F0 78 movx @dptr,a + 000E D0 E0 79 pop acc + 0010 A3 80 inc dptr + 0011 F0 81 movx @dptr,a + 0012 D0 E0 82 pop acc + 0014 A3 83 inc dptr + 0015 F0 84 movx @dptr,a + 0016 D0 E0 85 pop acc + 0018 A3 86 inc dptr + 0019 F0 87 movx @dptr,a + 88 ; _ulong2fs.c 82 + 001A 90s00r04 89 mov dptr,#___ulong2fs_sign_1_1 + 001D E4 90 clr a + 001E A3 91 inc dptr + 001F A3 92 inc dptr + 0020 A3 93 inc dptr + 0021 F0 94 movx @dptr,a + 0022 12s00r00 95 lcall __decdptr + 0025 F0 96 movx @dptr,a + 0026 12s00r00 97 lcall __decdptr + 0029 F0 98 movx @dptr,a + 002A 12s00r00 99 lcall __decdptr + 002D F0 100 movx @dptr,a + 101 ; _ulong2fs.c 85 + 002E 90s00r00 102 mov dptr,#___ulong2fs_a_1_1 + 0031 E0 103 movx a,@dptr + 0032 FA 104 mov r2,a + 0033 A3 105 inc dptr + 0034 E0 106 movx a,@dptr + 0035 FB 107 mov r3,a + 0036 A3 108 inc dptr + 0037 E0 109 movx a,@dptr + 0038 FC 110 mov r4,a + 0039 A3 111 inc dptr + 003A E0 112 movx a,@dptr + 003B FD 113 mov r5,a + 003C 90s00r0C 114 mov dptr,#___ulong2fs_a1_1_1 + 003F EA 115 mov a,r2 + 0040 F0 116 movx @dptr,a + 0041 A3 117 inc dptr + 0042 EB 118 mov a,r3 + 0043 F0 119 movx @dptr,a + 0044 A3 120 inc dptr + 0045 EC 121 mov a,r4 + 0046 F0 122 movx @dptr,a + 0047 A3 123 inc dptr + 0048 ED 124 mov a,r5 + 0049 F0 125 movx @dptr,a + 126 ; _ulong2fs.c 87 + 004A EA 127 mov a,r2 + 004B 4B 128 orl a,r3 + 004C 4C 129 orl a,r4 + 004D 4D 130 orl a,r5 + 131 ; Peephole 109 removed ljmp by inverse jump logic + 004E 70 23 132 jnz 00102$ + 0050 133 00114$: + 134 ; _ulong2fs.c 89 + 0050 90s00r08 135 mov dptr,#(___ulong2fs_fl_1_1) + 136 ; Peephole 101 removed redundant mov + 137 ; Peephole 180 changed mov to clr + 0053 E4 138 clr a + 0054 F0 139 movx @dptr,a + 0055 A3 140 inc dptr + 0056 F0 141 movx @dptr,a + 0057 A3 142 inc dptr + 143 ; Peephole 101 removed redundant mov + 144 ; Peephole 180 changed mov to clr + 0058 E4 145 clr a + 0059 F0 146 movx @dptr,a + 005A A3 147 inc dptr + 005B F0 148 movx @dptr,a + 149 ; _ulong2fs.c 90 + 005C 90s00r08 150 mov dptr,#(___ulong2fs_fl_1_1) + 005F E0 151 movx a,@dptr + 0060 FE 152 mov r6,a + 0061 A3 153 inc dptr + 0062 E0 154 movx a,@dptr + 0063 FF 155 mov r7,a + 0064 A3 156 inc dptr + 0065 E0 157 movx a,@dptr + 0066 F8 158 mov r0,a + 0067 A3 159 inc dptr + 0068 E0 160 movx a,@dptr + 161 ; Peephole 191 removed redundant mov + 0069 F9 162 mov r1,a + 006A 8E 82 163 mov dpl,r6 + 006C 8F 83 164 mov dph,r7 + 006E 88 F0 165 mov b,r0 + 0070 02s01r4F 166 ljmp 00108$ + 0073 167 00102$: + 168 ; _ulong2fs.c 93 + 0073 C3 169 clr c + 170 ; Peephole 108 removed ljmp by inverse jump logic + 0074 50 21 171 jnc 00113$ + 0076 172 00115$: + 173 ; _ulong2fs.c 95 + 0076 90s00r04 174 mov dptr,#___ulong2fs_sign_1_1 + 175 ; Peephole 101 removed redundant mov + 176 ; Peephole 180 changed mov to clr + 0079 E4 177 clr a + 007A F0 178 movx @dptr,a + 007B A3 179 inc dptr + 007C F0 180 movx @dptr,a + 007D A3 181 inc dptr + 182 ; Peephole 180 changed mov to clr + 007E E4 183 clr a + 007F F0 184 movx @dptr,a + 0080 A3 185 inc dptr + 0081 74 80 186 mov a,#0x80 + 0083 F0 187 movx @dptr,a + 188 ; _ulong2fs.c 96 + 0084 90s00r0C 189 mov dptr,#___ulong2fs_a1_1_1 + 0087 C3 190 clr c + 0088 E4 191 clr a + 0089 9A 192 subb a,r2 + 008A F0 193 movx @dptr,a + 008B E4 194 clr a + 008C 9B 195 subb a,r3 + 008D A3 196 inc dptr + 008E F0 197 movx @dptr,a + 008F E4 198 clr a + 0090 9C 199 subb a,r4 + 0091 A3 200 inc dptr + 0092 F0 201 movx @dptr,a + 0093 E4 202 clr a + 0094 9D 203 subb a,r5 + 0095 A3 204 inc dptr + 0096 F0 205 movx @dptr,a + 206 ; _ulong2fs.c 99 + 0097 207 00113$: + 0097 E4 208 clr a + 0098 F5*01 209 mov (___ulong2fs_sloc0_1_0 + 1),a + 009A 75*00 96 210 mov ___ulong2fs_sloc0_1_0,#0x96 + 009D 211 00105$: + 009D 90s00r0C 212 mov dptr,#___ulong2fs_a1_1_1 + 00A0 E0 213 movx a,@dptr + 00A1 FC 214 mov r4,a + 00A2 A3 215 inc dptr + 00A3 E0 216 movx a,@dptr + 00A4 FD 217 mov r5,a + 00A5 A3 218 inc dptr + 00A6 E0 219 movx a,@dptr + 00A7 FE 220 mov r6,a + 00A8 A3 221 inc dptr + 00A9 E0 222 movx a,@dptr + 00AA FF 223 mov r7,a + 00AB C3 224 clr c + 00AC EC 225 mov a,r4 + 00AD 94 00 226 subb a,#0x00 + 00AF ED 227 mov a,r5 + 00B0 94 00 228 subb a,#0x00 + 00B2 EE 229 mov a,r6 + 00B3 94 80 230 subb a,#0x80 + 00B5 EF 231 mov a,r7 + 00B6 94 00 232 subb a,#0x00 + 233 ; Peephole 108 removed ljmp by inverse jump logic + 00B8 50 27 234 jnc 00107$ + 00BA 235 00116$: + 236 ; _ulong2fs.c 101 + 00BA EC 237 mov a,r4 + 00BB 25 E0 238 add a,acc + 00BD F8 239 mov r0,a + 00BE ED 240 mov a,r5 + 00BF 33 241 rlc a + 00C0 F9 242 mov r1,a + 00C1 EE 243 mov a,r6 + 00C2 33 244 rlc a + 00C3 FA 245 mov r2,a + 00C4 EF 246 mov a,r7 + 00C5 33 247 rlc a + 00C6 FB 248 mov r3,a + 00C7 90s00r0C 249 mov dptr,#___ulong2fs_a1_1_1 + 00CA E8 250 mov a,r0 + 00CB F0 251 movx @dptr,a + 00CC A3 252 inc dptr + 00CD E9 253 mov a,r1 + 00CE F0 254 movx @dptr,a + 00CF A3 255 inc dptr + 00D0 EA 256 mov a,r2 + 00D1 F0 257 movx @dptr,a + 00D2 A3 258 inc dptr + 00D3 EB 259 mov a,r3 + 00D4 F0 260 movx @dptr,a + 261 ; _ulong2fs.c 102 + 00D5 15*00 262 dec ___ulong2fs_sloc0_1_0 + 00D7 74 FF 263 mov a,#0xff + 00D9 B5*00 02 264 cjne a,___ulong2fs_sloc0_1_0,00117$ + 00DC 15*01 265 dec (___ulong2fs_sloc0_1_0 + 1) + 00DE 266 00117$: + 00DE 02s00r9D 267 ljmp 00105$ + 00E1 268 00107$: + 269 ; _ulong2fs.c 105 + 00E1 53 06 7F 270 anl ar6,#0x7f + 271 ; _ulong2fs.c 107 + 00E4 AA*00 272 mov r2,___ulong2fs_sloc0_1_0 + 00E6 AB*01 273 mov r3,(___ulong2fs_sloc0_1_0 + 1) + 00E8 78 00 274 mov r0,#0x00 + 00EA 79 00 275 mov r1,#0x00 + 00EC 8A*04 276 mov (___ulong2fs_sloc1_1_0 + 2),r2 + 00EE EB 277 mov a,r3 + 00EF 54 01 278 anl a,#0x01 + 00F1 A2 E0 279 mov c,acc.0 + 00F3 C5*04 280 xch a,(___ulong2fs_sloc1_1_0 + 2) + 00F5 13 281 rrc a + 00F6 C5*04 282 xch a,(___ulong2fs_sloc1_1_0 + 2) + 00F8 13 283 rrc a + 00F9 C5*04 284 xch a,(___ulong2fs_sloc1_1_0 + 2) + 00FB F5*05 285 mov (___ulong2fs_sloc1_1_0 + 3),a + 00FD 75*03 00 286 mov (___ulong2fs_sloc1_1_0 + 1),#0x00 + 0100 75*02 00 287 mov ___ulong2fs_sloc1_1_0,#0x00 + 0103 90s00r04 288 mov dptr,#___ulong2fs_sign_1_1 + 0106 E0 289 movx a,@dptr + 0107 FA 290 mov r2,a + 0108 A3 291 inc dptr + 0109 E0 292 movx a,@dptr + 010A FB 293 mov r3,a + 010B A3 294 inc dptr + 010C E0 295 movx a,@dptr + 010D F8 296 mov r0,a + 010E A3 297 inc dptr + 010F E0 298 movx a,@dptr + 0110 F9 299 mov r1,a + 0111 E5*02 300 mov a,___ulong2fs_sloc1_1_0 + 0113 42 02 301 orl ar2,a + 0115 E5*03 302 mov a,(___ulong2fs_sloc1_1_0 + 1) + 0117 42 03 303 orl ar3,a + 0119 E5*04 304 mov a,(___ulong2fs_sloc1_1_0 + 2) + 011B 42 00 305 orl ar0,a + 011D E5*05 306 mov a,(___ulong2fs_sloc1_1_0 + 3) + 011F 42 01 307 orl ar1,a + 0121 EA 308 mov a,r2 + 0122 42 04 309 orl ar4,a + 0124 EB 310 mov a,r3 + 0125 42 05 311 orl ar5,a + 0127 E8 312 mov a,r0 + 0128 42 06 313 orl ar6,a + 012A E9 314 mov a,r1 + 012B 42 07 315 orl ar7,a + 012D 90s00r08 316 mov dptr,#(___ulong2fs_fl_1_1) + 0130 EC 317 mov a,r4 + 0131 F0 318 movx @dptr,a + 0132 A3 319 inc dptr + 0133 ED 320 mov a,r5 + 0134 F0 321 movx @dptr,a + 0135 A3 322 inc dptr + 0136 EE 323 mov a,r6 + 0137 F0 324 movx @dptr,a + 0138 A3 325 inc dptr + 0139 EF 326 mov a,r7 + 013A F0 327 movx @dptr,a + 328 ; _ulong2fs.c 109 + 013B 90s00r08 329 mov dptr,#(___ulong2fs_fl_1_1) + 013E E0 330 movx a,@dptr + 013F FA 331 mov r2,a + 0140 A3 332 inc dptr + 0141 E0 333 movx a,@dptr + 0142 FB 334 mov r3,a + 0143 A3 335 inc dptr + 0144 E0 336 movx a,@dptr + 0145 FC 337 mov r4,a + 0146 A3 338 inc dptr + 0147 E0 339 movx a,@dptr + 340 ; Peephole 191 removed redundant mov + 0148 FD 341 mov r5,a + 0149 8A 82 342 mov dpl,r2 + 014B 8B 83 343 mov dph,r3 + 014D 8C F0 344 mov b,r4 + 014F 345 00108$: + 014F 346 C$_ulong2fs.c$110$1$1 ==. + 014F 347 XG$__ulong2fs$0$0 ==. + 014F 22 348 ret + 349 .area CSEG (CODE) diff --git a/device/lib/_ulong2fs.sym b/device/lib/_ulong2fs.sym new file mode 100644 index 00000000..fdb1b8e2 --- /dev/null +++ b/device/lib/_ulong2fs.sym @@ -0,0 +1,612 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$_ulong2fs$100 002D GR + 7 A$_ulong2fs$102 002E GR + 7 A$_ulong2fs$103 0031 GR + 7 A$_ulong2fs$104 0032 GR + 7 A$_ulong2fs$105 0033 GR + 7 A$_ulong2fs$106 0034 GR + 7 A$_ulong2fs$107 0035 GR + 7 A$_ulong2fs$108 0036 GR + 7 A$_ulong2fs$109 0037 GR + 7 A$_ulong2fs$110 0038 GR + 7 A$_ulong2fs$111 0039 GR + 7 A$_ulong2fs$112 003A GR + 7 A$_ulong2fs$113 003B GR + 7 A$_ulong2fs$114 003C GR + 7 A$_ulong2fs$115 003F GR + 7 A$_ulong2fs$116 0040 GR + 7 A$_ulong2fs$117 0041 GR + 7 A$_ulong2fs$118 0042 GR + 7 A$_ulong2fs$119 0043 GR + 7 A$_ulong2fs$120 0044 GR + 7 A$_ulong2fs$121 0045 GR + 7 A$_ulong2fs$122 0046 GR + 7 A$_ulong2fs$123 0047 GR + 7 A$_ulong2fs$124 0048 GR + 7 A$_ulong2fs$125 0049 GR + 7 A$_ulong2fs$127 004A GR + 7 A$_ulong2fs$128 004B GR + 7 A$_ulong2fs$129 004C GR + 7 A$_ulong2fs$130 004D GR + 7 A$_ulong2fs$132 004E GR + 7 A$_ulong2fs$135 0050 GR + 7 A$_ulong2fs$138 0053 GR + 7 A$_ulong2fs$139 0054 GR + 7 A$_ulong2fs$140 0055 GR + 7 A$_ulong2fs$141 0056 GR + 7 A$_ulong2fs$142 0057 GR + 7 A$_ulong2fs$145 0058 GR + 7 A$_ulong2fs$146 0059 GR + 7 A$_ulong2fs$147 005A GR + 7 A$_ulong2fs$148 005B GR + 7 A$_ulong2fs$150 005C GR + 7 A$_ulong2fs$151 005F GR + 7 A$_ulong2fs$152 0060 GR + 7 A$_ulong2fs$153 0061 GR + 7 A$_ulong2fs$154 0062 GR + 7 A$_ulong2fs$155 0063 GR + 7 A$_ulong2fs$156 0064 GR + 7 A$_ulong2fs$157 0065 GR + 7 A$_ulong2fs$158 0066 GR + 7 A$_ulong2fs$159 0067 GR + 7 A$_ulong2fs$160 0068 GR + 7 A$_ulong2fs$162 0069 GR + 7 A$_ulong2fs$163 006A GR + 7 A$_ulong2fs$164 006C GR + 7 A$_ulong2fs$165 006E GR + 7 A$_ulong2fs$166 0070 GR + 7 A$_ulong2fs$169 0073 GR + 7 A$_ulong2fs$171 0074 GR + 7 A$_ulong2fs$174 0076 GR + 7 A$_ulong2fs$177 0079 GR + 7 A$_ulong2fs$178 007A GR + 7 A$_ulong2fs$179 007B GR + 7 A$_ulong2fs$180 007C GR + 7 A$_ulong2fs$181 007D GR + 7 A$_ulong2fs$183 007E GR + 7 A$_ulong2fs$184 007F GR + 7 A$_ulong2fs$185 0080 GR + 7 A$_ulong2fs$186 0081 GR + 7 A$_ulong2fs$187 0083 GR + 7 A$_ulong2fs$189 0084 GR + 7 A$_ulong2fs$190 0087 GR + 7 A$_ulong2fs$191 0088 GR + 7 A$_ulong2fs$192 0089 GR + 7 A$_ulong2fs$193 008A GR + 7 A$_ulong2fs$194 008B GR + 7 A$_ulong2fs$195 008C GR + 7 A$_ulong2fs$196 008D GR + 7 A$_ulong2fs$197 008E GR + 7 A$_ulong2fs$198 008F GR + 7 A$_ulong2fs$199 0090 GR + 7 A$_ulong2fs$200 0091 GR + 7 A$_ulong2fs$201 0092 GR + 7 A$_ulong2fs$202 0093 GR + 7 A$_ulong2fs$203 0094 GR + 7 A$_ulong2fs$204 0095 GR + 7 A$_ulong2fs$205 0096 GR + 7 A$_ulong2fs$208 0097 GR + 7 A$_ulong2fs$209 0098 GR + 7 A$_ulong2fs$210 009A GR + 7 A$_ulong2fs$212 009D GR + 7 A$_ulong2fs$213 00A0 GR + 7 A$_ulong2fs$214 00A1 GR + 7 A$_ulong2fs$215 00A2 GR + 7 A$_ulong2fs$216 00A3 GR + 7 A$_ulong2fs$217 00A4 GR + 7 A$_ulong2fs$218 00A5 GR + 7 A$_ulong2fs$219 00A6 GR + 7 A$_ulong2fs$220 00A7 GR + 7 A$_ulong2fs$221 00A8 GR + 7 A$_ulong2fs$222 00A9 GR + 7 A$_ulong2fs$223 00AA GR + 7 A$_ulong2fs$224 00AB GR + 7 A$_ulong2fs$225 00AC GR + 7 A$_ulong2fs$226 00AD GR + 7 A$_ulong2fs$227 00AF GR + 7 A$_ulong2fs$228 00B0 GR + 7 A$_ulong2fs$229 00B2 GR + 7 A$_ulong2fs$230 00B3 GR + 7 A$_ulong2fs$231 00B5 GR + 7 A$_ulong2fs$232 00B6 GR + 7 A$_ulong2fs$234 00B8 GR + 7 A$_ulong2fs$237 00BA GR + 7 A$_ulong2fs$238 00BB GR + 7 A$_ulong2fs$239 00BD GR + 7 A$_ulong2fs$240 00BE GR + 7 A$_ulong2fs$241 00BF GR + 7 A$_ulong2fs$242 00C0 GR + 7 A$_ulong2fs$243 00C1 GR + 7 A$_ulong2fs$244 00C2 GR + 7 A$_ulong2fs$245 00C3 GR + 7 A$_ulong2fs$246 00C4 GR + 7 A$_ulong2fs$247 00C5 GR + 7 A$_ulong2fs$248 00C6 GR + 7 A$_ulong2fs$249 00C7 GR + 7 A$_ulong2fs$250 00CA GR + 7 A$_ulong2fs$251 00CB GR + 7 A$_ulong2fs$252 00CC GR + 7 A$_ulong2fs$253 00CD GR + 7 A$_ulong2fs$254 00CE GR + 7 A$_ulong2fs$255 00CF GR + 7 A$_ulong2fs$256 00D0 GR + 7 A$_ulong2fs$257 00D1 GR + 7 A$_ulong2fs$258 00D2 GR + 7 A$_ulong2fs$259 00D3 GR + 7 A$_ulong2fs$260 00D4 GR + 7 A$_ulong2fs$262 00D5 GR + 7 A$_ulong2fs$263 00D7 GR + 7 A$_ulong2fs$264 00D9 GR + 7 A$_ulong2fs$265 00DC GR + 7 A$_ulong2fs$267 00DE GR + 7 A$_ulong2fs$270 00E1 GR + 7 A$_ulong2fs$272 00E4 GR + 7 A$_ulong2fs$273 00E6 GR + 7 A$_ulong2fs$274 00E8 GR + 7 A$_ulong2fs$275 00EA GR + 7 A$_ulong2fs$276 00EC GR + 7 A$_ulong2fs$277 00EE GR + 7 A$_ulong2fs$278 00EF GR + 7 A$_ulong2fs$279 00F1 GR + 7 A$_ulong2fs$280 00F3 GR + 7 A$_ulong2fs$281 00F5 GR + 7 A$_ulong2fs$282 00F6 GR + 7 A$_ulong2fs$283 00F8 GR + 7 A$_ulong2fs$284 00F9 GR + 7 A$_ulong2fs$285 00FB GR + 7 A$_ulong2fs$286 00FD GR + 7 A$_ulong2fs$287 0100 GR + 7 A$_ulong2fs$288 0103 GR + 7 A$_ulong2fs$289 0106 GR + 7 A$_ulong2fs$290 0107 GR + 7 A$_ulong2fs$291 0108 GR + 7 A$_ulong2fs$292 0109 GR + 7 A$_ulong2fs$293 010A GR + 7 A$_ulong2fs$294 010B GR + 7 A$_ulong2fs$295 010C GR + 7 A$_ulong2fs$296 010D GR + 7 A$_ulong2fs$297 010E GR + 7 A$_ulong2fs$298 010F GR + 7 A$_ulong2fs$299 0110 GR + 7 A$_ulong2fs$300 0111 GR + 7 A$_ulong2fs$301 0113 GR + 7 A$_ulong2fs$302 0115 GR + 7 A$_ulong2fs$303 0117 GR + 7 A$_ulong2fs$304 0119 GR + 7 A$_ulong2fs$305 011B GR + 7 A$_ulong2fs$306 011D GR + 7 A$_ulong2fs$307 011F GR + 7 A$_ulong2fs$308 0121 GR + 7 A$_ulong2fs$309 0122 GR + 7 A$_ulong2fs$310 0124 GR + 7 A$_ulong2fs$311 0125 GR + 7 A$_ulong2fs$312 0127 GR + 7 A$_ulong2fs$313 0128 GR + 7 A$_ulong2fs$314 012A GR + 7 A$_ulong2fs$315 012B GR + 7 A$_ulong2fs$316 012D GR + 7 A$_ulong2fs$317 0130 GR + 7 A$_ulong2fs$318 0131 GR + 7 A$_ulong2fs$319 0132 GR + 7 A$_ulong2fs$320 0133 GR + 7 A$_ulong2fs$321 0134 GR + 7 A$_ulong2fs$322 0135 GR + 7 A$_ulong2fs$323 0136 GR + 7 A$_ulong2fs$324 0137 GR + 7 A$_ulong2fs$325 0138 GR + 7 A$_ulong2fs$326 0139 GR + 7 A$_ulong2fs$327 013A GR + 7 A$_ulong2fs$329 013B GR + 7 A$_ulong2fs$330 013E GR + 7 A$_ulong2fs$331 013F GR + 7 A$_ulong2fs$332 0140 GR + 7 A$_ulong2fs$333 0141 GR + 7 A$_ulong2fs$334 0142 GR + 7 A$_ulong2fs$335 0143 GR + 7 A$_ulong2fs$336 0144 GR + 7 A$_ulong2fs$337 0145 GR + 7 A$_ulong2fs$338 0146 GR + 7 A$_ulong2fs$339 0147 GR + 7 A$_ulong2fs$341 0148 GR + 7 A$_ulong2fs$342 0149 GR + 7 A$_ulong2fs$343 014B GR + 7 A$_ulong2fs$344 014D GR + 7 A$_ulong2fs$348 014F GR + 7 A$_ulong2fs$72 0000 GR + 7 A$_ulong2fs$73 0002 GR + 7 A$_ulong2fs$74 0004 GR + 7 A$_ulong2fs$75 0006 GR + 7 A$_ulong2fs$76 0008 GR + 7 A$_ulong2fs$77 000B GR + 7 A$_ulong2fs$78 000D GR + 7 A$_ulong2fs$79 000E GR + 7 A$_ulong2fs$80 0010 GR + 7 A$_ulong2fs$81 0011 GR + 7 A$_ulong2fs$82 0012 GR + 7 A$_ulong2fs$83 0014 GR + 7 A$_ulong2fs$84 0015 GR + 7 A$_ulong2fs$85 0016 GR + 7 A$_ulong2fs$86 0018 GR + 7 A$_ulong2fs$87 0019 GR + 7 A$_ulong2fs$89 001A GR + 7 A$_ulong2fs$90 001D GR + 7 A$_ulong2fs$91 001E GR + 7 A$_ulong2fs$92 001F GR + 7 A$_ulong2fs$93 0020 GR + 7 A$_ulong2fs$94 0021 GR + 7 A$_ulong2fs$95 0022 GR + 7 A$_ulong2fs$96 0025 GR + 7 A$_ulong2fs$97 0026 GR + 7 A$_ulong2fs$98 0029 GR + 7 A$_ulong2fs$99 002A GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$_ulong2fs.c$110$1$1 = 014F GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$__ulong2fs$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$__ulong2fs$0$0 = 014F GR + 7 ___ulong2fs 0000 GR + 5 ___ulong2fs_a1_1_1 000C R + 5 ___ulong2fs_a_1_1 0000 R + 5 ___ulong2fs_fl_1_1 0008 R + 5 ___ulong2fs_sign_1_1 0004 R + 1 ___ulong2fs_sloc0_1_0 0000 R + 1 ___ulong2fs_sloc1_1_0 0002 R + __decdptr **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 6 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 10 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 150 flags 20 diff --git a/device/lib/assert.c b/device/lib/assert.c new file mode 100644 index 00000000..229ede97 --- /dev/null +++ b/device/lib/assert.c @@ -0,0 +1,9 @@ +#include +#include + +void _assert(char *expr, const char *filename, unsigned int linenumber) +{ + printf("Assert(%s) failed at line %u in file %s.\n", + expr, linenumber, filename); + while(1); +} diff --git a/device/lib/assert.lst b/device/lib/assert.lst new file mode 100644 index 00000000..721015b9 --- /dev/null +++ b/device/lib/assert.lst @@ -0,0 +1,144 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:40 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module assert + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl __assert + 11 .globl __assert_PARM_3 + 12 .globl __assert_PARM_2 + 13 ;-------------------------------------------------------- + 14 ; special function registers + 15 ;-------------------------------------------------------- + 16 ;-------------------------------------------------------- + 17 ; special function bits + 18 ;-------------------------------------------------------- + 19 ;-------------------------------------------------------- + 20 ; internal ram data + 21 ;-------------------------------------------------------- + 22 .area DSEG (DATA) + 23 ;-------------------------------------------------------- + 24 ; overlayable items in internal ram + 25 ;-------------------------------------------------------- + 26 .area OSEG (OVR,DATA) + 27 ;-------------------------------------------------------- + 28 ; indirectly addressable internal ram data + 29 ;-------------------------------------------------------- + 30 .area ISEG (DATA) + 31 ;-------------------------------------------------------- + 32 ; bit data + 33 ;-------------------------------------------------------- + 34 .area BSEG (BIT) + 35 ;-------------------------------------------------------- + 36 ; external ram data + 37 ;-------------------------------------------------------- + 38 .area XSEG (XDATA) + 0000 39 __assert_PARM_2: + 0000 40 .ds 0x0003 + 0003 41 __assert_PARM_3: + 0003 42 .ds 0x0002 + 0005 43 __assert_expr_1_1: + 0005 44 .ds 0x0003 + 45 ;-------------------------------------------------------- + 46 ; global & static initialisations + 47 ;-------------------------------------------------------- + 48 .area GSINIT (CODE) + 49 ;-------------------------------------------------------- + 50 ; code + 51 ;-------------------------------------------------------- + 52 .area CSEG (CODE) + 0000 53 G$_assert$0$0 ==. + 54 ; assert.c 4 + 55 ; ----------------------------------------- + 56 ; function _assert + 57 ; ----------------------------------------- + 0000 58 __assert: + 0002 59 ar2 = 0x02 + 0003 60 ar3 = 0x03 + 0004 61 ar4 = 0x04 + 0005 62 ar5 = 0x05 + 0006 63 ar6 = 0x06 + 0007 64 ar7 = 0x07 + 0000 65 ar0 = 0x00 + 0001 66 ar1 = 0x01 + 67 ; assert.c 0 + 0000 C0 F0 68 push b + 0002 C0 83 69 push dph + 0004 C0 82 70 push dpl + 0006 90s00r05 71 mov dptr,#__assert_expr_1_1 + 0009 D0 E0 72 pop acc + 000B F0 73 movx @dptr,a + 000C D0 E0 74 pop acc + 000E A3 75 inc dptr + 000F F0 76 movx @dptr,a + 0010 D0 E0 77 pop acc + 0012 A3 78 inc dptr + 0013 F0 79 movx @dptr,a + 80 ; assert.c 7 + 0014 90s00r05 81 mov dptr,#__assert_expr_1_1 + 0017 E0 82 movx a,@dptr + 0018 FA 83 mov r2,a + 0019 A3 84 inc dptr + 001A E0 85 movx a,@dptr + 001B FB 86 mov r3,a + 001C A3 87 inc dptr + 001D E0 88 movx a,@dptr + 001E FC 89 mov r4,a + 90 ; assert.c 6 + 001F 7Dr55 91 mov r5,#__str_0 + 0021 7Es00 92 mov r6,#(__str_0 >> 8) + 0023 7F 02 93 mov r7,#0x02 + 0025 90s00r00 94 mov dptr,#__assert_PARM_2 + 0028 E0 95 movx a,@dptr + 96 ; Peephole 100.a removed redundant mov + 0029 C0 E0 97 push acc + 002B A3 98 inc dptr + 002C E0 99 movx a,@dptr + 100 ; Peephole 100.a removed redundant mov + 002D C0 E0 101 push acc + 002F A3 102 inc dptr + 0030 E0 103 movx a,@dptr + 104 ; Peephole 100.a removed redundant mov + 0031 C0 E0 105 push acc + 0033 90s00r03 106 mov dptr,#__assert_PARM_3 + 0036 E0 107 movx a,@dptr + 108 ; Peephole 100.a removed redundant mov + 0037 C0 E0 109 push acc + 0039 A3 110 inc dptr + 003A E0 111 movx a,@dptr + 112 ; Peephole 100.a removed redundant mov + 003B C0 E0 113 push acc + 003D C0 05 114 push ar5 + 003F C0 06 115 push ar6 + 0041 C0 07 116 push ar7 + 0043 8A 82 117 mov dpl,r2 + 0045 8B 83 118 mov dph,r3 + 0047 8C F0 119 mov b,r4 + 0049 12s00r00 120 lcall _printf + 004C E5 81 121 mov a,sp + 004E 24 FA 122 add a,#0xfa + 0050 F5 81 123 mov sp,a + 124 ; assert.c 8 + 0052 125 00102$: + 126 ; Peephole 132 changed ljmp to sjmp + 0052 80 FE 127 sjmp 00102$ + 0054 128 00104$: + 0054 129 C$assert.c$9$1$1 ==. + 0054 130 XG$_assert$0$0 ==. + 0054 22 131 ret + 132 .area CSEG (CODE) + 0055 133 Fassert$_str_0$0$0 == . + 0055 134 __str_0: + 0055 41 73 73 65 72 74 135 .ascii /Assert(%s) failed at line %u in file %s./ + 28 25 73 29 20 66 + 61 69 6C 65 64 20 + 61 74 20 6C 69 6E + 65 20 25 75 20 69 + 6E 20 66 69 6C 65 + 20 25 73 2E + 007D 0A 136 .byte 0x0a + 007E 137 .ascii // + 007E 00 138 .byte 0 diff --git a/device/lib/assert.sym b/device/lib/assert.sym new file mode 100644 index 00000000..1c77961e --- /dev/null +++ b/device/lib/assert.sym @@ -0,0 +1,422 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$assert$101 002D GR + 7 A$assert$102 002F GR + 7 A$assert$103 0030 GR + 7 A$assert$105 0031 GR + 7 A$assert$106 0033 GR + 7 A$assert$107 0036 GR + 7 A$assert$109 0037 GR + 7 A$assert$110 0039 GR + 7 A$assert$111 003A GR + 7 A$assert$113 003B GR + 7 A$assert$114 003D GR + 7 A$assert$115 003F GR + 7 A$assert$116 0041 GR + 7 A$assert$117 0043 GR + 7 A$assert$118 0045 GR + 7 A$assert$119 0047 GR + 7 A$assert$120 0049 GR + 7 A$assert$121 004C GR + 7 A$assert$122 004E GR + 7 A$assert$123 0050 GR + 7 A$assert$127 0052 GR + 7 A$assert$131 0054 GR + 7 A$assert$68 0000 GR + 7 A$assert$69 0002 GR + 7 A$assert$70 0004 GR + 7 A$assert$71 0006 GR + 7 A$assert$72 0009 GR + 7 A$assert$73 000B GR + 7 A$assert$74 000C GR + 7 A$assert$75 000E GR + 7 A$assert$76 000F GR + 7 A$assert$77 0010 GR + 7 A$assert$78 0012 GR + 7 A$assert$79 0013 GR + 7 A$assert$81 0014 GR + 7 A$assert$82 0017 GR + 7 A$assert$83 0018 GR + 7 A$assert$84 0019 GR + 7 A$assert$85 001A GR + 7 A$assert$86 001B GR + 7 A$assert$87 001C GR + 7 A$assert$88 001D GR + 7 A$assert$89 001E GR + 7 A$assert$91 001F GR + 7 A$assert$92 0021 GR + 7 A$assert$93 0023 GR + 7 A$assert$94 0025 GR + 7 A$assert$95 0028 GR + 7 A$assert$97 0029 GR + 7 A$assert$98 002B GR + 7 A$assert$99 002C GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$assert.c$9$1$1 = 0054 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 Fassert$_str_0$0$0 = 0055 GR + 7 G$_assert$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$_assert$0$0 = 0054 GR + 7 __assert 0000 GR + 5 __assert_PARM_2 0000 GR + 5 __assert_PARM_3 0003 GR + 5 __assert_expr_1_1 0005 R + 7 __str_0 0055 R + _printf **** GX + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 8 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 7F flags 20 diff --git a/device/lib/clean.mk b/device/lib/clean.mk new file mode 100644 index 00000000..c3d26ea6 --- /dev/null +++ b/device/lib/clean.mk @@ -0,0 +1,28 @@ +include incl.mk + +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] *.rel *.lst *.sym *.asm *.ihx *.dump* *.cdb + rm -f .[a-z]*~ + rm -f *.dump* + for model in $(MODELS); do \ + rm -rf $$model; \ + done + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/device/lib/conf.mk b/device/lib/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/device/lib/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/device/lib/incl.mk b/device/lib/incl.mk new file mode 100644 index 00000000..e1cae0c3 --- /dev/null +++ b/device/lib/incl.mk @@ -0,0 +1 @@ +MODELS = small large diff --git a/device/lib/large/_atoi.asm b/device/lib/large/_atoi.asm new file mode 100644 index 00000000..7fa4dad2 --- /dev/null +++ b/device/lib/large/_atoi.asm @@ -0,0 +1,335 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + +;-------------------------------------------------------- + .module _atoi +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _atoi +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_atoi_s_1_1: + .ds 0x0003 +_atoi_rv_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$atoi$0$0 ==. +; _atoi.c 25 +; ----------------------------------------- +; function atoi +; ----------------------------------------- +_atoi: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _atoi.c 0 + push b + push dph + push dpl + mov dptr,#_atoi_s_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _atoi.c 27 + mov dptr,#_atoi_rv_1_1 + clr a + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _atoi.c 31 + mov dptr,#_atoi_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +00107$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00109$ +00133$: +; _atoi.c 32 + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r5 + xrl b,#0x80 + subb a,b +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00134$: + clr c + mov a,r5 + xrl a,#0x80 + subb a,#0xb0 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00109$ +00135$: +; _atoi.c 33 +00102$: +; _atoi.c 34 + cjne r5,#0x2d,00136$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00136$: + cjne r5,#0x2b,00137$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00137$: +; _atoi.c 36 + inc r2 + cjne r2,#0x00,00138$ + inc r3 +00138$: + mov dptr,#_atoi_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00109$: +; _atoi.c 39 + mov dptr,#_atoi_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget + mov r5,a + cjne r5,#0x2d,00139$ + mov a,#0x01 + sjmp 00140$ +00139$: + clr a +00140$: +; _atoi.c 40 +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00110$ +00141$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r5,#0x2b,00131$ +; Peephole 201 removed redundant sjmp +00142$: +00143$: +00110$: + mov dptr,#_atoi_s_1_1 + mov a,#0x01 + add a,r2 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + inc dptr + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _atoi.c 42 +00131$: + mov dptr,#_atoi_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +00115$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a + jnz 00144$ + ljmp 00117$ +00144$: + clr c + mov a,r5 + xrl a,#0x80 + subb a,#0xb0 + jnc 00145$ + ljmp 00117$ +00145$: + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r5 + xrl b,#0x80 + subb a,b + jnc 00146$ + ljmp 00117$ +00146$: +; _atoi.c 43 + mov dptr,#_atoi_rv_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + mov dptr,#__mulsint_PARM_2 + clr a + inc dptr + movx @dptr,a + lcall __decdptr + mov a,#0x0a + movx @dptr,a + push ar2 + push ar3 + push ar4 + push ar5 + push ar6 + mov dpl,r7 + mov dph,r0 + lcall __mulsint + mov r7,dpl + mov r0,dph + pop ar6 + pop ar5 + pop ar4 + pop ar3 + pop ar2 + mov a,r5 + add a,#0xd0 + mov r5,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r1,a + mov dptr,#_atoi_rv_1_1 + mov a,r5 + add a,r7 + movx @dptr,a + mov a,r1 + addc a,r0 + inc dptr + movx @dptr,a +; _atoi.c 44 + inc r2 + cjne r2,#0x00,00147$ + inc r3 +00147$: + mov dptr,#_atoi_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + ljmp 00115$ +00117$: +; _atoi.c 47 + mov dptr,#_atoi_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov a,r6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00120$ +00148$: + mov dptr,#_atoi_rv_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + clr c + clr a + subb a,r2 + mov r2,a + clr a + subb a,r3 + mov r3,a +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00120$: + mov dptr,#_atoi_rv_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a +00121$: + mov dpl,r2 + mov dph,r3 +00118$: + C$_atoi.c$48$1$1 ==. + XG$atoi$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_atoi.cdb b/device/lib/large/_atoi.cdb new file mode 100644 index 00000000..f79ca306 --- /dev/null +++ b/device/lib/large/_atoi.cdb @@ -0,0 +1,2 @@ +M:_atoi +F:G$atoi$0$0({2}DF,SI:S),C,0,0,0,0,0 diff --git a/device/lib/large/_atoi.rel b/device/lib/large/_atoi.rel new file mode 100644 index 00000000..b237469f --- /dev/null +++ b/device/lib/large/_atoi.rel @@ -0,0 +1,363 @@ +;!FILE _atoi.asm +XH +H 8 areas DB global symbols +M _atoi +S __mulsint Ref0000 +S __decdptr Ref0000 +S __mulsint_PARM_2 Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 5 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 14E flags 20 +S A$_atoi$200 Def009B +S A$_atoi$101 Def0033 +S A$_atoi$300 Def012B +S A$_atoi$210 Def00A7 +S A$_atoi$201 Def009C +S A$_atoi$310 Def0136 +S A$_atoi$301 Def012C +S A$_atoi$220 Def00B6 +S A$_atoi$202 Def009D +S A$_atoi$130 Def0051 +S A$_atoi$112 Def003F +S A$_atoi$320 Def013F +S A$_atoi$311 Def0137 +S A$_atoi$302 Def012D +S A$_atoi$230 Def00C7 +S A$_atoi$221 Def00B8 +S A$_atoi$212 Def00AA +S A$_atoi$203 Def009E +S A$_atoi$140 Def005D +S A$_atoi$104 Def0035 +S A$_atoi$330 Def014B +S A$_atoi$312 Def0138 +S A$_atoi$240 Def00D5 +S A$_atoi$213 Def00AB +S A$_atoi$204 Def009F +S A$_atoi$150 Def0065 +S A$_atoi$141 Def005E +S A$_atoi$114 Def0041 +S A$_atoi$322 Def0141 +S A$_atoi$313 Def0139 +S A$_atoi$304 Def012E +S A$_atoi$250 Def00E6 +S A$_atoi$241 Def00D6 +S A$_atoi$223 Def00BB +S A$_atoi$214 Def00AD +S A$_atoi$205 Def00A0 +S A$_atoi$160 Def0072 +S A$_atoi$151 Def0068 +S A$_atoi$142 Def005F +S A$_atoi$133 Def0053 +S A$_atoi$124 Def0049 +S A$_atoi$115 Def0042 +S A$_atoi$106 Def0036 +S _atoi Def0000 +S A$_atoi$323 Def0144 +S A$_atoi$314 Def013A +S A$_atoi$260 Def00FB +S A$_atoi$251 Def00E8 +S A$_atoi$242 Def00D7 +S A$_atoi$233 Def00CA +S A$_atoi$161 Def0074 +S A$_atoi$152 Def0069 +S A$_atoi$143 Def0060 +S A$_atoi$134 Def0054 +S A$_atoi$116 Def0043 +S A$_atoi$107 Def0038 +S A$_atoi$324 Def0145 +S A$_atoi$315 Def013B +S A$_atoi$306 Def0130 +S A$_atoi$270 Def0109 +S A$_atoi$261 Def00FD +S A$_atoi$252 Def00EA +S A$_atoi$243 Def00D8 +S A$_atoi$234 Def00CD +S A$_atoi$225 Def00BC +S A$_atoi$216 Def00B0 +S A$_atoi$207 Def00A1 +S A$_atoi$162 Def0076 +S A$_atoi$153 Def006A +S A$_atoi$144 Def0061 +S A$_atoi$135 Def0057 +S A$_atoi$126 Def004C +S A$_atoi$117 Def0045 +S A$_atoi$108 Def003A +S A$_atoi$334 Def014D +S A$_atoi$325 Def0146 +S A$_atoi$316 Def013C +S A$_atoi$307 Def0133 +S A$_atoi$271 Def010A +S A$_atoi$262 Def00FE +S A$_atoi$253 Def00EC +S A$_atoi$244 Def00DB +S A$_atoi$235 Def00CE +S A$_atoi$226 Def00BE +S A$_atoi$217 Def00B1 +S A$_atoi$208 Def00A3 +S A$_atoi$190 Def0091 +S A$_atoi$172 Def0082 +S A$_atoi$163 Def0079 +S A$_atoi$154 Def006B +S A$_atoi$145 Def0062 +S A$_atoi$109 Def003D +S A$_atoi$326 Def0147 +S A$_atoi$317 Def013D +S A$_atoi$308 Def0134 +S A$_atoi$290 Def011F +S A$_atoi$281 Def0114 +S A$_atoi$272 Def010B +S A$_atoi$263 Def0100 +S A$_atoi$254 Def00EF +S A$_atoi$245 Def00DD +S A$_atoi$236 Def00CF +S A$_atoi$227 Def00C0 +S A$_atoi$218 Def00B2 +S A$_atoi$209 Def00A5 +S A$_atoi$191 Def0092 +S A$_atoi$164 Def007A +S A$_atoi$155 Def006C +S A$_atoi$137 Def0058 +S A$_atoi$128 Def004E +S A$_atoi$119 Def0047 +S A$_atoi$327 Def0148 +S A$_atoi$318 Def013E +S A$_atoi$309 Def0135 +S A$_atoi$282 Def0117 +S A$_atoi$273 Def010C +S A$_atoi$255 Def00F1 +S A$_atoi$246 Def00DE +S A$_atoi$237 Def00D0 +S A$_atoi$228 Def00C3 +S A$_atoi$219 Def00B4 +S A$_atoi$192 Def0093 +S A$_atoi$183 Def0088 +S A$_atoi$174 Def0083 +S A$_atoi$165 Def007D +S A$_atoi$156 Def006D +S A$_atoi$147 Def0063 +S A$_atoi$138 Def005B +S A$_atoi$283 Def0118 +S A$_atoi$274 Def010D +S A$_atoi$265 Def0101 +S A$_atoi$256 Def00F3 +S A$_atoi$247 Def00E0 +S A$_atoi$238 Def00D1 +S A$_atoi$229 Def00C5 +S A$_atoi$193 Def0094 +S A$_atoi$184 Def008B +S A$_atoi$166 Def007F +S A$_atoi$157 Def006E +S A$_atoi$139 Def005C +S A$_atoi$329 Def0149 +S A$_atoi$293 Def0122 +S A$_atoi$284 Def0119 +S A$_atoi$275 Def010E +S A$_atoi$266 Def0102 +S A$_atoi$257 Def00F5 +S A$_atoi$248 Def00E2 +S A$_atoi$239 Def00D2 +S A$_atoi$194 Def0095 +S A$_atoi$185 Def008D +S A$_atoi$158 Def006F +S A$_atoi$294 Def0125 +S A$_atoi$285 Def011A +S A$_atoi$267 Def0104 +S A$_atoi$258 Def00F7 +S A$_atoi$249 Def00E4 +S A$_atoi$186 Def008E +S A$_atoi$168 Def0081 +S A$_atoi$159 Def0070 +S A$_atoi$295 Def0126 +S A$_atoi$286 Def011B +S A$_atoi$277 Def010F +S A$_atoi$268 Def0105 +S A$_atoi$259 Def00F9 +S A$_atoi$178 Def0085 +S A$_atoi$296 Def0127 +S A$_atoi$287 Def011C +S A$_atoi$278 Def0110 +S A$_atoi$269 Def0108 +S A$_atoi$197 Def0096 +S A$_atoi$188 Def008F +S A$_atoi$297 Def0128 +S A$_atoi$288 Def011D +S A$_atoi$279 Def0113 +S A$_atoi$198 Def0099 +S A$_atoi$189 Def0090 +S A$_atoi$298 Def0129 +S A$_atoi$289 Def011E +S A$_atoi$199 Def009A +S XG$atoi$0$0 Def014D +S A$_atoi$299 Def012A +S A$_atoi$70 Def000C +S A$_atoi$80 Def0019 +S A$_atoi$71 Def000E +S A$_atoi$90 Def0026 +S A$_atoi$81 Def001A +S A$_atoi$72 Def000F +S C$_atoi.c$48$1$1 Def014D +S A$_atoi$91 Def0027 +S A$_atoi$82 Def001D +S A$_atoi$73 Def0010 +S A$_atoi$64 Def0000 +S A$_atoi$92 Def0028 +S A$_atoi$74 Def0012 +S A$_atoi$65 Def0002 +S G$atoi$0$0 Def0000 +S A$_atoi$84 Def001E +S A$_atoi$75 Def0013 +S A$_atoi$66 Def0004 +S A$_atoi$94 Def0029 +S A$_atoi$85 Def0021 +S A$_atoi$67 Def0006 +S A$_atoi$95 Def002B +S A$_atoi$86 Def0022 +S A$_atoi$77 Def0014 +S A$_atoi$68 Def0009 +S A$_atoi$96 Def002D +S A$_atoi$87 Def0023 +S A$_atoi$78 Def0017 +S A$_atoi$69 Def000B +S A$_atoi$97 Def002F +S A$_atoi$88 Def0024 +S A$_atoi$79 Def0018 +S A$_atoi$89 Def0025 +S A$_atoi$99 Def0032 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E4 A3 F0 12 +R 00 00 00 07 00 09 00 05 +T 00 1B 00 00 F0 90 00 00 E0 FA A3 E0 FB A3 E0 FC +R 00 00 00 07 02 02 00 01 00 06 00 05 +T 00 29 +R 00 00 00 07 +T 00 29 8A 82 8B 83 8C F0 12 00 00 FD 60 30 +R 00 00 00 07 02 09 00 03 +T 00 35 +R 00 00 00 07 +T 00 35 C3 74 B9 8D F0 63 F0 80 95 F0 40 08 +R 00 00 00 07 +T 00 41 +R 00 00 00 07 +T 00 41 C3 ED 64 80 94 B0 50 1C +R 00 00 00 07 +T 00 49 +R 00 00 00 07 +T 00 49 +R 00 00 00 07 +T 00 49 BD 2D 02 80 17 +R 00 00 00 07 +T 00 4E +R 00 00 00 07 +T 00 4E BD 2B 02 80 12 +R 00 00 00 07 +T 00 53 +R 00 00 00 07 +T 00 53 0A BA 00 01 0B +R 00 00 00 07 +T 00 58 +R 00 00 00 07 +T 00 58 90 00 00 EA F0 A3 EB F0 A3 EC F0 80 C4 +R 00 00 00 07 00 03 00 05 +T 00 65 +R 00 00 00 07 +T 00 65 90 00 00 EA F0 A3 EB F0 A3 EC F0 8A 82 8B +R 00 00 00 07 00 03 00 05 +T 00 73 83 8C F0 12 00 00 FD BD 2D 04 74 01 80 01 +R 00 00 00 07 02 06 00 03 +T 00 81 +R 00 00 00 07 +T 00 81 E4 +R 00 00 00 07 +T 00 82 +R 00 00 00 07 +T 00 82 FE 70 03 +R 00 00 00 07 +T 00 85 +R 00 00 00 07 +T 00 85 BD 2B 0E +R 00 00 00 07 +T 00 88 +R 00 00 00 07 +T 00 88 +R 00 00 00 07 +T 00 88 +R 00 00 00 07 +T 00 88 90 00 00 74 01 2A F0 E4 3B A3 F0 A3 EC F0 +R 00 00 00 07 00 03 00 05 +T 00 96 +R 00 00 00 07 +T 00 96 90 00 00 E0 FA A3 E0 FB A3 E0 FC +R 00 00 00 07 00 03 00 05 +T 00 A1 +R 00 00 00 07 +T 00 A1 8A 82 8B 83 8C F0 12 00 00 FD 70 03 02 +R 00 00 00 07 02 09 00 03 +T 00 AE 01 22 +R 00 00 00 07 00 02 00 07 +T 00 B0 +R 00 00 00 07 +T 00 B0 C3 ED 64 80 94 B0 50 03 02 01 22 +R 00 00 00 07 00 0B 00 07 +T 00 BB +R 00 00 00 07 +T 00 BB C3 74 B9 8D F0 63 F0 80 95 F0 50 03 02 +R 00 00 00 07 +T 00 C8 01 22 +R 00 00 00 07 00 02 00 07 +T 00 CA +R 00 00 00 07 +T 00 CA 90 00 03 E0 FF A3 E0 F8 90 00 00 E4 A3 F0 +R 00 00 00 07 00 03 00 05 02 0B 00 02 +T 00 D8 12 00 00 74 0A F0 C0 02 C0 03 C0 04 C0 05 +R 00 00 00 07 02 03 00 01 +T 00 E6 C0 06 8F 82 88 83 12 00 00 AF 82 A8 83 D0 +R 00 00 00 07 02 09 00 00 +T 00 F4 06 D0 05 D0 04 D0 03 D0 02 ED 24 D0 FD E4 +R 00 00 00 07 +T 01 02 34 FF F9 90 00 03 ED 2F F0 E9 38 A3 F0 0A +R 00 00 00 07 00 06 00 05 +T 01 10 BA 00 01 0B +R 00 00 00 07 +T 01 14 +R 00 00 00 07 +T 01 14 90 00 00 EA F0 A3 EB F0 A3 EC F0 02 00 A1 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 01 22 +R 00 00 00 07 +T 01 22 90 00 00 EA F0 A3 EB F0 A3 EC F0 EE 60 11 +R 00 00 00 07 00 03 00 05 +T 01 30 +R 00 00 00 07 +T 01 30 90 00 03 E0 FA A3 E0 FB C3 E4 9A FA E4 9B +R 00 00 00 07 00 03 00 05 +T 01 3E FB 80 08 +R 00 00 00 07 +T 01 41 +R 00 00 00 07 +T 01 41 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 03 00 05 +T 01 49 +R 00 00 00 07 +T 01 49 8A 82 8B 83 +R 00 00 00 07 +T 01 4D +R 00 00 00 07 +T 01 4D 22 +R 00 00 00 07 diff --git a/device/lib/large/_atol.asm b/device/lib/large/_atol.asm new file mode 100644 index 00000000..c66cfe87 --- /dev/null +++ b/device/lib/large/_atol.asm @@ -0,0 +1,397 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + +;-------------------------------------------------------- + .module _atol +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _atol +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_atol_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_atol_s_1_1: + .ds 0x0003 +_atol_rv_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$atol$0$0 ==. +; _atol.c 25 +; ----------------------------------------- +; function atol +; ----------------------------------------- +_atol: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _atol.c 0 + push b + push dph + push dpl + mov dptr,#_atol_s_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _atol.c 27 + mov dptr,#_atol_rv_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _atol.c 31 + mov dptr,#_atol_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +00107$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00109$ +00133$: +; _atol.c 32 + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r5 + xrl b,#0x80 + subb a,b +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00134$: + clr c + mov a,r5 + xrl a,#0x80 + subb a,#0xb0 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00109$ +00135$: +; _atol.c 33 +00102$: +; _atol.c 34 + cjne r5,#0x2d,00136$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00136$: + cjne r5,#0x2b,00137$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00137$: +; _atol.c 36 + inc r2 + cjne r2,#0x00,00138$ + inc r3 +00138$: + mov dptr,#_atol_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00109$: +; _atol.c 39 + mov dptr,#_atol_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget + mov r5,a + cjne r5,#0x2d,00139$ + mov a,#0x01 + sjmp 00140$ +00139$: + clr a +00140$: +; _atol.c 40 +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00110$ +00141$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r5,#0x2b,00131$ +; Peephole 201 removed redundant sjmp +00142$: +00143$: +00110$: + mov dptr,#_atol_s_1_1 + mov a,#0x01 + add a,r2 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + inc dptr + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _atol.c 42 +00131$: + mov dptr,#_atol_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +00115$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a + jnz 00144$ + ljmp 00117$ +00144$: + clr c + mov a,r5 + xrl a,#0x80 + subb a,#0xb0 + jnc 00145$ + ljmp 00117$ +00145$: + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r5 + xrl b,#0x80 + subb a,b + jnc 00146$ + ljmp 00117$ +00146$: +; _atol.c 43 + push ar6 + mov dptr,#_atol_rv_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr + mov r6,a + mov dptr,#__mulslong_PARM_2 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + mov a,#0x0a + movx @dptr,a + push ar2 + push ar3 + push ar4 + push ar5 + push ar6 + mov dpl,r7 + mov dph,r0 + mov b,r1 + mov a,r6 + lcall __mulslong + mov _atol_sloc0_1_0,dpl + mov (_atol_sloc0_1_0 + 1),dph + mov (_atol_sloc0_1_0 + 2),b + mov (_atol_sloc0_1_0 + 3),a + pop ar6 + pop ar5 + pop ar4 + pop ar3 + pop ar2 + mov a,r5 + add a,#0xd0 + mov r5,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r6,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r7,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r0,a + mov dptr,#_atol_rv_1_1 + mov a,r5 + add a,_atol_sloc0_1_0 + movx @dptr,a + mov a,r6 + addc a,(_atol_sloc0_1_0 + 1) + inc dptr + movx @dptr,a + mov a,r7 + addc a,(_atol_sloc0_1_0 + 2) + inc dptr + movx @dptr,a + mov a,r0 + addc a,(_atol_sloc0_1_0 + 3) + inc dptr + movx @dptr,a +; _atol.c 44 + inc r2 + cjne r2,#0x00,00147$ + inc r3 +00147$: + mov dptr,#_atol_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + pop ar6 + ljmp 00115$ +00117$: +; _atol.c 47 + mov dptr,#_atol_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov a,r6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00120$ +00148$: + mov dptr,#_atol_rv_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + clr c + clr a + subb a,r2 + mov r2,a + clr a + subb a,r3 + mov r3,a + clr a + subb a,r4 + mov r4,a + clr a + subb a,r5 + mov r5,a +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00120$: + mov dptr,#_atol_rv_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a +00121$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 +00118$: + C$_atol.c$48$1$1 ==. + XG$atol$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_atol.cdb b/device/lib/large/_atol.cdb new file mode 100644 index 00000000..110eace8 --- /dev/null +++ b/device/lib/large/_atol.cdb @@ -0,0 +1,2 @@ +M:_atol +F:G$atol$0$0({2}DF,SL:S),C,0,0,0,0,0 diff --git a/device/lib/large/_atol.rel b/device/lib/large/_atol.rel new file mode 100644 index 00000000..edca1f6d --- /dev/null +++ b/device/lib/large/_atol.rel @@ -0,0 +1,439 @@ +;!FILE _atol.asm +XH +H 8 areas 115 global symbols +M _atol +S __mulslong_PARM_2 Ref0000 +S __decdptr Ref0000 +S __mulslong Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 4 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 7 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 19F flags 20 +S A$_atol$100 Def0032 +S A$_atol$200 Def009D +S A$_atol$300 Def0132 +S A$_atol$210 Def00A7 +S A$_atol$201 Def009E +S A$_atol$120 Def0049 +S A$_atol$102 Def0033 +S A$_atol$310 Def0140 +S A$_atol$301 Def0133 +S A$_atol$220 Def00B4 +S A$_atol$211 Def00A8 +S A$_atol$202 Def009F +S A$_atol$112 Def003F +S A$_atol$103 Def0035 +S A$_atol$320 Def014D +S A$_atol$311 Def0142 +S A$_atol$302 Def0136 +S A$_atol$221 Def00B5 +S A$_atol$212 Def00A9 +S A$_atol$122 Def004B +S A$_atol$104 Def0037 +S A$_atol$330 Def0158 +S A$_atol$312 Def0143 +S A$_atol$303 Def0137 +S A$_atol$231 Def00C5 +S A$_atol$222 Def00B7 +S A$_atol$213 Def00AA +S A$_atol$150 Def0069 +S A$_atol$141 Def005D +S A$_atol$132 Def0053 +S A$_atol$123 Def004C +S A$_atol$114 Def0040 +S A$_atol$105 Def0039 +S A$_atol$340 Def0165 +S A$_atol$331 Def0159 +S A$_atol$322 Def014E +S A$_atol$313 Def0144 +S A$_atol$304 Def0139 +S A$_atol$250 Def00E0 +S A$_atol$241 Def00D4 +S A$_atol$205 Def00A0 +S A$_atol$160 Def0073 +S A$_atol$151 Def006A +S A$_atol$142 Def005E +S A$_atol$124 Def004D +S A$_atol$115 Def0042 +S _atol Def0000 +S A$_atol$350 Def0170 +S A$_atol$341 Def0166 +S A$_atol$332 Def015B +S A$_atol$323 Def0151 +S A$_atol$314 Def0145 +S A$_atol$305 Def013A +S A$_atol$260 Def00EC +S A$_atol$251 Def00E1 +S A$_atol$242 Def00D6 +S A$_atol$233 Def00C6 +S A$_atol$224 Def00BA +S A$_atol$215 Def00AB +S A$_atol$206 Def00A3 +S A$_atol$170 Def0080 +S A$_atol$161 Def0074 +S A$_atol$152 Def006B +S A$_atol$143 Def0061 +S A$_atol$134 Def0056 +S A$_atol$125 Def004F +S A$_atol$116 Def0044 +S A$_atol$107 Def003C +S A$_atol$360 Def017A +S A$_atol$351 Def0171 +S A$_atol$342 Def0167 +S A$_atol$324 Def0152 +S A$_atol$315 Def0147 +S A$_atol$306 Def013B +S A$_atol$270 Def0100 +S A$_atol$261 Def00EF +S A$_atol$252 Def00E2 +S A$_atol$243 Def00D9 +S A$_atol$234 Def00C8 +S A$_atol$225 Def00BB +S A$_atol$216 Def00AD +S A$_atol$207 Def00A4 +S A$_atol$180 Def008C +S A$_atol$171 Def0083 +S A$_atol$162 Def0075 +S A$_atol$153 Def006C +S A$_atol$117 Def0047 +S A$_atol$370 Def0184 +S A$_atol$361 Def017B +S A$_atol$352 Def0172 +S A$_atol$343 Def0168 +S A$_atol$325 Def0153 +S A$_atol$316 Def0148 +S A$_atol$307 Def013D +S A$_atol$280 Def0117 +S A$_atol$271 Def0102 +S A$_atol$262 Def00F0 +S A$_atol$253 Def00E3 +S A$_atol$244 Def00DA +S A$_atol$235 Def00CA +S A$_atol$226 Def00BC +S A$_atol$217 Def00AF +S A$_atol$208 Def00A5 +S A$_atol$172 Def0084 +S A$_atol$163 Def0076 +S A$_atol$145 Def0062 +S A$_atol$136 Def0058 +S A$_atol$127 Def0051 +S A$_atol$109 Def003D +S A$_atol$380 Def018F +S A$_atol$371 Def0185 +S A$_atol$362 Def017C +S A$_atol$353 Def0173 +S A$_atol$344 Def0169 +S A$_atol$335 Def015E +S A$_atol$326 Def0154 +S A$_atol$308 Def013E +S A$_atol$290 Def0127 +S A$_atol$281 Def0119 +S A$_atol$272 Def0104 +S A$_atol$263 Def00F3 +S A$_atol$254 Def00E4 +S A$_atol$245 Def00DB +S A$_atol$236 Def00CD +S A$_atol$227 Def00BE +S A$_atol$218 Def00B1 +S A$_atol$209 Def00A6 +S A$_atol$191 Def0092 +S A$_atol$182 Def008D +S A$_atol$173 Def0087 +S A$_atol$164 Def0077 +S A$_atol$155 Def006D +S A$_atol$146 Def0065 +S A$_atol$390 Def0199 +S A$_atol$381 Def0190 +S A$_atol$372 Def0186 +S A$_atol$363 Def017D +S A$_atol$354 Def0174 +S A$_atol$336 Def0161 +S A$_atol$327 Def0155 +S A$_atol$318 Def0149 +S A$_atol$309 Def013F +S A$_atol$291 Def0128 +S A$_atol$282 Def011B +S A$_atol$273 Def0106 +S A$_atol$264 Def00F4 +S A$_atol$255 Def00E7 +S A$_atol$246 Def00DC +S A$_atol$237 Def00CF +S A$_atol$228 Def00C0 +S A$_atol$192 Def0095 +S A$_atol$174 Def0089 +S A$_atol$165 Def0078 +S A$_atol$147 Def0066 +S A$_atol$138 Def005B +S A$_atol$391 Def019B +S A$_atol$382 Def0191 +S A$_atol$364 Def017E +S A$_atol$355 Def0175 +S A$_atol$346 Def016A +S A$_atol$337 Def0162 +S A$_atol$328 Def0156 +S A$_atol$319 Def014A +S A$_atol$292 Def012A +S A$_atol$283 Def011D +S A$_atol$274 Def0108 +S A$_atol$265 Def00F7 +S A$_atol$256 Def00E8 +S A$_atol$247 Def00DD +S A$_atol$238 Def00D1 +S A$_atol$229 Def00C2 +S A$_atol$193 Def0097 +S A$_atol$166 Def0079 +S A$_atol$148 Def0067 +S A$_atol$392 Def019D +S A$_atol$383 Def0192 +S A$_atol$374 Def0187 +S A$_atol$365 Def017F +S A$_atol$356 Def0176 +S A$_atol$338 Def0163 +S A$_atol$329 Def0157 +S A$_atol$284 Def011F +S A$_atol$275 Def010A +S A$_atol$266 Def00F9 +S A$_atol$257 Def00E9 +S A$_atol$248 Def00DE +S A$_atol$194 Def0098 +S A$_atol$176 Def008B +S A$_atol$167 Def007A +S A$_atol$158 Def006F +S A$_atol$149 Def0068 +S A$_atol$384 Def0193 +S A$_atol$366 Def0180 +S A$_atol$357 Def0177 +S A$_atol$348 Def016C +S A$_atol$339 Def0164 +S A$_atol$294 Def012B +S A$_atol$285 Def0121 +S A$_atol$276 Def010B +S A$_atol$267 Def00FA +S A$_atol$258 Def00EA +S A$_atol$249 Def00DF +S A$_atol$186 Def008F +S A$_atol$168 Def007C +S A$_atol$159 Def0072 +S A$_atol$385 Def0194 +S A$_atol$376 Def0189 +S A$_atol$367 Def0181 +S A$_atol$358 Def0178 +S A$_atol$349 Def016F +S A$_atol$295 Def012C +S A$_atol$286 Def0123 +S A$_atol$277 Def010E +S A$_atol$268 Def00FC +S A$_atol$259 Def00EB +S A$_atol$196 Def0099 +S A$_atol$169 Def007E +S A$_atol$386 Def0195 +S A$_atol$377 Def018C +S A$_atol$368 Def0182 +S A$_atol$359 Def0179 +S A$_atol$296 Def012E +S A$_atol$287 Def0124 +S A$_atol$278 Def0111 +S A$_atol$269 Def00FE +S A$_atol$197 Def009A +S A$_atol$396 Def019E +S A$_atol$387 Def0196 +S A$_atol$378 Def018D +S A$_atol$369 Def0183 +S A$_atol$288 Def0126 +S A$_atol$279 Def0114 +S A$_atol$198 Def009B +S A$_atol$379 Def018E +S A$_atol$298 Def012F +S A$_atol$199 Def009C +S XG$atol$0$0 Def019E +S A$_atol$389 Def0197 +S A$_atol$299 Def0130 +S A$_atol$70 Def0009 +S A$_atol$80 Def0017 +S A$_atol$71 Def000B +S A$_atol$90 Def0027 +S A$_atol$81 Def0018 +S A$_atol$72 Def000C +S C$_atol.c$48$1$1 Def019E +S A$_atol$82 Def0019 +S A$_atol$73 Def000E +S A$_atol$92 Def0028 +S A$_atol$83 Def001A +S A$_atol$74 Def000F +S G$atol$0$0 Def0000 +S A$_atol$93 Def002B +S A$_atol$84 Def001B +S A$_atol$75 Def0010 +S A$_atol$66 Def0000 +S A$_atol$94 Def002C +S A$_atol$85 Def001C +S A$_atol$76 Def0012 +S A$_atol$67 Def0002 +S A$_atol$95 Def002D +S A$_atol$86 Def001F +S A$_atol$77 Def0013 +S A$_atol$68 Def0004 +S A$_atol$96 Def002E +S A$_atol$87 Def0020 +S A$_atol$69 Def0006 +S A$_atol$97 Def002F +S A$_atol$88 Def0023 +S A$_atol$79 Def0014 +S A$_atol$98 Def0030 +S A$_atol$89 Def0024 +S A$_atol$99 Def0031 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E4 A3 A3 A3 F0 +R 00 00 00 07 00 09 00 05 +T 00 1C 12 00 00 F0 12 00 00 F0 12 00 00 F0 90 +R 00 00 00 07 02 03 00 01 02 07 00 01 02 0B 00 01 +T 00 29 00 00 E0 FA A3 E0 FB A3 E0 FC +R 00 00 00 07 00 02 00 05 +T 00 33 +R 00 00 00 07 +T 00 33 8A 82 8B 83 8C F0 12 00 00 FD 60 30 +R 00 00 00 07 02 09 00 03 +T 00 3F +R 00 00 00 07 +T 00 3F C3 74 B9 8D F0 63 F0 80 95 F0 40 08 +R 00 00 00 07 +T 00 4B +R 00 00 00 07 +T 00 4B C3 ED 64 80 94 B0 50 1C +R 00 00 00 07 +T 00 53 +R 00 00 00 07 +T 00 53 +R 00 00 00 07 +T 00 53 BD 2D 02 80 17 +R 00 00 00 07 +T 00 58 +R 00 00 00 07 +T 00 58 BD 2B 02 80 12 +R 00 00 00 07 +T 00 5D +R 00 00 00 07 +T 00 5D 0A BA 00 01 0B +R 00 00 00 07 +T 00 62 +R 00 00 00 07 +T 00 62 90 00 00 EA F0 A3 EB F0 A3 EC F0 80 C4 +R 00 00 00 07 00 03 00 05 +T 00 6F +R 00 00 00 07 +T 00 6F 90 00 00 EA F0 A3 EB F0 A3 EC F0 8A 82 8B +R 00 00 00 07 00 03 00 05 +T 00 7D 83 8C F0 12 00 00 FD BD 2D 04 74 01 80 01 +R 00 00 00 07 02 06 00 03 +T 00 8B +R 00 00 00 07 +T 00 8B E4 +R 00 00 00 07 +T 00 8C +R 00 00 00 07 +T 00 8C FE 70 03 +R 00 00 00 07 +T 00 8F +R 00 00 00 07 +T 00 8F BD 2B 0E +R 00 00 00 07 +T 00 92 +R 00 00 00 07 +T 00 92 +R 00 00 00 07 +T 00 92 +R 00 00 00 07 +T 00 92 90 00 00 74 01 2A F0 E4 3B A3 F0 A3 EC F0 +R 00 00 00 07 00 03 00 05 +T 00 A0 +R 00 00 00 07 +T 00 A0 90 00 00 E0 FA A3 E0 FB A3 E0 FC +R 00 00 00 07 00 03 00 05 +T 00 AB +R 00 00 00 07 +T 00 AB 8A 82 8B 83 8C F0 12 00 00 FD 70 03 02 +R 00 00 00 07 02 09 00 03 +T 00 B8 01 5E +R 00 00 00 07 00 02 00 07 +T 00 BA +R 00 00 00 07 +T 00 BA C3 ED 64 80 94 B0 50 03 02 01 5E +R 00 00 00 07 00 0B 00 07 +T 00 C5 +R 00 00 00 07 +T 00 C5 C3 74 B9 8D F0 63 F0 80 95 F0 50 03 02 +R 00 00 00 07 +T 00 D2 01 5E +R 00 00 00 07 00 02 00 07 +T 00 D4 +R 00 00 00 07 +T 00 D4 C0 06 90 00 03 E0 FF A3 E0 F8 A3 E0 F9 A3 +R 00 00 00 07 00 05 00 05 +T 00 E2 E0 FE 90 00 00 E4 A3 A3 A3 F0 12 00 00 F0 +R 00 00 00 07 02 05 00 00 02 0D 00 01 +T 00 F0 12 00 00 F0 12 00 00 74 0A F0 C0 02 C0 03 +R 00 00 00 07 02 03 00 01 02 07 00 01 +T 00 FE C0 04 C0 05 C0 06 8F 82 88 83 89 F0 EE 12 +R 00 00 00 07 +T 01 0C 00 00 85 82 00 00 85 83 00 01 85 F0 +R 00 00 00 07 02 02 00 02 29 06 00 01 29 0A 00 01 +T 01 16 00 02 F5 00 03 D0 06 D0 05 D0 04 D0 03 D0 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 01 22 02 ED 24 D0 FD E4 34 FF FE E4 34 FF FF E4 +R 00 00 00 07 +T 01 30 34 FF F8 90 00 03 ED 25 00 00 F0 EE 35 +R 00 00 00 07 00 06 00 05 29 0A 00 01 +T 01 3C 00 01 A3 F0 EF 35 00 02 A3 F0 E8 35 00 03 +R 00 00 00 07 29 02 00 01 29 08 00 01 29 0E 00 01 +T 01 47 A3 F0 0A BA 00 01 0B +R 00 00 00 07 +T 01 4E +R 00 00 00 07 +T 01 4E 90 00 00 EA F0 A3 EB F0 A3 EC F0 D0 06 02 +R 00 00 00 07 00 03 00 05 +T 01 5C 00 AB +R 00 00 00 07 00 02 00 07 +T 01 5E +R 00 00 00 07 +T 01 5E 90 00 00 EA F0 A3 EB F0 A3 EC F0 EE 60 1D +R 00 00 00 07 00 03 00 05 +T 01 6C +R 00 00 00 07 +T 01 6C 90 00 03 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 01 7A C3 E4 9A FA E4 9B FB E4 9C FC E4 9D FD 80 +R 00 00 00 07 +T 01 88 0E +R 00 00 00 07 +T 01 89 +R 00 00 00 07 +T 01 89 90 00 03 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 01 97 +R 00 00 00 07 +T 01 97 8A 82 8B 83 8C F0 ED +R 00 00 00 07 +T 01 9E +R 00 00 00 07 +T 01 9E 22 +R 00 00 00 07 diff --git a/device/lib/large/_autobaud.asm b/device/lib/large/_autobaud.asm new file mode 100644 index 00000000..89a212c4 --- /dev/null +++ b/device/lib/large/_autobaud.asm @@ -0,0 +1,325 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + +;-------------------------------------------------------- + .module _autobaud +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _autobaud +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$autobaud$0$0 ==. +; _autobaud.c 52 +; ----------------------------------------- +; function autobaud +; ----------------------------------------- +_autobaud: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _autobaud.c 56 + mov _TMOD,#0x11 +; _autobaud.c 57 + mov _TCON,#0x00 +; _autobaud.c 58 + mov _TL1,#0x00 + mov _TH1,#0x00 +; _autobaud.c 62 +00101$: +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00142$: +; _autobaud.c 66 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00143$: +; _autobaud.c 67 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00144$: +; _autobaud.c 68 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00145$: +; _autobaud.c 69 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00146$: +; _autobaud.c 72 +00113$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _RXD,00113$ +00147$: +; _autobaud.c 73 + setb _TR1 +; _autobaud.c 74 +00116$: +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00116$ +00148$: +; _autobaud.c 75 +00119$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _RXD,00119$ +00149$: +; _autobaud.c 76 +00122$: +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00122$ +00150$: +; _autobaud.c 77 +00125$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _RXD,00125$ +00151$: +; _autobaud.c 78 + clr _TR1 +; _autobaud.c 81 + mov a,_TH1 + add a,acc + mov r2,a + mov a,_TL1 + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r3,a + orl a,r2 +; _autobaud.c 84 +; Peephole 105 removed redundant mov + mov _TH1,a + add a,acc + mov r2,a + mov a,_TL1 + rl a + rl a +; Peephole 139 removed redundant mov +; Peephole 183 avoided anl during execution + anl a,#(0x03 & 0x01) + mov r3,a + orl a,r2 +; _autobaud.c 87 +; Peephole 105 removed redundant mov +; Peephole 184 removed redundant mov + cpl a +; _autobaud.c 90 +; Peephole 185 changed order of increment (acc incremented also!) + inc a + mov _TH1,a +; _autobaud.c 92 + mov _TL1,_TH1 +; _autobaud.c 93 + mov _TMOD,#0x21 +; _autobaud.c 94 + mov _PCON,#0x80 +; _autobaud.c 95 + mov _SCON,#0x52 +00128$: + C$_autobaud.c$96$1$1 ==. + XG$autobaud$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_autobaud.cdb b/device/lib/large/_autobaud.cdb new file mode 100644 index 00000000..f63b4c24 --- /dev/null +++ b/device/lib/large/_autobaud.cdb @@ -0,0 +1,85 @@ +M:_autobaud +F:G$autobaud$0$0({2}DF,SV:S),C,0,0,0,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/large/_autobaud.rel b/device/lib/large/_autobaud.rel new file mode 100644 index 00000000..7901545c --- /dev/null +++ b/device/lib/large/_autobaud.rel @@ -0,0 +1,210 @@ +;!FILE _autobaud.asm +XH +H 8 areas 80 global symbols +M _autobaud +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 58 flags 20 +S A$_autobaud$298 Def0041 +S XG$autobaud$0$0 Def0057 +S A$_autobaud$299 Def0042 +S G$autobaud$0$0 Def0000 +S C$_autobaud.c$96$1$1 Def0057 +S A$_autobaud$320 Def0054 +S A$_autobaud$311 Def0048 +S A$_autobaud$302 Def0043 +S A$_autobaud$230 Def0006 +S A$_autobaud$312 Def0049 +S A$_autobaud$303 Def0045 +S A$_autobaud$231 Def0009 +S A$_autobaud$304 Def0046 +S _autobaud Def0000 +S A$_autobaud$314 Def004B +S A$_autobaud$251 Def0018 +S A$_autobaud$324 Def0057 +S A$_autobaud$243 Def0012 +S A$_autobaud$316 Def004E +S A$_autobaud$235 Def000C +S A$_autobaud$226 Def0000 +S A$_autobaud$308 Def0047 +S A$_autobaud$290 Def0038 +S A$_autobaud$281 Def002C +S A$_autobaud$263 Def0020 +S A$_autobaud$318 Def0051 +S A$_autobaud$291 Def0039 +S A$_autobaud$273 Def0026 +S A$_autobaud$228 Def0003 +S A$_autobaud$283 Def002E +S A$_autobaud$256 Def001B +S A$_autobaud$247 Def0015 +S A$_autobaud$284 Def0030 +S A$_autobaud$239 Def000F +S A$_autobaud$294 Def003A +S A$_autobaud$285 Def0032 +S A$_autobaud$295 Def003C +S A$_autobaud$286 Def0033 +S A$_autobaud$268 Def0023 +S A$_autobaud$259 Def001E +S A$_autobaud$296 Def003E +S A$_autobaud$287 Def0035 +S A$_autobaud$278 Def0029 +S A$_autobaud$297 Def003F +S A$_autobaud$288 Def0036 +T 00 00 +R 00 00 00 07 +T 00 00 75 89 11 75 88 00 75 8B 00 75 8D 00 +R 00 00 00 07 +T 00 0C +R 00 00 00 07 +T 00 0C 20 B0 FD +R 00 00 00 07 +T 00 0F +R 00 00 00 07 +T 00 0F 20 B0 FA +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 20 B0 F7 +R 00 00 00 07 +T 00 15 +R 00 00 00 07 +T 00 15 20 B0 F4 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 20 B0 F1 +R 00 00 00 07 +T 00 1B +R 00 00 00 07 +T 00 1B +R 00 00 00 07 +T 00 1B 30 B0 FD +R 00 00 00 07 +T 00 1E +R 00 00 00 07 +T 00 1E D2 8E +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 20 B0 FD +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 30 B0 FD +R 00 00 00 07 +T 00 26 +R 00 00 00 07 +T 00 26 +R 00 00 00 07 +T 00 26 20 B0 FD +R 00 00 00 07 +T 00 29 +R 00 00 00 07 +T 00 29 +R 00 00 00 07 +T 00 29 30 B0 FD +R 00 00 00 07 +T 00 2C +R 00 00 00 07 +T 00 2C C2 8E E5 8D 25 E0 FA E5 8B 23 54 01 FB 4A +R 00 00 00 07 +T 00 3A F5 8D 25 E0 FA E5 8B 23 23 54 01 FB 4A F4 +R 00 00 00 07 +T 00 48 04 F5 8D 85 8D 8B 75 89 21 75 87 80 75 98 +R 00 00 00 07 +T 00 56 52 +R 00 00 00 07 +T 00 57 +R 00 00 00 07 +T 00 57 22 +R 00 00 00 07 diff --git a/device/lib/large/_bp.asm b/device/lib/large/_bp.asm new file mode 100644 index 00000000..8ae0d658 --- /dev/null +++ b/device/lib/large/_bp.asm @@ -0,0 +1,48 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + +;-------------------------------------------------------- + .module _bp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _bp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +G$bp$0$0==. +_bp: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + .area CSEG (CODE) diff --git a/device/lib/large/_bp.cdb b/device/lib/large/_bp.cdb new file mode 100644 index 00000000..ffe2abde --- /dev/null +++ b/device/lib/large/_bp.cdb @@ -0,0 +1,2 @@ +M:_bp +S:G$bp$0$0({1}SC:U),E,0,0 diff --git a/device/lib/large/_bp.rel b/device/lib/large/_bp.rel new file mode 100644 index 00000000..837e0a53 --- /dev/null +++ b/device/lib/large/_bp.rel @@ -0,0 +1,17 @@ +XH +H 8 areas 2 global symbols +M _bp +A _CODE size 0 flags 0 +A DSEG size 1 flags 0 +S G$bp$0$0 Def0000 +S _bp Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 0 flags 20 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 diff --git a/device/lib/large/_char2fs.asm b/device/lib/large/_char2fs.asm new file mode 100644 index 00000000..7a3a2228 --- /dev/null +++ b/device/lib/large/_char2fs.asm @@ -0,0 +1,334 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + +;-------------------------------------------------------- + .module _char2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___char2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___char2fs_sloc0_1_0: + .ds 0x0002 +___char2fs_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___char2fs_a_1_1: + .ds 0x0001 +___char2fs_sign_1_1: + .ds 0x0004 +___char2fs_fl_1_1: + .ds 0x0004 +___char2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__char2fs$0$0 ==. +; _char2fs.c 80 +; ----------------------------------------- +; function __char2fs +; ----------------------------------------- +___char2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _char2fs.c 109 + push dpl + mov dptr,#___char2fs_a_1_1 + pop acc + movx @dptr,a +; _char2fs.c 82 + mov dptr,#___char2fs_sign_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _char2fs.c 85 + mov dptr,#___char2fs_a_1_1 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + rlc a + subb a,acc + mov r3,a + mov r4,a + mov r5,a + mov dptr,#___char2fs_a1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _char2fs.c 87 + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _char2fs.c 89 + mov dptr,#(___char2fs_fl_1_1) +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; _char2fs.c 90 + mov dptr,#(___char2fs_fl_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r6 + mov dph,r7 + mov b,r0 + ljmp 00108$ +00102$: +; _char2fs.c 93 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _char2fs.c 95 + mov dptr,#___char2fs_sign_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x80 + movx @dptr,a +; _char2fs.c 96 + mov dptr,#___char2fs_a1_1_1 + clr c + clr a + subb a,r2 + movx @dptr,a + clr a + subb a,r3 + inc dptr + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a +; _char2fs.c 99 +00113$: + clr a + mov (___char2fs_sloc0_1_0 + 1),a + mov ___char2fs_sloc0_1_0,#0x96 +00105$: + mov dptr,#___char2fs_a1_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r4 + subb a,#0x00 + mov a,r5 + subb a,#0x00 + mov a,r6 + subb a,#0x80 + mov a,r7 + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _char2fs.c 101 + mov a,r4 + add a,acc + mov r0,a + mov a,r5 + rlc a + mov r1,a + mov a,r6 + rlc a + mov r2,a + mov a,r7 + rlc a + mov r3,a + mov dptr,#___char2fs_a1_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _char2fs.c 102 + dec ___char2fs_sloc0_1_0 + mov a,#0xff + cjne a,___char2fs_sloc0_1_0,00117$ + dec (___char2fs_sloc0_1_0 + 1) +00117$: + ljmp 00105$ +00107$: +; _char2fs.c 105 + anl ar6,#0x7f +; _char2fs.c 107 + mov r2,___char2fs_sloc0_1_0 + mov r3,(___char2fs_sloc0_1_0 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___char2fs_sloc1_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___char2fs_sloc1_1_0 + 2) + rrc a + xch a,(___char2fs_sloc1_1_0 + 2) + rrc a + xch a,(___char2fs_sloc1_1_0 + 2) + mov (___char2fs_sloc1_1_0 + 3),a + mov (___char2fs_sloc1_1_0 + 1),#0x00 + mov ___char2fs_sloc1_1_0,#0x00 + mov dptr,#___char2fs_sign_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,___char2fs_sloc1_1_0 + orl ar2,a + mov a,(___char2fs_sloc1_1_0 + 1) + orl ar3,a + mov a,(___char2fs_sloc1_1_0 + 2) + orl ar0,a + mov a,(___char2fs_sloc1_1_0 + 3) + orl ar1,a + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov dptr,#(___char2fs_fl_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _char2fs.c 109 + mov dptr,#(___char2fs_fl_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00108$: + C$_char2fs.c$110$1$1 ==. + XG$__char2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_char2fs.cdb b/device/lib/large/_char2fs.cdb new file mode 100644 index 00000000..dd997178 --- /dev/null +++ b/device/lib/large/_char2fs.cdb @@ -0,0 +1,2 @@ +M:_char2fs +F:G$__char2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_char2fs.rel b/device/lib/large/_char2fs.rel new file mode 100644 index 00000000..a3cc804a --- /dev/null +++ b/device/lib/large/_char2fs.rel @@ -0,0 +1,345 @@ +;!FILE _char2fs.asm +XH +H 8 areas E5 global symbols +M _char2fs +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size D flags 40 +A GSINIT size 0 flags 20 +A CSEG size 13C flags 20 +S C$_char2fs.c$110$1$1 Def013B +S A$_char2fs$100 Def002A +S A$_char2fs$200 Def008E +S A$_char2fs$110 Def0034 +S A$_char2fs$101 Def002B +S A$_char2fs$300 Def0117 +S A$_char2fs$210 Def0098 +S A$_char2fs$201 Def008F +S A$_char2fs$120 Def003B +S A$_char2fs$102 Def002C +S A$_char2fs$310 Def0124 +S A$_char2fs$301 Def0119 +S A$_char2fs$211 Def0099 +S A$_char2fs$202 Def0090 +S A$_char2fs$130 Def0043 +S A$_char2fs$112 Def0035 +S A$_char2fs$103 Def002D +S A$_char2fs$320 Def012F +S A$_char2fs$311 Def0125 +S A$_char2fs$302 Def011C +S A$_char2fs$230 Def00AF +S A$_char2fs$212 Def009B +S A$_char2fs$203 Def0091 +S A$_char2fs$140 Def004E +S A$_char2fs$131 Def0044 +S A$_char2fs$113 Def0036 +S A$_char2fs$104 Def002E +S ___char2fs Def0000 +S A$_char2fs$321 Def0130 +S A$_char2fs$312 Def0126 +S A$_char2fs$303 Def011D +S A$_char2fs$240 Def00BB +S A$_char2fs$231 Def00B0 +S A$_char2fs$222 Def00A6 +S A$_char2fs$213 Def009C +S A$_char2fs$204 Def0092 +S A$_char2fs$150 Def0059 +S A$_char2fs$141 Def004F +S A$_char2fs$132 Def0045 +S A$_char2fs$123 Def003E +S A$_char2fs$114 Def0037 +S A$_char2fs$105 Def002F +S A$_char2fs$322 Def0131 +S A$_char2fs$304 Def011E +S A$_char2fs$250 Def00C8 +S A$_char2fs$241 Def00BC +S A$_char2fs$232 Def00B1 +S A$_char2fs$223 Def00A7 +S A$_char2fs$214 Def009E +S A$_char2fs$205 Def0093 +S A$_char2fs$151 Def005B +S A$_char2fs$142 Def0050 +S A$_char2fs$133 Def0046 +S A$_char2fs$124 Def003F +S A$_char2fs$115 Def0038 +S A$_char2fs$106 Def0030 +S A$_char2fs$323 Def0132 +S A$_char2fs$314 Def0127 +S A$_char2fs$305 Def011F +S A$_char2fs$260 Def00D6 +S A$_char2fs$242 Def00BD +S A$_char2fs$233 Def00B2 +S A$_char2fs$224 Def00A9 +S A$_char2fs$215 Def009F +S A$_char2fs$206 Def0094 +S A$_char2fs$170 Def006C +S A$_char2fs$143 Def0051 +S A$_char2fs$125 Def0040 +S A$_char2fs$107 Def0031 +S A$_char2fs$333 Def013B +S A$_char2fs$324 Def0133 +S A$_char2fs$315 Def012A +S A$_char2fs$306 Def0120 +S A$_char2fs$270 Def00E7 +S A$_char2fs$261 Def00D8 +S A$_char2fs$252 Def00CA +S A$_char2fs$243 Def00BE +S A$_char2fs$234 Def00B3 +S A$_char2fs$225 Def00AA +S A$_char2fs$216 Def00A1 +S A$_char2fs$207 Def0095 +S A$_char2fs$180 Def0078 +S A$_char2fs$171 Def006D +S A$_char2fs$162 Def0065 +S A$_char2fs$144 Def0052 +S A$_char2fs$135 Def0047 +S A$_char2fs$126 Def0041 +S A$_char2fs$117 Def0039 +S A$_char2fs$108 Def0032 +S A$_char2fs$316 Def012B +S A$_char2fs$307 Def0121 +S A$_char2fs$280 Def00F8 +S A$_char2fs$271 Def00E9 +S A$_char2fs$262 Def00DA +S A$_char2fs$244 Def00BF +S A$_char2fs$235 Def00B6 +S A$_char2fs$226 Def00AB +S A$_char2fs$217 Def00A2 +S A$_char2fs$208 Def0096 +S A$_char2fs$190 Def0082 +S A$_char2fs$181 Def0079 +S A$_char2fs$172 Def006F +S A$_char2fs$163 Def0066 +S A$_char2fs$154 Def005E +S A$_char2fs$145 Def0053 +S A$_char2fs$136 Def004A +S A$_char2fs$127 Def0042 +S A$_char2fs$109 Def0033 +S A$_char2fs$326 Def0134 +S A$_char2fs$317 Def012C +S A$_char2fs$308 Def0122 +S A$_char2fs$290 Def0107 +S A$_char2fs$281 Def00F9 +S A$_char2fs$272 Def00EC +S A$_char2fs$263 Def00DB +S A$_char2fs$245 Def00C0 +S A$_char2fs$236 Def00B7 +S A$_char2fs$227 Def00AC +S A$_char2fs$209 Def0097 +S A$_char2fs$182 Def007A +S A$_char2fs$164 Def0067 +S A$_char2fs$137 Def004B +S A$_char2fs$327 Def0135 +S A$_char2fs$318 Def012D +S A$_char2fs$309 Def0123 +S A$_char2fs$291 Def0109 +S A$_char2fs$282 Def00FA +S A$_char2fs$273 Def00EF +S A$_char2fs$264 Def00DD +S A$_char2fs$255 Def00CD +S A$_char2fs$237 Def00B8 +S A$_char2fs$228 Def00AD +S A$_char2fs$219 Def00A4 +S A$_char2fs$183 Def007B +S A$_char2fs$174 Def0070 +S A$_char2fs$165 Def0068 +S A$_char2fs$156 Def005F +S A$_char2fs$147 Def0054 +S A$_char2fs$138 Def004C +S A$_char2fs$328 Def0137 +S A$_char2fs$319 Def012E +S A$_char2fs$292 Def010B +S A$_char2fs$283 Def00FB +S A$_char2fs$274 Def00F2 +S A$_char2fs$265 Def00DF +S A$_char2fs$247 Def00C1 +S A$_char2fs$238 Def00B9 +S A$_char2fs$229 Def00AE +S A$_char2fs$193 Def0083 +S A$_char2fs$184 Def007C +S A$_char2fs$175 Def0073 +S A$_char2fs$166 Def0069 +S A$_char2fs$148 Def0055 +S A$_char2fs$139 Def004D +S A$_char2fs$329 Def0139 +S A$_char2fs$293 Def010D +S A$_char2fs$284 Def00FC +S A$_char2fs$275 Def00F3 +S A$_char2fs$266 Def00E1 +S A$_char2fs$257 Def00D0 +S A$_char2fs$248 Def00C3 +S A$_char2fs$239 Def00BA +S A$_char2fs$194 Def0084 +S A$_char2fs$185 Def007D +S A$_char2fs$176 Def0074 +S A$_char2fs$149 Def0057 +S A$_char2fs$294 Def010E +S A$_char2fs$285 Def00FD +S A$_char2fs$276 Def00F4 +S A$_char2fs$267 Def00E2 +S A$_char2fs$258 Def00D2 +S A$_char2fs$249 Def00C5 +S A$_char2fs$195 Def0086 +S A$_char2fs$186 Def007E +S A$_char2fs$177 Def0075 +S A$_char2fs$168 Def006A +S A$_char2fs$159 Def0062 +S A$_char2fs$295 Def0110 +S A$_char2fs$286 Def00FF +S A$_char2fs$277 Def00F5 +S A$_char2fs$268 Def00E4 +S A$_char2fs$259 Def00D4 +S A$_char2fs$187 Def007F +S A$_char2fs$178 Def0076 +S A$_char2fs$169 Def006B +S A$_char2fs$296 Def0111 +S A$_char2fs$287 Def0101 +S A$_char2fs$278 Def00F6 +S A$_char2fs$269 Def00E5 +S A$_char2fs$197 Def0089 +S A$_char2fs$188 Def0080 +S A$_char2fs$179 Def0077 +S XG$__char2fs$0$0 Def013B +S A$_char2fs$297 Def0113 +S A$_char2fs$288 Def0103 +S A$_char2fs$279 Def00F7 +S A$_char2fs$198 Def008C +S A$_char2fs$189 Def0081 +S A$_char2fs$298 Def0114 +S A$_char2fs$289 Def0105 +S A$_char2fs$199 Def008D +S A$_char2fs$299 Def0116 +S A$_char2fs$80 Def000D +S A$_char2fs$90 Def001C +S A$_char2fs$81 Def000E +S A$_char2fs$72 Def0000 +S G$__char2fs$0$0 Def0000 +S A$_char2fs$91 Def001F +S A$_char2fs$82 Def000F +S A$_char2fs$73 Def0002 +S A$_char2fs$83 Def0010 +S A$_char2fs$74 Def0005 +S A$_char2fs$93 Def0020 +S A$_char2fs$84 Def0013 +S A$_char2fs$75 Def0007 +S A$_char2fs$94 Def0021 +S A$_char2fs$85 Def0014 +S A$_char2fs$95 Def0022 +S A$_char2fs$86 Def0017 +S A$_char2fs$77 Def0008 +S A$_char2fs$96 Def0024 +S A$_char2fs$87 Def0018 +S A$_char2fs$78 Def000B +S A$_char2fs$97 Def0025 +S A$_char2fs$88 Def001B +S A$_char2fs$79 Def000C +S A$_char2fs$98 Def0026 +S A$_char2fs$99 Def0027 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 01 E4 A3 A3 +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E A3 F0 12 00 00 F0 12 00 00 F0 12 00 00 F0 +R 00 00 00 07 02 05 00 00 02 09 00 00 02 0D 00 00 +T 00 1C 90 00 00 E0 FA 33 95 E0 FB FC FD 90 00 09 +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 00 2A EA F0 A3 EB F0 A3 EC F0 A3 ED F0 EA 4B 4C +R 00 00 00 07 +T 00 38 4D 70 23 +R 00 00 00 07 +T 00 3B +R 00 00 00 07 +T 00 3B 90 00 05 E4 F0 A3 F0 A3 E4 F0 A3 F0 90 +R 00 00 00 07 00 03 00 05 +T 00 48 00 05 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 8E +R 00 00 00 07 00 02 00 05 +T 00 56 82 8F 83 88 F0 02 01 3B +R 00 00 00 07 00 08 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E ED 30 E7 21 +R 00 00 00 07 +T 00 62 +R 00 00 00 07 +T 00 62 90 00 01 E4 F0 A3 F0 A3 E4 F0 A3 74 80 F0 +R 00 00 00 07 00 03 00 05 +T 00 70 90 00 09 C3 E4 9A F0 E4 9B A3 F0 E4 9C A3 +R 00 00 00 07 00 03 00 05 +T 00 7E F0 E4 9D A3 F0 +R 00 00 00 07 +T 00 83 +R 00 00 00 07 +T 00 83 E4 F5 00 01 75 00 00 96 +R 00 00 00 07 29 04 00 01 29 07 00 01 +T 00 89 +R 00 00 00 07 +T 00 89 90 00 09 E0 FC A3 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 97 C3 EC 94 00 ED 94 00 EE 94 80 EF 94 00 50 +R 00 00 00 07 +T 00 A5 27 +R 00 00 00 07 +T 00 A6 +R 00 00 00 07 +T 00 A6 EC 25 E0 F8 ED 33 F9 EE 33 FA EF 33 FB 90 +R 00 00 00 07 +T 00 B4 00 09 E8 F0 A3 E9 F0 A3 EA F0 A3 EB F0 15 +R 00 00 00 07 00 02 00 05 +T 00 C2 00 00 74 FF B5 00 00 02 15 00 01 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 00 CA +R 00 00 00 07 +T 00 CA 02 00 89 +R 00 00 00 07 00 03 00 07 +T 00 CD +R 00 00 00 07 +T 00 CD 53 06 7F AA 00 00 AB 00 01 78 00 79 00 8A +R 00 00 00 07 29 06 00 01 29 09 00 01 +T 00 D9 00 04 EB 54 01 A2 E0 C5 00 04 13 C5 00 04 +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 00 E4 13 C5 00 04 F5 00 05 75 00 03 00 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 00 ED 00 02 00 90 00 01 E0 FA A3 E0 FB A3 E0 F8 +R 00 00 00 07 29 02 00 01 00 06 00 05 +T 00 FA A3 E0 F9 E5 00 02 42 02 E5 00 03 42 03 E5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 01 06 00 04 42 00 E5 00 05 42 01 EA 42 04 EB 42 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 01 12 05 E8 42 06 E9 42 07 90 00 05 EC F0 A3 ED +R 00 00 00 07 00 0A 00 05 +T 01 20 F0 A3 EE F0 A3 EF F0 90 00 05 E0 FA A3 E0 +R 00 00 00 07 00 0A 00 05 +T 01 2E FB A3 E0 FC A3 E0 FD 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 3B +R 00 00 00 07 +T 01 3B 22 +R 00 00 00 07 diff --git a/device/lib/large/_decdptr.asm b/device/lib/large/_decdptr.asm new file mode 100644 index 00000000..7f3a9424 --- /dev/null +++ b/device/lib/large/_decdptr.asm @@ -0,0 +1,70 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:22 2000 + +;-------------------------------------------------------- + .module _decdptr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __decdptr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_decdptr$0$0 ==. +; _decdptr.c 26 +; ----------------------------------------- +; function _decdptr +; ----------------------------------------- +__decdptr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _decdptr.c 35 + xch a,dpl + jnz 00001$ + dec dph +00001$: + dec a + xch a,dpl +00101$: + C$_decdptr.c$36$1$1 ==. + XG$_decdptr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_decdptr.cdb b/device/lib/large/_decdptr.cdb new file mode 100644 index 00000000..da3898b4 --- /dev/null +++ b/device/lib/large/_decdptr.cdb @@ -0,0 +1,2 @@ +M:_decdptr +F:G$_decdptr$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/large/_decdptr.rel b/device/lib/large/_decdptr.rel new file mode 100644 index 00000000..81a3dfb2 --- /dev/null +++ b/device/lib/large/_decdptr.rel @@ -0,0 +1,34 @@ +;!FILE _decdptr.asm +XH +H 8 areas A global symbols +M _decdptr +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size A flags 20 +S A$_decdptr$60 Def0000 +S C$_decdptr.c$36$1$1 Def0009 +S A$_decdptr$61 Def0002 +S A$_decdptr$62 Def0004 +S A$_decdptr$64 Def0006 +S A$_decdptr$65 Def0007 +S A$_decdptr$69 Def0009 +S __decdptr Def0000 +S XG$_decdptr$0$0 Def0009 +S G$_decdptr$0$0 Def0000 +T 00 00 +R 00 00 00 07 +T 00 00 C5 82 70 02 15 83 +R 00 00 00 07 +T 00 06 +R 00 00 00 07 +T 00 06 14 C5 82 +R 00 00 00 07 +T 00 09 +R 00 00 00 07 +T 00 09 22 +R 00 00 00 07 diff --git a/device/lib/large/_divsint.asm b/device/lib/large/_divsint.asm new file mode 100644 index 00000000..3b0eab9d --- /dev/null +++ b/device/lib/large/_divsint.asm @@ -0,0 +1,180 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + +;-------------------------------------------------------- + .module _divsint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divsint_PARM_2 + .globl __divsint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__divsint_PARM_2: + .ds 0x0002 +__divsint_a_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divsint$0$0 ==. +; _divsint.c 26 +; ----------------------------------------- +; function _divsint +; ----------------------------------------- +__divsint: + clr ea + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divsint.c 0 + push dph + push dpl + mov dptr,#__divsint_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _divsint.c 33 + mov dptr,#__divsint_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00113$: + clr c + clr a + subb a,r2 + mov r4,a + clr a + subb a,r3 + mov r5,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar4,r2 + mov ar5,r3 +00107$: + mov ar2,r4 + mov ar3,r5 +; _divsint.c 34 + mov dptr,#__divsint_PARM_2 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,r4 + mov r7,a + clr a + subb a,r5 + mov r0,a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov ar7,r4 + mov ar0,r5 +00109$: + mov dptr,#__divuint_PARM_2 + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + push ar6 + mov dpl,r2 + mov dph,r3 + lcall __divuint + mov r2,dpl + mov r3,dph + pop ar6 +; _divsint.c 35 + mov dptr,#__divsint_a_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a + mov r4,a + mov a,r6 + xrl a,ar4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _divsint.c 37 + clr c + clr a + subb a,r2 + mov r4,a + clr a + subb a,r3 + mov r6,a + mov dpl,r4 + mov dph,r6 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _divsint.c 41 + mov dpl,r2 + mov dph,r3 +00104$: + setb ea + C$_divsint.c$43$1$1 ==. + XG$_divsint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_divsint.cdb b/device/lib/large/_divsint.cdb new file mode 100644 index 00000000..24d9d316 --- /dev/null +++ b/device/lib/large/_divsint.cdb @@ -0,0 +1,2 @@ +M:_divsint +F:G$_divsint$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_divsint.rel b/device/lib/large/_divsint.rel new file mode 100644 index 00000000..8024bf40 --- /dev/null +++ b/device/lib/large/_divsint.rel @@ -0,0 +1,164 @@ +;!FILE _divsint.asm +XH +H 8 areas 60 global symbols +M _divsint +S __divuint Ref0000 +S __divuint_PARM_2 Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 4 flags 40 +S __divsint_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 83 flags 20 +S XG$_divsint$0$0 Def0082 +S G$_divsint$0$0 Def0000 +S A$_divsint$110 Def0036 +S A$_divsint$101 Def002C +S A$_divsint$120 Def003E +S A$_divsint$102 Def002F +S A$_divsint$130 Def004A +S A$_divsint$121 Def003F +S A$_divsint$112 Def0037 +S A$_divsint$103 Def0030 +S A$_divsint$140 Def005A +S A$_divsint$131 Def004B +S A$_divsint$122 Def0040 +S A$_divsint$104 Def0031 +S A$_divsint$150 Def0066 +S A$_divsint$141 Def005C +S A$_divsint$132 Def004C +S A$_divsint$114 Def0038 +S A$_divsint$105 Def0032 +S A$_divsint$160 Def006F +S A$_divsint$151 Def0067 +S A$_divsint$133 Def004D +S A$_divsint$124 Def0041 +S A$_divsint$170 Def007A +S A$_divsint$161 Def0070 +S A$_divsint$152 Def0068 +S A$_divsint$143 Def005E +S A$_divsint$134 Def004E +S A$_divsint$116 Def003A +S A$_divsint$107 Def0033 +S A$_divsint$162 Def0071 +S A$_divsint$153 Def0069 +S A$_divsint$144 Def0061 +S A$_divsint$135 Def004F +S A$_divsint$126 Def0043 +S A$_divsint$117 Def003B +S A$_divsint$108 Def0034 +S A$_divsint$163 Def0072 +S A$_divsint$154 Def006A +S A$_divsint$145 Def0062 +S A$_divsint$136 Def0051 +S A$_divsint$127 Def0045 +S A$_divsint$118 Def003C +S A$_divsint$109 Def0035 +S A$_divsint$173 Def007C +S A$_divsint$164 Def0073 +S A$_divsint$155 Def006B +S A$_divsint$146 Def0063 +S A$_divsint$137 Def0053 +S A$_divsint$119 Def003D +S A$_divsint$174 Def007E +S A$_divsint$165 Def0074 +S A$_divsint$147 Def0064 +S A$_divsint$138 Def0055 +S A$_divsint$129 Def0047 +S A$_divsint$166 Def0075 +S A$_divsint$157 Def006D +S A$_divsint$139 Def0058 +S A$_divsint$176 Def0080 +S A$_divsint$167 Def0076 +S A$_divsint$149 Def0065 +S A$_divsint$168 Def0078 +S A$_divsint$179 Def0082 +S C$_divsint.c$43$1$1 Def0082 +S A$_divsint$70 Def000B +S A$_divsint$71 Def000C +S A$_divsint$90 Def0020 +S A$_divsint$81 Def0017 +S A$_divsint$72 Def000E +S A$_divsint$91 Def0021 +S A$_divsint$73 Def000F +S A$_divsint$83 Def0018 +S A$_divsint$56 Def0000 +S A$_divsint$93 Def0022 +S A$_divsint$75 Def0010 +S A$_divsint$66 Def0002 +S A$_divsint$85 Def001B +S A$_divsint$76 Def0013 +S A$_divsint$67 Def0004 +S A$_divsint$95 Def0024 +S A$_divsint$86 Def001C +S A$_divsint$77 Def0014 +S A$_divsint$68 Def0006 +S A$_divsint$96 Def0026 +S A$_divsint$87 Def001D +S A$_divsint$78 Def0015 +S A$_divsint$69 Def0009 +S A$_divsint$88 Def001E +S A$_divsint$79 Def0016 +S A$_divsint$98 Def0028 +S A$_divsint$89 Def001F +S A$_divsint$99 Def002A +S __divsint Def0000 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C2 AF C0 83 C0 82 90 00 02 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 90 00 02 E0 FA A3 E0 FB 30 E7 09 +R 00 00 00 07 00 05 00 05 +T 00 1B +R 00 00 00 07 +T 00 1B C3 E4 9A FC E4 9B FD 80 04 +R 00 00 00 07 +T 00 24 +R 00 00 00 07 +T 00 24 8A 04 8B 05 +R 00 00 00 07 +T 00 28 +R 00 00 00 07 +T 00 28 8C 02 8D 03 90 00 00 E0 FC A3 E0 FD 33 E4 +R 00 00 00 07 00 07 00 05 +T 00 36 33 FE 60 09 +R 00 00 00 07 +T 00 3A +R 00 00 00 07 +T 00 3A C3 E4 9C FF E4 9D F8 80 04 +R 00 00 00 07 +T 00 43 +R 00 00 00 07 +T 00 43 8C 07 8D 00 +R 00 00 00 07 +T 00 47 +R 00 00 00 07 +T 00 47 90 00 00 EF F0 A3 E8 F0 C0 06 8A 82 8B 83 +R 00 00 00 07 02 03 00 01 +T 00 55 12 00 00 AA 82 AB 83 D0 06 90 00 02 E0 FC +R 00 00 00 07 02 03 00 00 00 0C 00 05 +T 00 63 A3 E0 FD 33 E4 33 FC EE 65 04 60 0D +R 00 00 00 07 +T 00 6F +R 00 00 00 07 +T 00 6F C3 E4 9A FC E4 9B FE 8C 82 8E 83 80 04 +R 00 00 00 07 +T 00 7C +R 00 00 00 07 +T 00 7C 8A 82 8B 83 +R 00 00 00 07 +T 00 80 +R 00 00 00 07 +T 00 80 D2 AF 22 +R 00 00 00 07 diff --git a/device/lib/large/_divslong.asm b/device/lib/large/_divslong.asm new file mode 100644 index 00000000..7c0503e9 --- /dev/null +++ b/device/lib/large/_divslong.asm @@ -0,0 +1,254 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + +;-------------------------------------------------------- + .module _divslong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divslong_PARM_2 + .globl __divslong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__divslong_sloc0_1_0: + .ds 0x0004 +__divslong_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__divslong_PARM_2: + .ds 0x0004 +__divslong_a_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divslong$0$0 ==. +; _divslong.c 25 +; ----------------------------------------- +; function _divslong +; ----------------------------------------- +__divslong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divslong.c 0 + push acc + push b + push dph + push dpl + mov dptr,#__divslong_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _divslong.c 29 + mov dptr,#__divslong_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00113$: + clr c + clr a + subb a,r2 + mov r6,a + clr a + subb a,r3 + mov r7,a + clr a + subb a,r4 + mov r0,a + clr a + subb a,r5 + mov r1,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar6,r2 + mov ar7,r3 + mov ar0,r4 + mov ar1,r5 +00107$: + mov __divslong_sloc0_1_0,r6 + mov (__divslong_sloc0_1_0 + 1),r7 + mov (__divslong_sloc0_1_0 + 2),r0 + mov (__divslong_sloc0_1_0 + 3),r1 +; _divslong.c 30 + mov dptr,#__divslong_PARM_2 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r1,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,r6 + mov __divslong_sloc1_1_0,a + clr a + subb a,r7 + mov (__divslong_sloc1_1_0 + 1),a + clr a + subb a,r0 + mov (__divslong_sloc1_1_0 + 2),a + clr a + subb a,r1 + mov (__divslong_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov __divslong_sloc1_1_0,r6 + mov (__divslong_sloc1_1_0 + 1),r7 + mov (__divslong_sloc1_1_0 + 2),r0 + mov (__divslong_sloc1_1_0 + 3),r1 +00109$: + mov dptr,#__divulong_PARM_2 + mov a,__divslong_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(__divslong_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(__divslong_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(__divslong_sloc1_1_0 + 3) + movx @dptr,a + push ar2 + mov dpl,__divslong_sloc0_1_0 + mov dph,(__divslong_sloc0_1_0 + 1) + mov b,(__divslong_sloc0_1_0 + 2) + mov a,(__divslong_sloc0_1_0 + 3) + lcall __divulong + mov r3,dpl + mov r4,dph + mov r5,b + mov r6,a + pop ar2 +; _divslong.c 31 + push ar3 + push ar4 + push ar5 + push ar6 + mov dptr,#__divslong_a_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + rlc a + clr a + rlc a + mov r7,a + mov a,r2 + xrl a,ar7 + pop ar6 + pop ar5 + pop ar4 + pop ar3 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _divslong.c 32 + clr c + clr a + subb a,r3 + mov __divslong_sloc1_1_0,a + clr a + subb a,r4 + mov (__divslong_sloc1_1_0 + 1),a + clr a + subb a,r5 + mov (__divslong_sloc1_1_0 + 2),a + clr a + subb a,r6 +; Peephole 191 removed redundant mov + mov (__divslong_sloc1_1_0 + 3),a + mov dpl,__divslong_sloc1_1_0 + mov dph,(__divslong_sloc1_1_0 + 1) + mov b,(__divslong_sloc1_1_0 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _divslong.c 34 + mov dpl,r3 + mov dph,r4 + mov b,r5 + mov a,r6 +00104$: + C$_divslong.c$35$1$1 ==. + XG$_divslong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_divslong.cdb b/device/lib/large/_divslong.cdb new file mode 100644 index 00000000..56ce27ec --- /dev/null +++ b/device/lib/large/_divslong.cdb @@ -0,0 +1,2 @@ +M:_divslong +F:G$_divslong$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_divslong.rel b/device/lib/large/_divslong.rel new file mode 100644 index 00000000..6704d702 --- /dev/null +++ b/device/lib/large/_divslong.rel @@ -0,0 +1,265 @@ +;!FILE _divslong.asm +XH +H 8 areas A5 global symbols +M _divslong +S __divulong_PARM_2 Ref0000 +S __divulong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S __divslong_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size EF flags 20 +S A$_divslong$200 Def00B0 +S A$_divslong$110 Def0033 +S A$_divslong$210 Def00B9 +S A$_divslong$201 Def00B1 +S A$_divslong$120 Def003E +S A$_divslong$111 Def0034 +S A$_divslong$102 Def002B +S A$_divslong$220 Def00C7 +S A$_divslong$211 Def00BA +S A$_divslong$202 Def00B2 +S A$_divslong$130 Def004E +S A$_divslong$121 Def0040 +S A$_divslong$112 Def0035 +S A$_divslong$103 Def002C +S A$_divslong$230 Def00D1 +S A$_divslong$212 Def00BB +S A$_divslong$203 Def00B3 +S A$_divslong$140 Def0057 +S A$_divslong$131 Def004F +S A$_divslong$113 Def0036 +S A$_divslong$104 Def002D +S A$_divslong$240 Def00DF +S A$_divslong$231 Def00D2 +S A$_divslong$222 Def00C9 +S A$_divslong$213 Def00BC +S A$_divslong$204 Def00B4 +S A$_divslong$150 Def005F +S A$_divslong$141 Def0058 +S A$_divslong$132 Def0050 +S A$_divslong$123 Def0042 +S A$_divslong$114 Def0037 +S A$_divslong$105 Def002E +S A$_divslong$241 Def00E2 +S A$_divslong$232 Def00D4 +S A$_divslong$214 Def00BD +S A$_divslong$205 Def00B5 +S A$_divslong$160 Def006C +S A$_divslong$151 Def0060 +S A$_divslong$142 Def0059 +S A$_divslong$133 Def0051 +S A$_divslong$124 Def0044 +S A$_divslong$106 Def002F +S A$_divslong$233 Def00D5 +S A$_divslong$215 Def00BE +S A$_divslong$206 Def00B6 +S A$_divslong$170 Def0079 +S A$_divslong$161 Def006D +S A$_divslong$152 Def0061 +S A$_divslong$143 Def005A +S A$_divslong$134 Def0052 +S A$_divslong$125 Def0046 +S A$_divslong$116 Def0038 +S A$_divslong$107 Def0030 +S A$_divslong$243 Def00E5 +S A$_divslong$234 Def00D6 +S A$_divslong$225 Def00CB +S A$_divslong$216 Def00BF +S A$_divslong$207 Def00B7 +S A$_divslong$180 Def0088 +S A$_divslong$171 Def007C +S A$_divslong$153 Def0063 +S A$_divslong$135 Def0053 +S A$_divslong$126 Def0048 +S A$_divslong$108 Def0031 +S A$_divslong$253 Def00EE +S A$_divslong$235 Def00D8 +S A$_divslong$226 Def00CC +S A$_divslong$217 Def00C1 +S A$_divslong$208 Def00B8 +S A$_divslong$190 Def009F +S A$_divslong$181 Def008A +S A$_divslong$172 Def007E +S A$_divslong$163 Def006F +S A$_divslong$154 Def0064 +S A$_divslong$145 Def005B +S A$_divslong$136 Def0054 +S A$_divslong$118 Def003A +S A$_divslong$109 Def0032 +S A$_divslong$236 Def00D9 +S A$_divslong$227 Def00CD +S A$_divslong$218 Def00C3 +S A$_divslong$191 Def00A1 +S A$_divslong$182 Def008B +S A$_divslong$173 Def007F +S A$_divslong$155 Def0065 +S A$_divslong$137 Def0055 +S A$_divslong$128 Def004A +S A$_divslong$119 Def003C +S A$_divslong$246 Def00E7 +S A$_divslong$228 Def00CE +S A$_divslong$219 Def00C5 +S A$_divslong$192 Def00A2 +S A$_divslong$183 Def008D +S A$_divslong$174 Def0080 +S A$_divslong$165 Def0071 +S A$_divslong$156 Def0067 +S A$_divslong$147 Def005C +S A$_divslong$138 Def0056 +S A$_divslong$129 Def004D +S A$_divslong$247 Def00E9 +S A$_divslong$238 Def00DA +S A$_divslong$229 Def00D0 +S A$_divslong$184 Def0090 +S A$_divslong$175 Def0082 +S A$_divslong$166 Def0073 +S A$_divslong$157 Def0068 +S A$_divslong$248 Def00EB +S A$_divslong$239 Def00DC +S A$_divslong$194 Def00A4 +S A$_divslong$185 Def0093 +S A$_divslong$176 Def0083 +S A$_divslong$167 Def0075 +S A$_divslong$158 Def0069 +S A$_divslong$149 Def005E +S A$_divslong$249 Def00ED +S A$_divslong$195 Def00A6 +S A$_divslong$186 Def0096 +S A$_divslong$177 Def0084 +S A$_divslong$168 Def0077 +S A$_divslong$159 Def006B +S A$_divslong$196 Def00A8 +S A$_divslong$187 Def0098 +S A$_divslong$178 Def0086 +S A$_divslong$197 Def00AA +S A$_divslong$188 Def009B +S A$_divslong$179 Def0087 +S A$_divslong$198 Def00AC +S A$_divslong$189 Def009D +S A$_divslong$199 Def00AF +S C$_divslong.c$35$1$1 Def00EE +S A$_divslong$70 Def0002 +S A$_divslong$80 Def0014 +S A$_divslong$71 Def0004 +S A$_divslong$90 Def0020 +S A$_divslong$81 Def0015 +S A$_divslong$72 Def0006 +S A$_divslong$91 Def0021 +S A$_divslong$82 Def0016 +S A$_divslong$73 Def0008 +S A$_divslong$92 Def0022 +S A$_divslong$83 Def0018 +S A$_divslong$74 Def000B +S A$_divslong$93 Def0023 +S A$_divslong$84 Def0019 +S A$_divslong$75 Def000D +S A$_divslong$94 Def0024 +S A$_divslong$76 Def000E +S A$_divslong$95 Def0025 +S A$_divslong$86 Def001A +S A$_divslong$77 Def0010 +S A$_divslong$96 Def0026 +S A$_divslong$87 Def001D +S A$_divslong$78 Def0011 +S A$_divslong$69 Def0000 +S A$_divslong$88 Def001E +S A$_divslong$79 Def0012 +S A$_divslong$98 Def0027 +S A$_divslong$89 Def001F +S __divslong Def0000 +S XG$_divslong$0$0 Def00EE +S G$_divslong$0$0 Def0000 +S A$_divslong$100 Def0028 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 30 +R 00 00 00 07 00 02 00 05 +T 00 29 E7 0F +R 00 00 00 07 +T 00 2B +R 00 00 00 07 +T 00 2B C3 E4 9A FE E4 9B FF E4 9C F8 E4 9D F9 80 +R 00 00 00 07 +T 00 39 08 +R 00 00 00 07 +T 00 3A +R 00 00 00 07 +T 00 3A 8A 06 8B 07 8C 00 8D 01 +R 00 00 00 07 +T 00 42 +R 00 00 00 07 +T 00 42 8E 00 00 8F 00 01 88 00 02 89 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 49 00 03 90 00 00 E0 FE A3 E0 FF A3 E0 F8 A3 +R 00 00 00 07 29 02 00 01 00 05 00 05 +T 00 56 E0 F9 33 E4 33 FA 60 13 +R 00 00 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E C3 E4 9E F5 00 04 E4 9F F5 00 05 E4 98 F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 6A 00 06 E4 99 F5 00 07 80 08 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 71 +R 00 00 00 07 +T 00 71 8E 00 04 8F 00 05 88 00 06 89 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 78 00 07 +R 00 00 00 07 29 02 00 01 +T 00 79 +R 00 00 00 07 +T 00 79 90 00 00 E5 00 04 F0 A3 E5 00 05 F0 A3 E5 +R 00 00 00 07 02 03 00 00 29 06 00 01 29 0B 00 01 +T 00 85 00 06 F0 A3 E5 00 07 F0 C0 02 85 00 00 82 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 00 90 85 00 01 83 85 00 02 F0 E5 00 03 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 99 00 00 AB 82 AC 83 AD F0 FE D0 02 C0 03 C0 +R 00 00 00 07 02 02 00 01 +T 00 A7 04 C0 05 C0 06 90 00 04 E0 FF A3 E0 F8 A3 +R 00 00 00 07 00 08 00 05 +T 00 B5 E0 F9 A3 E0 FB 33 E4 33 FF EA 65 07 D0 06 +R 00 00 00 07 +T 00 C3 D0 05 D0 04 D0 03 60 1C +R 00 00 00 07 +T 00 CB +R 00 00 00 07 +T 00 CB C3 E4 9B F5 00 04 E4 9C F5 00 05 E4 9D F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 D7 00 06 E4 9E F5 00 07 85 00 04 82 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 00 E0 00 05 83 85 00 06 F0 80 07 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 00 E7 +R 00 00 00 07 +T 00 E7 8B 82 8C 83 8D F0 EE +R 00 00 00 07 +T 00 EE +R 00 00 00 07 +T 00 EE 22 +R 00 00 00 07 diff --git a/device/lib/large/_divuint.asm b/device/lib/large/_divuint.asm new file mode 100644 index 00000000..8c407c86 --- /dev/null +++ b/device/lib/large/_divuint.asm @@ -0,0 +1,215 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + +;-------------------------------------------------------- + .module _divuint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divuint_PARM_2 + .globl __divuint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +__divuint_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__divuint_PARM_2: + .ds 0x0002 +__divuint_a_1_1: + .ds 0x0002 +__divuint_reste_1_1: + .ds 0x0002 +__divuint_count_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divuint$0$0 ==. +; _divuint.c 28 +; ----------------------------------------- +; function _divuint +; ----------------------------------------- +__divuint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divuint.c 49 + push dph + push dpl + mov dptr,#__divuint_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _divuint.c 30 + mov dptr,#__divuint_reste_1_1 + clr a + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _divuint.c 31 + mov dptr,#__divuint_count_1_1 + mov a,#0x10 + movx @dptr,a +; _divuint.c 34 + mov dptr,#__divuint_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a +00105$: +; _divuint.c 36 + mov dptr,#__divuint_a_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rl a + anl a,#0x01 + mov r6,a +; _divuint.c 37 + mov a,r5 + xch a,r4 + add a,acc + xch a,r4 + rlc a + mov r5,a + mov dptr,#__divuint_a_1_1 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _divuint.c 38 + mov dptr,#__divuint_reste_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + xch a,r7 + add a,acc + xch a,r7 + rlc a + mov r0,a + mov dptr,#__divuint_reste_1_1 + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a +; _divuint.c 39 + mov a,r6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _divuint.c 40 + mov dptr,#__divuint_reste_1_1 + mov a,#0x01 + orl a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a +00102$: +; _divuint.c 42 + mov dptr,#__divuint_reste_1_1 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r6 + subb a,r2 + mov a,r7 + subb a,r3 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00106$ +00115$: +; _divuint.c 43 + mov dptr,#__divuint_reste_1_1 + clr c + mov a,r6 + subb a,r2 + movx @dptr,a + mov a,r7 + subb a,r3 + inc dptr + movx @dptr,a +; _divuint.c 45 + mov dptr,#__divuint_a_1_1 + mov a,#0x01 + orl a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +00106$: +; _divuint.c 47 + mov dptr,#__divuint_count_1_1 + movx a,@dptr + add a,#0xff +; Peephole 100 removed redundant mov + mov r4,a + mov dptr,#__divuint_count_1_1 + movx @dptr,a + mov a,r4 + jz 00116$ + ljmp 00105$ +00116$: +; _divuint.c 49 + mov dptr,#__divuint_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov dpl,r2 + mov dph,r3 +00108$: + C$_divuint.c$50$1$1 ==. + XG$_divuint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_divuint.cdb b/device/lib/large/_divuint.cdb new file mode 100644 index 00000000..8386455f --- /dev/null +++ b/device/lib/large/_divuint.cdb @@ -0,0 +1,2 @@ +M:_divuint +F:G$_divuint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_divuint.rel b/device/lib/large/_divuint.rel new file mode 100644 index 00000000..d16c5e92 --- /dev/null +++ b/device/lib/large/_divuint.rel @@ -0,0 +1,202 @@ +;!FILE _divuint.asm +XH +H 8 areas 7A global symbols +M _divuint +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 1 flags 80 +A XSEG size 7 flags 40 +S __divuint_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size A6 flags 20 +S __divuint Def0000 +S XG$_divuint$0$0 Def00A5 +S G$_divuint$0$0 Def0000 +S A$_divuint$100 Def0029 +S A$_divuint$200 Def0096 +S A$_divuint$110 Def0032 +S A$_divuint$101 Def002A +S A$_divuint$210 Def00A3 +S A$_divuint$120 Def003F +S A$_divuint$111 Def0033 +S A$_divuint$102 Def002B +S A$_divuint$130 Def0049 +S A$_divuint$121 Def0040 +S A$_divuint$112 Def0034 +S A$_divuint$103 Def002C +S A$_divuint$203 Def0099 +S A$_divuint$140 Def0056 +S A$_divuint$131 Def004A +S A$_divuint$113 Def0036 +S A$_divuint$204 Def009C +S A$_divuint$150 Def0060 +S A$_divuint$132 Def004C +S A$_divuint$123 Def0041 +S A$_divuint$114 Def0037 +S A$_divuint$105 Def002D +S A$_divuint$214 Def00A5 +S A$_divuint$205 Def009D +S A$_divuint$160 Def006A +S A$_divuint$151 Def0061 +S A$_divuint$142 Def0057 +S A$_divuint$133 Def004D +S A$_divuint$124 Def0044 +S A$_divuint$115 Def0038 +S A$_divuint$106 Def002E +S A$_divuint$206 Def009E +S A$_divuint$161 Def006B +S A$_divuint$152 Def0062 +S A$_divuint$134 Def004E +S A$_divuint$125 Def0045 +S A$_divuint$116 Def0039 +S A$_divuint$107 Def002F +S A$_divuint$207 Def009F +S A$_divuint$180 Def007D +S A$_divuint$162 Def006C +S A$_divuint$153 Def0063 +S A$_divuint$144 Def0058 +S A$_divuint$135 Def004F +S A$_divuint$126 Def0046 +S A$_divuint$117 Def003C +S A$_divuint$108 Def0031 +S A$_divuint$208 Def00A0 +S A$_divuint$172 Def0073 +S A$_divuint$163 Def006D +S A$_divuint$136 Def0052 +S A$_divuint$127 Def0047 +S A$_divuint$118 Def003D +S A$_divuint$209 Def00A1 +S A$_divuint$191 Def0088 +S A$_divuint$182 Def007E +S A$_divuint$173 Def0076 +S A$_divuint$164 Def006E +S A$_divuint$137 Def0053 +S A$_divuint$119 Def003E +S A$_divuint$192 Def008B +S A$_divuint$183 Def0081 +S A$_divuint$174 Def0077 +S A$_divuint$165 Def006F +S A$_divuint$156 Def0064 +S A$_divuint$147 Def005A +S A$_divuint$138 Def0054 +S A$_divuint$129 Def0048 +S A$_divuint$193 Def008C +S A$_divuint$184 Def0083 +S A$_divuint$175 Def0078 +S A$_divuint$166 Def0070 +S A$_divuint$157 Def0067 +S A$_divuint$148 Def005D +S A$_divuint$139 Def0055 +S A$_divuint$185 Def0084 +S A$_divuint$176 Def0079 +S A$_divuint$158 Def0068 +S A$_divuint$149 Def005F +S A$_divuint$195 Def008E +S A$_divuint$186 Def0085 +S A$_divuint$177 Def007A +S A$_divuint$159 Def0069 +S A$_divuint$196 Def008F +S A$_divuint$187 Def0086 +S A$_divuint$178 Def007B +S A$_divuint$169 Def0071 +S A$_divuint$197 Def0092 +S A$_divuint$188 Def0087 +S A$_divuint$179 Def007C +S A$_divuint$198 Def0093 +S C$_divuint.c$50$1$1 Def00A5 +S A$_divuint$199 Def0094 +S A$_divuint$80 Def000E +S A$_divuint$71 Def0000 +S A$_divuint$81 Def0011 +S A$_divuint$72 Def0002 +S A$_divuint$91 Def001E +S A$_divuint$82 Def0012 +S A$_divuint$73 Def0004 +S A$_divuint$92 Def0021 +S A$_divuint$83 Def0013 +S A$_divuint$74 Def0007 +S A$_divuint$93 Def0022 +S A$_divuint$84 Def0014 +S A$_divuint$75 Def0009 +S A$_divuint$94 Def0023 +S A$_divuint$85 Def0017 +S A$_divuint$76 Def000A +S A$_divuint$95 Def0024 +S A$_divuint$77 Def000C +S A$_divuint$96 Def0025 +S A$_divuint$87 Def0018 +S A$_divuint$78 Def000D +S A$_divuint$88 Def001B +S A$_divuint$89 Def001D +S A$_divuint$99 Def0026 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 02 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 04 E4 A3 F0 12 00 00 F0 90 00 06 74 +R 00 00 00 07 00 03 00 05 02 09 00 00 00 0D 00 05 +T 00 1C 10 F0 90 00 00 E0 FA A3 E0 FB +R 00 00 00 07 00 05 00 05 +T 00 26 +R 00 00 00 07 +T 00 26 90 00 02 E0 FC A3 E0 FD 23 54 01 FE ED CC +R 00 00 00 07 00 03 00 05 +T 00 34 25 E0 CC 33 FD 90 00 02 EC F0 A3 ED F0 90 +R 00 00 00 07 00 08 00 05 +T 00 42 00 04 E0 FF A3 E0 F8 CF 25 E0 CF 33 F8 90 +R 00 00 00 07 00 02 00 05 +T 00 50 00 04 EF F0 A3 E8 F0 EE 60 0A +R 00 00 00 07 00 02 00 05 +T 00 5A +R 00 00 00 07 +T 00 5A 90 00 04 74 01 4F F0 A3 E8 F0 +R 00 00 00 07 00 03 00 05 +T 00 64 +R 00 00 00 07 +T 00 64 90 00 04 E0 FE A3 E0 FF C3 EE 9A EF 9B 40 +R 00 00 00 07 00 03 00 05 +T 00 72 15 +R 00 00 00 07 +T 00 73 +R 00 00 00 07 +T 00 73 90 00 04 C3 EE 9A F0 EF 9B A3 F0 90 00 02 +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 00 81 74 01 4C F0 A3 ED F0 +R 00 00 00 07 +T 00 88 +R 00 00 00 07 +T 00 88 90 00 06 E0 24 FF FC 90 00 06 F0 EC 60 03 +R 00 00 00 07 00 03 00 05 00 0A 00 05 +T 00 96 02 00 26 +R 00 00 00 07 00 03 00 07 +T 00 99 +R 00 00 00 07 +T 00 99 90 00 02 E0 FA A3 E0 FB 8A 82 8B 83 +R 00 00 00 07 00 03 00 05 +T 00 A5 +R 00 00 00 07 +T 00 A5 22 +R 00 00 00 07 diff --git a/device/lib/large/_divulong.asm b/device/lib/large/_divulong.asm new file mode 100644 index 00000000..5dcc74bb --- /dev/null +++ b/device/lib/large/_divulong.asm @@ -0,0 +1,319 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + +;-------------------------------------------------------- + .module _divulong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divulong_PARM_2 + .globl __divulong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__divulong_sloc0_1_0: + .ds 0x0004 +__divulong_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__divulong_PARM_2: + .ds 0x0004 +__divulong_a_1_1: + .ds 0x0004 +__divulong_reste_1_1: + .ds 0x0004 +__divulong_count_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divulong$0$0 ==. +; _divulong.c 27 +; ----------------------------------------- +; function _divulong +; ----------------------------------------- +__divulong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divulong.c 48 + push acc + push b + push dph + push dpl + mov dptr,#__divulong_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _divulong.c 29 + mov dptr,#__divulong_reste_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _divulong.c 30 + mov dptr,#__divulong_count_1_1 + mov a,#0x20 + movx @dptr,a +; _divulong.c 33 + mov dptr,#__divulong_PARM_2 + movx a,@dptr + mov __divulong_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (__divulong_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (__divulong_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (__divulong_sloc0_1_0 + 3),a +00105$: +; _divulong.c 35 + mov dptr,#__divulong_a_1_1 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r1,a + rl a + anl a,#0x01 + mov r2,a +; _divulong.c 36 + mov a,r6 + add a,acc + mov r6,a + mov a,r7 + rlc a + mov r4,a + mov a,r0 + rlc a + mov r5,a + mov a,r1 + rlc a + mov r3,a + mov dptr,#__divulong_a_1_1 + mov a,r6 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _divulong.c 37 + push ar6 + push ar4 + push ar5 + push ar3 + mov dptr,#__divulong_reste_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr + mov r3,a + mov a,r7 + add a,acc + mov __divulong_sloc1_1_0,a + mov a,r0 + rlc a + mov (__divulong_sloc1_1_0 + 1),a + mov a,r1 + rlc a + mov (__divulong_sloc1_1_0 + 2),a + mov a,r3 + rlc a + mov (__divulong_sloc1_1_0 + 3),a + mov dptr,#__divulong_reste_1_1 + mov a,__divulong_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(__divulong_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(__divulong_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(__divulong_sloc1_1_0 + 3) + movx @dptr,a +; _divulong.c 38 + pop ar3 + pop ar5 + pop ar4 + pop ar6 + mov a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _divulong.c 39 + mov dptr,#__divulong_reste_1_1 + mov a,#0x01 + orl a,__divulong_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(__divulong_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(__divulong_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(__divulong_sloc1_1_0 + 3) + movx @dptr,a +00102$: +; _divulong.c 41 + mov dptr,#__divulong_reste_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + clr c + mov a,r2 + subb a,__divulong_sloc0_1_0 + mov a,r7 + subb a,(__divulong_sloc0_1_0 + 1) + mov a,r0 + subb a,(__divulong_sloc0_1_0 + 2) + mov a,r1 + subb a,(__divulong_sloc0_1_0 + 3) +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00106$ +00115$: +; _divulong.c 42 + mov dptr,#__divulong_reste_1_1 + clr c + mov a,r2 + subb a,__divulong_sloc0_1_0 + movx @dptr,a + mov a,r7 + subb a,(__divulong_sloc0_1_0 + 1) + inc dptr + movx @dptr,a + mov a,r0 + subb a,(__divulong_sloc0_1_0 + 2) + inc dptr + movx @dptr,a + mov a,r1 + subb a,(__divulong_sloc0_1_0 + 3) + inc dptr + movx @dptr,a +; _divulong.c 44 + mov dptr,#__divulong_a_1_1 + mov a,#0x01 + orl a,r6 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +00106$: +; _divulong.c 46 + mov dptr,#__divulong_count_1_1 + movx a,@dptr + add a,#0xff +; Peephole 100 removed redundant mov + mov r2,a + mov dptr,#__divulong_count_1_1 + movx @dptr,a + mov a,r2 + jz 00116$ + ljmp 00105$ +00116$: +; _divulong.c 48 + mov dptr,#__divulong_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00108$: + C$_divulong.c$49$1$1 ==. + XG$_divulong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_divulong.cdb b/device/lib/large/_divulong.cdb new file mode 100644 index 00000000..1ec9def8 --- /dev/null +++ b/device/lib/large/_divulong.cdb @@ -0,0 +1,2 @@ +M:_divulong +F:G$_divulong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_divulong.rel b/device/lib/large/_divulong.rel new file mode 100644 index 00000000..faa1dee4 --- /dev/null +++ b/device/lib/large/_divulong.rel @@ -0,0 +1,334 @@ +;!FILE _divulong.asm +XH +H 8 areas E0 global symbols +M _divulong +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size D flags 40 +S __divulong_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 135 flags 20 +S A$_divulong$100 Def002A +S A$_divulong$200 Def00A8 +S A$_divulong$110 Def003A +S A$_divulong$101 Def002D +S A$_divulong$300 Def0123 +S A$_divulong$210 Def00B5 +S A$_divulong$201 Def00A9 +S A$_divulong$111 Def003B +S A$_divulong$301 Def0124 +S A$_divulong$220 Def00C3 +S A$_divulong$202 Def00AB +S A$_divulong$130 Def0051 +S A$_divulong$121 Def0046 +S A$_divulong$112 Def003C +S A$_divulong$103 Def002E +S A$_divulong$311 Def012D +S A$_divulong$302 Def0125 +S A$_divulong$230 Def00CF +S A$_divulong$221 Def00C4 +S A$_divulong$140 Def005B +S A$_divulong$131 Def0052 +S A$_divulong$122 Def0049 +S A$_divulong$113 Def003E +S A$_divulong$104 Def0031 +S A$_divulong$312 Def012E +S A$_divulong$303 Def0126 +S A$_divulong$240 Def00D9 +S A$_divulong$231 Def00D0 +S A$_divulong$222 Def00C6 +S A$_divulong$213 Def00B7 +S A$_divulong$204 Def00AC +S A$_divulong$150 Def0065 +S A$_divulong$141 Def005C +S A$_divulong$123 Def004A +S A$_divulong$114 Def003F +S A$_divulong$105 Def0033 +S A$_divulong$313 Def0130 +S A$_divulong$304 Def0127 +S A$_divulong$241 Def00DA +S A$_divulong$232 Def00D1 +S A$_divulong$223 Def00C7 +S A$_divulong$214 Def00BA +S A$_divulong$205 Def00AE +S A$_divulong$160 Def0071 +S A$_divulong$151 Def0068 +S A$_divulong$142 Def005D +S A$_divulong$133 Def0053 +S A$_divulong$124 Def004B +S A$_divulong$115 Def0040 +S A$_divulong$314 Def0132 +S A$_divulong$305 Def0128 +S A$_divulong$260 Def00F1 +S A$_divulong$251 Def00E6 +S A$_divulong$242 Def00DB +S A$_divulong$233 Def00D2 +S A$_divulong$224 Def00C8 +S A$_divulong$215 Def00BC +S A$_divulong$206 Def00B0 +S A$_divulong$170 Def0080 +S A$_divulong$161 Def0072 +S A$_divulong$152 Def0069 +S A$_divulong$143 Def005E +S A$_divulong$134 Def0054 +S A$_divulong$125 Def004C +S A$_divulong$116 Def0042 +S A$_divulong$107 Def0034 +S A$_divulong$306 Def0129 +S A$_divulong$270 Def00FE +S A$_divulong$261 Def00F3 +S A$_divulong$243 Def00DD +S A$_divulong$234 Def00D3 +S A$_divulong$225 Def00CA +S A$_divulong$216 Def00BE +S A$_divulong$207 Def00B2 +S A$_divulong$180 Def008A +S A$_divulong$171 Def0081 +S A$_divulong$153 Def006A +S A$_divulong$144 Def005F +S A$_divulong$135 Def0055 +S A$_divulong$126 Def004D +S A$_divulong$117 Def0043 +S A$_divulong$108 Def0037 +S A$_divulong$307 Def012A +S A$_divulong$280 Def010A +S A$_divulong$262 Def00F4 +S A$_divulong$244 Def00DE +S A$_divulong$235 Def00D4 +S A$_divulong$217 Def00BF +S A$_divulong$208 Def00B4 +S A$_divulong$190 Def0098 +S A$_divulong$181 Def008C +S A$_divulong$172 Def0082 +S A$_divulong$163 Def0073 +S A$_divulong$154 Def006B +S A$_divulong$145 Def0060 +S A$_divulong$136 Def0057 +S A$_divulong$127 Def004E +S A$_divulong$118 Def0044 +S A$_divulong$109 Def0038 +S A$_divulong$308 Def012B +S A$_divulong$281 Def010B +S A$_divulong$272 Def00FF +S A$_divulong$263 Def00F5 +S A$_divulong$254 Def00E8 +S A$_divulong$245 Def00E0 +S A$_divulong$236 Def00D5 +S A$_divulong$218 Def00C0 +S A$_divulong$191 Def009A +S A$_divulong$182 Def008E +S A$_divulong$173 Def0083 +S A$_divulong$164 Def0075 +S A$_divulong$155 Def006C +S A$_divulong$146 Def0061 +S A$_divulong$128 Def004F +S A$_divulong$318 Def0134 +S A$_divulong$309 Def012C +S A$_divulong$291 Def0115 +S A$_divulong$282 Def010C +S A$_divulong$273 Def0102 +S A$_divulong$264 Def00F6 +S A$_divulong$255 Def00EB +S A$_divulong$246 Def00E1 +S A$_divulong$237 Def00D6 +S A$_divulong$228 Def00CB +S A$_divulong$219 Def00C2 +S A$_divulong$192 Def009D +S A$_divulong$183 Def008F +S A$_divulong$174 Def0084 +S A$_divulong$165 Def0077 +S A$_divulong$156 Def006D +S A$_divulong$147 Def0062 +S A$_divulong$138 Def0058 +S A$_divulong$129 Def0050 +S A$_divulong$292 Def0116 +S A$_divulong$283 Def010D +S A$_divulong$274 Def0104 +S A$_divulong$265 Def00F8 +S A$_divulong$256 Def00EC +S A$_divulong$247 Def00E3 +S A$_divulong$238 Def00D7 +S A$_divulong$229 Def00CE +S A$_divulong$193 Def009F +S A$_divulong$184 Def0090 +S A$_divulong$175 Def0085 +S A$_divulong$166 Def0079 +S A$_divulong$157 Def006E +S A$_divulong$148 Def0063 +S A$_divulong$139 Def0059 +S A$_divulong$293 Def0119 +S A$_divulong$284 Def010E +S A$_divulong$275 Def0105 +S A$_divulong$266 Def00F9 +S A$_divulong$257 Def00ED +S A$_divulong$248 Def00E4 +S A$_divulong$239 Def00D8 +S A$_divulong$194 Def00A0 +S A$_divulong$185 Def0092 +S A$_divulong$176 Def0086 +S A$_divulong$167 Def007B +S A$_divulong$158 Def006F +S A$_divulong$149 Def0064 +S A$_divulong$294 Def011A +S A$_divulong$276 Def0106 +S A$_divulong$267 Def00FA +S A$_divulong$258 Def00EF +S A$_divulong$195 Def00A1 +S A$_divulong$186 Def0093 +S A$_divulong$177 Def0087 +S A$_divulong$168 Def007E +S A$_divulong$159 Def0070 +S A$_divulong$295 Def011B +S A$_divulong$277 Def0107 +S A$_divulong$268 Def00FB +S A$_divulong$259 Def00F0 +S A$_divulong$196 Def00A3 +S A$_divulong$187 Def0094 +S A$_divulong$178 Def0088 +S A$_divulong$169 Def007F +S A$_divulong$296 Def011D +S A$_divulong$287 Def010F +S A$_divulong$278 Def0108 +S A$_divulong$269 Def00FD +S A$_divulong$197 Def00A4 +S A$_divulong$188 Def0096 +S A$_divulong$179 Def0089 +S A$_divulong$288 Def0112 +S A$_divulong$279 Def0109 +S A$_divulong$198 Def00A5 +S A$_divulong$189 Def0097 +S A$_divulong$289 Def0113 +S A$_divulong$199 Def00A7 +S A$_divulong$299 Def0120 +S A$_divulong$80 Def000E +S A$_divulong$90 Def001A +S A$_divulong$81 Def0010 +S A$_divulong$91 Def001D +S A$_divulong$82 Def0011 +S A$_divulong$73 Def0000 +S C$_divulong.c$49$1$1 Def0134 +S A$_divulong$92 Def001E +S A$_divulong$83 Def0012 +S A$_divulong$74 Def0002 +S A$_divulong$93 Def001F +S A$_divulong$84 Def0014 +S A$_divulong$75 Def0004 +S A$_divulong$94 Def0020 +S A$_divulong$85 Def0015 +S A$_divulong$76 Def0006 +S A$_divulong$95 Def0021 +S A$_divulong$86 Def0016 +S A$_divulong$77 Def0008 +S A$_divulong$96 Def0022 +S A$_divulong$87 Def0018 +S A$_divulong$78 Def000B +S A$_divulong$97 Def0025 +S A$_divulong$88 Def0019 +S A$_divulong$79 Def000D +S A$_divulong$98 Def0026 +S A$_divulong$99 Def0029 +S __divulong Def0000 +S XG$_divulong$0$0 Def0134 +S G$_divulong$0$0 Def0000 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 08 E4 A3 A3 A3 F0 12 00 00 F0 12 00 00 +R 00 00 00 07 00 02 00 05 02 0A 00 00 02 0E 00 00 +T 00 29 F0 12 00 00 F0 90 00 0C 74 20 F0 90 00 00 +R 00 00 00 07 02 04 00 00 00 08 00 05 00 0E 00 05 +T 00 37 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 +R 00 00 00 07 29 04 00 01 29 09 00 01 29 0E 00 01 +T 00 42 A3 E0 F5 00 03 +R 00 00 00 07 29 05 00 01 +T 00 46 +R 00 00 00 07 +T 00 46 90 00 04 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 +R 00 00 00 07 00 03 00 05 +T 00 54 23 54 01 FA EE 25 E0 FE EF 33 FC E8 33 FD +R 00 00 00 07 +T 00 62 E9 33 FB 90 00 04 EE F0 A3 EC F0 A3 ED F0 +R 00 00 00 07 00 06 00 05 +T 00 70 A3 EB F0 C0 06 C0 04 C0 05 C0 03 90 00 08 +R 00 00 00 07 00 0E 00 05 +T 00 7E E0 FF A3 E0 F8 A3 E0 F9 A3 E0 FB EF 25 E0 +R 00 00 00 07 +T 00 8C F5 00 04 E8 33 F5 00 05 E9 33 F5 00 06 EB +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 00 97 33 F5 00 07 90 00 08 E5 00 04 F0 A3 E5 +R 00 00 00 07 29 04 00 01 00 07 00 05 29 0A 00 01 +T 00 A2 00 05 F0 A3 E5 00 06 F0 A3 E5 00 07 F0 D0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 AD 03 D0 05 D0 04 D0 06 EA 60 14 +R 00 00 00 07 +T 00 B7 +R 00 00 00 07 +T 00 B7 90 00 08 74 01 45 00 04 F0 A3 E5 00 05 F0 +R 00 00 00 07 00 03 00 05 29 08 00 01 29 0D 00 01 +T 00 C3 A3 E5 00 06 F0 A3 E5 00 07 F0 +R 00 00 00 07 29 04 00 01 29 09 00 01 +T 00 CB +R 00 00 00 07 +T 00 CB 90 00 08 E0 FA A3 E0 FF A3 E0 F8 A3 E0 F9 +R 00 00 00 07 00 03 00 05 +T 00 D9 C3 EA 95 00 00 EF 95 00 01 E8 95 00 02 E9 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0D 00 01 +T 00 E4 95 00 03 40 27 +R 00 00 00 07 29 03 00 01 +T 00 E8 +R 00 00 00 07 +T 00 E8 90 00 08 C3 EA 95 00 00 F0 EF 95 00 01 A3 +R 00 00 00 07 00 03 00 05 29 08 00 01 29 0D 00 01 +T 00 F4 F0 E8 95 00 02 A3 F0 E9 95 00 03 A3 F0 90 +R 00 00 00 07 29 05 00 01 29 0B 00 01 +T 01 00 00 04 74 01 4E F0 A3 EC F0 A3 ED F0 A3 EB +R 00 00 00 07 00 02 00 05 +T 01 0E F0 +R 00 00 00 07 +T 01 0F +R 00 00 00 07 +T 01 0F 90 00 0C E0 24 FF FA 90 00 0C F0 EA 60 03 +R 00 00 00 07 00 03 00 05 00 0A 00 05 +T 01 1D 02 00 46 +R 00 00 00 07 00 03 00 07 +T 01 20 +R 00 00 00 07 +T 01 20 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 01 2E 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 34 +R 00 00 00 07 +T 01 34 22 +R 00 00 00 07 diff --git a/device/lib/large/_fs2char.asm b/device/lib/large/_fs2char.asm new file mode 100644 index 00000000..cb96bdc7 --- /dev/null +++ b/device/lib/large/_fs2char.asm @@ -0,0 +1,432 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + +;-------------------------------------------------------- + .module _fs2char +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2char +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fs2char_sloc0_1_0: + .ds 0x0004 +___fs2char_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fs2char_a1_1_1: + .ds 0x0004 +___fs2char_fl1_1_1: + .ds 0x0004 +___fs2char_exp_1_1: + .ds 0x0002 +___fs2char_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2char$0$0 ==. +; _fs2char.c 73 +; ----------------------------------------- +; function __fs2char +; ----------------------------------------- +___fs2char: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2char.c 96 + push acc + push b + push dph + push dpl + mov dptr,#___fs2char_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fs2char.c 79 + mov dptr,#___fs2char_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fs2char_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fs2char.c 81 + mov dptr,#(___fs2char_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2char.c 82 + mov dpl,#0x00 + ljmp 00110$ +00102$: +; _fs2char.c 84 + mov dptr,#(___fs2char_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov r2,a + mov a,b + addc a,#0xff + mov r3,a + mov dptr,#___fs2char_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _fs2char.c 85 + mov dptr,#(___fs2char_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + anl ar6,#0x7f + mov r7,#0x00 + mov dptr,#___fs2char_l_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + mov a,#0x80 + orl a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _fs2char.c 87 + mov dptr,#___fs2char_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + clr c +; Peephole 180 changed mov to clr + clr a + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,r3 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2char.c 88 + mov dptr,#(___fs2char_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r7,a + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov dpl,r2 + ljmp 00110$ +00104$: +; _fs2char.c 91 + mov dptr,#___fs2char_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + jb acc.7,00123$ + ljmp 00106$ +00123$: + mov dptr,#___fs2char_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + mov a,#0xe7 + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,r0 + xrl b,#0x80 + subb a,b + jc 00124$ + ljmp 00106$ +00124$: + mov dptr,#___fs2char_l_1_1 + movx a,@dptr + mov ___fs2char_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fs2char_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc0_1_0 + 3),a + mov a,___fs2char_sloc0_1_0 + orl a,(___fs2char_sloc0_1_0 + 1) + orl a,(___fs2char_sloc0_1_0 + 2) + orl a,(___fs2char_sloc0_1_0 + 3) + jnz 00125$ + ljmp 00106$ +00125$: +; _fs2char.c 92 + mov dptr,#___fs2char_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + clr a + subb a,r2 + mov ___fs2char_sloc0_1_0,a + clr a + subb a,r0 + mov (___fs2char_sloc0_1_0 + 1),a + mov dptr,#___fs2char_l_1_1 + movx a,@dptr + mov ___fs2char_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 3),a + mov b,___fs2char_sloc0_1_0 + inc b + mov a,(___fs2char_sloc1_1_0 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2char_sloc1_1_0 + 3) + rrc a + mov (___fs2char_sloc1_1_0 + 3),a + mov a,(___fs2char_sloc1_1_0 + 2) + rrc a + mov (___fs2char_sloc1_1_0 + 2),a + mov a,(___fs2char_sloc1_1_0 + 1) + rrc a + mov (___fs2char_sloc1_1_0 + 1),a + mov a,___fs2char_sloc1_1_0 + rrc a + mov ___fs2char_sloc1_1_0,a +00127$: + djnz b,00126$ + mov dptr,#___fs2char_l_1_1 + mov a,___fs2char_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fs2char_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fs2char_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fs2char_sloc1_1_0 + 3) + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2char.c 94 + mov dpl,#0x00 + ljmp 00110$ +00107$: +; _fs2char.c 96 + mov dptr,#(___fs2char_fl1_1_1) + movx a,@dptr + mov ___fs2char_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fs2char_sloc1_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + mov dptr,#___fs2char_l_1_1 + movx a,@dptr + mov ___fs2char_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 3),a + clr c + clr a + subb a,___fs2char_sloc1_1_0 + mov ___fs2char_sloc1_1_0,a + clr a + subb a,(___fs2char_sloc1_1_0 + 1) + mov (___fs2char_sloc1_1_0 + 1),a + clr a + subb a,(___fs2char_sloc1_1_0 + 2) + mov (___fs2char_sloc1_1_0 + 2),a + clr a + subb a,(___fs2char_sloc1_1_0 + 3) + mov (___fs2char_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov dptr,#___fs2char_l_1_1 + movx a,@dptr + mov ___fs2char_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2char_sloc1_1_0 + 3),a +00113$: + mov dpl,___fs2char_sloc1_1_0 + mov dph,(___fs2char_sloc1_1_0 + 1) + mov b,(___fs2char_sloc1_1_0 + 2) + mov a,(___fs2char_sloc1_1_0 + 3) +00110$: + C$_fs2char.c$97$1$1 ==. + XG$__fs2char$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fs2char.cdb b/device/lib/large/_fs2char.cdb new file mode 100644 index 00000000..09f26dd7 --- /dev/null +++ b/device/lib/large/_fs2char.cdb @@ -0,0 +1,2 @@ +M:_fs2char +F:G$__fs2char$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fs2char.rel b/device/lib/large/_fs2char.rel new file mode 100644 index 00000000..465835a4 --- /dev/null +++ b/device/lib/large/_fs2char.rel @@ -0,0 +1,487 @@ +;!FILE _fs2char.asm +XH +H 8 areas 143 global symbols +M _fs2char +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 1E4 flags 20 +S A$_fs2char$100 Def0027 +S A$_fs2char$200 Def00A3 +S A$_fs2char$110 Def0033 +S A$_fs2char$101 Def0028 +S A$_fs2char$300 Def0129 +S A$_fs2char$210 Def00AF +S A$_fs2char$201 Def00A4 +S A$_fs2char$120 Def003E +S A$_fs2char$111 Def0034 +S A$_fs2char$102 Def002B +S A$_fs2char$400 Def01B6 +S A$_fs2char$310 Def0137 +S A$_fs2char$301 Def012A +S A$_fs2char$220 Def00B7 +S A$_fs2char$211 Def00B0 +S A$_fs2char$202 Def00A6 +S A$_fs2char$121 Def003F +S A$_fs2char$112 Def0035 +S A$_fs2char$103 Def002C +S A$_fs2char$401 Def01B8 +S A$_fs2char$320 Def0144 +S A$_fs2char$311 Def0138 +S A$_fs2char$302 Def012B +S A$_fs2char$230 Def00C6 +S A$_fs2char$221 Def00B9 +S A$_fs2char$212 Def00B1 +S A$_fs2char$203 Def00A7 +S A$_fs2char$140 Def0054 +S A$_fs2char$131 Def0048 +S A$_fs2char$122 Def0040 +S A$_fs2char$104 Def002D +S ___fs2char Def0000 +S A$_fs2char$420 Def01D4 +S A$_fs2char$411 Def01C6 +S A$_fs2char$402 Def01BA +S A$_fs2char$330 Def0156 +S A$_fs2char$321 Def0146 +S A$_fs2char$312 Def013A +S A$_fs2char$303 Def012C +S A$_fs2char$240 Def00CF +S A$_fs2char$231 Def00C7 +S A$_fs2char$222 Def00BB +S A$_fs2char$213 Def00B2 +S A$_fs2char$204 Def00A8 +S A$_fs2char$150 Def005E +S A$_fs2char$141 Def0055 +S A$_fs2char$123 Def0041 +S A$_fs2char$114 Def0036 +S A$_fs2char$105 Def002E +S A$_fs2char$421 Def01D5 +S A$_fs2char$412 Def01C9 +S A$_fs2char$403 Def01BB +S A$_fs2char$340 Def0166 +S A$_fs2char$331 Def0157 +S A$_fs2char$322 Def0149 +S A$_fs2char$313 Def013B +S A$_fs2char$304 Def012D +S A$_fs2char$250 Def00DF +S A$_fs2char$241 Def00D0 +S A$_fs2char$232 Def00C8 +S A$_fs2char$223 Def00BE +S A$_fs2char$214 Def00B3 +S A$_fs2char$205 Def00A9 +S A$_fs2char$160 Def006D +S A$_fs2char$151 Def0060 +S A$_fs2char$142 Def0056 +S A$_fs2char$124 Def0042 +S A$_fs2char$115 Def0039 +S A$_fs2char$106 Def002F +S A$_fs2char$431 Def01E3 +S A$_fs2char$422 Def01D6 +S A$_fs2char$413 Def01CA +S A$_fs2char$404 Def01BD +S A$_fs2char$350 Def0176 +S A$_fs2char$332 Def0159 +S A$_fs2char$323 Def014B +S A$_fs2char$314 Def013C +S A$_fs2char$305 Def012E +S A$_fs2char$260 Def00ED +S A$_fs2char$251 Def00E0 +S A$_fs2char$242 Def00D1 +S A$_fs2char$233 Def00C9 +S A$_fs2char$215 Def00B4 +S A$_fs2char$206 Def00AA +S A$_fs2char$170 Def007B +S A$_fs2char$152 Def0061 +S A$_fs2char$143 Def0057 +S A$_fs2char$134 Def004A +S A$_fs2char$125 Def0043 +S A$_fs2char$116 Def003A +S A$_fs2char$107 Def0030 +S A$_fs2char$414 Def01CC +S A$_fs2char$405 Def01BF +S A$_fs2char$360 Def0182 +S A$_fs2char$351 Def0178 +S A$_fs2char$342 Def0168 +S A$_fs2char$333 Def015B +S A$_fs2char$324 Def014D +S A$_fs2char$315 Def013E +S A$_fs2char$306 Def0130 +S A$_fs2char$270 Def00F8 +S A$_fs2char$261 Def00EE +S A$_fs2char$252 Def00E1 +S A$_fs2char$243 Def00D3 +S A$_fs2char$234 Def00CA +S A$_fs2char$225 Def00C0 +S A$_fs2char$207 Def00AB +S A$_fs2char$171 Def007C +S A$_fs2char$162 Def006F +S A$_fs2char$153 Def0063 +S A$_fs2char$144 Def0058 +S A$_fs2char$135 Def004D +S A$_fs2char$126 Def0044 +S A$_fs2char$117 Def003B +S A$_fs2char$108 Def0031 +S A$_fs2char$424 Def01D8 +S A$_fs2char$415 Def01CD +S A$_fs2char$406 Def01C0 +S A$_fs2char$370 Def0190 +S A$_fs2char$352 Def0179 +S A$_fs2char$343 Def016B +S A$_fs2char$334 Def015C +S A$_fs2char$325 Def014E +S A$_fs2char$316 Def013F +S A$_fs2char$307 Def0131 +S A$_fs2char$280 Def010B +S A$_fs2char$271 Def00FA +S A$_fs2char$262 Def00EF +S A$_fs2char$253 Def00E2 +S A$_fs2char$244 Def00D4 +S A$_fs2char$235 Def00CB +S A$_fs2char$217 Def00B5 +S A$_fs2char$190 Def0094 +S A$_fs2char$181 Def0089 +S A$_fs2char$172 Def007E +S A$_fs2char$163 Def0070 +S A$_fs2char$154 Def0064 +S A$_fs2char$145 Def0059 +S A$_fs2char$127 Def0045 +S A$_fs2char$118 Def003C +S A$_fs2char$109 Def0032 +S A$_fs2char$425 Def01DB +S A$_fs2char$416 Def01CE +S A$_fs2char$407 Def01C2 +S A$_fs2char$371 Def0191 +S A$_fs2char$353 Def017A +S A$_fs2char$344 Def016E +S A$_fs2char$335 Def015E +S A$_fs2char$326 Def0150 +S A$_fs2char$317 Def0140 +S A$_fs2char$308 Def0132 +S A$_fs2char$290 Def011A +S A$_fs2char$281 Def010C +S A$_fs2char$272 Def00FD +S A$_fs2char$263 Def00F0 +S A$_fs2char$245 Def00D7 +S A$_fs2char$236 Def00CC +S A$_fs2char$218 Def00B6 +S A$_fs2char$209 Def00AC +S A$_fs2char$191 Def0095 +S A$_fs2char$182 Def008C +S A$_fs2char$173 Def0080 +S A$_fs2char$164 Def0071 +S A$_fs2char$155 Def0065 +S A$_fs2char$146 Def005A +S A$_fs2char$128 Def0046 +S A$_fs2char$119 Def003D +S A$_fs2char$426 Def01DE +S A$_fs2char$417 Def01D0 +S A$_fs2char$390 Def01A8 +S A$_fs2char$381 Def019B +S A$_fs2char$372 Def0193 +S A$_fs2char$363 Def0185 +S A$_fs2char$354 Def017C +S A$_fs2char$345 Def0170 +S A$_fs2char$336 Def0160 +S A$_fs2char$318 Def0142 +S A$_fs2char$309 Def0134 +S A$_fs2char$291 Def011C +S A$_fs2char$282 Def010E +S A$_fs2char$273 Def00FF +S A$_fs2char$264 Def00F1 +S A$_fs2char$255 Def00E3 +S A$_fs2char$246 Def00D9 +S A$_fs2char$237 Def00CD +S A$_fs2char$228 Def00C2 +S A$_fs2char$192 Def0096 +S A$_fs2char$183 Def008D +S A$_fs2char$174 Def0081 +S A$_fs2char$165 Def0073 +S A$_fs2char$156 Def0066 +S A$_fs2char$147 Def005B +S A$_fs2char$138 Def0050 +S A$_fs2char$129 Def0047 +S A$_fs2char$427 Def01E1 +S A$_fs2char$418 Def01D1 +S A$_fs2char$409 Def01C4 +S A$_fs2char$391 Def01A9 +S A$_fs2char$373 Def0194 +S A$_fs2char$364 Def0188 +S A$_fs2char$346 Def0171 +S A$_fs2char$337 Def0161 +S A$_fs2char$328 Def0152 +S A$_fs2char$319 Def0143 +S A$_fs2char$292 Def011E +S A$_fs2char$283 Def010F +S A$_fs2char$274 Def0101 +S A$_fs2char$265 Def00F2 +S A$_fs2char$256 Def00E4 +S A$_fs2char$238 Def00CE +S A$_fs2char$229 Def00C5 +S A$_fs2char$193 Def0097 +S A$_fs2char$184 Def008E +S A$_fs2char$175 Def0084 +S A$_fs2char$166 Def0074 +S A$_fs2char$157 Def0067 +S A$_fs2char$148 Def005C +S A$_fs2char$139 Def0053 +S A$_fs2char$419 Def01D2 +S A$_fs2char$392 Def01AB +S A$_fs2char$383 Def019D +S A$_fs2char$365 Def0189 +S A$_fs2char$356 Def017D +S A$_fs2char$347 Def0172 +S A$_fs2char$338 Def0163 +S A$_fs2char$329 Def0154 +S A$_fs2char$293 Def0120 +S A$_fs2char$284 Def0110 +S A$_fs2char$266 Def00F3 +S A$_fs2char$257 Def00E7 +S A$_fs2char$194 Def009A +S A$_fs2char$185 Def008F +S A$_fs2char$176 Def0085 +S A$_fs2char$167 Def0075 +S A$_fs2char$158 Def0068 +S A$_fs2char$149 Def005D +S A$_fs2char$393 Def01AC +S A$_fs2char$384 Def01A0 +S A$_fs2char$375 Def0195 +S A$_fs2char$366 Def018B +S A$_fs2char$348 Def0174 +S A$_fs2char$339 Def0165 +S A$_fs2char$285 Def0112 +S A$_fs2char$276 Def0104 +S A$_fs2char$267 Def00F5 +S A$_fs2char$249 Def00DC +S A$_fs2char$195 Def009C +S A$_fs2char$186 Def0090 +S A$_fs2char$177 Def0086 +S A$_fs2char$168 Def0076 +S A$_fs2char$159 Def006A +S A$_fs2char$394 Def01AD +S A$_fs2char$385 Def01A1 +S A$_fs2char$376 Def0197 +S A$_fs2char$367 Def018C +S A$_fs2char$349 Def0175 +S A$_fs2char$286 Def0113 +S A$_fs2char$277 Def0107 +S A$_fs2char$259 Def00EA +S A$_fs2char$196 Def009F +S A$_fs2char$187 Def0091 +S A$_fs2char$178 Def0087 +S A$_fs2char$169 Def0079 +S A$_fs2char$395 Def01AF +S A$_fs2char$386 Def01A3 +S A$_fs2char$377 Def0198 +S A$_fs2char$368 Def018D +S A$_fs2char$359 Def017F +S A$_fs2char$296 Def0123 +S A$_fs2char$287 Def0114 +S A$_fs2char$278 Def0108 +S A$_fs2char$269 Def00F6 +S A$_fs2char$197 Def00A0 +S A$_fs2char$188 Def0092 +S A$_fs2char$179 Def0088 +S XG$__fs2char$0$0 Def01E3 +S A$_fs2char$396 Def01B0 +S A$_fs2char$387 Def01A4 +S A$_fs2char$369 Def018F +S A$_fs2char$297 Def0126 +S A$_fs2char$288 Def0116 +S A$_fs2char$279 Def010A +S A$_fs2char$198 Def00A1 +S A$_fs2char$189 Def0093 +S A$_fs2char$397 Def01B1 +S A$_fs2char$388 Def01A5 +S A$_fs2char$379 Def019A +S A$_fs2char$298 Def0127 +S A$_fs2char$289 Def0118 +S A$_fs2char$199 Def00A2 +S A$_fs2char$398 Def01B3 +S A$_fs2char$389 Def01A7 +S A$_fs2char$299 Def0128 +S A$_fs2char$399 Def01B5 +S A$_fs2char$80 Def0010 +S A$_fs2char$90 Def001D +S A$_fs2char$81 Def0011 +S A$_fs2char$72 Def0000 +S G$__fs2char$0$0 Def0000 +S A$_fs2char$91 Def001E +S A$_fs2char$82 Def0012 +S A$_fs2char$73 Def0002 +S A$_fs2char$92 Def001F +S A$_fs2char$83 Def0014 +S A$_fs2char$74 Def0004 +S A$_fs2char$93 Def0020 +S A$_fs2char$84 Def0015 +S A$_fs2char$75 Def0006 +S A$_fs2char$94 Def0021 +S A$_fs2char$85 Def0016 +S A$_fs2char$76 Def0008 +S C$_fs2char.c$97$1$1 Def01E3 +S A$_fs2char$95 Def0022 +S A$_fs2char$86 Def0018 +S A$_fs2char$77 Def000B +S A$_fs2char$96 Def0023 +S A$_fs2char$87 Def0019 +S A$_fs2char$78 Def000D +S A$_fs2char$97 Def0024 +S A$_fs2char$79 Def000E +S A$_fs2char$98 Def0025 +S A$_fs2char$89 Def001A +S A$_fs2char$99 Def0026 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 04 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 45 4B 4C 4D 70 06 +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A 75 82 00 02 01 E3 +R 00 00 00 07 00 06 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 5E 8C 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 6C 02 44 FE +R 00 00 00 07 +T 00 6F +R 00 00 00 07 +T 00 6F FB 33 95 E0 FC FD EA 75 F0 00 24 6A FA E5 +R 00 00 00 07 +T 00 7D F0 34 FF FB 90 00 08 EA F0 A3 EB F0 90 +R 00 00 00 07 00 07 00 05 +T 00 8A 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF 53 +R 00 00 00 07 00 02 00 05 +T 00 98 06 7F 7F 00 90 00 0A EA F0 A3 EB F0 74 80 +R 00 00 00 07 00 07 00 05 +T 00 A6 4E A3 F0 A3 EF F0 90 00 08 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 B4 C3 E4 9A 74 80 8B F0 63 F0 80 95 F0 50 1A +R 00 00 00 07 +T 00 C2 +R 00 00 00 07 +T 00 C2 90 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 D0 23 54 01 FA 43 02 7F 8A 82 02 01 E3 +R 00 00 00 07 00 0C 00 07 +T 00 DC +R 00 00 00 07 +T 00 DC 90 00 08 E0 FA A3 E0 F8 20 E7 03 02 01 7F +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 00 EA +R 00 00 00 07 +T 00 EA 90 00 08 E0 FA A3 E0 F8 C3 74 E7 9A 74 7F +R 00 00 00 07 00 03 00 05 +T 00 F8 88 F0 63 F0 80 95 F0 40 03 02 01 7F +R 00 00 00 07 00 0C 00 07 +T 01 04 +R 00 00 00 07 +T 01 04 90 00 0A E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 10 F5 00 02 A3 E0 F5 00 03 E5 00 00 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 19 00 01 45 00 02 45 00 03 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 21 01 7F +R 00 00 00 07 00 02 00 07 +T 01 23 +R 00 00 00 07 +T 01 23 90 00 08 E0 FA A3 E0 F8 C3 E4 9A F5 00 00 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 01 30 E4 98 F5 00 01 90 00 0A E0 F5 00 04 A3 E0 +R 00 00 00 07 29 05 00 01 00 08 00 05 29 0C 00 01 +T 01 3C F5 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 85 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 47 00 00 F0 05 F0 E5 00 07 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 01 52 +R 00 00 00 07 +T 01 52 A2 D2 E5 00 07 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 01 5D 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 64 00 04 13 F5 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 01 68 +R 00 00 00 07 +T 01 68 D5 F0 E7 90 00 0A E5 00 04 F0 A3 E5 00 05 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 01 74 F0 A3 E5 00 06 F0 A3 E5 00 07 F0 80 06 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 01 7F +R 00 00 00 07 +T 01 7F 75 82 00 02 01 E3 +R 00 00 00 07 00 06 00 07 +T 01 85 +R 00 00 00 07 +T 01 85 90 00 04 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 91 F5 00 06 A3 E0 F5 00 07 23 54 01 FA 60 29 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 9D +R 00 00 00 07 +T 01 9D 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 A9 F5 00 06 A3 E0 F5 00 07 C3 E4 95 00 04 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 B4 00 04 E4 95 00 05 F5 00 05 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 BC 00 06 F5 00 06 E4 95 00 07 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 C3 00 07 80 12 +R 00 00 00 07 29 02 00 01 +T 01 C6 +R 00 00 00 07 +T 01 C6 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 D2 F5 00 06 A3 E0 F5 00 07 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 D8 +R 00 00 00 07 +T 01 D8 85 00 04 82 85 00 05 83 85 00 06 F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 01 E2 00 07 +R 00 00 00 07 29 02 00 01 +T 01 E3 +R 00 00 00 07 +T 01 E3 22 +R 00 00 00 07 diff --git a/device/lib/large/_fs2int.asm b/device/lib/large/_fs2int.asm new file mode 100644 index 00000000..2e6a947d --- /dev/null +++ b/device/lib/large/_fs2int.asm @@ -0,0 +1,439 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:23 2000 + +;-------------------------------------------------------- + .module _fs2int +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2int +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fs2int_sloc0_1_0: + .ds 0x0004 +___fs2int_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fs2int_a1_1_1: + .ds 0x0004 +___fs2int_fl1_1_1: + .ds 0x0004 +___fs2int_exp_1_1: + .ds 0x0002 +___fs2int_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2int$0$0 ==. +; _fs2int.c 73 +; ----------------------------------------- +; function __fs2int +; ----------------------------------------- +___fs2int: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2int.c 0 + push acc + push b + push dph + push dpl + mov dptr,#___fs2int_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fs2int.c 79 + mov dptr,#___fs2int_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fs2int_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fs2int.c 81 + mov dptr,#(___fs2int_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2int.c 82 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00110$ +00102$: +; _fs2int.c 84 + mov dptr,#(___fs2int_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov r2,a + mov a,b + addc a,#0xff + mov r3,a + mov dptr,#___fs2int_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _fs2int.c 85 + mov dptr,#(___fs2int_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + anl ar6,#0x7f + mov r7,#0x00 + mov dptr,#___fs2int_l_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + mov a,#0x80 + orl a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _fs2int.c 87 + mov dptr,#___fs2int_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + clr c +; Peephole 180 changed mov to clr + clr a + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,r3 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2int.c 88 + mov dptr,#(___fs2int_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r7,a + rl a + anl a,#0x01 +; Peephole 140 removed redundant mov + orl a,#0x7f + mov r2,a + rlc a + subb a,acc + mov r0,a + mov dpl,r2 + mov dph,r0 + ljmp 00110$ +00104$: +; _fs2int.c 91 + mov dptr,#___fs2int_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + jb acc.7,00123$ + ljmp 00106$ +00123$: + mov dptr,#___fs2int_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + mov a,#0xe7 + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,r0 + xrl b,#0x80 + subb a,b + jc 00124$ + ljmp 00106$ +00124$: + mov dptr,#___fs2int_l_1_1 + movx a,@dptr + mov ___fs2int_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fs2int_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc0_1_0 + 3),a + mov a,___fs2int_sloc0_1_0 + orl a,(___fs2int_sloc0_1_0 + 1) + orl a,(___fs2int_sloc0_1_0 + 2) + orl a,(___fs2int_sloc0_1_0 + 3) + jnz 00125$ + ljmp 00106$ +00125$: +; _fs2int.c 92 + mov dptr,#___fs2int_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + clr a + subb a,r2 + mov ___fs2int_sloc0_1_0,a + clr a + subb a,r0 + mov (___fs2int_sloc0_1_0 + 1),a + mov dptr,#___fs2int_l_1_1 + movx a,@dptr + mov ___fs2int_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 3),a + mov b,___fs2int_sloc0_1_0 + inc b + mov a,(___fs2int_sloc1_1_0 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2int_sloc1_1_0 + 3) + rrc a + mov (___fs2int_sloc1_1_0 + 3),a + mov a,(___fs2int_sloc1_1_0 + 2) + rrc a + mov (___fs2int_sloc1_1_0 + 2),a + mov a,(___fs2int_sloc1_1_0 + 1) + rrc a + mov (___fs2int_sloc1_1_0 + 1),a + mov a,___fs2int_sloc1_1_0 + rrc a + mov ___fs2int_sloc1_1_0,a +00127$: + djnz b,00126$ + mov dptr,#___fs2int_l_1_1 + mov a,___fs2int_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fs2int_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fs2int_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fs2int_sloc1_1_0 + 3) + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2int.c 94 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00110$ +00107$: +; _fs2int.c 96 + mov dptr,#(___fs2int_fl1_1_1) + movx a,@dptr + mov ___fs2int_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fs2int_sloc1_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + mov dptr,#___fs2int_l_1_1 + movx a,@dptr + mov ___fs2int_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 3),a + clr c + clr a + subb a,___fs2int_sloc1_1_0 + mov ___fs2int_sloc1_1_0,a + clr a + subb a,(___fs2int_sloc1_1_0 + 1) + mov (___fs2int_sloc1_1_0 + 1),a + clr a + subb a,(___fs2int_sloc1_1_0 + 2) + mov (___fs2int_sloc1_1_0 + 2),a + clr a + subb a,(___fs2int_sloc1_1_0 + 3) + mov (___fs2int_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov dptr,#___fs2int_l_1_1 + movx a,@dptr + mov ___fs2int_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2int_sloc1_1_0 + 3),a +00113$: + mov r2,___fs2int_sloc1_1_0 + mov r0,(___fs2int_sloc1_1_0 + 1) + mov dpl,r2 + mov dph,r0 +00110$: + C$_fs2int.c$97$1$1 ==. + XG$__fs2int$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fs2int.cdb b/device/lib/large/_fs2int.cdb new file mode 100644 index 00000000..49cd00e0 --- /dev/null +++ b/device/lib/large/_fs2int.cdb @@ -0,0 +1,2 @@ +M:_fs2int +F:G$__fs2int$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fs2int.rel b/device/lib/large/_fs2int.rel new file mode 100644 index 00000000..dea35528 --- /dev/null +++ b/device/lib/large/_fs2int.rel @@ -0,0 +1,491 @@ +;!FILE _fs2int.asm +XH +H 8 areas 147 global symbols +M _fs2int +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 1E6 flags 20 +S A$_fs2int$396 Def01AC +S A$_fs2int$378 Def0196 +S A$_fs2int$297 Def0121 +S A$_fs2int$288 Def0113 +S A$_fs2int$279 Def0104 +S A$_fs2int$198 Def00A0 +S A$_fs2int$189 Def0092 +S A$_fs2int$397 Def01AD +S A$_fs2int$388 Def01A0 +S A$_fs2int$379 Def0198 +S A$_fs2int$298 Def0123 +S A$_fs2int$289 Def0114 +S A$_fs2int$199 Def00A1 +S A$_fs2int$398 Def01AE +S A$_fs2int$299 Def0125 +S A$_fs2int$399 Def01B0 +S A$_fs2int$80 Def0010 +S A$_fs2int$90 Def001D +S A$_fs2int$81 Def0011 +S A$_fs2int$72 Def0000 +S G$__fs2int$0$0 Def0000 +S A$_fs2int$91 Def001E +S A$_fs2int$82 Def0012 +S A$_fs2int$73 Def0002 +S A$_fs2int$92 Def001F +S A$_fs2int$83 Def0014 +S A$_fs2int$74 Def0004 +S A$_fs2int$93 Def0020 +S A$_fs2int$84 Def0015 +S A$_fs2int$75 Def0006 +S A$_fs2int$94 Def0021 +S A$_fs2int$85 Def0016 +S A$_fs2int$76 Def0008 +S C$_fs2int.c$97$1$1 Def01E5 +S A$_fs2int$95 Def0022 +S A$_fs2int$86 Def0018 +S A$_fs2int$77 Def000B +S A$_fs2int$96 Def0023 +S A$_fs2int$87 Def0019 +S A$_fs2int$78 Def000D +S A$_fs2int$97 Def0024 +S A$_fs2int$79 Def000E +S A$_fs2int$98 Def0025 +S A$_fs2int$89 Def001A +S A$_fs2int$99 Def0026 +S A$_fs2int$100 Def0027 +S A$_fs2int$200 Def00A2 +S A$_fs2int$110 Def0033 +S A$_fs2int$101 Def0028 +S A$_fs2int$210 Def00AC +S A$_fs2int$201 Def00A3 +S A$_fs2int$120 Def003E +S A$_fs2int$111 Def0034 +S A$_fs2int$102 Def002B +S A$_fs2int$400 Def01B1 +S A$_fs2int$310 Def0132 +S A$_fs2int$211 Def00AF +S A$_fs2int$202 Def00A4 +S A$_fs2int$121 Def003F +S A$_fs2int$112 Def0035 +S A$_fs2int$103 Def002C +S A$_fs2int$410 Def01C0 +S A$_fs2int$401 Def01B2 +S A$_fs2int$320 Def0141 +S A$_fs2int$311 Def0133 +S A$_fs2int$302 Def0128 +S A$_fs2int$230 Def00C5 +S A$_fs2int$221 Def00B7 +S A$_fs2int$212 Def00B0 +S A$_fs2int$203 Def00A6 +S A$_fs2int$140 Def0053 +S A$_fs2int$131 Def0048 +S A$_fs2int$122 Def0040 +S A$_fs2int$104 Def002D +S ___fs2int Def0000 +S A$_fs2int$420 Def01CF +S A$_fs2int$411 Def01C2 +S A$_fs2int$402 Def01B4 +S A$_fs2int$330 Def0152 +S A$_fs2int$321 Def0143 +S A$_fs2int$312 Def0135 +S A$_fs2int$303 Def012B +S A$_fs2int$231 Def00C6 +S A$_fs2int$222 Def00B9 +S A$_fs2int$213 Def00B1 +S A$_fs2int$204 Def00A7 +S A$_fs2int$150 Def005D +S A$_fs2int$141 Def0054 +S A$_fs2int$123 Def0041 +S A$_fs2int$114 Def0036 +S A$_fs2int$105 Def002E +S A$_fs2int$421 Def01D1 +S A$_fs2int$412 Def01C4 +S A$_fs2int$403 Def01B5 +S A$_fs2int$340 Def0161 +S A$_fs2int$331 Def0153 +S A$_fs2int$322 Def0144 +S A$_fs2int$313 Def0136 +S A$_fs2int$304 Def012C +S A$_fs2int$250 Def00DA +S A$_fs2int$241 Def00CF +S A$_fs2int$232 Def00C7 +S A$_fs2int$223 Def00BB +S A$_fs2int$214 Def00B2 +S A$_fs2int$205 Def00A8 +S A$_fs2int$160 Def006A +S A$_fs2int$151 Def005E +S A$_fs2int$142 Def0055 +S A$_fs2int$124 Def0042 +S A$_fs2int$115 Def0039 +S A$_fs2int$106 Def002F +S A$_fs2int$431 Def01DD +S A$_fs2int$422 Def01D2 +S A$_fs2int$413 Def01C5 +S A$_fs2int$404 Def01B6 +S A$_fs2int$350 Def0173 +S A$_fs2int$341 Def0163 +S A$_fs2int$332 Def0155 +S A$_fs2int$323 Def0145 +S A$_fs2int$314 Def0137 +S A$_fs2int$305 Def012D +S A$_fs2int$251 Def00DC +S A$_fs2int$242 Def00D0 +S A$_fs2int$233 Def00C8 +S A$_fs2int$224 Def00BE +S A$_fs2int$215 Def00B3 +S A$_fs2int$206 Def00A9 +S A$_fs2int$170 Def0079 +S A$_fs2int$161 Def006D +S A$_fs2int$152 Def0060 +S A$_fs2int$143 Def0056 +S A$_fs2int$125 Def0043 +S A$_fs2int$116 Def003A +S A$_fs2int$107 Def0030 +S A$_fs2int$432 Def01DF +S A$_fs2int$423 Def01D3 +S A$_fs2int$414 Def01C7 +S A$_fs2int$405 Def01B8 +S A$_fs2int$360 Def0181 +S A$_fs2int$351 Def0175 +S A$_fs2int$342 Def0165 +S A$_fs2int$324 Def0147 +S A$_fs2int$315 Def0139 +S A$_fs2int$306 Def012E +S A$_fs2int$270 Def00F6 +S A$_fs2int$261 Def00E8 +S A$_fs2int$252 Def00DE +S A$_fs2int$243 Def00D1 +S A$_fs2int$234 Def00C9 +S A$_fs2int$216 Def00B4 +S A$_fs2int$207 Def00AA +S A$_fs2int$180 Def0088 +S A$_fs2int$171 Def007B +S A$_fs2int$153 Def0061 +S A$_fs2int$144 Def0057 +S A$_fs2int$135 Def004A +S A$_fs2int$126 Def0044 +S A$_fs2int$117 Def003B +S A$_fs2int$108 Def0031 +S A$_fs2int$433 Def01E1 +S A$_fs2int$424 Def01D5 +S A$_fs2int$406 Def01BA +S A$_fs2int$370 Def018A +S A$_fs2int$352 Def0176 +S A$_fs2int$343 Def0166 +S A$_fs2int$334 Def0157 +S A$_fs2int$325 Def0148 +S A$_fs2int$316 Def013C +S A$_fs2int$307 Def012F +S A$_fs2int$280 Def0106 +S A$_fs2int$271 Def00F7 +S A$_fs2int$262 Def00E9 +S A$_fs2int$235 Def00CA +S A$_fs2int$226 Def00C0 +S A$_fs2int$208 Def00AB +S A$_fs2int$190 Def0093 +S A$_fs2int$172 Def007C +S A$_fs2int$163 Def006F +S A$_fs2int$154 Def0063 +S A$_fs2int$145 Def0058 +S A$_fs2int$136 Def004D +S A$_fs2int$127 Def0045 +S A$_fs2int$118 Def003C +S A$_fs2int$109 Def0032 +S A$_fs2int$434 Def01E3 +S A$_fs2int$425 Def01D6 +S A$_fs2int$416 Def01C9 +S A$_fs2int$407 Def01BB +S A$_fs2int$380 Def0199 +S A$_fs2int$371 Def018D +S A$_fs2int$362 Def0182 +S A$_fs2int$353 Def0177 +S A$_fs2int$344 Def0168 +S A$_fs2int$335 Def0159 +S A$_fs2int$326 Def0149 +S A$_fs2int$317 Def013D +S A$_fs2int$308 Def0130 +S A$_fs2int$290 Def0115 +S A$_fs2int$272 Def00F8 +S A$_fs2int$263 Def00EC +S A$_fs2int$245 Def00D3 +S A$_fs2int$236 Def00CB +S A$_fs2int$218 Def00B5 +S A$_fs2int$191 Def0094 +S A$_fs2int$182 Def0089 +S A$_fs2int$173 Def007E +S A$_fs2int$164 Def0070 +S A$_fs2int$155 Def0064 +S A$_fs2int$146 Def0059 +S A$_fs2int$128 Def0046 +S A$_fs2int$119 Def003D +S A$_fs2int$426 Def01D7 +S A$_fs2int$408 Def01BD +S A$_fs2int$390 Def01A2 +S A$_fs2int$372 Def018E +S A$_fs2int$354 Def0179 +S A$_fs2int$345 Def016A +S A$_fs2int$336 Def015B +S A$_fs2int$327 Def014B +S A$_fs2int$318 Def013F +S A$_fs2int$309 Def0131 +S A$_fs2int$291 Def0117 +S A$_fs2int$282 Def0109 +S A$_fs2int$273 Def00FA +S A$_fs2int$255 Def00E1 +S A$_fs2int$246 Def00D5 +S A$_fs2int$237 Def00CC +S A$_fs2int$219 Def00B6 +S A$_fs2int$192 Def0095 +S A$_fs2int$183 Def008C +S A$_fs2int$174 Def0080 +S A$_fs2int$165 Def0071 +S A$_fs2int$156 Def0065 +S A$_fs2int$147 Def005A +S A$_fs2int$129 Def0047 +S A$_fs2int$427 Def01D9 +S A$_fs2int$418 Def01CB +S A$_fs2int$409 Def01BF +S A$_fs2int$391 Def01A5 +S A$_fs2int$382 Def019A +S A$_fs2int$373 Def0190 +S A$_fs2int$355 Def017A +S A$_fs2int$346 Def016B +S A$_fs2int$337 Def015C +S A$_fs2int$328 Def014E +S A$_fs2int$319 Def0140 +S A$_fs2int$292 Def0118 +S A$_fs2int$283 Def010C +S A$_fs2int$265 Def00EF +S A$_fs2int$256 Def00E4 +S A$_fs2int$247 Def00D6 +S A$_fs2int$238 Def00CD +S A$_fs2int$229 Def00C2 +S A$_fs2int$193 Def0096 +S A$_fs2int$184 Def008D +S A$_fs2int$175 Def0081 +S A$_fs2int$166 Def0073 +S A$_fs2int$157 Def0066 +S A$_fs2int$148 Def005B +S A$_fs2int$139 Def0050 +S A$_fs2int$428 Def01DA +S A$_fs2int$419 Def01CE +S A$_fs2int$392 Def01A6 +S A$_fs2int$383 Def019C +S A$_fs2int$374 Def0191 +S A$_fs2int$356 Def017B +S A$_fs2int$338 Def015E +S A$_fs2int$329 Def0150 +S A$_fs2int$293 Def0119 +S A$_fs2int$284 Def010D +S A$_fs2int$275 Def00FB +S A$_fs2int$266 Def00F2 +S A$_fs2int$257 Def00E5 +S A$_fs2int$248 Def00D7 +S A$_fs2int$239 Def00CE +S A$_fs2int$194 Def0097 +S A$_fs2int$185 Def008E +S A$_fs2int$176 Def0084 +S A$_fs2int$167 Def0074 +S A$_fs2int$158 Def0067 +S A$_fs2int$149 Def005C +S A$_fs2int$438 Def01E5 +S A$_fs2int$429 Def01DB +S A$_fs2int$393 Def01A8 +S A$_fs2int$384 Def019D +S A$_fs2int$375 Def0192 +S A$_fs2int$366 Def0184 +S A$_fs2int$357 Def017D +S A$_fs2int$348 Def016D +S A$_fs2int$339 Def0160 +S A$_fs2int$294 Def011B +S A$_fs2int$285 Def010F +S A$_fs2int$276 Def00FD +S A$_fs2int$267 Def00F3 +S A$_fs2int$258 Def00E6 +S A$_fs2int$249 Def00D9 +S A$_fs2int$195 Def009A +S A$_fs2int$186 Def008F +S A$_fs2int$177 Def0085 +S A$_fs2int$168 Def0075 +S A$_fs2int$159 Def0068 +S A$_fs2int$394 Def01A9 +S A$_fs2int$376 Def0194 +S A$_fs2int$367 Def0187 +S A$_fs2int$358 Def017E +S A$_fs2int$349 Def0170 +S A$_fs2int$295 Def011D +S A$_fs2int$286 Def0110 +S A$_fs2int$277 Def00FF +S A$_fs2int$268 Def00F4 +S A$_fs2int$259 Def00E7 +S A$_fs2int$196 Def009C +S A$_fs2int$187 Def0090 +S A$_fs2int$178 Def0086 +S A$_fs2int$169 Def0076 +S A$_fs2int$395 Def01AA +S A$_fs2int$386 Def019F +S A$_fs2int$377 Def0195 +S A$_fs2int$359 Def017F +S A$_fs2int$296 Def011F +S A$_fs2int$287 Def0111 +S A$_fs2int$278 Def0102 +S A$_fs2int$269 Def00F5 +S A$_fs2int$197 Def009F +S A$_fs2int$188 Def0091 +S A$_fs2int$179 Def0087 +S XG$__fs2int$0$0 Def01E5 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 04 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 45 4B 4C 4D 70 06 +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A 90 00 00 02 01 E5 +R 00 00 00 07 00 06 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 5E 8C 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 6C 02 44 FE +R 00 00 00 07 +T 00 6F +R 00 00 00 07 +T 00 6F FB 33 95 E0 FC FD EA 75 F0 00 24 6A FA E5 +R 00 00 00 07 +T 00 7D F0 34 FF FB 90 00 08 EA F0 A3 EB F0 90 +R 00 00 00 07 00 07 00 05 +T 00 8A 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF 53 +R 00 00 00 07 00 02 00 05 +T 00 98 06 7F 7F 00 90 00 0A EA F0 A3 EB F0 74 80 +R 00 00 00 07 00 07 00 05 +T 00 A6 4E A3 F0 A3 EF F0 90 00 08 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 B4 C3 E4 9A 74 80 8B F0 63 F0 80 95 F0 50 1F +R 00 00 00 07 +T 00 C2 +R 00 00 00 07 +T 00 C2 90 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 D0 23 54 01 44 7F FA 33 95 E0 F8 8A 82 88 83 +R 00 00 00 07 +T 00 DE 02 01 E5 +R 00 00 00 07 00 03 00 07 +T 00 E1 +R 00 00 00 07 +T 00 E1 90 00 08 E0 FA A3 E0 F8 20 E7 03 02 01 84 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 00 EF +R 00 00 00 07 +T 00 EF 90 00 08 E0 FA A3 E0 F8 C3 74 E7 9A 74 7F +R 00 00 00 07 00 03 00 05 +T 00 FD 88 F0 63 F0 80 95 F0 40 03 02 01 84 +R 00 00 00 07 00 0C 00 07 +T 01 09 +R 00 00 00 07 +T 01 09 90 00 0A E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 15 F5 00 02 A3 E0 F5 00 03 E5 00 00 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 1E 00 01 45 00 02 45 00 03 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 26 01 84 +R 00 00 00 07 00 02 00 07 +T 01 28 +R 00 00 00 07 +T 01 28 90 00 08 E0 FA A3 E0 F8 C3 E4 9A F5 00 00 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 01 35 E4 98 F5 00 01 90 00 0A E0 F5 00 04 A3 E0 +R 00 00 00 07 29 05 00 01 00 08 00 05 29 0C 00 01 +T 01 41 F5 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 85 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 4C 00 00 F0 05 F0 E5 00 07 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 01 57 +R 00 00 00 07 +T 01 57 A2 D2 E5 00 07 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 01 62 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 69 00 04 13 F5 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 01 6D +R 00 00 00 07 +T 01 6D D5 F0 E7 90 00 0A E5 00 04 F0 A3 E5 00 05 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 01 79 F0 A3 E5 00 06 F0 A3 E5 00 07 F0 80 06 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 01 84 +R 00 00 00 07 +T 01 84 90 00 00 02 01 E5 +R 00 00 00 07 00 06 00 07 +T 01 8A +R 00 00 00 07 +T 01 8A 90 00 04 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 96 F5 00 06 A3 E0 F5 00 07 23 54 01 FA 60 29 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 A2 +R 00 00 00 07 +T 01 A2 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 AE F5 00 06 A3 E0 F5 00 07 C3 E4 95 00 04 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 B9 00 04 E4 95 00 05 F5 00 05 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 C1 00 06 F5 00 06 E4 95 00 07 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 C8 00 07 80 12 +R 00 00 00 07 29 02 00 01 +T 01 CB +R 00 00 00 07 +T 01 CB 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 D7 F5 00 06 A3 E0 F5 00 07 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 DD +R 00 00 00 07 +T 01 DD AA 00 04 A8 00 05 8A 82 88 83 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 01 E5 +R 00 00 00 07 +T 01 E5 22 +R 00 00 00 07 diff --git a/device/lib/large/_fs2long.asm b/device/lib/large/_fs2long.asm new file mode 100644 index 00000000..977b68a3 --- /dev/null +++ b/device/lib/large/_fs2long.asm @@ -0,0 +1,454 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + +;-------------------------------------------------------- + .module _fs2long +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2long +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fs2long_sloc0_1_0: + .ds 0x0004 +___fs2long_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fs2long_a1_1_1: + .ds 0x0004 +___fs2long_fl1_1_1: + .ds 0x0004 +___fs2long_exp_1_1: + .ds 0x0002 +___fs2long_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2long$0$0 ==. +; _fs2long.c 73 +; ----------------------------------------- +; function __fs2long +; ----------------------------------------- +___fs2long: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2long.c 0 + push acc + push b + push dph + push dpl + mov dptr,#___fs2long_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fs2long.c 79 + mov dptr,#___fs2long_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fs2long_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fs2long.c 81 + mov dptr,#(___fs2long_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2long.c 82 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00110$ +00102$: +; _fs2long.c 84 + mov dptr,#(___fs2long_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov r2,a + mov a,b + addc a,#0xff + mov r3,a + mov dptr,#___fs2long_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _fs2long.c 85 + mov dptr,#(___fs2long_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + anl ar6,#0x7f + mov r7,#0x00 + mov dptr,#___fs2long_l_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + mov a,#0x80 + orl a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _fs2long.c 87 + mov dptr,#___fs2long_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + clr c +; Peephole 180 changed mov to clr + clr a + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,r3 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2long.c 88 + mov dptr,#(___fs2long_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r7,a + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov ___fs2long_sloc0_1_0,r2 + mov a,r2 + rlc a + subb a,acc + mov (___fs2long_sloc0_1_0 + 1),a + mov (___fs2long_sloc0_1_0 + 2),a +; Peephole 191 removed redundant mov + mov (___fs2long_sloc0_1_0 + 3),a + mov dpl,___fs2long_sloc0_1_0 + mov dph,(___fs2long_sloc0_1_0 + 1) + mov b,(___fs2long_sloc0_1_0 + 2) + ljmp 00110$ +00104$: +; _fs2long.c 91 + mov dptr,#___fs2long_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + jb acc.7,00123$ + ljmp 00106$ +00123$: + mov dptr,#___fs2long_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + mov a,#0xe7 + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,r0 + xrl b,#0x80 + subb a,b + jc 00124$ + ljmp 00106$ +00124$: + mov dptr,#___fs2long_l_1_1 + movx a,@dptr + mov ___fs2long_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fs2long_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc0_1_0 + 3),a + mov a,___fs2long_sloc0_1_0 + orl a,(___fs2long_sloc0_1_0 + 1) + orl a,(___fs2long_sloc0_1_0 + 2) + orl a,(___fs2long_sloc0_1_0 + 3) + jnz 00125$ + ljmp 00106$ +00125$: +; _fs2long.c 92 + mov dptr,#___fs2long_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + clr a + subb a,r2 + mov ___fs2long_sloc0_1_0,a + clr a + subb a,r0 + mov (___fs2long_sloc0_1_0 + 1),a + mov dptr,#___fs2long_l_1_1 + movx a,@dptr + mov ___fs2long_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 3),a + mov b,___fs2long_sloc0_1_0 + inc b + mov a,(___fs2long_sloc1_1_0 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2long_sloc1_1_0 + 3) + rrc a + mov (___fs2long_sloc1_1_0 + 3),a + mov a,(___fs2long_sloc1_1_0 + 2) + rrc a + mov (___fs2long_sloc1_1_0 + 2),a + mov a,(___fs2long_sloc1_1_0 + 1) + rrc a + mov (___fs2long_sloc1_1_0 + 1),a + mov a,___fs2long_sloc1_1_0 + rrc a + mov ___fs2long_sloc1_1_0,a +00127$: + djnz b,00126$ + mov dptr,#___fs2long_l_1_1 + mov a,___fs2long_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fs2long_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fs2long_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fs2long_sloc1_1_0 + 3) + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2long.c 94 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00110$ +00107$: +; _fs2long.c 96 + mov dptr,#(___fs2long_fl1_1_1) + movx a,@dptr + mov ___fs2long_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fs2long_sloc1_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + mov dptr,#___fs2long_l_1_1 + movx a,@dptr + mov ___fs2long_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 3),a + clr c + clr a + subb a,___fs2long_sloc1_1_0 + mov ___fs2long_sloc1_1_0,a + clr a + subb a,(___fs2long_sloc1_1_0 + 1) + mov (___fs2long_sloc1_1_0 + 1),a + clr a + subb a,(___fs2long_sloc1_1_0 + 2) + mov (___fs2long_sloc1_1_0 + 2),a + clr a + subb a,(___fs2long_sloc1_1_0 + 3) + mov (___fs2long_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov dptr,#___fs2long_l_1_1 + movx a,@dptr + mov ___fs2long_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2long_sloc1_1_0 + 3),a +00113$: + mov dpl,___fs2long_sloc1_1_0 + mov dph,(___fs2long_sloc1_1_0 + 1) + mov b,(___fs2long_sloc1_1_0 + 2) + mov a,(___fs2long_sloc1_1_0 + 3) +00110$: + C$_fs2long.c$97$1$1 ==. + XG$__fs2long$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fs2long.cdb b/device/lib/large/_fs2long.cdb new file mode 100644 index 00000000..8e9563e8 --- /dev/null +++ b/device/lib/large/_fs2long.cdb @@ -0,0 +1,2 @@ +M:_fs2long +F:G$__fs2long$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fs2long.rel b/device/lib/large/_fs2long.rel new file mode 100644 index 00000000..a0f1cd7f --- /dev/null +++ b/device/lib/large/_fs2long.rel @@ -0,0 +1,508 @@ +;!FILE _fs2long.asm +XH +H 8 areas 152 global symbols +M _fs2long +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 1FF flags 20 +S A$_fs2long$100 Def0027 +S A$_fs2long$200 Def009E +S A$_fs2long$110 Def0033 +S A$_fs2long$101 Def0028 +S A$_fs2long$300 Def0127 +S A$_fs2long$210 Def00AC +S A$_fs2long$201 Def00A0 +S A$_fs2long$120 Def003E +S A$_fs2long$111 Def0034 +S A$_fs2long$102 Def002B +S A$_fs2long$301 Def0129 +S A$_fs2long$220 Def00B7 +S A$_fs2long$211 Def00AD +S A$_fs2long$202 Def00A3 +S A$_fs2long$121 Def003F +S A$_fs2long$112 Def0035 +S A$_fs2long$103 Def002C +S A$_fs2long$410 Def01C0 +S A$_fs2long$401 Def01B5 +S A$_fs2long$320 Def0144 +S A$_fs2long$302 Def012A +S A$_fs2long$221 Def00B8 +S A$_fs2long$212 Def00AE +S A$_fs2long$203 Def00A4 +S A$_fs2long$140 Def004F +S A$_fs2long$131 Def0048 +S A$_fs2long$122 Def0040 +S A$_fs2long$104 Def002D +S ___fs2long Def0000 +S A$_fs2long$420 Def01CE +S A$_fs2long$411 Def01C2 +S A$_fs2long$330 Def0153 +S A$_fs2long$321 Def0145 +S A$_fs2long$312 Def013A +S A$_fs2long$303 Def012B +S A$_fs2long$240 Def00CE +S A$_fs2long$231 Def00C4 +S A$_fs2long$213 Def00AF +S A$_fs2long$204 Def00A5 +S A$_fs2long$150 Def005C +S A$_fs2long$141 Def0051 +S A$_fs2long$123 Def0041 +S A$_fs2long$114 Def0036 +S A$_fs2long$105 Def002E +S A$_fs2long$421 Def01D0 +S A$_fs2long$412 Def01C3 +S A$_fs2long$403 Def01B6 +S A$_fs2long$340 Def0164 +S A$_fs2long$331 Def0155 +S A$_fs2long$322 Def0147 +S A$_fs2long$313 Def013D +S A$_fs2long$304 Def012D +S A$_fs2long$250 Def00D8 +S A$_fs2long$241 Def00CF +S A$_fs2long$223 Def00B9 +S A$_fs2long$205 Def00A6 +S A$_fs2long$160 Def0068 +S A$_fs2long$151 Def005D +S A$_fs2long$124 Def0042 +S A$_fs2long$115 Def0039 +S A$_fs2long$106 Def002F +S A$_fs2long$440 Def01EC +S A$_fs2long$431 Def01DF +S A$_fs2long$422 Def01D1 +S A$_fs2long$413 Def01C4 +S A$_fs2long$350 Def0173 +S A$_fs2long$341 Def0165 +S A$_fs2long$332 Def0156 +S A$_fs2long$323 Def0148 +S A$_fs2long$314 Def013E +S A$_fs2long$305 Def012F +S A$_fs2long$260 Def00EA +S A$_fs2long$251 Def00DB +S A$_fs2long$242 Def00D0 +S A$_fs2long$224 Def00BA +S A$_fs2long$215 Def00B0 +S A$_fs2long$206 Def00A7 +S A$_fs2long$170 Def0075 +S A$_fs2long$161 Def0069 +S A$_fs2long$152 Def005E +S A$_fs2long$125 Def0043 +S A$_fs2long$116 Def003A +S A$_fs2long$107 Def0030 +S A$_fs2long$441 Def01ED +S A$_fs2long$423 Def01D3 +S A$_fs2long$414 Def01C6 +S A$_fs2long$405 Def01B8 +S A$_fs2long$360 Def0185 +S A$_fs2long$351 Def0175 +S A$_fs2long$342 Def0167 +S A$_fs2long$333 Def0157 +S A$_fs2long$324 Def0149 +S A$_fs2long$315 Def013F +S A$_fs2long$306 Def0131 +S A$_fs2long$261 Def00ED +S A$_fs2long$252 Def00DD +S A$_fs2long$243 Def00D1 +S A$_fs2long$234 Def00C6 +S A$_fs2long$216 Def00B3 +S A$_fs2long$207 Def00A8 +S A$_fs2long$180 Def0085 +S A$_fs2long$171 Def0077 +S A$_fs2long$162 Def006A +S A$_fs2long$153 Def005F +S A$_fs2long$144 Def0054 +S A$_fs2long$126 Def0044 +S A$_fs2long$117 Def003B +S A$_fs2long$108 Def0031 +S A$_fs2long$442 Def01EF +S A$_fs2long$433 Def01E1 +S A$_fs2long$424 Def01D5 +S A$_fs2long$415 Def01C7 +S A$_fs2long$406 Def01BB +S A$_fs2long$370 Def0193 +S A$_fs2long$361 Def0187 +S A$_fs2long$352 Def0177 +S A$_fs2long$334 Def0159 +S A$_fs2long$325 Def014B +S A$_fs2long$316 Def0140 +S A$_fs2long$307 Def0133 +S A$_fs2long$280 Def0108 +S A$_fs2long$271 Def00FA +S A$_fs2long$262 Def00F0 +S A$_fs2long$253 Def00DE +S A$_fs2long$244 Def00D2 +S A$_fs2long$235 Def00C9 +S A$_fs2long$226 Def00BB +S A$_fs2long$217 Def00B4 +S A$_fs2long$208 Def00AA +S A$_fs2long$190 Def0092 +S A$_fs2long$181 Def0088 +S A$_fs2long$172 Def0078 +S A$_fs2long$163 Def006B +S A$_fs2long$154 Def0060 +S A$_fs2long$145 Def0057 +S A$_fs2long$127 Def0045 +S A$_fs2long$118 Def003C +S A$_fs2long$109 Def0032 +S A$_fs2long$443 Def01F0 +S A$_fs2long$434 Def01E4 +S A$_fs2long$425 Def01D6 +S A$_fs2long$416 Def01C8 +S A$_fs2long$407 Def01BC +S A$_fs2long$380 Def0199 +S A$_fs2long$362 Def0188 +S A$_fs2long$353 Def0178 +S A$_fs2long$344 Def0169 +S A$_fs2long$335 Def015A +S A$_fs2long$326 Def014E +S A$_fs2long$317 Def0141 +S A$_fs2long$308 Def0135 +S A$_fs2long$290 Def0118 +S A$_fs2long$281 Def0109 +S A$_fs2long$272 Def00FB +S A$_fs2long$254 Def00DF +S A$_fs2long$236 Def00CA +S A$_fs2long$227 Def00BD +S A$_fs2long$218 Def00B5 +S A$_fs2long$209 Def00AB +S A$_fs2long$191 Def0093 +S A$_fs2long$182 Def0089 +S A$_fs2long$173 Def0079 +S A$_fs2long$164 Def006C +S A$_fs2long$155 Def0061 +S A$_fs2long$146 Def0058 +S A$_fs2long$137 Def004A +S A$_fs2long$128 Def0046 +S A$_fs2long$119 Def003D +S A$_fs2long$453 Def01FE +S A$_fs2long$444 Def01F1 +S A$_fs2long$435 Def01E5 +S A$_fs2long$426 Def01D8 +S A$_fs2long$417 Def01CA +S A$_fs2long$408 Def01BE +S A$_fs2long$390 Def01A8 +S A$_fs2long$381 Def019B +S A$_fs2long$372 Def0194 +S A$_fs2long$363 Def0189 +S A$_fs2long$354 Def017A +S A$_fs2long$345 Def016B +S A$_fs2long$336 Def015B +S A$_fs2long$327 Def014F +S A$_fs2long$318 Def0142 +S A$_fs2long$309 Def0137 +S A$_fs2long$282 Def010A +S A$_fs2long$273 Def00FE +S A$_fs2long$255 Def00E1 +S A$_fs2long$246 Def00D3 +S A$_fs2long$237 Def00CB +S A$_fs2long$228 Def00BF +S A$_fs2long$219 Def00B6 +S A$_fs2long$192 Def0094 +S A$_fs2long$183 Def008A +S A$_fs2long$174 Def007A +S A$_fs2long$165 Def006E +S A$_fs2long$156 Def0062 +S A$_fs2long$147 Def0059 +S A$_fs2long$138 Def004B +S A$_fs2long$129 Def0047 +S A$_fs2long$436 Def01E7 +S A$_fs2long$427 Def01DA +S A$_fs2long$418 Def01CB +S A$_fs2long$409 Def01BF +S A$_fs2long$391 Def01AA +S A$_fs2long$382 Def019D +S A$_fs2long$364 Def018B +S A$_fs2long$355 Def017C +S A$_fs2long$346 Def016D +S A$_fs2long$337 Def015D +S A$_fs2long$328 Def0151 +S A$_fs2long$319 Def0143 +S A$_fs2long$292 Def011B +S A$_fs2long$283 Def010C +S A$_fs2long$265 Def00F3 +S A$_fs2long$256 Def00E3 +S A$_fs2long$247 Def00D4 +S A$_fs2long$238 Def00CC +S A$_fs2long$229 Def00C2 +S A$_fs2long$193 Def0095 +S A$_fs2long$184 Def008B +S A$_fs2long$175 Def007D +S A$_fs2long$166 Def0071 +S A$_fs2long$157 Def0064 +S A$_fs2long$148 Def005A +S A$_fs2long$139 Def004D +S A$_fs2long$446 Def01F3 +S A$_fs2long$437 Def01E8 +S A$_fs2long$428 Def01DB +S A$_fs2long$419 Def01CC +S A$_fs2long$392 Def01AB +S A$_fs2long$365 Def018C +S A$_fs2long$356 Def017D +S A$_fs2long$347 Def016E +S A$_fs2long$338 Def0160 +S A$_fs2long$329 Def0152 +S A$_fs2long$293 Def011E +S A$_fs2long$275 Def0101 +S A$_fs2long$266 Def00F6 +S A$_fs2long$248 Def00D5 +S A$_fs2long$239 Def00CD +S A$_fs2long$194 Def0096 +S A$_fs2long$185 Def008C +S A$_fs2long$176 Def007F +S A$_fs2long$158 Def0065 +S A$_fs2long$149 Def005B +S A$_fs2long$447 Def01F6 +S A$_fs2long$438 Def01E9 +S A$_fs2long$429 Def01DD +S A$_fs2long$393 Def01AC +S A$_fs2long$366 Def018D +S A$_fs2long$348 Def0170 +S A$_fs2long$339 Def0162 +S A$_fs2long$294 Def011F +S A$_fs2long$285 Def010D +S A$_fs2long$276 Def0104 +S A$_fs2long$267 Def00F7 +S A$_fs2long$258 Def00E5 +S A$_fs2long$249 Def00D7 +S A$_fs2long$195 Def0097 +S A$_fs2long$177 Def0080 +S A$_fs2long$168 Def0073 +S A$_fs2long$159 Def0067 +S A$_fs2long$448 Def01F9 +S A$_fs2long$439 Def01EB +S A$_fs2long$394 Def01AE +S A$_fs2long$385 Def01A0 +S A$_fs2long$367 Def018F +S A$_fs2long$358 Def017F +S A$_fs2long$349 Def0172 +S A$_fs2long$295 Def0121 +S A$_fs2long$286 Def010F +S A$_fs2long$277 Def0105 +S A$_fs2long$268 Def00F8 +S A$_fs2long$259 Def00E7 +S A$_fs2long$196 Def0098 +S A$_fs2long$187 Def008D +S A$_fs2long$178 Def0082 +S A$_fs2long$169 Def0074 +S A$_fs2long$449 Def01FC +S A$_fs2long$395 Def01AF +S A$_fs2long$386 Def01A3 +S A$_fs2long$368 Def0190 +S A$_fs2long$359 Def0182 +S A$_fs2long$296 Def0122 +S A$_fs2long$287 Def0111 +S A$_fs2long$278 Def0106 +S A$_fs2long$269 Def00F9 +S A$_fs2long$197 Def0099 +S A$_fs2long$188 Def0090 +S A$_fs2long$179 Def0084 +S XG$__fs2long$0$0 Def01FE +S A$_fs2long$387 Def01A4 +S A$_fs2long$378 Def0196 +S A$_fs2long$369 Def0191 +S A$_fs2long$297 Def0123 +S A$_fs2long$288 Def0114 +S A$_fs2long$279 Def0107 +S A$_fs2long$198 Def009A +S A$_fs2long$189 Def0091 +S A$_fs2long$397 Def01B0 +S A$_fs2long$388 Def01A6 +S A$_fs2long$379 Def0197 +S A$_fs2long$298 Def0125 +S A$_fs2long$289 Def0116 +S A$_fs2long$199 Def009B +S A$_fs2long$398 Def01B2 +S A$_fs2long$389 Def01A7 +S A$_fs2long$299 Def0126 +S A$_fs2long$399 Def01B3 +S A$_fs2long$80 Def0010 +S A$_fs2long$90 Def001D +S A$_fs2long$81 Def0011 +S A$_fs2long$72 Def0000 +S G$__fs2long$0$0 Def0000 +S A$_fs2long$91 Def001E +S A$_fs2long$82 Def0012 +S A$_fs2long$73 Def0002 +S A$_fs2long$92 Def001F +S A$_fs2long$83 Def0014 +S A$_fs2long$74 Def0004 +S A$_fs2long$93 Def0020 +S A$_fs2long$84 Def0015 +S A$_fs2long$75 Def0006 +S A$_fs2long$94 Def0021 +S A$_fs2long$85 Def0016 +S A$_fs2long$76 Def0008 +S C$_fs2long.c$97$1$1 Def01FE +S A$_fs2long$95 Def0022 +S A$_fs2long$86 Def0018 +S A$_fs2long$77 Def000B +S A$_fs2long$96 Def0023 +S A$_fs2long$87 Def0019 +S A$_fs2long$78 Def000D +S A$_fs2long$97 Def0024 +S A$_fs2long$79 Def000E +S A$_fs2long$98 Def0025 +S A$_fs2long$89 Def001A +S A$_fs2long$99 Def0026 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 04 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 45 4B 4C 4D 70 0A +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A E4 F5 82 F5 83 F5 F0 02 01 FE +R 00 00 00 07 00 0A 00 07 +T 00 54 +R 00 00 00 07 +T 00 54 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 62 8C 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 70 02 44 FE +R 00 00 00 07 +T 00 73 +R 00 00 00 07 +T 00 73 FB 33 95 E0 FC FD EA 75 F0 00 24 6A FA E5 +R 00 00 00 07 +T 00 81 F0 34 FF FB 90 00 08 EA F0 A3 EB F0 90 +R 00 00 00 07 00 07 00 05 +T 00 8E 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF 53 +R 00 00 00 07 00 02 00 05 +T 00 9C 06 7F 7F 00 90 00 0A EA F0 A3 EB F0 74 80 +R 00 00 00 07 00 07 00 05 +T 00 AA 4E A3 F0 A3 EF F0 90 00 08 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 B8 C3 E4 9A 74 80 8B F0 63 F0 80 95 F0 50 2D +R 00 00 00 07 +T 00 C6 +R 00 00 00 07 +T 00 C6 90 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 D4 23 54 01 FA 43 02 7F 8A 00 00 EA 33 95 E0 +R 00 00 00 07 29 0A 00 01 +T 00 E1 F5 00 01 F5 00 02 F5 00 03 85 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 E8 00 00 82 85 00 01 83 85 00 02 F0 02 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 F1 01 FE +R 00 00 00 07 00 02 00 07 +T 00 F3 +R 00 00 00 07 +T 00 F3 90 00 08 E0 FA A3 E0 F8 20 E7 03 02 01 96 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 01 01 +R 00 00 00 07 +T 01 01 90 00 08 E0 FA A3 E0 F8 C3 74 E7 9A 74 7F +R 00 00 00 07 00 03 00 05 +T 01 0F 88 F0 63 F0 80 95 F0 40 03 02 01 96 +R 00 00 00 07 00 0C 00 07 +T 01 1B +R 00 00 00 07 +T 01 1B 90 00 0A E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 27 F5 00 02 A3 E0 F5 00 03 E5 00 00 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 30 00 01 45 00 02 45 00 03 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 38 01 96 +R 00 00 00 07 00 02 00 07 +T 01 3A +R 00 00 00 07 +T 01 3A 90 00 08 E0 FA A3 E0 F8 C3 E4 9A F5 00 00 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 01 47 E4 98 F5 00 01 90 00 0A E0 F5 00 04 A3 E0 +R 00 00 00 07 29 05 00 01 00 08 00 05 29 0C 00 01 +T 01 53 F5 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 85 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 5E 00 00 F0 05 F0 E5 00 07 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 01 69 +R 00 00 00 07 +T 01 69 A2 D2 E5 00 07 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 01 74 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 7B 00 04 13 F5 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 01 7F +R 00 00 00 07 +T 01 7F D5 F0 E7 90 00 0A E5 00 04 F0 A3 E5 00 05 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 01 8B F0 A3 E5 00 06 F0 A3 E5 00 07 F0 80 0A +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 01 96 +R 00 00 00 07 +T 01 96 E4 F5 82 F5 83 F5 F0 02 01 FE +R 00 00 00 07 00 0A 00 07 +T 01 A0 +R 00 00 00 07 +T 01 A0 90 00 04 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 AC F5 00 06 A3 E0 F5 00 07 23 54 01 FA 60 29 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 B8 +R 00 00 00 07 +T 01 B8 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 C4 F5 00 06 A3 E0 F5 00 07 C3 E4 95 00 04 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 CF 00 04 E4 95 00 05 F5 00 05 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 D7 00 06 F5 00 06 E4 95 00 07 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 DE 00 07 80 12 +R 00 00 00 07 29 02 00 01 +T 01 E1 +R 00 00 00 07 +T 01 E1 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 ED F5 00 06 A3 E0 F5 00 07 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 F3 +R 00 00 00 07 +T 01 F3 85 00 04 82 85 00 05 83 85 00 06 F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 01 FD 00 07 +R 00 00 00 07 29 02 00 01 +T 01 FE +R 00 00 00 07 +T 01 FE 22 +R 00 00 00 07 diff --git a/device/lib/large/_fs2uchar.asm b/device/lib/large/_fs2uchar.asm new file mode 100644 index 00000000..f509a635 --- /dev/null +++ b/device/lib/large/_fs2uchar.asm @@ -0,0 +1,422 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + +;-------------------------------------------------------- + .module _fs2uchar +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2uchar +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fs2uchar_sloc0_1_0: + .ds 0x0004 +___fs2uchar_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fs2uchar_a1_1_1: + .ds 0x0004 +___fs2uchar_fl1_1_1: + .ds 0x0004 +___fs2uchar_exp_1_1: + .ds 0x0002 +___fs2uchar_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2uchar$0$0 ==. +; _fs2uchar.c 73 +; ----------------------------------------- +; function __fs2uchar +; ----------------------------------------- +___fs2uchar: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2uchar.c 0 + push acc + push b + push dph + push dpl + mov dptr,#___fs2uchar_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fs2uchar.c 79 + mov dptr,#___fs2uchar_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fs2uchar_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fs2uchar.c 81 + mov dptr,#(___fs2uchar_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2uchar.c 82 + mov dpl,#0x00 + ljmp 00110$ +00102$: +; _fs2uchar.c 84 + mov dptr,#(___fs2uchar_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov r2,a + mov a,b + addc a,#0xff + mov r3,a + mov dptr,#___fs2uchar_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _fs2uchar.c 85 + mov dptr,#(___fs2uchar_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + anl ar6,#0x7f + mov r7,#0x00 + mov dptr,#___fs2uchar_l_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + mov a,#0x80 + orl a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _fs2uchar.c 87 + mov dptr,#___fs2uchar_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + clr c +; Peephole 180 changed mov to clr + clr a + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,r3 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2uchar.c 88 + mov dptr,#(___fs2uchar_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r7,a + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov dpl,r2 + ljmp 00110$ +00104$: +; _fs2uchar.c 91 + mov dptr,#___fs2uchar_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + jb acc.7,00123$ + ljmp 00106$ +00123$: + mov dptr,#___fs2uchar_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + mov a,#0xe7 + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,r0 + xrl b,#0x80 + subb a,b + jc 00124$ + ljmp 00106$ +00124$: + mov dptr,#___fs2uchar_l_1_1 + movx a,@dptr + mov ___fs2uchar_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc0_1_0 + 3),a + mov a,___fs2uchar_sloc0_1_0 + orl a,(___fs2uchar_sloc0_1_0 + 1) + orl a,(___fs2uchar_sloc0_1_0 + 2) + orl a,(___fs2uchar_sloc0_1_0 + 3) + jnz 00125$ + ljmp 00106$ +00125$: +; _fs2uchar.c 92 + mov dptr,#___fs2uchar_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + clr a + subb a,r2 + mov ___fs2uchar_sloc0_1_0,a + clr a + subb a,r0 + mov (___fs2uchar_sloc0_1_0 + 1),a + mov dptr,#___fs2uchar_l_1_1 + movx a,@dptr + mov ___fs2uchar_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 3),a + mov b,___fs2uchar_sloc0_1_0 + inc b + mov a,(___fs2uchar_sloc1_1_0 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2uchar_sloc1_1_0 + 3) + rrc a + mov (___fs2uchar_sloc1_1_0 + 3),a + mov a,(___fs2uchar_sloc1_1_0 + 2) + rrc a + mov (___fs2uchar_sloc1_1_0 + 2),a + mov a,(___fs2uchar_sloc1_1_0 + 1) + rrc a + mov (___fs2uchar_sloc1_1_0 + 1),a + mov a,___fs2uchar_sloc1_1_0 + rrc a + mov ___fs2uchar_sloc1_1_0,a +00127$: + djnz b,00126$ + mov dptr,#___fs2uchar_l_1_1 + mov a,___fs2uchar_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fs2uchar_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fs2uchar_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fs2uchar_sloc1_1_0 + 3) + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2uchar.c 94 + mov dpl,#0x00 + ljmp 00110$ +00107$: +; _fs2uchar.c 96 + mov dptr,#(___fs2uchar_fl1_1_1) + movx a,@dptr + mov ___fs2uchar_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fs2uchar_sloc1_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + mov dptr,#___fs2uchar_l_1_1 + movx a,@dptr + mov ___fs2uchar_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc1_1_0 + 3),a + mov r2,___fs2uchar_sloc1_1_0 + clr c + clr a + subb a,r2 + mov ___fs2uchar_sloc1_1_0,a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov dptr,#___fs2uchar_l_1_1 + movx a,@dptr + mov ___fs2uchar_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uchar_sloc0_1_0 + 3),a + mov ___fs2uchar_sloc1_1_0,___fs2uchar_sloc0_1_0 +00113$: + mov dpl,___fs2uchar_sloc1_1_0 +00110$: + C$_fs2uchar.c$97$1$1 ==. + XG$__fs2uchar$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fs2uchar.cdb b/device/lib/large/_fs2uchar.cdb new file mode 100644 index 00000000..c8846cbb --- /dev/null +++ b/device/lib/large/_fs2uchar.cdb @@ -0,0 +1,2 @@ +M:_fs2uchar +F:G$__fs2uchar$0$0({2}DF,SC:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_fs2uchar.rel b/device/lib/large/_fs2uchar.rel new file mode 100644 index 00000000..d9156b1e --- /dev/null +++ b/device/lib/large/_fs2uchar.rel @@ -0,0 +1,473 @@ +;!FILE _fs2uchar.asm +XH +H 8 areas 139 global symbols +M _fs2uchar +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 1D1 flags 20 +S A$_fs2uchar$415 Def01CA +S A$_fs2uchar$406 Def01BE +S A$_fs2uchar$370 Def0190 +S A$_fs2uchar$352 Def0179 +S A$_fs2uchar$343 Def016B +S A$_fs2uchar$334 Def015C +S A$_fs2uchar$325 Def014E +S A$_fs2uchar$316 Def013F +S A$_fs2uchar$307 Def0131 +S A$_fs2uchar$280 Def010B +S A$_fs2uchar$271 Def00FA +S A$_fs2uchar$262 Def00EF +S A$_fs2uchar$253 Def00E2 +S A$_fs2uchar$244 Def00D4 +S A$_fs2uchar$235 Def00CB +S A$_fs2uchar$217 Def00B5 +S A$_fs2uchar$190 Def0094 +S A$_fs2uchar$181 Def0089 +S A$_fs2uchar$172 Def007E +S A$_fs2uchar$163 Def0070 +S A$_fs2uchar$154 Def0064 +S A$_fs2uchar$145 Def0059 +S A$_fs2uchar$127 Def0045 +S A$_fs2uchar$118 Def003C +S A$_fs2uchar$109 Def0032 +S A$_fs2uchar$407 Def01BF +S A$_fs2uchar$371 Def0191 +S A$_fs2uchar$353 Def017A +S A$_fs2uchar$344 Def016E +S A$_fs2uchar$335 Def015E +S A$_fs2uchar$326 Def0150 +S A$_fs2uchar$317 Def0140 +S A$_fs2uchar$308 Def0132 +S A$_fs2uchar$290 Def011A +S A$_fs2uchar$281 Def010C +S A$_fs2uchar$272 Def00FD +S A$_fs2uchar$263 Def00F0 +S A$_fs2uchar$245 Def00D7 +S A$_fs2uchar$236 Def00CC +S A$_fs2uchar$218 Def00B6 +S A$_fs2uchar$209 Def00AC +S A$_fs2uchar$191 Def0095 +S A$_fs2uchar$182 Def008C +S A$_fs2uchar$173 Def0080 +S A$_fs2uchar$164 Def0071 +S A$_fs2uchar$155 Def0065 +S A$_fs2uchar$146 Def005A +S A$_fs2uchar$128 Def0046 +S A$_fs2uchar$119 Def003D +S A$_fs2uchar$417 Def01CD +S A$_fs2uchar$408 Def01C0 +S A$_fs2uchar$390 Def01A8 +S A$_fs2uchar$381 Def019B +S A$_fs2uchar$372 Def0193 +S A$_fs2uchar$363 Def0185 +S A$_fs2uchar$354 Def017C +S A$_fs2uchar$345 Def0170 +S A$_fs2uchar$336 Def0160 +S A$_fs2uchar$318 Def0142 +S A$_fs2uchar$309 Def0134 +S A$_fs2uchar$291 Def011C +S A$_fs2uchar$282 Def010E +S A$_fs2uchar$273 Def00FF +S A$_fs2uchar$264 Def00F1 +S A$_fs2uchar$255 Def00E3 +S A$_fs2uchar$246 Def00D9 +S A$_fs2uchar$237 Def00CD +S A$_fs2uchar$228 Def00C2 +S A$_fs2uchar$192 Def0096 +S A$_fs2uchar$183 Def008D +S A$_fs2uchar$174 Def0081 +S A$_fs2uchar$165 Def0073 +S A$_fs2uchar$156 Def0066 +S A$_fs2uchar$147 Def005B +S A$_fs2uchar$138 Def0050 +S A$_fs2uchar$129 Def0047 +S A$_fs2uchar$409 Def01C2 +S A$_fs2uchar$391 Def01A9 +S A$_fs2uchar$373 Def0194 +S A$_fs2uchar$364 Def0188 +S A$_fs2uchar$346 Def0171 +S A$_fs2uchar$337 Def0161 +S A$_fs2uchar$328 Def0152 +S A$_fs2uchar$319 Def0143 +S A$_fs2uchar$292 Def011E +S A$_fs2uchar$283 Def010F +S A$_fs2uchar$274 Def0101 +S A$_fs2uchar$265 Def00F2 +S A$_fs2uchar$256 Def00E4 +S A$_fs2uchar$238 Def00CE +S A$_fs2uchar$229 Def00C5 +S A$_fs2uchar$193 Def0097 +S A$_fs2uchar$184 Def008E +S A$_fs2uchar$175 Def0084 +S A$_fs2uchar$166 Def0074 +S A$_fs2uchar$157 Def0067 +S A$_fs2uchar$148 Def005C +S A$_fs2uchar$139 Def0053 +S A$_fs2uchar$392 Def01AB +S A$_fs2uchar$383 Def019D +S A$_fs2uchar$365 Def0189 +S A$_fs2uchar$356 Def017D +S A$_fs2uchar$347 Def0172 +S A$_fs2uchar$338 Def0163 +S A$_fs2uchar$329 Def0154 +S A$_fs2uchar$293 Def0120 +S A$_fs2uchar$284 Def0110 +S A$_fs2uchar$266 Def00F3 +S A$_fs2uchar$257 Def00E7 +S A$_fs2uchar$194 Def009A +S A$_fs2uchar$185 Def008F +S A$_fs2uchar$176 Def0085 +S A$_fs2uchar$167 Def0075 +S A$_fs2uchar$158 Def0068 +S A$_fs2uchar$149 Def005D +S A$_fs2uchar$393 Def01AC +S A$_fs2uchar$384 Def01A0 +S A$_fs2uchar$375 Def0195 +S A$_fs2uchar$366 Def018B +S A$_fs2uchar$348 Def0174 +S A$_fs2uchar$339 Def0165 +S A$_fs2uchar$285 Def0112 +S A$_fs2uchar$276 Def0104 +S A$_fs2uchar$267 Def00F5 +S A$_fs2uchar$249 Def00DC +S A$_fs2uchar$195 Def009C +S A$_fs2uchar$186 Def0090 +S A$_fs2uchar$177 Def0086 +S A$_fs2uchar$168 Def0076 +S A$_fs2uchar$159 Def006A +S A$_fs2uchar$394 Def01AD +S A$_fs2uchar$385 Def01A1 +S A$_fs2uchar$376 Def0197 +S A$_fs2uchar$367 Def018C +S A$_fs2uchar$349 Def0175 +S A$_fs2uchar$286 Def0113 +S A$_fs2uchar$277 Def0107 +S A$_fs2uchar$259 Def00EA +S A$_fs2uchar$196 Def009F +S A$_fs2uchar$187 Def0091 +S A$_fs2uchar$178 Def0087 +S A$_fs2uchar$169 Def0079 +S A$_fs2uchar$395 Def01AF +S A$_fs2uchar$386 Def01A3 +S A$_fs2uchar$377 Def0198 +S A$_fs2uchar$368 Def018D +S A$_fs2uchar$359 Def017F +S A$_fs2uchar$296 Def0123 +S A$_fs2uchar$287 Def0114 +S A$_fs2uchar$278 Def0108 +S A$_fs2uchar$269 Def00F6 +S A$_fs2uchar$197 Def00A0 +S A$_fs2uchar$188 Def0092 +S A$_fs2uchar$179 Def0088 +S XG$__fs2uchar$0$0 Def01D0 +S A$_fs2uchar$396 Def01B1 +S A$_fs2uchar$387 Def01A4 +S A$_fs2uchar$369 Def018F +S A$_fs2uchar$297 Def0126 +S A$_fs2uchar$288 Def0116 +S A$_fs2uchar$279 Def010A +S A$_fs2uchar$198 Def00A1 +S A$_fs2uchar$189 Def0093 +S A$_fs2uchar$397 Def01B2 +S A$_fs2uchar$388 Def01A5 +S A$_fs2uchar$379 Def019A +S A$_fs2uchar$298 Def0127 +S A$_fs2uchar$289 Def0118 +S A$_fs2uchar$199 Def00A2 +S A$_fs2uchar$398 Def01B3 +S A$_fs2uchar$389 Def01A7 +S A$_fs2uchar$299 Def0128 +S A$_fs2uchar$399 Def01B4 +S A$_fs2uchar$80 Def0010 +S A$_fs2uchar$90 Def001D +S A$_fs2uchar$81 Def0011 +S A$_fs2uchar$72 Def0000 +S G$__fs2uchar$0$0 Def0000 +S A$_fs2uchar$91 Def001E +S A$_fs2uchar$82 Def0012 +S A$_fs2uchar$73 Def0002 +S A$_fs2uchar$92 Def001F +S A$_fs2uchar$83 Def0014 +S A$_fs2uchar$74 Def0004 +S A$_fs2uchar$93 Def0020 +S A$_fs2uchar$84 Def0015 +S A$_fs2uchar$75 Def0006 +S A$_fs2uchar$94 Def0021 +S A$_fs2uchar$85 Def0016 +S A$_fs2uchar$76 Def0008 +S C$_fs2uchar.c$97$1$1 Def01D0 +S A$_fs2uchar$95 Def0022 +S A$_fs2uchar$86 Def0018 +S A$_fs2uchar$77 Def000B +S A$_fs2uchar$96 Def0023 +S A$_fs2uchar$87 Def0019 +S A$_fs2uchar$78 Def000D +S A$_fs2uchar$97 Def0024 +S A$_fs2uchar$79 Def000E +S A$_fs2uchar$98 Def0025 +S A$_fs2uchar$89 Def001A +S A$_fs2uchar$99 Def0026 +S A$_fs2uchar$100 Def0027 +S A$_fs2uchar$200 Def00A3 +S A$_fs2uchar$110 Def0033 +S A$_fs2uchar$101 Def0028 +S A$_fs2uchar$300 Def0129 +S A$_fs2uchar$210 Def00AF +S A$_fs2uchar$201 Def00A4 +S A$_fs2uchar$120 Def003E +S A$_fs2uchar$111 Def0034 +S A$_fs2uchar$102 Def002B +S A$_fs2uchar$310 Def0137 +S A$_fs2uchar$301 Def012A +S A$_fs2uchar$220 Def00B7 +S A$_fs2uchar$211 Def00B0 +S A$_fs2uchar$202 Def00A6 +S A$_fs2uchar$121 Def003F +S A$_fs2uchar$112 Def0035 +S A$_fs2uchar$103 Def002C +S A$_fs2uchar$410 Def01C3 +S A$_fs2uchar$401 Def01B6 +S A$_fs2uchar$320 Def0144 +S A$_fs2uchar$311 Def0138 +S A$_fs2uchar$302 Def012B +S A$_fs2uchar$230 Def00C6 +S A$_fs2uchar$221 Def00B9 +S A$_fs2uchar$212 Def00B1 +S A$_fs2uchar$203 Def00A7 +S A$_fs2uchar$140 Def0054 +S A$_fs2uchar$131 Def0048 +S A$_fs2uchar$122 Def0040 +S A$_fs2uchar$104 Def002D +S ___fs2uchar Def0000 +S A$_fs2uchar$411 Def01C4 +S A$_fs2uchar$330 Def0156 +S A$_fs2uchar$321 Def0146 +S A$_fs2uchar$312 Def013A +S A$_fs2uchar$303 Def012C +S A$_fs2uchar$240 Def00CF +S A$_fs2uchar$231 Def00C7 +S A$_fs2uchar$222 Def00BB +S A$_fs2uchar$213 Def00B2 +S A$_fs2uchar$204 Def00A8 +S A$_fs2uchar$150 Def005E +S A$_fs2uchar$141 Def0055 +S A$_fs2uchar$123 Def0041 +S A$_fs2uchar$114 Def0036 +S A$_fs2uchar$105 Def002E +S A$_fs2uchar$421 Def01D0 +S A$_fs2uchar$412 Def01C6 +S A$_fs2uchar$403 Def01B8 +S A$_fs2uchar$340 Def0166 +S A$_fs2uchar$331 Def0157 +S A$_fs2uchar$322 Def0149 +S A$_fs2uchar$313 Def013B +S A$_fs2uchar$304 Def012D +S A$_fs2uchar$250 Def00DF +S A$_fs2uchar$241 Def00D0 +S A$_fs2uchar$232 Def00C8 +S A$_fs2uchar$223 Def00BE +S A$_fs2uchar$214 Def00B3 +S A$_fs2uchar$205 Def00A9 +S A$_fs2uchar$160 Def006D +S A$_fs2uchar$151 Def0060 +S A$_fs2uchar$142 Def0056 +S A$_fs2uchar$124 Def0042 +S A$_fs2uchar$115 Def0039 +S A$_fs2uchar$106 Def002F +S A$_fs2uchar$413 Def01C7 +S A$_fs2uchar$404 Def01BB +S A$_fs2uchar$350 Def0176 +S A$_fs2uchar$332 Def0159 +S A$_fs2uchar$323 Def014B +S A$_fs2uchar$314 Def013C +S A$_fs2uchar$305 Def012E +S A$_fs2uchar$260 Def00ED +S A$_fs2uchar$251 Def00E0 +S A$_fs2uchar$242 Def00D1 +S A$_fs2uchar$233 Def00C9 +S A$_fs2uchar$215 Def00B4 +S A$_fs2uchar$206 Def00AA +S A$_fs2uchar$170 Def007B +S A$_fs2uchar$152 Def0061 +S A$_fs2uchar$143 Def0057 +S A$_fs2uchar$134 Def004A +S A$_fs2uchar$125 Def0043 +S A$_fs2uchar$116 Def003A +S A$_fs2uchar$107 Def0030 +S A$_fs2uchar$414 Def01C8 +S A$_fs2uchar$405 Def01BC +S A$_fs2uchar$360 Def0182 +S A$_fs2uchar$351 Def0178 +S A$_fs2uchar$342 Def0168 +S A$_fs2uchar$333 Def015B +S A$_fs2uchar$324 Def014D +S A$_fs2uchar$315 Def013E +S A$_fs2uchar$306 Def0130 +S A$_fs2uchar$270 Def00F8 +S A$_fs2uchar$261 Def00EE +S A$_fs2uchar$252 Def00E1 +S A$_fs2uchar$243 Def00D3 +S A$_fs2uchar$234 Def00CA +S A$_fs2uchar$225 Def00C0 +S A$_fs2uchar$207 Def00AB +S A$_fs2uchar$171 Def007C +S A$_fs2uchar$162 Def006F +S A$_fs2uchar$153 Def0063 +S A$_fs2uchar$144 Def0058 +S A$_fs2uchar$135 Def004D +S A$_fs2uchar$126 Def0044 +S A$_fs2uchar$117 Def003B +S A$_fs2uchar$108 Def0031 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 04 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 45 4B 4C 4D 70 06 +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A 75 82 00 02 01 D0 +R 00 00 00 07 00 06 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 5E 8C 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 6C 02 44 FE +R 00 00 00 07 +T 00 6F +R 00 00 00 07 +T 00 6F FB 33 95 E0 FC FD EA 75 F0 00 24 6A FA E5 +R 00 00 00 07 +T 00 7D F0 34 FF FB 90 00 08 EA F0 A3 EB F0 90 +R 00 00 00 07 00 07 00 05 +T 00 8A 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF 53 +R 00 00 00 07 00 02 00 05 +T 00 98 06 7F 7F 00 90 00 0A EA F0 A3 EB F0 74 80 +R 00 00 00 07 00 07 00 05 +T 00 A6 4E A3 F0 A3 EF F0 90 00 08 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 B4 C3 E4 9A 74 80 8B F0 63 F0 80 95 F0 50 1A +R 00 00 00 07 +T 00 C2 +R 00 00 00 07 +T 00 C2 90 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 D0 23 54 01 FA 43 02 7F 8A 82 02 01 D0 +R 00 00 00 07 00 0C 00 07 +T 00 DC +R 00 00 00 07 +T 00 DC 90 00 08 E0 FA A3 E0 F8 20 E7 03 02 01 7F +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 00 EA +R 00 00 00 07 +T 00 EA 90 00 08 E0 FA A3 E0 F8 C3 74 E7 9A 74 7F +R 00 00 00 07 00 03 00 05 +T 00 F8 88 F0 63 F0 80 95 F0 40 03 02 01 7F +R 00 00 00 07 00 0C 00 07 +T 01 04 +R 00 00 00 07 +T 01 04 90 00 0A E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 10 F5 00 02 A3 E0 F5 00 03 E5 00 00 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 19 00 01 45 00 02 45 00 03 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 21 01 7F +R 00 00 00 07 00 02 00 07 +T 01 23 +R 00 00 00 07 +T 01 23 90 00 08 E0 FA A3 E0 F8 C3 E4 9A F5 00 00 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 01 30 E4 98 F5 00 01 90 00 0A E0 F5 00 04 A3 E0 +R 00 00 00 07 29 05 00 01 00 08 00 05 29 0C 00 01 +T 01 3C F5 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 85 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 47 00 00 F0 05 F0 E5 00 07 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 01 52 +R 00 00 00 07 +T 01 52 A2 D2 E5 00 07 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 01 5D 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 64 00 04 13 F5 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 01 68 +R 00 00 00 07 +T 01 68 D5 F0 E7 90 00 0A E5 00 04 F0 A3 E5 00 05 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 01 74 F0 A3 E5 00 06 F0 A3 E5 00 07 F0 80 06 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 01 7F +R 00 00 00 07 +T 01 7F 75 82 00 02 01 D0 +R 00 00 00 07 00 06 00 07 +T 01 85 +R 00 00 00 07 +T 01 85 90 00 04 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 91 F5 00 06 A3 E0 F5 00 07 23 54 01 FA 60 1B +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 9D +R 00 00 00 07 +T 01 9D 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 A9 F5 00 06 A3 E0 F5 00 07 AA 00 04 C3 E4 9A +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 B4 F5 00 04 80 15 +R 00 00 00 07 29 03 00 01 +T 01 B8 +R 00 00 00 07 +T 01 B8 90 00 0A E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 C4 F5 00 02 A3 E0 F5 00 03 85 00 00 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 CC 00 04 +R 00 00 00 07 29 02 00 01 +T 01 CD +R 00 00 00 07 +T 01 CD 85 00 04 82 +R 00 00 00 07 29 03 00 01 +T 01 D0 +R 00 00 00 07 +T 01 D0 22 +R 00 00 00 07 diff --git a/device/lib/large/_fs2uint.asm b/device/lib/large/_fs2uint.asm new file mode 100644 index 00000000..e091af9c --- /dev/null +++ b/device/lib/large/_fs2uint.asm @@ -0,0 +1,436 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + +;-------------------------------------------------------- + .module _fs2uint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2uint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fs2uint_sloc0_1_0: + .ds 0x0004 +___fs2uint_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fs2uint_a1_1_1: + .ds 0x0004 +___fs2uint_fl1_1_1: + .ds 0x0004 +___fs2uint_exp_1_1: + .ds 0x0002 +___fs2uint_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2uint$0$0 ==. +; _fs2uint.c 73 +; ----------------------------------------- +; function __fs2uint +; ----------------------------------------- +___fs2uint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2uint.c 0 + push acc + push b + push dph + push dpl + mov dptr,#___fs2uint_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fs2uint.c 79 + mov dptr,#___fs2uint_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fs2uint_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fs2uint.c 81 + mov dptr,#(___fs2uint_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2uint.c 82 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00110$ +00102$: +; _fs2uint.c 84 + mov dptr,#(___fs2uint_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov r2,a + mov a,b + addc a,#0xff + mov r3,a + mov dptr,#___fs2uint_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _fs2uint.c 85 + mov dptr,#(___fs2uint_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + anl ar6,#0x7f + mov r7,#0x00 + mov dptr,#___fs2uint_l_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + mov a,#0x80 + orl a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _fs2uint.c 87 + mov dptr,#___fs2uint_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + clr c +; Peephole 180 changed mov to clr + clr a + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,r3 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2uint.c 88 + mov dptr,#(___fs2uint_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r7,a + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov r0,#0x00 + mov dpl,r2 + mov dph,r0 + ljmp 00110$ +00104$: +; _fs2uint.c 91 + mov dptr,#___fs2uint_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + jb acc.7,00123$ + ljmp 00106$ +00123$: + mov dptr,#___fs2uint_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + mov a,#0xe7 + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,r0 + xrl b,#0x80 + subb a,b + jc 00124$ + ljmp 00106$ +00124$: + mov dptr,#___fs2uint_l_1_1 + movx a,@dptr + mov ___fs2uint_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc0_1_0 + 3),a + mov a,___fs2uint_sloc0_1_0 + orl a,(___fs2uint_sloc0_1_0 + 1) + orl a,(___fs2uint_sloc0_1_0 + 2) + orl a,(___fs2uint_sloc0_1_0 + 3) + jnz 00125$ + ljmp 00106$ +00125$: +; _fs2uint.c 92 + mov dptr,#___fs2uint_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + clr a + subb a,r2 + mov ___fs2uint_sloc0_1_0,a + clr a + subb a,r0 + mov (___fs2uint_sloc0_1_0 + 1),a + mov dptr,#___fs2uint_l_1_1 + movx a,@dptr + mov ___fs2uint_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 3),a + mov b,___fs2uint_sloc0_1_0 + inc b + mov a,(___fs2uint_sloc1_1_0 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2uint_sloc1_1_0 + 3) + rrc a + mov (___fs2uint_sloc1_1_0 + 3),a + mov a,(___fs2uint_sloc1_1_0 + 2) + rrc a + mov (___fs2uint_sloc1_1_0 + 2),a + mov a,(___fs2uint_sloc1_1_0 + 1) + rrc a + mov (___fs2uint_sloc1_1_0 + 1),a + mov a,___fs2uint_sloc1_1_0 + rrc a + mov ___fs2uint_sloc1_1_0,a +00127$: + djnz b,00126$ + mov dptr,#___fs2uint_l_1_1 + mov a,___fs2uint_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fs2uint_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fs2uint_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fs2uint_sloc1_1_0 + 3) + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2uint.c 94 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00110$ +00107$: +; _fs2uint.c 96 + mov dptr,#(___fs2uint_fl1_1_1) + movx a,@dptr + mov ___fs2uint_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fs2uint_sloc1_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + mov dptr,#___fs2uint_l_1_1 + movx a,@dptr + mov ___fs2uint_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 3),a + clr c + clr a + subb a,___fs2uint_sloc1_1_0 + mov ___fs2uint_sloc1_1_0,a + clr a + subb a,(___fs2uint_sloc1_1_0 + 1) + mov (___fs2uint_sloc1_1_0 + 1),a + clr a + subb a,(___fs2uint_sloc1_1_0 + 2) + mov (___fs2uint_sloc1_1_0 + 2),a + clr a + subb a,(___fs2uint_sloc1_1_0 + 3) + mov (___fs2uint_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov dptr,#___fs2uint_l_1_1 + movx a,@dptr + mov ___fs2uint_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2uint_sloc1_1_0 + 3),a +00113$: + mov r2,___fs2uint_sloc1_1_0 + mov r0,(___fs2uint_sloc1_1_0 + 1) + mov dpl,r2 + mov dph,r0 +00110$: + C$_fs2uint.c$97$1$1 ==. + XG$__fs2uint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fs2uint.cdb b/device/lib/large/_fs2uint.cdb new file mode 100644 index 00000000..52d12a6d --- /dev/null +++ b/device/lib/large/_fs2uint.cdb @@ -0,0 +1,2 @@ +M:_fs2uint +F:G$__fs2uint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_fs2uint.rel b/device/lib/large/_fs2uint.rel new file mode 100644 index 00000000..ab34fb59 --- /dev/null +++ b/device/lib/large/_fs2uint.rel @@ -0,0 +1,489 @@ +;!FILE _fs2uint.asm +XH +H 8 areas 145 global symbols +M _fs2uint +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 1E5 flags 20 +S A$_fs2uint$94 Def0021 +S A$_fs2uint$85 Def0016 +S A$_fs2uint$76 Def0008 +S C$_fs2uint.c$97$1$1 Def01E4 +S A$_fs2uint$95 Def0022 +S A$_fs2uint$86 Def0018 +S A$_fs2uint$77 Def000B +S A$_fs2uint$96 Def0023 +S A$_fs2uint$87 Def0019 +S A$_fs2uint$78 Def000D +S A$_fs2uint$97 Def0024 +S A$_fs2uint$79 Def000E +S A$_fs2uint$98 Def0025 +S A$_fs2uint$89 Def001A +S A$_fs2uint$99 Def0026 +S A$_fs2uint$100 Def0027 +S A$_fs2uint$200 Def00A2 +S A$_fs2uint$110 Def0033 +S A$_fs2uint$101 Def0028 +S A$_fs2uint$300 Def012A +S A$_fs2uint$210 Def00AC +S A$_fs2uint$201 Def00A3 +S A$_fs2uint$120 Def003E +S A$_fs2uint$111 Def0034 +S A$_fs2uint$102 Def002B +S A$_fs2uint$400 Def01B4 +S A$_fs2uint$310 Def0135 +S A$_fs2uint$301 Def012B +S A$_fs2uint$211 Def00AF +S A$_fs2uint$202 Def00A4 +S A$_fs2uint$121 Def003F +S A$_fs2uint$112 Def0035 +S A$_fs2uint$103 Def002C +S A$_fs2uint$410 Def01C4 +S A$_fs2uint$401 Def01B5 +S A$_fs2uint$320 Def0144 +S A$_fs2uint$311 Def0136 +S A$_fs2uint$302 Def012C +S A$_fs2uint$230 Def00C5 +S A$_fs2uint$221 Def00B7 +S A$_fs2uint$212 Def00B0 +S A$_fs2uint$203 Def00A6 +S A$_fs2uint$140 Def0053 +S A$_fs2uint$131 Def0048 +S A$_fs2uint$122 Def0040 +S A$_fs2uint$104 Def002D +S ___fs2uint Def0000 +S A$_fs2uint$420 Def01D2 +S A$_fs2uint$411 Def01C6 +S A$_fs2uint$402 Def01B7 +S A$_fs2uint$321 Def0146 +S A$_fs2uint$312 Def0138 +S A$_fs2uint$303 Def012D +S A$_fs2uint$231 Def00C6 +S A$_fs2uint$222 Def00B9 +S A$_fs2uint$213 Def00B1 +S A$_fs2uint$204 Def00A7 +S A$_fs2uint$150 Def005D +S A$_fs2uint$141 Def0054 +S A$_fs2uint$123 Def0041 +S A$_fs2uint$114 Def0036 +S A$_fs2uint$105 Def002E +S A$_fs2uint$430 Def01E0 +S A$_fs2uint$421 Def01D4 +S A$_fs2uint$403 Def01B9 +S A$_fs2uint$340 Def0165 +S A$_fs2uint$331 Def0156 +S A$_fs2uint$322 Def0147 +S A$_fs2uint$313 Def013B +S A$_fs2uint$304 Def012E +S A$_fs2uint$241 Def00CF +S A$_fs2uint$232 Def00C7 +S A$_fs2uint$223 Def00BB +S A$_fs2uint$214 Def00B2 +S A$_fs2uint$205 Def00A8 +S A$_fs2uint$160 Def006A +S A$_fs2uint$151 Def005E +S A$_fs2uint$142 Def0055 +S A$_fs2uint$124 Def0042 +S A$_fs2uint$115 Def0039 +S A$_fs2uint$106 Def002F +S A$_fs2uint$431 Def01E2 +S A$_fs2uint$422 Def01D5 +S A$_fs2uint$413 Def01C8 +S A$_fs2uint$404 Def01BA +S A$_fs2uint$350 Def0176 +S A$_fs2uint$341 Def0167 +S A$_fs2uint$332 Def0158 +S A$_fs2uint$323 Def0148 +S A$_fs2uint$314 Def013C +S A$_fs2uint$305 Def012F +S A$_fs2uint$260 Def00EB +S A$_fs2uint$242 Def00D0 +S A$_fs2uint$233 Def00C8 +S A$_fs2uint$224 Def00BE +S A$_fs2uint$215 Def00B3 +S A$_fs2uint$206 Def00A9 +S A$_fs2uint$170 Def0079 +S A$_fs2uint$161 Def006D +S A$_fs2uint$152 Def0060 +S A$_fs2uint$143 Def0056 +S A$_fs2uint$125 Def0043 +S A$_fs2uint$116 Def003A +S A$_fs2uint$107 Def0030 +S A$_fs2uint$423 Def01D6 +S A$_fs2uint$405 Def01BC +S A$_fs2uint$351 Def0178 +S A$_fs2uint$342 Def0169 +S A$_fs2uint$333 Def015A +S A$_fs2uint$324 Def014A +S A$_fs2uint$315 Def013E +S A$_fs2uint$306 Def0130 +S A$_fs2uint$270 Def00F9 +S A$_fs2uint$252 Def00E0 +S A$_fs2uint$243 Def00D1 +S A$_fs2uint$234 Def00C9 +S A$_fs2uint$216 Def00B4 +S A$_fs2uint$207 Def00AA +S A$_fs2uint$180 Def0088 +S A$_fs2uint$171 Def007B +S A$_fs2uint$153 Def0061 +S A$_fs2uint$144 Def0057 +S A$_fs2uint$135 Def004A +S A$_fs2uint$126 Def0044 +S A$_fs2uint$117 Def003B +S A$_fs2uint$108 Def0031 +S A$_fs2uint$424 Def01D8 +S A$_fs2uint$415 Def01CA +S A$_fs2uint$406 Def01BE +S A$_fs2uint$370 Def018F +S A$_fs2uint$352 Def0179 +S A$_fs2uint$343 Def016A +S A$_fs2uint$334 Def015B +S A$_fs2uint$325 Def014D +S A$_fs2uint$316 Def013F +S A$_fs2uint$307 Def0131 +S A$_fs2uint$280 Def010B +S A$_fs2uint$262 Def00EE +S A$_fs2uint$253 Def00E3 +S A$_fs2uint$244 Def00D3 +S A$_fs2uint$235 Def00CA +S A$_fs2uint$226 Def00C0 +S A$_fs2uint$208 Def00AB +S A$_fs2uint$190 Def0093 +S A$_fs2uint$172 Def007C +S A$_fs2uint$163 Def006F +S A$_fs2uint$154 Def0063 +S A$_fs2uint$145 Def0058 +S A$_fs2uint$136 Def004D +S A$_fs2uint$127 Def0045 +S A$_fs2uint$118 Def003C +S A$_fs2uint$109 Def0032 +S A$_fs2uint$425 Def01D9 +S A$_fs2uint$416 Def01CD +S A$_fs2uint$407 Def01BF +S A$_fs2uint$380 Def019B +S A$_fs2uint$371 Def0190 +S A$_fs2uint$353 Def017A +S A$_fs2uint$335 Def015D +S A$_fs2uint$326 Def014F +S A$_fs2uint$317 Def0140 +S A$_fs2uint$308 Def0132 +S A$_fs2uint$290 Def0118 +S A$_fs2uint$281 Def010C +S A$_fs2uint$272 Def00FA +S A$_fs2uint$263 Def00F1 +S A$_fs2uint$254 Def00E4 +S A$_fs2uint$245 Def00D4 +S A$_fs2uint$236 Def00CB +S A$_fs2uint$218 Def00B5 +S A$_fs2uint$191 Def0094 +S A$_fs2uint$182 Def0089 +S A$_fs2uint$173 Def007E +S A$_fs2uint$164 Def0070 +S A$_fs2uint$155 Def0064 +S A$_fs2uint$146 Def0059 +S A$_fs2uint$128 Def0046 +S A$_fs2uint$119 Def003D +S A$_fs2uint$435 Def01E4 +S A$_fs2uint$426 Def01DA +S A$_fs2uint$417 Def01CE +S A$_fs2uint$408 Def01C1 +S A$_fs2uint$390 Def01A7 +S A$_fs2uint$381 Def019C +S A$_fs2uint$372 Def0191 +S A$_fs2uint$363 Def0183 +S A$_fs2uint$354 Def017C +S A$_fs2uint$345 Def016C +S A$_fs2uint$336 Def015F +S A$_fs2uint$327 Def0151 +S A$_fs2uint$318 Def0142 +S A$_fs2uint$309 Def0134 +S A$_fs2uint$291 Def011A +S A$_fs2uint$282 Def010E +S A$_fs2uint$273 Def00FC +S A$_fs2uint$264 Def00F2 +S A$_fs2uint$255 Def00E5 +S A$_fs2uint$246 Def00D7 +S A$_fs2uint$237 Def00CC +S A$_fs2uint$219 Def00B6 +S A$_fs2uint$192 Def0095 +S A$_fs2uint$183 Def008C +S A$_fs2uint$174 Def0080 +S A$_fs2uint$165 Def0071 +S A$_fs2uint$156 Def0065 +S A$_fs2uint$147 Def005A +S A$_fs2uint$129 Def0047 +S A$_fs2uint$418 Def01D0 +S A$_fs2uint$409 Def01C3 +S A$_fs2uint$391 Def01A8 +S A$_fs2uint$373 Def0193 +S A$_fs2uint$364 Def0186 +S A$_fs2uint$355 Def017D +S A$_fs2uint$346 Def016F +S A$_fs2uint$337 Def0160 +S A$_fs2uint$328 Def0152 +S A$_fs2uint$319 Def0143 +S A$_fs2uint$292 Def011C +S A$_fs2uint$283 Def010F +S A$_fs2uint$274 Def00FE +S A$_fs2uint$265 Def00F3 +S A$_fs2uint$256 Def00E6 +S A$_fs2uint$247 Def00D9 +S A$_fs2uint$238 Def00CD +S A$_fs2uint$229 Def00C2 +S A$_fs2uint$193 Def0096 +S A$_fs2uint$184 Def008D +S A$_fs2uint$175 Def0081 +S A$_fs2uint$166 Def0073 +S A$_fs2uint$157 Def0066 +S A$_fs2uint$148 Def005B +S A$_fs2uint$139 Def0050 +S A$_fs2uint$428 Def01DC +S A$_fs2uint$419 Def01D1 +S A$_fs2uint$392 Def01A9 +S A$_fs2uint$383 Def019E +S A$_fs2uint$374 Def0194 +S A$_fs2uint$356 Def017E +S A$_fs2uint$347 Def0172 +S A$_fs2uint$338 Def0162 +S A$_fs2uint$329 Def0154 +S A$_fs2uint$293 Def011E +S A$_fs2uint$284 Def0110 +S A$_fs2uint$275 Def0101 +S A$_fs2uint$266 Def00F4 +S A$_fs2uint$248 Def00DB +S A$_fs2uint$239 Def00CE +S A$_fs2uint$194 Def0097 +S A$_fs2uint$185 Def008E +S A$_fs2uint$176 Def0084 +S A$_fs2uint$167 Def0074 +S A$_fs2uint$158 Def0067 +S A$_fs2uint$149 Def005C +S A$_fs2uint$429 Def01DE +S A$_fs2uint$393 Def01AB +S A$_fs2uint$375 Def0195 +S A$_fs2uint$357 Def0180 +S A$_fs2uint$348 Def0174 +S A$_fs2uint$339 Def0164 +S A$_fs2uint$294 Def0120 +S A$_fs2uint$285 Def0112 +S A$_fs2uint$276 Def0103 +S A$_fs2uint$267 Def00F5 +S A$_fs2uint$258 Def00E7 +S A$_fs2uint$249 Def00DD +S A$_fs2uint$195 Def009A +S A$_fs2uint$186 Def008F +S A$_fs2uint$177 Def0085 +S A$_fs2uint$168 Def0075 +S A$_fs2uint$159 Def0068 +S A$_fs2uint$394 Def01AC +S A$_fs2uint$385 Def019F +S A$_fs2uint$376 Def0197 +S A$_fs2uint$367 Def0189 +S A$_fs2uint$349 Def0175 +S A$_fs2uint$295 Def0122 +S A$_fs2uint$286 Def0113 +S A$_fs2uint$277 Def0105 +S A$_fs2uint$268 Def00F6 +S A$_fs2uint$259 Def00E8 +S A$_fs2uint$196 Def009C +S A$_fs2uint$187 Def0090 +S A$_fs2uint$178 Def0086 +S A$_fs2uint$169 Def0076 +S A$_fs2uint$395 Def01AD +S A$_fs2uint$377 Def0198 +S A$_fs2uint$368 Def018C +S A$_fs2uint$359 Def0181 +S A$_fs2uint$296 Def0124 +S A$_fs2uint$287 Def0114 +S A$_fs2uint$269 Def00F7 +S A$_fs2uint$197 Def009F +S A$_fs2uint$188 Def0091 +S A$_fs2uint$179 Def0087 +S XG$__fs2uint$0$0 Def01E4 +S A$_fs2uint$396 Def01AF +S A$_fs2uint$387 Def01A1 +S A$_fs2uint$369 Def018D +S A$_fs2uint$288 Def0116 +S A$_fs2uint$279 Def0108 +S A$_fs2uint$198 Def00A0 +S A$_fs2uint$189 Def0092 +S A$_fs2uint$397 Def01B0 +S A$_fs2uint$388 Def01A4 +S A$_fs2uint$379 Def0199 +S A$_fs2uint$289 Def0117 +S A$_fs2uint$199 Def00A1 +S A$_fs2uint$398 Def01B1 +S A$_fs2uint$389 Def01A5 +S A$_fs2uint$299 Def0127 +S A$_fs2uint$399 Def01B3 +S A$_fs2uint$80 Def0010 +S A$_fs2uint$90 Def001D +S A$_fs2uint$81 Def0011 +S A$_fs2uint$72 Def0000 +S G$__fs2uint$0$0 Def0000 +S A$_fs2uint$91 Def001E +S A$_fs2uint$82 Def0012 +S A$_fs2uint$73 Def0002 +S A$_fs2uint$92 Def001F +S A$_fs2uint$83 Def0014 +S A$_fs2uint$74 Def0004 +S A$_fs2uint$93 Def0020 +S A$_fs2uint$84 Def0015 +S A$_fs2uint$75 Def0006 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 04 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 45 4B 4C 4D 70 06 +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A 90 00 00 02 01 E4 +R 00 00 00 07 00 06 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 5E 8C 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 6C 02 44 FE +R 00 00 00 07 +T 00 6F +R 00 00 00 07 +T 00 6F FB 33 95 E0 FC FD EA 75 F0 00 24 6A FA E5 +R 00 00 00 07 +T 00 7D F0 34 FF FB 90 00 08 EA F0 A3 EB F0 90 +R 00 00 00 07 00 07 00 05 +T 00 8A 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF 53 +R 00 00 00 07 00 02 00 05 +T 00 98 06 7F 7F 00 90 00 0A EA F0 A3 EB F0 74 80 +R 00 00 00 07 00 07 00 05 +T 00 A6 4E A3 F0 A3 EF F0 90 00 08 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 B4 C3 E4 9A 74 80 8B F0 63 F0 80 95 F0 50 1E +R 00 00 00 07 +T 00 C2 +R 00 00 00 07 +T 00 C2 90 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 D0 23 54 01 FA 43 02 7F 78 00 8A 82 88 83 02 +R 00 00 00 07 +T 00 DE 01 E4 +R 00 00 00 07 00 02 00 07 +T 00 E0 +R 00 00 00 07 +T 00 E0 90 00 08 E0 FA A3 E0 F8 20 E7 03 02 01 83 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 00 EE +R 00 00 00 07 +T 00 EE 90 00 08 E0 FA A3 E0 F8 C3 74 E7 9A 74 7F +R 00 00 00 07 00 03 00 05 +T 00 FC 88 F0 63 F0 80 95 F0 40 03 02 01 83 +R 00 00 00 07 00 0C 00 07 +T 01 08 +R 00 00 00 07 +T 01 08 90 00 0A E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 14 F5 00 02 A3 E0 F5 00 03 E5 00 00 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 1D 00 01 45 00 02 45 00 03 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 25 01 83 +R 00 00 00 07 00 02 00 07 +T 01 27 +R 00 00 00 07 +T 01 27 90 00 08 E0 FA A3 E0 F8 C3 E4 9A F5 00 00 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 01 34 E4 98 F5 00 01 90 00 0A E0 F5 00 04 A3 E0 +R 00 00 00 07 29 05 00 01 00 08 00 05 29 0C 00 01 +T 01 40 F5 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 85 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 4B 00 00 F0 05 F0 E5 00 07 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 01 56 +R 00 00 00 07 +T 01 56 A2 D2 E5 00 07 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 01 61 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 68 00 04 13 F5 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 01 6C +R 00 00 00 07 +T 01 6C D5 F0 E7 90 00 0A E5 00 04 F0 A3 E5 00 05 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 01 78 F0 A3 E5 00 06 F0 A3 E5 00 07 F0 80 06 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 01 83 +R 00 00 00 07 +T 01 83 90 00 00 02 01 E4 +R 00 00 00 07 00 06 00 07 +T 01 89 +R 00 00 00 07 +T 01 89 90 00 04 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 95 F5 00 06 A3 E0 F5 00 07 23 54 01 FA 60 29 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 A1 +R 00 00 00 07 +T 01 A1 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 AD F5 00 06 A3 E0 F5 00 07 C3 E4 95 00 04 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 B8 00 04 E4 95 00 05 F5 00 05 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 C0 00 06 F5 00 06 E4 95 00 07 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 C7 00 07 80 12 +R 00 00 00 07 29 02 00 01 +T 01 CA +R 00 00 00 07 +T 01 CA 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 D6 F5 00 06 A3 E0 F5 00 07 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 DC +R 00 00 00 07 +T 01 DC AA 00 04 A8 00 05 8A 82 88 83 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 01 E4 +R 00 00 00 07 +T 01 E4 22 +R 00 00 00 07 diff --git a/device/lib/large/_fs2ulong.asm b/device/lib/large/_fs2ulong.asm new file mode 100644 index 00000000..3980fd75 --- /dev/null +++ b/device/lib/large/_fs2ulong.asm @@ -0,0 +1,451 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:24 2000 + +;-------------------------------------------------------- + .module _fs2ulong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2ulong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fs2ulong_sloc0_1_0: + .ds 0x0004 +___fs2ulong_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fs2ulong_a1_1_1: + .ds 0x0004 +___fs2ulong_fl1_1_1: + .ds 0x0004 +___fs2ulong_exp_1_1: + .ds 0x0002 +___fs2ulong_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2ulong$0$0 ==. +; _fs2ulong.c 73 +; ----------------------------------------- +; function __fs2ulong +; ----------------------------------------- +___fs2ulong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2ulong.c 0 + push acc + push b + push dph + push dpl + mov dptr,#___fs2ulong_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fs2ulong.c 79 + mov dptr,#___fs2ulong_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fs2ulong_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fs2ulong.c 81 + mov dptr,#(___fs2ulong_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2ulong.c 82 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00110$ +00102$: +; _fs2ulong.c 84 + mov dptr,#(___fs2ulong_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov r2,a + mov a,b + addc a,#0xff + mov r3,a + mov dptr,#___fs2ulong_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _fs2ulong.c 85 + mov dptr,#(___fs2ulong_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + anl ar6,#0x7f + mov r7,#0x00 + mov dptr,#___fs2ulong_l_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + mov a,#0x80 + orl a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _fs2ulong.c 87 + mov dptr,#___fs2ulong_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + clr c +; Peephole 180 changed mov to clr + clr a + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,r3 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2ulong.c 88 + mov dptr,#(___fs2ulong_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r7,a + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov ___fs2ulong_sloc0_1_0,r2 + mov (___fs2ulong_sloc0_1_0 + 1),#0x00 + mov (___fs2ulong_sloc0_1_0 + 2),#0x00 + mov (___fs2ulong_sloc0_1_0 + 3),#0x00 + mov dpl,___fs2ulong_sloc0_1_0 + mov dph,(___fs2ulong_sloc0_1_0 + 1) + mov b,(___fs2ulong_sloc0_1_0 + 2) + mov a,(___fs2ulong_sloc0_1_0 + 3) + ljmp 00110$ +00104$: +; _fs2ulong.c 91 + mov dptr,#___fs2ulong_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + jb acc.7,00123$ + ljmp 00106$ +00123$: + mov dptr,#___fs2ulong_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + mov a,#0xe7 + subb a,r2 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,r0 + xrl b,#0x80 + subb a,b + jc 00124$ + ljmp 00106$ +00124$: + mov dptr,#___fs2ulong_l_1_1 + movx a,@dptr + mov ___fs2ulong_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc0_1_0 + 3),a + mov a,___fs2ulong_sloc0_1_0 + orl a,(___fs2ulong_sloc0_1_0 + 1) + orl a,(___fs2ulong_sloc0_1_0 + 2) + orl a,(___fs2ulong_sloc0_1_0 + 3) + jnz 00125$ + ljmp 00106$ +00125$: +; _fs2ulong.c 92 + mov dptr,#___fs2ulong_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r0,a + clr c + clr a + subb a,r2 + mov ___fs2ulong_sloc0_1_0,a + clr a + subb a,r0 + mov (___fs2ulong_sloc0_1_0 + 1),a + mov dptr,#___fs2ulong_l_1_1 + movx a,@dptr + mov ___fs2ulong_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 3),a + mov b,___fs2ulong_sloc0_1_0 + inc b + mov a,(___fs2ulong_sloc1_1_0 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2ulong_sloc1_1_0 + 3) + rrc a + mov (___fs2ulong_sloc1_1_0 + 3),a + mov a,(___fs2ulong_sloc1_1_0 + 2) + rrc a + mov (___fs2ulong_sloc1_1_0 + 2),a + mov a,(___fs2ulong_sloc1_1_0 + 1) + rrc a + mov (___fs2ulong_sloc1_1_0 + 1),a + mov a,___fs2ulong_sloc1_1_0 + rrc a + mov ___fs2ulong_sloc1_1_0,a +00127$: + djnz b,00126$ + mov dptr,#___fs2ulong_l_1_1 + mov a,___fs2ulong_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fs2ulong_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fs2ulong_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fs2ulong_sloc1_1_0 + 3) + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2ulong.c 94 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00110$ +00107$: +; _fs2ulong.c 96 + mov dptr,#(___fs2ulong_fl1_1_1) + movx a,@dptr + mov ___fs2ulong_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fs2ulong_sloc1_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + mov dptr,#___fs2ulong_l_1_1 + movx a,@dptr + mov ___fs2ulong_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 3),a + clr c + clr a + subb a,___fs2ulong_sloc1_1_0 + mov ___fs2ulong_sloc1_1_0,a + clr a + subb a,(___fs2ulong_sloc1_1_0 + 1) + mov (___fs2ulong_sloc1_1_0 + 1),a + clr a + subb a,(___fs2ulong_sloc1_1_0 + 2) + mov (___fs2ulong_sloc1_1_0 + 2),a + clr a + subb a,(___fs2ulong_sloc1_1_0 + 3) + mov (___fs2ulong_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov dptr,#___fs2ulong_l_1_1 + movx a,@dptr + mov ___fs2ulong_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fs2ulong_sloc1_1_0 + 3),a +00113$: + mov dpl,___fs2ulong_sloc1_1_0 + mov dph,(___fs2ulong_sloc1_1_0 + 1) + mov b,(___fs2ulong_sloc1_1_0 + 2) + mov a,(___fs2ulong_sloc1_1_0 + 3) +00110$: + C$_fs2ulong.c$97$1$1 ==. + XG$__fs2ulong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fs2ulong.cdb b/device/lib/large/_fs2ulong.cdb new file mode 100644 index 00000000..e579f516 --- /dev/null +++ b/device/lib/large/_fs2ulong.cdb @@ -0,0 +1,2 @@ +M:_fs2ulong +F:G$__fs2ulong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_fs2ulong.rel b/device/lib/large/_fs2ulong.rel new file mode 100644 index 00000000..8d02b1ff --- /dev/null +++ b/device/lib/large/_fs2ulong.rel @@ -0,0 +1,506 @@ +;!FILE _fs2ulong.asm +XH +H 8 areas 150 global symbols +M _fs2ulong +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 200 flags 20 +S A$_fs2ulong$100 Def0027 +S A$_fs2ulong$200 Def009E +S A$_fs2ulong$110 Def0033 +S A$_fs2ulong$101 Def0028 +S A$_fs2ulong$300 Def012C +S A$_fs2ulong$210 Def00AC +S A$_fs2ulong$201 Def00A0 +S A$_fs2ulong$120 Def003E +S A$_fs2ulong$111 Def0034 +S A$_fs2ulong$102 Def002B +S A$_fs2ulong$400 Def01B7 +S A$_fs2ulong$310 Def013E +S A$_fs2ulong$301 Def012E +S A$_fs2ulong$220 Def00B7 +S A$_fs2ulong$211 Def00AD +S A$_fs2ulong$202 Def00A3 +S A$_fs2ulong$121 Def003F +S A$_fs2ulong$112 Def0035 +S A$_fs2ulong$103 Def002C +S A$_fs2ulong$410 Def01C5 +S A$_fs2ulong$320 Def0149 +S A$_fs2ulong$311 Def013F +S A$_fs2ulong$302 Def0130 +S A$_fs2ulong$221 Def00B8 +S A$_fs2ulong$212 Def00AE +S A$_fs2ulong$203 Def00A4 +S A$_fs2ulong$140 Def004F +S A$_fs2ulong$131 Def0048 +S A$_fs2ulong$122 Def0040 +S A$_fs2ulong$104 Def002D +S ___fs2ulong Def0000 +S A$_fs2ulong$420 Def01D4 +S A$_fs2ulong$411 Def01C7 +S A$_fs2ulong$402 Def01B9 +S A$_fs2ulong$330 Def0158 +S A$_fs2ulong$321 Def014A +S A$_fs2ulong$312 Def0140 +S A$_fs2ulong$303 Def0132 +S A$_fs2ulong$240 Def00CE +S A$_fs2ulong$231 Def00C4 +S A$_fs2ulong$213 Def00AF +S A$_fs2ulong$204 Def00A5 +S A$_fs2ulong$150 Def005C +S A$_fs2ulong$141 Def0051 +S A$_fs2ulong$123 Def0041 +S A$_fs2ulong$114 Def0036 +S A$_fs2ulong$105 Def002E +S A$_fs2ulong$430 Def01E2 +S A$_fs2ulong$421 Def01D6 +S A$_fs2ulong$412 Def01C8 +S A$_fs2ulong$403 Def01BC +S A$_fs2ulong$331 Def015A +S A$_fs2ulong$322 Def014C +S A$_fs2ulong$313 Def0141 +S A$_fs2ulong$304 Def0134 +S A$_fs2ulong$250 Def00D8 +S A$_fs2ulong$241 Def00CF +S A$_fs2ulong$223 Def00B9 +S A$_fs2ulong$205 Def00A6 +S A$_fs2ulong$160 Def0068 +S A$_fs2ulong$151 Def005D +S A$_fs2ulong$124 Def0042 +S A$_fs2ulong$115 Def0039 +S A$_fs2ulong$106 Def002F +S A$_fs2ulong$440 Def01F1 +S A$_fs2ulong$431 Def01E5 +S A$_fs2ulong$422 Def01D7 +S A$_fs2ulong$413 Def01C9 +S A$_fs2ulong$404 Def01BD +S A$_fs2ulong$350 Def0179 +S A$_fs2ulong$341 Def016A +S A$_fs2ulong$332 Def015B +S A$_fs2ulong$323 Def014F +S A$_fs2ulong$314 Def0142 +S A$_fs2ulong$305 Def0136 +S A$_fs2ulong$251 Def00DB +S A$_fs2ulong$242 Def00D0 +S A$_fs2ulong$224 Def00BA +S A$_fs2ulong$215 Def00B0 +S A$_fs2ulong$206 Def00A7 +S A$_fs2ulong$170 Def0075 +S A$_fs2ulong$161 Def0069 +S A$_fs2ulong$152 Def005E +S A$_fs2ulong$125 Def0043 +S A$_fs2ulong$116 Def003A +S A$_fs2ulong$107 Def0030 +S A$_fs2ulong$450 Def01FF +S A$_fs2ulong$441 Def01F2 +S A$_fs2ulong$432 Def01E6 +S A$_fs2ulong$423 Def01D9 +S A$_fs2ulong$414 Def01CB +S A$_fs2ulong$405 Def01BF +S A$_fs2ulong$360 Def018A +S A$_fs2ulong$351 Def017B +S A$_fs2ulong$342 Def016C +S A$_fs2ulong$333 Def015C +S A$_fs2ulong$324 Def0150 +S A$_fs2ulong$315 Def0143 +S A$_fs2ulong$306 Def0138 +S A$_fs2ulong$270 Def00FF +S A$_fs2ulong$252 Def00DD +S A$_fs2ulong$243 Def00D1 +S A$_fs2ulong$234 Def00C6 +S A$_fs2ulong$216 Def00B3 +S A$_fs2ulong$207 Def00A8 +S A$_fs2ulong$180 Def0085 +S A$_fs2ulong$171 Def0077 +S A$_fs2ulong$162 Def006A +S A$_fs2ulong$153 Def005F +S A$_fs2ulong$144 Def0054 +S A$_fs2ulong$126 Def0044 +S A$_fs2ulong$117 Def003B +S A$_fs2ulong$108 Def0031 +S A$_fs2ulong$433 Def01E8 +S A$_fs2ulong$424 Def01DB +S A$_fs2ulong$415 Def01CC +S A$_fs2ulong$406 Def01C0 +S A$_fs2ulong$361 Def018C +S A$_fs2ulong$352 Def017D +S A$_fs2ulong$343 Def016E +S A$_fs2ulong$334 Def015E +S A$_fs2ulong$325 Def0152 +S A$_fs2ulong$316 Def0144 +S A$_fs2ulong$280 Def010D +S A$_fs2ulong$262 Def00F4 +S A$_fs2ulong$253 Def00E0 +S A$_fs2ulong$244 Def00D2 +S A$_fs2ulong$235 Def00C9 +S A$_fs2ulong$226 Def00BB +S A$_fs2ulong$217 Def00B4 +S A$_fs2ulong$208 Def00AA +S A$_fs2ulong$190 Def0092 +S A$_fs2ulong$181 Def0088 +S A$_fs2ulong$172 Def0078 +S A$_fs2ulong$163 Def006B +S A$_fs2ulong$154 Def0060 +S A$_fs2ulong$145 Def0057 +S A$_fs2ulong$127 Def0045 +S A$_fs2ulong$118 Def003C +S A$_fs2ulong$109 Def0032 +S A$_fs2ulong$443 Def01F4 +S A$_fs2ulong$434 Def01E9 +S A$_fs2ulong$425 Def01DC +S A$_fs2ulong$416 Def01CD +S A$_fs2ulong$407 Def01C1 +S A$_fs2ulong$362 Def018D +S A$_fs2ulong$353 Def017E +S A$_fs2ulong$344 Def016F +S A$_fs2ulong$335 Def0161 +S A$_fs2ulong$326 Def0153 +S A$_fs2ulong$317 Def0145 +S A$_fs2ulong$290 Def011F +S A$_fs2ulong$272 Def0102 +S A$_fs2ulong$263 Def00F7 +S A$_fs2ulong$254 Def00E3 +S A$_fs2ulong$236 Def00CA +S A$_fs2ulong$227 Def00BD +S A$_fs2ulong$218 Def00B5 +S A$_fs2ulong$209 Def00AB +S A$_fs2ulong$191 Def0093 +S A$_fs2ulong$182 Def0089 +S A$_fs2ulong$173 Def0079 +S A$_fs2ulong$164 Def006C +S A$_fs2ulong$155 Def0061 +S A$_fs2ulong$146 Def0058 +S A$_fs2ulong$137 Def004A +S A$_fs2ulong$128 Def0046 +S A$_fs2ulong$119 Def003D +S A$_fs2ulong$444 Def01F7 +S A$_fs2ulong$435 Def01EA +S A$_fs2ulong$426 Def01DE +S A$_fs2ulong$417 Def01CF +S A$_fs2ulong$408 Def01C3 +S A$_fs2ulong$390 Def01AD +S A$_fs2ulong$363 Def018E +S A$_fs2ulong$345 Def0171 +S A$_fs2ulong$336 Def0163 +S A$_fs2ulong$327 Def0154 +S A$_fs2ulong$318 Def0146 +S A$_fs2ulong$309 Def013B +S A$_fs2ulong$291 Def0120 +S A$_fs2ulong$282 Def010E +S A$_fs2ulong$273 Def0105 +S A$_fs2ulong$264 Def00F8 +S A$_fs2ulong$255 Def00E6 +S A$_fs2ulong$246 Def00D3 +S A$_fs2ulong$237 Def00CB +S A$_fs2ulong$228 Def00BF +S A$_fs2ulong$219 Def00B6 +S A$_fs2ulong$192 Def0094 +S A$_fs2ulong$183 Def008A +S A$_fs2ulong$174 Def007A +S A$_fs2ulong$165 Def006E +S A$_fs2ulong$156 Def0062 +S A$_fs2ulong$147 Def0059 +S A$_fs2ulong$138 Def004B +S A$_fs2ulong$129 Def0047 +S A$_fs2ulong$445 Def01FA +S A$_fs2ulong$436 Def01EC +S A$_fs2ulong$418 Def01D1 +S A$_fs2ulong$409 Def01C4 +S A$_fs2ulong$391 Def01AF +S A$_fs2ulong$382 Def01A1 +S A$_fs2ulong$364 Def0190 +S A$_fs2ulong$355 Def0180 +S A$_fs2ulong$346 Def0173 +S A$_fs2ulong$337 Def0165 +S A$_fs2ulong$328 Def0156 +S A$_fs2ulong$319 Def0148 +S A$_fs2ulong$292 Def0122 +S A$_fs2ulong$283 Def0110 +S A$_fs2ulong$274 Def0106 +S A$_fs2ulong$265 Def00F9 +S A$_fs2ulong$256 Def00E9 +S A$_fs2ulong$247 Def00D4 +S A$_fs2ulong$238 Def00CC +S A$_fs2ulong$229 Def00C2 +S A$_fs2ulong$193 Def0095 +S A$_fs2ulong$184 Def008B +S A$_fs2ulong$175 Def007D +S A$_fs2ulong$166 Def0071 +S A$_fs2ulong$157 Def0064 +S A$_fs2ulong$148 Def005A +S A$_fs2ulong$139 Def004D +S A$_fs2ulong$446 Def01FD +S A$_fs2ulong$437 Def01ED +S A$_fs2ulong$428 Def01E0 +S A$_fs2ulong$419 Def01D2 +S A$_fs2ulong$392 Def01B0 +S A$_fs2ulong$383 Def01A4 +S A$_fs2ulong$365 Def0191 +S A$_fs2ulong$356 Def0183 +S A$_fs2ulong$347 Def0174 +S A$_fs2ulong$338 Def0166 +S A$_fs2ulong$329 Def0157 +S A$_fs2ulong$293 Def0123 +S A$_fs2ulong$284 Def0112 +S A$_fs2ulong$275 Def0107 +S A$_fs2ulong$266 Def00FA +S A$_fs2ulong$257 Def00EC +S A$_fs2ulong$248 Def00D5 +S A$_fs2ulong$239 Def00CD +S A$_fs2ulong$194 Def0096 +S A$_fs2ulong$185 Def008C +S A$_fs2ulong$176 Def007F +S A$_fs2ulong$158 Def0065 +S A$_fs2ulong$149 Def005B +S A$_fs2ulong$438 Def01EE +S A$_fs2ulong$384 Def01A5 +S A$_fs2ulong$375 Def0197 +S A$_fs2ulong$366 Def0192 +S A$_fs2ulong$357 Def0186 +S A$_fs2ulong$348 Def0176 +S A$_fs2ulong$339 Def0168 +S A$_fs2ulong$294 Def0124 +S A$_fs2ulong$285 Def0115 +S A$_fs2ulong$276 Def0108 +S A$_fs2ulong$258 Def00EF +S A$_fs2ulong$249 Def00D7 +S A$_fs2ulong$195 Def0097 +S A$_fs2ulong$177 Def0080 +S A$_fs2ulong$168 Def0073 +S A$_fs2ulong$159 Def0067 +S A$_fs2ulong$439 Def01F0 +S A$_fs2ulong$394 Def01B1 +S A$_fs2ulong$385 Def01A7 +S A$_fs2ulong$376 Def0198 +S A$_fs2ulong$367 Def0194 +S A$_fs2ulong$358 Def0188 +S A$_fs2ulong$349 Def0178 +S A$_fs2ulong$295 Def0126 +S A$_fs2ulong$286 Def0117 +S A$_fs2ulong$277 Def0109 +S A$_fs2ulong$268 Def00FB +S A$_fs2ulong$259 Def00F1 +S A$_fs2ulong$196 Def0098 +S A$_fs2ulong$187 Def008D +S A$_fs2ulong$178 Def0082 +S A$_fs2ulong$169 Def0074 +S A$_fs2ulong$395 Def01B3 +S A$_fs2ulong$386 Def01A8 +S A$_fs2ulong$377 Def019A +S A$_fs2ulong$359 Def0189 +S A$_fs2ulong$296 Def0127 +S A$_fs2ulong$287 Def0119 +S A$_fs2ulong$278 Def010A +S A$_fs2ulong$269 Def00FC +S A$_fs2ulong$197 Def0099 +S A$_fs2ulong$188 Def0090 +S A$_fs2ulong$179 Def0084 +S XG$__fs2ulong$0$0 Def01FF +S A$_fs2ulong$396 Def01B4 +S A$_fs2ulong$387 Def01A9 +S A$_fs2ulong$378 Def019C +S A$_fs2ulong$369 Def0195 +S A$_fs2ulong$297 Def0128 +S A$_fs2ulong$279 Def010B +S A$_fs2ulong$198 Def009A +S A$_fs2ulong$189 Def0091 +S A$_fs2ulong$388 Def01AB +S A$_fs2ulong$379 Def019E +S A$_fs2ulong$298 Def012A +S A$_fs2ulong$289 Def011C +S A$_fs2ulong$199 Def009B +S A$_fs2ulong$398 Def01B6 +S A$_fs2ulong$389 Def01AC +S A$_fs2ulong$299 Def012B +S A$_fs2ulong$80 Def0010 +S A$_fs2ulong$90 Def001D +S A$_fs2ulong$81 Def0011 +S A$_fs2ulong$72 Def0000 +S G$__fs2ulong$0$0 Def0000 +S A$_fs2ulong$91 Def001E +S A$_fs2ulong$82 Def0012 +S A$_fs2ulong$73 Def0002 +S A$_fs2ulong$92 Def001F +S A$_fs2ulong$83 Def0014 +S A$_fs2ulong$74 Def0004 +S A$_fs2ulong$93 Def0020 +S A$_fs2ulong$84 Def0015 +S A$_fs2ulong$75 Def0006 +S A$_fs2ulong$94 Def0021 +S A$_fs2ulong$85 Def0016 +S A$_fs2ulong$76 Def0008 +S C$_fs2ulong.c$97$1$1 Def01FF +S A$_fs2ulong$95 Def0022 +S A$_fs2ulong$86 Def0018 +S A$_fs2ulong$77 Def000B +S A$_fs2ulong$96 Def0023 +S A$_fs2ulong$87 Def0019 +S A$_fs2ulong$78 Def000D +S A$_fs2ulong$97 Def0024 +S A$_fs2ulong$79 Def000E +S A$_fs2ulong$98 Def0025 +S A$_fs2ulong$89 Def001A +S A$_fs2ulong$99 Def0026 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 04 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 45 4B 4C 4D 70 0A +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A E4 F5 82 F5 83 F5 F0 02 01 FF +R 00 00 00 07 00 0A 00 07 +T 00 54 +R 00 00 00 07 +T 00 54 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 62 8C 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 70 02 44 FE +R 00 00 00 07 +T 00 73 +R 00 00 00 07 +T 00 73 FB 33 95 E0 FC FD EA 75 F0 00 24 6A FA E5 +R 00 00 00 07 +T 00 81 F0 34 FF FB 90 00 08 EA F0 A3 EB F0 90 +R 00 00 00 07 00 07 00 05 +T 00 8E 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF 53 +R 00 00 00 07 00 02 00 05 +T 00 9C 06 7F 7F 00 90 00 0A EA F0 A3 EB F0 74 80 +R 00 00 00 07 00 07 00 05 +T 00 AA 4E A3 F0 A3 EF F0 90 00 08 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 B8 C3 E4 9A 74 80 8B F0 63 F0 80 95 F0 50 2E +R 00 00 00 07 +T 00 C6 +R 00 00 00 07 +T 00 C6 90 00 04 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 D4 23 54 01 FA 43 02 7F 8A 00 00 75 00 01 00 +R 00 00 00 07 29 0A 00 01 29 0D 00 01 +T 00 E0 75 00 02 00 75 00 03 00 85 00 00 82 85 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 EA 00 01 83 85 00 02 F0 E5 00 03 02 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 F2 01 FF +R 00 00 00 07 00 02 00 07 +T 00 F4 +R 00 00 00 07 +T 00 F4 90 00 08 E0 FA A3 E0 F8 20 E7 03 02 01 97 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 01 02 +R 00 00 00 07 +T 01 02 90 00 08 E0 FA A3 E0 F8 C3 74 E7 9A 74 7F +R 00 00 00 07 00 03 00 05 +T 01 10 88 F0 63 F0 80 95 F0 40 03 02 01 97 +R 00 00 00 07 00 0C 00 07 +T 01 1C +R 00 00 00 07 +T 01 1C 90 00 0A E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 28 F5 00 02 A3 E0 F5 00 03 E5 00 00 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 31 00 01 45 00 02 45 00 03 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 39 01 97 +R 00 00 00 07 00 02 00 07 +T 01 3B +R 00 00 00 07 +T 01 3B 90 00 08 E0 FA A3 E0 F8 C3 E4 9A F5 00 00 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 01 48 E4 98 F5 00 01 90 00 0A E0 F5 00 04 A3 E0 +R 00 00 00 07 29 05 00 01 00 08 00 05 29 0C 00 01 +T 01 54 F5 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 85 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 5F 00 00 F0 05 F0 E5 00 07 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 01 6A +R 00 00 00 07 +T 01 6A A2 D2 E5 00 07 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 01 75 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 7C 00 04 13 F5 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 01 80 +R 00 00 00 07 +T 01 80 D5 F0 E7 90 00 0A E5 00 04 F0 A3 E5 00 05 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 01 8C F0 A3 E5 00 06 F0 A3 E5 00 07 F0 80 0A +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 01 97 +R 00 00 00 07 +T 01 97 E4 F5 82 F5 83 F5 F0 02 01 FF +R 00 00 00 07 00 0A 00 07 +T 01 A1 +R 00 00 00 07 +T 01 A1 90 00 04 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 AD F5 00 06 A3 E0 F5 00 07 23 54 01 FA 60 29 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 B9 +R 00 00 00 07 +T 01 B9 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 C5 F5 00 06 A3 E0 F5 00 07 C3 E4 95 00 04 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 D0 00 04 E4 95 00 05 F5 00 05 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 D8 00 06 F5 00 06 E4 95 00 07 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 DF 00 07 80 12 +R 00 00 00 07 29 02 00 01 +T 01 E2 +R 00 00 00 07 +T 01 E2 90 00 0A E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 EE F5 00 06 A3 E0 F5 00 07 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 F4 +R 00 00 00 07 +T 01 F4 85 00 04 82 85 00 05 83 85 00 06 F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 01 FE 00 07 +R 00 00 00 07 29 02 00 01 +T 01 FF +R 00 00 00 07 +T 01 FF 22 +R 00 00 00 07 diff --git a/device/lib/large/_fsadd.asm b/device/lib/large/_fsadd.asm new file mode 100644 index 00000000..670116b2 --- /dev/null +++ b/device/lib/large/_fsadd.asm @@ -0,0 +1,1406 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:25 2000 + +;-------------------------------------------------------- + .module _fsadd +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsadd_PARM_2 + .globl ___fsadd +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsadd_sloc0_1_0: + .ds 0x0004 +___fsadd_sloc1_1_0: + .ds 0x0002 +___fsadd_sloc2_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fsadd_PARM_2: + .ds 0x0004 +___fsadd_a1_1_1: + .ds 0x0004 +___fsadd_mant1_1_1: + .ds 0x0004 +___fsadd_mant2_1_1: + .ds 0x0004 +___fsadd_fl1_1_1: + .ds 0x0004 +___fsadd_fl2_1_1: + .ds 0x0004 +___fsadd_exp1_1_1: + .ds 0x0002 +___fsadd_exp2_1_1: + .ds 0x0002 +___fsadd_sign_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsadd$0$0 ==. +; _fsadd.c 17 +; ----------------------------------------- +; function __fsadd +; ----------------------------------------- +___fsadd: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsadd.c 101 + push acc + push b + push dph + push dpl + mov dptr,#___fsadd_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fsadd.c 22 + mov dptr,#___fsadd_sign_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _fsadd.c 24 + mov dptr,#___fsadd_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsadd_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsadd.c 25 + mov dptr,#___fsadd_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsadd_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsadd.c 28 + mov dptr,#(___fsadd_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00146$: +; _fsadd.c 29 + mov dptr,#(___fsadd_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + ljmp 00128$ +00102$: +; _fsadd.c 30 + mov dptr,#(___fsadd_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00147$: +; _fsadd.c 31 + mov dptr,#(___fsadd_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + ljmp 00128$ +00104$: +; _fsadd.c 33 + mov dptr,#(___fsadd_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00148$ + orl a,#0xfe +00148$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov dptr,#___fsadd_exp1_1_1 + mov a,r2 + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _fsadd.c 34 + mov dptr,#(___fsadd_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + mov ar2,r6 + mov a,r7 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00149$ + orl a,#0xfe +00149$: + mov r3,a + rlc a + subb a,acc + mov r6,a + mov r7,a + mov dptr,#___fsadd_exp2_1_1 + mov a,r2 + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _fsadd.c 36 + mov dptr,#___fsadd_exp2_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov a,#0x19 + add a,r2 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r3,a + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + clr c + mov a,r2 + subb a,r0 + mov a,r3 + xrl a,#0x80 + mov b,r1 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00150$: +; _fsadd.c 37 + mov dptr,#(___fsadd_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r2 + mov dph,r3 + mov b,r0 + lcall ___long2fs + mov r2,dpl + mov r3,dph + mov r0,b +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r2 + mov dph,r3 + mov b,r0 + ljmp 00128$ +00106$: +; _fsadd.c 38 + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov a,#0x19 + add a,r2 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r3,a + mov dptr,#___fsadd_exp2_1_1 + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + clr c + mov a,r2 + subb a,r0 + mov a,r3 + xrl a,#0x80 + mov b,r1 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00108$ +00151$: +; _fsadd.c 39 + mov dptr,#(___fsadd_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r2 + mov dph,r3 + mov b,r0 + lcall ___long2fs + mov r2,dpl + mov r3,dph + mov r0,b +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r2 + mov dph,r3 + mov b,r0 + ljmp 00128$ +00108$: +; _fsadd.c 42 + mov dptr,#(___fsadd_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + anl ar0,#0x7f + mov r1,#0x00 + orl ar0,#0x80 + mov a,r1 + anl a,#0x03 + mov c,acc.0 + xch a,r0 + rrc a + xch a,r0 + rrc a + xch a,r0 + rrc a + xch a,r0 + rrc a + xch a,r0 + mov r1,a + mov a,r3 + rr a + rr a + anl a,#0x3f + orl a,r0 + mov r0,a + mov a,r3 + anl a,#0x03 + mov c,acc.0 + xch a,r2 + rrc a + xch a,r2 + rrc a + xch a,r2 + rrc a + xch a,r2 + rrc a + xch a,r2 + mov r3,a + mov dptr,#___fsadd_mant1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a +; _fsadd.c 43 + mov dptr,#(___fsadd_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + anl ar0,#0x7f + mov r1,#0x00 + orl ar0,#0x80 + mov a,r1 + anl a,#0x03 + mov c,acc.0 + xch a,r0 + rrc a + xch a,r0 + rrc a + xch a,r0 + rrc a + xch a,r0 + rrc a + xch a,r0 + mov r1,a + mov a,r3 + rr a + rr a + anl a,#0x3f + orl a,r0 + mov r0,a + mov a,r3 + anl a,#0x03 + mov c,acc.0 + xch a,r2 + rrc a + xch a,r2 + rrc a + xch a,r2 + rrc a + xch a,r2 + rrc a + xch a,r2 + mov r3,a + mov dptr,#___fsadd_mant2_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a +; _fsadd.c 45 + mov dptr,#(___fsadd_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r1,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00110$ +00152$: +; _fsadd.c 46 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + clr c + clr a + subb a,___fsadd_sloc0_1_0 + movx @dptr,a + clr a + subb a,(___fsadd_sloc0_1_0 + 1) + inc dptr + movx @dptr,a + clr a + subb a,(___fsadd_sloc0_1_0 + 2) + inc dptr + movx @dptr,a + clr a + subb a,(___fsadd_sloc0_1_0 + 3) + inc dptr + movx @dptr,a +00110$: +; _fsadd.c 47 + mov dptr,#(___fsadd_fl2_1_1) + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsadd_sloc0_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00153$: +; _fsadd.c 48 + mov dptr,#___fsadd_mant2_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov dptr,#___fsadd_mant2_1_1 + clr c + clr a + subb a,___fsadd_sloc0_1_0 + movx @dptr,a + clr a + subb a,(___fsadd_sloc0_1_0 + 1) + inc dptr + movx @dptr,a + clr a + subb a,(___fsadd_sloc0_1_0 + 2) + inc dptr + movx @dptr,a + clr a + subb a,(___fsadd_sloc0_1_0 + 3) + inc dptr + movx @dptr,a +00112$: +; _fsadd.c 50 + mov dptr,#___fsadd_exp2_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + mov ___fsadd_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc1_1_0 + 1),a + clr c + mov a,___fsadd_sloc0_1_0 + subb a,___fsadd_sloc1_1_0 + mov a,(___fsadd_sloc0_1_0 + 1) + xrl a,#0x80 + mov b,(___fsadd_sloc1_1_0 + 1) + xrl b,#0x80 + subb a,b + jc 00154$ + ljmp 00114$ +00154$: +; _fsadd.c 52 + mov dptr,#___fsadd_exp2_1_1 + movx a,@dptr + mov ___fsadd_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc1_1_0 + 1),a + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + clr c + mov a,___fsadd_sloc0_1_0 + subb a,___fsadd_sloc1_1_0 + mov ___fsadd_sloc1_1_0,a + mov a,(___fsadd_sloc0_1_0 + 1) + subb a,(___fsadd_sloc1_1_0 + 1) + mov (___fsadd_sloc1_1_0 + 1),a + mov dptr,#___fsadd_mant2_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov b,___fsadd_sloc1_1_0 + inc b + mov a,(___fsadd_sloc0_1_0 + 3) + rlc a + mov ov,c + sjmp 00156$ +00155$: + mov c,ov + mov a,(___fsadd_sloc0_1_0 + 3) + rrc a + mov (___fsadd_sloc0_1_0 + 3),a + mov a,(___fsadd_sloc0_1_0 + 2) + rrc a + mov (___fsadd_sloc0_1_0 + 2),a + mov a,(___fsadd_sloc0_1_0 + 1) + rrc a + mov (___fsadd_sloc0_1_0 + 1),a + mov a,___fsadd_sloc0_1_0 + rrc a + mov ___fsadd_sloc0_1_0,a +00156$: + djnz b,00155$ + mov dptr,#___fsadd_mant2_1_1 + mov a,___fsadd_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc0_1_0 + 3) + movx @dptr,a + ljmp 00115$ +00114$: +; _fsadd.c 56 + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + mov ___fsadd_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc1_1_0 + 1),a + mov dptr,#___fsadd_exp2_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + clr c + mov a,___fsadd_sloc0_1_0 + subb a,___fsadd_sloc1_1_0 + mov ___fsadd_sloc1_1_0,a + mov a,(___fsadd_sloc0_1_0 + 1) + subb a,(___fsadd_sloc1_1_0 + 1) + mov (___fsadd_sloc1_1_0 + 1),a + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov b,___fsadd_sloc1_1_0 + inc b + mov a,(___fsadd_sloc0_1_0 + 3) + rlc a + mov ov,c + sjmp 00158$ +00157$: + mov c,ov + mov a,(___fsadd_sloc0_1_0 + 3) + rrc a + mov (___fsadd_sloc0_1_0 + 3),a + mov a,(___fsadd_sloc0_1_0 + 2) + rrc a + mov (___fsadd_sloc0_1_0 + 2),a + mov a,(___fsadd_sloc0_1_0 + 1) + rrc a + mov (___fsadd_sloc0_1_0 + 1),a + mov a,___fsadd_sloc0_1_0 + rrc a + mov ___fsadd_sloc0_1_0,a +00158$: + djnz b,00157$ + mov dptr,#___fsadd_mant1_1_1 + mov a,___fsadd_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc0_1_0 + 3) + movx @dptr,a +; _fsadd.c 57 + mov dptr,#___fsadd_exp2_1_1 + movx a,@dptr + mov ___fsadd_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc1_1_0 + 1),a + mov dptr,#___fsadd_exp1_1_1 + mov a,___fsadd_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc1_1_0 + 1) + movx @dptr,a +00115$: +; _fsadd.c 59 + mov dptr,#___fsadd_mant2_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + mov a,___fsadd_sloc0_1_0 + add a,___fsadd_sloc2_1_0 + movx @dptr,a + mov a,(___fsadd_sloc0_1_0 + 1) + addc a,(___fsadd_sloc2_1_0 + 1) + inc dptr + movx @dptr,a + mov a,(___fsadd_sloc0_1_0 + 2) + addc a,(___fsadd_sloc2_1_0 + 2) + inc dptr + movx @dptr,a + mov a,(___fsadd_sloc0_1_0 + 3) + addc a,(___fsadd_sloc2_1_0 + 3) + inc dptr + movx @dptr,a +; _fsadd.c 61 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsadd_sloc2_1_0 + 3),a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00119$ +00159$: +; _fsadd.c 63 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + clr c + clr a + subb a,___fsadd_sloc2_1_0 + movx @dptr,a + clr a + subb a,(___fsadd_sloc2_1_0 + 1) + inc dptr + movx @dptr,a + clr a + subb a,(___fsadd_sloc2_1_0 + 2) + inc dptr + movx @dptr,a + clr a + subb a,(___fsadd_sloc2_1_0 + 3) + inc dptr + movx @dptr,a +; _fsadd.c 64 + mov dptr,#___fsadd_sign_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x80 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00119$: +; _fsadd.c 66 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 3),a + mov a,___fsadd_sloc2_1_0 + orl a,(___fsadd_sloc2_1_0 + 1) + orl a,(___fsadd_sloc2_1_0 + 2) + orl a,(___fsadd_sloc2_1_0 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00121$ +00160$: +; _fsadd.c 67 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00128$ +; _fsadd.c 70 +00121$: + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsadd_sloc2_1_0 + 3),a + anl a,#0xe0 +; Peephole 162 removed sjmp by inverse jump logic + jz 00162$ +00161$: + ljmp 00123$ +00162$: +; _fsadd.c 72 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 3),a + mov a,___fsadd_sloc2_1_0 + add a,acc + mov ___fsadd_sloc2_1_0,a + mov a,(___fsadd_sloc2_1_0 + 1) + rlc a + mov (___fsadd_sloc2_1_0 + 1),a + mov a,(___fsadd_sloc2_1_0 + 2) + rlc a + mov (___fsadd_sloc2_1_0 + 2),a + mov a,(___fsadd_sloc2_1_0 + 3) + rlc a + mov (___fsadd_sloc2_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + mov a,___fsadd_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 3) + movx @dptr,a +; _fsadd.c 73 + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + add a,#0xff + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + addc a,#0xff + mov (___fsadd_sloc2_1_0 + 1),a + mov dptr,#___fsadd_exp1_1_1 + mov a,___fsadd_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 1) + movx @dptr,a + ljmp 00121$ +00123$: +; _fsadd.c 77 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsadd_sloc2_1_0 + 3),a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.6,00125$ +00163$: +; _fsadd.c 79 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsadd_sloc2_1_0 + 3),a + mov c,acc.7 + rrc a + mov (___fsadd_sloc2_1_0 + 3),a + mov a,(___fsadd_sloc2_1_0 + 2) + rrc a + mov (___fsadd_sloc2_1_0 + 2),a + mov a,(___fsadd_sloc2_1_0 + 1) + rrc a + mov (___fsadd_sloc2_1_0 + 1),a + mov a,___fsadd_sloc2_1_0 + rrc a +; Peephole 100 removed redundant mov + mov ___fsadd_sloc2_1_0,a + mov dptr,#___fsadd_mant1_1_1 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 3) + movx @dptr,a +; _fsadd.c 80 + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + add a,#0x01 + movx @dptr,a + inc dptr + movx a,@dptr + addc a,#0x00 + movx @dptr,a +00125$: +; _fsadd.c 84 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 3),a + mov a,___fsadd_sloc2_1_0 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.6,00130$ +00164$: + clr a + mov (___fsadd_sloc2_1_0 + 3),a + mov (___fsadd_sloc2_1_0 + 2),a + mov (___fsadd_sloc2_1_0 + 1),a + mov ___fsadd_sloc2_1_0,#0x20 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00130$: + clr a + mov (___fsadd_sloc2_1_0 + 3),a + mov (___fsadd_sloc2_1_0 + 2),a + mov (___fsadd_sloc2_1_0 + 1),a + mov ___fsadd_sloc2_1_0,#0x1f +00131$: + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + mov a,___fsadd_sloc2_1_0 + add a,___fsadd_sloc0_1_0 + movx @dptr,a + mov a,(___fsadd_sloc2_1_0 + 1) + addc a,(___fsadd_sloc0_1_0 + 1) + inc dptr + movx @dptr,a + mov a,(___fsadd_sloc2_1_0 + 2) + addc a,(___fsadd_sloc0_1_0 + 2) + inc dptr + movx @dptr,a + mov a,(___fsadd_sloc2_1_0 + 3) + addc a,(___fsadd_sloc0_1_0 + 3) + inc dptr + movx @dptr,a +; _fsadd.c 87 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsadd_sloc2_1_0 + 3),a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.6,00127$ +00165$: +; _fsadd.c 89 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsadd_sloc2_1_0 + 3),a + mov c,acc.7 + rrc a + mov (___fsadd_sloc2_1_0 + 3),a + mov a,(___fsadd_sloc2_1_0 + 2) + rrc a + mov (___fsadd_sloc2_1_0 + 2),a + mov a,(___fsadd_sloc2_1_0 + 1) + rrc a + mov (___fsadd_sloc2_1_0 + 1),a + mov a,___fsadd_sloc2_1_0 + rrc a +; Peephole 100 removed redundant mov + mov ___fsadd_sloc2_1_0,a + mov dptr,#___fsadd_mant1_1_1 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 3) + movx @dptr,a +; _fsadd.c 90 + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + add a,#0x01 + movx @dptr,a + inc dptr + movx a,@dptr + addc a,#0x00 + movx @dptr,a +00127$: +; _fsadd.c 94 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 3),a + mov a,(___fsadd_sloc2_1_0 + 1) + mov c,acc.7 + xch a,___fsadd_sloc2_1_0 + rlc a + xch a,___fsadd_sloc2_1_0 + rlc a + xch a,___fsadd_sloc2_1_0 + rlc a + xch a,___fsadd_sloc2_1_0 + rlc a + xch a,___fsadd_sloc2_1_0 + anl a,#0x03 + mov (___fsadd_sloc2_1_0 + 1),a + mov a,(___fsadd_sloc2_1_0 + 2) + add a,acc + add a,acc + orl a,(___fsadd_sloc2_1_0 + 1) + mov (___fsadd_sloc2_1_0 + 1),a + mov a,(___fsadd_sloc2_1_0 + 3) + mov c,acc.7 + xch a,(___fsadd_sloc2_1_0 + 2) + rlc a + xch a,(___fsadd_sloc2_1_0 + 2) + rlc a + xch a,(___fsadd_sloc2_1_0 + 2) + rlc a + xch a,(___fsadd_sloc2_1_0 + 2) + rlc a + xch a,(___fsadd_sloc2_1_0 + 2) + anl a,#0x03 + jnb acc.1,00166$ + orl a,#0xfc +00166$: + mov (___fsadd_sloc2_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + mov a,___fsadd_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 3) + movx @dptr,a +; _fsadd.c 97 + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + mov a,___fsadd_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 1) + movx @dptr,a + mov a,#0x7f + anl a,(___fsadd_sloc2_1_0 + 2) + inc dptr + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 3) + movx @dptr,a +; _fsadd.c 100 + mov dptr,#___fsadd_exp1_1_1 + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + mov (___fsadd_sloc2_1_0 + 2),___fsadd_sloc2_1_0 + mov a,(___fsadd_sloc2_1_0 + 1) + anl a,#0x01 + mov c,acc.0 + xch a,(___fsadd_sloc2_1_0 + 2) + rrc a + xch a,(___fsadd_sloc2_1_0 + 2) + rrc a + xch a,(___fsadd_sloc2_1_0 + 2) + mov (___fsadd_sloc2_1_0 + 3),a + mov (___fsadd_sloc2_1_0 + 1),#0x00 + mov ___fsadd_sloc2_1_0,#0x00 + mov dptr,#___fsadd_sign_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov a,___fsadd_sloc0_1_0 + orl ___fsadd_sloc2_1_0,a + mov a,(___fsadd_sloc0_1_0 + 1) + orl (___fsadd_sloc2_1_0 + 1),a + mov a,(___fsadd_sloc0_1_0 + 2) + orl (___fsadd_sloc2_1_0 + 2),a + mov a,(___fsadd_sloc0_1_0 + 3) + orl (___fsadd_sloc2_1_0 + 3),a + mov dptr,#___fsadd_mant1_1_1 + movx a,@dptr + mov ___fsadd_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc0_1_0 + 3),a + mov a,___fsadd_sloc0_1_0 + orl ___fsadd_sloc2_1_0,a + mov a,(___fsadd_sloc0_1_0 + 1) + orl (___fsadd_sloc2_1_0 + 1),a + mov a,(___fsadd_sloc0_1_0 + 2) + orl (___fsadd_sloc2_1_0 + 2),a + mov a,(___fsadd_sloc0_1_0 + 3) + orl (___fsadd_sloc2_1_0 + 3),a + mov dptr,#(___fsadd_fl1_1_1) + mov a,___fsadd_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsadd_sloc2_1_0 + 3) + movx @dptr,a +; _fsadd.c 101 + mov dptr,#(___fsadd_fl1_1_1) + movx a,@dptr + mov ___fsadd_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsadd_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov (___fsadd_sloc2_1_0 + 3),a + mov dpl,___fsadd_sloc2_1_0 + mov dph,(___fsadd_sloc2_1_0 + 1) + mov b,(___fsadd_sloc2_1_0 + 2) +00128$: + C$_fsadd.c$102$1$1 ==. + XG$__fsadd$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fsadd.cdb b/device/lib/large/_fsadd.cdb new file mode 100644 index 00000000..192532fc --- /dev/null +++ b/device/lib/large/_fsadd.cdb @@ -0,0 +1,2 @@ +M:_fsadd +F:G$__fsadd$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fsadd.rel b/device/lib/large/_fsadd.rel new file mode 100644 index 00000000..2e5eba41 --- /dev/null +++ b/device/lib/large/_fsadd.rel @@ -0,0 +1,1695 @@ +;!FILE _fsadd.asm +XH +H 8 areas 4B3 global symbols +M _fsadd +S ___long2fs Ref0000 +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size A flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 20 flags 40 +S ___fsadd_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 715 flags 20 +S A$_fsadd$1000 Def04B4 +S A$_fsadd$1100 Def0546 +S A$_fsadd$1010 Def04C5 +S A$_fsadd$1001 Def04B6 +S A$_fsadd$1200 Def05D3 +S A$_fsadd$1110 Def0552 +S A$_fsadd$1101 Def0547 +S A$_fsadd$1020 Def04D5 +S A$_fsadd$1011 Def04C7 +S A$_fsadd$1002 Def04B8 +S A$_fsadd$1300 Def066A +S A$_fsadd$1210 Def05E3 +S A$_fsadd$1201 Def05D5 +S A$_fsadd$1120 Def055F +S A$_fsadd$1111 Def0553 +S A$_fsadd$1102 Def0548 +S A$_fsadd$1030 Def04E3 +S A$_fsadd$1021 Def04D6 +S A$_fsadd$1012 Def04CA +S A$_fsadd$1003 Def04BA +S A$_fsadd$1400 Def070E +S A$_fsadd$1310 Def067B +S A$_fsadd$1301 Def066C +S A$_fsadd$1220 Def05EF +S A$_fsadd$1211 Def05E4 +S A$_fsadd$1202 Def05D7 +S A$_fsadd$1130 Def056E +S A$_fsadd$1112 Def0555 +S A$_fsadd$1103 Def054A +S A$_fsadd$1031 Def04E5 +S A$_fsadd$1022 Def04D8 +S A$_fsadd$1013 Def04CC +S A$_fsadd$1004 Def04BB +S A$_fsadd$1401 Def0711 +S A$_fsadd$1320 Def0688 +S A$_fsadd$1311 Def067C +S A$_fsadd$1302 Def066F +S A$_fsadd$1230 Def05FB +S A$_fsadd$1221 Def05F2 +S A$_fsadd$1212 Def05E6 +S A$_fsadd$1203 Def05D8 +S A$_fsadd$1140 Def057F +S A$_fsadd$1131 Def056F +S A$_fsadd$1122 Def0562 +S A$_fsadd$1113 Def0556 +S A$_fsadd$1050 Def0502 +S A$_fsadd$1041 Def04F4 +S A$_fsadd$1032 Def04E7 +S A$_fsadd$1014 Def04CD +S A$_fsadd$1005 Def04BD +S A$_fsadd$1330 Def069B +S A$_fsadd$1321 Def068A +S A$_fsadd$1312 Def067D +S A$_fsadd$1303 Def0671 +S A$_fsadd$1240 Def060A +S A$_fsadd$1231 Def05FE +S A$_fsadd$1222 Def05F3 +S A$_fsadd$1213 Def05E7 +S A$_fsadd$1204 Def05DA +S A$_fsadd$1150 Def058F +S A$_fsadd$1141 Def0580 +S A$_fsadd$1132 Def0571 +S A$_fsadd$1123 Def0563 +S A$_fsadd$1114 Def0557 +S A$_fsadd$1060 Def050D +S A$_fsadd$1051 Def0503 +S A$_fsadd$1042 Def04F7 +S A$_fsadd$1033 Def04EA +S A$_fsadd$1024 Def04D9 +S A$_fsadd$1015 Def04CE +S A$_fsadd$1006 Def04BF +S A$_fsadd$1340 Def06AE +S A$_fsadd$1331 Def069D +S A$_fsadd$1322 Def068D +S A$_fsadd$1313 Def067F +S A$_fsadd$1304 Def0672 +S A$_fsadd$1250 Def061A +S A$_fsadd$1241 Def060B +S A$_fsadd$1232 Def05FF +S A$_fsadd$1223 Def05F5 +S A$_fsadd$1214 Def05E8 +S A$_fsadd$1205 Def05DC +S A$_fsadd$1160 Def059E +S A$_fsadd$1151 Def0591 +S A$_fsadd$1142 Def0582 +S A$_fsadd$1133 Def0573 +S A$_fsadd$1124 Def0565 +S A$_fsadd$1115 Def0559 +S A$_fsadd$1106 Def054B +S A$_fsadd$1070 Def0519 +S A$_fsadd$1061 Def050F +S A$_fsadd$1043 Def04F8 +S A$_fsadd$1034 Def04EC +S A$_fsadd$1025 Def04DC +S A$_fsadd$1016 Def04D0 +S A$_fsadd$1007 Def04C0 +S A$_fsadd$1350 Def06BF +S A$_fsadd$1341 Def06AF +S A$_fsadd$1332 Def06A0 +S A$_fsadd$1323 Def068F +S A$_fsadd$1305 Def0673 +S A$_fsadd$1260 Def062D +S A$_fsadd$1251 Def061C +S A$_fsadd$1242 Def060D +S A$_fsadd$1233 Def0601 +S A$_fsadd$1224 Def05F6 +S A$_fsadd$1215 Def05EA +S A$_fsadd$1170 Def05AC +S A$_fsadd$1161 Def05A0 +S A$_fsadd$1152 Def0592 +S A$_fsadd$1143 Def0583 +S A$_fsadd$1134 Def0575 +S A$_fsadd$1125 Def0567 +S A$_fsadd$1116 Def055A +S A$_fsadd$1107 Def054E +S A$_fsadd$1080 Def052A +S A$_fsadd$1071 Def051B +S A$_fsadd$1062 Def0510 +S A$_fsadd$1053 Def0504 +S A$_fsadd$1044 Def04FA +S A$_fsadd$1035 Def04ED +S A$_fsadd$1026 Def04DD +S A$_fsadd$1017 Def04D1 +S A$_fsadd$1008 Def04C2 +S A$_fsadd$1405 Def0714 +S A$_fsadd$1360 Def06D0 +S A$_fsadd$1351 Def06C1 +S A$_fsadd$1342 Def06B1 +S A$_fsadd$1333 Def06A3 +S A$_fsadd$1324 Def0691 +S A$_fsadd$1315 Def0680 +S A$_fsadd$1306 Def0675 +S A$_fsadd$1270 Def063D +S A$_fsadd$1261 Def062F +S A$_fsadd$1252 Def061D +S A$_fsadd$1243 Def060F +S A$_fsadd$1234 Def0602 +S A$_fsadd$1225 Def05F7 +S A$_fsadd$1216 Def05EB +S A$_fsadd$1207 Def05DD +S A$_fsadd$1171 Def05AE +S A$_fsadd$1162 Def05A2 +S A$_fsadd$1153 Def0594 +S A$_fsadd$1144 Def0584 +S A$_fsadd$1126 Def0569 +S A$_fsadd$1117 Def055B +S A$_fsadd$1108 Def054F +S A$_fsadd$1090 Def0538 +S A$_fsadd$1081 Def052C +S A$_fsadd$1072 Def051D +S A$_fsadd$1063 Def0511 +S A$_fsadd$1045 Def04FB +S A$_fsadd$1036 Def04EE +S A$_fsadd$1027 Def04DF +S A$_fsadd$1018 Def04D2 +S A$_fsadd$1009 Def04C4 +S A$_fsadd$1370 Def06E1 +S A$_fsadd$1361 Def06D1 +S A$_fsadd$1352 Def06C3 +S A$_fsadd$1343 Def06B2 +S A$_fsadd$1334 Def06A6 +S A$_fsadd$1325 Def0693 +S A$_fsadd$1316 Def0683 +S A$_fsadd$1307 Def0676 +S A$_fsadd$1280 Def064F +S A$_fsadd$1271 Def063F +S A$_fsadd$1262 Def0631 +S A$_fsadd$1253 Def061F +S A$_fsadd$1244 Def0611 +S A$_fsadd$1235 Def0603 +S A$_fsadd$1226 Def05F8 +S A$_fsadd$1217 Def05EC +S A$_fsadd$1208 Def05DF +S A$_fsadd$1190 Def05C5 +S A$_fsadd$1172 Def05AF +S A$_fsadd$1163 Def05A3 +S A$_fsadd$1154 Def0596 +S A$_fsadd$1145 Def0586 +S A$_fsadd$1136 Def0578 +S A$_fsadd$1118 Def055D +S A$_fsadd$1109 Def0551 +S A$_fsadd$1091 Def053A +S A$_fsadd$1073 Def051E +S A$_fsadd$1064 Def0513 +S A$_fsadd$1055 Def0506 +S A$_fsadd$1046 Def04FC +S A$_fsadd$1037 Def04F0 +S A$_fsadd$1028 Def04E1 +S A$_fsadd$1019 Def04D4 +S A$_fsadd$1380 Def06F2 +S A$_fsadd$1371 Def06E3 +S A$_fsadd$1362 Def06D3 +S A$_fsadd$1353 Def06C5 +S A$_fsadd$1344 Def06B3 +S A$_fsadd$1335 Def06A7 +S A$_fsadd$1326 Def0695 +S A$_fsadd$1317 Def0684 +S A$_fsadd$1308 Def0678 +S A$_fsadd$1290 Def065D +S A$_fsadd$1281 Def0651 +S A$_fsadd$1272 Def0641 +S A$_fsadd$1263 Def0633 +S A$_fsadd$1254 Def0621 +S A$_fsadd$1245 Def0613 +S A$_fsadd$1236 Def0605 +S A$_fsadd$1227 Def05FA +S A$_fsadd$1218 Def05EE +S A$_fsadd$1209 Def05E2 +S A$_fsadd$1191 Def05C7 +S A$_fsadd$1182 Def05B9 +S A$_fsadd$1173 Def05B0 +S A$_fsadd$1155 Def0597 +S A$_fsadd$1146 Def0587 +S A$_fsadd$1137 Def057B +S A$_fsadd$1128 Def056C +S A$_fsadd$1092 Def053B +S A$_fsadd$1083 Def052D +S A$_fsadd$1074 Def0520 +S A$_fsadd$1065 Def0514 +S A$_fsadd$1047 Def04FE +S A$_fsadd$1038 Def04F1 +S A$_fsadd$1029 Def04E2 +S A$_fsadd$1390 Def0700 +S A$_fsadd$1381 Def06F4 +S A$_fsadd$1372 Def06E5 +S A$_fsadd$1363 Def06D4 +S A$_fsadd$1354 Def06C8 +S A$_fsadd$1345 Def06B5 +S A$_fsadd$1336 Def06A9 +S A$_fsadd$1327 Def0696 +S A$_fsadd$1318 Def0686 +S A$_fsadd$1309 Def067A +S A$_fsadd$1291 Def065E +S A$_fsadd$1282 Def0652 +S A$_fsadd$1273 Def0644 +S A$_fsadd$1264 Def0634 +S A$_fsadd$1255 Def0623 +S A$_fsadd$1246 Def0614 +S A$_fsadd$1237 Def0606 +S A$_fsadd$1192 Def05C8 +S A$_fsadd$1183 Def05BC +S A$_fsadd$1174 Def05B2 +S A$_fsadd$1165 Def05A4 +S A$_fsadd$1156 Def0598 +S A$_fsadd$1147 Def0588 +S A$_fsadd$1138 Def057C +S A$_fsadd$1093 Def053C +S A$_fsadd$1084 Def052F +S A$_fsadd$1075 Def0522 +S A$_fsadd$1066 Def0515 +S A$_fsadd$1048 Def04FF +S A$_fsadd$1391 Def0701 +S A$_fsadd$1382 Def06F5 +S A$_fsadd$1373 Def06E7 +S A$_fsadd$1364 Def06D5 +S A$_fsadd$1355 Def06C9 +S A$_fsadd$1346 Def06B7 +S A$_fsadd$1337 Def06AA +S A$_fsadd$1328 Def0698 +S A$_fsadd$1319 Def0687 +S A$_fsadd$1292 Def0660 +S A$_fsadd$1283 Def0653 +S A$_fsadd$1265 Def0636 +S A$_fsadd$1256 Def0625 +S A$_fsadd$1247 Def0616 +S A$_fsadd$1238 Def0607 +S A$_fsadd$1184 Def05BD +S A$_fsadd$1175 Def05B3 +S A$_fsadd$1166 Def05A7 +S A$_fsadd$1157 Def059A +S A$_fsadd$1148 Def058A +S A$_fsadd$1139 Def057E +S A$_fsadd$1094 Def053E +S A$_fsadd$1085 Def0532 +S A$_fsadd$1076 Def0523 +S A$_fsadd$1067 Def0517 +S A$_fsadd$1058 Def0509 +S A$_fsadd$1049 Def0500 +S A$_fsadd$1392 Def0703 +S A$_fsadd$1383 Def06F6 +S A$_fsadd$1374 Def06EA +S A$_fsadd$1365 Def06D7 +S A$_fsadd$1356 Def06CB +S A$_fsadd$1347 Def06B9 +S A$_fsadd$1338 Def06AB +S A$_fsadd$1329 Def0699 +S A$_fsadd$1293 Def0661 +S A$_fsadd$1284 Def0655 +S A$_fsadd$1275 Def0646 +S A$_fsadd$1266 Def0637 +S A$_fsadd$1257 Def0627 +S A$_fsadd$1248 Def0617 +S A$_fsadd$1239 Def0609 +S A$_fsadd$1194 Def05C9 +S A$_fsadd$1185 Def05BF +S A$_fsadd$1167 Def05A8 +S A$_fsadd$1158 Def059C +S A$_fsadd$1149 Def058D +S A$_fsadd$1086 Def0533 +S A$_fsadd$1077 Def0525 +S A$_fsadd$1068 Def0518 +S A$_fsadd$1059 Def050C +S A$_fsadd$1393 Def0704 +S A$_fsadd$1384 Def06F8 +S A$_fsadd$1375 Def06EC +S A$_fsadd$1366 Def06D9 +S A$_fsadd$1357 Def06CC +S A$_fsadd$1348 Def06BB +S A$_fsadd$1339 Def06AD +S A$_fsadd$1294 Def0662 +S A$_fsadd$1285 Def0656 +S A$_fsadd$1276 Def0648 +S A$_fsadd$1267 Def0639 +S A$_fsadd$1258 Def0629 +S A$_fsadd$1249 Def0619 +S A$_fsadd$1195 Def05CB +S A$_fsadd$1186 Def05C0 +S A$_fsadd$1177 Def05B4 +S A$_fsadd$1168 Def05AA +S A$_fsadd$1159 Def059D +S A$_fsadd$1096 Def053F +S A$_fsadd$1087 Def0534 +S A$_fsadd$1078 Def0527 +S C$_fsadd.c$102$1$1 Def0714 +S A$_fsadd$1394 Def0705 +S A$_fsadd$1376 Def06ED +S A$_fsadd$1367 Def06DB +S A$_fsadd$1358 Def06CD +S A$_fsadd$1349 Def06BD +S A$_fsadd$1295 Def0664 +S A$_fsadd$1286 Def0657 +S A$_fsadd$1277 Def064B +S A$_fsadd$1268 Def063A +S A$_fsadd$1259 Def062B +S A$_fsadd$1196 Def05CD +S A$_fsadd$1187 Def05C1 +S A$_fsadd$1169 Def05AB +S A$_fsadd$1097 Def0542 +S A$_fsadd$1088 Def0536 +S A$_fsadd$1079 Def0528 +S A$_fsadd$100 Def0019 +S A$_fsadd$1395 Def0707 +S A$_fsadd$1386 Def06F9 +S A$_fsadd$1377 Def06EE +S A$_fsadd$1368 Def06DD +S A$_fsadd$1359 Def06CF +S A$_fsadd$1296 Def0665 +S A$_fsadd$1287 Def0659 +S A$_fsadd$1278 Def064D +S A$_fsadd$1269 Def063C +S A$_fsadd$1197 Def05CE +S A$_fsadd$1188 Def05C3 +S A$_fsadd$1179 Def05B6 +S A$_fsadd$1098 Def0543 +S A$_fsadd$1089 Def0537 +S A$_fsadd$200 Def008C +S A$_fsadd$110 Def0026 +S A$_fsadd$1396 Def0708 +S A$_fsadd$1387 Def06FC +S A$_fsadd$1378 Def06F0 +S A$_fsadd$1369 Def06DF +S A$_fsadd$1297 Def0666 +S A$_fsadd$1279 Def064E +S A$_fsadd$1198 Def05D0 +S A$_fsadd$1189 Def05C4 +S A$_fsadd$1099 Def0545 +S A$_fsadd$300 Def0101 +S A$_fsadd$210 Def0099 +S A$_fsadd$201 Def008E +S A$_fsadd$120 Def0035 +S A$_fsadd$111 Def0029 +S A$_fsadd$102 Def001A +S A$_fsadd$1388 Def06FD +S A$_fsadd$1379 Def06F1 +S A$_fsadd$1298 Def0668 +S A$_fsadd$1289 Def065A +S A$_fsadd$1199 Def05D2 +S A$_fsadd$400 Def0180 +S A$_fsadd$310 Def0111 +S A$_fsadd$301 Def0103 +S A$_fsadd$211 Def009A +S A$_fsadd$130 Def0041 +S A$_fsadd$121 Def0036 +S A$_fsadd$112 Def002A +S A$_fsadd$103 Def001D +S A$_fsadd$1398 Def0709 +S A$_fsadd$1389 Def06FF +S A$_fsadd$1299 Def0669 +S A$_fsadd$500 Def0200 +S A$_fsadd$410 Def018E +S A$_fsadd$401 Def0182 +S A$_fsadd$320 Def011B +S A$_fsadd$311 Def0112 +S A$_fsadd$302 Def0106 +S A$_fsadd$230 Def00AD +S A$_fsadd$221 Def00A3 +S A$_fsadd$212 Def009B +S A$_fsadd$140 Def004A +S A$_fsadd$131 Def0042 +S A$_fsadd$122 Def0037 +S A$_fsadd$113 Def002D +S A$_fsadd$104 Def001E +S ___fsadd Def0000 +S A$_fsadd$1399 Def070B +S A$_fsadd$600 Def0279 +S A$_fsadd$510 Def020F +S A$_fsadd$501 Def0201 +S A$_fsadd$420 Def0197 +S A$_fsadd$411 Def018F +S A$_fsadd$402 Def0185 +S A$_fsadd$330 Def0125 +S A$_fsadd$321 Def011C +S A$_fsadd$312 Def0113 +S A$_fsadd$240 Def00B9 +S A$_fsadd$231 Def00AE +S A$_fsadd$213 Def009C +S A$_fsadd$204 Def0091 +S A$_fsadd$150 Def0056 +S A$_fsadd$141 Def004D +S A$_fsadd$132 Def0043 +S A$_fsadd$123 Def0038 +S A$_fsadd$105 Def001F +S A$_fsadd$700 Def0307 +S A$_fsadd$610 Def0285 +S A$_fsadd$601 Def027A +S A$_fsadd$520 Def021B +S A$_fsadd$511 Def0210 +S A$_fsadd$502 Def0202 +S A$_fsadd$430 Def01A9 +S A$_fsadd$421 Def0199 +S A$_fsadd$412 Def0190 +S A$_fsadd$340 Def0131 +S A$_fsadd$331 Def0128 +S A$_fsadd$322 Def011D +S A$_fsadd$304 Def0108 +S A$_fsadd$250 Def00C5 +S A$_fsadd$232 Def00AF +S A$_fsadd$214 Def009D +S A$_fsadd$205 Def0094 +S A$_fsadd$160 Def0062 +S A$_fsadd$151 Def0057 +S A$_fsadd$142 Def004E +S A$_fsadd$133 Def0044 +S A$_fsadd$124 Def0039 +S A$_fsadd$115 Def002E +S A$_fsadd$106 Def0020 +S A$_fsadd$800 Def03A9 +S A$_fsadd$710 Def0317 +S A$_fsadd$701 Def0309 +S A$_fsadd$620 Def0291 +S A$_fsadd$611 Def0286 +S A$_fsadd$602 Def027B +S A$_fsadd$530 Def0226 +S A$_fsadd$521 Def021C +S A$_fsadd$512 Def0212 +S A$_fsadd$503 Def0203 +S A$_fsadd$440 Def01B7 +S A$_fsadd$431 Def01AB +S A$_fsadd$422 Def019B +S A$_fsadd$413 Def0191 +S A$_fsadd$404 Def0187 +S A$_fsadd$350 Def0140 +S A$_fsadd$341 Def0133 +S A$_fsadd$332 Def0129 +S A$_fsadd$323 Def011E +S A$_fsadd$314 Def0114 +S A$_fsadd$305 Def0109 +S A$_fsadd$260 Def00D1 +S A$_fsadd$251 Def00C6 +S A$_fsadd$233 Def00B0 +S A$_fsadd$224 Def00A5 +S A$_fsadd$215 Def009E +S A$_fsadd$206 Def0095 +S A$_fsadd$170 Def006D +S A$_fsadd$161 Def0063 +S A$_fsadd$152 Def0058 +S A$_fsadd$143 Def004F +S A$_fsadd$134 Def0045 +S A$_fsadd$125 Def003A +S A$_fsadd$116 Def0031 +S A$_fsadd$107 Def0021 +S A$_fsadd$900 Def0438 +S A$_fsadd$810 Def03B9 +S A$_fsadd$801 Def03AA +S A$_fsadd$711 Def0319 +S A$_fsadd$702 Def030B +S A$_fsadd$630 Def029B +S A$_fsadd$621 Def0292 +S A$_fsadd$612 Def0287 +S A$_fsadd$603 Def027D +S A$_fsadd$540 Def0232 +S A$_fsadd$531 Def0228 +S A$_fsadd$522 Def021D +S A$_fsadd$513 Def0214 +S A$_fsadd$504 Def0204 +S A$_fsadd$450 Def01C6 +S A$_fsadd$441 Def01B8 +S A$_fsadd$432 Def01AD +S A$_fsadd$423 Def019D +S A$_fsadd$414 Def0192 +S A$_fsadd$360 Def0149 +S A$_fsadd$351 Def0141 +S A$_fsadd$342 Def0135 +S A$_fsadd$333 Def012A +S A$_fsadd$324 Def0120 +S A$_fsadd$315 Def0115 +S A$_fsadd$306 Def010A +S A$_fsadd$270 Def00DF +S A$_fsadd$261 Def00D2 +S A$_fsadd$252 Def00C7 +S A$_fsadd$243 Def00BC +S A$_fsadd$234 Def00B1 +S A$_fsadd$225 Def00A8 +S A$_fsadd$216 Def009F +S A$_fsadd$207 Def0096 +S A$_fsadd$180 Def0077 +S A$_fsadd$171 Def006E +S A$_fsadd$162 Def0064 +S A$_fsadd$153 Def005B +S A$_fsadd$144 Def0050 +S A$_fsadd$135 Def0046 +S A$_fsadd$126 Def003B +S A$_fsadd$117 Def0032 +S A$_fsadd$108 Def0022 +S A$_fsadd$910 Def0447 +S A$_fsadd$901 Def043A +S A$_fsadd$820 Def03C7 +S A$_fsadd$811 Def03BA +S A$_fsadd$730 Def0338 +S A$_fsadd$721 Def0329 +S A$_fsadd$712 Def031A +S A$_fsadd$703 Def030E +S A$_fsadd$640 Def02A9 +S A$_fsadd$631 Def029D +S A$_fsadd$613 Def0289 +S A$_fsadd$604 Def027E +S A$_fsadd$550 Def023E +S A$_fsadd$541 Def0233 +S A$_fsadd$532 Def022A +S A$_fsadd$523 Def021E +S A$_fsadd$514 Def0215 +S A$_fsadd$505 Def0205 +S A$_fsadd$460 Def01D2 +S A$_fsadd$451 Def01C7 +S A$_fsadd$442 Def01B9 +S A$_fsadd$424 Def01A0 +S A$_fsadd$415 Def0193 +S A$_fsadd$370 Def015A +S A$_fsadd$361 Def014A +S A$_fsadd$352 Def0142 +S A$_fsadd$343 Def0138 +S A$_fsadd$334 Def012B +S A$_fsadd$325 Def0121 +S A$_fsadd$307 Def010C +S A$_fsadd$280 Def00E9 +S A$_fsadd$271 Def00E0 +S A$_fsadd$262 Def00D3 +S A$_fsadd$253 Def00C8 +S A$_fsadd$244 Def00BF +S A$_fsadd$226 Def00A9 +S A$_fsadd$217 Def00A0 +S A$_fsadd$208 Def0097 +S A$_fsadd$190 Def0081 +S A$_fsadd$172 Def006F +S A$_fsadd$163 Def0065 +S A$_fsadd$154 Def005C +S A$_fsadd$145 Def0051 +S A$_fsadd$136 Def0047 +S A$_fsadd$127 Def003C +S A$_fsadd$118 Def0033 +S A$_fsadd$109 Def0025 +S A$_fsadd$911 Def0448 +S A$_fsadd$902 Def043D +S A$_fsadd$821 Def03C8 +S A$_fsadd$812 Def03BC +S A$_fsadd$803 Def03AC +S A$_fsadd$740 Def0349 +S A$_fsadd$731 Def033A +S A$_fsadd$722 Def032B +S A$_fsadd$713 Def031B +S A$_fsadd$704 Def030F +S A$_fsadd$650 Def02B7 +S A$_fsadd$641 Def02AC +S A$_fsadd$632 Def029E +S A$_fsadd$623 Def0294 +S A$_fsadd$614 Def028A +S A$_fsadd$560 Def0249 +S A$_fsadd$551 Def023F +S A$_fsadd$542 Def0234 +S A$_fsadd$533 Def022B +S A$_fsadd$524 Def021F +S A$_fsadd$515 Def0216 +S A$_fsadd$506 Def0206 +S A$_fsadd$470 Def01DD +S A$_fsadd$461 Def01D3 +S A$_fsadd$452 Def01C9 +S A$_fsadd$443 Def01BA +S A$_fsadd$425 Def01A2 +S A$_fsadd$416 Def0194 +S A$_fsadd$407 Def0189 +S A$_fsadd$380 Def0169 +S A$_fsadd$371 Def015C +S A$_fsadd$362 Def014C +S A$_fsadd$353 Def0143 +S A$_fsadd$335 Def012C +S A$_fsadd$317 Def0116 +S A$_fsadd$308 Def010D +S A$_fsadd$290 Def00F5 +S A$_fsadd$281 Def00EC +S A$_fsadd$272 Def00E1 +S A$_fsadd$263 Def00D4 +S A$_fsadd$254 Def00C9 +S A$_fsadd$245 Def00C0 +S A$_fsadd$236 Def00B2 +S A$_fsadd$227 Def00AA +S A$_fsadd$218 Def00A1 +S A$_fsadd$209 Def0098 +S A$_fsadd$191 Def0082 +S A$_fsadd$182 Def0078 +S A$_fsadd$173 Def0070 +S A$_fsadd$155 Def005D +S A$_fsadd$146 Def0052 +S A$_fsadd$137 Def0048 +S A$_fsadd$128 Def003F +S A$_fsadd$119 Def0034 +S A$_fsadd$930 Def045B +S A$_fsadd$912 Def044A +S A$_fsadd$903 Def043E +S A$_fsadd$840 Def03E3 +S A$_fsadd$831 Def03D5 +S A$_fsadd$822 Def03C9 +S A$_fsadd$813 Def03BD +S A$_fsadd$804 Def03AF +S A$_fsadd$741 Def034B +S A$_fsadd$732 Def033C +S A$_fsadd$723 Def032D +S A$_fsadd$714 Def031D +S A$_fsadd$705 Def0311 +S A$_fsadd$660 Def02C3 +S A$_fsadd$651 Def02B9 +S A$_fsadd$642 Def02AD +S A$_fsadd$633 Def029F +S A$_fsadd$615 Def028B +S A$_fsadd$561 Def024A +S A$_fsadd$552 Def0240 +S A$_fsadd$543 Def0237 +S A$_fsadd$534 Def022C +S A$_fsadd$525 Def0220 +S A$_fsadd$516 Def0217 +S A$_fsadd$507 Def0207 +S A$_fsadd$480 Def01E9 +S A$_fsadd$471 Def01DF +S A$_fsadd$462 Def01D4 +S A$_fsadd$453 Def01CB +S A$_fsadd$444 Def01BB +S A$_fsadd$435 Def01B0 +S A$_fsadd$426 Def01A4 +S A$_fsadd$417 Def0195 +S A$_fsadd$408 Def018C +S A$_fsadd$390 Def0175 +S A$_fsadd$381 Def016A +S A$_fsadd$372 Def015E +S A$_fsadd$363 Def014E +S A$_fsadd$354 Def0144 +S A$_fsadd$345 Def013A +S A$_fsadd$336 Def012D +S A$_fsadd$327 Def0122 +S A$_fsadd$318 Def0119 +S A$_fsadd$309 Def010E +S A$_fsadd$291 Def00F6 +S A$_fsadd$282 Def00ED +S A$_fsadd$273 Def00E4 +S A$_fsadd$264 Def00D6 +S A$_fsadd$255 Def00CA +S A$_fsadd$246 Def00C1 +S A$_fsadd$237 Def00B3 +S A$_fsadd$228 Def00AB +S A$_fsadd$219 Def00A2 +S A$_fsadd$192 Def0083 +S A$_fsadd$174 Def0071 +S A$_fsadd$165 Def0066 +S A$_fsadd$156 Def005E +S A$_fsadd$147 Def0053 +S A$_fsadd$138 Def0049 +S A$_fsadd$129 Def0040 +S A$_fsadd$940 Def0467 +S A$_fsadd$931 Def045C +S A$_fsadd$922 Def0454 +S A$_fsadd$913 Def044B +S A$_fsadd$904 Def043F +S A$_fsadd$850 Def03F2 +S A$_fsadd$841 Def03E4 +S A$_fsadd$832 Def03D8 +S A$_fsadd$823 Def03CB +S A$_fsadd$814 Def03BE +S A$_fsadd$805 Def03B2 +S A$_fsadd$760 Def0367 +S A$_fsadd$751 Def0357 +S A$_fsadd$742 Def034C +S A$_fsadd$733 Def033D +S A$_fsadd$724 Def032E +S A$_fsadd$715 Def0320 +S A$_fsadd$706 Def0312 +S A$_fsadd$670 Def02D2 +S A$_fsadd$661 Def02C4 +S A$_fsadd$652 Def02BA +S A$_fsadd$643 Def02AE +S A$_fsadd$634 Def02A1 +S A$_fsadd$625 Def0295 +S A$_fsadd$616 Def028D +S A$_fsadd$607 Def027F +S A$_fsadd$580 Def025D +S A$_fsadd$571 Def0253 +S A$_fsadd$562 Def024B +S A$_fsadd$553 Def0241 +S A$_fsadd$544 Def0238 +S A$_fsadd$535 Def022D +S A$_fsadd$526 Def0221 +S A$_fsadd$517 Def0218 +S A$_fsadd$508 Def020A +S A$_fsadd$490 Def01F5 +S A$_fsadd$481 Def01EA +S A$_fsadd$472 Def01E1 +S A$_fsadd$463 Def01D5 +S A$_fsadd$454 Def01CC +S A$_fsadd$445 Def01BC +S A$_fsadd$436 Def01B3 +S A$_fsadd$409 Def018D +S A$_fsadd$391 Def0176 +S A$_fsadd$382 Def016B +S A$_fsadd$373 Def0160 +S A$_fsadd$364 Def0150 +S A$_fsadd$355 Def0145 +S A$_fsadd$337 Def012E +S A$_fsadd$328 Def0123 +S A$_fsadd$319 Def011A +S A$_fsadd$292 Def00F7 +S A$_fsadd$283 Def00EE +S A$_fsadd$274 Def00E5 +S A$_fsadd$265 Def00D9 +S A$_fsadd$256 Def00CC +S A$_fsadd$247 Def00C2 +S A$_fsadd$238 Def00B5 +S A$_fsadd$229 Def00AC +S A$_fsadd$193 Def0084 +S A$_fsadd$175 Def0072 +S A$_fsadd$166 Def0069 +S A$_fsadd$157 Def005F +S A$_fsadd$148 Def0054 +S A$_fsadd$950 Def0475 +S A$_fsadd$941 Def0468 +S A$_fsadd$932 Def045E +S A$_fsadd$923 Def0455 +S A$_fsadd$914 Def044C +S A$_fsadd$905 Def0441 +S A$_fsadd$860 Def0403 +S A$_fsadd$851 Def03F3 +S A$_fsadd$842 Def03E5 +S A$_fsadd$833 Def03D9 +S A$_fsadd$824 Def03CE +S A$_fsadd$815 Def03C0 +S A$_fsadd$806 Def03B4 +S A$_fsadd$770 Def0378 +S A$_fsadd$761 Def0368 +S A$_fsadd$752 Def035A +S A$_fsadd$743 Def034D +S A$_fsadd$725 Def0330 +S A$_fsadd$716 Def0322 +S A$_fsadd$707 Def0313 +S A$_fsadd$680 Def02E7 +S A$_fsadd$671 Def02D4 +S A$_fsadd$662 Def02C6 +S A$_fsadd$653 Def02BB +S A$_fsadd$644 Def02B0 +S A$_fsadd$635 Def02A2 +S A$_fsadd$617 Def028E +S A$_fsadd$608 Def0282 +S A$_fsadd$590 Def026C +S A$_fsadd$581 Def025E +S A$_fsadd$563 Def024C +S A$_fsadd$545 Def0239 +S A$_fsadd$536 Def022E +S A$_fsadd$527 Def0223 +S A$_fsadd$518 Def0219 +S A$_fsadd$509 Def020C +S A$_fsadd$491 Def01F6 +S A$_fsadd$482 Def01EB +S A$_fsadd$473 Def01E2 +S A$_fsadd$464 Def01D6 +S A$_fsadd$455 Def01CD +S A$_fsadd$446 Def01BD +S A$_fsadd$437 Def01B4 +S A$_fsadd$428 Def01A6 +S A$_fsadd$419 Def0196 +S A$_fsadd$392 Def0177 +S A$_fsadd$383 Def016D +S A$_fsadd$365 Def0153 +S A$_fsadd$356 Def0146 +S A$_fsadd$338 Def012F +S A$_fsadd$329 Def0124 +S A$_fsadd$293 Def00F9 +S A$_fsadd$284 Def00EF +S A$_fsadd$275 Def00E6 +S A$_fsadd$257 Def00CD +S A$_fsadd$248 Def00C3 +S A$_fsadd$239 Def00B7 +S A$_fsadd$194 Def0085 +S A$_fsadd$185 Def007A +S A$_fsadd$176 Def0073 +S A$_fsadd$167 Def006A +S A$_fsadd$158 Def0060 +S A$_fsadd$149 Def0055 +S A$_fsadd$960 Def047D +S A$_fsadd$951 Def0477 +S A$_fsadd$942 Def0469 +S A$_fsadd$924 Def0456 +S A$_fsadd$915 Def044D +S A$_fsadd$906 Def0442 +S A$_fsadd$870 Def0412 +S A$_fsadd$861 Def0405 +S A$_fsadd$852 Def03F5 +S A$_fsadd$843 Def03E7 +S A$_fsadd$834 Def03DB +S A$_fsadd$825 Def03D0 +S A$_fsadd$807 Def03B5 +S A$_fsadd$780 Def0387 +S A$_fsadd$771 Def037B +S A$_fsadd$762 Def0369 +S A$_fsadd$753 Def035B +S A$_fsadd$744 Def034F +S A$_fsadd$735 Def033F +S A$_fsadd$726 Def0332 +S A$_fsadd$717 Def0324 +S A$_fsadd$708 Def0315 +S A$_fsadd$690 Def02F7 +S A$_fsadd$672 Def02D5 +S A$_fsadd$663 Def02C7 +S A$_fsadd$654 Def02BC +S A$_fsadd$645 Def02B1 +S A$_fsadd$636 Def02A3 +S A$_fsadd$609 Def0283 +S A$_fsadd$591 Def026D +S A$_fsadd$582 Def0260 +S A$_fsadd$573 Def0254 +S A$_fsadd$564 Def024D +S A$_fsadd$555 Def0242 +S A$_fsadd$546 Def023A +S A$_fsadd$537 Def022F +S A$_fsadd$528 Def0224 +S A$_fsadd$519 Def021A +S A$_fsadd$492 Def01F7 +S A$_fsadd$483 Def01EE +S A$_fsadd$474 Def01E3 +S A$_fsadd$465 Def01D7 +S A$_fsadd$456 Def01CE +S A$_fsadd$447 Def01BE +S A$_fsadd$438 Def01B5 +S A$_fsadd$429 Def01A7 +S A$_fsadd$393 Def0178 +S A$_fsadd$384 Def016E +S A$_fsadd$366 Def0155 +S A$_fsadd$357 Def0147 +S A$_fsadd$348 Def013C +S A$_fsadd$339 Def0130 +S A$_fsadd$294 Def00FA +S A$_fsadd$285 Def00F0 +S A$_fsadd$267 Def00DB +S A$_fsadd$258 Def00CF +S A$_fsadd$249 Def00C4 +S A$_fsadd$195 Def0086 +S A$_fsadd$186 Def007D +S A$_fsadd$177 Def0074 +S A$_fsadd$168 Def006B +S A$_fsadd$159 Def0061 +S A$_fsadd$970 Def048D +S A$_fsadd$961 Def047E +S A$_fsadd$952 Def0479 +S A$_fsadd$943 Def046B +S A$_fsadd$934 Def045F +S A$_fsadd$925 Def0457 +S A$_fsadd$916 Def044F +S A$_fsadd$907 Def0443 +S A$_fsadd$880 Def041F +S A$_fsadd$862 Def0406 +S A$_fsadd$853 Def03F6 +S A$_fsadd$844 Def03EA +S A$_fsadd$835 Def03DC +S A$_fsadd$826 Def03D1 +S A$_fsadd$817 Def03C1 +S A$_fsadd$808 Def03B6 +S A$_fsadd$790 Def0398 +S A$_fsadd$781 Def0388 +S A$_fsadd$772 Def037C +S A$_fsadd$763 Def036B +S A$_fsadd$754 Def035D +S A$_fsadd$745 Def0350 +S A$_fsadd$736 Def0342 +S A$_fsadd$727 Def0333 +S A$_fsadd$718 Def0325 +S A$_fsadd$709 Def0316 +S A$_fsadd$691 Def02F8 +S A$_fsadd$673 Def02D7 +S A$_fsadd$664 Def02C8 +S A$_fsadd$655 Def02BE +S A$_fsadd$646 Def02B2 +S A$_fsadd$637 Def02A5 +S A$_fsadd$628 Def0297 +S A$_fsadd$619 Def028F +S A$_fsadd$592 Def026F +S A$_fsadd$583 Def0261 +S A$_fsadd$565 Def024E +S A$_fsadd$556 Def0245 +S A$_fsadd$547 Def023B +S A$_fsadd$538 Def0230 +S A$_fsadd$529 Def0225 +S A$_fsadd$493 Def01F8 +S A$_fsadd$484 Def01EF +S A$_fsadd$475 Def01E4 +S A$_fsadd$466 Def01D8 +S A$_fsadd$457 Def01CF +S A$_fsadd$448 Def01C1 +S A$_fsadd$439 Def01B6 +S A$_fsadd$394 Def0179 +S A$_fsadd$376 Def0163 +S A$_fsadd$367 Def0157 +S A$_fsadd$358 Def0148 +S A$_fsadd$349 Def013F +S A$_fsadd$295 Def00FC +S A$_fsadd$286 Def00F1 +S A$_fsadd$277 Def00E7 +S A$_fsadd$268 Def00DC +S A$_fsadd$259 Def00D0 +S A$_fsadd$187 Def007E +S A$_fsadd$178 Def0075 +S A$_fsadd$169 Def006C +S A$_fsadd$980 Def0499 +S A$_fsadd$971 Def048E +S A$_fsadd$962 Def0480 +S A$_fsadd$944 Def046C +S A$_fsadd$926 Def0458 +S A$_fsadd$917 Def0450 +S A$_fsadd$908 Def0445 +S A$_fsadd$890 Def042B +S A$_fsadd$881 Def0421 +S A$_fsadd$872 Def0413 +S A$_fsadd$863 Def0407 +S A$_fsadd$854 Def03F7 +S A$_fsadd$845 Def03EB +S A$_fsadd$836 Def03DD +S A$_fsadd$827 Def03D2 +S A$_fsadd$818 Def03C4 +S A$_fsadd$809 Def03B8 +S A$_fsadd$791 Def039A +S A$_fsadd$782 Def038A +S A$_fsadd$773 Def037E +S A$_fsadd$764 Def036C +S A$_fsadd$755 Def035E +S A$_fsadd$746 Def0351 +S A$_fsadd$737 Def0345 +S A$_fsadd$728 Def0335 +S A$_fsadd$719 Def0327 +S A$_fsadd$692 Def02FA +S A$_fsadd$683 Def02EA +S A$_fsadd$674 Def02D9 +S A$_fsadd$665 Def02CA +S A$_fsadd$656 Def02BF +S A$_fsadd$647 Def02B4 +S A$_fsadd$638 Def02A6 +S A$_fsadd$629 Def029A +S A$_fsadd$593 Def0270 +S A$_fsadd$584 Def0262 +S A$_fsadd$557 Def0246 +S A$_fsadd$548 Def023C +S A$_fsadd$539 Def0231 +S A$_fsadd$485 Def01F0 +S A$_fsadd$476 Def01E5 +S A$_fsadd$467 Def01DA +S A$_fsadd$458 Def01D0 +S A$_fsadd$449 Def01C3 +S A$_fsadd$395 Def017A +S A$_fsadd$386 Def016F +S A$_fsadd$377 Def0166 +S A$_fsadd$296 Def00FD +S A$_fsadd$287 Def00F2 +S A$_fsadd$278 Def00E8 +S A$_fsadd$269 Def00DD +S A$_fsadd$197 Def0087 +S A$_fsadd$188 Def007F +S A$_fsadd$179 Def0076 +S XG$__fsadd$0$0 Def0714 +S A$_fsadd$990 Def04A6 +S A$_fsadd$972 Def048F +S A$_fsadd$963 Def0482 +S A$_fsadd$954 Def047B +S A$_fsadd$945 Def046D +S A$_fsadd$909 Def0446 +S A$_fsadd$891 Def042C +S A$_fsadd$882 Def0422 +S A$_fsadd$873 Def0416 +S A$_fsadd$864 Def0409 +S A$_fsadd$855 Def03F9 +S A$_fsadd$846 Def03ED +S A$_fsadd$837 Def03DF +S A$_fsadd$828 Def03D4 +S A$_fsadd$819 Def03C5 +S A$_fsadd$792 Def039B +S A$_fsadd$783 Def038D +S A$_fsadd$774 Def037F +S A$_fsadd$765 Def036E +S A$_fsadd$756 Def035F +S A$_fsadd$747 Def0353 +S A$_fsadd$738 Def0347 +S A$_fsadd$729 Def0337 +S A$_fsadd$693 Def02FB +S A$_fsadd$684 Def02ED +S A$_fsadd$675 Def02DB +S A$_fsadd$666 Def02CD +S A$_fsadd$648 Def02B5 +S A$_fsadd$639 Def02A7 +S A$_fsadd$594 Def0271 +S A$_fsadd$585 Def0264 +S A$_fsadd$576 Def0256 +S A$_fsadd$567 Def024F +S A$_fsadd$558 Def0247 +S A$_fsadd$549 Def023D +S A$_fsadd$495 Def01F9 +S A$_fsadd$486 Def01F1 +S A$_fsadd$477 Def01E6 +S A$_fsadd$468 Def01DB +S A$_fsadd$459 Def01D1 +S A$_fsadd$396 Def017B +S A$_fsadd$387 Def0170 +S A$_fsadd$378 Def0167 +S A$_fsadd$369 Def0159 +S A$_fsadd$297 Def00FE +S A$_fsadd$288 Def00F3 +S A$_fsadd$198 Def0088 +S A$_fsadd$189 Def0080 +S A$_fsadd$991 Def04A7 +S A$_fsadd$982 Def049B +S A$_fsadd$973 Def0491 +S A$_fsadd$964 Def0484 +S A$_fsadd$946 Def046F +S A$_fsadd$937 Def0461 +S A$_fsadd$928 Def0459 +S A$_fsadd$919 Def0451 +S A$_fsadd$892 Def042E +S A$_fsadd$874 Def0417 +S A$_fsadd$865 Def040B +S A$_fsadd$856 Def03FC +S A$_fsadd$847 Def03EE +S A$_fsadd$838 Def03E0 +S A$_fsadd$793 Def039D +S A$_fsadd$784 Def038F +S A$_fsadd$775 Def0380 +S A$_fsadd$766 Def0370 +S A$_fsadd$757 Def0361 +S A$_fsadd$748 Def0354 +S A$_fsadd$739 Def0348 +S A$_fsadd$694 Def02FC +S A$_fsadd$685 Def02EE +S A$_fsadd$676 Def02DD +S A$_fsadd$667 Def02CE +S A$_fsadd$649 Def02B6 +S A$_fsadd$595 Def0273 +S A$_fsadd$586 Def0265 +S A$_fsadd$577 Def0259 +S A$_fsadd$568 Def0250 +S A$_fsadd$559 Def0248 +S A$_fsadd$496 Def01FC +S A$_fsadd$487 Def01F2 +S A$_fsadd$478 Def01E7 +S A$_fsadd$469 Def01DC +S A$_fsadd$397 Def017C +S A$_fsadd$388 Def0171 +S A$_fsadd$379 Def0168 +S A$_fsadd$298 Def00FF +S A$_fsadd$289 Def00F4 +S A$_fsadd$199 Def008A +S A$_fsadd$992 Def04A8 +S A$_fsadd$974 Def0492 +S A$_fsadd$947 Def0470 +S A$_fsadd$938 Def0464 +S A$_fsadd$929 Def045A +S A$_fsadd$893 Def042F +S A$_fsadd$884 Def0423 +S A$_fsadd$875 Def0419 +S A$_fsadd$866 Def040C +S A$_fsadd$857 Def03FE +S A$_fsadd$848 Def03EF +S A$_fsadd$839 Def03E1 +S A$_fsadd$794 Def039F +S A$_fsadd$785 Def0391 +S A$_fsadd$776 Def0382 +S A$_fsadd$767 Def0372 +S A$_fsadd$758 Def0364 +S A$_fsadd$695 Def02FE +S A$_fsadd$686 Def02F0 +S A$_fsadd$677 Def02E0 +S A$_fsadd$668 Def02D0 +S A$_fsadd$659 Def02C0 +S A$_fsadd$596 Def0274 +S A$_fsadd$587 Def0266 +S A$_fsadd$578 Def025A +S A$_fsadd$569 Def0251 +S A$_fsadd$497 Def01FD +S A$_fsadd$488 Def01F3 +S A$_fsadd$479 Def01E8 +S A$_fsadd$398 Def017D +S A$_fsadd$389 Def0172 +S A$_fsadd$299 Def0100 +S A$_fsadd$993 Def04AA +S A$_fsadd$984 Def049D +S A$_fsadd$975 Def0493 +S A$_fsadd$948 Def0471 +S A$_fsadd$939 Def0465 +S A$_fsadd$894 Def0430 +S A$_fsadd$876 Def041A +S A$_fsadd$867 Def040D +S A$_fsadd$858 Def0400 +S A$_fsadd$849 Def03F1 +S A$_fsadd$795 Def03A0 +S A$_fsadd$786 Def0392 +S A$_fsadd$777 Def0383 +S A$_fsadd$768 Def0374 +S A$_fsadd$759 Def0365 +S A$_fsadd$696 Def02FF +S A$_fsadd$687 Def02F1 +S A$_fsadd$678 Def02E3 +S A$_fsadd$669 Def02D1 +S A$_fsadd$597 Def0275 +S A$_fsadd$588 Def0268 +S A$_fsadd$579 Def025C +S A$_fsadd$498 Def01FE +S A$_fsadd$489 Def01F4 +S A$_fsadd$399 Def017E +S A$_fsadd$994 Def04AB +S A$_fsadd$976 Def0495 +S A$_fsadd$967 Def0487 +S A$_fsadd$949 Def0473 +S A$_fsadd$895 Def0432 +S A$_fsadd$886 Def0425 +S A$_fsadd$877 Def041B +S A$_fsadd$868 Def040F +S A$_fsadd$859 Def0401 +S A$_fsadd$796 Def03A2 +S A$_fsadd$787 Def0394 +S A$_fsadd$778 Def0384 +S A$_fsadd$769 Def0376 +S A$_fsadd$697 Def0301 +S A$_fsadd$688 Def02F2 +S A$_fsadd$679 Def02E5 +S A$_fsadd$598 Def0276 +S A$_fsadd$589 Def026B +S A$_fsadd$499 Def01FF +S A$_fsadd$995 Def04AC +S A$_fsadd$977 Def0496 +S A$_fsadd$968 Def048A +S A$_fsadd$896 Def0433 +S A$_fsadd$878 Def041D +S A$_fsadd$869 Def0411 +S A$_fsadd$797 Def03A4 +S A$_fsadd$779 Def0386 +S A$_fsadd$698 Def0303 +S A$_fsadd$689 Def02F4 +S A$_fsadd$599 Def0278 +S A$_fsadd$996 Def04AE +S A$_fsadd$987 Def04A0 +S A$_fsadd$969 Def048B +S A$_fsadd$897 Def0434 +S A$_fsadd$879 Def041E +S A$_fsadd$798 Def03A5 +S A$_fsadd$789 Def0396 +S A$_fsadd$699 Def0305 +S A$_fsadd$997 Def04AF +S A$_fsadd$988 Def04A3 +S A$_fsadd$979 Def0497 +S A$_fsadd$898 Def0436 +S A$_fsadd$889 Def0428 +S A$_fsadd$799 Def03A7 +S A$_fsadd$90 Def000B +S G$__fsadd$0$0 Def0000 +S A$_fsadd$998 Def04B0 +S A$_fsadd$989 Def04A4 +S A$_fsadd$899 Def0437 +S A$_fsadd$91 Def000D +S A$_fsadd$999 Def04B2 +S A$_fsadd$92 Def000E +S A$_fsadd$93 Def0010 +S A$_fsadd$94 Def0011 +S A$_fsadd$85 Def0000 +S A$_fsadd$95 Def0012 +S A$_fsadd$86 Def0002 +S A$_fsadd$96 Def0014 +S A$_fsadd$87 Def0004 +S A$_fsadd$97 Def0015 +S A$_fsadd$88 Def0006 +S A$_fsadd$98 Def0016 +S A$_fsadd$89 Def0008 +S A$_fsadd$99 Def0018 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 10 +R 00 00 00 05 +T 00 10 +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 18 +R 00 00 00 05 +T 00 18 +R 00 00 00 05 +T 00 1A +R 00 00 00 05 +T 00 1A +R 00 00 00 05 +T 00 1C +R 00 00 00 05 +T 00 1C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 1C E4 A3 A3 A3 F0 12 00 00 F0 12 00 00 +R 00 00 00 07 00 02 00 05 02 0A 00 01 02 0E 00 01 +T 00 29 F0 12 00 00 F0 90 00 04 E0 FA A3 E0 FB A3 +R 00 00 00 07 02 04 00 01 00 08 00 05 +T 00 37 E0 FC A3 E0 FD 90 00 10 EA F0 A3 EB F0 A3 +R 00 00 00 07 00 08 00 05 +T 00 45 EC F0 A3 ED F0 90 00 00 E0 FA A3 E0 FB A3 +R 00 00 00 07 00 08 00 05 +T 00 53 E0 FC A3 E0 FD 90 00 14 EA F0 A3 EB F0 A3 +R 00 00 00 07 00 08 00 05 +T 00 61 EC F0 A3 ED F0 90 00 10 E0 FA A3 E0 FB A3 +R 00 00 00 07 00 08 00 05 +T 00 6F E0 FC A3 E0 FD EA 4B 4C 4D 70 17 +R 00 00 00 07 +T 00 7A +R 00 00 00 07 +T 00 7A 90 00 14 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 88 8A 82 8B 83 8C F0 02 07 14 +R 00 00 00 07 00 09 00 07 +T 00 91 +R 00 00 00 07 +T 00 91 90 00 14 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 9F EA 4B 4C 4D 70 17 +R 00 00 00 07 +T 00 A5 +R 00 00 00 07 +T 00 A5 90 00 10 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 B3 8A 82 8B 83 8C F0 02 07 14 +R 00 00 00 07 00 09 00 07 +T 00 BC +R 00 00 00 07 +T 00 BC 90 00 10 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 CA 8C 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 D8 02 44 FE +R 00 00 00 07 +T 00 DB +R 00 00 00 07 +T 00 DB FB 33 95 E0 FC FD 90 00 18 EA F0 A3 E4 F0 +R 00 00 00 07 00 09 00 05 +T 00 E9 90 00 14 E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 F7 8E 02 EF A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 01 05 02 44 FE +R 00 00 00 07 +T 01 08 +R 00 00 00 07 +T 01 08 FB 33 95 E0 FE FF 90 00 1A EA F0 A3 E4 F0 +R 00 00 00 07 00 09 00 05 +T 01 16 90 00 1A E0 FA A3 E0 FB 74 19 2A FA E4 3B +R 00 00 00 07 00 03 00 05 +T 01 24 FB 90 00 18 E0 F8 A3 E0 F9 C3 EA 98 EB 64 +R 00 00 00 07 00 04 00 05 +T 01 32 80 89 F0 63 F0 80 95 F0 50 27 +R 00 00 00 07 +T 01 3C +R 00 00 00 07 +T 01 3C 90 00 10 E0 FA A3 E0 FB A3 E0 F8 A3 E0 F9 +R 00 00 00 07 00 03 00 05 +T 01 4A 8A 82 8B 83 88 F0 12 00 00 AA 82 AB 83 A8 +R 00 00 00 07 02 09 00 00 +T 01 58 F0 F9 8A 82 8B 83 88 F0 02 07 14 +R 00 00 00 07 00 0B 00 07 +T 01 63 +R 00 00 00 07 +T 01 63 90 00 18 E0 FA A3 E0 FB 74 19 2A FA E4 3B +R 00 00 00 07 00 03 00 05 +T 01 71 FB 90 00 1A E0 F8 A3 E0 F9 C3 EA 98 EB 64 +R 00 00 00 07 00 04 00 05 +T 01 7F 80 89 F0 63 F0 80 95 F0 50 27 +R 00 00 00 07 +T 01 89 +R 00 00 00 07 +T 01 89 90 00 14 E0 FA A3 E0 FB A3 E0 F8 A3 E0 F9 +R 00 00 00 07 00 03 00 05 +T 01 97 8A 82 8B 83 88 F0 12 00 00 AA 82 AB 83 A8 +R 00 00 00 07 02 09 00 00 +T 01 A5 F0 F9 8A 82 8B 83 88 F0 02 07 14 +R 00 00 00 07 00 0B 00 07 +T 01 B0 +R 00 00 00 07 +T 01 B0 90 00 10 E0 FA A3 E0 FB A3 E0 F8 A3 E0 F9 +R 00 00 00 07 00 03 00 05 +T 01 BE 53 00 7F 79 00 43 00 80 E9 54 03 A2 E0 C8 +R 00 00 00 07 +T 01 CC 13 C8 13 C8 13 C8 13 C8 F9 EB 03 03 54 3F +R 00 00 00 07 +T 01 DA 48 F8 EB 54 03 A2 E0 CA 13 CA 13 CA 13 CA +R 00 00 00 07 +T 01 E8 13 CA FB 90 00 08 EA F0 A3 EB F0 A3 E8 F0 +R 00 00 00 07 00 06 00 05 +T 01 F6 A3 E9 F0 90 00 14 E0 FA A3 E0 FB A3 E0 F8 +R 00 00 00 07 00 06 00 05 +T 02 04 A3 E0 F9 53 00 7F 79 00 43 00 80 E9 54 03 +R 00 00 00 07 +T 02 12 A2 E0 C8 13 C8 13 C8 13 C8 13 C8 F9 EB 03 +R 00 00 00 07 +T 02 20 03 54 3F 48 F8 EB 54 03 A2 E0 CA 13 CA 13 +R 00 00 00 07 +T 02 2E CA 13 CA 13 CA FB 90 00 0C EA F0 A3 EB F0 +R 00 00 00 07 00 09 00 05 +T 02 3C A3 E8 F0 A3 E9 F0 90 00 10 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 02 4A A3 E0 F8 A3 E0 F9 23 54 01 FA 60 29 +R 00 00 00 07 +T 02 56 +R 00 00 00 07 +T 02 56 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 62 F5 00 02 A3 E0 F5 00 03 90 00 08 C3 E4 95 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 02 6E 00 00 F0 E4 95 00 01 A3 F0 E4 95 00 02 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 02 79 F0 E4 95 00 03 A3 F0 +R 00 00 00 07 29 05 00 01 +T 02 7F +R 00 00 00 07 +T 02 7F 90 00 14 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 8B F5 00 02 A3 E0 F5 00 03 23 54 01 FA 60 29 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 02 97 +R 00 00 00 07 +T 02 97 90 00 0C E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 A3 F5 00 02 A3 E0 F5 00 03 90 00 0C C3 E4 95 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 02 AF 00 00 F0 E4 95 00 01 A3 F0 E4 95 00 02 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 02 BA F0 E4 95 00 03 A3 F0 +R 00 00 00 07 29 05 00 01 +T 02 C0 +R 00 00 00 07 +T 02 C0 90 00 1A E0 F5 00 00 A3 E0 F5 00 01 90 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 CB 00 18 E0 F5 00 04 A3 E0 F5 00 05 C3 E5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 02 D6 00 00 95 00 04 E5 00 01 64 80 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 DE 00 05 F0 63 F0 80 95 F0 40 03 02 03 57 +R 00 00 00 07 29 02 00 01 00 0D 00 07 +T 02 EA +R 00 00 00 07 +T 02 EA 90 00 1A E0 F5 00 04 A3 E0 F5 00 05 90 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 F5 00 18 E0 F5 00 00 A3 E0 F5 00 01 C3 E5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 03 00 00 00 95 00 04 F5 00 04 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 06 00 01 95 00 05 F5 00 05 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 0C 00 0C E0 F5 00 00 A3 E0 F5 00 01 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 03 18 00 02 A3 E0 F5 00 03 85 00 04 F0 05 F0 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 03 23 00 03 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 +T 03 29 +R 00 00 00 07 +T 03 29 A2 D2 E5 00 03 13 F5 00 03 E5 00 02 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 03 34 00 02 E5 00 01 13 F5 00 01 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 03 3B 00 00 13 F5 00 00 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 03 3F +R 00 00 00 07 +T 03 3F D5 F0 E7 90 00 0C E5 00 00 F0 A3 E5 00 01 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 03 4B F0 A3 E5 00 02 F0 A3 E5 00 03 F0 02 03 D5 +R 00 00 00 07 29 05 00 01 29 0A 00 01 00 0E 00 07 +T 03 57 +R 00 00 00 07 +T 03 57 90 00 18 E0 F5 00 04 A3 E0 F5 00 05 90 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 03 62 00 1A E0 F5 00 00 A3 E0 F5 00 01 C3 E5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 03 6D 00 00 95 00 04 F5 00 04 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 73 00 01 95 00 05 F5 00 05 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 79 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 03 85 00 02 A3 E0 F5 00 03 85 00 04 F0 05 F0 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 03 90 00 03 33 92 D2 80 16 +R 00 00 00 07 29 02 00 01 +T 03 96 +R 00 00 00 07 +T 03 96 A2 D2 E5 00 03 13 F5 00 03 E5 00 02 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 03 A1 00 02 E5 00 01 13 F5 00 01 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 03 A8 00 00 13 F5 00 00 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 03 AC +R 00 00 00 07 +T 03 AC D5 F0 E7 90 00 08 E5 00 00 F0 A3 E5 00 01 +R 00 00 00 07 00 06 00 05 29 09 00 01 29 0E 00 01 +T 03 B8 F0 A3 E5 00 02 F0 A3 E5 00 03 F0 90 00 1A +R 00 00 00 07 29 05 00 01 29 0A 00 01 00 0E 00 05 +T 03 C4 E0 F5 00 04 A3 E0 F5 00 05 90 00 18 E5 +R 00 00 00 07 29 04 00 01 29 09 00 01 00 0C 00 05 +T 03 CF 00 04 F0 A3 E5 00 05 F0 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 03 D5 +R 00 00 00 07 +T 03 D5 90 00 0C E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 03 E1 F5 00 02 A3 E0 F5 00 03 90 00 08 E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 03 EC 00 06 A3 E0 F5 00 07 A3 E0 F5 00 08 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 F7 F5 00 09 90 00 08 E5 00 00 25 +R 00 00 00 07 29 03 00 01 00 06 00 05 29 09 00 01 +T 03 FF 00 06 F0 E5 00 01 35 00 07 A3 F0 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 04 08 00 02 35 00 08 A3 F0 E5 00 03 35 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 04 10 00 09 A3 F0 90 00 08 E0 F5 00 06 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 07 00 05 29 0B 00 01 +T 04 1C 00 07 A3 E0 F5 00 08 A3 E0 F5 00 09 30 E7 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 04 27 39 +R 00 00 00 07 +T 04 28 +R 00 00 00 07 +T 04 28 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 04 34 F5 00 08 A3 E0 F5 00 09 90 00 08 C3 E4 95 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 04 40 00 06 F0 E4 95 00 07 A3 F0 E4 95 00 08 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 04 4B F0 E4 95 00 09 A3 F0 90 00 1C E4 F0 A3 F0 +R 00 00 00 07 29 05 00 01 00 0A 00 05 +T 04 58 A3 E4 F0 A3 74 80 F0 80 26 +R 00 00 00 07 +T 04 61 +R 00 00 00 07 +T 04 61 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 04 6D F5 00 08 A3 E0 F5 00 09 E5 00 06 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 04 76 00 07 45 00 08 45 00 09 70 0A +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 7D +R 00 00 00 07 +T 04 7D E4 F5 82 F5 83 F5 F0 02 07 14 +R 00 00 00 07 00 0A 00 07 +T 04 87 +R 00 00 00 07 +T 04 87 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 04 93 F5 00 08 A3 E0 F5 00 09 54 E0 60 03 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 04 9D +R 00 00 00 07 +T 04 9D 02 04 F4 +R 00 00 00 07 00 03 00 07 +T 04 A0 +R 00 00 00 07 +T 04 A0 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 04 AC F5 00 08 A3 E0 F5 00 09 E5 00 06 25 E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 04 B7 00 06 E5 00 07 33 F5 00 07 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 04 BE 00 08 33 F5 00 08 E5 00 09 33 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 04 C6 00 09 90 00 08 E5 00 06 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 08 00 01 +T 04 CF 00 07 F0 A3 E5 00 08 F0 A3 E5 00 09 F0 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 04 DA 00 18 E0 24 FF F5 00 06 A3 E0 34 FF F5 +R 00 00 00 07 00 02 00 05 29 08 00 01 +T 04 E6 00 07 90 00 18 E5 00 06 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 08 00 01 +T 04 EF 00 07 F0 02 04 87 +R 00 00 00 07 29 02 00 01 00 06 00 07 +T 04 F4 +R 00 00 00 07 +T 04 F4 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 05 00 F5 00 08 A3 E0 F5 00 09 30 E6 42 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 05 09 +R 00 00 00 07 +T 05 09 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 05 15 F5 00 08 A3 E0 F5 00 09 A2 E7 13 F5 00 09 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0E 00 01 +T 05 20 E5 00 08 13 F5 00 08 E5 00 07 13 F5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0A 00 01 +T 05 29 00 07 E5 00 06 13 F5 00 06 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 05 30 00 08 F0 A3 E5 00 07 F0 A3 E5 00 08 F0 A3 +R 00 00 00 07 00 02 00 05 29 07 00 01 29 0C 00 01 +T 05 3C E5 00 09 F0 90 00 18 E0 24 01 F0 A3 E0 34 +R 00 00 00 07 29 03 00 01 00 07 00 05 +T 05 49 00 F0 +R 00 00 00 07 +T 05 4B +R 00 00 00 07 +T 05 4B 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 05 57 F5 00 08 A3 E0 F5 00 09 E5 00 06 30 E6 0C +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 05 62 +R 00 00 00 07 +T 05 62 E4 F5 00 09 F5 00 08 F5 00 07 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 05 6A 00 06 20 80 0A +R 00 00 00 07 29 02 00 01 +T 05 6E +R 00 00 00 07 +T 05 6E E4 F5 00 09 F5 00 08 F5 00 07 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 05 76 00 06 1F +R 00 00 00 07 29 02 00 01 +T 05 78 +R 00 00 00 07 +T 05 78 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 05 84 F5 00 02 A3 E0 F5 00 03 90 00 08 E5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 05 8E 00 06 25 00 00 F0 E5 00 07 35 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 05 95 00 01 A3 F0 E5 00 08 35 00 02 A3 F0 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 05 9F 00 09 35 00 03 A3 F0 90 00 08 E0 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 00 0A 00 05 +T 05 A9 00 06 A3 E0 F5 00 07 A3 E0 F5 00 08 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 05 B4 F5 00 09 30 E6 42 +R 00 00 00 07 29 03 00 01 +T 05 B9 +R 00 00 00 07 +T 05 B9 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 05 C5 F5 00 08 A3 E0 F5 00 09 A2 E7 13 F5 00 09 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0E 00 01 +T 05 D0 E5 00 08 13 F5 00 08 E5 00 07 13 F5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0A 00 01 +T 05 D9 00 07 E5 00 06 13 F5 00 06 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 05 E0 00 08 F0 A3 E5 00 07 F0 A3 E5 00 08 F0 A3 +R 00 00 00 07 00 02 00 05 29 07 00 01 29 0C 00 01 +T 05 EC E5 00 09 F0 90 00 18 E0 24 01 F0 A3 E0 34 +R 00 00 00 07 29 03 00 01 00 07 00 05 +T 05 F9 00 F0 +R 00 00 00 07 +T 05 FB +R 00 00 00 07 +T 05 FB 90 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 06 07 F5 00 08 A3 E0 F5 00 09 E5 00 07 A2 E7 C5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 06 12 00 06 33 C5 00 06 33 C5 00 06 33 C5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 06 1B 00 06 33 C5 00 06 54 03 F5 00 07 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0B 00 01 +T 06 24 00 08 25 E0 25 E0 45 00 07 F5 00 07 E5 +R 00 00 00 07 29 02 00 01 29 09 00 01 29 0C 00 01 +T 06 2E 00 09 A2 E7 C5 00 08 33 C5 00 08 33 C5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 06 38 00 08 33 C5 00 08 33 C5 00 08 54 03 30 E1 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 06 43 02 44 FC +R 00 00 00 07 +T 06 46 +R 00 00 00 07 +T 06 46 F5 00 09 90 00 08 E5 00 06 F0 A3 E5 +R 00 00 00 07 29 03 00 01 00 06 00 05 29 09 00 01 +T 06 50 00 07 F0 A3 E5 00 08 F0 A3 E5 00 09 F0 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 06 5B 00 08 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 06 67 00 08 A3 E0 F5 00 09 90 00 08 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0A 00 05 +T 06 70 00 06 F0 A3 E5 00 07 F0 74 7F 55 00 08 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 06 7B F0 A3 E5 00 09 F0 90 00 18 E0 F5 00 06 A3 +R 00 00 00 07 29 05 00 01 00 09 00 05 29 0D 00 01 +T 06 87 E0 F5 00 07 85 00 06 00 08 E5 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 09 00 01 +T 06 8E 00 07 54 01 A2 E0 C5 00 08 13 C5 00 08 13 +R 00 00 00 07 29 02 00 01 29 09 00 01 29 0D 00 01 +T 06 99 C5 00 08 F5 00 09 75 00 07 00 75 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 06 A1 00 06 00 90 00 1C E0 F5 00 00 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 06 00 05 29 0A 00 01 +T 06 AC 00 01 A3 E0 F5 00 02 A3 E0 F5 00 03 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 06 B6 00 00 42 00 06 E5 00 01 42 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 06 BC 00 07 E5 00 02 42 00 08 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 06 C2 00 03 42 00 09 90 00 08 E0 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 00 08 00 05 +T 06 CA 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 06 D5 F5 00 03 E5 00 00 42 00 06 E5 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 06 DC 00 01 42 00 07 E5 00 02 42 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 06 E2 00 08 E5 00 03 42 00 09 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 06 E8 00 10 E5 00 06 F0 A3 E5 00 07 F0 A3 E5 +R 00 00 00 07 00 02 00 05 29 05 00 01 29 0A 00 01 +T 06 F3 00 08 F0 A3 E5 00 09 F0 90 00 10 E0 F5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0B 00 05 +T 06 FE 00 06 A3 E0 F5 00 07 A3 E0 F5 00 08 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 07 09 F5 00 09 85 00 06 82 85 00 07 83 85 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 0A 00 01 +T 07 12 00 08 F0 +R 00 00 00 07 29 02 00 01 +T 07 14 +R 00 00 00 07 +T 07 14 22 +R 00 00 00 07 diff --git a/device/lib/large/_fsdiv.asm b/device/lib/large/_fsdiv.asm new file mode 100644 index 00000000..80751613 --- /dev/null +++ b/device/lib/large/_fsdiv.asm @@ -0,0 +1,936 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:26 2000 + +;-------------------------------------------------------- + .module _fsdiv +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsdiv_PARM_2 + .globl ___fsdiv +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsdiv_sloc0_1_0: + .ds 0x0001 +___fsdiv_sloc1_1_0: + .ds 0x0004 +___fsdiv_sloc2_1_0: + .ds 0x0004 +___fsdiv_sloc3_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fsdiv_PARM_2: + .ds 0x0004 +___fsdiv_a1_1_1: + .ds 0x0004 +___fsdiv_fl1_1_1: + .ds 0x0004 +___fsdiv_fl2_1_1: + .ds 0x0004 +___fsdiv_result_1_1: + .ds 0x0004 +___fsdiv_mask_1_1: + .ds 0x0004 +___fsdiv_mant1_1_1: + .ds 0x0004 +___fsdiv_mant2_1_1: + .ds 0x0004 +___fsdiv_exp_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsdiv$0$0 ==. +; _fsdiv.c 73 +; ----------------------------------------- +; function __fsdiv +; ----------------------------------------- +___fsdiv: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsdiv.c 138 + push acc + push b + push dph + push dpl + mov dptr,#___fsdiv_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fsdiv.c 82 + mov dptr,#___fsdiv_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsdiv_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsdiv.c 83 + mov dptr,#___fsdiv_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsdiv_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsdiv.c 86 + mov dptr,#(___fsdiv_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov ar2,r4 + mov a,r5 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00120$ + orl a,#0xfe +00120$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov dptr,#___fsdiv_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _fsdiv.c 87 + mov dptr,#(___fsdiv_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + mov ar2,r6 + mov a,r7 + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r6,a + mov r7,a + mov r3,#0x00 + mov dptr,#___fsdiv_exp_1_1 + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov dptr,#___fsdiv_exp_1_1 + clr c + mov a,r0 + subb a,r2 + movx @dptr,a + mov a,r1 + subb a,r3 + inc dptr + movx @dptr,a +; _fsdiv.c 88 + mov dptr,#___fsdiv_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov dptr,#___fsdiv_exp_1_1 + mov a,#0x7e + add a,r2 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + inc dptr + movx @dptr,a +; _fsdiv.c 91 + mov dptr,#(___fsdiv_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r1,a + rl a + anl a,#0x01 + mov ___fsdiv_sloc0_1_0,a + mov dptr,#(___fsdiv_fl2_1_1) + movx a,@dptr + mov ___fsdiv_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsdiv_sloc1_1_0 + 3),a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + xrl a,___fsdiv_sloc0_1_0 + mov ___fsdiv_sloc1_1_0,a +; _fsdiv.c 94 + mov dptr,#(___fsdiv_fl2_1_1) + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + mov a,___fsdiv_sloc2_1_0 + orl a,(___fsdiv_sloc2_1_0 + 1) + orl a,(___fsdiv_sloc2_1_0 + 2) + orl a,(___fsdiv_sloc2_1_0 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00122$: +; _fsdiv.c 96 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x80 + mov a,#0xbf + ljmp 00112$ +00102$: +; _fsdiv.c 99 + mov dptr,#(___fsdiv_fl1_1_1) + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + mov a,___fsdiv_sloc2_1_0 + orl a,(___fsdiv_sloc2_1_0 + 1) + orl a,(___fsdiv_sloc2_1_0 + 2) + orl a,(___fsdiv_sloc2_1_0 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00123$: +; _fsdiv.c 100 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00112$ +00104$: +; _fsdiv.c 103 + mov dptr,#(___fsdiv_fl1_1_1) + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + anl (___fsdiv_sloc2_1_0 + 2),#0x7f + mov (___fsdiv_sloc2_1_0 + 3),#0x00 + mov dptr,#___fsdiv_mant1_1_1 + mov a,___fsdiv_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc2_1_0 + 1) + movx @dptr,a + mov a,#0x80 + orl a,(___fsdiv_sloc2_1_0 + 2) + inc dptr + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc2_1_0 + 3) + movx @dptr,a +; _fsdiv.c 104 + mov dptr,#(___fsdiv_fl2_1_1) + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + anl (___fsdiv_sloc2_1_0 + 2),#0x7f + mov (___fsdiv_sloc2_1_0 + 3),#0x00 + mov dptr,#___fsdiv_mant2_1_1 + mov a,___fsdiv_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc2_1_0 + 1) + movx @dptr,a + mov a,#0x80 + orl a,(___fsdiv_sloc2_1_0 + 2) + inc dptr + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc2_1_0 + 3) + movx @dptr,a +; _fsdiv.c 107 + mov dptr,#___fsdiv_mant2_1_1 + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + mov dptr,#___fsdiv_mant1_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + clr c + mov a,___fsdiv_sloc3_1_0 + subb a,___fsdiv_sloc2_1_0 + mov a,(___fsdiv_sloc3_1_0 + 1) + subb a,(___fsdiv_sloc2_1_0 + 1) + mov a,(___fsdiv_sloc3_1_0 + 2) + subb a,(___fsdiv_sloc2_1_0 + 2) + mov a,(___fsdiv_sloc3_1_0 + 3) + xrl a,#0x80 + mov b,(___fsdiv_sloc2_1_0 + 3) + xrl b,#0x80 + subb a,b + jc 00124$ + ljmp 00106$ +00124$: +; _fsdiv.c 109 + mov dptr,#___fsdiv_mant1_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov a,___fsdiv_sloc3_1_0 + add a,acc + mov ___fsdiv_sloc3_1_0,a + mov a,(___fsdiv_sloc3_1_0 + 1) + rlc a + mov (___fsdiv_sloc3_1_0 + 1),a + mov a,(___fsdiv_sloc3_1_0 + 2) + rlc a + mov (___fsdiv_sloc3_1_0 + 2),a + mov a,(___fsdiv_sloc3_1_0 + 3) + rlc a + mov (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_mant1_1_1 + mov a,___fsdiv_sloc3_1_0 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 3) + movx @dptr,a +; _fsdiv.c 110 + mov dptr,#___fsdiv_exp_1_1 + movx a,@dptr + add a,#0xff + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + addc a,#0xff + mov (___fsdiv_sloc3_1_0 + 1),a + mov dptr,#___fsdiv_exp_1_1 + mov a,___fsdiv_sloc3_1_0 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 1) + movx @dptr,a +00106$: +; _fsdiv.c 114 + mov dptr,#___fsdiv_mask_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x01 + movx @dptr,a +; _fsdiv.c 115 + mov dptr,#___fsdiv_result_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _fsdiv.c 116 +00109$: + mov dptr,#___fsdiv_mask_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov a,___fsdiv_sloc3_1_0 + orl a,(___fsdiv_sloc3_1_0 + 1) + orl a,(___fsdiv_sloc3_1_0 + 2) + orl a,(___fsdiv_sloc3_1_0 + 3) + jnz 00125$ + ljmp 00111$ +00125$: +; _fsdiv.c 118 + mov dptr,#___fsdiv_mant2_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_mant1_1_1 + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + clr c + mov a,___fsdiv_sloc2_1_0 + subb a,___fsdiv_sloc3_1_0 + mov a,(___fsdiv_sloc2_1_0 + 1) + subb a,(___fsdiv_sloc3_1_0 + 1) + mov a,(___fsdiv_sloc2_1_0 + 2) + subb a,(___fsdiv_sloc3_1_0 + 2) + mov a,(___fsdiv_sloc2_1_0 + 3) + xrl a,#0x80 + mov b,(___fsdiv_sloc3_1_0 + 3) + xrl b,#0x80 + subb a,b + jnc 00126$ + ljmp 00108$ +00126$: +; _fsdiv.c 120 + mov dptr,#___fsdiv_mask_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_result_1_1 + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + mov dptr,#___fsdiv_result_1_1 + mov a,___fsdiv_sloc3_1_0 + orl a,___fsdiv_sloc2_1_0 + movx @dptr,a + mov a,(___fsdiv_sloc3_1_0 + 1) + orl a,(___fsdiv_sloc2_1_0 + 1) + inc dptr + movx @dptr,a + mov a,(___fsdiv_sloc3_1_0 + 2) + orl a,(___fsdiv_sloc2_1_0 + 2) + inc dptr + movx @dptr,a + mov a,(___fsdiv_sloc3_1_0 + 3) + orl a,(___fsdiv_sloc2_1_0 + 3) + inc dptr + movx @dptr,a +; _fsdiv.c 121 + mov dptr,#___fsdiv_mant2_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_mant1_1_1 + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + mov dptr,#___fsdiv_mant1_1_1 + clr c + mov a,___fsdiv_sloc2_1_0 + subb a,___fsdiv_sloc3_1_0 + movx @dptr,a + mov a,(___fsdiv_sloc2_1_0 + 1) + subb a,(___fsdiv_sloc3_1_0 + 1) + inc dptr + movx @dptr,a + mov a,(___fsdiv_sloc2_1_0 + 2) + subb a,(___fsdiv_sloc3_1_0 + 2) + inc dptr + movx @dptr,a + mov a,(___fsdiv_sloc2_1_0 + 3) + subb a,(___fsdiv_sloc3_1_0 + 3) + inc dptr + movx @dptr,a +00108$: +; _fsdiv.c 123 + mov dptr,#___fsdiv_mant1_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov a,___fsdiv_sloc3_1_0 + add a,acc + mov ___fsdiv_sloc3_1_0,a + mov a,(___fsdiv_sloc3_1_0 + 1) + rlc a + mov (___fsdiv_sloc3_1_0 + 1),a + mov a,(___fsdiv_sloc3_1_0 + 2) + rlc a + mov (___fsdiv_sloc3_1_0 + 2),a + mov a,(___fsdiv_sloc3_1_0 + 3) + rlc a + mov (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_mant1_1_1 + mov a,___fsdiv_sloc3_1_0 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 3) + movx @dptr,a +; _fsdiv.c 124 + mov dptr,#___fsdiv_mask_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 106 removed redundant mov + mov (___fsdiv_sloc3_1_0 + 3),a + clr c + rrc a + mov (___fsdiv_sloc3_1_0 + 3),a + mov a,(___fsdiv_sloc3_1_0 + 2) + rrc a + mov (___fsdiv_sloc3_1_0 + 2),a + mov a,(___fsdiv_sloc3_1_0 + 1) + rrc a + mov (___fsdiv_sloc3_1_0 + 1),a + mov a,___fsdiv_sloc3_1_0 + rrc a +; Peephole 100 removed redundant mov + mov ___fsdiv_sloc3_1_0,a + mov dptr,#___fsdiv_mask_1_1 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 3) + movx @dptr,a + ljmp 00109$ +00111$: +; _fsdiv.c 128 + mov dptr,#___fsdiv_result_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_result_1_1 + mov a,#0x01 + add a,___fsdiv_sloc3_1_0 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsdiv_sloc3_1_0 + 1) + inc dptr + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsdiv_sloc3_1_0 + 2) + inc dptr + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsdiv_sloc3_1_0 + 3) + inc dptr + movx @dptr,a +; _fsdiv.c 131 + mov dptr,#___fsdiv_exp_1_1 + movx a,@dptr + add a,#0x01 + movx @dptr,a + inc dptr + movx a,@dptr + addc a,#0x00 + movx @dptr,a +; _fsdiv.c 132 + mov dptr,#___fsdiv_result_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsdiv_sloc3_1_0 + 3),a + mov c,acc.7 + rrc a + mov (___fsdiv_sloc3_1_0 + 3),a + mov a,(___fsdiv_sloc3_1_0 + 2) + rrc a + mov (___fsdiv_sloc3_1_0 + 2),a + mov a,(___fsdiv_sloc3_1_0 + 1) + rrc a + mov (___fsdiv_sloc3_1_0 + 1),a + mov a,___fsdiv_sloc3_1_0 + rrc a +; Peephole 100 removed redundant mov + mov ___fsdiv_sloc3_1_0,a + mov dptr,#___fsdiv_result_1_1 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 3) + movx @dptr,a +; _fsdiv.c 134 + mov dptr,#___fsdiv_result_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_result_1_1 + mov a,___fsdiv_sloc3_1_0 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 1) + movx @dptr,a + mov a,#0x7f + anl a,(___fsdiv_sloc3_1_0 + 2) + inc dptr + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 3) + movx @dptr,a +; _fsdiv.c 137 + mov dptr,#___fsdiv_exp_1_1 + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + mov (___fsdiv_sloc3_1_0 + 2),___fsdiv_sloc3_1_0 + mov a,(___fsdiv_sloc3_1_0 + 1) + anl a,#0x01 + mov c,acc.0 + xch a,(___fsdiv_sloc3_1_0 + 2) + rrc a + xch a,(___fsdiv_sloc3_1_0 + 2) + rrc a + xch a,(___fsdiv_sloc3_1_0 + 2) + mov (___fsdiv_sloc3_1_0 + 3),a + mov (___fsdiv_sloc3_1_0 + 1),#0x00 + mov ___fsdiv_sloc3_1_0,#0x00 + mov ___fsdiv_sloc2_1_0,___fsdiv_sloc1_1_0 +; Peephole 3.c changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov (___fsdiv_sloc2_1_0 + 1),a + mov (___fsdiv_sloc2_1_0 + 2),a + mov (___fsdiv_sloc2_1_0 + 3),a + mov a,___fsdiv_sloc2_1_0 + orl ___fsdiv_sloc3_1_0,a + mov a,(___fsdiv_sloc2_1_0 + 1) + orl (___fsdiv_sloc3_1_0 + 1),a + mov a,(___fsdiv_sloc2_1_0 + 2) + orl (___fsdiv_sloc3_1_0 + 2),a + mov a,(___fsdiv_sloc2_1_0 + 3) + orl (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#___fsdiv_result_1_1 + movx a,@dptr + mov ___fsdiv_sloc2_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc2_1_0 + 3),a + mov a,___fsdiv_sloc2_1_0 + orl ___fsdiv_sloc3_1_0,a + mov a,(___fsdiv_sloc2_1_0 + 1) + orl (___fsdiv_sloc3_1_0 + 1),a + mov a,(___fsdiv_sloc2_1_0 + 2) + orl (___fsdiv_sloc3_1_0 + 2),a + mov a,(___fsdiv_sloc2_1_0 + 3) + orl (___fsdiv_sloc3_1_0 + 3),a + mov dptr,#(___fsdiv_fl1_1_1) + mov a,___fsdiv_sloc3_1_0 + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsdiv_sloc3_1_0 + 3) + movx @dptr,a +; _fsdiv.c 138 + mov dptr,#(___fsdiv_fl1_1_1) + movx a,@dptr + mov ___fsdiv_sloc3_1_0,a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsdiv_sloc3_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov (___fsdiv_sloc3_1_0 + 3),a + mov dpl,___fsdiv_sloc3_1_0 + mov dph,(___fsdiv_sloc3_1_0 + 1) + mov b,(___fsdiv_sloc3_1_0 + 2) +00112$: + C$_fsdiv.c$139$1$1 ==. + XG$__fsdiv$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fsdiv.cdb b/device/lib/large/_fsdiv.cdb new file mode 100644 index 00000000..037077d2 --- /dev/null +++ b/device/lib/large/_fsdiv.cdb @@ -0,0 +1,2 @@ +M:_fsdiv +F:G$__fsdiv$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fsdiv.rel b/device/lib/large/_fsdiv.rel new file mode 100644 index 00000000..5dc37aac --- /dev/null +++ b/device/lib/large/_fsdiv.rel @@ -0,0 +1,1124 @@ +;!FILE _fsdiv.asm +XH +H 8 areas 312 global symbols +M _fsdiv +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size D flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 22 flags 40 +S ___fsdiv_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 4C0 flags 20 +S A$_fsdiv$930 Def04B9 +S A$_fsdiv$921 Def04AC +S A$_fsdiv$912 Def04A0 +S A$_fsdiv$903 Def0492 +S A$_fsdiv$840 Def0426 +S A$_fsdiv$831 Def0418 +S A$_fsdiv$822 Def040C +S A$_fsdiv$813 Def0400 +S A$_fsdiv$804 Def03F1 +S A$_fsdiv$750 Def03AA +S A$_fsdiv$741 Def039E +S A$_fsdiv$732 Def0392 +S A$_fsdiv$723 Def0383 +S A$_fsdiv$714 Def0378 +S A$_fsdiv$705 Def036A +S A$_fsdiv$660 Def0329 +S A$_fsdiv$651 Def031A +S A$_fsdiv$642 Def030C +S A$_fsdiv$633 Def02FE +S A$_fsdiv$615 Def02E5 +S A$_fsdiv$606 Def02D5 +S A$_fsdiv$570 Def0299 +S A$_fsdiv$561 Def028C +S A$_fsdiv$552 Def027E +S A$_fsdiv$534 Def0262 +S A$_fsdiv$525 Def0256 +S A$_fsdiv$516 Def0247 +S A$_fsdiv$507 Def023C +S A$_fsdiv$480 Def021C +S A$_fsdiv$471 Def0210 +S A$_fsdiv$462 Def0200 +S A$_fsdiv$453 Def01F0 +S A$_fsdiv$444 Def01E4 +S A$_fsdiv$435 Def01D3 +S A$_fsdiv$426 Def01C2 +S A$_fsdiv$417 Def01B6 +S A$_fsdiv$408 Def01A8 +S A$_fsdiv$390 Def018F +S A$_fsdiv$381 Def017D +S A$_fsdiv$372 Def0171 +S A$_fsdiv$363 Def0164 +S A$_fsdiv$354 Def0152 +S A$_fsdiv$327 Def0130 +S A$_fsdiv$318 Def0124 +S A$_fsdiv$291 Def00FD +S A$_fsdiv$282 Def00F1 +S A$_fsdiv$273 Def00E6 +S A$_fsdiv$255 Def00D0 +S A$_fsdiv$246 Def00C7 +S A$_fsdiv$237 Def00B9 +S A$_fsdiv$228 Def00B1 +S A$_fsdiv$219 Def00A3 +S A$_fsdiv$192 Def0082 +S A$_fsdiv$183 Def0077 +S A$_fsdiv$174 Def006A +S A$_fsdiv$165 Def005F +S A$_fsdiv$156 Def0056 +S A$_fsdiv$147 Def004C +S A$_fsdiv$138 Def0041 +S A$_fsdiv$129 Def0036 +S A$_fsdiv$931 Def04BC +S A$_fsdiv$922 Def04AE +S A$_fsdiv$913 Def04A1 +S A$_fsdiv$904 Def0495 +S A$_fsdiv$850 Def0433 +S A$_fsdiv$841 Def0428 +S A$_fsdiv$832 Def0419 +S A$_fsdiv$814 Def0401 +S A$_fsdiv$805 Def03F3 +S A$_fsdiv$760 Def03BB +S A$_fsdiv$751 Def03AC +S A$_fsdiv$742 Def039F +S A$_fsdiv$733 Def0393 +S A$_fsdiv$724 Def0385 +S A$_fsdiv$715 Def0379 +S A$_fsdiv$706 Def036D +S A$_fsdiv$670 Def0335 +S A$_fsdiv$661 Def032A +S A$_fsdiv$652 Def031C +S A$_fsdiv$643 Def030E +S A$_fsdiv$634 Def0300 +S A$_fsdiv$625 Def02F2 +S A$_fsdiv$616 Def02E6 +S A$_fsdiv$607 Def02D6 +S A$_fsdiv$580 Def02AF +S A$_fsdiv$571 Def029B +S A$_fsdiv$562 Def028E +S A$_fsdiv$553 Def0280 +S A$_fsdiv$544 Def0272 +S A$_fsdiv$535 Def0263 +S A$_fsdiv$526 Def0257 +S A$_fsdiv$517 Def024A +S A$_fsdiv$508 Def023E +S A$_fsdiv$490 Def022D +S A$_fsdiv$481 Def021D +S A$_fsdiv$472 Def0211 +S A$_fsdiv$463 Def0202 +S A$_fsdiv$454 Def01F2 +S A$_fsdiv$445 Def01E6 +S A$_fsdiv$436 Def01D6 +S A$_fsdiv$427 Def01C3 +S A$_fsdiv$418 Def01B7 +S A$_fsdiv$409 Def01A9 +S A$_fsdiv$391 Def0190 +S A$_fsdiv$382 Def017E +S A$_fsdiv$364 Def0165 +S A$_fsdiv$355 Def0154 +S A$_fsdiv$346 Def0146 +S A$_fsdiv$328 Def0132 +S A$_fsdiv$319 Def0126 +S A$_fsdiv$292 Def00FF +S A$_fsdiv$283 Def00F2 +S A$_fsdiv$274 Def00E7 +S A$_fsdiv$265 Def00D9 +S A$_fsdiv$256 Def00D1 +S A$_fsdiv$238 Def00BC +S A$_fsdiv$229 Def00B2 +S A$_fsdiv$193 Def0083 +S A$_fsdiv$184 Def007A +S A$_fsdiv$175 Def006C +S A$_fsdiv$166 Def0060 +S A$_fsdiv$157 Def0057 +S A$_fsdiv$148 Def004D +S A$_fsdiv$139 Def0042 +S A$_fsdiv$923 Def04AF +S A$_fsdiv$914 Def04A3 +S A$_fsdiv$905 Def0497 +S A$_fsdiv$860 Def0446 +S A$_fsdiv$851 Def0436 +S A$_fsdiv$842 Def0429 +S A$_fsdiv$833 Def041B +S A$_fsdiv$824 Def040D +S A$_fsdiv$815 Def0402 +S A$_fsdiv$806 Def03F5 +S A$_fsdiv$770 Def03C5 +S A$_fsdiv$752 Def03AD +S A$_fsdiv$734 Def0394 +S A$_fsdiv$725 Def0387 +S A$_fsdiv$707 Def036E +S A$_fsdiv$680 Def0343 +S A$_fsdiv$671 Def0337 +S A$_fsdiv$662 Def032B +S A$_fsdiv$653 Def031E +S A$_fsdiv$644 Def030F +S A$_fsdiv$635 Def0301 +S A$_fsdiv$626 Def02F5 +S A$_fsdiv$617 Def02E8 +S A$_fsdiv$608 Def02D8 +S A$_fsdiv$590 Def02BE +S A$_fsdiv$581 Def02B1 +S A$_fsdiv$572 Def029D +S A$_fsdiv$563 Def028F +S A$_fsdiv$554 Def0281 +S A$_fsdiv$545 Def0275 +S A$_fsdiv$536 Def0265 +S A$_fsdiv$527 Def0259 +S A$_fsdiv$518 Def024B +S A$_fsdiv$491 Def022E +S A$_fsdiv$482 Def021F +S A$_fsdiv$473 Def0212 +S A$_fsdiv$464 Def0204 +S A$_fsdiv$455 Def01F4 +S A$_fsdiv$446 Def01E7 +S A$_fsdiv$437 Def01D9 +S A$_fsdiv$428 Def01C5 +S A$_fsdiv$419 Def01B8 +S A$_fsdiv$392 Def0191 +S A$_fsdiv$383 Def0180 +S A$_fsdiv$374 Def0172 +S A$_fsdiv$365 Def0167 +S A$_fsdiv$356 Def0155 +S A$_fsdiv$347 Def0149 +S A$_fsdiv$329 Def0134 +S A$_fsdiv$293 Def0100 +S A$_fsdiv$275 Def00E9 +S A$_fsdiv$266 Def00DA +S A$_fsdiv$257 Def00D2 +S A$_fsdiv$248 Def00C8 +S A$_fsdiv$239 Def00BD +S A$_fsdiv$194 Def0084 +S A$_fsdiv$185 Def007B +S A$_fsdiv$176 Def006F +S A$_fsdiv$167 Def0062 +S A$_fsdiv$158 Def0058 +S A$_fsdiv$149 Def004E +S A$_fsdiv$924 Def04B0 +S A$_fsdiv$906 Def0498 +S A$_fsdiv$861 Def0448 +S A$_fsdiv$852 Def0437 +S A$_fsdiv$843 Def042B +S A$_fsdiv$834 Def041C +S A$_fsdiv$825 Def0410 +S A$_fsdiv$816 Def0404 +S A$_fsdiv$807 Def03F6 +S A$_fsdiv$780 Def03D1 +S A$_fsdiv$762 Def03BC +S A$_fsdiv$753 Def03AE +S A$_fsdiv$735 Def0396 +S A$_fsdiv$726 Def0388 +S A$_fsdiv$717 Def037A +S A$_fsdiv$708 Def0370 +S A$_fsdiv$690 Def0355 +S A$_fsdiv$681 Def0345 +S A$_fsdiv$672 Def0338 +S A$_fsdiv$663 Def032D +S A$_fsdiv$654 Def031F +S A$_fsdiv$645 Def0310 +S A$_fsdiv$636 Def0302 +S A$_fsdiv$627 Def02F6 +S A$_fsdiv$618 Def02EA +S A$_fsdiv$609 Def02DB +S A$_fsdiv$591 Def02BF +S A$_fsdiv$573 Def029F +S A$_fsdiv$564 Def0290 +S A$_fsdiv$555 Def0282 +S A$_fsdiv$546 Def0276 +S A$_fsdiv$537 Def0267 +S A$_fsdiv$528 Def025A +S A$_fsdiv$519 Def024E +S A$_fsdiv$492 Def0230 +S A$_fsdiv$483 Def0221 +S A$_fsdiv$474 Def0214 +S A$_fsdiv$465 Def0205 +S A$_fsdiv$456 Def01F6 +S A$_fsdiv$447 Def01E8 +S A$_fsdiv$438 Def01DB +S A$_fsdiv$429 Def01C7 +S A$_fsdiv$393 Def0193 +S A$_fsdiv$384 Def0181 +S A$_fsdiv$375 Def0175 +S A$_fsdiv$366 Def0168 +S A$_fsdiv$357 Def0156 +S A$_fsdiv$348 Def014A +S A$_fsdiv$339 Def013C +S A$_fsdiv$294 Def0101 +S A$_fsdiv$285 Def00F4 +S A$_fsdiv$276 Def00EA +S A$_fsdiv$267 Def00DB +S A$_fsdiv$258 Def00D3 +S A$_fsdiv$249 Def00C9 +S A$_fsdiv$195 Def0085 +S A$_fsdiv$186 Def007C +S A$_fsdiv$168 Def0063 +S A$_fsdiv$159 Def0059 +S A$_fsdiv$925 Def04B2 +S A$_fsdiv$916 Def04A4 +S A$_fsdiv$907 Def0499 +S A$_fsdiv$880 Def046A +S A$_fsdiv$871 Def0459 +S A$_fsdiv$862 Def0449 +S A$_fsdiv$853 Def0439 +S A$_fsdiv$844 Def042D +S A$_fsdiv$835 Def041D +S A$_fsdiv$826 Def0411 +S A$_fsdiv$817 Def0405 +S A$_fsdiv$808 Def03F8 +S A$_fsdiv$790 Def03DE +S A$_fsdiv$781 Def03D2 +S A$_fsdiv$772 Def03C6 +S A$_fsdiv$763 Def03BD +S A$_fsdiv$754 Def03B0 +S A$_fsdiv$745 Def03A2 +S A$_fsdiv$736 Def0397 +S A$_fsdiv$727 Def038A +S A$_fsdiv$718 Def037C +S A$_fsdiv$709 Def0371 +S A$_fsdiv$691 Def0356 +S A$_fsdiv$682 Def0347 +S A$_fsdiv$673 Def0339 +S A$_fsdiv$664 Def032F +S A$_fsdiv$655 Def0321 +S A$_fsdiv$646 Def0312 +S A$_fsdiv$637 Def0304 +S A$_fsdiv$628 Def02F8 +S A$_fsdiv$619 Def02EB +S A$_fsdiv$592 Def02C0 +S A$_fsdiv$574 Def02A1 +S A$_fsdiv$565 Def0292 +S A$_fsdiv$556 Def0284 +S A$_fsdiv$547 Def0278 +S A$_fsdiv$538 Def0269 +S A$_fsdiv$529 Def025B +S A$_fsdiv$484 Def0222 +S A$_fsdiv$475 Def0215 +S A$_fsdiv$466 Def0207 +S A$_fsdiv$457 Def01F8 +S A$_fsdiv$448 Def01EA +S A$_fsdiv$439 Def01DD +S A$_fsdiv$394 Def0194 +S A$_fsdiv$385 Def0182 +S A$_fsdiv$376 Def0176 +S A$_fsdiv$367 Def016A +S A$_fsdiv$358 Def0158 +S A$_fsdiv$349 Def014C +S A$_fsdiv$295 Def0103 +S A$_fsdiv$286 Def00F5 +S A$_fsdiv$277 Def00EB +S A$_fsdiv$268 Def00DD +S A$_fsdiv$259 Def00D4 +S A$_fsdiv$196 Def0086 +S A$_fsdiv$178 Def0071 +S A$_fsdiv$169 Def0065 +S A$_fsdiv$935 Def04BF +S A$_fsdiv$926 Def04B3 +S A$_fsdiv$917 Def04A7 +S A$_fsdiv$908 Def049B +S A$_fsdiv$890 Def047B +S A$_fsdiv$881 Def046C +S A$_fsdiv$872 Def045A +S A$_fsdiv$863 Def044B +S A$_fsdiv$854 Def043A +S A$_fsdiv$845 Def042E +S A$_fsdiv$836 Def041F +S A$_fsdiv$827 Def0413 +S A$_fsdiv$818 Def0406 +S A$_fsdiv$809 Def03FA +S A$_fsdiv$791 Def03DF +S A$_fsdiv$782 Def03D3 +S A$_fsdiv$773 Def03C7 +S A$_fsdiv$764 Def03BF +S A$_fsdiv$755 Def03B1 +S A$_fsdiv$746 Def03A5 +S A$_fsdiv$737 Def0398 +S A$_fsdiv$728 Def038C +S A$_fsdiv$719 Def037D +S A$_fsdiv$692 Def0358 +S A$_fsdiv$683 Def0349 +S A$_fsdiv$674 Def033B +S A$_fsdiv$665 Def0330 +S A$_fsdiv$656 Def0323 +S A$_fsdiv$647 Def0313 +S A$_fsdiv$638 Def0307 +S A$_fsdiv$629 Def02F9 +S A$_fsdiv$593 Def02C2 +S A$_fsdiv$584 Def02B4 +S A$_fsdiv$575 Def02A3 +S A$_fsdiv$566 Def0293 +S A$_fsdiv$557 Def0287 +S A$_fsdiv$548 Def0279 +S A$_fsdiv$539 Def026B +S A$_fsdiv$485 Def0223 +S A$_fsdiv$476 Def0216 +S A$_fsdiv$467 Def020A +S A$_fsdiv$458 Def01FA +S A$_fsdiv$449 Def01EB +S A$_fsdiv$395 Def0196 +S A$_fsdiv$386 Def0184 +S A$_fsdiv$377 Def0178 +S A$_fsdiv$368 Def016C +S A$_fsdiv$359 Def015B +S A$_fsdiv$296 Def0104 +S A$_fsdiv$287 Def00F7 +S A$_fsdiv$278 Def00ED +S A$_fsdiv$269 Def00DF +S A$_fsdiv$197 Def0087 +S A$_fsdiv$188 Def007D +S A$_fsdiv$179 Def0072 +S XG$__fsdiv$0$0 Def04BF +S A$_fsdiv$918 Def04A8 +S A$_fsdiv$909 Def049C +S A$_fsdiv$891 Def047C +S A$_fsdiv$882 Def046E +S A$_fsdiv$873 Def045C +S A$_fsdiv$864 Def044C +S A$_fsdiv$855 Def043B +S A$_fsdiv$846 Def042F +S A$_fsdiv$837 Def0422 +S A$_fsdiv$828 Def0414 +S A$_fsdiv$819 Def0408 +S A$_fsdiv$792 Def03E1 +S A$_fsdiv$783 Def03D4 +S A$_fsdiv$774 Def03C9 +S A$_fsdiv$765 Def03C0 +S A$_fsdiv$756 Def03B2 +S A$_fsdiv$747 Def03A6 +S A$_fsdiv$738 Def039A +S A$_fsdiv$693 Def035B +S A$_fsdiv$684 Def034B +S A$_fsdiv$675 Def033C +S A$_fsdiv$657 Def0324 +S A$_fsdiv$648 Def0314 +S A$_fsdiv$639 Def0308 +S A$_fsdiv$594 Def02C3 +S A$_fsdiv$585 Def02B7 +S A$_fsdiv$576 Def02A5 +S A$_fsdiv$567 Def0294 +S A$_fsdiv$558 Def0288 +S A$_fsdiv$549 Def027A +S A$_fsdiv$495 Def0231 +S A$_fsdiv$486 Def0225 +S A$_fsdiv$477 Def0218 +S A$_fsdiv$468 Def020C +S A$_fsdiv$459 Def01FB +S A$_fsdiv$396 Def0198 +S A$_fsdiv$387 Def0187 +S A$_fsdiv$378 Def0179 +S A$_fsdiv$369 Def016D +S A$_fsdiv$297 Def0105 +S A$_fsdiv$279 Def00EE +S A$_fsdiv$198 Def0088 +S A$_fsdiv$189 Def007E +S A$_fsdiv$928 Def04B4 +S A$_fsdiv$919 Def04AA +S A$_fsdiv$892 Def047E +S A$_fsdiv$883 Def0470 +S A$_fsdiv$874 Def045E +S A$_fsdiv$865 Def044E +S A$_fsdiv$856 Def043D +S A$_fsdiv$847 Def0430 +S A$_fsdiv$838 Def0424 +S A$_fsdiv$829 Def0415 +S A$_fsdiv$793 Def03E2 +S A$_fsdiv$784 Def03D6 +S A$_fsdiv$775 Def03CA +S A$_fsdiv$757 Def03B4 +S A$_fsdiv$748 Def03A8 +S A$_fsdiv$739 Def039B +S A$_fsdiv$694 Def035D +S A$_fsdiv$685 Def034C +S A$_fsdiv$676 Def033D +S A$_fsdiv$658 Def0325 +S A$_fsdiv$649 Def0316 +S A$_fsdiv$595 Def02C4 +S A$_fsdiv$586 Def02B8 +S A$_fsdiv$577 Def02A7 +S A$_fsdiv$568 Def0296 +S A$_fsdiv$559 Def028A +S A$_fsdiv$487 Def0227 +S A$_fsdiv$469 Def020D +S A$_fsdiv$397 Def0199 +S A$_fsdiv$388 Def018A +S A$_fsdiv$379 Def017A +S A$_fsdiv$298 Def0107 +S A$_fsdiv$289 Def00F9 +S A$_fsdiv$199 Def0089 +S A$_fsdiv$929 Def04B6 +S A$_fsdiv$893 Def047F +S A$_fsdiv$884 Def0473 +S A$_fsdiv$875 Def0460 +S A$_fsdiv$866 Def0450 +S A$_fsdiv$857 Def0440 +S A$_fsdiv$848 Def0432 +S A$_fsdiv$839 Def0425 +S A$_fsdiv$794 Def03E3 +S A$_fsdiv$767 Def03C1 +S A$_fsdiv$758 Def03B7 +S A$_fsdiv$749 Def03A9 +S A$_fsdiv$695 Def035E +S A$_fsdiv$686 Def034E +S A$_fsdiv$677 Def033F +S A$_fsdiv$668 Def0331 +S A$_fsdiv$659 Def0327 +S A$_fsdiv$596 Def02C6 +S A$_fsdiv$587 Def02BA +S A$_fsdiv$578 Def02AA +S A$_fsdiv$569 Def0297 +S A$_fsdiv$488 Def022A +S A$_fsdiv$479 Def0219 +S A$_fsdiv$398 Def019A +S A$_fsdiv$389 Def018D +S A$_fsdiv$299 Def0108 +S A$_fsdiv$894 Def0480 +S A$_fsdiv$885 Def0474 +S A$_fsdiv$876 Def0462 +S A$_fsdiv$867 Def0453 +S A$_fsdiv$858 Def0442 +S A$_fsdiv$795 Def03E5 +S A$_fsdiv$786 Def03D7 +S A$_fsdiv$777 Def03CB +S A$_fsdiv$768 Def03C2 +S A$_fsdiv$759 Def03B9 +S A$_fsdiv$696 Def035F +S A$_fsdiv$687 Def0350 +S A$_fsdiv$678 Def0340 +S A$_fsdiv$669 Def0334 +S A$_fsdiv$597 Def02C9 +S A$_fsdiv$588 Def02BB +S A$_fsdiv$579 Def02AD +S A$_fsdiv$498 Def0234 +S A$_fsdiv$489 Def022C +S A$_fsdiv$399 Def019B +S A$_fsdiv$895 Def0482 +S A$_fsdiv$886 Def0476 +S A$_fsdiv$877 Def0464 +S A$_fsdiv$868 Def0456 +S A$_fsdiv$859 Def0444 +S A$_fsdiv$796 Def03E6 +S A$_fsdiv$787 Def03DA +S A$_fsdiv$778 Def03CE +S A$_fsdiv$769 Def03C4 +S A$_fsdiv$697 Def0361 +S A$_fsdiv$688 Def0351 +S A$_fsdiv$679 Def0341 +S A$_fsdiv$598 Def02CA +S A$_fsdiv$589 Def02BC +S A$_fsdiv$499 Def0235 +S A$_fsdiv$896 Def0484 +S A$_fsdiv$887 Def0477 +S A$_fsdiv$878 Def0466 +S A$_fsdiv$788 Def03DB +S A$_fsdiv$779 Def03CF +S A$_fsdiv$698 Def0362 +S A$_fsdiv$689 Def0353 +S A$_fsdiv$599 Def02CC +S A$_fsdiv$897 Def0486 +S A$_fsdiv$888 Def0478 +S A$_fsdiv$879 Def0468 +S A$_fsdiv$798 Def03E7 +S A$_fsdiv$789 Def03DD +S A$_fsdiv$699 Def0363 +S A$_fsdiv$898 Def0488 +S A$_fsdiv$889 Def047A +S A$_fsdiv$799 Def03E9 +S A$_fsdiv$90 Def0006 +S G$__fsdiv$0$0 Def0000 +S A$_fsdiv$899 Def048A +S A$_fsdiv$91 Def0008 +S A$_fsdiv$92 Def000B +S A$_fsdiv$93 Def000D +S A$_fsdiv$94 Def000E +S A$_fsdiv$95 Def0010 +S A$_fsdiv$96 Def0011 +S A$_fsdiv$87 Def0000 +S A$_fsdiv$97 Def0012 +S A$_fsdiv$88 Def0002 +S A$_fsdiv$98 Def0014 +S A$_fsdiv$89 Def0004 +S A$_fsdiv$99 Def0015 +S A$_fsdiv$100 Def0016 +S A$_fsdiv$200 Def008A +S A$_fsdiv$110 Def0022 +S A$_fsdiv$101 Def0018 +S A$_fsdiv$300 Def0109 +S A$_fsdiv$210 Def0096 +S A$_fsdiv$201 Def008B +S A$_fsdiv$120 Def002E +S A$_fsdiv$111 Def0023 +S A$_fsdiv$102 Def0019 +S A$_fsdiv$400 Def019D +S A$_fsdiv$310 Def0115 +S A$_fsdiv$301 Def010B +S A$_fsdiv$220 Def00A4 +S A$_fsdiv$211 Def0097 +S A$_fsdiv$202 Def008C +S A$_fsdiv$130 Def0039 +S A$_fsdiv$121 Def002F +S A$_fsdiv$112 Def0024 +S A$_fsdiv$500 Def0236 +S A$_fsdiv$410 Def01AA +S A$_fsdiv$320 Def0127 +S A$_fsdiv$311 Def0118 +S A$_fsdiv$302 Def010D +S A$_fsdiv$230 Def00B3 +S A$_fsdiv$221 Def00A6 +S A$_fsdiv$212 Def0099 +S A$_fsdiv$203 Def008D +S A$_fsdiv$140 Def0043 +S A$_fsdiv$131 Def003A +S A$_fsdiv$122 Def0030 +S A$_fsdiv$113 Def0025 +S A$_fsdiv$104 Def001A +S ___fsdiv Def0000 +S A$_fsdiv$600 Def02CD +S A$_fsdiv$510 Def023F +S A$_fsdiv$501 Def0237 +S A$_fsdiv$420 Def01BA +S A$_fsdiv$411 Def01AC +S A$_fsdiv$402 Def019E +S A$_fsdiv$330 Def0136 +S A$_fsdiv$321 Def0128 +S A$_fsdiv$312 Def011B +S A$_fsdiv$303 Def010F +S A$_fsdiv$240 Def00BE +S A$_fsdiv$231 Def00B4 +S A$_fsdiv$222 Def00A9 +S A$_fsdiv$213 Def009C +S A$_fsdiv$204 Def008F +S A$_fsdiv$150 Def004F +S A$_fsdiv$141 Def0044 +S A$_fsdiv$132 Def003B +S A$_fsdiv$123 Def0031 +S A$_fsdiv$114 Def0026 +S A$_fsdiv$105 Def001D +S A$_fsdiv$700 Def0365 +S A$_fsdiv$610 Def02DD +S A$_fsdiv$601 Def02CE +S A$_fsdiv$520 Def024F +S A$_fsdiv$511 Def0242 +S A$_fsdiv$502 Def0238 +S A$_fsdiv$430 Def01C9 +S A$_fsdiv$421 Def01BB +S A$_fsdiv$412 Def01AD +S A$_fsdiv$403 Def01A1 +S A$_fsdiv$340 Def013D +S A$_fsdiv$331 Def0138 +S A$_fsdiv$322 Def012A +S A$_fsdiv$313 Def011D +S A$_fsdiv$304 Def0111 +S A$_fsdiv$250 Def00CA +S A$_fsdiv$241 Def00BF +S A$_fsdiv$232 Def00B5 +S A$_fsdiv$223 Def00AA +S A$_fsdiv$205 Def0090 +S A$_fsdiv$160 Def005A +S A$_fsdiv$151 Def0050 +S A$_fsdiv$142 Def0047 +S A$_fsdiv$133 Def003C +S A$_fsdiv$124 Def0032 +S A$_fsdiv$115 Def0027 +S A$_fsdiv$106 Def001E +S A$_fsdiv$800 Def03EB +S A$_fsdiv$710 Def0372 +S A$_fsdiv$701 Def0366 +S A$_fsdiv$620 Def02EC +S A$_fsdiv$611 Def02DF +S A$_fsdiv$602 Def02D0 +S A$_fsdiv$530 Def025D +S A$_fsdiv$521 Def0252 +S A$_fsdiv$512 Def0243 +S A$_fsdiv$431 Def01CB +S A$_fsdiv$422 Def01BC +S A$_fsdiv$413 Def01AE +S A$_fsdiv$404 Def01A2 +S A$_fsdiv$350 Def014D +S A$_fsdiv$341 Def013F +S A$_fsdiv$323 Def012B +S A$_fsdiv$260 Def00D5 +S A$_fsdiv$251 Def00CB +S A$_fsdiv$242 Def00C0 +S A$_fsdiv$233 Def00B6 +S A$_fsdiv$224 Def00AB +S A$_fsdiv$215 Def009E +S A$_fsdiv$206 Def0092 +S A$_fsdiv$170 Def0066 +S A$_fsdiv$161 Def005B +S A$_fsdiv$152 Def0051 +S A$_fsdiv$143 Def0048 +S A$_fsdiv$134 Def003D +S A$_fsdiv$125 Def0033 +S A$_fsdiv$116 Def0028 +S A$_fsdiv$107 Def001F +S A$_fsdiv$900 Def048C +S A$_fsdiv$801 Def03EC +S A$_fsdiv$720 Def037E +S A$_fsdiv$711 Def0374 +S A$_fsdiv$702 Def0367 +S A$_fsdiv$630 Def02FA +S A$_fsdiv$621 Def02EE +S A$_fsdiv$612 Def02E0 +S A$_fsdiv$603 Def02D1 +S A$_fsdiv$540 Def026D +S A$_fsdiv$531 Def025E +S A$_fsdiv$513 Def0244 +S A$_fsdiv$504 Def0239 +S A$_fsdiv$450 Def01EC +S A$_fsdiv$432 Def01CD +S A$_fsdiv$423 Def01BE +S A$_fsdiv$414 Def01B0 +S A$_fsdiv$405 Def01A4 +S A$_fsdiv$360 Def015E +S A$_fsdiv$351 Def014E +S A$_fsdiv$342 Def0141 +S A$_fsdiv$333 Def013A +S A$_fsdiv$324 Def012C +S A$_fsdiv$306 Def0113 +S A$_fsdiv$270 Def00E2 +S A$_fsdiv$261 Def00D6 +S A$_fsdiv$243 Def00C1 +S A$_fsdiv$234 Def00B7 +S A$_fsdiv$225 Def00AC +S A$_fsdiv$216 Def009F +S A$_fsdiv$207 Def0093 +S A$_fsdiv$180 Def0073 +S A$_fsdiv$171 Def0067 +S A$_fsdiv$162 Def005C +S A$_fsdiv$144 Def0049 +S A$_fsdiv$135 Def003E +S A$_fsdiv$126 Def0034 +S A$_fsdiv$117 Def002B +S A$_fsdiv$108 Def0020 +S A$_fsdiv$910 Def049D +S A$_fsdiv$901 Def048E +S A$_fsdiv$820 Def0409 +S A$_fsdiv$811 Def03FB +S A$_fsdiv$802 Def03EE +S A$_fsdiv$730 Def038D +S A$_fsdiv$721 Def0380 +S A$_fsdiv$712 Def0375 +S A$_fsdiv$703 Def0369 +S A$_fsdiv$640 Def030A +S A$_fsdiv$631 Def02FC +S A$_fsdiv$622 Def02F0 +S A$_fsdiv$613 Def02E2 +S A$_fsdiv$604 Def02D2 +S A$_fsdiv$550 Def027C +S A$_fsdiv$541 Def026F +S A$_fsdiv$532 Def025F +S A$_fsdiv$514 Def0245 +S A$_fsdiv$505 Def023A +S A$_fsdiv$460 Def01FD +S A$_fsdiv$451 Def01EE +S A$_fsdiv$442 Def01E0 +S A$_fsdiv$433 Def01CF +S A$_fsdiv$424 Def01BF +S A$_fsdiv$415 Def01B3 +S A$_fsdiv$406 Def01A5 +S A$_fsdiv$370 Def016E +S A$_fsdiv$361 Def0161 +S A$_fsdiv$352 Def0150 +S A$_fsdiv$343 Def0143 +S A$_fsdiv$325 Def012E +S A$_fsdiv$316 Def0120 +S A$_fsdiv$271 Def00E3 +S A$_fsdiv$262 Def00D7 +S A$_fsdiv$253 Def00CC +S A$_fsdiv$244 Def00C4 +S A$_fsdiv$235 Def00B8 +S A$_fsdiv$226 Def00AD +S A$_fsdiv$217 Def00A0 +S A$_fsdiv$208 Def0094 +S A$_fsdiv$181 Def0075 +S A$_fsdiv$172 Def0068 +S A$_fsdiv$163 Def005D +S A$_fsdiv$154 Def0052 +S A$_fsdiv$145 Def004A +S A$_fsdiv$136 Def003F +S A$_fsdiv$127 Def0035 +S A$_fsdiv$118 Def002C +S A$_fsdiv$109 Def0021 +S C$_fsdiv.c$139$1$1 Def04BF +S A$_fsdiv$920 Def04AB +S A$_fsdiv$911 Def049F +S A$_fsdiv$902 Def0490 +S A$_fsdiv$830 Def0417 +S A$_fsdiv$821 Def040A +S A$_fsdiv$812 Def03FD +S A$_fsdiv$803 Def03F0 +S A$_fsdiv$740 Def039C +S A$_fsdiv$731 Def038F +S A$_fsdiv$722 Def0382 +S A$_fsdiv$713 Def0376 +S A$_fsdiv$650 Def0319 +S A$_fsdiv$641 Def030B +S A$_fsdiv$632 Def02FD +S A$_fsdiv$623 Def02F1 +S A$_fsdiv$614 Def02E4 +S A$_fsdiv$605 Def02D4 +S A$_fsdiv$560 Def028B +S A$_fsdiv$551 Def027D +S A$_fsdiv$533 Def0261 +S A$_fsdiv$524 Def0253 +S A$_fsdiv$515 Def0246 +S A$_fsdiv$506 Def023B +S A$_fsdiv$470 Def020E +S A$_fsdiv$461 Def01FF +S A$_fsdiv$452 Def01EF +S A$_fsdiv$443 Def01E3 +S A$_fsdiv$434 Def01D1 +S A$_fsdiv$425 Def01C0 +S A$_fsdiv$416 Def01B4 +S A$_fsdiv$407 Def01A6 +S A$_fsdiv$380 Def017C +S A$_fsdiv$371 Def016F +S A$_fsdiv$362 Def0163 +S A$_fsdiv$353 Def0151 +S A$_fsdiv$326 Def012F +S A$_fsdiv$317 Def0123 +S A$_fsdiv$290 Def00FC +S A$_fsdiv$281 Def00EF +S A$_fsdiv$272 Def00E5 +S A$_fsdiv$263 Def00D8 +S A$_fsdiv$254 Def00CF +S A$_fsdiv$245 Def00C6 +S A$_fsdiv$227 Def00AE +S A$_fsdiv$218 Def00A2 +S A$_fsdiv$209 Def0095 +S A$_fsdiv$191 Def007F +S A$_fsdiv$182 Def0076 +S A$_fsdiv$173 Def0069 +S A$_fsdiv$164 Def005E +S A$_fsdiv$155 Def0055 +S A$_fsdiv$146 Def004B +S A$_fsdiv$137 Def0040 +S A$_fsdiv$119 Def002D +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 10 +R 00 00 00 05 +T 00 10 +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 18 +R 00 00 00 05 +T 00 18 +R 00 00 00 05 +T 00 1C +R 00 00 00 05 +T 00 1C +R 00 00 00 05 +T 00 20 +R 00 00 00 05 +T 00 20 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 08 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 45 00 0C EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 53 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 8C +R 00 00 00 07 00 02 00 05 +T 00 61 02 ED A2 E7 CA 33 CA 33 CA 54 01 30 E0 02 +R 00 00 00 07 +T 00 6F 44 FE +R 00 00 00 07 +T 00 71 +R 00 00 00 07 +T 00 71 FB 33 95 E0 FC FD 90 00 20 EA F0 A3 E4 F0 +R 00 00 00 07 00 09 00 05 +T 00 7F 90 00 0C E0 FA A3 E0 FB A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 8D 8E 02 EF A2 E7 CA 33 CA 33 CA 54 01 30 E0 +R 00 00 00 07 +T 00 9B 02 44 FE +R 00 00 00 07 +T 00 9E +R 00 00 00 07 +T 00 9E FB 33 95 E0 FE FF 7B 00 90 00 20 E0 F8 A3 +R 00 00 00 07 00 0B 00 05 +T 00 AC E0 F9 90 00 20 C3 E8 9A F0 E9 9B A3 F0 90 +R 00 00 00 07 00 05 00 05 +T 00 BA 00 20 E0 FA A3 E0 FB 90 00 20 74 7E 2A F0 +R 00 00 00 07 00 02 00 05 00 0A 00 05 +T 00 C8 E4 3B A3 F0 90 00 08 E0 FA A3 E0 FB A3 E0 +R 00 00 00 07 00 07 00 05 +T 00 D6 F8 A3 E0 F9 23 54 01 F5 00 00 90 00 0C E0 +R 00 00 00 07 29 0A 00 01 00 0D 00 05 +T 00 E3 F5 00 01 A3 E0 F5 00 02 A3 E0 F5 00 03 A3 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 00 EE E0 F5 00 04 23 54 01 FA 65 00 00 F5 00 01 +R 00 00 00 07 29 04 00 01 29 0B 00 01 29 0E 00 01 +T 00 F9 90 00 0C E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 05 F5 00 07 A3 E0 F5 00 08 E5 00 05 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 0E 00 06 45 00 07 45 00 08 70 0B +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 15 +R 00 00 00 07 +T 01 15 90 00 00 75 F0 80 74 BF 02 04 BF +R 00 00 00 07 00 0B 00 07 +T 01 20 +R 00 00 00 07 +T 01 20 90 00 08 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 2C F5 00 07 A3 E0 F5 00 08 E5 00 05 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 35 00 06 45 00 07 45 00 08 70 0A +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 3C +R 00 00 00 07 +T 01 3C E4 F5 82 F5 83 F5 F0 02 04 BF +R 00 00 00 07 00 0A 00 07 +T 01 46 +R 00 00 00 07 +T 01 46 90 00 08 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 52 F5 00 07 A3 E0 F5 00 08 53 00 07 7F 75 +R 00 00 00 07 29 03 00 01 29 08 00 01 09 0B 00 01 +T 01 5C 00 08 00 90 00 18 E5 00 05 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 06 00 05 29 09 00 01 +T 01 66 00 06 F0 74 80 45 00 07 A3 F0 A3 E5 00 08 +R 00 00 00 07 29 02 00 01 29 08 00 01 29 0E 00 01 +T 01 71 F0 90 00 0C E0 F5 00 05 A3 E0 F5 00 06 A3 +R 00 00 00 07 00 04 00 05 29 08 00 01 29 0D 00 01 +T 01 7D E0 F5 00 07 A3 E0 F5 00 08 53 00 07 7F 75 +R 00 00 00 07 29 04 00 01 29 09 00 01 09 0C 00 01 +T 01 88 00 08 00 90 00 1C E5 00 05 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 06 00 05 29 09 00 01 +T 01 92 00 06 F0 74 80 45 00 07 A3 F0 A3 E5 00 08 +R 00 00 00 07 29 02 00 01 29 08 00 01 29 0E 00 01 +T 01 9D F0 90 00 1C E0 F5 00 05 A3 E0 F5 00 06 A3 +R 00 00 00 07 00 04 00 05 29 08 00 01 29 0D 00 01 +T 01 A9 E0 F5 00 07 A3 E0 F5 00 08 90 00 18 E0 F5 +R 00 00 00 07 29 04 00 01 29 09 00 01 00 0C 00 05 +T 01 B5 00 09 A3 E0 F5 00 0A A3 E0 F5 00 0B A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 01 C0 F5 00 0C C3 E5 00 09 95 00 05 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0A 00 01 +T 01 C8 00 0A 95 00 06 E5 00 0B 95 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 CE 00 07 E5 00 0C 64 80 85 00 08 F0 63 F0 80 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 01 D9 95 F0 40 03 02 02 31 +R 00 00 00 07 00 07 00 07 +T 01 E0 +R 00 00 00 07 +T 01 E0 90 00 18 E0 F5 00 09 A3 E0 F5 00 0A A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 EC F5 00 0B A3 E0 F5 00 0C E5 00 09 25 E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 F7 00 09 E5 00 0A 33 F5 00 0A E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 FE 00 0B 33 F5 00 0B E5 00 0C 33 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 02 06 00 0C 90 00 18 E5 00 09 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 08 00 01 +T 02 0F 00 0A F0 A3 E5 00 0B F0 A3 E5 00 0C F0 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 1A 00 20 E0 24 FF F5 00 09 A3 E0 34 FF F5 +R 00 00 00 07 00 02 00 05 29 08 00 01 +T 02 26 00 0A 90 00 20 E5 00 09 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 08 00 01 +T 02 2F 00 0A F0 +R 00 00 00 07 29 02 00 01 +T 02 31 +R 00 00 00 07 +T 02 31 90 00 14 E4 F0 A3 F0 A3 E4 F0 A3 74 01 F0 +R 00 00 00 07 00 03 00 05 +T 02 3F 90 00 10 E4 A3 A3 A3 F0 12 00 00 F0 12 +R 00 00 00 07 00 03 00 05 02 0B 00 00 +T 02 4C 00 00 F0 12 00 00 F0 +R 00 00 00 07 02 02 00 00 02 06 00 00 +T 02 53 +R 00 00 00 07 +T 02 53 90 00 14 E0 F5 00 09 A3 E0 F5 00 0A A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 5F F5 00 0B A3 E0 F5 00 0C E5 00 09 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 02 68 00 0A 45 00 0B 45 00 0C 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 70 03 A2 +R 00 00 00 07 00 02 00 07 +T 02 72 +R 00 00 00 07 +T 02 72 90 00 1C E0 F5 00 09 A3 E0 F5 00 0A A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 7E F5 00 0B A3 E0 F5 00 0C 90 00 18 E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 02 89 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 94 F5 00 08 C3 E5 00 05 95 00 09 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0A 00 01 +T 02 9C 00 06 95 00 0A E5 00 07 95 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 A2 00 0B E5 00 08 64 80 85 00 0C F0 63 F0 80 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 02 AD 95 F0 50 03 02 03 31 +R 00 00 00 07 00 07 00 07 +T 02 B4 +R 00 00 00 07 +T 02 B4 90 00 14 E0 F5 00 09 A3 E0 F5 00 0A A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 02 C0 F5 00 0B A3 E0 F5 00 0C 90 00 10 E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 02 CB 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 D6 F5 00 08 90 00 10 E5 00 09 45 +R 00 00 00 07 29 03 00 01 00 06 00 05 29 09 00 01 +T 02 DE 00 05 F0 E5 00 0A 45 00 06 A3 F0 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 02 E7 00 0B 45 00 07 A3 F0 E5 00 0C 45 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 02 EF 00 08 A3 F0 90 00 1C E0 F5 00 09 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 07 00 05 29 0B 00 01 +T 02 FB 00 0A A3 E0 F5 00 0B A3 E0 F5 00 0C 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 05 00 18 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 03 11 00 07 A3 E0 F5 00 08 90 00 18 C3 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0A 00 05 +T 03 1B 00 05 95 00 09 F0 E5 00 06 95 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 03 22 00 0A A3 F0 E5 00 07 95 00 0B A3 F0 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 03 2C 00 08 95 00 0C A3 F0 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 03 31 +R 00 00 00 07 +T 03 31 90 00 18 E0 F5 00 09 A3 E0 F5 00 0A A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 03 3D F5 00 0B A3 E0 F5 00 0C E5 00 09 25 E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 03 48 00 09 E5 00 0A 33 F5 00 0A E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 03 4F 00 0B 33 F5 00 0B E5 00 0C 33 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 03 57 00 0C 90 00 18 E5 00 09 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 08 00 01 +T 03 60 00 0A F0 A3 E5 00 0B F0 A3 E5 00 0C F0 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 6B 00 14 E0 F5 00 09 A3 E0 F5 00 0A A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 03 77 00 0B A3 E0 F5 00 0C C3 13 F5 00 0C E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 81 00 0B 13 F5 00 0B E5 00 0A 13 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 03 89 00 0A E5 00 09 13 F5 00 09 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 03 90 00 14 F0 A3 E5 00 0A F0 A3 E5 00 0B F0 A3 +R 00 00 00 07 00 02 00 05 29 07 00 01 29 0C 00 01 +T 03 9C E5 00 0C F0 02 02 53 +R 00 00 00 07 29 03 00 01 00 07 00 07 +T 03 A2 +R 00 00 00 07 +T 03 A2 90 00 10 E0 F5 00 09 A3 E0 F5 00 0A A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 03 AE F5 00 0B A3 E0 F5 00 0C 90 00 10 74 01 25 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 03 BA 00 09 F0 E4 35 00 0A A3 F0 E4 35 00 0B A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 03 C5 F0 E4 35 00 0C A3 F0 90 00 20 E0 24 01 F0 +R 00 00 00 07 29 05 00 01 00 0A 00 05 +T 03 D2 A3 E0 34 00 F0 90 00 10 E0 F5 00 09 A3 E0 +R 00 00 00 07 00 08 00 05 29 0C 00 01 +T 03 DF F5 00 0A A3 E0 F5 00 0B A3 E0 F5 00 0C A2 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 03 EA E7 13 F5 00 0C E5 00 0B 13 F5 00 0B E5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 03 F4 00 0A 13 F5 00 0A E5 00 09 13 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 03 FC 00 09 90 00 10 F0 A3 E5 00 0A F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 0A 00 01 +T 04 07 00 0B F0 A3 E5 00 0C F0 90 00 10 E0 F5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0B 00 05 +T 04 12 00 09 A3 E0 F5 00 0A A3 E0 F5 00 0B A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 04 1D F5 00 0C 90 00 10 E5 00 09 F0 A3 E5 +R 00 00 00 07 29 03 00 01 00 06 00 05 29 09 00 01 +T 04 27 00 0A F0 74 7F 55 00 0B A3 F0 A3 E5 00 0C +R 00 00 00 07 29 02 00 01 29 08 00 01 29 0E 00 01 +T 04 32 F0 90 00 20 E0 F5 00 09 A3 E0 F5 00 0A 85 +R 00 00 00 07 00 04 00 05 29 08 00 01 29 0D 00 01 +T 04 3E 00 09 00 0B E5 00 0A 54 01 A2 E0 C5 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 04 47 00 0B 13 C5 00 0B 13 C5 00 0B F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 04 4F 00 0C 75 00 0A 00 75 00 09 00 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 04 57 00 01 00 05 E4 F5 00 06 F5 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 08 00 01 +T 04 5D 00 07 F5 00 08 E5 00 05 42 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 63 00 09 E5 00 06 42 00 0A E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 69 00 07 42 00 0B E5 00 08 42 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 6F 00 0C 90 00 10 E0 F5 00 05 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 09 00 01 +T 04 79 00 06 A3 E0 F5 00 07 A3 E0 F5 00 08 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 04 83 00 05 42 00 09 E5 00 06 42 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 89 00 0A E5 00 07 42 00 0B E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 8F 00 08 42 00 0C 90 00 08 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 00 08 00 05 +T 04 96 00 09 F0 A3 E5 00 0A F0 A3 E5 00 0B F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 04 A1 E5 00 0C F0 90 00 08 E0 F5 00 09 A3 E0 F5 +R 00 00 00 07 29 03 00 01 00 07 00 05 29 0B 00 01 +T 04 AD 00 0A A3 E0 F5 00 0B A3 E0 F5 00 0C 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 04 B7 00 09 82 85 00 0A 83 85 00 0B F0 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 04 BF +R 00 00 00 07 +T 04 BF 22 +R 00 00 00 07 diff --git a/device/lib/large/_fseq.asm b/device/lib/large/_fseq.asm new file mode 100644 index 00000000..ad866be1 --- /dev/null +++ b/device/lib/large/_fseq.asm @@ -0,0 +1,282 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:27 2000 + +;-------------------------------------------------------- + .module _fseq +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fseq_PARM_2 + .globl ___fseq +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fseq_sloc0_1_0: + .ds 0x0004 +___fseq_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fseq_PARM_2: + .ds 0x0004 +___fseq_a1_1_1: + .ds 0x0004 +___fseq_fl1_1_1: + .ds 0x0004 +___fseq_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fseq$0$0 ==. +; _fseq.c 73 +; ----------------------------------------- +; function __fseq +; ----------------------------------------- +___fseq: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fseq.c 87 + push acc + push b + push dph + push dpl + mov dptr,#___fseq_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fseq.c 77 + mov dptr,#___fseq_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fseq_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fseq.c 78 + mov dptr,#___fseq_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fseq_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fseq.c 80 + mov dptr,#(___fseq_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00111$ + ljmp 00102$ +00111$: + mov dptr,#(___fseq_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00112$ + ljmp 00102$ +00112$: +; _fseq.c 82 + mov dptr,#(___fseq_fl1_1_1) + movx a,@dptr + mov ___fseq_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 3),a + xrl (___fseq_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fseq_fl1_1_1) + mov a,___fseq_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fseq_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fseq_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fseq_sloc0_1_0 + 3) + movx @dptr,a +; _fseq.c 83 + mov dptr,#(___fseq_fl2_1_1) + movx a,@dptr + mov ___fseq_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 3),a + xrl (___fseq_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fseq_fl2_1_1) + mov a,___fseq_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fseq_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fseq_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fseq_sloc0_1_0 + 3) + movx @dptr,a +00102$: +; _fseq.c 85 + mov dptr,#(___fseq_fl1_1_1) + movx a,@dptr + mov ___fseq_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fseq_sloc0_1_0 + 3),a + mov dptr,#(___fseq_fl2_1_1) + movx a,@dptr + mov ___fseq_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fseq_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fseq_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fseq_sloc1_1_0 + 3),a + mov a,___fseq_sloc0_1_0 +; Peephole 132 changed ljmp to sjmp +; Peephole 193 optimized misc jump sequence + cjne a,___fseq_sloc1_1_0,00105$ + mov a,(___fseq_sloc0_1_0 + 1) + cjne a,(___fseq_sloc1_1_0 + 1),00105$ + mov a,(___fseq_sloc0_1_0 + 2) + cjne a,(___fseq_sloc1_1_0 + 2),00105$ + mov a,(___fseq_sloc0_1_0 + 3) + cjne a,(___fseq_sloc1_1_0 + 3),00105$ +; Peephole 201 removed redundant sjmp +00113$: +00114$: +; _fseq.c 86 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fseq.c 87 + mov dpl,#0x00 +00106$: + C$_fseq.c$88$1$1 ==. + XG$__fseq$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fseq.cdb b/device/lib/large/_fseq.cdb new file mode 100644 index 00000000..1598e175 --- /dev/null +++ b/device/lib/large/_fseq.cdb @@ -0,0 +1,2 @@ +M:_fseq +F:G$__fseq$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fseq.rel b/device/lib/large/_fseq.rel new file mode 100644 index 00000000..b025aa82 --- /dev/null +++ b/device/lib/large/_fseq.rel @@ -0,0 +1,295 @@ +;!FILE _fseq.asm +XH +H 8 areas BD global symbols +M _fseq +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 10 flags 40 +S ___fseq_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 10F flags 20 +S A$_fseq$100 Def0026 +S A$_fseq$200 Def009F +S A$_fseq$110 Def0032 +S A$_fseq$101 Def0027 +S A$_fseq$210 Def00AD +S A$_fseq$201 Def00A0 +S A$_fseq$120 Def003D +S A$_fseq$111 Def0033 +S A$_fseq$102 Def0028 +S A$_fseq$220 Def00BC +S A$_fseq$211 Def00AE +S A$_fseq$202 Def00A2 +S A$_fseq$130 Def0049 +S A$_fseq$121 Def003E +S A$_fseq$112 Def0034 +S A$_fseq$103 Def002B +S A$_fseq$230 Def00CB +S A$_fseq$221 Def00BF +S A$_fseq$212 Def00AF +S A$_fseq$203 Def00A3 +S A$_fseq$140 Def0052 +S A$_fseq$131 Def004A +S A$_fseq$122 Def003F +S A$_fseq$113 Def0035 +S A$_fseq$104 Def002C +S ___fseq Def0000 +S A$_fseq$240 Def00D8 +S A$_fseq$231 Def00CD +S A$_fseq$222 Def00C1 +S A$_fseq$213 Def00B1 +S A$_fseq$204 Def00A4 +S A$_fseq$150 Def005E +S A$_fseq$141 Def0055 +S A$_fseq$132 Def004B +S A$_fseq$123 Def0040 +S A$_fseq$105 Def002D +S A$_fseq$250 Def00E7 +S A$_fseq$241 Def00D9 +S A$_fseq$223 Def00C2 +S A$_fseq$214 Def00B2 +S A$_fseq$205 Def00A6 +S A$_fseq$160 Def0069 +S A$_fseq$142 Def0056 +S A$_fseq$133 Def004C +S A$_fseq$124 Def0041 +S A$_fseq$115 Def0036 +S A$_fseq$106 Def002E +S A$_fseq$251 Def00E8 +S A$_fseq$242 Def00DA +S A$_fseq$224 Def00C3 +S A$_fseq$215 Def00B3 +S A$_fseq$170 Def0075 +S A$_fseq$161 Def006C +S A$_fseq$152 Def005F +S A$_fseq$143 Def0057 +S A$_fseq$134 Def004D +S A$_fseq$125 Def0042 +S A$_fseq$116 Def0039 +S A$_fseq$107 Def002F +S A$_fseq$261 Def00F4 +S A$_fseq$252 Def00EA +S A$_fseq$243 Def00DC +S A$_fseq$234 Def00CE +S A$_fseq$225 Def00C5 +S A$_fseq$216 Def00B5 +S A$_fseq$207 Def00A7 +S A$_fseq$162 Def006D +S A$_fseq$153 Def0060 +S A$_fseq$144 Def0058 +S A$_fseq$135 Def004E +S A$_fseq$126 Def0043 +S A$_fseq$117 Def003A +S A$_fseq$108 Def0030 +S A$_fseq$262 Def00F7 +S A$_fseq$253 Def00EB +S A$_fseq$244 Def00DD +S A$_fseq$235 Def00D1 +S A$_fseq$226 Def00C6 +S A$_fseq$217 Def00B6 +S A$_fseq$208 Def00AA +S A$_fseq$190 Def008E +S A$_fseq$181 Def0080 +S A$_fseq$172 Def0076 +S A$_fseq$163 Def006E +S A$_fseq$154 Def0061 +S A$_fseq$145 Def0059 +S A$_fseq$136 Def004F +S A$_fseq$127 Def0044 +S A$_fseq$118 Def003B +S A$_fseq$109 Def0031 +S A$_fseq$281 Def010E +S A$_fseq$272 Def0106 +S A$_fseq$263 Def00F9 +S A$_fseq$254 Def00EC +S A$_fseq$245 Def00DE +S A$_fseq$236 Def00D2 +S A$_fseq$227 Def00C7 +S A$_fseq$218 Def00B7 +S A$_fseq$209 Def00AB +S A$_fseq$191 Def008F +S A$_fseq$182 Def0083 +S A$_fseq$173 Def0077 +S A$_fseq$164 Def006F +S A$_fseq$146 Def005A +S A$_fseq$137 Def0050 +S A$_fseq$128 Def0047 +S A$_fseq$119 Def003C +S A$_fseq$264 Def00FC +S A$_fseq$255 Def00EE +S A$_fseq$246 Def00E0 +S A$_fseq$237 Def00D4 +S A$_fseq$228 Def00C9 +S A$_fseq$219 Def00B9 +S A$_fseq$192 Def0090 +S A$_fseq$183 Def0084 +S A$_fseq$174 Def0078 +S A$_fseq$165 Def0070 +S A$_fseq$156 Def0063 +S A$_fseq$147 Def005B +S A$_fseq$138 Def0051 +S A$_fseq$129 Def0048 +S A$_fseq$274 Def0109 +S A$_fseq$265 Def00FE +S A$_fseq$256 Def00EF +S A$_fseq$247 Def00E3 +S A$_fseq$238 Def00D5 +S A$_fseq$229 Def00CA +S A$_fseq$193 Def0092 +S A$_fseq$184 Def0086 +S A$_fseq$166 Def0071 +S A$_fseq$157 Def0064 +S A$_fseq$148 Def005C +S A$_fseq$266 Def0101 +S A$_fseq$257 Def00F0 +S A$_fseq$248 Def00E4 +S A$_fseq$239 Def00D6 +S A$_fseq$194 Def0095 +S A$_fseq$185 Def0087 +S A$_fseq$176 Def007A +S A$_fseq$167 Def0072 +S A$_fseq$158 Def0066 +S A$_fseq$149 Def005D +S A$_fseq$267 Def0103 +S A$_fseq$258 Def00F2 +S A$_fseq$249 Def00E6 +S A$_fseq$195 Def0098 +S A$_fseq$186 Def0088 +S A$_fseq$177 Def007B +S A$_fseq$168 Def0073 +S A$_fseq$277 Def010B +S A$_fseq$196 Def009A +S A$_fseq$187 Def008A +S A$_fseq$178 Def007D +S A$_fseq$169 Def0074 +S A$_fseq$197 Def009B +S A$_fseq$188 Def008B +S XG$__fseq$0$0 Def010E +S A$_fseq$198 Def009C +S A$_fseq$189 Def008C +S A$_fseq$199 Def009E +S A$_fseq$80 Def000E +S A$_fseq$90 Def001A +S A$_fseq$81 Def0010 +S G$__fseq$0$0 Def0000 +S A$_fseq$91 Def001D +S A$_fseq$82 Def0011 +S A$_fseq$73 Def0000 +S A$_fseq$92 Def001E +S A$_fseq$83 Def0012 +S A$_fseq$74 Def0002 +S A$_fseq$93 Def001F +S A$_fseq$84 Def0014 +S A$_fseq$75 Def0004 +S A$_fseq$94 Def0020 +S A$_fseq$85 Def0015 +S A$_fseq$76 Def0006 +S C$_fseq.c$88$1$1 Def010E +S A$_fseq$95 Def0021 +S A$_fseq$86 Def0016 +S A$_fseq$77 Def0008 +S A$_fseq$96 Def0022 +S A$_fseq$87 Def0018 +S A$_fseq$78 Def000B +S A$_fseq$97 Def0023 +S A$_fseq$88 Def0019 +S A$_fseq$79 Def000D +S A$_fseq$98 Def0024 +S A$_fseq$99 Def0025 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 08 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 45 00 0C EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 53 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 23 +R 00 00 00 07 00 02 00 05 +T 00 61 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 08 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 90 00 0C E0 FA A3 E0 FE A3 E0 FF A3 E0 F8 +R 00 00 00 07 00 03 00 05 +T 00 77 23 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 09 00 07 +T 00 80 +R 00 00 00 07 +T 00 80 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 8C F5 00 02 A3 E0 F5 00 03 63 00 03 80 90 +R 00 00 00 07 29 03 00 01 29 08 00 01 09 0B 00 01 +T 00 96 00 08 E5 00 00 F0 A3 E5 00 01 F0 A3 E5 +R 00 00 00 07 00 02 00 05 29 05 00 01 29 0A 00 01 +T 00 A1 00 02 F0 A3 E5 00 03 F0 90 00 0C E0 F5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0B 00 05 +T 00 AC 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 B7 F5 00 03 63 00 03 80 90 00 0C E5 +R 00 00 00 07 29 03 00 01 09 06 00 01 00 0A 00 05 +T 00 C0 00 00 F0 A3 E5 00 01 F0 A3 E5 00 02 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 CB E5 00 03 F0 +R 00 00 00 07 29 03 00 01 +T 00 CE +R 00 00 00 07 +T 00 CE 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 DA F5 00 02 A3 E0 F5 00 03 90 00 0C E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 00 E5 00 04 A3 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 F0 F5 00 07 E5 00 00 B5 00 04 14 E5 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 F8 00 01 B5 00 05 0F E5 00 02 B5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 00 FF 00 06 0A E5 00 03 B5 00 07 05 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 06 +R 00 00 00 07 +T 01 06 +R 00 00 00 07 +T 01 06 75 82 01 80 03 +R 00 00 00 07 +T 01 0B +R 00 00 00 07 +T 01 0B 75 82 00 +R 00 00 00 07 +T 01 0E +R 00 00 00 07 +T 01 0E 22 +R 00 00 00 07 diff --git a/device/lib/large/_fsgt.asm b/device/lib/large/_fsgt.asm new file mode 100644 index 00000000..965bcd5c --- /dev/null +++ b/device/lib/large/_fsgt.asm @@ -0,0 +1,284 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:27 2000 + +;-------------------------------------------------------- + .module _fsgt +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsgt_PARM_2 + .globl ___fsgt +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsgt_sloc0_1_0: + .ds 0x0004 +___fsgt_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fsgt_PARM_2: + .ds 0x0004 +___fsgt_a1_1_1: + .ds 0x0004 +___fsgt_fl1_1_1: + .ds 0x0004 +___fsgt_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsgt$0$0 ==. +; _fsgt.c 73 +; ----------------------------------------- +; function __fsgt +; ----------------------------------------- +___fsgt: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsgt.c 87 + push acc + push b + push dph + push dpl + mov dptr,#___fsgt_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fsgt.c 77 + mov dptr,#___fsgt_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsgt_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsgt.c 78 + mov dptr,#___fsgt_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsgt_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsgt.c 80 + mov dptr,#(___fsgt_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00111$ + ljmp 00102$ +00111$: + mov dptr,#(___fsgt_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00112$ + ljmp 00102$ +00112$: +; _fsgt.c 82 + mov dptr,#(___fsgt_fl1_1_1) + movx a,@dptr + mov ___fsgt_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 3),a + xrl (___fsgt_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fsgt_fl1_1_1) + mov a,___fsgt_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsgt_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsgt_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsgt_sloc0_1_0 + 3) + movx @dptr,a +; _fsgt.c 83 + mov dptr,#(___fsgt_fl2_1_1) + movx a,@dptr + mov ___fsgt_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 3),a + xrl (___fsgt_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fsgt_fl2_1_1) + mov a,___fsgt_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsgt_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsgt_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsgt_sloc0_1_0 + 3) + movx @dptr,a +00102$: +; _fsgt.c 85 + mov dptr,#(___fsgt_fl1_1_1) + movx a,@dptr + mov ___fsgt_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc0_1_0 + 3),a + mov dptr,#(___fsgt_fl2_1_1) + movx a,@dptr + mov ___fsgt_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsgt_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsgt_sloc1_1_0 + 3),a + clr c + mov a,___fsgt_sloc1_1_0 + subb a,___fsgt_sloc0_1_0 + mov a,(___fsgt_sloc1_1_0 + 1) + subb a,(___fsgt_sloc0_1_0 + 1) + mov a,(___fsgt_sloc1_1_0 + 2) + subb a,(___fsgt_sloc0_1_0 + 2) + mov a,(___fsgt_sloc1_1_0 + 3) + xrl a,#0x80 + mov b,(___fsgt_sloc0_1_0 + 3) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00105$ +00113$: +; _fsgt.c 86 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fsgt.c 87 + mov dpl,#0x00 +00106$: + C$_fsgt.c$88$1$1 ==. + XG$__fsgt$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fsgt.cdb b/device/lib/large/_fsgt.cdb new file mode 100644 index 00000000..e948f606 --- /dev/null +++ b/device/lib/large/_fsgt.cdb @@ -0,0 +1,2 @@ +M:_fsgt +F:G$__fsgt$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fsgt.rel b/device/lib/large/_fsgt.rel new file mode 100644 index 00000000..a8b25514 --- /dev/null +++ b/device/lib/large/_fsgt.rel @@ -0,0 +1,300 @@ +;!FILE _fsgt.asm +XH +H 8 areas C2 global symbols +M _fsgt +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 10 flags 40 +S ___fsgt_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 116 flags 20 +S A$_fsgt$100 Def0026 +S A$_fsgt$200 Def009F +S A$_fsgt$110 Def0032 +S A$_fsgt$101 Def0027 +S A$_fsgt$210 Def00AD +S A$_fsgt$201 Def00A0 +S A$_fsgt$120 Def003D +S A$_fsgt$111 Def0033 +S A$_fsgt$102 Def0028 +S A$_fsgt$220 Def00BC +S A$_fsgt$211 Def00AE +S A$_fsgt$202 Def00A2 +S A$_fsgt$130 Def0049 +S A$_fsgt$121 Def003E +S A$_fsgt$112 Def0034 +S A$_fsgt$103 Def002B +S A$_fsgt$230 Def00CB +S A$_fsgt$221 Def00BF +S A$_fsgt$212 Def00AF +S A$_fsgt$203 Def00A3 +S A$_fsgt$140 Def0052 +S A$_fsgt$131 Def004A +S A$_fsgt$122 Def003F +S A$_fsgt$113 Def0035 +S A$_fsgt$104 Def002C +S ___fsgt Def0000 +S A$_fsgt$240 Def00D8 +S A$_fsgt$231 Def00CD +S A$_fsgt$222 Def00C1 +S A$_fsgt$213 Def00B1 +S A$_fsgt$204 Def00A4 +S A$_fsgt$150 Def005E +S A$_fsgt$141 Def0055 +S A$_fsgt$132 Def004B +S A$_fsgt$123 Def0040 +S A$_fsgt$105 Def002D +S A$_fsgt$250 Def00E7 +S A$_fsgt$241 Def00D9 +S A$_fsgt$223 Def00C2 +S A$_fsgt$214 Def00B2 +S A$_fsgt$205 Def00A6 +S A$_fsgt$160 Def0069 +S A$_fsgt$142 Def0056 +S A$_fsgt$133 Def004C +S A$_fsgt$124 Def0041 +S A$_fsgt$115 Def0036 +S A$_fsgt$106 Def002E +S A$_fsgt$260 Def00F5 +S A$_fsgt$251 Def00E8 +S A$_fsgt$242 Def00DA +S A$_fsgt$224 Def00C3 +S A$_fsgt$215 Def00B3 +S A$_fsgt$170 Def0075 +S A$_fsgt$161 Def006C +S A$_fsgt$152 Def005F +S A$_fsgt$143 Def0057 +S A$_fsgt$134 Def004D +S A$_fsgt$125 Def0042 +S A$_fsgt$116 Def0039 +S A$_fsgt$107 Def002F +S A$_fsgt$261 Def00F7 +S A$_fsgt$252 Def00EA +S A$_fsgt$243 Def00DC +S A$_fsgt$234 Def00CE +S A$_fsgt$225 Def00C5 +S A$_fsgt$216 Def00B5 +S A$_fsgt$207 Def00A7 +S A$_fsgt$162 Def006D +S A$_fsgt$153 Def0060 +S A$_fsgt$144 Def0058 +S A$_fsgt$135 Def004E +S A$_fsgt$126 Def0043 +S A$_fsgt$117 Def003A +S A$_fsgt$108 Def0030 +S A$_fsgt$271 Def010B +S A$_fsgt$262 Def00F9 +S A$_fsgt$253 Def00EB +S A$_fsgt$244 Def00DD +S A$_fsgt$235 Def00D1 +S A$_fsgt$226 Def00C6 +S A$_fsgt$217 Def00B6 +S A$_fsgt$208 Def00AA +S A$_fsgt$190 Def008E +S A$_fsgt$181 Def0080 +S A$_fsgt$172 Def0076 +S A$_fsgt$163 Def006E +S A$_fsgt$154 Def0061 +S A$_fsgt$145 Def0059 +S A$_fsgt$136 Def004F +S A$_fsgt$127 Def0044 +S A$_fsgt$118 Def003B +S A$_fsgt$109 Def0031 +S A$_fsgt$263 Def00FB +S A$_fsgt$254 Def00EC +S A$_fsgt$245 Def00DE +S A$_fsgt$236 Def00D2 +S A$_fsgt$227 Def00C7 +S A$_fsgt$218 Def00B7 +S A$_fsgt$209 Def00AB +S A$_fsgt$191 Def008F +S A$_fsgt$182 Def0083 +S A$_fsgt$173 Def0077 +S A$_fsgt$164 Def006F +S A$_fsgt$146 Def005A +S A$_fsgt$137 Def0050 +S A$_fsgt$128 Def0047 +S A$_fsgt$119 Def003C +S A$_fsgt$264 Def00FD +S A$_fsgt$255 Def00EE +S A$_fsgt$246 Def00E0 +S A$_fsgt$237 Def00D4 +S A$_fsgt$228 Def00C9 +S A$_fsgt$219 Def00B9 +S A$_fsgt$192 Def0090 +S A$_fsgt$183 Def0084 +S A$_fsgt$174 Def0078 +S A$_fsgt$165 Def0070 +S A$_fsgt$156 Def0063 +S A$_fsgt$147 Def005B +S A$_fsgt$138 Def0051 +S A$_fsgt$129 Def0048 +S A$_fsgt$283 Def0115 +S A$_fsgt$274 Def010D +S A$_fsgt$265 Def00FF +S A$_fsgt$256 Def00EF +S A$_fsgt$247 Def00E3 +S A$_fsgt$238 Def00D5 +S A$_fsgt$229 Def00CA +S A$_fsgt$193 Def0092 +S A$_fsgt$184 Def0086 +S A$_fsgt$166 Def0071 +S A$_fsgt$157 Def0064 +S A$_fsgt$148 Def005C +S A$_fsgt$266 Def0101 +S A$_fsgt$257 Def00F0 +S A$_fsgt$248 Def00E4 +S A$_fsgt$239 Def00D6 +S A$_fsgt$194 Def0095 +S A$_fsgt$185 Def0087 +S A$_fsgt$176 Def007A +S A$_fsgt$167 Def0072 +S A$_fsgt$158 Def0066 +S A$_fsgt$149 Def005D +S A$_fsgt$276 Def0110 +S A$_fsgt$267 Def0103 +S A$_fsgt$258 Def00F2 +S A$_fsgt$249 Def00E6 +S A$_fsgt$195 Def0098 +S A$_fsgt$186 Def0088 +S A$_fsgt$177 Def007B +S A$_fsgt$168 Def0073 +S A$_fsgt$268 Def0106 +S A$_fsgt$259 Def00F3 +S A$_fsgt$196 Def009A +S A$_fsgt$187 Def008A +S A$_fsgt$178 Def007D +S A$_fsgt$169 Def0074 +S A$_fsgt$269 Def0109 +S A$_fsgt$197 Def009B +S A$_fsgt$188 Def008B +S XG$__fsgt$0$0 Def0115 +S A$_fsgt$279 Def0112 +S A$_fsgt$198 Def009C +S A$_fsgt$189 Def008C +S A$_fsgt$199 Def009E +S A$_fsgt$80 Def000E +S A$_fsgt$90 Def001A +S A$_fsgt$81 Def0010 +S G$__fsgt$0$0 Def0000 +S A$_fsgt$91 Def001D +S A$_fsgt$82 Def0011 +S A$_fsgt$73 Def0000 +S A$_fsgt$92 Def001E +S A$_fsgt$83 Def0012 +S A$_fsgt$74 Def0002 +S A$_fsgt$93 Def001F +S A$_fsgt$84 Def0014 +S A$_fsgt$75 Def0004 +S A$_fsgt$94 Def0020 +S A$_fsgt$85 Def0015 +S A$_fsgt$76 Def0006 +S C$_fsgt.c$88$1$1 Def0115 +S A$_fsgt$95 Def0021 +S A$_fsgt$86 Def0016 +S A$_fsgt$77 Def0008 +S A$_fsgt$96 Def0022 +S A$_fsgt$87 Def0018 +S A$_fsgt$78 Def000B +S A$_fsgt$97 Def0023 +S A$_fsgt$88 Def0019 +S A$_fsgt$79 Def000D +S A$_fsgt$98 Def0024 +S A$_fsgt$99 Def0025 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 08 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 45 00 0C EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 53 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 23 +R 00 00 00 07 00 02 00 05 +T 00 61 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 08 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 90 00 0C E0 FA A3 E0 FE A3 E0 FF A3 E0 F8 +R 00 00 00 07 00 03 00 05 +T 00 77 23 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 09 00 07 +T 00 80 +R 00 00 00 07 +T 00 80 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 8C F5 00 02 A3 E0 F5 00 03 63 00 03 80 90 +R 00 00 00 07 29 03 00 01 29 08 00 01 09 0B 00 01 +T 00 96 00 08 E5 00 00 F0 A3 E5 00 01 F0 A3 E5 +R 00 00 00 07 00 02 00 05 29 05 00 01 29 0A 00 01 +T 00 A1 00 02 F0 A3 E5 00 03 F0 90 00 0C E0 F5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0B 00 05 +T 00 AC 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 B7 F5 00 03 63 00 03 80 90 00 0C E5 +R 00 00 00 07 29 03 00 01 09 06 00 01 00 0A 00 05 +T 00 C0 00 00 F0 A3 E5 00 01 F0 A3 E5 00 02 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 CB E5 00 03 F0 +R 00 00 00 07 29 03 00 01 +T 00 CE +R 00 00 00 07 +T 00 CE 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 DA F5 00 02 A3 E0 F5 00 03 90 00 0C E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 00 E5 00 04 A3 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 F0 F5 00 07 C3 E5 00 04 95 00 00 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0A 00 01 +T 00 F8 00 05 95 00 01 E5 00 06 95 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 FE 00 02 E5 00 07 64 80 85 00 03 F0 63 F0 80 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 01 09 95 F0 50 05 +R 00 00 00 07 +T 01 0D +R 00 00 00 07 +T 01 0D 75 82 01 80 03 +R 00 00 00 07 +T 01 12 +R 00 00 00 07 +T 01 12 75 82 00 +R 00 00 00 07 +T 01 15 +R 00 00 00 07 +T 01 15 22 +R 00 00 00 07 diff --git a/device/lib/large/_fslt.asm b/device/lib/large/_fslt.asm new file mode 100644 index 00000000..e6da6703 --- /dev/null +++ b/device/lib/large/_fslt.asm @@ -0,0 +1,284 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:27 2000 + +;-------------------------------------------------------- + .module _fslt +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fslt_PARM_2 + .globl ___fslt +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fslt_sloc0_1_0: + .ds 0x0004 +___fslt_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fslt_PARM_2: + .ds 0x0004 +___fslt_a1_1_1: + .ds 0x0004 +___fslt_fl1_1_1: + .ds 0x0004 +___fslt_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fslt$0$0 ==. +; _fslt.c 73 +; ----------------------------------------- +; function __fslt +; ----------------------------------------- +___fslt: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fslt.c 87 + push acc + push b + push dph + push dpl + mov dptr,#___fslt_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fslt.c 77 + mov dptr,#___fslt_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fslt_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fslt.c 78 + mov dptr,#___fslt_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fslt_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fslt.c 80 + mov dptr,#(___fslt_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00111$ + ljmp 00102$ +00111$: + mov dptr,#(___fslt_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00112$ + ljmp 00102$ +00112$: +; _fslt.c 82 + mov dptr,#(___fslt_fl1_1_1) + movx a,@dptr + mov ___fslt_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 3),a + xrl (___fslt_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fslt_fl1_1_1) + mov a,___fslt_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fslt_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fslt_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fslt_sloc0_1_0 + 3) + movx @dptr,a +; _fslt.c 83 + mov dptr,#(___fslt_fl2_1_1) + movx a,@dptr + mov ___fslt_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 3),a + xrl (___fslt_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fslt_fl2_1_1) + mov a,___fslt_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fslt_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fslt_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fslt_sloc0_1_0 + 3) + movx @dptr,a +00102$: +; _fslt.c 85 + mov dptr,#(___fslt_fl1_1_1) + movx a,@dptr + mov ___fslt_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fslt_sloc0_1_0 + 3),a + mov dptr,#(___fslt_fl2_1_1) + movx a,@dptr + mov ___fslt_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fslt_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fslt_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fslt_sloc1_1_0 + 3),a + clr c + mov a,___fslt_sloc0_1_0 + subb a,___fslt_sloc1_1_0 + mov a,(___fslt_sloc0_1_0 + 1) + subb a,(___fslt_sloc1_1_0 + 1) + mov a,(___fslt_sloc0_1_0 + 2) + subb a,(___fslt_sloc1_1_0 + 2) + mov a,(___fslt_sloc0_1_0 + 3) + xrl a,#0x80 + mov b,(___fslt_sloc1_1_0 + 3) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00105$ +00113$: +; _fslt.c 86 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fslt.c 87 + mov dpl,#0x00 +00106$: + C$_fslt.c$88$1$1 ==. + XG$__fslt$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fslt.cdb b/device/lib/large/_fslt.cdb new file mode 100644 index 00000000..74e764bc --- /dev/null +++ b/device/lib/large/_fslt.cdb @@ -0,0 +1,2 @@ +M:_fslt +F:G$__fslt$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fslt.rel b/device/lib/large/_fslt.rel new file mode 100644 index 00000000..5540ee26 --- /dev/null +++ b/device/lib/large/_fslt.rel @@ -0,0 +1,300 @@ +;!FILE _fslt.asm +XH +H 8 areas C2 global symbols +M _fslt +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 10 flags 40 +S ___fslt_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 116 flags 20 +S A$_fslt$100 Def0026 +S A$_fslt$200 Def009F +S A$_fslt$110 Def0032 +S A$_fslt$101 Def0027 +S A$_fslt$210 Def00AD +S A$_fslt$201 Def00A0 +S A$_fslt$120 Def003D +S A$_fslt$111 Def0033 +S A$_fslt$102 Def0028 +S A$_fslt$220 Def00BC +S A$_fslt$211 Def00AE +S A$_fslt$202 Def00A2 +S A$_fslt$130 Def0049 +S A$_fslt$121 Def003E +S A$_fslt$112 Def0034 +S A$_fslt$103 Def002B +S A$_fslt$230 Def00CB +S A$_fslt$221 Def00BF +S A$_fslt$212 Def00AF +S A$_fslt$203 Def00A3 +S A$_fslt$140 Def0052 +S A$_fslt$131 Def004A +S A$_fslt$122 Def003F +S A$_fslt$113 Def0035 +S A$_fslt$104 Def002C +S ___fslt Def0000 +S A$_fslt$240 Def00D8 +S A$_fslt$231 Def00CD +S A$_fslt$222 Def00C1 +S A$_fslt$213 Def00B1 +S A$_fslt$204 Def00A4 +S A$_fslt$150 Def005E +S A$_fslt$141 Def0055 +S A$_fslt$132 Def004B +S A$_fslt$123 Def0040 +S A$_fslt$105 Def002D +S A$_fslt$250 Def00E7 +S A$_fslt$241 Def00D9 +S A$_fslt$223 Def00C2 +S A$_fslt$214 Def00B2 +S A$_fslt$205 Def00A6 +S A$_fslt$160 Def0069 +S A$_fslt$142 Def0056 +S A$_fslt$133 Def004C +S A$_fslt$124 Def0041 +S A$_fslt$115 Def0036 +S A$_fslt$106 Def002E +S A$_fslt$260 Def00F5 +S A$_fslt$251 Def00E8 +S A$_fslt$242 Def00DA +S A$_fslt$224 Def00C3 +S A$_fslt$215 Def00B3 +S A$_fslt$170 Def0075 +S A$_fslt$161 Def006C +S A$_fslt$152 Def005F +S A$_fslt$143 Def0057 +S A$_fslt$134 Def004D +S A$_fslt$125 Def0042 +S A$_fslt$116 Def0039 +S A$_fslt$107 Def002F +S A$_fslt$261 Def00F7 +S A$_fslt$252 Def00EA +S A$_fslt$243 Def00DC +S A$_fslt$234 Def00CE +S A$_fslt$225 Def00C5 +S A$_fslt$216 Def00B5 +S A$_fslt$207 Def00A7 +S A$_fslt$162 Def006D +S A$_fslt$153 Def0060 +S A$_fslt$144 Def0058 +S A$_fslt$135 Def004E +S A$_fslt$126 Def0043 +S A$_fslt$117 Def003A +S A$_fslt$108 Def0030 +S A$_fslt$271 Def010B +S A$_fslt$262 Def00F9 +S A$_fslt$253 Def00EB +S A$_fslt$244 Def00DD +S A$_fslt$235 Def00D1 +S A$_fslt$226 Def00C6 +S A$_fslt$217 Def00B6 +S A$_fslt$208 Def00AA +S A$_fslt$190 Def008E +S A$_fslt$181 Def0080 +S A$_fslt$172 Def0076 +S A$_fslt$163 Def006E +S A$_fslt$154 Def0061 +S A$_fslt$145 Def0059 +S A$_fslt$136 Def004F +S A$_fslt$127 Def0044 +S A$_fslt$118 Def003B +S A$_fslt$109 Def0031 +S A$_fslt$263 Def00FB +S A$_fslt$254 Def00EC +S A$_fslt$245 Def00DE +S A$_fslt$236 Def00D2 +S A$_fslt$227 Def00C7 +S A$_fslt$218 Def00B7 +S A$_fslt$209 Def00AB +S A$_fslt$191 Def008F +S A$_fslt$182 Def0083 +S A$_fslt$173 Def0077 +S A$_fslt$164 Def006F +S A$_fslt$146 Def005A +S A$_fslt$137 Def0050 +S A$_fslt$128 Def0047 +S A$_fslt$119 Def003C +S A$_fslt$264 Def00FD +S A$_fslt$255 Def00EE +S A$_fslt$246 Def00E0 +S A$_fslt$237 Def00D4 +S A$_fslt$228 Def00C9 +S A$_fslt$219 Def00B9 +S A$_fslt$192 Def0090 +S A$_fslt$183 Def0084 +S A$_fslt$174 Def0078 +S A$_fslt$165 Def0070 +S A$_fslt$156 Def0063 +S A$_fslt$147 Def005B +S A$_fslt$138 Def0051 +S A$_fslt$129 Def0048 +S A$_fslt$283 Def0115 +S A$_fslt$274 Def010D +S A$_fslt$265 Def00FF +S A$_fslt$256 Def00EF +S A$_fslt$247 Def00E3 +S A$_fslt$238 Def00D5 +S A$_fslt$229 Def00CA +S A$_fslt$193 Def0092 +S A$_fslt$184 Def0086 +S A$_fslt$166 Def0071 +S A$_fslt$157 Def0064 +S A$_fslt$148 Def005C +S A$_fslt$266 Def0101 +S A$_fslt$257 Def00F0 +S A$_fslt$248 Def00E4 +S A$_fslt$239 Def00D6 +S A$_fslt$194 Def0095 +S A$_fslt$185 Def0087 +S A$_fslt$176 Def007A +S A$_fslt$167 Def0072 +S A$_fslt$158 Def0066 +S A$_fslt$149 Def005D +S A$_fslt$276 Def0110 +S A$_fslt$267 Def0103 +S A$_fslt$258 Def00F2 +S A$_fslt$249 Def00E6 +S A$_fslt$195 Def0098 +S A$_fslt$186 Def0088 +S A$_fslt$177 Def007B +S A$_fslt$168 Def0073 +S A$_fslt$268 Def0106 +S A$_fslt$259 Def00F3 +S A$_fslt$196 Def009A +S A$_fslt$187 Def008A +S A$_fslt$178 Def007D +S A$_fslt$169 Def0074 +S A$_fslt$269 Def0109 +S A$_fslt$197 Def009B +S A$_fslt$188 Def008B +S XG$__fslt$0$0 Def0115 +S A$_fslt$279 Def0112 +S A$_fslt$198 Def009C +S A$_fslt$189 Def008C +S A$_fslt$199 Def009E +S A$_fslt$80 Def000E +S A$_fslt$90 Def001A +S A$_fslt$81 Def0010 +S G$__fslt$0$0 Def0000 +S A$_fslt$91 Def001D +S A$_fslt$82 Def0011 +S A$_fslt$73 Def0000 +S A$_fslt$92 Def001E +S A$_fslt$83 Def0012 +S A$_fslt$74 Def0002 +S A$_fslt$93 Def001F +S A$_fslt$84 Def0014 +S A$_fslt$75 Def0004 +S A$_fslt$94 Def0020 +S A$_fslt$85 Def0015 +S A$_fslt$76 Def0006 +S C$_fslt.c$88$1$1 Def0115 +S A$_fslt$95 Def0021 +S A$_fslt$86 Def0016 +S A$_fslt$77 Def0008 +S A$_fslt$96 Def0022 +S A$_fslt$87 Def0018 +S A$_fslt$78 Def000B +S A$_fslt$97 Def0023 +S A$_fslt$88 Def0019 +S A$_fslt$79 Def000D +S A$_fslt$98 Def0024 +S A$_fslt$99 Def0025 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 08 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 45 00 0C EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 53 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 23 +R 00 00 00 07 00 02 00 05 +T 00 61 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 08 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 90 00 0C E0 FA A3 E0 FE A3 E0 FF A3 E0 F8 +R 00 00 00 07 00 03 00 05 +T 00 77 23 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 09 00 07 +T 00 80 +R 00 00 00 07 +T 00 80 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 8C F5 00 02 A3 E0 F5 00 03 63 00 03 80 90 +R 00 00 00 07 29 03 00 01 29 08 00 01 09 0B 00 01 +T 00 96 00 08 E5 00 00 F0 A3 E5 00 01 F0 A3 E5 +R 00 00 00 07 00 02 00 05 29 05 00 01 29 0A 00 01 +T 00 A1 00 02 F0 A3 E5 00 03 F0 90 00 0C E0 F5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0B 00 05 +T 00 AC 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 B7 F5 00 03 63 00 03 80 90 00 0C E5 +R 00 00 00 07 29 03 00 01 09 06 00 01 00 0A 00 05 +T 00 C0 00 00 F0 A3 E5 00 01 F0 A3 E5 00 02 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 CB E5 00 03 F0 +R 00 00 00 07 29 03 00 01 +T 00 CE +R 00 00 00 07 +T 00 CE 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 DA F5 00 02 A3 E0 F5 00 03 90 00 0C E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 00 E5 00 04 A3 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 F0 F5 00 07 C3 E5 00 00 95 00 04 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0A 00 01 +T 00 F8 00 01 95 00 05 E5 00 02 95 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 FE 00 06 E5 00 03 64 80 85 00 07 F0 63 F0 80 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 01 09 95 F0 50 05 +R 00 00 00 07 +T 01 0D +R 00 00 00 07 +T 01 0D 75 82 01 80 03 +R 00 00 00 07 +T 01 12 +R 00 00 00 07 +T 01 12 75 82 00 +R 00 00 00 07 +T 01 15 +R 00 00 00 07 +T 01 15 22 +R 00 00 00 07 diff --git a/device/lib/large/_fsmul.asm b/device/lib/large/_fsmul.asm new file mode 100644 index 00000000..15834d82 --- /dev/null +++ b/device/lib/large/_fsmul.asm @@ -0,0 +1,936 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + +;-------------------------------------------------------- + .module _fsmul +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsmul_PARM_2 + .globl ___fsmul +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsmul_sloc0_1_0: + .ds 0x0004 +___fsmul_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fsmul_PARM_2: + .ds 0x0004 +___fsmul_a1_1_1: + .ds 0x0004 +___fsmul_fl1_1_1: + .ds 0x0004 +___fsmul_fl2_1_1: + .ds 0x0004 +___fsmul_result_1_1: + .ds 0x0004 +___fsmul_exp_1_1: + .ds 0x0002 +___fsmul_sign_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsmul$0$0 ==. +; _fsmul.c 81 +; ----------------------------------------- +; function __fsmul +; ----------------------------------------- +___fsmul: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsmul.c 125 + push acc + push b + push dph + push dpl + mov dptr,#___fsmul_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fsmul.c 88 + mov dptr,#___fsmul_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsmul_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsmul.c 89 + mov dptr,#___fsmul_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsmul_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsmul.c 91 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 110 removed ljmp by inverse jump logic + jz 00101$ +00114$: + mov dptr,#(___fsmul_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00115$: +00101$: +; _fsmul.c 92 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00107$ +00102$: +; _fsmul.c 95 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rl a + anl a,#0x01 + mov r2,a + mov dptr,#(___fsmul_fl2_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r1,a + rl a + anl a,#0x01 + mov r6,a + mov dptr,#___fsmul_sign_1_1 + mov a,r6 + xrl a,ar2 + movx @dptr,a +; _fsmul.c 96 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 2) + mov a,(___fsmul_sloc0_1_0 + 3) + mov c,acc.7 + xch a,___fsmul_sloc0_1_0 + rlc a + xch a,___fsmul_sloc0_1_0 + rlc a + xch a,___fsmul_sloc0_1_0 + anl a,#0x01 + jnb acc.0,00116$ + orl a,#0xfe +00116$: + mov (___fsmul_sloc0_1_0 + 1),a + rlc a + subb a,acc + mov (___fsmul_sloc0_1_0 + 2),a + mov (___fsmul_sloc0_1_0 + 3),a + mov r2,___fsmul_sloc0_1_0 + mov r6,(___fsmul_sloc0_1_0 + 1) + mov a,r2 + mov b,#0x00 + add a,#0x82 + mov r2,a + mov a,b + addc a,#0xff + mov r6,a + mov dptr,#___fsmul_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a +; _fsmul.c 97 + mov dptr,#(___fsmul_fl2_1_1) + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 2) + mov a,(___fsmul_sloc0_1_0 + 3) + mov c,acc.7 + xch a,___fsmul_sloc0_1_0 + rlc a + xch a,___fsmul_sloc0_1_0 + rlc a + xch a,___fsmul_sloc0_1_0 + anl a,#0x01 + jnb acc.0,00117$ + orl a,#0xfe +00117$: + mov (___fsmul_sloc0_1_0 + 1),a + rlc a + subb a,acc + mov (___fsmul_sloc0_1_0 + 2),a + mov (___fsmul_sloc0_1_0 + 3),a + mov r2,___fsmul_sloc0_1_0 + mov r6,(___fsmul_sloc0_1_0 + 1) + mov ___fsmul_sloc0_1_0,r2 + mov (___fsmul_sloc0_1_0 + 1),#0x00 + mov dptr,#___fsmul_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r6,a + mov dptr,#___fsmul_exp_1_1 + mov a,___fsmul_sloc0_1_0 + add a,r2 + movx @dptr,a + mov a,(___fsmul_sloc0_1_0 + 1) + addc a,r6 + inc dptr + movx @dptr,a +; _fsmul.c 99 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + anl (___fsmul_sloc0_1_0 + 2),#0x7f + mov (___fsmul_sloc0_1_0 + 3),#0x00 + orl (___fsmul_sloc0_1_0 + 2),#0x80 + mov dptr,#(___fsmul_fl1_1_1) + mov a,___fsmul_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 3) + movx @dptr,a +; _fsmul.c 100 + mov dptr,#(___fsmul_fl2_1_1) + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + anl (___fsmul_sloc0_1_0 + 2),#0x7f + mov (___fsmul_sloc0_1_0 + 3),#0x00 + orl (___fsmul_sloc0_1_0 + 2),#0x80 + mov dptr,#(___fsmul_fl2_1_1) + mov a,___fsmul_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 3) + movx @dptr,a +; _fsmul.c 103 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 1) + mov (___fsmul_sloc0_1_0 + 1),(___fsmul_sloc0_1_0 + 2) + mov a,(___fsmul_sloc0_1_0 + 3) + mov (___fsmul_sloc0_1_0 + 2),a + rlc a + subb a,acc + mov (___fsmul_sloc0_1_0 + 3),a + mov dptr,#(___fsmul_fl2_1_1) + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + mov a,(___fsmul_sloc1_1_0 + 3) + mov (___fsmul_sloc1_1_0 + 2),a + rlc a + subb a,acc + mov (___fsmul_sloc1_1_0 + 3),a + mov dptr,#__mulslong_PARM_2 + mov a,___fsmul_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 3) + movx @dptr,a + mov dpl,___fsmul_sloc0_1_0 + mov dph,(___fsmul_sloc0_1_0 + 1) + mov b,(___fsmul_sloc0_1_0 + 2) + mov a,(___fsmul_sloc0_1_0 + 3) + lcall __mulslong + mov ___fsmul_sloc1_1_0,dpl + mov (___fsmul_sloc1_1_0 + 1),dph + mov (___fsmul_sloc1_1_0 + 2),b + mov (___fsmul_sloc1_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + mov a,___fsmul_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 3) + movx @dptr,a +; _fsmul.c 104 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov (___fsmul_sloc1_1_0 + 1),#0x00 + mov (___fsmul_sloc1_1_0 + 2),#0x00 + mov (___fsmul_sloc1_1_0 + 3),#0x00 + mov dptr,#(___fsmul_fl2_1_1) + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 1) + mov (___fsmul_sloc0_1_0 + 1),(___fsmul_sloc0_1_0 + 2) + mov a,(___fsmul_sloc0_1_0 + 3) + mov (___fsmul_sloc0_1_0 + 2),a + rlc a + subb a,acc + mov (___fsmul_sloc0_1_0 + 3),a + mov dptr,#__mululong_PARM_2 + mov a,___fsmul_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 3) + movx @dptr,a + mov dpl,___fsmul_sloc1_1_0 + mov dph,(___fsmul_sloc1_1_0 + 1) + mov b,(___fsmul_sloc1_1_0 + 2) + mov a,(___fsmul_sloc1_1_0 + 3) + lcall __mululong + mov ___fsmul_sloc1_1_0,dpl + mov (___fsmul_sloc1_1_0 + 1),dph + mov (___fsmul_sloc1_1_0 + 2),b + mov (___fsmul_sloc1_1_0 + 3),a + mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + mov (___fsmul_sloc1_1_0 + 2),(___fsmul_sloc1_1_0 + 3) + mov (___fsmul_sloc1_1_0 + 3),#0x00 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + mov a,___fsmul_sloc1_1_0 + add a,___fsmul_sloc0_1_0 + movx @dptr,a + mov a,(___fsmul_sloc1_1_0 + 1) + addc a,(___fsmul_sloc0_1_0 + 1) + inc dptr + movx @dptr,a + mov a,(___fsmul_sloc1_1_0 + 2) + addc a,(___fsmul_sloc0_1_0 + 2) + inc dptr + movx @dptr,a + mov a,(___fsmul_sloc1_1_0 + 3) + addc a,(___fsmul_sloc0_1_0 + 3) + inc dptr + movx @dptr,a +; _fsmul.c 105 + mov dptr,#(___fsmul_fl2_1_1) + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov (___fsmul_sloc1_1_0 + 1),#0x00 + mov (___fsmul_sloc1_1_0 + 2),#0x00 + mov (___fsmul_sloc1_1_0 + 3),#0x00 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov ___fsmul_sloc0_1_0,(___fsmul_sloc0_1_0 + 1) + mov (___fsmul_sloc0_1_0 + 1),(___fsmul_sloc0_1_0 + 2) + mov a,(___fsmul_sloc0_1_0 + 3) + mov (___fsmul_sloc0_1_0 + 2),a + rlc a + subb a,acc + mov (___fsmul_sloc0_1_0 + 3),a + mov dptr,#__mululong_PARM_2 + mov a,___fsmul_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc0_1_0 + 3) + movx @dptr,a + mov dpl,___fsmul_sloc1_1_0 + mov dph,(___fsmul_sloc1_1_0 + 1) + mov b,(___fsmul_sloc1_1_0 + 2) + mov a,(___fsmul_sloc1_1_0 + 3) + lcall __mululong + mov ___fsmul_sloc1_1_0,dpl + mov (___fsmul_sloc1_1_0 + 1),dph + mov (___fsmul_sloc1_1_0 + 2),b + mov (___fsmul_sloc1_1_0 + 3),a + mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + mov (___fsmul_sloc1_1_0 + 2),(___fsmul_sloc1_1_0 + 3) + mov (___fsmul_sloc1_1_0 + 3),#0x00 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + mov a,___fsmul_sloc1_1_0 + add a,___fsmul_sloc0_1_0 + movx @dptr,a + mov a,(___fsmul_sloc1_1_0 + 1) + addc a,(___fsmul_sloc0_1_0 + 1) + inc dptr + movx @dptr,a + mov a,(___fsmul_sloc1_1_0 + 2) + addc a,(___fsmul_sloc0_1_0 + 2) + inc dptr + movx @dptr,a + mov a,(___fsmul_sloc1_1_0 + 3) + addc a,(___fsmul_sloc0_1_0 + 3) + inc dptr + movx @dptr,a +; _fsmul.c 107 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov (___fsmul_sloc1_1_0 + 3),a + jb acc.7,00118$ + ljmp 00105$ +00118$: +; _fsmul.c 110 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + mov a,#0x80 + add a,___fsmul_sloc1_1_0 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_sloc1_1_0 + 1) + inc dptr + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_sloc1_1_0 + 2) + inc dptr + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_sloc1_1_0 + 3) + inc dptr + movx @dptr,a +; _fsmul.c 111 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov ___fsmul_sloc1_1_0,(___fsmul_sloc1_1_0 + 1) + mov (___fsmul_sloc1_1_0 + 1),(___fsmul_sloc1_1_0 + 2) + mov (___fsmul_sloc1_1_0 + 2),(___fsmul_sloc1_1_0 + 3) + mov (___fsmul_sloc1_1_0 + 3),#0x00 + mov dptr,#___fsmul_result_1_1 + mov a,___fsmul_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 3) + movx @dptr,a + ljmp 00106$ +00105$: +; _fsmul.c 116 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + mov a,#0x40 + add a,___fsmul_sloc1_1_0 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_sloc1_1_0 + 1) + inc dptr + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_sloc1_1_0 + 2) + inc dptr + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_sloc1_1_0 + 3) + inc dptr + movx @dptr,a +; _fsmul.c 117 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov a,(___fsmul_sloc1_1_0 + 1) + mov c,acc.7 + xch a,___fsmul_sloc1_1_0 + rlc a + xch a,___fsmul_sloc1_1_0 + rlc a + xch a,___fsmul_sloc1_1_0 + anl a,#0x01 + mov (___fsmul_sloc1_1_0 + 1),a + mov a,(___fsmul_sloc1_1_0 + 2) + add a,acc + orl a,(___fsmul_sloc1_1_0 + 1) + mov (___fsmul_sloc1_1_0 + 1),a + mov a,(___fsmul_sloc1_1_0 + 3) + mov c,acc.7 + xch a,(___fsmul_sloc1_1_0 + 2) + rlc a + xch a,(___fsmul_sloc1_1_0 + 2) + rlc a + xch a,(___fsmul_sloc1_1_0 + 2) + anl a,#0x01 + mov (___fsmul_sloc1_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + mov a,___fsmul_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 3) + movx @dptr,a +; _fsmul.c 118 + mov dptr,#___fsmul_exp_1_1 + movx a,@dptr + add a,#0xff + mov r2,a + inc dptr + movx a,@dptr + addc a,#0xff + mov r6,a + mov dptr,#___fsmul_exp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a +00106$: +; _fsmul.c 121 + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + mov a,___fsmul_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 1) + movx @dptr,a + mov a,#0x7f + anl a,(___fsmul_sloc1_1_0 + 2) + inc dptr + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 3) + movx @dptr,a +; _fsmul.c 124 + mov dptr,#___fsmul_sign_1_1 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00109$ +00119$: + mov ___fsmul_sloc1_1_0,#0x00 + mov (___fsmul_sloc1_1_0 + 1),#0x00 + mov (___fsmul_sloc1_1_0 + 2),#0x00 + mov (___fsmul_sloc1_1_0 + 3),#0x80 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00109$: + clr a + mov (___fsmul_sloc1_1_0 + 3),a + mov (___fsmul_sloc1_1_0 + 2),a + mov (___fsmul_sloc1_1_0 + 1),a + mov ___fsmul_sloc1_1_0,a +00110$: + mov dptr,#___fsmul_exp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r6,a + mov ___fsmul_sloc0_1_0,r2 + mov (___fsmul_sloc0_1_0 + 1),r6 + mov (___fsmul_sloc0_1_0 + 2),#0x00 + mov (___fsmul_sloc0_1_0 + 3),#0x00 + mov (___fsmul_sloc0_1_0 + 2),___fsmul_sloc0_1_0 + mov a,(___fsmul_sloc0_1_0 + 1) + anl a,#0x01 + mov c,acc.0 + xch a,(___fsmul_sloc0_1_0 + 2) + rrc a + xch a,(___fsmul_sloc0_1_0 + 2) + rrc a + xch a,(___fsmul_sloc0_1_0 + 2) + mov (___fsmul_sloc0_1_0 + 3),a +; Peephole 3.c changed mov to clr + clr a + mov (___fsmul_sloc0_1_0 + 1),a +; Peephole 105 removed redundant mov + mov ___fsmul_sloc0_1_0,a + orl ___fsmul_sloc1_1_0,a + mov a,(___fsmul_sloc0_1_0 + 1) + orl (___fsmul_sloc1_1_0 + 1),a + mov a,(___fsmul_sloc0_1_0 + 2) + orl (___fsmul_sloc1_1_0 + 2),a + mov a,(___fsmul_sloc0_1_0 + 3) + orl (___fsmul_sloc1_1_0 + 3),a + mov dptr,#___fsmul_result_1_1 + movx a,@dptr + mov ___fsmul_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc0_1_0 + 3),a + mov a,___fsmul_sloc0_1_0 + orl ___fsmul_sloc1_1_0,a + mov a,(___fsmul_sloc0_1_0 + 1) + orl (___fsmul_sloc1_1_0 + 1),a + mov a,(___fsmul_sloc0_1_0 + 2) + orl (___fsmul_sloc1_1_0 + 2),a + mov a,(___fsmul_sloc0_1_0 + 3) + orl (___fsmul_sloc1_1_0 + 3),a + mov dptr,#(___fsmul_fl1_1_1) + mov a,___fsmul_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsmul_sloc1_1_0 + 3) + movx @dptr,a +; _fsmul.c 125 + mov dptr,#(___fsmul_fl1_1_1) + movx a,@dptr + mov ___fsmul_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsmul_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov (___fsmul_sloc1_1_0 + 3),a + mov dpl,___fsmul_sloc1_1_0 + mov dph,(___fsmul_sloc1_1_0 + 1) + mov b,(___fsmul_sloc1_1_0 + 2) +00107$: + C$_fsmul.c$126$1$1 ==. + XG$__fsmul$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fsmul.cdb b/device/lib/large/_fsmul.cdb new file mode 100644 index 00000000..1d48b9c1 --- /dev/null +++ b/device/lib/large/_fsmul.cdb @@ -0,0 +1,2 @@ +M:_fsmul +F:G$__fsmul$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fsmul.rel b/device/lib/large/_fsmul.rel new file mode 100644 index 00000000..78f1b3d4 --- /dev/null +++ b/device/lib/large/_fsmul.rel @@ -0,0 +1,1164 @@ +;!FILE _fsmul.asm +XH +H 8 areas 32A global symbols +M _fsmul +S __mulslong_PARM_2 Ref0000 +S __mululong_PARM_2 Ref0000 +S __mulslong Ref0000 +S __mululong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 17 flags 40 +S ___fsmul_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 526 flags 20 +S A$_fsmul$100 Def0020 +S A$_fsmul$200 Def008A +S A$_fsmul$110 Def002C +S A$_fsmul$101 Def0021 +S A$_fsmul$300 Def011E +S A$_fsmul$210 Def0093 +S A$_fsmul$201 Def008B +S A$_fsmul$111 Def002D +S A$_fsmul$102 Def0022 +S A$_fsmul$400 Def01BF +S A$_fsmul$310 Def012F +S A$_fsmul$220 Def00A0 +S A$_fsmul$211 Def0095 +S A$_fsmul$202 Def008C +S A$_fsmul$130 Def0041 +S A$_fsmul$121 Def0036 +S A$_fsmul$112 Def002E +S A$_fsmul$103 Def0023 +S A$_fsmul$500 Def026D +S A$_fsmul$410 Def01CF +S A$_fsmul$401 Def01C1 +S A$_fsmul$320 Def0140 +S A$_fsmul$311 Def0132 +S A$_fsmul$302 Def0120 +S A$_fsmul$230 Def00AC +S A$_fsmul$221 Def00A1 +S A$_fsmul$212 Def0096 +S A$_fsmul$203 Def008D +S A$_fsmul$140 Def004D +S A$_fsmul$131 Def0042 +S A$_fsmul$122 Def0039 +S A$_fsmul$113 Def002F +S A$_fsmul$104 Def0024 +S ___fsmul Def0000 +S A$_fsmul$600 Def032E +S A$_fsmul$510 Def0289 +S A$_fsmul$501 Def0270 +S A$_fsmul$420 Def01E2 +S A$_fsmul$411 Def01D0 +S A$_fsmul$402 Def01C4 +S A$_fsmul$330 Def014D +S A$_fsmul$321 Def0141 +S A$_fsmul$312 Def0135 +S A$_fsmul$303 Def0122 +S A$_fsmul$240 Def00BA +S A$_fsmul$231 Def00AE +S A$_fsmul$222 Def00A2 +S A$_fsmul$213 Def0099 +S A$_fsmul$204 Def008E +S A$_fsmul$150 Def0058 +S A$_fsmul$141 Def004E +S A$_fsmul$132 Def0043 +S A$_fsmul$123 Def003A +S A$_fsmul$114 Def0030 +S A$_fsmul$105 Def0025 +S C$_fsmul.c$126$1$1 Def0525 +S A$_fsmul$700 Def03C5 +S A$_fsmul$610 Def033F +S A$_fsmul$601 Def0331 +S A$_fsmul$520 Def029D +S A$_fsmul$511 Def028C +S A$_fsmul$502 Def0273 +S A$_fsmul$430 Def01F1 +S A$_fsmul$421 Def01E5 +S A$_fsmul$412 Def01D1 +S A$_fsmul$403 Def01C5 +S A$_fsmul$340 Def015E +S A$_fsmul$331 Def014E +S A$_fsmul$322 Def0143 +S A$_fsmul$313 Def0136 +S A$_fsmul$304 Def0123 +S A$_fsmul$250 Def00CB +S A$_fsmul$241 Def00BB +S A$_fsmul$214 Def009A +S A$_fsmul$205 Def008F +S A$_fsmul$160 Def0062 +S A$_fsmul$151 Def0059 +S A$_fsmul$142 Def004F +S A$_fsmul$133 Def0044 +S A$_fsmul$124 Def003B +S A$_fsmul$115 Def0031 +S A$_fsmul$106 Def0026 +S A$_fsmul$800 Def0457 +S A$_fsmul$710 Def03D1 +S A$_fsmul$701 Def03C6 +S A$_fsmul$620 Def0350 +S A$_fsmul$611 Def0340 +S A$_fsmul$602 Def0334 +S A$_fsmul$530 Def02AE +S A$_fsmul$521 Def029E +S A$_fsmul$512 Def028F +S A$_fsmul$503 Def0276 +S A$_fsmul$440 Def020B +S A$_fsmul$431 Def01F3 +S A$_fsmul$422 Def01E7 +S A$_fsmul$413 Def01D3 +S A$_fsmul$404 Def01C7 +S A$_fsmul$350 Def016F +S A$_fsmul$341 Def0161 +S A$_fsmul$332 Def0150 +S A$_fsmul$323 Def0144 +S A$_fsmul$314 Def0137 +S A$_fsmul$305 Def0125 +S A$_fsmul$260 Def00DC +S A$_fsmul$251 Def00CD +S A$_fsmul$242 Def00BD +S A$_fsmul$233 Def00AF +S A$_fsmul$224 Def00A3 +S A$_fsmul$215 Def009B +S A$_fsmul$206 Def0090 +S A$_fsmul$170 Def006D +S A$_fsmul$161 Def0063 +S A$_fsmul$152 Def005A +S A$_fsmul$143 Def0050 +S A$_fsmul$134 Def0047 +S A$_fsmul$125 Def003C +S A$_fsmul$116 Def0032 +S A$_fsmul$107 Def0027 +S A$_fsmul$900 Def04F2 +S A$_fsmul$810 Def0462 +S A$_fsmul$801 Def0458 +S A$_fsmul$720 Def03E0 +S A$_fsmul$711 Def03D4 +S A$_fsmul$702 Def03C7 +S A$_fsmul$630 Def035D +S A$_fsmul$621 Def0351 +S A$_fsmul$612 Def0341 +S A$_fsmul$603 Def0335 +S A$_fsmul$540 Def02BD +S A$_fsmul$531 Def02B0 +S A$_fsmul$522 Def02A0 +S A$_fsmul$513 Def0292 +S A$_fsmul$504 Def0278 +S A$_fsmul$450 Def021B +S A$_fsmul$441 Def020D +S A$_fsmul$432 Def01F4 +S A$_fsmul$423 Def01E8 +S A$_fsmul$414 Def01D6 +S A$_fsmul$405 Def01C8 +S A$_fsmul$360 Def017D +S A$_fsmul$351 Def0170 +S A$_fsmul$342 Def0164 +S A$_fsmul$333 Def0151 +S A$_fsmul$324 Def0145 +S A$_fsmul$315 Def0138 +S A$_fsmul$306 Def0127 +S A$_fsmul$270 Def00EF +S A$_fsmul$261 Def00DE +S A$_fsmul$252 Def00CE +S A$_fsmul$243 Def00BE +S A$_fsmul$234 Def00B2 +S A$_fsmul$225 Def00A4 +S A$_fsmul$216 Def009C +S A$_fsmul$180 Def0077 +S A$_fsmul$171 Def006E +S A$_fsmul$153 Def005B +S A$_fsmul$144 Def0051 +S A$_fsmul$135 Def0048 +S A$_fsmul$126 Def003D +S A$_fsmul$117 Def0033 +S A$_fsmul$108 Def0028 +S A$_fsmul$910 Def0503 +S A$_fsmul$901 Def04F4 +S A$_fsmul$820 Def0472 +S A$_fsmul$811 Def0464 +S A$_fsmul$802 Def0459 +S A$_fsmul$730 Def03EF +S A$_fsmul$721 Def03E1 +S A$_fsmul$712 Def03D5 +S A$_fsmul$703 Def03C9 +S A$_fsmul$640 Def036C +S A$_fsmul$631 Def0360 +S A$_fsmul$622 Def0353 +S A$_fsmul$613 Def0343 +S A$_fsmul$604 Def0337 +S A$_fsmul$550 Def02CA +S A$_fsmul$532 Def02B1 +S A$_fsmul$523 Def02A1 +S A$_fsmul$514 Def0295 +S A$_fsmul$505 Def027B +S A$_fsmul$460 Def0229 +S A$_fsmul$451 Def021C +S A$_fsmul$442 Def0210 +S A$_fsmul$433 Def01F7 +S A$_fsmul$424 Def01E9 +S A$_fsmul$415 Def01D9 +S A$_fsmul$406 Def01C9 +S A$_fsmul$370 Def0191 +S A$_fsmul$361 Def017E +S A$_fsmul$352 Def0172 +S A$_fsmul$343 Def0166 +S A$_fsmul$334 Def0152 +S A$_fsmul$316 Def0139 +S A$_fsmul$307 Def0129 +S A$_fsmul$280 Def00FC +S A$_fsmul$271 Def00F0 +S A$_fsmul$262 Def00E0 +S A$_fsmul$253 Def00D0 +S A$_fsmul$244 Def00BF +S A$_fsmul$235 Def00B3 +S A$_fsmul$226 Def00A5 +S A$_fsmul$217 Def009D +S A$_fsmul$208 Def0091 +S A$_fsmul$190 Def007B +S A$_fsmul$172 Def006F +S A$_fsmul$163 Def0064 +S A$_fsmul$154 Def005C +S A$_fsmul$136 Def0049 +S A$_fsmul$127 Def003E +S A$_fsmul$118 Def0034 +S A$_fsmul$109 Def002B +S A$_fsmul$920 Def0511 +S A$_fsmul$911 Def0505 +S A$_fsmul$902 Def04F6 +S A$_fsmul$821 Def0473 +S A$_fsmul$812 Def0465 +S A$_fsmul$740 Def03F9 +S A$_fsmul$722 Def03E3 +S A$_fsmul$713 Def03D7 +S A$_fsmul$704 Def03CA +S A$_fsmul$650 Def037B +S A$_fsmul$632 Def0361 +S A$_fsmul$623 Def0355 +S A$_fsmul$614 Def0346 +S A$_fsmul$605 Def0338 +S A$_fsmul$560 Def02DF +S A$_fsmul$551 Def02CC +S A$_fsmul$542 Def02BE +S A$_fsmul$533 Def02B2 +S A$_fsmul$524 Def02A2 +S A$_fsmul$515 Def0296 +S A$_fsmul$506 Def027E +S A$_fsmul$470 Def023D +S A$_fsmul$461 Def022A +S A$_fsmul$452 Def021E +S A$_fsmul$443 Def0212 +S A$_fsmul$434 Def01FA +S A$_fsmul$425 Def01EB +S A$_fsmul$416 Def01DB +S A$_fsmul$407 Def01CB +S A$_fsmul$380 Def019F +S A$_fsmul$371 Def0193 +S A$_fsmul$362 Def017F +S A$_fsmul$344 Def0167 +S A$_fsmul$335 Def0154 +S A$_fsmul$326 Def0146 +S A$_fsmul$317 Def013A +S A$_fsmul$308 Def012B +S A$_fsmul$290 Def010A +S A$_fsmul$281 Def00FE +S A$_fsmul$272 Def00F3 +S A$_fsmul$263 Def00E2 +S A$_fsmul$254 Def00D2 +S A$_fsmul$245 Def00C1 +S A$_fsmul$236 Def00B5 +S A$_fsmul$227 Def00A7 +S A$_fsmul$218 Def009E +S A$_fsmul$209 Def0092 +S A$_fsmul$191 Def007D +S A$_fsmul$182 Def0078 +S A$_fsmul$173 Def0070 +S A$_fsmul$155 Def005D +S A$_fsmul$146 Def0052 +S A$_fsmul$137 Def004A +S A$_fsmul$128 Def003F +S A$_fsmul$119 Def0035 +S A$_fsmul$930 Def051F +S A$_fsmul$921 Def0512 +S A$_fsmul$912 Def0506 +S A$_fsmul$903 Def04F8 +S A$_fsmul$840 Def048D +S A$_fsmul$831 Def0480 +S A$_fsmul$822 Def0475 +S A$_fsmul$813 Def0466 +S A$_fsmul$750 Def0406 +S A$_fsmul$732 Def03F0 +S A$_fsmul$723 Def03E6 +S A$_fsmul$714 Def03D8 +S A$_fsmul$705 Def03CB +S A$_fsmul$660 Def038A +S A$_fsmul$651 Def037C +S A$_fsmul$642 Def036D +S A$_fsmul$633 Def0363 +S A$_fsmul$624 Def0356 +S A$_fsmul$615 Def0348 +S A$_fsmul$606 Def0339 +S A$_fsmul$570 Def02EE +S A$_fsmul$561 Def02E0 +S A$_fsmul$552 Def02CD +S A$_fsmul$543 Def02C1 +S A$_fsmul$534 Def02B4 +S A$_fsmul$525 Def02A4 +S A$_fsmul$516 Def0298 +S A$_fsmul$507 Def0281 +S A$_fsmul$480 Def024A +S A$_fsmul$471 Def023E +S A$_fsmul$462 Def022B +S A$_fsmul$444 Def0213 +S A$_fsmul$435 Def01FD +S A$_fsmul$426 Def01EC +S A$_fsmul$417 Def01DD +S A$_fsmul$408 Def01CC +S A$_fsmul$390 Def01AC +S A$_fsmul$372 Def0194 +S A$_fsmul$363 Def0181 +S A$_fsmul$354 Def0173 +S A$_fsmul$345 Def0168 +S A$_fsmul$336 Def0155 +S A$_fsmul$327 Def0149 +S A$_fsmul$318 Def013D +S A$_fsmul$309 Def012D +S A$_fsmul$291 Def010D +S A$_fsmul$282 Def00FF +S A$_fsmul$273 Def00F4 +S A$_fsmul$264 Def00E4 +S A$_fsmul$255 Def00D5 +S A$_fsmul$246 Def00C4 +S A$_fsmul$237 Def00B6 +S A$_fsmul$228 Def00A8 +S A$_fsmul$219 Def009F +S A$_fsmul$192 Def007F +S A$_fsmul$174 Def0071 +S A$_fsmul$165 Def0066 +S A$_fsmul$156 Def005E +S A$_fsmul$147 Def0055 +S A$_fsmul$138 Def004B +S A$_fsmul$129 Def0040 +S A$_fsmul$931 Def0522 +S A$_fsmul$922 Def0514 +S A$_fsmul$913 Def0507 +S A$_fsmul$904 Def04FB +S A$_fsmul$841 Def0490 +S A$_fsmul$832 Def0483 +S A$_fsmul$823 Def0476 +S A$_fsmul$814 Def0468 +S A$_fsmul$805 Def045A +S A$_fsmul$760 Def0416 +S A$_fsmul$751 Def0408 +S A$_fsmul$742 Def03FA +S A$_fsmul$733 Def03F1 +S A$_fsmul$724 Def03E8 +S A$_fsmul$715 Def03D9 +S A$_fsmul$706 Def03CD +S A$_fsmul$670 Def0395 +S A$_fsmul$661 Def038C +S A$_fsmul$652 Def037D +S A$_fsmul$643 Def036F +S A$_fsmul$634 Def0364 +S A$_fsmul$625 Def0357 +S A$_fsmul$616 Def034A +S A$_fsmul$607 Def033B +S A$_fsmul$580 Def0301 +S A$_fsmul$571 Def02F1 +S A$_fsmul$562 Def02E1 +S A$_fsmul$553 Def02CE +S A$_fsmul$544 Def02C2 +S A$_fsmul$535 Def02B6 +S A$_fsmul$526 Def02A7 +S A$_fsmul$517 Def0299 +S A$_fsmul$508 Def0284 +S A$_fsmul$490 Def0260 +S A$_fsmul$481 Def024C +S A$_fsmul$472 Def0240 +S A$_fsmul$463 Def022D +S A$_fsmul$454 Def021F +S A$_fsmul$445 Def0214 +S A$_fsmul$436 Def01FF +S A$_fsmul$427 Def01ED +S A$_fsmul$418 Def01DE +S A$_fsmul$409 Def01CD +S A$_fsmul$391 Def01AE +S A$_fsmul$382 Def01A0 +S A$_fsmul$373 Def0195 +S A$_fsmul$364 Def0182 +S A$_fsmul$355 Def0176 +S A$_fsmul$346 Def016A +S A$_fsmul$337 Def0156 +S A$_fsmul$328 Def014A +S A$_fsmul$319 Def013F +S A$_fsmul$292 Def010F +S A$_fsmul$283 Def0100 +S A$_fsmul$274 Def00F5 +S A$_fsmul$265 Def00E5 +S A$_fsmul$247 Def00C6 +S A$_fsmul$238 Def00B7 +S A$_fsmul$229 Def00AB +S A$_fsmul$193 Def0081 +S A$_fsmul$175 Def0072 +S A$_fsmul$166 Def0069 +S A$_fsmul$157 Def005F +S A$_fsmul$148 Def0056 +S A$_fsmul$139 Def004C +S A$_fsmul$923 Def0515 +S A$_fsmul$914 Def0509 +S A$_fsmul$905 Def04FD +S A$_fsmul$860 Def04AD +S A$_fsmul$851 Def049E +S A$_fsmul$824 Def0478 +S A$_fsmul$815 Def0469 +S A$_fsmul$806 Def045D +S A$_fsmul$770 Def042A +S A$_fsmul$761 Def0418 +S A$_fsmul$752 Def0409 +S A$_fsmul$743 Def03FD +S A$_fsmul$734 Def03F3 +S A$_fsmul$725 Def03EA +S A$_fsmul$716 Def03DB +S A$_fsmul$707 Def03CE +S A$_fsmul$680 Def03A1 +S A$_fsmul$671 Def0397 +S A$_fsmul$662 Def038E +S A$_fsmul$653 Def037F +S A$_fsmul$644 Def0372 +S A$_fsmul$635 Def0365 +S A$_fsmul$626 Def0359 +S A$_fsmul$617 Def034B +S A$_fsmul$608 Def033C +S A$_fsmul$590 Def0312 +S A$_fsmul$581 Def0303 +S A$_fsmul$572 Def02F3 +S A$_fsmul$563 Def02E3 +S A$_fsmul$554 Def02D0 +S A$_fsmul$545 Def02C4 +S A$_fsmul$536 Def02B7 +S A$_fsmul$527 Def02A9 +S A$_fsmul$518 Def029A +S A$_fsmul$509 Def0286 +S A$_fsmul$491 Def0261 +S A$_fsmul$482 Def024F +S A$_fsmul$473 Def0241 +S A$_fsmul$464 Def022E +S A$_fsmul$455 Def0222 +S A$_fsmul$446 Def0216 +S A$_fsmul$437 Def0202 +S A$_fsmul$428 Def01EF +S A$_fsmul$419 Def01E0 +S A$_fsmul$392 Def01AF +S A$_fsmul$383 Def01A3 +S A$_fsmul$374 Def0197 +S A$_fsmul$365 Def0183 +S A$_fsmul$356 Def0177 +S A$_fsmul$347 Def016B +S A$_fsmul$338 Def0158 +S A$_fsmul$329 Def014C +S A$_fsmul$293 Def0111 +S A$_fsmul$284 Def0102 +S A$_fsmul$275 Def00F6 +S A$_fsmul$266 Def00E8 +S A$_fsmul$257 Def00D7 +S A$_fsmul$248 Def00C8 +S A$_fsmul$239 Def00B9 +S A$_fsmul$176 Def0073 +S A$_fsmul$167 Def006A +S A$_fsmul$158 Def0060 +S A$_fsmul$149 Def0057 +S A$_fsmul$924 Def0516 +S A$_fsmul$906 Def04FE +S A$_fsmul$870 Def04C1 +S A$_fsmul$861 Def04B0 +S A$_fsmul$852 Def04A1 +S A$_fsmul$843 Def0493 +S A$_fsmul$834 Def0484 +S A$_fsmul$825 Def047A +S A$_fsmul$816 Def046A +S A$_fsmul$807 Def045E +S A$_fsmul$780 Def043B +S A$_fsmul$771 Def042B +S A$_fsmul$762 Def041A +S A$_fsmul$753 Def040A +S A$_fsmul$744 Def03FE +S A$_fsmul$735 Def03F4 +S A$_fsmul$717 Def03DC +S A$_fsmul$690 Def03AE +S A$_fsmul$681 Def03A2 +S A$_fsmul$672 Def0398 +S A$_fsmul$654 Def0380 +S A$_fsmul$636 Def0367 +S A$_fsmul$627 Def035B +S A$_fsmul$618 Def034D +S A$_fsmul$609 Def033D +S A$_fsmul$591 Def0315 +S A$_fsmul$582 Def0304 +S A$_fsmul$573 Def02F5 +S A$_fsmul$564 Def02E4 +S A$_fsmul$555 Def02D3 +S A$_fsmul$546 Def02C5 +S A$_fsmul$537 Def02B8 +S A$_fsmul$528 Def02AB +S A$_fsmul$519 Def029C +S A$_fsmul$492 Def0262 +S A$_fsmul$483 Def0252 +S A$_fsmul$474 Def0242 +S A$_fsmul$465 Def022F +S A$_fsmul$456 Def0223 +S A$_fsmul$447 Def0217 +S A$_fsmul$438 Def0205 +S A$_fsmul$429 Def01F0 +S A$_fsmul$393 Def01B0 +S A$_fsmul$384 Def01A4 +S A$_fsmul$375 Def0198 +S A$_fsmul$366 Def0185 +S A$_fsmul$357 Def0179 +S A$_fsmul$348 Def016C +S A$_fsmul$339 Def015B +S A$_fsmul$294 Def0113 +S A$_fsmul$285 Def0103 +S A$_fsmul$276 Def00F7 +S A$_fsmul$267 Def00EA +S A$_fsmul$258 Def00D9 +S A$_fsmul$249 Def00CA +S A$_fsmul$177 Def0074 +S A$_fsmul$168 Def006B +S A$_fsmul$159 Def0061 +S A$_fsmul$925 Def0518 +S A$_fsmul$916 Def050A +S A$_fsmul$907 Def04FF +S A$_fsmul$880 Def04D0 +S A$_fsmul$862 Def04B3 +S A$_fsmul$853 Def04A2 +S A$_fsmul$826 Def047B +S A$_fsmul$817 Def046C +S A$_fsmul$808 Def0460 +S A$_fsmul$790 Def0449 +S A$_fsmul$781 Def043D +S A$_fsmul$772 Def042D +S A$_fsmul$763 Def041C +S A$_fsmul$754 Def040C +S A$_fsmul$745 Def0400 +S A$_fsmul$727 Def03EB +S A$_fsmul$718 Def03DD +S A$_fsmul$691 Def03B0 +S A$_fsmul$682 Def03A4 +S A$_fsmul$664 Def038F +S A$_fsmul$655 Def0381 +S A$_fsmul$637 Def0368 +S A$_fsmul$628 Def035C +S A$_fsmul$619 Def034F +S A$_fsmul$592 Def0317 +S A$_fsmul$583 Def0305 +S A$_fsmul$574 Def02F6 +S A$_fsmul$565 Def02E5 +S A$_fsmul$556 Def02D6 +S A$_fsmul$547 Def02C6 +S A$_fsmul$538 Def02BA +S A$_fsmul$529 Def02AC +S A$_fsmul$493 Def0264 +S A$_fsmul$484 Def0254 +S A$_fsmul$475 Def0244 +S A$_fsmul$466 Def0231 +S A$_fsmul$457 Def0225 +S A$_fsmul$448 Def0218 +S A$_fsmul$439 Def0208 +S A$_fsmul$394 Def01B2 +S A$_fsmul$385 Def01A6 +S A$_fsmul$376 Def0199 +S A$_fsmul$367 Def0188 +S A$_fsmul$358 Def017A +S A$_fsmul$349 Def016E +S A$_fsmul$295 Def0114 +S A$_fsmul$286 Def0104 +S A$_fsmul$268 Def00EB +S A$_fsmul$259 Def00DA +S A$_fsmul$196 Def0084 +S A$_fsmul$178 Def0075 +S A$_fsmul$169 Def006C +S A$_fsmul$935 Def0525 +S A$_fsmul$926 Def0519 +S A$_fsmul$917 Def050D +S A$_fsmul$908 Def0501 +S A$_fsmul$890 Def04E1 +S A$_fsmul$881 Def04D2 +S A$_fsmul$872 Def04C3 +S A$_fsmul$863 Def04B5 +S A$_fsmul$854 Def04A3 +S A$_fsmul$845 Def0495 +S A$_fsmul$836 Def0485 +S A$_fsmul$827 Def047C +S A$_fsmul$818 Def046F +S A$_fsmul$809 Def0461 +S A$_fsmul$791 Def044A +S A$_fsmul$782 Def043E +S A$_fsmul$773 Def042E +S A$_fsmul$764 Def041E +S A$_fsmul$755 Def040E +S A$_fsmul$746 Def0401 +S A$_fsmul$737 Def03F5 +S A$_fsmul$728 Def03EC +S A$_fsmul$719 Def03DF +S A$_fsmul$692 Def03B3 +S A$_fsmul$683 Def03A5 +S A$_fsmul$674 Def0399 +S A$_fsmul$665 Def0390 +S A$_fsmul$656 Def0383 +S A$_fsmul$647 Def0375 +S A$_fsmul$638 Def0369 +S A$_fsmul$593 Def031A +S A$_fsmul$584 Def0307 +S A$_fsmul$575 Def02F8 +S A$_fsmul$566 Def02E7 +S A$_fsmul$557 Def02D9 +S A$_fsmul$548 Def02C8 +S A$_fsmul$539 Def02BC +S A$_fsmul$494 Def0265 +S A$_fsmul$485 Def0256 +S A$_fsmul$476 Def0245 +S A$_fsmul$467 Def0234 +S A$_fsmul$458 Def0226 +S A$_fsmul$449 Def021A +S A$_fsmul$395 Def01B5 +S A$_fsmul$386 Def01A7 +S A$_fsmul$377 Def019B +S A$_fsmul$368 Def018B +S A$_fsmul$359 Def017B +S A$_fsmul$296 Def0116 +S A$_fsmul$287 Def0106 +S A$_fsmul$278 Def00F8 +S A$_fsmul$269 Def00ED +S A$_fsmul$197 Def0087 +S A$_fsmul$179 Def0076 +S XG$__fsmul$0$0 Def0525 +S A$_fsmul$918 Def050E +S A$_fsmul$909 Def0502 +S A$_fsmul$891 Def04E2 +S A$_fsmul$882 Def04D4 +S A$_fsmul$873 Def04C4 +S A$_fsmul$864 Def04B7 +S A$_fsmul$855 Def04A4 +S A$_fsmul$846 Def0496 +S A$_fsmul$828 Def047D +S A$_fsmul$819 Def0471 +S A$_fsmul$792 Def044C +S A$_fsmul$783 Def043F +S A$_fsmul$774 Def0430 +S A$_fsmul$765 Def0420 +S A$_fsmul$756 Def0410 +S A$_fsmul$747 Def0402 +S A$_fsmul$738 Def03F6 +S A$_fsmul$729 Def03EE +S A$_fsmul$693 Def03B6 +S A$_fsmul$684 Def03A6 +S A$_fsmul$675 Def039A +S A$_fsmul$666 Def0392 +S A$_fsmul$657 Def0384 +S A$_fsmul$648 Def0378 +S A$_fsmul$639 Def036B +S A$_fsmul$594 Def031D +S A$_fsmul$585 Def0308 +S A$_fsmul$576 Def02FA +S A$_fsmul$567 Def02E8 +S A$_fsmul$558 Def02DC +S A$_fsmul$549 Def02C9 +S A$_fsmul$495 Def0266 +S A$_fsmul$486 Def0257 +S A$_fsmul$477 Def0246 +S A$_fsmul$468 Def0237 +S A$_fsmul$459 Def0227 +S A$_fsmul$396 Def01B8 +S A$_fsmul$387 Def01A8 +S A$_fsmul$378 Def019C +S A$_fsmul$369 Def018E +S A$_fsmul$297 Def0117 +S A$_fsmul$288 Def0107 +S A$_fsmul$279 Def00FB +S A$_fsmul$198 Def0088 +S A$_fsmul$189 Def007A +S A$_fsmul$928 Def051A +S A$_fsmul$919 Def0510 +S A$_fsmul$892 Def04E4 +S A$_fsmul$883 Def04D6 +S A$_fsmul$865 Def04B9 +S A$_fsmul$856 Def04A5 +S A$_fsmul$847 Def0498 +S A$_fsmul$838 Def0487 +S A$_fsmul$829 Def047F +S A$_fsmul$793 Def044D +S A$_fsmul$784 Def0441 +S A$_fsmul$775 Def0432 +S A$_fsmul$766 Def0422 +S A$_fsmul$757 Def0412 +S A$_fsmul$748 Def0404 +S A$_fsmul$739 Def03F8 +S A$_fsmul$694 Def03B9 +S A$_fsmul$685 Def03A8 +S A$_fsmul$676 Def039C +S A$_fsmul$667 Def0393 +S A$_fsmul$658 Def0385 +S A$_fsmul$649 Def0379 +S A$_fsmul$595 Def0320 +S A$_fsmul$586 Def0309 +S A$_fsmul$577 Def02FD +S A$_fsmul$568 Def02E9 +S A$_fsmul$559 Def02DD +S A$_fsmul$496 Def0268 +S A$_fsmul$487 Def0259 +S A$_fsmul$478 Def0248 +S A$_fsmul$469 Def023A +S A$_fsmul$397 Def01BA +S A$_fsmul$388 Def01AA +S A$_fsmul$379 Def019D +S A$_fsmul$298 Def0119 +S A$_fsmul$289 Def0108 +S A$_fsmul$199 Def0089 +S A$_fsmul$929 Def051C +S A$_fsmul$893 Def04E5 +S A$_fsmul$884 Def04D9 +S A$_fsmul$875 Def04C6 +S A$_fsmul$866 Def04BB +S A$_fsmul$857 Def04A6 +S A$_fsmul$848 Def049A +S A$_fsmul$839 Def048A +S A$_fsmul$794 Def044E +S A$_fsmul$785 Def0442 +S A$_fsmul$776 Def0434 +S A$_fsmul$767 Def0424 +S A$_fsmul$758 Def0413 +S A$_fsmul$749 Def0405 +S A$_fsmul$695 Def03BC +S A$_fsmul$686 Def03A9 +S A$_fsmul$677 Def039D +S A$_fsmul$659 Def0387 +S A$_fsmul$596 Def0323 +S A$_fsmul$587 Def030B +S A$_fsmul$578 Def02FF +S A$_fsmul$569 Def02EB +S A$_fsmul$497 Def0269 +S A$_fsmul$488 Def025B +S A$_fsmul$479 Def0249 +S A$_fsmul$398 Def01BC +S A$_fsmul$389 Def01AB +S A$_fsmul$299 Def011B +S A$_fsmul$894 Def04E6 +S A$_fsmul$885 Def04DA +S A$_fsmul$876 Def04C8 +S A$_fsmul$867 Def04BC +S A$_fsmul$858 Def04A8 +S A$_fsmul$849 Def049C +S A$_fsmul$795 Def044F +S A$_fsmul$786 Def0443 +S A$_fsmul$777 Def0437 +S A$_fsmul$768 Def0426 +S A$_fsmul$759 Def0415 +S A$_fsmul$696 Def03BF +S A$_fsmul$687 Def03AA +S A$_fsmul$669 Def0394 +S A$_fsmul$597 Def0325 +S A$_fsmul$588 Def030C +S A$_fsmul$579 Def0300 +S A$_fsmul$498 Def026A +S A$_fsmul$489 Def025E +S A$_fsmul$399 Def01BD +S A$_fsmul$895 Def04E8 +S A$_fsmul$886 Def04DC +S A$_fsmul$877 Def04CA +S A$_fsmul$868 Def04BE +S A$_fsmul$859 Def04AA +S A$_fsmul$796 Def0451 +S A$_fsmul$787 Def0445 +S A$_fsmul$778 Def0439 +S A$_fsmul$769 Def0428 +S A$_fsmul$697 Def03C1 +S A$_fsmul$688 Def03AC +S A$_fsmul$679 Def039E +S A$_fsmul$598 Def0328 +S A$_fsmul$589 Def030F +S A$_fsmul$499 Def026C +S A$_fsmul$896 Def04EA +S A$_fsmul$887 Def04DD +S A$_fsmul$878 Def04CC +S A$_fsmul$869 Def04BF +S A$_fsmul$797 Def0452 +S A$_fsmul$779 Def043A +S A$_fsmul$698 Def03C2 +S A$_fsmul$689 Def03AD +S A$_fsmul$599 Def032B +S A$_fsmul$897 Def04EC +S A$_fsmul$888 Def04DE +S A$_fsmul$879 Def04CE +S A$_fsmul$798 Def0455 +S A$_fsmul$789 Def0446 +S A$_fsmul$699 Def03C3 +S A$_fsmul$80 Def0002 +S A$_fsmul$898 Def04EE +S A$_fsmul$889 Def04E0 +S A$_fsmul$799 Def0456 +S A$_fsmul$90 Def0014 +S A$_fsmul$81 Def0004 +S G$__fsmul$0$0 Def0000 +S A$_fsmul$899 Def04F0 +S A$_fsmul$91 Def0015 +S A$_fsmul$82 Def0006 +S A$_fsmul$92 Def0016 +S A$_fsmul$83 Def0008 +S A$_fsmul$93 Def0018 +S A$_fsmul$84 Def000B +S A$_fsmul$94 Def0019 +S A$_fsmul$85 Def000D +S A$_fsmul$86 Def000E +S A$_fsmul$96 Def001A +S A$_fsmul$87 Def0010 +S A$_fsmul$97 Def001D +S A$_fsmul$88 Def0011 +S A$_fsmul$79 Def0000 +S A$_fsmul$98 Def001E +S A$_fsmul$89 Def0012 +S A$_fsmul$99 Def001F +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 10 +R 00 00 00 05 +T 00 10 +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 16 +R 00 00 00 05 +T 00 16 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 08 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 45 00 0C EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 53 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 61 4B 4C 4D 60 14 +R 00 00 00 07 +T 00 66 +R 00 00 00 07 +T 00 66 90 00 0C E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 74 EA 4B 4C 4D 70 0A +R 00 00 00 07 +T 00 7A +R 00 00 00 07 +T 00 7A +R 00 00 00 07 +T 00 7A E4 F5 82 F5 83 F5 F0 02 05 25 +R 00 00 00 07 00 0A 00 07 +T 00 84 +R 00 00 00 07 +T 00 84 90 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 92 23 54 01 FA 90 00 0C E0 FE A3 E0 FF A3 E0 +R 00 00 00 07 00 07 00 05 +T 00 A0 F8 A3 E0 F9 23 54 01 FE 90 00 16 EE 65 02 +R 00 00 00 07 00 0B 00 05 +T 00 AE F0 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 +R 00 00 00 07 00 04 00 05 29 08 00 01 29 0D 00 01 +T 00 BA E0 F5 00 02 A3 E0 F5 00 03 85 00 02 +R 00 00 00 07 29 04 00 01 29 09 00 01 29 0C 00 01 +T 00 C3 00 00 E5 00 03 A2 E7 C5 00 00 33 C5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 00 CC 00 00 33 C5 00 00 54 01 30 E0 02 44 FE +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 00 D7 +R 00 00 00 07 +T 00 D7 F5 00 01 33 95 E0 F5 00 02 F5 00 03 AA +R 00 00 00 07 29 03 00 01 29 09 00 01 29 0C 00 01 +T 00 E1 00 00 AE 00 01 EA 75 F0 00 24 82 FA E5 F0 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 ED 34 FF FE 90 00 14 EA F0 A3 EE F0 90 00 0C +R 00 00 00 07 00 06 00 05 00 0E 00 05 +T 00 FB E0 F5 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 +R 00 00 00 07 29 04 00 01 29 09 00 01 29 0E 00 01 +T 01 06 A3 E0 F5 00 03 85 00 02 00 00 E5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0A 00 01 +T 01 0E 00 03 A2 E7 C5 00 00 33 C5 00 00 33 C5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 01 18 00 00 54 01 30 E0 02 44 FE +R 00 00 00 07 29 02 00 01 +T 01 20 +R 00 00 00 07 +T 01 20 F5 00 01 33 95 E0 F5 00 02 F5 00 03 AA +R 00 00 00 07 29 03 00 01 29 09 00 01 29 0C 00 01 +T 01 2A 00 00 AE 00 01 8A 00 00 75 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 30 00 01 00 90 00 14 E0 FA A3 E0 FE 90 00 14 +R 00 00 00 07 29 02 00 01 00 06 00 05 00 0E 00 05 +T 01 3D E5 00 00 2A F0 E5 00 01 3E A3 F0 90 00 08 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0E 00 05 +T 01 49 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 +R 00 00 00 07 29 04 00 01 29 09 00 01 29 0E 00 01 +T 01 54 A3 E0 F5 00 03 53 00 02 7F 75 00 03 00 43 +R 00 00 00 07 29 05 00 01 09 08 00 01 29 0C 00 01 +T 01 5F 00 02 80 90 00 08 E5 00 00 F0 A3 E5 +R 00 00 00 07 09 02 00 01 00 06 00 05 29 09 00 01 +T 01 69 00 01 F0 A3 E5 00 02 F0 A3 E5 00 03 F0 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 01 74 00 0C E0 F5 00 00 A3 E0 F5 00 01 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 01 80 00 02 A3 E0 F5 00 03 53 00 02 7F 75 +R 00 00 00 07 29 02 00 01 29 07 00 01 09 0A 00 01 +T 01 89 00 03 00 43 00 02 80 90 00 0C E5 +R 00 00 00 07 29 02 00 01 09 06 00 01 00 0A 00 05 +T 01 92 00 00 F0 A3 E5 00 01 F0 A3 E5 00 02 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 01 9D E5 00 03 F0 90 00 08 E0 F5 00 00 A3 E0 F5 +R 00 00 00 07 29 03 00 01 00 07 00 05 29 0B 00 01 +T 01 A9 00 01 A3 E0 F5 00 02 A3 E0 F5 00 03 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 01 B3 00 01 00 00 85 00 02 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 01 B7 00 01 E5 00 03 F5 00 02 33 95 E0 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 C0 00 03 90 00 0C E0 F5 00 04 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 09 00 01 +T 01 CA 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 01 D4 00 05 00 04 85 00 06 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 01 D8 00 05 E5 00 07 F5 00 06 33 95 E0 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 E1 00 07 90 00 00 E5 00 04 F0 A3 E5 +R 00 00 00 07 29 02 00 01 02 05 00 00 29 08 00 01 +T 01 EA 00 05 F0 A3 E5 00 06 F0 A3 E5 00 07 F0 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 01 F5 00 00 82 85 00 01 83 85 00 02 F0 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 01 FE 00 03 12 00 00 85 82 00 04 85 83 +R 00 00 00 07 29 02 00 01 02 05 00 02 29 09 00 01 +T 02 07 00 05 85 F0 00 06 F5 00 07 90 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 02 0E 00 10 E5 00 04 F0 A3 E5 00 05 F0 A3 E5 +R 00 00 00 07 00 02 00 05 29 05 00 01 29 0A 00 01 +T 02 19 00 06 F0 A3 E5 00 07 F0 90 00 08 E0 F5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0B 00 05 +T 02 24 00 04 A3 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 2F F5 00 07 75 00 05 00 75 00 06 00 75 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 0A 00 01 +T 02 38 00 07 00 90 00 0C E0 F5 00 00 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 06 00 05 29 0A 00 01 +T 02 43 00 01 A3 E0 F5 00 02 A3 E0 F5 00 03 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 4D 00 01 00 00 85 00 02 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 02 51 00 01 E5 00 03 F5 00 02 33 95 E0 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 5A 00 03 90 00 00 E5 00 00 F0 A3 E5 +R 00 00 00 07 29 02 00 01 02 05 00 01 29 08 00 01 +T 02 63 00 01 F0 A3 E5 00 02 F0 A3 E5 00 03 F0 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 6E 00 04 82 85 00 05 83 85 00 06 F0 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 02 77 00 07 12 00 00 85 82 00 04 85 83 +R 00 00 00 07 29 02 00 01 02 05 00 03 29 09 00 01 +T 02 80 00 05 85 F0 00 06 F5 00 07 85 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 02 87 00 05 00 04 85 00 06 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 02 8B 00 05 85 00 07 00 06 75 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 02 90 00 07 00 90 00 10 E0 F5 00 00 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 06 00 05 29 0A 00 01 +T 02 9B 00 01 A3 E0 F5 00 02 A3 E0 F5 00 03 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 A5 00 10 E5 00 04 25 00 00 F0 E5 +R 00 00 00 07 00 02 00 05 29 05 00 01 29 08 00 01 +T 02 AD 00 05 35 00 01 A3 F0 E5 00 06 35 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 02 B5 00 02 A3 F0 E5 00 07 35 00 03 A3 F0 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 02 BF 00 0C E0 F5 00 04 A3 E0 F5 00 05 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 02 CB 00 06 A3 E0 F5 00 07 75 00 05 00 75 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 02 D4 00 06 00 75 00 07 00 90 00 08 E0 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 00 0A 00 05 +T 02 DE 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 E9 F5 00 03 85 00 01 00 00 85 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 08 00 01 +T 02 EF 00 02 00 01 E5 00 03 F5 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 02 F4 00 02 33 95 E0 F5 00 03 90 00 00 E5 +R 00 00 00 07 29 02 00 01 29 08 00 01 02 0B 00 01 +T 02 FE 00 00 F0 A3 E5 00 01 F0 A3 E5 00 02 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 09 E5 00 03 F0 85 00 04 82 85 00 05 83 85 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 03 13 00 06 F0 E5 00 07 12 00 00 85 82 +R 00 00 00 07 29 02 00 01 29 06 00 01 02 09 00 03 +T 03 1C 00 04 85 83 00 05 85 F0 00 06 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 03 24 00 07 85 00 05 00 04 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 03 29 00 06 00 05 85 00 07 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 03 2D 00 06 75 00 07 00 90 00 10 E0 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 00 09 00 05 +T 03 36 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 41 F5 00 03 90 00 10 E5 00 04 25 +R 00 00 00 07 29 03 00 01 00 06 00 05 29 09 00 01 +T 03 49 00 00 F0 E5 00 05 35 00 01 A3 F0 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 03 52 00 06 35 00 02 A3 F0 E5 00 07 35 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 03 5A 00 03 A3 F0 90 00 10 E0 F5 00 04 A3 E0 F5 +R 00 00 00 07 29 02 00 01 00 07 00 05 29 0B 00 01 +T 03 66 00 05 A3 E0 F5 00 06 A3 E0 F5 00 07 20 E7 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 71 03 02 03 D1 +R 00 00 00 07 00 04 00 07 +T 03 75 +R 00 00 00 07 +T 03 75 90 00 10 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 03 81 F5 00 06 A3 E0 F5 00 07 90 00 10 74 80 25 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 03 8D 00 04 F0 E4 35 00 05 A3 F0 E4 35 00 06 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 03 98 F0 E4 35 00 07 A3 F0 90 00 10 E0 F5 00 04 +R 00 00 00 07 29 05 00 01 00 0A 00 05 29 0E 00 01 +T 03 A4 A3 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 F5 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 03 AF 00 07 85 00 05 00 04 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 03 B4 00 06 00 05 85 00 07 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 03 B8 00 06 75 00 07 00 90 00 10 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 00 09 00 05 +T 03 C0 00 04 F0 A3 E5 00 05 F0 A3 E5 00 06 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 CB E5 00 07 F0 02 04 5A +R 00 00 00 07 29 03 00 01 00 07 00 07 +T 03 D1 +R 00 00 00 07 +T 03 D1 90 00 10 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 03 DD F5 00 06 A3 E0 F5 00 07 90 00 10 74 40 25 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 03 E9 00 04 F0 E4 35 00 05 A3 F0 E4 35 00 06 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 03 F4 F0 E4 35 00 07 A3 F0 90 00 10 E0 F5 00 04 +R 00 00 00 07 29 05 00 01 00 0A 00 05 29 0E 00 01 +T 04 00 A3 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 F5 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 04 0B 00 07 E5 00 05 A2 E7 C5 00 04 33 C5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 04 14 00 04 33 C5 00 04 54 01 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0B 00 01 +T 04 1D 00 06 25 E0 45 00 05 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 04 25 00 07 A2 E7 C5 00 06 33 C5 00 06 33 C5 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 04 2F 00 06 54 01 F5 00 07 90 00 10 E5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0A 00 05 +T 04 38 00 04 F0 A3 E5 00 05 F0 A3 E5 00 06 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 04 43 E5 00 07 F0 90 00 14 E0 24 FF FA A3 E0 34 +R 00 00 00 07 29 03 00 01 00 07 00 05 +T 04 50 FF FE 90 00 14 EA F0 A3 EE F0 +R 00 00 00 07 00 05 00 05 +T 04 5A +R 00 00 00 07 +T 04 5A 90 00 10 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 04 66 F5 00 06 A3 E0 F5 00 07 90 00 10 E5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 04 70 00 04 F0 A3 E5 00 05 F0 74 7F 55 00 06 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 04 7B F0 A3 E5 00 07 F0 90 00 16 E0 FA 60 0E +R 00 00 00 07 29 05 00 01 00 09 00 05 +T 04 87 +R 00 00 00 07 +T 04 87 75 00 04 00 75 00 05 00 75 00 06 00 75 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 04 91 00 07 80 80 09 +R 00 00 00 07 29 02 00 01 +T 04 95 +R 00 00 00 07 +T 04 95 E4 F5 00 07 F5 00 06 F5 00 05 F5 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 04 9D 00 04 +R 00 00 00 07 29 02 00 01 +T 04 9E +R 00 00 00 07 +T 04 9E 90 00 14 E0 FA A3 E0 FE 8A 00 00 8E 00 01 +R 00 00 00 07 00 03 00 05 29 0B 00 01 29 0E 00 01 +T 04 AA 75 00 02 00 75 00 03 00 85 00 00 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 04 B2 00 02 E5 00 01 54 01 A2 E0 C5 00 02 13 C5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0C 00 01 +T 04 BD 00 02 13 C5 00 02 F5 00 03 E4 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 04 C5 00 01 F5 00 00 42 00 04 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 CB 00 01 42 00 05 E5 00 02 42 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 D1 00 06 E5 00 03 42 00 07 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 D7 00 10 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 04 E3 00 02 A3 E0 F5 00 03 E5 00 00 42 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 04 EB 00 04 E5 00 01 42 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 F1 00 02 42 00 06 E5 00 03 42 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 F7 00 07 90 00 08 E5 00 04 F0 A3 E5 +R 00 00 00 07 29 02 00 01 00 05 00 05 29 08 00 01 +T 05 00 00 05 F0 A3 E5 00 06 F0 A3 E5 00 07 F0 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 05 0B 00 08 E0 F5 00 04 A3 E0 F5 00 05 A3 E0 F5 +R 00 00 00 07 00 02 00 05 29 06 00 01 29 0B 00 01 +T 05 17 00 06 A3 E0 F5 00 07 85 00 04 82 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 05 20 00 05 83 85 00 06 F0 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 05 25 +R 00 00 00 07 +T 05 25 22 +R 00 00 00 07 diff --git a/device/lib/large/_fsneq.asm b/device/lib/large/_fsneq.asm new file mode 100644 index 00000000..d7faf541 --- /dev/null +++ b/device/lib/large/_fsneq.asm @@ -0,0 +1,282 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + +;-------------------------------------------------------- + .module _fsneq +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsneq_PARM_2 + .globl ___fsneq +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsneq_sloc0_1_0: + .ds 0x0004 +___fsneq_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fsneq_PARM_2: + .ds 0x0004 +___fsneq_a1_1_1: + .ds 0x0004 +___fsneq_fl1_1_1: + .ds 0x0004 +___fsneq_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsneq$0$0 ==. +; _fsneq.c 73 +; ----------------------------------------- +; function __fsneq +; ----------------------------------------- +___fsneq: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsneq.c 87 + push acc + push b + push dph + push dpl + mov dptr,#___fsneq_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fsneq.c 77 + mov dptr,#___fsneq_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsneq_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsneq.c 78 + mov dptr,#___fsneq_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fsneq_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fsneq.c 80 + mov dptr,#(___fsneq_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00111$ + ljmp 00102$ +00111$: + mov dptr,#(___fsneq_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r0,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a + jnz 00112$ + ljmp 00102$ +00112$: +; _fsneq.c 82 + mov dptr,#(___fsneq_fl1_1_1) + movx a,@dptr + mov ___fsneq_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 3),a + xrl (___fsneq_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fsneq_fl1_1_1) + mov a,___fsneq_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsneq_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsneq_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsneq_sloc0_1_0 + 3) + movx @dptr,a +; _fsneq.c 83 + mov dptr,#(___fsneq_fl2_1_1) + movx a,@dptr + mov ___fsneq_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 3),a + xrl (___fsneq_sloc0_1_0 + 3),#0x80 + mov dptr,#(___fsneq_fl2_1_1) + mov a,___fsneq_sloc0_1_0 + movx @dptr,a + inc dptr + mov a,(___fsneq_sloc0_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(___fsneq_sloc0_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(___fsneq_sloc0_1_0 + 3) + movx @dptr,a +00102$: +; _fsneq.c 85 + mov dptr,#(___fsneq_fl1_1_1) + movx a,@dptr + mov ___fsneq_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc0_1_0 + 3),a + mov dptr,#(___fsneq_fl2_1_1) + movx a,@dptr + mov ___fsneq_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (___fsneq_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc1_1_0 + 2),a + inc dptr + movx a,@dptr + mov (___fsneq_sloc1_1_0 + 3),a + mov a,___fsneq_sloc0_1_0 +; Peephole 132 changed ljmp to sjmp +; Peephole 193 optimized misc jump sequence + cjne a,___fsneq_sloc1_1_0,00105$ + mov a,(___fsneq_sloc0_1_0 + 1) + cjne a,(___fsneq_sloc1_1_0 + 1),00105$ + mov a,(___fsneq_sloc0_1_0 + 2) + cjne a,(___fsneq_sloc1_1_0 + 2),00105$ + mov a,(___fsneq_sloc0_1_0 + 3) + cjne a,(___fsneq_sloc1_1_0 + 3),00105$ +; Peephole 201 removed redundant sjmp +00113$: +00114$: +; _fsneq.c 86 + mov dpl,#0x00 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fsneq.c 87 + mov dpl,#0x01 +00106$: + C$_fsneq.c$88$1$1 ==. + XG$__fsneq$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fsneq.cdb b/device/lib/large/_fsneq.cdb new file mode 100644 index 00000000..b9f0060d --- /dev/null +++ b/device/lib/large/_fsneq.cdb @@ -0,0 +1,2 @@ +M:_fsneq +F:G$__fsneq$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fsneq.rel b/device/lib/large/_fsneq.rel new file mode 100644 index 00000000..1547acb8 --- /dev/null +++ b/device/lib/large/_fsneq.rel @@ -0,0 +1,295 @@ +;!FILE _fsneq.asm +XH +H 8 areas BD global symbols +M _fsneq +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 10 flags 40 +S ___fsneq_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 10F flags 20 +S A$_fsneq$281 Def010E +S A$_fsneq$272 Def0106 +S A$_fsneq$263 Def00F9 +S A$_fsneq$254 Def00EC +S A$_fsneq$245 Def00DE +S A$_fsneq$236 Def00D2 +S A$_fsneq$227 Def00C7 +S A$_fsneq$218 Def00B7 +S A$_fsneq$209 Def00AB +S A$_fsneq$191 Def008F +S A$_fsneq$182 Def0083 +S A$_fsneq$173 Def0077 +S A$_fsneq$164 Def006F +S A$_fsneq$146 Def005A +S A$_fsneq$137 Def0050 +S A$_fsneq$128 Def0047 +S A$_fsneq$119 Def003C +S A$_fsneq$264 Def00FC +S A$_fsneq$255 Def00EE +S A$_fsneq$246 Def00E0 +S A$_fsneq$237 Def00D4 +S A$_fsneq$228 Def00C9 +S A$_fsneq$219 Def00B9 +S A$_fsneq$192 Def0090 +S A$_fsneq$183 Def0084 +S A$_fsneq$174 Def0078 +S A$_fsneq$165 Def0070 +S A$_fsneq$156 Def0063 +S A$_fsneq$147 Def005B +S A$_fsneq$138 Def0051 +S A$_fsneq$129 Def0048 +S A$_fsneq$274 Def0109 +S A$_fsneq$265 Def00FE +S A$_fsneq$256 Def00EF +S A$_fsneq$247 Def00E3 +S A$_fsneq$238 Def00D5 +S A$_fsneq$229 Def00CA +S A$_fsneq$193 Def0092 +S A$_fsneq$184 Def0086 +S A$_fsneq$166 Def0071 +S A$_fsneq$157 Def0064 +S A$_fsneq$148 Def005C +S A$_fsneq$266 Def0101 +S A$_fsneq$257 Def00F0 +S A$_fsneq$248 Def00E4 +S A$_fsneq$239 Def00D6 +S A$_fsneq$194 Def0095 +S A$_fsneq$185 Def0087 +S A$_fsneq$176 Def007A +S A$_fsneq$167 Def0072 +S A$_fsneq$158 Def0066 +S A$_fsneq$149 Def005D +S A$_fsneq$267 Def0103 +S A$_fsneq$258 Def00F2 +S A$_fsneq$249 Def00E6 +S A$_fsneq$195 Def0098 +S A$_fsneq$186 Def0088 +S A$_fsneq$177 Def007B +S A$_fsneq$168 Def0073 +S A$_fsneq$277 Def010B +S A$_fsneq$196 Def009A +S A$_fsneq$187 Def008A +S A$_fsneq$178 Def007D +S A$_fsneq$169 Def0074 +S A$_fsneq$197 Def009B +S A$_fsneq$188 Def008B +S XG$__fsneq$0$0 Def010E +S A$_fsneq$198 Def009C +S A$_fsneq$189 Def008C +S A$_fsneq$199 Def009E +S A$_fsneq$80 Def000E +S A$_fsneq$90 Def001A +S A$_fsneq$81 Def0010 +S G$__fsneq$0$0 Def0000 +S A$_fsneq$91 Def001D +S A$_fsneq$82 Def0011 +S A$_fsneq$73 Def0000 +S A$_fsneq$92 Def001E +S A$_fsneq$83 Def0012 +S A$_fsneq$74 Def0002 +S A$_fsneq$93 Def001F +S A$_fsneq$84 Def0014 +S A$_fsneq$75 Def0004 +S A$_fsneq$94 Def0020 +S A$_fsneq$85 Def0015 +S A$_fsneq$76 Def0006 +S C$_fsneq.c$88$1$1 Def010E +S A$_fsneq$95 Def0021 +S A$_fsneq$86 Def0016 +S A$_fsneq$77 Def0008 +S A$_fsneq$96 Def0022 +S A$_fsneq$87 Def0018 +S A$_fsneq$78 Def000B +S A$_fsneq$97 Def0023 +S A$_fsneq$88 Def0019 +S A$_fsneq$79 Def000D +S A$_fsneq$98 Def0024 +S A$_fsneq$99 Def0025 +S A$_fsneq$100 Def0026 +S A$_fsneq$200 Def009F +S A$_fsneq$110 Def0032 +S A$_fsneq$101 Def0027 +S A$_fsneq$210 Def00AD +S A$_fsneq$201 Def00A0 +S A$_fsneq$120 Def003D +S A$_fsneq$111 Def0033 +S A$_fsneq$102 Def0028 +S A$_fsneq$220 Def00BC +S A$_fsneq$211 Def00AE +S A$_fsneq$202 Def00A2 +S A$_fsneq$130 Def0049 +S A$_fsneq$121 Def003E +S A$_fsneq$112 Def0034 +S A$_fsneq$103 Def002B +S A$_fsneq$230 Def00CB +S A$_fsneq$221 Def00BF +S A$_fsneq$212 Def00AF +S A$_fsneq$203 Def00A3 +S A$_fsneq$140 Def0052 +S A$_fsneq$131 Def004A +S A$_fsneq$122 Def003F +S A$_fsneq$113 Def0035 +S A$_fsneq$104 Def002C +S ___fsneq Def0000 +S A$_fsneq$240 Def00D8 +S A$_fsneq$231 Def00CD +S A$_fsneq$222 Def00C1 +S A$_fsneq$213 Def00B1 +S A$_fsneq$204 Def00A4 +S A$_fsneq$150 Def005E +S A$_fsneq$141 Def0055 +S A$_fsneq$132 Def004B +S A$_fsneq$123 Def0040 +S A$_fsneq$105 Def002D +S A$_fsneq$250 Def00E7 +S A$_fsneq$241 Def00D9 +S A$_fsneq$223 Def00C2 +S A$_fsneq$214 Def00B2 +S A$_fsneq$205 Def00A6 +S A$_fsneq$160 Def0069 +S A$_fsneq$142 Def0056 +S A$_fsneq$133 Def004C +S A$_fsneq$124 Def0041 +S A$_fsneq$115 Def0036 +S A$_fsneq$106 Def002E +S A$_fsneq$251 Def00E8 +S A$_fsneq$242 Def00DA +S A$_fsneq$224 Def00C3 +S A$_fsneq$215 Def00B3 +S A$_fsneq$170 Def0075 +S A$_fsneq$161 Def006C +S A$_fsneq$152 Def005F +S A$_fsneq$143 Def0057 +S A$_fsneq$134 Def004D +S A$_fsneq$125 Def0042 +S A$_fsneq$116 Def0039 +S A$_fsneq$107 Def002F +S A$_fsneq$261 Def00F4 +S A$_fsneq$252 Def00EA +S A$_fsneq$243 Def00DC +S A$_fsneq$234 Def00CE +S A$_fsneq$225 Def00C5 +S A$_fsneq$216 Def00B5 +S A$_fsneq$207 Def00A7 +S A$_fsneq$162 Def006D +S A$_fsneq$153 Def0060 +S A$_fsneq$144 Def0058 +S A$_fsneq$135 Def004E +S A$_fsneq$126 Def0043 +S A$_fsneq$117 Def003A +S A$_fsneq$108 Def0030 +S A$_fsneq$262 Def00F7 +S A$_fsneq$253 Def00EB +S A$_fsneq$244 Def00DD +S A$_fsneq$235 Def00D1 +S A$_fsneq$226 Def00C6 +S A$_fsneq$217 Def00B6 +S A$_fsneq$208 Def00AA +S A$_fsneq$190 Def008E +S A$_fsneq$181 Def0080 +S A$_fsneq$172 Def0076 +S A$_fsneq$163 Def006E +S A$_fsneq$154 Def0061 +S A$_fsneq$145 Def0059 +S A$_fsneq$136 Def004F +S A$_fsneq$127 Def0044 +S A$_fsneq$118 Def003B +S A$_fsneq$109 Def0031 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 08 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 45 00 0C EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 53 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 23 +R 00 00 00 07 00 02 00 05 +T 00 61 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 08 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 90 00 0C E0 FA A3 E0 FE A3 E0 FF A3 E0 F8 +R 00 00 00 07 00 03 00 05 +T 00 77 23 54 01 FA 70 03 02 00 CE +R 00 00 00 07 00 09 00 07 +T 00 80 +R 00 00 00 07 +T 00 80 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 8C F5 00 02 A3 E0 F5 00 03 63 00 03 80 90 +R 00 00 00 07 29 03 00 01 29 08 00 01 09 0B 00 01 +T 00 96 00 08 E5 00 00 F0 A3 E5 00 01 F0 A3 E5 +R 00 00 00 07 00 02 00 05 29 05 00 01 29 0A 00 01 +T 00 A1 00 02 F0 A3 E5 00 03 F0 90 00 0C E0 F5 +R 00 00 00 07 29 02 00 01 29 07 00 01 00 0B 00 05 +T 00 AC 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 B7 F5 00 03 63 00 03 80 90 00 0C E5 +R 00 00 00 07 29 03 00 01 09 06 00 01 00 0A 00 05 +T 00 C0 00 00 F0 A3 E5 00 01 F0 A3 E5 00 02 F0 A3 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 CB E5 00 03 F0 +R 00 00 00 07 29 03 00 01 +T 00 CE +R 00 00 00 07 +T 00 CE 90 00 08 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 DA F5 00 02 A3 E0 F5 00 03 90 00 0C E0 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0B 00 05 +T 00 E5 00 04 A3 E0 F5 00 05 A3 E0 F5 00 06 A3 E0 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 F0 F5 00 07 E5 00 00 B5 00 04 14 E5 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 F8 00 01 B5 00 05 0F E5 00 02 B5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 00 FF 00 06 0A E5 00 03 B5 00 07 05 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 06 +R 00 00 00 07 +T 01 06 +R 00 00 00 07 +T 01 06 75 82 00 80 03 +R 00 00 00 07 +T 01 0B +R 00 00 00 07 +T 01 0B 75 82 01 +R 00 00 00 07 +T 01 0E +R 00 00 00 07 +T 01 0E 22 +R 00 00 00 07 diff --git a/device/lib/large/_fssub.asm b/device/lib/large/_fssub.asm new file mode 100644 index 00000000..b6477bf9 --- /dev/null +++ b/device/lib/large/_fssub.asm @@ -0,0 +1,289 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + +;-------------------------------------------------------- + .module _fssub +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fssub_PARM_2 + .globl ___fssub +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___fssub_PARM_2: + .ds 0x0004 +___fssub_a1_1_1: + .ds 0x0004 +___fssub_fl1_1_1: + .ds 0x0004 +___fssub_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fssub$0$0 ==. +; _fssub.c 81 +; ----------------------------------------- +; function __fssub +; ----------------------------------------- +___fssub: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fssub.c 96 + push acc + push b + push dph + push dpl + mov dptr,#___fssub_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _fssub.c 85 + mov dptr,#___fssub_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fssub_fl1_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fssub.c 86 + mov dptr,#___fssub_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fssub_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fssub.c 89 + mov dptr,#(___fssub_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00109$: +; _fssub.c 90 + mov dptr,#(___fssub_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + ljmp 00105$ +00102$: +; _fssub.c 91 + mov dptr,#(___fssub_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00110$: +; _fssub.c 92 + mov dptr,#(___fssub_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + cpl acc.7 +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + ljmp 00105$ +00104$: +; _fssub.c 95 + mov dptr,#(___fssub_fl2_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + xrl ar5,#0x80 + mov dptr,#(___fssub_fl2_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _fssub.c 96 + mov dptr,#(___fssub_fl1_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(___fssub_fl2_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov dptr,#___fsadd_PARM_2 + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 + lcall ___fsadd + C$_fssub.c$97$1$1 ==. + XG$__fssub$0$0 ==. +; Peephole 156 removed misc moves via dph, dpl, b, a before return +00105$: + ret + .area CSEG (CODE) diff --git a/device/lib/large/_fssub.cdb b/device/lib/large/_fssub.cdb new file mode 100644 index 00000000..43bfd1ea --- /dev/null +++ b/device/lib/large/_fssub.cdb @@ -0,0 +1,2 @@ +M:_fssub +F:G$__fssub$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_fssub.rel b/device/lib/large/_fssub.rel new file mode 100644 index 00000000..aa14dfbf --- /dev/null +++ b/device/lib/large/_fssub.rel @@ -0,0 +1,288 @@ +;!FILE _fssub.asm +XH +H 8 areas CE global symbols +M _fssub +S ___fsadd Ref0000 +S ___fsadd_PARM_2 Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 10 flags 40 +S ___fssub_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size FF flags 20 +S A$_fssub$230 Def00BC +S A$_fssub$221 Def00B1 +S A$_fssub$212 Def00A4 +S A$_fssub$203 Def009B +S A$_fssub$140 Def0058 +S A$_fssub$131 Def004E +S A$_fssub$122 Def0043 +S A$_fssub$113 Def003A +S A$_fssub$104 Def0030 +S ___fssub Def0000 +S A$_fssub$240 Def00C8 +S A$_fssub$231 Def00BF +S A$_fssub$222 Def00B2 +S A$_fssub$213 Def00A6 +S A$_fssub$204 Def009C +S A$_fssub$150 Def0062 +S A$_fssub$141 Def0059 +S A$_fssub$132 Def004F +S A$_fssub$123 Def0044 +S A$_fssub$114 Def003B +S A$_fssub$105 Def0031 +S A$_fssub$250 Def00D3 +S A$_fssub$241 Def00C9 +S A$_fssub$232 Def00C0 +S A$_fssub$223 Def00B3 +S A$_fssub$214 Def00A8 +S A$_fssub$205 Def009D +S A$_fssub$160 Def006C +S A$_fssub$151 Def0063 +S A$_fssub$142 Def005A +S A$_fssub$133 Def0050 +S A$_fssub$124 Def0047 +S A$_fssub$115 Def003C +S A$_fssub$106 Def0032 +S A$_fssub$260 Def00DF +S A$_fssub$251 Def00D4 +S A$_fssub$233 Def00C1 +S A$_fssub$224 Def00B4 +S A$_fssub$170 Def0076 +S A$_fssub$161 Def006D +S A$_fssub$143 Def005B +S A$_fssub$134 Def0051 +S A$_fssub$125 Def0048 +S A$_fssub$116 Def003D +S A$_fssub$107 Def0033 +S A$_fssub$270 Def00EB +S A$_fssub$261 Def00E0 +S A$_fssub$252 Def00D5 +S A$_fssub$243 Def00CA +S A$_fssub$234 Def00C2 +S A$_fssub$225 Def00B5 +S A$_fssub$207 Def009E +S A$_fssub$180 Def0084 +S A$_fssub$171 Def0078 +S A$_fssub$162 Def006E +S A$_fssub$153 Def0064 +S A$_fssub$144 Def005C +S A$_fssub$126 Def0049 +S A$_fssub$117 Def003E +S A$_fssub$108 Def0034 +S A$_fssub$280 Def00F6 +S A$_fssub$271 Def00EC +S A$_fssub$262 Def00E1 +S A$_fssub$253 Def00D6 +S A$_fssub$244 Def00CD +S A$_fssub$235 Def00C3 +S A$_fssub$226 Def00B6 +S A$_fssub$217 Def00AB +S A$_fssub$208 Def009F +S A$_fssub$190 Def008E +S A$_fssub$181 Def0085 +S A$_fssub$172 Def007A +S A$_fssub$163 Def006F +S A$_fssub$145 Def005D +S A$_fssub$136 Def0052 +S A$_fssub$127 Def004A +S A$_fssub$118 Def003F +S A$_fssub$109 Def0035 +S A$_fssub$281 Def00F8 +S A$_fssub$272 Def00ED +S A$_fssub$263 Def00E2 +S A$_fssub$254 Def00D7 +S A$_fssub$245 Def00CE +S A$_fssub$236 Def00C4 +S A$_fssub$227 Def00B7 +S A$_fssub$218 Def00AE +S A$_fssub$182 Def0086 +S A$_fssub$164 Def0070 +S A$_fssub$146 Def005E +S A$_fssub$137 Def0055 +S A$_fssub$128 Def004B +S A$_fssub$119 Def0040 +S A$_fssub$282 Def00FA +S A$_fssub$273 Def00EE +S A$_fssub$264 Def00E3 +S A$_fssub$255 Def00D8 +S A$_fssub$246 Def00CF +S A$_fssub$237 Def00C5 +S A$_fssub$228 Def00B8 +S A$_fssub$219 Def00AF +S A$_fssub$192 Def008F +S A$_fssub$183 Def0087 +S A$_fssub$165 Def0071 +S A$_fssub$156 Def0066 +S A$_fssub$147 Def005F +S A$_fssub$138 Def0056 +S A$_fssub$129 Def004C +S A$_fssub$283 Def00FB +S A$_fssub$274 Def00EF +S A$_fssub$265 Def00E4 +S A$_fssub$256 Def00DB +S A$_fssub$247 Def00D0 +S A$_fssub$238 Def00C6 +S A$_fssub$229 Def00B9 +S A$_fssub$184 Def0088 +S A$_fssub$175 Def007D +S A$_fssub$166 Def0072 +S A$_fssub$157 Def0069 +S A$_fssub$148 Def0060 +S A$_fssub$139 Def0057 +S A$_fssub$275 Def00F0 +S A$_fssub$266 Def00E5 +S A$_fssub$257 Def00DC +S A$_fssub$248 Def00D1 +S A$_fssub$239 Def00C7 +S A$_fssub$185 Def0089 +S A$_fssub$176 Def0080 +S A$_fssub$158 Def006A +S A$_fssub$149 Def0061 +S A$_fssub$276 Def00F1 +S A$_fssub$267 Def00E6 +S A$_fssub$258 Def00DD +S A$_fssub$249 Def00D2 +S A$_fssub$195 Def0091 +S A$_fssub$186 Def008A +S A$_fssub$177 Def0081 +S A$_fssub$168 Def0073 +S A$_fssub$159 Def006B +S A$_fssub$277 Def00F2 +S A$_fssub$268 Def00E9 +S A$_fssub$259 Def00DE +S A$_fssub$196 Def0094 +S A$_fssub$187 Def008B +S A$_fssub$178 Def0082 +S A$_fssub$169 Def0074 +S A$_fssub$278 Def00F3 +S A$_fssub$269 Def00EA +S A$_fssub$197 Def0095 +S A$_fssub$188 Def008C +S A$_fssub$179 Def0083 +S XG$__fssub$0$0 Def00FE +S A$_fssub$288 Def00FE +S A$_fssub$279 Def00F4 +S A$_fssub$198 Def0096 +S A$_fssub$189 Def008D +S A$_fssub$199 Def0097 +S A$_fssub$70 Def0002 +S A$_fssub$80 Def0014 +S A$_fssub$71 Def0004 +S A$_fssub$90 Def0020 +S A$_fssub$81 Def0015 +S A$_fssub$72 Def0006 +S G$__fssub$0$0 Def0000 +S A$_fssub$91 Def0021 +S A$_fssub$82 Def0016 +S A$_fssub$73 Def0008 +S A$_fssub$92 Def0022 +S A$_fssub$83 Def0018 +S A$_fssub$74 Def000B +S A$_fssub$93 Def0023 +S A$_fssub$84 Def0019 +S A$_fssub$75 Def000D +S A$_fssub$94 Def0024 +S A$_fssub$76 Def000E +S C$_fssub.c$97$1$1 Def00FE +S A$_fssub$95 Def0025 +S A$_fssub$86 Def001A +S A$_fssub$77 Def0010 +S A$_fssub$96 Def0026 +S A$_fssub$87 Def001D +S A$_fssub$78 Def0011 +S A$_fssub$69 Def0000 +S A$_fssub$97 Def0027 +S A$_fssub$88 Def001E +S A$_fssub$79 Def0012 +S A$_fssub$98 Def0028 +S A$_fssub$89 Def001F +S A$_fssub$99 Def002B +S A$_fssub$100 Def002C +S A$_fssub$200 Def0098 +S A$_fssub$101 Def002D +S A$_fssub$210 Def00A1 +S A$_fssub$201 Def0099 +S A$_fssub$120 Def0041 +S A$_fssub$111 Def0036 +S A$_fssub$102 Def002E +S A$_fssub$220 Def00B0 +S A$_fssub$211 Def00A2 +S A$_fssub$202 Def009A +S A$_fssub$130 Def004D +S A$_fssub$121 Def0042 +S A$_fssub$112 Def0039 +S A$_fssub$103 Def002F +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 29 00 08 EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 37 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 +R 00 00 00 07 00 02 00 05 +T 00 45 00 0C EA F0 A3 EB F0 A3 EC F0 A3 ED F0 90 +R 00 00 00 07 00 02 00 05 +T 00 53 00 0C E0 FA A3 E0 FB A3 E0 FC A3 E0 FD EA +R 00 00 00 07 00 02 00 05 +T 00 61 4B 4C 4D 70 17 +R 00 00 00 07 +T 00 66 +R 00 00 00 07 +T 00 66 90 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 74 8A 82 8B 83 8C F0 02 00 FE +R 00 00 00 07 00 09 00 07 +T 00 7D +R 00 00 00 07 +T 00 7D 90 00 08 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 8B EA 4B 4C 4D 70 1A +R 00 00 00 07 +T 00 91 +R 00 00 00 07 +T 00 91 90 00 0C E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 9F B2 E7 FD 8A 82 8B 83 8C F0 02 00 FE +R 00 00 00 07 00 0C 00 07 +T 00 AB +R 00 00 00 07 +T 00 AB 90 00 0C E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 B9 63 05 80 90 00 0C EA F0 A3 EB F0 A3 EC F0 +R 00 00 00 07 00 06 00 05 +T 00 C7 A3 ED F0 90 00 08 E0 FA A3 E0 FB A3 E0 FC +R 00 00 00 07 00 06 00 05 +T 00 D5 A3 E0 FD 90 00 0C E0 FE A3 E0 FF A3 E0 F8 +R 00 00 00 07 00 06 00 05 +T 00 E3 A3 E0 F9 90 00 00 EE F0 A3 EF F0 A3 E8 F0 +R 00 00 00 07 02 06 00 01 +T 00 F1 A3 E9 F0 8A 82 8B 83 8C F0 ED 12 00 00 +R 00 00 00 07 02 0D 00 00 +T 00 FE +R 00 00 00 07 +T 00 FE 22 +R 00 00 00 07 diff --git a/device/lib/large/_gptrget.asm b/device/lib/large/_gptrget.asm new file mode 100644 index 00000000..3c3272c6 --- /dev/null +++ b/device/lib/large/_gptrget.asm @@ -0,0 +1,116 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + +;-------------------------------------------------------- + .module _gptrget +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __gptrget +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_gptrget$0$0 ==. +; _gptrget.c 26 +; ----------------------------------------- +; function _gptrget +; ----------------------------------------- +__gptrget: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _gptrget.c 81 + ; save values passed + xch a,r0 + push acc + ; + ; depending on the pointer type + ; + mov a,b + jz 00001$ + dec a + jz 00002$ + dec a + jz 00003$ + dec a + jz 00004$ + ; + ; any other value for type + ; return xFF + mov a,#0xff + sjmp 00005$ + ; + ; Pointer to data space + ; + 00001$: + mov r0,dpl ; use only low order address + mov a,@r0 + sjmp 00005$ + ; + ; pointer to xternal data + ; + 00002$: + movx a,@dptr + sjmp 00005$ +; +; pointer to code area +; + 00003$: + clr a + movc a,@a+dptr + sjmp 00005$ +; +; pointer to xternal stack +; + 00004$: + mov r0,dpl + movx a,@r0 +; +; restore and return +; + 00005$: + mov r0,a + pop acc + xch a,r0 +00101$: + C$_gptrget.c$83$1$1 ==. + XG$_gptrget$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_gptrget.cdb b/device/lib/large/_gptrget.cdb new file mode 100644 index 00000000..1bfacfe1 --- /dev/null +++ b/device/lib/large/_gptrget.cdb @@ -0,0 +1,2 @@ +M:_gptrget +F:G$_gptrget$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/large/_gptrget.rel b/device/lib/large/_gptrget.rel new file mode 100644 index 00000000..dce6cdb4 --- /dev/null +++ b/device/lib/large/_gptrget.rel @@ -0,0 +1,72 @@ +;!FILE _gptrget.asm +XH +H 8 areas 1E global symbols +M _gptrget +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 28 flags 20 +S XG$_gptrget$0$0 Def0027 +S G$_gptrget$0$0 Def0000 +S A$_gptrget$110 Def0024 +S A$_gptrget$111 Def0026 +S A$_gptrget$103 Def0020 +S A$_gptrget$104 Def0022 +S A$_gptrget$115 Def0027 +S A$_gptrget$109 Def0023 +S A$_gptrget$70 Def000A +S A$_gptrget$61 Def0000 +S A$_gptrget$71 Def000B +S A$_gptrget$62 Def0001 +S C$_gptrget.c$83$1$1 Def0027 +S A$_gptrget$90 Def0019 +S A$_gptrget$72 Def000D +S A$_gptrget$91 Def001A +S A$_gptrget$73 Def000E +S A$_gptrget$83 Def0014 +S A$_gptrget$84 Def0016 +S A$_gptrget$66 Def0003 +S A$_gptrget$85 Def0017 +S A$_gptrget$67 Def0005 +S A$_gptrget$77 Def0010 +S A$_gptrget$68 Def0007 +S A$_gptrget$96 Def001C +S A$_gptrget$78 Def0012 +S A$_gptrget$69 Def0008 +S A$_gptrget$97 Def001D +S A$_gptrget$98 Def001E +S __gptrget Def0000 +T 00 00 +R 00 00 00 07 +T 00 00 C8 C0 E0 E5 F0 60 0D 14 60 0F 14 60 0F 14 +R 00 00 00 07 +T 00 0E 60 10 74 FF 80 0F +R 00 00 00 07 +T 00 14 +R 00 00 00 07 +T 00 14 A8 82 E6 80 0A +R 00 00 00 07 +T 00 19 +R 00 00 00 07 +T 00 19 E0 80 07 +R 00 00 00 07 +T 00 1C +R 00 00 00 07 +T 00 1C E4 93 80 03 +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 A8 82 E2 +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 F8 D0 E0 C8 +R 00 00 00 07 +T 00 27 +R 00 00 00 07 +T 00 27 22 +R 00 00 00 07 diff --git a/device/lib/large/_gptrput.asm b/device/lib/large/_gptrput.asm new file mode 100644 index 00000000..ed19a6e7 --- /dev/null +++ b/device/lib/large/_gptrput.asm @@ -0,0 +1,104 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:28 2000 + +;-------------------------------------------------------- + .module _gptrput +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __gptrput +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_gptrput$0$0 ==. +; _gptrput.c 26 +; ----------------------------------------- +; function _gptrput +; ----------------------------------------- +__gptrput: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _gptrput.c 72 + xch a,r0 + push acc + xch a,r0 + push acc + ; + ; depending on the pointer type + ; + mov a,b + jz 00001$ + dec a + jz 00002$ + dec a + jz 00003$ + dec a + jz 00004$ + pop acc + sjmp 00005$ +; +; store into near space +; + 00001$: + pop acc + mov r0,dpl + mov @r0,a + sjmp 00005$ + 00002$: + pop acc + movx @dptr,a + sjmp 00005$ + 00003$: + pop acc ; do nothing + sjmp 00005$ + 00004$: + pop acc + mov r0,dpl + movx @r0,a + 00005$: + xch a,r0 + pop acc + xch a,r0 +00101$: + C$_gptrput.c$73$1$1 ==. + XG$_gptrput$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_gptrput.cdb b/device/lib/large/_gptrput.cdb new file mode 100644 index 00000000..32b5fe30 --- /dev/null +++ b/device/lib/large/_gptrput.cdb @@ -0,0 +1,2 @@ +M:_gptrput +F:G$_gptrput$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/large/_gptrput.rel b/device/lib/large/_gptrput.rel new file mode 100644 index 00000000..d690979e --- /dev/null +++ b/device/lib/large/_gptrput.rel @@ -0,0 +1,76 @@ +;!FILE _gptrput.asm +XH +H 8 areas 22 global symbols +M _gptrput +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 31 flags 20 +S A$_gptrput$60 Def0000 +S A$_gptrput$70 Def000B +S A$_gptrput$61 Def0001 +S C$_gptrput.c$73$1$1 Def0030 +S A$_gptrput$71 Def000D +S A$_gptrput$62 Def0003 +S A$_gptrput$90 Def0023 +S A$_gptrput$81 Def0017 +S A$_gptrput$72 Def000E +S A$_gptrput$63 Def0004 +S A$_gptrput$91 Def0025 +S A$_gptrput$82 Def0019 +S A$_gptrput$73 Def0010 +S A$_gptrput$83 Def001B +S A$_gptrput$74 Def0011 +S A$_gptrput$93 Def0027 +S A$_gptrput$84 Def001C +S A$_gptrput$75 Def0013 +S A$_gptrput$94 Def0029 +S A$_gptrput$76 Def0015 +S A$_gptrput$67 Def0006 +S A$_gptrput$95 Def002B +S A$_gptrput$86 Def001E +S A$_gptrput$68 Def0008 +S A$_gptrput$87 Def0020 +S A$_gptrput$69 Def000A +S A$_gptrput$97 Def002C +S A$_gptrput$88 Def0021 +S A$_gptrput$98 Def002D +S A$_gptrput$99 Def002F +S __gptrput Def0000 +S XG$_gptrput$0$0 Def0030 +S G$_gptrput$0$0 Def0000 +S A$_gptrput$103 Def0030 +T 00 00 +R 00 00 00 07 +T 00 00 C8 C0 E0 C8 C0 E0 E5 F0 60 0D 14 60 11 14 +R 00 00 00 07 +T 00 0E 60 13 14 60 14 D0 E0 80 15 +R 00 00 00 07 +T 00 17 +R 00 00 00 07 +T 00 17 D0 E0 A8 82 F6 80 0E +R 00 00 00 07 +T 00 1E +R 00 00 00 07 +T 00 1E D0 E0 F0 80 09 +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 D0 E0 80 05 +R 00 00 00 07 +T 00 27 +R 00 00 00 07 +T 00 27 D0 E0 A8 82 F2 +R 00 00 00 07 +T 00 2C +R 00 00 00 07 +T 00 2C C8 D0 E0 C8 +R 00 00 00 07 +T 00 30 +R 00 00 00 07 +T 00 30 22 +R 00 00 00 07 diff --git a/device/lib/large/_int2fs.asm b/device/lib/large/_int2fs.asm new file mode 100644 index 00000000..048c5fad --- /dev/null +++ b/device/lib/large/_int2fs.asm @@ -0,0 +1,340 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _int2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___int2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___int2fs_sloc0_1_0: + .ds 0x0002 +___int2fs_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___int2fs_a_1_1: + .ds 0x0002 +___int2fs_sign_1_1: + .ds 0x0004 +___int2fs_fl_1_1: + .ds 0x0004 +___int2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__int2fs$0$0 ==. +; _int2fs.c 80 +; ----------------------------------------- +; function __int2fs +; ----------------------------------------- +___int2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _int2fs.c 110 + push dph + push dpl + mov dptr,#___int2fs_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _int2fs.c 82 + mov dptr,#___int2fs_sign_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _int2fs.c 85 + mov dptr,#___int2fs_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov dptr,#___int2fs_a1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _int2fs.c 87 + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _int2fs.c 89 + mov dptr,#(___int2fs_fl_1_1) +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; _int2fs.c 90 + mov dptr,#(___int2fs_fl_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r6 + mov dph,r7 + mov b,r0 + ljmp 00108$ +00102$: +; _int2fs.c 93 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _int2fs.c 95 + mov dptr,#___int2fs_sign_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x80 + movx @dptr,a +; _int2fs.c 96 + mov dptr,#___int2fs_a1_1_1 + clr c + clr a + subb a,r2 + movx @dptr,a + clr a + subb a,r3 + inc dptr + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a +; _int2fs.c 99 +00113$: + clr a + mov (___int2fs_sloc0_1_0 + 1),a + mov ___int2fs_sloc0_1_0,#0x96 +00105$: + mov dptr,#___int2fs_a1_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r4 + subb a,#0x00 + mov a,r5 + subb a,#0x00 + mov a,r6 + subb a,#0x80 + mov a,r7 + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _int2fs.c 101 + mov a,r4 + add a,acc + mov r0,a + mov a,r5 + rlc a + mov r1,a + mov a,r6 + rlc a + mov r2,a + mov a,r7 + rlc a + mov r3,a + mov dptr,#___int2fs_a1_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _int2fs.c 102 + dec ___int2fs_sloc0_1_0 + mov a,#0xff + cjne a,___int2fs_sloc0_1_0,00117$ + dec (___int2fs_sloc0_1_0 + 1) +00117$: + ljmp 00105$ +00107$: +; _int2fs.c 105 + anl ar6,#0x7f +; _int2fs.c 108 + mov r2,___int2fs_sloc0_1_0 + mov r3,(___int2fs_sloc0_1_0 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___int2fs_sloc1_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___int2fs_sloc1_1_0 + 2) + rrc a + xch a,(___int2fs_sloc1_1_0 + 2) + rrc a + xch a,(___int2fs_sloc1_1_0 + 2) + mov (___int2fs_sloc1_1_0 + 3),a + mov (___int2fs_sloc1_1_0 + 1),#0x00 + mov ___int2fs_sloc1_1_0,#0x00 + mov dptr,#___int2fs_sign_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,___int2fs_sloc1_1_0 + orl ar2,a + mov a,(___int2fs_sloc1_1_0 + 1) + orl ar3,a + mov a,(___int2fs_sloc1_1_0 + 2) + orl ar0,a + mov a,(___int2fs_sloc1_1_0 + 3) + orl ar1,a + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov dptr,#(___int2fs_fl_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _int2fs.c 110 + mov dptr,#(___int2fs_fl_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00108$: + C$_int2fs.c$111$1$1 ==. + XG$__int2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_int2fs.cdb b/device/lib/large/_int2fs.cdb new file mode 100644 index 00000000..7e5497af --- /dev/null +++ b/device/lib/large/_int2fs.cdb @@ -0,0 +1,2 @@ +M:_int2fs +F:G$__int2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_int2fs.rel b/device/lib/large/_int2fs.rel new file mode 100644 index 00000000..18b52abd --- /dev/null +++ b/device/lib/large/_int2fs.rel @@ -0,0 +1,351 @@ +;!FILE _int2fs.asm +XH +H 8 areas EB global symbols +M _int2fs +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 144 flags 20 +S A$_int2fs$297 Def0111 +S A$_int2fs$288 Def0102 +S A$_int2fs$279 Def00F7 +S A$_int2fs$189 Def0083 +S A$_int2fs$298 Def0113 +S A$_int2fs$289 Def0103 +S A$_int2fs$199 Def008B +S A$_int2fs$299 Def0115 +S A$_int2fs$90 Def001D +S A$_int2fs$81 Def000E +S A$_int2fs$72 Def0000 +S G$__int2fs$0$0 Def0000 +S A$_int2fs$91 Def001E +S A$_int2fs$82 Def0011 +S A$_int2fs$73 Def0002 +S A$_int2fs$92 Def0021 +S A$_int2fs$83 Def0012 +S A$_int2fs$74 Def0004 +S A$_int2fs$84 Def0013 +S A$_int2fs$75 Def0007 +S A$_int2fs$94 Def0022 +S A$_int2fs$85 Def0014 +S A$_int2fs$76 Def0009 +S A$_int2fs$95 Def0025 +S A$_int2fs$86 Def0015 +S A$_int2fs$77 Def000A +S A$_int2fs$96 Def0026 +S A$_int2fs$87 Def0016 +S A$_int2fs$78 Def000C +S A$_int2fs$97 Def0027 +S A$_int2fs$88 Def0019 +S A$_int2fs$79 Def000D +S A$_int2fs$98 Def0028 +S A$_int2fs$89 Def001A +S C$_int2fs.c$111$1$1 Def0143 +S A$_int2fs$100 Def0029 +S A$_int2fs$200 Def008C +S A$_int2fs$110 Def0036 +S A$_int2fs$101 Def002A +S A$_int2fs$300 Def0116 +S A$_int2fs$210 Def009A +S A$_int2fs$201 Def008E +S A$_int2fs$120 Def003F +S A$_int2fs$111 Def0037 +S A$_int2fs$102 Def002B +S A$_int2fs$310 Def0126 +S A$_int2fs$301 Def0118 +S A$_int2fs$220 Def00A6 +S A$_int2fs$211 Def009B +S A$_int2fs$130 Def0047 +S A$_int2fs$121 Def0040 +S A$_int2fs$112 Def0038 +S A$_int2fs$103 Def002D +S A$_int2fs$320 Def012F +S A$_int2fs$311 Def0127 +S A$_int2fs$302 Def0119 +S A$_int2fs$230 Def00B1 +S A$_int2fs$221 Def00A7 +S A$_int2fs$212 Def009C +S A$_int2fs$203 Def0091 +S A$_int2fs$131 Def0048 +S A$_int2fs$113 Def0039 +S A$_int2fs$104 Def002E +S ___int2fs Def0000 +S A$_int2fs$330 Def013B +S A$_int2fs$321 Def0132 +S A$_int2fs$312 Def0128 +S A$_int2fs$303 Def011B +S A$_int2fs$240 Def00BB +S A$_int2fs$231 Def00B2 +S A$_int2fs$222 Def00A9 +S A$_int2fs$213 Def009D +S A$_int2fs$204 Def0094 +S A$_int2fs$150 Def005A +S A$_int2fs$141 Def004F +S A$_int2fs$132 Def0049 +S A$_int2fs$123 Def0041 +S A$_int2fs$114 Def003A +S A$_int2fs$105 Def002F +S A$_int2fs$322 Def0133 +S A$_int2fs$313 Def0129 +S A$_int2fs$304 Def011C +S A$_int2fs$250 Def00C7 +S A$_int2fs$241 Def00BE +S A$_int2fs$232 Def00B3 +S A$_int2fs$223 Def00AA +S A$_int2fs$214 Def009E +S A$_int2fs$205 Def0095 +S A$_int2fs$160 Def0066 +S A$_int2fs$151 Def005B +S A$_int2fs$142 Def0052 +S A$_int2fs$133 Def004A +S A$_int2fs$115 Def003B +S A$_int2fs$106 Def0032 +S A$_int2fs$332 Def013C +S A$_int2fs$323 Def0134 +S A$_int2fs$314 Def012A +S A$_int2fs$305 Def011E +S A$_int2fs$251 Def00C8 +S A$_int2fs$242 Def00BF +S A$_int2fs$233 Def00B4 +S A$_int2fs$215 Def009F +S A$_int2fs$206 Def0096 +S A$_int2fs$170 Def006F +S A$_int2fs$143 Def0053 +S A$_int2fs$116 Def003C +S A$_int2fs$107 Def0033 +S A$_int2fs$333 Def013D +S A$_int2fs$324 Def0135 +S A$_int2fs$315 Def012B +S A$_int2fs$306 Def011F +S A$_int2fs$270 Def00E5 +S A$_int2fs$261 Def00D5 +S A$_int2fs$243 Def00C0 +S A$_int2fs$234 Def00B5 +S A$_int2fs$225 Def00AC +S A$_int2fs$216 Def00A0 +S A$_int2fs$207 Def0097 +S A$_int2fs$180 Def0078 +S A$_int2fs$171 Def0070 +S A$_int2fs$162 Def0067 +S A$_int2fs$153 Def005C +S A$_int2fs$144 Def0054 +S A$_int2fs$126 Def0043 +S A$_int2fs$108 Def0034 +S A$_int2fs$334 Def013F +S A$_int2fs$325 Def0136 +S A$_int2fs$316 Def012C +S A$_int2fs$307 Def0121 +S A$_int2fs$280 Def00FA +S A$_int2fs$271 Def00E7 +S A$_int2fs$253 Def00C9 +S A$_int2fs$244 Def00C1 +S A$_int2fs$235 Def00B6 +S A$_int2fs$217 Def00A1 +S A$_int2fs$208 Def0098 +S A$_int2fs$190 Def0084 +S A$_int2fs$181 Def007B +S A$_int2fs$172 Def0071 +S A$_int2fs$154 Def005D +S A$_int2fs$145 Def0055 +S A$_int2fs$136 Def004B +S A$_int2fs$118 Def003D +S A$_int2fs$109 Def0035 +S A$_int2fs$335 Def0141 +S A$_int2fs$326 Def0137 +S A$_int2fs$317 Def012D +S A$_int2fs$308 Def0124 +S A$_int2fs$290 Def0104 +S A$_int2fs$281 Def00FB +S A$_int2fs$272 Def00E9 +S A$_int2fs$263 Def00D8 +S A$_int2fs$254 Def00CB +S A$_int2fs$245 Def00C2 +S A$_int2fs$236 Def00B7 +S A$_int2fs$218 Def00A3 +S A$_int2fs$209 Def0099 +S A$_int2fs$191 Def0085 +S A$_int2fs$182 Def007C +S A$_int2fs$155 Def005F +S A$_int2fs$146 Def0056 +S A$_int2fs$137 Def004C +S A$_int2fs$119 Def003E +S A$_int2fs$327 Def0138 +S A$_int2fs$318 Def012E +S A$_int2fs$309 Def0125 +S A$_int2fs$291 Def0105 +S A$_int2fs$282 Def00FC +S A$_int2fs$273 Def00EA +S A$_int2fs$264 Def00DA +S A$_int2fs$255 Def00CD +S A$_int2fs$246 Def00C3 +S A$_int2fs$237 Def00B8 +S A$_int2fs$228 Def00AE +S A$_int2fs$219 Def00A4 +S A$_int2fs$192 Def0086 +S A$_int2fs$183 Def007D +S A$_int2fs$174 Def0072 +S A$_int2fs$165 Def006A +S A$_int2fs$156 Def0061 +S A$_int2fs$147 Def0057 +S A$_int2fs$138 Def004D +S A$_int2fs$129 Def0046 +S A$_int2fs$328 Def0139 +S A$_int2fs$292 Def0107 +S A$_int2fs$283 Def00FD +S A$_int2fs$274 Def00EC +S A$_int2fs$265 Def00DC +S A$_int2fs$256 Def00D0 +S A$_int2fs$247 Def00C4 +S A$_int2fs$238 Def00B9 +S A$_int2fs$229 Def00AF +S A$_int2fs$193 Def0087 +S A$_int2fs$184 Def007E +S A$_int2fs$175 Def0073 +S A$_int2fs$157 Def0063 +S A$_int2fs$148 Def0058 +S A$_int2fs$139 Def004E +S A$_int2fs$329 Def013A +S A$_int2fs$293 Def0109 +S A$_int2fs$284 Def00FE +S A$_int2fs$275 Def00ED +S A$_int2fs$266 Def00DE +S A$_int2fs$248 Def00C5 +S A$_int2fs$239 Def00BA +S A$_int2fs$194 Def0088 +S A$_int2fs$185 Def007F +S A$_int2fs$176 Def0074 +S A$_int2fs$149 Def0059 +S A$_int2fs$339 Def0143 +S A$_int2fs$294 Def010B +S A$_int2fs$285 Def00FF +S A$_int2fs$276 Def00EF +S A$_int2fs$267 Def00E0 +S A$_int2fs$258 Def00D2 +S A$_int2fs$249 Def00C6 +S A$_int2fs$195 Def0089 +S A$_int2fs$186 Def0080 +S A$_int2fs$177 Def0075 +S A$_int2fs$168 Def006D +S A$_int2fs$295 Def010D +S A$_int2fs$286 Def0100 +S A$_int2fs$277 Def00F1 +S A$_int2fs$268 Def00E2 +S A$_int2fs$196 Def008A +S A$_int2fs$187 Def0081 +S A$_int2fs$178 Def0077 +S A$_int2fs$169 Def006E +S A$_int2fs$296 Def010F +S A$_int2fs$287 Def0101 +S A$_int2fs$278 Def00F4 +S A$_int2fs$269 Def00E3 +S A$_int2fs$188 Def0082 +S XG$__int2fs$0$0 Def0143 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 00 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 02 E4 A3 A3 A3 F0 12 00 00 F0 12 +R 00 00 00 07 00 03 00 05 02 0B 00 00 +T 00 1B 00 00 F0 12 00 00 F0 90 00 00 E0 FA A3 E0 +R 00 00 00 07 02 02 00 00 02 06 00 00 00 0A 00 05 +T 00 29 FB 33 95 E0 FC FD 90 00 0A EA F0 A3 EB F0 +R 00 00 00 07 00 09 00 05 +T 00 37 A3 EC F0 A3 ED F0 EA 4B 4C 4D 70 23 +R 00 00 00 07 +T 00 43 +R 00 00 00 07 +T 00 43 90 00 06 E4 F0 A3 F0 A3 E4 F0 A3 F0 90 +R 00 00 00 07 00 03 00 05 +T 00 50 00 06 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 8E +R 00 00 00 07 00 02 00 05 +T 00 5E 82 8F 83 88 F0 02 01 43 +R 00 00 00 07 00 08 00 07 +T 00 66 +R 00 00 00 07 +T 00 66 ED 30 E7 21 +R 00 00 00 07 +T 00 6A +R 00 00 00 07 +T 00 6A 90 00 02 E4 F0 A3 F0 A3 E4 F0 A3 74 80 F0 +R 00 00 00 07 00 03 00 05 +T 00 78 90 00 0A C3 E4 9A F0 E4 9B A3 F0 E4 9C A3 +R 00 00 00 07 00 03 00 05 +T 00 86 F0 E4 9D A3 F0 +R 00 00 00 07 +T 00 8B +R 00 00 00 07 +T 00 8B E4 F5 00 01 75 00 00 96 +R 00 00 00 07 29 04 00 01 29 07 00 01 +T 00 91 +R 00 00 00 07 +T 00 91 90 00 0A E0 FC A3 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 9F C3 EC 94 00 ED 94 00 EE 94 80 EF 94 00 50 +R 00 00 00 07 +T 00 AD 27 +R 00 00 00 07 +T 00 AE +R 00 00 00 07 +T 00 AE EC 25 E0 F8 ED 33 F9 EE 33 FA EF 33 FB 90 +R 00 00 00 07 +T 00 BC 00 0A E8 F0 A3 E9 F0 A3 EA F0 A3 EB F0 15 +R 00 00 00 07 00 02 00 05 +T 00 CA 00 00 74 FF B5 00 00 02 15 00 01 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 00 D2 +R 00 00 00 07 +T 00 D2 02 00 91 +R 00 00 00 07 00 03 00 07 +T 00 D5 +R 00 00 00 07 +T 00 D5 53 06 7F AA 00 00 AB 00 01 78 00 79 00 8A +R 00 00 00 07 29 06 00 01 29 09 00 01 +T 00 E1 00 04 EB 54 01 A2 E0 C5 00 04 13 C5 00 04 +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 00 EC 13 C5 00 04 F5 00 05 75 00 03 00 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 00 F5 00 02 00 90 00 02 E0 FA A3 E0 FB A3 E0 F8 +R 00 00 00 07 29 02 00 01 00 06 00 05 +T 01 02 A3 E0 F9 E5 00 02 42 02 E5 00 03 42 03 E5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 01 0E 00 04 42 00 E5 00 05 42 01 EA 42 04 EB 42 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 01 1A 05 E8 42 06 E9 42 07 90 00 06 EC F0 A3 ED +R 00 00 00 07 00 0A 00 05 +T 01 28 F0 A3 EE F0 A3 EF F0 90 00 06 E0 FA A3 E0 +R 00 00 00 07 00 0A 00 05 +T 01 36 FB A3 E0 FC A3 E0 FD 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 43 +R 00 00 00 07 +T 01 43 22 +R 00 00 00 07 diff --git a/device/lib/large/_iscntrl.asm b/device/lib/large/_iscntrl.asm new file mode 100644 index 00000000..97a02473 --- /dev/null +++ b/device/lib/large/_iscntrl.asm @@ -0,0 +1,94 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _iscntrl +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _iscntrl +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_iscntrl_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$iscntrl$0$0 ==. +; _iscntrl.c 27 +; ----------------------------------------- +; function iscntrl +; ----------------------------------------- +_iscntrl: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _iscntrl.c 32 + push dpl + mov dptr,#_iscntrl_c_1_1 + pop acc + movx @dptr,a +; _iscntrl.c 30 + mov dptr,#_iscntrl_c_1_1 + movx a,@dptr + mov r2,a + clr c + mov a,#0x1f + subb a,r2 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00107$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r2,#0x7f,00102$ +; Peephole 201 removed redundant sjmp +00108$: +00109$: +00101$: +; _iscntrl.c 31 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _iscntrl.c 32 + mov dpl,#0x00 +00104$: + C$_iscntrl.c$33$1$1 ==. + XG$iscntrl$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_iscntrl.cdb b/device/lib/large/_iscntrl.cdb new file mode 100644 index 00000000..8eb5da75 --- /dev/null +++ b/device/lib/large/_iscntrl.cdb @@ -0,0 +1,2 @@ +M:_iscntrl +F:G$iscntrl$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_iscntrl.rel b/device/lib/large/_iscntrl.rel new file mode 100644 index 00000000..f88ad415 --- /dev/null +++ b/device/lib/large/_iscntrl.rel @@ -0,0 +1,62 @@ +;!FILE _iscntrl.asm +XH +H 8 areas 14 global symbols +M _iscntrl +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 1F flags 20 +S _iscntrl Def0000 +S XG$iscntrl$0$0 Def001E +S C$_iscntrl.c$33$1$1 Def001E +S A$_iscntrl$70 Def000D +S A$_iscntrl$71 Def000E +S A$_iscntrl$62 Def0000 +S A$_iscntrl$72 Def0010 +S A$_iscntrl$63 Def0002 +S A$_iscntrl$64 Def0005 +S A$_iscntrl$74 Def0011 +S A$_iscntrl$65 Def0007 +S G$iscntrl$0$0 Def0000 +S A$_iscntrl$93 Def001E +S A$_iscntrl$84 Def0016 +S A$_iscntrl$67 Def0008 +S A$_iscntrl$86 Def0019 +S A$_iscntrl$68 Def000B +S A$_iscntrl$78 Def0013 +S A$_iscntrl$69 Def000C +S A$_iscntrl$89 Def001B +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA C3 +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 74 1F 9A 50 03 +R 00 00 00 07 +T 00 13 +R 00 00 00 07 +T 00 13 BA 7F 05 +R 00 00 00 07 +T 00 16 +R 00 00 00 07 +T 00 16 +R 00 00 00 07 +T 00 16 +R 00 00 00 07 +T 00 16 75 82 01 80 03 +R 00 00 00 07 +T 00 1B +R 00 00 00 07 +T 00 1B 75 82 00 +R 00 00 00 07 +T 00 1E +R 00 00 00 07 +T 00 1E 22 +R 00 00 00 07 diff --git a/device/lib/large/_isdigit.asm b/device/lib/large/_isdigit.asm new file mode 100644 index 00000000..470beb10 --- /dev/null +++ b/device/lib/large/_isdigit.asm @@ -0,0 +1,94 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _isdigit +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isdigit +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_isdigit_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isdigit$0$0 ==. +; _isdigit.c 26 +; ----------------------------------------- +; function isdigit +; ----------------------------------------- +_isdigit: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isdigit.c 31 + push dpl + mov dptr,#_isdigit_c_1_1 + pop acc + movx @dptr,a +; _isdigit.c 29 + mov dptr,#_isdigit_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x30,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x39 + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isdigit.c 30 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isdigit.c 31 + mov dpl,#0x00 +00104$: + C$_isdigit.c$32$1$1 ==. + XG$isdigit$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_isdigit.cdb b/device/lib/large/_isdigit.cdb new file mode 100644 index 00000000..82f7ab1e --- /dev/null +++ b/device/lib/large/_isdigit.cdb @@ -0,0 +1,2 @@ +M:_isdigit +F:G$isdigit$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_isdigit.rel b/device/lib/large/_isdigit.rel new file mode 100644 index 00000000..14bd4bef --- /dev/null +++ b/device/lib/large/_isdigit.rel @@ -0,0 +1,63 @@ +;!FILE _isdigit.asm +XH +H 8 areas 15 global symbols +M _isdigit +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 21 flags 20 +S _isdigit Def0000 +S C$_isdigit.c$32$1$1 Def0020 +S XG$isdigit$0$0 Def0020 +S A$_isdigit$70 Def000D +S A$_isdigit$62 Def0000 +S A$_isdigit$81 Def0016 +S A$_isdigit$63 Def0002 +S A$_isdigit$64 Def0005 +S A$_isdigit$74 Def0010 +S A$_isdigit$65 Def0007 +S G$isdigit$0$0 Def0000 +S A$_isdigit$93 Def0020 +S A$_isdigit$84 Def0018 +S A$_isdigit$76 Def0012 +S A$_isdigit$67 Def0008 +S A$_isdigit$86 Def001B +S A$_isdigit$77 Def0013 +S A$_isdigit$68 Def000B +S A$_isdigit$78 Def0015 +S A$_isdigit$69 Def000C +S A$_isdigit$89 Def001D +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA BA +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 30 00 +R 00 00 00 07 +T 00 10 +R 00 00 00 07 +T 00 10 40 0B +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 C3 74 39 9A 40 05 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 75 82 01 80 03 +R 00 00 00 07 +T 00 1D +R 00 00 00 07 +T 00 1D 75 82 00 +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 22 +R 00 00 00 07 diff --git a/device/lib/large/_isgraph.asm b/device/lib/large/_isgraph.asm new file mode 100644 index 00000000..af8b9d8e --- /dev/null +++ b/device/lib/large/_isgraph.asm @@ -0,0 +1,94 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _isgraph +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isgraph +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_isgraph_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isgraph$0$0 ==. +; _isgraph.c 25 +; ----------------------------------------- +; function isgraph +; ----------------------------------------- +_isgraph: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isgraph.c 30 + push dpl + mov dptr,#_isgraph_c_1_1 + pop acc + movx @dptr,a +; _isgraph.c 28 + mov dptr,#_isgraph_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x21,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x7e + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isgraph.c 29 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isgraph.c 30 + mov dpl,#0x00 +00104$: + C$_isgraph.c$31$1$1 ==. + XG$isgraph$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_isgraph.cdb b/device/lib/large/_isgraph.cdb new file mode 100644 index 00000000..257b3d9b --- /dev/null +++ b/device/lib/large/_isgraph.cdb @@ -0,0 +1,2 @@ +M:_isgraph +F:G$isgraph$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_isgraph.rel b/device/lib/large/_isgraph.rel new file mode 100644 index 00000000..663cd48a --- /dev/null +++ b/device/lib/large/_isgraph.rel @@ -0,0 +1,63 @@ +;!FILE _isgraph.asm +XH +H 8 areas 15 global symbols +M _isgraph +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 21 flags 20 +S _isgraph Def0000 +S C$_isgraph.c$31$1$1 Def0020 +S XG$isgraph$0$0 Def0020 +S A$_isgraph$70 Def000D +S A$_isgraph$62 Def0000 +S A$_isgraph$81 Def0016 +S A$_isgraph$63 Def0002 +S A$_isgraph$64 Def0005 +S A$_isgraph$74 Def0010 +S A$_isgraph$65 Def0007 +S G$isgraph$0$0 Def0000 +S A$_isgraph$93 Def0020 +S A$_isgraph$84 Def0018 +S A$_isgraph$76 Def0012 +S A$_isgraph$67 Def0008 +S A$_isgraph$86 Def001B +S A$_isgraph$77 Def0013 +S A$_isgraph$68 Def000B +S A$_isgraph$78 Def0015 +S A$_isgraph$69 Def000C +S A$_isgraph$89 Def001D +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA BA +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 21 00 +R 00 00 00 07 +T 00 10 +R 00 00 00 07 +T 00 10 40 0B +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 C3 74 7E 9A 40 05 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 75 82 01 80 03 +R 00 00 00 07 +T 00 1D +R 00 00 00 07 +T 00 1D 75 82 00 +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 22 +R 00 00 00 07 diff --git a/device/lib/large/_islower.asm b/device/lib/large/_islower.asm new file mode 100644 index 00000000..b96baea2 --- /dev/null +++ b/device/lib/large/_islower.asm @@ -0,0 +1,94 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _islower +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _islower +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_islower_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$islower$0$0 ==. +; _islower.c 25 +; ----------------------------------------- +; function islower +; ----------------------------------------- +_islower: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _islower.c 30 + push dpl + mov dptr,#_islower_c_1_1 + pop acc + movx @dptr,a +; _islower.c 28 + mov dptr,#_islower_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x61,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x7a + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _islower.c 29 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _islower.c 30 + mov dpl,#0x00 +00104$: + C$_islower.c$31$1$1 ==. + XG$islower$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_islower.cdb b/device/lib/large/_islower.cdb new file mode 100644 index 00000000..574e3174 --- /dev/null +++ b/device/lib/large/_islower.cdb @@ -0,0 +1,2 @@ +M:_islower +F:G$islower$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_islower.rel b/device/lib/large/_islower.rel new file mode 100644 index 00000000..b48559b7 --- /dev/null +++ b/device/lib/large/_islower.rel @@ -0,0 +1,63 @@ +;!FILE _islower.asm +XH +H 8 areas 15 global symbols +M _islower +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 21 flags 20 +S _islower Def0000 +S C$_islower.c$31$1$1 Def0020 +S XG$islower$0$0 Def0020 +S A$_islower$70 Def000D +S A$_islower$62 Def0000 +S A$_islower$81 Def0016 +S A$_islower$63 Def0002 +S A$_islower$64 Def0005 +S A$_islower$74 Def0010 +S A$_islower$65 Def0007 +S G$islower$0$0 Def0000 +S A$_islower$93 Def0020 +S A$_islower$84 Def0018 +S A$_islower$76 Def0012 +S A$_islower$67 Def0008 +S A$_islower$86 Def001B +S A$_islower$77 Def0013 +S A$_islower$68 Def000B +S A$_islower$78 Def0015 +S A$_islower$69 Def000C +S A$_islower$89 Def001D +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA BA +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 61 00 +R 00 00 00 07 +T 00 10 +R 00 00 00 07 +T 00 10 40 0B +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 C3 74 7A 9A 40 05 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 75 82 01 80 03 +R 00 00 00 07 +T 00 1D +R 00 00 00 07 +T 00 1D 75 82 00 +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 22 +R 00 00 00 07 diff --git a/device/lib/large/_isprint.asm b/device/lib/large/_isprint.asm new file mode 100644 index 00000000..39741541 --- /dev/null +++ b/device/lib/large/_isprint.asm @@ -0,0 +1,94 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _isprint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isprint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_isprint_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isprint$0$0 ==. +; _isprint.c 24 +; ----------------------------------------- +; function isprint +; ----------------------------------------- +_isprint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isprint.c 29 + push dpl + mov dptr,#_isprint_c_1_1 + pop acc + movx @dptr,a +; _isprint.c 27 + mov dptr,#_isprint_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x20,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x7e + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isprint.c 28 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isprint.c 29 + mov dpl,#0x00 +00104$: + C$_isprint.c$30$1$1 ==. + XG$isprint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_isprint.cdb b/device/lib/large/_isprint.cdb new file mode 100644 index 00000000..c8637529 --- /dev/null +++ b/device/lib/large/_isprint.cdb @@ -0,0 +1,2 @@ +M:_isprint +F:G$isprint$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_isprint.rel b/device/lib/large/_isprint.rel new file mode 100644 index 00000000..ce36cf2f --- /dev/null +++ b/device/lib/large/_isprint.rel @@ -0,0 +1,63 @@ +;!FILE _isprint.asm +XH +H 8 areas 15 global symbols +M _isprint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 21 flags 20 +S A$_isprint$78 Def0015 +S A$_isprint$69 Def000C +S A$_isprint$89 Def001D +S _isprint Def0000 +S C$_isprint.c$30$1$1 Def0020 +S XG$isprint$0$0 Def0020 +S A$_isprint$70 Def000D +S A$_isprint$62 Def0000 +S A$_isprint$81 Def0016 +S A$_isprint$63 Def0002 +S A$_isprint$64 Def0005 +S A$_isprint$74 Def0010 +S A$_isprint$65 Def0007 +S G$isprint$0$0 Def0000 +S A$_isprint$93 Def0020 +S A$_isprint$84 Def0018 +S A$_isprint$76 Def0012 +S A$_isprint$67 Def0008 +S A$_isprint$86 Def001B +S A$_isprint$77 Def0013 +S A$_isprint$68 Def000B +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA BA +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 20 00 +R 00 00 00 07 +T 00 10 +R 00 00 00 07 +T 00 10 40 0B +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 C3 74 7E 9A 40 05 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 75 82 01 80 03 +R 00 00 00 07 +T 00 1D +R 00 00 00 07 +T 00 1D 75 82 00 +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 22 +R 00 00 00 07 diff --git a/device/lib/large/_ispunct.asm b/device/lib/large/_ispunct.asm new file mode 100644 index 00000000..0eea8f67 --- /dev/null +++ b/device/lib/large/_ispunct.asm @@ -0,0 +1,123 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _ispunct +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _ispunct +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_ispunct_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$ispunct$0$0 ==. +; _ispunct.c 25 +; ----------------------------------------- +; function ispunct +; ----------------------------------------- +_ispunct: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ispunct.c 34 + push dpl + mov dptr,#_ispunct_c_1_1 + pop acc + movx @dptr,a +; _ispunct.c 28 + mov dptr,#_ispunct_c_1_1 + movx a,@dptr + mov r2,a + push ar2 + mov dpl,r2 + lcall _isprint + mov r3,dpl + pop ar2 + mov a,r3 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _ispunct.c 29 + push ar2 + mov dpl,r2 + lcall _islower + mov r3,dpl + pop ar2 + mov a,r3 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00115$: +; _ispunct.c 30 + push ar2 + mov dpl,r2 + lcall _isupper + mov r3,dpl + pop ar2 + mov a,r3 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00116$: +; _ispunct.c 31 + cjne r2,#0x20,00117$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00117$: +; _ispunct.c 32 + mov dpl,r2 + lcall _isdigit + mov r2,dpl + mov a,r2 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00118$: +; _ispunct.c 33 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00102$: +; _ispunct.c 34 + mov dpl,#0x00 +00107$: + C$_ispunct.c$35$1$1 ==. + XG$ispunct$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_ispunct.cdb b/device/lib/large/_ispunct.cdb new file mode 100644 index 00000000..92ef79f8 --- /dev/null +++ b/device/lib/large/_ispunct.cdb @@ -0,0 +1,2 @@ +M:_ispunct +F:G$ispunct$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_ispunct.rel b/device/lib/large/_ispunct.rel new file mode 100644 index 00000000..ca3bf457 --- /dev/null +++ b/device/lib/large/_ispunct.rel @@ -0,0 +1,97 @@ +;!FILE _ispunct.asm +XH +H 8 areas 2F global symbols +M _ispunct +S _isdigit Ref0000 +S _islower Ref0000 +S _isupper Ref0000 +S _isprint Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 4F flags 20 +S A$_ispunct$100 Def0037 +S A$_ispunct$110 Def0044 +S A$_ispunct$102 Def003A +S A$_ispunct$122 Def004E +S A$_ispunct$113 Def0046 +S A$_ispunct$105 Def003C +S A$_ispunct$115 Def0049 +S A$_ispunct$106 Def003E +S _ispunct Def0000 +S A$_ispunct$107 Def0041 +S A$_ispunct$108 Def0043 +S A$_ispunct$118 Def004B +S XG$ispunct$0$0 Def004E +S C$_ispunct.c$35$1$1 Def004E +S A$_ispunct$70 Def000D +S A$_ispunct$80 Def001B +S A$_ispunct$71 Def000F +S A$_ispunct$62 Def0000 +S A$_ispunct$90 Def0029 +S A$_ispunct$81 Def001D +S A$_ispunct$72 Def0011 +S A$_ispunct$63 Def0002 +S A$_ispunct$91 Def002B +S A$_ispunct$82 Def001F +S A$_ispunct$73 Def0014 +S A$_ispunct$64 Def0005 +S A$_ispunct$92 Def002D +S A$_ispunct$83 Def0022 +S A$_ispunct$74 Def0016 +S A$_ispunct$65 Def0007 +S G$ispunct$0$0 Def0000 +S A$_ispunct$93 Def0030 +S A$_ispunct$84 Def0024 +S A$_ispunct$75 Def0018 +S A$_ispunct$94 Def0032 +S A$_ispunct$85 Def0026 +S A$_ispunct$67 Def0008 +S A$_ispunct$95 Def0034 +S A$_ispunct$77 Def0019 +S A$_ispunct$68 Def000B +S A$_ispunct$87 Def0027 +S A$_ispunct$69 Def000C +S A$_ispunct$97 Def0035 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA C0 +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 02 8A 82 12 00 00 AB 82 D0 02 EB 60 30 +R 00 00 00 07 02 06 00 03 +T 00 1B +R 00 00 00 07 +T 00 1B C0 02 8A 82 12 00 00 AB 82 D0 02 EB 70 22 +R 00 00 00 07 02 07 00 01 +T 00 29 +R 00 00 00 07 +T 00 29 C0 02 8A 82 12 00 00 AB 82 D0 02 EB 70 14 +R 00 00 00 07 02 07 00 02 +T 00 37 +R 00 00 00 07 +T 00 37 BA 20 02 80 0F +R 00 00 00 07 +T 00 3C +R 00 00 00 07 +T 00 3C 8A 82 12 00 00 AA 82 EA 70 05 +R 00 00 00 07 02 05 00 00 +T 00 46 +R 00 00 00 07 +T 00 46 75 82 01 80 03 +R 00 00 00 07 +T 00 4B +R 00 00 00 07 +T 00 4B 75 82 00 +R 00 00 00 07 +T 00 4E +R 00 00 00 07 +T 00 4E 22 +R 00 00 00 07 diff --git a/device/lib/large/_isspace.asm b/device/lib/large/_isspace.asm new file mode 100644 index 00000000..62008bb3 --- /dev/null +++ b/device/lib/large/_isspace.asm @@ -0,0 +1,113 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _isspace +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isspace +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_isspace_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isspace$0$0 ==. +; _isspace.c 24 +; ----------------------------------------- +; function isspace +; ----------------------------------------- +_isspace: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isspace.c 34 + push dpl + mov dptr,#_isspace_c_1_1 + pop acc + movx @dptr,a +; _isspace.c 27 + mov dptr,#_isspace_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x20,00115$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00115$: +; _isspace.c 28 + cjne r2,#0x0c,00116$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00116$: +; _isspace.c 29 + cjne r2,#0x0a,00117$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00117$: +; _isspace.c 30 + cjne r2,#0x0d,00118$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00118$: +; _isspace.c 31 + cjne r2,#0x09,00119$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00119$: +; _isspace.c 32 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r2,#0x0b,00102$ +; Peephole 201 removed redundant sjmp +00120$: +00121$: +00101$: +; _isspace.c 33 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00102$: +; _isspace.c 34 + mov dpl,#0x00 +00108$: + C$_isspace.c$35$1$1 ==. + XG$isspace$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_isspace.cdb b/device/lib/large/_isspace.cdb new file mode 100644 index 00000000..a9440c9b --- /dev/null +++ b/device/lib/large/_isspace.cdb @@ -0,0 +1,2 @@ +M:_isspace +F:G$isspace$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_isspace.rel b/device/lib/large/_isspace.rel new file mode 100644 index 00000000..fa6dd961 --- /dev/null +++ b/device/lib/large/_isspace.rel @@ -0,0 +1,84 @@ +;!FILE _isspace.asm +XH +H 8 areas 1A global symbols +M _isspace +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 32 flags 20 +S A$_isspace$112 Def0031 +S A$_isspace$103 Def0029 +S A$_isspace$105 Def002C +S _isspace Def0000 +S A$_isspace$108 Def002E +S XG$isspace$0$0 Def0031 +S C$_isspace.c$35$1$1 Def0031 +S A$_isspace$70 Def000D +S A$_isspace$80 Def0017 +S A$_isspace$62 Def0000 +S A$_isspace$90 Def0021 +S A$_isspace$72 Def0010 +S A$_isspace$63 Def0002 +S A$_isspace$82 Def001A +S A$_isspace$64 Def0005 +S A$_isspace$92 Def0024 +S A$_isspace$65 Def0007 +S G$isspace$0$0 Def0000 +S A$_isspace$75 Def0012 +S A$_isspace$85 Def001C +S A$_isspace$67 Def0008 +S A$_isspace$77 Def0015 +S A$_isspace$68 Def000B +S A$_isspace$87 Def001F +S A$_isspace$69 Def000C +S A$_isspace$97 Def0026 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA BA +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 20 02 80 17 +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 BA 0C 02 80 12 +R 00 00 00 07 +T 00 17 +R 00 00 00 07 +T 00 17 BA 0A 02 80 0D +R 00 00 00 07 +T 00 1C +R 00 00 00 07 +T 00 1C BA 0D 02 80 08 +R 00 00 00 07 +T 00 21 +R 00 00 00 07 +T 00 21 BA 09 02 80 03 +R 00 00 00 07 +T 00 26 +R 00 00 00 07 +T 00 26 BA 0B 05 +R 00 00 00 07 +T 00 29 +R 00 00 00 07 +T 00 29 +R 00 00 00 07 +T 00 29 +R 00 00 00 07 +T 00 29 75 82 01 80 03 +R 00 00 00 07 +T 00 2E +R 00 00 00 07 +T 00 2E 75 82 00 +R 00 00 00 07 +T 00 31 +R 00 00 00 07 +T 00 31 22 +R 00 00 00 07 diff --git a/device/lib/large/_isupper.asm b/device/lib/large/_isupper.asm new file mode 100644 index 00000000..e3b28ea9 --- /dev/null +++ b/device/lib/large/_isupper.asm @@ -0,0 +1,94 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _isupper +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isupper +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_isupper_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isupper$0$0 ==. +; _isupper.c 24 +; ----------------------------------------- +; function isupper +; ----------------------------------------- +_isupper: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isupper.c 29 + push dpl + mov dptr,#_isupper_c_1_1 + pop acc + movx @dptr,a +; _isupper.c 27 + mov dptr,#_isupper_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x41,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x5a + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isupper.c 28 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isupper.c 29 + mov dpl,#0x00 +00104$: + C$_isupper.c$30$1$1 ==. + XG$isupper$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_isupper.cdb b/device/lib/large/_isupper.cdb new file mode 100644 index 00000000..bb37037d --- /dev/null +++ b/device/lib/large/_isupper.cdb @@ -0,0 +1,2 @@ +M:_isupper +F:G$isupper$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_isupper.rel b/device/lib/large/_isupper.rel new file mode 100644 index 00000000..9679d01c --- /dev/null +++ b/device/lib/large/_isupper.rel @@ -0,0 +1,63 @@ +;!FILE _isupper.asm +XH +H 8 areas 15 global symbols +M _isupper +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 21 flags 20 +S A$_isupper$89 Def001D +S _isupper Def0000 +S C$_isupper.c$30$1$1 Def0020 +S XG$isupper$0$0 Def0020 +S A$_isupper$70 Def000D +S A$_isupper$62 Def0000 +S A$_isupper$81 Def0016 +S A$_isupper$63 Def0002 +S A$_isupper$64 Def0005 +S A$_isupper$74 Def0010 +S A$_isupper$65 Def0007 +S G$isupper$0$0 Def0000 +S A$_isupper$93 Def0020 +S A$_isupper$84 Def0018 +S A$_isupper$76 Def0012 +S A$_isupper$67 Def0008 +S A$_isupper$86 Def001B +S A$_isupper$77 Def0013 +S A$_isupper$68 Def000B +S A$_isupper$78 Def0015 +S A$_isupper$69 Def000C +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA BA +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 41 00 +R 00 00 00 07 +T 00 10 +R 00 00 00 07 +T 00 10 40 0B +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 C3 74 5A 9A 40 05 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 75 82 01 80 03 +R 00 00 00 07 +T 00 1D +R 00 00 00 07 +T 00 1D 75 82 00 +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 22 +R 00 00 00 07 diff --git a/device/lib/large/_isxdigit.asm b/device/lib/large/_isxdigit.asm new file mode 100644 index 00000000..495b863f --- /dev/null +++ b/device/lib/large/_isxdigit.asm @@ -0,0 +1,129 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:29 2000 + +;-------------------------------------------------------- + .module _isxdigit +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isxdigit +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_isxdigit_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isxdigit$0$0 ==. +; _isxdigit.c 24 +; ----------------------------------------- +; function isxdigit +; ----------------------------------------- +_isxdigit: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isxdigit.c 31 + push dpl + mov dptr,#_isxdigit_c_1_1 + pop acc + movx @dptr,a +; _isxdigit.c 27 + mov dptr,#_isxdigit_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x30,00113$ +00113$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00105$ +00114$: + clr c + mov a,#0x39 + subb a,r2 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00115$: +00105$: +; _isxdigit.c 28 + mov dptr,#_isxdigit_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x61,00116$ +00116$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00117$: + clr c + mov a,#0x66 + subb a,r2 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00118$: +00107$: +; _isxdigit.c 29 + mov dptr,#_isxdigit_c_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x41,00119$ +00119$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00120$: + clr c + mov a,#0x46 + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00121$: +00101$: +; _isxdigit.c 30 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00102$: +; _isxdigit.c 31 + mov dpl,#0x00 +00108$: + C$_isxdigit.c$33$1$1 ==. + XG$isxdigit$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_isxdigit.cdb b/device/lib/large/_isxdigit.cdb new file mode 100644 index 00000000..c7983cff --- /dev/null +++ b/device/lib/large/_isxdigit.cdb @@ -0,0 +1,2 @@ +M:_isxdigit +F:G$isxdigit$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/large/_isxdigit.rel b/device/lib/large/_isxdigit.rel new file mode 100644 index 00000000..6bfb9380 --- /dev/null +++ b/device/lib/large/_isxdigit.rel @@ -0,0 +1,111 @@ +;!FILE _isxdigit.asm +XH +H 8 areas 27 global symbols +M _isxdigit +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 1 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 41 flags 20 +S A$_isxdigit$111 Def0033 +S A$_isxdigit$102 Def002B +S A$_isxdigit$121 Def003B +S A$_isxdigit$112 Def0035 +S A$_isxdigit$103 Def002C +S A$_isxdigit$104 Def002D +S A$_isxdigit$124 Def003D +S A$_isxdigit$115 Def0036 +S _isxdigit Def0000 +S A$_isxdigit$108 Def0030 +S A$_isxdigit$128 Def0040 +S A$_isxdigit$119 Def0038 +S XG$isxdigit$0$0 Def0040 +S C$_isxdigit.c$33$1$1 Def0040 +S A$_isxdigit$70 Def000D +S A$_isxdigit$80 Def0016 +S A$_isxdigit$62 Def0000 +S A$_isxdigit$63 Def0002 +S A$_isxdigit$91 Def0020 +S A$_isxdigit$64 Def0005 +S A$_isxdigit$74 Def0010 +S A$_isxdigit$65 Def0007 +S G$isxdigit$0$0 Def0000 +S A$_isxdigit$93 Def0022 +S A$_isxdigit$84 Def0018 +S A$_isxdigit$94 Def0023 +S A$_isxdigit$85 Def001B +S A$_isxdigit$76 Def0012 +S A$_isxdigit$67 Def0008 +S A$_isxdigit$95 Def0025 +S A$_isxdigit$86 Def001C +S A$_isxdigit$77 Def0013 +S A$_isxdigit$68 Def000B +S A$_isxdigit$87 Def001D +S A$_isxdigit$78 Def0015 +S A$_isxdigit$69 Def000C +S A$_isxdigit$97 Def0026 +S A$_isxdigit$110 Def0032 +S A$_isxdigit$101 Def0028 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 00 E0 FA BA +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E 30 00 +R 00 00 00 07 +T 00 10 +R 00 00 00 07 +T 00 10 40 06 +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 C3 74 39 9A 50 20 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 90 00 00 E0 FA BA 61 00 +R 00 00 00 07 00 03 00 05 +T 00 20 +R 00 00 00 07 +T 00 20 40 06 +R 00 00 00 07 +T 00 22 +R 00 00 00 07 +T 00 22 C3 74 66 9A 50 10 +R 00 00 00 07 +T 00 28 +R 00 00 00 07 +T 00 28 +R 00 00 00 07 +T 00 28 90 00 00 E0 FA BA 41 00 +R 00 00 00 07 00 03 00 05 +T 00 30 +R 00 00 00 07 +T 00 30 40 0B +R 00 00 00 07 +T 00 32 +R 00 00 00 07 +T 00 32 C3 74 46 9A 40 05 +R 00 00 00 07 +T 00 38 +R 00 00 00 07 +T 00 38 +R 00 00 00 07 +T 00 38 75 82 01 80 03 +R 00 00 00 07 +T 00 3D +R 00 00 00 07 +T 00 3D 75 82 00 +R 00 00 00 07 +T 00 40 +R 00 00 00 07 +T 00 40 22 +R 00 00 00 07 diff --git a/device/lib/large/_long2fs.asm b/device/lib/large/_long2fs.asm new file mode 100644 index 00000000..05d2bce4 --- /dev/null +++ b/device/lib/large/_long2fs.asm @@ -0,0 +1,346 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + +;-------------------------------------------------------- + .module _long2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___long2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___long2fs_sloc0_1_0: + .ds 0x0002 +___long2fs_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___long2fs_a1_1_1: + .ds 0x0004 +___long2fs_sign_1_1: + .ds 0x0004 +___long2fs_fl_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__long2fs$0$0 ==. +; _long2fs.c 80 +; ----------------------------------------- +; function __long2fs +; ----------------------------------------- +___long2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _long2fs.c 108 + push acc + push b + push dph + push dpl + mov dptr,#___long2fs_a1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _long2fs.c 82 + mov dptr,#___long2fs_sign_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _long2fs.c 86 + mov dptr,#___long2fs_a1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _long2fs.c 88 + mov dptr,#(___long2fs_fl_1_1) +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; _long2fs.c 89 + mov dptr,#(___long2fs_fl_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r6 + mov dph,r7 + mov b,r0 + ljmp 00108$ +00102$: +; _long2fs.c 92 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _long2fs.c 94 + mov dptr,#___long2fs_sign_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x80 + movx @dptr,a +; _long2fs.c 95 + mov dptr,#___long2fs_a1_1_1 + clr c + clr a + subb a,r2 + movx @dptr,a + clr a + subb a,r3 + inc dptr + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a +; _long2fs.c 98 +00113$: + clr a + mov (___long2fs_sloc0_1_0 + 1),a + mov ___long2fs_sloc0_1_0,#0x96 +00105$: + mov dptr,#___long2fs_a1_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r4 + subb a,#0x00 + mov a,r5 + subb a,#0x00 + mov a,r6 + subb a,#0x80 + mov a,r7 + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _long2fs.c 100 + mov a,r4 + add a,acc + mov r0,a + mov a,r5 + rlc a + mov r1,a + mov a,r6 + rlc a + mov r2,a + mov a,r7 + rlc a + mov r3,a + mov dptr,#___long2fs_a1_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _long2fs.c 101 + dec ___long2fs_sloc0_1_0 + mov a,#0xff + cjne a,___long2fs_sloc0_1_0,00117$ + dec (___long2fs_sloc0_1_0 + 1) +00117$: + ljmp 00105$ +00107$: +; _long2fs.c 104 + anl ar6,#0x7f + mov dptr,#___long2fs_a1_1_1 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _long2fs.c 106 + mov r2,___long2fs_sloc0_1_0 + mov r3,(___long2fs_sloc0_1_0 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___long2fs_sloc1_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___long2fs_sloc1_1_0 + 2) + rrc a + xch a,(___long2fs_sloc1_1_0 + 2) + rrc a + xch a,(___long2fs_sloc1_1_0 + 2) + mov (___long2fs_sloc1_1_0 + 3),a + mov (___long2fs_sloc1_1_0 + 1),#0x00 + mov ___long2fs_sloc1_1_0,#0x00 + mov dptr,#___long2fs_sign_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,___long2fs_sloc1_1_0 + orl ar2,a + mov a,(___long2fs_sloc1_1_0 + 1) + orl ar3,a + mov a,(___long2fs_sloc1_1_0 + 2) + orl ar0,a + mov a,(___long2fs_sloc1_1_0 + 3) + orl ar1,a + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov dptr,#(___long2fs_fl_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _long2fs.c 108 + mov dptr,#(___long2fs_fl_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00108$: + C$_long2fs.c$109$1$1 ==. + XG$__long2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_long2fs.cdb b/device/lib/large/_long2fs.cdb new file mode 100644 index 00000000..6ba151b2 --- /dev/null +++ b/device/lib/large/_long2fs.cdb @@ -0,0 +1,2 @@ +M:_long2fs +F:G$__long2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_long2fs.rel b/device/lib/large/_long2fs.rel new file mode 100644 index 00000000..6a7d0b86 --- /dev/null +++ b/device/lib/large/_long2fs.rel @@ -0,0 +1,359 @@ +;!FILE _long2fs.asm +XH +H 8 areas F5 global symbols +M _long2fs +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size C flags 40 +A GSINIT size 0 flags 20 +A CSEG size 151 flags 20 +S A$_long2fs$100 Def002E +S A$_long2fs$200 Def0095 +S A$_long2fs$110 Def003A +S A$_long2fs$101 Def0031 +S A$_long2fs$300 Def0118 +S A$_long2fs$210 Def009F +S A$_long2fs$201 Def0096 +S A$_long2fs$120 Def0042 +S A$_long2fs$111 Def003B +S A$_long2fs$102 Def0032 +S A$_long2fs$310 Def0129 +S A$_long2fs$301 Def011A +S A$_long2fs$211 Def00A0 +S A$_long2fs$202 Def0097 +S A$_long2fs$130 Def004A +S A$_long2fs$112 Def003C +S A$_long2fs$103 Def0033 +S A$_long2fs$320 Def0137 +S A$_long2fs$311 Def012B +S A$_long2fs$302 Def011C +S A$_long2fs$230 Def00B6 +S A$_long2fs$212 Def00A2 +S A$_long2fs$203 Def0098 +S A$_long2fs$140 Def0055 +S A$_long2fs$131 Def004B +S A$_long2fs$113 Def003D +S A$_long2fs$104 Def0034 +S ___long2fs Def0000 +S A$_long2fs$330 Def0142 +S A$_long2fs$321 Def0138 +S A$_long2fs$312 Def012C +S A$_long2fs$303 Def011E +S A$_long2fs$240 Def00C2 +S A$_long2fs$231 Def00B7 +S A$_long2fs$222 Def00AD +S A$_long2fs$213 Def00A3 +S A$_long2fs$204 Def0099 +S A$_long2fs$150 Def0060 +S A$_long2fs$141 Def0056 +S A$_long2fs$132 Def004C +S A$_long2fs$123 Def0045 +S A$_long2fs$114 Def003E +S A$_long2fs$105 Def0035 +S A$_long2fs$340 Def014C +S A$_long2fs$331 Def0143 +S A$_long2fs$322 Def0139 +S A$_long2fs$313 Def012E +S A$_long2fs$304 Def0120 +S A$_long2fs$250 Def00CF +S A$_long2fs$241 Def00C3 +S A$_long2fs$232 Def00B8 +S A$_long2fs$223 Def00AE +S A$_long2fs$214 Def00A5 +S A$_long2fs$205 Def009A +S A$_long2fs$151 Def0062 +S A$_long2fs$142 Def0057 +S A$_long2fs$133 Def004D +S A$_long2fs$124 Def0046 +S A$_long2fs$115 Def003F +S A$_long2fs$106 Def0036 +S C$_long2fs.c$109$1$1 Def0150 +S A$_long2fs$341 Def014E +S A$_long2fs$332 Def0144 +S A$_long2fs$323 Def013A +S A$_long2fs$314 Def0131 +S A$_long2fs$305 Def0122 +S A$_long2fs$260 Def00DD +S A$_long2fs$242 Def00C4 +S A$_long2fs$233 Def00B9 +S A$_long2fs$224 Def00B0 +S A$_long2fs$215 Def00A6 +S A$_long2fs$206 Def009B +S A$_long2fs$170 Def0073 +S A$_long2fs$143 Def0058 +S A$_long2fs$125 Def0047 +S A$_long2fs$107 Def0037 +S A$_long2fs$333 Def0145 +S A$_long2fs$324 Def013B +S A$_long2fs$315 Def0132 +S A$_long2fs$306 Def0123 +S A$_long2fs$270 Def00E7 +S A$_long2fs$261 Def00DE +S A$_long2fs$252 Def00D1 +S A$_long2fs$243 Def00C5 +S A$_long2fs$234 Def00BA +S A$_long2fs$225 Def00B1 +S A$_long2fs$216 Def00A8 +S A$_long2fs$207 Def009C +S A$_long2fs$180 Def007F +S A$_long2fs$171 Def0074 +S A$_long2fs$162 Def006C +S A$_long2fs$144 Def0059 +S A$_long2fs$135 Def004E +S A$_long2fs$126 Def0048 +S A$_long2fs$117 Def0040 +S A$_long2fs$108 Def0038 +S A$_long2fs$334 Def0146 +S A$_long2fs$316 Def0133 +S A$_long2fs$307 Def0125 +S A$_long2fs$280 Def00F9 +S A$_long2fs$271 Def00E9 +S A$_long2fs$262 Def00DF +S A$_long2fs$244 Def00C6 +S A$_long2fs$235 Def00BD +S A$_long2fs$226 Def00B2 +S A$_long2fs$217 Def00A9 +S A$_long2fs$208 Def009D +S A$_long2fs$190 Def0089 +S A$_long2fs$181 Def0080 +S A$_long2fs$172 Def0076 +S A$_long2fs$163 Def006D +S A$_long2fs$154 Def0065 +S A$_long2fs$145 Def005A +S A$_long2fs$136 Def0051 +S A$_long2fs$127 Def0049 +S A$_long2fs$109 Def0039 +S A$_long2fs$335 Def0147 +S A$_long2fs$326 Def013C +S A$_long2fs$317 Def0134 +S A$_long2fs$308 Def0126 +S A$_long2fs$290 Def010B +S A$_long2fs$281 Def00FA +S A$_long2fs$272 Def00EB +S A$_long2fs$263 Def00E0 +S A$_long2fs$245 Def00C7 +S A$_long2fs$236 Def00BE +S A$_long2fs$227 Def00B3 +S A$_long2fs$209 Def009E +S A$_long2fs$182 Def0081 +S A$_long2fs$164 Def006E +S A$_long2fs$137 Def0052 +S A$_long2fs$345 Def0150 +S A$_long2fs$336 Def0148 +S A$_long2fs$327 Def013F +S A$_long2fs$318 Def0135 +S A$_long2fs$309 Def0128 +S A$_long2fs$291 Def010C +S A$_long2fs$282 Def00FC +S A$_long2fs$273 Def00ED +S A$_long2fs$264 Def00E1 +S A$_long2fs$255 Def00D4 +S A$_long2fs$237 Def00BF +S A$_long2fs$228 Def00B4 +S A$_long2fs$219 Def00AB +S A$_long2fs$183 Def0082 +S A$_long2fs$174 Def0077 +S A$_long2fs$165 Def006F +S A$_long2fs$156 Def0066 +S A$_long2fs$147 Def005B +S A$_long2fs$138 Def0053 +S A$_long2fs$328 Def0140 +S A$_long2fs$319 Def0136 +S A$_long2fs$292 Def010D +S A$_long2fs$283 Def00FE +S A$_long2fs$274 Def00EF +S A$_long2fs$265 Def00E2 +S A$_long2fs$256 Def00D7 +S A$_long2fs$247 Def00C8 +S A$_long2fs$238 Def00C0 +S A$_long2fs$229 Def00B5 +S A$_long2fs$193 Def008A +S A$_long2fs$184 Def0083 +S A$_long2fs$175 Def007A +S A$_long2fs$166 Def0070 +S A$_long2fs$148 Def005C +S A$_long2fs$139 Def0054 +S A$_long2fs$338 Def0149 +S A$_long2fs$329 Def0141 +S A$_long2fs$293 Def010E +S A$_long2fs$284 Def0101 +S A$_long2fs$275 Def00F0 +S A$_long2fs$266 Def00E3 +S A$_long2fs$257 Def00DA +S A$_long2fs$248 Def00CA +S A$_long2fs$239 Def00C1 +S A$_long2fs$194 Def008B +S A$_long2fs$185 Def0084 +S A$_long2fs$176 Def007B +S A$_long2fs$149 Def005E +S A$_long2fs$339 Def014A +S A$_long2fs$294 Def010F +S A$_long2fs$285 Def0104 +S A$_long2fs$276 Def00F2 +S A$_long2fs$267 Def00E4 +S A$_long2fs$258 Def00DB +S A$_long2fs$249 Def00CC +S A$_long2fs$195 Def008D +S A$_long2fs$186 Def0085 +S A$_long2fs$177 Def007C +S A$_long2fs$168 Def0071 +S A$_long2fs$159 Def0069 +S A$_long2fs$295 Def0110 +S A$_long2fs$286 Def0107 +S A$_long2fs$277 Def00F4 +S A$_long2fs$259 Def00DC +S A$_long2fs$187 Def0086 +S A$_long2fs$178 Def007D +S A$_long2fs$169 Def0072 +S A$_long2fs$296 Def0111 +S A$_long2fs$287 Def0108 +S A$_long2fs$278 Def00F6 +S A$_long2fs$269 Def00E5 +S A$_long2fs$197 Def0090 +S A$_long2fs$188 Def0087 +S A$_long2fs$179 Def007E +S XG$__long2fs$0$0 Def0150 +S A$_long2fs$297 Def0112 +S A$_long2fs$288 Def0109 +S A$_long2fs$279 Def00F7 +S A$_long2fs$198 Def0093 +S A$_long2fs$189 Def0088 +S A$_long2fs$298 Def0114 +S A$_long2fs$289 Def010A +S A$_long2fs$199 Def0094 +S A$_long2fs$299 Def0116 +S A$_long2fs$70 Def0000 +S A$_long2fs$80 Def0012 +S A$_long2fs$71 Def0002 +S A$_long2fs$90 Def001F +S A$_long2fs$81 Def0014 +S A$_long2fs$72 Def0004 +S G$__long2fs$0$0 Def0000 +S A$_long2fs$91 Def0020 +S A$_long2fs$82 Def0015 +S A$_long2fs$73 Def0006 +S A$_long2fs$92 Def0021 +S A$_long2fs$83 Def0016 +S A$_long2fs$74 Def0008 +S A$_long2fs$93 Def0022 +S A$_long2fs$84 Def0018 +S A$_long2fs$75 Def000B +S A$_long2fs$94 Def0025 +S A$_long2fs$85 Def0019 +S A$_long2fs$76 Def000D +S A$_long2fs$95 Def0026 +S A$_long2fs$77 Def000E +S A$_long2fs$96 Def0029 +S A$_long2fs$87 Def001A +S A$_long2fs$78 Def0010 +S A$_long2fs$97 Def002A +S A$_long2fs$88 Def001D +S A$_long2fs$79 Def0011 +S A$_long2fs$98 Def002D +S A$_long2fs$89 Def001E +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E4 A3 A3 A3 F0 12 00 00 F0 12 00 00 +R 00 00 00 07 00 02 00 05 02 0A 00 00 02 0E 00 00 +T 00 29 F0 12 00 00 F0 90 00 00 E0 FA A3 E0 FB A3 +R 00 00 00 07 02 04 00 00 00 08 00 05 +T 00 37 E0 FC A3 E0 FD EA 4B 4C 4D 70 23 +R 00 00 00 07 +T 00 42 +R 00 00 00 07 +T 00 42 90 00 08 E4 F0 A3 F0 A3 E4 F0 A3 F0 90 +R 00 00 00 07 00 03 00 05 +T 00 4F 00 08 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 8E +R 00 00 00 07 00 02 00 05 +T 00 5D 82 8F 83 88 F0 02 01 50 +R 00 00 00 07 00 08 00 07 +T 00 65 +R 00 00 00 07 +T 00 65 ED 30 E7 21 +R 00 00 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 90 00 04 E4 F0 A3 F0 A3 E4 F0 A3 74 80 F0 +R 00 00 00 07 00 03 00 05 +T 00 77 90 00 00 C3 E4 9A F0 E4 9B A3 F0 E4 9C A3 +R 00 00 00 07 00 03 00 05 +T 00 85 F0 E4 9D A3 F0 +R 00 00 00 07 +T 00 8A +R 00 00 00 07 +T 00 8A E4 F5 00 01 75 00 00 96 +R 00 00 00 07 29 04 00 01 29 07 00 01 +T 00 90 +R 00 00 00 07 +T 00 90 90 00 00 E0 FC A3 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 9E C3 EC 94 00 ED 94 00 EE 94 80 EF 94 00 50 +R 00 00 00 07 +T 00 AC 27 +R 00 00 00 07 +T 00 AD +R 00 00 00 07 +T 00 AD EC 25 E0 F8 ED 33 F9 EE 33 FA EF 33 FB 90 +R 00 00 00 07 +T 00 BB 00 00 E8 F0 A3 E9 F0 A3 EA F0 A3 EB F0 15 +R 00 00 00 07 00 02 00 05 +T 00 C9 00 00 74 FF B5 00 00 02 15 00 01 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 00 D1 +R 00 00 00 07 +T 00 D1 02 00 90 +R 00 00 00 07 00 03 00 07 +T 00 D4 +R 00 00 00 07 +T 00 D4 53 06 7F 90 00 00 EC F0 A3 ED F0 A3 EE F0 +R 00 00 00 07 00 06 00 05 +T 00 E2 A3 EF F0 AA 00 00 AB 00 01 78 00 79 00 8A +R 00 00 00 07 29 06 00 01 29 09 00 01 +T 00 EE 00 04 EB 54 01 A2 E0 C5 00 04 13 C5 00 04 +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 00 F9 13 C5 00 04 F5 00 05 75 00 03 00 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 01 02 00 02 00 90 00 04 E0 FA A3 E0 FB A3 E0 F8 +R 00 00 00 07 29 02 00 01 00 06 00 05 +T 01 0F A3 E0 F9 E5 00 02 42 02 E5 00 03 42 03 E5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 01 1B 00 04 42 00 E5 00 05 42 01 EA 42 04 EB 42 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 01 27 05 E8 42 06 E9 42 07 90 00 08 EC F0 A3 ED +R 00 00 00 07 00 0A 00 05 +T 01 35 F0 A3 EE F0 A3 EF F0 90 00 08 E0 FA A3 E0 +R 00 00 00 07 00 0A 00 05 +T 01 43 FB A3 E0 FC A3 E0 FD 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 50 +R 00 00 00 07 +T 01 50 22 +R 00 00 00 07 diff --git a/device/lib/large/_memcmp.asm b/device/lib/large/_memcmp.asm new file mode 100644 index 00000000..0b475d07 --- /dev/null +++ b/device/lib/large/_memcmp.asm @@ -0,0 +1,208 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + +;-------------------------------------------------------- + .module _memcmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _memcmp_PARM_3 + .globl _memcmp_PARM_2 + .globl _memcmp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_memcmp_PARM_2: + .ds 0x0003 +_memcmp_PARM_3: + .ds 0x0002 +_memcmp_buf1_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$memcmp$0$0 ==. +; _memcmp.c 27 +; ----------------------------------------- +; function memcmp +; ----------------------------------------- +_memcmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _memcmp.c 0 + push b + push dph + push dpl + mov dptr,#_memcmp_buf1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _memcmp.c 33 + mov dptr,#_memcmp_PARM_3 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r3,a + orl a,r2 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00112$ +00113$: +; _memcmp.c 34 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00107$ +; _memcmp.c 36 +00112$: + mov dptr,#_memcmp_buf1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#_memcmp_PARM_2 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a +00104$: + mov dptr,#_memcmp_PARM_3 + movx a,@dptr + add a,#0xff + mov r0,a + inc dptr + movx a,@dptr + addc a,#0xff + mov r1,a + mov dptr,#_memcmp_PARM_3 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + mov a,r0 + orl a,r1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00114$: + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r0,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r1,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar0,00106$ +; Peephole 201 removed redundant sjmp +00115$: +00116$: +; _memcmp.c 37 + inc r2 + cjne r2,#0x00,00117$ + inc r3 +00117$: + mov dptr,#_memcmp_buf1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _memcmp.c 38 + inc r5 + cjne r5,#0x00,00118$ + inc r6 +00118$: + ljmp 00104$ +00106$: +; _memcmp.c 41 + mov dptr,#_memcmp_buf1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 106 removed redundant mov + mov r2,a + clr c + subb a,r5 + mov r2,a +; Peephole 180 changed mov to clr + clr a + subb a,#0x00 + mov r5,a + mov dpl,r2 + mov dph,r5 +00107$: + C$_memcmp.c$42$1$1 ==. + XG$memcmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_memcmp.cdb b/device/lib/large/_memcmp.cdb new file mode 100644 index 00000000..034eb8cd --- /dev/null +++ b/device/lib/large/_memcmp.cdb @@ -0,0 +1,2 @@ +M:_memcmp +F:G$memcmp$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_memcmp.rel b/device/lib/large/_memcmp.rel new file mode 100644 index 00000000..65504065 --- /dev/null +++ b/device/lib/large/_memcmp.rel @@ -0,0 +1,201 @@ +;!FILE _memcmp.asm +XH +H 8 areas 77 global symbols +M _memcmp +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S _memcmp_PARM_2 Def0000 +S _memcmp_PARM_3 Def0003 +A GSINIT size 0 flags 20 +A CSEG size AD flags 20 +S A$_memcmp$100 Def0029 +S A$_memcmp$200 Def00A5 +S A$_memcmp$110 Def0035 +S A$_memcmp$101 Def002A +S A$_memcmp$201 Def00A7 +S A$_memcmp$120 Def0041 +S A$_memcmp$111 Def0036 +S A$_memcmp$102 Def002B +S A$_memcmp$202 Def00A8 +S A$_memcmp$130 Def004E +S A$_memcmp$121 Def0042 +S A$_memcmp$112 Def0037 +S A$_memcmp$103 Def002C +S A$_memcmp$203 Def00AA +S A$_memcmp$140 Def005C +S A$_memcmp$131 Def004F +S A$_memcmp$122 Def0043 +S A$_memcmp$113 Def0038 +S A$_memcmp$104 Def002D +S A$_memcmp$141 Def005D +S A$_memcmp$132 Def0050 +S A$_memcmp$123 Def0044 +S A$_memcmp$114 Def0039 +S A$_memcmp$105 Def002E +S A$_memcmp$160 Def0073 +S A$_memcmp$142 Def005F +S A$_memcmp$124 Def0046 +S A$_memcmp$115 Def003A +S A$_memcmp$106 Def002F +S _memcmp Def0000 +S A$_memcmp$170 Def007E +S A$_memcmp$161 Def0074 +S A$_memcmp$143 Def0061 +S A$_memcmp$134 Def0051 +S A$_memcmp$125 Def0047 +S A$_memcmp$107 Def0030 +S A$_memcmp$207 Def00AC +S A$_memcmp$180 Def0089 +S A$_memcmp$162 Def0075 +S A$_memcmp$144 Def0063 +S A$_memcmp$126 Def004A +S A$_memcmp$117 Def003B +S A$_memcmp$108 Def0033 +S A$_memcmp$190 Def0099 +S A$_memcmp$181 Def008A +S A$_memcmp$172 Def007F +S A$_memcmp$163 Def0076 +S A$_memcmp$154 Def006A +S A$_memcmp$136 Def0053 +S A$_memcmp$127 Def004B +S A$_memcmp$118 Def003E +S A$_memcmp$109 Def0034 +S A$_memcmp$191 Def009B +S A$_memcmp$182 Def008B +S A$_memcmp$164 Def0077 +S A$_memcmp$155 Def006B +S A$_memcmp$146 Def0066 +S A$_memcmp$137 Def0055 +S A$_memcmp$128 Def004C +S A$_memcmp$119 Def003F +S A$_memcmp$192 Def009D +S A$_memcmp$183 Def008C +S A$_memcmp$165 Def0078 +S A$_memcmp$156 Def006E +S A$_memcmp$138 Def0057 +S A$_memcmp$129 Def004D +S A$_memcmp$184 Def008D +S A$_memcmp$175 Def0082 +S A$_memcmp$166 Def0079 +S A$_memcmp$139 Def0059 +S A$_memcmp$194 Def00A0 +S A$_memcmp$185 Def008F +S A$_memcmp$176 Def0085 +S A$_memcmp$158 Def006F +S A$_memcmp$149 Def0067 +S A$_memcmp$195 Def00A1 +S A$_memcmp$186 Def0091 +S A$_memcmp$177 Def0086 +S A$_memcmp$168 Def007A +S A$_memcmp$159 Def0072 +S A$_memcmp$196 Def00A2 +S A$_memcmp$187 Def0093 +S A$_memcmp$178 Def0087 +S A$_memcmp$169 Def007B +S A$_memcmp$197 Def00A3 +S A$_memcmp$188 Def0096 +S A$_memcmp$179 Def0088 +S A$_memcmp$189 Def0097 +S A$_memcmp$199 Def00A4 +S XG$memcmp$0$0 Def00AC +S C$_memcmp.c$42$1$1 Def00AC +S A$_memcmp$70 Def0004 +S A$_memcmp$71 Def0006 +S A$_memcmp$90 Def001D +S A$_memcmp$81 Def0014 +S A$_memcmp$72 Def0009 +S A$_memcmp$82 Def0017 +S A$_memcmp$73 Def000B +S A$_memcmp$83 Def0018 +S A$_memcmp$74 Def000C +S G$memcmp$0$0 Def0000 +S A$_memcmp$84 Def0019 +S A$_memcmp$75 Def000E +S A$_memcmp$94 Def001F +S A$_memcmp$85 Def001A +S A$_memcmp$76 Def000F +S A$_memcmp$95 Def0022 +S A$_memcmp$77 Def0010 +S A$_memcmp$68 Def0000 +S A$_memcmp$87 Def001B +S A$_memcmp$78 Def0012 +S A$_memcmp$69 Def0002 +S A$_memcmp$88 Def001C +S A$_memcmp$79 Def0013 +S A$_memcmp$98 Def0025 +S A$_memcmp$99 Def0028 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 05 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C 4A 70 06 +R 00 00 00 07 +T 00 1F +R 00 00 00 07 +T 00 1F 90 00 00 02 00 AC +R 00 00 00 07 00 06 00 07 +T 00 25 +R 00 00 00 07 +T 00 25 90 00 05 E0 FA A3 E0 FB A3 E0 FC 90 00 00 +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 00 33 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 +T 00 3B +R 00 00 00 07 +T 00 3B 90 00 03 E0 24 FF F8 A3 E0 34 FF F9 90 +R 00 00 00 07 00 03 00 05 +T 00 48 00 03 E8 F0 A3 E9 F0 E8 49 60 2F +R 00 00 00 07 00 02 00 05 +T 00 53 +R 00 00 00 07 +T 00 53 8D 82 8E 83 8F F0 12 00 00 F8 8A 82 8B 83 +R 00 00 00 07 02 09 00 00 +T 00 61 8C F0 12 00 00 F9 B5 00 18 +R 00 00 00 07 02 05 00 00 +T 00 6A +R 00 00 00 07 +T 00 6A +R 00 00 00 07 +T 00 6A 0A BA 00 01 0B +R 00 00 00 07 +T 00 6F +R 00 00 00 07 +T 00 6F 90 00 05 EA F0 A3 EB F0 A3 EC F0 0D BD 00 +R 00 00 00 07 00 03 00 05 +T 00 7D 01 0E +R 00 00 00 07 +T 00 7F +R 00 00 00 07 +T 00 7F 02 00 3B +R 00 00 00 07 00 03 00 07 +T 00 82 +R 00 00 00 07 +T 00 82 90 00 05 EA F0 A3 EB F0 A3 EC F0 8D 82 8E +R 00 00 00 07 00 03 00 05 +T 00 90 83 8F F0 12 00 00 FD 8A 82 8B 83 8C F0 12 +R 00 00 00 07 02 06 00 00 +T 00 9E 00 00 FA C3 9D FA E4 94 00 FD 8A 82 8D 83 +R 00 00 00 07 02 02 00 00 +T 00 AC +R 00 00 00 07 +T 00 AC 22 +R 00 00 00 07 diff --git a/device/lib/large/_memcpy.asm b/device/lib/large/_memcpy.asm new file mode 100644 index 00000000..da293651 --- /dev/null +++ b/device/lib/large/_memcpy.asm @@ -0,0 +1,164 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + +;-------------------------------------------------------- + .module _memcpy +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _memcpy_PARM_3 + .globl _memcpy_PARM_2 + .globl _memcpy +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_memcpy_sloc0_1_0: + .ds 0x0003 +_memcpy_sloc1_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_memcpy_PARM_2: + .ds 0x0003 +_memcpy_PARM_3: + .ds 0x0002 +_memcpy_dst_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$memcpy$0$0 ==. +; _memcpy.c 27 +; ----------------------------------------- +; function memcpy +; ----------------------------------------- +_memcpy: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _memcpy.c 44 + push b + push dph + push dpl + mov dptr,#_memcpy_dst_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _memcpy.c 33 + mov dptr,#_memcpy_dst_1_1 + movx a,@dptr + mov _memcpy_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (_memcpy_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_memcpy_sloc1_1_0 + 2),a +; _memcpy.c 35 + mov dptr,#_memcpy_PARM_2 + movx a,@dptr + mov _memcpy_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_memcpy_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_memcpy_sloc0_1_0 + 2),a +; _memcpy.c 40 + mov r0,_memcpy_sloc1_1_0 + mov r1,(_memcpy_sloc1_1_0 + 1) + mov r5,(_memcpy_sloc1_1_0 + 2) + mov dptr,#_memcpy_PARM_3 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +00101$: + mov ar2,r3 + mov ar6,r4 + dec r3 + cjne r3,#0xff,00108$ + dec r4 +00108$: + mov a,r2 + orl a,r6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _memcpy.c 41 + push ar3 + push ar4 + mov ar2,r0 + mov ar6,r1 + mov ar7,r5 + inc r0 + cjne r0,#0x00,00110$ + inc r1 +00110$: + mov dpl,_memcpy_sloc0_1_0 + mov dph,(_memcpy_sloc0_1_0 + 1) + mov b,(_memcpy_sloc0_1_0 + 2) + inc _memcpy_sloc0_1_0 + clr a + cjne a,_memcpy_sloc0_1_0,00111$ + inc (_memcpy_sloc0_1_0 + 1) +00111$: + lcall __gptrget +; Peephole 191 removed redundant mov + mov r3,a + mov dpl,r2 + mov dph,r6 + mov b,r7 + lcall __gptrput + pop ar4 + pop ar3 +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _memcpy.c 44 + mov dpl,_memcpy_sloc1_1_0 + mov dph,(_memcpy_sloc1_1_0 + 1) + mov b,(_memcpy_sloc1_1_0 + 2) +00104$: + C$_memcpy.c$45$1$1 ==. + XG$memcpy$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_memcpy.cdb b/device/lib/large/_memcpy.cdb new file mode 100644 index 00000000..3d6826c0 --- /dev/null +++ b/device/lib/large/_memcpy.cdb @@ -0,0 +1,2 @@ +M:_memcpy +F:G$memcpy$0$0({2}DF,DG,SV:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_memcpy.rel b/device/lib/large/_memcpy.rel new file mode 100644 index 00000000..031b5e0f --- /dev/null +++ b/device/lib/large/_memcpy.rel @@ -0,0 +1,163 @@ +;!FILE _memcpy.asm +XH +H 8 areas 53 global symbols +M _memcpy +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S _memcpy_PARM_2 Def0000 +S _memcpy_PARM_3 Def0003 +A GSINIT size 0 flags 20 +A CSEG size 88 flags 20 +S A$_memcpy$85 Def0014 +S A$_memcpy$76 Def0009 +S A$_memcpy$95 Def0022 +S A$_memcpy$86 Def0017 +S A$_memcpy$77 Def000B +S A$_memcpy$96 Def0025 +S A$_memcpy$87 Def0018 +S A$_memcpy$78 Def000C +S A$_memcpy$97 Def0026 +S A$_memcpy$88 Def001A +S A$_memcpy$79 Def000E +S A$_memcpy$98 Def0028 +S A$_memcpy$89 Def001B +S A$_memcpy$99 Def0029 +S A$_memcpy$100 Def002A +S A$_memcpy$110 Def003A +S A$_memcpy$101 Def002C +S A$_memcpy$111 Def003B +S A$_memcpy$102 Def002D +S A$_memcpy$130 Def0051 +S A$_memcpy$121 Def0047 +S A$_memcpy$112 Def003C +S A$_memcpy$103 Def002E +S A$_memcpy$140 Def0065 +S A$_memcpy$131 Def0053 +S A$_memcpy$122 Def0048 +S A$_memcpy$113 Def003D +S A$_memcpy$150 Def0075 +S A$_memcpy$141 Def0066 +S A$_memcpy$132 Def0055 +S A$_memcpy$105 Def0030 +S A$_memcpy$151 Def0078 +S A$_memcpy$142 Def0069 +S A$_memcpy$133 Def0056 +S A$_memcpy$124 Def0049 +S A$_memcpy$115 Def003E +S A$_memcpy$106 Def0032 +S _memcpy Def0000 +S A$_memcpy$152 Def007A +S A$_memcpy$134 Def0059 +S A$_memcpy$116 Def0040 +S A$_memcpy$107 Def0034 +S A$_memcpy$144 Def006B +S A$_memcpy$117 Def0042 +S A$_memcpy$108 Def0036 +S A$_memcpy$163 Def0087 +S A$_memcpy$154 Def007C +S A$_memcpy$136 Def005A +S A$_memcpy$127 Def004B +S A$_memcpy$118 Def0043 +S A$_memcpy$109 Def0039 +S A$_memcpy$146 Def006E +S A$_memcpy$137 Def005D +S A$_memcpy$128 Def004D +S A$_memcpy$119 Def0046 +S A$_memcpy$147 Def006F +S A$_memcpy$138 Def0060 +S A$_memcpy$129 Def004F +S A$_memcpy$157 Def007E +S A$_memcpy$148 Def0071 +S A$_memcpy$139 Def0063 +S A$_memcpy$158 Def0081 +S A$_memcpy$149 Def0073 +S A$_memcpy$159 Def0084 +S XG$memcpy$0$0 Def0087 +S C$_memcpy.c$45$1$1 Def0087 +S A$_memcpy$80 Def000F +S A$_memcpy$90 Def001C +S A$_memcpy$81 Def0010 +S A$_memcpy$72 Def0000 +S A$_memcpy$91 Def001E +S A$_memcpy$82 Def0012 +S A$_memcpy$73 Def0002 +S A$_memcpy$92 Def001F +S A$_memcpy$83 Def0013 +S A$_memcpy$74 Def0004 +S G$memcpy$0$0 Def0000 +S A$_memcpy$93 Def0020 +S A$_memcpy$75 Def0006 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 05 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 05 E0 F5 00 03 A3 +R 00 00 00 07 00 09 00 05 29 0D 00 01 +T 00 1B E0 F5 00 04 A3 E0 F5 00 05 90 00 00 E0 F5 +R 00 00 00 07 29 04 00 01 29 09 00 01 00 0C 00 05 +T 00 27 00 00 A3 E0 F5 00 01 A3 E0 F5 00 02 A8 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 31 00 03 A9 00 04 AD 00 05 90 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 37 00 03 E0 FB A3 E0 FC +R 00 00 00 07 00 02 00 05 +T 00 3E +R 00 00 00 07 +T 00 3E 8B 02 8C 06 1B BB FF 01 1C +R 00 00 00 07 +T 00 47 +R 00 00 00 07 +T 00 47 EA 4E 60 33 +R 00 00 00 07 +T 00 4B +R 00 00 00 07 +T 00 4B C0 03 C0 04 88 02 89 06 8D 07 08 B8 00 01 +R 00 00 00 07 +T 00 59 09 +R 00 00 00 07 +T 00 5A +R 00 00 00 07 +T 00 5A 85 00 00 82 85 00 01 83 85 00 02 F0 05 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 64 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 6B +R 00 00 00 07 +T 00 6B 12 00 00 FB 8A 82 8E 83 8F F0 12 00 00 D0 +R 00 00 00 07 02 03 00 01 02 0D 00 00 +T 00 79 04 D0 03 80 C0 +R 00 00 00 07 +T 00 7E +R 00 00 00 07 +T 00 7E 85 00 03 82 85 00 04 83 85 00 05 F0 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 87 +R 00 00 00 07 +T 00 87 22 +R 00 00 00 07 diff --git a/device/lib/large/_memset.asm b/device/lib/large/_memset.asm new file mode 100644 index 00000000..d76aaeed --- /dev/null +++ b/device/lib/large/_memset.asm @@ -0,0 +1,143 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + +;-------------------------------------------------------- + .module _memset +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _memset_PARM_3 + .globl _memset_PARM_2 + .globl _memset +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_memset_PARM_2: + .ds 0x0001 +_memset_PARM_3: + .ds 0x0002 +_memset_buf_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$memset$0$0 ==. +; _memset.c 27 +; ----------------------------------------- +; function memset +; ----------------------------------------- +_memset: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _memset.c 40 + push b + push dph + push dpl + mov dptr,#_memset_buf_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _memset.c 33 + mov dptr,#_memset_buf_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +; _memset.c 35 + mov dptr,#_memset_PARM_2 + movx a,@dptr + mov r5,a + mov dptr,#_memset_PARM_3 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a +00101$: + mov ar0,r6 + mov ar1,r7 + dec r6 + cjne r6,#0xff,00108$ + dec r7 +00108$: + mov a,r0 + orl a,r1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _memset.c 36 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 + lcall __gptrput +; _memset.c 37 + inc r2 + cjne r2,#0x00,00110$ + inc r3 +00110$: +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _memset.c 40 + mov dptr,#_memset_buf_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00104$: + C$_memset.c$41$1$1 ==. + XG$memset$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_memset.cdb b/device/lib/large/_memset.cdb new file mode 100644 index 00000000..f04d3149 --- /dev/null +++ b/device/lib/large/_memset.cdb @@ -0,0 +1,2 @@ +M:_memset +F:G$memset$0$0({2}DF,DG,SV:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_memset.rel b/device/lib/large/_memset.rel new file mode 100644 index 00000000..b465545a --- /dev/null +++ b/device/lib/large/_memset.rel @@ -0,0 +1,129 @@ +;!FILE _memset.asm +XH +H 8 areas 43 global symbols +M _memset +S __gptrput Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 6 flags 40 +S _memset_PARM_2 Def0000 +S _memset_PARM_3 Def0001 +A GSINIT size 0 flags 20 +A CSEG size 5C flags 20 +S A$_memset$94 Def0024 +S A$_memset$85 Def001A +S A$_memset$76 Def000F +S A$_memset$95 Def0027 +S A$_memset$86 Def001B +S A$_memset$77 Def0010 +S A$_memset$68 Def0000 +S A$_memset$96 Def0028 +S A$_memset$87 Def001C +S A$_memset$78 Def0012 +S A$_memset$69 Def0002 +S A$_memset$97 Def0029 +S A$_memset$88 Def001D +S A$_memset$79 Def0013 +S A$_memset$98 Def002A +S A$_memset$89 Def001E +S A$_memset$99 Def002B +S A$_memset$110 Def0037 +S A$_memset$101 Def002C +S A$_memset$120 Def0044 +S A$_memset$102 Def002E +S A$_memset$130 Def004F +S A$_memset$121 Def0047 +S A$_memset$103 Def0030 +S A$_memset$131 Def0050 +S A$_memset$113 Def0039 +S A$_memset$104 Def0031 +S A$_memset$132 Def0051 +S A$_memset$114 Def003B +S A$_memset$105 Def0034 +S A$_memset$142 Def005B +S A$_memset$133 Def0052 +S A$_memset$124 Def0048 +S A$_memset$115 Def003D +S _memset Def0000 +S A$_memset$134 Def0053 +S A$_memset$116 Def003F +S A$_memset$107 Def0035 +S A$_memset$135 Def0054 +S A$_memset$117 Def0040 +S A$_memset$108 Def0036 +S A$_memset$136 Def0055 +S A$_memset$127 Def004A +S A$_memset$137 Def0057 +S A$_memset$128 Def004D +S A$_memset$119 Def0043 +S A$_memset$138 Def0059 +S A$_memset$129 Def004E +S C$_memset.c$41$1$1 Def005B +S XG$memset$0$0 Def005B +S A$_memset$70 Def0004 +S A$_memset$71 Def0006 +S A$_memset$81 Def0014 +S A$_memset$72 Def0009 +S A$_memset$91 Def001F +S A$_memset$82 Def0017 +S A$_memset$73 Def000B +S A$_memset$92 Def0022 +S A$_memset$83 Def0018 +S A$_memset$74 Def000C +S G$memset$0$0 Def0000 +S A$_memset$93 Def0023 +S A$_memset$84 Def0019 +S A$_memset$75 Def000E +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 90 00 00 E0 FD 90 00 01 E0 FE A3 +R 00 00 00 07 00 06 00 05 00 0B 00 05 +T 00 2A E0 FF +R 00 00 00 07 +T 00 2C +R 00 00 00 07 +T 00 2C 8E 00 8F 01 1E BE FF 01 1F +R 00 00 00 07 +T 00 35 +R 00 00 00 07 +T 00 35 E8 49 60 11 +R 00 00 00 07 +T 00 39 +R 00 00 00 07 +T 00 39 8A 82 8B 83 8C F0 ED 12 00 00 0A BA 00 01 +R 00 00 00 07 02 0A 00 00 +T 00 47 0B +R 00 00 00 07 +T 00 48 +R 00 00 00 07 +T 00 48 80 E2 +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A 90 00 03 E0 FA A3 E0 FB A3 E0 FC 8A 82 8B +R 00 00 00 07 00 03 00 05 +T 00 58 83 8C F0 +R 00 00 00 07 +T 00 5B +R 00 00 00 07 +T 00 5B 22 +R 00 00 00 07 diff --git a/device/lib/large/_modsint.asm b/device/lib/large/_modsint.asm new file mode 100644 index 00000000..d9f7885e --- /dev/null +++ b/device/lib/large/_modsint.asm @@ -0,0 +1,178 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:30 2000 + +;-------------------------------------------------------- + .module _modsint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __modsint_PARM_2 + .globl __modsint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__modsint_PARM_2: + .ds 0x0002 +__modsint_a_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_modsint$0$0 ==. +; _modsint.c 26 +; ----------------------------------------- +; function _modsint +; ----------------------------------------- +__modsint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _modsint.c 0 + push dph + push dpl + mov dptr,#__modsint_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _modsint.c 30 + mov dptr,#__modsint_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00113$: + clr c + clr a + subb a,r2 + mov r4,a + clr a + subb a,r3 + mov r5,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar4,r2 + mov ar5,r3 +00107$: + mov ar2,r4 + mov ar3,r5 +; _modsint.c 31 + mov dptr,#__modsint_PARM_2 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,r4 + mov r7,a + clr a + subb a,r5 + mov r0,a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov ar7,r4 + mov ar0,r5 +00109$: + mov dptr,#__moduint_PARM_2 + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + push ar6 + mov dpl,r2 + mov dph,r3 + lcall __moduint + mov r2,dpl + mov r3,dph + pop ar6 +; _modsint.c 33 + mov dptr,#__modsint_a_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a + mov r4,a + mov a,r6 + xrl a,ar4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _modsint.c 34 + clr c + clr a + subb a,r2 + mov r4,a + clr a + subb a,r3 + mov r6,a + mov dpl,r4 + mov dph,r6 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _modsint.c 36 + mov dpl,r2 + mov dph,r3 +00104$: + C$_modsint.c$37$1$1 ==. + XG$_modsint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_modsint.cdb b/device/lib/large/_modsint.cdb new file mode 100644 index 00000000..231bb3b5 --- /dev/null +++ b/device/lib/large/_modsint.cdb @@ -0,0 +1,2 @@ +M:_modsint +F:G$_modsint$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_modsint.rel b/device/lib/large/_modsint.rel new file mode 100644 index 00000000..228809c3 --- /dev/null +++ b/device/lib/large/_modsint.rel @@ -0,0 +1,162 @@ +;!FILE _modsint.asm +XH +H 8 areas 5E global symbols +M _modsint +S __moduint_PARM_2 Ref0000 +S __moduint Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 4 flags 40 +S __modsint_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 7F flags 20 +S XG$_modsint$0$0 Def007E +S G$_modsint$0$0 Def0000 +S A$_modsint$100 Def002A +S A$_modsint$101 Def002D +S A$_modsint$120 Def003D +S A$_modsint$111 Def0035 +S A$_modsint$102 Def002E +S A$_modsint$130 Def0049 +S A$_modsint$121 Def003E +S A$_modsint$103 Def002F +S A$_modsint$140 Def005A +S A$_modsint$131 Def004A +S A$_modsint$113 Def0036 +S A$_modsint$104 Def0030 +S A$_modsint$150 Def0065 +S A$_modsint$132 Def004B +S A$_modsint$123 Def003F +S A$_modsint$160 Def006E +S A$_modsint$151 Def0066 +S A$_modsint$142 Def005C +S A$_modsint$133 Def004C +S A$_modsint$115 Def0038 +S A$_modsint$106 Def0031 +S A$_modsint$161 Def006F +S A$_modsint$152 Def0067 +S A$_modsint$143 Def005F +S A$_modsint$134 Def004D +S A$_modsint$125 Def0041 +S A$_modsint$116 Def0039 +S A$_modsint$107 Def0032 +S A$_modsint$162 Def0070 +S A$_modsint$153 Def0068 +S A$_modsint$144 Def0060 +S A$_modsint$135 Def004F +S A$_modsint$126 Def0043 +S A$_modsint$117 Def003A +S A$_modsint$108 Def0033 +S A$_modsint$172 Def007A +S A$_modsint$163 Def0071 +S A$_modsint$154 Def0069 +S A$_modsint$145 Def0061 +S A$_modsint$136 Def0051 +S A$_modsint$118 Def003B +S A$_modsint$109 Def0034 +S A$_modsint$173 Def007C +S A$_modsint$164 Def0072 +S A$_modsint$146 Def0062 +S A$_modsint$137 Def0053 +S A$_modsint$128 Def0045 +S A$_modsint$119 Def003C +S A$_modsint$165 Def0073 +S A$_modsint$156 Def006B +S A$_modsint$138 Def0056 +S A$_modsint$129 Def0048 +S A$_modsint$166 Def0074 +S A$_modsint$148 Def0063 +S A$_modsint$139 Def0058 +S A$_modsint$167 Def0076 +S A$_modsint$149 Def0064 +S A$_modsint$177 Def007E +S A$_modsint$159 Def006D +S A$_modsint$169 Def0078 +S A$_modsint$70 Def000A +S C$_modsint.c$37$1$1 Def007E +S A$_modsint$80 Def0015 +S A$_modsint$71 Def000C +S A$_modsint$90 Def001F +S A$_modsint$72 Def000D +S A$_modsint$82 Def0016 +S A$_modsint$92 Def0020 +S A$_modsint$74 Def000E +S A$_modsint$65 Def0000 +S A$_modsint$84 Def0019 +S A$_modsint$75 Def0011 +S A$_modsint$66 Def0002 +S A$_modsint$94 Def0022 +S A$_modsint$85 Def001A +S A$_modsint$76 Def0012 +S A$_modsint$67 Def0004 +S A$_modsint$95 Def0024 +S A$_modsint$86 Def001B +S A$_modsint$77 Def0013 +S A$_modsint$68 Def0007 +S A$_modsint$87 Def001C +S A$_modsint$78 Def0014 +S A$_modsint$69 Def0009 +S A$_modsint$97 Def0026 +S A$_modsint$88 Def001D +S A$_modsint$98 Def0028 +S A$_modsint$89 Def001E +S __modsint Def0000 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 02 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 02 E0 FA A3 E0 FB 30 E7 09 +R 00 00 00 07 00 03 00 05 +T 00 19 +R 00 00 00 07 +T 00 19 C3 E4 9A FC E4 9B FD 80 04 +R 00 00 00 07 +T 00 22 +R 00 00 00 07 +T 00 22 8A 04 8B 05 +R 00 00 00 07 +T 00 26 +R 00 00 00 07 +T 00 26 8C 02 8D 03 90 00 00 E0 FC A3 E0 FD 33 E4 +R 00 00 00 07 00 07 00 05 +T 00 34 33 FE 60 09 +R 00 00 00 07 +T 00 38 +R 00 00 00 07 +T 00 38 C3 E4 9C FF E4 9D F8 80 04 +R 00 00 00 07 +T 00 41 +R 00 00 00 07 +T 00 41 8C 07 8D 00 +R 00 00 00 07 +T 00 45 +R 00 00 00 07 +T 00 45 90 00 00 EF F0 A3 E8 F0 C0 06 8A 82 8B 83 +R 00 00 00 07 02 03 00 00 +T 00 53 12 00 00 AA 82 AB 83 D0 06 90 00 02 E0 FC +R 00 00 00 07 02 03 00 01 00 0C 00 05 +T 00 61 A3 E0 FD 33 E4 33 FC EE 65 04 60 0D +R 00 00 00 07 +T 00 6D +R 00 00 00 07 +T 00 6D C3 E4 9A FC E4 9B FE 8C 82 8E 83 80 04 +R 00 00 00 07 +T 00 7A +R 00 00 00 07 +T 00 7A 8A 82 8B 83 +R 00 00 00 07 +T 00 7E +R 00 00 00 07 +T 00 7E 22 +R 00 00 00 07 diff --git a/device/lib/large/_modslong.asm b/device/lib/large/_modslong.asm new file mode 100644 index 00000000..dac091d9 --- /dev/null +++ b/device/lib/large/_modslong.asm @@ -0,0 +1,254 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + +;-------------------------------------------------------- + .module _modslong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __modslong_PARM_2 + .globl __modslong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__modslong_sloc0_1_0: + .ds 0x0004 +__modslong_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__modslong_PARM_2: + .ds 0x0004 +__modslong_a_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_modslong$0$0 ==. +; _modslong.c 24 +; ----------------------------------------- +; function _modslong +; ----------------------------------------- +__modslong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _modslong.c 0 + push acc + push b + push dph + push dpl + mov dptr,#__modslong_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _modslong.c 28 + mov dptr,#__modslong_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00113$: + clr c + clr a + subb a,r2 + mov r6,a + clr a + subb a,r3 + mov r7,a + clr a + subb a,r4 + mov r0,a + clr a + subb a,r5 + mov r1,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar6,r2 + mov ar7,r3 + mov ar0,r4 + mov ar1,r5 +00107$: + mov __modslong_sloc0_1_0,r6 + mov (__modslong_sloc0_1_0 + 1),r7 + mov (__modslong_sloc0_1_0 + 2),r0 + mov (__modslong_sloc0_1_0 + 3),r1 +; _modslong.c 29 + mov dptr,#__modslong_PARM_2 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r1,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,r6 + mov __modslong_sloc1_1_0,a + clr a + subb a,r7 + mov (__modslong_sloc1_1_0 + 1),a + clr a + subb a,r0 + mov (__modslong_sloc1_1_0 + 2),a + clr a + subb a,r1 + mov (__modslong_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov __modslong_sloc1_1_0,r6 + mov (__modslong_sloc1_1_0 + 1),r7 + mov (__modslong_sloc1_1_0 + 2),r0 + mov (__modslong_sloc1_1_0 + 3),r1 +00109$: + mov dptr,#__modulong_PARM_2 + mov a,__modslong_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(__modslong_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(__modslong_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(__modslong_sloc1_1_0 + 3) + movx @dptr,a + push ar2 + mov dpl,__modslong_sloc0_1_0 + mov dph,(__modslong_sloc0_1_0 + 1) + mov b,(__modslong_sloc0_1_0 + 2) + mov a,(__modslong_sloc0_1_0 + 3) + lcall __modulong + mov r3,dpl + mov r4,dph + mov r5,b + mov r6,a + pop ar2 +; _modslong.c 31 + push ar3 + push ar4 + push ar5 + push ar6 + mov dptr,#__modslong_a_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + rlc a + clr a + rlc a + mov r7,a + mov a,r2 + xrl a,ar7 + pop ar6 + pop ar5 + pop ar4 + pop ar3 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _modslong.c 32 + clr c + clr a + subb a,r3 + mov __modslong_sloc1_1_0,a + clr a + subb a,r4 + mov (__modslong_sloc1_1_0 + 1),a + clr a + subb a,r5 + mov (__modslong_sloc1_1_0 + 2),a + clr a + subb a,r6 +; Peephole 191 removed redundant mov + mov (__modslong_sloc1_1_0 + 3),a + mov dpl,__modslong_sloc1_1_0 + mov dph,(__modslong_sloc1_1_0 + 1) + mov b,(__modslong_sloc1_1_0 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _modslong.c 34 + mov dpl,r3 + mov dph,r4 + mov b,r5 + mov a,r6 +00104$: + C$_modslong.c$35$1$1 ==. + XG$_modslong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_modslong.cdb b/device/lib/large/_modslong.cdb new file mode 100644 index 00000000..5af6a222 --- /dev/null +++ b/device/lib/large/_modslong.cdb @@ -0,0 +1,2 @@ +M:_modslong +F:G$_modslong$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_modslong.rel b/device/lib/large/_modslong.rel new file mode 100644 index 00000000..4b81fb90 --- /dev/null +++ b/device/lib/large/_modslong.rel @@ -0,0 +1,265 @@ +;!FILE _modslong.asm +XH +H 8 areas A5 global symbols +M _modslong +S __modulong_PARM_2 Ref0000 +S __modulong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S __modslong_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size EF flags 20 +S A$_modslong$230 Def00D1 +S A$_modslong$212 Def00BB +S A$_modslong$203 Def00B3 +S A$_modslong$140 Def0057 +S A$_modslong$131 Def004F +S A$_modslong$113 Def0036 +S A$_modslong$104 Def002D +S A$_modslong$240 Def00DF +S A$_modslong$231 Def00D2 +S A$_modslong$222 Def00C9 +S A$_modslong$213 Def00BC +S A$_modslong$204 Def00B4 +S A$_modslong$150 Def005F +S A$_modslong$141 Def0058 +S A$_modslong$132 Def0050 +S A$_modslong$123 Def0042 +S A$_modslong$114 Def0037 +S A$_modslong$105 Def002E +S A$_modslong$241 Def00E2 +S A$_modslong$232 Def00D4 +S A$_modslong$214 Def00BD +S A$_modslong$205 Def00B5 +S A$_modslong$160 Def006C +S A$_modslong$151 Def0060 +S A$_modslong$142 Def0059 +S A$_modslong$133 Def0051 +S A$_modslong$124 Def0044 +S A$_modslong$106 Def002F +S A$_modslong$233 Def00D5 +S A$_modslong$215 Def00BE +S A$_modslong$206 Def00B6 +S A$_modslong$170 Def0079 +S A$_modslong$161 Def006D +S A$_modslong$152 Def0061 +S A$_modslong$143 Def005A +S A$_modslong$134 Def0052 +S A$_modslong$125 Def0046 +S A$_modslong$116 Def0038 +S A$_modslong$107 Def0030 +S A$_modslong$243 Def00E5 +S A$_modslong$234 Def00D6 +S A$_modslong$225 Def00CB +S A$_modslong$216 Def00BF +S A$_modslong$207 Def00B7 +S A$_modslong$180 Def0088 +S A$_modslong$171 Def007C +S A$_modslong$153 Def0063 +S A$_modslong$135 Def0053 +S A$_modslong$126 Def0048 +S A$_modslong$108 Def0031 +S A$_modslong$253 Def00EE +S A$_modslong$235 Def00D8 +S A$_modslong$226 Def00CC +S A$_modslong$217 Def00C1 +S A$_modslong$208 Def00B8 +S A$_modslong$190 Def009F +S A$_modslong$181 Def008A +S A$_modslong$172 Def007E +S A$_modslong$163 Def006F +S A$_modslong$154 Def0064 +S A$_modslong$145 Def005B +S A$_modslong$136 Def0054 +S A$_modslong$118 Def003A +S A$_modslong$109 Def0032 +S A$_modslong$236 Def00D9 +S A$_modslong$227 Def00CD +S A$_modslong$218 Def00C3 +S A$_modslong$191 Def00A1 +S A$_modslong$182 Def008B +S A$_modslong$173 Def007F +S A$_modslong$155 Def0065 +S A$_modslong$137 Def0055 +S A$_modslong$128 Def004A +S A$_modslong$119 Def003C +S A$_modslong$246 Def00E7 +S A$_modslong$228 Def00CE +S A$_modslong$219 Def00C5 +S A$_modslong$192 Def00A2 +S A$_modslong$183 Def008D +S A$_modslong$174 Def0080 +S A$_modslong$165 Def0071 +S A$_modslong$156 Def0067 +S A$_modslong$147 Def005C +S A$_modslong$138 Def0056 +S A$_modslong$129 Def004D +S A$_modslong$247 Def00E9 +S A$_modslong$238 Def00DA +S A$_modslong$229 Def00D0 +S A$_modslong$184 Def0090 +S A$_modslong$175 Def0082 +S A$_modslong$166 Def0073 +S A$_modslong$157 Def0068 +S A$_modslong$248 Def00EB +S A$_modslong$239 Def00DC +S A$_modslong$194 Def00A4 +S A$_modslong$185 Def0093 +S A$_modslong$176 Def0083 +S A$_modslong$167 Def0075 +S A$_modslong$158 Def0069 +S A$_modslong$149 Def005E +S A$_modslong$249 Def00ED +S A$_modslong$195 Def00A6 +S A$_modslong$186 Def0096 +S A$_modslong$177 Def0084 +S A$_modslong$168 Def0077 +S A$_modslong$159 Def006B +S A$_modslong$196 Def00A8 +S A$_modslong$187 Def0098 +S A$_modslong$178 Def0086 +S A$_modslong$197 Def00AA +S A$_modslong$188 Def009B +S A$_modslong$179 Def0087 +S A$_modslong$198 Def00AC +S A$_modslong$189 Def009D +S A$_modslong$199 Def00AF +S C$_modslong.c$35$1$1 Def00EE +S A$_modslong$70 Def0002 +S A$_modslong$80 Def0014 +S A$_modslong$71 Def0004 +S A$_modslong$90 Def0020 +S A$_modslong$81 Def0015 +S A$_modslong$72 Def0006 +S A$_modslong$91 Def0021 +S A$_modslong$82 Def0016 +S A$_modslong$73 Def0008 +S A$_modslong$92 Def0022 +S A$_modslong$83 Def0018 +S A$_modslong$74 Def000B +S A$_modslong$93 Def0023 +S A$_modslong$84 Def0019 +S A$_modslong$75 Def000D +S A$_modslong$94 Def0024 +S A$_modslong$76 Def000E +S A$_modslong$95 Def0025 +S A$_modslong$86 Def001A +S A$_modslong$77 Def0010 +S A$_modslong$96 Def0026 +S A$_modslong$87 Def001D +S A$_modslong$78 Def0011 +S A$_modslong$69 Def0000 +S A$_modslong$88 Def001E +S A$_modslong$79 Def0012 +S A$_modslong$98 Def0027 +S A$_modslong$89 Def001F +S __modslong Def0000 +S XG$_modslong$0$0 Def00EE +S G$_modslong$0$0 Def0000 +S A$_modslong$100 Def0028 +S A$_modslong$200 Def00B0 +S A$_modslong$110 Def0033 +S A$_modslong$210 Def00B9 +S A$_modslong$201 Def00B1 +S A$_modslong$120 Def003E +S A$_modslong$111 Def0034 +S A$_modslong$102 Def002B +S A$_modslong$220 Def00C7 +S A$_modslong$211 Def00BA +S A$_modslong$202 Def00B2 +S A$_modslong$130 Def004E +S A$_modslong$121 Def0040 +S A$_modslong$112 Def0035 +S A$_modslong$103 Def002C +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 30 +R 00 00 00 07 00 02 00 05 +T 00 29 E7 0F +R 00 00 00 07 +T 00 2B +R 00 00 00 07 +T 00 2B C3 E4 9A FE E4 9B FF E4 9C F8 E4 9D F9 80 +R 00 00 00 07 +T 00 39 08 +R 00 00 00 07 +T 00 3A +R 00 00 00 07 +T 00 3A 8A 06 8B 07 8C 00 8D 01 +R 00 00 00 07 +T 00 42 +R 00 00 00 07 +T 00 42 8E 00 00 8F 00 01 88 00 02 89 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 49 00 03 90 00 00 E0 FE A3 E0 FF A3 E0 F8 A3 +R 00 00 00 07 29 02 00 01 00 05 00 05 +T 00 56 E0 F9 33 E4 33 FA 60 13 +R 00 00 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E C3 E4 9E F5 00 04 E4 9F F5 00 05 E4 98 F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 6A 00 06 E4 99 F5 00 07 80 08 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 71 +R 00 00 00 07 +T 00 71 8E 00 04 8F 00 05 88 00 06 89 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 78 00 07 +R 00 00 00 07 29 02 00 01 +T 00 79 +R 00 00 00 07 +T 00 79 90 00 00 E5 00 04 F0 A3 E5 00 05 F0 A3 E5 +R 00 00 00 07 02 03 00 00 29 06 00 01 29 0B 00 01 +T 00 85 00 06 F0 A3 E5 00 07 F0 C0 02 85 00 00 82 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 00 90 85 00 01 83 85 00 02 F0 E5 00 03 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 99 00 00 AB 82 AC 83 AD F0 FE D0 02 C0 03 C0 +R 00 00 00 07 02 02 00 01 +T 00 A7 04 C0 05 C0 06 90 00 04 E0 FF A3 E0 F8 A3 +R 00 00 00 07 00 08 00 05 +T 00 B5 E0 F9 A3 E0 FB 33 E4 33 FF EA 65 07 D0 06 +R 00 00 00 07 +T 00 C3 D0 05 D0 04 D0 03 60 1C +R 00 00 00 07 +T 00 CB +R 00 00 00 07 +T 00 CB C3 E4 9B F5 00 04 E4 9C F5 00 05 E4 9D F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 D7 00 06 E4 9E F5 00 07 85 00 04 82 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 00 E0 00 05 83 85 00 06 F0 80 07 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 00 E7 +R 00 00 00 07 +T 00 E7 8B 82 8C 83 8D F0 EE +R 00 00 00 07 +T 00 EE +R 00 00 00 07 +T 00 EE 22 +R 00 00 00 07 diff --git a/device/lib/large/_moduint.asm b/device/lib/large/_moduint.asm new file mode 100644 index 00000000..7b7a01ee --- /dev/null +++ b/device/lib/large/_moduint.asm @@ -0,0 +1,228 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + +;-------------------------------------------------------- + .module _moduint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __moduint_PARM_2 + .globl __moduint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__moduint_PARM_2: + .ds 0x0002 +__moduint_a_1_1: + .ds 0x0002 +__moduint_count_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_moduint$0$0 ==. +; _moduint.c 30 +; ----------------------------------------- +; function _moduint +; ----------------------------------------- +__moduint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _moduint.c 52 + push dph + push dpl + mov dptr,#__moduint_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _moduint.c 32 + mov dptr,#__moduint_count_1_1 +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _moduint.c 35 + mov dptr,#__moduint_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov r4,#0x00 +00103$: + mov dptr,#__moduint_PARM_2 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r6,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00117$ +00119$: +; _moduint.c 36 + mov a,r6 + xch a,r5 + add a,acc + xch a,r5 + rlc a + mov r6,a + mov dptr,#__moduint_PARM_2 + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a +; _moduint.c 37 + clr c + mov a,r2 + subb a,r5 + mov a,r3 + subb a,r6 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00102$ +00120$: +; _moduint.c 39 + mov a,r6 + clr c + rrc a + xch a,r5 + rrc a + xch a,r5 + mov r6,a + mov dptr,#__moduint_PARM_2 + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a +; _moduint.c 40 +; Peephole 132 changed ljmp to sjmp + sjmp 00117$ +00102$: +; _moduint.c 42 + inc r4 + mov dptr,#__moduint_count_1_1 + mov a,r4 + movx @dptr,a + ljmp 00103$ +; _moduint.c 45 +00117$: + mov dptr,#__moduint_count_1_1 + movx a,@dptr + mov r2,a +00108$: +; _moduint.c 46 + mov dptr,#__moduint_a_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#__moduint_PARM_2 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + clr c + mov a,r3 + subb a,r5 + mov a,r4 + subb a,r6 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00121$: +; _moduint.c 47 + mov dptr,#__moduint_a_1_1 + clr c + mov a,r3 + subb a,r5 + movx @dptr,a + mov a,r4 + subb a,r6 + inc dptr + movx @dptr,a +00107$: +; _moduint.c 49 + mov dptr,#__moduint_PARM_2 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r4,a + clr c + rrc a + xch a,r3 + rrc a + xch a,r3 + mov r4,a + mov dptr,#__moduint_PARM_2 + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _moduint.c 50 + mov ar3,r2 + dec r2 + mov a,r3 + jz 00122$ + ljmp 00108$ +00122$: +; _moduint.c 52 + mov dptr,#__moduint_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov dpl,r2 + mov dph,r3 +00111$: + C$_moduint.c$53$1$1 ==. + XG$_moduint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_moduint.cdb b/device/lib/large/_moduint.cdb new file mode 100644 index 00000000..2634be18 --- /dev/null +++ b/device/lib/large/_moduint.cdb @@ -0,0 +1,2 @@ +M:_moduint +F:G$_moduint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_moduint.rel b/device/lib/large/_moduint.rel new file mode 100644 index 00000000..11ac2ea5 --- /dev/null +++ b/device/lib/large/_moduint.rel @@ -0,0 +1,214 @@ +;!FILE _moduint.asm +XH +H 8 areas 84 global symbols +M _moduint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 5 flags 40 +S __moduint_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size AE flags 20 +S XG$_moduint$0$0 Def00AD +S G$_moduint$0$0 Def0000 +S A$_moduint$200 Def008E +S A$_moduint$110 Def0032 +S A$_moduint$101 Def0029 +S A$_moduint$210 Def009A +S A$_moduint$201 Def008F +S A$_moduint$120 Def003D +S A$_moduint$111 Def0035 +S A$_moduint$220 Def00A7 +S A$_moduint$211 Def009B +S A$_moduint$202 Def0090 +S A$_moduint$130 Def0045 +S A$_moduint$121 Def003E +S A$_moduint$112 Def0036 +S A$_moduint$221 Def00A8 +S A$_moduint$212 Def009C +S A$_moduint$203 Def0093 +S A$_moduint$131 Def0046 +S A$_moduint$113 Def0037 +S A$_moduint$104 Def002B +S A$_moduint$222 Def00A9 +S A$_moduint$213 Def009E +S A$_moduint$204 Def0094 +S A$_moduint$141 Def0050 +S A$_moduint$132 Def0047 +S A$_moduint$123 Def003F +S A$_moduint$114 Def0038 +S A$_moduint$105 Def002C +S A$_moduint$223 Def00AB +S A$_moduint$205 Def0095 +S A$_moduint$160 Def0066 +S A$_moduint$151 Def005B +S A$_moduint$133 Def0048 +S A$_moduint$115 Def0039 +S A$_moduint$106 Def002D +S A$_moduint$206 Def0096 +S A$_moduint$170 Def0072 +S A$_moduint$161 Def0067 +S A$_moduint$152 Def005E +S A$_moduint$134 Def004B +S A$_moduint$107 Def002F +S A$_moduint$216 Def00A1 +S A$_moduint$207 Def0097 +S A$_moduint$180 Def007B +S A$_moduint$171 Def0073 +S A$_moduint$162 Def0068 +S A$_moduint$153 Def005F +S A$_moduint$144 Def0052 +S A$_moduint$135 Def004C +S A$_moduint$126 Def0041 +S A$_moduint$117 Def003A +S A$_moduint$108 Def0030 +S A$_moduint$217 Def00A4 +S A$_moduint$190 Def0085 +S A$_moduint$181 Def007C +S A$_moduint$172 Def0074 +S A$_moduint$163 Def006B +S A$_moduint$145 Def0053 +S A$_moduint$136 Def004D +S A$_moduint$127 Def0042 +S A$_moduint$118 Def003B +S A$_moduint$109 Def0031 +S A$_moduint$227 Def00AD +S A$_moduint$218 Def00A5 +S A$_moduint$209 Def0098 +S A$_moduint$191 Def0086 +S A$_moduint$182 Def007D +S A$_moduint$164 Def006C +S A$_moduint$146 Def0056 +S A$_moduint$137 Def004E +S A$_moduint$128 Def0043 +S A$_moduint$119 Def003C +S A$_moduint$219 Def00A6 +S A$_moduint$192 Def0087 +S A$_moduint$183 Def007E +S A$_moduint$165 Def006D +S A$_moduint$156 Def0060 +S A$_moduint$147 Def0057 +S A$_moduint$138 Def004F +S A$_moduint$129 Def0044 +S A$_moduint$193 Def0088 +S A$_moduint$184 Def007F +S A$_moduint$175 Def0075 +S A$_moduint$166 Def006E +S A$_moduint$157 Def0063 +S A$_moduint$148 Def0058 +S A$_moduint$185 Def0080 +S A$_moduint$167 Def006F +S A$_moduint$158 Def0064 +S A$_moduint$195 Def0089 +S A$_moduint$186 Def0081 +S A$_moduint$168 Def0070 +S A$_moduint$159 Def0065 +S A$_moduint$196 Def008A +S A$_moduint$178 Def0077 +S A$_moduint$169 Def0071 +S A$_moduint$197 Def008B +S A$_moduint$179 Def007A +S A$_moduint$198 Def008C +S A$_moduint$189 Def0082 +S A$_moduint$199 Def008D +S C$_moduint.c$53$1$1 Def00AD +S A$_moduint$70 Def0007 +S A$_moduint$71 Def0009 +S A$_moduint$90 Def0020 +S A$_moduint$81 Def0013 +S A$_moduint$72 Def000A +S A$_moduint$91 Def0021 +S A$_moduint$82 Def0016 +S A$_moduint$73 Def000C +S A$_moduint$92 Def0022 +S A$_moduint$83 Def0017 +S A$_moduint$74 Def000D +S A$_moduint$93 Def0023 +S A$_moduint$84 Def0018 +S A$_moduint$85 Def0019 +S A$_moduint$76 Def000E +S A$_moduint$67 Def0000 +S A$_moduint$95 Def0024 +S A$_moduint$86 Def001A +S A$_moduint$68 Def0002 +S A$_moduint$96 Def0025 +S A$_moduint$87 Def001B +S A$_moduint$78 Def0011 +S A$_moduint$69 Def0004 +S A$_moduint$97 Def0026 +S A$_moduint$79 Def0012 +S A$_moduint$89 Def001D +S A$_moduint$99 Def0028 +S __moduint Def0000 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 02 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 04 E4 F0 90 00 02 E0 FA A3 E0 FB 7C +R 00 00 00 07 00 03 00 05 00 08 00 05 +T 00 1C 00 +R 00 00 00 07 +T 00 1D +R 00 00 00 07 +T 00 1D 90 00 00 E0 FD A3 E0 FE 23 54 01 FF 70 30 +R 00 00 00 07 00 03 00 05 +T 00 2B +R 00 00 00 07 +T 00 2B EE CD 25 E0 CD 33 FE 90 00 00 ED F0 A3 EE +R 00 00 00 07 00 0A 00 05 +T 00 39 F0 C3 EA 9D EB 9E 50 11 +R 00 00 00 07 +T 00 41 +R 00 00 00 07 +T 00 41 EE C3 13 CD 13 CD FE 90 00 00 ED F0 A3 EE +R 00 00 00 07 00 0A 00 05 +T 00 4F F0 80 09 +R 00 00 00 07 +T 00 52 +R 00 00 00 07 +T 00 52 0C 90 00 04 EC F0 02 00 1D +R 00 00 00 07 00 04 00 05 00 09 00 07 +T 00 5B +R 00 00 00 07 +T 00 5B 90 00 04 E0 FA +R 00 00 00 07 00 03 00 05 +T 00 60 +R 00 00 00 07 +T 00 60 90 00 02 E0 FB A3 E0 FC 90 00 00 E0 FD A3 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 00 6E E0 FE C3 EB 9D EC 9E 40 0B +R 00 00 00 07 +T 00 77 +R 00 00 00 07 +T 00 77 90 00 02 C3 EB 9D F0 EC 9E A3 F0 +R 00 00 00 07 00 03 00 05 +T 00 82 +R 00 00 00 07 +T 00 82 90 00 00 E0 FB A3 E0 FC C3 13 CB 13 CB FC +R 00 00 00 07 00 03 00 05 +T 00 90 90 00 00 EB F0 A3 EC F0 8A 03 1A EB 60 03 +R 00 00 00 07 00 03 00 05 +T 00 9E 02 00 60 +R 00 00 00 07 00 03 00 07 +T 00 A1 +R 00 00 00 07 +T 00 A1 90 00 02 E0 FA A3 E0 FB 8A 82 8B 83 +R 00 00 00 07 00 03 00 05 +T 00 AD +R 00 00 00 07 +T 00 AD 22 +R 00 00 00 07 diff --git a/device/lib/large/_modulong.asm b/device/lib/large/_modulong.asm new file mode 100644 index 00000000..9ca4c4cc --- /dev/null +++ b/device/lib/large/_modulong.asm @@ -0,0 +1,328 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + +;-------------------------------------------------------- + .module _modulong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __modulong_PARM_2 + .globl __modulong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__modulong_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__modulong_PARM_2: + .ds 0x0004 +__modulong_a_1_1: + .ds 0x0004 +__modulong_count_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_modulong$0$0 ==. +; _modulong.c 29 +; ----------------------------------------- +; function _modulong +; ----------------------------------------- +__modulong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _modulong.c 51 + push acc + push b + push dph + push dpl + mov dptr,#__modulong_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _modulong.c 31 + mov dptr,#__modulong_count_1_1 +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _modulong.c 34 + mov dptr,#__modulong_a_1_1 + movx a,@dptr + mov __modulong_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (__modulong_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (__modulong_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (__modulong_sloc0_1_0 + 3),a + mov r6,#0x00 +00103$: + mov dptr,#__modulong_PARM_2 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r3,a + jz 00119$ + ljmp 00117$ +00119$: +; _modulong.c 35 + mov a,r7 + add a,acc + mov r5,a + mov a,r0 + rlc a + mov r3,a + mov a,r1 + rlc a + mov r4,a + mov a,r2 + rlc a + mov r2,a + mov dptr,#__modulong_PARM_2 + mov a,r5 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a +; _modulong.c 36 + clr c + mov a,__modulong_sloc0_1_0 + subb a,r5 + mov a,(__modulong_sloc0_1_0 + 1) + subb a,r3 + mov a,(__modulong_sloc0_1_0 + 2) + subb a,r4 + mov a,(__modulong_sloc0_1_0 + 3) + subb a,r2 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00102$ +00120$: +; _modulong.c 38 + clr c + mov a,r2 + rrc a + mov r2,a + mov a,r4 + rrc a + mov r4,a + mov a,r3 + rrc a + mov r3,a + mov a,r5 + rrc a +; Peephole 100 removed redundant mov + mov r5,a + mov dptr,#__modulong_PARM_2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a +; _modulong.c 39 +; Peephole 132 changed ljmp to sjmp + sjmp 00117$ +00102$: +; _modulong.c 41 + inc r6 + mov dptr,#__modulong_count_1_1 + mov a,r6 + movx @dptr,a + ljmp 00103$ +; _modulong.c 44 +00117$: + mov dptr,#__modulong_count_1_1 + movx a,@dptr + mov __modulong_sloc0_1_0,a +00108$: +; _modulong.c 45 + mov dptr,#__modulong_a_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + mov dptr,#__modulong_PARM_2 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr + mov r2,a + clr c + mov a,r3 + subb a,r7 + mov a,r4 + subb a,r0 + mov a,r5 + subb a,r1 + mov a,r6 + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00121$: +; _modulong.c 46 + mov dptr,#__modulong_a_1_1 + clr c + mov a,r3 + subb a,r7 + movx @dptr,a + mov a,r4 + subb a,r0 + inc dptr + movx @dptr,a + mov a,r5 + subb a,r1 + inc dptr + movx @dptr,a + mov a,r6 + subb a,r2 + inc dptr + movx @dptr,a +00107$: +; _modulong.c 48 + mov dptr,#__modulong_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 106 removed redundant mov + mov r5,a + clr c + rrc a + mov r5,a + mov a,r4 + rrc a + mov r4,a + mov a,r3 + rrc a + mov r3,a + mov a,r2 + rrc a +; Peephole 100 removed redundant mov + mov r2,a + mov dptr,#__modulong_PARM_2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _modulong.c 49 + mov r2,__modulong_sloc0_1_0 + dec __modulong_sloc0_1_0 + mov a,r2 + jz 00122$ + ljmp 00108$ +00122$: +; _modulong.c 51 + mov dptr,#__modulong_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00111$: + C$_modulong.c$52$1$1 ==. + XG$_modulong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_modulong.cdb b/device/lib/large/_modulong.cdb new file mode 100644 index 00000000..65d66212 --- /dev/null +++ b/device/lib/large/_modulong.cdb @@ -0,0 +1,2 @@ +M:_modulong +F:G$_modulong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_modulong.rel b/device/lib/large/_modulong.rel new file mode 100644 index 00000000..7e9f2c0f --- /dev/null +++ b/device/lib/large/_modulong.rel @@ -0,0 +1,330 @@ +;!FILE _modulong.asm +XH +H 8 areas E4 global symbols +M _modulong +A _CODE size 0 flags 0 +A DSEG size 4 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 9 flags 40 +S __modulong_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 11F flags 20 +S A$_modulong$210 Def00A5 +S A$_modulong$201 Def0099 +S A$_modulong$111 Def003B +S A$_modulong$102 Def002F +S A$_modulong$310 Def010E +S A$_modulong$301 Def0100 +S A$_modulong$220 Def00B1 +S A$_modulong$211 Def00A6 +S A$_modulong$202 Def009C +S A$_modulong$130 Def004F +S A$_modulong$121 Def0044 +S A$_modulong$112 Def003C +S A$_modulong$103 Def0031 +S A$_modulong$320 Def0117 +S A$_modulong$311 Def010F +S A$_modulong$302 Def0102 +S A$_modulong$230 Def00BB +S A$_modulong$221 Def00B2 +S A$_modulong$212 Def00A7 +S A$_modulong$203 Def009D +S A$_modulong$140 Def005B +S A$_modulong$131 Def0050 +S A$_modulong$122 Def0045 +S A$_modulong$113 Def003D +S A$_modulong$321 Def0118 +S A$_modulong$312 Def0110 +S A$_modulong$303 Def0104 +S A$_modulong$231 Def00BC +S A$_modulong$222 Def00B3 +S A$_modulong$213 Def00A8 +S A$_modulong$141 Def005C +S A$_modulong$132 Def0051 +S A$_modulong$123 Def0047 +S A$_modulong$114 Def003E +S A$_modulong$105 Def0033 +S A$_modulong$322 Def011A +S A$_modulong$313 Def0111 +S A$_modulong$304 Def0105 +S A$_modulong$250 Def00CE +S A$_modulong$241 Def00C4 +S A$_modulong$232 Def00BD +S A$_modulong$223 Def00B4 +S A$_modulong$214 Def00A9 +S A$_modulong$151 Def0065 +S A$_modulong$142 Def005D +S A$_modulong$133 Def0052 +S A$_modulong$115 Def003F +S A$_modulong$106 Def0036 +S A$_modulong$323 Def011C +S A$_modulong$314 Def0112 +S A$_modulong$305 Def0107 +S A$_modulong$260 Def00D8 +S A$_modulong$251 Def00CF +S A$_modulong$233 Def00BE +S A$_modulong$224 Def00B5 +S A$_modulong$215 Def00AA +S A$_modulong$206 Def009F +S A$_modulong$170 Def007A +S A$_modulong$161 Def0072 +S A$_modulong$152 Def0066 +S A$_modulong$143 Def005E +S A$_modulong$134 Def0053 +S A$_modulong$107 Def0037 +S A$_modulong$315 Def0113 +S A$_modulong$270 Def00E2 +S A$_modulong$252 Def00D0 +S A$_modulong$234 Def00BF +S A$_modulong$225 Def00B6 +S A$_modulong$216 Def00AB +S A$_modulong$207 Def00A2 +S A$_modulong$180 Def0085 +S A$_modulong$171 Def007B +S A$_modulong$153 Def0068 +S A$_modulong$144 Def005F +S A$_modulong$135 Def0054 +S A$_modulong$126 Def004A +S A$_modulong$117 Def0040 +S A$_modulong$108 Def0038 +S A$_modulong$316 Def0114 +S A$_modulong$280 Def00EB +S A$_modulong$271 Def00E3 +S A$_modulong$253 Def00D1 +S A$_modulong$244 Def00C6 +S A$_modulong$235 Def00C0 +S A$_modulong$226 Def00B7 +S A$_modulong$217 Def00AC +S A$_modulong$208 Def00A3 +S A$_modulong$181 Def0086 +S A$_modulong$172 Def007C +S A$_modulong$154 Def0069 +S A$_modulong$145 Def0060 +S A$_modulong$136 Def0055 +S A$_modulong$127 Def004B +S A$_modulong$118 Def0041 +S A$_modulong$109 Def0039 +S A$_modulong$317 Def0115 +S A$_modulong$308 Def010A +S A$_modulong$290 Def00F6 +S A$_modulong$281 Def00EC +S A$_modulong$272 Def00E4 +S A$_modulong$263 Def00D9 +S A$_modulong$254 Def00D2 +S A$_modulong$245 Def00C9 +S A$_modulong$236 Def00C1 +S A$_modulong$227 Def00B8 +S A$_modulong$218 Def00AD +S A$_modulong$209 Def00A4 +S A$_modulong$191 Def008E +S A$_modulong$182 Def0087 +S A$_modulong$173 Def007D +S A$_modulong$164 Def0074 +S A$_modulong$155 Def006B +S A$_modulong$146 Def0061 +S A$_modulong$137 Def0056 +S A$_modulong$128 Def004D +S A$_modulong$119 Def0042 +S A$_modulong$327 Def011E +S A$_modulong$318 Def0116 +S A$_modulong$309 Def010D +S A$_modulong$291 Def00F7 +S A$_modulong$282 Def00ED +S A$_modulong$273 Def00E5 +S A$_modulong$264 Def00DC +S A$_modulong$255 Def00D3 +S A$_modulong$246 Def00CA +S A$_modulong$237 Def00C2 +S A$_modulong$228 Def00B9 +S A$_modulong$219 Def00B0 +S A$_modulong$183 Def0088 +S A$_modulong$174 Def007E +S A$_modulong$165 Def0075 +S A$_modulong$156 Def006C +S A$_modulong$147 Def0062 +S A$_modulong$138 Def0057 +S A$_modulong$129 Def004E +S A$_modulong$292 Def00F8 +S A$_modulong$283 Def00EE +S A$_modulong$265 Def00DD +S A$_modulong$256 Def00D4 +S A$_modulong$247 Def00CB +S A$_modulong$238 Def00C3 +S A$_modulong$229 Def00BA +S A$_modulong$184 Def0089 +S A$_modulong$175 Def007F +S A$_modulong$166 Def0076 +S A$_modulong$157 Def006E +S A$_modulong$148 Def0063 +S A$_modulong$139 Def005A +S A$_modulong$293 Def00F9 +S A$_modulong$284 Def00EF +S A$_modulong$275 Def00E6 +S A$_modulong$266 Def00DE +S A$_modulong$257 Def00D5 +S A$_modulong$248 Def00CC +S A$_modulong$194 Def0090 +S A$_modulong$185 Def008A +S A$_modulong$167 Def0077 +S A$_modulong$158 Def006F +S A$_modulong$149 Def0064 +S A$_modulong$294 Def00FA +S A$_modulong$285 Def00F0 +S A$_modulong$276 Def00E7 +S A$_modulong$267 Def00DF +S A$_modulong$258 Def00D6 +S A$_modulong$249 Def00CD +S A$_modulong$195 Def0091 +S A$_modulong$186 Def008B +S A$_modulong$177 Def0080 +S A$_modulong$168 Def0078 +S A$_modulong$159 Def0071 +S A$_modulong$295 Def00FB +S A$_modulong$286 Def00F1 +S A$_modulong$277 Def00E8 +S A$_modulong$268 Def00E0 +S A$_modulong$259 Def00D7 +S A$_modulong$196 Def0094 +S A$_modulong$187 Def008C +S A$_modulong$178 Def0081 +S A$_modulong$169 Def0079 +S A$_modulong$296 Def00FC +S A$_modulong$278 Def00E9 +S A$_modulong$269 Def00E1 +S A$_modulong$197 Def0095 +S A$_modulong$188 Def008D +S A$_modulong$179 Def0084 +S A$_modulong$297 Def00FD +S A$_modulong$288 Def00F2 +S A$_modulong$279 Def00EA +S A$_modulong$198 Def0096 +S A$_modulong$298 Def00FE +S A$_modulong$289 Def00F3 +S A$_modulong$299 Def00FF +S C$_modulong.c$52$1$1 Def011E +S A$_modulong$70 Def0002 +S A$_modulong$80 Def0014 +S A$_modulong$71 Def0004 +S A$_modulong$81 Def0015 +S A$_modulong$72 Def0006 +S A$_modulong$91 Def001F +S A$_modulong$82 Def0016 +S A$_modulong$73 Def0008 +S A$_modulong$92 Def0022 +S A$_modulong$83 Def0018 +S A$_modulong$74 Def000B +S A$_modulong$93 Def0023 +S A$_modulong$84 Def0019 +S A$_modulong$75 Def000D +S A$_modulong$94 Def0025 +S A$_modulong$76 Def000E +S A$_modulong$95 Def0026 +S A$_modulong$86 Def001A +S A$_modulong$77 Def0010 +S A$_modulong$96 Def0027 +S A$_modulong$78 Def0011 +S A$_modulong$69 Def0000 +S A$_modulong$97 Def0029 +S A$_modulong$88 Def001D +S A$_modulong$79 Def0012 +S A$_modulong$98 Def002A +S A$_modulong$89 Def001E +S A$_modulong$99 Def002B +S __modulong Def0000 +S XG$_modulong$0$0 Def011E +S G$_modulong$0$0 Def0000 +S A$_modulong$100 Def002D +S A$_modulong$110 Def003A +S A$_modulong$101 Def002E +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 08 E4 F0 90 00 04 E0 F5 00 00 A3 E0 F5 +R 00 00 00 07 00 02 00 05 00 07 00 05 29 0B 00 01 +T 00 28 00 01 A3 E0 F5 00 02 A3 E0 F5 00 03 7E 00 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 33 +R 00 00 00 07 +T 00 33 90 00 00 E0 FF A3 E0 F8 A3 E0 F9 A3 E0 FA +R 00 00 00 07 00 03 00 05 +T 00 41 23 54 01 FB 60 03 02 00 99 +R 00 00 00 07 00 09 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A EF 25 E0 FD E8 33 FB E9 33 FC EA 33 FA 90 +R 00 00 00 07 +T 00 58 00 00 ED F0 A3 EB F0 A3 EC F0 A3 EA F0 C3 +R 00 00 00 07 00 02 00 05 +T 00 66 E5 00 00 9D E5 00 01 9B E5 00 02 9C E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 70 00 03 9A 50 1C +R 00 00 00 07 29 02 00 01 +T 00 74 +R 00 00 00 07 +T 00 74 C3 EA 13 FA EC 13 FC EB 13 FB ED 13 FD 90 +R 00 00 00 07 +T 00 82 00 00 F0 A3 EB F0 A3 EC F0 A3 EA F0 80 09 +R 00 00 00 07 00 02 00 05 +T 00 90 +R 00 00 00 07 +T 00 90 0E 90 00 08 EE F0 02 00 33 +R 00 00 00 07 00 04 00 05 00 09 00 07 +T 00 99 +R 00 00 00 07 +T 00 99 90 00 08 E0 F5 00 00 +R 00 00 00 07 00 03 00 05 29 07 00 01 +T 00 9F +R 00 00 00 07 +T 00 9F 90 00 04 E0 FB A3 E0 FC A3 E0 FD A3 E0 FE +R 00 00 00 07 00 03 00 05 +T 00 AD 90 00 00 E0 FF A3 E0 F8 A3 E0 F9 A3 E0 FA +R 00 00 00 07 00 03 00 05 +T 00 BB C3 EB 9F EC 98 ED 99 EE 9A 40 13 +R 00 00 00 07 +T 00 C6 +R 00 00 00 07 +T 00 C6 90 00 04 C3 EB 9F F0 EC 98 A3 F0 ED 99 A3 +R 00 00 00 07 00 03 00 05 +T 00 D4 F0 EE 9A A3 F0 +R 00 00 00 07 +T 00 D9 +R 00 00 00 07 +T 00 D9 90 00 00 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 E7 C3 13 FD EC 13 FC EB 13 FB EA 13 FA 90 +R 00 00 00 07 +T 00 F4 00 00 F0 A3 EB F0 A3 EC F0 A3 ED F0 AA +R 00 00 00 07 00 02 00 05 +T 01 01 00 00 15 00 00 EA 60 03 02 00 9F +R 00 00 00 07 29 02 00 01 29 05 00 01 00 0B 00 07 +T 01 0A +R 00 00 00 07 +T 01 0A 90 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 01 18 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 1E +R 00 00 00 07 +T 01 1E 22 +R 00 00 00 07 diff --git a/device/lib/large/_mulsint.asm b/device/lib/large/_mulsint.asm new file mode 100644 index 00000000..62dbac4f --- /dev/null +++ b/device/lib/large/_mulsint.asm @@ -0,0 +1,178 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + +;-------------------------------------------------------- + .module _mulsint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __mulsint_PARM_2 + .globl __mulsint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__mulsint_PARM_2: + .ds 0x0002 +__mulsint_a_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_mulsint$0$0 ==. +; _mulsint.c 26 +; ----------------------------------------- +; function _mulsint +; ----------------------------------------- +__mulsint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _mulsint.c 0 + push dph + push dpl + mov dptr,#__mulsint_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _mulsint.c 30 + mov dptr,#__mulsint_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00113$: + clr c + clr a + subb a,r2 + mov r4,a + clr a + subb a,r3 + mov r5,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar4,r2 + mov ar5,r3 +00107$: + mov ar2,r4 + mov ar3,r5 +; _mulsint.c 31 + mov dptr,#__mulsint_PARM_2 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,r4 + mov r7,a + clr a + subb a,r5 + mov r0,a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov ar7,r4 + mov ar0,r5 +00109$: + mov dptr,#__muluint_PARM_2 + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + push ar6 + mov dpl,r2 + mov dph,r3 + lcall __muluint + mov r2,dpl + mov r3,dph + pop ar6 +; _mulsint.c 33 + mov dptr,#__mulsint_a_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a + mov r4,a + mov a,r6 + xrl a,ar4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _mulsint.c 34 + clr c + clr a + subb a,r2 + mov r4,a + clr a + subb a,r3 + mov r6,a + mov dpl,r4 + mov dph,r6 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _mulsint.c 36 + mov dpl,r2 + mov dph,r3 +00104$: + C$_mulsint.c$37$1$1 ==. + XG$_mulsint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_mulsint.cdb b/device/lib/large/_mulsint.cdb new file mode 100644 index 00000000..49440424 --- /dev/null +++ b/device/lib/large/_mulsint.cdb @@ -0,0 +1,2 @@ +M:_mulsint +F:G$_mulsint$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_mulsint.rel b/device/lib/large/_mulsint.rel new file mode 100644 index 00000000..2ec0e721 --- /dev/null +++ b/device/lib/large/_mulsint.rel @@ -0,0 +1,162 @@ +;!FILE _mulsint.asm +XH +H 8 areas 5E global symbols +M _mulsint +S __muluint Ref0000 +S __muluint_PARM_2 Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 4 flags 40 +S __mulsint_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 7F flags 20 +S A$_mulsint$84 Def0019 +S A$_mulsint$75 Def0011 +S A$_mulsint$66 Def0002 +S A$_mulsint$94 Def0022 +S A$_mulsint$85 Def001A +S A$_mulsint$76 Def0012 +S A$_mulsint$67 Def0004 +S A$_mulsint$95 Def0024 +S A$_mulsint$86 Def001B +S A$_mulsint$77 Def0013 +S A$_mulsint$68 Def0007 +S A$_mulsint$87 Def001C +S A$_mulsint$78 Def0014 +S A$_mulsint$69 Def0009 +S A$_mulsint$97 Def0026 +S A$_mulsint$88 Def001D +S A$_mulsint$98 Def0028 +S A$_mulsint$89 Def001E +S __mulsint Def0000 +S XG$_mulsint$0$0 Def007E +S G$_mulsint$0$0 Def0000 +S A$_mulsint$100 Def002A +S A$_mulsint$101 Def002D +S A$_mulsint$120 Def003D +S A$_mulsint$111 Def0035 +S A$_mulsint$102 Def002E +S A$_mulsint$130 Def0049 +S A$_mulsint$121 Def003E +S A$_mulsint$103 Def002F +S A$_mulsint$140 Def005A +S A$_mulsint$131 Def004A +S A$_mulsint$113 Def0036 +S A$_mulsint$104 Def0030 +S A$_mulsint$150 Def0065 +S A$_mulsint$132 Def004B +S A$_mulsint$123 Def003F +S A$_mulsint$160 Def006E +S A$_mulsint$151 Def0066 +S A$_mulsint$142 Def005C +S A$_mulsint$133 Def004C +S A$_mulsint$115 Def0038 +S A$_mulsint$106 Def0031 +S A$_mulsint$161 Def006F +S A$_mulsint$152 Def0067 +S A$_mulsint$143 Def005F +S A$_mulsint$134 Def004D +S A$_mulsint$125 Def0041 +S A$_mulsint$116 Def0039 +S A$_mulsint$107 Def0032 +S A$_mulsint$162 Def0070 +S A$_mulsint$153 Def0068 +S A$_mulsint$144 Def0060 +S A$_mulsint$135 Def004F +S A$_mulsint$126 Def0043 +S A$_mulsint$117 Def003A +S A$_mulsint$108 Def0033 +S A$_mulsint$172 Def007A +S A$_mulsint$163 Def0071 +S A$_mulsint$154 Def0069 +S A$_mulsint$145 Def0061 +S A$_mulsint$136 Def0051 +S A$_mulsint$118 Def003B +S A$_mulsint$109 Def0034 +S A$_mulsint$173 Def007C +S A$_mulsint$164 Def0072 +S A$_mulsint$146 Def0062 +S A$_mulsint$137 Def0053 +S A$_mulsint$128 Def0045 +S A$_mulsint$119 Def003C +S A$_mulsint$165 Def0073 +S A$_mulsint$156 Def006B +S A$_mulsint$138 Def0056 +S A$_mulsint$129 Def0048 +S A$_mulsint$166 Def0074 +S A$_mulsint$148 Def0063 +S A$_mulsint$139 Def0058 +S A$_mulsint$167 Def0076 +S A$_mulsint$149 Def0064 +S A$_mulsint$177 Def007E +S A$_mulsint$159 Def006D +S A$_mulsint$169 Def0078 +S A$_mulsint$70 Def000A +S C$_mulsint.c$37$1$1 Def007E +S A$_mulsint$80 Def0015 +S A$_mulsint$71 Def000C +S A$_mulsint$90 Def001F +S A$_mulsint$72 Def000D +S A$_mulsint$82 Def0016 +S A$_mulsint$92 Def0020 +S A$_mulsint$74 Def000E +S A$_mulsint$65 Def0000 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 02 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 02 E0 FA A3 E0 FB 30 E7 09 +R 00 00 00 07 00 03 00 05 +T 00 19 +R 00 00 00 07 +T 00 19 C3 E4 9A FC E4 9B FD 80 04 +R 00 00 00 07 +T 00 22 +R 00 00 00 07 +T 00 22 8A 04 8B 05 +R 00 00 00 07 +T 00 26 +R 00 00 00 07 +T 00 26 8C 02 8D 03 90 00 00 E0 FC A3 E0 FD 33 E4 +R 00 00 00 07 00 07 00 05 +T 00 34 33 FE 60 09 +R 00 00 00 07 +T 00 38 +R 00 00 00 07 +T 00 38 C3 E4 9C FF E4 9D F8 80 04 +R 00 00 00 07 +T 00 41 +R 00 00 00 07 +T 00 41 8C 07 8D 00 +R 00 00 00 07 +T 00 45 +R 00 00 00 07 +T 00 45 90 00 00 EF F0 A3 E8 F0 C0 06 8A 82 8B 83 +R 00 00 00 07 02 03 00 01 +T 00 53 12 00 00 AA 82 AB 83 D0 06 90 00 02 E0 FC +R 00 00 00 07 02 03 00 00 00 0C 00 05 +T 00 61 A3 E0 FD 33 E4 33 FC EE 65 04 60 0D +R 00 00 00 07 +T 00 6D +R 00 00 00 07 +T 00 6D C3 E4 9A FC E4 9B FE 8C 82 8E 83 80 04 +R 00 00 00 07 +T 00 7A +R 00 00 00 07 +T 00 7A 8A 82 8B 83 +R 00 00 00 07 +T 00 7E +R 00 00 00 07 +T 00 7E 22 +R 00 00 00 07 diff --git a/device/lib/large/_muluint.asm b/device/lib/large/_muluint.asm new file mode 100644 index 00000000..254340e9 --- /dev/null +++ b/device/lib/large/_muluint.asm @@ -0,0 +1,133 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:31 2000 + +;-------------------------------------------------------- + .module _muluint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __muluint_PARM_2 + .globl __muluint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__muluint_PARM_2: + .ds 0x0002 +__muluint_a_1_1: + .ds 0x0002 +__muluint_t_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_muluint$0$0 ==. +; _muluint.c 32 +; ----------------------------------------- +; function _muluint +; ----------------------------------------- +__muluint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _muluint.c 51 + push dph + push dpl + mov dptr,#__muluint_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _muluint.c 38 +; _muluint.c 39 +; _muluint.c 48 + mov dptr,#(__muluint_a_1_1) + movx a,@dptr + mov r2,a + mov dptr,#(__muluint_PARM_2) + movx a,@dptr + mov r3,a + mov b,r3 + mov a,r2 + mul ab + mov r4,a + mov r5,b + mov dptr,#(__muluint_t_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _muluint.c 49 + mov dptr,#(0x0001 + __muluint_t_1_1) + movx a,@dptr + mov r4,a + mov dptr,#(0x0001 + __muluint_PARM_2) + movx a,@dptr + mov r5,a + mov b,r5 + mov a,r2 + mul ab + mov r2,a + mov dptr,#(0x0001 + __muluint_a_1_1) + movx a,@dptr + mov r5,a + mov b,r3 + mov a,r5 + mul ab +; Peephole 105 removed redundant mov + mov r3,a + add a,r2 + add a,r4 +; Peephole 100 removed redundant mov + mov r4,a + mov dptr,#(0x0001 + __muluint_t_1_1) + movx @dptr,a +; _muluint.c 51 + mov dptr,#(__muluint_t_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov dpl,r2 + mov dph,r3 +00101$: + C$_muluint.c$52$1$1 ==. + XG$_muluint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_muluint.cdb b/device/lib/large/_muluint.cdb new file mode 100644 index 00000000..531f0176 --- /dev/null +++ b/device/lib/large/_muluint.cdb @@ -0,0 +1,2 @@ +M:_muluint +F:G$_muluint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_muluint.rel b/device/lib/large/_muluint.rel new file mode 100644 index 00000000..87a89084 --- /dev/null +++ b/device/lib/large/_muluint.rel @@ -0,0 +1,105 @@ +;!FILE _muluint.asm +XH +H 8 areas 3D global symbols +M _muluint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 6 flags 40 +S __muluint_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 54 flags 20 +S A$_muluint$91 Def0023 +S A$_muluint$82 Def0016 +S A$_muluint$73 Def000C +S A$_muluint$92 Def0024 +S A$_muluint$83 Def0017 +S A$_muluint$74 Def000D +S A$_muluint$93 Def0025 +S A$_muluint$84 Def0018 +S A$_muluint$94 Def0026 +S A$_muluint$85 Def001A +S A$_muluint$67 Def0000 +S A$_muluint$86 Def001B +S A$_muluint$68 Def0002 +S A$_muluint$96 Def0027 +S A$_muluint$87 Def001C +S A$_muluint$78 Def000E +S A$_muluint$69 Def0004 +S A$_muluint$97 Def002A +S A$_muluint$88 Def001D +S A$_muluint$79 Def0011 +S A$_muluint$98 Def002B +S A$_muluint$89 Def001F +S A$_muluint$99 Def002C +S __muluint Def0000 +S XG$_muluint$0$0 Def0053 +S G$_muluint$0$0 Def0000 +S A$_muluint$100 Def002F +S A$_muluint$110 Def003D +S A$_muluint$101 Def0030 +S A$_muluint$111 Def003E +S A$_muluint$102 Def0031 +S A$_muluint$121 Def0047 +S A$_muluint$103 Def0033 +S A$_muluint$122 Def004A +S A$_muluint$113 Def003F +S A$_muluint$104 Def0034 +S A$_muluint$132 Def0053 +S A$_muluint$123 Def004B +S A$_muluint$114 Def0040 +S A$_muluint$105 Def0035 +S A$_muluint$124 Def004C +S A$_muluint$115 Def0041 +S A$_muluint$106 Def0036 +S A$_muluint$125 Def004D +S A$_muluint$107 Def0039 +S A$_muluint$126 Def004E +S A$_muluint$117 Def0042 +S A$_muluint$108 Def003A +S A$_muluint$127 Def004F +S A$_muluint$118 Def0043 +S A$_muluint$109 Def003B +S A$_muluint$128 Def0051 +S A$_muluint$119 Def0046 +S C$_muluint.c$52$1$1 Def0053 +S A$_muluint$70 Def0007 +S A$_muluint$80 Def0012 +S A$_muluint$71 Def0009 +S A$_muluint$90 Def0022 +S A$_muluint$81 Def0013 +S A$_muluint$72 Def000A +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 02 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 02 E0 FA 90 00 00 E0 FB 8B F0 EA A4 +R 00 00 00 07 00 03 00 05 00 08 00 05 +T 00 1C FC AD F0 90 00 04 EC F0 A3 ED F0 90 00 05 +R 00 00 00 07 00 06 00 05 00 0E 00 05 +T 00 2A E0 FC 90 00 01 E0 FD 8D F0 EA A4 FA 90 +R 00 00 00 07 00 05 00 05 +T 00 37 00 03 E0 FD 8B F0 ED A4 FB 2A 2C FC 90 +R 00 00 00 07 00 02 00 05 +T 00 44 00 05 F0 90 00 04 E0 FA A3 E0 FB 8A 82 8B +R 00 00 00 07 00 02 00 05 00 06 00 05 +T 00 52 83 +R 00 00 00 07 +T 00 53 +R 00 00 00 07 +T 00 53 22 +R 00 00 00 07 diff --git a/device/lib/large/_mululong.asm b/device/lib/large/_mululong.asm new file mode 100644 index 00000000..187937c5 --- /dev/null +++ b/device/lib/large/_mululong.asm @@ -0,0 +1,362 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + +;-------------------------------------------------------- + .module _mululong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __mululong_PARM_2 + .globl __mululong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__mululong_PARM_2: + .ds 0x0004 +__mululong_a_1_1: + .ds 0x0004 +__mululong_t_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_mululong$0$0 ==. +; _mululong.c 59 +; ----------------------------------------- +; function _mululong +; ----------------------------------------- +__mululong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _mululong.c 86 + push acc + push b + push dph + push dpl + mov dptr,#__mululong_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _mululong.c 63 + mov dptr,#(__mululong_a_1_1) + movx a,@dptr + mov r2,a + mov dptr,#(0x0002 + __mululong_PARM_2) + movx a,@dptr + mov r3,a + mov b,r3 + mov a,r2 + mul ab + mov r3,a + mov r4,b + mov dptr,#(0x0002 + __mululong_t_1_1) + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _mululong.c 64 + mov dptr,#(__mululong_PARM_2) + movx a,@dptr + mov r3,a + mov b,r3 + mov a,r2 + mul ab + mov r4,a + mov r5,b + mov dptr,#(__mululong_t_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _mululong.c 65 + mov dptr,#(0x0003 + __mululong_t_1_1) + movx a,@dptr + mov r4,a + mov dptr,#(0x0003 + __mululong_a_1_1) + movx a,@dptr + mov r5,a +; _mululong.c 66 + mov b,r3 + mov a,r5 + mul ab +; Peephole 105 removed redundant mov + mov r5,a + add a,r4 +; Peephole 100 removed redundant mov + mov r4,a + mov dptr,#(0x0003 + __mululong_t_1_1) + movx @dptr,a +; _mululong.c 67 + mov dptr,#(0x0003 + __mululong_t_1_1) + movx a,@dptr + mov r4,a + mov dptr,#(0x0002 + __mululong_a_1_1) + movx a,@dptr + mov r5,a +; _mululong.c 68 + mov dptr,#(0x0001 + __mululong_PARM_2) + movx a,@dptr + mov r6,a + mov b,r6 + mov a,r5 + mul ab +; Peephole 105 removed redundant mov + mov r5,a + add a,r4 +; Peephole 100 removed redundant mov + mov r4,a + mov dptr,#(0x0003 + __mululong_t_1_1) + movx @dptr,a +; _mululong.c 69 + mov dptr,#(0x0002 + __mululong_t_1_1) + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(0x0002 + __mululong_a_1_1) + movx a,@dptr + mov r6,a + mov b,r3 + mov a,r6 + mul ab + mov r6,a + mov r7,b + mov a,r6 + add a,r4 + mov r4,a + mov a,r7 + addc a,r5 + mov r5,a + mov dptr,#(0x0002 + __mululong_t_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _mululong.c 71 + mov dptr,#(0x0002 + __mululong_t_1_1) + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#(0x0001 + __mululong_a_1_1) + movx a,@dptr + mov r6,a + mov dptr,#(0x0001 + __mululong_PARM_2) + movx a,@dptr + mov r7,a + mov b,r7 + mov a,r6 + mul ab + mov r7,a + mov r6,b + mov a,r7 + add a,r4 + mov r4,a + mov a,r6 + addc a,r5 + mov r5,a + mov dptr,#(0x0002 + __mululong_t_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _mululong.c 73 + mov dptr,#(0x0001 + __mululong_a_1_1) + movx a,@dptr + mov r4,a +; _mululong.c 74 + mov dptr,#(0x0002 + __mululong_PARM_2) + movx a,@dptr + mov r5,a + mov b,r5 + mov a,r4 + mul ab +; Peephole 100 removed redundant mov + mov r4,a + mov dptr,#(0x0003 + __mululong_a_1_1) + movx @dptr,a +; _mululong.c 75 + mov dptr,#(0x0001 + __mululong_a_1_1) + movx a,@dptr + mov r4,a +; _mululong.c 76 + mov b,r3 + mov a,r4 + mul ab + mov r3,a + mov r5,b + mov dptr,#(0x0001 + __mululong_a_1_1) + mov a,r3 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _mululong.c 78 +; _mululong.c 79 + mov dptr,#(0x0003 + __mululong_PARM_2) + movx a,@dptr + mov r3,a + mov b,r3 + mov a,r2 + mul ab +; Peephole 100 removed redundant mov + mov r3,a + mov dptr,#(0x0003 + __mululong_PARM_2) + movx @dptr,a +; _mululong.c 81 + mov dptr,#(0x0001 + __mululong_PARM_2) + movx a,@dptr + mov r3,a + mov b,r3 + mov a,r2 + mul ab + mov r2,a + mov r4,b + mov dptr,#(0x0001 + __mululong_PARM_2) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _mululong.c 82 + mov dptr,#(__mululong_PARM_2) +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _mululong.c 83 + mov dptr,#(__mululong_a_1_1) +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _mululong.c 84 + mov dptr,#(__mululong_t_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#__mululong_a_1_1 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,r6 + add a,r2 + mov r2,a + mov a,r7 + addc a,r3 + mov r3,a + mov a,r0 + addc a,r4 + mov r4,a + mov a,r1 + addc a,r5 + mov r5,a + mov dptr,#(__mululong_t_1_1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _mululong.c 86 + mov dptr,#__mululong_PARM_2 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,r6 + add a,r2 + mov r2,a + mov a,r7 + addc a,r3 + mov r3,a + mov a,r0 + addc a,r4 + mov r4,a + mov a,r1 + addc a,r5 +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00101$: + C$_mululong.c$87$1$1 ==. + XG$_mululong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_mululong.cdb b/device/lib/large/_mululong.cdb new file mode 100644 index 00000000..e600681e --- /dev/null +++ b/device/lib/large/_mululong.cdb @@ -0,0 +1,2 @@ +M:_mululong +F:G$_mululong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/large/_mululong.rel b/device/lib/large/_mululong.rel new file mode 100644 index 00000000..9284e853 --- /dev/null +++ b/device/lib/large/_mululong.rel @@ -0,0 +1,351 @@ +;!FILE _mululong.asm +XH +H 8 areas 10D global symbols +M _mululong +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size C flags 40 +S __mululong_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 169 flags 20 +S G$_mululong$0$0 Def0000 +S A$_mululong$100 Def0032 +S A$_mululong$200 Def00B1 +S A$_mululong$110 Def003F +S A$_mululong$300 Def0129 +S A$_mululong$210 Def00BD +S A$_mululong$201 Def00B2 +S A$_mululong$120 Def004C +S A$_mululong$111 Def0042 +S A$_mululong$102 Def0033 +S A$_mululong$310 Def0133 +S A$_mululong$301 Def012A +S A$_mululong$220 Def00C9 +S A$_mululong$211 Def00BE +S A$_mululong$202 Def00B3 +S A$_mululong$121 Def004F +S A$_mululong$112 Def0043 +S A$_mululong$103 Def0036 +S A$_mululong$320 Def013F +S A$_mululong$311 Def0134 +S A$_mululong$302 Def012B +S A$_mululong$230 Def00D6 +S A$_mululong$221 Def00CB +S A$_mululong$203 Def00B4 +S A$_mululong$140 Def0065 +S A$_mululong$131 Def0057 +S A$_mululong$122 Def0050 +S A$_mululong$113 Def0044 +S A$_mululong$104 Def0037 +S A$_mululong$330 Def0148 +S A$_mululong$321 Def0140 +S A$_mululong$312 Def0135 +S A$_mululong$303 Def012C +S A$_mululong$240 Def00E3 +S A$_mululong$222 Def00CC +S A$_mululong$213 Def00BF +S A$_mululong$204 Def00B5 +S A$_mululong$150 Def0070 +S A$_mululong$132 Def0058 +S A$_mululong$114 Def0045 +S A$_mululong$105 Def0038 +S A$_mululong$340 Def0154 +S A$_mululong$331 Def014B +S A$_mululong$322 Def0141 +S A$_mululong$313 Def0136 +S A$_mululong$304 Def012D +S A$_mululong$250 Def00EE +S A$_mululong$241 Def00E4 +S A$_mululong$232 Def00D7 +S A$_mululong$214 Def00C2 +S A$_mululong$205 Def00B6 +S A$_mululong$160 Def007C +S A$_mululong$142 Def0066 +S A$_mululong$133 Def005B +S A$_mululong$124 Def0051 +S A$_mululong$115 Def0046 +S A$_mululong$106 Def003A +S A$_mululong$350 Def015E +S A$_mululong$341 Def0155 +S A$_mululong$332 Def014C +S A$_mululong$323 Def0142 +S A$_mululong$314 Def0137 +S A$_mululong$305 Def012E +S A$_mululong$260 Def00FB +S A$_mululong$242 Def00E5 +S A$_mululong$233 Def00D9 +S A$_mululong$224 Def00CD +S A$_mululong$215 Def00C3 +S A$_mululong$206 Def00B7 +S A$_mululong$170 Def008A +S A$_mululong$161 Def007D +S A$_mululong$152 Def0071 +S A$_mululong$143 Def0069 +S A$_mululong$125 Def0053 +S A$_mululong$107 Def003B +S A$_mululong$351 Def015F +S A$_mululong$342 Def0156 +S A$_mululong$333 Def014D +S A$_mululong$324 Def0143 +S A$_mululong$315 Def0138 +S A$_mululong$306 Def012F +S A$_mululong$261 Def00FC +S A$_mululong$252 Def00EF +S A$_mululong$234 Def00DA +S A$_mululong$225 Def00CE +S A$_mululong$207 Def00BA +S A$_mululong$180 Def0096 +S A$_mululong$171 Def008B +S A$_mululong$162 Def007E +S A$_mululong$153 Def0072 +S A$_mululong$144 Def006A +S A$_mululong$135 Def005C +S A$_mululong$126 Def0054 +S A$_mululong$117 Def0047 +S A$_mululong$108 Def003C +S A$_mululong$361 Def0168 +S A$_mululong$352 Def0160 +S A$_mululong$343 Def0157 +S A$_mululong$334 Def014E +S A$_mululong$325 Def0144 +S A$_mululong$316 Def0139 +S A$_mululong$307 Def0130 +S A$_mululong$271 Def0108 +S A$_mululong$262 Def00FD +S A$_mululong$253 Def00F0 +S A$_mululong$235 Def00DB +S A$_mululong$226 Def00D1 +S A$_mululong$217 Def00C4 +S A$_mululong$208 Def00BB +S A$_mululong$190 Def00A3 +S A$_mululong$181 Def0097 +S A$_mululong$172 Def008C +S A$_mululong$163 Def0081 +S A$_mululong$154 Def0075 +S A$_mululong$145 Def006B +S A$_mululong$136 Def005F +S A$_mululong$118 Def004A +S A$_mululong$109 Def003D +S A$_mululong$344 Def0158 +S A$_mululong$335 Def014F +S A$_mululong$326 Def0145 +S A$_mululong$317 Def013A +S A$_mululong$308 Def0131 +S A$_mululong$290 Def011D +S A$_mululong$281 Def0112 +S A$_mululong$263 Def00FE +S A$_mululong$254 Def00F3 +S A$_mululong$245 Def00E6 +S A$_mululong$236 Def00DC +S A$_mululong$218 Def00C7 +S A$_mululong$209 Def00BC +S A$_mululong$191 Def00A4 +S A$_mululong$173 Def008D +S A$_mululong$164 Def0082 +S A$_mululong$146 Def006D +S A$_mululong$137 Def0060 +S A$_mululong$128 Def0055 +S A$_mululong$119 Def004B +S A$_mululong$354 Def0161 +S A$_mululong$345 Def0159 +S A$_mululong$336 Def0150 +S A$_mululong$327 Def0146 +S A$_mululong$318 Def013D +S A$_mululong$309 Def0132 +S A$_mululong$291 Def011E +S A$_mululong$282 Def0115 +S A$_mululong$273 Def010B +S A$_mululong$264 Def0100 +S A$_mululong$246 Def00E9 +S A$_mululong$237 Def00DE +S A$_mululong$228 Def00D2 +S A$_mululong$219 Def00C8 +S A$_mululong$192 Def00A5 +S A$_mululong$183 Def0098 +S A$_mululong$174 Def008E +S A$_mululong$165 Def0083 +S A$_mululong$156 Def0076 +S A$_mululong$147 Def006E +S A$_mululong$138 Def0061 +S A$_mululong$129 Def0056 +S A$_mululong$355 Def0162 +S A$_mululong$346 Def015A +S A$_mululong$337 Def0151 +S A$_mululong$328 Def0147 +S A$_mululong$319 Def013E +S A$_mululong$292 Def011F +S A$_mululong$283 Def0116 +S A$_mululong$274 Def010C +S A$_mululong$265 Def0103 +S A$_mululong$256 Def00F4 +S A$_mululong$247 Def00EA +S A$_mululong$238 Def00E1 +S A$_mululong$229 Def00D5 +S A$_mululong$193 Def00A8 +S A$_mululong$184 Def009B +S A$_mululong$175 Def008F +S A$_mululong$166 Def0085 +S A$_mululong$157 Def0079 +S A$_mululong$139 Def0064 +S A$_mululong$356 Def0164 +S A$_mululong$347 Def015B +S A$_mululong$338 Def0152 +S A$_mululong$293 Def0120 +S A$_mululong$284 Def0117 +S A$_mululong$266 Def0104 +S A$_mululong$257 Def00F7 +S A$_mululong$248 Def00EB +S A$_mululong$239 Def00E2 +S A$_mululong$194 Def00A9 +S A$_mululong$185 Def009C +S A$_mululong$176 Def0090 +S A$_mululong$167 Def0086 +S A$_mululong$158 Def007A +S A$_mululong$149 Def006F +S A$_mululong$357 Def0166 +S A$_mululong$348 Def015C +S A$_mululong$339 Def0153 +S A$_mululong$294 Def0123 +S A$_mululong$285 Def0118 +S A$_mululong$276 Def010D +S A$_mululong$267 Def0105 +S A$_mululong$258 Def00F8 +S A$_mululong$249 Def00ED +S A$_mululong$195 Def00AA +S A$_mululong$186 Def009D +S A$_mululong$177 Def0093 +S A$_mululong$168 Def0087 +S A$_mululong$159 Def007B +S A$_mululong$349 Def015D +S A$_mululong$295 Def0124 +S A$_mululong$286 Def0119 +S A$_mululong$268 Def0106 +S A$_mululong$259 Def00F9 +S A$_mululong$196 Def00AC +S A$_mululong$187 Def009E +S A$_mululong$178 Def0094 +S A$_mululong$169 Def0088 +S A$_mululong$296 Def0125 +S A$_mululong$287 Def011A +S A$_mululong$278 Def0110 +S A$_mululong$269 Def0107 +S A$_mululong$197 Def00AD +S A$_mululong$188 Def009F +S A$_mululong$179 Def0095 +S A$_mululong$297 Def0126 +S A$_mululong$288 Def011B +S A$_mululong$279 Def0111 +S A$_mululong$198 Def00AE +S A$_mululong$189 Def00A0 +S A$_mululong$298 Def0127 +S A$_mululong$289 Def011C +S A$_mululong$199 Def00AF +S A$_mululong$299 Def0128 +S A$_mululong$70 Def0006 +S A$_mululong$80 Def0016 +S A$_mululong$71 Def0008 +S A$_mululong$90 Def0024 +S A$_mululong$81 Def0018 +S A$_mululong$72 Def000B +S A$_mululong$91 Def0026 +S A$_mululong$82 Def0019 +S A$_mululong$73 Def000D +S A$_mululong$92 Def0027 +S A$_mululong$74 Def000E +S A$_mululong$93 Def0028 +S A$_mululong$84 Def001A +S A$_mululong$75 Def0010 +S C$_mululong.c$87$1$1 Def0168 +S A$_mululong$94 Def0029 +S A$_mululong$85 Def001D +S A$_mululong$76 Def0011 +S A$_mululong$67 Def0000 +S A$_mululong$95 Def002B +S A$_mululong$86 Def001E +S A$_mululong$77 Def0012 +S A$_mululong$68 Def0002 +S A$_mululong$96 Def002E +S A$_mululong$87 Def001F +S A$_mululong$78 Def0014 +S A$_mululong$69 Def0004 +S A$_mululong$97 Def002F +S A$_mululong$88 Def0022 +S A$_mululong$79 Def0015 +S A$_mululong$98 Def0030 +S A$_mululong$89 Def0023 +S A$_mululong$99 Def0031 +S __mululong Def0000 +S XG$_mululong$0$0 Def0168 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA 90 00 02 E0 FB 8B F0 EA A4 FB +R 00 00 00 07 00 02 00 05 00 07 00 05 +T 00 29 AC F0 90 00 0A EB F0 A3 EC F0 90 00 00 E0 +R 00 00 00 07 00 05 00 05 00 0D 00 05 +T 00 37 FB 8B F0 EA A4 FC AD F0 90 00 08 EC F0 A3 +R 00 00 00 07 00 0B 00 05 +T 00 45 ED F0 90 00 0B E0 FC 90 00 07 E0 FD 8B F0 +R 00 00 00 07 00 05 00 05 00 0A 00 05 +T 00 53 ED A4 FD 2C FC 90 00 0B F0 90 00 0B E0 FC +R 00 00 00 07 00 08 00 05 00 0C 00 05 +T 00 61 90 00 06 E0 FD 90 00 01 E0 FE 8E F0 ED A4 +R 00 00 00 07 00 03 00 05 00 08 00 05 +T 00 6F FD 2C FC 90 00 0B F0 90 00 0A E0 FC A3 E0 +R 00 00 00 07 00 06 00 05 00 0A 00 05 +T 00 7D FD 90 00 06 E0 FE 8B F0 EE A4 FE AF F0 EE +R 00 00 00 07 00 04 00 05 +T 00 8B 2C FC EF 3D FD 90 00 0A EC F0 A3 ED F0 90 +R 00 00 00 07 00 08 00 05 +T 00 99 00 0A E0 FC A3 E0 FD 90 00 05 E0 FE 90 +R 00 00 00 07 00 02 00 05 00 0A 00 05 +T 00 A6 00 01 E0 FF 8F F0 EE A4 FF AE F0 EF 2C FC +R 00 00 00 07 00 02 00 05 +T 00 B4 EE 3D FD 90 00 0A EC F0 A3 ED F0 90 00 05 +R 00 00 00 07 00 06 00 05 00 0E 00 05 +T 00 C2 E0 FC 90 00 02 E0 FD 8D F0 EC A4 FC 90 +R 00 00 00 07 00 05 00 05 +T 00 CF 00 07 F0 90 00 05 E0 FC 8B F0 EC A4 FB AD +R 00 00 00 07 00 02 00 05 00 06 00 05 +T 00 DD F0 90 00 05 EB F0 A3 ED F0 90 00 03 E0 FB +R 00 00 00 07 00 04 00 05 00 0C 00 05 +T 00 EB 8B F0 EA A4 FB 90 00 03 F0 90 00 01 E0 FB +R 00 00 00 07 00 08 00 05 00 0C 00 05 +T 00 F9 8B F0 EA A4 FA AC F0 90 00 01 EA F0 A3 EC +R 00 00 00 07 00 0A 00 05 +T 01 07 F0 90 00 00 E4 F0 90 00 04 E4 F0 90 00 08 +R 00 00 00 07 00 04 00 05 00 09 00 05 00 0E 00 05 +T 01 15 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 90 00 04 +R 00 00 00 07 00 0E 00 05 +T 01 23 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 EE 2A FA +R 00 00 00 07 +T 01 31 EF 3B FB E8 3C FC E9 3D FD 90 00 08 EA F0 +R 00 00 00 07 00 0C 00 05 +T 01 3F A3 EB F0 A3 EC F0 A3 ED F0 90 00 00 E0 FE +R 00 00 00 07 00 0C 00 05 +T 01 4D A3 E0 FF A3 E0 F8 A3 E0 F9 EE 2A FA EF 3B +R 00 00 00 07 +T 01 5B FB E8 3C FC E9 3D FD 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 68 +R 00 00 00 07 +T 01 68 22 +R 00 00 00 07 diff --git a/device/lib/large/_muslong.asm b/device/lib/large/_muslong.asm new file mode 100644 index 00000000..033c619c --- /dev/null +++ b/device/lib/large/_muslong.asm @@ -0,0 +1,254 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + +;-------------------------------------------------------- + .module _muslong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __mulslong_PARM_2 + .globl __mulslong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__mulslong_sloc0_1_0: + .ds 0x0004 +__mulslong_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__mulslong_PARM_2: + .ds 0x0004 +__mulslong_a_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_mulslong$0$0 ==. +; _muslong.c 24 +; ----------------------------------------- +; function _mulslong +; ----------------------------------------- +__mulslong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _muslong.c 0 + push acc + push b + push dph + push dpl + mov dptr,#__mulslong_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _muslong.c 28 + mov dptr,#__mulslong_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00113$: + clr c + clr a + subb a,r2 + mov r6,a + clr a + subb a,r3 + mov r7,a + clr a + subb a,r4 + mov r0,a + clr a + subb a,r5 + mov r1,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar6,r2 + mov ar7,r3 + mov ar0,r4 + mov ar1,r5 +00107$: + mov __mulslong_sloc0_1_0,r6 + mov (__mulslong_sloc0_1_0 + 1),r7 + mov (__mulslong_sloc0_1_0 + 2),r0 + mov (__mulslong_sloc0_1_0 + 3),r1 +; _muslong.c 29 + mov dptr,#__mulslong_PARM_2 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r1,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,r6 + mov __mulslong_sloc1_1_0,a + clr a + subb a,r7 + mov (__mulslong_sloc1_1_0 + 1),a + clr a + subb a,r0 + mov (__mulslong_sloc1_1_0 + 2),a + clr a + subb a,r1 + mov (__mulslong_sloc1_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov __mulslong_sloc1_1_0,r6 + mov (__mulslong_sloc1_1_0 + 1),r7 + mov (__mulslong_sloc1_1_0 + 2),r0 + mov (__mulslong_sloc1_1_0 + 3),r1 +00109$: + mov dptr,#__mululong_PARM_2 + mov a,__mulslong_sloc1_1_0 + movx @dptr,a + inc dptr + mov a,(__mulslong_sloc1_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(__mulslong_sloc1_1_0 + 2) + movx @dptr,a + inc dptr + mov a,(__mulslong_sloc1_1_0 + 3) + movx @dptr,a + push ar2 + mov dpl,__mulslong_sloc0_1_0 + mov dph,(__mulslong_sloc0_1_0 + 1) + mov b,(__mulslong_sloc0_1_0 + 2) + mov a,(__mulslong_sloc0_1_0 + 3) + lcall __mululong + mov r3,dpl + mov r4,dph + mov r5,b + mov r6,a + pop ar2 +; _muslong.c 31 + push ar3 + push ar4 + push ar5 + push ar6 + mov dptr,#__mulslong_a_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + rlc a + clr a + rlc a + mov r7,a + mov a,r2 + xrl a,ar7 + pop ar6 + pop ar5 + pop ar4 + pop ar3 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _muslong.c 32 + clr c + clr a + subb a,r3 + mov __mulslong_sloc1_1_0,a + clr a + subb a,r4 + mov (__mulslong_sloc1_1_0 + 1),a + clr a + subb a,r5 + mov (__mulslong_sloc1_1_0 + 2),a + clr a + subb a,r6 +; Peephole 191 removed redundant mov + mov (__mulslong_sloc1_1_0 + 3),a + mov dpl,__mulslong_sloc1_1_0 + mov dph,(__mulslong_sloc1_1_0 + 1) + mov b,(__mulslong_sloc1_1_0 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _muslong.c 34 + mov dpl,r3 + mov dph,r4 + mov b,r5 + mov a,r6 +00104$: + C$_muslong.c$35$1$1 ==. + XG$_mulslong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_muslong.cdb b/device/lib/large/_muslong.cdb new file mode 100644 index 00000000..7932ad22 --- /dev/null +++ b/device/lib/large/_muslong.cdb @@ -0,0 +1,2 @@ +M:_muslong +F:G$_mulslong$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_muslong.rel b/device/lib/large/_muslong.rel new file mode 100644 index 00000000..6a37bdff --- /dev/null +++ b/device/lib/large/_muslong.rel @@ -0,0 +1,265 @@ +;!FILE _muslong.asm +XH +H 8 areas A5 global symbols +M _muslong +S __mululong_PARM_2 Ref0000 +S __mululong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S __mulslong_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size EF flags 20 +S G$_mulslong$0$0 Def0000 +S A$_muslong$100 Def0028 +S A$_muslong$200 Def00B0 +S A$_muslong$110 Def0033 +S A$_muslong$210 Def00B9 +S A$_muslong$201 Def00B1 +S A$_muslong$120 Def003E +S A$_muslong$111 Def0034 +S A$_muslong$102 Def002B +S A$_muslong$220 Def00C7 +S A$_muslong$211 Def00BA +S A$_muslong$202 Def00B2 +S A$_muslong$130 Def004E +S A$_muslong$121 Def0040 +S A$_muslong$112 Def0035 +S A$_muslong$103 Def002C +S A$_muslong$230 Def00D1 +S A$_muslong$212 Def00BB +S A$_muslong$203 Def00B3 +S A$_muslong$140 Def0057 +S A$_muslong$131 Def004F +S A$_muslong$113 Def0036 +S A$_muslong$104 Def002D +S A$_muslong$240 Def00DF +S A$_muslong$231 Def00D2 +S A$_muslong$222 Def00C9 +S A$_muslong$213 Def00BC +S A$_muslong$204 Def00B4 +S A$_muslong$150 Def005F +S A$_muslong$141 Def0058 +S A$_muslong$132 Def0050 +S A$_muslong$123 Def0042 +S A$_muslong$114 Def0037 +S A$_muslong$105 Def002E +S A$_muslong$241 Def00E2 +S A$_muslong$232 Def00D4 +S A$_muslong$214 Def00BD +S A$_muslong$205 Def00B5 +S A$_muslong$160 Def006C +S A$_muslong$151 Def0060 +S A$_muslong$142 Def0059 +S A$_muslong$133 Def0051 +S A$_muslong$124 Def0044 +S A$_muslong$106 Def002F +S A$_muslong$233 Def00D5 +S A$_muslong$215 Def00BE +S A$_muslong$206 Def00B6 +S A$_muslong$170 Def0079 +S A$_muslong$161 Def006D +S A$_muslong$152 Def0061 +S A$_muslong$143 Def005A +S A$_muslong$134 Def0052 +S A$_muslong$125 Def0046 +S A$_muslong$116 Def0038 +S A$_muslong$107 Def0030 +S A$_muslong$243 Def00E5 +S A$_muslong$234 Def00D6 +S A$_muslong$225 Def00CB +S A$_muslong$216 Def00BF +S A$_muslong$207 Def00B7 +S A$_muslong$180 Def0088 +S A$_muslong$171 Def007C +S A$_muslong$153 Def0063 +S A$_muslong$135 Def0053 +S A$_muslong$126 Def0048 +S A$_muslong$108 Def0031 +S A$_muslong$253 Def00EE +S A$_muslong$235 Def00D8 +S A$_muslong$226 Def00CC +S A$_muslong$217 Def00C1 +S A$_muslong$208 Def00B8 +S A$_muslong$190 Def009F +S A$_muslong$181 Def008A +S A$_muslong$172 Def007E +S A$_muslong$163 Def006F +S A$_muslong$154 Def0064 +S A$_muslong$145 Def005B +S A$_muslong$136 Def0054 +S A$_muslong$118 Def003A +S A$_muslong$109 Def0032 +S A$_muslong$236 Def00D9 +S A$_muslong$227 Def00CD +S A$_muslong$218 Def00C3 +S A$_muslong$191 Def00A1 +S A$_muslong$182 Def008B +S A$_muslong$173 Def007F +S A$_muslong$155 Def0065 +S A$_muslong$137 Def0055 +S A$_muslong$128 Def004A +S A$_muslong$119 Def003C +S A$_muslong$246 Def00E7 +S A$_muslong$228 Def00CE +S A$_muslong$219 Def00C5 +S A$_muslong$192 Def00A2 +S A$_muslong$183 Def008D +S A$_muslong$174 Def0080 +S A$_muslong$165 Def0071 +S A$_muslong$156 Def0067 +S A$_muslong$147 Def005C +S A$_muslong$138 Def0056 +S A$_muslong$129 Def004D +S A$_muslong$247 Def00E9 +S A$_muslong$238 Def00DA +S A$_muslong$229 Def00D0 +S A$_muslong$184 Def0090 +S A$_muslong$175 Def0082 +S A$_muslong$166 Def0073 +S A$_muslong$157 Def0068 +S A$_muslong$248 Def00EB +S A$_muslong$239 Def00DC +S A$_muslong$194 Def00A4 +S A$_muslong$185 Def0093 +S A$_muslong$176 Def0083 +S A$_muslong$167 Def0075 +S A$_muslong$158 Def0069 +S A$_muslong$149 Def005E +S A$_muslong$249 Def00ED +S A$_muslong$195 Def00A6 +S A$_muslong$186 Def0096 +S A$_muslong$177 Def0084 +S A$_muslong$168 Def0077 +S A$_muslong$159 Def006B +S A$_muslong$196 Def00A8 +S A$_muslong$187 Def0098 +S A$_muslong$178 Def0086 +S A$_muslong$197 Def00AA +S A$_muslong$188 Def009B +S A$_muslong$179 Def0087 +S A$_muslong$198 Def00AC +S A$_muslong$189 Def009D +S __mulslong Def0000 +S A$_muslong$199 Def00AF +S C$_muslong.c$35$1$1 Def00EE +S A$_muslong$70 Def0002 +S A$_muslong$80 Def0014 +S A$_muslong$71 Def0004 +S A$_muslong$90 Def0020 +S A$_muslong$81 Def0015 +S A$_muslong$72 Def0006 +S A$_muslong$91 Def0021 +S A$_muslong$82 Def0016 +S A$_muslong$73 Def0008 +S A$_muslong$92 Def0022 +S A$_muslong$83 Def0018 +S A$_muslong$74 Def000B +S A$_muslong$93 Def0023 +S A$_muslong$84 Def0019 +S A$_muslong$75 Def000D +S A$_muslong$94 Def0024 +S A$_muslong$76 Def000E +S A$_muslong$95 Def0025 +S A$_muslong$86 Def001A +S A$_muslong$77 Def0010 +S XG$_mulslong$0$0 Def00EE +S A$_muslong$96 Def0026 +S A$_muslong$87 Def001D +S A$_muslong$78 Def0011 +S A$_muslong$69 Def0000 +S A$_muslong$88 Def001E +S A$_muslong$79 Def0012 +S A$_muslong$98 Def0027 +S A$_muslong$89 Def001F +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 04 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD 30 +R 00 00 00 07 00 02 00 05 +T 00 29 E7 0F +R 00 00 00 07 +T 00 2B +R 00 00 00 07 +T 00 2B C3 E4 9A FE E4 9B FF E4 9C F8 E4 9D F9 80 +R 00 00 00 07 +T 00 39 08 +R 00 00 00 07 +T 00 3A +R 00 00 00 07 +T 00 3A 8A 06 8B 07 8C 00 8D 01 +R 00 00 00 07 +T 00 42 +R 00 00 00 07 +T 00 42 8E 00 00 8F 00 01 88 00 02 89 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 49 00 03 90 00 00 E0 FE A3 E0 FF A3 E0 F8 A3 +R 00 00 00 07 29 02 00 01 00 05 00 05 +T 00 56 E0 F9 33 E4 33 FA 60 13 +R 00 00 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E C3 E4 9E F5 00 04 E4 9F F5 00 05 E4 98 F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 6A 00 06 E4 99 F5 00 07 80 08 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 71 +R 00 00 00 07 +T 00 71 8E 00 04 8F 00 05 88 00 06 89 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 78 00 07 +R 00 00 00 07 29 02 00 01 +T 00 79 +R 00 00 00 07 +T 00 79 90 00 00 E5 00 04 F0 A3 E5 00 05 F0 A3 E5 +R 00 00 00 07 02 03 00 00 29 06 00 01 29 0B 00 01 +T 00 85 00 06 F0 A3 E5 00 07 F0 C0 02 85 00 00 82 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0D 00 01 +T 00 90 85 00 01 83 85 00 02 F0 E5 00 03 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 99 00 00 AB 82 AC 83 AD F0 FE D0 02 C0 03 C0 +R 00 00 00 07 02 02 00 01 +T 00 A7 04 C0 05 C0 06 90 00 04 E0 FF A3 E0 F8 A3 +R 00 00 00 07 00 08 00 05 +T 00 B5 E0 F9 A3 E0 FB 33 E4 33 FF EA 65 07 D0 06 +R 00 00 00 07 +T 00 C3 D0 05 D0 04 D0 03 60 1C +R 00 00 00 07 +T 00 CB +R 00 00 00 07 +T 00 CB C3 E4 9B F5 00 04 E4 9C F5 00 05 E4 9D F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 D7 00 06 E4 9E F5 00 07 85 00 04 82 85 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0A 00 01 +T 00 E0 00 05 83 85 00 06 F0 80 07 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 00 E7 +R 00 00 00 07 +T 00 E7 8B 82 8C 83 8D F0 EE +R 00 00 00 07 +T 00 EE +R 00 00 00 07 +T 00 EE 22 +R 00 00 00 07 diff --git a/device/lib/large/_ser.asm b/device/lib/large/_ser.asm new file mode 100644 index 00000000..d952b560 --- /dev/null +++ b/device/lib/large/_ser.asm @@ -0,0 +1,636 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + +;-------------------------------------------------------- + .module _ser +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _ser_charAvail + .globl _ser_printString + .globl _ser_getc + .globl _ser_putc + .globl _ser_interrupt_handler + .globl _ser_init + .globl _ser_rxBuffer + .globl _ser_txBuffer + .globl _ser_rxIndexOut + .globl _ser_rxIndexIn + .globl _ser_txIndexOut + .globl _ser_txIndexIn +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +F_ser$ser_txBusy$0$0==. +_ser_txBusy: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +G$ser_txIndexIn$0$0==. +_ser_txIndexIn: + .ds 0x0001 +G$ser_txIndexOut$0$0==. +_ser_txIndexOut: + .ds 0x0001 +G$ser_rxIndexIn$0$0==. +_ser_rxIndexIn: + .ds 0x0001 +G$ser_rxIndexOut$0$0==. +_ser_rxIndexOut: + .ds 0x0001 +G$ser_txBuffer$0$0==. +_ser_txBuffer: + .ds 0x0100 +G$ser_rxBuffer$0$0==. +_ser_rxBuffer: + .ds 0x0100 +_ser_putc_c_1_1: + .ds 0x0001 +_ser_getc_tmp_1_1: + .ds 0x0001 +_ser_printString_String_1_1: + .ds 0x0003 +_ser_charAvail_ret_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$ser_init$0$0 ==. +; _ser.c 49 +; ----------------------------------------- +; function ser_init +; ----------------------------------------- +_ser_init: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ser.c 51 + clr _ES +; _ser.c 53 + clr _ser_txBusy +; _ser.c 55 + mov dptr,#_ser_txIndexIn +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 56 + mov dptr,#_ser_txIndexOut +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 57 + mov dptr,#_ser_rxIndexIn +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 58 + mov dptr,#_ser_rxIndexOut +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 60 + mov _T2CON,#0x30 +; _ser.c 63 + mov _RCAP2H,#0xff +; _ser.c 64 + mov _RCAP2L,#0xdd +; _ser.c 67 + mov _T2CON,#0x34 +; _ser.c 69 + mov _SCON,#0x50 +; _ser.c 71 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00102$ +00109$: +; _ser.c 72 + clr _TI +00102$: +; _ser.c 74 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00104$ +00110$: +; _ser.c 75 + clr _RI +00104$: +; _ser.c 78 + setb _ES +00105$: + C$_ser.c$79$1$1 ==. + XG$ser_init$0$0 ==. + ret + G$ser_interrupt_handler$0$0 ==. +; _ser.c 82 +; ----------------------------------------- +; function ser_interrupt_handler +; ----------------------------------------- +_ser_interrupt_handler: + ar2 = 0x0a + ar3 = 0x0b + ar4 = 0x0c + ar5 = 0x0d + ar6 = 0x0e + ar7 = 0x0f + ar0 = 0x08 + ar1 = 0x09 + push acc + push b + push dpl + push dph + push psw + mov psw,#0x08 +; _ser.c 84 + clr _ES +; _ser.c 86 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00105$ +00113$: +; _ser.c 87 + clr _TI +; _ser.c 88 + mov dptr,#_ser_txIndexOut + movx a,@dptr + mov r2,a + mov dptr,#_ser_txIndexIn + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar2,00102$ +; Peephole 201 removed redundant sjmp +00114$: +00115$: +; _ser.c 89 + clr _ser_txBusy +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00102$: +; _ser.c 92 + mov dptr,#_ser_txIndexOut + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_ser_txBuffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_txBuffer >> 8) + mov dph,a + movx a,@dptr + mov _SBUF,a +00105$: +; _ser.c 96 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00107$ +00116$: +; _ser.c 97 + clr _RI +; _ser.c 98 + mov dptr,#_ser_rxIndexIn + movx a,@dptr + mov r2,a + mov dptr,#_ser_rxIndexIn + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_ser_rxBuffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_rxBuffer >> 8) + mov dph,a + mov a,_SBUF + movx @dptr,a +00107$: +; _ser.c 101 + setb _ES +00108$: + pop psw + pop dph + pop dpl + pop b + pop acc + C$_ser.c$102$1$1 ==. + XG$ser_interrupt_handler$0$0 ==. + reti + G$ser_putc$0$0 ==. +; _ser.c 105 +; ----------------------------------------- +; function ser_putc +; ----------------------------------------- +_ser_putc: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ser.c 117 + push dpl + mov dptr,#_ser_putc_c_1_1 + pop acc + movx @dptr,a +; _ser.c 107 + clr _ES +; _ser.c 109 +; Peephole 111 removed ljmp by inverse jump logic + jnb _ser_txBusy,00102$ +00107$: +; _ser.c 110 + mov dptr,#_ser_txIndexIn + movx a,@dptr + mov r2,a + mov dptr,#_ser_txIndexIn + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_ser_txBuffer + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_txBuffer >> 8) + mov r3,a + mov dptr,#_ser_putc_c_1_1 + movx a,@dptr +; Peephole 136 removed redundant moves + mov r4,a + mov dpl,r2 + mov dph,r3 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: +; _ser.c 113 + setb _ser_txBusy +; _ser.c 114 + mov dptr,#_ser_putc_c_1_1 + movx a,@dptr + mov _SBUF,a +00103$: +; _ser.c 117 + setb _ES +00104$: + C$_ser.c$118$1$1 ==. + XG$ser_putc$0$0 ==. + ret + G$ser_getc$0$0 ==. +; _ser.c 121 +; ----------------------------------------- +; function ser_getc +; ----------------------------------------- +_ser_getc: +; _ser.c 126 + mov dptr,#_ser_rxIndexOut + movx a,@dptr + mov r2,a + mov dptr,#_ser_rxIndexIn + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + cjne a,ar2,00107$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00107$: +; _ser.c 127 + mov dptr,#_ser_rxIndexOut + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_ser_rxBuffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_rxBuffer >> 8) + mov dph,a + movx a,@dptr +; Peephole 100 removed redundant mov + mov r2,a + mov dptr,#_ser_getc_tmp_1_1 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: +; _ser.c 130 + mov dptr,#_ser_getc_tmp_1_1 +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +00103$: +; _ser.c 134 + mov dptr,#_ser_getc_tmp_1_1 + movx a,@dptr + mov r2,a + mov dpl,r2 +00104$: + C$_ser.c$135$1$1 ==. + XG$ser_getc$0$0 ==. + ret + G$ser_printString$0$0 ==. +; _ser.c 138 +; ----------------------------------------- +; function ser_printString +; ----------------------------------------- +_ser_printString: +; _ser.c 0 + push b + push dph + push dpl + mov dptr,#_ser_printString_String_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _ser.c 140 + mov dptr,#_ser_printString_String_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +00101$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget + mov r5,a + mov dptr,#_ser_printString_String_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov a,r5 +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00108$: +; _ser.c 141 + inc r2 + cjne r2,#0x00,00109$ + inc r3 +00109$: + push ar2 + push ar3 + push ar4 + mov dpl,r5 + lcall _ser_putc + pop ar4 + pop ar3 + pop ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00104$: + C$_ser.c$143$1$1 ==. + XG$ser_printString$0$0 ==. + ret + G$ser_charAvail$0$0 ==. +; _ser.c 146 +; ----------------------------------------- +; function ser_charAvail +; ----------------------------------------- +_ser_charAvail: +; _ser.c 148 + mov dptr,#_ser_charAvail_ret_1_1 +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 150 + mov dptr,#_ser_rxIndexOut + movx a,@dptr + mov r2,a + mov dptr,#_ser_rxIndexIn + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + cjne a,ar2,00106$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00106$: +; _ser.c 151 + mov dptr,#_ser_charAvail_ret_1_1 + mov a,#0x01 + movx @dptr,a +00102$: +; _ser.c 154 + mov dptr,#_ser_charAvail_ret_1_1 + movx a,@dptr + mov r2,a + mov dpl,r2 +00103$: + C$_ser.c$155$1$1 ==. + XG$ser_charAvail$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_ser.cdb b/device/lib/large/_ser.cdb new file mode 100644 index 00000000..51a66fbe --- /dev/null +++ b/device/lib/large/_ser.cdb @@ -0,0 +1,97 @@ +M:_ser +F:G$ser_init$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_interrupt_handler$0$0({2}DF,SV:S),Z,0,0,1,4,1 +F:G$ser_putc$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_getc$0$0({2}DF,SC:U),Z,0,0,0,0,0 +F:G$ser_printString$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_charAvail$0$0({2}DF,SS:S),Z,0,0,0,0,0 +S:F_ser$ser_txBusy$0$0({1}SB0$1:S),H,0,0 +S:G$ser_txIndexIn$0$0({1}SC:U),F,0,0 +S:G$ser_txIndexOut$0$0({1}SC:U),F,0,0 +S:G$ser_rxIndexIn$0$0({1}SC:U),F,0,0 +S:G$ser_rxIndexOut$0$0({1}SC:U),F,0,0 +S:G$ser_txBuffer$0$0({256}DA256,SC:U),F,0,0 +S:G$ser_rxBuffer$0$0({256}DA256,SC:U),F,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/large/_ser.rel b/device/lib/large/_ser.rel new file mode 100644 index 00000000..84960b53 --- /dev/null +++ b/device/lib/large/_ser.rel @@ -0,0 +1,556 @@ +;!FILE _ser.asm +XH +H 8 areas 14C global symbols +M _ser +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 1 flags 80 +S F_ser$ser_txBusy$0$0 Def0000 +A XSEG size 20A flags 40 +S G$ser_rxBuffer$0$0 Def0104 +S G$ser_txBuffer$0$0 Def0004 +S _ser_rxIndexIn Def0002 +S _ser_rxIndexOut Def0003 +S _ser_txIndexIn Def0000 +S _ser_txIndexOut Def0001 +S _ser_rxBuffer Def0104 +S _ser_txBuffer Def0004 +S G$ser_rxIndexIn$0$0 Def0002 +S G$ser_rxIndexOut$0$0 Def0003 +S G$ser_txIndexIn$0$0 Def0000 +S G$ser_txIndexOut$0$0 Def0001 +A GSINIT size 0 flags 20 +A CSEG size 177 flags 20 +S _ser_putc Def0098 +S G$ser_interrupt_handler$0$0 Def0034 +S G$ser_charAvail$0$0 Def0155 +S XG$ser_init$0$0 Def0033 +S _ser_printString Def0105 +S XG$ser_putc$0$0 Def00CF +S G$ser_init$0$0 Def0000 +S XG$ser_printString$0$0 Def0154 +S G$ser_putc$0$0 Def0098 +S G$ser_printString$0$0 Def0105 +S C$_ser.c$102$1$1 Def0097 +S A$_ser$400 Def0084 +S A$_ser$301 Def0027 +S A$_ser$500 Def00E4 +S A$_ser$410 Def0091 +S A$_ser$401 Def0086 +S A$_ser$311 Def002F +S C$_ser.c$143$1$1 Def0154 +S A$_ser$501 Def00E5 +S A$_ser$411 Def0093 +S A$_ser$402 Def0088 +S C$_ser.c$135$1$1 Def0104 +S A$_ser$520 Def00FB +S A$_ser$511 Def00F1 +S A$_ser$502 Def00E6 +S A$_ser$412 Def0095 +S A$_ser$403 Def008A +S A$_ser$340 Def0041 +S A$_ser$304 Def002A +S C$_ser.c$118$1$1 Def00CF +S A$_ser$620 Def0167 +S A$_ser$611 Def015A +S A$_ser$521 Def00FC +S A$_ser$512 Def00F2 +S A$_ser$503 Def00E7 +S A$_ser$431 Def0098 +S A$_ser$350 Def004C +S A$_ser$314 Def0031 +S C$_ser.c$155$1$1 Def0176 +S A$_ser$630 Def0173 +S A$_ser$612 Def015D +S A$_ser$540 Def0107 +S A$_ser$531 Def0104 +S A$_ser$513 Def00F5 +S A$_ser$504 Def00E9 +S A$_ser$450 Def00B2 +S A$_ser$432 Def009A +S A$_ser$351 Def004D +S A$_ser$333 Def0034 +S A$_ser$270 Def0004 +S _ser_getc Def00D0 +S A$_ser$631 Def0174 +S A$_ser$613 Def015E +S A$_ser$550 Def0118 +S A$_ser$541 Def0109 +S A$_ser$460 Def00BE +S A$_ser$451 Def00B4 +S A$_ser$442 Def00A5 +S A$_ser$433 Def009D +S A$_ser$415 Def0097 +S A$_ser$406 Def008B +S A$_ser$370 Def005F +S A$_ser$352 Def0050 +S A$_ser$343 Def0043 +S A$_ser$334 Def0036 +S A$_ser$280 Def000E +S A$_ser$623 Def0169 +S A$_ser$614 Def015F +S A$_ser$560 Def0123 +S A$_ser$542 Def010B +S A$_ser$524 Def00FD +S A$_ser$515 Def00F6 +S A$_ser$506 Def00EB +S A$_ser$470 Def00CA +S A$_ser$461 Def00C0 +S A$_ser$443 Def00A8 +S A$_ser$434 Def009F +S A$_ser$371 Def0060 +S A$_ser$362 Def0055 +S A$_ser$335 Def0038 +S A$_ser$308 Def002C +S A$_ser$290 Def0018 +S A$_ser$272 Def0007 +S A$_ser$624 Def016C +S A$_ser$615 Def0162 +S A$_ser$606 Def0155 +S A$_ser$570 Def0133 +S A$_ser$552 Def0119 +S A$_ser$543 Def010E +S A$_ser$525 Def0100 +S A$_ser$507 Def00EC +S A$_ser$471 Def00CB +S A$_ser$462 Def00C2 +S A$_ser$453 Def00B5 +S A$_ser$444 Def00A9 +S A$_ser$408 Def008D +S A$_ser$390 Def0076 +S A$_ser$372 Def0061 +S A$_ser$354 Def0051 +S A$_ser$336 Def003A +S A$_ser$318 Def0033 +S A$_ser$282 Def0011 +S A$_ser$273 Def0008 +S A$_ser$625 Def016E +S A$_ser$571 Def0134 +S A$_ser$562 Def0124 +S A$_ser$553 Def011C +S A$_ser$544 Def0110 +S A$_ser$526 Def0101 +S A$_ser$508 Def00EE +S A$_ser$490 Def00D8 +S A$_ser$454 Def00B6 +S A$_ser$445 Def00AA +S A$_ser$436 Def00A0 +S A$_ser$409 Def008F +S A$_ser$391 Def0077 +S A$_ser$373 Def0063 +S A$_ser$364 Def0057 +S A$_ser$346 Def0046 +S A$_ser$337 Def003C +S A$_ser$292 Def001B +S A$_ser$283 Def0012 +S A$_ser$635 Def0176 +S A$_ser$617 Def0163 +S A$_ser$608 Def0158 +S A$_ser$590 Def014C +S A$_ser$581 Def013C +S A$_ser$572 Def0135 +S A$_ser$563 Def0126 +S A$_ser$554 Def011D +S A$_ser$545 Def0111 +S A$_ser$527 Def0102 +S A$_ser$518 Def00F8 +S A$_ser$509 Def00F0 +S A$_ser$464 Def00C3 +S A$_ser$455 Def00B8 +S A$_ser$446 Def00AD +S A$_ser$392 Def007A +S A$_ser$383 Def006D +S A$_ser$338 Def003E +S A$_ser$275 Def0009 +S A$_ser$266 Def0000 +S A$_ser$618 Def0164 +S A$_ser$609 Def0159 +S A$_ser$591 Def014E +S A$_ser$582 Def013D +S A$_ser$573 Def0136 +S A$_ser$564 Def0128 +S A$_ser$555 Def011E +S A$_ser$546 Def0113 +S A$_ser$492 Def00D9 +S A$_ser$474 Def00CD +S A$_ser$456 Def00B9 +S A$_ser$447 Def00AF +S A$_ser$393 Def007C +S A$_ser$375 Def0065 +S A$_ser$357 Def0052 +S A$_ser$348 Def0048 +S A$_ser$294 Def001E +S A$_ser$285 Def0013 +S A$_ser$628 Def016F +S A$_ser$592 Def0150 +S A$_ser$583 Def0140 +S A$_ser$574 Def0137 +S A$_ser$565 Def012A +S A$_ser$556 Def011F +S A$_ser$547 Def0114 +S A$_ser$493 Def00DA +S A$_ser$457 Def00BC +S A$_ser$448 Def00B0 +S A$_ser$439 Def00A2 +S A$_ser$394 Def007D +S A$_ser$376 Def0066 +S A$_ser$367 Def0059 +S A$_ser$349 Def004B +S A$_ser$277 Def000C +S A$_ser$268 Def0002 +S _ser_interrupt_handler Def0034 +S A$_ser$629 Def0172 +S A$_ser$575 Def0138 +S A$_ser$566 Def012D +S A$_ser$557 Def0120 +S A$_ser$548 Def0115 +S A$_ser$539 Def0105 +S A$_ser$467 Def00C5 +S A$_ser$449 Def00B1 +S A$_ser$395 Def007E +S A$_ser$386 Def0070 +S A$_ser$377 Def0068 +S A$_ser$368 Def005C +S A$_ser$296 Def0021 +S A$_ser$287 Def0016 +S A$_ser$278 Def000D +S _ser_charAvail Def0155 +S A$_ser$594 Def0152 +S A$_ser$585 Def0141 +S A$_ser$576 Def0139 +S A$_ser$567 Def012E +S A$_ser$558 Def0121 +S A$_ser$549 Def0117 +S A$_ser$495 Def00DD +S A$_ser$486 Def00D0 +S A$_ser$459 Def00BD +S A$_ser$396 Def007F +S A$_ser$378 Def006A +S A$_ser$369 Def005E +S A$_ser$288 Def0017 +S A$_ser$586 Def0143 +S A$_ser$568 Def0131 +S A$_ser$559 Def0122 +S A$_ser$487 Def00D3 +S A$_ser$478 Def00CF +S A$_ser$469 Def00C7 +S A$_ser$397 Def0081 +S A$_ser$388 Def0072 +S A$_ser$379 Def006B +S A$_ser$298 Def0024 +S A$_ser$587 Def0145 +S A$_ser$578 Def013A +S A$_ser$569 Def0132 +S A$_ser$488 Def00D4 +S A$_ser$389 Def0075 +S A$_ser$588 Def0147 +S A$_ser$498 Def00DF +S A$_ser$489 Def00D5 +S A$_ser$399 Def0083 +S XG$ser_getc$0$0 Def0104 +S A$_ser$598 Def0154 +S A$_ser$589 Def0149 +S A$_ser$499 Def00E2 +S _ser_init Def0000 +S XG$ser_interrupt_handler$0$0 Def0097 +S XG$ser_charAvail$0$0 Def0176 +S G$ser_getc$0$0 Def00D0 +S C$_ser.c$79$1$1 Def0033 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 01 04 +R 00 00 00 05 +T 01 04 +R 00 00 00 05 +T 02 04 +R 00 00 00 05 +T 02 04 +R 00 00 00 05 +T 02 05 +R 00 00 00 05 +T 02 05 +R 00 00 00 05 +T 02 06 +R 00 00 00 05 +T 02 06 +R 00 00 00 05 +T 02 09 +R 00 00 00 05 +T 02 09 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C2 AC C2 00 00 90 00 00 E4 F0 90 00 01 E4 +R 00 00 00 07 29 05 00 04 00 08 00 05 00 0D 00 05 +T 00 0D F0 90 00 02 E4 F0 90 00 03 E4 F0 75 C8 30 +R 00 00 00 07 00 04 00 05 00 09 00 05 +T 00 1B 75 CB FF 75 CA DD 75 C8 34 75 98 50 30 99 +R 00 00 00 07 +T 00 29 02 +R 00 00 00 07 +T 00 2A +R 00 00 00 07 +T 00 2A C2 99 +R 00 00 00 07 +T 00 2C +R 00 00 00 07 +T 00 2C 30 98 02 +R 00 00 00 07 +T 00 2F +R 00 00 00 07 +T 00 2F C2 98 +R 00 00 00 07 +T 00 31 +R 00 00 00 07 +T 00 31 D2 AC +R 00 00 00 07 +T 00 33 +R 00 00 00 07 +T 00 33 22 +R 00 00 00 07 +T 00 34 +R 00 00 00 07 +T 00 34 C0 E0 C0 F0 C0 82 C0 83 C0 D0 75 D0 08 C2 +R 00 00 00 07 +T 00 42 AC 30 99 27 +R 00 00 00 07 +T 00 46 +R 00 00 00 07 +T 00 46 C2 99 90 00 01 E0 FA 90 00 00 E0 FB B5 0A +R 00 00 00 07 00 05 00 05 00 0A 00 05 +T 00 54 04 +R 00 00 00 07 +T 00 55 +R 00 00 00 07 +T 00 55 +R 00 00 00 07 +T 00 55 C2 00 00 80 14 +R 00 00 00 07 29 03 00 04 +T 00 59 +R 00 00 00 07 +T 00 59 90 00 01 74 01 2A F0 EA 24 00 04 F5 82 E4 +R 00 00 00 07 00 03 00 05 09 0B 00 05 +T 00 66 34 00 04 F5 83 E0 F5 99 +R 00 00 00 07 89 03 00 05 +T 00 6D +R 00 00 00 07 +T 00 6D 30 98 1B +R 00 00 00 07 +T 00 70 +R 00 00 00 07 +T 00 70 C2 98 90 00 02 E0 FA 90 00 02 74 01 2A F0 +R 00 00 00 07 00 05 00 05 00 0A 00 05 +T 00 7E EA 24 01 04 F5 82 E4 34 01 04 F5 83 E5 99 +R 00 00 00 07 09 04 00 05 89 0A 00 05 +T 00 8A F0 +R 00 00 00 07 +T 00 8B +R 00 00 00 07 +T 00 8B D2 AC +R 00 00 00 07 +T 00 8D +R 00 00 00 07 +T 00 8D D0 D0 D0 83 D0 82 D0 F0 D0 E0 32 +R 00 00 00 07 +T 00 98 +R 00 00 00 07 +T 00 98 C0 82 90 02 04 D0 E0 F0 C2 AC 30 00 00 20 +R 00 00 00 07 00 05 00 05 29 0D 00 04 +T 00 A5 +R 00 00 00 07 +T 00 A5 90 00 00 E0 FA 90 00 00 74 01 2A F0 EA 24 +R 00 00 00 07 00 03 00 05 00 08 00 05 +T 00 B3 00 04 FA E4 34 00 04 FB 90 02 04 E0 FC 8A +R 00 00 00 07 09 02 00 05 89 07 00 05 00 0B 00 05 +T 00 BF 82 8B 83 F0 80 08 +R 00 00 00 07 +T 00 C5 +R 00 00 00 07 +T 00 C5 D2 00 00 90 02 04 E0 F5 99 +R 00 00 00 07 29 03 00 04 00 06 00 05 +T 00 CD +R 00 00 00 07 +T 00 CD D2 AC +R 00 00 00 07 +T 00 CF +R 00 00 00 07 +T 00 CF 22 +R 00 00 00 07 +T 00 D0 +R 00 00 00 07 +T 00 D0 90 00 03 E0 FA 90 00 02 E0 FB B5 02 02 80 +R 00 00 00 07 00 03 00 05 00 08 00 05 +T 00 DE 19 +R 00 00 00 07 +T 00 DF +R 00 00 00 07 +T 00 DF 90 00 03 74 01 2A F0 EA 24 01 04 F5 82 E4 +R 00 00 00 07 00 03 00 05 09 0B 00 05 +T 00 EC 34 01 04 F5 83 E0 FA 90 02 05 F0 80 05 +R 00 00 00 07 89 03 00 05 00 0A 00 05 +T 00 F8 +R 00 00 00 07 +T 00 F8 90 02 05 E4 F0 +R 00 00 00 07 00 03 00 05 +T 00 FD +R 00 00 00 07 +T 00 FD 90 02 05 E0 FA 8A 82 +R 00 00 00 07 00 03 00 05 +T 01 04 +R 00 00 00 07 +T 01 04 22 +R 00 00 00 07 +T 01 05 +R 00 00 00 07 +T 01 05 C0 F0 C0 83 C0 82 90 02 06 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 01 13 A3 F0 D0 E0 A3 F0 90 02 06 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 01 21 A3 E0 FC +R 00 00 00 07 +T 01 24 +R 00 00 00 07 +T 01 24 8A 82 8B 83 8C F0 12 00 00 FD 90 02 06 EA +R 00 00 00 07 02 09 00 4D 00 0D 00 05 +T 01 32 F0 A3 EB F0 A3 EC F0 ED 60 18 +R 00 00 00 07 +T 01 3C +R 00 00 00 07 +T 01 3C 0A BA 00 01 0B +R 00 00 00 07 +T 01 41 +R 00 00 00 07 +T 01 41 C0 02 C0 03 C0 04 8D 82 12 00 98 D0 04 D0 +R 00 00 00 07 00 0B 00 07 +T 01 4F 03 D0 02 80 D0 +R 00 00 00 07 +T 01 54 +R 00 00 00 07 +T 01 54 22 +R 00 00 00 07 +T 01 55 +R 00 00 00 07 +T 01 55 90 02 09 E4 F0 90 00 03 E0 FA 90 00 02 E0 +R 00 00 00 07 00 03 00 05 00 08 00 05 00 0D 00 05 +T 01 63 FB B5 02 02 80 06 +R 00 00 00 07 +T 01 69 +R 00 00 00 07 +T 01 69 90 02 09 74 01 F0 +R 00 00 00 07 00 03 00 05 +T 01 6F +R 00 00 00 07 +T 01 6F 90 02 09 E0 FA 8A 82 +R 00 00 00 07 00 03 00 05 +T 01 76 +R 00 00 00 07 +T 01 76 22 +R 00 00 00 07 diff --git a/device/lib/large/_setjmp.asm b/device/lib/large/_setjmp.asm new file mode 100644 index 00000000..5664bc72 --- /dev/null +++ b/device/lib/large/_setjmp.asm @@ -0,0 +1,403 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + +;-------------------------------------------------------- + .module _setjmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _setjmp + .globl _longjmp + .globl _longjmp_PARM_2 +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_setjmp_sloc0_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_longjmp_PARM_2: + .ds 0x0002 +_longjmp_bp_1_1: + .ds 0x0003 +_setjmp_bp_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$longjmp$0$0 ==. +; _setjmp.c 28 +; ----------------------------------------- +; function longjmp +; ----------------------------------------- +_longjmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _setjmp.c 35 + push b + push dph + push dpl + mov dptr,#_longjmp_bp_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _setjmp.c 31 + mov dptr,#_longjmp_bp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov a,#0x02 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a + mov b,r4 + lcall __gptrget + mov r5,a +; _setjmp.c 32 + mov ar0,r5 + mov a,#0x01 + add a,r2 + mov r6,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r7,a + mov ar1,r4 + mov dptr,#_longjmp_bp_1_1 + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 192 used a instead of ar2 as source + mov r2,a + mov @r0,a +; _setjmp.c 33 + dec r0 + mov dpl,r6 + mov dph,r7 + mov b,r1 + lcall __gptrget +; Peephole 192 used a instead of ar6 as source + mov r6,a + mov @r0,a +; _setjmp.c 34 + mov _SP,r5 +; _setjmp.c 35 + mov dptr,#_longjmp_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r5,a + mov dpl,r2 + mov dph,r5 +00101$: + C$_setjmp.c$36$1$1 ==. + XG$longjmp$0$0 ==. + ret + G$setjmp$0$0 ==. +; _setjmp.c 38 +; ----------------------------------------- +; function setjmp +; ----------------------------------------- +_setjmp: +; _setjmp.c 0 + push b + push dph + push dpl + mov dptr,#_setjmp_bp_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _setjmp.c 43 + mov dptr,#_setjmp_bp_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov a,#0x01 + add a,r2 + mov _setjmp_sloc0_1_0,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov (_setjmp_sloc0_1_0 + 1),a + mov (_setjmp_sloc0_1_0 + 2),r4 + mov r0,_SP + mov ar5,@r0 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 + lcall __gptrput +; _setjmp.c 44 + mov a,#0x01 + add a,_setjmp_sloc0_1_0 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,(_setjmp_sloc0_1_0 + 1) + mov r3,a + mov r4,(_setjmp_sloc0_1_0 + 2) + mov dptr,#_setjmp_bp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov r5,_SP + mov a,r5 + add a,#0xff + mov r0,a + mov ar5,@r0 + mov dpl,_setjmp_sloc0_1_0 + mov dph,(_setjmp_sloc0_1_0 + 1) + mov b,(_setjmp_sloc0_1_0 + 2) + mov a,r5 + lcall __gptrput +; _setjmp.c 45 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,_SP + lcall __gptrput +; _setjmp.c 46 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 +00101$: + C$_setjmp.c$48$1$1 ==. + XG$setjmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_setjmp.cdb b/device/lib/large/_setjmp.cdb new file mode 100644 index 00000000..ff668dbf --- /dev/null +++ b/device/lib/large/_setjmp.cdb @@ -0,0 +1,86 @@ +M:_setjmp +F:G$longjmp$0$0({2}DF,SI:S),C,0,0,0,0,0 +F:G$setjmp$0$0({2}DF,SI:S),C,0,0,0,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/large/_setjmp.rel b/device/lib/large/_setjmp.rel new file mode 100644 index 00000000..1dbd6bee --- /dev/null +++ b/device/lib/large/_setjmp.rel @@ -0,0 +1,306 @@ +;!FILE _setjmp.asm +XH +H 8 areas E8 global symbols +M _setjmp +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S __gptrput Ref0000 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 3 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S _longjmp_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size DC flags 20 +S C$_setjmp.c$36$1$1 Def0069 +S C$_setjmp.c$48$1$1 Def00DB +S G$setjmp$0$0 Def006A +S _longjmp Def0000 +S XG$longjmp$0$0 Def0069 +S G$longjmp$0$0 Def0000 +S A$_setjmp$310 Def0063 +S A$_setjmp$301 Def0059 +S A$_setjmp$311 Def0064 +S A$_setjmp$302 Def005A +S A$_setjmp$402 Def00DB +S A$_setjmp$330 Def0075 +S A$_setjmp$312 Def0065 +S A$_setjmp$240 Def0009 +S A$_setjmp$340 Def0082 +S A$_setjmp$331 Def0076 +S A$_setjmp$313 Def0067 +S A$_setjmp$304 Def005B +S A$_setjmp$250 Def0017 +S A$_setjmp$241 Def000B +S _setjmp Def006A +S A$_setjmp$341 Def0083 +S A$_setjmp$332 Def0078 +S A$_setjmp$260 Def0022 +S A$_setjmp$251 Def0018 +S A$_setjmp$242 Def000C +S A$_setjmp$360 Def009E +S A$_setjmp$351 Def008E +S A$_setjmp$342 Def0084 +S A$_setjmp$333 Def0079 +S A$_setjmp$306 Def005D +S A$_setjmp$270 Def0030 +S A$_setjmp$252 Def0019 +S A$_setjmp$243 Def000E +S A$_setjmp$370 Def00AB +S A$_setjmp$361 Def009F +S A$_setjmp$352 Def008F +S A$_setjmp$343 Def0085 +S A$_setjmp$334 Def007A +S A$_setjmp$325 Def006A +S A$_setjmp$307 Def0060 +S A$_setjmp$280 Def003D +S A$_setjmp$271 Def0032 +S A$_setjmp$262 Def0024 +S A$_setjmp$253 Def001A +S A$_setjmp$244 Def000F +S A$_setjmp$380 Def00B8 +S A$_setjmp$371 Def00AD +S A$_setjmp$353 Def0090 +S A$_setjmp$344 Def0086 +S A$_setjmp$335 Def007C +S A$_setjmp$326 Def006C +S A$_setjmp$317 Def0069 +S A$_setjmp$308 Def0061 +S A$_setjmp$290 Def004A +S A$_setjmp$281 Def003E +S A$_setjmp$272 Def0033 +S A$_setjmp$263 Def0025 +S A$_setjmp$254 Def001B +S A$_setjmp$245 Def0010 +S A$_setjmp$236 Def0000 +S A$_setjmp$381 Def00BA +S A$_setjmp$372 Def00B0 +S A$_setjmp$363 Def00A2 +S A$_setjmp$354 Def0092 +S A$_setjmp$345 Def0087 +S A$_setjmp$336 Def007D +S A$_setjmp$327 Def006E +S A$_setjmp$309 Def0062 +S A$_setjmp$282 Def003F +S A$_setjmp$264 Def0026 +S A$_setjmp$255 Def001C +S A$_setjmp$246 Def0012 +S A$_setjmp$237 Def0002 +S A$_setjmp$391 Def00CD +S A$_setjmp$382 Def00BB +S A$_setjmp$373 Def00B1 +S A$_setjmp$364 Def00A4 +S A$_setjmp$355 Def0094 +S A$_setjmp$346 Def0088 +S A$_setjmp$328 Def0070 +S A$_setjmp$292 Def004D +S A$_setjmp$283 Def0040 +S A$_setjmp$274 Def0034 +S A$_setjmp$265 Def0028 +S A$_setjmp$256 Def001D +S A$_setjmp$247 Def0013 +S A$_setjmp$238 Def0004 +S A$_setjmp$392 Def00CF +S A$_setjmp$383 Def00BD +S A$_setjmp$374 Def00B2 +S A$_setjmp$365 Def00A6 +S A$_setjmp$356 Def0096 +S A$_setjmp$347 Def0089 +S A$_setjmp$338 Def007E +S A$_setjmp$329 Def0073 +S A$_setjmp$293 Def004E +S A$_setjmp$284 Def0041 +S A$_setjmp$275 Def0035 +S A$_setjmp$266 Def002A +S A$_setjmp$257 Def001E +S A$_setjmp$239 Def0006 +S A$_setjmp$393 Def00D1 +S A$_setjmp$384 Def00BE +S A$_setjmp$375 Def00B3 +S A$_setjmp$357 Def0098 +S A$_setjmp$348 Def008B +S A$_setjmp$339 Def0081 +S A$_setjmp$285 Def0042 +S A$_setjmp$276 Def0036 +S A$_setjmp$267 Def002D +S A$_setjmp$258 Def001F +S A$_setjmp$249 Def0014 +S A$_setjmp$394 Def00D3 +S A$_setjmp$385 Def00C0 +S A$_setjmp$376 Def00B4 +S A$_setjmp$367 Def00A7 +S A$_setjmp$358 Def009A +S A$_setjmp$349 Def008C +S A$_setjmp$295 Def004F +S A$_setjmp$286 Def0043 +S A$_setjmp$277 Def0037 +S A$_setjmp$259 Def0021 +S A$_setjmp$395 Def00D5 +S A$_setjmp$386 Def00C3 +S A$_setjmp$377 Def00B5 +S A$_setjmp$368 Def00A8 +S A$_setjmp$359 Def009C +S A$_setjmp$296 Def0050 +S A$_setjmp$287 Def0044 +S A$_setjmp$278 Def0039 +S A$_setjmp$269 Def002E +S A$_setjmp$387 Def00C6 +S A$_setjmp$378 Def00B6 +S A$_setjmp$369 Def00AA +S A$_setjmp$297 Def0052 +S A$_setjmp$288 Def0046 +S A$_setjmp$279 Def003C +S A$_setjmp$388 Def00C9 +S A$_setjmp$379 Def00B7 +S A$_setjmp$298 Def0054 +S A$_setjmp$289 Def0048 +S XG$setjmp$0$0 Def00DB +S A$_setjmp$398 Def00D8 +S A$_setjmp$389 Def00CA +S A$_setjmp$299 Def0056 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 02 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 02 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 74 02 2A F5 82 E4 3B F5 83 8C F0 +R 00 00 00 07 +T 00 2A 12 00 00 FD 8D 00 74 01 2A FE E4 3B FF 8C +R 00 00 00 07 02 03 00 4E +T 00 38 01 90 00 02 EE F0 A3 EF F0 A3 E9 F0 8A 82 +R 00 00 00 07 00 04 00 05 +T 00 46 8B 83 8C F0 12 00 00 FA F6 18 8E 82 8F 83 +R 00 00 00 07 02 07 00 4E +T 00 54 89 F0 12 00 00 FE F6 8D 81 90 00 00 E0 FA +R 00 00 00 07 02 05 00 4E 00 0C 00 05 +T 00 62 A3 E0 FD 8A 82 8D 83 +R 00 00 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 22 +R 00 00 00 07 +T 00 6A +R 00 00 00 07 +T 00 6A C0 F0 C0 83 C0 82 90 00 05 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 78 A3 F0 D0 E0 A3 F0 90 00 05 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 86 A3 E0 FC 74 01 2A F5 00 00 E4 3B F5 00 01 +R 00 00 00 07 29 09 00 01 29 0E 00 01 +T 00 92 8C 00 02 A8 81 86 05 8A 82 8B 83 8C F0 ED +R 00 00 00 07 29 03 00 01 +T 00 9F 12 00 00 74 01 25 00 00 FA E4 35 00 01 FB +R 00 00 00 07 02 03 00 1F 29 08 00 01 29 0D 00 01 +T 00 AB AC 00 02 90 00 05 EA F0 A3 EB F0 A3 EC F0 +R 00 00 00 07 29 03 00 01 00 06 00 05 +T 00 B8 AD 81 ED 24 FF F8 86 05 85 00 00 82 85 +R 00 00 00 07 29 0B 00 01 +T 00 C4 00 01 83 85 00 02 F0 ED 12 00 00 8A 82 8B +R 00 00 00 07 29 02 00 01 29 06 00 01 02 0B 00 1F +T 00 D0 83 8C F0 E5 81 12 00 00 90 00 00 +R 00 00 00 07 02 08 00 1F +T 00 DB +R 00 00 00 07 +T 00 DB 22 +R 00 00 00 07 diff --git a/device/lib/large/_spx.asm b/device/lib/large/_spx.asm new file mode 100644 index 00000000..128e4c56 --- /dev/null +++ b/device/lib/large/_spx.asm @@ -0,0 +1,48 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:32 2000 + +;-------------------------------------------------------- + .module _spx +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _spx +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +G$spx$0$0==. +_spx: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + .area CSEG (CODE) diff --git a/device/lib/large/_spx.cdb b/device/lib/large/_spx.cdb new file mode 100644 index 00000000..dbd29c49 --- /dev/null +++ b/device/lib/large/_spx.cdb @@ -0,0 +1,2 @@ +M:_spx +S:G$spx$0$0({1}SC:U),E,0,0 diff --git a/device/lib/large/_spx.rel b/device/lib/large/_spx.rel new file mode 100644 index 00000000..8ed7637a --- /dev/null +++ b/device/lib/large/_spx.rel @@ -0,0 +1,17 @@ +XH +H 8 areas 2 global symbols +M _spx +A _CODE size 0 flags 0 +A DSEG size 1 flags 0 +S G$spx$0$0 Def0000 +S _spx Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 0 flags 20 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 diff --git a/device/lib/large/_startup.asm b/device/lib/large/_startup.asm new file mode 100644 index 00000000..1f7ac1c4 --- /dev/null +++ b/device/lib/large/_startup.asm @@ -0,0 +1,65 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _startup +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __sdcc_external_startup +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_sdcc_external_startup$0$0 ==. +; _startup.c 30 +; ----------------------------------------- +; function _sdcc_external_startup +; ----------------------------------------- +__sdcc_external_startup: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _startup.c 32 + mov dpl,#0x00 +00101$: + C$_startup.c$33$1$1 ==. + XG$_sdcc_external_startup$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_startup.cdb b/device/lib/large/_startup.cdb new file mode 100644 index 00000000..60863d5f --- /dev/null +++ b/device/lib/large/_startup.cdb @@ -0,0 +1,2 @@ +M:_startup +F:G$_sdcc_external_startup$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/large/_startup.rel b/device/lib/large/_startup.rel new file mode 100644 index 00000000..09a36715 --- /dev/null +++ b/device/lib/large/_startup.rel @@ -0,0 +1,26 @@ +;!FILE _startup.asm +XH +H 8 areas 6 global symbols +M _startup +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 4 flags 20 +S A$_startup$60 Def0000 +S A$_startup$64 Def0003 +S __sdcc_external_startup Def0000 +S XG$_sdcc_external_startup$0$0 Def0003 +S G$_sdcc_external_startup$0$0 Def0000 +S C$_startup.c$33$1$1 Def0003 +T 00 00 +R 00 00 00 07 +T 00 00 75 82 00 +R 00 00 00 07 +T 00 03 +R 00 00 00 07 +T 00 03 22 +R 00 00 00 07 diff --git a/device/lib/large/_strcat.asm b/device/lib/large/_strcat.asm new file mode 100644 index 00000000..764852aa --- /dev/null +++ b/device/lib/large/_strcat.asm @@ -0,0 +1,162 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:40 2000 + +;-------------------------------------------------------- + .module _strcat +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcat_PARM_2 + .globl _strcat +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strcat_sloc0_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strcat_PARM_2: + .ds 0x0003 +_strcat_dst_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcat$0$0 ==. +; _strcat.c 26 +; ----------------------------------------- +; function strcat +; ----------------------------------------- +_strcat: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcat.c 38 + push b + push dph + push dpl + mov dptr,#_strcat_dst_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strcat.c 31 + mov dptr,#_strcat_dst_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +; _strcat.c 33 +00101$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00111$ +00113$: +; _strcat.c 34 + inc r2 + cjne r2,#0x00,00114$ + inc r3 +00114$: +; _strcat.c 36 +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00111$: + mov dptr,#_strcat_PARM_2 + movx a,@dptr + mov _strcat_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strcat_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strcat_sloc0_1_0 + 2),a +00104$: + mov ar0,r2 + mov ar1,r3 + mov ar5,r4 + inc r2 + cjne r2,#0x00,00115$ + inc r3 +00115$: + mov dpl,_strcat_sloc0_1_0 + mov dph,(_strcat_sloc0_1_0 + 1) + mov b,(_strcat_sloc0_1_0 + 2) + inc _strcat_sloc0_1_0 + clr a + cjne a,_strcat_sloc0_1_0,00116$ + inc (_strcat_sloc0_1_0 + 1) +00116$: + lcall __gptrget +; Peephole 190 removed redundant mov +; Peephole 191 removed redundant mov + mov r6,a + mov dpl,r0 + mov dph,r1 + mov b,r5 + lcall __gptrput +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00117$: +; _strcat.c 38 + mov dptr,#_strcat_dst_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00107$: + C$_strcat.c$40$1$1 ==. + XG$strcat$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strcat.cdb b/device/lib/large/_strcat.cdb new file mode 100644 index 00000000..50dd1670 --- /dev/null +++ b/device/lib/large/_strcat.cdb @@ -0,0 +1,2 @@ +M:_strcat +F:G$strcat$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strcat.rel b/device/lib/large/_strcat.rel new file mode 100644 index 00000000..af4fc7b9 --- /dev/null +++ b/device/lib/large/_strcat.rel @@ -0,0 +1,156 @@ +;!FILE _strcat.asm +XH +H 8 areas 50 global symbols +M _strcat +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 3 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 6 flags 40 +S _strcat_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 7D flags 20 +S A$_strcat$70 Def0006 +S A$_strcat$80 Def0014 +S A$_strcat$71 Def0009 +S A$_strcat$81 Def0017 +S A$_strcat$72 Def000B +S A$_strcat$91 Def001F +S A$_strcat$82 Def0018 +S A$_strcat$73 Def000C +S A$_strcat$92 Def0021 +S A$_strcat$83 Def0019 +S A$_strcat$74 Def000E +S G$strcat$0$0 Def0000 +S A$_strcat$93 Def0023 +S A$_strcat$84 Def001A +S A$_strcat$75 Def000F +S A$_strcat$94 Def0025 +S A$_strcat$85 Def001B +S A$_strcat$76 Def0010 +S A$_strcat$67 Def0000 +S A$_strcat$86 Def001C +S A$_strcat$77 Def0012 +S A$_strcat$68 Def0002 +S A$_strcat$96 Def0028 +S A$_strcat$87 Def001D +S A$_strcat$78 Def0013 +S A$_strcat$69 Def0004 +S A$_strcat$88 Def001E +S A$_strcat$98 Def0029 +S A$_strcat$110 Def0035 +S A$_strcat$101 Def002B +S A$_strcat$120 Def0042 +S A$_strcat$111 Def0036 +S A$_strcat$102 Def002C +S A$_strcat$130 Def0056 +S A$_strcat$121 Def0044 +S A$_strcat$112 Def0038 +S A$_strcat$103 Def002F +S A$_strcat$140 Def0064 +S A$_strcat$131 Def0057 +S A$_strcat$122 Def0046 +S A$_strcat$113 Def0039 +S A$_strcat$150 Def0071 +S A$_strcat$141 Def0066 +S A$_strcat$132 Def005A +S A$_strcat$123 Def0047 +S A$_strcat$114 Def003A +S A$_strcat$151 Def0072 +S A$_strcat$124 Def004A +S A$_strcat$115 Def003C +S _strcat Def0000 +S A$_strcat$161 Def007C +S A$_strcat$152 Def0073 +S A$_strcat$143 Def0069 +S A$_strcat$134 Def005C +S A$_strcat$116 Def003D +S A$_strcat$107 Def0030 +S A$_strcat$153 Def0074 +S A$_strcat$126 Def004B +S A$_strcat$117 Def003E +S A$_strcat$154 Def0075 +S A$_strcat$127 Def004E +S A$_strcat$109 Def0032 +S A$_strcat$155 Def0076 +S A$_strcat$146 Def006B +S A$_strcat$137 Def005F +S A$_strcat$128 Def0051 +S A$_strcat$119 Def0040 +S A$_strcat$156 Def0078 +S A$_strcat$147 Def006E +S A$_strcat$138 Def0060 +S A$_strcat$129 Def0054 +S A$_strcat$157 Def007A +S A$_strcat$148 Def006F +S A$_strcat$139 Def0062 +S A$_strcat$149 Def0070 +S C$_strcat.c$40$1$1 Def007C +S XG$strcat$0$0 Def007C +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC +R 00 00 00 07 +T 00 1F +R 00 00 00 07 +T 00 1F 8A 82 8B 83 8C F0 12 00 00 FD 60 07 +R 00 00 00 07 02 09 00 01 +T 00 2B +R 00 00 00 07 +T 00 2B 0A BA 00 01 0B +R 00 00 00 07 +T 00 30 +R 00 00 00 07 +T 00 30 80 ED +R 00 00 00 07 +T 00 32 +R 00 00 00 07 +T 00 32 90 00 00 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 3E F5 00 02 +R 00 00 00 07 29 03 00 01 +T 00 40 +R 00 00 00 07 +T 00 40 8A 00 8B 01 8C 05 0A BA 00 01 0B +R 00 00 00 07 +T 00 4B +R 00 00 00 07 +T 00 4B 85 00 00 82 85 00 01 83 85 00 02 F0 05 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 55 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 5C +R 00 00 00 07 +T 00 5C 12 00 00 FE 88 82 89 83 8D F0 12 00 00 70 +R 00 00 00 07 02 03 00 01 02 0D 00 00 +T 00 6A D5 +R 00 00 00 07 +T 00 6B +R 00 00 00 07 +T 00 6B 90 00 03 E0 FA A3 E0 FB A3 E0 FC 8A 82 8B +R 00 00 00 07 00 03 00 05 +T 00 79 83 8C F0 +R 00 00 00 07 +T 00 7C +R 00 00 00 07 +T 00 7C 22 +R 00 00 00 07 diff --git a/device/lib/large/_strchr.asm b/device/lib/large/_strchr.asm new file mode 100644 index 00000000..11829cc8 --- /dev/null +++ b/device/lib/large/_strchr.asm @@ -0,0 +1,159 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _strchr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strchr_PARM_2 + .globl _strchr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strchr_PARM_2: + .ds 0x0001 +_strchr_string_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strchr$0$0 ==. +; _strchr.c 27 +; ----------------------------------------- +; function strchr +; ----------------------------------------- +_strchr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strchr.c 0 + push b + push dph + push dpl + mov dptr,#_strchr_string_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strchr.c 32 + mov dptr,#_strchr_PARM_2 + movx a,@dptr + mov r2,a + mov dptr,#_strchr_string_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a +00102$: + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00113$: + mov a,r6 + cjne a,ar2,00114$ +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00114$: +; _strchr.c 33 + inc r3 + cjne r3,#0x00,00115$ + inc r4 +00115$: + mov dptr,#_strchr_string_1_1 + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00104$: +; _strchr.c 35 + mov dptr,#_strchr_string_1_1 + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar2,00106$ +; Peephole 201 removed redundant sjmp +00116$: +00117$: +; _strchr.c 36 + mov dpl,r3 + mov dph,r4 + mov b,r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _strchr.c 37 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00107$: + C$_strchr.c$38$1$1 ==. + XG$strchr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strchr.cdb b/device/lib/large/_strchr.cdb new file mode 100644 index 00000000..f295b35d --- /dev/null +++ b/device/lib/large/_strchr.cdb @@ -0,0 +1,2 @@ +M:_strchr +F:G$strchr$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strchr.rel b/device/lib/large/_strchr.rel new file mode 100644 index 00000000..514b7748 --- /dev/null +++ b/device/lib/large/_strchr.rel @@ -0,0 +1,138 @@ +;!FILE _strchr.asm +XH +H 8 areas 4A global symbols +M _strchr +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 4 flags 40 +S _strchr_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 6F flags 20 +S XG$strchr$0$0 Def006E +S A$_strchr$70 Def000B +S A$_strchr$80 Def0018 +S A$_strchr$71 Def000C +S C$_strchr.c$38$1$1 Def006E +S A$_strchr$81 Def0019 +S A$_strchr$72 Def000E +S A$_strchr$91 Def0024 +S A$_strchr$82 Def001C +S A$_strchr$73 Def000F +S A$_strchr$92 Def0026 +S A$_strchr$83 Def001D +S A$_strchr$74 Def0010 +S A$_strchr$65 Def0000 +S G$strchr$0$0 Def0000 +S A$_strchr$93 Def0028 +S A$_strchr$84 Def001E +S A$_strchr$75 Def0012 +S A$_strchr$66 Def0002 +S A$_strchr$94 Def002A +S A$_strchr$85 Def001F +S A$_strchr$76 Def0013 +S A$_strchr$67 Def0004 +S A$_strchr$86 Def0020 +S A$_strchr$68 Def0006 +S A$_strchr$96 Def002D +S A$_strchr$87 Def0021 +S A$_strchr$78 Def0014 +S A$_strchr$69 Def0009 +S A$_strchr$88 Def0022 +S A$_strchr$79 Def0017 +S A$_strchr$98 Def002E +S A$_strchr$89 Def0023 +S A$_strchr$100 Def0030 +S A$_strchr$110 Def003B +S A$_strchr$101 Def0031 +S A$_strchr$120 Def0046 +S A$_strchr$111 Def003E +S A$_strchr$130 Def0051 +S A$_strchr$112 Def003F +S A$_strchr$103 Def0034 +S A$_strchr$140 Def005D +S A$_strchr$131 Def0052 +S A$_strchr$113 Def0040 +S A$_strchr$132 Def0053 +S A$_strchr$123 Def0048 +S A$_strchr$114 Def0041 +S A$_strchr$133 Def0055 +S A$_strchr$124 Def004B +S A$_strchr$115 Def0042 +S A$_strchr$106 Def0036 +S _strchr Def0000 +S A$_strchr$134 Def0057 +S A$_strchr$125 Def004C +S A$_strchr$116 Def0043 +S A$_strchr$107 Def0037 +S A$_strchr$153 Def0068 +S A$_strchr$135 Def0059 +S A$_strchr$126 Def004D +S A$_strchr$117 Def0044 +S A$_strchr$108 Def003A +S A$_strchr$154 Def006B +S A$_strchr$145 Def0060 +S A$_strchr$127 Def004E +S A$_strchr$118 Def0045 +S A$_strchr$146 Def0062 +S A$_strchr$137 Def005C +S A$_strchr$128 Def004F +S A$_strchr$147 Def0064 +S A$_strchr$129 Def0050 +S A$_strchr$158 Def006E +S A$_strchr$149 Def0066 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 01 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 00 E0 FA 90 00 01 +R 00 00 00 07 00 09 00 05 00 0E 00 05 +T 00 1C E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 +T 00 24 +R 00 00 00 07 +T 00 24 8B 82 8C 83 8D F0 12 00 00 FE 60 18 +R 00 00 00 07 02 09 00 00 +T 00 30 +R 00 00 00 07 +T 00 30 EE B5 02 02 80 12 +R 00 00 00 07 +T 00 36 +R 00 00 00 07 +T 00 36 0B BB 00 01 0C +R 00 00 00 07 +T 00 3B +R 00 00 00 07 +T 00 3B 90 00 01 EB F0 A3 EC F0 A3 ED F0 80 DC +R 00 00 00 07 00 03 00 05 +T 00 48 +R 00 00 00 07 +T 00 48 90 00 01 EB F0 A3 EC F0 A3 ED F0 8B 82 8C +R 00 00 00 07 00 03 00 05 +T 00 56 83 8D F0 12 00 00 FE B5 02 08 +R 00 00 00 07 02 06 00 00 +T 00 60 +R 00 00 00 07 +T 00 60 +R 00 00 00 07 +T 00 60 8B 82 8C 83 8D F0 80 06 +R 00 00 00 07 +T 00 68 +R 00 00 00 07 +T 00 68 90 00 00 75 F0 00 +R 00 00 00 07 +T 00 6E +R 00 00 00 07 +T 00 6E 22 +R 00 00 00 07 diff --git a/device/lib/large/_strcmp.asm b/device/lib/large/_strcmp.asm new file mode 100644 index 00000000..4c6dfdf7 --- /dev/null +++ b/device/lib/large/_strcmp.asm @@ -0,0 +1,217 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _strcmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcmp_PARM_2 + .globl _strcmp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strcmp_sloc0_1_0: + .ds 0x0001 +_strcmp_sloc1_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strcmp_PARM_2: + .ds 0x0003 +_strcmp_src_1_1: + .ds 0x0003 +_strcmp_ret_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcmp$0$0 ==. +; _strcmp.c 27 +; ----------------------------------------- +; function strcmp +; ----------------------------------------- +_strcmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcmp.c 42 + push b + push dph + push dpl + mov dptr,#_strcmp_src_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strcmp.c 34 + mov dptr,#_strcmp_src_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#_strcmp_PARM_2 + movx a,@dptr + mov _strcmp_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (_strcmp_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strcmp_sloc1_1_0 + 2),a +00102$: + mov dpl,_strcmp_sloc1_1_0 + mov dph,(_strcmp_sloc1_1_0 + 1) + mov b,(_strcmp_sloc1_1_0 + 2) + lcall __gptrget + mov _strcmp_sloc0_1_0,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 106 removed redundant mov + mov r1,a + clr c + subb a,_strcmp_sloc0_1_0 +; Peephole 166 removed redundant mov + mov r1,a + mov ar0,r1 + rlc a + subb a,acc + mov r5,a + mov dptr,#_strcmp_ret_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + mov a,r1 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00117$: + mov a,_strcmp_sloc0_1_0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00118$: +; _strcmp.c 35 + inc r2 + cjne r2,#0x00,00119$ + inc r3 +00119$: + mov dptr,#_strcmp_src_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc _strcmp_sloc1_1_0 + clr a + cjne a,_strcmp_sloc1_1_0,00120$ + inc (_strcmp_sloc1_1_0 + 1) +00120$: +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00104$: +; _strcmp.c 37 + mov dptr,#_strcmp_src_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00108$ +00121$: +; _strcmp.c 38 + mov dptr,#_strcmp_ret_1_1 +; Peephole 101 removed redundant mov + mov a,#0xff + movx @dptr,a + inc dptr + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: +; _strcmp.c 39 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,r0 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,r5 + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00109$ +00122$: +; _strcmp.c 40 + mov dptr,#_strcmp_ret_1_1 + clr a + inc dptr + movx @dptr,a + lcall __decdptr + mov a,#0x01 + movx @dptr,a +00109$: +; _strcmp.c 42 + mov dptr,#_strcmp_ret_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov dpl,r2 + mov dph,r3 +00110$: + C$_strcmp.c$43$1$1 ==. + XG$strcmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strcmp.cdb b/device/lib/large/_strcmp.cdb new file mode 100644 index 00000000..7a674a90 --- /dev/null +++ b/device/lib/large/_strcmp.cdb @@ -0,0 +1,2 @@ +M:_strcmp +F:G$strcmp$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strcmp.rel b/device/lib/large/_strcmp.rel new file mode 100644 index 00000000..44aa0c25 --- /dev/null +++ b/device/lib/large/_strcmp.rel @@ -0,0 +1,218 @@ +;!FILE _strcmp.asm +XH +H 8 areas 7A global symbols +M _strcmp +S __decdptr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 4 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S _strcmp_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size B8 flags 20 +S A$_strcmp$186 Def0093 +S A$_strcmp$177 Def008D +S A$_strcmp$168 Def0083 +S A$_strcmp$159 Def0078 +S A$_strcmp$196 Def009F +S A$_strcmp$178 Def008E +S A$_strcmp$197 Def00A2 +S A$_strcmp$188 Def0094 +S A$_strcmp$198 Def00A3 +S A$_strcmp$189 Def0096 +S A$_strcmp$199 Def00A4 +S XG$strcmp$0$0 Def00B7 +S C$_strcmp.c$43$1$1 Def00B7 +S A$_strcmp$80 Def0010 +S A$_strcmp$71 Def0000 +S A$_strcmp$90 Def001C +S A$_strcmp$81 Def0012 +S A$_strcmp$72 Def0002 +S A$_strcmp$91 Def001D +S A$_strcmp$82 Def0013 +S A$_strcmp$73 Def0004 +S A$_strcmp$92 Def001E +S A$_strcmp$74 Def0006 +S G$strcmp$0$0 Def0000 +S A$_strcmp$93 Def001F +S A$_strcmp$84 Def0014 +S A$_strcmp$75 Def0009 +S A$_strcmp$94 Def0022 +S A$_strcmp$85 Def0017 +S A$_strcmp$76 Def000B +S A$_strcmp$95 Def0023 +S A$_strcmp$86 Def0018 +S A$_strcmp$77 Def000C +S A$_strcmp$96 Def0025 +S A$_strcmp$87 Def0019 +S A$_strcmp$78 Def000E +S A$_strcmp$97 Def0026 +S A$_strcmp$88 Def001A +S A$_strcmp$79 Def000F +S A$_strcmp$98 Def0027 +S A$_strcmp$89 Def001B +S A$_strcmp$99 Def0029 +S A$_strcmp$100 Def002A +S A$_strcmp$200 Def00A5 +S A$_strcmp$110 Def003F +S A$_strcmp$101 Def002B +S A$_strcmp$210 Def00B2 +S A$_strcmp$201 Def00A8 +S A$_strcmp$120 Def004C +S A$_strcmp$111 Def0041 +S A$_strcmp$211 Def00B3 +S A$_strcmp$202 Def00AA +S A$_strcmp$130 Def0058 +S A$_strcmp$121 Def004E +S A$_strcmp$103 Def002D +S A$_strcmp$212 Def00B5 +S A$_strcmp$122 Def004F +S A$_strcmp$113 Def0044 +S A$_strcmp$104 Def0030 +S A$_strcmp$150 Def006E +S A$_strcmp$141 Def0063 +S A$_strcmp$132 Def005A +S A$_strcmp$123 Def0052 +S A$_strcmp$114 Def0045 +S A$_strcmp$105 Def0033 +S A$_strcmp$205 Def00AB +S A$_strcmp$160 Def007B +S A$_strcmp$151 Def0070 +S A$_strcmp$142 Def0066 +S A$_strcmp$124 Def0053 +S A$_strcmp$115 Def0046 +S A$_strcmp$106 Def0036 +S _strcmp Def0000 +S A$_strcmp$206 Def00AE +S A$_strcmp$170 Def0084 +S A$_strcmp$161 Def007C +S A$_strcmp$152 Def0071 +S A$_strcmp$143 Def0067 +S A$_strcmp$134 Def005C +S A$_strcmp$125 Def0054 +S A$_strcmp$107 Def0039 +S A$_strcmp$216 Def00B7 +S A$_strcmp$207 Def00AF +S A$_strcmp$180 Def008F +S A$_strcmp$162 Def007D +S A$_strcmp$153 Def0074 +S A$_strcmp$144 Def0068 +S A$_strcmp$126 Def0055 +S A$_strcmp$117 Def0048 +S A$_strcmp$108 Def003B +S A$_strcmp$208 Def00B0 +S A$_strcmp$190 Def0098 +S A$_strcmp$163 Def007E +S A$_strcmp$145 Def0069 +S A$_strcmp$127 Def0056 +S A$_strcmp$118 Def0049 +S A$_strcmp$109 Def003D +S A$_strcmp$209 Def00B1 +S A$_strcmp$191 Def009B +S A$_strcmp$173 Def0087 +S A$_strcmp$164 Def007F +S A$_strcmp$146 Def006A +S A$_strcmp$137 Def005E +S A$_strcmp$128 Def0057 +S A$_strcmp$119 Def004B +S A$_strcmp$183 Def0091 +S A$_strcmp$165 Def0080 +S A$_strcmp$156 Def0076 +S A$_strcmp$147 Def006B +S A$_strcmp$138 Def005F +S A$_strcmp$193 Def009D +S A$_strcmp$175 Def008A +S A$_strcmp$166 Def0081 +S A$_strcmp$148 Def006C +S A$_strcmp$139 Def0062 +S A$_strcmp$185 Def0092 +S A$_strcmp$176 Def008C +S A$_strcmp$167 Def0082 +S A$_strcmp$149 Def006D +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 90 00 00 E0 F5 00 01 A3 E0 F5 +R 00 00 00 07 00 06 00 05 29 0A 00 01 +T 00 28 00 02 A3 E0 F5 00 03 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 2D +R 00 00 00 07 +T 00 2D 85 00 01 82 85 00 02 83 85 00 03 F0 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 37 00 00 F5 00 00 8A 82 8B 83 8C F0 12 00 00 +R 00 00 00 07 02 02 00 01 29 05 00 01 02 0E 00 01 +T 00 44 F9 C3 95 00 00 F9 89 00 33 95 E0 FD 90 +R 00 00 00 07 29 05 00 01 +T 00 50 00 06 E8 F0 A3 ED F0 E9 70 1E +R 00 00 00 07 00 02 00 05 +T 00 5A +R 00 00 00 07 +T 00 5A E5 00 00 60 1A +R 00 00 00 07 29 03 00 01 +T 00 5E +R 00 00 00 07 +T 00 5E 0A BA 00 01 0B +R 00 00 00 07 +T 00 63 +R 00 00 00 07 +T 00 63 90 00 03 EA F0 A3 EB F0 A3 EC F0 05 00 01 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 00 70 E4 B5 00 01 02 05 00 02 +R 00 00 00 07 29 04 00 01 29 08 00 01 +T 00 76 +R 00 00 00 07 +T 00 76 80 B5 +R 00 00 00 07 +T 00 78 +R 00 00 00 07 +T 00 78 90 00 03 EA F0 A3 EB F0 A3 EC F0 ED 30 E7 +R 00 00 00 07 00 03 00 05 +T 00 86 0A +R 00 00 00 07 +T 00 87 +R 00 00 00 07 +T 00 87 90 00 06 74 FF F0 A3 F0 80 1A +R 00 00 00 07 00 03 00 05 +T 00 91 +R 00 00 00 07 +T 00 91 C3 E4 98 74 80 8D F0 63 F0 80 95 F0 50 0C +R 00 00 00 07 +T 00 9F +R 00 00 00 07 +T 00 9F 90 00 06 E4 A3 F0 12 00 00 74 01 F0 +R 00 00 00 07 00 03 00 05 02 09 00 00 +T 00 AB +R 00 00 00 07 +T 00 AB 90 00 06 E0 FA A3 E0 FB 8A 82 8B 83 +R 00 00 00 07 00 03 00 05 +T 00 B7 +R 00 00 00 07 +T 00 B7 22 +R 00 00 00 07 diff --git a/device/lib/large/_strcpy.asm b/device/lib/large/_strcpy.asm new file mode 100644 index 00000000..2aa8f13d --- /dev/null +++ b/device/lib/large/_strcpy.asm @@ -0,0 +1,143 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _strcpy +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcpy_PARM_2 + .globl _strcpy +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strcpy_sloc0_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strcpy_PARM_2: + .ds 0x0003 +_strcpy_d_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcpy$0$0 ==. +; _strcpy.c 27 +; ----------------------------------------- +; function strcpy +; ----------------------------------------- +_strcpy: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcpy.c 35 + push b + push dph + push dpl + mov dptr,#_strcpy_d_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strcpy.c 31 + mov dptr,#_strcpy_d_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +; _strcpy.c 33 + mov dptr,#_strcpy_PARM_2 + movx a,@dptr + mov _strcpy_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strcpy_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strcpy_sloc0_1_0 + 2),a +00101$: + mov ar0,r2 + mov ar1,r3 + mov ar5,r4 + inc r2 + cjne r2,#0x00,00108$ + inc r3 +00108$: + mov dpl,_strcpy_sloc0_1_0 + mov dph,(_strcpy_sloc0_1_0 + 1) + mov b,(_strcpy_sloc0_1_0 + 2) + inc _strcpy_sloc0_1_0 + clr a + cjne a,_strcpy_sloc0_1_0,00109$ + inc (_strcpy_sloc0_1_0 + 1) +00109$: + lcall __gptrget +; Peephole 190 removed redundant mov +; Peephole 191 removed redundant mov + mov r6,a + mov dpl,r0 + mov dph,r1 + mov b,r5 + lcall __gptrput +; Peephole 109 removed ljmp by inverse jump logic + jnz 00101$ +00110$: +; _strcpy.c 35 + mov dptr,#_strcpy_d_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00104$: + C$_strcpy.c$36$1$1 ==. + XG$strcpy$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strcpy.cdb b/device/lib/large/_strcpy.cdb new file mode 100644 index 00000000..42708a46 --- /dev/null +++ b/device/lib/large/_strcpy.cdb @@ -0,0 +1,2 @@ +M:_strcpy +F:G$strcpy$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strcpy.rel b/device/lib/large/_strcpy.rel new file mode 100644 index 00000000..5f560a57 --- /dev/null +++ b/device/lib/large/_strcpy.rel @@ -0,0 +1,130 @@ +;!FILE _strcpy.asm +XH +H 8 areas 46 global symbols +M _strcpy +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 3 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 6 flags 40 +S _strcpy_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 6A flags 20 +S A$_strcpy$120 Def004F +S A$_strcpy$111 Def0043 +S A$_strcpy$102 Def0031 +S A$_strcpy$130 Def005D +S A$_strcpy$121 Def0051 +S A$_strcpy$112 Def0044 +S A$_strcpy$103 Def0033 +S A$_strcpy$131 Def005E +S A$_strcpy$122 Def0053 +S A$_strcpy$113 Def0047 +S A$_strcpy$104 Def0034 +S A$_strcpy$132 Def005F +S A$_strcpy$105 Def0037 +S A$_strcpy$142 Def0069 +S A$_strcpy$133 Def0060 +S A$_strcpy$124 Def0056 +S A$_strcpy$115 Def0049 +S _strcpy Def0000 +S A$_strcpy$134 Def0061 +S A$_strcpy$107 Def0038 +S A$_strcpy$135 Def0062 +S A$_strcpy$108 Def003B +S A$_strcpy$136 Def0063 +S A$_strcpy$127 Def0058 +S A$_strcpy$118 Def004C +S A$_strcpy$109 Def003E +S A$_strcpy$137 Def0065 +S A$_strcpy$128 Def005B +S A$_strcpy$119 Def004D +S A$_strcpy$138 Def0067 +S A$_strcpy$129 Def005C +S XG$strcpy$0$0 Def0069 +S C$_strcpy.c$36$1$1 Def0069 +S A$_strcpy$70 Def0006 +S A$_strcpy$80 Def0014 +S A$_strcpy$71 Def0009 +S A$_strcpy$90 Def001F +S A$_strcpy$81 Def0017 +S A$_strcpy$72 Def000B +S A$_strcpy$91 Def0022 +S A$_strcpy$82 Def0018 +S A$_strcpy$73 Def000C +S A$_strcpy$92 Def0023 +S A$_strcpy$83 Def0019 +S A$_strcpy$74 Def000E +S G$strcpy$0$0 Def0000 +S A$_strcpy$93 Def0025 +S A$_strcpy$84 Def001A +S A$_strcpy$75 Def000F +S A$_strcpy$94 Def0026 +S A$_strcpy$85 Def001B +S A$_strcpy$76 Def0010 +S A$_strcpy$67 Def0000 +S A$_strcpy$95 Def0027 +S A$_strcpy$86 Def001C +S A$_strcpy$77 Def0012 +S A$_strcpy$68 Def0002 +S A$_strcpy$96 Def0029 +S A$_strcpy$87 Def001D +S A$_strcpy$78 Def0013 +S A$_strcpy$69 Def0004 +S A$_strcpy$97 Def002A +S A$_strcpy$88 Def001E +S A$_strcpy$98 Def002B +S A$_strcpy$100 Def002D +S A$_strcpy$110 Def0041 +S A$_strcpy$101 Def002F +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 90 00 00 E0 F5 00 00 A3 E0 F5 +R 00 00 00 07 00 06 00 05 29 0A 00 01 +T 00 28 00 01 A3 E0 F5 00 02 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 2D +R 00 00 00 07 +T 00 2D 8A 00 8B 01 8C 05 0A BA 00 01 0B +R 00 00 00 07 +T 00 38 +R 00 00 00 07 +T 00 38 85 00 00 82 85 00 01 83 85 00 02 F0 05 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 42 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 49 +R 00 00 00 07 +T 00 49 12 00 00 FE 88 82 89 83 8D F0 12 00 00 70 +R 00 00 00 07 02 03 00 01 02 0D 00 00 +T 00 57 D5 +R 00 00 00 07 +T 00 58 +R 00 00 00 07 +T 00 58 90 00 03 E0 FA A3 E0 FB A3 E0 FC 8A 82 8B +R 00 00 00 07 00 03 00 05 +T 00 66 83 8C F0 +R 00 00 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 22 +R 00 00 00 07 diff --git a/device/lib/large/_strcspn.asm b/device/lib/large/_strcspn.asm new file mode 100644 index 00000000..a05e2d70 --- /dev/null +++ b/device/lib/large/_strcspn.asm @@ -0,0 +1,152 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _strcspn +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcspn_PARM_2 + .globl _strcspn +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strcspn_sloc0_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strcspn_PARM_2: + .ds 0x0003 +_strcspn_string_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcspn$0$0 ==. +; _strcspn.c 27 +; ----------------------------------------- +; function strcspn +; ----------------------------------------- +_strcspn: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcspn.c 42 + push b + push dph + push dpl + mov dptr,#_strcspn_string_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strcspn.c 35 + mov dptr,#_strcspn_PARM_2 + movx a,@dptr + mov _strcspn_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strcspn_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strcspn_sloc0_1_0 + 2),a + mov dptr,#_strcspn_string_1_1 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + mov r0,#0x00 + mov r1,#0x00 +00104$: + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00112$: +; _strcspn.c 36 + mov dptr,#_strchr_PARM_2 + mov a,r2 + movx @dptr,a + push ar5 + push ar6 + push ar7 + push ar0 + push ar1 + mov dpl,_strcspn_sloc0_1_0 + mov dph,(_strcspn_sloc0_1_0 + 1) + mov b,(_strcspn_sloc0_1_0 + 2) + lcall _strchr + mov r2,dpl + mov r3,dph + mov r4,b + pop ar1 + pop ar0 + pop ar7 + pop ar6 + pop ar5 + mov a,r2 + orl a,r3 + orl a,r4 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00106$ +00113$: +; _strcspn.c 39 + inc r0 + cjne r0,#0x00,00114$ + inc r1 +00114$: +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00106$: +; _strcspn.c 42 + mov dpl,r0 + mov dph,r1 +00107$: + C$_strcspn.c$43$1$1 ==. + XG$strcspn$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strcspn.cdb b/device/lib/large/_strcspn.cdb new file mode 100644 index 00000000..8fa76335 --- /dev/null +++ b/device/lib/large/_strcspn.cdb @@ -0,0 +1,2 @@ +M:_strcspn +F:G$strcspn$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strcspn.rel b/device/lib/large/_strcspn.rel new file mode 100644 index 00000000..f0bd5cea --- /dev/null +++ b/device/lib/large/_strcspn.rel @@ -0,0 +1,141 @@ +;!FILE _strcspn.asm +XH +H 8 areas 4D global symbols +M _strcspn +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 3 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 6 flags 40 +S _strcspn_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 79 flags 20 +S A$_strcspn$92 Def0027 +S A$_strcspn$83 Def001A +S A$_strcspn$74 Def000E +S G$strcspn$0$0 Def0000 +S A$_strcspn$93 Def0028 +S A$_strcspn$84 Def001B +S A$_strcspn$75 Def000F +S A$_strcspn$94 Def0029 +S A$_strcspn$85 Def001C +S A$_strcspn$76 Def0010 +S A$_strcspn$67 Def0000 +S A$_strcspn$95 Def002A +S A$_strcspn$86 Def001E +S A$_strcspn$77 Def0012 +S A$_strcspn$68 Def0002 +S A$_strcspn$96 Def002B +S A$_strcspn$87 Def001F +S A$_strcspn$78 Def0013 +S A$_strcspn$69 Def0004 +S A$_strcspn$97 Def002C +S A$_strcspn$88 Def0020 +S A$_strcspn$98 Def002D +S A$_strcspn$89 Def0022 +S A$_strcspn$99 Def002F +S A$_strcspn$101 Def0031 +S A$_strcspn$120 Def004F +S A$_strcspn$111 Def003D +S A$_strcspn$102 Def0033 +S A$_strcspn$130 Def0066 +S A$_strcspn$121 Def0052 +S A$_strcspn$112 Def0040 +S A$_strcspn$103 Def0035 +S A$_strcspn$140 Def0071 +S A$_strcspn$131 Def0068 +S A$_strcspn$122 Def0055 +S A$_strcspn$113 Def0041 +S A$_strcspn$104 Def0037 +S A$_strcspn$132 Def0069 +S A$_strcspn$123 Def0058 +S A$_strcspn$114 Def0042 +S A$_strcspn$151 Def0078 +S A$_strcspn$133 Def006A +S A$_strcspn$124 Def005A +S A$_strcspn$115 Def0044 +S A$_strcspn$106 Def003A +S _strcspn Def0000 +S A$_strcspn$143 Def0072 +S A$_strcspn$125 Def005C +S A$_strcspn$116 Def0046 +S A$_strcspn$135 Def006B +S A$_strcspn$126 Def005E +S A$_strcspn$117 Def0048 +S A$_strcspn$108 Def003B +S A$_strcspn$127 Def0060 +S A$_strcspn$118 Def004A +S A$_strcspn$146 Def0074 +S A$_strcspn$128 Def0062 +S A$_strcspn$119 Def004C +S A$_strcspn$147 Def0076 +S A$_strcspn$138 Def006D +S A$_strcspn$129 Def0064 +S A$_strcspn$139 Def006E +S XG$strcspn$0$0 Def0078 +S C$_strcspn.c$43$1$1 Def0078 +S A$_strcspn$70 Def0006 +S A$_strcspn$80 Def0014 +S A$_strcspn$71 Def0009 +S A$_strcspn$90 Def0025 +S A$_strcspn$81 Def0017 +S A$_strcspn$72 Def000B +S A$_strcspn$91 Def0026 +S A$_strcspn$82 Def0018 +S A$_strcspn$73 Def000C +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 00 E0 F5 00 00 A3 +R 00 00 00 07 00 09 00 05 29 0D 00 01 +T 00 1B E0 F5 00 01 A3 E0 F5 00 02 90 00 03 E0 FD +R 00 00 00 07 29 04 00 01 29 09 00 01 00 0C 00 05 +T 00 27 A3 E0 FE A3 E0 FF 78 00 79 00 +R 00 00 00 07 +T 00 31 +R 00 00 00 07 +T 00 31 8D 82 8E 83 8F F0 12 00 00 FA 60 37 +R 00 00 00 07 02 09 00 02 +T 00 3D +R 00 00 00 07 +T 00 3D 90 00 00 EA F0 C0 05 C0 06 C0 07 C0 00 C0 +R 00 00 00 07 02 03 00 00 +T 00 4B 01 85 00 00 82 85 00 01 83 85 00 02 F0 12 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 00 56 00 00 AA 82 AB 83 AC F0 D0 01 D0 00 D0 07 +R 00 00 00 07 02 02 00 01 +T 00 64 D0 06 D0 05 EA 4B 4C 70 07 +R 00 00 00 07 +T 00 6D +R 00 00 00 07 +T 00 6D 08 B8 00 01 09 +R 00 00 00 07 +T 00 72 +R 00 00 00 07 +T 00 72 80 BD +R 00 00 00 07 +T 00 74 +R 00 00 00 07 +T 00 74 88 82 89 83 +R 00 00 00 07 +T 00 78 +R 00 00 00 07 +T 00 78 22 +R 00 00 00 07 diff --git a/device/lib/large/_strlen.asm b/device/lib/large/_strlen.asm new file mode 100644 index 00000000..dae06bce --- /dev/null +++ b/device/lib/large/_strlen.asm @@ -0,0 +1,127 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _strlen +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strlen +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strlen_str_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strlen$0$0 ==. +; _strlen.c 27 +; ----------------------------------------- +; function strlen +; ----------------------------------------- +_strlen: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strlen.c 34 + push b + push dph + push dpl + mov dptr,#_strlen_str_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strlen.c 31 + mov r2,#0x00 + mov r3,#0x00 + mov dptr,#_strlen_str_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a +00101$: + mov ar7,r4 + mov ar0,r5 + mov ar1,r6 + inc r4 + cjne r4,#0x00,00108$ + inc r5 +00108$: + mov dptr,#_strlen_str_1_1 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + mov dpl,r7 + mov dph,r0 + mov b,r1 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _strlen.c 32 + inc r2 + cjne r2,#0x00,00110$ + inc r3 +00110$: +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _strlen.c 34 + mov dpl,r2 + mov dph,r3 +00104$: + C$_strlen.c$35$1$1 ==. + XG$strlen$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strlen.cdb b/device/lib/large/_strlen.cdb new file mode 100644 index 00000000..a17ea6a4 --- /dev/null +++ b/device/lib/large/_strlen.cdb @@ -0,0 +1,2 @@ +M:_strlen +F:G$strlen$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strlen.rel b/device/lib/large/_strlen.rel new file mode 100644 index 00000000..f8399ac8 --- /dev/null +++ b/device/lib/large/_strlen.rel @@ -0,0 +1,106 @@ +;!FILE _strlen.asm +XH +H 8 areas 38 global symbols +M _strlen +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 3 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 51 flags 20 +S XG$strlen$0$0 Def0050 +S C$_strlen.c$35$1$1 Def0050 +S A$_strlen$70 Def000F +S A$_strlen$80 Def001D +S A$_strlen$71 Def0010 +S A$_strlen$62 Def0000 +S A$_strlen$90 Def0029 +S A$_strlen$81 Def001E +S A$_strlen$72 Def0012 +S A$_strlen$63 Def0002 +S A$_strlen$91 Def002A +S A$_strlen$82 Def001F +S A$_strlen$73 Def0013 +S A$_strlen$64 Def0004 +S A$_strlen$92 Def002D +S A$_strlen$83 Def0020 +S A$_strlen$65 Def0006 +S G$strlen$0$0 Def0000 +S A$_strlen$84 Def0021 +S A$_strlen$75 Def0014 +S A$_strlen$66 Def0009 +S A$_strlen$94 Def002E +S A$_strlen$85 Def0022 +S A$_strlen$76 Def0016 +S A$_strlen$67 Def000B +S A$_strlen$95 Def0031 +S A$_strlen$77 Def0018 +S A$_strlen$68 Def000C +S A$_strlen$96 Def0032 +S A$_strlen$87 Def0023 +S A$_strlen$78 Def001B +S A$_strlen$69 Def000E +S A$_strlen$97 Def0033 +S A$_strlen$88 Def0025 +S A$_strlen$79 Def001C +S A$_strlen$98 Def0034 +S A$_strlen$89 Def0027 +S A$_strlen$99 Def0035 +S A$_strlen$100 Def0036 +S A$_strlen$110 Def0043 +S A$_strlen$101 Def0037 +S A$_strlen$102 Def0038 +S A$_strlen$121 Def004C +S A$_strlen$103 Def0039 +S A$_strlen$122 Def004E +S A$_strlen$113 Def0045 +S A$_strlen$104 Def003B +S A$_strlen$114 Def0046 +S A$_strlen$105 Def003D +S A$_strlen$115 Def0049 +S A$_strlen$106 Def003F +S _strlen Def0000 +S A$_strlen$126 Def0050 +S A$_strlen$108 Def0042 +S A$_strlen$118 Def004A +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 7A 00 7B 00 90 00 00 E0 +R 00 00 00 07 00 0D 00 05 +T 00 1C FC A3 E0 FD A3 E0 FE +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 8C 07 8D 00 8E 01 0C BC 00 01 0D +R 00 00 00 07 +T 00 2E +R 00 00 00 07 +T 00 2E 90 00 00 EC F0 A3 ED F0 A3 EE F0 8F 82 88 +R 00 00 00 07 00 03 00 05 +T 00 3C 83 89 F0 12 00 00 FF 60 07 +R 00 00 00 07 02 06 00 00 +T 00 45 +R 00 00 00 07 +T 00 45 0A BA 00 01 0B +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A 80 D7 +R 00 00 00 07 +T 00 4C +R 00 00 00 07 +T 00 4C 8A 82 8B 83 +R 00 00 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 22 +R 00 00 00 07 diff --git a/device/lib/large/_strncat.asm b/device/lib/large/_strncat.asm new file mode 100644 index 00000000..f10810bf --- /dev/null +++ b/device/lib/large/_strncat.asm @@ -0,0 +1,248 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _strncat +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strncat_PARM_3 + .globl _strncat_PARM_2 + .globl _strncat +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strncat_sloc0_1_0: + .ds 0x0003 +_strncat_sloc1_1_0: + .ds 0x0003 +_strncat_sloc2_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strncat_PARM_2: + .ds 0x0003 +_strncat_PARM_3: + .ds 0x0002 +_strncat_front_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strncat$0$0 ==. +; _strncat.c 27 +; ----------------------------------------- +; function strncat +; ----------------------------------------- +_strncat: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strncat.c 44 + push b + push dph + push dpl + mov dptr,#_strncat_front_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strncat.c 33 + mov dptr,#_strncat_front_1_1 + movx a,@dptr + mov _strncat_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strncat_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strncat_sloc0_1_0 + 2),a +; _strncat.c 35 +00101$: + mov dptr,#_strncat_front_1_1 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + mov a,#0x01 + add a,r5 + mov r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r6 + mov r1,a + mov ar2,r7 + mov dptr,#_strncat_front_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00101$ +00116$: +; _strncat.c 37 + mov a,r0 + add a,#0xff + mov r4,a + mov a,r1 + addc a,#0xff + mov r3,a + mov dptr,#_strncat_front_1_1 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a +; _strncat.c 39 + mov _strncat_sloc2_1_0,r4 + mov (_strncat_sloc2_1_0 + 1),r3 + mov (_strncat_sloc2_1_0 + 2),r2 + mov dptr,#_strncat_PARM_2 + movx a,@dptr + mov _strncat_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (_strncat_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strncat_sloc1_1_0 + 2),a + mov dptr,#_strncat_PARM_3 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r0,a +00106$: + mov ar1,r5 + mov ar2,r0 + dec r5 + cjne r5,#0xff,00117$ + dec r0 +00117$: + mov a,r1 + orl a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00118$: +; _strncat.c 40 + mov r2,_strncat_sloc2_1_0 + mov r3,(_strncat_sloc2_1_0 + 1) + mov r4,(_strncat_sloc2_1_0 + 2) + inc _strncat_sloc2_1_0 + clr a + cjne a,_strncat_sloc2_1_0,00119$ + inc (_strncat_sloc2_1_0 + 1) +00119$: + mov dptr,#_strncat_front_1_1 + mov a,_strncat_sloc2_1_0 + movx @dptr,a + inc dptr + mov a,(_strncat_sloc2_1_0 + 1) + movx @dptr,a + inc dptr + mov a,(_strncat_sloc2_1_0 + 2) + movx @dptr,a + mov dpl,_strncat_sloc1_1_0 + mov dph,(_strncat_sloc1_1_0 + 1) + mov b,(_strncat_sloc1_1_0 + 2) + inc _strncat_sloc1_1_0 + clr a + cjne a,_strncat_sloc1_1_0,00120$ + inc (_strncat_sloc1_1_0 + 1) +00120$: + lcall __gptrget +; Peephole 190 removed redundant mov +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrput +; Peephole 109 removed ljmp by inverse jump logic + jnz 00106$ +00121$: +; _strncat.c 41 + mov dpl,_strncat_sloc0_1_0 + mov dph,(_strncat_sloc0_1_0 + 1) + mov b,(_strncat_sloc0_1_0 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: +; _strncat.c 43 + mov dptr,#_strncat_front_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +; Peephole 180 changed mov to clr + clr a + lcall __gptrput +; _strncat.c 44 + mov dpl,_strncat_sloc0_1_0 + mov dph,(_strncat_sloc0_1_0 + 1) + mov b,(_strncat_sloc0_1_0 + 2) +00109$: + C$_strncat.c$45$1$1 ==. + XG$strncat$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strncat.cdb b/device/lib/large/_strncat.cdb new file mode 100644 index 00000000..32daeafd --- /dev/null +++ b/device/lib/large/_strncat.cdb @@ -0,0 +1,2 @@ +M:_strncat +F:G$strncat$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strncat.rel b/device/lib/large/_strncat.rel new file mode 100644 index 00000000..da66d0fd --- /dev/null +++ b/device/lib/large/_strncat.rel @@ -0,0 +1,263 @@ +;!FILE _strncat.asm +XH +H 8 areas 99 global symbols +M _strncat +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 9 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S _strncat_PARM_2 Def0000 +S _strncat_PARM_3 Def0003 +A GSINIT size 0 flags 20 +A CSEG size EF flags 20 +S A$_strncat$100 Def0026 +S A$_strncat$200 Def00AB +S A$_strncat$101 Def0027 +S A$_strncat$210 Def00BA +S A$_strncat$201 Def00AE +S A$_strncat$120 Def003D +S A$_strncat$111 Def0031 +S A$_strncat$102 Def0028 +S A$_strncat$220 Def00CB +S A$_strncat$211 Def00BC +S A$_strncat$202 Def00B0 +S A$_strncat$121 Def003E +S A$_strncat$112 Def0032 +S A$_strncat$103 Def0029 +S A$_strncat$230 Def00D7 +S A$_strncat$212 Def00BE +S A$_strncat$203 Def00B1 +S A$_strncat$140 Def0055 +S A$_strncat$131 Def004B +S A$_strncat$122 Def003F +S A$_strncat$113 Def0033 +S A$_strncat$104 Def002A +S A$_strncat$231 Def00D8 +S A$_strncat$222 Def00CE +S A$_strncat$213 Def00C0 +S A$_strncat$204 Def00B4 +S A$_strncat$150 Def0060 +S A$_strncat$141 Def0058 +S A$_strncat$123 Def0040 +S A$_strncat$114 Def0034 +S A$_strncat$105 Def002B +S A$_strncat$241 Def00E5 +S A$_strncat$232 Def00D9 +S A$_strncat$160 Def0071 +S A$_strncat$151 Def0062 +S A$_strncat$142 Def0059 +S A$_strncat$124 Def0041 +S A$_strncat$115 Def0036 +S A$_strncat$106 Def002C +S _strncat Def0000 +S A$_strncat$242 Def00E8 +S A$_strncat$233 Def00DA +S A$_strncat$215 Def00C3 +S A$_strncat$206 Def00B6 +S A$_strncat$170 Def007E +S A$_strncat$161 Def0072 +S A$_strncat$152 Def0064 +S A$_strncat$143 Def005A +S A$_strncat$134 Def004D +S A$_strncat$125 Def0043 +S A$_strncat$116 Def0039 +S A$_strncat$107 Def002D +S A$_strncat$243 Def00EB +S A$_strncat$234 Def00DB +S A$_strncat$225 Def00D0 +S A$_strncat$171 Def0080 +S A$_strncat$162 Def0074 +S A$_strncat$153 Def0066 +S A$_strncat$144 Def005B +S A$_strncat$135 Def004E +S A$_strncat$126 Def0045 +S A$_strncat$117 Def003A +S A$_strncat$108 Def002F +S A$_strncat$235 Def00DD +S A$_strncat$226 Def00D3 +S A$_strncat$190 Def009A +S A$_strncat$181 Def0089 +S A$_strncat$172 Def0081 +S A$_strncat$163 Def0077 +S A$_strncat$154 Def0069 +S A$_strncat$145 Def005C +S A$_strncat$136 Def0050 +S A$_strncat$127 Def0047 +S A$_strncat$118 Def003B +S A$_strncat$109 Def0030 +S A$_strncat$236 Def00DF +S A$_strncat$227 Def00D4 +S A$_strncat$218 Def00C5 +S A$_strncat$209 Def00B9 +S A$_strncat$191 Def009C +S A$_strncat$182 Def008B +S A$_strncat$173 Def0084 +S A$_strncat$164 Def0078 +S A$_strncat$155 Def006A +S A$_strncat$146 Def005D +S A$_strncat$137 Def0051 +S A$_strncat$119 Def003C +S A$_strncat$228 Def00D5 +S A$_strncat$219 Def00C8 +S A$_strncat$192 Def009D +S A$_strncat$183 Def008D +S A$_strncat$165 Def0079 +S A$_strncat$156 Def006C +S A$_strncat$147 Def005E +S A$_strncat$138 Def0052 +S A$_strncat$129 Def004A +S A$_strncat$247 Def00EE +S A$_strncat$238 Def00E1 +S A$_strncat$229 Def00D6 +S A$_strncat$193 Def009E +S A$_strncat$184 Def008F +S A$_strncat$175 Def0085 +S A$_strncat$166 Def007A +S A$_strncat$157 Def006D +S A$_strncat$148 Def005F +S A$_strncat$139 Def0054 +S A$_strncat$239 Def00E2 +S A$_strncat$194 Def00A0 +S A$_strncat$185 Def0091 +S A$_strncat$176 Def0086 +S A$_strncat$167 Def007B +S A$_strncat$158 Def006E +S A$_strncat$195 Def00A1 +S A$_strncat$186 Def0092 +S A$_strncat$159 Def0070 +S A$_strncat$196 Def00A2 +S A$_strncat$187 Def0095 +S A$_strncat$178 Def0087 +S A$_strncat$169 Def007C +S A$_strncat$197 Def00A4 +S A$_strncat$198 Def00A5 +S A$_strncat$189 Def0097 +S A$_strncat$199 Def00A8 +S XG$strncat$0$0 Def00EE +S C$_strncat.c$45$1$1 Def00EE +S A$_strncat$80 Def000C +S A$_strncat$90 Def001A +S A$_strncat$81 Def000E +S A$_strncat$91 Def001B +S A$_strncat$82 Def000F +S A$_strncat$92 Def001C +S A$_strncat$83 Def0010 +S A$_strncat$74 Def0000 +S G$strncat$0$0 Def0000 +S A$_strncat$93 Def001E +S A$_strncat$84 Def0012 +S A$_strncat$75 Def0002 +S A$_strncat$94 Def001F +S A$_strncat$85 Def0013 +S A$_strncat$76 Def0004 +S A$_strncat$95 Def0020 +S A$_strncat$77 Def0006 +S A$_strncat$87 Def0014 +S A$_strncat$78 Def0009 +S A$_strncat$88 Def0017 +S A$_strncat$79 Def000B +S A$_strncat$98 Def0022 +S A$_strncat$89 Def0018 +S A$_strncat$99 Def0025 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 05 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 05 E0 F5 00 00 A3 +R 00 00 00 07 00 09 00 05 29 0D 00 01 +T 00 1B E0 F5 00 01 A3 E0 F5 00 02 +R 00 00 00 07 29 04 00 01 29 09 00 01 +T 00 22 +R 00 00 00 07 +T 00 22 90 00 05 E0 FD A3 E0 FE A3 E0 FF 74 01 2D +R 00 00 00 07 00 03 00 05 +T 00 30 F8 E4 3E F9 8F 02 90 00 05 E8 F0 A3 E9 F0 +R 00 00 00 07 00 09 00 05 +T 00 3E A3 EA F0 8D 82 8E 83 8F F0 12 00 00 FD 70 +R 00 00 00 07 02 0C 00 01 +T 00 4C D5 +R 00 00 00 07 +T 00 4D +R 00 00 00 07 +T 00 4D E8 24 FF FC E9 34 FF FB 90 00 05 EC F0 A3 +R 00 00 00 07 00 0B 00 05 +T 00 5B EB F0 A3 EA F0 8C 00 06 8B 00 07 8A 00 08 +R 00 00 00 07 29 08 00 01 29 0B 00 01 29 0E 00 01 +T 00 66 90 00 00 E0 F5 00 03 A3 E0 F5 00 04 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 72 F5 00 05 90 00 03 E0 FD A3 E0 F8 +R 00 00 00 07 29 03 00 01 00 06 00 05 +T 00 7C +R 00 00 00 07 +T 00 7C 8D 01 88 02 1D BD FF 01 18 +R 00 00 00 07 +T 00 85 +R 00 00 00 07 +T 00 85 E9 4A 60 47 +R 00 00 00 07 +T 00 89 +R 00 00 00 07 +T 00 89 AA 00 06 AB 00 07 AC 00 08 05 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 90 00 06 E4 B5 00 06 02 05 00 07 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 97 +R 00 00 00 07 +T 00 97 90 00 05 E5 00 06 F0 A3 E5 00 07 F0 A3 E5 +R 00 00 00 07 00 03 00 05 29 06 00 01 29 0B 00 01 +T 00 A3 00 08 F0 85 00 03 82 85 00 04 83 85 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 AC 00 05 F0 05 00 03 E4 B5 00 03 02 05 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 B5 00 04 +R 00 00 00 07 29 02 00 01 +T 00 B6 +R 00 00 00 07 +T 00 B6 12 00 00 F9 8A 82 8B 83 8C F0 12 00 00 70 +R 00 00 00 07 02 03 00 01 02 0D 00 00 +T 00 C4 B7 +R 00 00 00 07 +T 00 C5 +R 00 00 00 07 +T 00 C5 85 00 00 82 85 00 01 83 85 00 02 F0 80 1E +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 D0 +R 00 00 00 07 +T 00 D0 90 00 05 E0 FA A3 E0 FB A3 E0 FC 8A 82 8B +R 00 00 00 07 00 03 00 05 +T 00 DE 83 8C F0 E4 12 00 00 85 00 00 82 85 00 01 +R 00 00 00 07 02 07 00 00 29 0A 00 01 29 0E 00 01 +T 00 EA 83 85 00 02 F0 +R 00 00 00 07 29 04 00 01 +T 00 EE +R 00 00 00 07 +T 00 EE 22 +R 00 00 00 07 diff --git a/device/lib/large/_strncmp.asm b/device/lib/large/_strncmp.asm new file mode 100644 index 00000000..630f04d0 --- /dev/null +++ b/device/lib/large/_strncmp.asm @@ -0,0 +1,212 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:33 2000 + +;-------------------------------------------------------- + .module _strncmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strncmp_PARM_3 + .globl _strncmp_PARM_2 + .globl _strncmp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strncmp_PARM_2: + .ds 0x0003 +_strncmp_PARM_3: + .ds 0x0002 +_strncmp_first_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strncmp$0$0 ==. +; _strncmp.c 27 +; ----------------------------------------- +; function strncmp +; ----------------------------------------- +_strncmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strncmp.c 0 + push b + push dph + push dpl + mov dptr,#_strncmp_first_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strncmp.c 33 + mov dptr,#_strncmp_PARM_3 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r3,a + orl a,r2 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00114$ +00115$: +; _strncmp.c 34 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00108$ +; _strncmp.c 36 +00114$: + mov dptr,#_strncmp_first_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#_strncmp_PARM_2 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a +00105$: + mov dptr,#_strncmp_PARM_3 + movx a,@dptr + add a,#0xff + mov r0,a + inc dptr + movx a,@dptr + addc a,#0xff + mov r1,a + mov dptr,#_strncmp_PARM_3 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + mov a,r0 + orl a,r1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00116$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00117$: + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r1,a + mov a,r0 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar1,00107$ +; Peephole 201 removed redundant sjmp +00118$: +00119$: +; _strncmp.c 37 + inc r2 + cjne r2,#0x00,00120$ + inc r3 +00120$: + mov dptr,#_strncmp_first_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _strncmp.c 38 + inc r5 + cjne r5,#0x00,00121$ + inc r6 +00121$: + ljmp 00105$ +00107$: +; _strncmp.c 41 + mov dptr,#_strncmp_first_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 106 removed redundant mov + mov r2,a + clr c + subb a,r5 + mov r2,a +; Peephole 180 changed mov to clr + clr a + subb a,#0x00 + mov r5,a + mov dpl,r2 + mov dph,r5 +00108$: + C$_strncmp.c$42$1$1 ==. + XG$strncmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strncmp.cdb b/device/lib/large/_strncmp.cdb new file mode 100644 index 00000000..2464f2c8 --- /dev/null +++ b/device/lib/large/_strncmp.cdb @@ -0,0 +1,2 @@ +M:_strncmp +F:G$strncmp$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strncmp.rel b/device/lib/large/_strncmp.rel new file mode 100644 index 00000000..787d23e7 --- /dev/null +++ b/device/lib/large/_strncmp.rel @@ -0,0 +1,205 @@ +;!FILE _strncmp.asm +XH +H 8 areas 79 global symbols +M _strncmp +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S _strncmp_PARM_2 Def0000 +S _strncmp_PARM_3 Def0003 +A GSINIT size 0 flags 20 +A CSEG size B0 flags 20 +S A$_strncmp$98 Def0025 +S A$_strncmp$99 Def0028 +S A$_strncmp$100 Def0029 +S A$_strncmp$200 Def00A5 +S A$_strncmp$110 Def0035 +S A$_strncmp$101 Def002A +S A$_strncmp$201 Def00A6 +S A$_strncmp$120 Def0041 +S A$_strncmp$111 Def0036 +S A$_strncmp$102 Def002B +S A$_strncmp$211 Def00AF +S A$_strncmp$130 Def004E +S A$_strncmp$121 Def0042 +S A$_strncmp$112 Def0037 +S A$_strncmp$103 Def002C +S A$_strncmp$203 Def00A7 +S A$_strncmp$131 Def004F +S A$_strncmp$122 Def0043 +S A$_strncmp$113 Def0038 +S A$_strncmp$104 Def002D +S A$_strncmp$204 Def00A8 +S A$_strncmp$150 Def0069 +S A$_strncmp$141 Def005C +S A$_strncmp$132 Def0050 +S A$_strncmp$123 Def0044 +S A$_strncmp$114 Def0039 +S A$_strncmp$105 Def002E +S A$_strncmp$205 Def00AA +S A$_strncmp$160 Def0071 +S A$_strncmp$124 Def0046 +S A$_strncmp$115 Def003A +S A$_strncmp$106 Def002F +S _strncmp Def0000 +S A$_strncmp$206 Def00AB +S A$_strncmp$170 Def007C +S A$_strncmp$143 Def005D +S A$_strncmp$134 Def0051 +S A$_strncmp$125 Def0047 +S A$_strncmp$107 Def0030 +S A$_strncmp$207 Def00AD +S A$_strncmp$180 Def0088 +S A$_strncmp$162 Def0072 +S A$_strncmp$153 Def006A +S A$_strncmp$126 Def004A +S A$_strncmp$117 Def003B +S A$_strncmp$108 Def0033 +S A$_strncmp$190 Def0094 +S A$_strncmp$181 Def0089 +S A$_strncmp$172 Def007D +S A$_strncmp$163 Def0075 +S A$_strncmp$145 Def005F +S A$_strncmp$136 Def0053 +S A$_strncmp$127 Def004B +S A$_strncmp$118 Def003E +S A$_strncmp$109 Def0034 +S A$_strncmp$191 Def0096 +S A$_strncmp$182 Def008A +S A$_strncmp$173 Def007E +S A$_strncmp$164 Def0076 +S A$_strncmp$146 Def0061 +S A$_strncmp$137 Def0055 +S A$_strncmp$128 Def004C +S A$_strncmp$119 Def003F +S A$_strncmp$192 Def0099 +S A$_strncmp$183 Def008B +S A$_strncmp$174 Def0081 +S A$_strncmp$165 Def0077 +S A$_strncmp$147 Def0063 +S A$_strncmp$138 Def0057 +S A$_strncmp$129 Def004D +S A$_strncmp$193 Def009A +S A$_strncmp$184 Def008C +S A$_strncmp$166 Def0078 +S A$_strncmp$148 Def0065 +S A$_strncmp$139 Def0059 +S A$_strncmp$194 Def009C +S A$_strncmp$185 Def008D +S A$_strncmp$176 Def0082 +S A$_strncmp$167 Def0079 +S A$_strncmp$158 Def006D +S A$_strncmp$149 Def0068 +S A$_strncmp$195 Def009E +S A$_strncmp$186 Def008E +S A$_strncmp$168 Def007A +S A$_strncmp$159 Def006E +S A$_strncmp$196 Def00A0 +S A$_strncmp$187 Def008F +S A$_strncmp$169 Def007B +S A$_strncmp$188 Def0090 +S A$_strncmp$179 Def0085 +S A$_strncmp$198 Def00A3 +S A$_strncmp$189 Def0092 +S A$_strncmp$199 Def00A4 +S XG$strncmp$0$0 Def00AF +S C$_strncmp.c$42$1$1 Def00AF +S A$_strncmp$70 Def0004 +S A$_strncmp$71 Def0006 +S A$_strncmp$90 Def001D +S A$_strncmp$81 Def0014 +S A$_strncmp$72 Def0009 +S A$_strncmp$82 Def0017 +S A$_strncmp$73 Def000B +S A$_strncmp$83 Def0018 +S A$_strncmp$74 Def000C +S G$strncmp$0$0 Def0000 +S A$_strncmp$84 Def0019 +S A$_strncmp$75 Def000E +S A$_strncmp$94 Def001F +S A$_strncmp$85 Def001A +S A$_strncmp$76 Def000F +S A$_strncmp$95 Def0022 +S A$_strncmp$77 Def0010 +S A$_strncmp$68 Def0000 +S A$_strncmp$87 Def001B +S A$_strncmp$78 Def0012 +S A$_strncmp$69 Def0002 +S A$_strncmp$88 Def001C +S A$_strncmp$79 Def0013 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 05 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C 4A 70 06 +R 00 00 00 07 +T 00 1F +R 00 00 00 07 +T 00 1F 90 00 00 02 00 AF +R 00 00 00 07 00 06 00 07 +T 00 25 +R 00 00 00 07 +T 00 25 90 00 05 E0 FA A3 E0 FB A3 E0 FC 90 00 00 +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 00 33 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 +T 00 3B +R 00 00 00 07 +T 00 3B 90 00 03 E0 24 FF F8 A3 E0 34 FF F9 90 +R 00 00 00 07 00 03 00 05 +T 00 48 00 03 E8 F0 A3 E9 F0 E8 49 60 32 +R 00 00 00 07 00 02 00 05 +T 00 53 +R 00 00 00 07 +T 00 53 8A 82 8B 83 8C F0 12 00 00 F8 60 26 +R 00 00 00 07 02 09 00 00 +T 00 5F +R 00 00 00 07 +T 00 5F 8D 82 8E 83 8F F0 12 00 00 F9 E8 B5 01 18 +R 00 00 00 07 02 09 00 00 +T 00 6D +R 00 00 00 07 +T 00 6D +R 00 00 00 07 +T 00 6D 0A BA 00 01 0B +R 00 00 00 07 +T 00 72 +R 00 00 00 07 +T 00 72 90 00 05 EA F0 A3 EB F0 A3 EC F0 0D BD 00 +R 00 00 00 07 00 03 00 05 +T 00 80 01 0E +R 00 00 00 07 +T 00 82 +R 00 00 00 07 +T 00 82 02 00 3B +R 00 00 00 07 00 03 00 07 +T 00 85 +R 00 00 00 07 +T 00 85 90 00 05 EA F0 A3 EB F0 A3 EC F0 8D 82 8E +R 00 00 00 07 00 03 00 05 +T 00 93 83 8F F0 12 00 00 FD 8A 82 8B 83 8C F0 12 +R 00 00 00 07 02 06 00 00 +T 00 A1 00 00 FA C3 9D FA E4 94 00 FD 8A 82 8D 83 +R 00 00 00 07 02 02 00 00 +T 00 AF +R 00 00 00 07 +T 00 AF 22 +R 00 00 00 07 diff --git a/device/lib/large/_strncpy.asm b/device/lib/large/_strncpy.asm new file mode 100644 index 00000000..03bb0d0a --- /dev/null +++ b/device/lib/large/_strncpy.asm @@ -0,0 +1,172 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + +;-------------------------------------------------------- + .module _strncpy +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strncpy_PARM_3 + .globl _strncpy_PARM_2 + .globl _strncpy +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strncpy_sloc0_1_0: + .ds 0x0003 +_strncpy_sloc1_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strncpy_PARM_2: + .ds 0x0003 +_strncpy_PARM_3: + .ds 0x0002 +_strncpy_d_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strncpy$0$0 ==. +; _strncpy.c 27 +; ----------------------------------------- +; function strncpy +; ----------------------------------------- +_strncpy: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strncpy.c 36 + push b + push dph + push dpl + mov dptr,#_strncpy_d_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strncpy.c 32 + mov dptr,#_strncpy_d_1_1 + movx a,@dptr + mov _strncpy_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strncpy_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strncpy_sloc0_1_0 + 2),a +; _strncpy.c 34 + mov r5,_strncpy_sloc0_1_0 + mov r6,(_strncpy_sloc0_1_0 + 1) + mov r7,(_strncpy_sloc0_1_0 + 2) + mov dptr,#_strncpy_PARM_2 + movx a,@dptr + mov _strncpy_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (_strncpy_sloc1_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strncpy_sloc1_1_0 + 2),a + mov dptr,#_strncpy_PARM_3 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +00101$: + mov ar2,r3 + mov ar0,r4 + dec r3 + cjne r3,#0xff,00108$ + dec r4 +00108$: + mov dptr,#_strncpy_d_1_1 + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + mov a,r2 + orl a,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _strncpy.c 35 + push ar3 + push ar4 + mov ar2,r5 + mov ar0,r6 + mov ar1,r7 + inc r5 + cjne r5,#0x00,00110$ + inc r6 +00110$: + mov dpl,_strncpy_sloc1_1_0 + mov dph,(_strncpy_sloc1_1_0 + 1) + mov b,(_strncpy_sloc1_1_0 + 2) + inc _strncpy_sloc1_1_0 + clr a + cjne a,_strncpy_sloc1_1_0,00111$ + inc (_strncpy_sloc1_1_0 + 1) +00111$: + lcall __gptrget +; Peephole 191 removed redundant mov + mov r3,a + mov dpl,r2 + mov dph,r0 + mov b,r1 + lcall __gptrput + pop ar4 + pop ar3 +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _strncpy.c 36 + mov dpl,_strncpy_sloc0_1_0 + mov dph,(_strncpy_sloc0_1_0 + 1) + mov b,(_strncpy_sloc0_1_0 + 2) +00104$: + C$_strncpy.c$37$1$1 ==. + XG$strncpy$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strncpy.cdb b/device/lib/large/_strncpy.cdb new file mode 100644 index 00000000..c2c28153 --- /dev/null +++ b/device/lib/large/_strncpy.cdb @@ -0,0 +1,2 @@ +M:_strncpy +F:G$strncpy$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strncpy.rel b/device/lib/large/_strncpy.rel new file mode 100644 index 00000000..338031e5 --- /dev/null +++ b/device/lib/large/_strncpy.rel @@ -0,0 +1,174 @@ +;!FILE _strncpy.asm +XH +H 8 areas 5C global symbols +M _strncpy +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S _strncpy_PARM_2 Def0000 +S _strncpy_PARM_3 Def0003 +A GSINIT size 0 flags 20 +A CSEG size 93 flags 20 +S C$_strncpy.c$37$1$1 Def0092 +S A$_strncpy$80 Def000F +S A$_strncpy$90 Def001C +S A$_strncpy$81 Def0010 +S A$_strncpy$72 Def0000 +S A$_strncpy$91 Def001E +S A$_strncpy$82 Def0012 +S A$_strncpy$73 Def0002 +S A$_strncpy$92 Def001F +S A$_strncpy$83 Def0013 +S A$_strncpy$74 Def0004 +S G$strncpy$0$0 Def0000 +S A$_strncpy$93 Def0020 +S A$_strncpy$75 Def0006 +S A$_strncpy$85 Def0014 +S A$_strncpy$76 Def0009 +S A$_strncpy$95 Def0022 +S A$_strncpy$86 Def0017 +S A$_strncpy$77 Def000B +S A$_strncpy$96 Def0024 +S A$_strncpy$87 Def0018 +S A$_strncpy$78 Def000C +S A$_strncpy$97 Def0026 +S A$_strncpy$88 Def001A +S A$_strncpy$79 Def000E +S A$_strncpy$98 Def0028 +S A$_strncpy$89 Def001B +S A$_strncpy$99 Def002B +S A$_strncpy$100 Def002C +S A$_strncpy$110 Def003B +S A$_strncpy$101 Def002E +S A$_strncpy$120 Def0047 +S A$_strncpy$111 Def003C +S A$_strncpy$102 Def002F +S A$_strncpy$130 Def0053 +S A$_strncpy$121 Def004A +S A$_strncpy$112 Def003D +S A$_strncpy$103 Def0030 +S A$_strncpy$140 Def0060 +S A$_strncpy$122 Def004B +S A$_strncpy$104 Def0032 +S A$_strncpy$150 Def0074 +S A$_strncpy$141 Def0061 +S A$_strncpy$132 Def0054 +S A$_strncpy$123 Def004C +S A$_strncpy$114 Def003E +S A$_strncpy$105 Def0033 +S A$_strncpy$160 Def0085 +S A$_strncpy$142 Def0064 +S A$_strncpy$124 Def004D +S A$_strncpy$115 Def0040 +S A$_strncpy$106 Def0034 +S _strncpy Def0000 +S A$_strncpy$152 Def0076 +S A$_strncpy$125 Def004E +S A$_strncpy$116 Def0042 +S A$_strncpy$107 Def0036 +S A$_strncpy$171 Def0092 +S A$_strncpy$162 Def0087 +S A$_strncpy$144 Def0065 +S A$_strncpy$135 Def0056 +S A$_strncpy$126 Def004F +S A$_strncpy$117 Def0043 +S A$_strncpy$108 Def0039 +S A$_strncpy$154 Def0079 +S A$_strncpy$145 Def0068 +S A$_strncpy$136 Def0058 +S A$_strncpy$127 Def0050 +S A$_strncpy$118 Def0046 +S A$_strncpy$109 Def003A +S A$_strncpy$155 Def007A +S A$_strncpy$146 Def006B +S A$_strncpy$137 Def005A +S A$_strncpy$128 Def0051 +S A$_strncpy$165 Def0089 +S A$_strncpy$156 Def007C +S A$_strncpy$147 Def006E +S A$_strncpy$138 Def005C +S A$_strncpy$129 Def0052 +S A$_strncpy$166 Def008C +S A$_strncpy$157 Def007E +S A$_strncpy$148 Def0070 +S A$_strncpy$139 Def005E +S A$_strncpy$167 Def008F +S A$_strncpy$158 Def0080 +S A$_strncpy$149 Def0071 +S A$_strncpy$159 Def0083 +S XG$strncpy$0$0 Def0092 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 05 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 05 E0 F5 00 00 A3 +R 00 00 00 07 00 09 00 05 29 0D 00 01 +T 00 1B E0 F5 00 01 A3 E0 F5 00 02 AD 00 00 AE +R 00 00 00 07 29 04 00 01 29 09 00 01 29 0C 00 01 +T 00 25 00 01 AF 00 02 90 00 00 E0 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 00 08 00 05 +T 00 2D 00 03 A3 E0 F5 00 04 A3 E0 F5 00 05 90 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 37 00 03 E0 FB A3 E0 FC +R 00 00 00 07 00 02 00 05 +T 00 3E +R 00 00 00 07 +T 00 3E 8B 02 8C 00 1B BB FF 01 1C +R 00 00 00 07 +T 00 47 +R 00 00 00 07 +T 00 47 90 00 05 ED F0 A3 EE F0 A3 EF F0 EA 48 60 +R 00 00 00 07 00 03 00 05 +T 00 55 33 +R 00 00 00 07 +T 00 56 +R 00 00 00 07 +T 00 56 C0 03 C0 04 8D 02 8E 00 8F 01 0D BD 00 01 +R 00 00 00 07 +T 00 64 0E +R 00 00 00 07 +T 00 65 +R 00 00 00 07 +T 00 65 85 00 03 82 85 00 04 83 85 00 05 F0 05 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 6F 00 03 E4 B5 00 03 02 05 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 76 +R 00 00 00 07 +T 00 76 12 00 00 FB 8A 82 88 83 89 F0 12 00 00 D0 +R 00 00 00 07 02 03 00 01 02 0D 00 00 +T 00 84 04 D0 03 80 B5 +R 00 00 00 07 +T 00 89 +R 00 00 00 07 +T 00 89 85 00 00 82 85 00 01 83 85 00 02 F0 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 92 +R 00 00 00 07 +T 00 92 22 +R 00 00 00 07 diff --git a/device/lib/large/_strpbrk.asm b/device/lib/large/_strpbrk.asm new file mode 100644 index 00000000..ad3cc7c8 --- /dev/null +++ b/device/lib/large/_strpbrk.asm @@ -0,0 +1,146 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + +;-------------------------------------------------------- + .module _strpbrk +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strpbrk_PARM_2 + .globl _strpbrk +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strpbrk_sloc0_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strpbrk_PARM_2: + .ds 0x0003 +_strpbrk_string_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strpbrk$0$0 ==. +; _strpbrk.c 27 +; ----------------------------------------- +; function strpbrk +; ----------------------------------------- +_strpbrk: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strpbrk.c 0 + push b + push dph + push dpl + mov dptr,#_strpbrk_string_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strpbrk.c 34 + mov dptr,#_strpbrk_PARM_2 + movx a,@dptr + mov _strpbrk_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strpbrk_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strpbrk_sloc0_1_0 + 2),a + mov dptr,#_strpbrk_string_1_1 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a +00103$: + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00105$ +00111$: +; _strpbrk.c 35 + mov dptr,#_strchr_PARM_2 + mov a,r0 + movx @dptr,a + push ar5 + push ar6 + push ar7 + mov dpl,_strpbrk_sloc0_1_0 + mov dph,(_strpbrk_sloc0_1_0 + 1) + mov b,(_strpbrk_sloc0_1_0 + 2) + lcall _strchr + mov r0,dpl + mov r1,dph + mov r2,b + pop ar7 + pop ar6 + pop ar5 + mov a,r0 + orl a,r1 + orl a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00112$: +; _strpbrk.c 36 + mov dpl,r5 + mov dph,r6 + mov b,r7 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _strpbrk.c 39 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00106$: + C$_strpbrk.c$40$1$1 ==. + XG$strpbrk$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strpbrk.cdb b/device/lib/large/_strpbrk.cdb new file mode 100644 index 00000000..59c97da3 --- /dev/null +++ b/device/lib/large/_strpbrk.cdb @@ -0,0 +1,2 @@ +M:_strpbrk +F:G$strpbrk$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strpbrk.rel b/device/lib/large/_strpbrk.rel new file mode 100644 index 00000000..37833fd7 --- /dev/null +++ b/device/lib/large/_strpbrk.rel @@ -0,0 +1,131 @@ +;!FILE _strpbrk.asm +XH +H 8 areas 47 global symbols +M _strpbrk +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 3 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 6 flags 40 +S _strpbrk_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 70 flags 20 +S A$_strpbrk$97 Def002C +S A$_strpbrk$88 Def0020 +S A$_strpbrk$89 Def0022 +S A$_strpbrk$99 Def002D +S A$_strpbrk$100 Def002F +S A$_strpbrk$110 Def003C +S A$_strpbrk$101 Def0031 +S A$_strpbrk$120 Def0052 +S A$_strpbrk$111 Def003D +S A$_strpbrk$102 Def0033 +S A$_strpbrk$121 Def0054 +S A$_strpbrk$112 Def003E +S A$_strpbrk$140 Def0069 +S A$_strpbrk$122 Def0056 +S A$_strpbrk$113 Def0040 +S A$_strpbrk$104 Def0036 +S A$_strpbrk$141 Def006C +S A$_strpbrk$132 Def0061 +S A$_strpbrk$123 Def0058 +S A$_strpbrk$114 Def0042 +S A$_strpbrk$133 Def0063 +S A$_strpbrk$124 Def005A +S A$_strpbrk$115 Def0044 +S A$_strpbrk$106 Def0037 +S _strpbrk Def0000 +S A$_strpbrk$134 Def0065 +S A$_strpbrk$125 Def005C +S A$_strpbrk$116 Def0047 +S A$_strpbrk$126 Def005D +S A$_strpbrk$117 Def004A +S A$_strpbrk$145 Def006F +S A$_strpbrk$136 Def0067 +S A$_strpbrk$127 Def005E +S A$_strpbrk$118 Def004D +S A$_strpbrk$109 Def0039 +S A$_strpbrk$119 Def0050 +S A$_strpbrk$129 Def005F +S C$_strpbrk.c$40$1$1 Def006F +S XG$strpbrk$0$0 Def006F +S A$_strpbrk$70 Def0006 +S A$_strpbrk$80 Def0014 +S A$_strpbrk$71 Def0009 +S A$_strpbrk$90 Def0025 +S A$_strpbrk$81 Def0017 +S A$_strpbrk$72 Def000B +S A$_strpbrk$91 Def0026 +S A$_strpbrk$82 Def0018 +S A$_strpbrk$73 Def000C +S A$_strpbrk$92 Def0027 +S A$_strpbrk$83 Def001A +S A$_strpbrk$74 Def000E +S G$strpbrk$0$0 Def0000 +S A$_strpbrk$93 Def0028 +S A$_strpbrk$84 Def001B +S A$_strpbrk$75 Def000F +S A$_strpbrk$94 Def0029 +S A$_strpbrk$85 Def001C +S A$_strpbrk$76 Def0010 +S A$_strpbrk$67 Def0000 +S A$_strpbrk$95 Def002A +S A$_strpbrk$86 Def001E +S A$_strpbrk$77 Def0012 +S A$_strpbrk$68 Def0002 +S A$_strpbrk$96 Def002B +S A$_strpbrk$87 Def001F +S A$_strpbrk$78 Def0013 +S A$_strpbrk$69 Def0004 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 00 E0 F5 00 00 A3 +R 00 00 00 07 00 09 00 05 29 0D 00 01 +T 00 1B E0 F5 00 01 A3 E0 F5 00 02 90 00 03 E0 FD +R 00 00 00 07 29 04 00 01 29 09 00 01 00 0C 00 05 +T 00 27 A3 E0 FE A3 E0 FF +R 00 00 00 07 +T 00 2D +R 00 00 00 07 +T 00 2D 8D 82 8E 83 8F F0 12 00 00 F8 60 30 +R 00 00 00 07 02 09 00 02 +T 00 39 +R 00 00 00 07 +T 00 39 90 00 00 E8 F0 C0 05 C0 06 C0 07 85 00 00 +R 00 00 00 07 02 03 00 00 29 0E 00 01 +T 00 46 82 85 00 01 83 85 00 02 F0 12 00 00 A8 82 +R 00 00 00 07 29 04 00 01 29 08 00 01 02 0C 00 01 +T 00 52 A9 83 AA F0 D0 07 D0 06 D0 05 E8 49 4A 60 +R 00 00 00 07 +T 00 60 CC +R 00 00 00 07 +T 00 61 +R 00 00 00 07 +T 00 61 8D 82 8E 83 8F F0 80 06 +R 00 00 00 07 +T 00 69 +R 00 00 00 07 +T 00 69 90 00 00 75 F0 00 +R 00 00 00 07 +T 00 6F +R 00 00 00 07 +T 00 6F 22 +R 00 00 00 07 diff --git a/device/lib/large/_strrchr.asm b/device/lib/large/_strrchr.asm new file mode 100644 index 00000000..ba7b742d --- /dev/null +++ b/device/lib/large/_strrchr.asm @@ -0,0 +1,209 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + +;-------------------------------------------------------- + .module _strrchr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strrchr_PARM_2 + .globl _strrchr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strrchr_sloc0_1_0: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strrchr_PARM_2: + .ds 0x0001 +_strrchr_string_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strrchr$0$0 ==. +; _strrchr.c 27 +; ----------------------------------------- +; function strrchr +; ----------------------------------------- +_strrchr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strrchr.c 0 + push b + push dph + push dpl + mov dptr,#_strrchr_string_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strrchr.c 32 + mov dptr,#_strrchr_string_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +; _strrchr.c 34 + mov ar5,r2 + mov ar6,r3 + mov ar7,r4 +00101$: + push ar2 + push ar3 + push ar4 + mov ar0,r5 + mov ar1,r6 + mov ar2,r7 + inc r5 + cjne r5,#0x00,00116$ + inc r6 +00116$: + mov dptr,#_strrchr_string_1_1 + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + mov dpl,r0 + mov dph,r1 + mov b,r2 + lcall __gptrget + mov r0,a + pop ar4 + pop ar3 + pop ar2 + mov a,r0 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00101$ +00117$: +; _strrchr.c 37 + mov dptr,#_strrchr_PARM_2 + movx a,@dptr + mov _strrchr_sloc0_1_0,a +00105$: + mov dptr,#_strrchr_string_1_1 + movx a,@dptr + add a,#0xff + mov r6,a + inc dptr + movx a,@dptr + addc a,#0xff + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + mov dptr,#_strrchr_string_1_1 + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + mov a,r6 + cjne a,ar2,00118$ + mov a,r7 + cjne a,ar3,00118$ + mov a,r0 + cjne a,ar4,00118$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00118$: + push ar2 + push ar3 + push ar4 + mov dpl,r6 + mov dph,r7 + mov b,r0 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r2,a + cjne a,_strrchr_sloc0_1_0,00119$ + mov a,#0x01 + sjmp 00120$ +00119$: + clr a +00120$: + pop ar4 + pop ar3 + pop ar2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00105$ +00121$: +00107$: +; _strrchr.c 40 + mov dpl,r6 + mov dph,r7 + mov b,r0 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,_strrchr_sloc0_1_0,00109$ +; Peephole 201 removed redundant sjmp +00122$: +00123$: +; _strrchr.c 41 + mov dpl,r6 + mov dph,r7 + mov b,r0 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00109$: +; _strrchr.c 43 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00110$: + C$_strrchr.c$44$1$1 ==. + XG$strrchr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strrchr.cdb b/device/lib/large/_strrchr.cdb new file mode 100644 index 00000000..cc49dc3f --- /dev/null +++ b/device/lib/large/_strrchr.cdb @@ -0,0 +1,2 @@ +M:_strrchr +F:G$strrchr$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strrchr.rel b/device/lib/large/_strrchr.rel new file mode 100644 index 00000000..1f5e2c0b --- /dev/null +++ b/device/lib/large/_strrchr.rel @@ -0,0 +1,209 @@ +;!FILE _strrchr.asm +XH +H 8 areas 75 global symbols +M _strrchr +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 1 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 4 flags 40 +S _strrchr_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size BE flags 20 +S A$_strrchr$97 Def002B +S A$_strrchr$88 Def001E +S A$_strrchr$98 Def002D +S A$_strrchr$99 Def002F +S A$_strrchr$100 Def0031 +S A$_strrchr$110 Def003E +S A$_strrchr$101 Def0032 +S A$_strrchr$120 Def004F +S A$_strrchr$111 Def003F +S A$_strrchr$102 Def0035 +S A$_strrchr$130 Def005A +S A$_strrchr$121 Def0051 +S A$_strrchr$112 Def0040 +S A$_strrchr$203 Def00B7 +S A$_strrchr$140 Def0068 +S A$_strrchr$131 Def005D +S A$_strrchr$113 Def0041 +S A$_strrchr$104 Def0036 +S A$_strrchr$204 Def00BA +S A$_strrchr$150 Def0074 +S A$_strrchr$141 Def0069 +S A$_strrchr$132 Def005E +S A$_strrchr$123 Def0052 +S A$_strrchr$114 Def0043 +S A$_strrchr$105 Def0039 +S A$_strrchr$160 Def0084 +S A$_strrchr$151 Def0075 +S A$_strrchr$142 Def006C +S A$_strrchr$133 Def0060 +S A$_strrchr$115 Def0045 +S A$_strrchr$106 Def003A +S _strrchr Def0000 +S A$_strrchr$170 Def0097 +S A$_strrchr$161 Def0086 +S A$_strrchr$152 Def0078 +S A$_strrchr$143 Def006D +S A$_strrchr$134 Def0061 +S A$_strrchr$116 Def0047 +S A$_strrchr$107 Def003B +S A$_strrchr$162 Def0088 +S A$_strrchr$153 Def0079 +S A$_strrchr$144 Def006E +S A$_strrchr$135 Def0062 +S A$_strrchr$126 Def0054 +S A$_strrchr$117 Def004A +S A$_strrchr$108 Def003C +S A$_strrchr$208 Def00BD +S A$_strrchr$190 Def00AC +S A$_strrchr$172 Def0099 +S A$_strrchr$163 Def008A +S A$_strrchr$154 Def007C +S A$_strrchr$145 Def006F +S A$_strrchr$136 Def0063 +S A$_strrchr$127 Def0057 +S A$_strrchr$118 Def004B +S A$_strrchr$109 Def003D +S A$_strrchr$182 Def00A2 +S A$_strrchr$164 Def008C +S A$_strrchr$155 Def007D +S A$_strrchr$146 Def0070 +S A$_strrchr$137 Def0065 +S A$_strrchr$128 Def0058 +S A$_strrchr$119 Def004D +S A$_strrchr$183 Def00A4 +S A$_strrchr$174 Def009A +S A$_strrchr$165 Def008E +S A$_strrchr$147 Def0071 +S A$_strrchr$138 Def0066 +S A$_strrchr$184 Def00A6 +S A$_strrchr$175 Def009C +S A$_strrchr$157 Def0080 +S A$_strrchr$148 Def0072 +S A$_strrchr$139 Def0067 +S A$_strrchr$185 Def00A8 +S A$_strrchr$176 Def009E +S A$_strrchr$167 Def0091 +S A$_strrchr$149 Def0073 +S A$_strrchr$195 Def00AF +S A$_strrchr$168 Def0092 +S A$_strrchr$159 Def0082 +S A$_strrchr$196 Def00B1 +S A$_strrchr$187 Def00AB +S A$_strrchr$178 Def00A0 +S A$_strrchr$169 Def0095 +S A$_strrchr$197 Def00B3 +S A$_strrchr$199 Def00B5 +S XG$strrchr$0$0 Def00BD +S C$_strrchr.c$44$1$1 Def00BD +S A$_strrchr$70 Def0006 +S A$_strrchr$80 Def0014 +S A$_strrchr$71 Def0009 +S A$_strrchr$90 Def001F +S A$_strrchr$81 Def0017 +S A$_strrchr$72 Def000B +S A$_strrchr$91 Def0021 +S A$_strrchr$82 Def0018 +S A$_strrchr$73 Def000C +S A$_strrchr$92 Def0023 +S A$_strrchr$83 Def0019 +S A$_strrchr$74 Def000E +S G$strrchr$0$0 Def0000 +S A$_strrchr$84 Def001A +S A$_strrchr$75 Def000F +S A$_strrchr$94 Def0025 +S A$_strrchr$85 Def001B +S A$_strrchr$76 Def0010 +S A$_strrchr$67 Def0000 +S A$_strrchr$95 Def0027 +S A$_strrchr$86 Def001C +S A$_strrchr$77 Def0012 +S A$_strrchr$68 Def0002 +S A$_strrchr$96 Def0029 +S A$_strrchr$87 Def001D +S A$_strrchr$78 Def0013 +S A$_strrchr$69 Def0004 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 01 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 01 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 8A 05 8B 06 8C 07 +R 00 00 00 07 +T 00 25 +R 00 00 00 07 +T 00 25 C0 02 C0 03 C0 04 8D 00 8E 01 8F 02 0D BD +R 00 00 00 07 +T 00 33 00 01 0E +R 00 00 00 07 +T 00 36 +R 00 00 00 07 +T 00 36 90 00 01 ED F0 A3 EE F0 A3 EF F0 88 82 89 +R 00 00 00 07 00 03 00 05 +T 00 44 83 8A F0 12 00 00 F8 D0 04 D0 03 D0 02 E8 +R 00 00 00 07 02 06 00 00 +T 00 52 70 D1 +R 00 00 00 07 +T 00 54 +R 00 00 00 07 +T 00 54 90 00 00 E0 F5 00 00 +R 00 00 00 07 00 03 00 05 29 07 00 01 +T 00 5A +R 00 00 00 07 +T 00 5A 90 00 01 E0 24 FF FE A3 E0 34 FF FF A3 E0 +R 00 00 00 07 00 03 00 05 +T 00 68 F8 90 00 01 EE F0 A3 EF F0 A3 E8 F0 EE B5 +R 00 00 00 07 00 04 00 05 +T 00 76 02 0A EF B5 03 06 E8 B5 04 02 80 20 +R 00 00 00 07 +T 00 82 +R 00 00 00 07 +T 00 82 C0 02 C0 03 C0 04 8E 82 8F 83 88 F0 12 +R 00 00 00 07 +T 00 8F 00 00 FA B5 00 00 04 74 01 80 01 +R 00 00 00 07 02 02 00 00 29 06 00 01 +T 00 99 +R 00 00 00 07 +T 00 99 E4 +R 00 00 00 07 +T 00 9A +R 00 00 00 07 +T 00 9A D0 04 D0 03 D0 02 60 B8 +R 00 00 00 07 +T 00 A2 +R 00 00 00 07 +T 00 A2 +R 00 00 00 07 +T 00 A2 8E 82 8F 83 88 F0 12 00 00 FD B5 00 00 08 +R 00 00 00 07 02 09 00 00 29 0D 00 01 +T 00 AF +R 00 00 00 07 +T 00 AF +R 00 00 00 07 +T 00 AF 8E 82 8F 83 88 F0 80 06 +R 00 00 00 07 +T 00 B7 +R 00 00 00 07 +T 00 B7 90 00 00 75 F0 00 +R 00 00 00 07 +T 00 BD +R 00 00 00 07 +T 00 BD 22 +R 00 00 00 07 diff --git a/device/lib/large/_strspn.asm b/device/lib/large/_strspn.asm new file mode 100644 index 00000000..fa733153 --- /dev/null +++ b/device/lib/large/_strspn.asm @@ -0,0 +1,174 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + +;-------------------------------------------------------- + .module _strspn +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strspn_PARM_2 + .globl _strspn +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strspn_sloc0_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strspn_PARM_2: + .ds 0x0003 +_strspn_string_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strspn$0$0 ==. +; _strspn.c 27 +; ----------------------------------------- +; function strspn +; ----------------------------------------- +_strspn: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strspn.c 43 + push b + push dph + push dpl + mov dptr,#_strspn_string_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strspn.c 35 + mov dptr,#_strspn_PARM_2 + movx a,@dptr + mov _strspn_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strspn_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strspn_sloc0_1_0 + 2),a + mov r5,#0x00 + mov r6,#0x00 + mov dptr,#_strspn_string_1_1 + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a +00104$: + mov dpl,r7 + mov dph,r0 + mov b,r1 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00112$: +; _strspn.c 36 + mov dptr,#_strchr_PARM_2 + mov a,r2 + movx @dptr,a + push ar5 + push ar6 + push ar7 + push ar0 + push ar1 + mov dpl,_strspn_sloc0_1_0 + mov dph,(_strspn_sloc0_1_0 + 1) + mov b,(_strspn_sloc0_1_0 + 2) + lcall _strchr + mov r2,dpl + mov r3,dph + mov r4,b + pop ar1 + pop ar0 + pop ar7 + pop ar6 + pop ar5 + mov a,r2 + orl a,r3 + orl a,r4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: +; _strspn.c 37 + inc r5 + cjne r5,#0x00,00114$ + inc r6 +00114$: +; _strspn.c 40 + inc r7 + cjne r7,#0x00,00115$ + inc r0 +00115$: + mov dptr,#_strspn_string_1_1 + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + ljmp 00104$ +00106$: +; _strspn.c 43 + mov dptr,#_strspn_string_1_1 + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + mov dpl,r5 + mov dph,r6 +00107$: + C$_strspn.c$44$1$1 ==. + XG$strspn$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strspn.cdb b/device/lib/large/_strspn.cdb new file mode 100644 index 00000000..81839f77 --- /dev/null +++ b/device/lib/large/_strspn.cdb @@ -0,0 +1,2 @@ +M:_strspn +F:G$strspn$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strspn.rel b/device/lib/large/_strspn.rel new file mode 100644 index 00000000..d4c3f224 --- /dev/null +++ b/device/lib/large/_strspn.rel @@ -0,0 +1,168 @@ +;!FILE _strspn.asm +XH +H 8 areas 62 global symbols +M _strspn +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 3 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 6 flags 40 +S _strspn_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size 95 flags 20 +S A$_strspn$101 Def0031 +S A$_strspn$120 Def004F +S A$_strspn$111 Def003D +S A$_strspn$102 Def0033 +S A$_strspn$130 Def0066 +S A$_strspn$121 Def0052 +S A$_strspn$112 Def0040 +S A$_strspn$103 Def0035 +S A$_strspn$140 Def0071 +S A$_strspn$131 Def0068 +S A$_strspn$122 Def0055 +S A$_strspn$113 Def0041 +S A$_strspn$104 Def0037 +S A$_strspn$150 Def007C +S A$_strspn$132 Def0069 +S A$_strspn$123 Def0058 +S A$_strspn$114 Def0042 +S A$_strspn$160 Def0088 +S A$_strspn$151 Def007D +S A$_strspn$133 Def006A +S A$_strspn$124 Def005A +S A$_strspn$115 Def0044 +S A$_strspn$106 Def003A +S _strspn Def0000 +S A$_strspn$161 Def0089 +S A$_strspn$152 Def007E +S A$_strspn$143 Def0072 +S A$_strspn$125 Def005C +S A$_strspn$116 Def0046 +S A$_strspn$162 Def008A +S A$_strspn$153 Def007F +S A$_strspn$144 Def0073 +S A$_strspn$135 Def006B +S A$_strspn$126 Def005E +S A$_strspn$117 Def0048 +S A$_strspn$108 Def003B +S A$_strspn$163 Def008B +S A$_strspn$154 Def0080 +S A$_strspn$145 Def0076 +S A$_strspn$127 Def0060 +S A$_strspn$118 Def004A +S A$_strspn$173 Def0094 +S A$_strspn$164 Def008C +S A$_strspn$155 Def0081 +S A$_strspn$128 Def0062 +S A$_strspn$119 Def004C +S A$_strspn$165 Def008D +S A$_strspn$156 Def0082 +S A$_strspn$147 Def0077 +S A$_strspn$138 Def006D +S A$_strspn$129 Def0064 +S A$_strspn$166 Def008E +S A$_strspn$148 Def007A +S A$_strspn$139 Def006E +S A$_strspn$167 Def008F +S A$_strspn$149 Def007B +S A$_strspn$168 Def0090 +S A$_strspn$159 Def0085 +S A$_strspn$169 Def0092 +S XG$strspn$0$0 Def0094 +S C$_strspn.c$44$1$1 Def0094 +S A$_strspn$70 Def0006 +S A$_strspn$80 Def0014 +S A$_strspn$71 Def0009 +S A$_strspn$90 Def0024 +S A$_strspn$81 Def0017 +S A$_strspn$72 Def000B +S A$_strspn$91 Def0026 +S A$_strspn$82 Def0018 +S A$_strspn$73 Def000C +S A$_strspn$92 Def0029 +S A$_strspn$83 Def001A +S A$_strspn$74 Def000E +S G$strspn$0$0 Def0000 +S A$_strspn$93 Def002A +S A$_strspn$84 Def001B +S A$_strspn$75 Def000F +S A$_strspn$94 Def002B +S A$_strspn$85 Def001C +S A$_strspn$76 Def0010 +S A$_strspn$67 Def0000 +S A$_strspn$95 Def002C +S A$_strspn$86 Def001E +S A$_strspn$77 Def0012 +S A$_strspn$68 Def0002 +S A$_strspn$96 Def002D +S A$_strspn$87 Def001F +S A$_strspn$78 Def0013 +S A$_strspn$69 Def0004 +S A$_strspn$97 Def002E +S A$_strspn$88 Def0020 +S A$_strspn$98 Def002F +S A$_strspn$89 Def0022 +S A$_strspn$99 Def0030 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 00 E0 F5 00 00 A3 +R 00 00 00 07 00 09 00 05 29 0D 00 01 +T 00 1B E0 F5 00 01 A3 E0 F5 00 02 7D 00 7E 00 90 +R 00 00 00 07 29 04 00 01 29 09 00 01 +T 00 27 00 03 E0 FF A3 E0 F8 A3 E0 F9 +R 00 00 00 07 00 02 00 05 +T 00 31 +R 00 00 00 07 +T 00 31 8F 82 88 83 89 F0 12 00 00 FA 60 48 +R 00 00 00 07 02 09 00 02 +T 00 3D +R 00 00 00 07 +T 00 3D 90 00 00 EA F0 C0 05 C0 06 C0 07 C0 00 C0 +R 00 00 00 07 02 03 00 00 +T 00 4B 01 85 00 00 82 85 00 01 83 85 00 02 F0 12 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 00 56 00 00 AA 82 AB 83 AC F0 D0 01 D0 00 D0 07 +R 00 00 00 07 02 02 00 01 +T 00 64 D0 06 D0 05 EA 4B 4C 60 18 +R 00 00 00 07 +T 00 6D +R 00 00 00 07 +T 00 6D 0D BD 00 01 0E +R 00 00 00 07 +T 00 72 +R 00 00 00 07 +T 00 72 0F BF 00 01 08 +R 00 00 00 07 +T 00 77 +R 00 00 00 07 +T 00 77 90 00 03 EF F0 A3 E8 F0 A3 E9 F0 02 00 31 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 00 85 +R 00 00 00 07 +T 00 85 90 00 03 EF F0 A3 E8 F0 A3 E9 F0 8D 82 8E +R 00 00 00 07 00 03 00 05 +T 00 93 83 +R 00 00 00 07 +T 00 94 +R 00 00 00 07 +T 00 94 22 +R 00 00 00 07 diff --git a/device/lib/large/_strstr.asm b/device/lib/large/_strstr.asm new file mode 100644 index 00000000..86ed41e5 --- /dev/null +++ b/device/lib/large/_strstr.asm @@ -0,0 +1,233 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + +;-------------------------------------------------------- + .module _strstr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strstr_PARM_2 + .globl _strstr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strstr_sloc0_1_0: + .ds 0x0003 +_strstr_sloc1_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strstr_PARM_2: + .ds 0x0003 +_strstr_str1_1_1: + .ds 0x0003 +_strstr_cp_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strstr$0$0 ==. +; _strstr.c 27 +; ----------------------------------------- +; function strstr +; ----------------------------------------- +_strstr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strstr.c 0 + push b + push dph + push dpl + mov dptr,#_strstr_str1_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strstr.c 32 + mov dptr,#_strstr_str1_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#_strstr_cp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; _strstr.c 36 + mov dptr,#_strstr_PARM_2 + movx a,@dptr + mov _strstr_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_strstr_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_strstr_sloc0_1_0 + 2),a + mov dpl,_strstr_sloc0_1_0 + mov dph,(_strstr_sloc0_1_0 + 1) + mov b,(_strstr_sloc0_1_0 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00122$ +00123$: +; _strstr.c 37 + mov dpl,r2 + mov dph,r3 + mov b,r4 + ljmp 00113$ +; _strstr.c 39 +00122$: +00110$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a + jnz 00124$ + ljmp 00112$ +00124$: +; _strstr.c 44 + mov _strstr_sloc1_1_0,r2 + mov (_strstr_sloc1_1_0 + 1),r3 + mov (_strstr_sloc1_1_0 + 2),r4 + mov r6,_strstr_sloc0_1_0 + mov r7,(_strstr_sloc0_1_0 + 1) + mov r5,(_strstr_sloc0_1_0 + 2) +00105$: + mov dpl,_strstr_sloc1_1_0 + mov dph,(_strstr_sloc1_1_0 + 1) + mov b,(_strstr_sloc1_1_0 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00125$: + mov dpl,r6 + mov dph,r7 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r1,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00126$: + clr c + mov a,r0 + subb a,r1 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00107$ +00127$: +; _strstr.c 45 + inc _strstr_sloc1_1_0 + clr a + cjne a,_strstr_sloc1_1_0,00128$ + inc (_strstr_sloc1_1_0 + 1) +00128$: + inc r6 + cjne r6,#0x00,00129$ + inc r7 +00129$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _strstr.c 47 + mov dpl,r6 + mov dph,r7 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00109$ +00130$: +; _strstr.c 48 + mov dptr,#_strstr_cp_1_1 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov dpl,r6 + mov dph,r0 + mov b,r1 +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00109$: +; _strstr.c 50 + inc r2 + cjne r2,#0x00,00131$ + inc r3 +00131$: + mov dptr,#_strstr_cp_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + ljmp 00110$ +00112$: +; _strstr.c 53 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00113$: + C$_strstr.c$54$1$1 ==. + XG$strstr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strstr.cdb b/device/lib/large/_strstr.cdb new file mode 100644 index 00000000..f68b0265 --- /dev/null +++ b/device/lib/large/_strstr.cdb @@ -0,0 +1,2 @@ +M:_strstr +F:G$strstr$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strstr.rel b/device/lib/large/_strstr.rel new file mode 100644 index 00000000..45e12d96 --- /dev/null +++ b/device/lib/large/_strstr.rel @@ -0,0 +1,243 @@ +;!FILE _strstr.asm +XH +H 8 areas 7F global symbols +M _strstr +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 9 flags 40 +S _strstr_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size D3 flags 20 +S A$_strstr$100 Def0028 +S A$_strstr$200 Def00AE +S A$_strstr$110 Def0035 +S A$_strstr$101 Def0029 +S A$_strstr$210 Def00B9 +S A$_strstr$201 Def00AF +S A$_strstr$111 Def0036 +S A$_strstr$220 Def00C6 +S A$_strstr$211 Def00BA +S A$_strstr$202 Def00B0 +S A$_strstr$130 Def0052 +S A$_strstr$112 Def0038 +S A$_strstr$103 Def002A +S A$_strstr$221 Def00C7 +S A$_strstr$212 Def00BD +S A$_strstr$203 Def00B1 +S A$_strstr$140 Def0061 +S A$_strstr$131 Def0054 +S A$_strstr$122 Def0047 +S A$_strstr$113 Def003B +S A$_strstr$104 Def002D +S A$_strstr$222 Def00C8 +S A$_strstr$204 Def00B3 +S A$_strstr$141 Def0063 +S A$_strstr$132 Def0056 +S A$_strstr$123 Def0049 +S A$_strstr$114 Def003E +S A$_strstr$105 Def002E +S A$_strstr$232 Def00D2 +S A$_strstr$223 Def00C9 +S A$_strstr$214 Def00BE +S A$_strstr$205 Def00B5 +S A$_strstr$160 Def0083 +S A$_strstr$151 Def0077 +S A$_strstr$142 Def0065 +S A$_strstr$124 Def004B +S A$_strstr$115 Def0041 +S A$_strstr$106 Def0030 +S _strstr Def0000 +S A$_strstr$215 Def00C1 +S A$_strstr$143 Def0067 +S A$_strstr$134 Def0059 +S A$_strstr$125 Def004D +S A$_strstr$107 Def0031 +S A$_strstr$216 Def00C2 +S A$_strstr$207 Def00B7 +S A$_strstr$171 Def008B +S A$_strstr$162 Def0084 +S A$_strstr$153 Def0078 +S A$_strstr$144 Def0069 +S A$_strstr$135 Def005A +S A$_strstr$117 Def0044 +S A$_strstr$108 Def0032 +S A$_strstr$217 Def00C3 +S A$_strstr$181 Def0098 +S A$_strstr$172 Def008D +S A$_strstr$136 Def005C +S A$_strstr$109 Def0034 +S A$_strstr$227 Def00CC +S A$_strstr$218 Def00C4 +S A$_strstr$191 Def00A4 +S A$_strstr$173 Def008E +S A$_strstr$164 Def0086 +S A$_strstr$155 Def007A +S A$_strstr$146 Def006B +S A$_strstr$119 Def0045 +S A$_strstr$228 Def00CF +S A$_strstr$219 Def00C5 +S A$_strstr$174 Def0091 +S A$_strstr$165 Def0087 +S A$_strstr$156 Def007C +S A$_strstr$147 Def006E +S A$_strstr$129 Def0050 +S A$_strstr$184 Def009A +S A$_strstr$166 Def0088 +S A$_strstr$157 Def007E +S A$_strstr$148 Def0071 +S A$_strstr$139 Def005F +S A$_strstr$194 Def00A6 +S A$_strstr$185 Def009C +S A$_strstr$176 Def0093 +S A$_strstr$158 Def0080 +S A$_strstr$149 Def0074 +S A$_strstr$195 Def00A9 +S A$_strstr$186 Def009E +S A$_strstr$177 Def0094 +S A$_strstr$168 Def0089 +S A$_strstr$196 Def00AA +S A$_strstr$187 Def00A0 +S A$_strstr$178 Def0097 +S A$_strstr$197 Def00AB +S A$_strstr$198 Def00AC +S A$_strstr$189 Def00A3 +S A$_strstr$199 Def00AD +S XG$strstr$0$0 Def00D2 +S C$_strstr.c$54$1$1 Def00D2 +S A$_strstr$80 Def0010 +S A$_strstr$71 Def0000 +S A$_strstr$90 Def001C +S A$_strstr$81 Def0012 +S A$_strstr$72 Def0002 +S A$_strstr$91 Def001D +S A$_strstr$82 Def0013 +S A$_strstr$73 Def0004 +S A$_strstr$92 Def001E +S A$_strstr$74 Def0006 +S G$strstr$0$0 Def0000 +S A$_strstr$93 Def001F +S A$_strstr$84 Def0014 +S A$_strstr$75 Def0009 +S A$_strstr$94 Def0022 +S A$_strstr$85 Def0017 +S A$_strstr$76 Def000B +S A$_strstr$95 Def0023 +S A$_strstr$86 Def0018 +S A$_strstr$77 Def000C +S A$_strstr$96 Def0024 +S A$_strstr$87 Def0019 +S A$_strstr$78 Def000E +S A$_strstr$97 Def0025 +S A$_strstr$88 Def001A +S A$_strstr$79 Def000F +S A$_strstr$98 Def0026 +S A$_strstr$89 Def001B +S A$_strstr$99 Def0027 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 90 00 06 EA F0 A3 EB F0 A3 EC F0 +R 00 00 00 07 00 06 00 05 +T 00 2A 90 00 00 E0 F5 00 00 A3 E0 F5 00 01 A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 00 36 F5 00 02 85 00 00 82 85 00 01 83 85 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 0A 00 01 +T 00 3F 00 02 F0 12 00 00 F8 70 09 +R 00 00 00 07 29 02 00 01 02 06 00 00 +T 00 47 +R 00 00 00 07 +T 00 47 8A 82 8B 83 8C F0 02 00 D2 +R 00 00 00 07 00 09 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 8A 82 8B 83 8C F0 12 00 00 F8 70 03 02 +R 00 00 00 07 02 09 00 00 +T 00 5D 00 CC +R 00 00 00 07 00 02 00 07 +T 00 5F +R 00 00 00 07 +T 00 5F 8A 00 03 8B 00 04 8C 00 05 AE +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 66 00 00 AF 00 01 AD 00 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 6B +R 00 00 00 07 +T 00 6B 85 00 03 82 85 00 04 83 85 00 05 F0 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 75 00 00 F8 60 20 +R 00 00 00 07 02 02 00 00 +T 00 7A +R 00 00 00 07 +T 00 7A 8E 82 8F 83 8D F0 12 00 00 F9 60 14 +R 00 00 00 07 02 09 00 00 +T 00 86 +R 00 00 00 07 +T 00 86 C3 E8 99 70 0F +R 00 00 00 07 +T 00 8B +R 00 00 00 07 +T 00 8B 05 00 03 E4 B5 00 03 02 05 00 04 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 93 +R 00 00 00 07 +T 00 93 0E BE 00 01 0F +R 00 00 00 07 +T 00 98 +R 00 00 00 07 +T 00 98 80 D1 +R 00 00 00 07 +T 00 9A +R 00 00 00 07 +T 00 9A 8E 82 8F 83 8D F0 12 00 00 FE 70 13 +R 00 00 00 07 02 09 00 00 +T 00 A6 +R 00 00 00 07 +T 00 A6 90 00 06 E0 FE A3 E0 F8 A3 E0 F9 8E 82 88 +R 00 00 00 07 00 03 00 05 +T 00 B4 83 89 F0 80 19 +R 00 00 00 07 +T 00 B9 +R 00 00 00 07 +T 00 B9 0A BA 00 01 0B +R 00 00 00 07 +T 00 BE +R 00 00 00 07 +T 00 BE 90 00 06 EA F0 A3 EB F0 A3 EC F0 02 00 50 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 00 CC +R 00 00 00 07 +T 00 CC 90 00 00 75 F0 00 +R 00 00 00 07 +T 00 D2 +R 00 00 00 07 +T 00 D2 22 +R 00 00 00 07 diff --git a/device/lib/large/_strtok.asm b/device/lib/large/_strtok.asm new file mode 100644 index 00000000..4bf0dc2a --- /dev/null +++ b/device/lib/large/_strtok.asm @@ -0,0 +1,223 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + +;-------------------------------------------------------- + .module _strtok +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strtok_PARM_2 + .globl _strtok +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_strtok_PARM_2: + .ds 0x0003 +_strtok_str_1_1: + .ds 0x0003 +_strtok_s_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strtok$0$0 ==. +; _strtok.c 32 +; ----------------------------------------- +; function strtok +; ----------------------------------------- +_strtok: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strtok.c 0 + push b + push dph + push dpl + mov dptr,#_strtok_str_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _strtok.c 40 + mov dptr,#_strtok_str_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov a,r2 + orl a,r3 + orl a,r4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _strtok.c 41 + mov dptr,#_strtok_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +00102$: +; _strtok.c 43 + mov dptr,#_strtok_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +; _strtok.c 45 +00105$: + mov dptr,#_strtok_s_1_1 + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a + jnz 00115$ + ljmp 00107$ +00115$: +; _strtok.c 46 + push ar2 + push ar3 + push ar4 + mov dptr,#_strtok_PARM_2 + movx a,@dptr + mov r1,a + inc dptr + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov dptr,#_strchr_PARM_2 + mov a,r0 + movx @dptr,a + push ar5 + push ar6 + push ar7 + mov dpl,r1 + mov dph,r2 + mov b,r3 + lcall _strchr + mov r2,dpl + mov r3,dph + mov r4,b + pop ar7 + pop ar6 + pop ar5 + mov a,r2 + orl a,r3 + orl a,r4 + pop ar4 + pop ar3 + pop ar2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00116$: +; _strtok.c 47 + mov dptr,#_strtok_s_1_1 + mov a,#0x01 + add a,r5 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + mov dpl,r5 + mov dph,r6 + mov b,r7 +; Peephole 180 changed mov to clr + clr a + lcall __gptrput +; _strtok.c 48 + mov dpl,r2 + mov dph,r3 + mov b,r4 +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00104$: +; _strtok.c 50 + mov dptr,#_strtok_s_1_1 + mov a,#0x01 + add a,r5 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r6 + inc dptr + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + ljmp 00105$ +00107$: +; _strtok.c 52 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00108$: + C$_strtok.c$53$1$1 ==. + XG$strtok$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_strtok.cdb b/device/lib/large/_strtok.cdb new file mode 100644 index 00000000..5a98130b --- /dev/null +++ b/device/lib/large/_strtok.cdb @@ -0,0 +1,2 @@ +M:_strtok +F:G$strtok$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_strtok.rel b/device/lib/large/_strtok.rel new file mode 100644 index 00000000..81fbbb28 --- /dev/null +++ b/device/lib/large/_strtok.rel @@ -0,0 +1,218 @@ +;!FILE _strtok.asm +XH +H 8 areas 8A global symbols +M _strtok +S __gptrput Ref0000 +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 9 flags 40 +S _strtok_PARM_2 Def0000 +A GSINIT size 0 flags 20 +A CSEG size C8 flags 20 +S A$_strtok$100 Def002A +S A$_strtok$110 Def0034 +S A$_strtok$101 Def002B +S A$_strtok$210 Def00BB +S A$_strtok$201 Def00B0 +S A$_strtok$120 Def003E +S A$_strtok$111 Def0035 +S A$_strtok$102 Def002C +S A$_strtok$211 Def00BC +S A$_strtok$202 Def00B3 +S A$_strtok$130 Def004B +S A$_strtok$121 Def003F +S A$_strtok$112 Def0036 +S A$_strtok$103 Def002D +S A$_strtok$212 Def00BD +S A$_strtok$203 Def00B5 +S A$_strtok$140 Def005A +S A$_strtok$122 Def0040 +S A$_strtok$113 Def0037 +S A$_strtok$104 Def002E +S A$_strtok$222 Def00C7 +S A$_strtok$213 Def00BE +S A$_strtok$204 Def00B6 +S A$_strtok$150 Def0068 +S A$_strtok$141 Def005D +S A$_strtok$132 Def004E +S A$_strtok$123 Def0041 +S A$_strtok$114 Def0038 +S A$_strtok$160 Def007B +S A$_strtok$151 Def0069 +S A$_strtok$142 Def005E +S A$_strtok$133 Def004F +S A$_strtok$124 Def0042 +S A$_strtok$115 Def0039 +S _strtok Def0000 +S A$_strtok$206 Def00B7 +S A$_strtok$170 Def008C +S A$_strtok$161 Def007D +S A$_strtok$152 Def006A +S A$_strtok$143 Def005F +S A$_strtok$134 Def0051 +S A$_strtok$125 Def0043 +S A$_strtok$107 Def002F +S A$_strtok$207 Def00B8 +S A$_strtok$180 Def0097 +S A$_strtok$162 Def007F +S A$_strtok$153 Def006C +S A$_strtok$144 Def0060 +S A$_strtok$126 Def0044 +S A$_strtok$108 Def0032 +S A$_strtok$217 Def00C1 +S A$_strtok$208 Def00B9 +S A$_strtok$181 Def0098 +S A$_strtok$172 Def008E +S A$_strtok$163 Def0081 +S A$_strtok$154 Def006E +S A$_strtok$145 Def0061 +S A$_strtok$127 Def0045 +S A$_strtok$118 Def003A +S A$_strtok$109 Def0033 +S A$_strtok$218 Def00C4 +S A$_strtok$209 Def00BA +S A$_strtok$191 Def00A4 +S A$_strtok$182 Def0099 +S A$_strtok$164 Def0083 +S A$_strtok$155 Def0070 +S A$_strtok$146 Def0062 +S A$_strtok$137 Def0054 +S A$_strtok$128 Def0047 +S A$_strtok$119 Def003D +S A$_strtok$192 Def00A5 +S A$_strtok$183 Def009A +S A$_strtok$165 Def0085 +S A$_strtok$156 Def0072 +S A$_strtok$147 Def0063 +S A$_strtok$138 Def0056 +S A$_strtok$129 Def0049 +S A$_strtok$184 Def009B +S A$_strtok$175 Def0090 +S A$_strtok$166 Def0086 +S A$_strtok$157 Def0074 +S A$_strtok$148 Def0064 +S A$_strtok$139 Def0058 +S A$_strtok$194 Def00A8 +S A$_strtok$185 Def009C +S A$_strtok$176 Def0093 +S A$_strtok$167 Def0087 +S A$_strtok$158 Def0076 +S A$_strtok$149 Def0065 +S A$_strtok$195 Def00AA +S A$_strtok$186 Def009D +S A$_strtok$177 Def0095 +S A$_strtok$168 Def0088 +S A$_strtok$159 Def0079 +S A$_strtok$196 Def00AC +S A$_strtok$187 Def009E +S A$_strtok$178 Def0096 +S A$_strtok$169 Def008A +S A$_strtok$188 Def00A0 +S A$_strtok$198 Def00AE +S A$_strtok$189 Def00A2 +S XG$strtok$0$0 Def00C7 +S C$_strtok.c$53$1$1 Def00C7 +S A$_strtok$70 Def0006 +S A$_strtok$80 Def0014 +S A$_strtok$71 Def0009 +S A$_strtok$90 Def0020 +S A$_strtok$81 Def0017 +S A$_strtok$72 Def000B +S A$_strtok$91 Def0021 +S A$_strtok$82 Def0018 +S A$_strtok$73 Def000C +S A$_strtok$83 Def0019 +S A$_strtok$74 Def000E +S G$strtok$0$0 Def0000 +S A$_strtok$93 Def0022 +S A$_strtok$84 Def001A +S A$_strtok$75 Def000F +S A$_strtok$85 Def001B +S A$_strtok$76 Def0010 +S A$_strtok$67 Def0000 +S A$_strtok$86 Def001C +S A$_strtok$77 Def0012 +S A$_strtok$68 Def0002 +S A$_strtok$96 Def0024 +S A$_strtok$87 Def001D +S A$_strtok$78 Def0013 +S A$_strtok$69 Def0004 +S A$_strtok$97 Def0027 +S A$_strtok$88 Def001E +S A$_strtok$98 Def0028 +S A$_strtok$89 Def001F +S A$_strtok$99 Def0029 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 03 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 03 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC EA 4B 4C 60 0B +R 00 00 00 07 +T 00 24 +R 00 00 00 07 +T 00 24 90 00 06 EA F0 A3 EB F0 A3 EC F0 +R 00 00 00 07 00 03 00 05 +T 00 2F +R 00 00 00 07 +T 00 2F 90 00 06 E0 FA A3 E0 FB A3 E0 FC +R 00 00 00 07 00 03 00 05 +T 00 3A +R 00 00 00 07 +T 00 3A 90 00 06 E0 FD A3 E0 FE A3 E0 FF 8D 82 8E +R 00 00 00 07 00 03 00 05 +T 00 48 83 8F F0 12 00 00 F8 70 03 02 00 C1 +R 00 00 00 07 02 06 00 03 00 0C 00 07 +T 00 54 +R 00 00 00 07 +T 00 54 C0 02 C0 03 C0 04 90 00 00 E0 F9 A3 E0 FA +R 00 00 00 07 00 09 00 05 +T 00 62 A3 E0 FB 90 00 00 E8 F0 C0 05 C0 06 C0 07 +R 00 00 00 07 02 06 00 01 +T 00 70 89 82 8A 83 8B F0 12 00 00 AA 82 AB 83 AC +R 00 00 00 07 02 09 00 02 +T 00 7E F0 D0 07 D0 06 D0 05 EA 4B 4C D0 04 D0 03 +R 00 00 00 07 +T 00 8C D0 02 60 20 +R 00 00 00 07 +T 00 90 +R 00 00 00 07 +T 00 90 90 00 06 74 01 2D F0 E4 3E A3 F0 A3 EF F0 +R 00 00 00 07 00 03 00 05 +T 00 9E 8D 82 8E 83 8F F0 E4 12 00 00 8A 82 8B 83 +R 00 00 00 07 02 0A 00 00 +T 00 AC 8C F0 80 17 +R 00 00 00 07 +T 00 B0 +R 00 00 00 07 +T 00 B0 90 00 06 74 01 2D F0 E4 3E A3 F0 A3 EF F0 +R 00 00 00 07 00 03 00 05 +T 00 BE 02 00 3A +R 00 00 00 07 00 03 00 07 +T 00 C1 +R 00 00 00 07 +T 00 C1 90 00 00 75 F0 00 +R 00 00 00 07 +T 00 C7 +R 00 00 00 07 +T 00 C7 22 +R 00 00 00 07 diff --git a/device/lib/large/_uchar2fs.asm b/device/lib/large/_uchar2fs.asm new file mode 100644 index 00000000..0e0711db --- /dev/null +++ b/device/lib/large/_uchar2fs.asm @@ -0,0 +1,334 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:34 2000 + +;-------------------------------------------------------- + .module _uchar2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___uchar2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___uchar2fs_sloc0_1_0: + .ds 0x0002 +___uchar2fs_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___uchar2fs_a_1_1: + .ds 0x0001 +___uchar2fs_sign_1_1: + .ds 0x0004 +___uchar2fs_fl_1_1: + .ds 0x0004 +___uchar2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__uchar2fs$0$0 ==. +; _uchar2fs.c 80 +; ----------------------------------------- +; function __uchar2fs +; ----------------------------------------- +___uchar2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _uchar2fs.c 109 + push dpl + mov dptr,#___uchar2fs_a_1_1 + pop acc + movx @dptr,a +; _uchar2fs.c 82 + mov dptr,#___uchar2fs_sign_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _uchar2fs.c 85 + mov dptr,#___uchar2fs_a_1_1 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + rlc a + subb a,acc + mov r3,a + mov r4,a + mov r5,a + mov dptr,#___uchar2fs_a1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _uchar2fs.c 87 + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _uchar2fs.c 89 + mov dptr,#(___uchar2fs_fl_1_1) +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; _uchar2fs.c 90 + mov dptr,#(___uchar2fs_fl_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r6 + mov dph,r7 + mov b,r0 + ljmp 00108$ +00102$: +; _uchar2fs.c 93 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _uchar2fs.c 95 + mov dptr,#___uchar2fs_sign_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x80 + movx @dptr,a +; _uchar2fs.c 96 + mov dptr,#___uchar2fs_a1_1_1 + clr c + clr a + subb a,r2 + movx @dptr,a + clr a + subb a,r3 + inc dptr + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a +; _uchar2fs.c 99 +00113$: + clr a + mov (___uchar2fs_sloc0_1_0 + 1),a + mov ___uchar2fs_sloc0_1_0,#0x96 +00105$: + mov dptr,#___uchar2fs_a1_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r4 + subb a,#0x00 + mov a,r5 + subb a,#0x00 + mov a,r6 + subb a,#0x80 + mov a,r7 + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _uchar2fs.c 101 + mov a,r4 + add a,acc + mov r0,a + mov a,r5 + rlc a + mov r1,a + mov a,r6 + rlc a + mov r2,a + mov a,r7 + rlc a + mov r3,a + mov dptr,#___uchar2fs_a1_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _uchar2fs.c 102 + dec ___uchar2fs_sloc0_1_0 + mov a,#0xff + cjne a,___uchar2fs_sloc0_1_0,00117$ + dec (___uchar2fs_sloc0_1_0 + 1) +00117$: + ljmp 00105$ +00107$: +; _uchar2fs.c 105 + anl ar6,#0x7f +; _uchar2fs.c 107 + mov r2,___uchar2fs_sloc0_1_0 + mov r3,(___uchar2fs_sloc0_1_0 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___uchar2fs_sloc1_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___uchar2fs_sloc1_1_0 + 2) + rrc a + xch a,(___uchar2fs_sloc1_1_0 + 2) + rrc a + xch a,(___uchar2fs_sloc1_1_0 + 2) + mov (___uchar2fs_sloc1_1_0 + 3),a + mov (___uchar2fs_sloc1_1_0 + 1),#0x00 + mov ___uchar2fs_sloc1_1_0,#0x00 + mov dptr,#___uchar2fs_sign_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,___uchar2fs_sloc1_1_0 + orl ar2,a + mov a,(___uchar2fs_sloc1_1_0 + 1) + orl ar3,a + mov a,(___uchar2fs_sloc1_1_0 + 2) + orl ar0,a + mov a,(___uchar2fs_sloc1_1_0 + 3) + orl ar1,a + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov dptr,#(___uchar2fs_fl_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _uchar2fs.c 109 + mov dptr,#(___uchar2fs_fl_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00108$: + C$_uchar2fs.c$110$1$1 ==. + XG$__uchar2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_uchar2fs.cdb b/device/lib/large/_uchar2fs.cdb new file mode 100644 index 00000000..093722f2 --- /dev/null +++ b/device/lib/large/_uchar2fs.cdb @@ -0,0 +1,2 @@ +M:_uchar2fs +F:G$__uchar2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_uchar2fs.rel b/device/lib/large/_uchar2fs.rel new file mode 100644 index 00000000..96e2cdcb --- /dev/null +++ b/device/lib/large/_uchar2fs.rel @@ -0,0 +1,345 @@ +;!FILE _uchar2fs.asm +XH +H 8 areas E5 global symbols +M _uchar2fs +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size D flags 40 +A GSINIT size 0 flags 20 +A CSEG size 13C flags 20 +S A$_uchar2fs$316 Def012B +S A$_uchar2fs$307 Def0121 +S A$_uchar2fs$280 Def00F8 +S A$_uchar2fs$271 Def00E9 +S A$_uchar2fs$262 Def00DA +S A$_uchar2fs$244 Def00BF +S A$_uchar2fs$235 Def00B6 +S A$_uchar2fs$226 Def00AB +S A$_uchar2fs$217 Def00A2 +S A$_uchar2fs$208 Def0096 +S A$_uchar2fs$190 Def0082 +S A$_uchar2fs$181 Def0079 +S A$_uchar2fs$172 Def006F +S A$_uchar2fs$163 Def0066 +S A$_uchar2fs$154 Def005E +S A$_uchar2fs$145 Def0053 +S A$_uchar2fs$136 Def004A +S A$_uchar2fs$127 Def0042 +S A$_uchar2fs$109 Def0033 +S A$_uchar2fs$326 Def0134 +S A$_uchar2fs$317 Def012C +S A$_uchar2fs$308 Def0122 +S A$_uchar2fs$290 Def0107 +S A$_uchar2fs$281 Def00F9 +S A$_uchar2fs$272 Def00EC +S A$_uchar2fs$263 Def00DB +S A$_uchar2fs$245 Def00C0 +S A$_uchar2fs$236 Def00B7 +S A$_uchar2fs$227 Def00AC +S A$_uchar2fs$209 Def0097 +S A$_uchar2fs$182 Def007A +S A$_uchar2fs$164 Def0067 +S A$_uchar2fs$137 Def004B +S A$_uchar2fs$327 Def0135 +S A$_uchar2fs$318 Def012D +S A$_uchar2fs$309 Def0123 +S A$_uchar2fs$291 Def0109 +S A$_uchar2fs$282 Def00FA +S A$_uchar2fs$273 Def00EF +S A$_uchar2fs$264 Def00DD +S A$_uchar2fs$255 Def00CD +S A$_uchar2fs$237 Def00B8 +S A$_uchar2fs$228 Def00AD +S A$_uchar2fs$219 Def00A4 +S A$_uchar2fs$183 Def007B +S A$_uchar2fs$174 Def0070 +S A$_uchar2fs$165 Def0068 +S A$_uchar2fs$156 Def005F +S A$_uchar2fs$147 Def0054 +S A$_uchar2fs$138 Def004C +S A$_uchar2fs$328 Def0137 +S A$_uchar2fs$319 Def012E +S A$_uchar2fs$292 Def010B +S A$_uchar2fs$283 Def00FB +S A$_uchar2fs$274 Def00F2 +S A$_uchar2fs$265 Def00DF +S A$_uchar2fs$247 Def00C1 +S A$_uchar2fs$238 Def00B9 +S A$_uchar2fs$229 Def00AE +S A$_uchar2fs$193 Def0083 +S A$_uchar2fs$184 Def007C +S A$_uchar2fs$175 Def0073 +S A$_uchar2fs$166 Def0069 +S A$_uchar2fs$148 Def0055 +S A$_uchar2fs$139 Def004D +S A$_uchar2fs$329 Def0139 +S A$_uchar2fs$293 Def010D +S A$_uchar2fs$284 Def00FC +S A$_uchar2fs$275 Def00F3 +S A$_uchar2fs$266 Def00E1 +S A$_uchar2fs$257 Def00D0 +S A$_uchar2fs$248 Def00C3 +S A$_uchar2fs$239 Def00BA +S A$_uchar2fs$194 Def0084 +S A$_uchar2fs$185 Def007D +S A$_uchar2fs$176 Def0074 +S A$_uchar2fs$149 Def0057 +S A$_uchar2fs$294 Def010E +S A$_uchar2fs$285 Def00FD +S A$_uchar2fs$276 Def00F4 +S A$_uchar2fs$267 Def00E2 +S A$_uchar2fs$258 Def00D2 +S A$_uchar2fs$249 Def00C5 +S A$_uchar2fs$195 Def0086 +S A$_uchar2fs$186 Def007E +S A$_uchar2fs$177 Def0075 +S A$_uchar2fs$168 Def006A +S A$_uchar2fs$159 Def0062 +S A$_uchar2fs$295 Def0110 +S A$_uchar2fs$286 Def00FF +S A$_uchar2fs$277 Def00F5 +S A$_uchar2fs$268 Def00E4 +S A$_uchar2fs$259 Def00D4 +S A$_uchar2fs$187 Def007F +S A$_uchar2fs$178 Def0076 +S A$_uchar2fs$169 Def006B +S A$_uchar2fs$296 Def0111 +S A$_uchar2fs$287 Def0101 +S A$_uchar2fs$278 Def00F6 +S A$_uchar2fs$269 Def00E5 +S A$_uchar2fs$197 Def0089 +S A$_uchar2fs$188 Def0080 +S A$_uchar2fs$179 Def0077 +S XG$__uchar2fs$0$0 Def013B +S A$_uchar2fs$297 Def0113 +S A$_uchar2fs$288 Def0103 +S A$_uchar2fs$279 Def00F7 +S A$_uchar2fs$198 Def008C +S A$_uchar2fs$189 Def0081 +S A$_uchar2fs$298 Def0114 +S A$_uchar2fs$289 Def0105 +S A$_uchar2fs$199 Def008D +S A$_uchar2fs$299 Def0116 +S A$_uchar2fs$80 Def000D +S A$_uchar2fs$90 Def001C +S A$_uchar2fs$81 Def000E +S A$_uchar2fs$72 Def0000 +S G$__uchar2fs$0$0 Def0000 +S A$_uchar2fs$91 Def001F +S A$_uchar2fs$82 Def000F +S A$_uchar2fs$73 Def0002 +S A$_uchar2fs$83 Def0010 +S A$_uchar2fs$74 Def0005 +S A$_uchar2fs$93 Def0020 +S A$_uchar2fs$84 Def0013 +S A$_uchar2fs$75 Def0007 +S A$_uchar2fs$94 Def0021 +S A$_uchar2fs$85 Def0014 +S A$_uchar2fs$95 Def0022 +S A$_uchar2fs$86 Def0017 +S A$_uchar2fs$77 Def0008 +S A$_uchar2fs$96 Def0024 +S A$_uchar2fs$87 Def0018 +S A$_uchar2fs$78 Def000B +S A$_uchar2fs$97 Def0025 +S A$_uchar2fs$88 Def001B +S A$_uchar2fs$79 Def000C +S A$_uchar2fs$98 Def0026 +S A$_uchar2fs$99 Def0027 +S C$_uchar2fs.c$110$1$1 Def013B +S A$_uchar2fs$100 Def002A +S A$_uchar2fs$200 Def008E +S A$_uchar2fs$110 Def0034 +S A$_uchar2fs$101 Def002B +S A$_uchar2fs$300 Def0117 +S A$_uchar2fs$210 Def0098 +S A$_uchar2fs$201 Def008F +S A$_uchar2fs$120 Def003B +S A$_uchar2fs$102 Def002C +S A$_uchar2fs$310 Def0124 +S A$_uchar2fs$301 Def0119 +S A$_uchar2fs$211 Def0099 +S A$_uchar2fs$202 Def0090 +S A$_uchar2fs$130 Def0043 +S A$_uchar2fs$112 Def0035 +S A$_uchar2fs$103 Def002D +S A$_uchar2fs$320 Def012F +S A$_uchar2fs$311 Def0125 +S A$_uchar2fs$302 Def011C +S A$_uchar2fs$230 Def00AF +S A$_uchar2fs$212 Def009B +S A$_uchar2fs$203 Def0091 +S A$_uchar2fs$140 Def004E +S A$_uchar2fs$131 Def0044 +S A$_uchar2fs$113 Def0036 +S A$_uchar2fs$104 Def002E +S ___uchar2fs Def0000 +S A$_uchar2fs$321 Def0130 +S A$_uchar2fs$312 Def0126 +S A$_uchar2fs$303 Def011D +S A$_uchar2fs$240 Def00BB +S A$_uchar2fs$231 Def00B0 +S A$_uchar2fs$222 Def00A6 +S A$_uchar2fs$213 Def009C +S A$_uchar2fs$204 Def0092 +S A$_uchar2fs$150 Def0059 +S A$_uchar2fs$141 Def004F +S A$_uchar2fs$132 Def0045 +S A$_uchar2fs$123 Def003E +S A$_uchar2fs$114 Def0037 +S A$_uchar2fs$105 Def002F +S A$_uchar2fs$322 Def0131 +S A$_uchar2fs$304 Def011E +S A$_uchar2fs$250 Def00C8 +S A$_uchar2fs$241 Def00BC +S A$_uchar2fs$232 Def00B1 +S A$_uchar2fs$223 Def00A7 +S A$_uchar2fs$214 Def009E +S A$_uchar2fs$205 Def0093 +S A$_uchar2fs$151 Def005B +S A$_uchar2fs$142 Def0050 +S A$_uchar2fs$133 Def0046 +S A$_uchar2fs$124 Def003F +S A$_uchar2fs$115 Def0038 +S A$_uchar2fs$106 Def0030 +S A$_uchar2fs$323 Def0132 +S A$_uchar2fs$314 Def0127 +S A$_uchar2fs$305 Def011F +S A$_uchar2fs$260 Def00D6 +S A$_uchar2fs$242 Def00BD +S A$_uchar2fs$233 Def00B2 +S A$_uchar2fs$224 Def00A9 +S A$_uchar2fs$215 Def009F +S A$_uchar2fs$206 Def0094 +S A$_uchar2fs$170 Def006C +S A$_uchar2fs$143 Def0051 +S A$_uchar2fs$125 Def0040 +S A$_uchar2fs$107 Def0031 +S A$_uchar2fs$333 Def013B +S A$_uchar2fs$324 Def0133 +S A$_uchar2fs$315 Def012A +S A$_uchar2fs$306 Def0120 +S A$_uchar2fs$270 Def00E7 +S A$_uchar2fs$261 Def00D8 +S A$_uchar2fs$252 Def00CA +S A$_uchar2fs$243 Def00BE +S A$_uchar2fs$234 Def00B3 +S A$_uchar2fs$225 Def00AA +S A$_uchar2fs$216 Def00A1 +S A$_uchar2fs$207 Def0095 +S A$_uchar2fs$180 Def0078 +S A$_uchar2fs$171 Def006D +S A$_uchar2fs$162 Def0065 +S A$_uchar2fs$144 Def0052 +S A$_uchar2fs$135 Def0047 +S A$_uchar2fs$126 Def0041 +S A$_uchar2fs$117 Def0039 +S A$_uchar2fs$108 Def0032 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 82 90 00 00 D0 E0 F0 90 00 01 E4 A3 A3 +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 0E A3 F0 12 00 00 F0 12 00 00 F0 12 00 00 F0 +R 00 00 00 07 02 05 00 00 02 09 00 00 02 0D 00 00 +T 00 1C 90 00 00 E0 FA 33 95 E0 FB FC FD 90 00 09 +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 00 2A EA F0 A3 EB F0 A3 EC F0 A3 ED F0 EA 4B 4C +R 00 00 00 07 +T 00 38 4D 70 23 +R 00 00 00 07 +T 00 3B +R 00 00 00 07 +T 00 3B 90 00 05 E4 F0 A3 F0 A3 E4 F0 A3 F0 90 +R 00 00 00 07 00 03 00 05 +T 00 48 00 05 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 8E +R 00 00 00 07 00 02 00 05 +T 00 56 82 8F 83 88 F0 02 01 3B +R 00 00 00 07 00 08 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E ED 30 E7 21 +R 00 00 00 07 +T 00 62 +R 00 00 00 07 +T 00 62 90 00 01 E4 F0 A3 F0 A3 E4 F0 A3 74 80 F0 +R 00 00 00 07 00 03 00 05 +T 00 70 90 00 09 C3 E4 9A F0 E4 9B A3 F0 E4 9C A3 +R 00 00 00 07 00 03 00 05 +T 00 7E F0 E4 9D A3 F0 +R 00 00 00 07 +T 00 83 +R 00 00 00 07 +T 00 83 E4 F5 00 01 75 00 00 96 +R 00 00 00 07 29 04 00 01 29 07 00 01 +T 00 89 +R 00 00 00 07 +T 00 89 90 00 09 E0 FC A3 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 97 C3 EC 94 00 ED 94 00 EE 94 80 EF 94 00 50 +R 00 00 00 07 +T 00 A5 27 +R 00 00 00 07 +T 00 A6 +R 00 00 00 07 +T 00 A6 EC 25 E0 F8 ED 33 F9 EE 33 FA EF 33 FB 90 +R 00 00 00 07 +T 00 B4 00 09 E8 F0 A3 E9 F0 A3 EA F0 A3 EB F0 15 +R 00 00 00 07 00 02 00 05 +T 00 C2 00 00 74 FF B5 00 00 02 15 00 01 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 00 CA +R 00 00 00 07 +T 00 CA 02 00 89 +R 00 00 00 07 00 03 00 07 +T 00 CD +R 00 00 00 07 +T 00 CD 53 06 7F AA 00 00 AB 00 01 78 00 79 00 8A +R 00 00 00 07 29 06 00 01 29 09 00 01 +T 00 D9 00 04 EB 54 01 A2 E0 C5 00 04 13 C5 00 04 +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 00 E4 13 C5 00 04 F5 00 05 75 00 03 00 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 00 ED 00 02 00 90 00 01 E0 FA A3 E0 FB A3 E0 F8 +R 00 00 00 07 29 02 00 01 00 06 00 05 +T 00 FA A3 E0 F9 E5 00 02 42 02 E5 00 03 42 03 E5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 01 06 00 04 42 00 E5 00 05 42 01 EA 42 04 EB 42 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 01 12 05 E8 42 06 E9 42 07 90 00 05 EC F0 A3 ED +R 00 00 00 07 00 0A 00 05 +T 01 20 F0 A3 EE F0 A3 EF F0 90 00 05 E0 FA A3 E0 +R 00 00 00 07 00 0A 00 05 +T 01 2E FB A3 E0 FC A3 E0 FD 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 3B +R 00 00 00 07 +T 01 3B 22 +R 00 00 00 07 diff --git a/device/lib/large/_uint2fs.asm b/device/lib/large/_uint2fs.asm new file mode 100644 index 00000000..2fe663fb --- /dev/null +++ b/device/lib/large/_uint2fs.asm @@ -0,0 +1,340 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + +;-------------------------------------------------------- + .module _uint2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___uint2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___uint2fs_sloc0_1_0: + .ds 0x0002 +___uint2fs_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___uint2fs_a_1_1: + .ds 0x0002 +___uint2fs_sign_1_1: + .ds 0x0004 +___uint2fs_fl_1_1: + .ds 0x0004 +___uint2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__uint2fs$0$0 ==. +; _uint2fs.c 80 +; ----------------------------------------- +; function __uint2fs +; ----------------------------------------- +___uint2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _uint2fs.c 109 + push dph + push dpl + mov dptr,#___uint2fs_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _uint2fs.c 82 + mov dptr,#___uint2fs_sign_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _uint2fs.c 85 + mov dptr,#___uint2fs_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov dptr,#___uint2fs_a1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _uint2fs.c 87 + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _uint2fs.c 89 + mov dptr,#(___uint2fs_fl_1_1) +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; _uint2fs.c 90 + mov dptr,#(___uint2fs_fl_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r6 + mov dph,r7 + mov b,r0 + ljmp 00108$ +00102$: +; _uint2fs.c 93 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _uint2fs.c 95 + mov dptr,#___uint2fs_sign_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x80 + movx @dptr,a +; _uint2fs.c 96 + mov dptr,#___uint2fs_a1_1_1 + clr c + clr a + subb a,r2 + movx @dptr,a + clr a + subb a,r3 + inc dptr + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a +; _uint2fs.c 99 +00113$: + clr a + mov (___uint2fs_sloc0_1_0 + 1),a + mov ___uint2fs_sloc0_1_0,#0x96 +00105$: + mov dptr,#___uint2fs_a1_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r4 + subb a,#0x00 + mov a,r5 + subb a,#0x00 + mov a,r6 + subb a,#0x80 + mov a,r7 + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _uint2fs.c 101 + mov a,r4 + add a,acc + mov r0,a + mov a,r5 + rlc a + mov r1,a + mov a,r6 + rlc a + mov r2,a + mov a,r7 + rlc a + mov r3,a + mov dptr,#___uint2fs_a1_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _uint2fs.c 102 + dec ___uint2fs_sloc0_1_0 + mov a,#0xff + cjne a,___uint2fs_sloc0_1_0,00117$ + dec (___uint2fs_sloc0_1_0 + 1) +00117$: + ljmp 00105$ +00107$: +; _uint2fs.c 105 + anl ar6,#0x7f +; _uint2fs.c 107 + mov r2,___uint2fs_sloc0_1_0 + mov r3,(___uint2fs_sloc0_1_0 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___uint2fs_sloc1_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___uint2fs_sloc1_1_0 + 2) + rrc a + xch a,(___uint2fs_sloc1_1_0 + 2) + rrc a + xch a,(___uint2fs_sloc1_1_0 + 2) + mov (___uint2fs_sloc1_1_0 + 3),a + mov (___uint2fs_sloc1_1_0 + 1),#0x00 + mov ___uint2fs_sloc1_1_0,#0x00 + mov dptr,#___uint2fs_sign_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,___uint2fs_sloc1_1_0 + orl ar2,a + mov a,(___uint2fs_sloc1_1_0 + 1) + orl ar3,a + mov a,(___uint2fs_sloc1_1_0 + 2) + orl ar0,a + mov a,(___uint2fs_sloc1_1_0 + 3) + orl ar1,a + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov dptr,#(___uint2fs_fl_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _uint2fs.c 109 + mov dptr,#(___uint2fs_fl_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00108$: + C$_uint2fs.c$110$1$1 ==. + XG$__uint2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_uint2fs.cdb b/device/lib/large/_uint2fs.cdb new file mode 100644 index 00000000..3445c946 --- /dev/null +++ b/device/lib/large/_uint2fs.cdb @@ -0,0 +1,2 @@ +M:_uint2fs +F:G$__uint2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_uint2fs.rel b/device/lib/large/_uint2fs.rel new file mode 100644 index 00000000..5ba69a54 --- /dev/null +++ b/device/lib/large/_uint2fs.rel @@ -0,0 +1,351 @@ +;!FILE _uint2fs.asm +XH +H 8 areas EB global symbols +M _uint2fs +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size E flags 40 +A GSINIT size 0 flags 20 +A CSEG size 144 flags 20 +S A$_uint2fs$94 Def0022 +S A$_uint2fs$85 Def0014 +S A$_uint2fs$76 Def0009 +S A$_uint2fs$95 Def0025 +S A$_uint2fs$86 Def0015 +S A$_uint2fs$77 Def000A +S A$_uint2fs$96 Def0026 +S A$_uint2fs$87 Def0016 +S A$_uint2fs$78 Def000C +S A$_uint2fs$97 Def0027 +S A$_uint2fs$88 Def0019 +S A$_uint2fs$79 Def000D +S A$_uint2fs$98 Def0028 +S A$_uint2fs$89 Def001A +S C$_uint2fs.c$110$1$1 Def0143 +S A$_uint2fs$100 Def0029 +S A$_uint2fs$200 Def008C +S A$_uint2fs$110 Def0036 +S A$_uint2fs$101 Def002A +S A$_uint2fs$300 Def0116 +S A$_uint2fs$210 Def009A +S A$_uint2fs$201 Def008E +S A$_uint2fs$120 Def003F +S A$_uint2fs$111 Def0037 +S A$_uint2fs$102 Def002B +S A$_uint2fs$310 Def0126 +S A$_uint2fs$301 Def0118 +S A$_uint2fs$220 Def00A6 +S A$_uint2fs$211 Def009B +S A$_uint2fs$130 Def0047 +S A$_uint2fs$121 Def0040 +S A$_uint2fs$112 Def0038 +S A$_uint2fs$103 Def002D +S A$_uint2fs$320 Def012F +S A$_uint2fs$311 Def0127 +S A$_uint2fs$302 Def0119 +S A$_uint2fs$230 Def00B1 +S A$_uint2fs$221 Def00A7 +S A$_uint2fs$212 Def009C +S A$_uint2fs$203 Def0091 +S A$_uint2fs$131 Def0048 +S A$_uint2fs$113 Def0039 +S A$_uint2fs$104 Def002E +S ___uint2fs Def0000 +S A$_uint2fs$330 Def013B +S A$_uint2fs$321 Def0132 +S A$_uint2fs$312 Def0128 +S A$_uint2fs$303 Def011B +S A$_uint2fs$240 Def00BB +S A$_uint2fs$231 Def00B2 +S A$_uint2fs$222 Def00A9 +S A$_uint2fs$213 Def009D +S A$_uint2fs$204 Def0094 +S A$_uint2fs$150 Def005A +S A$_uint2fs$141 Def004F +S A$_uint2fs$132 Def0049 +S A$_uint2fs$123 Def0041 +S A$_uint2fs$114 Def003A +S A$_uint2fs$105 Def002F +S A$_uint2fs$322 Def0133 +S A$_uint2fs$313 Def0129 +S A$_uint2fs$304 Def011C +S A$_uint2fs$250 Def00C7 +S A$_uint2fs$241 Def00BE +S A$_uint2fs$232 Def00B3 +S A$_uint2fs$223 Def00AA +S A$_uint2fs$214 Def009E +S A$_uint2fs$205 Def0095 +S A$_uint2fs$160 Def0066 +S A$_uint2fs$151 Def005B +S A$_uint2fs$142 Def0052 +S A$_uint2fs$133 Def004A +S A$_uint2fs$115 Def003B +S A$_uint2fs$106 Def0032 +S A$_uint2fs$332 Def013C +S A$_uint2fs$323 Def0134 +S A$_uint2fs$314 Def012A +S A$_uint2fs$305 Def011E +S A$_uint2fs$251 Def00C8 +S A$_uint2fs$242 Def00BF +S A$_uint2fs$233 Def00B4 +S A$_uint2fs$215 Def009F +S A$_uint2fs$206 Def0096 +S A$_uint2fs$170 Def006F +S A$_uint2fs$143 Def0053 +S A$_uint2fs$116 Def003C +S A$_uint2fs$107 Def0033 +S A$_uint2fs$333 Def013D +S A$_uint2fs$324 Def0135 +S A$_uint2fs$315 Def012B +S A$_uint2fs$306 Def011F +S A$_uint2fs$270 Def00E5 +S A$_uint2fs$261 Def00D5 +S A$_uint2fs$243 Def00C0 +S A$_uint2fs$234 Def00B5 +S A$_uint2fs$225 Def00AC +S A$_uint2fs$216 Def00A0 +S A$_uint2fs$207 Def0097 +S A$_uint2fs$180 Def0078 +S A$_uint2fs$171 Def0070 +S A$_uint2fs$162 Def0067 +S A$_uint2fs$153 Def005C +S A$_uint2fs$144 Def0054 +S A$_uint2fs$126 Def0043 +S A$_uint2fs$108 Def0034 +S A$_uint2fs$334 Def013F +S A$_uint2fs$325 Def0136 +S A$_uint2fs$316 Def012C +S A$_uint2fs$307 Def0121 +S A$_uint2fs$280 Def00FA +S A$_uint2fs$271 Def00E7 +S A$_uint2fs$253 Def00C9 +S A$_uint2fs$244 Def00C1 +S A$_uint2fs$235 Def00B6 +S A$_uint2fs$217 Def00A1 +S A$_uint2fs$208 Def0098 +S A$_uint2fs$190 Def0084 +S A$_uint2fs$181 Def007B +S A$_uint2fs$172 Def0071 +S A$_uint2fs$154 Def005D +S A$_uint2fs$145 Def0055 +S A$_uint2fs$136 Def004B +S A$_uint2fs$118 Def003D +S A$_uint2fs$109 Def0035 +S A$_uint2fs$335 Def0141 +S A$_uint2fs$326 Def0137 +S A$_uint2fs$317 Def012D +S A$_uint2fs$308 Def0124 +S A$_uint2fs$290 Def0104 +S A$_uint2fs$281 Def00FB +S A$_uint2fs$272 Def00E9 +S A$_uint2fs$263 Def00D8 +S A$_uint2fs$254 Def00CB +S A$_uint2fs$245 Def00C2 +S A$_uint2fs$236 Def00B7 +S A$_uint2fs$218 Def00A3 +S A$_uint2fs$209 Def0099 +S A$_uint2fs$191 Def0085 +S A$_uint2fs$182 Def007C +S A$_uint2fs$155 Def005F +S A$_uint2fs$146 Def0056 +S A$_uint2fs$137 Def004C +S A$_uint2fs$119 Def003E +S A$_uint2fs$327 Def0138 +S A$_uint2fs$318 Def012E +S A$_uint2fs$309 Def0125 +S A$_uint2fs$291 Def0105 +S A$_uint2fs$282 Def00FC +S A$_uint2fs$273 Def00EA +S A$_uint2fs$264 Def00DA +S A$_uint2fs$255 Def00CD +S A$_uint2fs$246 Def00C3 +S A$_uint2fs$237 Def00B8 +S A$_uint2fs$228 Def00AE +S A$_uint2fs$219 Def00A4 +S A$_uint2fs$192 Def0086 +S A$_uint2fs$183 Def007D +S A$_uint2fs$174 Def0072 +S A$_uint2fs$165 Def006A +S A$_uint2fs$156 Def0061 +S A$_uint2fs$147 Def0057 +S A$_uint2fs$138 Def004D +S A$_uint2fs$129 Def0046 +S A$_uint2fs$328 Def0139 +S A$_uint2fs$292 Def0107 +S A$_uint2fs$283 Def00FD +S A$_uint2fs$274 Def00EC +S A$_uint2fs$265 Def00DC +S A$_uint2fs$256 Def00D0 +S A$_uint2fs$247 Def00C4 +S A$_uint2fs$238 Def00B9 +S A$_uint2fs$229 Def00AF +S A$_uint2fs$193 Def0087 +S A$_uint2fs$184 Def007E +S A$_uint2fs$175 Def0073 +S A$_uint2fs$157 Def0063 +S A$_uint2fs$148 Def0058 +S A$_uint2fs$139 Def004E +S A$_uint2fs$329 Def013A +S A$_uint2fs$293 Def0109 +S A$_uint2fs$284 Def00FE +S A$_uint2fs$275 Def00ED +S A$_uint2fs$266 Def00DE +S A$_uint2fs$248 Def00C5 +S A$_uint2fs$239 Def00BA +S A$_uint2fs$194 Def0088 +S A$_uint2fs$185 Def007F +S A$_uint2fs$176 Def0074 +S A$_uint2fs$149 Def0059 +S A$_uint2fs$339 Def0143 +S A$_uint2fs$294 Def010B +S A$_uint2fs$285 Def00FF +S A$_uint2fs$276 Def00EF +S A$_uint2fs$267 Def00E0 +S A$_uint2fs$258 Def00D2 +S A$_uint2fs$249 Def00C6 +S A$_uint2fs$195 Def0089 +S A$_uint2fs$186 Def0080 +S A$_uint2fs$177 Def0075 +S A$_uint2fs$168 Def006D +S A$_uint2fs$295 Def010D +S A$_uint2fs$286 Def0100 +S A$_uint2fs$277 Def00F1 +S A$_uint2fs$268 Def00E2 +S A$_uint2fs$196 Def008A +S A$_uint2fs$187 Def0081 +S A$_uint2fs$178 Def0077 +S A$_uint2fs$169 Def006E +S A$_uint2fs$296 Def010F +S A$_uint2fs$287 Def0101 +S A$_uint2fs$278 Def00F4 +S A$_uint2fs$269 Def00E3 +S A$_uint2fs$188 Def0082 +S XG$__uint2fs$0$0 Def0143 +S A$_uint2fs$297 Def0111 +S A$_uint2fs$288 Def0102 +S A$_uint2fs$279 Def00F7 +S A$_uint2fs$189 Def0083 +S A$_uint2fs$298 Def0113 +S A$_uint2fs$289 Def0103 +S A$_uint2fs$199 Def008B +S A$_uint2fs$299 Def0115 +S A$_uint2fs$90 Def001D +S A$_uint2fs$81 Def000E +S A$_uint2fs$72 Def0000 +S G$__uint2fs$0$0 Def0000 +S A$_uint2fs$91 Def001E +S A$_uint2fs$82 Def0011 +S A$_uint2fs$73 Def0002 +S A$_uint2fs$92 Def0021 +S A$_uint2fs$83 Def0012 +S A$_uint2fs$74 Def0004 +S A$_uint2fs$84 Def0013 +S A$_uint2fs$75 Def0007 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 00 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 02 E4 A3 A3 A3 F0 12 00 00 F0 12 +R 00 00 00 07 00 03 00 05 02 0B 00 00 +T 00 1B 00 00 F0 12 00 00 F0 90 00 00 E0 FA A3 E0 +R 00 00 00 07 02 02 00 00 02 06 00 00 00 0A 00 05 +T 00 29 FB 33 95 E0 FC FD 90 00 0A EA F0 A3 EB F0 +R 00 00 00 07 00 09 00 05 +T 00 37 A3 EC F0 A3 ED F0 EA 4B 4C 4D 70 23 +R 00 00 00 07 +T 00 43 +R 00 00 00 07 +T 00 43 90 00 06 E4 F0 A3 F0 A3 E4 F0 A3 F0 90 +R 00 00 00 07 00 03 00 05 +T 00 50 00 06 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 8E +R 00 00 00 07 00 02 00 05 +T 00 5E 82 8F 83 88 F0 02 01 43 +R 00 00 00 07 00 08 00 07 +T 00 66 +R 00 00 00 07 +T 00 66 ED 30 E7 21 +R 00 00 00 07 +T 00 6A +R 00 00 00 07 +T 00 6A 90 00 02 E4 F0 A3 F0 A3 E4 F0 A3 74 80 F0 +R 00 00 00 07 00 03 00 05 +T 00 78 90 00 0A C3 E4 9A F0 E4 9B A3 F0 E4 9C A3 +R 00 00 00 07 00 03 00 05 +T 00 86 F0 E4 9D A3 F0 +R 00 00 00 07 +T 00 8B +R 00 00 00 07 +T 00 8B E4 F5 00 01 75 00 00 96 +R 00 00 00 07 29 04 00 01 29 07 00 01 +T 00 91 +R 00 00 00 07 +T 00 91 90 00 0A E0 FC A3 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 9F C3 EC 94 00 ED 94 00 EE 94 80 EF 94 00 50 +R 00 00 00 07 +T 00 AD 27 +R 00 00 00 07 +T 00 AE +R 00 00 00 07 +T 00 AE EC 25 E0 F8 ED 33 F9 EE 33 FA EF 33 FB 90 +R 00 00 00 07 +T 00 BC 00 0A E8 F0 A3 E9 F0 A3 EA F0 A3 EB F0 15 +R 00 00 00 07 00 02 00 05 +T 00 CA 00 00 74 FF B5 00 00 02 15 00 01 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 00 D2 +R 00 00 00 07 +T 00 D2 02 00 91 +R 00 00 00 07 00 03 00 07 +T 00 D5 +R 00 00 00 07 +T 00 D5 53 06 7F AA 00 00 AB 00 01 78 00 79 00 8A +R 00 00 00 07 29 06 00 01 29 09 00 01 +T 00 E1 00 04 EB 54 01 A2 E0 C5 00 04 13 C5 00 04 +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 00 EC 13 C5 00 04 F5 00 05 75 00 03 00 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 00 F5 00 02 00 90 00 02 E0 FA A3 E0 FB A3 E0 F8 +R 00 00 00 07 29 02 00 01 00 06 00 05 +T 01 02 A3 E0 F9 E5 00 02 42 02 E5 00 03 42 03 E5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 01 0E 00 04 42 00 E5 00 05 42 01 EA 42 04 EB 42 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 01 1A 05 E8 42 06 E9 42 07 90 00 06 EC F0 A3 ED +R 00 00 00 07 00 0A 00 05 +T 01 28 F0 A3 EE F0 A3 EF F0 90 00 06 E0 FA A3 E0 +R 00 00 00 07 00 0A 00 05 +T 01 36 FB A3 E0 FC A3 E0 FD 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 43 +R 00 00 00 07 +T 01 43 22 +R 00 00 00 07 diff --git a/device/lib/large/_ulong2fs.asm b/device/lib/large/_ulong2fs.asm new file mode 100644 index 00000000..ce510008 --- /dev/null +++ b/device/lib/large/_ulong2fs.asm @@ -0,0 +1,349 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + +;-------------------------------------------------------- + .module _ulong2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___ulong2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___ulong2fs_sloc0_1_0: + .ds 0x0002 +___ulong2fs_sloc1_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +___ulong2fs_a_1_1: + .ds 0x0004 +___ulong2fs_sign_1_1: + .ds 0x0004 +___ulong2fs_fl_1_1: + .ds 0x0004 +___ulong2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__ulong2fs$0$0 ==. +; _ulong2fs.c 80 +; ----------------------------------------- +; function __ulong2fs +; ----------------------------------------- +___ulong2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ulong2fs.c 109 + push acc + push b + push dph + push dpl + mov dptr,#___ulong2fs_a_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; _ulong2fs.c 82 + mov dptr,#___ulong2fs_sign_1_1 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a +; _ulong2fs.c 85 + mov dptr,#___ulong2fs_a_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#___ulong2fs_a1_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; _ulong2fs.c 87 + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _ulong2fs.c 89 + mov dptr,#(___ulong2fs_fl_1_1) +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; _ulong2fs.c 90 + mov dptr,#(___ulong2fs_fl_1_1) + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r6 + mov dph,r7 + mov b,r0 + ljmp 00108$ +00102$: +; _ulong2fs.c 93 + clr c +; Peephole 108 removed ljmp by inverse jump logic + jnc 00113$ +00115$: +; _ulong2fs.c 95 + mov dptr,#___ulong2fs_sign_1_1 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + mov a,#0x80 + movx @dptr,a +; _ulong2fs.c 96 + mov dptr,#___ulong2fs_a1_1_1 + clr c + clr a + subb a,r2 + movx @dptr,a + clr a + subb a,r3 + inc dptr + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a +; _ulong2fs.c 99 +00113$: + clr a + mov (___ulong2fs_sloc0_1_0 + 1),a + mov ___ulong2fs_sloc0_1_0,#0x96 +00105$: + mov dptr,#___ulong2fs_a1_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r4 + subb a,#0x00 + mov a,r5 + subb a,#0x00 + mov a,r6 + subb a,#0x80 + mov a,r7 + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _ulong2fs.c 101 + mov a,r4 + add a,acc + mov r0,a + mov a,r5 + rlc a + mov r1,a + mov a,r6 + rlc a + mov r2,a + mov a,r7 + rlc a + mov r3,a + mov dptr,#___ulong2fs_a1_1_1 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a + inc dptr + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; _ulong2fs.c 102 + dec ___ulong2fs_sloc0_1_0 + mov a,#0xff + cjne a,___ulong2fs_sloc0_1_0,00117$ + dec (___ulong2fs_sloc0_1_0 + 1) +00117$: + ljmp 00105$ +00107$: +; _ulong2fs.c 105 + anl ar6,#0x7f +; _ulong2fs.c 107 + mov r2,___ulong2fs_sloc0_1_0 + mov r3,(___ulong2fs_sloc0_1_0 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___ulong2fs_sloc1_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___ulong2fs_sloc1_1_0 + 2) + rrc a + xch a,(___ulong2fs_sloc1_1_0 + 2) + rrc a + xch a,(___ulong2fs_sloc1_1_0 + 2) + mov (___ulong2fs_sloc1_1_0 + 3),a + mov (___ulong2fs_sloc1_1_0 + 1),#0x00 + mov ___ulong2fs_sloc1_1_0,#0x00 + mov dptr,#___ulong2fs_sign_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr + mov r1,a + mov a,___ulong2fs_sloc1_1_0 + orl ar2,a + mov a,(___ulong2fs_sloc1_1_0 + 1) + orl ar3,a + mov a,(___ulong2fs_sloc1_1_0 + 2) + orl ar0,a + mov a,(___ulong2fs_sloc1_1_0 + 3) + orl ar1,a + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov dptr,#(___ulong2fs_fl_1_1) + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; _ulong2fs.c 109 + mov dptr,#(___ulong2fs_fl_1_1) + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 191 removed redundant mov + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 +00108$: + C$_ulong2fs.c$110$1$1 ==. + XG$__ulong2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/_ulong2fs.cdb b/device/lib/large/_ulong2fs.cdb new file mode 100644 index 00000000..5a2bb991 --- /dev/null +++ b/device/lib/large/_ulong2fs.cdb @@ -0,0 +1,2 @@ +M:_ulong2fs +F:G$__ulong2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/large/_ulong2fs.rel b/device/lib/large/_ulong2fs.rel new file mode 100644 index 00000000..484714d3 --- /dev/null +++ b/device/lib/large/_ulong2fs.rel @@ -0,0 +1,363 @@ +;!FILE _ulong2fs.asm +XH +H 8 areas F5 global symbols +M _ulong2fs +S __decdptr Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 10 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 150 flags 20 +S C$_ulong2fs.c$110$1$1 Def014F +S A$_ulong2fs$100 Def002D +S A$_ulong2fs$200 Def0091 +S A$_ulong2fs$110 Def0038 +S A$_ulong2fs$300 Def0111 +S A$_ulong2fs$210 Def009A +S A$_ulong2fs$201 Def0092 +S A$_ulong2fs$120 Def0044 +S A$_ulong2fs$111 Def0039 +S A$_ulong2fs$102 Def002E +S A$_ulong2fs$310 Def0124 +S A$_ulong2fs$301 Def0113 +S A$_ulong2fs$220 Def00A7 +S A$_ulong2fs$202 Def0093 +S A$_ulong2fs$130 Def004D +S A$_ulong2fs$121 Def0045 +S A$_ulong2fs$112 Def003A +S A$_ulong2fs$103 Def0031 +S A$_ulong2fs$320 Def0133 +S A$_ulong2fs$311 Def0125 +S A$_ulong2fs$302 Def0115 +S A$_ulong2fs$230 Def00B3 +S A$_ulong2fs$221 Def00A8 +S A$_ulong2fs$212 Def009D +S A$_ulong2fs$203 Def0094 +S A$_ulong2fs$140 Def0055 +S A$_ulong2fs$122 Def0046 +S A$_ulong2fs$113 Def003B +S A$_ulong2fs$104 Def0032 +S ___ulong2fs Def0000 +S A$_ulong2fs$330 Def013E +S A$_ulong2fs$321 Def0134 +S A$_ulong2fs$312 Def0127 +S A$_ulong2fs$303 Def0117 +S A$_ulong2fs$240 Def00BE +S A$_ulong2fs$231 Def00B5 +S A$_ulong2fs$222 Def00A9 +S A$_ulong2fs$213 Def00A0 +S A$_ulong2fs$204 Def0095 +S A$_ulong2fs$150 Def005C +S A$_ulong2fs$141 Def0056 +S A$_ulong2fs$132 Def004E +S A$_ulong2fs$123 Def0047 +S A$_ulong2fs$114 Def003C +S A$_ulong2fs$105 Def0033 +S A$_ulong2fs$331 Def013F +S A$_ulong2fs$322 Def0135 +S A$_ulong2fs$313 Def0128 +S A$_ulong2fs$304 Def0119 +S A$_ulong2fs$250 Def00CA +S A$_ulong2fs$241 Def00BF +S A$_ulong2fs$232 Def00B6 +S A$_ulong2fs$223 Def00AA +S A$_ulong2fs$214 Def00A1 +S A$_ulong2fs$205 Def0096 +S A$_ulong2fs$160 Def0068 +S A$_ulong2fs$151 Def005F +S A$_ulong2fs$142 Def0057 +S A$_ulong2fs$124 Def0048 +S A$_ulong2fs$115 Def003F +S A$_ulong2fs$106 Def0034 +S A$_ulong2fs$341 Def0148 +S A$_ulong2fs$332 Def0140 +S A$_ulong2fs$323 Def0136 +S A$_ulong2fs$314 Def012A +S A$_ulong2fs$305 Def011B +S A$_ulong2fs$260 Def00D4 +S A$_ulong2fs$251 Def00CB +S A$_ulong2fs$242 Def00C0 +S A$_ulong2fs$224 Def00AB +S A$_ulong2fs$215 Def00A2 +S A$_ulong2fs$152 Def0060 +S A$_ulong2fs$125 Def0049 +S A$_ulong2fs$116 Def0040 +S A$_ulong2fs$107 Def0035 +S A$_ulong2fs$342 Def0149 +S A$_ulong2fs$333 Def0141 +S A$_ulong2fs$324 Def0137 +S A$_ulong2fs$315 Def012B +S A$_ulong2fs$306 Def011D +S A$_ulong2fs$270 Def00E1 +S A$_ulong2fs$252 Def00CC +S A$_ulong2fs$243 Def00C1 +S A$_ulong2fs$234 Def00B8 +S A$_ulong2fs$225 Def00AC +S A$_ulong2fs$216 Def00A3 +S A$_ulong2fs$180 Def007C +S A$_ulong2fs$171 Def0074 +S A$_ulong2fs$162 Def0069 +S A$_ulong2fs$153 Def0061 +S A$_ulong2fs$135 Def0050 +S A$_ulong2fs$117 Def0041 +S A$_ulong2fs$108 Def0036 +S A$_ulong2fs$343 Def014B +S A$_ulong2fs$334 Def0142 +S A$_ulong2fs$325 Def0138 +S A$_ulong2fs$316 Def012D +S A$_ulong2fs$307 Def011F +S A$_ulong2fs$280 Def00F3 +S A$_ulong2fs$262 Def00D5 +S A$_ulong2fs$253 Def00CD +S A$_ulong2fs$244 Def00C2 +S A$_ulong2fs$226 Def00AD +S A$_ulong2fs$217 Def00A4 +S A$_ulong2fs$208 Def0097 +S A$_ulong2fs$190 Def0087 +S A$_ulong2fs$181 Def007D +S A$_ulong2fs$163 Def006A +S A$_ulong2fs$154 Def0062 +S A$_ulong2fs$145 Def0058 +S A$_ulong2fs$127 Def004A +S A$_ulong2fs$118 Def0042 +S A$_ulong2fs$109 Def0037 +S A$_ulong2fs$344 Def014D +S A$_ulong2fs$335 Def0143 +S A$_ulong2fs$326 Def0139 +S A$_ulong2fs$317 Def0130 +S A$_ulong2fs$308 Def0121 +S A$_ulong2fs$290 Def0107 +S A$_ulong2fs$281 Def00F5 +S A$_ulong2fs$272 Def00E4 +S A$_ulong2fs$263 Def00D7 +S A$_ulong2fs$254 Def00CE +S A$_ulong2fs$245 Def00C3 +S A$_ulong2fs$227 Def00AF +S A$_ulong2fs$218 Def00A5 +S A$_ulong2fs$209 Def0098 +S A$_ulong2fs$191 Def0088 +S A$_ulong2fs$164 Def006C +S A$_ulong2fs$155 Def0063 +S A$_ulong2fs$146 Def0059 +S A$_ulong2fs$128 Def004B +S A$_ulong2fs$119 Def0043 +S A$_ulong2fs$336 Def0144 +S A$_ulong2fs$327 Def013A +S A$_ulong2fs$318 Def0131 +S A$_ulong2fs$309 Def0122 +S A$_ulong2fs$291 Def0108 +S A$_ulong2fs$282 Def00F6 +S A$_ulong2fs$273 Def00E6 +S A$_ulong2fs$264 Def00D9 +S A$_ulong2fs$255 Def00CF +S A$_ulong2fs$246 Def00C4 +S A$_ulong2fs$237 Def00BA +S A$_ulong2fs$228 Def00B0 +S A$_ulong2fs$219 Def00A6 +S A$_ulong2fs$192 Def0089 +S A$_ulong2fs$183 Def007E +S A$_ulong2fs$174 Def0076 +S A$_ulong2fs$165 Def006E +S A$_ulong2fs$156 Def0064 +S A$_ulong2fs$147 Def005A +S A$_ulong2fs$138 Def0053 +S A$_ulong2fs$129 Def004C +S A$_ulong2fs$337 Def0145 +S A$_ulong2fs$319 Def0132 +S A$_ulong2fs$292 Def0109 +S A$_ulong2fs$283 Def00F8 +S A$_ulong2fs$274 Def00E8 +S A$_ulong2fs$265 Def00DC +S A$_ulong2fs$256 Def00D0 +S A$_ulong2fs$247 Def00C5 +S A$_ulong2fs$238 Def00BB +S A$_ulong2fs$229 Def00B2 +S A$_ulong2fs$193 Def008A +S A$_ulong2fs$184 Def007F +S A$_ulong2fs$166 Def0070 +S A$_ulong2fs$157 Def0065 +S A$_ulong2fs$148 Def005B +S A$_ulong2fs$139 Def0054 +S A$_ulong2fs$338 Def0146 +S A$_ulong2fs$329 Def013B +S A$_ulong2fs$293 Def010A +S A$_ulong2fs$284 Def00F9 +S A$_ulong2fs$275 Def00EA +S A$_ulong2fs$257 Def00D1 +S A$_ulong2fs$248 Def00C6 +S A$_ulong2fs$239 Def00BD +S A$_ulong2fs$194 Def008B +S A$_ulong2fs$185 Def0080 +S A$_ulong2fs$158 Def0066 +S A$_ulong2fs$348 Def014F +S A$_ulong2fs$339 Def0147 +S A$_ulong2fs$294 Def010B +S A$_ulong2fs$285 Def00FB +S A$_ulong2fs$276 Def00EC +S A$_ulong2fs$267 Def00DE +S A$_ulong2fs$258 Def00D2 +S A$_ulong2fs$249 Def00C7 +S A$_ulong2fs$195 Def008C +S A$_ulong2fs$186 Def0081 +S A$_ulong2fs$177 Def0079 +S A$_ulong2fs$159 Def0067 +S A$_ulong2fs$295 Def010C +S A$_ulong2fs$286 Def00FD +S A$_ulong2fs$277 Def00EE +S A$_ulong2fs$259 Def00D3 +S A$_ulong2fs$196 Def008D +S A$_ulong2fs$187 Def0083 +S A$_ulong2fs$178 Def007A +S A$_ulong2fs$169 Def0073 +S A$_ulong2fs$296 Def010D +S A$_ulong2fs$287 Def0100 +S A$_ulong2fs$278 Def00EF +S A$_ulong2fs$197 Def008E +S A$_ulong2fs$179 Def007B +S XG$__ulong2fs$0$0 Def014F +S A$_ulong2fs$297 Def010E +S A$_ulong2fs$288 Def0103 +S A$_ulong2fs$279 Def00F1 +S A$_ulong2fs$198 Def008F +S A$_ulong2fs$189 Def0084 +S A$_ulong2fs$298 Def010F +S A$_ulong2fs$289 Def0106 +S A$_ulong2fs$199 Def0090 +S A$_ulong2fs$299 Def0110 +S A$_ulong2fs$80 Def0010 +S A$_ulong2fs$90 Def001D +S A$_ulong2fs$81 Def0011 +S A$_ulong2fs$72 Def0000 +S G$__ulong2fs$0$0 Def0000 +S A$_ulong2fs$91 Def001E +S A$_ulong2fs$82 Def0012 +S A$_ulong2fs$73 Def0002 +S A$_ulong2fs$92 Def001F +S A$_ulong2fs$83 Def0014 +S A$_ulong2fs$74 Def0004 +S A$_ulong2fs$93 Def0020 +S A$_ulong2fs$84 Def0015 +S A$_ulong2fs$75 Def0006 +S A$_ulong2fs$94 Def0021 +S A$_ulong2fs$85 Def0016 +S A$_ulong2fs$76 Def0008 +S A$_ulong2fs$95 Def0022 +S A$_ulong2fs$86 Def0018 +S A$_ulong2fs$77 Def000B +S A$_ulong2fs$96 Def0025 +S A$_ulong2fs$87 Def0019 +S A$_ulong2fs$78 Def000D +S A$_ulong2fs$97 Def0026 +S A$_ulong2fs$79 Def000E +S A$_ulong2fs$98 Def0029 +S A$_ulong2fs$89 Def001A +S A$_ulong2fs$99 Def002A +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E4 A3 A3 A3 F0 12 00 00 F0 12 00 00 +R 00 00 00 07 00 02 00 05 02 0A 00 00 02 0E 00 00 +T 00 29 F0 12 00 00 F0 90 00 00 E0 FA A3 E0 FB A3 +R 00 00 00 07 02 04 00 00 00 08 00 05 +T 00 37 E0 FC A3 E0 FD 90 00 0C EA F0 A3 EB F0 A3 +R 00 00 00 07 00 08 00 05 +T 00 45 EC F0 A3 ED F0 EA 4B 4C 4D 70 23 +R 00 00 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 90 00 08 E4 F0 A3 F0 A3 E4 F0 A3 F0 90 +R 00 00 00 07 00 03 00 05 +T 00 5D 00 08 E0 FE A3 E0 FF A3 E0 F8 A3 E0 F9 8E +R 00 00 00 07 00 02 00 05 +T 00 6B 82 8F 83 88 F0 02 01 4F +R 00 00 00 07 00 08 00 07 +T 00 73 +R 00 00 00 07 +T 00 73 C3 50 21 +R 00 00 00 07 +T 00 76 +R 00 00 00 07 +T 00 76 90 00 04 E4 F0 A3 F0 A3 E4 F0 A3 74 80 F0 +R 00 00 00 07 00 03 00 05 +T 00 84 90 00 0C C3 E4 9A F0 E4 9B A3 F0 E4 9C A3 +R 00 00 00 07 00 03 00 05 +T 00 92 F0 E4 9D A3 F0 +R 00 00 00 07 +T 00 97 +R 00 00 00 07 +T 00 97 E4 F5 00 01 75 00 00 96 +R 00 00 00 07 29 04 00 01 29 07 00 01 +T 00 9D +R 00 00 00 07 +T 00 9D 90 00 0C E0 FC A3 E0 FD A3 E0 FE A3 E0 FF +R 00 00 00 07 00 03 00 05 +T 00 AB C3 EC 94 00 ED 94 00 EE 94 80 EF 94 00 50 +R 00 00 00 07 +T 00 B9 27 +R 00 00 00 07 +T 00 BA +R 00 00 00 07 +T 00 BA EC 25 E0 F8 ED 33 F9 EE 33 FA EF 33 FB 90 +R 00 00 00 07 +T 00 C8 00 0C E8 F0 A3 E9 F0 A3 EA F0 A3 EB F0 15 +R 00 00 00 07 00 02 00 05 +T 00 D6 00 00 74 FF B5 00 00 02 15 00 01 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 00 DE +R 00 00 00 07 +T 00 DE 02 00 9D +R 00 00 00 07 00 03 00 07 +T 00 E1 +R 00 00 00 07 +T 00 E1 53 06 7F AA 00 00 AB 00 01 78 00 79 00 8A +R 00 00 00 07 29 06 00 01 29 09 00 01 +T 00 ED 00 04 EB 54 01 A2 E0 C5 00 04 13 C5 00 04 +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 00 F8 13 C5 00 04 F5 00 05 75 00 03 00 75 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 01 01 00 02 00 90 00 04 E0 FA A3 E0 FB A3 E0 F8 +R 00 00 00 07 29 02 00 01 00 06 00 05 +T 01 0E A3 E0 F9 E5 00 02 42 02 E5 00 03 42 03 E5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 01 1A 00 04 42 00 E5 00 05 42 01 EA 42 04 EB 42 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 01 26 05 E8 42 06 E9 42 07 90 00 08 EC F0 A3 ED +R 00 00 00 07 00 0A 00 05 +T 01 34 F0 A3 EE F0 A3 EF F0 90 00 08 E0 FA A3 E0 +R 00 00 00 07 00 0A 00 05 +T 01 42 FB A3 E0 FC A3 E0 FD 8A 82 8B 83 8C F0 +R 00 00 00 07 +T 01 4F +R 00 00 00 07 +T 01 4F 22 +R 00 00 00 07 diff --git a/device/lib/large/assert.asm b/device/lib/large/assert.asm new file mode 100644 index 00000000..8804d3d6 --- /dev/null +++ b/device/lib/large/assert.asm @@ -0,0 +1,138 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:40 2000 + +;-------------------------------------------------------- + .module assert +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __assert + .globl __assert_PARM_3 + .globl __assert_PARM_2 +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +__assert_PARM_2: + .ds 0x0003 +__assert_PARM_3: + .ds 0x0002 +__assert_expr_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_assert$0$0 ==. +; assert.c 4 +; ----------------------------------------- +; function _assert +; ----------------------------------------- +__assert: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; assert.c 0 + push b + push dph + push dpl + mov dptr,#__assert_expr_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; assert.c 7 + mov dptr,#__assert_expr_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a +; assert.c 6 + mov r5,#__str_0 + mov r6,#(__str_0 >> 8) + mov r7,#0x02 + mov dptr,#__assert_PARM_2 + movx a,@dptr +; Peephole 100.a removed redundant mov + push acc + inc dptr + movx a,@dptr +; Peephole 100.a removed redundant mov + push acc + inc dptr + movx a,@dptr +; Peephole 100.a removed redundant mov + push acc + mov dptr,#__assert_PARM_3 + movx a,@dptr +; Peephole 100.a removed redundant mov + push acc + inc dptr + movx a,@dptr +; Peephole 100.a removed redundant mov + push acc + push ar5 + push ar6 + push ar7 + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall _printf + mov a,sp + add a,#0xfa + mov sp,a +; assert.c 8 +00102$: +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00104$: + C$assert.c$9$1$1 ==. + XG$_assert$0$0 ==. + ret + .area CSEG (CODE) +Fassert$_str_0$0$0 == . +__str_0: + .ascii /Assert(%s) failed at line %u in file %s./ + .byte 0x0a + .ascii // + .byte 0 diff --git a/device/lib/large/assert.cdb b/device/lib/large/assert.cdb new file mode 100644 index 00000000..690295aa --- /dev/null +++ b/device/lib/large/assert.cdb @@ -0,0 +1,3 @@ +M:assert +F:G$_assert$0$0({2}DF,SV:S),C,0,0,0,0,0 +S:Fassert$_str_0$0$0({43}DA43,SC:S),D,0,0 diff --git a/device/lib/large/assert.rel b/device/lib/large/assert.rel new file mode 100644 index 00000000..cc615e50 --- /dev/null +++ b/device/lib/large/assert.rel @@ -0,0 +1,113 @@ +;!FILE assert.asm +XH +H 8 areas 3B global symbols +M assert +S _printf Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 8 flags 40 +S __assert_PARM_2 Def0000 +S __assert_PARM_3 Def0003 +A GSINIT size 0 flags 20 +A CSEG size 7F flags 20 +S Fassert$_str_0$0$0 Def0055 +S A$assert$110 Def0039 +S A$assert$101 Def002D +S A$assert$120 Def0049 +S A$assert$111 Def003A +S A$assert$102 Def002F +S A$assert$121 Def004C +S A$assert$103 Def0030 +S A$assert$131 Def0054 +S A$assert$122 Def004E +S A$assert$113 Def003B +S __assert Def0000 +S A$assert$123 Def0050 +S A$assert$114 Def003D +S A$assert$105 Def0031 +S A$assert$115 Def003F +S A$assert$106 Def0033 +S A$assert$116 Def0041 +S A$assert$107 Def0036 +S A$assert$117 Def0043 +S A$assert$127 Def0052 +S A$assert$118 Def0045 +S A$assert$109 Def0037 +S A$assert$119 Def0047 +S XG$_assert$0$0 Def0054 +S A$assert$70 Def0004 +S A$assert$71 Def0006 +S A$assert$81 Def0014 +S A$assert$72 Def0009 +S G$_assert$0$0 Def0000 +S A$assert$91 Def001F +S A$assert$82 Def0017 +S A$assert$73 Def000B +S A$assert$92 Def0021 +S A$assert$83 Def0018 +S A$assert$74 Def000C +S A$assert$93 Def0023 +S A$assert$84 Def0019 +S A$assert$75 Def000E +S A$assert$94 Def0025 +S A$assert$85 Def001A +S A$assert$76 Def000F +S A$assert$95 Def0028 +S A$assert$86 Def001B +S A$assert$77 Def0010 +S A$assert$68 Def0000 +S A$assert$87 Def001C +S A$assert$78 Def0012 +S A$assert$69 Def0002 +S A$assert$97 Def0029 +S A$assert$88 Def001D +S A$assert$79 Def0013 +S A$assert$98 Def002B +S A$assert$89 Def001E +S A$assert$99 Def002C +S C$assert.c$9$1$1 Def0054 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 05 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 05 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 7D 00 55 7E 00 55 7F 02 90 00 00 +R 00 00 00 07 09 06 00 07 89 09 00 07 00 0E 00 05 +T 00 28 E0 C0 E0 A3 E0 C0 E0 A3 E0 C0 E0 90 00 03 +R 00 00 00 07 00 0E 00 05 +T 00 36 E0 C0 E0 A3 E0 C0 E0 C0 05 C0 06 C0 07 8A +R 00 00 00 07 +T 00 44 82 8B 83 8C F0 12 00 00 E5 81 24 FA F5 81 +R 00 00 00 07 02 08 00 00 +T 00 52 +R 00 00 00 07 +T 00 52 80 FE +R 00 00 00 07 +T 00 54 +R 00 00 00 07 +T 00 54 22 +R 00 00 00 07 +T 00 55 +R 00 00 00 07 +T 00 55 41 73 73 65 72 74 28 25 73 29 20 66 61 69 +R 00 00 00 07 +T 00 63 6C 65 64 20 61 74 20 6C 69 6E 65 20 25 75 +R 00 00 00 07 +T 00 71 20 69 6E 20 66 69 6C 65 20 25 73 2E 0A 00 +R 00 00 00 07 diff --git a/device/lib/large/malloc.asm b/device/lib/large/malloc.asm new file mode 100644 index 00000000..ef38f2a0 --- /dev/null +++ b/device/lib/large/malloc.asm @@ -0,0 +1,593 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + +;-------------------------------------------------------- + .module malloc +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _free + .globl _malloc + .globl _init_dynamic_memory + .globl _init_dynamic_memory_PARM_2 +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_malloc_sloc0_1_0: + .ds 0x0002 +_malloc_sloc1_1_0: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0==. +_FIRST_MEMORY_HEADER_PTR: + .ds 0x0002 +_init_dynamic_memory_PARM_2: + .ds 0x0002 +_init_dynamic_memory_array_1_1: + .ds 0x0002 +_malloc_size_1_1: + .ds 0x0002 +_malloc_current_header_1_1: + .ds 0x0002 +_free_p_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$init_dynamic_memory$0$0 ==. +; malloc.c 31 +; ----------------------------------------- +; function init_dynamic_memory +; ----------------------------------------- +_init_dynamic_memory: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; malloc.c 63 + push dph + push dpl + mov dptr,#_init_dynamic_memory_array_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; malloc.c 53 + mov dptr,#_init_dynamic_memory_array_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r3,a + orl a,r2 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00106$: +; malloc.c 55 + mov dptr,#_init_dynamic_memory_array_1_1 + mov a,#0x01 + add a,r2 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + inc dptr + movx @dptr,a +; malloc.c 56 + mov dptr,#_init_dynamic_memory_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + dec r2 + cjne r2,#0xff,00107$ + dec r3 +00107$: + mov dptr,#_init_dynamic_memory_PARM_2 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +00102$: +; malloc.c 58 + mov dptr,#_init_dynamic_memory_array_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov dptr,#_FIRST_MEMORY_HEADER_PTR + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; malloc.c 60 + mov dptr,#_init_dynamic_memory_PARM_2 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,r4 + add a,r2 + mov r4,a + mov a,r5 + addc a,r3 + mov r5,a + mov a,r4 + add a,#0xfa + mov r4,a + mov a,r5 + addc a,#0xff + mov r5,a + mov dpl,r2 + mov dph,r3 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; malloc.c 61 + mov dpl,r4 + mov dph,r5 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; malloc.c 62 + mov a,#0x02 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; malloc.c 63 + mov a,#0x04 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +00103$: + C$malloc.c$64$1$1 ==. + XG$init_dynamic_memory$0$0 ==. + ret + G$malloc$0$0 ==. +; malloc.c 66 +; ----------------------------------------- +; function malloc +; ----------------------------------------- +_malloc: +; malloc.c 0 + push dph + push dpl + mov dptr,#_malloc_size_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; malloc.c 71 + mov dptr,#_malloc_size_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + mov ar4,r2 + mov ar5,r3 + mov r6,#0x00 + mov r7,#0x00 + clr c + mov a,#0xf9 + subb a,r4 + mov a,#0xff + subb a,r5 +; Peephole 180 changed mov to clr + clr a + subb a,r6 +; Peephole 180 changed mov to clr + clr a + subb a,r7 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00102$ +00122$: +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00114$ +00102$: +; malloc.c 72 + mov a,#0x06 + add a,r2 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r3,a + mov dptr,#_malloc_size_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; malloc.c 73 + mov dptr,#_FIRST_MEMORY_HEADER_PTR + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#_malloc_current_header_1_1 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; malloc.c 74 +00108$: +; malloc.c 84 + mov dptr,#_malloc_current_header_1_1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dpl,r4 + mov dph,r5 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + mov ar0,r6 + mov ar1,r7 +; malloc.c 85 + push ar6 + push ar7 + mov ar6,r4 + mov ar7,r5 + clr c + mov a,r0 + subb a,r6 + mov r0,a + mov a,r1 + subb a,r7 + mov r1,a +; malloc.c 86 + mov a,#0x04 + add a,r4 + mov _malloc_sloc0_1_0,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov (_malloc_sloc0_1_0 + 1),a + mov dpl,_malloc_sloc0_1_0 + mov dph,(_malloc_sloc0_1_0 + 1) + movx a,@dptr + mov _malloc_sloc1_1_0,a + inc dptr + movx a,@dptr + mov (_malloc_sloc1_1_0 + 1),a + clr c + mov a,r0 + subb a,_malloc_sloc1_1_0 + mov r0,a + mov a,r1 + subb a,(_malloc_sloc1_1_0 + 1) + mov r1,a + clr c + mov a,r0 + subb a,r2 + mov a,r1 + subb a,r3 + clr a + rlc a + pop ar7 + pop ar6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00109$ +00123$: +; malloc.c 87 + mov dptr,#_malloc_current_header_1_1 + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; malloc.c 88 + mov dpl,r6 + mov dph,r7 + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r1,a + orl a,r0 + jz 00124$ + ljmp 00108$ +00124$: +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00114$ +00109$: +; malloc.c 90 + mov a,_malloc_sloc1_1_0 + orl a,(_malloc_sloc1_1_0 + 1) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00111$ +00125$: +; malloc.c 92 + mov dpl,_malloc_sloc0_1_0 + mov dph,(_malloc_sloc0_1_0 + 1) + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; malloc.c 93 + mov a,#0x06 + add a,r4 + mov r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov r1,a + mov dpl,r0 + mov dph,r1 + ljmp 00114$ +00111$: +; malloc.c 95 + mov a,_malloc_sloc1_1_0 + add a,r4 + mov r0,a + mov a,(_malloc_sloc1_1_0 + 1) + addc a,r5 + mov r1,a +; malloc.c 96 + mov dpl,r0 + mov dph,r1 + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; malloc.c 97 + mov a,#0x02 + add a,r0 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r1 + mov dph,a + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; malloc.c 98 + mov dpl,r4 + mov dph,r5 + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a +; malloc.c 99 + mov a,r6 + orl a,r7 +; Peephole 110 removed ljmp by inverse jump logic + jz 00113$ +00126$: + mov dpl,r0 + mov dph,r1 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,#0x02 + add a,r4 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov dph,a + mov a,r0 + movx @dptr,a + inc dptr + mov a,r1 + movx @dptr,a +00113$: +; malloc.c 100 + mov a,#0x04 + add a,r0 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r1 + mov dph,a + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; malloc.c 101 + mov a,#0x06 + add a,r0 + mov r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r1 + mov r1,a + mov dpl,r0 + mov dph,r1 +00114$: + C$malloc.c$102$1$1 ==. + XG$malloc$0$0 ==. + ret + G$free$0$0 ==. +; malloc.c 104 +; ----------------------------------------- +; function free +; ----------------------------------------- +_free: +; malloc.c 0 + push dph + push dpl + mov dptr,#_free_p_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; malloc.c 107 + mov dptr,#_free_p_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r3,a + orl a,r2 + jnz 00113$ + ljmp 00108$ +00113$: +; malloc.c 109 + mov a,r2 + add a,#0xfa + mov r4,a + mov a,r3 + addc a,#0xff + mov r5,a + mov dptr,#_free_p_1_1 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; malloc.c 110 + mov a,#0x02 + add a,r4 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov dph,a + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r7,a + orl a,r6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00114$: +; malloc.c 113 + mov dpl,r4 + mov dph,r5 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dpl,r6 + mov dph,r7 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; malloc.c 114 + mov a,r4 + orl a,r5 +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00115$: + mov a,#0x02 + add a,r4 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov dph,a + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00104$: +; malloc.c 116 + mov a,#0xfe + add a,r2 + mov dpl,a + mov a,#0xff + addc a,r3 + mov dph,a +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +00108$: + C$malloc.c$118$2$1 ==. + XG$free$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/malloc.cdb b/device/lib/large/malloc.cdb new file mode 100644 index 00000000..61d7a414 --- /dev/null +++ b/device/lib/large/malloc.cdb @@ -0,0 +1,5 @@ +M:malloc +F:G$init_dynamic_memory$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$malloc$0$0({2}DF,DX,SV:S),C,0,0,0,0,0 +F:G$free$0$0({2}DF,SV:S),C,0,0,0,0,0 +S:Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0({2}DX,STMAH:S),F,0,0 diff --git a/device/lib/large/malloc.rel b/device/lib/large/malloc.rel new file mode 100644 index 00000000..bd34f5a5 --- /dev/null +++ b/device/lib/large/malloc.rel @@ -0,0 +1,614 @@ +;!FILE malloc.asm +XH +H 8 areas 1A2 global symbols +M malloc +A _CODE size 0 flags 0 +A DSEG size 4 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size C flags 40 +S Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0 Def0000 +S _init_dynamic_memory_PARM_2 Def0002 +A GSINIT size 0 flags 20 +A CSEG size 236 flags 20 +S A$malloc$582 Def022F +S A$malloc$546 Def0208 +S A$malloc$528 Def01F6 +S A$malloc$519 Def01ED +S A$malloc$492 Def01CB +S A$malloc$474 Def01BD +S A$malloc$465 Def01B5 +S A$malloc$456 Def01AA +S A$malloc$447 Def01A2 +S A$malloc$438 Def0198 +S A$malloc$384 Def015C +S A$malloc$375 Def0151 +S A$malloc$348 Def0131 +S A$malloc$339 Def0127 +S A$malloc$294 Def00EB +S A$malloc$285 Def00E0 +S A$malloc$276 Def00D8 +S A$malloc$267 Def00CB +S A$malloc$258 Def00C1 +S A$malloc$249 Def00B6 +S A$malloc$195 Def0082 +S A$malloc$186 Def0079 +S A$malloc$177 Def0070 +S A$malloc$168 Def0068 +S A$malloc$159 Def005E +S A$malloc$592 Def0235 +S A$malloc$574 Def0225 +S A$malloc$565 Def021C +S A$malloc$556 Def0213 +S A$malloc$547 Def0209 +S A$malloc$538 Def01FF +S A$malloc$529 Def01F7 +S A$malloc$493 Def01CD +S A$malloc$475 Def01BE +S A$malloc$466 Def01B6 +S A$malloc$457 Def01AC +S A$malloc$448 Def01A3 +S A$malloc$439 Def0199 +S A$malloc$394 Def0167 +S A$malloc$376 Def0154 +S A$malloc$358 Def013B +S A$malloc$349 Def0132 +S A$malloc$295 Def00EC +S A$malloc$286 Def00E1 +S A$malloc$277 Def00D9 +S A$malloc$268 Def00CE +S A$malloc$259 Def00C2 +S A$malloc$196 Def0083 +S A$malloc$187 Def007A +S A$malloc$178 Def0072 +S A$malloc$169 Def006A +S _free Def01C4 +S A$malloc$566 Def021D +S A$malloc$557 Def0214 +S A$malloc$548 Def020A +S A$malloc$494 Def01CE +S A$malloc$476 Def01BF +S A$malloc$467 Def01B7 +S A$malloc$458 Def01AD +S A$malloc$449 Def01A5 +S A$malloc$395 Def0169 +S A$malloc$386 Def015D +S A$malloc$377 Def0155 +S A$malloc$368 Def0148 +S A$malloc$359 Def013C +S A$malloc$296 Def00EE +S A$malloc$287 Def00E2 +S A$malloc$278 Def00DA +S A$malloc$269 Def00CF +S A$malloc$197 Def0084 +S A$malloc$188 Def007B +S A$malloc$179 Def0073 +S A$malloc$585 Def0231 +S A$malloc$567 Def021E +S A$malloc$549 Def020C +S A$malloc$495 Def01D0 +S A$malloc$477 Def01C1 +S A$malloc$396 Def016A +S A$malloc$387 Def015E +S A$malloc$378 Def0156 +S A$malloc$369 Def014A +S A$malloc$288 Def00E3 +S A$malloc$189 Def007C +S A$malloc$586 Def0232 +S A$malloc$577 Def0227 +S A$malloc$568 Def0220 +S A$malloc$559 Def0215 +S A$malloc$496 Def01D1 +S A$malloc$469 Def01B8 +S A$malloc$397 Def016B +S A$malloc$388 Def015F +S A$malloc$379 Def0157 +S A$malloc$298 Def00F0 +S A$malloc$289 Def00E5 +S A$malloc$587 Def0233 +S A$malloc$578 Def0229 +S A$malloc$569 Def0221 +S A$malloc$398 Def016D +S A$malloc$389 Def0160 +S A$malloc$299 Def00F2 +S A$malloc$588 Def0234 +S A$malloc$579 Def022A +S A$malloc$498 Def01D2 +S A$malloc$489 Def01C4 +S A$malloc$399 Def016E +S A$malloc$499 Def01D5 +S C$malloc.c$64$1$1 Def008A +S A$malloc$80 Def0000 +S A$malloc$90 Def0011 +S A$malloc$81 Def0002 +S A$malloc$91 Def0012 +S A$malloc$82 Def0004 +S A$malloc$92 Def0013 +S A$malloc$83 Def0007 +S A$malloc$93 Def0014 +S A$malloc$84 Def0009 +S XG$free$0$0 Def0235 +S A$malloc$85 Def000A +S A$malloc$95 Def0015 +S A$malloc$86 Def000C +S _init_dynamic_memory Def0000 +S A$malloc$96 Def0016 +S A$malloc$87 Def000D +S A$malloc$98 Def0017 +S A$malloc$89 Def000E +S G$free$0$0 Def01C4 +S _malloc Def008B +S XG$init_dynamic_memory$0$0 Def008A +S XG$malloc$0$0 Def01C3 +S G$init_dynamic_memory$0$0 Def0000 +S G$malloc$0$0 Def008B +S C$malloc.c$102$1$1 Def01C3 +S A$malloc$200 Def0086 +S A$malloc$101 Def0019 +S A$malloc$300 Def00F4 +S A$malloc$201 Def0087 +S A$malloc$111 Def0024 +S A$malloc$102 Def001C +S A$malloc$310 Def00FF +S A$malloc$301 Def00F6 +S A$malloc$220 Def0095 +S A$malloc$202 Def0088 +S A$malloc$130 Def003C +S A$malloc$121 Def0031 +S A$malloc$112 Def0027 +S A$malloc$103 Def001E +S A$malloc$500 Def01D6 +S A$malloc$410 Def017A +S A$malloc$401 Def016F +S A$malloc$320 Def010F +S A$malloc$311 Def0101 +S A$malloc$302 Def00F8 +S A$malloc$230 Def00A1 +S A$malloc$221 Def0097 +S A$malloc$203 Def0089 +S A$malloc$140 Def0048 +S A$malloc$131 Def003D +S A$malloc$122 Def0034 +S A$malloc$113 Def0028 +S A$malloc$104 Def001F +S A$malloc$510 Def01E0 +S A$malloc$501 Def01D7 +S A$malloc$420 Def0185 +S A$malloc$411 Def017B +S A$malloc$402 Def0171 +S A$malloc$330 Def011D +S A$malloc$321 Def0111 +S A$malloc$312 Def0102 +S A$malloc$303 Def00F9 +S A$malloc$240 Def00B0 +S A$malloc$231 Def00A3 +S A$malloc$222 Def0098 +S A$malloc$150 Def0053 +S A$malloc$132 Def003E +S A$malloc$123 Def0035 +S A$malloc$114 Def0029 +S A$malloc$520 Def01EE +S A$malloc$511 Def01E1 +S A$malloc$502 Def01D8 +S A$malloc$430 Def018F +S A$malloc$403 Def0173 +S A$malloc$331 Def011E +S A$malloc$322 Def0112 +S A$malloc$304 Def00FA +S A$malloc$250 Def00B9 +S A$malloc$241 Def00B1 +S A$malloc$232 Def00A5 +S A$malloc$160 Def005F +S A$malloc$151 Def0054 +S A$malloc$142 Def0049 +S A$malloc$133 Def003F +S A$malloc$124 Def0036 +S A$malloc$115 Def002A +S A$malloc$106 Def0020 +S A$malloc$530 Def01F9 +S A$malloc$521 Def01EF +S A$malloc$512 Def01E3 +S A$malloc$440 Def019A +S A$malloc$431 Def0190 +S A$malloc$422 Def0186 +S A$malloc$413 Def017D +S A$malloc$404 Def0174 +S A$malloc$341 Def0129 +S A$malloc$332 Def011F +S A$malloc$323 Def0113 +S A$malloc$314 Def0104 +S A$malloc$305 Def00FB +S A$malloc$260 Def00C3 +S A$malloc$233 Def00A7 +S A$malloc$224 Def0099 +S A$malloc$215 Def008B +S A$malloc$161 Def0061 +S A$malloc$152 Def0055 +S A$malloc$143 Def004C +S A$malloc$134 Def0040 +S A$malloc$125 Def0037 +S A$malloc$116 Def002B +S A$malloc$107 Def0021 +S C$malloc.c$118$2$1 Def0235 +S A$malloc$531 Def01FA +S A$malloc$513 Def01E4 +S A$malloc$504 Def01D9 +S A$malloc$450 Def01A6 +S A$malloc$441 Def019B +S A$malloc$423 Def0188 +S A$malloc$414 Def017E +S A$malloc$405 Def0175 +S A$malloc$360 Def013D +S A$malloc$351 Def0133 +S A$malloc$333 Def0120 +S A$malloc$324 Def0115 +S A$malloc$315 Def0105 +S A$malloc$306 Def00FC +S A$malloc$270 Def00D0 +S A$malloc$261 Def00C6 +S A$malloc$243 Def00B2 +S A$malloc$234 Def00A9 +S A$malloc$225 Def009C +S A$malloc$216 Def008D +S A$malloc$207 Def008A +S A$malloc$162 Def0063 +S A$malloc$153 Def0056 +S A$malloc$144 Def004D +S A$malloc$135 Def0041 +S A$malloc$126 Def0038 +S A$malloc$117 Def002C +S A$malloc$108 Def0022 +S A$malloc$550 Def020E +S A$malloc$541 Def0201 +S A$malloc$532 Def01FB +S A$malloc$523 Def01F0 +S A$malloc$514 Def01E5 +S A$malloc$505 Def01DA +S A$malloc$460 Def01AF +S A$malloc$451 Def01A7 +S A$malloc$442 Def019C +S A$malloc$433 Def0191 +S A$malloc$424 Def018A +S A$malloc$415 Def017F +S A$malloc$406 Def0176 +S A$malloc$361 Def013F +S A$malloc$352 Def0135 +S A$malloc$334 Def0121 +S A$malloc$325 Def0116 +S A$malloc$316 Def0106 +S A$malloc$307 Def00FD +S A$malloc$271 Def00D1 +S A$malloc$262 Def00C7 +S A$malloc$253 Def00BC +S A$malloc$244 Def00B3 +S A$malloc$235 Def00AA +S A$malloc$226 Def009D +S A$malloc$217 Def008F +S A$malloc$181 Def0075 +S A$malloc$172 Def006C +S A$malloc$163 Def0064 +S A$malloc$154 Def0057 +S A$malloc$145 Def004E +S A$malloc$136 Def0044 +S A$malloc$118 Def002D +S A$malloc$109 Def0023 +S A$malloc$551 Def020F +S A$malloc$542 Def0203 +S A$malloc$533 Def01FC +S A$malloc$524 Def01F2 +S A$malloc$515 Def01E7 +S A$malloc$506 Def01DB +S A$malloc$470 Def01BA +S A$malloc$461 Def01B0 +S A$malloc$452 Def01A8 +S A$malloc$443 Def019E +S A$malloc$425 Def018B +S A$malloc$416 Def0181 +S A$malloc$407 Def0177 +S A$malloc$380 Def0158 +S A$malloc$371 Def014C +S A$malloc$353 Def0137 +S A$malloc$344 Def012B +S A$malloc$335 Def0122 +S A$malloc$326 Def0117 +S A$malloc$317 Def0108 +S A$malloc$308 Def00FE +S A$malloc$290 Def00E7 +S A$malloc$272 Def00D2 +S A$malloc$263 Def00C8 +S A$malloc$254 Def00BE +S A$malloc$236 Def00AC +S A$malloc$227 Def009E +S A$malloc$218 Def0092 +S A$malloc$191 Def007D +S A$malloc$182 Def0076 +S A$malloc$173 Def006D +S A$malloc$164 Def0065 +S A$malloc$155 Def0058 +S A$malloc$146 Def004F +S A$malloc$137 Def0045 +S A$malloc$119 Def0030 +S A$malloc$570 Def0222 +S A$malloc$561 Def0217 +S A$malloc$552 Def0210 +S A$malloc$543 Def0205 +S A$malloc$525 Def01F3 +S A$malloc$516 Def01E8 +S A$malloc$507 Def01DD +S A$malloc$471 Def01BB +S A$malloc$462 Def01B1 +S A$malloc$453 Def01A9 +S A$malloc$444 Def019F +S A$malloc$435 Def0193 +S A$malloc$426 Def018C +S A$malloc$417 Def0182 +S A$malloc$390 Def0162 +S A$malloc$354 Def0138 +S A$malloc$345 Def012E +S A$malloc$336 Def0123 +S A$malloc$327 Def0119 +S A$malloc$318 Def010B +S A$malloc$291 Def00E8 +S A$malloc$282 Def00DB +S A$malloc$273 Def00D3 +S A$malloc$264 Def00C9 +S A$malloc$255 Def00BF +S A$malloc$246 Def00B4 +S A$malloc$237 Def00AD +S A$malloc$228 Def009F +S A$malloc$219 Def0094 +S A$malloc$192 Def007F +S A$malloc$183 Def0077 +S A$malloc$174 Def006E +S A$malloc$165 Def0066 +S A$malloc$156 Def005A +S A$malloc$147 Def0050 +S A$malloc$138 Def0046 +S A$malloc$129 Def0039 +S A$malloc$580 Def022C +S A$malloc$571 Def0223 +S A$malloc$562 Def0219 +S A$malloc$553 Def0211 +S A$malloc$544 Def0206 +S A$malloc$535 Def01FD +S A$malloc$517 Def01EB +S A$malloc$490 Def01C6 +S A$malloc$481 Def01C3 +S A$malloc$463 Def01B3 +S A$malloc$436 Def0195 +S A$malloc$427 Def018D +S A$malloc$418 Def0183 +S A$malloc$409 Def0178 +S A$malloc$391 Def0164 +S A$malloc$382 Def0159 +S A$malloc$364 Def0142 +S A$malloc$355 Def0139 +S A$malloc$346 Def012F +S A$malloc$337 Def0124 +S A$malloc$328 Def011A +S A$malloc$319 Def010E +S A$malloc$292 Def00E9 +S A$malloc$283 Def00DE +S A$malloc$274 Def00D6 +S A$malloc$265 Def00CA +S A$malloc$238 Def00AF +S A$malloc$229 Def00A0 +S A$malloc$193 Def0080 +S A$malloc$175 Def006F +S A$malloc$166 Def0067 +S A$malloc$157 Def005B +S A$malloc$148 Def0051 +S A$malloc$139 Def0047 +S A$malloc$581 Def022E +S A$malloc$572 Def0224 +S A$malloc$563 Def021A +S A$malloc$554 Def0212 +S A$malloc$545 Def0207 +S A$malloc$536 Def01FE +S A$malloc$527 Def01F5 +S A$malloc$518 Def01EC +S A$malloc$491 Def01C8 +S A$malloc$473 Def01BC +S A$malloc$464 Def01B4 +S A$malloc$446 Def01A1 +S A$malloc$437 Def0197 +S A$malloc$428 Def018E +S A$malloc$419 Def0184 +S A$malloc$383 Def015B +S A$malloc$374 Def014E +S A$malloc$365 Def0145 +S A$malloc$356 Def013A +S A$malloc$347 Def0130 +S A$malloc$338 Def0125 +S A$malloc$329 Def011B +S A$malloc$293 Def00EA +S A$malloc$284 Def00DF +S A$malloc$275 Def00D7 +S A$malloc$257 Def00C0 +S A$malloc$158 Def005C +S A$malloc$149 Def0052 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 83 C0 82 90 00 04 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 0E 90 00 04 E0 FA A3 E0 FB 4A 70 20 +R 00 00 00 07 00 03 00 05 +T 00 19 +R 00 00 00 07 +T 00 19 90 00 04 74 01 2A F0 E4 3B A3 F0 90 00 02 +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 00 27 E0 FA A3 E0 FB 1A BA FF 01 1B +R 00 00 00 07 +T 00 31 +R 00 00 00 07 +T 00 31 90 00 02 EA F0 A3 EB F0 +R 00 00 00 07 00 03 00 05 +T 00 39 +R 00 00 00 07 +T 00 39 90 00 04 E0 FA A3 E0 FB 90 00 00 EA F0 A3 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 00 47 EB F0 90 00 02 E0 FC A3 E0 FD EC 2A FC ED +R 00 00 00 07 00 05 00 05 +T 00 55 3B FD EC 24 FA FC ED 34 FF FD 8A 82 8B 83 +R 00 00 00 07 +T 00 63 EC F0 A3 ED F0 8C 82 8D 83 E4 F0 A3 F0 74 +R 00 00 00 07 +T 00 71 02 2A F5 82 E4 3B F5 83 E4 F0 A3 F0 74 04 +R 00 00 00 07 +T 00 7F 2A F5 82 E4 3B F5 83 E4 F0 A3 F0 +R 00 00 00 07 +T 00 8A +R 00 00 00 07 +T 00 8A 22 +R 00 00 00 07 +T 00 8B +R 00 00 00 07 +T 00 8B C0 83 C0 82 90 00 06 D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 00 99 90 00 06 E0 FA A3 E0 FB 8A 04 8B 05 7E 00 +R 00 00 00 07 00 03 00 05 +T 00 A7 7F 00 C3 74 F9 9C 74 FF 9D E4 9E E4 9F 50 +R 00 00 00 07 +T 00 B5 06 +R 00 00 00 07 +T 00 B6 +R 00 00 00 07 +T 00 B6 90 00 00 02 01 C3 +R 00 00 00 07 00 06 00 07 +T 00 BC +R 00 00 00 07 +T 00 BC 74 06 2A FA E4 3B FB 90 00 06 EA F0 A3 EB +R 00 00 00 07 00 0A 00 05 +T 00 CA F0 90 00 00 E0 FC A3 E0 FD 90 00 08 EC F0 +R 00 00 00 07 00 04 00 05 00 0C 00 05 +T 00 D8 A3 ED F0 +R 00 00 00 07 +T 00 DB +R 00 00 00 07 +T 00 DB 90 00 08 E0 FC A3 E0 FD 8C 82 8D 83 E0 FE +R 00 00 00 07 00 03 00 05 +T 00 E9 A3 E0 FF 8E 00 8F 01 C0 06 C0 07 8C 06 8D +R 00 00 00 07 +T 00 F7 07 C3 E8 9E F8 E9 9F F9 74 04 2C F5 00 00 +R 00 00 00 07 29 0E 00 01 +T 01 04 E4 3D F5 00 01 85 00 00 82 85 00 01 83 E0 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 01 0F F5 00 02 A3 E0 F5 00 03 C3 E8 95 00 02 F8 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 01 1A E9 95 00 03 F9 C3 E8 9A E9 9B E4 33 D0 07 +R 00 00 00 07 29 04 00 01 +T 01 27 D0 06 60 1D +R 00 00 00 07 +T 01 2B +R 00 00 00 07 +T 01 2B 90 00 08 EE F0 A3 EF F0 8E 82 8F 83 E0 F8 +R 00 00 00 07 00 03 00 05 +T 01 39 A3 E0 F9 48 60 03 02 00 DB +R 00 00 00 07 00 09 00 07 +T 01 42 +R 00 00 00 07 +T 01 42 90 00 00 02 01 C3 +R 00 00 00 07 00 06 00 07 +T 01 48 +R 00 00 00 07 +T 01 48 E5 00 02 45 00 03 70 19 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 01 4E +R 00 00 00 07 +T 01 4E 85 00 00 82 85 00 01 83 EA F0 A3 EB F0 74 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 01 5A 06 2C F8 E4 3D F9 88 82 89 83 02 01 C3 +R 00 00 00 07 00 0D 00 07 +T 01 67 +R 00 00 00 07 +T 01 67 E5 00 02 2C F8 E5 00 03 3D F9 88 82 89 83 +R 00 00 00 07 29 03 00 01 29 08 00 01 +T 01 73 EE F0 A3 EF F0 74 02 28 F5 82 E4 39 F5 83 +R 00 00 00 07 +T 01 81 EC F0 A3 ED F0 8C 82 8D 83 E8 F0 A3 E9 F0 +R 00 00 00 07 +T 01 8F EE 4F 60 17 +R 00 00 00 07 +T 01 93 +R 00 00 00 07 +T 01 93 88 82 89 83 E0 FC A3 E0 FD 74 02 2C F5 82 +R 00 00 00 07 +T 01 A1 E4 3D F5 83 E8 F0 A3 E9 F0 +R 00 00 00 07 +T 01 AA +R 00 00 00 07 +T 01 AA 74 04 28 F5 82 E4 39 F5 83 EA F0 A3 EB F0 +R 00 00 00 07 +T 01 B8 74 06 28 F8 E4 39 F9 88 82 89 83 +R 00 00 00 07 +T 01 C3 +R 00 00 00 07 +T 01 C3 22 +R 00 00 00 07 +T 01 C4 +R 00 00 00 07 +T 01 C4 C0 83 C0 82 90 00 0A D0 E0 F0 D0 E0 A3 F0 +R 00 00 00 07 00 07 00 05 +T 01 D2 90 00 0A E0 FA A3 E0 FB 4A 70 03 02 02 35 +R 00 00 00 07 00 03 00 05 00 0E 00 07 +T 01 E0 +R 00 00 00 07 +T 01 E0 EA 24 FA FC EB 34 FF FD 90 00 0A EC F0 A3 +R 00 00 00 07 00 0B 00 05 +T 01 EE ED F0 74 02 2C F5 82 E4 3D F5 83 E0 FE A3 +R 00 00 00 07 +T 01 FC E0 FF 4E 60 26 +R 00 00 00 07 +T 02 01 +R 00 00 00 07 +T 02 01 8C 82 8D 83 E0 FC A3 E0 FD 8E 82 8F 83 EC +R 00 00 00 07 +T 02 0F F0 A3 ED F0 EC 4D 60 1E +R 00 00 00 07 +T 02 17 +R 00 00 00 07 +T 02 17 74 02 2C F5 82 E4 3D F5 83 EE F0 A3 EF F0 +R 00 00 00 07 +T 02 25 80 0E +R 00 00 00 07 +T 02 27 +R 00 00 00 07 +T 02 27 74 FE 2A F5 82 74 FF 3B F5 83 E4 F0 A3 F0 +R 00 00 00 07 +T 02 35 +R 00 00 00 07 +T 02 35 22 +R 00 00 00 07 diff --git a/device/lib/large/printf_large.cdb b/device/lib/large/printf_large.cdb new file mode 100644 index 00000000..fffbe4f8 --- /dev/null +++ b/device/lib/large/printf_large.cdb @@ -0,0 +1 @@ +M:printf_large diff --git a/device/lib/large/printfl.asm b/device/lib/large/printfl.asm new file mode 100644 index 00000000..1d0b6db4 --- /dev/null +++ b/device/lib/large/printfl.asm @@ -0,0 +1,1384 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:37 2000 + +;-------------------------------------------------------- + .module printfl +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _printf_small +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +Fprintfl$ch$0$0==. +_ch: + .ds 0x0001 +Fprintfl$radix$0$0==. +_radix: + .ds 0x0001 +Fprintfl$str$0$0==. +_str: + .ds 0x0003 +Fprintfl$val$0$0==. +_val: + .ds 0x0004 +_pvaloct_sloc0_1_0: + .ds 0x0004 +_printf_small_sloc0_1_0: + .ds 0x0001 +_printf_small_sloc1_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +Fprintfl$long_flag$0$0==. +_long_flag: + .ds 0x0001 +Fprintfl$string_flag$0$0==. +_string_flag: + .ds 0x0001 +Fprintfl$short_flag$0$0==. +_short_flag: + .ds 0x0001 +Fprintfl$sign$0$0==. +_sign: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_pvalhex_val_1_1: + .ds 0x0004 +_pvalhex_sp_1_1: + .ds 0x0001 +_pvalhex_lval_1_1: + .ds 0x0004 +_pvaloct_val_1_1: + .ds 0x0004 +_pvaloct_lval_1_1: + .ds 0x0004 +_pvaldec_val_1_1: + .ds 0x0004 +_pvaldec_lval_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) + G$printf_small$0$0 ==. +; printfl.c 215 + clr _long_flag + G$printf_small$0$0 ==. +; printfl.c 215 + clr _string_flag + G$printf_small$0$0 ==. +; printfl.c 215 + clr _short_flag +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + Fprintfl$pvalhex$0$0 ==. +; printfl.c 53 +; ----------------------------------------- +; function pvalhex +; ----------------------------------------- +_pvalhex: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; printfl.c 0 + push acc + push b + push dph + push dpl + mov dptr,#_pvalhex_val_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; printfl.c 55 + mov dptr,#_pvalhex_sp_1_1 + mov a,_SP + movx @dptr,a +; printfl.c 56 + mov dptr,#_pvalhex_val_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#_pvalhex_lval_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; printfl.c 58 +; Peephole 112 removed ljmp by inverse jump logic + jb _long_flag,00102$ +00119$: +; printfl.c 59 + mov dptr,#_pvalhex_lval_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +00102$: +; printfl.c 61 +; Peephole 111 removed ljmp by inverse jump logic + jnb _short_flag,00116$ +00120$: +; printfl.c 62 + mov dptr,#_pvalhex_lval_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#_pvalhex_lval_1_1 + mov a,r2 + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; printfl.c 64 +00116$: +00105$: + mov dptr,#_pvalhex_lval_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + inc dptr + movx a,@dptr + mov r0,a + mov a,r2 + orl a,r6 + orl a,r7 + orl a,r0 + jnz 00121$ + ljmp 00108$ +00121$: +; printfl.c 65 + mov ar1,r2 + anl ar1,#0x0f + mov a,r1 +; Peephole 180 changed mov to clr +; Peephole 186 optimized movc sequence + mov dptr,#__str_0 + movc a,@a+dptr + mov _ch,a +; printfl.c 66 + push _ch +; printfl.c 67 + mov a,r6 + swap a + xch a,r2 + swap a + anl a,#0x0f + xrl a,r2 + xch a,r2 + anl a,#0x0f + xch a,r2 + xrl a,r2 + xch a,r2 + mov r6,a + mov a,r7 + swap a + anl a,#0xf0 + orl a,r6 + mov r6,a + mov a,r0 + swap a + xch a,r7 + swap a + anl a,#0x0f + xrl a,r7 + xch a,r7 + anl a,#0x0f + xch a,r7 + xrl a,r7 + xch a,r7 + mov r0,a + mov dptr,#_pvalhex_lval_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + ljmp 00105$ +; printfl.c 70 +00108$: + mov dptr,#_pvalhex_sp_1_1 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + cjne a,_SP,00122$ +; Peephole 132 changed ljmp to sjmp + sjmp 00111$ +00122$: +; printfl.c 71 + pop _ch +; printfl.c 72 + mov dpl,_ch + lcall _putchar +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00111$: + C$printfl.c$75$1$1 ==. + XFprintfl$pvalhex$0$0 ==. + ret + Fprintfl$pvaloct$0$0 ==. +; printfl.c 77 +; ----------------------------------------- +; function pvaloct +; ----------------------------------------- +_pvaloct: +; printfl.c 0 + push acc + push b + push dph + push dpl + mov dptr,#_pvaloct_val_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; printfl.c 81 +; printfl.c 82 + mov dptr,#_pvaloct_val_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00102$ +00126$: +; printfl.c 83 + mov dptr,#_pvaloct_lval_1_1 + clr c + clr a + subb a,r3 + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a + clr a + subb a,r6 + inc dptr + movx @dptr,a +; printfl.c 84 + setb _sign +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: +; printfl.c 86 + mov dptr,#_pvaloct_lval_1_1 + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a +; printfl.c 87 + clr _sign +00103$: +; printfl.c 90 +; Peephole 112 removed ljmp by inverse jump logic + jb _long_flag,00105$ +00127$: +; printfl.c 91 + mov dptr,#_pvaloct_lval_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + mov dptr,#_pvaloct_lval_1_1 + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +00105$: +; printfl.c 92 +; Peephole 111 removed ljmp by inverse jump logic + jnb _short_flag,00108$ +00128$: +; printfl.c 93 + mov dptr,#_pvaloct_lval_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + mov dptr,#_pvaloct_lval_1_1 + mov a,r3 + movx @dptr,a + inc dptr +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a + inc dptr +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; printfl.c 95 +00108$: + mov dptr,#_pvaloct_lval_1_1 + movx a,@dptr + mov _pvaloct_sloc0_1_0,a + inc dptr + movx a,@dptr + mov (_pvaloct_sloc0_1_0 + 1),a + inc dptr + movx a,@dptr + mov (_pvaloct_sloc0_1_0 + 2),a + inc dptr + movx a,@dptr + mov (_pvaloct_sloc0_1_0 + 3),a + mov a,_pvaloct_sloc0_1_0 + orl a,(_pvaloct_sloc0_1_0 + 1) + orl a,(_pvaloct_sloc0_1_0 + 2) + orl a,(_pvaloct_sloc0_1_0 + 3) + jnz 00129$ + ljmp 00110$ +00129$: +; printfl.c 96 + mov dptr,#__modulong_PARM_2 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + mov a,#0x08 + movx @dptr,a + mov dpl,_pvaloct_sloc0_1_0 + mov dph,(_pvaloct_sloc0_1_0 + 1) + mov b,(_pvaloct_sloc0_1_0 + 2) + mov a,(_pvaloct_sloc0_1_0 + 3) + lcall __modulong + mov r2,dpl + mov r3,dph + mov r7,b + mov r0,a + mov a,#0x30 + add a,r2 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r3,a +; Peephole 180 changed mov to clr + clr a + addc a,r7 + mov r7,a +; Peephole 180 changed mov to clr + clr a + addc a,r0 + mov r0,a + mov _ch,r2 +; printfl.c 97 + push _ch +; printfl.c 98 + mov r2,_pvaloct_sloc0_1_0 + mov a,(_pvaloct_sloc0_1_0 + 1) + swap a + rl a + xch a,r2 + swap a + rl a + anl a,#0x1f + xrl a,r2 + xch a,r2 + anl a,#0x1f + xch a,r2 + xrl a,r2 + xch a,r2 + mov r3,a + mov a,(_pvaloct_sloc0_1_0 + 2) + swap a + rl a + anl a,#0xe0 + orl a,r3 + mov r3,a + mov r7,(_pvaloct_sloc0_1_0 + 2) + mov a,(_pvaloct_sloc0_1_0 + 3) + swap a + rl a + xch a,r7 + swap a + rl a + anl a,#0x1f + xrl a,r7 + xch a,r7 + anl a,#0x1f + xch a,r7 + xrl a,r7 + xch a,r7 + mov r0,a + mov dptr,#_pvaloct_lval_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + inc dptr + mov a,r0 + movx @dptr,a + ljmp 00108$ +00110$: +; printfl.c 101 +; Peephole 111 removed ljmp by inverse jump logic + jnb _sign,00113$ +00130$: +; printfl.c 102 + mov _ch,#0x2d +; printfl.c 103 + push _ch +; printfl.c 107 +00113$: + mov a,_SP + cjne a,_SP,00131$ +; Peephole 132 changed ljmp to sjmp + sjmp 00116$ +00131$: +; printfl.c 108 + pop _ch +; printfl.c 109 + mov dpl,_ch + lcall _putchar +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00116$: + C$printfl.c$111$1$1 ==. + XFprintfl$pvaloct$0$0 ==. + ret + Fprintfl$pvaldec$0$0 ==. +; printfl.c 113 +; ----------------------------------------- +; function pvaldec +; ----------------------------------------- +_pvaldec: +; printfl.c 0 + push acc + push b + push dph + push dpl + mov dptr,#_pvaldec_val_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; printfl.c 117 +; printfl.c 118 + mov dptr,#_pvaldec_val_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00102$ +00120$: +; printfl.c 119 + mov dptr,#_pvaldec_lval_1_1 + clr c + clr a + subb a,r3 + movx @dptr,a + clr a + subb a,r4 + inc dptr + movx @dptr,a + clr a + subb a,r5 + inc dptr + movx @dptr,a + clr a + subb a,r6 + inc dptr + movx @dptr,a +; printfl.c 120 + setb _sign +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; printfl.c 122 + mov dptr,#_pvaldec_lval_1_1 + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a +; printfl.c 123 + clr _sign +; printfl.c 126 +00104$: + mov dptr,#_pvaldec_lval_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + inc dptr + movx a,@dptr + mov r6,a + mov a,r3 + orl a,r4 + orl a,r5 + orl a,r6 + jnz 00121$ + ljmp 00106$ +00121$: +; printfl.c 127 + mov dptr,#__modulong_PARM_2 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + mov a,#0x0a + movx @dptr,a + push ar3 + push ar4 + push ar5 + push ar6 + mov dpl,r3 + mov dph,r4 + mov b,r5 + mov a,r6 + lcall __modulong + mov r7,dpl + mov r0,dph + mov r1,b + mov r2,a + pop ar6 + pop ar5 + pop ar4 + pop ar3 + mov a,#0x30 + add a,r7 + mov r7,a +; Peephole 180 changed mov to clr + clr a + addc a,r0 + mov r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r1 + mov r1,a +; Peephole 180 changed mov to clr + clr a + addc a,r2 + mov r2,a + mov _ch,r7 +; printfl.c 128 + push _ch +; printfl.c 129 + mov dptr,#__divulong_PARM_2 + clr a + inc dptr + inc dptr + inc dptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + movx @dptr,a + lcall __decdptr + mov a,#0x0a + movx @dptr,a + mov dpl,r3 + mov dph,r4 + mov b,r5 + mov a,r6 + lcall __divulong + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a + mov dptr,#_pvaldec_lval_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + ljmp 00104$ +00106$: +; printfl.c 132 +; Peephole 111 removed ljmp by inverse jump logic + jnb _sign,00109$ +00122$: +; printfl.c 133 + mov _ch,#0x2d +; printfl.c 134 + push _ch +; printfl.c 138 +00109$: + mov a,_SP + cjne a,_SP,00123$ +; Peephole 132 changed ljmp to sjmp + sjmp 00112$ +00123$: +; printfl.c 139 + pop _ch +; printfl.c 140 + mov dpl,_ch + lcall _putchar +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00112$: + C$printfl.c$142$1$1 ==. + XFprintfl$pvaldec$0$0 ==. + ret + G$printf_small$0$0 ==. +; printfl.c 144 +; ----------------------------------------- +; function printf_small +; ----------------------------------------- +_printf_small: + push _bp + mov _bp,sp + inc sp +; printfl.c 148 + mov a,_bp + add a,#0xfb + mov r2,a +; Peephole 3.c changed mov to clr + clr a + mov r3,a + mov r4,a +; Peephole 212 reduced add sequence to inc + mov r0,_bp + inc r0 + mov @r0,ar2 +00129$: +; printfl.c 150 + mov a,_bp + add a,#0xfb + mov r0,a + mov ar3,@r0 + inc r0 + mov ar4,@r0 + inc r0 + mov ar5,@r0 + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a + jnz 00154$ + ljmp 00133$ +00154$: +; printfl.c 151 + cjne r6,#0x25,00155$ + sjmp 00156$ +00155$: + ljmp 00127$ +00156$: +; printfl.c 152 + clr _short_flag + clr _string_flag + clr _long_flag +; printfl.c 153 + inc r3 + cjne r3,#0x00,00157$ + inc r4 +00157$: + mov a,_bp + add a,#0xfb + mov r0,a + mov @r0,ar3 + inc r0 + mov @r0,ar4 + inc r0 + mov @r0,ar5 +; printfl.c 154 + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget + mov r7,a + cjne r7,#0x68,00158$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00158$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r7,#0x6c,00103$ +; Peephole 201 removed redundant sjmp +00159$: +00160$: +; printfl.c 156 + setb _long_flag +; printfl.c 157 + mov a,_bp + add a,#0xfb + mov r0,a + mov a,#0x01 + add a,r3 + mov @r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + inc r0 + mov @r0,a + inc r0 + mov @r0,ar5 +; printfl.c 158 +; printfl.c 160 +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: + setb _short_flag +; printfl.c 161 + mov a,_bp + add a,#0xfb + mov r0,a + mov a,#0x01 + add a,r3 + mov @r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + inc r0 + mov @r0,a + inc r0 + mov @r0,ar5 +; printfl.c 162 +00103$: +; printfl.c 164 + mov a,_bp + add a,#0xfb + mov r0,a + mov ar3,@r0 + inc r0 + mov ar4,@r0 + inc r0 + mov ar5,@r0 + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget + mov r3,a + cjne r3,#0x63,00161$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00161$: + cjne r3,#0x64,00162$ +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00162$: + cjne r3,#0x6f,00163$ +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00163$: + cjne r3,#0x73,00164$ +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00164$: +; Peephole 132 changed ljmp to sjmp +; printfl.c 166 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r3,#0x78,00109$ + sjmp 00106$ +00165$: +00104$: + setb _string_flag +; printfl.c 167 +; printfl.c 169 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00105$: + mov _radix,#0x0a +; printfl.c 170 +; printfl.c 172 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00106$: + mov _radix,#0x10 +; printfl.c 173 +; printfl.c 175 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00107$: + mov _radix,#0x00 +; printfl.c 176 +; printfl.c 178 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov _radix,#0x08 +; printfl.c 180 +00109$: +; printfl.c 182 + jb _string_flag,00166$ + ljmp 00114$ +00166$: +; printfl.c 183 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xfd + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov _str,@r0 + inc r0 + mov (_str + 1),@r0 + inc r0 + mov (_str + 2),@r0 + dec r0 + dec r0 +; printfl.c 184 +00110$: + mov _printf_small_sloc1_1_0,_str + mov (_printf_small_sloc1_1_0 + 1),(_str + 1) + mov (_printf_small_sloc1_1_0 + 2),(_str + 2) + mov dpl,_printf_small_sloc1_1_0 + mov dph,(_printf_small_sloc1_1_0 + 1) + mov b,(_printf_small_sloc1_1_0 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov _printf_small_sloc0_1_0,a + jnz 00167$ + ljmp 00131$ +00167$: + mov dpl,_str + mov dph,(_str + 1) + mov b,(_str + 2) + mov a,#0x01 + add a,_str + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,(_str + 1) + mov r7,a + mov r3,(_str + 2) + mov _str,r2 + mov (_str + 1),r7 + mov (_str + 2),r3 + lcall __gptrget + mov r4,a + push ar2 + push ar3 + push ar4 + push ar6 + push ar7 + mov dpl,r4 + lcall _putchar + pop ar7 + pop ar6 + pop ar4 + pop ar3 + pop ar2 +; printfl.c 185 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00114$: +; printfl.c 188 +; Peephole 111 removed ljmp by inverse jump logic + jnb _long_flag,00119$ +00168$: +; printfl.c 189 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xfc + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov _val,@r0 + inc r0 + mov (_val + 1),@r0 + inc r0 + mov (_val + 2),@r0 + inc r0 + mov (_val + 3),@r0 + dec r0 + dec r0 + dec r0 +; Peephole 132 changed ljmp to sjmp + sjmp 00120$ +00119$: +; printfl.c 191 +; Peephole 111 removed ljmp by inverse jump logic + jnb _short_flag,00116$ +00169$: +; printfl.c 192 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xff + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov ar2,@r0 + mov _val,r2 + mov a,r2 + rlc a + subb a,acc + mov (_val + 1),a + mov (_val + 2),a + mov (_val + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00120$ +00116$: +; printfl.c 194 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xfe + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov ar2,@r0 + inc r0 + mov ar3,@r0 + dec r0 + mov _val,r2 + mov (_val + 1),r3 + mov a,r3 + rlc a + subb a,acc + mov (_val + 2),a + mov (_val + 3),a +00120$: +; printfl.c 196 + mov a,_radix +; Peephole 110 removed ljmp by inverse jump logic + jz 00123$ +00170$: + mov a,_radix + cjne a,#0x08,00171$ +; Peephole 132 changed ljmp to sjmp + sjmp 00124$ +00171$: + mov a,_radix + cjne a,#0x0a,00172$ +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00172$: + mov a,_radix +; Peephole 132 changed ljmp to sjmp +; printfl.c 198 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,#0x10,00131$ + sjmp 00122$ +00173$: +00121$: + push ar6 + mov dpl,_val + mov dph,(_val + 1) + mov b,(_val + 2) + mov a,(_val + 3) + lcall _pvaldec + pop ar6 +; printfl.c 199 +; printfl.c 201 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00122$: + push ar6 + mov dpl,_val + mov dph,(_val + 1) + mov b,(_val + 2) + mov a,(_val + 3) + lcall _pvalhex + pop ar6 +; printfl.c 202 +; printfl.c 204 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00123$: + mov r2,_val + push ar6 + mov dpl,r2 + lcall _putchar + pop ar6 +; printfl.c 205 +; printfl.c 207 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00124$: + push ar6 + mov dpl,_val + mov dph,(_val + 1) + mov b,(_val + 2) + mov a,(_val + 3) + lcall _pvaloct + pop ar6 +; printfl.c 209 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00127$: +; printfl.c 212 + mov dpl,r6 + lcall _putchar +00131$: +; printfl.c 150 + mov a,_bp + add a,#0xfb + mov r0,a + inc @r0 + cjne @r0,#0x00,00174$ + inc r0 + inc @r0 +00174$: + ljmp 00129$ +00133$: + mov sp,_bp + pop _bp + C$printfl.c$214$1$1 ==. + XG$printf_small$0$0 ==. + ret + .area CSEG (CODE) +Fprintfl$_str_0$0$0 == . +__str_0: + .ascii /0123456789ABCDEF/ + .byte 0 diff --git a/device/lib/large/printfl.cdb b/device/lib/large/printfl.cdb new file mode 100644 index 00000000..88a9e658 --- /dev/null +++ b/device/lib/large/printfl.cdb @@ -0,0 +1,100 @@ +M:printfl +F:Fprintfl$pvalhex$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fprintfl$pvaloct$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fprintfl$pvaldec$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$ch$0$0({1}SC:S),E,0,0 +S:Fprintfl$radix$0$0({1}SC:S),E,0,0 +S:Fprintfl$str$0$0({3}DG,SC:S),E,0,0 +S:Fprintfl$val$0$0({4}SL:S),E,0,0 +S:Fprintfl$long_flag$0$0({1}SB0$1:S),H,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$string_flag$0$0({1}SB0$1:S),H,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$short_flag$0$0({1}SB0$1:S),H,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$sign$0$0({1}SB0$1:S),H,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 +S:Fprintfl$_str_0$0$0({17}DA17,SC:S),D,0,0 diff --git a/device/lib/large/printfl.rel b/device/lib/large/printfl.rel new file mode 100644 index 00000000..e2021bcb --- /dev/null +++ b/device/lib/large/printfl.rel @@ -0,0 +1,1475 @@ +;!FILE printfl.asm +XH +H 8 areas 3AD global symbols +M printfl +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S __modulong_PARM_2 Ref0000 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S __divulong_PARM_2 Ref0000 +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S _putchar Ref0000 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S __modulong Ref0000 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S __decdptr Ref0000 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S __divulong Ref0000 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S _bp Ref0000 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 11 flags 0 +S Fprintfl$radix$0$0 Def0001 +S Fprintfl$str$0$0 Def0002 +S Fprintfl$val$0$0 Def0005 +S Fprintfl$ch$0$0 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 4 flags 80 +S Fprintfl$string_flag$0$0 Def0001 +S Fprintfl$short_flag$0$0 Def0002 +S Fprintfl$long_flag$0$0 Def0000 +S Fprintfl$sign$0$0 Def0003 +A XSEG size 19 flags 40 +A GSINIT size 6 flags 20 +S A$printfl$253 Def0000 +S A$printfl$256 Def0002 +S A$printfl$259 Def0004 +A CSEG size 543 flags 20 +S A$printfl$800 Def024C +S A$printfl$710 Def01EC +S A$printfl$701 Def01E1 +S A$printfl$620 Def016D +S A$printfl$611 Def0163 +S A$printfl$602 Def015D +S A$printfl$521 Def010C +S A$printfl$503 Def00FA +S A$printfl$440 Def00B6 +S A$printfl$431 Def00AA +S A$printfl$422 Def009F +S A$printfl$413 Def0095 +S A$printfl$404 Def008B +S A$printfl$350 Def0053 +S A$printfl$341 Def004B +S A$printfl$332 Def0044 +S A$printfl$323 Def003B +S A$printfl$314 Def0032 +S A$printfl$305 Def0027 +S A$printfl$900 Def02C8 +S A$printfl$810 Def0256 +S A$printfl$801 Def024D +S A$printfl$720 Def01F8 +S A$printfl$711 Def01ED +S A$printfl$702 Def01E2 +S A$printfl$630 Def017D +S A$printfl$621 Def016F +S A$printfl$612 Def0164 +S A$printfl$540 Def011F +S A$printfl$531 Def0115 +S A$printfl$522 Def010D +S A$printfl$513 Def0102 +S A$printfl$504 Def00FB +S A$printfl$441 Def00B7 +S A$printfl$432 Def00AB +S A$printfl$423 Def00A1 +S A$printfl$414 Def0096 +S A$printfl$360 Def005D +S A$printfl$351 Def0054 +S A$printfl$333 Def0045 +S A$printfl$315 Def0033 +S A$printfl$306 Def0028 +S A$printfl$910 Def02D6 +S A$printfl$820 Def0260 +S A$printfl$802 Def024E +S A$printfl$721 Def01F9 +S A$printfl$712 Def01EE +S A$printfl$703 Def01E3 +S A$printfl$640 Def018B +S A$printfl$631 Def017F +S A$printfl$622 Def0170 +S A$printfl$541 Def0120 +S A$printfl$523 Def010E +S A$printfl$514 Def0105 +S A$printfl$505 Def00FC +S A$printfl$442 Def00B8 +S A$printfl$433 Def00AD +S A$printfl$424 Def00A2 +S A$printfl$415 Def0097 +S A$printfl$406 Def008D +S A$printfl$370 Def0067 +S A$printfl$361 Def0060 +S A$printfl$352 Def0055 +S A$printfl$334 Def0046 +S A$printfl$316 Def0034 +S A$printfl$307 Def0029 +S A$printfl$280 Def0002 +S A$printfl$920 Def02EA +S A$printfl$911 Def02D9 +S A$printfl$902 Def02CA +S A$printfl$830 Def0269 +S A$printfl$821 Def0261 +S A$printfl$812 Def0257 +S A$printfl$803 Def024F +S A$printfl$731 Def0202 +S A$printfl$722 Def01FA +S A$printfl$713 Def01F1 +S A$printfl$704 Def01E4 +S A$printfl$650 Def01A0 +S A$printfl$641 Def018C +S A$printfl$632 Def0181 +S A$printfl$623 Def0171 +S A$printfl$605 Def015E +S A$printfl$560 Def0132 +S A$printfl$542 Def0121 +S A$printfl$533 Def0117 +S A$printfl$524 Def010F +S A$printfl$515 Def0106 +S A$printfl$506 Def00FD +S A$printfl$470 Def00D6 +S A$printfl$461 Def00CC +S A$printfl$452 Def00C2 +S A$printfl$443 Def00B9 +S A$printfl$434 Def00AE +S A$printfl$425 Def00A3 +S A$printfl$416 Def0099 +S A$printfl$380 Def006F +S A$printfl$362 Def0061 +S A$printfl$353 Def0056 +S A$printfl$335 Def0047 +S A$printfl$326 Def003C +S A$printfl$317 Def0035 +S A$printfl$308 Def002A +S A$printfl$290 Def0014 +S A$printfl$281 Def0004 +S A$printfl$930 Def02F9 +S A$printfl$921 Def02EC +S A$printfl$912 Def02DA +S A$printfl$903 Def02CD +S A$printfl$840 Def0274 +S A$printfl$822 Def0262 +S A$printfl$804 Def0250 +S A$printfl$723 Def01FB +S A$printfl$714 Def01F2 +S A$printfl$705 Def01E6 +S A$printfl$651 Def01A3 +S A$printfl$642 Def018F +S A$printfl$624 Def0173 +S A$printfl$615 Def0165 +S A$printfl$606 Def015F +S A$printfl$570 Def013E +S A$printfl$561 Def0133 +S A$printfl$543 Def0122 +S A$printfl$525 Def0110 +S A$printfl$516 Def0107 +S A$printfl$480 Def00DB +S A$printfl$453 Def00C5 +S A$printfl$444 Def00BA +S A$printfl$435 Def00AF +S A$printfl$426 Def00A4 +S A$printfl$417 Def009A +S A$printfl$408 Def008F +S A$printfl$390 Def0079 +S A$printfl$381 Def0070 +S A$printfl$372 Def0068 +S A$printfl$363 Def0062 +S A$printfl$354 Def0057 +S A$printfl$345 Def004C +S A$printfl$318 Def0036 +S A$printfl$309 Def002B +S A$printfl$291 Def0015 +S A$printfl$282 Def0006 +S A$printfl$940 Def0302 +S A$printfl$931 Def02FA +S A$printfl$922 Def02EE +S A$printfl$913 Def02DD +S A$printfl$904 Def02CE +S A$printfl$850 Def027F +S A$printfl$841 Def0275 +S A$printfl$823 Def0263 +S A$printfl$814 Def0259 +S A$printfl$805 Def0251 +S A$printfl$760 Def021B +S A$printfl$751 Def0218 +S A$printfl$742 Def020E +S A$printfl$733 Def0205 +S A$printfl$724 Def01FC +S A$printfl$715 Def01F3 +S A$printfl$706 Def01E7 +S A$printfl$670 Def01BA +S A$printfl$661 Def01B3 +S A$printfl$652 Def01A5 +S A$printfl$643 Def0190 +S A$printfl$625 Def0174 +S A$printfl$616 Def0168 +S A$printfl$607 Def0160 +S A$printfl$580 Def0146 +S A$printfl$571 Def013F +S A$printfl$562 Def0134 +S A$printfl$553 Def0129 +S A$printfl$544 Def0123 +S A$printfl$526 Def0111 +S A$printfl$517 Def0108 +S A$printfl$508 Def00FE +S A$printfl$490 Def00EC +S A$printfl$481 Def00DD +S A$printfl$463 Def00CE +S A$printfl$445 Def00BB +S A$printfl$436 Def00B0 +S A$printfl$427 Def00A5 +S A$printfl$418 Def009B +S A$printfl$409 Def0090 +S A$printfl$391 Def007A +S A$printfl$382 Def0071 +S A$printfl$373 Def0069 +S A$printfl$355 Def0058 +S A$printfl$319 Def0037 +S A$printfl$292 Def0016 +S A$printfl$283 Def0008 +S A$printfl$932 Def02FB +S A$printfl$923 Def02F0 +S A$printfl$914 Def02DF +S A$printfl$905 Def02CF +S A$printfl$860 Def028D +S A$printfl$842 Def0276 +S A$printfl$833 Def026B +S A$printfl$824 Def0264 +S A$printfl$806 Def0252 +S A$printfl$770 Def022D +S A$printfl$761 Def021D +S A$printfl$716 Def01F4 +S A$printfl$707 Def01E8 +S A$printfl$680 Def01C6 +S A$printfl$671 Def01BB +S A$printfl$662 Def01B4 +S A$printfl$653 Def01A8 +S A$printfl$644 Def0193 +S A$printfl$635 Def0184 +S A$printfl$626 Def0175 +S A$printfl$617 Def0169 +S A$printfl$608 Def0161 +S A$printfl$590 Def014F +S A$printfl$572 Def0140 +S A$printfl$563 Def0135 +S A$printfl$545 Def0124 +S A$printfl$536 Def0119 +S A$printfl$527 Def0112 +S A$printfl$518 Def0109 +S A$printfl$491 Def00ED +S A$printfl$482 Def00DF +S A$printfl$464 Def00D1 +S A$printfl$455 Def00C6 +S A$printfl$446 Def00BC +S A$printfl$437 Def00B1 +S A$printfl$428 Def00A6 +S A$printfl$419 Def009C +S A$printfl$392 Def007B +S A$printfl$383 Def0072 +S A$printfl$356 Def0059 +S A$printfl$338 Def0048 +S A$printfl$329 Def003F +S A$printfl$293 Def0018 +S A$printfl$284 Def000B +S A$printfl$951 Def030F +S A$printfl$933 Def02FC +S A$printfl$924 Def02F1 +S A$printfl$915 Def02E0 +S A$printfl$906 Def02D0 +S A$printfl$870 Def02A0 +S A$printfl$861 Def028E +S A$printfl$843 Def0277 +S A$printfl$834 Def026E +S A$printfl$825 Def0265 +S A$printfl$807 Def0253 +S A$printfl$780 Def0238 +S A$printfl$771 Def022E +S A$printfl$762 Def021F +S A$printfl$744 Def0210 +S A$printfl$717 Def01F5 +S A$printfl$708 Def01EA +S A$printfl$690 Def01D2 +S A$printfl$681 Def01C7 +S A$printfl$672 Def01BC +S A$printfl$663 Def01B5 +S A$printfl$654 Def01AA +S A$printfl$645 Def0194 +S A$printfl$636 Def0187 +S A$printfl$627 Def0177 +S A$printfl$618 Def016B +S A$printfl$609 Def0162 +S A$printfl$591 Def0150 +S A$printfl$573 Def0141 +S A$printfl$564 Def0136 +S A$printfl$546 Def0125 +S A$printfl$537 Def011C +S A$printfl$528 Def0113 +S A$printfl$519 Def010A +S A$printfl$492 Def00EF +S A$printfl$483 Def00E2 +S A$printfl$456 Def00C7 +S A$printfl$447 Def00BD +S A$printfl$438 Def00B4 +S A$printfl$429 Def00A7 +S A$printfl$393 Def007C +S A$printfl$384 Def0073 +S A$printfl$366 Def0063 +S A$printfl$357 Def005A +S A$printfl$348 Def004F +S A$printfl$339 Def0049 +S A$printfl$294 Def0019 +S A$printfl$285 Def000D +S A$printfl$970 Def031C +S A$printfl$943 Def0305 +S A$printfl$934 Def02FD +S A$printfl$925 Def02F4 +S A$printfl$916 Def02E2 +S A$printfl$907 Def02D1 +S A$printfl$880 Def02B3 +S A$printfl$871 Def02A2 +S A$printfl$862 Def0291 +S A$printfl$853 Def0282 +S A$printfl$844 Def0278 +S A$printfl$835 Def026F +S A$printfl$826 Def0266 +S A$printfl$817 Def025B +S A$printfl$808 Def0254 +S A$printfl$781 Def0239 +S A$printfl$772 Def022F +S A$printfl$763 Def0221 +S A$printfl$745 Def0213 +S A$printfl$736 Def0207 +S A$printfl$718 Def01F6 +S A$printfl$709 Def01EB +S A$printfl$691 Def01D3 +S A$printfl$682 Def01C8 +S A$printfl$655 Def01AC +S A$printfl$646 Def0197 +S A$printfl$637 Def0188 +S A$printfl$628 Def0179 +S A$printfl$619 Def016C +S A$printfl$592 Def0151 +S A$printfl$574 Def0142 +S A$printfl$565 Def0137 +S A$printfl$556 Def012C +S A$printfl$547 Def0126 +S A$printfl$538 Def011D +S A$printfl$529 Def0114 +S A$printfl$493 Def00F0 +S A$printfl$484 Def00E4 +S A$printfl$466 Def00D4 +S A$printfl$448 Def00BE +S A$printfl$439 Def00B5 +S A$printfl$394 Def007E +S A$printfl$385 Def0074 +S A$printfl$367 Def0064 +S A$printfl$358 Def005B +S A$printfl$349 Def0052 +S A$printfl$286 Def000E +S XFprintfl$pvaldec$0$0 Def031B +S A$printfl$980 Def032A +S A$printfl$971 Def031E +S A$printfl$935 Def02FE +S A$printfl$926 Def02F5 +S A$printfl$917 Def02E4 +S A$printfl$908 Def02D2 +S A$printfl$881 Def02B5 +S A$printfl$872 Def02A4 +S A$printfl$863 Def0292 +S A$printfl$854 Def0285 +S A$printfl$845 Def0279 +S A$printfl$836 Def0270 +S A$printfl$827 Def0267 +S A$printfl$818 Def025E +S A$printfl$809 Def0255 +S A$printfl$791 Def0241 +S A$printfl$782 Def023A +S A$printfl$773 Def0231 +S A$printfl$764 Def0224 +S A$printfl$737 Def0209 +S A$printfl$728 Def01FF +S A$printfl$719 Def01F7 +S A$printfl$692 Def01D5 +S A$printfl$683 Def01C9 +S A$printfl$674 Def01BE +S A$printfl$665 Def01B6 +S A$printfl$656 Def01AE +S A$printfl$647 Def0199 +S A$printfl$638 Def0189 +S A$printfl$629 Def017B +S A$printfl$593 Def0152 +S A$printfl$584 Def0147 +S A$printfl$566 Def0138 +S A$printfl$557 Def012F +S A$printfl$539 Def011E +S A$printfl$485 Def00E5 +S A$printfl$458 Def00CA +S A$printfl$449 Def00BF +S A$printfl$386 Def0075 +S A$printfl$377 Def006A +S A$printfl$368 Def0065 +S A$printfl$359 Def005C +S A$printfl$296 Def001A +S A$printfl$287 Def0010 +S A$printfl$990 Def0335 +S A$printfl$972 Def0321 +S A$printfl$963 Def031B +S A$printfl$954 Def0311 +S A$printfl$945 Def0308 +S A$printfl$936 Def02FF +S A$printfl$927 Def02F6 +S A$printfl$918 Def02E6 +S A$printfl$909 Def02D5 +S A$printfl$891 Def02C0 +S A$printfl$882 Def02B7 +S A$printfl$873 Def02A6 +S A$printfl$864 Def0295 +S A$printfl$855 Def0286 +S A$printfl$846 Def027A +S A$printfl$837 Def0271 +S A$printfl$828 Def0268 +S A$printfl$819 Def025F +S A$printfl$783 Def023B +S A$printfl$774 Def0232 +S A$printfl$765 Def0226 +S A$printfl$747 Def0216 +S A$printfl$693 Def01D6 +S A$printfl$684 Def01CB +S A$printfl$666 Def01B7 +S A$printfl$657 Def01AF +S A$printfl$648 Def019A +S A$printfl$639 Def018A +S A$printfl$594 Def0153 +S A$printfl$567 Def0139 +S A$printfl$558 Def0130 +S A$printfl$549 Def0127 +S A$printfl$486 Def00E7 +S A$printfl$387 Def0076 +S A$printfl$378 Def006D +S A$printfl$369 Def0066 +S A$printfl$297 Def001D +S A$printfl$288 Def0011 +S A$printfl$279 Def0000 +S A$printfl$991 Def0337 +S A$printfl$982 Def032B +S A$printfl$928 Def02F7 +S A$printfl$919 Def02E7 +S A$printfl$892 Def02C1 +S A$printfl$883 Def02B9 +S A$printfl$874 Def02A7 +S A$printfl$865 Def0297 +S A$printfl$856 Def0287 +S A$printfl$847 Def027B +S A$printfl$838 Def0272 +S A$printfl$784 Def023C +S A$printfl$766 Def0227 +S A$printfl$739 Def020C +S A$printfl$694 Def01D7 +S A$printfl$685 Def01CC +S A$printfl$676 Def01C0 +S A$printfl$667 Def01B8 +S A$printfl$658 Def01B1 +S A$printfl$649 Def019D +S A$printfl$595 Def0154 +S A$printfl$577 Def0143 +S A$printfl$568 Def013A +S A$printfl$559 Def0131 +S A$printfl$496 Def00F1 +S A$printfl$487 Def00E8 +S A$printfl$478 Def00D7 +S A$printfl$397 Def0081 +S A$printfl$388 Def0077 +S A$printfl$379 Def006E +S A$printfl$298 Def001F +S A$printfl$289 Def0012 +S A$printfl$992 Def0338 +S A$printfl$983 Def032D +S A$printfl$974 Def0323 +S A$printfl$956 Def0313 +S A$printfl$929 Def02F8 +S A$printfl$893 Def02C2 +S A$printfl$884 Def02BB +S A$printfl$875 Def02AA +S A$printfl$866 Def0298 +S A$printfl$857 Def0288 +S A$printfl$848 Def027C +S A$printfl$839 Def0273 +S A$printfl$794 Def0244 +S A$printfl$785 Def023D +S A$printfl$767 Def0229 +S A$printfl$695 Def01D9 +S A$printfl$686 Def01CD +S A$printfl$677 Def01C2 +S A$printfl$659 Def01B2 +S A$printfl$596 Def0155 +S A$printfl$587 Def014A +S A$printfl$578 Def0144 +S A$printfl$569 Def013D +S A$printfl$497 Def00F4 +S A$printfl$488 Def00E9 +S A$printfl$479 Def00D9 +S A$printfl$398 Def0083 +S A$printfl$389 Def0078 +S A$printfl$993 Def033A +S A$printfl$984 Def032E +S A$printfl$975 Def0325 +S A$printfl$957 Def0316 +S A$printfl$948 Def030A +S A$printfl$885 Def02BC +S A$printfl$876 Def02AC +S A$printfl$867 Def029A +S A$printfl$858 Def0289 +S A$printfl$849 Def027D +S A$printfl$795 Def0247 +S A$printfl$786 Def023E +S A$printfl$777 Def0233 +S A$printfl$768 Def022A +S A$printfl$759 Def0219 +S A$printfl$696 Def01DA +S A$printfl$687 Def01CF +S A$printfl$678 Def01C4 +S A$printfl$669 Def01B9 +S A$printfl$597 Def0156 +S A$printfl$588 Def014D +S A$printfl$579 Def0145 +S A$printfl$498 Def00F5 +S A$printfl$489 Def00EB +S A$printfl$399 Def0086 +S A$printfl$994 Def033B +S A$printfl$976 Def0327 +S A$printfl$949 Def030C +S A$printfl$895 Def02C3 +S A$printfl$877 Def02AE +S A$printfl$868 Def029C +S A$printfl$859 Def028A +S A$printfl$796 Def0248 +S A$printfl$787 Def023F +S A$printfl$778 Def0236 +S A$printfl$769 Def022B +S A$printfl$697 Def01DB +S A$printfl$688 Def01D0 +S A$printfl$679 Def01C5 +S A$printfl$598 Def0157 +S A$printfl$589 Def014E +S A$printfl$499 Def00F6 +S A$printfl$995 Def033D +S A$printfl$959 Def0319 +S A$printfl$896 Def02C4 +S A$printfl$887 Def02BD +S A$printfl$878 Def02B0 +S A$printfl$869 Def029E +S A$printfl$797 Def0249 +S A$printfl$779 Def0237 +S A$printfl$698 Def01DD +S A$printfl$689 Def01D1 +S A$printfl$599 Def0158 +S A$printfl$996 Def033F +S A$printfl$987 Def0330 +S A$printfl$978 Def0328 +S A$printfl$897 Def02C5 +S A$printfl$888 Def02BE +S A$printfl$879 Def02B1 +S A$printfl$798 Def024A +S A$printfl$789 Def0240 +S A$printfl$699 Def01DF +S Fprintfl$pvaldec$0$0 Def0219 +S A$printfl$997 Def0341 +S A$printfl$988 Def0332 +S A$printfl$979 Def0329 +S A$printfl$898 Def02C6 +S A$printfl$889 Def02BF +S A$printfl$799 Def024B +S C$printfl.c$75$1$1 Def00D6 +S A$printfl$998 Def0343 +S A$printfl$989 Def0334 +S XFprintfl$pvalhex$0$0 Def00D6 +S XFprintfl$pvaloct$0$0 Def0218 +S A$printfl$1000 Def0346 +S Fprintfl$pvalhex$0$0 Def0000 +S A$printfl$1001 Def0347 +S Fprintfl$pvaloct$0$0 Def00D7 +S _printf_small Def031C +S A$printfl$1200 Def0444 +S A$printfl$1101 Def03C3 +S A$printfl$1020 Def0361 +S A$printfl$1011 Def0354 +S A$printfl$1002 Def0349 +S A$printfl$1201 Def0446 +S A$printfl$1030 Def0370 +S A$printfl$1021 Def0363 +S A$printfl$1012 Def0356 +S A$printfl$1301 Def04C2 +S A$printfl$1220 Def045E +S A$printfl$1202 Def0448 +S A$printfl$1103 Def03C5 +S A$printfl$1031 Def0372 +S A$printfl$1022 Def0364 +S A$printfl$1013 Def0358 +S A$printfl$1320 Def04DD +S A$printfl$1311 Def04CB +S A$printfl$1302 Def04C4 +S A$printfl$1230 Def046C +S A$printfl$1221 Def0460 +S A$printfl$1212 Def0459 +S A$printfl$1203 Def044A +S A$printfl$1131 Def03DD +S A$printfl$1050 Def0387 +S A$printfl$1032 Def0375 +S A$printfl$1023 Def0366 +S A$printfl$1005 Def034C +S A$printfl$1330 Def04EC +S A$printfl$1321 Def04E0 +S A$printfl$1312 Def04CE +S A$printfl$1240 Def0478 +S A$printfl$1231 Def046D +S A$printfl$1222 Def0461 +S A$printfl$1204 Def044C +S A$printfl$1141 Def03E5 +S A$printfl$1123 Def03D6 +S A$printfl$1105 Def03C8 +S A$printfl$1051 Def0388 +S A$printfl$1033 Def0376 +S A$printfl$1024 Def0367 +S A$printfl$1015 Def035A +S A$printfl$1006 Def034F +S A$printfl$1340 Def04FA +S A$printfl$1331 Def04EF +S A$printfl$1304 Def04C7 +S A$printfl$1250 Def0480 +S A$printfl$1232 Def046F +S A$printfl$1223 Def0462 +S A$printfl$1205 Def044F +S A$printfl$1160 Def03FA +S A$printfl$1115 Def03CF +S A$printfl$1070 Def039B +S A$printfl$1025 Def0369 +S A$printfl$1016 Def035B +S A$printfl$1350 Def0507 +S A$printfl$1341 Def04FC +S A$printfl$1332 Def04F1 +S A$printfl$1260 Def048E +S A$printfl$1251 Def0481 +S A$printfl$1233 Def0470 +S A$printfl$1224 Def0464 +S A$printfl$1206 Def0451 +S A$printfl$1170 Def0406 +S A$printfl$1161 Def03FC +S A$printfl$1152 Def03F0 +S A$printfl$1143 Def03E7 +S A$printfl$1125 Def03D8 +S A$printfl$1116 Def03D2 +S A$printfl$1107 Def03CA +S A$printfl$1071 Def039C +S A$printfl$1062 Def0390 +S A$printfl$1053 Def0389 +S A$printfl$1044 Def037E +S A$printfl$1035 Def0379 +S A$printfl$1026 Def036A +S A$printfl$1017 Def035E +S A$printfl$1008 Def0351 +S A$printfl$1351 Def050A +S A$printfl$1342 Def04FE +S A$printfl$1333 Def04F4 +S A$printfl$1315 Def04D0 +S A$printfl$1306 Def04C9 +S A$printfl$1270 Def0499 +S A$printfl$1261 Def048F +S A$printfl$1252 Def0483 +S A$printfl$1234 Def0472 +S A$printfl$1216 Def045B +S A$printfl$1207 Def0453 +S A$printfl$1180 Def041F +S A$printfl$1171 Def0409 +S A$printfl$1162 Def03FE +S A$printfl$1153 Def03F2 +S A$printfl$1135 Def03E0 +S A$printfl$1090 Def03B1 +S A$printfl$1054 Def038A +S A$printfl$1370 Def0527 +S A$printfl$1361 Def0519 +S A$printfl$1352 Def050D +S A$printfl$1343 Def0501 +S A$printfl$1325 Def04E2 +S A$printfl$1316 Def04D2 +S A$printfl$1280 Def04A7 +S A$printfl$1271 Def049B +S A$printfl$1262 Def0491 +S A$printfl$1244 Def047A +S A$printfl$1235 Def0473 +S A$printfl$1226 Def0465 +S A$printfl$1208 Def0455 +S A$printfl$1190 Def0431 +S A$printfl$1172 Def040C +S A$printfl$1163 Def03FF +S A$printfl$1154 Def03F3 +S A$printfl$1109 Def03CD +S A$printfl$1091 Def03B3 +S A$printfl$1082 Def03A4 +S A$printfl$1073 Def039D +S A$printfl$1064 Def0392 +S A$printfl$1055 Def038B +S A$printfl$1046 Def0380 +S A$printfl$1028 Def036C +S A$printfl$1019 Def035F +S A$printfl$1371 Def0528 +S A$printfl$1362 Def051B +S A$printfl$1353 Def0510 +S A$printfl$1317 Def04D5 +S A$printfl$1281 Def04A8 +S A$printfl$1272 Def049C +S A$printfl$1263 Def0493 +S A$printfl$1254 Def0484 +S A$printfl$1236 Def0475 +S A$printfl$1227 Def0467 +S A$printfl$1209 Def0457 +S A$printfl$1191 Def0433 +S A$printfl$1182 Def0422 +S A$printfl$1173 Def040F +S A$printfl$1164 Def0401 +S A$printfl$1155 Def03F4 +S A$printfl$1137 Def03E2 +S A$printfl$1119 Def03D4 +S A$printfl$1092 Def03B5 +S A$printfl$1083 Def03A6 +S A$printfl$1074 Def039E +S A$printfl$1056 Def038C +S A$printfl$1047 Def0382 +S A$printfl$1029 Def036E +S A$printfl$1354 Def0512 +S A$printfl$1327 Def04E4 +S A$printfl$1318 Def04D8 +S A$printfl$1282 Def04AA +S A$printfl$1273 Def049D +S A$printfl$1264 Def0495 +S A$printfl$1255 Def0486 +S A$printfl$1237 Def0476 +S A$printfl$1228 Def0468 +S A$printfl$1192 Def0434 +S A$printfl$1183 Def0425 +S A$printfl$1174 Def0412 +S A$printfl$1165 Def0402 +S A$printfl$1156 Def03F6 +S A$printfl$1147 Def03EA +S A$printfl$1129 Def03DB +S A$printfl$1093 Def03B7 +S A$printfl$1084 Def03A8 +S A$printfl$1075 Def039F +S A$printfl$1066 Def0394 +S A$printfl$1057 Def038D +S A$printfl$1048 Def0384 +S A$printfl$1039 Def037B +S A$printfl$1373 Def0529 +S A$printfl$1355 Def0515 +S A$printfl$1337 Def04F6 +S A$printfl$1328 Def04E6 +S A$printfl$1319 Def04DB +S A$printfl$1292 Def04B7 +S A$printfl$1283 Def04AB +S A$printfl$1274 Def049F +S A$printfl$1256 Def0487 +S A$printfl$1238 Def0477 +S A$printfl$1229 Def046A +S A$printfl$1193 Def0436 +S A$printfl$1184 Def0428 +S A$printfl$1175 Def0415 +S A$printfl$1166 Def0404 +S A$printfl$1148 Def03ED +S A$printfl$1094 Def03BA +S A$printfl$1085 Def03A9 +S A$printfl$1076 Def03A0 +S A$printfl$1067 Def0396 +S A$printfl$1058 Def038E +S A$printfl$1049 Def0385 +S XG$printf_small$0$0 Def0531 +S A$printfl$1365 Def051E +S A$printfl$1347 Def0503 +S A$printfl$1329 Def04E9 +S A$printfl$1284 Def04AD +S A$printfl$1266 Def0497 +S A$printfl$1257 Def0489 +S A$printfl$1248 Def047D +S A$printfl$1194 Def0438 +S A$printfl$1185 Def042B +S A$printfl$1176 Def0418 +S A$printfl$1167 Def0405 +S A$printfl$1158 Def03F7 +S A$printfl$1095 Def03BB +S A$printfl$1086 Def03AB +S A$printfl$1077 Def03A1 +S A$printfl$1068 Def0398 +S A$printfl$1375 Def052C +S A$printfl$1366 Def0520 +S A$printfl$1339 Def04F8 +S A$printfl$1294 Def04B9 +S A$printfl$1285 Def04AF +S A$printfl$1276 Def04A0 +S A$printfl$1258 Def048B +S A$printfl$1249 Def047F +S A$printfl$1195 Def043A +S A$printfl$1186 Def042D +S A$printfl$1159 Def03F9 +S A$printfl$1087 Def03AC +S A$printfl$1078 Def03A2 +S A$printfl$1069 Def0399 +S Fprintfl$_str_0$0$0 Def0532 +S C$printfl.c$111$1$1 Def0218 +S A$printfl$1376 Def052F +S A$printfl$1367 Def0522 +S A$printfl$1358 Def0517 +S A$printfl$1349 Def0505 +S A$printfl$1286 Def04B0 +S A$printfl$1277 Def04A2 +S A$printfl$1259 Def048D +S A$printfl$1196 Def043C +S A$printfl$1187 Def042F +S A$printfl$1178 Def041B +S A$printfl$1097 Def03BE +S A$printfl$1088 Def03AE +S A$printfl$1368 Def0523 +S A$printfl$1296 Def04BB +S A$printfl$1287 Def04B1 +S A$printfl$1278 Def04A3 +S A$printfl$1197 Def043F +S A$printfl$1179 Def041D +S A$printfl$1089 Def03AF +S A$printfl$1369 Def0524 +S A$printfl$1297 Def04BD +S A$printfl$1288 Def04B3 +S A$printfl$1279 Def04A5 +S A$printfl$1198 Def0440 +S A$printfl$1189 Def0430 +S A$printfl$1099 Def03C0 +S A$printfl$300 Def0020 +S A$printfl$1379 Def0531 +S A$printfl$1289 Def04B5 +S A$printfl$1199 Def0442 +S A$printfl$310 Def002C +S A$printfl$301 Def0023 +S C$printfl.c$214$1$1 Def0531 +S C$printfl.c$142$1$1 Def031B +S A$printfl$1299 Def04C0 +S A$printfl$500 Def00F7 +S A$printfl$410 Def0091 +S A$printfl$320 Def0038 +S A$printfl$311 Def002D +S A$printfl$302 Def0024 +S A$printfl$600 Def015B +S A$printfl$510 Def00FF +S A$printfl$501 Def00F8 +S A$printfl$420 Def009D +S A$printfl$411 Def0092 +S A$printfl$402 Def0087 +S A$printfl$330 Def0042 +S A$printfl$321 Def0039 +S A$printfl$312 Def002E +S A$printfl$303 Def0025 +S G$printf_small$0$0 Def031C +S A$printfl$700 Def01E0 +S A$printfl$601 Def015C +S A$printfl$520 Def010B +S A$printfl$502 Def00F9 +S A$printfl$430 Def00A9 +S A$printfl$421 Def009E +S A$printfl$412 Def0093 +S A$printfl$403 Def008A +S A$printfl$340 Def004A +S A$printfl$331 Def0043 +S A$printfl$322 Def003A +S A$printfl$313 Def0031 +S A$printfl$304 Def0026 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 0D +R 00 00 00 05 +T 00 0D +R 00 00 00 05 +T 00 11 +R 00 00 00 05 +T 00 11 +R 00 00 00 05 +T 00 15 +R 00 00 00 05 +T 00 15 +R 00 00 00 05 +T 00 00 C2 00 00 C2 00 01 C2 00 02 +R 00 00 00 06 29 03 00 04 29 06 00 04 29 09 00 04 +T 00 00 +R 00 00 00 07 +T 00 00 C0 E0 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 0E D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 1B 00 04 E5 81 F0 90 00 00 E0 FA A3 E0 FB A3 +R 00 00 00 07 00 02 00 05 00 08 00 05 +T 00 29 E0 FC A3 E0 FD 90 00 05 EA F0 A3 EB F0 A3 +R 00 00 00 07 00 08 00 05 +T 00 37 EC F0 A3 ED F0 20 00 00 0D +R 00 00 00 07 29 08 00 04 +T 00 3F +R 00 00 00 07 +T 00 3F 90 00 05 EA F0 A3 EB F0 A3 E4 F0 A3 F0 +R 00 00 00 07 00 03 00 05 +T 00 4C +R 00 00 00 07 +T 00 4C 30 00 02 1B +R 00 00 00 07 29 03 00 04 +T 00 4F +R 00 00 00 07 +T 00 4F 90 00 05 E0 FA A3 E0 FB A3 E0 FC A3 E0 FD +R 00 00 00 07 00 03 00 05 +T 00 5D 90 00 05 EA F0 A3 E4 F0 A3 F0 A3 E4 F0 +R 00 00 00 07 00 03 00 05 +T 00 6A +R 00 00 00 07 +T 00 6A +R 00 00 00 07 +T 00 6A 90 00 05 E0 FA A3 E0 FE A3 E0 FF A3 E0 F8 +R 00 00 00 07 00 03 00 05 +T 00 78 EA 4E 4F 48 70 03 02 00 C2 +R 00 00 00 07 00 09 00 07 +T 00 81 +R 00 00 00 07 +T 00 81 8A 01 53 01 0F E9 90 05 32 93 F5 00 00 C0 +R 00 00 00 07 00 09 00 07 29 0D 00 01 +T 00 8E 00 00 EE C4 CA C4 54 0F 6A CA 54 0F CA 6A +R 00 00 00 07 29 02 00 01 +T 00 9B CA FE EF C4 54 F0 4E FE E8 C4 CF C4 54 0F +R 00 00 00 07 +T 00 A9 6F CF 54 0F CF 6F CF F8 90 00 05 EA F0 A3 +R 00 00 00 07 00 0B 00 05 +T 00 B7 EE F0 A3 EF F0 A3 E8 F0 02 00 6A +R 00 00 00 07 00 0B 00 07 +T 00 C2 +R 00 00 00 07 +T 00 C2 90 00 04 E0 FA B5 81 02 80 0A +R 00 00 00 07 00 03 00 05 +T 00 CC +R 00 00 00 07 +T 00 CC D0 00 00 85 00 00 82 12 00 00 80 EC +R 00 00 00 07 29 03 00 01 29 06 00 01 02 0A 00 24 +T 00 D6 +R 00 00 00 07 +T 00 D6 22 +R 00 00 00 07 +T 00 D7 +R 00 00 00 07 +T 00 D7 C0 E0 C0 F0 C0 83 C0 82 90 00 09 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 00 E5 D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 00 F2 00 09 E0 FB A3 E0 FC A3 E0 FD A3 E0 FE 30 +R 00 00 00 07 00 02 00 05 +T 01 00 E7 17 +R 00 00 00 07 +T 01 02 +R 00 00 00 07 +T 01 02 90 00 0D C3 E4 9B F0 E4 9C A3 F0 E4 9D A3 +R 00 00 00 07 00 03 00 05 +T 01 10 F0 E4 9E A3 F0 D2 00 03 80 10 +R 00 00 00 07 29 08 00 04 +T 01 19 +R 00 00 00 07 +T 01 19 90 00 0D EB F0 A3 EC F0 A3 ED F0 A3 EE F0 +R 00 00 00 07 00 03 00 05 +T 01 27 C2 00 03 +R 00 00 00 07 29 03 00 04 +T 01 29 +R 00 00 00 07 +T 01 29 20 00 00 1B +R 00 00 00 07 29 03 00 04 +T 01 2C +R 00 00 00 07 +T 01 2C 90 00 0D E0 FB A3 E0 FC A3 E0 FD A3 E0 FE +R 00 00 00 07 00 03 00 05 +T 01 3A 90 00 0D EB F0 A3 EC F0 A3 E4 F0 A3 F0 +R 00 00 00 07 00 03 00 05 +T 01 47 +R 00 00 00 07 +T 01 47 30 00 02 1B +R 00 00 00 07 29 03 00 04 +T 01 4A +R 00 00 00 07 +T 01 4A 90 00 0D E0 FB A3 E0 FC A3 E0 FD A3 E0 FE +R 00 00 00 07 00 03 00 05 +T 01 58 90 00 0D EB F0 A3 E4 F0 A3 F0 A3 E4 F0 +R 00 00 00 07 00 03 00 05 +T 01 65 +R 00 00 00 07 +T 01 65 90 00 0D E0 F5 00 09 A3 E0 F5 00 0A A3 E0 +R 00 00 00 07 00 03 00 05 29 07 00 01 29 0C 00 01 +T 01 71 F5 00 0B A3 E0 F5 00 0C E5 00 09 45 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 01 7A 00 0A 45 00 0B 45 00 0C 70 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 82 01 FF +R 00 00 00 07 00 02 00 07 +T 01 84 +R 00 00 00 07 +T 01 84 90 00 00 E4 A3 A3 A3 F0 12 00 00 F0 12 +R 00 00 00 07 02 03 00 08 02 0B 00 33 +T 01 91 00 00 F0 12 00 00 74 08 F0 85 00 09 82 85 +R 00 00 00 07 02 02 00 33 02 06 00 33 29 0C 00 01 +T 01 9E 00 0A 83 85 00 0B F0 E5 00 0C 12 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 01 A6 00 00 AA 82 AB 83 AF F0 F8 74 30 2A FA E4 +R 00 00 00 07 02 02 00 2E +T 01 B4 3B FB E4 3F FF E4 38 F8 8A 00 00 C0 00 00 +R 00 00 00 07 29 0B 00 01 29 0E 00 01 +T 01 C0 AA 00 09 E5 00 0A C4 23 CA C4 23 54 1F 6A +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 01 CC CA 54 1F CA 6A CA FB E5 00 0B C4 23 54 E0 +R 00 00 00 07 29 0A 00 01 +T 01 D9 4B FB AF 00 0B E5 00 0C C4 23 CF C4 23 54 +R 00 00 00 07 29 05 00 01 29 08 00 01 +T 01 E5 1F 6F CF 54 1F CF 6F CF F8 90 00 0D EA F0 +R 00 00 00 07 00 0C 00 05 +T 01 F3 A3 EB F0 A3 EF F0 A3 E8 F0 02 01 65 +R 00 00 00 07 00 0C 00 07 +T 01 FF +R 00 00 00 07 +T 01 FF 30 00 03 05 +R 00 00 00 07 29 03 00 04 +T 02 02 +R 00 00 00 07 +T 02 02 75 00 00 2D C0 00 00 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 02 07 +R 00 00 00 07 +T 02 07 E5 81 B5 81 02 80 0A +R 00 00 00 07 +T 02 0E +R 00 00 00 07 +T 02 0E D0 00 00 85 00 00 82 12 00 00 80 EF +R 00 00 00 07 29 03 00 01 29 06 00 01 02 0A 00 24 +T 02 18 +R 00 00 00 07 +T 02 18 22 +R 00 00 00 07 +T 02 19 +R 00 00 00 07 +T 02 19 C0 E0 C0 F0 C0 83 C0 82 90 00 11 D0 E0 F0 +R 00 00 00 07 00 0B 00 05 +T 02 27 D0 E0 A3 F0 D0 E0 A3 F0 D0 E0 A3 F0 90 +R 00 00 00 07 +T 02 34 00 11 E0 FB A3 E0 FC A3 E0 FD A3 E0 FE 30 +R 00 00 00 07 00 02 00 05 +T 02 42 E7 17 +R 00 00 00 07 +T 02 44 +R 00 00 00 07 +T 02 44 90 00 15 C3 E4 9B F0 E4 9C A3 F0 E4 9D A3 +R 00 00 00 07 00 03 00 05 +T 02 52 F0 E4 9E A3 F0 D2 00 03 80 10 +R 00 00 00 07 29 08 00 04 +T 02 5B +R 00 00 00 07 +T 02 5B 90 00 15 EB F0 A3 EC F0 A3 ED F0 A3 EE F0 +R 00 00 00 07 00 03 00 05 +T 02 69 C2 00 03 +R 00 00 00 07 29 03 00 04 +T 02 6B +R 00 00 00 07 +T 02 6B 90 00 15 E0 FB A3 E0 FC A3 E0 FD A3 E0 FE +R 00 00 00 07 00 03 00 05 +T 02 79 EB 4C 4D 4E 70 03 02 03 02 +R 00 00 00 07 00 09 00 07 +T 02 82 +R 00 00 00 07 +T 02 82 90 00 00 E4 A3 A3 A3 F0 12 00 00 F0 12 +R 00 00 00 07 02 03 00 08 02 0B 00 33 +T 02 8F 00 00 F0 12 00 00 74 0A F0 C0 03 C0 04 C0 +R 00 00 00 07 02 02 00 33 02 06 00 33 +T 02 9D 05 C0 06 8B 82 8C 83 8D F0 EE 12 00 00 AF +R 00 00 00 07 02 0D 00 2E +T 02 AB 82 A8 83 A9 F0 FA D0 06 D0 05 D0 04 D0 03 +R 00 00 00 07 +T 02 B9 74 30 2F FF E4 38 F8 E4 39 F9 E4 3A FA 8F +R 00 00 00 07 +T 02 C7 00 00 C0 00 00 90 00 00 E4 A3 A3 A3 F0 12 +R 00 00 00 07 29 02 00 01 29 05 00 01 02 08 00 0F +T 02 D3 00 00 F0 12 00 00 F0 12 00 00 74 0A F0 8B +R 00 00 00 07 02 02 00 33 02 06 00 33 02 0A 00 33 +T 02 E1 82 8C 83 8D F0 EE 12 00 00 AA 82 AB 83 AC +R 00 00 00 07 02 09 00 36 +T 02 EF F0 FD 90 00 15 EA F0 A3 EB F0 A3 EC F0 A3 +R 00 00 00 07 00 05 00 05 +T 02 FD ED F0 02 02 6B +R 00 00 00 07 00 05 00 07 +T 03 02 +R 00 00 00 07 +T 03 02 30 00 03 05 +R 00 00 00 07 29 03 00 04 +T 03 05 +R 00 00 00 07 +T 03 05 75 00 00 2D C0 00 00 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 03 0A +R 00 00 00 07 +T 03 0A E5 81 B5 81 02 80 0A +R 00 00 00 07 +T 03 11 +R 00 00 00 07 +T 03 11 D0 00 00 85 00 00 82 12 00 00 80 EF +R 00 00 00 07 29 03 00 01 29 06 00 01 02 0A 00 24 +T 03 1B +R 00 00 00 07 +T 03 1B 22 +R 00 00 00 07 +T 03 1C +R 00 00 00 07 +T 03 1C C0 00 00 85 81 00 00 05 81 E5 00 00 24 FB +R 00 00 00 07 2B 03 00 4A 2B 07 00 4A 2B 0C 00 4A +T 03 27 FA E4 FB FC A8 00 00 08 A6 02 +R 00 00 00 07 2B 07 00 4A +T 03 30 +R 00 00 00 07 +T 03 30 E5 00 00 24 FB F8 86 03 08 86 04 08 86 05 +R 00 00 00 07 2B 03 00 4A +T 03 3D 8B 82 8C 83 8D F0 12 00 00 FE 70 03 02 +R 00 00 00 07 02 09 00 54 +T 03 4A 05 2C +R 00 00 00 07 00 02 00 07 +T 03 4C +R 00 00 00 07 +T 03 4C BE 25 02 80 03 +R 00 00 00 07 +T 03 51 +R 00 00 00 07 +T 03 51 02 05 19 +R 00 00 00 07 00 03 00 07 +T 03 54 +R 00 00 00 07 +T 03 54 C2 00 02 C2 00 01 C2 00 00 0B BB 00 01 0C +R 00 00 00 07 29 03 00 04 29 06 00 04 29 09 00 04 +T 03 5F +R 00 00 00 07 +T 03 5F E5 00 00 24 FB F8 A6 03 08 A6 04 08 A6 05 +R 00 00 00 07 2B 03 00 4A +T 03 6C 8B 82 8C 83 8D F0 12 00 00 FF BF 68 02 80 +R 00 00 00 07 02 09 00 54 +T 03 7A 17 +R 00 00 00 07 +T 03 7B +R 00 00 00 07 +T 03 7B BF 6C 26 +R 00 00 00 07 +T 03 7E +R 00 00 00 07 +T 03 7E +R 00 00 00 07 +T 03 7E D2 00 00 E5 00 00 24 FB F8 74 01 2B F6 E4 +R 00 00 00 07 29 03 00 04 2B 06 00 4A +T 03 8A 3C 08 F6 08 A6 05 80 12 +R 00 00 00 07 +T 03 92 +R 00 00 00 07 +T 03 92 D2 00 02 E5 00 00 24 FB F8 74 01 2B F6 E4 +R 00 00 00 07 29 03 00 04 2B 06 00 4A +T 03 9E 3C 08 F6 08 A6 05 +R 00 00 00 07 +T 03 A4 +R 00 00 00 07 +T 03 A4 E5 00 00 24 FB F8 86 03 08 86 04 08 86 05 +R 00 00 00 07 2B 03 00 4A +T 03 B1 8B 82 8C 83 8D F0 12 00 00 FB BB 63 02 80 +R 00 00 00 07 02 09 00 54 +T 03 BF 22 +R 00 00 00 07 +T 03 C0 +R 00 00 00 07 +T 03 C0 BB 64 02 80 13 +R 00 00 00 07 +T 03 C5 +R 00 00 00 07 +T 03 C5 BB 6F 02 80 1D +R 00 00 00 07 +T 03 CA +R 00 00 00 07 +T 03 CA BB 73 02 80 05 +R 00 00 00 07 +T 03 CF +R 00 00 00 07 +T 03 CF BB 78 18 80 09 +R 00 00 00 07 +T 03 D4 +R 00 00 00 07 +T 03 D4 +R 00 00 00 07 +T 03 D4 D2 00 01 80 12 +R 00 00 00 07 29 03 00 04 +T 03 D8 +R 00 00 00 07 +T 03 D8 75 00 01 0A 80 0D +R 00 00 00 07 29 03 00 01 +T 03 DD +R 00 00 00 07 +T 03 DD 75 00 01 10 80 08 +R 00 00 00 07 29 03 00 01 +T 03 E2 +R 00 00 00 07 +T 03 E2 75 00 01 00 80 03 +R 00 00 00 07 29 03 00 01 +T 03 E7 +R 00 00 00 07 +T 03 E7 75 00 01 08 +R 00 00 00 07 29 03 00 01 +T 03 EA +R 00 00 00 07 +T 03 EA 20 00 01 03 02 04 5B +R 00 00 00 07 29 03 00 04 00 07 00 07 +T 03 F0 +R 00 00 00 07 +T 03 F0 A9 00 00 09 E7 24 FD F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 4A 2B 0B 00 4A +T 03 FC 86 00 02 08 86 00 03 08 86 00 04 18 18 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 04 06 +R 00 00 00 07 +T 04 06 85 00 02 00 0E 85 00 03 +R 00 00 00 07 29 03 00 01 29 05 00 01 29 08 00 01 +T 04 0B 00 0F 85 00 04 00 10 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 04 10 00 0E 82 85 00 0F 83 85 00 10 F0 12 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 04 19 00 00 F5 00 0D 70 03 02 05 1E +R 00 00 00 07 02 02 00 54 29 05 00 01 00 0A 00 07 +T 04 22 +R 00 00 00 07 +T 04 22 85 00 02 82 85 00 03 83 85 00 04 F0 74 01 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 04 2D 25 00 02 FA E4 35 00 03 FF AB 00 04 8A +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0C 00 01 +T 04 37 00 02 8F 00 03 8B 00 04 12 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 3D 00 00 FC C0 02 C0 03 C0 04 C0 06 C0 07 8C +R 00 00 00 07 02 02 00 54 +T 04 4B 82 12 00 00 D0 07 D0 06 D0 04 D0 03 D0 02 +R 00 00 00 07 02 04 00 24 +T 04 59 80 AB +R 00 00 00 07 +T 04 5B +R 00 00 00 07 +T 04 5B 30 00 00 1C +R 00 00 00 07 29 03 00 04 +T 04 5E +R 00 00 00 07 +T 04 5E A9 00 00 09 E7 24 FC F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 4A 2B 0B 00 4A +T 04 6A 86 00 05 08 86 00 06 08 86 00 07 08 86 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 04 74 00 08 18 18 18 80 3D +R 00 00 00 07 29 02 00 01 +T 04 7A +R 00 00 00 07 +T 04 7A 30 00 02 1C +R 00 00 00 07 29 03 00 04 +T 04 7D +R 00 00 00 07 +T 04 7D A9 00 00 09 E7 24 FF F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 4A 2B 0B 00 4A +T 04 89 86 02 8A 00 05 EA 33 95 E0 F5 00 06 F5 +R 00 00 00 07 29 05 00 01 29 0C 00 01 +T 04 94 00 07 F5 00 08 80 1E +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 04 99 +R 00 00 00 07 +T 04 99 A9 00 00 09 E7 24 FE F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 4A 2B 0B 00 4A +T 04 A5 86 02 08 86 03 18 8A 00 05 8B 00 06 EB 33 +R 00 00 00 07 29 09 00 01 29 0C 00 01 +T 04 B1 95 E0 F5 00 07 F5 00 08 +R 00 00 00 07 29 05 00 01 29 08 00 01 +T 04 B7 +R 00 00 00 07 +T 04 B7 E5 00 01 60 3D +R 00 00 00 07 29 03 00 01 +T 04 BB +R 00 00 00 07 +T 04 BB E5 00 01 B4 08 02 80 43 +R 00 00 00 07 29 03 00 01 +T 04 C2 +R 00 00 00 07 +T 04 C2 E5 00 01 B4 0A 02 80 07 +R 00 00 00 07 29 03 00 01 +T 04 C9 +R 00 00 00 07 +T 04 C9 E5 00 01 B4 10 50 80 14 +R 00 00 00 07 29 03 00 01 +T 04 D0 +R 00 00 00 07 +T 04 D0 +R 00 00 00 07 +T 04 D0 C0 06 85 00 05 82 85 00 06 83 85 00 07 F0 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0D 00 01 +T 04 DB E5 00 08 12 02 19 D0 06 80 3A +R 00 00 00 07 29 03 00 01 00 06 00 07 +T 04 E4 +R 00 00 00 07 +T 04 E4 C0 06 85 00 05 82 85 00 06 83 85 00 07 F0 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0D 00 01 +T 04 EF E5 00 08 12 00 00 D0 06 80 26 +R 00 00 00 07 29 03 00 01 00 06 00 07 +T 04 F8 +R 00 00 00 07 +T 04 F8 AA 00 05 C0 06 8A 82 12 00 00 D0 06 80 19 +R 00 00 00 07 29 03 00 01 02 0A 00 24 +T 05 05 +R 00 00 00 07 +T 05 05 C0 06 85 00 05 82 85 00 06 83 85 00 07 F0 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0D 00 01 +T 05 10 E5 00 08 12 00 D7 D0 06 80 05 +R 00 00 00 07 29 03 00 01 00 06 00 07 +T 05 19 +R 00 00 00 07 +T 05 19 8E 82 12 00 00 +R 00 00 00 07 02 05 00 24 +T 05 1E +R 00 00 00 07 +T 05 1E E5 00 00 24 FB F8 06 B6 00 02 08 06 +R 00 00 00 07 2B 03 00 4A +T 05 29 +R 00 00 00 07 +T 05 29 02 03 30 +R 00 00 00 07 00 03 00 07 +T 05 2C +R 00 00 00 07 +T 05 2C 85 00 00 81 D0 00 00 22 +R 00 00 00 07 2B 03 00 4A 2B 07 00 4A +T 05 32 +R 00 00 00 07 +T 05 32 30 31 32 33 34 35 36 37 38 39 41 42 43 44 +R 00 00 00 07 +T 05 40 45 46 00 +R 00 00 00 07 diff --git a/device/lib/large/puts.asm b/device/lib/large/puts.asm new file mode 100644 index 00000000..083c307a --- /dev/null +++ b/device/lib/large/puts.asm @@ -0,0 +1,148 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:39 2000 + +;-------------------------------------------------------- + .module puts +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _puts +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +_puts_s_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$puts$0$0 ==. +; puts.c 27 +; ----------------------------------------- +; function puts +; ----------------------------------------- +_puts: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; puts.c 35 + push b + push dph + push dpl + mov dptr,#_puts_s_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; puts.c 30 + mov dptr,#_puts_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov r5,#0x00 + mov r6,#0x00 +00101$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget + mov r7,a + mov dptr,#_puts_s_1_1 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov a,r7 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00108$: +; puts.c 31 + inc r2 + cjne r2,#0x00,00109$ + inc r3 +00109$: + push ar2 + push ar3 + push ar4 + push ar5 + push ar6 + mov dpl,r7 + lcall _putchar + pop ar6 + pop ar5 + pop ar4 + pop ar3 + pop ar2 +; puts.c 32 + inc r5 + cjne r5,#0x00,00110$ + inc r6 +00110$: +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; puts.c 34 + push ar5 + push ar6 + mov dpl,#0x0a + lcall _putchar + pop ar6 + pop ar5 +; puts.c 35 + inc r5 + cjne r5,#0x00,00111$ + inc r6 +00111$: + mov dpl,r5 + mov dph,r6 +00104$: + C$puts.c$36$1$1 ==. + XG$puts$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/puts.cdb b/device/lib/large/puts.cdb new file mode 100644 index 00000000..1f616e72 --- /dev/null +++ b/device/lib/large/puts.cdb @@ -0,0 +1,2 @@ +M:puts +F:G$puts$0$0({2}DF,SI:S),C,0,0,0,0,0 diff --git a/device/lib/large/puts.rel b/device/lib/large/puts.rel new file mode 100644 index 00000000..0491726b --- /dev/null +++ b/device/lib/large/puts.rel @@ -0,0 +1,136 @@ +;!FILE puts.asm +XH +H 8 areas 4C global symbols +M puts +S _putchar Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 3 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 78 flags 20 +S A$puts$100 Def0037 +S A$puts$110 Def0040 +S A$puts$101 Def0038 +S A$puts$120 Def0055 +S A$puts$111 Def0042 +S A$puts$121 Def0057 +S A$puts$112 Def0044 +S A$puts$103 Def0039 +S A$puts$140 Def0072 +S A$puts$131 Def0060 +S A$puts$113 Def0046 +S A$puts$132 Def0062 +S A$puts$123 Def0059 +S A$puts$114 Def0048 +S A$puts$142 Def0073 +S A$puts$133 Def0064 +S A$puts$124 Def005A +S A$puts$115 Def004A +S A$puts$106 Def003B +S A$puts$143 Def0075 +S A$puts$134 Def0067 +S A$puts$125 Def005D +S A$puts$116 Def004C +S A$puts$107 Def003C +S A$puts$135 Def006A +S A$puts$117 Def004F +S A$puts$108 Def003F +S A$puts$136 Def006C +S A$puts$118 Def0051 +S A$puts$128 Def005E +S A$puts$119 Def0053 +S A$puts$147 Def0077 +S A$puts$138 Def006E +S A$puts$139 Def006F +S C$puts.c$36$1$1 Def0077 +S A$puts$70 Def000F +S A$puts$80 Def001B +S A$puts$71 Def0010 +S A$puts$62 Def0000 +S A$puts$90 Def0029 +S A$puts$81 Def001C +S A$puts$72 Def0012 +S A$puts$63 Def0002 +S A$puts$91 Def002C +S A$puts$82 Def001D +S A$puts$73 Def0013 +S A$puts$64 Def0004 +S A$puts$92 Def002D +S A$puts$83 Def001E +S A$puts$65 Def0006 +S A$puts$93 Def0030 +S A$puts$84 Def001F +S A$puts$75 Def0014 +S A$puts$66 Def0009 +S A$puts$94 Def0031 +S A$puts$85 Def0021 +S A$puts$76 Def0017 +S A$puts$67 Def000B +S A$puts$95 Def0032 +S A$puts$77 Def0018 +S A$puts$68 Def000C +S A$puts$96 Def0033 +S A$puts$87 Def0023 +S A$puts$78 Def0019 +S A$puts$69 Def000E +S A$puts$97 Def0034 +S A$puts$88 Def0025 +S A$puts$79 Def001A +S A$puts$98 Def0035 +S A$puts$89 Def0027 +S A$puts$99 Def0036 +S _puts Def0000 +S XG$puts$0$0 Def0077 +S G$puts$0$0 Def0000 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 F0 C0 83 C0 82 90 00 00 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 0E A3 F0 D0 E0 A3 F0 90 00 00 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 1C A3 E0 FC 7D 00 7E 00 +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 8A 82 8B 83 8C F0 12 00 00 FF 90 00 00 EA +R 00 00 00 07 02 09 00 01 00 0D 00 05 +T 00 31 F0 A3 EB F0 A3 EC F0 EF 60 25 +R 00 00 00 07 +T 00 3B +R 00 00 00 07 +T 00 3B 0A BA 00 01 0B +R 00 00 00 07 +T 00 40 +R 00 00 00 07 +T 00 40 C0 02 C0 03 C0 04 C0 05 C0 06 8F 82 12 +R 00 00 00 07 +T 00 4D 00 00 D0 06 D0 05 D0 04 D0 03 D0 02 0D BD +R 00 00 00 07 02 02 00 00 +T 00 5B 00 01 0E +R 00 00 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E 80 C3 +R 00 00 00 07 +T 00 60 +R 00 00 00 07 +T 00 60 C0 05 C0 06 75 82 0A 12 00 00 D0 06 D0 05 +R 00 00 00 07 02 0A 00 00 +T 00 6E 0D BD 00 01 0E +R 00 00 00 07 +T 00 73 +R 00 00 00 07 +T 00 73 8D 82 8E 83 +R 00 00 00 07 +T 00 77 +R 00 00 00 07 +T 00 77 22 +R 00 00 00 07 diff --git a/device/lib/large/ser_ir.asm b/device/lib/large/ser_ir.asm new file mode 100644 index 00000000..0e883047 --- /dev/null +++ b/device/lib/large/ser_ir.asm @@ -0,0 +1,765 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:36 2000 + +;-------------------------------------------------------- + .module ser_ir +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _ser_handler + .globl _ser_can_xmt + .globl _ser_can_rcv + .globl _ser_getc + .globl _ser_gets + .globl _ser_puts + .globl _ser_putc + .globl _ser_init + .globl _ser_gets_PARM_2 +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$A$0$0 == 0x00e0 +_A = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$AIN0$0$0 == 0x0090 +_AIN0 = 0x0090 +G$AIN1$0$0 == 0x0091 +_AIN1 = 0x0091 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$REN$0$0 == 0x009c +_REN = 0x009c +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET2$0$0 == 0x00ad +_ET2 = 0x00ad +G$EA$0$0 == 0x00af +_EA = 0x00af +G$P3_0$0$0 == 0x00b0 +_P3_0 = 0x00b0 +G$P3_1$0$0 == 0x00b1 +_P3_1 = 0x00b1 +G$P3_2$0$0 == 0x00b2 +_P3_2 = 0x00b2 +G$P3_3$0$0 == 0x00b3 +_P3_3 = 0x00b3 +G$P3_4$0$0 == 0x00b4 +_P3_4 = 0x00b4 +G$P3_5$0$0 == 0x00b5 +_P3_5 = 0x00b5 +G$P3_7$0$0 == 0x00b7 +_P3_7 = 0x00b7 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$AOUT$0$0 == 0x00b6 +_AOUT = 0x00b6 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$FL$0$0 == 0x00d1 +_FL = 0x00d1 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +Fser_ir$rbuf$0$0==. +_rbuf: + .ds 0x000a +Fser_ir$xbuf$0$0==. +_xbuf: + .ds 0x000a +Fser_ir$rcnt$0$0==. +_rcnt: + .ds 0x0001 +Fser_ir$xcnt$0$0==. +_xcnt: + .ds 0x0001 +Fser_ir$rpos$0$0==. +_rpos: + .ds 0x0001 +Fser_ir$xpos$0$0==. +_xpos: + .ds 0x0001 +Fser_ir$busy$0$0==. +_busy: + .ds 0x0001 +_ser_putc_c_1_1: + .ds 0x0001 +_ser_puts_s_1_1: + .ds 0x0003 +_ser_gets_PARM_2: + .ds 0x0001 +_ser_gets_s_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$ser_init$0$0 ==. +; ser_ir.c 49 +; ----------------------------------------- +; function ser_init +; ----------------------------------------- +_ser_init: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; ser_ir.c 51 + clr _ES +; ser_ir.c 52 + mov dptr,#_xpos +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_rpos +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_xcnt +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_rcnt +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; ser_ir.c 53 + mov dptr,#_busy +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; ser_ir.c 54 + mov _SCON,#0x50 +; ser_ir.c 55 + orl _PCON,#0x80 +; ser_ir.c 56 + anl _TMOD,#0x0f +; ser_ir.c 57 + orl _TMOD,#0x20 +; ser_ir.c 58 + mov _TL1,#0xfd + mov _TH1,#0xfd + setb _TR1 +; ser_ir.c 59 + setb _ES +00101$: + C$ser_ir.c$60$1$1 ==. + XG$ser_init$0$0 ==. + ret + G$ser_handler$0$0 ==. +; ser_ir.c 62 +; ----------------------------------------- +; function ser_handler +; ----------------------------------------- +_ser_handler: + push acc + push b + push dpl + push dph + push ar2 + push ar3 + push psw + mov psw,#0x00 +; ser_ir.c 64 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00104$ +00118$: +; ser_ir.c 65 + clr _RI +; ser_ir.c 67 + mov dptr,#_rcnt + movx a,@dptr + mov r2,a + cjne r2,#0x0a,00119$ +00119$: +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00120$: +; ser_ir.c 68 + mov dptr,#_rcnt + mov a,#0x01 + add a,r2 + movx @dptr,a + mov dptr,#_rpos + movx a,@dptr +; Peephole 214 reduced some extra movs + mov r3,a + add a,r2 + mov b,#0x0a + div ab + mov r2,b + mov a,r2 + add a,#_rbuf + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_rbuf >> 8) + mov dph,a + mov a,_SBUF + movx @dptr,a +00104$: +; ser_ir.c 70 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00111$ +00121$: +; ser_ir.c 71 + clr _TI +; ser_ir.c 72 + mov dptr,#_xcnt + movx a,@dptr +; Peephole 100 removed redundant mov + mov r2,a + mov dptr,#_busy + movx @dptr,a + mov a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00111$ +00122$: +; ser_ir.c 73 + mov a,r2 + add a,#0xff + mov dptr,#_xcnt + movx @dptr,a +; ser_ir.c 74 + mov dptr,#_xpos + movx a,@dptr +; Peephole 214 reduced some extra movs + mov r2,a + add a,#0x01 +; Peephole 100 removed redundant mov + mov r3,a + mov dptr,#_xpos + movx @dptr,a + mov a,r2 + add a,#_xbuf + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_xbuf >> 8) + mov dph,a + movx a,@dptr + mov _SBUF,a +; ser_ir.c 75 + cjne r3,#0x0a,00123$ +00123$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00111$ +00124$: +; ser_ir.c 76 + mov dptr,#_xpos +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +00111$: + pop psw + pop ar3 + pop ar2 + pop dph + pop dpl + pop b + pop acc + C$ser_ir.c$79$1$1 ==. + XG$ser_handler$0$0 ==. + reti + G$ser_putc$0$0 ==. +; ser_ir.c 81 +; ----------------------------------------- +; function ser_putc +; ----------------------------------------- +_ser_putc: +; ser_ir.c 92 + push dpl + mov dptr,#_ser_putc_c_1_1 + pop acc + movx @dptr,a +; ser_ir.c 83 +00101$: + mov dptr,#_xcnt + movx a,@dptr + mov r2,a + cjne r2,#0x0a,00112$ +00112$: +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00113$: +; ser_ir.c 85 + clr _ES +; ser_ir.c 86 + mov dptr,#_busy + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00105$ +00114$: +; ser_ir.c 87 + mov dptr,#_xcnt + mov a,#0x01 + add a,r2 + movx @dptr,a + mov dptr,#_xpos + movx a,@dptr +; Peephole 214 reduced some extra movs + mov r3,a + add a,r2 + mov b,#0x0a + div ab + mov r2,b + mov a,r2 + add a,#_xbuf + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_xbuf >> 8) + mov r3,a + mov dptr,#_ser_putc_c_1_1 + movx a,@dptr +; Peephole 136 removed redundant moves + mov r4,a + mov dpl,r2 + mov dph,r3 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; ser_ir.c 89 + mov dptr,#_ser_putc_c_1_1 + movx a,@dptr + mov _SBUF,a +; ser_ir.c 90 + mov dptr,#_busy + mov a,#0x01 + movx @dptr,a +00106$: +; ser_ir.c 92 + setb _ES +00107$: + C$ser_ir.c$93$1$1 ==. + XG$ser_putc$0$0 ==. + ret + G$ser_getc$0$0 ==. +; ser_ir.c 95 +; ----------------------------------------- +; function ser_getc +; ----------------------------------------- +_ser_getc: +; ser_ir.c 98 +00101$: + mov dptr,#_rcnt + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00101$ +00111$: +; ser_ir.c 100 + clr _ES +; ser_ir.c 101 + mov a,r2 + add a,#0xff + mov dptr,#_rcnt + movx @dptr,a +; ser_ir.c 102 + mov dptr,#_rpos + movx a,@dptr +; Peephole 214 reduced some extra movs + mov r2,a + add a,#0x01 +; Peephole 100 removed redundant mov + mov r3,a + mov dptr,#_rpos + movx @dptr,a + mov a,r2 + add a,#_rbuf + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_rbuf >> 8) + mov dph,a + movx a,@dptr + mov r2,a +; ser_ir.c 103 + cjne r3,#0x0a,00112$ +00112$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00105$ +00113$: +; ser_ir.c 104 + mov dptr,#_rpos +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +00105$: +; ser_ir.c 105 + setb _ES +; ser_ir.c 106 + mov dpl,r2 +00106$: + C$ser_ir.c$107$1$1 ==. + XG$ser_getc$0$0 ==. + ret + G$ser_puts$0$0 ==. +; ser_ir.c 110 +; ----------------------------------------- +; function ser_puts +; ----------------------------------------- +_ser_puts: +; ser_ir.c 0 + push b + push dph + push dpl + mov dptr,#_ser_puts_s_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; ser_ir.c 113 +00103$: + mov dptr,#_ser_puts_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#_ser_puts_s_1_1 + mov a,#0x01 + add a,r2 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + inc dptr + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00111$: +; ser_ir.c 114 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r2,#0x0a,00102$ +; Peephole 201 removed redundant sjmp +00112$: +00113$: + push ar2 + mov dpl,#0x0d + lcall _ser_putc + pop ar2 +00102$: +; ser_ir.c 115 + mov dpl,r2 + lcall _ser_putc +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00106$: + C$ser_ir.c$117$1$1 ==. + XG$ser_puts$0$0 ==. + ret + G$ser_gets$0$0 ==. +; ser_ir.c 119 +; ----------------------------------------- +; function ser_gets +; ----------------------------------------- +_ser_gets: +; ser_ir.c 130 + push b + push dph + push dpl + mov dptr,#_ser_gets_s_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; ser_ir.c 124 + mov dptr,#_ser_gets_PARM_2 + movx a,@dptr + mov r2,a + mov dptr,#_ser_gets_s_1_1 + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov r6,#0x00 +00105$: + mov ar7,r6 + clr c + mov a,r2 + subb a,r6 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00113$: +; ser_ir.c 125 + push ar2 + push ar3 + push ar4 + push ar5 + push ar6 + push ar7 + lcall _ser_getc + mov r0,dpl + pop ar7 + pop ar6 + pop ar5 + pop ar4 + pop ar3 + pop ar2 +; ser_ir.c 126 + cjne r0,#0x0d,00114$ +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00114$: +; ser_ir.c 127 + inc r6 + mov a,r7 + add a,r3 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + mov dph,a + mov b,r5 + mov a,r0 + lcall __gptrput +; ser_ir.c 128 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r0,#0x0a,00105$ +; Peephole 201 removed redundant sjmp +00115$: +00116$: +00107$: +; ser_ir.c 130 + mov dptr,#_ser_gets_s_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov a,r6 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a + mov b,r4 +; Peephole 180 changed mov to clr + clr a + lcall __gptrput +00108$: + C$ser_ir.c$131$1$1 ==. + XG$ser_gets$0$0 ==. + ret + G$ser_can_xmt$0$0 ==. +; ser_ir.c 133 +; ----------------------------------------- +; function ser_can_xmt +; ----------------------------------------- +_ser_can_xmt: +; ser_ir.c 135 + mov dptr,#_xcnt + movx a,@dptr + mov r2,a + clr c + mov a,#0x0a + subb a,r2 + mov r2,a + mov dpl,r2 +00101$: + C$ser_ir.c$136$1$1 ==. + XG$ser_can_xmt$0$0 ==. + ret + G$ser_can_rcv$0$0 ==. +; ser_ir.c 138 +; ----------------------------------------- +; function ser_can_rcv +; ----------------------------------------- +_ser_can_rcv: +; ser_ir.c 140 + mov dptr,#_rcnt + movx a,@dptr + mov r2,a + mov dpl,r2 +00101$: + C$ser_ir.c$141$1$1 ==. + XG$ser_can_rcv$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/ser_ir.cdb b/device/lib/large/ser_ir.cdb new file mode 100644 index 00000000..c7e9cdc4 --- /dev/null +++ b/device/lib/large/ser_ir.cdb @@ -0,0 +1,96 @@ +M:ser_ir +F:G$ser_init$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_handler$0$0({2}DF,SV:S),Z,0,0,1,4,0 +F:G$ser_putc$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_getc$0$0({2}DF,SC:U),Z,0,0,0,0,0 +F:G$ser_puts$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_gets$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_can_xmt$0$0({2}DF,SC:U),Z,0,0,0,0,0 +F:G$ser_can_rcv$0$0({2}DF,SC:U),Z,0,0,0,0,0 +S:Fser_ir$rbuf$0$0({10}DA10,SC:U),F,0,0 +S:Fser_ir$xbuf$0$0({10}DA10,SC:U),F,0,0 +S:Fser_ir$rcnt$0$0({1}SC:U),F,0,0 +S:Fser_ir$xcnt$0$0({1}SC:U),F,0,0 +S:Fser_ir$rpos$0$0({1}SC:U),F,0,0 +S:Fser_ir$xpos$0$0({1}SC:U),F,0,0 +S:Fser_ir$busy$0$0({1}SC:U),F,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$A$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$AIN0$0$0({1}SX:S),J,0,0 +S:G$AIN1$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET2$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$P3_0$0$0({1}SX:S),J,0,0 +S:G$P3_1$0$0({1}SX:S),J,0,0 +S:G$P3_2$0$0({1}SX:S),J,0,0 +S:G$P3_3$0$0({1}SX:S),J,0,0 +S:G$P3_4$0$0({1}SX:S),J,0,0 +S:G$P3_5$0$0({1}SX:S),J,0,0 +S:G$P3_7$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$AOUT$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$FL$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 diff --git a/device/lib/large/ser_ir.rel b/device/lib/large/ser_ir.rel new file mode 100644 index 00000000..91640974 --- /dev/null +++ b/device/lib/large/ser_ir.rel @@ -0,0 +1,713 @@ +;!FILE ser_ir.asm +XH +H 8 areas 1B5 global symbols +M ser_ir +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$TB8$0$0 Def009B +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$TXD$0$0 Def00B1 +S G$SM0$0$0 Def009F +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$FL$0$0 Def00D1 +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$RS0$0$0 Def00D3 +S G$PT1$0$0 Def00BB +S G$F0$0$0 Def00D5 +S G$RS1$0$0 Def00D4 +S G$TR0$0$0 Def008C +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S __gptrput Ref0000 +S G$A$0$0 Def00E0 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$PS$0$0 Def00BC +S G$P3$0$0 Def00B0 +S G$SP$0$0 Def0081 +S G$T0$0$0 Def00B4 +S G$OV$0$0 Def00D2 +S G$T1$0$0 Def00B5 +S G$ACC$0$0 Def00E0 +S G$AIN0$0$0 Def0090 +S G$AIN1$0$0 Def0091 +S G$P$0$0 Def00D0 +S G$P1_0$0$0 Def0090 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P3_0$0$0 Def00B0 +S G$P1_2$0$0 Def0092 +S G$P3_1$0$0 Def00B1 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P3_2$0$0 Def00B2 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$P3_3$0$0 Def00B3 +S G$P1_5$0$0 Def0095 +S G$P3_4$0$0 Def00B4 +S G$P1_6$0$0 Def0096 +S G$P3_5$0$0 Def00B5 +S G$P1_7$0$0 Def0097 +S G$AOUT$0$0 Def00B6 +S G$P3_7$0$0 Def00B7 +S G$INT0$0$0 Def00B2 +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$ET2$0$0 Def00AD +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 21 flags 40 +S Fser_ir$xpos$0$0 Def0017 +S _ser_gets_PARM_2 Def001D +S Fser_ir$rbuf$0$0 Def0000 +S Fser_ir$xbuf$0$0 Def000A +S Fser_ir$rcnt$0$0 Def0014 +S Fser_ir$xcnt$0$0 Def0015 +S Fser_ir$busy$0$0 Def0018 +S Fser_ir$rpos$0$0 Def0016 +A GSINIT size 0 flags 20 +A CSEG size 222 flags 20 +S C$ser_ir.c$141$1$1 Def0221 +S A$ser_ir$310 Def003E +S A$ser_ir$410 Def00B9 +S A$ser_ir$401 Def00AB +S A$ser_ir$320 Def004B +S A$ser_ir$311 Def0040 +S C$ser_ir.c$107$1$1 Def0143 +S A$ser_ir$510 Def0119 +S A$ser_ir$501 Def0111 +S A$ser_ir$402 Def00AC +S A$ser_ir$330 Def0057 +S A$ser_ir$321 Def004C +S C$ser_ir.c$117$1$1 Def0191 +S A$ser_ir$610 Def0180 +S A$ser_ir$601 Def017B +S A$ser_ir$520 Def0125 +S A$ser_ir$511 Def011C +S A$ser_ir$430 Def00C9 +S A$ser_ir$421 Def00BC +S A$ser_ir$340 Def0065 +S A$ser_ir$331 Def0058 +S A$ser_ir$322 Def004D +S A$ser_ir$304 Def0032 +S C$ser_ir.c$136$1$1 Def0219 +S _ser_putc Def00BC +S A$ser_ir$710 Def01F8 +S A$ser_ir$701 Def01F0 +S A$ser_ir$611 Def0182 +S A$ser_ir$530 Def0134 +S A$ser_ir$521 Def0128 +S A$ser_ir$503 Def0112 +S A$ser_ir$422 Def00BE +S A$ser_ir$413 Def00BB +S A$ser_ir$404 Def00AD +S A$ser_ir$341 Def0066 +S A$ser_ir$332 Def0059 +S A$ser_ir$314 Def0043 +S A$ser_ir$305 Def0034 +S A$ser_ir$720 Def0202 +S A$ser_ir$711 Def01F9 +S A$ser_ir$612 Def0185 +S A$ser_ir$522 Def0129 +S A$ser_ir$513 Def011D +S A$ser_ir$450 Def00DE +S A$ser_ir$441 Def00D4 +S A$ser_ir$423 Def00C1 +S A$ser_ir$405 Def00AF +S A$ser_ir$360 Def007B +S A$ser_ir$342 Def0068 +S A$ser_ir$333 Def005C +S A$ser_ir$306 Def0036 +S A$ser_ir$270 Def0010 +S A$ser_ir$261 Def0005 +S G$ser_can_xmt$0$0 Def020D +S A$ser_ir$730 Def020C +S A$ser_ir$721 Def0203 +S A$ser_ir$712 Def01FA +S A$ser_ir$640 Def01A2 +S A$ser_ir$631 Def0192 +S A$ser_ir$613 Def0188 +S A$ser_ir$541 Def013D +S A$ser_ir$532 Def0135 +S A$ser_ir$523 Def012A +S A$ser_ir$514 Def0120 +S A$ser_ir$460 Def00ED +S A$ser_ir$451 Def00E1 +S A$ser_ir$433 Def00CC +S A$ser_ir$424 Def00C3 +S A$ser_ir$406 Def00B1 +S A$ser_ir$370 Def0086 +S A$ser_ir$361 Def007C +S A$ser_ir$352 Def0072 +S A$ser_ir$325 Def0050 +S A$ser_ir$307 Def0038 +S A$ser_ir$271 Def0011 +S A$ser_ir$262 Def0006 +S XG$ser_gets$0$0 Def020C +S A$ser_ir$740 Def0211 +S A$ser_ir$722 Def0204 +S A$ser_ir$713 Def01FB +S A$ser_ir$650 Def01B0 +S A$ser_ir$641 Def01A4 +S A$ser_ir$632 Def0194 +S A$ser_ir$623 Def0191 +S A$ser_ir$560 Def0146 +S A$ser_ir$551 Def0143 +S A$ser_ir$542 Def013E +S A$ser_ir$524 Def012C +S A$ser_ir$506 Def0114 +S A$ser_ir$470 Def00F9 +S A$ser_ir$443 Def00D5 +S A$ser_ir$407 Def00B3 +S A$ser_ir$380 Def0092 +S A$ser_ir$371 Def0089 +S A$ser_ir$362 Def007F +S A$ser_ir$344 Def006A +S A$ser_ir$335 Def005D +S A$ser_ir$317 Def0046 +S A$ser_ir$308 Def003A +S A$ser_ir$290 Def002A +S A$ser_ir$281 Def001B +S A$ser_ir$263 Def0007 +S XG$ser_init$0$0 Def0031 +S A$ser_ir$741 Def0212 +S A$ser_ir$723 Def0206 +S A$ser_ir$714 Def01FC +S A$ser_ir$660 Def01BB +S A$ser_ir$651 Def01B1 +S A$ser_ir$642 Def01A5 +S A$ser_ir$633 Def0196 +S A$ser_ir$606 Def017D +S A$ser_ir$570 Def0157 +S A$ser_ir$561 Def0148 +S A$ser_ir$516 Def0121 +S A$ser_ir$480 Def0104 +S A$ser_ir$471 Def00FB +S A$ser_ir$462 Def00EE +S A$ser_ir$453 Def00E2 +S A$ser_ir$408 Def00B5 +S A$ser_ir$390 Def00A1 +S A$ser_ir$381 Def0095 +S A$ser_ir$363 Def0080 +S A$ser_ir$345 Def006B +S A$ser_ir$336 Def005E +S A$ser_ir$309 Def003C +S A$ser_ir$291 Def002D +S A$ser_ir$273 Def0014 +S A$ser_ir$760 Def021F +S A$ser_ir$742 Def0213 +S A$ser_ir$715 Def01FD +S A$ser_ir$670 Def01C5 +S A$ser_ir$661 Def01BC +S A$ser_ir$652 Def01B2 +S A$ser_ir$634 Def0198 +S A$ser_ir$616 Def018A +S A$ser_ir$580 Def0161 +S A$ser_ir$562 Def014A +S A$ser_ir$526 Def012E +S A$ser_ir$517 Def0122 +S A$ser_ir$508 Def0116 +S A$ser_ir$481 Def0107 +S A$ser_ir$463 Def00EF +S A$ser_ir$454 Def00E3 +S A$ser_ir$436 Def00CE +S A$ser_ir$427 Def00C4 +S A$ser_ir$409 Def00B7 +S A$ser_ir$382 Def0096 +S A$ser_ir$373 Def008A +S A$ser_ir$355 Def0075 +S A$ser_ir$346 Def006D +S A$ser_ir$337 Def005F +S A$ser_ir$328 Def0052 +S A$ser_ir$319 Def0048 +S A$ser_ir$283 Def001E +S A$ser_ir$274 Def0015 +S A$ser_ir$265 Def000A +S A$ser_ir$743 Def0215 +S A$ser_ir$725 Def0208 +S A$ser_ir$716 Def01FE +S A$ser_ir$707 Def01F3 +S A$ser_ir$680 Def01DA +S A$ser_ir$671 Def01C7 +S A$ser_ir$653 Def01B3 +S A$ser_ir$644 Def01A6 +S A$ser_ir$635 Def019B +S A$ser_ir$617 Def018C +S A$ser_ir$590 Def016D +S A$ser_ir$581 Def0162 +S A$ser_ir$563 Def014D +S A$ser_ir$545 Def013F +S A$ser_ir$536 Def0138 +S A$ser_ir$527 Def012F +S A$ser_ir$509 Def0117 +S A$ser_ir$482 Def0109 +S A$ser_ir$473 Def00FC +S A$ser_ir$464 Def00F1 +S A$ser_ir$455 Def00E4 +S A$ser_ir$446 Def00D7 +S A$ser_ir$428 Def00C7 +S A$ser_ir$392 Def00A3 +S A$ser_ir$383 Def0097 +S A$ser_ir$374 Def008D +S A$ser_ir$365 Def0081 +S A$ser_ir$347 Def006F +S A$ser_ir$338 Def0062 +S A$ser_ir$329 Def0055 +S A$ser_ir$293 Def002F +S A$ser_ir$266 Def000B +S A$ser_ir$257 Def0000 +S A$ser_ir$744 Def0216 +S A$ser_ir$726 Def0209 +S A$ser_ir$717 Def01FF +S A$ser_ir$708 Def01F6 +S A$ser_ir$690 Def01E4 +S A$ser_ir$672 Def01C9 +S A$ser_ir$654 Def01B4 +S A$ser_ir$645 Def01A9 +S A$ser_ir$636 Def019D +S A$ser_ir$591 Def016E +S A$ser_ir$582 Def0163 +S A$ser_ir$573 Def0158 +S A$ser_ir$564 Def014F +S A$ser_ir$528 Def0131 +S A$ser_ir$519 Def0124 +S A$ser_ir$465 Def00F2 +S A$ser_ir$456 Def00E7 +S A$ser_ir$447 Def00DA +S A$ser_ir$438 Def00D0 +S A$ser_ir$429 Def00C8 +S A$ser_ir$384 Def0099 +S A$ser_ir$357 Def0077 +S A$ser_ir$348 Def0071 +S A$ser_ir$339 Def0063 +S A$ser_ir$285 Def0021 +S A$ser_ir$276 Def0016 +S A$ser_ir$267 Def000C +S A$ser_ir$745 Def0217 +S A$ser_ir$718 Def0200 +S A$ser_ir$709 Def01F7 +S A$ser_ir$682 Def01DC +S A$ser_ir$673 Def01CB +S A$ser_ir$664 Def01BD +S A$ser_ir$655 Def01B5 +S A$ser_ir$646 Def01AA +S A$ser_ir$637 Def019E +S A$ser_ir$619 Def018F +S A$ser_ir$592 Def016F +S A$ser_ir$583 Def0166 +S A$ser_ir$574 Def015B +S A$ser_ir$565 Def0150 +S A$ser_ir$547 Def0141 +S A$ser_ir$529 Def0133 +S A$ser_ir$466 Def00F5 +S A$ser_ir$457 Def00E8 +S A$ser_ir$448 Def00DC +S A$ser_ir$439 Def00D3 +S A$ser_ir$376 Def008E +S A$ser_ir$358 Def007A +S A$ser_ir$259 Def0002 +S A$ser_ir$764 Def0221 +S A$ser_ir$692 Def01E6 +S A$ser_ir$674 Def01CE +S A$ser_ir$656 Def01B6 +S A$ser_ir$647 Def01AB +S A$ser_ir$638 Def01A0 +S A$ser_ir$593 Def0170 +S A$ser_ir$584 Def0168 +S A$ser_ir$575 Def015C +S A$ser_ir$566 Def0152 +S A$ser_ir$539 Def013A +S A$ser_ir$485 Def010A +S A$ser_ir$476 Def00FE +S A$ser_ir$458 Def00EA +S A$ser_ir$449 Def00DD +S A$ser_ir$386 Def009B +S A$ser_ir$377 Def008F +S A$ser_ir$368 Def0083 +S A$ser_ir$287 Def0024 +S A$ser_ir$278 Def0019 +S A$ser_ir$269 Def000F +S A$ser_ir$738 Def020D +S A$ser_ir$693 Def01E7 +S A$ser_ir$684 Def01DF +S A$ser_ir$675 Def01D0 +S A$ser_ir$648 Def01AE +S A$ser_ir$639 Def01A1 +S A$ser_ir$594 Def0171 +S A$ser_ir$585 Def0169 +S A$ser_ir$576 Def015D +S A$ser_ir$567 Def0153 +S A$ser_ir$477 Def0101 +S A$ser_ir$468 Def00F6 +S A$ser_ir$459 Def00EB +S A$ser_ir$396 Def00A6 +S A$ser_ir$387 Def009C +S A$ser_ir$369 Def0084 +S A$ser_ir$297 Def0031 +S A$ser_ir$279 Def001A +S G$ser_gets$0$0 Def0192 +S A$ser_ir$757 Def021A +S A$ser_ir$739 Def0210 +S A$ser_ir$694 Def01E8 +S A$ser_ir$676 Def01D2 +S A$ser_ir$667 Def01BF +S A$ser_ir$658 Def01B8 +S A$ser_ir$649 Def01AF +S A$ser_ir$595 Def0173 +S A$ser_ir$577 Def015E +S A$ser_ir$568 Def0154 +S A$ser_ir$559 Def0144 +S A$ser_ir$478 Def0102 +S A$ser_ir$469 Def00F7 +S A$ser_ir$388 Def009E +S A$ser_ir$379 Def0091 +S A$ser_ir$289 Def0027 +S XG$ser_putc$0$0 Def010C +S C$ser_ir.c$60$1$1 Def0031 +S G$ser_init$0$0 Def0000 +S A$ser_ir$758 Def021D +S A$ser_ir$749 Def0219 +S A$ser_ir$695 Def01EA +S A$ser_ir$677 Def01D4 +S A$ser_ir$668 Def01C1 +S A$ser_ir$659 Def01BA +S A$ser_ir$596 Def0175 +S A$ser_ir$587 Def016A +S A$ser_ir$578 Def015F +S A$ser_ir$569 Def0156 +S A$ser_ir$389 Def00A0 +S A$ser_ir$759 Def021E +S A$ser_ir$696 Def01EC +S A$ser_ir$687 Def01E1 +S A$ser_ir$678 Def01D6 +S A$ser_ir$669 Def01C3 +S A$ser_ir$597 Def0177 +S A$ser_ir$588 Def016B +S A$ser_ir$579 Def0160 +S A$ser_ir$498 Def010D +S A$ser_ir$489 Def010C +S A$ser_ir$399 Def00A8 +S A$ser_ir$697 Def01ED +S A$ser_ir$688 Def01E2 +S A$ser_ir$679 Def01D8 +S A$ser_ir$589 Def016C +S A$ser_ir$499 Def0110 +S A$ser_ir$689 Def01E3 +S A$ser_ir$599 Def017A +S _ser_puts Def0144 +S C$ser_ir.c$93$1$1 Def010C +S G$ser_putc$0$0 Def00BC +S C$ser_ir.c$79$1$1 Def00BB +S XG$ser_puts$0$0 Def0191 +S _ser_can_rcv Def021A +S _ser_handler Def0032 +S G$ser_puts$0$0 Def0144 +S _ser_getc Def010D +S XG$ser_can_rcv$0$0 Def0221 +S XG$ser_handler$0$0 Def00BB +S _ser_can_xmt Def020D +S XG$ser_getc$0$0 Def0143 +S G$ser_can_rcv$0$0 Def021A +S G$ser_handler$0$0 Def0032 +S _ser_gets Def0192 +S _ser_init Def0000 +S XG$ser_can_xmt$0$0 Def0219 +S C$ser_ir.c$131$1$1 Def020C +S G$ser_getc$0$0 Def010D +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 0A +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 14 +R 00 00 00 05 +T 00 15 +R 00 00 00 05 +T 00 15 +R 00 00 00 05 +T 00 16 +R 00 00 00 05 +T 00 16 +R 00 00 00 05 +T 00 17 +R 00 00 00 05 +T 00 17 +R 00 00 00 05 +T 00 18 +R 00 00 00 05 +T 00 18 +R 00 00 00 05 +T 00 19 +R 00 00 00 05 +T 00 19 +R 00 00 00 05 +T 00 1A +R 00 00 00 05 +T 00 1A +R 00 00 00 05 +T 00 1D +R 00 00 00 05 +T 00 1D +R 00 00 00 05 +T 00 1E +R 00 00 00 05 +T 00 1E +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C2 AC 90 00 17 E4 F0 90 00 16 E4 F0 90 +R 00 00 00 07 00 05 00 05 00 0A 00 05 +T 00 0D 00 15 E4 F0 90 00 14 E4 F0 90 00 18 E4 F0 +R 00 00 00 07 00 02 00 05 00 07 00 05 00 0C 00 05 +T 00 1B 75 98 50 43 87 80 53 89 0F 43 89 20 75 8B +R 00 00 00 07 +T 00 29 FD 75 8D FD D2 8E D2 AC +R 00 00 00 07 +T 00 31 +R 00 00 00 07 +T 00 31 22 +R 00 00 00 07 +T 00 32 +R 00 00 00 07 +T 00 32 C0 E0 C0 F0 C0 82 C0 83 C0 02 C0 03 C0 D0 +R 00 00 00 07 +T 00 40 75 D0 00 30 98 2C +R 00 00 00 07 +T 00 46 +R 00 00 00 07 +T 00 46 C2 98 90 00 14 E0 FA BA 0A 00 +R 00 00 00 07 00 05 00 05 +T 00 50 +R 00 00 00 07 +T 00 50 50 20 +R 00 00 00 07 +T 00 52 +R 00 00 00 07 +T 00 52 90 00 14 74 01 2A F0 90 00 16 E0 FB 2A 75 +R 00 00 00 07 00 03 00 05 00 0A 00 05 +T 00 60 F0 0A 84 AA F0 EA 24 00 00 F5 82 E4 34 +R 00 00 00 07 09 09 00 05 +T 00 6C 00 00 F5 83 E5 99 F0 +R 00 00 00 07 89 02 00 05 +T 00 72 +R 00 00 00 07 +T 00 72 30 99 38 +R 00 00 00 07 +T 00 75 +R 00 00 00 07 +T 00 75 C2 99 90 00 15 E0 FA 90 00 18 F0 EA 60 2A +R 00 00 00 07 00 05 00 05 00 0A 00 05 +T 00 83 +R 00 00 00 07 +T 00 83 EA 24 FF 90 00 15 F0 90 00 17 E0 FA 24 01 +R 00 00 00 07 00 06 00 05 00 0A 00 05 +T 00 91 FB 90 00 17 F0 EA 24 00 0A F5 82 E4 34 +R 00 00 00 07 00 04 00 05 09 09 00 05 +T 00 9D 00 0A F5 83 E0 F5 99 BB 0A 00 +R 00 00 00 07 89 02 00 05 +T 00 A6 +R 00 00 00 07 +T 00 A6 40 05 +R 00 00 00 07 +T 00 A8 +R 00 00 00 07 +T 00 A8 90 00 17 E4 F0 +R 00 00 00 07 00 03 00 05 +T 00 AD +R 00 00 00 07 +T 00 AD D0 D0 D0 03 D0 02 D0 83 D0 82 D0 F0 D0 E0 +R 00 00 00 07 +T 00 BB 32 +R 00 00 00 07 +T 00 BC +R 00 00 00 07 +T 00 BC C0 82 90 00 19 D0 E0 F0 +R 00 00 00 07 00 05 00 05 +T 00 C4 +R 00 00 00 07 +T 00 C4 90 00 15 E0 FA BA 0A 00 +R 00 00 00 07 00 03 00 05 +T 00 CC +R 00 00 00 07 +T 00 CC 50 F6 +R 00 00 00 07 +T 00 CE +R 00 00 00 07 +T 00 CE C2 AC 90 00 18 E0 FB 60 27 +R 00 00 00 07 00 05 00 05 +T 00 D7 +R 00 00 00 07 +T 00 D7 90 00 15 74 01 2A F0 90 00 17 E0 FB 2A 75 +R 00 00 00 07 00 03 00 05 00 0A 00 05 +T 00 E5 F0 0A 84 AA F0 EA 24 00 0A FA E4 34 00 0A +R 00 00 00 07 09 09 00 05 89 0E 00 05 +T 00 F1 FB 90 00 19 E0 FC 8A 82 8B 83 F0 80 0C +R 00 00 00 07 00 04 00 05 +T 00 FE +R 00 00 00 07 +T 00 FE 90 00 19 E0 F5 99 90 00 18 74 01 F0 +R 00 00 00 07 00 03 00 05 00 09 00 05 +T 01 0A +R 00 00 00 07 +T 01 0A D2 AC +R 00 00 00 07 +T 01 0C +R 00 00 00 07 +T 01 0C 22 +R 00 00 00 07 +T 01 0D +R 00 00 00 07 +T 01 0D +R 00 00 00 07 +T 01 0D 90 00 14 E0 FA 60 F9 +R 00 00 00 07 00 03 00 05 +T 01 14 +R 00 00 00 07 +T 01 14 C2 AC EA 24 FF 90 00 14 F0 90 00 16 E0 FA +R 00 00 00 07 00 08 00 05 00 0C 00 05 +T 01 22 24 01 FB 90 00 16 F0 EA 24 00 00 F5 82 E4 +R 00 00 00 07 00 06 00 05 09 0B 00 05 +T 01 2F 34 00 00 F5 83 E0 FA BB 0A 00 +R 00 00 00 07 89 03 00 05 +T 01 38 +R 00 00 00 07 +T 01 38 40 05 +R 00 00 00 07 +T 01 3A +R 00 00 00 07 +T 01 3A 90 00 16 E4 F0 +R 00 00 00 07 00 03 00 05 +T 01 3F +R 00 00 00 07 +T 01 3F D2 AC 8A 82 +R 00 00 00 07 +T 01 43 +R 00 00 00 07 +T 01 43 22 +R 00 00 00 07 +T 01 44 +R 00 00 00 07 +T 01 44 C0 F0 C0 83 C0 82 90 00 1A D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 01 52 A3 F0 D0 E0 A3 F0 +R 00 00 00 07 +T 01 58 +R 00 00 00 07 +T 01 58 90 00 1A E0 FA A3 E0 FB A3 E0 FC 90 00 1A +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 01 66 74 01 2A F0 E4 3B A3 F0 A3 EC F0 8A 82 8B +R 00 00 00 07 +T 01 74 83 8C F0 12 00 00 FA 60 14 +R 00 00 00 07 02 06 00 4A +T 01 7D +R 00 00 00 07 +T 01 7D BA 0A 0A +R 00 00 00 07 +T 01 80 +R 00 00 00 07 +T 01 80 +R 00 00 00 07 +T 01 80 C0 02 75 82 0D 12 00 BC D0 02 +R 00 00 00 07 00 08 00 07 +T 01 8A +R 00 00 00 07 +T 01 8A 8A 82 12 00 BC 80 C7 +R 00 00 00 07 00 05 00 07 +T 01 91 +R 00 00 00 07 +T 01 91 22 +R 00 00 00 07 +T 01 92 +R 00 00 00 07 +T 01 92 C0 F0 C0 83 C0 82 90 00 1E D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 01 A0 A3 F0 D0 E0 A3 F0 90 00 1D E0 FA 90 00 1E +R 00 00 00 07 00 09 00 05 00 0E 00 05 +T 01 AE E0 FB A3 E0 FC A3 E0 FD 7E 00 +R 00 00 00 07 +T 01 B8 +R 00 00 00 07 +T 01 B8 8E 07 C3 EA 9E 40 34 +R 00 00 00 07 +T 01 BF +R 00 00 00 07 +T 01 BF C0 02 C0 03 C0 04 C0 05 C0 06 C0 07 12 +R 00 00 00 07 +T 01 CC 01 0D A8 82 D0 07 D0 06 D0 05 D0 04 D0 03 +R 00 00 00 07 00 02 00 07 +T 01 DA D0 02 B8 0D 02 80 D7 +R 00 00 00 07 +T 01 E1 +R 00 00 00 07 +T 01 E1 0E EF 2B F5 82 E4 3C F5 83 8D F0 E8 12 +R 00 00 00 07 +T 01 EE 00 00 B8 0A C5 +R 00 00 00 07 02 02 00 1E +T 01 F3 +R 00 00 00 07 +T 01 F3 +R 00 00 00 07 +T 01 F3 +R 00 00 00 07 +T 01 F3 90 00 1E E0 FA A3 E0 FB A3 E0 FC EE 2A F5 +R 00 00 00 07 00 03 00 05 +T 02 01 82 E4 3B F5 83 8C F0 E4 12 00 00 +R 00 00 00 07 02 0B 00 1E +T 02 0C +R 00 00 00 07 +T 02 0C 22 +R 00 00 00 07 +T 02 0D +R 00 00 00 07 +T 02 0D 90 00 15 E0 FA C3 74 0A 9A FA 8A 82 +R 00 00 00 07 00 03 00 05 +T 02 19 +R 00 00 00 07 +T 02 19 22 +R 00 00 00 07 +T 02 1A +R 00 00 00 07 +T 02 1A 90 00 14 E0 FA 8A 82 +R 00 00 00 07 00 03 00 05 +T 02 21 +R 00 00 00 07 +T 02 21 22 +R 00 00 00 07 diff --git a/device/lib/large/serial.asm b/device/lib/large/serial.asm new file mode 100644 index 00000000..b336c60e --- /dev/null +++ b/device/lib/large/serial.asm @@ -0,0 +1,515 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + +;-------------------------------------------------------- + .module serial +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _serial_getc + .globl _serial_putc + .globl _serial_interrupt_handler + .globl _serial_init +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +Fserial$work_flag_byte_arrived$0$0==. +_work_flag_byte_arrived: + .ds 0x0001 +Fserial$work_flag_buffer_transfered$0$0==. +_work_flag_buffer_transfered: + .ds 0x0001 +Fserial$tx_serial_buffer_empty$0$0==. +_tx_serial_buffer_empty: + .ds 0x0001 +Fserial$rx_serial_buffer_empty$0$0==. +_rx_serial_buffer_empty: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +Fserial$stx_index_in$0$0==. +_stx_index_in: + .ds 0x0001 +Fserial$srx_index_in$0$0==. +_srx_index_in: + .ds 0x0001 +Fserial$stx_index_out$0$0==. +_stx_index_out: + .ds 0x0001 +Fserial$srx_index_out$0$0==. +_srx_index_out: + .ds 0x0001 +Fserial$stx_buffer$0$0==. +_stx_buffer: + .ds 0x0100 +Fserial$srx_buffer$0$0==. +_srx_buffer: + .ds 0x0100 +_serial_putc_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$serial_init$0$0 ==. +; serial.c 24 +; ----------------------------------------- +; function serial_init +; ----------------------------------------- +_serial_init: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; serial.c 26 + mov _SCON,#0x50 +; serial.c 27 + mov _T2CON,#0x34 +; serial.c 28 + setb _PS +; serial.c 29 + mov _T2CON,#0x34 +; serial.c 30 + mov _RCAP2H,#0xff +; serial.c 31 + mov _RCAP2L,#0xda +; serial.c 33 + clr _RI +; serial.c 34 + clr _TI +; serial.c 36 + mov dptr,#_srx_index_out +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_stx_index_out +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_srx_index_in +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_stx_index_in +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; serial.c 37 + setb _tx_serial_buffer_empty + setb _rx_serial_buffer_empty +; serial.c 38 + clr _work_flag_buffer_transfered +; serial.c 39 + clr _work_flag_byte_arrived +; serial.c 40 + setb _ES +00101$: + C$serial.c$41$1$1 ==. + XG$serial_init$0$0 ==. + ret + G$serial_interrupt_handler$0$0 ==. +; serial.c 43 +; ----------------------------------------- +; function serial_interrupt_handler +; ----------------------------------------- +_serial_interrupt_handler: + ar2 = 0x0a + ar3 = 0x0b + ar4 = 0x0c + ar5 = 0x0d + ar6 = 0x0e + ar7 = 0x0f + ar0 = 0x08 + ar1 = 0x09 + push acc + push b + push dpl + push dph + push psw + mov psw,#0x08 +; serial.c 45 + clr _ES +; serial.c 46 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00105$ +00113$: +; serial.c 48 + clr _TI +; serial.c 49 + mov dptr,#_stx_index_in + movx a,@dptr + mov r2,a + mov dptr,#_stx_index_out + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar2,00102$ +; Peephole 201 removed redundant sjmp +00114$: +00115$: +; serial.c 51 + setb _tx_serial_buffer_empty +; serial.c 52 + setb _work_flag_buffer_transfered +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00102$: +; serial.c 54 + mov dptr,#_stx_index_out + mov a,#0x01 + add a,r3 + movx @dptr,a + mov a,r3 + add a,#_stx_buffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_stx_buffer >> 8) + mov dph,a + movx a,@dptr + mov _SBUF,a +00105$: +; serial.c 56 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00107$ +00116$: +; serial.c 58 + clr _RI +; serial.c 59 + mov dptr,#_srx_index_in + movx a,@dptr + mov r2,a + mov dptr,#_srx_index_in + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_srx_buffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_srx_buffer >> 8) + mov dph,a + mov a,_SBUF + movx @dptr,a +; serial.c 60 + setb _work_flag_byte_arrived +; serial.c 61 + clr _rx_serial_buffer_empty +00107$: +; serial.c 63 + setb _ES +00108$: + pop psw + pop dph + pop dpl + pop b + pop acc + C$serial.c$64$1$1 ==. + XG$serial_interrupt_handler$0$0 ==. + reti + G$serial_putc$0$0 ==. +; serial.c 68 +; ----------------------------------------- +; function serial_putc +; ----------------------------------------- +_serial_putc: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; serial.c 77 + push dpl + mov dptr,#_serial_putc_c_1_1 + pop acc + movx @dptr,a +; serial.c 70 + mov dptr,#_stx_index_in + movx a,@dptr + mov r2,a + mov dptr,#_stx_index_in + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_stx_buffer + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_stx_buffer >> 8) + mov r3,a + mov dptr,#_serial_putc_c_1_1 + movx a,@dptr +; Peephole 136 removed redundant moves + mov r4,a + mov dpl,r2 + mov dph,r3 + movx @dptr,a +; serial.c 71 + clr _ES +; serial.c 72 +; Peephole 111 removed ljmp by inverse jump logic + jnb _tx_serial_buffer_empty,00102$ +00106$: +; serial.c 74 + clr _tx_serial_buffer_empty +; serial.c 75 + setb _TI +00102$: +; serial.c 77 + setb _ES +00103$: + C$serial.c$78$1$1 ==. + XG$serial_putc$0$0 ==. + ret + G$serial_getc$0$0 ==. +; serial.c 80 +; ----------------------------------------- +; function serial_getc +; ----------------------------------------- +_serial_getc: +; serial.c 82 + mov dptr,#_srx_index_out + movx a,@dptr +; Peephole 214 reduced some extra movs + mov r2,a + add a,#0x01 +; Peephole 100 removed redundant mov + mov r3,a + mov dptr,#_srx_index_out + movx @dptr,a + mov a,r2 + add a,#_srx_buffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_srx_buffer >> 8) + mov dph,a + movx a,@dptr + mov r2,a +; serial.c 83 + clr _ES +; serial.c 84 + mov dptr,#_srx_index_in + movx a,@dptr + mov r4,a + mov a,r3 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar4,00102$ +; Peephole 201 removed redundant sjmp +00106$: +00107$: + setb _rx_serial_buffer_empty +00102$: +; serial.c 85 + setb _ES +; serial.c 86 + mov dpl,r2 +00103$: + C$serial.c$87$1$1 ==. + XG$serial_getc$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/large/serial.cdb b/device/lib/large/serial.cdb new file mode 100644 index 00000000..d635ef8e --- /dev/null +++ b/device/lib/large/serial.cdb @@ -0,0 +1,98 @@ +M:serial +F:G$serial_init$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$serial_interrupt_handler$0$0({2}DF,SV:S),C,0,0,1,4,1 +F:G$serial_putc$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$serial_getc$0$0({2}DF,SC:U),C,0,0,0,0,0 +S:Fserial$work_flag_byte_arrived$0$0({1}SB0$1:S),H,0,0 +S:Fserial$work_flag_buffer_transfered$0$0({1}SB0$1:S),H,0,0 +S:Fserial$tx_serial_buffer_empty$0$0({1}SB0$1:S),H,0,0 +S:Fserial$rx_serial_buffer_empty$0$0({1}SB0$1:S),H,0,0 +S:Fserial$stx_index_in$0$0({1}SC:U),F,0,0 +S:Fserial$srx_index_in$0$0({1}SC:U),F,0,0 +S:Fserial$stx_index_out$0$0({1}SC:U),F,0,0 +S:Fserial$srx_index_out$0$0({1}SC:U),F,0,0 +S:Fserial$stx_buffer$0$0({256}DA256,SC:U),F,0,0 +S:Fserial$srx_buffer$0$0({256}DA256,SC:U),F,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/large/serial.rel b/device/lib/large/serial.rel new file mode 100644 index 00000000..decf7fbd --- /dev/null +++ b/device/lib/large/serial.rel @@ -0,0 +1,406 @@ +;!FILE serial.asm +XH +H 8 areas F6 global symbols +M serial +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 4 flags 80 +S Fserial$work_flag_byte_arrived$0$0 Def0000 +S Fserial$work_flag_buffer_transfered$0$0 Def0001 +S Fserial$rx_serial_buffer_empty$0$0 Def0003 +S Fserial$tx_serial_buffer_empty$0$0 Def0002 +A XSEG size 205 flags 40 +S Fserial$srx_buffer$0$0 Def0104 +S Fserial$stx_buffer$0$0 Def0004 +S Fserial$srx_index_in$0$0 Def0001 +S Fserial$srx_index_out$0$0 Def0003 +S Fserial$stx_index_in$0$0 Def0000 +S Fserial$stx_index_out$0$0 Def0002 +A GSINIT size 0 flags 20 +A CSEG size FA flags 20 +S A$serial$430 Def00A9 +S A$serial$403 Def0097 +S A$serial$322 Def0038 +S A$serial$440 Def00B6 +S A$serial$431 Def00AA +S A$serial$404 Def0099 +S A$serial$341 Def0051 +S A$serial$323 Def003A +S A$serial$305 Def0033 +S A$serial$441 Def00B7 +S A$serial$432 Def00AB +S A$serial$405 Def009B +S A$serial$360 Def0062 +S A$serial$351 Def0057 +S A$serial$333 Def0046 +S A$serial$324 Def003C +S A$serial$261 Def0000 +S A$serial$514 Def00F9 +S A$serial$505 Def00F3 +S A$serial$451 Def00C4 +S A$serial$442 Def00B9 +S A$serial$433 Def00AE +S A$serial$424 Def009E +S A$serial$361 Def0063 +S A$serial$325 Def003E +S A$serial$280 Def0019 +S A$serial$271 Def000E +S A$serial$443 Def00BA +S A$serial$434 Def00B0 +S A$serial$425 Def00A0 +S A$serial$380 Def0079 +S A$serial$362 Def0065 +S A$serial$353 Def0059 +S A$serial$344 Def0052 +S A$serial$335 Def0048 +S A$serial$281 Def001A +S A$serial$263 Def0003 +S A$serial$480 Def00D7 +S A$serial$462 Def00CD +S A$serial$444 Def00BD +S A$serial$435 Def00B1 +S A$serial$426 Def00A3 +S A$serial$408 Def009D +S A$serial$390 Def0088 +S A$serial$381 Def007C +S A$serial$372 Def006F +S A$serial$336 Def004B +S A$serial$327 Def0041 +S A$serial$291 Def0027 +S A$serial$273 Def0011 +S A$serial$508 Def00F5 +S A$serial$490 Def00E6 +S A$serial$481 Def00D8 +S A$serial$454 Def00C6 +S A$serial$436 Def00B2 +S A$serial$427 Def00A5 +S A$serial$391 Def008A +S A$serial$382 Def007E +S A$serial$364 Def0067 +S A$serial$337 Def004C +S A$serial$292 Def0028 +S A$serial$283 Def001D +S A$serial$265 Def0006 +S XG$serial_putc$0$0 Def00CF +S G$serial_init$0$0 Def0000 +S A$serial$491 Def00E7 +S A$serial$482 Def00DB +S A$serial$446 Def00BE +S A$serial$437 Def00B3 +S A$serial$392 Def008C +S A$serial$383 Def007F +S A$serial$365 Def0068 +S A$serial$356 Def005B +S A$serial$338 Def004D +S A$serial$284 Def001E +S A$serial$275 Def0013 +S A$serial$483 Def00DC +S A$serial$474 Def00D0 +S A$serial$447 Def00BF +S A$serial$438 Def00B5 +S A$serial$429 Def00A6 +S A$serial$384 Def0080 +S A$serial$375 Def0072 +S A$serial$366 Def006A +S A$serial$357 Def005E +S A$serial$339 Def0050 +S A$serial$294 Def0029 +S A$serial$285 Def001F +S A$serial$267 Def0008 +S A$serial$493 Def00E8 +S A$serial$484 Def00DD +S A$serial$475 Def00D3 +S A$serial$466 Def00CF +S A$serial$457 Def00C9 +S A$serial$448 Def00C1 +S A$serial$394 Def008D +S A$serial$385 Def0081 +S A$serial$367 Def006C +S A$serial$358 Def0060 +S A$serial$349 Def0055 +S A$serial$295 Def002B +S A$serial$277 Def0015 +S A$serial$485 Def00DF +S A$serial$449 Def00C3 +S A$serial$386 Def0083 +S A$serial$377 Def0074 +S A$serial$368 Def006D +S A$serial$359 Def0061 +S A$serial$287 Def0022 +S A$serial$269 Def000B +S A$serial$495 Def00EA +S A$serial$477 Def00D4 +S A$serial$459 Def00CB +S A$serial$396 Def008F +S A$serial$378 Def0077 +S A$serial$297 Def002D +S A$serial$288 Def0023 +S A$serial$279 Def0018 +S C$serial.c$41$1$1 Def0033 +S A$serial$496 Def00ED +S A$serial$487 Def00E1 +S A$serial$478 Def00D5 +S A$serial$388 Def0085 +S A$serial$379 Def0078 +S A$serial$289 Def0024 +S A$serial$497 Def00EE +S A$serial$488 Def00E2 +S A$serial$389 Def0086 +S A$serial$299 Def002F +S A$serial$498 Def00EF +S A$serial$489 Def00E4 +S A$serial$399 Def0091 +S G$serial_putc$0$0 Def009E +S C$serial.c$64$1$1 Def009D +S C$serial.c$87$1$1 Def00F9 +S C$serial.c$78$1$1 Def00CF +S _serial_getc Def00D0 +S _serial_interrupt_handler Def0034 +S XG$serial_getc$0$0 Def00F9 +S _serial_init Def0000 +S XG$serial_interrupt_handler$0$0 Def009D +S G$serial_getc$0$0 Def00D0 +S _serial_putc Def009E +S G$serial_interrupt_handler$0$0 Def0034 +S A$serial$301 Def0031 +S A$serial$401 Def0093 +S A$serial$320 Def0034 +S XG$serial_init$0$0 Def0033 +S A$serial$510 Def00F7 +S A$serial$501 Def00F0 +S A$serial$402 Def0095 +S A$serial$330 Def0043 +S A$serial$321 Def0036 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 01 04 +R 00 00 00 05 +T 01 04 +R 00 00 00 05 +T 02 04 +R 00 00 00 05 +T 02 04 +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 75 98 50 75 C8 34 D2 BC 75 C8 34 75 CB FF +R 00 00 00 07 +T 00 0E 75 CA DA C2 98 C2 99 90 00 03 E4 F0 90 +R 00 00 00 07 00 0A 00 05 +T 00 1B 00 02 E4 F0 90 00 01 E4 F0 90 00 00 E4 F0 +R 00 00 00 07 00 02 00 05 00 07 00 05 00 0C 00 05 +T 00 29 D2 00 02 D2 00 03 C2 00 01 C2 +R 00 00 00 07 29 03 00 04 29 06 00 04 29 09 00 04 +T 00 30 00 00 D2 AC +R 00 00 00 07 29 02 00 04 +T 00 33 +R 00 00 00 07 +T 00 33 22 +R 00 00 00 07 +T 00 34 +R 00 00 00 07 +T 00 34 C0 E0 C0 F0 C0 82 C0 83 C0 D0 75 D0 08 C2 +R 00 00 00 07 +T 00 42 AC 30 99 29 +R 00 00 00 07 +T 00 46 +R 00 00 00 07 +T 00 46 C2 99 90 00 00 E0 FA 90 00 02 E0 FB B5 0A +R 00 00 00 07 00 05 00 05 00 0A 00 05 +T 00 54 06 +R 00 00 00 07 +T 00 55 +R 00 00 00 07 +T 00 55 +R 00 00 00 07 +T 00 55 D2 00 02 D2 00 01 80 14 +R 00 00 00 07 29 03 00 04 29 06 00 04 +T 00 5B +R 00 00 00 07 +T 00 5B 90 00 02 74 01 2B F0 EB 24 00 04 F5 82 E4 +R 00 00 00 07 00 03 00 05 09 0B 00 05 +T 00 68 34 00 04 F5 83 E0 F5 99 +R 00 00 00 07 89 03 00 05 +T 00 6F +R 00 00 00 07 +T 00 6F 30 98 1F +R 00 00 00 07 +T 00 72 +R 00 00 00 07 +T 00 72 C2 98 90 00 01 E0 FA 90 00 01 74 01 2A F0 +R 00 00 00 07 00 05 00 05 00 0A 00 05 +T 00 80 EA 24 01 04 F5 82 E4 34 01 04 F5 83 E5 99 +R 00 00 00 07 09 04 00 05 89 0A 00 05 +T 00 8C F0 D2 00 00 C2 00 03 +R 00 00 00 07 29 04 00 04 29 07 00 04 +T 00 91 +R 00 00 00 07 +T 00 91 D2 AC +R 00 00 00 07 +T 00 93 +R 00 00 00 07 +T 00 93 D0 D0 D0 83 D0 82 D0 F0 D0 E0 32 +R 00 00 00 07 +T 00 9E +R 00 00 00 07 +T 00 9E C0 82 90 02 04 D0 E0 F0 90 00 00 E0 FA 90 +R 00 00 00 07 00 05 00 05 00 0B 00 05 +T 00 AC 00 00 74 01 2A F0 EA 24 00 04 FA E4 34 +R 00 00 00 07 00 02 00 05 09 0A 00 05 +T 00 B8 00 04 FB 90 02 04 E0 FC 8A 82 8B 83 F0 C2 +R 00 00 00 07 89 02 00 05 00 06 00 05 +T 00 C5 AC 30 00 02 04 +R 00 00 00 07 29 04 00 04 +T 00 C9 +R 00 00 00 07 +T 00 C9 C2 00 02 D2 99 +R 00 00 00 07 29 03 00 04 +T 00 CD +R 00 00 00 07 +T 00 CD D2 AC +R 00 00 00 07 +T 00 CF +R 00 00 00 07 +T 00 CF 22 +R 00 00 00 07 +T 00 D0 +R 00 00 00 07 +T 00 D0 90 00 03 E0 FA 24 01 FB 90 00 03 F0 EA 24 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 00 DE 01 04 F5 82 E4 34 01 04 F5 83 E0 FA C2 AC +R 00 00 00 07 09 02 00 05 89 08 00 05 +T 00 EA 90 00 01 E0 FC EB B5 04 02 +R 00 00 00 07 00 03 00 05 +T 00 F3 +R 00 00 00 07 +T 00 F3 +R 00 00 00 07 +T 00 F3 D2 00 03 +R 00 00 00 07 29 03 00 04 +T 00 F5 +R 00 00 00 07 +T 00 F5 D2 AC 8A 82 +R 00 00 00 07 +T 00 F9 +R 00 00 00 07 +T 00 F9 22 +R 00 00 00 07 diff --git a/device/lib/large/vprintf.asm b/device/lib/large/vprintf.asm new file mode 100644 index 00000000..9795f4ea --- /dev/null +++ b/device/lib/large/vprintf.asm @@ -0,0 +1,1471 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:39 2000 + +;-------------------------------------------------------- + .module vprintf +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _vprintf_PARM_2 + .globl _vsprintf_PARM_3 + .globl _vsprintf_PARM_2 + .globl _radix + .globl _output_ptr + .globl _lsd + .globl _lower_case + .globl _output_to_string + .globl _value + .globl _vsprintf + .globl _vprintf +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +G$value$0$0==. +_value: + .ds 0x0005 +_vsprintf_sloc0_1_0: + .ds 0x0001 +_vsprintf_sloc1_1_0: + .ds 0x0001 +_vsprintf_sloc2_1_0: + .ds 0x0003 +_vsprintf_sloc3_1_0: + .ds 0x0001 +_vsprintf_sloc4_1_0: + .ds 0x0001 +_vsprintf_sloc5_1_0: + .ds 0x0001 +_vsprintf_sloc6_1_0: + .ds 0x0001 +_vsprintf_sloc7_1_0: + .ds 0x0001 +_vsprintf_sloc8_1_0: + .ds 0x0001 +_vsprintf_sloc9_1_0: + .ds 0x0001 +_vsprintf_sloc10_1_0: + .ds 0x0001 +_vsprintf_sloc11_1_0: + .ds 0x0001 +_vsprintf_sloc12_1_0: + .ds 0x0001 +_vsprintf_sloc13_1_0: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +G$output_to_string$0$0==. +_output_to_string: + .ds 0x0001 +G$lower_case$0$0==. +_lower_case: + .ds 0x0001 +G$lsd$0$0==. +_lsd: + .ds 0x0001 +_vsprintf_left_justify_1_1: + .ds 0x0001 +_vsprintf_zero_padding_1_1: + .ds 0x0001 +_vsprintf_prefix_sign_1_1: + .ds 0x0001 +_vsprintf_prefix_space_1_1: + .ds 0x0001 +_vsprintf_signed_argument_1_1: + .ds 0x0001 +_vsprintf_char_argument_1_1: + .ds 0x0001 +_vsprintf_long_argument_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +G$output_ptr$0$0==. +_output_ptr: + .ds 0x0003 +G$radix$0$0==. +_radix: + .ds 0x0001 +_vsprintf_PARM_2: + .ds 0x0003 +_vsprintf_PARM_3: + .ds 0x0001 +_vsprintf_buf_1_1: + .ds 0x0003 +_vsprintf_width_1_1: + .ds 0x0001 +_vsprintf_length_1_1: + .ds 0x0001 +_vsprintf_c_1_1: + .ds 0x0001 +_vprintf_PARM_2: + .ds 0x0001 +_vprintf_format_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + Fvprintf$output_char$0$0 ==. +; vprintf.c 63 +; ----------------------------------------- +; function output_char +; ----------------------------------------- +_output_char: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 + push _bp + mov _bp,sp +; vprintf.c 0 + mov r2,dpl +; vprintf.c 65 +; Peephole 111 removed ljmp by inverse jump logic + jnb _output_to_string,00102$ +00107$: +; vprintf.c 67 + mov dptr,#_output_ptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov dptr,#_output_ptr + mov a,#0x01 + add a,r3 + movx @dptr,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + inc dptr + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a + mov dpl,r3 + mov dph,r4 + mov b,r5 + mov a,r2 + lcall __gptrput +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; vprintf.c 71 + mov dpl,r2 + lcall _putchar +00104$: + mov sp,_bp + pop _bp + C$vprintf.c$73$1$1 ==. + XFvprintf$output_char$0$0 ==. + ret + Fvprintf$output_digit$0$0 ==. +; vprintf.c 77 +; ----------------------------------------- +; function output_digit +; ----------------------------------------- +_output_digit: + push _bp + mov _bp,sp +; vprintf.c 79 + mov r2,dpl + clr c + mov a,#0x09 + subb a,r2 + clr a + rlc a +; Peephole 105 removed redundant mov + mov r3,a + cjne a,#0x01,00109$ +00109$: + clr a + rlc a +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00110$: + mov a,#0x30 + add a,r2 + mov r3,a +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00103$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _lower_case,00105$ +00111$: + mov a,#0x57 + add a,r2 + mov r4,a +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: + mov a,#0x37 + add a,r2 + mov r4,a +00106$: + mov ar3,r4 +00104$: + mov dpl,r3 + lcall _output_char +00101$: + mov sp,_bp + pop _bp + C$vprintf.c$80$1$1 ==. + XFvprintf$output_digit$0$0 ==. + ret + Fvprintf$output_2digits$0$0 ==. +; vprintf.c 84 +; ----------------------------------------- +; function output_2digits +; ----------------------------------------- +_output_2digits: + push _bp + mov _bp,sp +; vprintf.c 87 + mov r2,dpl +; vprintf.c 86 + mov a,r2 + swap a + anl a,#0x0f + mov r3,a + push ar2 + mov dpl,r3 + lcall _output_digit + pop ar2 +; vprintf.c 87 + anl ar2,#0x0f + mov dpl,r2 + lcall _output_digit +00101$: + mov sp,_bp + pop _bp + C$vprintf.c$88$1$1 ==. + XFvprintf$output_2digits$0$0 ==. + ret + Fvprintf$calculate_digit$0$0 ==. +; vprintf.c 92 +; ----------------------------------------- +; function calculate_digit +; ----------------------------------------- +_calculate_digit: +; vprintf.c 96 + mov r2,#0x20 +00103$: + cjne r2,#0x00,00112$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00112$: +; vprintf.c 115 + clr c + mov a,_value+0 + rlc a + mov _value+0,a + mov a,_value+1 + rlc a + mov _value+1,a + mov a,_value+2 + rlc a + mov _value+2,a + mov a,_value+3 + rlc a + mov _value+3,a + mov a,_value+4 + rlc a + mov _value+4,a +; vprintf.c 117 + mov dptr,#_radix + movx a,@dptr + mov r3,a + clr c + mov a,0x0004 + _value + subb a,r3 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00105$ +00113$: +; vprintf.c 119 + clr c + mov a,0x0004 + _value + subb a,r3 + mov 0x0004 + _value,a +; vprintf.c 120 + mov a,#0x01 + add a,_value + mov _value,a +00105$: +; vprintf.c 96 + dec r2 +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00107$: + C$vprintf.c$123$1$1 ==. + XFvprintf$calculate_digit$0$0 ==. + ret + G$vsprintf$0$0 ==. +; vprintf.c 127 +; ----------------------------------------- +; function vsprintf +; ----------------------------------------- +_vsprintf: +; vprintf.c 0 + push b + push dph + push dpl + mov dptr,#_vsprintf_buf_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a +; vprintf.c 141 + mov dptr,#_vsprintf_buf_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#_output_ptr + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a +; vprintf.c 142 + mov a,r2 + orl a,r3 + orl a,r4 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00262$: +; vprintf.c 144 + clr _output_to_string +; Peephole 132 changed ljmp to sjmp + sjmp 00237$ +00102$: +; vprintf.c 148 + setb _output_to_string +; vprintf.c 151 +00237$: +00193$: + mov dptr,#_vsprintf_PARM_2 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov a,#0x01 + add a,r2 + mov r5,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r6,a + mov ar7,r4 + mov dptr,#_vsprintf_PARM_2 + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov _vsprintf_sloc0_1_0,a + jnz 00263$ + ljmp 00195$ +00263$: +; vprintf.c 153 + mov a,_vsprintf_sloc0_1_0 + cjne a,#0x25,00264$ + sjmp 00265$ +00264$: + ljmp 00191$ +00265$: +; vprintf.c 155 + clr _vsprintf_left_justify_1_1 +; vprintf.c 156 + clr _vsprintf_zero_padding_1_1 +; vprintf.c 157 + clr _vsprintf_prefix_sign_1_1 +; vprintf.c 158 + clr _vsprintf_prefix_space_1_1 +; vprintf.c 159 + clr _vsprintf_signed_argument_1_1 +; vprintf.c 160 + mov dptr,#_radix +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; vprintf.c 161 + clr _vsprintf_char_argument_1_1 +; vprintf.c 162 + clr _vsprintf_long_argument_1_1 +; vprintf.c 163 + mov dptr,#_vsprintf_width_1_1 +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; vprintf.c 167 +00104$: + mov _vsprintf_sloc2_1_0,r5 + mov (_vsprintf_sloc2_1_0 + 1),r6 + mov (_vsprintf_sloc2_1_0 + 2),r7 + inc r5 + cjne r5,#0x00,00266$ + inc r6 +00266$: + mov dptr,#_vsprintf_PARM_2 + mov a,r5 + movx @dptr,a + inc dptr + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a + mov dpl,_vsprintf_sloc2_1_0 + mov dph,(_vsprintf_sloc2_1_0 + 1) + mov b,(_vsprintf_sloc2_1_0 + 2) + lcall __gptrget +; Peephole 100 removed redundant mov + mov r1,a + mov dptr,#_vsprintf_c_1_1 + movx @dptr,a +; vprintf.c 169 + push ar5 + push ar6 + push ar7 + push ar1 + mov dpl,r1 + lcall _isdigit + mov _vsprintf_sloc1_1_0,dpl + pop ar1 + pop ar7 + pop ar6 + pop ar5 + mov a,_vsprintf_sloc1_1_0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00267$: +; vprintf.c 171 + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr + mov r2,a + mov b,#0x0a + mov a,r2 + mul ab + mov _vsprintf_sloc5_1_0,a + mov a,r1 + add a,#0xd0 +; Peephole 105 removed redundant mov + mov _vsprintf_sloc3_1_0,a + add a,_vsprintf_sloc5_1_0 +; Peephole 100 removed redundant mov + mov r0,a + mov dptr,#_vsprintf_width_1_1 + movx @dptr,a +; vprintf.c 173 + cjne r0,#0x00,00268$ + mov a,#0x01 + sjmp 00269$ +00268$: + clr a +00269$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc4_1_0,a + jnz 00270$ + ljmp 00104$ +00270$: +; vprintf.c 176 + setb _vsprintf_zero_padding_1_1 +; vprintf.c 178 + ljmp 00104$ +00108$: +; vprintf.c 181 + push ar2 + push ar5 + push ar6 + push ar7 + push ar0 + push ar1 + mov dpl,r1 + lcall _islower + mov _vsprintf_sloc6_1_0,dpl + pop ar1 + pop ar0 + pop ar7 + pop ar6 + pop ar5 + pop ar2 + mov a,_vsprintf_sloc6_1_0 + cjne a,#0x01,00271$ +00271$: + cpl c + mov _lower_case,c +; vprintf.c 182 +; Peephole 111 removed ljmp by inverse jump logic + jnb _lower_case,00110$ +00272$: +; vprintf.c 184 + mov a,#0xdf + anl a,r1 + mov dptr,#_vsprintf_c_1_1 + movx @dptr,a +00110$: +; vprintf.c 187 + mov dptr,#_vsprintf_c_1_1 + movx a,@dptr + mov r3,a + cjne r3,#0x20,00273$ + mov a,#0x01 + sjmp 00274$ +00273$: + clr a +00274$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc7_1_0,a + jz 00275$ + ljmp 00113$ +00275$: + cjne r3,#0x2b,00276$ + mov a,#0x01 + sjmp 00277$ +00276$: + clr a +00277$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc8_1_0,a + jz 00278$ + ljmp 00112$ +00278$: + cjne r3,#0x2d,00279$ + mov a,#0x01 + sjmp 00280$ +00279$: + clr a +00280$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc9_1_0,a +; Peephole 132 changed ljmp to sjmp +; Peephole 163 removed sjmp by inverse jump logic + jnz 00111$ +00281$: + cjne r3,#0x42,00282$ + mov a,#0x01 + sjmp 00283$ +00282$: + clr a +00283$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc10_1_0,a +; Peephole 132 changed ljmp to sjmp +; Peephole 163 removed sjmp by inverse jump logic + jnz 00114$ +00284$: + cjne r3,#0x43,00285$ + mov a,#0x01 + sjmp 00286$ +00285$: + clr a +00286$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc11_1_0,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00116$ +00287$: + cjne r3,#0x44,00288$ + mov a,#0x01 + sjmp 00289$ +00288$: + clr a +00289$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc12_1_0,a + jz 00290$ + ljmp 00137$ +00290$: + cjne r3,#0x49,00291$ + mov a,#0x01 + sjmp 00292$ +00291$: + clr a +00292$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc13_1_0,a + jz 00293$ + ljmp 00137$ +00293$: + cjne r3,#0x4c,00294$ + mov a,#0x01 + sjmp 00295$ +00294$: + clr a +00295$: +; Peephole 105 removed redundant mov + mov r4,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00115$ +00296$: + cjne r3,#0x4f,00297$ + ljmp 00139$ +00297$: + cjne r3,#0x50,00298$ + ljmp 00133$ +00298$: + cjne r3,#0x53,00299$ +; Peephole 132 changed ljmp to sjmp + sjmp 00117$ +00299$: + cjne r3,#0x55,00300$ + ljmp 00140$ +00300$: + cjne r3,#0x58,00301$ + ljmp 00141$ +00301$: + ljmp 00142$ +; vprintf.c 190 +00111$: + setb _vsprintf_left_justify_1_1 +; vprintf.c 191 + ljmp 00104$ +; vprintf.c 193 +00112$: + setb _vsprintf_prefix_sign_1_1 +; vprintf.c 194 + ljmp 00104$ +; vprintf.c 196 +00113$: + setb _vsprintf_prefix_space_1_1 +; vprintf.c 197 + ljmp 00104$ +; vprintf.c 199 +00114$: + setb _vsprintf_char_argument_1_1 +; vprintf.c 200 + ljmp 00104$ +; vprintf.c 202 +00115$: + setb _vsprintf_long_argument_1_1 +; vprintf.c 203 + ljmp 00104$ +; vprintf.c 206 +00116$: + mov dptr,#_vsprintf_PARM_3 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xff +; Peephole 100 removed redundant mov + mov r0,a + mov dptr,#_vsprintf_PARM_3 + movx @dptr,a + mov ar2,@r0 + push ar3 + mov dpl,r2 + lcall _output_char + pop ar3 +; vprintf.c 207 + ljmp 00143$ +; vprintf.c 210 +00117$: + mov dptr,#_vsprintf_PARM_3 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xfd +; Peephole 100 removed redundant mov + mov r0,a + mov dptr,#_vsprintf_PARM_3 + movx @dptr,a + mov ar2,@r0 + inc r0 + mov ar4,@r0 + inc r0 + mov ar5,@r0 + dec r0 + dec r0 + mov _value,r2 + mov (_value + 1),r4 + mov (_value + 2),r5 +; vprintf.c 212 + push ar3 + mov dpl,r2 + mov dph,r4 + mov b,r5 + lcall _strlen + mov r2,dpl + mov r4,dph + pop ar3 + mov _vsprintf_sloc13_1_0,r2 +; vprintf.c 213 +; Peephole 112 removed ljmp by inverse jump logic + jb _vsprintf_left_justify_1_1,00124$ +00302$: + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr + mov r4,a + clr c + mov a,_vsprintf_sloc13_1_0 + subb a,r4 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00124$ +00303$: +; vprintf.c 215 + clr c + mov a,r4 + subb a,_vsprintf_sloc13_1_0 + mov r4,a +; vprintf.c 216 +00118$: + mov ar5,r4 + dec r4 + mov dptr,#_vsprintf_width_1_1 + mov a,r4 + movx @dptr,a + cjne r5,#0x00,00304$ + mov a,#0x01 + sjmp 00305$ +00304$: + clr a +00305$: +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00124$ +00306$: +; vprintf.c 218 + push ar3 + push ar4 + push ar5 + push ar6 + mov dpl,#0x20 + lcall _output_char + pop ar6 + pop ar5 + pop ar4 + pop ar3 +; vprintf.c 222 +; Peephole 132 changed ljmp to sjmp + sjmp 00118$ +00124$: + mov r4,_value + mov r5,(_value + 1) + mov r6,(_value + 2) + mov dpl,r4 + mov dph,r5 + mov b,r6 + lcall __gptrget +; Peephole 105 removed redundant mov + mov _vsprintf_sloc12_1_0,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00126$ +00307$: +; vprintf.c 223 + mov a,#0x01 + add a,r4 + mov r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov r1,a + mov ar2,r6 + mov _value,r0 + mov (_value + 1),r1 + mov (_value + 2),r2 + mov dpl,r4 + mov dph,r5 + mov b,r6 + lcall __gptrget + mov r7,a + push ar2 + push ar3 + push ar4 + push ar5 + push ar6 + push ar7 + push ar0 + push ar1 + mov dpl,r7 + lcall _output_char + pop ar1 + pop ar0 + pop ar7 + pop ar6 + pop ar5 + pop ar4 + pop ar3 + pop ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00124$ +00126$: +; vprintf.c 225 + jb _vsprintf_left_justify_1_1,00308$ + ljmp 00143$ +00308$: + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr + mov r2,a + clr c + mov a,_vsprintf_sloc13_1_0 + subb a,r2 + jc 00309$ + ljmp 00143$ +00309$: +; vprintf.c 227 + clr c + mov a,r2 + subb a,_vsprintf_sloc13_1_0 + mov r2,a +; vprintf.c 228 +00127$: + mov ar4,r2 + dec r2 + mov dptr,#_vsprintf_width_1_1 + mov a,r2 + movx @dptr,a + cjne r4,#0x00,00310$ + mov a,#0x01 + sjmp 00311$ +00310$: + clr a +00311$: +; Peephole 105 removed redundant mov + mov r5,a + jz 00312$ + ljmp 00143$ +00312$: +; vprintf.c 230 + push ar2 + push ar3 + push ar4 + push ar5 + mov dpl,#0x20 + lcall _output_char + pop ar5 + pop ar4 + pop ar3 + pop ar2 +; vprintf.c 236 +; Peephole 132 changed ljmp to sjmp + sjmp 00127$ +00133$: + mov dptr,#_vsprintf_PARM_3 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xfd +; Peephole 100 removed redundant mov + mov r0,a + mov dptr,#_vsprintf_PARM_3 + movx @dptr,a + mov ar2,@r0 + inc r0 + mov ar4,@r0 + inc r0 + mov ar5,@r0 + dec r0 + dec r0 + mov _value,r2 + mov (_value + 1),r4 + mov (_value + 2),r5 +; vprintf.c 238 + clr c + mov a,#0x03 + subb a,0x0002 + _value +; Peephole 108 removed ljmp by inverse jump logic + jnc 00200$ +00313$: + mov r2,#0x04 +; Peephole 132 changed ljmp to sjmp + sjmp 00201$ +00200$: + mov r2,0x0002 + _value +00201$: + mov a,r2 +; Peephole 180 changed mov to clr +; Peephole 186 optimized movc sequence + mov dptr,#_memory_id + movc a,@a+dptr + mov r2,a + push ar3 + mov dpl,r2 + lcall _output_char + pop ar3 +; vprintf.c 239 + push ar3 + mov dpl,#0x3a + lcall _output_char + pop ar3 +; vprintf.c 240 + mov a,0x0002 + _value +; Peephole 110 removed ljmp by inverse jump logic + jz 00135$ +00314$: + mov a,0x0002 + _value + cjne a,#0x03,00315$ +; Peephole 132 changed ljmp to sjmp + sjmp 00135$ +00315$: +; vprintf.c 241 + push ar3 + mov dpl,0x0001 + _value + lcall _output_2digits + pop ar3 +00135$: +; vprintf.c 242 + push ar3 + mov dpl,_value + lcall _output_2digits + pop ar3 +; vprintf.c 243 +; vprintf.c 247 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00137$: + setb _vsprintf_signed_argument_1_1 +; vprintf.c 248 + mov dptr,#_radix + mov a,#0x0a + movx @dptr,a +; vprintf.c 249 +; vprintf.c 252 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00139$: + mov dptr,#_radix + mov a,#0x08 + movx @dptr,a +; vprintf.c 253 +; vprintf.c 256 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00140$: + mov dptr,#_radix + mov a,#0x0a + movx @dptr,a +; vprintf.c 257 +; vprintf.c 260 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00141$: + mov dptr,#_radix + mov a,#0x10 + movx @dptr,a +; vprintf.c 261 +; vprintf.c 265 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00142$: + mov dpl,r3 + lcall _output_char +; vprintf.c 267 +00143$: +; vprintf.c 269 + mov dptr,#_radix + movx a,@dptr + mov r2,a + cjne r2,#0x00,00316$ + ljmp 00193$ +00316$: +; vprintf.c 275 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_char_argument_1_1,00152$ +00317$: +; vprintf.c 277 + mov dptr,#_vsprintf_PARM_3 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xff +; Peephole 100 removed redundant mov + mov r0,a + mov dptr,#_vsprintf_PARM_3 + movx @dptr,a + mov ar2,@r0 + mov a,r2 + rlc a + subb a,acc + mov r3,a + mov r4,a + mov r5,a + mov _value,r2 + mov (_value + 1),r3 + mov (_value + 2),r4 + mov (_value + 3),r5 +; vprintf.c 278 + jnb _vsprintf_signed_argument_1_1,00318$ + ljmp 00153$ +00318$: +; vprintf.c 280 + mov 0x0001 + _value,#0x00 +; vprintf.c 281 + mov 0x0002 + _value,#0x00 +; vprintf.c 282 + mov 0x0003 + _value,#0x00 + ljmp 00153$ +00152$: +; vprintf.c 285 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_long_argument_1_1,00149$ +00319$: +; vprintf.c 287 + mov dptr,#_vsprintf_PARM_3 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xfc +; Peephole 100 removed redundant mov + mov r0,a + mov dptr,#_vsprintf_PARM_3 + movx @dptr,a + mov ar2,@r0 + inc r0 + mov ar3,@r0 + inc r0 + mov ar4,@r0 + inc r0 + mov ar5,@r0 + dec r0 + dec r0 + dec r0 + mov _value,r2 + mov (_value + 1),r3 + mov (_value + 2),r4 + mov (_value + 3),r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00153$ +00149$: +; vprintf.c 291 + mov dptr,#_vsprintf_PARM_3 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xfe +; Peephole 100 removed redundant mov + mov r0,a + mov dptr,#_vsprintf_PARM_3 + movx @dptr,a + mov ar2,@r0 + inc r0 + mov ar3,@r0 + dec r0 + mov a,r3 + rlc a + subb a,acc + mov r4,a + mov r5,a + mov _value,r2 + mov (_value + 1),r3 + mov (_value + 2),r4 + mov (_value + 3),r5 +; vprintf.c 292 +; Peephole 112 removed ljmp by inverse jump logic + jb _vsprintf_signed_argument_1_1,00153$ +00320$: +; vprintf.c 294 + mov 0x0002 + _value,#0x00 +; vprintf.c 295 + mov 0x0003 + _value,#0x00 +00153$: +; vprintf.c 299 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_signed_argument_1_1,00158$ +00321$: +; vprintf.c 301 + mov a,(_value + 3) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00155$ +00322$: +; vprintf.c 302 + clr c + clr a + subb a,_value + mov r2,a + clr a + subb a,(_value + 1) + mov r3,a + clr a + subb a,(_value + 2) + mov r4,a + clr a + subb a,(_value + 3) + mov r5,a + mov _value,r2 + mov (_value + 1),r3 + mov (_value + 2),r4 + mov (_value + 3),r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00158$ +00155$: +; vprintf.c 304 + clr _vsprintf_signed_argument_1_1 +00158$: +; vprintf.c 307 + mov dptr,#_vsprintf_length_1_1 +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; vprintf.c 308 + setb _lsd +; vprintf.c 309 + mov r2,#0x00 +00162$: + mov a,_value +; Peephole 162 removed sjmp by inverse jump logic + jz 00324$ +00323$: +; Peephole 132 changed ljmp to sjmp + sjmp 00163$ +00324$: + mov a,0x0001 + _value +; Peephole 162 removed sjmp by inverse jump logic + jz 00326$ +00325$: +; Peephole 132 changed ljmp to sjmp + sjmp 00163$ +00326$: +; vprintf.c 310 + mov a,0x0002 + _value +; Peephole 162 removed sjmp by inverse jump logic + jz 00328$ +00327$: +; Peephole 132 changed ljmp to sjmp + sjmp 00163$ +00328$: + mov a,0x0003 + _value + jnz 00329$ + mov a,#0x01 + sjmp 00330$ +00329$: + clr a +00330$: + mov r3,a + mov dptr,#_vsprintf_length_1_1 + mov a,r2 + movx @dptr,a + mov a,r3 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00164$ +00331$: +00163$: +; vprintf.c 312 + mov 0x0004 + _value,#0x00 +; vprintf.c 313 + push ar2 + lcall _calculate_digit + pop ar2 +; vprintf.c 327 + jb _lsd,1$ + pop b ; b = + mov a,_value+4 ; a = + swap a + orl b,a ; b = + push b + sjmp 2$ +1$: + mov a,_value+4 ; a = + push acc +2$: +; vprintf.c 329 + inc r2 +; vprintf.c 330 +; Peephole 167 removed redundant bit moves (c not set to _lsd) + cpl _lsd +; Peephole 132 changed ljmp to sjmp + sjmp 00162$ +00164$: +; vprintf.c 333 + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr + mov r3,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r3,#0x00,00166$ +; Peephole 201 removed redundant sjmp +00332$: +00333$: +; vprintf.c 338 + mov dptr,#_vsprintf_width_1_1 + mov a,#0x01 + movx @dptr,a +00166$: +; vprintf.c 342 +; Peephole 112 removed ljmp by inverse jump logic + jb _vsprintf_zero_padding_1_1,00171$ +00334$: +; vprintf.c 344 + inc r2 + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr + mov r3,a +00167$: + clr c + mov a,r2 + subb a,r3 + clr a + rlc a + mov r2,a + mov dptr,#_vsprintf_width_1_1 + mov a,r3 + movx @dptr,a + mov a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00171$ +00335$: +; vprintf.c 346 + push ar3 + mov dpl,#0x20 + lcall _output_char + pop ar3 +; vprintf.c 347 + dec r3 +; Peephole 132 changed ljmp to sjmp + sjmp 00167$ +00171$: +; vprintf.c 351 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_signed_argument_1_1,00180$ +00336$: +; vprintf.c 353 + mov dpl,#0x2d + lcall _output_char +; vprintf.c 355 + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xff + mov dptr,#_vsprintf_width_1_1 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00258$ +00180$: +; vprintf.c 357 + mov dptr,#_vsprintf_length_1_1 + movx a,@dptr + mov r2,a + cjne r2,#0x00,00337$ +; Peephole 132 changed ljmp to sjmp + sjmp 00258$ +00337$: +; vprintf.c 360 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_prefix_sign_1_1,00175$ +00338$: +; vprintf.c 362 + mov dpl,#0x2b + lcall _output_char +; vprintf.c 364 + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xff + mov dptr,#_vsprintf_width_1_1 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00258$ +00175$: +; vprintf.c 366 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_prefix_space_1_1,00258$ +00339$: +; vprintf.c 368 + mov dpl,#0x20 + lcall _output_char +; vprintf.c 370 + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr +; Peephole 105 removed redundant mov + mov r2,a + add a,#0xff + mov dptr,#_vsprintf_width_1_1 + movx @dptr,a +; vprintf.c 375 +00258$: + mov dptr,#_vsprintf_length_1_1 + movx a,@dptr + mov r2,a + mov dptr,#_vsprintf_width_1_1 + movx a,@dptr + mov r3,a +00182$: + mov ar4,r3 + dec r3 + clr c + mov a,r2 + subb a,r4 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00260$ +00340$: +; vprintf.c 377 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_zero_padding_1_1,00202$ +00341$: + mov r4,#0x30 +; Peephole 132 changed ljmp to sjmp + sjmp 00203$ +00202$: + mov r4,#0x20 +00203$: + push ar2 + push ar3 + mov dpl,r4 + lcall _output_char + pop ar3 + pop ar2 +; vprintf.c 381 +; Peephole 132 changed ljmp to sjmp + sjmp 00182$ +00260$: +00185$: + mov ar3,r2 + dec r2 + mov a,r3 + jnz 00342$ + ljmp 00193$ +00342$: +; vprintf.c 383 +; Peephole 167 removed redundant bit moves (c not set to _lsd) + cpl _lsd +; vprintf.c 398 + jb _lsd,3$ + pop acc ; a = + nop ; to disable the "optimizer" + push acc + swap a + anl a,#0x0F ; a = + sjmp 4$ +3$: + pop acc + anl a,#0x0F ; a = +4$: + mov _value+4,a +; vprintf.c 400 + push ar2 + mov dpl,0x0004 + _value + lcall _output_digit + pop ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00185$ +00191$: +; vprintf.c 407 + mov dpl,_vsprintf_sloc0_1_0 + lcall _output_char + ljmp 00193$ +00195$: +; vprintf.c 413 +; Peephole 111 removed ljmp by inverse jump logic + jnb _output_to_string,00198$ +00343$: + mov dpl,#0x00 + lcall _output_char +00198$: + C$vprintf.c$414$1$1 ==. + XG$vsprintf$0$0 ==. + ret + G$vprintf$0$0 ==. +; vprintf.c 418 +; ----------------------------------------- +; function vprintf +; ----------------------------------------- +_vprintf: +; vprintf.c 420 + push b + push dph + push dpl + mov dptr,#_vprintf_format_1_1 + pop acc + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + pop acc + inc dptr + movx @dptr,a + mov dptr,#_vprintf_format_1_1 + movx a,@dptr + mov r2,a + inc dptr + movx a,@dptr + mov r3,a + inc dptr + movx a,@dptr + mov r4,a + mov dptr,#_vprintf_PARM_2 + movx a,@dptr + mov r5,a + mov dptr,#_vsprintf_PARM_2 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a + inc dptr + mov a,r4 + movx @dptr,a + mov dptr,#_vsprintf_PARM_3 + mov a,r5 + movx @dptr,a +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 + lcall _vsprintf + C$vprintf.c$421$1$1 ==. + XG$vprintf$0$0 ==. +; Peephole 151 removed misc moves via dph, dpl before return +00101$: + ret + .area CSEG (CODE) +Fvprintf$memory_id$0$0 == . +_memory_id: + .ascii /IXCP-/ + .byte 0 diff --git a/device/lib/large/vprintf.cdb b/device/lib/large/vprintf.cdb new file mode 100644 index 00000000..ffd5562a --- /dev/null +++ b/device/lib/large/vprintf.cdb @@ -0,0 +1,14 @@ +M:vprintf +F:Fvprintf$output_char$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fvprintf$output_digit$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fvprintf$output_2digits$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fvprintf$calculate_digit$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$vsprintf$0$0({2}DF,SI:S),Z,0,0,0,0,0 +F:G$vprintf$0$0({2}DF,SI:S),Z,0,0,0,0,0 +S:G$value$0$0({5}ST__00010000:S),E,0,0 +S:G$output_to_string$0$0({1}SB0$1:S),H,0,0 +S:G$lower_case$0$0({1}SB0$1:S),H,0,0 +S:G$lsd$0$0({1}SB0$1:S),H,0,0 +S:G$output_ptr$0$0({3}DG,SC:S),F,0,0 +S:G$radix$0$0({1}SS:U),F,0,0 +S:Fvprintf$memory_id$0$0({6}DA6,SC:S),D,0,0 diff --git a/device/lib/large/vprintf.rel b/device/lib/large/vprintf.rel new file mode 100644 index 00000000..679a050b --- /dev/null +++ b/device/lib/large/vprintf.rel @@ -0,0 +1,1838 @@ +;!FILE vprintf.asm +XH +H 8 areas 39A global symbols +M vprintf +S _isdigit Ref0000 +S __gptrput Ref0000 +S _putchar Ref0000 +S _islower Ref0000 +S _bp Ref0000 +S _strlen Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 15 flags 0 +S G$value$0$0 Def0000 +S _value Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size A flags 80 +S _lower_case Def0001 +S _output_to_string Def0000 +S G$lower_case$0$0 Def0001 +S G$output_to_string$0$0 Def0000 +S _lsd Def0002 +S G$lsd$0$0 Def0002 +A XSEG size 12 flags 40 +S _output_ptr Def0000 +S _vprintf_PARM_2 Def000E +S G$radix$0$0 Def0003 +S G$output_ptr$0$0 Def0000 +S _radix Def0003 +S _vsprintf_PARM_2 Def0004 +S _vsprintf_PARM_3 Def0007 +A GSINIT size 0 flags 20 +A CSEG size 671 flags 20 +S A$vprintf$1454 Def065B +S A$vprintf$1445 Def0650 +S A$vprintf$1436 Def0645 +S A$vprintf$1427 Def0638 +S A$vprintf$1409 Def0626 +S A$vprintf$1391 Def060C +S A$vprintf$1382 Def0600 +S A$vprintf$1373 Def05F4 +S A$vprintf$1364 Def05EC +S A$vprintf$1355 Def05DD +S A$vprintf$1337 Def05CB +S A$vprintf$1328 Def05BF +S A$vprintf$1319 Def05B2 +S A$vprintf$1292 Def0592 +S A$vprintf$1265 Def0571 +S A$vprintf$1256 Def0567 +S A$vprintf$1247 Def055F +S A$vprintf$1238 Def0557 +S A$vprintf$1193 Def0525 +S A$vprintf$1184 Def0519 +S A$vprintf$1166 Def0509 +S A$vprintf$1157 Def0501 +S A$vprintf$1139 Def04ED +S A$vprintf$1094 Def04B6 +S A$vprintf$1076 Def04A1 +S A$vprintf$1067 Def0492 +S Fvprintf$memory_id$0$0 Def066B +S A$vprintf$1455 Def065C +S A$vprintf$1446 Def0651 +S A$vprintf$1437 Def0646 +S A$vprintf$1428 Def0639 +S A$vprintf$1383 Def0601 +S A$vprintf$1374 Def05F6 +S A$vprintf$1347 Def05D6 +S A$vprintf$1338 Def05CE +S A$vprintf$1329 Def05C0 +S A$vprintf$1293 Def0595 +S A$vprintf$1284 Def0589 +S A$vprintf$1275 Def057C +S A$vprintf$1266 Def0574 +S A$vprintf$1257 Def056A +S A$vprintf$1248 Def0560 +S A$vprintf$1194 Def0526 +S A$vprintf$1185 Def051B +S A$vprintf$1176 Def0511 +S A$vprintf$1149 Def04FA +S A$vprintf$1095 Def04B9 +S A$vprintf$1077 Def04A2 +S A$vprintf$1068 Def0495 +S Fvprintf$output_2digits$0$0 Def0070 +S A$vprintf$1456 Def065F +S A$vprintf$1447 Def0654 +S A$vprintf$1438 Def0647 +S A$vprintf$1429 Def063B +S A$vprintf$1393 Def060E +S A$vprintf$1384 Def0603 +S A$vprintf$1357 Def05DF +S A$vprintf$1339 Def05CF +S A$vprintf$1294 Def0596 +S A$vprintf$1285 Def058A +S A$vprintf$1267 Def0577 +S A$vprintf$1258 Def056B +S A$vprintf$1186 Def051D +S A$vprintf$1168 Def050B +S A$vprintf$1159 Def0503 +S A$vprintf$1096 Def04BA +S A$vprintf$1087 Def04AE +S A$vprintf$1078 Def04A3 +S A$vprintf$1069 Def0496 +S A$vprintf$1466 Def066A +S A$vprintf$1457 Def0660 +S A$vprintf$1448 Def0655 +S A$vprintf$1439 Def0648 +S A$vprintf$1394 Def0610 +S A$vprintf$1385 Def0604 +S A$vprintf$1367 Def05EE +S A$vprintf$1295 Def0597 +S A$vprintf$1286 Def058C +S A$vprintf$1259 Def056C +S A$vprintf$1196 Def0527 +S A$vprintf$1178 Def0513 +S A$vprintf$1097 Def04BC +S A$vprintf$1088 Def04B1 +S A$vprintf$1079 Def04A4 +S A$vprintf$1449 Def0656 +S A$vprintf$1395 Def0613 +S A$vprintf$1386 Def0606 +S A$vprintf$1359 Def05E1 +S A$vprintf$1287 Def058F +S A$vprintf$1278 Def057F +S A$vprintf$1269 Def0579 +S A$vprintf$1188 Def051F +S A$vprintf$1098 Def04BD +S A$vprintf$1459 Def0661 +S A$vprintf$1396 Def0616 +S A$vprintf$1378 Def05F9 +S A$vprintf$1297 Def059A +S A$vprintf$1279 Def0582 +S A$vprintf$1099 Def04BF +S A$vprintf$300 Def00AA +S A$vprintf$201 Def003F +S C$vprintf.c$123$1$1 Def00CE +S A$vprintf$1388 Def0608 +S A$vprintf$1289 Def0590 +S A$vprintf$400 Def0111 +S A$vprintf$310 Def00B9 +S A$vprintf$301 Def00AC +S A$vprintf$220 Def0053 +S A$vprintf$211 Def004B +S A$vprintf$202 Def0041 +S C$vprintf.c$421$1$1 Def066A +S A$vprintf$1398 Def0618 +S A$vprintf$1389 Def060A +S A$vprintf$500 Def019B +S A$vprintf$410 Def011D +S A$vprintf$401 Def0112 +S A$vprintf$320 Def00C2 +S A$vprintf$311 Def00BA +S A$vprintf$302 Def00AD +S A$vprintf$212 Def004C +S A$vprintf$203 Def0042 +S A$vprintf$510 Def01A9 +S A$vprintf$501 Def019C +S A$vprintf$411 Def011E +S A$vprintf$330 Def00CC +S A$vprintf$321 Def00C3 +S A$vprintf$312 Def00BC +S A$vprintf$303 Def00AF +S A$vprintf$240 Def0067 +S A$vprintf$231 Def005D +S A$vprintf$222 Def0054 +S A$vprintf$204 Def0044 +S C$vprintf.c$414$1$1 Def062C +S A$vprintf$601 Def0225 +S A$vprintf$520 Def01B7 +S A$vprintf$502 Def019D +S A$vprintf$430 Def013A +S A$vprintf$421 Def012C +S A$vprintf$412 Def011F +S A$vprintf$403 Def0113 +S A$vprintf$304 Def00B1 +S A$vprintf$214 Def004D +S A$vprintf$205 Def0045 +S A$vprintf$160 Def0012 +S A$vprintf$151 Def0007 +S A$vprintf$800 Def0328 +S A$vprintf$710 Def02AB +S A$vprintf$701 Def029F +S A$vprintf$620 Def0239 +S A$vprintf$611 Def022F +S A$vprintf$602 Def0228 +S A$vprintf$530 Def01C1 +S A$vprintf$512 Def01AB +S A$vprintf$503 Def01A0 +S A$vprintf$422 Def012E +S A$vprintf$413 Def0120 +S A$vprintf$404 Def0114 +S A$vprintf$350 Def00DE +S A$vprintf$323 Def00C5 +S A$vprintf$305 Def00B2 +S A$vprintf$260 Def0079 +S A$vprintf$242 Def006A +S A$vprintf$233 Def005F +S A$vprintf$206 Def0046 +S A$vprintf$170 Def001E +S A$vprintf$161 Def0013 +S A$vprintf$900 Def03C0 +S A$vprintf$801 Def032A +S A$vprintf$720 Def02BC +S A$vprintf$711 Def02AD +S A$vprintf$702 Def02A2 +S A$vprintf$603 Def022A +S A$vprintf$540 Def01D2 +S A$vprintf$513 Def01AC +S A$vprintf$504 Def01A1 +S A$vprintf$450 Def014E +S A$vprintf$441 Def0145 +S A$vprintf$423 Def0130 +S A$vprintf$414 Def0121 +S A$vprintf$405 Def0115 +S A$vprintf$360 Def00EA +S A$vprintf$351 Def00DF +S A$vprintf$342 Def00CF +S A$vprintf$324 Def00C7 +S A$vprintf$315 Def00BD +S A$vprintf$261 Def007B +S A$vprintf$243 Def006D +S A$vprintf$234 Def0061 +S A$vprintf$225 Def0056 +S A$vprintf$216 Def004E +S A$vprintf$171 Def001F +S A$vprintf$162 Def0014 +S A$vprintf$910 Def03CE +S A$vprintf$901 Def03C3 +S A$vprintf$820 Def0342 +S A$vprintf$802 Def032C +S A$vprintf$730 Def02C8 +S A$vprintf$712 Def02AF +S A$vprintf$631 Def0245 +S A$vprintf$622 Def023B +S A$vprintf$613 Def0231 +S A$vprintf$541 Def01D5 +S A$vprintf$523 Def01B8 +S A$vprintf$514 Def01AF +S A$vprintf$505 Def01A2 +S A$vprintf$460 Def0159 +S A$vprintf$433 Def013D +S A$vprintf$415 Def0122 +S A$vprintf$406 Def0116 +S A$vprintf$370 Def00F6 +S A$vprintf$361 Def00EB +S A$vprintf$352 Def00E1 +S A$vprintf$343 Def00D1 +S A$vprintf$334 Def00CE +S A$vprintf$325 Def00C9 +S A$vprintf$307 Def00B4 +S A$vprintf$271 Def008D +S A$vprintf$262 Def007C +S A$vprintf$253 Def0070 +S A$vprintf$235 Def0062 +S A$vprintf$208 Def0047 +S A$vprintf$181 Def002D +S A$vprintf$172 Def0020 +S A$vprintf$163 Def0015 +S A$vprintf$154 Def000A +S A$vprintf$145 Def0000 +S A$vprintf$920 Def03DC +S A$vprintf$911 Def03CF +S A$vprintf$830 Def0356 +S A$vprintf$821 Def0344 +S A$vprintf$812 Def0339 +S A$vprintf$803 Def032E +S A$vprintf$740 Def02D7 +S A$vprintf$731 Def02CA +S A$vprintf$722 Def02BD +S A$vprintf$713 Def02B1 +S A$vprintf$704 Def02A3 +S A$vprintf$650 Def0262 +S A$vprintf$632 Def0247 +S A$vprintf$614 Def0234 +S A$vprintf$605 Def022C +S A$vprintf$560 Def01F2 +S A$vprintf$551 Def01E9 +S A$vprintf$542 Def01D8 +S A$vprintf$533 Def01C4 +S A$vprintf$524 Def01BA +S A$vprintf$506 Def01A4 +S A$vprintf$470 Def0167 +S A$vprintf$461 Def015B +S A$vprintf$452 Def0150 +S A$vprintf$443 Def0147 +S A$vprintf$416 Def0123 +S A$vprintf$407 Def0118 +S A$vprintf$371 Def00F7 +S A$vprintf$362 Def00EC +S A$vprintf$353 Def00E2 +S A$vprintf$344 Def00D3 +S A$vprintf$308 Def00B7 +S A$vprintf$290 Def009A +S A$vprintf$272 Def0090 +S A$vprintf$263 Def007E +S A$vprintf$254 Def0072 +S A$vprintf$227 Def0059 +S A$vprintf$218 Def0050 +S A$vprintf$209 Def0048 +S A$vprintf$191 Def0039 +S A$vprintf$173 Def0021 +S A$vprintf$164 Def0018 +S A$vprintf$155 Def000D +S A$vprintf$146 Def0002 +S A$vprintf$930 Def03E7 +S A$vprintf$921 Def03DD +S A$vprintf$912 Def03D1 +S A$vprintf$903 Def03C4 +S A$vprintf$840 Def036B +S A$vprintf$831 Def0358 +S A$vprintf$822 Def0346 +S A$vprintf$813 Def033B +S A$vprintf$804 Def0330 +S A$vprintf$750 Def02E8 +S A$vprintf$741 Def02D9 +S A$vprintf$732 Def02CB +S A$vprintf$723 Def02BE +S A$vprintf$714 Def02B4 +S A$vprintf$705 Def02A4 +S A$vprintf$660 Def026C +S A$vprintf$642 Def0254 +S A$vprintf$633 Def0249 +S A$vprintf$624 Def023D +S A$vprintf$615 Def0236 +S A$vprintf$561 Def01F5 +S A$vprintf$552 Def01EA +S A$vprintf$543 Def01DA +S A$vprintf$534 Def01C6 +S A$vprintf$525 Def01BC +S A$vprintf$516 Def01B0 +S A$vprintf$507 Def01A5 +S A$vprintf$480 Def0178 +S A$vprintf$471 Def0168 +S A$vprintf$462 Def015C +S A$vprintf$435 Def013F +S A$vprintf$426 Def0133 +S A$vprintf$417 Def0125 +S A$vprintf$408 Def011B +S A$vprintf$390 Def0104 +S A$vprintf$381 Def00FE +S A$vprintf$372 Def00F8 +S A$vprintf$363 Def00ED +S A$vprintf$345 Def00D5 +S A$vprintf$318 Def00BF +S A$vprintf$309 Def00B8 +S A$vprintf$291 Def009B +S A$vprintf$264 Def0080 +S A$vprintf$246 Def006F +S A$vprintf$237 Def0063 +S A$vprintf$228 Def005B +S A$vprintf$219 Def0052 +S A$vprintf$174 Def0022 +S A$vprintf$165 Def001A +S A$vprintf$156 Def000E +S A$vprintf$940 Def03F3 +S A$vprintf$922 Def03DF +S A$vprintf$913 Def03D2 +S A$vprintf$904 Def03C5 +S A$vprintf$850 Def0379 +S A$vprintf$841 Def036D +S A$vprintf$832 Def035A +S A$vprintf$823 Def0348 +S A$vprintf$814 Def033C +S A$vprintf$805 Def0332 +S A$vprintf$742 Def02DB +S A$vprintf$733 Def02CD +S A$vprintf$670 Def027D +S A$vprintf$661 Def026F +S A$vprintf$643 Def0256 +S A$vprintf$625 Def0240 +S A$vprintf$580 Def020F +S A$vprintf$571 Def0202 +S A$vprintf$544 Def01DC +S A$vprintf$535 Def01C8 +S A$vprintf$517 Def01B3 +S A$vprintf$490 Def018C +S A$vprintf$481 Def017B +S A$vprintf$472 Def0169 +S A$vprintf$463 Def015F +S A$vprintf$454 Def0153 +S A$vprintf$445 Def014A +S A$vprintf$427 Def0135 +S A$vprintf$418 Def0127 +S A$vprintf$409 Def011C +S A$vprintf$391 Def0107 +S A$vprintf$364 Def00EE +S A$vprintf$355 Def00E3 +S A$vprintf$346 Def00D8 +S A$vprintf$328 Def00CB +S A$vprintf$319 Def00C0 +S A$vprintf$292 Def009D +S A$vprintf$283 Def0093 +S A$vprintf$265 Def0083 +S A$vprintf$256 Def0075 +S A$vprintf$229 Def005C +S A$vprintf$184 Def002F +S A$vprintf$175 Def0023 +S A$vprintf$166 Def001B +S A$vprintf$157 Def000F +S A$vprintf$148 Def0005 +S A$vprintf$950 Def0404 +S A$vprintf$941 Def03F6 +S A$vprintf$932 Def03E9 +S A$vprintf$914 Def03D4 +S A$vprintf$860 Def038A +S A$vprintf$851 Def037C +S A$vprintf$842 Def036F +S A$vprintf$833 Def035C +S A$vprintf$824 Def034A +S A$vprintf$770 Def02FE +S A$vprintf$752 Def02EB +S A$vprintf$743 Def02DD +S A$vprintf$734 Def02CE +S A$vprintf$725 Def02C0 +S A$vprintf$716 Def02B6 +S A$vprintf$707 Def02A6 +S A$vprintf$671 Def0280 +S A$vprintf$653 Def0263 +S A$vprintf$644 Def0258 +S A$vprintf$635 Def024C +S A$vprintf$626 Def0242 +S A$vprintf$617 Def0238 +S A$vprintf$608 Def022D +S A$vprintf$590 Def021C +S A$vprintf$545 Def01DE +S A$vprintf$536 Def01CA +S A$vprintf$518 Def01B5 +S A$vprintf$509 Def01A7 +S A$vprintf$491 Def018E +S A$vprintf$473 Def016A +S A$vprintf$455 Def0154 +S A$vprintf$446 Def014B +S A$vprintf$437 Def0141 +S A$vprintf$428 Def0138 +S A$vprintf$419 Def0129 +S A$vprintf$392 Def0108 +S A$vprintf$383 Def0100 +S A$vprintf$374 Def00F9 +S A$vprintf$365 Def00F1 +S A$vprintf$356 Def00E6 +S A$vprintf$347 Def00DA +S A$vprintf$293 Def009E +S A$vprintf$275 Def0092 +S A$vprintf$239 Def0065 +S A$vprintf$185 Def0031 +S A$vprintf$176 Def0025 +S A$vprintf$158 Def0010 +S A$vprintf$960 Def0412 +S A$vprintf$924 Def03E1 +S A$vprintf$915 Def03D5 +S A$vprintf$906 Def03C7 +S A$vprintf$870 Def0394 +S A$vprintf$843 Def0371 +S A$vprintf$834 Def035E +S A$vprintf$825 Def034C +S A$vprintf$816 Def033D +S A$vprintf$807 Def0335 +S A$vprintf$780 Def030B +S A$vprintf$771 Def0301 +S A$vprintf$762 Def02F6 +S A$vprintf$753 Def02EE +S A$vprintf$744 Def02E0 +S A$vprintf$735 Def02CF +S A$vprintf$726 Def02C1 +S A$vprintf$708 Def02A7 +S A$vprintf$681 Def028B +S A$vprintf$663 Def0272 +S A$vprintf$636 Def024F +S A$vprintf$591 Def021E +S A$vprintf$582 Def0211 +S A$vprintf$564 Def01F6 +S A$vprintf$555 Def01EC +S A$vprintf$546 Def01E0 +S A$vprintf$537 Def01CC +S A$vprintf$528 Def01BF +S A$vprintf$492 Def0190 +S A$vprintf$483 Def017C +S A$vprintf$474 Def016B +S A$vprintf$465 Def0160 +S A$vprintf$393 Def0109 +S A$vprintf$375 Def00FA +S A$vprintf$366 Def00F2 +S A$vprintf$357 Def00E7 +S A$vprintf$348 Def00DB +S A$vprintf$294 Def00A0 +S A$vprintf$285 Def0095 +S A$vprintf$267 Def0085 +S A$vprintf$258 Def0077 +S A$vprintf$177 Def0027 +S A$vprintf$168 Def001C +S A$vprintf$159 Def0011 +S XFvprintf$calculate_digit$0$0 Def00CE +S A$vprintf$961 Def0415 +S A$vprintf$952 Def0406 +S A$vprintf$943 Def03F8 +S A$vprintf$916 Def03D6 +S A$vprintf$907 Def03C8 +S A$vprintf$871 Def0395 +S A$vprintf$853 Def037F +S A$vprintf$844 Def0373 +S A$vprintf$835 Def0360 +S A$vprintf$826 Def034E +S A$vprintf$817 Def033E +S A$vprintf$790 Def0319 +S A$vprintf$772 Def0302 +S A$vprintf$763 Def02F7 +S A$vprintf$754 Def02EF +S A$vprintf$745 Def02E2 +S A$vprintf$736 Def02D1 +S A$vprintf$727 Def02C4 +S A$vprintf$709 Def02AA +S A$vprintf$691 Def0295 +S A$vprintf$673 Def0283 +S A$vprintf$655 Def0264 +S A$vprintf$646 Def025B +S A$vprintf$637 Def0251 +S A$vprintf$628 Def0244 +S A$vprintf$574 Def0203 +S A$vprintf$565 Def01F9 +S A$vprintf$547 Def01E2 +S A$vprintf$538 Def01CE +S A$vprintf$493 Def0192 +S A$vprintf$484 Def017E +S A$vprintf$475 Def016E +S A$vprintf$466 Def0163 +S A$vprintf$448 Def014C +S A$vprintf$439 Def0143 +S A$vprintf$394 Def010A +S A$vprintf$376 Def00FB +S A$vprintf$367 Def00F3 +S A$vprintf$358 Def00E8 +S A$vprintf$349 Def00DD +S A$vprintf$295 Def00A2 +S A$vprintf$268 Def0088 +S A$vprintf$259 Def0078 +S A$vprintf$187 Def0034 +S A$vprintf$178 Def0029 +S A$vprintf$169 Def001D +S A$vprintf$971 Def0421 +S A$vprintf$953 Def0408 +S A$vprintf$944 Def03FA +S A$vprintf$935 Def03EA +S A$vprintf$926 Def03E3 +S A$vprintf$917 Def03D8 +S A$vprintf$908 Def03CB +S A$vprintf$890 Def03B0 +S A$vprintf$881 Def03A2 +S A$vprintf$872 Def0398 +S A$vprintf$863 Def038D +S A$vprintf$854 Def0382 +S A$vprintf$845 Def0375 +S A$vprintf$836 Def0362 +S A$vprintf$827 Def0351 +S A$vprintf$818 Def033F +S A$vprintf$809 Def0337 +S A$vprintf$791 Def031C +S A$vprintf$782 Def030C +S A$vprintf$773 Def0303 +S A$vprintf$764 Def02F8 +S A$vprintf$755 Def02F0 +S A$vprintf$746 Def02E4 +S A$vprintf$737 Def02D3 +S A$vprintf$728 Def02C5 +S A$vprintf$719 Def02B9 +S A$vprintf$683 Def028D +S A$vprintf$665 Def0275 +S A$vprintf$647 Def025E +S A$vprintf$593 Def0220 +S A$vprintf$575 Def0205 +S A$vprintf$566 Def01FA +S A$vprintf$548 Def01E4 +S A$vprintf$539 Def01D0 +S A$vprintf$494 Def0194 +S A$vprintf$485 Def0180 +S A$vprintf$476 Def0171 +S A$vprintf$467 Def0164 +S A$vprintf$458 Def0155 +S A$vprintf$395 Def010B +S A$vprintf$386 Def0102 +S A$vprintf$368 Def00F4 +S A$vprintf$359 Def00E9 +S A$vprintf$296 Def00A3 +S A$vprintf$287 Def0098 +S A$vprintf$269 Def008A +S A$vprintf$188 Def0037 +S A$vprintf$179 Def002A +S A$vprintf$981 Def042B +S A$vprintf$945 Def03FD +S A$vprintf$936 Def03ED +S A$vprintf$918 Def03DA +S A$vprintf$909 Def03CC +S A$vprintf$891 Def03B3 +S A$vprintf$882 Def03A3 +S A$vprintf$873 Def0399 +S A$vprintf$864 Def038E +S A$vprintf$855 Def0383 +S A$vprintf$837 Def0364 +S A$vprintf$828 Def0352 +S A$vprintf$819 Def0340 +S A$vprintf$792 Def031E +S A$vprintf$774 Def0306 +S A$vprintf$765 Def02FA +S A$vprintf$756 Def02F1 +S A$vprintf$747 Def02E6 +S A$vprintf$729 Def02C7 +S A$vprintf$693 Def0297 +S A$vprintf$657 Def0266 +S A$vprintf$648 Def0260 +S A$vprintf$639 Def0253 +S A$vprintf$585 Def0212 +S A$vprintf$576 Def0207 +S A$vprintf$567 Def01FB +S A$vprintf$558 Def01EF +S A$vprintf$549 Def01E6 +S A$vprintf$486 Def0182 +S A$vprintf$477 Def0174 +S A$vprintf$468 Def0165 +S A$vprintf$459 Def0157 +S A$vprintf$396 Def010C +S A$vprintf$378 Def00FC +S A$vprintf$369 Def00F5 +S A$vprintf$297 Def00A5 +S A$vprintf$198 Def003A +S XFvprintf$output_digit$0$0 Def006F +S A$vprintf$991 Def0435 +S A$vprintf$973 Def0423 +S A$vprintf$964 Def0417 +S A$vprintf$955 Def040B +S A$vprintf$946 Def0400 +S A$vprintf$937 Def03EE +S A$vprintf$928 Def03E5 +S A$vprintf$892 Def03B6 +S A$vprintf$883 Def03A5 +S A$vprintf$874 Def039A +S A$vprintf$865 Def038F +S A$vprintf$856 Def0384 +S A$vprintf$847 Def0377 +S A$vprintf$838 Def0367 +S A$vprintf$829 Def0354 +S A$vprintf$793 Def0320 +S A$vprintf$775 Def0308 +S A$vprintf$757 Def02F3 +S A$vprintf$739 Def02D5 +S A$vprintf$676 Def0286 +S A$vprintf$667 Def0277 +S A$vprintf$658 Def0269 +S A$vprintf$586 Def0214 +S A$vprintf$568 Def01FE +S A$vprintf$559 Def01F1 +S A$vprintf$496 Def0196 +S A$vprintf$487 Def0184 +S A$vprintf$469 Def0166 +S A$vprintf$397 Def010D +S A$vprintf$298 Def00A7 +S A$vprintf$199 Def003C +S A$vprintf$992 Def0438 +S A$vprintf$983 Def042D +S A$vprintf$965 Def0419 +S A$vprintf$938 Def03EF +S A$vprintf$893 Def03B8 +S A$vprintf$875 Def039D +S A$vprintf$866 Def0391 +S A$vprintf$857 Def0385 +S A$vprintf$839 Def0369 +S A$vprintf$794 Def0322 +S A$vprintf$785 Def030E +S A$vprintf$686 Def0290 +S A$vprintf$668 Def027A +S A$vprintf$596 Def0221 +S A$vprintf$587 Def0216 +S A$vprintf$578 Def020A +S A$vprintf$569 Def0200 +S A$vprintf$488 Def0186 +S A$vprintf$479 Def0177 +S A$vprintf$398 Def010E +S A$vprintf$299 Def00A8 +S A$vprintf$993 Def043A +S A$vprintf$984 Def0430 +S A$vprintf$975 Def0425 +S A$vprintf$966 Def041C +S A$vprintf$948 Def0402 +S A$vprintf$939 Def03F1 +S A$vprintf$894 Def03BA +S A$vprintf$876 Def039F +S A$vprintf$858 Def0387 +S A$vprintf$786 Def0310 +S A$vprintf$777 Def030A +S A$vprintf$768 Def02FB +S A$vprintf$759 Def02F4 +S A$vprintf$696 Def029A +S A$vprintf$678 Def0288 +S A$vprintf$579 Def020D +S A$vprintf$489 Def0189 +S A$vprintf$399 Def010F +S C$vprintf.c$80$1$1 Def006F +S A$vprintf$985 Def0432 +S A$vprintf$976 Def0428 +S A$vprintf$967 Def041F +S A$vprintf$958 Def040D +S A$vprintf$895 Def03BC +S A$vprintf$886 Def03A8 +S A$vprintf$859 Def0388 +S A$vprintf$787 Def0312 +S A$vprintf$769 Def02FD +S A$vprintf$688 Def0292 +S A$vprintf$589 Def0219 +S A$vprintf$499 Def0198 +S A$vprintf$977 Def042A +S A$vprintf$959 Def040F +S A$vprintf$887 Def03AA +S A$vprintf$878 Def03A1 +S A$vprintf$869 Def0392 +S A$vprintf$797 Def0324 +S A$vprintf$788 Def0314 +S A$vprintf$698 Def029C +S A$vprintf$599 Def0223 +S Fvprintf$calculate_digit$0$0 Def0093 +S C$vprintf.c$73$1$1 Def0039 +S A$vprintf$888 Def03AC +S A$vprintf$789 Def0316 +S A$vprintf$997 Def043B +S A$vprintf$898 Def03BE +S A$vprintf$889 Def03AE +S A$vprintf$799 Def0326 +S _vsprintf Def00CF +S A$vprintf$989 Def0433 +S Fvprintf$output_digit$0$0 Def003A +S A$vprintf$999 Def043D +S C$vprintf.c$88$1$1 Def0092 +S XFvprintf$output_char$0$0 Def0039 +S XG$vsprintf$0$0 Def062C +S _vprintf Def062D +S Fvprintf$output_char$0$0 Def0000 +S G$vsprintf$0$0 Def00CF +S A$vprintf$1000 Def0440 +S A$vprintf$1100 Def04C0 +S A$vprintf$1001 Def0442 +S XG$vprintf$0$0 Def066A +S A$vprintf$1200 Def0529 +S A$vprintf$1101 Def04C1 +S A$vprintf$1020 Def0455 +S A$vprintf$1210 Def053B +S A$vprintf$1120 Def04D7 +S A$vprintf$1111 Def04CE +S A$vprintf$1102 Def04C2 +S A$vprintf$1030 Def0460 +S A$vprintf$1012 Def044A +S A$vprintf$1310 Def05A9 +S A$vprintf$1301 Def059C +S A$vprintf$1211 Def053D +S A$vprintf$1202 Def052C +S A$vprintf$1130 Def04E1 +S A$vprintf$1103 Def04C4 +S A$vprintf$1040 Def046F +S A$vprintf$1031 Def0463 +S A$vprintf$1013 Def044D +S A$vprintf$1410 Def0629 +S A$vprintf$1401 Def061A +S A$vprintf$1311 Def05AA +S A$vprintf$1221 Def0546 +S A$vprintf$1212 Def053F +S A$vprintf$1203 Def052E +S A$vprintf$1140 Def04EF +S A$vprintf$1131 Def04E3 +S A$vprintf$1104 Def04C5 +S A$vprintf$1050 Def047E +S A$vprintf$1041 Def0471 +S A$vprintf$1032 Def0464 +S A$vprintf$1023 Def0458 +S A$vprintf$1014 Def044E +S A$vprintf$1005 Def0443 +S A$vprintf$1402 Def061D +S A$vprintf$1330 Def05C2 +S A$vprintf$1312 Def05AC +S A$vprintf$1231 Def054F +S A$vprintf$1204 Def0531 +S A$vprintf$1141 Def04F0 +S A$vprintf$1132 Def04E4 +S A$vprintf$1123 Def04DA +S A$vprintf$1114 Def04D1 +S A$vprintf$1105 Def04C6 +S A$vprintf$1060 Def048A +S A$vprintf$1042 Def0473 +S A$vprintf$1033 Def0466 +S A$vprintf$1024 Def045B +S A$vprintf$1015 Def044F +S XFvprintf$output_2digits$0$0 Def0092 +S A$vprintf$1430 Def063C +S A$vprintf$1403 Def0620 +S A$vprintf$1331 Def05C5 +S A$vprintf$1322 Def05B5 +S A$vprintf$1313 Def05AF +S A$vprintf$1304 Def059F +S A$vprintf$1250 Def0561 +S A$vprintf$1223 Def0548 +S A$vprintf$1214 Def0541 +S A$vprintf$1142 Def04F2 +S A$vprintf$1133 Def04E5 +S A$vprintf$1106 Def04C8 +S A$vprintf$1070 Def0498 +S A$vprintf$1061 Def048D +S A$vprintf$1052 Def0481 +S A$vprintf$1034 Def0467 +S A$vprintf$1016 Def0452 +S A$vprintf$1007 Def0445 +S A$vprintf$1440 Def0649 +S A$vprintf$1431 Def063D +S A$vprintf$1422 Def062D +S A$vprintf$1341 Def05D0 +S A$vprintf$1323 Def05B8 +S A$vprintf$1305 Def05A2 +S A$vprintf$1251 Def0562 +S A$vprintf$1242 Def0558 +S A$vprintf$1215 Def0543 +S A$vprintf$1206 Def0533 +S A$vprintf$1170 Def050D +S A$vprintf$1161 Def0505 +S A$vprintf$1152 Def04FC +S A$vprintf$1143 Def04F4 +S A$vprintf$1134 Def04E7 +S A$vprintf$1125 Def04DC +S A$vprintf$1116 Def04D4 +S A$vprintf$1107 Def04CA +S A$vprintf$1080 Def04A6 +S A$vprintf$1071 Def0499 +S A$vprintf$1053 Def0484 +S A$vprintf$1044 Def0475 +S A$vprintf$1035 Def0468 +S A$vprintf$1026 Def045C +S A$vprintf$1008 Def0447 +S A$vprintf$1450 Def0657 +S A$vprintf$1441 Def064A +S A$vprintf$1432 Def063F +S A$vprintf$1423 Def062F +S A$vprintf$1414 Def062C +S A$vprintf$1360 Def05E3 +S A$vprintf$1351 Def05D8 +S A$vprintf$1342 Def05D2 +S A$vprintf$1315 Def05B0 +S A$vprintf$1261 Def056D +S A$vprintf$1252 Def0563 +S A$vprintf$1207 Def0536 +S A$vprintf$1144 Def04F6 +S A$vprintf$1135 Def04E8 +S A$vprintf$1108 Def04CC +S A$vprintf$1090 Def04B2 +S A$vprintf$1081 Def04A8 +S A$vprintf$1072 Def049B +S A$vprintf$1063 Def048E +S A$vprintf$1045 Def0478 +S A$vprintf$1036 Def046A +S A$vprintf$1027 Def045D +S G$vprintf$0$0 Def062D +S A$vprintf$1460 Def0664 +S A$vprintf$1451 Def0658 +S A$vprintf$1442 Def064B +S A$vprintf$1433 Def0640 +S A$vprintf$1424 Def0631 +S A$vprintf$1370 Def05F0 +S A$vprintf$1361 Def05E5 +S A$vprintf$1343 Def05D3 +S A$vprintf$1334 Def05C6 +S A$vprintf$1325 Def05BB +S A$vprintf$1307 Def05A5 +S A$vprintf$1271 Def057A +S A$vprintf$1253 Def0564 +S A$vprintf$1226 Def054A +S A$vprintf$1208 Def0538 +S A$vprintf$1190 Def0520 +S A$vprintf$1181 Def0515 +S A$vprintf$1163 Def0507 +S A$vprintf$1154 Def04FF +S A$vprintf$1136 Def04E9 +S A$vprintf$1091 Def04B3 +S A$vprintf$1082 Def04AA +S A$vprintf$1073 Def049C +S A$vprintf$1064 Def048F +S A$vprintf$1037 Def046B +S A$vprintf$1461 Def0667 +S A$vprintf$1452 Def0659 +S A$vprintf$1443 Def064C +S A$vprintf$1434 Def0641 +S A$vprintf$1425 Def0633 +S A$vprintf$1407 Def0623 +S A$vprintf$1380 Def05FB +S A$vprintf$1371 Def05F2 +S A$vprintf$1362 Def05E7 +S A$vprintf$1353 Def05DB +S A$vprintf$1344 Def05D4 +S A$vprintf$1335 Def05C9 +S A$vprintf$1326 Def05BE +S A$vprintf$1308 Def05A8 +S A$vprintf$1281 Def0585 +S A$vprintf$1254 Def0565 +S A$vprintf$1245 Def055B +S A$vprintf$1236 Def0552 +S A$vprintf$1227 Def054D +S A$vprintf$1218 Def0545 +S A$vprintf$1209 Def053A +S A$vprintf$1191 Def0521 +S A$vprintf$1173 Def050F +S A$vprintf$1155 Def0500 +S A$vprintf$1146 Def04F8 +S A$vprintf$1137 Def04EB +S A$vprintf$1128 Def04DF +S A$vprintf$1074 Def049E +S A$vprintf$1038 Def046C +S A$vprintf$1029 Def045F +S A$vprintf$1453 Def065A +S A$vprintf$1444 Def064F +S A$vprintf$1435 Def0644 +S A$vprintf$1426 Def0636 +S A$vprintf$1381 Def05FE +S A$vprintf$1372 Def05F3 +S A$vprintf$1363 Def05EA +S A$vprintf$1345 Def05D5 +S A$vprintf$1336 Def05CA +S A$vprintf$1282 Def0588 +S A$vprintf$1264 Def056F +S A$vprintf$1255 Def0566 +S A$vprintf$1246 Def055C +S A$vprintf$1237 Def0555 +S A$vprintf$1228 Def054E +S A$vprintf$1192 Def0524 +S A$vprintf$1183 Def0517 +S A$vprintf$1138 Def04EC +S A$vprintf$1129 Def04E0 +S A$vprintf$1093 Def04B5 +S A$vprintf$1084 Def04AC +S A$vprintf$1075 Def049F +S A$vprintf$1066 Def0491 +S A$vprintf$1057 Def0487 +S A$vprintf$1048 Def047B +S A$vprintf$1039 Def046D +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 07 +R 00 00 00 01 +T 00 07 +R 00 00 00 01 +T 00 0A +R 00 00 00 01 +T 00 0A +R 00 00 00 01 +T 00 0B +R 00 00 00 01 +T 00 0B +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 0F +R 00 00 00 01 +T 00 0F +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 11 +R 00 00 00 01 +T 00 11 +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 04 +R 00 00 00 04 +T 00 04 +R 00 00 00 04 +T 00 05 +R 00 00 00 04 +T 00 05 +R 00 00 00 04 +T 00 06 +R 00 00 00 04 +T 00 06 +R 00 00 00 04 +T 00 07 +R 00 00 00 04 +T 00 07 +R 00 00 00 04 +T 00 08 +R 00 00 00 04 +T 00 08 +R 00 00 00 04 +T 00 09 +R 00 00 00 04 +T 00 09 +R 00 00 00 04 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 07 +R 00 00 00 05 +T 00 07 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 0B +R 00 00 00 05 +T 00 0B +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0C +R 00 00 00 05 +T 00 0D +R 00 00 00 05 +T 00 0D +R 00 00 00 05 +T 00 0E +R 00 00 00 05 +T 00 0E +R 00 00 00 05 +T 00 0F +R 00 00 00 05 +T 00 0F +R 00 00 00 05 +T 00 00 +R 00 00 00 07 +T 00 00 C0 00 00 85 81 00 00 AA 82 30 00 00 25 +R 00 00 00 07 2B 03 00 04 2B 07 00 04 29 0C 00 04 +T 00 0A +R 00 00 00 07 +T 00 0A 90 00 00 E0 FB A3 E0 FC A3 E0 FD 90 00 00 +R 00 00 00 07 00 03 00 05 00 0E 00 05 +T 00 18 74 01 2B F0 E4 3C A3 F0 A3 ED F0 8B 82 8C +R 00 00 00 07 +T 00 26 83 8D F0 EA 12 00 00 80 05 +R 00 00 00 07 02 07 00 01 +T 00 2F +R 00 00 00 07 +T 00 2F 8A 82 12 00 00 +R 00 00 00 07 02 05 00 02 +T 00 34 +R 00 00 00 07 +T 00 34 85 00 00 81 D0 00 00 22 +R 00 00 00 07 2B 03 00 04 2B 07 00 04 +T 00 3A +R 00 00 00 07 +T 00 3A C0 00 00 85 81 00 00 AA 82 C3 74 09 9A E4 +R 00 00 00 07 2B 03 00 04 2B 07 00 04 +T 00 46 33 FB B4 01 00 +R 00 00 00 07 +T 00 4B +R 00 00 00 07 +T 00 4B E4 33 FB 60 06 +R 00 00 00 07 +T 00 50 +R 00 00 00 07 +T 00 50 74 30 2A FB 80 0F +R 00 00 00 07 +T 00 56 +R 00 00 00 07 +T 00 56 30 00 01 06 +R 00 00 00 07 29 03 00 04 +T 00 59 +R 00 00 00 07 +T 00 59 74 57 2A FC 80 04 +R 00 00 00 07 +T 00 5F +R 00 00 00 07 +T 00 5F 74 37 2A FC +R 00 00 00 07 +T 00 63 +R 00 00 00 07 +T 00 63 8C 03 +R 00 00 00 07 +T 00 65 +R 00 00 00 07 +T 00 65 8B 82 12 00 00 +R 00 00 00 07 00 05 00 07 +T 00 6A +R 00 00 00 07 +T 00 6A 85 00 00 81 D0 00 00 22 +R 00 00 00 07 2B 03 00 04 2B 07 00 04 +T 00 70 +R 00 00 00 07 +T 00 70 C0 00 00 85 81 00 00 AA 82 EA C4 54 0F FB +R 00 00 00 07 2B 03 00 04 2B 07 00 04 +T 00 7C C0 02 8B 82 12 00 3A D0 02 53 02 0F 8A 82 +R 00 00 00 07 00 07 00 07 +T 00 8A 12 00 3A +R 00 00 00 07 00 03 00 07 +T 00 8D +R 00 00 00 07 +T 00 8D 85 00 00 81 D0 00 00 22 +R 00 00 00 07 2B 03 00 04 2B 07 00 04 +T 00 93 +R 00 00 00 07 +T 00 93 7A 20 +R 00 00 00 07 +T 00 95 +R 00 00 00 07 +T 00 95 BA 00 02 80 34 +R 00 00 00 07 +T 00 9A +R 00 00 00 07 +T 00 9A C3 E5 00 00 33 F5 00 00 E5 00 01 33 F5 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0B 00 01 +T 00 A4 00 01 E5 00 02 33 F5 00 02 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 00 AB 00 03 33 F5 00 03 E5 00 04 33 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 B3 00 04 90 00 03 E0 FB C3 E5 00 04 9B 40 0C +R 00 00 00 07 29 02 00 01 00 05 00 05 29 0B 00 01 +T 00 BF +R 00 00 00 07 +T 00 BF C3 E5 00 04 9B F5 00 04 74 01 25 00 00 F5 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0D 00 01 +T 00 CA 00 00 +R 00 00 00 07 29 02 00 01 +T 00 CB +R 00 00 00 07 +T 00 CB 1A 80 C7 +R 00 00 00 07 +T 00 CE +R 00 00 00 07 +T 00 CE 22 +R 00 00 00 07 +T 00 CF +R 00 00 00 07 +T 00 CF C0 F0 C0 83 C0 82 90 00 08 D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 00 DD A3 F0 D0 E0 A3 F0 90 00 08 E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 00 EB A3 E0 FC 90 00 00 EA F0 A3 EB F0 A3 EC F0 +R 00 00 00 07 00 06 00 05 +T 00 F9 EA 4B 4C 70 04 +R 00 00 00 07 +T 00 FE +R 00 00 00 07 +T 00 FE C2 00 00 80 02 +R 00 00 00 07 29 03 00 04 +T 01 02 +R 00 00 00 07 +T 01 02 D2 00 00 +R 00 00 00 07 29 03 00 04 +T 01 04 +R 00 00 00 07 +T 01 04 +R 00 00 00 07 +T 01 04 90 00 04 E0 FA A3 E0 FB A3 E0 FC 74 01 2A +R 00 00 00 07 00 03 00 05 +T 01 12 FD E4 3B FE 8C 07 90 00 04 ED F0 A3 EE F0 +R 00 00 00 07 00 09 00 05 +T 01 20 A3 EF F0 8A 82 8B 83 8C F0 12 00 00 F5 +R 00 00 00 07 02 0C 00 06 +T 01 2D 00 05 70 03 02 06 23 +R 00 00 00 07 29 02 00 01 00 07 00 07 +T 01 33 +R 00 00 00 07 +T 01 33 E5 00 05 B4 25 02 80 03 +R 00 00 00 07 29 03 00 01 +T 01 3A +R 00 00 00 07 +T 01 3A 02 06 1A +R 00 00 00 07 00 03 00 07 +T 01 3D +R 00 00 00 07 +T 01 3D C2 00 03 C2 00 04 C2 00 05 C2 +R 00 00 00 07 29 03 00 04 29 06 00 04 29 09 00 04 +T 01 44 00 06 C2 00 07 90 00 03 E4 F0 C2 +R 00 00 00 07 29 02 00 04 29 05 00 04 00 08 00 05 +T 01 4D 00 08 C2 00 09 90 00 0B E4 F0 +R 00 00 00 07 29 02 00 04 29 05 00 04 00 08 00 05 +T 01 55 +R 00 00 00 07 +T 01 55 8D 00 07 8E 00 08 8F 00 09 0D BD 00 01 0E +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 01 60 +R 00 00 00 07 +T 01 60 90 00 04 ED F0 A3 EE F0 A3 EF F0 85 00 07 +R 00 00 00 07 00 03 00 05 29 0E 00 01 +T 01 6D 82 85 00 08 83 85 00 09 F0 12 00 00 F9 90 +R 00 00 00 07 29 04 00 01 29 08 00 01 02 0C 00 06 +T 01 79 00 0D F0 C0 05 C0 06 C0 07 C0 01 89 82 12 +R 00 00 00 07 00 02 00 05 +T 01 87 00 00 85 82 00 06 D0 01 D0 07 D0 06 D0 05 +R 00 00 00 07 02 02 00 00 29 06 00 01 +T 01 94 E5 00 06 60 2C +R 00 00 00 07 29 03 00 01 +T 01 98 +R 00 00 00 07 +T 01 98 90 00 0B E0 FA 75 F0 0A EA A4 F5 00 0C E9 +R 00 00 00 07 00 03 00 05 29 0D 00 01 +T 01 A5 24 D0 F5 00 0A 25 00 0C F8 90 00 0B F0 B8 +R 00 00 00 07 29 05 00 01 29 08 00 01 00 0C 00 05 +T 01 B1 00 04 74 01 80 01 +R 00 00 00 07 +T 01 B7 +R 00 00 00 07 +T 01 B7 E4 +R 00 00 00 07 +T 01 B8 +R 00 00 00 07 +T 01 B8 F5 00 0B 70 03 02 01 55 +R 00 00 00 07 29 03 00 01 00 08 00 07 +T 01 BF +R 00 00 00 07 +T 01 BF D2 00 04 02 01 55 +R 00 00 00 07 29 03 00 04 00 06 00 07 +T 01 C4 +R 00 00 00 07 +T 01 C4 C0 02 C0 05 C0 06 C0 07 C0 00 C0 01 89 82 +R 00 00 00 07 +T 01 D2 12 00 00 85 82 00 0D D0 01 D0 00 D0 07 D0 +R 00 00 00 07 02 03 00 03 29 07 00 01 +T 01 DF 06 D0 05 D0 02 E5 00 0D B4 01 00 +R 00 00 00 07 29 08 00 01 +T 01 E9 +R 00 00 00 07 +T 01 E9 B3 92 00 01 30 00 01 07 +R 00 00 00 07 29 04 00 04 29 07 00 04 +T 01 EF +R 00 00 00 07 +T 01 EF 74 DF 59 90 00 0D F0 +R 00 00 00 07 00 06 00 05 +T 01 F6 +R 00 00 00 07 +T 01 F6 90 00 0D E0 FB BB 20 04 74 01 80 01 +R 00 00 00 07 00 03 00 05 +T 02 02 +R 00 00 00 07 +T 02 02 E4 +R 00 00 00 07 +T 02 03 +R 00 00 00 07 +T 02 03 F5 00 0E 60 03 02 02 90 +R 00 00 00 07 29 03 00 01 00 08 00 07 +T 02 0A +R 00 00 00 07 +T 02 0A BB 2B 04 74 01 80 01 +R 00 00 00 07 +T 02 11 +R 00 00 00 07 +T 02 11 E4 +R 00 00 00 07 +T 02 12 +R 00 00 00 07 +T 02 12 F5 00 0F 60 03 02 02 8B +R 00 00 00 07 29 03 00 01 00 08 00 07 +T 02 19 +R 00 00 00 07 +T 02 19 BB 2D 04 74 01 80 01 +R 00 00 00 07 +T 02 20 +R 00 00 00 07 +T 02 20 E4 +R 00 00 00 07 +T 02 21 +R 00 00 00 07 +T 02 21 F5 00 10 70 61 +R 00 00 00 07 29 03 00 01 +T 02 25 +R 00 00 00 07 +T 02 25 BB 42 04 74 01 80 01 +R 00 00 00 07 +T 02 2C +R 00 00 00 07 +T 02 2C E4 +R 00 00 00 07 +T 02 2D +R 00 00 00 07 +T 02 2D F5 00 11 70 64 +R 00 00 00 07 29 03 00 01 +T 02 31 +R 00 00 00 07 +T 02 31 BB 43 04 74 01 80 01 +R 00 00 00 07 +T 02 38 +R 00 00 00 07 +T 02 38 E4 +R 00 00 00 07 +T 02 39 +R 00 00 00 07 +T 02 39 F5 00 12 70 62 +R 00 00 00 07 29 03 00 01 +T 02 3D +R 00 00 00 07 +T 02 3D BB 44 04 74 01 80 01 +R 00 00 00 07 +T 02 44 +R 00 00 00 07 +T 02 44 E4 +R 00 00 00 07 +T 02 45 +R 00 00 00 07 +T 02 45 F5 00 13 60 03 02 04 23 +R 00 00 00 07 29 03 00 01 00 08 00 07 +T 02 4C +R 00 00 00 07 +T 02 4C BB 49 04 74 01 80 01 +R 00 00 00 07 +T 02 53 +R 00 00 00 07 +T 02 53 E4 +R 00 00 00 07 +T 02 54 +R 00 00 00 07 +T 02 54 F5 00 14 60 03 02 04 23 +R 00 00 00 07 29 03 00 01 00 08 00 07 +T 02 5B +R 00 00 00 07 +T 02 5B BB 4C 04 74 01 80 01 +R 00 00 00 07 +T 02 62 +R 00 00 00 07 +T 02 62 E4 +R 00 00 00 07 +T 02 63 +R 00 00 00 07 +T 02 63 FC 70 34 +R 00 00 00 07 +T 02 66 +R 00 00 00 07 +T 02 66 BB 4F 03 02 04 2D +R 00 00 00 07 00 06 00 07 +T 02 6C +R 00 00 00 07 +T 02 6C BB 50 03 02 03 C0 +R 00 00 00 07 00 06 00 07 +T 02 72 +R 00 00 00 07 +T 02 72 BB 53 02 80 42 +R 00 00 00 07 +T 02 77 +R 00 00 00 07 +T 02 77 BB 55 03 02 04 35 +R 00 00 00 07 00 06 00 07 +T 02 7D +R 00 00 00 07 +T 02 7D BB 58 03 02 04 3D +R 00 00 00 07 00 06 00 07 +T 02 83 +R 00 00 00 07 +T 02 83 02 04 45 +R 00 00 00 07 00 03 00 07 +T 02 86 +R 00 00 00 07 +T 02 86 D2 00 03 02 01 55 +R 00 00 00 07 29 03 00 04 00 06 00 07 +T 02 8B +R 00 00 00 07 +T 02 8B D2 00 05 02 01 55 +R 00 00 00 07 29 03 00 04 00 06 00 07 +T 02 90 +R 00 00 00 07 +T 02 90 D2 00 06 02 01 55 +R 00 00 00 07 29 03 00 04 00 06 00 07 +T 02 95 +R 00 00 00 07 +T 02 95 D2 00 08 02 01 55 +R 00 00 00 07 29 03 00 04 00 06 00 07 +T 02 9A +R 00 00 00 07 +T 02 9A D2 00 09 02 01 55 +R 00 00 00 07 29 03 00 04 00 06 00 07 +T 02 9F +R 00 00 00 07 +T 02 9F 90 00 07 E0 FA 24 FF F8 90 00 07 F0 86 02 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 02 AD C0 03 8A 82 12 00 00 D0 03 02 04 4A +R 00 00 00 07 00 07 00 07 00 0C 00 07 +T 02 B9 +R 00 00 00 07 +T 02 B9 90 00 07 E0 FA 24 FD F8 90 00 07 F0 86 02 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 02 C7 08 86 04 08 86 05 18 18 8A 00 00 8C 00 01 +R 00 00 00 07 29 0B 00 01 29 0E 00 01 +T 02 D3 8D 00 02 C0 03 8A 82 8C 83 8D F0 12 00 00 +R 00 00 00 07 29 03 00 01 02 0E 00 05 +T 02 E0 AA 82 AC 83 D0 03 8A 00 14 20 00 03 3B +R 00 00 00 07 29 09 00 01 29 0C 00 04 +T 02 EB +R 00 00 00 07 +T 02 EB 90 00 0B E0 FC C3 E5 00 14 9C 50 30 +R 00 00 00 07 00 03 00 05 29 09 00 01 +T 02 F6 +R 00 00 00 07 +T 02 F6 C3 EC 95 00 14 FC +R 00 00 00 07 29 05 00 01 +T 02 FB +R 00 00 00 07 +T 02 FB 8C 05 1C 90 00 0B EC F0 BD 00 04 74 01 80 +R 00 00 00 07 00 06 00 05 +T 03 09 01 +R 00 00 00 07 +T 03 0A +R 00 00 00 07 +T 03 0A E4 +R 00 00 00 07 +T 03 0B +R 00 00 00 07 +T 03 0B FE 70 18 +R 00 00 00 07 +T 03 0E +R 00 00 00 07 +T 03 0E C0 03 C0 04 C0 05 C0 06 75 82 20 12 00 00 +R 00 00 00 07 00 0E 00 07 +T 03 1C D0 06 D0 05 D0 04 D0 03 80 D5 +R 00 00 00 07 +T 03 26 +R 00 00 00 07 +T 03 26 AC 00 00 AD 00 01 AE 00 02 8C 82 8D 83 8E +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 03 31 F0 12 00 00 F5 00 13 60 40 +R 00 00 00 07 02 04 00 06 29 07 00 01 +T 03 39 +R 00 00 00 07 +T 03 39 74 01 2C F8 E4 3D F9 8E 02 88 00 00 89 +R 00 00 00 07 29 0C 00 01 +T 03 45 00 01 8A 00 02 8C 82 8D 83 8E F0 12 00 00 +R 00 00 00 07 29 02 00 01 29 05 00 01 02 0E 00 06 +T 03 51 FF C0 02 C0 03 C0 04 C0 05 C0 06 C0 07 C0 +R 00 00 00 07 +T 03 5F 00 C0 01 8F 82 12 00 00 D0 01 D0 00 D0 07 +R 00 00 00 07 00 08 00 07 +T 03 6D D0 06 D0 05 D0 04 D0 03 D0 02 80 AD +R 00 00 00 07 +T 03 79 +R 00 00 00 07 +T 03 79 20 00 03 03 02 04 4A +R 00 00 00 07 29 03 00 04 00 07 00 07 +T 03 7F +R 00 00 00 07 +T 03 7F 90 00 0B E0 FA C3 E5 00 14 9A 40 03 02 +R 00 00 00 07 00 03 00 05 29 09 00 01 +T 03 8B 04 4A +R 00 00 00 07 00 02 00 07 +T 03 8D +R 00 00 00 07 +T 03 8D C3 EA 95 00 14 FA +R 00 00 00 07 29 05 00 01 +T 03 92 +R 00 00 00 07 +T 03 92 8A 04 1A 90 00 0B EA F0 BC 00 04 74 01 80 +R 00 00 00 07 00 06 00 05 +T 03 A0 01 +R 00 00 00 07 +T 03 A1 +R 00 00 00 07 +T 03 A1 E4 +R 00 00 00 07 +T 03 A2 +R 00 00 00 07 +T 03 A2 FD 60 03 02 04 4A +R 00 00 00 07 00 06 00 07 +T 03 A8 +R 00 00 00 07 +T 03 A8 C0 02 C0 03 C0 04 C0 05 75 82 20 12 00 00 +R 00 00 00 07 00 0E 00 07 +T 03 B6 D0 05 D0 04 D0 03 D0 02 80 D2 +R 00 00 00 07 +T 03 C0 +R 00 00 00 07 +T 03 C0 90 00 07 E0 FA 24 FD F8 90 00 07 F0 86 02 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 03 CE 08 86 04 08 86 05 18 18 8A 00 00 8C 00 01 +R 00 00 00 07 29 0B 00 01 29 0E 00 01 +T 03 DA 8D 00 02 C3 74 03 95 00 02 50 04 +R 00 00 00 07 29 03 00 01 29 09 00 01 +T 03 E3 +R 00 00 00 07 +T 03 E3 7A 04 80 02 +R 00 00 00 07 +T 03 E7 +R 00 00 00 07 +T 03 E7 AA 00 02 +R 00 00 00 07 29 03 00 01 +T 03 E9 +R 00 00 00 07 +T 03 E9 EA 90 06 6B 93 FA C0 03 8A 82 12 00 00 D0 +R 00 00 00 07 00 04 00 07 00 0D 00 07 +T 03 F7 03 C0 03 75 82 3A 12 00 00 D0 03 E5 00 02 +R 00 00 00 07 00 09 00 07 29 0E 00 01 +T 04 04 60 11 +R 00 00 00 07 +T 04 06 +R 00 00 00 07 +T 04 06 E5 00 02 B4 03 02 80 0A +R 00 00 00 07 29 03 00 01 +T 04 0D +R 00 00 00 07 +T 04 0D C0 03 85 00 01 82 12 00 70 D0 03 +R 00 00 00 07 29 05 00 01 00 09 00 07 +T 04 17 +R 00 00 00 07 +T 04 17 C0 03 85 00 00 82 12 00 70 D0 03 80 27 +R 00 00 00 07 29 05 00 01 00 09 00 07 +T 04 23 +R 00 00 00 07 +T 04 23 D2 00 07 90 00 03 74 0A F0 80 1D +R 00 00 00 07 29 03 00 04 00 06 00 05 +T 04 2D +R 00 00 00 07 +T 04 2D 90 00 03 74 08 F0 80 15 +R 00 00 00 07 00 03 00 05 +T 04 35 +R 00 00 00 07 +T 04 35 90 00 03 74 0A F0 80 0D +R 00 00 00 07 00 03 00 05 +T 04 3D +R 00 00 00 07 +T 04 3D 90 00 03 74 10 F0 80 05 +R 00 00 00 07 00 03 00 05 +T 04 45 +R 00 00 00 07 +T 04 45 8B 82 12 00 00 +R 00 00 00 07 00 05 00 07 +T 04 4A +R 00 00 00 07 +T 04 4A 90 00 03 E0 FA BA 00 03 02 01 04 +R 00 00 00 07 00 03 00 05 00 0B 00 07 +T 04 55 +R 00 00 00 07 +T 04 55 30 00 08 2F +R 00 00 00 07 29 03 00 04 +T 04 58 +R 00 00 00 07 +T 04 58 90 00 07 E0 FA 24 FF F8 90 00 07 F0 86 02 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 04 66 EA 33 95 E0 FB FC FD 8A 00 00 8B 00 01 8C +R 00 00 00 07 29 0A 00 01 29 0D 00 01 +T 04 72 00 02 8D 00 03 30 00 07 03 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 04 +T 04 79 04 D7 +R 00 00 00 07 00 02 00 07 +T 04 7B +R 00 00 00 07 +T 04 7B 75 00 01 00 75 00 02 00 75 00 03 00 02 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 04 85 04 D7 +R 00 00 00 07 00 02 00 07 +T 04 87 +R 00 00 00 07 +T 04 87 30 00 09 24 +R 00 00 00 07 29 03 00 04 +T 04 8A +R 00 00 00 07 +T 04 8A 90 00 07 E0 FA 24 FC F8 90 00 07 F0 86 02 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 04 98 08 86 03 08 86 04 08 86 05 18 18 18 8A +R 00 00 00 07 +T 04 A5 00 00 8B 00 01 8C 00 02 8D +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 AB 00 03 80 29 +R 00 00 00 07 29 02 00 01 +T 04 AE +R 00 00 00 07 +T 04 AE 90 00 07 E0 FA 24 FE F8 90 00 07 F0 86 02 +R 00 00 00 07 00 03 00 05 00 0B 00 05 +T 04 BC 08 86 03 18 EB 33 95 E0 FC FD 8A 00 00 8B +R 00 00 00 07 29 0D 00 01 +T 04 C9 00 01 8C 00 02 8D 00 03 20 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 CF 00 07 06 +R 00 00 00 07 29 02 00 04 +T 04 D1 +R 00 00 00 07 +T 04 D1 75 00 02 00 75 00 03 00 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 04 D7 +R 00 00 00 07 +T 04 D7 30 00 07 22 +R 00 00 00 07 29 03 00 04 +T 04 DA +R 00 00 00 07 +T 04 DA E5 00 03 30 E7 1B +R 00 00 00 07 29 03 00 01 +T 04 DF +R 00 00 00 07 +T 04 DF C3 E4 95 00 00 FA E4 95 00 01 FB E4 95 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 04 EA 00 02 FC E4 95 00 03 FD 8A 00 00 8B +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 04 F3 00 01 8C 00 02 8D 00 03 80 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 FA +R 00 00 00 07 +T 04 FA C2 00 07 +R 00 00 00 07 29 03 00 04 +T 04 FC +R 00 00 00 07 +T 04 FC 90 00 0C E4 F0 D2 00 02 7A 00 +R 00 00 00 07 00 03 00 05 29 08 00 04 +T 05 05 +R 00 00 00 07 +T 05 05 E5 00 00 60 02 +R 00 00 00 07 29 03 00 01 +T 05 09 +R 00 00 00 07 +T 05 09 80 1E +R 00 00 00 07 +T 05 0B +R 00 00 00 07 +T 05 0B E5 00 01 60 02 +R 00 00 00 07 29 03 00 01 +T 05 0F +R 00 00 00 07 +T 05 0F 80 18 +R 00 00 00 07 +T 05 11 +R 00 00 00 07 +T 05 11 E5 00 02 60 02 +R 00 00 00 07 29 03 00 01 +T 05 15 +R 00 00 00 07 +T 05 15 80 12 +R 00 00 00 07 +T 05 17 +R 00 00 00 07 +T 05 17 E5 00 03 70 04 74 01 80 01 +R 00 00 00 07 29 03 00 01 +T 05 1F +R 00 00 00 07 +T 05 1F E4 +R 00 00 00 07 +T 05 20 +R 00 00 00 07 +T 05 20 FB 90 00 0C EA F0 EB 70 21 +R 00 00 00 07 00 04 00 05 +T 05 29 +R 00 00 00 07 +T 05 29 +R 00 00 00 07 +T 05 29 75 00 04 00 C0 02 12 00 93 D0 02 20 00 02 +R 00 00 00 07 29 03 00 01 00 09 00 07 29 0E 00 04 +T 05 35 0B D0 F0 E5 00 04 C4 42 F0 C0 F0 80 04 +R 00 00 00 07 29 06 00 01 +T 05 41 +R 00 00 00 07 +T 05 41 E5 00 04 C0 E0 +R 00 00 00 07 29 03 00 01 +T 05 45 +R 00 00 00 07 +T 05 45 0A B2 00 02 80 BB +R 00 00 00 07 29 04 00 04 +T 05 4A +R 00 00 00 07 +T 05 4A 90 00 0B E0 FB BB 00 06 +R 00 00 00 07 00 03 00 05 +T 05 52 +R 00 00 00 07 +T 05 52 +R 00 00 00 07 +T 05 52 90 00 0B 74 01 F0 +R 00 00 00 07 00 03 00 05 +T 05 58 +R 00 00 00 07 +T 05 58 20 00 04 21 +R 00 00 00 07 29 03 00 04 +T 05 5B +R 00 00 00 07 +T 05 5B 0A 90 00 0B E0 FB +R 00 00 00 07 00 04 00 05 +T 05 61 +R 00 00 00 07 +T 05 61 C3 EA 9B E4 33 FA 90 00 0B EB F0 EA 60 0D +R 00 00 00 07 00 09 00 05 +T 05 6F +R 00 00 00 07 +T 05 6F C0 03 75 82 20 12 00 00 D0 03 1B 80 E5 +R 00 00 00 07 00 08 00 07 +T 05 7C +R 00 00 00 07 +T 05 7C 30 00 07 13 +R 00 00 00 07 29 03 00 04 +T 05 7F +R 00 00 00 07 +T 05 7F 75 82 2D 12 00 00 90 00 0B E0 FA 24 FF 90 +R 00 00 00 07 00 06 00 07 00 09 00 05 +T 05 8D 00 0B F0 80 34 +R 00 00 00 07 00 02 00 05 +T 05 92 +R 00 00 00 07 +T 05 92 90 00 0C E0 FA BA 00 02 80 2A +R 00 00 00 07 00 03 00 05 +T 05 9C +R 00 00 00 07 +T 05 9C 30 00 05 13 +R 00 00 00 07 29 03 00 04 +T 05 9F +R 00 00 00 07 +T 05 9F 75 82 2B 12 00 00 90 00 0B E0 FA 24 FF 90 +R 00 00 00 07 00 06 00 07 00 09 00 05 +T 05 AD 00 0B F0 80 14 +R 00 00 00 07 00 02 00 05 +T 05 B2 +R 00 00 00 07 +T 05 B2 30 00 06 11 +R 00 00 00 07 29 03 00 04 +T 05 B5 +R 00 00 00 07 +T 05 B5 75 82 20 12 00 00 90 00 0B E0 FA 24 FF 90 +R 00 00 00 07 00 06 00 07 00 09 00 05 +T 05 C3 00 0B F0 +R 00 00 00 07 00 02 00 05 +T 05 C6 +R 00 00 00 07 +T 05 C6 90 00 0C E0 FA 90 00 0B E0 FB +R 00 00 00 07 00 03 00 05 00 08 00 05 +T 05 D0 +R 00 00 00 07 +T 05 D0 8B 04 1B C3 EA 9C 50 18 +R 00 00 00 07 +T 05 D8 +R 00 00 00 07 +T 05 D8 30 00 04 04 +R 00 00 00 07 29 03 00 04 +T 05 DB +R 00 00 00 07 +T 05 DB 7C 30 80 02 +R 00 00 00 07 +T 05 DF +R 00 00 00 07 +T 05 DF 7C 20 +R 00 00 00 07 +T 05 E1 +R 00 00 00 07 +T 05 E1 C0 02 C0 03 8C 82 12 00 00 D0 03 D0 02 80 +R 00 00 00 07 00 09 00 07 +T 05 EF E0 +R 00 00 00 07 +T 05 F0 +R 00 00 00 07 +T 05 F0 +R 00 00 00 07 +T 05 F0 8A 03 1A EB 70 03 02 01 04 +R 00 00 00 07 00 09 00 07 +T 05 F9 +R 00 00 00 07 +T 05 F9 B2 00 02 20 00 02 0A D0 E0 00 C0 E0 C4 54 +R 00 00 00 07 29 03 00 04 29 06 00 04 +T 06 05 0F 80 04 +R 00 00 00 07 +T 06 08 +R 00 00 00 07 +T 06 08 D0 E0 54 0F +R 00 00 00 07 +T 06 0C +R 00 00 00 07 +T 06 0C F5 00 04 C0 02 85 00 04 82 12 00 3A D0 02 +R 00 00 00 07 29 03 00 01 29 08 00 01 00 0C 00 07 +T 06 18 80 D6 +R 00 00 00 07 +T 06 1A +R 00 00 00 07 +T 06 1A 85 00 05 82 12 00 00 02 01 04 +R 00 00 00 07 29 03 00 01 00 07 00 07 00 0A 00 07 +T 06 23 +R 00 00 00 07 +T 06 23 30 00 00 06 +R 00 00 00 07 29 03 00 04 +T 06 26 +R 00 00 00 07 +T 06 26 75 82 00 12 00 00 +R 00 00 00 07 00 06 00 07 +T 06 2C +R 00 00 00 07 +T 06 2C 22 +R 00 00 00 07 +T 06 2D +R 00 00 00 07 +T 06 2D C0 F0 C0 83 C0 82 90 00 0F D0 E0 F0 D0 E0 +R 00 00 00 07 00 09 00 05 +T 06 3B A3 F0 D0 E0 A3 F0 90 00 0F E0 FA A3 E0 FB +R 00 00 00 07 00 09 00 05 +T 06 49 A3 E0 FC 90 00 0E E0 FD 90 00 04 EA F0 A3 +R 00 00 00 07 00 06 00 05 00 0B 00 05 +T 06 57 EB F0 A3 EC F0 90 00 07 ED F0 90 00 00 75 +R 00 00 00 07 00 08 00 05 +T 06 65 F0 00 12 00 CF +R 00 00 00 07 00 05 00 07 +T 06 6A +R 00 00 00 07 +T 06 6A 22 +R 00 00 00 07 +T 06 6B +R 00 00 00 07 +T 06 6B 49 58 43 50 2D 00 +R 00 00 00 07 diff --git a/device/lib/libfloat.lib b/device/lib/libfloat.lib new file mode 100644 index 00000000..2d28e3f2 --- /dev/null +++ b/device/lib/libfloat.lib @@ -0,0 +1,20 @@ +_fsadd +_fsdiv +_fseq +_fsgt +_fslt +_fsmul +_fsneq +_fssub +_char2fs +_int2fs +_long2fs +_uchar2fs +_uint2fs +_ulong2fs +_fs2char +_fs2int +_fs2long +_fs2uchar +_fs2uint +_fs2ulong diff --git a/device/lib/libint.lib b/device/lib/libint.lib new file mode 100644 index 00000000..adc8e636 --- /dev/null +++ b/device/lib/libint.lib @@ -0,0 +1,6 @@ +_divsint +_divuint +_modsint +_moduint +_mulsint +_muluint diff --git a/device/lib/liblong.lib b/device/lib/liblong.lib new file mode 100644 index 00000000..64fb8892 --- /dev/null +++ b/device/lib/liblong.lib @@ -0,0 +1,6 @@ +_divslong.rel +_divulong.rel +_modslong.rel +_modulong.rel +_mululong.rel +_muslong.rel diff --git a/device/lib/libsdcc.lib b/device/lib/libsdcc.lib new file mode 100644 index 00000000..42aa85d9 --- /dev/null +++ b/device/lib/libsdcc.lib @@ -0,0 +1,42 @@ +_iscntrl +_isdigit +_isgraph +_islower +_isprint +_ispunct +_isspace +_isupper +_isxdigit +_strchr +_strcmp +_strcpy +_strcspn +_strlen +_strcat +_strncat +_strncmp +_strncpy +_strpbrk +_strrchr +_strspn +_strstr +_strtok +_memcmp +_memcpy +_memset +_gptrget +_gptrput +_decdptr +_bp +_spx +_atoi +_atol +malloc +serial +_autobaud +_startup +_ser +printfl +printf_large +vprintf +assert diff --git a/device/lib/malloc.c b/device/lib/malloc.c new file mode 100644 index 00000000..214c7b92 --- /dev/null +++ b/device/lib/malloc.c @@ -0,0 +1,120 @@ + + + //-------------------------------------------------------------------- + //Written by Dmitry S. Obukhov, 1997 + //dso@usa.net + //-------------------------------------------------------------------- + //Modified for SDCC by Sandeep Dutta, 1999 + //sandeep.dutta@usa.net + //-------------------------------------------------------------------- + //malloc and free functions implementation for embedded system + //Non-ANSI keywords are C51 specific. + // xdata - variable in external memory (just RAM) + //-------------------------------------------------------------------- + + #define MEMHEADER struct MAH// Memory Allocation Header + + MEMHEADER + { + MEMHEADER _xdata * next; + MEMHEADER _xdata * prev; + unsigned int len; + unsigned char mem[1]; + }; + + #define HEADER_SIZE (sizeof(MEMHEADER)-1) + #define NULL (void _xdata * ) 0 + + + //Static here means: can be accessed from this module only + static MEMHEADER _xdata * FIRST_MEMORY_HEADER_PTR; + void init_dynamic_memory(MEMHEADER _xdata * array, unsigned int size) + { + + //This function MUST be called after the RESET. + //Parameters: array - pointer to memory allocated by the linker + // size - size of this memory pool + //Example: + // #define DYNAMIC_MEMORY_SIZE 0x2000 + // ..... + // unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE]; + // unsigned char xdata * current_buffer; + // ..... + // void main(void) + // { + // ... + // init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE); + // //Now it's possible to use malloc. + // ... + // current_buffer = malloc(0x100); + // + // + + if ( !array ) //Reserved memory starts on 0x0000 but it's NULL... + { //So, we lost one byte! + array = (MEMHEADER _xdata * )((char _xdata * ) array + 1) ; + size --; + } + FIRST_MEMORY_HEADER_PTR = array; + //Reserve a mem for last header + array->next = (MEMHEADER _xdata * )(((char _xdata * ) array) + size - HEADER_SIZE); + array->next->next = NULL; //And mark it as last + array->prev = NULL; //and mark first as first + array->len = 0; //Empty and ready. + } + + void _xdata * malloc (unsigned int size) + { + register MEMHEADER _xdata * current_header; + register MEMHEADER _xdata * new_header; + + if (size>(0xFFFF-HEADER_SIZE)) return NULL; //To prevent overflow in next line + size += HEADER_SIZE; //We need a memory for header too + current_header = FIRST_MEMORY_HEADER_PTR; + while (1) + { + + // current + // | len next + // v v v + //....*****.........******.... + // ^^^^^^^^^ + // spare + + if ((((unsigned int)current_header->next) - + ((unsigned int)current_header) - + current_header->len) >= size) break; //if spare is more than need + current_header = current_header->next; //else try next + if (!current_header->next) return NULL; //if end_of_list reached + } + if (!current_header->len) + { //This code works only for first_header in the list and only + current_header->len = size; //for first allocation + return (current_header->mem); + } //else create new header at the begin of spare + new_header = (MEMHEADER _xdata * )((char _xdata *)current_header + current_header->len); + new_header->next = current_header->next; //and plug it into the chain + new_header->prev = current_header; + current_header->next = new_header; + if (new_header->next) new_header->next->prev = new_header; + new_header->len = size; //mark as used + return (new_header->mem); + } + + void free (MEMHEADER _xdata * p) + { + register MEMHEADER _xdata * prev_header; + if ( p ) //For allocated pointers only! + { + p = (MEMHEADER _xdata * )((char _xdata *) p - HEADER_SIZE); //to start of header + if ( p->prev ) // For the regular header + { + prev_header = p->prev; + prev_header->next = p->next; + if (p->next) p->next->prev = prev_header; + } + else p->len = 0; //For the first header + } + } + //END OF MODULE + diff --git a/device/lib/malloc.lst b/device/lib/malloc.lst new file mode 100644 index 00000000..df8be917 --- /dev/null +++ b/device/lib/malloc.lst @@ -0,0 +1,593 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module malloc + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _free + 11 .globl _malloc + 12 .globl _init_dynamic_memory + 13 .globl _init_dynamic_memory_PARM_2 + 14 ;-------------------------------------------------------- + 15 ; special function registers + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; special function bits + 19 ;-------------------------------------------------------- + 20 ;-------------------------------------------------------- + 21 ; internal ram data + 22 ;-------------------------------------------------------- + 23 .area DSEG (DATA) + 0000 24 _malloc_sloc0_1_0: + 0000 25 .ds 0x0002 + 0002 26 _malloc_sloc1_1_0: + 0002 27 .ds 0x0002 + 28 ;-------------------------------------------------------- + 29 ; overlayable items in internal ram + 30 ;-------------------------------------------------------- + 31 .area OSEG (OVR,DATA) + 32 ;-------------------------------------------------------- + 33 ; indirectly addressable internal ram data + 34 ;-------------------------------------------------------- + 35 .area ISEG (DATA) + 36 ;-------------------------------------------------------- + 37 ; bit data + 38 ;-------------------------------------------------------- + 39 .area BSEG (BIT) + 40 ;-------------------------------------------------------- + 41 ; external ram data + 42 ;-------------------------------------------------------- + 43 .area XSEG (XDATA) + 0000 44 Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0==. + 0000 45 _FIRST_MEMORY_HEADER_PTR: + 0000 46 .ds 0x0002 + 0002 47 _init_dynamic_memory_PARM_2: + 0002 48 .ds 0x0002 + 0004 49 _init_dynamic_memory_array_1_1: + 0004 50 .ds 0x0002 + 0006 51 _malloc_size_1_1: + 0006 52 .ds 0x0002 + 0008 53 _malloc_current_header_1_1: + 0008 54 .ds 0x0002 + 000A 55 _free_p_1_1: + 000A 56 .ds 0x0002 + 57 ;-------------------------------------------------------- + 58 ; global & static initialisations + 59 ;-------------------------------------------------------- + 60 .area GSINIT (CODE) + 61 ;-------------------------------------------------------- + 62 ; code + 63 ;-------------------------------------------------------- + 64 .area CSEG (CODE) + 0000 65 G$init_dynamic_memory$0$0 ==. + 66 ; malloc.c 31 + 67 ; ----------------------------------------- + 68 ; function init_dynamic_memory + 69 ; ----------------------------------------- + 0000 70 _init_dynamic_memory: + 0002 71 ar2 = 0x02 + 0003 72 ar3 = 0x03 + 0004 73 ar4 = 0x04 + 0005 74 ar5 = 0x05 + 0006 75 ar6 = 0x06 + 0007 76 ar7 = 0x07 + 0000 77 ar0 = 0x00 + 0001 78 ar1 = 0x01 + 79 ; malloc.c 63 + 0000 C0 83 80 push dph + 0002 C0 82 81 push dpl + 0004 90s00r04 82 mov dptr,#_init_dynamic_memory_array_1_1 + 0007 D0 E0 83 pop acc + 0009 F0 84 movx @dptr,a + 000A D0 E0 85 pop acc + 000C A3 86 inc dptr + 000D F0 87 movx @dptr,a + 88 ; malloc.c 53 + 000E 90s00r04 89 mov dptr,#_init_dynamic_memory_array_1_1 + 0011 E0 90 movx a,@dptr + 0012 FA 91 mov r2,a + 0013 A3 92 inc dptr + 0014 E0 93 movx a,@dptr + 94 ; Peephole 135 removed redundant mov + 0015 FB 95 mov r3,a + 0016 4A 96 orl a,r2 + 97 ; Peephole 109 removed ljmp by inverse jump logic + 0017 70 20 98 jnz 00102$ + 0019 99 00106$: + 100 ; malloc.c 55 + 0019 90s00r04 101 mov dptr,#_init_dynamic_memory_array_1_1 + 001C 74 01 102 mov a,#0x01 + 001E 2A 103 add a,r2 + 001F F0 104 movx @dptr,a + 105 ; Peephole 180 changed mov to clr + 0020 E4 106 clr a + 0021 3B 107 addc a,r3 + 0022 A3 108 inc dptr + 0023 F0 109 movx @dptr,a + 110 ; malloc.c 56 + 0024 90s00r02 111 mov dptr,#_init_dynamic_memory_PARM_2 + 0027 E0 112 movx a,@dptr + 0028 FA 113 mov r2,a + 0029 A3 114 inc dptr + 002A E0 115 movx a,@dptr + 002B FB 116 mov r3,a + 002C 1A 117 dec r2 + 002D BA FF 01 118 cjne r2,#0xff,00107$ + 0030 1B 119 dec r3 + 0031 120 00107$: + 0031 90s00r02 121 mov dptr,#_init_dynamic_memory_PARM_2 + 0034 EA 122 mov a,r2 + 0035 F0 123 movx @dptr,a + 0036 A3 124 inc dptr + 0037 EB 125 mov a,r3 + 0038 F0 126 movx @dptr,a + 0039 127 00102$: + 128 ; malloc.c 58 + 0039 90s00r04 129 mov dptr,#_init_dynamic_memory_array_1_1 + 003C E0 130 movx a,@dptr + 003D FA 131 mov r2,a + 003E A3 132 inc dptr + 003F E0 133 movx a,@dptr + 0040 FB 134 mov r3,a + 0041 90s00r00 135 mov dptr,#_FIRST_MEMORY_HEADER_PTR + 0044 EA 136 mov a,r2 + 0045 F0 137 movx @dptr,a + 0046 A3 138 inc dptr + 0047 EB 139 mov a,r3 + 0048 F0 140 movx @dptr,a + 141 ; malloc.c 60 + 0049 90s00r02 142 mov dptr,#_init_dynamic_memory_PARM_2 + 004C E0 143 movx a,@dptr + 004D FC 144 mov r4,a + 004E A3 145 inc dptr + 004F E0 146 movx a,@dptr + 0050 FD 147 mov r5,a + 0051 EC 148 mov a,r4 + 0052 2A 149 add a,r2 + 0053 FC 150 mov r4,a + 0054 ED 151 mov a,r5 + 0055 3B 152 addc a,r3 + 0056 FD 153 mov r5,a + 0057 EC 154 mov a,r4 + 0058 24 FA 155 add a,#0xfa + 005A FC 156 mov r4,a + 005B ED 157 mov a,r5 + 005C 34 FF 158 addc a,#0xff + 005E FD 159 mov r5,a + 005F 8A 82 160 mov dpl,r2 + 0061 8B 83 161 mov dph,r3 + 0063 EC 162 mov a,r4 + 0064 F0 163 movx @dptr,a + 0065 A3 164 inc dptr + 0066 ED 165 mov a,r5 + 0067 F0 166 movx @dptr,a + 167 ; malloc.c 61 + 0068 8C 82 168 mov dpl,r4 + 006A 8D 83 169 mov dph,r5 + 170 ; Peephole 101 removed redundant mov + 171 ; Peephole 180 changed mov to clr + 006C E4 172 clr a + 006D F0 173 movx @dptr,a + 006E A3 174 inc dptr + 006F F0 175 movx @dptr,a + 176 ; malloc.c 62 + 0070 74 02 177 mov a,#0x02 + 0072 2A 178 add a,r2 + 0073 F5 82 179 mov dpl,a + 180 ; Peephole 180 changed mov to clr + 0075 E4 181 clr a + 0076 3B 182 addc a,r3 + 0077 F5 83 183 mov dph,a + 184 ; Peephole 101 removed redundant mov + 185 ; Peephole 180 changed mov to clr + 0079 E4 186 clr a + 007A F0 187 movx @dptr,a + 007B A3 188 inc dptr + 007C F0 189 movx @dptr,a + 190 ; malloc.c 63 + 007D 74 04 191 mov a,#0x04 + 007F 2A 192 add a,r2 + 0080 F5 82 193 mov dpl,a + 194 ; Peephole 180 changed mov to clr + 0082 E4 195 clr a + 0083 3B 196 addc a,r3 + 0084 F5 83 197 mov dph,a + 198 ; Peephole 101 removed redundant mov + 199 ; Peephole 180 changed mov to clr + 0086 E4 200 clr a + 0087 F0 201 movx @dptr,a + 0088 A3 202 inc dptr + 0089 F0 203 movx @dptr,a + 008A 204 00103$: + 008A 205 C$malloc.c$64$1$1 ==. + 008A 206 XG$init_dynamic_memory$0$0 ==. + 008A 22 207 ret + 008B 208 G$malloc$0$0 ==. + 209 ; malloc.c 66 + 210 ; ----------------------------------------- + 211 ; function malloc + 212 ; ----------------------------------------- + 008B 213 _malloc: + 214 ; malloc.c 0 + 008B C0 83 215 push dph + 008D C0 82 216 push dpl + 008F 90s00r06 217 mov dptr,#_malloc_size_1_1 + 0092 D0 E0 218 pop acc + 0094 F0 219 movx @dptr,a + 0095 D0 E0 220 pop acc + 0097 A3 221 inc dptr + 0098 F0 222 movx @dptr,a + 223 ; malloc.c 71 + 0099 90s00r06 224 mov dptr,#_malloc_size_1_1 + 009C E0 225 movx a,@dptr + 009D FA 226 mov r2,a + 009E A3 227 inc dptr + 009F E0 228 movx a,@dptr + 00A0 FB 229 mov r3,a + 00A1 8A 04 230 mov ar4,r2 + 00A3 8B 05 231 mov ar5,r3 + 00A5 7E 00 232 mov r6,#0x00 + 00A7 7F 00 233 mov r7,#0x00 + 00A9 C3 234 clr c + 00AA 74 F9 235 mov a,#0xf9 + 00AC 9C 236 subb a,r4 + 00AD 74 FF 237 mov a,#0xff + 00AF 9D 238 subb a,r5 + 239 ; Peephole 180 changed mov to clr + 00B0 E4 240 clr a + 00B1 9E 241 subb a,r6 + 242 ; Peephole 180 changed mov to clr + 00B2 E4 243 clr a + 00B3 9F 244 subb a,r7 + 245 ; Peephole 108 removed ljmp by inverse jump logic + 00B4 50 06 246 jnc 00102$ + 00B6 247 00122$: + 248 ; Peephole 181 used 16 bit load of dptr + 00B6 90 00 00 249 mov dptr,#0x0000 + 00B9 02s01rC3 250 ljmp 00114$ + 00BC 251 00102$: + 252 ; malloc.c 72 + 00BC 74 06 253 mov a,#0x06 + 00BE 2A 254 add a,r2 + 00BF FA 255 mov r2,a + 256 ; Peephole 180 changed mov to clr + 00C0 E4 257 clr a + 00C1 3B 258 addc a,r3 + 00C2 FB 259 mov r3,a + 00C3 90s00r06 260 mov dptr,#_malloc_size_1_1 + 00C6 EA 261 mov a,r2 + 00C7 F0 262 movx @dptr,a + 00C8 A3 263 inc dptr + 00C9 EB 264 mov a,r3 + 00CA F0 265 movx @dptr,a + 266 ; malloc.c 73 + 00CB 90s00r00 267 mov dptr,#_FIRST_MEMORY_HEADER_PTR + 00CE E0 268 movx a,@dptr + 00CF FC 269 mov r4,a + 00D0 A3 270 inc dptr + 00D1 E0 271 movx a,@dptr + 00D2 FD 272 mov r5,a + 00D3 90s00r08 273 mov dptr,#_malloc_current_header_1_1 + 00D6 EC 274 mov a,r4 + 00D7 F0 275 movx @dptr,a + 00D8 A3 276 inc dptr + 00D9 ED 277 mov a,r5 + 00DA F0 278 movx @dptr,a + 279 ; malloc.c 74 + 00DB 280 00108$: + 281 ; malloc.c 84 + 00DB 90s00r08 282 mov dptr,#_malloc_current_header_1_1 + 00DE E0 283 movx a,@dptr + 00DF FC 284 mov r4,a + 00E0 A3 285 inc dptr + 00E1 E0 286 movx a,@dptr + 00E2 FD 287 mov r5,a + 00E3 8C 82 288 mov dpl,r4 + 00E5 8D 83 289 mov dph,r5 + 00E7 E0 290 movx a,@dptr + 00E8 FE 291 mov r6,a + 00E9 A3 292 inc dptr + 00EA E0 293 movx a,@dptr + 00EB FF 294 mov r7,a + 00EC 8E 00 295 mov ar0,r6 + 00EE 8F 01 296 mov ar1,r7 + 297 ; malloc.c 85 + 00F0 C0 06 298 push ar6 + 00F2 C0 07 299 push ar7 + 00F4 8C 06 300 mov ar6,r4 + 00F6 8D 07 301 mov ar7,r5 + 00F8 C3 302 clr c + 00F9 E8 303 mov a,r0 + 00FA 9E 304 subb a,r6 + 00FB F8 305 mov r0,a + 00FC E9 306 mov a,r1 + 00FD 9F 307 subb a,r7 + 00FE F9 308 mov r1,a + 309 ; malloc.c 86 + 00FF 74 04 310 mov a,#0x04 + 0101 2C 311 add a,r4 + 0102 F5*00 312 mov _malloc_sloc0_1_0,a + 313 ; Peephole 180 changed mov to clr + 0104 E4 314 clr a + 0105 3D 315 addc a,r5 + 0106 F5*01 316 mov (_malloc_sloc0_1_0 + 1),a + 0108 85*00 82 317 mov dpl,_malloc_sloc0_1_0 + 010B 85*01 83 318 mov dph,(_malloc_sloc0_1_0 + 1) + 010E E0 319 movx a,@dptr + 010F F5*02 320 mov _malloc_sloc1_1_0,a + 0111 A3 321 inc dptr + 0112 E0 322 movx a,@dptr + 0113 F5*03 323 mov (_malloc_sloc1_1_0 + 1),a + 0115 C3 324 clr c + 0116 E8 325 mov a,r0 + 0117 95*02 326 subb a,_malloc_sloc1_1_0 + 0119 F8 327 mov r0,a + 011A E9 328 mov a,r1 + 011B 95*03 329 subb a,(_malloc_sloc1_1_0 + 1) + 011D F9 330 mov r1,a + 011E C3 331 clr c + 011F E8 332 mov a,r0 + 0120 9A 333 subb a,r2 + 0121 E9 334 mov a,r1 + 0122 9B 335 subb a,r3 + 0123 E4 336 clr a + 0124 33 337 rlc a + 0125 D0 07 338 pop ar7 + 0127 D0 06 339 pop ar6 + 340 ; Peephole 110 removed ljmp by inverse jump logic + 0129 60 1D 341 jz 00109$ + 012B 342 00123$: + 343 ; malloc.c 87 + 012B 90s00r08 344 mov dptr,#_malloc_current_header_1_1 + 012E EE 345 mov a,r6 + 012F F0 346 movx @dptr,a + 0130 A3 347 inc dptr + 0131 EF 348 mov a,r7 + 0132 F0 349 movx @dptr,a + 350 ; malloc.c 88 + 0133 8E 82 351 mov dpl,r6 + 0135 8F 83 352 mov dph,r7 + 0137 E0 353 movx a,@dptr + 0138 F8 354 mov r0,a + 0139 A3 355 inc dptr + 013A E0 356 movx a,@dptr + 357 ; Peephole 135 removed redundant mov + 013B F9 358 mov r1,a + 013C 48 359 orl a,r0 + 013D 60 03 360 jz 00124$ + 013F 02s00rDB 361 ljmp 00108$ + 0142 362 00124$: + 363 ; Peephole 181 used 16 bit load of dptr + 0142 90 00 00 364 mov dptr,#0x0000 + 0145 02s01rC3 365 ljmp 00114$ + 0148 366 00109$: + 367 ; malloc.c 90 + 0148 E5*02 368 mov a,_malloc_sloc1_1_0 + 014A 45*03 369 orl a,(_malloc_sloc1_1_0 + 1) + 370 ; Peephole 109 removed ljmp by inverse jump logic + 014C 70 19 371 jnz 00111$ + 014E 372 00125$: + 373 ; malloc.c 92 + 014E 85*00 82 374 mov dpl,_malloc_sloc0_1_0 + 0151 85*01 83 375 mov dph,(_malloc_sloc0_1_0 + 1) + 0154 EA 376 mov a,r2 + 0155 F0 377 movx @dptr,a + 0156 A3 378 inc dptr + 0157 EB 379 mov a,r3 + 0158 F0 380 movx @dptr,a + 381 ; malloc.c 93 + 0159 74 06 382 mov a,#0x06 + 015B 2C 383 add a,r4 + 015C F8 384 mov r0,a + 385 ; Peephole 180 changed mov to clr + 015D E4 386 clr a + 015E 3D 387 addc a,r5 + 015F F9 388 mov r1,a + 0160 88 82 389 mov dpl,r0 + 0162 89 83 390 mov dph,r1 + 0164 02s01rC3 391 ljmp 00114$ + 0167 392 00111$: + 393 ; malloc.c 95 + 0167 E5*02 394 mov a,_malloc_sloc1_1_0 + 0169 2C 395 add a,r4 + 016A F8 396 mov r0,a + 016B E5*03 397 mov a,(_malloc_sloc1_1_0 + 1) + 016D 3D 398 addc a,r5 + 016E F9 399 mov r1,a + 400 ; malloc.c 96 + 016F 88 82 401 mov dpl,r0 + 0171 89 83 402 mov dph,r1 + 0173 EE 403 mov a,r6 + 0174 F0 404 movx @dptr,a + 0175 A3 405 inc dptr + 0176 EF 406 mov a,r7 + 0177 F0 407 movx @dptr,a + 408 ; malloc.c 97 + 0178 74 02 409 mov a,#0x02 + 017A 28 410 add a,r0 + 017B F5 82 411 mov dpl,a + 412 ; Peephole 180 changed mov to clr + 017D E4 413 clr a + 017E 39 414 addc a,r1 + 017F F5 83 415 mov dph,a + 0181 EC 416 mov a,r4 + 0182 F0 417 movx @dptr,a + 0183 A3 418 inc dptr + 0184 ED 419 mov a,r5 + 0185 F0 420 movx @dptr,a + 421 ; malloc.c 98 + 0186 8C 82 422 mov dpl,r4 + 0188 8D 83 423 mov dph,r5 + 018A E8 424 mov a,r0 + 018B F0 425 movx @dptr,a + 018C A3 426 inc dptr + 018D E9 427 mov a,r1 + 018E F0 428 movx @dptr,a + 429 ; malloc.c 99 + 018F EE 430 mov a,r6 + 0190 4F 431 orl a,r7 + 432 ; Peephole 110 removed ljmp by inverse jump logic + 0191 60 17 433 jz 00113$ + 0193 434 00126$: + 0193 88 82 435 mov dpl,r0 + 0195 89 83 436 mov dph,r1 + 0197 E0 437 movx a,@dptr + 0198 FC 438 mov r4,a + 0199 A3 439 inc dptr + 019A E0 440 movx a,@dptr + 019B FD 441 mov r5,a + 019C 74 02 442 mov a,#0x02 + 019E 2C 443 add a,r4 + 019F F5 82 444 mov dpl,a + 445 ; Peephole 180 changed mov to clr + 01A1 E4 446 clr a + 01A2 3D 447 addc a,r5 + 01A3 F5 83 448 mov dph,a + 01A5 E8 449 mov a,r0 + 01A6 F0 450 movx @dptr,a + 01A7 A3 451 inc dptr + 01A8 E9 452 mov a,r1 + 01A9 F0 453 movx @dptr,a + 01AA 454 00113$: + 455 ; malloc.c 100 + 01AA 74 04 456 mov a,#0x04 + 01AC 28 457 add a,r0 + 01AD F5 82 458 mov dpl,a + 459 ; Peephole 180 changed mov to clr + 01AF E4 460 clr a + 01B0 39 461 addc a,r1 + 01B1 F5 83 462 mov dph,a + 01B3 EA 463 mov a,r2 + 01B4 F0 464 movx @dptr,a + 01B5 A3 465 inc dptr + 01B6 EB 466 mov a,r3 + 01B7 F0 467 movx @dptr,a + 468 ; malloc.c 101 + 01B8 74 06 469 mov a,#0x06 + 01BA 28 470 add a,r0 + 01BB F8 471 mov r0,a + 472 ; Peephole 180 changed mov to clr + 01BC E4 473 clr a + 01BD 39 474 addc a,r1 + 01BE F9 475 mov r1,a + 01BF 88 82 476 mov dpl,r0 + 01C1 89 83 477 mov dph,r1 + 01C3 478 00114$: + 01C3 479 C$malloc.c$102$1$1 ==. + 01C3 480 XG$malloc$0$0 ==. + 01C3 22 481 ret + 01C4 482 G$free$0$0 ==. + 483 ; malloc.c 104 + 484 ; ----------------------------------------- + 485 ; function free + 486 ; ----------------------------------------- + 01C4 487 _free: + 488 ; malloc.c 0 + 01C4 C0 83 489 push dph + 01C6 C0 82 490 push dpl + 01C8 90s00r0A 491 mov dptr,#_free_p_1_1 + 01CB D0 E0 492 pop acc + 01CD F0 493 movx @dptr,a + 01CE D0 E0 494 pop acc + 01D0 A3 495 inc dptr + 01D1 F0 496 movx @dptr,a + 497 ; malloc.c 107 + 01D2 90s00r0A 498 mov dptr,#_free_p_1_1 + 01D5 E0 499 movx a,@dptr + 01D6 FA 500 mov r2,a + 01D7 A3 501 inc dptr + 01D8 E0 502 movx a,@dptr + 503 ; Peephole 135 removed redundant mov + 01D9 FB 504 mov r3,a + 01DA 4A 505 orl a,r2 + 01DB 70 03 506 jnz 00113$ + 01DD 02s02r35 507 ljmp 00108$ + 01E0 508 00113$: + 509 ; malloc.c 109 + 01E0 EA 510 mov a,r2 + 01E1 24 FA 511 add a,#0xfa + 01E3 FC 512 mov r4,a + 01E4 EB 513 mov a,r3 + 01E5 34 FF 514 addc a,#0xff + 01E7 FD 515 mov r5,a + 01E8 90s00r0A 516 mov dptr,#_free_p_1_1 + 01EB EC 517 mov a,r4 + 01EC F0 518 movx @dptr,a + 01ED A3 519 inc dptr + 01EE ED 520 mov a,r5 + 01EF F0 521 movx @dptr,a + 522 ; malloc.c 110 + 01F0 74 02 523 mov a,#0x02 + 01F2 2C 524 add a,r4 + 01F3 F5 82 525 mov dpl,a + 526 ; Peephole 180 changed mov to clr + 01F5 E4 527 clr a + 01F6 3D 528 addc a,r5 + 01F7 F5 83 529 mov dph,a + 01F9 E0 530 movx a,@dptr + 01FA FE 531 mov r6,a + 01FB A3 532 inc dptr + 01FC E0 533 movx a,@dptr + 534 ; Peephole 135 removed redundant mov + 01FD FF 535 mov r7,a + 01FE 4E 536 orl a,r6 + 537 ; Peephole 110 removed ljmp by inverse jump logic + 01FF 60 26 538 jz 00104$ + 0201 539 00114$: + 540 ; malloc.c 113 + 0201 8C 82 541 mov dpl,r4 + 0203 8D 83 542 mov dph,r5 + 0205 E0 543 movx a,@dptr + 0206 FC 544 mov r4,a + 0207 A3 545 inc dptr + 0208 E0 546 movx a,@dptr + 0209 FD 547 mov r5,a + 020A 8E 82 548 mov dpl,r6 + 020C 8F 83 549 mov dph,r7 + 020E EC 550 mov a,r4 + 020F F0 551 movx @dptr,a + 0210 A3 552 inc dptr + 0211 ED 553 mov a,r5 + 0212 F0 554 movx @dptr,a + 555 ; malloc.c 114 + 0213 EC 556 mov a,r4 + 0214 4D 557 orl a,r5 + 558 ; Peephole 110 removed ljmp by inverse jump logic + 0215 60 1E 559 jz 00108$ + 0217 560 00115$: + 0217 74 02 561 mov a,#0x02 + 0219 2C 562 add a,r4 + 021A F5 82 563 mov dpl,a + 564 ; Peephole 180 changed mov to clr + 021C E4 565 clr a + 021D 3D 566 addc a,r5 + 021E F5 83 567 mov dph,a + 0220 EE 568 mov a,r6 + 0221 F0 569 movx @dptr,a + 0222 A3 570 inc dptr + 0223 EF 571 mov a,r7 + 0224 F0 572 movx @dptr,a + 573 ; Peephole 132 changed ljmp to sjmp + 0225 80 0E 574 sjmp 00108$ + 0227 575 00104$: + 576 ; malloc.c 116 + 0227 74 FE 577 mov a,#0xfe + 0229 2A 578 add a,r2 + 022A F5 82 579 mov dpl,a + 022C 74 FF 580 mov a,#0xff + 022E 3B 581 addc a,r3 + 022F F5 83 582 mov dph,a + 583 ; Peephole 101 removed redundant mov + 584 ; Peephole 180 changed mov to clr + 0231 E4 585 clr a + 0232 F0 586 movx @dptr,a + 0233 A3 587 inc dptr + 0234 F0 588 movx @dptr,a + 0235 589 00108$: + 0235 590 C$malloc.c$118$2$1 ==. + 0235 591 XG$free$0$0 ==. + 0235 22 592 ret + 593 .area CSEG (CODE) diff --git a/device/lib/malloc.sym b/device/lib/malloc.sym new file mode 100644 index 00000000..169cf40e --- /dev/null +++ b/device/lib/malloc.sym @@ -0,0 +1,786 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$malloc$101 0019 GR + 7 A$malloc$102 001C GR + 7 A$malloc$103 001E GR + 7 A$malloc$104 001F GR + 7 A$malloc$106 0020 GR + 7 A$malloc$107 0021 GR + 7 A$malloc$108 0022 GR + 7 A$malloc$109 0023 GR + 7 A$malloc$111 0024 GR + 7 A$malloc$112 0027 GR + 7 A$malloc$113 0028 GR + 7 A$malloc$114 0029 GR + 7 A$malloc$115 002A GR + 7 A$malloc$116 002B GR + 7 A$malloc$117 002C GR + 7 A$malloc$118 002D GR + 7 A$malloc$119 0030 GR + 7 A$malloc$121 0031 GR + 7 A$malloc$122 0034 GR + 7 A$malloc$123 0035 GR + 7 A$malloc$124 0036 GR + 7 A$malloc$125 0037 GR + 7 A$malloc$126 0038 GR + 7 A$malloc$129 0039 GR + 7 A$malloc$130 003C GR + 7 A$malloc$131 003D GR + 7 A$malloc$132 003E GR + 7 A$malloc$133 003F GR + 7 A$malloc$134 0040 GR + 7 A$malloc$135 0041 GR + 7 A$malloc$136 0044 GR + 7 A$malloc$137 0045 GR + 7 A$malloc$138 0046 GR + 7 A$malloc$139 0047 GR + 7 A$malloc$140 0048 GR + 7 A$malloc$142 0049 GR + 7 A$malloc$143 004C GR + 7 A$malloc$144 004D GR + 7 A$malloc$145 004E GR + 7 A$malloc$146 004F GR + 7 A$malloc$147 0050 GR + 7 A$malloc$148 0051 GR + 7 A$malloc$149 0052 GR + 7 A$malloc$150 0053 GR + 7 A$malloc$151 0054 GR + 7 A$malloc$152 0055 GR + 7 A$malloc$153 0056 GR + 7 A$malloc$154 0057 GR + 7 A$malloc$155 0058 GR + 7 A$malloc$156 005A GR + 7 A$malloc$157 005B GR + 7 A$malloc$158 005C GR + 7 A$malloc$159 005E GR + 7 A$malloc$160 005F GR + 7 A$malloc$161 0061 GR + 7 A$malloc$162 0063 GR + 7 A$malloc$163 0064 GR + 7 A$malloc$164 0065 GR + 7 A$malloc$165 0066 GR + 7 A$malloc$166 0067 GR + 7 A$malloc$168 0068 GR + 7 A$malloc$169 006A GR + 7 A$malloc$172 006C GR + 7 A$malloc$173 006D GR + 7 A$malloc$174 006E GR + 7 A$malloc$175 006F GR + 7 A$malloc$177 0070 GR + 7 A$malloc$178 0072 GR + 7 A$malloc$179 0073 GR + 7 A$malloc$181 0075 GR + 7 A$malloc$182 0076 GR + 7 A$malloc$183 0077 GR + 7 A$malloc$186 0079 GR + 7 A$malloc$187 007A GR + 7 A$malloc$188 007B GR + 7 A$malloc$189 007C GR + 7 A$malloc$191 007D GR + 7 A$malloc$192 007F GR + 7 A$malloc$193 0080 GR + 7 A$malloc$195 0082 GR + 7 A$malloc$196 0083 GR + 7 A$malloc$197 0084 GR + 7 A$malloc$200 0086 GR + 7 A$malloc$201 0087 GR + 7 A$malloc$202 0088 GR + 7 A$malloc$203 0089 GR + 7 A$malloc$207 008A GR + 7 A$malloc$215 008B GR + 7 A$malloc$216 008D GR + 7 A$malloc$217 008F GR + 7 A$malloc$218 0092 GR + 7 A$malloc$219 0094 GR + 7 A$malloc$220 0095 GR + 7 A$malloc$221 0097 GR + 7 A$malloc$222 0098 GR + 7 A$malloc$224 0099 GR + 7 A$malloc$225 009C GR + 7 A$malloc$226 009D GR + 7 A$malloc$227 009E GR + 7 A$malloc$228 009F GR + 7 A$malloc$229 00A0 GR + 7 A$malloc$230 00A1 GR + 7 A$malloc$231 00A3 GR + 7 A$malloc$232 00A5 GR + 7 A$malloc$233 00A7 GR + 7 A$malloc$234 00A9 GR + 7 A$malloc$235 00AA GR + 7 A$malloc$236 00AC GR + 7 A$malloc$237 00AD GR + 7 A$malloc$238 00AF GR + 7 A$malloc$240 00B0 GR + 7 A$malloc$241 00B1 GR + 7 A$malloc$243 00B2 GR + 7 A$malloc$244 00B3 GR + 7 A$malloc$246 00B4 GR + 7 A$malloc$249 00B6 GR + 7 A$malloc$250 00B9 GR + 7 A$malloc$253 00BC GR + 7 A$malloc$254 00BE GR + 7 A$malloc$255 00BF GR + 7 A$malloc$257 00C0 GR + 7 A$malloc$258 00C1 GR + 7 A$malloc$259 00C2 GR + 7 A$malloc$260 00C3 GR + 7 A$malloc$261 00C6 GR + 7 A$malloc$262 00C7 GR + 7 A$malloc$263 00C8 GR + 7 A$malloc$264 00C9 GR + 7 A$malloc$265 00CA GR + 7 A$malloc$267 00CB GR + 7 A$malloc$268 00CE GR + 7 A$malloc$269 00CF GR + 7 A$malloc$270 00D0 GR + 7 A$malloc$271 00D1 GR + 7 A$malloc$272 00D2 GR + 7 A$malloc$273 00D3 GR + 7 A$malloc$274 00D6 GR + 7 A$malloc$275 00D7 GR + 7 A$malloc$276 00D8 GR + 7 A$malloc$277 00D9 GR + 7 A$malloc$278 00DA GR + 7 A$malloc$282 00DB GR + 7 A$malloc$283 00DE GR + 7 A$malloc$284 00DF GR + 7 A$malloc$285 00E0 GR + 7 A$malloc$286 00E1 GR + 7 A$malloc$287 00E2 GR + 7 A$malloc$288 00E3 GR + 7 A$malloc$289 00E5 GR + 7 A$malloc$290 00E7 GR + 7 A$malloc$291 00E8 GR + 7 A$malloc$292 00E9 GR + 7 A$malloc$293 00EA GR + 7 A$malloc$294 00EB GR + 7 A$malloc$295 00EC GR + 7 A$malloc$296 00EE GR + 7 A$malloc$298 00F0 GR + 7 A$malloc$299 00F2 GR + 7 A$malloc$300 00F4 GR + 7 A$malloc$301 00F6 GR + 7 A$malloc$302 00F8 GR + 7 A$malloc$303 00F9 GR + 7 A$malloc$304 00FA GR + 7 A$malloc$305 00FB GR + 7 A$malloc$306 00FC GR + 7 A$malloc$307 00FD GR + 7 A$malloc$308 00FE GR + 7 A$malloc$310 00FF GR + 7 A$malloc$311 0101 GR + 7 A$malloc$312 0102 GR + 7 A$malloc$314 0104 GR + 7 A$malloc$315 0105 GR + 7 A$malloc$316 0106 GR + 7 A$malloc$317 0108 GR + 7 A$malloc$318 010B GR + 7 A$malloc$319 010E GR + 7 A$malloc$320 010F GR + 7 A$malloc$321 0111 GR + 7 A$malloc$322 0112 GR + 7 A$malloc$323 0113 GR + 7 A$malloc$324 0115 GR + 7 A$malloc$325 0116 GR + 7 A$malloc$326 0117 GR + 7 A$malloc$327 0119 GR + 7 A$malloc$328 011A GR + 7 A$malloc$329 011B GR + 7 A$malloc$330 011D GR + 7 A$malloc$331 011E GR + 7 A$malloc$332 011F GR + 7 A$malloc$333 0120 GR + 7 A$malloc$334 0121 GR + 7 A$malloc$335 0122 GR + 7 A$malloc$336 0123 GR + 7 A$malloc$337 0124 GR + 7 A$malloc$338 0125 GR + 7 A$malloc$339 0127 GR + 7 A$malloc$341 0129 GR + 7 A$malloc$344 012B GR + 7 A$malloc$345 012E GR + 7 A$malloc$346 012F GR + 7 A$malloc$347 0130 GR + 7 A$malloc$348 0131 GR + 7 A$malloc$349 0132 GR + 7 A$malloc$351 0133 GR + 7 A$malloc$352 0135 GR + 7 A$malloc$353 0137 GR + 7 A$malloc$354 0138 GR + 7 A$malloc$355 0139 GR + 7 A$malloc$356 013A GR + 7 A$malloc$358 013B GR + 7 A$malloc$359 013C GR + 7 A$malloc$360 013D GR + 7 A$malloc$361 013F GR + 7 A$malloc$364 0142 GR + 7 A$malloc$365 0145 GR + 7 A$malloc$368 0148 GR + 7 A$malloc$369 014A GR + 7 A$malloc$371 014C GR + 7 A$malloc$374 014E GR + 7 A$malloc$375 0151 GR + 7 A$malloc$376 0154 GR + 7 A$malloc$377 0155 GR + 7 A$malloc$378 0156 GR + 7 A$malloc$379 0157 GR + 7 A$malloc$380 0158 GR + 7 A$malloc$382 0159 GR + 7 A$malloc$383 015B GR + 7 A$malloc$384 015C GR + 7 A$malloc$386 015D GR + 7 A$malloc$387 015E GR + 7 A$malloc$388 015F GR + 7 A$malloc$389 0160 GR + 7 A$malloc$390 0162 GR + 7 A$malloc$391 0164 GR + 7 A$malloc$394 0167 GR + 7 A$malloc$395 0169 GR + 7 A$malloc$396 016A GR + 7 A$malloc$397 016B GR + 7 A$malloc$398 016D GR + 7 A$malloc$399 016E GR + 7 A$malloc$401 016F GR + 7 A$malloc$402 0171 GR + 7 A$malloc$403 0173 GR + 7 A$malloc$404 0174 GR + 7 A$malloc$405 0175 GR + 7 A$malloc$406 0176 GR + 7 A$malloc$407 0177 GR + 7 A$malloc$409 0178 GR + 7 A$malloc$410 017A GR + 7 A$malloc$411 017B GR + 7 A$malloc$413 017D GR + 7 A$malloc$414 017E GR + 7 A$malloc$415 017F GR + 7 A$malloc$416 0181 GR + 7 A$malloc$417 0182 GR + 7 A$malloc$418 0183 GR + 7 A$malloc$419 0184 GR + 7 A$malloc$420 0185 GR + 7 A$malloc$422 0186 GR + 7 A$malloc$423 0188 GR + 7 A$malloc$424 018A GR + 7 A$malloc$425 018B GR + 7 A$malloc$426 018C GR + 7 A$malloc$427 018D GR + 7 A$malloc$428 018E GR + 7 A$malloc$430 018F GR + 7 A$malloc$431 0190 GR + 7 A$malloc$433 0191 GR + 7 A$malloc$435 0193 GR + 7 A$malloc$436 0195 GR + 7 A$malloc$437 0197 GR + 7 A$malloc$438 0198 GR + 7 A$malloc$439 0199 GR + 7 A$malloc$440 019A GR + 7 A$malloc$441 019B GR + 7 A$malloc$442 019C GR + 7 A$malloc$443 019E GR + 7 A$malloc$444 019F GR + 7 A$malloc$446 01A1 GR + 7 A$malloc$447 01A2 GR + 7 A$malloc$448 01A3 GR + 7 A$malloc$449 01A5 GR + 7 A$malloc$450 01A6 GR + 7 A$malloc$451 01A7 GR + 7 A$malloc$452 01A8 GR + 7 A$malloc$453 01A9 GR + 7 A$malloc$456 01AA GR + 7 A$malloc$457 01AC GR + 7 A$malloc$458 01AD GR + 7 A$malloc$460 01AF GR + 7 A$malloc$461 01B0 GR + 7 A$malloc$462 01B1 GR + 7 A$malloc$463 01B3 GR + 7 A$malloc$464 01B4 GR + 7 A$malloc$465 01B5 GR + 7 A$malloc$466 01B6 GR + 7 A$malloc$467 01B7 GR + 7 A$malloc$469 01B8 GR + 7 A$malloc$470 01BA GR + 7 A$malloc$471 01BB GR + 7 A$malloc$473 01BC GR + 7 A$malloc$474 01BD GR + 7 A$malloc$475 01BE GR + 7 A$malloc$476 01BF GR + 7 A$malloc$477 01C1 GR + 7 A$malloc$481 01C3 GR + 7 A$malloc$489 01C4 GR + 7 A$malloc$490 01C6 GR + 7 A$malloc$491 01C8 GR + 7 A$malloc$492 01CB GR + 7 A$malloc$493 01CD GR + 7 A$malloc$494 01CE GR + 7 A$malloc$495 01D0 GR + 7 A$malloc$496 01D1 GR + 7 A$malloc$498 01D2 GR + 7 A$malloc$499 01D5 GR + 7 A$malloc$500 01D6 GR + 7 A$malloc$501 01D7 GR + 7 A$malloc$502 01D8 GR + 7 A$malloc$504 01D9 GR + 7 A$malloc$505 01DA GR + 7 A$malloc$506 01DB GR + 7 A$malloc$507 01DD GR + 7 A$malloc$510 01E0 GR + 7 A$malloc$511 01E1 GR + 7 A$malloc$512 01E3 GR + 7 A$malloc$513 01E4 GR + 7 A$malloc$514 01E5 GR + 7 A$malloc$515 01E7 GR + 7 A$malloc$516 01E8 GR + 7 A$malloc$517 01EB GR + 7 A$malloc$518 01EC GR + 7 A$malloc$519 01ED GR + 7 A$malloc$520 01EE GR + 7 A$malloc$521 01EF GR + 7 A$malloc$523 01F0 GR + 7 A$malloc$524 01F2 GR + 7 A$malloc$525 01F3 GR + 7 A$malloc$527 01F5 GR + 7 A$malloc$528 01F6 GR + 7 A$malloc$529 01F7 GR + 7 A$malloc$530 01F9 GR + 7 A$malloc$531 01FA GR + 7 A$malloc$532 01FB GR + 7 A$malloc$533 01FC GR + 7 A$malloc$535 01FD GR + 7 A$malloc$536 01FE GR + 7 A$malloc$538 01FF GR + 7 A$malloc$541 0201 GR + 7 A$malloc$542 0203 GR + 7 A$malloc$543 0205 GR + 7 A$malloc$544 0206 GR + 7 A$malloc$545 0207 GR + 7 A$malloc$546 0208 GR + 7 A$malloc$547 0209 GR + 7 A$malloc$548 020A GR + 7 A$malloc$549 020C GR + 7 A$malloc$550 020E GR + 7 A$malloc$551 020F GR + 7 A$malloc$552 0210 GR + 7 A$malloc$553 0211 GR + 7 A$malloc$554 0212 GR + 7 A$malloc$556 0213 GR + 7 A$malloc$557 0214 GR + 7 A$malloc$559 0215 GR + 7 A$malloc$561 0217 GR + 7 A$malloc$562 0219 GR + 7 A$malloc$563 021A GR + 7 A$malloc$565 021C GR + 7 A$malloc$566 021D GR + 7 A$malloc$567 021E GR + 7 A$malloc$568 0220 GR + 7 A$malloc$569 0221 GR + 7 A$malloc$570 0222 GR + 7 A$malloc$571 0223 GR + 7 A$malloc$572 0224 GR + 7 A$malloc$574 0225 GR + 7 A$malloc$577 0227 GR + 7 A$malloc$578 0229 GR + 7 A$malloc$579 022A GR + 7 A$malloc$580 022C GR + 7 A$malloc$581 022E GR + 7 A$malloc$582 022F GR + 7 A$malloc$585 0231 GR + 7 A$malloc$586 0232 GR + 7 A$malloc$587 0233 GR + 7 A$malloc$588 0234 GR + 7 A$malloc$592 0235 GR + 7 A$malloc$80 0000 GR + 7 A$malloc$81 0002 GR + 7 A$malloc$82 0004 GR + 7 A$malloc$83 0007 GR + 7 A$malloc$84 0009 GR + 7 A$malloc$85 000A GR + 7 A$malloc$86 000C GR + 7 A$malloc$87 000D GR + 7 A$malloc$89 000E GR + 7 A$malloc$90 0011 GR + 7 A$malloc$91 0012 GR + 7 A$malloc$92 0013 GR + 7 A$malloc$93 0014 GR + 7 A$malloc$95 0015 GR + 7 A$malloc$96 0016 GR + 7 A$malloc$98 0017 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$malloc.c$102$1$1 = 01C3 GR + 7 C$malloc.c$118$2$1 = 0235 GR + 7 C$malloc.c$64$1$1 = 008A GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 5 Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0 = 0000 GR + 7 G$free$0$0 = 01C4 GR + 7 G$init_dynamic_memory$0$0 = 0000 GR + 7 G$malloc$0$0 = 008B GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$free$0$0 = 0235 GR + 7 XG$init_dynamic_memory$0$0 = 008A GR + 7 XG$malloc$0$0 = 01C3 GR + 5 _FIRST_MEMORY_HEADER_PTR 0000 R + 7 _free 01C4 GR + 5 _free_p_1_1 000A R + 7 _init_dynamic_memory 0000 GR + 5 _init_dynamic_memory_PARM_2 0002 GR + 5 _init_dynamic_memory_array_1_1 0004 R + 7 _malloc 008B GR + 5 _malloc_current_header_1_1 0008 R + 5 _malloc_size_1_1 0006 R + 1 _malloc_sloc0_1_0 0000 R + 1 _malloc_sloc1_1_0 0002 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 4 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size C flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 236 flags 20 diff --git a/device/lib/mcs51/README b/device/lib/mcs51/README new file mode 100644 index 00000000..84adfe2d --- /dev/null +++ b/device/lib/mcs51/README @@ -0,0 +1,4 @@ +sdcc/device/lib/mcs51 +------------------- + +mcs51 specific routines. diff --git a/device/lib/printf_large.c b/device/lib/printf_large.c new file mode 100644 index 00000000..8257d11c --- /dev/null +++ b/device/lib/printf_large.c @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + printf.c - formatted output conversion + + Written By - Martijn van Balen aed@iae.nl (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include + +int printf (const char *format, ...) reentrant +{ + va_list arg; + int done; + + va_start (arg, format); + done = vprintf ((char *)0,format, arg); + va_end (arg); + + return done; +} + +int sprintf (const char *buf, const char *format, ...) reentrant +{ + va_list arg; + int done; + + va_start (arg, format); + done = vsprintf (buf, format, arg); + va_end (arg); + + return done; +} diff --git a/device/lib/printfl.c b/device/lib/printfl.c new file mode 100644 index 00000000..7cf18ea0 --- /dev/null +++ b/device/lib/printfl.c @@ -0,0 +1,214 @@ +/*----------------------------------------------------------------- + printfl.c - source file for reduced version of printf + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +/* following formats are supported :- + format output type argument-type + %d decimal int + %ld decimal long + %hd decimal short/char + %x hexadecimal int + %lx hexadecimal long + %hx hexadecimal short/char + %o octal int + %lo octal long + %ho octal short/char + %c character char/short + %s character _generic pointer +*/ + +#include +#include +extern void putchar(char ); + +static data volatile char ch; +static data char radix ; +static bit long_flag = 0; +static bit string_flag =0; +static bit short_flag = 0; +static bit sign; +static char * data str ; +static data long val; + +static void pvalhex( long val) +{ + volatile char sp = SP; + unsigned long lval = val; + + if (!long_flag) + lval &= 0x0000ffff; + + if (short_flag) + lval &= 0x000000ff; + + while (lval) { + ch = "0123456789ABCDEF"[(unsigned short)lval & 0x0f]; + _asm push _ch _endasm; + lval /= 16; + } + + while (sp != SP) { + _asm pop _ch _endasm; + putchar(ch); + } + +} + +static void pvaloct(long val) +{ + char sp ; + unsigned long lval; + sp = SP; + if (val < 0) { + lval = -val; + sign = 1; + } else { + lval = val; + sign = 0; + } + + if (!long_flag) + lval &= 0x0000ffff; + if (short_flag) + lval &= 0x000000ff; + + while (lval) { + ch = (lval % 8) + '0'; + _asm push _ch _endasm; + lval = lval / 8; + } + + if (sign) { + ch = '-'; + _asm push _ch _endasm; + } + + + while (sp != SP) { + _asm pop _ch _endasm; + putchar(ch); + } +} + +static void pvaldec(long val ) +{ + char sp ; + unsigned long lval; + sp = SP; + if (val < 0) { + lval = -val; + sign = 1; + } else { + lval = val; + sign = 0; + } + + while (lval) { + ch = (lval % 10) + '0'; + _asm push _ch _endasm; + lval = lval / 10; + } + + if (sign) { + ch = '-'; + _asm push _ch _endasm; + } + + + while (sp != SP) { + _asm pop _ch _endasm; + putchar(ch); + } +} + +void printf_small (char * fmt, ... ) reentrant +{ + va_list ap ; + + va_start(ap,fmt); + + for (; *fmt ; fmt++ ) { + if (*fmt == '%') { + long_flag = string_flag = short_flag = 0; + fmt++ ; + switch (*fmt) { + case 'l': + long_flag = 1; + fmt++; + break; + case 'h': + short_flag = 1; + fmt++; + } + + switch (*fmt) { + case 's': + string_flag = 1; + break; + case 'd': + radix = 10; + break; + case 'x': + radix = 16; + break; + case 'c': + radix = 0; + break; + case 'o': + radix = 8; + break; + } + + if (string_flag) { + str = va_arg(ap,char _generic *); + while (*str) putchar(*str++); + continue ; + } + + if (long_flag) + val = va_arg(ap,long); + else + if (short_flag) + val = va_arg(ap,short); + else + val = va_arg(ap,int); + + switch (radix) { + case 10: + pvaldec(val) ; + break; + case 16: + pvalhex (val); + break; + case 0: + putchar((char)val); + break; + case 8: + pvaloct(val) ; + break; + } + + } else + putchar(*fmt); + } +} diff --git a/device/lib/printfl.lst b/device/lib/printfl.lst new file mode 100644 index 00000000..b86d0012 --- /dev/null +++ b/device/lib/printfl.lst @@ -0,0 +1,1386 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:37 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module printfl + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _printf_small + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 0080 14 G$P0$0$0 == 0x0080 + 0080 15 _P0 = 0x0080 + 0090 16 G$P1$0$0 == 0x0090 + 0090 17 _P1 = 0x0090 + 00A0 18 G$P2$0$0 == 0x00a0 + 00A0 19 _P2 = 0x00a0 + 00B0 20 G$P3$0$0 == 0x00b0 + 00B0 21 _P3 = 0x00b0 + 00D0 22 G$PSW$0$0 == 0x00d0 + 00D0 23 _PSW = 0x00d0 + 00E0 24 G$ACC$0$0 == 0x00e0 + 00E0 25 _ACC = 0x00e0 + 00F0 26 G$B$0$0 == 0x00f0 + 00F0 27 _B = 0x00f0 + 0081 28 G$SP$0$0 == 0x0081 + 0081 29 _SP = 0x0081 + 0082 30 G$DPL$0$0 == 0x0082 + 0082 31 _DPL = 0x0082 + 0083 32 G$DPH$0$0 == 0x0083 + 0083 33 _DPH = 0x0083 + 0087 34 G$PCON$0$0 == 0x0087 + 0087 35 _PCON = 0x0087 + 0088 36 G$TCON$0$0 == 0x0088 + 0088 37 _TCON = 0x0088 + 0089 38 G$TMOD$0$0 == 0x0089 + 0089 39 _TMOD = 0x0089 + 008A 40 G$TL0$0$0 == 0x008a + 008A 41 _TL0 = 0x008a + 008B 42 G$TL1$0$0 == 0x008b + 008B 43 _TL1 = 0x008b + 008C 44 G$TH0$0$0 == 0x008c + 008C 45 _TH0 = 0x008c + 008D 46 G$TH1$0$0 == 0x008d + 008D 47 _TH1 = 0x008d + 008E 48 G$AUXR$0$0 == 0x008e + 008E 49 _AUXR = 0x008e + 00A8 50 G$IE$0$0 == 0x00a8 + 00A8 51 _IE = 0x00a8 + 00B8 52 G$IP$0$0 == 0x00b8 + 00B8 53 _IP = 0x00b8 + 0098 54 G$SCON$0$0 == 0x0098 + 0098 55 _SCON = 0x0098 + 0099 56 G$SBUF$0$0 == 0x0099 + 0099 57 _SBUF = 0x0099 + 00C8 58 G$T2CON$0$0 == 0x00c8 + 00C8 59 _T2CON = 0x00c8 + 00CB 60 G$RCAP2H$0$0 == 0x00cb + 00CB 61 _RCAP2H = 0x00cb + 00CA 62 G$RCAP2L$0$0 == 0x00ca + 00CA 63 _RCAP2L = 0x00ca + 64 ;-------------------------------------------------------- + 65 ; special function bits + 66 ;-------------------------------------------------------- + 00D7 67 G$CY$0$0 == 0x00d7 + 00D7 68 _CY = 0x00d7 + 00D6 69 G$AC$0$0 == 0x00d6 + 00D6 70 _AC = 0x00d6 + 00D5 71 G$F0$0$0 == 0x00d5 + 00D5 72 _F0 = 0x00d5 + 00D4 73 G$RS1$0$0 == 0x00d4 + 00D4 74 _RS1 = 0x00d4 + 00D3 75 G$RS0$0$0 == 0x00d3 + 00D3 76 _RS0 = 0x00d3 + 00D2 77 G$OV$0$0 == 0x00d2 + 00D2 78 _OV = 0x00d2 + 00D0 79 G$P$0$0 == 0x00d0 + 00D0 80 _P = 0x00d0 + 008F 81 G$TF1$0$0 == 0x008f + 008F 82 _TF1 = 0x008f + 008E 83 G$TR1$0$0 == 0x008e + 008E 84 _TR1 = 0x008e + 008D 85 G$TF0$0$0 == 0x008d + 008D 86 _TF0 = 0x008d + 008C 87 G$TR0$0$0 == 0x008c + 008C 88 _TR0 = 0x008c + 008B 89 G$IE1$0$0 == 0x008b + 008B 90 _IE1 = 0x008b + 008A 91 G$IT1$0$0 == 0x008a + 008A 92 _IT1 = 0x008a + 0089 93 G$IE0$0$0 == 0x0089 + 0089 94 _IE0 = 0x0089 + 0088 95 G$IT0$0$0 == 0x0088 + 0088 96 _IT0 = 0x0088 + 00AF 97 G$EA$0$0 == 0x00af + 00AF 98 _EA = 0x00af + 00AC 99 G$ES$0$0 == 0x00ac + 00AC 100 _ES = 0x00ac + 00AB 101 G$ET1$0$0 == 0x00ab + 00AB 102 _ET1 = 0x00ab + 00AA 103 G$EX1$0$0 == 0x00aa + 00AA 104 _EX1 = 0x00aa + 00A9 105 G$ET0$0$0 == 0x00a9 + 00A9 106 _ET0 = 0x00a9 + 00A8 107 G$EX0$0$0 == 0x00a8 + 00A8 108 _EX0 = 0x00a8 + 00BC 109 G$PS$0$0 == 0x00bc + 00BC 110 _PS = 0x00bc + 00BB 111 G$PT1$0$0 == 0x00bb + 00BB 112 _PT1 = 0x00bb + 00BA 113 G$PX1$0$0 == 0x00ba + 00BA 114 _PX1 = 0x00ba + 00B9 115 G$PT0$0$0 == 0x00b9 + 00B9 116 _PT0 = 0x00b9 + 00B8 117 G$PX0$0$0 == 0x00b8 + 00B8 118 _PX0 = 0x00b8 + 00B7 119 G$RD$0$0 == 0x00b7 + 00B7 120 _RD = 0x00b7 + 00B6 121 G$WR$0$0 == 0x00b6 + 00B6 122 _WR = 0x00b6 + 00B5 123 G$T1$0$0 == 0x00b5 + 00B5 124 _T1 = 0x00b5 + 00B4 125 G$T0$0$0 == 0x00b4 + 00B4 126 _T0 = 0x00b4 + 00B3 127 G$INT1$0$0 == 0x00b3 + 00B3 128 _INT1 = 0x00b3 + 00B2 129 G$INT0$0$0 == 0x00b2 + 00B2 130 _INT0 = 0x00b2 + 00B1 131 G$TXD$0$0 == 0x00b1 + 00B1 132 _TXD = 0x00b1 + 00B0 133 G$RXD$0$0 == 0x00b0 + 00B0 134 _RXD = 0x00b0 + 0090 135 G$P1_0$0$0 == 0x0090 + 0090 136 _P1_0 = 0x0090 + 0091 137 G$P1_1$0$0 == 0x0091 + 0091 138 _P1_1 = 0x0091 + 0092 139 G$P1_2$0$0 == 0x0092 + 0092 140 _P1_2 = 0x0092 + 0093 141 G$P1_3$0$0 == 0x0093 + 0093 142 _P1_3 = 0x0093 + 0094 143 G$P1_4$0$0 == 0x0094 + 0094 144 _P1_4 = 0x0094 + 0095 145 G$P1_5$0$0 == 0x0095 + 0095 146 _P1_5 = 0x0095 + 0096 147 G$P1_6$0$0 == 0x0096 + 0096 148 _P1_6 = 0x0096 + 0097 149 G$P1_7$0$0 == 0x0097 + 0097 150 _P1_7 = 0x0097 + 009F 151 G$SM0$0$0 == 0x009f + 009F 152 _SM0 = 0x009f + 009E 153 G$SM1$0$0 == 0x009e + 009E 154 _SM1 = 0x009e + 009D 155 G$SM2$0$0 == 0x009d + 009D 156 _SM2 = 0x009d + 009C 157 G$REN$0$0 == 0x009c + 009C 158 _REN = 0x009c + 009B 159 G$TB8$0$0 == 0x009b + 009B 160 _TB8 = 0x009b + 009A 161 G$RB8$0$0 == 0x009a + 009A 162 _RB8 = 0x009a + 0099 163 G$TI$0$0 == 0x0099 + 0099 164 _TI = 0x0099 + 0098 165 G$RI$0$0 == 0x0098 + 0098 166 _RI = 0x0098 + 00C8 167 G$T2CON_0$0$0 == 0x00c8 + 00C8 168 _T2CON_0 = 0x00c8 + 00C9 169 G$T2CON_1$0$0 == 0x00c9 + 00C9 170 _T2CON_1 = 0x00c9 + 00CA 171 G$T2CON_2$0$0 == 0x00ca + 00CA 172 _T2CON_2 = 0x00ca + 00CB 173 G$T2CON_3$0$0 == 0x00cb + 00CB 174 _T2CON_3 = 0x00cb + 00CC 175 G$T2CON_4$0$0 == 0x00cc + 00CC 176 _T2CON_4 = 0x00cc + 00CD 177 G$T2CON_5$0$0 == 0x00cd + 00CD 178 _T2CON_5 = 0x00cd + 00CE 179 G$T2CON_6$0$0 == 0x00ce + 00CE 180 _T2CON_6 = 0x00ce + 00CF 181 G$T2CON_7$0$0 == 0x00cf + 00CF 182 _T2CON_7 = 0x00cf + 183 ;-------------------------------------------------------- + 184 ; internal ram data + 185 ;-------------------------------------------------------- + 186 .area DSEG (DATA) + 0000 187 Fprintfl$ch$0$0==. + 0000 188 _ch: + 0000 189 .ds 0x0001 + 0001 190 Fprintfl$radix$0$0==. + 0001 191 _radix: + 0001 192 .ds 0x0001 + 0002 193 Fprintfl$str$0$0==. + 0002 194 _str: + 0002 195 .ds 0x0003 + 0005 196 Fprintfl$val$0$0==. + 0005 197 _val: + 0005 198 .ds 0x0004 + 0009 199 _pvaloct_sloc0_1_0: + 0009 200 .ds 0x0004 + 000D 201 _printf_small_sloc0_1_0: + 000D 202 .ds 0x0001 + 000E 203 _printf_small_sloc1_1_0: + 000E 204 .ds 0x0003 + 205 ;-------------------------------------------------------- + 206 ; overlayable items in internal ram + 207 ;-------------------------------------------------------- + 208 .area OSEG (OVR,DATA) + 209 ;-------------------------------------------------------- + 210 ; indirectly addressable internal ram data + 211 ;-------------------------------------------------------- + 212 .area ISEG (DATA) + 213 ;-------------------------------------------------------- + 214 ; bit data + 215 ;-------------------------------------------------------- + 216 .area BSEG (BIT) + 0000 217 Fprintfl$long_flag$0$0==. + 0000 218 _long_flag: + 0000 219 .ds 0x0001 + 0001 220 Fprintfl$string_flag$0$0==. + 0001 221 _string_flag: + 0001 222 .ds 0x0001 + 0002 223 Fprintfl$short_flag$0$0==. + 0002 224 _short_flag: + 0002 225 .ds 0x0001 + 0003 226 Fprintfl$sign$0$0==. + 0003 227 _sign: + 0003 228 .ds 0x0001 + 229 ;-------------------------------------------------------- + 230 ; external ram data + 231 ;-------------------------------------------------------- + 232 .area XSEG (XDATA) + 0000 233 _pvalhex_val_1_1: + 0000 234 .ds 0x0004 + 0004 235 _pvalhex_sp_1_1: + 0004 236 .ds 0x0001 + 0005 237 _pvalhex_lval_1_1: + 0005 238 .ds 0x0004 + 0009 239 _pvaloct_val_1_1: + 0009 240 .ds 0x0004 + 000D 241 _pvaloct_lval_1_1: + 000D 242 .ds 0x0004 + 0011 243 _pvaldec_val_1_1: + 0011 244 .ds 0x0004 + 0015 245 _pvaldec_lval_1_1: + 0015 246 .ds 0x0004 + 247 ;-------------------------------------------------------- + 248 ; global & static initialisations + 249 ;-------------------------------------------------------- + 250 .area GSINIT (CODE) + 0000 251 G$printf_small$0$0 ==. + 252 ; printfl.c 215 + 0000 C2*00 253 clr _long_flag + 0002 254 G$printf_small$0$0 ==. + 255 ; printfl.c 215 + 0002 C2*01 256 clr _string_flag + 0004 257 G$printf_small$0$0 ==. + 258 ; printfl.c 215 + 0004 C2*02 259 clr _short_flag + 260 ;-------------------------------------------------------- + 261 ; code + 262 ;-------------------------------------------------------- + 263 .area CSEG (CODE) + 0000 264 Fprintfl$pvalhex$0$0 ==. + 265 ; printfl.c 53 + 266 ; ----------------------------------------- + 267 ; function pvalhex + 268 ; ----------------------------------------- + 0000 269 _pvalhex: + 0002 270 ar2 = 0x02 + 0003 271 ar3 = 0x03 + 0004 272 ar4 = 0x04 + 0005 273 ar5 = 0x05 + 0006 274 ar6 = 0x06 + 0007 275 ar7 = 0x07 + 0000 276 ar0 = 0x00 + 0001 277 ar1 = 0x01 + 278 ; printfl.c 0 + 0000 C0 E0 279 push acc + 0002 C0 F0 280 push b + 0004 C0 83 281 push dph + 0006 C0 82 282 push dpl + 0008 90s00r00 283 mov dptr,#_pvalhex_val_1_1 + 000B D0 E0 284 pop acc + 000D F0 285 movx @dptr,a + 000E D0 E0 286 pop acc + 0010 A3 287 inc dptr + 0011 F0 288 movx @dptr,a + 0012 D0 E0 289 pop acc + 0014 A3 290 inc dptr + 0015 F0 291 movx @dptr,a + 0016 D0 E0 292 pop acc + 0018 A3 293 inc dptr + 0019 F0 294 movx @dptr,a + 295 ; printfl.c 55 + 001A 90s00r04 296 mov dptr,#_pvalhex_sp_1_1 + 001D E5 81 297 mov a,_SP + 001F F0 298 movx @dptr,a + 299 ; printfl.c 56 + 0020 90s00r00 300 mov dptr,#_pvalhex_val_1_1 + 0023 E0 301 movx a,@dptr + 0024 FA 302 mov r2,a + 0025 A3 303 inc dptr + 0026 E0 304 movx a,@dptr + 0027 FB 305 mov r3,a + 0028 A3 306 inc dptr + 0029 E0 307 movx a,@dptr + 002A FC 308 mov r4,a + 002B A3 309 inc dptr + 002C E0 310 movx a,@dptr + 002D FD 311 mov r5,a + 002E 90s00r05 312 mov dptr,#_pvalhex_lval_1_1 + 0031 EA 313 mov a,r2 + 0032 F0 314 movx @dptr,a + 0033 A3 315 inc dptr + 0034 EB 316 mov a,r3 + 0035 F0 317 movx @dptr,a + 0036 A3 318 inc dptr + 0037 EC 319 mov a,r4 + 0038 F0 320 movx @dptr,a + 0039 A3 321 inc dptr + 003A ED 322 mov a,r5 + 003B F0 323 movx @dptr,a + 324 ; printfl.c 58 + 325 ; Peephole 112 removed ljmp by inverse jump logic + 003C 20*00 0D 326 jb _long_flag,00102$ + 003F 327 00119$: + 328 ; printfl.c 59 + 003F 90s00r05 329 mov dptr,#_pvalhex_lval_1_1 + 0042 EA 330 mov a,r2 + 0043 F0 331 movx @dptr,a + 0044 A3 332 inc dptr + 0045 EB 333 mov a,r3 + 0046 F0 334 movx @dptr,a + 0047 A3 335 inc dptr + 336 ; Peephole 101 removed redundant mov + 337 ; Peephole 180 changed mov to clr + 0048 E4 338 clr a + 0049 F0 339 movx @dptr,a + 004A A3 340 inc dptr + 004B F0 341 movx @dptr,a + 004C 342 00102$: + 343 ; printfl.c 61 + 344 ; Peephole 111 removed ljmp by inverse jump logic + 004C 30*02 1B 345 jnb _short_flag,00116$ + 004F 346 00120$: + 347 ; printfl.c 62 + 004F 90s00r05 348 mov dptr,#_pvalhex_lval_1_1 + 0052 E0 349 movx a,@dptr + 0053 FA 350 mov r2,a + 0054 A3 351 inc dptr + 0055 E0 352 movx a,@dptr + 0056 FB 353 mov r3,a + 0057 A3 354 inc dptr + 0058 E0 355 movx a,@dptr + 0059 FC 356 mov r4,a + 005A A3 357 inc dptr + 005B E0 358 movx a,@dptr + 005C FD 359 mov r5,a + 005D 90s00r05 360 mov dptr,#_pvalhex_lval_1_1 + 0060 EA 361 mov a,r2 + 0061 F0 362 movx @dptr,a + 0062 A3 363 inc dptr + 364 ; Peephole 101 removed redundant mov + 365 ; Peephole 180 changed mov to clr + 0063 E4 366 clr a + 0064 F0 367 movx @dptr,a + 0065 A3 368 inc dptr + 0066 F0 369 movx @dptr,a + 0067 A3 370 inc dptr + 371 ; Peephole 180 changed mov to clr + 0068 E4 372 clr a + 0069 F0 373 movx @dptr,a + 374 ; printfl.c 64 + 006A 375 00116$: + 006A 376 00105$: + 006A 90s00r05 377 mov dptr,#_pvalhex_lval_1_1 + 006D E0 378 movx a,@dptr + 006E FA 379 mov r2,a + 006F A3 380 inc dptr + 0070 E0 381 movx a,@dptr + 0071 FE 382 mov r6,a + 0072 A3 383 inc dptr + 0073 E0 384 movx a,@dptr + 0074 FF 385 mov r7,a + 0075 A3 386 inc dptr + 0076 E0 387 movx a,@dptr + 0077 F8 388 mov r0,a + 0078 EA 389 mov a,r2 + 0079 4E 390 orl a,r6 + 007A 4F 391 orl a,r7 + 007B 48 392 orl a,r0 + 007C 70 03 393 jnz 00121$ + 007E 02s00rC2 394 ljmp 00108$ + 0081 395 00121$: + 396 ; printfl.c 65 + 0081 8A 01 397 mov ar1,r2 + 0083 53 01 0F 398 anl ar1,#0x0f + 0086 E9 399 mov a,r1 + 400 ; Peephole 180 changed mov to clr + 401 ; Peephole 186 optimized movc sequence + 0087 90s05r32 402 mov dptr,#__str_0 + 008A 93 403 movc a,@a+dptr + 008B F5*00 404 mov _ch,a + 405 ; printfl.c 66 + 008D C0*00 406 push _ch + 407 ; printfl.c 67 + 008F EE 408 mov a,r6 + 0090 C4 409 swap a + 0091 CA 410 xch a,r2 + 0092 C4 411 swap a + 0093 54 0F 412 anl a,#0x0f + 0095 6A 413 xrl a,r2 + 0096 CA 414 xch a,r2 + 0097 54 0F 415 anl a,#0x0f + 0099 CA 416 xch a,r2 + 009A 6A 417 xrl a,r2 + 009B CA 418 xch a,r2 + 009C FE 419 mov r6,a + 009D EF 420 mov a,r7 + 009E C4 421 swap a + 009F 54 F0 422 anl a,#0xf0 + 00A1 4E 423 orl a,r6 + 00A2 FE 424 mov r6,a + 00A3 E8 425 mov a,r0 + 00A4 C4 426 swap a + 00A5 CF 427 xch a,r7 + 00A6 C4 428 swap a + 00A7 54 0F 429 anl a,#0x0f + 00A9 6F 430 xrl a,r7 + 00AA CF 431 xch a,r7 + 00AB 54 0F 432 anl a,#0x0f + 00AD CF 433 xch a,r7 + 00AE 6F 434 xrl a,r7 + 00AF CF 435 xch a,r7 + 00B0 F8 436 mov r0,a + 00B1 90s00r05 437 mov dptr,#_pvalhex_lval_1_1 + 00B4 EA 438 mov a,r2 + 00B5 F0 439 movx @dptr,a + 00B6 A3 440 inc dptr + 00B7 EE 441 mov a,r6 + 00B8 F0 442 movx @dptr,a + 00B9 A3 443 inc dptr + 00BA EF 444 mov a,r7 + 00BB F0 445 movx @dptr,a + 00BC A3 446 inc dptr + 00BD E8 447 mov a,r0 + 00BE F0 448 movx @dptr,a + 00BF 02s00r6A 449 ljmp 00105$ + 450 ; printfl.c 70 + 00C2 451 00108$: + 00C2 90s00r04 452 mov dptr,#_pvalhex_sp_1_1 + 00C5 E0 453 movx a,@dptr + 454 ; Peephole 105 removed redundant mov + 00C6 FA 455 mov r2,a + 00C7 B5 81 02 456 cjne a,_SP,00122$ + 457 ; Peephole 132 changed ljmp to sjmp + 00CA 80 0A 458 sjmp 00111$ + 00CC 459 00122$: + 460 ; printfl.c 71 + 00CC D0*00 461 pop _ch + 462 ; printfl.c 72 + 00CE 85*00 82 463 mov dpl,_ch + 00D1 12s00r00 464 lcall _putchar + 465 ; Peephole 132 changed ljmp to sjmp + 00D4 80 EC 466 sjmp 00108$ + 00D6 467 00111$: + 00D6 468 C$printfl.c$75$1$1 ==. + 00D6 469 XFprintfl$pvalhex$0$0 ==. + 00D6 22 470 ret + 00D7 471 Fprintfl$pvaloct$0$0 ==. + 472 ; printfl.c 77 + 473 ; ----------------------------------------- + 474 ; function pvaloct + 475 ; ----------------------------------------- + 00D7 476 _pvaloct: + 477 ; printfl.c 0 + 00D7 C0 E0 478 push acc + 00D9 C0 F0 479 push b + 00DB C0 83 480 push dph + 00DD C0 82 481 push dpl + 00DF 90s00r09 482 mov dptr,#_pvaloct_val_1_1 + 00E2 D0 E0 483 pop acc + 00E4 F0 484 movx @dptr,a + 00E5 D0 E0 485 pop acc + 00E7 A3 486 inc dptr + 00E8 F0 487 movx @dptr,a + 00E9 D0 E0 488 pop acc + 00EB A3 489 inc dptr + 00EC F0 490 movx @dptr,a + 00ED D0 E0 491 pop acc + 00EF A3 492 inc dptr + 00F0 F0 493 movx @dptr,a + 494 ; printfl.c 81 + 495 ; printfl.c 82 + 00F1 90s00r09 496 mov dptr,#_pvaloct_val_1_1 + 00F4 E0 497 movx a,@dptr + 00F5 FB 498 mov r3,a + 00F6 A3 499 inc dptr + 00F7 E0 500 movx a,@dptr + 00F8 FC 501 mov r4,a + 00F9 A3 502 inc dptr + 00FA E0 503 movx a,@dptr + 00FB FD 504 mov r5,a + 00FC A3 505 inc dptr + 00FD E0 506 movx a,@dptr + 507 ; Peephole 105 removed redundant mov + 00FE FE 508 mov r6,a + 509 ; Peephole 111 removed ljmp by inverse jump logic + 00FF 30 E7 17 510 jnb acc.7,00102$ + 0102 511 00126$: + 512 ; printfl.c 83 + 0102 90s00r0D 513 mov dptr,#_pvaloct_lval_1_1 + 0105 C3 514 clr c + 0106 E4 515 clr a + 0107 9B 516 subb a,r3 + 0108 F0 517 movx @dptr,a + 0109 E4 518 clr a + 010A 9C 519 subb a,r4 + 010B A3 520 inc dptr + 010C F0 521 movx @dptr,a + 010D E4 522 clr a + 010E 9D 523 subb a,r5 + 010F A3 524 inc dptr + 0110 F0 525 movx @dptr,a + 0111 E4 526 clr a + 0112 9E 527 subb a,r6 + 0113 A3 528 inc dptr + 0114 F0 529 movx @dptr,a + 530 ; printfl.c 84 + 0115 D2*03 531 setb _sign + 532 ; Peephole 132 changed ljmp to sjmp + 0117 80 10 533 sjmp 00103$ + 0119 534 00102$: + 535 ; printfl.c 86 + 0119 90s00r0D 536 mov dptr,#_pvaloct_lval_1_1 + 011C EB 537 mov a,r3 + 011D F0 538 movx @dptr,a + 011E A3 539 inc dptr + 011F EC 540 mov a,r4 + 0120 F0 541 movx @dptr,a + 0121 A3 542 inc dptr + 0122 ED 543 mov a,r5 + 0123 F0 544 movx @dptr,a + 0124 A3 545 inc dptr + 0125 EE 546 mov a,r6 + 0126 F0 547 movx @dptr,a + 548 ; printfl.c 87 + 0127 C2*03 549 clr _sign + 0129 550 00103$: + 551 ; printfl.c 90 + 552 ; Peephole 112 removed ljmp by inverse jump logic + 0129 20*00 1B 553 jb _long_flag,00105$ + 012C 554 00127$: + 555 ; printfl.c 91 + 012C 90s00r0D 556 mov dptr,#_pvaloct_lval_1_1 + 012F E0 557 movx a,@dptr + 0130 FB 558 mov r3,a + 0131 A3 559 inc dptr + 0132 E0 560 movx a,@dptr + 0133 FC 561 mov r4,a + 0134 A3 562 inc dptr + 0135 E0 563 movx a,@dptr + 0136 FD 564 mov r5,a + 0137 A3 565 inc dptr + 0138 E0 566 movx a,@dptr + 0139 FE 567 mov r6,a + 013A 90s00r0D 568 mov dptr,#_pvaloct_lval_1_1 + 013D EB 569 mov a,r3 + 013E F0 570 movx @dptr,a + 013F A3 571 inc dptr + 0140 EC 572 mov a,r4 + 0141 F0 573 movx @dptr,a + 0142 A3 574 inc dptr + 575 ; Peephole 101 removed redundant mov + 576 ; Peephole 180 changed mov to clr + 0143 E4 577 clr a + 0144 F0 578 movx @dptr,a + 0145 A3 579 inc dptr + 0146 F0 580 movx @dptr,a + 0147 581 00105$: + 582 ; printfl.c 92 + 583 ; Peephole 111 removed ljmp by inverse jump logic + 0147 30*02 1B 584 jnb _short_flag,00108$ + 014A 585 00128$: + 586 ; printfl.c 93 + 014A 90s00r0D 587 mov dptr,#_pvaloct_lval_1_1 + 014D E0 588 movx a,@dptr + 014E FB 589 mov r3,a + 014F A3 590 inc dptr + 0150 E0 591 movx a,@dptr + 0151 FC 592 mov r4,a + 0152 A3 593 inc dptr + 0153 E0 594 movx a,@dptr + 0154 FD 595 mov r5,a + 0155 A3 596 inc dptr + 0156 E0 597 movx a,@dptr + 0157 FE 598 mov r6,a + 0158 90s00r0D 599 mov dptr,#_pvaloct_lval_1_1 + 015B EB 600 mov a,r3 + 015C F0 601 movx @dptr,a + 015D A3 602 inc dptr + 603 ; Peephole 101 removed redundant mov + 604 ; Peephole 180 changed mov to clr + 015E E4 605 clr a + 015F F0 606 movx @dptr,a + 0160 A3 607 inc dptr + 0161 F0 608 movx @dptr,a + 0162 A3 609 inc dptr + 610 ; Peephole 180 changed mov to clr + 0163 E4 611 clr a + 0164 F0 612 movx @dptr,a + 613 ; printfl.c 95 + 0165 614 00108$: + 0165 90s00r0D 615 mov dptr,#_pvaloct_lval_1_1 + 0168 E0 616 movx a,@dptr + 0169 F5*09 617 mov _pvaloct_sloc0_1_0,a + 016B A3 618 inc dptr + 016C E0 619 movx a,@dptr + 016D F5*0A 620 mov (_pvaloct_sloc0_1_0 + 1),a + 016F A3 621 inc dptr + 0170 E0 622 movx a,@dptr + 0171 F5*0B 623 mov (_pvaloct_sloc0_1_0 + 2),a + 0173 A3 624 inc dptr + 0174 E0 625 movx a,@dptr + 0175 F5*0C 626 mov (_pvaloct_sloc0_1_0 + 3),a + 0177 E5*09 627 mov a,_pvaloct_sloc0_1_0 + 0179 45*0A 628 orl a,(_pvaloct_sloc0_1_0 + 1) + 017B 45*0B 629 orl a,(_pvaloct_sloc0_1_0 + 2) + 017D 45*0C 630 orl a,(_pvaloct_sloc0_1_0 + 3) + 017F 70 03 631 jnz 00129$ + 0181 02s01rFF 632 ljmp 00110$ + 0184 633 00129$: + 634 ; printfl.c 96 + 0184 90s00r00 635 mov dptr,#__modulong_PARM_2 + 0187 E4 636 clr a + 0188 A3 637 inc dptr + 0189 A3 638 inc dptr + 018A A3 639 inc dptr + 018B F0 640 movx @dptr,a + 018C 12s00r00 641 lcall __decdptr + 018F F0 642 movx @dptr,a + 0190 12s00r00 643 lcall __decdptr + 0193 F0 644 movx @dptr,a + 0194 12s00r00 645 lcall __decdptr + 0197 74 08 646 mov a,#0x08 + 0199 F0 647 movx @dptr,a + 019A 85*09 82 648 mov dpl,_pvaloct_sloc0_1_0 + 019D 85*0A 83 649 mov dph,(_pvaloct_sloc0_1_0 + 1) + 01A0 85*0B F0 650 mov b,(_pvaloct_sloc0_1_0 + 2) + 01A3 E5*0C 651 mov a,(_pvaloct_sloc0_1_0 + 3) + 01A5 12s00r00 652 lcall __modulong + 01A8 AA 82 653 mov r2,dpl + 01AA AB 83 654 mov r3,dph + 01AC AF F0 655 mov r7,b + 01AE F8 656 mov r0,a + 01AF 74 30 657 mov a,#0x30 + 01B1 2A 658 add a,r2 + 01B2 FA 659 mov r2,a + 660 ; Peephole 180 changed mov to clr + 01B3 E4 661 clr a + 01B4 3B 662 addc a,r3 + 01B5 FB 663 mov r3,a + 664 ; Peephole 180 changed mov to clr + 01B6 E4 665 clr a + 01B7 3F 666 addc a,r7 + 01B8 FF 667 mov r7,a + 668 ; Peephole 180 changed mov to clr + 01B9 E4 669 clr a + 01BA 38 670 addc a,r0 + 01BB F8 671 mov r0,a + 01BC 8A*00 672 mov _ch,r2 + 673 ; printfl.c 97 + 01BE C0*00 674 push _ch + 675 ; printfl.c 98 + 01C0 AA*09 676 mov r2,_pvaloct_sloc0_1_0 + 01C2 E5*0A 677 mov a,(_pvaloct_sloc0_1_0 + 1) + 01C4 C4 678 swap a + 01C5 23 679 rl a + 01C6 CA 680 xch a,r2 + 01C7 C4 681 swap a + 01C8 23 682 rl a + 01C9 54 1F 683 anl a,#0x1f + 01CB 6A 684 xrl a,r2 + 01CC CA 685 xch a,r2 + 01CD 54 1F 686 anl a,#0x1f + 01CF CA 687 xch a,r2 + 01D0 6A 688 xrl a,r2 + 01D1 CA 689 xch a,r2 + 01D2 FB 690 mov r3,a + 01D3 E5*0B 691 mov a,(_pvaloct_sloc0_1_0 + 2) + 01D5 C4 692 swap a + 01D6 23 693 rl a + 01D7 54 E0 694 anl a,#0xe0 + 01D9 4B 695 orl a,r3 + 01DA FB 696 mov r3,a + 01DB AF*0B 697 mov r7,(_pvaloct_sloc0_1_0 + 2) + 01DD E5*0C 698 mov a,(_pvaloct_sloc0_1_0 + 3) + 01DF C4 699 swap a + 01E0 23 700 rl a + 01E1 CF 701 xch a,r7 + 01E2 C4 702 swap a + 01E3 23 703 rl a + 01E4 54 1F 704 anl a,#0x1f + 01E6 6F 705 xrl a,r7 + 01E7 CF 706 xch a,r7 + 01E8 54 1F 707 anl a,#0x1f + 01EA CF 708 xch a,r7 + 01EB 6F 709 xrl a,r7 + 01EC CF 710 xch a,r7 + 01ED F8 711 mov r0,a + 01EE 90s00r0D 712 mov dptr,#_pvaloct_lval_1_1 + 01F1 EA 713 mov a,r2 + 01F2 F0 714 movx @dptr,a + 01F3 A3 715 inc dptr + 01F4 EB 716 mov a,r3 + 01F5 F0 717 movx @dptr,a + 01F6 A3 718 inc dptr + 01F7 EF 719 mov a,r7 + 01F8 F0 720 movx @dptr,a + 01F9 A3 721 inc dptr + 01FA E8 722 mov a,r0 + 01FB F0 723 movx @dptr,a + 01FC 02s01r65 724 ljmp 00108$ + 01FF 725 00110$: + 726 ; printfl.c 101 + 727 ; Peephole 111 removed ljmp by inverse jump logic + 01FF 30*03 05 728 jnb _sign,00113$ + 0202 729 00130$: + 730 ; printfl.c 102 + 0202 75*00 2D 731 mov _ch,#0x2d + 732 ; printfl.c 103 + 0205 C0*00 733 push _ch + 734 ; printfl.c 107 + 0207 735 00113$: + 0207 E5 81 736 mov a,_SP + 0209 B5 81 02 737 cjne a,_SP,00131$ + 738 ; Peephole 132 changed ljmp to sjmp + 020C 80 0A 739 sjmp 00116$ + 020E 740 00131$: + 741 ; printfl.c 108 + 020E D0*00 742 pop _ch + 743 ; printfl.c 109 + 0210 85*00 82 744 mov dpl,_ch + 0213 12s00r00 745 lcall _putchar + 746 ; Peephole 132 changed ljmp to sjmp + 0216 80 EF 747 sjmp 00113$ + 0218 748 00116$: + 0218 749 C$printfl.c$111$1$1 ==. + 0218 750 XFprintfl$pvaloct$0$0 ==. + 0218 22 751 ret + 0219 752 Fprintfl$pvaldec$0$0 ==. + 753 ; printfl.c 113 + 754 ; ----------------------------------------- + 755 ; function pvaldec + 756 ; ----------------------------------------- + 0219 757 _pvaldec: + 758 ; printfl.c 0 + 0219 C0 E0 759 push acc + 021B C0 F0 760 push b + 021D C0 83 761 push dph + 021F C0 82 762 push dpl + 0221 90s00r11 763 mov dptr,#_pvaldec_val_1_1 + 0224 D0 E0 764 pop acc + 0226 F0 765 movx @dptr,a + 0227 D0 E0 766 pop acc + 0229 A3 767 inc dptr + 022A F0 768 movx @dptr,a + 022B D0 E0 769 pop acc + 022D A3 770 inc dptr + 022E F0 771 movx @dptr,a + 022F D0 E0 772 pop acc + 0231 A3 773 inc dptr + 0232 F0 774 movx @dptr,a + 775 ; printfl.c 117 + 776 ; printfl.c 118 + 0233 90s00r11 777 mov dptr,#_pvaldec_val_1_1 + 0236 E0 778 movx a,@dptr + 0237 FB 779 mov r3,a + 0238 A3 780 inc dptr + 0239 E0 781 movx a,@dptr + 023A FC 782 mov r4,a + 023B A3 783 inc dptr + 023C E0 784 movx a,@dptr + 023D FD 785 mov r5,a + 023E A3 786 inc dptr + 023F E0 787 movx a,@dptr + 788 ; Peephole 105 removed redundant mov + 0240 FE 789 mov r6,a + 790 ; Peephole 111 removed ljmp by inverse jump logic + 0241 30 E7 17 791 jnb acc.7,00102$ + 0244 792 00120$: + 793 ; printfl.c 119 + 0244 90s00r15 794 mov dptr,#_pvaldec_lval_1_1 + 0247 C3 795 clr c + 0248 E4 796 clr a + 0249 9B 797 subb a,r3 + 024A F0 798 movx @dptr,a + 024B E4 799 clr a + 024C 9C 800 subb a,r4 + 024D A3 801 inc dptr + 024E F0 802 movx @dptr,a + 024F E4 803 clr a + 0250 9D 804 subb a,r5 + 0251 A3 805 inc dptr + 0252 F0 806 movx @dptr,a + 0253 E4 807 clr a + 0254 9E 808 subb a,r6 + 0255 A3 809 inc dptr + 0256 F0 810 movx @dptr,a + 811 ; printfl.c 120 + 0257 D2*03 812 setb _sign + 813 ; Peephole 132 changed ljmp to sjmp + 0259 80 10 814 sjmp 00104$ + 025B 815 00102$: + 816 ; printfl.c 122 + 025B 90s00r15 817 mov dptr,#_pvaldec_lval_1_1 + 025E EB 818 mov a,r3 + 025F F0 819 movx @dptr,a + 0260 A3 820 inc dptr + 0261 EC 821 mov a,r4 + 0262 F0 822 movx @dptr,a + 0263 A3 823 inc dptr + 0264 ED 824 mov a,r5 + 0265 F0 825 movx @dptr,a + 0266 A3 826 inc dptr + 0267 EE 827 mov a,r6 + 0268 F0 828 movx @dptr,a + 829 ; printfl.c 123 + 0269 C2*03 830 clr _sign + 831 ; printfl.c 126 + 026B 832 00104$: + 026B 90s00r15 833 mov dptr,#_pvaldec_lval_1_1 + 026E E0 834 movx a,@dptr + 026F FB 835 mov r3,a + 0270 A3 836 inc dptr + 0271 E0 837 movx a,@dptr + 0272 FC 838 mov r4,a + 0273 A3 839 inc dptr + 0274 E0 840 movx a,@dptr + 0275 FD 841 mov r5,a + 0276 A3 842 inc dptr + 0277 E0 843 movx a,@dptr + 0278 FE 844 mov r6,a + 0279 EB 845 mov a,r3 + 027A 4C 846 orl a,r4 + 027B 4D 847 orl a,r5 + 027C 4E 848 orl a,r6 + 027D 70 03 849 jnz 00121$ + 027F 02s03r02 850 ljmp 00106$ + 0282 851 00121$: + 852 ; printfl.c 127 + 0282 90s00r00 853 mov dptr,#__modulong_PARM_2 + 0285 E4 854 clr a + 0286 A3 855 inc dptr + 0287 A3 856 inc dptr + 0288 A3 857 inc dptr + 0289 F0 858 movx @dptr,a + 028A 12s00r00 859 lcall __decdptr + 028D F0 860 movx @dptr,a + 028E 12s00r00 861 lcall __decdptr + 0291 F0 862 movx @dptr,a + 0292 12s00r00 863 lcall __decdptr + 0295 74 0A 864 mov a,#0x0a + 0297 F0 865 movx @dptr,a + 0298 C0 03 866 push ar3 + 029A C0 04 867 push ar4 + 029C C0 05 868 push ar5 + 029E C0 06 869 push ar6 + 02A0 8B 82 870 mov dpl,r3 + 02A2 8C 83 871 mov dph,r4 + 02A4 8D F0 872 mov b,r5 + 02A6 EE 873 mov a,r6 + 02A7 12s00r00 874 lcall __modulong + 02AA AF 82 875 mov r7,dpl + 02AC A8 83 876 mov r0,dph + 02AE A9 F0 877 mov r1,b + 02B0 FA 878 mov r2,a + 02B1 D0 06 879 pop ar6 + 02B3 D0 05 880 pop ar5 + 02B5 D0 04 881 pop ar4 + 02B7 D0 03 882 pop ar3 + 02B9 74 30 883 mov a,#0x30 + 02BB 2F 884 add a,r7 + 02BC FF 885 mov r7,a + 886 ; Peephole 180 changed mov to clr + 02BD E4 887 clr a + 02BE 38 888 addc a,r0 + 02BF F8 889 mov r0,a + 890 ; Peephole 180 changed mov to clr + 02C0 E4 891 clr a + 02C1 39 892 addc a,r1 + 02C2 F9 893 mov r1,a + 894 ; Peephole 180 changed mov to clr + 02C3 E4 895 clr a + 02C4 3A 896 addc a,r2 + 02C5 FA 897 mov r2,a + 02C6 8F*00 898 mov _ch,r7 + 899 ; printfl.c 128 + 02C8 C0*00 900 push _ch + 901 ; printfl.c 129 + 02CA 90s00r00 902 mov dptr,#__divulong_PARM_2 + 02CD E4 903 clr a + 02CE A3 904 inc dptr + 02CF A3 905 inc dptr + 02D0 A3 906 inc dptr + 02D1 F0 907 movx @dptr,a + 02D2 12s00r00 908 lcall __decdptr + 02D5 F0 909 movx @dptr,a + 02D6 12s00r00 910 lcall __decdptr + 02D9 F0 911 movx @dptr,a + 02DA 12s00r00 912 lcall __decdptr + 02DD 74 0A 913 mov a,#0x0a + 02DF F0 914 movx @dptr,a + 02E0 8B 82 915 mov dpl,r3 + 02E2 8C 83 916 mov dph,r4 + 02E4 8D F0 917 mov b,r5 + 02E6 EE 918 mov a,r6 + 02E7 12s00r00 919 lcall __divulong + 02EA AA 82 920 mov r2,dpl + 02EC AB 83 921 mov r3,dph + 02EE AC F0 922 mov r4,b + 02F0 FD 923 mov r5,a + 02F1 90s00r15 924 mov dptr,#_pvaldec_lval_1_1 + 02F4 EA 925 mov a,r2 + 02F5 F0 926 movx @dptr,a + 02F6 A3 927 inc dptr + 02F7 EB 928 mov a,r3 + 02F8 F0 929 movx @dptr,a + 02F9 A3 930 inc dptr + 02FA EC 931 mov a,r4 + 02FB F0 932 movx @dptr,a + 02FC A3 933 inc dptr + 02FD ED 934 mov a,r5 + 02FE F0 935 movx @dptr,a + 02FF 02s02r6B 936 ljmp 00104$ + 0302 937 00106$: + 938 ; printfl.c 132 + 939 ; Peephole 111 removed ljmp by inverse jump logic + 0302 30*03 05 940 jnb _sign,00109$ + 0305 941 00122$: + 942 ; printfl.c 133 + 0305 75*00 2D 943 mov _ch,#0x2d + 944 ; printfl.c 134 + 0308 C0*00 945 push _ch + 946 ; printfl.c 138 + 030A 947 00109$: + 030A E5 81 948 mov a,_SP + 030C B5 81 02 949 cjne a,_SP,00123$ + 950 ; Peephole 132 changed ljmp to sjmp + 030F 80 0A 951 sjmp 00112$ + 0311 952 00123$: + 953 ; printfl.c 139 + 0311 D0*00 954 pop _ch + 955 ; printfl.c 140 + 0313 85*00 82 956 mov dpl,_ch + 0316 12s00r00 957 lcall _putchar + 958 ; Peephole 132 changed ljmp to sjmp + 0319 80 EF 959 sjmp 00109$ + 031B 960 00112$: + 031B 961 C$printfl.c$142$1$1 ==. + 031B 962 XFprintfl$pvaldec$0$0 ==. + 031B 22 963 ret + 031C 964 G$printf_small$0$0 ==. + 965 ; printfl.c 144 + 966 ; ----------------------------------------- + 967 ; function printf_small + 968 ; ----------------------------------------- + 031C 969 _printf_small: + 031C C0*00 970 push _bp + 031E 85 81*00 971 mov _bp,sp + 0321 05 81 972 inc sp + 973 ; printfl.c 148 + 0323 E5*00 974 mov a,_bp + 0325 24 FB 975 add a,#0xfb + 0327 FA 976 mov r2,a + 977 ; Peephole 3.c changed mov to clr + 0328 E4 978 clr a + 0329 FB 979 mov r3,a + 032A FC 980 mov r4,a + 981 ; Peephole 212 reduced add sequence to inc + 032B A8*00 982 mov r0,_bp + 032D 08 983 inc r0 + 032E A6 02 984 mov @r0,ar2 + 0330 985 00129$: + 986 ; printfl.c 150 + 0330 E5*00 987 mov a,_bp + 0332 24 FB 988 add a,#0xfb + 0334 F8 989 mov r0,a + 0335 86 03 990 mov ar3,@r0 + 0337 08 991 inc r0 + 0338 86 04 992 mov ar4,@r0 + 033A 08 993 inc r0 + 033B 86 05 994 mov ar5,@r0 + 033D 8B 82 995 mov dpl,r3 + 033F 8C 83 996 mov dph,r4 + 0341 8D F0 997 mov b,r5 + 0343 12s00r00 998 lcall __gptrget + 999 ; Peephole 105 removed redundant mov + 0346 FE 1000 mov r6,a + 0347 70 03 1001 jnz 00154$ + 0349 02s05r2C 1002 ljmp 00133$ + 034C 1003 00154$: + 1004 ; printfl.c 151 + 034C BE 25 02 1005 cjne r6,#0x25,00155$ + 034F 80 03 1006 sjmp 00156$ + 0351 1007 00155$: + 0351 02s05r19 1008 ljmp 00127$ + 0354 1009 00156$: + 1010 ; printfl.c 152 + 0354 C2*02 1011 clr _short_flag + 0356 C2*01 1012 clr _string_flag + 0358 C2*00 1013 clr _long_flag + 1014 ; printfl.c 153 + 035A 0B 1015 inc r3 + 035B BB 00 01 1016 cjne r3,#0x00,00157$ + 035E 0C 1017 inc r4 + 035F 1018 00157$: + 035F E5*00 1019 mov a,_bp + 0361 24 FB 1020 add a,#0xfb + 0363 F8 1021 mov r0,a + 0364 A6 03 1022 mov @r0,ar3 + 0366 08 1023 inc r0 + 0367 A6 04 1024 mov @r0,ar4 + 0369 08 1025 inc r0 + 036A A6 05 1026 mov @r0,ar5 + 1027 ; printfl.c 154 + 036C 8B 82 1028 mov dpl,r3 + 036E 8C 83 1029 mov dph,r4 + 0370 8D F0 1030 mov b,r5 + 0372 12s00r00 1031 lcall __gptrget + 0375 FF 1032 mov r7,a + 0376 BF 68 02 1033 cjne r7,#0x68,00158$ + 1034 ; Peephole 132 changed ljmp to sjmp + 0379 80 17 1035 sjmp 00102$ + 037B 1036 00158$: + 1037 ; Peephole 132 changed ljmp to sjmp + 1038 ; Peephole 199 optimized misc jump sequence + 037B BF 6C 26 1039 cjne r7,#0x6c,00103$ + 1040 ; Peephole 201 removed redundant sjmp + 037E 1041 00159$: + 037E 1042 00160$: + 1043 ; printfl.c 156 + 037E D2*00 1044 setb _long_flag + 1045 ; printfl.c 157 + 0380 E5*00 1046 mov a,_bp + 0382 24 FB 1047 add a,#0xfb + 0384 F8 1048 mov r0,a + 0385 74 01 1049 mov a,#0x01 + 0387 2B 1050 add a,r3 + 0388 F6 1051 mov @r0,a + 1052 ; Peephole 180 changed mov to clr + 0389 E4 1053 clr a + 038A 3C 1054 addc a,r4 + 038B 08 1055 inc r0 + 038C F6 1056 mov @r0,a + 038D 08 1057 inc r0 + 038E A6 05 1058 mov @r0,ar5 + 1059 ; printfl.c 158 + 1060 ; printfl.c 160 + 1061 ; Peephole 132 changed ljmp to sjmp + 0390 80 12 1062 sjmp 00103$ + 0392 1063 00102$: + 0392 D2*02 1064 setb _short_flag + 1065 ; printfl.c 161 + 0394 E5*00 1066 mov a,_bp + 0396 24 FB 1067 add a,#0xfb + 0398 F8 1068 mov r0,a + 0399 74 01 1069 mov a,#0x01 + 039B 2B 1070 add a,r3 + 039C F6 1071 mov @r0,a + 1072 ; Peephole 180 changed mov to clr + 039D E4 1073 clr a + 039E 3C 1074 addc a,r4 + 039F 08 1075 inc r0 + 03A0 F6 1076 mov @r0,a + 03A1 08 1077 inc r0 + 03A2 A6 05 1078 mov @r0,ar5 + 1079 ; printfl.c 162 + 03A4 1080 00103$: + 1081 ; printfl.c 164 + 03A4 E5*00 1082 mov a,_bp + 03A6 24 FB 1083 add a,#0xfb + 03A8 F8 1084 mov r0,a + 03A9 86 03 1085 mov ar3,@r0 + 03AB 08 1086 inc r0 + 03AC 86 04 1087 mov ar4,@r0 + 03AE 08 1088 inc r0 + 03AF 86 05 1089 mov ar5,@r0 + 03B1 8B 82 1090 mov dpl,r3 + 03B3 8C 83 1091 mov dph,r4 + 03B5 8D F0 1092 mov b,r5 + 03B7 12s00r00 1093 lcall __gptrget + 03BA FB 1094 mov r3,a + 03BB BB 63 02 1095 cjne r3,#0x63,00161$ + 1096 ; Peephole 132 changed ljmp to sjmp + 03BE 80 22 1097 sjmp 00107$ + 03C0 1098 00161$: + 03C0 BB 64 02 1099 cjne r3,#0x64,00162$ + 1100 ; Peephole 132 changed ljmp to sjmp + 03C3 80 13 1101 sjmp 00105$ + 03C5 1102 00162$: + 03C5 BB 6F 02 1103 cjne r3,#0x6f,00163$ + 1104 ; Peephole 132 changed ljmp to sjmp + 03C8 80 1D 1105 sjmp 00108$ + 03CA 1106 00163$: + 03CA BB 73 02 1107 cjne r3,#0x73,00164$ + 1108 ; Peephole 132 changed ljmp to sjmp + 03CD 80 05 1109 sjmp 00104$ + 03CF 1110 00164$: + 1111 ; Peephole 132 changed ljmp to sjmp + 1112 ; printfl.c 166 + 1113 ; Peephole 132 changed ljmp to sjmp + 1114 ; Peephole 199 optimized misc jump sequence + 03CF BB 78 18 1115 cjne r3,#0x78,00109$ + 03D2 80 09 1116 sjmp 00106$ + 03D4 1117 00165$: + 03D4 1118 00104$: + 03D4 D2*01 1119 setb _string_flag + 1120 ; printfl.c 167 + 1121 ; printfl.c 169 + 1122 ; Peephole 132 changed ljmp to sjmp + 03D6 80 12 1123 sjmp 00109$ + 03D8 1124 00105$: + 03D8 75*01 0A 1125 mov _radix,#0x0a + 1126 ; printfl.c 170 + 1127 ; printfl.c 172 + 1128 ; Peephole 132 changed ljmp to sjmp + 03DB 80 0D 1129 sjmp 00109$ + 03DD 1130 00106$: + 03DD 75*01 10 1131 mov _radix,#0x10 + 1132 ; printfl.c 173 + 1133 ; printfl.c 175 + 1134 ; Peephole 132 changed ljmp to sjmp + 03E0 80 08 1135 sjmp 00109$ + 03E2 1136 00107$: + 03E2 75*01 00 1137 mov _radix,#0x00 + 1138 ; printfl.c 176 + 1139 ; printfl.c 178 + 1140 ; Peephole 132 changed ljmp to sjmp + 03E5 80 03 1141 sjmp 00109$ + 03E7 1142 00108$: + 03E7 75*01 08 1143 mov _radix,#0x08 + 1144 ; printfl.c 180 + 03EA 1145 00109$: + 1146 ; printfl.c 182 + 03EA 20*01 03 1147 jb _string_flag,00166$ + 03ED 02s04r5B 1148 ljmp 00114$ + 03F0 1149 00166$: + 1150 ; printfl.c 183 + 1151 ; Peephole 212 reduced add sequence to inc + 03F0 A9*00 1152 mov r1,_bp + 03F2 09 1153 inc r1 + 03F3 E7 1154 mov a,@r1 + 03F4 24 FD 1155 add a,#0xfd + 03F6 F8 1156 mov r0,a + 1157 ; Peephole 212 reduced add sequence to inc + 03F7 A9*00 1158 mov r1,_bp + 03F9 09 1159 inc r1 + 03FA A7 00 1160 mov @r1,ar0 + 03FC 86*02 1161 mov _str,@r0 + 03FE 08 1162 inc r0 + 03FF 86*03 1163 mov (_str + 1),@r0 + 0401 08 1164 inc r0 + 0402 86*04 1165 mov (_str + 2),@r0 + 0404 18 1166 dec r0 + 0405 18 1167 dec r0 + 1168 ; printfl.c 184 + 0406 1169 00110$: + 0406 85*02*0E 1170 mov _printf_small_sloc1_1_0,_str + 0409 85*03*0F 1171 mov (_printf_small_sloc1_1_0 + 1),(_str + 1) + 040C 85*04*10 1172 mov (_printf_small_sloc1_1_0 + 2),(_str + 2) + 040F 85*0E 82 1173 mov dpl,_printf_small_sloc1_1_0 + 0412 85*0F 83 1174 mov dph,(_printf_small_sloc1_1_0 + 1) + 0415 85*10 F0 1175 mov b,(_printf_small_sloc1_1_0 + 2) + 0418 12s00r00 1176 lcall __gptrget + 1177 ; Peephole 105 removed redundant mov + 041B F5*0D 1178 mov _printf_small_sloc0_1_0,a + 041D 70 03 1179 jnz 00167$ + 041F 02s05r1E 1180 ljmp 00131$ + 0422 1181 00167$: + 0422 85*02 82 1182 mov dpl,_str + 0425 85*03 83 1183 mov dph,(_str + 1) + 0428 85*04 F0 1184 mov b,(_str + 2) + 042B 74 01 1185 mov a,#0x01 + 042D 25*02 1186 add a,_str + 042F FA 1187 mov r2,a + 1188 ; Peephole 180 changed mov to clr + 0430 E4 1189 clr a + 0431 35*03 1190 addc a,(_str + 1) + 0433 FF 1191 mov r7,a + 0434 AB*04 1192 mov r3,(_str + 2) + 0436 8A*02 1193 mov _str,r2 + 0438 8F*03 1194 mov (_str + 1),r7 + 043A 8B*04 1195 mov (_str + 2),r3 + 043C 12s00r00 1196 lcall __gptrget + 043F FC 1197 mov r4,a + 0440 C0 02 1198 push ar2 + 0442 C0 03 1199 push ar3 + 0444 C0 04 1200 push ar4 + 0446 C0 06 1201 push ar6 + 0448 C0 07 1202 push ar7 + 044A 8C 82 1203 mov dpl,r4 + 044C 12s00r00 1204 lcall _putchar + 044F D0 07 1205 pop ar7 + 0451 D0 06 1206 pop ar6 + 0453 D0 04 1207 pop ar4 + 0455 D0 03 1208 pop ar3 + 0457 D0 02 1209 pop ar2 + 1210 ; printfl.c 185 + 1211 ; Peephole 132 changed ljmp to sjmp + 0459 80 AB 1212 sjmp 00110$ + 045B 1213 00114$: + 1214 ; printfl.c 188 + 1215 ; Peephole 111 removed ljmp by inverse jump logic + 045B 30*00 1C 1216 jnb _long_flag,00119$ + 045E 1217 00168$: + 1218 ; printfl.c 189 + 1219 ; Peephole 212 reduced add sequence to inc + 045E A9*00 1220 mov r1,_bp + 0460 09 1221 inc r1 + 0461 E7 1222 mov a,@r1 + 0462 24 FC 1223 add a,#0xfc + 0464 F8 1224 mov r0,a + 1225 ; Peephole 212 reduced add sequence to inc + 0465 A9*00 1226 mov r1,_bp + 0467 09 1227 inc r1 + 0468 A7 00 1228 mov @r1,ar0 + 046A 86*05 1229 mov _val,@r0 + 046C 08 1230 inc r0 + 046D 86*06 1231 mov (_val + 1),@r0 + 046F 08 1232 inc r0 + 0470 86*07 1233 mov (_val + 2),@r0 + 0472 08 1234 inc r0 + 0473 86*08 1235 mov (_val + 3),@r0 + 0475 18 1236 dec r0 + 0476 18 1237 dec r0 + 0477 18 1238 dec r0 + 1239 ; Peephole 132 changed ljmp to sjmp + 0478 80 3D 1240 sjmp 00120$ + 047A 1241 00119$: + 1242 ; printfl.c 191 + 1243 ; Peephole 111 removed ljmp by inverse jump logic + 047A 30*02 1C 1244 jnb _short_flag,00116$ + 047D 1245 00169$: + 1246 ; printfl.c 192 + 1247 ; Peephole 212 reduced add sequence to inc + 047D A9*00 1248 mov r1,_bp + 047F 09 1249 inc r1 + 0480 E7 1250 mov a,@r1 + 0481 24 FF 1251 add a,#0xff + 0483 F8 1252 mov r0,a + 1253 ; Peephole 212 reduced add sequence to inc + 0484 A9*00 1254 mov r1,_bp + 0486 09 1255 inc r1 + 0487 A7 00 1256 mov @r1,ar0 + 0489 86 02 1257 mov ar2,@r0 + 048B 8A*05 1258 mov _val,r2 + 048D EA 1259 mov a,r2 + 048E 33 1260 rlc a + 048F 95 E0 1261 subb a,acc + 0491 F5*06 1262 mov (_val + 1),a + 0493 F5*07 1263 mov (_val + 2),a + 0495 F5*08 1264 mov (_val + 3),a + 1265 ; Peephole 132 changed ljmp to sjmp + 0497 80 1E 1266 sjmp 00120$ + 0499 1267 00116$: + 1268 ; printfl.c 194 + 1269 ; Peephole 212 reduced add sequence to inc + 0499 A9*00 1270 mov r1,_bp + 049B 09 1271 inc r1 + 049C E7 1272 mov a,@r1 + 049D 24 FE 1273 add a,#0xfe + 049F F8 1274 mov r0,a + 1275 ; Peephole 212 reduced add sequence to inc + 04A0 A9*00 1276 mov r1,_bp + 04A2 09 1277 inc r1 + 04A3 A7 00 1278 mov @r1,ar0 + 04A5 86 02 1279 mov ar2,@r0 + 04A7 08 1280 inc r0 + 04A8 86 03 1281 mov ar3,@r0 + 04AA 18 1282 dec r0 + 04AB 8A*05 1283 mov _val,r2 + 04AD 8B*06 1284 mov (_val + 1),r3 + 04AF EB 1285 mov a,r3 + 04B0 33 1286 rlc a + 04B1 95 E0 1287 subb a,acc + 04B3 F5*07 1288 mov (_val + 2),a + 04B5 F5*08 1289 mov (_val + 3),a + 04B7 1290 00120$: + 1291 ; printfl.c 196 + 04B7 E5*01 1292 mov a,_radix + 1293 ; Peephole 110 removed ljmp by inverse jump logic + 04B9 60 3D 1294 jz 00123$ + 04BB 1295 00170$: + 04BB E5*01 1296 mov a,_radix + 04BD B4 08 02 1297 cjne a,#0x08,00171$ + 1298 ; Peephole 132 changed ljmp to sjmp + 04C0 80 43 1299 sjmp 00124$ + 04C2 1300 00171$: + 04C2 E5*01 1301 mov a,_radix + 04C4 B4 0A 02 1302 cjne a,#0x0a,00172$ + 1303 ; Peephole 132 changed ljmp to sjmp + 04C7 80 07 1304 sjmp 00121$ + 04C9 1305 00172$: + 04C9 E5*01 1306 mov a,_radix + 1307 ; Peephole 132 changed ljmp to sjmp + 1308 ; printfl.c 198 + 1309 ; Peephole 132 changed ljmp to sjmp + 1310 ; Peephole 199 optimized misc jump sequence + 04CB B4 10 50 1311 cjne a,#0x10,00131$ + 04CE 80 14 1312 sjmp 00122$ + 04D0 1313 00173$: + 04D0 1314 00121$: + 04D0 C0 06 1315 push ar6 + 04D2 85*05 82 1316 mov dpl,_val + 04D5 85*06 83 1317 mov dph,(_val + 1) + 04D8 85*07 F0 1318 mov b,(_val + 2) + 04DB E5*08 1319 mov a,(_val + 3) + 04DD 12s02r19 1320 lcall _pvaldec + 04E0 D0 06 1321 pop ar6 + 1322 ; printfl.c 199 + 1323 ; printfl.c 201 + 1324 ; Peephole 132 changed ljmp to sjmp + 04E2 80 3A 1325 sjmp 00131$ + 04E4 1326 00122$: + 04E4 C0 06 1327 push ar6 + 04E6 85*05 82 1328 mov dpl,_val + 04E9 85*06 83 1329 mov dph,(_val + 1) + 04EC 85*07 F0 1330 mov b,(_val + 2) + 04EF E5*08 1331 mov a,(_val + 3) + 04F1 12s00r00 1332 lcall _pvalhex + 04F4 D0 06 1333 pop ar6 + 1334 ; printfl.c 202 + 1335 ; printfl.c 204 + 1336 ; Peephole 132 changed ljmp to sjmp + 04F6 80 26 1337 sjmp 00131$ + 04F8 1338 00123$: + 04F8 AA*05 1339 mov r2,_val + 04FA C0 06 1340 push ar6 + 04FC 8A 82 1341 mov dpl,r2 + 04FE 12s00r00 1342 lcall _putchar + 0501 D0 06 1343 pop ar6 + 1344 ; printfl.c 205 + 1345 ; printfl.c 207 + 1346 ; Peephole 132 changed ljmp to sjmp + 0503 80 19 1347 sjmp 00131$ + 0505 1348 00124$: + 0505 C0 06 1349 push ar6 + 0507 85*05 82 1350 mov dpl,_val + 050A 85*06 83 1351 mov dph,(_val + 1) + 050D 85*07 F0 1352 mov b,(_val + 2) + 0510 E5*08 1353 mov a,(_val + 3) + 0512 12s00rD7 1354 lcall _pvaloct + 0515 D0 06 1355 pop ar6 + 1356 ; printfl.c 209 + 1357 ; Peephole 132 changed ljmp to sjmp + 0517 80 05 1358 sjmp 00131$ + 0519 1359 00127$: + 1360 ; printfl.c 212 + 0519 8E 82 1361 mov dpl,r6 + 051B 12s00r00 1362 lcall _putchar + 051E 1363 00131$: + 1364 ; printfl.c 150 + 051E E5*00 1365 mov a,_bp + 0520 24 FB 1366 add a,#0xfb + 0522 F8 1367 mov r0,a + 0523 06 1368 inc @r0 + 0524 B6 00 02 1369 cjne @r0,#0x00,00174$ + 0527 08 1370 inc r0 + 0528 06 1371 inc @r0 + 0529 1372 00174$: + 0529 02s03r30 1373 ljmp 00129$ + 052C 1374 00133$: + 052C 85*00 81 1375 mov sp,_bp + 052F D0*00 1376 pop _bp + 0531 1377 C$printfl.c$214$1$1 ==. + 0531 1378 XG$printf_small$0$0 ==. + 0531 22 1379 ret + 1380 .area CSEG (CODE) + 0532 1381 Fprintfl$_str_0$0$0 == . + 0532 1382 __str_0: + 0532 30 31 32 33 34 35 1383 .ascii /0123456789ABCDEF/ + 36 37 38 39 41 42 + 43 44 45 46 + 0542 00 1384 .byte 0 diff --git a/device/lib/printfl.sym b/device/lib/printfl.sym new file mode 100644 index 00000000..31527acd --- /dev/null +++ b/device/lib/printfl.sym @@ -0,0 +1,1407 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$printfl$1000 0346 GR + 7 A$printfl$1001 0347 GR + 7 A$printfl$1002 0349 GR + 7 A$printfl$1005 034C GR + 7 A$printfl$1006 034F GR + 7 A$printfl$1008 0351 GR + 7 A$printfl$1011 0354 GR + 7 A$printfl$1012 0356 GR + 7 A$printfl$1013 0358 GR + 7 A$printfl$1015 035A GR + 7 A$printfl$1016 035B GR + 7 A$printfl$1017 035E GR + 7 A$printfl$1019 035F GR + 7 A$printfl$1020 0361 GR + 7 A$printfl$1021 0363 GR + 7 A$printfl$1022 0364 GR + 7 A$printfl$1023 0366 GR + 7 A$printfl$1024 0367 GR + 7 A$printfl$1025 0369 GR + 7 A$printfl$1026 036A GR + 7 A$printfl$1028 036C GR + 7 A$printfl$1029 036E GR + 7 A$printfl$1030 0370 GR + 7 A$printfl$1031 0372 GR + 7 A$printfl$1032 0375 GR + 7 A$printfl$1033 0376 GR + 7 A$printfl$1035 0379 GR + 7 A$printfl$1039 037B GR + 7 A$printfl$1044 037E GR + 7 A$printfl$1046 0380 GR + 7 A$printfl$1047 0382 GR + 7 A$printfl$1048 0384 GR + 7 A$printfl$1049 0385 GR + 7 A$printfl$1050 0387 GR + 7 A$printfl$1051 0388 GR + 7 A$printfl$1053 0389 GR + 7 A$printfl$1054 038A GR + 7 A$printfl$1055 038B GR + 7 A$printfl$1056 038C GR + 7 A$printfl$1057 038D GR + 7 A$printfl$1058 038E GR + 7 A$printfl$1062 0390 GR + 7 A$printfl$1064 0392 GR + 7 A$printfl$1066 0394 GR + 7 A$printfl$1067 0396 GR + 7 A$printfl$1068 0398 GR + 7 A$printfl$1069 0399 GR + 7 A$printfl$1070 039B GR + 7 A$printfl$1071 039C GR + 7 A$printfl$1073 039D GR + 7 A$printfl$1074 039E GR + 7 A$printfl$1075 039F GR + 7 A$printfl$1076 03A0 GR + 7 A$printfl$1077 03A1 GR + 7 A$printfl$1078 03A2 GR + 7 A$printfl$1082 03A4 GR + 7 A$printfl$1083 03A6 GR + 7 A$printfl$1084 03A8 GR + 7 A$printfl$1085 03A9 GR + 7 A$printfl$1086 03AB GR + 7 A$printfl$1087 03AC GR + 7 A$printfl$1088 03AE GR + 7 A$printfl$1089 03AF GR + 7 A$printfl$1090 03B1 GR + 7 A$printfl$1091 03B3 GR + 7 A$printfl$1092 03B5 GR + 7 A$printfl$1093 03B7 GR + 7 A$printfl$1094 03BA GR + 7 A$printfl$1095 03BB GR + 7 A$printfl$1097 03BE GR + 7 A$printfl$1099 03C0 GR + 7 A$printfl$1101 03C3 GR + 7 A$printfl$1103 03C5 GR + 7 A$printfl$1105 03C8 GR + 7 A$printfl$1107 03CA GR + 7 A$printfl$1109 03CD GR + 7 A$printfl$1115 03CF GR + 7 A$printfl$1116 03D2 GR + 7 A$printfl$1119 03D4 GR + 7 A$printfl$1123 03D6 GR + 7 A$printfl$1125 03D8 GR + 7 A$printfl$1129 03DB GR + 7 A$printfl$1131 03DD GR + 7 A$printfl$1135 03E0 GR + 7 A$printfl$1137 03E2 GR + 7 A$printfl$1141 03E5 GR + 7 A$printfl$1143 03E7 GR + 7 A$printfl$1147 03EA GR + 7 A$printfl$1148 03ED GR + 7 A$printfl$1152 03F0 GR + 7 A$printfl$1153 03F2 GR + 7 A$printfl$1154 03F3 GR + 7 A$printfl$1155 03F4 GR + 7 A$printfl$1156 03F6 GR + 7 A$printfl$1158 03F7 GR + 7 A$printfl$1159 03F9 GR + 7 A$printfl$1160 03FA GR + 7 A$printfl$1161 03FC GR + 7 A$printfl$1162 03FE GR + 7 A$printfl$1163 03FF GR + 7 A$printfl$1164 0401 GR + 7 A$printfl$1165 0402 GR + 7 A$printfl$1166 0404 GR + 7 A$printfl$1167 0405 GR + 7 A$printfl$1170 0406 GR + 7 A$printfl$1171 0409 GR + 7 A$printfl$1172 040C GR + 7 A$printfl$1173 040F GR + 7 A$printfl$1174 0412 GR + 7 A$printfl$1175 0415 GR + 7 A$printfl$1176 0418 GR + 7 A$printfl$1178 041B GR + 7 A$printfl$1179 041D GR + 7 A$printfl$1180 041F GR + 7 A$printfl$1182 0422 GR + 7 A$printfl$1183 0425 GR + 7 A$printfl$1184 0428 GR + 7 A$printfl$1185 042B GR + 7 A$printfl$1186 042D GR + 7 A$printfl$1187 042F GR + 7 A$printfl$1189 0430 GR + 7 A$printfl$1190 0431 GR + 7 A$printfl$1191 0433 GR + 7 A$printfl$1192 0434 GR + 7 A$printfl$1193 0436 GR + 7 A$printfl$1194 0438 GR + 7 A$printfl$1195 043A GR + 7 A$printfl$1196 043C GR + 7 A$printfl$1197 043F GR + 7 A$printfl$1198 0440 GR + 7 A$printfl$1199 0442 GR + 7 A$printfl$1200 0444 GR + 7 A$printfl$1201 0446 GR + 7 A$printfl$1202 0448 GR + 7 A$printfl$1203 044A GR + 7 A$printfl$1204 044C GR + 7 A$printfl$1205 044F GR + 7 A$printfl$1206 0451 GR + 7 A$printfl$1207 0453 GR + 7 A$printfl$1208 0455 GR + 7 A$printfl$1209 0457 GR + 7 A$printfl$1212 0459 GR + 7 A$printfl$1216 045B GR + 7 A$printfl$1220 045E GR + 7 A$printfl$1221 0460 GR + 7 A$printfl$1222 0461 GR + 7 A$printfl$1223 0462 GR + 7 A$printfl$1224 0464 GR + 7 A$printfl$1226 0465 GR + 7 A$printfl$1227 0467 GR + 7 A$printfl$1228 0468 GR + 7 A$printfl$1229 046A GR + 7 A$printfl$1230 046C GR + 7 A$printfl$1231 046D GR + 7 A$printfl$1232 046F GR + 7 A$printfl$1233 0470 GR + 7 A$printfl$1234 0472 GR + 7 A$printfl$1235 0473 GR + 7 A$printfl$1236 0475 GR + 7 A$printfl$1237 0476 GR + 7 A$printfl$1238 0477 GR + 7 A$printfl$1240 0478 GR + 7 A$printfl$1244 047A GR + 7 A$printfl$1248 047D GR + 7 A$printfl$1249 047F GR + 7 A$printfl$1250 0480 GR + 7 A$printfl$1251 0481 GR + 7 A$printfl$1252 0483 GR + 7 A$printfl$1254 0484 GR + 7 A$printfl$1255 0486 GR + 7 A$printfl$1256 0487 GR + 7 A$printfl$1257 0489 GR + 7 A$printfl$1258 048B GR + 7 A$printfl$1259 048D GR + 7 A$printfl$1260 048E GR + 7 A$printfl$1261 048F GR + 7 A$printfl$1262 0491 GR + 7 A$printfl$1263 0493 GR + 7 A$printfl$1264 0495 GR + 7 A$printfl$1266 0497 GR + 7 A$printfl$1270 0499 GR + 7 A$printfl$1271 049B GR + 7 A$printfl$1272 049C GR + 7 A$printfl$1273 049D GR + 7 A$printfl$1274 049F GR + 7 A$printfl$1276 04A0 GR + 7 A$printfl$1277 04A2 GR + 7 A$printfl$1278 04A3 GR + 7 A$printfl$1279 04A5 GR + 7 A$printfl$1280 04A7 GR + 7 A$printfl$1281 04A8 GR + 7 A$printfl$1282 04AA GR + 7 A$printfl$1283 04AB GR + 7 A$printfl$1284 04AD GR + 7 A$printfl$1285 04AF GR + 7 A$printfl$1286 04B0 GR + 7 A$printfl$1287 04B1 GR + 7 A$printfl$1288 04B3 GR + 7 A$printfl$1289 04B5 GR + 7 A$printfl$1292 04B7 GR + 7 A$printfl$1294 04B9 GR + 7 A$printfl$1296 04BB GR + 7 A$printfl$1297 04BD GR + 7 A$printfl$1299 04C0 GR + 7 A$printfl$1301 04C2 GR + 7 A$printfl$1302 04C4 GR + 7 A$printfl$1304 04C7 GR + 7 A$printfl$1306 04C9 GR + 7 A$printfl$1311 04CB GR + 7 A$printfl$1312 04CE GR + 7 A$printfl$1315 04D0 GR + 7 A$printfl$1316 04D2 GR + 7 A$printfl$1317 04D5 GR + 7 A$printfl$1318 04D8 GR + 7 A$printfl$1319 04DB GR + 7 A$printfl$1320 04DD GR + 7 A$printfl$1321 04E0 GR + 7 A$printfl$1325 04E2 GR + 7 A$printfl$1327 04E4 GR + 7 A$printfl$1328 04E6 GR + 7 A$printfl$1329 04E9 GR + 7 A$printfl$1330 04EC GR + 7 A$printfl$1331 04EF GR + 7 A$printfl$1332 04F1 GR + 7 A$printfl$1333 04F4 GR + 7 A$printfl$1337 04F6 GR + 7 A$printfl$1339 04F8 GR + 7 A$printfl$1340 04FA GR + 7 A$printfl$1341 04FC GR + 7 A$printfl$1342 04FE GR + 7 A$printfl$1343 0501 GR + 7 A$printfl$1347 0503 GR + 7 A$printfl$1349 0505 GR + 7 A$printfl$1350 0507 GR + 7 A$printfl$1351 050A GR + 7 A$printfl$1352 050D GR + 7 A$printfl$1353 0510 GR + 7 A$printfl$1354 0512 GR + 7 A$printfl$1355 0515 GR + 7 A$printfl$1358 0517 GR + 7 A$printfl$1361 0519 GR + 7 A$printfl$1362 051B GR + 7 A$printfl$1365 051E GR + 7 A$printfl$1366 0520 GR + 7 A$printfl$1367 0522 GR + 7 A$printfl$1368 0523 GR + 7 A$printfl$1369 0524 GR + 7 A$printfl$1370 0527 GR + 7 A$printfl$1371 0528 GR + 7 A$printfl$1373 0529 GR + 7 A$printfl$1375 052C GR + 7 A$printfl$1376 052F GR + 7 A$printfl$1379 0531 GR + 6 A$printfl$253 0000 GR + 6 A$printfl$256 0002 GR + 6 A$printfl$259 0004 GR + 7 A$printfl$279 0000 GR + 7 A$printfl$280 0002 GR + 7 A$printfl$281 0004 GR + 7 A$printfl$282 0006 GR + 7 A$printfl$283 0008 GR + 7 A$printfl$284 000B GR + 7 A$printfl$285 000D GR + 7 A$printfl$286 000E GR + 7 A$printfl$287 0010 GR + 7 A$printfl$288 0011 GR + 7 A$printfl$289 0012 GR + 7 A$printfl$290 0014 GR + 7 A$printfl$291 0015 GR + 7 A$printfl$292 0016 GR + 7 A$printfl$293 0018 GR + 7 A$printfl$294 0019 GR + 7 A$printfl$296 001A GR + 7 A$printfl$297 001D GR + 7 A$printfl$298 001F GR + 7 A$printfl$300 0020 GR + 7 A$printfl$301 0023 GR + 7 A$printfl$302 0024 GR + 7 A$printfl$303 0025 GR + 7 A$printfl$304 0026 GR + 7 A$printfl$305 0027 GR + 7 A$printfl$306 0028 GR + 7 A$printfl$307 0029 GR + 7 A$printfl$308 002A GR + 7 A$printfl$309 002B GR + 7 A$printfl$310 002C GR + 7 A$printfl$311 002D GR + 7 A$printfl$312 002E GR + 7 A$printfl$313 0031 GR + 7 A$printfl$314 0032 GR + 7 A$printfl$315 0033 GR + 7 A$printfl$316 0034 GR + 7 A$printfl$317 0035 GR + 7 A$printfl$318 0036 GR + 7 A$printfl$319 0037 GR + 7 A$printfl$320 0038 GR + 7 A$printfl$321 0039 GR + 7 A$printfl$322 003A GR + 7 A$printfl$323 003B GR + 7 A$printfl$326 003C GR + 7 A$printfl$329 003F GR + 7 A$printfl$330 0042 GR + 7 A$printfl$331 0043 GR + 7 A$printfl$332 0044 GR + 7 A$printfl$333 0045 GR + 7 A$printfl$334 0046 GR + 7 A$printfl$335 0047 GR + 7 A$printfl$338 0048 GR + 7 A$printfl$339 0049 GR + 7 A$printfl$340 004A GR + 7 A$printfl$341 004B GR + 7 A$printfl$345 004C GR + 7 A$printfl$348 004F GR + 7 A$printfl$349 0052 GR + 7 A$printfl$350 0053 GR + 7 A$printfl$351 0054 GR + 7 A$printfl$352 0055 GR + 7 A$printfl$353 0056 GR + 7 A$printfl$354 0057 GR + 7 A$printfl$355 0058 GR + 7 A$printfl$356 0059 GR + 7 A$printfl$357 005A GR + 7 A$printfl$358 005B GR + 7 A$printfl$359 005C GR + 7 A$printfl$360 005D GR + 7 A$printfl$361 0060 GR + 7 A$printfl$362 0061 GR + 7 A$printfl$363 0062 GR + 7 A$printfl$366 0063 GR + 7 A$printfl$367 0064 GR + 7 A$printfl$368 0065 GR + 7 A$printfl$369 0066 GR + 7 A$printfl$370 0067 GR + 7 A$printfl$372 0068 GR + 7 A$printfl$373 0069 GR + 7 A$printfl$377 006A GR + 7 A$printfl$378 006D GR + 7 A$printfl$379 006E GR + 7 A$printfl$380 006F GR + 7 A$printfl$381 0070 GR + 7 A$printfl$382 0071 GR + 7 A$printfl$383 0072 GR + 7 A$printfl$384 0073 GR + 7 A$printfl$385 0074 GR + 7 A$printfl$386 0075 GR + 7 A$printfl$387 0076 GR + 7 A$printfl$388 0077 GR + 7 A$printfl$389 0078 GR + 7 A$printfl$390 0079 GR + 7 A$printfl$391 007A GR + 7 A$printfl$392 007B GR + 7 A$printfl$393 007C GR + 7 A$printfl$394 007E GR + 7 A$printfl$397 0081 GR + 7 A$printfl$398 0083 GR + 7 A$printfl$399 0086 GR + 7 A$printfl$402 0087 GR + 7 A$printfl$403 008A GR + 7 A$printfl$404 008B GR + 7 A$printfl$406 008D GR + 7 A$printfl$408 008F GR + 7 A$printfl$409 0090 GR + 7 A$printfl$410 0091 GR + 7 A$printfl$411 0092 GR + 7 A$printfl$412 0093 GR + 7 A$printfl$413 0095 GR + 7 A$printfl$414 0096 GR + 7 A$printfl$415 0097 GR + 7 A$printfl$416 0099 GR + 7 A$printfl$417 009A GR + 7 A$printfl$418 009B GR + 7 A$printfl$419 009C GR + 7 A$printfl$420 009D GR + 7 A$printfl$421 009E GR + 7 A$printfl$422 009F GR + 7 A$printfl$423 00A1 GR + 7 A$printfl$424 00A2 GR + 7 A$printfl$425 00A3 GR + 7 A$printfl$426 00A4 GR + 7 A$printfl$427 00A5 GR + 7 A$printfl$428 00A6 GR + 7 A$printfl$429 00A7 GR + 7 A$printfl$430 00A9 GR + 7 A$printfl$431 00AA GR + 7 A$printfl$432 00AB GR + 7 A$printfl$433 00AD GR + 7 A$printfl$434 00AE GR + 7 A$printfl$435 00AF GR + 7 A$printfl$436 00B0 GR + 7 A$printfl$437 00B1 GR + 7 A$printfl$438 00B4 GR + 7 A$printfl$439 00B5 GR + 7 A$printfl$440 00B6 GR + 7 A$printfl$441 00B7 GR + 7 A$printfl$442 00B8 GR + 7 A$printfl$443 00B9 GR + 7 A$printfl$444 00BA GR + 7 A$printfl$445 00BB GR + 7 A$printfl$446 00BC GR + 7 A$printfl$447 00BD GR + 7 A$printfl$448 00BE GR + 7 A$printfl$449 00BF GR + 7 A$printfl$452 00C2 GR + 7 A$printfl$453 00C5 GR + 7 A$printfl$455 00C6 GR + 7 A$printfl$456 00C7 GR + 7 A$printfl$458 00CA GR + 7 A$printfl$461 00CC GR + 7 A$printfl$463 00CE GR + 7 A$printfl$464 00D1 GR + 7 A$printfl$466 00D4 GR + 7 A$printfl$470 00D6 GR + 7 A$printfl$478 00D7 GR + 7 A$printfl$479 00D9 GR + 7 A$printfl$480 00DB GR + 7 A$printfl$481 00DD GR + 7 A$printfl$482 00DF GR + 7 A$printfl$483 00E2 GR + 7 A$printfl$484 00E4 GR + 7 A$printfl$485 00E5 GR + 7 A$printfl$486 00E7 GR + 7 A$printfl$487 00E8 GR + 7 A$printfl$488 00E9 GR + 7 A$printfl$489 00EB GR + 7 A$printfl$490 00EC GR + 7 A$printfl$491 00ED GR + 7 A$printfl$492 00EF GR + 7 A$printfl$493 00F0 GR + 7 A$printfl$496 00F1 GR + 7 A$printfl$497 00F4 GR + 7 A$printfl$498 00F5 GR + 7 A$printfl$499 00F6 GR + 7 A$printfl$500 00F7 GR + 7 A$printfl$501 00F8 GR + 7 A$printfl$502 00F9 GR + 7 A$printfl$503 00FA GR + 7 A$printfl$504 00FB GR + 7 A$printfl$505 00FC GR + 7 A$printfl$506 00FD GR + 7 A$printfl$508 00FE GR + 7 A$printfl$510 00FF GR + 7 A$printfl$513 0102 GR + 7 A$printfl$514 0105 GR + 7 A$printfl$515 0106 GR + 7 A$printfl$516 0107 GR + 7 A$printfl$517 0108 GR + 7 A$printfl$518 0109 GR + 7 A$printfl$519 010A GR + 7 A$printfl$520 010B GR + 7 A$printfl$521 010C GR + 7 A$printfl$522 010D GR + 7 A$printfl$523 010E GR + 7 A$printfl$524 010F GR + 7 A$printfl$525 0110 GR + 7 A$printfl$526 0111 GR + 7 A$printfl$527 0112 GR + 7 A$printfl$528 0113 GR + 7 A$printfl$529 0114 GR + 7 A$printfl$531 0115 GR + 7 A$printfl$533 0117 GR + 7 A$printfl$536 0119 GR + 7 A$printfl$537 011C GR + 7 A$printfl$538 011D GR + 7 A$printfl$539 011E GR + 7 A$printfl$540 011F GR + 7 A$printfl$541 0120 GR + 7 A$printfl$542 0121 GR + 7 A$printfl$543 0122 GR + 7 A$printfl$544 0123 GR + 7 A$printfl$545 0124 GR + 7 A$printfl$546 0125 GR + 7 A$printfl$547 0126 GR + 7 A$printfl$549 0127 GR + 7 A$printfl$553 0129 GR + 7 A$printfl$556 012C GR + 7 A$printfl$557 012F GR + 7 A$printfl$558 0130 GR + 7 A$printfl$559 0131 GR + 7 A$printfl$560 0132 GR + 7 A$printfl$561 0133 GR + 7 A$printfl$562 0134 GR + 7 A$printfl$563 0135 GR + 7 A$printfl$564 0136 GR + 7 A$printfl$565 0137 GR + 7 A$printfl$566 0138 GR + 7 A$printfl$567 0139 GR + 7 A$printfl$568 013A GR + 7 A$printfl$569 013D GR + 7 A$printfl$570 013E GR + 7 A$printfl$571 013F GR + 7 A$printfl$572 0140 GR + 7 A$printfl$573 0141 GR + 7 A$printfl$574 0142 GR + 7 A$printfl$577 0143 GR + 7 A$printfl$578 0144 GR + 7 A$printfl$579 0145 GR + 7 A$printfl$580 0146 GR + 7 A$printfl$584 0147 GR + 7 A$printfl$587 014A GR + 7 A$printfl$588 014D GR + 7 A$printfl$589 014E GR + 7 A$printfl$590 014F GR + 7 A$printfl$591 0150 GR + 7 A$printfl$592 0151 GR + 7 A$printfl$593 0152 GR + 7 A$printfl$594 0153 GR + 7 A$printfl$595 0154 GR + 7 A$printfl$596 0155 GR + 7 A$printfl$597 0156 GR + 7 A$printfl$598 0157 GR + 7 A$printfl$599 0158 GR + 7 A$printfl$600 015B GR + 7 A$printfl$601 015C GR + 7 A$printfl$602 015D GR + 7 A$printfl$605 015E GR + 7 A$printfl$606 015F GR + 7 A$printfl$607 0160 GR + 7 A$printfl$608 0161 GR + 7 A$printfl$609 0162 GR + 7 A$printfl$611 0163 GR + 7 A$printfl$612 0164 GR + 7 A$printfl$615 0165 GR + 7 A$printfl$616 0168 GR + 7 A$printfl$617 0169 GR + 7 A$printfl$618 016B GR + 7 A$printfl$619 016C GR + 7 A$printfl$620 016D GR + 7 A$printfl$621 016F GR + 7 A$printfl$622 0170 GR + 7 A$printfl$623 0171 GR + 7 A$printfl$624 0173 GR + 7 A$printfl$625 0174 GR + 7 A$printfl$626 0175 GR + 7 A$printfl$627 0177 GR + 7 A$printfl$628 0179 GR + 7 A$printfl$629 017B GR + 7 A$printfl$630 017D GR + 7 A$printfl$631 017F GR + 7 A$printfl$632 0181 GR + 7 A$printfl$635 0184 GR + 7 A$printfl$636 0187 GR + 7 A$printfl$637 0188 GR + 7 A$printfl$638 0189 GR + 7 A$printfl$639 018A GR + 7 A$printfl$640 018B GR + 7 A$printfl$641 018C GR + 7 A$printfl$642 018F GR + 7 A$printfl$643 0190 GR + 7 A$printfl$644 0193 GR + 7 A$printfl$645 0194 GR + 7 A$printfl$646 0197 GR + 7 A$printfl$647 0199 GR + 7 A$printfl$648 019A GR + 7 A$printfl$649 019D GR + 7 A$printfl$650 01A0 GR + 7 A$printfl$651 01A3 GR + 7 A$printfl$652 01A5 GR + 7 A$printfl$653 01A8 GR + 7 A$printfl$654 01AA GR + 7 A$printfl$655 01AC GR + 7 A$printfl$656 01AE GR + 7 A$printfl$657 01AF GR + 7 A$printfl$658 01B1 GR + 7 A$printfl$659 01B2 GR + 7 A$printfl$661 01B3 GR + 7 A$printfl$662 01B4 GR + 7 A$printfl$663 01B5 GR + 7 A$printfl$665 01B6 GR + 7 A$printfl$666 01B7 GR + 7 A$printfl$667 01B8 GR + 7 A$printfl$669 01B9 GR + 7 A$printfl$670 01BA GR + 7 A$printfl$671 01BB GR + 7 A$printfl$672 01BC GR + 7 A$printfl$674 01BE GR + 7 A$printfl$676 01C0 GR + 7 A$printfl$677 01C2 GR + 7 A$printfl$678 01C4 GR + 7 A$printfl$679 01C5 GR + 7 A$printfl$680 01C6 GR + 7 A$printfl$681 01C7 GR + 7 A$printfl$682 01C8 GR + 7 A$printfl$683 01C9 GR + 7 A$printfl$684 01CB GR + 7 A$printfl$685 01CC GR + 7 A$printfl$686 01CD GR + 7 A$printfl$687 01CF GR + 7 A$printfl$688 01D0 GR + 7 A$printfl$689 01D1 GR + 7 A$printfl$690 01D2 GR + 7 A$printfl$691 01D3 GR + 7 A$printfl$692 01D5 GR + 7 A$printfl$693 01D6 GR + 7 A$printfl$694 01D7 GR + 7 A$printfl$695 01D9 GR + 7 A$printfl$696 01DA GR + 7 A$printfl$697 01DB GR + 7 A$printfl$698 01DD GR + 7 A$printfl$699 01DF GR + 7 A$printfl$700 01E0 GR + 7 A$printfl$701 01E1 GR + 7 A$printfl$702 01E2 GR + 7 A$printfl$703 01E3 GR + 7 A$printfl$704 01E4 GR + 7 A$printfl$705 01E6 GR + 7 A$printfl$706 01E7 GR + 7 A$printfl$707 01E8 GR + 7 A$printfl$708 01EA GR + 7 A$printfl$709 01EB GR + 7 A$printfl$710 01EC GR + 7 A$printfl$711 01ED GR + 7 A$printfl$712 01EE GR + 7 A$printfl$713 01F1 GR + 7 A$printfl$714 01F2 GR + 7 A$printfl$715 01F3 GR + 7 A$printfl$716 01F4 GR + 7 A$printfl$717 01F5 GR + 7 A$printfl$718 01F6 GR + 7 A$printfl$719 01F7 GR + 7 A$printfl$720 01F8 GR + 7 A$printfl$721 01F9 GR + 7 A$printfl$722 01FA GR + 7 A$printfl$723 01FB GR + 7 A$printfl$724 01FC GR + 7 A$printfl$728 01FF GR + 7 A$printfl$731 0202 GR + 7 A$printfl$733 0205 GR + 7 A$printfl$736 0207 GR + 7 A$printfl$737 0209 GR + 7 A$printfl$739 020C GR + 7 A$printfl$742 020E GR + 7 A$printfl$744 0210 GR + 7 A$printfl$745 0213 GR + 7 A$printfl$747 0216 GR + 7 A$printfl$751 0218 GR + 7 A$printfl$759 0219 GR + 7 A$printfl$760 021B GR + 7 A$printfl$761 021D GR + 7 A$printfl$762 021F GR + 7 A$printfl$763 0221 GR + 7 A$printfl$764 0224 GR + 7 A$printfl$765 0226 GR + 7 A$printfl$766 0227 GR + 7 A$printfl$767 0229 GR + 7 A$printfl$768 022A GR + 7 A$printfl$769 022B GR + 7 A$printfl$770 022D GR + 7 A$printfl$771 022E GR + 7 A$printfl$772 022F GR + 7 A$printfl$773 0231 GR + 7 A$printfl$774 0232 GR + 7 A$printfl$777 0233 GR + 7 A$printfl$778 0236 GR + 7 A$printfl$779 0237 GR + 7 A$printfl$780 0238 GR + 7 A$printfl$781 0239 GR + 7 A$printfl$782 023A GR + 7 A$printfl$783 023B GR + 7 A$printfl$784 023C GR + 7 A$printfl$785 023D GR + 7 A$printfl$786 023E GR + 7 A$printfl$787 023F GR + 7 A$printfl$789 0240 GR + 7 A$printfl$791 0241 GR + 7 A$printfl$794 0244 GR + 7 A$printfl$795 0247 GR + 7 A$printfl$796 0248 GR + 7 A$printfl$797 0249 GR + 7 A$printfl$798 024A GR + 7 A$printfl$799 024B GR + 7 A$printfl$800 024C GR + 7 A$printfl$801 024D GR + 7 A$printfl$802 024E GR + 7 A$printfl$803 024F GR + 7 A$printfl$804 0250 GR + 7 A$printfl$805 0251 GR + 7 A$printfl$806 0252 GR + 7 A$printfl$807 0253 GR + 7 A$printfl$808 0254 GR + 7 A$printfl$809 0255 GR + 7 A$printfl$810 0256 GR + 7 A$printfl$812 0257 GR + 7 A$printfl$814 0259 GR + 7 A$printfl$817 025B GR + 7 A$printfl$818 025E GR + 7 A$printfl$819 025F GR + 7 A$printfl$820 0260 GR + 7 A$printfl$821 0261 GR + 7 A$printfl$822 0262 GR + 7 A$printfl$823 0263 GR + 7 A$printfl$824 0264 GR + 7 A$printfl$825 0265 GR + 7 A$printfl$826 0266 GR + 7 A$printfl$827 0267 GR + 7 A$printfl$828 0268 GR + 7 A$printfl$830 0269 GR + 7 A$printfl$833 026B GR + 7 A$printfl$834 026E GR + 7 A$printfl$835 026F GR + 7 A$printfl$836 0270 GR + 7 A$printfl$837 0271 GR + 7 A$printfl$838 0272 GR + 7 A$printfl$839 0273 GR + 7 A$printfl$840 0274 GR + 7 A$printfl$841 0275 GR + 7 A$printfl$842 0276 GR + 7 A$printfl$843 0277 GR + 7 A$printfl$844 0278 GR + 7 A$printfl$845 0279 GR + 7 A$printfl$846 027A GR + 7 A$printfl$847 027B GR + 7 A$printfl$848 027C GR + 7 A$printfl$849 027D GR + 7 A$printfl$850 027F GR + 7 A$printfl$853 0282 GR + 7 A$printfl$854 0285 GR + 7 A$printfl$855 0286 GR + 7 A$printfl$856 0287 GR + 7 A$printfl$857 0288 GR + 7 A$printfl$858 0289 GR + 7 A$printfl$859 028A GR + 7 A$printfl$860 028D GR + 7 A$printfl$861 028E GR + 7 A$printfl$862 0291 GR + 7 A$printfl$863 0292 GR + 7 A$printfl$864 0295 GR + 7 A$printfl$865 0297 GR + 7 A$printfl$866 0298 GR + 7 A$printfl$867 029A GR + 7 A$printfl$868 029C GR + 7 A$printfl$869 029E GR + 7 A$printfl$870 02A0 GR + 7 A$printfl$871 02A2 GR + 7 A$printfl$872 02A4 GR + 7 A$printfl$873 02A6 GR + 7 A$printfl$874 02A7 GR + 7 A$printfl$875 02AA GR + 7 A$printfl$876 02AC GR + 7 A$printfl$877 02AE GR + 7 A$printfl$878 02B0 GR + 7 A$printfl$879 02B1 GR + 7 A$printfl$880 02B3 GR + 7 A$printfl$881 02B5 GR + 7 A$printfl$882 02B7 GR + 7 A$printfl$883 02B9 GR + 7 A$printfl$884 02BB GR + 7 A$printfl$885 02BC GR + 7 A$printfl$887 02BD GR + 7 A$printfl$888 02BE GR + 7 A$printfl$889 02BF GR + 7 A$printfl$891 02C0 GR + 7 A$printfl$892 02C1 GR + 7 A$printfl$893 02C2 GR + 7 A$printfl$895 02C3 GR + 7 A$printfl$896 02C4 GR + 7 A$printfl$897 02C5 GR + 7 A$printfl$898 02C6 GR + 7 A$printfl$900 02C8 GR + 7 A$printfl$902 02CA GR + 7 A$printfl$903 02CD GR + 7 A$printfl$904 02CE GR + 7 A$printfl$905 02CF GR + 7 A$printfl$906 02D0 GR + 7 A$printfl$907 02D1 GR + 7 A$printfl$908 02D2 GR + 7 A$printfl$909 02D5 GR + 7 A$printfl$910 02D6 GR + 7 A$printfl$911 02D9 GR + 7 A$printfl$912 02DA GR + 7 A$printfl$913 02DD GR + 7 A$printfl$914 02DF GR + 7 A$printfl$915 02E0 GR + 7 A$printfl$916 02E2 GR + 7 A$printfl$917 02E4 GR + 7 A$printfl$918 02E6 GR + 7 A$printfl$919 02E7 GR + 7 A$printfl$920 02EA GR + 7 A$printfl$921 02EC GR + 7 A$printfl$922 02EE GR + 7 A$printfl$923 02F0 GR + 7 A$printfl$924 02F1 GR + 7 A$printfl$925 02F4 GR + 7 A$printfl$926 02F5 GR + 7 A$printfl$927 02F6 GR + 7 A$printfl$928 02F7 GR + 7 A$printfl$929 02F8 GR + 7 A$printfl$930 02F9 GR + 7 A$printfl$931 02FA GR + 7 A$printfl$932 02FB GR + 7 A$printfl$933 02FC GR + 7 A$printfl$934 02FD GR + 7 A$printfl$935 02FE GR + 7 A$printfl$936 02FF GR + 7 A$printfl$940 0302 GR + 7 A$printfl$943 0305 GR + 7 A$printfl$945 0308 GR + 7 A$printfl$948 030A GR + 7 A$printfl$949 030C GR + 7 A$printfl$951 030F GR + 7 A$printfl$954 0311 GR + 7 A$printfl$956 0313 GR + 7 A$printfl$957 0316 GR + 7 A$printfl$959 0319 GR + 7 A$printfl$963 031B GR + 7 A$printfl$970 031C GR + 7 A$printfl$971 031E GR + 7 A$printfl$972 0321 GR + 7 A$printfl$974 0323 GR + 7 A$printfl$975 0325 GR + 7 A$printfl$976 0327 GR + 7 A$printfl$978 0328 GR + 7 A$printfl$979 0329 GR + 7 A$printfl$980 032A GR + 7 A$printfl$982 032B GR + 7 A$printfl$983 032D GR + 7 A$printfl$984 032E GR + 7 A$printfl$987 0330 GR + 7 A$printfl$988 0332 GR + 7 A$printfl$989 0334 GR + 7 A$printfl$990 0335 GR + 7 A$printfl$991 0337 GR + 7 A$printfl$992 0338 GR + 7 A$printfl$993 033A GR + 7 A$printfl$994 033B GR + 7 A$printfl$995 033D GR + 7 A$printfl$996 033F GR + 7 A$printfl$997 0341 GR + 7 A$printfl$998 0343 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$printfl.c$111$1$1 = 0218 GR + 7 C$printfl.c$142$1$1 = 031B GR + 7 C$printfl.c$214$1$1 = 0531 GR + 7 C$printfl.c$75$1$1 = 00D6 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 Fprintfl$_str_0$0$0 = 0532 GR + 1 Fprintfl$ch$0$0 = 0000 GR + 4 Fprintfl$long_flag$0$0 = 0000 GR + 7 Fprintfl$pvaldec$0$0 = 0219 GR + 7 Fprintfl$pvalhex$0$0 = 0000 GR + 7 Fprintfl$pvaloct$0$0 = 00D7 GR + 1 Fprintfl$radix$0$0 = 0001 GR + 4 Fprintfl$short_flag$0$0 = 0002 GR + 4 Fprintfl$sign$0$0 = 0003 GR + 1 Fprintfl$str$0$0 = 0002 GR + 4 Fprintfl$string_flag$0$0 = 0001 GR + 1 Fprintfl$val$0$0 = 0005 GR + G$AC$0$0 = 00D6 G + G$ACC$0$0 = 00E0 G + G$AUXR$0$0 = 008E G + G$B$0$0 = 00F0 G + G$CY$0$0 = 00D7 G + G$DPH$0$0 = 0083 G + G$DPL$0$0 = 0082 G + G$EA$0$0 = 00AF G + G$ES$0$0 = 00AC G + G$ET0$0$0 = 00A9 G + G$ET1$0$0 = 00AB G + G$EX0$0$0 = 00A8 G + G$EX1$0$0 = 00AA G + G$F0$0$0 = 00D5 G + G$IE$0$0 = 00A8 G + G$IE0$0$0 = 0089 G + G$IE1$0$0 = 008B G + G$INT0$0$0 = 00B2 G + G$INT1$0$0 = 00B3 G + G$IP$0$0 = 00B8 G + G$IT0$0$0 = 0088 G + G$IT1$0$0 = 008A G + G$OV$0$0 = 00D2 G + G$P$0$0 = 00D0 G + G$P0$0$0 = 0080 G + G$P1$0$0 = 0090 G + G$P1_0$0$0 = 0090 G + G$P1_1$0$0 = 0091 G + G$P1_2$0$0 = 0092 G + G$P1_3$0$0 = 0093 G + G$P1_4$0$0 = 0094 G + G$P1_5$0$0 = 0095 G + G$P1_6$0$0 = 0096 G + G$P1_7$0$0 = 0097 G + G$P2$0$0 = 00A0 G + G$P3$0$0 = 00B0 G + G$PCON$0$0 = 0087 G + G$PS$0$0 = 00BC G + G$PSW$0$0 = 00D0 G + G$PT0$0$0 = 00B9 G + G$PT1$0$0 = 00BB G + G$PX0$0$0 = 00B8 G + G$PX1$0$0 = 00BA G + G$RB8$0$0 = 009A G + G$RCAP2H$0$0 = 00CB G + G$RCAP2L$0$0 = 00CA G + G$RD$0$0 = 00B7 G + G$REN$0$0 = 009C G + G$RI$0$0 = 0098 G + G$RS0$0$0 = 00D3 G + G$RS1$0$0 = 00D4 G + G$RXD$0$0 = 00B0 G + G$SBUF$0$0 = 0099 G + G$SCON$0$0 = 0098 G + G$SM0$0$0 = 009F G + G$SM1$0$0 = 009E G + G$SM2$0$0 = 009D G + G$SP$0$0 = 0081 G + G$T0$0$0 = 00B4 G + G$T1$0$0 = 00B5 G + G$T2CON$0$0 = 00C8 G + G$T2CON_0$0$0 = 00C8 G + G$T2CON_1$0$0 = 00C9 G + G$T2CON_2$0$0 = 00CA G + G$T2CON_3$0$0 = 00CB G + G$T2CON_4$0$0 = 00CC G + G$T2CON_5$0$0 = 00CD G + G$T2CON_6$0$0 = 00CE G + G$T2CON_7$0$0 = 00CF G + G$TB8$0$0 = 009B G + G$TCON$0$0 = 0088 G + G$TF0$0$0 = 008D G + G$TF1$0$0 = 008F G + G$TH0$0$0 = 008C G + G$TH1$0$0 = 008D G + G$TI$0$0 = 0099 G + G$TL0$0$0 = 008A G + G$TL1$0$0 = 008B G + G$TMOD$0$0 = 0089 G + G$TR0$0$0 = 008C G + G$TR1$0$0 = 008E G + G$TXD$0$0 = 00B1 G + G$WR$0$0 = 00B6 G + 7 G$printf_small$0$0 = 031C GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XFprintfl$pvaldec$0$0 = 031B GR + 7 XFprintfl$pvalhex$0$0 = 00D6 GR + 7 XFprintfl$pvaloct$0$0 = 0218 GR + 7 XG$printf_small$0$0 = 0531 GR + _AC = 00D6 + _ACC = 00E0 + _AUXR = 008E + _B = 00F0 + _CY = 00D7 + _DPH = 0083 + _DPL = 0082 + _EA = 00AF + _ES = 00AC + _ET0 = 00A9 + _ET1 = 00AB + _EX0 = 00A8 + _EX1 = 00AA + _F0 = 00D5 + _IE = 00A8 + _IE0 = 0089 + _IE1 = 008B + _INT0 = 00B2 + _INT1 = 00B3 + _IP = 00B8 + _IT0 = 0088 + _IT1 = 008A + _OV = 00D2 + _P = 00D0 + _P0 = 0080 + _P1 = 0090 + _P1_0 = 0090 + _P1_1 = 0091 + _P1_2 = 0092 + _P1_3 = 0093 + _P1_4 = 0094 + _P1_5 = 0095 + _P1_6 = 0096 + _P1_7 = 0097 + _P2 = 00A0 + _P3 = 00B0 + _PCON = 0087 + _PS = 00BC + _PSW = 00D0 + _PT0 = 00B9 + _PT1 = 00BB + _PX0 = 00B8 + _PX1 = 00BA + _RB8 = 009A + _RCAP2H = 00CB + _RCAP2L = 00CA + _RD = 00B7 + _REN = 009C + _RI = 0098 + _RS0 = 00D3 + _RS1 = 00D4 + _RXD = 00B0 + _SBUF = 0099 + _SCON = 0098 + _SM0 = 009F + _SM1 = 009E + _SM2 = 009D + _SP = 0081 + _T0 = 00B4 + _T1 = 00B5 + _T2CON = 00C8 + _T2CON_0 = 00C8 + _T2CON_1 = 00C9 + _T2CON_2 = 00CA + _T2CON_3 = 00CB + _T2CON_4 = 00CC + _T2CON_5 = 00CD + _T2CON_6 = 00CE + _T2CON_7 = 00CF + _TB8 = 009B + _TCON = 0088 + _TF0 = 008D + _TF1 = 008F + _TH0 = 008C + _TH1 = 008D + _TI = 0099 + _TL0 = 008A + _TL1 = 008B + _TMOD = 0089 + _TR0 = 008C + _TR1 = 008E + _TXD = 00B1 + _WR = 00B6 + __decdptr **** GX + __divulong **** GX + __divulong_PARM_2 **** GX + __gptrget **** GX + __modulong **** GX + __modulong_PARM_2 **** GX + 7 __str_0 0532 R + _bp **** GX + 1 _ch 0000 R + 4 _long_flag 0000 R + 7 _printf_small 031C GR + 1 _printf_small_sloc0_1_0 000D R + 1 _printf_small_sloc1_1_0 000E R + _putchar **** GX + 7 _pvaldec 0219 R + 5 _pvaldec_lval_1_1 0015 R + 5 _pvaldec_val_1_1 0011 R + 7 _pvalhex 0000 R + 5 _pvalhex_lval_1_1 0005 R + 5 _pvalhex_sp_1_1 0004 R + 5 _pvalhex_val_1_1 0000 R + 7 _pvaloct 00D7 R + 5 _pvaloct_lval_1_1 000D R + 1 _pvaloct_sloc0_1_0 0009 R + 5 _pvaloct_val_1_1 0009 R + 1 _radix 0001 R + 4 _short_flag 0002 R + 4 _sign 0003 R + 1 _str 0002 R + 4 _string_flag 0001 R + 1 _val 0005 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 11 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 4 flags 80 + 5 XSEG size 19 flags 40 + 6 GSINIT size 6 flags 20 + 7 CSEG size 543 flags 20 diff --git a/device/lib/puts.c b/device/lib/puts.c new file mode 100644 index 00000000..1dae47fa --- /dev/null +++ b/device/lib/puts.c @@ -0,0 +1,36 @@ +/*----------------------------------------------------------------- + puts.c - source file for ANSI Function puts + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +extern void putchar(char); + +int puts (char *s) +{ + int i = 0; + while (*s){ + putchar(*s++); + i++; + } + putchar('\n'); + return i+1; +} diff --git a/device/lib/puts.lst b/device/lib/puts.lst new file mode 100644 index 00000000..6b77e4de --- /dev/null +++ b/device/lib/puts.lst @@ -0,0 +1,148 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:39 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module puts + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _puts + 11 ;-------------------------------------------------------- + 12 ; special function registers + 13 ;-------------------------------------------------------- + 14 ;-------------------------------------------------------- + 15 ; special function bits + 16 ;-------------------------------------------------------- + 17 ;-------------------------------------------------------- + 18 ; internal ram data + 19 ;-------------------------------------------------------- + 20 .area DSEG (DATA) + 21 ;-------------------------------------------------------- + 22 ; overlayable items in internal ram + 23 ;-------------------------------------------------------- + 24 .area OSEG (OVR,DATA) + 25 ;-------------------------------------------------------- + 26 ; indirectly addressable internal ram data + 27 ;-------------------------------------------------------- + 28 .area ISEG (DATA) + 29 ;-------------------------------------------------------- + 30 ; bit data + 31 ;-------------------------------------------------------- + 32 .area BSEG (BIT) + 33 ;-------------------------------------------------------- + 34 ; external ram data + 35 ;-------------------------------------------------------- + 36 .area XSEG (XDATA) + 0000 37 _puts_s_1_1: + 0000 38 .ds 0x0003 + 39 ;-------------------------------------------------------- + 40 ; global & static initialisations + 41 ;-------------------------------------------------------- + 42 .area GSINIT (CODE) + 43 ;-------------------------------------------------------- + 44 ; code + 45 ;-------------------------------------------------------- + 46 .area CSEG (CODE) + 0000 47 G$puts$0$0 ==. + 48 ; puts.c 27 + 49 ; ----------------------------------------- + 50 ; function puts + 51 ; ----------------------------------------- + 0000 52 _puts: + 0002 53 ar2 = 0x02 + 0003 54 ar3 = 0x03 + 0004 55 ar4 = 0x04 + 0005 56 ar5 = 0x05 + 0006 57 ar6 = 0x06 + 0007 58 ar7 = 0x07 + 0000 59 ar0 = 0x00 + 0001 60 ar1 = 0x01 + 61 ; puts.c 35 + 0000 C0 F0 62 push b + 0002 C0 83 63 push dph + 0004 C0 82 64 push dpl + 0006 90s00r00 65 mov dptr,#_puts_s_1_1 + 0009 D0 E0 66 pop acc + 000B F0 67 movx @dptr,a + 000C D0 E0 68 pop acc + 000E A3 69 inc dptr + 000F F0 70 movx @dptr,a + 0010 D0 E0 71 pop acc + 0012 A3 72 inc dptr + 0013 F0 73 movx @dptr,a + 74 ; puts.c 30 + 0014 90s00r00 75 mov dptr,#_puts_s_1_1 + 0017 E0 76 movx a,@dptr + 0018 FA 77 mov r2,a + 0019 A3 78 inc dptr + 001A E0 79 movx a,@dptr + 001B FB 80 mov r3,a + 001C A3 81 inc dptr + 001D E0 82 movx a,@dptr + 001E FC 83 mov r4,a + 001F 7D 00 84 mov r5,#0x00 + 0021 7E 00 85 mov r6,#0x00 + 0023 86 00101$: + 0023 8A 82 87 mov dpl,r2 + 0025 8B 83 88 mov dph,r3 + 0027 8C F0 89 mov b,r4 + 0029 12s00r00 90 lcall __gptrget + 002C FF 91 mov r7,a + 002D 90s00r00 92 mov dptr,#_puts_s_1_1 + 0030 EA 93 mov a,r2 + 0031 F0 94 movx @dptr,a + 0032 A3 95 inc dptr + 0033 EB 96 mov a,r3 + 0034 F0 97 movx @dptr,a + 0035 A3 98 inc dptr + 0036 EC 99 mov a,r4 + 0037 F0 100 movx @dptr,a + 0038 EF 101 mov a,r7 + 102 ; Peephole 110 removed ljmp by inverse jump logic + 0039 60 25 103 jz 00103$ + 003B 104 00108$: + 105 ; puts.c 31 + 003B 0A 106 inc r2 + 003C BA 00 01 107 cjne r2,#0x00,00109$ + 003F 0B 108 inc r3 + 0040 109 00109$: + 0040 C0 02 110 push ar2 + 0042 C0 03 111 push ar3 + 0044 C0 04 112 push ar4 + 0046 C0 05 113 push ar5 + 0048 C0 06 114 push ar6 + 004A 8F 82 115 mov dpl,r7 + 004C 12s00r00 116 lcall _putchar + 004F D0 06 117 pop ar6 + 0051 D0 05 118 pop ar5 + 0053 D0 04 119 pop ar4 + 0055 D0 03 120 pop ar3 + 0057 D0 02 121 pop ar2 + 122 ; puts.c 32 + 0059 0D 123 inc r5 + 005A BD 00 01 124 cjne r5,#0x00,00110$ + 005D 0E 125 inc r6 + 005E 126 00110$: + 127 ; Peephole 132 changed ljmp to sjmp + 005E 80 C3 128 sjmp 00101$ + 0060 129 00103$: + 130 ; puts.c 34 + 0060 C0 05 131 push ar5 + 0062 C0 06 132 push ar6 + 0064 75 82 0A 133 mov dpl,#0x0a + 0067 12s00r00 134 lcall _putchar + 006A D0 06 135 pop ar6 + 006C D0 05 136 pop ar5 + 137 ; puts.c 35 + 006E 0D 138 inc r5 + 006F BD 00 01 139 cjne r5,#0x00,00111$ + 0072 0E 140 inc r6 + 0073 141 00111$: + 0073 8D 82 142 mov dpl,r5 + 0075 8E 83 143 mov dph,r6 + 0077 144 00104$: + 0077 145 C$puts.c$36$1$1 ==. + 0077 146 XG$puts$0$0 ==. + 0077 22 147 ret + 148 .area CSEG (CODE) diff --git a/device/lib/puts.sym b/device/lib/puts.sym new file mode 100644 index 00000000..798e19d3 --- /dev/null +++ b/device/lib/puts.sym @@ -0,0 +1,438 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$puts$100 0037 GR + 7 A$puts$101 0038 GR + 7 A$puts$103 0039 GR + 7 A$puts$106 003B GR + 7 A$puts$107 003C GR + 7 A$puts$108 003F GR + 7 A$puts$110 0040 GR + 7 A$puts$111 0042 GR + 7 A$puts$112 0044 GR + 7 A$puts$113 0046 GR + 7 A$puts$114 0048 GR + 7 A$puts$115 004A GR + 7 A$puts$116 004C GR + 7 A$puts$117 004F GR + 7 A$puts$118 0051 GR + 7 A$puts$119 0053 GR + 7 A$puts$120 0055 GR + 7 A$puts$121 0057 GR + 7 A$puts$123 0059 GR + 7 A$puts$124 005A GR + 7 A$puts$125 005D GR + 7 A$puts$128 005E GR + 7 A$puts$131 0060 GR + 7 A$puts$132 0062 GR + 7 A$puts$133 0064 GR + 7 A$puts$134 0067 GR + 7 A$puts$135 006A GR + 7 A$puts$136 006C GR + 7 A$puts$138 006E GR + 7 A$puts$139 006F GR + 7 A$puts$140 0072 GR + 7 A$puts$142 0073 GR + 7 A$puts$143 0075 GR + 7 A$puts$147 0077 GR + 7 A$puts$62 0000 GR + 7 A$puts$63 0002 GR + 7 A$puts$64 0004 GR + 7 A$puts$65 0006 GR + 7 A$puts$66 0009 GR + 7 A$puts$67 000B GR + 7 A$puts$68 000C GR + 7 A$puts$69 000E GR + 7 A$puts$70 000F GR + 7 A$puts$71 0010 GR + 7 A$puts$72 0012 GR + 7 A$puts$73 0013 GR + 7 A$puts$75 0014 GR + 7 A$puts$76 0017 GR + 7 A$puts$77 0018 GR + 7 A$puts$78 0019 GR + 7 A$puts$79 001A GR + 7 A$puts$80 001B GR + 7 A$puts$81 001C GR + 7 A$puts$82 001D GR + 7 A$puts$83 001E GR + 7 A$puts$84 001F GR + 7 A$puts$85 0021 GR + 7 A$puts$87 0023 GR + 7 A$puts$88 0025 GR + 7 A$puts$89 0027 GR + 7 A$puts$90 0029 GR + 7 A$puts$91 002C GR + 7 A$puts$92 002D GR + 7 A$puts$93 0030 GR + 7 A$puts$94 0031 GR + 7 A$puts$95 0032 GR + 7 A$puts$96 0033 GR + 7 A$puts$97 0034 GR + 7 A$puts$98 0035 GR + 7 A$puts$99 0036 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$puts.c$36$1$1 = 0077 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 G$puts$0$0 = 0000 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$puts$0$0 = 0077 GR + __gptrget **** GX + _putchar **** GX + 7 _puts 0000 GR + 5 _puts_s_1_1 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 3 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 78 flags 20 diff --git a/device/lib/ser_ir.c b/device/lib/ser_ir.c new file mode 100644 index 00000000..d351ff3d --- /dev/null +++ b/device/lib/ser_ir.c @@ -0,0 +1,141 @@ +/*------------------------------------------------------------------------- + ser_ir.c - source file for serial routines + + Written By - Josef Wolf (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + +-------------------------------------------------------------------------*/ +#include "ser_ir.h" + +/* This file implements a serial interrupt handler and its supporting +* routines. Compared with the existing serial.c and _ser.c it has +* following advantages: +* - You can specify arbitrary buffer sizes (umm, up to 255 bytes), +* so it can run on devices with _little_ memory like at89cx051. +* - It won't overwrite characters which already are stored in the +* receive-/transmit-buffer. +* - It checks receiver first to minimize probability for overruns +* in the serial receiver. +*/ + +/* BUG: those definitions (and the #include) should be set dynamically +* (while linking or at runtime) to make this file a _real_ library. +*/ +#include +#define XBUFLEN 10 +#define RBUFLEN 10 + +static unsigned char rbuf[RBUFLEN], xbuf[XBUFLEN]; +static unsigned char rcnt, xcnt, rpos, xpos; +static unsigned char busy; + +void ser_init (void) +{ + ES = 0; + rcnt = xcnt = rpos = xpos = 0; /* init buffers */ + busy = 0; + SCON = 0x50; + PCON |= 0x80; /* SMOD = 1; */ + TMOD &= 0x0f; /* use timer 1 */ + TMOD |= 0x20; + TL1 = -3; TH1 = -3; TR1 = 1; /* 19200bps with 11.059MHz crystal */ + ES = 1; +} + +void ser_handler (void) interrupt 4 +{ + if (RI) { + RI = 0; + /* don't overwrite chars already in buffer */ + if (rcnt < RBUFLEN) + rbuf [(rpos+rcnt++) % RBUFLEN] = SBUF; + } + if (TI) { + TI = 0; + if (busy = xcnt) { /* Assignment, _not_ comparison! */ + xcnt--; + SBUF = xbuf [xpos++]; + if (xpos >= XBUFLEN) + xpos = 0; + } + } +} + +void ser_putc (unsigned char c) +{ + while (xcnt >= XBUFLEN) /* wait for room in buffer */ + ; + ES = 0; + if (busy) { + xbuf[(xpos+xcnt++) % XBUFLEN] = c; + } else { + SBUF = c; + busy = 1; + } + ES = 1; +} + +unsigned char ser_getc (void) +{ + unsigned char c; + while (!rcnt) /* wait for character */ + ; + ES = 0; + rcnt--; + c = rbuf [rpos++]; + if (rpos >= RBUFLEN) + rpos = 0; + ES = 1; + return (c); +} +#pragma SAVE +#pragma NOINDUCTION +void ser_puts (unsigned char *s) +{ + unsigned char c; + while (c=*s++) { + if (c == '\n') ser_putc ('\r'); + ser_putc (c); + } +} +#pragma RESTORE +void ser_gets (unsigned char *s, unsigned char len) +{ + unsigned char pos, c; + + pos = 0; + while (pos <= len) { + c = ser_getc (); + if (c == '\r') continue; /* discard CR's */ + s[pos++] = c; + if (c == '\n') break; /* NL terminates */ + } + s[pos] = '\0'; +} + +unsigned char ser_can_xmt (void) +{ + return XBUFLEN - xcnt; +} + +unsigned char ser_can_rcv (void) +{ + return rcnt; +} diff --git a/device/lib/ser_ir.lst b/device/lib/ser_ir.lst new file mode 100644 index 00000000..3670a6d2 --- /dev/null +++ b/device/lib/ser_ir.lst @@ -0,0 +1,765 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:36 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module ser_ir + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _ser_handler + 11 .globl _ser_can_xmt + 12 .globl _ser_can_rcv + 13 .globl _ser_getc + 14 .globl _ser_gets + 15 .globl _ser_puts + 16 .globl _ser_putc + 17 .globl _ser_init + 18 .globl _ser_gets_PARM_2 + 19 ;-------------------------------------------------------- + 20 ; special function registers + 21 ;-------------------------------------------------------- + 0081 22 G$SP$0$0 == 0x0081 + 0081 23 _SP = 0x0081 + 0082 24 G$DPL$0$0 == 0x0082 + 0082 25 _DPL = 0x0082 + 0083 26 G$DPH$0$0 == 0x0083 + 0083 27 _DPH = 0x0083 + 0087 28 G$PCON$0$0 == 0x0087 + 0087 29 _PCON = 0x0087 + 0088 30 G$TCON$0$0 == 0x0088 + 0088 31 _TCON = 0x0088 + 0089 32 G$TMOD$0$0 == 0x0089 + 0089 33 _TMOD = 0x0089 + 008A 34 G$TL0$0$0 == 0x008a + 008A 35 _TL0 = 0x008a + 008B 36 G$TL1$0$0 == 0x008b + 008B 37 _TL1 = 0x008b + 008C 38 G$TH0$0$0 == 0x008c + 008C 39 _TH0 = 0x008c + 008D 40 G$TH1$0$0 == 0x008d + 008D 41 _TH1 = 0x008d + 0090 42 G$P1$0$0 == 0x0090 + 0090 43 _P1 = 0x0090 + 0098 44 G$SCON$0$0 == 0x0098 + 0098 45 _SCON = 0x0098 + 0099 46 G$SBUF$0$0 == 0x0099 + 0099 47 _SBUF = 0x0099 + 00A8 48 G$IE$0$0 == 0x00a8 + 00A8 49 _IE = 0x00a8 + 00B0 50 G$P3$0$0 == 0x00b0 + 00B0 51 _P3 = 0x00b0 + 00B8 52 G$IP$0$0 == 0x00b8 + 00B8 53 _IP = 0x00b8 + 00D0 54 G$PSW$0$0 == 0x00d0 + 00D0 55 _PSW = 0x00d0 + 00E0 56 G$ACC$0$0 == 0x00e0 + 00E0 57 _ACC = 0x00e0 + 00E0 58 G$A$0$0 == 0x00e0 + 00E0 59 _A = 0x00e0 + 00F0 60 G$B$0$0 == 0x00f0 + 00F0 61 _B = 0x00f0 + 62 ;-------------------------------------------------------- + 63 ; special function bits + 64 ;-------------------------------------------------------- + 0088 65 G$IT0$0$0 == 0x0088 + 0088 66 _IT0 = 0x0088 + 0089 67 G$IE0$0$0 == 0x0089 + 0089 68 _IE0 = 0x0089 + 008A 69 G$IT1$0$0 == 0x008a + 008A 70 _IT1 = 0x008a + 008B 71 G$IE1$0$0 == 0x008b + 008B 72 _IE1 = 0x008b + 008C 73 G$TR0$0$0 == 0x008c + 008C 74 _TR0 = 0x008c + 008D 75 G$TF0$0$0 == 0x008d + 008D 76 _TF0 = 0x008d + 008E 77 G$TR1$0$0 == 0x008e + 008E 78 _TR1 = 0x008e + 008F 79 G$TF1$0$0 == 0x008f + 008F 80 _TF1 = 0x008f + 0090 81 G$P1_0$0$0 == 0x0090 + 0090 82 _P1_0 = 0x0090 + 0091 83 G$P1_1$0$0 == 0x0091 + 0091 84 _P1_1 = 0x0091 + 0092 85 G$P1_2$0$0 == 0x0092 + 0092 86 _P1_2 = 0x0092 + 0093 87 G$P1_3$0$0 == 0x0093 + 0093 88 _P1_3 = 0x0093 + 0094 89 G$P1_4$0$0 == 0x0094 + 0094 90 _P1_4 = 0x0094 + 0095 91 G$P1_5$0$0 == 0x0095 + 0095 92 _P1_5 = 0x0095 + 0096 93 G$P1_6$0$0 == 0x0096 + 0096 94 _P1_6 = 0x0096 + 0097 95 G$P1_7$0$0 == 0x0097 + 0097 96 _P1_7 = 0x0097 + 0090 97 G$AIN0$0$0 == 0x0090 + 0090 98 _AIN0 = 0x0090 + 0091 99 G$AIN1$0$0 == 0x0091 + 0091 100 _AIN1 = 0x0091 + 0098 101 G$RI$0$0 == 0x0098 + 0098 102 _RI = 0x0098 + 0099 103 G$TI$0$0 == 0x0099 + 0099 104 _TI = 0x0099 + 009A 105 G$RB8$0$0 == 0x009a + 009A 106 _RB8 = 0x009a + 009B 107 G$TB8$0$0 == 0x009b + 009B 108 _TB8 = 0x009b + 009C 109 G$REN$0$0 == 0x009c + 009C 110 _REN = 0x009c + 009D 111 G$SM2$0$0 == 0x009d + 009D 112 _SM2 = 0x009d + 009E 113 G$SM1$0$0 == 0x009e + 009E 114 _SM1 = 0x009e + 009F 115 G$SM0$0$0 == 0x009f + 009F 116 _SM0 = 0x009f + 00A8 117 G$EX0$0$0 == 0x00a8 + 00A8 118 _EX0 = 0x00a8 + 00A9 119 G$ET0$0$0 == 0x00a9 + 00A9 120 _ET0 = 0x00a9 + 00AA 121 G$EX1$0$0 == 0x00aa + 00AA 122 _EX1 = 0x00aa + 00AB 123 G$ET1$0$0 == 0x00ab + 00AB 124 _ET1 = 0x00ab + 00AC 125 G$ES$0$0 == 0x00ac + 00AC 126 _ES = 0x00ac + 00AD 127 G$ET2$0$0 == 0x00ad + 00AD 128 _ET2 = 0x00ad + 00AF 129 G$EA$0$0 == 0x00af + 00AF 130 _EA = 0x00af + 00B0 131 G$P3_0$0$0 == 0x00b0 + 00B0 132 _P3_0 = 0x00b0 + 00B1 133 G$P3_1$0$0 == 0x00b1 + 00B1 134 _P3_1 = 0x00b1 + 00B2 135 G$P3_2$0$0 == 0x00b2 + 00B2 136 _P3_2 = 0x00b2 + 00B3 137 G$P3_3$0$0 == 0x00b3 + 00B3 138 _P3_3 = 0x00b3 + 00B4 139 G$P3_4$0$0 == 0x00b4 + 00B4 140 _P3_4 = 0x00b4 + 00B5 141 G$P3_5$0$0 == 0x00b5 + 00B5 142 _P3_5 = 0x00b5 + 00B7 143 G$P3_7$0$0 == 0x00b7 + 00B7 144 _P3_7 = 0x00b7 + 00B0 145 G$RXD$0$0 == 0x00b0 + 00B0 146 _RXD = 0x00b0 + 00B1 147 G$TXD$0$0 == 0x00b1 + 00B1 148 _TXD = 0x00b1 + 00B2 149 G$INT0$0$0 == 0x00b2 + 00B2 150 _INT0 = 0x00b2 + 00B3 151 G$INT1$0$0 == 0x00b3 + 00B3 152 _INT1 = 0x00b3 + 00B4 153 G$T0$0$0 == 0x00b4 + 00B4 154 _T0 = 0x00b4 + 00B5 155 G$T1$0$0 == 0x00b5 + 00B5 156 _T1 = 0x00b5 + 00B6 157 G$AOUT$0$0 == 0x00b6 + 00B6 158 _AOUT = 0x00b6 + 00B8 159 G$PX0$0$0 == 0x00b8 + 00B8 160 _PX0 = 0x00b8 + 00B9 161 G$PT0$0$0 == 0x00b9 + 00B9 162 _PT0 = 0x00b9 + 00BA 163 G$PX1$0$0 == 0x00ba + 00BA 164 _PX1 = 0x00ba + 00BB 165 G$PT1$0$0 == 0x00bb + 00BB 166 _PT1 = 0x00bb + 00BC 167 G$PS$0$0 == 0x00bc + 00BC 168 _PS = 0x00bc + 00D0 169 G$P$0$0 == 0x00d0 + 00D0 170 _P = 0x00d0 + 00D1 171 G$FL$0$0 == 0x00d1 + 00D1 172 _FL = 0x00d1 + 00D2 173 G$OV$0$0 == 0x00d2 + 00D2 174 _OV = 0x00d2 + 00D3 175 G$RS0$0$0 == 0x00d3 + 00D3 176 _RS0 = 0x00d3 + 00D4 177 G$RS1$0$0 == 0x00d4 + 00D4 178 _RS1 = 0x00d4 + 00D5 179 G$F0$0$0 == 0x00d5 + 00D5 180 _F0 = 0x00d5 + 00D6 181 G$AC$0$0 == 0x00d6 + 00D6 182 _AC = 0x00d6 + 00D7 183 G$CY$0$0 == 0x00d7 + 00D7 184 _CY = 0x00d7 + 185 ;-------------------------------------------------------- + 186 ; internal ram data + 187 ;-------------------------------------------------------- + 188 .area DSEG (DATA) + 189 ;-------------------------------------------------------- + 190 ; overlayable items in internal ram + 191 ;-------------------------------------------------------- + 192 .area OSEG (OVR,DATA) + 193 ;-------------------------------------------------------- + 194 ; indirectly addressable internal ram data + 195 ;-------------------------------------------------------- + 196 .area ISEG (DATA) + 197 ;-------------------------------------------------------- + 198 ; bit data + 199 ;-------------------------------------------------------- + 200 .area BSEG (BIT) + 201 ;-------------------------------------------------------- + 202 ; external ram data + 203 ;-------------------------------------------------------- + 204 .area XSEG (XDATA) + 0000 205 Fser_ir$rbuf$0$0==. + 0000 206 _rbuf: + 0000 207 .ds 0x000a + 000A 208 Fser_ir$xbuf$0$0==. + 000A 209 _xbuf: + 000A 210 .ds 0x000a + 0014 211 Fser_ir$rcnt$0$0==. + 0014 212 _rcnt: + 0014 213 .ds 0x0001 + 0015 214 Fser_ir$xcnt$0$0==. + 0015 215 _xcnt: + 0015 216 .ds 0x0001 + 0016 217 Fser_ir$rpos$0$0==. + 0016 218 _rpos: + 0016 219 .ds 0x0001 + 0017 220 Fser_ir$xpos$0$0==. + 0017 221 _xpos: + 0017 222 .ds 0x0001 + 0018 223 Fser_ir$busy$0$0==. + 0018 224 _busy: + 0018 225 .ds 0x0001 + 0019 226 _ser_putc_c_1_1: + 0019 227 .ds 0x0001 + 001A 228 _ser_puts_s_1_1: + 001A 229 .ds 0x0003 + 001D 230 _ser_gets_PARM_2: + 001D 231 .ds 0x0001 + 001E 232 _ser_gets_s_1_1: + 001E 233 .ds 0x0003 + 234 ;-------------------------------------------------------- + 235 ; global & static initialisations + 236 ;-------------------------------------------------------- + 237 .area GSINIT (CODE) + 238 ;-------------------------------------------------------- + 239 ; code + 240 ;-------------------------------------------------------- + 241 .area CSEG (CODE) + 0000 242 G$ser_init$0$0 ==. + 243 ; ser_ir.c 49 + 244 ; ----------------------------------------- + 245 ; function ser_init + 246 ; ----------------------------------------- + 0000 247 _ser_init: + 0002 248 ar2 = 0x02 + 0003 249 ar3 = 0x03 + 0004 250 ar4 = 0x04 + 0005 251 ar5 = 0x05 + 0006 252 ar6 = 0x06 + 0007 253 ar7 = 0x07 + 0000 254 ar0 = 0x00 + 0001 255 ar1 = 0x01 + 256 ; ser_ir.c 51 + 0000 C2 AC 257 clr _ES + 258 ; ser_ir.c 52 + 0002 90s00r17 259 mov dptr,#_xpos + 260 ; Peephole 180 changed mov to clr + 0005 E4 261 clr a + 0006 F0 262 movx @dptr,a + 0007 90s00r16 263 mov dptr,#_rpos + 264 ; Peephole 180 changed mov to clr + 000A E4 265 clr a + 000B F0 266 movx @dptr,a + 000C 90s00r15 267 mov dptr,#_xcnt + 268 ; Peephole 180 changed mov to clr + 000F E4 269 clr a + 0010 F0 270 movx @dptr,a + 0011 90s00r14 271 mov dptr,#_rcnt + 272 ; Peephole 180 changed mov to clr + 0014 E4 273 clr a + 0015 F0 274 movx @dptr,a + 275 ; ser_ir.c 53 + 0016 90s00r18 276 mov dptr,#_busy + 277 ; Peephole 180 changed mov to clr + 0019 E4 278 clr a + 001A F0 279 movx @dptr,a + 280 ; ser_ir.c 54 + 001B 75 98 50 281 mov _SCON,#0x50 + 282 ; ser_ir.c 55 + 001E 43 87 80 283 orl _PCON,#0x80 + 284 ; ser_ir.c 56 + 0021 53 89 0F 285 anl _TMOD,#0x0f + 286 ; ser_ir.c 57 + 0024 43 89 20 287 orl _TMOD,#0x20 + 288 ; ser_ir.c 58 + 0027 75 8B FD 289 mov _TL1,#0xfd + 002A 75 8D FD 290 mov _TH1,#0xfd + 002D D2 8E 291 setb _TR1 + 292 ; ser_ir.c 59 + 002F D2 AC 293 setb _ES + 0031 294 00101$: + 0031 295 C$ser_ir.c$60$1$1 ==. + 0031 296 XG$ser_init$0$0 ==. + 0031 22 297 ret + 0032 298 G$ser_handler$0$0 ==. + 299 ; ser_ir.c 62 + 300 ; ----------------------------------------- + 301 ; function ser_handler + 302 ; ----------------------------------------- + 0032 303 _ser_handler: + 0032 C0 E0 304 push acc + 0034 C0 F0 305 push b + 0036 C0 82 306 push dpl + 0038 C0 83 307 push dph + 003A C0 02 308 push ar2 + 003C C0 03 309 push ar3 + 003E C0 D0 310 push psw + 0040 75 D0 00 311 mov psw,#0x00 + 312 ; ser_ir.c 64 + 313 ; Peephole 111 removed ljmp by inverse jump logic + 0043 30 98 2C 314 jnb _RI,00104$ + 0046 315 00118$: + 316 ; ser_ir.c 65 + 0046 C2 98 317 clr _RI + 318 ; ser_ir.c 67 + 0048 90s00r14 319 mov dptr,#_rcnt + 004B E0 320 movx a,@dptr + 004C FA 321 mov r2,a + 004D BA 0A 00 322 cjne r2,#0x0a,00119$ + 0050 323 00119$: + 324 ; Peephole 108 removed ljmp by inverse jump logic + 0050 50 20 325 jnc 00104$ + 0052 326 00120$: + 327 ; ser_ir.c 68 + 0052 90s00r14 328 mov dptr,#_rcnt + 0055 74 01 329 mov a,#0x01 + 0057 2A 330 add a,r2 + 0058 F0 331 movx @dptr,a + 0059 90s00r16 332 mov dptr,#_rpos + 005C E0 333 movx a,@dptr + 334 ; Peephole 214 reduced some extra movs + 005D FB 335 mov r3,a + 005E 2A 336 add a,r2 + 005F 75 F0 0A 337 mov b,#0x0a + 0062 84 338 div ab + 0063 AA F0 339 mov r2,b + 0065 EA 340 mov a,r2 + 0066 24r00 341 add a,#_rbuf + 0068 F5 82 342 mov dpl,a + 343 ; Peephole 180 changed mov to clr + 006A E4 344 clr a + 006B 34s00 345 addc a,#(_rbuf >> 8) + 006D F5 83 346 mov dph,a + 006F E5 99 347 mov a,_SBUF + 0071 F0 348 movx @dptr,a + 0072 349 00104$: + 350 ; ser_ir.c 70 + 351 ; Peephole 111 removed ljmp by inverse jump logic + 0072 30 99 38 352 jnb _TI,00111$ + 0075 353 00121$: + 354 ; ser_ir.c 71 + 0075 C2 99 355 clr _TI + 356 ; ser_ir.c 72 + 0077 90s00r15 357 mov dptr,#_xcnt + 007A E0 358 movx a,@dptr + 359 ; Peephole 100 removed redundant mov + 007B FA 360 mov r2,a + 007C 90s00r18 361 mov dptr,#_busy + 007F F0 362 movx @dptr,a + 0080 EA 363 mov a,r2 + 364 ; Peephole 110 removed ljmp by inverse jump logic + 0081 60 2A 365 jz 00111$ + 0083 366 00122$: + 367 ; ser_ir.c 73 + 0083 EA 368 mov a,r2 + 0084 24 FF 369 add a,#0xff + 0086 90s00r15 370 mov dptr,#_xcnt + 0089 F0 371 movx @dptr,a + 372 ; ser_ir.c 74 + 008A 90s00r17 373 mov dptr,#_xpos + 008D E0 374 movx a,@dptr + 375 ; Peephole 214 reduced some extra movs + 008E FA 376 mov r2,a + 008F 24 01 377 add a,#0x01 + 378 ; Peephole 100 removed redundant mov + 0091 FB 379 mov r3,a + 0092 90s00r17 380 mov dptr,#_xpos + 0095 F0 381 movx @dptr,a + 0096 EA 382 mov a,r2 + 0097 24r0A 383 add a,#_xbuf + 0099 F5 82 384 mov dpl,a + 385 ; Peephole 180 changed mov to clr + 009B E4 386 clr a + 009C 34s00 387 addc a,#(_xbuf >> 8) + 009E F5 83 388 mov dph,a + 00A0 E0 389 movx a,@dptr + 00A1 F5 99 390 mov _SBUF,a + 391 ; ser_ir.c 75 + 00A3 BB 0A 00 392 cjne r3,#0x0a,00123$ + 00A6 393 00123$: + 394 ; Peephole 132 changed ljmp to sjmp + 395 ; Peephole 160 removed sjmp by inverse jump logic + 00A6 40 05 396 jc 00111$ + 00A8 397 00124$: + 398 ; ser_ir.c 76 + 00A8 90s00r17 399 mov dptr,#_xpos + 400 ; Peephole 180 changed mov to clr + 00AB E4 401 clr a + 00AC F0 402 movx @dptr,a + 00AD 403 00111$: + 00AD D0 D0 404 pop psw + 00AF D0 03 405 pop ar3 + 00B1 D0 02 406 pop ar2 + 00B3 D0 83 407 pop dph + 00B5 D0 82 408 pop dpl + 00B7 D0 F0 409 pop b + 00B9 D0 E0 410 pop acc + 00BB 411 C$ser_ir.c$79$1$1 ==. + 00BB 412 XG$ser_handler$0$0 ==. + 00BB 32 413 reti + 00BC 414 G$ser_putc$0$0 ==. + 415 ; ser_ir.c 81 + 416 ; ----------------------------------------- + 417 ; function ser_putc + 418 ; ----------------------------------------- + 00BC 419 _ser_putc: + 420 ; ser_ir.c 92 + 00BC C0 82 421 push dpl + 00BE 90s00r19 422 mov dptr,#_ser_putc_c_1_1 + 00C1 D0 E0 423 pop acc + 00C3 F0 424 movx @dptr,a + 425 ; ser_ir.c 83 + 00C4 426 00101$: + 00C4 90s00r15 427 mov dptr,#_xcnt + 00C7 E0 428 movx a,@dptr + 00C8 FA 429 mov r2,a + 00C9 BA 0A 00 430 cjne r2,#0x0a,00112$ + 00CC 431 00112$: + 432 ; Peephole 108 removed ljmp by inverse jump logic + 00CC 50 F6 433 jnc 00101$ + 00CE 434 00113$: + 435 ; ser_ir.c 85 + 00CE C2 AC 436 clr _ES + 437 ; ser_ir.c 86 + 00D0 90s00r18 438 mov dptr,#_busy + 00D3 E0 439 movx a,@dptr + 440 ; Peephole 105 removed redundant mov + 00D4 FB 441 mov r3,a + 442 ; Peephole 110 removed ljmp by inverse jump logic + 00D5 60 27 443 jz 00105$ + 00D7 444 00114$: + 445 ; ser_ir.c 87 + 00D7 90s00r15 446 mov dptr,#_xcnt + 00DA 74 01 447 mov a,#0x01 + 00DC 2A 448 add a,r2 + 00DD F0 449 movx @dptr,a + 00DE 90s00r17 450 mov dptr,#_xpos + 00E1 E0 451 movx a,@dptr + 452 ; Peephole 214 reduced some extra movs + 00E2 FB 453 mov r3,a + 00E3 2A 454 add a,r2 + 00E4 75 F0 0A 455 mov b,#0x0a + 00E7 84 456 div ab + 00E8 AA F0 457 mov r2,b + 00EA EA 458 mov a,r2 + 00EB 24r0A 459 add a,#_xbuf + 00ED FA 460 mov r2,a + 461 ; Peephole 180 changed mov to clr + 00EE E4 462 clr a + 00EF 34s00 463 addc a,#(_xbuf >> 8) + 00F1 FB 464 mov r3,a + 00F2 90s00r19 465 mov dptr,#_ser_putc_c_1_1 + 00F5 E0 466 movx a,@dptr + 467 ; Peephole 136 removed redundant moves + 00F6 FC 468 mov r4,a + 00F7 8A 82 469 mov dpl,r2 + 00F9 8B 83 470 mov dph,r3 + 00FB F0 471 movx @dptr,a + 472 ; Peephole 132 changed ljmp to sjmp + 00FC 80 0C 473 sjmp 00106$ + 00FE 474 00105$: + 475 ; ser_ir.c 89 + 00FE 90s00r19 476 mov dptr,#_ser_putc_c_1_1 + 0101 E0 477 movx a,@dptr + 0102 F5 99 478 mov _SBUF,a + 479 ; ser_ir.c 90 + 0104 90s00r18 480 mov dptr,#_busy + 0107 74 01 481 mov a,#0x01 + 0109 F0 482 movx @dptr,a + 010A 483 00106$: + 484 ; ser_ir.c 92 + 010A D2 AC 485 setb _ES + 010C 486 00107$: + 010C 487 C$ser_ir.c$93$1$1 ==. + 010C 488 XG$ser_putc$0$0 ==. + 010C 22 489 ret + 010D 490 G$ser_getc$0$0 ==. + 491 ; ser_ir.c 95 + 492 ; ----------------------------------------- + 493 ; function ser_getc + 494 ; ----------------------------------------- + 010D 495 _ser_getc: + 496 ; ser_ir.c 98 + 010D 497 00101$: + 010D 90s00r14 498 mov dptr,#_rcnt + 0110 E0 499 movx a,@dptr + 500 ; Peephole 105 removed redundant mov + 0111 FA 501 mov r2,a + 502 ; Peephole 110 removed ljmp by inverse jump logic + 0112 60 F9 503 jz 00101$ + 0114 504 00111$: + 505 ; ser_ir.c 100 + 0114 C2 AC 506 clr _ES + 507 ; ser_ir.c 101 + 0116 EA 508 mov a,r2 + 0117 24 FF 509 add a,#0xff + 0119 90s00r14 510 mov dptr,#_rcnt + 011C F0 511 movx @dptr,a + 512 ; ser_ir.c 102 + 011D 90s00r16 513 mov dptr,#_rpos + 0120 E0 514 movx a,@dptr + 515 ; Peephole 214 reduced some extra movs + 0121 FA 516 mov r2,a + 0122 24 01 517 add a,#0x01 + 518 ; Peephole 100 removed redundant mov + 0124 FB 519 mov r3,a + 0125 90s00r16 520 mov dptr,#_rpos + 0128 F0 521 movx @dptr,a + 0129 EA 522 mov a,r2 + 012A 24r00 523 add a,#_rbuf + 012C F5 82 524 mov dpl,a + 525 ; Peephole 180 changed mov to clr + 012E E4 526 clr a + 012F 34s00 527 addc a,#(_rbuf >> 8) + 0131 F5 83 528 mov dph,a + 0133 E0 529 movx a,@dptr + 0134 FA 530 mov r2,a + 531 ; ser_ir.c 103 + 0135 BB 0A 00 532 cjne r3,#0x0a,00112$ + 0138 533 00112$: + 534 ; Peephole 132 changed ljmp to sjmp + 535 ; Peephole 160 removed sjmp by inverse jump logic + 0138 40 05 536 jc 00105$ + 013A 537 00113$: + 538 ; ser_ir.c 104 + 013A 90s00r16 539 mov dptr,#_rpos + 540 ; Peephole 180 changed mov to clr + 013D E4 541 clr a + 013E F0 542 movx @dptr,a + 013F 543 00105$: + 544 ; ser_ir.c 105 + 013F D2 AC 545 setb _ES + 546 ; ser_ir.c 106 + 0141 8A 82 547 mov dpl,r2 + 0143 548 00106$: + 0143 549 C$ser_ir.c$107$1$1 ==. + 0143 550 XG$ser_getc$0$0 ==. + 0143 22 551 ret + 0144 552 G$ser_puts$0$0 ==. + 553 ; ser_ir.c 110 + 554 ; ----------------------------------------- + 555 ; function ser_puts + 556 ; ----------------------------------------- + 0144 557 _ser_puts: + 558 ; ser_ir.c 0 + 0144 C0 F0 559 push b + 0146 C0 83 560 push dph + 0148 C0 82 561 push dpl + 014A 90s00r1A 562 mov dptr,#_ser_puts_s_1_1 + 014D D0 E0 563 pop acc + 014F F0 564 movx @dptr,a + 0150 D0 E0 565 pop acc + 0152 A3 566 inc dptr + 0153 F0 567 movx @dptr,a + 0154 D0 E0 568 pop acc + 0156 A3 569 inc dptr + 0157 F0 570 movx @dptr,a + 571 ; ser_ir.c 113 + 0158 572 00103$: + 0158 90s00r1A 573 mov dptr,#_ser_puts_s_1_1 + 015B E0 574 movx a,@dptr + 015C FA 575 mov r2,a + 015D A3 576 inc dptr + 015E E0 577 movx a,@dptr + 015F FB 578 mov r3,a + 0160 A3 579 inc dptr + 0161 E0 580 movx a,@dptr + 0162 FC 581 mov r4,a + 0163 90s00r1A 582 mov dptr,#_ser_puts_s_1_1 + 0166 74 01 583 mov a,#0x01 + 0168 2A 584 add a,r2 + 0169 F0 585 movx @dptr,a + 586 ; Peephole 180 changed mov to clr + 016A E4 587 clr a + 016B 3B 588 addc a,r3 + 016C A3 589 inc dptr + 016D F0 590 movx @dptr,a + 016E A3 591 inc dptr + 016F EC 592 mov a,r4 + 0170 F0 593 movx @dptr,a + 0171 8A 82 594 mov dpl,r2 + 0173 8B 83 595 mov dph,r3 + 0175 8C F0 596 mov b,r4 + 0177 12s00r00 597 lcall __gptrget + 598 ; Peephole 105 removed redundant mov + 017A FA 599 mov r2,a + 600 ; Peephole 110 removed ljmp by inverse jump logic + 017B 60 14 601 jz 00106$ + 017D 602 00111$: + 603 ; ser_ir.c 114 + 604 ; Peephole 132 changed ljmp to sjmp + 605 ; Peephole 199 optimized misc jump sequence + 017D BA 0A 0A 606 cjne r2,#0x0a,00102$ + 607 ; Peephole 201 removed redundant sjmp + 0180 608 00112$: + 0180 609 00113$: + 0180 C0 02 610 push ar2 + 0182 75 82 0D 611 mov dpl,#0x0d + 0185 12s00rBC 612 lcall _ser_putc + 0188 D0 02 613 pop ar2 + 018A 614 00102$: + 615 ; ser_ir.c 115 + 018A 8A 82 616 mov dpl,r2 + 018C 12s00rBC 617 lcall _ser_putc + 618 ; Peephole 132 changed ljmp to sjmp + 018F 80 C7 619 sjmp 00103$ + 0191 620 00106$: + 0191 621 C$ser_ir.c$117$1$1 ==. + 0191 622 XG$ser_puts$0$0 ==. + 0191 22 623 ret + 0192 624 G$ser_gets$0$0 ==. + 625 ; ser_ir.c 119 + 626 ; ----------------------------------------- + 627 ; function ser_gets + 628 ; ----------------------------------------- + 0192 629 _ser_gets: + 630 ; ser_ir.c 130 + 0192 C0 F0 631 push b + 0194 C0 83 632 push dph + 0196 C0 82 633 push dpl + 0198 90s00r1E 634 mov dptr,#_ser_gets_s_1_1 + 019B D0 E0 635 pop acc + 019D F0 636 movx @dptr,a + 019E D0 E0 637 pop acc + 01A0 A3 638 inc dptr + 01A1 F0 639 movx @dptr,a + 01A2 D0 E0 640 pop acc + 01A4 A3 641 inc dptr + 01A5 F0 642 movx @dptr,a + 643 ; ser_ir.c 124 + 01A6 90s00r1D 644 mov dptr,#_ser_gets_PARM_2 + 01A9 E0 645 movx a,@dptr + 01AA FA 646 mov r2,a + 01AB 90s00r1E 647 mov dptr,#_ser_gets_s_1_1 + 01AE E0 648 movx a,@dptr + 01AF FB 649 mov r3,a + 01B0 A3 650 inc dptr + 01B1 E0 651 movx a,@dptr + 01B2 FC 652 mov r4,a + 01B3 A3 653 inc dptr + 01B4 E0 654 movx a,@dptr + 01B5 FD 655 mov r5,a + 01B6 7E 00 656 mov r6,#0x00 + 01B8 657 00105$: + 01B8 8E 07 658 mov ar7,r6 + 01BA C3 659 clr c + 01BB EA 660 mov a,r2 + 01BC 9E 661 subb a,r6 + 662 ; Peephole 132 changed ljmp to sjmp + 663 ; Peephole 160 removed sjmp by inverse jump logic + 01BD 40 34 664 jc 00107$ + 01BF 665 00113$: + 666 ; ser_ir.c 125 + 01BF C0 02 667 push ar2 + 01C1 C0 03 668 push ar3 + 01C3 C0 04 669 push ar4 + 01C5 C0 05 670 push ar5 + 01C7 C0 06 671 push ar6 + 01C9 C0 07 672 push ar7 + 01CB 12s01r0D 673 lcall _ser_getc + 01CE A8 82 674 mov r0,dpl + 01D0 D0 07 675 pop ar7 + 01D2 D0 06 676 pop ar6 + 01D4 D0 05 677 pop ar5 + 01D6 D0 04 678 pop ar4 + 01D8 D0 03 679 pop ar3 + 01DA D0 02 680 pop ar2 + 681 ; ser_ir.c 126 + 01DC B8 0D 02 682 cjne r0,#0x0d,00114$ + 683 ; Peephole 132 changed ljmp to sjmp + 01DF 80 D7 684 sjmp 00105$ + 01E1 685 00114$: + 686 ; ser_ir.c 127 + 01E1 0E 687 inc r6 + 01E2 EF 688 mov a,r7 + 01E3 2B 689 add a,r3 + 01E4 F5 82 690 mov dpl,a + 691 ; Peephole 180 changed mov to clr + 01E6 E4 692 clr a + 01E7 3C 693 addc a,r4 + 01E8 F5 83 694 mov dph,a + 01EA 8D F0 695 mov b,r5 + 01EC E8 696 mov a,r0 + 01ED 12s00r00 697 lcall __gptrput + 698 ; ser_ir.c 128 + 699 ; Peephole 132 changed ljmp to sjmp + 700 ; Peephole 199 optimized misc jump sequence + 01F0 B8 0A C5 701 cjne r0,#0x0a,00105$ + 702 ; Peephole 201 removed redundant sjmp + 01F3 703 00115$: + 01F3 704 00116$: + 01F3 705 00107$: + 706 ; ser_ir.c 130 + 01F3 90s00r1E 707 mov dptr,#_ser_gets_s_1_1 + 01F6 E0 708 movx a,@dptr + 01F7 FA 709 mov r2,a + 01F8 A3 710 inc dptr + 01F9 E0 711 movx a,@dptr + 01FA FB 712 mov r3,a + 01FB A3 713 inc dptr + 01FC E0 714 movx a,@dptr + 01FD FC 715 mov r4,a + 01FE EE 716 mov a,r6 + 01FF 2A 717 add a,r2 + 0200 F5 82 718 mov dpl,a + 719 ; Peephole 180 changed mov to clr + 0202 E4 720 clr a + 0203 3B 721 addc a,r3 + 0204 F5 83 722 mov dph,a + 0206 8C F0 723 mov b,r4 + 724 ; Peephole 180 changed mov to clr + 0208 E4 725 clr a + 0209 12s00r00 726 lcall __gptrput + 020C 727 00108$: + 020C 728 C$ser_ir.c$131$1$1 ==. + 020C 729 XG$ser_gets$0$0 ==. + 020C 22 730 ret + 020D 731 G$ser_can_xmt$0$0 ==. + 732 ; ser_ir.c 133 + 733 ; ----------------------------------------- + 734 ; function ser_can_xmt + 735 ; ----------------------------------------- + 020D 736 _ser_can_xmt: + 737 ; ser_ir.c 135 + 020D 90s00r15 738 mov dptr,#_xcnt + 0210 E0 739 movx a,@dptr + 0211 FA 740 mov r2,a + 0212 C3 741 clr c + 0213 74 0A 742 mov a,#0x0a + 0215 9A 743 subb a,r2 + 0216 FA 744 mov r2,a + 0217 8A 82 745 mov dpl,r2 + 0219 746 00101$: + 0219 747 C$ser_ir.c$136$1$1 ==. + 0219 748 XG$ser_can_xmt$0$0 ==. + 0219 22 749 ret + 021A 750 G$ser_can_rcv$0$0 ==. + 751 ; ser_ir.c 138 + 752 ; ----------------------------------------- + 753 ; function ser_can_rcv + 754 ; ----------------------------------------- + 021A 755 _ser_can_rcv: + 756 ; ser_ir.c 140 + 021A 90s00r14 757 mov dptr,#_rcnt + 021D E0 758 movx a,@dptr + 021E FA 759 mov r2,a + 021F 8A 82 760 mov dpl,r2 + 0221 761 00101$: + 0221 762 C$ser_ir.c$141$1$1 ==. + 0221 763 XG$ser_can_rcv$0$0 ==. + 0221 22 764 ret + 765 .area CSEG (CODE) diff --git a/device/lib/ser_ir.sym b/device/lib/ser_ir.sym new file mode 100644 index 00000000..2ca6e944 --- /dev/null +++ b/device/lib/ser_ir.sym @@ -0,0 +1,888 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$ser_ir$257 0000 GR + 7 A$ser_ir$259 0002 GR + 7 A$ser_ir$261 0005 GR + 7 A$ser_ir$262 0006 GR + 7 A$ser_ir$263 0007 GR + 7 A$ser_ir$265 000A GR + 7 A$ser_ir$266 000B GR + 7 A$ser_ir$267 000C GR + 7 A$ser_ir$269 000F GR + 7 A$ser_ir$270 0010 GR + 7 A$ser_ir$271 0011 GR + 7 A$ser_ir$273 0014 GR + 7 A$ser_ir$274 0015 GR + 7 A$ser_ir$276 0016 GR + 7 A$ser_ir$278 0019 GR + 7 A$ser_ir$279 001A GR + 7 A$ser_ir$281 001B GR + 7 A$ser_ir$283 001E GR + 7 A$ser_ir$285 0021 GR + 7 A$ser_ir$287 0024 GR + 7 A$ser_ir$289 0027 GR + 7 A$ser_ir$290 002A GR + 7 A$ser_ir$291 002D GR + 7 A$ser_ir$293 002F GR + 7 A$ser_ir$297 0031 GR + 7 A$ser_ir$304 0032 GR + 7 A$ser_ir$305 0034 GR + 7 A$ser_ir$306 0036 GR + 7 A$ser_ir$307 0038 GR + 7 A$ser_ir$308 003A GR + 7 A$ser_ir$309 003C GR + 7 A$ser_ir$310 003E GR + 7 A$ser_ir$311 0040 GR + 7 A$ser_ir$314 0043 GR + 7 A$ser_ir$317 0046 GR + 7 A$ser_ir$319 0048 GR + 7 A$ser_ir$320 004B GR + 7 A$ser_ir$321 004C GR + 7 A$ser_ir$322 004D GR + 7 A$ser_ir$325 0050 GR + 7 A$ser_ir$328 0052 GR + 7 A$ser_ir$329 0055 GR + 7 A$ser_ir$330 0057 GR + 7 A$ser_ir$331 0058 GR + 7 A$ser_ir$332 0059 GR + 7 A$ser_ir$333 005C GR + 7 A$ser_ir$335 005D GR + 7 A$ser_ir$336 005E GR + 7 A$ser_ir$337 005F GR + 7 A$ser_ir$338 0062 GR + 7 A$ser_ir$339 0063 GR + 7 A$ser_ir$340 0065 GR + 7 A$ser_ir$341 0066 GR + 7 A$ser_ir$342 0068 GR + 7 A$ser_ir$344 006A GR + 7 A$ser_ir$345 006B GR + 7 A$ser_ir$346 006D GR + 7 A$ser_ir$347 006F GR + 7 A$ser_ir$348 0071 GR + 7 A$ser_ir$352 0072 GR + 7 A$ser_ir$355 0075 GR + 7 A$ser_ir$357 0077 GR + 7 A$ser_ir$358 007A GR + 7 A$ser_ir$360 007B GR + 7 A$ser_ir$361 007C GR + 7 A$ser_ir$362 007F GR + 7 A$ser_ir$363 0080 GR + 7 A$ser_ir$365 0081 GR + 7 A$ser_ir$368 0083 GR + 7 A$ser_ir$369 0084 GR + 7 A$ser_ir$370 0086 GR + 7 A$ser_ir$371 0089 GR + 7 A$ser_ir$373 008A GR + 7 A$ser_ir$374 008D GR + 7 A$ser_ir$376 008E GR + 7 A$ser_ir$377 008F GR + 7 A$ser_ir$379 0091 GR + 7 A$ser_ir$380 0092 GR + 7 A$ser_ir$381 0095 GR + 7 A$ser_ir$382 0096 GR + 7 A$ser_ir$383 0097 GR + 7 A$ser_ir$384 0099 GR + 7 A$ser_ir$386 009B GR + 7 A$ser_ir$387 009C GR + 7 A$ser_ir$388 009E GR + 7 A$ser_ir$389 00A0 GR + 7 A$ser_ir$390 00A1 GR + 7 A$ser_ir$392 00A3 GR + 7 A$ser_ir$396 00A6 GR + 7 A$ser_ir$399 00A8 GR + 7 A$ser_ir$401 00AB GR + 7 A$ser_ir$402 00AC GR + 7 A$ser_ir$404 00AD GR + 7 A$ser_ir$405 00AF GR + 7 A$ser_ir$406 00B1 GR + 7 A$ser_ir$407 00B3 GR + 7 A$ser_ir$408 00B5 GR + 7 A$ser_ir$409 00B7 GR + 7 A$ser_ir$410 00B9 GR + 7 A$ser_ir$413 00BB GR + 7 A$ser_ir$421 00BC GR + 7 A$ser_ir$422 00BE GR + 7 A$ser_ir$423 00C1 GR + 7 A$ser_ir$424 00C3 GR + 7 A$ser_ir$427 00C4 GR + 7 A$ser_ir$428 00C7 GR + 7 A$ser_ir$429 00C8 GR + 7 A$ser_ir$430 00C9 GR + 7 A$ser_ir$433 00CC GR + 7 A$ser_ir$436 00CE GR + 7 A$ser_ir$438 00D0 GR + 7 A$ser_ir$439 00D3 GR + 7 A$ser_ir$441 00D4 GR + 7 A$ser_ir$443 00D5 GR + 7 A$ser_ir$446 00D7 GR + 7 A$ser_ir$447 00DA GR + 7 A$ser_ir$448 00DC GR + 7 A$ser_ir$449 00DD GR + 7 A$ser_ir$450 00DE GR + 7 A$ser_ir$451 00E1 GR + 7 A$ser_ir$453 00E2 GR + 7 A$ser_ir$454 00E3 GR + 7 A$ser_ir$455 00E4 GR + 7 A$ser_ir$456 00E7 GR + 7 A$ser_ir$457 00E8 GR + 7 A$ser_ir$458 00EA GR + 7 A$ser_ir$459 00EB GR + 7 A$ser_ir$460 00ED GR + 7 A$ser_ir$462 00EE GR + 7 A$ser_ir$463 00EF GR + 7 A$ser_ir$464 00F1 GR + 7 A$ser_ir$465 00F2 GR + 7 A$ser_ir$466 00F5 GR + 7 A$ser_ir$468 00F6 GR + 7 A$ser_ir$469 00F7 GR + 7 A$ser_ir$470 00F9 GR + 7 A$ser_ir$471 00FB GR + 7 A$ser_ir$473 00FC GR + 7 A$ser_ir$476 00FE GR + 7 A$ser_ir$477 0101 GR + 7 A$ser_ir$478 0102 GR + 7 A$ser_ir$480 0104 GR + 7 A$ser_ir$481 0107 GR + 7 A$ser_ir$482 0109 GR + 7 A$ser_ir$485 010A GR + 7 A$ser_ir$489 010C GR + 7 A$ser_ir$498 010D GR + 7 A$ser_ir$499 0110 GR + 7 A$ser_ir$501 0111 GR + 7 A$ser_ir$503 0112 GR + 7 A$ser_ir$506 0114 GR + 7 A$ser_ir$508 0116 GR + 7 A$ser_ir$509 0117 GR + 7 A$ser_ir$510 0119 GR + 7 A$ser_ir$511 011C GR + 7 A$ser_ir$513 011D GR + 7 A$ser_ir$514 0120 GR + 7 A$ser_ir$516 0121 GR + 7 A$ser_ir$517 0122 GR + 7 A$ser_ir$519 0124 GR + 7 A$ser_ir$520 0125 GR + 7 A$ser_ir$521 0128 GR + 7 A$ser_ir$522 0129 GR + 7 A$ser_ir$523 012A GR + 7 A$ser_ir$524 012C GR + 7 A$ser_ir$526 012E GR + 7 A$ser_ir$527 012F GR + 7 A$ser_ir$528 0131 GR + 7 A$ser_ir$529 0133 GR + 7 A$ser_ir$530 0134 GR + 7 A$ser_ir$532 0135 GR + 7 A$ser_ir$536 0138 GR + 7 A$ser_ir$539 013A GR + 7 A$ser_ir$541 013D GR + 7 A$ser_ir$542 013E GR + 7 A$ser_ir$545 013F GR + 7 A$ser_ir$547 0141 GR + 7 A$ser_ir$551 0143 GR + 7 A$ser_ir$559 0144 GR + 7 A$ser_ir$560 0146 GR + 7 A$ser_ir$561 0148 GR + 7 A$ser_ir$562 014A GR + 7 A$ser_ir$563 014D GR + 7 A$ser_ir$564 014F GR + 7 A$ser_ir$565 0150 GR + 7 A$ser_ir$566 0152 GR + 7 A$ser_ir$567 0153 GR + 7 A$ser_ir$568 0154 GR + 7 A$ser_ir$569 0156 GR + 7 A$ser_ir$570 0157 GR + 7 A$ser_ir$573 0158 GR + 7 A$ser_ir$574 015B GR + 7 A$ser_ir$575 015C GR + 7 A$ser_ir$576 015D GR + 7 A$ser_ir$577 015E GR + 7 A$ser_ir$578 015F GR + 7 A$ser_ir$579 0160 GR + 7 A$ser_ir$580 0161 GR + 7 A$ser_ir$581 0162 GR + 7 A$ser_ir$582 0163 GR + 7 A$ser_ir$583 0166 GR + 7 A$ser_ir$584 0168 GR + 7 A$ser_ir$585 0169 GR + 7 A$ser_ir$587 016A GR + 7 A$ser_ir$588 016B GR + 7 A$ser_ir$589 016C GR + 7 A$ser_ir$590 016D GR + 7 A$ser_ir$591 016E GR + 7 A$ser_ir$592 016F GR + 7 A$ser_ir$593 0170 GR + 7 A$ser_ir$594 0171 GR + 7 A$ser_ir$595 0173 GR + 7 A$ser_ir$596 0175 GR + 7 A$ser_ir$597 0177 GR + 7 A$ser_ir$599 017A GR + 7 A$ser_ir$601 017B GR + 7 A$ser_ir$606 017D GR + 7 A$ser_ir$610 0180 GR + 7 A$ser_ir$611 0182 GR + 7 A$ser_ir$612 0185 GR + 7 A$ser_ir$613 0188 GR + 7 A$ser_ir$616 018A GR + 7 A$ser_ir$617 018C GR + 7 A$ser_ir$619 018F GR + 7 A$ser_ir$623 0191 GR + 7 A$ser_ir$631 0192 GR + 7 A$ser_ir$632 0194 GR + 7 A$ser_ir$633 0196 GR + 7 A$ser_ir$634 0198 GR + 7 A$ser_ir$635 019B GR + 7 A$ser_ir$636 019D GR + 7 A$ser_ir$637 019E GR + 7 A$ser_ir$638 01A0 GR + 7 A$ser_ir$639 01A1 GR + 7 A$ser_ir$640 01A2 GR + 7 A$ser_ir$641 01A4 GR + 7 A$ser_ir$642 01A5 GR + 7 A$ser_ir$644 01A6 GR + 7 A$ser_ir$645 01A9 GR + 7 A$ser_ir$646 01AA GR + 7 A$ser_ir$647 01AB GR + 7 A$ser_ir$648 01AE GR + 7 A$ser_ir$649 01AF GR + 7 A$ser_ir$650 01B0 GR + 7 A$ser_ir$651 01B1 GR + 7 A$ser_ir$652 01B2 GR + 7 A$ser_ir$653 01B3 GR + 7 A$ser_ir$654 01B4 GR + 7 A$ser_ir$655 01B5 GR + 7 A$ser_ir$656 01B6 GR + 7 A$ser_ir$658 01B8 GR + 7 A$ser_ir$659 01BA GR + 7 A$ser_ir$660 01BB GR + 7 A$ser_ir$661 01BC GR + 7 A$ser_ir$664 01BD GR + 7 A$ser_ir$667 01BF GR + 7 A$ser_ir$668 01C1 GR + 7 A$ser_ir$669 01C3 GR + 7 A$ser_ir$670 01C5 GR + 7 A$ser_ir$671 01C7 GR + 7 A$ser_ir$672 01C9 GR + 7 A$ser_ir$673 01CB GR + 7 A$ser_ir$674 01CE GR + 7 A$ser_ir$675 01D0 GR + 7 A$ser_ir$676 01D2 GR + 7 A$ser_ir$677 01D4 GR + 7 A$ser_ir$678 01D6 GR + 7 A$ser_ir$679 01D8 GR + 7 A$ser_ir$680 01DA GR + 7 A$ser_ir$682 01DC GR + 7 A$ser_ir$684 01DF GR + 7 A$ser_ir$687 01E1 GR + 7 A$ser_ir$688 01E2 GR + 7 A$ser_ir$689 01E3 GR + 7 A$ser_ir$690 01E4 GR + 7 A$ser_ir$692 01E6 GR + 7 A$ser_ir$693 01E7 GR + 7 A$ser_ir$694 01E8 GR + 7 A$ser_ir$695 01EA GR + 7 A$ser_ir$696 01EC GR + 7 A$ser_ir$697 01ED GR + 7 A$ser_ir$701 01F0 GR + 7 A$ser_ir$707 01F3 GR + 7 A$ser_ir$708 01F6 GR + 7 A$ser_ir$709 01F7 GR + 7 A$ser_ir$710 01F8 GR + 7 A$ser_ir$711 01F9 GR + 7 A$ser_ir$712 01FA GR + 7 A$ser_ir$713 01FB GR + 7 A$ser_ir$714 01FC GR + 7 A$ser_ir$715 01FD GR + 7 A$ser_ir$716 01FE GR + 7 A$ser_ir$717 01FF GR + 7 A$ser_ir$718 0200 GR + 7 A$ser_ir$720 0202 GR + 7 A$ser_ir$721 0203 GR + 7 A$ser_ir$722 0204 GR + 7 A$ser_ir$723 0206 GR + 7 A$ser_ir$725 0208 GR + 7 A$ser_ir$726 0209 GR + 7 A$ser_ir$730 020C GR + 7 A$ser_ir$738 020D GR + 7 A$ser_ir$739 0210 GR + 7 A$ser_ir$740 0211 GR + 7 A$ser_ir$741 0212 GR + 7 A$ser_ir$742 0213 GR + 7 A$ser_ir$743 0215 GR + 7 A$ser_ir$744 0216 GR + 7 A$ser_ir$745 0217 GR + 7 A$ser_ir$749 0219 GR + 7 A$ser_ir$757 021A GR + 7 A$ser_ir$758 021D GR + 7 A$ser_ir$759 021E GR + 7 A$ser_ir$760 021F GR + 7 A$ser_ir$764 0221 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$ser_ir.c$107$1$1 = 0143 GR + 7 C$ser_ir.c$117$1$1 = 0191 GR + 7 C$ser_ir.c$131$1$1 = 020C GR + 7 C$ser_ir.c$136$1$1 = 0219 GR + 7 C$ser_ir.c$141$1$1 = 0221 GR + 7 C$ser_ir.c$60$1$1 = 0031 GR + 7 C$ser_ir.c$79$1$1 = 00BB GR + 7 C$ser_ir.c$93$1$1 = 010C GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 5 Fser_ir$busy$0$0 = 0018 GR + 5 Fser_ir$rbuf$0$0 = 0000 GR + 5 Fser_ir$rcnt$0$0 = 0014 GR + 5 Fser_ir$rpos$0$0 = 0016 GR + 5 Fser_ir$xbuf$0$0 = 000A GR + 5 Fser_ir$xcnt$0$0 = 0015 GR + 5 Fser_ir$xpos$0$0 = 0017 GR + G$A$0$0 = 00E0 G + G$AC$0$0 = 00D6 G + G$ACC$0$0 = 00E0 G + G$AIN0$0$0 = 0090 G + G$AIN1$0$0 = 0091 G + G$AOUT$0$0 = 00B6 G + G$B$0$0 = 00F0 G + G$CY$0$0 = 00D7 G + G$DPH$0$0 = 0083 G + G$DPL$0$0 = 0082 G + G$EA$0$0 = 00AF G + G$ES$0$0 = 00AC G + G$ET0$0$0 = 00A9 G + G$ET1$0$0 = 00AB G + G$ET2$0$0 = 00AD G + G$EX0$0$0 = 00A8 G + G$EX1$0$0 = 00AA G + G$F0$0$0 = 00D5 G + G$FL$0$0 = 00D1 G + G$IE$0$0 = 00A8 G + G$IE0$0$0 = 0089 G + G$IE1$0$0 = 008B G + G$INT0$0$0 = 00B2 G + G$INT1$0$0 = 00B3 G + G$IP$0$0 = 00B8 G + G$IT0$0$0 = 0088 G + G$IT1$0$0 = 008A G + G$OV$0$0 = 00D2 G + G$P$0$0 = 00D0 G + G$P1$0$0 = 0090 G + G$P1_0$0$0 = 0090 G + G$P1_1$0$0 = 0091 G + G$P1_2$0$0 = 0092 G + G$P1_3$0$0 = 0093 G + G$P1_4$0$0 = 0094 G + G$P1_5$0$0 = 0095 G + G$P1_6$0$0 = 0096 G + G$P1_7$0$0 = 0097 G + G$P3$0$0 = 00B0 G + G$P3_0$0$0 = 00B0 G + G$P3_1$0$0 = 00B1 G + G$P3_2$0$0 = 00B2 G + G$P3_3$0$0 = 00B3 G + G$P3_4$0$0 = 00B4 G + G$P3_5$0$0 = 00B5 G + G$P3_7$0$0 = 00B7 G + G$PCON$0$0 = 0087 G + G$PS$0$0 = 00BC G + G$PSW$0$0 = 00D0 G + G$PT0$0$0 = 00B9 G + G$PT1$0$0 = 00BB G + G$PX0$0$0 = 00B8 G + G$PX1$0$0 = 00BA G + G$RB8$0$0 = 009A G + G$REN$0$0 = 009C G + G$RI$0$0 = 0098 G + G$RS0$0$0 = 00D3 G + G$RS1$0$0 = 00D4 G + G$RXD$0$0 = 00B0 G + G$SBUF$0$0 = 0099 G + G$SCON$0$0 = 0098 G + G$SM0$0$0 = 009F G + G$SM1$0$0 = 009E G + G$SM2$0$0 = 009D G + G$SP$0$0 = 0081 G + G$T0$0$0 = 00B4 G + G$T1$0$0 = 00B5 G + G$TB8$0$0 = 009B G + G$TCON$0$0 = 0088 G + G$TF0$0$0 = 008D G + G$TF1$0$0 = 008F G + G$TH0$0$0 = 008C G + G$TH1$0$0 = 008D G + G$TI$0$0 = 0099 G + G$TL0$0$0 = 008A G + G$TL1$0$0 = 008B G + G$TMOD$0$0 = 0089 G + G$TR0$0$0 = 008C G + G$TR1$0$0 = 008E G + G$TXD$0$0 = 00B1 G + 7 G$ser_can_rcv$0$0 = 021A GR + 7 G$ser_can_xmt$0$0 = 020D GR + 7 G$ser_getc$0$0 = 010D GR + 7 G$ser_gets$0$0 = 0192 GR + 7 G$ser_handler$0$0 = 0032 GR + 7 G$ser_init$0$0 = 0000 GR + 7 G$ser_putc$0$0 = 00BC GR + 7 G$ser_puts$0$0 = 0144 GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$ser_can_rcv$0$0 = 0221 GR + 7 XG$ser_can_xmt$0$0 = 0219 GR + 7 XG$ser_getc$0$0 = 0143 GR + 7 XG$ser_gets$0$0 = 020C GR + 7 XG$ser_handler$0$0 = 00BB GR + 7 XG$ser_init$0$0 = 0031 GR + 7 XG$ser_putc$0$0 = 010C GR + 7 XG$ser_puts$0$0 = 0191 GR + _A = 00E0 + _AC = 00D6 + _ACC = 00E0 + _AIN0 = 0090 + _AIN1 = 0091 + _AOUT = 00B6 + _B = 00F0 + _CY = 00D7 + _DPH = 0083 + _DPL = 0082 + _EA = 00AF + _ES = 00AC + _ET0 = 00A9 + _ET1 = 00AB + _ET2 = 00AD + _EX0 = 00A8 + _EX1 = 00AA + _F0 = 00D5 + _FL = 00D1 + _IE = 00A8 + _IE0 = 0089 + _IE1 = 008B + _INT0 = 00B2 + _INT1 = 00B3 + _IP = 00B8 + _IT0 = 0088 + _IT1 = 008A + _OV = 00D2 + _P = 00D0 + _P1 = 0090 + _P1_0 = 0090 + _P1_1 = 0091 + _P1_2 = 0092 + _P1_3 = 0093 + _P1_4 = 0094 + _P1_5 = 0095 + _P1_6 = 0096 + _P1_7 = 0097 + _P3 = 00B0 + _P3_0 = 00B0 + _P3_1 = 00B1 + _P3_2 = 00B2 + _P3_3 = 00B3 + _P3_4 = 00B4 + _P3_5 = 00B5 + _P3_7 = 00B7 + _PCON = 0087 + _PS = 00BC + _PSW = 00D0 + _PT0 = 00B9 + _PT1 = 00BB + _PX0 = 00B8 + _PX1 = 00BA + _RB8 = 009A + _REN = 009C + _RI = 0098 + _RS0 = 00D3 + _RS1 = 00D4 + _RXD = 00B0 + _SBUF = 0099 + _SCON = 0098 + _SM0 = 009F + _SM1 = 009E + _SM2 = 009D + _SP = 0081 + _T0 = 00B4 + _T1 = 00B5 + _TB8 = 009B + _TCON = 0088 + _TF0 = 008D + _TF1 = 008F + _TH0 = 008C + _TH1 = 008D + _TI = 0099 + _TL0 = 008A + _TL1 = 008B + _TMOD = 0089 + _TR0 = 008C + _TR1 = 008E + _TXD = 00B1 + __gptrget **** GX + __gptrput **** GX + 5 _busy 0018 R + 5 _rbuf 0000 R + 5 _rcnt 0014 R + 5 _rpos 0016 R + 7 _ser_can_rcv 021A GR + 7 _ser_can_xmt 020D GR + 7 _ser_getc 010D GR + 7 _ser_gets 0192 GR + 5 _ser_gets_PARM_2 001D GR + 5 _ser_gets_s_1_1 001E R + 7 _ser_handler 0032 GR + 7 _ser_init 0000 GR + 7 _ser_putc 00BC GR + 5 _ser_putc_c_1_1 0019 R + 7 _ser_puts 0144 GR + 5 _ser_puts_s_1_1 001A R + 5 _xbuf 000A R + 5 _xcnt 0015 R + 5 _xpos 0017 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 0 flags 80 + 5 XSEG size 21 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 222 flags 20 diff --git a/device/lib/serial.c b/device/lib/serial.c new file mode 100644 index 00000000..4508282e --- /dev/null +++ b/device/lib/serial.c @@ -0,0 +1,89 @@ +//---------------------------------------------------------------------------- +//Written by Dmitry S. Obukhov, 1996 +// dso@usa.net +//---------------------------------------------------------------------------- +//This module implements serial interrupt handler and IO routinwes using +//two 256 byte cyclic buffers. Bit variables can be used as flags for +//real-time kernel tasks +//Last modified 6 Apr 97 +//---------------------------------------------------------------------------- + +#include "reg51.h"//This module contains definition of I8051 registers + + +static unsigned char xdata stx_index_in, srx_index_in, stx_index_out, srx_index_out; +static unsigned char xdata stx_buffer[0x100]; +static unsigned char xdata srx_buffer[0x100]; + +static bit work_flag_byte_arrived; +static bit work_flag_buffer_transfered; +static bit tx_serial_buffer_empty; +static bit rx_serial_buffer_empty; + + +void serial_init(void) +{ + SCON = 0x50; + T2CON = 0x34; + PS = 1; + T2CON = 0x34; + RCAP2H = 0xFF; + RCAP2L = 0xDA; + + RI = 0; + TI = 0; + + stx_index_in = srx_index_in = stx_index_out = srx_index_out = 0; + rx_serial_buffer_empty = tx_serial_buffer_empty = 1; + work_flag_buffer_transfered = 0; + work_flag_byte_arrived = 0; + ES=1; +} + +void serial_interrupt_handler(void) interrupt 4 using 1 +{ + ES=0; + if ( TI ) + { + TI = 0; + if (stx_index_out == stx_index_in ) + { + tx_serial_buffer_empty = 1; + work_flag_buffer_transfered = 1; + } + else SBUF = stx_buffer[stx_index_out++]; + } + if ( RI ) + { + RI = 0; + srx_buffer[srx_index_in++]=SBUF; + work_flag_byte_arrived = 1; + rx_serial_buffer_empty = 0; + } + ES=1; +} + +//Next two functions are interface + +void serial_putc(unsigned char c) +{ + stx_buffer[stx_index_in++]=c; + ES=0; + if ( tx_serial_buffer_empty ) + { + tx_serial_buffer_empty = 0; + TI=1; + } + ES=1; +} + +unsigned char serial_getc(void) +{ + unsigned char tmp = srx_buffer[srx_index_out++]; + ES=0; + if ( srx_index_out == srx_index_in) rx_serial_buffer_empty = 1; + ES=1; + return tmp; +} + +//END OF MODULE diff --git a/device/lib/serial.lst b/device/lib/serial.lst new file mode 100644 index 00000000..aae883fe --- /dev/null +++ b/device/lib/serial.lst @@ -0,0 +1,515 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:35 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module serial + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _serial_getc + 11 .globl _serial_putc + 12 .globl _serial_interrupt_handler + 13 .globl _serial_init + 14 ;-------------------------------------------------------- + 15 ; special function registers + 16 ;-------------------------------------------------------- + 0080 17 G$P0$0$0 == 0x0080 + 0080 18 _P0 = 0x0080 + 0090 19 G$P1$0$0 == 0x0090 + 0090 20 _P1 = 0x0090 + 00A0 21 G$P2$0$0 == 0x00a0 + 00A0 22 _P2 = 0x00a0 + 00B0 23 G$P3$0$0 == 0x00b0 + 00B0 24 _P3 = 0x00b0 + 00D0 25 G$PSW$0$0 == 0x00d0 + 00D0 26 _PSW = 0x00d0 + 00E0 27 G$ACC$0$0 == 0x00e0 + 00E0 28 _ACC = 0x00e0 + 00F0 29 G$B$0$0 == 0x00f0 + 00F0 30 _B = 0x00f0 + 0081 31 G$SP$0$0 == 0x0081 + 0081 32 _SP = 0x0081 + 0082 33 G$DPL$0$0 == 0x0082 + 0082 34 _DPL = 0x0082 + 0083 35 G$DPH$0$0 == 0x0083 + 0083 36 _DPH = 0x0083 + 0087 37 G$PCON$0$0 == 0x0087 + 0087 38 _PCON = 0x0087 + 0088 39 G$TCON$0$0 == 0x0088 + 0088 40 _TCON = 0x0088 + 0089 41 G$TMOD$0$0 == 0x0089 + 0089 42 _TMOD = 0x0089 + 008A 43 G$TL0$0$0 == 0x008a + 008A 44 _TL0 = 0x008a + 008B 45 G$TL1$0$0 == 0x008b + 008B 46 _TL1 = 0x008b + 008C 47 G$TH0$0$0 == 0x008c + 008C 48 _TH0 = 0x008c + 008D 49 G$TH1$0$0 == 0x008d + 008D 50 _TH1 = 0x008d + 008E 51 G$AUXR$0$0 == 0x008e + 008E 52 _AUXR = 0x008e + 00A8 53 G$IE$0$0 == 0x00a8 + 00A8 54 _IE = 0x00a8 + 00B8 55 G$IP$0$0 == 0x00b8 + 00B8 56 _IP = 0x00b8 + 0098 57 G$SCON$0$0 == 0x0098 + 0098 58 _SCON = 0x0098 + 0099 59 G$SBUF$0$0 == 0x0099 + 0099 60 _SBUF = 0x0099 + 00C8 61 G$T2CON$0$0 == 0x00c8 + 00C8 62 _T2CON = 0x00c8 + 00CB 63 G$RCAP2H$0$0 == 0x00cb + 00CB 64 _RCAP2H = 0x00cb + 00CA 65 G$RCAP2L$0$0 == 0x00ca + 00CA 66 _RCAP2L = 0x00ca + 67 ;-------------------------------------------------------- + 68 ; special function bits + 69 ;-------------------------------------------------------- + 00D7 70 G$CY$0$0 == 0x00d7 + 00D7 71 _CY = 0x00d7 + 00D6 72 G$AC$0$0 == 0x00d6 + 00D6 73 _AC = 0x00d6 + 00D5 74 G$F0$0$0 == 0x00d5 + 00D5 75 _F0 = 0x00d5 + 00D4 76 G$RS1$0$0 == 0x00d4 + 00D4 77 _RS1 = 0x00d4 + 00D3 78 G$RS0$0$0 == 0x00d3 + 00D3 79 _RS0 = 0x00d3 + 00D2 80 G$OV$0$0 == 0x00d2 + 00D2 81 _OV = 0x00d2 + 00D0 82 G$P$0$0 == 0x00d0 + 00D0 83 _P = 0x00d0 + 008F 84 G$TF1$0$0 == 0x008f + 008F 85 _TF1 = 0x008f + 008E 86 G$TR1$0$0 == 0x008e + 008E 87 _TR1 = 0x008e + 008D 88 G$TF0$0$0 == 0x008d + 008D 89 _TF0 = 0x008d + 008C 90 G$TR0$0$0 == 0x008c + 008C 91 _TR0 = 0x008c + 008B 92 G$IE1$0$0 == 0x008b + 008B 93 _IE1 = 0x008b + 008A 94 G$IT1$0$0 == 0x008a + 008A 95 _IT1 = 0x008a + 0089 96 G$IE0$0$0 == 0x0089 + 0089 97 _IE0 = 0x0089 + 0088 98 G$IT0$0$0 == 0x0088 + 0088 99 _IT0 = 0x0088 + 00AF 100 G$EA$0$0 == 0x00af + 00AF 101 _EA = 0x00af + 00AC 102 G$ES$0$0 == 0x00ac + 00AC 103 _ES = 0x00ac + 00AB 104 G$ET1$0$0 == 0x00ab + 00AB 105 _ET1 = 0x00ab + 00AA 106 G$EX1$0$0 == 0x00aa + 00AA 107 _EX1 = 0x00aa + 00A9 108 G$ET0$0$0 == 0x00a9 + 00A9 109 _ET0 = 0x00a9 + 00A8 110 G$EX0$0$0 == 0x00a8 + 00A8 111 _EX0 = 0x00a8 + 00BC 112 G$PS$0$0 == 0x00bc + 00BC 113 _PS = 0x00bc + 00BB 114 G$PT1$0$0 == 0x00bb + 00BB 115 _PT1 = 0x00bb + 00BA 116 G$PX1$0$0 == 0x00ba + 00BA 117 _PX1 = 0x00ba + 00B9 118 G$PT0$0$0 == 0x00b9 + 00B9 119 _PT0 = 0x00b9 + 00B8 120 G$PX0$0$0 == 0x00b8 + 00B8 121 _PX0 = 0x00b8 + 00B7 122 G$RD$0$0 == 0x00b7 + 00B7 123 _RD = 0x00b7 + 00B6 124 G$WR$0$0 == 0x00b6 + 00B6 125 _WR = 0x00b6 + 00B5 126 G$T1$0$0 == 0x00b5 + 00B5 127 _T1 = 0x00b5 + 00B4 128 G$T0$0$0 == 0x00b4 + 00B4 129 _T0 = 0x00b4 + 00B3 130 G$INT1$0$0 == 0x00b3 + 00B3 131 _INT1 = 0x00b3 + 00B2 132 G$INT0$0$0 == 0x00b2 + 00B2 133 _INT0 = 0x00b2 + 00B1 134 G$TXD$0$0 == 0x00b1 + 00B1 135 _TXD = 0x00b1 + 00B0 136 G$RXD$0$0 == 0x00b0 + 00B0 137 _RXD = 0x00b0 + 0090 138 G$P1_0$0$0 == 0x0090 + 0090 139 _P1_0 = 0x0090 + 0091 140 G$P1_1$0$0 == 0x0091 + 0091 141 _P1_1 = 0x0091 + 0092 142 G$P1_2$0$0 == 0x0092 + 0092 143 _P1_2 = 0x0092 + 0093 144 G$P1_3$0$0 == 0x0093 + 0093 145 _P1_3 = 0x0093 + 0094 146 G$P1_4$0$0 == 0x0094 + 0094 147 _P1_4 = 0x0094 + 0095 148 G$P1_5$0$0 == 0x0095 + 0095 149 _P1_5 = 0x0095 + 0096 150 G$P1_6$0$0 == 0x0096 + 0096 151 _P1_6 = 0x0096 + 0097 152 G$P1_7$0$0 == 0x0097 + 0097 153 _P1_7 = 0x0097 + 009F 154 G$SM0$0$0 == 0x009f + 009F 155 _SM0 = 0x009f + 009E 156 G$SM1$0$0 == 0x009e + 009E 157 _SM1 = 0x009e + 009D 158 G$SM2$0$0 == 0x009d + 009D 159 _SM2 = 0x009d + 009C 160 G$REN$0$0 == 0x009c + 009C 161 _REN = 0x009c + 009B 162 G$TB8$0$0 == 0x009b + 009B 163 _TB8 = 0x009b + 009A 164 G$RB8$0$0 == 0x009a + 009A 165 _RB8 = 0x009a + 0099 166 G$TI$0$0 == 0x0099 + 0099 167 _TI = 0x0099 + 0098 168 G$RI$0$0 == 0x0098 + 0098 169 _RI = 0x0098 + 00C8 170 G$T2CON_0$0$0 == 0x00c8 + 00C8 171 _T2CON_0 = 0x00c8 + 00C9 172 G$T2CON_1$0$0 == 0x00c9 + 00C9 173 _T2CON_1 = 0x00c9 + 00CA 174 G$T2CON_2$0$0 == 0x00ca + 00CA 175 _T2CON_2 = 0x00ca + 00CB 176 G$T2CON_3$0$0 == 0x00cb + 00CB 177 _T2CON_3 = 0x00cb + 00CC 178 G$T2CON_4$0$0 == 0x00cc + 00CC 179 _T2CON_4 = 0x00cc + 00CD 180 G$T2CON_5$0$0 == 0x00cd + 00CD 181 _T2CON_5 = 0x00cd + 00CE 182 G$T2CON_6$0$0 == 0x00ce + 00CE 183 _T2CON_6 = 0x00ce + 00CF 184 G$T2CON_7$0$0 == 0x00cf + 00CF 185 _T2CON_7 = 0x00cf + 186 ;-------------------------------------------------------- + 187 ; internal ram data + 188 ;-------------------------------------------------------- + 189 .area DSEG (DATA) + 190 ;-------------------------------------------------------- + 191 ; overlayable items in internal ram + 192 ;-------------------------------------------------------- + 193 .area OSEG (OVR,DATA) + 194 ;-------------------------------------------------------- + 195 ; indirectly addressable internal ram data + 196 ;-------------------------------------------------------- + 197 .area ISEG (DATA) + 198 ;-------------------------------------------------------- + 199 ; bit data + 200 ;-------------------------------------------------------- + 201 .area BSEG (BIT) + 0000 202 Fserial$work_flag_byte_arrived$0$0==. + 0000 203 _work_flag_byte_arrived: + 0000 204 .ds 0x0001 + 0001 205 Fserial$work_flag_buffer_transfered$0$0==. + 0001 206 _work_flag_buffer_transfered: + 0001 207 .ds 0x0001 + 0002 208 Fserial$tx_serial_buffer_empty$0$0==. + 0002 209 _tx_serial_buffer_empty: + 0002 210 .ds 0x0001 + 0003 211 Fserial$rx_serial_buffer_empty$0$0==. + 0003 212 _rx_serial_buffer_empty: + 0003 213 .ds 0x0001 + 214 ;-------------------------------------------------------- + 215 ; external ram data + 216 ;-------------------------------------------------------- + 217 .area XSEG (XDATA) + 0000 218 Fserial$stx_index_in$0$0==. + 0000 219 _stx_index_in: + 0000 220 .ds 0x0001 + 0001 221 Fserial$srx_index_in$0$0==. + 0001 222 _srx_index_in: + 0001 223 .ds 0x0001 + 0002 224 Fserial$stx_index_out$0$0==. + 0002 225 _stx_index_out: + 0002 226 .ds 0x0001 + 0003 227 Fserial$srx_index_out$0$0==. + 0003 228 _srx_index_out: + 0003 229 .ds 0x0001 + 0004 230 Fserial$stx_buffer$0$0==. + 0004 231 _stx_buffer: + 0004 232 .ds 0x0100 + 0104 233 Fserial$srx_buffer$0$0==. + 0104 234 _srx_buffer: + 0104 235 .ds 0x0100 + 0204 236 _serial_putc_c_1_1: + 0204 237 .ds 0x0001 + 238 ;-------------------------------------------------------- + 239 ; global & static initialisations + 240 ;-------------------------------------------------------- + 241 .area GSINIT (CODE) + 242 ;-------------------------------------------------------- + 243 ; code + 244 ;-------------------------------------------------------- + 245 .area CSEG (CODE) + 0000 246 G$serial_init$0$0 ==. + 247 ; serial.c 24 + 248 ; ----------------------------------------- + 249 ; function serial_init + 250 ; ----------------------------------------- + 0000 251 _serial_init: + 0002 252 ar2 = 0x02 + 0003 253 ar3 = 0x03 + 0004 254 ar4 = 0x04 + 0005 255 ar5 = 0x05 + 0006 256 ar6 = 0x06 + 0007 257 ar7 = 0x07 + 0000 258 ar0 = 0x00 + 0001 259 ar1 = 0x01 + 260 ; serial.c 26 + 0000 75 98 50 261 mov _SCON,#0x50 + 262 ; serial.c 27 + 0003 75 C8 34 263 mov _T2CON,#0x34 + 264 ; serial.c 28 + 0006 D2 BC 265 setb _PS + 266 ; serial.c 29 + 0008 75 C8 34 267 mov _T2CON,#0x34 + 268 ; serial.c 30 + 000B 75 CB FF 269 mov _RCAP2H,#0xff + 270 ; serial.c 31 + 000E 75 CA DA 271 mov _RCAP2L,#0xda + 272 ; serial.c 33 + 0011 C2 98 273 clr _RI + 274 ; serial.c 34 + 0013 C2 99 275 clr _TI + 276 ; serial.c 36 + 0015 90s00r03 277 mov dptr,#_srx_index_out + 278 ; Peephole 180 changed mov to clr + 0018 E4 279 clr a + 0019 F0 280 movx @dptr,a + 001A 90s00r02 281 mov dptr,#_stx_index_out + 282 ; Peephole 180 changed mov to clr + 001D E4 283 clr a + 001E F0 284 movx @dptr,a + 001F 90s00r01 285 mov dptr,#_srx_index_in + 286 ; Peephole 180 changed mov to clr + 0022 E4 287 clr a + 0023 F0 288 movx @dptr,a + 0024 90s00r00 289 mov dptr,#_stx_index_in + 290 ; Peephole 180 changed mov to clr + 0027 E4 291 clr a + 0028 F0 292 movx @dptr,a + 293 ; serial.c 37 + 0029 D2*02 294 setb _tx_serial_buffer_empty + 002B D2*03 295 setb _rx_serial_buffer_empty + 296 ; serial.c 38 + 002D C2*01 297 clr _work_flag_buffer_transfered + 298 ; serial.c 39 + 002F C2*00 299 clr _work_flag_byte_arrived + 300 ; serial.c 40 + 0031 D2 AC 301 setb _ES + 0033 302 00101$: + 0033 303 C$serial.c$41$1$1 ==. + 0033 304 XG$serial_init$0$0 ==. + 0033 22 305 ret + 0034 306 G$serial_interrupt_handler$0$0 ==. + 307 ; serial.c 43 + 308 ; ----------------------------------------- + 309 ; function serial_interrupt_handler + 310 ; ----------------------------------------- + 0034 311 _serial_interrupt_handler: + 000A 312 ar2 = 0x0a + 000B 313 ar3 = 0x0b + 000C 314 ar4 = 0x0c + 000D 315 ar5 = 0x0d + 000E 316 ar6 = 0x0e + 000F 317 ar7 = 0x0f + 0008 318 ar0 = 0x08 + 0009 319 ar1 = 0x09 + 0034 C0 E0 320 push acc + 0036 C0 F0 321 push b + 0038 C0 82 322 push dpl + 003A C0 83 323 push dph + 003C C0 D0 324 push psw + 003E 75 D0 08 325 mov psw,#0x08 + 326 ; serial.c 45 + 0041 C2 AC 327 clr _ES + 328 ; serial.c 46 + 329 ; Peephole 111 removed ljmp by inverse jump logic + 0043 30 99 29 330 jnb _TI,00105$ + 0046 331 00113$: + 332 ; serial.c 48 + 0046 C2 99 333 clr _TI + 334 ; serial.c 49 + 0048 90s00r00 335 mov dptr,#_stx_index_in + 004B E0 336 movx a,@dptr + 004C FA 337 mov r2,a + 004D 90s00r02 338 mov dptr,#_stx_index_out + 0050 E0 339 movx a,@dptr + 340 ; Peephole 105 removed redundant mov + 0051 FB 341 mov r3,a + 342 ; Peephole 132 changed ljmp to sjmp + 343 ; Peephole 199 optimized misc jump sequence + 0052 B5 0A 06 344 cjne a,ar2,00102$ + 345 ; Peephole 201 removed redundant sjmp + 0055 346 00114$: + 0055 347 00115$: + 348 ; serial.c 51 + 0055 D2*02 349 setb _tx_serial_buffer_empty + 350 ; serial.c 52 + 0057 D2*01 351 setb _work_flag_buffer_transfered + 352 ; Peephole 132 changed ljmp to sjmp + 0059 80 14 353 sjmp 00105$ + 005B 354 00102$: + 355 ; serial.c 54 + 005B 90s00r02 356 mov dptr,#_stx_index_out + 005E 74 01 357 mov a,#0x01 + 0060 2B 358 add a,r3 + 0061 F0 359 movx @dptr,a + 0062 EB 360 mov a,r3 + 0063 24r04 361 add a,#_stx_buffer + 0065 F5 82 362 mov dpl,a + 363 ; Peephole 180 changed mov to clr + 0067 E4 364 clr a + 0068 34s00 365 addc a,#(_stx_buffer >> 8) + 006A F5 83 366 mov dph,a + 006C E0 367 movx a,@dptr + 006D F5 99 368 mov _SBUF,a + 006F 369 00105$: + 370 ; serial.c 56 + 371 ; Peephole 111 removed ljmp by inverse jump logic + 006F 30 98 1F 372 jnb _RI,00107$ + 0072 373 00116$: + 374 ; serial.c 58 + 0072 C2 98 375 clr _RI + 376 ; serial.c 59 + 0074 90s00r01 377 mov dptr,#_srx_index_in + 0077 E0 378 movx a,@dptr + 0078 FA 379 mov r2,a + 0079 90s00r01 380 mov dptr,#_srx_index_in + 007C 74 01 381 mov a,#0x01 + 007E 2A 382 add a,r2 + 007F F0 383 movx @dptr,a + 0080 EA 384 mov a,r2 + 0081 24r04 385 add a,#_srx_buffer + 0083 F5 82 386 mov dpl,a + 387 ; Peephole 180 changed mov to clr + 0085 E4 388 clr a + 0086 34s01 389 addc a,#(_srx_buffer >> 8) + 0088 F5 83 390 mov dph,a + 008A E5 99 391 mov a,_SBUF + 008C F0 392 movx @dptr,a + 393 ; serial.c 60 + 008D D2*00 394 setb _work_flag_byte_arrived + 395 ; serial.c 61 + 008F C2*03 396 clr _rx_serial_buffer_empty + 0091 397 00107$: + 398 ; serial.c 63 + 0091 D2 AC 399 setb _ES + 0093 400 00108$: + 0093 D0 D0 401 pop psw + 0095 D0 83 402 pop dph + 0097 D0 82 403 pop dpl + 0099 D0 F0 404 pop b + 009B D0 E0 405 pop acc + 009D 406 C$serial.c$64$1$1 ==. + 009D 407 XG$serial_interrupt_handler$0$0 ==. + 009D 32 408 reti + 009E 409 G$serial_putc$0$0 ==. + 410 ; serial.c 68 + 411 ; ----------------------------------------- + 412 ; function serial_putc + 413 ; ----------------------------------------- + 009E 414 _serial_putc: + 0002 415 ar2 = 0x02 + 0003 416 ar3 = 0x03 + 0004 417 ar4 = 0x04 + 0005 418 ar5 = 0x05 + 0006 419 ar6 = 0x06 + 0007 420 ar7 = 0x07 + 0000 421 ar0 = 0x00 + 0001 422 ar1 = 0x01 + 423 ; serial.c 77 + 009E C0 82 424 push dpl + 00A0 90s02r04 425 mov dptr,#_serial_putc_c_1_1 + 00A3 D0 E0 426 pop acc + 00A5 F0 427 movx @dptr,a + 428 ; serial.c 70 + 00A6 90s00r00 429 mov dptr,#_stx_index_in + 00A9 E0 430 movx a,@dptr + 00AA FA 431 mov r2,a + 00AB 90s00r00 432 mov dptr,#_stx_index_in + 00AE 74 01 433 mov a,#0x01 + 00B0 2A 434 add a,r2 + 00B1 F0 435 movx @dptr,a + 00B2 EA 436 mov a,r2 + 00B3 24r04 437 add a,#_stx_buffer + 00B5 FA 438 mov r2,a + 439 ; Peephole 180 changed mov to clr + 00B6 E4 440 clr a + 00B7 34s00 441 addc a,#(_stx_buffer >> 8) + 00B9 FB 442 mov r3,a + 00BA 90s02r04 443 mov dptr,#_serial_putc_c_1_1 + 00BD E0 444 movx a,@dptr + 445 ; Peephole 136 removed redundant moves + 00BE FC 446 mov r4,a + 00BF 8A 82 447 mov dpl,r2 + 00C1 8B 83 448 mov dph,r3 + 00C3 F0 449 movx @dptr,a + 450 ; serial.c 71 + 00C4 C2 AC 451 clr _ES + 452 ; serial.c 72 + 453 ; Peephole 111 removed ljmp by inverse jump logic + 00C6 30*02 04 454 jnb _tx_serial_buffer_empty,00102$ + 00C9 455 00106$: + 456 ; serial.c 74 + 00C9 C2*02 457 clr _tx_serial_buffer_empty + 458 ; serial.c 75 + 00CB D2 99 459 setb _TI + 00CD 460 00102$: + 461 ; serial.c 77 + 00CD D2 AC 462 setb _ES + 00CF 463 00103$: + 00CF 464 C$serial.c$78$1$1 ==. + 00CF 465 XG$serial_putc$0$0 ==. + 00CF 22 466 ret + 00D0 467 G$serial_getc$0$0 ==. + 468 ; serial.c 80 + 469 ; ----------------------------------------- + 470 ; function serial_getc + 471 ; ----------------------------------------- + 00D0 472 _serial_getc: + 473 ; serial.c 82 + 00D0 90s00r03 474 mov dptr,#_srx_index_out + 00D3 E0 475 movx a,@dptr + 476 ; Peephole 214 reduced some extra movs + 00D4 FA 477 mov r2,a + 00D5 24 01 478 add a,#0x01 + 479 ; Peephole 100 removed redundant mov + 00D7 FB 480 mov r3,a + 00D8 90s00r03 481 mov dptr,#_srx_index_out + 00DB F0 482 movx @dptr,a + 00DC EA 483 mov a,r2 + 00DD 24r04 484 add a,#_srx_buffer + 00DF F5 82 485 mov dpl,a + 486 ; Peephole 180 changed mov to clr + 00E1 E4 487 clr a + 00E2 34s01 488 addc a,#(_srx_buffer >> 8) + 00E4 F5 83 489 mov dph,a + 00E6 E0 490 movx a,@dptr + 00E7 FA 491 mov r2,a + 492 ; serial.c 83 + 00E8 C2 AC 493 clr _ES + 494 ; serial.c 84 + 00EA 90s00r01 495 mov dptr,#_srx_index_in + 00ED E0 496 movx a,@dptr + 00EE FC 497 mov r4,a + 00EF EB 498 mov a,r3 + 499 ; Peephole 132 changed ljmp to sjmp + 500 ; Peephole 199 optimized misc jump sequence + 00F0 B5 04 02 501 cjne a,ar4,00102$ + 502 ; Peephole 201 removed redundant sjmp + 00F3 503 00106$: + 00F3 504 00107$: + 00F3 D2*03 505 setb _rx_serial_buffer_empty + 00F5 506 00102$: + 507 ; serial.c 85 + 00F5 D2 AC 508 setb _ES + 509 ; serial.c 86 + 00F7 8A 82 510 mov dpl,r2 + 00F9 511 00103$: + 00F9 512 C$serial.c$87$1$1 ==. + 00F9 513 XG$serial_getc$0$0 ==. + 00F9 22 514 ret + 515 .area CSEG (CODE) diff --git a/device/lib/serial.sym b/device/lib/serial.sym new file mode 100644 index 00000000..8008211d --- /dev/null +++ b/device/lib/serial.sym @@ -0,0 +1,701 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$serial$261 0000 GR + 7 A$serial$263 0003 GR + 7 A$serial$265 0006 GR + 7 A$serial$267 0008 GR + 7 A$serial$269 000B GR + 7 A$serial$271 000E GR + 7 A$serial$273 0011 GR + 7 A$serial$275 0013 GR + 7 A$serial$277 0015 GR + 7 A$serial$279 0018 GR + 7 A$serial$280 0019 GR + 7 A$serial$281 001A GR + 7 A$serial$283 001D GR + 7 A$serial$284 001E GR + 7 A$serial$285 001F GR + 7 A$serial$287 0022 GR + 7 A$serial$288 0023 GR + 7 A$serial$289 0024 GR + 7 A$serial$291 0027 GR + 7 A$serial$292 0028 GR + 7 A$serial$294 0029 GR + 7 A$serial$295 002B GR + 7 A$serial$297 002D GR + 7 A$serial$299 002F GR + 7 A$serial$301 0031 GR + 7 A$serial$305 0033 GR + 7 A$serial$320 0034 GR + 7 A$serial$321 0036 GR + 7 A$serial$322 0038 GR + 7 A$serial$323 003A GR + 7 A$serial$324 003C GR + 7 A$serial$325 003E GR + 7 A$serial$327 0041 GR + 7 A$serial$330 0043 GR + 7 A$serial$333 0046 GR + 7 A$serial$335 0048 GR + 7 A$serial$336 004B GR + 7 A$serial$337 004C GR + 7 A$serial$338 004D GR + 7 A$serial$339 0050 GR + 7 A$serial$341 0051 GR + 7 A$serial$344 0052 GR + 7 A$serial$349 0055 GR + 7 A$serial$351 0057 GR + 7 A$serial$353 0059 GR + 7 A$serial$356 005B GR + 7 A$serial$357 005E GR + 7 A$serial$358 0060 GR + 7 A$serial$359 0061 GR + 7 A$serial$360 0062 GR + 7 A$serial$361 0063 GR + 7 A$serial$362 0065 GR + 7 A$serial$364 0067 GR + 7 A$serial$365 0068 GR + 7 A$serial$366 006A GR + 7 A$serial$367 006C GR + 7 A$serial$368 006D GR + 7 A$serial$372 006F GR + 7 A$serial$375 0072 GR + 7 A$serial$377 0074 GR + 7 A$serial$378 0077 GR + 7 A$serial$379 0078 GR + 7 A$serial$380 0079 GR + 7 A$serial$381 007C GR + 7 A$serial$382 007E GR + 7 A$serial$383 007F GR + 7 A$serial$384 0080 GR + 7 A$serial$385 0081 GR + 7 A$serial$386 0083 GR + 7 A$serial$388 0085 GR + 7 A$serial$389 0086 GR + 7 A$serial$390 0088 GR + 7 A$serial$391 008A GR + 7 A$serial$392 008C GR + 7 A$serial$394 008D GR + 7 A$serial$396 008F GR + 7 A$serial$399 0091 GR + 7 A$serial$401 0093 GR + 7 A$serial$402 0095 GR + 7 A$serial$403 0097 GR + 7 A$serial$404 0099 GR + 7 A$serial$405 009B GR + 7 A$serial$408 009D GR + 7 A$serial$424 009E GR + 7 A$serial$425 00A0 GR + 7 A$serial$426 00A3 GR + 7 A$serial$427 00A5 GR + 7 A$serial$429 00A6 GR + 7 A$serial$430 00A9 GR + 7 A$serial$431 00AA GR + 7 A$serial$432 00AB GR + 7 A$serial$433 00AE GR + 7 A$serial$434 00B0 GR + 7 A$serial$435 00B1 GR + 7 A$serial$436 00B2 GR + 7 A$serial$437 00B3 GR + 7 A$serial$438 00B5 GR + 7 A$serial$440 00B6 GR + 7 A$serial$441 00B7 GR + 7 A$serial$442 00B9 GR + 7 A$serial$443 00BA GR + 7 A$serial$444 00BD GR + 7 A$serial$446 00BE GR + 7 A$serial$447 00BF GR + 7 A$serial$448 00C1 GR + 7 A$serial$449 00C3 GR + 7 A$serial$451 00C4 GR + 7 A$serial$454 00C6 GR + 7 A$serial$457 00C9 GR + 7 A$serial$459 00CB GR + 7 A$serial$462 00CD GR + 7 A$serial$466 00CF GR + 7 A$serial$474 00D0 GR + 7 A$serial$475 00D3 GR + 7 A$serial$477 00D4 GR + 7 A$serial$478 00D5 GR + 7 A$serial$480 00D7 GR + 7 A$serial$481 00D8 GR + 7 A$serial$482 00DB GR + 7 A$serial$483 00DC GR + 7 A$serial$484 00DD GR + 7 A$serial$485 00DF GR + 7 A$serial$487 00E1 GR + 7 A$serial$488 00E2 GR + 7 A$serial$489 00E4 GR + 7 A$serial$490 00E6 GR + 7 A$serial$491 00E7 GR + 7 A$serial$493 00E8 GR + 7 A$serial$495 00EA GR + 7 A$serial$496 00ED GR + 7 A$serial$497 00EE GR + 7 A$serial$498 00EF GR + 7 A$serial$501 00F0 GR + 7 A$serial$505 00F3 GR + 7 A$serial$508 00F5 GR + 7 A$serial$510 00F7 GR + 7 A$serial$514 00F9 GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$serial.c$41$1$1 = 0033 GR + 7 C$serial.c$64$1$1 = 009D GR + 7 C$serial.c$78$1$1 = 00CF GR + 7 C$serial.c$87$1$1 = 00F9 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 4 Fserial$rx_serial_buffer_empty$0$0 = 0003 GR + 5 Fserial$srx_buffer$0$0 = 0104 GR + 5 Fserial$srx_index_in$0$0 = 0001 GR + 5 Fserial$srx_index_out$0$0 = 0003 GR + 5 Fserial$stx_buffer$0$0 = 0004 GR + 5 Fserial$stx_index_in$0$0 = 0000 GR + 5 Fserial$stx_index_out$0$0 = 0002 GR + 4 Fserial$tx_serial_buffer_empty$0$0 = 0002 GR + 4 Fserial$work_flag_buffer_transfered$0$0 = 0001 GR + 4 Fserial$work_flag_byte_arrived$0$0 = 0000 GR + G$AC$0$0 = 00D6 G + G$ACC$0$0 = 00E0 G + G$AUXR$0$0 = 008E G + G$B$0$0 = 00F0 G + G$CY$0$0 = 00D7 G + G$DPH$0$0 = 0083 G + G$DPL$0$0 = 0082 G + G$EA$0$0 = 00AF G + G$ES$0$0 = 00AC G + G$ET0$0$0 = 00A9 G + G$ET1$0$0 = 00AB G + G$EX0$0$0 = 00A8 G + G$EX1$0$0 = 00AA G + G$F0$0$0 = 00D5 G + G$IE$0$0 = 00A8 G + G$IE0$0$0 = 0089 G + G$IE1$0$0 = 008B G + G$INT0$0$0 = 00B2 G + G$INT1$0$0 = 00B3 G + G$IP$0$0 = 00B8 G + G$IT0$0$0 = 0088 G + G$IT1$0$0 = 008A G + G$OV$0$0 = 00D2 G + G$P$0$0 = 00D0 G + G$P0$0$0 = 0080 G + G$P1$0$0 = 0090 G + G$P1_0$0$0 = 0090 G + G$P1_1$0$0 = 0091 G + G$P1_2$0$0 = 0092 G + G$P1_3$0$0 = 0093 G + G$P1_4$0$0 = 0094 G + G$P1_5$0$0 = 0095 G + G$P1_6$0$0 = 0096 G + G$P1_7$0$0 = 0097 G + G$P2$0$0 = 00A0 G + G$P3$0$0 = 00B0 G + G$PCON$0$0 = 0087 G + G$PS$0$0 = 00BC G + G$PSW$0$0 = 00D0 G + G$PT0$0$0 = 00B9 G + G$PT1$0$0 = 00BB G + G$PX0$0$0 = 00B8 G + G$PX1$0$0 = 00BA G + G$RB8$0$0 = 009A G + G$RCAP2H$0$0 = 00CB G + G$RCAP2L$0$0 = 00CA G + G$RD$0$0 = 00B7 G + G$REN$0$0 = 009C G + G$RI$0$0 = 0098 G + G$RS0$0$0 = 00D3 G + G$RS1$0$0 = 00D4 G + G$RXD$0$0 = 00B0 G + G$SBUF$0$0 = 0099 G + G$SCON$0$0 = 0098 G + G$SM0$0$0 = 009F G + G$SM1$0$0 = 009E G + G$SM2$0$0 = 009D G + G$SP$0$0 = 0081 G + G$T0$0$0 = 00B4 G + G$T1$0$0 = 00B5 G + G$T2CON$0$0 = 00C8 G + G$T2CON_0$0$0 = 00C8 G + G$T2CON_1$0$0 = 00C9 G + G$T2CON_2$0$0 = 00CA G + G$T2CON_3$0$0 = 00CB G + G$T2CON_4$0$0 = 00CC G + G$T2CON_5$0$0 = 00CD G + G$T2CON_6$0$0 = 00CE G + G$T2CON_7$0$0 = 00CF G + G$TB8$0$0 = 009B G + G$TCON$0$0 = 0088 G + G$TF0$0$0 = 008D G + G$TF1$0$0 = 008F G + G$TH0$0$0 = 008C G + G$TH1$0$0 = 008D G + G$TI$0$0 = 0099 G + G$TL0$0$0 = 008A G + G$TL1$0$0 = 008B G + G$TMOD$0$0 = 0089 G + G$TR0$0$0 = 008C G + G$TR1$0$0 = 008E G + G$TXD$0$0 = 00B1 G + G$WR$0$0 = 00B6 G + 7 G$serial_getc$0$0 = 00D0 GR + 7 G$serial_init$0$0 = 0000 GR + 7 G$serial_interrupt_handler$0$0 = 0034 GR + 7 G$serial_putc$0$0 = 009E GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XG$serial_getc$0$0 = 00F9 GR + 7 XG$serial_init$0$0 = 0033 GR + 7 XG$serial_interrupt_handler$0$0 = 009D GR + 7 XG$serial_putc$0$0 = 00CF GR + _AC = 00D6 + _ACC = 00E0 + _AUXR = 008E + _B = 00F0 + _CY = 00D7 + _DPH = 0083 + _DPL = 0082 + _EA = 00AF + _ES = 00AC + _ET0 = 00A9 + _ET1 = 00AB + _EX0 = 00A8 + _EX1 = 00AA + _F0 = 00D5 + _IE = 00A8 + _IE0 = 0089 + _IE1 = 008B + _INT0 = 00B2 + _INT1 = 00B3 + _IP = 00B8 + _IT0 = 0088 + _IT1 = 008A + _OV = 00D2 + _P = 00D0 + _P0 = 0080 + _P1 = 0090 + _P1_0 = 0090 + _P1_1 = 0091 + _P1_2 = 0092 + _P1_3 = 0093 + _P1_4 = 0094 + _P1_5 = 0095 + _P1_6 = 0096 + _P1_7 = 0097 + _P2 = 00A0 + _P3 = 00B0 + _PCON = 0087 + _PS = 00BC + _PSW = 00D0 + _PT0 = 00B9 + _PT1 = 00BB + _PX0 = 00B8 + _PX1 = 00BA + _RB8 = 009A + _RCAP2H = 00CB + _RCAP2L = 00CA + _RD = 00B7 + _REN = 009C + _RI = 0098 + _RS0 = 00D3 + _RS1 = 00D4 + _RXD = 00B0 + _SBUF = 0099 + _SCON = 0098 + _SM0 = 009F + _SM1 = 009E + _SM2 = 009D + _SP = 0081 + _T0 = 00B4 + _T1 = 00B5 + _T2CON = 00C8 + _T2CON_0 = 00C8 + _T2CON_1 = 00C9 + _T2CON_2 = 00CA + _T2CON_3 = 00CB + _T2CON_4 = 00CC + _T2CON_5 = 00CD + _T2CON_6 = 00CE + _T2CON_7 = 00CF + _TB8 = 009B + _TCON = 0088 + _TF0 = 008D + _TF1 = 008F + _TH0 = 008C + _TH1 = 008D + _TI = 0099 + _TL0 = 008A + _TL1 = 008B + _TMOD = 0089 + _TR0 = 008C + _TR1 = 008E + _TXD = 00B1 + _WR = 00B6 + 4 _rx_serial_buffer_empty 0003 R + 7 _serial_getc 00D0 GR + 7 _serial_init 0000 GR + 7 _serial_interrupt_handler 0034 GR + 7 _serial_putc 009E GR + 5 _serial_putc_c_1_1 0204 R + 5 _srx_buffer 0104 R + 5 _srx_index_in 0001 R + 5 _srx_index_out 0003 R + 5 _stx_buffer 0004 R + 5 _stx_index_in 0000 R + 5 _stx_index_out 0002 R + 4 _tx_serial_buffer_empty 0002 R + 4 _work_flag_buffer_transfered 0001 R + 4 _work_flag_byte_arrived 0000 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 0 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size 4 flags 80 + 5 XSEG size 205 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size FA flags 20 diff --git a/device/lib/small/_atoi.asm b/device/lib/small/_atoi.asm new file mode 100644 index 00000000..67380628 --- /dev/null +++ b/device/lib/small/_atoi.asm @@ -0,0 +1,247 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:30:25 2000 + +;-------------------------------------------------------- + .module _atoi +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _atoi +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_atoi_s_1_1: + .ds 0x0003 +_atoi_rv_1_1: + .ds 0x0002 +_atoi_sign_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$atoi$0$0 ==. +; _atoi.c 25 +; ----------------------------------------- +; function atoi +; ----------------------------------------- +_atoi: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _atoi.c 0 + mov _atoi_s_1_1,dpl + mov (_atoi_s_1_1 + 1),dph + mov (_atoi_s_1_1 + 2),b +; _atoi.c 27 + clr a + mov (_atoi_rv_1_1 + 1),a + mov _atoi_rv_1_1,a +; _atoi.c 31 + mov r7,_atoi_s_1_1 + mov r0,(_atoi_s_1_1 + 1) + mov r1,(_atoi_s_1_1 + 2) +00107$: + mov dpl,r7 + mov dph,r0 + mov b,r1 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00109$ +00133$: +; _atoi.c 32 + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r2 + xrl b,#0x80 + subb a,b +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00134$: + clr c + mov a,r2 + xrl a,#0x80 + subb a,#0xb0 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00109$ +00135$: +; _atoi.c 33 +00102$: +; _atoi.c 34 + cjne r2,#0x2d,00136$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00136$: + cjne r2,#0x2b,00137$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00137$: +; _atoi.c 36 + inc r7 + cjne r7,#0x00,00138$ + inc r0 +00138$: +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00109$: +; _atoi.c 39 + mov _atoi_s_1_1,r7 + mov (_atoi_s_1_1 + 1),r0 + mov (_atoi_s_1_1 + 2),r1 + cjne r2,#0x2d,00139$ + mov a,#0x01 + sjmp 00140$ +00139$: + clr a +00140$: +; _atoi.c 40 +; Peephole 166 removed redundant mov + mov r3,a + mov _atoi_sign_1_1,r3 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00110$ +00141$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r2,#0x2b,00131$ +; Peephole 201 removed redundant sjmp +00142$: +00143$: +00110$: + inc _atoi_s_1_1 + clr a + cjne a,_atoi_s_1_1,00144$ + inc (_atoi_s_1_1 + 1) +00144$: +; _atoi.c 42 +00131$: + mov r2,_atoi_s_1_1 + mov r3,(_atoi_s_1_1 + 1) + mov r7,(_atoi_s_1_1 + 2) +00115$: + mov dpl,r2 + mov dph,r3 + mov b,r7 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a + jnz 00145$ + ljmp 00117$ +00145$: + clr c + mov a,r0 + xrl a,#0x80 + subb a,#0xb0 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00117$ +00146$: + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r0 + xrl b,#0x80 + subb a,b +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00117$ +00147$: +; _atoi.c 43 + clr a + mov (__mulsint_PARM_2 + 1),a + mov __mulsint_PARM_2,#0x0a + push ar2 + push ar3 + push ar7 + push ar0 + mov dpl,_atoi_rv_1_1 + mov dph,(_atoi_rv_1_1 + 1) + lcall __mulsint + mov r1,dpl + mov r4,dph + pop ar0 + pop ar7 + pop ar3 + pop ar2 + mov a,r0 + add a,#0xd0 + mov r0,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r5,a + mov a,r0 + add a,r1 + mov _atoi_rv_1_1,a + mov a,r5 + addc a,r4 + mov (_atoi_rv_1_1 + 1),a +; _atoi.c 44 + inc r2 + cjne r2,#0x00,00148$ + inc r3 +00148$: + ljmp 00115$ +00117$: +; _atoi.c 47 + mov a,_atoi_sign_1_1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00120$ +00149$: + clr c + clr a + subb a,_atoi_rv_1_1 + mov r2,a + clr a + subb a,(_atoi_rv_1_1 + 1) + mov r3,a +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00120$: + mov r2,_atoi_rv_1_1 + mov r3,(_atoi_rv_1_1 + 1) +00121$: + mov dpl,r2 + mov dph,r3 +00118$: + C$_atoi.c$48$1$1 ==. + XG$atoi$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_atoi.cdb b/device/lib/small/_atoi.cdb new file mode 100644 index 00000000..f79ca306 --- /dev/null +++ b/device/lib/small/_atoi.cdb @@ -0,0 +1,2 @@ +M:_atoi +F:G$atoi$0$0({2}DF,SI:S),C,0,0,0,0,0 diff --git a/device/lib/small/_atoi.rel b/device/lib/small/_atoi.rel new file mode 100644 index 00000000..79a02f27 --- /dev/null +++ b/device/lib/small/_atoi.rel @@ -0,0 +1,268 @@ +;!FILE _atoi.asm +XH +H 8 areas 7C global symbols +M _atoi +S __mulsint Ref0000 +S __mulsint_PARM_2 Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size DF flags 20 +S A$_atoi$100 Def002E +S A$_atoi$200 Def00A9 +S A$_atoi$110 Def0037 +S A$_atoi$101 Def0030 +S A$_atoi$210 Def00B7 +S A$_atoi$201 Def00AB +S A$_atoi$211 Def00B8 +S A$_atoi$202 Def00AD +S A$_atoi$130 Def0050 +S A$_atoi$112 Def0039 +S A$_atoi$103 Def0032 +S A$_atoi$230 Def00CD +S A$_atoi$221 Def00C4 +S A$_atoi$212 Def00B9 +S A$_atoi$203 Def00AF +S A$_atoi$122 Def0043 +S A$_atoi$231 Def00CF +S A$_atoi$213 Def00BB +S A$_atoi$204 Def00B0 +S A$_atoi$150 Def005E +S A$_atoi$132 Def0052 +S A$_atoi$114 Def003C +S A$_atoi$241 Def00DA +S A$_atoi$232 Def00D0 +S A$_atoi$214 Def00BC +S A$_atoi$205 Def00B2 +S A$_atoi$160 Def006B +S A$_atoi$151 Def0061 +S _atoi Def0000 +S A$_atoi$242 Def00DC +S A$_atoi$233 Def00D1 +S A$_atoi$224 Def00C7 +S A$_atoi$215 Def00BD +S A$_atoi$170 Def007A +S A$_atoi$161 Def006D +S A$_atoi$143 Def0058 +S A$_atoi$125 Def0045 +S A$_atoi$234 Def00D3 +S A$_atoi$207 Def00B3 +S A$_atoi$180 Def0085 +S A$_atoi$171 Def007C +S A$_atoi$162 Def006F +S A$_atoi$126 Def0047 +S A$_atoi$117 Def003E +S A$_atoi$108 Def0034 +S A$_atoi$226 Def00C9 +S A$_atoi$217 Def00BF +S A$_atoi$208 Def00B4 +S A$_atoi$190 Def0092 +S A$_atoi$181 Def0088 +S A$_atoi$136 Def0053 +S A$_atoi$127 Def0049 +S A$_atoi$118 Def003F +S A$_atoi$236 Def00D4 +S A$_atoi$218 Def00C0 +S A$_atoi$209 Def00B6 +S A$_atoi$191 Def0094 +S A$_atoi$164 Def0072 +S A$_atoi$155 Def0063 +S A$_atoi$137 Def0054 +S A$_atoi$128 Def004B +S A$_atoi$119 Def0042 +S A$_atoi$246 Def00DE +S A$_atoi$228 Def00CB +S A$_atoi$219 Def00C3 +S A$_atoi$192 Def0096 +S A$_atoi$174 Def007E +S A$_atoi$165 Def0073 +S A$_atoi$156 Def0065 +S A$_atoi$129 Def004E +S A$_atoi$238 Def00D6 +S A$_atoi$229 Def00CC +S A$_atoi$193 Def0098 +S A$_atoi$184 Def008A +S A$_atoi$166 Def0075 +S A$_atoi$157 Def0067 +S A$_atoi$148 Def005B +S A$_atoi$139 Def0056 +S A$_atoi$239 Def00D8 +S A$_atoi$194 Def009A +S A$_atoi$176 Def0080 +S A$_atoi$149 Def005D +S A$_atoi$195 Def009D +S A$_atoi$168 Def0078 +S A$_atoi$159 Def0069 +S A$_atoi$196 Def00A0 +S A$_atoi$187 Def008C +S A$_atoi$178 Def0081 +S A$_atoi$169 Def0079 +S A$_atoi$197 Def00A3 +S A$_atoi$188 Def008D +S A$_atoi$179 Def0083 +S A$_atoi$198 Def00A5 +S A$_atoi$189 Def008F +S A$_atoi$199 Def00A7 +S XG$atoi$0$0 Def00DE +S A$_atoi$70 Def0009 +S A$_atoi$80 Def0018 +S A$_atoi$71 Def000A +S A$_atoi$90 Def0021 +S A$_atoi$81 Def001A +S A$_atoi$72 Def000C +S C$_atoi.c$48$1$1 Def00DE +S A$_atoi$91 Def0023 +S A$_atoi$92 Def0025 +S A$_atoi$83 Def001D +S A$_atoi$74 Def000E +S G$atoi$0$0 Def0000 +S A$_atoi$93 Def0028 +S A$_atoi$75 Def0010 +S A$_atoi$66 Def0000 +S A$_atoi$85 Def001E +S A$_atoi$76 Def0012 +S A$_atoi$67 Def0003 +S A$_atoi$68 Def0006 +S A$_atoi$96 Def002A +S A$_atoi$78 Def0014 +S A$_atoi$88 Def0020 +S A$_atoi$79 Def0016 +S A$_atoi$98 Def002C +S A$_atoi$99 Def002D +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 85 82 00 00 85 83 00 01 85 F0 00 02 E4 F5 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 00 0B 00 04 F5 00 03 AF 00 00 A8 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 11 00 01 A9 00 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 14 +R 00 00 00 07 +T 00 14 8F 82 88 83 89 F0 12 00 00 FA 60 25 +R 00 00 00 07 02 09 00 02 +T 00 20 +R 00 00 00 07 +T 00 20 C3 74 B9 8A F0 63 F0 80 95 F0 40 08 +R 00 00 00 07 +T 00 2C +R 00 00 00 07 +T 00 2C C3 EA 64 80 94 B0 50 11 +R 00 00 00 07 +T 00 34 +R 00 00 00 07 +T 00 34 +R 00 00 00 07 +T 00 34 BA 2D 02 80 0C +R 00 00 00 07 +T 00 39 +R 00 00 00 07 +T 00 39 BA 2B 02 80 07 +R 00 00 00 07 +T 00 3E +R 00 00 00 07 +T 00 3E 0F BF 00 01 08 +R 00 00 00 07 +T 00 43 +R 00 00 00 07 +T 00 43 80 CF +R 00 00 00 07 +T 00 45 +R 00 00 00 07 +T 00 45 8F 00 00 88 00 01 89 00 02 BA 2D 04 74 01 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 50 80 01 +R 00 00 00 07 +T 00 52 +R 00 00 00 07 +T 00 52 E4 +R 00 00 00 07 +T 00 53 +R 00 00 00 07 +T 00 53 FB 8B 00 05 70 03 +R 00 00 00 07 29 04 00 01 +T 00 58 +R 00 00 00 07 +T 00 58 BA 2B 08 +R 00 00 00 07 +T 00 5B +R 00 00 00 07 +T 00 5B +R 00 00 00 07 +T 00 5B +R 00 00 00 07 +T 00 5B 05 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 63 +R 00 00 00 07 +T 00 63 +R 00 00 00 07 +T 00 63 AA 00 00 AB 00 01 AF 00 02 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 69 +R 00 00 00 07 +T 00 69 8A 82 8B 83 8F F0 12 00 00 F8 70 03 02 +R 00 00 00 07 02 09 00 02 +T 00 76 00 C7 +R 00 00 00 07 00 02 00 07 +T 00 78 +R 00 00 00 07 +T 00 78 C3 E8 64 80 94 B0 40 47 +R 00 00 00 07 +T 00 80 +R 00 00 00 07 +T 00 80 C3 74 B9 88 F0 63 F0 80 95 F0 40 3B +R 00 00 00 07 +T 00 8C +R 00 00 00 07 +T 00 8C E4 F5 00 01 75 00 00 0A C0 02 C0 03 C0 07 +R 00 00 00 07 2B 04 00 01 2B 07 00 01 +T 00 98 C0 00 85 00 03 82 85 00 04 83 12 00 00 A9 +R 00 00 00 07 29 05 00 01 29 09 00 01 02 0D 00 00 +T 00 A4 82 AC 83 D0 00 D0 07 D0 03 D0 02 E8 24 D0 +R 00 00 00 07 +T 00 B2 F8 E4 34 FF FD E8 29 F5 00 03 ED 3C F5 +R 00 00 00 07 29 0A 00 01 +T 00 BE 00 04 0A BA 00 01 0B +R 00 00 00 07 29 02 00 01 +T 00 C4 +R 00 00 00 07 +T 00 C4 02 00 69 +R 00 00 00 07 00 03 00 07 +T 00 C7 +R 00 00 00 07 +T 00 C7 E5 00 05 60 0B +R 00 00 00 07 29 03 00 01 +T 00 CB +R 00 00 00 07 +T 00 CB C3 E4 95 00 03 FA E4 95 00 04 FB 80 04 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 00 D6 +R 00 00 00 07 +T 00 D6 AA 00 03 AB 00 04 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 00 DA +R 00 00 00 07 +T 00 DA 8A 82 8B 83 +R 00 00 00 07 +T 00 DE +R 00 00 00 07 +T 00 DE 22 +R 00 00 00 07 diff --git a/device/lib/small/_atol.asm b/device/lib/small/_atol.asm new file mode 100644 index 00000000..98ec01f6 --- /dev/null +++ b/device/lib/small/_atol.asm @@ -0,0 +1,271 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:08 2000 + +;-------------------------------------------------------- + .module _atol +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _atol +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_atol_s_1_1: + .ds 0x0003 +_atol_rv_1_1: + .ds 0x0004 +_atol_sign_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$atol$0$0 ==. +; _atol.c 25 +; ----------------------------------------- +; function atol +; ----------------------------------------- +_atol: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _atol.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _atol.c 27 + clr a + mov (_atol_rv_1_1 + 3),a + mov (_atol_rv_1_1 + 2),a + mov (_atol_rv_1_1 + 1),a + mov _atol_rv_1_1,a +; _atol.c 31 + mov ar1,r2 + mov ar5,r3 + mov ar6,r4 +00107$: + mov dpl,r1 + mov dph,r5 + mov b,r6 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00109$ +00133$: +; _atol.c 32 + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r7 + xrl b,#0x80 + subb a,b +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00134$: + clr c + mov a,r7 + xrl a,#0x80 + subb a,#0xb0 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00109$ +00135$: +; _atol.c 33 +00102$: +; _atol.c 34 + cjne r7,#0x2d,00136$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00136$: + cjne r7,#0x2b,00137$ +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00137$: +; _atol.c 36 + inc r1 + cjne r1,#0x00,00138$ + inc r5 +00138$: +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00109$: +; _atol.c 39 + mov ar2,r1 + mov ar3,r5 + mov ar4,r6 + cjne r7,#0x2d,00139$ + mov a,#0x01 + sjmp 00140$ +00139$: + clr a +00140$: +; _atol.c 40 +; Peephole 166 removed redundant mov + mov r5,a + mov _atol_sign_1_1,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00110$ +00141$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r7,#0x2b,00131$ +; Peephole 201 removed redundant sjmp +00142$: +00143$: +00110$: + inc r2 + cjne r2,#0x00,00144$ + inc r3 +00144$: +; _atol.c 42 +00131$: + mov _atol_s_1_1,r2 + mov (_atol_s_1_1 + 1),r3 + mov (_atol_s_1_1 + 2),r4 +00115$: + mov dpl,_atol_s_1_1 + mov dph,(_atol_s_1_1 + 1) + mov b,(_atol_s_1_1 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a + jnz 00145$ + ljmp 00117$ +00145$: + clr c + mov a,r5 + xrl a,#0x80 + subb a,#0xb0 + jnc 00146$ + ljmp 00117$ +00146$: + clr c +; Peephole 159 avoided xrl during execution + mov a,#(0x39 ^ 0x80) + mov b,r5 + xrl b,#0x80 + subb a,b + jnc 00147$ + ljmp 00117$ +00147$: +; _atol.c 43 + clr a + mov (__mulslong_PARM_2 + 3),a + mov (__mulslong_PARM_2 + 2),a + mov (__mulslong_PARM_2 + 1),a + mov __mulslong_PARM_2,#0x0a + push ar5 + mov dpl,_atol_rv_1_1 + mov dph,(_atol_rv_1_1 + 1) + mov b,(_atol_rv_1_1 + 2) + mov a,(_atol_rv_1_1 + 3) + lcall __mulslong + mov r7,dpl + mov r0,dph + mov r1,b + mov r6,a + pop ar5 + mov a,r5 + add a,#0xd0 + mov r5,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r3,a +; Peephole 180 changed mov to clr + clr a + addc a,#0xff + mov r4,a + mov a,r5 + add a,r7 + mov _atol_rv_1_1,a + mov a,r2 + addc a,r0 + mov (_atol_rv_1_1 + 1),a + mov a,r3 + addc a,r1 + mov (_atol_rv_1_1 + 2),a + mov a,r4 + addc a,r6 + mov (_atol_rv_1_1 + 3),a +; _atol.c 44 + inc _atol_s_1_1 + clr a + cjne a,_atol_s_1_1,00148$ + inc (_atol_s_1_1 + 1) +00148$: + ljmp 00115$ +00117$: +; _atol.c 47 + mov a,_atol_sign_1_1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00120$ +00149$: + clr c + clr a + subb a,_atol_rv_1_1 + mov r2,a + clr a + subb a,(_atol_rv_1_1 + 1) + mov r3,a + clr a + subb a,(_atol_rv_1_1 + 2) + mov r4,a + clr a + subb a,(_atol_rv_1_1 + 3) + mov r5,a +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00120$: + mov r2,_atol_rv_1_1 + mov r3,(_atol_rv_1_1 + 1) + mov r4,(_atol_rv_1_1 + 2) + mov r5,(_atol_rv_1_1 + 3) +00121$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 +00118$: + C$_atol.c$48$1$1 ==. + XG$atol$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_atol.cdb b/device/lib/small/_atol.cdb new file mode 100644 index 00000000..110eace8 --- /dev/null +++ b/device/lib/small/_atol.cdb @@ -0,0 +1,2 @@ +M:_atol +F:G$atol$0$0({2}DF,SL:S),C,0,0,0,0,0 diff --git a/device/lib/small/_atol.rel b/device/lib/small/_atol.rel new file mode 100644 index 00000000..a67afbf2 --- /dev/null +++ b/device/lib/small/_atol.rel @@ -0,0 +1,300 @@ +;!FILE _atol.asm +XH +H 8 areas 96 global symbols +M _atol +S __mulslong_PARM_2 Ref0000 +S __mulslong Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 108 flags 20 +S A$_atol$100 Def002D +S A$_atol$200 Def00B3 +S A$_atol$110 Def0035 +S A$_atol$101 Def002E +S A$_atol$210 Def00BE +S A$_atol$201 Def00B4 +S A$_atol$120 Def0040 +S A$_atol$102 Def002F +S A$_atol$220 Def00CA +S A$_atol$211 Def00BF +S A$_atol$202 Def00B6 +S A$_atol$130 Def004C +S A$_atol$121 Def0043 +S A$_atol$112 Def0038 +S A$_atol$103 Def0031 +S A$_atol$230 Def00D6 +S A$_atol$221 Def00CB +S A$_atol$212 Def00C1 +S A$_atol$203 Def00B7 +S A$_atol$131 Def004F +S A$_atol$240 Def00E3 +S A$_atol$231 Def00D8 +S A$_atol$222 Def00CC +S A$_atol$204 Def00B9 +S A$_atol$150 Def005C +S A$_atol$141 Def0057 +S A$_atol$132 Def0051 +S A$_atol$114 Def003A +S A$_atol$105 Def0033 +S A$_atol$250 Def00EF +S A$_atol$232 Def00D9 +S A$_atol$223 Def00CE +S A$_atol$214 Def00C2 +S A$_atol$160 Def0067 +S A$_atol$151 Def005D +S A$_atol$124 Def0044 +S _atol Def0000 +S A$_atol$260 Def00FC +S A$_atol$251 Def00F1 +S A$_atol$242 Def00E5 +S A$_atol$233 Def00DC +S A$_atol$224 Def00CF +S A$_atol$215 Def00C3 +S A$_atol$206 Def00BA +S A$_atol$170 Def007A +S A$_atol$161 Def006A +S A$_atol$152 Def0060 +S A$_atol$134 Def0053 +S A$_atol$116 Def003D +S A$_atol$270 Def0107 +S A$_atol$261 Def00FE +S A$_atol$252 Def00F2 +S A$_atol$243 Def00E6 +S A$_atol$225 Def00D0 +S A$_atol$216 Def00C5 +S A$_atol$207 Def00BB +S A$_atol$180 Def0089 +S A$_atol$171 Def007B +S A$_atol$162 Def006D +S A$_atol$253 Def00F3 +S A$_atol$244 Def00E7 +S A$_atol$235 Def00DE +S A$_atol$226 Def00D2 +S A$_atol$217 Def00C6 +S A$_atol$208 Def00BD +S A$_atol$190 Def009A +S A$_atol$181 Def008C +S A$_atol$172 Def007D +S A$_atol$163 Def0070 +S A$_atol$145 Def0059 +S A$_atol$127 Def0046 +S A$_atol$263 Def0100 +S A$_atol$254 Def00F5 +S A$_atol$245 Def00E9 +S A$_atol$227 Def00D3 +S A$_atol$218 Def00C7 +S A$_atol$191 Def009D +S A$_atol$182 Def008E +S A$_atol$173 Def007F +S A$_atol$128 Def0048 +S A$_atol$119 Def003F +S A$_atol$264 Def0102 +S A$_atol$246 Def00EA +S A$_atol$228 Def00D4 +S A$_atol$219 Def00C8 +S A$_atol$192 Def009F +S A$_atol$183 Def0090 +S A$_atol$174 Def0081 +S A$_atol$165 Def0073 +S A$_atol$156 Def0061 +S A$_atol$138 Def0054 +S A$_atol$129 Def004A +S A$_atol$265 Def0104 +S A$_atol$256 Def00F6 +S A$_atol$247 Def00EB +S A$_atol$238 Def00E1 +S A$_atol$193 Def00A2 +S A$_atol$166 Def0074 +S A$_atol$157 Def0063 +S A$_atol$139 Def0055 +S A$_atol$266 Def0106 +S A$_atol$248 Def00ED +S A$_atol$194 Def00A5 +S A$_atol$176 Def0084 +S A$_atol$167 Def0076 +S A$_atol$158 Def0065 +S A$_atol$258 Def00F8 +S A$_atol$249 Def00EE +S A$_atol$195 Def00A8 +S A$_atol$186 Def0093 +S A$_atol$259 Def00FA +S A$_atol$196 Def00AA +S A$_atol$187 Def0094 +S A$_atol$178 Def0085 +S A$_atol$169 Def0079 +S A$_atol$197 Def00AD +S A$_atol$188 Def0096 +S A$_atol$179 Def0087 +S A$_atol$198 Def00AF +S A$_atol$189 Def0098 +S A$_atol$199 Def00B1 +S XG$atol$0$0 Def0107 +S A$_atol$70 Def0006 +S A$_atol$80 Def0015 +S A$_atol$71 Def0007 +S A$_atol$90 Def0021 +S A$_atol$81 Def0017 +S A$_atol$72 Def0009 +S C$_atol.c$48$1$1 Def0107 +S A$_atol$82 Def0019 +S A$_atol$73 Def000B +S A$_atol$92 Def0022 +S A$_atol$83 Def001B +S A$_atol$74 Def000D +S G$atol$0$0 Def0000 +S A$_atol$93 Def0024 +S A$_atol$66 Def0000 +S A$_atol$94 Def0026 +S A$_atol$85 Def001E +S A$_atol$76 Def000F +S A$_atol$67 Def0002 +S A$_atol$95 Def0029 +S A$_atol$77 Def0011 +S A$_atol$68 Def0004 +S A$_atol$87 Def001F +S A$_atol$78 Def0013 +S A$_atol$98 Def002B +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 07 +R 00 00 00 01 +T 00 07 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 E4 F5 00 06 F5 00 05 F5 +R 00 00 00 07 29 0A 00 01 29 0D 00 01 +T 00 0C 00 04 F5 00 03 8A 01 8B 05 8C 06 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 15 +R 00 00 00 07 +T 00 15 89 82 8D 83 8E F0 12 00 00 FF 60 25 +R 00 00 00 07 02 09 00 02 +T 00 21 +R 00 00 00 07 +T 00 21 C3 74 B9 8F F0 63 F0 80 95 F0 40 08 +R 00 00 00 07 +T 00 2D +R 00 00 00 07 +T 00 2D C3 EF 64 80 94 B0 50 11 +R 00 00 00 07 +T 00 35 +R 00 00 00 07 +T 00 35 +R 00 00 00 07 +T 00 35 BF 2D 02 80 0C +R 00 00 00 07 +T 00 3A +R 00 00 00 07 +T 00 3A BF 2B 02 80 07 +R 00 00 00 07 +T 00 3F +R 00 00 00 07 +T 00 3F 09 B9 00 01 0D +R 00 00 00 07 +T 00 44 +R 00 00 00 07 +T 00 44 80 CF +R 00 00 00 07 +T 00 46 +R 00 00 00 07 +T 00 46 89 02 8D 03 8E 04 BF 2D 04 74 01 80 01 +R 00 00 00 07 +T 00 53 +R 00 00 00 07 +T 00 53 E4 +R 00 00 00 07 +T 00 54 +R 00 00 00 07 +T 00 54 FD 8D 00 07 70 03 +R 00 00 00 07 29 04 00 01 +T 00 59 +R 00 00 00 07 +T 00 59 BF 2B 05 +R 00 00 00 07 +T 00 5C +R 00 00 00 07 +T 00 5C +R 00 00 00 07 +T 00 5C +R 00 00 00 07 +T 00 5C 0A BA 00 01 0B +R 00 00 00 07 +T 00 61 +R 00 00 00 07 +T 00 61 +R 00 00 00 07 +T 00 61 8A 00 00 8B 00 01 8C 00 02 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 67 +R 00 00 00 07 +T 00 67 85 00 00 82 85 00 01 83 85 00 02 F0 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 71 00 00 FD 70 03 02 00 E1 +R 00 00 00 07 02 02 00 02 00 08 00 07 +T 00 79 +R 00 00 00 07 +T 00 79 C3 ED 64 80 94 B0 50 03 02 00 E1 +R 00 00 00 07 00 0B 00 07 +T 00 84 +R 00 00 00 07 +T 00 84 C3 74 B9 8D F0 63 F0 80 95 F0 50 03 02 +R 00 00 00 07 +T 00 91 00 E1 +R 00 00 00 07 00 02 00 07 +T 00 93 +R 00 00 00 07 +T 00 93 E4 F5 00 03 F5 00 02 F5 00 01 75 +R 00 00 00 07 2B 04 00 00 2B 07 00 00 2B 0A 00 00 +T 00 9B 00 00 0A C0 05 85 00 03 82 85 00 04 83 85 +R 00 00 00 07 2B 02 00 00 29 08 00 01 29 0C 00 01 +T 00 A6 00 05 F0 E5 00 06 12 00 00 AF 82 A8 83 A9 +R 00 00 00 07 29 02 00 01 29 06 00 01 02 09 00 01 +T 00 B2 F0 FE D0 05 ED 24 D0 FD E4 34 FF FA E4 34 +R 00 00 00 07 +T 00 C0 FF FB E4 34 FF FC ED 2F F5 00 03 EA 38 F5 +R 00 00 00 07 29 0B 00 01 +T 00 CD 00 04 EB 39 F5 00 05 EC 3E F5 00 06 05 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 00 D7 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 DE +R 00 00 00 07 +T 00 DE 02 00 67 +R 00 00 00 07 00 03 00 07 +T 00 E1 +R 00 00 00 07 +T 00 E1 E5 00 07 60 13 +R 00 00 00 07 29 03 00 01 +T 00 E5 +R 00 00 00 07 +T 00 E5 C3 E4 95 00 03 FA E4 95 00 04 FB E4 95 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 00 F0 00 05 FC E4 95 00 06 FD 80 08 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 F8 +R 00 00 00 07 +T 00 F8 AA 00 03 AB 00 04 AC 00 05 AD +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 FF 00 06 +R 00 00 00 07 29 02 00 01 +T 01 00 +R 00 00 00 07 +T 01 00 8A 82 8B 83 8C F0 ED +R 00 00 00 07 +T 01 07 +R 00 00 00 07 +T 01 07 22 +R 00 00 00 07 diff --git a/device/lib/small/_autobaud.asm b/device/lib/small/_autobaud.asm new file mode 100644 index 00000000..757c3117 --- /dev/null +++ b/device/lib/small/_autobaud.asm @@ -0,0 +1,325 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:08 2000 + +;-------------------------------------------------------- + .module _autobaud +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _autobaud +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$autobaud$0$0 ==. +; _autobaud.c 52 +; ----------------------------------------- +; function autobaud +; ----------------------------------------- +_autobaud: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _autobaud.c 56 + mov _TMOD,#0x11 +; _autobaud.c 57 + mov _TCON,#0x00 +; _autobaud.c 58 + mov _TL1,#0x00 + mov _TH1,#0x00 +; _autobaud.c 62 +00101$: +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00142$: +; _autobaud.c 66 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00143$: +; _autobaud.c 67 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00144$: +; _autobaud.c 68 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00145$: +; _autobaud.c 69 +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00101$ +00146$: +; _autobaud.c 72 +00113$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _RXD,00113$ +00147$: +; _autobaud.c 73 + setb _TR1 +; _autobaud.c 74 +00116$: +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00116$ +00148$: +; _autobaud.c 75 +00119$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _RXD,00119$ +00149$: +; _autobaud.c 76 +00122$: +; Peephole 112 removed ljmp by inverse jump logic + jb _RXD,00122$ +00150$: +; _autobaud.c 77 +00125$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _RXD,00125$ +00151$: +; _autobaud.c 78 + clr _TR1 +; _autobaud.c 81 + mov a,_TH1 + add a,acc + mov r2,a + mov a,_TL1 + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r3,a + orl a,r2 +; _autobaud.c 84 +; Peephole 105 removed redundant mov + mov _TH1,a + add a,acc + mov r2,a + mov a,_TL1 + rl a + rl a +; Peephole 139 removed redundant mov +; Peephole 183 avoided anl during execution + anl a,#(0x03 & 0x01) + mov r3,a + orl a,r2 +; _autobaud.c 87 +; Peephole 105 removed redundant mov +; Peephole 184 removed redundant mov + cpl a +; _autobaud.c 90 +; Peephole 185 changed order of increment (acc incremented also!) + inc a + mov _TH1,a +; _autobaud.c 92 + mov _TL1,_TH1 +; _autobaud.c 93 + mov _TMOD,#0x21 +; _autobaud.c 94 + mov _PCON,#0x80 +; _autobaud.c 95 + mov _SCON,#0x52 +00128$: + C$_autobaud.c$96$1$1 ==. + XG$autobaud$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_autobaud.cdb b/device/lib/small/_autobaud.cdb new file mode 100644 index 00000000..f63b4c24 --- /dev/null +++ b/device/lib/small/_autobaud.cdb @@ -0,0 +1,85 @@ +M:_autobaud +F:G$autobaud$0$0({2}DF,SV:S),C,0,0,0,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/small/_autobaud.rel b/device/lib/small/_autobaud.rel new file mode 100644 index 00000000..7901545c --- /dev/null +++ b/device/lib/small/_autobaud.rel @@ -0,0 +1,210 @@ +;!FILE _autobaud.asm +XH +H 8 areas 80 global symbols +M _autobaud +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 58 flags 20 +S A$_autobaud$298 Def0041 +S XG$autobaud$0$0 Def0057 +S A$_autobaud$299 Def0042 +S G$autobaud$0$0 Def0000 +S C$_autobaud.c$96$1$1 Def0057 +S A$_autobaud$320 Def0054 +S A$_autobaud$311 Def0048 +S A$_autobaud$302 Def0043 +S A$_autobaud$230 Def0006 +S A$_autobaud$312 Def0049 +S A$_autobaud$303 Def0045 +S A$_autobaud$231 Def0009 +S A$_autobaud$304 Def0046 +S _autobaud Def0000 +S A$_autobaud$314 Def004B +S A$_autobaud$251 Def0018 +S A$_autobaud$324 Def0057 +S A$_autobaud$243 Def0012 +S A$_autobaud$316 Def004E +S A$_autobaud$235 Def000C +S A$_autobaud$226 Def0000 +S A$_autobaud$308 Def0047 +S A$_autobaud$290 Def0038 +S A$_autobaud$281 Def002C +S A$_autobaud$263 Def0020 +S A$_autobaud$318 Def0051 +S A$_autobaud$291 Def0039 +S A$_autobaud$273 Def0026 +S A$_autobaud$228 Def0003 +S A$_autobaud$283 Def002E +S A$_autobaud$256 Def001B +S A$_autobaud$247 Def0015 +S A$_autobaud$284 Def0030 +S A$_autobaud$239 Def000F +S A$_autobaud$294 Def003A +S A$_autobaud$285 Def0032 +S A$_autobaud$295 Def003C +S A$_autobaud$286 Def0033 +S A$_autobaud$268 Def0023 +S A$_autobaud$259 Def001E +S A$_autobaud$296 Def003E +S A$_autobaud$287 Def0035 +S A$_autobaud$278 Def0029 +S A$_autobaud$297 Def003F +S A$_autobaud$288 Def0036 +T 00 00 +R 00 00 00 07 +T 00 00 75 89 11 75 88 00 75 8B 00 75 8D 00 +R 00 00 00 07 +T 00 0C +R 00 00 00 07 +T 00 0C 20 B0 FD +R 00 00 00 07 +T 00 0F +R 00 00 00 07 +T 00 0F 20 B0 FA +R 00 00 00 07 +T 00 12 +R 00 00 00 07 +T 00 12 20 B0 F7 +R 00 00 00 07 +T 00 15 +R 00 00 00 07 +T 00 15 20 B0 F4 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 20 B0 F1 +R 00 00 00 07 +T 00 1B +R 00 00 00 07 +T 00 1B +R 00 00 00 07 +T 00 1B 30 B0 FD +R 00 00 00 07 +T 00 1E +R 00 00 00 07 +T 00 1E D2 8E +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 20 B0 FD +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 30 B0 FD +R 00 00 00 07 +T 00 26 +R 00 00 00 07 +T 00 26 +R 00 00 00 07 +T 00 26 20 B0 FD +R 00 00 00 07 +T 00 29 +R 00 00 00 07 +T 00 29 +R 00 00 00 07 +T 00 29 30 B0 FD +R 00 00 00 07 +T 00 2C +R 00 00 00 07 +T 00 2C C2 8E E5 8D 25 E0 FA E5 8B 23 54 01 FB 4A +R 00 00 00 07 +T 00 3A F5 8D 25 E0 FA E5 8B 23 23 54 01 FB 4A F4 +R 00 00 00 07 +T 00 48 04 F5 8D 85 8D 8B 75 89 21 75 87 80 75 98 +R 00 00 00 07 +T 00 56 52 +R 00 00 00 07 +T 00 57 +R 00 00 00 07 +T 00 57 22 +R 00 00 00 07 diff --git a/device/lib/small/_bp.asm b/device/lib/small/_bp.asm new file mode 100644 index 00000000..43f783ab --- /dev/null +++ b/device/lib/small/_bp.asm @@ -0,0 +1,48 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:08 2000 + +;-------------------------------------------------------- + .module _bp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _bp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +G$bp$0$0==. +_bp: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + .area CSEG (CODE) diff --git a/device/lib/small/_bp.cdb b/device/lib/small/_bp.cdb new file mode 100644 index 00000000..ffe2abde --- /dev/null +++ b/device/lib/small/_bp.cdb @@ -0,0 +1,2 @@ +M:_bp +S:G$bp$0$0({1}SC:U),E,0,0 diff --git a/device/lib/small/_bp.rel b/device/lib/small/_bp.rel new file mode 100644 index 00000000..837e0a53 --- /dev/null +++ b/device/lib/small/_bp.rel @@ -0,0 +1,17 @@ +XH +H 8 areas 2 global symbols +M _bp +A _CODE size 0 flags 0 +A DSEG size 1 flags 0 +S G$bp$0$0 Def0000 +S _bp Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 0 flags 20 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 diff --git a/device/lib/small/_char2fs.asm b/device/lib/small/_char2fs.asm new file mode 100644 index 00000000..9fdc33f3 --- /dev/null +++ b/device/lib/small/_char2fs.asm @@ -0,0 +1,214 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:08 2000 + +;-------------------------------------------------------- + .module _char2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___char2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___char2fs_sign_1_1: + .ds 0x0004 +___char2fs_fl_1_1: + .ds 0x0004 +___char2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__char2fs$0$0 ==. +; _char2fs.c 80 +; ----------------------------------------- +; function __char2fs +; ----------------------------------------- +___char2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _char2fs.c 109 + mov r2,dpl +; _char2fs.c 82 + clr a + mov (___char2fs_sign_1_1 + 3),a + mov (___char2fs_sign_1_1 + 2),a + mov (___char2fs_sign_1_1 + 1),a + mov ___char2fs_sign_1_1,a +; _char2fs.c 85 + mov ___char2fs_a1_1_1,r2 + mov a,r2 + rlc a + subb a,acc + mov (___char2fs_a1_1_1 + 1),a + mov (___char2fs_a1_1_1 + 2),a + mov (___char2fs_a1_1_1 + 3),a +; _char2fs.c 87 + mov a,___char2fs_a1_1_1 + orl a,(___char2fs_a1_1_1 + 1) + orl a,(___char2fs_a1_1_1 + 2) + orl a,(___char2fs_a1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _char2fs.c 89 + mov ___char2fs_fl_1_1,#0x00 + mov (___char2fs_fl_1_1 + 1),#0x00 + mov (___char2fs_fl_1_1 + 2),#0x00 + mov (___char2fs_fl_1_1 + 3),#0x00 +; _char2fs.c 90 + mov dpl,___char2fs_fl_1_1 + mov dph,(___char2fs_fl_1_1 + 1) + mov b,(___char2fs_fl_1_1 + 2) + mov a,(___char2fs_fl_1_1 + 3) + ljmp 00108$ +00102$: +; _char2fs.c 93 + mov a,(___char2fs_a1_1_1 + 3) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _char2fs.c 95 + mov ___char2fs_sign_1_1,#0x00 + mov (___char2fs_sign_1_1 + 1),#0x00 + mov (___char2fs_sign_1_1 + 2),#0x00 + mov (___char2fs_sign_1_1 + 3),#0x80 +; _char2fs.c 96 + clr c + clr a + subb a,___char2fs_a1_1_1 + mov ___char2fs_a1_1_1,a + clr a + subb a,(___char2fs_a1_1_1 + 1) + mov (___char2fs_a1_1_1 + 1),a + clr a + subb a,(___char2fs_a1_1_1 + 2) + mov (___char2fs_a1_1_1 + 2),a + clr a + subb a,(___char2fs_a1_1_1 + 3) + mov (___char2fs_a1_1_1 + 3),a +; _char2fs.c 99 +00113$: + mov r3,#0x96 + mov r4,#0x00 +00105$: + clr c + mov a,___char2fs_a1_1_1 + subb a,#0x00 + mov a,(___char2fs_a1_1_1 + 1) + subb a,#0x00 + mov a,(___char2fs_a1_1_1 + 2) + subb a,#0x80 + mov a,(___char2fs_a1_1_1 + 3) + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _char2fs.c 101 + mov a,___char2fs_a1_1_1 + add a,acc + mov ___char2fs_a1_1_1,a + mov a,(___char2fs_a1_1_1 + 1) + rlc a + mov (___char2fs_a1_1_1 + 1),a + mov a,(___char2fs_a1_1_1 + 2) + rlc a + mov (___char2fs_a1_1_1 + 2),a + mov a,(___char2fs_a1_1_1 + 3) + rlc a + mov (___char2fs_a1_1_1 + 3),a +; _char2fs.c 102 + dec r3 + cjne r3,#0xff,00117$ + dec r4 +00117$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _char2fs.c 105 + anl (___char2fs_a1_1_1 + 2),#0x7f +; _char2fs.c 107 + mov r5,#0x00 + mov r6,#0x00 + mov ar5,r3 + mov a,r4 + anl a,#0x01 + mov c,acc.0 + xch a,r5 + rrc a + xch a,r5 + rrc a + xch a,r5 + mov r6,a + mov r4,#0x00 + mov r3,#0x00 + mov r2,___char2fs_sign_1_1 + mov r7,(___char2fs_sign_1_1 + 1) + mov r0,(___char2fs_sign_1_1 + 2) + mov r1,(___char2fs_sign_1_1 + 3) + mov a,r2 + orl ar3,a + mov a,r7 + orl ar4,a + mov a,r0 + orl ar5,a + mov a,r1 + orl ar6,a + mov a,___char2fs_a1_1_1 + orl ar3,a + mov a,(___char2fs_a1_1_1 + 1) + orl ar4,a + mov a,(___char2fs_a1_1_1 + 2) + orl ar5,a + mov a,(___char2fs_a1_1_1 + 3) + orl ar6,a + mov ___char2fs_fl_1_1,r3 + mov (___char2fs_fl_1_1 + 1),r4 + mov (___char2fs_fl_1_1 + 2),r5 + mov (___char2fs_fl_1_1 + 3),r6 +; _char2fs.c 109 + mov dpl,___char2fs_fl_1_1 + mov dph,(___char2fs_fl_1_1 + 1) + mov b,(___char2fs_fl_1_1 + 2) + mov a,(___char2fs_fl_1_1 + 3) +00108$: + C$_char2fs.c$110$1$1 ==. + XG$__char2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_char2fs.cdb b/device/lib/small/_char2fs.cdb new file mode 100644 index 00000000..dd997178 --- /dev/null +++ b/device/lib/small/_char2fs.cdb @@ -0,0 +1,2 @@ +M:_char2fs +F:G$__char2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_char2fs.rel b/device/lib/small/_char2fs.rel new file mode 100644 index 00000000..0338f6c5 --- /dev/null +++ b/device/lib/small/_char2fs.rel @@ -0,0 +1,223 @@ +;!FILE _char2fs.asm +XH +H 9 areas 7A global symbols +M _char2fs +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size E4 flags 20 +S C$_char2fs.c$110$1$1 Def00E3 +S A$_char2fs$100 Def0038 +S A$_char2fs$200 Def00CE +S A$_char2fs$110 Def0046 +S A$_char2fs$201 Def00D0 +S A$_char2fs$120 Def0057 +S A$_char2fs$111 Def0049 +S A$_char2fs$202 Def00D2 +S A$_char2fs$121 Def0058 +S A$_char2fs$103 Def003B +S A$_char2fs$203 Def00D4 +S A$_char2fs$131 Def0065 +S A$_char2fs$122 Def005A +S A$_char2fs$113 Def004C +S ___char2fs Def0000 +S A$_char2fs$213 Def00E3 +S A$_char2fs$204 Def00D6 +S A$_char2fs$150 Def0083 +S A$_char2fs$141 Def0076 +S A$_char2fs$132 Def0066 +S A$_char2fs$123 Def005C +S A$_char2fs$114 Def004D +S A$_char2fs$105 Def003D +S A$_char2fs$151 Def0085 +S A$_char2fs$133 Def0068 +S A$_char2fs$124 Def005D +S A$_char2fs$115 Def004E +S A$_char2fs$206 Def00D8 +S A$_char2fs$170 Def009D +S A$_char2fs$152 Def0086 +S A$_char2fs$134 Def006A +S A$_char2fs$125 Def005F +S A$_char2fs$116 Def0050 +S A$_char2fs$207 Def00DB +S A$_char2fs$180 Def00AA +S A$_char2fs$171 Def009E +S A$_char2fs$162 Def0092 +S A$_char2fs$153 Def0088 +S A$_char2fs$144 Def0078 +S A$_char2fs$135 Def006C +S A$_char2fs$117 Def0052 +S A$_char2fs$108 Def0040 +S A$_char2fs$208 Def00DE +S A$_char2fs$190 Def00BB +S A$_char2fs$181 Def00AC +S A$_char2fs$172 Def00A0 +S A$_char2fs$154 Def008A +S A$_char2fs$145 Def007A +S A$_char2fs$136 Def006E +S A$_char2fs$118 Def0053 +S A$_char2fs$109 Def0043 +S A$_char2fs$209 Def00E1 +S A$_char2fs$191 Def00BD +S A$_char2fs$182 Def00AE +S A$_char2fs$173 Def00A2 +S A$_char2fs$155 Def008B +S A$_char2fs$146 Def007C +S A$_char2fs$137 Def0070 +S A$_char2fs$128 Def0061 +S A$_char2fs$119 Def0055 +S A$_char2fs$192 Def00BE +S A$_char2fs$183 Def00B0 +S A$_char2fs$174 Def00A3 +S A$_char2fs$165 Def0094 +S A$_char2fs$147 Def007E +S A$_char2fs$138 Def0072 +S A$_char2fs$129 Def0063 +S A$_char2fs$193 Def00C0 +S A$_char2fs$184 Def00B2 +S A$_char2fs$175 Def00A4 +S A$_char2fs$157 Def008D +S A$_char2fs$148 Def0080 +S A$_char2fs$139 Def0074 +S A$_char2fs$194 Def00C2 +S A$_char2fs$185 Def00B4 +S A$_char2fs$176 Def00A5 +S A$_char2fs$167 Def0097 +S A$_char2fs$158 Def008E +S A$_char2fs$149 Def0081 +S A$_char2fs$195 Def00C4 +S A$_char2fs$186 Def00B5 +S A$_char2fs$177 Def00A6 +S A$_char2fs$168 Def0099 +S A$_char2fs$159 Def0091 +S A$_char2fs$196 Def00C6 +S A$_char2fs$187 Def00B7 +S A$_char2fs$178 Def00A7 +S A$_char2fs$169 Def009B +S A$_char2fs$197 Def00C8 +S A$_char2fs$188 Def00B8 +S A$_char2fs$179 Def00A8 +S XG$__char2fs$0$0 Def00E3 +S A$_char2fs$198 Def00CA +S A$_char2fs$189 Def00BA +S A$_char2fs$199 Def00CC +S A$_char2fs$70 Def0003 +S A$_char2fs$80 Def0013 +S A$_char2fs$71 Def0005 +S A$_char2fs$81 Def0015 +S A$_char2fs$72 Def0007 +S G$__char2fs$0$0 Def0000 +S A$_char2fs$91 Def0021 +S A$_char2fs$73 Def0009 +S A$_char2fs$92 Def0024 +S A$_char2fs$83 Def0017 +S A$_char2fs$93 Def0027 +S A$_char2fs$84 Def0019 +S A$_char2fs$75 Def000B +S A$_char2fs$94 Def002A +S A$_char2fs$85 Def001B +S A$_char2fs$76 Def000D +S A$_char2fs$67 Def0000 +S A$_char2fs$86 Def001D +S A$_char2fs$77 Def000E +S A$_char2fs$96 Def002D +S A$_char2fs$78 Def000F +S A$_char2fs$69 Def0002 +S A$_char2fs$97 Def0030 +S A$_char2fs$88 Def001F +S A$_char2fs$79 Def0011 +S A$_char2fs$98 Def0033 +S A$_char2fs$99 Def0036 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 E4 F5 00 03 F5 00 02 F5 00 01 F5 +R 00 00 00 08 29 06 00 03 29 09 00 03 29 0C 00 03 +T 00 0A 00 00 8A 00 08 EA 33 95 E0 F5 00 09 F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0C 00 03 +T 00 14 00 0A F5 00 0B E5 00 08 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 1A 00 09 45 00 0A 45 00 0B 70 1A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 21 +R 00 00 00 08 +T 00 21 75 00 04 00 75 00 05 00 75 00 06 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 2B 00 07 00 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 34 00 06 F0 E5 00 07 02 00 E3 +R 00 00 00 08 29 02 00 03 29 06 00 03 00 09 00 08 +T 00 3B +R 00 00 00 08 +T 00 3B E5 00 0B 30 E7 21 +R 00 00 00 08 29 03 00 03 +T 00 40 +R 00 00 00 08 +T 00 40 75 00 00 00 75 00 01 00 75 00 02 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 4A 00 03 80 C3 E4 95 00 08 F5 00 08 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 54 00 09 F5 00 09 E4 95 00 0A F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 5B 00 0A E4 95 00 0B F5 00 0B +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 61 +R 00 00 00 08 +T 00 61 7B 96 7C 00 +R 00 00 00 08 +T 00 65 +R 00 00 00 08 +T 00 65 C3 E5 00 08 94 00 E5 00 09 94 00 E5 00 0A +R 00 00 00 08 29 04 00 03 29 09 00 03 29 0E 00 03 +T 00 70 94 80 E5 00 0B 94 00 50 1C +R 00 00 00 08 29 05 00 03 +T 00 78 +R 00 00 00 08 +T 00 78 E5 00 08 25 E0 F5 00 08 E5 00 09 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 00 82 00 09 E5 00 0A 33 F5 00 0A E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 89 00 0B 33 F5 00 0B 1B BB FF 01 1C +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 92 +R 00 00 00 08 +T 00 92 80 D1 +R 00 00 00 08 +T 00 94 +R 00 00 00 08 +T 00 94 53 00 0A 7F 7D 00 7E 00 8B 05 EC 54 01 A2 +R 00 00 00 08 09 03 00 03 +T 00 A1 E0 CD 13 CD 13 CD FE 7C 00 7B 00 AA 00 00 +R 00 00 00 08 29 0E 00 03 +T 00 AE AF 00 01 A8 00 02 A9 00 03 EA 42 03 EF 42 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 B9 04 E8 42 05 E9 42 06 E5 00 08 42 03 E5 +R 00 00 00 08 29 0A 00 03 +T 00 C5 00 09 42 04 E5 00 0A 42 05 E5 00 0B 42 06 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0C 00 03 +T 00 D0 8B 00 04 8C 00 05 8D 00 06 8E +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 D7 00 07 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 DF 00 06 F0 E5 00 07 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 E3 +R 00 00 00 08 +T 00 E3 22 +R 00 00 00 08 diff --git a/device/lib/small/_decdptr.asm b/device/lib/small/_decdptr.asm new file mode 100644 index 00000000..add355ae --- /dev/null +++ b/device/lib/small/_decdptr.asm @@ -0,0 +1,70 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:09 2000 + +;-------------------------------------------------------- + .module _decdptr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __decdptr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_decdptr$0$0 ==. +; _decdptr.c 26 +; ----------------------------------------- +; function _decdptr +; ----------------------------------------- +__decdptr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _decdptr.c 35 + xch a,dpl + jnz 00001$ + dec dph +00001$: + dec a + xch a,dpl +00101$: + C$_decdptr.c$36$1$1 ==. + XG$_decdptr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_decdptr.cdb b/device/lib/small/_decdptr.cdb new file mode 100644 index 00000000..da3898b4 --- /dev/null +++ b/device/lib/small/_decdptr.cdb @@ -0,0 +1,2 @@ +M:_decdptr +F:G$_decdptr$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/small/_decdptr.rel b/device/lib/small/_decdptr.rel new file mode 100644 index 00000000..81a3dfb2 --- /dev/null +++ b/device/lib/small/_decdptr.rel @@ -0,0 +1,34 @@ +;!FILE _decdptr.asm +XH +H 8 areas A global symbols +M _decdptr +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size A flags 20 +S A$_decdptr$60 Def0000 +S C$_decdptr.c$36$1$1 Def0009 +S A$_decdptr$61 Def0002 +S A$_decdptr$62 Def0004 +S A$_decdptr$64 Def0006 +S A$_decdptr$65 Def0007 +S A$_decdptr$69 Def0009 +S __decdptr Def0000 +S XG$_decdptr$0$0 Def0009 +S G$_decdptr$0$0 Def0000 +T 00 00 +R 00 00 00 07 +T 00 00 C5 82 70 02 15 83 +R 00 00 00 07 +T 00 06 +R 00 00 00 07 +T 00 06 14 C5 82 +R 00 00 00 07 +T 00 09 +R 00 00 00 07 +T 00 09 22 +R 00 00 00 07 diff --git a/device/lib/small/_divsint.asm b/device/lib/small/_divsint.asm new file mode 100644 index 00000000..f2c6a3da --- /dev/null +++ b/device/lib/small/_divsint.asm @@ -0,0 +1,150 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:09 2000 + +;-------------------------------------------------------- + .module _divsint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divsint_PARM_2 + .globl __divsint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__divsint_PARM_2: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divsint$0$0 ==. +; _divsint.c 26 +; ----------------------------------------- +; function _divsint +; ----------------------------------------- +__divsint: + clr ea + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divsint.c 0 + mov r2,dpl + mov r3,dph +; _divsint.c 33 + mov a,r3 + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r4,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: + clr c + clr a + subb a,r2 + mov r5,a + clr a + subb a,r3 + mov r6,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar5,r2 + mov ar6,r3 +00107$: + mov ar2,r5 + mov ar3,r6 +; _divsint.c 34 + mov a,(__divsint_PARM_2 + 1) + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,__divsint_PARM_2 + mov r6,a + clr a + subb a,(__divsint_PARM_2 + 1) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov r6,__divsint_PARM_2 + mov r7,(__divsint_PARM_2 + 1) +00109$: + mov __divuint_PARM_2,r6 + mov (__divuint_PARM_2 + 1),r7 + push ar4 + push ar5 + mov dpl,r2 + mov dph,r3 + lcall __divuint + mov r2,dpl + mov r3,dph + pop ar5 + pop ar4 +; _divsint.c 35 + mov a,r5 + xrl a,ar4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _divsint.c 37 + clr c + clr a + subb a,r2 + mov dpl,a + clr a + subb a,r3 + mov dph,a +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _divsint.c 41 + mov dpl,r2 + mov dph,r3 +00104$: + setb ea + C$_divsint.c$43$1$1 ==. + XG$_divsint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_divsint.cdb b/device/lib/small/_divsint.cdb new file mode 100644 index 00000000..24d9d316 --- /dev/null +++ b/device/lib/small/_divsint.cdb @@ -0,0 +1,2 @@ +M:_divsint +F:G$_divsint$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_divsint.rel b/device/lib/small/_divsint.rel new file mode 100644 index 00000000..466af42d --- /dev/null +++ b/device/lib/small/_divsint.rel @@ -0,0 +1,130 @@ +;!FILE _divsint.asm +XH +H 8 areas 46 global symbols +M _divsint +S __divuint Ref0000 +S __divuint_PARM_2 Ref0000 +A _CODE size 0 flags 0 +A DSEG size 2 flags 0 +S __divsint_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 63 flags 20 +S XG$_divsint$0$0 Def0062 +S G$_divsint$0$0 Def0000 +S A$_divsint$101 Def0026 +S A$_divsint$120 Def0041 +S A$_divsint$111 Def0031 +S A$_divsint$102 Def0027 +S A$_divsint$121 Def0044 +S A$_divsint$112 Def0033 +S A$_divsint$103 Def0028 +S A$_divsint$140 Def005A +S A$_divsint$122 Def0046 +S A$_divsint$104 Def002A +S A$_divsint$132 Def0051 +S A$_divsint$123 Def0048 +S A$_divsint$114 Def0035 +S A$_divsint$105 Def002B +S A$_divsint$133 Def0052 +S A$_divsint$124 Def004A +S A$_divsint$115 Def0037 +S A$_divsint$106 Def002C +S A$_divsint$143 Def005C +S A$_divsint$134 Def0053 +S A$_divsint$116 Def0039 +S A$_divsint$107 Def002E +S A$_divsint$144 Def005E +S A$_divsint$135 Def0054 +S A$_divsint$126 Def004C +S A$_divsint$117 Def003B +S A$_divsint$136 Def0056 +S A$_divsint$127 Def004D +S A$_divsint$118 Def003D +S A$_divsint$109 Def002F +S A$_divsint$146 Def0060 +S A$_divsint$137 Def0057 +S A$_divsint$119 Def003F +S A$_divsint$138 Def0058 +S A$_divsint$129 Def004F +S A$_divsint$149 Def0062 +S C$_divsint.c$43$1$1 Def0062 +S A$_divsint$70 Def0009 +S A$_divsint$80 Def0011 +S A$_divsint$90 Def001C +S A$_divsint$81 Def0012 +S A$_divsint$72 Def000A +S A$_divsint$54 Def0000 +S A$_divsint$82 Def0013 +S A$_divsint$64 Def0002 +S A$_divsint$92 Def001E +S A$_divsint$74 Def000B +S A$_divsint$65 Def0004 +S A$_divsint$93 Def0020 +S A$_divsint$84 Def0014 +S A$_divsint$94 Def0021 +S A$_divsint$76 Def000D +S A$_divsint$67 Def0006 +S A$_divsint$95 Def0022 +S A$_divsint$86 Def0016 +S A$_divsint$77 Def000E +S A$_divsint$68 Def0007 +S A$_divsint$87 Def0018 +S A$_divsint$78 Def000F +S A$_divsint$69 Def0008 +S A$_divsint$97 Def0023 +S A$_divsint$79 Def0010 +S A$_divsint$89 Def001A +S A$_divsint$99 Def0024 +S __divsint Def0000 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 C2 AF AA 82 AB 83 EB 33 E4 33 FC 60 09 +R 00 00 00 07 +T 00 0D +R 00 00 00 07 +T 00 0D C3 E4 9A FD E4 9B FE 80 04 +R 00 00 00 07 +T 00 16 +R 00 00 00 07 +T 00 16 8A 05 8B 06 +R 00 00 00 07 +T 00 1A +R 00 00 00 07 +T 00 1A 8D 02 8E 03 E5 00 01 33 E4 33 FD 60 0B +R 00 00 00 07 29 07 00 01 +T 00 26 +R 00 00 00 07 +T 00 26 C3 E4 95 00 00 FE E4 95 00 01 FF 80 04 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 00 31 +R 00 00 00 07 +T 00 31 AE 00 00 AF 00 01 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 00 35 +R 00 00 00 07 +T 00 35 8E 00 00 8F 00 01 C0 04 C0 05 8A 82 8B 83 +R 00 00 00 07 2B 03 00 01 2B 06 00 01 +T 00 41 12 00 00 AA 82 AB 83 D0 05 D0 04 ED 65 04 +R 00 00 00 07 02 03 00 00 +T 00 4F 60 0B +R 00 00 00 07 +T 00 51 +R 00 00 00 07 +T 00 51 C3 E4 9A F5 82 E4 9B F5 83 80 04 +R 00 00 00 07 +T 00 5C +R 00 00 00 07 +T 00 5C 8A 82 8B 83 +R 00 00 00 07 +T 00 60 +R 00 00 00 07 +T 00 60 D2 AF 22 +R 00 00 00 07 diff --git a/device/lib/small/_divslong.asm b/device/lib/small/_divslong.asm new file mode 100644 index 00000000..e74ff161 --- /dev/null +++ b/device/lib/small/_divslong.asm @@ -0,0 +1,183 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:09 2000 + +;-------------------------------------------------------- + .module _divslong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divslong_PARM_2 + .globl __divslong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__divslong_PARM_2: + .ds 0x0004 +__divslong_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divslong$0$0 ==. +; _divslong.c 25 +; ----------------------------------------- +; function _divslong +; ----------------------------------------- +__divslong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divslong.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _divslong.c 29 +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: + clr c + clr a + subb a,r2 + mov __divslong_sloc0_1_0,a + clr a + subb a,r3 + mov (__divslong_sloc0_1_0 + 1),a + clr a + subb a,r4 + mov (__divslong_sloc0_1_0 + 2),a + clr a + subb a,r5 + mov (__divslong_sloc0_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov __divslong_sloc0_1_0,r2 + mov (__divslong_sloc0_1_0 + 1),r3 + mov (__divslong_sloc0_1_0 + 2),r4 + mov (__divslong_sloc0_1_0 + 3),r5 +00107$: + mov r2,__divslong_sloc0_1_0 + mov r3,(__divslong_sloc0_1_0 + 1) + mov r4,(__divslong_sloc0_1_0 + 2) + mov r5,(__divslong_sloc0_1_0 + 3) +; _divslong.c 30 + mov a,(__divslong_PARM_2 + 3) + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,__divslong_PARM_2 + mov __divslong_sloc0_1_0,a + clr a + subb a,(__divslong_PARM_2 + 1) + mov (__divslong_sloc0_1_0 + 1),a + clr a + subb a,(__divslong_PARM_2 + 2) + mov (__divslong_sloc0_1_0 + 2),a + clr a + subb a,(__divslong_PARM_2 + 3) + mov (__divslong_sloc0_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov __divslong_sloc0_1_0,__divslong_PARM_2 + mov (__divslong_sloc0_1_0 + 1),(__divslong_PARM_2 + 1) + mov (__divslong_sloc0_1_0 + 2),(__divslong_PARM_2 + 2) + mov (__divslong_sloc0_1_0 + 3),(__divslong_PARM_2 + 3) +00109$: + mov __divulong_PARM_2,__divslong_sloc0_1_0 + mov (__divulong_PARM_2 + 1),(__divslong_sloc0_1_0 + 1) + mov (__divulong_PARM_2 + 2),(__divslong_sloc0_1_0 + 2) + mov (__divulong_PARM_2 + 3),(__divslong_sloc0_1_0 + 3) + push ar6 + push ar7 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 + lcall __divulong + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a + pop ar7 + pop ar6 +; _divslong.c 31 + mov a,r7 + xrl a,ar6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _divslong.c 32 + clr c + clr a + subb a,r2 + mov dpl,a + clr a + subb a,r3 + mov dph,a + clr a + subb a,r4 + mov b,a + clr a + subb a,r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _divslong.c 34 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 +00104$: + C$_divslong.c$35$1$1 ==. + XG$_divslong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_divslong.cdb b/device/lib/small/_divslong.cdb new file mode 100644 index 00000000..56ce27ec --- /dev/null +++ b/device/lib/small/_divslong.cdb @@ -0,0 +1,2 @@ +M:_divslong +F:G$_divslong$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_divslong.rel b/device/lib/small/_divslong.rel new file mode 100644 index 00000000..f15d393e --- /dev/null +++ b/device/lib/small/_divslong.rel @@ -0,0 +1,184 @@ +;!FILE _divslong.asm +XH +H 8 areas 64 global symbols +M _divslong +S __divulong_PARM_2 Ref0000 +S __divulong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +S __divslong_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 9E flags 20 +S A$_divslong$110 Def0035 +S A$_divslong$101 Def002A +S A$_divslong$120 Def0041 +S A$_divslong$102 Def002C +S A$_divslong$130 Def004F +S A$_divslong$121 Def0043 +S A$_divslong$112 Def0036 +S A$_divslong$103 Def002E +S A$_divslong$140 Def0069 +S A$_divslong$131 Def0052 +S A$_divslong$122 Def0044 +S A$_divslong$150 Def007C +S A$_divslong$141 Def006B +S A$_divslong$132 Def0055 +S A$_divslong$123 Def0046 +S A$_divslong$114 Def0038 +S A$_divslong$105 Def0030 +S A$_divslong$160 Def0086 +S A$_divslong$151 Def007E +S A$_divslong$142 Def006D +S A$_divslong$133 Def0058 +S A$_divslong$124 Def0048 +S A$_divslong$115 Def0039 +S A$_divslong$106 Def0032 +S A$_divslong$170 Def0093 +S A$_divslong$161 Def0087 +S A$_divslong$143 Def006F +S A$_divslong$125 Def0049 +S A$_divslong$116 Def003A +S A$_divslong$107 Def0033 +S A$_divslong$162 Def0088 +S A$_divslong$153 Def0080 +S A$_divslong$144 Def0071 +S A$_divslong$135 Def005B +S A$_divslong$126 Def004B +S A$_divslong$117 Def003C +S A$_divslong$108 Def0034 +S A$_divslong$172 Def0094 +S A$_divslong$163 Def008A +S A$_divslong$154 Def0081 +S A$_divslong$145 Def0072 +S A$_divslong$136 Def005E +S A$_divslong$118 Def003E +S A$_divslong$182 Def009D +S A$_divslong$164 Def008B +S A$_divslong$146 Def0075 +S A$_divslong$137 Def0061 +S A$_divslong$128 Def004D +S A$_divslong$119 Def003F +S A$_divslong$165 Def008C +S A$_divslong$156 Def0083 +S A$_divslong$147 Def0077 +S A$_divslong$138 Def0064 +S A$_divslong$175 Def0096 +S A$_divslong$166 Def008E +S A$_divslong$148 Def0079 +S A$_divslong$139 Def0067 +S A$_divslong$176 Def0098 +S A$_divslong$167 Def008F +S A$_divslong$149 Def007B +S A$_divslong$177 Def009A +S A$_divslong$168 Def0090 +S A$_divslong$159 Def0085 +S A$_divslong$178 Def009C +S A$_divslong$169 Def0092 +S C$_divslong.c$35$1$1 Def009D +S A$_divslong$70 Def0006 +S A$_divslong$80 Def000E +S A$_divslong$71 Def0007 +S A$_divslong$90 Def001B +S A$_divslong$81 Def000F +S A$_divslong$72 Def0008 +S A$_divslong$91 Def001C +S A$_divslong$82 Def0010 +S A$_divslong$73 Def0009 +S A$_divslong$83 Def0012 +S A$_divslong$65 Def0000 +S A$_divslong$93 Def001E +S A$_divslong$84 Def0013 +S A$_divslong$75 Def000A +S A$_divslong$66 Def0002 +S A$_divslong$85 Def0014 +S A$_divslong$67 Def0004 +S A$_divslong$95 Def0020 +S A$_divslong$86 Def0016 +S A$_divslong$77 Def000B +S A$_divslong$96 Def0022 +S A$_divslong$87 Def0017 +S A$_divslong$97 Def0024 +S A$_divslong$88 Def0018 +S A$_divslong$79 Def000D +S A$_divslong$98 Def0026 +S A$_divslong$89 Def001A +S __divslong Def0000 +S XG$_divslong$0$0 Def009D +S G$_divslong$0$0 Def0000 +S A$_divslong$100 Def0028 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 FD 33 E4 33 FE 60 13 +R 00 00 00 07 +T 00 0D +R 00 00 00 07 +T 00 0D C3 E4 9A F5 00 04 E4 9B F5 00 05 E4 9C F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 19 00 06 E4 9D F5 00 07 80 08 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 20 +R 00 00 00 07 +T 00 20 8A 00 04 8B 00 05 8C 00 06 8D +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 27 00 07 +R 00 00 00 07 29 02 00 01 +T 00 28 +R 00 00 00 07 +T 00 28 AA 00 04 AB 00 05 AC 00 06 AD +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 2F 00 07 E5 00 03 33 E4 33 FF 60 17 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 38 +R 00 00 00 07 +T 00 38 C3 E4 95 00 00 F5 00 04 E4 95 00 01 F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 00 42 00 05 E4 95 00 02 F5 00 06 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 4A 00 03 F5 00 07 80 0C +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 4F +R 00 00 00 07 +T 00 4F 85 00 00 00 04 85 00 01 +R 00 00 00 07 29 03 00 01 29 05 00 01 29 08 00 01 +T 00 54 00 05 85 00 02 00 06 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 00 59 00 03 00 07 +R 00 00 00 07 29 02 00 01 29 04 00 01 +T 00 5B +R 00 00 00 07 +T 00 5B 85 00 04 00 00 85 00 05 +R 00 00 00 07 29 03 00 01 2B 05 00 00 29 08 00 01 +T 00 60 00 01 85 00 06 00 02 85 +R 00 00 00 07 2B 02 00 00 29 05 00 01 2B 07 00 00 +T 00 65 00 07 00 03 C0 06 C0 07 8A 82 8B 83 8C F0 +R 00 00 00 07 29 02 00 01 2B 04 00 00 +T 00 71 ED 12 00 00 AA 82 AB 83 AC F0 FD D0 07 D0 +R 00 00 00 07 02 04 00 01 +T 00 7F 06 EF 65 06 60 11 +R 00 00 00 07 +T 00 85 +R 00 00 00 07 +T 00 85 C3 E4 9A F5 82 E4 9B F5 83 E4 9C F5 F0 E4 +R 00 00 00 07 +T 00 93 9D 80 07 +R 00 00 00 07 +T 00 96 +R 00 00 00 07 +T 00 96 8A 82 8B 83 8C F0 ED +R 00 00 00 07 +T 00 9D +R 00 00 00 07 +T 00 9D 22 +R 00 00 00 07 diff --git a/device/lib/small/_divuint.asm b/device/lib/small/_divuint.asm new file mode 100644 index 00000000..c71b2b72 --- /dev/null +++ b/device/lib/small/_divuint.asm @@ -0,0 +1,135 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:09 2000 + +;-------------------------------------------------------- + .module _divuint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divuint_PARM_2 + .globl __divuint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +__divuint_PARM_2: + .ds 0x0002 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +__divuint_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divuint$0$0 ==. +; _divuint.c 28 +; ----------------------------------------- +; function _divuint +; ----------------------------------------- +__divuint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divuint.c 49 + mov r2,dpl + mov r3,dph +; _divuint.c 30 + mov r4,#0x00 + mov r5,#0x00 +; _divuint.c 34 + mov r6,#0x10 +00105$: +; _divuint.c 36 + mov a,r3 + rl a + anl a,#0x01 + mov r7,a +; _divuint.c 37 + mov a,r3 + xch a,r2 + add a,acc + xch a,r2 + rlc a + mov r3,a +; _divuint.c 38 + mov a,r5 + xch a,r4 + add a,acc + xch a,r4 + rlc a + mov r5,a +; _divuint.c 39 + mov a,r7 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _divuint.c 40 + orl ar4,#0x01 +00102$: +; _divuint.c 42 + clr c + mov a,r4 + subb a,__divuint_PARM_2 + mov a,r5 + subb a,(__divuint_PARM_2 + 1) +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00106$ +00115$: +; _divuint.c 43 + clr c + mov a,r4 + subb a,__divuint_PARM_2 + mov r4,a + mov a,r5 + subb a,(__divuint_PARM_2 + 1) + mov r5,a +; _divuint.c 45 + orl ar2,#0x01 +00106$: +; _divuint.c 47 +; Peephole 132 changed ljmp to sjmp +; Peephole 205 optimized misc jump sequence + djnz r6,00105$ +00116$: +00117$: +; _divuint.c 49 + mov dpl,r2 + mov dph,r3 +00108$: + C$_divuint.c$50$1$1 ==. + XG$_divuint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_divuint.cdb b/device/lib/small/_divuint.cdb new file mode 100644 index 00000000..8386455f --- /dev/null +++ b/device/lib/small/_divuint.cdb @@ -0,0 +1,2 @@ +M:_divuint +F:G$_divuint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_divuint.rel b/device/lib/small/_divuint.rel new file mode 100644 index 00000000..763afb63 --- /dev/null +++ b/device/lib/small/_divuint.rel @@ -0,0 +1,104 @@ +;!FILE _divuint.asm +XH +H 9 areas 2F global symbols +M _divuint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 2 flags 4 +S __divuint_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 1 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 3F flags 20 +S __divuint Def0000 +S XG$_divuint$0$0 Def003E +S G$_divuint$0$0 Def0000 +S A$_divuint$120 Def0035 +S A$_divuint$102 Def0023 +S A$_divuint$130 Def003C +S A$_divuint$112 Def002C +S A$_divuint$103 Def0024 +S A$_divuint$113 Def002D +S A$_divuint$104 Def0025 +S A$_divuint$114 Def002E +S A$_divuint$105 Def0027 +S A$_divuint$115 Def0030 +S A$_divuint$106 Def0028 +S A$_divuint$134 Def003E +S A$_divuint$125 Def0038 +S A$_divuint$116 Def0031 +S A$_divuint$117 Def0032 +S A$_divuint$118 Def0034 +S A$_divuint$109 Def002A +S A$_divuint$129 Def003A +S C$_divuint.c$50$1$1 Def003E +S A$_divuint$70 Def0006 +S A$_divuint$80 Def000F +S A$_divuint$90 Def001A +S A$_divuint$81 Def0010 +S A$_divuint$72 Def0008 +S A$_divuint$91 Def001B +S A$_divuint$82 Def0011 +S A$_divuint$92 Def001C +S A$_divuint$83 Def0013 +S A$_divuint$84 Def0014 +S A$_divuint$75 Def000A +S A$_divuint$66 Def0000 +S A$_divuint$94 Def001D +S A$_divuint$85 Def0015 +S A$_divuint$76 Def000B +S A$_divuint$67 Def0002 +S A$_divuint$77 Def000C +S A$_divuint$96 Def001E +S A$_divuint$87 Def0016 +S A$_divuint$78 Def000E +S A$_divuint$69 Def0004 +S A$_divuint$88 Def0017 +S A$_divuint$89 Def0018 +S A$_divuint$99 Def0020 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 7C 00 7D 00 7E 10 +R 00 00 00 08 +T 00 0A +R 00 00 00 08 +T 00 0A EB 23 54 01 FF EB CA 25 E0 CA 33 FB ED CC +R 00 00 00 08 +T 00 18 25 E0 CC 33 FD EF 60 03 +R 00 00 00 08 +T 00 20 +R 00 00 00 08 +T 00 20 43 04 01 +R 00 00 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 C3 EC 95 00 00 ED 95 00 01 40 0C +R 00 00 00 08 29 05 00 03 29 09 00 03 +T 00 2C +R 00 00 00 08 +T 00 2C C3 EC 95 00 00 FC ED 95 00 01 FD 43 02 01 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 38 +R 00 00 00 08 +T 00 38 DE D0 +R 00 00 00 08 +T 00 3A +R 00 00 00 08 +T 00 3A +R 00 00 00 08 +T 00 3A 8A 82 8B 83 +R 00 00 00 08 +T 00 3E +R 00 00 00 08 +T 00 3E 22 +R 00 00 00 08 diff --git a/device/lib/small/_divulong.asm b/device/lib/small/_divulong.asm new file mode 100644 index 00000000..ab2da8b8 --- /dev/null +++ b/device/lib/small/_divulong.asm @@ -0,0 +1,187 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:09 2000 + +;-------------------------------------------------------- + .module _divulong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __divulong_PARM_2 + .globl __divulong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +__divulong_PARM_2: + .ds 0x0004 +__divulong_a_1_1: + .ds 0x0004 +__divulong_reste_1_1: + .ds 0x0004 +__divulong_count_1_1: + .ds 0x0001 +__divulong_c_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_divulong$0$0 ==. +; _divulong.c 27 +; ----------------------------------------- +; function _divulong +; ----------------------------------------- +__divulong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _divulong.c 48 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _divulong.c 29 + mov r6,#0x00 + mov r7,#0x00 + mov r0,#0x00 + mov r1,#0x00 +; _divulong.c 33 + mov __divulong_count_1_1,#0x20 +00105$: +; _divulong.c 35 + mov a,r5 + rl a + anl a,#0x01 + mov __divulong_c_1_1,a +; _divulong.c 36 + mov a,r2 + add a,acc + mov r2,a + mov a,r3 + rlc a + mov r3,a + mov a,r4 + rlc a + mov r4,a + mov a,r5 + rlc a + mov r5,a +; _divulong.c 37 + mov a,r6 + add a,acc + mov r6,a + mov a,r7 + rlc a + mov r7,a + mov a,r0 + rlc a + mov r0,a + mov a,r1 + rlc a + mov r1,a +; _divulong.c 38 + mov a,__divulong_c_1_1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _divulong.c 39 + mov __divulong_reste_1_1,r6 + mov (__divulong_reste_1_1 + 1),r7 + mov (__divulong_reste_1_1 + 2),r0 + mov (__divulong_reste_1_1 + 3),r1 + mov a,#0x01 + orl a,__divulong_reste_1_1 + mov r6,a + mov r7,(__divulong_reste_1_1 + 1) + mov r0,(__divulong_reste_1_1 + 2) + mov r1,(__divulong_reste_1_1 + 3) +00102$: +; _divulong.c 41 + clr c + mov a,r6 + subb a,__divulong_PARM_2 + mov a,r7 + subb a,(__divulong_PARM_2 + 1) + mov a,r0 + subb a,(__divulong_PARM_2 + 2) + mov a,r1 + subb a,(__divulong_PARM_2 + 3) +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00106$ +00115$: +; _divulong.c 42 + clr c + mov a,r6 + subb a,__divulong_PARM_2 + mov r6,a + mov a,r7 + subb a,(__divulong_PARM_2 + 1) + mov r7,a + mov a,r0 + subb a,(__divulong_PARM_2 + 2) + mov r0,a + mov a,r1 + subb a,(__divulong_PARM_2 + 3) + mov r1,a +; _divulong.c 44 + mov __divulong_a_1_1,r2 + mov (__divulong_a_1_1 + 1),r3 + mov (__divulong_a_1_1 + 2),r4 + mov (__divulong_a_1_1 + 3),r5 + mov a,#0x01 + orl a,__divulong_a_1_1 + mov r2,a + mov r3,(__divulong_a_1_1 + 1) + mov r4,(__divulong_a_1_1 + 2) + mov r5,(__divulong_a_1_1 + 3) +00106$: +; _divulong.c 46 + djnz __divulong_count_1_1,00116$ + sjmp 00117$ +00116$: + ljmp 00105$ +00117$: +; _divulong.c 48 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 +00108$: + C$_divulong.c$49$1$1 ==. + XG$_divulong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_divulong.cdb b/device/lib/small/_divulong.cdb new file mode 100644 index 00000000..1ec9def8 --- /dev/null +++ b/device/lib/small/_divulong.cdb @@ -0,0 +1,2 @@ +M:_divulong +F:G$_divulong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_divulong.rel b/device/lib/small/_divulong.rel new file mode 100644 index 00000000..6acfe509 --- /dev/null +++ b/device/lib/small/_divulong.rel @@ -0,0 +1,184 @@ +;!FILE _divulong.asm +XH +H 9 areas 5F global symbols +M _divulong +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size E flags 4 +S __divulong_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 8C flags 20 +S A$_divulong$100 Def0023 +S A$_divulong$110 Def002D +S A$_divulong$101 Def0024 +S A$_divulong$111 Def002E +S A$_divulong$130 Def0047 +S A$_divulong$121 Def0036 +S A$_divulong$112 Def002F +S A$_divulong$103 Def0025 +S A$_divulong$140 Def0053 +S A$_divulong$122 Def0038 +S A$_divulong$113 Def0030 +S A$_divulong$104 Def0026 +S A$_divulong$150 Def005C +S A$_divulong$141 Def0054 +S A$_divulong$123 Def003A +S A$_divulong$114 Def0031 +S A$_divulong$105 Def0028 +S A$_divulong$151 Def005D +S A$_divulong$133 Def0049 +S A$_divulong$124 Def003C +S A$_divulong$106 Def0029 +S A$_divulong$170 Def007A +S A$_divulong$161 Def0069 +S A$_divulong$152 Def005E +S A$_divulong$134 Def004A +S A$_divulong$125 Def003E +S A$_divulong$116 Def0032 +S A$_divulong$107 Def002A +S A$_divulong$180 Def0086 +S A$_divulong$162 Def006B +S A$_divulong$153 Def0060 +S A$_divulong$144 Def0056 +S A$_divulong$135 Def004B +S A$_divulong$126 Def0040 +S A$_divulong$108 Def002B +S A$_divulong$181 Def0088 +S A$_divulong$163 Def006D +S A$_divulong$154 Def0061 +S A$_divulong$136 Def004D +S A$_divulong$127 Def0042 +S A$_divulong$118 Def0034 +S A$_divulong$109 Def002C +S A$_divulong$182 Def008A +S A$_divulong$173 Def007C +S A$_divulong$164 Def006F +S A$_divulong$155 Def0062 +S A$_divulong$137 Def004E +S A$_divulong$128 Def0043 +S A$_divulong$174 Def007F +S A$_divulong$165 Def0071 +S A$_divulong$156 Def0064 +S A$_divulong$147 Def0058 +S A$_divulong$138 Def0050 +S A$_divulong$129 Def0045 +S A$_divulong$166 Def0073 +S A$_divulong$157 Def0065 +S A$_divulong$148 Def0059 +S A$_divulong$139 Def0051 +S A$_divulong$176 Def0081 +S A$_divulong$167 Def0075 +S A$_divulong$158 Def0066 +S A$_divulong$149 Def005A +S A$_divulong$186 Def008B +S A$_divulong$168 Def0076 +S A$_divulong$159 Def0068 +S A$_divulong$169 Def0078 +S A$_divulong$179 Def0084 +S A$_divulong$80 Def000D +S A$_divulong$90 Def0018 +S A$_divulong$72 Def0000 +S A$_divulong$91 Def0019 +S A$_divulong$82 Def000F +S A$_divulong$73 Def0002 +S C$_divulong.c$49$1$1 Def008B +S A$_divulong$92 Def001B +S A$_divulong$74 Def0004 +S A$_divulong$93 Def001C +S A$_divulong$75 Def0006 +S A$_divulong$94 Def001D +S A$_divulong$85 Def0012 +S A$_divulong$95 Def001E +S A$_divulong$86 Def0013 +S A$_divulong$77 Def0007 +S A$_divulong$96 Def001F +S A$_divulong$87 Def0014 +S A$_divulong$78 Def0009 +S A$_divulong$97 Def0020 +S A$_divulong$88 Def0016 +S A$_divulong$79 Def000B +S A$_divulong$98 Def0021 +S A$_divulong$99 Def0022 +S __divulong Def0000 +S XG$_divulong$0$0 Def008B +S G$_divulong$0$0 Def0000 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 0C +R 00 00 00 03 +T 00 0C +R 00 00 00 03 +T 00 0D +R 00 00 00 03 +T 00 0D +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 7E 00 7F 00 78 00 79 +R 00 00 00 08 +T 00 0E 00 75 00 0C 20 +R 00 00 00 08 29 04 00 03 +T 00 12 +R 00 00 00 08 +T 00 12 ED 23 54 01 F5 00 0D EA 25 E0 FA EB 33 FB +R 00 00 00 08 29 07 00 03 +T 00 1F EC 33 FC ED 33 FD EE 25 E0 FE EF 33 FF E8 +R 00 00 00 08 +T 00 2D 33 F8 E9 33 F9 E5 00 0D 60 13 +R 00 00 00 08 29 08 00 03 +T 00 36 +R 00 00 00 08 +T 00 36 8E 00 08 8F 00 09 88 00 0A 89 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 3D 00 0B 74 01 45 00 08 FE AF 00 09 A8 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0B 00 03 +T 00 46 00 0A A9 00 0B +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 49 +R 00 00 00 08 +T 00 49 C3 EE 95 00 00 EF 95 00 01 E8 95 00 02 E9 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0D 00 03 +T 00 54 95 00 03 40 24 +R 00 00 00 08 29 03 00 03 +T 00 58 +R 00 00 00 08 +T 00 58 C3 EE 95 00 00 FE EF 95 00 01 FF E8 95 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 63 00 02 F8 E9 95 00 03 F9 8A 00 04 8B +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0B 00 03 +T 00 6C 00 05 8C 00 06 8D 00 07 74 01 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 74 00 04 FA AB 00 05 AC 00 06 AD +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 7B 00 07 +R 00 00 00 08 29 02 00 03 +T 00 7C +R 00 00 00 08 +T 00 7C D5 00 0C 02 80 03 +R 00 00 00 08 29 03 00 03 +T 00 81 +R 00 00 00 08 +T 00 81 02 00 12 +R 00 00 00 08 00 03 00 08 +T 00 84 +R 00 00 00 08 +T 00 84 8A 82 8B 83 8C F0 ED +R 00 00 00 08 +T 00 8B +R 00 00 00 08 +T 00 8B 22 +R 00 00 00 08 diff --git a/device/lib/small/_fs2char.asm b/device/lib/small/_fs2char.asm new file mode 100644 index 00000000..cd49c3c9 --- /dev/null +++ b/device/lib/small/_fs2char.asm @@ -0,0 +1,248 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:09 2000 + +;-------------------------------------------------------- + .module _fs2char +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2char +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fs2char_fl1_1_1: + .ds 0x0004 +___fs2char_exp_1_1: + .ds 0x0002 +___fs2char_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2char$0$0 ==. +; _fs2char.c 73 +; ----------------------------------------- +; function __fs2char +; ----------------------------------------- +___fs2char: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2char.c 96 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fs2char.c 79 + mov ___fs2char_fl1_1_1,r2 + mov (___fs2char_fl1_1_1 + 1),r3 + mov (___fs2char_fl1_1_1 + 2),r4 + mov (___fs2char_fl1_1_1 + 3),r5 +; _fs2char.c 81 + mov a,___fs2char_fl1_1_1 + orl a,(___fs2char_fl1_1_1 + 1) + orl a,(___fs2char_fl1_1_1 + 2) + orl a,(___fs2char_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2char.c 82 + mov dpl,#0x00 + ljmp 00110$ +00102$: +; _fs2char.c 84 + mov r2,(___fs2char_fl1_1_1 + 2) + mov a,(___fs2char_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov ___fs2char_exp_1_1,a + mov a,b + addc a,#0xff + mov (___fs2char_exp_1_1 + 1),a +; _fs2char.c 85 + mov r2,___fs2char_fl1_1_1 + mov r3,(___fs2char_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fs2char_fl1_1_1 + 2) + mov r6,a + mov r7,#0x00 + mov ___fs2char_l_1_1,r2 + mov (___fs2char_l_1_1 + 1),r3 + mov a,#0x80 + orl a,r6 + mov (___fs2char_l_1_1 + 2),a + mov (___fs2char_l_1_1 + 3),r7 +; _fs2char.c 87 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,___fs2char_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,(___fs2char_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2char.c 88 + mov a,(___fs2char_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + mov a,#0x7f + orl a,r2 + mov dpl,a + ljmp 00110$ +00104$: +; _fs2char.c 91 + mov a,(___fs2char_exp_1_1 + 1) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00123$: + clr c + mov a,#0xe7 + subb a,___fs2char_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,(___fs2char_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00124$: + mov a,___fs2char_l_1_1 + orl a,(___fs2char_l_1_1 + 1) + orl a,(___fs2char_l_1_1 + 2) + orl a,(___fs2char_l_1_1 + 3) +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00125$: +; _fs2char.c 92 + clr c + clr a + subb a,___fs2char_exp_1_1 + mov r2,a + clr a + subb a,(___fs2char_exp_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fs2char_l_1_1 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2char_l_1_1 + 3) + rrc a + mov (___fs2char_l_1_1 + 3),a + mov a,(___fs2char_l_1_1 + 2) + rrc a + mov (___fs2char_l_1_1 + 2),a + mov a,(___fs2char_l_1_1 + 1) + rrc a + mov (___fs2char_l_1_1 + 1),a + mov a,___fs2char_l_1_1 + rrc a + mov ___fs2char_l_1_1,a +00127$: + djnz b,00126$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2char.c 94 + mov dpl,#0x00 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00107$: +; _fs2char.c 96 + mov a,(___fs2char_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + clr c + clr a + subb a,___fs2char_l_1_1 + mov r2,a + clr a + subb a,(___fs2char_l_1_1 + 1) + mov r3,a + clr a + subb a,(___fs2char_l_1_1 + 2) + mov r6,a + clr a + subb a,(___fs2char_l_1_1 + 3) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov r2,___fs2char_l_1_1 + mov r3,(___fs2char_l_1_1 + 1) + mov r6,(___fs2char_l_1_1 + 2) + mov r7,(___fs2char_l_1_1 + 3) +00113$: + mov dpl,r2 + mov dph,r3 + mov b,r6 + mov a,r7 +00110$: + C$_fs2char.c$97$1$1 ==. + XG$__fs2char$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fs2char.cdb b/device/lib/small/_fs2char.cdb new file mode 100644 index 00000000..09f26dd7 --- /dev/null +++ b/device/lib/small/_fs2char.cdb @@ -0,0 +1,2 @@ +M:_fs2char +F:G$__fs2char$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fs2char.rel b/device/lib/small/_fs2char.rel new file mode 100644 index 00000000..5bb133a3 --- /dev/null +++ b/device/lib/small/_fs2char.rel @@ -0,0 +1,268 @@ +;!FILE _fs2char.asm +XH +H 9 areas 8F global symbols +M _fs2char +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size A flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size F8 flags 20 +S A$_fs2char$110 Def003F +S A$_fs2char$101 Def0031 +S A$_fs2char$201 Def00C3 +S A$_fs2char$120 Def0050 +S A$_fs2char$111 Def0041 +S A$_fs2char$102 Def0032 +S A$_fs2char$220 Def00D6 +S A$_fs2char$211 Def00CD +S A$_fs2char$130 Def005D +S A$_fs2char$121 Def0052 +S A$_fs2char$112 Def0043 +S A$_fs2char$103 Def0033 +S A$_fs2char$230 Def00E3 +S A$_fs2char$221 Def00D7 +S A$_fs2char$212 Def00CF +S A$_fs2char$203 Def00C6 +S A$_fs2char$140 Def006B +S A$_fs2char$122 Def0054 +S A$_fs2char$104 Def0035 +S ___fs2char Def0000 +S A$_fs2char$240 Def00F0 +S A$_fs2char$231 Def00E5 +S A$_fs2char$222 Def00D9 +S A$_fs2char$213 Def00D0 +S A$_fs2char$150 Def0079 +S A$_fs2char$141 Def006D +S A$_fs2char$132 Def005F +S A$_fs2char$123 Def0056 +S A$_fs2char$114 Def0045 +S A$_fs2char$105 Def0036 +S A$_fs2char$241 Def00F2 +S A$_fs2char$223 Def00DA +S A$_fs2char$160 Def0088 +S A$_fs2char$142 Def006E +S A$_fs2char$133 Def0061 +S A$_fs2char$124 Def0057 +S A$_fs2char$115 Def0047 +S A$_fs2char$106 Def0037 +S A$_fs2char$242 Def00F4 +S A$_fs2char$233 Def00E6 +S A$_fs2char$224 Def00DB +S A$_fs2char$215 Def00D2 +S A$_fs2char$206 Def00C8 +S A$_fs2char$170 Def0097 +S A$_fs2char$161 Def008B +S A$_fs2char$152 Def007B +S A$_fs2char$143 Def0070 +S A$_fs2char$134 Def0064 +S A$_fs2char$125 Def0059 +S A$_fs2char$116 Def0049 +S A$_fs2char$107 Def0038 +S A$_fs2char$243 Def00F6 +S A$_fs2char$225 Def00DD +S A$_fs2char$180 Def00A2 +S A$_fs2char$144 Def0071 +S A$_fs2char$135 Def0067 +S A$_fs2char$117 Def004B +S A$_fs2char$108 Def003B +S A$_fs2char$235 Def00E8 +S A$_fs2char$226 Def00DE +S A$_fs2char$217 Def00D3 +S A$_fs2char$208 Def00CB +S A$_fs2char$190 Def00B2 +S A$_fs2char$181 Def00A4 +S A$_fs2char$163 Def008D +S A$_fs2char$154 Def007E +S A$_fs2char$145 Def0073 +S A$_fs2char$127 Def005B +S A$_fs2char$118 Def004D +S A$_fs2char$109 Def003D +S A$_fs2char$236 Def00EA +S A$_fs2char$227 Def00DF +S A$_fs2char$191 Def00B4 +S A$_fs2char$182 Def00A6 +S A$_fs2char$173 Def0099 +S A$_fs2char$155 Def007F +S A$_fs2char$146 Def0074 +S A$_fs2char$137 Def0069 +S A$_fs2char$119 Def004E +S A$_fs2char$237 Def00EC +S A$_fs2char$228 Def00E1 +S A$_fs2char$219 Def00D5 +S A$_fs2char$192 Def00B6 +S A$_fs2char$183 Def00A8 +S A$_fs2char$174 Def009A +S A$_fs2char$165 Def008F +S A$_fs2char$156 Def0081 +S A$_fs2char$147 Def0076 +S A$_fs2char$129 Def005C +S A$_fs2char$247 Def00F7 +S A$_fs2char$238 Def00EE +S A$_fs2char$229 Def00E2 +S A$_fs2char$193 Def00B7 +S A$_fs2char$184 Def00A9 +S A$_fs2char$175 Def009B +S A$_fs2char$166 Def0091 +S A$_fs2char$194 Def00B9 +S A$_fs2char$185 Def00AB +S A$_fs2char$176 Def009D +S A$_fs2char$167 Def0093 +S A$_fs2char$158 Def0083 +S A$_fs2char$195 Def00BB +S A$_fs2char$177 Def009E +S A$_fs2char$168 Def0095 +S A$_fs2char$159 Def0085 +S A$_fs2char$196 Def00BC +S A$_fs2char$187 Def00AD +S A$_fs2char$178 Def009F +S A$_fs2char$197 Def00BE +S A$_fs2char$188 Def00AF +S A$_fs2char$179 Def00A1 +S XG$__fs2char$0$0 Def00F7 +S A$_fs2char$198 Def00C0 +S A$_fs2char$189 Def00B1 +S A$_fs2char$199 Def00C1 +S A$_fs2char$70 Def0006 +S A$_fs2char$80 Def0015 +S A$_fs2char$90 Def0021 +S A$_fs2char$72 Def0007 +S G$__fs2char$0$0 Def0000 +S A$_fs2char$91 Def0023 +S A$_fs2char$82 Def0017 +S A$_fs2char$73 Def0009 +S A$_fs2char$92 Def0025 +S A$_fs2char$74 Def000B +S A$_fs2char$93 Def0026 +S A$_fs2char$75 Def000D +S A$_fs2char$94 Def0027 +S A$_fs2char$85 Def0019 +S A$_fs2char$67 Def0000 +S C$_fs2char.c$97$1$1 Def00F7 +S A$_fs2char$95 Def0028 +S A$_fs2char$86 Def001C +S A$_fs2char$77 Def000F +S A$_fs2char$68 Def0002 +S A$_fs2char$96 Def0029 +S A$_fs2char$78 Def0011 +S A$_fs2char$69 Def0004 +S A$_fs2char$97 Def002A +S A$_fs2char$79 Def0013 +S A$_fs2char$98 Def002C +S A$_fs2char$89 Def001F +S A$_fs2char$99 Def002F +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 00 8B 00 01 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 02 8D 00 03 E5 00 00 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 12 00 01 45 00 02 45 00 03 70 06 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 19 +R 00 00 00 08 +T 00 19 75 82 00 02 00 F7 +R 00 00 00 08 00 06 00 08 +T 00 1F +R 00 00 00 08 +T 00 1F AA 00 02 E5 00 03 A2 E7 CA 33 CA 33 CA 54 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 2B 01 30 E0 02 44 FE +R 00 00 00 08 +T 00 31 +R 00 00 00 08 +T 00 31 FB 33 95 E0 FC FD EA 75 F0 00 24 6A F5 +R 00 00 00 08 +T 00 3E 00 04 E5 F0 34 FF F5 00 05 AA 00 00 AB +R 00 00 00 08 29 02 00 03 29 09 00 03 29 0C 00 03 +T 00 48 00 01 74 7F 55 00 02 FE 7F 00 8A 00 06 8B +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0D 00 03 +T 00 53 00 07 74 80 4E F5 00 08 8F 00 09 C3 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 5E 00 04 74 80 85 00 05 F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6A 0E +R 00 00 00 08 +T 00 6B +R 00 00 00 08 +T 00 6B E5 00 03 23 54 01 FA 74 7F 4A F5 82 02 +R 00 00 00 08 29 03 00 03 +T 00 77 00 F7 +R 00 00 00 08 00 02 00 08 +T 00 79 +R 00 00 00 08 +T 00 79 E5 00 05 30 E7 4A +R 00 00 00 08 29 03 00 03 +T 00 7E +R 00 00 00 08 +T 00 7E C3 74 E7 95 00 04 74 7F 85 00 05 F0 63 F0 +R 00 00 00 08 29 06 00 03 29 0B 00 03 +T 00 8A 80 95 F0 50 39 +R 00 00 00 08 +T 00 8F +R 00 00 00 08 +T 00 8F E5 00 06 45 00 07 45 00 08 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 96 00 09 60 2F +R 00 00 00 08 29 02 00 03 +T 00 99 +R 00 00 00 08 +T 00 99 C3 E4 95 00 04 FA E4 95 00 05 FB 8A F0 05 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 A5 F0 E5 00 09 33 92 D2 80 16 +R 00 00 00 08 29 04 00 03 +T 00 AD +R 00 00 00 08 +T 00 AD A2 D2 E5 00 09 13 F5 00 09 E5 00 08 13 F5 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0C 00 03 +T 00 B8 00 08 E5 00 07 13 F5 00 07 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 BF 00 06 13 F5 00 06 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 C3 +R 00 00 00 08 +T 00 C3 D5 F0 E7 80 05 +R 00 00 00 08 +T 00 C8 +R 00 00 00 08 +T 00 C8 75 82 00 80 2A +R 00 00 00 08 +T 00 CD +R 00 00 00 08 +T 00 CD E5 00 03 23 54 01 FA 60 13 +R 00 00 00 08 29 03 00 03 +T 00 D5 +R 00 00 00 08 +T 00 D5 C3 E4 95 00 06 FA E4 95 00 07 FB E4 95 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 E0 00 08 FE E4 95 00 09 FF 80 08 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 E8 +R 00 00 00 08 +T 00 E8 AA 00 06 AB 00 07 AE 00 08 AF +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 EF 00 09 +R 00 00 00 08 29 02 00 03 +T 00 F0 +R 00 00 00 08 +T 00 F0 8A 82 8B 83 8E F0 EF +R 00 00 00 08 +T 00 F7 +R 00 00 00 08 +T 00 F7 22 +R 00 00 00 08 diff --git a/device/lib/small/_fs2int.asm b/device/lib/small/_fs2int.asm new file mode 100644 index 00000000..2ead8324 --- /dev/null +++ b/device/lib/small/_fs2int.asm @@ -0,0 +1,251 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:09 2000 + +;-------------------------------------------------------- + .module _fs2int +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2int +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fs2int_fl1_1_1: + .ds 0x0004 +___fs2int_exp_1_1: + .ds 0x0002 +___fs2int_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2int$0$0 ==. +; _fs2int.c 73 +; ----------------------------------------- +; function __fs2int +; ----------------------------------------- +___fs2int: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2int.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fs2int.c 79 + mov ___fs2int_fl1_1_1,r2 + mov (___fs2int_fl1_1_1 + 1),r3 + mov (___fs2int_fl1_1_1 + 2),r4 + mov (___fs2int_fl1_1_1 + 3),r5 +; _fs2int.c 81 + mov a,___fs2int_fl1_1_1 + orl a,(___fs2int_fl1_1_1 + 1) + orl a,(___fs2int_fl1_1_1 + 2) + orl a,(___fs2int_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2int.c 82 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00110$ +00102$: +; _fs2int.c 84 + mov r2,(___fs2int_fl1_1_1 + 2) + mov a,(___fs2int_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov ___fs2int_exp_1_1,a + mov a,b + addc a,#0xff + mov (___fs2int_exp_1_1 + 1),a +; _fs2int.c 85 + mov r2,___fs2int_fl1_1_1 + mov r3,(___fs2int_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fs2int_fl1_1_1 + 2) + mov r6,a + mov r7,#0x00 + mov ___fs2int_l_1_1,r2 + mov (___fs2int_l_1_1 + 1),r3 + mov a,#0x80 + orl a,r6 + mov (___fs2int_l_1_1 + 2),a + mov (___fs2int_l_1_1 + 3),r7 +; _fs2int.c 87 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,___fs2int_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,(___fs2int_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2int.c 88 + mov a,(___fs2int_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov dpl,r2 + mov a,r2 + rlc a + subb a,acc + mov dph,a + ljmp 00110$ +00104$: +; _fs2int.c 91 + mov a,(___fs2int_exp_1_1 + 1) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00123$: + clr c + mov a,#0xe7 + subb a,___fs2int_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,(___fs2int_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00124$: + mov a,___fs2int_l_1_1 + orl a,(___fs2int_l_1_1 + 1) + orl a,(___fs2int_l_1_1 + 2) + orl a,(___fs2int_l_1_1 + 3) +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00125$: +; _fs2int.c 92 + clr c + clr a + subb a,___fs2int_exp_1_1 + mov r2,a + clr a + subb a,(___fs2int_exp_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fs2int_l_1_1 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2int_l_1_1 + 3) + rrc a + mov (___fs2int_l_1_1 + 3),a + mov a,(___fs2int_l_1_1 + 2) + rrc a + mov (___fs2int_l_1_1 + 2),a + mov a,(___fs2int_l_1_1 + 1) + rrc a + mov (___fs2int_l_1_1 + 1),a + mov a,___fs2int_l_1_1 + rrc a + mov ___fs2int_l_1_1,a +00127$: + djnz b,00126$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2int.c 94 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00107$: +; _fs2int.c 96 + mov a,(___fs2int_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + clr c + clr a + subb a,___fs2int_l_1_1 + mov r2,a + clr a + subb a,(___fs2int_l_1_1 + 1) + mov r3,a + clr a + subb a,(___fs2int_l_1_1 + 2) + mov r6,a + clr a + subb a,(___fs2int_l_1_1 + 3) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov r2,___fs2int_l_1_1 + mov r3,(___fs2int_l_1_1 + 1) + mov r6,(___fs2int_l_1_1 + 2) + mov r7,(___fs2int_l_1_1 + 3) +00113$: + mov dpl,r2 + mov dph,r3 +00110$: + C$_fs2int.c$97$1$1 ==. + XG$__fs2int$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fs2int.cdb b/device/lib/small/_fs2int.cdb new file mode 100644 index 00000000..49cd00e0 --- /dev/null +++ b/device/lib/small/_fs2int.cdb @@ -0,0 +1,2 @@ +M:_fs2int +F:G$__fs2int$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fs2int.rel b/device/lib/small/_fs2int.rel new file mode 100644 index 00000000..cb580a13 --- /dev/null +++ b/device/lib/small/_fs2int.rel @@ -0,0 +1,269 @@ +;!FILE _fs2int.asm +XH +H 9 areas 90 global symbols +M _fs2int +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size A flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size FB flags 20 +S A$_fs2int$198 Def00BF +S A$_fs2int$189 Def00B1 +S A$_fs2int$199 Def00C1 +S A$_fs2int$70 Def0006 +S A$_fs2int$80 Def0015 +S A$_fs2int$90 Def001F +S A$_fs2int$72 Def0007 +S G$__fs2int$0$0 Def0000 +S A$_fs2int$91 Def0021 +S A$_fs2int$82 Def0017 +S A$_fs2int$73 Def0009 +S A$_fs2int$92 Def0023 +S A$_fs2int$74 Def000B +S A$_fs2int$93 Def0025 +S A$_fs2int$75 Def000D +S A$_fs2int$94 Def0026 +S A$_fs2int$67 Def0000 +S C$_fs2int.c$97$1$1 Def00FA +S A$_fs2int$95 Def0027 +S A$_fs2int$86 Def0019 +S A$_fs2int$77 Def000F +S A$_fs2int$68 Def0002 +S A$_fs2int$96 Def0028 +S A$_fs2int$87 Def001C +S A$_fs2int$78 Def0011 +S A$_fs2int$69 Def0004 +S A$_fs2int$97 Def0029 +S A$_fs2int$79 Def0013 +S A$_fs2int$98 Def002A +S A$_fs2int$99 Def002C +S A$_fs2int$100 Def002F +S A$_fs2int$200 Def00C2 +S A$_fs2int$110 Def003D +S A$_fs2int$201 Def00C4 +S A$_fs2int$120 Def004E +S A$_fs2int$111 Def003F +S A$_fs2int$102 Def0031 +S A$_fs2int$220 Def00D8 +S A$_fs2int$211 Def00CE +S A$_fs2int$202 Def00C6 +S A$_fs2int$130 Def005C +S A$_fs2int$121 Def0050 +S A$_fs2int$112 Def0041 +S A$_fs2int$103 Def0032 +S A$_fs2int$230 Def00E3 +S A$_fs2int$203 Def00C7 +S A$_fs2int$131 Def005D +S A$_fs2int$122 Def0052 +S A$_fs2int$113 Def0043 +S A$_fs2int$104 Def0033 +S ___fs2int Def0000 +S A$_fs2int$240 Def00EE +S A$_fs2int$231 Def00E4 +S A$_fs2int$222 Def00D9 +S A$_fs2int$213 Def00D1 +S A$_fs2int$150 Def007A +S A$_fs2int$141 Def006B +S A$_fs2int$123 Def0054 +S A$_fs2int$105 Def0035 +S A$_fs2int$250 Def00FA +S A$_fs2int$241 Def00F0 +S A$_fs2int$232 Def00E5 +S A$_fs2int$205 Def00C9 +S A$_fs2int$160 Def0087 +S A$_fs2int$151 Def007C +S A$_fs2int$142 Def006D +S A$_fs2int$133 Def005F +S A$_fs2int$124 Def0056 +S A$_fs2int$115 Def0045 +S A$_fs2int$106 Def0036 +S A$_fs2int$242 Def00F2 +S A$_fs2int$233 Def00E7 +S A$_fs2int$224 Def00DB +S A$_fs2int$170 Def0097 +S A$_fs2int$143 Def006E +S A$_fs2int$134 Def0061 +S A$_fs2int$125 Def0057 +S A$_fs2int$116 Def0047 +S A$_fs2int$107 Def0037 +S A$_fs2int$243 Def00F4 +S A$_fs2int$234 Def00E8 +S A$_fs2int$225 Def00DC +S A$_fs2int$216 Def00D3 +S A$_fs2int$207 Def00CC +S A$_fs2int$180 Def00A3 +S A$_fs2int$171 Def0099 +S A$_fs2int$162 Def0089 +S A$_fs2int$144 Def0070 +S A$_fs2int$135 Def0064 +S A$_fs2int$126 Def0059 +S A$_fs2int$117 Def0049 +S A$_fs2int$108 Def0038 +S A$_fs2int$235 Def00E9 +S A$_fs2int$226 Def00DD +S A$_fs2int$217 Def00D5 +S A$_fs2int$181 Def00A4 +S A$_fs2int$172 Def009B +S A$_fs2int$163 Def008B +S A$_fs2int$154 Def007F +S A$_fs2int$145 Def0071 +S A$_fs2int$136 Def0067 +S A$_fs2int$118 Def004B +S A$_fs2int$109 Def003B +S A$_fs2int$245 Def00F6 +S A$_fs2int$236 Def00EB +S A$_fs2int$227 Def00DF +S A$_fs2int$218 Def00D6 +S A$_fs2int$191 Def00B3 +S A$_fs2int$182 Def00A5 +S A$_fs2int$164 Def008E +S A$_fs2int$146 Def0074 +S A$_fs2int$128 Def005B +S A$_fs2int$119 Def004D +S A$_fs2int$246 Def00F8 +S A$_fs2int$228 Def00E0 +S A$_fs2int$192 Def00B5 +S A$_fs2int$183 Def00A7 +S A$_fs2int$174 Def009D +S A$_fs2int$165 Def0091 +S A$_fs2int$156 Def0081 +S A$_fs2int$147 Def0076 +S A$_fs2int$138 Def0069 +S A$_fs2int$238 Def00EC +S A$_fs2int$229 Def00E1 +S A$_fs2int$193 Def00B7 +S A$_fs2int$184 Def00A8 +S A$_fs2int$148 Def0077 +S A$_fs2int$194 Def00B8 +S A$_fs2int$185 Def00AA +S A$_fs2int$167 Def0093 +S A$_fs2int$158 Def0084 +S A$_fs2int$149 Def0078 +S A$_fs2int$195 Def00BA +S A$_fs2int$186 Def00AC +S A$_fs2int$177 Def009F +S A$_fs2int$159 Def0085 +S A$_fs2int$196 Def00BC +S A$_fs2int$187 Def00AE +S A$_fs2int$178 Def00A0 +S A$_fs2int$169 Def0095 +S A$_fs2int$197 Def00BD +S A$_fs2int$188 Def00AF +S A$_fs2int$179 Def00A1 +S XG$__fs2int$0$0 Def00FA +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 00 8B 00 01 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 02 8D 00 03 E5 00 00 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 12 00 01 45 00 02 45 00 03 70 06 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 19 +R 00 00 00 08 +T 00 19 90 00 00 02 00 FA +R 00 00 00 08 00 06 00 08 +T 00 1F +R 00 00 00 08 +T 00 1F AA 00 02 E5 00 03 A2 E7 CA 33 CA 33 CA 54 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 2B 01 30 E0 02 44 FE +R 00 00 00 08 +T 00 31 +R 00 00 00 08 +T 00 31 FB 33 95 E0 FC FD EA 75 F0 00 24 6A F5 +R 00 00 00 08 +T 00 3E 00 04 E5 F0 34 FF F5 00 05 AA 00 00 AB +R 00 00 00 08 29 02 00 03 29 09 00 03 29 0C 00 03 +T 00 48 00 01 74 7F 55 00 02 FE 7F 00 8A 00 06 8B +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0D 00 03 +T 00 53 00 07 74 80 4E F5 00 08 8F 00 09 C3 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 5E 00 04 74 80 85 00 05 F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6A 14 +R 00 00 00 08 +T 00 6B +R 00 00 00 08 +T 00 6B E5 00 03 23 54 01 FA 43 02 7F 8A 82 EA 33 +R 00 00 00 08 29 03 00 03 +T 00 78 95 E0 F5 83 02 00 FA +R 00 00 00 08 00 07 00 08 +T 00 7F +R 00 00 00 08 +T 00 7F E5 00 05 30 E7 4A +R 00 00 00 08 29 03 00 03 +T 00 84 +R 00 00 00 08 +T 00 84 C3 74 E7 95 00 04 74 7F 85 00 05 F0 63 F0 +R 00 00 00 08 29 06 00 03 29 0B 00 03 +T 00 90 80 95 F0 50 39 +R 00 00 00 08 +T 00 95 +R 00 00 00 08 +T 00 95 E5 00 06 45 00 07 45 00 08 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 9C 00 09 60 2F +R 00 00 00 08 29 02 00 03 +T 00 9F +R 00 00 00 08 +T 00 9F C3 E4 95 00 04 FA E4 95 00 05 FB 8A F0 05 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 AB F0 E5 00 09 33 92 D2 80 16 +R 00 00 00 08 29 04 00 03 +T 00 B3 +R 00 00 00 08 +T 00 B3 A2 D2 E5 00 09 13 F5 00 09 E5 00 08 13 F5 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0C 00 03 +T 00 BE 00 08 E5 00 07 13 F5 00 07 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 C5 00 06 13 F5 00 06 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 C9 +R 00 00 00 08 +T 00 C9 D5 F0 E7 80 05 +R 00 00 00 08 +T 00 CE +R 00 00 00 08 +T 00 CE 90 00 00 80 27 +R 00 00 00 08 +T 00 D3 +R 00 00 00 08 +T 00 D3 E5 00 03 23 54 01 FA 60 13 +R 00 00 00 08 29 03 00 03 +T 00 DB +R 00 00 00 08 +T 00 DB C3 E4 95 00 06 FA E4 95 00 07 FB E4 95 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 E6 00 08 FE E4 95 00 09 FF 80 08 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 EE +R 00 00 00 08 +T 00 EE AA 00 06 AB 00 07 AE 00 08 AF +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 F5 00 09 +R 00 00 00 08 29 02 00 03 +T 00 F6 +R 00 00 00 08 +T 00 F6 8A 82 8B 83 +R 00 00 00 08 +T 00 FA +R 00 00 00 08 +T 00 FA 22 +R 00 00 00 08 diff --git a/device/lib/small/_fs2long.asm b/device/lib/small/_fs2long.asm new file mode 100644 index 00000000..369c0744 --- /dev/null +++ b/device/lib/small/_fs2long.asm @@ -0,0 +1,264 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:10 2000 + +;-------------------------------------------------------- + .module _fs2long +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2long +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fs2long_fl1_1_1: + .ds 0x0004 +___fs2long_exp_1_1: + .ds 0x0002 +___fs2long_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2long$0$0 ==. +; _fs2long.c 73 +; ----------------------------------------- +; function __fs2long +; ----------------------------------------- +___fs2long: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2long.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fs2long.c 79 + mov ___fs2long_fl1_1_1,r2 + mov (___fs2long_fl1_1_1 + 1),r3 + mov (___fs2long_fl1_1_1 + 2),r4 + mov (___fs2long_fl1_1_1 + 3),r5 +; _fs2long.c 81 + mov a,___fs2long_fl1_1_1 + orl a,(___fs2long_fl1_1_1 + 1) + orl a,(___fs2long_fl1_1_1 + 2) + orl a,(___fs2long_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2long.c 82 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00110$ +00102$: +; _fs2long.c 84 + mov r2,(___fs2long_fl1_1_1 + 2) + mov a,(___fs2long_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov ___fs2long_exp_1_1,a + mov a,b + addc a,#0xff + mov (___fs2long_exp_1_1 + 1),a +; _fs2long.c 85 + mov r2,___fs2long_fl1_1_1 + mov r3,(___fs2long_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fs2long_fl1_1_1 + 2) + mov r6,a + mov r7,#0x00 + mov ___fs2long_l_1_1,r2 + mov (___fs2long_l_1_1 + 1),r3 + mov a,#0x80 + orl a,r6 + mov (___fs2long_l_1_1 + 2),a + mov (___fs2long_l_1_1 + 3),r7 +; _fs2long.c 87 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,___fs2long_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,(___fs2long_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2long.c 88 + mov a,(___fs2long_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov dpl,r2 + mov a,r2 + rlc a + subb a,acc + mov dph,a + mov b,a + ljmp 00110$ +00104$: +; _fs2long.c 91 + mov a,(___fs2long_exp_1_1 + 1) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00123$: + clr c + mov a,#0xe7 + subb a,___fs2long_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,(___fs2long_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00124$: + mov a,___fs2long_l_1_1 + orl a,(___fs2long_l_1_1 + 1) + orl a,(___fs2long_l_1_1 + 2) + orl a,(___fs2long_l_1_1 + 3) +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00125$: +; _fs2long.c 92 + clr c + clr a + subb a,___fs2long_exp_1_1 + mov r2,a + clr a + subb a,(___fs2long_exp_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fs2long_l_1_1 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2long_l_1_1 + 3) + rrc a + mov (___fs2long_l_1_1 + 3),a + mov a,(___fs2long_l_1_1 + 2) + rrc a + mov (___fs2long_l_1_1 + 2),a + mov a,(___fs2long_l_1_1 + 1) + rrc a + mov (___fs2long_l_1_1 + 1),a + mov a,___fs2long_l_1_1 + rrc a + mov ___fs2long_l_1_1,a +00127$: + djnz b,00126$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2long.c 94 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00107$: +; _fs2long.c 96 + mov a,(___fs2long_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + clr c + clr a + subb a,___fs2long_l_1_1 + mov r2,a + clr a + subb a,(___fs2long_l_1_1 + 1) + mov r3,a + clr a + subb a,(___fs2long_l_1_1 + 2) + mov r6,a + clr a + subb a,(___fs2long_l_1_1 + 3) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov r2,___fs2long_l_1_1 + mov r3,(___fs2long_l_1_1 + 1) + mov r6,(___fs2long_l_1_1 + 2) + mov r7,(___fs2long_l_1_1 + 3) +00113$: + mov dpl,r2 + mov dph,r3 + mov b,r6 + mov a,r7 +00110$: + C$_fs2long.c$97$1$1 ==. + XG$__fs2long$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fs2long.cdb b/device/lib/small/_fs2long.cdb new file mode 100644 index 00000000..8e9563e8 --- /dev/null +++ b/device/lib/small/_fs2long.cdb @@ -0,0 +1,2 @@ +M:_fs2long +F:G$__fs2long$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fs2long.rel b/device/lib/small/_fs2long.rel new file mode 100644 index 00000000..d135089d --- /dev/null +++ b/device/lib/small/_fs2long.rel @@ -0,0 +1,278 @@ +;!FILE _fs2long.asm +XH +H 9 areas 99 global symbols +M _fs2long +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size A flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 108 flags 20 +S A$_fs2long$100 Def002B +S A$_fs2long$200 Def00BE +S A$_fs2long$110 Def0039 +S A$_fs2long$101 Def002C +S A$_fs2long$201 Def00C0 +S A$_fs2long$120 Def0049 +S A$_fs2long$111 Def003A +S A$_fs2long$102 Def002D +S A$_fs2long$220 Def00D5 +S A$_fs2long$211 Def00CF +S A$_fs2long$202 Def00C2 +S A$_fs2long$130 Def005B +S A$_fs2long$121 Def004B +S A$_fs2long$112 Def003B +S A$_fs2long$103 Def002E +S A$_fs2long$221 Def00D7 +S A$_fs2long$203 Def00C3 +S A$_fs2long$140 Def0068 +S A$_fs2long$131 Def005D +S A$_fs2long$122 Def004D +S A$_fs2long$113 Def003C +S A$_fs2long$104 Def0030 +S ___fs2long Def0000 +S A$_fs2long$240 Def00EB +S A$_fs2long$231 Def00E2 +S A$_fs2long$222 Def00D9 +S A$_fs2long$213 Def00D2 +S A$_fs2long$204 Def00C5 +S A$_fs2long$150 Def0075 +S A$_fs2long$141 Def006B +S A$_fs2long$123 Def004F +S A$_fs2long$114 Def003F +S A$_fs2long$105 Def0033 +S A$_fs2long$241 Def00ED +S A$_fs2long$205 Def00C7 +S A$_fs2long$160 Def0085 +S A$_fs2long$151 Def0078 +S A$_fs2long$133 Def005F +S A$_fs2long$124 Def0051 +S A$_fs2long$115 Def0041 +S A$_fs2long$251 Def00F8 +S A$_fs2long$242 Def00EE +S A$_fs2long$233 Def00E3 +S A$_fs2long$224 Def00DB +S A$_fs2long$206 Def00C8 +S A$_fs2long$170 Def0094 +S A$_fs2long$152 Def007A +S A$_fs2long$143 Def006D +S A$_fs2long$125 Def0052 +S A$_fs2long$116 Def0043 +S A$_fs2long$107 Def0035 +S A$_fs2long$252 Def00FA +S A$_fs2long$243 Def00EF +S A$_fs2long$207 Def00CA +S A$_fs2long$180 Def00A3 +S A$_fs2long$171 Def0097 +S A$_fs2long$162 Def0087 +S A$_fs2long$153 Def007B +S A$_fs2long$135 Def0060 +S A$_fs2long$126 Def0054 +S A$_fs2long$117 Def0045 +S A$_fs2long$108 Def0036 +S A$_fs2long$253 Def00FC +S A$_fs2long$244 Def00F1 +S A$_fs2long$235 Def00E5 +S A$_fs2long$208 Def00CC +S A$_fs2long$190 Def00AE +S A$_fs2long$154 Def007C +S A$_fs2long$136 Def0061 +S A$_fs2long$127 Def0056 +S A$_fs2long$118 Def0047 +S A$_fs2long$109 Def0037 +S A$_fs2long$263 Def0107 +S A$_fs2long$254 Def00FE +S A$_fs2long$245 Def00F2 +S A$_fs2long$236 Def00E6 +S A$_fs2long$227 Def00DD +S A$_fs2long$209 Def00CD +S A$_fs2long$191 Def00B0 +S A$_fs2long$173 Def0099 +S A$_fs2long$164 Def008A +S A$_fs2long$155 Def007E +S A$_fs2long$146 Def006F +S A$_fs2long$128 Def0058 +S A$_fs2long$246 Def00F3 +S A$_fs2long$237 Def00E7 +S A$_fs2long$228 Def00DF +S A$_fs2long$219 Def00D4 +S A$_fs2long$192 Def00B2 +S A$_fs2long$183 Def00A5 +S A$_fs2long$165 Def008B +S A$_fs2long$156 Def0080 +S A$_fs2long$147 Def0071 +S A$_fs2long$138 Def0063 +S A$_fs2long$129 Def005A +S A$_fs2long$256 Def0100 +S A$_fs2long$247 Def00F5 +S A$_fs2long$238 Def00E9 +S A$_fs2long$229 Def00E0 +S A$_fs2long$193 Def00B4 +S A$_fs2long$184 Def00A6 +S A$_fs2long$175 Def009B +S A$_fs2long$166 Def008D +S A$_fs2long$157 Def0082 +S A$_fs2long$148 Def0072 +S A$_fs2long$139 Def0065 +S A$_fs2long$257 Def0102 +S A$_fs2long$239 Def00EA +S A$_fs2long$194 Def00B5 +S A$_fs2long$185 Def00A7 +S A$_fs2long$176 Def009D +S A$_fs2long$149 Def0074 +S A$_fs2long$258 Def0104 +S A$_fs2long$249 Def00F6 +S A$_fs2long$195 Def00B7 +S A$_fs2long$186 Def00A9 +S A$_fs2long$177 Def009F +S A$_fs2long$168 Def008F +S A$_fs2long$259 Def0106 +S A$_fs2long$187 Def00AA +S A$_fs2long$178 Def00A1 +S A$_fs2long$169 Def0091 +S A$_fs2long$197 Def00B9 +S A$_fs2long$188 Def00AB +S XG$__fs2long$0$0 Def0107 +S A$_fs2long$198 Def00BB +S A$_fs2long$189 Def00AD +S A$_fs2long$199 Def00BD +S A$_fs2long$70 Def0006 +S A$_fs2long$80 Def0015 +S A$_fs2long$90 Def001C +S A$_fs2long$72 Def0007 +S G$__fs2long$0$0 Def0000 +S A$_fs2long$91 Def001E +S A$_fs2long$82 Def0017 +S A$_fs2long$73 Def0009 +S A$_fs2long$92 Def0020 +S A$_fs2long$74 Def000B +S A$_fs2long$75 Def000D +S A$_fs2long$67 Def0000 +S C$_fs2long.c$97$1$1 Def0107 +S A$_fs2long$95 Def0023 +S A$_fs2long$77 Def000F +S A$_fs2long$68 Def0002 +S A$_fs2long$96 Def0025 +S A$_fs2long$78 Def0011 +S A$_fs2long$69 Def0004 +S A$_fs2long$97 Def0027 +S A$_fs2long$88 Def0019 +S A$_fs2long$79 Def0013 +S A$_fs2long$98 Def0029 +S A$_fs2long$89 Def001A +S A$_fs2long$99 Def002A +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 00 8B 00 01 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 02 8D 00 03 E5 00 00 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 12 00 01 45 00 02 45 00 03 70 0A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 19 +R 00 00 00 08 +T 00 19 E4 F5 82 F5 83 F5 F0 02 01 07 +R 00 00 00 08 00 0A 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 AA 00 02 E5 00 03 A2 E7 CA 33 CA 33 CA 54 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 2F 01 30 E0 02 44 FE +R 00 00 00 08 +T 00 35 +R 00 00 00 08 +T 00 35 FB 33 95 E0 FC FD EA 75 F0 00 24 6A F5 +R 00 00 00 08 +T 00 42 00 04 E5 F0 34 FF F5 00 05 AA 00 00 AB +R 00 00 00 08 29 02 00 03 29 09 00 03 29 0C 00 03 +T 00 4C 00 01 74 7F 55 00 02 FE 7F 00 8A 00 06 8B +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0D 00 03 +T 00 57 00 07 74 80 4E F5 00 08 8F 00 09 C3 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 62 00 04 74 80 85 00 05 F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6E 16 +R 00 00 00 08 +T 00 6F +R 00 00 00 08 +T 00 6F E5 00 03 23 54 01 FA 43 02 7F 8A 82 EA 33 +R 00 00 00 08 29 03 00 03 +T 00 7C 95 E0 F5 83 F5 F0 02 01 07 +R 00 00 00 08 00 09 00 08 +T 00 85 +R 00 00 00 08 +T 00 85 E5 00 05 30 E7 4A +R 00 00 00 08 29 03 00 03 +T 00 8A +R 00 00 00 08 +T 00 8A C3 74 E7 95 00 04 74 7F 85 00 05 F0 63 F0 +R 00 00 00 08 29 06 00 03 29 0B 00 03 +T 00 96 80 95 F0 50 39 +R 00 00 00 08 +T 00 9B +R 00 00 00 08 +T 00 9B E5 00 06 45 00 07 45 00 08 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 A2 00 09 60 2F +R 00 00 00 08 29 02 00 03 +T 00 A5 +R 00 00 00 08 +T 00 A5 C3 E4 95 00 04 FA E4 95 00 05 FB 8A F0 05 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 B1 F0 E5 00 09 33 92 D2 80 16 +R 00 00 00 08 29 04 00 03 +T 00 B9 +R 00 00 00 08 +T 00 B9 A2 D2 E5 00 09 13 F5 00 09 E5 00 08 13 F5 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0C 00 03 +T 00 C4 00 08 E5 00 07 13 F5 00 07 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 CB 00 06 13 F5 00 06 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 CF +R 00 00 00 08 +T 00 CF D5 F0 E7 80 09 +R 00 00 00 08 +T 00 D4 +R 00 00 00 08 +T 00 D4 E4 F5 82 F5 83 F5 F0 80 2A +R 00 00 00 08 +T 00 DD +R 00 00 00 08 +T 00 DD E5 00 03 23 54 01 FA 60 13 +R 00 00 00 08 29 03 00 03 +T 00 E5 +R 00 00 00 08 +T 00 E5 C3 E4 95 00 06 FA E4 95 00 07 FB E4 95 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 F0 00 08 FE E4 95 00 09 FF 80 08 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 F8 +R 00 00 00 08 +T 00 F8 AA 00 06 AB 00 07 AE 00 08 AF +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 FF 00 09 +R 00 00 00 08 29 02 00 03 +T 01 00 +R 00 00 00 08 +T 01 00 8A 82 8B 83 8E F0 EF +R 00 00 00 08 +T 01 07 +R 00 00 00 08 +T 01 07 22 +R 00 00 00 08 diff --git a/device/lib/small/_fs2uchar.asm b/device/lib/small/_fs2uchar.asm new file mode 100644 index 00000000..198dae99 --- /dev/null +++ b/device/lib/small/_fs2uchar.asm @@ -0,0 +1,234 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:10 2000 + +;-------------------------------------------------------- + .module _fs2uchar +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2uchar +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fs2uchar_fl1_1_1: + .ds 0x0004 +___fs2uchar_exp_1_1: + .ds 0x0002 +___fs2uchar_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2uchar$0$0 ==. +; _fs2uchar.c 73 +; ----------------------------------------- +; function __fs2uchar +; ----------------------------------------- +___fs2uchar: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2uchar.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fs2uchar.c 79 + mov ___fs2uchar_fl1_1_1,r2 + mov (___fs2uchar_fl1_1_1 + 1),r3 + mov (___fs2uchar_fl1_1_1 + 2),r4 + mov (___fs2uchar_fl1_1_1 + 3),r5 +; _fs2uchar.c 81 + mov a,___fs2uchar_fl1_1_1 + orl a,(___fs2uchar_fl1_1_1 + 1) + orl a,(___fs2uchar_fl1_1_1 + 2) + orl a,(___fs2uchar_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2uchar.c 82 + mov dpl,#0x00 + ljmp 00110$ +00102$: +; _fs2uchar.c 84 + mov r2,(___fs2uchar_fl1_1_1 + 2) + mov a,(___fs2uchar_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov ___fs2uchar_exp_1_1,a + mov a,b + addc a,#0xff + mov (___fs2uchar_exp_1_1 + 1),a +; _fs2uchar.c 85 + mov r2,___fs2uchar_fl1_1_1 + mov r3,(___fs2uchar_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fs2uchar_fl1_1_1 + 2) + mov r6,a + mov r7,#0x00 + mov ___fs2uchar_l_1_1,r2 + mov (___fs2uchar_l_1_1 + 1),r3 + mov a,#0x80 + orl a,r6 + mov (___fs2uchar_l_1_1 + 2),a + mov (___fs2uchar_l_1_1 + 3),r7 +; _fs2uchar.c 87 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,___fs2uchar_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,(___fs2uchar_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2uchar.c 88 + mov a,(___fs2uchar_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + mov a,#0x7f + orl a,r2 + mov dpl,a + ljmp 00110$ +00104$: +; _fs2uchar.c 91 + mov a,(___fs2uchar_exp_1_1 + 1) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00123$: + clr c + mov a,#0xe7 + subb a,___fs2uchar_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,(___fs2uchar_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00124$: + mov a,___fs2uchar_l_1_1 + orl a,(___fs2uchar_l_1_1 + 1) + orl a,(___fs2uchar_l_1_1 + 2) + orl a,(___fs2uchar_l_1_1 + 3) +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00125$: +; _fs2uchar.c 92 + clr c + clr a + subb a,___fs2uchar_exp_1_1 + mov r2,a + clr a + subb a,(___fs2uchar_exp_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fs2uchar_l_1_1 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2uchar_l_1_1 + 3) + rrc a + mov (___fs2uchar_l_1_1 + 3),a + mov a,(___fs2uchar_l_1_1 + 2) + rrc a + mov (___fs2uchar_l_1_1 + 2),a + mov a,(___fs2uchar_l_1_1 + 1) + rrc a + mov (___fs2uchar_l_1_1 + 1),a + mov a,___fs2uchar_l_1_1 + rrc a + mov ___fs2uchar_l_1_1,a +00127$: + djnz b,00126$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2uchar.c 94 + mov dpl,#0x00 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00107$: +; _fs2uchar.c 96 + mov a,(___fs2uchar_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + mov r2,___fs2uchar_l_1_1 + clr c + clr a + subb a,r2 + mov r2,a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov r2,___fs2uchar_l_1_1 +00113$: + mov dpl,r2 +00110$: + C$_fs2uchar.c$97$1$1 ==. + XG$__fs2uchar$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fs2uchar.cdb b/device/lib/small/_fs2uchar.cdb new file mode 100644 index 00000000..c8846cbb --- /dev/null +++ b/device/lib/small/_fs2uchar.cdb @@ -0,0 +1,2 @@ +M:_fs2uchar +F:G$__fs2uchar$0$0({2}DF,SC:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_fs2uchar.rel b/device/lib/small/_fs2uchar.rel new file mode 100644 index 00000000..ea456006 --- /dev/null +++ b/device/lib/small/_fs2uchar.rel @@ -0,0 +1,250 @@ +;!FILE _fs2uchar.asm +XH +H 9 areas 81 global symbols +M _fs2uchar +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size A flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size E2 flags 20 +S A$_fs2uchar$217 Def00D3 +S A$_fs2uchar$208 Def00CB +S A$_fs2uchar$190 Def00B2 +S A$_fs2uchar$181 Def00A4 +S A$_fs2uchar$163 Def008D +S A$_fs2uchar$154 Def007E +S A$_fs2uchar$145 Def0073 +S A$_fs2uchar$127 Def005B +S A$_fs2uchar$118 Def004D +S A$_fs2uchar$109 Def003D +S A$_fs2uchar$227 Def00DD +S A$_fs2uchar$191 Def00B4 +S A$_fs2uchar$182 Def00A6 +S A$_fs2uchar$173 Def0099 +S A$_fs2uchar$155 Def007F +S A$_fs2uchar$146 Def0074 +S A$_fs2uchar$137 Def0069 +S A$_fs2uchar$119 Def004E +S A$_fs2uchar$219 Def00D5 +S A$_fs2uchar$192 Def00B6 +S A$_fs2uchar$183 Def00A8 +S A$_fs2uchar$174 Def009A +S A$_fs2uchar$165 Def008F +S A$_fs2uchar$156 Def0081 +S A$_fs2uchar$147 Def0076 +S A$_fs2uchar$129 Def005C +S A$_fs2uchar$229 Def00DF +S A$_fs2uchar$193 Def00B7 +S A$_fs2uchar$184 Def00A9 +S A$_fs2uchar$175 Def009B +S A$_fs2uchar$166 Def0091 +S A$_fs2uchar$194 Def00B9 +S A$_fs2uchar$185 Def00AB +S A$_fs2uchar$176 Def009D +S A$_fs2uchar$167 Def0093 +S A$_fs2uchar$158 Def0083 +S A$_fs2uchar$195 Def00BB +S A$_fs2uchar$177 Def009E +S A$_fs2uchar$168 Def0095 +S A$_fs2uchar$159 Def0085 +S A$_fs2uchar$196 Def00BC +S A$_fs2uchar$187 Def00AD +S A$_fs2uchar$178 Def009F +S A$_fs2uchar$197 Def00BE +S A$_fs2uchar$188 Def00AF +S A$_fs2uchar$179 Def00A1 +S XG$__fs2uchar$0$0 Def00E1 +S A$_fs2uchar$198 Def00C0 +S A$_fs2uchar$189 Def00B1 +S A$_fs2uchar$199 Def00C1 +S A$_fs2uchar$70 Def0006 +S A$_fs2uchar$80 Def0015 +S A$_fs2uchar$90 Def0021 +S A$_fs2uchar$72 Def0007 +S G$__fs2uchar$0$0 Def0000 +S A$_fs2uchar$91 Def0023 +S A$_fs2uchar$82 Def0017 +S A$_fs2uchar$73 Def0009 +S A$_fs2uchar$92 Def0025 +S A$_fs2uchar$74 Def000B +S A$_fs2uchar$93 Def0026 +S A$_fs2uchar$75 Def000D +S A$_fs2uchar$94 Def0027 +S A$_fs2uchar$85 Def0019 +S A$_fs2uchar$67 Def0000 +S C$_fs2uchar.c$97$1$1 Def00E1 +S A$_fs2uchar$95 Def0028 +S A$_fs2uchar$86 Def001C +S A$_fs2uchar$77 Def000F +S A$_fs2uchar$68 Def0002 +S A$_fs2uchar$96 Def0029 +S A$_fs2uchar$78 Def0011 +S A$_fs2uchar$69 Def0004 +S A$_fs2uchar$97 Def002A +S A$_fs2uchar$79 Def0013 +S A$_fs2uchar$98 Def002C +S A$_fs2uchar$89 Def001F +S A$_fs2uchar$99 Def002F +S A$_fs2uchar$110 Def003F +S A$_fs2uchar$101 Def0031 +S A$_fs2uchar$201 Def00C3 +S A$_fs2uchar$120 Def0050 +S A$_fs2uchar$111 Def0041 +S A$_fs2uchar$102 Def0032 +S A$_fs2uchar$220 Def00D7 +S A$_fs2uchar$211 Def00CD +S A$_fs2uchar$130 Def005D +S A$_fs2uchar$121 Def0052 +S A$_fs2uchar$112 Def0043 +S A$_fs2uchar$103 Def0033 +S A$_fs2uchar$221 Def00D8 +S A$_fs2uchar$212 Def00CF +S A$_fs2uchar$203 Def00C6 +S A$_fs2uchar$140 Def006B +S A$_fs2uchar$122 Def0054 +S A$_fs2uchar$104 Def0035 +S ___fs2uchar Def0000 +S A$_fs2uchar$222 Def00D9 +S A$_fs2uchar$213 Def00D0 +S A$_fs2uchar$150 Def0079 +S A$_fs2uchar$141 Def006D +S A$_fs2uchar$132 Def005F +S A$_fs2uchar$123 Def0056 +S A$_fs2uchar$114 Def0045 +S A$_fs2uchar$105 Def0036 +S A$_fs2uchar$223 Def00DA +S A$_fs2uchar$160 Def0088 +S A$_fs2uchar$142 Def006E +S A$_fs2uchar$133 Def0061 +S A$_fs2uchar$124 Def0057 +S A$_fs2uchar$115 Def0047 +S A$_fs2uchar$106 Def0037 +S A$_fs2uchar$233 Def00E1 +S A$_fs2uchar$215 Def00D2 +S A$_fs2uchar$206 Def00C8 +S A$_fs2uchar$170 Def0097 +S A$_fs2uchar$161 Def008B +S A$_fs2uchar$152 Def007B +S A$_fs2uchar$143 Def0070 +S A$_fs2uchar$134 Def0064 +S A$_fs2uchar$125 Def0059 +S A$_fs2uchar$116 Def0049 +S A$_fs2uchar$107 Def0038 +S A$_fs2uchar$225 Def00DB +S A$_fs2uchar$180 Def00A2 +S A$_fs2uchar$144 Def0071 +S A$_fs2uchar$135 Def0067 +S A$_fs2uchar$117 Def004B +S A$_fs2uchar$108 Def003B +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 00 8B 00 01 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 02 8D 00 03 E5 00 00 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 12 00 01 45 00 02 45 00 03 70 06 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 19 +R 00 00 00 08 +T 00 19 75 82 00 02 00 E1 +R 00 00 00 08 00 06 00 08 +T 00 1F +R 00 00 00 08 +T 00 1F AA 00 02 E5 00 03 A2 E7 CA 33 CA 33 CA 54 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 2B 01 30 E0 02 44 FE +R 00 00 00 08 +T 00 31 +R 00 00 00 08 +T 00 31 FB 33 95 E0 FC FD EA 75 F0 00 24 6A F5 +R 00 00 00 08 +T 00 3E 00 04 E5 F0 34 FF F5 00 05 AA 00 00 AB +R 00 00 00 08 29 02 00 03 29 09 00 03 29 0C 00 03 +T 00 48 00 01 74 7F 55 00 02 FE 7F 00 8A 00 06 8B +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0D 00 03 +T 00 53 00 07 74 80 4E F5 00 08 8F 00 09 C3 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 5E 00 04 74 80 85 00 05 F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6A 0E +R 00 00 00 08 +T 00 6B +R 00 00 00 08 +T 00 6B E5 00 03 23 54 01 FA 74 7F 4A F5 82 02 +R 00 00 00 08 29 03 00 03 +T 00 77 00 E1 +R 00 00 00 08 00 02 00 08 +T 00 79 +R 00 00 00 08 +T 00 79 E5 00 05 30 E7 4A +R 00 00 00 08 29 03 00 03 +T 00 7E +R 00 00 00 08 +T 00 7E C3 74 E7 95 00 04 74 7F 85 00 05 F0 63 F0 +R 00 00 00 08 29 06 00 03 29 0B 00 03 +T 00 8A 80 95 F0 50 39 +R 00 00 00 08 +T 00 8F +R 00 00 00 08 +T 00 8F E5 00 06 45 00 07 45 00 08 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 96 00 09 60 2F +R 00 00 00 08 29 02 00 03 +T 00 99 +R 00 00 00 08 +T 00 99 C3 E4 95 00 04 FA E4 95 00 05 FB 8A F0 05 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 A5 F0 E5 00 09 33 92 D2 80 16 +R 00 00 00 08 29 04 00 03 +T 00 AD +R 00 00 00 08 +T 00 AD A2 D2 E5 00 09 13 F5 00 09 E5 00 08 13 F5 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0C 00 03 +T 00 B8 00 08 E5 00 07 13 F5 00 07 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 BF 00 06 13 F5 00 06 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 C3 +R 00 00 00 08 +T 00 C3 D5 F0 E7 80 05 +R 00 00 00 08 +T 00 C8 +R 00 00 00 08 +T 00 C8 75 82 00 80 14 +R 00 00 00 08 +T 00 CD +R 00 00 00 08 +T 00 CD E5 00 03 23 54 01 FA 60 08 +R 00 00 00 08 29 03 00 03 +T 00 D5 +R 00 00 00 08 +T 00 D5 AA 00 06 C3 E4 9A FA 80 02 +R 00 00 00 08 29 03 00 03 +T 00 DD +R 00 00 00 08 +T 00 DD AA 00 06 +R 00 00 00 08 29 03 00 03 +T 00 DF +R 00 00 00 08 +T 00 DF 8A 82 +R 00 00 00 08 +T 00 E1 +R 00 00 00 08 +T 00 E1 22 +R 00 00 00 08 diff --git a/device/lib/small/_fs2uint.asm b/device/lib/small/_fs2uint.asm new file mode 100644 index 00000000..77576ede --- /dev/null +++ b/device/lib/small/_fs2uint.asm @@ -0,0 +1,248 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:10 2000 + +;-------------------------------------------------------- + .module _fs2uint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2uint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fs2uint_fl1_1_1: + .ds 0x0004 +___fs2uint_exp_1_1: + .ds 0x0002 +___fs2uint_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2uint$0$0 ==. +; _fs2uint.c 73 +; ----------------------------------------- +; function __fs2uint +; ----------------------------------------- +___fs2uint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2uint.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fs2uint.c 79 + mov ___fs2uint_fl1_1_1,r2 + mov (___fs2uint_fl1_1_1 + 1),r3 + mov (___fs2uint_fl1_1_1 + 2),r4 + mov (___fs2uint_fl1_1_1 + 3),r5 +; _fs2uint.c 81 + mov a,___fs2uint_fl1_1_1 + orl a,(___fs2uint_fl1_1_1 + 1) + orl a,(___fs2uint_fl1_1_1 + 2) + orl a,(___fs2uint_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2uint.c 82 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00110$ +00102$: +; _fs2uint.c 84 + mov r2,(___fs2uint_fl1_1_1 + 2) + mov a,(___fs2uint_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov ___fs2uint_exp_1_1,a + mov a,b + addc a,#0xff + mov (___fs2uint_exp_1_1 + 1),a +; _fs2uint.c 85 + mov r2,___fs2uint_fl1_1_1 + mov r3,(___fs2uint_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fs2uint_fl1_1_1 + 2) + mov r6,a + mov r7,#0x00 + mov ___fs2uint_l_1_1,r2 + mov (___fs2uint_l_1_1 + 1),r3 + mov a,#0x80 + orl a,r6 + mov (___fs2uint_l_1_1 + 2),a + mov (___fs2uint_l_1_1 + 3),r7 +; _fs2uint.c 87 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,___fs2uint_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,(___fs2uint_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2uint.c 88 + mov a,(___fs2uint_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov dpl,r2 + mov dph,#0x00 + ljmp 00110$ +00104$: +; _fs2uint.c 91 + mov a,(___fs2uint_exp_1_1 + 1) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00123$: + clr c + mov a,#0xe7 + subb a,___fs2uint_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,(___fs2uint_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00124$: + mov a,___fs2uint_l_1_1 + orl a,(___fs2uint_l_1_1 + 1) + orl a,(___fs2uint_l_1_1 + 2) + orl a,(___fs2uint_l_1_1 + 3) +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00125$: +; _fs2uint.c 92 + clr c + clr a + subb a,___fs2uint_exp_1_1 + mov r2,a + clr a + subb a,(___fs2uint_exp_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fs2uint_l_1_1 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2uint_l_1_1 + 3) + rrc a + mov (___fs2uint_l_1_1 + 3),a + mov a,(___fs2uint_l_1_1 + 2) + rrc a + mov (___fs2uint_l_1_1 + 2),a + mov a,(___fs2uint_l_1_1 + 1) + rrc a + mov (___fs2uint_l_1_1 + 1),a + mov a,___fs2uint_l_1_1 + rrc a + mov ___fs2uint_l_1_1,a +00127$: + djnz b,00126$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2uint.c 94 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00107$: +; _fs2uint.c 96 + mov a,(___fs2uint_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + clr c + clr a + subb a,___fs2uint_l_1_1 + mov r2,a + clr a + subb a,(___fs2uint_l_1_1 + 1) + mov r3,a + clr a + subb a,(___fs2uint_l_1_1 + 2) + mov r6,a + clr a + subb a,(___fs2uint_l_1_1 + 3) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov r2,___fs2uint_l_1_1 + mov r3,(___fs2uint_l_1_1 + 1) + mov r6,(___fs2uint_l_1_1 + 2) + mov r7,(___fs2uint_l_1_1 + 3) +00113$: + mov dpl,r2 + mov dph,r3 +00110$: + C$_fs2uint.c$97$1$1 ==. + XG$__fs2uint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fs2uint.cdb b/device/lib/small/_fs2uint.cdb new file mode 100644 index 00000000..52d12a6d --- /dev/null +++ b/device/lib/small/_fs2uint.cdb @@ -0,0 +1,2 @@ +M:_fs2uint +F:G$__fs2uint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_fs2uint.rel b/device/lib/small/_fs2uint.rel new file mode 100644 index 00000000..5868954f --- /dev/null +++ b/device/lib/small/_fs2uint.rel @@ -0,0 +1,266 @@ +;!FILE _fs2uint.asm +XH +H 9 areas 8D global symbols +M _fs2uint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size A flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size F8 flags 20 +S A$_fs2uint$94 Def0026 +S A$_fs2uint$67 Def0000 +S C$_fs2uint.c$97$1$1 Def00F7 +S A$_fs2uint$95 Def0027 +S A$_fs2uint$86 Def0019 +S A$_fs2uint$77 Def000F +S A$_fs2uint$68 Def0002 +S A$_fs2uint$96 Def0028 +S A$_fs2uint$87 Def001C +S A$_fs2uint$78 Def0011 +S A$_fs2uint$69 Def0004 +S A$_fs2uint$97 Def0029 +S A$_fs2uint$79 Def0013 +S A$_fs2uint$98 Def002A +S A$_fs2uint$99 Def002C +S A$_fs2uint$100 Def002F +S A$_fs2uint$200 Def00C4 +S A$_fs2uint$110 Def003D +S A$_fs2uint$210 Def00CE +S A$_fs2uint$120 Def004E +S A$_fs2uint$111 Def003F +S A$_fs2uint$102 Def0031 +S A$_fs2uint$202 Def00C6 +S A$_fs2uint$130 Def005C +S A$_fs2uint$121 Def0050 +S A$_fs2uint$112 Def0041 +S A$_fs2uint$103 Def0032 +S A$_fs2uint$230 Def00E4 +S A$_fs2uint$221 Def00D8 +S A$_fs2uint$131 Def005D +S A$_fs2uint$122 Def0052 +S A$_fs2uint$113 Def0043 +S A$_fs2uint$104 Def0033 +S ___fs2uint Def0000 +S A$_fs2uint$240 Def00F1 +S A$_fs2uint$231 Def00E5 +S A$_fs2uint$222 Def00D9 +S A$_fs2uint$213 Def00D0 +S A$_fs2uint$204 Def00C9 +S A$_fs2uint$141 Def006B +S A$_fs2uint$123 Def0054 +S A$_fs2uint$105 Def0035 +S A$_fs2uint$232 Def00E6 +S A$_fs2uint$223 Def00DA +S A$_fs2uint$214 Def00D2 +S A$_fs2uint$160 Def0088 +S A$_fs2uint$151 Def007C +S A$_fs2uint$142 Def006D +S A$_fs2uint$133 Def005F +S A$_fs2uint$124 Def0056 +S A$_fs2uint$115 Def0045 +S A$_fs2uint$106 Def0036 +S A$_fs2uint$242 Def00F3 +S A$_fs2uint$233 Def00E8 +S A$_fs2uint$224 Def00DC +S A$_fs2uint$215 Def00D3 +S A$_fs2uint$161 Def008B +S A$_fs2uint$143 Def006E +S A$_fs2uint$134 Def0061 +S A$_fs2uint$125 Def0057 +S A$_fs2uint$116 Def0047 +S A$_fs2uint$107 Def0037 +S A$_fs2uint$243 Def00F5 +S A$_fs2uint$225 Def00DD +S A$_fs2uint$180 Def00A4 +S A$_fs2uint$171 Def009A +S A$_fs2uint$162 Def008E +S A$_fs2uint$153 Def007E +S A$_fs2uint$144 Def0070 +S A$_fs2uint$135 Def0064 +S A$_fs2uint$126 Def0059 +S A$_fs2uint$117 Def0049 +S A$_fs2uint$108 Def0038 +S A$_fs2uint$235 Def00E9 +S A$_fs2uint$226 Def00DE +S A$_fs2uint$217 Def00D5 +S A$_fs2uint$208 Def00CB +S A$_fs2uint$190 Def00B4 +S A$_fs2uint$181 Def00A5 +S A$_fs2uint$145 Def0071 +S A$_fs2uint$136 Def0067 +S A$_fs2uint$118 Def004B +S A$_fs2uint$109 Def003B +S A$_fs2uint$227 Def00E0 +S A$_fs2uint$191 Def00B5 +S A$_fs2uint$182 Def00A7 +S A$_fs2uint$164 Def0090 +S A$_fs2uint$155 Def0081 +S A$_fs2uint$146 Def0074 +S A$_fs2uint$128 Def005B +S A$_fs2uint$119 Def004D +S A$_fs2uint$237 Def00EB +S A$_fs2uint$228 Def00E1 +S A$_fs2uint$219 Def00D6 +S A$_fs2uint$192 Def00B7 +S A$_fs2uint$183 Def00A9 +S A$_fs2uint$174 Def009C +S A$_fs2uint$156 Def0082 +S A$_fs2uint$147 Def0076 +S A$_fs2uint$138 Def0069 +S A$_fs2uint$247 Def00F7 +S A$_fs2uint$238 Def00ED +S A$_fs2uint$229 Def00E2 +S A$_fs2uint$193 Def00B9 +S A$_fs2uint$184 Def00AB +S A$_fs2uint$175 Def009D +S A$_fs2uint$166 Def0092 +S A$_fs2uint$157 Def0084 +S A$_fs2uint$148 Def0079 +S A$_fs2uint$239 Def00EF +S A$_fs2uint$194 Def00BA +S A$_fs2uint$185 Def00AC +S A$_fs2uint$176 Def009E +S A$_fs2uint$167 Def0094 +S A$_fs2uint$195 Def00BC +S A$_fs2uint$186 Def00AE +S A$_fs2uint$177 Def00A0 +S A$_fs2uint$168 Def0096 +S A$_fs2uint$159 Def0086 +S A$_fs2uint$196 Def00BE +S A$_fs2uint$178 Def00A1 +S A$_fs2uint$169 Def0098 +S A$_fs2uint$197 Def00BF +S A$_fs2uint$188 Def00B0 +S A$_fs2uint$179 Def00A2 +S XG$__fs2uint$0$0 Def00F7 +S A$_fs2uint$198 Def00C1 +S A$_fs2uint$189 Def00B2 +S A$_fs2uint$199 Def00C3 +S A$_fs2uint$70 Def0006 +S A$_fs2uint$80 Def0015 +S A$_fs2uint$90 Def001F +S A$_fs2uint$72 Def0007 +S G$__fs2uint$0$0 Def0000 +S A$_fs2uint$91 Def0021 +S A$_fs2uint$82 Def0017 +S A$_fs2uint$73 Def0009 +S A$_fs2uint$92 Def0023 +S A$_fs2uint$74 Def000B +S A$_fs2uint$93 Def0025 +S A$_fs2uint$75 Def000D +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 00 8B 00 01 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 02 8D 00 03 E5 00 00 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 12 00 01 45 00 02 45 00 03 70 06 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 19 +R 00 00 00 08 +T 00 19 90 00 00 02 00 F7 +R 00 00 00 08 00 06 00 08 +T 00 1F +R 00 00 00 08 +T 00 1F AA 00 02 E5 00 03 A2 E7 CA 33 CA 33 CA 54 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 2B 01 30 E0 02 44 FE +R 00 00 00 08 +T 00 31 +R 00 00 00 08 +T 00 31 FB 33 95 E0 FC FD EA 75 F0 00 24 6A F5 +R 00 00 00 08 +T 00 3E 00 04 E5 F0 34 FF F5 00 05 AA 00 00 AB +R 00 00 00 08 29 02 00 03 29 09 00 03 29 0C 00 03 +T 00 48 00 01 74 7F 55 00 02 FE 7F 00 8A 00 06 8B +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0D 00 03 +T 00 53 00 07 74 80 4E F5 00 08 8F 00 09 C3 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 5E 00 04 74 80 85 00 05 F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6A 11 +R 00 00 00 08 +T 00 6B +R 00 00 00 08 +T 00 6B E5 00 03 23 54 01 FA 43 02 7F 8A 82 75 83 +R 00 00 00 08 29 03 00 03 +T 00 78 00 02 00 F7 +R 00 00 00 08 00 04 00 08 +T 00 7C +R 00 00 00 08 +T 00 7C E5 00 05 30 E7 4A +R 00 00 00 08 29 03 00 03 +T 00 81 +R 00 00 00 08 +T 00 81 C3 74 E7 95 00 04 74 7F 85 00 05 F0 63 F0 +R 00 00 00 08 29 06 00 03 29 0B 00 03 +T 00 8D 80 95 F0 50 39 +R 00 00 00 08 +T 00 92 +R 00 00 00 08 +T 00 92 E5 00 06 45 00 07 45 00 08 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 99 00 09 60 2F +R 00 00 00 08 29 02 00 03 +T 00 9C +R 00 00 00 08 +T 00 9C C3 E4 95 00 04 FA E4 95 00 05 FB 8A F0 05 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 A8 F0 E5 00 09 33 92 D2 80 16 +R 00 00 00 08 29 04 00 03 +T 00 B0 +R 00 00 00 08 +T 00 B0 A2 D2 E5 00 09 13 F5 00 09 E5 00 08 13 F5 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0C 00 03 +T 00 BB 00 08 E5 00 07 13 F5 00 07 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 C2 00 06 13 F5 00 06 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 C6 +R 00 00 00 08 +T 00 C6 D5 F0 E7 80 05 +R 00 00 00 08 +T 00 CB +R 00 00 00 08 +T 00 CB 90 00 00 80 27 +R 00 00 00 08 +T 00 D0 +R 00 00 00 08 +T 00 D0 E5 00 03 23 54 01 FA 60 13 +R 00 00 00 08 29 03 00 03 +T 00 D8 +R 00 00 00 08 +T 00 D8 C3 E4 95 00 06 FA E4 95 00 07 FB E4 95 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 E3 00 08 FE E4 95 00 09 FF 80 08 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 EB +R 00 00 00 08 +T 00 EB AA 00 06 AB 00 07 AE 00 08 AF +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 F2 00 09 +R 00 00 00 08 29 02 00 03 +T 00 F3 +R 00 00 00 08 +T 00 F3 8A 82 8B 83 +R 00 00 00 08 +T 00 F7 +R 00 00 00 08 +T 00 F7 22 +R 00 00 00 08 diff --git a/device/lib/small/_fs2ulong.asm b/device/lib/small/_fs2ulong.asm new file mode 100644 index 00000000..8d686bec --- /dev/null +++ b/device/lib/small/_fs2ulong.asm @@ -0,0 +1,264 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:10 2000 + +;-------------------------------------------------------- + .module _fs2ulong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fs2ulong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fs2ulong_fl1_1_1: + .ds 0x0004 +___fs2ulong_exp_1_1: + .ds 0x0002 +___fs2ulong_l_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fs2ulong$0$0 ==. +; _fs2ulong.c 73 +; ----------------------------------------- +; function __fs2ulong +; ----------------------------------------- +___fs2ulong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fs2ulong.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fs2ulong.c 79 + mov ___fs2ulong_fl1_1_1,r2 + mov (___fs2ulong_fl1_1_1 + 1),r3 + mov (___fs2ulong_fl1_1_1 + 2),r4 + mov (___fs2ulong_fl1_1_1 + 3),r5 +; _fs2ulong.c 81 + mov a,___fs2ulong_fl1_1_1 + orl a,(___fs2ulong_fl1_1_1 + 1) + orl a,(___fs2ulong_fl1_1_1 + 2) + orl a,(___fs2ulong_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00120$: +; _fs2ulong.c 82 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00110$ +00102$: +; _fs2ulong.c 84 + mov r2,(___fs2ulong_fl1_1_1 + 2) + mov a,(___fs2ulong_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov a,r2 + mov b,#0x00 + add a,#0x6a + mov ___fs2ulong_exp_1_1,a + mov a,b + addc a,#0xff + mov (___fs2ulong_exp_1_1 + 1),a +; _fs2ulong.c 85 + mov r2,___fs2ulong_fl1_1_1 + mov r3,(___fs2ulong_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fs2ulong_fl1_1_1 + 2) + mov r6,a + mov r7,#0x00 + mov ___fs2ulong_l_1_1,r2 + mov (___fs2ulong_l_1_1 + 1),r3 + mov a,#0x80 + orl a,r6 + mov (___fs2ulong_l_1_1 + 2),a + mov (___fs2ulong_l_1_1 + 3),r7 +; _fs2ulong.c 87 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,___fs2ulong_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,(___fs2ulong_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00122$: +; _fs2ulong.c 88 + mov a,(___fs2ulong_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + orl ar2,#0x7f + mov dpl,r2 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dph,a + mov b,a + ljmp 00110$ +00104$: +; _fs2ulong.c 91 + mov a,(___fs2ulong_exp_1_1 + 1) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00106$ +00123$: + clr c + mov a,#0xe7 + subb a,___fs2ulong_exp_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0xff ^ 0x80) + mov b,(___fs2ulong_exp_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00124$: + mov a,___fs2ulong_l_1_1 + orl a,(___fs2ulong_l_1_1 + 1) + orl a,(___fs2ulong_l_1_1 + 2) + orl a,(___fs2ulong_l_1_1 + 3) +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00125$: +; _fs2ulong.c 92 + clr c + clr a + subb a,___fs2ulong_exp_1_1 + mov r2,a + clr a + subb a,(___fs2ulong_exp_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fs2ulong_l_1_1 + 3) + rlc a + mov ov,c + sjmp 00127$ +00126$: + mov c,ov + mov a,(___fs2ulong_l_1_1 + 3) + rrc a + mov (___fs2ulong_l_1_1 + 3),a + mov a,(___fs2ulong_l_1_1 + 2) + rrc a + mov (___fs2ulong_l_1_1 + 2),a + mov a,(___fs2ulong_l_1_1 + 1) + rrc a + mov (___fs2ulong_l_1_1 + 1),a + mov a,___fs2ulong_l_1_1 + rrc a + mov ___fs2ulong_l_1_1,a +00127$: + djnz b,00126$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _fs2ulong.c 94 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00107$: +; _fs2ulong.c 96 + mov a,(___fs2ulong_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00128$: + clr c + clr a + subb a,___fs2ulong_l_1_1 + mov r2,a + clr a + subb a,(___fs2ulong_l_1_1 + 1) + mov r3,a + clr a + subb a,(___fs2ulong_l_1_1 + 2) + mov r6,a + clr a + subb a,(___fs2ulong_l_1_1 + 3) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00112$: + mov r2,___fs2ulong_l_1_1 + mov r3,(___fs2ulong_l_1_1 + 1) + mov r6,(___fs2ulong_l_1_1 + 2) + mov r7,(___fs2ulong_l_1_1 + 3) +00113$: + mov dpl,r2 + mov dph,r3 + mov b,r6 + mov a,r7 +00110$: + C$_fs2ulong.c$97$1$1 ==. + XG$__fs2ulong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fs2ulong.cdb b/device/lib/small/_fs2ulong.cdb new file mode 100644 index 00000000..e579f516 --- /dev/null +++ b/device/lib/small/_fs2ulong.cdb @@ -0,0 +1,2 @@ +M:_fs2ulong +F:G$__fs2ulong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_fs2ulong.rel b/device/lib/small/_fs2ulong.rel new file mode 100644 index 00000000..8fd2de1c --- /dev/null +++ b/device/lib/small/_fs2ulong.rel @@ -0,0 +1,276 @@ +;!FILE _fs2ulong.asm +XH +H 9 areas 97 global symbols +M _fs2ulong +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size A flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 105 flags 20 +S A$_fs2ulong$100 Def002B +S A$_fs2ulong$200 Def00BB +S A$_fs2ulong$110 Def0039 +S A$_fs2ulong$101 Def002C +S A$_fs2ulong$201 Def00BD +S A$_fs2ulong$120 Def0049 +S A$_fs2ulong$111 Def003A +S A$_fs2ulong$102 Def002D +S A$_fs2ulong$220 Def00D2 +S A$_fs2ulong$211 Def00CC +S A$_fs2ulong$202 Def00BF +S A$_fs2ulong$130 Def005B +S A$_fs2ulong$121 Def004B +S A$_fs2ulong$112 Def003B +S A$_fs2ulong$103 Def002E +S A$_fs2ulong$221 Def00D4 +S A$_fs2ulong$203 Def00C0 +S A$_fs2ulong$140 Def0068 +S A$_fs2ulong$131 Def005D +S A$_fs2ulong$122 Def004D +S A$_fs2ulong$113 Def003C +S A$_fs2ulong$104 Def0030 +S ___fs2ulong Def0000 +S A$_fs2ulong$240 Def00E8 +S A$_fs2ulong$231 Def00DF +S A$_fs2ulong$222 Def00D6 +S A$_fs2ulong$213 Def00CF +S A$_fs2ulong$204 Def00C2 +S A$_fs2ulong$150 Def0075 +S A$_fs2ulong$141 Def006B +S A$_fs2ulong$123 Def004F +S A$_fs2ulong$114 Def003F +S A$_fs2ulong$105 Def0033 +S A$_fs2ulong$241 Def00EA +S A$_fs2ulong$205 Def00C4 +S A$_fs2ulong$160 Def0082 +S A$_fs2ulong$151 Def0078 +S A$_fs2ulong$133 Def005F +S A$_fs2ulong$124 Def0051 +S A$_fs2ulong$115 Def0041 +S A$_fs2ulong$251 Def00F5 +S A$_fs2ulong$242 Def00EB +S A$_fs2ulong$233 Def00E0 +S A$_fs2ulong$224 Def00D8 +S A$_fs2ulong$206 Def00C5 +S A$_fs2ulong$170 Def0091 +S A$_fs2ulong$143 Def006D +S A$_fs2ulong$125 Def0052 +S A$_fs2ulong$116 Def0043 +S A$_fs2ulong$107 Def0035 +S A$_fs2ulong$252 Def00F7 +S A$_fs2ulong$243 Def00EC +S A$_fs2ulong$207 Def00C7 +S A$_fs2ulong$180 Def00A0 +S A$_fs2ulong$171 Def0094 +S A$_fs2ulong$162 Def0084 +S A$_fs2ulong$135 Def0060 +S A$_fs2ulong$126 Def0054 +S A$_fs2ulong$117 Def0045 +S A$_fs2ulong$108 Def0036 +S A$_fs2ulong$253 Def00F9 +S A$_fs2ulong$244 Def00EE +S A$_fs2ulong$235 Def00E2 +S A$_fs2ulong$208 Def00C9 +S A$_fs2ulong$190 Def00AB +S A$_fs2ulong$154 Def007A +S A$_fs2ulong$136 Def0061 +S A$_fs2ulong$127 Def0056 +S A$_fs2ulong$118 Def0047 +S A$_fs2ulong$109 Def0037 +S A$_fs2ulong$263 Def0104 +S A$_fs2ulong$254 Def00FB +S A$_fs2ulong$245 Def00EF +S A$_fs2ulong$236 Def00E3 +S A$_fs2ulong$227 Def00DA +S A$_fs2ulong$209 Def00CA +S A$_fs2ulong$191 Def00AD +S A$_fs2ulong$173 Def0096 +S A$_fs2ulong$164 Def0087 +S A$_fs2ulong$155 Def007B +S A$_fs2ulong$146 Def006F +S A$_fs2ulong$128 Def0058 +S A$_fs2ulong$246 Def00F0 +S A$_fs2ulong$237 Def00E4 +S A$_fs2ulong$228 Def00DC +S A$_fs2ulong$219 Def00D1 +S A$_fs2ulong$192 Def00AF +S A$_fs2ulong$183 Def00A2 +S A$_fs2ulong$165 Def0088 +S A$_fs2ulong$156 Def007D +S A$_fs2ulong$147 Def0071 +S A$_fs2ulong$138 Def0063 +S A$_fs2ulong$129 Def005A +S A$_fs2ulong$256 Def00FD +S A$_fs2ulong$247 Def00F2 +S A$_fs2ulong$238 Def00E6 +S A$_fs2ulong$229 Def00DD +S A$_fs2ulong$193 Def00B1 +S A$_fs2ulong$184 Def00A3 +S A$_fs2ulong$175 Def0098 +S A$_fs2ulong$166 Def008A +S A$_fs2ulong$157 Def007F +S A$_fs2ulong$148 Def0072 +S A$_fs2ulong$139 Def0065 +S A$_fs2ulong$257 Def00FF +S A$_fs2ulong$239 Def00E7 +S A$_fs2ulong$194 Def00B2 +S A$_fs2ulong$185 Def00A4 +S A$_fs2ulong$176 Def009A +S A$_fs2ulong$149 Def0074 +S A$_fs2ulong$258 Def0101 +S A$_fs2ulong$249 Def00F3 +S A$_fs2ulong$195 Def00B4 +S A$_fs2ulong$186 Def00A6 +S A$_fs2ulong$177 Def009C +S A$_fs2ulong$168 Def008C +S A$_fs2ulong$259 Def0103 +S A$_fs2ulong$187 Def00A7 +S A$_fs2ulong$178 Def009E +S A$_fs2ulong$169 Def008E +S A$_fs2ulong$197 Def00B6 +S A$_fs2ulong$188 Def00A8 +S XG$__fs2ulong$0$0 Def0104 +S A$_fs2ulong$198 Def00B8 +S A$_fs2ulong$189 Def00AA +S A$_fs2ulong$199 Def00BA +S A$_fs2ulong$70 Def0006 +S A$_fs2ulong$80 Def0015 +S A$_fs2ulong$90 Def001C +S A$_fs2ulong$72 Def0007 +S G$__fs2ulong$0$0 Def0000 +S A$_fs2ulong$91 Def001E +S A$_fs2ulong$82 Def0017 +S A$_fs2ulong$73 Def0009 +S A$_fs2ulong$92 Def0020 +S A$_fs2ulong$74 Def000B +S A$_fs2ulong$75 Def000D +S A$_fs2ulong$67 Def0000 +S C$_fs2ulong.c$97$1$1 Def0104 +S A$_fs2ulong$95 Def0023 +S A$_fs2ulong$77 Def000F +S A$_fs2ulong$68 Def0002 +S A$_fs2ulong$96 Def0025 +S A$_fs2ulong$78 Def0011 +S A$_fs2ulong$69 Def0004 +S A$_fs2ulong$97 Def0027 +S A$_fs2ulong$88 Def0019 +S A$_fs2ulong$79 Def0013 +S A$_fs2ulong$98 Def0029 +S A$_fs2ulong$89 Def001A +S A$_fs2ulong$99 Def002A +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 00 8B 00 01 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 02 8D 00 03 E5 00 00 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 12 00 01 45 00 02 45 00 03 70 0A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 19 +R 00 00 00 08 +T 00 19 E4 F5 82 F5 83 F5 F0 02 01 04 +R 00 00 00 08 00 0A 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 AA 00 02 E5 00 03 A2 E7 CA 33 CA 33 CA 54 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 2F 01 30 E0 02 44 FE +R 00 00 00 08 +T 00 35 +R 00 00 00 08 +T 00 35 FB 33 95 E0 FC FD EA 75 F0 00 24 6A F5 +R 00 00 00 08 +T 00 42 00 04 E5 F0 34 FF F5 00 05 AA 00 00 AB +R 00 00 00 08 29 02 00 03 29 09 00 03 29 0C 00 03 +T 00 4C 00 01 74 7F 55 00 02 FE 7F 00 8A 00 06 8B +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0D 00 03 +T 00 57 00 07 74 80 4E F5 00 08 8F 00 09 C3 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 62 00 04 74 80 85 00 05 F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6E 13 +R 00 00 00 08 +T 00 6F +R 00 00 00 08 +T 00 6F E5 00 03 23 54 01 FA 43 02 7F 8A 82 E4 F5 +R 00 00 00 08 29 03 00 03 +T 00 7C 83 F5 F0 02 01 04 +R 00 00 00 08 00 06 00 08 +T 00 82 +R 00 00 00 08 +T 00 82 E5 00 05 30 E7 4A +R 00 00 00 08 29 03 00 03 +T 00 87 +R 00 00 00 08 +T 00 87 C3 74 E7 95 00 04 74 7F 85 00 05 F0 63 F0 +R 00 00 00 08 29 06 00 03 29 0B 00 03 +T 00 93 80 95 F0 50 39 +R 00 00 00 08 +T 00 98 +R 00 00 00 08 +T 00 98 E5 00 06 45 00 07 45 00 08 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 9F 00 09 60 2F +R 00 00 00 08 29 02 00 03 +T 00 A2 +R 00 00 00 08 +T 00 A2 C3 E4 95 00 04 FA E4 95 00 05 FB 8A F0 05 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 AE F0 E5 00 09 33 92 D2 80 16 +R 00 00 00 08 29 04 00 03 +T 00 B6 +R 00 00 00 08 +T 00 B6 A2 D2 E5 00 09 13 F5 00 09 E5 00 08 13 F5 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0C 00 03 +T 00 C1 00 08 E5 00 07 13 F5 00 07 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 C8 00 06 13 F5 00 06 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 CC +R 00 00 00 08 +T 00 CC D5 F0 E7 80 09 +R 00 00 00 08 +T 00 D1 +R 00 00 00 08 +T 00 D1 E4 F5 82 F5 83 F5 F0 80 2A +R 00 00 00 08 +T 00 DA +R 00 00 00 08 +T 00 DA E5 00 03 23 54 01 FA 60 13 +R 00 00 00 08 29 03 00 03 +T 00 E2 +R 00 00 00 08 +T 00 E2 C3 E4 95 00 06 FA E4 95 00 07 FB E4 95 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 ED 00 08 FE E4 95 00 09 FF 80 08 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 F5 +R 00 00 00 08 +T 00 F5 AA 00 06 AB 00 07 AE 00 08 AF +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 FC 00 09 +R 00 00 00 08 29 02 00 03 +T 00 FD +R 00 00 00 08 +T 00 FD 8A 82 8B 83 8E F0 EF +R 00 00 00 08 +T 01 04 +R 00 00 00 08 +T 01 04 22 +R 00 00 00 08 diff --git a/device/lib/small/_fsadd.asm b/device/lib/small/_fsadd.asm new file mode 100644 index 00000000..00ad5e63 --- /dev/null +++ b/device/lib/small/_fsadd.asm @@ -0,0 +1,736 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:11 2000 + +;-------------------------------------------------------- + .module _fsadd +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsadd_PARM_2 + .globl ___fsadd +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsadd_PARM_2: + .ds 0x0004 +___fsadd_mant1_1_1: + .ds 0x0004 +___fsadd_mant2_1_1: + .ds 0x0004 +___fsadd_fl1_1_1: + .ds 0x0004 +___fsadd_fl2_1_1: + .ds 0x0004 +___fsadd_exp1_1_1: + .ds 0x0002 +___fsadd_exp2_1_1: + .ds 0x0002 +___fsadd_sign_1_1: + .ds 0x0004 +___fsadd_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsadd$0$0 ==. +; _fsadd.c 17 +; ----------------------------------------- +; function __fsadd +; ----------------------------------------- +___fsadd: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsadd.c 101 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fsadd.c 22 + clr a + mov (___fsadd_sign_1_1 + 3),a + mov (___fsadd_sign_1_1 + 2),a + mov (___fsadd_sign_1_1 + 1),a + mov ___fsadd_sign_1_1,a +; _fsadd.c 24 + mov ___fsadd_fl1_1_1,r2 + mov (___fsadd_fl1_1_1 + 1),r3 + mov (___fsadd_fl1_1_1 + 2),r4 + mov (___fsadd_fl1_1_1 + 3),r5 +; _fsadd.c 25 + mov ___fsadd_fl2_1_1,___fsadd_PARM_2 + mov (___fsadd_fl2_1_1 + 1),(___fsadd_PARM_2 + 1) + mov (___fsadd_fl2_1_1 + 2),(___fsadd_PARM_2 + 2) + mov (___fsadd_fl2_1_1 + 3),(___fsadd_PARM_2 + 3) +; _fsadd.c 28 + mov a,___fsadd_fl1_1_1 + orl a,(___fsadd_fl1_1_1 + 1) + orl a,(___fsadd_fl1_1_1 + 2) + orl a,(___fsadd_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00146$: +; _fsadd.c 29 + mov dpl,___fsadd_fl2_1_1 + mov dph,(___fsadd_fl2_1_1 + 1) + mov b,(___fsadd_fl2_1_1 + 2) + mov a,(___fsadd_fl2_1_1 + 3) + ljmp 00128$ +00102$: +; _fsadd.c 30 + mov a,___fsadd_fl2_1_1 + orl a,(___fsadd_fl2_1_1 + 1) + orl a,(___fsadd_fl2_1_1 + 2) + orl a,(___fsadd_fl2_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00147$: +; _fsadd.c 31 + mov dpl,___fsadd_fl1_1_1 + mov dph,(___fsadd_fl1_1_1 + 1) + mov b,(___fsadd_fl1_1_1 + 2) + mov a,(___fsadd_fl1_1_1 + 3) + ljmp 00128$ +00104$: +; _fsadd.c 33 + mov r2,(___fsadd_fl1_1_1 + 2) + mov a,(___fsadd_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00148$ + orl a,#0xfe +00148$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov ___fsadd_exp1_1_1,r2 + mov (___fsadd_exp1_1_1 + 1),#0x00 +; _fsadd.c 34 + mov r2,(___fsadd_fl2_1_1 + 2) + mov a,(___fsadd_fl2_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00149$ + orl a,#0xfe +00149$: + mov r3,a + rlc a + subb a,acc + mov r6,a + mov r7,a + mov ___fsadd_exp2_1_1,r2 + mov (___fsadd_exp2_1_1 + 1),#0x00 +; _fsadd.c 36 + mov a,#0x19 + add a,___fsadd_exp2_1_1 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsadd_exp2_1_1 + 1) + mov r3,a + clr c + mov a,r2 + subb a,___fsadd_exp1_1_1 + mov a,r3 + xrl a,#0x80 + mov b,(___fsadd_exp1_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00150$: +; _fsadd.c 37 + mov dpl,___fsadd_fl1_1_1 + mov dph,(___fsadd_fl1_1_1 + 1) + mov b,(___fsadd_fl1_1_1 + 2) + mov a,(___fsadd_fl1_1_1 + 3) + lcall ___long2fs + mov r2,dpl + mov r3,dph + mov r0,b +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r2 + mov dph,r3 + mov b,r0 + ljmp 00128$ +00106$: +; _fsadd.c 38 + mov a,#0x19 + add a,___fsadd_exp1_1_1 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsadd_exp1_1_1 + 1) + mov r3,a + clr c + mov a,r2 + subb a,___fsadd_exp2_1_1 + mov a,r3 + xrl a,#0x80 + mov b,(___fsadd_exp2_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00108$ +00151$: +; _fsadd.c 39 + mov dpl,___fsadd_fl2_1_1 + mov dph,(___fsadd_fl2_1_1 + 1) + mov b,(___fsadd_fl2_1_1 + 2) + mov a,(___fsadd_fl2_1_1 + 3) + lcall ___long2fs + mov r2,dpl + mov r3,dph + mov r0,b +; Peephole 191 removed redundant mov + mov r1,a + mov dpl,r2 + mov dph,r3 + mov b,r0 + ljmp 00128$ +00108$: +; _fsadd.c 42 + mov r2,___fsadd_fl1_1_1 + mov r3,(___fsadd_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fsadd_fl1_1_1 + 2) + mov r0,a + mov r1,#0x00 + orl ar0,#0x80 + mov (___fsadd_mant1_1_1 + 2),r0 + mov a,r1 + anl a,#0x03 + mov c,acc.0 + xch a,(___fsadd_mant1_1_1 + 2) + rrc a + xch a,(___fsadd_mant1_1_1 + 2) + rrc a + xch a,(___fsadd_mant1_1_1 + 2) + rrc a + xch a,(___fsadd_mant1_1_1 + 2) + rrc a + xch a,(___fsadd_mant1_1_1 + 2) + mov (___fsadd_mant1_1_1 + 3),a + mov a,r3 + rr a + rr a + anl a,#0x3f + orl a,(___fsadd_mant1_1_1 + 2) + mov (___fsadd_mant1_1_1 + 2),a + mov ___fsadd_mant1_1_1,r2 + mov a,r3 + anl a,#0x03 + mov c,acc.0 + xch a,___fsadd_mant1_1_1 + rrc a + xch a,___fsadd_mant1_1_1 + rrc a + xch a,___fsadd_mant1_1_1 + rrc a + xch a,___fsadd_mant1_1_1 + rrc a + xch a,___fsadd_mant1_1_1 + mov (___fsadd_mant1_1_1 + 1),a +; _fsadd.c 43 + mov r2,___fsadd_fl2_1_1 + mov r3,(___fsadd_fl2_1_1 + 1) + mov a,#0x7f + anl a,(___fsadd_fl2_1_1 + 2) + mov r0,a + mov r1,#0x00 + orl ar0,#0x80 + mov (___fsadd_mant2_1_1 + 2),r0 + mov a,r1 + anl a,#0x03 + mov c,acc.0 + xch a,(___fsadd_mant2_1_1 + 2) + rrc a + xch a,(___fsadd_mant2_1_1 + 2) + rrc a + xch a,(___fsadd_mant2_1_1 + 2) + rrc a + xch a,(___fsadd_mant2_1_1 + 2) + rrc a + xch a,(___fsadd_mant2_1_1 + 2) + mov (___fsadd_mant2_1_1 + 3),a + mov a,r3 + rr a + rr a + anl a,#0x3f + orl a,(___fsadd_mant2_1_1 + 2) + mov (___fsadd_mant2_1_1 + 2),a + mov ___fsadd_mant2_1_1,r2 + mov a,r3 + anl a,#0x03 + mov c,acc.0 + xch a,___fsadd_mant2_1_1 + rrc a + xch a,___fsadd_mant2_1_1 + rrc a + xch a,___fsadd_mant2_1_1 + rrc a + xch a,___fsadd_mant2_1_1 + rrc a + xch a,___fsadd_mant2_1_1 + mov (___fsadd_mant2_1_1 + 1),a +; _fsadd.c 45 + mov a,(___fsadd_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00110$ +00152$: +; _fsadd.c 46 + clr c + clr a + subb a,___fsadd_mant1_1_1 + mov ___fsadd_mant1_1_1,a + clr a + subb a,(___fsadd_mant1_1_1 + 1) + mov (___fsadd_mant1_1_1 + 1),a + clr a + subb a,(___fsadd_mant1_1_1 + 2) + mov (___fsadd_mant1_1_1 + 2),a + clr a + subb a,(___fsadd_mant1_1_1 + 3) + mov (___fsadd_mant1_1_1 + 3),a +00110$: +; _fsadd.c 47 + mov a,(___fsadd_fl2_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00112$ +00153$: +; _fsadd.c 48 + clr c + clr a + subb a,___fsadd_mant2_1_1 + mov ___fsadd_mant2_1_1,a + clr a + subb a,(___fsadd_mant2_1_1 + 1) + mov (___fsadd_mant2_1_1 + 1),a + clr a + subb a,(___fsadd_mant2_1_1 + 2) + mov (___fsadd_mant2_1_1 + 2),a + clr a + subb a,(___fsadd_mant2_1_1 + 3) + mov (___fsadd_mant2_1_1 + 3),a +00112$: +; _fsadd.c 50 + clr c + mov a,___fsadd_exp2_1_1 + subb a,___fsadd_exp1_1_1 + mov a,(___fsadd_exp2_1_1 + 1) + xrl a,#0x80 + mov b,(___fsadd_exp1_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00114$ +00154$: +; _fsadd.c 52 + clr c + mov a,___fsadd_exp1_1_1 + subb a,___fsadd_exp2_1_1 + mov r2,a + mov a,(___fsadd_exp1_1_1 + 1) + subb a,(___fsadd_exp2_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fsadd_mant2_1_1 + 3) + rlc a + mov ov,c + sjmp 00156$ +00155$: + mov c,ov + mov a,(___fsadd_mant2_1_1 + 3) + rrc a + mov (___fsadd_mant2_1_1 + 3),a + mov a,(___fsadd_mant2_1_1 + 2) + rrc a + mov (___fsadd_mant2_1_1 + 2),a + mov a,(___fsadd_mant2_1_1 + 1) + rrc a + mov (___fsadd_mant2_1_1 + 1),a + mov a,___fsadd_mant2_1_1 + rrc a + mov ___fsadd_mant2_1_1,a +00156$: + djnz b,00155$ +; Peephole 132 changed ljmp to sjmp + sjmp 00115$ +00114$: +; _fsadd.c 56 + clr c + mov a,___fsadd_exp2_1_1 + subb a,___fsadd_exp1_1_1 + mov r2,a + mov a,(___fsadd_exp2_1_1 + 1) + subb a,(___fsadd_exp1_1_1 + 1) + mov r3,a + mov b,r2 + inc b + mov a,(___fsadd_mant1_1_1 + 3) + rlc a + mov ov,c + sjmp 00158$ +00157$: + mov c,ov + mov a,(___fsadd_mant1_1_1 + 3) + rrc a + mov (___fsadd_mant1_1_1 + 3),a + mov a,(___fsadd_mant1_1_1 + 2) + rrc a + mov (___fsadd_mant1_1_1 + 2),a + mov a,(___fsadd_mant1_1_1 + 1) + rrc a + mov (___fsadd_mant1_1_1 + 1),a + mov a,___fsadd_mant1_1_1 + rrc a + mov ___fsadd_mant1_1_1,a +00158$: + djnz b,00157$ +; _fsadd.c 57 + mov ___fsadd_exp1_1_1,___fsadd_exp2_1_1 + mov (___fsadd_exp1_1_1 + 1),(___fsadd_exp2_1_1 + 1) +00115$: +; _fsadd.c 59 + mov a,___fsadd_mant2_1_1 + add a,___fsadd_mant1_1_1 + mov ___fsadd_mant1_1_1,a + mov a,(___fsadd_mant2_1_1 + 1) + addc a,(___fsadd_mant1_1_1 + 1) + mov (___fsadd_mant1_1_1 + 1),a + mov a,(___fsadd_mant2_1_1 + 2) + addc a,(___fsadd_mant1_1_1 + 2) + mov (___fsadd_mant1_1_1 + 2),a + mov a,(___fsadd_mant2_1_1 + 3) + addc a,(___fsadd_mant1_1_1 + 3) +; _fsadd.c 61 +; Peephole 105 removed redundant mov + mov (___fsadd_mant1_1_1 + 3),a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00119$ +00159$: +; _fsadd.c 63 + clr c + clr a + subb a,___fsadd_mant1_1_1 + mov ___fsadd_mant1_1_1,a + clr a + subb a,(___fsadd_mant1_1_1 + 1) + mov (___fsadd_mant1_1_1 + 1),a + clr a + subb a,(___fsadd_mant1_1_1 + 2) + mov (___fsadd_mant1_1_1 + 2),a + clr a + subb a,(___fsadd_mant1_1_1 + 3) + mov (___fsadd_mant1_1_1 + 3),a +; _fsadd.c 64 + mov ___fsadd_sign_1_1,#0x00 + mov (___fsadd_sign_1_1 + 1),#0x00 + mov (___fsadd_sign_1_1 + 2),#0x00 + mov (___fsadd_sign_1_1 + 3),#0x80 +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00119$: +; _fsadd.c 66 + mov a,___fsadd_mant1_1_1 + orl a,(___fsadd_mant1_1_1 + 1) + orl a,(___fsadd_mant1_1_1 + 2) + orl a,(___fsadd_mant1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00121$ +00160$: +; _fsadd.c 67 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00128$ +; _fsadd.c 70 +00121$: + mov r2,___fsadd_mant1_1_1 + mov r3,(___fsadd_mant1_1_1 + 1) + mov r0,(___fsadd_mant1_1_1 + 2) + mov r1,(___fsadd_mant1_1_1 + 3) + mov a,r1 + anl a,#0xe0 +; Peephole 162 removed sjmp by inverse jump logic + jz 00162$ +00161$: +; Peephole 132 changed ljmp to sjmp + sjmp 00123$ +00162$: +; _fsadd.c 72 + mov a,___fsadd_mant1_1_1 + add a,acc + mov ___fsadd_mant1_1_1,a + mov a,(___fsadd_mant1_1_1 + 1) + rlc a + mov (___fsadd_mant1_1_1 + 1),a + mov a,(___fsadd_mant1_1_1 + 2) + rlc a + mov (___fsadd_mant1_1_1 + 2),a + mov a,(___fsadd_mant1_1_1 + 3) + rlc a + mov (___fsadd_mant1_1_1 + 3),a +; _fsadd.c 73 + dec ___fsadd_exp1_1_1 + mov a,#0xff + cjne a,___fsadd_exp1_1_1,00163$ + dec (___fsadd_exp1_1_1 + 1) +00163$: +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00123$: +; _fsadd.c 77 + mov r2,___fsadd_mant1_1_1 + mov r3,(___fsadd_mant1_1_1 + 1) + mov r0,(___fsadd_mant1_1_1 + 2) + mov r1,(___fsadd_mant1_1_1 + 3) + mov a,r1 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.6,00125$ +00164$: +; _fsadd.c 79 + mov a,(___fsadd_mant1_1_1 + 3) + mov c,acc.7 + rrc a + mov (___fsadd_mant1_1_1 + 3),a + mov a,(___fsadd_mant1_1_1 + 2) + rrc a + mov (___fsadd_mant1_1_1 + 2),a + mov a,(___fsadd_mant1_1_1 + 1) + rrc a + mov (___fsadd_mant1_1_1 + 1),a + mov a,___fsadd_mant1_1_1 + rrc a + mov ___fsadd_mant1_1_1,a +; _fsadd.c 80 + inc ___fsadd_exp1_1_1 + clr a + cjne a,___fsadd_exp1_1_1,00165$ + inc (___fsadd_exp1_1_1 + 1) +00165$: +00125$: +; _fsadd.c 84 + mov r2,___fsadd_mant1_1_1 + mov r3,(___fsadd_mant1_1_1 + 1) + mov r0,(___fsadd_mant1_1_1 + 2) + mov r1,(___fsadd_mant1_1_1 + 3) + mov a,r2 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.6,00130$ +00166$: + mov r2,#0x20 + mov r3,#0x00 + mov r0,#0x00 + mov r1,#0x00 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00130$: + mov r2,#0x1f + mov r3,#0x00 + mov r0,#0x00 + mov r1,#0x00 +00131$: + mov a,r2 + add a,___fsadd_mant1_1_1 + mov ___fsadd_mant1_1_1,a + mov a,r3 + addc a,(___fsadd_mant1_1_1 + 1) + mov (___fsadd_mant1_1_1 + 1),a + mov a,r0 + addc a,(___fsadd_mant1_1_1 + 2) + mov (___fsadd_mant1_1_1 + 2),a + mov a,r1 + addc a,(___fsadd_mant1_1_1 + 3) + mov (___fsadd_mant1_1_1 + 3),a +; _fsadd.c 87 + mov r2,___fsadd_mant1_1_1 + mov r3,(___fsadd_mant1_1_1 + 1) + mov r0,(___fsadd_mant1_1_1 + 2) + mov r1,(___fsadd_mant1_1_1 + 3) + mov a,r1 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.6,00127$ +00167$: +; _fsadd.c 89 + mov a,(___fsadd_mant1_1_1 + 3) + mov c,acc.7 + rrc a + mov (___fsadd_mant1_1_1 + 3),a + mov a,(___fsadd_mant1_1_1 + 2) + rrc a + mov (___fsadd_mant1_1_1 + 2),a + mov a,(___fsadd_mant1_1_1 + 1) + rrc a + mov (___fsadd_mant1_1_1 + 1),a + mov a,___fsadd_mant1_1_1 + rrc a + mov ___fsadd_mant1_1_1,a +; _fsadd.c 90 + inc ___fsadd_exp1_1_1 + clr a + cjne a,___fsadd_exp1_1_1,00168$ + inc (___fsadd_exp1_1_1 + 1) +00168$: +00127$: +; _fsadd.c 94 + mov a,(___fsadd_mant1_1_1 + 1) + mov c,acc.7 + xch a,___fsadd_mant1_1_1 + rlc a + xch a,___fsadd_mant1_1_1 + rlc a + xch a,___fsadd_mant1_1_1 + rlc a + xch a,___fsadd_mant1_1_1 + rlc a + xch a,___fsadd_mant1_1_1 + anl a,#0x03 + mov (___fsadd_mant1_1_1 + 1),a + mov a,(___fsadd_mant1_1_1 + 2) + add a,acc + add a,acc + orl a,(___fsadd_mant1_1_1 + 1) + mov (___fsadd_mant1_1_1 + 1),a + mov a,(___fsadd_mant1_1_1 + 3) + mov c,acc.7 + xch a,(___fsadd_mant1_1_1 + 2) + rlc a + xch a,(___fsadd_mant1_1_1 + 2) + rlc a + xch a,(___fsadd_mant1_1_1 + 2) + rlc a + xch a,(___fsadd_mant1_1_1 + 2) + rlc a + xch a,(___fsadd_mant1_1_1 + 2) + anl a,#0x03 + jnb acc.1,00169$ + orl a,#0xfc +00169$: + mov (___fsadd_mant1_1_1 + 3),a +; _fsadd.c 97 + mov r2,___fsadd_mant1_1_1 + mov r3,(___fsadd_mant1_1_1 + 1) + mov r0,(___fsadd_mant1_1_1 + 2) + mov r1,(___fsadd_mant1_1_1 + 3) + mov ___fsadd_mant1_1_1,r2 + mov (___fsadd_mant1_1_1 + 1),r3 + mov a,#0x7f + anl a,r0 + mov (___fsadd_mant1_1_1 + 2),a + mov (___fsadd_mant1_1_1 + 3),r1 +; _fsadd.c 100 + mov r2,___fsadd_exp1_1_1 + mov r3,(___fsadd_exp1_1_1 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___fsadd_sloc0_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___fsadd_sloc0_1_0 + 2) + rrc a + xch a,(___fsadd_sloc0_1_0 + 2) + rrc a + xch a,(___fsadd_sloc0_1_0 + 2) + mov (___fsadd_sloc0_1_0 + 3),a + mov (___fsadd_sloc0_1_0 + 1),#0x00 + mov ___fsadd_sloc0_1_0,#0x00 + mov r2,___fsadd_sign_1_1 + mov r3,(___fsadd_sign_1_1 + 1) + mov r0,(___fsadd_sign_1_1 + 2) + mov r1,(___fsadd_sign_1_1 + 3) + mov a,r2 + orl ___fsadd_sloc0_1_0,a + mov a,r3 + orl (___fsadd_sloc0_1_0 + 1),a + mov a,r0 + orl (___fsadd_sloc0_1_0 + 2),a + mov a,r1 + orl (___fsadd_sloc0_1_0 + 3),a + mov r2,___fsadd_mant1_1_1 + mov r3,(___fsadd_mant1_1_1 + 1) + mov r0,(___fsadd_mant1_1_1 + 2) + mov r1,(___fsadd_mant1_1_1 + 3) + mov a,___fsadd_sloc0_1_0 + orl ar2,a + mov a,(___fsadd_sloc0_1_0 + 1) + orl ar3,a + mov a,(___fsadd_sloc0_1_0 + 2) + orl ar0,a + mov a,(___fsadd_sloc0_1_0 + 3) + orl ar1,a + mov ___fsadd_fl1_1_1,r2 + mov (___fsadd_fl1_1_1 + 1),r3 + mov (___fsadd_fl1_1_1 + 2),r0 + mov (___fsadd_fl1_1_1 + 3),r1 +; _fsadd.c 101 + mov dpl,___fsadd_fl1_1_1 + mov dph,(___fsadd_fl1_1_1 + 1) + mov b,(___fsadd_fl1_1_1 + 2) + mov a,(___fsadd_fl1_1_1 + 3) +00128$: + C$_fsadd.c$102$1$1 ==. + XG$__fsadd$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fsadd.cdb b/device/lib/small/_fsadd.cdb new file mode 100644 index 00000000..192532fc --- /dev/null +++ b/device/lib/small/_fsadd.cdb @@ -0,0 +1,2 @@ +M:_fsadd +F:G$__fsadd$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fsadd.rel b/device/lib/small/_fsadd.rel new file mode 100644 index 00000000..a028c459 --- /dev/null +++ b/device/lib/small/_fsadd.rel @@ -0,0 +1,934 @@ +;!FILE _fsadd.asm +XH +H 8 areas 226 global symbols +M _fsadd +S ___long2fs Ref0000 +A _CODE size 0 flags 0 +A DSEG size 20 flags 0 +S ___fsadd_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 3EF flags 20 +S C$_fsadd.c$102$1$1 Def03EE +S A$_fsadd$100 Def0024 +S A$_fsadd$200 Def00BF +S A$_fsadd$110 Def0034 +S A$_fsadd$101 Def0026 +S A$_fsadd$300 Def0163 +S A$_fsadd$210 Def00CC +S A$_fsadd$201 Def00C1 +S A$_fsadd$120 Def0044 +S A$_fsadd$111 Def0037 +S A$_fsadd$102 Def0028 +S A$_fsadd$400 Def01EF +S A$_fsadd$310 Def0173 +S A$_fsadd$301 Def0164 +S A$_fsadd$211 Def00CE +S A$_fsadd$202 Def00C3 +S A$_fsadd$130 Def0054 +S A$_fsadd$112 Def0039 +S A$_fsadd$103 Def002A +S A$_fsadd$410 Def01FF +S A$_fsadd$401 Def01F0 +S A$_fsadd$320 Def0183 +S A$_fsadd$311 Def0174 +S A$_fsadd$302 Def0166 +S A$_fsadd$230 Def00F0 +S A$_fsadd$221 Def00DE +S A$_fsadd$212 Def00CF +S A$_fsadd$140 Def0064 +S A$_fsadd$131 Def0056 +S ___fsadd Def0000 +S A$_fsadd$600 Def030E +S A$_fsadd$510 Def028F +S A$_fsadd$420 Def020B +S A$_fsadd$402 Def01F2 +S A$_fsadd$330 Def018E +S A$_fsadd$321 Def0184 +S A$_fsadd$312 Def0176 +S A$_fsadd$303 Def0168 +S A$_fsadd$240 Def00FE +S A$_fsadd$231 Def00F2 +S A$_fsadd$213 Def00D0 +S A$_fsadd$150 Def0071 +S A$_fsadd$132 Def0058 +S A$_fsadd$123 Def0046 +S A$_fsadd$105 Def002C +S A$_fsadd$700 Def03B1 +S A$_fsadd$610 Def031E +S A$_fsadd$601 Def030F +S A$_fsadd$511 Def0291 +S A$_fsadd$502 Def0283 +S A$_fsadd$421 Def020C +S A$_fsadd$412 Def0201 +S A$_fsadd$403 Def01F4 +S A$_fsadd$340 Def019B +S A$_fsadd$322 Def0186 +S A$_fsadd$313 Def0178 +S A$_fsadd$304 Def0169 +S A$_fsadd$250 Def0111 +S A$_fsadd$241 Def0100 +S A$_fsadd$214 Def00D1 +S A$_fsadd$205 Def00C6 +S A$_fsadd$160 Def0081 +S A$_fsadd$151 Def0073 +S A$_fsadd$142 Def0066 +S A$_fsadd$133 Def005A +S A$_fsadd$124 Def0049 +S A$_fsadd$115 Def003C +S A$_fsadd$710 Def03C1 +S A$_fsadd$701 Def03B3 +S A$_fsadd$620 Def032B +S A$_fsadd$611 Def0320 +S A$_fsadd$602 Def0311 +S A$_fsadd$530 Def02AA +S A$_fsadd$512 Def0293 +S A$_fsadd$503 Def0284 +S A$_fsadd$440 Def022B +S A$_fsadd$431 Def021C +S A$_fsadd$422 Def020E +S A$_fsadd$404 Def01F5 +S A$_fsadd$350 Def01A8 +S A$_fsadd$341 Def019C +S A$_fsadd$314 Def017A +S A$_fsadd$305 Def016A +S A$_fsadd$260 Def0121 +S A$_fsadd$251 Def0113 +S A$_fsadd$242 Def0102 +S A$_fsadd$233 Def00F4 +S A$_fsadd$224 Def00E0 +S A$_fsadd$215 Def00D3 +S A$_fsadd$206 Def00C8 +S A$_fsadd$170 Def008E +S A$_fsadd$152 Def0075 +S A$_fsadd$143 Def0067 +S A$_fsadd$134 Def005B +S A$_fsadd$125 Def004C +S A$_fsadd$116 Def003E +S A$_fsadd$720 Def03D5 +S A$_fsadd$711 Def03C3 +S A$_fsadd$702 Def03B5 +S A$_fsadd$630 Def033A +S A$_fsadd$621 Def032D +S A$_fsadd$603 Def0313 +S A$_fsadd$531 Def02AC +S A$_fsadd$522 Def029C +S A$_fsadd$513 Def0295 +S A$_fsadd$504 Def0286 +S A$_fsadd$441 Def022D +S A$_fsadd$432 Def021E +S A$_fsadd$423 Def0210 +S A$_fsadd$414 Def0204 +S A$_fsadd$405 Def01F7 +S A$_fsadd$360 Def01B1 +S A$_fsadd$342 Def019E +S A$_fsadd$333 Def0190 +S A$_fsadd$324 Def0188 +S A$_fsadd$315 Def017B +S A$_fsadd$306 Def016B +S A$_fsadd$270 Def0131 +S A$_fsadd$261 Def0123 +S A$_fsadd$252 Def0115 +S A$_fsadd$243 Def0104 +S A$_fsadd$234 Def00F5 +S A$_fsadd$225 Def00E3 +S A$_fsadd$216 Def00D4 +S A$_fsadd$207 Def00CA +S A$_fsadd$180 Def009B +S A$_fsadd$171 Def0090 +S A$_fsadd$162 Def0083 +S A$_fsadd$153 Def0077 +S A$_fsadd$144 Def0068 +S A$_fsadd$135 Def005C +S A$_fsadd$126 Def004F +S A$_fsadd$117 Def0040 +S A$_fsadd$108 Def002E +S A$_fsadd$730 Def03E9 +S A$_fsadd$721 Def03D7 +S A$_fsadd$712 Def03C5 +S A$_fsadd$703 Def03B7 +S A$_fsadd$640 Def0348 +S A$_fsadd$631 Def033C +S A$_fsadd$622 Def032E +S A$_fsadd$613 Def0321 +S A$_fsadd$604 Def0314 +S A$_fsadd$550 Def02C5 +S A$_fsadd$541 Def02BA +S A$_fsadd$532 Def02AE +S A$_fsadd$523 Def029E +S A$_fsadd$514 Def0296 +S A$_fsadd$505 Def0288 +S A$_fsadd$460 Def024D +S A$_fsadd$451 Def023B +S A$_fsadd$442 Def022F +S A$_fsadd$433 Def0220 +S A$_fsadd$424 Def0211 +S A$_fsadd$406 Def01F9 +S A$_fsadd$361 Def01B3 +S A$_fsadd$352 Def01AA +S A$_fsadd$343 Def01A0 +S A$_fsadd$334 Def0191 +S A$_fsadd$325 Def018A +S A$_fsadd$316 Def017D +S A$_fsadd$307 Def016D +S A$_fsadd$280 Def0141 +S A$_fsadd$271 Def0133 +S A$_fsadd$262 Def0124 +S A$_fsadd$253 Def0116 +S A$_fsadd$244 Def0106 +S A$_fsadd$235 Def00F7 +S A$_fsadd$226 Def00E6 +S A$_fsadd$217 Def00D6 +S A$_fsadd$190 Def00AB +S A$_fsadd$181 Def009C +S A$_fsadd$172 Def0092 +S A$_fsadd$163 Def0084 +S A$_fsadd$154 Def0078 +S A$_fsadd$145 Def006A +S A$_fsadd$136 Def005D +S A$_fsadd$127 Def0051 +S A$_fsadd$118 Def0042 +S A$_fsadd$109 Def0031 +S A$_fsadd$731 Def03EC +S A$_fsadd$722 Def03D9 +S A$_fsadd$713 Def03C7 +S A$_fsadd$704 Def03B8 +S A$_fsadd$650 Def0358 +S A$_fsadd$641 Def0349 +S A$_fsadd$632 Def033D +S A$_fsadd$623 Def0330 +S A$_fsadd$605 Def0316 +S A$_fsadd$560 Def02D4 +S A$_fsadd$533 Def02AF +S A$_fsadd$524 Def02A0 +S A$_fsadd$506 Def028A +S A$_fsadd$470 Def0257 +S A$_fsadd$461 Def024F +S A$_fsadd$452 Def023D +S A$_fsadd$443 Def0230 +S A$_fsadd$434 Def0221 +S A$_fsadd$425 Def0213 +S A$_fsadd$407 Def01FA +S A$_fsadd$362 Def01B4 +S A$_fsadd$344 Def01A1 +S A$_fsadd$335 Def0192 +S A$_fsadd$326 Def018B +S A$_fsadd$317 Def017E +S A$_fsadd$308 Def016F +S A$_fsadd$290 Def0153 +S A$_fsadd$272 Def0135 +S A$_fsadd$263 Def0125 +S A$_fsadd$254 Def0118 +S A$_fsadd$245 Def0107 +S A$_fsadd$236 Def00F9 +S A$_fsadd$227 Def00E9 +S A$_fsadd$218 Def00D9 +S A$_fsadd$209 Def00CB +S A$_fsadd$191 Def00AE +S A$_fsadd$182 Def009E +S A$_fsadd$164 Def0085 +S A$_fsadd$155 Def0079 +S A$_fsadd$146 Def006B +S A$_fsadd$137 Def005E +S A$_fsadd$723 Def03DB +S A$_fsadd$714 Def03C9 +S A$_fsadd$705 Def03BA +S A$_fsadd$660 Def036B +S A$_fsadd$651 Def035A +S A$_fsadd$642 Def034B +S A$_fsadd$633 Def0340 +S A$_fsadd$624 Def0332 +S A$_fsadd$570 Def02E4 +S A$_fsadd$561 Def02D6 +S A$_fsadd$525 Def02A2 +S A$_fsadd$516 Def0298 +S A$_fsadd$480 Def0267 +S A$_fsadd$471 Def0258 +S A$_fsadd$453 Def023F +S A$_fsadd$435 Def0223 +S A$_fsadd$426 Def0215 +S A$_fsadd$417 Def0206 +S A$_fsadd$408 Def01FC +S A$_fsadd$390 Def01DF +S A$_fsadd$381 Def01D3 +S A$_fsadd$372 Def01C2 +S A$_fsadd$363 Def01B6 +S A$_fsadd$354 Def01AB +S A$_fsadd$345 Def01A3 +S A$_fsadd$336 Def0194 +S A$_fsadd$318 Def0180 +S A$_fsadd$309 Def0171 +S A$_fsadd$291 Def0154 +S A$_fsadd$282 Def0143 +S A$_fsadd$273 Def0136 +S A$_fsadd$264 Def0126 +S A$_fsadd$255 Def0119 +S A$_fsadd$246 Def0109 +S A$_fsadd$237 Def00FB +S A$_fsadd$228 Def00EB +S A$_fsadd$219 Def00DC +S A$_fsadd$192 Def00B1 +S A$_fsadd$183 Def00A1 +S A$_fsadd$174 Def0093 +S A$_fsadd$165 Def0087 +S A$_fsadd$156 Def007A +S A$_fsadd$147 Def006C +S A$_fsadd$138 Def005F +S A$_fsadd$724 Def03DD +S A$_fsadd$715 Def03CB +S A$_fsadd$706 Def03BB +S A$_fsadd$670 Def037B +S A$_fsadd$661 Def036C +S A$_fsadd$652 Def035C +S A$_fsadd$643 Def034C +S A$_fsadd$625 Def0333 +S A$_fsadd$616 Def0324 +S A$_fsadd$607 Def0318 +S A$_fsadd$580 Def02EF +S A$_fsadd$562 Def02D7 +S A$_fsadd$553 Def02C8 +S A$_fsadd$544 Def02BC +S A$_fsadd$535 Def02B1 +S A$_fsadd$526 Def02A4 +S A$_fsadd$481 Def0269 +S A$_fsadd$472 Def025A +S A$_fsadd$454 Def0241 +S A$_fsadd$445 Def0232 +S A$_fsadd$436 Def0225 +S A$_fsadd$427 Def0217 +S A$_fsadd$418 Def0207 +S A$_fsadd$409 Def01FE +S A$_fsadd$391 Def01E0 +S A$_fsadd$373 Def01C3 +S A$_fsadd$364 Def01B8 +S A$_fsadd$337 Def0196 +S A$_fsadd$328 Def018D +S A$_fsadd$319 Def0181 +S A$_fsadd$292 Def0156 +S A$_fsadd$283 Def0145 +S A$_fsadd$274 Def0138 +S A$_fsadd$265 Def0128 +S A$_fsadd$256 Def011B +S A$_fsadd$247 Def010C +S A$_fsadd$229 Def00EE +S A$_fsadd$193 Def00B3 +S A$_fsadd$184 Def00A4 +S A$_fsadd$175 Def0094 +S A$_fsadd$166 Def0088 +S A$_fsadd$157 Def007B +S A$_fsadd$148 Def006E +S A$_fsadd$139 Def0061 +S A$_fsadd$725 Def03DF +S A$_fsadd$716 Def03CD +S A$_fsadd$707 Def03BD +S A$_fsadd$680 Def038C +S A$_fsadd$662 Def036E +S A$_fsadd$653 Def035E +S A$_fsadd$644 Def034E +S A$_fsadd$626 Def0335 +S A$_fsadd$617 Def0326 +S A$_fsadd$608 Def031A +S A$_fsadd$590 Def02FE +S A$_fsadd$563 Def02D9 +S A$_fsadd$554 Def02CA +S A$_fsadd$545 Def02BE +S A$_fsadd$536 Def02B3 +S A$_fsadd$527 Def02A5 +S A$_fsadd$509 Def028D +S A$_fsadd$491 Def0279 +S A$_fsadd$473 Def025C +S A$_fsadd$464 Def0251 +S A$_fsadd$455 Def0243 +S A$_fsadd$437 Def0226 +S A$_fsadd$428 Def0218 +S A$_fsadd$419 Def0209 +S A$_fsadd$392 Def01E2 +S A$_fsadd$374 Def01C5 +S A$_fsadd$365 Def01B9 +S A$_fsadd$338 Def0197 +S A$_fsadd$293 Def0158 +S A$_fsadd$284 Def0147 +S A$_fsadd$275 Def0139 +S A$_fsadd$266 Def012A +S A$_fsadd$257 Def011C +S A$_fsadd$248 Def010E +S A$_fsadd$194 Def00B6 +S A$_fsadd$176 Def0096 +S A$_fsadd$167 Def0089 +S A$_fsadd$158 Def007C +S A$_fsadd$735 Def03EE +S A$_fsadd$726 Def03E1 +S A$_fsadd$717 Def03CF +S A$_fsadd$708 Def03BE +S A$_fsadd$690 Def039D +S A$_fsadd$681 Def038E +S A$_fsadd$672 Def037D +S A$_fsadd$663 Def036F +S A$_fsadd$654 Def0360 +S A$_fsadd$645 Def034F +S A$_fsadd$627 Def0337 +S A$_fsadd$618 Def0328 +S A$_fsadd$609 Def031C +S A$_fsadd$591 Def0300 +S A$_fsadd$582 Def02F2 +S A$_fsadd$564 Def02DB +S A$_fsadd$555 Def02CC +S A$_fsadd$546 Def02C0 +S A$_fsadd$537 Def02B5 +S A$_fsadd$528 Def02A7 +S A$_fsadd$519 Def029A +S A$_fsadd$492 Def027B +S A$_fsadd$483 Def026B +S A$_fsadd$474 Def025D +S A$_fsadd$456 Def0245 +S A$_fsadd$447 Def0235 +S A$_fsadd$438 Def0228 +S A$_fsadd$429 Def021A +S A$_fsadd$393 Def01E4 +S A$_fsadd$384 Def01D5 +S A$_fsadd$375 Def01C7 +S A$_fsadd$366 Def01BB +S A$_fsadd$357 Def01AD +S A$_fsadd$348 Def01A5 +S A$_fsadd$339 Def0199 +S A$_fsadd$294 Def015A +S A$_fsadd$285 Def0149 +S A$_fsadd$276 Def013B +S A$_fsadd$267 Def012C +S A$_fsadd$258 Def011E +S A$_fsadd$249 Def010F +S A$_fsadd$195 Def00B8 +S A$_fsadd$186 Def00A6 +S A$_fsadd$177 Def0097 +S A$_fsadd$168 Def008B +S A$_fsadd$159 Def007E +S A$_fsadd$718 Def03D1 +S A$_fsadd$709 Def03C0 +S A$_fsadd$691 Def039F +S A$_fsadd$673 Def037F +S A$_fsadd$664 Def0371 +S A$_fsadd$655 Def0362 +S A$_fsadd$646 Def0351 +S A$_fsadd$637 Def0342 +S A$_fsadd$628 Def0338 +S A$_fsadd$619 Def0329 +S A$_fsadd$592 Def0302 +S A$_fsadd$583 Def02F4 +S A$_fsadd$574 Def02E6 +S A$_fsadd$565 Def02DC +S A$_fsadd$556 Def02CD +S A$_fsadd$547 Def02C2 +S A$_fsadd$538 Def02B8 +S A$_fsadd$529 Def02A9 +S A$_fsadd$493 Def027D +S A$_fsadd$484 Def026E +S A$_fsadd$475 Def025F +S A$_fsadd$466 Def0253 +S A$_fsadd$457 Def0247 +S A$_fsadd$448 Def0238 +S A$_fsadd$439 Def022A +S A$_fsadd$394 Def01E6 +S A$_fsadd$385 Def01D6 +S A$_fsadd$376 Def01C9 +S A$_fsadd$367 Def01BD +S A$_fsadd$358 Def01AE +S A$_fsadd$349 Def01A7 +S A$_fsadd$295 Def015B +S A$_fsadd$286 Def014B +S A$_fsadd$277 Def013C +S A$_fsadd$268 Def012E +S A$_fsadd$259 Def011F +S A$_fsadd$196 Def00BA +S A$_fsadd$178 Def0098 +S A$_fsadd$728 Def03E3 +S A$_fsadd$719 Def03D3 +S A$_fsadd$692 Def03A1 +S A$_fsadd$683 Def0390 +S A$_fsadd$674 Def0381 +S A$_fsadd$665 Def0372 +S A$_fsadd$656 Def0364 +S A$_fsadd$647 Def0352 +S A$_fsadd$638 Def0344 +S A$_fsadd$584 Def02F6 +S A$_fsadd$575 Def02E8 +S A$_fsadd$557 Def02CF +S A$_fsadd$548 Def02C4 +S A$_fsadd$494 Def027F +S A$_fsadd$485 Def0271 +S A$_fsadd$476 Def0261 +S A$_fsadd$458 Def0249 +S A$_fsadd$395 Def01E7 +S A$_fsadd$386 Def01D8 +S A$_fsadd$377 Def01CB +S A$_fsadd$368 Def01BE +S A$_fsadd$359 Def01AF +S A$_fsadd$296 Def015D +S A$_fsadd$287 Def014C +S A$_fsadd$278 Def013E +S A$_fsadd$269 Def012F +S A$_fsadd$179 Def0099 +S XG$__fsadd$0$0 Def03EE +S A$_fsadd$729 Def03E6 +S A$_fsadd$693 Def03A2 +S A$_fsadd$684 Def0392 +S A$_fsadd$675 Def0383 +S A$_fsadd$666 Def0374 +S A$_fsadd$657 Def0366 +S A$_fsadd$648 Def0354 +S A$_fsadd$639 Def0346 +S A$_fsadd$594 Def0304 +S A$_fsadd$585 Def02F8 +S A$_fsadd$576 Def02EA +S A$_fsadd$567 Def02DE +S A$_fsadd$558 Def02D1 +S A$_fsadd$486 Def0274 +S A$_fsadd$477 Def0262 +S A$_fsadd$459 Def024B +S A$_fsadd$396 Def01E9 +S A$_fsadd$387 Def01DA +S A$_fsadd$378 Def01CE +S A$_fsadd$369 Def01C0 +S A$_fsadd$297 Def015E +S A$_fsadd$288 Def014E +S A$_fsadd$279 Def013F +S A$_fsadd$198 Def00BC +S A$_fsadd$189 Def00A8 +S A$_fsadd$694 Def03A4 +S A$_fsadd$685 Def0394 +S A$_fsadd$676 Def0385 +S A$_fsadd$667 Def0376 +S A$_fsadd$658 Def0368 +S A$_fsadd$649 Def0356 +S A$_fsadd$595 Def0305 +S A$_fsadd$577 Def02EC +S A$_fsadd$568 Def02E0 +S A$_fsadd$559 Def02D2 +S A$_fsadd$496 Def0281 +S A$_fsadd$478 Def0264 +S A$_fsadd$469 Def0256 +S A$_fsadd$388 Def01DB +S A$_fsadd$379 Def01D1 +S A$_fsadd$298 Def0160 +S A$_fsadd$289 Def0151 +S A$_fsadd$199 Def00BD +S A$_fsadd$695 Def03A5 +S A$_fsadd$686 Def0396 +S A$_fsadd$677 Def0387 +S A$_fsadd$668 Def0379 +S A$_fsadd$659 Def0369 +S A$_fsadd$596 Def0307 +S A$_fsadd$587 Def02FA +S A$_fsadd$578 Def02EE +S A$_fsadd$569 Def02E1 +S A$_fsadd$488 Def0277 +S A$_fsadd$479 Def0266 +S A$_fsadd$398 Def01EB +S A$_fsadd$389 Def01DD +S A$_fsadd$299 Def0161 +S A$_fsadd$696 Def03A7 +S A$_fsadd$687 Def0398 +S A$_fsadd$678 Def0389 +S A$_fsadd$597 Def0309 +S A$_fsadd$399 Def01ED +S A$_fsadd$697 Def03A9 +S A$_fsadd$688 Def039A +S A$_fsadd$679 Def038B +S A$_fsadd$598 Def030A +S A$_fsadd$589 Def02FC +S A$_fsadd$698 Def03AC +S A$_fsadd$689 Def039B +S A$_fsadd$599 Def030C +S A$_fsadd$699 Def03AF +S A$_fsadd$80 Def0002 +S A$_fsadd$90 Def0010 +S A$_fsadd$81 Def0004 +S G$__fsadd$0$0 Def0000 +S A$_fsadd$91 Def0012 +S A$_fsadd$82 Def0006 +S A$_fsadd$92 Def0014 +S A$_fsadd$93 Def0016 +S A$_fsadd$84 Def0007 +S A$_fsadd$85 Def0008 +S A$_fsadd$95 Def0018 +S A$_fsadd$86 Def000A +S A$_fsadd$96 Def001B +S A$_fsadd$87 Def000C +S A$_fsadd$97 Def001E +S A$_fsadd$88 Def000E +S A$_fsadd$79 Def0000 +S A$_fsadd$98 Def0021 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 16 +R 00 00 00 01 +T 00 16 +R 00 00 00 01 +T 00 18 +R 00 00 00 01 +T 00 18 +R 00 00 00 01 +T 00 1C +R 00 00 00 01 +T 00 1C +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 FD E4 F5 00 1B F5 00 1A +R 00 00 00 07 29 0B 00 01 29 0E 00 01 +T 00 0C F5 00 19 F5 00 18 8A 00 0C 8B +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 13 00 0D 8C 00 0E 8D 00 0F 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 19 00 00 00 10 85 00 01 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 00 1D 00 11 85 00 02 00 12 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 00 22 00 03 00 13 E5 00 0C 45 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 00 27 00 0D 45 00 0E 45 00 0F 70 0E +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 2E +R 00 00 00 07 +T 00 2E 85 00 10 82 85 00 11 83 85 00 12 F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 38 00 13 02 03 EE +R 00 00 00 07 29 02 00 01 00 05 00 07 +T 00 3C +R 00 00 00 07 +T 00 3C E5 00 10 45 00 11 45 00 12 45 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 43 00 13 70 0E +R 00 00 00 07 29 02 00 01 +T 00 46 +R 00 00 00 07 +T 00 46 85 00 0C 82 85 00 0D 83 85 00 0E F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 50 00 0F 02 03 EE +R 00 00 00 07 29 02 00 01 00 05 00 07 +T 00 54 +R 00 00 00 07 +T 00 54 AA 00 0E E5 00 0F A2 E7 CA 33 CA 33 CA 54 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 00 60 01 30 E0 02 44 FE +R 00 00 00 07 +T 00 66 +R 00 00 00 07 +T 00 66 FB 33 95 E0 FC FD 8A 00 14 75 00 15 00 AA +R 00 00 00 07 29 09 00 01 29 0C 00 01 +T 00 72 00 12 E5 00 13 A2 E7 CA 33 CA 33 CA 54 01 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 7E 30 E0 02 44 FE +R 00 00 00 07 +T 00 83 +R 00 00 00 07 +T 00 83 FB 33 95 E0 FE FF 8A 00 16 75 00 17 00 74 +R 00 00 00 07 29 09 00 01 29 0C 00 01 +T 00 8F 19 25 00 16 FA E4 35 00 17 FB C3 EA 95 +R 00 00 00 07 29 04 00 01 29 09 00 01 +T 00 9A 00 14 EB 64 80 85 00 15 F0 63 F0 80 95 F0 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 00 A6 50 1E +R 00 00 00 07 +T 00 A8 +R 00 00 00 07 +T 00 A8 85 00 0C 82 85 00 0D 83 85 00 0E F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 B2 00 0F 12 00 00 AA 82 AB 83 A8 F0 F9 8A 82 +R 00 00 00 07 29 02 00 01 02 05 00 00 +T 00 BF 8B 83 88 F0 02 03 EE +R 00 00 00 07 00 07 00 07 +T 00 C6 +R 00 00 00 07 +T 00 C6 74 19 25 00 14 FA E4 35 00 15 FB C3 EA 95 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 00 D2 00 16 EB 64 80 85 00 17 F0 63 F0 80 95 F0 +R 00 00 00 07 29 02 00 01 29 08 00 01 +T 00 DE 50 1E +R 00 00 00 07 +T 00 E0 +R 00 00 00 07 +T 00 E0 85 00 10 82 85 00 11 83 85 00 12 F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 EA 00 13 12 00 00 AA 82 AB 83 A8 F0 F9 8A 82 +R 00 00 00 07 29 02 00 01 02 05 00 00 +T 00 F7 8B 83 88 F0 02 03 EE +R 00 00 00 07 00 07 00 07 +T 00 FE +R 00 00 00 07 +T 00 FE AA 00 0C AB 00 0D 74 7F 55 00 0E F8 79 00 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 0B 00 01 +T 01 09 43 00 80 88 00 06 E9 54 03 A2 E0 C5 00 06 +R 00 00 00 07 29 06 00 01 29 0E 00 01 +T 01 15 13 C5 00 06 13 C5 00 06 13 C5 00 06 13 C5 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 01 20 00 06 F5 00 07 EB 03 03 54 3F 45 00 06 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0D 00 01 +T 01 2B 00 06 8A 00 04 EB 54 03 A2 E0 C5 00 04 13 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0D 00 01 +T 01 36 C5 00 04 13 C5 00 04 13 C5 00 04 13 C5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 01 40 00 04 F5 00 05 AA 00 10 AB +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 46 00 11 74 7F 55 00 12 F8 79 00 43 00 80 88 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 01 52 00 0A E9 54 03 A2 E0 C5 00 0A 13 C5 00 0A +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 01 5D 13 C5 00 0A 13 C5 00 0A 13 C5 00 0A F5 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 01 67 00 0B EB 03 03 54 3F 45 00 0A F5 00 0A 8A +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0D 00 01 +T 01 72 00 08 EB 54 03 A2 E0 C5 00 08 13 C5 00 08 +R 00 00 00 07 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 01 7D 13 C5 00 08 13 C5 00 08 13 C5 00 08 F5 +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 01 87 00 09 E5 00 0F 23 54 01 FA 60 15 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 01 90 +R 00 00 00 07 +T 01 90 C3 E4 95 00 04 F5 00 04 E4 95 00 05 F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 01 9A 00 05 E4 95 00 06 F5 00 06 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 A2 00 07 F5 00 07 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 01 A5 +R 00 00 00 07 +T 01 A5 E5 00 13 23 54 01 FA 60 15 +R 00 00 00 07 29 03 00 01 +T 01 AD +R 00 00 00 07 +T 01 AD C3 E4 95 00 08 F5 00 08 E4 95 00 09 F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 01 B7 00 09 E4 95 00 0A F5 00 0A E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 BF 00 0B F5 00 0B +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 01 C2 +R 00 00 00 07 +T 01 C2 C3 E5 00 16 95 00 14 E5 00 17 64 80 85 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 01 CC 00 15 F0 63 F0 80 95 F0 50 31 +R 00 00 00 07 29 02 00 01 +T 01 D5 +R 00 00 00 07 +T 01 D5 C3 E5 00 14 95 00 16 FA E5 00 15 95 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0B 00 01 +T 01 DE 00 17 FB 8A F0 05 F0 E5 00 0B 33 92 D2 80 +R 00 00 00 07 29 02 00 01 29 0A 00 01 +T 01 EA 16 +R 00 00 00 07 +T 01 EB +R 00 00 00 07 +T 01 EB A2 D2 E5 00 0B 13 F5 00 0B E5 00 0A 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 01 F6 00 0A E5 00 09 13 F5 00 09 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 01 FD 00 08 13 F5 00 08 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 02 01 +R 00 00 00 07 +T 02 01 D5 F0 E7 80 35 +R 00 00 00 07 +T 02 06 +R 00 00 00 07 +T 02 06 C3 E5 00 16 95 00 14 FA E5 00 17 95 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0B 00 01 +T 02 0F 00 15 FB 8A F0 05 F0 E5 00 07 33 92 D2 80 +R 00 00 00 07 29 02 00 01 29 0A 00 01 +T 02 1B 16 +R 00 00 00 07 +T 02 1C +R 00 00 00 07 +T 02 1C A2 D2 E5 00 07 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0C 00 01 +T 02 27 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 02 2E 00 04 13 F5 00 04 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 02 32 +R 00 00 00 07 +T 02 32 D5 F0 E7 85 00 16 00 14 85 00 17 +R 00 00 00 07 29 06 00 01 29 08 00 01 29 0B 00 01 +T 02 3A 00 15 +R 00 00 00 07 29 02 00 01 +T 02 3B +R 00 00 00 07 +T 02 3B E5 00 08 25 00 04 F5 00 04 E5 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 02 42 00 09 35 00 05 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 48 00 0A 35 00 06 F5 00 06 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 4E 00 0B 35 00 07 F5 00 07 30 E7 23 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 56 +R 00 00 00 07 +T 02 56 C3 E4 95 00 04 F5 00 04 E4 95 00 05 F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 02 60 00 05 E4 95 00 06 F5 00 06 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 02 68 00 07 F5 00 07 75 00 18 00 75 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 02 6F 00 19 00 75 00 1A 00 75 00 1B 80 80 14 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 02 79 +R 00 00 00 07 +T 02 79 E5 00 04 45 00 05 45 00 06 45 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 02 80 00 07 70 0A +R 00 00 00 07 29 02 00 01 +T 02 83 +R 00 00 00 07 +T 02 83 E4 F5 82 F5 83 F5 F0 02 03 EE +R 00 00 00 07 00 0A 00 07 +T 02 8D +R 00 00 00 07 +T 02 8D AA 00 04 AB 00 05 A8 00 06 A9 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 02 94 00 07 E9 54 E0 60 02 +R 00 00 00 07 29 02 00 01 +T 02 9A +R 00 00 00 07 +T 02 9A 80 20 +R 00 00 00 07 +T 02 9C +R 00 00 00 07 +T 02 9C E5 00 04 25 E0 F5 00 04 E5 00 05 33 F5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 02 A6 00 05 E5 00 06 33 F5 00 06 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 02 AD 00 07 33 F5 00 07 15 00 14 74 FF B5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 02 B6 00 14 02 15 00 15 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 02 BA +R 00 00 00 07 +T 02 BA 80 D1 +R 00 00 00 07 +T 02 BC +R 00 00 00 07 +T 02 BC AA 00 04 AB 00 05 A8 00 06 A9 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 02 C3 00 07 E9 30 E6 1E +R 00 00 00 07 29 02 00 01 +T 02 C8 +R 00 00 00 07 +T 02 C8 E5 00 07 A2 E7 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 03 00 01 29 09 00 01 29 0C 00 01 +T 02 D3 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 02 DA 00 04 13 F5 00 04 05 00 14 E4 B5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 02 E2 00 14 02 05 00 15 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 02 E6 +R 00 00 00 07 +T 02 E6 +R 00 00 00 07 +T 02 E6 AA 00 04 AB 00 05 A8 00 06 A9 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 02 ED 00 07 EA 30 E6 0A +R 00 00 00 07 29 02 00 01 +T 02 F2 +R 00 00 00 07 +T 02 F2 7A 20 7B 00 78 00 79 00 80 08 +R 00 00 00 07 +T 02 FC +R 00 00 00 07 +T 02 FC 7A 1F 7B 00 78 00 79 00 +R 00 00 00 07 +T 03 04 +R 00 00 00 07 +T 03 04 EA 25 00 04 F5 00 04 EB 35 00 05 F5 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0B 00 01 +T 03 0D 00 05 E8 35 00 06 F5 00 06 E9 35 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 03 15 00 07 F5 00 07 AA 00 04 AB +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 1B 00 05 A8 00 06 A9 00 07 E9 30 E6 1E +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 24 +R 00 00 00 07 +T 03 24 E5 00 07 A2 E7 13 F5 00 07 E5 00 06 13 F5 +R 00 00 00 07 29 03 00 01 29 09 00 01 29 0C 00 01 +T 03 2F 00 06 E5 00 05 13 F5 00 05 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 09 00 01 +T 03 36 00 04 13 F5 00 04 05 00 14 E4 B5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 03 3E 00 14 02 05 00 15 +R 00 00 00 07 29 02 00 01 29 06 00 01 +T 03 42 +R 00 00 00 07 +T 03 42 +R 00 00 00 07 +T 03 42 E5 00 05 A2 E7 C5 00 04 33 C5 00 04 33 C5 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0C 00 01 +T 03 4D 00 04 33 C5 00 04 33 C5 00 04 54 03 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 03 57 00 05 E5 00 06 25 E0 25 E0 45 00 05 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0C 00 01 +T 03 61 00 05 E5 00 07 A2 E7 C5 00 06 33 C5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 03 6A 00 06 33 C5 00 06 33 C5 00 06 33 C5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 03 73 00 06 54 03 30 E1 02 44 FC +R 00 00 00 07 29 02 00 01 +T 03 7B +R 00 00 00 07 +T 03 7B F5 00 07 AA 00 04 AB 00 05 A8 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 03 82 00 06 A9 00 07 8A 00 04 8B +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 88 00 05 74 7F 58 F5 00 06 89 00 07 AA +R 00 00 00 07 29 02 00 01 29 08 00 01 29 0B 00 01 +T 03 91 00 14 AB 00 15 78 00 79 00 8A 00 1E EB 54 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0C 00 01 +T 03 9C 01 A2 E0 C5 00 1E 13 C5 00 1E 13 C5 00 1E +R 00 00 00 07 29 06 00 01 29 0A 00 01 29 0E 00 01 +T 03 A7 F5 00 1F 75 00 1D 00 75 00 1C 00 AA +R 00 00 00 07 29 03 00 01 29 06 00 01 29 0A 00 01 +T 03 B0 00 18 AB 00 19 A8 00 1A A9 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 B6 00 1B EA 42 00 1C EB 42 00 1D E8 42 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 03 BF 00 1E E9 42 00 1F AA 00 04 AB +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 03 C6 00 05 A8 00 06 A9 00 07 E5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 CC 00 1C 42 02 E5 00 1D 42 03 E5 00 1E 42 00 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 03 D7 E5 00 1F 42 01 8A 00 0C 8B 00 0D 88 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0B 00 01 +T 03 E0 00 0E 89 00 0F 85 00 0C 82 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 E7 00 0D 83 85 00 0E F0 E5 00 0F +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 03 EE +R 00 00 00 07 +T 03 EE 22 +R 00 00 00 07 diff --git a/device/lib/small/_fsdiv.asm b/device/lib/small/_fsdiv.asm new file mode 100644 index 00000000..6db5b7a6 --- /dev/null +++ b/device/lib/small/_fsdiv.asm @@ -0,0 +1,453 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:11 2000 + +;-------------------------------------------------------- + .module _fsdiv +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsdiv_PARM_2 + .globl ___fsdiv +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsdiv_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fsdiv_PARM_2: + .ds 0x0004 +___fsdiv_fl1_1_1: + .ds 0x0004 +___fsdiv_fl2_1_1: + .ds 0x0004 +___fsdiv_result_1_1: + .ds 0x0004 +___fsdiv_mask_1_1: + .ds 0x0004 +___fsdiv_mant1_1_1: + .ds 0x0004 +___fsdiv_mant2_1_1: + .ds 0x0004 +___fsdiv_exp_1_1: + .ds 0x0002 +___fsdiv_sign_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsdiv$0$0 ==. +; _fsdiv.c 73 +; ----------------------------------------- +; function __fsdiv +; ----------------------------------------- +___fsdiv: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsdiv.c 138 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fsdiv.c 82 + mov ___fsdiv_fl1_1_1,r2 + mov (___fsdiv_fl1_1_1 + 1),r3 + mov (___fsdiv_fl1_1_1 + 2),r4 + mov (___fsdiv_fl1_1_1 + 3),r5 +; _fsdiv.c 83 + mov ___fsdiv_fl2_1_1,___fsdiv_PARM_2 + mov (___fsdiv_fl2_1_1 + 1),(___fsdiv_PARM_2 + 1) + mov (___fsdiv_fl2_1_1 + 2),(___fsdiv_PARM_2 + 2) + mov (___fsdiv_fl2_1_1 + 3),(___fsdiv_PARM_2 + 3) +; _fsdiv.c 86 + mov r2,(___fsdiv_fl1_1_1 + 2) + mov a,(___fsdiv_fl1_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00120$ + orl a,#0xfe +00120$: + mov r3,a + rlc a + subb a,acc + mov r4,a + mov r5,a + mov ___fsdiv_exp_1_1,r2 + mov (___fsdiv_exp_1_1 + 1),#0x00 +; _fsdiv.c 87 + mov r2,(___fsdiv_fl2_1_1 + 2) + mov a,(___fsdiv_fl2_1_1 + 3) + mov c,acc.7 + xch a,r2 + rlc a + xch a,r2 + rlc a + xch a,r2 + anl a,#0x01 + jnb acc.0,00121$ + orl a,#0xfe +00121$: + mov r3,a + rlc a + subb a,acc + mov r6,a + mov r7,a + mov r3,#0x00 + clr c + mov a,___fsdiv_exp_1_1 + subb a,r2 + mov ___fsdiv_exp_1_1,a + mov a,(___fsdiv_exp_1_1 + 1) + subb a,r3 + mov (___fsdiv_exp_1_1 + 1),a +; _fsdiv.c 88 + mov a,#0x7e + add a,___fsdiv_exp_1_1 + mov ___fsdiv_exp_1_1,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsdiv_exp_1_1 + 1) + mov (___fsdiv_exp_1_1 + 1),a +; _fsdiv.c 91 + mov a,(___fsdiv_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + mov a,(___fsdiv_fl2_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r3,a + xrl a,ar2 + mov ___fsdiv_sign_1_1,a +; _fsdiv.c 94 + mov a,___fsdiv_fl2_1_1 + orl a,(___fsdiv_fl2_1_1 + 1) + orl a,(___fsdiv_fl2_1_1 + 2) + orl a,(___fsdiv_fl2_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00122$: +; _fsdiv.c 96 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x80 + mov a,#0xbf + ljmp 00112$ +00102$: +; _fsdiv.c 99 + mov a,___fsdiv_fl1_1_1 + orl a,(___fsdiv_fl1_1_1 + 1) + orl a,(___fsdiv_fl1_1_1 + 2) + orl a,(___fsdiv_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00123$: +; _fsdiv.c 100 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00112$ +00104$: +; _fsdiv.c 103 + mov r3,___fsdiv_fl1_1_1 + mov r0,(___fsdiv_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fsdiv_fl1_1_1 + 2) + mov r1,a + mov r2,#0x00 + mov ___fsdiv_mant1_1_1,r3 + mov (___fsdiv_mant1_1_1 + 1),r0 + mov a,#0x80 + orl a,r1 + mov (___fsdiv_mant1_1_1 + 2),a + mov (___fsdiv_mant1_1_1 + 3),r2 +; _fsdiv.c 104 + mov r2,___fsdiv_fl2_1_1 + mov r3,(___fsdiv_fl2_1_1 + 1) + mov a,#0x7f + anl a,(___fsdiv_fl2_1_1 + 2) + mov r0,a + mov r1,#0x00 + mov ___fsdiv_mant2_1_1,r2 + mov (___fsdiv_mant2_1_1 + 1),r3 + mov a,#0x80 + orl a,r0 + mov (___fsdiv_mant2_1_1 + 2),a + mov (___fsdiv_mant2_1_1 + 3),r1 +; _fsdiv.c 107 + clr c + mov a,___fsdiv_mant1_1_1 + subb a,___fsdiv_mant2_1_1 + mov a,(___fsdiv_mant1_1_1 + 1) + subb a,(___fsdiv_mant2_1_1 + 1) + mov a,(___fsdiv_mant1_1_1 + 2) + subb a,(___fsdiv_mant2_1_1 + 2) + mov a,(___fsdiv_mant1_1_1 + 3) + xrl a,#0x80 + mov b,(___fsdiv_mant2_1_1 + 3) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00106$ +00124$: +; _fsdiv.c 109 + mov a,___fsdiv_mant1_1_1 + add a,acc + mov ___fsdiv_mant1_1_1,a + mov a,(___fsdiv_mant1_1_1 + 1) + rlc a + mov (___fsdiv_mant1_1_1 + 1),a + mov a,(___fsdiv_mant1_1_1 + 2) + rlc a + mov (___fsdiv_mant1_1_1 + 2),a + mov a,(___fsdiv_mant1_1_1 + 3) + rlc a + mov (___fsdiv_mant1_1_1 + 3),a +; _fsdiv.c 110 + dec ___fsdiv_exp_1_1 + mov a,#0xff + cjne a,___fsdiv_exp_1_1,00125$ + dec (___fsdiv_exp_1_1 + 1) +00125$: +00106$: +; _fsdiv.c 114 + mov ___fsdiv_mask_1_1,#0x00 + mov (___fsdiv_mask_1_1 + 1),#0x00 + mov (___fsdiv_mask_1_1 + 2),#0x00 + mov (___fsdiv_mask_1_1 + 3),#0x01 +; _fsdiv.c 115 + clr a + mov (___fsdiv_result_1_1 + 3),a + mov (___fsdiv_result_1_1 + 2),a + mov (___fsdiv_result_1_1 + 1),a + mov ___fsdiv_result_1_1,a +; _fsdiv.c 116 +00109$: + mov a,___fsdiv_mask_1_1 + orl a,(___fsdiv_mask_1_1 + 1) + orl a,(___fsdiv_mask_1_1 + 2) + orl a,(___fsdiv_mask_1_1 + 3) + jnz 00126$ + ljmp 00111$ +00126$: +; _fsdiv.c 118 + clr c + mov a,___fsdiv_mant1_1_1 + subb a,___fsdiv_mant2_1_1 + mov a,(___fsdiv_mant1_1_1 + 1) + subb a,(___fsdiv_mant2_1_1 + 1) + mov a,(___fsdiv_mant1_1_1 + 2) + subb a,(___fsdiv_mant2_1_1 + 2) + mov a,(___fsdiv_mant1_1_1 + 3) + xrl a,#0x80 + mov b,(___fsdiv_mant2_1_1 + 3) + xrl b,#0x80 + subb a,b +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00108$ +00127$: +; _fsdiv.c 120 + mov r2,___fsdiv_result_1_1 + mov r3,(___fsdiv_result_1_1 + 1) + mov r0,(___fsdiv_result_1_1 + 2) + mov r1,(___fsdiv_result_1_1 + 3) + mov a,___fsdiv_mask_1_1 + orl a,r2 + mov ___fsdiv_result_1_1,a + mov a,(___fsdiv_mask_1_1 + 1) + orl a,r3 + mov (___fsdiv_result_1_1 + 1),a + mov a,(___fsdiv_mask_1_1 + 2) + orl a,r0 + mov (___fsdiv_result_1_1 + 2),a + mov a,(___fsdiv_mask_1_1 + 3) + orl a,r1 + mov (___fsdiv_result_1_1 + 3),a +; _fsdiv.c 121 + clr c + mov a,___fsdiv_mant1_1_1 + subb a,___fsdiv_mant2_1_1 + mov ___fsdiv_mant1_1_1,a + mov a,(___fsdiv_mant1_1_1 + 1) + subb a,(___fsdiv_mant2_1_1 + 1) + mov (___fsdiv_mant1_1_1 + 1),a + mov a,(___fsdiv_mant1_1_1 + 2) + subb a,(___fsdiv_mant2_1_1 + 2) + mov (___fsdiv_mant1_1_1 + 2),a + mov a,(___fsdiv_mant1_1_1 + 3) + subb a,(___fsdiv_mant2_1_1 + 3) + mov (___fsdiv_mant1_1_1 + 3),a +00108$: +; _fsdiv.c 123 + mov a,___fsdiv_mant1_1_1 + add a,acc + mov ___fsdiv_mant1_1_1,a + mov a,(___fsdiv_mant1_1_1 + 1) + rlc a + mov (___fsdiv_mant1_1_1 + 1),a + mov a,(___fsdiv_mant1_1_1 + 2) + rlc a + mov (___fsdiv_mant1_1_1 + 2),a + mov a,(___fsdiv_mant1_1_1 + 3) + rlc a + mov (___fsdiv_mant1_1_1 + 3),a +; _fsdiv.c 124 + clr c + mov a,(___fsdiv_mask_1_1 + 3) + rrc a + mov (___fsdiv_mask_1_1 + 3),a + mov a,(___fsdiv_mask_1_1 + 2) + rrc a + mov (___fsdiv_mask_1_1 + 2),a + mov a,(___fsdiv_mask_1_1 + 1) + rrc a + mov (___fsdiv_mask_1_1 + 1),a + mov a,___fsdiv_mask_1_1 + rrc a + mov ___fsdiv_mask_1_1,a + ljmp 00109$ +00111$: +; _fsdiv.c 128 + inc ___fsdiv_result_1_1 + clr a + cjne a,___fsdiv_result_1_1,00128$ + inc (___fsdiv_result_1_1 + 1) + cjne a,(___fsdiv_result_1_1 + 1),00128$ + inc (___fsdiv_result_1_1 + 2) + cjne a,(___fsdiv_result_1_1 + 2),00128$ + inc (___fsdiv_result_1_1 + 3) +00128$: +; _fsdiv.c 131 + inc ___fsdiv_exp_1_1 + clr a + cjne a,___fsdiv_exp_1_1,00129$ + inc (___fsdiv_exp_1_1 + 1) +00129$: +; _fsdiv.c 132 + mov a,(___fsdiv_result_1_1 + 3) + mov c,acc.7 + rrc a + mov (___fsdiv_result_1_1 + 3),a + mov a,(___fsdiv_result_1_1 + 2) + rrc a + mov (___fsdiv_result_1_1 + 2),a + mov a,(___fsdiv_result_1_1 + 1) + rrc a + mov (___fsdiv_result_1_1 + 1),a + mov a,___fsdiv_result_1_1 + rrc a + mov ___fsdiv_result_1_1,a +; _fsdiv.c 134 + mov r2,___fsdiv_result_1_1 + mov r3,(___fsdiv_result_1_1 + 1) + mov r0,(___fsdiv_result_1_1 + 2) + mov r1,(___fsdiv_result_1_1 + 3) + mov ___fsdiv_result_1_1,r2 + mov (___fsdiv_result_1_1 + 1),r3 + mov a,#0x7f + anl a,r0 + mov (___fsdiv_result_1_1 + 2),a + mov (___fsdiv_result_1_1 + 3),r1 +; _fsdiv.c 137 + mov r2,___fsdiv_exp_1_1 + mov r3,(___fsdiv_exp_1_1 + 1) + mov r0,#0x00 + mov r1,#0x00 + mov (___fsdiv_sloc0_1_0 + 2),r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,(___fsdiv_sloc0_1_0 + 2) + rrc a + xch a,(___fsdiv_sloc0_1_0 + 2) + rrc a + xch a,(___fsdiv_sloc0_1_0 + 2) + mov (___fsdiv_sloc0_1_0 + 3),a + mov (___fsdiv_sloc0_1_0 + 1),#0x00 + mov ___fsdiv_sloc0_1_0,#0x00 + mov r2,___fsdiv_sign_1_1 +; Peephole 3.c changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov r3,a + mov r0,a + mov r1,a + mov a,r2 + orl ___fsdiv_sloc0_1_0,a + mov a,r3 + orl (___fsdiv_sloc0_1_0 + 1),a + mov a,r0 + orl (___fsdiv_sloc0_1_0 + 2),a + mov a,r1 + orl (___fsdiv_sloc0_1_0 + 3),a + mov r2,___fsdiv_result_1_1 + mov r3,(___fsdiv_result_1_1 + 1) + mov r0,(___fsdiv_result_1_1 + 2) + mov r1,(___fsdiv_result_1_1 + 3) + mov a,___fsdiv_sloc0_1_0 + orl ar2,a + mov a,(___fsdiv_sloc0_1_0 + 1) + orl ar3,a + mov a,(___fsdiv_sloc0_1_0 + 2) + orl ar0,a + mov a,(___fsdiv_sloc0_1_0 + 3) + orl ar1,a + mov ___fsdiv_fl1_1_1,r2 + mov (___fsdiv_fl1_1_1 + 1),r3 + mov (___fsdiv_fl1_1_1 + 2),r0 + mov (___fsdiv_fl1_1_1 + 3),r1 +; _fsdiv.c 138 + mov dpl,___fsdiv_fl1_1_1 + mov dph,(___fsdiv_fl1_1_1 + 1) + mov b,(___fsdiv_fl1_1_1 + 2) + mov a,(___fsdiv_fl1_1_1 + 3) +00112$: + C$_fsdiv.c$139$1$1 ==. + XG$__fsdiv$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fsdiv.cdb b/device/lib/small/_fsdiv.cdb new file mode 100644 index 00000000..037077d2 --- /dev/null +++ b/device/lib/small/_fsdiv.cdb @@ -0,0 +1,2 @@ +M:_fsdiv +F:G$__fsdiv$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fsdiv.rel b/device/lib/small/_fsdiv.rel new file mode 100644 index 00000000..d15c4ccd --- /dev/null +++ b/device/lib/small/_fsdiv.rel @@ -0,0 +1,554 @@ +;!FILE _fsdiv.asm +XH +H 9 areas 13B global symbols +M _fsdiv +A _CODE size 0 flags 0 +A DSEG size 4 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 1F flags 4 +S ___fsdiv_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 245 flags 20 +S A$_fsdiv$435 Def0227 +S A$_fsdiv$426 Def0216 +S A$_fsdiv$417 Def020A +S A$_fsdiv$408 Def01FC +S A$_fsdiv$390 Def01DD +S A$_fsdiv$381 Def01CE +S A$_fsdiv$372 Def01BF +S A$_fsdiv$363 Def01B5 +S A$_fsdiv$345 Def0195 +S A$_fsdiv$336 Def0188 +S A$_fsdiv$327 Def0178 +S A$_fsdiv$318 Def016A +S A$_fsdiv$309 Def015C +S A$_fsdiv$282 Def012F +S A$_fsdiv$273 Def0121 +S A$_fsdiv$264 Def0113 +S A$_fsdiv$246 Def00F6 +S A$_fsdiv$228 Def00D8 +S A$_fsdiv$219 Def00C9 +S A$_fsdiv$192 Def009C +S A$_fsdiv$183 Def0095 +S A$_fsdiv$174 Def0088 +S A$_fsdiv$165 Def007C +S A$_fsdiv$156 Def0070 +S A$_fsdiv$147 Def0063 +S A$_fsdiv$138 Def0056 +S A$_fsdiv$129 Def004A +S A$_fsdiv$445 Def0239 +S A$_fsdiv$436 Def0229 +S A$_fsdiv$427 Def0217 +S A$_fsdiv$418 Def020B +S A$_fsdiv$409 Def01FD +S A$_fsdiv$391 Def01DF +S A$_fsdiv$382 Def01D0 +S A$_fsdiv$373 Def01C1 +S A$_fsdiv$346 Def0196 +S A$_fsdiv$337 Def018A +S A$_fsdiv$328 Def017A +S A$_fsdiv$319 Def016C +S A$_fsdiv$292 Def0141 +S A$_fsdiv$283 Def0131 +S A$_fsdiv$274 Def0123 +S A$_fsdiv$265 Def0115 +S A$_fsdiv$247 Def00F8 +S A$_fsdiv$238 Def00E8 +S A$_fsdiv$229 Def00DA +S A$_fsdiv$193 Def009E +S A$_fsdiv$175 Def008A +S A$_fsdiv$166 Def007E +S A$_fsdiv$157 Def0071 +S A$_fsdiv$148 Def0064 +S A$_fsdiv$139 Def0058 +S A$_fsdiv$446 Def023C +S A$_fsdiv$437 Def022B +S A$_fsdiv$428 Def0219 +S A$_fsdiv$419 Def020C +S A$_fsdiv$392 Def01E1 +S A$_fsdiv$383 Def01D2 +S A$_fsdiv$374 Def01C3 +S A$_fsdiv$356 Def01A5 +S A$_fsdiv$347 Def0198 +S A$_fsdiv$338 Def018B +S A$_fsdiv$329 Def017C +S A$_fsdiv$284 Def0133 +S A$_fsdiv$275 Def0125 +S A$_fsdiv$266 Def0117 +S A$_fsdiv$248 Def00FA +S A$_fsdiv$239 Def00EA +S A$_fsdiv$149 Def0066 +S A$_fsdiv$447 Def023F +S A$_fsdiv$438 Def022D +S A$_fsdiv$429 Def021B +S A$_fsdiv$393 Def01E3 +S A$_fsdiv$384 Def01D3 +S A$_fsdiv$375 Def01C4 +S A$_fsdiv$366 Def01B7 +S A$_fsdiv$357 Def01A7 +S A$_fsdiv$348 Def019A +S A$_fsdiv$285 Def0135 +S A$_fsdiv$267 Def0119 +S A$_fsdiv$258 Def0106 +S A$_fsdiv$249 Def00FB +S A$_fsdiv$168 Def0080 +S A$_fsdiv$159 Def0073 +S A$_fsdiv$448 Def0242 +S A$_fsdiv$439 Def022F +S A$_fsdiv$394 Def01E4 +S A$_fsdiv$376 Def01C6 +S A$_fsdiv$367 Def01B9 +S A$_fsdiv$358 Def01A8 +S A$_fsdiv$349 Def019B +S A$_fsdiv$295 Def0143 +S A$_fsdiv$286 Def0137 +S A$_fsdiv$259 Def0109 +S A$_fsdiv$196 Def00A1 +S A$_fsdiv$178 Def008D +S A$_fsdiv$395 Def01E6 +S A$_fsdiv$386 Def01D5 +S A$_fsdiv$377 Def01C8 +S A$_fsdiv$368 Def01BA +S A$_fsdiv$359 Def01AB +S A$_fsdiv$296 Def0145 +S A$_fsdiv$287 Def0139 +S A$_fsdiv$278 Def0128 +S A$_fsdiv$197 Def00A3 +S A$_fsdiv$179 Def008F +S XG$__fsdiv$0$0 Def0244 +S A$_fsdiv$387 Def01D7 +S A$_fsdiv$378 Def01C9 +S A$_fsdiv$369 Def01BD +S A$_fsdiv$297 Def0147 +S A$_fsdiv$288 Def013C +S A$_fsdiv$279 Def0129 +S A$_fsdiv$198 Def00A5 +S A$_fsdiv$189 Def0097 +S A$_fsdiv$397 Def01E8 +S A$_fsdiv$388 Def01D9 +S A$_fsdiv$379 Def01CB +S A$_fsdiv$298 Def0149 +S A$_fsdiv$289 Def013F +S A$_fsdiv$199 Def00A7 +S A$_fsdiv$398 Def01EA +S A$_fsdiv$389 Def01DB +S A$_fsdiv$299 Def014B +S A$_fsdiv$399 Def01EC +S A$_fsdiv$90 Def000D +S G$__fsdiv$0$0 Def0000 +S A$_fsdiv$82 Def0000 +S A$_fsdiv$92 Def000F +S A$_fsdiv$83 Def0002 +S A$_fsdiv$93 Def0012 +S A$_fsdiv$84 Def0004 +S A$_fsdiv$94 Def0015 +S A$_fsdiv$85 Def0006 +S A$_fsdiv$95 Def0018 +S A$_fsdiv$87 Def0007 +S A$_fsdiv$97 Def001B +S A$_fsdiv$88 Def0009 +S A$_fsdiv$98 Def001D +S A$_fsdiv$89 Def000B +S A$_fsdiv$99 Def001F +S A$_fsdiv$100 Def0021 +S A$_fsdiv$200 Def00A9 +S A$_fsdiv$110 Def002E +S A$_fsdiv$101 Def0022 +S A$_fsdiv$300 Def014D +S A$_fsdiv$210 Def00B9 +S A$_fsdiv$201 Def00AA +S A$_fsdiv$120 Def003E +S A$_fsdiv$111 Def002F +S A$_fsdiv$102 Def0023 +S A$_fsdiv$400 Def01EE +S A$_fsdiv$310 Def015D +S A$_fsdiv$301 Def014E +S A$_fsdiv$220 Def00CB +S A$_fsdiv$211 Def00BB +S A$_fsdiv$202 Def00AC +S A$_fsdiv$130 Def004B +S A$_fsdiv$121 Def003F +S A$_fsdiv$112 Def0031 +S A$_fsdiv$103 Def0024 +S A$_fsdiv$410 Def01FF +S A$_fsdiv$401 Def01F0 +S A$_fsdiv$320 Def016E +S A$_fsdiv$302 Def0150 +S A$_fsdiv$230 Def00DC +S A$_fsdiv$212 Def00BD +S A$_fsdiv$203 Def00AE +S A$_fsdiv$140 Def005A +S A$_fsdiv$131 Def004C +S A$_fsdiv$122 Def0040 +S A$_fsdiv$113 Def0032 +S A$_fsdiv$104 Def0025 +S ___fsdiv Def0000 +S A$_fsdiv$420 Def020D +S A$_fsdiv$411 Def0201 +S A$_fsdiv$402 Def01F2 +S A$_fsdiv$330 Def017E +S A$_fsdiv$321 Def0170 +S A$_fsdiv$312 Def015F +S A$_fsdiv$303 Def0152 +S A$_fsdiv$240 Def00EC +S A$_fsdiv$231 Def00DE +S A$_fsdiv$222 Def00CD +S A$_fsdiv$213 Def00BF +S A$_fsdiv$204 Def00B0 +S A$_fsdiv$141 Def005B +S A$_fsdiv$132 Def004E +S A$_fsdiv$123 Def0041 +S A$_fsdiv$114 Def0033 +S A$_fsdiv$105 Def0026 +S A$_fsdiv$430 Def021D +S A$_fsdiv$421 Def020E +S A$_fsdiv$412 Def0204 +S A$_fsdiv$403 Def01F3 +S A$_fsdiv$340 Def018D +S A$_fsdiv$331 Def0180 +S A$_fsdiv$322 Def0172 +S A$_fsdiv$313 Def0160 +S A$_fsdiv$304 Def0153 +S A$_fsdiv$241 Def00EE +S A$_fsdiv$232 Def00E1 +S A$_fsdiv$223 Def00CE +S A$_fsdiv$214 Def00C0 +S A$_fsdiv$205 Def00B2 +S A$_fsdiv$160 Def0074 +S A$_fsdiv$151 Def0068 +S A$_fsdiv$133 Def004F +S A$_fsdiv$124 Def0042 +S A$_fsdiv$115 Def0035 +S A$_fsdiv$106 Def0028 +S A$_fsdiv$440 Def0231 +S A$_fsdiv$431 Def021F +S A$_fsdiv$422 Def0210 +S A$_fsdiv$413 Def0207 +S A$_fsdiv$404 Def01F5 +S A$_fsdiv$350 Def019D +S A$_fsdiv$341 Def018E +S A$_fsdiv$332 Def0181 +S A$_fsdiv$323 Def0174 +S A$_fsdiv$314 Def0162 +S A$_fsdiv$305 Def0155 +S A$_fsdiv$260 Def010C +S A$_fsdiv$251 Def00FD +S A$_fsdiv$242 Def00F0 +S A$_fsdiv$233 Def00E4 +S A$_fsdiv$224 Def00D0 +S A$_fsdiv$215 Def00C2 +S A$_fsdiv$206 Def00B3 +S A$_fsdiv$161 Def0076 +S A$_fsdiv$152 Def006A +S A$_fsdiv$143 Def005D +S A$_fsdiv$134 Def0050 +S A$_fsdiv$125 Def0043 +S A$_fsdiv$107 Def002B +S A$_fsdiv$441 Def0233 +S A$_fsdiv$432 Def0221 +S A$_fsdiv$423 Def0211 +S A$_fsdiv$405 Def01F7 +S A$_fsdiv$360 Def01AD +S A$_fsdiv$351 Def019F +S A$_fsdiv$342 Def0190 +S A$_fsdiv$333 Def0183 +S A$_fsdiv$324 Def0176 +S A$_fsdiv$315 Def0164 +S A$_fsdiv$306 Def0157 +S A$_fsdiv$270 Def011B +S A$_fsdiv$261 Def010F +S A$_fsdiv$252 Def00FF +S A$_fsdiv$243 Def00F1 +S A$_fsdiv$225 Def00D2 +S A$_fsdiv$216 Def00C4 +S A$_fsdiv$207 Def00B5 +S A$_fsdiv$180 Def0091 +S A$_fsdiv$153 Def006B +S A$_fsdiv$144 Def005F +S A$_fsdiv$135 Def0052 +S A$_fsdiv$126 Def0045 +S A$_fsdiv$117 Def0038 +S A$_fsdiv$442 Def0235 +S A$_fsdiv$433 Def0223 +S A$_fsdiv$424 Def0213 +S A$_fsdiv$406 Def01F9 +S A$_fsdiv$361 Def01B0 +S A$_fsdiv$352 Def01A0 +S A$_fsdiv$343 Def0191 +S A$_fsdiv$334 Def0185 +S A$_fsdiv$316 Def0166 +S A$_fsdiv$307 Def0158 +S A$_fsdiv$280 Def012B +S A$_fsdiv$271 Def011D +S A$_fsdiv$253 Def0101 +S A$_fsdiv$244 Def00F3 +S A$_fsdiv$235 Def00E6 +S A$_fsdiv$226 Def00D4 +S A$_fsdiv$217 Def00C6 +S A$_fsdiv$190 Def0098 +S A$_fsdiv$181 Def0093 +S A$_fsdiv$172 Def0082 +S A$_fsdiv$163 Def0078 +S A$_fsdiv$154 Def006D +S A$_fsdiv$145 Def0061 +S A$_fsdiv$136 Def0053 +S A$_fsdiv$127 Def0048 +S A$_fsdiv$118 Def003A +S A$_fsdiv$109 Def002D +S C$_fsdiv.c$139$1$1 Def0244 +S A$_fsdiv$452 Def0244 +S A$_fsdiv$443 Def0237 +S A$_fsdiv$434 Def0225 +S A$_fsdiv$425 Def0214 +S A$_fsdiv$416 Def0209 +S A$_fsdiv$407 Def01FA +S A$_fsdiv$380 Def01CD +S A$_fsdiv$362 Def01B2 +S A$_fsdiv$353 Def01A2 +S A$_fsdiv$344 Def0193 +S A$_fsdiv$335 Def0186 +S A$_fsdiv$317 Def0168 +S A$_fsdiv$308 Def015A +S A$_fsdiv$281 Def012D +S A$_fsdiv$272 Def011F +S A$_fsdiv$263 Def0112 +S A$_fsdiv$254 Def0104 +S A$_fsdiv$245 Def00F5 +S A$_fsdiv$227 Def00D6 +S A$_fsdiv$218 Def00C8 +S A$_fsdiv$209 Def00B7 +S A$_fsdiv$191 Def009A +S A$_fsdiv$173 Def0085 +S A$_fsdiv$164 Def007A +S A$_fsdiv$155 Def006E +S A$_fsdiv$137 Def0055 +S A$_fsdiv$119 Def003C +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 0C +R 00 00 00 03 +T 00 0C +R 00 00 00 03 +T 00 10 +R 00 00 00 03 +T 00 10 +R 00 00 00 03 +T 00 14 +R 00 00 00 03 +T 00 14 +R 00 00 00 03 +T 00 18 +R 00 00 00 03 +T 00 18 +R 00 00 00 03 +T 00 1C +R 00 00 00 03 +T 00 1C +R 00 00 00 03 +T 00 1E +R 00 00 00 03 +T 00 1E +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 06 8D 00 07 85 00 00 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 11 00 08 85 00 01 00 09 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 16 00 02 00 0A 85 00 03 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 1A 00 0B AA 00 06 E5 00 07 A2 E7 CA 33 CA 33 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 25 CA 54 01 30 E0 02 44 FE +R 00 00 00 08 +T 00 2D +R 00 00 00 08 +T 00 2D FB 33 95 E0 FC FD 8A 00 1C 75 00 1D 00 AA +R 00 00 00 08 29 09 00 03 29 0C 00 03 +T 00 39 00 0A E5 00 0B A2 E7 CA 33 CA 33 CA 54 01 +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 45 30 E0 02 44 FE +R 00 00 00 08 +T 00 4A +R 00 00 00 08 +T 00 4A FB 33 95 E0 FE FF 7B 00 C3 E5 00 1C 9A F5 +R 00 00 00 08 29 0C 00 03 +T 00 57 00 1C E5 00 1D 9B F5 00 1D 74 7E 25 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 60 00 1C F5 00 1C E4 35 00 1D F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 67 00 1D E5 00 07 23 54 01 FA E5 00 0B 23 54 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0C 00 03 +T 00 72 01 FB 65 02 F5 00 1E E5 00 08 45 00 09 45 +R 00 00 00 08 29 07 00 03 29 0A 00 03 29 0D 00 03 +T 00 7D 00 0A 45 00 0B 70 0B +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 82 +R 00 00 00 08 +T 00 82 90 00 00 75 F0 80 74 BF 02 02 44 +R 00 00 00 08 00 0B 00 08 +T 00 8D +R 00 00 00 08 +T 00 8D E5 00 04 45 00 05 45 00 06 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 94 00 07 70 0A +R 00 00 00 08 29 02 00 03 +T 00 97 +R 00 00 00 08 +T 00 97 E4 F5 82 F5 83 F5 F0 02 02 44 +R 00 00 00 08 00 0A 00 08 +T 00 A1 +R 00 00 00 08 +T 00 A1 AB 00 04 A8 00 05 74 7F 55 00 06 F9 7A 00 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 0B 00 03 +T 00 AC 8B 00 14 88 00 15 74 80 49 F5 00 16 8A +R 00 00 00 08 29 03 00 03 29 06 00 03 29 0C 00 03 +T 00 B6 00 17 AA 00 08 AB 00 09 74 7F 55 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 BE 00 0A F8 79 00 8A 00 18 8B 00 19 74 80 48 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 C9 F5 00 1A 89 00 1B C3 E5 00 14 95 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 0A 00 03 +T 00 D1 00 18 E5 00 15 95 00 19 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 D7 00 16 95 00 1A E5 00 17 64 80 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 DF 00 1B F0 63 F0 80 95 F0 50 1E +R 00 00 00 08 29 02 00 03 +T 00 E8 +R 00 00 00 08 +T 00 E8 E5 00 14 25 E0 F5 00 14 E5 00 15 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 00 F2 00 15 E5 00 16 33 F5 00 16 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 F9 00 17 33 F5 00 17 15 00 1C 74 FF B5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 01 02 00 1C 02 15 00 1D +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 01 06 +R 00 00 00 08 +T 01 06 +R 00 00 00 08 +T 01 06 75 00 10 00 75 00 11 00 75 00 12 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 01 10 00 13 01 E4 F5 00 0F F5 00 0E F5 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0A 00 03 +T 01 18 00 0D F5 00 0C +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 01 1B +R 00 00 00 08 +T 01 1B E5 00 10 45 00 11 45 00 12 45 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 01 22 00 13 70 03 02 01 A5 +R 00 00 00 08 29 02 00 03 00 07 00 08 +T 01 28 +R 00 00 00 08 +T 01 28 C3 E5 00 14 95 00 18 E5 00 15 95 +R 00 00 00 08 29 04 00 03 29 07 00 03 29 0A 00 03 +T 01 30 00 19 E5 00 16 95 00 1A E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 01 36 00 17 64 80 85 00 1B F0 63 F0 80 95 F0 40 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 01 42 35 +R 00 00 00 08 +T 01 43 +R 00 00 00 08 +T 01 43 AA 00 0C AB 00 0D A8 00 0E A9 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 01 4A 00 0F E5 00 10 4A F5 00 0C E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 01 51 00 11 4B F5 00 0D E5 00 12 48 F5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 01 59 00 0E E5 00 13 49 F5 00 0F C3 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 01 61 00 14 95 00 18 F5 00 14 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 01 67 00 15 95 00 19 F5 00 15 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 01 6D 00 16 95 00 1A F5 00 16 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 01 73 00 17 95 00 1B F5 00 17 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 01 78 +R 00 00 00 08 +T 01 78 E5 00 14 25 E0 F5 00 14 E5 00 15 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 01 82 00 15 E5 00 16 33 F5 00 16 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 01 89 00 17 33 F5 00 17 C3 E5 00 13 13 F5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 01 92 00 13 E5 00 12 13 F5 00 12 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 01 99 00 11 13 F5 00 11 E5 00 10 13 F5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 01 A1 00 10 02 01 1B +R 00 00 00 08 29 02 00 03 00 05 00 08 +T 01 A5 +R 00 00 00 08 +T 01 A5 05 00 0C E4 B5 00 0C 0C 05 00 0D B5 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 01 AE 00 0D 07 05 00 0E B5 00 0E 02 05 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 01 B6 00 0F +R 00 00 00 08 29 02 00 03 +T 01 B7 +R 00 00 00 08 +T 01 B7 05 00 1C E4 B5 00 1C 02 05 00 1D +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 01 BF +R 00 00 00 08 +T 01 BF E5 00 0F A2 E7 13 F5 00 0F E5 00 0E 13 F5 +R 00 00 00 08 29 03 00 03 29 09 00 03 29 0C 00 03 +T 01 CA 00 0E E5 00 0D 13 F5 00 0D E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 01 D1 00 0C 13 F5 00 0C AA 00 0C AB +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 01 D8 00 0D A8 00 0E A9 00 0F 8A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 01 DE 00 0C 8B 00 0D 74 7F 58 F5 00 0E 89 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0B 00 03 +T 01 E7 00 0F AA 00 1C AB 00 1D 78 00 79 00 8A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 01 F1 00 02 EB 54 01 A2 E0 C5 00 02 13 C5 00 02 +R 00 00 00 08 29 02 00 01 29 0A 00 01 29 0E 00 01 +T 01 FC 13 C5 00 02 F5 00 03 75 00 01 00 75 +R 00 00 00 08 29 04 00 01 29 07 00 01 29 0A 00 01 +T 02 05 00 00 00 AA 00 1E E4 FB F8 F9 EA 42 00 00 +R 00 00 00 08 29 02 00 01 29 06 00 03 29 0E 00 01 +T 02 10 EB 42 00 01 E8 42 00 02 E9 42 00 03 AA +R 00 00 00 08 29 04 00 01 29 08 00 01 29 0C 00 01 +T 02 1A 00 0C AB 00 0D A8 00 0E A9 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 02 20 00 0F E5 00 00 42 02 E5 00 01 42 03 E5 +R 00 00 00 08 29 02 00 03 29 05 00 01 29 0A 00 01 +T 02 2A 00 02 42 00 E5 00 03 42 01 8A 00 04 8B +R 00 00 00 08 29 02 00 01 29 07 00 01 29 0C 00 03 +T 02 34 00 05 88 00 06 89 00 07 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 02 3A 00 04 82 85 00 05 83 85 00 06 F0 E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 02 43 00 07 +R 00 00 00 08 29 02 00 03 +T 02 44 +R 00 00 00 08 +T 02 44 22 +R 00 00 00 08 diff --git a/device/lib/small/_fseq.asm b/device/lib/small/_fseq.asm new file mode 100644 index 00000000..d3b87aa5 --- /dev/null +++ b/device/lib/small/_fseq.asm @@ -0,0 +1,147 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:11 2000 + +;-------------------------------------------------------- + .module _fseq +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fseq_PARM_2 + .globl ___fseq +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fseq_PARM_2: + .ds 0x0004 +___fseq_fl1_1_1: + .ds 0x0004 +___fseq_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fseq$0$0 ==. +; _fseq.c 73 +; ----------------------------------------- +; function __fseq +; ----------------------------------------- +___fseq: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fseq.c 87 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fseq.c 77 + mov ___fseq_fl1_1_1,r2 + mov (___fseq_fl1_1_1 + 1),r3 + mov (___fseq_fl1_1_1 + 2),r4 + mov (___fseq_fl1_1_1 + 3),r5 +; _fseq.c 78 + mov ___fseq_fl2_1_1,___fseq_PARM_2 + mov (___fseq_fl2_1_1 + 1),(___fseq_PARM_2 + 1) + mov (___fseq_fl2_1_1 + 2),(___fseq_PARM_2 + 2) + mov (___fseq_fl2_1_1 + 3),(___fseq_PARM_2 + 3) +; _fseq.c 80 + mov a,(___fseq_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00111$: + mov a,(___fseq_fl2_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00112$: +; _fseq.c 82 + mov r2,___fseq_fl1_1_1 + mov r3,(___fseq_fl1_1_1 + 1) + mov r4,(___fseq_fl1_1_1 + 2) + mov a,#0x80 + xrl a,(___fseq_fl1_1_1 + 3) + mov r5,a + mov ___fseq_fl1_1_1,r2 + mov (___fseq_fl1_1_1 + 1),r3 + mov (___fseq_fl1_1_1 + 2),r4 + mov (___fseq_fl1_1_1 + 3),r5 +; _fseq.c 83 + mov r2,___fseq_fl2_1_1 + mov r3,(___fseq_fl2_1_1 + 1) + mov r4,(___fseq_fl2_1_1 + 2) + mov a,#0x80 + xrl a,(___fseq_fl2_1_1 + 3) + mov r5,a + mov ___fseq_fl2_1_1,r2 + mov (___fseq_fl2_1_1 + 1),r3 + mov (___fseq_fl2_1_1 + 2),r4 + mov (___fseq_fl2_1_1 + 3),r5 +00102$: +; _fseq.c 85 + mov a,___fseq_fl1_1_1 +; Peephole 132 changed ljmp to sjmp +; Peephole 193 optimized misc jump sequence + cjne a,___fseq_fl2_1_1,00105$ + mov a,(___fseq_fl1_1_1 + 1) + cjne a,(___fseq_fl2_1_1 + 1),00105$ + mov a,(___fseq_fl1_1_1 + 2) + cjne a,(___fseq_fl2_1_1 + 2),00105$ + mov a,(___fseq_fl1_1_1 + 3) + cjne a,(___fseq_fl2_1_1 + 3),00105$ +; Peephole 201 removed redundant sjmp +00113$: +00114$: +; _fseq.c 86 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fseq.c 87 + mov dpl,#0x00 +00106$: + C$_fseq.c$88$1$1 ==. + XG$__fseq$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fseq.cdb b/device/lib/small/_fseq.cdb new file mode 100644 index 00000000..1598e175 --- /dev/null +++ b/device/lib/small/_fseq.cdb @@ -0,0 +1,2 @@ +M:_fseq +F:G$__fseq$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fseq.rel b/device/lib/small/_fseq.rel new file mode 100644 index 00000000..f32ef552 --- /dev/null +++ b/device/lib/small/_fseq.rel @@ -0,0 +1,136 @@ +;!FILE _fseq.asm +XH +H 9 areas 3B global symbols +M _fseq +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +S ___fseq_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 6E flags 20 +S A$_fseq$100 Def002B +S A$_fseq$101 Def002D +S A$_fseq$120 Def004F +S A$_fseq$111 Def003E +S A$_fseq$102 Def002F +S A$_fseq$130 Def005D +S A$_fseq$112 Def0040 +S A$_fseq$103 Def0031 +S A$_fseq$131 Def0060 +S A$_fseq$113 Def0042 +S A$_fseq$104 Def0033 +S ___fseq Def0000 +S A$_fseq$132 Def0062 +S A$_fseq$123 Def0051 +S A$_fseq$114 Def0044 +S A$_fseq$105 Def0035 +S A$_fseq$142 Def006A +S A$_fseq$115 Def0046 +S A$_fseq$106 Def0036 +S A$_fseq$116 Def0048 +S A$_fseq$107 Def0038 +S A$_fseq$126 Def0053 +S A$_fseq$117 Def0049 +S A$_fseq$108 Def003A +S A$_fseq$127 Def0056 +S A$_fseq$118 Def004B +S A$_fseq$109 Def003C +S A$_fseq$146 Def006D +S A$_fseq$137 Def0065 +S A$_fseq$128 Def0058 +S A$_fseq$119 Def004D +S A$_fseq$129 Def005B +S A$_fseq$139 Def0068 +S XG$__fseq$0$0 Def006D +S A$_fseq$70 Def0004 +S A$_fseq$80 Def0015 +S A$_fseq$71 Def0006 +S A$_fseq$81 Def0018 +S G$__fseq$0$0 Def0000 +S A$_fseq$91 Def0023 +S A$_fseq$73 Def0007 +S A$_fseq$92 Def0025 +S A$_fseq$83 Def001B +S A$_fseq$74 Def0009 +S A$_fseq$93 Def0026 +S A$_fseq$84 Def001D +S A$_fseq$75 Def000B +S A$_fseq$85 Def001E +S A$_fseq$76 Def000D +S C$_fseq.c$88$1$1 Def006D +S A$_fseq$95 Def0028 +S A$_fseq$68 Def0000 +S A$_fseq$87 Def0020 +S A$_fseq$78 Def000F +S A$_fseq$69 Def0002 +S A$_fseq$97 Def0029 +S A$_fseq$79 Def0012 +S A$_fseq$89 Def0021 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 06 8D 00 07 85 00 00 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 11 00 08 85 00 01 00 09 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 16 00 02 00 0A 85 00 03 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 1A 00 0B E5 00 07 23 54 01 FA 60 2E +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 23 +R 00 00 00 08 +T 00 23 E5 00 0B 23 54 01 FA 60 26 +R 00 00 00 08 29 03 00 03 +T 00 2B +R 00 00 00 08 +T 00 2B AA 00 04 AB 00 05 AC 00 06 74 80 65 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 34 00 07 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 3B 00 06 8D 00 07 AA 00 08 AB +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 41 00 09 AC 00 0A 74 80 65 00 0B FD 8A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0A 00 03 +T 00 4A 00 08 8B 00 09 8C 00 0A 8D +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 50 00 0B +R 00 00 00 08 29 02 00 03 +T 00 51 +R 00 00 00 08 +T 00 51 E5 00 04 B5 00 08 14 E5 00 05 B5 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 0A 00 03 +T 00 59 00 09 0F E5 00 06 B5 00 0A 0A E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 61 00 07 B5 00 0B 05 +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 65 +R 00 00 00 08 +T 00 65 +R 00 00 00 08 +T 00 65 75 82 01 80 03 +R 00 00 00 08 +T 00 6A +R 00 00 00 08 +T 00 6A 75 82 00 +R 00 00 00 08 +T 00 6D +R 00 00 00 08 +T 00 6D 22 +R 00 00 00 08 diff --git a/device/lib/small/_fsgt.asm b/device/lib/small/_fsgt.asm new file mode 100644 index 00000000..15388d56 --- /dev/null +++ b/device/lib/small/_fsgt.asm @@ -0,0 +1,149 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:11 2000 + +;-------------------------------------------------------- + .module _fsgt +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsgt_PARM_2 + .globl ___fsgt +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fsgt_PARM_2: + .ds 0x0004 +___fsgt_fl1_1_1: + .ds 0x0004 +___fsgt_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsgt$0$0 ==. +; _fsgt.c 73 +; ----------------------------------------- +; function __fsgt +; ----------------------------------------- +___fsgt: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsgt.c 87 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fsgt.c 77 + mov ___fsgt_fl1_1_1,r2 + mov (___fsgt_fl1_1_1 + 1),r3 + mov (___fsgt_fl1_1_1 + 2),r4 + mov (___fsgt_fl1_1_1 + 3),r5 +; _fsgt.c 78 + mov ___fsgt_fl2_1_1,___fsgt_PARM_2 + mov (___fsgt_fl2_1_1 + 1),(___fsgt_PARM_2 + 1) + mov (___fsgt_fl2_1_1 + 2),(___fsgt_PARM_2 + 2) + mov (___fsgt_fl2_1_1 + 3),(___fsgt_PARM_2 + 3) +; _fsgt.c 80 + mov a,(___fsgt_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00111$: + mov a,(___fsgt_fl2_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00112$: +; _fsgt.c 82 + mov r2,___fsgt_fl1_1_1 + mov r3,(___fsgt_fl1_1_1 + 1) + mov r4,(___fsgt_fl1_1_1 + 2) + mov a,#0x80 + xrl a,(___fsgt_fl1_1_1 + 3) + mov r5,a + mov ___fsgt_fl1_1_1,r2 + mov (___fsgt_fl1_1_1 + 1),r3 + mov (___fsgt_fl1_1_1 + 2),r4 + mov (___fsgt_fl1_1_1 + 3),r5 +; _fsgt.c 83 + mov r2,___fsgt_fl2_1_1 + mov r3,(___fsgt_fl2_1_1 + 1) + mov r4,(___fsgt_fl2_1_1 + 2) + mov a,#0x80 + xrl a,(___fsgt_fl2_1_1 + 3) + mov r5,a + mov ___fsgt_fl2_1_1,r2 + mov (___fsgt_fl2_1_1 + 1),r3 + mov (___fsgt_fl2_1_1 + 2),r4 + mov (___fsgt_fl2_1_1 + 3),r5 +00102$: +; _fsgt.c 85 + clr c + mov a,___fsgt_fl2_1_1 + subb a,___fsgt_fl1_1_1 + mov a,(___fsgt_fl2_1_1 + 1) + subb a,(___fsgt_fl1_1_1 + 1) + mov a,(___fsgt_fl2_1_1 + 2) + subb a,(___fsgt_fl1_1_1 + 2) + mov a,(___fsgt_fl2_1_1 + 3) + xrl a,#0x80 + mov b,(___fsgt_fl1_1_1 + 3) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00105$ +00113$: +; _fsgt.c 86 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fsgt.c 87 + mov dpl,#0x00 +00106$: + C$_fsgt.c$88$1$1 ==. + XG$__fsgt$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fsgt.cdb b/device/lib/small/_fsgt.cdb new file mode 100644 index 00000000..e948f606 --- /dev/null +++ b/device/lib/small/_fsgt.cdb @@ -0,0 +1,2 @@ +M:_fsgt +F:G$__fsgt$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fsgt.rel b/device/lib/small/_fsgt.rel new file mode 100644 index 00000000..401eb2a1 --- /dev/null +++ b/device/lib/small/_fsgt.rel @@ -0,0 +1,141 @@ +;!FILE _fsgt.asm +XH +H 9 areas 40 global symbols +M _fsgt +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +S ___fsgt_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 75 flags 20 +S A$_fsgt$100 Def002B +S A$_fsgt$101 Def002D +S A$_fsgt$120 Def004F +S A$_fsgt$111 Def003E +S A$_fsgt$102 Def002F +S A$_fsgt$130 Def005E +S A$_fsgt$112 Def0040 +S A$_fsgt$103 Def0031 +S A$_fsgt$131 Def0060 +S A$_fsgt$113 Def0042 +S A$_fsgt$104 Def0033 +S ___fsgt Def0000 +S A$_fsgt$141 Def006F +S A$_fsgt$132 Def0062 +S A$_fsgt$123 Def0051 +S A$_fsgt$114 Def0044 +S A$_fsgt$105 Def0035 +S A$_fsgt$133 Def0065 +S A$_fsgt$124 Def0052 +S A$_fsgt$115 Def0046 +S A$_fsgt$106 Def0036 +S A$_fsgt$134 Def0068 +S A$_fsgt$125 Def0054 +S A$_fsgt$116 Def0048 +S A$_fsgt$107 Def0038 +S A$_fsgt$144 Def0071 +S A$_fsgt$126 Def0056 +S A$_fsgt$117 Def0049 +S A$_fsgt$108 Def003A +S A$_fsgt$136 Def006A +S A$_fsgt$127 Def0058 +S A$_fsgt$118 Def004B +S A$_fsgt$109 Def003C +S A$_fsgt$128 Def005A +S A$_fsgt$119 Def004D +S A$_fsgt$129 Def005C +S A$_fsgt$148 Def0074 +S A$_fsgt$139 Def006C +S XG$__fsgt$0$0 Def0074 +S A$_fsgt$70 Def0004 +S A$_fsgt$80 Def0015 +S A$_fsgt$71 Def0006 +S A$_fsgt$81 Def0018 +S G$__fsgt$0$0 Def0000 +S A$_fsgt$91 Def0023 +S A$_fsgt$73 Def0007 +S A$_fsgt$92 Def0025 +S A$_fsgt$83 Def001B +S A$_fsgt$74 Def0009 +S A$_fsgt$93 Def0026 +S A$_fsgt$84 Def001D +S A$_fsgt$75 Def000B +S A$_fsgt$85 Def001E +S A$_fsgt$76 Def000D +S C$_fsgt.c$88$1$1 Def0074 +S A$_fsgt$95 Def0028 +S A$_fsgt$68 Def0000 +S A$_fsgt$87 Def0020 +S A$_fsgt$78 Def000F +S A$_fsgt$69 Def0002 +S A$_fsgt$97 Def0029 +S A$_fsgt$79 Def0012 +S A$_fsgt$89 Def0021 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 06 8D 00 07 85 00 00 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 11 00 08 85 00 01 00 09 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 16 00 02 00 0A 85 00 03 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 1A 00 0B E5 00 07 23 54 01 FA 60 2E +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 23 +R 00 00 00 08 +T 00 23 E5 00 0B 23 54 01 FA 60 26 +R 00 00 00 08 29 03 00 03 +T 00 2B +R 00 00 00 08 +T 00 2B AA 00 04 AB 00 05 AC 00 06 74 80 65 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 34 00 07 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 3B 00 06 8D 00 07 AA 00 08 AB +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 41 00 09 AC 00 0A 74 80 65 00 0B FD 8A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0A 00 03 +T 00 4A 00 08 8B 00 09 8C 00 0A 8D +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 50 00 0B +R 00 00 00 08 29 02 00 03 +T 00 51 +R 00 00 00 08 +T 00 51 C3 E5 00 08 95 00 04 E5 00 09 95 +R 00 00 00 08 29 04 00 03 29 07 00 03 29 0A 00 03 +T 00 59 00 05 E5 00 0A 95 00 06 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 5F 00 0B 64 80 85 00 07 F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6B 05 +R 00 00 00 08 +T 00 6C +R 00 00 00 08 +T 00 6C 75 82 01 80 03 +R 00 00 00 08 +T 00 71 +R 00 00 00 08 +T 00 71 75 82 00 +R 00 00 00 08 +T 00 74 +R 00 00 00 08 +T 00 74 22 +R 00 00 00 08 diff --git a/device/lib/small/_fslt.asm b/device/lib/small/_fslt.asm new file mode 100644 index 00000000..7009d826 --- /dev/null +++ b/device/lib/small/_fslt.asm @@ -0,0 +1,149 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _fslt +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fslt_PARM_2 + .globl ___fslt +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fslt_PARM_2: + .ds 0x0004 +___fslt_fl1_1_1: + .ds 0x0004 +___fslt_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fslt$0$0 ==. +; _fslt.c 73 +; ----------------------------------------- +; function __fslt +; ----------------------------------------- +___fslt: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fslt.c 87 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fslt.c 77 + mov ___fslt_fl1_1_1,r2 + mov (___fslt_fl1_1_1 + 1),r3 + mov (___fslt_fl1_1_1 + 2),r4 + mov (___fslt_fl1_1_1 + 3),r5 +; _fslt.c 78 + mov ___fslt_fl2_1_1,___fslt_PARM_2 + mov (___fslt_fl2_1_1 + 1),(___fslt_PARM_2 + 1) + mov (___fslt_fl2_1_1 + 2),(___fslt_PARM_2 + 2) + mov (___fslt_fl2_1_1 + 3),(___fslt_PARM_2 + 3) +; _fslt.c 80 + mov a,(___fslt_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00111$: + mov a,(___fslt_fl2_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00112$: +; _fslt.c 82 + mov r2,___fslt_fl1_1_1 + mov r3,(___fslt_fl1_1_1 + 1) + mov r4,(___fslt_fl1_1_1 + 2) + mov a,#0x80 + xrl a,(___fslt_fl1_1_1 + 3) + mov r5,a + mov ___fslt_fl1_1_1,r2 + mov (___fslt_fl1_1_1 + 1),r3 + mov (___fslt_fl1_1_1 + 2),r4 + mov (___fslt_fl1_1_1 + 3),r5 +; _fslt.c 83 + mov r2,___fslt_fl2_1_1 + mov r3,(___fslt_fl2_1_1 + 1) + mov r4,(___fslt_fl2_1_1 + 2) + mov a,#0x80 + xrl a,(___fslt_fl2_1_1 + 3) + mov r5,a + mov ___fslt_fl2_1_1,r2 + mov (___fslt_fl2_1_1 + 1),r3 + mov (___fslt_fl2_1_1 + 2),r4 + mov (___fslt_fl2_1_1 + 3),r5 +00102$: +; _fslt.c 85 + clr c + mov a,___fslt_fl1_1_1 + subb a,___fslt_fl2_1_1 + mov a,(___fslt_fl1_1_1 + 1) + subb a,(___fslt_fl2_1_1 + 1) + mov a,(___fslt_fl1_1_1 + 2) + subb a,(___fslt_fl2_1_1 + 2) + mov a,(___fslt_fl1_1_1 + 3) + xrl a,#0x80 + mov b,(___fslt_fl2_1_1 + 3) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00105$ +00113$: +; _fslt.c 86 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fslt.c 87 + mov dpl,#0x00 +00106$: + C$_fslt.c$88$1$1 ==. + XG$__fslt$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fslt.cdb b/device/lib/small/_fslt.cdb new file mode 100644 index 00000000..74e764bc --- /dev/null +++ b/device/lib/small/_fslt.cdb @@ -0,0 +1,2 @@ +M:_fslt +F:G$__fslt$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fslt.rel b/device/lib/small/_fslt.rel new file mode 100644 index 00000000..58a3ca81 --- /dev/null +++ b/device/lib/small/_fslt.rel @@ -0,0 +1,141 @@ +;!FILE _fslt.asm +XH +H 9 areas 40 global symbols +M _fslt +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +S ___fslt_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 75 flags 20 +S A$_fslt$100 Def002B +S A$_fslt$101 Def002D +S A$_fslt$120 Def004F +S A$_fslt$111 Def003E +S A$_fslt$102 Def002F +S A$_fslt$130 Def005E +S A$_fslt$112 Def0040 +S A$_fslt$103 Def0031 +S A$_fslt$131 Def0060 +S A$_fslt$113 Def0042 +S A$_fslt$104 Def0033 +S ___fslt Def0000 +S A$_fslt$141 Def006F +S A$_fslt$132 Def0062 +S A$_fslt$123 Def0051 +S A$_fslt$114 Def0044 +S A$_fslt$105 Def0035 +S A$_fslt$133 Def0065 +S A$_fslt$124 Def0052 +S A$_fslt$115 Def0046 +S A$_fslt$106 Def0036 +S A$_fslt$134 Def0068 +S A$_fslt$125 Def0054 +S A$_fslt$116 Def0048 +S A$_fslt$107 Def0038 +S A$_fslt$144 Def0071 +S A$_fslt$126 Def0056 +S A$_fslt$117 Def0049 +S A$_fslt$108 Def003A +S A$_fslt$136 Def006A +S A$_fslt$127 Def0058 +S A$_fslt$118 Def004B +S A$_fslt$109 Def003C +S A$_fslt$128 Def005A +S A$_fslt$119 Def004D +S A$_fslt$129 Def005C +S A$_fslt$148 Def0074 +S A$_fslt$139 Def006C +S XG$__fslt$0$0 Def0074 +S A$_fslt$70 Def0004 +S A$_fslt$80 Def0015 +S A$_fslt$71 Def0006 +S A$_fslt$81 Def0018 +S G$__fslt$0$0 Def0000 +S A$_fslt$91 Def0023 +S A$_fslt$73 Def0007 +S A$_fslt$92 Def0025 +S A$_fslt$83 Def001B +S A$_fslt$74 Def0009 +S A$_fslt$93 Def0026 +S A$_fslt$84 Def001D +S A$_fslt$75 Def000B +S A$_fslt$85 Def001E +S A$_fslt$76 Def000D +S C$_fslt.c$88$1$1 Def0074 +S A$_fslt$95 Def0028 +S A$_fslt$68 Def0000 +S A$_fslt$87 Def0020 +S A$_fslt$78 Def000F +S A$_fslt$69 Def0002 +S A$_fslt$97 Def0029 +S A$_fslt$79 Def0012 +S A$_fslt$89 Def0021 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 06 8D 00 07 85 00 00 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 11 00 08 85 00 01 00 09 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 16 00 02 00 0A 85 00 03 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 1A 00 0B E5 00 07 23 54 01 FA 60 2E +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 23 +R 00 00 00 08 +T 00 23 E5 00 0B 23 54 01 FA 60 26 +R 00 00 00 08 29 03 00 03 +T 00 2B +R 00 00 00 08 +T 00 2B AA 00 04 AB 00 05 AC 00 06 74 80 65 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 34 00 07 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 3B 00 06 8D 00 07 AA 00 08 AB +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 41 00 09 AC 00 0A 74 80 65 00 0B FD 8A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0A 00 03 +T 00 4A 00 08 8B 00 09 8C 00 0A 8D +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 50 00 0B +R 00 00 00 08 29 02 00 03 +T 00 51 +R 00 00 00 08 +T 00 51 C3 E5 00 04 95 00 08 E5 00 05 95 +R 00 00 00 08 29 04 00 03 29 07 00 03 29 0A 00 03 +T 00 59 00 09 E5 00 06 95 00 0A E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 5F 00 07 64 80 85 00 0B F0 63 F0 80 95 F0 50 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 6B 05 +R 00 00 00 08 +T 00 6C +R 00 00 00 08 +T 00 6C 75 82 01 80 03 +R 00 00 00 08 +T 00 71 +R 00 00 00 08 +T 00 71 75 82 00 +R 00 00 00 08 +T 00 74 +R 00 00 00 08 +T 00 74 22 +R 00 00 00 08 diff --git a/device/lib/small/_fsmul.asm b/device/lib/small/_fsmul.asm new file mode 100644 index 00000000..43025836 --- /dev/null +++ b/device/lib/small/_fsmul.asm @@ -0,0 +1,435 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _fsmul +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsmul_PARM_2 + .globl ___fsmul +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fsmul_PARM_2: + .ds 0x0004 +___fsmul_fl1_1_1: + .ds 0x0004 +___fsmul_fl2_1_1: + .ds 0x0004 +___fsmul_result_1_1: + .ds 0x0004 +___fsmul_exp_1_1: + .ds 0x0002 +___fsmul_sign_1_1: + .ds 0x0001 +___fsmul_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsmul$0$0 ==. +; _fsmul.c 81 +; ----------------------------------------- +; function __fsmul +; ----------------------------------------- +___fsmul: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsmul.c 125 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fsmul.c 88 + mov ___fsmul_fl1_1_1,r2 + mov (___fsmul_fl1_1_1 + 1),r3 + mov (___fsmul_fl1_1_1 + 2),r4 + mov (___fsmul_fl1_1_1 + 3),r5 +; _fsmul.c 89 + mov ___fsmul_fl2_1_1,___fsmul_PARM_2 + mov (___fsmul_fl2_1_1 + 1),(___fsmul_PARM_2 + 1) + mov (___fsmul_fl2_1_1 + 2),(___fsmul_PARM_2 + 2) + mov (___fsmul_fl2_1_1 + 3),(___fsmul_PARM_2 + 3) +; _fsmul.c 91 + mov a,___fsmul_fl1_1_1 + orl a,(___fsmul_fl1_1_1 + 1) + orl a,(___fsmul_fl1_1_1 + 2) + orl a,(___fsmul_fl1_1_1 + 3) +; Peephole 110 removed ljmp by inverse jump logic + jz 00101$ +00114$: + mov a,___fsmul_fl2_1_1 + orl a,(___fsmul_fl2_1_1 + 1) + orl a,(___fsmul_fl2_1_1 + 2) + orl a,(___fsmul_fl2_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00115$: +00101$: +; _fsmul.c 92 +; Peephole 3.a changed mov to clr +; Peephole 3.b changed mov to clr +; Peephole 3.b changed mov to clr + clr a + mov dpl,a + mov dph,a + mov b,a + ljmp 00107$ +00102$: +; _fsmul.c 95 + mov a,(___fsmul_fl1_1_1 + 3) + rl a + anl a,#0x01 + mov r2,a + mov a,(___fsmul_fl2_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r3,a + xrl a,ar2 + mov ___fsmul_sign_1_1,a +; _fsmul.c 96 + mov r3,(___fsmul_fl1_1_1 + 2) + mov a,(___fsmul_fl1_1_1 + 3) + mov c,acc.7 + xch a,r3 + rlc a + xch a,r3 + rlc a + xch a,r3 + anl a,#0x01 + jnb acc.0,00116$ + orl a,#0xfe +00116$: + mov r4,a + rlc a + subb a,acc + mov r5,a + mov r6,a + mov a,r3 + mov b,#0x00 + add a,#0x82 + mov ___fsmul_exp_1_1,a + mov a,b + addc a,#0xff + mov (___fsmul_exp_1_1 + 1),a +; _fsmul.c 97 + mov r3,(___fsmul_fl2_1_1 + 2) + mov a,(___fsmul_fl2_1_1 + 3) + mov c,acc.7 + xch a,r3 + rlc a + xch a,r3 + rlc a + xch a,r3 + anl a,#0x01 + jnb acc.0,00117$ + orl a,#0xfe +00117$: + mov r4,a + rlc a + subb a,acc + mov r7,a + mov r0,a + mov r4,#0x00 + mov a,r3 + add a,___fsmul_exp_1_1 + mov ___fsmul_exp_1_1,a + mov a,r4 + addc a,(___fsmul_exp_1_1 + 1) + mov (___fsmul_exp_1_1 + 1),a +; _fsmul.c 99 + mov r3,___fsmul_fl1_1_1 + mov r4,(___fsmul_fl1_1_1 + 1) + mov a,#0x7f + anl a,(___fsmul_fl1_1_1 + 2) + mov r1,a + mov r2,#0x00 + orl ar1,#0x80 + mov ___fsmul_fl1_1_1,r3 + mov (___fsmul_fl1_1_1 + 1),r4 + mov (___fsmul_fl1_1_1 + 2),r1 + mov (___fsmul_fl1_1_1 + 3),r2 +; _fsmul.c 100 + mov r2,___fsmul_fl2_1_1 + mov r3,(___fsmul_fl2_1_1 + 1) + mov a,#0x7f + anl a,(___fsmul_fl2_1_1 + 2) + mov r4,a + mov r1,#0x00 + orl ar4,#0x80 + mov ___fsmul_fl2_1_1,r2 + mov (___fsmul_fl2_1_1 + 1),r3 + mov (___fsmul_fl2_1_1 + 2),r4 + mov (___fsmul_fl2_1_1 + 3),r1 +; _fsmul.c 103 + mov r2,(___fsmul_fl1_1_1 + 1) + mov r3,(___fsmul_fl1_1_1 + 2) + mov a,(___fsmul_fl1_1_1 + 3) + mov r4,a + rlc a + subb a,acc + mov r1,a + mov __mulslong_PARM_2,(___fsmul_fl2_1_1 + 1) + mov (__mulslong_PARM_2 + 1),(___fsmul_fl2_1_1 + 2) + mov a,(___fsmul_fl2_1_1 + 3) + mov (__mulslong_PARM_2 + 2),a + rlc a + subb a,acc + mov (__mulslong_PARM_2 + 3),a + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r1 + lcall __mulslong + mov ___fsmul_result_1_1,dpl + mov (___fsmul_result_1_1 + 1),dph + mov (___fsmul_result_1_1 + 2),b + mov (___fsmul_result_1_1 + 3),a +; _fsmul.c 104 + mov r2,___fsmul_fl1_1_1 + mov r3,#0x00 + mov r4,#0x00 + mov r1,#0x00 + mov __mululong_PARM_2,(___fsmul_fl2_1_1 + 1) + mov (__mululong_PARM_2 + 1),(___fsmul_fl2_1_1 + 2) + mov (__mululong_PARM_2 + 2),(___fsmul_fl2_1_1 + 3) + mov (__mululong_PARM_2 + 3),#0x00 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r1 + lcall __mululong + mov r2,dpl + mov r3,dph + mov r4,b + mov r1,a + mov ar2,r3 + mov ar3,r4 + mov ar4,r1 + mov r1,#0x00 + mov a,r2 + add a,___fsmul_result_1_1 + mov ___fsmul_result_1_1,a + mov a,r3 + addc a,(___fsmul_result_1_1 + 1) + mov (___fsmul_result_1_1 + 1),a + mov a,r4 + addc a,(___fsmul_result_1_1 + 2) + mov (___fsmul_result_1_1 + 2),a + mov a,r1 + addc a,(___fsmul_result_1_1 + 3) + mov (___fsmul_result_1_1 + 3),a +; _fsmul.c 105 + mov r2,___fsmul_fl2_1_1 + mov r3,#0x00 + mov r4,#0x00 + mov r1,#0x00 + mov __mululong_PARM_2,(___fsmul_fl1_1_1 + 1) + mov (__mululong_PARM_2 + 1),(___fsmul_fl1_1_1 + 2) + mov (__mululong_PARM_2 + 2),(___fsmul_fl1_1_1 + 3) + mov (__mululong_PARM_2 + 3),#0x00 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r1 + lcall __mululong + mov r2,dpl + mov r3,dph + mov r4,b + mov r1,a + mov ar2,r3 + mov ar3,r4 + mov ar4,r1 + mov r1,#0x00 + mov a,r2 + add a,___fsmul_result_1_1 + mov ___fsmul_result_1_1,a + mov a,r3 + addc a,(___fsmul_result_1_1 + 1) + mov (___fsmul_result_1_1 + 1),a + mov a,r4 + addc a,(___fsmul_result_1_1 + 2) + mov (___fsmul_result_1_1 + 2),a + mov a,r1 + addc a,(___fsmul_result_1_1 + 3) +; _fsmul.c 107 +; Peephole 105 removed redundant mov + mov (___fsmul_result_1_1 + 3),a +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00105$ +00118$: +; _fsmul.c 110 + mov a,#0x80 + add a,___fsmul_result_1_1 + mov ___fsmul_result_1_1,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_result_1_1 + 1) + mov (___fsmul_result_1_1 + 1),a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_result_1_1 + 2) + mov (___fsmul_result_1_1 + 2),a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_result_1_1 + 3) + mov (___fsmul_result_1_1 + 3),a +; _fsmul.c 111 + mov ___fsmul_result_1_1,(___fsmul_result_1_1 + 1) + mov (___fsmul_result_1_1 + 1),(___fsmul_result_1_1 + 2) + mov (___fsmul_result_1_1 + 2),(___fsmul_result_1_1 + 3) + mov (___fsmul_result_1_1 + 3),#0x00 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fsmul.c 116 + mov a,#0x40 + add a,___fsmul_result_1_1 + mov ___fsmul_result_1_1,a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_result_1_1 + 1) + mov (___fsmul_result_1_1 + 1),a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_result_1_1 + 2) + mov (___fsmul_result_1_1 + 2),a +; Peephole 180 changed mov to clr + clr a + addc a,(___fsmul_result_1_1 + 3) + mov (___fsmul_result_1_1 + 3),a +; _fsmul.c 117 + mov a,(___fsmul_result_1_1 + 1) + mov c,acc.7 + xch a,___fsmul_result_1_1 + rlc a + xch a,___fsmul_result_1_1 + rlc a + xch a,___fsmul_result_1_1 + anl a,#0x01 + mov (___fsmul_result_1_1 + 1),a + mov a,(___fsmul_result_1_1 + 2) + add a,acc + orl a,(___fsmul_result_1_1 + 1) + mov (___fsmul_result_1_1 + 1),a + mov a,(___fsmul_result_1_1 + 3) + mov c,acc.7 + xch a,(___fsmul_result_1_1 + 2) + rlc a + xch a,(___fsmul_result_1_1 + 2) + rlc a + xch a,(___fsmul_result_1_1 + 2) + anl a,#0x01 + mov (___fsmul_result_1_1 + 3),a +; _fsmul.c 118 + dec ___fsmul_exp_1_1 + mov a,#0xff + cjne a,___fsmul_exp_1_1,00119$ + dec (___fsmul_exp_1_1 + 1) +00119$: +00106$: +; _fsmul.c 121 + anl (___fsmul_result_1_1 + 2),#0x7f +; _fsmul.c 124 + mov a,___fsmul_sign_1_1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00109$ +00120$: + mov ___fsmul_sloc0_1_0,#0x00 + mov (___fsmul_sloc0_1_0 + 1),#0x00 + mov (___fsmul_sloc0_1_0 + 2),#0x00 + mov (___fsmul_sloc0_1_0 + 3),#0x80 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00109$: + clr a + mov (___fsmul_sloc0_1_0 + 3),a + mov (___fsmul_sloc0_1_0 + 2),a + mov (___fsmul_sloc0_1_0 + 1),a + mov ___fsmul_sloc0_1_0,a +00110$: + mov r2,___fsmul_exp_1_1 + mov r3,(___fsmul_exp_1_1 + 1) + mov r4,#0x00 + mov r1,#0x00 + mov ar4,r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,r4 + rrc a + xch a,r4 + rrc a + xch a,r4 + mov r1,a +; Peephole 3.c changed mov to clr + clr a + mov r3,a + mov r2,a + mov a,___fsmul_sloc0_1_0 + orl ar2,a + mov a,(___fsmul_sloc0_1_0 + 1) + orl ar3,a + mov a,(___fsmul_sloc0_1_0 + 2) + orl ar4,a + mov a,(___fsmul_sloc0_1_0 + 3) + orl ar1,a + mov a,___fsmul_result_1_1 + orl ar2,a + mov a,(___fsmul_result_1_1 + 1) + orl ar3,a + mov a,(___fsmul_result_1_1 + 2) + orl ar4,a + mov a,(___fsmul_result_1_1 + 3) + orl ar1,a + mov ___fsmul_fl1_1_1,r2 + mov (___fsmul_fl1_1_1 + 1),r3 + mov (___fsmul_fl1_1_1 + 2),r4 + mov (___fsmul_fl1_1_1 + 3),r1 +; _fsmul.c 125 + mov dpl,___fsmul_fl1_1_1 + mov dph,(___fsmul_fl1_1_1 + 1) + mov b,(___fsmul_fl1_1_1 + 2) + mov a,(___fsmul_fl1_1_1 + 3) +00107$: + C$_fsmul.c$126$1$1 ==. + XG$__fsmul$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fsmul.cdb b/device/lib/small/_fsmul.cdb new file mode 100644 index 00000000..1d48b9c1 --- /dev/null +++ b/device/lib/small/_fsmul.cdb @@ -0,0 +1,2 @@ +M:_fsmul +F:G$__fsmul$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fsmul.rel b/device/lib/small/_fsmul.rel new file mode 100644 index 00000000..7f786829 --- /dev/null +++ b/device/lib/small/_fsmul.rel @@ -0,0 +1,522 @@ +;!FILE _fsmul.asm +XH +H 8 areas 13A global symbols +M _fsmul +S __mulslong_PARM_2 Ref0000 +S __mululong_PARM_2 Ref0000 +S __mulslong Ref0000 +S __mululong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 17 flags 0 +S ___fsmul_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 246 flags 20 +S A$_fsmul$100 Def002B +S A$_fsmul$200 Def00BD +S A$_fsmul$110 Def0030 +S A$_fsmul$300 Def0175 +S A$_fsmul$210 Def00CD +S A$_fsmul$120 Def003F +S A$_fsmul$111 Def0032 +S A$_fsmul$102 Def002D +S A$_fsmul$400 Def020D +S A$_fsmul$301 Def0177 +S A$_fsmul$220 Def00E0 +S A$_fsmul$211 Def00D0 +S A$_fsmul$202 Def00BF +S A$_fsmul$130 Def004D +S A$_fsmul$121 Def0041 +S A$_fsmul$112 Def0034 +S A$_fsmul$410 Def021A +S A$_fsmul$401 Def020E +S A$_fsmul$320 Def0194 +S A$_fsmul$311 Def0183 +S A$_fsmul$230 Def00F6 +S A$_fsmul$221 Def00E3 +S A$_fsmul$212 Def00D2 +S A$_fsmul$203 Def00C1 +S A$_fsmul$140 Def005B +S A$_fsmul$131 Def004F +S A$_fsmul$122 Def0042 +S A$_fsmul$113 Def0036 +S ___fsmul Def0000 +S A$_fsmul$420 Def022E +S A$_fsmul$411 Def021C +S A$_fsmul$312 Def0184 +S A$_fsmul$303 Def0179 +S A$_fsmul$240 Def010E +S A$_fsmul$231 Def00F9 +S A$_fsmul$222 Def00E6 +S A$_fsmul$213 Def00D4 +S A$_fsmul$204 Def00C3 +S A$_fsmul$150 Def006B +S A$_fsmul$141 Def005C +S A$_fsmul$132 Def0050 +S C$_fsmul.c$126$1$1 Def0245 +S A$_fsmul$430 Def0243 +S A$_fsmul$421 Def0230 +S A$_fsmul$412 Def021E +S A$_fsmul$403 Def020F +S A$_fsmul$340 Def01AD +S A$_fsmul$331 Def01A1 +S A$_fsmul$313 Def0186 +S A$_fsmul$304 Def017A +S A$_fsmul$250 Def0120 +S A$_fsmul$241 Def0110 +S A$_fsmul$232 Def00FC +S A$_fsmul$223 Def00E9 +S A$_fsmul$214 Def00D5 +S A$_fsmul$205 Def00C5 +S A$_fsmul$160 Def0079 +S A$_fsmul$151 Def006D +S A$_fsmul$142 Def005D +S A$_fsmul$133 Def0051 +S A$_fsmul$124 Def0044 +S A$_fsmul$422 Def0232 +S A$_fsmul$413 Def0220 +S A$_fsmul$404 Def0210 +S A$_fsmul$350 Def01BF +S A$_fsmul$341 Def01AF +S A$_fsmul$332 Def01A2 +S A$_fsmul$323 Def0196 +S A$_fsmul$305 Def017C +S A$_fsmul$260 Def012F +S A$_fsmul$251 Def0121 +S A$_fsmul$242 Def0112 +S A$_fsmul$233 Def00FF +S A$_fsmul$224 Def00EC +S A$_fsmul$215 Def00D7 +S A$_fsmul$206 Def00C6 +S A$_fsmul$170 Def0087 +S A$_fsmul$161 Def007A +S A$_fsmul$143 Def005F +S A$_fsmul$134 Def0052 +S A$_fsmul$125 Def0045 +S A$_fsmul$116 Def0039 +S A$_fsmul$423 Def0234 +S A$_fsmul$414 Def0222 +S A$_fsmul$405 Def0211 +S A$_fsmul$360 Def01D1 +S A$_fsmul$351 Def01C1 +S A$_fsmul$342 Def01B1 +S A$_fsmul$333 Def01A4 +S A$_fsmul$324 Def0198 +S A$_fsmul$315 Def0188 +S A$_fsmul$270 Def0147 +S A$_fsmul$261 Def0131 +S A$_fsmul$252 Def0123 +S A$_fsmul$243 Def0113 +S A$_fsmul$234 Def0102 +S A$_fsmul$216 Def00D9 +S A$_fsmul$207 Def00C7 +S A$_fsmul$180 Def0097 +S A$_fsmul$171 Def0089 +S A$_fsmul$162 Def007C +S A$_fsmul$153 Def006F +S A$_fsmul$144 Def0060 +S A$_fsmul$135 Def0053 +S A$_fsmul$126 Def0047 +S A$_fsmul$117 Def003B +S A$_fsmul$424 Def0236 +S A$_fsmul$415 Def0224 +S A$_fsmul$406 Def0212 +S A$_fsmul$352 Def01C3 +S A$_fsmul$343 Def01B2 +S A$_fsmul$325 Def019A +S A$_fsmul$316 Def018B +S A$_fsmul$307 Def017E +S A$_fsmul$280 Def015A +S A$_fsmul$271 Def0149 +S A$_fsmul$262 Def0133 +S A$_fsmul$253 Def0125 +S A$_fsmul$244 Def0115 +S A$_fsmul$235 Def0104 +S A$_fsmul$226 Def00EE +S A$_fsmul$217 Def00DB +S A$_fsmul$208 Def00C9 +S A$_fsmul$190 Def00A9 +S A$_fsmul$181 Def0099 +S A$_fsmul$172 Def008A +S A$_fsmul$163 Def007F +S A$_fsmul$154 Def0071 +S A$_fsmul$145 Def0061 +S A$_fsmul$136 Def0054 +S A$_fsmul$118 Def003C +S A$_fsmul$109 Def002F +S A$_fsmul$434 Def0245 +S A$_fsmul$425 Def0238 +S A$_fsmul$416 Def0226 +S A$_fsmul$407 Def0214 +S A$_fsmul$380 Def01EF +S A$_fsmul$371 Def01DF +S A$_fsmul$362 Def01D3 +S A$_fsmul$353 Def01C5 +S A$_fsmul$344 Def01B4 +S A$_fsmul$335 Def01A6 +S A$_fsmul$317 Def018E +S A$_fsmul$308 Def017F +S A$_fsmul$290 Def016B +S A$_fsmul$281 Def015C +S A$_fsmul$272 Def014A +S A$_fsmul$263 Def0135 +S A$_fsmul$254 Def0126 +S A$_fsmul$245 Def0117 +S A$_fsmul$236 Def0106 +S A$_fsmul$227 Def00F0 +S A$_fsmul$218 Def00DD +S A$_fsmul$209 Def00CA +S A$_fsmul$191 Def00AB +S A$_fsmul$182 Def009B +S A$_fsmul$173 Def008C +S A$_fsmul$155 Def0073 +S A$_fsmul$146 Def0062 +S A$_fsmul$137 Def0056 +S A$_fsmul$128 Def0049 +S A$_fsmul$119 Def003E +S A$_fsmul$417 Def0228 +S A$_fsmul$408 Def0216 +S A$_fsmul$390 Def01FE +S A$_fsmul$363 Def01D5 +S A$_fsmul$354 Def01C7 +S A$_fsmul$345 Def01B5 +S A$_fsmul$336 Def01A7 +S A$_fsmul$327 Def019C +S A$_fsmul$318 Def0191 +S A$_fsmul$309 Def0181 +S A$_fsmul$291 Def016C +S A$_fsmul$282 Def015D +S A$_fsmul$273 Def014D +S A$_fsmul$264 Def0137 +S A$_fsmul$255 Def0128 +S A$_fsmul$246 Def0119 +S A$_fsmul$237 Def0108 +S A$_fsmul$228 Def00F2 +S A$_fsmul$219 Def00DF +S A$_fsmul$192 Def00AD +S A$_fsmul$183 Def009C +S A$_fsmul$174 Def008E +S A$_fsmul$165 Def0081 +S A$_fsmul$156 Def0075 +S A$_fsmul$147 Def0065 +S A$_fsmul$138 Def0059 +S A$_fsmul$129 Def004B +S A$_fsmul$427 Def023A +S A$_fsmul$418 Def022A +S A$_fsmul$409 Def0218 +S A$_fsmul$391 Def0200 +S A$_fsmul$382 Def01F1 +S A$_fsmul$373 Def01E1 +S A$_fsmul$364 Def01D7 +S A$_fsmul$355 Def01C9 +S A$_fsmul$346 Def01B7 +S A$_fsmul$337 Def01A9 +S A$_fsmul$328 Def019D +S A$_fsmul$283 Def015F +S A$_fsmul$274 Def014F +S A$_fsmul$265 Def013A +S A$_fsmul$256 Def012A +S A$_fsmul$247 Def011B +S A$_fsmul$238 Def0109 +S A$_fsmul$229 Def00F4 +S A$_fsmul$193 Def00AF +S A$_fsmul$184 Def009E +S A$_fsmul$175 Def008F +S A$_fsmul$166 Def0082 +S A$_fsmul$157 Def0076 +S A$_fsmul$148 Def0067 +S A$_fsmul$428 Def023D +S A$_fsmul$419 Def022C +S A$_fsmul$392 Def0202 +S A$_fsmul$383 Def01F2 +S A$_fsmul$365 Def01DA +S A$_fsmul$356 Def01CA +S A$_fsmul$347 Def01B9 +S A$_fsmul$329 Def019F +S A$_fsmul$284 Def0161 +S A$_fsmul$275 Def0151 +S A$_fsmul$266 Def013D +S A$_fsmul$257 Def012B +S A$_fsmul$248 Def011C +S A$_fsmul$239 Def010C +S A$_fsmul$194 Def00B1 +S A$_fsmul$185 Def00A1 +S A$_fsmul$176 Def0091 +S A$_fsmul$167 Def0083 +S A$_fsmul$158 Def0077 +S A$_fsmul$149 Def0069 +S A$_fsmul$429 Def0240 +S A$_fsmul$393 Def0204 +S A$_fsmul$384 Def01F4 +S A$_fsmul$375 Def01E3 +S A$_fsmul$357 Def01CC +S A$_fsmul$348 Def01BB +S A$_fsmul$339 Def01AB +S A$_fsmul$294 Def016E +S A$_fsmul$285 Def0162 +S A$_fsmul$276 Def0153 +S A$_fsmul$267 Def0140 +S A$_fsmul$258 Def012D +S A$_fsmul$249 Def011E +S A$_fsmul$195 Def00B2 +S A$_fsmul$186 Def00A3 +S A$_fsmul$168 Def0085 +S A$_fsmul$159 Def0078 +S A$_fsmul$394 Def0205 +S A$_fsmul$385 Def01F6 +S A$_fsmul$376 Def01E6 +S A$_fsmul$358 Def01CD +S A$_fsmul$349 Def01BD +S A$_fsmul$286 Def0164 +S A$_fsmul$277 Def0154 +S A$_fsmul$268 Def0143 +S A$_fsmul$196 Def00B4 +S A$_fsmul$187 Def00A5 +S A$_fsmul$178 Def0093 +S A$_fsmul$169 Def0086 +S A$_fsmul$395 Def0207 +S A$_fsmul$386 Def01F8 +S A$_fsmul$377 Def01E9 +S A$_fsmul$359 Def01CF +S A$_fsmul$296 Def0170 +S A$_fsmul$287 Def0166 +S A$_fsmul$278 Def0156 +S A$_fsmul$269 Def0145 +S A$_fsmul$197 Def00B7 +S A$_fsmul$188 Def00A7 +S A$_fsmul$179 Def0095 +S XG$__fsmul$0$0 Def0245 +S A$_fsmul$396 Def0209 +S A$_fsmul$378 Def01EC +S A$_fsmul$369 Def01DC +S A$_fsmul$288 Def0167 +S A$_fsmul$279 Def0158 +S A$_fsmul$198 Def00B9 +S A$_fsmul$397 Def020A +S A$_fsmul$388 Def01FA +S A$_fsmul$289 Def0169 +S A$_fsmul$199 Def00BB +S A$_fsmul$398 Def020B +S A$_fsmul$389 Def01FC +S A$_fsmul$299 Def0173 +S A$_fsmul$399 Def020C +S A$_fsmul$80 Def0007 +S A$_fsmul$90 Def001B +S A$_fsmul$81 Def0009 +S G$__fsmul$0$0 Def0000 +S A$_fsmul$91 Def001D +S A$_fsmul$82 Def000B +S A$_fsmul$92 Def001F +S A$_fsmul$83 Def000D +S A$_fsmul$93 Def0021 +S A$_fsmul$75 Def0000 +S A$_fsmul$85 Def000F +S A$_fsmul$76 Def0002 +S A$_fsmul$95 Def0023 +S A$_fsmul$86 Def0012 +S A$_fsmul$77 Def0004 +S A$_fsmul$87 Def0015 +S A$_fsmul$78 Def0006 +S A$_fsmul$97 Def0025 +S A$_fsmul$88 Def0018 +S A$_fsmul$98 Def0027 +S A$_fsmul$99 Def0029 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 04 8B 00 05 8C +R 00 00 00 07 29 0A 00 01 29 0D 00 01 +T 00 0C 00 06 8D 00 07 85 00 00 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 11 00 08 85 00 01 00 09 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 00 16 00 02 00 0A 85 00 03 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 00 1A 00 0B E5 00 04 45 00 05 45 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 20 00 06 45 00 07 60 0A +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 25 +R 00 00 00 07 +T 00 25 E5 00 08 45 00 09 45 00 0A 45 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 2C 00 0B 70 0A +R 00 00 00 07 29 02 00 01 +T 00 2F +R 00 00 00 07 +T 00 2F +R 00 00 00 07 +T 00 2F E4 F5 82 F5 83 F5 F0 02 02 45 +R 00 00 00 07 00 0A 00 07 +T 00 39 +R 00 00 00 07 +T 00 39 E5 00 07 23 54 01 FA E5 00 0B 23 54 01 FB +R 00 00 00 07 29 03 00 01 29 0A 00 01 +T 00 45 65 02 F5 00 12 AB 00 06 E5 00 07 A2 E7 CB +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0B 00 01 +T 00 50 33 CB 33 CB 54 01 30 E0 02 44 FE +R 00 00 00 07 +T 00 5B +R 00 00 00 07 +T 00 5B FC 33 95 E0 FD FE EB 75 F0 00 24 82 F5 +R 00 00 00 07 +T 00 68 00 10 E5 F0 34 FF F5 00 11 AB 00 0A E5 +R 00 00 00 07 29 02 00 01 29 09 00 01 29 0C 00 01 +T 00 72 00 0B A2 E7 CB 33 CB 33 CB 54 01 30 E0 02 +R 00 00 00 07 29 02 00 01 +T 00 7F 44 FE +R 00 00 00 07 +T 00 81 +R 00 00 00 07 +T 00 81 FC 33 95 E0 FF F8 7C 00 EB 25 00 10 F5 +R 00 00 00 07 29 0C 00 01 +T 00 8D 00 10 EC 35 00 11 F5 00 11 AB +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 94 00 04 AC 00 05 74 7F 55 00 06 F9 7A 00 43 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 00 9F 01 80 8B 00 04 8C 00 05 89 00 06 8A +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0B 00 01 +T 00 A8 00 07 AA 00 08 AB 00 09 74 7F 55 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 B0 00 0A FC 79 00 43 04 80 8A 00 08 8B 00 09 +R 00 00 00 07 29 02 00 01 29 0B 00 01 29 0E 00 01 +T 00 BB 8C 00 0A 89 00 0B AA 00 05 AB +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 C2 00 06 E5 00 07 FC 33 95 E0 F9 85 00 09 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0D 00 01 +T 00 CC 00 00 85 00 0A 00 01 E5 +R 00 00 00 07 2B 02 00 00 29 05 00 01 2B 07 00 00 +T 00 D1 00 0B F5 00 02 33 95 E0 F5 00 03 8A 82 8B +R 00 00 00 07 29 02 00 01 2B 05 00 00 2B 0B 00 00 +T 00 DC 83 8C F0 E9 12 00 00 85 82 00 0C 85 83 +R 00 00 00 07 02 07 00 02 29 0B 00 01 +T 00 E8 00 0D 85 F0 00 0E F5 00 0F AA +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 EF 00 04 7B 00 7C 00 79 00 85 00 09 00 00 85 +R 00 00 00 07 29 02 00 01 29 0B 00 01 2B 0D 00 01 +T 00 FA 00 0A 00 01 85 00 0B +R 00 00 00 07 29 02 00 01 2B 04 00 01 29 07 00 01 +T 00 FE 00 02 75 00 03 00 8A 82 8B 83 8C F0 E9 12 +R 00 00 00 07 2B 02 00 01 2B 05 00 01 +T 01 0A 00 00 AA 82 AB 83 AC F0 F9 8B 02 8C 03 89 +R 00 00 00 07 02 02 00 03 +T 01 18 04 79 00 EA 25 00 0C F5 00 0C EB 35 00 0D +R 00 00 00 07 29 07 00 01 29 0A 00 01 29 0E 00 01 +T 01 23 F5 00 0D EC 35 00 0E F5 00 0E E9 35 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0A 00 01 +T 01 2C 00 0F F5 00 0F AA 00 08 7B 00 7C 00 79 00 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 37 85 00 05 00 00 85 00 06 +R 00 00 00 07 29 03 00 01 2B 05 00 01 29 08 00 01 +T 01 3C 00 01 85 00 07 00 02 75 +R 00 00 00 07 2B 02 00 01 29 05 00 01 2B 07 00 01 +T 01 41 00 03 00 8A 82 8B 83 8C F0 E9 12 00 00 AA +R 00 00 00 07 2B 02 00 01 02 0D 00 03 +T 01 4E 82 AB 83 AC F0 F9 8B 02 8C 03 89 04 79 00 +R 00 00 00 07 +T 01 5C EA 25 00 0C F5 00 0C EB 35 00 0D F5 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0B 00 01 +T 01 65 00 0D EC 35 00 0E F5 00 0E E9 35 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 6D 00 0F F5 00 0F 30 E7 23 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 01 73 +R 00 00 00 07 +T 01 73 74 80 25 00 0C F5 00 0C E4 35 00 0D F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 01 7D 00 0D E4 35 00 0E F5 00 0E E4 35 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 85 00 0F F5 00 0F 85 00 0D +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 8A 00 0C 85 00 0E 00 0D 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 01 8F 00 0F 00 0E 75 00 0F 00 80 46 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 01 96 +R 00 00 00 07 +T 01 96 74 40 25 00 0C F5 00 0C E4 35 00 0D F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 01 A0 00 0D E4 35 00 0E F5 00 0E E4 35 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 01 A8 00 0F F5 00 0F E5 00 0D A2 E7 C5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 B0 00 0C 33 C5 00 0C 33 C5 00 0C 54 01 F5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 01 BA 00 0D E5 00 0E 25 E0 45 00 0D F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 01 C2 00 0D E5 00 0F A2 E7 C5 00 0E 33 C5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 0A 00 01 +T 01 CB 00 0E 33 C5 00 0E 54 01 F5 00 0F 15 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0B 00 01 +T 01 D4 00 10 74 FF B5 00 10 02 15 00 11 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0B 00 01 +T 01 DC +R 00 00 00 07 +T 01 DC +R 00 00 00 07 +T 01 DC 53 00 0E 7F E5 00 12 60 0E +R 00 00 00 07 09 03 00 01 29 07 00 01 +T 01 E3 +R 00 00 00 07 +T 01 E3 75 00 13 00 75 00 14 00 75 00 15 00 75 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 01 ED 00 16 80 80 09 +R 00 00 00 07 29 02 00 01 +T 01 F1 +R 00 00 00 07 +T 01 F1 E4 F5 00 16 F5 00 15 F5 00 14 F5 +R 00 00 00 07 29 04 00 01 29 07 00 01 29 0A 00 01 +T 01 F9 00 13 +R 00 00 00 07 29 02 00 01 +T 01 FA +R 00 00 00 07 +T 01 FA AA 00 10 AB 00 11 7C 00 79 00 8A 04 EB 54 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 02 06 01 A2 E0 CC 13 CC 13 CC F9 E4 FB FA E5 +R 00 00 00 07 +T 02 13 00 13 42 02 E5 00 14 42 03 E5 00 15 42 04 +R 00 00 00 07 29 02 00 01 29 07 00 01 29 0C 00 01 +T 02 1E E5 00 16 42 01 E5 00 0C 42 02 E5 00 0D 42 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0D 00 01 +T 02 29 03 E5 00 0E 42 04 E5 00 0F 42 01 8A 00 04 +R 00 00 00 07 29 04 00 01 29 09 00 01 29 0E 00 01 +T 02 34 8B 00 05 8C 00 06 89 00 07 85 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 02 3B 00 04 82 85 00 05 83 85 00 06 F0 E5 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 02 44 00 07 +R 00 00 00 07 29 02 00 01 +T 02 45 +R 00 00 00 07 +T 02 45 22 +R 00 00 00 07 diff --git a/device/lib/small/_fsneq.asm b/device/lib/small/_fsneq.asm new file mode 100644 index 00000000..9ab23020 --- /dev/null +++ b/device/lib/small/_fsneq.asm @@ -0,0 +1,147 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _fsneq +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fsneq_PARM_2 + .globl ___fsneq +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___fsneq_PARM_2: + .ds 0x0004 +___fsneq_fl1_1_1: + .ds 0x0004 +___fsneq_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fsneq$0$0 ==. +; _fsneq.c 73 +; ----------------------------------------- +; function __fsneq +; ----------------------------------------- +___fsneq: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fsneq.c 87 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fsneq.c 77 + mov ___fsneq_fl1_1_1,r2 + mov (___fsneq_fl1_1_1 + 1),r3 + mov (___fsneq_fl1_1_1 + 2),r4 + mov (___fsneq_fl1_1_1 + 3),r5 +; _fsneq.c 78 + mov ___fsneq_fl2_1_1,___fsneq_PARM_2 + mov (___fsneq_fl2_1_1 + 1),(___fsneq_PARM_2 + 1) + mov (___fsneq_fl2_1_1 + 2),(___fsneq_PARM_2 + 2) + mov (___fsneq_fl2_1_1 + 3),(___fsneq_PARM_2 + 3) +; _fsneq.c 80 + mov a,(___fsneq_fl1_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00111$: + mov a,(___fsneq_fl2_1_1 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r2,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00112$: +; _fsneq.c 82 + mov r2,___fsneq_fl1_1_1 + mov r3,(___fsneq_fl1_1_1 + 1) + mov r4,(___fsneq_fl1_1_1 + 2) + mov a,#0x80 + xrl a,(___fsneq_fl1_1_1 + 3) + mov r5,a + mov ___fsneq_fl1_1_1,r2 + mov (___fsneq_fl1_1_1 + 1),r3 + mov (___fsneq_fl1_1_1 + 2),r4 + mov (___fsneq_fl1_1_1 + 3),r5 +; _fsneq.c 83 + mov r2,___fsneq_fl2_1_1 + mov r3,(___fsneq_fl2_1_1 + 1) + mov r4,(___fsneq_fl2_1_1 + 2) + mov a,#0x80 + xrl a,(___fsneq_fl2_1_1 + 3) + mov r5,a + mov ___fsneq_fl2_1_1,r2 + mov (___fsneq_fl2_1_1 + 1),r3 + mov (___fsneq_fl2_1_1 + 2),r4 + mov (___fsneq_fl2_1_1 + 3),r5 +00102$: +; _fsneq.c 85 + mov a,___fsneq_fl1_1_1 +; Peephole 132 changed ljmp to sjmp +; Peephole 193 optimized misc jump sequence + cjne a,___fsneq_fl2_1_1,00105$ + mov a,(___fsneq_fl1_1_1 + 1) + cjne a,(___fsneq_fl2_1_1 + 1),00105$ + mov a,(___fsneq_fl1_1_1 + 2) + cjne a,(___fsneq_fl2_1_1 + 2),00105$ + mov a,(___fsneq_fl1_1_1 + 3) + cjne a,(___fsneq_fl2_1_1 + 3),00105$ +; Peephole 201 removed redundant sjmp +00113$: +00114$: +; _fsneq.c 86 + mov dpl,#0x00 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _fsneq.c 87 + mov dpl,#0x01 +00106$: + C$_fsneq.c$88$1$1 ==. + XG$__fsneq$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fsneq.cdb b/device/lib/small/_fsneq.cdb new file mode 100644 index 00000000..b9f0060d --- /dev/null +++ b/device/lib/small/_fsneq.cdb @@ -0,0 +1,2 @@ +M:_fsneq +F:G$__fsneq$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fsneq.rel b/device/lib/small/_fsneq.rel new file mode 100644 index 00000000..cfdb5663 --- /dev/null +++ b/device/lib/small/_fsneq.rel @@ -0,0 +1,136 @@ +;!FILE _fsneq.asm +XH +H 9 areas 3B global symbols +M _fsneq +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +S ___fsneq_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 6E flags 20 +S A$_fsneq$146 Def006D +S A$_fsneq$137 Def0065 +S A$_fsneq$128 Def0058 +S A$_fsneq$119 Def004D +S A$_fsneq$129 Def005B +S A$_fsneq$139 Def0068 +S XG$__fsneq$0$0 Def006D +S A$_fsneq$70 Def0004 +S A$_fsneq$80 Def0015 +S A$_fsneq$71 Def0006 +S A$_fsneq$81 Def0018 +S G$__fsneq$0$0 Def0000 +S A$_fsneq$91 Def0023 +S A$_fsneq$73 Def0007 +S A$_fsneq$92 Def0025 +S A$_fsneq$83 Def001B +S A$_fsneq$74 Def0009 +S A$_fsneq$93 Def0026 +S A$_fsneq$84 Def001D +S A$_fsneq$75 Def000B +S A$_fsneq$85 Def001E +S A$_fsneq$76 Def000D +S C$_fsneq.c$88$1$1 Def006D +S A$_fsneq$95 Def0028 +S A$_fsneq$68 Def0000 +S A$_fsneq$87 Def0020 +S A$_fsneq$78 Def000F +S A$_fsneq$69 Def0002 +S A$_fsneq$97 Def0029 +S A$_fsneq$79 Def0012 +S A$_fsneq$89 Def0021 +S A$_fsneq$100 Def002B +S A$_fsneq$101 Def002D +S A$_fsneq$120 Def004F +S A$_fsneq$111 Def003E +S A$_fsneq$102 Def002F +S A$_fsneq$130 Def005D +S A$_fsneq$112 Def0040 +S A$_fsneq$103 Def0031 +S A$_fsneq$131 Def0060 +S A$_fsneq$113 Def0042 +S A$_fsneq$104 Def0033 +S ___fsneq Def0000 +S A$_fsneq$132 Def0062 +S A$_fsneq$123 Def0051 +S A$_fsneq$114 Def0044 +S A$_fsneq$105 Def0035 +S A$_fsneq$142 Def006A +S A$_fsneq$115 Def0046 +S A$_fsneq$106 Def0036 +S A$_fsneq$116 Def0048 +S A$_fsneq$107 Def0038 +S A$_fsneq$126 Def0053 +S A$_fsneq$117 Def0049 +S A$_fsneq$108 Def003A +S A$_fsneq$127 Def0056 +S A$_fsneq$118 Def004B +S A$_fsneq$109 Def003C +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 0A 00 03 29 0D 00 03 +T 00 0C 00 06 8D 00 07 85 00 00 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 11 00 08 85 00 01 00 09 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 16 00 02 00 0A 85 00 03 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 1A 00 0B E5 00 07 23 54 01 FA 60 2E +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 23 +R 00 00 00 08 +T 00 23 E5 00 0B 23 54 01 FA 60 26 +R 00 00 00 08 29 03 00 03 +T 00 2B +R 00 00 00 08 +T 00 2B AA 00 04 AB 00 05 AC 00 06 74 80 65 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 34 00 07 FD 8A 00 04 8B 00 05 8C +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 3B 00 06 8D 00 07 AA 00 08 AB +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 41 00 09 AC 00 0A 74 80 65 00 0B FD 8A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0A 00 03 +T 00 4A 00 08 8B 00 09 8C 00 0A 8D +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 50 00 0B +R 00 00 00 08 29 02 00 03 +T 00 51 +R 00 00 00 08 +T 00 51 E5 00 04 B5 00 08 14 E5 00 05 B5 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 0A 00 03 +T 00 59 00 09 0F E5 00 06 B5 00 0A 0A E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 61 00 07 B5 00 0B 05 +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 65 +R 00 00 00 08 +T 00 65 +R 00 00 00 08 +T 00 65 75 82 00 80 03 +R 00 00 00 08 +T 00 6A +R 00 00 00 08 +T 00 6A 75 82 01 +R 00 00 00 08 +T 00 6D +R 00 00 00 08 +T 00 6D 22 +R 00 00 00 08 diff --git a/device/lib/small/_fssub.asm b/device/lib/small/_fssub.asm new file mode 100644 index 00000000..ac597bf1 --- /dev/null +++ b/device/lib/small/_fssub.asm @@ -0,0 +1,140 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _fssub +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___fssub_PARM_2 + .globl ___fssub +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +___fssub_PARM_2: + .ds 0x0004 +___fssub_fl1_1_1: + .ds 0x0004 +___fssub_fl2_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__fssub$0$0 ==. +; _fssub.c 81 +; ----------------------------------------- +; function __fssub +; ----------------------------------------- +___fssub: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _fssub.c 96 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _fssub.c 85 + mov ___fssub_fl1_1_1,r2 + mov (___fssub_fl1_1_1 + 1),r3 + mov (___fssub_fl1_1_1 + 2),r4 + mov (___fssub_fl1_1_1 + 3),r5 +; _fssub.c 86 + mov ___fssub_fl2_1_1,___fssub_PARM_2 + mov (___fssub_fl2_1_1 + 1),(___fssub_PARM_2 + 1) + mov (___fssub_fl2_1_1 + 2),(___fssub_PARM_2 + 2) + mov (___fssub_fl2_1_1 + 3),(___fssub_PARM_2 + 3) +; _fssub.c 89 + mov a,___fssub_fl2_1_1 + orl a,(___fssub_fl2_1_1 + 1) + orl a,(___fssub_fl2_1_1 + 2) + orl a,(___fssub_fl2_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00109$: +; _fssub.c 90 + mov dpl,___fssub_fl1_1_1 + mov dph,(___fssub_fl1_1_1 + 1) + mov b,(___fssub_fl1_1_1 + 2) + mov a,(___fssub_fl1_1_1 + 3) +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00102$: +; _fssub.c 91 + mov a,___fssub_fl1_1_1 + orl a,(___fssub_fl1_1_1 + 1) + orl a,(___fssub_fl1_1_1 + 2) + orl a,(___fssub_fl1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00110$: +; _fssub.c 92 + mov a,(___fssub_fl2_1_1 + 3) + cpl acc.7 + mov dpl,___fssub_fl2_1_1 + mov dph,(___fssub_fl2_1_1 + 1) + mov b,(___fssub_fl2_1_1 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00104$: +; _fssub.c 95 + mov r2,___fssub_fl2_1_1 + mov r3,(___fssub_fl2_1_1 + 1) + mov r4,(___fssub_fl2_1_1 + 2) + mov a,#0x80 + xrl a,(___fssub_fl2_1_1 + 3) + mov r5,a + mov ___fssub_fl2_1_1,r2 + mov (___fssub_fl2_1_1 + 1),r3 + mov (___fssub_fl2_1_1 + 2),r4 + mov (___fssub_fl2_1_1 + 3),r5 +; _fssub.c 96 + mov ___fsadd_PARM_2,___fssub_fl2_1_1 + mov (___fsadd_PARM_2 + 1),(___fssub_fl2_1_1 + 1) + mov (___fsadd_PARM_2 + 2),(___fssub_fl2_1_1 + 2) + mov (___fsadd_PARM_2 + 3),(___fssub_fl2_1_1 + 3) + mov dpl,___fssub_fl1_1_1 + mov dph,(___fssub_fl1_1_1 + 1) + mov b,(___fssub_fl1_1_1 + 2) + mov a,(___fssub_fl1_1_1 + 3) + lcall ___fsadd + C$_fssub.c$97$1$1 ==. + XG$__fssub$0$0 ==. +; Peephole 156 removed misc moves via dph, dpl, b, a before return +00105$: + ret + .area CSEG (CODE) diff --git a/device/lib/small/_fssub.cdb b/device/lib/small/_fssub.cdb new file mode 100644 index 00000000..43bfd1ea --- /dev/null +++ b/device/lib/small/_fssub.cdb @@ -0,0 +1,2 @@ +M:_fssub +F:G$__fssub$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_fssub.rel b/device/lib/small/_fssub.rel new file mode 100644 index 00000000..81376290 --- /dev/null +++ b/device/lib/small/_fssub.rel @@ -0,0 +1,136 @@ +;!FILE _fssub.asm +XH +H 8 areas 3C global symbols +M _fssub +S ___fsadd Ref0000 +S ___fsadd_PARM_2 Ref0000 +A _CODE size 0 flags 0 +A DSEG size C flags 0 +S ___fssub_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 79 flags 20 +S A$_fssub$131 Def006D +S A$_fssub$122 Def0058 +S ___fssub Def0000 +S A$_fssub$132 Def0070 +S A$_fssub$123 Def005A +S A$_fssub$133 Def0073 +S A$_fssub$124 Def005C +S A$_fssub$115 Def004B +S A$_fssub$106 Def003C +S A$_fssub$134 Def0075 +S A$_fssub$116 Def004D +S A$_fssub$107 Def003E +S A$_fssub$126 Def005E +S A$_fssub$117 Def004F +S A$_fssub$108 Def0040 +S A$_fssub$127 Def0061 +S A$_fssub$118 Def0051 +S A$_fssub$109 Def0043 +S A$_fssub$128 Def0064 +S A$_fssub$119 Def0053 +S A$_fssub$129 Def0067 +S A$_fssub$139 Def0078 +S XG$__fssub$0$0 Def0078 +S A$_fssub$70 Def0006 +S A$_fssub$80 Def0018 +S A$_fssub$90 Def0025 +S A$_fssub$72 Def0007 +S G$__fssub$0$0 Def0000 +S A$_fssub$91 Def0028 +S A$_fssub$82 Def001B +S A$_fssub$73 Def0009 +S A$_fssub$92 Def002B +S A$_fssub$83 Def001D +S A$_fssub$74 Def000B +S A$_fssub$93 Def002E +S A$_fssub$84 Def001F +S A$_fssub$75 Def000D +S A$_fssub$85 Def0021 +S A$_fssub$67 Def0000 +S C$_fssub.c$97$1$1 Def0078 +S A$_fssub$95 Def0030 +S A$_fssub$77 Def000F +S A$_fssub$68 Def0002 +S A$_fssub$87 Def0023 +S A$_fssub$78 Def0012 +S A$_fssub$69 Def0004 +S A$_fssub$79 Def0015 +S A$_fssub$98 Def0032 +S A$_fssub$99 Def0034 +S A$_fssub$100 Def0036 +S A$_fssub$110 Def0046 +S A$_fssub$101 Def0038 +S A$_fssub$120 Def0055 +S A$_fssub$130 Def006A +S A$_fssub$121 Def0056 +S A$_fssub$112 Def0049 +S A$_fssub$103 Def003A +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 FD 8A 00 04 8B 00 05 8C +R 00 00 00 07 29 0A 00 01 29 0D 00 01 +T 00 0C 00 06 8D 00 07 85 00 00 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 11 00 08 85 00 01 00 09 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 00 16 00 02 00 0A 85 00 03 +R 00 00 00 07 29 02 00 01 29 04 00 01 29 07 00 01 +T 00 1A 00 0B E5 00 08 45 00 09 45 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 20 00 0A 45 00 0B 70 0D +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 25 +R 00 00 00 07 +T 00 25 85 00 04 82 85 00 05 83 85 00 06 F0 E5 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 2F 00 07 80 46 +R 00 00 00 07 29 02 00 01 +T 00 32 +R 00 00 00 07 +T 00 32 E5 00 04 45 00 05 45 00 06 45 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 39 00 07 70 0F +R 00 00 00 07 29 02 00 01 +T 00 3C +R 00 00 00 07 +T 00 3C E5 00 0B B2 E7 85 00 08 82 85 00 09 83 85 +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0C 00 01 +T 00 47 00 0A F0 80 2D +R 00 00 00 07 29 02 00 01 +T 00 4B +R 00 00 00 07 +T 00 4B AA 00 08 AB 00 09 AC 00 0A 74 80 65 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 54 00 0B FD 8A 00 08 8B 00 09 8C +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 5B 00 0A 8D 00 0B 85 00 08 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 60 00 00 85 00 09 00 01 85 +R 00 00 00 07 2B 02 00 01 29 05 00 01 2B 07 00 01 +T 00 65 00 0A 00 02 85 00 0B +R 00 00 00 07 29 02 00 01 2B 04 00 01 29 07 00 01 +T 00 69 00 03 85 00 04 82 85 00 05 83 85 +R 00 00 00 07 2B 02 00 01 29 05 00 01 29 09 00 01 +T 00 71 00 06 F0 E5 00 07 12 00 00 +R 00 00 00 07 29 02 00 01 29 06 00 01 02 09 00 00 +T 00 78 +R 00 00 00 07 +T 00 78 22 +R 00 00 00 07 diff --git a/device/lib/small/_gptrget.asm b/device/lib/small/_gptrget.asm new file mode 100644 index 00000000..65e5007f --- /dev/null +++ b/device/lib/small/_gptrget.asm @@ -0,0 +1,116 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _gptrget +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __gptrget +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_gptrget$0$0 ==. +; _gptrget.c 26 +; ----------------------------------------- +; function _gptrget +; ----------------------------------------- +__gptrget: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _gptrget.c 81 + ; save values passed + xch a,r0 + push acc + ; + ; depending on the pointer type + ; + mov a,b + jz 00001$ + dec a + jz 00002$ + dec a + jz 00003$ + dec a + jz 00004$ + ; + ; any other value for type + ; return xFF + mov a,#0xff + sjmp 00005$ + ; + ; Pointer to data space + ; + 00001$: + mov r0,dpl ; use only low order address + mov a,@r0 + sjmp 00005$ + ; + ; pointer to xternal data + ; + 00002$: + movx a,@dptr + sjmp 00005$ +; +; pointer to code area +; + 00003$: + clr a + movc a,@a+dptr + sjmp 00005$ +; +; pointer to xternal stack +; + 00004$: + mov r0,dpl + movx a,@r0 +; +; restore and return +; + 00005$: + mov r0,a + pop acc + xch a,r0 +00101$: + C$_gptrget.c$83$1$1 ==. + XG$_gptrget$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_gptrget.cdb b/device/lib/small/_gptrget.cdb new file mode 100644 index 00000000..1bfacfe1 --- /dev/null +++ b/device/lib/small/_gptrget.cdb @@ -0,0 +1,2 @@ +M:_gptrget +F:G$_gptrget$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/small/_gptrget.rel b/device/lib/small/_gptrget.rel new file mode 100644 index 00000000..dce6cdb4 --- /dev/null +++ b/device/lib/small/_gptrget.rel @@ -0,0 +1,72 @@ +;!FILE _gptrget.asm +XH +H 8 areas 1E global symbols +M _gptrget +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 28 flags 20 +S XG$_gptrget$0$0 Def0027 +S G$_gptrget$0$0 Def0000 +S A$_gptrget$110 Def0024 +S A$_gptrget$111 Def0026 +S A$_gptrget$103 Def0020 +S A$_gptrget$104 Def0022 +S A$_gptrget$115 Def0027 +S A$_gptrget$109 Def0023 +S A$_gptrget$70 Def000A +S A$_gptrget$61 Def0000 +S A$_gptrget$71 Def000B +S A$_gptrget$62 Def0001 +S C$_gptrget.c$83$1$1 Def0027 +S A$_gptrget$90 Def0019 +S A$_gptrget$72 Def000D +S A$_gptrget$91 Def001A +S A$_gptrget$73 Def000E +S A$_gptrget$83 Def0014 +S A$_gptrget$84 Def0016 +S A$_gptrget$66 Def0003 +S A$_gptrget$85 Def0017 +S A$_gptrget$67 Def0005 +S A$_gptrget$77 Def0010 +S A$_gptrget$68 Def0007 +S A$_gptrget$96 Def001C +S A$_gptrget$78 Def0012 +S A$_gptrget$69 Def0008 +S A$_gptrget$97 Def001D +S A$_gptrget$98 Def001E +S __gptrget Def0000 +T 00 00 +R 00 00 00 07 +T 00 00 C8 C0 E0 E5 F0 60 0D 14 60 0F 14 60 0F 14 +R 00 00 00 07 +T 00 0E 60 10 74 FF 80 0F +R 00 00 00 07 +T 00 14 +R 00 00 00 07 +T 00 14 A8 82 E6 80 0A +R 00 00 00 07 +T 00 19 +R 00 00 00 07 +T 00 19 E0 80 07 +R 00 00 00 07 +T 00 1C +R 00 00 00 07 +T 00 1C E4 93 80 03 +R 00 00 00 07 +T 00 20 +R 00 00 00 07 +T 00 20 A8 82 E2 +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 F8 D0 E0 C8 +R 00 00 00 07 +T 00 27 +R 00 00 00 07 +T 00 27 22 +R 00 00 00 07 diff --git a/device/lib/small/_gptrput.asm b/device/lib/small/_gptrput.asm new file mode 100644 index 00000000..43437b29 --- /dev/null +++ b/device/lib/small/_gptrput.asm @@ -0,0 +1,104 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _gptrput +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __gptrput +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_gptrput$0$0 ==. +; _gptrput.c 26 +; ----------------------------------------- +; function _gptrput +; ----------------------------------------- +__gptrput: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _gptrput.c 72 + xch a,r0 + push acc + xch a,r0 + push acc + ; + ; depending on the pointer type + ; + mov a,b + jz 00001$ + dec a + jz 00002$ + dec a + jz 00003$ + dec a + jz 00004$ + pop acc + sjmp 00005$ +; +; store into near space +; + 00001$: + pop acc + mov r0,dpl + mov @r0,a + sjmp 00005$ + 00002$: + pop acc + movx @dptr,a + sjmp 00005$ + 00003$: + pop acc ; do nothing + sjmp 00005$ + 00004$: + pop acc + mov r0,dpl + movx @r0,a + 00005$: + xch a,r0 + pop acc + xch a,r0 +00101$: + C$_gptrput.c$73$1$1 ==. + XG$_gptrput$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_gptrput.cdb b/device/lib/small/_gptrput.cdb new file mode 100644 index 00000000..32b5fe30 --- /dev/null +++ b/device/lib/small/_gptrput.cdb @@ -0,0 +1,2 @@ +M:_gptrput +F:G$_gptrput$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/small/_gptrput.rel b/device/lib/small/_gptrput.rel new file mode 100644 index 00000000..d690979e --- /dev/null +++ b/device/lib/small/_gptrput.rel @@ -0,0 +1,76 @@ +;!FILE _gptrput.asm +XH +H 8 areas 22 global symbols +M _gptrput +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 31 flags 20 +S A$_gptrput$60 Def0000 +S A$_gptrput$70 Def000B +S A$_gptrput$61 Def0001 +S C$_gptrput.c$73$1$1 Def0030 +S A$_gptrput$71 Def000D +S A$_gptrput$62 Def0003 +S A$_gptrput$90 Def0023 +S A$_gptrput$81 Def0017 +S A$_gptrput$72 Def000E +S A$_gptrput$63 Def0004 +S A$_gptrput$91 Def0025 +S A$_gptrput$82 Def0019 +S A$_gptrput$73 Def0010 +S A$_gptrput$83 Def001B +S A$_gptrput$74 Def0011 +S A$_gptrput$93 Def0027 +S A$_gptrput$84 Def001C +S A$_gptrput$75 Def0013 +S A$_gptrput$94 Def0029 +S A$_gptrput$76 Def0015 +S A$_gptrput$67 Def0006 +S A$_gptrput$95 Def002B +S A$_gptrput$86 Def001E +S A$_gptrput$68 Def0008 +S A$_gptrput$87 Def0020 +S A$_gptrput$69 Def000A +S A$_gptrput$97 Def002C +S A$_gptrput$88 Def0021 +S A$_gptrput$98 Def002D +S A$_gptrput$99 Def002F +S __gptrput Def0000 +S XG$_gptrput$0$0 Def0030 +S G$_gptrput$0$0 Def0000 +S A$_gptrput$103 Def0030 +T 00 00 +R 00 00 00 07 +T 00 00 C8 C0 E0 C8 C0 E0 E5 F0 60 0D 14 60 11 14 +R 00 00 00 07 +T 00 0E 60 13 14 60 14 D0 E0 80 15 +R 00 00 00 07 +T 00 17 +R 00 00 00 07 +T 00 17 D0 E0 A8 82 F6 80 0E +R 00 00 00 07 +T 00 1E +R 00 00 00 07 +T 00 1E D0 E0 F0 80 09 +R 00 00 00 07 +T 00 23 +R 00 00 00 07 +T 00 23 D0 E0 80 05 +R 00 00 00 07 +T 00 27 +R 00 00 00 07 +T 00 27 D0 E0 A8 82 F2 +R 00 00 00 07 +T 00 2C +R 00 00 00 07 +T 00 2C C8 D0 E0 C8 +R 00 00 00 07 +T 00 30 +R 00 00 00 07 +T 00 30 22 +R 00 00 00 07 diff --git a/device/lib/small/_int2fs.asm b/device/lib/small/_int2fs.asm new file mode 100644 index 00000000..3b99b535 --- /dev/null +++ b/device/lib/small/_int2fs.asm @@ -0,0 +1,215 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _int2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___int2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___int2fs_sign_1_1: + .ds 0x0004 +___int2fs_fl_1_1: + .ds 0x0004 +___int2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__int2fs$0$0 ==. +; _int2fs.c 80 +; ----------------------------------------- +; function __int2fs +; ----------------------------------------- +___int2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _int2fs.c 110 + mov r2,dpl + mov r3,dph +; _int2fs.c 82 + clr a + mov (___int2fs_sign_1_1 + 3),a + mov (___int2fs_sign_1_1 + 2),a + mov (___int2fs_sign_1_1 + 1),a + mov ___int2fs_sign_1_1,a +; _int2fs.c 85 + mov ___int2fs_a1_1_1,r2 + mov (___int2fs_a1_1_1 + 1),r3 + mov a,r3 + rlc a + subb a,acc + mov (___int2fs_a1_1_1 + 2),a + mov (___int2fs_a1_1_1 + 3),a +; _int2fs.c 87 + mov a,___int2fs_a1_1_1 + orl a,(___int2fs_a1_1_1 + 1) + orl a,(___int2fs_a1_1_1 + 2) + orl a,(___int2fs_a1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _int2fs.c 89 + mov ___int2fs_fl_1_1,#0x00 + mov (___int2fs_fl_1_1 + 1),#0x00 + mov (___int2fs_fl_1_1 + 2),#0x00 + mov (___int2fs_fl_1_1 + 3),#0x00 +; _int2fs.c 90 + mov dpl,___int2fs_fl_1_1 + mov dph,(___int2fs_fl_1_1 + 1) + mov b,(___int2fs_fl_1_1 + 2) + mov a,(___int2fs_fl_1_1 + 3) + ljmp 00108$ +00102$: +; _int2fs.c 93 + mov a,(___int2fs_a1_1_1 + 3) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _int2fs.c 95 + mov ___int2fs_sign_1_1,#0x00 + mov (___int2fs_sign_1_1 + 1),#0x00 + mov (___int2fs_sign_1_1 + 2),#0x00 + mov (___int2fs_sign_1_1 + 3),#0x80 +; _int2fs.c 96 + clr c + clr a + subb a,___int2fs_a1_1_1 + mov ___int2fs_a1_1_1,a + clr a + subb a,(___int2fs_a1_1_1 + 1) + mov (___int2fs_a1_1_1 + 1),a + clr a + subb a,(___int2fs_a1_1_1 + 2) + mov (___int2fs_a1_1_1 + 2),a + clr a + subb a,(___int2fs_a1_1_1 + 3) + mov (___int2fs_a1_1_1 + 3),a +; _int2fs.c 99 +00113$: + mov r4,#0x96 + mov r5,#0x00 +00105$: + clr c + mov a,___int2fs_a1_1_1 + subb a,#0x00 + mov a,(___int2fs_a1_1_1 + 1) + subb a,#0x00 + mov a,(___int2fs_a1_1_1 + 2) + subb a,#0x80 + mov a,(___int2fs_a1_1_1 + 3) + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _int2fs.c 101 + mov a,___int2fs_a1_1_1 + add a,acc + mov ___int2fs_a1_1_1,a + mov a,(___int2fs_a1_1_1 + 1) + rlc a + mov (___int2fs_a1_1_1 + 1),a + mov a,(___int2fs_a1_1_1 + 2) + rlc a + mov (___int2fs_a1_1_1 + 2),a + mov a,(___int2fs_a1_1_1 + 3) + rlc a + mov (___int2fs_a1_1_1 + 3),a +; _int2fs.c 102 + dec r4 + cjne r4,#0xff,00117$ + dec r5 +00117$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _int2fs.c 105 + anl (___int2fs_a1_1_1 + 2),#0x7f +; _int2fs.c 108 + mov r6,#0x00 + mov r7,#0x00 + mov ar6,r4 + mov a,r5 + anl a,#0x01 + mov c,acc.0 + xch a,r6 + rrc a + xch a,r6 + rrc a + xch a,r6 + mov r7,a + mov r5,#0x00 + mov r4,#0x00 + mov r2,___int2fs_sign_1_1 + mov r3,(___int2fs_sign_1_1 + 1) + mov r0,(___int2fs_sign_1_1 + 2) + mov r1,(___int2fs_sign_1_1 + 3) + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov a,___int2fs_a1_1_1 + orl ar4,a + mov a,(___int2fs_a1_1_1 + 1) + orl ar5,a + mov a,(___int2fs_a1_1_1 + 2) + orl ar6,a + mov a,(___int2fs_a1_1_1 + 3) + orl ar7,a + mov ___int2fs_fl_1_1,r4 + mov (___int2fs_fl_1_1 + 1),r5 + mov (___int2fs_fl_1_1 + 2),r6 + mov (___int2fs_fl_1_1 + 3),r7 +; _int2fs.c 110 + mov dpl,___int2fs_fl_1_1 + mov dph,(___int2fs_fl_1_1 + 1) + mov b,(___int2fs_fl_1_1 + 2) + mov a,(___int2fs_fl_1_1 + 3) +00108$: + C$_int2fs.c$111$1$1 ==. + XG$__int2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_int2fs.cdb b/device/lib/small/_int2fs.cdb new file mode 100644 index 00000000..7e5497af --- /dev/null +++ b/device/lib/small/_int2fs.cdb @@ -0,0 +1,2 @@ +M:_int2fs +F:G$__int2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_int2fs.rel b/device/lib/small/_int2fs.rel new file mode 100644 index 00000000..09e1e0f6 --- /dev/null +++ b/device/lib/small/_int2fs.rel @@ -0,0 +1,224 @@ +;!FILE _int2fs.asm +XH +H 9 areas 7B global symbols +M _int2fs +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size E6 flags 20 +S A$_int2fs$198 Def00CA +S A$_int2fs$189 Def00BA +S A$_int2fs$199 Def00CC +S A$_int2fs$70 Def0004 +S A$_int2fs$80 Def0013 +S A$_int2fs$71 Def0005 +S A$_int2fs$81 Def0015 +S A$_int2fs$72 Def0007 +S G$__int2fs$0$0 Def0000 +S A$_int2fs$82 Def0017 +S A$_int2fs$73 Def0009 +S A$_int2fs$92 Def0023 +S A$_int2fs$74 Def000B +S A$_int2fs$93 Def0026 +S A$_int2fs$84 Def0019 +S A$_int2fs$94 Def0029 +S A$_int2fs$85 Def001B +S A$_int2fs$76 Def000D +S A$_int2fs$67 Def0000 +S A$_int2fs$95 Def002C +S A$_int2fs$86 Def001D +S A$_int2fs$77 Def000F +S A$_int2fs$68 Def0002 +S A$_int2fs$87 Def001F +S A$_int2fs$78 Def0011 +S A$_int2fs$97 Def002F +S A$_int2fs$79 Def0012 +S A$_int2fs$98 Def0032 +S A$_int2fs$89 Def0021 +S A$_int2fs$99 Def0035 +S C$_int2fs.c$111$1$1 Def00E5 +S A$_int2fs$100 Def0038 +S A$_int2fs$200 Def00CE +S A$_int2fs$110 Def0045 +S A$_int2fs$101 Def003A +S A$_int2fs$210 Def00E3 +S A$_int2fs$201 Def00D0 +S A$_int2fs$120 Def0057 +S A$_int2fs$111 Def0048 +S A$_int2fs$202 Def00D2 +S A$_int2fs$130 Def0065 +S A$_int2fs$121 Def0059 +S A$_int2fs$112 Def004B +S A$_int2fs$203 Def00D4 +S A$_int2fs$140 Def0076 +S A$_int2fs$122 Def005A +S A$_int2fs$104 Def003D +S ___int2fs Def0000 +S A$_int2fs$204 Def00D6 +S A$_int2fs$150 Def0083 +S A$_int2fs$132 Def0067 +S A$_int2fs$123 Def005C +S A$_int2fs$114 Def004E +S A$_int2fs$214 Def00E5 +S A$_int2fs$205 Def00D8 +S A$_int2fs$160 Def0093 +S A$_int2fs$151 Def0085 +S A$_int2fs$142 Def0078 +S A$_int2fs$133 Def0068 +S A$_int2fs$124 Def005E +S A$_int2fs$115 Def004F +S A$_int2fs$106 Def003F +S A$_int2fs$170 Def009D +S A$_int2fs$152 Def0087 +S A$_int2fs$134 Def006A +S A$_int2fs$125 Def005F +S A$_int2fs$116 Def0050 +S A$_int2fs$207 Def00DA +S A$_int2fs$180 Def00AA +S A$_int2fs$171 Def009F +S A$_int2fs$153 Def0088 +S A$_int2fs$135 Def006C +S A$_int2fs$126 Def0061 +S A$_int2fs$117 Def0052 +S A$_int2fs$208 Def00DD +S A$_int2fs$190 Def00BC +S A$_int2fs$181 Def00AC +S A$_int2fs$172 Def00A0 +S A$_int2fs$163 Def0094 +S A$_int2fs$154 Def008A +S A$_int2fs$145 Def007A +S A$_int2fs$136 Def006E +S A$_int2fs$118 Def0054 +S A$_int2fs$109 Def0042 +S A$_int2fs$209 Def00E0 +S A$_int2fs$191 Def00BD +S A$_int2fs$182 Def00AE +S A$_int2fs$173 Def00A2 +S A$_int2fs$155 Def008C +S A$_int2fs$146 Def007C +S A$_int2fs$137 Def0070 +S A$_int2fs$119 Def0055 +S A$_int2fs$192 Def00BF +S A$_int2fs$183 Def00B0 +S A$_int2fs$174 Def00A4 +S A$_int2fs$156 Def008D +S A$_int2fs$147 Def007E +S A$_int2fs$138 Def0072 +S A$_int2fs$129 Def0063 +S A$_int2fs$193 Def00C0 +S A$_int2fs$184 Def00B2 +S A$_int2fs$175 Def00A5 +S A$_int2fs$166 Def0096 +S A$_int2fs$148 Def0080 +S A$_int2fs$139 Def0074 +S A$_int2fs$194 Def00C2 +S A$_int2fs$185 Def00B4 +S A$_int2fs$176 Def00A6 +S A$_int2fs$158 Def008F +S A$_int2fs$149 Def0082 +S A$_int2fs$195 Def00C4 +S A$_int2fs$186 Def00B6 +S A$_int2fs$177 Def00A7 +S A$_int2fs$168 Def0099 +S A$_int2fs$159 Def0090 +S A$_int2fs$196 Def00C6 +S A$_int2fs$187 Def00B7 +S A$_int2fs$178 Def00A8 +S A$_int2fs$169 Def009B +S A$_int2fs$197 Def00C8 +S A$_int2fs$188 Def00B9 +S A$_int2fs$179 Def00A9 +S XG$__int2fs$0$0 Def00E5 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 E4 F5 00 03 F5 00 02 F5 00 01 +R 00 00 00 08 29 08 00 03 29 0B 00 03 29 0E 00 03 +T 00 0B F5 00 00 8A 00 08 8B 00 09 EB 33 95 E0 F5 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 16 00 0A F5 00 0B E5 00 08 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 1C 00 09 45 00 0A 45 00 0B 70 1A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 23 +R 00 00 00 08 +T 00 23 75 00 04 00 75 00 05 00 75 00 06 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 2D 00 07 00 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 36 00 06 F0 E5 00 07 02 00 E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 00 09 00 08 +T 00 3D +R 00 00 00 08 +T 00 3D E5 00 0B 30 E7 21 +R 00 00 00 08 29 03 00 03 +T 00 42 +R 00 00 00 08 +T 00 42 75 00 00 00 75 00 01 00 75 00 02 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 4C 00 03 80 C3 E4 95 00 08 F5 00 08 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 56 00 09 F5 00 09 E4 95 00 0A F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 5D 00 0A E4 95 00 0B F5 00 0B +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 63 +R 00 00 00 08 +T 00 63 7C 96 7D 00 +R 00 00 00 08 +T 00 67 +R 00 00 00 08 +T 00 67 C3 E5 00 08 94 00 E5 00 09 94 00 E5 00 0A +R 00 00 00 08 29 04 00 03 29 09 00 03 29 0E 00 03 +T 00 72 94 80 E5 00 0B 94 00 50 1C +R 00 00 00 08 29 05 00 03 +T 00 7A +R 00 00 00 08 +T 00 7A E5 00 08 25 E0 F5 00 08 E5 00 09 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 00 84 00 09 E5 00 0A 33 F5 00 0A E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 8B 00 0B 33 F5 00 0B 1C BC FF 01 1D +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 94 +R 00 00 00 08 +T 00 94 80 D1 +R 00 00 00 08 +T 00 96 +R 00 00 00 08 +T 00 96 53 00 0A 7F 7E 00 7F 00 8C 06 ED 54 01 A2 +R 00 00 00 08 09 03 00 03 +T 00 A3 E0 CE 13 CE 13 CE FF 7D 00 7C 00 AA 00 00 +R 00 00 00 08 29 0E 00 03 +T 00 B0 AB 00 01 A8 00 02 A9 00 03 EA 42 04 EB 42 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 BB 05 E8 42 06 E9 42 07 E5 00 08 42 04 E5 +R 00 00 00 08 29 0A 00 03 +T 00 C7 00 09 42 05 E5 00 0A 42 06 E5 00 0B 42 07 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0C 00 03 +T 00 D2 8C 00 04 8D 00 05 8E 00 06 8F +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 D9 00 07 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 E1 00 06 F0 E5 00 07 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 E5 +R 00 00 00 08 +T 00 E5 22 +R 00 00 00 08 diff --git a/device/lib/small/_iscntrl.asm b/device/lib/small/_iscntrl.asm new file mode 100644 index 00000000..8c64c29a --- /dev/null +++ b/device/lib/small/_iscntrl.asm @@ -0,0 +1,87 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:12 2000 + +;-------------------------------------------------------- + .module _iscntrl +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _iscntrl +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$iscntrl$0$0 ==. +; _iscntrl.c 27 +; ----------------------------------------- +; function iscntrl +; ----------------------------------------- +_iscntrl: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _iscntrl.c 32 + mov r2,dpl +; _iscntrl.c 30 + clr c + mov a,#0x1f + subb a,r2 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00107$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r2,#0x7f,00102$ +; Peephole 201 removed redundant sjmp +00108$: +00109$: +00101$: +; _iscntrl.c 31 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _iscntrl.c 32 + mov dpl,#0x00 +00104$: + C$_iscntrl.c$33$1$1 ==. + XG$iscntrl$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_iscntrl.cdb b/device/lib/small/_iscntrl.cdb new file mode 100644 index 00000000..8eb5da75 --- /dev/null +++ b/device/lib/small/_iscntrl.cdb @@ -0,0 +1,2 @@ +M:_iscntrl +F:G$iscntrl$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_iscntrl.rel b/device/lib/small/_iscntrl.rel new file mode 100644 index 00000000..666bf21d --- /dev/null +++ b/device/lib/small/_iscntrl.rel @@ -0,0 +1,51 @@ +;!FILE _iscntrl.asm +XH +H 9 areas E global symbols +M _iscntrl +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 14 flags 20 +S _iscntrl Def0000 +S XG$iscntrl$0$0 Def0013 +S C$_iscntrl.c$33$1$1 Def0013 +S A$_iscntrl$61 Def0000 +S A$_iscntrl$71 Def0008 +S A$_iscntrl$63 Def0002 +S A$_iscntrl$82 Def0010 +S A$_iscntrl$64 Def0003 +S A$_iscntrl$65 Def0005 +S G$iscntrl$0$0 Def0000 +S A$_iscntrl$67 Def0006 +S A$_iscntrl$86 Def0013 +S A$_iscntrl$77 Def000B +S A$_iscntrl$79 Def000E +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 C3 74 1F 9A 50 03 +R 00 00 00 08 +T 00 08 +R 00 00 00 08 +T 00 08 BA 7F 05 +R 00 00 00 08 +T 00 0B +R 00 00 00 08 +T 00 0B +R 00 00 00 08 +T 00 0B +R 00 00 00 08 +T 00 0B 75 82 01 80 03 +R 00 00 00 08 +T 00 10 +R 00 00 00 08 +T 00 10 75 82 00 +R 00 00 00 08 +T 00 13 +R 00 00 00 08 +T 00 13 22 +R 00 00 00 08 diff --git a/device/lib/small/_isdigit.asm b/device/lib/small/_isdigit.asm new file mode 100644 index 00000000..a36d30df --- /dev/null +++ b/device/lib/small/_isdigit.asm @@ -0,0 +1,87 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _isdigit +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isdigit +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isdigit$0$0 ==. +; _isdigit.c 26 +; ----------------------------------------- +; function isdigit +; ----------------------------------------- +_isdigit: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isdigit.c 31 + mov r2,dpl +; _isdigit.c 29 + cjne r2,#0x30,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x39 + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isdigit.c 30 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isdigit.c 31 + mov dpl,#0x00 +00104$: + C$_isdigit.c$32$1$1 ==. + XG$isdigit$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_isdigit.cdb b/device/lib/small/_isdigit.cdb new file mode 100644 index 00000000..82f7ab1e --- /dev/null +++ b/device/lib/small/_isdigit.cdb @@ -0,0 +1,2 @@ +M:_isdigit +F:G$isdigit$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_isdigit.rel b/device/lib/small/_isdigit.rel new file mode 100644 index 00000000..e3e73a5d --- /dev/null +++ b/device/lib/small/_isdigit.rel @@ -0,0 +1,52 @@ +;!FILE _isdigit.asm +XH +H 9 areas F global symbols +M _isdigit +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 16 flags 20 +S _isdigit Def0000 +S C$_isdigit.c$32$1$1 Def0015 +S XG$isdigit$0$0 Def0015 +S A$_isdigit$70 Def0008 +S A$_isdigit$61 Def0000 +S A$_isdigit$71 Def000A +S A$_isdigit$63 Def0002 +S A$_isdigit$82 Def0012 +S A$_isdigit$74 Def000B +S G$isdigit$0$0 Def0000 +S A$_isdigit$67 Def0005 +S A$_isdigit$86 Def0015 +S A$_isdigit$77 Def000D +S A$_isdigit$69 Def0007 +S A$_isdigit$79 Def0010 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 BA 30 00 +R 00 00 00 08 +T 00 05 +R 00 00 00 08 +T 00 05 40 0B +R 00 00 00 08 +T 00 07 +R 00 00 00 08 +T 00 07 C3 74 39 9A 40 05 +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D 75 82 01 80 03 +R 00 00 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 75 82 00 +R 00 00 00 08 +T 00 15 +R 00 00 00 08 +T 00 15 22 +R 00 00 00 08 diff --git a/device/lib/small/_isgraph.asm b/device/lib/small/_isgraph.asm new file mode 100644 index 00000000..70ced7c0 --- /dev/null +++ b/device/lib/small/_isgraph.asm @@ -0,0 +1,87 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _isgraph +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isgraph +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isgraph$0$0 ==. +; _isgraph.c 25 +; ----------------------------------------- +; function isgraph +; ----------------------------------------- +_isgraph: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isgraph.c 30 + mov r2,dpl +; _isgraph.c 28 + cjne r2,#0x21,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x7e + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isgraph.c 29 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isgraph.c 30 + mov dpl,#0x00 +00104$: + C$_isgraph.c$31$1$1 ==. + XG$isgraph$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_isgraph.cdb b/device/lib/small/_isgraph.cdb new file mode 100644 index 00000000..257b3d9b --- /dev/null +++ b/device/lib/small/_isgraph.cdb @@ -0,0 +1,2 @@ +M:_isgraph +F:G$isgraph$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_isgraph.rel b/device/lib/small/_isgraph.rel new file mode 100644 index 00000000..02f128a4 --- /dev/null +++ b/device/lib/small/_isgraph.rel @@ -0,0 +1,52 @@ +;!FILE _isgraph.asm +XH +H 9 areas F global symbols +M _isgraph +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 16 flags 20 +S _isgraph Def0000 +S C$_isgraph.c$31$1$1 Def0015 +S XG$isgraph$0$0 Def0015 +S A$_isgraph$70 Def0008 +S A$_isgraph$61 Def0000 +S A$_isgraph$71 Def000A +S A$_isgraph$63 Def0002 +S A$_isgraph$82 Def0012 +S A$_isgraph$74 Def000B +S G$isgraph$0$0 Def0000 +S A$_isgraph$67 Def0005 +S A$_isgraph$86 Def0015 +S A$_isgraph$77 Def000D +S A$_isgraph$69 Def0007 +S A$_isgraph$79 Def0010 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 BA 21 00 +R 00 00 00 08 +T 00 05 +R 00 00 00 08 +T 00 05 40 0B +R 00 00 00 08 +T 00 07 +R 00 00 00 08 +T 00 07 C3 74 7E 9A 40 05 +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D 75 82 01 80 03 +R 00 00 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 75 82 00 +R 00 00 00 08 +T 00 15 +R 00 00 00 08 +T 00 15 22 +R 00 00 00 08 diff --git a/device/lib/small/_islower.asm b/device/lib/small/_islower.asm new file mode 100644 index 00000000..ba10d10c --- /dev/null +++ b/device/lib/small/_islower.asm @@ -0,0 +1,87 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _islower +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _islower +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$islower$0$0 ==. +; _islower.c 25 +; ----------------------------------------- +; function islower +; ----------------------------------------- +_islower: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _islower.c 30 + mov r2,dpl +; _islower.c 28 + cjne r2,#0x61,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x7a + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _islower.c 29 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _islower.c 30 + mov dpl,#0x00 +00104$: + C$_islower.c$31$1$1 ==. + XG$islower$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_islower.cdb b/device/lib/small/_islower.cdb new file mode 100644 index 00000000..574e3174 --- /dev/null +++ b/device/lib/small/_islower.cdb @@ -0,0 +1,2 @@ +M:_islower +F:G$islower$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_islower.rel b/device/lib/small/_islower.rel new file mode 100644 index 00000000..52327484 --- /dev/null +++ b/device/lib/small/_islower.rel @@ -0,0 +1,52 @@ +;!FILE _islower.asm +XH +H 9 areas F global symbols +M _islower +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 16 flags 20 +S _islower Def0000 +S C$_islower.c$31$1$1 Def0015 +S XG$islower$0$0 Def0015 +S A$_islower$70 Def0008 +S A$_islower$61 Def0000 +S A$_islower$71 Def000A +S A$_islower$63 Def0002 +S A$_islower$82 Def0012 +S A$_islower$74 Def000B +S G$islower$0$0 Def0000 +S A$_islower$67 Def0005 +S A$_islower$86 Def0015 +S A$_islower$77 Def000D +S A$_islower$69 Def0007 +S A$_islower$79 Def0010 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 BA 61 00 +R 00 00 00 08 +T 00 05 +R 00 00 00 08 +T 00 05 40 0B +R 00 00 00 08 +T 00 07 +R 00 00 00 08 +T 00 07 C3 74 7A 9A 40 05 +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D 75 82 01 80 03 +R 00 00 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 75 82 00 +R 00 00 00 08 +T 00 15 +R 00 00 00 08 +T 00 15 22 +R 00 00 00 08 diff --git a/device/lib/small/_isprint.asm b/device/lib/small/_isprint.asm new file mode 100644 index 00000000..a309f18c --- /dev/null +++ b/device/lib/small/_isprint.asm @@ -0,0 +1,87 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _isprint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isprint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isprint$0$0 ==. +; _isprint.c 24 +; ----------------------------------------- +; function isprint +; ----------------------------------------- +_isprint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isprint.c 29 + mov r2,dpl +; _isprint.c 27 + cjne r2,#0x20,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x7e + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isprint.c 28 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isprint.c 29 + mov dpl,#0x00 +00104$: + C$_isprint.c$30$1$1 ==. + XG$isprint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_isprint.cdb b/device/lib/small/_isprint.cdb new file mode 100644 index 00000000..c8637529 --- /dev/null +++ b/device/lib/small/_isprint.cdb @@ -0,0 +1,2 @@ +M:_isprint +F:G$isprint$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_isprint.rel b/device/lib/small/_isprint.rel new file mode 100644 index 00000000..433d9434 --- /dev/null +++ b/device/lib/small/_isprint.rel @@ -0,0 +1,52 @@ +;!FILE _isprint.asm +XH +H 9 areas F global symbols +M _isprint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 16 flags 20 +S A$_isprint$69 Def0007 +S A$_isprint$79 Def0010 +S _isprint Def0000 +S C$_isprint.c$30$1$1 Def0015 +S XG$isprint$0$0 Def0015 +S A$_isprint$70 Def0008 +S A$_isprint$61 Def0000 +S A$_isprint$71 Def000A +S A$_isprint$63 Def0002 +S A$_isprint$82 Def0012 +S A$_isprint$74 Def000B +S G$isprint$0$0 Def0000 +S A$_isprint$67 Def0005 +S A$_isprint$86 Def0015 +S A$_isprint$77 Def000D +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 BA 20 00 +R 00 00 00 08 +T 00 05 +R 00 00 00 08 +T 00 05 40 0B +R 00 00 00 08 +T 00 07 +R 00 00 00 08 +T 00 07 C3 74 7E 9A 40 05 +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D 75 82 01 80 03 +R 00 00 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 75 82 00 +R 00 00 00 08 +T 00 15 +R 00 00 00 08 +T 00 15 22 +R 00 00 00 08 diff --git a/device/lib/small/_ispunct.asm b/device/lib/small/_ispunct.asm new file mode 100644 index 00000000..4c688e5d --- /dev/null +++ b/device/lib/small/_ispunct.asm @@ -0,0 +1,115 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _ispunct +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _ispunct +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$ispunct$0$0 ==. +; _ispunct.c 25 +; ----------------------------------------- +; function ispunct +; ----------------------------------------- +_ispunct: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ispunct.c 34 + mov r2,dpl +; _ispunct.c 28 + push ar2 + mov dpl,r2 + lcall _isprint + mov r3,dpl + pop ar2 + mov a,r3 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _ispunct.c 29 + push ar2 + mov dpl,r2 + lcall _islower + mov r3,dpl + pop ar2 + mov a,r3 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00115$: +; _ispunct.c 30 + push ar2 + mov dpl,r2 + lcall _isupper + mov r3,dpl + pop ar2 + mov a,r3 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00116$: +; _ispunct.c 31 + cjne r2,#0x20,00117$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00117$: +; _ispunct.c 32 + mov dpl,r2 + lcall _isdigit + mov r2,dpl + mov a,r2 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00118$: +; _ispunct.c 33 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00102$: +; _ispunct.c 34 + mov dpl,#0x00 +00107$: + C$_ispunct.c$35$1$1 ==. + XG$ispunct$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_ispunct.cdb b/device/lib/small/_ispunct.cdb new file mode 100644 index 00000000..92ef79f8 --- /dev/null +++ b/device/lib/small/_ispunct.cdb @@ -0,0 +1,2 @@ +M:_ispunct +F:G$ispunct$0$0({2}DF,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_ispunct.rel b/device/lib/small/_ispunct.rel new file mode 100644 index 00000000..09ae1616 --- /dev/null +++ b/device/lib/small/_ispunct.rel @@ -0,0 +1,87 @@ +;!FILE _ispunct.asm +XH +H 8 areas 29 global symbols +M _ispunct +S _isdigit Ref0000 +S _islower Ref0000 +S _isupper Ref0000 +S _isprint Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 44 flags 20 +S A$_ispunct$99 Def0036 +S A$_ispunct$100 Def0038 +S A$_ispunct$110 Def0040 +S A$_ispunct$102 Def0039 +S A$_ispunct$114 Def0043 +S A$_ispunct$105 Def003B +S _ispunct Def0000 +S A$_ispunct$107 Def003E +S XG$ispunct$0$0 Def0043 +S C$_ispunct.c$35$1$1 Def0043 +S A$_ispunct$60 Def0000 +S A$_ispunct$62 Def0002 +S A$_ispunct$72 Def0010 +S A$_ispunct$63 Def0004 +S A$_ispunct$82 Def001E +S A$_ispunct$73 Def0012 +S A$_ispunct$64 Def0006 +S A$_ispunct$92 Def002C +S A$_ispunct$83 Def0020 +S A$_ispunct$74 Def0014 +S A$_ispunct$65 Def0009 +S G$ispunct$0$0 Def0000 +S A$_ispunct$84 Def0022 +S A$_ispunct$75 Def0017 +S A$_ispunct$66 Def000B +S A$_ispunct$94 Def002F +S A$_ispunct$85 Def0025 +S A$_ispunct$76 Def0019 +S A$_ispunct$67 Def000D +S A$_ispunct$86 Def0027 +S A$_ispunct$77 Def001B +S A$_ispunct$87 Def0029 +S A$_ispunct$69 Def000E +S A$_ispunct$97 Def0031 +S A$_ispunct$79 Def001C +S A$_ispunct$98 Def0033 +S A$_ispunct$89 Def002A +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 C0 02 8A 82 12 00 00 AB 82 D0 02 EB +R 00 00 00 07 02 09 00 03 +T 00 0E 60 30 +R 00 00 00 07 +T 00 10 +R 00 00 00 07 +T 00 10 C0 02 8A 82 12 00 00 AB 82 D0 02 EB 70 22 +R 00 00 00 07 02 07 00 01 +T 00 1E +R 00 00 00 07 +T 00 1E C0 02 8A 82 12 00 00 AB 82 D0 02 EB 70 14 +R 00 00 00 07 02 07 00 02 +T 00 2C +R 00 00 00 07 +T 00 2C BA 20 02 80 0F +R 00 00 00 07 +T 00 31 +R 00 00 00 07 +T 00 31 8A 82 12 00 00 AA 82 EA 70 05 +R 00 00 00 07 02 05 00 00 +T 00 3B +R 00 00 00 07 +T 00 3B 75 82 01 80 03 +R 00 00 00 07 +T 00 40 +R 00 00 00 07 +T 00 40 75 82 00 +R 00 00 00 07 +T 00 43 +R 00 00 00 07 +T 00 43 22 +R 00 00 00 07 diff --git a/device/lib/small/_isspace.asm b/device/lib/small/_isspace.asm new file mode 100644 index 00000000..0c47f99f --- /dev/null +++ b/device/lib/small/_isspace.asm @@ -0,0 +1,106 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _isspace +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isspace +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isspace$0$0 ==. +; _isspace.c 24 +; ----------------------------------------- +; function isspace +; ----------------------------------------- +_isspace: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isspace.c 34 + mov r2,dpl +; _isspace.c 27 + cjne r2,#0x20,00115$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00115$: +; _isspace.c 28 + cjne r2,#0x0c,00116$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00116$: +; _isspace.c 29 + cjne r2,#0x0a,00117$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00117$: +; _isspace.c 30 + cjne r2,#0x0d,00118$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00118$: +; _isspace.c 31 + cjne r2,#0x09,00119$ +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00119$: +; _isspace.c 32 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r2,#0x0b,00102$ +; Peephole 201 removed redundant sjmp +00120$: +00121$: +00101$: +; _isspace.c 33 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00102$: +; _isspace.c 34 + mov dpl,#0x00 +00108$: + C$_isspace.c$35$1$1 ==. + XG$isspace$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_isspace.cdb b/device/lib/small/_isspace.cdb new file mode 100644 index 00000000..a9440c9b --- /dev/null +++ b/device/lib/small/_isspace.cdb @@ -0,0 +1,2 @@ +M:_isspace +F:G$isspace$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_isspace.rel b/device/lib/small/_isspace.rel new file mode 100644 index 00000000..a6bdcd84 --- /dev/null +++ b/device/lib/small/_isspace.rel @@ -0,0 +1,73 @@ +;!FILE _isspace.asm +XH +H 9 areas 14 global symbols +M _isspace +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 27 flags 20 +S A$_isspace$101 Def0023 +S A$_isspace$105 Def0026 +S _isspace Def0000 +S XG$isspace$0$0 Def0026 +S C$_isspace.c$35$1$1 Def0026 +S A$_isspace$70 Def000A +S A$_isspace$61 Def0000 +S A$_isspace$80 Def0014 +S A$_isspace$90 Def001B +S A$_isspace$63 Def0002 +S A$_isspace$73 Def000C +S A$_isspace$83 Def0016 +S A$_isspace$65 Def0005 +S G$isspace$0$0 Def0000 +S A$_isspace$75 Def000F +S A$_isspace$85 Def0019 +S A$_isspace$68 Def0007 +S A$_isspace$96 Def001E +S A$_isspace$78 Def0011 +S A$_isspace$98 Def0021 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 BA 20 02 80 17 +R 00 00 00 08 +T 00 07 +R 00 00 00 08 +T 00 07 BA 0C 02 80 12 +R 00 00 00 08 +T 00 0C +R 00 00 00 08 +T 00 0C BA 0A 02 80 0D +R 00 00 00 08 +T 00 11 +R 00 00 00 08 +T 00 11 BA 0D 02 80 08 +R 00 00 00 08 +T 00 16 +R 00 00 00 08 +T 00 16 BA 09 02 80 03 +R 00 00 00 08 +T 00 1B +R 00 00 00 08 +T 00 1B BA 0B 05 +R 00 00 00 08 +T 00 1E +R 00 00 00 08 +T 00 1E +R 00 00 00 08 +T 00 1E +R 00 00 00 08 +T 00 1E 75 82 01 80 03 +R 00 00 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 75 82 00 +R 00 00 00 08 +T 00 26 +R 00 00 00 08 +T 00 26 22 +R 00 00 00 08 diff --git a/device/lib/small/_isupper.asm b/device/lib/small/_isupper.asm new file mode 100644 index 00000000..55d2ddda --- /dev/null +++ b/device/lib/small/_isupper.asm @@ -0,0 +1,87 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _isupper +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isupper +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isupper$0$0 ==. +; _isupper.c 24 +; ----------------------------------------- +; function isupper +; ----------------------------------------- +_isupper: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isupper.c 29 + mov r2,dpl +; _isupper.c 27 + cjne r2,#0x41,00108$ +00108$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00109$: + clr c + mov a,#0x5a + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00110$: +; _isupper.c 28 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _isupper.c 29 + mov dpl,#0x00 +00104$: + C$_isupper.c$30$1$1 ==. + XG$isupper$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_isupper.cdb b/device/lib/small/_isupper.cdb new file mode 100644 index 00000000..bb37037d --- /dev/null +++ b/device/lib/small/_isupper.cdb @@ -0,0 +1,2 @@ +M:_isupper +F:G$isupper$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_isupper.rel b/device/lib/small/_isupper.rel new file mode 100644 index 00000000..ccd2948b --- /dev/null +++ b/device/lib/small/_isupper.rel @@ -0,0 +1,52 @@ +;!FILE _isupper.asm +XH +H 9 areas F global symbols +M _isupper +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 16 flags 20 +S A$_isupper$79 Def0010 +S _isupper Def0000 +S C$_isupper.c$30$1$1 Def0015 +S XG$isupper$0$0 Def0015 +S A$_isupper$70 Def0008 +S A$_isupper$61 Def0000 +S A$_isupper$71 Def000A +S A$_isupper$63 Def0002 +S A$_isupper$82 Def0012 +S A$_isupper$74 Def000B +S G$isupper$0$0 Def0000 +S A$_isupper$67 Def0005 +S A$_isupper$86 Def0015 +S A$_isupper$77 Def000D +S A$_isupper$69 Def0007 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 BA 41 00 +R 00 00 00 08 +T 00 05 +R 00 00 00 08 +T 00 05 40 0B +R 00 00 00 08 +T 00 07 +R 00 00 00 08 +T 00 07 C3 74 5A 9A 40 05 +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D 75 82 01 80 03 +R 00 00 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 75 82 00 +R 00 00 00 08 +T 00 15 +R 00 00 00 08 +T 00 15 22 +R 00 00 00 08 diff --git a/device/lib/small/_isxdigit.asm b/device/lib/small/_isxdigit.asm new file mode 100644 index 00000000..1a32dbd0 --- /dev/null +++ b/device/lib/small/_isxdigit.asm @@ -0,0 +1,116 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _isxdigit +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _isxdigit +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$isxdigit$0$0 ==. +; _isxdigit.c 24 +; ----------------------------------------- +; function isxdigit +; ----------------------------------------- +_isxdigit: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _isxdigit.c 31 + mov r2,dpl +; _isxdigit.c 27 + cjne r2,#0x30,00113$ +00113$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00105$ +00114$: + clr c + mov a,#0x39 + subb a,r2 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00115$: +00105$: +; _isxdigit.c 28 + cjne r2,#0x61,00116$ +00116$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00117$: + clr c + mov a,#0x66 + subb a,r2 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00118$: +00107$: +; _isxdigit.c 29 + cjne r2,#0x41,00119$ +00119$: +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00120$: + clr c + mov a,#0x46 + subb a,r2 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00102$ +00121$: +00101$: +; _isxdigit.c 30 + mov dpl,#0x01 +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00102$: +; _isxdigit.c 31 + mov dpl,#0x00 +00108$: + C$_isxdigit.c$33$1$1 ==. + XG$isxdigit$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_isxdigit.cdb b/device/lib/small/_isxdigit.cdb new file mode 100644 index 00000000..c7983cff --- /dev/null +++ b/device/lib/small/_isxdigit.cdb @@ -0,0 +1,2 @@ +M:_isxdigit +F:G$isxdigit$0$0({2}DF,SC:S),C,0,0,0,0,0 diff --git a/device/lib/small/_isxdigit.rel b/device/lib/small/_isxdigit.rel new file mode 100644 index 00000000..b73b4bc3 --- /dev/null +++ b/device/lib/small/_isxdigit.rel @@ -0,0 +1,94 @@ +;!FILE _isxdigit.asm +XH +H 9 areas 1B global symbols +M _isxdigit +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 2C flags 20 +S A$_isxdigit$111 Def0028 +S A$_isxdigit$102 Def0021 +S A$_isxdigit$115 Def002B +S A$_isxdigit$106 Def0023 +S _isxdigit Def0000 +S A$_isxdigit$108 Def0026 +S XG$isxdigit$0$0 Def002B +S C$_isxdigit.c$33$1$1 Def002B +S A$_isxdigit$70 Def0008 +S A$_isxdigit$61 Def0000 +S A$_isxdigit$71 Def000A +S A$_isxdigit$81 Def0010 +S A$_isxdigit$63 Def0002 +S A$_isxdigit$91 Def0018 +S A$_isxdigit$73 Def000B +S A$_isxdigit$83 Def0012 +S G$isxdigit$0$0 Def0000 +S A$_isxdigit$84 Def0013 +S A$_isxdigit$85 Def0015 +S A$_isxdigit$67 Def0005 +S A$_isxdigit$95 Def001B +S A$_isxdigit$77 Def000D +S A$_isxdigit$87 Def0016 +S A$_isxdigit$69 Def0007 +S A$_isxdigit$97 Def001D +S A$_isxdigit$98 Def001E +S A$_isxdigit$99 Def0020 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 BA 30 00 +R 00 00 00 08 +T 00 05 +R 00 00 00 08 +T 00 05 40 06 +R 00 00 00 08 +T 00 07 +R 00 00 00 08 +T 00 07 C3 74 39 9A 50 16 +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D BA 61 00 +R 00 00 00 08 +T 00 10 +R 00 00 00 08 +T 00 10 40 06 +R 00 00 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 C3 74 66 9A 50 0B +R 00 00 00 08 +T 00 18 +R 00 00 00 08 +T 00 18 +R 00 00 00 08 +T 00 18 BA 41 00 +R 00 00 00 08 +T 00 1B +R 00 00 00 08 +T 00 1B 40 0B +R 00 00 00 08 +T 00 1D +R 00 00 00 08 +T 00 1D C3 74 46 9A 40 05 +R 00 00 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 75 82 01 80 03 +R 00 00 00 08 +T 00 28 +R 00 00 00 08 +T 00 28 75 82 00 +R 00 00 00 08 +T 00 2B +R 00 00 00 08 +T 00 2B 22 +R 00 00 00 08 diff --git a/device/lib/small/_long2fs.asm b/device/lib/small/_long2fs.asm new file mode 100644 index 00000000..4b1b5bea --- /dev/null +++ b/device/lib/small/_long2fs.asm @@ -0,0 +1,209 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _long2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___long2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___long2fs_a1_1_1: + .ds 0x0004 +___long2fs_sign_1_1: + .ds 0x0004 +___long2fs_fl_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__long2fs$0$0 ==. +; _long2fs.c 80 +; ----------------------------------------- +; function __long2fs +; ----------------------------------------- +___long2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _long2fs.c 108 + mov ___long2fs_a1_1_1,dpl + mov (___long2fs_a1_1_1 + 1),dph + mov (___long2fs_a1_1_1 + 2),b + mov (___long2fs_a1_1_1 + 3),a +; _long2fs.c 82 + clr a + mov (___long2fs_sign_1_1 + 3),a + mov (___long2fs_sign_1_1 + 2),a + mov (___long2fs_sign_1_1 + 1),a + mov ___long2fs_sign_1_1,a +; _long2fs.c 86 + mov a,___long2fs_a1_1_1 + orl a,(___long2fs_a1_1_1 + 1) + orl a,(___long2fs_a1_1_1 + 2) + orl a,(___long2fs_a1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _long2fs.c 88 + mov ___long2fs_fl_1_1,#0x00 + mov (___long2fs_fl_1_1 + 1),#0x00 + mov (___long2fs_fl_1_1 + 2),#0x00 + mov (___long2fs_fl_1_1 + 3),#0x00 +; _long2fs.c 89 + mov dpl,___long2fs_fl_1_1 + mov dph,(___long2fs_fl_1_1 + 1) + mov b,(___long2fs_fl_1_1 + 2) + mov a,(___long2fs_fl_1_1 + 3) + ljmp 00108$ +00102$: +; _long2fs.c 92 + mov a,(___long2fs_a1_1_1 + 3) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _long2fs.c 94 + mov ___long2fs_sign_1_1,#0x00 + mov (___long2fs_sign_1_1 + 1),#0x00 + mov (___long2fs_sign_1_1 + 2),#0x00 + mov (___long2fs_sign_1_1 + 3),#0x80 +; _long2fs.c 95 + clr c + clr a + subb a,___long2fs_a1_1_1 + mov ___long2fs_a1_1_1,a + clr a + subb a,(___long2fs_a1_1_1 + 1) + mov (___long2fs_a1_1_1 + 1),a + clr a + subb a,(___long2fs_a1_1_1 + 2) + mov (___long2fs_a1_1_1 + 2),a + clr a + subb a,(___long2fs_a1_1_1 + 3) + mov (___long2fs_a1_1_1 + 3),a +; _long2fs.c 98 +00113$: + mov r6,#0x96 + mov r7,#0x00 +00105$: + clr c + mov a,___long2fs_a1_1_1 + subb a,#0x00 + mov a,(___long2fs_a1_1_1 + 1) + subb a,#0x00 + mov a,(___long2fs_a1_1_1 + 2) + subb a,#0x80 + mov a,(___long2fs_a1_1_1 + 3) + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _long2fs.c 100 + mov a,___long2fs_a1_1_1 + add a,acc + mov ___long2fs_a1_1_1,a + mov a,(___long2fs_a1_1_1 + 1) + rlc a + mov (___long2fs_a1_1_1 + 1),a + mov a,(___long2fs_a1_1_1 + 2) + rlc a + mov (___long2fs_a1_1_1 + 2),a + mov a,(___long2fs_a1_1_1 + 3) + rlc a + mov (___long2fs_a1_1_1 + 3),a +; _long2fs.c 101 + dec r6 + cjne r6,#0xff,00117$ + dec r7 +00117$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _long2fs.c 104 + anl (___long2fs_a1_1_1 + 2),#0x7f +; _long2fs.c 106 + mov r0,#0x00 + mov r1,#0x00 + mov ar0,r6 + mov a,r7 + anl a,#0x01 + mov c,acc.0 + xch a,r0 + rrc a + xch a,r0 + rrc a + xch a,r0 + mov r1,a + mov r7,#0x00 + mov r6,#0x00 + mov r2,___long2fs_sign_1_1 + mov r3,(___long2fs_sign_1_1 + 1) + mov r4,(___long2fs_sign_1_1 + 2) + mov r5,(___long2fs_sign_1_1 + 3) + mov a,r2 + orl ar6,a + mov a,r3 + orl ar7,a + mov a,r4 + orl ar0,a + mov a,r5 + orl ar1,a + mov a,___long2fs_a1_1_1 + orl ar6,a + mov a,(___long2fs_a1_1_1 + 1) + orl ar7,a + mov a,(___long2fs_a1_1_1 + 2) + orl ar0,a + mov a,(___long2fs_a1_1_1 + 3) + orl ar1,a + mov ___long2fs_fl_1_1,r6 + mov (___long2fs_fl_1_1 + 1),r7 + mov (___long2fs_fl_1_1 + 2),r0 + mov (___long2fs_fl_1_1 + 3),r1 +; _long2fs.c 108 + mov dpl,___long2fs_fl_1_1 + mov dph,(___long2fs_fl_1_1 + 1) + mov b,(___long2fs_fl_1_1 + 2) + mov a,(___long2fs_fl_1_1 + 3) +00108$: + C$_long2fs.c$109$1$1 ==. + XG$__long2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_long2fs.cdb b/device/lib/small/_long2fs.cdb new file mode 100644 index 00000000..6ba151b2 --- /dev/null +++ b/device/lib/small/_long2fs.cdb @@ -0,0 +1,2 @@ +M:_long2fs +F:G$__long2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_long2fs.rel b/device/lib/small/_long2fs.rel new file mode 100644 index 00000000..7d18617a --- /dev/null +++ b/device/lib/small/_long2fs.rel @@ -0,0 +1,219 @@ +;!FILE _long2fs.asm +XH +H 9 areas 76 global symbols +M _long2fs +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size E1 flags 20 +S A$_long2fs$100 Def003A +S A$_long2fs$110 Def004B +S A$_long2fs$201 Def00D5 +S A$_long2fs$120 Def005C +S A$_long2fs$111 Def004D +S A$_long2fs$202 Def00D8 +S A$_long2fs$130 Def0069 +S A$_long2fs$112 Def004F +S A$_long2fs$103 Def003D +S A$_long2fs$203 Def00DB +S A$_long2fs$140 Def0077 +S A$_long2fs$131 Def006B +S A$_long2fs$113 Def0050 +S A$_long2fs$104 Def0040 +S ___long2fs Def0000 +S A$_long2fs$204 Def00DE +S A$_long2fs$150 Def0088 +S A$_long2fs$141 Def0079 +S A$_long2fs$132 Def006D +S A$_long2fs$123 Def005E +S A$_long2fs$114 Def0052 +S A$_long2fs$105 Def0043 +S A$_long2fs$160 Def0091 +S A$_long2fs$142 Def007B +S A$_long2fs$133 Def006F +S A$_long2fs$124 Def0060 +S A$_long2fs$115 Def0054 +S A$_long2fs$106 Def0046 +S C$_long2fs.c$109$1$1 Def00E0 +S A$_long2fs$170 Def00A1 +S A$_long2fs$152 Def008A +S A$_long2fs$143 Def007D +S A$_long2fs$134 Def0071 +S A$_long2fs$116 Def0055 +S A$_long2fs$180 Def00B1 +S A$_long2fs$171 Def00A2 +S A$_long2fs$162 Def0094 +S A$_long2fs$153 Def008B +S A$_long2fs$144 Def007E +S A$_long2fs$126 Def0062 +S A$_long2fs$117 Def0057 +S A$_long2fs$108 Def0049 +S A$_long2fs$208 Def00E0 +S A$_long2fs$190 Def00C1 +S A$_long2fs$181 Def00B2 +S A$_long2fs$172 Def00A3 +S A$_long2fs$163 Def0096 +S A$_long2fs$154 Def008E +S A$_long2fs$145 Def0080 +S A$_long2fs$136 Def0073 +S A$_long2fs$127 Def0063 +S A$_long2fs$118 Def0059 +S A$_long2fs$109 Def004A +S A$_long2fs$191 Def00C3 +S A$_long2fs$182 Def00B4 +S A$_long2fs$173 Def00A4 +S A$_long2fs$164 Def0098 +S A$_long2fs$146 Def0082 +S A$_long2fs$128 Def0065 +S A$_long2fs$119 Def005A +S A$_long2fs$192 Def00C5 +S A$_long2fs$183 Def00B5 +S A$_long2fs$174 Def00A5 +S A$_long2fs$165 Def009A +S A$_long2fs$147 Def0083 +S A$_long2fs$129 Def0067 +S A$_long2fs$193 Def00C7 +S A$_long2fs$184 Def00B7 +S A$_long2fs$175 Def00A7 +S A$_long2fs$166 Def009B +S A$_long2fs$157 Def008F +S A$_long2fs$148 Def0085 +S A$_long2fs$139 Def0075 +S A$_long2fs$194 Def00C9 +S A$_long2fs$185 Def00B8 +S A$_long2fs$176 Def00A9 +S A$_long2fs$167 Def009D +S A$_long2fs$149 Def0087 +S A$_long2fs$195 Def00CB +S A$_long2fs$186 Def00BA +S A$_long2fs$177 Def00AB +S A$_long2fs$168 Def009F +S A$_long2fs$196 Def00CD +S A$_long2fs$187 Def00BB +S A$_long2fs$178 Def00AD +S A$_long2fs$169 Def00A0 +S A$_long2fs$197 Def00CF +S A$_long2fs$188 Def00BD +S A$_long2fs$179 Def00AF +S XG$__long2fs$0$0 Def00E0 +S A$_long2fs$198 Def00D1 +S A$_long2fs$189 Def00BF +S A$_long2fs$199 Def00D3 +S A$_long2fs$70 Def0009 +S A$_long2fs$80 Def0018 +S A$_long2fs$81 Def001A +S A$_long2fs$72 Def000B +S G$__long2fs$0$0 Def0000 +S A$_long2fs$91 Def002A +S A$_long2fs$73 Def000C +S A$_long2fs$92 Def002D +S A$_long2fs$83 Def001C +S A$_long2fs$74 Def000E +S A$_long2fs$93 Def0030 +S A$_long2fs$75 Def0010 +S A$_long2fs$94 Def0033 +S A$_long2fs$76 Def0012 +S A$_long2fs$67 Def0000 +S A$_long2fs$95 Def0035 +S A$_long2fs$86 Def001E +S A$_long2fs$68 Def0003 +S A$_long2fs$87 Def0021 +S A$_long2fs$78 Def0014 +S A$_long2fs$69 Def0006 +S A$_long2fs$88 Def0024 +S A$_long2fs$79 Def0016 +S A$_long2fs$98 Def0038 +S A$_long2fs$89 Def0027 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 85 82 00 00 85 83 00 01 85 F0 00 02 F5 +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0C 00 03 +T 00 0A 00 03 E4 F5 00 07 F5 00 06 F5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 11 00 05 F5 00 04 E5 00 00 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 17 00 01 45 00 02 45 00 03 70 1A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 1E +R 00 00 00 08 +T 00 1E 75 00 08 00 75 00 09 00 75 00 0A 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 28 00 0B 00 85 00 08 82 85 00 09 83 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 31 00 0A F0 E5 00 0B 02 00 E0 +R 00 00 00 08 29 02 00 03 29 06 00 03 00 09 00 08 +T 00 38 +R 00 00 00 08 +T 00 38 E5 00 03 30 E7 21 +R 00 00 00 08 29 03 00 03 +T 00 3D +R 00 00 00 08 +T 00 3D 75 00 04 00 75 00 05 00 75 00 06 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 47 00 07 80 C3 E4 95 00 00 F5 00 00 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 51 00 01 F5 00 01 E4 95 00 02 F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 58 00 02 E4 95 00 03 F5 00 03 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 5E +R 00 00 00 08 +T 00 5E 7E 96 7F 00 +R 00 00 00 08 +T 00 62 +R 00 00 00 08 +T 00 62 C3 E5 00 00 94 00 E5 00 01 94 00 E5 00 02 +R 00 00 00 08 29 04 00 03 29 09 00 03 29 0E 00 03 +T 00 6D 94 80 E5 00 03 94 00 50 1C +R 00 00 00 08 29 05 00 03 +T 00 75 +R 00 00 00 08 +T 00 75 E5 00 00 25 E0 F5 00 00 E5 00 01 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 00 7F 00 01 E5 00 02 33 F5 00 02 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 86 00 03 33 F5 00 03 1E BE FF 01 1F +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 8F +R 00 00 00 08 +T 00 8F 80 D1 +R 00 00 00 08 +T 00 91 +R 00 00 00 08 +T 00 91 53 00 02 7F 78 00 79 00 8E 00 EF 54 01 A2 +R 00 00 00 08 09 03 00 03 +T 00 9E E0 C8 13 C8 13 C8 F9 7F 00 7E 00 AA 00 04 +R 00 00 00 08 29 0E 00 03 +T 00 AB AB 00 05 AC 00 06 AD 00 07 EA 42 06 EB 42 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 B6 07 EC 42 00 ED 42 01 E5 00 00 42 06 E5 +R 00 00 00 08 29 0A 00 03 +T 00 C2 00 01 42 07 E5 00 02 42 00 E5 00 03 42 01 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0C 00 03 +T 00 CD 8E 00 08 8F 00 09 88 00 0A 89 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 D4 00 0B 85 00 08 82 85 00 09 83 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 DC 00 0A F0 E5 00 0B +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 E0 +R 00 00 00 08 +T 00 E0 22 +R 00 00 00 08 diff --git a/device/lib/small/_memcmp.asm b/device/lib/small/_memcmp.asm new file mode 100644 index 00000000..795258f3 --- /dev/null +++ b/device/lib/small/_memcmp.asm @@ -0,0 +1,160 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _memcmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _memcmp_PARM_3 + .globl _memcmp_PARM_2 + .globl _memcmp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_memcmp_PARM_2: + .ds 0x0003 +_memcmp_PARM_3: + .ds 0x0002 +_memcmp_buf1_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$memcmp$0$0 ==. +; _memcmp.c 27 +; ----------------------------------------- +; function memcmp +; ----------------------------------------- +_memcmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _memcmp.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _memcmp.c 33 + mov a,_memcmp_PARM_3 + orl a,(_memcmp_PARM_3 + 1) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00113$: +; _memcmp.c 34 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00107$ +; _memcmp.c 36 +00104$: + mov a,_memcmp_PARM_3 + add a,#0xff + mov r5,a + mov a,(_memcmp_PARM_3 + 1) + addc a,#0xff + mov r6,a + mov _memcmp_PARM_3,r5 + mov (_memcmp_PARM_3 + 1),r6 + mov a,r5 + orl a,r6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00114$: + mov _memcmp_buf1_1_1,r2 + mov (_memcmp_buf1_1_1 + 1),r3 + mov (_memcmp_buf1_1_1 + 2),r4 + mov r0,_memcmp_PARM_2 + mov r1,(_memcmp_PARM_2 + 1) + mov r5,(_memcmp_PARM_2 + 2) + mov dpl,r0 + mov dph,r1 + mov b,r5 + lcall __gptrget + mov r6,a + mov dpl,_memcmp_buf1_1_1 + mov dph,(_memcmp_buf1_1_1 + 1) + mov b,(_memcmp_buf1_1_1 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar6,00106$ +; Peephole 201 removed redundant sjmp +00115$: +00116$: +; _memcmp.c 37 + inc r2 + cjne r2,#0x00,00117$ + inc r3 +00117$: +; _memcmp.c 38 + mov a,#0x01 + add a,r0 + mov _memcmp_PARM_2,a +; Peephole 180 changed mov to clr + clr a + addc a,r1 + mov (_memcmp_PARM_2 + 1),a + mov (_memcmp_PARM_2 + 2),r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00106$: +; _memcmp.c 41 + mov dpl,_memcmp_PARM_2 + mov dph,(_memcmp_PARM_2 + 1) + mov b,(_memcmp_PARM_2 + 2) + lcall __gptrget + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 106 removed redundant mov + mov r2,a + clr c + subb a,r5 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + subb a,#0x00 + mov dph,a +00107$: + C$_memcmp.c$42$1$1 ==. + XG$memcmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_memcmp.cdb b/device/lib/small/_memcmp.cdb new file mode 100644 index 00000000..034eb8cd --- /dev/null +++ b/device/lib/small/_memcmp.cdb @@ -0,0 +1,2 @@ +M:_memcmp +F:G$memcmp$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_memcmp.rel b/device/lib/small/_memcmp.rel new file mode 100644 index 00000000..94c957e6 --- /dev/null +++ b/device/lib/small/_memcmp.rel @@ -0,0 +1,144 @@ +;!FILE _memcmp.asm +XH +H 9 areas 47 global symbols +M _memcmp +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 8 flags 4 +S _memcmp_PARM_2 Def0000 +S _memcmp_PARM_3 Def0003 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 7D flags 20 +S A$_memcmp$100 Def002A +S A$_memcmp$110 Def0040 +S A$_memcmp$101 Def002C +S A$_memcmp$111 Def0043 +S A$_memcmp$102 Def002E +S A$_memcmp$130 Def0054 +S A$_memcmp$121 Def004A +S A$_memcmp$103 Def0030 +S A$_memcmp$140 Def0062 +S A$_memcmp$131 Def0055 +S A$_memcmp$122 Def004B +S A$_memcmp$113 Def0046 +S A$_memcmp$104 Def0032 +S A$_memcmp$150 Def0074 +S A$_memcmp$141 Def0065 +S A$_memcmp$132 Def0056 +S A$_memcmp$123 Def004E +S A$_memcmp$105 Def0034 +S A$_memcmp$151 Def0075 +S A$_memcmp$142 Def0068 +S A$_memcmp$133 Def0058 +S A$_memcmp$106 Def0036 +S _memcmp Def0000 +S A$_memcmp$143 Def0069 +S A$_memcmp$116 Def0047 +S A$_memcmp$107 Def0039 +S A$_memcmp$153 Def0077 +S A$_memcmp$144 Def006B +S A$_memcmp$135 Def005A +S A$_memcmp$126 Def004F +S A$_memcmp$108 Def003A +S A$_memcmp$154 Def0078 +S A$_memcmp$145 Def006D +S A$_memcmp$127 Def0051 +S A$_memcmp$109 Def003D +S A$_memcmp$155 Def007A +S A$_memcmp$146 Def006F +S A$_memcmp$128 Def0052 +S A$_memcmp$138 Def005C +S A$_memcmp$148 Def0072 +S A$_memcmp$139 Def005F +S A$_memcmp$149 Def0073 +S A$_memcmp$159 Def007C +S XG$memcmp$0$0 Def007C +S C$_memcmp.c$42$1$1 Def007C +S A$_memcmp$70 Def0002 +S A$_memcmp$80 Def000C +S A$_memcmp$71 Def0004 +S A$_memcmp$90 Def001C +S A$_memcmp$81 Def000F +S A$_memcmp$91 Def001E +S A$_memcmp$73 Def0006 +S A$_memcmp$92 Def0020 +S A$_memcmp$74 Def0008 +S G$memcmp$0$0 Def0000 +S A$_memcmp$93 Def0021 +S A$_memcmp$84 Def0012 +S A$_memcmp$85 Def0014 +S A$_memcmp$76 Def000A +S A$_memcmp$95 Def0022 +S A$_memcmp$86 Def0016 +S A$_memcmp$87 Def0017 +S A$_memcmp$69 Def0000 +S A$_memcmp$97 Def0024 +S A$_memcmp$88 Def0019 +S A$_memcmp$98 Def0026 +S A$_memcmp$89 Def001B +S A$_memcmp$99 Def0028 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 E5 00 03 45 00 04 70 06 +R 00 00 00 08 29 09 00 03 29 0C 00 03 +T 00 0C +R 00 00 00 08 +T 00 0C 90 00 00 02 00 7C +R 00 00 00 08 00 06 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 E5 00 03 24 FF FD E5 00 04 34 FF FE 8D +R 00 00 00 08 29 03 00 03 29 09 00 03 +T 00 1D 00 03 8E 00 04 ED 4E 60 38 +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 24 +R 00 00 00 08 +T 00 24 8A 00 05 8B 00 06 8C 00 07 A8 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 2B 00 00 A9 00 01 AD 00 02 88 82 89 83 8D F0 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 36 12 00 00 FE 85 00 05 82 85 00 06 83 85 +R 00 00 00 08 02 03 00 00 29 07 00 03 29 0B 00 03 +T 00 41 00 07 F0 12 00 00 FF B5 06 12 +R 00 00 00 08 29 02 00 03 02 06 00 00 +T 00 4A +R 00 00 00 08 +T 00 4A +R 00 00 00 08 +T 00 4A 0A BA 00 01 0B +R 00 00 00 08 +T 00 4F +R 00 00 00 08 +T 00 4F 74 01 28 F5 00 00 E4 39 F5 00 01 8D 00 02 +R 00 00 00 08 29 06 00 03 29 0B 00 03 29 0E 00 03 +T 00 5A 80 B6 +R 00 00 00 08 +T 00 5C +R 00 00 00 08 +T 00 5C 85 00 00 82 85 00 01 83 85 00 02 F0 12 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 66 00 00 FD 8A 82 8B 83 8C F0 12 00 00 FA C3 +R 00 00 00 08 02 02 00 00 02 0C 00 00 +T 00 74 9D F5 82 E4 94 00 F5 83 +R 00 00 00 08 +T 00 7C +R 00 00 00 08 +T 00 7C 22 +R 00 00 00 08 diff --git a/device/lib/small/_memcpy.asm b/device/lib/small/_memcpy.asm new file mode 100644 index 00000000..9a0f4b04 --- /dev/null +++ b/device/lib/small/_memcpy.asm @@ -0,0 +1,139 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:13 2000 + +;-------------------------------------------------------- + .module _memcpy +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _memcpy_PARM_3 + .globl _memcpy_PARM_2 + .globl _memcpy +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_memcpy_PARM_2: + .ds 0x0003 +_memcpy_PARM_3: + .ds 0x0002 +_memcpy_dst_1_1: + .ds 0x0003 +_memcpy_ret_1_1: + .ds 0x0003 +_memcpy_s_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$memcpy$0$0 ==. +; _memcpy.c 27 +; ----------------------------------------- +; function memcpy +; ----------------------------------------- +_memcpy: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _memcpy.c 44 + mov r2,dpl + mov r3,dph + mov r4,b +; _memcpy.c 33 + mov _memcpy_ret_1_1,r2 + mov (_memcpy_ret_1_1 + 1),r3 + mov (_memcpy_ret_1_1 + 2),r4 +; _memcpy.c 34 + mov _memcpy_dst_1_1,r2 + mov (_memcpy_dst_1_1 + 1),r3 + mov (_memcpy_dst_1_1 + 2),r4 +; _memcpy.c 35 +; _memcpy.c 40 + mov r3,_memcpy_dst_1_1 + mov r4,(_memcpy_dst_1_1 + 1) + mov r2,(_memcpy_dst_1_1 + 2) + mov _memcpy_s_1_1,_memcpy_PARM_2 + mov (_memcpy_s_1_1 + 1),(_memcpy_PARM_2 + 1) + mov (_memcpy_s_1_1 + 2),(_memcpy_PARM_2 + 2) +00101$: + mov r5,_memcpy_PARM_3 + mov r0,(_memcpy_PARM_3 + 1) + dec _memcpy_PARM_3 + mov a,#0xff + cjne a,_memcpy_PARM_3,00108$ + dec (_memcpy_PARM_3 + 1) +00108$: + mov a,r5 + orl a,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _memcpy.c 41 + mov ar5,r3 + mov ar0,r4 + mov ar1,r2 + inc r3 + cjne r3,#0x00,00110$ + inc r4 +00110$: + mov dpl,_memcpy_s_1_1 + mov dph,(_memcpy_s_1_1 + 1) + mov b,(_memcpy_s_1_1 + 2) + inc _memcpy_s_1_1 + clr a + cjne a,_memcpy_s_1_1,00111$ + inc (_memcpy_s_1_1 + 1) +00111$: + lcall __gptrget +; Peephole 191 removed redundant mov + mov r6,a + mov dpl,r5 + mov dph,r0 + mov b,r1 + lcall __gptrput +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _memcpy.c 44 + mov dpl,_memcpy_ret_1_1 + mov dph,(_memcpy_ret_1_1 + 1) + mov b,(_memcpy_ret_1_1 + 2) +00104$: + C$_memcpy.c$45$1$1 ==. + XG$memcpy$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_memcpy.cdb b/device/lib/small/_memcpy.cdb new file mode 100644 index 00000000..3d6826c0 --- /dev/null +++ b/device/lib/small/_memcpy.cdb @@ -0,0 +1,2 @@ +M:_memcpy +F:G$memcpy$0$0({2}DF,DG,SV:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_memcpy.rel b/device/lib/small/_memcpy.rel new file mode 100644 index 00000000..fb85179b --- /dev/null +++ b/device/lib/small/_memcpy.rel @@ -0,0 +1,137 @@ +;!FILE _memcpy.asm +XH +H 9 areas 38 global symbols +M _memcpy +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size E flags 4 +S _memcpy_PARM_2 Def0000 +S _memcpy_PARM_3 Def0003 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 67 flags 20 +S A$_memcpy$94 Def0023 +S A$_memcpy$95 Def0025 +S A$_memcpy$86 Def0012 +S A$_memcpy$77 Def0006 +S A$_memcpy$96 Def0027 +S A$_memcpy$87 Def0014 +S A$_memcpy$78 Def0008 +S A$_memcpy$97 Def0029 +S A$_memcpy$88 Def0016 +S A$_memcpy$79 Def000A +S A$_memcpy$98 Def002C +S A$_memcpy$89 Def0018 +S A$_memcpy$100 Def002E +S A$_memcpy$110 Def0039 +S A$_memcpy$101 Def002F +S A$_memcpy$111 Def003C +S A$_memcpy$121 Def004E +S A$_memcpy$103 Def0030 +S A$_memcpy$113 Def003D +S A$_memcpy$132 Def005D +S A$_memcpy$123 Def0051 +S A$_memcpy$114 Def0040 +S A$_memcpy$133 Def0060 +S A$_memcpy$124 Def0052 +S A$_memcpy$115 Def0043 +S A$_memcpy$106 Def0032 +S _memcpy Def0000 +S A$_memcpy$134 Def0063 +S A$_memcpy$125 Def0054 +S A$_memcpy$116 Def0046 +S A$_memcpy$107 Def0034 +S A$_memcpy$126 Def0056 +S A$_memcpy$117 Def0048 +S A$_memcpy$108 Def0036 +S A$_memcpy$127 Def0058 +S A$_memcpy$118 Def0049 +S A$_memcpy$109 Def0038 +S A$_memcpy$119 Def004C +S A$_memcpy$138 Def0066 +S A$_memcpy$129 Def005B +S XG$memcpy$0$0 Def0066 +S C$_memcpy.c$45$1$1 Def0066 +S A$_memcpy$90 Def001B +S A$_memcpy$81 Def000C +S A$_memcpy$91 Def001E +S A$_memcpy$82 Def000E +S A$_memcpy$73 Def0000 +S A$_memcpy$83 Def0010 +S A$_memcpy$74 Def0002 +S G$memcpy$0$0 Def0000 +S A$_memcpy$93 Def0021 +S A$_memcpy$75 Def0004 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 0B +R 00 00 00 03 +T 00 0B +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 8A 00 08 8B 00 09 8C +R 00 00 00 08 29 09 00 03 29 0C 00 03 +T 00 0B 00 0A 8A 00 05 8B 00 06 8C +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 11 00 07 AB 00 05 AC 00 06 AA +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 17 00 07 85 00 00 00 0B 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 1C 00 01 00 0C 85 00 02 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 20 00 0D +R 00 00 00 08 29 02 00 03 +T 00 21 +R 00 00 00 08 +T 00 21 AD 00 03 A8 00 04 15 00 03 74 FF B5 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 2A 00 03 02 15 00 04 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 2E +R 00 00 00 08 +T 00 2E ED 48 60 2B +R 00 00 00 08 +T 00 32 +R 00 00 00 08 +T 00 32 8B 05 8C 00 8A 01 0B BB 00 01 0C +R 00 00 00 08 +T 00 3D +R 00 00 00 08 +T 00 3D 85 00 0B 82 85 00 0C 83 85 00 0D F0 05 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 47 00 0B E4 B5 00 0B 02 05 00 0C +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 4E +R 00 00 00 08 +T 00 4E 12 00 00 FE 8D 82 88 83 89 F0 12 00 00 80 +R 00 00 00 08 02 03 00 01 02 0D 00 00 +T 00 5C C4 +R 00 00 00 08 +T 00 5D +R 00 00 00 08 +T 00 5D 85 00 08 82 85 00 09 83 85 00 0A F0 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 66 +R 00 00 00 08 +T 00 66 22 +R 00 00 00 08 diff --git a/device/lib/small/_memset.asm b/device/lib/small/_memset.asm new file mode 100644 index 00000000..ded66d9c --- /dev/null +++ b/device/lib/small/_memset.asm @@ -0,0 +1,113 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:14 2000 + +;-------------------------------------------------------- + .module _memset +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _memset_PARM_3 + .globl _memset_PARM_2 + .globl _memset +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_memset_PARM_2: + .ds 0x0001 +_memset_PARM_3: + .ds 0x0002 +_memset_buf_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$memset$0$0 ==. +; _memset.c 27 +; ----------------------------------------- +; function memset +; ----------------------------------------- +_memset: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _memset.c 40 + mov _memset_buf_1_1,dpl + mov (_memset_buf_1_1 + 1),dph + mov (_memset_buf_1_1 + 2),b +; _memset.c 33 + mov r5,_memset_buf_1_1 + mov r6,(_memset_buf_1_1 + 1) + mov r7,(_memset_buf_1_1 + 2) +; _memset.c 35 + mov r0,_memset_PARM_3 + mov r1,(_memset_PARM_3 + 1) +00101$: + mov ar2,r0 + mov ar3,r1 + dec r0 + cjne r0,#0xff,00108$ + dec r1 +00108$: + mov a,r2 + orl a,r3 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _memset.c 36 + mov dpl,r5 + mov dph,r6 + mov b,r7 + mov a,_memset_PARM_2 + lcall __gptrput +; _memset.c 37 + inc r5 + cjne r5,#0x00,00110$ + inc r6 +00110$: +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _memset.c 40 + mov dpl,_memset_buf_1_1 + mov dph,(_memset_buf_1_1 + 1) + mov b,(_memset_buf_1_1 + 2) +00104$: + C$_memset.c$41$1$1 ==. + XG$memset$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_memset.cdb b/device/lib/small/_memset.cdb new file mode 100644 index 00000000..f04d3149 --- /dev/null +++ b/device/lib/small/_memset.cdb @@ -0,0 +1,2 @@ +M:_memset +F:G$memset$0$0({2}DF,DG,SV:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_memset.rel b/device/lib/small/_memset.rel new file mode 100644 index 00000000..fd537072 --- /dev/null +++ b/device/lib/small/_memset.rel @@ -0,0 +1,95 @@ +;!FILE _memset.asm +XH +H 9 areas 24 global symbols +M _memset +S __gptrput Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 6 flags 4 +S _memset_PARM_2 Def0000 +S _memset_PARM_3 Def0001 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 3C flags 20 +S A$_memset$94 Def0024 +S A$_memset$95 Def0026 +S A$_memset$86 Def001C +S A$_memset$77 Def000F +S A$_memset$96 Def0028 +S A$_memset$87 Def001D +S A$_memset$78 Def0011 +S A$_memset$69 Def0000 +S A$_memset$98 Def002B +S A$_memset$89 Def001E +S A$_memset$99 Def002C +S A$_memset$100 Def002F +S A$_memset$112 Def003B +S A$_memset$103 Def0030 +S A$_memset$106 Def0032 +S _memset Def0000 +S A$_memset$107 Def0035 +S A$_memset$108 Def0038 +S C$_memset.c$41$1$1 Def003B +S XG$memset$0$0 Def003B +S A$_memset$70 Def0003 +S A$_memset$80 Def0013 +S A$_memset$71 Def0006 +S A$_memset$81 Def0015 +S A$_memset$82 Def0017 +S A$_memset$73 Def0009 +S A$_memset$92 Def0020 +S A$_memset$83 Def0018 +S A$_memset$74 Def000B +S G$memset$0$0 Def0000 +S A$_memset$93 Def0022 +S A$_memset$84 Def001B +S A$_memset$75 Def000D +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 01 +R 00 00 00 03 +T 00 01 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 85 82 00 03 85 83 00 04 85 F0 00 05 AD +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0C 00 03 +T 00 0A 00 03 AE 00 04 AF 00 05 A8 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 10 00 01 A9 00 02 +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 13 +R 00 00 00 08 +T 00 13 88 02 89 03 18 B8 FF 01 19 +R 00 00 00 08 +T 00 1C +R 00 00 00 08 +T 00 1C EA 4B 60 12 +R 00 00 00 08 +T 00 20 +R 00 00 00 08 +T 00 20 8D 82 8E 83 8F F0 E5 00 00 12 00 00 0D BD +R 00 00 00 08 29 09 00 03 02 0C 00 00 +T 00 2D 00 01 0E +R 00 00 00 08 +T 00 30 +R 00 00 00 08 +T 00 30 80 E1 +R 00 00 00 08 +T 00 32 +R 00 00 00 08 +T 00 32 85 00 03 82 85 00 04 83 85 00 05 F0 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 3B +R 00 00 00 08 +T 00 3B 22 +R 00 00 00 08 diff --git a/device/lib/small/_modsint.asm b/device/lib/small/_modsint.asm new file mode 100644 index 00000000..b5d1a8a2 --- /dev/null +++ b/device/lib/small/_modsint.asm @@ -0,0 +1,148 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:14 2000 + +;-------------------------------------------------------- + .module _modsint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __modsint_PARM_2 + .globl __modsint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__modsint_PARM_2: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_modsint$0$0 ==. +; _modsint.c 26 +; ----------------------------------------- +; function _modsint +; ----------------------------------------- +__modsint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _modsint.c 0 + mov r2,dpl + mov r3,dph +; _modsint.c 30 + mov a,r3 + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r4,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: + clr c + clr a + subb a,r2 + mov r5,a + clr a + subb a,r3 + mov r6,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar5,r2 + mov ar6,r3 +00107$: + mov ar2,r5 + mov ar3,r6 +; _modsint.c 31 + mov a,(__modsint_PARM_2 + 1) + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,__modsint_PARM_2 + mov r6,a + clr a + subb a,(__modsint_PARM_2 + 1) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov r6,__modsint_PARM_2 + mov r7,(__modsint_PARM_2 + 1) +00109$: + mov __moduint_PARM_2,r6 + mov (__moduint_PARM_2 + 1),r7 + push ar4 + push ar5 + mov dpl,r2 + mov dph,r3 + lcall __moduint + mov r2,dpl + mov r3,dph + pop ar5 + pop ar4 +; _modsint.c 33 + mov a,r5 + xrl a,ar4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _modsint.c 34 + clr c + clr a + subb a,r2 + mov dpl,a + clr a + subb a,r3 + mov dph,a +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _modsint.c 36 + mov dpl,r2 + mov dph,r3 +00104$: + C$_modsint.c$37$1$1 ==. + XG$_modsint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_modsint.cdb b/device/lib/small/_modsint.cdb new file mode 100644 index 00000000..231bb3b5 --- /dev/null +++ b/device/lib/small/_modsint.cdb @@ -0,0 +1,2 @@ +M:_modsint +F:G$_modsint$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_modsint.rel b/device/lib/small/_modsint.rel new file mode 100644 index 00000000..0bf4f4d6 --- /dev/null +++ b/device/lib/small/_modsint.rel @@ -0,0 +1,128 @@ +;!FILE _modsint.asm +XH +H 8 areas 44 global symbols +M _modsint +S __moduint_PARM_2 Ref0000 +S __moduint Ref0000 +A _CODE size 0 flags 0 +A DSEG size 2 flags 0 +S __modsint_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 5F flags 20 +S XG$_modsint$0$0 Def005E +S G$_modsint$0$0 Def0000 +S A$_modsint$100 Def0024 +S A$_modsint$110 Def002F +S A$_modsint$101 Def0025 +S A$_modsint$120 Def0042 +S A$_modsint$111 Def0031 +S A$_modsint$102 Def0026 +S A$_modsint$121 Def0044 +S A$_modsint$103 Def0028 +S A$_modsint$131 Def004F +S A$_modsint$122 Def0046 +S A$_modsint$113 Def0033 +S A$_modsint$104 Def0029 +S A$_modsint$132 Def0050 +S A$_modsint$123 Def0048 +S A$_modsint$114 Def0035 +S A$_modsint$105 Def002A +S A$_modsint$142 Def005A +S A$_modsint$133 Def0051 +S A$_modsint$115 Def0037 +S A$_modsint$106 Def002C +S A$_modsint$143 Def005C +S A$_modsint$134 Def0052 +S A$_modsint$125 Def004A +S A$_modsint$116 Def0039 +S A$_modsint$135 Def0054 +S A$_modsint$126 Def004B +S A$_modsint$117 Def003B +S A$_modsint$108 Def002D +S A$_modsint$136 Def0055 +S A$_modsint$118 Def003D +S A$_modsint$137 Def0056 +S A$_modsint$128 Def004D +S A$_modsint$119 Def003F +S A$_modsint$147 Def005E +S A$_modsint$139 Def0058 +S C$_modsint.c$37$1$1 Def005E +S A$_modsint$80 Def0010 +S A$_modsint$71 Def0008 +S A$_modsint$81 Def0011 +S A$_modsint$63 Def0000 +S A$_modsint$91 Def001C +S A$_modsint$73 Def0009 +S A$_modsint$64 Def0002 +S A$_modsint$92 Def001E +S A$_modsint$83 Def0012 +S A$_modsint$93 Def001F +S A$_modsint$75 Def000B +S A$_modsint$66 Def0004 +S A$_modsint$94 Def0020 +S A$_modsint$85 Def0014 +S A$_modsint$76 Def000C +S A$_modsint$67 Def0005 +S A$_modsint$86 Def0016 +S A$_modsint$77 Def000D +S A$_modsint$68 Def0006 +S A$_modsint$96 Def0021 +S A$_modsint$78 Def000E +S A$_modsint$69 Def0007 +S A$_modsint$88 Def0018 +S A$_modsint$79 Def000F +S A$_modsint$98 Def0022 +S A$_modsint$89 Def001A +S __modsint Def0000 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 EB 33 E4 33 FC 60 09 +R 00 00 00 07 +T 00 0B +R 00 00 00 07 +T 00 0B C3 E4 9A FD E4 9B FE 80 04 +R 00 00 00 07 +T 00 14 +R 00 00 00 07 +T 00 14 8A 05 8B 06 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 8D 02 8E 03 E5 00 01 33 E4 33 FD 60 0B +R 00 00 00 07 29 07 00 01 +T 00 24 +R 00 00 00 07 +T 00 24 C3 E4 95 00 00 FE E4 95 00 01 FF 80 04 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 00 2F +R 00 00 00 07 +T 00 2F AE 00 00 AF 00 01 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 00 33 +R 00 00 00 07 +T 00 33 8E 00 00 8F 00 01 C0 04 C0 05 8A 82 8B 83 +R 00 00 00 07 2B 03 00 00 2B 06 00 00 +T 00 3F 12 00 00 AA 82 AB 83 D0 05 D0 04 ED 65 04 +R 00 00 00 07 02 03 00 01 +T 00 4D 60 0B +R 00 00 00 07 +T 00 4F +R 00 00 00 07 +T 00 4F C3 E4 9A F5 82 E4 9B F5 83 80 04 +R 00 00 00 07 +T 00 5A +R 00 00 00 07 +T 00 5A 8A 82 8B 83 +R 00 00 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E 22 +R 00 00 00 07 diff --git a/device/lib/small/_modslong.asm b/device/lib/small/_modslong.asm new file mode 100644 index 00000000..8678e037 --- /dev/null +++ b/device/lib/small/_modslong.asm @@ -0,0 +1,183 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:14 2000 + +;-------------------------------------------------------- + .module _modslong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __modslong_PARM_2 + .globl __modslong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__modslong_PARM_2: + .ds 0x0004 +__modslong_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_modslong$0$0 ==. +; _modslong.c 24 +; ----------------------------------------- +; function _modslong +; ----------------------------------------- +__modslong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _modslong.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _modslong.c 28 +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: + clr c + clr a + subb a,r2 + mov __modslong_sloc0_1_0,a + clr a + subb a,r3 + mov (__modslong_sloc0_1_0 + 1),a + clr a + subb a,r4 + mov (__modslong_sloc0_1_0 + 2),a + clr a + subb a,r5 + mov (__modslong_sloc0_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov __modslong_sloc0_1_0,r2 + mov (__modslong_sloc0_1_0 + 1),r3 + mov (__modslong_sloc0_1_0 + 2),r4 + mov (__modslong_sloc0_1_0 + 3),r5 +00107$: + mov r2,__modslong_sloc0_1_0 + mov r3,(__modslong_sloc0_1_0 + 1) + mov r4,(__modslong_sloc0_1_0 + 2) + mov r5,(__modslong_sloc0_1_0 + 3) +; _modslong.c 29 + mov a,(__modslong_PARM_2 + 3) + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,__modslong_PARM_2 + mov __modslong_sloc0_1_0,a + clr a + subb a,(__modslong_PARM_2 + 1) + mov (__modslong_sloc0_1_0 + 1),a + clr a + subb a,(__modslong_PARM_2 + 2) + mov (__modslong_sloc0_1_0 + 2),a + clr a + subb a,(__modslong_PARM_2 + 3) + mov (__modslong_sloc0_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov __modslong_sloc0_1_0,__modslong_PARM_2 + mov (__modslong_sloc0_1_0 + 1),(__modslong_PARM_2 + 1) + mov (__modslong_sloc0_1_0 + 2),(__modslong_PARM_2 + 2) + mov (__modslong_sloc0_1_0 + 3),(__modslong_PARM_2 + 3) +00109$: + mov __modulong_PARM_2,__modslong_sloc0_1_0 + mov (__modulong_PARM_2 + 1),(__modslong_sloc0_1_0 + 1) + mov (__modulong_PARM_2 + 2),(__modslong_sloc0_1_0 + 2) + mov (__modulong_PARM_2 + 3),(__modslong_sloc0_1_0 + 3) + push ar6 + push ar7 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 + lcall __modulong + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a + pop ar7 + pop ar6 +; _modslong.c 31 + mov a,r7 + xrl a,ar6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _modslong.c 32 + clr c + clr a + subb a,r2 + mov dpl,a + clr a + subb a,r3 + mov dph,a + clr a + subb a,r4 + mov b,a + clr a + subb a,r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _modslong.c 34 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 +00104$: + C$_modslong.c$35$1$1 ==. + XG$_modslong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_modslong.cdb b/device/lib/small/_modslong.cdb new file mode 100644 index 00000000..5af6a222 --- /dev/null +++ b/device/lib/small/_modslong.cdb @@ -0,0 +1,2 @@ +M:_modslong +F:G$_modslong$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_modslong.rel b/device/lib/small/_modslong.rel new file mode 100644 index 00000000..7b1240c5 --- /dev/null +++ b/device/lib/small/_modslong.rel @@ -0,0 +1,184 @@ +;!FILE _modslong.asm +XH +H 8 areas 64 global symbols +M _modslong +S __modulong_PARM_2 Ref0000 +S __modulong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +S __modslong_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 9E flags 20 +S A$_modslong$140 Def0069 +S A$_modslong$131 Def0052 +S A$_modslong$122 Def0044 +S A$_modslong$150 Def007C +S A$_modslong$141 Def006B +S A$_modslong$132 Def0055 +S A$_modslong$123 Def0046 +S A$_modslong$114 Def0038 +S A$_modslong$105 Def0030 +S A$_modslong$160 Def0086 +S A$_modslong$151 Def007E +S A$_modslong$142 Def006D +S A$_modslong$133 Def0058 +S A$_modslong$124 Def0048 +S A$_modslong$115 Def0039 +S A$_modslong$106 Def0032 +S A$_modslong$170 Def0093 +S A$_modslong$161 Def0087 +S A$_modslong$143 Def006F +S A$_modslong$125 Def0049 +S A$_modslong$116 Def003A +S A$_modslong$107 Def0033 +S A$_modslong$162 Def0088 +S A$_modslong$153 Def0080 +S A$_modslong$144 Def0071 +S A$_modslong$135 Def005B +S A$_modslong$126 Def004B +S A$_modslong$117 Def003C +S A$_modslong$108 Def0034 +S A$_modslong$172 Def0094 +S A$_modslong$163 Def008A +S A$_modslong$154 Def0081 +S A$_modslong$145 Def0072 +S A$_modslong$136 Def005E +S A$_modslong$118 Def003E +S A$_modslong$182 Def009D +S A$_modslong$164 Def008B +S A$_modslong$146 Def0075 +S A$_modslong$137 Def0061 +S A$_modslong$128 Def004D +S A$_modslong$119 Def003F +S A$_modslong$165 Def008C +S A$_modslong$156 Def0083 +S A$_modslong$147 Def0077 +S A$_modslong$138 Def0064 +S A$_modslong$175 Def0096 +S A$_modslong$166 Def008E +S A$_modslong$148 Def0079 +S A$_modslong$139 Def0067 +S A$_modslong$176 Def0098 +S A$_modslong$167 Def008F +S A$_modslong$149 Def007B +S A$_modslong$177 Def009A +S A$_modslong$168 Def0090 +S A$_modslong$159 Def0085 +S A$_modslong$178 Def009C +S A$_modslong$169 Def0092 +S C$_modslong.c$35$1$1 Def009D +S A$_modslong$70 Def0006 +S A$_modslong$80 Def000E +S A$_modslong$71 Def0007 +S A$_modslong$90 Def001B +S A$_modslong$81 Def000F +S A$_modslong$72 Def0008 +S A$_modslong$91 Def001C +S A$_modslong$82 Def0010 +S A$_modslong$73 Def0009 +S A$_modslong$83 Def0012 +S A$_modslong$65 Def0000 +S A$_modslong$93 Def001E +S A$_modslong$84 Def0013 +S A$_modslong$75 Def000A +S A$_modslong$66 Def0002 +S A$_modslong$85 Def0014 +S A$_modslong$67 Def0004 +S A$_modslong$95 Def0020 +S A$_modslong$86 Def0016 +S A$_modslong$77 Def000B +S A$_modslong$96 Def0022 +S A$_modslong$87 Def0017 +S A$_modslong$97 Def0024 +S A$_modslong$88 Def0018 +S A$_modslong$79 Def000D +S A$_modslong$98 Def0026 +S A$_modslong$89 Def001A +S __modslong Def0000 +S XG$_modslong$0$0 Def009D +S G$_modslong$0$0 Def0000 +S A$_modslong$100 Def0028 +S A$_modslong$110 Def0035 +S A$_modslong$101 Def002A +S A$_modslong$120 Def0041 +S A$_modslong$102 Def002C +S A$_modslong$130 Def004F +S A$_modslong$121 Def0043 +S A$_modslong$112 Def0036 +S A$_modslong$103 Def002E +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 FD 33 E4 33 FE 60 13 +R 00 00 00 07 +T 00 0D +R 00 00 00 07 +T 00 0D C3 E4 9A F5 00 04 E4 9B F5 00 05 E4 9C F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 19 00 06 E4 9D F5 00 07 80 08 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 20 +R 00 00 00 07 +T 00 20 8A 00 04 8B 00 05 8C 00 06 8D +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 27 00 07 +R 00 00 00 07 29 02 00 01 +T 00 28 +R 00 00 00 07 +T 00 28 AA 00 04 AB 00 05 AC 00 06 AD +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 2F 00 07 E5 00 03 33 E4 33 FF 60 17 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 38 +R 00 00 00 07 +T 00 38 C3 E4 95 00 00 F5 00 04 E4 95 00 01 F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 00 42 00 05 E4 95 00 02 F5 00 06 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 4A 00 03 F5 00 07 80 0C +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 4F +R 00 00 00 07 +T 00 4F 85 00 00 00 04 85 00 01 +R 00 00 00 07 29 03 00 01 29 05 00 01 29 08 00 01 +T 00 54 00 05 85 00 02 00 06 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 00 59 00 03 00 07 +R 00 00 00 07 29 02 00 01 29 04 00 01 +T 00 5B +R 00 00 00 07 +T 00 5B 85 00 04 00 00 85 00 05 +R 00 00 00 07 29 03 00 01 2B 05 00 00 29 08 00 01 +T 00 60 00 01 85 00 06 00 02 85 +R 00 00 00 07 2B 02 00 00 29 05 00 01 2B 07 00 00 +T 00 65 00 07 00 03 C0 06 C0 07 8A 82 8B 83 8C F0 +R 00 00 00 07 29 02 00 01 2B 04 00 00 +T 00 71 ED 12 00 00 AA 82 AB 83 AC F0 FD D0 07 D0 +R 00 00 00 07 02 04 00 01 +T 00 7F 06 EF 65 06 60 11 +R 00 00 00 07 +T 00 85 +R 00 00 00 07 +T 00 85 C3 E4 9A F5 82 E4 9B F5 83 E4 9C F5 F0 E4 +R 00 00 00 07 +T 00 93 9D 80 07 +R 00 00 00 07 +T 00 96 +R 00 00 00 07 +T 00 96 8A 82 8B 83 8C F0 ED +R 00 00 00 07 +T 00 9D +R 00 00 00 07 +T 00 9D 22 +R 00 00 00 07 diff --git a/device/lib/small/_moduint.asm b/device/lib/small/_moduint.asm new file mode 100644 index 00000000..52d90914 --- /dev/null +++ b/device/lib/small/_moduint.asm @@ -0,0 +1,160 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:14 2000 + +;-------------------------------------------------------- + .module _moduint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __moduint_PARM_2 + .globl __moduint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +__moduint_PARM_2: + .ds 0x0002 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_moduint$0$0 ==. +; _moduint.c 30 +; ----------------------------------------- +; function _moduint +; ----------------------------------------- +__moduint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _moduint.c 52 + mov r2,dpl + mov r3,dph +; _moduint.c 32 + mov r4,#0x00 +; _moduint.c 35 + mov r5,#0x00 +00103$: + mov a,(__moduint_PARM_2 + 1) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00117$ +00119$: +; _moduint.c 36 + mov r6,__moduint_PARM_2 + mov a,(__moduint_PARM_2 + 1) + xch a,r6 + add a,acc + xch a,r6 + rlc a + mov r7,a + mov __moduint_PARM_2,r6 + mov (__moduint_PARM_2 + 1),r7 +; _moduint.c 37 + clr c + mov a,r2 + subb a,r6 + mov a,r3 + subb a,r7 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00102$ +00120$: +; _moduint.c 39 + mov __moduint_PARM_2,r6 + mov a,r7 + clr c + rrc a + xch a,__moduint_PARM_2 + rrc a + xch a,__moduint_PARM_2 + mov (__moduint_PARM_2 + 1),a +; _moduint.c 40 +; Peephole 132 changed ljmp to sjmp + sjmp 00117$ +00102$: +; _moduint.c 42 + inc r5 + mov ar4,r5 +; _moduint.c 45 +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00117$: +00108$: +; _moduint.c 46 + clr c + mov a,r2 + subb a,__moduint_PARM_2 + mov a,r3 + subb a,(__moduint_PARM_2 + 1) +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00121$: +; _moduint.c 47 + clr c + mov a,r2 + subb a,__moduint_PARM_2 + mov r2,a + mov a,r3 + subb a,(__moduint_PARM_2 + 1) + mov r3,a +00107$: +; _moduint.c 49 + mov a,(__moduint_PARM_2 + 1) + clr c + rrc a + xch a,__moduint_PARM_2 + rrc a + xch a,__moduint_PARM_2 + mov (__moduint_PARM_2 + 1),a +; _moduint.c 50 + mov ar5,r4 + dec r4 + mov a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00108$ +00122$: +; _moduint.c 52 + mov dpl,r2 + mov dph,r3 +00111$: + C$_moduint.c$53$1$1 ==. + XG$_moduint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_moduint.cdb b/device/lib/small/_moduint.cdb new file mode 100644 index 00000000..2634be18 --- /dev/null +++ b/device/lib/small/_moduint.cdb @@ -0,0 +1,2 @@ +M:_moduint +F:G$_moduint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_moduint.rel b/device/lib/small/_moduint.rel new file mode 100644 index 00000000..eb22b448 --- /dev/null +++ b/device/lib/small/_moduint.rel @@ -0,0 +1,133 @@ +;!FILE _moduint.asm +XH +H 9 areas 44 global symbols +M _moduint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 2 flags 4 +S __moduint_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 60 flags 20 +S XG$_moduint$0$0 Def005F +S G$_moduint$0$0 Def0000 +S A$_moduint$100 Def0027 +S A$_moduint$101 Def0028 +S A$_moduint$120 Def0038 +S A$_moduint$102 Def0029 +S A$_moduint$130 Def0041 +S A$_moduint$121 Def0039 +S A$_moduint$112 Def0033 +S A$_moduint$103 Def002A +S A$_moduint$140 Def004C +S A$_moduint$131 Def0042 +S A$_moduint$122 Def003A +S A$_moduint$113 Def0034 +S A$_moduint$104 Def002C +S A$_moduint$141 Def004D +S A$_moduint$132 Def0043 +S A$_moduint$123 Def003C +S A$_moduint$105 Def002D +S A$_moduint$151 Def0059 +S A$_moduint$142 Def004E +S A$_moduint$133 Def0045 +S A$_moduint$124 Def003D +S A$_moduint$106 Def002F +S A$_moduint$143 Def0050 +S A$_moduint$134 Def0046 +S A$_moduint$116 Def0036 +S A$_moduint$144 Def0051 +S A$_moduint$135 Def0047 +S A$_moduint$154 Def005B +S A$_moduint$145 Def0053 +S A$_moduint$136 Def0049 +S A$_moduint$127 Def003F +S A$_moduint$109 Def0031 +S A$_moduint$155 Def005D +S A$_moduint$147 Def0055 +S A$_moduint$148 Def0057 +S A$_moduint$139 Def004A +S A$_moduint$149 Def0058 +S A$_moduint$159 Def005F +S C$_moduint.c$53$1$1 Def005F +S A$_moduint$80 Def0010 +S A$_moduint$71 Def0008 +S A$_moduint$90 Def001E +S A$_moduint$81 Def0012 +S A$_moduint$72 Def000A +S A$_moduint$91 Def001F +S A$_moduint$82 Def0014 +S A$_moduint$73 Def000B +S A$_moduint$64 Def0000 +S A$_moduint$92 Def0020 +S A$_moduint$83 Def0015 +S A$_moduint$65 Def0002 +S A$_moduint$93 Def0021 +S A$_moduint$84 Def0017 +S A$_moduint$75 Def000D +S A$_moduint$94 Def0022 +S A$_moduint$85 Def0018 +S A$_moduint$67 Def0004 +S A$_moduint$86 Def0019 +S A$_moduint$77 Def000E +S A$_moduint$96 Def0023 +S A$_moduint$87 Def001A +S A$_moduint$69 Def0006 +S A$_moduint$88 Def001C +S A$_moduint$99 Def0025 +S __moduint Def0000 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 7C 00 7D 00 +R 00 00 00 08 +T 00 08 +R 00 00 00 08 +T 00 08 E5 00 01 23 54 01 FE 70 28 +R 00 00 00 08 29 03 00 03 +T 00 10 +R 00 00 00 08 +T 00 10 AE 00 00 E5 00 01 CE 25 E0 CE 33 FF 8E +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 1B 00 00 8F 00 01 C3 EA 9E EB 9F 50 0E +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 25 +R 00 00 00 08 +T 00 25 8E 00 00 EF C3 13 C5 00 00 13 C5 00 00 F5 +R 00 00 00 08 29 03 00 03 29 09 00 03 29 0D 00 03 +T 00 30 00 01 80 05 +R 00 00 00 08 29 02 00 03 +T 00 33 +R 00 00 00 08 +T 00 33 0D 8D 04 80 D0 +R 00 00 00 08 +T 00 38 +R 00 00 00 08 +T 00 38 +R 00 00 00 08 +T 00 38 C3 EA 95 00 00 EB 95 00 01 40 09 +R 00 00 00 08 29 05 00 03 29 09 00 03 +T 00 41 +R 00 00 00 08 +T 00 41 C3 EA 95 00 00 FA EB 95 00 01 FB +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 4A +R 00 00 00 08 +T 00 4A E5 00 01 C3 13 C5 00 00 13 C5 00 00 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0C 00 03 +T 00 54 00 01 8C 05 1C ED 70 DD +R 00 00 00 08 29 02 00 03 +T 00 5B +R 00 00 00 08 +T 00 5B 8A 82 8B 83 +R 00 00 00 08 +T 00 5F +R 00 00 00 08 +T 00 5F 22 +R 00 00 00 08 diff --git a/device/lib/small/_modulong.asm b/device/lib/small/_modulong.asm new file mode 100644 index 00000000..e8ccea67 --- /dev/null +++ b/device/lib/small/_modulong.asm @@ -0,0 +1,197 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:14 2000 + +;-------------------------------------------------------- + .module _modulong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __modulong_PARM_2 + .globl __modulong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +__modulong_PARM_2: + .ds 0x0004 +__modulong_count_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_modulong$0$0 ==. +; _modulong.c 29 +; ----------------------------------------- +; function _modulong +; ----------------------------------------- +__modulong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _modulong.c 51 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _modulong.c 31 + mov __modulong_count_1_1,#0x00 +; _modulong.c 34 + mov __modulong_count_1_1,#0x00 +00103$: + mov a,(__modulong_PARM_2 + 3) + rl a + anl a,#0x01 +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00117$ +00119$: +; _modulong.c 35 + mov a,__modulong_PARM_2 + add a,acc + mov r0,a + mov a,(__modulong_PARM_2 + 1) + rlc a + mov r1,a + mov a,(__modulong_PARM_2 + 2) + rlc a + mov r6,a + mov a,(__modulong_PARM_2 + 3) + rlc a + mov r7,a + mov __modulong_PARM_2,r0 + mov (__modulong_PARM_2 + 1),r1 + mov (__modulong_PARM_2 + 2),r6 + mov (__modulong_PARM_2 + 3),r7 +; _modulong.c 36 + clr c + mov a,r2 + subb a,r0 + mov a,r3 + subb a,r1 + mov a,r4 + subb a,r6 + mov a,r5 + subb a,r7 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00102$ +00120$: +; _modulong.c 38 + clr c + mov a,r7 + rrc a + mov (__modulong_PARM_2 + 3),a + mov a,r6 + rrc a + mov (__modulong_PARM_2 + 2),a + mov a,r1 + rrc a + mov (__modulong_PARM_2 + 1),a + mov a,r0 + rrc a + mov __modulong_PARM_2,a +; _modulong.c 39 +; Peephole 132 changed ljmp to sjmp + sjmp 00117$ +00102$: +; _modulong.c 41 + inc __modulong_count_1_1 + ljmp 00103$ +; _modulong.c 44 +00117$: + mov r6,__modulong_count_1_1 +00108$: +; _modulong.c 45 + clr c + mov a,r2 + subb a,__modulong_PARM_2 + mov a,r3 + subb a,(__modulong_PARM_2 + 1) + mov a,r4 + subb a,(__modulong_PARM_2 + 2) + mov a,r5 + subb a,(__modulong_PARM_2 + 3) +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00121$: +; _modulong.c 46 + clr c + mov a,r2 + subb a,__modulong_PARM_2 + mov r2,a + mov a,r3 + subb a,(__modulong_PARM_2 + 1) + mov r3,a + mov a,r4 + subb a,(__modulong_PARM_2 + 2) + mov r4,a + mov a,r5 + subb a,(__modulong_PARM_2 + 3) + mov r5,a +00107$: +; _modulong.c 48 + clr c + mov a,(__modulong_PARM_2 + 3) + rrc a + mov (__modulong_PARM_2 + 3),a + mov a,(__modulong_PARM_2 + 2) + rrc a + mov (__modulong_PARM_2 + 2),a + mov a,(__modulong_PARM_2 + 1) + rrc a + mov (__modulong_PARM_2 + 1),a + mov a,__modulong_PARM_2 + rrc a + mov __modulong_PARM_2,a +; _modulong.c 49 + mov ar7,r6 + dec r6 + mov a,r7 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00108$ +00122$: +; _modulong.c 51 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 +00111$: + C$_modulong.c$52$1$1 ==. + XG$_modulong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_modulong.cdb b/device/lib/small/_modulong.cdb new file mode 100644 index 00000000..65d66212 --- /dev/null +++ b/device/lib/small/_modulong.cdb @@ -0,0 +1,2 @@ +M:_modulong +F:G$_modulong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_modulong.rel b/device/lib/small/_modulong.rel new file mode 100644 index 00000000..f2f6b435 --- /dev/null +++ b/device/lib/small/_modulong.rel @@ -0,0 +1,187 @@ +;!FILE _modulong.asm +XH +H 9 areas 68 global symbols +M _modulong +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 5 flags 4 +S __modulong_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 96 flags 20 +S A$_modulong$120 Def0040 +S A$_modulong$111 Def0037 +S A$_modulong$102 Def002F +S A$_modulong$121 Def0042 +S A$_modulong$103 Def0030 +S A$_modulong$140 Def0054 +S A$_modulong$122 Def0043 +S A$_modulong$104 Def0031 +S A$_modulong$150 Def0060 +S A$_modulong$141 Def0055 +S A$_modulong$132 Def004C +S A$_modulong$123 Def0044 +S A$_modulong$114 Def0039 +S A$_modulong$105 Def0032 +S A$_modulong$160 Def006B +S A$_modulong$142 Def0057 +S A$_modulong$133 Def004E +S A$_modulong$124 Def0046 +S A$_modulong$115 Def003A +S A$_modulong$106 Def0033 +S A$_modulong$170 Def0076 +S A$_modulong$161 Def006C +S A$_modulong$143 Def0058 +S A$_modulong$125 Def0047 +S A$_modulong$116 Def003B +S A$_modulong$107 Def0034 +S A$_modulong$180 Def0086 +S A$_modulong$171 Def0077 +S A$_modulong$162 Def006E +S A$_modulong$153 Def0062 +S A$_modulong$144 Def005A +S A$_modulong$126 Def0048 +S A$_modulong$117 Def003C +S A$_modulong$108 Def0035 +S A$_modulong$190 Def0090 +S A$_modulong$172 Def0079 +S A$_modulong$163 Def006F +S A$_modulong$154 Def0063 +S A$_modulong$145 Def005B +S A$_modulong$136 Def0051 +S A$_modulong$118 Def003E +S A$_modulong$109 Def0036 +S A$_modulong$191 Def0092 +S A$_modulong$182 Def0088 +S A$_modulong$173 Def007B +S A$_modulong$164 Def0070 +S A$_modulong$155 Def0064 +S A$_modulong$146 Def005D +S A$_modulong$119 Def003F +S A$_modulong$192 Def0094 +S A$_modulong$183 Def008A +S A$_modulong$174 Def007C +S A$_modulong$165 Def0072 +S A$_modulong$156 Def0066 +S A$_modulong$147 Def005E +S A$_modulong$129 Def004A +S A$_modulong$184 Def008B +S A$_modulong$175 Def007E +S A$_modulong$157 Def0067 +S A$_modulong$139 Def0053 +S A$_modulong$176 Def0080 +S A$_modulong$158 Def0068 +S A$_modulong$186 Def008C +S A$_modulong$177 Def0081 +S A$_modulong$168 Def0073 +S A$_modulong$159 Def006A +S A$_modulong$196 Def0095 +S A$_modulong$178 Def0083 +S A$_modulong$169 Def0074 +S A$_modulong$179 Def0085 +S A$_modulong$189 Def008E +S C$_modulong.c$52$1$1 Def0095 +S A$_modulong$71 Def0007 +S A$_modulong$90 Def001E +S A$_modulong$81 Def0013 +S A$_modulong$91 Def0020 +S A$_modulong$73 Def000A +S A$_modulong$92 Def0021 +S A$_modulong$93 Def0022 +S A$_modulong$84 Def0015 +S A$_modulong$75 Def000D +S A$_modulong$66 Def0000 +S A$_modulong$94 Def0024 +S A$_modulong$85 Def0017 +S A$_modulong$76 Def000F +S A$_modulong$67 Def0002 +S A$_modulong$95 Def0025 +S A$_modulong$86 Def0019 +S A$_modulong$77 Def0010 +S A$_modulong$68 Def0004 +S A$_modulong$96 Def0026 +S A$_modulong$87 Def001A +S A$_modulong$69 Def0006 +S A$_modulong$97 Def0028 +S A$_modulong$88 Def001C +S A$_modulong$79 Def0012 +S A$_modulong$98 Def002A +S A$_modulong$89 Def001D +S A$_modulong$99 Def002C +S __modulong Def0000 +S XG$_modulong$0$0 Def0095 +S G$_modulong$0$0 Def0000 +S A$_modulong$101 Def002E +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD 75 00 04 00 75 00 04 +R 00 00 00 08 29 0A 00 03 29 0E 00 03 +T 00 0C 00 +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D E5 00 03 23 54 01 F8 70 3C +R 00 00 00 08 29 03 00 03 +T 00 15 +R 00 00 00 08 +T 00 15 E5 00 00 25 E0 F8 E5 00 01 33 F9 E5 00 02 +R 00 00 00 08 29 03 00 03 29 09 00 03 29 0E 00 03 +T 00 20 33 FE E5 00 03 33 FF 88 00 00 89 00 01 8E +R 00 00 00 08 29 05 00 03 29 0A 00 03 29 0D 00 03 +T 00 2B 00 02 8F 00 03 C3 EA 98 EB 99 EC 9E ED 9F +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 37 50 13 +R 00 00 00 08 +T 00 39 +R 00 00 00 08 +T 00 39 C3 EF 13 F5 00 03 EE 13 F5 00 02 E9 13 F5 +R 00 00 00 08 29 06 00 03 29 0B 00 03 +T 00 45 00 01 E8 13 F5 00 00 80 05 +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 4C +R 00 00 00 08 +T 00 4C 05 00 04 02 00 0D +R 00 00 00 08 29 03 00 03 00 06 00 08 +T 00 51 +R 00 00 00 08 +T 00 51 AE 00 04 +R 00 00 00 08 29 03 00 03 +T 00 53 +R 00 00 00 08 +T 00 53 C3 EA 95 00 00 EB 95 00 01 EC 95 00 02 ED +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0D 00 03 +T 00 5E 95 00 03 40 11 +R 00 00 00 08 29 03 00 03 +T 00 62 +R 00 00 00 08 +T 00 62 C3 EA 95 00 00 FA EB 95 00 01 FB EC 95 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 6D 00 02 FC ED 95 00 03 FD +R 00 00 00 08 29 02 00 03 29 07 00 03 +T 00 73 +R 00 00 00 08 +T 00 73 C3 E5 00 03 13 F5 00 03 E5 00 02 13 F5 +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0B 00 03 +T 00 7D 00 02 E5 00 01 13 F5 00 01 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 84 00 00 13 F5 00 00 8E 07 1E EF 70 C5 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 8E +R 00 00 00 08 +T 00 8E 8A 82 8B 83 8C F0 ED +R 00 00 00 08 +T 00 95 +R 00 00 00 08 +T 00 95 22 +R 00 00 00 08 diff --git a/device/lib/small/_mulsint.asm b/device/lib/small/_mulsint.asm new file mode 100644 index 00000000..6eb560b4 --- /dev/null +++ b/device/lib/small/_mulsint.asm @@ -0,0 +1,148 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:14 2000 + +;-------------------------------------------------------- + .module _mulsint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __mulsint_PARM_2 + .globl __mulsint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__mulsint_PARM_2: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_mulsint$0$0 ==. +; _mulsint.c 26 +; ----------------------------------------- +; function _mulsint +; ----------------------------------------- +__mulsint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _mulsint.c 0 + mov r2,dpl + mov r3,dph +; _mulsint.c 30 + mov a,r3 + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r4,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: + clr c + clr a + subb a,r2 + mov r5,a + clr a + subb a,r3 + mov r6,a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov ar5,r2 + mov ar6,r3 +00107$: + mov ar2,r5 + mov ar3,r6 +; _mulsint.c 31 + mov a,(__mulsint_PARM_2 + 1) + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,__mulsint_PARM_2 + mov r6,a + clr a + subb a,(__mulsint_PARM_2 + 1) + mov r7,a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov r6,__mulsint_PARM_2 + mov r7,(__mulsint_PARM_2 + 1) +00109$: + mov __muluint_PARM_2,r6 + mov (__muluint_PARM_2 + 1),r7 + push ar4 + push ar5 + mov dpl,r2 + mov dph,r3 + lcall __muluint + mov r2,dpl + mov r3,dph + pop ar5 + pop ar4 +; _mulsint.c 33 + mov a,r5 + xrl a,ar4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _mulsint.c 34 + clr c + clr a + subb a,r2 + mov dpl,a + clr a + subb a,r3 + mov dph,a +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _mulsint.c 36 + mov dpl,r2 + mov dph,r3 +00104$: + C$_mulsint.c$37$1$1 ==. + XG$_mulsint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_mulsint.cdb b/device/lib/small/_mulsint.cdb new file mode 100644 index 00000000..49440424 --- /dev/null +++ b/device/lib/small/_mulsint.cdb @@ -0,0 +1,2 @@ +M:_mulsint +F:G$_mulsint$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_mulsint.rel b/device/lib/small/_mulsint.rel new file mode 100644 index 00000000..0ba8202f --- /dev/null +++ b/device/lib/small/_mulsint.rel @@ -0,0 +1,128 @@ +;!FILE _mulsint.asm +XH +H 8 areas 44 global symbols +M _mulsint +S __muluint Ref0000 +S __muluint_PARM_2 Ref0000 +A _CODE size 0 flags 0 +A DSEG size 2 flags 0 +S __mulsint_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 5F flags 20 +S A$_mulsint$93 Def001F +S A$_mulsint$75 Def000B +S A$_mulsint$66 Def0004 +S A$_mulsint$94 Def0020 +S A$_mulsint$85 Def0014 +S A$_mulsint$76 Def000C +S A$_mulsint$67 Def0005 +S A$_mulsint$86 Def0016 +S A$_mulsint$77 Def000D +S A$_mulsint$68 Def0006 +S A$_mulsint$96 Def0021 +S A$_mulsint$78 Def000E +S A$_mulsint$69 Def0007 +S A$_mulsint$88 Def0018 +S A$_mulsint$79 Def000F +S A$_mulsint$98 Def0022 +S A$_mulsint$89 Def001A +S __mulsint Def0000 +S XG$_mulsint$0$0 Def005E +S G$_mulsint$0$0 Def0000 +S A$_mulsint$100 Def0024 +S A$_mulsint$110 Def002F +S A$_mulsint$101 Def0025 +S A$_mulsint$120 Def0042 +S A$_mulsint$111 Def0031 +S A$_mulsint$102 Def0026 +S A$_mulsint$121 Def0044 +S A$_mulsint$103 Def0028 +S A$_mulsint$131 Def004F +S A$_mulsint$122 Def0046 +S A$_mulsint$113 Def0033 +S A$_mulsint$104 Def0029 +S A$_mulsint$132 Def0050 +S A$_mulsint$123 Def0048 +S A$_mulsint$114 Def0035 +S A$_mulsint$105 Def002A +S A$_mulsint$142 Def005A +S A$_mulsint$133 Def0051 +S A$_mulsint$115 Def0037 +S A$_mulsint$106 Def002C +S A$_mulsint$143 Def005C +S A$_mulsint$134 Def0052 +S A$_mulsint$125 Def004A +S A$_mulsint$116 Def0039 +S A$_mulsint$135 Def0054 +S A$_mulsint$126 Def004B +S A$_mulsint$117 Def003B +S A$_mulsint$108 Def002D +S A$_mulsint$136 Def0055 +S A$_mulsint$118 Def003D +S A$_mulsint$137 Def0056 +S A$_mulsint$128 Def004D +S A$_mulsint$119 Def003F +S A$_mulsint$147 Def005E +S A$_mulsint$139 Def0058 +S C$_mulsint.c$37$1$1 Def005E +S A$_mulsint$80 Def0010 +S A$_mulsint$71 Def0008 +S A$_mulsint$81 Def0011 +S A$_mulsint$63 Def0000 +S A$_mulsint$91 Def001C +S A$_mulsint$73 Def0009 +S A$_mulsint$64 Def0002 +S A$_mulsint$92 Def001E +S A$_mulsint$83 Def0012 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 EB 33 E4 33 FC 60 09 +R 00 00 00 07 +T 00 0B +R 00 00 00 07 +T 00 0B C3 E4 9A FD E4 9B FE 80 04 +R 00 00 00 07 +T 00 14 +R 00 00 00 07 +T 00 14 8A 05 8B 06 +R 00 00 00 07 +T 00 18 +R 00 00 00 07 +T 00 18 8D 02 8E 03 E5 00 01 33 E4 33 FD 60 0B +R 00 00 00 07 29 07 00 01 +T 00 24 +R 00 00 00 07 +T 00 24 C3 E4 95 00 00 FE E4 95 00 01 FF 80 04 +R 00 00 00 07 29 05 00 01 29 0A 00 01 +T 00 2F +R 00 00 00 07 +T 00 2F AE 00 00 AF 00 01 +R 00 00 00 07 29 03 00 01 29 06 00 01 +T 00 33 +R 00 00 00 07 +T 00 33 8E 00 00 8F 00 01 C0 04 C0 05 8A 82 8B 83 +R 00 00 00 07 2B 03 00 01 2B 06 00 01 +T 00 3F 12 00 00 AA 82 AB 83 D0 05 D0 04 ED 65 04 +R 00 00 00 07 02 03 00 00 +T 00 4D 60 0B +R 00 00 00 07 +T 00 4F +R 00 00 00 07 +T 00 4F C3 E4 9A F5 82 E4 9B F5 83 80 04 +R 00 00 00 07 +T 00 5A +R 00 00 00 07 +T 00 5A 8A 82 8B 83 +R 00 00 00 07 +T 00 5E +R 00 00 00 07 +T 00 5E 22 +R 00 00 00 07 diff --git a/device/lib/small/_muluint.asm b/device/lib/small/_muluint.asm new file mode 100644 index 00000000..d2f5dfe5 --- /dev/null +++ b/device/lib/small/_muluint.asm @@ -0,0 +1,98 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:14 2000 + +;-------------------------------------------------------- + .module _muluint +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __muluint_PARM_2 + .globl __muluint +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +__muluint_PARM_2: + .ds 0x0002 +__muluint_a_1_1: + .ds 0x0002 +__muluint_t_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_muluint$0$0 ==. +; _muluint.c 32 +; ----------------------------------------- +; function _muluint +; ----------------------------------------- +__muluint: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _muluint.c 51 + mov __muluint_a_1_1,dpl + mov (__muluint_a_1_1 + 1),dph +; _muluint.c 44 +; _muluint.c 45 +; _muluint.c 48 + mov b,__muluint_PARM_2 + mov a,__muluint_a_1_1 + mul ab + mov __muluint_t_1_1,a + mov (__muluint_t_1_1 + 1),b +; _muluint.c 49 + mov b,0x0001 + __muluint_PARM_2 + mov a,__muluint_a_1_1 + mul ab + mov r2,a + mov b,__muluint_PARM_2 + mov a,0x0001 + __muluint_a_1_1 + mul ab +; Peephole 105 removed redundant mov + mov r3,a + add a,r2 + add a,0x0001 + __muluint_t_1_1 + mov 0x0001 + __muluint_t_1_1,a +; _muluint.c 51 + mov dpl,__muluint_t_1_1 + mov dph,(__muluint_t_1_1 + 1) +00101$: + C$_muluint.c$52$1$1 ==. + XG$_muluint$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_muluint.cdb b/device/lib/small/_muluint.cdb new file mode 100644 index 00000000..531f0176 --- /dev/null +++ b/device/lib/small/_muluint.cdb @@ -0,0 +1,2 @@ +M:_muluint +F:G$_muluint$0$0({2}DF,SI:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_muluint.rel b/device/lib/small/_muluint.rel new file mode 100644 index 00000000..7b3fbd65 --- /dev/null +++ b/device/lib/small/_muluint.rel @@ -0,0 +1,67 @@ +;!FILE _muluint.asm +XH +H 9 areas 1A global symbols +M _muluint +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 6 flags 4 +S __muluint_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 2B flags 20 +S A$_muluint$82 Def0017 +S A$_muluint$73 Def0006 +S A$_muluint$92 Def0024 +S A$_muluint$83 Def0018 +S A$_muluint$74 Def0009 +S A$_muluint$93 Def0027 +S A$_muluint$84 Def001B +S A$_muluint$75 Def000B +S A$_muluint$85 Def001D +S A$_muluint$76 Def000C +S A$_muluint$77 Def000E +S A$_muluint$68 Def0000 +S A$_muluint$87 Def001E +S A$_muluint$69 Def0003 +S A$_muluint$97 Def002A +S A$_muluint$88 Def001F +S A$_muluint$79 Def0011 +S A$_muluint$89 Def0020 +S __muluint Def0000 +S XG$_muluint$0$0 Def002A +S G$_muluint$0$0 Def0000 +S C$_muluint.c$52$1$1 Def002A +S A$_muluint$80 Def0014 +S A$_muluint$90 Def0022 +S A$_muluint$81 Def0016 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 02 +R 00 00 00 03 +T 00 02 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 85 82 00 02 85 83 00 03 85 00 00 F0 E5 +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0B 00 03 +T 00 0A 00 02 A4 F5 00 04 85 F0 00 05 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 12 00 01 F0 E5 00 02 A4 FA 85 00 00 F0 E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0B 00 03 +T 00 1C 00 03 A4 FB 2A 25 00 05 F5 00 05 85 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 25 00 04 82 85 00 05 83 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 2A +R 00 00 00 08 +T 00 2A 22 +R 00 00 00 08 diff --git a/device/lib/small/_mululong.asm b/device/lib/small/_mululong.asm new file mode 100644 index 00000000..4a39b410 --- /dev/null +++ b/device/lib/small/_mululong.asm @@ -0,0 +1,194 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:15 2000 + +;-------------------------------------------------------- + .module _mululong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __mululong_PARM_2 + .globl __mululong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +__mululong_PARM_2: + .ds 0x0004 +__mululong_a_1_1: + .ds 0x0004 +__mululong_t_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_mululong$0$0 ==. +; _mululong.c 59 +; ----------------------------------------- +; function _mululong +; ----------------------------------------- +__mululong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _mululong.c 86 + mov __mululong_a_1_1,dpl + mov (__mululong_a_1_1 + 1),dph + mov (__mululong_a_1_1 + 2),b + mov (__mululong_a_1_1 + 3),a +; _mululong.c 63 + mov b,0x0002 + __mululong_PARM_2 + mov a,__mululong_a_1_1 + mul ab + mov 0x0002 + __mululong_t_1_1,a + mov (0x0002 + __mululong_t_1_1 + 1),b +; _mululong.c 64 + mov b,__mululong_PARM_2 + mov a,__mululong_a_1_1 + mul ab + mov __mululong_t_1_1,a + mov (__mululong_t_1_1 + 1),b +; _mululong.c 65 +; _mululong.c 66 + mov b,__mululong_PARM_2 + mov a,0x0003 + __mululong_a_1_1 + mul ab +; Peephole 105 removed redundant mov + mov r2,a + add a,0x0003 + __mululong_t_1_1 + mov 0x0003 + __mululong_t_1_1,a +; _mululong.c 67 +; _mululong.c 68 + mov b,0x0001 + __mululong_PARM_2 + mov a,0x0002 + __mululong_a_1_1 + mul ab +; Peephole 105 removed redundant mov + mov r2,a + add a,0x0003 + __mululong_t_1_1 + mov 0x0003 + __mululong_t_1_1,a +; _mululong.c 69 + mov b,__mululong_PARM_2 + mov a,0x0002 + __mululong_a_1_1 + mul ab + mov r2,a + mov r3,b + mov a,r2 + add a,0x0002 + __mululong_t_1_1 + mov r2,a + mov a,r3 + addc a,(0x0002 + __mululong_t_1_1 + 1) + mov r3,a + mov 0x0002 + __mululong_t_1_1,r2 + mov (0x0002 + __mululong_t_1_1 + 1),r3 +; _mululong.c 71 + mov b,0x0001 + __mululong_PARM_2 + mov a,0x0001 + __mululong_a_1_1 + mul ab + mov r2,a + mov r3,b + mov a,r2 + add a,0x0002 + __mululong_t_1_1 + mov r2,a + mov a,r3 + addc a,(0x0002 + __mululong_t_1_1 + 1) + mov r3,a + mov 0x0002 + __mululong_t_1_1,r2 + mov (0x0002 + __mululong_t_1_1 + 1),r3 +; _mululong.c 73 +; _mululong.c 74 + mov b,0x0002 + __mululong_PARM_2 + mov a,0x0001 + __mululong_a_1_1 + mul ab + mov 0x0003 + __mululong_a_1_1,a +; _mululong.c 75 +; _mululong.c 76 + mov b,__mululong_PARM_2 + mov a,0x0001 + __mululong_a_1_1 + mul ab + mov 0x0001 + __mululong_a_1_1,a + mov (0x0001 + __mululong_a_1_1 + 1),b +; _mululong.c 78 +; _mululong.c 79 + mov b,0x0003 + __mululong_PARM_2 + mov a,__mululong_a_1_1 + mul ab + mov 0x0003 + __mululong_PARM_2,a +; _mululong.c 81 + mov b,0x0001 + __mululong_PARM_2 + mov a,__mululong_a_1_1 + mul ab + mov 0x0001 + __mululong_PARM_2,a + mov (0x0001 + __mululong_PARM_2 + 1),b +; _mululong.c 82 +; _mululong.c 83 +; _mululong.c 84 +; Peephole 3.c changed mov to clr + clr a + mov __mululong_PARM_2,a +; Peephole 105 removed redundant mov + mov __mululong_a_1_1,a + add a,__mululong_t_1_1 + mov r2,a + mov a,(__mululong_a_1_1 + 1) + addc a,(__mululong_t_1_1 + 1) + mov r3,a + mov a,(__mululong_a_1_1 + 2) + addc a,(__mululong_t_1_1 + 2) + mov r4,a + mov a,(__mululong_a_1_1 + 3) + addc a,(__mululong_t_1_1 + 3) + mov r5,a + mov __mululong_t_1_1,r2 + mov (__mululong_t_1_1 + 1),r3 + mov (__mululong_t_1_1 + 2),r4 + mov (__mululong_t_1_1 + 3),r5 +; _mululong.c 86 + mov a,__mululong_PARM_2 + add a,r2 + mov dpl,a + mov a,(__mululong_PARM_2 + 1) + addc a,r3 + mov dph,a + mov a,(__mululong_PARM_2 + 2) + addc a,r4 + mov b,a + mov a,(__mululong_PARM_2 + 3) + addc a,r5 +00101$: + C$_mululong.c$87$1$1 ==. + XG$_mululong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_mululong.cdb b/device/lib/small/_mululong.cdb new file mode 100644 index 00000000..e600681e --- /dev/null +++ b/device/lib/small/_mululong.cdb @@ -0,0 +1,2 @@ +M:_mululong +F:G$_mululong$0$0({2}DF,SL:U),Z,0,0,0,0,0 diff --git a/device/lib/small/_mululong.rel b/device/lib/small/_mululong.rel new file mode 100644 index 00000000..483ba37d --- /dev/null +++ b/device/lib/small/_mululong.rel @@ -0,0 +1,180 @@ +;!FILE _mululong.asm +XH +H 9 areas 69 global symbols +M _mululong +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +S __mululong_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size B9 flags 20 +S G$_mululong$0$0 Def0000 +S A$_mululong$100 Def0033 +S A$_mululong$110 Def0043 +S A$_mululong$101 Def0035 +S A$_mululong$120 Def0052 +S A$_mululong$111 Def0044 +S A$_mululong$121 Def0053 +S A$_mululong$112 Def0045 +S A$_mululong$103 Def0037 +S A$_mululong$140 Def006E +S A$_mululong$122 Def0055 +S A$_mululong$113 Def0047 +S A$_mululong$104 Def003A +S A$_mululong$150 Def007C +S A$_mululong$141 Def006F +S A$_mululong$132 Def0061 +S A$_mululong$123 Def0056 +S A$_mululong$114 Def0048 +S A$_mululong$105 Def003C +S A$_mululong$160 Def0088 +S A$_mululong$151 Def007F +S A$_mululong$142 Def0071 +S A$_mululong$133 Def0064 +S A$_mululong$124 Def0058 +S A$_mululong$115 Def004A +S A$_mululong$106 Def003D +S A$_mululong$170 Def0098 +S A$_mululong$152 Def0081 +S A$_mululong$134 Def0066 +S A$_mululong$125 Def0059 +S A$_mululong$107 Def003E +S A$_mululong$180 Def00A8 +S A$_mululong$171 Def0099 +S A$_mululong$162 Def008A +S A$_mululong$153 Def0082 +S A$_mululong$135 Def0067 +S A$_mululong$126 Def005A +S A$_mululong$117 Def004C +S A$_mululong$108 Def0040 +S A$_mululong$181 Def00A9 +S A$_mululong$172 Def009B +S A$_mululong$163 Def008C +S A$_mululong$154 Def0084 +S A$_mululong$145 Def0074 +S A$_mululong$127 Def005C +S A$_mululong$118 Def004F +S A$_mululong$109 Def0041 +S A$_mululong$182 Def00AB +S A$_mululong$173 Def009D +S A$_mululong$164 Def008E +S A$_mululong$146 Def0077 +S A$_mululong$128 Def005D +S A$_mululong$119 Def0051 +S A$_mululong$183 Def00AD +S A$_mululong$174 Def009E +S A$_mululong$165 Def008F +S A$_mululong$147 Def0079 +S A$_mululong$138 Def0069 +S A$_mululong$129 Def005F +S A$_mululong$193 Def00B8 +S A$_mululong$184 Def00AE +S A$_mululong$175 Def00A0 +S A$_mululong$166 Def0091 +S A$_mululong$148 Def007A +S A$_mululong$139 Def006C +S A$_mululong$185 Def00B0 +S A$_mululong$176 Def00A2 +S A$_mululong$167 Def0093 +S A$_mululong$186 Def00B2 +S A$_mululong$177 Def00A4 +S A$_mululong$168 Def0094 +S A$_mululong$159 Def0087 +S A$_mululong$187 Def00B3 +S A$_mululong$169 Def0096 +S A$_mululong$188 Def00B5 +S A$_mululong$179 Def00A6 +S A$_mululong$189 Def00B7 +S A$_mululong$70 Def0006 +S A$_mululong$80 Def0019 +S A$_mululong$71 Def0009 +S A$_mululong$90 Def0027 +S A$_mululong$81 Def001B +S A$_mululong$91 Def0028 +S A$_mululong$82 Def001C +S A$_mululong$73 Def000B +S A$_mululong$92 Def002A +S A$_mululong$83 Def001E +S A$_mululong$74 Def000E +S A$_mululong$75 Def0010 +S C$_mululong.c$87$1$1 Def00B8 +S A$_mululong$76 Def0011 +S A$_mululong$95 Def002C +S A$_mululong$86 Def0021 +S A$_mululong$77 Def0013 +S A$_mululong$68 Def0000 +S A$_mululong$96 Def002F +S A$_mululong$87 Def0024 +S A$_mululong$69 Def0003 +S A$_mululong$97 Def0031 +S A$_mululong$88 Def0026 +S A$_mululong$79 Def0016 +S A$_mululong$99 Def0032 +S __mululong Def0000 +S XG$_mululong$0$0 Def00B8 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 85 82 00 04 85 83 00 05 85 F0 00 06 F5 +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0C 00 03 +T 00 0A 00 07 85 00 02 F0 E5 00 04 A4 F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 12 00 0A 85 F0 00 0B 85 00 00 F0 E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 1A 00 04 A4 F5 00 08 85 F0 00 09 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 22 00 00 F0 E5 00 07 A4 FA 25 00 0B F5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0B 00 03 +T 00 2B 00 0B 85 00 01 F0 E5 00 06 A4 FA 25 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 34 00 0B F5 00 0B 85 00 00 F0 E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 3B 00 06 A4 FA AB F0 EA 25 00 0A FA EB 35 +R 00 00 00 08 29 02 00 03 29 0A 00 03 +T 00 46 00 0B FB 8A 00 0A 8B 00 0B 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 4D 00 01 F0 E5 00 05 A4 FA AB F0 EA 25 00 0A +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0E 00 03 +T 00 58 FA EB 35 00 0B FB 8A 00 0A 8B 00 0B 85 +R 00 00 00 08 29 05 00 03 29 09 00 03 29 0C 00 03 +T 00 62 00 02 F0 E5 00 05 A4 F5 00 07 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 6A 00 00 F0 E5 00 05 A4 F5 00 05 85 F0 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 73 00 06 85 00 03 F0 E5 00 04 A4 F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 7B 00 03 85 00 01 F0 E5 00 04 A4 F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 83 00 01 85 F0 00 02 E4 F5 00 00 F5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 8B 00 04 25 00 08 FA E5 00 05 35 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 92 00 09 FB E5 00 06 35 00 0A FC E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 9A 00 07 35 00 0B FD 8A 00 08 8B +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 A1 00 09 8C 00 0A 8D 00 0B E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 A7 00 00 2A F5 82 E5 00 01 3B F5 83 E5 00 02 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0E 00 03 +T 00 B2 3C F5 F0 E5 00 03 3D +R 00 00 00 08 29 06 00 03 +T 00 B8 +R 00 00 00 08 +T 00 B8 22 +R 00 00 00 08 diff --git a/device/lib/small/_muslong.asm b/device/lib/small/_muslong.asm new file mode 100644 index 00000000..c6e6a052 --- /dev/null +++ b/device/lib/small/_muslong.asm @@ -0,0 +1,183 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:15 2000 + +;-------------------------------------------------------- + .module _muslong +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __mulslong_PARM_2 + .globl __mulslong +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__mulslong_PARM_2: + .ds 0x0004 +__mulslong_sloc0_1_0: + .ds 0x0004 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_mulslong$0$0 ==. +; _muslong.c 24 +; ----------------------------------------- +; function _mulslong +; ----------------------------------------- +__mulslong: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _muslong.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _muslong.c 28 +; Peephole 105 removed redundant mov + mov r5,a + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: + clr c + clr a + subb a,r2 + mov __mulslong_sloc0_1_0,a + clr a + subb a,r3 + mov (__mulslong_sloc0_1_0 + 1),a + clr a + subb a,r4 + mov (__mulslong_sloc0_1_0 + 2),a + clr a + subb a,r5 + mov (__mulslong_sloc0_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: + mov __mulslong_sloc0_1_0,r2 + mov (__mulslong_sloc0_1_0 + 1),r3 + mov (__mulslong_sloc0_1_0 + 2),r4 + mov (__mulslong_sloc0_1_0 + 3),r5 +00107$: + mov r2,__mulslong_sloc0_1_0 + mov r3,(__mulslong_sloc0_1_0 + 1) + mov r4,(__mulslong_sloc0_1_0 + 2) + mov r5,(__mulslong_sloc0_1_0 + 3) +; _muslong.c 29 + mov a,(__mulslong_PARM_2 + 3) + rlc a + clr a + rlc a +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00114$: + clr c + clr a + subb a,__mulslong_PARM_2 + mov __mulslong_sloc0_1_0,a + clr a + subb a,(__mulslong_PARM_2 + 1) + mov (__mulslong_sloc0_1_0 + 1),a + clr a + subb a,(__mulslong_PARM_2 + 2) + mov (__mulslong_sloc0_1_0 + 2),a + clr a + subb a,(__mulslong_PARM_2 + 3) + mov (__mulslong_sloc0_1_0 + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov __mulslong_sloc0_1_0,__mulslong_PARM_2 + mov (__mulslong_sloc0_1_0 + 1),(__mulslong_PARM_2 + 1) + mov (__mulslong_sloc0_1_0 + 2),(__mulslong_PARM_2 + 2) + mov (__mulslong_sloc0_1_0 + 3),(__mulslong_PARM_2 + 3) +00109$: + mov __mululong_PARM_2,__mulslong_sloc0_1_0 + mov (__mululong_PARM_2 + 1),(__mulslong_sloc0_1_0 + 1) + mov (__mululong_PARM_2 + 2),(__mulslong_sloc0_1_0 + 2) + mov (__mululong_PARM_2 + 3),(__mulslong_sloc0_1_0 + 3) + push ar6 + push ar7 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 + lcall __mululong + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a + pop ar7 + pop ar6 +; _muslong.c 31 + mov a,r7 + xrl a,ar6 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00115$: +; _muslong.c 32 + clr c + clr a + subb a,r2 + mov dpl,a + clr a + subb a,r3 + mov dph,a + clr a + subb a,r4 + mov b,a + clr a + subb a,r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; _muslong.c 34 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 +00104$: + C$_muslong.c$35$1$1 ==. + XG$_mulslong$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_muslong.cdb b/device/lib/small/_muslong.cdb new file mode 100644 index 00000000..7932ad22 --- /dev/null +++ b/device/lib/small/_muslong.cdb @@ -0,0 +1,2 @@ +M:_muslong +F:G$_mulslong$0$0({2}DF,SL:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_muslong.rel b/device/lib/small/_muslong.rel new file mode 100644 index 00000000..853f93ab --- /dev/null +++ b/device/lib/small/_muslong.rel @@ -0,0 +1,184 @@ +;!FILE _muslong.asm +XH +H 8 areas 64 global symbols +M _muslong +S __mululong_PARM_2 Ref0000 +S __mululong Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +S __mulslong_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 9E flags 20 +S G$_mulslong$0$0 Def0000 +S A$_muslong$100 Def0028 +S A$_muslong$110 Def0035 +S A$_muslong$101 Def002A +S A$_muslong$120 Def0041 +S A$_muslong$102 Def002C +S A$_muslong$130 Def004F +S A$_muslong$121 Def0043 +S A$_muslong$112 Def0036 +S A$_muslong$103 Def002E +S A$_muslong$140 Def0069 +S A$_muslong$131 Def0052 +S A$_muslong$122 Def0044 +S A$_muslong$150 Def007C +S A$_muslong$141 Def006B +S A$_muslong$132 Def0055 +S A$_muslong$123 Def0046 +S A$_muslong$114 Def0038 +S A$_muslong$105 Def0030 +S A$_muslong$160 Def0086 +S A$_muslong$151 Def007E +S A$_muslong$142 Def006D +S A$_muslong$133 Def0058 +S A$_muslong$124 Def0048 +S A$_muslong$115 Def0039 +S A$_muslong$106 Def0032 +S A$_muslong$170 Def0093 +S A$_muslong$161 Def0087 +S A$_muslong$143 Def006F +S A$_muslong$125 Def0049 +S A$_muslong$116 Def003A +S A$_muslong$107 Def0033 +S A$_muslong$162 Def0088 +S A$_muslong$153 Def0080 +S A$_muslong$144 Def0071 +S A$_muslong$135 Def005B +S A$_muslong$126 Def004B +S A$_muslong$117 Def003C +S A$_muslong$108 Def0034 +S A$_muslong$172 Def0094 +S A$_muslong$163 Def008A +S A$_muslong$154 Def0081 +S A$_muslong$145 Def0072 +S A$_muslong$136 Def005E +S A$_muslong$118 Def003E +S A$_muslong$182 Def009D +S A$_muslong$164 Def008B +S A$_muslong$146 Def0075 +S A$_muslong$137 Def0061 +S A$_muslong$128 Def004D +S A$_muslong$119 Def003F +S A$_muslong$165 Def008C +S A$_muslong$156 Def0083 +S A$_muslong$147 Def0077 +S A$_muslong$138 Def0064 +S A$_muslong$175 Def0096 +S A$_muslong$166 Def008E +S A$_muslong$148 Def0079 +S A$_muslong$139 Def0067 +S A$_muslong$176 Def0098 +S A$_muslong$167 Def008F +S A$_muslong$149 Def007B +S A$_muslong$177 Def009A +S A$_muslong$168 Def0090 +S A$_muslong$159 Def0085 +S A$_muslong$178 Def009C +S A$_muslong$169 Def0092 +S __mulslong Def0000 +S C$_muslong.c$35$1$1 Def009D +S A$_muslong$70 Def0006 +S A$_muslong$80 Def000E +S A$_muslong$71 Def0007 +S A$_muslong$90 Def001B +S A$_muslong$81 Def000F +S A$_muslong$72 Def0008 +S A$_muslong$91 Def001C +S A$_muslong$82 Def0010 +S A$_muslong$73 Def0009 +S A$_muslong$83 Def0012 +S A$_muslong$65 Def0000 +S A$_muslong$93 Def001E +S A$_muslong$84 Def0013 +S A$_muslong$75 Def000A +S A$_muslong$66 Def0002 +S A$_muslong$85 Def0014 +S A$_muslong$67 Def0004 +S A$_muslong$95 Def0020 +S A$_muslong$86 Def0016 +S A$_muslong$77 Def000B +S XG$_mulslong$0$0 Def009D +S A$_muslong$96 Def0022 +S A$_muslong$87 Def0017 +S A$_muslong$97 Def0024 +S A$_muslong$88 Def0018 +S A$_muslong$79 Def000D +S A$_muslong$98 Def0026 +S A$_muslong$89 Def001A +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 04 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 FD 33 E4 33 FE 60 13 +R 00 00 00 07 +T 00 0D +R 00 00 00 07 +T 00 0D C3 E4 9A F5 00 04 E4 9B F5 00 05 E4 9C F5 +R 00 00 00 07 29 06 00 01 29 0B 00 01 +T 00 19 00 06 E4 9D F5 00 07 80 08 +R 00 00 00 07 29 02 00 01 29 07 00 01 +T 00 20 +R 00 00 00 07 +T 00 20 8A 00 04 8B 00 05 8C 00 06 8D +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 27 00 07 +R 00 00 00 07 29 02 00 01 +T 00 28 +R 00 00 00 07 +T 00 28 AA 00 04 AB 00 05 AC 00 06 AD +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 2F 00 07 E5 00 03 33 E4 33 FF 60 17 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 38 +R 00 00 00 07 +T 00 38 C3 E4 95 00 00 F5 00 04 E4 95 00 01 F5 +R 00 00 00 07 29 05 00 01 29 08 00 01 29 0C 00 01 +T 00 42 00 05 E4 95 00 02 F5 00 06 E4 95 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 4A 00 03 F5 00 07 80 0C +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 4F +R 00 00 00 07 +T 00 4F 85 00 00 00 04 85 00 01 +R 00 00 00 07 29 03 00 01 29 05 00 01 29 08 00 01 +T 00 54 00 05 85 00 02 00 06 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 00 59 00 03 00 07 +R 00 00 00 07 29 02 00 01 29 04 00 01 +T 00 5B +R 00 00 00 07 +T 00 5B 85 00 04 00 00 85 00 05 +R 00 00 00 07 29 03 00 01 2B 05 00 00 29 08 00 01 +T 00 60 00 01 85 00 06 00 02 85 +R 00 00 00 07 2B 02 00 00 29 05 00 01 2B 07 00 00 +T 00 65 00 07 00 03 C0 06 C0 07 8A 82 8B 83 8C F0 +R 00 00 00 07 29 02 00 01 2B 04 00 00 +T 00 71 ED 12 00 00 AA 82 AB 83 AC F0 FD D0 07 D0 +R 00 00 00 07 02 04 00 01 +T 00 7F 06 EF 65 06 60 11 +R 00 00 00 07 +T 00 85 +R 00 00 00 07 +T 00 85 C3 E4 9A F5 82 E4 9B F5 83 E4 9C F5 F0 E4 +R 00 00 00 07 +T 00 93 9D 80 07 +R 00 00 00 07 +T 00 96 +R 00 00 00 07 +T 00 96 8A 82 8B 83 8C F0 ED +R 00 00 00 07 +T 00 9D +R 00 00 00 07 +T 00 9D 22 +R 00 00 00 07 diff --git a/device/lib/small/_ser.asm b/device/lib/small/_ser.asm new file mode 100644 index 00000000..50c4d219 --- /dev/null +++ b/device/lib/small/_ser.asm @@ -0,0 +1,584 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:15 2000 + +;-------------------------------------------------------- + .module _ser +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _ser_charAvail + .globl _ser_printString + .globl _ser_getc + .globl _ser_putc + .globl _ser_interrupt_handler + .globl _ser_init + .globl _ser_rxBuffer + .globl _ser_txBuffer + .globl _ser_rxIndexOut + .globl _ser_rxIndexIn + .globl _ser_txIndexOut + .globl _ser_txIndexIn +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) + .area _DUMMY + .area OSEG (OVR,DATA) + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +F_ser$ser_txBusy$0$0==. +_ser_txBusy: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +G$ser_txIndexIn$0$0==. +_ser_txIndexIn: + .ds 0x0001 +G$ser_txIndexOut$0$0==. +_ser_txIndexOut: + .ds 0x0001 +G$ser_rxIndexIn$0$0==. +_ser_rxIndexIn: + .ds 0x0001 +G$ser_rxIndexOut$0$0==. +_ser_rxIndexOut: + .ds 0x0001 +G$ser_txBuffer$0$0==. +_ser_txBuffer: + .ds 0x0100 +G$ser_rxBuffer$0$0==. +_ser_rxBuffer: + .ds 0x0100 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$ser_init$0$0 ==. +; _ser.c 49 +; ----------------------------------------- +; function ser_init +; ----------------------------------------- +_ser_init: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ser.c 51 + clr _ES +; _ser.c 53 + clr _ser_txBusy +; _ser.c 55 + mov dptr,#_ser_txIndexIn +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 56 + mov dptr,#_ser_txIndexOut +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 57 + mov dptr,#_ser_rxIndexIn +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 58 + mov dptr,#_ser_rxIndexOut +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; _ser.c 60 + mov _T2CON,#0x30 +; _ser.c 63 + mov _RCAP2H,#0xff +; _ser.c 64 + mov _RCAP2L,#0xdd +; _ser.c 67 + mov _T2CON,#0x34 +; _ser.c 69 + mov _SCON,#0x50 +; _ser.c 71 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00102$ +00109$: +; _ser.c 72 + clr _TI +00102$: +; _ser.c 74 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00104$ +00110$: +; _ser.c 75 + clr _RI +00104$: +; _ser.c 78 + setb _ES +00105$: + C$_ser.c$79$1$1 ==. + XG$ser_init$0$0 ==. + ret + G$ser_interrupt_handler$0$0 ==. +; _ser.c 82 +; ----------------------------------------- +; function ser_interrupt_handler +; ----------------------------------------- +_ser_interrupt_handler: + ar2 = 0x0a + ar3 = 0x0b + ar4 = 0x0c + ar5 = 0x0d + ar6 = 0x0e + ar7 = 0x0f + ar0 = 0x08 + ar1 = 0x09 + push acc + push b + push dpl + push dph + push psw + mov psw,#0x08 +; _ser.c 84 + clr _ES +; _ser.c 86 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00105$ +00113$: +; _ser.c 87 + clr _TI +; _ser.c 88 + mov dptr,#_ser_txIndexOut + movx a,@dptr + mov r2,a + mov dptr,#_ser_txIndexIn + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar2,00102$ +; Peephole 201 removed redundant sjmp +00114$: +00115$: +; _ser.c 89 + clr _ser_txBusy +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00102$: +; _ser.c 92 + mov dptr,#_ser_txIndexOut + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_ser_txBuffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_txBuffer >> 8) + mov dph,a + movx a,@dptr + mov _SBUF,a +00105$: +; _ser.c 96 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00107$ +00116$: +; _ser.c 97 + clr _RI +; _ser.c 98 + mov dptr,#_ser_rxIndexIn + movx a,@dptr + mov r2,a + mov dptr,#_ser_rxIndexIn + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_ser_rxBuffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_rxBuffer >> 8) + mov dph,a + mov a,_SBUF + movx @dptr,a +00107$: +; _ser.c 101 + setb _ES +00108$: + pop psw + pop dph + pop dpl + pop b + pop acc + C$_ser.c$102$1$1 ==. + XG$ser_interrupt_handler$0$0 ==. + reti + G$ser_putc$0$0 ==. +; _ser.c 105 +; ----------------------------------------- +; function ser_putc +; ----------------------------------------- +_ser_putc: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ser.c 117 + mov r2,dpl +; _ser.c 107 + clr _ES +; _ser.c 109 +; Peephole 111 removed ljmp by inverse jump logic + jnb _ser_txBusy,00102$ +00107$: +; _ser.c 110 + mov dptr,#_ser_txIndexIn + movx a,@dptr + mov r3,a + mov dptr,#_ser_txIndexIn + mov a,#0x01 + add a,r3 + movx @dptr,a + mov a,r3 + add a,#_ser_txBuffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_txBuffer >> 8) + mov dph,a + mov a,r2 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: +; _ser.c 113 + setb _ser_txBusy +; _ser.c 114 + mov _SBUF,r2 +00103$: +; _ser.c 117 + setb _ES +00104$: + C$_ser.c$118$1$1 ==. + XG$ser_putc$0$0 ==. + ret + G$ser_getc$0$0 ==. +; _ser.c 121 +; ----------------------------------------- +; function ser_getc +; ----------------------------------------- +_ser_getc: +; _ser.c 126 + mov dptr,#_ser_rxIndexOut + movx a,@dptr + mov r2,a + mov dptr,#_ser_rxIndexIn + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a + cjne a,ar2,00107$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00107$: +; _ser.c 127 + mov dptr,#_ser_rxIndexOut + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_ser_rxBuffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_ser_rxBuffer >> 8) + mov dph,a + movx a,@dptr + mov r2,a +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: +; _ser.c 130 + mov r2,#0x00 +00103$: +; _ser.c 134 + mov dpl,r2 +00104$: + C$_ser.c$135$1$1 ==. + XG$ser_getc$0$0 ==. + ret + G$ser_printString$0$0 ==. +; _ser.c 138 +; ----------------------------------------- +; function ser_printString +; ----------------------------------------- +_ser_printString: +; _ser.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _ser.c 140 +00101$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00108$: +; _ser.c 141 + mov dpl,r2 + mov dph,r3 + mov b,r4 + inc r2 + cjne r2,#0x00,00109$ + inc r3 +00109$: + lcall __gptrget + mov r5,a + push ar2 + push ar3 + push ar4 + mov dpl,r5 + lcall _ser_putc + pop ar4 + pop ar3 + pop ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00104$: + C$_ser.c$143$1$1 ==. + XG$ser_printString$0$0 ==. + ret + G$ser_charAvail$0$0 ==. +; _ser.c 146 +; ----------------------------------------- +; function ser_charAvail +; ----------------------------------------- +_ser_charAvail: +; _ser.c 148 + mov r2,#0x00 +; _ser.c 150 + mov dptr,#_ser_rxIndexOut + movx a,@dptr + mov r3,a + mov dptr,#_ser_rxIndexIn + movx a,@dptr +; Peephole 105 removed redundant mov + mov r4,a + cjne a,ar3,00106$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00106$: +; _ser.c 151 + mov r2,#0x01 +00102$: +; _ser.c 154 + mov dpl,r2 +00103$: + C$_ser.c$155$1$1 ==. + XG$ser_charAvail$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_ser.cdb b/device/lib/small/_ser.cdb new file mode 100644 index 00000000..51a66fbe --- /dev/null +++ b/device/lib/small/_ser.cdb @@ -0,0 +1,97 @@ +M:_ser +F:G$ser_init$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_interrupt_handler$0$0({2}DF,SV:S),Z,0,0,1,4,1 +F:G$ser_putc$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_getc$0$0({2}DF,SC:U),Z,0,0,0,0,0 +F:G$ser_printString$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_charAvail$0$0({2}DF,SS:S),Z,0,0,0,0,0 +S:F_ser$ser_txBusy$0$0({1}SB0$1:S),H,0,0 +S:G$ser_txIndexIn$0$0({1}SC:U),F,0,0 +S:G$ser_txIndexOut$0$0({1}SC:U),F,0,0 +S:G$ser_rxIndexIn$0$0({1}SC:U),F,0,0 +S:G$ser_rxIndexOut$0$0({1}SC:U),F,0,0 +S:G$ser_txBuffer$0$0({256}DA256,SC:U),F,0,0 +S:G$ser_rxBuffer$0$0({256}DA256,SC:U),F,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/small/_ser.rel b/device/lib/small/_ser.rel new file mode 100644 index 00000000..af1b2819 --- /dev/null +++ b/device/lib/small/_ser.rel @@ -0,0 +1,487 @@ +;!FILE _ser.asm +XH +H 9 areas 11E global symbols +M _ser +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 1 flags 80 +S F_ser$ser_txBusy$0$0 Def0000 +A XSEG size 204 flags 40 +S G$ser_rxBuffer$0$0 Def0104 +S G$ser_txBuffer$0$0 Def0004 +S _ser_rxIndexIn Def0002 +S _ser_rxIndexOut Def0003 +S _ser_txIndexIn Def0000 +S _ser_txIndexOut Def0001 +S _ser_rxBuffer Def0104 +S _ser_txBuffer Def0004 +S G$ser_rxIndexIn$0$0 Def0002 +S G$ser_rxIndexOut$0$0 Def0003 +S G$ser_txIndexIn$0$0 Def0000 +S G$ser_txIndexOut$0$0 Def0001 +A GSINIT size 0 flags 20 +A CSEG size 134 flags 20 +S _ser_putc Def0098 +S G$ser_interrupt_handler$0$0 Def0034 +S G$ser_charAvail$0$0 Def011E +S XG$ser_init$0$0 Def0033 +S _ser_printString Def00E9 +S XG$ser_putc$0$0 Def00BF +S G$ser_init$0$0 Def0000 +S XG$ser_printString$0$0 Def011D +S G$ser_putc$0$0 Def0098 +S G$ser_printString$0$0 Def00E9 +S C$_ser.c$102$1$1 Def0097 +S A$_ser$400 Def008A +S A$_ser$301 Def002A +S A$_ser$311 Def0031 +S C$_ser.c$143$1$1 Def011D +S A$_ser$330 Def0034 +S C$_ser.c$135$1$1 Def00E8 +S A$_ser$502 Def00E4 +S A$_ser$430 Def009A +S A$_ser$412 Def0097 +S A$_ser$403 Def008B +S A$_ser$340 Def0043 +S A$_ser$331 Def0036 +S C$_ser.c$118$1$1 Def00BF +S A$_ser$440 Def00A7 +S A$_ser$332 Def0038 +S A$_ser$305 Def002C +S C$_ser.c$155$1$1 Def0133 +S A$_ser$540 Def0109 +S A$_ser$522 Def00EF +S A$_ser$450 Def00B5 +S A$_ser$441 Def00A9 +S A$_ser$405 Def008D +S A$_ser$351 Def0051 +S A$_ser$333 Def003A +S A$_ser$315 Def0033 +S A$_ser$270 Def0008 +S _ser_getc Def00C0 +S A$_ser$550 Def011B +S A$_ser$541 Def010A +S A$_ser$532 Def00FB +S A$_ser$523 Def00F1 +S A$_ser$505 Def00E6 +S A$_ser$451 Def00B6 +S A$_ser$442 Def00AA +S A$_ser$433 Def009C +S A$_ser$406 Def008F +S A$_ser$370 Def0063 +S A$_ser$361 Def0057 +S A$_ser$343 Def0046 +S A$_ser$334 Def003C +S A$_ser$280 Def0012 +S A$_ser$542 Def010C +S A$_ser$533 Def00FD +S A$_ser$524 Def00F3 +S A$_ser$461 Def00BD +S A$_ser$443 Def00AB +S A$_ser$407 Def0091 +S A$_ser$380 Def006D +S A$_ser$335 Def003E +S A$_ser$308 Def002F +S A$_ser$272 Def0009 +S A$_ser$263 Def0000 +S A$_ser$570 Def0129 +S A$_ser$543 Def010E +S A$_ser$534 Def00FF +S A$_ser$525 Def00F5 +S A$_ser$480 Def00CA +S A$_ser$453 Def00B7 +S A$_ser$444 Def00AC +S A$_ser$408 Def0093 +S A$_ser$390 Def007C +S A$_ser$372 Def0065 +S A$_ser$354 Def0052 +S A$_ser$345 Def0048 +S A$_ser$291 Def001E +S A$_ser$282 Def0013 +S A$_ser$571 Def012A +S A$_ser$562 Def011E +S A$_ser$544 Def0110 +S A$_ser$535 Def0101 +S A$_ser$517 Def00E9 +S A$_ser$490 Def00D7 +S A$_ser$445 Def00AE +S A$_ser$436 Def009F +S A$_ser$409 Def0095 +S A$_ser$391 Def007D +S A$_ser$373 Def0066 +S A$_ser$364 Def0059 +S A$_ser$346 Def004B +S A$_ser$337 Def0041 +S A$_ser$274 Def000C +S A$_ser$265 Def0002 +S A$_ser$554 Def011D +S A$_ser$545 Def0112 +S A$_ser$536 Def0102 +S A$_ser$527 Def00F8 +S A$_ser$518 Def00EB +S A$_ser$509 Def00E8 +S A$_ser$491 Def00D9 +S A$_ser$482 Def00CD +S A$_ser$473 Def00C0 +S A$_ser$437 Def00A2 +S A$_ser$428 Def0098 +S A$_ser$392 Def007E +S A$_ser$383 Def0070 +S A$_ser$374 Def0068 +S A$_ser$365 Def005C +S A$_ser$347 Def004C +S A$_ser$293 Def0021 +S A$_ser$284 Def0016 +S A$_ser$275 Def000D +S A$_ser$573 Def012D +S A$_ser$564 Def0120 +S A$_ser$546 Def0115 +S A$_ser$537 Def0105 +S A$_ser$519 Def00ED +S A$_ser$474 Def00C3 +S A$_ser$465 Def00BF +S A$_ser$456 Def00B9 +S A$_ser$447 Def00B0 +S A$_ser$438 Def00A3 +S A$_ser$393 Def007F +S A$_ser$375 Def006A +S A$_ser$366 Def005E +S A$_ser$348 Def004D +S A$_ser$285 Def0017 +S A$_ser$267 Def0004 +S A$_ser$583 Def0133 +S A$_ser$565 Def0123 +S A$_ser$547 Def0117 +S A$_ser$529 Def00F9 +S A$_ser$493 Def00DB +S A$_ser$475 Def00C4 +S A$_ser$448 Def00B1 +S A$_ser$439 Def00A4 +S A$_ser$394 Def0081 +S A$_ser$385 Def0072 +S A$_ser$376 Def006B +S A$_ser$367 Def005F +S A$_ser$349 Def0050 +S A$_ser$295 Def0024 +S A$_ser$277 Def000E +S _ser_interrupt_handler Def0034 +S A$_ser$566 Def0124 +S A$_ser$548 Def0119 +S A$_ser$539 Def0106 +S A$_ser$494 Def00DC +S A$_ser$485 Def00CF +S A$_ser$476 Def00C5 +S A$_ser$458 Def00BB +S A$_ser$449 Def00B3 +S A$_ser$386 Def0075 +S A$_ser$368 Def0060 +S A$_ser$359 Def0055 +S A$_ser$287 Def0018 +S A$_ser$269 Def0007 +S _ser_charAvail Def011E +S A$_ser$576 Def012F +S A$_ser$567 Def0125 +S A$_ser$495 Def00DE +S A$_ser$486 Def00D2 +S A$_ser$477 Def00C8 +S A$_ser$396 Def0083 +S A$_ser$387 Def0076 +S A$_ser$369 Def0061 +S A$_ser$279 Def0011 +S A$_ser$568 Def0128 +S A$_ser$496 Def00E0 +S A$_ser$487 Def00D4 +S A$_ser$397 Def0084 +S A$_ser$388 Def0077 +S A$_ser$298 Def0027 +S A$_ser$289 Def001B +S A$_ser$497 Def00E1 +S A$_ser$488 Def00D5 +S A$_ser$479 Def00C9 +S A$_ser$398 Def0086 +S A$_ser$389 Def007A +S A$_ser$579 Def0131 +S A$_ser$489 Def00D6 +S A$_ser$399 Def0088 +S XG$ser_getc$0$0 Def00E8 +S A$_ser$499 Def00E2 +S _ser_init Def0000 +S XG$ser_interrupt_handler$0$0 Def0097 +S XG$ser_charAvail$0$0 Def0133 +S G$ser_getc$0$0 Def00C0 +S C$_ser.c$79$1$1 Def0033 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 06 +T 00 00 +R 00 00 00 06 +T 00 01 +R 00 00 00 06 +T 00 01 +R 00 00 00 06 +T 00 02 +R 00 00 00 06 +T 00 02 +R 00 00 00 06 +T 00 03 +R 00 00 00 06 +T 00 03 +R 00 00 00 06 +T 00 04 +R 00 00 00 06 +T 00 04 +R 00 00 00 06 +T 01 04 +R 00 00 00 06 +T 01 04 +R 00 00 00 06 +T 00 00 +R 00 00 00 08 +T 00 00 C2 AC C2 00 00 90 00 00 E4 F0 90 00 01 E4 +R 00 00 00 08 29 05 00 05 00 08 00 06 00 0D 00 06 +T 00 0D F0 90 00 02 E4 F0 90 00 03 E4 F0 75 C8 30 +R 00 00 00 08 00 04 00 06 00 09 00 06 +T 00 1B 75 CB FF 75 CA DD 75 C8 34 75 98 50 30 99 +R 00 00 00 08 +T 00 29 02 +R 00 00 00 08 +T 00 2A +R 00 00 00 08 +T 00 2A C2 99 +R 00 00 00 08 +T 00 2C +R 00 00 00 08 +T 00 2C 30 98 02 +R 00 00 00 08 +T 00 2F +R 00 00 00 08 +T 00 2F C2 98 +R 00 00 00 08 +T 00 31 +R 00 00 00 08 +T 00 31 D2 AC +R 00 00 00 08 +T 00 33 +R 00 00 00 08 +T 00 33 22 +R 00 00 00 08 +T 00 34 +R 00 00 00 08 +T 00 34 C0 E0 C0 F0 C0 82 C0 83 C0 D0 75 D0 08 C2 +R 00 00 00 08 +T 00 42 AC 30 99 27 +R 00 00 00 08 +T 00 46 +R 00 00 00 08 +T 00 46 C2 99 90 00 01 E0 FA 90 00 00 E0 FB B5 0A +R 00 00 00 08 00 05 00 06 00 0A 00 06 +T 00 54 04 +R 00 00 00 08 +T 00 55 +R 00 00 00 08 +T 00 55 +R 00 00 00 08 +T 00 55 C2 00 00 80 14 +R 00 00 00 08 29 03 00 05 +T 00 59 +R 00 00 00 08 +T 00 59 90 00 01 74 01 2A F0 EA 24 00 04 F5 82 E4 +R 00 00 00 08 00 03 00 06 09 0B 00 06 +T 00 66 34 00 04 F5 83 E0 F5 99 +R 00 00 00 08 89 03 00 06 +T 00 6D +R 00 00 00 08 +T 00 6D 30 98 1B +R 00 00 00 08 +T 00 70 +R 00 00 00 08 +T 00 70 C2 98 90 00 02 E0 FA 90 00 02 74 01 2A F0 +R 00 00 00 08 00 05 00 06 00 0A 00 06 +T 00 7E EA 24 01 04 F5 82 E4 34 01 04 F5 83 E5 99 +R 00 00 00 08 09 04 00 06 89 0A 00 06 +T 00 8A F0 +R 00 00 00 08 +T 00 8B +R 00 00 00 08 +T 00 8B D2 AC +R 00 00 00 08 +T 00 8D +R 00 00 00 08 +T 00 8D D0 D0 D0 83 D0 82 D0 F0 D0 E0 32 +R 00 00 00 08 +T 00 98 +R 00 00 00 08 +T 00 98 AA 82 C2 AC 30 00 00 1A +R 00 00 00 08 29 07 00 05 +T 00 9F +R 00 00 00 08 +T 00 9F 90 00 00 E0 FB 90 00 00 74 01 2B F0 EB 24 +R 00 00 00 08 00 03 00 06 00 08 00 06 +T 00 AD 00 04 F5 82 E4 34 00 04 F5 83 EA F0 80 04 +R 00 00 00 08 09 02 00 06 89 08 00 06 +T 00 B9 +R 00 00 00 08 +T 00 B9 D2 00 00 8A 99 +R 00 00 00 08 29 03 00 05 +T 00 BD +R 00 00 00 08 +T 00 BD D2 AC +R 00 00 00 08 +T 00 BF +R 00 00 00 08 +T 00 BF 22 +R 00 00 00 08 +T 00 C0 +R 00 00 00 08 +T 00 C0 90 00 03 E0 FA 90 00 02 E0 FB B5 02 02 80 +R 00 00 00 08 00 03 00 06 00 08 00 06 +T 00 CE 15 +R 00 00 00 08 +T 00 CF +R 00 00 00 08 +T 00 CF 90 00 03 74 01 2A F0 EA 24 01 04 F5 82 E4 +R 00 00 00 08 00 03 00 06 09 0B 00 06 +T 00 DC 34 01 04 F5 83 E0 FA 80 02 +R 00 00 00 08 89 03 00 06 +T 00 E4 +R 00 00 00 08 +T 00 E4 7A 00 +R 00 00 00 08 +T 00 E6 +R 00 00 00 08 +T 00 E6 8A 82 +R 00 00 00 08 +T 00 E8 +R 00 00 00 08 +T 00 E8 22 +R 00 00 00 08 +T 00 E9 +R 00 00 00 08 +T 00 E9 AA 82 AB 83 AC F0 +R 00 00 00 08 +T 00 EF +R 00 00 00 08 +T 00 EF 8A 82 8B 83 8C F0 12 00 00 FD 60 22 +R 00 00 00 08 02 09 00 4D +T 00 FB +R 00 00 00 08 +T 00 FB 8A 82 8B 83 8C F0 0A BA 00 01 0B +R 00 00 00 08 +T 01 06 +R 00 00 00 08 +T 01 06 12 00 00 FD C0 02 C0 03 C0 04 8D 82 12 +R 00 00 00 08 02 03 00 4D +T 01 13 00 98 D0 04 D0 03 D0 02 80 D2 +R 00 00 00 08 00 02 00 08 +T 01 1D +R 00 00 00 08 +T 01 1D 22 +R 00 00 00 08 +T 01 1E +R 00 00 00 08 +T 01 1E 7A 00 90 00 03 E0 FB 90 00 02 E0 FC B5 03 +R 00 00 00 08 00 05 00 06 00 0A 00 06 +T 01 2C 02 80 02 +R 00 00 00 08 +T 01 2F +R 00 00 00 08 +T 01 2F 7A 01 +R 00 00 00 08 +T 01 31 +R 00 00 00 08 +T 01 31 8A 82 +R 00 00 00 08 +T 01 33 +R 00 00 00 08 +T 01 33 22 +R 00 00 00 08 diff --git a/device/lib/small/_setjmp.asm b/device/lib/small/_setjmp.asm new file mode 100644 index 00000000..480c4a9e --- /dev/null +++ b/device/lib/small/_setjmp.asm @@ -0,0 +1,338 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:15 2000 + +;-------------------------------------------------------- + .module _setjmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _longjmp_PARM_2 + .globl _setjmp + .globl _longjmp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_longjmp_PARM_2: + .ds 0x0002 + .area _DUMMY + .area OSEG (OVR,DATA) +_setjmp_bp_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$longjmp$0$0 ==. +; _setjmp.c 28 +; ----------------------------------------- +; function longjmp +; ----------------------------------------- +_longjmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _setjmp.c 35 + mov r2,dpl + mov r3,dph + mov r4,b +; _setjmp.c 31 + mov a,#0x02 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a + mov b,r4 + lcall __gptrget + mov r5,a +; _setjmp.c 32 + mov ar0,r5 + mov dpl,r2 + mov dph,r3 + mov b,r4 + inc r2 + cjne r2,#0x00,00103$ + inc r3 +00103$: + lcall __gptrget +; Peephole 192 used a instead of ar6 as source + mov r6,a + mov @r0,a +; _setjmp.c 33 + dec r0 + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 192 used a instead of ar2 as source + mov r2,a + mov @r0,a +; _setjmp.c 34 + mov _SP,r5 +; _setjmp.c 35 + mov dpl,_longjmp_PARM_2 + mov dph,(_longjmp_PARM_2 + 1) +00101$: + C$_setjmp.c$36$1$1 ==. + XG$longjmp$0$0 ==. + ret + G$setjmp$0$0 ==. +; _setjmp.c 38 +; ----------------------------------------- +; function setjmp +; ----------------------------------------- +_setjmp: +; _setjmp.c 0 + mov _setjmp_bp_1_1,dpl + mov (_setjmp_bp_1_1 + 1),dph + mov (_setjmp_bp_1_1 + 2),b +; _setjmp.c 43 + mov r5,_setjmp_bp_1_1 + mov r6,(_setjmp_bp_1_1 + 1) + mov r7,(_setjmp_bp_1_1 + 2) + inc _setjmp_bp_1_1 + clr a + cjne a,_setjmp_bp_1_1,00103$ + inc (_setjmp_bp_1_1 + 1) +00103$: + mov r0,_SP + mov ar2,@r0 + mov dpl,r5 + mov dph,r6 + mov b,r7 + mov a,r2 + lcall __gptrput +; _setjmp.c 44 + mov r2,_setjmp_bp_1_1 + mov r3,(_setjmp_bp_1_1 + 1) + mov r4,(_setjmp_bp_1_1 + 2) + inc _setjmp_bp_1_1 + clr a + cjne a,_setjmp_bp_1_1,00104$ + inc (_setjmp_bp_1_1 + 1) +00104$: + mov r5,_SP + mov a,r5 + add a,#0xff + mov r0,a + mov ar5,@r0 + mov dpl,r2 + mov dph,r3 + mov b,r4 + mov a,r5 + lcall __gptrput +; _setjmp.c 45 + mov dpl,_setjmp_bp_1_1 + mov dph,(_setjmp_bp_1_1 + 1) + mov b,(_setjmp_bp_1_1 + 2) + mov a,_SP + lcall __gptrput +; _setjmp.c 46 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 +00101$: + C$_setjmp.c$48$1$1 ==. + XG$setjmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_setjmp.cdb b/device/lib/small/_setjmp.cdb new file mode 100644 index 00000000..ff668dbf --- /dev/null +++ b/device/lib/small/_setjmp.cdb @@ -0,0 +1,86 @@ +M:_setjmp +F:G$longjmp$0$0({2}DF,SI:S),C,0,0,0,0,0 +F:G$setjmp$0$0({2}DF,SI:S),C,0,0,0,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/small/_setjmp.rel b/device/lib/small/_setjmp.rel new file mode 100644 index 00000000..46908778 --- /dev/null +++ b/device/lib/small/_setjmp.rel @@ -0,0 +1,235 @@ +;!FILE _setjmp.asm +XH +H 9 areas A8 global symbols +M _setjmp +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S __gptrput Ref0000 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 3 flags 4 +S _longjmp_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 93 flags 20 +S C$_setjmp.c$36$1$1 Def003B +S C$_setjmp.c$48$1$1 Def0092 +S G$setjmp$0$0 Def003C +S _longjmp Def0000 +S XG$longjmp$0$0 Def003B +S G$longjmp$0$0 Def0000 +S A$_setjmp$300 Def0055 +S A$_setjmp$310 Def0067 +S A$_setjmp$301 Def0057 +S A$_setjmp$320 Def0077 +S A$_setjmp$311 Def0069 +S A$_setjmp$302 Def0059 +S A$_setjmp$330 Def008C +S A$_setjmp$321 Def0079 +S A$_setjmp$312 Def006A +S A$_setjmp$303 Def005B +S A$_setjmp$240 Def0008 +S A$_setjmp$322 Def007B +S A$_setjmp$313 Def006D +S A$_setjmp$304 Def005D +S A$_setjmp$250 Def0015 +S A$_setjmp$241 Def0009 +S _setjmp Def003C +S A$_setjmp$323 Def007D +S A$_setjmp$305 Def005E +S A$_setjmp$260 Def0025 +S A$_setjmp$251 Def0017 +S A$_setjmp$333 Def008F +S A$_setjmp$324 Def007E +S A$_setjmp$315 Def006F +S A$_setjmp$270 Def0032 +S A$_setjmp$261 Def0026 +S A$_setjmp$252 Def0019 +S A$_setjmp$243 Def000B +S A$_setjmp$316 Def0071 +S A$_setjmp$307 Def0061 +S A$_setjmp$253 Def001B +S A$_setjmp$244 Def000C +S A$_setjmp$235 Def0000 +S A$_setjmp$326 Def0081 +S A$_setjmp$317 Def0072 +S A$_setjmp$308 Def0063 +S A$_setjmp$272 Def0033 +S A$_setjmp$263 Def0027 +S A$_setjmp$254 Def001D +S A$_setjmp$245 Def000D +S A$_setjmp$236 Def0002 +S A$_setjmp$327 Def0084 +S A$_setjmp$318 Def0074 +S A$_setjmp$309 Def0065 +S A$_setjmp$291 Def0045 +S A$_setjmp$264 Def0028 +S A$_setjmp$255 Def001E +S A$_setjmp$246 Def000F +S A$_setjmp$237 Def0004 +S A$_setjmp$337 Def0092 +S A$_setjmp$328 Def0087 +S A$_setjmp$319 Def0075 +S A$_setjmp$292 Def0047 +S A$_setjmp$274 Def0035 +S A$_setjmp$265 Def002A +S A$_setjmp$256 Def0021 +S A$_setjmp$247 Def0011 +S A$_setjmp$329 Def008A +S A$_setjmp$293 Def0049 +S A$_setjmp$275 Def0038 +S A$_setjmp$266 Def002C +S A$_setjmp$248 Def0014 +S A$_setjmp$239 Def0006 +S A$_setjmp$294 Def004B +S A$_setjmp$267 Def002E +S A$_setjmp$258 Def0022 +S A$_setjmp$295 Def004D +S A$_setjmp$296 Def004E +S A$_setjmp$287 Def003C +S A$_setjmp$269 Def0031 +S A$_setjmp$297 Def0051 +S A$_setjmp$288 Def003F +S A$_setjmp$279 Def003B +S A$_setjmp$289 Def0042 +S XG$setjmp$0$0 Def0092 +S A$_setjmp$299 Def0053 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 74 02 2A F5 82 E4 3B F5 +R 00 00 00 08 +T 00 0E 83 8C F0 12 00 00 FD 8D 00 8A 82 8B 83 8C +R 00 00 00 08 02 06 00 4E +T 00 1C F0 0A BA 00 01 0B +R 00 00 00 08 +T 00 22 +R 00 00 00 08 +T 00 22 12 00 00 FE F6 18 8A 82 8B 83 8C F0 12 +R 00 00 00 08 02 03 00 4E +T 00 2F 00 00 FA F6 8D 81 85 00 00 82 85 00 01 83 +R 00 00 00 08 02 02 00 4E 29 09 00 03 29 0D 00 03 +T 00 3B +R 00 00 00 08 +T 00 3B 22 +R 00 00 00 08 +T 00 3C +R 00 00 00 08 +T 00 3C 85 82 00 00 85 83 00 01 85 F0 00 02 AD +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0C 00 03 +T 00 46 00 00 AE 00 01 AF 00 02 05 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 4C 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 53 +R 00 00 00 08 +T 00 53 A8 81 86 02 8D 82 8E 83 8F F0 EA 12 00 00 +R 00 00 00 08 02 0E 00 1F +T 00 61 AA 00 00 AB 00 01 AC 00 02 05 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 68 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 6F +R 00 00 00 08 +T 00 6F AD 81 ED 24 FF F8 86 05 8A 82 8B 83 8C F0 +R 00 00 00 08 +T 00 7D ED 12 00 00 85 00 00 82 85 00 01 83 85 +R 00 00 00 08 02 04 00 1F 29 07 00 03 29 0B 00 03 +T 00 88 00 02 F0 E5 81 12 00 00 90 00 00 +R 00 00 00 08 29 02 00 03 02 08 00 1F +T 00 92 +R 00 00 00 08 +T 00 92 22 +R 00 00 00 08 diff --git a/device/lib/small/_spx.asm b/device/lib/small/_spx.asm new file mode 100644 index 00000000..1c1cc9ba --- /dev/null +++ b/device/lib/small/_spx.asm @@ -0,0 +1,48 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:15 2000 + +;-------------------------------------------------------- + .module _spx +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _spx +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +G$spx$0$0==. +_spx: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + .area CSEG (CODE) diff --git a/device/lib/small/_spx.cdb b/device/lib/small/_spx.cdb new file mode 100644 index 00000000..dbd29c49 --- /dev/null +++ b/device/lib/small/_spx.cdb @@ -0,0 +1,2 @@ +M:_spx +S:G$spx$0$0({1}SC:U),E,0,0 diff --git a/device/lib/small/_spx.rel b/device/lib/small/_spx.rel new file mode 100644 index 00000000..8ed7637a --- /dev/null +++ b/device/lib/small/_spx.rel @@ -0,0 +1,17 @@ +XH +H 8 areas 2 global symbols +M _spx +A _CODE size 0 flags 0 +A DSEG size 1 flags 0 +S G$spx$0$0 Def0000 +S _spx Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 0 flags 20 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 diff --git a/device/lib/small/_startup.asm b/device/lib/small/_startup.asm new file mode 100644 index 00000000..a1a1d5bf --- /dev/null +++ b/device/lib/small/_startup.asm @@ -0,0 +1,65 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:15 2000 + +;-------------------------------------------------------- + .module _startup +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __sdcc_external_startup +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_sdcc_external_startup$0$0 ==. +; _startup.c 30 +; ----------------------------------------- +; function _sdcc_external_startup +; ----------------------------------------- +__sdcc_external_startup: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _startup.c 32 + mov dpl,#0x00 +00101$: + C$_startup.c$33$1$1 ==. + XG$_sdcc_external_startup$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_startup.cdb b/device/lib/small/_startup.cdb new file mode 100644 index 00000000..60863d5f --- /dev/null +++ b/device/lib/small/_startup.cdb @@ -0,0 +1,2 @@ +M:_startup +F:G$_sdcc_external_startup$0$0({2}DF,SC:U),C,0,0,0,0,0 diff --git a/device/lib/small/_startup.rel b/device/lib/small/_startup.rel new file mode 100644 index 00000000..09a36715 --- /dev/null +++ b/device/lib/small/_startup.rel @@ -0,0 +1,26 @@ +;!FILE _startup.asm +XH +H 8 areas 6 global symbols +M _startup +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 4 flags 20 +S A$_startup$60 Def0000 +S A$_startup$64 Def0003 +S __sdcc_external_startup Def0000 +S XG$_sdcc_external_startup$0$0 Def0003 +S G$_sdcc_external_startup$0$0 Def0000 +S C$_startup.c$33$1$1 Def0003 +T 00 00 +R 00 00 00 07 +T 00 00 75 82 00 +R 00 00 00 07 +T 00 03 +R 00 00 00 07 +T 00 03 22 +R 00 00 00 07 diff --git a/device/lib/small/_strcat.asm b/device/lib/small/_strcat.asm new file mode 100644 index 00000000..36552765 --- /dev/null +++ b/device/lib/small/_strcat.asm @@ -0,0 +1,127 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:21 2000 + +;-------------------------------------------------------- + .module _strcat +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcat_PARM_2 + .globl _strcat +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strcat_PARM_2: + .ds 0x0003 +_strcat_dst_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcat$0$0 ==. +; _strcat.c 26 +; ----------------------------------------- +; function strcat +; ----------------------------------------- +_strcat: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcat.c 38 + mov _strcat_dst_1_1,dpl + mov (_strcat_dst_1_1 + 1),dph + mov (_strcat_dst_1_1 + 2),b +; _strcat.c 33 + mov r5,_strcat_dst_1_1 + mov r6,(_strcat_dst_1_1 + 1) + mov r7,(_strcat_dst_1_1 + 2) +00101$: + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00111$ +00113$: +; _strcat.c 34 + inc r5 + cjne r5,#0x00,00114$ + inc r6 +00114$: +; _strcat.c 36 +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00111$: +00104$: + mov ar3,r5 + mov ar4,r6 + mov ar2,r7 + inc r5 + cjne r5,#0x00,00115$ + inc r6 +00115$: + mov dpl,_strcat_PARM_2 + mov dph,(_strcat_PARM_2 + 1) + mov b,(_strcat_PARM_2 + 2) + inc _strcat_PARM_2 + clr a + cjne a,_strcat_PARM_2,00116$ + inc (_strcat_PARM_2 + 1) +00116$: + lcall __gptrget +; Peephole 190 removed redundant mov +; Peephole 191 removed redundant mov + mov r0,a + mov dpl,r3 + mov dph,r4 + mov b,r2 + lcall __gptrput +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00117$: +; _strcat.c 38 + mov dpl,_strcat_dst_1_1 + mov dph,(_strcat_dst_1_1 + 1) + mov b,(_strcat_dst_1_1 + 2) +00107$: + C$_strcat.c$40$1$1 ==. + XG$strcat$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strcat.cdb b/device/lib/small/_strcat.cdb new file mode 100644 index 00000000..50dd1670 --- /dev/null +++ b/device/lib/small/_strcat.cdb @@ -0,0 +1,2 @@ +M:_strcat +F:G$strcat$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strcat.rel b/device/lib/small/_strcat.rel new file mode 100644 index 00000000..bb902ff5 --- /dev/null +++ b/device/lib/small/_strcat.rel @@ -0,0 +1,112 @@ +;!FILE _strcat.asm +XH +H 9 areas 2F global symbols +M _strcat +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 6 flags 4 +S _strcat_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 57 flags 20 +S A$_strcat$70 Def0009 +S A$_strcat$71 Def000B +S A$_strcat$90 Def0020 +S A$_strcat$81 Def0019 +S A$_strcat$72 Def000D +S A$_strcat$74 Def000F +S G$strcat$0$0 Def0000 +S A$_strcat$93 Def0022 +S A$_strcat$84 Def001B +S A$_strcat$75 Def0011 +S A$_strcat$66 Def0000 +S A$_strcat$94 Def0024 +S A$_strcat$85 Def001C +S A$_strcat$76 Def0013 +S A$_strcat$67 Def0003 +S A$_strcat$95 Def0026 +S A$_strcat$86 Def001F +S A$_strcat$77 Def0015 +S A$_strcat$68 Def0006 +S A$_strcat$96 Def0028 +S A$_strcat$97 Def0029 +S A$_strcat$79 Def0018 +S A$_strcat$98 Def002C +S A$_strcat$100 Def002D +S A$_strcat$101 Def0030 +S A$_strcat$120 Def004D +S A$_strcat$111 Def0041 +S A$_strcat$102 Def0033 +S A$_strcat$121 Def0050 +S A$_strcat$112 Def0042 +S A$_strcat$103 Def0036 +S A$_strcat$122 Def0053 +S A$_strcat$113 Def0044 +S A$_strcat$104 Def0038 +S A$_strcat$114 Def0046 +S A$_strcat$105 Def0039 +S A$_strcat$115 Def0048 +S A$_strcat$106 Def003C +S _strcat Def0000 +S A$_strcat$126 Def0056 +S A$_strcat$117 Def004B +S A$_strcat$108 Def003E +S C$_strcat.c$40$1$1 Def0056 +S XG$strcat$0$0 Def0056 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 85 82 00 03 85 83 00 04 85 F0 00 05 AD +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0C 00 03 +T 00 0A 00 03 AE 00 04 AF 00 05 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 0F +R 00 00 00 08 +T 00 0F 8D 82 8E 83 8F F0 12 00 00 F8 60 07 +R 00 00 00 08 02 09 00 01 +T 00 1B +R 00 00 00 08 +T 00 1B 0D BD 00 01 0E +R 00 00 00 08 +T 00 20 +R 00 00 00 08 +T 00 20 80 ED +R 00 00 00 08 +T 00 22 +R 00 00 00 08 +T 00 22 +R 00 00 00 08 +T 00 22 8D 03 8E 04 8F 02 0D BD 00 01 0E +R 00 00 00 08 +T 00 2D +R 00 00 00 08 +T 00 2D 85 00 00 82 85 00 01 83 85 00 02 F0 05 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 37 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 3E +R 00 00 00 08 +T 00 3E 12 00 00 F8 8B 82 8C 83 8A F0 12 00 00 70 +R 00 00 00 08 02 03 00 01 02 0D 00 00 +T 00 4C D5 +R 00 00 00 08 +T 00 4D +R 00 00 00 08 +T 00 4D 85 00 03 82 85 00 04 83 85 00 05 F0 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 56 +R 00 00 00 08 +T 00 56 22 +R 00 00 00 08 diff --git a/device/lib/small/_strchr.asm b/device/lib/small/_strchr.asm new file mode 100644 index 00000000..e859955b --- /dev/null +++ b/device/lib/small/_strchr.asm @@ -0,0 +1,114 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:15 2000 + +;-------------------------------------------------------- + .module _strchr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strchr_PARM_2 + .globl _strchr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strchr_PARM_2: + .ds 0x0001 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strchr$0$0 ==. +; _strchr.c 27 +; ----------------------------------------- +; function strchr +; ----------------------------------------- +_strchr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strchr.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _strchr.c 32 +00102$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00113$: + mov a,r5 + cjne a,_strchr_PARM_2,00114$ +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00114$: +; _strchr.c 33 + inc r2 + cjne r2,#0x00,00115$ + inc r3 +00115$: +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00104$: +; _strchr.c 35 + mov a,r5 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,_strchr_PARM_2,00106$ +; Peephole 201 removed redundant sjmp +00116$: +00117$: +; _strchr.c 36 + mov dpl,r2 + mov dph,r3 + mov b,r4 +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00106$: +; _strchr.c 37 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00107$: + C$_strchr.c$38$1$1 ==. + XG$strchr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strchr.cdb b/device/lib/small/_strchr.cdb new file mode 100644 index 00000000..f295b35d --- /dev/null +++ b/device/lib/small/_strchr.cdb @@ -0,0 +1,2 @@ +M:_strchr +F:G$strchr$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strchr.rel b/device/lib/small/_strchr.rel new file mode 100644 index 00000000..47186eed --- /dev/null +++ b/device/lib/small/_strchr.rel @@ -0,0 +1,86 @@ +;!FILE _strchr.asm +XH +H 9 areas 1F global symbols +M _strchr +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 1 flags 4 +S _strchr_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 32 flags 20 +S XG$strchr$0$0 Def0031 +S A$_strchr$70 Def0008 +S A$_strchr$71 Def000A +S C$_strchr.c$38$1$1 Def0031 +S A$_strchr$81 Def0016 +S A$_strchr$72 Def000C +S A$_strchr$64 Def0000 +S A$_strchr$92 Def001F +S A$_strchr$74 Def000F +S A$_strchr$65 Def0002 +S G$strchr$0$0 Def0000 +S A$_strchr$84 Def0018 +S A$_strchr$66 Def0004 +S A$_strchr$85 Def0019 +S A$_strchr$76 Def0010 +S A$_strchr$95 Def0020 +S A$_strchr$86 Def001C +S A$_strchr$78 Def0012 +S A$_strchr$69 Def0006 +S A$_strchr$79 Def0013 +S A$_strchr$89 Def001D +S A$_strchr$100 Def0023 +S A$_strchr$101 Def0025 +S A$_strchr$102 Def0027 +S A$_strchr$113 Def0031 +S A$_strchr$104 Def0029 +S _strchr Def0000 +S A$_strchr$108 Def002B +S A$_strchr$109 Def002E +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 +R 00 00 00 08 +T 00 06 +R 00 00 00 08 +T 00 06 8A 82 8B 83 8C F0 12 00 00 FD 60 0D +R 00 00 00 08 02 09 00 00 +T 00 12 +R 00 00 00 08 +T 00 12 ED B5 00 00 02 80 07 +R 00 00 00 08 29 04 00 03 +T 00 18 +R 00 00 00 08 +T 00 18 0A BA 00 01 0B +R 00 00 00 08 +T 00 1D +R 00 00 00 08 +T 00 1D 80 E7 +R 00 00 00 08 +T 00 1F +R 00 00 00 08 +T 00 1F ED B5 00 00 08 +R 00 00 00 08 29 04 00 03 +T 00 23 +R 00 00 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 8A 82 8B 83 8C F0 80 06 +R 00 00 00 08 +T 00 2B +R 00 00 00 08 +T 00 2B 90 00 00 75 F0 00 +R 00 00 00 08 +T 00 31 +R 00 00 00 08 +T 00 31 22 +R 00 00 00 08 diff --git a/device/lib/small/_strcmp.asm b/device/lib/small/_strcmp.asm new file mode 100644 index 00000000..07b496b1 --- /dev/null +++ b/device/lib/small/_strcmp.asm @@ -0,0 +1,149 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strcmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcmp_PARM_2 + .globl _strcmp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strcmp_PARM_2: + .ds 0x0003 +_strcmp_ret_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcmp$0$0 ==. +; _strcmp.c 27 +; ----------------------------------------- +; function strcmp +; ----------------------------------------- +_strcmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcmp.c 42 + mov r2,dpl + mov r3,dph + mov r4,b +; _strcmp.c 34 + mov r5,_strcmp_PARM_2 + mov r6,(_strcmp_PARM_2 + 1) + mov r7,(_strcmp_PARM_2 + 2) +00102$: + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r0,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 106 removed redundant mov + mov r1,a + clr c + subb a,r0 +; Peephole 166 removed redundant mov + mov r1,a + mov _strcmp_ret_1_1,r1 + rlc a + subb a,acc + mov (_strcmp_ret_1_1 + 1),a + mov a,r1 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00104$ +00117$: + mov a,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00118$: +; _strcmp.c 35 + inc r2 + cjne r2,#0x00,00119$ + inc r3 +00119$: + inc r5 + cjne r5,#0x00,00120$ + inc r6 +00120$: +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00104$: +; _strcmp.c 37 + mov a,(_strcmp_ret_1_1 + 1) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00108$ +00121$: +; _strcmp.c 38 + mov _strcmp_ret_1_1,#0xff + mov (_strcmp_ret_1_1 + 1),#0xff +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: +; _strcmp.c 39 + clr c +; Peephole 180 changed mov to clr + clr a + subb a,_strcmp_ret_1_1 +; Peephole 159 avoided xrl during execution + mov a,#(0x00 ^ 0x80) + mov b,(_strcmp_ret_1_1 + 1) + xrl b,#0x80 + subb a,b +; Peephole 108 removed ljmp by inverse jump logic + jnc 00109$ +00122$: +; _strcmp.c 40 + clr a + mov (_strcmp_ret_1_1 + 1),a + mov _strcmp_ret_1_1,#0x01 +00109$: +; _strcmp.c 42 + mov dpl,_strcmp_ret_1_1 + mov dph,(_strcmp_ret_1_1 + 1) +00110$: + C$_strcmp.c$43$1$1 ==. + XG$strcmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strcmp.cdb b/device/lib/small/_strcmp.cdb new file mode 100644 index 00000000..7a674a90 --- /dev/null +++ b/device/lib/small/_strcmp.cdb @@ -0,0 +1,2 @@ +M:_strcmp +F:G$strcmp$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strcmp.rel b/device/lib/small/_strcmp.rel new file mode 100644 index 00000000..dab6681b --- /dev/null +++ b/device/lib/small/_strcmp.rel @@ -0,0 +1,136 @@ +;!FILE _strcmp.asm +XH +H 9 areas 3B global symbols +M _strcmp +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 5 flags 4 +S _strcmp_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 66 flags 20 +S XG$strcmp$0$0 Def0065 +S C$_strcmp.c$43$1$1 Def0065 +S A$_strcmp$70 Def0006 +S A$_strcmp$80 Def0018 +S A$_strcmp$71 Def0008 +S A$_strcmp$90 Def0025 +S A$_strcmp$81 Def001A +S A$_strcmp$72 Def000A +S A$_strcmp$91 Def0026 +S A$_strcmp$82 Def001C +S A$_strcmp$92 Def0028 +S A$_strcmp$74 Def000C +S G$strcmp$0$0 Def0000 +S A$_strcmp$93 Def002A +S A$_strcmp$84 Def001F +S A$_strcmp$75 Def000E +S A$_strcmp$66 Def0000 +S A$_strcmp$85 Def0020 +S A$_strcmp$76 Def0010 +S A$_strcmp$67 Def0002 +S A$_strcmp$95 Def002B +S A$_strcmp$86 Def0021 +S A$_strcmp$77 Def0012 +S A$_strcmp$68 Def0004 +S A$_strcmp$78 Def0015 +S A$_strcmp$97 Def002D +S A$_strcmp$88 Def0022 +S A$_strcmp$79 Def0016 +S A$_strcmp$89 Def0023 +S A$_strcmp$99 Def002E +S A$_strcmp$120 Def0044 +S A$_strcmp$111 Def003A +S A$_strcmp$102 Def0030 +S A$_strcmp$130 Def004D +S A$_strcmp$103 Def0031 +S A$_strcmp$140 Def005C +S A$_strcmp$131 Def004F +S A$_strcmp$122 Def0047 +S A$_strcmp$104 Def0034 +S A$_strcmp$132 Def0052 +S A$_strcmp$114 Def003C +S A$_strcmp$133 Def0055 +S A$_strcmp$106 Def0035 +S _strcmp Def0000 +S A$_strcmp$143 Def005F +S A$_strcmp$125 Def0049 +S A$_strcmp$116 Def003E +S A$_strcmp$107 Def0036 +S A$_strcmp$144 Def0062 +S A$_strcmp$135 Def0057 +S A$_strcmp$108 Def0039 +S A$_strcmp$127 Def004A +S A$_strcmp$128 Def004B +S A$_strcmp$119 Def0041 +S A$_strcmp$138 Def0059 +S A$_strcmp$148 Def0065 +S A$_strcmp$139 Def005A +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 AD 00 00 AE 00 01 AF +R 00 00 00 08 29 09 00 03 29 0C 00 03 +T 00 0B 00 02 +R 00 00 00 08 29 02 00 03 +T 00 0C +R 00 00 00 08 +T 00 0C 8D 82 8E 83 8F F0 12 00 00 F8 8A 82 8B 83 +R 00 00 00 08 02 09 00 00 +T 00 1A 8C F0 12 00 00 F9 C3 98 F9 89 00 03 33 95 +R 00 00 00 08 02 05 00 00 29 0C 00 03 +T 00 27 E0 F5 00 04 E9 70 0F +R 00 00 00 08 29 04 00 03 +T 00 2D +R 00 00 00 08 +T 00 2D E8 60 0C +R 00 00 00 08 +T 00 30 +R 00 00 00 08 +T 00 30 0A BA 00 01 0B +R 00 00 00 08 +T 00 35 +R 00 00 00 08 +T 00 35 0D BD 00 01 0E +R 00 00 00 08 +T 00 3A +R 00 00 00 08 +T 00 3A 80 D0 +R 00 00 00 08 +T 00 3C +R 00 00 00 08 +T 00 3C E5 00 04 30 E7 08 +R 00 00 00 08 29 03 00 03 +T 00 41 +R 00 00 00 08 +T 00 41 75 00 03 FF 75 00 04 FF 80 16 +R 00 00 00 08 29 03 00 03 29 07 00 03 +T 00 49 +R 00 00 00 08 +T 00 49 C3 E4 95 00 03 74 80 85 00 04 F0 63 F0 80 +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 55 95 F0 50 06 +R 00 00 00 08 +T 00 59 +R 00 00 00 08 +T 00 59 E4 F5 00 04 75 00 03 01 +R 00 00 00 08 29 04 00 03 29 07 00 03 +T 00 5F +R 00 00 00 08 +T 00 5F 85 00 03 82 85 00 04 83 +R 00 00 00 08 29 03 00 03 29 07 00 03 +T 00 65 +R 00 00 00 08 +T 00 65 22 +R 00 00 00 08 diff --git a/device/lib/small/_strcpy.asm b/device/lib/small/_strcpy.asm new file mode 100644 index 00000000..40601552 --- /dev/null +++ b/device/lib/small/_strcpy.asm @@ -0,0 +1,108 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strcpy +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcpy_PARM_2 + .globl _strcpy +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strcpy_PARM_2: + .ds 0x0003 +_strcpy_d_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcpy$0$0 ==. +; _strcpy.c 27 +; ----------------------------------------- +; function strcpy +; ----------------------------------------- +_strcpy: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcpy.c 35 + mov _strcpy_d_1_1,dpl + mov (_strcpy_d_1_1 + 1),dph + mov (_strcpy_d_1_1 + 2),b +; _strcpy.c 33 + mov r5,_strcpy_d_1_1 + mov r6,(_strcpy_d_1_1 + 1) + mov r7,(_strcpy_d_1_1 + 2) +00101$: + mov ar3,r5 + mov ar4,r6 + mov ar2,r7 + inc r5 + cjne r5,#0x00,00108$ + inc r6 +00108$: + mov dpl,_strcpy_PARM_2 + mov dph,(_strcpy_PARM_2 + 1) + mov b,(_strcpy_PARM_2 + 2) + inc _strcpy_PARM_2 + clr a + cjne a,_strcpy_PARM_2,00109$ + inc (_strcpy_PARM_2 + 1) +00109$: + lcall __gptrget +; Peephole 190 removed redundant mov +; Peephole 191 removed redundant mov + mov r0,a + mov dpl,r3 + mov dph,r4 + mov b,r2 + lcall __gptrput +; Peephole 109 removed ljmp by inverse jump logic + jnz 00101$ +00110$: +; _strcpy.c 35 + mov dpl,_strcpy_d_1_1 + mov dph,(_strcpy_d_1_1 + 1) + mov b,(_strcpy_d_1_1 + 2) +00104$: + C$_strcpy.c$36$1$1 ==. + XG$strcpy$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strcpy.cdb b/device/lib/small/_strcpy.cdb new file mode 100644 index 00000000..42708a46 --- /dev/null +++ b/device/lib/small/_strcpy.cdb @@ -0,0 +1,2 @@ +M:_strcpy +F:G$strcpy$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strcpy.rel b/device/lib/small/_strcpy.rel new file mode 100644 index 00000000..ccf1db67 --- /dev/null +++ b/device/lib/small/_strcpy.rel @@ -0,0 +1,88 @@ +;!FILE _strcpy.asm +XH +H 9 areas 25 global symbols +M _strcpy +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 6 flags 4 +S _strcpy_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 44 flags 20 +S A$_strcpy$102 Def003D +S A$_strcpy$103 Def0040 +S _strcpy Def0000 +S A$_strcpy$107 Def0043 +S XG$strcpy$0$0 Def0043 +S C$_strcpy.c$36$1$1 Def0043 +S A$_strcpy$70 Def0009 +S A$_strcpy$71 Def000B +S A$_strcpy$81 Def001A +S A$_strcpy$72 Def000D +S A$_strcpy$82 Def001D +S A$_strcpy$92 Def002E +S A$_strcpy$83 Def0020 +S A$_strcpy$74 Def000F +S G$strcpy$0$0 Def0000 +S A$_strcpy$93 Def002F +S A$_strcpy$84 Def0023 +S A$_strcpy$75 Def0011 +S A$_strcpy$66 Def0000 +S A$_strcpy$94 Def0031 +S A$_strcpy$85 Def0025 +S A$_strcpy$76 Def0013 +S A$_strcpy$67 Def0003 +S A$_strcpy$95 Def0033 +S A$_strcpy$86 Def0026 +S A$_strcpy$77 Def0015 +S A$_strcpy$68 Def0006 +S A$_strcpy$96 Def0035 +S A$_strcpy$87 Def0029 +S A$_strcpy$78 Def0016 +S A$_strcpy$79 Def0019 +S A$_strcpy$98 Def0038 +S A$_strcpy$89 Def002B +S A$_strcpy$101 Def003A +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 85 82 00 03 85 83 00 04 85 F0 00 05 AD +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0C 00 03 +T 00 0A 00 03 AE 00 04 AF 00 05 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 0F +R 00 00 00 08 +T 00 0F 8D 03 8E 04 8F 02 0D BD 00 01 0E +R 00 00 00 08 +T 00 1A +R 00 00 00 08 +T 00 1A 85 00 00 82 85 00 01 83 85 00 02 F0 05 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 24 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 2B +R 00 00 00 08 +T 00 2B 12 00 00 F8 8B 82 8C 83 8A F0 12 00 00 70 +R 00 00 00 08 02 03 00 01 02 0D 00 00 +T 00 39 D5 +R 00 00 00 08 +T 00 3A +R 00 00 00 08 +T 00 3A 85 00 03 82 85 00 04 83 85 00 05 F0 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 43 +R 00 00 00 08 +T 00 43 22 +R 00 00 00 08 diff --git a/device/lib/small/_strcspn.asm b/device/lib/small/_strcspn.asm new file mode 100644 index 00000000..1b0f4f84 --- /dev/null +++ b/device/lib/small/_strcspn.asm @@ -0,0 +1,125 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strcspn +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strcspn_PARM_2 + .globl _strcspn +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strcspn_PARM_2: + .ds 0x0003 +_strcspn_string_1_1: + .ds 0x0003 +_strcspn_count_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strcspn$0$0 ==. +; _strcspn.c 27 +; ----------------------------------------- +; function strcspn +; ----------------------------------------- +_strcspn: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strcspn.c 42 + mov _strcspn_string_1_1,dpl + mov (_strcspn_string_1_1 + 1),dph + mov (_strcspn_string_1_1 + 2),b +; _strcspn.c 35 + mov r5,_strcspn_PARM_2 + mov r6,(_strcspn_PARM_2 + 1) + mov r7,(_strcspn_PARM_2 + 2) + clr a + mov (_strcspn_count_1_1 + 1),a + mov _strcspn_count_1_1,a +00104$: + mov dpl,_strcspn_string_1_1 + mov dph,(_strcspn_string_1_1 + 1) + mov b,(_strcspn_string_1_1 + 2) + lcall __gptrget +; Peephole 166 removed redundant mov + mov r0,a + mov ar1,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00112$: +; _strcspn.c 36 + mov _strchr_PARM_2,r1 + push ar5 + push ar6 + push ar7 + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall _strchr + mov r0,dpl + mov r1,dph + mov r2,b + pop ar7 + pop ar6 + pop ar5 + mov a,r0 + orl a,r1 + orl a,r2 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00106$ +00113$: +; _strcspn.c 39 + inc _strcspn_count_1_1 + clr a + cjne a,_strcspn_count_1_1,00114$ + inc (_strcspn_count_1_1 + 1) +00114$: +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00106$: +; _strcspn.c 42 + mov dpl,_strcspn_count_1_1 + mov dph,(_strcspn_count_1_1 + 1) +00107$: + C$_strcspn.c$43$1$1 ==. + XG$strcspn$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strcspn.cdb b/device/lib/small/_strcspn.cdb new file mode 100644 index 00000000..8fa76335 --- /dev/null +++ b/device/lib/small/_strcspn.cdb @@ -0,0 +1,2 @@ +M:_strcspn +F:G$strcspn$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strcspn.rel b/device/lib/small/_strcspn.rel new file mode 100644 index 00000000..b01c6778 --- /dev/null +++ b/device/lib/small/_strcspn.rel @@ -0,0 +1,112 @@ +;!FILE _strcspn.asm +XH +H 8 areas 32 global symbols +M _strcspn +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +S _strcspn_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 58 flags 20 +S A$_strcspn$92 Def002B +S A$_strcspn$83 Def0020 +S A$_strcspn$74 Def000F +S G$strcspn$0$0 Def0000 +S A$_strcspn$93 Def002D +S A$_strcspn$84 Def0021 +S A$_strcspn$75 Def0010 +S A$_strcspn$94 Def002F +S A$_strcspn$76 Def0012 +S A$_strcspn$67 Def0000 +S A$_strcspn$95 Def0031 +S A$_strcspn$86 Def0023 +S A$_strcspn$68 Def0003 +S A$_strcspn$96 Def0033 +S A$_strcspn$78 Def0014 +S A$_strcspn$69 Def0006 +S A$_strcspn$97 Def0036 +S A$_strcspn$79 Def0017 +S A$_strcspn$98 Def0038 +S A$_strcspn$89 Def0025 +S A$_strcspn$99 Def003A +S A$_strcspn$100 Def003C +S A$_strcspn$110 Def0047 +S A$_strcspn$101 Def003E +S A$_strcspn$120 Def0054 +S A$_strcspn$111 Def0049 +S A$_strcspn$102 Def0040 +S A$_strcspn$112 Def004A +S A$_strcspn$103 Def0042 +S A$_strcspn$113 Def004D +S A$_strcspn$104 Def0043 +S A$_strcspn$105 Def0044 +S A$_strcspn$124 Def0057 +S _strcspn Def0000 +S A$_strcspn$116 Def004F +S A$_strcspn$107 Def0045 +S A$_strcspn$119 Def0051 +S XG$strcspn$0$0 Def0057 +S C$_strcspn.c$43$1$1 Def0057 +S A$_strcspn$80 Def001A +S A$_strcspn$71 Def0009 +S A$_strcspn$90 Def0027 +S A$_strcspn$81 Def001D +S A$_strcspn$72 Def000B +S A$_strcspn$91 Def0029 +S A$_strcspn$73 Def000D +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 85 82 00 03 85 83 00 04 85 F0 00 05 AD +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 00 0A 00 00 AE 00 01 AF 00 02 E4 F5 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 11 00 07 F5 00 06 +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 00 14 +R 00 00 00 07 +T 00 14 85 00 03 82 85 00 04 83 85 00 05 F0 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 1E 00 00 F8 88 01 60 2C +R 00 00 00 07 02 02 00 02 +T 00 25 +R 00 00 00 07 +T 00 25 89 00 00 C0 05 C0 06 C0 07 8D 82 8E 83 8F +R 00 00 00 07 2B 03 00 00 +T 00 32 F0 12 00 00 A8 82 A9 83 AA F0 D0 07 D0 06 +R 00 00 00 07 02 04 00 01 +T 00 40 D0 05 E8 49 4A 70 0A +R 00 00 00 07 +T 00 47 +R 00 00 00 07 +T 00 47 05 00 06 E4 B5 00 06 02 05 00 07 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 4F +R 00 00 00 07 +T 00 4F 80 C3 +R 00 00 00 07 +T 00 51 +R 00 00 00 07 +T 00 51 85 00 06 82 85 00 07 83 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 00 57 +R 00 00 00 07 +T 00 57 22 +R 00 00 00 07 diff --git a/device/lib/small/_strlen.asm b/device/lib/small/_strlen.asm new file mode 100644 index 00000000..3c4c808b --- /dev/null +++ b/device/lib/small/_strlen.asm @@ -0,0 +1,96 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strlen +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strlen +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strlen$0$0 ==. +; _strlen.c 27 +; ----------------------------------------- +; function strlen +; ----------------------------------------- +_strlen: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strlen.c 34 + mov r2,dpl + mov r3,dph + mov r4,b +; _strlen.c 31 + mov r5,#0x00 + mov r6,#0x00 +00101$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + inc r2 + cjne r2,#0x00,00108$ + inc r3 +00108$: + lcall __gptrget +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _strlen.c 32 + inc r5 + cjne r5,#0x00,00110$ + inc r6 +00110$: +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _strlen.c 34 + mov dpl,r5 + mov dph,r6 +00104$: + C$_strlen.c$35$1$1 ==. + XG$strlen$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strlen.cdb b/device/lib/small/_strlen.cdb new file mode 100644 index 00000000..a17ea6a4 --- /dev/null +++ b/device/lib/small/_strlen.cdb @@ -0,0 +1,2 @@ +M:_strlen +F:G$strlen$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strlen.rel b/device/lib/small/_strlen.rel new file mode 100644 index 00000000..6659d903 --- /dev/null +++ b/device/lib/small/_strlen.rel @@ -0,0 +1,67 @@ +;!FILE _strlen.asm +XH +H 9 areas 1A global symbols +M _strlen +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 27 flags 20 +S XG$strlen$0$0 Def0026 +S C$_strlen.c$35$1$1 Def0026 +S A$_strlen$70 Def000E +S A$_strlen$61 Def0000 +S A$_strlen$71 Def0010 +S A$_strlen$62 Def0002 +S A$_strlen$90 Def0022 +S A$_strlen$72 Def0011 +S A$_strlen$63 Def0004 +S A$_strlen$91 Def0024 +S A$_strlen$82 Def001B +S A$_strlen$73 Def0014 +S A$_strlen$83 Def001C +S A$_strlen$65 Def0006 +S G$strlen$0$0 Def0000 +S A$_strlen$84 Def001F +S A$_strlen$75 Def0015 +S A$_strlen$66 Def0008 +S A$_strlen$95 Def0026 +S A$_strlen$77 Def0018 +S A$_strlen$68 Def000A +S A$_strlen$87 Def0020 +S A$_strlen$69 Def000C +S A$_strlen$79 Def0019 +S _strlen Def0000 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 7D 00 7E 00 +R 00 00 00 08 +T 00 0A +R 00 00 00 08 +T 00 0A 8A 82 8B 83 8C F0 0A BA 00 01 0B +R 00 00 00 08 +T 00 15 +R 00 00 00 08 +T 00 15 12 00 00 FF 60 07 +R 00 00 00 08 02 03 00 00 +T 00 1B +R 00 00 00 08 +T 00 1B 0D BD 00 01 0E +R 00 00 00 08 +T 00 20 +R 00 00 00 08 +T 00 20 80 E8 +R 00 00 00 08 +T 00 22 +R 00 00 00 08 +T 00 22 8D 82 8E 83 +R 00 00 00 08 +T 00 26 +R 00 00 00 08 +T 00 26 22 +R 00 00 00 08 diff --git a/device/lib/small/_strncat.asm b/device/lib/small/_strncat.asm new file mode 100644 index 00000000..33209e96 --- /dev/null +++ b/device/lib/small/_strncat.asm @@ -0,0 +1,173 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strncat +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strncat_PARM_3 + .globl _strncat_PARM_2 + .globl _strncat +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strncat_PARM_2: + .ds 0x0003 +_strncat_PARM_3: + .ds 0x0002 +_strncat_front_1_1: + .ds 0x0003 +_strncat_start_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strncat$0$0 ==. +; _strncat.c 27 +; ----------------------------------------- +; function strncat +; ----------------------------------------- +_strncat: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strncat.c 44 + mov _strncat_front_1_1,dpl + mov (_strncat_front_1_1 + 1),dph + mov (_strncat_front_1_1 + 2),b +; _strncat.c 33 + mov _strncat_start_1_1,_strncat_front_1_1 + mov (_strncat_start_1_1 + 1),(_strncat_front_1_1 + 1) + mov (_strncat_start_1_1 + 2),(_strncat_front_1_1 + 2) +; _strncat.c 35 + mov r0,_strncat_front_1_1 + mov r1,(_strncat_front_1_1 + 1) + mov r5,(_strncat_front_1_1 + 2) +00101$: + mov dpl,r0 + mov dph,r1 + mov b,r5 + inc r0 + cjne r0,#0x00,00116$ + inc r1 +00116$: + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00101$ +00117$: +; _strncat.c 37 + mov a,r0 + add a,#0xff + mov _strncat_front_1_1,a + mov a,r1 + addc a,#0xff + mov (_strncat_front_1_1 + 1),a + mov (_strncat_front_1_1 + 2),r5 +; _strncat.c 39 + mov r5,_strncat_front_1_1 + mov r6,(_strncat_front_1_1 + 1) + mov r7,(_strncat_front_1_1 + 2) +00106$: + mov r2,_strncat_PARM_3 + mov r0,(_strncat_PARM_3 + 1) + dec _strncat_PARM_3 + mov a,#0xff + cjne a,_strncat_PARM_3,00118$ + dec (_strncat_PARM_3 + 1) +00118$: + mov a,r2 + orl a,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00119$: +; _strncat.c 40 + mov ar2,r5 + mov ar0,r6 + mov ar1,r7 + inc r5 + cjne r5,#0x00,00120$ + inc r6 +00120$: + mov _strncat_front_1_1,r5 + mov (_strncat_front_1_1 + 1),r6 + mov (_strncat_front_1_1 + 2),r7 + mov dpl,_strncat_PARM_2 + mov dph,(_strncat_PARM_2 + 1) + mov b,(_strncat_PARM_2 + 2) + inc _strncat_PARM_2 + clr a + cjne a,_strncat_PARM_2,00121$ + inc (_strncat_PARM_2 + 1) +00121$: + lcall __gptrget +; Peephole 190 removed redundant mov +; Peephole 191 removed redundant mov + mov r3,a + mov dpl,r2 + mov dph,r0 + mov b,r1 + lcall __gptrput +; Peephole 109 removed ljmp by inverse jump logic + jnz 00106$ +00122$: +; _strncat.c 41 + mov dpl,_strncat_start_1_1 + mov dph,(_strncat_start_1_1 + 1) + mov b,(_strncat_start_1_1 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: +; _strncat.c 43 + mov dpl,_strncat_front_1_1 + mov dph,(_strncat_front_1_1 + 1) + mov b,(_strncat_front_1_1 + 2) +; Peephole 180 changed mov to clr + clr a + lcall __gptrput +; _strncat.c 44 + mov dpl,_strncat_start_1_1 + mov dph,(_strncat_start_1_1 + 1) + mov b,(_strncat_start_1_1 + 2) +00109$: + C$_strncat.c$45$1$1 ==. + XG$strncat$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strncat.cdb b/device/lib/small/_strncat.cdb new file mode 100644 index 00000000..32daeafd --- /dev/null +++ b/device/lib/small/_strncat.cdb @@ -0,0 +1,2 @@ +M:_strncat +F:G$strncat$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strncat.rel b/device/lib/small/_strncat.rel new file mode 100644 index 00000000..718de4f2 --- /dev/null +++ b/device/lib/small/_strncat.rel @@ -0,0 +1,180 @@ +;!FILE _strncat.asm +XH +H 9 areas 51 global symbols +M _strncat +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size B flags 4 +S _strncat_PARM_2 Def0000 +S _strncat_PARM_3 Def0003 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 9F flags 20 +S A$_strncat$100 Def002E +S A$_strncat$110 Def003D +S A$_strncat$101 Def002F +S A$_strncat$111 Def003F +S A$_strncat$102 Def0031 +S A$_strncat$130 Def0059 +S A$_strncat$112 Def0041 +S A$_strncat$103 Def0033 +S A$_strncat$140 Def006E +S A$_strncat$131 Def005B +S A$_strncat$122 Def004C +S A$_strncat$113 Def0043 +S A$_strncat$132 Def005D +S A$_strncat$123 Def004E +S A$_strncat$114 Def0046 +S A$_strncat$105 Def0035 +S A$_strncat$160 Def008B +S A$_strncat$133 Def0060 +S A$_strncat$124 Def0050 +S A$_strncat$106 Def0037 +S _strncat Def0000 +S A$_strncat$161 Def008E +S A$_strncat$152 Def007D +S A$_strncat$143 Def0071 +S A$_strncat$134 Def0063 +S A$_strncat$125 Def0052 +S A$_strncat$116 Def0048 +S A$_strncat$107 Def0039 +S A$_strncat$153 Def0080 +S A$_strncat$144 Def0072 +S A$_strncat$135 Def0066 +S A$_strncat$126 Def0053 +S A$_strncat$117 Def0049 +S A$_strncat$172 Def009E +S A$_strncat$163 Def0091 +S A$_strncat$154 Def0083 +S A$_strncat$145 Def0074 +S A$_strncat$136 Def0068 +S A$_strncat$127 Def0056 +S A$_strncat$109 Def003B +S A$_strncat$164 Def0092 +S A$_strncat$146 Def0076 +S A$_strncat$137 Def0069 +S A$_strncat$119 Def004A +S A$_strncat$156 Def0086 +S A$_strncat$147 Def0078 +S A$_strncat$138 Def006C +S A$_strncat$129 Def0057 +S A$_strncat$166 Def0095 +S A$_strncat$167 Def0098 +S A$_strncat$149 Def007B +S A$_strncat$168 Def009B +S A$_strncat$159 Def0088 +S XG$strncat$0$0 Def009E +S C$_strncat.c$45$1$1 Def009E +S A$_strncat$80 Def0014 +S A$_strncat$71 Def0000 +S A$_strncat$90 Def0023 +S A$_strncat$81 Def0016 +S A$_strncat$72 Def0003 +S A$_strncat$73 Def0006 +S A$_strncat$92 Def0026 +S A$_strncat$83 Def0018 +S G$strncat$0$0 Def0000 +S A$_strncat$84 Def001A +S A$_strncat$75 Def0009 +S A$_strncat$94 Def0027 +S A$_strncat$85 Def001C +S A$_strncat$76 Def000C +S A$_strncat$86 Def001E +S A$_strncat$77 Def000F +S A$_strncat$87 Def001F +S A$_strncat$97 Def0029 +S A$_strncat$88 Def0022 +S A$_strncat$79 Def0012 +S A$_strncat$98 Def002A +S A$_strncat$99 Def002C +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 85 82 00 05 85 83 00 06 85 F0 00 07 85 +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0C 00 03 +T 00 0A 00 05 00 08 85 00 06 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 0E 00 09 85 00 07 00 0A A8 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 13 00 05 A9 00 06 AD 00 07 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 18 +R 00 00 00 08 +T 00 18 88 82 89 83 8D F0 08 B8 00 01 09 +R 00 00 00 08 +T 00 23 +R 00 00 00 08 +T 00 23 12 00 00 FE 70 EF +R 00 00 00 08 02 03 00 01 +T 00 29 +R 00 00 00 08 +T 00 29 E8 24 FF F5 00 05 E9 34 FF F5 00 06 8D +R 00 00 00 08 29 06 00 03 29 0C 00 03 +T 00 34 00 07 AD 00 05 AE 00 06 AF +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 3A 00 07 +R 00 00 00 08 29 02 00 03 +T 00 3B +R 00 00 00 08 +T 00 3B AA 00 03 A8 00 04 15 00 03 74 FF B5 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 44 00 03 02 15 00 04 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 48 +R 00 00 00 08 +T 00 48 EA 48 60 3C +R 00 00 00 08 +T 00 4C +R 00 00 00 08 +T 00 4C 8D 02 8E 00 8F 01 0D BD 00 01 0E +R 00 00 00 08 +T 00 57 +R 00 00 00 08 +T 00 57 8D 00 05 8E 00 06 8F 00 07 85 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 5E 00 00 82 85 00 01 83 85 00 02 F0 05 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 67 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 6E +R 00 00 00 08 +T 00 6E 12 00 00 FB 8A 82 88 83 89 F0 12 00 00 70 +R 00 00 00 08 02 03 00 01 02 0D 00 00 +T 00 7C BE +R 00 00 00 08 +T 00 7D +R 00 00 00 08 +T 00 7D 85 00 08 82 85 00 09 83 85 00 0A F0 80 16 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 88 +R 00 00 00 08 +T 00 88 85 00 05 82 85 00 06 83 85 00 07 F0 E4 12 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 93 00 00 85 00 08 82 85 00 09 83 85 +R 00 00 00 08 02 02 00 00 29 05 00 03 29 09 00 03 +T 00 9C 00 0A F0 +R 00 00 00 08 29 02 00 03 +T 00 9E +R 00 00 00 08 +T 00 9E 22 +R 00 00 00 08 diff --git a/device/lib/small/_strncmp.asm b/device/lib/small/_strncmp.asm new file mode 100644 index 00000000..ac14415b --- /dev/null +++ b/device/lib/small/_strncmp.asm @@ -0,0 +1,156 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strncmp +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strncmp_PARM_3 + .globl _strncmp_PARM_2 + .globl _strncmp +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strncmp_PARM_2: + .ds 0x0003 +_strncmp_PARM_3: + .ds 0x0002 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strncmp$0$0 ==. +; _strncmp.c 27 +; ----------------------------------------- +; function strncmp +; ----------------------------------------- +_strncmp: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strncmp.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _strncmp.c 33 + mov a,_strncmp_PARM_3 + orl a,(_strncmp_PARM_3 + 1) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00114$ +00115$: +; _strncmp.c 34 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00108$ +; _strncmp.c 36 +00114$: + mov r5,_strncmp_PARM_2 + mov r6,(_strncmp_PARM_2 + 1) + mov r7,(_strncmp_PARM_2 + 2) +00105$: + mov a,_strncmp_PARM_3 + add a,#0xff + mov r0,a + mov a,(_strncmp_PARM_3 + 1) + addc a,#0xff + mov r1,a + mov _strncmp_PARM_3,r0 + mov (_strncmp_PARM_3 + 1),r1 + mov a,r0 + orl a,r1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00116$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00117$: + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r1,a + mov a,r0 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar1,00107$ +; Peephole 201 removed redundant sjmp +00118$: +00119$: +; _strncmp.c 37 + inc r2 + cjne r2,#0x00,00120$ + inc r3 +00120$: +; _strncmp.c 38 + inc r5 + cjne r5,#0x00,00121$ + inc r6 +00121$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _strncmp.c 41 + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r5,a + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 106 removed redundant mov + mov r2,a + clr c + subb a,r5 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + subb a,#0x00 + mov dph,a +00108$: + C$_strncmp.c$42$1$1 ==. + XG$strncmp$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strncmp.cdb b/device/lib/small/_strncmp.cdb new file mode 100644 index 00000000..2464f2c8 --- /dev/null +++ b/device/lib/small/_strncmp.cdb @@ -0,0 +1,2 @@ +M:_strncmp +F:G$strncmp$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strncmp.rel b/device/lib/small/_strncmp.rel new file mode 100644 index 00000000..99723fb9 --- /dev/null +++ b/device/lib/small/_strncmp.rel @@ -0,0 +1,139 @@ +;!FILE _strncmp.asm +XH +H 9 areas 42 global symbols +M _strncmp +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 5 flags 4 +S _strncmp_PARM_2 Def0000 +S _strncmp_PARM_3 Def0003 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 6E flags 20 +S A$_strncmp$89 Def001D +S A$_strncmp$99 Def002A +S A$_strncmp$100 Def002C +S A$_strncmp$110 Def003A +S A$_strncmp$101 Def002E +S A$_strncmp$111 Def003C +S A$_strncmp$102 Def0030 +S A$_strncmp$121 Def0044 +S A$_strncmp$112 Def003F +S A$_strncmp$140 Def005C +S A$_strncmp$131 Def004E +S A$_strncmp$122 Def0045 +S A$_strncmp$113 Def0040 +S A$_strncmp$104 Def0033 +S A$_strncmp$150 Def0069 +S A$_strncmp$141 Def005E +S A$_strncmp$123 Def0048 +S A$_strncmp$151 Def006B +S A$_strncmp$142 Def0060 +S A$_strncmp$106 Def0034 +S _strncmp Def0000 +S A$_strncmp$134 Def0050 +S A$_strncmp$116 Def0041 +S A$_strncmp$144 Def0063 +S A$_strncmp$135 Def0052 +S A$_strncmp$126 Def0049 +S A$_strncmp$108 Def0036 +S A$_strncmp$145 Def0064 +S A$_strncmp$136 Def0054 +S A$_strncmp$127 Def004A +S A$_strncmp$109 Def0038 +S A$_strncmp$155 Def006D +S A$_strncmp$146 Def0065 +S A$_strncmp$137 Def0056 +S A$_strncmp$128 Def004D +S A$_strncmp$147 Def0066 +S A$_strncmp$138 Def0059 +S A$_strncmp$139 Def005A +S A$_strncmp$149 Def0068 +S XG$strncmp$0$0 Def006D +S C$_strncmp.c$42$1$1 Def006D +S A$_strncmp$71 Def0006 +S A$_strncmp$90 Def001F +S A$_strncmp$72 Def0008 +S A$_strncmp$91 Def0021 +S A$_strncmp$82 Def0012 +S A$_strncmp$92 Def0022 +S A$_strncmp$83 Def0014 +S A$_strncmp$74 Def000A +S G$strncmp$0$0 Def0000 +S A$_strncmp$93 Def0024 +S A$_strncmp$84 Def0016 +S A$_strncmp$94 Def0026 +S A$_strncmp$67 Def0000 +S A$_strncmp$95 Def0027 +S A$_strncmp$86 Def0018 +S A$_strncmp$68 Def0002 +S A$_strncmp$87 Def001A +S A$_strncmp$78 Def000C +S A$_strncmp$69 Def0004 +S A$_strncmp$97 Def0028 +S A$_strncmp$88 Def001C +S A$_strncmp$79 Def000F +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 E5 00 03 45 00 04 70 06 +R 00 00 00 08 29 09 00 03 29 0C 00 03 +T 00 0C +R 00 00 00 08 +T 00 0C 90 00 00 02 00 6D +R 00 00 00 08 00 06 00 08 +T 00 12 +R 00 00 00 08 +T 00 12 AD 00 00 AE 00 01 AF 00 02 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 18 +R 00 00 00 08 +T 00 18 E5 00 03 24 FF F8 E5 00 04 34 FF F9 88 +R 00 00 00 08 29 03 00 03 29 09 00 03 +T 00 23 00 03 89 00 04 E8 49 60 26 +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 2A +R 00 00 00 08 +T 00 2A 8A 82 8B 83 8C F0 12 00 00 F8 60 1A +R 00 00 00 08 02 09 00 00 +T 00 36 +R 00 00 00 08 +T 00 36 8D 82 8E 83 8F F0 12 00 00 F9 E8 B5 01 0C +R 00 00 00 08 02 09 00 00 +T 00 44 +R 00 00 00 08 +T 00 44 +R 00 00 00 08 +T 00 44 0A BA 00 01 0B +R 00 00 00 08 +T 00 49 +R 00 00 00 08 +T 00 49 0D BD 00 01 0E +R 00 00 00 08 +T 00 4E +R 00 00 00 08 +T 00 4E 80 C8 +R 00 00 00 08 +T 00 50 +R 00 00 00 08 +T 00 50 8D 82 8E 83 8F F0 12 00 00 FD 8A 82 8B 83 +R 00 00 00 08 02 09 00 00 +T 00 5E 8C F0 12 00 00 FA C3 9D F5 82 E4 94 00 F5 +R 00 00 00 08 02 05 00 00 +T 00 6C 83 +R 00 00 00 08 +T 00 6D +R 00 00 00 08 +T 00 6D 22 +R 00 00 00 08 diff --git a/device/lib/small/_strncpy.asm b/device/lib/small/_strncpy.asm new file mode 100644 index 00000000..868c2ece --- /dev/null +++ b/device/lib/small/_strncpy.asm @@ -0,0 +1,124 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strncpy +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strncpy_PARM_3 + .globl _strncpy_PARM_2 + .globl _strncpy +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strncpy_PARM_2: + .ds 0x0003 +_strncpy_PARM_3: + .ds 0x0002 +_strncpy_d1_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strncpy$0$0 ==. +; _strncpy.c 27 +; ----------------------------------------- +; function strncpy +; ----------------------------------------- +_strncpy: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strncpy.c 36 + mov r2,dpl + mov r3,dph + mov r4,b +; _strncpy.c 32 + mov _strncpy_d1_1_1,r2 + mov (_strncpy_d1_1_1 + 1),r3 + mov (_strncpy_d1_1_1 + 2),r4 +; _strncpy.c 34 +00101$: + mov r5,_strncpy_PARM_3 + mov r0,(_strncpy_PARM_3 + 1) + dec _strncpy_PARM_3 + mov a,#0xff + cjne a,_strncpy_PARM_3,00108$ + dec (_strncpy_PARM_3 + 1) +00108$: + mov a,r5 + orl a,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00109$: +; _strncpy.c 35 + mov ar5,r2 + mov ar0,r3 + mov ar1,r4 + inc r2 + cjne r2,#0x00,00110$ + inc r3 +00110$: + mov dpl,_strncpy_PARM_2 + mov dph,(_strncpy_PARM_2 + 1) + mov b,(_strncpy_PARM_2 + 2) + inc _strncpy_PARM_2 + clr a + cjne a,_strncpy_PARM_2,00111$ + inc (_strncpy_PARM_2 + 1) +00111$: + lcall __gptrget +; Peephole 191 removed redundant mov + mov r6,a + mov dpl,r5 + mov dph,r0 + mov b,r1 + lcall __gptrput +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; _strncpy.c 36 + mov dpl,_strncpy_d1_1_1 + mov dph,(_strncpy_d1_1_1 + 1) + mov b,(_strncpy_d1_1_1 + 2) +00104$: + C$_strncpy.c$37$1$1 ==. + XG$strncpy$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strncpy.cdb b/device/lib/small/_strncpy.cdb new file mode 100644 index 00000000..c2c28153 --- /dev/null +++ b/device/lib/small/_strncpy.cdb @@ -0,0 +1,2 @@ +M:_strncpy +F:G$strncpy$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strncpy.rel b/device/lib/small/_strncpy.rel new file mode 100644 index 00000000..df611d8d --- /dev/null +++ b/device/lib/small/_strncpy.rel @@ -0,0 +1,112 @@ +;!FILE _strncpy.asm +XH +H 9 areas 2F global symbols +M _strncpy +S __gptrput Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 8 flags 4 +S _strncpy_PARM_2 Def0000 +S _strncpy_PARM_3 Def0003 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 52 flags 20 +S A$_strncpy$70 Def0002 +S C$_strncpy.c$37$1$1 Def0051 +S A$_strncpy$80 Def0010 +S A$_strncpy$71 Def0004 +S A$_strncpy$81 Def0012 +S A$_strncpy$91 Def001D +S A$_strncpy$82 Def0014 +S A$_strncpy$73 Def0006 +S A$_strncpy$92 Def001F +S A$_strncpy$83 Def0017 +S A$_strncpy$74 Def0008 +S G$strncpy$0$0 Def0000 +S A$_strncpy$93 Def0021 +S A$_strncpy$75 Def000A +S A$_strncpy$94 Def0023 +S A$_strncpy$85 Def0019 +S A$_strncpy$95 Def0024 +S A$_strncpy$86 Def001A +S A$_strncpy$96 Def0027 +S A$_strncpy$78 Def000C +S A$_strncpy$69 Def0000 +S A$_strncpy$88 Def001B +S A$_strncpy$79 Def000E +S A$_strncpy$98 Def0028 +S A$_strncpy$99 Def002B +S A$_strncpy$100 Def002E +S A$_strncpy$110 Def003F +S A$_strncpy$101 Def0031 +S A$_strncpy$111 Def0041 +S A$_strncpy$102 Def0033 +S A$_strncpy$112 Def0043 +S A$_strncpy$103 Def0034 +S A$_strncpy$104 Def0037 +S A$_strncpy$123 Def0051 +S A$_strncpy$114 Def0046 +S A$_strncpy$106 Def0039 +S _strncpy Def0000 +S A$_strncpy$117 Def0048 +S A$_strncpy$108 Def003C +S A$_strncpy$118 Def004B +S A$_strncpy$109 Def003D +S A$_strncpy$119 Def004E +S XG$strncpy$0$0 Def0051 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 05 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 8A 00 05 8B 00 06 8C +R 00 00 00 08 29 09 00 03 29 0C 00 03 +T 00 0B 00 07 +R 00 00 00 08 29 02 00 03 +T 00 0C +R 00 00 00 08 +T 00 0C AD 00 03 A8 00 04 15 00 03 74 FF B5 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 15 00 03 02 15 00 04 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 19 +R 00 00 00 08 +T 00 19 ED 48 60 2B +R 00 00 00 08 +T 00 1D +R 00 00 00 08 +T 00 1D 8A 05 8B 00 8C 01 0A BA 00 01 0B +R 00 00 00 08 +T 00 28 +R 00 00 00 08 +T 00 28 85 00 00 82 85 00 01 83 85 00 02 F0 05 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 32 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 39 +R 00 00 00 08 +T 00 39 12 00 00 FE 8D 82 88 83 89 F0 12 00 00 80 +R 00 00 00 08 02 03 00 01 02 0D 00 00 +T 00 47 C4 +R 00 00 00 08 +T 00 48 +R 00 00 00 08 +T 00 48 85 00 05 82 85 00 06 83 85 00 07 F0 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 51 +R 00 00 00 08 +T 00 51 22 +R 00 00 00 08 diff --git a/device/lib/small/_strpbrk.asm b/device/lib/small/_strpbrk.asm new file mode 100644 index 00000000..a770a6b5 --- /dev/null +++ b/device/lib/small/_strpbrk.asm @@ -0,0 +1,119 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strpbrk +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strpbrk_PARM_2 + .globl _strpbrk +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strpbrk_PARM_2: + .ds 0x0003 +_strpbrk_string_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strpbrk$0$0 ==. +; _strpbrk.c 27 +; ----------------------------------------- +; function strpbrk +; ----------------------------------------- +_strpbrk: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strpbrk.c 0 + mov _strpbrk_string_1_1,dpl + mov (_strpbrk_string_1_1 + 1),dph + mov (_strpbrk_string_1_1 + 2),b +; _strpbrk.c 34 + mov r5,_strpbrk_PARM_2 + mov r6,(_strpbrk_PARM_2 + 1) + mov r7,(_strpbrk_PARM_2 + 2) +00103$: + mov dpl,_strpbrk_string_1_1 + mov dph,(_strpbrk_string_1_1 + 1) + mov b,(_strpbrk_string_1_1 + 2) + lcall __gptrget +; Peephole 166 removed redundant mov + mov r0,a + mov ar1,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00105$ +00111$: +; _strpbrk.c 35 + mov _strchr_PARM_2,r1 + push ar5 + push ar6 + push ar7 + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall _strchr + mov r0,dpl + mov r1,dph + mov r2,b + pop ar7 + pop ar6 + pop ar5 + mov a,r0 + orl a,r1 + orl a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00112$: +; _strpbrk.c 36 + mov dpl,_strpbrk_string_1_1 + mov dph,(_strpbrk_string_1_1 + 1) + mov b,(_strpbrk_string_1_1 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; _strpbrk.c 39 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00106$: + C$_strpbrk.c$40$1$1 ==. + XG$strpbrk$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strpbrk.cdb b/device/lib/small/_strpbrk.cdb new file mode 100644 index 00000000..59c97da3 --- /dev/null +++ b/device/lib/small/_strpbrk.cdb @@ -0,0 +1,2 @@ +M:_strpbrk +F:G$strpbrk$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strpbrk.rel b/device/lib/small/_strpbrk.rel new file mode 100644 index 00000000..fc15e191 --- /dev/null +++ b/device/lib/small/_strpbrk.rel @@ -0,0 +1,98 @@ +;!FILE _strpbrk.asm +XH +H 8 areas 2E global symbols +M _strpbrk +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 6 flags 0 +S _strpbrk_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 54 flags 20 +S A$_strpbrk$97 Def003B +S A$_strpbrk$88 Def0028 +S A$_strpbrk$79 Def001C +S A$_strpbrk$98 Def003D +S A$_strpbrk$89 Def002A +S A$_strpbrk$99 Def003E +S A$_strpbrk$100 Def003F +S A$_strpbrk$102 Def0040 +S A$_strpbrk$113 Def004D +S A$_strpbrk$114 Def0050 +S A$_strpbrk$105 Def0042 +S A$_strpbrk$106 Def0045 +S _strpbrk Def0000 +S A$_strpbrk$107 Def0048 +S A$_strpbrk$118 Def0053 +S A$_strpbrk$109 Def004B +S C$_strpbrk.c$40$1$1 Def0053 +S XG$strpbrk$0$0 Def0053 +S A$_strpbrk$70 Def000B +S A$_strpbrk$71 Def000D +S A$_strpbrk$90 Def002C +S A$_strpbrk$81 Def001E +S A$_strpbrk$91 Def002E +S A$_strpbrk$73 Def000F +S A$_strpbrk$92 Def0031 +S A$_strpbrk$74 Def0012 +S A$_strpbrk$65 Def0000 +S G$strpbrk$0$0 Def0000 +S A$_strpbrk$93 Def0033 +S A$_strpbrk$84 Def0020 +S A$_strpbrk$75 Def0015 +S A$_strpbrk$66 Def0003 +S A$_strpbrk$94 Def0035 +S A$_strpbrk$85 Def0022 +S A$_strpbrk$76 Def0018 +S A$_strpbrk$67 Def0006 +S A$_strpbrk$95 Def0037 +S A$_strpbrk$86 Def0024 +S A$_strpbrk$96 Def0039 +S A$_strpbrk$87 Def0026 +S A$_strpbrk$78 Def001B +S A$_strpbrk$69 Def0009 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 85 82 00 03 85 83 00 04 85 F0 00 05 AD +R 00 00 00 07 29 04 00 01 29 08 00 01 29 0C 00 01 +T 00 0A 00 00 AE 00 01 AF 00 02 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 0F +R 00 00 00 07 +T 00 0F 85 00 03 82 85 00 04 83 85 00 05 F0 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 19 00 00 F8 88 01 60 2D +R 00 00 00 07 02 02 00 02 +T 00 20 +R 00 00 00 07 +T 00 20 89 00 00 C0 05 C0 06 C0 07 8D 82 8E 83 8F +R 00 00 00 07 2B 03 00 00 +T 00 2D F0 12 00 00 A8 82 A9 83 AA F0 D0 07 D0 06 +R 00 00 00 07 02 04 00 01 +T 00 3B D0 05 E8 49 4A 60 CD +R 00 00 00 07 +T 00 42 +R 00 00 00 07 +T 00 42 85 00 03 82 85 00 04 83 85 00 05 F0 80 06 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 4D +R 00 00 00 07 +T 00 4D 90 00 00 75 F0 00 +R 00 00 00 07 +T 00 53 +R 00 00 00 07 +T 00 53 22 +R 00 00 00 07 diff --git a/device/lib/small/_strrchr.asm b/device/lib/small/_strrchr.asm new file mode 100644 index 00000000..bbcc25a4 --- /dev/null +++ b/device/lib/small/_strrchr.asm @@ -0,0 +1,142 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:16 2000 + +;-------------------------------------------------------- + .module _strrchr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strrchr_PARM_2 + .globl _strrchr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strrchr_PARM_2: + .ds 0x0001 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strrchr$0$0 ==. +; _strrchr.c 27 +; ----------------------------------------- +; function strrchr +; ----------------------------------------- +_strrchr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strrchr.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _strrchr.c 32 + mov ar5,r2 + mov ar6,r3 + mov ar7,r4 +; _strrchr.c 34 +00101$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + inc r2 + cjne r2,#0x00,00116$ + inc r3 +00116$: + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00101$ +00117$: +; _strrchr.c 37 +00105$: + dec r2 + cjne r2,#0xff,00118$ + dec r3 +00118$: + mov a,r2 + cjne a,ar5,00119$ + mov a,r3 + cjne a,ar6,00119$ + mov a,r4 + cjne a,ar7,00119$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00119$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,_strrchr_PARM_2,00105$ +; Peephole 201 removed redundant sjmp +00120$: +00121$: +00107$: +; _strrchr.c 40 + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r5,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,_strrchr_PARM_2,00109$ +; Peephole 201 removed redundant sjmp +00122$: +00123$: +; _strrchr.c 41 + mov dpl,r2 + mov dph,r3 + mov b,r4 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00109$: +; _strrchr.c 43 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00110$: + C$_strrchr.c$44$1$1 ==. + XG$strrchr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strrchr.cdb b/device/lib/small/_strrchr.cdb new file mode 100644 index 00000000..cc49dc3f --- /dev/null +++ b/device/lib/small/_strrchr.cdb @@ -0,0 +1,2 @@ +M:_strrchr +F:G$strrchr$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strrchr.rel b/device/lib/small/_strrchr.rel new file mode 100644 index 00000000..8ba516ac --- /dev/null +++ b/device/lib/small/_strrchr.rel @@ -0,0 +1,115 @@ +;!FILE _strrchr.asm +XH +H 9 areas 32 global symbols +M _strrchr +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 1 flags 4 +S _strrchr_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 59 flags 20 +S A$_strrchr$97 Def002B +S A$_strrchr$88 Def001D +S A$_strrchr$89 Def001E +S A$_strrchr$99 Def002E +S A$_strrchr$101 Def0030 +S A$_strrchr$120 Def0046 +S A$_strrchr$102 Def0032 +S A$_strrchr$130 Def004E +S A$_strrchr$103 Def0034 +S A$_strrchr$104 Def0036 +S A$_strrchr$141 Def0058 +S A$_strrchr$132 Def0050 +S A$_strrchr$123 Def0047 +S A$_strrchr$115 Def003D +S A$_strrchr$106 Def0039 +S _strrchr Def0000 +S A$_strrchr$116 Def003F +S A$_strrchr$117 Def0041 +S A$_strrchr$136 Def0052 +S A$_strrchr$118 Def0043 +S A$_strrchr$109 Def003A +S A$_strrchr$137 Def0055 +S A$_strrchr$128 Def004A +S A$_strrchr$129 Def004C +S XG$strrchr$0$0 Def0058 +S C$_strrchr.c$44$1$1 Def0058 +S A$_strrchr$70 Def000A +S A$_strrchr$80 Def0017 +S A$_strrchr$90 Def0021 +S A$_strrchr$82 Def001A +S A$_strrchr$73 Def000C +S A$_strrchr$64 Def0000 +S A$_strrchr$92 Def0022 +S A$_strrchr$74 Def000E +S A$_strrchr$65 Def0002 +S G$strrchr$0$0 Def0000 +S A$_strrchr$93 Def0023 +S A$_strrchr$84 Def001B +S A$_strrchr$75 Def0010 +S A$_strrchr$66 Def0004 +S A$_strrchr$94 Def0026 +S A$_strrchr$76 Def0012 +S A$_strrchr$95 Def0027 +S A$_strrchr$77 Def0013 +S A$_strrchr$68 Def0006 +S A$_strrchr$96 Def002A +S A$_strrchr$78 Def0016 +S A$_strrchr$69 Def0008 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 8A 05 8B 06 8C 07 +R 00 00 00 08 +T 00 0C +R 00 00 00 08 +T 00 0C 8A 82 8B 83 8C F0 0A BA 00 01 0B +R 00 00 00 08 +T 00 17 +R 00 00 00 08 +T 00 17 12 00 00 F8 70 EF +R 00 00 00 08 02 03 00 00 +T 00 1D +R 00 00 00 08 +T 00 1D +R 00 00 00 08 +T 00 1D 1A BA FF 01 1B +R 00 00 00 08 +T 00 22 +R 00 00 00 08 +T 00 22 EA B5 05 0A EB B5 06 06 EC B5 07 02 80 0D +R 00 00 00 08 +T 00 30 +R 00 00 00 08 +T 00 30 8A 82 8B 83 8C F0 12 00 00 F8 B5 00 00 E0 +R 00 00 00 08 02 09 00 00 29 0D 00 03 +T 00 3D +R 00 00 00 08 +T 00 3D +R 00 00 00 08 +T 00 3D +R 00 00 00 08 +T 00 3D 8A 82 8B 83 8C F0 12 00 00 FD B5 00 00 08 +R 00 00 00 08 02 09 00 00 29 0D 00 03 +T 00 4A +R 00 00 00 08 +T 00 4A +R 00 00 00 08 +T 00 4A 8A 82 8B 83 8C F0 80 06 +R 00 00 00 08 +T 00 52 +R 00 00 00 08 +T 00 52 90 00 00 75 F0 00 +R 00 00 00 08 +T 00 58 +R 00 00 00 08 +T 00 58 22 +R 00 00 00 08 diff --git a/device/lib/small/_strspn.asm b/device/lib/small/_strspn.asm new file mode 100644 index 00000000..b0df1f4c --- /dev/null +++ b/device/lib/small/_strspn.asm @@ -0,0 +1,134 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:17 2000 + +;-------------------------------------------------------- + .module _strspn +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strspn_PARM_2 + .globl _strspn +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strspn_PARM_2: + .ds 0x0003 +_strspn_string_1_1: + .ds 0x0003 +_strspn_count_1_1: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strspn$0$0 ==. +; _strspn.c 27 +; ----------------------------------------- +; function strspn +; ----------------------------------------- +_strspn: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strspn.c 43 + mov r2,dpl + mov r3,dph + mov r4,b +; _strspn.c 35 + mov r5,_strspn_PARM_2 + mov r6,(_strspn_PARM_2 + 1) + mov r7,(_strspn_PARM_2 + 2) + clr a + mov (_strspn_count_1_1 + 1),a + mov _strspn_count_1_1,a + mov _strspn_string_1_1,r2 + mov (_strspn_string_1_1 + 1),r3 + mov (_strspn_string_1_1 + 2),r4 +00104$: + mov dpl,_strspn_string_1_1 + mov dph,(_strspn_string_1_1 + 1) + mov b,(_strspn_string_1_1 + 2) + lcall __gptrget +; Peephole 166 removed redundant mov + mov r0,a + mov ar1,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00112$: +; _strspn.c 36 + mov _strchr_PARM_2,r1 + push ar5 + push ar6 + push ar7 + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall _strchr + mov r0,dpl + mov r1,dph + mov r2,b + pop ar7 + pop ar6 + pop ar5 + mov a,r0 + orl a,r1 + orl a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00113$: +; _strspn.c 37 + inc _strspn_count_1_1 + clr a + cjne a,_strspn_count_1_1,00114$ + inc (_strspn_count_1_1 + 1) +00114$: +; _strspn.c 40 + inc _strspn_string_1_1 + clr a + cjne a,_strspn_string_1_1,00115$ + inc (_strspn_string_1_1 + 1) +00115$: +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00106$: +; _strspn.c 43 + mov dpl,_strspn_count_1_1 + mov dph,(_strspn_count_1_1 + 1) +00107$: + C$_strspn.c$44$1$1 ==. + XG$strspn$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strspn.cdb b/device/lib/small/_strspn.cdb new file mode 100644 index 00000000..81839f77 --- /dev/null +++ b/device/lib/small/_strspn.cdb @@ -0,0 +1,2 @@ +M:_strspn +F:G$strspn$0$0({2}DF,SI:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strspn.rel b/device/lib/small/_strspn.rel new file mode 100644 index 00000000..548678f1 --- /dev/null +++ b/device/lib/small/_strspn.rel @@ -0,0 +1,123 @@ +;!FILE _strspn.asm +XH +H 8 areas 39 global symbols +M _strspn +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 8 flags 0 +S _strspn_PARM_2 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 63 flags 20 +S A$_strspn$100 Def0039 +S A$_strspn$110 Def0048 +S A$_strspn$101 Def003B +S A$_strspn$120 Def0054 +S A$_strspn$102 Def003D +S A$_strspn$121 Def0055 +S A$_strspn$103 Def003F +S A$_strspn$122 Def0058 +S A$_strspn$113 Def004A +S A$_strspn$104 Def0041 +S A$_strspn$114 Def004C +S A$_strspn$105 Def0043 +S A$_strspn$133 Def0062 +S A$_strspn$115 Def004D +S A$_strspn$106 Def0045 +S _strspn Def0000 +S A$_strspn$125 Def005A +S A$_strspn$116 Def0050 +S A$_strspn$107 Def0046 +S A$_strspn$108 Def0047 +S A$_strspn$128 Def005C +S A$_strspn$119 Def0052 +S A$_strspn$129 Def005F +S XG$strspn$0$0 Def0062 +S C$_strspn.c$44$1$1 Def0062 +S A$_strspn$71 Def0006 +S A$_strspn$81 Def0017 +S A$_strspn$72 Def0008 +S A$_strspn$82 Def001A +S A$_strspn$73 Def000A +S A$_strspn$92 Def0028 +S A$_strspn$83 Def001D +S A$_strspn$74 Def000C +S G$strspn$0$0 Def0000 +S A$_strspn$93 Def002A +S A$_strspn$84 Def0020 +S A$_strspn$75 Def000D +S A$_strspn$94 Def002C +S A$_strspn$76 Def000F +S A$_strspn$67 Def0000 +S A$_strspn$95 Def002E +S A$_strspn$86 Def0023 +S A$_strspn$77 Def0011 +S A$_strspn$68 Def0002 +S A$_strspn$96 Def0030 +S A$_strspn$87 Def0024 +S A$_strspn$78 Def0013 +S A$_strspn$69 Def0004 +S A$_strspn$97 Def0032 +S A$_strspn$79 Def0015 +S A$_strspn$98 Def0034 +S A$_strspn$89 Def0026 +S A$_strspn$99 Def0036 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 AD 00 00 AE 00 01 AF +R 00 00 00 07 29 09 00 01 29 0C 00 01 +T 00 0B 00 02 E4 F5 00 07 F5 00 06 8A +R 00 00 00 07 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 12 00 03 8B 00 04 8C 00 05 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 17 +R 00 00 00 07 +T 00 17 85 00 03 82 85 00 04 83 85 00 05 F0 12 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 21 00 00 F8 88 01 60 34 +R 00 00 00 07 02 02 00 02 +T 00 28 +R 00 00 00 07 +T 00 28 89 00 00 C0 05 C0 06 C0 07 8D 82 8E 83 8F +R 00 00 00 07 2B 03 00 00 +T 00 35 F0 12 00 00 A8 82 A9 83 AA F0 D0 07 D0 06 +R 00 00 00 07 02 04 00 01 +T 00 43 D0 05 E8 49 4A 60 12 +R 00 00 00 07 +T 00 4A +R 00 00 00 07 +T 00 4A 05 00 06 E4 B5 00 06 02 05 00 07 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 52 +R 00 00 00 07 +T 00 52 05 00 03 E4 B5 00 03 02 05 00 04 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 5A +R 00 00 00 07 +T 00 5A 80 BB +R 00 00 00 07 +T 00 5C +R 00 00 00 07 +T 00 5C 85 00 06 82 85 00 07 83 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 00 62 +R 00 00 00 07 +T 00 62 22 +R 00 00 00 07 diff --git a/device/lib/small/_strstr.asm b/device/lib/small/_strstr.asm new file mode 100644 index 00000000..32a33dce --- /dev/null +++ b/device/lib/small/_strstr.asm @@ -0,0 +1,188 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:17 2000 + +;-------------------------------------------------------- + .module _strstr +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strstr_PARM_2 + .globl _strstr +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_strstr_PARM_2: + .ds 0x0003 +_strstr_cp_1_1: + .ds 0x0003 +_strstr_s1_1_1: + .ds 0x0003 +_strstr_s2_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strstr$0$0 ==. +; _strstr.c 27 +; ----------------------------------------- +; function strstr +; ----------------------------------------- +_strstr: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strstr.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _strstr.c 32 + mov _strstr_cp_1_1,r2 + mov (_strstr_cp_1_1 + 1),r3 + mov (_strstr_cp_1_1 + 2),r4 +; _strstr.c 36 + mov _strstr_s2_1_1,_strstr_PARM_2 + mov (_strstr_s2_1_1 + 1),(_strstr_PARM_2 + 1) + mov (_strstr_s2_1_1 + 2),(_strstr_PARM_2 + 2) + mov dpl,_strstr_s2_1_1 + mov dph,(_strstr_s2_1_1 + 1) + mov b,(_strstr_s2_1_1 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00122$ +00123$: +; _strstr.c 37 + mov dpl,r2 + mov dph,r3 + mov b,r4 + ljmp 00113$ +; _strstr.c 39 +00122$: +00110$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a + jnz 00124$ + ljmp 00112$ +00124$: +; _strstr.c 42 +; _strstr.c 44 + mov _strstr_s1_1_1,r2 + mov (_strstr_s1_1_1 + 1),r3 + mov (_strstr_s1_1_1 + 2),r4 + mov r0,_strstr_s2_1_1 + mov r1,(_strstr_s2_1_1 + 1) + mov r5,(_strstr_s2_1_1 + 2) +00105$: + mov dpl,_strstr_s1_1_1 + mov dph,(_strstr_s1_1_1 + 1) + mov b,(_strstr_s1_1_1 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00125$: + mov dpl,r0 + mov dph,r1 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00107$ +00126$: + clr c + mov a,r6 + subb a,r7 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00107$ +00127$: +; _strstr.c 45 + inc _strstr_s1_1_1 + clr a + cjne a,_strstr_s1_1_1,00128$ + inc (_strstr_s1_1_1 + 1) +00128$: + inc r0 + cjne r0,#0x00,00129$ + inc r1 +00129$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _strstr.c 47 + mov dpl,r0 + mov dph,r1 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00109$ +00130$: +; _strstr.c 48 + mov dpl,_strstr_cp_1_1 + mov dph,(_strstr_cp_1_1 + 1) + mov b,(_strstr_cp_1_1 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00109$: +; _strstr.c 50 + inc r2 + cjne r2,#0x00,00131$ + inc r3 +00131$: + mov _strstr_cp_1_1,r2 + mov (_strstr_cp_1_1 + 1),r3 + mov (_strstr_cp_1_1 + 2),r4 + ljmp 00110$ +00112$: +; _strstr.c 53 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00113$: + C$_strstr.c$54$1$1 ==. + XG$strstr$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strstr.cdb b/device/lib/small/_strstr.cdb new file mode 100644 index 00000000..f68b0265 --- /dev/null +++ b/device/lib/small/_strstr.cdb @@ -0,0 +1,2 @@ +M:_strstr +F:G$strstr$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strstr.rel b/device/lib/small/_strstr.rel new file mode 100644 index 00000000..38631ce6 --- /dev/null +++ b/device/lib/small/_strstr.rel @@ -0,0 +1,193 @@ +;!FILE _strstr.asm +XH +H 9 areas 52 global symbols +M _strstr +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +S _strstr_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size A3 flags 20 +S A$_strstr$100 Def0031 +S A$_strstr$110 Def003E +S A$_strstr$101 Def0033 +S A$_strstr$111 Def0040 +S A$_strstr$130 Def0060 +S A$_strstr$121 Def0054 +S A$_strstr$112 Def0042 +S A$_strstr$103 Def0036 +S A$_strstr$113 Def0044 +S A$_strstr$104 Def0037 +S A$_strstr$141 Def0068 +S A$_strstr$132 Def0061 +S A$_strstr$123 Def0055 +S A$_strstr$114 Def0046 +S A$_strstr$105 Def0039 +S A$_strstr$151 Def0075 +S A$_strstr$142 Def006A +S _strstr Def0000 +S A$_strstr$161 Def0081 +S A$_strstr$143 Def006B +S A$_strstr$134 Def0063 +S A$_strstr$125 Def0057 +S A$_strstr$116 Def0048 +S A$_strstr$171 Def008E +S A$_strstr$144 Def006E +S A$_strstr$135 Def0064 +S A$_strstr$126 Def0059 +S A$_strstr$117 Def004B +S A$_strstr$172 Def008F +S A$_strstr$154 Def0077 +S A$_strstr$136 Def0065 +S A$_strstr$127 Def005B +S A$_strstr$118 Def004E +S A$_strstr$109 Def003C +S A$_strstr$182 Def009C +S A$_strstr$173 Def0092 +S A$_strstr$164 Def0083 +S A$_strstr$155 Def0079 +S A$_strstr$146 Def0070 +S A$_strstr$128 Def005D +S A$_strstr$119 Def0051 +S A$_strstr$183 Def009F +S A$_strstr$165 Def0086 +S A$_strstr$156 Def007B +S A$_strstr$147 Def0071 +S A$_strstr$138 Def0066 +S A$_strstr$175 Def0093 +S A$_strstr$166 Def0089 +S A$_strstr$157 Def007D +S A$_strstr$148 Def0074 +S A$_strstr$176 Def0095 +S A$_strstr$177 Def0097 +S A$_strstr$168 Def008C +S A$_strstr$159 Def0080 +S A$_strstr$187 Def00A2 +S A$_strstr$178 Def0099 +S XG$strstr$0$0 Def00A2 +S C$_strstr.c$54$1$1 Def00A2 +S A$_strstr$70 Def0000 +S A$_strstr$80 Def0012 +S A$_strstr$71 Def0002 +S A$_strstr$81 Def0015 +S A$_strstr$72 Def0004 +S A$_strstr$91 Def0024 +S A$_strstr$82 Def0018 +S A$_strstr$92 Def0026 +S A$_strstr$83 Def001B +S A$_strstr$74 Def0006 +S G$strstr$0$0 Def0000 +S A$_strstr$93 Def0028 +S A$_strstr$84 Def001E +S A$_strstr$75 Def0008 +S A$_strstr$94 Def002A +S A$_strstr$76 Def000A +S A$_strstr$86 Def0021 +S A$_strstr$78 Def000C +S A$_strstr$88 Def0022 +S A$_strstr$79 Def000F +S A$_strstr$98 Def002D +S A$_strstr$99 Def002F +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 03 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 06 +R 00 00 00 03 +T 00 09 +R 00 00 00 03 +T 00 09 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 8A 00 03 8B 00 04 8C +R 00 00 00 08 29 09 00 03 29 0C 00 03 +T 00 0B 00 05 85 00 00 00 09 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 07 00 03 +T 00 10 00 01 00 0A 85 00 02 +R 00 00 00 08 29 02 00 03 29 04 00 03 29 07 00 03 +T 00 14 00 0B 85 00 09 82 85 00 0A 83 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 1C 00 0B F0 12 00 00 FE 70 09 +R 00 00 00 08 29 02 00 03 02 06 00 00 +T 00 24 +R 00 00 00 08 +T 00 24 8A 82 8B 83 8C F0 02 00 A2 +R 00 00 00 08 00 09 00 08 +T 00 2D +R 00 00 00 08 +T 00 2D +R 00 00 00 08 +T 00 2D 8A 82 8B 83 8C F0 12 00 00 FE 70 03 02 +R 00 00 00 08 02 09 00 00 +T 00 3A 00 9C +R 00 00 00 08 00 02 00 08 +T 00 3C +R 00 00 00 08 +T 00 3C 8A 00 06 8B 00 07 8C 00 08 A8 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 43 00 09 A9 00 0A AD 00 0B +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 48 +R 00 00 00 08 +T 00 48 85 00 06 82 85 00 07 83 85 00 08 F0 12 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 52 00 00 FE 60 20 +R 00 00 00 08 02 02 00 00 +T 00 57 +R 00 00 00 08 +T 00 57 88 82 89 83 8D F0 12 00 00 FF 60 14 +R 00 00 00 08 02 09 00 00 +T 00 63 +R 00 00 00 08 +T 00 63 C3 EE 9F 70 0F +R 00 00 00 08 +T 00 68 +R 00 00 00 08 +T 00 68 05 00 06 E4 B5 00 06 02 05 00 07 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 70 +R 00 00 00 08 +T 00 70 08 B8 00 01 09 +R 00 00 00 08 +T 00 75 +R 00 00 00 08 +T 00 75 80 D1 +R 00 00 00 08 +T 00 77 +R 00 00 00 08 +T 00 77 88 82 89 83 8D F0 12 00 00 F8 70 0B +R 00 00 00 08 02 09 00 00 +T 00 83 +R 00 00 00 08 +T 00 83 85 00 03 82 85 00 04 83 85 00 05 F0 80 14 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 8E +R 00 00 00 08 +T 00 8E 0A BA 00 01 0B +R 00 00 00 08 +T 00 93 +R 00 00 00 08 +T 00 93 8A 00 03 8B 00 04 8C 00 05 02 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 9A 00 2D +R 00 00 00 08 00 02 00 08 +T 00 9C +R 00 00 00 08 +T 00 9C 90 00 00 75 F0 00 +R 00 00 00 08 +T 00 A2 +R 00 00 00 08 +T 00 A2 22 +R 00 00 00 08 diff --git a/device/lib/small/_strtok.asm b/device/lib/small/_strtok.asm new file mode 100644 index 00000000..0323147a --- /dev/null +++ b/device/lib/small/_strtok.asm @@ -0,0 +1,169 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:17 2000 + +;-------------------------------------------------------- + .module _strtok +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _strtok_PARM_2 + .globl _strtok +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +_strtok_s_1_1: + .ds 0x0003 +_strtok_PARM_2: + .ds 0x0003 +_strtok_s1_1_1: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$strtok$0$0 ==. +; _strtok.c 32 +; ----------------------------------------- +; function strtok +; ----------------------------------------- +_strtok: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _strtok.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; _strtok.c 40 + mov a,r2 + orl a,r3 + orl a,r4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00102$ +00114$: +; _strtok.c 41 + mov _strtok_s_1_1,r2 + mov (_strtok_s_1_1 + 1),r3 + mov (_strtok_s_1_1 + 2),r4 +00102$: +; _strtok.c 43 + mov _strtok_s1_1_1,_strtok_s_1_1 + mov (_strtok_s1_1_1 + 1),(_strtok_s_1_1 + 1) + mov (_strtok_s1_1_1 + 2),(_strtok_s_1_1 + 2) +; _strtok.c 45 + mov r5,_strtok_PARM_2 + mov r6,(_strtok_PARM_2 + 1) + mov r7,(_strtok_PARM_2 + 2) +00105$: + mov r0,_strtok_s_1_1 + mov r1,(_strtok_s_1_1 + 1) + mov r2,(_strtok_s_1_1 + 2) + mov dpl,r0 + mov dph,r1 + mov b,r2 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r0,a + jnz 00115$ + ljmp 00107$ +00115$: +; _strtok.c 46 + mov r3,_strtok_s_1_1 + mov r4,(_strtok_s_1_1 + 1) + mov r0,(_strtok_s_1_1 + 2) + mov dpl,r3 + mov dph,r4 + mov b,r0 + lcall __gptrget + mov _strchr_PARM_2,a + push ar5 + push ar6 + push ar7 + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall _strchr + mov r3,dpl + mov r4,dph + mov r0,b + pop ar7 + pop ar6 + pop ar5 + mov a,r3 + orl a,r4 + orl a,r0 +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00116$: +; _strtok.c 47 + mov r3,_strtok_s_1_1 + mov r4,(_strtok_s_1_1 + 1) + mov r5,(_strtok_s_1_1 + 2) + inc _strtok_s_1_1 + clr a + cjne a,_strtok_s_1_1,00117$ + inc (_strtok_s_1_1 + 1) +00117$: + mov dpl,r3 + mov dph,r4 + mov b,r5 +; Peephole 180 changed mov to clr + clr a + lcall __gptrput +; _strtok.c 48 + mov dpl,_strtok_s1_1_1 + mov dph,(_strtok_s1_1_1 + 1) + mov b,(_strtok_s1_1_1 + 2) +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00104$: +; _strtok.c 50 + inc _strtok_s_1_1 + clr a + cjne a,_strtok_s_1_1,00118$ + inc (_strtok_s_1_1 + 1) +00118$: + ljmp 00105$ +00107$: +; _strtok.c 52 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 +00108$: + C$_strtok.c$53$1$1 ==. + XG$strtok$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_strtok.cdb b/device/lib/small/_strtok.cdb new file mode 100644 index 00000000..5a98130b --- /dev/null +++ b/device/lib/small/_strtok.cdb @@ -0,0 +1,2 @@ +M:_strtok +F:G$strtok$0$0({2}DF,DG,SC:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_strtok.rel b/device/lib/small/_strtok.rel new file mode 100644 index 00000000..7844e634 --- /dev/null +++ b/device/lib/small/_strtok.rel @@ -0,0 +1,168 @@ +;!FILE _strtok.asm +XH +H 8 areas 54 global symbols +M _strtok +S __gptrput Ref0000 +S _strchr_PARM_2 Ref0000 +S _strchr Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 9 flags 0 +S _strtok_PARM_2 Def0003 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 9B flags 20 +S A$_strtok$100 Def0030 +S A$_strtok$110 Def0041 +S A$_strtok$101 Def0032 +S A$_strtok$120 Def0057 +S A$_strtok$111 Def0044 +S A$_strtok$121 Def0059 +S A$_strtok$112 Def0046 +S A$_strtok$140 Def0074 +S A$_strtok$122 Def005B +S A$_strtok$113 Def0048 +S A$_strtok$104 Def0035 +S A$_strtok$141 Def0076 +S A$_strtok$132 Def0066 +S A$_strtok$123 Def005D +S A$_strtok$114 Def004A +S A$_strtok$105 Def0037 +S A$_strtok$151 Def0087 +S A$_strtok$142 Def0078 +S A$_strtok$133 Def0068 +S A$_strtok$124 Def005F +S A$_strtok$115 Def004C +S A$_strtok$106 Def0039 +S _strtok Def0000 +S A$_strtok$134 Def006A +S A$_strtok$125 Def0061 +S A$_strtok$116 Def004E +S A$_strtok$107 Def003B +S A$_strtok$144 Def007A +S A$_strtok$135 Def006C +S A$_strtok$126 Def0062 +S A$_strtok$117 Def0050 +S A$_strtok$108 Def003D +S A$_strtok$163 Def0094 +S A$_strtok$154 Def0089 +S A$_strtok$145 Def007B +S A$_strtok$136 Def006E +S A$_strtok$127 Def0063 +S A$_strtok$118 Def0052 +S A$_strtok$109 Def003F +S A$_strtok$164 Def0097 +S A$_strtok$155 Def008B +S A$_strtok$137 Def006F +S A$_strtok$119 Def0055 +S A$_strtok$156 Def008C +S A$_strtok$147 Def007E +S A$_strtok$138 Def0072 +S A$_strtok$129 Def0064 +S A$_strtok$157 Def008F +S A$_strtok$148 Def0081 +S A$_strtok$149 Def0084 +S A$_strtok$168 Def009A +S A$_strtok$159 Def0091 +S XG$strtok$0$0 Def009A +S C$_strtok.c$53$1$1 Def009A +S A$_strtok$80 Def000F +S A$_strtok$71 Def0006 +S A$_strtok$72 Def0007 +S A$_strtok$91 Def0020 +S A$_strtok$73 Def0008 +S A$_strtok$92 Def0022 +S A$_strtok$83 Def0011 +S G$strtok$0$0 Def0000 +S A$_strtok$93 Def0024 +S A$_strtok$84 Def0014 +S A$_strtok$75 Def0009 +S A$_strtok$94 Def0026 +S A$_strtok$85 Def0017 +S A$_strtok$67 Def0000 +S A$_strtok$95 Def0028 +S A$_strtok$68 Def0002 +S A$_strtok$96 Def002A +S A$_strtok$87 Def001A +S A$_strtok$78 Def000B +S A$_strtok$69 Def0004 +S A$_strtok$97 Def002C +S A$_strtok$88 Def001C +S A$_strtok$79 Def000D +S A$_strtok$89 Def001E +S A$_strtok$99 Def002F +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 06 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 EA 4B 4C 60 06 +R 00 00 00 07 +T 00 0B +R 00 00 00 07 +T 00 0B 8A 00 00 8B 00 01 8C 00 02 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 11 +R 00 00 00 07 +T 00 11 85 00 00 00 06 85 00 01 +R 00 00 00 07 29 03 00 01 29 05 00 01 29 08 00 01 +T 00 16 00 07 85 00 02 00 08 AD +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 00 1B 00 03 AE 00 04 AF 00 05 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 20 +R 00 00 00 07 +T 00 20 A8 00 00 A9 00 01 AA 00 02 88 82 89 83 8A +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 2B F0 12 00 00 F8 70 03 02 00 94 +R 00 00 00 07 02 04 00 03 00 0A 00 07 +T 00 35 +R 00 00 00 07 +T 00 35 AB 00 00 AC 00 01 A8 00 02 8B 82 8C 83 88 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 40 F0 12 00 00 F5 00 00 C0 05 C0 06 C0 07 8D +R 00 00 00 07 02 04 00 03 2B 07 00 01 +T 00 4D 82 8E 83 8F F0 12 00 00 AB 82 AC 83 A8 F0 +R 00 00 00 07 02 08 00 02 +T 00 5B D0 07 D0 06 D0 05 EB 4C 48 60 23 +R 00 00 00 07 +T 00 66 +R 00 00 00 07 +T 00 66 AB 00 00 AC 00 01 AD 00 02 05 +R 00 00 00 07 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 6D 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 74 +R 00 00 00 07 +T 00 74 8B 82 8C 83 8D F0 E4 12 00 00 85 00 06 82 +R 00 00 00 07 02 0A 00 00 29 0D 00 01 +T 00 81 85 00 07 83 85 00 08 F0 80 11 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 00 89 +R 00 00 00 07 +T 00 89 05 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 00 91 +R 00 00 00 07 +T 00 91 02 00 20 +R 00 00 00 07 00 03 00 07 +T 00 94 +R 00 00 00 07 +T 00 94 90 00 00 75 F0 00 +R 00 00 00 07 +T 00 9A +R 00 00 00 07 +T 00 9A 22 +R 00 00 00 07 diff --git a/device/lib/small/_uchar2fs.asm b/device/lib/small/_uchar2fs.asm new file mode 100644 index 00000000..a3ec33c0 --- /dev/null +++ b/device/lib/small/_uchar2fs.asm @@ -0,0 +1,214 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:17 2000 + +;-------------------------------------------------------- + .module _uchar2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___uchar2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___uchar2fs_sign_1_1: + .ds 0x0004 +___uchar2fs_fl_1_1: + .ds 0x0004 +___uchar2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__uchar2fs$0$0 ==. +; _uchar2fs.c 80 +; ----------------------------------------- +; function __uchar2fs +; ----------------------------------------- +___uchar2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _uchar2fs.c 109 + mov r2,dpl +; _uchar2fs.c 82 + clr a + mov (___uchar2fs_sign_1_1 + 3),a + mov (___uchar2fs_sign_1_1 + 2),a + mov (___uchar2fs_sign_1_1 + 1),a + mov ___uchar2fs_sign_1_1,a +; _uchar2fs.c 85 + mov ___uchar2fs_a1_1_1,r2 + mov a,r2 + rlc a + subb a,acc + mov (___uchar2fs_a1_1_1 + 1),a + mov (___uchar2fs_a1_1_1 + 2),a + mov (___uchar2fs_a1_1_1 + 3),a +; _uchar2fs.c 87 + mov a,___uchar2fs_a1_1_1 + orl a,(___uchar2fs_a1_1_1 + 1) + orl a,(___uchar2fs_a1_1_1 + 2) + orl a,(___uchar2fs_a1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _uchar2fs.c 89 + mov ___uchar2fs_fl_1_1,#0x00 + mov (___uchar2fs_fl_1_1 + 1),#0x00 + mov (___uchar2fs_fl_1_1 + 2),#0x00 + mov (___uchar2fs_fl_1_1 + 3),#0x00 +; _uchar2fs.c 90 + mov dpl,___uchar2fs_fl_1_1 + mov dph,(___uchar2fs_fl_1_1 + 1) + mov b,(___uchar2fs_fl_1_1 + 2) + mov a,(___uchar2fs_fl_1_1 + 3) + ljmp 00108$ +00102$: +; _uchar2fs.c 93 + mov a,(___uchar2fs_a1_1_1 + 3) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _uchar2fs.c 95 + mov ___uchar2fs_sign_1_1,#0x00 + mov (___uchar2fs_sign_1_1 + 1),#0x00 + mov (___uchar2fs_sign_1_1 + 2),#0x00 + mov (___uchar2fs_sign_1_1 + 3),#0x80 +; _uchar2fs.c 96 + clr c + clr a + subb a,___uchar2fs_a1_1_1 + mov ___uchar2fs_a1_1_1,a + clr a + subb a,(___uchar2fs_a1_1_1 + 1) + mov (___uchar2fs_a1_1_1 + 1),a + clr a + subb a,(___uchar2fs_a1_1_1 + 2) + mov (___uchar2fs_a1_1_1 + 2),a + clr a + subb a,(___uchar2fs_a1_1_1 + 3) + mov (___uchar2fs_a1_1_1 + 3),a +; _uchar2fs.c 99 +00113$: + mov r3,#0x96 + mov r4,#0x00 +00105$: + clr c + mov a,___uchar2fs_a1_1_1 + subb a,#0x00 + mov a,(___uchar2fs_a1_1_1 + 1) + subb a,#0x00 + mov a,(___uchar2fs_a1_1_1 + 2) + subb a,#0x80 + mov a,(___uchar2fs_a1_1_1 + 3) + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _uchar2fs.c 101 + mov a,___uchar2fs_a1_1_1 + add a,acc + mov ___uchar2fs_a1_1_1,a + mov a,(___uchar2fs_a1_1_1 + 1) + rlc a + mov (___uchar2fs_a1_1_1 + 1),a + mov a,(___uchar2fs_a1_1_1 + 2) + rlc a + mov (___uchar2fs_a1_1_1 + 2),a + mov a,(___uchar2fs_a1_1_1 + 3) + rlc a + mov (___uchar2fs_a1_1_1 + 3),a +; _uchar2fs.c 102 + dec r3 + cjne r3,#0xff,00117$ + dec r4 +00117$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _uchar2fs.c 105 + anl (___uchar2fs_a1_1_1 + 2),#0x7f +; _uchar2fs.c 107 + mov r5,#0x00 + mov r6,#0x00 + mov ar5,r3 + mov a,r4 + anl a,#0x01 + mov c,acc.0 + xch a,r5 + rrc a + xch a,r5 + rrc a + xch a,r5 + mov r6,a + mov r4,#0x00 + mov r3,#0x00 + mov r2,___uchar2fs_sign_1_1 + mov r7,(___uchar2fs_sign_1_1 + 1) + mov r0,(___uchar2fs_sign_1_1 + 2) + mov r1,(___uchar2fs_sign_1_1 + 3) + mov a,r2 + orl ar3,a + mov a,r7 + orl ar4,a + mov a,r0 + orl ar5,a + mov a,r1 + orl ar6,a + mov a,___uchar2fs_a1_1_1 + orl ar3,a + mov a,(___uchar2fs_a1_1_1 + 1) + orl ar4,a + mov a,(___uchar2fs_a1_1_1 + 2) + orl ar5,a + mov a,(___uchar2fs_a1_1_1 + 3) + orl ar6,a + mov ___uchar2fs_fl_1_1,r3 + mov (___uchar2fs_fl_1_1 + 1),r4 + mov (___uchar2fs_fl_1_1 + 2),r5 + mov (___uchar2fs_fl_1_1 + 3),r6 +; _uchar2fs.c 109 + mov dpl,___uchar2fs_fl_1_1 + mov dph,(___uchar2fs_fl_1_1 + 1) + mov b,(___uchar2fs_fl_1_1 + 2) + mov a,(___uchar2fs_fl_1_1 + 3) +00108$: + C$_uchar2fs.c$110$1$1 ==. + XG$__uchar2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_uchar2fs.cdb b/device/lib/small/_uchar2fs.cdb new file mode 100644 index 00000000..093722f2 --- /dev/null +++ b/device/lib/small/_uchar2fs.cdb @@ -0,0 +1,2 @@ +M:_uchar2fs +F:G$__uchar2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_uchar2fs.rel b/device/lib/small/_uchar2fs.rel new file mode 100644 index 00000000..4e5c2208 --- /dev/null +++ b/device/lib/small/_uchar2fs.rel @@ -0,0 +1,223 @@ +;!FILE _uchar2fs.asm +XH +H 9 areas 7A global symbols +M _uchar2fs +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size E4 flags 20 +S A$_uchar2fs$208 Def00DE +S A$_uchar2fs$190 Def00BB +S A$_uchar2fs$181 Def00AC +S A$_uchar2fs$172 Def00A0 +S A$_uchar2fs$154 Def008A +S A$_uchar2fs$145 Def007A +S A$_uchar2fs$136 Def006E +S A$_uchar2fs$118 Def0053 +S A$_uchar2fs$109 Def0043 +S A$_uchar2fs$209 Def00E1 +S A$_uchar2fs$191 Def00BD +S A$_uchar2fs$182 Def00AE +S A$_uchar2fs$173 Def00A2 +S A$_uchar2fs$155 Def008B +S A$_uchar2fs$146 Def007C +S A$_uchar2fs$137 Def0070 +S A$_uchar2fs$128 Def0061 +S A$_uchar2fs$119 Def0055 +S A$_uchar2fs$192 Def00BE +S A$_uchar2fs$183 Def00B0 +S A$_uchar2fs$174 Def00A3 +S A$_uchar2fs$165 Def0094 +S A$_uchar2fs$147 Def007E +S A$_uchar2fs$138 Def0072 +S A$_uchar2fs$129 Def0063 +S A$_uchar2fs$193 Def00C0 +S A$_uchar2fs$184 Def00B2 +S A$_uchar2fs$175 Def00A4 +S A$_uchar2fs$157 Def008D +S A$_uchar2fs$148 Def0080 +S A$_uchar2fs$139 Def0074 +S A$_uchar2fs$194 Def00C2 +S A$_uchar2fs$185 Def00B4 +S A$_uchar2fs$176 Def00A5 +S A$_uchar2fs$167 Def0097 +S A$_uchar2fs$158 Def008E +S A$_uchar2fs$149 Def0081 +S A$_uchar2fs$195 Def00C4 +S A$_uchar2fs$186 Def00B5 +S A$_uchar2fs$177 Def00A6 +S A$_uchar2fs$168 Def0099 +S A$_uchar2fs$159 Def0091 +S A$_uchar2fs$196 Def00C6 +S A$_uchar2fs$187 Def00B7 +S A$_uchar2fs$178 Def00A7 +S A$_uchar2fs$169 Def009B +S A$_uchar2fs$197 Def00C8 +S A$_uchar2fs$188 Def00B8 +S A$_uchar2fs$179 Def00A8 +S XG$__uchar2fs$0$0 Def00E3 +S A$_uchar2fs$198 Def00CA +S A$_uchar2fs$189 Def00BA +S A$_uchar2fs$199 Def00CC +S A$_uchar2fs$70 Def0003 +S A$_uchar2fs$80 Def0013 +S A$_uchar2fs$71 Def0005 +S A$_uchar2fs$81 Def0015 +S A$_uchar2fs$72 Def0007 +S G$__uchar2fs$0$0 Def0000 +S A$_uchar2fs$91 Def0021 +S A$_uchar2fs$73 Def0009 +S A$_uchar2fs$92 Def0024 +S A$_uchar2fs$83 Def0017 +S A$_uchar2fs$93 Def0027 +S A$_uchar2fs$84 Def0019 +S A$_uchar2fs$75 Def000B +S A$_uchar2fs$94 Def002A +S A$_uchar2fs$85 Def001B +S A$_uchar2fs$76 Def000D +S A$_uchar2fs$67 Def0000 +S A$_uchar2fs$86 Def001D +S A$_uchar2fs$77 Def000E +S A$_uchar2fs$96 Def002D +S A$_uchar2fs$78 Def000F +S A$_uchar2fs$69 Def0002 +S A$_uchar2fs$97 Def0030 +S A$_uchar2fs$88 Def001F +S A$_uchar2fs$79 Def0011 +S A$_uchar2fs$98 Def0033 +S A$_uchar2fs$99 Def0036 +S C$_uchar2fs.c$110$1$1 Def00E3 +S A$_uchar2fs$100 Def0038 +S A$_uchar2fs$200 Def00CE +S A$_uchar2fs$110 Def0046 +S A$_uchar2fs$201 Def00D0 +S A$_uchar2fs$120 Def0057 +S A$_uchar2fs$111 Def0049 +S A$_uchar2fs$202 Def00D2 +S A$_uchar2fs$121 Def0058 +S A$_uchar2fs$103 Def003B +S A$_uchar2fs$203 Def00D4 +S A$_uchar2fs$131 Def0065 +S A$_uchar2fs$122 Def005A +S A$_uchar2fs$113 Def004C +S ___uchar2fs Def0000 +S A$_uchar2fs$213 Def00E3 +S A$_uchar2fs$204 Def00D6 +S A$_uchar2fs$150 Def0083 +S A$_uchar2fs$141 Def0076 +S A$_uchar2fs$132 Def0066 +S A$_uchar2fs$123 Def005C +S A$_uchar2fs$114 Def004D +S A$_uchar2fs$105 Def003D +S A$_uchar2fs$151 Def0085 +S A$_uchar2fs$133 Def0068 +S A$_uchar2fs$124 Def005D +S A$_uchar2fs$115 Def004E +S A$_uchar2fs$206 Def00D8 +S A$_uchar2fs$170 Def009D +S A$_uchar2fs$152 Def0086 +S A$_uchar2fs$134 Def006A +S A$_uchar2fs$125 Def005F +S A$_uchar2fs$116 Def0050 +S A$_uchar2fs$207 Def00DB +S A$_uchar2fs$180 Def00AA +S A$_uchar2fs$171 Def009E +S A$_uchar2fs$162 Def0092 +S A$_uchar2fs$153 Def0088 +S A$_uchar2fs$144 Def0078 +S A$_uchar2fs$135 Def006C +S A$_uchar2fs$117 Def0052 +S A$_uchar2fs$108 Def0040 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 E4 F5 00 03 F5 00 02 F5 00 01 F5 +R 00 00 00 08 29 06 00 03 29 09 00 03 29 0C 00 03 +T 00 0A 00 00 8A 00 08 EA 33 95 E0 F5 00 09 F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 0C 00 03 +T 00 14 00 0A F5 00 0B E5 00 08 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 1A 00 09 45 00 0A 45 00 0B 70 1A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 21 +R 00 00 00 08 +T 00 21 75 00 04 00 75 00 05 00 75 00 06 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 2B 00 07 00 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 34 00 06 F0 E5 00 07 02 00 E3 +R 00 00 00 08 29 02 00 03 29 06 00 03 00 09 00 08 +T 00 3B +R 00 00 00 08 +T 00 3B E5 00 0B 30 E7 21 +R 00 00 00 08 29 03 00 03 +T 00 40 +R 00 00 00 08 +T 00 40 75 00 00 00 75 00 01 00 75 00 02 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 4A 00 03 80 C3 E4 95 00 08 F5 00 08 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 54 00 09 F5 00 09 E4 95 00 0A F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 5B 00 0A E4 95 00 0B F5 00 0B +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 61 +R 00 00 00 08 +T 00 61 7B 96 7C 00 +R 00 00 00 08 +T 00 65 +R 00 00 00 08 +T 00 65 C3 E5 00 08 94 00 E5 00 09 94 00 E5 00 0A +R 00 00 00 08 29 04 00 03 29 09 00 03 29 0E 00 03 +T 00 70 94 80 E5 00 0B 94 00 50 1C +R 00 00 00 08 29 05 00 03 +T 00 78 +R 00 00 00 08 +T 00 78 E5 00 08 25 E0 F5 00 08 E5 00 09 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 00 82 00 09 E5 00 0A 33 F5 00 0A E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 89 00 0B 33 F5 00 0B 1B BB FF 01 1C +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 92 +R 00 00 00 08 +T 00 92 80 D1 +R 00 00 00 08 +T 00 94 +R 00 00 00 08 +T 00 94 53 00 0A 7F 7D 00 7E 00 8B 05 EC 54 01 A2 +R 00 00 00 08 09 03 00 03 +T 00 A1 E0 CD 13 CD 13 CD FE 7C 00 7B 00 AA 00 00 +R 00 00 00 08 29 0E 00 03 +T 00 AE AF 00 01 A8 00 02 A9 00 03 EA 42 03 EF 42 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 B9 04 E8 42 05 E9 42 06 E5 00 08 42 03 E5 +R 00 00 00 08 29 0A 00 03 +T 00 C5 00 09 42 04 E5 00 0A 42 05 E5 00 0B 42 06 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0C 00 03 +T 00 D0 8B 00 04 8C 00 05 8D 00 06 8E +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 D7 00 07 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 DF 00 06 F0 E5 00 07 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 E3 +R 00 00 00 08 +T 00 E3 22 +R 00 00 00 08 diff --git a/device/lib/small/_uint2fs.asm b/device/lib/small/_uint2fs.asm new file mode 100644 index 00000000..65d0302c --- /dev/null +++ b/device/lib/small/_uint2fs.asm @@ -0,0 +1,215 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:17 2000 + +;-------------------------------------------------------- + .module _uint2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___uint2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___uint2fs_sign_1_1: + .ds 0x0004 +___uint2fs_fl_1_1: + .ds 0x0004 +___uint2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__uint2fs$0$0 ==. +; _uint2fs.c 80 +; ----------------------------------------- +; function __uint2fs +; ----------------------------------------- +___uint2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _uint2fs.c 109 + mov r2,dpl + mov r3,dph +; _uint2fs.c 82 + clr a + mov (___uint2fs_sign_1_1 + 3),a + mov (___uint2fs_sign_1_1 + 2),a + mov (___uint2fs_sign_1_1 + 1),a + mov ___uint2fs_sign_1_1,a +; _uint2fs.c 85 + mov ___uint2fs_a1_1_1,r2 + mov (___uint2fs_a1_1_1 + 1),r3 + mov a,r3 + rlc a + subb a,acc + mov (___uint2fs_a1_1_1 + 2),a + mov (___uint2fs_a1_1_1 + 3),a +; _uint2fs.c 87 + mov a,___uint2fs_a1_1_1 + orl a,(___uint2fs_a1_1_1 + 1) + orl a,(___uint2fs_a1_1_1 + 2) + orl a,(___uint2fs_a1_1_1 + 3) +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _uint2fs.c 89 + mov ___uint2fs_fl_1_1,#0x00 + mov (___uint2fs_fl_1_1 + 1),#0x00 + mov (___uint2fs_fl_1_1 + 2),#0x00 + mov (___uint2fs_fl_1_1 + 3),#0x00 +; _uint2fs.c 90 + mov dpl,___uint2fs_fl_1_1 + mov dph,(___uint2fs_fl_1_1 + 1) + mov b,(___uint2fs_fl_1_1 + 2) + mov a,(___uint2fs_fl_1_1 + 3) + ljmp 00108$ +00102$: +; _uint2fs.c 93 + mov a,(___uint2fs_a1_1_1 + 3) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _uint2fs.c 95 + mov ___uint2fs_sign_1_1,#0x00 + mov (___uint2fs_sign_1_1 + 1),#0x00 + mov (___uint2fs_sign_1_1 + 2),#0x00 + mov (___uint2fs_sign_1_1 + 3),#0x80 +; _uint2fs.c 96 + clr c + clr a + subb a,___uint2fs_a1_1_1 + mov ___uint2fs_a1_1_1,a + clr a + subb a,(___uint2fs_a1_1_1 + 1) + mov (___uint2fs_a1_1_1 + 1),a + clr a + subb a,(___uint2fs_a1_1_1 + 2) + mov (___uint2fs_a1_1_1 + 2),a + clr a + subb a,(___uint2fs_a1_1_1 + 3) + mov (___uint2fs_a1_1_1 + 3),a +; _uint2fs.c 99 +00113$: + mov r4,#0x96 + mov r5,#0x00 +00105$: + clr c + mov a,___uint2fs_a1_1_1 + subb a,#0x00 + mov a,(___uint2fs_a1_1_1 + 1) + subb a,#0x00 + mov a,(___uint2fs_a1_1_1 + 2) + subb a,#0x80 + mov a,(___uint2fs_a1_1_1 + 3) + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _uint2fs.c 101 + mov a,___uint2fs_a1_1_1 + add a,acc + mov ___uint2fs_a1_1_1,a + mov a,(___uint2fs_a1_1_1 + 1) + rlc a + mov (___uint2fs_a1_1_1 + 1),a + mov a,(___uint2fs_a1_1_1 + 2) + rlc a + mov (___uint2fs_a1_1_1 + 2),a + mov a,(___uint2fs_a1_1_1 + 3) + rlc a + mov (___uint2fs_a1_1_1 + 3),a +; _uint2fs.c 102 + dec r4 + cjne r4,#0xff,00117$ + dec r5 +00117$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _uint2fs.c 105 + anl (___uint2fs_a1_1_1 + 2),#0x7f +; _uint2fs.c 107 + mov r6,#0x00 + mov r7,#0x00 + mov ar6,r4 + mov a,r5 + anl a,#0x01 + mov c,acc.0 + xch a,r6 + rrc a + xch a,r6 + rrc a + xch a,r6 + mov r7,a + mov r5,#0x00 + mov r4,#0x00 + mov r2,___uint2fs_sign_1_1 + mov r3,(___uint2fs_sign_1_1 + 1) + mov r0,(___uint2fs_sign_1_1 + 2) + mov r1,(___uint2fs_sign_1_1 + 3) + mov a,r2 + orl ar4,a + mov a,r3 + orl ar5,a + mov a,r0 + orl ar6,a + mov a,r1 + orl ar7,a + mov a,___uint2fs_a1_1_1 + orl ar4,a + mov a,(___uint2fs_a1_1_1 + 1) + orl ar5,a + mov a,(___uint2fs_a1_1_1 + 2) + orl ar6,a + mov a,(___uint2fs_a1_1_1 + 3) + orl ar7,a + mov ___uint2fs_fl_1_1,r4 + mov (___uint2fs_fl_1_1 + 1),r5 + mov (___uint2fs_fl_1_1 + 2),r6 + mov (___uint2fs_fl_1_1 + 3),r7 +; _uint2fs.c 109 + mov dpl,___uint2fs_fl_1_1 + mov dph,(___uint2fs_fl_1_1 + 1) + mov b,(___uint2fs_fl_1_1 + 2) + mov a,(___uint2fs_fl_1_1 + 3) +00108$: + C$_uint2fs.c$110$1$1 ==. + XG$__uint2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_uint2fs.cdb b/device/lib/small/_uint2fs.cdb new file mode 100644 index 00000000..3445c946 --- /dev/null +++ b/device/lib/small/_uint2fs.cdb @@ -0,0 +1,2 @@ +M:_uint2fs +F:G$__uint2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_uint2fs.rel b/device/lib/small/_uint2fs.rel new file mode 100644 index 00000000..28e2c089 --- /dev/null +++ b/device/lib/small/_uint2fs.rel @@ -0,0 +1,224 @@ +;!FILE _uint2fs.asm +XH +H 9 areas 7B global symbols +M _uint2fs +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size E6 flags 20 +S A$_uint2fs$94 Def0029 +S A$_uint2fs$85 Def001B +S A$_uint2fs$76 Def000D +S A$_uint2fs$67 Def0000 +S A$_uint2fs$95 Def002C +S A$_uint2fs$86 Def001D +S A$_uint2fs$77 Def000F +S A$_uint2fs$68 Def0002 +S A$_uint2fs$87 Def001F +S A$_uint2fs$78 Def0011 +S A$_uint2fs$97 Def002F +S A$_uint2fs$79 Def0012 +S A$_uint2fs$98 Def0032 +S A$_uint2fs$89 Def0021 +S A$_uint2fs$99 Def0035 +S C$_uint2fs.c$110$1$1 Def00E5 +S A$_uint2fs$100 Def0038 +S A$_uint2fs$200 Def00CE +S A$_uint2fs$110 Def0045 +S A$_uint2fs$101 Def003A +S A$_uint2fs$210 Def00E3 +S A$_uint2fs$201 Def00D0 +S A$_uint2fs$120 Def0057 +S A$_uint2fs$111 Def0048 +S A$_uint2fs$202 Def00D2 +S A$_uint2fs$130 Def0065 +S A$_uint2fs$121 Def0059 +S A$_uint2fs$112 Def004B +S A$_uint2fs$203 Def00D4 +S A$_uint2fs$140 Def0076 +S A$_uint2fs$122 Def005A +S A$_uint2fs$104 Def003D +S ___uint2fs Def0000 +S A$_uint2fs$204 Def00D6 +S A$_uint2fs$150 Def0083 +S A$_uint2fs$132 Def0067 +S A$_uint2fs$123 Def005C +S A$_uint2fs$114 Def004E +S A$_uint2fs$214 Def00E5 +S A$_uint2fs$205 Def00D8 +S A$_uint2fs$160 Def0093 +S A$_uint2fs$151 Def0085 +S A$_uint2fs$142 Def0078 +S A$_uint2fs$133 Def0068 +S A$_uint2fs$124 Def005E +S A$_uint2fs$115 Def004F +S A$_uint2fs$106 Def003F +S A$_uint2fs$170 Def009D +S A$_uint2fs$152 Def0087 +S A$_uint2fs$134 Def006A +S A$_uint2fs$125 Def005F +S A$_uint2fs$116 Def0050 +S A$_uint2fs$207 Def00DA +S A$_uint2fs$180 Def00AA +S A$_uint2fs$171 Def009F +S A$_uint2fs$153 Def0088 +S A$_uint2fs$135 Def006C +S A$_uint2fs$126 Def0061 +S A$_uint2fs$117 Def0052 +S A$_uint2fs$208 Def00DD +S A$_uint2fs$190 Def00BC +S A$_uint2fs$181 Def00AC +S A$_uint2fs$172 Def00A0 +S A$_uint2fs$163 Def0094 +S A$_uint2fs$154 Def008A +S A$_uint2fs$145 Def007A +S A$_uint2fs$136 Def006E +S A$_uint2fs$118 Def0054 +S A$_uint2fs$109 Def0042 +S A$_uint2fs$209 Def00E0 +S A$_uint2fs$191 Def00BD +S A$_uint2fs$182 Def00AE +S A$_uint2fs$173 Def00A2 +S A$_uint2fs$155 Def008C +S A$_uint2fs$146 Def007C +S A$_uint2fs$137 Def0070 +S A$_uint2fs$119 Def0055 +S A$_uint2fs$192 Def00BF +S A$_uint2fs$183 Def00B0 +S A$_uint2fs$174 Def00A4 +S A$_uint2fs$156 Def008D +S A$_uint2fs$147 Def007E +S A$_uint2fs$138 Def0072 +S A$_uint2fs$129 Def0063 +S A$_uint2fs$193 Def00C0 +S A$_uint2fs$184 Def00B2 +S A$_uint2fs$175 Def00A5 +S A$_uint2fs$166 Def0096 +S A$_uint2fs$148 Def0080 +S A$_uint2fs$139 Def0074 +S A$_uint2fs$194 Def00C2 +S A$_uint2fs$185 Def00B4 +S A$_uint2fs$176 Def00A6 +S A$_uint2fs$158 Def008F +S A$_uint2fs$149 Def0082 +S A$_uint2fs$195 Def00C4 +S A$_uint2fs$186 Def00B6 +S A$_uint2fs$177 Def00A7 +S A$_uint2fs$168 Def0099 +S A$_uint2fs$159 Def0090 +S A$_uint2fs$196 Def00C6 +S A$_uint2fs$187 Def00B7 +S A$_uint2fs$178 Def00A8 +S A$_uint2fs$169 Def009B +S A$_uint2fs$197 Def00C8 +S A$_uint2fs$188 Def00B9 +S A$_uint2fs$179 Def00A9 +S XG$__uint2fs$0$0 Def00E5 +S A$_uint2fs$198 Def00CA +S A$_uint2fs$189 Def00BA +S A$_uint2fs$199 Def00CC +S A$_uint2fs$70 Def0004 +S A$_uint2fs$80 Def0013 +S A$_uint2fs$71 Def0005 +S A$_uint2fs$81 Def0015 +S A$_uint2fs$72 Def0007 +S G$__uint2fs$0$0 Def0000 +S A$_uint2fs$82 Def0017 +S A$_uint2fs$73 Def0009 +S A$_uint2fs$92 Def0023 +S A$_uint2fs$74 Def000B +S A$_uint2fs$93 Def0026 +S A$_uint2fs$84 Def0019 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 E4 F5 00 03 F5 00 02 F5 00 01 +R 00 00 00 08 29 08 00 03 29 0B 00 03 29 0E 00 03 +T 00 0B F5 00 00 8A 00 08 8B 00 09 EB 33 95 E0 F5 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 16 00 0A F5 00 0B E5 00 08 45 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 1C 00 09 45 00 0A 45 00 0B 70 1A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 23 +R 00 00 00 08 +T 00 23 75 00 04 00 75 00 05 00 75 00 06 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 2D 00 07 00 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 36 00 06 F0 E5 00 07 02 00 E5 +R 00 00 00 08 29 02 00 03 29 06 00 03 00 09 00 08 +T 00 3D +R 00 00 00 08 +T 00 3D E5 00 0B 30 E7 21 +R 00 00 00 08 29 03 00 03 +T 00 42 +R 00 00 00 08 +T 00 42 75 00 00 00 75 00 01 00 75 00 02 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 4C 00 03 80 C3 E4 95 00 08 F5 00 08 E4 95 +R 00 00 00 08 29 02 00 03 29 08 00 03 29 0B 00 03 +T 00 56 00 09 F5 00 09 E4 95 00 0A F5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 5D 00 0A E4 95 00 0B F5 00 0B +R 00 00 00 08 29 02 00 03 29 06 00 03 29 09 00 03 +T 00 63 +R 00 00 00 08 +T 00 63 7C 96 7D 00 +R 00 00 00 08 +T 00 67 +R 00 00 00 08 +T 00 67 C3 E5 00 08 94 00 E5 00 09 94 00 E5 00 0A +R 00 00 00 08 29 04 00 03 29 09 00 03 29 0E 00 03 +T 00 72 94 80 E5 00 0B 94 00 50 1C +R 00 00 00 08 29 05 00 03 +T 00 7A +R 00 00 00 08 +T 00 7A E5 00 08 25 E0 F5 00 08 E5 00 09 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 00 84 00 09 E5 00 0A 33 F5 00 0A E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 8B 00 0B 33 F5 00 0B 1C BC FF 01 1D +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 94 +R 00 00 00 08 +T 00 94 80 D1 +R 00 00 00 08 +T 00 96 +R 00 00 00 08 +T 00 96 53 00 0A 7F 7E 00 7F 00 8C 06 ED 54 01 A2 +R 00 00 00 08 09 03 00 03 +T 00 A3 E0 CE 13 CE 13 CE FF 7D 00 7C 00 AA 00 00 +R 00 00 00 08 29 0E 00 03 +T 00 B0 AB 00 01 A8 00 02 A9 00 03 EA 42 04 EB 42 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 BB 05 E8 42 06 E9 42 07 E5 00 08 42 04 E5 +R 00 00 00 08 29 0A 00 03 +T 00 C7 00 09 42 05 E5 00 0A 42 06 E5 00 0B 42 07 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0C 00 03 +T 00 D2 8C 00 04 8D 00 05 8E 00 06 8F +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 D9 00 07 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 E1 00 06 F0 E5 00 07 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 E5 +R 00 00 00 08 +T 00 E5 22 +R 00 00 00 08 diff --git a/device/lib/small/_ulong2fs.asm b/device/lib/small/_ulong2fs.asm new file mode 100644 index 00000000..55819036 --- /dev/null +++ b/device/lib/small/_ulong2fs.asm @@ -0,0 +1,214 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:17 2000 + +;-------------------------------------------------------- + .module _ulong2fs +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl ___ulong2fs +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +___ulong2fs_sign_1_1: + .ds 0x0004 +___ulong2fs_fl_1_1: + .ds 0x0004 +___ulong2fs_a1_1_1: + .ds 0x0004 +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$__ulong2fs$0$0 ==. +; _ulong2fs.c 80 +; ----------------------------------------- +; function __ulong2fs +; ----------------------------------------- +___ulong2fs: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; _ulong2fs.c 109 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; _ulong2fs.c 82 + clr a + mov (___ulong2fs_sign_1_1 + 3),a + mov (___ulong2fs_sign_1_1 + 2),a + mov (___ulong2fs_sign_1_1 + 1),a + mov ___ulong2fs_sign_1_1,a +; _ulong2fs.c 85 + mov ___ulong2fs_a1_1_1,r2 + mov (___ulong2fs_a1_1_1 + 1),r3 + mov (___ulong2fs_a1_1_1 + 2),r4 + mov (___ulong2fs_a1_1_1 + 3),r5 +; _ulong2fs.c 87 + mov a,r2 + orl a,r3 + orl a,r4 + orl a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00114$: +; _ulong2fs.c 89 + mov ___ulong2fs_fl_1_1,#0x00 + mov (___ulong2fs_fl_1_1 + 1),#0x00 + mov (___ulong2fs_fl_1_1 + 2),#0x00 + mov (___ulong2fs_fl_1_1 + 3),#0x00 +; _ulong2fs.c 90 + mov dpl,___ulong2fs_fl_1_1 + mov dph,(___ulong2fs_fl_1_1 + 1) + mov b,(___ulong2fs_fl_1_1 + 2) + mov a,(___ulong2fs_fl_1_1 + 3) + ljmp 00108$ +00102$: +; _ulong2fs.c 93 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00113$ +00115$: +; _ulong2fs.c 95 + mov ___ulong2fs_sign_1_1,#0x00 + mov (___ulong2fs_sign_1_1 + 1),#0x00 + mov (___ulong2fs_sign_1_1 + 2),#0x00 + mov (___ulong2fs_sign_1_1 + 3),#0x80 +; _ulong2fs.c 96 + clr c + clr a + subb a,r2 + mov ___ulong2fs_a1_1_1,a + clr a + subb a,r3 + mov (___ulong2fs_a1_1_1 + 1),a + clr a + subb a,r4 + mov (___ulong2fs_a1_1_1 + 2),a + clr a + subb a,r5 + mov (___ulong2fs_a1_1_1 + 3),a +; _ulong2fs.c 99 +00113$: + mov r2,#0x96 + mov r3,#0x00 +00105$: + clr c + mov a,___ulong2fs_a1_1_1 + subb a,#0x00 + mov a,(___ulong2fs_a1_1_1 + 1) + subb a,#0x00 + mov a,(___ulong2fs_a1_1_1 + 2) + subb a,#0x80 + mov a,(___ulong2fs_a1_1_1 + 3) + subb a,#0x00 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00107$ +00116$: +; _ulong2fs.c 101 + mov a,___ulong2fs_a1_1_1 + add a,acc + mov ___ulong2fs_a1_1_1,a + mov a,(___ulong2fs_a1_1_1 + 1) + rlc a + mov (___ulong2fs_a1_1_1 + 1),a + mov a,(___ulong2fs_a1_1_1 + 2) + rlc a + mov (___ulong2fs_a1_1_1 + 2),a + mov a,(___ulong2fs_a1_1_1 + 3) + rlc a + mov (___ulong2fs_a1_1_1 + 3),a +; _ulong2fs.c 102 + dec r2 + cjne r2,#0xff,00117$ + dec r3 +00117$: +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00107$: +; _ulong2fs.c 105 + anl (___ulong2fs_a1_1_1 + 2),#0x7f +; _ulong2fs.c 107 + mov r4,#0x00 + mov r5,#0x00 + mov ar4,r2 + mov a,r3 + anl a,#0x01 + mov c,acc.0 + xch a,r4 + rrc a + xch a,r4 + rrc a + xch a,r4 + mov r5,a + mov r3,#0x00 + mov r2,#0x00 + mov r6,___ulong2fs_sign_1_1 + mov r7,(___ulong2fs_sign_1_1 + 1) + mov r0,(___ulong2fs_sign_1_1 + 2) + mov r1,(___ulong2fs_sign_1_1 + 3) + mov a,r6 + orl ar2,a + mov a,r7 + orl ar3,a + mov a,r0 + orl ar4,a + mov a,r1 + orl ar5,a + mov a,___ulong2fs_a1_1_1 + orl ar2,a + mov a,(___ulong2fs_a1_1_1 + 1) + orl ar3,a + mov a,(___ulong2fs_a1_1_1 + 2) + orl ar4,a + mov a,(___ulong2fs_a1_1_1 + 3) + orl ar5,a + mov ___ulong2fs_fl_1_1,r2 + mov (___ulong2fs_fl_1_1 + 1),r3 + mov (___ulong2fs_fl_1_1 + 2),r4 + mov (___ulong2fs_fl_1_1 + 3),r5 +; _ulong2fs.c 109 + mov dpl,___ulong2fs_fl_1_1 + mov dph,(___ulong2fs_fl_1_1 + 1) + mov b,(___ulong2fs_fl_1_1 + 2) + mov a,(___ulong2fs_fl_1_1 + 3) +00108$: + C$_ulong2fs.c$110$1$1 ==. + XG$__ulong2fs$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/_ulong2fs.cdb b/device/lib/small/_ulong2fs.cdb new file mode 100644 index 00000000..5a2bb991 --- /dev/null +++ b/device/lib/small/_ulong2fs.cdb @@ -0,0 +1,2 @@ +M:_ulong2fs +F:G$__ulong2fs$0$0({2}DF,SF:S),Z,0,0,0,0,0 diff --git a/device/lib/small/_ulong2fs.rel b/device/lib/small/_ulong2fs.rel new file mode 100644 index 00000000..5c407bb6 --- /dev/null +++ b/device/lib/small/_ulong2fs.rel @@ -0,0 +1,219 @@ +;!FILE _ulong2fs.asm +XH +H 9 areas 7A global symbols +M _ulong2fs +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size C flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size DC flags 20 +S C$_ulong2fs.c$110$1$1 Def00DB +S A$_ulong2fs$100 Def0035 +S A$_ulong2fs$200 Def00C6 +S A$_ulong2fs$110 Def0042 +S A$_ulong2fs$201 Def00C8 +S A$_ulong2fs$120 Def0051 +S A$_ulong2fs$111 Def0045 +S A$_ulong2fs$202 Def00CA +S A$_ulong2fs$121 Def0052 +S A$_ulong2fs$103 Def0038 +S A$_ulong2fs$203 Def00CC +S A$_ulong2fs$131 Def005D +S A$_ulong2fs$122 Def0053 +S A$_ulong2fs$113 Def0048 +S ___ulong2fs Def0000 +S A$_ulong2fs$213 Def00DB +S A$_ulong2fs$204 Def00CE +S A$_ulong2fs$150 Def007B +S A$_ulong2fs$141 Def006E +S A$_ulong2fs$132 Def005E +S A$_ulong2fs$123 Def0055 +S A$_ulong2fs$114 Def0049 +S A$_ulong2fs$105 Def0039 +S A$_ulong2fs$151 Def007D +S A$_ulong2fs$133 Def0060 +S A$_ulong2fs$124 Def0056 +S A$_ulong2fs$115 Def004A +S A$_ulong2fs$206 Def00D0 +S A$_ulong2fs$170 Def0095 +S A$_ulong2fs$152 Def007E +S A$_ulong2fs$134 Def0062 +S A$_ulong2fs$125 Def0057 +S A$_ulong2fs$116 Def004B +S A$_ulong2fs$207 Def00D3 +S A$_ulong2fs$180 Def00A2 +S A$_ulong2fs$171 Def0096 +S A$_ulong2fs$162 Def008A +S A$_ulong2fs$153 Def0080 +S A$_ulong2fs$144 Def0070 +S A$_ulong2fs$135 Def0064 +S A$_ulong2fs$117 Def004D +S A$_ulong2fs$108 Def003C +S A$_ulong2fs$208 Def00D6 +S A$_ulong2fs$190 Def00B3 +S A$_ulong2fs$181 Def00A4 +S A$_ulong2fs$172 Def0098 +S A$_ulong2fs$154 Def0082 +S A$_ulong2fs$145 Def0072 +S A$_ulong2fs$136 Def0066 +S A$_ulong2fs$118 Def004E +S A$_ulong2fs$109 Def003F +S A$_ulong2fs$209 Def00D9 +S A$_ulong2fs$191 Def00B5 +S A$_ulong2fs$182 Def00A6 +S A$_ulong2fs$173 Def009A +S A$_ulong2fs$155 Def0083 +S A$_ulong2fs$146 Def0074 +S A$_ulong2fs$137 Def0068 +S A$_ulong2fs$128 Def0059 +S A$_ulong2fs$119 Def004F +S A$_ulong2fs$192 Def00B6 +S A$_ulong2fs$183 Def00A8 +S A$_ulong2fs$174 Def009B +S A$_ulong2fs$165 Def008C +S A$_ulong2fs$147 Def0076 +S A$_ulong2fs$138 Def006A +S A$_ulong2fs$129 Def005B +S A$_ulong2fs$193 Def00B8 +S A$_ulong2fs$184 Def00AA +S A$_ulong2fs$175 Def009C +S A$_ulong2fs$157 Def0085 +S A$_ulong2fs$148 Def0078 +S A$_ulong2fs$139 Def006C +S A$_ulong2fs$194 Def00BA +S A$_ulong2fs$185 Def00AC +S A$_ulong2fs$176 Def009D +S A$_ulong2fs$167 Def008F +S A$_ulong2fs$158 Def0086 +S A$_ulong2fs$149 Def0079 +S A$_ulong2fs$195 Def00BC +S A$_ulong2fs$186 Def00AD +S A$_ulong2fs$177 Def009E +S A$_ulong2fs$168 Def0091 +S A$_ulong2fs$159 Def0089 +S A$_ulong2fs$196 Def00BE +S A$_ulong2fs$187 Def00AF +S A$_ulong2fs$178 Def009F +S A$_ulong2fs$169 Def0093 +S A$_ulong2fs$197 Def00C0 +S A$_ulong2fs$188 Def00B0 +S A$_ulong2fs$179 Def00A0 +S XG$__ulong2fs$0$0 Def00DB +S A$_ulong2fs$198 Def00C2 +S A$_ulong2fs$189 Def00B2 +S A$_ulong2fs$199 Def00C4 +S A$_ulong2fs$70 Def0006 +S A$_ulong2fs$80 Def0014 +S A$_ulong2fs$81 Def0016 +S A$_ulong2fs$72 Def0007 +S G$__ulong2fs$0$0 Def0000 +S A$_ulong2fs$91 Def001E +S A$_ulong2fs$73 Def0008 +S A$_ulong2fs$92 Def0021 +S A$_ulong2fs$83 Def0018 +S A$_ulong2fs$74 Def000A +S A$_ulong2fs$93 Def0024 +S A$_ulong2fs$84 Def0019 +S A$_ulong2fs$75 Def000C +S A$_ulong2fs$94 Def0027 +S A$_ulong2fs$85 Def001A +S A$_ulong2fs$76 Def000E +S A$_ulong2fs$67 Def0000 +S A$_ulong2fs$86 Def001B +S A$_ulong2fs$68 Def0002 +S A$_ulong2fs$96 Def002A +S A$_ulong2fs$78 Def0010 +S A$_ulong2fs$69 Def0004 +S A$_ulong2fs$97 Def002D +S A$_ulong2fs$88 Def001C +S A$_ulong2fs$79 Def0012 +S A$_ulong2fs$98 Def0030 +S A$_ulong2fs$99 Def0033 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 04 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 08 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 AC F0 FD E4 F5 00 03 F5 00 02 +R 00 00 00 08 29 0B 00 03 29 0E 00 03 +T 00 0C F5 00 01 F5 00 00 8A 00 08 8B +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 13 00 09 8C 00 0A 8D 00 0B EA 4B 4C 4D 70 1A +R 00 00 00 08 29 02 00 03 29 05 00 03 29 08 00 03 +T 00 1E +R 00 00 00 08 +T 00 1E 75 00 04 00 75 00 05 00 75 00 06 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 28 00 07 00 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 06 00 03 29 0A 00 03 +T 00 31 00 06 F0 E5 00 07 02 00 DB +R 00 00 00 08 29 02 00 03 29 06 00 03 00 09 00 08 +T 00 38 +R 00 00 00 08 +T 00 38 ED 30 E7 1D +R 00 00 00 08 +T 00 3C +R 00 00 00 08 +T 00 3C 75 00 00 00 75 00 01 00 75 00 02 00 75 +R 00 00 00 08 29 03 00 03 29 07 00 03 29 0B 00 03 +T 00 46 00 03 80 C3 E4 9A F5 00 08 E4 9B F5 00 09 +R 00 00 00 08 29 02 00 03 29 09 00 03 29 0E 00 03 +T 00 51 E4 9C F5 00 0A E4 9D F5 00 0B +R 00 00 00 08 29 05 00 03 29 0A 00 03 +T 00 59 +R 00 00 00 08 +T 00 59 7A 96 7B 00 +R 00 00 00 08 +T 00 5D +R 00 00 00 08 +T 00 5D C3 E5 00 08 94 00 E5 00 09 94 00 E5 00 0A +R 00 00 00 08 29 04 00 03 29 09 00 03 29 0E 00 03 +T 00 68 94 80 E5 00 0B 94 00 50 1C +R 00 00 00 08 29 05 00 03 +T 00 70 +R 00 00 00 08 +T 00 70 E5 00 08 25 E0 F5 00 08 E5 00 09 33 F5 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0B 00 03 +T 00 7A 00 09 E5 00 0A 33 F5 00 0A E5 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 81 00 0B 33 F5 00 0B 1A BA FF 01 1B +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 8A +R 00 00 00 08 +T 00 8A 80 D1 +R 00 00 00 08 +T 00 8C +R 00 00 00 08 +T 00 8C 53 00 0A 7F 7C 00 7D 00 8A 04 EB 54 01 A2 +R 00 00 00 08 09 03 00 03 +T 00 99 E0 CC 13 CC 13 CC FD 7B 00 7A 00 AE 00 00 +R 00 00 00 08 29 0E 00 03 +T 00 A6 AF 00 01 A8 00 02 A9 00 03 EE 42 02 EF 42 +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 B1 03 E8 42 04 E9 42 05 E5 00 08 42 02 E5 +R 00 00 00 08 29 0A 00 03 +T 00 BD 00 09 42 03 E5 00 0A 42 04 E5 00 0B 42 05 +R 00 00 00 08 29 02 00 03 29 07 00 03 29 0C 00 03 +T 00 C8 8A 00 04 8B 00 05 8C 00 06 8D +R 00 00 00 08 29 03 00 03 29 06 00 03 29 09 00 03 +T 00 CF 00 07 85 00 04 82 85 00 05 83 85 +R 00 00 00 08 29 02 00 03 29 05 00 03 29 09 00 03 +T 00 D7 00 06 F0 E5 00 07 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 DB +R 00 00 00 08 +T 00 DB 22 +R 00 00 00 08 diff --git a/device/lib/small/assert.asm b/device/lib/small/assert.asm new file mode 100644 index 00000000..cb7da4a9 --- /dev/null +++ b/device/lib/small/assert.asm @@ -0,0 +1,96 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:21 2000 + +;-------------------------------------------------------- + .module assert +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl __assert + .globl __assert_PARM_3 + .globl __assert_PARM_2 +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +__assert_PARM_2: + .ds 0x0003 +__assert_PARM_3: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$_assert$0$0 ==. +; assert.c 4 +; ----------------------------------------- +; function _assert +; ----------------------------------------- +__assert: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; assert.c 0 +; assert.c 6 + mov r2,#__str_0 + mov r3,#(__str_0 >> 8) + mov r4,#0x02 + push __assert_PARM_2 + push (__assert_PARM_2 + 1) + push (__assert_PARM_2 + 2) + push __assert_PARM_3 + push (__assert_PARM_3 + 1) + push ar2 + push ar3 + push ar4 + lcall _printf + mov a,sp + add a,#0xfa + mov sp,a +; assert.c 8 +00102$: +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00104$: + C$assert.c$9$1$1 ==. + XG$_assert$0$0 ==. + ret + .area CSEG (CODE) +Fassert$_str_0$0$0 == . +__str_0: + .ascii /Assert(%s) failed at line %u in file %s./ + .byte 0x0a + .ascii // + .byte 0 diff --git a/device/lib/small/assert.cdb b/device/lib/small/assert.cdb new file mode 100644 index 00000000..690295aa --- /dev/null +++ b/device/lib/small/assert.cdb @@ -0,0 +1,3 @@ +M:assert +F:G$_assert$0$0({2}DF,SV:S),C,0,0,0,0,0 +S:Fassert$_str_0$0$0({43}DA43,SC:S),D,0,0 diff --git a/device/lib/small/assert.rel b/device/lib/small/assert.rel new file mode 100644 index 00000000..ed17bb75 --- /dev/null +++ b/device/lib/small/assert.rel @@ -0,0 +1,71 @@ +;!FILE assert.asm +XH +H 8 areas 19 global symbols +M assert +S _printf Ref0000 +A _CODE size 0 flags 0 +A DSEG size 5 flags 0 +S __assert_PARM_2 Def0000 +S __assert_PARM_3 Def0003 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 4C flags 20 +S Fassert$_str_0$0$0 Def0022 +S __assert Def0000 +S XG$_assert$0$0 Def0021 +S A$assert$70 Def0006 +S A$assert$80 Def001B +S A$assert$71 Def0008 +S A$assert$81 Def001D +S A$assert$72 Def000A +S G$_assert$0$0 Def0000 +S A$assert$73 Def000C +S A$assert$74 Def000E +S A$assert$75 Def0010 +S A$assert$85 Def001F +S A$assert$76 Def0012 +S A$assert$67 Def0000 +S A$assert$77 Def0014 +S A$assert$68 Def0002 +S A$assert$78 Def0016 +S A$assert$69 Def0004 +S A$assert$79 Def0019 +S A$assert$89 Def0021 +S C$assert.c$9$1$1 Def0021 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 00 +R 00 00 00 07 +T 00 00 7A 00 22 7B 00 22 7C 02 C0 00 00 C0 +R 00 00 00 07 09 03 00 07 89 06 00 07 29 0B 00 01 +T 00 09 00 01 C0 00 02 C0 00 03 C0 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 00 0F 00 04 C0 02 C0 03 C0 04 12 00 00 E5 81 24 +R 00 00 00 07 29 02 00 01 02 0B 00 00 +T 00 1C FA F5 81 +R 00 00 00 07 +T 00 1F +R 00 00 00 07 +T 00 1F 80 FE +R 00 00 00 07 +T 00 21 +R 00 00 00 07 +T 00 21 22 +R 00 00 00 07 +T 00 22 +R 00 00 00 07 +T 00 22 41 73 73 65 72 74 28 25 73 29 20 66 61 69 +R 00 00 00 07 +T 00 30 6C 65 64 20 61 74 20 6C 69 6E 65 20 25 75 +R 00 00 00 07 +T 00 3E 20 69 6E 20 66 69 6C 65 20 25 73 2E 0A 00 +R 00 00 00 07 diff --git a/device/lib/small/malloc.asm b/device/lib/small/malloc.asm new file mode 100644 index 00000000..9eb0b787 --- /dev/null +++ b/device/lib/small/malloc.asm @@ -0,0 +1,490 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:18 2000 + +;-------------------------------------------------------- + .module malloc +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _init_dynamic_memory_PARM_2 + .globl _free + .globl _malloc + .globl _init_dynamic_memory +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0==. +_FIRST_MEMORY_HEADER_PTR: + .ds 0x0002 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +_init_dynamic_memory_PARM_2: + .ds 0x0002 + .area _DUMMY + .area OSEG (OVR,DATA) +_malloc_size_1_1: + .ds 0x0002 +_malloc_current_header_1_1: + .ds 0x0002 + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$init_dynamic_memory$0$0 ==. +; malloc.c 31 +; ----------------------------------------- +; function init_dynamic_memory +; ----------------------------------------- +_init_dynamic_memory: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; malloc.c 63 + mov r2,dpl + mov r3,dph +; malloc.c 53 + mov a,r2 + orl a,r3 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00106$: +; malloc.c 55 + inc r2 + cjne r2,#0x00,00107$ + inc r3 +00107$: +; malloc.c 56 + dec _init_dynamic_memory_PARM_2 + mov a,#0xff + cjne a,_init_dynamic_memory_PARM_2,00108$ + dec (_init_dynamic_memory_PARM_2 + 1) +00108$: +00102$: +; malloc.c 58 + mov _FIRST_MEMORY_HEADER_PTR,r2 + mov (_FIRST_MEMORY_HEADER_PTR + 1),r3 +; malloc.c 60 + mov r4,_init_dynamic_memory_PARM_2 + mov r5,(_init_dynamic_memory_PARM_2 + 1) + mov a,r4 + add a,r2 + mov r4,a + mov a,r5 + addc a,r3 + mov r5,a + mov a,r4 + add a,#0xfa + mov r4,a + mov a,r5 + addc a,#0xff + mov r5,a + mov dpl,r2 + mov dph,r3 + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; malloc.c 61 + mov dpl,r4 + mov dph,r5 +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; malloc.c 62 + mov a,#0x02 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +; malloc.c 63 + mov a,#0x04 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +00103$: + C$malloc.c$64$1$1 ==. + XG$init_dynamic_memory$0$0 ==. + ret + G$malloc$0$0 ==. +; malloc.c 66 +; ----------------------------------------- +; function malloc +; ----------------------------------------- +_malloc: +; malloc.c 0 + mov _malloc_size_1_1,dpl + mov (_malloc_size_1_1 + 1),dph +; malloc.c 71 + mov r4,_malloc_size_1_1 + mov r5,(_malloc_size_1_1 + 1) + mov r6,#0x00 + mov r7,#0x00 + clr c + mov a,#0xf9 + subb a,r4 + mov a,#0xff + subb a,r5 +; Peephole 180 changed mov to clr + clr a + subb a,r6 +; Peephole 180 changed mov to clr + clr a + subb a,r7 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00102$ +00122$: +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00114$ +00102$: +; malloc.c 72 + mov a,#0x06 + add a,_malloc_size_1_1 + mov _malloc_size_1_1,a +; Peephole 180 changed mov to clr + clr a + addc a,(_malloc_size_1_1 + 1) + mov (_malloc_size_1_1 + 1),a +; malloc.c 73 + mov r4,_FIRST_MEMORY_HEADER_PTR + mov r5,(_FIRST_MEMORY_HEADER_PTR + 1) +; malloc.c 74 +00108$: +; malloc.c 84 + mov dpl,r4 + mov dph,r5 + movx a,@dptr + mov _malloc_current_header_1_1,a + inc dptr + movx a,@dptr + mov (_malloc_current_header_1_1 + 1),a + mov r0,_malloc_current_header_1_1 + mov r1,(_malloc_current_header_1_1 + 1) +; malloc.c 85 + mov ar2,r4 + mov ar3,r5 + clr c + mov a,r0 + subb a,r2 + mov r0,a + mov a,r1 + subb a,r3 + mov r1,a +; malloc.c 86 + mov a,#0x04 + add a,r4 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov r3,a + mov dpl,r2 + mov dph,r3 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + clr c + mov a,r0 + subb a,r6 + mov r0,a + mov a,r1 + subb a,r7 + mov r1,a + clr c + mov a,r0 + subb a,_malloc_size_1_1 + mov a,r1 + subb a,(_malloc_size_1_1 + 1) +; Peephole 108 removed ljmp by inverse jump logic + jnc 00109$ +00123$: +; malloc.c 87 + mov r4,_malloc_current_header_1_1 + mov r5,(_malloc_current_header_1_1 + 1) +; malloc.c 88 + mov dpl,r4 + mov dph,r5 + movx a,@dptr + mov r0,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r1,a + orl a,r0 + jz 00124$ + ljmp 00108$ +00124$: +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + ljmp 00114$ +00109$: +; malloc.c 90 + mov a,r6 + orl a,r7 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00111$ +00125$: +; malloc.c 92 + mov dpl,r2 + mov dph,r3 + mov a,_malloc_size_1_1 + movx @dptr,a + inc dptr + mov a,(_malloc_size_1_1 + 1) + movx @dptr,a +; malloc.c 93 + mov a,#0x06 + add a,r4 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov r3,a + mov dpl,r2 + mov dph,r3 + ljmp 00114$ +00111$: +; malloc.c 95 + mov a,r6 + add a,r4 + mov r2,a + mov a,r7 + addc a,r5 + mov r3,a +; malloc.c 96 + mov dpl,r2 + mov dph,r3 + mov a,_malloc_current_header_1_1 + movx @dptr,a + inc dptr + mov a,(_malloc_current_header_1_1 + 1) + movx @dptr,a +; malloc.c 97 + mov a,#0x02 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; malloc.c 98 + mov dpl,r4 + mov dph,r5 + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +; malloc.c 99 + mov a,_malloc_current_header_1_1 + orl a,(_malloc_current_header_1_1 + 1) +; Peephole 110 removed ljmp by inverse jump logic + jz 00113$ +00126$: + mov dpl,r2 + mov dph,r3 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr + mov r5,a + mov a,#0x02 + add a,r4 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov dph,a + mov a,r2 + movx @dptr,a + inc dptr + mov a,r3 + movx @dptr,a +00113$: +; malloc.c 100 + mov a,#0x04 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a + mov a,_malloc_size_1_1 + movx @dptr,a + inc dptr + mov a,(_malloc_size_1_1 + 1) + movx @dptr,a +; malloc.c 101 + mov a,#0x06 + add a,r2 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r3,a + mov dpl,r2 + mov dph,r3 +00114$: + C$malloc.c$102$1$1 ==. + XG$malloc$0$0 ==. + ret + G$free$0$0 ==. +; malloc.c 104 +; ----------------------------------------- +; function free +; ----------------------------------------- +_free: +; malloc.c 0 + mov r2,dpl + mov r3,dph +; malloc.c 107 + mov a,r2 + orl a,r3 + jnz 00113$ + ljmp 00108$ +00113$: +; malloc.c 109 + mov a,r2 + add a,#0xfa + mov r2,a + mov a,r3 + addc a,#0xff + mov r3,a +; malloc.c 110 + mov a,#0x02 + add a,r2 + mov r4,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r5,a + mov dpl,r4 + mov dph,r5 + movx a,@dptr + mov r4,a + inc dptr + movx a,@dptr +; Peephole 135 removed redundant mov + mov r5,a + orl a,r4 +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00114$: +; malloc.c 112 +; malloc.c 113 + mov dpl,r2 + mov dph,r3 + movx a,@dptr + mov r6,a + inc dptr + movx a,@dptr + mov r7,a + mov dpl,r4 + mov dph,r5 + mov a,r6 + movx @dptr,a + inc dptr + mov a,r7 + movx @dptr,a +; malloc.c 114 + mov a,r6 + orl a,r7 +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00115$: + mov a,#0x02 + add a,r6 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r7 + mov dph,a + mov a,r4 + movx @dptr,a + inc dptr + mov a,r5 + movx @dptr,a +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00104$: +; malloc.c 116 + mov a,#0x04 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a +; Peephole 101 removed redundant mov +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + inc dptr + movx @dptr,a +00108$: + C$malloc.c$118$2$1 ==. + XG$free$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/malloc.cdb b/device/lib/small/malloc.cdb new file mode 100644 index 00000000..5b0e97e1 --- /dev/null +++ b/device/lib/small/malloc.cdb @@ -0,0 +1,5 @@ +M:malloc +F:G$init_dynamic_memory$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$malloc$0$0({2}DF,DX,SV:S),C,0,0,0,0,0 +F:G$free$0$0({2}DF,SV:S),C,0,0,0,0,0 +S:Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0({2}DX,STMAH:S),E,0,0 diff --git a/device/lib/small/malloc.rel b/device/lib/small/malloc.rel new file mode 100644 index 00000000..0921c8f2 --- /dev/null +++ b/device/lib/small/malloc.rel @@ -0,0 +1,487 @@ +;!FILE malloc.asm +XH +H 9 areas 13E global symbols +M malloc +A _CODE size 0 flags 0 +A DSEG size 2 flags 0 +S Fmalloc$FIRST_MEMORY_HEADER_PTR$0$0 Def0000 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +S _init_dynamic_memory_PARM_2 Def0000 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 1B3 flags 20 +S A$malloc$483 Def01AF +S A$malloc$474 Def01A7 +S A$malloc$465 Def019F +S A$malloc$447 Def018D +S A$malloc$438 Def0181 +S A$malloc$384 Def0151 +S A$malloc$375 Def0148 +S A$malloc$357 Def0134 +S A$malloc$348 Def012A +S A$malloc$339 Def011F +S A$malloc$294 Def00EC +S A$malloc$285 Def00DF +S A$malloc$276 Def00D8 +S A$malloc$267 Def00CD +S A$malloc$249 Def00B8 +S A$malloc$186 Def006F +S A$malloc$177 Def0066 +S A$malloc$484 Def01B0 +S A$malloc$475 Def01A8 +S A$malloc$466 Def01A0 +S A$malloc$457 Def0195 +S A$malloc$448 Def018E +S A$malloc$439 Def0183 +S A$malloc$385 Def0152 +S A$malloc$376 Def0149 +S A$malloc$367 Def013D +S A$malloc$358 Def0135 +S A$malloc$349 Def012B +S A$malloc$295 Def00ED +S A$malloc$286 Def00E1 +S A$malloc$259 Def00C2 +S A$malloc$196 Def0079 +S A$malloc$187 Def0070 +S A$malloc$178 Def0067 +S _free Def0159 +S A$malloc$485 Def01B1 +S A$malloc$467 Def01A1 +S A$malloc$458 Def0197 +S A$malloc$449 Def018F +S A$malloc$386 Def0153 +S A$malloc$377 Def014A +S A$malloc$368 Def013F +S A$malloc$359 Def0136 +S A$malloc$287 Def00E3 +S A$malloc$269 Def00CE +S A$malloc$197 Def007B +S A$malloc$179 Def0069 +S A$malloc$477 Def01AA +S A$malloc$468 Def01A2 +S A$malloc$459 Def0198 +S A$malloc$387 Def0154 +S A$malloc$378 Def014C +S A$malloc$369 Def0140 +S A$malloc$297 Def00EE +S A$malloc$288 Def00E5 +S A$malloc$279 Def00DB +S A$malloc$198 Def007D +S A$malloc$189 Def0071 +S A$malloc$478 Def01AB +S A$malloc$388 Def0156 +S A$malloc$298 Def00EF +S A$malloc$289 Def00E6 +S A$malloc$479 Def01AC +S A$malloc$299 Def00F0 +S A$malloc$489 Def01B2 +S C$malloc.c$64$1$1 Def0057 +S A$malloc$80 Def0004 +S A$malloc$81 Def0005 +S A$malloc$91 Def000D +S A$malloc$92 Def000F +S A$malloc$83 Def0006 +S A$malloc$93 Def0011 +S XG$free$0$0 Def01B2 +S A$malloc$94 Def0014 +S A$malloc$86 Def0008 +S A$malloc$77 Def0000 +S _init_dynamic_memory Def0000 +S A$malloc$87 Def0009 +S A$malloc$78 Def0002 +S A$malloc$88 Def000C +S A$malloc$98 Def0016 +S A$malloc$99 Def0018 +S G$free$0$0 Def0159 +S _malloc Def0058 +S XG$init_dynamic_memory$0$0 Def0057 +S XG$malloc$0$0 Def0158 +S G$init_dynamic_memory$0$0 Def0000 +S G$malloc$0$0 Def0058 +S C$malloc.c$102$1$1 Def0158 +S A$malloc$200 Def007F +S A$malloc$110 Def0025 +S A$malloc$101 Def001A +S A$malloc$300 Def00F1 +S A$malloc$210 Def008A +S A$malloc$201 Def0080 +S A$malloc$120 Def0033 +S A$malloc$111 Def0027 +S A$malloc$102 Def001C +S A$malloc$400 Def0159 +S A$malloc$310 Def00FD +S A$malloc$301 Def00F3 +S A$malloc$220 Def0099 +S A$malloc$211 Def008C +S A$malloc$202 Def0082 +S A$malloc$130 Def003C +S A$malloc$121 Def0034 +S A$malloc$112 Def0028 +S A$malloc$103 Def001E +S A$malloc$410 Def0165 +S A$malloc$401 Def015B +S A$malloc$320 Def0109 +S A$malloc$302 Def00F5 +S A$malloc$230 Def00A4 +S A$malloc$221 Def009B +S A$malloc$212 Def008D +S A$malloc$113 Def0029 +S A$malloc$104 Def001F +S A$malloc$420 Def0170 +S A$malloc$411 Def0167 +S A$malloc$330 Def0115 +S A$malloc$321 Def010B +S A$malloc$312 Def00FE +S A$malloc$240 Def00AF +S A$malloc$231 Def00A5 +S A$malloc$222 Def009C +S A$malloc$213 Def008F +S A$malloc$204 Def0084 +S A$malloc$150 Def004F +S A$malloc$141 Def0046 +S A$malloc$132 Def003D +S A$malloc$123 Def0035 +S A$malloc$114 Def002B +S A$malloc$105 Def0020 +S A$malloc$430 Def017B +S A$malloc$421 Def0171 +S A$malloc$412 Def0168 +S A$malloc$403 Def015D +S A$malloc$331 Def0116 +S A$malloc$322 Def010C +S A$malloc$313 Def0100 +S A$malloc$250 Def00B9 +S A$malloc$241 Def00B0 +S A$malloc$223 Def009D +S A$malloc$214 Def0090 +S A$malloc$205 Def0086 +S A$malloc$151 Def0050 +S A$malloc$142 Def0047 +S A$malloc$133 Def003F +S A$malloc$124 Def0037 +S A$malloc$115 Def002C +S A$malloc$106 Def0021 +S A$malloc$440 Def0184 +S A$malloc$431 Def017C +S A$malloc$422 Def0172 +S A$malloc$413 Def0169 +S A$malloc$404 Def015E +S A$malloc$350 Def012C +S A$malloc$341 Def0120 +S A$malloc$314 Def0102 +S A$malloc$305 Def00F8 +S A$malloc$260 Def00C4 +S A$malloc$251 Def00BA +S A$malloc$242 Def00B1 +S A$malloc$233 Def00A6 +S A$malloc$224 Def009E +S A$malloc$215 Def0091 +S A$malloc$170 Def0058 +S A$malloc$152 Def0051 +S A$malloc$143 Def0048 +S A$malloc$134 Def0040 +S A$malloc$116 Def002E +S A$malloc$107 Def0022 +S C$malloc.c$118$2$1 Def01B2 +S A$malloc$450 Def0190 +S A$malloc$441 Def0185 +S A$malloc$423 Def0173 +S A$malloc$414 Def016B +S A$malloc$405 Def015F +S A$malloc$360 Def0138 +S A$malloc$351 Def012D +S A$malloc$342 Def0122 +S A$malloc$333 Def0117 +S A$malloc$324 Def010E +S A$malloc$315 Def0104 +S A$malloc$306 Def00F9 +S A$malloc$270 Def00CF +S A$malloc$252 Def00BB +S A$malloc$243 Def00B2 +S A$malloc$234 Def00A7 +S A$malloc$225 Def009F +S A$malloc$216 Def0093 +S A$malloc$180 Def006A +S A$malloc$171 Def005B +S A$malloc$162 Def0057 +S A$malloc$144 Def0049 +S A$malloc$117 Def0030 +S A$malloc$108 Def0023 +S A$malloc$442 Def0186 +S A$malloc$433 Def017D +S A$malloc$424 Def0175 +S A$malloc$406 Def0161 +S A$malloc$361 Def0139 +S A$malloc$352 Def012E +S A$malloc$334 Def0119 +S A$malloc$325 Def010F +S A$malloc$316 Def0105 +S A$malloc$307 Def00FA +S A$malloc$280 Def00DC +S A$malloc$271 Def00D0 +S A$malloc$262 Def00C6 +S A$malloc$253 Def00BD +S A$malloc$244 Def00B3 +S A$malloc$235 Def00A8 +S A$malloc$226 Def00A0 +S A$malloc$217 Def0095 +S A$malloc$181 Def006C +S A$malloc$136 Def0042 +S A$malloc$127 Def0039 +S A$malloc$118 Def0031 +S A$malloc$109 Def0024 +S A$malloc$470 Def01A3 +S A$malloc$461 Def019A +S A$malloc$452 Def0191 +S A$malloc$443 Def0187 +S A$malloc$425 Def0177 +S A$malloc$416 Def016C +S A$malloc$380 Def014D +S A$malloc$371 Def0142 +S A$malloc$362 Def013A +S A$malloc$353 Def012F +S A$malloc$344 Def0124 +S A$malloc$335 Def011B +S A$malloc$326 Def0110 +S A$malloc$317 Def0106 +S A$malloc$308 Def00FB +S A$malloc$290 Def00E7 +S A$malloc$272 Def00D2 +S A$malloc$263 Def00C8 +S A$malloc$254 Def00BE +S A$malloc$245 Def00B4 +S A$malloc$236 Def00A9 +S A$malloc$227 Def00A1 +S A$malloc$209 Def0088 +S A$malloc$173 Def005E +S A$malloc$155 Def0053 +S A$malloc$146 Def004A +S A$malloc$137 Def0043 +S A$malloc$128 Def003A +S A$malloc$119 Def0032 +S A$malloc$462 Def019B +S A$malloc$453 Def0192 +S A$malloc$444 Def0188 +S A$malloc$426 Def0178 +S A$malloc$417 Def016E +S A$malloc$381 Def014F +S A$malloc$372 Def0143 +S A$malloc$363 Def013B +S A$malloc$354 Def0131 +S A$malloc$336 Def011C +S A$malloc$327 Def0112 +S A$malloc$318 Def0108 +S A$malloc$309 Def00FC +S A$malloc$291 Def00E9 +S A$malloc$282 Def00DD +S A$malloc$264 Def00CA +S A$malloc$246 Def00B5 +S A$malloc$237 Def00AB +S A$malloc$219 Def0097 +S A$malloc$192 Def0073 +S A$malloc$183 Def006D +S A$malloc$174 Def0060 +S A$malloc$156 Def0054 +S A$malloc$147 Def004C +S A$malloc$138 Def0044 +S A$malloc$129 Def003B +S A$malloc$463 Def019C +S A$malloc$445 Def018A +S A$malloc$427 Def0179 +S A$malloc$418 Def016F +S A$malloc$409 Def0164 +S A$malloc$382 Def0150 +S A$malloc$373 Def0144 +S A$malloc$364 Def013C +S A$malloc$355 Def0132 +S A$malloc$346 Def0126 +S A$malloc$337 Def011D +S A$malloc$328 Def0113 +S A$malloc$265 Def00CB +S A$malloc$256 Def00C0 +S A$malloc$247 Def00B6 +S A$malloc$238 Def00AD +S A$malloc$229 Def00A2 +S A$malloc$193 Def0076 +S A$malloc$184 Def006E +S A$malloc$175 Def0062 +S A$malloc$157 Def0055 +S A$malloc$148 Def004D +S A$malloc$482 Def01AE +S A$malloc$473 Def01A5 +S A$malloc$464 Def019E +S A$malloc$455 Def0193 +S A$malloc$446 Def018C +S A$malloc$437 Def017F +S A$malloc$428 Def017A +S A$malloc$392 Def0158 +S A$malloc$374 Def0146 +S A$malloc$347 Def0128 +S A$malloc$338 Def011E +S A$malloc$329 Def0114 +S A$malloc$293 Def00EA +S A$malloc$275 Def00D5 +S A$malloc$266 Def00CC +S A$malloc$248 Def00B7 +S A$malloc$239 Def00AE +S A$malloc$176 Def0064 +S A$malloc$158 Def0056 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 00 +R 00 00 00 03 +T 00 02 +R 00 00 00 03 +T 00 02 +R 00 00 00 03 +T 00 00 +R 00 00 00 08 +T 00 00 AA 82 AB 83 EA 4B 70 0E +R 00 00 00 08 +T 00 08 +R 00 00 00 08 +T 00 08 0A BA 00 01 0B +R 00 00 00 08 +T 00 0D +R 00 00 00 08 +T 00 0D 15 00 00 74 FF B5 00 00 02 15 00 01 +R 00 00 00 08 29 03 00 03 29 08 00 03 29 0C 00 03 +T 00 16 +R 00 00 00 08 +T 00 16 +R 00 00 00 08 +T 00 16 8A 00 00 8B 00 01 AC 00 00 AD +R 00 00 00 08 29 03 00 01 29 06 00 01 29 09 00 03 +T 00 1D 00 01 EC 2A FC ED 3B FD EC 24 FA FC ED 34 +R 00 00 00 08 29 02 00 03 +T 00 2A FF FD 8A 82 8B 83 EC F0 A3 ED F0 8C 82 8D +R 00 00 00 08 +T 00 38 83 E4 F0 A3 F0 74 02 2A F5 82 E4 3B F5 83 +R 00 00 00 08 +T 00 46 E4 F0 A3 F0 74 04 2A F5 82 E4 3B F5 83 E4 +R 00 00 00 08 +T 00 54 F0 A3 F0 +R 00 00 00 08 +T 00 57 +R 00 00 00 08 +T 00 57 22 +R 00 00 00 08 +T 00 58 +R 00 00 00 08 +T 00 58 85 82 00 00 85 83 00 01 AC 00 00 AD +R 00 00 00 08 29 04 00 03 29 08 00 03 29 0B 00 03 +T 00 61 00 01 7E 00 7F 00 C3 74 F9 9C 74 FF 9D E4 +R 00 00 00 08 29 02 00 03 +T 00 6E 9E E4 9F 50 06 +R 00 00 00 08 +T 00 73 +R 00 00 00 08 +T 00 73 90 00 00 02 01 58 +R 00 00 00 08 00 06 00 08 +T 00 79 +R 00 00 00 08 +T 00 79 74 06 25 00 00 F5 00 00 E4 35 00 01 F5 +R 00 00 00 08 29 05 00 03 29 08 00 03 29 0C 00 03 +T 00 83 00 01 AC 00 00 AD 00 01 +R 00 00 00 08 29 02 00 03 29 05 00 01 29 08 00 01 +T 00 88 +R 00 00 00 08 +T 00 88 8C 82 8D 83 E0 F5 00 02 A3 E0 F5 00 03 A8 +R 00 00 00 08 29 08 00 03 29 0D 00 03 +T 00 94 00 02 A9 00 03 8C 02 8D 03 C3 E8 9A F8 E9 +R 00 00 00 08 29 02 00 03 29 05 00 03 +T 00 A0 9B F9 74 04 2C FA E4 3D FB 8A 82 8B 83 E0 +R 00 00 00 08 +T 00 AE FE A3 E0 FF C3 E8 9E F8 E9 9F F9 C3 E8 95 +R 00 00 00 08 +T 00 BC 00 00 E9 95 00 01 50 19 +R 00 00 00 08 29 02 00 03 29 06 00 03 +T 00 C2 +R 00 00 00 08 +T 00 C2 AC 00 02 AD 00 03 8C 82 8D 83 E0 F8 A3 E0 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 00 CE F9 48 60 03 02 00 88 +R 00 00 00 08 00 07 00 08 +T 00 D5 +R 00 00 00 08 +T 00 D5 90 00 00 02 01 58 +R 00 00 00 08 00 06 00 08 +T 00 DB +R 00 00 00 08 +T 00 DB EE 4F 70 19 +R 00 00 00 08 +T 00 DF +R 00 00 00 08 +T 00 DF 8A 82 8B 83 E5 00 00 F0 A3 E5 00 01 F0 74 +R 00 00 00 08 29 07 00 03 29 0C 00 03 +T 00 EB 06 2C FA E4 3D FB 8A 82 8B 83 02 01 58 +R 00 00 00 08 00 0D 00 08 +T 00 F8 +R 00 00 00 08 +T 00 F8 EE 2C FA EF 3D FB 8A 82 8B 83 E5 00 02 F0 +R 00 00 00 08 29 0D 00 03 +T 01 05 A3 E5 00 03 F0 74 02 2A F5 82 E4 3B F5 83 +R 00 00 00 08 29 04 00 03 +T 01 12 EC F0 A3 ED F0 8C 82 8D 83 EA F0 A3 EB F0 +R 00 00 00 08 +T 01 20 E5 00 02 45 00 03 60 17 +R 00 00 00 08 29 03 00 03 29 06 00 03 +T 01 26 +R 00 00 00 08 +T 01 26 8A 82 8B 83 E0 FC A3 E0 FD 74 02 2C F5 82 +R 00 00 00 08 +T 01 34 E4 3D F5 83 EA F0 A3 EB F0 +R 00 00 00 08 +T 01 3D +R 00 00 00 08 +T 01 3D 74 04 2A F5 82 E4 3B F5 83 E5 00 00 F0 A3 +R 00 00 00 08 29 0C 00 03 +T 01 4A E5 00 01 F0 74 06 2A FA E4 3B FB 8A 82 8B +R 00 00 00 08 29 03 00 03 +T 01 57 83 +R 00 00 00 08 +T 01 58 +R 00 00 00 08 +T 01 58 22 +R 00 00 00 08 +T 01 59 +R 00 00 00 08 +T 01 59 AA 82 AB 83 EA 4B 70 03 02 01 B2 +R 00 00 00 08 00 0B 00 08 +T 01 64 +R 00 00 00 08 +T 01 64 EA 24 FA FA EB 34 FF FB 74 02 2A FC E4 3B +R 00 00 00 08 +T 01 72 FD 8C 82 8D 83 E0 FC A3 E0 FD 4C 60 26 +R 00 00 00 08 +T 01 7F +R 00 00 00 08 +T 01 7F 8A 82 8B 83 E0 FE A3 E0 FF 8C 82 8D 83 EE +R 00 00 00 08 +T 01 8D F0 A3 EF F0 EE 4F 60 1D +R 00 00 00 08 +T 01 95 +R 00 00 00 08 +T 01 95 74 02 2E F5 82 E4 3F F5 83 EC F0 A3 ED F0 +R 00 00 00 08 +T 01 A3 80 0D +R 00 00 00 08 +T 01 A5 +R 00 00 00 08 +T 01 A5 74 04 2A F5 82 E4 3B F5 83 E4 F0 A3 F0 +R 00 00 00 08 +T 01 B2 +R 00 00 00 08 +T 01 B2 22 +R 00 00 00 08 diff --git a/device/lib/small/printf_large.cdb b/device/lib/small/printf_large.cdb new file mode 100644 index 00000000..fffbe4f8 --- /dev/null +++ b/device/lib/small/printf_large.cdb @@ -0,0 +1 @@ +M:printf_large diff --git a/device/lib/small/printfl.asm b/device/lib/small/printfl.asm new file mode 100644 index 00000000..1e7b8cd4 --- /dev/null +++ b/device/lib/small/printfl.asm @@ -0,0 +1,1111 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:19 2000 + +;-------------------------------------------------------- + .module printfl +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _printf_small +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +Fprintfl$ch$0$0==. +_ch: + .ds 0x0001 +Fprintfl$radix$0$0==. +_radix: + .ds 0x0001 +Fprintfl$str$0$0==. +_str: + .ds 0x0003 +Fprintfl$val$0$0==. +_val: + .ds 0x0004 +_pvalhex_val_1_1: + .ds 0x0004 +_pvalhex_sp_1_1: + .ds 0x0001 +_pvaloct_val_1_1: + .ds 0x0004 +_pvaloct_sp_1_1: + .ds 0x0001 +_pvaldec_val_1_1: + .ds 0x0004 +_pvaldec_sp_1_1: + .ds 0x0001 +_printf_small_sloc0_1_0: + .ds 0x0001 +_printf_small_sloc1_1_0: + .ds 0x0003 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +Fprintfl$long_flag$0$0==. +_long_flag: + .ds 0x0001 +Fprintfl$string_flag$0$0==. +_string_flag: + .ds 0x0001 +Fprintfl$short_flag$0$0==. +_short_flag: + .ds 0x0001 +Fprintfl$sign$0$0==. +_sign: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) + G$printf_small$0$0 ==. +; printfl.c 215 + clr _long_flag + G$printf_small$0$0 ==. +; printfl.c 215 + clr _string_flag + G$printf_small$0$0 ==. +; printfl.c 215 + clr _short_flag +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + Fprintfl$pvalhex$0$0 ==. +; printfl.c 53 +; ----------------------------------------- +; function pvalhex +; ----------------------------------------- +_pvalhex: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; printfl.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; printfl.c 55 + mov _pvalhex_sp_1_1,_SP +; printfl.c 56 + mov ar6,r2 + mov ar7,r3 + mov ar0,r4 + mov ar1,r5 +; printfl.c 58 +; Peephole 112 removed ljmp by inverse jump logic + jb _long_flag,00102$ +00119$: +; printfl.c 59 + mov ar6,r2 + mov ar7,r3 + mov r0,#0x00 + mov r1,#0x00 +00102$: +; printfl.c 61 +; Peephole 111 removed ljmp by inverse jump logic + jnb _short_flag,00116$ +00120$: +; printfl.c 62 + mov ar2,r6 + mov ar6,r2 + mov r7,#0x00 + mov r0,#0x00 + mov r1,#0x00 +; printfl.c 64 +00116$: +00105$: + mov a,r6 + orl a,r7 + orl a,r0 + orl a,r1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00121$: +; printfl.c 65 + mov ar2,r6 + anl ar2,#0x0f + mov a,r2 +; Peephole 180 changed mov to clr +; Peephole 186 optimized movc sequence + mov dptr,#__str_0 + movc a,@a+dptr + mov _ch,a +; printfl.c 66 + push _ch +; printfl.c 67 + mov a,r7 + swap a + xch a,r6 + swap a + anl a,#0x0f + xrl a,r6 + xch a,r6 + anl a,#0x0f + xch a,r6 + xrl a,r6 + xch a,r6 + mov r7,a + mov a,r0 + swap a + anl a,#0xf0 + orl a,r7 + mov r7,a + mov a,r1 + swap a + xch a,r0 + swap a + anl a,#0x0f + xrl a,r0 + xch a,r0 + anl a,#0x0f + xch a,r0 + xrl a,r0 + xch a,r0 + mov r1,a + ljmp 00105$ +; printfl.c 70 +00108$: + mov r2,_pvalhex_sp_1_1 + mov a,r2 + cjne a,_SP,00122$ +; Peephole 132 changed ljmp to sjmp + sjmp 00111$ +00122$: +; printfl.c 71 + pop _ch +; printfl.c 72 + mov dpl,_ch + lcall _putchar +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00111$: + C$printfl.c$75$1$1 ==. + XFprintfl$pvalhex$0$0 ==. + ret + Fprintfl$pvaloct$0$0 ==. +; printfl.c 77 +; ----------------------------------------- +; function pvaloct +; ----------------------------------------- +_pvaloct: +; printfl.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; printfl.c 81 + mov _pvaloct_sp_1_1,_SP +; printfl.c 82 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00102$ +00126$: +; printfl.c 83 + clr c + clr a + subb a,r2 + mov r7,a + clr a + subb a,r3 + mov r0,a + clr a + subb a,r4 + mov r1,a + clr a + subb a,r5 + mov r6,a +; printfl.c 84 + setb _sign +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: +; printfl.c 86 + mov ar7,r2 + mov ar0,r3 + mov ar1,r4 + mov ar6,r5 +; printfl.c 87 + clr _sign +00103$: +; printfl.c 90 +; Peephole 112 removed ljmp by inverse jump logic + jb _long_flag,00105$ +00127$: +; printfl.c 91 + mov r1,#0x00 + mov r6,#0x00 +00105$: +; printfl.c 92 +; Peephole 111 removed ljmp by inverse jump logic + jnb _short_flag,00108$ +00128$: +; printfl.c 93 + mov ar2,r7 + mov ar7,r2 + mov r0,#0x00 + mov r1,#0x00 + mov r6,#0x00 +; printfl.c 95 +00108$: + mov a,r7 + orl a,r0 + orl a,r1 + orl a,r6 + jnz 00129$ + ljmp 00110$ +00129$: +; printfl.c 96 + clr a + mov (__modulong_PARM_2 + 3),a + mov (__modulong_PARM_2 + 2),a + mov (__modulong_PARM_2 + 1),a + mov __modulong_PARM_2,#0x08 + push ar6 + push ar7 + push ar0 + push ar1 + mov dpl,r7 + mov dph,r0 + mov b,r1 + mov a,r6 + lcall __modulong + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a + pop ar1 + pop ar0 + pop ar7 + pop ar6 + mov a,#0x30 + add a,r2 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r3,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + mov r4,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov r5,a + mov _ch,r2 +; printfl.c 97 + push _ch +; printfl.c 98 + mov a,r0 + swap a + rl a + xch a,r7 + swap a + rl a + anl a,#0x1f + xrl a,r7 + xch a,r7 + anl a,#0x1f + xch a,r7 + xrl a,r7 + xch a,r7 + mov r0,a + mov a,r1 + swap a + rl a + anl a,#0xe0 + orl a,r0 + mov r0,a + mov a,r6 + swap a + rl a + xch a,r1 + swap a + rl a + anl a,#0x1f + xrl a,r1 + xch a,r1 + anl a,#0x1f + xch a,r1 + xrl a,r1 + xch a,r1 + mov r6,a + ljmp 00108$ +00110$: +; printfl.c 101 +; Peephole 111 removed ljmp by inverse jump logic + jnb _sign,00113$ +00130$: +; printfl.c 102 + mov _ch,#0x2d +; printfl.c 103 + push _ch +; printfl.c 107 +00113$: + mov r2,_pvaloct_sp_1_1 + mov a,r2 + cjne a,_SP,00131$ +; Peephole 132 changed ljmp to sjmp + sjmp 00116$ +00131$: +; printfl.c 108 + pop _ch +; printfl.c 109 + mov dpl,_ch + lcall _putchar +; Peephole 132 changed ljmp to sjmp + sjmp 00113$ +00116$: + C$printfl.c$111$1$1 ==. + XFprintfl$pvaloct$0$0 ==. + ret + Fprintfl$pvaldec$0$0 ==. +; printfl.c 113 +; ----------------------------------------- +; function pvaldec +; ----------------------------------------- +_pvaldec: +; printfl.c 0 + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a +; printfl.c 117 + mov _pvaldec_sp_1_1,_SP +; printfl.c 118 + mov a,r5 +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00102$ +00120$: +; printfl.c 119 + clr c + clr a + subb a,r2 + mov r7,a + clr a + subb a,r3 + mov r0,a + clr a + subb a,r4 + mov r1,a + clr a + subb a,r5 + mov r6,a +; printfl.c 120 + setb _sign +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; printfl.c 122 + mov ar7,r2 + mov ar0,r3 + mov ar1,r4 + mov ar6,r5 +; printfl.c 123 + clr _sign +; printfl.c 126 +00104$: + mov a,r7 + orl a,r0 + orl a,r1 + orl a,r6 + jnz 00121$ + ljmp 00106$ +00121$: +; printfl.c 127 + clr a + mov (__modulong_PARM_2 + 3),a + mov (__modulong_PARM_2 + 2),a + mov (__modulong_PARM_2 + 1),a + mov __modulong_PARM_2,#0x0a + push ar6 + push ar7 + push ar0 + push ar1 + mov dpl,r7 + mov dph,r0 + mov b,r1 + mov a,r6 + lcall __modulong + mov r2,dpl + mov r3,dph + mov r4,b + mov r5,a + pop ar1 + pop ar0 + pop ar7 + pop ar6 + mov a,#0x30 + add a,r2 + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r3,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + mov r4,a +; Peephole 180 changed mov to clr + clr a + addc a,r5 + mov r5,a + mov _ch,r2 +; printfl.c 128 + push _ch +; printfl.c 129 + clr a + mov (__divulong_PARM_2 + 3),a + mov (__divulong_PARM_2 + 2),a + mov (__divulong_PARM_2 + 1),a + mov __divulong_PARM_2,#0x0a + mov dpl,r7 + mov dph,r0 + mov b,r1 + mov a,r6 + lcall __divulong + mov r7,dpl + mov r0,dph + mov r1,b + mov r6,a + ljmp 00104$ +00106$: +; printfl.c 132 +; Peephole 111 removed ljmp by inverse jump logic + jnb _sign,00109$ +00122$: +; printfl.c 133 + mov _ch,#0x2d +; printfl.c 134 + push _ch +; printfl.c 138 +00109$: + mov r2,_pvaldec_sp_1_1 + mov a,r2 + cjne a,_SP,00123$ +; Peephole 132 changed ljmp to sjmp + sjmp 00112$ +00123$: +; printfl.c 139 + pop _ch +; printfl.c 140 + mov dpl,_ch + lcall _putchar +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00112$: + C$printfl.c$142$1$1 ==. + XFprintfl$pvaldec$0$0 ==. + ret + G$printf_small$0$0 ==. +; printfl.c 144 +; ----------------------------------------- +; function printf_small +; ----------------------------------------- +_printf_small: + push _bp + mov _bp,sp + inc sp +; printfl.c 148 + mov a,_bp + add a,#0xfb + mov r2,a +; Peephole 3.c changed mov to clr + clr a + mov r3,a + mov r4,a +; Peephole 212 reduced add sequence to inc + mov r0,_bp + inc r0 + mov @r0,ar2 +00129$: +; printfl.c 150 + mov a,_bp + add a,#0xfb + mov r0,a + mov ar3,@r0 + inc r0 + mov ar4,@r0 + inc r0 + mov ar5,@r0 + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r6,a + jnz 00154$ + ljmp 00133$ +00154$: +; printfl.c 151 + cjne r6,#0x25,00155$ + sjmp 00156$ +00155$: + ljmp 00127$ +00156$: +; printfl.c 152 + clr _short_flag + clr _string_flag + clr _long_flag +; printfl.c 153 + inc r3 + cjne r3,#0x00,00157$ + inc r4 +00157$: + mov a,_bp + add a,#0xfb + mov r0,a + mov @r0,ar3 + inc r0 + mov @r0,ar4 + inc r0 + mov @r0,ar5 +; printfl.c 154 + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget + mov r7,a + cjne r7,#0x68,00158$ +; Peephole 132 changed ljmp to sjmp + sjmp 00102$ +00158$: +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r7,#0x6c,00103$ +; Peephole 201 removed redundant sjmp +00159$: +00160$: +; printfl.c 156 + setb _long_flag +; printfl.c 157 + mov a,_bp + add a,#0xfb + mov r0,a + mov a,#0x01 + add a,r3 + mov @r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + inc r0 + mov @r0,a + inc r0 + mov @r0,ar5 +; printfl.c 158 +; printfl.c 160 +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00102$: + setb _short_flag +; printfl.c 161 + mov a,_bp + add a,#0xfb + mov r0,a + mov a,#0x01 + add a,r3 + mov @r0,a +; Peephole 180 changed mov to clr + clr a + addc a,r4 + inc r0 + mov @r0,a + inc r0 + mov @r0,ar5 +; printfl.c 162 +00103$: +; printfl.c 164 + mov a,_bp + add a,#0xfb + mov r0,a + mov ar3,@r0 + inc r0 + mov ar4,@r0 + inc r0 + mov ar5,@r0 + mov dpl,r3 + mov dph,r4 + mov b,r5 + lcall __gptrget + mov r3,a + cjne r3,#0x63,00161$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00161$: + cjne r3,#0x64,00162$ +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00162$: + cjne r3,#0x6f,00163$ +; Peephole 132 changed ljmp to sjmp + sjmp 00108$ +00163$: + cjne r3,#0x73,00164$ +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00164$: +; Peephole 132 changed ljmp to sjmp +; printfl.c 166 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r3,#0x78,00109$ + sjmp 00106$ +00165$: +00104$: + setb _string_flag +; printfl.c 167 +; printfl.c 169 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00105$: + mov _radix,#0x0a +; printfl.c 170 +; printfl.c 172 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00106$: + mov _radix,#0x10 +; printfl.c 173 +; printfl.c 175 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00107$: + mov _radix,#0x00 +; printfl.c 176 +; printfl.c 178 +; Peephole 132 changed ljmp to sjmp + sjmp 00109$ +00108$: + mov _radix,#0x08 +; printfl.c 180 +00109$: +; printfl.c 182 + jb _string_flag,00166$ + ljmp 00114$ +00166$: +; printfl.c 183 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xfd + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov _str,@r0 + inc r0 + mov (_str + 1),@r0 + inc r0 + mov (_str + 2),@r0 + dec r0 + dec r0 +; printfl.c 184 +00110$: + mov _printf_small_sloc1_1_0,_str + mov (_printf_small_sloc1_1_0 + 1),(_str + 1) + mov (_printf_small_sloc1_1_0 + 2),(_str + 2) + mov dpl,_printf_small_sloc1_1_0 + mov dph,(_printf_small_sloc1_1_0 + 1) + mov b,(_printf_small_sloc1_1_0 + 2) + lcall __gptrget +; Peephole 105 removed redundant mov + mov _printf_small_sloc0_1_0,a + jnz 00167$ + ljmp 00131$ +00167$: + mov dpl,_str + mov dph,(_str + 1) + mov b,(_str + 2) + mov a,#0x01 + add a,_str + mov r2,a +; Peephole 180 changed mov to clr + clr a + addc a,(_str + 1) + mov r7,a + mov r3,(_str + 2) + mov _str,r2 + mov (_str + 1),r7 + mov (_str + 2),r3 + lcall __gptrget + mov r4,a + push ar2 + push ar3 + push ar4 + push ar6 + push ar7 + mov dpl,r4 + lcall _putchar + pop ar7 + pop ar6 + pop ar4 + pop ar3 + pop ar2 +; printfl.c 185 +; Peephole 132 changed ljmp to sjmp + sjmp 00110$ +00114$: +; printfl.c 188 +; Peephole 111 removed ljmp by inverse jump logic + jnb _long_flag,00119$ +00168$: +; printfl.c 189 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xfc + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov _val,@r0 + inc r0 + mov (_val + 1),@r0 + inc r0 + mov (_val + 2),@r0 + inc r0 + mov (_val + 3),@r0 + dec r0 + dec r0 + dec r0 +; Peephole 132 changed ljmp to sjmp + sjmp 00120$ +00119$: +; printfl.c 191 +; Peephole 111 removed ljmp by inverse jump logic + jnb _short_flag,00116$ +00169$: +; printfl.c 192 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xff + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov ar2,@r0 + mov _val,r2 + mov a,r2 + rlc a + subb a,acc + mov (_val + 1),a + mov (_val + 2),a + mov (_val + 3),a +; Peephole 132 changed ljmp to sjmp + sjmp 00120$ +00116$: +; printfl.c 194 +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov a,@r1 + add a,#0xfe + mov r0,a +; Peephole 212 reduced add sequence to inc + mov r1,_bp + inc r1 + mov @r1,ar0 + mov ar2,@r0 + inc r0 + mov ar3,@r0 + dec r0 + mov _val,r2 + mov (_val + 1),r3 + mov a,r3 + rlc a + subb a,acc + mov (_val + 2),a + mov (_val + 3),a +00120$: +; printfl.c 196 + mov a,_radix +; Peephole 110 removed ljmp by inverse jump logic + jz 00123$ +00170$: + mov a,_radix + cjne a,#0x08,00171$ +; Peephole 132 changed ljmp to sjmp + sjmp 00124$ +00171$: + mov a,_radix + cjne a,#0x0a,00172$ +; Peephole 132 changed ljmp to sjmp + sjmp 00121$ +00172$: + mov a,_radix +; Peephole 132 changed ljmp to sjmp +; printfl.c 198 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,#0x10,00131$ + sjmp 00122$ +00173$: +00121$: + push ar6 + mov dpl,_val + mov dph,(_val + 1) + mov b,(_val + 2) + mov a,(_val + 3) + lcall _pvaldec + pop ar6 +; printfl.c 199 +; printfl.c 201 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00122$: + push ar6 + mov dpl,_val + mov dph,(_val + 1) + mov b,(_val + 2) + mov a,(_val + 3) + lcall _pvalhex + pop ar6 +; printfl.c 202 +; printfl.c 204 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00123$: + mov dpl,_val + push ar6 + lcall _putchar + pop ar6 +; printfl.c 205 +; printfl.c 207 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00124$: + push ar6 + mov dpl,_val + mov dph,(_val + 1) + mov b,(_val + 2) + mov a,(_val + 3) + lcall _pvaloct + pop ar6 +; printfl.c 209 +; Peephole 132 changed ljmp to sjmp + sjmp 00131$ +00127$: +; printfl.c 212 + mov dpl,r6 + lcall _putchar +00131$: +; printfl.c 150 + mov a,_bp + add a,#0xfb + mov r0,a + inc @r0 + cjne @r0,#0x00,00174$ + inc r0 + inc @r0 +00174$: + ljmp 00129$ +00133$: + mov sp,_bp + pop _bp + C$printfl.c$214$1$1 ==. + XG$printf_small$0$0 ==. + ret + .area CSEG (CODE) +Fprintfl$_str_0$0$0 == . +__str_0: + .ascii /0123456789ABCDEF/ + .byte 0 diff --git a/device/lib/small/printfl.cdb b/device/lib/small/printfl.cdb new file mode 100644 index 00000000..88a9e658 --- /dev/null +++ b/device/lib/small/printfl.cdb @@ -0,0 +1,100 @@ +M:printfl +F:Fprintfl$pvalhex$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fprintfl$pvaloct$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fprintfl$pvaldec$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$ch$0$0({1}SC:S),E,0,0 +S:Fprintfl$radix$0$0({1}SC:S),E,0,0 +S:Fprintfl$str$0$0({3}DG,SC:S),E,0,0 +S:Fprintfl$val$0$0({4}SL:S),E,0,0 +S:Fprintfl$long_flag$0$0({1}SB0$1:S),H,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$string_flag$0$0({1}SB0$1:S),H,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$short_flag$0$0({1}SB0$1:S),H,0,0 +F:G$printf_small$0$0({2}DF,SV:S),C,0,1,0,0,0 +S:Fprintfl$sign$0$0({1}SB0$1:S),H,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 +S:Fprintfl$_str_0$0$0({17}DA17,SC:S),D,0,0 diff --git a/device/lib/small/printfl.rel b/device/lib/small/printfl.rel new file mode 100644 index 00000000..24ae91c5 --- /dev/null +++ b/device/lib/small/printfl.rel @@ -0,0 +1,1165 @@ +;!FILE printfl.asm +XH +H 8 areas 2AB global symbols +M printfl +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S __modulong_PARM_2 Ref0000 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S __divulong_PARM_2 Ref0000 +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S _putchar Ref0000 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S __modulong Ref0000 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S __divulong Ref0000 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S _bp Ref0000 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 1C flags 0 +S Fprintfl$radix$0$0 Def0001 +S Fprintfl$str$0$0 Def0002 +S Fprintfl$val$0$0 Def0005 +S Fprintfl$ch$0$0 Def0000 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 4 flags 80 +S Fprintfl$string_flag$0$0 Def0001 +S Fprintfl$short_flag$0$0 Def0002 +S Fprintfl$long_flag$0$0 Def0000 +S Fprintfl$sign$0$0 Def0003 +A XSEG size 0 flags 40 +A GSINIT size 6 flags 20 +S A$printfl$252 Def0002 +S A$printfl$255 Def0004 +S A$printfl$249 Def0000 +A CSEG size 40A flags 20 +S A$printfl$710 Def01F3 +S A$printfl$620 Def0187 +S A$printfl$611 Def0174 +S A$printfl$602 Def0168 +S A$printfl$521 Def011B +S A$printfl$512 Def0110 +S A$printfl$503 Def0106 +S A$printfl$404 Def008C +S A$printfl$350 Def0058 +S A$printfl$341 Def004D +S A$printfl$332 Def0042 +S A$printfl$323 Def0039 +S A$printfl$314 Def002E +S A$printfl$305 Def0028 +S A$printfl$900 Def02D4 +S A$printfl$810 Def026C +S A$printfl$801 Def0265 +S A$printfl$720 Def0200 +S A$printfl$711 Def01F5 +S A$printfl$702 Def01EB +S A$printfl$630 Def019A +S A$printfl$621 Def0188 +S A$printfl$612 Def0176 +S A$printfl$603 Def0169 +S A$printfl$522 Def011C +S A$printfl$513 Def0111 +S A$printfl$504 Def0107 +S A$printfl$450 Def00BC +S A$printfl$432 Def00A6 +S A$printfl$405 Def008D +S A$printfl$360 Def0063 +S A$printfl$351 Def0059 +S A$printfl$342 Def004E +S A$printfl$333 Def0044 +S A$printfl$324 Def003A +S A$printfl$910 Def02EA +S A$printfl$901 Def02D7 +S A$printfl$820 Def027D +S A$printfl$811 Def026E +S A$printfl$802 Def0266 +S A$printfl$730 Def0211 +S A$printfl$721 Def0202 +S A$printfl$712 Def01F6 +S A$printfl$703 Def01ED +S A$printfl$640 Def01A3 +S A$printfl$631 Def019C +S A$printfl$622 Def018B +S A$printfl$613 Def0179 +S A$printfl$604 Def016A +S A$printfl$541 Def0130 +S A$printfl$532 Def0125 +S A$printfl$523 Def011D +S A$printfl$514 Def0112 +S A$printfl$505 Def0108 +S A$printfl$460 Def00D0 +S A$printfl$451 Def00BD +S A$printfl$442 Def00B3 +S A$printfl$424 Def009F +S A$printfl$415 Def0095 +S A$printfl$406 Def008E +S A$printfl$370 Def0070 +S A$printfl$361 Def0065 +S A$printfl$352 Def005A +S A$printfl$343 Def0050 +S A$printfl$334 Def0045 +S A$printfl$280 Def0007 +S A$printfl$920 Def02FC +S A$printfl$911 Def02ED +S A$printfl$902 Def02DA +S A$printfl$821 Def027F +S A$printfl$812 Def0270 +S A$printfl$803 Def0267 +S A$printfl$740 Def021E +S A$printfl$722 Def0203 +S A$printfl$704 Def01EF +S A$printfl$650 Def01AC +S A$printfl$632 Def019D +S A$printfl$623 Def018D +S A$printfl$614 Def017B +S A$printfl$605 Def016C +S A$printfl$524 Def011E +S A$printfl$515 Def0113 +S A$printfl$506 Def0109 +S A$printfl$470 Def00E3 +S A$printfl$461 Def00D2 +S A$printfl$452 Def00BF +S A$printfl$443 Def00B4 +S A$printfl$416 Def0097 +S A$printfl$407 Def008F +S A$printfl$362 Def0066 +S A$printfl$353 Def005C +S A$printfl$344 Def0051 +S A$printfl$335 Def0046 +S A$printfl$326 Def003C +S A$printfl$317 Def0030 +S A$printfl$930 Def0310 +S A$printfl$921 Def02FE +S A$printfl$912 Def02F0 +S A$printfl$903 Def02DD +S A$printfl$831 Def028D +S A$printfl$822 Def0282 +S A$printfl$813 Def0271 +S A$printfl$804 Def0268 +S A$printfl$750 Def022C +S A$printfl$741 Def0220 +S A$printfl$723 Def0205 +S A$printfl$660 Def01C1 +S A$printfl$651 Def01AE +S A$printfl$642 Def01A4 +S A$printfl$624 Def018F +S A$printfl$615 Def017D +S A$printfl$570 Def0148 +S A$printfl$561 Def013D +S A$printfl$534 Def0128 +S A$printfl$525 Def011F +S A$printfl$516 Def0114 +S A$printfl$507 Def010A +S A$printfl$480 Def00EE +S A$printfl$471 Def00E5 +S A$printfl$462 Def00D4 +S A$printfl$453 Def00C1 +S A$printfl$444 Def00B5 +S A$printfl$435 Def00A9 +S A$printfl$417 Def0099 +S A$printfl$408 Def0090 +S A$printfl$372 Def0073 +S A$printfl$354 Def005D +S A$printfl$345 Def0052 +S A$printfl$336 Def0048 +S A$printfl$318 Def0032 +S A$printfl$309 Def002A +S A$printfl$291 Def0015 +S A$printfl$282 Def000A +S A$printfl$940 Def0321 +S A$printfl$931 Def0312 +S A$printfl$922 Def0300 +S A$printfl$913 Def02F3 +S A$printfl$904 Def02E0 +S A$printfl$823 Def0283 +S A$printfl$814 Def0273 +S A$printfl$805 Def0269 +S A$printfl$760 Def023D +S A$printfl$751 Def022E +S A$printfl$733 Def0214 +S A$printfl$724 Def0207 +S A$printfl$715 Def01F8 +S A$printfl$706 Def01F0 +S A$printfl$670 Def01CC +S A$printfl$661 Def01C3 +S A$printfl$652 Def01B0 +S A$printfl$643 Def01A5 +S A$printfl$634 Def019E +S A$printfl$625 Def0191 +S A$printfl$616 Def017F +S A$printfl$580 Def0152 +S A$printfl$562 Def013F +S A$printfl$553 Def013C +S A$printfl$544 Def0132 +S A$printfl$517 Def0115 +S A$printfl$508 Def010B +S A$printfl$481 Def00EF +S A$printfl$472 Def00E7 +S A$printfl$463 Def00D5 +S A$printfl$454 Def00C3 +S A$printfl$445 Def00B6 +S A$printfl$436 Def00AB +S A$printfl$427 Def00A2 +S A$printfl$418 Def009B +S A$printfl$391 Def0080 +S A$printfl$364 Def0069 +S A$printfl$355 Def005E +S A$printfl$346 Def0053 +S A$printfl$337 Def0049 +S A$printfl$328 Def003E +S A$printfl$319 Def0035 +S A$printfl$292 Def0017 +S A$printfl$283 Def000C +S A$printfl$950 Def0329 +S A$printfl$932 Def0314 +S A$printfl$923 Def0302 +S A$printfl$914 Def02F5 +S A$printfl$851 Def029E +S A$printfl$833 Def0290 +S A$printfl$815 Def0274 +S A$printfl$806 Def026A +S A$printfl$761 Def023E +S A$printfl$752 Def022F +S A$printfl$743 Def0222 +S A$printfl$734 Def0217 +S A$printfl$725 Def0209 +S A$printfl$716 Def01FA +S A$printfl$707 Def01F1 +S A$printfl$662 Def01C5 +S A$printfl$653 Def01B2 +S A$printfl$644 Def01A6 +S A$printfl$635 Def019F +S A$printfl$626 Def0192 +S A$printfl$617 Def0181 +S A$printfl$608 Def016F +S A$printfl$581 Def0153 +S A$printfl$563 Def0141 +S A$printfl$518 Def0117 +S A$printfl$509 Def010D +S A$printfl$491 Def00F8 +S A$printfl$482 Def00F0 +S A$printfl$473 Def00E9 +S A$printfl$464 Def00D8 +S A$printfl$455 Def00C6 +S A$printfl$446 Def00B7 +S A$printfl$437 Def00AD +S A$printfl$428 Def00A4 +S A$printfl$356 Def005F +S A$printfl$347 Def0054 +S A$printfl$338 Def004A +S A$printfl$329 Def003F +S A$printfl$293 Def0019 +S A$printfl$284 Def000E +S A$printfl$275 Def0000 +S A$printfl$960 Def0337 +S A$printfl$951 Def032A +S A$printfl$933 Def0317 +S A$printfl$924 Def0304 +S A$printfl$915 Def02F7 +S A$printfl$906 Def02E3 +S A$printfl$843 Def0297 +S A$printfl$825 Def0286 +S A$printfl$816 Def0276 +S A$printfl$753 Def0231 +S A$printfl$744 Def0223 +S A$printfl$726 Def020B +S A$printfl$717 Def01FC +S A$printfl$708 Def01F2 +S A$printfl$672 Def01CF +S A$printfl$663 Def01C6 +S A$printfl$654 Def01B5 +S A$printfl$645 Def01A7 +S A$printfl$636 Def01A0 +S A$printfl$627 Def0194 +S A$printfl$618 Def0183 +S A$printfl$609 Def0170 +S A$printfl$582 Def0154 +S A$printfl$573 Def014B +S A$printfl$564 Def0143 +S A$printfl$546 Def0134 +S A$printfl$537 Def012A +S A$printfl$519 Def0118 +S A$printfl$492 Def00F9 +S A$printfl$474 Def00EA +S A$printfl$465 Def00DA +S A$printfl$456 Def00C8 +S A$printfl$447 Def00B9 +S A$printfl$438 Def00AF +S A$printfl$393 Def0081 +S A$printfl$384 Def0076 +S A$printfl$357 Def0060 +S A$printfl$348 Def0055 +S A$printfl$339 Def004B +S A$printfl$294 Def001B +S A$printfl$285 Def0010 +S A$printfl$276 Def0002 +S A$printfl$961 Def0338 +S A$printfl$952 Def032C +S A$printfl$934 Def0319 +S A$printfl$925 Def0307 +S A$printfl$907 Def02E5 +S A$printfl$880 Def02B8 +S A$printfl$871 Def02AF +S A$printfl$853 Def02A0 +S A$printfl$844 Def029A +S A$printfl$835 Def0292 +S A$printfl$817 Def0277 +S A$printfl$790 Def0258 +S A$printfl$781 Def0251 +S A$printfl$772 Def0246 +S A$printfl$763 Def0241 +S A$printfl$754 Def0232 +S A$printfl$745 Def0226 +S A$printfl$736 Def0219 +S A$printfl$718 Def01FD +S A$printfl$691 Def01E3 +S A$printfl$682 Def01D9 +S A$printfl$655 Def01B7 +S A$printfl$628 Def0196 +S A$printfl$619 Def0185 +S A$printfl$592 Def015C +S A$printfl$583 Def0155 +S A$printfl$574 Def014C +S A$printfl$547 Def0137 +S A$printfl$538 Def012C +S A$printfl$529 Def0122 +S A$printfl$493 Def00FA +S A$printfl$484 Def00F1 +S A$printfl$466 Def00DC +S A$printfl$457 Def00CA +S A$printfl$439 Def00B1 +S A$printfl$385 Def0078 +S A$printfl$376 Def0075 +S A$printfl$367 Def006B +S A$printfl$349 Def0056 +S A$printfl$277 Def0004 +S XFprintfl$pvaldec$0$0 Def01E3 +S A$printfl$980 Def034B +S A$printfl$962 Def033A +S A$printfl$944 Def0323 +S A$printfl$935 Def031B +S A$printfl$926 Def0308 +S A$printfl$917 Def02F8 +S A$printfl$908 Def02E7 +S A$printfl$890 Def02C6 +S A$printfl$881 Def02BA +S A$printfl$863 Def02A8 +S A$printfl$827 Def0288 +S A$printfl$818 Def0279 +S A$printfl$782 Def0252 +S A$printfl$728 Def020E +S A$printfl$719 Def01FF +S A$printfl$656 Def01B9 +S A$printfl$647 Def01A9 +S A$printfl$638 Def01A1 +S A$printfl$629 Def0198 +S A$printfl$593 Def015E +S A$printfl$584 Def0156 +S A$printfl$575 Def014D +S A$printfl$566 Def0144 +S A$printfl$539 Def012D +S A$printfl$494 Def00FB +S A$printfl$485 Def00F2 +S A$printfl$476 Def00EB +S A$printfl$467 Def00DE +S A$printfl$458 Def00CC +S A$printfl$386 Def007A +S A$printfl$278 Def0006 +S A$printfl$990 Def0359 +S A$printfl$972 Def0342 +S A$printfl$963 Def033B +S A$printfl$954 Def032D +S A$printfl$936 Def031D +S A$printfl$927 Def030A +S A$printfl$918 Def02F9 +S A$printfl$891 Def02C7 +S A$printfl$882 Def02BB +S A$printfl$837 Def0295 +S A$printfl$819 Def027B +S A$printfl$792 Def025A +S A$printfl$783 Def0253 +S A$printfl$774 Def0248 +S A$printfl$756 Def0234 +S A$printfl$747 Def0227 +S A$printfl$729 Def020F +S A$printfl$684 Def01DB +S A$printfl$675 Def01D1 +S A$printfl$657 Def01BB +S A$printfl$639 Def01A2 +S A$printfl$594 Def0160 +S A$printfl$585 Def0157 +S A$printfl$576 Def014E +S A$printfl$549 Def013A +S A$printfl$495 Def00FC +S A$printfl$486 Def00F3 +S A$printfl$477 Def00EC +S A$printfl$468 Def00DF +S A$printfl$459 Def00CE +S A$printfl$396 Def0084 +S A$printfl$387 Def007C +S A$printfl$369 Def006D +S A$printfl$288 Def0012 +S A$printfl$991 Def035B +S A$printfl$982 Def034C +S A$printfl$964 Def033D +S A$printfl$955 Def032F +S A$printfl$937 Def031F +S A$printfl$928 Def030C +S A$printfl$919 Def02FB +S A$printfl$892 Def02C9 +S A$printfl$883 Def02BC +S A$printfl$865 Def02AA +S A$printfl$847 Def029C +S A$printfl$829 Def028B +S A$printfl$784 Def0254 +S A$printfl$775 Def024A +S A$printfl$757 Def0236 +S A$printfl$748 Def0229 +S A$printfl$739 Def021C +S A$printfl$685 Def01DE +S A$printfl$676 Def01D3 +S A$printfl$667 Def01C9 +S A$printfl$658 Def01BC +S A$printfl$649 Def01AB +S A$printfl$595 Def0162 +S A$printfl$577 Def014F +S A$printfl$568 Def0147 +S A$printfl$496 Def00FD +S A$printfl$487 Def00F4 +S A$printfl$478 Def00ED +S A$printfl$469 Def00E1 +S A$printfl$397 Def0085 +S A$printfl$298 Def001D +S A$printfl$992 Def035D +S A$printfl$983 Def034E +S A$printfl$965 Def033E +S A$printfl$956 Def0330 +S A$printfl$929 Def030E +S A$printfl$893 Def02CA +S A$printfl$884 Def02BE +S A$printfl$875 Def02B2 +S A$printfl$857 Def02A3 +S A$printfl$794 Def025C +S A$printfl$785 Def0255 +S A$printfl$776 Def024C +S A$printfl$767 Def0243 +S A$printfl$758 Def0238 +S A$printfl$749 Def022B +S A$printfl$677 Def01D4 +S A$printfl$659 Def01BF +S A$printfl$587 Def0158 +S A$printfl$578 Def0150 +S A$printfl$497 Def00FE +S A$printfl$398 Def0086 +S A$printfl$389 Def007D +S A$printfl$984 Def034F +S A$printfl$966 Def033F +S A$printfl$957 Def0332 +S A$printfl$948 Def0326 +S A$printfl$894 Def02CC +S A$printfl$876 Def02B5 +S A$printfl$795 Def025E +S A$printfl$786 Def0256 +S A$printfl$777 Def024D +S A$printfl$759 Def023A +S A$printfl$687 Def01E1 +S A$printfl$597 Def0164 +S A$printfl$579 Def0151 +S A$printfl$498 Def0100 +S A$printfl$489 Def00F6 +S A$printfl$399 Def0087 +S A$printfl$994 Def035F +S A$printfl$985 Def0351 +S A$printfl$976 Def0345 +S A$printfl$958 Def0334 +S A$printfl$949 Def0328 +S A$printfl$895 Def02CD +S A$printfl$886 Def02BF +S A$printfl$859 Def02A5 +S A$printfl$796 Def0260 +S A$printfl$778 Def024F +S A$printfl$679 Def01D7 +S A$printfl$589 Def015A +S A$printfl$499 Def0101 +S A$printfl$986 Def0353 +S A$printfl$977 Def0347 +S A$printfl$968 Def0340 +S A$printfl$959 Def0335 +S A$printfl$887 Def02C1 +S A$printfl$869 Def02AD +S A$printfl$797 Def0261 +S A$printfl$779 Def0250 +S A$printfl$698 Def01E4 +S A$printfl$987 Def0355 +S A$printfl$978 Def0348 +S A$printfl$888 Def02C2 +S A$printfl$798 Def0263 +S A$printfl$699 Def01E6 +S Fprintfl$pvaldec$0$0 Def013D +S A$printfl$988 Def0356 +S A$printfl$979 Def0349 +S A$printfl$898 Def02CE +S A$printfl$889 Def02C4 +S A$printfl$799 Def0264 +S C$printfl.c$75$1$1 Def0075 +S A$printfl$998 Def0361 +S A$printfl$989 Def0357 +S A$printfl$899 Def02D1 +S A$printfl$999 Def0363 +S XFprintfl$pvalhex$0$0 Def0075 +S XFprintfl$pvaloct$0$0 Def013C +S A$printfl$1000 Def0364 +S Fprintfl$pvalhex$0$0 Def0000 +S A$printfl$1100 Def03F0 +S A$printfl$1010 Def0372 +S A$printfl$1001 Def0365 +S Fprintfl$pvaloct$0$0 Def0076 +S _printf_small Def01E4 +S A$printfl$1020 Def037F +S A$printfl$1011 Def0373 +S A$printfl$1002 Def0367 +S A$printfl$1102 Def03F3 +S A$printfl$1030 Def038C +S A$printfl$1012 Def0375 +S A$printfl$1103 Def03F6 +S A$printfl$1040 Def0396 +S A$printfl$1022 Def0381 +S A$printfl$1013 Def0377 +S A$printfl$1004 Def0368 +S A$printfl$1032 Def038F +S A$printfl$1014 Def0378 +S A$printfl$1005 Def036A +S A$printfl$1060 Def03B9 +S A$printfl$1024 Def0383 +S A$printfl$1015 Def0379 +S A$printfl$1006 Def036B +S A$printfl$1106 Def03F8 +S A$printfl$1070 Def03C8 +S A$printfl$1061 Def03BC +S A$printfl$1043 Def0398 +S A$printfl$1034 Def0391 +S A$printfl$1025 Def0385 +S A$printfl$1016 Def037B +S A$printfl$1007 Def036D +S A$printfl$1080 Def03D7 +S A$printfl$1053 Def03AA +S A$printfl$1044 Def039A +S A$printfl$1017 Def037D +S A$printfl$1008 Def036F +S A$printfl$1081 Def03D9 +S A$printfl$1045 Def039D +S A$printfl$1027 Def0388 +S A$printfl$1009 Def0370 +S A$printfl$1082 Def03DC +S A$printfl$1055 Def03AC +S A$printfl$1046 Def03A0 +S A$printfl$1092 Def03E5 +S A$printfl$1074 Def03CA +S A$printfl$1065 Def03BE +S A$printfl$1056 Def03AE +S A$printfl$1047 Def03A3 +S A$printfl$1029 Def038A +S A$printfl$1093 Def03E7 +S A$printfl$1057 Def03B1 +S A$printfl$1048 Def03A5 +S A$printfl$1039 Def0393 +S A$printfl$1094 Def03E9 +S A$printfl$1085 Def03DE +S A$printfl$1076 Def03CC +S A$printfl$1067 Def03C0 +S A$printfl$1058 Def03B4 +S A$printfl$1049 Def03A8 +S XG$printf_small$0$0 Def03F8 +S A$printfl$1095 Def03EA +S A$printfl$1077 Def03CE +S A$printfl$1068 Def03C3 +S A$printfl$1059 Def03B7 +S A$printfl$1096 Def03EB +S A$printfl$1078 Def03D1 +S A$printfl$1069 Def03C5 +S Fprintfl$_str_0$0$0 Def03F9 +S C$printfl.c$111$1$1 Def013C +S A$printfl$1097 Def03EE +S A$printfl$1088 Def03E0 +S A$printfl$1079 Def03D4 +S A$printfl$1098 Def03EF +S A$printfl$1089 Def03E2 +S A$printfl$400 Def0088 +S A$printfl$310 Def002B +S A$printfl$301 Def0020 +S C$printfl.c$214$1$1 Def03F8 +S C$printfl.c$142$1$1 Def01E3 +S A$printfl$500 Def0102 +S A$printfl$410 Def0091 +S A$printfl$401 Def0089 +S A$printfl$311 Def002C +S A$printfl$302 Def0022 +S A$printfl$600 Def0166 +S A$printfl$510 Def010E +S A$printfl$501 Def0104 +S A$printfl$420 Def009D +S A$printfl$402 Def008A +S A$printfl$330 Def0040 +S A$printfl$312 Def002D +S A$printfl$303 Def0024 +S G$printf_small$0$0 Def01E4 +S A$printfl$700 Def01E9 +S A$printfl$610 Def0172 +S A$printfl$601 Def0167 +S A$printfl$520 Def0119 +S A$printfl$511 Def010F +S A$printfl$502 Def0105 +S A$printfl$412 Def0093 +S A$printfl$403 Def008B +S A$printfl$340 Def004C +S A$printfl$331 Def0041 +S A$printfl$322 Def0036 +S A$printfl$304 Def0026 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 01 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 02 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 05 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 17 +R 00 00 00 01 +T 00 17 +R 00 00 00 01 +T 00 18 +R 00 00 00 01 +T 00 18 +R 00 00 00 01 +T 00 19 +R 00 00 00 01 +T 00 19 +R 00 00 00 01 +T 00 00 +R 00 00 00 04 +T 00 00 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 01 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 02 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 03 +R 00 00 00 04 +T 00 00 C2 00 00 C2 00 01 C2 00 02 +R 00 00 00 06 29 03 00 04 29 06 00 04 29 09 00 04 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 FD 85 81 00 0D 8A 06 8B +R 00 00 00 07 29 0B 00 01 +T 00 0D 07 8C 00 8D 01 20 00 00 08 +R 00 00 00 07 29 08 00 04 +T 00 15 +R 00 00 00 07 +T 00 15 8A 06 8B 07 78 00 79 00 +R 00 00 00 07 +T 00 1D +R 00 00 00 07 +T 00 1D 30 00 02 0A +R 00 00 00 07 29 03 00 04 +T 00 20 +R 00 00 00 07 +T 00 20 8E 02 8A 06 7F 00 78 00 79 00 +R 00 00 00 07 +T 00 2A +R 00 00 00 07 +T 00 2A +R 00 00 00 07 +T 00 2A EE 4F 48 49 60 33 +R 00 00 00 07 +T 00 30 +R 00 00 00 07 +T 00 30 8E 02 53 02 0F EA 90 03 F9 93 F5 00 00 C0 +R 00 00 00 07 00 09 00 07 29 0D 00 01 +T 00 3D 00 00 EF C4 CE C4 54 0F 6E CE 54 0F CE 6E +R 00 00 00 07 29 02 00 01 +T 00 4A CE FF E8 C4 54 F0 4F FF E9 C4 C8 C4 54 0F +R 00 00 00 07 +T 00 58 68 C8 54 0F C8 68 C8 F9 02 00 2A +R 00 00 00 07 00 0B 00 07 +T 00 63 +R 00 00 00 07 +T 00 63 AA 00 0D EA B5 81 02 80 0A +R 00 00 00 07 29 03 00 01 +T 00 6B +R 00 00 00 07 +T 00 6B D0 00 00 85 00 00 82 12 00 00 80 EE +R 00 00 00 07 29 03 00 01 29 06 00 01 02 0A 00 24 +T 00 75 +R 00 00 00 07 +T 00 75 22 +R 00 00 00 07 +T 00 76 +R 00 00 00 07 +T 00 76 AA 82 AB 83 AC F0 FD 85 81 00 12 ED 30 E7 +R 00 00 00 07 29 0B 00 01 +T 00 83 11 +R 00 00 00 07 +T 00 84 +R 00 00 00 07 +T 00 84 C3 E4 9A FF E4 9B F8 E4 9C F9 E4 9D FE D2 +R 00 00 00 07 +T 00 92 00 03 80 0A +R 00 00 00 07 29 02 00 04 +T 00 95 +R 00 00 00 07 +T 00 95 8A 07 8B 00 8C 01 8D 06 C2 00 03 +R 00 00 00 07 29 0B 00 04 +T 00 9F +R 00 00 00 07 +T 00 9F 20 00 00 04 +R 00 00 00 07 29 03 00 04 +T 00 A2 +R 00 00 00 07 +T 00 A2 79 00 7E 00 +R 00 00 00 07 +T 00 A6 +R 00 00 00 07 +T 00 A6 30 00 02 0A +R 00 00 00 07 29 03 00 04 +T 00 A9 +R 00 00 00 07 +T 00 A9 8F 02 8A 07 78 00 79 00 7E 00 +R 00 00 00 07 +T 00 B3 +R 00 00 00 07 +T 00 B3 EF 48 49 4E 70 03 02 01 22 +R 00 00 00 07 00 09 00 07 +T 00 BC +R 00 00 00 07 +T 00 BC E4 F5 00 03 F5 00 02 F5 00 01 75 +R 00 00 00 07 2B 04 00 08 2B 07 00 08 2B 0A 00 08 +T 00 C4 00 00 08 C0 06 C0 07 C0 00 C0 01 8F 82 88 +R 00 00 00 07 2B 02 00 08 +T 00 D1 83 89 F0 EE 12 00 00 AA 82 AB 83 AC F0 FD +R 00 00 00 07 02 07 00 2E +T 00 DF D0 01 D0 00 D0 07 D0 06 74 30 2A FA E4 3B +R 00 00 00 07 +T 00 ED FB E4 3C FC E4 3D FD 8A 00 00 C0 00 00 E8 +R 00 00 00 07 29 0A 00 01 29 0D 00 01 +T 00 F9 C4 23 CF C4 23 54 1F 6F CF 54 1F CF 6F CF +R 00 00 00 07 +T 01 07 F8 E9 C4 23 54 E0 48 F8 EE C4 23 C9 C4 23 +R 00 00 00 07 +T 01 15 54 1F 69 C9 54 1F C9 69 C9 FE 02 00 B3 +R 00 00 00 07 00 0D 00 07 +T 01 22 +R 00 00 00 07 +T 01 22 30 00 03 05 +R 00 00 00 07 29 03 00 04 +T 01 25 +R 00 00 00 07 +T 01 25 75 00 00 2D C0 00 00 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 01 2A +R 00 00 00 07 +T 01 2A AA 00 12 EA B5 81 02 80 0A +R 00 00 00 07 29 03 00 01 +T 01 32 +R 00 00 00 07 +T 01 32 D0 00 00 85 00 00 82 12 00 00 80 EE +R 00 00 00 07 29 03 00 01 29 06 00 01 02 0A 00 24 +T 01 3C +R 00 00 00 07 +T 01 3C 22 +R 00 00 00 07 +T 01 3D +R 00 00 00 07 +T 01 3D AA 82 AB 83 AC F0 FD 85 81 00 17 ED 30 E7 +R 00 00 00 07 29 0B 00 01 +T 01 4A 11 +R 00 00 00 07 +T 01 4B +R 00 00 00 07 +T 01 4B C3 E4 9A FF E4 9B F8 E4 9C F9 E4 9D FE D2 +R 00 00 00 07 +T 01 59 00 03 80 0A +R 00 00 00 07 29 02 00 04 +T 01 5C +R 00 00 00 07 +T 01 5C 8A 07 8B 00 8C 01 8D 06 C2 00 03 +R 00 00 00 07 29 0B 00 04 +T 01 66 +R 00 00 00 07 +T 01 66 EF 48 49 4E 70 03 02 01 C9 +R 00 00 00 07 00 09 00 07 +T 01 6F +R 00 00 00 07 +T 01 6F E4 F5 00 03 F5 00 02 F5 00 01 75 +R 00 00 00 07 2B 04 00 08 2B 07 00 08 2B 0A 00 08 +T 01 77 00 00 0A C0 06 C0 07 C0 00 C0 01 8F 82 88 +R 00 00 00 07 2B 02 00 08 +T 01 84 83 89 F0 EE 12 00 00 AA 82 AB 83 AC F0 FD +R 00 00 00 07 02 07 00 2E +T 01 92 D0 01 D0 00 D0 07 D0 06 74 30 2A FA E4 3B +R 00 00 00 07 +T 01 A0 FB E4 3C FC E4 3D FD 8A 00 00 C0 00 00 E4 +R 00 00 00 07 29 0A 00 01 29 0D 00 01 +T 01 AC F5 00 03 F5 00 02 F5 00 01 75 +R 00 00 00 07 2B 03 00 0F 2B 06 00 0F 2B 09 00 0F +T 01 B3 00 00 0A 8F 82 88 83 89 F0 EE 12 00 00 AF +R 00 00 00 07 2B 02 00 0F 02 0D 00 35 +T 01 C0 82 A8 83 A9 F0 FE 02 01 66 +R 00 00 00 07 00 09 00 07 +T 01 C9 +R 00 00 00 07 +T 01 C9 30 00 03 05 +R 00 00 00 07 29 03 00 04 +T 01 CC +R 00 00 00 07 +T 01 CC 75 00 00 2D C0 00 00 +R 00 00 00 07 29 03 00 01 29 07 00 01 +T 01 D1 +R 00 00 00 07 +T 01 D1 AA 00 17 EA B5 81 02 80 0A +R 00 00 00 07 29 03 00 01 +T 01 D9 +R 00 00 00 07 +T 01 D9 D0 00 00 85 00 00 82 12 00 00 80 EE +R 00 00 00 07 29 03 00 01 29 06 00 01 02 0A 00 24 +T 01 E3 +R 00 00 00 07 +T 01 E3 22 +R 00 00 00 07 +T 01 E4 +R 00 00 00 07 +T 01 E4 C0 00 00 85 81 00 00 05 81 E5 00 00 24 FB +R 00 00 00 07 2B 03 00 49 2B 07 00 49 2B 0C 00 49 +T 01 EF FA E4 FB FC A8 00 00 08 A6 02 +R 00 00 00 07 2B 07 00 49 +T 01 F8 +R 00 00 00 07 +T 01 F8 E5 00 00 24 FB F8 86 03 08 86 04 08 86 05 +R 00 00 00 07 2B 03 00 49 +T 02 05 8B 82 8C 83 8D F0 12 00 00 FE 70 03 02 +R 00 00 00 07 02 09 00 53 +T 02 12 03 F3 +R 00 00 00 07 00 02 00 07 +T 02 14 +R 00 00 00 07 +T 02 14 BE 25 02 80 03 +R 00 00 00 07 +T 02 19 +R 00 00 00 07 +T 02 19 02 03 E0 +R 00 00 00 07 00 03 00 07 +T 02 1C +R 00 00 00 07 +T 02 1C C2 00 02 C2 00 01 C2 00 00 0B BB 00 01 0C +R 00 00 00 07 29 03 00 04 29 06 00 04 29 09 00 04 +T 02 27 +R 00 00 00 07 +T 02 27 E5 00 00 24 FB F8 A6 03 08 A6 04 08 A6 05 +R 00 00 00 07 2B 03 00 49 +T 02 34 8B 82 8C 83 8D F0 12 00 00 FF BF 68 02 80 +R 00 00 00 07 02 09 00 53 +T 02 42 17 +R 00 00 00 07 +T 02 43 +R 00 00 00 07 +T 02 43 BF 6C 26 +R 00 00 00 07 +T 02 46 +R 00 00 00 07 +T 02 46 +R 00 00 00 07 +T 02 46 D2 00 00 E5 00 00 24 FB F8 74 01 2B F6 E4 +R 00 00 00 07 29 03 00 04 2B 06 00 49 +T 02 52 3C 08 F6 08 A6 05 80 12 +R 00 00 00 07 +T 02 5A +R 00 00 00 07 +T 02 5A D2 00 02 E5 00 00 24 FB F8 74 01 2B F6 E4 +R 00 00 00 07 29 03 00 04 2B 06 00 49 +T 02 66 3C 08 F6 08 A6 05 +R 00 00 00 07 +T 02 6C +R 00 00 00 07 +T 02 6C E5 00 00 24 FB F8 86 03 08 86 04 08 86 05 +R 00 00 00 07 2B 03 00 49 +T 02 79 8B 82 8C 83 8D F0 12 00 00 FB BB 63 02 80 +R 00 00 00 07 02 09 00 53 +T 02 87 22 +R 00 00 00 07 +T 02 88 +R 00 00 00 07 +T 02 88 BB 64 02 80 13 +R 00 00 00 07 +T 02 8D +R 00 00 00 07 +T 02 8D BB 6F 02 80 1D +R 00 00 00 07 +T 02 92 +R 00 00 00 07 +T 02 92 BB 73 02 80 05 +R 00 00 00 07 +T 02 97 +R 00 00 00 07 +T 02 97 BB 78 18 80 09 +R 00 00 00 07 +T 02 9C +R 00 00 00 07 +T 02 9C +R 00 00 00 07 +T 02 9C D2 00 01 80 12 +R 00 00 00 07 29 03 00 04 +T 02 A0 +R 00 00 00 07 +T 02 A0 75 00 01 0A 80 0D +R 00 00 00 07 29 03 00 01 +T 02 A5 +R 00 00 00 07 +T 02 A5 75 00 01 10 80 08 +R 00 00 00 07 29 03 00 01 +T 02 AA +R 00 00 00 07 +T 02 AA 75 00 01 00 80 03 +R 00 00 00 07 29 03 00 01 +T 02 AF +R 00 00 00 07 +T 02 AF 75 00 01 08 +R 00 00 00 07 29 03 00 01 +T 02 B2 +R 00 00 00 07 +T 02 B2 20 00 01 03 02 03 23 +R 00 00 00 07 29 03 00 04 00 07 00 07 +T 02 B8 +R 00 00 00 07 +T 02 B8 A9 00 00 09 E7 24 FD F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 49 2B 0B 00 49 +T 02 C4 86 00 02 08 86 00 03 08 86 00 04 18 18 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 02 CE +R 00 00 00 07 +T 02 CE 85 00 02 00 19 85 00 03 +R 00 00 00 07 29 03 00 01 29 05 00 01 29 08 00 01 +T 02 D3 00 1A 85 00 04 00 1B 85 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 07 00 01 +T 02 D8 00 19 82 85 00 1A 83 85 00 1B F0 12 +R 00 00 00 07 29 02 00 01 29 06 00 01 29 0A 00 01 +T 02 E1 00 00 F5 00 18 70 03 02 03 E5 +R 00 00 00 07 02 02 00 53 29 05 00 01 00 0A 00 07 +T 02 EA +R 00 00 00 07 +T 02 EA 85 00 02 82 85 00 03 83 85 00 04 F0 74 01 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 02 F5 25 00 02 FA E4 35 00 03 FF AB 00 04 8A +R 00 00 00 07 29 03 00 01 29 08 00 01 29 0C 00 01 +T 02 FF 00 02 8F 00 03 8B 00 04 12 +R 00 00 00 07 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 05 00 00 FC C0 02 C0 03 C0 04 C0 06 C0 07 8C +R 00 00 00 07 02 02 00 53 +T 03 13 82 12 00 00 D0 07 D0 06 D0 04 D0 03 D0 02 +R 00 00 00 07 02 04 00 24 +T 03 21 80 AB +R 00 00 00 07 +T 03 23 +R 00 00 00 07 +T 03 23 30 00 00 1C +R 00 00 00 07 29 03 00 04 +T 03 26 +R 00 00 00 07 +T 03 26 A9 00 00 09 E7 24 FC F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 49 2B 0B 00 49 +T 03 32 86 00 05 08 86 00 06 08 86 00 07 08 86 +R 00 00 00 07 29 03 00 01 29 07 00 01 29 0B 00 01 +T 03 3C 00 08 18 18 18 80 3D +R 00 00 00 07 29 02 00 01 +T 03 42 +R 00 00 00 07 +T 03 42 30 00 02 1C +R 00 00 00 07 29 03 00 04 +T 03 45 +R 00 00 00 07 +T 03 45 A9 00 00 09 E7 24 FF F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 49 2B 0B 00 49 +T 03 51 86 02 8A 00 05 EA 33 95 E0 F5 00 06 F5 +R 00 00 00 07 29 05 00 01 29 0C 00 01 +T 03 5C 00 07 F5 00 08 80 1E +R 00 00 00 07 29 02 00 01 29 05 00 01 +T 03 61 +R 00 00 00 07 +T 03 61 A9 00 00 09 E7 24 FE F8 A9 00 00 09 A7 00 +R 00 00 00 07 2B 03 00 49 2B 0B 00 49 +T 03 6D 86 02 08 86 03 18 8A 00 05 8B 00 06 EB 33 +R 00 00 00 07 29 09 00 01 29 0C 00 01 +T 03 79 95 E0 F5 00 07 F5 00 08 +R 00 00 00 07 29 05 00 01 29 08 00 01 +T 03 7F +R 00 00 00 07 +T 03 7F E5 00 01 60 3D +R 00 00 00 07 29 03 00 01 +T 03 83 +R 00 00 00 07 +T 03 83 E5 00 01 B4 08 02 80 42 +R 00 00 00 07 29 03 00 01 +T 03 8A +R 00 00 00 07 +T 03 8A E5 00 01 B4 0A 02 80 07 +R 00 00 00 07 29 03 00 01 +T 03 91 +R 00 00 00 07 +T 03 91 E5 00 01 B4 10 4F 80 14 +R 00 00 00 07 29 03 00 01 +T 03 98 +R 00 00 00 07 +T 03 98 +R 00 00 00 07 +T 03 98 C0 06 85 00 05 82 85 00 06 83 85 00 07 F0 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0D 00 01 +T 03 A3 E5 00 08 12 01 3D D0 06 80 39 +R 00 00 00 07 29 03 00 01 00 06 00 07 +T 03 AC +R 00 00 00 07 +T 03 AC C0 06 85 00 05 82 85 00 06 83 85 00 07 F0 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0D 00 01 +T 03 B7 E5 00 08 12 00 00 D0 06 80 25 +R 00 00 00 07 29 03 00 01 00 06 00 07 +T 03 C0 +R 00 00 00 07 +T 03 C0 85 00 05 82 C0 06 12 00 00 D0 06 80 19 +R 00 00 00 07 29 03 00 01 02 09 00 24 +T 03 CC +R 00 00 00 07 +T 03 CC C0 06 85 00 05 82 85 00 06 83 85 00 07 F0 +R 00 00 00 07 29 05 00 01 29 09 00 01 29 0D 00 01 +T 03 D7 E5 00 08 12 00 76 D0 06 80 05 +R 00 00 00 07 29 03 00 01 00 06 00 07 +T 03 E0 +R 00 00 00 07 +T 03 E0 8E 82 12 00 00 +R 00 00 00 07 02 05 00 24 +T 03 E5 +R 00 00 00 07 +T 03 E5 E5 00 00 24 FB F8 06 B6 00 02 08 06 +R 00 00 00 07 2B 03 00 49 +T 03 F0 +R 00 00 00 07 +T 03 F0 02 01 F8 +R 00 00 00 07 00 03 00 07 +T 03 F3 +R 00 00 00 07 +T 03 F3 85 00 00 81 D0 00 00 22 +R 00 00 00 07 2B 03 00 49 2B 07 00 49 +T 03 F9 +R 00 00 00 07 +T 03 F9 30 31 32 33 34 35 36 37 38 39 41 42 43 44 +R 00 00 00 07 +T 04 07 45 46 00 +R 00 00 00 07 diff --git a/device/lib/small/puts.asm b/device/lib/small/puts.asm new file mode 100644 index 00000000..5d06f115 --- /dev/null +++ b/device/lib/small/puts.asm @@ -0,0 +1,125 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:21 2000 + +;-------------------------------------------------------- + .module puts +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _puts +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$puts$0$0 ==. +; puts.c 27 +; ----------------------------------------- +; function puts +; ----------------------------------------- +_puts: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; puts.c 35 + mov r2,dpl + mov r3,dph + mov r4,b +; puts.c 30 + mov r5,#0x00 + mov r6,#0x00 +00101$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00108$: +; puts.c 31 + mov dpl,r2 + mov dph,r3 + mov b,r4 + inc r2 + cjne r2,#0x00,00109$ + inc r3 +00109$: + lcall __gptrget + mov r7,a + push ar2 + push ar3 + push ar4 + push ar5 + push ar6 + mov dpl,r7 + lcall _putchar + pop ar6 + pop ar5 + pop ar4 + pop ar3 + pop ar2 +; puts.c 32 + inc r5 + cjne r5,#0x00,00110$ + inc r6 +00110$: +; Peephole 132 changed ljmp to sjmp + sjmp 00101$ +00103$: +; puts.c 34 + push ar5 + push ar6 + mov dpl,#0x0a + lcall _putchar + pop ar6 + pop ar5 +; puts.c 35 + mov a,#0x01 + add a,r5 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r6 + mov dph,a +00104$: + C$puts.c$36$1$1 ==. + XG$puts$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/puts.cdb b/device/lib/small/puts.cdb new file mode 100644 index 00000000..1f616e72 --- /dev/null +++ b/device/lib/small/puts.cdb @@ -0,0 +1,2 @@ +M:puts +F:G$puts$0$0({2}DF,SI:S),C,0,0,0,0,0 diff --git a/device/lib/small/puts.rel b/device/lib/small/puts.rel new file mode 100644 index 00000000..d5bb09ba --- /dev/null +++ b/device/lib/small/puts.rel @@ -0,0 +1,100 @@ +;!FILE puts.asm +XH +H 8 areas 36 global symbols +M puts +S _putchar Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 5D flags 20 +S A$puts$100 Def003F +S A$puts$110 Def004C +S A$puts$101 Def0042 +S A$puts$120 Def005A +S A$puts$111 Def004F +S A$puts$112 Def0051 +S A$puts$104 Def0043 +S A$puts$114 Def0053 +S A$puts$124 Def005C +S A$puts$115 Def0055 +S A$puts$116 Def0056 +S A$puts$107 Def0045 +S A$puts$108 Def0047 +S A$puts$118 Def0058 +S A$puts$109 Def0049 +S A$puts$119 Def0059 +S A$puts$60 Def0000 +S C$puts.c$36$1$1 Def005C +S A$puts$70 Def0010 +S A$puts$61 Def0002 +S A$puts$80 Def001C +S A$puts$62 Def0004 +S A$puts$90 Def002D +S A$puts$81 Def001D +S A$puts$72 Def0013 +S A$puts$91 Def002F +S A$puts$82 Def0020 +S A$puts$64 Def0006 +S A$puts$92 Def0031 +S A$puts$74 Def0014 +S A$puts$65 Def0008 +S A$puts$93 Def0034 +S A$puts$84 Def0021 +S A$puts$94 Def0036 +S A$puts$85 Def0024 +S A$puts$67 Def000A +S A$puts$95 Def0038 +S A$puts$86 Def0025 +S A$puts$77 Def0016 +S A$puts$68 Def000C +S A$puts$96 Def003A +S A$puts$87 Def0027 +S A$puts$78 Def0018 +S A$puts$69 Def000E +S A$puts$97 Def003C +S A$puts$88 Def0029 +S A$puts$79 Def001A +S A$puts$89 Def002B +S A$puts$99 Def003E +S _puts Def0000 +S XG$puts$0$0 Def005C +S G$puts$0$0 Def0000 +T 00 00 +R 00 00 00 07 +T 00 00 AA 82 AB 83 AC F0 7D 00 7E 00 +R 00 00 00 07 +T 00 0A +R 00 00 00 07 +T 00 0A 8A 82 8B 83 8C F0 12 00 00 FF 60 2F +R 00 00 00 07 02 09 00 01 +T 00 16 +R 00 00 00 07 +T 00 16 8A 82 8B 83 8C F0 0A BA 00 01 0B +R 00 00 00 07 +T 00 21 +R 00 00 00 07 +T 00 21 12 00 00 FF C0 02 C0 03 C0 04 C0 05 C0 06 +R 00 00 00 07 02 03 00 01 +T 00 2F 8F 82 12 00 00 D0 06 D0 05 D0 04 D0 03 D0 +R 00 00 00 07 02 05 00 00 +T 00 3D 02 0D BD 00 01 0E +R 00 00 00 07 +T 00 43 +R 00 00 00 07 +T 00 43 80 C5 +R 00 00 00 07 +T 00 45 +R 00 00 00 07 +T 00 45 C0 05 C0 06 75 82 0A 12 00 00 D0 06 D0 05 +R 00 00 00 07 02 0A 00 00 +T 00 53 74 01 2D F5 82 E4 3E F5 83 +R 00 00 00 07 +T 00 5C +R 00 00 00 07 +T 00 5C 22 +R 00 00 00 07 diff --git a/device/lib/small/ser_ir.asm b/device/lib/small/ser_ir.asm new file mode 100644 index 00000000..c37debd7 --- /dev/null +++ b/device/lib/small/ser_ir.asm @@ -0,0 +1,612 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:18 2000 + +;-------------------------------------------------------- + .module ser_ir +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _ser_handler + .globl _ser_can_xmt + .globl _ser_can_rcv + .globl _ser_getc + .globl _ser_gets + .globl _ser_puts + .globl _ser_putc + .globl _ser_init + .globl _ser_gets_PARM_2 +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$A$0$0 == 0x00e0 +_A = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$AIN0$0$0 == 0x0090 +_AIN0 = 0x0090 +G$AIN1$0$0 == 0x0091 +_AIN1 = 0x0091 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$REN$0$0 == 0x009c +_REN = 0x009c +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET2$0$0 == 0x00ad +_ET2 = 0x00ad +G$EA$0$0 == 0x00af +_EA = 0x00af +G$P3_0$0$0 == 0x00b0 +_P3_0 = 0x00b0 +G$P3_1$0$0 == 0x00b1 +_P3_1 = 0x00b1 +G$P3_2$0$0 == 0x00b2 +_P3_2 = 0x00b2 +G$P3_3$0$0 == 0x00b3 +_P3_3 = 0x00b3 +G$P3_4$0$0 == 0x00b4 +_P3_4 = 0x00b4 +G$P3_5$0$0 == 0x00b5 +_P3_5 = 0x00b5 +G$P3_7$0$0 == 0x00b7 +_P3_7 = 0x00b7 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$AOUT$0$0 == 0x00b6 +_AOUT = 0x00b6 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$FL$0$0 == 0x00d1 +_FL = 0x00d1 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +Fser_ir$rbuf$0$0==. +_rbuf: + .ds 0x000a +Fser_ir$xbuf$0$0==. +_xbuf: + .ds 0x000a +Fser_ir$rcnt$0$0==. +_rcnt: + .ds 0x0001 +Fser_ir$xcnt$0$0==. +_xcnt: + .ds 0x0001 +Fser_ir$rpos$0$0==. +_rpos: + .ds 0x0001 +Fser_ir$xpos$0$0==. +_xpos: + .ds 0x0001 +Fser_ir$busy$0$0==. +_busy: + .ds 0x0001 +_ser_gets_PARM_2: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$ser_init$0$0 ==. +; ser_ir.c 49 +; ----------------------------------------- +; function ser_init +; ----------------------------------------- +_ser_init: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; ser_ir.c 51 + clr _ES +; ser_ir.c 52 + mov _xpos,#0x00 + mov _rpos,#0x00 + mov _xcnt,#0x00 + mov _rcnt,#0x00 +; ser_ir.c 53 + mov _busy,#0x00 +; ser_ir.c 54 + mov _SCON,#0x50 +; ser_ir.c 55 + orl _PCON,#0x80 +; ser_ir.c 56 + anl _TMOD,#0x0f +; ser_ir.c 57 + orl _TMOD,#0x20 +; ser_ir.c 58 + mov _TL1,#0xfd + mov _TH1,#0xfd + setb _TR1 +; ser_ir.c 59 + setb _ES +00101$: + C$ser_ir.c$60$1$1 ==. + XG$ser_init$0$0 ==. + ret + G$ser_handler$0$0 ==. +; ser_ir.c 62 +; ----------------------------------------- +; function ser_handler +; ----------------------------------------- +_ser_handler: + push acc + push b + push dpl + push dph + push ar2 + push ar0 + push psw + mov psw,#0x00 +; ser_ir.c 64 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00104$ +00118$: +; ser_ir.c 65 + clr _RI +; ser_ir.c 67 + clr c + mov a,_rcnt + subb a,#0x0a +; Peephole 108 removed ljmp by inverse jump logic + jnc 00104$ +00119$: +; ser_ir.c 68 + mov r2,_rcnt + inc _rcnt + mov a,r2 + add a,_rpos + mov b,#0x0a + div ab + mov r2,b + mov a,r2 + add a,#_rbuf + mov r0,acc + mov @r0,_SBUF +00104$: +; ser_ir.c 70 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00111$ +00120$: +; ser_ir.c 71 + clr _TI +; ser_ir.c 72 + mov _busy,_xcnt + mov a,_xcnt +; Peephole 110 removed ljmp by inverse jump logic + jz 00111$ +00121$: +; ser_ir.c 73 + dec _xcnt +; ser_ir.c 74 + mov r2,_xpos + inc _xpos + mov a,r2 + add a,#_xbuf + mov r0,a + mov _SBUF,@r0 +; ser_ir.c 75 + clr c + mov a,_xpos + subb a,#0x0a +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00111$ +00122$: +; ser_ir.c 76 + mov _xpos,#0x00 +00111$: + pop psw + pop ar0 + pop ar2 + pop dph + pop dpl + pop b + pop acc + C$ser_ir.c$79$1$1 ==. + XG$ser_handler$0$0 ==. + reti + G$ser_putc$0$0 ==. +; ser_ir.c 81 +; ----------------------------------------- +; function ser_putc +; ----------------------------------------- +_ser_putc: +; ser_ir.c 92 + mov r2,dpl +; ser_ir.c 83 +00101$: + clr c + mov a,_xcnt + subb a,#0x0a +; Peephole 108 removed ljmp by inverse jump logic + jnc 00101$ +00112$: +; ser_ir.c 85 + clr _ES +; ser_ir.c 86 + mov a,_busy +; Peephole 110 removed ljmp by inverse jump logic + jz 00105$ +00113$: +; ser_ir.c 87 + mov r3,_xcnt + inc _xcnt + mov a,r3 + add a,_xpos + mov b,#0x0a + div ab + mov r3,b + mov a,r3 + add a,#_xbuf + mov r0,acc + mov @r0,ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: +; ser_ir.c 89 + mov _SBUF,r2 +; ser_ir.c 90 + mov _busy,#0x01 +00106$: +; ser_ir.c 92 + setb _ES +00107$: + C$ser_ir.c$93$1$1 ==. + XG$ser_putc$0$0 ==. + ret + G$ser_getc$0$0 ==. +; ser_ir.c 95 +; ----------------------------------------- +; function ser_getc +; ----------------------------------------- +_ser_getc: +; ser_ir.c 98 +00101$: + mov a,_rcnt +; Peephole 110 removed ljmp by inverse jump logic + jz 00101$ +00111$: +; ser_ir.c 100 + clr _ES +; ser_ir.c 101 + dec _rcnt +; ser_ir.c 102 + mov r2,_rpos + inc _rpos + mov a,r2 + add a,#_rbuf + mov r0,a + mov ar2,@r0 +; ser_ir.c 103 + clr c + mov a,_rpos + subb a,#0x0a +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00105$ +00112$: +; ser_ir.c 104 + mov _rpos,#0x00 +00105$: +; ser_ir.c 105 + setb _ES +; ser_ir.c 106 + mov dpl,r2 +00106$: + C$ser_ir.c$107$1$1 ==. + XG$ser_getc$0$0 ==. + ret + G$ser_puts$0$0 ==. +; ser_ir.c 110 +; ----------------------------------------- +; function ser_puts +; ----------------------------------------- +_ser_puts: +; ser_ir.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; ser_ir.c 113 +00103$: + mov dpl,r2 + mov dph,r3 + mov b,r4 + inc r2 + cjne r2,#0x00,00111$ + inc r3 +00111$: + lcall __gptrget +; Peephole 166 removed redundant mov + mov r5,a + mov ar6,r5 +; Peephole 110 removed ljmp by inverse jump logic + jz 00106$ +00112$: +; ser_ir.c 114 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r6,#0x0a,00102$ +; Peephole 201 removed redundant sjmp +00113$: +00114$: + push ar2 + push ar3 + push ar4 + push ar6 + mov dpl,#0x0d + lcall _ser_putc + pop ar6 + pop ar4 + pop ar3 + pop ar2 +00102$: +; ser_ir.c 115 + push ar2 + push ar3 + push ar4 + mov dpl,r6 + lcall _ser_putc + pop ar4 + pop ar3 + pop ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00106$: + C$ser_ir.c$117$1$1 ==. + XG$ser_puts$0$0 ==. + ret + G$ser_gets$0$0 ==. +; ser_ir.c 119 +; ----------------------------------------- +; function ser_gets +; ----------------------------------------- +_ser_gets: +; ser_ir.c 130 + mov r2,dpl + mov r3,dph + mov r4,b +; ser_ir.c 124 + mov r5,#0x00 +00105$: + clr c + mov a,_ser_gets_PARM_2 + subb a,r5 +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00107$ +00113$: +; ser_ir.c 125 + push ar2 + push ar3 + push ar4 + push ar5 + lcall _ser_getc + mov r6,dpl + pop ar5 + pop ar4 + pop ar3 + pop ar2 +; ser_ir.c 126 + cjne r6,#0x0d,00114$ +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00114$: +; ser_ir.c 127 + mov ar7,r5 + inc r5 + mov a,r7 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a + mov b,r4 + mov a,r6 + lcall __gptrput +; ser_ir.c 128 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne r6,#0x0a,00105$ +; Peephole 201 removed redundant sjmp +00115$: +00116$: +00107$: +; ser_ir.c 130 + mov a,r5 + add a,r2 + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov dph,a + mov b,r4 +; Peephole 180 changed mov to clr + clr a + lcall __gptrput +00108$: + C$ser_ir.c$131$1$1 ==. + XG$ser_gets$0$0 ==. + ret + G$ser_can_xmt$0$0 ==. +; ser_ir.c 133 +; ----------------------------------------- +; function ser_can_xmt +; ----------------------------------------- +_ser_can_xmt: +; ser_ir.c 135 + clr c + mov a,#0x0a + subb a,_xcnt + mov dpl,a +00101$: + C$ser_ir.c$136$1$1 ==. + XG$ser_can_xmt$0$0 ==. + ret + G$ser_can_rcv$0$0 ==. +; ser_ir.c 138 +; ----------------------------------------- +; function ser_can_rcv +; ----------------------------------------- +_ser_can_rcv: +; ser_ir.c 140 + mov dpl,_rcnt +00101$: + C$ser_ir.c$141$1$1 ==. + XG$ser_can_rcv$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/ser_ir.cdb b/device/lib/small/ser_ir.cdb new file mode 100644 index 00000000..6641f75c --- /dev/null +++ b/device/lib/small/ser_ir.cdb @@ -0,0 +1,96 @@ +M:ser_ir +F:G$ser_init$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_handler$0$0({2}DF,SV:S),Z,0,0,1,4,0 +F:G$ser_putc$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_getc$0$0({2}DF,SC:U),Z,0,0,0,0,0 +F:G$ser_puts$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_gets$0$0({2}DF,SV:S),Z,0,0,0,0,0 +F:G$ser_can_xmt$0$0({2}DF,SC:U),Z,0,0,0,0,0 +F:G$ser_can_rcv$0$0({2}DF,SC:U),Z,0,0,0,0,0 +S:Fser_ir$rbuf$0$0({10}DA10,SC:U),E,0,0 +S:Fser_ir$xbuf$0$0({10}DA10,SC:U),E,0,0 +S:Fser_ir$rcnt$0$0({1}SC:U),E,0,0 +S:Fser_ir$xcnt$0$0({1}SC:U),E,0,0 +S:Fser_ir$rpos$0$0({1}SC:U),E,0,0 +S:Fser_ir$xpos$0$0({1}SC:U),E,0,0 +S:Fser_ir$busy$0$0({1}SC:U),E,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$A$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$AIN0$0$0({1}SX:S),J,0,0 +S:G$AIN1$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET2$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$P3_0$0$0({1}SX:S),J,0,0 +S:G$P3_1$0$0({1}SX:S),J,0,0 +S:G$P3_2$0$0({1}SX:S),J,0,0 +S:G$P3_3$0$0({1}SX:S),J,0,0 +S:G$P3_4$0$0({1}SX:S),J,0,0 +S:G$P3_5$0$0({1}SX:S),J,0,0 +S:G$P3_7$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$AOUT$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$FL$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 diff --git a/device/lib/small/ser_ir.rel b/device/lib/small/ser_ir.rel new file mode 100644 index 00000000..47633fb4 --- /dev/null +++ b/device/lib/small/ser_ir.rel @@ -0,0 +1,547 @@ +;!FILE ser_ir.asm +XH +H 9 areas 138 global symbols +M ser_ir +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$TB8$0$0 Def009B +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$TXD$0$0 Def00B1 +S G$SM0$0$0 Def009F +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$FL$0$0 Def00D1 +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$RS0$0$0 Def00D3 +S G$PT1$0$0 Def00BB +S G$F0$0$0 Def00D5 +S G$RS1$0$0 Def00D4 +S G$TR0$0$0 Def008C +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S __gptrput Ref0000 +S G$A$0$0 Def00E0 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$PS$0$0 Def00BC +S G$P3$0$0 Def00B0 +S G$SP$0$0 Def0081 +S G$T0$0$0 Def00B4 +S G$OV$0$0 Def00D2 +S G$T1$0$0 Def00B5 +S G$ACC$0$0 Def00E0 +S G$AIN0$0$0 Def0090 +S G$AIN1$0$0 Def0091 +S G$P$0$0 Def00D0 +S G$P1_0$0$0 Def0090 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P3_0$0$0 Def00B0 +S G$P1_2$0$0 Def0092 +S G$P3_1$0$0 Def00B1 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P3_2$0$0 Def00B2 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$P3_3$0$0 Def00B3 +S G$P1_5$0$0 Def0095 +S G$P3_4$0$0 Def00B4 +S G$P1_6$0$0 Def0096 +S G$P3_5$0$0 Def00B5 +S G$P1_7$0$0 Def0097 +S G$AOUT$0$0 Def00B6 +S G$P3_7$0$0 Def00B7 +S G$INT0$0$0 Def00B2 +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S __gptrget Ref0000 +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$ET2$0$0 Def00AD +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 1A flags 0 +S Fser_ir$xpos$0$0 Def0017 +S _ser_gets_PARM_2 Def0019 +S Fser_ir$rbuf$0$0 Def0000 +S Fser_ir$xbuf$0$0 Def000A +S Fser_ir$rcnt$0$0 Def0014 +S Fser_ir$xcnt$0$0 Def0015 +S Fser_ir$busy$0$0 Def0018 +S Fser_ir$rpos$0$0 Def0016 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 0 flags 80 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 175 flags 20 +S C$ser_ir.c$141$1$1 Def0174 +S A$ser_ir$310 Def0049 +S A$ser_ir$301 Def003E +S A$ser_ir$500 Def010E +S A$ser_ir$410 Def00B6 +S A$ser_ir$401 Def00AF +S A$ser_ir$311 Def004A +S A$ser_ir$302 Def003F +S C$ser_ir.c$107$1$1 Def00D7 +S A$ser_ir$501 Def0110 +S A$ser_ir$330 Def0063 +S A$ser_ir$312 Def004C +S A$ser_ir$303 Def0041 +S C$ser_ir.c$117$1$1 Def011D +S A$ser_ir$520 Def0120 +S A$ser_ir$511 Def011D +S A$ser_ir$502 Def0112 +S A$ser_ir$430 Def00C3 +S A$ser_ir$421 Def00B9 +S A$ser_ir$403 Def00B1 +S A$ser_ir$340 Def006F +S A$ser_ir$322 Def0059 +S A$ser_ir$313 Def004F +S C$ser_ir.c$136$1$1 Def0170 +S _ser_putc Def008A +S A$ser_ir$611 Def0174 +S A$ser_ir$530 Def012A +S A$ser_ir$521 Def0122 +S A$ser_ir$503 Def0115 +S A$ser_ir$440 Def00CE +S A$ser_ir$431 Def00C4 +S A$ser_ir$350 Def0078 +S A$ser_ir$314 Def0050 +S A$ser_ir$305 Def0043 +S A$ser_ir$540 Def013B +S A$ser_ir$504 Def0117 +S A$ser_ir$432 Def00C6 +S A$ser_ir$342 Def0071 +S A$ser_ir$333 Def0065 +S A$ser_ir$315 Def0052 +S A$ser_ir$261 Def000E +S G$ser_can_xmt$0$0 Def0169 +S A$ser_ir$550 Def0148 +S A$ser_ir$541 Def013D +S A$ser_ir$523 Def0124 +S A$ser_ir$505 Def0119 +S A$ser_ir$460 Def00D8 +S A$ser_ir$433 Def00C7 +S A$ser_ir$424 Def00BB +S A$ser_ir$406 Def00B4 +S A$ser_ir$361 Def0089 +S A$ser_ir$352 Def007B +S A$ser_ir$343 Def0072 +S A$ser_ir$325 Def005C +S A$ser_ir$316 Def0053 +S A$ser_ir$271 Def001D +S XG$ser_gets$0$0 Def0168 +S A$ser_ir$560 Def0154 +S A$ser_ir$551 Def0149 +S A$ser_ir$542 Def013F +S A$ser_ir$533 Def012C +S A$ser_ir$470 Def00E8 +S A$ser_ir$461 Def00DA +S A$ser_ir$452 Def00D7 +S A$ser_ir$443 Def00D0 +S A$ser_ir$353 Def007D +S A$ser_ir$344 Def0074 +S A$ser_ir$335 Def0067 +S A$ser_ir$317 Def0055 +S A$ser_ir$308 Def0045 +S A$ser_ir$290 Def0030 +S A$ser_ir$272 Def0020 +S A$ser_ir$263 Def0011 +S A$ser_ir$254 Def0000 +S XG$ser_init$0$0 Def0027 +S A$ser_ir$570 Def015A +S A$ser_ir$552 Def014A +S A$ser_ir$534 Def012E +S A$ser_ir$525 Def0126 +S A$ser_ir$507 Def011B +S A$ser_ir$462 Def00DC +S A$ser_ir$435 Def00C9 +S A$ser_ir$426 Def00BD +S A$ser_ir$390 Def00A0 +S A$ser_ir$381 Def0095 +S A$ser_ir$372 Def008C +S A$ser_ir$354 Def007F +S A$ser_ir$336 Def0069 +S A$ser_ir$327 Def005E +S A$ser_ir$318 Def0057 +S A$ser_ir$309 Def0047 +S A$ser_ir$291 Def0032 +S A$ser_ir$273 Def0023 +S A$ser_ir$607 Def0171 +S A$ser_ir$580 Def0165 +S A$ser_ir$571 Def015B +S A$ser_ir$553 Def014B +S A$ser_ir$544 Def0141 +S A$ser_ir$535 Def0130 +S A$ser_ir$526 Def0127 +S A$ser_ir$490 Def00FC +S A$ser_ir$472 Def00E9 +S A$ser_ir$436 Def00CA +S A$ser_ir$391 Def00A3 +S A$ser_ir$373 Def008D +S A$ser_ir$355 Def0081 +S A$ser_ir$337 Def006B +S A$ser_ir$328 Def0061 +S A$ser_ir$292 Def0034 +S A$ser_ir$265 Def0014 +S A$ser_ir$256 Def0002 +S A$ser_ir$572 Def015C +S A$ser_ir$536 Def0132 +S A$ser_ir$527 Def0129 +S A$ser_ir$491 Def00FF +S A$ser_ir$482 Def00F1 +S A$ser_ir$446 Def00D3 +S A$ser_ir$437 Def00CC +S A$ser_ir$428 Def00BF +S A$ser_ir$419 Def00B7 +S A$ser_ir$392 Def00A4 +S A$ser_ir$383 Def0097 +S A$ser_ir$374 Def008F +S A$ser_ir$356 Def0083 +S A$ser_ir$347 Def0076 +S A$ser_ir$338 Def006C +S A$ser_ir$293 Def0036 +S A$ser_ir$275 Def0025 +S A$ser_ir$257 Def0005 +S A$ser_ir$564 Def0157 +S A$ser_ir$555 Def014D +S A$ser_ir$546 Def0144 +S A$ser_ir$537 Def0134 +S A$ser_ir$519 Def011E +S A$ser_ir$492 Def0102 +S A$ser_ir$474 Def00EC +S A$ser_ir$465 Def00DE +S A$ser_ir$429 Def00C1 +S A$ser_ir$393 Def00A6 +S A$ser_ir$357 Def0085 +S A$ser_ir$339 Def006E +S A$ser_ir$267 Def0017 +S A$ser_ir$258 Def0008 +S A$ser_ir$592 Def0169 +S A$ser_ir$574 Def015E +S A$ser_ir$556 Def014E +S A$ser_ir$538 Def0137 +S A$ser_ir$493 Def0104 +S A$ser_ir$475 Def00ED +S A$ser_ir$466 Def00E0 +S A$ser_ir$448 Def00D5 +S A$ser_ir$394 Def00A7 +S A$ser_ir$376 Def0091 +S A$ser_ir$358 Def0087 +S A$ser_ir$286 Def0028 +S A$ser_ir$259 Def000B +S A$ser_ir$593 Def016A +S A$ser_ir$584 Def0168 +S A$ser_ir$575 Def015F +S A$ser_ir$557 Def014F +S A$ser_ir$539 Def0139 +S A$ser_ir$494 Def0106 +S A$ser_ir$467 Def00E2 +S A$ser_ir$395 Def00A9 +S A$ser_ir$386 Def0099 +S A$ser_ir$296 Def0039 +S A$ser_ir$287 Def002A +S A$ser_ir$269 Def001A +S A$ser_ir$594 Def016C +S A$ser_ir$576 Def0160 +S A$ser_ir$558 Def0151 +S A$ser_ir$549 Def0146 +S A$ser_ir$495 Def0108 +S A$ser_ir$486 Def00F4 +S A$ser_ir$477 Def00EF +S A$ser_ir$468 Def00E4 +S A$ser_ir$396 Def00AB +S A$ser_ir$387 Def009B +S A$ser_ir$369 Def008A +S A$ser_ir$288 Def002C +S A$ser_ir$279 Def0027 +S G$ser_gets$0$0 Def011E +S A$ser_ir$595 Def016E +S A$ser_ir$577 Def0162 +S A$ser_ir$559 Def0153 +S A$ser_ir$487 Def00F6 +S A$ser_ir$469 Def00E5 +S A$ser_ir$388 Def009D +S A$ser_ir$379 Def0093 +S A$ser_ir$289 Def002E +S XG$ser_putc$0$0 Def00B6 +S C$ser_ir.c$60$1$1 Def0027 +S G$ser_init$0$0 Def0000 +S A$ser_ir$488 Def00F8 +S A$ser_ir$398 Def00AD +S A$ser_ir$389 Def009E +S A$ser_ir$299 Def003C +S A$ser_ir$579 Def0164 +S A$ser_ir$498 Def010A +S A$ser_ir$489 Def00FA +S A$ser_ir$499 Def010C +S A$ser_ir$599 Def0170 +S _ser_puts Def00D8 +S C$ser_ir.c$93$1$1 Def00B6 +S G$ser_putc$0$0 Def008A +S C$ser_ir.c$79$1$1 Def0089 +S XG$ser_puts$0$0 Def011D +S _ser_can_rcv Def0171 +S _ser_handler Def0028 +S G$ser_puts$0$0 Def00D8 +S _ser_getc Def00B7 +S XG$ser_can_rcv$0$0 Def0174 +S XG$ser_handler$0$0 Def0089 +S _ser_can_xmt Def0169 +S XG$ser_getc$0$0 Def00D7 +S G$ser_can_rcv$0$0 Def0171 +S G$ser_handler$0$0 Def0028 +S _ser_gets Def011E +S _ser_init Def0000 +S XG$ser_can_xmt$0$0 Def0170 +S C$ser_ir.c$131$1$1 Def0168 +S G$ser_getc$0$0 Def00B7 +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 0A +R 00 00 00 01 +T 00 0A +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 15 +R 00 00 00 01 +T 00 15 +R 00 00 00 01 +T 00 16 +R 00 00 00 01 +T 00 16 +R 00 00 00 01 +T 00 17 +R 00 00 00 01 +T 00 17 +R 00 00 00 01 +T 00 18 +R 00 00 00 01 +T 00 18 +R 00 00 00 01 +T 00 19 +R 00 00 00 01 +T 00 19 +R 00 00 00 01 +T 00 00 +R 00 00 00 08 +T 00 00 C2 AC 75 00 17 00 75 00 16 00 75 00 15 00 +R 00 00 00 08 29 05 00 01 29 09 00 01 29 0D 00 01 +T 00 0B 75 00 14 00 75 00 18 00 75 98 50 43 87 80 +R 00 00 00 08 29 03 00 01 29 07 00 01 +T 00 17 53 89 0F 43 89 20 75 8B FD 75 8D FD D2 8E +R 00 00 00 08 +T 00 25 D2 AC +R 00 00 00 08 +T 00 27 +R 00 00 00 08 +T 00 27 22 +R 00 00 00 08 +T 00 28 +R 00 00 00 08 +T 00 28 C0 E0 C0 F0 C0 82 C0 83 C0 02 C0 00 C0 D0 +R 00 00 00 08 +T 00 36 75 D0 00 30 98 1D +R 00 00 00 08 +T 00 3C +R 00 00 00 08 +T 00 3C C2 98 C3 E5 00 14 94 0A 50 14 +R 00 00 00 08 29 06 00 01 +T 00 45 +R 00 00 00 08 +T 00 45 AA 00 14 05 00 14 EA 25 00 16 75 F0 0A 84 +R 00 00 00 08 29 03 00 01 29 06 00 01 29 0A 00 01 +T 00 50 AA F0 EA 24 00 00 A8 E0 A6 99 +R 00 00 00 08 09 06 00 01 +T 00 59 +R 00 00 00 08 +T 00 59 30 99 1F +R 00 00 00 08 +T 00 5C +R 00 00 00 08 +T 00 5C C2 99 85 00 15 00 18 E5 00 15 60 16 +R 00 00 00 08 29 05 00 01 29 07 00 01 29 0A 00 01 +T 00 65 +R 00 00 00 08 +T 00 65 15 00 15 AA 00 17 05 00 17 EA 24 +R 00 00 00 08 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 6D 00 0A F8 86 99 C3 E5 00 17 94 0A 40 03 +R 00 00 00 08 09 02 00 01 29 09 00 01 +T 00 78 +R 00 00 00 08 +T 00 78 75 00 17 00 +R 00 00 00 08 29 03 00 01 +T 00 7B +R 00 00 00 08 +T 00 7B D0 D0 D0 00 D0 02 D0 83 D0 82 D0 F0 D0 E0 +R 00 00 00 08 +T 00 89 32 +R 00 00 00 08 +T 00 8A +R 00 00 00 08 +T 00 8A AA 82 +R 00 00 00 08 +T 00 8C +R 00 00 00 08 +T 00 8C C3 E5 00 15 94 0A 50 F9 +R 00 00 00 08 29 04 00 01 +T 00 93 +R 00 00 00 08 +T 00 93 C2 AC E5 00 18 60 16 +R 00 00 00 08 29 05 00 01 +T 00 99 +R 00 00 00 08 +T 00 99 AB 00 15 05 00 15 EB 25 00 17 75 F0 0A 84 +R 00 00 00 08 29 03 00 01 29 06 00 01 29 0A 00 01 +T 00 A4 AB F0 EB 24 00 0A A8 E0 A6 02 80 05 +R 00 00 00 08 09 06 00 01 +T 00 AF +R 00 00 00 08 +T 00 AF 8A 99 75 00 18 01 +R 00 00 00 08 29 05 00 01 +T 00 B4 +R 00 00 00 08 +T 00 B4 D2 AC +R 00 00 00 08 +T 00 B6 +R 00 00 00 08 +T 00 B6 22 +R 00 00 00 08 +T 00 B7 +R 00 00 00 08 +T 00 B7 +R 00 00 00 08 +T 00 B7 E5 00 14 60 FC +R 00 00 00 08 29 03 00 01 +T 00 BB +R 00 00 00 08 +T 00 BB C2 AC 15 00 14 AA 00 16 05 00 16 EA 24 +R 00 00 00 08 29 05 00 01 29 08 00 01 29 0B 00 01 +T 00 C5 00 00 F8 86 02 C3 E5 00 16 94 0A 40 03 +R 00 00 00 08 09 02 00 01 29 09 00 01 +T 00 D0 +R 00 00 00 08 +T 00 D0 75 00 16 00 +R 00 00 00 08 29 03 00 01 +T 00 D3 +R 00 00 00 08 +T 00 D3 D2 AC 8A 82 +R 00 00 00 08 +T 00 D7 +R 00 00 00 08 +T 00 D7 22 +R 00 00 00 08 +T 00 D8 +R 00 00 00 08 +T 00 D8 AA 82 AB 83 AC F0 +R 00 00 00 08 +T 00 DE +R 00 00 00 08 +T 00 DE 8A 82 8B 83 8C F0 0A BA 00 01 0B +R 00 00 00 08 +T 00 E9 +R 00 00 00 08 +T 00 E9 12 00 00 FD 8D 06 60 2C +R 00 00 00 08 02 03 00 4A +T 00 F1 +R 00 00 00 08 +T 00 F1 BE 0A 16 +R 00 00 00 08 +T 00 F4 +R 00 00 00 08 +T 00 F4 +R 00 00 00 08 +T 00 F4 C0 02 C0 03 C0 04 C0 06 75 82 0D 12 00 8A +R 00 00 00 08 00 0E 00 08 +T 01 02 D0 06 D0 04 D0 03 D0 02 +R 00 00 00 08 +T 01 0A +R 00 00 00 08 +T 01 0A C0 02 C0 03 C0 04 8E 82 12 00 8A D0 04 D0 +R 00 00 00 08 00 0B 00 08 +T 01 18 03 D0 02 80 C1 +R 00 00 00 08 +T 01 1D +R 00 00 00 08 +T 01 1D 22 +R 00 00 00 08 +T 01 1E +R 00 00 00 08 +T 01 1E AA 82 AB 83 AC F0 7D 00 +R 00 00 00 08 +T 01 26 +R 00 00 00 08 +T 01 26 C3 E5 00 19 9D 40 2E +R 00 00 00 08 29 04 00 01 +T 01 2C +R 00 00 00 08 +T 01 2C C0 02 C0 03 C0 04 C0 05 12 00 B7 AE 82 D0 +R 00 00 00 08 00 0B 00 08 +T 01 3A 05 D0 04 D0 03 D0 02 BE 0D 02 80 E0 +R 00 00 00 08 +T 01 46 +R 00 00 00 08 +T 01 46 8D 07 0D EF 2A F5 82 E4 3B F5 83 8C F0 EE +R 00 00 00 08 +T 01 54 12 00 00 BE 0A CC +R 00 00 00 08 02 03 00 1E +T 01 5A +R 00 00 00 08 +T 01 5A +R 00 00 00 08 +T 01 5A +R 00 00 00 08 +T 01 5A ED 2A F5 82 E4 3B F5 83 8C F0 E4 12 00 00 +R 00 00 00 08 02 0E 00 1E +T 01 68 +R 00 00 00 08 +T 01 68 22 +R 00 00 00 08 +T 01 69 +R 00 00 00 08 +T 01 69 C3 74 0A 95 00 15 F5 82 +R 00 00 00 08 29 06 00 01 +T 01 70 +R 00 00 00 08 +T 01 70 22 +R 00 00 00 08 +T 01 71 +R 00 00 00 08 +T 01 71 85 00 14 82 +R 00 00 00 08 29 03 00 01 +T 01 74 +R 00 00 00 08 +T 01 74 22 +R 00 00 00 08 diff --git a/device/lib/small/serial.asm b/device/lib/small/serial.asm new file mode 100644 index 00000000..7bd45646 --- /dev/null +++ b/device/lib/small/serial.asm @@ -0,0 +1,508 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:18 2000 + +;-------------------------------------------------------- + .module serial +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _serial_getc + .globl _serial_putc + .globl _serial_interrupt_handler + .globl _serial_init +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +G$P0$0$0 == 0x0080 +_P0 = 0x0080 +G$P1$0$0 == 0x0090 +_P1 = 0x0090 +G$P2$0$0 == 0x00a0 +_P2 = 0x00a0 +G$P3$0$0 == 0x00b0 +_P3 = 0x00b0 +G$PSW$0$0 == 0x00d0 +_PSW = 0x00d0 +G$ACC$0$0 == 0x00e0 +_ACC = 0x00e0 +G$B$0$0 == 0x00f0 +_B = 0x00f0 +G$SP$0$0 == 0x0081 +_SP = 0x0081 +G$DPL$0$0 == 0x0082 +_DPL = 0x0082 +G$DPH$0$0 == 0x0083 +_DPH = 0x0083 +G$PCON$0$0 == 0x0087 +_PCON = 0x0087 +G$TCON$0$0 == 0x0088 +_TCON = 0x0088 +G$TMOD$0$0 == 0x0089 +_TMOD = 0x0089 +G$TL0$0$0 == 0x008a +_TL0 = 0x008a +G$TL1$0$0 == 0x008b +_TL1 = 0x008b +G$TH0$0$0 == 0x008c +_TH0 = 0x008c +G$TH1$0$0 == 0x008d +_TH1 = 0x008d +G$AUXR$0$0 == 0x008e +_AUXR = 0x008e +G$IE$0$0 == 0x00a8 +_IE = 0x00a8 +G$IP$0$0 == 0x00b8 +_IP = 0x00b8 +G$SCON$0$0 == 0x0098 +_SCON = 0x0098 +G$SBUF$0$0 == 0x0099 +_SBUF = 0x0099 +G$T2CON$0$0 == 0x00c8 +_T2CON = 0x00c8 +G$RCAP2H$0$0 == 0x00cb +_RCAP2H = 0x00cb +G$RCAP2L$0$0 == 0x00ca +_RCAP2L = 0x00ca +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +G$CY$0$0 == 0x00d7 +_CY = 0x00d7 +G$AC$0$0 == 0x00d6 +_AC = 0x00d6 +G$F0$0$0 == 0x00d5 +_F0 = 0x00d5 +G$RS1$0$0 == 0x00d4 +_RS1 = 0x00d4 +G$RS0$0$0 == 0x00d3 +_RS0 = 0x00d3 +G$OV$0$0 == 0x00d2 +_OV = 0x00d2 +G$P$0$0 == 0x00d0 +_P = 0x00d0 +G$TF1$0$0 == 0x008f +_TF1 = 0x008f +G$TR1$0$0 == 0x008e +_TR1 = 0x008e +G$TF0$0$0 == 0x008d +_TF0 = 0x008d +G$TR0$0$0 == 0x008c +_TR0 = 0x008c +G$IE1$0$0 == 0x008b +_IE1 = 0x008b +G$IT1$0$0 == 0x008a +_IT1 = 0x008a +G$IE0$0$0 == 0x0089 +_IE0 = 0x0089 +G$IT0$0$0 == 0x0088 +_IT0 = 0x0088 +G$EA$0$0 == 0x00af +_EA = 0x00af +G$ES$0$0 == 0x00ac +_ES = 0x00ac +G$ET1$0$0 == 0x00ab +_ET1 = 0x00ab +G$EX1$0$0 == 0x00aa +_EX1 = 0x00aa +G$ET0$0$0 == 0x00a9 +_ET0 = 0x00a9 +G$EX0$0$0 == 0x00a8 +_EX0 = 0x00a8 +G$PS$0$0 == 0x00bc +_PS = 0x00bc +G$PT1$0$0 == 0x00bb +_PT1 = 0x00bb +G$PX1$0$0 == 0x00ba +_PX1 = 0x00ba +G$PT0$0$0 == 0x00b9 +_PT0 = 0x00b9 +G$PX0$0$0 == 0x00b8 +_PX0 = 0x00b8 +G$RD$0$0 == 0x00b7 +_RD = 0x00b7 +G$WR$0$0 == 0x00b6 +_WR = 0x00b6 +G$T1$0$0 == 0x00b5 +_T1 = 0x00b5 +G$T0$0$0 == 0x00b4 +_T0 = 0x00b4 +G$INT1$0$0 == 0x00b3 +_INT1 = 0x00b3 +G$INT0$0$0 == 0x00b2 +_INT0 = 0x00b2 +G$TXD$0$0 == 0x00b1 +_TXD = 0x00b1 +G$RXD$0$0 == 0x00b0 +_RXD = 0x00b0 +G$P1_0$0$0 == 0x0090 +_P1_0 = 0x0090 +G$P1_1$0$0 == 0x0091 +_P1_1 = 0x0091 +G$P1_2$0$0 == 0x0092 +_P1_2 = 0x0092 +G$P1_3$0$0 == 0x0093 +_P1_3 = 0x0093 +G$P1_4$0$0 == 0x0094 +_P1_4 = 0x0094 +G$P1_5$0$0 == 0x0095 +_P1_5 = 0x0095 +G$P1_6$0$0 == 0x0096 +_P1_6 = 0x0096 +G$P1_7$0$0 == 0x0097 +_P1_7 = 0x0097 +G$SM0$0$0 == 0x009f +_SM0 = 0x009f +G$SM1$0$0 == 0x009e +_SM1 = 0x009e +G$SM2$0$0 == 0x009d +_SM2 = 0x009d +G$REN$0$0 == 0x009c +_REN = 0x009c +G$TB8$0$0 == 0x009b +_TB8 = 0x009b +G$RB8$0$0 == 0x009a +_RB8 = 0x009a +G$TI$0$0 == 0x0099 +_TI = 0x0099 +G$RI$0$0 == 0x0098 +_RI = 0x0098 +G$T2CON_0$0$0 == 0x00c8 +_T2CON_0 = 0x00c8 +G$T2CON_1$0$0 == 0x00c9 +_T2CON_1 = 0x00c9 +G$T2CON_2$0$0 == 0x00ca +_T2CON_2 = 0x00ca +G$T2CON_3$0$0 == 0x00cb +_T2CON_3 = 0x00cb +G$T2CON_4$0$0 == 0x00cc +_T2CON_4 = 0x00cc +G$T2CON_5$0$0 == 0x00cd +_T2CON_5 = 0x00cd +G$T2CON_6$0$0 == 0x00ce +_T2CON_6 = 0x00ce +G$T2CON_7$0$0 == 0x00cf +_T2CON_7 = 0x00cf +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +Fserial$work_flag_byte_arrived$0$0==. +_work_flag_byte_arrived: + .ds 0x0001 +Fserial$work_flag_buffer_transfered$0$0==. +_work_flag_buffer_transfered: + .ds 0x0001 +Fserial$tx_serial_buffer_empty$0$0==. +_tx_serial_buffer_empty: + .ds 0x0001 +Fserial$rx_serial_buffer_empty$0$0==. +_rx_serial_buffer_empty: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +Fserial$stx_index_in$0$0==. +_stx_index_in: + .ds 0x0001 +Fserial$srx_index_in$0$0==. +_srx_index_in: + .ds 0x0001 +Fserial$stx_index_out$0$0==. +_stx_index_out: + .ds 0x0001 +Fserial$srx_index_out$0$0==. +_srx_index_out: + .ds 0x0001 +Fserial$stx_buffer$0$0==. +_stx_buffer: + .ds 0x0100 +Fserial$srx_buffer$0$0==. +_srx_buffer: + .ds 0x0100 +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + G$serial_init$0$0 ==. +; serial.c 24 +; ----------------------------------------- +; function serial_init +; ----------------------------------------- +_serial_init: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; serial.c 26 + mov _SCON,#0x50 +; serial.c 27 + mov _T2CON,#0x34 +; serial.c 28 + setb _PS +; serial.c 29 + mov _T2CON,#0x34 +; serial.c 30 + mov _RCAP2H,#0xff +; serial.c 31 + mov _RCAP2L,#0xda +; serial.c 33 + clr _RI +; serial.c 34 + clr _TI +; serial.c 36 + mov dptr,#_srx_index_out +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_stx_index_out +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_srx_index_in +; Peephole 180 changed mov to clr + clr a + movx @dptr,a + mov dptr,#_stx_index_in +; Peephole 180 changed mov to clr + clr a + movx @dptr,a +; serial.c 37 + setb _tx_serial_buffer_empty + setb _rx_serial_buffer_empty +; serial.c 38 + clr _work_flag_buffer_transfered +; serial.c 39 + clr _work_flag_byte_arrived +; serial.c 40 + setb _ES +00101$: + C$serial.c$41$1$1 ==. + XG$serial_init$0$0 ==. + ret + G$serial_interrupt_handler$0$0 ==. +; serial.c 43 +; ----------------------------------------- +; function serial_interrupt_handler +; ----------------------------------------- +_serial_interrupt_handler: + ar2 = 0x0a + ar3 = 0x0b + ar4 = 0x0c + ar5 = 0x0d + ar6 = 0x0e + ar7 = 0x0f + ar0 = 0x08 + ar1 = 0x09 + push acc + push b + push dpl + push dph + push psw + mov psw,#0x08 +; serial.c 45 + clr _ES +; serial.c 46 +; Peephole 111 removed ljmp by inverse jump logic + jnb _TI,00105$ +00113$: +; serial.c 48 + clr _TI +; serial.c 49 + mov dptr,#_stx_index_in + movx a,@dptr + mov r2,a + mov dptr,#_stx_index_out + movx a,@dptr +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar2,00102$ +; Peephole 201 removed redundant sjmp +00114$: +00115$: +; serial.c 51 + setb _tx_serial_buffer_empty +; serial.c 52 + setb _work_flag_buffer_transfered +; Peephole 132 changed ljmp to sjmp + sjmp 00105$ +00102$: +; serial.c 54 + mov dptr,#_stx_index_out + mov a,#0x01 + add a,r3 + movx @dptr,a + mov a,r3 + add a,#_stx_buffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_stx_buffer >> 8) + mov dph,a + movx a,@dptr + mov _SBUF,a +00105$: +; serial.c 56 +; Peephole 111 removed ljmp by inverse jump logic + jnb _RI,00107$ +00116$: +; serial.c 58 + clr _RI +; serial.c 59 + mov dptr,#_srx_index_in + movx a,@dptr + mov r2,a + mov dptr,#_srx_index_in + mov a,#0x01 + add a,r2 + movx @dptr,a + mov a,r2 + add a,#_srx_buffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_srx_buffer >> 8) + mov dph,a + mov a,_SBUF + movx @dptr,a +; serial.c 60 + setb _work_flag_byte_arrived +; serial.c 61 + clr _rx_serial_buffer_empty +00107$: +; serial.c 63 + setb _ES +00108$: + pop psw + pop dph + pop dpl + pop b + pop acc + C$serial.c$64$1$1 ==. + XG$serial_interrupt_handler$0$0 ==. + reti + G$serial_putc$0$0 ==. +; serial.c 68 +; ----------------------------------------- +; function serial_putc +; ----------------------------------------- +_serial_putc: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 +; serial.c 77 + mov r2,dpl +; serial.c 70 + mov dptr,#_stx_index_in + movx a,@dptr + mov r3,a + mov dptr,#_stx_index_in + mov a,#0x01 + add a,r3 + movx @dptr,a + mov a,r3 + add a,#_stx_buffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_stx_buffer >> 8) + mov dph,a + mov a,r2 + movx @dptr,a +; serial.c 71 + clr _ES +; serial.c 72 +; Peephole 111 removed ljmp by inverse jump logic + jnb _tx_serial_buffer_empty,00102$ +00106$: +; serial.c 74 + clr _tx_serial_buffer_empty +; serial.c 75 + setb _TI +00102$: +; serial.c 77 + setb _ES +00103$: + C$serial.c$78$1$1 ==. + XG$serial_putc$0$0 ==. + ret + G$serial_getc$0$0 ==. +; serial.c 80 +; ----------------------------------------- +; function serial_getc +; ----------------------------------------- +_serial_getc: +; serial.c 82 + mov dptr,#_srx_index_out + movx a,@dptr +; Peephole 214 reduced some extra movs + mov r2,a + add a,#0x01 +; Peephole 100 removed redundant mov + mov r3,a + mov dptr,#_srx_index_out + movx @dptr,a + mov a,r2 + add a,#_srx_buffer + mov dpl,a +; Peephole 180 changed mov to clr + clr a + addc a,#(_srx_buffer >> 8) + mov dph,a + movx a,@dptr + mov r2,a +; serial.c 83 + clr _ES +; serial.c 84 + mov dptr,#_srx_index_in + movx a,@dptr + mov r4,a + mov a,r3 +; Peephole 132 changed ljmp to sjmp +; Peephole 199 optimized misc jump sequence + cjne a,ar4,00102$ +; Peephole 201 removed redundant sjmp +00106$: +00107$: + setb _rx_serial_buffer_empty +00102$: +; serial.c 85 + setb _ES +; serial.c 86 + mov dpl,r2 +00103$: + C$serial.c$87$1$1 ==. + XG$serial_getc$0$0 ==. + ret + .area CSEG (CODE) diff --git a/device/lib/small/serial.cdb b/device/lib/small/serial.cdb new file mode 100644 index 00000000..d635ef8e --- /dev/null +++ b/device/lib/small/serial.cdb @@ -0,0 +1,98 @@ +M:serial +F:G$serial_init$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$serial_interrupt_handler$0$0({2}DF,SV:S),C,0,0,1,4,1 +F:G$serial_putc$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$serial_getc$0$0({2}DF,SC:U),C,0,0,0,0,0 +S:Fserial$work_flag_byte_arrived$0$0({1}SB0$1:S),H,0,0 +S:Fserial$work_flag_buffer_transfered$0$0({1}SB0$1:S),H,0,0 +S:Fserial$tx_serial_buffer_empty$0$0({1}SB0$1:S),H,0,0 +S:Fserial$rx_serial_buffer_empty$0$0({1}SB0$1:S),H,0,0 +S:Fserial$stx_index_in$0$0({1}SC:U),F,0,0 +S:Fserial$srx_index_in$0$0({1}SC:U),F,0,0 +S:Fserial$stx_index_out$0$0({1}SC:U),F,0,0 +S:Fserial$srx_index_out$0$0({1}SC:U),F,0,0 +S:Fserial$stx_buffer$0$0({256}DA256,SC:U),F,0,0 +S:Fserial$srx_buffer$0$0({256}DA256,SC:U),F,0,0 +S:G$P0$0$0({1}SC:U),I,0,0 +S:G$P1$0$0({1}SC:U),I,0,0 +S:G$P2$0$0({1}SC:U),I,0,0 +S:G$P3$0$0({1}SC:U),I,0,0 +S:G$PSW$0$0({1}SC:U),I,0,0 +S:G$ACC$0$0({1}SC:U),I,0,0 +S:G$B$0$0({1}SC:U),I,0,0 +S:G$SP$0$0({1}SC:U),I,0,0 +S:G$DPL$0$0({1}SC:U),I,0,0 +S:G$DPH$0$0({1}SC:U),I,0,0 +S:G$PCON$0$0({1}SC:U),I,0,0 +S:G$TCON$0$0({1}SC:U),I,0,0 +S:G$TMOD$0$0({1}SC:U),I,0,0 +S:G$TL0$0$0({1}SC:U),I,0,0 +S:G$TL1$0$0({1}SC:U),I,0,0 +S:G$TH0$0$0({1}SC:U),I,0,0 +S:G$TH1$0$0({1}SC:U),I,0,0 +S:G$AUXR$0$0({1}SC:U),I,0,0 +S:G$IE$0$0({1}SC:U),I,0,0 +S:G$IP$0$0({1}SC:U),I,0,0 +S:G$SCON$0$0({1}SC:U),I,0,0 +S:G$SBUF$0$0({1}SC:U),I,0,0 +S:G$T2CON$0$0({1}SC:U),I,0,0 +S:G$RCAP2H$0$0({1}SC:U),I,0,0 +S:G$RCAP2L$0$0({1}SC:U),I,0,0 +S:G$CY$0$0({1}SX:S),J,0,0 +S:G$AC$0$0({1}SX:S),J,0,0 +S:G$F0$0$0({1}SX:S),J,0,0 +S:G$RS1$0$0({1}SX:S),J,0,0 +S:G$RS0$0$0({1}SX:S),J,0,0 +S:G$OV$0$0({1}SX:S),J,0,0 +S:G$P$0$0({1}SX:S),J,0,0 +S:G$TF1$0$0({1}SX:S),J,0,0 +S:G$TR1$0$0({1}SX:S),J,0,0 +S:G$TF0$0$0({1}SX:S),J,0,0 +S:G$TR0$0$0({1}SX:S),J,0,0 +S:G$IE1$0$0({1}SX:S),J,0,0 +S:G$IT1$0$0({1}SX:S),J,0,0 +S:G$IE0$0$0({1}SX:S),J,0,0 +S:G$IT0$0$0({1}SX:S),J,0,0 +S:G$EA$0$0({1}SX:S),J,0,0 +S:G$ES$0$0({1}SX:S),J,0,0 +S:G$ET1$0$0({1}SX:S),J,0,0 +S:G$EX1$0$0({1}SX:S),J,0,0 +S:G$ET0$0$0({1}SX:S),J,0,0 +S:G$EX0$0$0({1}SX:S),J,0,0 +S:G$PS$0$0({1}SX:S),J,0,0 +S:G$PT1$0$0({1}SX:S),J,0,0 +S:G$PX1$0$0({1}SX:S),J,0,0 +S:G$PT0$0$0({1}SX:S),J,0,0 +S:G$PX0$0$0({1}SX:S),J,0,0 +S:G$RD$0$0({1}SX:S),J,0,0 +S:G$WR$0$0({1}SX:S),J,0,0 +S:G$T1$0$0({1}SX:S),J,0,0 +S:G$T0$0$0({1}SX:S),J,0,0 +S:G$INT1$0$0({1}SX:S),J,0,0 +S:G$INT0$0$0({1}SX:S),J,0,0 +S:G$TXD$0$0({1}SX:S),J,0,0 +S:G$RXD$0$0({1}SX:S),J,0,0 +S:G$P1_0$0$0({1}SX:S),J,0,0 +S:G$P1_1$0$0({1}SX:S),J,0,0 +S:G$P1_2$0$0({1}SX:S),J,0,0 +S:G$P1_3$0$0({1}SX:S),J,0,0 +S:G$P1_4$0$0({1}SX:S),J,0,0 +S:G$P1_5$0$0({1}SX:S),J,0,0 +S:G$P1_6$0$0({1}SX:S),J,0,0 +S:G$P1_7$0$0({1}SX:S),J,0,0 +S:G$SM0$0$0({1}SX:S),J,0,0 +S:G$SM1$0$0({1}SX:S),J,0,0 +S:G$SM2$0$0({1}SX:S),J,0,0 +S:G$REN$0$0({1}SX:S),J,0,0 +S:G$TB8$0$0({1}SX:S),J,0,0 +S:G$RB8$0$0({1}SX:S),J,0,0 +S:G$TI$0$0({1}SX:S),J,0,0 +S:G$RI$0$0({1}SX:S),J,0,0 +S:G$T2CON_0$0$0({1}SX:S),J,0,0 +S:G$T2CON_1$0$0({1}SX:S),J,0,0 +S:G$T2CON_2$0$0({1}SX:S),J,0,0 +S:G$T2CON_3$0$0({1}SX:S),J,0,0 +S:G$T2CON_4$0$0({1}SX:S),J,0,0 +S:G$T2CON_5$0$0({1}SX:S),J,0,0 +S:G$T2CON_6$0$0({1}SX:S),J,0,0 +S:G$T2CON_7$0$0({1}SX:S),J,0,0 diff --git a/device/lib/small/serial.rel b/device/lib/small/serial.rel new file mode 100644 index 00000000..c4e1150a --- /dev/null +++ b/device/lib/small/serial.rel @@ -0,0 +1,394 @@ +;!FILE serial.asm +XH +H 9 areas EF global symbols +M serial +S G$EX0$0$0 Def00A8 +S G$IT0$0$0 Def0088 +S G$TH1$0$0 Def008D +S G$TB8$0$0 Def009B +S G$RXD$0$0 Def00B0 +S G$EX1$0$0 Def00AA +S G$IT1$0$0 Def008A +S G$IE$0$0 Def00A8 +S G$SM0$0$0 Def009F +S G$TXD$0$0 Def00B1 +S G$TL0$0$0 Def008A +S G$SM1$0$0 Def009E +S G$TL1$0$0 Def008B +S G$SM2$0$0 Def009D +S G$PT0$0$0 Def00B9 +S G$PT1$0$0 Def00BB +S G$RS0$0$0 Def00D3 +S G$RD$0$0 Def00B7 +S G$TR0$0$0 Def008C +S G$RS1$0$0 Def00D4 +S G$F0$0$0 Def00D5 +S G$TR1$0$0 Def008E +S G$PX0$0$0 Def00B8 +S G$ES$0$0 Def00AC +S G$PX1$0$0 Def00BA +S G$IP$0$0 Def00B8 +S G$PSW$0$0 Def00D0 +S G$RI$0$0 Def0098 +S G$CY$0$0 Def00D7 +S G$TI$0$0 Def0099 +S G$P0$0$0 Def0080 +S G$P1$0$0 Def0090 +S G$B$0$0 Def00F0 +S G$P2$0$0 Def00A0 +S G$PS$0$0 Def00BC +S G$SP$0$0 Def0081 +S G$P3$0$0 Def00B0 +S G$T0$0$0 Def00B4 +S G$T1$0$0 Def00B5 +S G$OV$0$0 Def00D2 +S G$T2CON$0$0 Def00C8 +S G$ACC$0$0 Def00E0 +S G$WR$0$0 Def00B6 +S G$P1_0$0$0 Def0090 +S G$P$0$0 Def00D0 +S G$SBUF$0$0 Def0099 +S G$PCON$0$0 Def0087 +S G$P1_1$0$0 Def0091 +S G$P1_2$0$0 Def0092 +S G$P1_3$0$0 Def0093 +S G$SCON$0$0 Def0098 +S G$P1_4$0$0 Def0094 +S G$TMOD$0$0 Def0089 +S G$TCON$0$0 Def0088 +S G$T2CON_0$0$0 Def00C8 +S G$P1_5$0$0 Def0095 +S G$T2CON_1$0$0 Def00C9 +S G$P1_6$0$0 Def0096 +S G$T2CON_2$0$0 Def00CA +S G$P1_7$0$0 Def0097 +S G$T2CON_3$0$0 Def00CB +S G$T2CON_4$0$0 Def00CC +S G$T2CON_5$0$0 Def00CD +S G$T2CON_6$0$0 Def00CE +S G$INT0$0$0 Def00B2 +S G$T2CON_7$0$0 Def00CF +S G$INT1$0$0 Def00B3 +S G$DPH$0$0 Def0083 +S G$IE0$0$0 Def0089 +S G$IE1$0$0 Def008B +S G$RCAP2H$0$0 Def00CB +S G$AUXR$0$0 Def008E +S G$DPL$0$0 Def0082 +S G$AC$0$0 Def00D6 +S G$RCAP2L$0$0 Def00CA +S G$REN$0$0 Def009C +S G$EA$0$0 Def00AF +S G$ET0$0$0 Def00A9 +S G$ET1$0$0 Def00AB +S G$TF0$0$0 Def008D +S G$TF1$0$0 Def008F +S G$RB8$0$0 Def009A +S G$TH0$0$0 Def008C +A _CODE size 0 flags 0 +A DSEG size 0 flags 0 +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size 4 flags 80 +S Fserial$work_flag_byte_arrived$0$0 Def0000 +S Fserial$work_flag_buffer_transfered$0$0 Def0001 +S Fserial$rx_serial_buffer_empty$0$0 Def0003 +S Fserial$tx_serial_buffer_empty$0$0 Def0002 +A XSEG size 204 flags 40 +S Fserial$srx_buffer$0$0 Def0104 +S Fserial$stx_buffer$0$0 Def0004 +S Fserial$srx_index_in$0$0 Def0001 +S Fserial$srx_index_out$0$0 Def0003 +S Fserial$stx_index_in$0$0 Def0000 +S Fserial$stx_index_out$0$0 Def0002 +A GSINIT size 0 flags 20 +A CSEG size EE flags 20 +S A$serial$430 Def00A5 +S A$serial$403 Def0095 +S A$serial$340 Def0050 +S A$serial$331 Def0043 +S A$serial$322 Def0036 +S A$serial$503 Def00EB +S A$serial$440 Def00B4 +S A$serial$431 Def00A8 +S A$serial$404 Def0097 +S A$serial$350 Def0055 +S A$serial$323 Def0038 +S A$serial$450 Def00BD +S A$serial$441 Def00B6 +S A$serial$432 Def00AA +S A$serial$405 Def0099 +S A$serial$360 Def0061 +S A$serial$342 Def0051 +S A$serial$324 Def003A +S A$serial$306 Def0033 +S A$serial$270 Def000B +S A$serial$442 Def00B7 +S A$serial$433 Def00AB +S A$serial$406 Def009B +S A$serial$361 Def0062 +S A$serial$352 Def0057 +S A$serial$334 Def0046 +S A$serial$325 Def003C +S A$serial$280 Def0018 +S A$serial$262 Def0000 +S A$serial$470 Def00C8 +S A$serial$452 Def00BF +S A$serial$434 Def00AC +S A$serial$425 Def009E +S A$serial$380 Def0078 +S A$serial$362 Def0063 +S A$serial$326 Def003E +S A$serial$290 Def0024 +S A$serial$281 Def0019 +S A$serial$272 Def000E +S A$serial$507 Def00ED +S A$serial$480 Def00D5 +S A$serial$471 Def00C9 +S A$serial$444 Def00B8 +S A$serial$435 Def00AD +S A$serial$390 Def0086 +S A$serial$381 Def0079 +S A$serial$363 Def0065 +S A$serial$354 Def0059 +S A$serial$345 Def0052 +S A$serial$336 Def0048 +S A$serial$282 Def001A +S A$serial$264 Def0003 +S A$serial$490 Def00E2 +S A$serial$481 Def00D6 +S A$serial$436 Def00AF +S A$serial$427 Def00A0 +S A$serial$409 Def009D +S A$serial$391 Def0088 +S A$serial$382 Def007C +S A$serial$373 Def006F +S A$serial$337 Def004B +S A$serial$328 Def0041 +S A$serial$292 Def0027 +S A$serial$274 Def0011 +S XG$serial_putc$0$0 Def00C3 +S G$serial_init$0$0 Def0000 +S A$serial$491 Def00E3 +S A$serial$482 Def00D8 +S A$serial$473 Def00CB +S A$serial$455 Def00C1 +S A$serial$428 Def00A3 +S A$serial$392 Def008A +S A$serial$383 Def007E +S A$serial$365 Def0067 +S A$serial$338 Def004C +S A$serial$293 Def0028 +S A$serial$284 Def001D +S A$serial$266 Def0006 +S A$serial$483 Def00DA +S A$serial$474 Def00CC +S A$serial$447 Def00BA +S A$serial$438 Def00B1 +S A$serial$429 Def00A4 +S A$serial$393 Def008C +S A$serial$384 Def007F +S A$serial$366 Def0068 +S A$serial$357 Def005B +S A$serial$339 Def004D +S A$serial$285 Def001E +S A$serial$276 Def0013 +S A$serial$484 Def00DB +S A$serial$475 Def00CF +S A$serial$439 Def00B2 +S A$serial$385 Def0080 +S A$serial$376 Def0072 +S A$serial$367 Def006A +S A$serial$358 Def005E +S A$serial$295 Def0029 +S A$serial$286 Def001F +S A$serial$268 Def0008 +S A$serial$494 Def00E4 +S A$serial$476 Def00D0 +S A$serial$467 Def00C4 +S A$serial$395 Def008D +S A$serial$386 Def0081 +S A$serial$368 Def006C +S A$serial$359 Def0060 +S A$serial$296 Def002B +S A$serial$278 Def0015 +S A$serial$486 Def00DC +S A$serial$477 Def00D1 +S A$serial$468 Def00C7 +S A$serial$459 Def00C3 +S A$serial$387 Def0083 +S A$serial$378 Def0074 +S A$serial$369 Def006D +S A$serial$288 Def0022 +S C$serial.c$41$1$1 Def0033 +S A$serial$478 Def00D3 +S A$serial$397 Def008F +S A$serial$379 Def0077 +S A$serial$298 Def002D +S A$serial$289 Def0023 +S A$serial$488 Def00DE +S A$serial$389 Def0085 +S A$serial$498 Def00E7 +S A$serial$489 Def00E1 +S G$serial_putc$0$0 Def009E +S C$serial.c$64$1$1 Def009D +S C$serial.c$87$1$1 Def00ED +S C$serial.c$78$1$1 Def00C3 +S _serial_getc Def00C4 +S _serial_interrupt_handler Def0034 +S XG$serial_getc$0$0 Def00ED +S _serial_init Def0000 +S XG$serial_interrupt_handler$0$0 Def009D +S G$serial_getc$0$0 Def00C4 +S _serial_putc Def009E +S A$serial$300 Def002F +S G$serial_interrupt_handler$0$0 Def0034 +S A$serial$400 Def0091 +S A$serial$302 Def0031 +S XG$serial_init$0$0 Def0033 +S A$serial$501 Def00E9 +S A$serial$402 Def0093 +S A$serial$321 Def0034 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 00 +R 00 00 00 06 +T 00 00 +R 00 00 00 06 +T 00 01 +R 00 00 00 06 +T 00 01 +R 00 00 00 06 +T 00 02 +R 00 00 00 06 +T 00 02 +R 00 00 00 06 +T 00 03 +R 00 00 00 06 +T 00 03 +R 00 00 00 06 +T 00 04 +R 00 00 00 06 +T 00 04 +R 00 00 00 06 +T 01 04 +R 00 00 00 06 +T 01 04 +R 00 00 00 06 +T 00 00 +R 00 00 00 08 +T 00 00 75 98 50 75 C8 34 D2 BC 75 C8 34 75 CB FF +R 00 00 00 08 +T 00 0E 75 CA DA C2 98 C2 99 90 00 03 E4 F0 90 +R 00 00 00 08 00 0A 00 06 +T 00 1B 00 02 E4 F0 90 00 01 E4 F0 90 00 00 E4 F0 +R 00 00 00 08 00 02 00 06 00 07 00 06 00 0C 00 06 +T 00 29 D2 00 02 D2 00 03 C2 00 01 C2 +R 00 00 00 08 29 03 00 05 29 06 00 05 29 09 00 05 +T 00 30 00 00 D2 AC +R 00 00 00 08 29 02 00 05 +T 00 33 +R 00 00 00 08 +T 00 33 22 +R 00 00 00 08 +T 00 34 +R 00 00 00 08 +T 00 34 C0 E0 C0 F0 C0 82 C0 83 C0 D0 75 D0 08 C2 +R 00 00 00 08 +T 00 42 AC 30 99 29 +R 00 00 00 08 +T 00 46 +R 00 00 00 08 +T 00 46 C2 99 90 00 00 E0 FA 90 00 02 E0 FB B5 0A +R 00 00 00 08 00 05 00 06 00 0A 00 06 +T 00 54 06 +R 00 00 00 08 +T 00 55 +R 00 00 00 08 +T 00 55 +R 00 00 00 08 +T 00 55 D2 00 02 D2 00 01 80 14 +R 00 00 00 08 29 03 00 05 29 06 00 05 +T 00 5B +R 00 00 00 08 +T 00 5B 90 00 02 74 01 2B F0 EB 24 00 04 F5 82 E4 +R 00 00 00 08 00 03 00 06 09 0B 00 06 +T 00 68 34 00 04 F5 83 E0 F5 99 +R 00 00 00 08 89 03 00 06 +T 00 6F +R 00 00 00 08 +T 00 6F 30 98 1F +R 00 00 00 08 +T 00 72 +R 00 00 00 08 +T 00 72 C2 98 90 00 01 E0 FA 90 00 01 74 01 2A F0 +R 00 00 00 08 00 05 00 06 00 0A 00 06 +T 00 80 EA 24 01 04 F5 82 E4 34 01 04 F5 83 E5 99 +R 00 00 00 08 09 04 00 06 89 0A 00 06 +T 00 8C F0 D2 00 00 C2 00 03 +R 00 00 00 08 29 04 00 05 29 07 00 05 +T 00 91 +R 00 00 00 08 +T 00 91 D2 AC +R 00 00 00 08 +T 00 93 +R 00 00 00 08 +T 00 93 D0 D0 D0 83 D0 82 D0 F0 D0 E0 32 +R 00 00 00 08 +T 00 9E +R 00 00 00 08 +T 00 9E AA 82 90 00 00 E0 FB 90 00 00 74 01 2B F0 +R 00 00 00 08 00 05 00 06 00 0A 00 06 +T 00 AC EB 24 00 04 F5 82 E4 34 00 04 F5 83 EA F0 +R 00 00 00 08 09 04 00 06 89 0A 00 06 +T 00 B8 C2 AC 30 00 02 04 +R 00 00 00 08 29 05 00 05 +T 00 BD +R 00 00 00 08 +T 00 BD C2 00 02 D2 99 +R 00 00 00 08 29 03 00 05 +T 00 C1 +R 00 00 00 08 +T 00 C1 D2 AC +R 00 00 00 08 +T 00 C3 +R 00 00 00 08 +T 00 C3 22 +R 00 00 00 08 +T 00 C4 +R 00 00 00 08 +T 00 C4 90 00 03 E0 FA 24 01 FB 90 00 03 F0 EA 24 +R 00 00 00 08 00 03 00 06 00 0B 00 06 +T 00 D2 01 04 F5 82 E4 34 01 04 F5 83 E0 FA C2 AC +R 00 00 00 08 09 02 00 06 89 08 00 06 +T 00 DE 90 00 01 E0 FC EB B5 04 02 +R 00 00 00 08 00 03 00 06 +T 00 E7 +R 00 00 00 08 +T 00 E7 +R 00 00 00 08 +T 00 E7 D2 00 03 +R 00 00 00 08 29 03 00 05 +T 00 E9 +R 00 00 00 08 +T 00 E9 D2 AC 8A 82 +R 00 00 00 08 +T 00 ED +R 00 00 00 08 +T 00 ED 22 +R 00 00 00 08 diff --git a/device/lib/small/vprintf.asm b/device/lib/small/vprintf.asm new file mode 100644 index 00000000..14679413 --- /dev/null +++ b/device/lib/small/vprintf.asm @@ -0,0 +1,1237 @@ +;-------------------------------------------------------- +; File Created by SDCC : FreeWare ANSI-C Compiler +; Version 2.1.9Ga Sun Jan 16 17:31:21 2000 + +;-------------------------------------------------------- + .module vprintf +;-------------------------------------------------------- +; publics variables in this module +;-------------------------------------------------------- + .globl _lsd + .globl _lower_case + .globl _output_to_string + .globl _vprintf_PARM_2 + .globl _vsprintf_PARM_3 + .globl _vsprintf_PARM_2 + .globl _radix + .globl _value + .globl _output_ptr + .globl _vsprintf + .globl _vprintf +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function bits +;-------------------------------------------------------- +;-------------------------------------------------------- +; internal ram data +;-------------------------------------------------------- + .area DSEG (DATA) +G$output_ptr$0$0==. +_output_ptr: + .ds 0x0003 +G$value$0$0==. +_value: + .ds 0x0005 +G$radix$0$0==. +_radix: + .ds 0x0001 +_vsprintf_PARM_2: + .ds 0x0003 +_vsprintf_PARM_3: + .ds 0x0001 +_vsprintf_width_1_1: + .ds 0x0001 +_vsprintf_length_1_1: + .ds 0x0001 +_vsprintf_c_1_1: + .ds 0x0001 +_vsprintf_sloc0_1_0: + .ds 0x0001 +_vsprintf_sloc1_1_0: + .ds 0x0001 +_vsprintf_sloc2_1_0: + .ds 0x0001 +_vsprintf_sloc3_1_0: + .ds 0x0001 +_vsprintf_sloc4_1_0: + .ds 0x0001 +_vsprintf_sloc5_1_0: + .ds 0x0001 +_vsprintf_sloc6_1_0: + .ds 0x0001 +_vsprintf_sloc7_1_0: + .ds 0x0003 +_vprintf_PARM_2: + .ds 0x0001 +;-------------------------------------------------------- +; overlayable items in internal ram +;-------------------------------------------------------- + .area _DUMMY + .area OSEG (OVR,DATA) +;-------------------------------------------------------- +; indirectly addressable internal ram data +;-------------------------------------------------------- + .area ISEG (DATA) +;-------------------------------------------------------- +; bit data +;-------------------------------------------------------- + .area BSEG (BIT) +G$output_to_string$0$0==. +_output_to_string: + .ds 0x0001 +G$lower_case$0$0==. +_lower_case: + .ds 0x0001 +G$lsd$0$0==. +_lsd: + .ds 0x0001 +_vsprintf_left_justify_1_1: + .ds 0x0001 +_vsprintf_zero_padding_1_1: + .ds 0x0001 +_vsprintf_prefix_sign_1_1: + .ds 0x0001 +_vsprintf_prefix_space_1_1: + .ds 0x0001 +_vsprintf_signed_argument_1_1: + .ds 0x0001 +_vsprintf_char_argument_1_1: + .ds 0x0001 +_vsprintf_long_argument_1_1: + .ds 0x0001 +;-------------------------------------------------------- +; external ram data +;-------------------------------------------------------- + .area XSEG (XDATA) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area GSINIT (CODE) +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) + Fvprintf$output_char$0$0 ==. +; vprintf.c 63 +; ----------------------------------------- +; function output_char +; ----------------------------------------- +_output_char: + ar2 = 0x02 + ar3 = 0x03 + ar4 = 0x04 + ar5 = 0x05 + ar6 = 0x06 + ar7 = 0x07 + ar0 = 0x00 + ar1 = 0x01 + push _bp + mov _bp,sp +; vprintf.c 0 + mov r2,dpl +; vprintf.c 65 +; Peephole 111 removed ljmp by inverse jump logic + jnb _output_to_string,00102$ +00107$: +; vprintf.c 67 + mov r3,_output_ptr + mov r4,(_output_ptr + 1) + mov r5,(_output_ptr + 2) + inc _output_ptr + clr a + cjne a,_output_ptr,00108$ + inc (_output_ptr + 1) +00108$: + mov dpl,r3 + mov dph,r4 + mov b,r5 + mov a,r2 + lcall __gptrput +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00102$: +; vprintf.c 71 + mov dpl,r2 + lcall _putchar +00104$: + mov sp,_bp + pop _bp + C$vprintf.c$73$1$1 ==. + XFvprintf$output_char$0$0 ==. + ret + Fvprintf$output_digit$0$0 ==. +; vprintf.c 77 +; ----------------------------------------- +; function output_digit +; ----------------------------------------- +_output_digit: + push _bp + mov _bp,sp +; vprintf.c 79 + mov r2,dpl + clr c + mov a,#0x09 + subb a,r2 + clr a + rlc a +; Peephole 105 removed redundant mov + mov r3,a + cjne a,#0x01,00109$ +00109$: + clr a + rlc a +; Peephole 105 removed redundant mov + mov r3,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00103$ +00110$: + mov a,#0x30 + add a,r2 + mov r3,a +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00103$: +; Peephole 111 removed ljmp by inverse jump logic + jnb _lower_case,00105$ +00111$: + mov a,#0x57 + add a,r2 + mov r4,a +; Peephole 132 changed ljmp to sjmp + sjmp 00106$ +00105$: + mov a,#0x37 + add a,r2 + mov r4,a +00106$: + mov ar3,r4 +00104$: + mov dpl,r3 + lcall _output_char +00101$: + mov sp,_bp + pop _bp + C$vprintf.c$80$1$1 ==. + XFvprintf$output_digit$0$0 ==. + ret + Fvprintf$output_2digits$0$0 ==. +; vprintf.c 84 +; ----------------------------------------- +; function output_2digits +; ----------------------------------------- +_output_2digits: + push _bp + mov _bp,sp +; vprintf.c 87 + mov r2,dpl +; vprintf.c 86 + mov a,r2 + swap a + anl a,#0x0f + mov dpl,a + push ar2 + lcall _output_digit + pop ar2 +; vprintf.c 87 + mov a,#0x0f + anl a,r2 + mov dpl,a + lcall _output_digit +00101$: + mov sp,_bp + pop _bp + C$vprintf.c$88$1$1 ==. + XFvprintf$output_2digits$0$0 ==. + ret + Fvprintf$calculate_digit$0$0 ==. +; vprintf.c 92 +; ----------------------------------------- +; function calculate_digit +; ----------------------------------------- +_calculate_digit: +; vprintf.c 96 + mov r2,#0x20 +00103$: + cjne r2,#0x00,00112$ +; Peephole 132 changed ljmp to sjmp + sjmp 00107$ +00112$: +; vprintf.c 115 + clr c + mov a,_value+0 + rlc a + mov _value+0,a + mov a,_value+1 + rlc a + mov _value+1,a + mov a,_value+2 + rlc a + mov _value+2,a + mov a,_value+3 + rlc a + mov _value+3,a + mov a,_value+4 + rlc a + mov _value+4,a +; vprintf.c 117 + clr c + mov a,0x0004 + _value + subb a,_radix +; Peephole 132 changed ljmp to sjmp +; Peephole 160 removed sjmp by inverse jump logic + jc 00105$ +00113$: +; vprintf.c 119 + clr c + mov a,0x0004 + _value + subb a,_radix + mov 0x0004 + _value,a +; vprintf.c 120 + mov a,#0x01 + add a,_value + mov _value,a +00105$: +; vprintf.c 96 + dec r2 +; Peephole 132 changed ljmp to sjmp + sjmp 00103$ +00107$: + C$vprintf.c$123$1$1 ==. + XFvprintf$calculate_digit$0$0 ==. + ret + G$vsprintf$0$0 ==. +; vprintf.c 127 +; ----------------------------------------- +; function vsprintf +; ----------------------------------------- +_vsprintf: +; vprintf.c 0 + mov r2,dpl + mov r3,dph + mov r4,b +; vprintf.c 141 + mov _output_ptr,r2 + mov (_output_ptr + 1),r3 + mov (_output_ptr + 2),r4 +; vprintf.c 142 + mov a,r2 + orl a,r3 + orl a,r4 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00102$ +00262$: +; vprintf.c 144 + clr _output_to_string +; Peephole 132 changed ljmp to sjmp + sjmp 00237$ +00102$: +; vprintf.c 148 + setb _output_to_string +; vprintf.c 151 +00237$: +00193$: + mov r2,_vsprintf_PARM_2 + mov r3,(_vsprintf_PARM_2 + 1) + mov r4,(_vsprintf_PARM_2 + 2) + mov a,#0x01 + add a,r2 + mov r5,a +; Peephole 180 changed mov to clr + clr a + addc a,r3 + mov r6,a + mov ar7,r4 + mov _vsprintf_PARM_2,r5 + mov (_vsprintf_PARM_2 + 1),r6 + mov (_vsprintf_PARM_2 + 2),r7 + mov dpl,r2 + mov dph,r3 + mov b,r4 + lcall __gptrget +; Peephole 166 removed redundant mov + mov r2,a + mov _vsprintf_c_1_1,r2 + jnz 00263$ + ljmp 00195$ +00263$: +; vprintf.c 153 + mov a,_vsprintf_c_1_1 + cjne a,#0x25,00264$ + sjmp 00265$ +00264$: + ljmp 00191$ +00265$: +; vprintf.c 155 + clr _vsprintf_left_justify_1_1 +; vprintf.c 156 + clr _vsprintf_zero_padding_1_1 +; vprintf.c 157 + clr _vsprintf_prefix_sign_1_1 +; vprintf.c 158 + clr _vsprintf_prefix_space_1_1 +; vprintf.c 159 + clr _vsprintf_signed_argument_1_1 +; vprintf.c 160 + mov _radix,#0x00 +; vprintf.c 161 + clr _vsprintf_char_argument_1_1 +; vprintf.c 162 + clr _vsprintf_long_argument_1_1 +; vprintf.c 163 + mov _vsprintf_width_1_1,#0x00 +; vprintf.c 167 + mov _vsprintf_PARM_2,r5 + mov (_vsprintf_PARM_2 + 1),r6 + mov (_vsprintf_PARM_2 + 2),r7 +00104$: + mov dpl,_vsprintf_PARM_2 + mov dph,(_vsprintf_PARM_2 + 1) + mov b,(_vsprintf_PARM_2 + 2) + inc _vsprintf_PARM_2 + clr a + cjne a,_vsprintf_PARM_2,00266$ + inc (_vsprintf_PARM_2 + 1) +00266$: + lcall __gptrget + mov _vsprintf_c_1_1,a +; vprintf.c 169 + mov dpl,_vsprintf_c_1_1 + lcall _isdigit + mov r1,dpl + mov a,r1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00108$ +00267$: +; vprintf.c 171 + mov b,#0x0a + mov a,_vsprintf_width_1_1 + mul ab + mov r5,a + mov a,_vsprintf_c_1_1 + add a,#0xd0 +; Peephole 105 removed redundant mov + mov r6,a + add a,r5 +; vprintf.c 173 +; Peephole 105 removed redundant mov + mov _vsprintf_width_1_1,a + jnz 00268$ + mov a,#0x01 + sjmp 00269$ +00268$: + clr a +00269$: +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00104$ +00270$: +; vprintf.c 176 + setb _vsprintf_zero_padding_1_1 +; vprintf.c 178 +; Peephole 132 changed ljmp to sjmp + sjmp 00104$ +00108$: +; vprintf.c 181 + mov dpl,_vsprintf_c_1_1 + push ar5 + push ar6 + push ar7 + push ar1 + lcall _islower + mov r2,dpl + pop ar1 + pop ar7 + pop ar6 + pop ar5 + mov a,r2 + cjne a,#0x01,00271$ +00271$: + cpl c + mov _lower_case,c +; vprintf.c 182 +; Peephole 111 removed ljmp by inverse jump logic + jnb _lower_case,00110$ +00272$: +; vprintf.c 184 + mov a,#0xdf + anl a,_vsprintf_c_1_1 + mov _vsprintf_c_1_1,a +00110$: +; vprintf.c 187 + mov a,_vsprintf_c_1_1 + cjne a,#0x20,00273$ + mov a,#0x01 + sjmp 00274$ +00273$: + clr a +00274$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc0_1_0,a + jz 00275$ + ljmp 00113$ +00275$: + mov a,_vsprintf_c_1_1 + cjne a,#0x2b,00276$ + mov a,#0x01 + sjmp 00277$ +00276$: + clr a +00277$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc1_1_0,a + jz 00278$ + ljmp 00112$ +00278$: + mov a,_vsprintf_c_1_1 + cjne a,#0x2d,00279$ + mov a,#0x01 + sjmp 00280$ +00279$: + clr a +00280$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc2_1_0,a + jz 00281$ + ljmp 00111$ +00281$: + mov a,_vsprintf_c_1_1 + cjne a,#0x42,00282$ + mov a,#0x01 + sjmp 00283$ +00282$: + clr a +00283$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc3_1_0,a + jz 00284$ + ljmp 00114$ +00284$: + mov a,_vsprintf_c_1_1 + cjne a,#0x43,00285$ + mov a,#0x01 + sjmp 00286$ +00285$: + clr a +00286$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc4_1_0,a + jz 00287$ + ljmp 00116$ +00287$: + mov a,_vsprintf_c_1_1 + cjne a,#0x44,00288$ + mov a,#0x01 + sjmp 00289$ +00288$: + clr a +00289$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc5_1_0,a + jz 00290$ + ljmp 00137$ +00290$: + mov a,_vsprintf_c_1_1 + cjne a,#0x49,00291$ + mov a,#0x01 + sjmp 00292$ +00291$: + clr a +00292$: +; Peephole 105 removed redundant mov + mov _vsprintf_sloc6_1_0,a + jz 00293$ + ljmp 00137$ +00293$: + mov a,_vsprintf_c_1_1 + cjne a,#0x4c,00294$ + mov a,#0x01 + sjmp 00295$ +00294$: + clr a +00295$: +; Peephole 105 removed redundant mov + mov r0,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00115$ +00296$: + mov a,_vsprintf_c_1_1 + cjne a,#0x4f,00297$ + ljmp 00139$ +00297$: + mov a,_vsprintf_c_1_1 + cjne a,#0x50,00298$ + ljmp 00133$ +00298$: + mov a,_vsprintf_c_1_1 + cjne a,#0x53,00299$ +; Peephole 132 changed ljmp to sjmp + sjmp 00117$ +00299$: + mov a,_vsprintf_c_1_1 + cjne a,#0x55,00300$ + ljmp 00140$ +00300$: + mov a,_vsprintf_c_1_1 + cjne a,#0x58,00301$ + ljmp 00141$ +00301$: + ljmp 00142$ +; vprintf.c 190 +00111$: + setb _vsprintf_left_justify_1_1 +; vprintf.c 191 + ljmp 00104$ +; vprintf.c 193 +00112$: + setb _vsprintf_prefix_sign_1_1 +; vprintf.c 194 + ljmp 00104$ +; vprintf.c 196 +00113$: + setb _vsprintf_prefix_space_1_1 +; vprintf.c 197 + ljmp 00104$ +; vprintf.c 199 +00114$: + setb _vsprintf_char_argument_1_1 +; vprintf.c 200 + ljmp 00104$ +; vprintf.c 202 +00115$: + setb _vsprintf_long_argument_1_1 +; vprintf.c 203 + ljmp 00104$ +; vprintf.c 206 +00116$: + mov a,_vsprintf_PARM_3 + add a,#0xff + mov r0,a + mov _vsprintf_PARM_3,r0 + mov dpl,@r0 + lcall _output_char +; vprintf.c 207 + ljmp 00143$ +; vprintf.c 210 +00117$: + mov a,_vsprintf_PARM_3 + add a,#0xfd + mov r0,a + mov _vsprintf_PARM_3,r0 + mov ar2,@r0 + inc r0 + mov ar5,@r0 + inc r0 + mov ar6,@r0 + dec r0 + dec r0 + mov _value,r2 + mov (_value + 1),r5 + mov (_value + 2),r6 +; vprintf.c 212 + mov dpl,r2 + mov dph,r5 + mov b,r6 + lcall _strlen + mov r2,dpl + mov r5,dph + mov _vsprintf_length_1_1,r2 +; vprintf.c 213 +; Peephole 112 removed ljmp by inverse jump logic + jb _vsprintf_left_justify_1_1,00124$ +00302$: + clr c + mov a,_vsprintf_length_1_1 + subb a,_vsprintf_width_1_1 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00124$ +00303$: +; vprintf.c 215 + clr c + mov a,_vsprintf_width_1_1 + subb a,_vsprintf_length_1_1 + mov _vsprintf_width_1_1,a +; vprintf.c 216 + mov r5,_vsprintf_width_1_1 +00118$: + mov ar6,r5 + dec r5 + mov _vsprintf_width_1_1,r5 + cjne r6,#0x00,00304$ + mov a,#0x01 + sjmp 00305$ +00304$: + clr a +00305$: +; Peephole 105 removed redundant mov + mov r7,a +; Peephole 109 removed ljmp by inverse jump logic + jnz 00124$ +00306$: +; vprintf.c 218 + push ar5 + push ar6 + push ar7 + mov dpl,#0x20 + lcall _output_char + pop ar7 + pop ar6 + pop ar5 +; vprintf.c 222 +; Peephole 132 changed ljmp to sjmp + sjmp 00118$ +00124$: + mov r5,_value + mov r6,(_value + 1) + mov r7,(_value + 2) + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget +; Peephole 105 removed redundant mov + mov _vsprintf_sloc6_1_0,a +; Peephole 110 removed ljmp by inverse jump logic + jz 00126$ +00307$: +; vprintf.c 223 + mov a,#0x01 + add a,r5 + mov _vsprintf_sloc7_1_0,a +; Peephole 180 changed mov to clr + clr a + addc a,r6 + mov (_vsprintf_sloc7_1_0 + 1),a + mov (_vsprintf_sloc7_1_0 + 2),r7 + mov _value,_vsprintf_sloc7_1_0 + mov (_value + 1),(_vsprintf_sloc7_1_0 + 1) + mov (_value + 2),(_vsprintf_sloc7_1_0 + 2) + mov dpl,r5 + mov dph,r6 + mov b,r7 + lcall __gptrget + mov r2,a + push ar2 + push ar5 + push ar6 + push ar7 + mov dpl,r2 + lcall _output_char + pop ar7 + pop ar6 + pop ar5 + pop ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00124$ +00126$: +; vprintf.c 225 + jb _vsprintf_left_justify_1_1,00308$ + ljmp 00143$ +00308$: + clr c + mov a,_vsprintf_length_1_1 + subb a,_vsprintf_width_1_1 + jc 00309$ + ljmp 00143$ +00309$: +; vprintf.c 227 + clr c + mov a,_vsprintf_width_1_1 + subb a,_vsprintf_length_1_1 + mov _vsprintf_width_1_1,a +; vprintf.c 228 + mov r2,_vsprintf_width_1_1 +00127$: + mov ar5,r2 + dec r2 + mov _vsprintf_width_1_1,r2 + cjne r5,#0x00,00310$ + mov a,#0x01 + sjmp 00311$ +00310$: + clr a +00311$: +; Peephole 105 removed redundant mov + mov r6,a + jz 00312$ + ljmp 00143$ +00312$: +; vprintf.c 230 + push ar2 + push ar5 + push ar6 + mov dpl,#0x20 + lcall _output_char + pop ar6 + pop ar5 + pop ar2 +; vprintf.c 236 +; Peephole 132 changed ljmp to sjmp + sjmp 00127$ +00133$: + mov a,_vsprintf_PARM_3 + add a,#0xfd + mov r0,a + mov _vsprintf_PARM_3,r0 + mov ar2,@r0 + inc r0 + mov ar5,@r0 + inc r0 + mov ar6,@r0 + dec r0 + dec r0 + mov _value,r2 + mov (_value + 1),r5 + mov (_value + 2),r6 +; vprintf.c 238 + clr c + mov a,#0x03 + subb a,0x0002 + _value +; Peephole 108 removed ljmp by inverse jump logic + jnc 00200$ +00313$: + mov r2,#0x04 +; Peephole 132 changed ljmp to sjmp + sjmp 00201$ +00200$: + mov r2,0x0002 + _value +00201$: + mov a,r2 +; Peephole 180 changed mov to clr +; Peephole 186 optimized movc sequence + mov dptr,#_memory_id + movc a,@a+dptr + mov r2,a + mov dpl,r2 + lcall _output_char +; vprintf.c 239 + mov dpl,#0x3a + lcall _output_char +; vprintf.c 240 + mov a,0x0002 + _value +; Peephole 110 removed ljmp by inverse jump logic + jz 00135$ +00314$: + mov a,0x0002 + _value + cjne a,#0x03,00315$ +; Peephole 132 changed ljmp to sjmp + sjmp 00135$ +00315$: +; vprintf.c 241 + mov dpl,0x0001 + _value + lcall _output_2digits +00135$: +; vprintf.c 242 + mov dpl,_value + lcall _output_2digits +; vprintf.c 243 +; vprintf.c 247 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00137$: + setb _vsprintf_signed_argument_1_1 +; vprintf.c 248 + mov _radix,#0x0a +; vprintf.c 249 +; vprintf.c 252 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00139$: + mov _radix,#0x08 +; vprintf.c 253 +; vprintf.c 256 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00140$: + mov _radix,#0x0a +; vprintf.c 257 +; vprintf.c 260 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00141$: + mov _radix,#0x10 +; vprintf.c 261 +; vprintf.c 265 +; Peephole 132 changed ljmp to sjmp + sjmp 00143$ +00142$: + mov dpl,_vsprintf_c_1_1 + lcall _output_char +; vprintf.c 267 +00143$: +; vprintf.c 269 + mov a,_radix + jnz 00316$ + ljmp 00193$ +00316$: +; vprintf.c 275 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_char_argument_1_1,00152$ +00317$: +; vprintf.c 277 + mov a,_vsprintf_PARM_3 + add a,#0xff + mov r0,a + mov _vsprintf_PARM_3,r0 + mov ar2,@r0 + mov a,r2 + rlc a + subb a,acc + mov r5,a + mov r6,a + mov r7,a + mov _value,r2 + mov (_value + 1),r5 + mov (_value + 2),r6 + mov (_value + 3),r7 +; vprintf.c 278 +; Peephole 132 changed ljmp to sjmp +; Peephole 164 removed sjmp by inverse jump logic + jb _vsprintf_signed_argument_1_1,00153$ +00318$: +; vprintf.c 280 + mov 0x0001 + _value,#0x00 +; vprintf.c 281 + mov 0x0002 + _value,#0x00 +; vprintf.c 282 + mov 0x0003 + _value,#0x00 +; Peephole 132 changed ljmp to sjmp + sjmp 00153$ +00152$: +; vprintf.c 285 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_long_argument_1_1,00149$ +00319$: +; vprintf.c 287 + mov a,_vsprintf_PARM_3 + add a,#0xfc + mov r0,a + mov _vsprintf_PARM_3,r0 + mov ar2,@r0 + inc r0 + mov ar5,@r0 + inc r0 + mov ar6,@r0 + inc r0 + mov ar7,@r0 + dec r0 + dec r0 + dec r0 + mov _value,r2 + mov (_value + 1),r5 + mov (_value + 2),r6 + mov (_value + 3),r7 +; Peephole 132 changed ljmp to sjmp + sjmp 00153$ +00149$: +; vprintf.c 291 + mov a,_vsprintf_PARM_3 + add a,#0xfe + mov r0,a + mov _vsprintf_PARM_3,r0 + mov ar2,@r0 + inc r0 + mov ar5,@r0 + dec r0 + mov a,r5 + rlc a + subb a,acc + mov r6,a + mov r7,a + mov _value,r2 + mov (_value + 1),r5 + mov (_value + 2),r6 + mov (_value + 3),r7 +; vprintf.c 292 +; Peephole 112 removed ljmp by inverse jump logic + jb _vsprintf_signed_argument_1_1,00153$ +00320$: +; vprintf.c 294 + mov 0x0002 + _value,#0x00 +; vprintf.c 295 + mov 0x0003 + _value,#0x00 +00153$: +; vprintf.c 299 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_signed_argument_1_1,00158$ +00321$: +; vprintf.c 301 + mov a,(_value + 3) +; Peephole 111 removed ljmp by inverse jump logic + jnb acc.7,00155$ +00322$: +; vprintf.c 302 + clr c + clr a + subb a,_value + mov r2,a + clr a + subb a,(_value + 1) + mov r5,a + clr a + subb a,(_value + 2) + mov r6,a + clr a + subb a,(_value + 3) + mov r7,a + mov _value,r2 + mov (_value + 1),r5 + mov (_value + 2),r6 + mov (_value + 3),r7 +; Peephole 132 changed ljmp to sjmp + sjmp 00158$ +00155$: +; vprintf.c 304 + clr _vsprintf_signed_argument_1_1 +00158$: +; vprintf.c 307 + mov _vsprintf_length_1_1,#0x00 +; vprintf.c 308 + setb _lsd +; vprintf.c 309 + mov r2,#0x00 +00162$: + mov a,_value +; Peephole 162 removed sjmp by inverse jump logic + jz 00324$ +00323$: +; Peephole 132 changed ljmp to sjmp + sjmp 00163$ +00324$: + mov a,0x0001 + _value +; Peephole 162 removed sjmp by inverse jump logic + jz 00326$ +00325$: +; Peephole 132 changed ljmp to sjmp + sjmp 00163$ +00326$: +; vprintf.c 310 + mov a,0x0002 + _value +; Peephole 162 removed sjmp by inverse jump logic + jz 00328$ +00327$: +; Peephole 132 changed ljmp to sjmp + sjmp 00163$ +00328$: + mov a,0x0003 + _value + jnz 00329$ + mov a,#0x01 + sjmp 00330$ +00329$: + clr a +00330$: + mov r5,a + mov _vsprintf_length_1_1,r2 + mov a,r5 +; Peephole 109 removed ljmp by inverse jump logic + jnz 00164$ +00331$: +00163$: +; vprintf.c 312 + mov 0x0004 + _value,#0x00 +; vprintf.c 313 + push ar2 + lcall _calculate_digit + pop ar2 +; vprintf.c 327 + jb _lsd,1$ + pop b ; b = + mov a,_value+4 ; a = + swap a + orl b,a ; b = + push b + sjmp 2$ +1$: + mov a,_value+4 ; a = + push acc +2$: +; vprintf.c 329 + inc r2 +; vprintf.c 330 +; Peephole 167 removed redundant bit moves (c not set to _lsd) + cpl _lsd +; Peephole 132 changed ljmp to sjmp + sjmp 00162$ +00164$: +; vprintf.c 333 + mov a,_vsprintf_width_1_1 +; Peephole 162 removed sjmp by inverse jump logic + jz 00333$ +00332$: +; Peephole 132 changed ljmp to sjmp + sjmp 00166$ +00333$: +; vprintf.c 338 + mov _vsprintf_width_1_1,#0x01 +00166$: +; vprintf.c 342 +; Peephole 112 removed ljmp by inverse jump logic + jb _vsprintf_zero_padding_1_1,00171$ +00334$: +; vprintf.c 344 + mov a,#0x01 + add a,_vsprintf_length_1_1 + mov r2,a + mov r5,_vsprintf_width_1_1 +00167$: + clr c + mov a,r2 + subb a,r5 + clr a + rlc a + mov r2,a + mov _vsprintf_width_1_1,r5 + mov a,r2 +; Peephole 110 removed ljmp by inverse jump logic + jz 00171$ +00335$: +; vprintf.c 346 + push ar5 + mov dpl,#0x20 + lcall _output_char + pop ar5 +; vprintf.c 347 + dec r5 +; Peephole 132 changed ljmp to sjmp + sjmp 00167$ +00171$: +; vprintf.c 351 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_signed_argument_1_1,00180$ +00336$: +; vprintf.c 353 + mov dpl,#0x2d + lcall _output_char +; vprintf.c 355 + dec _vsprintf_width_1_1 +; Peephole 132 changed ljmp to sjmp + sjmp 00258$ +00180$: +; vprintf.c 357 + mov a,_vsprintf_length_1_1 +; Peephole 110 removed ljmp by inverse jump logic + jz 00258$ +00337$: +; vprintf.c 360 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_prefix_sign_1_1,00175$ +00338$: +; vprintf.c 362 + mov dpl,#0x2b + lcall _output_char +; vprintf.c 364 + dec _vsprintf_width_1_1 +; Peephole 132 changed ljmp to sjmp + sjmp 00258$ +00175$: +; vprintf.c 366 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_prefix_space_1_1,00258$ +00339$: +; vprintf.c 368 + mov dpl,#0x20 + lcall _output_char +; vprintf.c 370 + dec _vsprintf_width_1_1 +; vprintf.c 375 +00258$: + mov r2,_vsprintf_width_1_1 +00182$: + mov ar5,r2 + dec r2 + clr c + mov a,_vsprintf_length_1_1 + subb a,r5 +; Peephole 108 removed ljmp by inverse jump logic + jnc 00260$ +00340$: +; vprintf.c 377 +; Peephole 111 removed ljmp by inverse jump logic + jnb _vsprintf_zero_padding_1_1,00202$ +00341$: + mov r5,#0x30 +; Peephole 132 changed ljmp to sjmp + sjmp 00203$ +00202$: + mov r5,#0x20 +00203$: + push ar2 + mov dpl,r5 + lcall _output_char + pop ar2 +; vprintf.c 381 +; Peephole 132 changed ljmp to sjmp + sjmp 00182$ +00260$: + mov r2,_vsprintf_length_1_1 +00185$: + mov ar5,r2 + dec r2 + mov a,r5 + jnz 00342$ + ljmp 00193$ +00342$: +; vprintf.c 383 +; Peephole 167 removed redundant bit moves (c not set to _lsd) + cpl _lsd +; vprintf.c 398 + jb _lsd,3$ + pop acc ; a = + nop ; to disable the "optimizer" + push acc + swap a + anl a,#0x0F ; a = + sjmp 4$ +3$: + pop acc + anl a,#0x0F ; a = +4$: + mov _value+4,a +; vprintf.c 400 + mov dpl,0x0004 + _value + push ar2 + lcall _output_digit + pop ar2 +; Peephole 132 changed ljmp to sjmp + sjmp 00185$ +00191$: +; vprintf.c 407 + mov dpl,_vsprintf_c_1_1 + lcall _output_char + ljmp 00193$ +00195$: +; vprintf.c 413 +; Peephole 111 removed ljmp by inverse jump logic + jnb _output_to_string,00198$ +00343$: + mov dpl,#0x00 + lcall _output_char +00198$: + C$vprintf.c$414$1$1 ==. + XG$vsprintf$0$0 ==. + ret + G$vprintf$0$0 ==. +; vprintf.c 418 +; ----------------------------------------- +; function vprintf +; ----------------------------------------- +_vprintf: +; vprintf.c 420 + mov _vsprintf_PARM_2,dpl + mov (_vsprintf_PARM_2 + 1),dph + mov (_vsprintf_PARM_2 + 2),b + mov _vsprintf_PARM_3,_vprintf_PARM_2 +; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 + mov b,#0x00 + lcall _vsprintf +00101$: + C$vprintf.c$421$1$1 ==. + XG$vprintf$0$0 ==. + ret + .area CSEG (CODE) +Fvprintf$memory_id$0$0 == . +_memory_id: + .ascii /IXCP-/ + .byte 0 diff --git a/device/lib/small/vprintf.cdb b/device/lib/small/vprintf.cdb new file mode 100644 index 00000000..0aacac8c --- /dev/null +++ b/device/lib/small/vprintf.cdb @@ -0,0 +1,14 @@ +M:vprintf +F:Fvprintf$output_char$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fvprintf$output_digit$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fvprintf$output_2digits$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:Fvprintf$calculate_digit$0$0({2}DF,SV:S),C,0,0,0,0,0 +F:G$vsprintf$0$0({2}DF,SI:S),Z,0,0,0,0,0 +F:G$vprintf$0$0({2}DF,SI:S),Z,0,0,0,0,0 +S:G$output_ptr$0$0({3}DG,SC:S),E,0,0 +S:G$value$0$0({5}ST__00010000:S),E,0,0 +S:G$radix$0$0({1}SS:U),E,0,0 +S:G$output_to_string$0$0({1}SB0$1:S),H,0,0 +S:G$lower_case$0$0({1}SB0$1:S),H,0,0 +S:G$lsd$0$0({1}SB0$1:S),H,0,0 +S:Fvprintf$memory_id$0$0({6}DA6,SC:S),D,0,0 diff --git a/device/lib/small/vprintf.rel b/device/lib/small/vprintf.rel new file mode 100644 index 00000000..46bc13d2 --- /dev/null +++ b/device/lib/small/vprintf.rel @@ -0,0 +1,1581 @@ +;!FILE vprintf.asm +XH +H 9 areas 2D4 global symbols +M vprintf +S _isdigit Ref0000 +S __gptrput Ref0000 +S _putchar Ref0000 +S _islower Ref0000 +S _bp Ref0000 +S _strlen Ref0000 +S __gptrget Ref0000 +A _CODE size 0 flags 0 +A DSEG size 1B flags 0 +S _output_ptr Def0000 +S _vprintf_PARM_2 Def001A +S G$radix$0$0 Def0008 +S G$value$0$0 Def0003 +S G$output_ptr$0$0 Def0000 +S _radix Def0008 +S _vsprintf_PARM_2 Def0009 +S _value Def0003 +S _vsprintf_PARM_3 Def000C +A _DUMMY size 0 flags 0 +A OSEG size 0 flags 4 +A ISEG size 0 flags 0 +A BSEG size A flags 80 +S _lower_case Def0001 +S _output_to_string Def0000 +S G$lower_case$0$0 Def0001 +S G$output_to_string$0$0 Def0000 +S _lsd Def0002 +S G$lsd$0$0 Def0002 +A XSEG size 0 flags 40 +A GSINIT size 0 flags 20 +A CSEG size 55E flags 20 +S A$vprintf$1193 Def0526 +S A$vprintf$1184 Def0519 +S A$vprintf$1157 Def04F6 +S A$vprintf$1139 Def04E4 +S A$vprintf$1085 Def04AB +S A$vprintf$1076 Def04A1 +S A$vprintf$1058 Def0490 +S Fvprintf$memory_id$0$0 Def0558 +S A$vprintf$1194 Def0528 +S A$vprintf$1185 Def051B +S A$vprintf$1167 Def0503 +S A$vprintf$1095 Def04B8 +S Fvprintf$output_2digits$0$0 Def0065 +S A$vprintf$1195 Def052B +S A$vprintf$1177 Def050E +S A$vprintf$1159 Def04F8 +S A$vprintf$1087 Def04AC +S A$vprintf$1078 Def04A3 +S A$vprintf$1187 Def051D +S A$vprintf$1169 Def0505 +S A$vprintf$1097 Def04B9 +S A$vprintf$1079 Def04A4 +S A$vprintf$1197 Def052D +S A$vprintf$1188 Def051F +S A$vprintf$1179 Def0510 +S A$vprintf$200 Def0050 +S A$vprintf$201 Def0051 +S C$vprintf.c$123$1$1 Def00BF +S A$vprintf$400 Def0137 +S A$vprintf$211 Def005A +S A$vprintf$130 Def0000 +S C$vprintf.c$421$1$1 Def0557 +S A$vprintf$500 Def01BA +S A$vprintf$410 Def0147 +S A$vprintf$401 Def013A +S A$vprintf$320 Def00CD +S A$vprintf$311 Def00C0 +S A$vprintf$230 Def006C +S A$vprintf$212 Def005C +S A$vprintf$203 Def0052 +S A$vprintf$140 Def000C +S A$vprintf$131 Def0002 +S A$vprintf$510 Def01C8 +S A$vprintf$501 Def01BC +S A$vprintf$420 Def0151 +S A$vprintf$411 Def0148 +S A$vprintf$402 Def013D +S A$vprintf$321 Def00CE +S A$vprintf$312 Def00C2 +S A$vprintf$303 Def00BF +S A$vprintf$240 Def007C +S A$vprintf$231 Def006D +S A$vprintf$150 Def001E +S A$vprintf$141 Def000E +S C$vprintf.c$414$1$1 Def0541 +S A$vprintf$700 Def02CF +S A$vprintf$610 Def0250 +S A$vprintf$601 Def0246 +S A$vprintf$520 Def01D5 +S A$vprintf$502 Def01BF +S A$vprintf$421 Def0153 +S A$vprintf$412 Def0149 +S A$vprintf$403 Def013F +S A$vprintf$340 Def00E0 +S A$vprintf$331 Def00D5 +S A$vprintf$313 Def00C4 +S A$vprintf$241 Def007E +S A$vprintf$232 Def006E +S A$vprintf$214 Def005F +S A$vprintf$205 Def0054 +S A$vprintf$160 Def002C +S A$vprintf$151 Def001F +S A$vprintf$142 Def0010 +S A$vprintf$133 Def0005 +S A$vprintf$800 Def0366 +S A$vprintf$710 Def02E1 +S A$vprintf$701 Def02D0 +S A$vprintf$620 Def025F +S A$vprintf$611 Def0252 +S A$vprintf$521 Def01D7 +S A$vprintf$512 Def01CB +S A$vprintf$503 Def01C1 +S A$vprintf$440 Def0164 +S A$vprintf$422 Def0155 +S A$vprintf$413 Def014B +S A$vprintf$350 Def00EE +S A$vprintf$323 Def00CF +S A$vprintf$233 Def0070 +S A$vprintf$215 Def0062 +S A$vprintf$206 Def0056 +S A$vprintf$170 Def002F +S A$vprintf$143 Def0012 +S A$vprintf$900 Def03DA +S A$vprintf$810 Def0374 +S A$vprintf$720 Def02F5 +S A$vprintf$711 Def02E3 +S A$vprintf$630 Def026E +S A$vprintf$621 Def0261 +S A$vprintf$612 Def0253 +S A$vprintf$522 Def01D9 +S A$vprintf$513 Def01CD +S A$vprintf$450 Def0178 +S A$vprintf$441 Def0166 +S A$vprintf$432 Def015B +S A$vprintf$405 Def0140 +S A$vprintf$360 Def00FD +S A$vprintf$351 Def00F0 +S A$vprintf$342 Def00E1 +S A$vprintf$315 Def00C6 +S A$vprintf$270 Def009B +S A$vprintf$243 Def0081 +S A$vprintf$234 Def0072 +S A$vprintf$225 Def0065 +S A$vprintf$207 Def0057 +S A$vprintf$180 Def003C +S A$vprintf$171 Def0031 +S A$vprintf$153 Def0022 +S A$vprintf$144 Def0013 +S A$vprintf$910 Def03E4 +S A$vprintf$730 Def0305 +S A$vprintf$721 Def02F8 +S A$vprintf$712 Def02E5 +S A$vprintf$703 Def02D2 +S A$vprintf$640 Def0281 +S A$vprintf$631 Def0270 +S A$vprintf$622 Def0262 +S A$vprintf$613 Def0255 +S A$vprintf$604 Def0249 +S A$vprintf$550 Def0203 +S A$vprintf$541 Def01F6 +S A$vprintf$532 Def01E6 +S A$vprintf$514 Def01D0 +S A$vprintf$505 Def01C3 +S A$vprintf$460 Def0183 +S A$vprintf$442 Def0168 +S A$vprintf$424 Def0157 +S A$vprintf$415 Def014D +S A$vprintf$361 Def00FF +S A$vprintf$352 Def00F2 +S A$vprintf$343 Def00E2 +S A$vprintf$316 Def00C8 +S A$vprintf$280 Def00A9 +S A$vprintf$271 Def009C +S A$vprintf$262 Def008E +S A$vprintf$244 Def0084 +S A$vprintf$235 Def0074 +S A$vprintf$226 Def0067 +S A$vprintf$190 Def0045 +S A$vprintf$181 Def003D +S A$vprintf$163 Def002E +S A$vprintf$145 Def0016 +S A$vprintf$136 Def0007 +S A$vprintf$920 Def03F3 +S A$vprintf$911 Def03E6 +S A$vprintf$812 Def0377 +S A$vprintf$803 Def0367 +S A$vprintf$740 Def0313 +S A$vprintf$722 Def02FA +S A$vprintf$713 Def02E7 +S A$vprintf$704 Def02D3 +S A$vprintf$632 Def0272 +S A$vprintf$623 Def0264 +S A$vprintf$614 Def0257 +S A$vprintf$560 Def020B +S A$vprintf$551 Def0205 +S A$vprintf$533 Def01E8 +S A$vprintf$524 Def01DC +S A$vprintf$515 Def01D2 +S A$vprintf$461 Def0185 +S A$vprintf$452 Def017B +S A$vprintf$443 Def016A +S A$vprintf$416 Def014E +S A$vprintf$371 Def010B +S A$vprintf$362 Def0102 +S A$vprintf$344 Def00E3 +S A$vprintf$335 Def00D7 +S A$vprintf$326 Def00D1 +S A$vprintf$317 Def00CA +S A$vprintf$290 Def00B4 +S A$vprintf$281 Def00AB +S A$vprintf$272 Def009E +S A$vprintf$263 Def008F +S A$vprintf$236 Def0077 +S A$vprintf$218 Def0064 +S A$vprintf$209 Def0058 +S A$vprintf$191 Def0047 +S A$vprintf$173 Def0034 +S A$vprintf$930 Def0400 +S A$vprintf$921 Def03F4 +S A$vprintf$912 Def03E8 +S A$vprintf$831 Def038E +S A$vprintf$822 Def0382 +S A$vprintf$804 Def036A +S A$vprintf$750 Def0323 +S A$vprintf$741 Def0315 +S A$vprintf$732 Def0308 +S A$vprintf$723 Def02FC +S A$vprintf$714 Def02EA +S A$vprintf$705 Def02D4 +S A$vprintf$660 Def0298 +S A$vprintf$624 Def0266 +S A$vprintf$606 Def024B +S A$vprintf$561 Def020D +S A$vprintf$534 Def01EA +S A$vprintf$525 Def01DE +S A$vprintf$453 Def017C +S A$vprintf$444 Def016D +S A$vprintf$435 Def015D +S A$vprintf$408 Def0142 +S A$vprintf$390 Def0124 +S A$vprintf$381 Def0116 +S A$vprintf$354 Def00F5 +S A$vprintf$345 Def00E4 +S A$vprintf$336 Def00D9 +S A$vprintf$273 Def00A0 +S A$vprintf$264 Def0091 +S A$vprintf$255 Def0087 +S A$vprintf$228 Def006A +S A$vprintf$192 Def0048 +S A$vprintf$183 Def0040 +S A$vprintf$174 Def0036 +S A$vprintf$156 Def0024 +S A$vprintf$147 Def0018 +S A$vprintf$940 Def040F +S A$vprintf$931 Def0402 +S A$vprintf$922 Def03F6 +S A$vprintf$913 Def03E9 +S A$vprintf$904 Def03DC +S A$vprintf$841 Def0397 +S A$vprintf$823 Def0385 +S A$vprintf$814 Def0379 +S A$vprintf$805 Def036B +S A$vprintf$751 Def0325 +S A$vprintf$742 Def0317 +S A$vprintf$733 Def0309 +S A$vprintf$724 Def02FE +S A$vprintf$715 Def02EB +S A$vprintf$706 Def02D6 +S A$vprintf$661 Def0299 +S A$vprintf$652 Def028D +S A$vprintf$643 Def0283 +S A$vprintf$634 Def0274 +S A$vprintf$625 Def0267 +S A$vprintf$616 Def025A +S A$vprintf$571 Def0220 +S A$vprintf$562 Def0210 +S A$vprintf$553 Def0207 +S A$vprintf$544 Def01F7 +S A$vprintf$526 Def01E1 +S A$vprintf$517 Def01D4 +S A$vprintf$508 Def01C4 +S A$vprintf$490 Def01AE +S A$vprintf$481 Def01A1 +S A$vprintf$472 Def0191 +S A$vprintf$445 Def016F +S A$vprintf$427 Def0158 +S A$vprintf$409 Def0145 +S A$vprintf$391 Def0127 +S A$vprintf$373 Def010D +S A$vprintf$364 Def0104 +S A$vprintf$355 Def00F6 +S A$vprintf$346 Def00E6 +S A$vprintf$337 Def00DB +S A$vprintf$328 Def00D3 +S A$vprintf$319 Def00CC +S A$vprintf$292 Def00B6 +S A$vprintf$274 Def00A1 +S A$vprintf$265 Def0092 +S A$vprintf$247 Def0086 +S A$vprintf$238 Def0079 +S A$vprintf$184 Def0041 +S A$vprintf$175 Def0037 +S A$vprintf$157 Def0026 +S A$vprintf$148 Def001A +S A$vprintf$139 Def000A +S A$vprintf$941 Def0410 +S A$vprintf$932 Def0403 +S A$vprintf$923 Def03F8 +S A$vprintf$914 Def03EB +S A$vprintf$860 Def03A9 +S A$vprintf$851 Def039F +S A$vprintf$833 Def0390 +S A$vprintf$806 Def036C +S A$vprintf$761 Def032E +S A$vprintf$734 Def030B +S A$vprintf$716 Def02ED +S A$vprintf$707 Def02D8 +S A$vprintf$680 Def02B4 +S A$vprintf$671 Def02A4 +S A$vprintf$662 Def029B +S A$vprintf$653 Def028E +S A$vprintf$635 Def0276 +S A$vprintf$626 Def0269 +S A$vprintf$581 Def0232 +S A$vprintf$545 Def01F9 +S A$vprintf$536 Def01ED +S A$vprintf$527 Def01E3 +S A$vprintf$509 Def01C6 +S A$vprintf$491 Def01B0 +S A$vprintf$473 Def0193 +S A$vprintf$464 Def0187 +S A$vprintf$446 Def0171 +S A$vprintf$419 Def014F +S A$vprintf$392 Def012A +S A$vprintf$383 Def0118 +S A$vprintf$356 Def00F8 +S A$vprintf$347 Def00E8 +S A$vprintf$338 Def00DD +S A$vprintf$293 Def00B8 +S A$vprintf$284 Def00AD +S A$vprintf$275 Def00A3 +S A$vprintf$266 Def0094 +S A$vprintf$257 Def0089 +S A$vprintf$239 Def007B +S A$vprintf$194 Def0049 +S A$vprintf$176 Def0039 +S A$vprintf$149 Def001C +S A$vprintf$960 Def0425 +S A$vprintf$951 Def041C +S A$vprintf$942 Def0411 +S A$vprintf$933 Def0405 +S A$vprintf$924 Def03FA +S A$vprintf$915 Def03EC +S A$vprintf$870 Def03B3 +S A$vprintf$816 Def037B +S A$vprintf$807 Def036E +S A$vprintf$780 Def034E +S A$vprintf$771 Def0340 +S A$vprintf$762 Def0330 +S A$vprintf$753 Def0327 +S A$vprintf$744 Def0319 +S A$vprintf$735 Def030D +S A$vprintf$726 Def0300 +S A$vprintf$717 Def02EF +S A$vprintf$708 Def02DB +S A$vprintf$690 Def02C2 +S A$vprintf$681 Def02B6 +S A$vprintf$663 Def029E +S A$vprintf$654 Def0290 +S A$vprintf$645 Def0286 +S A$vprintf$636 Def0278 +S A$vprintf$627 Def026A +S A$vprintf$609 Def024E +S A$vprintf$591 Def023C +S A$vprintf$573 Def0222 +S A$vprintf$564 Def0213 +S A$vprintf$546 Def01FB +S A$vprintf$537 Def01EF +S A$vprintf$474 Def0195 +S A$vprintf$465 Def0189 +S A$vprintf$456 Def017E +S A$vprintf$447 Def0173 +S A$vprintf$438 Def015F +S A$vprintf$429 Def0159 +S A$vprintf$393 Def012C +S A$vprintf$375 Def010F +S A$vprintf$357 Def00FA +S A$vprintf$348 Def00EA +S A$vprintf$339 Def00DF +S A$vprintf$294 Def00BA +S A$vprintf$276 Def00A5 +S A$vprintf$267 Def0096 +S A$vprintf$186 Def0042 +S A$vprintf$177 Def003A +S A$vprintf$159 Def0029 +S XFvprintf$calculate_digit$0$0 Def00BF +S A$vprintf$970 Def0430 +S A$vprintf$943 Def0413 +S A$vprintf$934 Def0407 +S A$vprintf$916 Def03EE +S A$vprintf$907 Def03DF +S A$vprintf$880 Def03C1 +S A$vprintf$853 Def03A1 +S A$vprintf$835 Def0392 +S A$vprintf$826 Def0388 +S A$vprintf$817 Def037D +S A$vprintf$790 Def035C +S A$vprintf$781 Def034F +S A$vprintf$763 Def0332 +S A$vprintf$736 Def030F +S A$vprintf$718 Def02F1 +S A$vprintf$709 Def02DE +S A$vprintf$691 Def02C4 +S A$vprintf$664 Def02A0 +S A$vprintf$655 Def0292 +S A$vprintf$646 Def0287 +S A$vprintf$637 Def027A +S A$vprintf$628 Def026C +S A$vprintf$619 Def025D +S A$vprintf$574 Def0224 +S A$vprintf$565 Def0215 +S A$vprintf$556 Def0208 +S A$vprintf$538 Def01F2 +S A$vprintf$529 Def01E5 +S A$vprintf$493 Def01B2 +S A$vprintf$484 Def01A2 +S A$vprintf$466 Def018C +S A$vprintf$448 Def0175 +S A$vprintf$439 Def0162 +S A$vprintf$394 Def012D +S A$vprintf$385 Def011B +S A$vprintf$367 Def0107 +S A$vprintf$349 Def00EC +S A$vprintf$277 Def00A6 +S A$vprintf$268 Def0097 +S A$vprintf$259 Def008C +S A$vprintf$178 Def003B +S A$vprintf$980 Def043F +S A$vprintf$971 Def0432 +S A$vprintf$962 Def0427 +S A$vprintf$953 Def041F +S A$vprintf$944 Def0415 +S A$vprintf$935 Def0408 +S A$vprintf$926 Def03FC +S A$vprintf$917 Def03EF +S A$vprintf$908 Def03E1 +S A$vprintf$881 Def03C3 +S A$vprintf$845 Def039A +S A$vprintf$827 Def038B +S A$vprintf$809 Def0371 +S A$vprintf$782 Def0351 +S A$vprintf$773 Def0342 +S A$vprintf$764 Def0334 +S A$vprintf$746 Def031B +S A$vprintf$719 Def02F3 +S A$vprintf$692 Def02C6 +S A$vprintf$674 Def02A6 +S A$vprintf$647 Def0289 +S A$vprintf$638 Def027D +S A$vprintf$629 Def026D +S A$vprintf$584 Def0235 +S A$vprintf$575 Def0227 +S A$vprintf$566 Def0218 +S A$vprintf$548 Def01FE +S A$vprintf$539 Def01F4 +S A$vprintf$485 Def01A4 +S A$vprintf$476 Def0198 +S A$vprintf$467 Def018E +S A$vprintf$449 Def0177 +S A$vprintf$395 Def0130 +S A$vprintf$386 Def011D +S A$vprintf$377 Def0111 +S A$vprintf$287 Def00AF +S A$vprintf$269 Def0099 +S A$vprintf$197 Def004B +S A$vprintf$188 Def0043 +S A$vprintf$981 Def0441 +S A$vprintf$972 Def0433 +S A$vprintf$945 Def0417 +S A$vprintf$936 Def040A +S A$vprintf$918 Def03F1 +S A$vprintf$909 Def03E3 +S A$vprintf$891 Def03CE +S A$vprintf$882 Def03C4 +S A$vprintf$873 Def03B6 +S A$vprintf$864 Def03AC +S A$vprintf$819 Def0380 +S A$vprintf$792 Def035E +S A$vprintf$783 Def0352 +S A$vprintf$774 Def0344 +S A$vprintf$765 Def0337 +S A$vprintf$756 Def0328 +S A$vprintf$747 Def031D +S A$vprintf$729 Def0302 +S A$vprintf$684 Def02B8 +S A$vprintf$675 Def02A8 +S A$vprintf$666 Def02A2 +S A$vprintf$657 Def0294 +S A$vprintf$639 Def027F +S A$vprintf$594 Def023F +S A$vprintf$558 Def0209 +S A$vprintf$549 Def0200 +S A$vprintf$486 Def01A6 +S A$vprintf$477 Def019A +S A$vprintf$459 Def0181 +S A$vprintf$387 Def011F +S A$vprintf$369 Def0109 +S A$vprintf$297 Def00BC +S A$vprintf$288 Def00B0 +S A$vprintf$279 Def00A8 +S XFvprintf$output_digit$0$0 Def0064 +S A$vprintf$991 Def044A +S A$vprintf$973 Def0434 +S A$vprintf$937 Def040B +S A$vprintf$919 Def03F2 +S A$vprintf$883 Def03C5 +S A$vprintf$874 Def03B8 +S A$vprintf$865 Def03AE +S A$vprintf$847 Def039C +S A$vprintf$784 Def0353 +S A$vprintf$775 Def0346 +S A$vprintf$766 Def033A +S A$vprintf$757 Def0329 +S A$vprintf$748 Def031E +S A$vprintf$739 Def0312 +S A$vprintf$694 Def02C9 +S A$vprintf$676 Def02AA +S A$vprintf$649 Def028B +S A$vprintf$586 Def0237 +S A$vprintf$577 Def022A +S A$vprintf$568 Def021B +S A$vprintf$496 Def01B3 +S A$vprintf$478 Def019D +S A$vprintf$469 Def0190 +S A$vprintf$397 Def0132 +S A$vprintf$379 Def0114 +S A$vprintf$289 Def00B2 +S A$vprintf$199 Def004E +S A$vprintf$983 Def0443 +S A$vprintf$974 Def0436 +S A$vprintf$965 Def042A +S A$vprintf$938 Def040C +S A$vprintf$929 Def03FE +S A$vprintf$884 Def03C6 +S A$vprintf$875 Def03BA +S A$vprintf$866 Def03B0 +S A$vprintf$857 Def03A4 +S A$vprintf$839 Def0395 +S A$vprintf$794 Def0360 +S A$vprintf$785 Def0355 +S A$vprintf$776 Def0347 +S A$vprintf$767 Def033C +S A$vprintf$758 Def032B +S A$vprintf$749 Def0320 +S A$vprintf$686 Def02BA +S A$vprintf$677 Def02AC +S A$vprintf$659 Def0296 +S A$vprintf$596 Def0241 +S A$vprintf$578 Def022C +S A$vprintf$569 Def021D +S A$vprintf$497 Def01B5 +S A$vprintf$488 Def01A9 +S A$vprintf$479 Def019F +S A$vprintf$398 Def0135 +S A$vprintf$389 Def0121 +S A$vprintf$299 Def00BD +S A$vprintf$993 Def044C +S A$vprintf$975 Def0437 +S A$vprintf$966 Def042B +S A$vprintf$957 Def0422 +S A$vprintf$948 Def0419 +S A$vprintf$939 Def040D +S A$vprintf$894 Def03D1 +S A$vprintf$885 Def03C8 +S A$vprintf$876 Def03BB +S A$vprintf$786 Def0357 +S A$vprintf$777 Def0349 +S A$vprintf$768 Def033E +S A$vprintf$696 Def02CB +S A$vprintf$687 Def02BC +S A$vprintf$678 Def02AF +S A$vprintf$669 Def02A3 +S A$vprintf$579 Def022F +S A$vprintf$498 Def01B7 +S A$vprintf$489 Def01AB +S C$vprintf.c$80$1$1 Def0064 +S A$vprintf$976 Def0438 +S A$vprintf$967 Def042C +S A$vprintf$886 Def03CA +S A$vprintf$877 Def03BD +S A$vprintf$859 Def03A6 +S A$vprintf$796 Def0362 +S A$vprintf$778 Def034B +S A$vprintf$688 Def02BE +S A$vprintf$679 Def02B2 +S A$vprintf$589 Def023A +S A$vprintf$995 Def044E +S A$vprintf$986 Def0445 +S A$vprintf$977 Def043A +S A$vprintf$968 Def042E +S A$vprintf$896 Def03D4 +S A$vprintf$887 Def03CC +S A$vprintf$878 Def03BF +S A$vprintf$788 Def0359 +S A$vprintf$779 Def034C +S A$vprintf$689 Def02C0 +S A$vprintf$599 Def0244 +S Fvprintf$calculate_digit$0$0 Def0087 +S C$vprintf.c$73$1$1 Def002E +S A$vprintf$978 Def043B +S A$vprintf$969 Def042F +S A$vprintf$879 Def03C0 +S A$vprintf$798 Def0364 +S A$vprintf$789 Def035A +S A$vprintf$699 Def02CD +S A$vprintf$997 Def0450 +S A$vprintf$979 Def043D +S A$vprintf$898 Def03D7 +S _vsprintf Def00C0 +S A$vprintf$989 Def0447 +S Fvprintf$output_digit$0$0 Def002F +S C$vprintf.c$88$1$1 Def0086 +S XFvprintf$output_char$0$0 Def002E +S XG$vsprintf$0$0 Def0541 +S _vprintf Def0542 +S Fvprintf$output_char$0$0 Def0000 +S G$vsprintf$0$0 Def00C0 +S A$vprintf$1000 Def0452 +S A$vprintf$1010 Def045A +S XG$vprintf$0$0 Def0557 +S A$vprintf$1200 Def052F +S A$vprintf$1101 Def04BB +S A$vprintf$1020 Def0466 +S A$vprintf$1002 Def0454 +S A$vprintf$1201 Def0532 +S A$vprintf$1012 Def045C +S A$vprintf$1202 Def0535 +S A$vprintf$1130 Def04D9 +S A$vprintf$1121 Def04CF +S A$vprintf$1112 Def04C8 +S A$vprintf$1040 Def047E +S A$vprintf$1022 Def0468 +S A$vprintf$1004 Def0456 +S A$vprintf$1221 Def0542 +S A$vprintf$1122 Def04D2 +S A$vprintf$1104 Def04BE +S A$vprintf$1050 Def048B +S A$vprintf$1041 Def0480 +S A$vprintf$1032 Def046F +S A$vprintf$1222 Def0545 +S A$vprintf$1213 Def0541 +S A$vprintf$1141 Def04E6 +S A$vprintf$1114 Def04CA +S A$vprintf$1105 Def04C1 +S A$vprintf$1060 Def0492 +S A$vprintf$1042 Def0481 +S A$vprintf$1024 Def0469 +S A$vprintf$1015 Def045E +S XFvprintf$output_2digits$0$0 Def0086 +S A$vprintf$1232 Def0557 +S A$vprintf$1223 Def0548 +S A$vprintf$1160 Def04FA +S A$vprintf$1151 Def04EF +S A$vprintf$1142 Def04E8 +S A$vprintf$1133 Def04DC +S A$vprintf$1124 Def04D5 +S A$vprintf$1070 Def0499 +S A$vprintf$1043 Def0483 +S A$vprintf$1034 Def0472 +S A$vprintf$1025 Def046A +S A$vprintf$1007 Def0458 +S A$vprintf$1224 Def054B +S A$vprintf$1206 Def0538 +S A$vprintf$1170 Def0507 +S A$vprintf$1161 Def04FC +S A$vprintf$1143 Def04E9 +S A$vprintf$1134 Def04DF +S A$vprintf$1107 Def04C4 +S A$vprintf$1080 Def04A5 +S A$vprintf$1053 Def048C +S A$vprintf$1044 Def0485 +S A$vprintf$1035 Def0474 +S A$vprintf$1026 Def046C +S A$vprintf$1017 Def0460 +S A$vprintf$1180 Def0513 +S A$vprintf$1171 Def0508 +S A$vprintf$1162 Def04FF +S A$vprintf$1153 Def04F2 +S A$vprintf$1144 Def04EA +S A$vprintf$1126 Def04D7 +S A$vprintf$1090 Def04AE +S A$vprintf$1081 Def04A6 +S A$vprintf$1063 Def0494 +S A$vprintf$1036 Def0477 +S A$vprintf$1018 Def0462 +S G$vprintf$0$0 Def0542 +S A$vprintf$1226 Def054E +S A$vprintf$1208 Def053B +S A$vprintf$1190 Def0521 +S A$vprintf$1181 Def0515 +S A$vprintf$1172 Def0509 +S A$vprintf$1145 Def04EC +S A$vprintf$1136 Def04E2 +S A$vprintf$1118 Def04CC +S A$vprintf$1109 Def04C6 +S A$vprintf$1091 Def04B0 +S A$vprintf$1082 Def04A7 +S A$vprintf$1073 Def049C +S A$vprintf$1055 Def048E +S A$vprintf$1046 Def0487 +S A$vprintf$1028 Def046D +S A$vprintf$1019 Def0464 +S A$vprintf$1227 Def0551 +S A$vprintf$1209 Def053E +S A$vprintf$1182 Def0516 +S A$vprintf$1173 Def050B +S A$vprintf$1155 Def04F4 +S A$vprintf$1092 Def04B3 +S A$vprintf$1083 Def04A8 +S A$vprintf$1074 Def049E +S A$vprintf$1047 Def0489 +S A$vprintf$1038 Def0479 +S A$vprintf$1228 Def0554 +S A$vprintf$1192 Def0523 +S A$vprintf$1183 Def0518 +S A$vprintf$1165 Def0501 +S A$vprintf$1147 Def04ED +S A$vprintf$1093 Def04B6 +S A$vprintf$1084 Def04A9 +S A$vprintf$1075 Def04A0 +S A$vprintf$1066 Def0496 +S A$vprintf$1039 Def047C +T 00 00 +R 00 00 00 01 +T 00 00 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 03 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 08 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 09 +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 0C +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0D +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 0E +R 00 00 00 01 +T 00 0F +R 00 00 00 01 +T 00 0F +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 10 +R 00 00 00 01 +T 00 11 +R 00 00 00 01 +T 00 11 +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 12 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 13 +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 14 +R 00 00 00 01 +T 00 15 +R 00 00 00 01 +T 00 15 +R 00 00 00 01 +T 00 16 +R 00 00 00 01 +T 00 16 +R 00 00 00 01 +T 00 17 +R 00 00 00 01 +T 00 17 +R 00 00 00 01 +T 00 1A +R 00 00 00 01 +T 00 1A +R 00 00 00 01 +T 00 00 +R 00 00 00 05 +T 00 00 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 01 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 02 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 03 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 04 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 05 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 06 +R 00 00 00 05 +T 00 07 +R 00 00 00 05 +T 00 07 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 08 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 09 +R 00 00 00 05 +T 00 00 +R 00 00 00 08 +T 00 00 C0 00 00 85 81 00 00 AA 82 30 00 00 1A +R 00 00 00 08 2B 03 00 04 2B 07 00 04 29 0C 00 05 +T 00 0A +R 00 00 00 08 +T 00 0A AB 00 00 AC 00 01 AD 00 02 05 +R 00 00 00 08 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 11 00 00 E4 B5 00 00 02 05 00 01 +R 00 00 00 08 29 02 00 01 29 06 00 01 29 0A 00 01 +T 00 18 +R 00 00 00 08 +T 00 18 8B 82 8C 83 8D F0 EA 12 00 00 80 05 +R 00 00 00 08 02 0A 00 01 +T 00 24 +R 00 00 00 08 +T 00 24 8A 82 12 00 00 +R 00 00 00 08 02 05 00 02 +T 00 29 +R 00 00 00 08 +T 00 29 85 00 00 81 D0 00 00 22 +R 00 00 00 08 2B 03 00 04 2B 07 00 04 +T 00 2F +R 00 00 00 08 +T 00 2F C0 00 00 85 81 00 00 AA 82 C3 74 09 9A E4 +R 00 00 00 08 2B 03 00 04 2B 07 00 04 +T 00 3B 33 FB B4 01 00 +R 00 00 00 08 +T 00 40 +R 00 00 00 08 +T 00 40 E4 33 FB 60 06 +R 00 00 00 08 +T 00 45 +R 00 00 00 08 +T 00 45 74 30 2A FB 80 0F +R 00 00 00 08 +T 00 4B +R 00 00 00 08 +T 00 4B 30 00 01 06 +R 00 00 00 08 29 03 00 05 +T 00 4E +R 00 00 00 08 +T 00 4E 74 57 2A FC 80 04 +R 00 00 00 08 +T 00 54 +R 00 00 00 08 +T 00 54 74 37 2A FC +R 00 00 00 08 +T 00 58 +R 00 00 00 08 +T 00 58 8C 03 +R 00 00 00 08 +T 00 5A +R 00 00 00 08 +T 00 5A 8B 82 12 00 00 +R 00 00 00 08 00 05 00 08 +T 00 5F +R 00 00 00 08 +T 00 5F 85 00 00 81 D0 00 00 22 +R 00 00 00 08 2B 03 00 04 2B 07 00 04 +T 00 65 +R 00 00 00 08 +T 00 65 C0 00 00 85 81 00 00 AA 82 EA C4 54 0F F5 +R 00 00 00 08 2B 03 00 04 2B 07 00 04 +T 00 71 82 C0 02 12 00 2F D0 02 74 0F 5A F5 82 12 +R 00 00 00 08 00 06 00 08 +T 00 7F 00 2F +R 00 00 00 08 00 02 00 08 +T 00 81 +R 00 00 00 08 +T 00 81 85 00 00 81 D0 00 00 22 +R 00 00 00 08 2B 03 00 04 2B 07 00 04 +T 00 87 +R 00 00 00 08 +T 00 87 7A 20 +R 00 00 00 08 +T 00 89 +R 00 00 00 08 +T 00 89 BA 00 02 80 31 +R 00 00 00 08 +T 00 8E +R 00 00 00 08 +T 00 8E C3 E5 00 03 33 F5 00 03 E5 00 04 33 F5 +R 00 00 00 08 29 04 00 01 29 08 00 01 29 0B 00 01 +T 00 98 00 04 E5 00 05 33 F5 00 05 E5 +R 00 00 00 08 29 02 00 01 29 05 00 01 29 09 00 01 +T 00 9F 00 06 33 F5 00 06 E5 00 07 33 F5 +R 00 00 00 08 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 A7 00 07 C3 E5 00 07 95 00 08 40 0D +R 00 00 00 08 29 02 00 01 29 06 00 01 29 09 00 01 +T 00 AF +R 00 00 00 08 +T 00 AF C3 E5 00 07 95 00 08 F5 00 07 74 01 25 +R 00 00 00 08 29 04 00 01 29 07 00 01 29 0A 00 01 +T 00 B9 00 03 F5 00 03 +R 00 00 00 08 29 02 00 01 29 05 00 01 +T 00 BC +R 00 00 00 08 +T 00 BC 1A 80 CA +R 00 00 00 08 +T 00 BF +R 00 00 00 08 +T 00 BF 22 +R 00 00 00 08 +T 00 C0 +R 00 00 00 08 +T 00 C0 AA 82 AB 83 AC F0 8A 00 00 8B 00 01 8C +R 00 00 00 08 29 09 00 01 29 0C 00 01 +T 00 CB 00 02 EA 4B 4C 70 04 +R 00 00 00 08 29 02 00 01 +T 00 D1 +R 00 00 00 08 +T 00 D1 C2 00 00 80 02 +R 00 00 00 08 29 03 00 05 +T 00 D5 +R 00 00 00 08 +T 00 D5 D2 00 00 +R 00 00 00 08 29 03 00 05 +T 00 D7 +R 00 00 00 08 +T 00 D7 +R 00 00 00 08 +T 00 D7 AA 00 09 AB 00 0A AC 00 0B 74 01 2A FD E4 +R 00 00 00 08 29 03 00 01 29 06 00 01 29 09 00 01 +T 00 E2 3B FE 8C 07 8D 00 09 8E 00 0A 8F 00 0B 8A +R 00 00 00 08 29 07 00 01 29 0A 00 01 29 0D 00 01 +T 00 ED 82 8B 83 8C F0 12 00 00 FA 8A 00 0F 70 03 +R 00 00 00 08 02 08 00 06 29 0C 00 01 +T 00 FA 02 05 38 +R 00 00 00 08 00 03 00 08 +T 00 FD +R 00 00 00 08 +T 00 FD E5 00 0F B4 25 02 80 03 +R 00 00 00 08 29 03 00 01 +T 01 04 +R 00 00 00 08 +T 01 04 02 05 2F +R 00 00 00 08 00 03 00 08 +T 01 07 +R 00 00 00 08 +T 01 07 C2 00 03 C2 00 04 C2 00 05 C2 +R 00 00 00 08 29 03 00 05 29 06 00 05 29 09 00 05 +T 01 0E 00 06 C2 00 07 75 00 08 00 C2 +R 00 00 00 08 29 02 00 05 29 05 00 05 29 08 00 01 +T 01 15 00 08 C2 00 09 75 00 0D 00 8D +R 00 00 00 08 29 02 00 05 29 05 00 05 29 08 00 01 +T 01 1C 00 09 8E 00 0A 8F 00 0B +R 00 00 00 08 29 02 00 01 29 05 00 01 29 08 00 01 +T 01 21 +R 00 00 00 08 +T 01 21 85 00 09 82 85 00 0A 83 85 00 0B F0 05 +R 00 00 00 08 29 03 00 01 29 07 00 01 29 0B 00 01 +T 01 2B 00 09 E4 B5 00 09 02 05 00 0A +R 00 00 00 08 29 02 00 01 29 06 00 01 29 0A 00 01 +T 01 32 +R 00 00 00 08 +T 01 32 12 00 00 F5 00 0F 85 00 0F 82 12 +R 00 00 00 08 02 03 00 06 29 06 00 01 29 09 00 01 +T 01 3B 00 00 A9 82 E9 60 1D +R 00 00 00 08 02 02 00 00 +T 01 42 +R 00 00 00 08 +T 01 42 75 F0 0A E5 00 0D A4 FD E5 00 0F 24 D0 FE +R 00 00 00 08 29 06 00 01 29 0B 00 01 +T 01 4E 2D F5 00 0D 70 04 74 01 80 01 +R 00 00 00 08 29 04 00 01 +T 01 57 +R 00 00 00 08 +T 01 57 E4 +R 00 00 00 08 +T 01 58 +R 00 00 00 08 +T 01 58 FF 60 C6 +R 00 00 00 08 +T 01 5B +R 00 00 00 08 +T 01 5B D2 00 04 80 C2 +R 00 00 00 08 29 03 00 05 +T 01 5F +R 00 00 00 08 +T 01 5F 85 00 0F 82 C0 05 C0 06 C0 07 C0 01 12 +R 00 00 00 08 29 03 00 01 +T 01 6B 00 00 AA 82 D0 01 D0 07 D0 06 D0 05 EA B4 +R 00 00 00 08 02 02 00 03 +T 01 79 01 00 +R 00 00 00 08 +T 01 7B +R 00 00 00 08 +T 01 7B B3 92 00 01 30 00 01 06 +R 00 00 00 08 29 04 00 05 29 07 00 05 +T 01 81 +R 00 00 00 08 +T 01 81 74 DF 55 00 0F F5 00 0F +R 00 00 00 08 29 05 00 01 29 08 00 01 +T 01 87 +R 00 00 00 08 +T 01 87 E5 00 0F B4 20 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 01 90 +R 00 00 00 08 +T 01 90 E4 +R 00 00 00 08 +T 01 91 +R 00 00 00 08 +T 01 91 F5 00 10 60 03 02 02 3F +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 01 98 +R 00 00 00 08 +T 01 98 E5 00 0F B4 2B 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 01 A1 +R 00 00 00 08 +T 01 A1 E4 +R 00 00 00 08 +T 01 A2 +R 00 00 00 08 +T 01 A2 F5 00 11 60 03 02 02 3A +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 01 A9 +R 00 00 00 08 +T 01 A9 E5 00 0F B4 2D 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 01 B2 +R 00 00 00 08 +T 01 B2 E4 +R 00 00 00 08 +T 01 B3 +R 00 00 00 08 +T 01 B3 F5 00 12 60 03 02 02 35 +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 01 BA +R 00 00 00 08 +T 01 BA E5 00 0F B4 42 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 01 C3 +R 00 00 00 08 +T 01 C3 E4 +R 00 00 00 08 +T 01 C4 +R 00 00 00 08 +T 01 C4 F5 00 13 60 03 02 02 44 +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 01 CB +R 00 00 00 08 +T 01 CB E5 00 0F B4 43 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 01 D4 +R 00 00 00 08 +T 01 D4 E4 +R 00 00 00 08 +T 01 D5 +R 00 00 00 08 +T 01 D5 F5 00 14 60 03 02 02 4E +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 01 DC +R 00 00 00 08 +T 01 DC E5 00 0F B4 44 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 01 E5 +R 00 00 00 08 +T 01 E5 E4 +R 00 00 00 08 +T 01 E6 +R 00 00 00 08 +T 01 E6 F5 00 15 60 03 02 03 90 +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 01 ED +R 00 00 00 08 +T 01 ED E5 00 0F B4 49 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 01 F6 +R 00 00 00 08 +T 01 F6 E4 +R 00 00 00 08 +T 01 F7 +R 00 00 00 08 +T 01 F7 F5 00 16 60 03 02 03 90 +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 01 FE +R 00 00 00 08 +T 01 FE E5 00 0F B4 4C 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 02 07 +R 00 00 00 08 +T 02 07 E4 +R 00 00 00 08 +T 02 08 +R 00 00 00 08 +T 02 08 F8 70 3E +R 00 00 00 08 +T 02 0B +R 00 00 00 08 +T 02 0B E5 00 0F B4 4F 03 02 03 97 +R 00 00 00 08 29 03 00 01 00 09 00 08 +T 02 13 +R 00 00 00 08 +T 02 13 E5 00 0F B4 50 03 02 03 42 +R 00 00 00 08 29 03 00 01 00 09 00 08 +T 02 1B +R 00 00 00 08 +T 02 1B E5 00 0F B4 53 02 80 3B +R 00 00 00 08 29 03 00 01 +T 02 22 +R 00 00 00 08 +T 02 22 E5 00 0F B4 55 03 02 03 9C +R 00 00 00 08 29 03 00 01 00 09 00 08 +T 02 2A +R 00 00 00 08 +T 02 2A E5 00 0F B4 58 03 02 03 A1 +R 00 00 00 08 29 03 00 01 00 09 00 08 +T 02 32 +R 00 00 00 08 +T 02 32 02 03 A6 +R 00 00 00 08 00 03 00 08 +T 02 35 +R 00 00 00 08 +T 02 35 D2 00 03 02 01 21 +R 00 00 00 08 29 03 00 05 00 06 00 08 +T 02 3A +R 00 00 00 08 +T 02 3A D2 00 05 02 01 21 +R 00 00 00 08 29 03 00 05 00 06 00 08 +T 02 3F +R 00 00 00 08 +T 02 3F D2 00 06 02 01 21 +R 00 00 00 08 29 03 00 05 00 06 00 08 +T 02 44 +R 00 00 00 08 +T 02 44 D2 00 08 02 01 21 +R 00 00 00 08 29 03 00 05 00 06 00 08 +T 02 49 +R 00 00 00 08 +T 02 49 D2 00 09 02 01 21 +R 00 00 00 08 29 03 00 05 00 06 00 08 +T 02 4E +R 00 00 00 08 +T 02 4E E5 00 0C 24 FF F8 88 00 0C 86 82 12 00 00 +R 00 00 00 08 29 03 00 01 29 09 00 01 00 0E 00 08 +T 02 5A 02 03 AC +R 00 00 00 08 00 03 00 08 +T 02 5D +R 00 00 00 08 +T 02 5D E5 00 0C 24 FD F8 88 00 0C 86 02 08 86 05 +R 00 00 00 08 29 03 00 01 29 09 00 01 +T 02 69 08 86 06 18 18 8A 00 03 8D 00 04 8E 00 05 +R 00 00 00 08 29 08 00 01 29 0B 00 01 29 0E 00 01 +T 02 74 8A 82 8D 83 8E F0 12 00 00 AA 82 AD 83 8A +R 00 00 00 08 02 09 00 05 +T 02 82 00 0E 20 00 03 34 +R 00 00 00 08 29 02 00 01 29 05 00 05 +T 02 86 +R 00 00 00 08 +T 02 86 C3 E5 00 0E 95 00 0D 50 2D +R 00 00 00 08 29 04 00 01 29 07 00 01 +T 02 8D +R 00 00 00 08 +T 02 8D C3 E5 00 0D 95 00 0E F5 00 0D AD +R 00 00 00 08 29 04 00 01 29 07 00 01 29 0A 00 01 +T 02 95 00 0D +R 00 00 00 08 29 02 00 01 +T 02 96 +R 00 00 00 08 +T 02 96 8D 06 1D 8D 00 0D BE 00 04 74 01 80 01 +R 00 00 00 08 29 06 00 01 +T 02 A2 +R 00 00 00 08 +T 02 A2 E4 +R 00 00 00 08 +T 02 A3 +R 00 00 00 08 +T 02 A3 FF 70 14 +R 00 00 00 08 +T 02 A6 +R 00 00 00 08 +T 02 A6 C0 05 C0 06 C0 07 75 82 20 12 00 00 D0 07 +R 00 00 00 08 00 0C 00 08 +T 02 B4 D0 06 D0 05 80 DC +R 00 00 00 08 +T 02 BA +R 00 00 00 08 +T 02 BA AD 00 03 AE 00 04 AF 00 05 8D 82 8E 83 8F +R 00 00 00 08 29 03 00 01 29 06 00 01 29 09 00 01 +T 02 C5 F0 12 00 00 F5 00 16 60 35 +R 00 00 00 08 02 04 00 06 29 07 00 01 +T 02 CD +R 00 00 00 08 +T 02 CD 74 01 2D F5 00 17 E4 3E F5 00 18 8F 00 19 +R 00 00 00 08 29 06 00 01 29 0B 00 01 29 0E 00 01 +T 02 D8 85 00 17 00 03 85 00 18 +R 00 00 00 08 29 03 00 01 29 05 00 01 29 08 00 01 +T 02 DD 00 04 85 00 19 00 05 8D 82 8E 83 8F F0 12 +R 00 00 00 08 29 02 00 01 29 05 00 01 29 07 00 01 +T 02 E8 00 00 FA C0 02 C0 05 C0 06 C0 07 8A 82 12 +R 00 00 00 08 02 02 00 06 +T 02 F6 00 00 D0 07 D0 06 D0 05 D0 02 80 B8 +R 00 00 00 08 00 02 00 08 +T 03 02 +R 00 00 00 08 +T 03 02 20 00 03 03 02 03 AC +R 00 00 00 08 29 03 00 05 00 07 00 08 +T 03 08 +R 00 00 00 08 +T 03 08 C3 E5 00 0E 95 00 0D 40 03 02 03 AC +R 00 00 00 08 29 04 00 01 29 07 00 01 00 0C 00 08 +T 03 12 +R 00 00 00 08 +T 03 12 C3 E5 00 0D 95 00 0E F5 00 0D AA +R 00 00 00 08 29 04 00 01 29 07 00 01 29 0A 00 01 +T 03 1A 00 0D +R 00 00 00 08 29 02 00 01 +T 03 1B +R 00 00 00 08 +T 03 1B 8A 05 1A 8A 00 0D BD 00 04 74 01 80 01 +R 00 00 00 08 29 06 00 01 +T 03 27 +R 00 00 00 08 +T 03 27 E4 +R 00 00 00 08 +T 03 28 +R 00 00 00 08 +T 03 28 FE 60 03 02 03 AC +R 00 00 00 08 00 06 00 08 +T 03 2E +R 00 00 00 08 +T 03 2E C0 02 C0 05 C0 06 75 82 20 12 00 00 D0 06 +R 00 00 00 08 00 0C 00 08 +T 03 3C D0 05 D0 02 80 D9 +R 00 00 00 08 +T 03 42 +R 00 00 00 08 +T 03 42 E5 00 0C 24 FD F8 88 00 0C 86 02 08 86 05 +R 00 00 00 08 29 03 00 01 29 09 00 01 +T 03 4E 08 86 06 18 18 8A 00 03 8D 00 04 8E 00 05 +R 00 00 00 08 29 08 00 01 29 0B 00 01 29 0E 00 01 +T 03 59 C3 74 03 95 00 05 50 04 +R 00 00 00 08 29 06 00 01 +T 03 60 +R 00 00 00 08 +T 03 60 7A 04 80 02 +R 00 00 00 08 +T 03 64 +R 00 00 00 08 +T 03 64 AA 00 05 +R 00 00 00 08 29 03 00 01 +T 03 66 +R 00 00 00 08 +T 03 66 EA 90 05 58 93 FA 8A 82 12 00 00 75 82 3A +R 00 00 00 08 00 04 00 08 00 0B 00 08 +T 03 74 12 00 00 E5 00 05 60 0D +R 00 00 00 08 00 03 00 08 29 06 00 01 +T 03 7B +R 00 00 00 08 +T 03 7B E5 00 05 B4 03 02 80 06 +R 00 00 00 08 29 03 00 01 +T 03 82 +R 00 00 00 08 +T 03 82 85 00 04 82 12 00 65 +R 00 00 00 08 29 03 00 01 00 07 00 08 +T 03 88 +R 00 00 00 08 +T 03 88 85 00 03 82 12 00 65 80 1C +R 00 00 00 08 29 03 00 01 00 07 00 08 +T 03 90 +R 00 00 00 08 +T 03 90 D2 00 07 75 00 08 0A 80 15 +R 00 00 00 08 29 03 00 05 29 06 00 01 +T 03 97 +R 00 00 00 08 +T 03 97 75 00 08 08 80 10 +R 00 00 00 08 29 03 00 01 +T 03 9C +R 00 00 00 08 +T 03 9C 75 00 08 0A 80 0B +R 00 00 00 08 29 03 00 01 +T 03 A1 +R 00 00 00 08 +T 03 A1 75 00 08 10 80 06 +R 00 00 00 08 29 03 00 01 +T 03 A6 +R 00 00 00 08 +T 03 A6 85 00 0F 82 12 00 00 +R 00 00 00 08 29 03 00 01 00 07 00 08 +T 03 AC +R 00 00 00 08 +T 03 AC E5 00 08 70 03 02 00 D7 +R 00 00 00 08 29 03 00 01 00 08 00 08 +T 03 B3 +R 00 00 00 08 +T 03 B3 30 00 08 26 +R 00 00 00 08 29 03 00 05 +T 03 B6 +R 00 00 00 08 +T 03 B6 E5 00 0C 24 FF F8 88 00 0C 86 02 EA 33 95 +R 00 00 00 08 29 03 00 01 29 09 00 01 +T 03 C2 E0 FD FE FF 8A 00 03 8D 00 04 8E 00 05 8F +R 00 00 00 08 29 07 00 01 29 0A 00 01 29 0D 00 01 +T 03 CD 00 06 20 00 07 51 +R 00 00 00 08 29 02 00 01 29 05 00 05 +T 03 D1 +R 00 00 00 08 +T 03 D1 75 00 04 00 75 00 05 00 75 00 06 00 80 46 +R 00 00 00 08 29 03 00 01 29 07 00 01 29 0B 00 01 +T 03 DC +R 00 00 00 08 +T 03 DC 30 00 09 1F +R 00 00 00 08 29 03 00 05 +T 03 DF +R 00 00 00 08 +T 03 DF E5 00 0C 24 FC F8 88 00 0C 86 02 08 86 05 +R 00 00 00 08 29 03 00 01 29 09 00 01 +T 03 EB 08 86 06 08 86 07 18 18 18 8A 00 03 8D +R 00 00 00 08 29 0C 00 01 +T 03 F7 00 04 8E 00 05 8F 00 06 80 24 +R 00 00 00 08 29 02 00 01 29 05 00 01 29 08 00 01 +T 03 FE +R 00 00 00 08 +T 03 FE E5 00 0C 24 FE F8 88 00 0C 86 02 08 86 05 +R 00 00 00 08 29 03 00 01 29 09 00 01 +T 04 0A 18 ED 33 95 E0 FE FF 8A 00 03 8D 00 04 8E +R 00 00 00 08 29 0A 00 01 29 0D 00 01 +T 04 16 00 05 8F 00 06 20 00 07 06 +R 00 00 00 08 29 02 00 01 29 05 00 01 29 08 00 05 +T 04 1C +R 00 00 00 08 +T 04 1C 75 00 05 00 75 00 06 00 +R 00 00 00 08 29 03 00 01 29 07 00 01 +T 04 22 +R 00 00 00 08 +T 04 22 30 00 07 22 +R 00 00 00 08 29 03 00 05 +T 04 25 +R 00 00 00 08 +T 04 25 E5 00 06 30 E7 1B +R 00 00 00 08 29 03 00 01 +T 04 2A +R 00 00 00 08 +T 04 2A C3 E4 95 00 03 FA E4 95 00 04 FD E4 95 +R 00 00 00 08 29 05 00 01 29 0A 00 01 +T 04 35 00 05 FE E4 95 00 06 FF 8A 00 03 8D +R 00 00 00 08 29 02 00 01 29 07 00 01 29 0B 00 01 +T 04 3E 00 04 8E 00 05 8F 00 06 80 02 +R 00 00 00 08 29 02 00 01 29 05 00 01 29 08 00 01 +T 04 45 +R 00 00 00 08 +T 04 45 C2 00 07 +R 00 00 00 08 29 03 00 05 +T 04 47 +R 00 00 00 08 +T 04 47 75 00 0E 00 D2 00 02 7A 00 +R 00 00 00 08 29 03 00 01 29 07 00 05 +T 04 4E +R 00 00 00 08 +T 04 4E E5 00 03 60 02 +R 00 00 00 08 29 03 00 01 +T 04 52 +R 00 00 00 08 +T 04 52 80 1B +R 00 00 00 08 +T 04 54 +R 00 00 00 08 +T 04 54 E5 00 04 60 02 +R 00 00 00 08 29 03 00 01 +T 04 58 +R 00 00 00 08 +T 04 58 80 15 +R 00 00 00 08 +T 04 5A +R 00 00 00 08 +T 04 5A E5 00 05 60 02 +R 00 00 00 08 29 03 00 01 +T 04 5E +R 00 00 00 08 +T 04 5E 80 0F +R 00 00 00 08 +T 04 60 +R 00 00 00 08 +T 04 60 E5 00 06 70 04 74 01 80 01 +R 00 00 00 08 29 03 00 01 +T 04 68 +R 00 00 00 08 +T 04 68 E4 +R 00 00 00 08 +T 04 69 +R 00 00 00 08 +T 04 69 FD 8A 00 0E ED 70 21 +R 00 00 00 08 29 04 00 01 +T 04 6F +R 00 00 00 08 +T 04 6F +R 00 00 00 08 +T 04 6F 75 00 07 00 C0 02 12 00 87 D0 02 20 00 02 +R 00 00 00 08 29 03 00 01 00 09 00 08 29 0E 00 05 +T 04 7B 0B D0 F0 E5 00 07 C4 42 F0 C0 F0 80 04 +R 00 00 00 08 29 06 00 01 +T 04 87 +R 00 00 00 08 +T 04 87 E5 00 07 C0 E0 +R 00 00 00 08 29 03 00 01 +T 04 8B +R 00 00 00 08 +T 04 8B 0A B2 00 02 80 BE +R 00 00 00 08 29 04 00 05 +T 04 90 +R 00 00 00 08 +T 04 90 E5 00 0D 60 02 +R 00 00 00 08 29 03 00 01 +T 04 94 +R 00 00 00 08 +T 04 94 80 03 +R 00 00 00 08 +T 04 96 +R 00 00 00 08 +T 04 96 75 00 0D 01 +R 00 00 00 08 29 03 00 01 +T 04 99 +R 00 00 00 08 +T 04 99 20 00 04 1F +R 00 00 00 08 29 03 00 05 +T 04 9C +R 00 00 00 08 +T 04 9C 74 01 25 00 0E FA AD 00 0D +R 00 00 00 08 29 05 00 01 29 09 00 01 +T 04 A3 +R 00 00 00 08 +T 04 A3 C3 EA 9D E4 33 FA 8D 00 0D EA 60 0D +R 00 00 00 08 29 09 00 01 +T 04 AE +R 00 00 00 08 +T 04 AE C0 05 75 82 20 12 00 00 D0 05 1D 80 E8 +R 00 00 00 08 00 08 00 08 +T 04 BB +R 00 00 00 08 +T 04 BB 30 00 07 0A +R 00 00 00 08 29 03 00 05 +T 04 BE +R 00 00 00 08 +T 04 BE 75 82 2D 12 00 00 15 00 0D 80 1C +R 00 00 00 08 00 06 00 08 29 09 00 01 +T 04 C8 +R 00 00 00 08 +T 04 C8 E5 00 0E 60 18 +R 00 00 00 08 29 03 00 01 +T 04 CC +R 00 00 00 08 +T 04 CC 30 00 05 0A +R 00 00 00 08 29 03 00 05 +T 04 CF +R 00 00 00 08 +T 04 CF 75 82 2B 12 00 00 15 00 0D 80 0B +R 00 00 00 08 00 06 00 08 29 09 00 01 +T 04 D9 +R 00 00 00 08 +T 04 D9 30 00 06 08 +R 00 00 00 08 29 03 00 05 +T 04 DC +R 00 00 00 08 +T 04 DC 75 82 20 12 00 00 15 00 0D +R 00 00 00 08 00 06 00 08 29 09 00 01 +T 04 E4 +R 00 00 00 08 +T 04 E4 AA 00 0D +R 00 00 00 08 29 03 00 01 +T 04 E6 +R 00 00 00 08 +T 04 E6 8A 05 1A C3 E5 00 0E 9D 50 14 +R 00 00 00 08 29 07 00 01 +T 04 EF +R 00 00 00 08 +T 04 EF 30 00 04 04 +R 00 00 00 08 29 03 00 05 +T 04 F2 +R 00 00 00 08 +T 04 F2 7D 30 80 02 +R 00 00 00 08 +T 04 F6 +R 00 00 00 08 +T 04 F6 7D 20 +R 00 00 00 08 +T 04 F8 +R 00 00 00 08 +T 04 F8 C0 02 8D 82 12 00 00 D0 02 80 E3 +R 00 00 00 08 00 07 00 08 +T 05 03 +R 00 00 00 08 +T 05 03 AA 00 0E +R 00 00 00 08 29 03 00 01 +T 05 05 +R 00 00 00 08 +T 05 05 8A 05 1A ED 70 03 02 00 D7 +R 00 00 00 08 00 09 00 08 +T 05 0E +R 00 00 00 08 +T 05 0E B2 00 02 20 00 02 0A D0 E0 00 C0 E0 C4 54 +R 00 00 00 08 29 03 00 05 29 06 00 05 +T 05 1A 0F 80 04 +R 00 00 00 08 +T 05 1D +R 00 00 00 08 +T 05 1D D0 E0 54 0F +R 00 00 00 08 +T 05 21 +R 00 00 00 08 +T 05 21 F5 00 07 85 00 07 82 C0 02 12 00 2F D0 02 +R 00 00 00 08 29 03 00 01 29 06 00 01 00 0C 00 08 +T 05 2D 80 D6 +R 00 00 00 08 +T 05 2F +R 00 00 00 08 +T 05 2F 85 00 0F 82 12 00 00 02 00 D7 +R 00 00 00 08 29 03 00 01 00 07 00 08 00 0A 00 08 +T 05 38 +R 00 00 00 08 +T 05 38 30 00 00 06 +R 00 00 00 08 29 03 00 05 +T 05 3B +R 00 00 00 08 +T 05 3B 75 82 00 12 00 00 +R 00 00 00 08 00 06 00 08 +T 05 41 +R 00 00 00 08 +T 05 41 22 +R 00 00 00 08 +T 05 42 +R 00 00 00 08 +T 05 42 85 82 00 09 85 83 00 0A 85 F0 00 0B 85 +R 00 00 00 08 29 04 00 01 29 08 00 01 29 0C 00 01 +T 05 4C 00 1A 00 0C 90 00 00 75 F0 00 12 00 C0 +R 00 00 00 08 29 02 00 01 29 04 00 01 00 0D 00 08 +T 05 57 +R 00 00 00 08 +T 05 57 22 +R 00 00 00 08 +T 05 58 +R 00 00 00 08 +T 05 58 49 58 43 50 2D 00 +R 00 00 00 08 diff --git a/device/lib/vprintf.c b/device/lib/vprintf.c new file mode 100644 index 00000000..12a7cdb8 --- /dev/null +++ b/device/lib/vprintf.c @@ -0,0 +1,421 @@ +/*------------------------------------------------------------------------- + vprintf.c - formatted output conversion + + Written By - Martijn van Balen aed@iae.nl (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include + +extern void putchar(const char); + +#define PTR value.p + +/****************************************************************************/ + +typedef char _generic *ptr_t; + +//#define toupper(c) ((c)&=~0x20) +#define toupper(c) ((c)&=0xDF) + +typedef union +{ + unsigned char byte[5]; + long l; + unsigned long ul; + char _generic *p; +} value_t; + + +static code char memory_id[] = "IXCP-"; + +ptr_t output_ptr; +bit output_to_string; +bit lower_case; +bit lsd; + +data value_t value; + + unsigned short radix; + +/****************************************************************************/ + +static void output_char( char c ) reentrant +{ + if (output_to_string) + { + *output_ptr++ = c; + } + else + { + putchar( c ); + } +} + +/*--------------------------------------------------------------------------*/ + +static void output_digit( unsigned char n ) reentrant +{ + output_char( n <= 9 ? '0'+n : (lower_case ? n+(char)('a'-10) : n+(char)('A'-10)) ); +} + +/*--------------------------------------------------------------------------*/ + +static void output_2digits( unsigned char b ) reentrant +{ + output_digit( b>>4 ); + output_digit( b&0x0F ); +} + +/*--------------------------------------------------------------------------*/ + +static void calculate_digit( void ) +{ + unsigned char i; + + for( i = 32; i != 0; i-- ) + { +_asm + clr c + mov a,_value+0 + rlc a + mov _value+0,a + mov a,_value+1 + rlc a + mov _value+1,a + mov a,_value+2 + rlc a + mov _value+2,a + mov a,_value+3 + rlc a + mov _value+3,a + mov a,_value+4 + rlc a + mov _value+4,a +_endasm; + + if (radix <= value.byte[4] ) + { + value.byte[4] -= radix; + value.byte[0]++; + } + } +} + +/*--------------------------------------------------------------------------*/ + +int vsprintf (const char *buf, const char *format, va_list ap) +{ + bit left_justify; + bit zero_padding; + bit prefix_sign; + bit prefix_space; + bit signed_argument; + bit char_argument; + bit long_argument; + + unsigned char width; + unsigned char length; + char c; + + output_ptr = buf; + if ( !buf ) + { + output_to_string = 0; + } + else + { + output_to_string = 1; + } + + while( c=*format++ ) + { + if ( c == '%' ) + { + left_justify = 0; + zero_padding = 0; + prefix_sign = 0; + prefix_space = 0; + signed_argument = 0; + radix = 0; + char_argument = 0; + long_argument = 0; + width = 0; + +get_conversion_spec: + + c = *format++; + + if (isdigit(c)) + { + width = 10*width + (c - '0'); + + if (width == 0) + { + /* first character of width is a zero */ + zero_padding = 1; + } + goto get_conversion_spec; + } + + lower_case = islower(c); + if (lower_case) + { + c = toupper(c); + } + + switch( c ) + { + case '-': + left_justify = 1; + goto get_conversion_spec; + case '+': + prefix_sign = 1; + goto get_conversion_spec; + case ' ': + prefix_space = 1; + goto get_conversion_spec; + case 'B': + char_argument = 1; + goto get_conversion_spec; + case 'L': + long_argument = 1; + goto get_conversion_spec; + + case 'C': + output_char( va_arg(ap,unsigned char) ); + break; + + case 'S': + PTR = va_arg(ap,ptr_t); + + length = strlen(PTR); + if ( ( !left_justify ) && (length < width) ) + { + width -= length; + while( width-- != 0 ) + { + output_char( ' ' ); + } + } + + while ( *PTR ) + output_char( *PTR++ ); + + if ( left_justify && (length < width)) + { + width -= length; + while( width-- != 0 ) + { + output_char( ' ' ); + } + } + break; + + case 'P': + PTR = va_arg(ap,ptr_t); + + output_char( memory_id[(value.byte[2] > 3) ? 4 : value.byte[2]] ); + output_char( ':' ); + if ((value.byte[2] != 0x00) && (value.byte[2] != 0x03)) + output_2digits( value.byte[1] ); + output_2digits( value.byte[0] ); + break; + + case 'D': + case 'I': + signed_argument = 1; + radix = 10; + break; + + case 'O': + radix = 8; + break; + + case 'U': + radix = 10; + break; + + case 'X': + radix = 16; + break; + + default: + // nothing special, just output the character + output_char( c ); + break; + } + + if (radix != 0) + { + // Apperently we have to output an integral type + // with radix "radix" + + // store value in byte[0] (LSB) ... byte[3] (MSB) + if (char_argument) + { + value.l = va_arg(ap,char); + if (!signed_argument) + { + value.byte[1] = 0x00; + value.byte[2] = 0x00; + value.byte[3] = 0x00; + } + } + else if (long_argument) + { + value.l = va_arg(ap,long); + } + else + { + value.l = va_arg(ap,int); + if (!signed_argument) + { + value.byte[2] = 0x00; + value.byte[3] = 0x00; + } + } + + if ( signed_argument ) + { + if (value.l < 0) + value.l = -value.l; + else + signed_argument = 0; + } + + length=0; + lsd = 1; + while( (value.byte[0] != 0) || (value.byte[1] != 0) || + (value.byte[2] != 0) || (value.byte[3] != 0) ) + { + value.byte[4] = 0; + calculate_digit(); + +_asm + jb _lsd,1$ + pop b ; b = + mov a,_value+4 ; a = + swap a + orl b,a ; b = + push b + sjmp 2$ +1$: + mov a,_value+4 ; a = + push acc +2$: +_endasm; + + length++; + lsd = ~lsd; + } + + if (width == 0) + { + // default width. We set it to 1 to output + // at least one character is case the value itself + // is zero (i.e. length==0) + width=1; + } + + /* prepend spaces if needed */ + if (!zero_padding) + { + while ( width > length+1 ) + { + output_char( ' ' ); + width--; + } + } + + if (signed_argument) // this now means the original value was negative + { + output_char( '-' ); + // adjust width to compensate for this character + width--; + } + else if (length != 0) + { + // value > 0 + if (prefix_sign) + { + output_char( '+' ); + // adjust width to compensate for this character + width--; + } + else if (prefix_space) + { + output_char( ' ' ); + // adjust width to compensate for this character + width--; + } + } + + /* prepend zeroes/spaces if needed */ + while ( width-- > length ) + { + output_char( zero_padding ? '0' : ' ' ); + } + + /* output the digits */ + while( length-- ) + { + lsd = ~lsd; + +_asm + jb _lsd,3$ + pop acc ; a = + nop ; to disable the "optimizer" + push acc + swap a + anl a,#0x0F ; a = + sjmp 4$ +3$: + pop acc + anl a,#0x0F ; a = +4$: + mov _value+4,a +_endasm; + + output_digit( value.byte[4] ); + } + } + } + else + { + // nothing special, just output the character + output_char( c ); + } + } + + // Copy \0 to the end of buf + // Modified by JB 17/12/99 + if (output_to_string) output_char(0); +} + +/*--------------------------------------------------------------------------*/ + +int vprintf (const char *format, va_list ap) +{ + return vsprintf( 0, format, ap ); +} diff --git a/device/lib/vprintf.lst b/device/lib/vprintf.lst new file mode 100644 index 00000000..2b30ef43 --- /dev/null +++ b/device/lib/vprintf.lst @@ -0,0 +1,1471 @@ + 1 ;-------------------------------------------------------- + 2 ; File Created by SDCC : FreeWare ANSI-C Compiler + 3 ; Version 2.1.9Ga Sun Jan 16 17:31:39 2000 + 4 + 5 ;-------------------------------------------------------- + 6 .module vprintf + 7 ;-------------------------------------------------------- + 8 ; publics variables in this module + 9 ;-------------------------------------------------------- + 10 .globl _vprintf_PARM_2 + 11 .globl _vsprintf_PARM_3 + 12 .globl _vsprintf_PARM_2 + 13 .globl _radix + 14 .globl _output_ptr + 15 .globl _lsd + 16 .globl _lower_case + 17 .globl _output_to_string + 18 .globl _value + 19 .globl _vsprintf + 20 .globl _vprintf + 21 ;-------------------------------------------------------- + 22 ; special function registers + 23 ;-------------------------------------------------------- + 24 ;-------------------------------------------------------- + 25 ; special function bits + 26 ;-------------------------------------------------------- + 27 ;-------------------------------------------------------- + 28 ; internal ram data + 29 ;-------------------------------------------------------- + 30 .area DSEG (DATA) + 0000 31 G$value$0$0==. + 0000 32 _value: + 0000 33 .ds 0x0005 + 0005 34 _vsprintf_sloc0_1_0: + 0005 35 .ds 0x0001 + 0006 36 _vsprintf_sloc1_1_0: + 0006 37 .ds 0x0001 + 0007 38 _vsprintf_sloc2_1_0: + 0007 39 .ds 0x0003 + 000A 40 _vsprintf_sloc3_1_0: + 000A 41 .ds 0x0001 + 000B 42 _vsprintf_sloc4_1_0: + 000B 43 .ds 0x0001 + 000C 44 _vsprintf_sloc5_1_0: + 000C 45 .ds 0x0001 + 000D 46 _vsprintf_sloc6_1_0: + 000D 47 .ds 0x0001 + 000E 48 _vsprintf_sloc7_1_0: + 000E 49 .ds 0x0001 + 000F 50 _vsprintf_sloc8_1_0: + 000F 51 .ds 0x0001 + 0010 52 _vsprintf_sloc9_1_0: + 0010 53 .ds 0x0001 + 0011 54 _vsprintf_sloc10_1_0: + 0011 55 .ds 0x0001 + 0012 56 _vsprintf_sloc11_1_0: + 0012 57 .ds 0x0001 + 0013 58 _vsprintf_sloc12_1_0: + 0013 59 .ds 0x0001 + 0014 60 _vsprintf_sloc13_1_0: + 0014 61 .ds 0x0001 + 62 ;-------------------------------------------------------- + 63 ; overlayable items in internal ram + 64 ;-------------------------------------------------------- + 65 .area OSEG (OVR,DATA) + 66 ;-------------------------------------------------------- + 67 ; indirectly addressable internal ram data + 68 ;-------------------------------------------------------- + 69 .area ISEG (DATA) + 70 ;-------------------------------------------------------- + 71 ; bit data + 72 ;-------------------------------------------------------- + 73 .area BSEG (BIT) + 0000 74 G$output_to_string$0$0==. + 0000 75 _output_to_string: + 0000 76 .ds 0x0001 + 0001 77 G$lower_case$0$0==. + 0001 78 _lower_case: + 0001 79 .ds 0x0001 + 0002 80 G$lsd$0$0==. + 0002 81 _lsd: + 0002 82 .ds 0x0001 + 0003 83 _vsprintf_left_justify_1_1: + 0003 84 .ds 0x0001 + 0004 85 _vsprintf_zero_padding_1_1: + 0004 86 .ds 0x0001 + 0005 87 _vsprintf_prefix_sign_1_1: + 0005 88 .ds 0x0001 + 0006 89 _vsprintf_prefix_space_1_1: + 0006 90 .ds 0x0001 + 0007 91 _vsprintf_signed_argument_1_1: + 0007 92 .ds 0x0001 + 0008 93 _vsprintf_char_argument_1_1: + 0008 94 .ds 0x0001 + 0009 95 _vsprintf_long_argument_1_1: + 0009 96 .ds 0x0001 + 97 ;-------------------------------------------------------- + 98 ; external ram data + 99 ;-------------------------------------------------------- + 100 .area XSEG (XDATA) + 0000 101 G$output_ptr$0$0==. + 0000 102 _output_ptr: + 0000 103 .ds 0x0003 + 0003 104 G$radix$0$0==. + 0003 105 _radix: + 0003 106 .ds 0x0001 + 0004 107 _vsprintf_PARM_2: + 0004 108 .ds 0x0003 + 0007 109 _vsprintf_PARM_3: + 0007 110 .ds 0x0001 + 0008 111 _vsprintf_buf_1_1: + 0008 112 .ds 0x0003 + 000B 113 _vsprintf_width_1_1: + 000B 114 .ds 0x0001 + 000C 115 _vsprintf_length_1_1: + 000C 116 .ds 0x0001 + 000D 117 _vsprintf_c_1_1: + 000D 118 .ds 0x0001 + 000E 119 _vprintf_PARM_2: + 000E 120 .ds 0x0001 + 000F 121 _vprintf_format_1_1: + 000F 122 .ds 0x0003 + 123 ;-------------------------------------------------------- + 124 ; global & static initialisations + 125 ;-------------------------------------------------------- + 126 .area GSINIT (CODE) + 127 ;-------------------------------------------------------- + 128 ; code + 129 ;-------------------------------------------------------- + 130 .area CSEG (CODE) + 0000 131 Fvprintf$output_char$0$0 ==. + 132 ; vprintf.c 63 + 133 ; ----------------------------------------- + 134 ; function output_char + 135 ; ----------------------------------------- + 0000 136 _output_char: + 0002 137 ar2 = 0x02 + 0003 138 ar3 = 0x03 + 0004 139 ar4 = 0x04 + 0005 140 ar5 = 0x05 + 0006 141 ar6 = 0x06 + 0007 142 ar7 = 0x07 + 0000 143 ar0 = 0x00 + 0001 144 ar1 = 0x01 + 0000 C0*00 145 push _bp + 0002 85 81*00 146 mov _bp,sp + 147 ; vprintf.c 0 + 0005 AA 82 148 mov r2,dpl + 149 ; vprintf.c 65 + 150 ; Peephole 111 removed ljmp by inverse jump logic + 0007 30*00 25 151 jnb _output_to_string,00102$ + 000A 152 00107$: + 153 ; vprintf.c 67 + 000A 90s00r00 154 mov dptr,#_output_ptr + 000D E0 155 movx a,@dptr + 000E FB 156 mov r3,a + 000F A3 157 inc dptr + 0010 E0 158 movx a,@dptr + 0011 FC 159 mov r4,a + 0012 A3 160 inc dptr + 0013 E0 161 movx a,@dptr + 0014 FD 162 mov r5,a + 0015 90s00r00 163 mov dptr,#_output_ptr + 0018 74 01 164 mov a,#0x01 + 001A 2B 165 add a,r3 + 001B F0 166 movx @dptr,a + 167 ; Peephole 180 changed mov to clr + 001C E4 168 clr a + 001D 3C 169 addc a,r4 + 001E A3 170 inc dptr + 001F F0 171 movx @dptr,a + 0020 A3 172 inc dptr + 0021 ED 173 mov a,r5 + 0022 F0 174 movx @dptr,a + 0023 8B 82 175 mov dpl,r3 + 0025 8C 83 176 mov dph,r4 + 0027 8D F0 177 mov b,r5 + 0029 EA 178 mov a,r2 + 002A 12s00r00 179 lcall __gptrput + 180 ; Peephole 132 changed ljmp to sjmp + 002D 80 05 181 sjmp 00104$ + 002F 182 00102$: + 183 ; vprintf.c 71 + 002F 8A 82 184 mov dpl,r2 + 0031 12s00r00 185 lcall _putchar + 0034 186 00104$: + 0034 85*00 81 187 mov sp,_bp + 0037 D0*00 188 pop _bp + 0039 189 C$vprintf.c$73$1$1 ==. + 0039 190 XFvprintf$output_char$0$0 ==. + 0039 22 191 ret + 003A 192 Fvprintf$output_digit$0$0 ==. + 193 ; vprintf.c 77 + 194 ; ----------------------------------------- + 195 ; function output_digit + 196 ; ----------------------------------------- + 003A 197 _output_digit: + 003A C0*00 198 push _bp + 003C 85 81*00 199 mov _bp,sp + 200 ; vprintf.c 79 + 003F AA 82 201 mov r2,dpl + 0041 C3 202 clr c + 0042 74 09 203 mov a,#0x09 + 0044 9A 204 subb a,r2 + 0045 E4 205 clr a + 0046 33 206 rlc a + 207 ; Peephole 105 removed redundant mov + 0047 FB 208 mov r3,a + 0048 B4 01 00 209 cjne a,#0x01,00109$ + 004B 210 00109$: + 004B E4 211 clr a + 004C 33 212 rlc a + 213 ; Peephole 105 removed redundant mov + 004D FB 214 mov r3,a + 215 ; Peephole 110 removed ljmp by inverse jump logic + 004E 60 06 216 jz 00103$ + 0050 217 00110$: + 0050 74 30 218 mov a,#0x30 + 0052 2A 219 add a,r2 + 0053 FB 220 mov r3,a + 221 ; Peephole 132 changed ljmp to sjmp + 0054 80 0F 222 sjmp 00104$ + 0056 223 00103$: + 224 ; Peephole 111 removed ljmp by inverse jump logic + 0056 30*01 06 225 jnb _lower_case,00105$ + 0059 226 00111$: + 0059 74 57 227 mov a,#0x57 + 005B 2A 228 add a,r2 + 005C FC 229 mov r4,a + 230 ; Peephole 132 changed ljmp to sjmp + 005D 80 04 231 sjmp 00106$ + 005F 232 00105$: + 005F 74 37 233 mov a,#0x37 + 0061 2A 234 add a,r2 + 0062 FC 235 mov r4,a + 0063 236 00106$: + 0063 8C 03 237 mov ar3,r4 + 0065 238 00104$: + 0065 8B 82 239 mov dpl,r3 + 0067 12s00r00 240 lcall _output_char + 006A 241 00101$: + 006A 85*00 81 242 mov sp,_bp + 006D D0*00 243 pop _bp + 006F 244 C$vprintf.c$80$1$1 ==. + 006F 245 XFvprintf$output_digit$0$0 ==. + 006F 22 246 ret + 0070 247 Fvprintf$output_2digits$0$0 ==. + 248 ; vprintf.c 84 + 249 ; ----------------------------------------- + 250 ; function output_2digits + 251 ; ----------------------------------------- + 0070 252 _output_2digits: + 0070 C0*00 253 push _bp + 0072 85 81*00 254 mov _bp,sp + 255 ; vprintf.c 87 + 0075 AA 82 256 mov r2,dpl + 257 ; vprintf.c 86 + 0077 EA 258 mov a,r2 + 0078 C4 259 swap a + 0079 54 0F 260 anl a,#0x0f + 007B FB 261 mov r3,a + 007C C0 02 262 push ar2 + 007E 8B 82 263 mov dpl,r3 + 0080 12s00r3A 264 lcall _output_digit + 0083 D0 02 265 pop ar2 + 266 ; vprintf.c 87 + 0085 53 02 0F 267 anl ar2,#0x0f + 0088 8A 82 268 mov dpl,r2 + 008A 12s00r3A 269 lcall _output_digit + 008D 270 00101$: + 008D 85*00 81 271 mov sp,_bp + 0090 D0*00 272 pop _bp + 0092 273 C$vprintf.c$88$1$1 ==. + 0092 274 XFvprintf$output_2digits$0$0 ==. + 0092 22 275 ret + 0093 276 Fvprintf$calculate_digit$0$0 ==. + 277 ; vprintf.c 92 + 278 ; ----------------------------------------- + 279 ; function calculate_digit + 280 ; ----------------------------------------- + 0093 281 _calculate_digit: + 282 ; vprintf.c 96 + 0093 7A 20 283 mov r2,#0x20 + 0095 284 00103$: + 0095 BA 00 02 285 cjne r2,#0x00,00112$ + 286 ; Peephole 132 changed ljmp to sjmp + 0098 80 34 287 sjmp 00107$ + 009A 288 00112$: + 289 ; vprintf.c 115 + 009A C3 290 clr c + 009B E5*00 291 mov a,_value+0 + 009D 33 292 rlc a + 009E F5*00 293 mov _value+0,a + 00A0 E5*01 294 mov a,_value+1 + 00A2 33 295 rlc a + 00A3 F5*01 296 mov _value+1,a + 00A5 E5*02 297 mov a,_value+2 + 00A7 33 298 rlc a + 00A8 F5*02 299 mov _value+2,a + 00AA E5*03 300 mov a,_value+3 + 00AC 33 301 rlc a + 00AD F5*03 302 mov _value+3,a + 00AF E5*04 303 mov a,_value+4 + 00B1 33 304 rlc a + 00B2 F5*04 305 mov _value+4,a + 306 ; vprintf.c 117 + 00B4 90s00r03 307 mov dptr,#_radix + 00B7 E0 308 movx a,@dptr + 00B8 FB 309 mov r3,a + 00B9 C3 310 clr c + 00BA E5*04 311 mov a,0x0004 + _value + 00BC 9B 312 subb a,r3 + 313 ; Peephole 132 changed ljmp to sjmp + 314 ; Peephole 160 removed sjmp by inverse jump logic + 00BD 40 0C 315 jc 00105$ + 00BF 316 00113$: + 317 ; vprintf.c 119 + 00BF C3 318 clr c + 00C0 E5*04 319 mov a,0x0004 + _value + 00C2 9B 320 subb a,r3 + 00C3 F5*04 321 mov 0x0004 + _value,a + 322 ; vprintf.c 120 + 00C5 74 01 323 mov a,#0x01 + 00C7 25*00 324 add a,_value + 00C9 F5*00 325 mov _value,a + 00CB 326 00105$: + 327 ; vprintf.c 96 + 00CB 1A 328 dec r2 + 329 ; Peephole 132 changed ljmp to sjmp + 00CC 80 C7 330 sjmp 00103$ + 00CE 331 00107$: + 00CE 332 C$vprintf.c$123$1$1 ==. + 00CE 333 XFvprintf$calculate_digit$0$0 ==. + 00CE 22 334 ret + 00CF 335 G$vsprintf$0$0 ==. + 336 ; vprintf.c 127 + 337 ; ----------------------------------------- + 338 ; function vsprintf + 339 ; ----------------------------------------- + 00CF 340 _vsprintf: + 341 ; vprintf.c 0 + 00CF C0 F0 342 push b + 00D1 C0 83 343 push dph + 00D3 C0 82 344 push dpl + 00D5 90s00r08 345 mov dptr,#_vsprintf_buf_1_1 + 00D8 D0 E0 346 pop acc + 00DA F0 347 movx @dptr,a + 00DB D0 E0 348 pop acc + 00DD A3 349 inc dptr + 00DE F0 350 movx @dptr,a + 00DF D0 E0 351 pop acc + 00E1 A3 352 inc dptr + 00E2 F0 353 movx @dptr,a + 354 ; vprintf.c 141 + 00E3 90s00r08 355 mov dptr,#_vsprintf_buf_1_1 + 00E6 E0 356 movx a,@dptr + 00E7 FA 357 mov r2,a + 00E8 A3 358 inc dptr + 00E9 E0 359 movx a,@dptr + 00EA FB 360 mov r3,a + 00EB A3 361 inc dptr + 00EC E0 362 movx a,@dptr + 00ED FC 363 mov r4,a + 00EE 90s00r00 364 mov dptr,#_output_ptr + 00F1 EA 365 mov a,r2 + 00F2 F0 366 movx @dptr,a + 00F3 A3 367 inc dptr + 00F4 EB 368 mov a,r3 + 00F5 F0 369 movx @dptr,a + 00F6 A3 370 inc dptr + 00F7 EC 371 mov a,r4 + 00F8 F0 372 movx @dptr,a + 373 ; vprintf.c 142 + 00F9 EA 374 mov a,r2 + 00FA 4B 375 orl a,r3 + 00FB 4C 376 orl a,r4 + 377 ; Peephole 109 removed ljmp by inverse jump logic + 00FC 70 04 378 jnz 00102$ + 00FE 379 00262$: + 380 ; vprintf.c 144 + 00FE C2*00 381 clr _output_to_string + 382 ; Peephole 132 changed ljmp to sjmp + 0100 80 02 383 sjmp 00237$ + 0102 384 00102$: + 385 ; vprintf.c 148 + 0102 D2*00 386 setb _output_to_string + 387 ; vprintf.c 151 + 0104 388 00237$: + 0104 389 00193$: + 0104 90s00r04 390 mov dptr,#_vsprintf_PARM_2 + 0107 E0 391 movx a,@dptr + 0108 FA 392 mov r2,a + 0109 A3 393 inc dptr + 010A E0 394 movx a,@dptr + 010B FB 395 mov r3,a + 010C A3 396 inc dptr + 010D E0 397 movx a,@dptr + 010E FC 398 mov r4,a + 010F 74 01 399 mov a,#0x01 + 0111 2A 400 add a,r2 + 0112 FD 401 mov r5,a + 402 ; Peephole 180 changed mov to clr + 0113 E4 403 clr a + 0114 3B 404 addc a,r3 + 0115 FE 405 mov r6,a + 0116 8C 07 406 mov ar7,r4 + 0118 90s00r04 407 mov dptr,#_vsprintf_PARM_2 + 011B ED 408 mov a,r5 + 011C F0 409 movx @dptr,a + 011D A3 410 inc dptr + 011E EE 411 mov a,r6 + 011F F0 412 movx @dptr,a + 0120 A3 413 inc dptr + 0121 EF 414 mov a,r7 + 0122 F0 415 movx @dptr,a + 0123 8A 82 416 mov dpl,r2 + 0125 8B 83 417 mov dph,r3 + 0127 8C F0 418 mov b,r4 + 0129 12s00r00 419 lcall __gptrget + 420 ; Peephole 105 removed redundant mov + 012C F5*05 421 mov _vsprintf_sloc0_1_0,a + 012E 70 03 422 jnz 00263$ + 0130 02s06r23 423 ljmp 00195$ + 0133 424 00263$: + 425 ; vprintf.c 153 + 0133 E5*05 426 mov a,_vsprintf_sloc0_1_0 + 0135 B4 25 02 427 cjne a,#0x25,00264$ + 0138 80 03 428 sjmp 00265$ + 013A 429 00264$: + 013A 02s06r1A 430 ljmp 00191$ + 013D 431 00265$: + 432 ; vprintf.c 155 + 013D C2*03 433 clr _vsprintf_left_justify_1_1 + 434 ; vprintf.c 156 + 013F C2*04 435 clr _vsprintf_zero_padding_1_1 + 436 ; vprintf.c 157 + 0141 C2*05 437 clr _vsprintf_prefix_sign_1_1 + 438 ; vprintf.c 158 + 0143 C2*06 439 clr _vsprintf_prefix_space_1_1 + 440 ; vprintf.c 159 + 0145 C2*07 441 clr _vsprintf_signed_argument_1_1 + 442 ; vprintf.c 160 + 0147 90s00r03 443 mov dptr,#_radix + 444 ; Peephole 180 changed mov to clr + 014A E4 445 clr a + 014B F0 446 movx @dptr,a + 447 ; vprintf.c 161 + 014C C2*08 448 clr _vsprintf_char_argument_1_1 + 449 ; vprintf.c 162 + 014E C2*09 450 clr _vsprintf_long_argument_1_1 + 451 ; vprintf.c 163 + 0150 90s00r0B 452 mov dptr,#_vsprintf_width_1_1 + 453 ; Peephole 180 changed mov to clr + 0153 E4 454 clr a + 0154 F0 455 movx @dptr,a + 456 ; vprintf.c 167 + 0155 457 00104$: + 0155 8D*07 458 mov _vsprintf_sloc2_1_0,r5 + 0157 8E*08 459 mov (_vsprintf_sloc2_1_0 + 1),r6 + 0159 8F*09 460 mov (_vsprintf_sloc2_1_0 + 2),r7 + 015B 0D 461 inc r5 + 015C BD 00 01 462 cjne r5,#0x00,00266$ + 015F 0E 463 inc r6 + 0160 464 00266$: + 0160 90s00r04 465 mov dptr,#_vsprintf_PARM_2 + 0163 ED 466 mov a,r5 + 0164 F0 467 movx @dptr,a + 0165 A3 468 inc dptr + 0166 EE 469 mov a,r6 + 0167 F0 470 movx @dptr,a + 0168 A3 471 inc dptr + 0169 EF 472 mov a,r7 + 016A F0 473 movx @dptr,a + 016B 85*07 82 474 mov dpl,_vsprintf_sloc2_1_0 + 016E 85*08 83 475 mov dph,(_vsprintf_sloc2_1_0 + 1) + 0171 85*09 F0 476 mov b,(_vsprintf_sloc2_1_0 + 2) + 0174 12s00r00 477 lcall __gptrget + 478 ; Peephole 100 removed redundant mov + 0177 F9 479 mov r1,a + 0178 90s00r0D 480 mov dptr,#_vsprintf_c_1_1 + 017B F0 481 movx @dptr,a + 482 ; vprintf.c 169 + 017C C0 05 483 push ar5 + 017E C0 06 484 push ar6 + 0180 C0 07 485 push ar7 + 0182 C0 01 486 push ar1 + 0184 89 82 487 mov dpl,r1 + 0186 12s00r00 488 lcall _isdigit + 0189 85 82*06 489 mov _vsprintf_sloc1_1_0,dpl + 018C D0 01 490 pop ar1 + 018E D0 07 491 pop ar7 + 0190 D0 06 492 pop ar6 + 0192 D0 05 493 pop ar5 + 0194 E5*06 494 mov a,_vsprintf_sloc1_1_0 + 495 ; Peephole 110 removed ljmp by inverse jump logic + 0196 60 2C 496 jz 00108$ + 0198 497 00267$: + 498 ; vprintf.c 171 + 0198 90s00r0B 499 mov dptr,#_vsprintf_width_1_1 + 019B E0 500 movx a,@dptr + 019C FA 501 mov r2,a + 019D 75 F0 0A 502 mov b,#0x0a + 01A0 EA 503 mov a,r2 + 01A1 A4 504 mul ab + 01A2 F5*0C 505 mov _vsprintf_sloc5_1_0,a + 01A4 E9 506 mov a,r1 + 01A5 24 D0 507 add a,#0xd0 + 508 ; Peephole 105 removed redundant mov + 01A7 F5*0A 509 mov _vsprintf_sloc3_1_0,a + 01A9 25*0C 510 add a,_vsprintf_sloc5_1_0 + 511 ; Peephole 100 removed redundant mov + 01AB F8 512 mov r0,a + 01AC 90s00r0B 513 mov dptr,#_vsprintf_width_1_1 + 01AF F0 514 movx @dptr,a + 515 ; vprintf.c 173 + 01B0 B8 00 04 516 cjne r0,#0x00,00268$ + 01B3 74 01 517 mov a,#0x01 + 01B5 80 01 518 sjmp 00269$ + 01B7 519 00268$: + 01B7 E4 520 clr a + 01B8 521 00269$: + 522 ; Peephole 105 removed redundant mov + 01B8 F5*0B 523 mov _vsprintf_sloc4_1_0,a + 01BA 70 03 524 jnz 00270$ + 01BC 02s01r55 525 ljmp 00104$ + 01BF 526 00270$: + 527 ; vprintf.c 176 + 01BF D2*04 528 setb _vsprintf_zero_padding_1_1 + 529 ; vprintf.c 178 + 01C1 02s01r55 530 ljmp 00104$ + 01C4 531 00108$: + 532 ; vprintf.c 181 + 01C4 C0 02 533 push ar2 + 01C6 C0 05 534 push ar5 + 01C8 C0 06 535 push ar6 + 01CA C0 07 536 push ar7 + 01CC C0 00 537 push ar0 + 01CE C0 01 538 push ar1 + 01D0 89 82 539 mov dpl,r1 + 01D2 12s00r00 540 lcall _islower + 01D5 85 82*0D 541 mov _vsprintf_sloc6_1_0,dpl + 01D8 D0 01 542 pop ar1 + 01DA D0 00 543 pop ar0 + 01DC D0 07 544 pop ar7 + 01DE D0 06 545 pop ar6 + 01E0 D0 05 546 pop ar5 + 01E2 D0 02 547 pop ar2 + 01E4 E5*0D 548 mov a,_vsprintf_sloc6_1_0 + 01E6 B4 01 00 549 cjne a,#0x01,00271$ + 01E9 550 00271$: + 01E9 B3 551 cpl c + 01EA 92*01 552 mov _lower_case,c + 553 ; vprintf.c 182 + 554 ; Peephole 111 removed ljmp by inverse jump logic + 01EC 30*01 07 555 jnb _lower_case,00110$ + 01EF 556 00272$: + 557 ; vprintf.c 184 + 01EF 74 DF 558 mov a,#0xdf + 01F1 59 559 anl a,r1 + 01F2 90s00r0D 560 mov dptr,#_vsprintf_c_1_1 + 01F5 F0 561 movx @dptr,a + 01F6 562 00110$: + 563 ; vprintf.c 187 + 01F6 90s00r0D 564 mov dptr,#_vsprintf_c_1_1 + 01F9 E0 565 movx a,@dptr + 01FA FB 566 mov r3,a + 01FB BB 20 04 567 cjne r3,#0x20,00273$ + 01FE 74 01 568 mov a,#0x01 + 0200 80 01 569 sjmp 00274$ + 0202 570 00273$: + 0202 E4 571 clr a + 0203 572 00274$: + 573 ; Peephole 105 removed redundant mov + 0203 F5*0E 574 mov _vsprintf_sloc7_1_0,a + 0205 60 03 575 jz 00275$ + 0207 02s02r90 576 ljmp 00113$ + 020A 577 00275$: + 020A BB 2B 04 578 cjne r3,#0x2b,00276$ + 020D 74 01 579 mov a,#0x01 + 020F 80 01 580 sjmp 00277$ + 0211 581 00276$: + 0211 E4 582 clr a + 0212 583 00277$: + 584 ; Peephole 105 removed redundant mov + 0212 F5*0F 585 mov _vsprintf_sloc8_1_0,a + 0214 60 03 586 jz 00278$ + 0216 02s02r8B 587 ljmp 00112$ + 0219 588 00278$: + 0219 BB 2D 04 589 cjne r3,#0x2d,00279$ + 021C 74 01 590 mov a,#0x01 + 021E 80 01 591 sjmp 00280$ + 0220 592 00279$: + 0220 E4 593 clr a + 0221 594 00280$: + 595 ; Peephole 105 removed redundant mov + 0221 F5*10 596 mov _vsprintf_sloc9_1_0,a + 597 ; Peephole 132 changed ljmp to sjmp + 598 ; Peephole 163 removed sjmp by inverse jump logic + 0223 70 61 599 jnz 00111$ + 0225 600 00281$: + 0225 BB 42 04 601 cjne r3,#0x42,00282$ + 0228 74 01 602 mov a,#0x01 + 022A 80 01 603 sjmp 00283$ + 022C 604 00282$: + 022C E4 605 clr a + 022D 606 00283$: + 607 ; Peephole 105 removed redundant mov + 022D F5*11 608 mov _vsprintf_sloc10_1_0,a + 609 ; Peephole 132 changed ljmp to sjmp + 610 ; Peephole 163 removed sjmp by inverse jump logic + 022F 70 64 611 jnz 00114$ + 0231 612 00284$: + 0231 BB 43 04 613 cjne r3,#0x43,00285$ + 0234 74 01 614 mov a,#0x01 + 0236 80 01 615 sjmp 00286$ + 0238 616 00285$: + 0238 E4 617 clr a + 0239 618 00286$: + 619 ; Peephole 105 removed redundant mov + 0239 F5*12 620 mov _vsprintf_sloc11_1_0,a + 621 ; Peephole 109 removed ljmp by inverse jump logic + 023B 70 62 622 jnz 00116$ + 023D 623 00287$: + 023D BB 44 04 624 cjne r3,#0x44,00288$ + 0240 74 01 625 mov a,#0x01 + 0242 80 01 626 sjmp 00289$ + 0244 627 00288$: + 0244 E4 628 clr a + 0245 629 00289$: + 630 ; Peephole 105 removed redundant mov + 0245 F5*13 631 mov _vsprintf_sloc12_1_0,a + 0247 60 03 632 jz 00290$ + 0249 02s04r23 633 ljmp 00137$ + 024C 634 00290$: + 024C BB 49 04 635 cjne r3,#0x49,00291$ + 024F 74 01 636 mov a,#0x01 + 0251 80 01 637 sjmp 00292$ + 0253 638 00291$: + 0253 E4 639 clr a + 0254 640 00292$: + 641 ; Peephole 105 removed redundant mov + 0254 F5*14 642 mov _vsprintf_sloc13_1_0,a + 0256 60 03 643 jz 00293$ + 0258 02s04r23 644 ljmp 00137$ + 025B 645 00293$: + 025B BB 4C 04 646 cjne r3,#0x4c,00294$ + 025E 74 01 647 mov a,#0x01 + 0260 80 01 648 sjmp 00295$ + 0262 649 00294$: + 0262 E4 650 clr a + 0263 651 00295$: + 652 ; Peephole 105 removed redundant mov + 0263 FC 653 mov r4,a + 654 ; Peephole 109 removed ljmp by inverse jump logic + 0264 70 34 655 jnz 00115$ + 0266 656 00296$: + 0266 BB 4F 03 657 cjne r3,#0x4f,00297$ + 0269 02s04r2D 658 ljmp 00139$ + 026C 659 00297$: + 026C BB 50 03 660 cjne r3,#0x50,00298$ + 026F 02s03rC0 661 ljmp 00133$ + 0272 662 00298$: + 0272 BB 53 02 663 cjne r3,#0x53,00299$ + 664 ; Peephole 132 changed ljmp to sjmp + 0275 80 42 665 sjmp 00117$ + 0277 666 00299$: + 0277 BB 55 03 667 cjne r3,#0x55,00300$ + 027A 02s04r35 668 ljmp 00140$ + 027D 669 00300$: + 027D BB 58 03 670 cjne r3,#0x58,00301$ + 0280 02s04r3D 671 ljmp 00141$ + 0283 672 00301$: + 0283 02s04r45 673 ljmp 00142$ + 674 ; vprintf.c 190 + 0286 675 00111$: + 0286 D2*03 676 setb _vsprintf_left_justify_1_1 + 677 ; vprintf.c 191 + 0288 02s01r55 678 ljmp 00104$ + 679 ; vprintf.c 193 + 028B 680 00112$: + 028B D2*05 681 setb _vsprintf_prefix_sign_1_1 + 682 ; vprintf.c 194 + 028D 02s01r55 683 ljmp 00104$ + 684 ; vprintf.c 196 + 0290 685 00113$: + 0290 D2*06 686 setb _vsprintf_prefix_space_1_1 + 687 ; vprintf.c 197 + 0292 02s01r55 688 ljmp 00104$ + 689 ; vprintf.c 199 + 0295 690 00114$: + 0295 D2*08 691 setb _vsprintf_char_argument_1_1 + 692 ; vprintf.c 200 + 0297 02s01r55 693 ljmp 00104$ + 694 ; vprintf.c 202 + 029A 695 00115$: + 029A D2*09 696 setb _vsprintf_long_argument_1_1 + 697 ; vprintf.c 203 + 029C 02s01r55 698 ljmp 00104$ + 699 ; vprintf.c 206 + 029F 700 00116$: + 029F 90s00r07 701 mov dptr,#_vsprintf_PARM_3 + 02A2 E0 702 movx a,@dptr + 703 ; Peephole 105 removed redundant mov + 02A3 FA 704 mov r2,a + 02A4 24 FF 705 add a,#0xff + 706 ; Peephole 100 removed redundant mov + 02A6 F8 707 mov r0,a + 02A7 90s00r07 708 mov dptr,#_vsprintf_PARM_3 + 02AA F0 709 movx @dptr,a + 02AB 86 02 710 mov ar2,@r0 + 02AD C0 03 711 push ar3 + 02AF 8A 82 712 mov dpl,r2 + 02B1 12s00r00 713 lcall _output_char + 02B4 D0 03 714 pop ar3 + 715 ; vprintf.c 207 + 02B6 02s04r4A 716 ljmp 00143$ + 717 ; vprintf.c 210 + 02B9 718 00117$: + 02B9 90s00r07 719 mov dptr,#_vsprintf_PARM_3 + 02BC E0 720 movx a,@dptr + 721 ; Peephole 105 removed redundant mov + 02BD FA 722 mov r2,a + 02BE 24 FD 723 add a,#0xfd + 724 ; Peephole 100 removed redundant mov + 02C0 F8 725 mov r0,a + 02C1 90s00r07 726 mov dptr,#_vsprintf_PARM_3 + 02C4 F0 727 movx @dptr,a + 02C5 86 02 728 mov ar2,@r0 + 02C7 08 729 inc r0 + 02C8 86 04 730 mov ar4,@r0 + 02CA 08 731 inc r0 + 02CB 86 05 732 mov ar5,@r0 + 02CD 18 733 dec r0 + 02CE 18 734 dec r0 + 02CF 8A*00 735 mov _value,r2 + 02D1 8C*01 736 mov (_value + 1),r4 + 02D3 8D*02 737 mov (_value + 2),r5 + 738 ; vprintf.c 212 + 02D5 C0 03 739 push ar3 + 02D7 8A 82 740 mov dpl,r2 + 02D9 8C 83 741 mov dph,r4 + 02DB 8D F0 742 mov b,r5 + 02DD 12s00r00 743 lcall _strlen + 02E0 AA 82 744 mov r2,dpl + 02E2 AC 83 745 mov r4,dph + 02E4 D0 03 746 pop ar3 + 02E6 8A*14 747 mov _vsprintf_sloc13_1_0,r2 + 748 ; vprintf.c 213 + 749 ; Peephole 112 removed ljmp by inverse jump logic + 02E8 20*03 3B 750 jb _vsprintf_left_justify_1_1,00124$ + 02EB 751 00302$: + 02EB 90s00r0B 752 mov dptr,#_vsprintf_width_1_1 + 02EE E0 753 movx a,@dptr + 02EF FC 754 mov r4,a + 02F0 C3 755 clr c + 02F1 E5*14 756 mov a,_vsprintf_sloc13_1_0 + 02F3 9C 757 subb a,r4 + 758 ; Peephole 108 removed ljmp by inverse jump logic + 02F4 50 30 759 jnc 00124$ + 02F6 760 00303$: + 761 ; vprintf.c 215 + 02F6 C3 762 clr c + 02F7 EC 763 mov a,r4 + 02F8 95*14 764 subb a,_vsprintf_sloc13_1_0 + 02FA FC 765 mov r4,a + 766 ; vprintf.c 216 + 02FB 767 00118$: + 02FB 8C 05 768 mov ar5,r4 + 02FD 1C 769 dec r4 + 02FE 90s00r0B 770 mov dptr,#_vsprintf_width_1_1 + 0301 EC 771 mov a,r4 + 0302 F0 772 movx @dptr,a + 0303 BD 00 04 773 cjne r5,#0x00,00304$ + 0306 74 01 774 mov a,#0x01 + 0308 80 01 775 sjmp 00305$ + 030A 776 00304$: + 030A E4 777 clr a + 030B 778 00305$: + 779 ; Peephole 105 removed redundant mov + 030B FE 780 mov r6,a + 781 ; Peephole 109 removed ljmp by inverse jump logic + 030C 70 18 782 jnz 00124$ + 030E 783 00306$: + 784 ; vprintf.c 218 + 030E C0 03 785 push ar3 + 0310 C0 04 786 push ar4 + 0312 C0 05 787 push ar5 + 0314 C0 06 788 push ar6 + 0316 75 82 20 789 mov dpl,#0x20 + 0319 12s00r00 790 lcall _output_char + 031C D0 06 791 pop ar6 + 031E D0 05 792 pop ar5 + 0320 D0 04 793 pop ar4 + 0322 D0 03 794 pop ar3 + 795 ; vprintf.c 222 + 796 ; Peephole 132 changed ljmp to sjmp + 0324 80 D5 797 sjmp 00118$ + 0326 798 00124$: + 0326 AC*00 799 mov r4,_value + 0328 AD*01 800 mov r5,(_value + 1) + 032A AE*02 801 mov r6,(_value + 2) + 032C 8C 82 802 mov dpl,r4 + 032E 8D 83 803 mov dph,r5 + 0330 8E F0 804 mov b,r6 + 0332 12s00r00 805 lcall __gptrget + 806 ; Peephole 105 removed redundant mov + 0335 F5*13 807 mov _vsprintf_sloc12_1_0,a + 808 ; Peephole 110 removed ljmp by inverse jump logic + 0337 60 40 809 jz 00126$ + 0339 810 00307$: + 811 ; vprintf.c 223 + 0339 74 01 812 mov a,#0x01 + 033B 2C 813 add a,r4 + 033C F8 814 mov r0,a + 815 ; Peephole 180 changed mov to clr + 033D E4 816 clr a + 033E 3D 817 addc a,r5 + 033F F9 818 mov r1,a + 0340 8E 02 819 mov ar2,r6 + 0342 88*00 820 mov _value,r0 + 0344 89*01 821 mov (_value + 1),r1 + 0346 8A*02 822 mov (_value + 2),r2 + 0348 8C 82 823 mov dpl,r4 + 034A 8D 83 824 mov dph,r5 + 034C 8E F0 825 mov b,r6 + 034E 12s00r00 826 lcall __gptrget + 0351 FF 827 mov r7,a + 0352 C0 02 828 push ar2 + 0354 C0 03 829 push ar3 + 0356 C0 04 830 push ar4 + 0358 C0 05 831 push ar5 + 035A C0 06 832 push ar6 + 035C C0 07 833 push ar7 + 035E C0 00 834 push ar0 + 0360 C0 01 835 push ar1 + 0362 8F 82 836 mov dpl,r7 + 0364 12s00r00 837 lcall _output_char + 0367 D0 01 838 pop ar1 + 0369 D0 00 839 pop ar0 + 036B D0 07 840 pop ar7 + 036D D0 06 841 pop ar6 + 036F D0 05 842 pop ar5 + 0371 D0 04 843 pop ar4 + 0373 D0 03 844 pop ar3 + 0375 D0 02 845 pop ar2 + 846 ; Peephole 132 changed ljmp to sjmp + 0377 80 AD 847 sjmp 00124$ + 0379 848 00126$: + 849 ; vprintf.c 225 + 0379 20*03 03 850 jb _vsprintf_left_justify_1_1,00308$ + 037C 02s04r4A 851 ljmp 00143$ + 037F 852 00308$: + 037F 90s00r0B 853 mov dptr,#_vsprintf_width_1_1 + 0382 E0 854 movx a,@dptr + 0383 FA 855 mov r2,a + 0384 C3 856 clr c + 0385 E5*14 857 mov a,_vsprintf_sloc13_1_0 + 0387 9A 858 subb a,r2 + 0388 40 03 859 jc 00309$ + 038A 02s04r4A 860 ljmp 00143$ + 038D 861 00309$: + 862 ; vprintf.c 227 + 038D C3 863 clr c + 038E EA 864 mov a,r2 + 038F 95*14 865 subb a,_vsprintf_sloc13_1_0 + 0391 FA 866 mov r2,a + 867 ; vprintf.c 228 + 0392 868 00127$: + 0392 8A 04 869 mov ar4,r2 + 0394 1A 870 dec r2 + 0395 90s00r0B 871 mov dptr,#_vsprintf_width_1_1 + 0398 EA 872 mov a,r2 + 0399 F0 873 movx @dptr,a + 039A BC 00 04 874 cjne r4,#0x00,00310$ + 039D 74 01 875 mov a,#0x01 + 039F 80 01 876 sjmp 00311$ + 03A1 877 00310$: + 03A1 E4 878 clr a + 03A2 879 00311$: + 880 ; Peephole 105 removed redundant mov + 03A2 FD 881 mov r5,a + 03A3 60 03 882 jz 00312$ + 03A5 02s04r4A 883 ljmp 00143$ + 03A8 884 00312$: + 885 ; vprintf.c 230 + 03A8 C0 02 886 push ar2 + 03AA C0 03 887 push ar3 + 03AC C0 04 888 push ar4 + 03AE C0 05 889 push ar5 + 03B0 75 82 20 890 mov dpl,#0x20 + 03B3 12s00r00 891 lcall _output_char + 03B6 D0 05 892 pop ar5 + 03B8 D0 04 893 pop ar4 + 03BA D0 03 894 pop ar3 + 03BC D0 02 895 pop ar2 + 896 ; vprintf.c 236 + 897 ; Peephole 132 changed ljmp to sjmp + 03BE 80 D2 898 sjmp 00127$ + 03C0 899 00133$: + 03C0 90s00r07 900 mov dptr,#_vsprintf_PARM_3 + 03C3 E0 901 movx a,@dptr + 902 ; Peephole 105 removed redundant mov + 03C4 FA 903 mov r2,a + 03C5 24 FD 904 add a,#0xfd + 905 ; Peephole 100 removed redundant mov + 03C7 F8 906 mov r0,a + 03C8 90s00r07 907 mov dptr,#_vsprintf_PARM_3 + 03CB F0 908 movx @dptr,a + 03CC 86 02 909 mov ar2,@r0 + 03CE 08 910 inc r0 + 03CF 86 04 911 mov ar4,@r0 + 03D1 08 912 inc r0 + 03D2 86 05 913 mov ar5,@r0 + 03D4 18 914 dec r0 + 03D5 18 915 dec r0 + 03D6 8A*00 916 mov _value,r2 + 03D8 8C*01 917 mov (_value + 1),r4 + 03DA 8D*02 918 mov (_value + 2),r5 + 919 ; vprintf.c 238 + 03DC C3 920 clr c + 03DD 74 03 921 mov a,#0x03 + 03DF 95*02 922 subb a,0x0002 + _value + 923 ; Peephole 108 removed ljmp by inverse jump logic + 03E1 50 04 924 jnc 00200$ + 03E3 925 00313$: + 03E3 7A 04 926 mov r2,#0x04 + 927 ; Peephole 132 changed ljmp to sjmp + 03E5 80 02 928 sjmp 00201$ + 03E7 929 00200$: + 03E7 AA*02 930 mov r2,0x0002 + _value + 03E9 931 00201$: + 03E9 EA 932 mov a,r2 + 933 ; Peephole 180 changed mov to clr + 934 ; Peephole 186 optimized movc sequence + 03EA 90s06r6B 935 mov dptr,#_memory_id + 03ED 93 936 movc a,@a+dptr + 03EE FA 937 mov r2,a + 03EF C0 03 938 push ar3 + 03F1 8A 82 939 mov dpl,r2 + 03F3 12s00r00 940 lcall _output_char + 03F6 D0 03 941 pop ar3 + 942 ; vprintf.c 239 + 03F8 C0 03 943 push ar3 + 03FA 75 82 3A 944 mov dpl,#0x3a + 03FD 12s00r00 945 lcall _output_char + 0400 D0 03 946 pop ar3 + 947 ; vprintf.c 240 + 0402 E5*02 948 mov a,0x0002 + _value + 949 ; Peephole 110 removed ljmp by inverse jump logic + 0404 60 11 950 jz 00135$ + 0406 951 00314$: + 0406 E5*02 952 mov a,0x0002 + _value + 0408 B4 03 02 953 cjne a,#0x03,00315$ + 954 ; Peephole 132 changed ljmp to sjmp + 040B 80 0A 955 sjmp 00135$ + 040D 956 00315$: + 957 ; vprintf.c 241 + 040D C0 03 958 push ar3 + 040F 85*01 82 959 mov dpl,0x0001 + _value + 0412 12s00r70 960 lcall _output_2digits + 0415 D0 03 961 pop ar3 + 0417 962 00135$: + 963 ; vprintf.c 242 + 0417 C0 03 964 push ar3 + 0419 85*00 82 965 mov dpl,_value + 041C 12s00r70 966 lcall _output_2digits + 041F D0 03 967 pop ar3 + 968 ; vprintf.c 243 + 969 ; vprintf.c 247 + 970 ; Peephole 132 changed ljmp to sjmp + 0421 80 27 971 sjmp 00143$ + 0423 972 00137$: + 0423 D2*07 973 setb _vsprintf_signed_argument_1_1 + 974 ; vprintf.c 248 + 0425 90s00r03 975 mov dptr,#_radix + 0428 74 0A 976 mov a,#0x0a + 042A F0 977 movx @dptr,a + 978 ; vprintf.c 249 + 979 ; vprintf.c 252 + 980 ; Peephole 132 changed ljmp to sjmp + 042B 80 1D 981 sjmp 00143$ + 042D 982 00139$: + 042D 90s00r03 983 mov dptr,#_radix + 0430 74 08 984 mov a,#0x08 + 0432 F0 985 movx @dptr,a + 986 ; vprintf.c 253 + 987 ; vprintf.c 256 + 988 ; Peephole 132 changed ljmp to sjmp + 0433 80 15 989 sjmp 00143$ + 0435 990 00140$: + 0435 90s00r03 991 mov dptr,#_radix + 0438 74 0A 992 mov a,#0x0a + 043A F0 993 movx @dptr,a + 994 ; vprintf.c 257 + 995 ; vprintf.c 260 + 996 ; Peephole 132 changed ljmp to sjmp + 043B 80 0D 997 sjmp 00143$ + 043D 998 00141$: + 043D 90s00r03 999 mov dptr,#_radix + 0440 74 10 1000 mov a,#0x10 + 0442 F0 1001 movx @dptr,a + 1002 ; vprintf.c 261 + 1003 ; vprintf.c 265 + 1004 ; Peephole 132 changed ljmp to sjmp + 0443 80 05 1005 sjmp 00143$ + 0445 1006 00142$: + 0445 8B 82 1007 mov dpl,r3 + 0447 12s00r00 1008 lcall _output_char + 1009 ; vprintf.c 267 + 044A 1010 00143$: + 1011 ; vprintf.c 269 + 044A 90s00r03 1012 mov dptr,#_radix + 044D E0 1013 movx a,@dptr + 044E FA 1014 mov r2,a + 044F BA 00 03 1015 cjne r2,#0x00,00316$ + 0452 02s01r04 1016 ljmp 00193$ + 0455 1017 00316$: + 1018 ; vprintf.c 275 + 1019 ; Peephole 111 removed ljmp by inverse jump logic + 0455 30*08 2F 1020 jnb _vsprintf_char_argument_1_1,00152$ + 0458 1021 00317$: + 1022 ; vprintf.c 277 + 0458 90s00r07 1023 mov dptr,#_vsprintf_PARM_3 + 045B E0 1024 movx a,@dptr + 1025 ; Peephole 105 removed redundant mov + 045C FA 1026 mov r2,a + 045D 24 FF 1027 add a,#0xff + 1028 ; Peephole 100 removed redundant mov + 045F F8 1029 mov r0,a + 0460 90s00r07 1030 mov dptr,#_vsprintf_PARM_3 + 0463 F0 1031 movx @dptr,a + 0464 86 02 1032 mov ar2,@r0 + 0466 EA 1033 mov a,r2 + 0467 33 1034 rlc a + 0468 95 E0 1035 subb a,acc + 046A FB 1036 mov r3,a + 046B FC 1037 mov r4,a + 046C FD 1038 mov r5,a + 046D 8A*00 1039 mov _value,r2 + 046F 8B*01 1040 mov (_value + 1),r3 + 0471 8C*02 1041 mov (_value + 2),r4 + 0473 8D*03 1042 mov (_value + 3),r5 + 1043 ; vprintf.c 278 + 0475 30*07 03 1044 jnb _vsprintf_signed_argument_1_1,00318$ + 0478 02s04rD7 1045 ljmp 00153$ + 047B 1046 00318$: + 1047 ; vprintf.c 280 + 047B 75*01 00 1048 mov 0x0001 + _value,#0x00 + 1049 ; vprintf.c 281 + 047E 75*02 00 1050 mov 0x0002 + _value,#0x00 + 1051 ; vprintf.c 282 + 0481 75*03 00 1052 mov 0x0003 + _value,#0x00 + 0484 02s04rD7 1053 ljmp 00153$ + 0487 1054 00152$: + 1055 ; vprintf.c 285 + 1056 ; Peephole 111 removed ljmp by inverse jump logic + 0487 30*09 24 1057 jnb _vsprintf_long_argument_1_1,00149$ + 048A 1058 00319$: + 1059 ; vprintf.c 287 + 048A 90s00r07 1060 mov dptr,#_vsprintf_PARM_3 + 048D E0 1061 movx a,@dptr + 1062 ; Peephole 105 removed redundant mov + 048E FA 1063 mov r2,a + 048F 24 FC 1064 add a,#0xfc + 1065 ; Peephole 100 removed redundant mov + 0491 F8 1066 mov r0,a + 0492 90s00r07 1067 mov dptr,#_vsprintf_PARM_3 + 0495 F0 1068 movx @dptr,a + 0496 86 02 1069 mov ar2,@r0 + 0498 08 1070 inc r0 + 0499 86 03 1071 mov ar3,@r0 + 049B 08 1072 inc r0 + 049C 86 04 1073 mov ar4,@r0 + 049E 08 1074 inc r0 + 049F 86 05 1075 mov ar5,@r0 + 04A1 18 1076 dec r0 + 04A2 18 1077 dec r0 + 04A3 18 1078 dec r0 + 04A4 8A*00 1079 mov _value,r2 + 04A6 8B*01 1080 mov (_value + 1),r3 + 04A8 8C*02 1081 mov (_value + 2),r4 + 04AA 8D*03 1082 mov (_value + 3),r5 + 1083 ; Peephole 132 changed ljmp to sjmp + 04AC 80 29 1084 sjmp 00153$ + 04AE 1085 00149$: + 1086 ; vprintf.c 291 + 04AE 90s00r07 1087 mov dptr,#_vsprintf_PARM_3 + 04B1 E0 1088 movx a,@dptr + 1089 ; Peephole 105 removed redundant mov + 04B2 FA 1090 mov r2,a + 04B3 24 FE 1091 add a,#0xfe + 1092 ; Peephole 100 removed redundant mov + 04B5 F8 1093 mov r0,a + 04B6 90s00r07 1094 mov dptr,#_vsprintf_PARM_3 + 04B9 F0 1095 movx @dptr,a + 04BA 86 02 1096 mov ar2,@r0 + 04BC 08 1097 inc r0 + 04BD 86 03 1098 mov ar3,@r0 + 04BF 18 1099 dec r0 + 04C0 EB 1100 mov a,r3 + 04C1 33 1101 rlc a + 04C2 95 E0 1102 subb a,acc + 04C4 FC 1103 mov r4,a + 04C5 FD 1104 mov r5,a + 04C6 8A*00 1105 mov _value,r2 + 04C8 8B*01 1106 mov (_value + 1),r3 + 04CA 8C*02 1107 mov (_value + 2),r4 + 04CC 8D*03 1108 mov (_value + 3),r5 + 1109 ; vprintf.c 292 + 1110 ; Peephole 112 removed ljmp by inverse jump logic + 04CE 20*07 06 1111 jb _vsprintf_signed_argument_1_1,00153$ + 04D1 1112 00320$: + 1113 ; vprintf.c 294 + 04D1 75*02 00 1114 mov 0x0002 + _value,#0x00 + 1115 ; vprintf.c 295 + 04D4 75*03 00 1116 mov 0x0003 + _value,#0x00 + 04D7 1117 00153$: + 1118 ; vprintf.c 299 + 1119 ; Peephole 111 removed ljmp by inverse jump logic + 04D7 30*07 22 1120 jnb _vsprintf_signed_argument_1_1,00158$ + 04DA 1121 00321$: + 1122 ; vprintf.c 301 + 04DA E5*03 1123 mov a,(_value + 3) + 1124 ; Peephole 111 removed ljmp by inverse jump logic + 04DC 30 E7 1B 1125 jnb acc.7,00155$ + 04DF 1126 00322$: + 1127 ; vprintf.c 302 + 04DF C3 1128 clr c + 04E0 E4 1129 clr a + 04E1 95*00 1130 subb a,_value + 04E3 FA 1131 mov r2,a + 04E4 E4 1132 clr a + 04E5 95*01 1133 subb a,(_value + 1) + 04E7 FB 1134 mov r3,a + 04E8 E4 1135 clr a + 04E9 95*02 1136 subb a,(_value + 2) + 04EB FC 1137 mov r4,a + 04EC E4 1138 clr a + 04ED 95*03 1139 subb a,(_value + 3) + 04EF FD 1140 mov r5,a + 04F0 8A*00 1141 mov _value,r2 + 04F2 8B*01 1142 mov (_value + 1),r3 + 04F4 8C*02 1143 mov (_value + 2),r4 + 04F6 8D*03 1144 mov (_value + 3),r5 + 1145 ; Peephole 132 changed ljmp to sjmp + 04F8 80 02 1146 sjmp 00158$ + 04FA 1147 00155$: + 1148 ; vprintf.c 304 + 04FA C2*07 1149 clr _vsprintf_signed_argument_1_1 + 04FC 1150 00158$: + 1151 ; vprintf.c 307 + 04FC 90s00r0C 1152 mov dptr,#_vsprintf_length_1_1 + 1153 ; Peephole 180 changed mov to clr + 04FF E4 1154 clr a + 0500 F0 1155 movx @dptr,a + 1156 ; vprintf.c 308 + 0501 D2*02 1157 setb _lsd + 1158 ; vprintf.c 309 + 0503 7A 00 1159 mov r2,#0x00 + 0505 1160 00162$: + 0505 E5*00 1161 mov a,_value + 1162 ; Peephole 162 removed sjmp by inverse jump logic + 0507 60 02 1163 jz 00324$ + 0509 1164 00323$: + 1165 ; Peephole 132 changed ljmp to sjmp + 0509 80 1E 1166 sjmp 00163$ + 050B 1167 00324$: + 050B E5*01 1168 mov a,0x0001 + _value + 1169 ; Peephole 162 removed sjmp by inverse jump logic + 050D 60 02 1170 jz 00326$ + 050F 1171 00325$: + 1172 ; Peephole 132 changed ljmp to sjmp + 050F 80 18 1173 sjmp 00163$ + 0511 1174 00326$: + 1175 ; vprintf.c 310 + 0511 E5*02 1176 mov a,0x0002 + _value + 1177 ; Peephole 162 removed sjmp by inverse jump logic + 0513 60 02 1178 jz 00328$ + 0515 1179 00327$: + 1180 ; Peephole 132 changed ljmp to sjmp + 0515 80 12 1181 sjmp 00163$ + 0517 1182 00328$: + 0517 E5*03 1183 mov a,0x0003 + _value + 0519 70 04 1184 jnz 00329$ + 051B 74 01 1185 mov a,#0x01 + 051D 80 01 1186 sjmp 00330$ + 051F 1187 00329$: + 051F E4 1188 clr a + 0520 1189 00330$: + 0520 FB 1190 mov r3,a + 0521 90s00r0C 1191 mov dptr,#_vsprintf_length_1_1 + 0524 EA 1192 mov a,r2 + 0525 F0 1193 movx @dptr,a + 0526 EB 1194 mov a,r3 + 1195 ; Peephole 109 removed ljmp by inverse jump logic + 0527 70 21 1196 jnz 00164$ + 0529 1197 00331$: + 0529 1198 00163$: + 1199 ; vprintf.c 312 + 0529 75*04 00 1200 mov 0x0004 + _value,#0x00 + 1201 ; vprintf.c 313 + 052C C0 02 1202 push ar2 + 052E 12s00r93 1203 lcall _calculate_digit + 0531 D0 02 1204 pop ar2 + 1205 ; vprintf.c 327 + 0533 20*02 0B 1206 jb _lsd,1$ + 0536 D0 F0 1207 pop b ; b = + 0538 E5*04 1208 mov a,_value+4 ; a = + 053A C4 1209 swap a + 053B 42 F0 1210 orl b,a ; b = + 053D C0 F0 1211 push b + 053F 80 04 1212 sjmp 2$ + 0541 1213 1$: + 0541 E5*04 1214 mov a,_value+4 ; a = + 0543 C0 E0 1215 push acc + 0545 1216 2$: + 1217 ; vprintf.c 329 + 0545 0A 1218 inc r2 + 1219 ; vprintf.c 330 + 1220 ; Peephole 167 removed redundant bit moves (c not set to _lsd) + 0546 B2*02 1221 cpl _lsd + 1222 ; Peephole 132 changed ljmp to sjmp + 0548 80 BB 1223 sjmp 00162$ + 054A 1224 00164$: + 1225 ; vprintf.c 333 + 054A 90s00r0B 1226 mov dptr,#_vsprintf_width_1_1 + 054D E0 1227 movx a,@dptr + 054E FB 1228 mov r3,a + 1229 ; Peephole 132 changed ljmp to sjmp + 1230 ; Peephole 199 optimized misc jump sequence + 054F BB 00 06 1231 cjne r3,#0x00,00166$ + 1232 ; Peephole 201 removed redundant sjmp + 0552 1233 00332$: + 0552 1234 00333$: + 1235 ; vprintf.c 338 + 0552 90s00r0B 1236 mov dptr,#_vsprintf_width_1_1 + 0555 74 01 1237 mov a,#0x01 + 0557 F0 1238 movx @dptr,a + 0558 1239 00166$: + 1240 ; vprintf.c 342 + 1241 ; Peephole 112 removed ljmp by inverse jump logic + 0558 20*04 21 1242 jb _vsprintf_zero_padding_1_1,00171$ + 055B 1243 00334$: + 1244 ; vprintf.c 344 + 055B 0A 1245 inc r2 + 055C 90s00r0B 1246 mov dptr,#_vsprintf_width_1_1 + 055F E0 1247 movx a,@dptr + 0560 FB 1248 mov r3,a + 0561 1249 00167$: + 0561 C3 1250 clr c + 0562 EA 1251 mov a,r2 + 0563 9B 1252 subb a,r3 + 0564 E4 1253 clr a + 0565 33 1254 rlc a + 0566 FA 1255 mov r2,a + 0567 90s00r0B 1256 mov dptr,#_vsprintf_width_1_1 + 056A EB 1257 mov a,r3 + 056B F0 1258 movx @dptr,a + 056C EA 1259 mov a,r2 + 1260 ; Peephole 110 removed ljmp by inverse jump logic + 056D 60 0D 1261 jz 00171$ + 056F 1262 00335$: + 1263 ; vprintf.c 346 + 056F C0 03 1264 push ar3 + 0571 75 82 20 1265 mov dpl,#0x20 + 0574 12s00r00 1266 lcall _output_char + 0577 D0 03 1267 pop ar3 + 1268 ; vprintf.c 347 + 0579 1B 1269 dec r3 + 1270 ; Peephole 132 changed ljmp to sjmp + 057A 80 E5 1271 sjmp 00167$ + 057C 1272 00171$: + 1273 ; vprintf.c 351 + 1274 ; Peephole 111 removed ljmp by inverse jump logic + 057C 30*07 13 1275 jnb _vsprintf_signed_argument_1_1,00180$ + 057F 1276 00336$: + 1277 ; vprintf.c 353 + 057F 75 82 2D 1278 mov dpl,#0x2d + 0582 12s00r00 1279 lcall _output_char + 1280 ; vprintf.c 355 + 0585 90s00r0B 1281 mov dptr,#_vsprintf_width_1_1 + 0588 E0 1282 movx a,@dptr + 1283 ; Peephole 105 removed redundant mov + 0589 FA 1284 mov r2,a + 058A 24 FF 1285 add a,#0xff + 058C 90s00r0B 1286 mov dptr,#_vsprintf_width_1_1 + 058F F0 1287 movx @dptr,a + 1288 ; Peephole 132 changed ljmp to sjmp + 0590 80 34 1289 sjmp 00258$ + 0592 1290 00180$: + 1291 ; vprintf.c 357 + 0592 90s00r0C 1292 mov dptr,#_vsprintf_length_1_1 + 0595 E0 1293 movx a,@dptr + 0596 FA 1294 mov r2,a + 0597 BA 00 02 1295 cjne r2,#0x00,00337$ + 1296 ; Peephole 132 changed ljmp to sjmp + 059A 80 2A 1297 sjmp 00258$ + 059C 1298 00337$: + 1299 ; vprintf.c 360 + 1300 ; Peephole 111 removed ljmp by inverse jump logic + 059C 30*05 13 1301 jnb _vsprintf_prefix_sign_1_1,00175$ + 059F 1302 00338$: + 1303 ; vprintf.c 362 + 059F 75 82 2B 1304 mov dpl,#0x2b + 05A2 12s00r00 1305 lcall _output_char + 1306 ; vprintf.c 364 + 05A5 90s00r0B 1307 mov dptr,#_vsprintf_width_1_1 + 05A8 E0 1308 movx a,@dptr + 1309 ; Peephole 105 removed redundant mov + 05A9 FA 1310 mov r2,a + 05AA 24 FF 1311 add a,#0xff + 05AC 90s00r0B 1312 mov dptr,#_vsprintf_width_1_1 + 05AF F0 1313 movx @dptr,a + 1314 ; Peephole 132 changed ljmp to sjmp + 05B0 80 14 1315 sjmp 00258$ + 05B2 1316 00175$: + 1317 ; vprintf.c 366 + 1318 ; Peephole 111 removed ljmp by inverse jump logic + 05B2 30*06 11 1319 jnb _vsprintf_prefix_space_1_1,00258$ + 05B5 1320 00339$: + 1321 ; vprintf.c 368 + 05B5 75 82 20 1322 mov dpl,#0x20 + 05B8 12s00r00 1323 lcall _output_char + 1324 ; vprintf.c 370 + 05BB 90s00r0B 1325 mov dptr,#_vsprintf_width_1_1 + 05BE E0 1326 movx a,@dptr + 1327 ; Peephole 105 removed redundant mov + 05BF FA 1328 mov r2,a + 05C0 24 FF 1329 add a,#0xff + 05C2 90s00r0B 1330 mov dptr,#_vsprintf_width_1_1 + 05C5 F0 1331 movx @dptr,a + 1332 ; vprintf.c 375 + 05C6 1333 00258$: + 05C6 90s00r0C 1334 mov dptr,#_vsprintf_length_1_1 + 05C9 E0 1335 movx a,@dptr + 05CA FA 1336 mov r2,a + 05CB 90s00r0B 1337 mov dptr,#_vsprintf_width_1_1 + 05CE E0 1338 movx a,@dptr + 05CF FB 1339 mov r3,a + 05D0 1340 00182$: + 05D0 8B 04 1341 mov ar4,r3 + 05D2 1B 1342 dec r3 + 05D3 C3 1343 clr c + 05D4 EA 1344 mov a,r2 + 05D5 9C 1345 subb a,r4 + 1346 ; Peephole 108 removed ljmp by inverse jump logic + 05D6 50 18 1347 jnc 00260$ + 05D8 1348 00340$: + 1349 ; vprintf.c 377 + 1350 ; Peephole 111 removed ljmp by inverse jump logic + 05D8 30*04 04 1351 jnb _vsprintf_zero_padding_1_1,00202$ + 05DB 1352 00341$: + 05DB 7C 30 1353 mov r4,#0x30 + 1354 ; Peephole 132 changed ljmp to sjmp + 05DD 80 02 1355 sjmp 00203$ + 05DF 1356 00202$: + 05DF 7C 20 1357 mov r4,#0x20 + 05E1 1358 00203$: + 05E1 C0 02 1359 push ar2 + 05E3 C0 03 1360 push ar3 + 05E5 8C 82 1361 mov dpl,r4 + 05E7 12s00r00 1362 lcall _output_char + 05EA D0 03 1363 pop ar3 + 05EC D0 02 1364 pop ar2 + 1365 ; vprintf.c 381 + 1366 ; Peephole 132 changed ljmp to sjmp + 05EE 80 E0 1367 sjmp 00182$ + 05F0 1368 00260$: + 05F0 1369 00185$: + 05F0 8A 03 1370 mov ar3,r2 + 05F2 1A 1371 dec r2 + 05F3 EB 1372 mov a,r3 + 05F4 70 03 1373 jnz 00342$ + 05F6 02s01r04 1374 ljmp 00193$ + 05F9 1375 00342$: + 1376 ; vprintf.c 383 + 1377 ; Peephole 167 removed redundant bit moves (c not set to _lsd) + 05F9 B2*02 1378 cpl _lsd + 1379 ; vprintf.c 398 + 05FB 20*02 0A 1380 jb _lsd,3$ + 05FE D0 E0 1381 pop acc ; a = + 0600 00 1382 nop ; to disable the "optimizer" + 0601 C0 E0 1383 push acc + 0603 C4 1384 swap a + 0604 54 0F 1385 anl a,#0x0F ; a = + 0606 80 04 1386 sjmp 4$ + 0608 1387 3$: + 0608 D0 E0 1388 pop acc + 060A 54 0F 1389 anl a,#0x0F ; a = + 060C 1390 4$: + 060C F5*04 1391 mov _value+4,a + 1392 ; vprintf.c 400 + 060E C0 02 1393 push ar2 + 0610 85*04 82 1394 mov dpl,0x0004 + _value + 0613 12s00r3A 1395 lcall _output_digit + 0616 D0 02 1396 pop ar2 + 1397 ; Peephole 132 changed ljmp to sjmp + 0618 80 D6 1398 sjmp 00185$ + 061A 1399 00191$: + 1400 ; vprintf.c 407 + 061A 85*05 82 1401 mov dpl,_vsprintf_sloc0_1_0 + 061D 12s00r00 1402 lcall _output_char + 0620 02s01r04 1403 ljmp 00193$ + 0623 1404 00195$: + 1405 ; vprintf.c 413 + 1406 ; Peephole 111 removed ljmp by inverse jump logic + 0623 30*00 06 1407 jnb _output_to_string,00198$ + 0626 1408 00343$: + 0626 75 82 00 1409 mov dpl,#0x00 + 0629 12s00r00 1410 lcall _output_char + 062C 1411 00198$: + 062C 1412 C$vprintf.c$414$1$1 ==. + 062C 1413 XG$vsprintf$0$0 ==. + 062C 22 1414 ret + 062D 1415 G$vprintf$0$0 ==. + 1416 ; vprintf.c 418 + 1417 ; ----------------------------------------- + 1418 ; function vprintf + 1419 ; ----------------------------------------- + 062D 1420 _vprintf: + 1421 ; vprintf.c 420 + 062D C0 F0 1422 push b + 062F C0 83 1423 push dph + 0631 C0 82 1424 push dpl + 0633 90s00r0F 1425 mov dptr,#_vprintf_format_1_1 + 0636 D0 E0 1426 pop acc + 0638 F0 1427 movx @dptr,a + 0639 D0 E0 1428 pop acc + 063B A3 1429 inc dptr + 063C F0 1430 movx @dptr,a + 063D D0 E0 1431 pop acc + 063F A3 1432 inc dptr + 0640 F0 1433 movx @dptr,a + 0641 90s00r0F 1434 mov dptr,#_vprintf_format_1_1 + 0644 E0 1435 movx a,@dptr + 0645 FA 1436 mov r2,a + 0646 A3 1437 inc dptr + 0647 E0 1438 movx a,@dptr + 0648 FB 1439 mov r3,a + 0649 A3 1440 inc dptr + 064A E0 1441 movx a,@dptr + 064B FC 1442 mov r4,a + 064C 90s00r0E 1443 mov dptr,#_vprintf_PARM_2 + 064F E0 1444 movx a,@dptr + 0650 FD 1445 mov r5,a + 0651 90s00r04 1446 mov dptr,#_vsprintf_PARM_2 + 0654 EA 1447 mov a,r2 + 0655 F0 1448 movx @dptr,a + 0656 A3 1449 inc dptr + 0657 EB 1450 mov a,r3 + 0658 F0 1451 movx @dptr,a + 0659 A3 1452 inc dptr + 065A EC 1453 mov a,r4 + 065B F0 1454 movx @dptr,a + 065C 90s00r07 1455 mov dptr,#_vsprintf_PARM_3 + 065F ED 1456 mov a,r5 + 0660 F0 1457 movx @dptr,a + 1458 ; Peephole 181 used 16 bit load of dptr + 0661 90 00 00 1459 mov dptr,#0x0000 + 0664 75 F0 00 1460 mov b,#0x00 + 0667 12s00rCF 1461 lcall _vsprintf + 066A 1462 C$vprintf.c$421$1$1 ==. + 066A 1463 XG$vprintf$0$0 ==. + 1464 ; Peephole 151 removed misc moves via dph, dpl before return + 066A 1465 00101$: + 066A 22 1466 ret + 1467 .area CSEG (CODE) + 066B 1468 Fvprintf$memory_id$0$0 == . + 066B 1469 _memory_id: + 066B 49 58 43 50 2D 1470 .ascii /IXCP-/ + 0670 00 1471 .byte 0 diff --git a/device/lib/vprintf.sym b/device/lib/vprintf.sym new file mode 100644 index 00000000..dc9f7f21 --- /dev/null +++ b/device/lib/vprintf.sym @@ -0,0 +1,1314 @@ + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 1. + +Symbol Table + + A 00D6 + 7 A$vprintf$1000 0440 GR + 7 A$vprintf$1001 0442 GR + 7 A$vprintf$1005 0443 GR + 7 A$vprintf$1007 0445 GR + 7 A$vprintf$1008 0447 GR + 7 A$vprintf$1012 044A GR + 7 A$vprintf$1013 044D GR + 7 A$vprintf$1014 044E GR + 7 A$vprintf$1015 044F GR + 7 A$vprintf$1016 0452 GR + 7 A$vprintf$1020 0455 GR + 7 A$vprintf$1023 0458 GR + 7 A$vprintf$1024 045B GR + 7 A$vprintf$1026 045C GR + 7 A$vprintf$1027 045D GR + 7 A$vprintf$1029 045F GR + 7 A$vprintf$1030 0460 GR + 7 A$vprintf$1031 0463 GR + 7 A$vprintf$1032 0464 GR + 7 A$vprintf$1033 0466 GR + 7 A$vprintf$1034 0467 GR + 7 A$vprintf$1035 0468 GR + 7 A$vprintf$1036 046A GR + 7 A$vprintf$1037 046B GR + 7 A$vprintf$1038 046C GR + 7 A$vprintf$1039 046D GR + 7 A$vprintf$1040 046F GR + 7 A$vprintf$1041 0471 GR + 7 A$vprintf$1042 0473 GR + 7 A$vprintf$1044 0475 GR + 7 A$vprintf$1045 0478 GR + 7 A$vprintf$1048 047B GR + 7 A$vprintf$1050 047E GR + 7 A$vprintf$1052 0481 GR + 7 A$vprintf$1053 0484 GR + 7 A$vprintf$1057 0487 GR + 7 A$vprintf$1060 048A GR + 7 A$vprintf$1061 048D GR + 7 A$vprintf$1063 048E GR + 7 A$vprintf$1064 048F GR + 7 A$vprintf$1066 0491 GR + 7 A$vprintf$1067 0492 GR + 7 A$vprintf$1068 0495 GR + 7 A$vprintf$1069 0496 GR + 7 A$vprintf$1070 0498 GR + 7 A$vprintf$1071 0499 GR + 7 A$vprintf$1072 049B GR + 7 A$vprintf$1073 049C GR + 7 A$vprintf$1074 049E GR + 7 A$vprintf$1075 049F GR + 7 A$vprintf$1076 04A1 GR + 7 A$vprintf$1077 04A2 GR + 7 A$vprintf$1078 04A3 GR + 7 A$vprintf$1079 04A4 GR + 7 A$vprintf$1080 04A6 GR + 7 A$vprintf$1081 04A8 GR + 7 A$vprintf$1082 04AA GR + 7 A$vprintf$1084 04AC GR + 7 A$vprintf$1087 04AE GR + 7 A$vprintf$1088 04B1 GR + 7 A$vprintf$1090 04B2 GR + 7 A$vprintf$1091 04B3 GR + 7 A$vprintf$1093 04B5 GR + 7 A$vprintf$1094 04B6 GR + 7 A$vprintf$1095 04B9 GR + 7 A$vprintf$1096 04BA GR + 7 A$vprintf$1097 04BC GR + 7 A$vprintf$1098 04BD GR + 7 A$vprintf$1099 04BF GR + 7 A$vprintf$1100 04C0 GR + 7 A$vprintf$1101 04C1 GR + 7 A$vprintf$1102 04C2 GR + 7 A$vprintf$1103 04C4 GR + 7 A$vprintf$1104 04C5 GR + 7 A$vprintf$1105 04C6 GR + 7 A$vprintf$1106 04C8 GR + 7 A$vprintf$1107 04CA GR + 7 A$vprintf$1108 04CC GR + 7 A$vprintf$1111 04CE GR + 7 A$vprintf$1114 04D1 GR + 7 A$vprintf$1116 04D4 GR + 7 A$vprintf$1120 04D7 GR + 7 A$vprintf$1123 04DA GR + 7 A$vprintf$1125 04DC GR + 7 A$vprintf$1128 04DF GR + 7 A$vprintf$1129 04E0 GR + 7 A$vprintf$1130 04E1 GR + 7 A$vprintf$1131 04E3 GR + 7 A$vprintf$1132 04E4 GR + 7 A$vprintf$1133 04E5 GR + 7 A$vprintf$1134 04E7 GR + 7 A$vprintf$1135 04E8 GR + 7 A$vprintf$1136 04E9 GR + 7 A$vprintf$1137 04EB GR + 7 A$vprintf$1138 04EC GR + 7 A$vprintf$1139 04ED GR + 7 A$vprintf$1140 04EF GR + 7 A$vprintf$1141 04F0 GR + 7 A$vprintf$1142 04F2 GR + 7 A$vprintf$1143 04F4 GR + 7 A$vprintf$1144 04F6 GR + 7 A$vprintf$1146 04F8 GR + 7 A$vprintf$1149 04FA GR + 7 A$vprintf$1152 04FC GR + 7 A$vprintf$1154 04FF GR + 7 A$vprintf$1155 0500 GR + 7 A$vprintf$1157 0501 GR + 7 A$vprintf$1159 0503 GR + 7 A$vprintf$1161 0505 GR + 7 A$vprintf$1163 0507 GR + 7 A$vprintf$1166 0509 GR + 7 A$vprintf$1168 050B GR + 7 A$vprintf$1170 050D GR + 7 A$vprintf$1173 050F GR + 7 A$vprintf$1176 0511 GR + 7 A$vprintf$1178 0513 GR + 7 A$vprintf$1181 0515 GR + 7 A$vprintf$1183 0517 GR + 7 A$vprintf$1184 0519 GR + 7 A$vprintf$1185 051B GR + 7 A$vprintf$1186 051D GR + 7 A$vprintf$1188 051F GR + 7 A$vprintf$1190 0520 GR + 7 A$vprintf$1191 0521 GR + 7 A$vprintf$1192 0524 GR + 7 A$vprintf$1193 0525 GR + 7 A$vprintf$1194 0526 GR + 7 A$vprintf$1196 0527 GR + 7 A$vprintf$1200 0529 GR + 7 A$vprintf$1202 052C GR + 7 A$vprintf$1203 052E GR + 7 A$vprintf$1204 0531 GR + 7 A$vprintf$1206 0533 GR + 7 A$vprintf$1207 0536 GR + 7 A$vprintf$1208 0538 GR + 7 A$vprintf$1209 053A GR + 7 A$vprintf$1210 053B GR + 7 A$vprintf$1211 053D GR + 7 A$vprintf$1212 053F GR + 7 A$vprintf$1214 0541 GR + 7 A$vprintf$1215 0543 GR + 7 A$vprintf$1218 0545 GR + 7 A$vprintf$1221 0546 GR + 7 A$vprintf$1223 0548 GR + 7 A$vprintf$1226 054A GR + 7 A$vprintf$1227 054D GR + 7 A$vprintf$1228 054E GR + 7 A$vprintf$1231 054F GR + 7 A$vprintf$1236 0552 GR + 7 A$vprintf$1237 0555 GR + 7 A$vprintf$1238 0557 GR + 7 A$vprintf$1242 0558 GR + 7 A$vprintf$1245 055B GR + 7 A$vprintf$1246 055C GR + 7 A$vprintf$1247 055F GR + 7 A$vprintf$1248 0560 GR + 7 A$vprintf$1250 0561 GR + 7 A$vprintf$1251 0562 GR + 7 A$vprintf$1252 0563 GR + 7 A$vprintf$1253 0564 GR + 7 A$vprintf$1254 0565 GR + 7 A$vprintf$1255 0566 GR + 7 A$vprintf$1256 0567 GR + 7 A$vprintf$1257 056A GR + 7 A$vprintf$1258 056B GR + 7 A$vprintf$1259 056C GR + 7 A$vprintf$1261 056D GR + 7 A$vprintf$1264 056F GR + 7 A$vprintf$1265 0571 GR + 7 A$vprintf$1266 0574 GR + 7 A$vprintf$1267 0577 GR + 7 A$vprintf$1269 0579 GR + 7 A$vprintf$1271 057A GR + 7 A$vprintf$1275 057C GR + 7 A$vprintf$1278 057F GR + 7 A$vprintf$1279 0582 GR + 7 A$vprintf$1281 0585 GR + 7 A$vprintf$1282 0588 GR + 7 A$vprintf$1284 0589 GR + 7 A$vprintf$1285 058A GR + 7 A$vprintf$1286 058C GR + 7 A$vprintf$1287 058F GR + 7 A$vprintf$1289 0590 GR + 7 A$vprintf$1292 0592 GR + 7 A$vprintf$1293 0595 GR + 7 A$vprintf$1294 0596 GR + 7 A$vprintf$1295 0597 GR + 7 A$vprintf$1297 059A GR + 7 A$vprintf$1301 059C GR + 7 A$vprintf$1304 059F GR + 7 A$vprintf$1305 05A2 GR + 7 A$vprintf$1307 05A5 GR + 7 A$vprintf$1308 05A8 GR + 7 A$vprintf$1310 05A9 GR + 7 A$vprintf$1311 05AA GR + 7 A$vprintf$1312 05AC GR + 7 A$vprintf$1313 05AF GR + 7 A$vprintf$1315 05B0 GR + 7 A$vprintf$1319 05B2 GR + 7 A$vprintf$1322 05B5 GR + 7 A$vprintf$1323 05B8 GR + 7 A$vprintf$1325 05BB GR + 7 A$vprintf$1326 05BE GR + 7 A$vprintf$1328 05BF GR + 7 A$vprintf$1329 05C0 GR + 7 A$vprintf$1330 05C2 GR + 7 A$vprintf$1331 05C5 GR + 7 A$vprintf$1334 05C6 GR + 7 A$vprintf$1335 05C9 GR + 7 A$vprintf$1336 05CA GR + 7 A$vprintf$1337 05CB GR + 7 A$vprintf$1338 05CE GR + 7 A$vprintf$1339 05CF GR + 7 A$vprintf$1341 05D0 GR + 7 A$vprintf$1342 05D2 GR + 7 A$vprintf$1343 05D3 GR + 7 A$vprintf$1344 05D4 GR + 7 A$vprintf$1345 05D5 GR + 7 A$vprintf$1347 05D6 GR + 7 A$vprintf$1351 05D8 GR + 7 A$vprintf$1353 05DB GR + 7 A$vprintf$1355 05DD GR + 7 A$vprintf$1357 05DF GR + 7 A$vprintf$1359 05E1 GR + 7 A$vprintf$1360 05E3 GR + 7 A$vprintf$1361 05E5 GR + 7 A$vprintf$1362 05E7 GR + 7 A$vprintf$1363 05EA GR + 7 A$vprintf$1364 05EC GR + 7 A$vprintf$1367 05EE GR + 7 A$vprintf$1370 05F0 GR + 7 A$vprintf$1371 05F2 GR + 7 A$vprintf$1372 05F3 GR + 7 A$vprintf$1373 05F4 GR + 7 A$vprintf$1374 05F6 GR + 7 A$vprintf$1378 05F9 GR + 7 A$vprintf$1380 05FB GR + 7 A$vprintf$1381 05FE GR + 7 A$vprintf$1382 0600 GR + 7 A$vprintf$1383 0601 GR + 7 A$vprintf$1384 0603 GR + 7 A$vprintf$1385 0604 GR + 7 A$vprintf$1386 0606 GR + 7 A$vprintf$1388 0608 GR + 7 A$vprintf$1389 060A GR + 7 A$vprintf$1391 060C GR + 7 A$vprintf$1393 060E GR + 7 A$vprintf$1394 0610 GR + 7 A$vprintf$1395 0613 GR + 7 A$vprintf$1396 0616 GR + 7 A$vprintf$1398 0618 GR + 7 A$vprintf$1401 061A GR + 7 A$vprintf$1402 061D GR + 7 A$vprintf$1403 0620 GR + 7 A$vprintf$1407 0623 GR + 7 A$vprintf$1409 0626 GR + 7 A$vprintf$1410 0629 GR + 7 A$vprintf$1414 062C GR + 7 A$vprintf$1422 062D GR + 7 A$vprintf$1423 062F GR + 7 A$vprintf$1424 0631 GR + 7 A$vprintf$1425 0633 GR + 7 A$vprintf$1426 0636 GR + 7 A$vprintf$1427 0638 GR + 7 A$vprintf$1428 0639 GR + 7 A$vprintf$1429 063B GR + 7 A$vprintf$1430 063C GR + 7 A$vprintf$1431 063D GR + 7 A$vprintf$1432 063F GR + 7 A$vprintf$1433 0640 GR + 7 A$vprintf$1434 0641 GR + 7 A$vprintf$1435 0644 GR + 7 A$vprintf$1436 0645 GR + 7 A$vprintf$1437 0646 GR + 7 A$vprintf$1438 0647 GR + 7 A$vprintf$1439 0648 GR + 7 A$vprintf$1440 0649 GR + 7 A$vprintf$1441 064A GR + 7 A$vprintf$1442 064B GR + 7 A$vprintf$1443 064C GR + 7 A$vprintf$1444 064F GR + 7 A$vprintf$1445 0650 GR + 7 A$vprintf$1446 0651 GR + 7 A$vprintf$1447 0654 GR + 7 A$vprintf$1448 0655 GR + 7 A$vprintf$1449 0656 GR + 7 A$vprintf$145 0000 GR + 7 A$vprintf$1450 0657 GR + 7 A$vprintf$1451 0658 GR + 7 A$vprintf$1452 0659 GR + 7 A$vprintf$1453 065A GR + 7 A$vprintf$1454 065B GR + 7 A$vprintf$1455 065C GR + 7 A$vprintf$1456 065F GR + 7 A$vprintf$1457 0660 GR + 7 A$vprintf$1459 0661 GR + 7 A$vprintf$146 0002 GR + 7 A$vprintf$1460 0664 GR + 7 A$vprintf$1461 0667 GR + 7 A$vprintf$1466 066A GR + 7 A$vprintf$148 0005 GR + 7 A$vprintf$151 0007 GR + 7 A$vprintf$154 000A GR + 7 A$vprintf$155 000D GR + 7 A$vprintf$156 000E GR + 7 A$vprintf$157 000F GR + 7 A$vprintf$158 0010 GR + 7 A$vprintf$159 0011 GR + 7 A$vprintf$160 0012 GR + 7 A$vprintf$161 0013 GR + 7 A$vprintf$162 0014 GR + 7 A$vprintf$163 0015 GR + 7 A$vprintf$164 0018 GR + 7 A$vprintf$165 001A GR + 7 A$vprintf$166 001B GR + 7 A$vprintf$168 001C GR + 7 A$vprintf$169 001D GR + 7 A$vprintf$170 001E GR + 7 A$vprintf$171 001F GR + 7 A$vprintf$172 0020 GR + 7 A$vprintf$173 0021 GR + 7 A$vprintf$174 0022 GR + 7 A$vprintf$175 0023 GR + 7 A$vprintf$176 0025 GR + 7 A$vprintf$177 0027 GR + 7 A$vprintf$178 0029 GR + 7 A$vprintf$179 002A GR + 7 A$vprintf$181 002D GR + 7 A$vprintf$184 002F GR + 7 A$vprintf$185 0031 GR + 7 A$vprintf$187 0034 GR + 7 A$vprintf$188 0037 GR + 7 A$vprintf$191 0039 GR + 7 A$vprintf$198 003A GR + 7 A$vprintf$199 003C GR + 7 A$vprintf$201 003F GR + 7 A$vprintf$202 0041 GR + 7 A$vprintf$203 0042 GR + 7 A$vprintf$204 0044 GR + 7 A$vprintf$205 0045 GR + 7 A$vprintf$206 0046 GR + 7 A$vprintf$208 0047 GR + 7 A$vprintf$209 0048 GR + 7 A$vprintf$211 004B GR + 7 A$vprintf$212 004C GR + 7 A$vprintf$214 004D GR + 7 A$vprintf$216 004E GR + 7 A$vprintf$218 0050 GR + 7 A$vprintf$219 0052 GR + 7 A$vprintf$220 0053 GR + 7 A$vprintf$222 0054 GR + 7 A$vprintf$225 0056 GR + 7 A$vprintf$227 0059 GR + 7 A$vprintf$228 005B GR + 7 A$vprintf$229 005C GR + 7 A$vprintf$231 005D GR + 7 A$vprintf$233 005F GR + 7 A$vprintf$234 0061 GR + 7 A$vprintf$235 0062 GR + 7 A$vprintf$237 0063 GR + 7 A$vprintf$239 0065 GR + 7 A$vprintf$240 0067 GR + 7 A$vprintf$242 006A GR + 7 A$vprintf$243 006D GR + 7 A$vprintf$246 006F GR + 7 A$vprintf$253 0070 GR + 7 A$vprintf$254 0072 GR + 7 A$vprintf$256 0075 GR + 7 A$vprintf$258 0077 GR + 7 A$vprintf$259 0078 GR + 7 A$vprintf$260 0079 GR + 7 A$vprintf$261 007B GR + 7 A$vprintf$262 007C GR + 7 A$vprintf$263 007E GR + 7 A$vprintf$264 0080 GR + 7 A$vprintf$265 0083 GR + 7 A$vprintf$267 0085 GR + 7 A$vprintf$268 0088 GR + 7 A$vprintf$269 008A GR + 7 A$vprintf$271 008D GR + 7 A$vprintf$272 0090 GR + 7 A$vprintf$275 0092 GR + 7 A$vprintf$283 0093 GR + 7 A$vprintf$285 0095 GR + 7 A$vprintf$287 0098 GR + 7 A$vprintf$290 009A GR + 7 A$vprintf$291 009B GR + 7 A$vprintf$292 009D GR + 7 A$vprintf$293 009E GR + 7 A$vprintf$294 00A0 GR + 7 A$vprintf$295 00A2 GR + 7 A$vprintf$296 00A3 GR + 7 A$vprintf$297 00A5 GR + 7 A$vprintf$298 00A7 GR + 7 A$vprintf$299 00A8 GR + 7 A$vprintf$300 00AA GR + 7 A$vprintf$301 00AC GR + 7 A$vprintf$302 00AD GR + 7 A$vprintf$303 00AF GR + 7 A$vprintf$304 00B1 GR + 7 A$vprintf$305 00B2 GR + 7 A$vprintf$307 00B4 GR + 7 A$vprintf$308 00B7 GR + 7 A$vprintf$309 00B8 GR + 7 A$vprintf$310 00B9 GR + 7 A$vprintf$311 00BA GR + 7 A$vprintf$312 00BC GR + 7 A$vprintf$315 00BD GR + 7 A$vprintf$318 00BF GR + 7 A$vprintf$319 00C0 GR + 7 A$vprintf$320 00C2 GR + 7 A$vprintf$321 00C3 GR + 7 A$vprintf$323 00C5 GR + 7 A$vprintf$324 00C7 GR + 7 A$vprintf$325 00C9 GR + 7 A$vprintf$328 00CB GR + 7 A$vprintf$330 00CC GR + 7 A$vprintf$334 00CE GR + 7 A$vprintf$342 00CF GR + 7 A$vprintf$343 00D1 GR + 7 A$vprintf$344 00D3 GR + 7 A$vprintf$345 00D5 GR + 7 A$vprintf$346 00D8 GR + 7 A$vprintf$347 00DA GR + 7 A$vprintf$348 00DB GR + 7 A$vprintf$349 00DD GR + 7 A$vprintf$350 00DE GR + 7 A$vprintf$351 00DF GR + 7 A$vprintf$352 00E1 GR + 7 A$vprintf$353 00E2 GR + 7 A$vprintf$355 00E3 GR + 7 A$vprintf$356 00E6 GR + 7 A$vprintf$357 00E7 GR + 7 A$vprintf$358 00E8 GR + 7 A$vprintf$359 00E9 GR + 7 A$vprintf$360 00EA GR + 7 A$vprintf$361 00EB GR + 7 A$vprintf$362 00EC GR + 7 A$vprintf$363 00ED GR + 7 A$vprintf$364 00EE GR + 7 A$vprintf$365 00F1 GR + 7 A$vprintf$366 00F2 GR + 7 A$vprintf$367 00F3 GR + 7 A$vprintf$368 00F4 GR + 7 A$vprintf$369 00F5 GR + 7 A$vprintf$370 00F6 GR + 7 A$vprintf$371 00F7 GR + 7 A$vprintf$372 00F8 GR + 7 A$vprintf$374 00F9 GR + 7 A$vprintf$375 00FA GR + 7 A$vprintf$376 00FB GR + 7 A$vprintf$378 00FC GR + 7 A$vprintf$381 00FE GR + 7 A$vprintf$383 0100 GR + 7 A$vprintf$386 0102 GR + 7 A$vprintf$390 0104 GR + 7 A$vprintf$391 0107 GR + 7 A$vprintf$392 0108 GR + 7 A$vprintf$393 0109 GR + 7 A$vprintf$394 010A GR + 7 A$vprintf$395 010B GR + 7 A$vprintf$396 010C GR + 7 A$vprintf$397 010D GR + 7 A$vprintf$398 010E GR + 7 A$vprintf$399 010F GR + 7 A$vprintf$400 0111 GR + 7 A$vprintf$401 0112 GR + 7 A$vprintf$403 0113 GR + 7 A$vprintf$404 0114 GR + 7 A$vprintf$405 0115 GR + 7 A$vprintf$406 0116 GR + 7 A$vprintf$407 0118 GR + 7 A$vprintf$408 011B GR + 7 A$vprintf$409 011C GR + 7 A$vprintf$410 011D GR + 7 A$vprintf$411 011E GR + 7 A$vprintf$412 011F GR + 7 A$vprintf$413 0120 GR + 7 A$vprintf$414 0121 GR + 7 A$vprintf$415 0122 GR + 7 A$vprintf$416 0123 GR + 7 A$vprintf$417 0125 GR + 7 A$vprintf$418 0127 GR + 7 A$vprintf$419 0129 GR + 7 A$vprintf$421 012C GR + 7 A$vprintf$422 012E GR + 7 A$vprintf$423 0130 GR + 7 A$vprintf$426 0133 GR + 7 A$vprintf$427 0135 GR + 7 A$vprintf$428 0138 GR + 7 A$vprintf$430 013A GR + 7 A$vprintf$433 013D GR + 7 A$vprintf$435 013F GR + 7 A$vprintf$437 0141 GR + 7 A$vprintf$439 0143 GR + 7 A$vprintf$441 0145 GR + 7 A$vprintf$443 0147 GR + 7 A$vprintf$445 014A GR + 7 A$vprintf$446 014B GR + 7 A$vprintf$448 014C GR + 7 A$vprintf$450 014E GR + 7 A$vprintf$452 0150 GR + 7 A$vprintf$454 0153 GR + 7 A$vprintf$455 0154 GR + 7 A$vprintf$458 0155 GR + 7 A$vprintf$459 0157 GR + 7 A$vprintf$460 0159 GR + 7 A$vprintf$461 015B GR + 7 A$vprintf$462 015C GR + 7 A$vprintf$463 015F GR + 7 A$vprintf$465 0160 GR + 7 A$vprintf$466 0163 GR + 7 A$vprintf$467 0164 GR + 7 A$vprintf$468 0165 GR + 7 A$vprintf$469 0166 GR + 7 A$vprintf$470 0167 GR + 7 A$vprintf$471 0168 GR + 7 A$vprintf$472 0169 GR + 7 A$vprintf$473 016A GR + 7 A$vprintf$474 016B GR + 7 A$vprintf$475 016E GR + 7 A$vprintf$476 0171 GR + 7 A$vprintf$477 0174 GR + 7 A$vprintf$479 0177 GR + 7 A$vprintf$480 0178 GR + 7 A$vprintf$481 017B GR + 7 A$vprintf$483 017C GR + 7 A$vprintf$484 017E GR + 7 A$vprintf$485 0180 GR + 7 A$vprintf$486 0182 GR + 7 A$vprintf$487 0184 GR + 7 A$vprintf$488 0186 GR + 7 A$vprintf$489 0189 GR + 7 A$vprintf$490 018C GR + 7 A$vprintf$491 018E GR + 7 A$vprintf$492 0190 GR + 7 A$vprintf$493 0192 GR + 7 A$vprintf$494 0194 GR + 7 A$vprintf$496 0196 GR + 7 A$vprintf$499 0198 GR + 7 A$vprintf$500 019B GR + 7 A$vprintf$501 019C GR + 7 A$vprintf$502 019D GR + 7 A$vprintf$503 01A0 GR + 7 A$vprintf$504 01A1 GR + 7 A$vprintf$505 01A2 GR + 7 A$vprintf$506 01A4 GR + 7 A$vprintf$507 01A5 GR + 7 A$vprintf$509 01A7 GR + 7 A$vprintf$510 01A9 GR + 7 A$vprintf$512 01AB GR + 7 A$vprintf$513 01AC GR + 7 A$vprintf$514 01AF GR + 7 A$vprintf$516 01B0 GR + 7 A$vprintf$517 01B3 GR + 7 A$vprintf$518 01B5 GR + 7 A$vprintf$520 01B7 GR + 7 A$vprintf$523 01B8 GR + 7 A$vprintf$524 01BA GR + 7 A$vprintf$525 01BC GR + 7 A$vprintf$528 01BF GR + 7 A$vprintf$530 01C1 GR + 7 A$vprintf$533 01C4 GR + 7 A$vprintf$534 01C6 GR + 7 A$vprintf$535 01C8 GR + 7 A$vprintf$536 01CA GR + 7 A$vprintf$537 01CC GR + 7 A$vprintf$538 01CE GR + 7 A$vprintf$539 01D0 GR + 7 A$vprintf$540 01D2 GR + 7 A$vprintf$541 01D5 GR + 7 A$vprintf$542 01D8 GR + 7 A$vprintf$543 01DA GR + 7 A$vprintf$544 01DC GR + 7 A$vprintf$545 01DE GR + 7 A$vprintf$546 01E0 GR + 7 A$vprintf$547 01E2 GR + 7 A$vprintf$548 01E4 GR + 7 A$vprintf$549 01E6 GR + 7 A$vprintf$551 01E9 GR + 7 A$vprintf$552 01EA GR + 7 A$vprintf$555 01EC GR + 7 A$vprintf$558 01EF GR + 7 A$vprintf$559 01F1 GR + 7 A$vprintf$560 01F2 GR + 7 A$vprintf$561 01F5 GR + 7 A$vprintf$564 01F6 GR + 7 A$vprintf$565 01F9 GR + 7 A$vprintf$566 01FA GR + 7 A$vprintf$567 01FB GR + 7 A$vprintf$568 01FE GR + 7 A$vprintf$569 0200 GR + 7 A$vprintf$571 0202 GR + 7 A$vprintf$574 0203 GR + 7 A$vprintf$575 0205 GR + 7 A$vprintf$576 0207 GR + 7 A$vprintf$578 020A GR + 7 A$vprintf$579 020D GR + 7 A$vprintf$580 020F GR + 7 A$vprintf$582 0211 GR + 7 A$vprintf$585 0212 GR + 7 A$vprintf$586 0214 GR + 7 A$vprintf$587 0216 GR + 7 A$vprintf$589 0219 GR + 7 A$vprintf$590 021C GR + 7 A$vprintf$591 021E GR + 7 A$vprintf$593 0220 GR + 7 A$vprintf$596 0221 GR + 7 A$vprintf$599 0223 GR + 7 A$vprintf$601 0225 GR + 7 A$vprintf$602 0228 GR + 7 A$vprintf$603 022A GR + 7 A$vprintf$605 022C GR + 7 A$vprintf$608 022D GR + 7 A$vprintf$611 022F GR + 7 A$vprintf$613 0231 GR + 7 A$vprintf$614 0234 GR + 7 A$vprintf$615 0236 GR + 7 A$vprintf$617 0238 GR + 7 A$vprintf$620 0239 GR + 7 A$vprintf$622 023B GR + 7 A$vprintf$624 023D GR + 7 A$vprintf$625 0240 GR + 7 A$vprintf$626 0242 GR + 7 A$vprintf$628 0244 GR + 7 A$vprintf$631 0245 GR + 7 A$vprintf$632 0247 GR + 7 A$vprintf$633 0249 GR + 7 A$vprintf$635 024C GR + 7 A$vprintf$636 024F GR + 7 A$vprintf$637 0251 GR + 7 A$vprintf$639 0253 GR + 7 A$vprintf$642 0254 GR + 7 A$vprintf$643 0256 GR + 7 A$vprintf$644 0258 GR + 7 A$vprintf$646 025B GR + 7 A$vprintf$647 025E GR + 7 A$vprintf$648 0260 GR + 7 A$vprintf$650 0262 GR + 7 A$vprintf$653 0263 GR + 7 A$vprintf$655 0264 GR + 7 A$vprintf$657 0266 GR + 7 A$vprintf$658 0269 GR + 7 A$vprintf$660 026C GR + 7 A$vprintf$661 026F GR + 7 A$vprintf$663 0272 GR + 7 A$vprintf$665 0275 GR + 7 A$vprintf$667 0277 GR + 7 A$vprintf$668 027A GR + 7 A$vprintf$670 027D GR + 7 A$vprintf$671 0280 GR + 7 A$vprintf$673 0283 GR + 7 A$vprintf$676 0286 GR + 7 A$vprintf$678 0288 GR + 7 A$vprintf$681 028B GR + 7 A$vprintf$683 028D GR + 7 A$vprintf$686 0290 GR + 7 A$vprintf$688 0292 GR + 7 A$vprintf$691 0295 GR + 7 A$vprintf$693 0297 GR + 7 A$vprintf$696 029A GR + 7 A$vprintf$698 029C GR + 7 A$vprintf$701 029F GR + 7 A$vprintf$702 02A2 GR + 7 A$vprintf$704 02A3 GR + 7 A$vprintf$705 02A4 GR + 7 A$vprintf$707 02A6 GR + 7 A$vprintf$708 02A7 GR + 7 A$vprintf$709 02AA GR + 7 A$vprintf$710 02AB GR + 7 A$vprintf$711 02AD GR + 7 A$vprintf$712 02AF GR + 7 A$vprintf$713 02B1 GR + 7 A$vprintf$714 02B4 GR + 7 A$vprintf$716 02B6 GR + 7 A$vprintf$719 02B9 GR + 7 A$vprintf$720 02BC GR + 7 A$vprintf$722 02BD GR + 7 A$vprintf$723 02BE GR + 7 A$vprintf$725 02C0 GR + 7 A$vprintf$726 02C1 GR + 7 A$vprintf$727 02C4 GR + 7 A$vprintf$728 02C5 GR + 7 A$vprintf$729 02C7 GR + 7 A$vprintf$730 02C8 GR + 7 A$vprintf$731 02CA GR + 7 A$vprintf$732 02CB GR + 7 A$vprintf$733 02CD GR + 7 A$vprintf$734 02CE GR + 7 A$vprintf$735 02CF GR + 7 A$vprintf$736 02D1 GR + 7 A$vprintf$737 02D3 GR + 7 A$vprintf$739 02D5 GR + 7 A$vprintf$740 02D7 GR + 7 A$vprintf$741 02D9 GR + 7 A$vprintf$742 02DB GR + 7 A$vprintf$743 02DD GR + 7 A$vprintf$744 02E0 GR + 7 A$vprintf$745 02E2 GR + 7 A$vprintf$746 02E4 GR + 7 A$vprintf$747 02E6 GR + 7 A$vprintf$750 02E8 GR + 7 A$vprintf$752 02EB GR + 7 A$vprintf$753 02EE GR + 7 A$vprintf$754 02EF GR + 7 A$vprintf$755 02F0 GR + 7 A$vprintf$756 02F1 GR + 7 A$vprintf$757 02F3 GR + 7 A$vprintf$759 02F4 GR + 7 A$vprintf$762 02F6 GR + 7 A$vprintf$763 02F7 GR + 7 A$vprintf$764 02F8 GR + 7 A$vprintf$765 02FA GR + 7 A$vprintf$768 02FB GR + 7 A$vprintf$769 02FD GR + 7 A$vprintf$770 02FE GR + 7 A$vprintf$771 0301 GR + 7 A$vprintf$772 0302 GR + 7 A$vprintf$773 0303 GR + 7 A$vprintf$774 0306 GR + 7 A$vprintf$775 0308 GR + 7 A$vprintf$777 030A GR + 7 A$vprintf$780 030B GR + 7 A$vprintf$782 030C GR + 7 A$vprintf$785 030E GR + 7 A$vprintf$786 0310 GR + 7 A$vprintf$787 0312 GR + 7 A$vprintf$788 0314 GR + 7 A$vprintf$789 0316 GR + 7 A$vprintf$790 0319 GR + 7 A$vprintf$791 031C GR + 7 A$vprintf$792 031E GR + 7 A$vprintf$793 0320 GR + 7 A$vprintf$794 0322 GR + 7 A$vprintf$797 0324 GR + 7 A$vprintf$799 0326 GR + 7 A$vprintf$800 0328 GR + 7 A$vprintf$801 032A GR + 7 A$vprintf$802 032C GR + 7 A$vprintf$803 032E GR + 7 A$vprintf$804 0330 GR + 7 A$vprintf$805 0332 GR + 7 A$vprintf$807 0335 GR + 7 A$vprintf$809 0337 GR + 7 A$vprintf$812 0339 GR + 7 A$vprintf$813 033B GR + 7 A$vprintf$814 033C GR + 7 A$vprintf$816 033D GR + 7 A$vprintf$817 033E GR + 7 A$vprintf$818 033F GR + 7 A$vprintf$819 0340 GR + 7 A$vprintf$820 0342 GR + 7 A$vprintf$821 0344 GR + 7 A$vprintf$822 0346 GR + 7 A$vprintf$823 0348 GR + 7 A$vprintf$824 034A GR + 7 A$vprintf$825 034C GR + 7 A$vprintf$826 034E GR + 7 A$vprintf$827 0351 GR + 7 A$vprintf$828 0352 GR + 7 A$vprintf$829 0354 GR + 7 A$vprintf$830 0356 GR + 7 A$vprintf$831 0358 GR + 7 A$vprintf$832 035A GR + 7 A$vprintf$833 035C GR + 7 A$vprintf$834 035E GR + 7 A$vprintf$835 0360 GR + 7 A$vprintf$836 0362 GR + 7 A$vprintf$837 0364 GR + 7 A$vprintf$838 0367 GR + 7 A$vprintf$839 0369 GR + 7 A$vprintf$840 036B GR + 7 A$vprintf$841 036D GR + 7 A$vprintf$842 036F GR + 7 A$vprintf$843 0371 GR + 7 A$vprintf$844 0373 GR + 7 A$vprintf$845 0375 GR + 7 A$vprintf$847 0377 GR + 7 A$vprintf$850 0379 GR + 7 A$vprintf$851 037C GR + 7 A$vprintf$853 037F GR + 7 A$vprintf$854 0382 GR + 7 A$vprintf$855 0383 GR + 7 A$vprintf$856 0384 GR + 7 A$vprintf$857 0385 GR + 7 A$vprintf$858 0387 GR + 7 A$vprintf$859 0388 GR + 7 A$vprintf$860 038A GR + 7 A$vprintf$863 038D GR + 7 A$vprintf$864 038E GR + 7 A$vprintf$865 038F GR + 7 A$vprintf$866 0391 GR + 7 A$vprintf$869 0392 GR + 7 A$vprintf$870 0394 GR + 7 A$vprintf$871 0395 GR + 7 A$vprintf$872 0398 GR + 7 A$vprintf$873 0399 GR + 7 A$vprintf$874 039A GR + 7 A$vprintf$875 039D GR + 7 A$vprintf$876 039F GR + 7 A$vprintf$878 03A1 GR + 7 A$vprintf$881 03A2 GR + 7 A$vprintf$882 03A3 GR + 7 A$vprintf$883 03A5 GR + 7 A$vprintf$886 03A8 GR + 7 A$vprintf$887 03AA GR + 7 A$vprintf$888 03AC GR + 7 A$vprintf$889 03AE GR + 7 A$vprintf$890 03B0 GR + 7 A$vprintf$891 03B3 GR + 7 A$vprintf$892 03B6 GR + 7 A$vprintf$893 03B8 GR + 7 A$vprintf$894 03BA GR + 7 A$vprintf$895 03BC GR + 7 A$vprintf$898 03BE GR + 7 A$vprintf$900 03C0 GR + 7 A$vprintf$901 03C3 GR + 7 A$vprintf$903 03C4 GR + 7 A$vprintf$904 03C5 GR + 7 A$vprintf$906 03C7 GR + 7 A$vprintf$907 03C8 GR + 7 A$vprintf$908 03CB GR + 7 A$vprintf$909 03CC GR + 7 A$vprintf$910 03CE GR + 7 A$vprintf$911 03CF GR + 7 A$vprintf$912 03D1 GR + 7 A$vprintf$913 03D2 GR + 7 A$vprintf$914 03D4 GR + 7 A$vprintf$915 03D5 GR + 7 A$vprintf$916 03D6 GR + 7 A$vprintf$917 03D8 GR + 7 A$vprintf$918 03DA GR + 7 A$vprintf$920 03DC GR + 7 A$vprintf$921 03DD GR + 7 A$vprintf$922 03DF GR + 7 A$vprintf$924 03E1 GR + 7 A$vprintf$926 03E3 GR + 7 A$vprintf$928 03E5 GR + 7 A$vprintf$930 03E7 GR + 7 A$vprintf$932 03E9 GR + 7 A$vprintf$935 03EA GR + 7 A$vprintf$936 03ED GR + 7 A$vprintf$937 03EE GR + 7 A$vprintf$938 03EF GR + 7 A$vprintf$939 03F1 GR + 7 A$vprintf$940 03F3 GR + 7 A$vprintf$941 03F6 GR + 7 A$vprintf$943 03F8 GR + 7 A$vprintf$944 03FA GR + 7 A$vprintf$945 03FD GR + 7 A$vprintf$946 0400 GR + 7 A$vprintf$948 0402 GR + 7 A$vprintf$950 0404 GR + 7 A$vprintf$952 0406 GR + 7 A$vprintf$953 0408 GR + 7 A$vprintf$955 040B GR + 7 A$vprintf$958 040D GR + 7 A$vprintf$959 040F GR + 7 A$vprintf$960 0412 GR + 7 A$vprintf$961 0415 GR + 7 A$vprintf$964 0417 GR + 7 A$vprintf$965 0419 GR + 7 A$vprintf$966 041C GR + 7 A$vprintf$967 041F GR + 7 A$vprintf$971 0421 GR + 7 A$vprintf$973 0423 GR + 7 A$vprintf$975 0425 GR + 7 A$vprintf$976 0428 GR + 7 A$vprintf$977 042A GR + 7 A$vprintf$981 042B GR + 7 A$vprintf$983 042D GR + 7 A$vprintf$984 0430 GR + 7 A$vprintf$985 0432 GR + 7 A$vprintf$989 0433 GR + 7 A$vprintf$991 0435 GR + 7 A$vprintf$992 0438 GR + 7 A$vprintf$993 043A GR + 7 A$vprintf$997 043B GR + 7 A$vprintf$999 043D GR + AC 00D6 + ACC 00E0 + ACC.0 00E0 + ACC.1 00E1 + ACC.2 00E2 + ACC.3 00E3 + ACC.4 00E4 + ACC.5 00E5 + ACC.6 00E6 + ACC.7 00E7 + B 00F0 + B.0 00F0 + B.1 00F1 + B.2 00F2 + B.3 00F3 + B.4 00F4 + B.5 00F5 + B.6 00F6 + B.7 00F7 + 7 C$vprintf.c$123$1$1 = 00CE GR + 7 C$vprintf.c$414$1$1 = 062C GR + 7 C$vprintf.c$421$1$1 = 066A GR + 7 C$vprintf.c$73$1$1 = 0039 GR + 7 C$vprintf.c$80$1$1 = 006F GR + 7 C$vprintf.c$88$1$1 = 0092 GR + CPRL2 00C8 + CT2 00C9 + CY 00D7 + DPH 0083 + DPL 0082 + EA 00AF + ES 00AC + ET0 00A9 + ET1 00AB + ET2 00AD + EX0 00A8 + EX1 00AA + EXEN2 00CB + EXF2 00CE + F0 00D5 + 7 Fvprintf$calculate_digit$0$0 = 0093 GR + 7 Fvprintf$memory_id$0$0 = 066B GR + 7 Fvprintf$output_2digits$0$0 = 0070 GR + 7 Fvprintf$output_char$0$0 = 0000 GR + 7 Fvprintf$output_digit$0$0 = 003A GR + 4 G$lower_case$0$0 = 0001 GR + 4 G$lsd$0$0 = 0002 GR + 5 G$output_ptr$0$0 = 0000 GR + 4 G$output_to_string$0$0 = 0000 GR + 5 G$radix$0$0 = 0003 GR + 1 G$value$0$0 = 0000 GR + 7 G$vprintf$0$0 = 062D GR + 7 G$vsprintf$0$0 = 00CF GR + IE 00A8 + IE.0 00A8 + IE.1 00A9 + IE.2 00AA + IE.3 00AB + IE.4 00AC + IE.5 00AD + IE.7 00AF + IE0 0089 + IE1 008B + INT0 00B2 + INT1 00B3 + IP 00B8 + IP.0 00B8 + IP.1 00B9 + IP.2 00BA + IP.3 00BB + IP.4 00BC + IP.5 00BD + IT0 0088 + IT1 008A + OV 00D2 + P 00D0 + P0 0080 + P0.0 0080 + P0.1 0081 + P0.2 0082 + P0.3 0083 + P0.4 0084 + P0.5 0085 + P0.6 0086 + P0.7 0087 + P1 0090 + P1.0 0090 + P1.1 0091 + P1.2 0092 + P1.3 0093 + P1.4 0094 + P1.5 0095 + P1.6 0096 + P1.7 0097 + P2 00A0 + P2.0 00A0 + P2.1 00A1 + P2.2 00A2 + P2.3 00A3 + P2.4 00A4 + P2.5 00A5 + P2.6 00A6 + P2.7 00A7 + P3 00B0 + P3.0 00B0 + P3.1 00B1 + P3.2 00B2 + P3.3 00B3 + P3.4 00B4 + P3.5 00B5 + P3.6 00B6 + P3.7 00B7 + PCON 0087 + PS 00BC + PSW 00D0 + PSW.0 00D0 + PSW.1 00D1 + PSW.2 00D2 + PSW.3 00D3 + PSW.4 00D4 + PSW.5 00D5 + PSW.6 00D6 + PSW.7 00D7 + PT0 00B9 + PT1 00BB + PT2 00BD + PX0 00B8 + PX1 00BA + RB8 009A + RCAP2H 00CB + RCAP2L 00CA + RCLK 00CD + REN 009C + RI 0098 + RS0 00D3 + RS1 00D4 + RXD 00B0 + SBUF 0099 + SCON 0098 + SCON.0 0098 + SCON.1 0099 + SCON.2 009A + SCON.3 009B + SCON.4 009C + SCON.5 009D + SCON.6 009E + SCON.7 009F + SM0 009F + SM1 009E + SM2 009D + SP 0081 + T2CON 00C8 + T2CON.0 00C8 + T2CON.1 00C9 + T2CON.2 00CA + T2CON.3 00CB + T2CON.4 00CC + T2CON.5 00CD + T2CON.6 00CE + T2CON.7 00CF + TB8 009B + TCLK 00CC + TCON 0088 + TCON.0 0088 + TCON.1 0089 + TCON.2 008A + TCON.3 008B + TCON.4 008C + TCON.5 008D + TCON.6 008E + TCON.7 008F + TF0 008D + TF1 008F + TF2 00CF + TH0 008C + TH1 008D + TH2 00CD + TI 0099 + TL0 008A + TL1 008B + TL2 00CC + TMOD 0089 + TR0 008C + TR1 008E + TR2 00CA + TXD 00B1 + 7 XFvprintf$calculate_digit$0$0 = 00CE GR + 7 XFvprintf$output_2digits$0$0 = 0092 GR + 7 XFvprintf$output_char$0$0 = 0039 GR + 7 XFvprintf$output_digit$0$0 = 006F GR + 7 XG$vprintf$0$0 = 066A GR + 7 XG$vsprintf$0$0 = 062C GR + __gptrget **** GX + __gptrput **** GX + _bp **** GX + 7 _calculate_digit 0093 R + _isdigit **** GX + _islower **** GX + 4 _lower_case 0001 GR + 4 _lsd 0002 GR + 7 _memory_id 066B R + 7 _output_2digits 0070 R + 7 _output_char 0000 R + 7 _output_digit 003A R + 5 _output_ptr 0000 GR + 4 _output_to_string 0000 GR + _putchar **** GX + 5 _radix 0003 GR + _strlen **** GX + 1 _value 0000 GR + 7 _vprintf 062D GR + 5 _vprintf_PARM_2 000E GR + 5 _vprintf_format_1_1 000F R + 7 _vsprintf 00CF GR + 5 _vsprintf_PARM_2 0004 GR + 5 _vsprintf_PARM_3 0007 GR + 5 _vsprintf_buf_1_1 0008 R + 5 _vsprintf_c_1_1 000D R + 4 _vsprintf_char_argument_1_1 0008 R + 4 _vsprintf_left_justify_1_1 0003 R + 5 _vsprintf_length_1_1 000C R + 4 _vsprintf_long_argument_1_1 0009 R + 4 _vsprintf_prefix_sign_1_1 0005 R + 4 _vsprintf_prefix_space_1_1 0006 R + 4 _vsprintf_signed_argument_1_1 0007 R + 1 _vsprintf_sloc0_1_0 0005 R + 1 _vsprintf_sloc10_1_0 0011 R + 1 _vsprintf_sloc11_1_0 0012 R + 1 _vsprintf_sloc12_1_0 0013 R + 1 _vsprintf_sloc13_1_0 0014 R + 1 _vsprintf_sloc1_1_0 0006 R + 1 _vsprintf_sloc2_1_0 0007 R + 1 _vsprintf_sloc3_1_0 000A R + 1 _vsprintf_sloc4_1_0 000B R + 1 _vsprintf_sloc5_1_0 000C R + 1 _vsprintf_sloc6_1_0 000D R + 1 _vsprintf_sloc7_1_0 000E R + 1 _vsprintf_sloc8_1_0 000F R + 1 _vsprintf_sloc9_1_0 0010 R + 5 _vsprintf_width_1_1 000B R + 4 _vsprintf_zero_padding_1_1 0004 R + a 00D6 + ac 00D6 + acc 00E0 + acc.0 00E0 + acc.1 00E1 + acc.2 00E2 + acc.3 00E3 + acc.4 00E4 + acc.5 00E5 + acc.6 00E6 + acc.7 00E7 + ar0 = 0000 + ar1 = 0001 + ar2 = 0002 + ar3 = 0003 + ar4 = 0004 + ar5 = 0005 + ar6 = 0006 + ar7 = 0007 + b 00F0 + b.0 00F0 + b.1 00F1 + b.2 00F2 + b.3 00F3 + b.4 00F4 + b.5 00F5 + b.6 00F6 + b.7 00F7 + cprl2 00C8 + ct2 00C9 + cy 00D7 + dph 0083 + dpl 0082 + ea 00AF + es 00AC + et0 00A9 + et1 00AB + et2 00AD + ex0 00A8 + ex1 00AA + exen2 00CB + exf2 00CE + f0 00D5 + ie 00A8 + ie.0 00A8 + ie.1 00A9 + ie.2 00AA + ie.3 00AB + ie.4 00AC + ie.5 00AD + ie.7 00AF + ie0 0089 + ie1 008B + int0 00B2 + int1 00B3 + ip 00B8 + ip.0 00B8 + ip.1 00B9 + ip.2 00BA + ip.3 00BB + ip.4 00BC + ip.5 00BD + it0 0088 + it1 008A + ov 00D2 + p 00D0 + p0 0080 + p0.0 0080 + p0.1 0081 + p0.2 0082 + p0.3 0083 + p0.4 0084 + p0.5 0085 + p0.6 0086 + p0.7 0087 + p1 0090 + p1.0 0090 + p1.1 0091 + p1.2 0092 + p1.3 0093 + p1.4 0094 + p1.5 0095 + p1.6 0096 + p1.7 0097 + p2 00A0 + p2.0 00A0 + p2.1 00A1 + p2.2 00A2 + p2.3 00A3 + p2.4 00A4 + p2.5 00A5 + p2.6 00A6 + p2.7 00A7 + p3 00B0 + p3.0 00B0 + p3.1 00B1 + p3.2 00B2 + p3.3 00B3 + p3.4 00B4 + p3.5 00B5 + p3.6 00B6 + p3.7 00B7 + pcon 0087 + ps 00BC + psw 00D0 + psw.0 00D0 + psw.1 00D1 + psw.2 00D2 + psw.3 00D3 + psw.4 00D4 + psw.5 00D5 + psw.6 00D6 + psw.7 00D7 + pt0 00B9 + pt1 00BB + pt2 00BD + px0 00B8 + px1 00BA + rb8 009A + rcap2h 00CB + rcap2l 00CA + rclk 00CD + ren 009C + ri 0098 + rs0 00D3 + rs1 00D4 + rxd 00B0 + sbuf 0099 + scon 0098 + scon.0 0098 + scon.1 0099 + scon.2 009A + scon.3 009B + scon.4 009C + scon.5 009D + scon.6 009E + scon.7 009F + sm0 009F + sm1 009E + sm2 009D + sp 0081 + t2con 00C8 + t2con.0 00C8 + t2con.1 00C9 + t2con.2 00CA + t2con.3 00CB + t2con.4 00CC + t2con.5 00CD + t2con.6 00CE + t2con.7 00CF + tb8 009B + tclk 00CC + tcon 0088 + tcon.0 0088 + tcon.1 0089 + tcon.2 008A + tcon.3 008B + tcon.4 008C + tcon.5 008D + tcon.6 008E + tcon.7 008F + tf0 008D + tf1 008F + tf2 00CF + th0 008C + th1 008D + th2 00CD + ti 0099 + tl0 008A + tl1 008B + tl2 00CC + tmod 0089 + tr0 008C + tr1 008E + tr2 00CA + txd 00B1 + + ASxxxx Assembler V01.70 + NoICE + SDCC mods Feb-1999 (Intel 8051), page 2. + +Area Table + + 0 _CODE size 0 flags 0 + 1 DSEG size 15 flags 0 + 2 OSEG size 0 flags 4 + 3 ISEG size 0 flags 0 + 4 BSEG size A flags 80 + 5 XSEG size 12 flags 40 + 6 GSINIT size 0 flags 20 + 7 CSEG size 671 flags 20 diff --git a/device/lib/z80/README b/device/lib/z80/README new file mode 100644 index 00000000..a34ea453 --- /dev/null +++ b/device/lib/z80/README @@ -0,0 +1,4 @@ +sdcc/device/lib/z80 +------------------- + +Z80 specific routines. diff --git a/doc/SDCCBugsFixed.html b/doc/SDCCBugsFixed.html new file mode 100644 index 00000000..33a1573e --- /dev/null +++ b/doc/SDCCBugsFixed.html @@ -0,0 +1,1554 @@ + + + + + + + +Enhancements and Bug fixes. +
  +
+
+
Release 2.1.9G +
    +
  • +Applied several patches provided by  "Anton +Voloshin" <vav@isv.ru> mainly to SDCCglue.c, SDCCmain.c & sdcdb/cmd.c
  • + +
  • +First parameter of struct member function pointer +not passed in register.
  • + +
  • +Parameter passing problem if first parameter of a +routine passed as second parm of another routine, vice versa. This bug +would caused some of the library routines to fail.
  • + +
  • +Address of structure member passed as parameter caused +problems.
  • + +
  • +#pragma callee-saves did not always work.
  • + +
  • +Furthur bug fix for live range computation within +loops.
  • + +
  • +Register 'b' could be clobbered when there was '*', +'/' or '%' operation for generic pointers.
  • + +
  • +initialisation for pointers to structure elements +in code space generated errors.
  • + +
  • +Debugger info lost when multiple files were linked +.
  • + +
  • +Fixed buf in printf_large.c(vsprintf called with wrong parms) +.
  • + +
  • +"extern" variables when spilt did not allocate spill locations +. i.e. "sloc" undefined error. +.
  • + +
  • +Added optimization for PUSH. "xdata" variables do not need to be +assigned to temps to be pushed. +.
  • + +
  • +Fixed aliasing problem where some pointer sub expressions +were carried across basic blocks .
  • + +
  • +Upgraded to version 0.2.36 of ucsim .
  • + +
  • +Added new optimization within basic blocks pointer +set values will replace get pointer values within a basic block. (across +basic blocks is a little bit complex will have to think about it some more).
  • + +
    which in plain english means. +
            a->b += 10; +
            putchar(a->b); +
    will come.. +
            a->b += 10; +
             +putchar(10);
+
+ +
+
+
Release 2.1.9F +
    +
  • +pointers passed to functions as parameters are removed +from cse list.
  • + +
  • +live range computation for variables inside loops +improved.
  • + +
  • +upgraded ucsim to latest release 0.2.31
  • + +
  • +loop invariant bug fix for (global variables assigned +constant values inside a loop)
  • + +
  • +Applied patch provided by  "Anton Voloshin" +<vav@isv.ru> rel files put into separate lines in the .lnk file.
  • + +
  • +union of structures caused compiler to generate incorrect +code for member access.
  • + +
  • +added patch to vprintf.c to null terminate output +string. BESSIERE_Jerome@stna.dgac.fr (BESSIERE Jerome)
  • + +
  • +Debugger had problem with structures/unions on stack
  • + +
  • +Debugger will now stop when simulator stops even +when break point not hit.
  • + +
  • +Debugger will display simulators "startup message", +this makes it a clearer to the user that the debugger is actually piggy +backing on top of the simulator.
  • + +
  • +Applied patch to assembler/linker some names were +getting truncated @ 8 characters . patch by  "Anton Voloshin" <vav@isv.ru>
  • + +
  • +_gptrput.c was leaving a byte on stack if unknown +storage class.
  • + +
  • +parameter passing was incorrect for reentrant functions +when prototype declared without parameter name.
  • +
+
+ +
+
+
Release 2.1.9E +
    +
  • +"remat " was not being cleared for global variables.
  • + +
  • +stack offset of a variable computed incorrectly in +some situations.
  • + +
  • +Applied patch for floating point routine provided +by Wojciech Zabolotny <wzab@ise.pw.edu.pl>
  • + +
  • +Force allocation of local variable if address taken +(even if not initialised)
  • + +
  • +Fixed loop reversal bug .
  • + +
  • +Fixed another bug in register allocator , long variables +can be printfed now.
  • + +
  • +DEBUGGER can now print values on stack and aggregates.
  • + +
  • +Upgraded to 0.2.26 of ucsim.
  • +
+
+ +
+
+
Release 2.1.9D +
    +
  • +Fixed loop optimization bug was treating variables +defined twice as loop induction.
  • + +
  • +Fixed loop optimization constrained induction variable +detection.
  • + +
  • +Fixed bug in some floating point routines (fix provided +by Wojciech Zabolotny <wzab@ise.pw.edu.pl>)
  • + +
  • +Fixed code generation bug for return literal floating +point.
  • + +
  • +Fixed register packing was not moving return value +under certain conditions.
  • + +
  • +Improved error recovery for undefined symbols.
  • +
+
+ +
+
+
Release 2.1.9C +
    +
  • +Fixed bug with register allocation, effected mostly +large routines compiled using the --model-large option.
  • + +
  • +Fixed bug in array of structures dereferncing.
  • + +
  • +Simplified the intermediate code generattion , removed +some tree nodes. The parser will not generate nodes with structure derefs, +and the operators +=,-= ..etc will be changed at parse time, this creates +a simplififed parse tree.
  • + +
  • +Upgraded to latest version of "gc", compile problems +on Redhat 6.0 should be fixed.
  • + +
  • +Fixed passing simulator parameters from the debugger +command line.
  • + +
  • +Fixed problem with the floating point routines.
  • +
+
+ +
+
+
Release 2.1.9B +
    +
  • +Fixed pointer access and array reference +bug introduced in the previous version.
  • + +
  • +integrated ucsim.0.2.25
  • + +
  • +Fixed bug for code not generated for +global pointers assigned to address of array element.
  • + +
  • +Fixed one more bug in live range computation.
  • + +
  • +Fixed bug in register allocator , it +was overwriting computed liverange values.
  • +
+ +
+
Release 2.1.9A +
    +
  • +Fixed bug in common subexpression elimination, +problem was found when a local variable was assigned values more than once +in a basic block.
  • + +
  • +Added warning when a "void" object +is cast to a non-void object.
  • + +
  • +Added warning when a non-pointer type +is cast to a _generic pointer.
  • + +
  • +Added a  peephole optimization +rule to remove some moves.
  • + +
  • +Fixed problem in register packing , +registers assigned to parameters were not being saved on the stack.
  • + +
  • +Bug in loop inductions, the induction +variable detection was not correctly replacing all references.
  • + +
  • +Merged bug fixes provided by Wojciech +Stryjewski <wstryj1@tiger.lsu.edu to> SDCCgen51.c
  • + +
  • +Local variable treated as invariant +even when address is taken.
  • + +
  • +Fixed Parameter problem for functions +with empty bodies.
  • + +
  • +Fixed problem with array dereferncing +when array of pointers.
  • + +
    +
+
+ +
Release 2.1.9 +
    +
  • +Integrated new simulator from Daniel +"ucsim-0.20.xx"
  • + +
  • +.cdb file will be created always, and +will contain global variables & function entry/extis information always. +This will facilitate debuggers especially NoICE.
  • + +
  • +Fixed bug when using typedefed types +in a structure.
  • + +
  • +Fixed aliasing bug in the loop optimizer, +when a global array is used in a loop it should not be treated as an invariant +if there are function calls in the loop.
  • + +
  • +Fixed problem with register allocation, +this was causing some of the "long" routines to fail.
  • + +
  • +Fixed problem of clobbering value of +_bp.
  • + +
  • +Fixed problem of clobbering acc when +a long variable is the first argument to a reentrant function.
  • + +
  • +Fixed a peephole optimizer problem, +when it was changing the ljmp to a sjmp in a jump-table.
  • + +
  • +Enhanced the initialization routines +to support initialization with '&' operations.
  • +
+
+ +
+
+
Release 2.1.8 +
    +
  • +Void function returning value check +was not working properly.(fixed)
  • + +
  • +Assigning 'void' values to variables +will generate warning.
  • + +
  • +Improved register allocation to use +"acc" , this will improve code generation , but for this register color +is severely restricted, will gradually work on improving this. This reduces +the redundant register moved drastically (once totally implemented)
  • + +
  • +Added some peephole rules eliminate +jump to jumps.
  • + +
  • +Bug in SDCCgen51.c when using a bit +variable (locally defined) in an if statement.
  • + +
  • +Literal values being cast to pointers +was not working.
  • + +
  • +'volatile' arrtibute for structure/union +elements were bieng ignored. Now we can selectively declare structure elements +to be volatile.
  • + +
  • +Did some profiling to improve performance, +changed peephole optimizer a little with profiler feedback.
  • + +
  • +Was generating incorrect "cjne" code +under some situations.
  • + +
  • +Improved data flow computation.
  • + +
  • +Fixed bug in geniCodeCast for floating +point conversions.
  • + +
  • +Fixed bug in modulong routine found +by Béla Török <aseht@ms1.kssg.ch>
  • + +
  • +Fixed bug for long shift left found +by Béla Török <aseht@ms1.kssg.ch>
  • + +
  • +Fixed bug with register allocator , +was marking variables as rematerializable too aggresively.
  • + +
  • +Added --version option.
  • + +
  • +Fixed problem of compiling source files +not in current directory.
  • + +
  • +Fixed a bug in a bitvector routine +(bitVectResize)
  • + +
  • +Added error message when "continue/break" +are out of context.
  • + +
  • +Fixed bug in error checking for uninitialised +local variables.
  • + +
  • +Fixed bug in code generation for not +(!) operation.
  • + +
  • +Fixed bug in live range computation +when intervenening unreachable block is present.
  • + +
  • +Changed register saving scheme, bank +will be saved only when called from a interrupt service routine.
  • + +
  • +Fixed bug with >> and << with +unknown shift count.
  • + +
  • +The fix to the bit vector exposed some +problem with the register allocation, fixed now.
  • + +
  • +Added an extra heuristic for register +spilling, now the spilling will a lot lower than before.
  • + +
  • +Added some more optimizations for register +packing.
  • + +
  • +Added a bunch of preprocessor options +see command line options in the documentation for details.
  • + +
  • +Some cosmetics like timestamp in .asm +in addition to Version Number.
  • + +
  • +fixed another bug with live range computation.
  • + +
  • +Automatic static variables will not +be assigned to registers.
  • + +
  • +The parameter name mangling a little +so that it gives the warnings/errors with the correct name, also required +for debugger.
  • + +
  • +Jean Louis fixed some bugs with shifting +"long" variables.
  • + +
  • +Fixed bug of access of local bit variables +when compiling with --model-large
  • + +
  • +Fixed two bugs in Register allocator.
  • + +
  • +Added fix to peephole optimizer rule +matching , fixed provided by Frieder.
  • + +
  • +"Mark O'Farrell" <ofarrell@haq.com.au> +added segment type to the segment definition.
  • + +
  • +"Mark O'Farrell" <ofarrell@haq.com.au> +added option to start stack after the data segment --stack-after-data (see +documentation)
  • + +
  • +Changed the computation for default +stack location, now if all four banks are used the stack will be placed +after the data segment (--stack-after-data), so as not to clobber the bit +segment (this should make Daniel Drotos happy:).
  • + +
  • +Compiler will no longer crash when +an uninitialised local variable is detected.
  • + +
  • +Fixed bug for bad code generation for +anl,xor & or when operand is on stack .
  • + +
  • +Fixed bug for side effecting parameters +when calling a reentrant function.
  • + +
  • +Improved optimization for ++ & +-- operation when operand is on stack.
  • + +
  • +Was STILL saving entire register bank +when calling function with different register bank from non ISR function.
  • + +
  • +Changed register saveing for ISR functions +not using register bank (see documentation [Interrupt Service Routines])
  • + +
  • +Josef Wolf <jw@raven.inka.de> provided +a set of serial routines which do not use the external ram (ser_ir.c), +included these as libraries.
  • + +
  • +PSW was not being saved for ISRs with +no register bank specification.
  • + +
  • +Integrated Daniel's simulator with +the compiler source distribution.
  • + +
  • +Added reduced "printf" routine it works +but is very resource intensive.
  • + +
  • +Certain complex pointer declarations +were not being handled correctly.
  • + +
  • +switch statements with empty bodies +were causing the compiler to crash.
  • + +
  • +sizeof union object computed incorrectly.
  • + +
  • +union element when passed as parameter +to a function generated incorrect code.
  • + +
  • +Martijn van Balen <balen@natlab.research.philips.com> +provided a complete set of printf routines including sprintf.
  • + +
  • +Fixed bug when union member is a pointer +and is used on the right side of an assignment.
  • + +
  • +Improved register allocation  +for arrays, structure & union members in data space will no longer +be spilt.
  • + +
  • +Some optimizations for pointer access +had got clobbered put them back.
  • + +
  • +Fixed bug for right shifting signed +quantity by zero.
  • + +
  • +Constant propagation had problem when +long variables were used in division.
  • + +
  • +Fixed bug in register allocator on +rare situations it saved wrong live ranges.
  • + +
  • +Fixed Bug with Backend (gen51.c) incorrect +code was generated when far space variable assigned o variable in far space.
  • + +
  • +Fixed problem with loop invariant processing, +was not taking into consideration when address or pointer was passed as +parameter to a function.
  • + +
  • +Added --help & -h option.
  • + +
  • +Added the peephole optimization rules +provided by Frieder   <fe@lake.iup.uni-heidelberg.de>
  • + +
  • +Function prototypes without parameter +names were occasionally causing problems.
  • + +
  • +Fixed problem with _spx inc/dec when +using xternal stack.
  • + +
  • +Register allocation bug
  • + +
  • +Addition of constant to generic pointer +was causing problems sometimes.
  • + +
  • +Improved register allocation some more.
  • + +
  • +Fixed bug in live range analysis (for +some complex contro flow situations.
  • + +
  • +Fixed bug of 'b' getting clobbered +in some left & right shift operations.
  • + +
  • +Added --callee-saves (documentation +updated)
  • + +
  • +Fixed bug in hTabDeleteItem() in SDCChasht.c +(exposed during debugger development)
  • + +
  • +Fixed bug in grammar .. to allow absolute +address for local "bit" variables.
  • + +
  • +Added #pragma CALLEE-SAVES (same effect +as --calle-saves)
  • + +
  • +Added #pragma EXCLUDE (see docs)
  • + +
  • +Fixed problem xrl generating incorrect +code.
  • + +
  • +Yet another problem in register allocator +fixed.
  • + +
  • +Fixed a bug with dataflow computation, +was computing pointer kills incorrectly.
  • + +
  • +Added loop reversal.
  • + +
  • +Fixed bug in structure declaration
  • + +
  • +Fixed floating point routines
  • + +
  • +Fixed parsing problem for LONG hex +constants
  • + +
  • +Fixed bug to allow local variables +to be declared in 'code' space.
  • + +
  • +Fixed bug in code generation for floating +point .
  • + +
  • +Parameters access was incorrect when +callee-saves && reentrant.
  • + +
  • +Fixed bug in hashTable routine.
  • + +
  • +Fixed bug when string initialisers +are used for char arrays with bounds.
  • + +
  • +Was generating incorrect code when +options --model-large && --stack-auto were used together
  • + +
  • +Replaced 32bit multiplication routine +with JeanLouis VERN's much better routine.
  • + +
  • +Fixed problem with loop-reversing
  • + +
  • +Introduced parameter passing using +registers.
  • + +
  • +Applied improvements/cleanups supplied +by Larry Dolittle.
  • + +
  • +Moved the variable substitution by +register equivalent to earlier phase , this generates much more optimized +code.
  • + +
  • +Compiler crashed when first parameter +was declared "const"
  • + +
  • +Assembler generated bad opcode for +"djnz" when the "." operator was used.
  • +
+
+ +
+
+
Release 2.1.7 +
    +
  • +Fixed a bug in the DEF-USE chaining +algorithm , was keeping some dead DEFs alive in the DEF bit vector of a +symbol.
  • + +
  • +Fixed bug with "(null)" operand generated +in rare situations.
  • + +
  • + Trefor <Trefor@magera.freeserve.co.uk> +did some more clean up.
  • + +
  • +Fixed bug that was introduced with +'&' with a literal.
  • + +
  • +Added alternate serial package provided +by "Wolfgang Esslinger "<wolfgang@WiredMinds.com> in ./sdcc51lib/_ser.c +(documentation updated)
  • + +
  • +Added Header file  sab80515.h +provided by Béla Török <aseht@ms1.kssg.ch>
  • + +
  • +Had made flow computation for global +variables too restrictive, now constant propagation will be allowed with +global variables.
  • +
+
+ +
+
+
Release 2.1.6 +
  +
+
  • +Fixed bug in the routines _*2fs.c +the +variable 'sign' should be declared as 'long'.
  • + +
  • +Included _char2fs in libfloat.lib
  • + +
  • +Fixed register allocator  bug +for allocating pointers (found by "Dr. Ed Croson" <soarebc@internetcds.com>).
  • + +
  • +Furthur loop induction variable detection +improvement.
  • + +
  • +Changed loop induction detection so +that it does not treat global variables as induction any more, this saves +some code, since assignments to global variables cannot be easily eliminated.
  • + +
  • +Fixed problem of __sdcc_program_startup +being out of range when large amount of initialization code is present.
  • + +
  • +Fixed bug with function returning pointers.
  • + +
  • +Changed register allocation to aggressively +allocate local variables to registers, users will see a vast improvement +in the generated code, not only in terms  of speed but also in terms +of data space utilization. Previously if there were multiple definitions +for a local variable flowing into a basic block the compiler would allocate +space for the variable, now it will allocate space only if it runs out +of registers.
  • + +
  • +Jean-Louis VERN (jlvern@<writeme.com>) +has done some more enhancements to the code generator ..... his comments.
  • + +
    +
  • +I did some light improvement s:
  • + +
            +- increment 16&32bits +
           +- decrement 16&32bits +
            +- assignment with literal +
            +- return with literal +
    and some cosmetics before optimizing +mult and div...*
    + +
  • + "BESSIERE Jerome" <BESSIERE_Jerome@stna.dgac.fr> +made a lot of improvements to the support routines, these include reducing +some memory leaks.. here are his comments.
  • + +
    +
  • +//* Incorrect call of werror(E_OUT_OF_MEM,...);
  • + +
    //* 1-a In file SDCCBBlock.c / +function iCodeBreakDown (...) +
    //* 1-b In file SDCChasht.c / function +newHashTable(...) +
    //* 1-c In file SDCCmain.c / function +parseCmdLine(...) +
  • +//* Sometime the compiler crash due +to compilation error
  • + +
    //* In file SDCCast.c / function +createFunction(...) +
  • +//* Sometime SDCC access not allocated +memory
  • + +
    //* In file SDCChasht.c / function +hTabSearch(...) +
  • +/* Many and many memory leak when not +using CYGWIN32
  • + +
    //* and  garblage collector +(I'm using MS VC++ 6.0 and WIN32) +
    //* specially in peepHole function +consuming Mo and Mo +
    //* even on compiling small function +
    //* I created a new function in +file SDCChasht.c for deleting an hTab +
    //* It Reduces memory leaks
    + +
  • +"Salvador Eduardo Tropea \(SET\)" <salvador@inti.gov.ar> +provided patches required to compile the system using DJGPP, the executables +produced can run on plain DOS. He has also created a readme.dj file +for those who want to compile using DJGPP.
  • + +
  • +Added code to issue warnings if something +is compared to / assigned a literal value which is greater than what the +variable can hold.
  • + +
  • +Changed the data/space extended message +to info , since this not really a warning message.
  • + +
  • +Added routine auto baud, for automatic +baud rate detection , adapted from Paul Stoffregen's  <paul@ece.orst.edu> +autobaud.asm
  • + +
  • +Was not doing check for constants in +case for ++/--, i.e. a variable declared as const could be incremented +or decremented
  • + +
  • +Fixed bug when setting & fetching +data from far space .
  • + +
  • +Added bunch of peephole optimization +rules.
  • + +
  • +Trefor@magera.freeserve.co.uk. Updated +the build script to give a choice to compile the libraries as large model +or small model.
  • + +
  • +Trefor also got rid of those annoying +warnings when compiling with egcs ( braces about ambiguous 'else')
  • + +
  • +Added some heuristics in constant folding +routine , to prevent pointer live ranges from becoming too long, this was +causing some avoidable spill code to be generated.
  • + +
  • +Added support for ANSI routines setjmp +and longjmp. Documentation updated.
  • + +
  • +Was generating code for unreachable +basic blocks ... now will not generate code for unreachable code... will +issue a warning.
  • + +
  • +Was generating incorrect code when +adding values to generic pointers (some times).
  • + +
  • +Improved bitwise '&' operation +a little bit to improve code generation.
  • +
    + +
    +
    Release 2.1.5 +

    Mostly a bug fix release +
      +

    +
  • +Fixed post & pre increment / Decrement +problem and inefficiency
  • + +
  • +Structures/Unions. Three things were +done this structure declarations.
  • + +
    +
  • +The long standing union problem has +been fixed, a very rudimentary solution right now , will some up with a +better solution shortly.
  • + +
  • +Structures declared inside function +scopes were not being properly cleaned up, came across this problem while +generating debug information fixed now.
  • + +
  • +pointers declared inside structures +were broken after the pointer fix in Version 2.1.3, now fixed.
  • +
    + +
  • +Fixed some library routines , for --model-large +.
  • + +
  • +Added whole lot of stuff for debug +information generation (DO NOT use --debug option might cause unpredictable +results).
  • +
    + +
    +
    Release 2.1.4 +
      +
      +
    • +Problem with parameter overlay : when +two functions with overlaid parameters were nested, the parameters of the +outer function was clobbered. This has been fixed, now the inner function +call will be lifted out and evaluated before parameters for the outer call +are assigned values.
    • + +
    • +New optimization added (suggested by +Jean Louis VERN <jlvern@writeme.com> to prevent global variables in +near space from being assigned to registers.
    • + +
    • +Improved loop optimization, now will +keep induction variables alive after loops even if loops have more that +one exit. This makes me happy, it takes care of almost all the common loop +constructs. So unless the user is doing something really weird the induction +variables  will be carried outside the loop. This also lays down the +ground work for value based optimizations, i.e. when the loop count is +known, then value of the induction variables will also be known at certain +exit points.
    • + +
    • +Fixed bug in genPlus, genAnd,genXor,genOr +routines , was generating incorrect code for Far Space variable with Literal.
    • + +
    • +Fixed bugs in SDCCglue.c, was generating +-ve size for variables of size 32768 or greater.
    • + +
    • +Changed register allocator to try & +keep all local variables in 'registers' regardless of they are declared +with the register storage class or not, this will reduce the amount of +data space required by the compiler generated code.
    • + +
    • +Fixed bug in SDCCmain.c , was unlinking +file preOutName before reading it (okay with POSIX , not okay with DOS).
    • + +
    • +David Bonnel <dbonnell@ozemail.com.au>. +fixed the following bugs
    • + +
        +
      • +In SDCCicode.c at line# 1314 should +be calling valMod not valDiv.
      • + +
      • +In line# 2728 missing a break statement +after the division case .
      • +
      + +
    • +David Bonnell <dbonnell@ozemail.com.au>. +also added a new option --iram-size <value> .    +His description of it .....  (Dave speaking)
    • + +
        +
      • +I added the command '-a [iram-size]' +to the linker. iram-size defaults to   128 (0x80) if it is omitted +(which is the amount of internal RAM I have on  my DS5000T chip :-)
      • +
      +             +Anyway, if this command is given, the (new) function iramcheck() is called +after linking to check that the OSEG, ISEG, and DSEG's do not extend  +past the end of internal RAM.  (Internal RAM is from  0..iram_size-1).  +It spits out a warning such as: +

                 +WARNING! Segment DSEG extends past the end of internal RAM.  Check +map file. +

         when such a problem +is detected. +

         Then I added a new +command-line option to SDCC, '--iram-size iram-size'. When this command +is given the linker command shown above is added to the linker command +file so that it will do the checking for internal RAM overflow. +
        +

    • + BESSIERE Jerome <BESSIERE_Jerome@stna.dgac.fr> +fixed the following bugs.
    • + +
        +
      • +File sdccicod.c / function operandOperation(...)
      • + +
      • +File sdccval.c / function valDiv(...)
      • + +
      • +File sdccbitv.c / function bitVectBitValue(...)
      • + +
      • +File sdccbitv.c / function bitVectUnSetBit(...)
      • +
      +
    + +
    +
    Release 2.1.3 +
      +
      +
    • +Fixed bug in assembler  i51mch.c  +; dot operator when used in branch instructions was generating incorrect +opcode.
    • + +
    • +Enhanced Dead Code elimination, (it +was missing some ).
    • + +
    • +Added new rules to SDCCpeeph.def  +provided by Frieder <fe@lake.iup.uni-heidelberg.de>
    • + +
    • +Fixed pointer return bug found by David +Bonnel <dbonnell@ozemail.com.au>.
    • + +
    • +Fixed the POINTER fiasco, I had misinterpreted +the grammar.
    • + +
        +
      • +data char *p;  was interpreted +as [generic pointer to char, with p in data space]. now interpreted as +pointer to character in data space with the pointer residing in unknown +space.
      • + +
      • +Updated the documentation for this.
      • +
      + +
    • +Updated documentation to include comments +about Parameter Overlaying.
    • + +
    • +Improved type checking to generate +error message when a void type is casted to some other type
    • + +
    • +Jean-Louis VERN (instead of sleeping +at night) has made some GREAT!! improvements to the back end for frequently +used expressions like
    • + +
        +
      • +if ( x & literal) ...
      • + +
      • +if ( x ^ literal) ...
      • + +
      • +if ( x |  literal) ...
      • + +
      • +if ( bit & x) ...
      • + +
      • +if ( bit | x ) ...
      • + +
      • +if (bit ^ x) ....
      • +
      + +
    • +Jean-Louis VERN rewrote the _decdptr.c +routine to improve it.
    • +
    + +
    +
    Release 2.1.2 +
      +
      +
    • +Bug in genAnd (SDCCgen51.c) caused +the compiler to issue error message for some bit wise and operations.
    • + +
    • +File _spx.c missing from source bundle.
    • + +
    • +Invalid code generated when interrupt +service routine used with external stack option.
    • + +
    • +Added --no-peep option to disable peep +hole optimization.
    • + +
    • +Added --peep-asm option to optionally +pass inline assembler code through the peephole optimizer.
    • + +
    • +Fixed bug in _strcpy.c David Bonnell +<dbonnell@ozemail.com.au>.
    • +
    + +
      +
    • +
    • +
    + +
    +
    Release 2.1.1 +
      +
      +
    • +bit variables could not be declared +extern +, bug was introduces while improving type checking for bit fields in structures.
    • +
    + +
    +

    Release 2.1.0 +

    A full source code release. Lots of stuff done in this +release. +
      +

      +
    • +Floating point support completed (although +cannot be used in small model).
    • + +
    • +Data flow computation enhanced to stop +flow computation of global variables when there is a call to another function.
    • + +
    • +JeanLouis VERN added a whole lot of +optimizations to the back end.
    • + +
    • +Function return value assigned to a +bit variable was crashing the compiler.
    • + +
    • +Changed the way peep hole optimizer +rules were being included. Now it is much easier to add default rules.
    • + +
    • +Added two new pointer types "* pdata" +and "* idata" these will facilitate the following
    • + +
        +
      • +Optimized access to near data
      • + +
      • +Implementation of external stack (External +stack is required if the compiler is going to be used to implement an RTOS)
      • +
      + +
    • +Fixed problem of Compiler giving warning +when it did not find any reaching definition for a local static variable.
    • + +
    • +Added code to backed for more optimized +access to arrays, structures & unions placed in near space, now the +compiler will not use indirect addressing to fetch the data if the offset +is can be determined at compile time.
    • + +
    • +Changed the way the startup code works. +Documentation updated see section Startup for more details.
    • + +
    • +Completed implementation of external +stack. Documentation updated see section External stack.
    • + +
    • +Jean-Louis VERN added a LOT of optimizations +to the back end code generator, following is only a small list.
    • + +
        +
      • +gencjne improved
      • + +
      • +gencmp improved
      • + +
      • +genand improved
      • + +
      • +genor improved.
      • + +
      • +_divuint improved
      • + +
      • +_divuint improved.
      • +
      + +
    • +Variables with absolute addresses now +considered as VOLATILE.
    • + +
    • +Dead Code elimination routine updated +: will not eliminate global assignments to global variables when function +call present.
    • + +
    • +Added file at89S8252.h to distribution +file supplied by "Michael Schmitt" <mschmitt@mainz-online.de>
    • + +
    • +Martijn van Balen <balen@natlab.research.philips.com>. +Fixed problems in assembler and linker. Files affected are asout.c +and lklist.c
    • + +
    • +Initialized character array variables +with no size were being generated one byte less in length.
    • + +
    • +Access to bit fields within structures +mucho mucho improved.
    • + +
    • +The compiler was allocating space on +the stack for local variables (for reentrant functions) even when not needed, +this has been fixed, the compiler will not allocate space on the stack +for local variables if they are assigned to registers.
    • +
    + +
    +
    Release 2.0.21 +
      +
    +
  • +Enhancement made to unsigned long & +integer division by Martijn van Balen <balen@natlab.research.philips.com>
  • + +
  • + _gptrget.c & _gptrput.c made +register bank independent  by Martijn van Balen <balen@natlab.research.philips.com>.
  • + +
  • +sdccbuil.sh script fixed by Subject: +Markus Mathes <mathes@prp.physik.tu-darmstadt.de>
  • + +
  • +Martijn van Balen <balen@natlab.research.philips.com> +found some problems with post & pre increment of pointer variables +, these are fixed.
  • +
    + +
    +
    Release 2.0.20 +

    Mostly enhancements in this release. Some bug fixes by +Jean Louis. +

    +
  • +Enhanced loop optimization (induction +variables), will generate more compact code for simple loops
  • + +
  • +Enhanced some aspects of basic block +processing.
  • + +
  • +Added a couple more MCU header files.
  • + +
  • +Jean Louis made some enhancements in +SDCCgen51.c for better code generation.
  • + +
  • +Jean Louis also fixed some bugs in +the back end .
  • +
    + +
    +
    Release 2.0.19 +
      +
    +
  • +Assignment of array variable to a pointer +sometimes did not generate code.
  • + +
  • +File containing intialised variables +ONLY with NO functions caused the compiler to crash
  • + +
  • +Initialising global volatile variables +caused the compiler to fail.
  • + +
  • +Generated incorrect code when bit variables +were modified and subsequently used in a conditional statement.
  • + +
  • +Added 3 more header files for Atmel +MCUs , provided by Bernd  Bartmann (Bernd.Bartmann@picard.isdn.cs.tu-berlin.de)
  • + +
  • +Added a lot of peephole optimization +rules, some suggested by Daniel Drotos <drdani@mazsola.iit.uni-miskolc.hu>
  • + +
  • +Added check to make sure functions +do not return 'bit'.
  • + +
  • +Jean Louis-VERN (jlvern@writeme.com) +fixed bug for divide with literal in his code.
  • +
    +
    + +
      +
      +
      Release 2.0.18 +
        +
        +
      • +Function prototype problem when parameter +name in the prototype was the same as a local variables.
      • + +
      • +Added header files for Atmel AT89x51 +& AT89X52 provided by : Bernd  Bartmann (Bernd.Bartmann@picard.isdn.cs.tu-berlin.de)
      • + +
      • +Jean Louis-VERN (jlvern@writeme.com) +has made substantial improvements +to the Back-end code generation for shift operations +and +multiplication.
      • +
      +
    + +
    +
    +
    +
    Release 2.0.17
    +
    + +
    +
      +
        +
      • +Empty if body with non-emtpy else body +cause compiler to give error message. Patch provided by Martijn van Balen +<balen@natlab.research.philips.com>
      • + +
      • +Loop optimizer missed induction variables +;
      • + +
      • +Added option --main-return , +will generate a 'ret' instead of 'ljmp .' when this option +is used.
      • + +
      • +Add support for user defined startup +code.
      • +
      +
    + +
    +
    +
      +
    • +generating incorrect assembler code +(new line missing), for 'long' variables initialization when defined +in 'code' space.
    • + +
    • +aslink occasionally core dumped, +after it finished processing. (patch provided by  Eric Norum <eric@skatter.USask.Ca> +)
    • + +
    • +comparing pointers with literals +, +e.g. ptr == NULL gave error message, (NULL had to be explicitly cast to +the pointer type)
    • + +
    • +assigning signed char values +to sfrs generated duplicate code.
    • + +
    • +definitions for CHAR_MIN, INT_MAX & +LONG_MAX incorrect in limits.h
    • + +
    • +some more patches from Eric Norum <eric@skatter.USask.Ca> +his description of the patches.
    • + +
        +
      • +1) asxxxx/lkmain.c:181
      • + +
           startp->f_type is +an integer variable and so should not be +
           compared with NULL. +

        2) asxxxx/lkmain.c:195 +
           *ip is a character +variable and so should not be +
           compared with NULL. +

        3) asxxxx/lkmain.c:717 +
           ctype[c] is a character +variable so the expression (ctype[c] != ILL) +
           is always true on +machines where char variables are signed. +

        4) SDCCmain.c:780 +
           The preprocessor output +file was left in the temporary directory. +
         

      + +
    • + volatile variables when used +as loop induction variables caused the compiler to crash.
    • + +
    • +compiler generated 'char * idata +icp'  as a generic pointer instead of 1 byte pointer.
    • + +
    • +link file problem, when linking multiple +files together the compiler sometimes generated a bad file name.
    • + +
    • +library function _atol.c had +the function main in it.
    • + +
    • +Incorrect code generated left shift +of one byte variables 'rl' should be 'rlc' . Patch +provided by : Jean-Louis VERN <jlvern@writeme.com>
    • + +
    • +Bug in ./cpp/cpplib.c . Patch +provided by :Martijn van Balen <balen@natlab.research.philips.com>
    • + +
    • +Consecutive 'if' statements +sometimes caused the compiler to crash. This bug was a fairly serious.
    • + +
    • +Incorrect code generated right shift +of long variables variables 'rlc' should be 'rrc' . +Patch provided by : Jean-Louis VERN <jlvern@writeme.com>
    • + +
    • +Xor, And and Or operation with bit +variable & non-bit variable generated incomplete code.
    • + +
    • +Expression folding was too aggresive, +was corrupting parameters in certain situations.
    • + +
    • +Function prototypes declared with parameter +names , occasionally caused problems.
    • +
    +
    + +
    +
      +
    • +
    • +
    +
    +
    + + + diff --git a/doc/SDCCUdoc-1.html b/doc/SDCCUdoc-1.html new file mode 100644 index 00000000..41785023 --- /dev/null +++ b/doc/SDCCUdoc-1.html @@ -0,0 +1,62 @@ + + + + + SDCC Compiler User Guide: Introduction + + + + + +
    Next +Previous +Contents +
    +

    1. Introduction

    + +

    SDCC is a Free ware , retargettable, optimizing ANSI-C compiler. The current +version targets Intel 8051 based MCUs, it can be retargetted for other 8 bit +MCUs or PICs. The entire source code for the compiler is distributed under +GPL. SDCC used ASXXXX & ASLINK a Free ware, retargettable assembler & +linker. SDCC has extensive MCU (8051) specific language extensions, which lets +it utilize the underlying hardware effectively. The front-end (parser) will +be enhanced to handle language extensions for other MCUs as and when they are +targetted. In addition to the MCU Specific optimizations SDCC also does a host +of standard optimizations like global sub expression elimination, loop optimizations +(loop invariant, strength reduction of induction variables and loop reversing), +constant folding & propagation, copy propagation, dead code elimination +and jumptables for 'switch' statements. For the back-end SDCC uses a global +register allocation scheme which should be well suited for other 8 bit MCUs +, the peep hole optimizer uses a rule based substitution mechanism which is +MCU independent. Supported data-types are short (8 bits, 1 byte), char (8 bits, +1 byte), int (16 bits, 2 bytes ), long (32 bit, 4 bytes) & float (4 byte +IEEE). The compiler also allows inline assembler code to be embedded anywhere +in a function. In addition routines developed in assembly can also be called. +SDCC also provides an option to report the relative complexity of a function, +these functions can then be further optimized , or hand coded in assembly if +need be. SDCC also comes with a companion source level debugger SDCDB, the +debugger currently uses S51 a freeware simulator for 8051, it can be easily +modified to use other simulators. The latest version can be downloaded from +http://www.geocities.com/ResearchTriangle/Forum/1353 +

    All packages used in this compiler system are opensource (freeware); source +code for all the sub-packages ( asxxxx assembler/linker , pre-processor and +gc a conservative garbage collector) are distributed with the package. Documentation +was created using a freeware word processor (LyX). +

    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, 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; if not, write to the Free Software Foundation, 59 Temple Place +- Suite 330, Boston, MA 02111-1307, USA. In other words, you are welcome to +use, share and improve this program. You are forbidden to forbid anyone else +to use, share and improve what you give them. Help stamp out software-hoarding! +

    +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-10.html b/doc/SDCCUdoc-10.html new file mode 100644 index 00000000..3de0515e --- /dev/null +++ b/doc/SDCCUdoc-10.html @@ -0,0 +1,48 @@ + + + + + SDCC Compiler User Guide: Absolute addressing. + + + + + +Next +Previous +Contents +
    +

    10. Absolute addressing.

    + +

    Data items can be assigned an absolute address with the at <address> +keyword, in addition to a storage class. +

    +

    +eg. xdata at 0x8000 unsigned char PORTA_8255 ;
    + 
    +
    +

    In the above example the PORTA_8255 will be allocated to the location 0x8000 +of the external ram. +

    Note that is this feature is provided to give the programmer access to +memory mapped devices attached to the controller. The compiler does not actually +reserve any space for variables declared in this way (they are implemented +with an equate in the assembler), thus it is left to the programmer to make +sure there are no overlaps with other variables that are declared without the +absolute address, the assembler listing file (.lst) and the linker output files +(<filename>.rst) and (<filename>.map) are a good places to look +for such overlaps. +

    Absolute address can be specified for variables in all storage classes. +

    +

    +eg.bit at 0x02 bvar;
    + 
    +
    +

    The above example will allocate the variable at offset 0x02 in the bit-addressable +space. There is no real advantage to assigning absolute addresses to variables +in this manner , unless you want strict control over all the variables allocated. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-11.html b/doc/SDCCUdoc-11.html new file mode 100644 index 00000000..9e2c5831 --- /dev/null +++ b/doc/SDCCUdoc-11.html @@ -0,0 +1,77 @@ + + + + + SDCC Compiler User Guide: Interrupt Service Routines + + + + + +Next +Previous +Contents +
    +

    11. Interrupt Service Routines

    + +

    SDCC allows interrupt service routines to be coded in C, with some extended +keywords. +

    +

    +void timer_isr (void) interrupt 2 using 1 
    +{ 
    +.. 
    +}
    + 
    +
    +

    The number following the 'interrupt' keyword is the interrupt number this +routine will service. The compiler will insert a call to this routine in the +interrupt vector table for the interrupt number specified. The 'using' keyword +is used to tell the compiler to use the specified register bank (8051 specific) +when generating code for this function. Note that when some function is called +from an interrupt service routine it should be preceded by a #pragma NOOVERLAY +(if it is not reentrant) . A special note here, int (16 bit) and long (32 bit) +integer division, multiplication & modulus operations are implemented using +external support routines developed in ANSI-C, if an interrupt service routine +needs to do any of these operations then the support routines (as mentioned +in a following section) will have to recompiled using the --stack-auto option +and the source file will need to be compiled using the --int-long-rent compiler +option. +

    If you have multiple source files in your project, interrupt service routines +can be present in any of them, but a prototype of the isr MUST be present in +the file that contains the function 'main'. +

    Interrupt Numbers and the corresponding address & descriptions for +the Standard 8051 are listed below. SDCC will automatically adjust the interrupt +vector table to the maximum interrupt number specified. +

    +

    +Interrupt #         Description           Vector Address 
    +   0                External
    + 0            0x0003 
    +   1                Timer 0               0x000B 
    +   2
    +                External 1            0x0013 
    +   3                Timer 1               0x001B
    + 
    +   4                Serial                0x0023
    + 
    +
    +

    If the interrupt service routine is defined without a register bank or +with register bank 0 (using 0), the compiler will save the registers used by +itself on the stack (upon entry and restore them at exit), however if such +an interrupt service routine calls another function then the entire register +bank will be saved on the stack. This scheme may be advantageous for small +interrupt service routines which have low register usage. +

    If the interrupt service routine is defined to be using a specific register +bank then only "a","b" & "dptr" are save and restored, if such an interrupt service +routine calls another function (using another register bank) then the entire +register bank of the called function will be saved on the stack. This scheme +is recommended for larger interrupt service routines. +

    Calling other functions from an interrupt service routine is not recommended +avoid it if possible. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-12.html b/doc/SDCCUdoc-12.html new file mode 100644 index 00000000..4ba08b3b --- /dev/null +++ b/doc/SDCCUdoc-12.html @@ -0,0 +1,27 @@ + + + + + SDCC Compiler User Guide: Startup Code + + + + + +Next +Previous +Contents +
    +

    12. Startup Code

    + +

    The compiler inserts a jump to the C routine _sdcc__external__startup()at the start of the CODE area. This routine can be found in the file SDCCDIR/sdcc51lib/_startup.c +, by default this routine returns 0, if this routine returns a non-zero value +, the static & global variable initialization will be skipped and the function +main will be invoked, other wise static & global variables will be initialized +before the function main is invoked. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-13.html b/doc/SDCCUdoc-13.html new file mode 100644 index 00000000..757e4928 --- /dev/null +++ b/doc/SDCCUdoc-13.html @@ -0,0 +1,71 @@ + + + + + SDCC Compiler User Guide: Inline assembler code. + + + + + +Next +Previous +Contents +
    +

    13. Inline assembler code.

    + +

    SDCC allows the use of in-line assembler with a few restriction as regards +labels. All labels defined within inline assembler code HAS TO BE of the form +nnnnn$ where nnnn is a number less than 100 (which implies a limit of +utmost 100 inline assembler labels per function). It is strongly recommended +that each assembly instruction (including labels) be placed in a separate line +( as the example shows). When the --peep-asm command line option is used, the +inline assembler code will be passed through the peephole optimizer, this might +cause some unexpected changes in the inline assembler code, please go throught +the peephole optimizer rules defined in file 'SDCCpeeph.def' carefully before +using this option. +

    +

    +eg_asm 
    +         mov b,#10 
    +00001$: 
    +         djnz b,00001$
    + 
    +_endasm ;
    + 
    +
    +

    The inline assembler code can contain any valid code understood by the +assembler (this includes any assembler directives and comment lines ) . The +compiler does not do any validation of the code within the _asm ... _endasm; +keyword pair. +

    Inline assembler code cannot reference any C-Labels however it can reference +labels defined by the inline assembler. +

    +

    +egfoo() { 
    +... /* some c code */ 
    +_asm 
    +     ; some assembler code 
    + 
    +   ljmp $0003 
    +_endasm ; 
    +... /* some more c code */ 
    +clabel:   /* inline
    + assembler cannot reference this label */ 
    +_asm 
    +   $0003: ;label (can
    + be reference by inline assembler only) 
    +_endasm ; 
    +... 
    +}
    + 
    +
    +

    In other words inline assembly code can access labels defined in inline +assembly. The same goes the other way, ie. labels defines in inline assembly +CANNOT be accessed by C statements. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-14.html b/doc/SDCCUdoc-14.html new file mode 100644 index 00000000..e6938bb3 --- /dev/null +++ b/doc/SDCCUdoc-14.html @@ -0,0 +1,47 @@ + + + + + SDCC Compiler User Guide: int (16 bit) and long (32 bit ) support. + + + + + +Next +Previous +Contents +
    +

    14. int (16 bit) and long (32 bit ) support.

    + +

    For signed & unsigned int (16 bit) and long (32 bit) variables, division, +multiplication and modulus operations are implemented by support routines. +These support routines are all developed in ANSI-C to facilitate porting to +other MCUs. The following files contain the described routine, all of them +can be found in the directory SDCCDIR/sdcc51lib +

    +

      +
    • _mulsint.c - signed 16 bit multiplication (calls _muluint)
    • +
    • _muluint.c - unsigned 16 bit multiplication
    • +
    • _divsint.c - signed 16 bit division (calls _divuint)
    • +
    • _divuint.c - unsigned 16 bit division.
    • +
    • _modsint.c - signed 16 bit modulus (call _moduint)
    • +
    • _moduint.c - unsigned 16 bit modulus.
    • +
    • _mulslong.c - signed 32 bit multiplication (calls _mululong)
    • +
    • _mululong.c - unsigned32 bit multiplication.
    • +
    • _divslong.c - signed 32 division (calls _divulong)
    • +
    • _divulong.c - unsigned 32 division.
    • +
    • _modslong.c - signed 32 bit modulus (calls _modulong).
    • +
    • _modulong.c - unsigned 32 bit modulus.
    • +
    +

    All these routines are compiled as non-reentrant and small model. Since +they are compiled as non-reentrant, interrupt service routines should not do +any of the above operations, if this unavoidable then the above routines will +need to ne compiled with the --stack-auto option, after which the source program +will have to be compiled with --int-long-rent option. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-15.html b/doc/SDCCUdoc-15.html new file mode 100644 index 00000000..612128e1 --- /dev/null +++ b/doc/SDCCUdoc-15.html @@ -0,0 +1,48 @@ + + + + + SDCC Compiler User Guide: Floating point support + + + + + +Next +Previous +Contents +
    +

    15. Floating point support

    + +

    SDCC supports IEEE (single precision 4bytes) floating point numbers.The +floating point support routines are derived from gcc's floatlib.c and consists +of the following routines. +

    +

      +
    • _fsadd.c - add floating point numbers.
    • +
    • _fssub.c - subtract floating point numbers
    • +
    • _fsdiv.c - divide floating point numbers
    • +
    • _fsmul.c - multiply floating point numbers
    • +
    • _fs2uchar.c - convert floating point to unsigned char
    • +
    • _fs2char.c - convert floating point to signed char.
    • +
    • _fs2uint.c - convert floating point to unsigned int.
    • +
    • _fs2int.c - convert floating point to signed int.
    • +
    • _fs2ulong.c - convert floating point to unsigned long.
    • +
    • _fs2long.c - convert floating point to signed long.
    • +
    • _uchar2fs.c - convert unsigned char to floating point
    • +
    • _char2fs.c - convert char to floating point number
    • +
    • _uint2fs.c - convert unsigned int to floating point
    • +
    • _int2fs.c - convert int to floating point numbers
    • +
    • _ulong2fs.c - convert unsigned long to floating point number
    • +
    • _long2fs.c - convert long to floating point number.
    • +
    +

    Note if all these routines are used simultaneously the data space might +overflow. For serious floating point usage it is strongly recommended that +the Large model be used (in which case the floating point routines mentioned +above will need to recompiled with the --model-Large option). +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-16.html b/doc/SDCCUdoc-16.html new file mode 100644 index 00000000..69eac941 --- /dev/null +++ b/doc/SDCCUdoc-16.html @@ -0,0 +1,36 @@ + + + + + SDCC Compiler User Guide: Memory Models + + + + + +Next +Previous +Contents +
    +

    16. Memory Models

    + +

    SDCC allows two memory models, modules compiled with different memory models +should be combined together, the results would be unpredictable. The support +routines supplied with the compiler are compiled in small-model by default, +and will need to be recompiled using the large model if the large model is +used. In general the use of the large model is discouraged. +

    When the large model is used all variables declared without a storage class +will be allocated into the external ram, this includes all parameters and local +variables (for non-reentrant functions). When the small model is used variables +without storage class are allocated in the internal ram. +

    Judicious usage of the processor specific storage classes and the 'reentrant' +function type will yield much more efficient code, than using the large-model. +Several optimizations are disabled when the program is compiled using the large +model, it is therefore strongly recommdended that the small model be used unless +absolutely required. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-17.html b/doc/SDCCUdoc-17.html new file mode 100644 index 00000000..37874070 --- /dev/null +++ b/doc/SDCCUdoc-17.html @@ -0,0 +1,31 @@ + + + + + SDCC Compiler User Guide: Defines created by the compiler. + + + + + +Next +Previous +Contents +
    +

    17. Defines created by the compiler.

    + +

    The compiler creates the following #defines . +

    +

      +
    • SDCC - this Symbol is always defined.
    • +
    • SDCC_STACK_AUTO - this symbol is defined when --stack-auto option is used.
    • +
    • SDCC_MODEL_SMALL - when small model is used.
    • +
    • SDCC_MODEL_LARGE - when --model-large is used.
    • +
    • SDCC_USE_XSTACK - when --xstack option is used.
    • +
    +
    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-18.html b/doc/SDCCUdoc-18.html new file mode 100644 index 00000000..1a9bdc53 --- /dev/null +++ b/doc/SDCCUdoc-18.html @@ -0,0 +1,95 @@ + + + + + SDCC Compiler User Guide: Pragmas + + + + + +Next +Previous +Contents +
    +

    18. Pragmas

    + +

    SDCC supports the following #pragma directives. This directives are +applicable only at a function level. +

    +

      +
    • SAVE + - this will save all the current options .
    • +
    • RESTORE + - will restore the saved options from the last save. Note that +SAVES & RESTOREs cannot be nested. SDCC uses the same buffer to save the +options each time a SAVE is called.
    • +
    • NOGCSE + - will stop global subexpression elimination.
    • +
    • NOINDUCTION + - will stop loop induction optimizations .
    • +
    • NOJTBOUND + - will not generate code for boundary value checking , when switch +statements are turned into jump-tables.
    • +
    • NOOVERLAY + - the compiler will not overlay the parameters and local variables +of a function.
    • +
    • NOLOOPREVERSE + - Will not do loop reversal optimization
    • +
    • EXCLUDE NONE | {acc[,b[,dpl[,dph]]] + +- The exclude pragma disables generation of pair of push/pop instruction in +ISR function (using interrupt keyword). The directive should be placed immediately +before the ISR function definition and it affects ALL ISR functions following +it. To enable the normal register saving for ISR functions use "#pragma +EXCLUDE none"
    • +
    • CALLEE-SAVES function1[,function2[,function3...]] + - +The compiler by default uses a caller saves convention for register saving +across function calls, however this can cause unneccessary register pushing +& popping when calling small functions from larger functions. This option +can be used to switch the register saving convention for the function names +specified. The compiler will not save registers when calling these functions, +extra code will be generated at the entry & exit for these functions to +save & restore the registers used by these functions, this can SUBSTANTIALLY +reduce code & improve run time performance of the generated code. In future +the compiler (with interprocedural analysis) will be able to determine the +appropriate scheme to use for each function call. If --callee-saves + command +line option is used, the function names specified in #pragma CALLEE-SAVES +is appended to the list of functions specified inthe command line.
    • +
    +

    The pragma's are intended to be used to turn-off certain optimizations +which might cause the compiler to generate extra stack / data space to store +compiler generated temporary variables. This usually happens in large functions. +Pragma directives should be used as shown in the following example, they are +used to control options & optimizations for a given function; pragmas should +be placed before and/or after a function, placing pragma's inside a function +body could have unpredictable results. +

    +

    +eg#pragma SAVE   /* save the current settings */ 
    +#pragma NOGCSE
    + /* turnoff global subexpression elimination */ 
    +#pragma NOINDUCTION /*
    + turn off induction optimizations */ 
    +int foo () 
    +{ 
    +    ... 
    +    /* large
    + code */ 
    +    ... 
    +} 
    +#pragma RESTORE /* turn the optimizations back
    + on */
    + 
    +
    +

    The compiler will generate a warning message when extra space is allocated. +It is strongly recommended that the SAVE and RESTORE pragma's be used when +changing options for a function. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-19.html b/doc/SDCCUdoc-19.html new file mode 100644 index 00000000..2f8614b4 --- /dev/null +++ b/doc/SDCCUdoc-19.html @@ -0,0 +1,98 @@ + + + + + SDCC Compiler User Guide: Library routines. + + + + + +Next +Previous +Contents +
    +

    19. Library routines.

    + +

    The following library routines are provided for your convenience. +

    stdio.h - Contains the following functions printf & sprintf these routines +are developed by Martijn van Balen <balen@natlab.research.philips.com>. +

    +

    +

    +%[flags][width][b|B|l|L]type           flags: -        left justify output in specified field width
    + 
    +                 +        prefix output with +/- sign if output is signed
    + type 
    +                 space    prefix output with a blank if it's a signed
    + positive value 
    +          width:          specifies minimum number of characters
    + outputted for numbers 
    +                          or strings. 
    +                         
    + - For numbers, spaces are added on the left when needed. 
    +                           
    + If width starts with a zero character, zeroes and used 
    +                           
    + instead of spaces. 
    +                          - For strings, spaces are are
    + added on the left or right (when 
    +                            flag '-' is used)
    + when needed. 
    +                          
    +          b/B:            byte argument
    + (used by d, u, o, x, X) 
    +          l/L:            long argument (used by d,
    + u, o, x, X)
    +          type:  d        decimal number 
    +                 u       
    + unsigned decimal number 
    +                 o        unsigned octal number 
    +                
    + x        unsigned hexadecimal number (0-9, a-f) 
    +                 X       
    + unsigned hexadecimal number (0-9, A-F) 
    +                 c        character
    + 
    +                 s        string (generic pointer) 
    +                 p       
    + generic pointer (I:data/idata, C:code, X:xdata, P:paged) 
    +                
    + f        float (still to be implemented)
    + 
    +
    +

    Also contains a very simple version of printf (printf_small). This simplified +version of printf supports only the following formats. +

    +

    +format     output type     argument-type <bf>
    +%d         decimal      
    + int 
    +%ld        decimal       long 
    +%hd        decimal       short/char
    + 
    +%x        hexadecimal    int 
    +%lx       hexadecimal    long
    + 
    +%hx       hexadecimal    short/char 
    +%o         octal         int
    + 
    +%lo        octal         long 
    +%ho        octal         short/char
    + 
    +%c        character      char/short 
    +%s        character     _generic
    + pointer
    + <p><tt>The routine is <tt><bf>very stack intesive , --stack-after-data parameter should
    + be used when using this routine, the routine also takes about 1K of code space
    + .It also expects an external function named putchar(char ) to be present (this
    + can be changed). When using the %s format the string / pointer should
    + be cast to a generic pointer. eg.
    + 
    +
    +
    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-2.html b/doc/SDCCUdoc-2.html new file mode 100644 index 00000000..20526133 --- /dev/null +++ b/doc/SDCCUdoc-2.html @@ -0,0 +1,267 @@ + + + + + SDCC Compiler User Guide: Installation + + + + + +Next +Previous +Contents +
    +

    2. Installation

    + +

    What you need before you start installation of SDCC ? A C Compiler, not +just any C Compiler, gcc to be exact, you can get adventurous and try another +compiler , I HAVEN'T tried it. GCC is free , and is available for almost all +major platforms, if you are using linux you probably already have it, if you +are using Windows 95/NT go to www.cygnus.com and download CYGWIN32 you will +need the full development version of their tool (full.exe), follow their instructions +for installation (this is also free and is very easy to install), Windows 95/NT +users be aware that the compiler runs substantially slower on the Windows platform, +I am not sure why. +

    After you have installed gcc you are ready to build the compiler (sorry +no binary distributions yet). SDCC is native to Linux but can be ported to +any platform on which GCC is available . Extract the source file package (.zip +or .tar.gz) into some directory , which we shall refer to as SDCCDIR from now +on. +

    2.1 Components of SDCC +

    + +

    gc ( a conservative garbage collector)

    + +

    SDCC relies on this component to do all the memory management, this excellent +package is copyrighted by Jans J Boehm(boehm@sgi.com) and Alan J Demers but +can be used with minimum restrictions. The GC source will be extracted into +the directory SDCCDIR/gc. +

    cpp ( C-Preprocessor)

    + +

    The preprocessor is extracted into the directory SDCCDIR/cpp, it is a modified +version of the GNU preprocessor. +

    asxxxx & aslink ( The assembler and Linkage Editor)

    + +

    This is retargettable assembler & linkage editor, it was developed +by Alan Baldwin, John Hartman created the version for 8051, and I (Sandeep) +have some enhancements and bug fixes for it to work properly with the SDCC. +This component is extracted into the directory SDCCDIR/asxxxx. +

    SDCC - The compiler.

    + +

    This is the actual compiler, it uses gc and invokes the assembler and linkage +editor. All files with the prefix SDCC are part of the compiler and is extracted +into the the directory SDCCDIR. +

    S51 - Simulator

    + +

    Version 2.1.8 onwards contains s51 a freeware , opensource simulator developed +by Daniel Drotos <drdani@mazsola.iit.uni-miskolc.hu>. The executable +is built as part of build process, for more information visit Daniel's website +at <http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51/>. +

    SDCDB - Source level Debugger.

    + +

    SDCDB is the companion source level debugger . The current version of the +debugger uses Daniel's Simulator S51, but can be easily changed to use other +simulators. +

    2.2 Installation for Version <= 2.1.7 +

    + +

    After the package is extracted (Windows 95/NT users start CYGWIN shell), +change to the directory where you extracted the package and give the command. +

    +

    +./sdccbuild.sh
    + 
    +
    +

    This is a bash shell script, it will compile all the above mentioned components +and install the executables into the directory SDCCDIR/bin make sure you add +this directory to your PATH environment variable. This script will also compile +all the support routines ( library routines ) using SDCC. The support routines +are all developed in C and need to be compiled. +

    2.3 Installation for Version >= 2.1.8a +

    + +

    The distribution method from Version 2.1.8a has been changed to be conforment +with the "autoconf" utility. The source is now distributed as sdcc-<version +number>.tar.gz format , instead of the older .zip format. The steps for +installation are as follows. +

    Unpack the sources.

    + +

    This is usually done by the following command "gunzip -c sdcc-<version +number>.tar.gz | tar -xv -" +

    Change to the main source directory (usually sdcc or sdcc-<version number>)

    + +

    Issue command to configure your system

    + +

    The configure command has several options the most commonly used option +is --prefix=<directory name>, where <directory name> is the final +location for the sdcc executables and libraries, (default location is /usr/local). +The installation process will create the following directory structure under +the <directory name> specified. +

    +

    +bin/ - binary exectables (add to PATH environment variable) 
    +share/ 
    +      sdcc51inc/
    + - include header files 
    +      sdcc51lib/ - 
    +             small/ - Object &
    + Library files for small model library 
    +             large/ - Object & library
    + files for large model library
    + 
    +
    +

    The command +

    './configure --prefix=/usr/local" +

    will create configure the compiler to be installed in directory /usr/local/bin. +

    make

    + +

    After configuration step issue the command +

    "make" +

    This will compile the compiler +

    "make install"

    + +

    Will install the compiler and libraries in the appropriate directories. +

    Special Notes for Windows Users. Provided by Michael Jamet[ mjamet@computer.org]

    + +

    +

    How to install SDCC from source on a Windows 95 or Windows NT 4 system +

    +

    +

    This document describes how to install SDCC on a Win 95 or Win NT 4 system. +

    +

    These instructions probably work for Win 98 as well, but have not been +

    +

    tested on that platform. +

    +

    There are lots of little differences between UNIX and the Win32 Cygnus +

    +

    environment which make porting more difficult than it should be. If +

    +

    you want the details, please contact me. Otherwise just follow these +

    +

    instructions. +

    +

    1. Install the Cygnus Software +

    Go to http://sourceware.cygnus.com/cygwin. Cygnus provides a UNIX like +

    +

    environment for Win 32 systems. Download "full.exe" and +install. You +

    MUST install it on your C drive. "full.exe" contains a shell +AND many +

    common UNIX utilities. +

    +

    2. Download and Extract the Latest SDCC +

    The latest version can be found at +

    www.geocities.com/ResearchTriange/Forum/1353. +

    It can be uncompressed with winzip. +

    +

    3. Start a Cygnus Shell +

    There should be an entry in the Start Menu for Cygnus. Invoke the shell. +

    +

    This gives you a UNIX like environment. FROM THIS POINT ON, DIRECTORIES +

    +

    MUST BE SPECIFIED WITH FORWARD SLASHES (/) NOT THE DOS STYLE BACK +

    SLASHES (\) BECAUSE THIS IS WHAT UNIX EXPECTS. - +

    ex. "\winnt" would be "/winnt" under the +shell. +

    +

    4. Change Directory to Where SDCC was extracted (referred to as INSTALLDIR) +

    +

    +

    ex. cd /sdcc218Da. If you extracted to a drive OTHER THAN C, the drive +

    +

    must be specified as part of the path. For example, if you extracted +to +

    your "g drive", type the following: "cd //g/mydir". +You must use "//" +

    to specify the drive. +

    +

    5. Make Dirs Which are Automatically Made During the UNIX Installation +

    +

    From the INSTALLDIR, +

    +

    mkdir -p bin (not a typo, just "bin") +

    mkdir -p /bin +

    mkdir -p /usr/local/bin +

    mkdir -p /usr/local/share +

    mkdir -p /usr/local/share/sdcc51lib +

    mkdir -p /usr/local/share/sdcc51inc +

    mkdir -p /tmp +

    +

    (When a path from the root directory is specified WITHOUT a drive, the +

    +

    drive defaults to c. For example /michael/newuser => c:\michael\newuser) +

    +

    +

    6. Add Programs to /bin Expected by the Installation Process +

    - Look at your path: echo $PATH +

    One of the fields is the diretory with the CYGNUS programs. +

    ex. /CYGNUS/CYGWIN~1/H-I586/BIN +

    +

    - cd to the directory found above. You may have to fiddle with the +

    +

    case (upper or lower) here because the PATH is SHOWN as all upper +

    +

    case, but is actually mixed. To help you along, you may type +

    a letter or 2 followed by the escape key. The shell will fill +

    out the remaining letters IF THEY describe a unique directory. +

    If you have problems here, cd one directory and type "ls". +"ls" +

    is the equivalent of "dir/w". +

    +

    - Copy the following: +

    cp sh.exe /bin +

    cp pwd.exe /bin +

    cp echo.exe /bin +

    +

    7. Go back to the INSTALLDIR +

    cd INSTALLDIR +

    ex. cd //d/sdcc218Da +

    +

    8. Run the configure Program +

    ./configure +

    The "./" is important because your current directory is NOT +in your path. +

    Under DOS, your current directory was implicitly always the first entry +

    +

    in your path. +

    +

    9. Run make +

    make +

    +

    This process takes quite some time under Win 32. +

    +

    10. Install the Newly Built Software +

    make install +

    +

    This will partially install the software into the /usr/local directories +

    +

    created in step 5. What it actually doing is copying the .c, .h and +

    +

    library files to directories under /usr/local/share. +

    +

    It will NOT be able to install the actual programs (binaries) because +

    +

    it does not know programs on Win32 systems have ".exe" extensions. +

    +

    For example, it tries to install sdcc instead of sdcc.exe. +

    +

    After the automated part is finished, you must manually copy the binaries: +

    +

    cd bin (This is the bin directory in your INSTALLDIR) +

    cp * /usr/local/bin +

    +

    11. Make sure /usr/local/bin is in Your PATH +

    You may add c:\usr\local\bin to your path however your +Win32 system allows. For +

    example you may add it to the PATH statement in autoexec.bat. +

    +

    Good luck. If you have any questions send them to me or post them +

    to the list. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-20.html b/doc/SDCCUdoc-20.html new file mode 100644 index 00000000..024b92f0 --- /dev/null +++ b/doc/SDCCUdoc-20.html @@ -0,0 +1,257 @@ + + + + + SDCC Compiler User Guide: Interfacing with assembly routines. + + + + + +Next +Previous +Contents +
    +

    20. Interfacing with assembly routines.

    + +

    20.1 Global registers used for parameter passing. +

    + +

    By default the compiler uses the global registers "DPL,DPH,B,ACC" to pass +the first parameter to a routine, the second parameter onwards is either allocated +on the stack (for reentrant routines or --stack-auto is used) or in the internal +/ external ram (depending on the memory model). +

    Assembler routine non-reentrant

    + +

    In the following example the function cfunc calls an assembler routine +asm_func, which takes two parameters. +

    extern int asm_func( unsigned short, unsigned short); +

    +

    + 
    +int c_func (unsigned short i, unsigned short j) 
    +{ 
    +        return
    + asm_func(i,j); 
    +} 
    +int main() 
    +{ 
    +   return c_func(10,9); 
    +}
    + 
    +
    +

    The corresponding assembler function is:- +

    +

    +        .globl _asm_func_PARM_2 
    +        .globl _asm_func 
    +        .area
    + OSEG 
    +_asm_func_PARM_2:       .ds      1 
    +        .area CSEG 
    +_asm_func: 
    +       
    + mov     a,dpl 
    +        add     a,_asm_func_PARM_2 
    +        mov     dpl,a 
    +       
    + mov     dpl,#0x00 
    +        ret
    + 
    +
    +

    Note here that the return values are placed in 'dpl' - One byte return +value, 'dpl' LSB & 'dph' MSB for two byte values. 'dpl', 'dph' and 'b' +for three byte values (generic pointers) and 'dpl','dph','b' & 'acc' for +four byte values. +

    The parameter naming convention is _<function_name>_PARM_<n>, +where n is the parameter number starting from 1, and counting from the left. +The first parameter is passed in "dpl" for One bye parameter, "dptr" if two bytes, +"b,dptr" for three bytes and "acc,b,dptr" for four bytes, the varaible name for +the second parameter will be _<function_name>_PARM_2. +

    Assemble the assembler routine with the following command. +

    +

    +asx8051 -losg asmfunc.asm
    + 
    +
    +

    Then compile and link the assembler routine to the C source file with the +following command, +

    +

    +sdcc cfunc.c asmfunc.rel
    + 
    +
    +

    Assembler routine is reentrant

    + +

    In this case the second parameter onwards will be passed on the stack , +the parameters are pushed from right to left i.e. after the call the left most +parameter will be on the top of the stack. Here is an example. +

    extern int asm_func( unsigned short, unsigned short); +

    +

    + int c_func (unsigned short i, unsigned short j) reentrant 
    +{ 
    +       
    + return asm_func(i,j); 
    +} 
    +int main() 
    +{ 
    +   return c_func(10,9);
    + 
    +}
    + 
    +
    +

    The corresponding assembler routine is. +

    +

    +        .globl _asm_func 
    +_asm_func: 
    +        push  _bp 
    +        mov  _bp,sp
    + 
    +        mov  r2,dpl
    +        mov  a,_bp 
    +        clr  c 
    +        add  a,#0xfd
    + 
    +        mov  r0,a 
    +        add  a,#0xfc
    +        mov  r1,a 
    +        mov 
    + a,@r0 
    +        add  a,r2
    +        mov  dpl,a 
    +        mov  dph,#0x00 
    +       
    + mov  sp,_bp 
    +        pop  _bp 
    +        ret
    + 
    +
    +

    The compiling and linking procedure remains the same, however note the +extra entry & exit linkage required for the assembler code, _bp is the +stack frame pointer and is used to compute the offset into the stack for parameters +and local variables. +

    20.2 With --noregparms option. +

    + +

    When the source is compiled with --noregparms option , space is allocated +for each of the parameters passed to a routine. +

    Assembler routine non-reentrant.

    + +

    In the following example the function cfunc calls an assembler routine +asm_func, which takes two parameters. +

    +

    +extern int asm_func( unsigned short, unsigned short); 
    +int c_func (unsigned short i, unsigned short j) 
    +{ 
    +        return
    + asm_func(i,j); 
    +} 
    +int main() 
    +{ 
    +   return c_func(10,9); 
    +}
    + 
    +
    +

    The corresponding assembler function is:- +

    +

    +        .globl _asm_func_PARM_1 
    +        .globl _asm_func_PARM_2 
    +       
    + .globl _asm_func 
    +        .area OSEG 
    +_asm_func_PARM_1:       .ds     1 
    +_asm_func_PARM_2:      
    + .ds      1 
    +        .area CSEG 
    +_asm_func: 
    +        mov     a,_asm_func_PARM_1
    + 
    +        add     a,_asm_func_PARM_2 
    +        mov     dpl,a 
    +        mov    
    + dpl,#0x00 
    +        ret
    + 
    +
    +

    Note here that the return values are placed in 'dpl' - One byte return +value, 'dpl' LSB & 'dph' MSB for two byte values. 'dpl', 'dph' and 'b' +for three byte values (generic pointers) and 'dpl','dph','b' & 'acc' for +four byte values. +

    The parameter naming convention is _<function_name>_PARM_<n>, +where n is the parameter number starting from 1, and counting from the left. +i.e. the left-most parameter name will be _<function_name>_PARM_1. +

    Assemble the assembler routine with the following command. +

    +

    +asx8051 -losg asmfunc.asm
    + 
    +
    +

    Then compile and link the assembler routine to the C source file with the +following command, +

    +

    +sdcc cfunc.c asmfunc.rel
    + 
    +
    +

    Assembler routine is reentrant.

    + +

    In this case the parameters will be passed on the stack , the parameters +are pushed from right to left i.e. after the call the left most parameter will +be on the top of the stack. Here is an example. +

    extern int asm_func( unsigned short, unsigned short); +

    +

    + int c_func (unsigned short i, unsigned short j) reentrant 
    +{ 
    +       
    + return asm_func(i,j); 
    +} 
    +int main() 
    +{ 
    +   return c_func(10,9);
    + 
    +}
    + 
    +
    +

    The corresponding assembler routine is. +

    +

    +        .globl _asm_func 
    +_asm_func: 
    +        push  _bp 
    +        mov  _bp,sp
    + 
    +        mov  a,_bp 
    +        clr  c 
    +        add  a,#0xfd 
    +        mov 
    + r0,a 
    +        mov  a,_bp 
    +        clr  c 
    +        add  a,#0xfc 
    +       
    + mov  r1,a 
    +        mov  a,@r0 
    +        add  a,@r1 
    +        mov  dpl,a 
    +       
    + mov  dph,#0x00 
    +        mov  sp,_bp 
    +        pop  _bp 
    +        ret
    + 
    +
    +

    The compiling and linking procedure remains the same, however note the +extra entry & exit linkage required for the assembler code, _bp is the +stack frame pointer and is used to compute the offset into the stack for parameters +and local variables. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-21.html b/doc/SDCCUdoc-21.html new file mode 100644 index 00000000..20a79076 --- /dev/null +++ b/doc/SDCCUdoc-21.html @@ -0,0 +1,32 @@ + + + + + SDCC Compiler User Guide: External Stack. + + + + + +Next +Previous +Contents +
    +

    21. External Stack.

    + +

    The external stack is located at the start of the external ram segment +, and is 256 bytes in size. When --xstack option is used to compile the program +, the parameters and local variables of all reentrant functions are allocated +in this area. This option is provided for programs with large stack space requirements. +When used with the --stack-auto option, all parameters and local variables +are allocated on the external stack (note support libraries will need to be +recompiled with the same options). +

    The compiler outputs the higher order address byte of the external ram +segment into PORT P2, therefore when using the External Stack option, this +port MAY NOT be used by the application program. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-22.html b/doc/SDCCUdoc-22.html new file mode 100644 index 00000000..90fbb02d --- /dev/null +++ b/doc/SDCCUdoc-22.html @@ -0,0 +1,91 @@ + + + + + SDCC Compiler User Guide: ANSI-Compliance. + + + + + +Next +Previous +Contents +
    +

    22. ANSI-Compliance.

    + +

    Deviations from the compliancy. +

    +

      +
    1. functions are not always reentrant.
    2. +
    3. structures cannot be assigned values directly, cannot be passed as function +parameters or assigned to each other and cannot be a return value from a function. +
      +eg
      +  
      +
      +
    4. +
    +

    +

    +struct s { ... }; 
    +struct s s1, s2; 
    +foo() 
    +{ 
    +... 
    +s1 =
    + s2 ; /* is invalid in SDCC although allowed in ANSI */ 
    +... 
    +}struct s foo1 (struct s parms) /* is invalid in SDCC although allowed in
    + ANSI */ 
    +{ 
    +struct s rets; 
    +... 
    +return rets;/* is invalid in SDCC although
    + allowed in ANSI */ 
    +}
    + 
    +
    +

    +

      +
    1. 'long long' (64 bit integers) not supported.
    2. +
    3. 'double' precision floating point not supported.
    4. +
    5. integral promotions are suppressed. What does this mean ? The compiler +will not implicitly promote an integer expression to a higher order integer, +exception is an assignment or parameter passing.
    6. +
    7. No support for setjmp and longjmp (for now).
    8. +
    9. Old K&R style function declarations are NOT allowed.
    10. +
    +

    +

    +foo( i,j) /* this old style of function declarations */ 
    +int i,j; /* are
    + valid in ANSI .. not valid in SDCC */ 
    +{ 
    +... 
    +}
    + 
    +
    +

    +

      +
    1. functions declared as pointers must be dereferenced during the call. +
      +int (*foo)();
      +  
      +
      +
    2. +
    +

    +

    +   ... 
    +   /* has to be called like this */ 
    +   (*foo)();/* ansi standard
    + allows calls to be made like 'foo()' */
    + 
    +
    +
    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-23.html b/doc/SDCCUdoc-23.html new file mode 100644 index 00000000..6191487f --- /dev/null +++ b/doc/SDCCUdoc-23.html @@ -0,0 +1,46 @@ + + + + + SDCC Compiler User Guide: Cyclomatic Complexity + + + + + +Next +Previous +Contents +
    +

    23. Cyclomatic Complexity

    + +

    Cyclomatic complexity of a function is defined as the number of independent +paths the program can take during execution of the function. This is an important +number since it defines the number test cases you have to generate to validate +the function . The accepted industry standard for complexity number is 10, +if the cyclomatic complexity reported by SDCC exceeds 10 you should think about +simplification of the function logic. +

    Note that the complexity level is not related to the number of lines of +code in a function. Large functions can have low complexity, and small functions +can have large complexity levels. SDCC uses the following formula to compute +the complexity. +

    +

    +complexity = (number of edges in control flow graph) - 
    +             (number
    + of nodes in control flow graph) + 2;
    + 
    +
    +

    Having said that the industry standard is 10, you should be aware that +in some cases it may unavoidable to have a complexity level of less than 10. +For example if you have switch statement with more than 10 case labels, each +case label adds one to the complexity level. The complexity level is by no +means an absolute measure of the algorithmic complexity of the function, it +does however provide a good starting point for which functions you might look +at for further optimization. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-24.html b/doc/SDCCUdoc-24.html new file mode 100644 index 00000000..f757d6b0 --- /dev/null +++ b/doc/SDCCUdoc-24.html @@ -0,0 +1,118 @@ + + + + + SDCC Compiler User Guide: TIPS + + + + + +Next +Previous +Contents +
    +

    24. TIPS

    + +

    Here are a few guide-lines that will help the compiler generate more efficient +code, some of the tips are specific to this compiler others are generally good +programming practice. +

    +

      +
    • Use the smallest data type to represent your data-value. If it is known +in advance that the value is going to be less than 256 then use a 'short' or +'char' instead of an 'int'.
    • +
    • Use unsigned when it is known in advance that the value is not going to +be negative. This helps especially if you are doing division or multiplication.
    • +
    • NEVER jump into a LOOP.
    • +
    • Declare the variables to be local whenever possible, especially loop control +variables (induction).
    • +
    • Since the compiler does not do implicit integral promotion, the programmer +should do an explicit cast when integral promotion is required.
    • +
    • Reducing the size of division , multiplication & modulus operations +can reduce code size substantially. Take the following code for example. +
      +foobar( unsigned int p1, unsigned char ch)
      +{
      +    unsigned char ch1
      + = p1 % ch ;
      +    ....    
      +}
      +  
      +
      + +

      For the modulus operation the variable ch will be promoted to unsigned +int first then the modulus operation will be performed (this will lead to a +call to a support routine). If the code is changed to + +

      +

      +foobar( unsigned int p1, unsigned char ch)
      +{
      +    unsigned char ch1
      + = (unsigned char)p1 % ch ;
      +    ....    
      +}
      +  
      +
      +

      It would substantially reduce the code generated (future versions of the +compiler will be smart enough to detect such optimization oppurtunities). +

    • +
    +

    Notes from an USER ( Trefor@magera.freeserve.co.uk ) +

    The 8051 family of micro controller have a minimum of 128 bytes of internal +memory which is structured as follows +

    - Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R7 to R7 +

    +

    - Bytes 20-2F - 16 bytes to hold 128 bit variables and +

    - Bytes 30-7F - 60 bytes for general purpose use. +

    Normally the SDCC compiler will only utilise the first bank of registers, +but it is possible to specify that other banks of registers should be used +in interrupt routines. By default, the compiler will place the stack after +the last bank of used registers, i.e. if the first 2 banks of registers are +used, it will position the base of the internal stack at address 16 (0X10). +This implies that as the stack grows, it will use up the remaining register +banks, and the 16 bytes used by the 128 bit variables, and 60 bytes for general +purpose use. +

    By default, the compiler uses the 60 general purpose bytes to hold "near +data". The compiler/optimiser may also declare some Local Variables in +this area to hold local data. +

    If any of the 128 bit variables are used, or near data is being used then +care needs to be taken to ensure that the stack does not grow so much that +it starts to over write either your bit variables or "near data". +There is no runtime checking to prevent this from happening. +

    The amount of stack being used is affected by the use of the "internal +stack" to save registers before a subroutine call is made, - --stack-auto +will declare parameters and local variables on the stack - the number of nested +subroutines. +

    If you detect that the stack is over writing you data, then the following +can be done. --xstack will cause an external stack to be used for saving registers +and (if --stack-auto is being used) storing parameters and local variables. +However this will produce more and code which will be slower to execute. +

    --stack-loc will allow you specify the start of the stack, i.e. you could +start it after any data in the general purpose area. However this may waste +the memory not used by the register banks and if the size of the "near +data" increases, it may creep into the bottom of the stack. +

    --stack-after-data, similar to the --stack-loc, but it automatically places +the stack after the end of the "near data". Again this could waste +any spare register space. +

    --data-loc allows you to specify the start address of the near data. This +could be used to move the "near data" further away from the stack +giving it more room to grow. This will only work if no bit variables are being +used and the stack can grow to use the bit variable space. +

    Conclusion. +

    If you find that the stack is over writing your bit variables or "near +data" then the approach which best utilised the internal memory is to +position the "near data" after the last bank of used registers +or, if you use bit variables, after the last bit variable by using the --data-loc, +e.g. if two register banks are being used and no data variables, --data-loc +16, and - use the --stack-after-data option. +

    If bit variables are being used, another method would be to try and squeeze +the data area in the unused register banks if it will fit, and start the stack +after the last bit variable. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-25.html b/doc/SDCCUdoc-25.html new file mode 100644 index 00000000..7809e017 --- /dev/null +++ b/doc/SDCCUdoc-25.html @@ -0,0 +1,73 @@ + + + + + SDCC Compiler User Guide: Retargetting for other MCUs. + + + + + +Next +Previous +Contents +
    +

    25. Retargetting for other MCUs.

    + +

    The issues for retargetting the compiler are far too numerous to be covered +by this document. What follows is a brief description of each of the seven +phases of the compiler and its MCU dependency. +

    +

      +
    1. Parsing the source and building the annotated parse tree. This phase is +largely MCU independent (except for the language extensions). Syntax & +semantic checks are also done in this phase , along with some initial optimizations +like back patching labels and the pattern matching optimizations like bit-rotation +etc.
    2. +
    3. The second phase involves generating an intermediate code which can be +easy manipulated during the later phases. This phase is entirely MCU independent. +The intermediate code generation assumes the target machine has unlimited number +of registers, and designates them with the name iTemp. The compiler can be +made to dump a human readable form of the code generated by using the --dumpraw +option.
    4. +
    5. This phase does the bulk of the standard optimizations and is also MCU +independent. This phase can be broken down into several sub-phases. +
        +
      • Break down intermediate code (iCode) into basic blocks.
      • +
      • Do control flow & data flow analysis on the basic blocks.
      • +
      • Do local common subexpression elimination, then global subexpression elimination
      • +
      • dead code elimination
      • +
      • loop optimizations
      • +
      • if loop optimizations caused any changes then do 'global subexpression +elimination' and 'dead code elimination' again.
      • +
      +
    6. +
    7. This phase determines the live-ranges; by live range I mean those iTemp +variables defined by the compiler that still survive after all the optimizations. +Live range analysis is essential for register allocation, since these computation +determines which of these iTemps will be assigned to registers, and for how +long.
    8. +
    9. Phase five is register allocation. There are two parts to this process +. +
        +
      1. The first part I call 'register packing' (for lack of a better term) . +In this case several MCU specific expression folding is done to reduce register +pressure.
      2. +
      3. The second part is more MCU independent and deals with allocating registers +to the remaining live ranges. A lot of MCU specific code does creep into this +phase because of the limited number of index registers available in the 8051.
      4. +
      +
    10. +
    11. The Code generation phase is (unhappily), entirely MCU dependent and very +little (if any at all) of this code can be reused for other MCU. However the +scheme for allocating a homogenized assembler operand for each iCode operand +may be reused.
    12. +
    13. As mentioned in the optimization section the peep-hole optimizer is rule +based system, which can reprogrammed for other MCUs.
    14. +
    +
    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-26.html b/doc/SDCCUdoc-26.html new file mode 100644 index 00000000..dfa33931 --- /dev/null +++ b/doc/SDCCUdoc-26.html @@ -0,0 +1,27 @@ + + + + + SDCC Compiler User Guide: Reporting Bugs + + + + + +Next +Previous +Contents +
    +

    26. Reporting Bugs

    + +

    Shoot of an email to 'sandeep.dutta@usa.net', as a matter of principle +I always reply to all email's sent to me. Bugs will be fixed ASAP. When reporting +a bug , it is useful to include a small snippet of code that is causing the +problem, if possible compile your program with the --dumpall option and send +the dump files along with the bug report. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-27.html b/doc/SDCCUdoc-27.html new file mode 100644 index 00000000..8ec850ba --- /dev/null +++ b/doc/SDCCUdoc-27.html @@ -0,0 +1,247 @@ + + + + + SDCC Compiler User Guide: SDCDB - Source level debugger. + + + + + +Next +Previous +Contents +
    +

    27. SDCDB - Source level debugger.

    + +

    SDCC is distributed with a source level debugger. The debugger uses a command +line interface, the command repertoire of the debugger has been kept as close +to gdb ( the GNU debugger) as possible. The configuration and build process +of the compiler see Installation + also builds and installs the debugger in +the target directory specified during configuration. The debugger allows you +debug BOTH at the C source and at the ASM source level. +

    27.1 Compiling for debugging. +

    + +

    The --debug option must be specified for all files for which debug information +is to be generated. The complier generates a .cdb file for each of these files. +The linker updates the .cdb file with the address information. This .cdb is +used by the debugger . +

    27.2 How the debugger works. +

    + +

    When the --debug option is specified the compiler generates extra symbol +information some of which are put into the the assembler source and some are +put into the .cdb file, the linker updates the .cdb file with the address information +for the symbols. The debugger reads the symbolic information generated by the +compiler & the address information generated by the linker. It uses the +SIMULATOR (Daniel's S51) to execute the program, the program execution is controlled +by the debugger. When a command is issued for the debugger, it translates it +into appropriate commands for the simulator . +

    27.3 Starting the debugger. +

    + +

    The debugger can be started using the following command line. (Assume the +file you are debugging has +

    the file name foo). +

    +

    +>sdcdb foo
    + 
    +
    +

    The debugger will look for the following files. +

    +

      +
    1. foo.c - the source file.
    2. +
    3. foo.cdb - the debugger symbol information file.
    4. +
    5. foo.ihx - the intel hex format object file.
    6. +
    +

    27.4 Command line options. +

    + +

    +

      +
    • --directory=<source file directory> this option can used to specify +the directory search list. The debugger will look into the directory list specified +for source , cdb & ihx files. The items in the directory list must be separated +by ':' , e.g. if the source files can be in the directories /home/src1 and +/home/src2, the --directory option should be --directory=/home/src1:/home/src2 +. Note there can be no spaces in the option.
    • +
    • -cd <directory> - change to the <directory>.
    • +
    • -fullname - used by GUI front ends.
    • +
    • -cpu <cpu-type> - this argument is passed to the simulator please +see the simulator docs for details.
    • +
    • -X <Clock frequency > this options is passed to the simulator please +see simulator docs for details.
    • +
    • -s <serial port file> passed to simulator see simulator docs for +details.
    • +
    • -S <serial in,out> passed to simulator see simulator docs for details.
    • +
    +

    27.5 Debugger Commands. +

    + +

    As mention earlier the command interface for the debugger has been deliberately +kept as close the GNU debugger gdb , as possible, this will help int integration +with existing graphical user interfaces (like ddd, xxgdb or xemacs) existing +for the GNU debugger. +

    break [line | file:line | function | file:function]

    + +

    Set breakpoint at specified line or function. +

    +

    +sdcdb>break 100 
    +sdcdb>break foo.c:100
    +sdcdb>break funcfoo
    +sdcdb>break
    + foo.c:funcfoo
    + 
    +
    +

    clear [line | file:line | function | file:function ]

    + +

    Clear breakpoint at specified line or function. +

    +

    +sdcdb>clear 100
    +sdcdb>clear foo.c:100
    +sdcdb>clear funcfoo
    +sdcdb>clear
    + foo.c:funcfoo
    + 
    +
    +

    continue

    + +

    Continue program being debugged, after breakpoint. +

    finish

    + +

    Execute till the end of the current function. +

    delete [n]

    + +

    Delete breakpoint number 'n'. If used without any option clear ALL user +defined break points. +

    info [break | stack | frame | registers ]

    + +

    +

      +
    • info break - list all breakpoints
    • +
    • info stack - show the function call stack.
    • +
    • info frame - show information about the current execution frame.
    • +
    • info registers - show content of all registers.
    • +
    +

    step

    + +

    Step program until it reaches a different source line. +

    next

    + +

    Step program, proceeding through subroutine calls. +

    run

    + +

    Start debugged program. +

    ptype variable

    + +

    Print type information of the variable. +

    print variable

    + +

    print value of variable. +

    file filename

    + +

    load the given file name. Note this is an alternate method of loading file +for debugging. +

    frame

    + +

    print information about current frame. +

    set srcmode

    + +

    Toggle between C source & assembly source. +

    ! simulator command

    + +

    Send the string following '!' to the simulator, the simulator response +is displayed. Note the debugger does not interpret the command being sent to +the simulator, so if a command like 'go' is sent the debugger can loose its +execution context and may display incorrect values. +

    quit.

    + +

    "Watch me now. Iam going Down. My name is Bobby Brown" +

    27.6 Interfacing with XEmacs. +

    + +

    Two files are (in emacs lisp) are provided for the interfacing with XEmacs, +sdcdb.el and sdcdbsrc.el. These two files can be found in the $(prefix)/bin +directory after the installation is complete. These files need to be loaded +into XEmacs for the interface to work, this can be done at XEmacs startup time +by inserting the following into your '.xemacs' file (which can be found in +your HOME directory) (load-file sdcdbsrc.el) [ .xemacs is a lisp file +so the () around the command is REQUIRED), the files can also be loaded dynamically +while XEmacs is running, set the environment variable 'EMACSLOADPATH' to the +installation bin directory [$(prefix)/bin], then enter the +following command ESC-x load-file sdcdbsrc . To start the interface enter the +following command ESC-x sdcdbsrc , you will prompted to enter the file name +to be debugged. +

    The command line options that are passed to the simulator directly are +bound to default values in the file sdcdbsrc.el the variables are listed below +these values maybe changed as required. +

    +

      +
    • sdcdbsrc-cpu-type '51
    • +
    • sdcdbsrc-frequency '11059200
    • +
    • sdcdbsrc-serial nil
    • +
    +

    The following is a list of key mapping for the debugger interface. +

    +

    + 
    +;; Current Listing :: 
    +;;key               binding                      Comment
    + 
    +;;---               -------                      ------- 
    +;; 
    +;; n              
    + sdcdb-next-from-src          SDCDB next command 
    +;; b               sdcdb-back-from-src          SDCDB
    + back command 
    +;; c               sdcdb-cont-from-src          SDCDB continue
    + command
    +;; s               sdcdb-step-from-src          SDCDB step command
    + 
    +;; ?               sdcdb-whatis-c-sexp          SDCDB ptypecommand for data
    + at 
    +;;                                           buffer point 
    +;; x              
    + sdcdbsrc-delete              SDCDB Delete all breakpoints if no arg 
    +;;                                              given
    + or delete arg (C-u arg x) 
    +;; m               sdcdbsrc-frame               SDCDB
    + Display current frame if no arg, 
    +;;                                              given
    + or display frame arg 
    +;;                                             buffer
    + point 
    +;; !               sdcdbsrc-goto-sdcdb          Goto the SDCDB output
    + buffer 
    +;; p               sdcdb-print-c-sexp           SDCDB print command
    + for data at 
    +;;                                           buffer point 
    +;;
    + g               sdcdbsrc-goto-sdcdb          Goto the SDCDB output buffer 
    +;;
    + t               sdcdbsrc-mode                Toggles Sdcdbsrc mode (turns it
    + off) 
    +;; 
    +;; C-c C-f         sdcdb-finish-from-src        SDCDB finish command
    + 
    +;; 
    +;; C-x SPC         sdcdb-break                  Set break for line with
    + point 
    +;; ESC t           sdcdbsrc-mode                Toggle Sdcdbsrc mode
    + 
    +;; ESC m           sdcdbsrc-srcmode             Toggle list mode 
    +;; 
    +
    + 
    +
    +
    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-28.html b/doc/SDCCUdoc-28.html new file mode 100644 index 00000000..cb2e167b --- /dev/null +++ b/doc/SDCCUdoc-28.html @@ -0,0 +1,30 @@ + + + + + SDCC Compiler User Guide: Conclusion + + + + + +Next +Previous +Contents +
    +

    28. Conclusion

    + +

    SDCC is a large project , the compiler alone (without the Assembler Package +, Preprocessor & garbage collector) is about 40,000 lines of code (blank +stripped). As with any project of this size there are bound to be bugs, I am +more than willing to work to fix these bugs , of course all the source code +is included with the package. +

    Where does it go from here ? I am planning to target the Atmel AVR 8-bit +MCUs which seems to have a lot of users. I am also planning to include an alias +analysis system with this compiler (it does not currently have one). +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-29.html b/doc/SDCCUdoc-29.html new file mode 100644 index 00000000..0c6aa382 --- /dev/null +++ b/doc/SDCCUdoc-29.html @@ -0,0 +1,33 @@ + + + + + SDCC Compiler User Guide: Acknowledgments + + + + +Next +Previous +Contents +
    +

    29. Acknowledgments

    + +

    Alan Baldwin (baldwin@shop-pdp.kent.edu) - Initial version of ASXXXX & +ASLINK. +

    John Hartman (jhartman@compuserve.com) - Porting ASXXX & ASLINK for +8051 +

    Dmitry S. Obukhov (dso@usa.net) - malloc & serial i/o routines. +

    Daniel Drotos <drdani@mazsola.iit.uni-miskolc.hu> - for his Freeware +simulator +

    Jans J Boehm(boehm@sgi.com) and Alan J Demers - Conservative garbage collector +for C & C++. +

    Malini Dutta(malini_dutta@hotmail.com) - my wife for her patience and support. +

    Unknown - for the GNU C - preprocessor. +

    +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-3.html b/doc/SDCCUdoc-3.html new file mode 100644 index 00000000..841d9860 --- /dev/null +++ b/doc/SDCCUdoc-3.html @@ -0,0 +1,100 @@ + + + + + SDCC Compiler User Guide: Compiling. + + + + + +Next +Previous +Contents +
    +

    3. Compiling.

    + +

    3.1 Single Source file projects. +

    + +

    For single source file projects the process is very simple. Compile your +programs with the following command +

    +

    +sdcc sourcefile.c
    + 
    +
    +

    The above command will compile ,assemble and link your source file. Output +files are as follows. +

    +

      +
    • sourcefile.asm - Assembler source file created by the compiler
    • +
    • sourcefile.lst - Assembler listing file created by the Assembler
    • +
    • sourcefile.rst - Assembler listing file updated with linkedit information +, created by linkage editor
    • +
    • sourcefile.sym - symbol listing for the sourcefile, created by the assembler.
    • +
    • sourcefile.rel - Object file created by the assembler, input to Linkage +editor.
    • +
    • sourcefile.map - The memory map for the load module, created by the Linker.
    • +
    • sourcefile.<ihx | s19> - The load module : ihx - Intel hex format +(default ), s19 - Motorola S19 format when compiler option --out-fmt-s19 is +used.
    • +
    +

    3.2 Projects with multiple source files. +

    + +

    SDCC can compile only ONE file at a time. Let us for example assume that +you have a project containing the following files. +

    +

    +foo1.c ( contains some functions )foo2.c (contains some more functions)foomain.c (contains more functions and the function main)
    + 
    +
    +

    The first two files will need to be compiled separately with the commands +

    +

    +sdcc -c foo1.csdcc -c foo2.c
    + 
    +
    +

    Then compile the source file containing main and link the other files together +with the following command. +

    +

    +sdcc foomain.c foo1.rel foo2.rel
    + 
    +
    +

    Alternatively foomain.c can be separately compiled as well +

    +

    +sdcc -c foomain.c sdcc foomain.rel foo1.rel foo2.rel
    + 
    +
    +

    The file containing the main function MUST be the FIRST file specified +in the command line , since the linkage editor processes file in the order +they are presented to it. +

    3.3 Projects with additional libraries. +

    + +

    Some reusable routines may be compiled into a library, see the documentation +for the assembler and linkage editor in the directory SDCCDIR/asxxxx/asxhtm.htm +this describes how to create a .lib library file, the libraries created in +this manner may be included using the command line, make sure you include the +-L <library-path> option to tell the linker where to look for these files. +Here is an example, assuming you have the source file 'foomain.c' and a library +'foolib.lib' in the directory 'mylib'. +

    +

    +sdcc foomain.c foolib.lib -L mylib
    + 
    +
    +

    Note here that 'mylib' must be an absolute path name. +

    The view of the way the linkage editor processes the library files, it +is recommended that you put each source routine in a separate file and combine +them using the .lib file. For an example see the standard library file 'libsdcc.lib' +in the directory SDCCDIR/sdcc51lib. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-4.html b/doc/SDCCUdoc-4.html new file mode 100644 index 00000000..7bcc9b40 --- /dev/null +++ b/doc/SDCCUdoc-4.html @@ -0,0 +1,260 @@ + + + + + SDCC Compiler User Guide: Command Line options + + + + + +Next +Previous +Contents +
    +

    4. Command Line options

    + +

    +

      +
    • --model-large + Generate code for Large model programs see section Memory +Models for more details. If this option is used all source files in the project +should be compiled with this option. In addition the standard library routines +are compiled with small model , they will need to be recompiled.
    • +
    • --model-small + Generate code for Small Model programs see section Memory +Models for more details. This is the default model.
    • +
    • --stack-auto + All functions in the source file will be compiled as reentrant, +i.e. the parameters and local variables will be allocated on the stack. see +section Parameters and Local Variables for more details. If this option is +used all source files in the project should be compiled with this option.
    • +
    • --xstack + Uses a pseudo stack in the first 256 bytes in the external ram +for allocating variables and passing parameters. See section on external stack +for more details.
    • +
    • --nogcse + Will not do global subexpression elimination, this option may +be used when the compiler creates undesirably large stack/data spaces to store +compiler temporaries. A warning message will be generated when this happens +and the compiler will indicate the number of extra bytes it allocated. It recommended +that this option NOT be used , #pragma NOGCSE can be used to turn off global +subexpression elimination for a given function only.
    • +
    • --noinvariant + Will not do loop invariant optimizations, this may be turned +off for reasons explained for the previous option . For more details of loop +optimizations performed see section Loop Invariants.It recommended that this +option NOT be used , #pragma NOINVARIANT can be used to turn off invariant +optimizations for a given function only.
    • +
    • --noinduction + Will not do loop induction optimizations, see section Strength +reduction for more details.It recommended that this option NOT be used , #pragma +NOINDUCTION can be used to turn off induction optimizations for given function +only.
    • +
    • --nojtbound + Will not generate boundary condition check when switch statements +are implemented using jump-tables. See section Switch Statements for more details.It +recommended that this option NOT be used , #pragma NOJTBOUND can be used +to turn off boundary checking for jump tables for a given function only.
    • +
    • --noloopreverse + Will not do loop reversal optimization
    • +
    • --noregparms + By default the first parameter is passed using global registers +(DPL,DPH,B,ACC). This option will disable parameter passing using registers. +NOTE: if your program uses the 16/32 bit support routines (for multiplication/division) +these library routines will need to be recompiled with the --noregparms option +as well.
    • +
    • --callee-saves function1[,function2][,function3].... + The compiler by default uses a caller saves convention for register saving +across function calls, however this can cause unneccessary register pushing +& popping when calling small functions from larger functions. This option +can be used to switch the register saving convention for the function names +specified. The compiler will not save registers when calling these functions, +extra code will be generated at the entry & exit for these functions to +save & restore the registers used by these functions, this can SUBSTANTIALLY +reduce code & improve run time performance of the generated code. In future +the compiler (with interprocedural analysis) will be able to determine the +appropriate scheme to use for each function call. DO NOT use this option for +built-in functions such as _muluint..., if this option is used for a library +function the appropriate library function needs to be recompiled with the same +option. If the project consists of multiple source files then all the source +file should be compiled with the same --callee-saves option string. Also see +Pragma Directive + CALLEE-SAVES. + .
    • +
    • --debug + When this option is used the compiler will generate debug information +, that can be used with the SDCDB. The debug information is collected in a +file with .cdb extension. For more information see documentation for SDCDB.
    • +
    • --regextend + This option will cause the compiler to define pseudo registers +, if this option is used, all source files in the project should be compiled +with this option. See section Register Extension for more details.
    • +
    • --compile-only(-c) + will compile and assemble the source only, will not +call the linkage editor.
    • +
    • --xram-loc + <Value> The start location of the external ram, default +value is 0. The value entered can be in Hexadecimal or Decimal format .eg. +--xram-loc 0x8000 or --xram-loc 32768.
    • +
    • --code-loc + <Value> The start location of the code segment , default +value 0. Note when this option is used the interrupt vector table is also relocated +to the given address. The value entered can be in Hexadecimal or Decimal format +.eg. --code-loc 0x8000 or --code-loc 32768.
    • +
    • --stack-loc + <Value> The initial value of the stack pointer. The default +value of the stack pointer is 0x07 if only register bank 0 is used, if other +register banks are used then the stack pointer is initialized to the location +above the highest register bank used. eg. if register banks 1 & 2 are used +the stack pointer will default to location 0x18. The value entered can be in +Hexadecimal or Decimal format .eg. --stack-loc 0x20 or --stack-loc 32. If all +four register banks are used the stack will be placed after the data segment +(equivalent to --stack-after-data)
    • +
    • --stack-after-data + This option will cause the stack to be located in the +internal ram after the data segment.
    • +
    • --data-loc + <Value> The start location of the internal ram data segment, +the default value is 0x30.The value entered can be in Hexadecimal or Decimal +format .eg. --data-loc 0x20 or --data-loc 32.
    • +
    • --idata-loc + <Value> The start location of the indirectly addressable +internal ram, default value is 0x80. The value entered can be in Hexadecimal +or Decimal format .eg. --idata-loc 0x88 or --idata-loc 136.
    • +
    • --peep-file + <filename> This option can be used to use additional +rules to be used by the peep hole optimizer. See section Peep Hole optimizations +for details on how to write these rules.
    • +
    • --lib-path (-L) + <absolute path to additional libraries> This option +is passed to the linkage editor, additional libraries search path. The path +name must be absolute. Additional library files may be specified in the command +line . See section Compiling programs for more details.
    • +
    • -I <path> + The additional location where the pre processor will look +for <..h> or "..h" files.
    • +
    • -D<macro[=value]> + Command line definition of macros. Passed +to the pre processor.
    • +
    • -E + Run only the C preprocessor. Preprocess all the C source files specified +and output the results to standard output.
    • +
    • -M + Tell the preprocessor to output a rule suitable for make describing +the dependencies of each object file. For each source file, the preprocessor +outputs one make-rule whose target is the object file name for that source +file and whose dependencies are all the files `#include'd in it. This rule +may be a single line or may be continued with `\'-newline if it is long. +The list of rules is printed on standard output instead of the preprocessed +C program. `-M' implies `-E'.
    • +
    • -C + Tell the preprocessor not to discard comments. Used with the `-E' option.
    • +
    • -MM + Like `-M' but the output mentions only the user header files included +with `#include file"'. System header files included with `#include +<file>' are omitted.
    • +
    • -Aquestion(answer) + Assert the answer answer for question, in case it is +tested with a preprocessor conditional such as `#if #question(answer)'. +`-A-' disables the standard asser- tions that normally describe the target +machine.
    • +
    • -Aquestion + (answer) Assert the answer answer for question, in case it is +tested with a preprocessor conditional such as `#if #question(answer)'. +`-A-' disables the standard assertions that normally describe the target machine.
    • +
    • -Umacro + Undefine macro macro. `-U' options are evaluated after all `-D' +options, but before any `-include' and `-imac- ros' options.
    • +
    • -dM + Tell the preprocessor to output only a list of the mac- ro definitions +that are in effect at the end of prepro- cessing. Used with the `-E' option.
    • +
    • -dD + Tell the preprocessor to pass all macro definitions into the output, +in their proper sequence in the rest of the output.
    • +
    • -dN + Like `-dD' except that the macro arguments and contents are omitted. +Only `#define name' is included in the output.
    • +
    • -S + Stop after the stage of compilation proper; do not as- semble. The output +is an assembler code file for the input file specified.
    • +
    • -Wa asmOption[,asmOption]... Pass the asmOption to the assembler
    • +
    • -Wl linkOption[,linkOption] .. Pass the linkOption to the linker.
    • +
    • --int-long-reent + Integer (16 bit) and long (32 bit) libraries have been +compiled as reentrant. Note by default these libraries are compiled as non-reentrant. +See section Installation for more details.
    • +
    • --cyclomatic + This option will cause the compiler to generate an information +message for each function in the source file. The message contains some important +information about the function. The number of edges and nodes the compiler +detected in the control flow graph of the function, and most importantly the +cyclomatic complexity see section on Cyclomatic Complexity for more details.
    • +
    • --float-reent + Floating point library is compiled as reentrant.See section +Installation for more details.
    • +
    • --out-fmt-ihx + The linker output (final object code) is in Intel Hex format. +(This is the default option).
    • +
    • --out-fmt-s19 + The linker output (final object code) is in Motorola S19 +format.
    • +
    • --nooverlay + The compiler will not overlay parameters and local variables +of any function, see section Parameters and local variables for more details.
    • +
    • --main-return + This option can be used when the code generated is called +by a monitor program. The compiler will generate a 'ret' upon return from the +'main' function. The default option is to lock up i.e. generate a 'ljmp .' +.
    • +
    • --no-peep + Disable peep-hole optimization.
    • +
    • --peep-asm + Pass the inline assembler code through the peep hole optimizer. +Can cause unexpected changes to inline assembler code , please go through the +peephole optimizer rules defnied in file 'SDCCpeeph.def' before using this +option.
    • +
    • --iram-size + <Value> Causes the linker to check if the interal ram +usage is within limits of the given value.
    • +
    +

    The following options are provided for the purpose of retargetting and +debugging the compiler . These provided a means to dump the intermediate code +(iCode) generated by the compiler in human readable form at various stages +of the compilation process. +

    +

      +
    • --dumpraw + . This option will cause the compiler to dump the intermediate +code into a file of named <source filename>.dumpraw just after the intermediate +code has been generated for a function , i.e. before any optimizations are +done. The basic blocks at this stage ordered in the depth first number, so +they may not be in sequence of execution.
    • +
    • --dumpgcse. + Will create a dump if iCode, after global subexpression elimination, +into a file named <source filename>.dumpgcse.
    • +
    • --dumpdeadcode + .Will create a dump if iCode, after deadcode elimination, +into a file named <source filename>.dumpdeadcode.
    • +
    • --dumploop. + Will create a dump if iCode, after loop optimizations, into +a file named <source filename>.dumploop.
    • +
    • --dumprange. + Will create a dump if iCode, after live range analysis, into +a file named <source filename>.dumprange.
    • +
    • --dumpregassign. + Will create a dump if iCode, after register assignment +, into a file named <source filename>.dumprassgn.
    • +
    • --dumpall. + Will cause all the above mentioned dumps to be created.
    • +
    +

    Note that the files created for the dump are appended to each time. So +the files should be deleted manually , before each dump is created. +

    When reporting bugs, it will be very helpful if you could include these +dumps along with the portion of the code that is causing the problem. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-5.html b/doc/SDCCUdoc-5.html new file mode 100644 index 00000000..09b37924 --- /dev/null +++ b/doc/SDCCUdoc-5.html @@ -0,0 +1,55 @@ + + + + + SDCC Compiler User Guide: Language Extensions + + + + + +Next +Previous +Contents +
    +

    5. Language Extensions

    + +

    5.1 Storage Classes. +

    + +

    In addition to the ANSI storage classes SDCC allows the following 8051 +specific storage classes. +

    xdata.

    + +

    Variables declared with this storage class will be placed in the extern +RAM. This is the default storage class for Large Memory model . +

    eg. xdata unsigned char xduc; +

    data

    + +

    This is the default storage class for Small Memory model. Variables declared +with this storage class will be allocated in the internal RAM. +

    eg. data int iramdata; +

    idata

    + +

    Variables declared with this storage class will be allocated into the indirectly +addressable portion of the internal ram of a 8051 . +

    eg.idata int idi; +

    bit

    + +

    This is a data-type and a storage class specifier. When a variable is declared +as a bit , it is allocated into the bit addressable memory of 8051. +

    eg.bit iFlag; +

    sfr / sbit

    + +

    Like the bit keyword, sfr / sbit signifies both a data-type and storage +class, they are used to describe the special function registers and special +bit variables of a 8051. +

    eg. +

    sfr at 0x80 P0; /* special function register P0 at location 0x80 */ +

    sbit at 0xd7 CY; /* CY (Carry Flag) */ +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-6.html b/doc/SDCCUdoc-6.html new file mode 100644 index 00000000..a99ad6aa --- /dev/null +++ b/doc/SDCCUdoc-6.html @@ -0,0 +1,532 @@ + + + + + SDCC Compiler User Guide: Optimizations + + + + + +Next +Previous +Contents +
    +

    6. Optimizations

    + +

    SDCC performs a a host of standard optimizations in addition to some MCU +specific optimizations. +

    6.1 Sub-expression elimination +

    + +

    The compiler does local and global common subexpression elimination. +

    eg. +

    +

    +i = x + y + 1; 
    +j = x + y;
    + 
    +
    +

    will be translated to +

    +

    +iTemp = x + y 
    +i = iTemp + 1 
    +j = iTemp
    + 
    +
    +

    Some subexpressions are not as obvious as the above example. +

    eg. +

    +

    +a->b[i].c = 10; 
    +a->b[i].d = 11;
    + 
    +
    +

    In this case the address arithmetic a->b[i] will be computed +only once; the equivalent code in C would be. +

    +

    +iTemp = a->b[i]; 
    +iTemp.c = 10; 
    +iTemp.d = 11;
    + 
    +
    +

    The compiler will try to keep these temporary variables in registers. +

    6.2 Dead-Code elimination. +

    + +

    eg. +

    +

    +int global; 
    +void f () { 
    +  int i; 
    +  i = 1;    /* dead store */ 
    +  global
    + = 1; /* dead store */ 
    +  global = 2; 
    +  return; 
    +  global = 3; /* unreachable
    + */ 
    +}
    + 
    +
    +

    will be changed to +

    +

    +int global; void f () 
    +{     
    + global = 2;     
    + return; 
    +}
    + 
    +
    +

    6.3 Copy-Propagation: +

    + +

    eg. +

    +

    +int f() { 
    +   int i, j; 
    +   i = 10; 
    +   j = i; 
    +   return j; 
    +}
    + 
    +
    +

    will be changed to +

    +

    +int f() { 
    +    int i,j; 
    +    i = 10; 
    +    j = 10; 
    +    return 10;
    + 
    +}
    + 
    +
    +

    Note: the dead stores created by this copy propagation will be eliminated +by dead-code elimination . +

    6.4 Loop optimizations +

    + +

    Two types of loop optimizations are done by SDCC loop invariant lifting +and strength reduction of loop induction variables.In addition to the strength +reduction the optimizer marks the induction variables and the register allocator +tries to keep the induction variables in registers for the duration of the +loop. Because of this preference of the register allocator , loop induction +optimization causes an increase in register pressure, which may cause unwanted +spilling of other temporary variables into the stack / data space . The compiler +will generate a warning message when it is forced to allocate extra space either +on the stack or data space. If this extra space allocation is undesirable then +induction optimization can be eliminated either for the entire source file +( with --noinduction option) or for a given function only (#pragma NOINDUCTION). +

    Loop Invariant:

    + +

    eg +

    +

    +for (i = 0 ; i < 100 ; i ++) 
    +     f += k + l;
    + 
    +
    +

    changed to +

    +

    +itemp = k + l; 
    +for ( i = 0; i < 100; i++ ) f += itemp;
    + 
    +
    +

    As mentioned previously some loop invariants are not as apparent, all static +address computations are also moved out of the loop. +

    Strength reduction :

    + +

    This optimization substitutes an expression by a cheaper expression. +

    eg. +

    +

    +for (i=0;i < 100; i++) ar[i*5] = i*3;
    + 
    +
    +

    changed to +

    +

    +itemp1 = 0; 
    +itemp2 = 0; 
    +for (i=0;i< 100;i++) { 
    +     ar[itemp1]
    + = itemp2; 
    +     itemp1 += 5; 
    +     itemp2 += 3; 
    +}
    + 
    +
    +

    The more expensive multiplication is changed to a less expensive addition. +

    Loop reversing:

    + +

    This optimization is done to reduce the overhead of checking loop boundaries +for every iteration. Some simple loops can be reversed and implemented using +a "decrement and jump if not zero" instruction. SDCC checks for the following +criterion to determine if a loop is reversible (note: more sophisticated compiers +use data-dependency analysis to make this determination, SDCC uses a more simple +minded analysis). +

    +

      +
    • The 'for' loop is of the form +"for ( <symbol> = <expression> +; <sym> [< | <=] <expression> ; [<sym>++ +| <sym> += 1]) +<for body>"
    • +
    • The <for body> does not contain "continue" or 'break".
    • +
    • All goto's are contained within the loop.
    • +
    • No function calls within the loop.
    • +
    • The loop control variable <sym> is not assigned any value within +the loop
    • +
    • The loop control variable does NOT participate in any arithmetic operation +within the loop.
    • +
    • There are NO switch statements in the loop.
    • +
    +

    Note djnz instruction can be used for 8-bit values ONLY, therefore it is +advantageous to declare loop control symbols as either 'char' or 'short', ofcourse +this may not be possible on all situations. +

    6.5 Algebraic simplifications: +

    + +

    SDCC does numerous algebraic simplifications, the following is a small +sub-set of these optimizations. +

    +

    +eg 
    +i = j + 0 ; /* changed to */ i = j; 
    +i /= 2; /* changed to */ i >>=
    + 1; 
    +i = j - j ; /* changed to */ i = 0; 
    +i = j / 1 ; /* changed to */ i = j;
    + 
    +
    +

    Note the subexpressions given above are generally introduced by macro expansions +or as a result of copy/constant propagation. +

    6.6 'switch' statements. +

    + +

    SDCC changes switch statements to jump tables when the following conditions +are true. +

    +

      +
    • The case labels are in numerical sequence , the labels need not be in order, +and the starting number need not be one or zero.
    • +
    +

    eg +

    +

    +switch(i) {                         switch (i) { 
    +case 4:...
    +                          case 1: ... 
    +case 5:...                          case
    + 2: ... 
    +case 3:...                          case 3: ... 
    +case 6:...        
    +                  case 4: ... 
    +}                                   }
    + 
    +
    +

    Both the above switch statements will be implemented using a jump-table. +

    +

      +
    • The number of case labels is at least three, since it takes two conditional +statements to handle the boundary conditions.
    • +
    • The number of case labels is less than 84, since each label takes 3 bytes +and a jump-table can be utmost 256 bytes long.
    • +
    +

    Switch statements which have gaps in the numeric sequence or those that +have more that 84 case labels can be split into more than one switch statement +for efficient code generation. +

    eg +

    +

    +switch (i) { 
    +case 1: ... 
    +case 2: ... 
    +case 3: ... 
    +case 4: ... 
    +case
    + 9: ... 
    +case 10: ... 
    +case 11: ... 
    +case 12: ... 
    +}
    + 
    +
    +

    If the above switch statement is broken down into two switch statements +

    +

    +switch (i) { 
    +case 1: ... 
    +case 2: ... 
    +case 3: ... 
    +case 4: ... 
    +}switch (i) { 
    +case 9: ... 
    +case 10: ... 
    +case 11: ... 
    +case 12:...
    + 
    +}
    + 
    +
    +

    then both the switch statements will be implemented using jump-tables whereas +the unmodified switch statement will not be . +

    6.7 bit-shifting operations. +

    + +

    Bit shifting is one of the most frequently used operation in embedded programming +. SDCC tries to implement bit-shift operations in the most efficient way possible. +

    eg. +

    +

    +unsigned short i;... 
    +i>>= 4; 
    +..
    + 
    +
    +

    generates the following code. +

    +

    +mov a,_i 
    +swap a 
    +anl a,#0x0f 
    +mov _i,a
    + 
    +
    +

    In general SDCC will never setup a loop if the shift count is known. Another +example +

    +

    +unsigned int i; 
    +... 
    +i >>= 9; 
    +...
    + 
    +
    +

    will generate +

    +

    +mov a,(_i + 1) 
    +mov (_i + 1),#0x00 
    +clr c 
    +rrc a 
    +mov _i,a
    + 
    +
    +

    Note that SDCC stores numbers in little-endian format (i.e. lowest order +first) +

    Bit-rotation:

    + +

    A special case of the bit-shift operation is bit rotation, SDCC recognizes +the following expression to be a left bit-rotation. +

    +

    +unsigned char i; 
    +... 
    +i = ( ( i << 1) | ( i >> 7)); 
    +...
    + 
    +
    +

    will generate the following code. +

    +

    +mov a,_i 
    +rl a 
    +mov _i,a
    + 
    +
    +

    SDCC uses pattern matching on the parse tree to determine this operation +.Variations of this case will also be recognized as bit-rotation i.e i = ((i +>> 7) | (i << 1)); /* left-bit rotation */ +

    6.8 Highest Order Bit. +

    + +

    It is frequently required to obtain the highest order bit of an integral +type (int,long,short or char types). SDCC recognizes the following expression +to yield the highest order bit and generates optimized code for it. +

    +

    +eg 
    +unsigned int gint; 
    +foo () { 
    +unsigned char hob; 
    +   ... 
    +   hob
    + = (gint >> 15) & 1; 
    +   .. 
    +}
    + 
    +
    +

    Will generate the following code. +

    +

    +                             61 ;  hob.c 7 
    +   000A E5*01               
    + 62         mov  a,(_gint + 1) 
    +   000C 33                   63         rlc 
    + a 
    +   000D E4                   64         clr  a 
    +   000E 13                  
    + 65         rrc  a 
    +   000F F5*02                66         mov  _foo_hob_1_1,a
    + 
    +
    +

    Variations of this case however will NOT be recognized . It is a standard +C expression , so I heartily recommend this be the only way to get the highest +order bit, (it is portable). Of course it will be recognized even if it is +embedded in other expressions. +

    +

    +eg.xyz = gint + ((gint >> 15) & 1);
    + 
    +
    +

    will still be recognized. +

    6.9 Peep-hole optimizer. +

    + +

    The compiler uses a rule based , pattern matching and re-writing mechanism +for peep-hole optimization . It is inspired by 'copt' a peep-hole optimizer +by Christopher W. Fraser (cwfraser@microsoft.com). A default set of rules are +compiled into the compiler, additional rules may be added with the --peep-file +<filename> option. The rule language is best illustrated with examples. +

    +

    +replace { 
    +mov %1,a 
    +mov a,%1 } by { mov %1,a
    + }
    + 
    +
    +

    The above rule will the following assembly sequence +

    +

    +mov r1,a 
    +mov a,r1
    + 
    +
    +

    to +

    +

    +mov r1,a
    + 
    +
    +

    Note: All occurrences of a '%n' ( pattern variable ) must denote +the same string. With the above rule, the assembly sequence +

    +

    +mov r1,a 
    +mov a,r2
    + 
    +
    +

    will remain unmodified. Other special case optimizations may be added by +the user (via --peep-file option), eg. some variants of the 8051 MCU allow +only 'AJMP' and 'ACALL' , the following two rules will change all 'LJMP' & +'LCALL' to 'AJMP' & 'ACALL'. +

    +

    +replace { lcall %1 } by { acall %1 }
    + 
    +replace { ljmp %1 } by { ajmp %1 }
    + 
    +
    +

    The inline-assembler' code is also passed through the peep hole optimizer, +thus the peephole optimizer can also be used as an assembly level macro expander. +The rules themselves are MCU dependent whereas the rule language infra-structure +is MCU independent. Peephole optimization rules for other MCU can be easily +programmed using the rule language. +

    The syntax for a rule is as follows , +

    +

    +rule := replace [ restart ] '{' <assembly sequence>
    + '\n' 
    +                            '}' by '{' '\n' 
    +   
    +                             <assembly sequence> '\n' 
    +         
    +                   '}' [if <functionName> ] '\n' 
    +<assembly
    + sequence> := assembly instruction (each instruction including labels must
    + be on a separate line).   
    + 
    +
    +

    The optimizer will apply to the rules one by one from the top in the sequence +of their appearance, it will terminate when all rules are exhausted. If the +'restart' option is specified, then the optimizer will start matching the rules +again from the top, this option for a rule is expensive (performance), it is +intended to be used in situations where a transformation will trigger the same +rule again. A good example of this the following rule. +

    +

    +replace restart { 
    +pop %1 
    +push %1 } by {
    + 
    +; nop 
    +}
    + 
    +
    +

    Note that the replace pattern cannot be a blank, but can be a comment line. +Without the 'restart' option only the inner most 'pop' 'push' pair would be +eliminated. i.e. +

    +

    +pop ar1 
    +pop ar2 
    +push ar2 
    +push ar1
    + 
    +
    +

    would result in +

    +

    +pop ar1 
    +; nop 
    +push ar1
    + 
    +
    +

    with the 'restart' option the rule will be applied again to the resulting +code and the all the 'pop' 'push' pairs will be eliminated to yield +

    +

    +; nop 
    +; nop
    + 
    +
    +

    A conditional function can be attached to a rule. Attaching rules are somewhat +more involved, let me illustrate this with an example. +

    +

    +replace { 
    +     ljmp %5 
    +%2:} by { 
    +     sjmp
    + %5 
    +%2:} if labelInRange
    + 
    +
    +

    The optimizer does a look-up of a function name table defined in function +'callFuncByName' in the source file SDCCpeeph.c , with the name 'labelInRange', +if it finds a corresponding entry the function is called. Note there can be +no parameters specified for these functions, in this case the use of '%5' +is crucial, since the function labelInRange expects to find the label in that +particular variable (the hash table containing the variable bindings is passed +as a parameter). If you want to code more such functions , take a close look +at the function labelInRange and the calling mechanism in source file SDCCpeeph.c. +I know this whole thing is a little kludgey , may be some day we will have +some better means. If you are looking at this file, you will also see the default +rules that are compiled into the compiler, you can your own rules in the default +set there if you get tired of specifying the --peep-file option. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-7.html b/doc/SDCCUdoc-7.html new file mode 100644 index 00000000..e7fa3fdc --- /dev/null +++ b/doc/SDCCUdoc-7.html @@ -0,0 +1,71 @@ + + + + + SDCC Compiler User Guide: Pointers + + + + + +Next +Previous +Contents +
    +

    7. Pointers

    + +

    SDCC allows (via language extensions) pointers to explicitly point to any +of the memory spaces of the 8051. In addition to the explicit pointers, the +compiler also allows a _generic class of pointers which can be used to point +to any of the memory spaces. +

    Pointer declaration examples. +

    +

    +/* pointer physically in xternal ram pointing to object in internal ram
    + */ 
    +data unsigned char * xdata p;
    +/* pointer physically in code rom pointing to data in xdata space */ 
    +xdata
    + unsigned char * code p;
    +/* pointer physically in code space pointing to data in code space */ 
    +code
    + unsigned char * code p;
    +
    +/* the folowing is a generic pointer physically located
    + in xdata space */
    +char * xdata p;
    + 
    +
    +

    Well you get the idea. For compatibility with the previous version of the +compiler, the following syntax for pointer declaration is also supported. Note +the above examples will be portable to other commercially available compilers. +

    +

    +unsigned char _xdata *ucxdp; /* pointer to data in external ram */ 
    +unsigned
    + char _data  *ucdp ; /* pointer to data in internal ram */ 
    +unsigned char _code
    +  *uccp ; /* pointer to data in R/O code space */
    +unsigned char _idata *uccp;
    +  /* pointer to upper 128 bytes of ram */
    + 
    +
    +

    All unqualified pointers are treated as 3 - byte '_generic' pointers. These +type of pointers can also to be explicitly declared. +

    +

    +unsigned char _generic *ucgp;
    + 
    +
    +

    The highest order byte of the generic pointers contains the data space +information. Assembler support routines are called whenever data is stored +or retrieved using _generic pointers. These are useful for developing reusable +library routines. Explicitly specifying the pointer type will generate the +most efficient code. Pointers declared using a mixture of OLD/NEW style could +have unpredictable results. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-8.html b/doc/SDCCUdoc-8.html new file mode 100644 index 00000000..8efb5dae --- /dev/null +++ b/doc/SDCCUdoc-8.html @@ -0,0 +1,106 @@ + + + + + SDCC Compiler User Guide: Parameters & Local Variables + + + + + +Next +Previous +Contents +
    +

    8. Parameters & Local Variables

    + +

    Automatic (local) variables and parameters to functions can either be placed +on the stack or in data-space. The default action of the compiler is to place +these variables in the internal RAM ( for small model) or external RAM (for +Large model). They can be placed on the stack either by using the --stack-auto +compiler option or by using the 'reentrant' keyword in the function declaration. +

    eg +

    +

    +unsigned short foo( short i) reentrant { 
    +... 
    +}
    + 
    +
    +

    Note that when the parameters & local variables are declared in the +internal/external ram the functions are non-reentrant. Since stack space on +8051 is limited the 'reentrant' keyword or the --stack-auto option should be +used sparingly. Note the reentrant keyword just means that the parameters & +local variables will be allocated to the stack, it DOES NOT mean that the function +is register bank independent. +

    When compiled with the default option (i.e. non-reentrant ), local variables +can be assigned storage classes and absolute addresses. +

    eg +

    +

    +unsigned short foo() { 
    +   xdata unsigned short i; 
    +   bit bvar; 
    + 
    +  data at 0x31 unsiged short j; 
    +... 
    +}
    + 
    +
    +

    In the above example the variable i will be allocated in the external ram, +bvar in bit addressable space and j in internal ram. When compiled with the +--stack-auto or when a function is declared as 'reentrant' local variables +cannot be assigned storage classes or absolute addresses. +

    Parameters however are not allowed any storage class, (storage classes +for parameters will be ignored), their allocation is governed by the memory +model in use , and the reentrancy options. +

    8.1 Overlaying +

    + +

    For non-reentrant functions SDCC will try to reduce internal ram space +usage by overlaying parameters and local variables of a function (if possible). +Parameters and local variables of a function will be allocated to an overlayable +segment if the function has no other function calls and the function is non-reentrant +and the memory model is small. If an explicit storage class is specified for +a local variable , it will NOT be overplayed. +

    Note that the compiler (not the linkage editor) makes the decision for +overlaying the data items. Functions that are called from an interrupt service +routine should be preceded by a #pragma NOOVERLAY if they are not reentrant +Along the same lines the compiler does not do any processing with the inline +assembler code so the compiler might incorrectly assign local variables and +parameters of a function into the overlay segment if the only function call +from a function is from inline assembler code, it is safe to use the #pragma +NOOVERLAY for functions which call other functions using inline assembler code. +

    Parameters and Local variables of functions that contain 16 or 32 bit multiplication +or division will NOT be overlayed since these are implemented using external +functions. +

    eg. +

    +

    +#pragma SAVE 
    +#pragma NOOVERLAY 
    +void set_error( unsigned short
    + errcd) 
    +{ 
    +    P3 = errcd; 
    +} 
    +#pragma RESTORE 
    +void some_isr
    + () interrupt 2 using 1 
    +{ 
    +    ... 
    +    set_error(10); 
    +    ... 
    +}
    + 
    +
    +

    In the above example the parameter errcd for the function set_error would +be assigned to the overlayable segment (if the #pragma NOOVERLAY was not +present) , this could cause unpredictable runtime behavior. The pragma NOOVERLAY +ensures that the parameters and local variables for the function are NOT overlayed. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc-9.html b/doc/SDCCUdoc-9.html new file mode 100644 index 00000000..4d9cfe1a --- /dev/null +++ b/doc/SDCCUdoc-9.html @@ -0,0 +1,37 @@ + + + + + SDCC Compiler User Guide: critical Functions. + + + + + +Next +Previous +Contents +
    +

    9. critical Functions.

    + +

    A special keyword may be associated with a function declaring it as 'critical'. +SDCC will generate code to disable all interrupts upon entry to a critical +function and enable them back before returning . Note that nesting critical +functions may cause unpredictable results. +

    eg +

    +

    +int foo () critical 
    +{ 
    +... 
    +... 
    +}
    + 
    +
    +

    The critical attribute maybe used with other attributes like reentrant. +


    +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc.html b/doc/SDCCUdoc.html new file mode 100644 index 00000000..ce4134ae --- /dev/null +++ b/doc/SDCCUdoc.html @@ -0,0 +1,219 @@ + + + + + SDCC Compiler User Guide + + + + + +Next +Previous +Contents +
    +

    SDCC Compiler User Guide

    + +

    Sandeep Dutta (sandeep.dutta@usa.net)

    +

    +

    1. Introduction

    + +

    +

    2. Installation

    + +
      +
    • 2.1 Components of SDCC +
    • 2.2 Installation for Version <= 2.1.7 +
    • 2.3 Installation for Version >= 2.1.8a +

      +

      3. Compiling.

      + +
        +
      • 3.1 Single Source file projects. +
      • 3.2 Projects with multiple source files. +
      • 3.3 Projects with additional libraries. +

        +

        4. Command Line options

        + +

        +

        5. Language Extensions

        + +
          +
        • 5.1 Storage Classes. +

          +

          6. Optimizations

          + +
            +
          • 6.1 Sub-expression elimination +
          • 6.2 Dead-Code elimination. +
          • 6.3 Copy-Propagation: +
          • 6.4 Loop optimizations +
          • 6.5 Algebraic simplifications: +
          • 6.6 'switch' statements. +
          • 6.7 bit-shifting operations. +
          • 6.8 Highest Order Bit. +
          • 6.9 Peep-hole optimizer. +

            +

            7. Pointers

            + +

            +

            8. Parameters & Local Variables

            + +
              +
            • 8.1 Overlaying +

              +

              9. critical Functions.

              + +

              +

              10. Absolute addressing.

              + +

              +

              11. Interrupt Service Routines

              + +

              +

              12. Startup Code

              + +

              +

              13. Inline assembler code.

              + +

              +

              14. int (16 bit) and long (32 bit ) support.

              + +

              +

              15. Floating point support

              + +

              +

              16. Memory Models

              + +

              +

              17. Defines created by the compiler.

              + +

              +

              18. Pragmas

              + +

              +

              19. Library routines.

              + +

              +

              +printf_small("my str %s, my int %d\n",(char _generic *)mystr,myint);
              +  
              +
              + +

              +

                +
              • stdarg.h - contains definition for the following macros to be used for +variable parameter list, note that a function can have a variable parameter +list if and only if it is 'reentrant' +

                va_list, va_start, va_arg, va_end. +

              • +
              • setjmp.h - contains defintion for ANSI setjmp & longjmp routines. Note +in this case setjmp & longjmp can be used between functions executing within +the same register bank, if long jmp is executed from a function that is using +a different register bank from the function issuing the setjmp function, the +results may be unpredictable. The jump buffer requires 3 bytes of data (the +stack pointer & a 16 byte return address), and can be placed in any address +space.
              • +
              • stdlib.h - contains the following functions. +

                atoi, atol. +

              • +
              • string.h - contains the following functions. +

                strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, strspn, +strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp, memset. +

              • +
              • ctype.h - contains the following routines. +

                iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace, +isxdigit, isalnum, isalpha. +

              • +
              • malloc.h - The malloc routines are developed by Dmitry S. Obukhov (dso@usa.net). +These routines will allocate memory from the external ram. Here is a description +on how to use them (as described by the author). +
                +//Example: 
                +     //     #define DYNAMIC_MEMORY_SIZE 0x2000 
                +     //    
                + ..... 
                +     //     unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
                + 
                +     //     unsigned char xdata * current_buffer; 
                +     //     ..... 
                +    
                + //     void main(void) 
                +     //     { 
                +     //         ... 
                +     //        
                + init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE); 
                +     //        
                + //Now it's possible to use malloc. 
                +     //         ... 
                +     //         current_buffer
                + = malloc(0x100); 
                +     //
                +  
                +
                +
              • +
              • serial.h - Serial IO routines are also developed by Dmitry S. Obukhov (dso@usa.net). +These routines are interrupt driven with a 256 byte circular buffer, they also +expect external ram to be present. Please see documentation in file SDCCDIR/sdcc51lib/serial.c +. Note the header file "serial.h" MUST be included in the file containing the +'main' function.
              • +
              • ser.h - Alternate serial routine provided by Wolfgang Esslinger <wolfgang@WiredMinds.com> +these routines are more compact and faster. Please see documentation in file +SDCCDIR/sdcc51lib/ser.c
              • +
              • ser_ir.h - Another alternate set of serial routines provided by Josef Wolf +<jw@raven.inka.de> , these routines do not use the external ram.
              • +
              • reg51.h - contains register definitions for a standard 8051
              • +
              • reg552.h - contains register definitions for 80C552.
              • +
              • float.h - contains min, max and other floating point related stuff.
              • +
              +

              All library routines are compiled as --model-small , they are all non-reentrant, +if you plan to use the large model or want to make these routines reentrant, +then they will have to be recompiled with the appropriate compiler option. +

              Have not had time to do the more involved routines like printf, will get +to them shortly. +

              +

              20. Interfacing with assembly routines.

              + +
                +
              • 20.1 Global registers used for parameter passing. +
              • 20.2 With --noregparms option. +

                +

                21. External Stack.

                + +

                +

                22. ANSI-Compliance.

                + +

                +

                23. Cyclomatic Complexity

                + +

                +

                24. TIPS

                + +

                +

                25. Retargetting for other MCUs.

                + +

                +

                26. Reporting Bugs

                + +

                +

                27. SDCDB - Source level debugger.

                + +
                  +
                • 27.1 Compiling for debugging. +
                • 27.2 How the debugger works. +
                • 27.3 Starting the debugger. +
                • 27.4 Command line options. +
                • 27.5 Debugger Commands. +
                • 27.6 Interfacing with XEmacs. +

                  +

                  28. Conclusion

                  + +

                  +

                  29. Acknowledgments

                  + +
                  +Next +Previous +Contents + + diff --git a/doc/SDCCUdoc.lyx b/doc/SDCCUdoc.lyx new file mode 100644 index 00000000..aa25ca1b --- /dev/null +++ b/doc/SDCCUdoc.lyx @@ -0,0 +1,11652 @@ +#This file was created by Thu Oct 14 02:37:27 1999 +#LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team +\lyxformat 2.15 +\textclass linuxdoc +\language english +\inputencoding default +\fontscheme default +\graphics default +\paperfontsize default +\spacing single +\papersize Default +\paperpackage a4 +\use_geometry 0 +\use_amsmath 0 +\paperorientation portrait +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\defskip medskip +\quotes_language english +\quotes_times 2 +\papercolumns 1 +\papersides 1 +\paperpagestyle default + +\layout Title + +SDCC Compiler User Guide +\layout Author + +Sandeep Dutta (sandeep.dutta@usa.net) +\layout Section + +Introduction +\layout Standard + +SDCC is a Free ware , retargettable, optimizing ANSI-C compiler. + The current version targets Intel 8051 based MCUs, it can be retargetted + for other 8 bit MCUs or PICs. + The entire source code for the compiler is distributed under GPL. + SDCC used ASXXXX & ASLINK a Free ware, retargettable assembler & linker. + SDCC has extensive MCU (8051) specific language extensions, which lets + it utilize the underlying hardware effectively. + The front-end (parser) will be enhanced to handle language extensions for + other MCUs as and when they are targetted. + In addition to the MCU Specific optimizations SDCC also does a host of + standard optimizations like +\emph on + global sub expression elimination, loop optimizations (loop invariant, + strength reduction of induction variables and loop reversing), constant + folding & propagation, copy propagation, dead code elimination and jumptables + for 'switch' statements. + +\emph default +For the back-end SDCC uses a global register allocation scheme which should + be well suited for other 8 bit MCUs , the peep hole optimizer uses a rule + based substitution mechanism which is MCU independent. + Supported data-types are +\emph on +short (8 bits, 1 byte), char (8 bits, 1 byte), int (16 bits, 2 bytes ), + long (32 bit, 4 bytes) & float (4 byte IEEE). + +\emph default +The compiler also allows +\emph on +inline assembler code +\emph default + to be embedded anywhere in a function. + In addition routines developed in assembly can also be called. + SDCC also provides an option to report the relative complexity of a function, + these functions can then be further optimized , or hand coded in assembly + if need be. + SDCC also comes with a companion source level debugger SDCDB, the debugger + currently uses S51 a freeware simulator for 8051, it can be easily modified + to use other simulators. + The latest version can be downloaded from +\series bold +http://www.geocities.com/ResearchTriangle/Forum/1353 +\layout Standard + +All packages used in this compiler system are +\emph on +opensource +\emph default + (freeware); source code for all the sub-packages ( asxxxx assembler/linker + , pre-processor and +\emph on + gc +\emph default + a conservative garbage collector) are distributed with the package. + Documentation was created using a freeware word processor (LyX). + +\layout Standard + +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, 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; if not, write to the Free Software Foundation, 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve what + you give them. + Help stamp out software-hoarding! +\layout Section + +Installation +\begin_inset LatexCommand \label{Installation} + +\end_inset + + +\layout Standard + +What you need before you start installation of SDCC ? A C Compiler, not + just any C Compiler, gcc to be exact, you can get adventurous and try another + compiler , I HAVEN'T tried it. + GCC is free , and is available for almost all major platforms, if you are + using +\emph on +linux +\emph default + you probably already have it, if you are using +\emph on +Windows 95/NT +\emph default + go to +\emph on +www.cygnus.com +\emph default + and download +\emph on +CYGWIN32 +\emph default + you will need the full development version of their tool ( +\emph on +full.exe) +\emph default +, follow their instructions for installation (this is also free and is very + easy to install), +\emph on +Windows +\emph default + +\emph on +95/NT +\emph default +users be aware that the compiler runs substantially slower on the Windows + platform, I am not sure why. +\layout Standard + +After you have installed +\emph on +gcc +\emph default + you are ready to build the compiler (sorry no binary distributions yet). + SDCC is native to Linux but can be ported to any platform on which GCC + is available . + Extract the source file package ( +\emph on +.zip +\emph default + or +\emph on +.tar.gz +\emph default +) into some directory , which we shall refer to as +\emph on +SDCCDIR +\emph default + from now on. +\layout Subsection + +Components of SDCC +\begin_inset LatexCommand \label{Components} + +\end_inset + + +\layout Subsubsection + +gc ( a conservative garbage collector) +\layout Standard + +SDCC relies on this component to do all the memory management, this excellent + package is copyrighted by +\emph on +Jans J Boehm(boehm@sgi.com) and Alan J Demers +\emph default + but can be used with minimum restrictions. + The GC source will be extracted into the directory +\emph on +SDCCDIR/gc. + +\emph default + +\layout Subsubsection + +cpp ( C-Preprocessor) +\layout Standard + +The preprocessor is extracted into the directory +\emph on +SDCCDIR/cpp +\emph default +, it is a modified version of the GNU preprocessor. +\layout Subsubsection + +asxxxx & aslink ( The assembler and Linkage Editor) +\layout Standard + +This is retargettable assembler & linkage editor, it was developed by Alan + Baldwin, John Hartman created the version for 8051, and I (Sandeep) have + some enhancements and bug fixes for it to work properly with the SDCC. + This component is extracted into the directory +\emph on +SDCCDIR/asxxxx. +\layout Subsubsection + +SDCC - The compiler. +\layout Standard + +This is the actual compiler, it uses +\emph on +gc +\emph default + and invokes the assembler and linkage editor. + All files with the prefix +\emph on +SDCC +\emph default +are part of the compiler and is extracted into the the directory +\emph on +SDCCDIR. +\layout Subsubsection + +S51 - Simulator +\layout Standard + +Version 2.1.8 onwards contains s51 a freeware , opensource simulator developed + by Daniel Drotos . + The executable is built as part of build process, for more information + visit Daniel's website at . +\layout Subsubsection + +SDCDB - Source level Debugger. +\layout Standard + +SDCDB is the companion source level debugger . + The current version of the debugger uses Daniel's Simulator S51, but can + be easily changed to use other simulators. +\layout Subsection + +Installation for Version <= 2.1.7 +\layout Standard + +After the package is extracted ( +\emph on +Windows 95/NT +\emph default + users start +\emph on +CYGWIN shell) +\emph default +, change to the directory where you extracted the package and give the command. +\layout Verbatim + +./sdccbuild.sh +\layout Standard + +This is a +\emph on +bash +\emph default + shell script, it will compile all the above mentioned components and install + the executables into the directory +\emph on +SDCCDIR/bin +\emph default + make sure you add this directory to your +\emph on +PATH +\emph default + environment variable. + This script will also compile all the support routines ( library routines + ) using SDCC. + The support routines are all developed in C and need to be compiled. +\layout Subsection + +Installation for Version >= 2.1.8a +\layout Standard + +The distribution method from Version 2.1.8a has been changed to be conforment + with the +\begin_inset Quotes eld +\end_inset + +autoconf +\begin_inset Quotes erd +\end_inset + + utility. + The source is now distributed as +\series bold +\size large +\emph on +sdcc-.tar.gz format +\series default +\size default +\emph default + , instead of the older .zip format. + The steps for installation are as follows. +\layout Subsubsection + +Unpack the sources. +\layout Standard + +This is usually done by the following command +\begin_inset Quotes eld +\end_inset + + +\series bold +\size large +\emph on +gunzip -c sdcc-.tar.gz | tar -xv - +\series default +\size default +\emph default + +\begin_inset Quotes eld +\end_inset + + +\layout Subsubsection + +Change to the main source directory (usually sdcc or sdcc-) +\layout Subsubsection + +Issue command to configure your system +\layout Standard + +The configure command has several options the most commonly used option + is --prefix=, where is the final location + for the sdcc executables and libraries, (default location is /usr/local). + The installation process will create the following directory structure + under the specified. +\layout Verbatim + +bin/ - binary exectables (add to PATH environment variable) +\newline +share/ +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +sdcc51inc/ - include header files +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +sdcc51lib/ - +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +small/ - Object & Library files for small model library +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +large/ - Object & library files for large model library +\layout Standard + +The command +\layout Standard + + +\series bold +\size large +\bar under +'./configure --prefix=/usr/local +\begin_inset Quotes erd +\end_inset + + +\layout Standard + +will create configure the compiler to be installed in directory /usr/local/bin. +\layout Subsubsection + +make +\layout Standard + +After configuration step issue the command +\layout Standard + + +\series bold +\size large +\bar under + +\begin_inset Quotes eld +\end_inset + +make +\begin_inset Quotes erd +\end_inset + + +\layout Standard + +This will compile the compiler +\layout Subsubsection + + +\begin_inset Quotes eld +\end_inset + +make install +\begin_inset Quotes erd +\end_inset + + +\layout Standard + +Will install the compiler and libraries in the appropriate directories. +\layout Subsubsection + +Special Notes for Windows Users. + Provided by Michael Jamet[ mjamet@computer.org] +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + How to install SDCC from source on a Windows 95 or Windows NT 4 system + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + This document describes how to install SDCC on a Win 95 or Win NT 4 system. + +\layout Standard + + +\protected_separator + These instructions probably work for Win 98 as well, but have not been + +\layout Standard + + +\protected_separator + tested on that platform. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + There are lots of little differences between UNIX and the Win32 Cygnus + +\layout Standard + + +\protected_separator + environment which make porting more difficult than it should be. +\protected_separator + If +\layout Standard + + +\protected_separator + you want the details, please contact me. +\protected_separator + Otherwise just follow these +\layout Standard + + +\protected_separator + instructions. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 1. + Install the Cygnus Software +\layout Standard + + +\protected_separator + Go to http://sourceware.cygnus.com/cygwin. +\protected_separator + Cygnus provides a UNIX like +\layout Standard + + +\protected_separator + environment for Win 32 systems. +\protected_separator + Download "full.exe" and install. +\protected_separator + You +\layout Standard + + +\protected_separator + MUST install it on your C drive. +\protected_separator + "full.exe" contains a shell AND many +\layout Standard + + +\protected_separator + common UNIX utilities. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 2. + Download and Extract the Latest SDCC +\layout Standard + + +\protected_separator + The latest version can be found at +\layout Standard + + +\protected_separator + +\protected_separator + www.geocities.com/ResearchTriange/Forum/1353. + +\layout Standard + + +\protected_separator + It can be uncompressed with winzip. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 3. +\protected_separator + Start a Cygnus Shell +\layout Standard + + +\protected_separator + There should be an entry in the Start Menu for Cygnus. +\protected_separator + Invoke the shell. + +\layout Standard + + +\protected_separator + This gives you a UNIX like environment. +\protected_separator + FROM THIS POINT ON, DIRECTORIES +\layout Standard + + +\protected_separator + MUST BE SPECIFIED WITH FORWARD SLASHES (/) NOT THE DOS STYLE BACK +\layout Standard + + +\protected_separator + SLASHES ( +\backslash +) BECAUSE THIS IS WHAT UNIX EXPECTS. +\protected_separator + - +\layout Standard + + +\protected_separator + +\protected_separator + ex. + " +\backslash +winnt" would be "/winnt" under the shell. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 4. + Change Directory to Where SDCC was extracted (referred to as INSTALLDIR) + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + ex. + cd /sdcc218Da. +\protected_separator + If you extracted to a drive OTHER THAN C, the drive +\layout Standard + + +\protected_separator + must be specified as part of the path. + For example, if you extracted to +\layout Standard + + +\protected_separator + your "g drive", type the following: "cd //g/mydir". +\protected_separator + You must use "//" +\layout Standard + + +\protected_separator + to specify the drive. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 5. + Make Dirs Which are Automatically Made During the UNIX Installation +\layout Standard + + +\protected_separator + From the INSTALLDIR, +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + +\protected_separator + mkdir -p bin +\protected_separator + +\protected_separator + (not a typo, just "bin") +\layout Standard + + +\protected_separator + +\protected_separator + mkdir -p /bin +\layout Standard + + +\protected_separator + +\protected_separator + mkdir -p /usr/local/bin +\layout Standard + + +\protected_separator + +\protected_separator + mkdir -p /usr/local/share +\layout Standard + + +\protected_separator + +\protected_separator + mkdir -p /usr/local/share/sdcc51lib +\layout Standard + + +\protected_separator + +\protected_separator + mkdir -p /usr/local/share/sdcc51inc +\layout Standard + + +\protected_separator + +\protected_separator + mkdir -p /tmp +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + (When a path from the root directory is specified WITHOUT a drive, the + +\layout Standard + + +\protected_separator + drive defaults to c. +\protected_separator + For example /michael/newuser => c: +\backslash +michael +\backslash +newuser) +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 6. +\protected_separator + Add Programs to /bin Expected by the Installation Process +\layout Standard + + +\protected_separator + +\protected_separator + - Look at your path: echo $PATH +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + One of the fields is the diretory with the CYGNUS programs. + +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + ex. + /CYGNUS/CYGWIN~1/H-I586/BIN +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + +\protected_separator + - cd to the directory found above. +\protected_separator + You may have to fiddle with the +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + case (upper or lower) here because the PATH is SHOWN as all upper +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + case, but is actually mixed. +\protected_separator + To help you along, you may type +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + a letter or 2 followed by the escape key. +\protected_separator + The shell will fill +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + out the remaining letters IF THEY describe a unique directory. + +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + If you have problems here, cd one directory and type "ls". +\protected_separator + "ls" +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + is the equivalent of "dir/w". + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + +\protected_separator + - Copy the following: +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + cp sh.exe /bin +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + cp pwd.exe /bin +\layout Standard + + +\protected_separator + +\protected_separator + +\protected_separator + cp echo.exe /bin +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 7. + Go back to the INSTALLDIR +\layout Standard + + +\protected_separator + +\protected_separator + cd INSTALLDIR +\layout Standard + + +\protected_separator + ex. + cd //d/sdcc218Da +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 8. + Run the configure Program +\layout Standard + + +\protected_separator + +\protected_separator + ./configure +\layout Standard + + +\protected_separator + The "./" is important because your current directory is NOT in your path. + +\layout Standard + + +\protected_separator + Under DOS, your current directory was implicitly always the first entry + +\layout Standard + + +\protected_separator + in your path. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 9. + Run make +\layout Standard + + +\protected_separator + +\protected_separator + make +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + This process takes quite some time under Win 32. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 10. + Install the Newly Built Software +\layout Standard + + +\protected_separator + +\protected_separator + make install +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + This will partially install the software into the /usr/local directories + +\layout Standard + + +\protected_separator + created in step 5. +\protected_separator + What it actually doing is copying the .c, .h and +\layout Standard + + +\protected_separator + library files to directories under /usr/local/share. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + It will NOT be able to install the actual programs (binaries) because +\layout Standard + + +\protected_separator + it does not know programs on Win32 systems have ".exe" extensions. + +\layout Standard + + +\protected_separator + For example, it tries to install sdcc instead of sdcc.exe. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + After the automated part is finished, you must manually copy the binaries: + +\layout Standard + + +\protected_separator + +\protected_separator + cd bin +\protected_separator + (This is the bin directory in your INSTALLDIR) +\layout Standard + + +\protected_separator + +\protected_separator + cp * /usr/local/bin +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + 11. + Make sure /usr/local/bin is in Your PATH +\layout Standard + + +\protected_separator + You may add c: +\backslash +usr +\backslash +local +\backslash +bin to your path however your Win32 system allows. +\protected_separator + For +\layout Standard + + +\protected_separator + example you may add it to the PATH statement in autoexec.bat. + +\layout Standard + + +\protected_separator + +\layout Standard + + +\protected_separator + Good luck. +\protected_separator + If you have any questions send them to me or post them +\layout Standard + + +\protected_separator + to the list. + +\layout Section + +Compiling. +\begin_inset LatexCommand \label{Compiling} + +\end_inset + + +\layout Subsection + +Single Source file projects. +\begin_inset LatexCommand \label{One Source File} + +\end_inset + + +\layout Standard + +For single source file projects the process is very simple. + Compile your programs with the following command +\layout Verbatim + + +\size footnotesize +sdcc sourcefile.c +\layout Standard + +The above command will compile ,assemble and link your source file. + Output files are as follows. +\layout Itemize + + +\size footnotesize +sourcefile.asm - Assembler source file created by the compiler +\layout Itemize + + +\size footnotesize +sourcefile.lst - Assembler listing file created by the Assembler +\layout Itemize + + +\size footnotesize +sourcefile.rst - Assembler listing file updated with linkedit information + , created by linkage editor +\layout Itemize + + +\size footnotesize +sourcefile.sym - symbol listing for the sourcefile, created by the assembler. +\layout Itemize + + +\size footnotesize +sourcefile.rel - Object file created by the assembler, input to Linkage editor. +\layout Itemize + + +\size footnotesize +sourcefile.map - The memory map for the load module, created by the Linker. +\layout Itemize + + +\size footnotesize +sourcefile. - The load module : ihx - Intel hex format (default + ), s19 - Motorola S19 format when compiler option --out-fmt-s19 is used. +\layout Subsection + +Projects with multiple source files. +\layout Standard + +SDCC can compile only ONE file at a time. + Let us for example assume that you have a project containing the following + files. +\layout Verbatim + + +\size footnotesize +foo1.c ( contains some functions ) +\layout Verbatim + + +\size footnotesize +foo2.c (contains some more functions) +\layout Verbatim + + +\size footnotesize +foomain.c (contains more functions and the function main) +\layout Standard + +The first two files will need to be compiled separately with the commands +\layout Verbatim + + +\size footnotesize +sdcc -c foo1.c +\layout Verbatim + + +\size footnotesize +sdcc -c foo2.c +\layout Standard + +Then compile the source file containing main and link the other files together + with the following command. +\layout Verbatim + + +\size footnotesize +sdcc foomain.c foo1.rel foo2.rel +\layout Standard + +Alternatively +\emph on +foomain.c +\emph default + can be separately compiled as well +\layout Verbatim + + +\size footnotesize +sdcc -c foomain.c +\layout Verbatim + + +\size footnotesize +sdcc foomain.rel foo1.rel foo2.rel +\layout Standard + +The file containing the main function MUST be the FIRST file specified in + the command line , since the linkage editor processes file in the order + they are presented to it. +\layout Subsection + +Projects with additional libraries. +\layout Standard + +Some reusable routines may be compiled into a library, see the documentation + for the assembler and linkage editor in the directory +\emph on +SDCCDIR/asxxxx/asxhtm.htm +\emph default +this describes how to create a +\emph on +.lib +\emph default + library file, the libraries created in this manner may be included using + the command line, make sure you include the -L option to + tell the linker where to look for these files. + Here is an example, assuming you have the source file +\emph on +'foomain.c +\emph default +' and a library +\emph on + 'foolib.lib' +\emph default + in the directory +\emph on +'mylib' +\emph default +. +\layout Verbatim + + +\size footnotesize +sdcc foomain.c foolib.lib -L mylib +\layout Standard + +Note here that +\emph on +'mylib +\emph default +' must be an absolute path name. +\layout Standard + +The view of the way the linkage editor processes the library files, it is + recommended that you put each source routine in a separate file and combine + them using the .lib file. + For an example see the standard library file 'libsdcc.lib' in the directory + SDCCDIR/sdcc51lib. +\layout Section + +Command Line options +\begin_inset LatexCommand \label{Command Line Options} + +\end_inset + + +\layout Itemize + + +\series bold +\size large +--model-large +\emph on + +\begin_inset LatexCommand \label{--model-large} + +\end_inset + + +\series default +\size default +\emph default + Generate code for Large model programs see section Memory Models for more + details. + If this option is used all source files in the project should be compiled + with this option. + In addition the standard library routines are compiled with small model + , they will need to be recompiled. +\layout Itemize + + +\series bold +\size large +\bar under +--model-small +\series default +\emph on +\bar default + +\size default +\emph default + +\begin_inset LatexCommand \label{--model-small} + +\end_inset + +Generate code for Small Model programs see section Memory Models for more + details. + This is the default model. +\layout Itemize + + +\series bold +\size large +\bar under +--stack- +\emph on +auto +\series default +\bar default + +\size default +\emph default + +\begin_inset LatexCommand \label{--stack-auto} + +\end_inset + +All functions in the source file will be compiled as +\emph on +reentrant +\emph default +, i.e. + the parameters and local variables will be allocated on the stack. + see section Parameters and Local Variables for more details. + If this option is used all source files in the project should be compiled + with this option. + +\layout Itemize + + +\series bold +\size large +\bar under +--xstack +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--xstack} + +\end_inset + + Uses a pseudo stack in the first 256 bytes in the external ram for allocating + variables and passing parameters. + See section on external stack for more details. +\layout Itemize + + +\series bold +\size large +\bar under +--nogcse +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--nogcse} + +\end_inset + + Will not do global subexpression elimination, this option may be used when + the compiler creates undesirably large stack/data spaces to store compiler + temporaries. + A warning message will be generated when this happens and the compiler + will indicate the number of extra bytes it allocated. + It recommended that this option NOT be used , #pragma NOGCSE can be used + to turn off global subexpression elimination for a given function only. +\layout Itemize + + +\series bold +\size large +\bar under +--noinvariant +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--noinvariant} + +\end_inset + + Will not do loop invariant optimizations, this may be turned off for reasons + explained for the previous option . + For more details of loop optimizations performed see section Loop Invariants.It + recommended that this option NOT be used , #pragma NOINVARIANT can be used + to turn off invariant optimizations for a given function only. +\layout Itemize + + +\series bold +\size large +\bar under +--noinduction +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--noinduction} + +\end_inset + + Will not do loop induction optimizations, see section Strength reduction + for more details.It recommended that this option NOT be used , #pragma NOINDUCTI +ON can be used to turn off induction optimizations for given function only. +\layout Itemize + + +\series bold +\size large +\bar under +--nojtbound +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--nojtbound} + +\end_inset + + Will not generate boundary condition check when switch statements are implement +ed using jump-tables. + See section Switch Statements for more details.It recommended that this + option NOT be used , #pragma NOJTBOUND can be used to turn off boundary + checking for jump tables for a given function only. +\layout Itemize + + +\series bold +\size large +\bar under +--noloopreverse +\series default +\bar default + +\size default + +\begin_inset LatexCommand \label{--noloopreverse} + +\end_inset + +Will not do loop reversal optimization +\layout Itemize + + +\series bold +\size large +\bar under +--noregparms +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--noregparms} + +\end_inset + + By default the first parameter is passed using global registers (DPL,DPH,B,ACC). + This option will disable parameter passing using registers. + NOTE: if your program uses the 16/32 bit support routines (for multiplication/d +ivision) these library routines will need to be recompiled with the --noregparms + option as well. +\layout Itemize + + +\series bold +\size large +\bar under +--callee-saves function1[,function2][,function3].... + +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--callee-saves} + +\end_inset + +The compiler by default uses a caller saves convention for register saving + across function calls, however this can cause unneccessary register pushing + & popping when calling small functions from larger functions. + This option can be used to switch the register saving convention for the + function names specified. + The compiler will not save registers when calling these functions, extra + code will be generated at the entry & exit for these functions to save + & restore the registers used by these functions, this can SUBSTANTIALLY + reduce code & improve run time performance of the generated code. + In future the compiler (with interprocedural analysis) will be able to + determine the appropriate scheme to use for each function call. + DO NOT use this option for built-in functions such as _muluint..., if this + option is used for a library function the appropriate library function + needs to be recompiled with the same option. + If the project consists of multiple source files then all the source file + should be compiled with the same --callee-saves option string. + Also see Pragma Directive +\begin_inset LatexCommand \ref{Pragmaa} + +\end_inset + + CALLEE-SAVES. +\begin_inset LatexCommand \ref{pragma callee-saves} + +\end_inset + + . +\layout Itemize + + +\series bold +\bar under +--debug +\series default +\bar default + +\begin_inset LatexCommand \label{--debug} + +\end_inset + +When this option is used the compiler will generate debug information , + that can be used with the SDCDB. + The debug information is collected in a file with .cdb extension. + For more information see documentation for SDCDB. +\layout Itemize + + +\series bold +\size large +\bar under +--regextend +\size default + +\series default +\bar default + +\begin_inset LatexCommand \label{--regextend} + +\end_inset + + This option will cause the compiler to define pseudo registers , if this + option is used, all source files in the project should be compiled with + this option. + See section Register Extension for more details. +\layout Itemize + + +\series bold +\size large +\bar under +--compile-only +\series default +\bar default +(-c) +\size default + +\begin_inset LatexCommand \label{--compile-only} + +\end_inset + + will compile and assemble the source only, will not call the linkage editor. +\layout Itemize + + +\series bold +\size large +\bar under +--xram-loc +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--xram-loc} + +\end_inset + + The start location of the external ram, default value is 0. + The value entered can be in Hexadecimal or Decimal format .eg. + --xram-loc 0x8000 or --xram-loc 32768. +\layout Itemize + + +\series bold +\size large +\bar under +--code-loc +\size default + +\series default +\bar default + +\begin_inset LatexCommand \label{--code-loc} + +\end_inset + + The start location of the code segment , default value 0. + Note when this option is used the interrupt vector table is also relocated + to the given address. + The value entered can be in Hexadecimal or Decimal format .eg. + --code-loc 0x8000 or --code-loc 32768. +\layout Itemize + + +\series bold +\size large +\bar under +--stack-loc +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--stack-loc} + +\end_inset + + The initial value of the stack pointer. + The default value of the stack pointer is 0x07 if only register bank 0 + is used, if other register banks are used then the stack pointer is initialized + to the location above the highest register bank used. + eg. + if register banks 1 & 2 are used the stack pointer will default to location + 0x18. + The value entered can be in Hexadecimal or Decimal format .eg. + --stack-loc 0x20 or --stack-loc 32. + If all four register banks are used the stack will be placed after the + data segment (equivalent to --stack-after-data) +\layout Itemize + + +\series bold +\size large +\bar under +--stack-after-data +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--stack-after-data} + +\end_inset + +This option will cause the stack to be located in the internal ram after + the data segment. +\layout Itemize + + +\series bold +\size large +\bar under +--data-loc +\series default +\bar default + +\size default + +\begin_inset LatexCommand \label{--data-loc} + +\end_inset + + The start location of the internal ram data segment, the default + value is 0x30.The value entered can be in Hexadecimal or Decimal format + .eg. + --data-loc 0x20 or --data-loc 32. +\layout Itemize + + +\series bold +\size large +\bar under +--idata-loc +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--idata-loc} + +\end_inset + + The start location of the indirectly addressable internal ram, default + value is 0x80. + The value entered can be in Hexadecimal or Decimal format .eg. + --idata-loc 0x88 or --idata-loc 136. +\layout Itemize + + +\series bold +\size large +\bar under +--peep-file +\size default + +\begin_inset LatexCommand \label{--peep-file} + +\end_inset + + +\series default +\bar default + This option can be used to use additional rules to be used by + the peep hole optimizer. + See section Peep Hole optimizations for details on how to write these rules. +\layout Itemize + + +\series bold +\size large +\bar under +--lib-path (-L) +\size default + +\series default +\bar default + +\begin_inset LatexCommand \label{--lib-path} + +\end_inset + + This option is passed to the linkage + editor, additional libraries search path. + The path name must be absolute. + Additional library files may be specified in the command line . + See section Compiling programs for more details. +\layout Itemize + + +\series bold +\bar under +-I +\begin_inset LatexCommand \label{-I} + +\end_inset + + +\series default +\bar default + The additional location where the pre processor will look for <..h> or +\begin_inset Quotes eld +\end_inset + +..h +\begin_inset Quotes erd +\end_inset + + files. +\layout Itemize + + +\series bold +\size large +\bar under +-D +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-D} + +\end_inset + +Command line definition of macros. + Passed to the pre processor. +\layout Itemize + + +\series bold +\size large +\bar under +-E +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-E} + +\end_inset + + Run only the C preprocessor. + Preprocess all the C source files specified and output the results to standard + output. +\layout Itemize + + +\series bold +\size large +\bar under +-M +\bar default + +\begin_inset LatexCommand \label{-M} + +\end_inset + + +\series default +\size default + Tell the preprocessor to output a rule suitable for make describing the + dependencies of each object file. + For each source file, the preprocessor outputs one make-rule whose target + is the object file name for that source file and whose dependencies are + all the files `#include'd in it. + This rule may be a single line or may be continued with ` +\backslash +'-newline if it is long. + The list of rules is printed on standard output instead of the preprocessed + C program. + `-M' implies `-E'. +\layout Itemize + + +\series bold +\size large +\bar under +-C +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-C} + +\end_inset + +Tell the preprocessor not to discard comments. + Used with the `-E' option. +\layout Itemize + + +\series bold +\size large +\bar under +-MM +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-MM} + +\end_inset + +Like `-M' but the output mentions only the user header files included with + `#include file"'. + System header files included with `#include ' are omitted. +\layout Itemize + + +\series bold +\size large +\bar under +-Aquestion(answer) +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-Aquestion(answer)} + +\end_inset + + Assert the answer answer for question, in case it is tested with a preprocessor + conditional such as `#if #question(answer)'. + `-A-' disables the standard asser- tions that normally describe the target + machine. +\layout Itemize + + +\series bold +\size large +\bar under +-Aquestion +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-Aquestion} + +\end_inset + + (answer) Assert the answer answer for question, in case it is tested with + a preprocessor conditional such as `#if #question(answer)'. + `-A-' disables the standard assertions that normally describe the target + machine. +\layout Itemize + + +\series bold +\size large +\bar under +-Umacro +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-Umacro} + +\end_inset + + Undefine macro macro. + `-U' options are evaluated after all `-D' options, but before any `-include' + and `-imac- ros' options. +\layout Itemize + + +\series bold +\size large +\bar under +-dM +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-dM} + +\end_inset + + Tell the preprocessor to output only a list of the mac- ro definitions + that are in effect at the end of prepro- cessing. + Used with the `-E' option. +\layout Itemize + + +\series bold +\size large +\bar under +-dD +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-dD} + +\end_inset + +Tell the preprocessor to pass all macro definitions into the output, in + their proper sequence in the rest of the output. +\layout Itemize + + +\series bold +\size large +\bar under +-dN +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-dN} + +\end_inset + +Like `-dD' except that the macro arguments and contents are omitted. + Only `#define name' is included in the output. +\layout Itemize + + +\series bold +\size large +\bar under +-S +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{-S} + +\end_inset + +Stop after the stage of compilation proper; do not as- semble. + The output is an assembler code file for the input file specified. +\layout Itemize + + +\series bold +\bar under +-Wa asmOption[,asmOption] +\series default +\bar default +... + Pass the asmOption to the assembler +\layout Itemize + + +\series bold +\bar under +-Wl linkOption[,linkOption] +\series default +\bar default + .. + Pass the linkOption to the linker. +\layout Itemize + + +\series bold +\size large +\bar under +--int-long-reent +\series default +\bar default + +\size default + +\begin_inset LatexCommand \label{--int-long-rent} + +\end_inset + + Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant. + Note by default these libraries are compiled as non-reentrant. + See section Installation for more details. +\layout Itemize + + +\series bold +\size large +\bar under +--cyclomatic +\size default + +\series default +\bar default + +\begin_inset LatexCommand \label{--cyclomatic} + +\end_inset + +This option will cause the compiler to generate an information message for + each function in the source file. + The message contains some +\emph on +important +\emph default + information about the function. + The number of edges and nodes the compiler detected in the control flow + graph of the function, and most importantly the +\emph on +cyclomatic complexity +\emph default + see section on Cyclomatic Complexity for more details. +\layout Itemize + + +\series bold +\size large +\bar under +--float-reent +\size default + +\series default +\bar default + +\begin_inset LatexCommand \label{--float-reent} + +\end_inset + + Floating point library is compiled as reentrant.See section Installation + for more details. +\layout Itemize + + +\series bold +\size large +\bar under +--out-fmt-ihx +\size default + +\begin_inset LatexCommand \label{--out-fmt-ihx} + +\end_inset + + +\series default +\bar default +The linker output (final object code) is in Intel Hex format. + (This is the default option). +\layout Itemize + + +\series bold +\size large +\bar under +--out-fmt-s19 +\size default + +\series default +\bar default + +\begin_inset LatexCommand \label{--out-fmt-s19} + +\end_inset + +The linker output (final object code) is in Motorola S19 format. +\layout Itemize + + +\series bold +\size large +\bar under +--nooverlay +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--nooverlay} + +\end_inset + + The compiler will not overlay parameters and local variables of any function, + see section Parameters and local variables for more details. +\layout Itemize + + +\series bold +\size large +\bar under +--main-return +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--main-return} + +\end_inset + + This option can be used when the code generated is called by a monitor + program. + The compiler will generate a 'ret' upon return from the 'main' function. + The default option is to lock up i.e. + generate a 'ljmp .' . +\layout Itemize + + +\series bold +\size large +\bar under +--no-peep +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--no-peep} + +\end_inset + + Disable peep-hole optimization. +\layout Itemize + + +\series bold +\size large +\bar under +--peep-asm +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--peep-asm} + +\end_inset + + Pass the inline assembler code through the peep hole optimizer. + Can cause unexpected changes to inline assembler code , please go through + the peephole optimizer rules defnied in file 'SDCCpeeph.def' before using + this option. +\layout Itemize + + +\series bold +\size large +\bar under +--iram-size +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--iram-size} + +\end_inset + + Causes the linker to check if the interal ram usage is within limits + of the given value. +\layout Standard + +The following options are provided for the purpose of retargetting and debugging + the compiler . + These provided a means to dump the intermediate code (iCode) generated + by the compiler in human readable form at various stages of the compilation + process. + +\layout Itemize + + +\series bold +\size large +\bar under +--dumpraw +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--dumpraw} + +\end_inset + +. + This option will cause the compiler to dump the intermediate code into + a file of named +\emph on +.dumpraw +\emph default + just after the intermediate code has been generated for a function , i.e. + before any optimizations are done. + The basic blocks at this stage ordered in the depth first number, so they + may not be in sequence of execution. +\layout Itemize + + +\series bold +\size large +\bar under +--dumpgcse +\series default +\bar default +. +\size default + +\begin_inset LatexCommand \label{--dumpgcse} + +\end_inset + + Will create a dump if iCode, after global subexpression elimination, into + a file named +\emph on +.dumpgcse. +\layout Itemize + + +\series bold +\size large +\bar under +--dumpdeadcode +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--dumpdeadcode} + +\end_inset + +.Will create a dump if iCode, after deadcode elimination, into a file named + +\emph on +.dumpdeadcode. +\layout Itemize + + +\series bold +\size large +\bar under +--dumploop. + +\series default +\bar default + +\size default + +\begin_inset LatexCommand \label{--dumploop} + +\end_inset + +Will create a dump if iCode, after loop optimizations, into a file named + +\emph on +.dumploop. +\layout Itemize + + +\series bold +\size large +\bar under +--dumprange. + +\series default +\bar default + +\size default + +\begin_inset LatexCommand \label{--dump-range} + +\end_inset + +Will create a dump if iCode, after live range analysis, into a file named + +\emph on +.dumprange. +\layout Itemize + + +\series bold +\size large +\bar under +--dumpregassign. + +\size default + +\series default +\bar default + +\begin_inset LatexCommand \label{--dumpregassign} + +\end_inset + +Will create a dump if iCode, after register assignment , into a file named + +\emph on +.dumprassgn. +\layout Itemize + + +\series bold +\size large +\bar under +--dumpall. + +\series default +\size default +\bar default + +\begin_inset LatexCommand \label{--dumpall} + +\end_inset + +Will cause all the above mentioned dumps to be created. +\layout Standard + +Note that the files created for the dump are appended to each time. + So the files should be deleted manually , before each dump is created. + +\layout Standard + +When reporting bugs, it will be very helpful if you could include these + dumps along with the portion of the code that is causing the problem. +\layout Section + +Language Extensions +\begin_inset LatexCommand \label{Language Extension} + +\end_inset + + +\layout Subsection + +Storage Classes. +\begin_inset LatexCommand \label{Storage Classes} + +\end_inset + + +\layout Standard + +In addition to the ANSI storage classes SDCC allows the following 8051 specific + storage classes. +\layout Subsubsection + +xdata. +\begin_inset LatexCommand \label{xdata} + +\end_inset + + +\layout Standard + +Variables declared with this storage class will be placed in the extern + RAM. + This is the +\series bold +default +\series default + storage class for Large Memory model . +\layout Standard + + +\size footnotesize +eg. + +\emph on +xdata unsigned char xduc; +\layout Subsubsection + +data +\begin_inset LatexCommand \label{data} + +\end_inset + + +\layout Standard + +This is the +\series bold +default +\series default + storage class for Small Memory model. + Variables declared with this storage class will be allocated in the internal + RAM. +\layout Standard + + +\size footnotesize +eg. + +\emph on + data int iramdata; +\layout Subsubsection + +idata +\begin_inset LatexCommand \label{idata} + +\end_inset + + +\layout Standard + +Variables declared with this storage class will be allocated into the indirectly + addressable portion of the internal ram of a 8051 . +\layout Standard + + +\size footnotesize +eg. +\emph on +idata int idi; +\layout Subsubsection + +bit +\begin_inset LatexCommand \label{bit} + +\end_inset + + +\layout Standard + +This is a data-type and a storage class specifier. + When a variable is declared as a bit , it is allocated into the bit addressable + memory of 8051. +\layout Standard + +eg. +\emph on +bit iFlag; +\layout Subsubsection + +sfr / sbit +\begin_inset LatexCommand \label{sfr / sbit} + +\end_inset + + +\layout Standard + +Like the bit keyword, +\emph on +sfr / sbit +\emph default +signifies both a data-type and storage class, they are used to describe + the special function registers and special bit variables of a 8051. + +\layout Standard + +eg. + +\emph on + +\layout Standard + + +\emph on +sfr at 0x80 P0; +\emph default +\noun on +/* special function register P0 at location 0x80 */ +\layout Standard + + +\emph on +sbit at 0xd7 CY; /* +\noun on +CY (Carry Flag) */ +\layout Section + +Optimizations +\begin_inset LatexCommand \label{Optimizations} + +\end_inset + + +\layout Standard + +SDCC performs a a host of standard optimizations in addition to some MCU + specific optimizations. + +\layout Subsection + +Sub-expression elimination +\begin_inset LatexCommand \label{Sub-expression Elimination} + +\end_inset + + +\layout Standard + +The compiler does +\emph on +local and global +\emph default +common subexpression elimination. +\layout Standard + + +\family typewriter +\size scriptsize +eg. + +\layout Verbatim + + +\size small +i = x + y + 1; +\size default + +\newline +j +\size small += x + y; +\layout Standard + +will be translated to +\layout Verbatim + + +\size small +iTemp = x + y +\newline +i = iTemp + 1 +\newline +j = iTemp +\layout Standard + +Some subexpressions are not as obvious as the above example. +\layout Standard + +eg. +\layout Verbatim + + +\size small +a->b[i].c = 10; +\newline +a->b[i].d = 11; +\layout Standard + +In this case the address arithmetic +\emph on +a->b[i] +\emph default +will be computed only once; the equivalent code in C would be. +\layout Verbatim + + +\size small +iTemp = a->b[i]; +\newline +iTemp.c = 10; +\newline +iTemp.d = 11; +\layout Standard + +The compiler will try to keep these temporary variables in registers. +\layout Subsection + +Dead-Code elimination. +\begin_inset LatexCommand \label{Dead-code elimination} + +\end_inset + + +\layout Standard + +eg. +\layout Verbatim + + +\size small +int global; +\newline +void f () { +\newline + +\protected_separator + +\protected_separator +int i; +\newline + +\protected_separator + +\protected_separator +i = 1; +\protected_separator + +\protected_separator + +\protected_separator +/* dead store */ +\newline + +\protected_separator + +\protected_separator +global = 1; /* dead store */ +\newline + +\protected_separator + +\protected_separator +global = 2; +\newline + +\protected_separator + +\protected_separator +return; +\newline + +\protected_separator + +\protected_separator +global = 3; /* unreachable */ +\newline +} +\layout Standard + +will be changed to +\layout Verbatim + + +\size footnotesize +int global; void f () +\newline +{ +\protected_separator + +\protected_separator + +\newline + +\protected_separator +global = 2; +\protected_separator + +\protected_separator + +\newline + +\protected_separator +return; +\newline +} +\layout Subsection + +Copy-Propagation: +\begin_inset LatexCommand \label{Copy-Propagation} + +\end_inset + + +\layout Standard + +eg. +\layout Verbatim + + +\size footnotesize +int f() { +\newline + +\protected_separator + +\protected_separator + +\protected_separator +int i, j; +\newline + +\protected_separator + +\protected_separator + +\protected_separator +i = 10; +\newline + +\protected_separator + +\protected_separator + +\protected_separator +j = i; +\newline + +\protected_separator + +\protected_separator + +\protected_separator +return j; +\newline +} +\layout Standard + +will be changed to +\layout Verbatim + + +\size small +int f() { +\newline + +\protected_separator + +\protected_separator + int i,j; +\newline + +\protected_separator + +\protected_separator + i = 10; +\newline + +\protected_separator + +\protected_separator + j = 10; +\newline + +\protected_separator + +\protected_separator + return 10; +\newline +} +\layout Standard + +Note: the dead stores created by this copy propagation will be eliminated + by dead-code elimination . +\layout Subsection + +Loop optimizations +\begin_inset LatexCommand \label{Loop Optimizations} + +\end_inset + + +\layout Standard + +Two types of loop optimizations are done by SDCC loop invariant lifting + and strength reduction of loop induction variables.In addition to the strength + reduction the optimizer marks the induction variables and the register + allocator tries to keep the induction variables in registers for the duration + of the loop. + Because of this preference of the register allocator , loop induction optimizat +ion causes an increase in register pressure, which may cause unwanted spilling + of other temporary variables into the stack / data space . + The compiler will generate a warning message when it is forced to allocate + extra space either on the stack or data space. + If this extra space allocation is undesirable then induction optimization + can be eliminated either for the entire source file ( with --noinduction + option) or for a given function only (#pragma NOINDUCTION). +\layout Subsubsection + +Loop Invariant: +\begin_inset LatexCommand \label{Loop Invariant} + +\end_inset + + +\layout Standard + +eg +\layout Verbatim + + +\size small +for (i = 0 ; i < 100 ; i ++) +\newline + +\protected_separator + +\protected_separator + +\protected_separator +f += k + l; +\layout Standard + +changed to +\layout Verbatim + + +\size small +itemp = k + l; +\newline +for ( i = 0; i < 100; i++ ) f += itemp; +\layout Standard + +As mentioned previously some loop invariants are not as apparent, all static + address computations are also moved out of the loop. +\layout Subsubsection + +Strength reduction : +\begin_inset LatexCommand \label{Strength Reduction} + +\end_inset + + +\layout Standard + +This optimization substitutes an expression by a cheaper expression. +\layout Standard + +eg. +\layout Verbatim + + +\size small +for (i=0;i < 100; i++) ar[i*5] = i*3; +\layout Standard + +changed to +\layout Verbatim + + +\size small +itemp1 = 0; +\newline +itemp2 = 0; +\newline +for (i=0;i< 100;i++) { +\newline + +\protected_separator + +\protected_separator + +\protected_separator +ar[itemp1] = itemp2; +\newline + +\protected_separator + +\protected_separator + +\protected_separator +itemp1 += 5; +\newline + +\protected_separator + +\protected_separator + +\protected_separator +itemp2 += 3; +\newline +} +\layout Standard + +The more expensive multiplication is changed to a less expensive addition. +\layout Subsubsection + +Loop reversing: +\begin_inset LatexCommand \label{Loop reversing} + +\end_inset + + +\layout Standard + +This optimization is done to reduce the overhead of checking loop boundaries + for every iteration. + Some simple loops can be reversed and implemented using a +\begin_inset Quotes eld +\end_inset + +decrement and jump if not zero +\begin_inset Quotes erd +\end_inset + + instruction. + SDCC checks for the following criterion to determine if a loop is reversible + (note: more sophisticated compiers use data-dependency analysis to make + this determination, SDCC uses a more simple minded analysis). +\layout Itemize + +The 'for' loop is of the form +\newline + +\begin_inset Quotes eld +\end_inset + +for ( = ; [< | <=] ; [++ | + += 1]) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\begin_inset Quotes erd +\end_inset + + +\layout Itemize + +The does not contain +\begin_inset Quotes eld +\end_inset + +continue +\begin_inset Quotes erd +\end_inset + + or 'break +\begin_inset Quotes erd +\end_inset + +. +\layout Itemize + +All goto's are contained within the loop. +\layout Itemize + +No function calls within the loop. +\layout Itemize + +The loop control variable is not assigned any value within the loop +\layout Itemize + +The loop control variable does NOT participate in any arithmetic operation + within the loop. +\layout Itemize + +There are NO switch statements in the loop. +\layout Standard + +Note djnz instruction can be used for 8-bit values ONLY, therefore it is + advantageous to declare loop control symbols as either 'char' or 'short', + ofcourse this may not be possible on all situations. +\layout Subsection + +Algebraic simplifications: +\begin_inset LatexCommand \label{Algebraic Simplifications} + +\end_inset + + +\layout Standard + +SDCC does numerous algebraic simplifications, the following is a small sub-set + of these optimizations. +\layout Verbatim + + +\size small +eg +\emph on + +\emph default + +\newline +i = j + 0 ; /* changed to */ i = j; +\newline +i /= 2; /* changed to */ i >>= 1; +\newline +i = j - j ; /* changed to */ i = 0; +\newline +i = j / 1 ; /* changed to */ i = j; +\layout Standard + +Note the subexpressions given above are generally introduced by macro expansions + or as a result of copy/constant propagation. +\layout Subsection + +'switch' statements. +\begin_inset LatexCommand \label{Switch Statement} + +\end_inset + + +\layout Standard + +SDCC changes switch statements to jump tables when the following conditions + are true. + +\layout Itemize + +The case labels are in numerical sequence , the labels need not be in order, + and the starting number need not be one or zero. +\layout Standard + +eg +\layout Verbatim + + +\size small +switch(i) { +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +switch (i) { +\newline +case 4:... + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +case 1: ... + +\newline +case 5:... + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +case 2: ... + +\newline +case 3:... + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +case 3: ... + +\newline +case 6:... + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +case 4: ... + +\newline +} +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +} +\layout Standard + +Both the above switch statements will be implemented using a jump-table. +\layout Itemize + +The number of case labels is at least three, since it takes two conditional + statements to handle the boundary conditions. +\layout Itemize + +The number of case labels is less than 84, since each label takes 3 bytes + and a jump-table can be utmost 256 bytes long. + +\layout Standard + +Switch statements which have gaps in the numeric sequence or those that + have more that 84 case labels can be split into more than one switch statement + for efficient code generation. +\layout Standard + +eg +\layout Verbatim + + +\size small +switch (i) { +\newline +case 1: ... + +\newline +case 2: ... + +\newline +case 3: ... + +\newline +case 4: ... + +\newline +case 9: ... + +\newline +case 10: ... + +\newline +case 11: ... + +\newline +case 12: ... + +\newline +} +\layout Standard + +If the above switch statement is broken down into two switch statements +\layout Verbatim + + +\size small +switch (i) { +\newline +case 1: ... + +\newline +case 2: ... + +\newline +case 3: ... + +\newline +case 4: ... + +\newline +} +\layout Verbatim + + +\size small +switch (i) { +\newline +case 9: ... + +\newline +case 10: ... + +\newline +case 11: ... + +\newline +case 12:... + +\newline +} +\layout Standard + +then both the switch statements will be implemented using jump-tables whereas + the unmodified switch statement will not be . +\layout Subsection + +bit-shifting operations. +\begin_inset LatexCommand \label{bit shifting} + +\end_inset + + +\layout Standard + +Bit shifting is one of the most frequently used operation in embedded programmin +g . + SDCC tries to implement bit-shift operations in the most efficient way + possible. +\layout Standard + +eg. +\layout Verbatim + + +\size small +unsigned short i; +\layout Verbatim + + +\size small +... + +\newline +i>>= 4; +\newline +.. +\layout Standard + +generates the following code. +\layout Verbatim + + +\size small +mov a,_i +\newline +swap a +\newline +anl a,#0x0f +\newline +mov _i,a +\layout Standard + +In general SDCC will never setup a loop if the shift count is known. + Another example +\layout Verbatim + + +\size small +unsigned int i; +\newline +... + +\newline +i >>= 9; +\newline +... +\layout Standard + +will generate +\layout Verbatim + + +\size small +mov a,(_i + 1) +\newline +mov (_i + 1),#0x00 +\newline +clr c +\newline +rrc a +\newline +mov _i,a +\layout Standard + +Note that SDCC stores numbers in +\noun on +little-endian +\noun default +format (i.e. + lowest order first) +\layout Subsubsection + +Bit-rotation: +\begin_inset LatexCommand \label{bit rotation} + +\end_inset + + +\layout Standard + +A special case of the bit-shift operation is bit rotation, SDCC recognizes + the following expression to be a left bit-rotation. +\layout Verbatim + + +\size small +unsigned char i; +\newline +... + +\newline +i = ( ( i << 1) | ( i >> 7)); +\newline +... +\layout Standard + +will generate the following code. +\layout Verbatim + + +\size small +mov a,_i +\newline +rl a +\newline +mov _i,a +\layout Standard + +SDCC uses pattern matching on the parse tree to determine this operation + .Variations of this case will also be recognized as bit-rotation i.e +\emph on + i = ((i >> 7) | (i << 1)); +\emph default +/* left-bit rotation */ +\layout Subsection + +Highest Order Bit. +\begin_inset LatexCommand \label{Highest Order Bit} + +\end_inset + + +\layout Standard + +It is frequently required to obtain the highest order bit of an integral + type (int,long,short or char types). + SDCC recognizes the following expression to yield the highest order bit + and generates optimized code for it. +\layout Verbatim + + +\size small +eg +\newline +unsigned int gint; +\newline +foo () { +\newline +unsigned char hob; +\newline + +\protected_separator + +\protected_separator + +\protected_separator +... + +\newline + +\protected_separator + +\protected_separator + +\protected_separator +hob = (gint >> 15) & 1; +\newline + +\protected_separator + +\protected_separator + +\protected_separator +.. + +\newline +} +\layout Standard + +Will generate the following code. +\layout Verbatim + + +\size small + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 61 ; +\protected_separator + hob.c 7 +\newline + +\protected_separator + +\protected_separator + 000A E5*01 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 62 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + a,(_gint + 1) +\newline + +\protected_separator + +\protected_separator + 000C 33 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 63 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + rlc +\protected_separator + a +\newline + +\protected_separator + +\protected_separator + 000D E4 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 64 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + clr +\protected_separator + a +\newline + +\protected_separator + +\protected_separator + 000E 13 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 65 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + rrc +\protected_separator + a +\newline + +\protected_separator + +\protected_separator + 000F F5*02 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 66 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + _foo_hob_1_1,a +\layout Standard + +Variations of this case however will NOT be recognized . + It is a standard C expression , so I heartily recommend this be the only + way to get the highest order bit, (it is portable). + Of course it will be recognized even if it is embedded in other expressions. +\layout Verbatim + + +\size small +eg. +\layout Verbatim + + +\size small +xyz = gint + ((gint >> 15) & 1); +\layout Standard + +will still be recognized. +\layout Subsection + +Peep-hole optimizer. +\begin_inset LatexCommand \label{Peep-Hole} + +\end_inset + + +\layout Standard + +The compiler uses a rule based , pattern matching and re-writing mechanism + for peep-hole optimization . + It is inspired by ' +\emph on +copt' +\emph default + a peep-hole optimizer by Christopher W. + Fraser (cwfraser@microsoft.com). + A default set of rules are compiled into the compiler, additional rules + may be added with the --peep-file option. + The rule language is best illustrated with examples. +\layout Verbatim + + +\size small +replace { +\newline +mov %1,a +\newline +mov a,%1 } by { mov %1,a } +\layout Standard + +The above rule will the following assembly sequence +\layout Verbatim + + +\size small +mov r1,a +\newline +mov a,r1 +\layout Standard + +to +\layout Verbatim + + +\size small +mov r1,a +\layout Standard + +Note: All occurrences of a '%n' ( pattern variable ) must denote the same + string. + With the above rule, the assembly sequence +\layout Verbatim + + +\size small +mov r1,a +\newline +mov a,r2 +\layout Standard + +will remain unmodified. + Other special case optimizations may be added by the user (via --peep-file + option), eg. + some variants of the 8051 MCU allow only 'AJMP' and 'ACALL' , the following + two rules will change all 'LJMP' & 'LCALL' to 'AJMP' & 'ACALL'. +\layout Verbatim + + +\size small +replace { lcall %1 } by { acall %1 } +\newline +replace { ljmp %1 } by { ajmp %1 } +\layout Standard + +The inline-assembler' code is also passed through the peep hole optimizer, + thus the peephole optimizer can also be used as an assembly level macro + expander. + The rules themselves are MCU dependent whereas the rule language infra-structur +e is MCU independent. + Peephole optimization rules for other MCU can be easily programmed using + the rule language. +\layout Standard + +The syntax for a rule is as follows , +\layout Verbatim + + +\size small +rule := replace [ restart ] '{' ' +\backslash +n' +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + '}' by '{' ' +\backslash +n' +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ' +\backslash +n' +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + '}' [if ] ' +\backslash +n' +\newline + := assembly instruction (each instruction including + labels must be on a separate line). +\protected_separator + +\protected_separator + +\layout Standard + +The optimizer will apply to the rules one by one from the top in the sequence + of their appearance, it will terminate when all rules are exhausted. + If the ' +\emph on +restart +\emph default +' option is specified, then the optimizer will start matching the rules + again from the top, this option for a rule is expensive (performance), + it is intended to be used in situations where a transformation will trigger + the same rule again. + A good example of this the following rule. +\layout Verbatim + + +\size small +replace restart { +\newline +pop %1 +\newline +push %1 } by { +\newline +; nop +\newline +} +\layout Standard + +Note that the replace pattern cannot be a blank, but can be a comment line. + Without the ' +\emph on +restart +\emph default +' option only the inner most 'pop' 'push' pair would be eliminated. + i.e. +\layout Verbatim + + +\size small +pop ar1 +\newline +pop ar2 +\newline +push ar2 +\newline +push ar1 +\layout Standard + +would result in +\layout Verbatim + + +\size small +pop ar1 +\newline +; nop +\newline +push ar1 +\layout Standard + +with the ' +\emph on +restart +\emph default +' option the rule will be applied again to the resulting code and the all + the ' +\emph on +pop' 'push' +\emph default + pairs will be eliminated to yield +\layout Verbatim + + +\size small +; nop +\newline +; nop +\layout Standard + +A conditional function can be attached to a rule. + Attaching rules are somewhat more involved, let me illustrate this with + an example. +\layout Verbatim + + +\size small +replace { +\newline + +\protected_separator + +\protected_separator + +\protected_separator +ljmp %5 +\newline +%2:} by { +\newline + +\protected_separator + +\protected_separator + +\protected_separator +sjmp %5 +\newline +%2:} if labelInRange +\layout Standard + +The optimizer does a look-up of a function name table defined in function + ' +\emph on +callFuncByName' +\emph default + in the source file +\emph on +SDCCpeeph.c +\emph default + , with the name +\emph on +'labelInRange +\emph default +', if it finds a corresponding entry the function is called. + Note there can be no parameters specified for these functions, in this + case the use of +\emph on +'%5 +\emph default +' is crucial, since the function +\emph on +labelInRange +\emph default + expects to find the label in that particular variable (the hash table containin +g the variable bindings is passed as a parameter). + If you want to code more such functions , take a close look at the function + +\emph on +labelInRange +\emph default + and the calling mechanism in source file +\emph on +SDCCpeeph.c +\emph default +. + I know this whole thing is a little kludgey , may be some day we will have + some better means. + If you are looking at this file, you will also see the default rules that + are compiled into the compiler, you can your own rules in the default set + there if you get tired of specifying the +\emph on +--peep-file +\emph default + option. +\layout Section + +Pointers +\begin_inset LatexCommand \label{Pointers} + +\end_inset + + +\layout Standard + +SDCC allows (via language extensions) pointers to explicitly point to any + of the memory spaces of the 8051. + In addition to the explicit pointers, the compiler also allows a +\emph on +_generic +\emph default + class of pointers which can be used to point to any of the memory spaces. + +\layout Standard + +Pointer declaration examples. +\layout Verbatim + + +\size small +/* pointer physically in xternal ram pointing to object in internal ram + */ +\newline +data unsigned char * xdata p; +\newline + +\layout Verbatim + + +\size small +/* pointer physically in code rom pointing to data in xdata space */ +\newline +xdata unsigned char * code p; +\newline + +\layout Verbatim + + +\size small +/* pointer physically in code space pointing to data in code space */ +\newline +code unsigned char * code p; +\newline + +\newline +/* the folowing is a generic pointer physically located in xdata space */ +\newline +char * xdata p; +\layout Standard + +Well you get the idea. + For compatibility with the previous version of the compiler, the following + syntax for pointer declaration is also supported. + Note the above examples will be portable to other commercially available + compilers. +\layout Verbatim + + +\size small +unsigned char _xdata *ucxdp; /* pointer to data in external ram */ +\newline +unsigned char _data +\protected_separator +*ucdp ; /* pointer to data in internal ram */ +\newline +unsigned char _code +\protected_separator +*uccp ; /* pointer to data in R/O code space */ +\newline +unsigned char _idata *uccp; +\protected_separator +/* pointer to upper 128 bytes of ram */ +\layout Standard + +All unqualified pointers are treated as 3 - byte '_generic' pointers. + These type of pointers can also to be explicitly declared. +\layout Verbatim + + +\size small +unsigned char _generic *ucgp; +\layout Standard + +The highest order byte of the generic pointers contains the data space informati +on. + Assembler support routines are called whenever data is stored or retrieved + using _generic pointers. + These are useful for developing reusable library routines. + Explicitly specifying the pointer type will generate the most efficient + code. + Pointers declared using a mixture of OLD/NEW style could have unpredictable + results. +\layout Section + +Parameters & Local Variables +\begin_inset LatexCommand \label{Auto Variables} + +\end_inset + + +\layout Standard + +Automatic (local) variables and parameters to functions can either be placed + on the stack or in data-space. + The default action of the compiler is to place these variables in the internal + RAM ( for small model) or external RAM (for Large model). + They can be placed on the stack either by using the +\emph on + --stack-auto +\emph default + compiler option or by using the 'reentrant' keyword in the function declaration. +\layout Standard + + +\family typewriter +\size scriptsize +eg +\layout Verbatim + + +\size small +unsigned short foo( short i) reentrant { +\newline +... + +\newline +} +\layout Standard + +Note that when the parameters & local variables are declared in the internal/ext +ernal ram the functions are non-reentrant. + Since stack space on 8051 is limited the +\emph on +'reentrant' +\emph default +keyword or the +\emph on + --stack-auto +\emph default + option should be used sparingly. + Note the reentrant keyword just means that the parameters & local variables + will be allocated to the stack, it DOES NOT mean that the function is register + bank independent. +\layout Standard + +When compiled with the default option (i.e. + non-reentrant ), local variables can be assigned storage classes and absolute + addresses. + +\layout Standard + + +\family typewriter +\size scriptsize +eg +\layout Verbatim + + +\size small +unsigned short foo() { +\newline + +\protected_separator + +\protected_separator +xdata unsigned short i; +\newline + +\protected_separator + +\protected_separator +bit bvar; +\newline + +\protected_separator + +\protected_separator +data at 0x31 unsiged short j; +\newline +... + +\newline +} +\layout Standard + +In the above example the variable +\emph on +i +\emph default + will be allocated in the external ram, +\emph on +bvar +\emph default + in bit addressable space and +\emph on + j +\emph default + in internal ram. + When compiled with the +\emph on +--stack-auto +\emph default + or when a function is declared as +\emph on +'reentrant' +\emph default + local variables cannot be assigned storage classes or absolute addresses. +\layout Standard + +Parameters however are not allowed any storage class, (storage classes for + parameters will be ignored), their allocation is governed by the memory + model in use , and the reentrancy options. +\layout Subsection + +Overlaying +\begin_inset LatexCommand \label{Overlaying} + +\end_inset + + +\layout Standard + +For non-reentrant functions SDCC will try to reduce internal ram space usage + by overlaying parameters and local variables of a function (if possible). + Parameters and local variables of a function will be allocated to an overlayabl +e segment if the function has +\emph on +no other function calls and the function is non-reentrant and the memory + model is small. + +\emph default + If an explicit storage class is specified for a local variable , it will + NOT be overplayed. +\layout Standard + +Note that the compiler (not the linkage editor) makes the decision for overlayin +g the data items. + Functions that are called from an interrupt service routine should be preceded + by a #pragma NOOVERLAY if they are not reentrant Along the same lines the + compiler does not do any processing with the inline assembler code so the + compiler might incorrectly assign local variables and parameters of a function + into the overlay segment if the only function call from a function is from + inline assembler code, it is safe to use the #pragma NOOVERLAY for functions + which call other functions using inline assembler code. +\layout Standard + +Parameters and Local variables of functions that contain 16 or 32 bit multiplica +tion or division will NOT be overlayed since these are implemented using + external functions. +\layout Standard + +eg. +\layout Verbatim + + +\size small +#pragma SAVE +\newline +#pragma NOOVERLAY +\newline +void set_error( unsigned short errcd) +\newline +{ +\newline + +\protected_separator + +\protected_separator + P3 = errcd; +\newline +} +\newline +#pragma RESTORE +\newline +void some_isr () interrupt 2 using 1 +\newline +{ +\newline + +\protected_separator + +\protected_separator + ... + +\newline + +\protected_separator + +\protected_separator + set_error(10); +\newline + +\protected_separator + +\protected_separator + ... + +\newline +} +\layout Standard + +In the above example the parameter +\emph on +errcd +\emph default + for the function +\emph on +set_error +\emph default + would be assigned to the overlayable segment (if the #pragma NOOVERLAY + was not present) , this could cause unpredictable runtime behavior. + The pragma NOOVERLAY ensures that the parameters and local variables for + the function are NOT overlayed. +\layout Section + +critical Functions. +\begin_inset LatexCommand \label{Critical} + +\end_inset + + +\layout Standard + +A special keyword may be associated with a function declaring it as ' +\emph on +critical +\emph default +'. + SDCC will generate code to disable all interrupts upon entry to a critical + function and enable them back before returning . + Note that nesting critical functions may cause unpredictable results. +\layout Standard + +eg +\layout Verbatim + + +\size small +int foo () critical +\newline +{ +\newline +... + +\newline +... + +\newline +} +\layout Standard + +The critical attribute maybe used with other attributes like +\emph on +reentrant. +\layout Section + +Absolute addressing. +\begin_inset LatexCommand \label{Absolute Addressing} + +\end_inset + + +\layout Standard + +Data items can be assigned an absolute address with the +\emph on +at
                  +\emph default + keyword, in addition to a storage class. +\layout Verbatim + +eg. + +\layout Verbatim + + +\size small +xdata at 0x8000 unsigned char PORTA_8255 ; +\layout Standard + +In the above example the +\emph on +PORTA_8255 +\emph default + will be allocated to the location 0x8000 of the external ram. + +\layout Standard + +Note that is this feature is provided to give the programmer access to +\emph on +memory mapped +\emph default + devices attached to the controller. + The compiler does not actually reserve any space for variables declared + in this way (they are implemented with an equate in the assembler), thus + it is left to the programmer to make sure there are no overlaps with other + variables that are declared without the absolute address, the assembler + listing file (.lst) and the linker output files (.rst) and (.m +ap) are a good places to look for such overlaps. +\layout Standard + +Absolute address can be specified for variables in all storage classes. +\layout Verbatim + + +\size small +eg. +\layout Verbatim + + +\size small +bit at 0x02 bvar; +\layout Standard + +The above example will allocate the variable at offset 0x02 in the bit-addressab +le space. + There is no real advantage to assigning absolute addresses to variables + in this manner , unless you want strict control over all the variables + allocated. +\layout Section + +Interrupt Service Routines +\begin_inset LatexCommand \label{Interrupt Service Rouines} + +\end_inset + + +\layout Standard + +SDCC allows interrupt service routines to be coded in C, with some extended + keywords. +\layout Verbatim + + +\size small +void timer_isr (void) interrupt 2 using 1 +\newline +{ +\newline +.. + +\newline +} +\layout Standard + +The number following the 'interrupt' keyword is the interrupt number this + routine will service. + The compiler will insert a call to this routine in the interrupt vector + table for the interrupt number specified. + The 'using' keyword is used to tell the compiler to use the specified register + bank (8051 specific) when generating code for this function. + Note that when some function is called from an interrupt service routine + it should be preceded by a #pragma NOOVERLAY (if it is not reentrant) . + A special note here, int (16 bit) and long (32 bit) integer division, multiplic +ation & modulus operations are implemented using external support routines + developed in ANSI-C, if an interrupt service routine needs to do any of + these operations then the support routines (as mentioned in a following + section) will have to recompiled using the --stack-auto option and the + source file will need to be compiled using the --int-long-rent compiler + option. +\layout Standard + +If you have multiple source files in your project, interrupt service routines + can be present in any of them, but a prototype of the isr MUST be present + in the file that contains the function +\emph on +'main' +\emph default +. +\layout Standard + +Interrupt Numbers and the corresponding address & descriptions for the Standard + 8051 are listed below. + SDCC will automatically adjust the interrupt vector table to the maximum + interrupt number specified. +\layout Verbatim + +Interrupt # +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Description +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Vector Address +\newline + +\protected_separator + +\protected_separator + +\protected_separator +0 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +External 0 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +0x0003 +\newline + +\protected_separator + +\protected_separator + +\protected_separator +1 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Timer 0 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +0x000B +\newline + +\protected_separator + +\protected_separator + +\protected_separator +2 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +External 1 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +0x0013 +\newline + +\protected_separator + +\protected_separator + +\protected_separator +3 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Timer 1 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +0x001B +\newline + +\protected_separator + +\protected_separator + +\protected_separator +4 +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Serial +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +0x0023 +\layout Standard + +If the interrupt service routine is defined without a register bank or with + register bank 0 (using 0), the compiler will save the registers used by + itself on the stack (upon entry and restore them at exit), however if such + an interrupt service routine calls another function then the entire register + bank will be saved on the stack. + This scheme may be advantageous for small interrupt service routines which + have low register usage. +\layout Standard + +If the interrupt service routine is defined to be using a specific register + bank then only +\begin_inset Quotes eld +\end_inset + +a +\begin_inset Quotes erd +\end_inset + +, +\begin_inset Quotes erd +\end_inset + +b +\begin_inset Quotes erd +\end_inset + + & +\begin_inset Quotes eld +\end_inset + +dptr +\begin_inset Quotes erd +\end_inset + + are save and restored, if such an interrupt service routine calls another + function (using another register bank) then the entire register bank of + the called function will be saved on the stack. + This scheme is recommended for larger interrupt service routines. +\layout Standard + +Calling other functions from an interrupt service routine is not recommended + avoid it if possible. +\layout Section + +Startup Code +\begin_inset LatexCommand \label{Startup} + +\end_inset + + +\layout Standard + +The compiler inserts a jump to the C routine +\series bold +_sdcc__external__startup() +\series default +at the start of the CODE area. + This routine can be found in the file +\series bold +SDCCDIR/sdcc51lib/_startup.c +\series default + , by default this routine returns 0, if this routine returns a non-zero + value , the static & global variable initialization will be skipped and + the function main will be invoked, other wise static & global variables + will be initialized before the function main is invoked. +\layout Section + +Inline assembler code. +\begin_inset LatexCommand \label{Inline} + +\end_inset + + +\layout Standard + +SDCC allows the use of in-line assembler with a few restriction as regards + labels. + All labels defined within inline assembler code HAS TO BE of the +\emph on +form nnnnn$ +\emph default + where nnnn is a number less than 100 (which implies a limit of utmost 100 + inline assembler labels +\noun on +per function) +\noun default +. + It is strongly recommended that each assembly instruction (including labels) + be placed in a separate line ( as the example shows). + When the +\series bold +\bar under +--peep-asm +\series default +\bar default + command line option is used, the inline assembler code will be passed through + the peephole optimizer, this might cause some unexpected changes in the + inline assembler code, please go throught the peephole optimizer rules + defined in file 'SDCCpeeph.def' carefully before using this option. +\layout Verbatim + + +\size small +eg +\layout Verbatim + + +\size small +_asm +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +mov b,#10 +\newline +00001$: +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +djnz b,00001$ +\newline +_endasm ; +\layout Standard + +The inline assembler code can contain any valid code understood by the assembler + (this includes any assembler directives and comment lines ) . + The compiler does not do any validation of the code within the +\emph on +_asm ... + _endasm; +\emph default + keyword pair. + +\layout Standard + +Inline assembler code cannot reference any C-Labels however it can reference + labels defined by the inline assembler. +\layout Verbatim + + +\size small +eg +\layout Verbatim + + +\size small +foo() { +\newline +... + /* some c code */ +\newline +_asm +\newline + +\protected_separator + +\protected_separator + +\protected_separator +; some assembler code +\newline + +\protected_separator + +\protected_separator + ljmp $0003 +\newline +_endasm ; +\newline +... + /* some more c code */ +\newline +clabel: +\protected_separator + /* inline assembler cannot reference this label */ +\newline +_asm +\newline + +\protected_separator + +\protected_separator +$0003: ;label (can be reference by inline assembler only) +\newline +_endasm ; +\newline +... + +\newline +} +\layout Standard + +In other words inline assembly code can access labels defined in inline + assembly. + The same goes the other way, ie. + labels defines in inline assembly CANNOT be accessed by C statements. +\layout Section + +int (16 bit) and long (32 bit ) support. +\begin_inset LatexCommand \label{int and long} + +\end_inset + + +\layout Standard + +For signed & unsigned int (16 bit) and long (32 bit) variables, division, + multiplication and modulus operations are implemented by support routines. + These support routines are all developed in ANSI-C to facilitate porting + to other MCUs. + The following files contain the described routine, all of them can be found + in the directory SDCCDIR/sdcc51lib +\layout Itemize + + +\size footnotesize +_mulsint.c - signed 16 bit multiplication (calls _muluint) +\layout Itemize + + +\size footnotesize +_muluint.c - unsigned 16 bit multiplication +\layout Itemize + + +\size footnotesize +_divsint.c - signed 16 bit division (calls _divuint) +\layout Itemize + + +\size footnotesize +_divuint.c - unsigned 16 bit division. +\layout Itemize + + +\size footnotesize +_modsint.c - signed 16 bit modulus (call _moduint) +\layout Itemize + + +\size footnotesize +_moduint.c - unsigned 16 bit modulus. +\layout Itemize + + +\size footnotesize +_mulslong.c - signed 32 bit multiplication (calls _mululong) +\layout Itemize + + +\size footnotesize +_mululong.c - unsigned32 bit multiplication. +\layout Itemize + + +\size footnotesize +_divslong.c - signed 32 division (calls _divulong) +\layout Itemize + + +\size footnotesize +_divulong.c - unsigned 32 division. +\layout Itemize + + +\size footnotesize +_modslong.c - signed 32 bit modulus (calls _modulong). +\layout Itemize + + +\size footnotesize +_modulong.c - unsigned 32 bit modulus. +\layout Standard + +All these routines are compiled as non-reentrant and small model. + Since they are compiled as non-reentrant, interrupt service routines should + not do any of the above operations, if this unavoidable then the above + routines will need to ne compiled with the --stack-auto option, after which + the source program will have to be compiled with --int-long-rent option. +\layout Section + +Floating point support +\begin_inset LatexCommand \label{Float} + +\end_inset + + +\layout Standard + +SDCC supports IEEE (single precision 4bytes) floating point numbers.The floating + point support routines are derived from gcc's floatlib.c and consists of + the following routines. + +\layout Itemize + + +\size footnotesize +_fsadd.c - add floating point numbers. +\layout Itemize + + +\size footnotesize +_fssub.c - subtract floating point numbers +\layout Itemize + + +\size footnotesize +_fsdiv.c - divide floating point numbers +\layout Itemize + + +\size footnotesize +_fsmul.c - multiply floating point numbers +\layout Itemize + + +\size footnotesize +_fs2uchar.c - convert floating point to unsigned char +\layout Itemize + + +\size footnotesize +_fs2char.c - convert floating point to signed char. +\layout Itemize + + +\size footnotesize +_fs2uint.c - convert floating point to unsigned int. +\layout Itemize + + +\size footnotesize +_fs2int.c - convert floating point to signed int. +\layout Itemize + + +\size footnotesize +_fs2ulong.c - convert floating point to unsigned long. +\layout Itemize + + +\size footnotesize +_fs2long.c - convert floating point to signed long. +\layout Itemize + + +\size footnotesize +_uchar2fs.c - convert unsigned char to floating point +\layout Itemize + + +\size footnotesize +_char2fs.c - convert char to floating point number +\layout Itemize + + +\size footnotesize +_uint2fs.c - convert unsigned int to floating point +\layout Itemize + + +\size footnotesize +_int2fs.c - convert int to floating point numbers +\layout Itemize + + +\size footnotesize +_ulong2fs.c - convert unsigned long to floating point number +\layout Itemize + + +\size footnotesize +_long2fs.c - convert long to floating point number. +\layout Standard + +Note if all these routines are used simultaneously the data space might + overflow. + For serious floating point usage it is strongly recommended that the Large + model be used (in which case the floating point routines mentioned above + will need to recompiled with the --model-Large option). +\layout Section + +Memory Models +\begin_inset LatexCommand \label{Memory Models} + +\end_inset + + +\layout Standard + +SDCC allows two memory models, modules compiled with different memory models + should be combined together, the results would be unpredictable. + The support routines supplied with the compiler are compiled in small-model + by default, and will need to be recompiled using the large model if the + large model is used. + In general the use of the large model is discouraged. +\layout Standard + +When the large model is used all variables declared without a storage class + will be allocated into the external ram, this includes all parameters and + local variables (for non-reentrant functions). + When the small model is used variables without storage class are allocated + in the internal ram. +\layout Standard + +Judicious usage of the processor specific storage classes and the 'reentrant' + function type will yield much more efficient code, than using the large-model. + Several optimizations are disabled when the program is compiled using the + large model, it is therefore strongly recommdended that the small model + be used unless absolutely required. +\layout Section + +Defines created by the compiler. +\begin_inset LatexCommand \label{Defines.} + +\end_inset + + +\layout Standard + +The compiler creates the following #defines . +\layout Itemize + +SDCC - this Symbol is always defined. +\layout Itemize + +SDCC_STACK_AUTO - this symbol is defined when --stack-auto option is used. +\layout Itemize + +SDCC_MODEL_SMALL - when small model is used. +\layout Itemize + +SDCC_MODEL_LARGE - when --model-large is used. +\layout Itemize + +SDCC_USE_XSTACK - when --xstack option is used. +\layout Section + +Pragmas +\begin_inset LatexCommand \label{Pragmaa} + +\end_inset + + +\layout Standard + +SDCC supports the following +\emph on +#pragma +\emph default +directives. + This directives are applicable only at a function level. +\layout Itemize + + +\series bold +SAVE +\series default + +\begin_inset LatexCommand \label{pragma save} + +\end_inset + + - this will save all the current options . +\layout Itemize + + +\series bold +RESTORE +\series default + +\begin_inset LatexCommand \label{pragma restore} + +\end_inset + +- will restore the saved options from the last save. + Note that SAVES & RESTOREs cannot be nested. + SDCC uses the same buffer to save the options each time a SAVE is called. +\layout Itemize + + +\series bold +NOGCSE +\series default + +\begin_inset LatexCommand \label{pragma nogcse} + +\end_inset + + - will stop global subexpression elimination. +\layout Itemize + + +\series bold +NOINDUCTION +\series default + +\begin_inset LatexCommand \label{pragma noinduction} + +\end_inset + +- will stop loop induction optimizations . +\layout Itemize + + +\series bold +NOJTBOUND +\series default + +\begin_inset LatexCommand \label{pragma nojtbound} + +\end_inset + +- will not generate code for boundary value checking , when switch statements + are turned into jump-tables. +\layout Itemize + + +\series bold +NOOVERLAY +\series default + +\begin_inset LatexCommand \label{pragma nooverlay} + +\end_inset + +- the compiler will not overlay the parameters and local variables of a + function. +\layout Itemize + + +\series bold +NOLOOPREVERSE +\series default + +\begin_inset LatexCommand \label{pragma noloopreverse} + +\end_inset + +- Will not do loop reversal optimization +\layout Itemize + + +\series bold +EXCLUDE NONE | {acc[,b[,dpl[,dph]]] +\series default + +\begin_inset LatexCommand \label{pragma exclude} + +\end_inset + + - The exclude pragma disables generation of pair of push/pop instruction + in ISR function (using interrupt keyword). + The directive should be placed immediately before the ISR function definition + and it affects ALL ISR functions following it. + To enable the normal register saving for ISR functions use +\begin_inset Quotes eld +\end_inset + +#pragma EXCLUDE none +\begin_inset Quotes erd +\end_inset + + +\layout Itemize + + +\series bold +CALLEE-SAVES function1[,function2[,function3...]] +\series default + +\begin_inset LatexCommand \label{pragma callee-saves} + +\end_inset + + - The compiler by default uses a caller saves convention for register saving + across function calls, however this can cause unneccessary register pushing + & popping when calling small functions from larger functions. + This option can be used to switch the register saving convention for the + function names specified. + The compiler will not save registers when calling these functions, extra + code will be generated at the entry & exit for these functions to save + & restore the registers used by these functions, this can SUBSTANTIALLY + reduce code & improve run time performance of the generated code. + In future the compiler (with interprocedural analysis) will be able to + determine the appropriate scheme to use for each function call. + If --callee-saves +\begin_inset LatexCommand \ref{--callee-saves} + +\end_inset + + command line option is used, the function names specified in #pragma CALLEE-SAV +ES is appended to the list of functions specified inthe command line. +\layout Standard + +The pragma's are intended to be used to turn-off certain optimizations which + might cause the compiler to generate extra stack / data space to store + compiler generated temporary variables. + This usually happens in large functions. + Pragma directives should be used as shown in the following example, they + are used to control options & optimizations for a given function; pragmas + should be placed +\noun on +before +\noun default + and/or +\noun on +after +\noun default + a function, placing pragma's inside a function body could have unpredictable + results. +\layout Verbatim + + +\size scriptsize +eg +\layout Verbatim + + +\size scriptsize +#pragma SAVE +\protected_separator + /* save the current settings */ +\newline +#pragma NOGCSE /* turnoff global subexpression elimination */ +\newline +#pragma NOINDUCTION /* turn off induction optimizations */ +\newline +int foo () +\newline +{ +\newline + +\protected_separator + +\protected_separator + ... + +\newline + +\protected_separator + +\protected_separator + /* large code */ +\newline + +\protected_separator + +\protected_separator + ... + +\newline +} +\newline +#pragma RESTORE /* turn the optimizations back on */ +\layout Standard + +The compiler will generate a warning message when extra space is allocated. + It is strongly recommended that the SAVE and RESTORE pragma's be used when + changing options for a function. +\layout Section + +Library routines. +\begin_inset LatexCommand \label{Library} + +\end_inset + + +\layout Standard + +The following library routines are provided for your convenience. +\layout Standard + + +\series bold +\size large +stdio.h +\series default +\size default +- Contains the following functions printf & sprintf these routines are developed + by +\emph on +Martijn van Balen . + +\layout Verbatim + + +\size scriptsize +%[flags][width][b|B|l|L]type +\layout Verbatim + + +\size scriptsize + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + flags: - +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + left justify output in specified field width +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + prefix output with +/- sign if output is signed type +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + space +\protected_separator + +\protected_separator + +\protected_separator + prefix output with a blank if it's a signed positive value +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + width: +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + specifies minimum number of characters outputted for numbers +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + or strings. + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + - For numbers, spaces are added on the left when needed. + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + If width starts with a zero character, zeroes and used +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + instead of spaces. + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + - For strings, spaces are are added on the left or right (when +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + flag '-' is used) when needed. + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + b/B: +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + byte argument (used by d, u, o, x, X) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + l/L: +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + long argument (used by d, u, o, x, X) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + type: +\protected_separator + d +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + decimal number +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + u +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + unsigned decimal number +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + o +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + unsigned octal number +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + x +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + unsigned hexadecimal number (0-9, a-f) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + X +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + unsigned hexadecimal number (0-9, A-F) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + c +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + character +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + s +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + string (generic pointer) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + p +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + generic pointer (I:data/idata, C:code, X:xdata, P:paged) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + f +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + float (still to be implemented) +\layout Standard + +Also contains a very simple version of printf ( +\series bold +printf_small +\series default +). + This simplified version of printf supports only the following formats. +\layout Verbatim + + +\size scriptsize +\bar under +format +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +output +\protected_separator +type +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +argument-type +\bar default + +\series bold +\size default + +\newline + +\series default +\size scriptsize +%d +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +decimal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + int +\newline +%ld +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +decimal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +long +\newline +%hd +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +decimal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +short/char +\newline +%x +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +hexadecimal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +int +\newline +%lx +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +hexadecimal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +long +\newline +%hx +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +hexadecimal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +short/char +\newline +%o +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +octal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +int +\newline +%lo +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +octal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +long +\newline +%ho +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +octal +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +short/char +\newline +%c +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +character +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +char/short +\newline +%s +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +character +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +_generic pointer +\begin_deeper +\layout Standard + +The routine is +\series bold +very stack intesive +\series default +, --stack-after-data parameter should be used when using this routine, the + routine also takes about 1K of code space .It also expects an external function + named +\emph on +putchar(char ) +\emph default + to be present (this can be changed). + When using the %s format the string / pointer should be cast to a generic + pointer. + eg. +\layout Verbatim + + +\size scriptsize +printf_small( +\begin_inset Quotes eld +\end_inset + +my str %s, my int %d +\backslash +n +\begin_inset Quotes erd +\end_inset + +,(char _generic *)mystr,myint); +\end_deeper +\layout Itemize + + +\series bold +\size large +stdarg.h +\series default +\size default +- contains definition for the following macros to be used for variable parameter + list, note that a function can have a variable parameter list if and only + if it is 'reentrant' +\begin_deeper +\layout Standard + + +\size small +va_list, va_start, va_arg, va_end. +\end_deeper +\layout Itemize + + +\series bold +\size large +setjmp.h +\series default +\size default +- contains defintion for ANSI +\series bold + setjmp +\series default +& +\series bold +longjmp +\series default + routines. + Note in this case setjmp & longjmp can be used between functions executing + within the same register bank, if long jmp is executed from a function + that is using a different register bank from the function issuing the setjmp + function, the results may be unpredictable. + The jump buffer requires 3 bytes of data (the stack pointer & a 16 byte + return address), and can be placed in any address space. +\layout Itemize + + +\series bold +\size large +stdlib.h +\series default +\size default + - contains the following functions. +\begin_deeper +\layout Standard + + +\size footnotesize +atoi, atol. +\end_deeper +\layout Itemize + + +\series bold +\size large +string.h +\series default +\size default +- contains the following functions. +\begin_deeper +\layout Standard + + +\size footnotesize +strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, strspn, + strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp, memset. +\end_deeper +\layout Itemize + + +\series bold +\size large +ctype.h +\series default +\size default + - contains the following routines. +\begin_deeper +\layout Standard + + +\size footnotesize +iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace, + isxdigit, isalnum, isalpha. +\end_deeper +\layout Itemize + + +\series bold +\size large +malloc.h +\series default +\size default + - The malloc routines are developed by Dmitry S. + Obukhov (dso@usa.net). + These routines will allocate memory from the external ram. + Here is a description on how to use them (as described by the author). +\begin_deeper +\layout Verbatim + + +\size scriptsize +//Example: +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + #define DYNAMIC_MEMORY_SIZE 0x2000 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ..... + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE]; +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + unsigned char xdata * current_buffer; +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ..... + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + void main(void) +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + { +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ... + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +// +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE); +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + //Now it's possible to use malloc. + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ... + +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + current_buffer = malloc(0x100); +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + // +\end_deeper +\layout Itemize + + +\series bold +\size large +serial.h +\series default +\size default + - Serial IO routines are also developed by Dmitry S. + Obukhov (dso@usa.net). + These routines are interrupt driven with a 256 byte circular buffer, they + also expect external ram to be present. + Please see documentation in file SDCCDIR/sdcc51lib/serial.c . + Note the header file +\begin_inset Quotes eld +\end_inset + +serial.h +\begin_inset Quotes erd +\end_inset + + MUST be included in the file containing the 'main' function. +\layout Itemize + + +\series bold +\size large +ser.h +\series default +\size default +- Alternate serial routine provided by Wolfgang Esslinger these routines are more compact and faster. + Please see documentation in file SDCCDIR/sdcc51lib/ser.c +\layout Itemize + + +\series bold +\size large +ser_ir.h +\series default +\size default +- Another alternate set of serial routines provided by Josef Wolf , these routines do not use the external ram. +\layout Itemize + + +\series bold +\size large +reg51.h +\series default +\size default + - contains register definitions for a standard 8051 +\layout Itemize + + +\series bold +\size large +reg552.h +\series default +\size default +- contains register definitions for 80C552. +\layout Itemize + + +\series bold +\size large +float.h +\series default +\size default + - contains min, max and other floating point related stuff. +\layout Standard + +All library routines are compiled as --model-small , they are all non-reentrant, + if you plan to use the large model or want to make these routines reentrant, + then they will have to be recompiled with the appropriate compiler option. +\layout Standard + +Have not had time to do the more involved routines like printf, will get + to them shortly. +\layout Section + +Interfacing with assembly routines. +\begin_inset LatexCommand \label{Interface_asm} + +\end_inset + + +\layout Subsection + +Global registers used for parameter passing. +\layout Standard + +By default the compiler uses the global registers +\begin_inset Quotes eld +\end_inset + +DPL,DPH,B,ACC +\begin_inset Quotes erd +\end_inset + + to pass the first parameter to a routine, the second parameter onwards + is either allocated on the stack (for reentrant routines or --stack-auto + is used) or in the internal / external ram (depending on the memory model). + +\layout Subsubsection + +Assembler routine non-reentrant +\layout Standard + +In the following example the function +\series bold + cfunc +\series default + calls an assembler routine +\series bold +asm_func +\series default +, which takes two parameters. +\layout Standard + + +\size footnotesize +extern int asm_func( unsigned short, unsigned short); +\layout Verbatim + + +\size footnotesize + +\protected_separator + +\newline +int c_func (unsigned short i, unsigned short j) +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + return asm_func(i,j); +\newline +} +\size default + +\size scriptsize + +\newline +int main() +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator +return c_func(10,9); +\newline +} +\layout Standard + +The corresponding assembler function is:- +\layout Verbatim + + +\size scriptsize + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .globl _asm_func_PARM_2 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .globl _asm_func +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .area OSEG +\newline +_asm_func_PARM_2: +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .ds +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 1 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .area CSEG +\newline +_asm_func: +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + a,dpl +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + a,_asm_func_PARM_2 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + dpl,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + dpl,#0x00 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ret +\layout Standard + +Note here that the return values are placed in 'dpl' - One byte return value, + 'dpl' LSB & 'dph' MSB for two byte values. + 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph',' +b' & 'acc' for four byte values. +\layout Standard + +The parameter naming convention is +\series bold +__PARM_, +\series default + where n is the parameter number starting from 1, and counting from the + left. + The first parameter is passed in +\begin_inset Quotes eld +\end_inset + +dpl +\begin_inset Quotes erd +\end_inset + + for One bye parameter, +\begin_inset Quotes eld +\end_inset + +dptr +\begin_inset Quotes erd +\end_inset + + if two bytes, +\begin_inset Quotes eld +\end_inset + +b,dptr +\begin_inset Quotes erd +\end_inset + + for three bytes and +\begin_inset Quotes eld +\end_inset + +acc,b,dptr +\begin_inset Quotes erd +\end_inset + + for four bytes, the +\family typewriter +\series bold +\size footnotesize +varaible name for the second parameter will be __PARM_2. +\layout Standard + +Assemble the assembler routine with the following command. +\layout Verbatim + +asx8051 -losg asmfunc.asm +\layout Standard + +Then compile and link the assembler routine to the C source file with the + following command, +\layout Verbatim + +sdcc cfunc.c asmfunc.rel +\layout Subsubsection + +Assembler routine is reentrant +\layout Standard + +In this case the second parameter onwards will be passed on the stack , + the parameters are pushed from right to left i.e. + after the call the left most parameter will be on the top of the stack. + Here is an example. +\layout Standard + + +\size footnotesize +extern int asm_func( unsigned short, unsigned short); +\layout Verbatim + + +\size footnotesize + +\protected_separator + +\layout Verbatim + + +\size footnotesize +int c_func (unsigned short i, unsigned short j) reentrant +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + return asm_func(i,j); +\newline +} +\size default + +\size scriptsize + +\newline +int main() +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator +return c_func(10,9); +\newline +} +\layout Standard + +The corresponding assembler routine is. +\layout Verbatim + + +\size scriptsize + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .globl _asm_func +\newline +_asm_func: +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + push +\protected_separator + _bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + _bp,sp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +mov +\protected_separator + r2,dpl +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + a,_bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + clr +\protected_separator + c +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + a,#0xfd +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + r0,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + a,#0xfc +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + r1,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + a,@r0 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + a,r2 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + dpl,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + dph,#0x00 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + sp,_bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + pop +\protected_separator + _bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ret +\layout Standard + +The compiling and linking procedure remains the same, however note the extra + entry & exit linkage required for the assembler code, _bp is the stack + frame pointer and is used to compute the offset into the stack for parameters + and local variables. +\layout Subsection + +With --noregparms option. +\layout Standard + +When the source is compiled with --noregparms option , space is allocated + for each of the parameters passed to a routine. +\layout Subsubsection + +Assembler routine non-reentrant. +\layout Standard + +In the following example the function +\series bold + cfunc +\series default + calls an assembler routine +\series bold +asm_func +\series default +, which takes two parameters. +\layout Verbatim + + +\size footnotesize +extern int asm_func( unsigned short, unsigned short); +\layout Verbatim + + +\size footnotesize + +\protected_separator + +\newline +int c_func (unsigned short i, unsigned short j) +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + return asm_func(i,j); +\newline +} +\size default + +\size scriptsize + +\newline +int main() +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator +return c_func(10,9); +\newline +} +\layout Standard + +The corresponding assembler function is:- +\layout Verbatim + + +\size scriptsize + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .globl _asm_func_PARM_1 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .globl _asm_func_PARM_2 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .globl _asm_func +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .area OSEG +\newline +_asm_func_PARM_1: +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .ds +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 1 +\newline +_asm_func_PARM_2: +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .ds +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + 1 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .area CSEG +\newline +_asm_func: +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + a,_asm_func_PARM_1 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + a,_asm_func_PARM_2 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + dpl,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + dpl,#0x00 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ret +\layout Standard + +Note here that the return values are placed in 'dpl' - One byte return value, + 'dpl' LSB & 'dph' MSB for two byte values. + 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph',' +b' & 'acc' for four byte values. +\layout Standard + +The parameter naming convention is +\series bold +__PARM_, +\series default + where n is the parameter number starting from 1, and counting from the + left. + i.e. + the +\family typewriter +\series bold +\size footnotesize +left-most parameter name will be __PARM_1. +\layout Standard + +Assemble the assembler routine with the following command. +\layout Verbatim + +asx8051 -losg asmfunc.asm +\layout Standard + +Then compile and link the assembler routine to the C source file with the + following command, +\layout Verbatim + +sdcc cfunc.c asmfunc.rel +\layout Subsubsection + +Assembler routine is reentrant. +\layout Standard + +In this case the parameters will be passed on the stack , the parameters + are pushed from right to left i.e. + after the call the left most parameter will be on the top of the stack. + Here is an example. +\layout Standard + + +\size footnotesize +extern int asm_func( unsigned short, unsigned short); +\layout Verbatim + + +\size footnotesize + +\protected_separator + +\layout Verbatim + + +\size footnotesize +int c_func (unsigned short i, unsigned short j) reentrant +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + return asm_func(i,j); +\newline +} +\size default + +\size scriptsize + +\newline +int main() +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator +return c_func(10,9); +\newline +} +\layout Standard + +The corresponding assembler routine is. +\layout Verbatim + + +\size scriptsize + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + .globl _asm_func +\newline +_asm_func: +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + push +\protected_separator + _bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + _bp,sp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + a,_bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + clr +\protected_separator + c +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + a,#0xfd +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + r0,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + a,_bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + clr +\protected_separator + c +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + a,#0xfc +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + r1,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + a,@r0 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + add +\protected_separator + a,@r1 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + dpl,a +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + dph,#0x00 +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + mov +\protected_separator + sp,_bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + pop +\protected_separator + _bp +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + ret +\layout Standard + +The compiling and linking procedure remains the same, however note the extra + entry & exit linkage required for the assembler code, _bp is the stack + frame pointer and is used to compute the offset into the stack for parameters + and local variables. +\layout Section + +External Stack. +\begin_inset LatexCommand \label{xstack} + +\end_inset + + +\layout Standard + +The external stack is located at the start of the external ram segment , + and is 256 bytes in size. + When --xstack option is used to compile the program , the parameters and + local variables of all reentrant functions are allocated in this area. + This option is provided for programs with large stack space requirements. + When used with the --stack-auto option, all parameters and local variables + are allocated on the external stack (note support libraries will need to + be recompiled with the same options). +\layout Standard + +The compiler outputs the higher order address byte of the external ram segment + into PORT P2, therefore when using the External Stack option, this port + MAY NOT be used by the application program. +\layout Section + +ANSI-Compliance. +\begin_inset LatexCommand \label{ANSI_Compliance} + +\end_inset + + +\layout Standard + +Deviations from the compliancy. +\layout Enumerate + +functions are not always reentrant. +\layout Enumerate + +structures cannot be assigned values directly, cannot be passed as function + parameters or assigned to each other and cannot be a return value from + a function. +\begin_deeper +\layout Verbatim + + +\size small +eg +\end_deeper +\layout Verbatim + + +\size small +struct s { ... + }; +\newline +struct s s1, s2; +\newline +foo() +\newline +{ +\newline +... + +\newline +s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ +\newline +... + +\newline +} +\layout Verbatim + + +\size small +struct s foo1 (struct s parms) /* is invalid in SDCC although allowed in + ANSI */ +\newline +{ +\newline +struct s rets; +\newline +... + +\newline +return rets;/* is invalid in SDCC although allowed in ANSI */ +\newline +} +\layout Enumerate + +'long long' (64 bit integers) not supported. +\layout Enumerate + +'double' precision floating point not supported. +\layout Enumerate + +integral promotions are suppressed. + What does this mean ? The compiler will not implicitly promote an integer + expression to a higher order integer, exception is an assignment or parameter + passing. + +\layout Enumerate + +No support for +\emph on +setjmp +\emph default + and +\emph on +longjmp +\emph default + (for now). +\layout Enumerate + +Old K&R style function declarations are NOT allowed. +\layout Verbatim + + +\size footnotesize +foo( i,j) /* this old style of function declarations */ +\newline +int i,j; /* are valid in ANSI .. + not valid in SDCC */ +\newline +{ +\newline +... + +\newline +} +\layout Enumerate + +functions declared as pointers must be dereferenced during the call. +\begin_deeper +\layout Verbatim + + +\size small +int (*foo)(); +\end_deeper +\layout Verbatim + + +\size small + +\protected_separator + +\protected_separator +... + +\newline + +\protected_separator + +\protected_separator +/* has to be called like this */ +\newline + +\protected_separator + +\protected_separator +(*foo)();/* ansi standard allows calls to be made like 'foo()' */ +\layout Section + +Cyclomatic Complexity +\begin_inset LatexCommand \label{Cyclomatic} + +\end_inset + + +\layout Standard + +Cyclomatic complexity of a function is defined as the number of independent + paths the program can take during execution of the function. + This is an important number since it defines the number test cases you + have to generate to validate the function . + The accepted industry standard for complexity number is 10, if the cyclomatic + complexity reported by SDCC exceeds 10 you should think about simplification + of the function logic. +\layout Standard + +Note that the complexity level is not related to the number of lines of + code in a function. + Large functions can have low complexity, and small functions can have large + complexity levels. + SDCC uses the following formula to compute the complexity. +\layout Verbatim + + +\size small +complexity = (number of edges in control flow graph) - +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +(number of nodes in control flow graph) + 2; +\layout Standard + +Having said that the industry standard is 10, you should be aware that in + some cases it may unavoidable to have a complexity level of less than 10. + For example if you have switch statement with more than 10 case labels, + each case label adds one to the complexity level. + The complexity level is by no means an absolute measure of the algorithmic + complexity of the function, it does however provide a good starting point + for which functions you might look at for further optimization. +\layout Section + +TIPS +\begin_inset LatexCommand \label{Tips} + +\end_inset + + +\layout Standard + +Here are a few guide-lines that will help the compiler generate more efficient + code, some of the tips are specific to this compiler others are generally + good programming practice. +\layout Itemize + +Use the smallest data type to represent your data-value. + If it is known in advance that the value is going to be less than 256 then + use a 'short' or 'char' instead of an 'int'. +\layout Itemize + +Use unsigned when it is known in advance that the value is not going to + be negative. + This helps especially if you are doing division or multiplication. +\layout Itemize + +NEVER jump into a LOOP. +\layout Itemize + +Declare the variables to be local whenever possible, especially loop control + variables (induction). +\layout Itemize + +Since the compiler does not do implicit integral promotion, the programmer + should do an explicit cast when integral promotion is required. +\layout Itemize + +Reducing the size of division , multiplication & modulus operations can + reduce code size substantially. + Take the following code for example. +\begin_deeper +\layout Verbatim + + +\size footnotesize +foobar( unsigned int p1, unsigned char ch) +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +unsigned char ch1 = p1 % ch ; +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +.... +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\newline +} +\layout Standard + +For the modulus operation the variable ch will be promoted to unsigned int + first then the modulus operation will be performed (this will lead to a + call to a support routine). + If the code is changed to +\layout Verbatim + + +\size footnotesize +foobar( unsigned int p1, unsigned char ch) +\newline +{ +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +unsigned char ch1 = (unsigned char)p1 % ch ; +\newline + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +.... +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\newline +} +\layout Standard + +It would substantially reduce the code generated (future versions of the + compiler will be smart enough to detect such optimization oppurtunities). +\end_deeper +\layout Standard + + +\series bold +Notes from an USER ( Trefor@magera.freeserve.co.uk ) +\layout Standard + +The 8051 family of micro controller have a minimum of 128 bytes of internal + memory which is structured as follows +\layout Standard + +- Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R7 to R7 + +\layout Standard + +- Bytes 20-2F - 16 bytes to hold 128 bit variables and +\layout Standard + +- Bytes 30-7F - 60 bytes for general purpose use. +\layout Standard + +Normally the SDCC compiler will only utilise the first bank of registers, + but it is possible to specify that other banks of registers should be used + in interrupt routines. + By default, the compiler will place the stack after the last bank of used + registers, i.e. + if the first 2 banks of registers are used, it will position the base of + the internal stack at address 16 (0X10). + This implies that as the stack grows, it will use up the remaining register + banks, and the 16 bytes used by the 128 bit variables, and 60 bytes for + general purpose use. +\layout Standard + +By default, the compiler uses the 60 general purpose bytes to hold "near + data". + The compiler/optimiser may also declare some Local Variables in this area + to hold local data. + +\layout Standard + +If any of the 128 bit variables are used, or near data is being used then + care needs to be taken to ensure that the stack does not grow so much that + it starts to over write either your bit variables or "near data". + There is no runtime checking to prevent this from happening. +\layout Standard + +The amount of stack being used is affected by the use of the "internal stack" + to save registers before a subroutine call is made, - --stack-auto will + declare parameters and local variables on the stack - the number of nested + subroutines. +\layout Standard + +If you detect that the stack is over writing you data, then the following + can be done. + --xstack will cause an external stack to be used for saving registers and + (if --stack-auto is being used) storing parameters and local variables. + However this will produce more and code which will be slower to execute. + +\layout Standard + +--stack-loc will allow you specify the start of the stack, i.e. + you could start it after any data in the general purpose area. + However this may waste the memory not used by the register banks and if + the size of the "near data" increases, it may creep into the bottom of + the stack. +\layout Standard + +--stack-after-data, similar to the --stack-loc, but it automatically places + the stack after the end of the "near data". + Again this could waste any spare register space. +\layout Standard + +--data-loc allows you to specify the start address of the near data. + This could be used to move the "near data" further away from the stack + giving it more room to grow. + This will only work if no bit variables are being used and the stack can + grow to use the bit variable space. +\layout Standard + +Conclusion. +\layout Standard + +If you find that the stack is over writing your bit variables or "near data" + then the approach which best utilised the internal memory is to position + the "near data" after the last bank of used registers or, if you use bit + variables, after the last bit variable by using the --data-loc, e.g. + if two register banks are being used and no data variables, --data-loc + 16, and - use the --stack-after-data option. +\layout Standard + +If bit variables are being used, another method would be to try and squeeze + the data area in the unused register banks if it will fit, and start the + stack after the last bit variable. +\layout Section + +Retargetting for other MCUs. +\begin_inset LatexCommand \label{Retargetting} + +\end_inset + + +\layout Standard + +The issues for retargetting the compiler are far too numerous to be covered + by this document. + What follows is a brief description of each of the seven phases of the + compiler and its MCU dependency. +\layout Enumerate + +Parsing the source and building the annotated parse tree. + This phase is largely MCU independent (except for the language extensions). + Syntax & semantic checks are also done in this phase , along with some + initial optimizations like back patching labels and the pattern matching + optimizations like bit-rotation etc. +\layout Enumerate + +The second phase involves generating an intermediate code which can be easy + manipulated during the later phases. + This phase is entirely MCU independent. + The intermediate code generation assumes the target machine has unlimited + number of registers, and designates them with the name iTemp. + The compiler can be made to dump a human readable form of the code generated + by using the --dumpraw option. +\layout Enumerate + +This phase does the bulk of the standard optimizations and is also MCU independe +nt. + This phase can be broken down into several sub-phases. +\begin_deeper +\layout Itemize + +Break down intermediate code (iCode) into basic blocks. +\layout Itemize + +Do control flow & data flow analysis on the basic blocks. +\layout Itemize + +Do local common subexpression elimination, then global subexpression elimination +\layout Itemize + +dead code elimination +\layout Itemize + +loop optimizations +\layout Itemize + +if loop optimizations caused any changes then do 'global subexpression eliminati +on' and 'dead code elimination' again. +\end_deeper +\layout Enumerate + +This phase determines the live-ranges; by live range I mean those iTemp + variables defined by the compiler that still survive after all the optimization +s. + Live range analysis is essential for register allocation, since these computati +on determines which of these iTemps will be assigned to registers, and for + how long. +\layout Enumerate + +Phase five is register allocation. + There are two parts to this process . +\begin_deeper +\layout Enumerate + +The first part I call 'register packing' (for lack of a better term) . + In this case several MCU specific expression folding is done to reduce + register pressure. +\layout Enumerate + +The second part is more MCU independent and deals with allocating registers + to the remaining live ranges. + A lot of MCU specific code does creep into this phase because of the limited + number of index registers available in the 8051. +\end_deeper +\layout Enumerate + +The Code generation phase is (unhappily), entirely MCU dependent and very + little (if any at all) of this code can be reused for other MCU. + However the scheme for allocating a homogenized assembler operand for each + iCode operand may be reused. +\layout Enumerate + +As mentioned in the optimization section the peep-hole optimizer is rule + based system, which can reprogrammed for other MCUs. +\layout Section + +Reporting Bugs +\begin_inset LatexCommand \label{Bugs} + +\end_inset + + +\layout Standard + +Shoot of an email to 'sandeep.dutta@usa.net', as a matter of principle I always + reply to all email's sent to me. + Bugs will be fixed ASAP. + When reporting a bug , it is useful to include a small snippet of code + that is causing the problem, if possible compile your program with the + --dumpall option and send the dump files along with the bug report. +\layout Section + +SDCDB - Source level debugger. +\layout Standard + +SDCC is distributed with a source level debugger. + The debugger uses a command line interface, the command repertoire of the + debugger has been kept as close to gdb ( the GNU debugger) as possible. + The configuration and build process of the compiler see Installation +\begin_inset LatexCommand \ref{Installation} + +\end_inset + + also builds and installs the debugger in the target directory specified + during configuration. + The debugger allows you debug BOTH at the C source and at the ASM source + level. +\layout Subsection + +Compiling for debugging. +\layout Standard + +The +\emph on +--debug +\emph default + option must be specified for all files for which debug information is to + be generated. + The complier generates a +\emph on +.cdb +\emph default + file for each of these files. + The linker updates the +\emph on +.cdb +\emph default + file with the address information. + This .cdb is used by the debugger . +\layout Subsection + +How the debugger works. +\layout Standard + +When the +\emph on +--debug +\emph default + option is specified the compiler generates extra symbol information some + of which are put into the the assembler source and some are put into the + .cdb file, the linker updates the .cdb file with the address information + for the symbols. + The debugger reads the symbolic information generated by the compiler & + the address information generated by the linker. + It uses the SIMULATOR (Daniel's S51) to execute the program, the program + execution is controlled by the debugger. + When a command is issued for the debugger, it translates it into appropriate + commands for the simulator . +\layout Subsection + +Starting the debugger. +\layout Standard + +The debugger can be started using the following command line. + (Assume the file you are debugging has +\layout Standard + +the file name foo). +\layout Verbatim + +>sdcdb foo +\layout Standard + +The debugger will look for the following files. +\layout Enumerate + +foo.c - the source file. +\layout Enumerate + +foo.cdb - the debugger symbol information file. +\layout Enumerate + +foo.ihx - the intel hex format object file. +\layout Subsection + +Command line options. +\layout Itemize + +--directory= this option can used to specify the + directory search list. + The debugger will look into the directory list specified for source , cdb + & ihx files. + The items in the directory list must be separated by ':' , e.g. + if the source files can be in the directories /home/src1 and /home/src2, + the --directory option should be --directory=/home/src1:/home/src2 . + Note there can be no spaces in the option. + +\layout Itemize + +-cd - change to the . +\layout Itemize + +-fullname - used by GUI front ends. +\layout Itemize + +-cpu - this argument is passed to the simulator please see the + simulator docs for details. +\layout Itemize + +-X this options is passed to the simulator please see + simulator docs for details. +\layout Itemize + +-s passed to simulator see simulator docs for details. +\layout Itemize + +-S passed to simulator see simulator docs for details. +\layout Subsection + +Debugger Commands. +\layout Standard + +As mention earlier the command interface for the debugger has been deliberately + kept as close the GNU debugger gdb , as possible, this will help int integratio +n with existing graphical user interfaces (like ddd, xxgdb or xemacs) existing + for the GNU debugger. +\layout Subsubsection + +break [line | file:line | function | file:function] +\layout Standard + +Set breakpoint at specified line or function. +\layout Verbatim + +sdcdb>break 100 +\newline +sdcdb>break foo.c:100 +\newline +sdcdb>break funcfoo +\newline +sdcdb>break foo.c:funcfoo +\layout Subsubsection + +clear [line | file:line | function | file:function ] +\layout Standard + +Clear breakpoint at specified line or function. +\layout Verbatim + +sdcdb>clear 100 +\newline +sdcdb>clear foo.c:100 +\newline +sdcdb>clear funcfoo +\newline +sdcdb>clear foo.c:funcfoo +\layout Subsubsection + +continue +\layout Standard + +Continue program being debugged, after breakpoint. +\layout Subsubsection + +finish +\layout Standard + +Execute till the end of the current function. +\layout Subsubsection + +delete [n] +\layout Standard + +Delete breakpoint number 'n'. + If used without any option clear ALL user defined break points. +\layout Subsubsection + +info [break | stack | frame | registers ] +\layout Itemize + +info break - list all breakpoints +\layout Itemize + +info stack - show the function call stack. +\layout Itemize + +info frame - show information about the current execution frame. +\layout Itemize + +info registers - show content of all registers. +\layout Subsubsection + +step +\layout Standard + +Step program until it reaches a different source line. +\layout Subsubsection + +next +\layout Standard + +Step program, proceeding through subroutine calls. +\layout Subsubsection + +run +\layout Standard + +Start debugged program. +\layout Subsubsection + +ptype variable +\layout Standard + +Print type information of the variable. +\layout Subsubsection + +print variable +\layout Standard + +print value of variable. +\layout Subsubsection + +file filename +\layout Standard + +load the given file name. + Note this is an alternate method of loading file for debugging. +\layout Subsubsection + +frame +\layout Standard + +print information about current frame. +\layout Subsubsection + +set srcmode +\layout Standard + +Toggle between C source & assembly source. +\layout Subsubsection + +! simulator command +\layout Standard + +Send the string following '!' to the simulator, the simulator response is + displayed. + Note the debugger does not interpret the command being sent to the simulator, + so if a command like 'go' is sent the debugger can loose its execution + context and may display incorrect values. +\layout Subsubsection + +quit. +\layout Standard + +"Watch me now. + Iam going Down. + My name is Bobby Brown" +\layout Subsection + +Interfacing with XEmacs. +\layout Standard + +Two files are (in emacs lisp) are provided for the interfacing with XEmacs, +\emph on + sdcdb.el +\emph default + and +\emph on +sdcdbsrc.el +\emph default +. + These two files can be found in the $(prefix)/bin directory after the installat +ion is complete. + These files need to be loaded into XEmacs for the interface to work, this + can be done at XEmacs startup time by inserting the following into your + +\emph on +'.xemacs' +\emph default + file (which can be found in your HOME directory) +\emph on +(load-file sdcdbsrc.el) +\emph default +[ .xemacs is a lisp file so the () around the command is REQUIRED), the files + can also be loaded dynamically while XEmacs is running, set the environment + variable +\emph on +'EMACSLOADPATH' +\emph default +to the installation bin directory [$(prefix)/bin], then enter the following + command +\emph on +ESC-x load-file sdcdbsrc . + +\emph default +To start the interface enter the following command +\emph on +ESC-x sdcdbsrc +\emph default + , you will prompted to enter the file name to be debugged. + +\layout Standard + +The command line options that are passed to the simulator directly are bound + to default values in the file +\emph on +sdcdbsrc.el +\emph default +the variables are listed below these values maybe changed as required. +\layout Itemize + +sdcdbsrc-cpu-type '51 +\layout Itemize + +sdcdbsrc-frequency '11059200 +\layout Itemize + +sdcdbsrc-serial nil +\layout Standard + +The following is a list of key mapping for the debugger interface. +\layout Verbatim + + +\protected_separator + +\size scriptsize + +\newline +;; Current Listing :: +\newline +;;key +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +binding +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Comment +\newline +;;--- +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +------- +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +------- +\newline +;; +\newline +;; n +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-next-from-src +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB next command +\newline +;; b +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-back-from-src +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB back command +\newline +;; c +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-cont-from-src +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB continue command +\newline +;; s +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-step-from-src +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB step command +\newline +;; ? +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-whatis-c-sexp +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB ptypecommand for data at +\newline +;; +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + buffer point +\newline +;; x +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdbsrc-delete +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB Delete all breakpoints if no arg +\newline +;; +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +given or delete arg (C-u arg x) +\newline +;; m +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdbsrc-frame +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB Display current frame if no arg, +\newline +;; +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +given or display frame arg +\newline +;; +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +buffer point +\newline +;; ! +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdbsrc-goto-sdcdb +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Goto the SDCDB output buffer +\newline +;; p +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-print-c-sexp +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB print command for data at +\newline +;; +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + buffer point +\newline +;; g +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdbsrc-goto-sdcdb +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Goto the SDCDB output buffer +\newline +;; t +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdbsrc-mode +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Toggles Sdcdbsrc mode (turns it off) +\newline +;; +\newline +;; C-c C-f +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-finish-from-src +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +SDCDB finish command +\newline +;; +\newline +;; C-x SPC +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdb-break +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Set break for line with point +\newline +;; ESC t +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdbsrc-mode +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator +Toggle Sdcdbsrc mode +\newline +;; ESC m +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + sdcdbsrc-srcmode +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + +\protected_separator + Toggle list mode +\newline +;; +\newline + +\layout Section + +Conclusion +\begin_inset LatexCommand \label{Conclusion} + +\end_inset + + +\layout Standard + +SDCC is a large project , the compiler alone (without the Assembler Package + , Preprocessor & garbage collector) is about 40,000 lines of code (blank + stripped). + As with any project of this size there are bound to be bugs, I am more + than willing to work to fix these bugs , of course all the source code + is included with the package. + +\layout Standard + +Where does it go from here ? I am planning to target the Atmel AVR 8-bit + MCUs which seems to have a lot of users. + I am also planning to include an alias analysis system with this compiler + (it does not currently have one). +\layout Section + +Acknowledgments +\begin_inset LatexCommand \label{Acknowledgements} + +\end_inset + + +\layout Standard + +Alan Baldwin (baldwin@shop-pdp.kent.edu) - Initial version of ASXXXX & ASLINK. + +\layout Standard + +John Hartman (jhartman@compuserve.com) - Porting ASXXX & ASLINK for 8051 +\layout Standard + +Dmitry S. + Obukhov (dso@usa.net) - malloc & serial i/o routines. + +\layout Standard + +Daniel Drotos - for his Freeware simulator +\layout Standard + +Jans J Boehm(boehm@sgi.com) and Alan J Demers - Conservative garbage collector + for C & C++. +\layout Standard + +Malini Dutta(malini_dutta@hotmail.com) - my wife for her patience and support. +\layout Standard + +Unknown - for the GNU C - preprocessor. +\layout Standard + + +\begin_inset LatexCommand \index{} + +\end_inset + + +\the_end diff --git a/doc/SDCCUdoc.sgml b/doc/SDCCUdoc.sgml new file mode 100644 index 00000000..f4bfeacf --- /dev/null +++ b/doc/SDCCUdoc.sgml @@ -0,0 +1,2520 @@ + + + + + + SDCC Compiler User Guide + + Sandeep Dutta (sandeep.dutta@usa.net) + + Introduction +

                  SDCC is a Free ware , retargettable, optimizing ANSI-C compiler. The current + version targets Intel 8051 based MCUs, it can be retargetted for other 8 bit + MCUs or PICs. The entire source code for the compiler is distributed under + GPL. SDCC used ASXXXX & ASLINK a Free ware, retargettable assembler & + linker. SDCC has extensive MCU (8051) specific language extensions, which lets + it utilize the underlying hardware effectively. The front-end (parser) will + be enhanced to handle language extensions for other MCUs as and when they are + targetted. In addition to the MCU Specific optimizations SDCC also does a host + of standard optimizations like global sub expression elimination, loop optimizations + (loop invariant, strength reduction of induction variables and loop reversing), + constant folding & propagation, copy propagation, dead code elimination + and jumptables for 'switch' statements. For the back-end SDCC uses a global + register allocation scheme which should be well suited for other 8 bit MCUs + , the peep hole optimizer uses a rule based substitution mechanism which is + MCU independent. Supported data-types are short (8 bits, 1 byte), char (8 bits, + 1 byte), int (16 bits, 2 bytes ), long (32 bit, 4 bytes) & float (4 byte + IEEE). The compiler also allows inline assembler code to be embedded anywhere + in a function. In addition routines developed in assembly can also be called. + SDCC also provides an option to report the relative complexity of a function, + these functions can then be further optimized , or hand coded in assembly if + need be. SDCC also comes with a companion source level debugger SDCDB, the + debugger currently uses S51 a freeware simulator for 8051, it can be easily + modified to use other simulators. The latest version can be downloaded from + http://www.geocities.com/ResearchTriangle/Forum/1353 +

                  +

                  All packages used in this compiler system are opensource (freeware); source + code for all the sub-packages ( asxxxx assembler/linker , pre-processor and + gc a conservative garbage collector) are distributed with the package. Documentation + was created using a freeware word processor (LyX). +

                  +

                  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, 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; if not, write to the Free Software Foundation, 59 Temple Place + - Suite 330, Boston, MA 02111-1307, USA. In other words, you are welcome to + use, share and improve this program. You are forbidden to forbid anyone else + to use, share and improve what you give them. Help stamp out software-hoarding! + +

                  + Installation
                  \ No newline at end of file diff --git a/doc/SDCCUdoc.txt b/doc/SDCCUdoc.txt new file mode 100644 index 00000000..838102c0 --- /dev/null +++ b/doc/SDCCUdoc.txt @@ -0,0 +1,2620 @@ + + +SDCC Compiler User Guide + +Sandeep Dutta (sandeep.dutta@usa.net) + +1 Introduction + +SDCC is a Free ware , retargettable, optimizing ANSI-C compiler. The +current version targets Intel 8051 based MCUs, it can be retargetted +for other 8 bit MCUs or PICs. The entire source code for the compiler +is distributed under GPL. SDCC used ASXXXX & ASLINK a Free ware, retargettable +assembler & linker. SDCC has extensive MCU (8051) specific language +extensions, which lets it utilize the underlying hardware effectively. +The front-end (parser) will be enhanced to handle language extensions +for other MCUs as and when they are targetted. In addition to the +MCU Specific optimizations SDCC also does a host of standard optimizations +like global sub expression elimination, loop optimizations (loop invariant, +strength reduction of induction variables and loop reversing), constant +folding & propagation, copy propagation, dead code elimination and +jumptables for 'switch' statements. For the back-end SDCC uses a global +register allocation scheme which should be well suited for other 8 +bit MCUs , the peep hole optimizer uses a rule based substitution +mechanism which is MCU independent. Supported data-types are short +(8 bits, 1 byte), char (8 bits, 1 byte), int (16 bits, 2 bytes ), +long (32 bit, 4 bytes) & float (4 byte IEEE). The compiler also allows +inline assembler code to be embedded anywhere in a function. In addition +routines developed in assembly can also be called. SDCC also provides +an option to report the relative complexity of a function, these functions +can then be further optimized , or hand coded in assembly if need +be. SDCC also comes with a companion source level debugger SDCDB, +the debugger currently uses S51 a freeware simulator for 8051, it +can be easily modified to use other simulators. The latest version +can be downloaded from http://www.geocities.com/ResearchTriangle/Forum/1353 + +All packages used in this compiler system are opensource (freeware); +source code for all the sub-packages ( asxxxx assembler/linker , pre-processor +and gc a conservative garbage collector) are distributed with the +package. Documentation was created using a freeware word processor +(LyX). + +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, 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; +if not, write to the Free Software Foundation, 59 Temple Place - Suite +330, Boston, MA 02111-1307, USA. In other words, you are welcome to +use, share and improve this program. You are forbidden to forbid anyone +else to use, share and improve what you give them. Help stamp out +software-hoarding! + +2 Installation \label{Installation} + +What you need before you start installation of SDCC ? A C Compiler, +not just any C Compiler, gcc to be exact, you can get adventurous +and try another compiler , I HAVEN'T tried it. GCC is free , and is +available for almost all major platforms, if you are using linux you +probably already have it, if you are using Windows 95/NT go to www.cygnus.com +and download CYGWIN32 you will need the full development version of +their tool (full.exe), follow their instructions for installation +(this is also free and is very easy to install), Windows 95/NT users +be aware that the compiler runs substantially slower on the Windows +platform, I am not sure why. + +After you have installed gcc you are ready to build the compiler (sorry +no binary distributions yet). SDCC is native to Linux but can be ported +to any platform on which GCC is available . Extract the source file +package (.zip or .tar.gz) into some directory , which we shall refer +to as SDCCDIR from now on. + +2.1 Components of SDCC\label{Components} + +2.1.1 gc ( a conservative garbage collector) + +SDCC relies on this component to do all the memory management, this +excellent package is copyrighted by Jans J Boehm(boehm@sgi.com) and +Alan J Demers but can be used with minimum restrictions. The GC source +will be extracted into the directory SDCCDIR/gc. + +2.1.2 cpp ( C-Preprocessor) + +The preprocessor is extracted into the directory SDCCDIR/cpp, it is +a modified version of the GNU preprocessor. + +2.1.3 asxxxx & aslink ( The assembler and Linkage Editor) + +This is retargettable assembler & linkage editor, it was developed +by Alan Baldwin, John Hartman created the version for 8051, and I +(Sandeep) have some enhancements and bug fixes for it to work properly +with the SDCC. This component is extracted into the directory SDCCDIR/asxxxx. + +2.1.4 SDCC - The compiler. + +This is the actual compiler, it uses gc and invokes the assembler and +linkage editor. All files with the prefix SDCC are part of the compiler +and is extracted into the the directory SDCCDIR. + +2.1.5 S51 - Simulator + +Version 2.1.8 onwards contains s51 a freeware , opensource simulator +developed by Daniel Drotos . The +executable is built as part of build process, for more information +visit Daniel's website at . + +2.1.6 SDCDB - Source level Debugger. + +SDCDB is the companion source level debugger . The current version +of the debugger uses Daniel's Simulator S51, but can be easily changed +to use other simulators. + +2.2 Installation for Version <= 2.1.7 + +After the package is extracted (Windows 95/NT users start CYGWIN shell), +change to the directory where you extracted the package and give the +command. + +./sdccbuild.sh + +This is a bash shell script, it will compile all the above mentioned +components and install the executables into the directory SDCCDIR/bin +make sure you add this directory to your PATH environment variable. +This script will also compile all the support routines ( library routines +) using SDCC. The support routines are all developed in C and need +to be compiled. + +2.3 Installation for Version >= 2.1.8a + +The distribution method from Version 2.1.8a has been changed to be +conforment with the ``autoconf'' utility. The source is now distributed +as sdcc-.tar.gz format , instead of the older .zip +format. The steps for installation are as follows. + +2.3.1 Unpack the sources. + +This is usually done by the following command ``gunzip -c sdcc-.tar.gz | tar -xv -`` + +2.3.2 Change to the main source directory (usually sdcc or sdcc-) + +2.3.3 Issue command to configure your system + +The configure command has several options the most commonly used option +is --prefix=, where is the final +location for the sdcc executables and libraries, (default location +is /usr/local). The installation process will create the following +directory structure under the specified. + +bin/ - binary exectables (add to PATH environment variable) +share/ + sdcc51inc/ - include header files + sdcc51lib/ - + small/ - Object & Library files for small model library + large/ - Object & library files for large model library + +The command + +'./configure --prefix=/usr/local'' + +will create configure the compiler to be installed in directory /usr/local/bin. + +2.3.4 make + +After configuration step issue the command + +``make'' + +This will compile the compiler + +2.3.5 ``make install'' + +Will install the compiler and libraries in the appropriate directories. + +2.3.6 Special Notes for Windows Users. Provided by Michael Jamet[ mjamet@computer.org] + + + + How to install SDCC from source on a Windows 95 or Windows NT 4 system + + + + This document describes how to install SDCC on a Win 95 or Win NT +4 system. + + These instructions probably work for Win 98 as well, but have not +been + + tested on that platform. + + + + There are lots of little differences between UNIX and the Win32 Cygnus + + environment which make porting more difficult than it should be. If + + you want the details, please contact me. Otherwise just follow these + + instructions. + + + + 1. Install the Cygnus Software + + Go to http://sourceware.cygnus.com/cygwin. Cygnus provides a UNIX +like + + environment for Win 32 systems. Download "full.exe" and install. You + + MUST install it on your C drive. "full.exe" contains a shell AND many + + common UNIX utilities. + + + + 2. Download and Extract the Latest SDCC + + The latest version can be found at + + www.geocities.com/ResearchTriange/Forum/1353. + + It can be uncompressed with winzip. + + + + 3. Start a Cygnus Shell + + There should be an entry in the Start Menu for Cygnus. Invoke the +shell. + + This gives you a UNIX like environment. FROM THIS POINT ON, DIRECTORIES + + MUST BE SPECIFIED WITH FORWARD SLASHES (/) NOT THE DOS STYLE BACK + + SLASHES (\) BECAUSE THIS IS WHAT UNIX EXPECTS. - + + ex. "\winnt" would be "/winnt" under the shell. + + + + 4. Change Directory to Where SDCC was extracted (referred to as INSTALLDIR) + + + + ex. cd /sdcc218Da. If you extracted to a drive OTHER THAN C, the drive + + must be specified as part of the path. For example, if you extracted +to + + your "g drive", type the following: "cd //g/mydir". You must use "//" + + to specify the drive. + + + + 5. Make Dirs Which are Automatically Made During the UNIX Installation + + From the INSTALLDIR, + + + + mkdir -p bin (not a typo, just "bin") + + mkdir -p /bin + + mkdir -p /usr/local/bin + + mkdir -p /usr/local/share + + mkdir -p /usr/local/share/sdcc51lib + + mkdir -p /usr/local/share/sdcc51inc + + mkdir -p /tmp + + + + (When a path from the root directory is specified WITHOUT a drive, +the + + drive defaults to c. For example /michael/newuser => c:\michael\newuser) + + + + 6. Add Programs to /bin Expected by the Installation Process + + - Look at your path: echo $PATH + + One of the fields is the diretory with the CYGNUS programs. + + ex. /CYGNUS/CYGWIN~1/H-I586/BIN + + + + - cd to the directory found above. You may have to fiddle with the + + case (upper or lower) here because the PATH is SHOWN as all upper + + case, but is actually mixed. To help you along, you may type + + a letter or 2 followed by the escape key. The shell will fill + + out the remaining letters IF THEY describe a unique directory. + + If you have problems here, cd one directory and type "ls". "ls" + + is the equivalent of "dir/w". + + + + - Copy the following: + + cp sh.exe /bin + + cp pwd.exe /bin + + cp echo.exe /bin + + + + 7. Go back to the INSTALLDIR + + cd INSTALLDIR + + ex. cd //d/sdcc218Da + + + + 8. Run the configure Program + + ./configure + + The "./" is important because your current directory is NOT in your +path. + + Under DOS, your current directory was implicitly always the first +entry + + in your path. + + + + 9. Run make + + make + + + + This process takes quite some time under Win 32. + + + + 10. Install the Newly Built Software + + make install + + + + This will partially install the software into the /usr/local directories + + created in step 5. What it actually doing is copying the .c, .h and + + library files to directories under /usr/local/share. + + + + It will NOT be able to install the actual programs (binaries) because + + it does not know programs on Win32 systems have ".exe" extensions. + + For example, it tries to install sdcc instead of sdcc.exe. + + + + After the automated part is finished, you must manually copy the binaries: + + cd bin (This is the bin directory in your INSTALLDIR) + + cp * /usr/local/bin + + + + 11. Make sure /usr/local/bin is in Your PATH + + You may add c:\usr\local\bin to your path however your Win32 system allows. +For + + example you may add it to the PATH statement in autoexec.bat. + + + + Good luck. If you have any questions send them to me or post them + + to the list. + +3 Compiling.\label{Compiling} + +3.1 Single Source file projects.\label{One Source File} + +For single source file projects the process is very simple. Compile +your programs with the following command + +sdcc sourcefile.c + +The above command will compile ,assemble and link your source file. +Output files are as follows. + +* sourcefile.asm - Assembler source file created by the compiler + +* sourcefile.lst - Assembler listing file created by the Assembler + +* sourcefile.rst - Assembler listing file updated with linkedit information + , created by linkage editor + +* sourcefile.sym - symbol listing for the sourcefile, created by the + assembler. + +* sourcefile.rel - Object file created by the assembler, input to Linkage + editor. + +* sourcefile.map - The memory map for the load module, created by the + Linker. + +* sourcefile. - The load module : ihx - Intel hex format + (default ), s19 - Motorola S19 format when compiler option --out-fmt-s19 + is used. + +3.2 Projects with multiple source files. + +SDCC can compile only ONE file at a time. Let us for example assume +that you have a project containing the following files. + +foo1.c ( contains some functions ) + +foo2.c (contains some more functions) + +foomain.c (contains more functions and the function main) + +The first two files will need to be compiled separately with the commands + +sdcc -c foo1.c + +sdcc -c foo2.c + +Then compile the source file containing main and link the other files +together with the following command. + +sdcc foomain.c foo1.rel foo2.rel + +Alternatively foomain.c can be separately compiled as well + +sdcc -c foomain.c + +sdcc foomain.rel foo1.rel foo2.rel + +The file containing the main function MUST be the FIRST file specified +in the command line , since the linkage editor processes file in the +order they are presented to it. + +3.3 Projects with additional libraries. + +Some reusable routines may be compiled into a library, see the documentation +for the assembler and linkage editor in the directory SDCCDIR/asxxxx/asxhtm.htm +this describes how to create a .lib library file, the libraries created +in this manner may be included using the command line, make sure you +include the -L option to tell the linker where to look +for these files. Here is an example, assuming you have the source +file 'foomain.c' and a library 'foolib.lib' in the directory 'mylib'. + +sdcc foomain.c foolib.lib -L mylib + +Note here that 'mylib' must be an absolute path name. + +The view of the way the linkage editor processes the library files, +it is recommended that you put each source routine in a separate file +and combine them using the .lib file. For an example see the standard +library file 'libsdcc.lib' in the directory SDCCDIR/sdcc51lib. + +4 Command Line options\label{Command Line Options} + +* --model-large\label{--model-large} Generate code for Large model + programs see section Memory Models for more details. If this option + is used all source files in the project should be compiled with + this option. In addition the standard library routines are compiled + with small model , they will need to be recompiled. + +* --model-small \label{--model-small}Generate code for Small Model + programs see section Memory Models for more details. This is the + default model. + +* --stack-auto \label{--stack-auto}All functions in the source file + will be compiled as reentrant, i.e. the parameters and local variables + will be allocated on the stack. see section Parameters and Local + Variables for more details. If this option is used all source files + in the project should be compiled with this option. + +* --xstack\label{--xstack} Uses a pseudo stack in the first 256 bytes + in the external ram for allocating variables and passing parameters. + See section on external stack for more details. + +* --nogcse\label{--nogcse} Will not do global subexpression elimination, + this option may be used when the compiler creates undesirably large + stack/data spaces to store compiler temporaries. A warning message + will be generated when this happens and the compiler will indicate + the number of extra bytes it allocated. It recommended that this + option NOT be used , #pragma NOGCSE can be used to turn off global + subexpression elimination for a given function only. + +* --noinvariant\label{--noinvariant} Will not do loop invariant optimizations, + this may be turned off for reasons explained for the previous option + . For more details of loop optimizations performed see section Loop + Invariants.It recommended that this option NOT be used , #pragma + NOINVARIANT can be used to turn off invariant optimizations for + a given function only. + +* --noinduction\label{--noinduction} Will not do loop induction optimizations, + see section Strength reduction for more details.It recommended that + this option NOT be used , #pragma NOINDUCTION can be used to turn + off induction optimizations for given function only. + +* --nojtbound \label{--nojtbound} Will not generate boundary condition + check when switch statements are implemented using jump-tables. + See section Switch Statements for more details.It recommended that + this option NOT be used , #pragma NOJTBOUND can be used to turn + off boundary checking for jump tables for a given function only. + +* --noloopreverse \label{--noloopreverse}Will not do loop reversal + optimization + +* --noregparms\label{--noregparms} By default the first parameter is + passed using global registers (DPL,DPH,B,ACC). This option will + disable parameter passing using registers. NOTE: if your program + uses the 16/32 bit support routines (for multiplication/division) + these library routines will need to be recompiled with the --noregparms + option as well. + +* --callee-saves function1[,function2][,function3].... \label{--callee-saves}The + compiler by default uses a caller saves convention for register + saving across function calls, however this can cause unneccessary + register pushing & popping when calling small functions from larger + functions. This option can be used to switch the register saving + convention for the function names specified. The compiler will not + save registers when calling these functions, extra code will be + generated at the entry & exit for these functions to save & restore + the registers used by these functions, this can SUBSTANTIALLY reduce + code & improve run time performance of the generated code. In future + the compiler (with interprocedural analysis) will be able to determine + the appropriate scheme to use for each function call. DO NOT use + this option for built-in functions such as _muluint..., if this + option is used for a library function the appropriate library function + needs to be recompiled with the same option. If the project consists + of multiple source files then all the source file should be compiled + with the same --callee-saves option string. Also see Pragma Directive\ref{Pragmaa} + CALLEE-SAVES.\ref{pragma callee-saves} . + +* --debug \label{--debug}When this option is used the compiler will + generate debug information , that can be used with the SDCDB. The + debug information is collected in a file with .cdb extension. For + more information see documentation for SDCDB. + +* --regextend \label{--regextend} This option will cause the compiler + to define pseudo registers , if this option is used, all source + files in the project should be compiled with this option. See section + Register Extension for more details. + +* --compile-only(-c) \label{--compile-only} will compile and assemble + the source only, will not call the linkage editor. + +* --xram-loc \label{--xram-loc} The start location of the external + ram, default value is 0. The value entered can be in Hexadecimal + or Decimal format .eg. --xram-loc 0x8000 or --xram-loc 32768. + +* --code-loc \label{--code-loc} The start location of the code + segment , default value 0. Note when this option is used the interrupt + vector table is also relocated to the given address. The value entered + can be in Hexadecimal or Decimal format .eg. --code-loc 0x8000 or + --code-loc 32768. + +* --stack-loc\label{--stack-loc} The initial value of the stack + pointer. The default value of the stack pointer is 0x07 if only + register bank 0 is used, if other register banks are used then the + stack pointer is initialized to the location above the highest register + bank used. eg. if register banks 1 & 2 are used the stack pointer + will default to location 0x18. The value entered can be in Hexadecimal + or Decimal format .eg. --stack-loc 0x20 or --stack-loc 32. If all + four register banks are used the stack will be placed after the + data segment (equivalent to --stack-after-data) + +* --stack-after-data\label{--stack-after-data}This option will cause + the stack to be located in the internal ram after the data segment. + +* --data-loc \label{--data-loc} The start location of the internal + ram data segment, the default value is 0x30.The value entered can + be in Hexadecimal or Decimal format .eg. --data-loc 0x20 or --data-loc + 32. + +* --idata-loc\label{--idata-loc} The start location of the indirectly + addressable internal ram, default value is 0x80. The value entered + can be in Hexadecimal or Decimal format .eg. --idata-loc 0x88 or + --idata-loc 136. + +* --peep-file\label{--peep-file} This option can be used + to use additional rules to be used by the peep hole optimizer. See + section Peep Hole optimizations for details on how to write these + rules. + +* --lib-path (-L) \label{--lib-path} + This option is passed to the linkage editor, additional libraries + search path. The path name must be absolute. Additional library + files may be specified in the command line . See section Compiling + programs for more details. + +* -I \label{-I} The additional location where the pre processor + will look for <..h> or ``..h'' files. + +* -D \label{-D}Command line definition of macros. Passed + to the pre processor. + +* -E\label{-E} Run only the C preprocessor. Preprocess all the C source + files specified and output the results to standard output. + +* -M\label{-M} Tell the preprocessor to output a rule suitable for + make describing the dependencies of each object file. For each source + file, the preprocessor outputs one make-rule whose target is the + object file name for that source file and whose dependencies are + all the files `#include'd in it. This rule may be a single line + or may be continued with `\'-newline if it is long. The list of rules + is printed on standard output instead of the preprocessed C program. + `-M' implies `-E'. + +* -C \label{-C}Tell the preprocessor not to discard comments. Used + with the `-E' option. + +* -MM \label{-MM}Like `-M' but the output mentions only the user header + files included with `#include file"'. System header files included + with `#include ' are omitted. + +* -Aquestion(answer)\label{-Aquestion(answer)} Assert the answer answer + for question, in case it is tested with a preprocessor conditional + such as `#if #question(answer)'. `-A-' disables the standard asser- + tions that normally describe the target machine. + +* -Aquestion\label{-Aquestion} (answer) Assert the answer answer for + question, in case it is tested with a preprocessor conditional such + as `#if #question(answer)'. `-A-' disables the standard assertions + that normally describe the target machine. + +* -Umacro\label{-Umacro} Undefine macro macro. `-U' options are evaluated + after all `-D' options, but before any `-include' and `-imac- ros' + options. + +* -dM\label{-dM} Tell the preprocessor to output only a list of the + mac- ro definitions that are in effect at the end of prepro- cessing. + Used with the `-E' option. + +* -dD \label{-dD}Tell the preprocessor to pass all macro definitions + into the output, in their proper sequence in the rest of the output. + +* -dN \label{-dN}Like `-dD' except that the macro arguments and contents + are omitted. Only `#define name' is included in the output. + +* -S \label{-S}Stop after the stage of compilation proper; do not as- + semble. The output is an assembler code file for the input file + specified. + +* -Wa asmOption[,asmOption]... Pass the asmOption to the assembler + +* -Wl linkOption[,linkOption] .. Pass the linkOption to the linker. + +* --int-long-reent \label{--int-long-rent} Integer (16 bit) and long + (32 bit) libraries have been compiled as reentrant. Note by default + these libraries are compiled as non-reentrant. See section Installation + for more details. + +* --cyclomatic \label{--cyclomatic}This option will cause the compiler + to generate an information message for each function in the source + file. The message contains some important information about the + function. The number of edges and nodes the compiler detected in + the control flow graph of the function, and most importantly the + cyclomatic complexity see section on Cyclomatic Complexity for more + details. + +* --float-reent \label{--float-reent} Floating point library is compiled + as reentrant.See section Installation for more details. + +* --out-fmt-ihx\label{--out-fmt-ihx} The linker output (final object + code) is in Intel Hex format. (This is the default option). + +* --out-fmt-s19 \label{--out-fmt-s19}The linker output (final object + code) is in Motorola S19 format. + +* --nooverlay \label{--nooverlay} The compiler will not overlay parameters + and local variables of any function, see section Parameters and + local variables for more details. + +* --main-return\label{--main-return} This option can be used when the + code generated is called by a monitor program. The compiler will + generate a 'ret' upon return from the 'main' function. The default + option is to lock up i.e. generate a 'ljmp .' . + +* --no-peep \label{--no-peep} Disable peep-hole optimization. + +* --peep-asm \label{--peep-asm} Pass the inline assembler code through + the peep hole optimizer. Can cause unexpected changes to inline + assembler code , please go through the peephole optimizer rules + defnied in file 'SDCCpeeph.def' before using this option. + +* --iram-size\label{--iram-size} Causes the linker to check + if the interal ram usage is within limits of the given value. + +The following options are provided for the purpose of retargetting +and debugging the compiler . These provided a means to dump the intermediate +code (iCode) generated by the compiler in human readable form at various +stages of the compilation process. + +* --dumpraw \label{--dumpraw}. This option will cause the compiler + to dump the intermediate code into a file of named .dumpraw + just after the intermediate code has been generated for a function + , i.e. before any optimizations are done. The basic blocks at this + stage ordered in the depth first number, so they may not be in sequence + of execution. + +* --dumpgcse.\label{--dumpgcse} Will create a dump if iCode, after + global subexpression elimination, into a file named .dumpgcse. + +* --dumpdeadcode \label{--dumpdeadcode}.Will create a dump if iCode, + after deadcode elimination, into a file named .dumpdeadcode. + +* --dumploop. \label{--dumploop}Will create a dump if iCode, after + loop optimizations, into a file named .dumploop. + +* --dumprange. \label{--dump-range}Will create a dump if iCode, after + live range analysis, into a file named .dumprange. + +* --dumpregassign. \label{--dumpregassign}Will create a dump if iCode, + after register assignment , into a file named .dumprassgn. + +* --dumpall. \label{--dumpall}Will cause all the above mentioned dumps + to be created. + +Note that the files created for the dump are appended to each time. +So the files should be deleted manually , before each dump is created. + +When reporting bugs, it will be very helpful if you could include these +dumps along with the portion of the code that is causing the problem. + +5 Language Extensions\label{Language Extension} + +5.1 Storage Classes.\label{Storage Classes} + +In addition to the ANSI storage classes SDCC allows the following 8051 +specific storage classes. + +5.1.1 xdata.\label{xdata} + +Variables declared with this storage class will be placed in the extern +RAM. This is the default storage class for Large Memory model . + +eg. xdata unsigned char xduc; + +5.1.2 data\label{data} + +This is the default storage class for Small Memory model. Variables +declared with this storage class will be allocated in the internal +RAM. + +eg. data int iramdata; + +5.1.3 idata\label{idata} + +Variables declared with this storage class will be allocated into the +indirectly addressable portion of the internal ram of a 8051 . + +eg.idata int idi; + +5.1.4 bit\label{bit} + +This is a data-type and a storage class specifier. When a variable +is declared as a bit , it is allocated into the bit addressable memory +of 8051. + +eg.bit iFlag; + +5.1.5 sfr / sbit\label{sfr / sbit} + +Like the bit keyword, sfr / sbit signifies both a data-type and storage +class, they are used to describe the special function registers and +special bit variables of a 8051. + +eg. + +sfr at 0x80 P0; /* special function register P0 at location 0x80 */ + +sbit at 0xd7 CY; /* CY (Carry Flag) */ + +6 Optimizations\label{Optimizations} + +SDCC performs a a host of standard optimizations in addition to some +MCU specific optimizations. + +6.1 Sub-expression elimination\label{Sub-expression Elimination} + +The compiler does local and global common subexpression elimination. + +eg. + +i = x + y + 1; +j = x + y; + +will be translated to + +iTemp = x + y +i = iTemp + 1 +j = iTemp + +Some subexpressions are not as obvious as the above example. + +eg. + +a->b[i].c = 10; +a->b[i].d = 11; + +In this case the address arithmetic a->b[i] will be computed only once; +the equivalent code in C would be. + +iTemp = a->b[i]; +iTemp.c = 10; +iTemp.d = 11; + +The compiler will try to keep these temporary variables in registers. + +6.2 Dead-Code elimination.\label{Dead-code elimination} + +eg. + +int global; +void f () { + int i; + i = 1; /* dead store */ + global = 1; /* dead store */ + global = 2; + return; + global = 3; /* unreachable */ +} + +will be changed to + +int global; void f () +{ + global = 2; + return; +} + +6.3 Copy-Propagation:\label{Copy-Propagation} + +eg. + +int f() { + int i, j; + i = 10; + j = i; + return j; +} + +will be changed to + +int f() { + int i,j; + i = 10; + j = 10; + return 10; +} + +Note: the dead stores created by this copy propagation will be eliminated +by dead-code elimination . + +6.4 Loop optimizations\label{Loop Optimizations} + +Two types of loop optimizations are done by SDCC loop invariant lifting +and strength reduction of loop induction variables.In addition to +the strength reduction the optimizer marks the induction variables +and the register allocator tries to keep the induction variables in +registers for the duration of the loop. Because of this preference +of the register allocator , loop induction optimization causes an +increase in register pressure, which may cause unwanted spilling of +other temporary variables into the stack / data space . The compiler +will generate a warning message when it is forced to allocate extra +space either on the stack or data space. If this extra space allocation +is undesirable then induction optimization can be eliminated either +for the entire source file ( with --noinduction option) or for a given +function only (#pragma NOINDUCTION). + +6.4.1 Loop Invariant:\label{Loop Invariant} + +eg + +for (i = 0 ; i < 100 ; i ++) + f += k + l; + +changed to + +itemp = k + l; +for ( i = 0; i < 100; i++ ) f += itemp; + +As mentioned previously some loop invariants are not as apparent, all +static address computations are also moved out of the loop. + +6.4.2 Strength reduction :\label{Strength Reduction} + +This optimization substitutes an expression by a cheaper expression. + +eg. + +for (i=0;i < 100; i++) ar[i*5] = i*3; + +changed to + +itemp1 = 0; +itemp2 = 0; +for (i=0;i< 100;i++) { + ar[itemp1] = itemp2; + itemp1 += 5; + itemp2 += 3; +} + +The more expensive multiplication is changed to a less expensive addition. + +6.4.3 Loop reversing:\label{Loop reversing} + +This optimization is done to reduce the overhead of checking loop boundaries +for every iteration. Some simple loops can be reversed and implemented +using a ``decrement and jump if not zero'' instruction. SDCC checks +for the following criterion to determine if a loop is reversible (note: +more sophisticated compiers use data-dependency analysis to make this +determination, SDCC uses a more simple minded analysis). + +* The 'for' loop is of the form + ``for ( = ; [< | <=] ; [++ + | += 1]) + '' + +* The does not contain ``continue'' or 'break''. + +* All goto's are contained within the loop. + +* No function calls within the loop. + +* The loop control variable is not assigned any value within + the loop + +* The loop control variable does NOT participate in any arithmetic + operation within the loop. + +* There are NO switch statements in the loop. + +Note djnz instruction can be used for 8-bit values ONLY, therefore +it is advantageous to declare loop control symbols as either 'char' +or 'short', ofcourse this may not be possible on all situations. + +6.5 Algebraic simplifications:\label{Algebraic Simplifications} + +SDCC does numerous algebraic simplifications, the following is a small +sub-set of these optimizations. + +eg +i = j + 0 ; /* changed to */ i = j; +i /= 2; /* changed to */ i >>= 1; +i = j - j ; /* changed to */ i = 0; +i = j / 1 ; /* changed to */ i = j; + +Note the subexpressions given above are generally introduced by macro +expansions or as a result of copy/constant propagation. + +6.6 'switch' statements.\label{Switch Statement} + +SDCC changes switch statements to jump tables when the following conditions +are true. + +* The case labels are in numerical sequence , the labels need not be + in order, and the starting number need not be one or zero. + +eg + +switch(i) { switch (i) { +case 4:... case 1: ... +case 5:... case 2: ... +case 3:... case 3: ... +case 6:... case 4: ... +} } + +Both the above switch statements will be implemented using a jump-table. + +* The number of case labels is at least three, since it takes two conditional + statements to handle the boundary conditions. + +* The number of case labels is less than 84, since each label takes + 3 bytes and a jump-table can be utmost 256 bytes long. + +Switch statements which have gaps in the numeric sequence or those +that have more that 84 case labels can be split into more than one +switch statement for efficient code generation. + +eg + +switch (i) { +case 1: ... +case 2: ... +case 3: ... +case 4: ... +case 9: ... +case 10: ... +case 11: ... +case 12: ... +} + +If the above switch statement is broken down into two switch statements + +switch (i) { +case 1: ... +case 2: ... +case 3: ... +case 4: ... +} + +switch (i) { +case 9: ... +case 10: ... +case 11: ... +case 12:... +} + +then both the switch statements will be implemented using jump-tables +whereas the unmodified switch statement will not be . + +6.7 bit-shifting operations.\label{bit shifting} + +Bit shifting is one of the most frequently used operation in embedded +programming . SDCC tries to implement bit-shift operations in the +most efficient way possible. + +eg. + +unsigned short i; + +... +i>>= 4; +.. + +generates the following code. + +mov a,_i +swap a +anl a,#0x0f +mov _i,a + +In general SDCC will never setup a loop if the shift count is known. +Another example + +unsigned int i; +... +i >>= 9; +... + +will generate + +mov a,(_i + 1) +mov (_i + 1),#0x00 +clr c +rrc a +mov _i,a + +Note that SDCC stores numbers in little-endian format (i.e. lowest +order first) + +6.7.1 Bit-rotation:\label{bit rotation} + +A special case of the bit-shift operation is bit rotation, SDCC recognizes +the following expression to be a left bit-rotation. + +unsigned char i; +... +i = ( ( i << 1) | ( i >> 7)); +... + +will generate the following code. + +mov a,_i +rl a +mov _i,a + +SDCC uses pattern matching on the parse tree to determine this operation +.Variations of this case will also be recognized as bit-rotation i.e +i = ((i >> 7) | (i << 1)); /* left-bit rotation */ + +6.8 Highest Order Bit.\label{Highest Order Bit} + +It is frequently required to obtain the highest order bit of an integral +type (int,long,short or char types). SDCC recognizes the following +expression to yield the highest order bit and generates optimized +code for it. + +eg +unsigned int gint; +foo () { +unsigned char hob; + ... + hob = (gint >> 15) & 1; + .. +} + +Will generate the following code. + + 61 ; hob.c 7 + 000A E5*01 62 mov a,(_gint + 1) + 000C 33 63 rlc a + 000D E4 64 clr a + 000E 13 65 rrc a + 000F F5*02 66 mov _foo_hob_1_1,a + +Variations of this case however will NOT be recognized . It is a standard +C expression , so I heartily recommend this be the only way to get +the highest order bit, (it is portable). Of course it will be recognized +even if it is embedded in other expressions. + +eg. + +xyz = gint + ((gint >> 15) & 1); + +will still be recognized. + +6.9 Peep-hole optimizer.\label{Peep-Hole} + +The compiler uses a rule based , pattern matching and re-writing mechanism +for peep-hole optimization . It is inspired by 'copt' a peep-hole +optimizer by Christopher W. Fraser (cwfraser@microsoft.com). A default +set of rules are compiled into the compiler, additional rules may +be added with the --peep-file option. The rule language +is best illustrated with examples. + +replace { +mov %1,a +mov a,%1 } by { mov %1,a } + +The above rule will the following assembly sequence + +mov r1,a +mov a,r1 + +to + +mov r1,a + +Note: All occurrences of a '%n' ( pattern variable ) must denote the +same string. With the above rule, the assembly sequence + +mov r1,a +mov a,r2 + +will remain unmodified. Other special case optimizations may be added +by the user (via --peep-file option), eg. some variants of the 8051 +MCU allow only 'AJMP' and 'ACALL' , the following two rules will change +all 'LJMP' & 'LCALL' to 'AJMP' & 'ACALL'. + +replace { lcall %1 } by { acall %1 } +replace { ljmp %1 } by { ajmp %1 } + +The inline-assembler' code is also passed through the peep hole optimizer, +thus the peephole optimizer can also be used as an assembly level +macro expander. The rules themselves are MCU dependent whereas the +rule language infra-structure is MCU independent. Peephole optimization +rules for other MCU can be easily programmed using the rule language. + +The syntax for a rule is as follows , + +rule := replace [ restart ] '{' '\n' + '}' by '{' '\n' + '\n' + '}' [if ] '\n' + := assembly instruction (each instruction including +labels must be on a separate line). + +The optimizer will apply to the rules one by one from the top in the +sequence of their appearance, it will terminate when all rules are +exhausted. If the 'restart' option is specified, then the optimizer +will start matching the rules again from the top, this option for +a rule is expensive (performance), it is intended to be used in situations +where a transformation will trigger the same rule again. A good example +of this the following rule. + +replace restart { +pop %1 +push %1 } by { +; nop +} + +Note that the replace pattern cannot be a blank, but can be a comment +line. Without the 'restart' option only the inner most 'pop' 'push' +pair would be eliminated. i.e. + +pop ar1 +pop ar2 +push ar2 +push ar1 + +would result in + +pop ar1 +; nop +push ar1 + +with the 'restart' option the rule will be applied again to the resulting +code and the all the 'pop' 'push' pairs will be eliminated to yield + +; nop +; nop + +A conditional function can be attached to a rule. Attaching rules are +somewhat more involved, let me illustrate this with an example. + +replace { + ljmp %5 +%2:} by { + sjmp %5 +%2:} if labelInRange + +The optimizer does a look-up of a function name table defined in function +'callFuncByName' in the source file SDCCpeeph.c , with the name 'labelInRange', +if it finds a corresponding entry the function is called. Note there +can be no parameters specified for these functions, in this case the +use of '%5' is crucial, since the function labelInRange expects to +find the label in that particular variable (the hash table containing +the variable bindings is passed as a parameter). If you want to code +more such functions , take a close look at the function labelInRange +and the calling mechanism in source file SDCCpeeph.c. I know this +whole thing is a little kludgey , may be some day we will have some +better means. If you are looking at this file, you will also see the +default rules that are compiled into the compiler, you can your own +rules in the default set there if you get tired of specifying the +--peep-file option. + +7 Pointers\label{Pointers} + +SDCC allows (via language extensions) pointers to explicitly point +to any of the memory spaces of the 8051. In addition to the explicit +pointers, the compiler also allows a _generic class of pointers which +can be used to point to any of the memory spaces. + +Pointer declaration examples. + +/* pointer physically in xternal ram pointing to object in internal +ram */ +data unsigned char * xdata p; + + +/* pointer physically in code rom pointing to data in xdata space */ + +xdata unsigned char * code p; + + +/* pointer physically in code space pointing to data in code space +*/ +code unsigned char * code p; + +/* the folowing is a generic pointer physically located in xdata space +*/ +char * xdata p; + +Well you get the idea. For compatibility with the previous version +of the compiler, the following syntax for pointer declaration is also +supported. Note the above examples will be portable to other commercially +available compilers. + +unsigned char _xdata *ucxdp; /* pointer to data in external ram */ + +unsigned char _data *ucdp ; /* pointer to data in internal ram */ +unsigned char _code *uccp ; /* pointer to data in R/O code space */ +unsigned char _idata *uccp; /* pointer to upper 128 bytes of ram */ + +All unqualified pointers are treated as 3 - byte '_generic' pointers. +These type of pointers can also to be explicitly declared. + +unsigned char _generic *ucgp; + +The highest order byte of the generic pointers contains the data space +information. Assembler support routines are called whenever data is +stored or retrieved using _generic pointers. These are useful for +developing reusable library routines. Explicitly specifying the pointer +type will generate the most efficient code. Pointers declared using +a mixture of OLD/NEW style could have unpredictable results. + +8 Parameters & Local Variables\label{Auto Variables} + +Automatic (local) variables and parameters to functions can either +be placed on the stack or in data-space. The default action of the +compiler is to place these variables in the internal RAM ( for small +model) or external RAM (for Large model). They can be placed on the +stack either by using the --stack-auto compiler option or by using +the 'reentrant' keyword in the function declaration. + +eg + +unsigned short foo( short i) reentrant { +... +} + +Note that when the parameters & local variables are declared in the +internal/external ram the functions are non-reentrant. Since stack +space on 8051 is limited the 'reentrant' keyword or the --stack-auto +option should be used sparingly. Note the reentrant keyword just means +that the parameters & local variables will be allocated to the stack, +it DOES NOT mean that the function is register bank independent. + +When compiled with the default option (i.e. non-reentrant ), local +variables can be assigned storage classes and absolute addresses. + +eg + +unsigned short foo() { + xdata unsigned short i; + bit bvar; + data at 0x31 unsiged short j; +... +} + +In the above example the variable i will be allocated in the external +ram, bvar in bit addressable space and j in internal ram. When compiled +with the --stack-auto or when a function is declared as 'reentrant' +local variables cannot be assigned storage classes or absolute addresses. + +Parameters however are not allowed any storage class, (storage classes +for parameters will be ignored), their allocation is governed by the +memory model in use , and the reentrancy options. + +8.1 Overlaying\label{Overlaying} + +For non-reentrant functions SDCC will try to reduce internal ram space +usage by overlaying parameters and local variables of a function (if +possible). Parameters and local variables of a function will be allocated +to an overlayable segment if the function has no other function calls +and the function is non-reentrant and the memory model is small. If +an explicit storage class is specified for a local variable , it will +NOT be overplayed. + +Note that the compiler (not the linkage editor) makes the decision +for overlaying the data items. Functions that are called from an interrupt +service routine should be preceded by a #pragma NOOVERLAY if they +are not reentrant Along the same lines the compiler does not do any +processing with the inline assembler code so the compiler might incorrectly +assign local variables and parameters of a function into the overlay +segment if the only function call from a function is from inline assembler +code, it is safe to use the #pragma NOOVERLAY for functions which +call other functions using inline assembler code. + +Parameters and Local variables of functions that contain 16 or 32 bit +multiplication or division will NOT be overlayed since these are implemented +using external functions. + +eg. + +#pragma SAVE +#pragma NOOVERLAY +void set_error( unsigned short errcd) +{ + P3 = errcd; +} +#pragma RESTORE +void some_isr () interrupt 2 using 1 +{ + ... + set_error(10); + ... +} + +In the above example the parameter errcd for the function set_error +would be assigned to the overlayable segment (if the #pragma NOOVERLAY +was not present) , this could cause unpredictable runtime behavior. +The pragma NOOVERLAY ensures that the parameters and local variables +for the function are NOT overlayed. + +9 critical Functions.\label{Critical} + +A special keyword may be associated with a function declaring it as +'critical'. SDCC will generate code to disable all interrupts upon +entry to a critical function and enable them back before returning +. Note that nesting critical functions may cause unpredictable results. + +eg + +int foo () critical +{ +... +... +} + +The critical attribute maybe used with other attributes like reentrant. + +10 Absolute addressing.\label{Absolute Addressing} + +Data items can be assigned an absolute address with the at
                  +keyword, in addition to a storage class. + +eg. + +xdata at 0x8000 unsigned char PORTA_8255 ; + +In the above example the PORTA_8255 will be allocated to the location +0x8000 of the external ram. + +Note that is this feature is provided to give the programmer access +to memory mapped devices attached to the controller. The compiler +does not actually reserve any space for variables declared in this +way (they are implemented with an equate in the assembler), thus it +is left to the programmer to make sure there are no overlaps with +other variables that are declared without the absolute address, the +assembler listing file (.lst) and the linker output files (.rst) +and (.map) are a good places to look for such overlaps. + +Absolute address can be specified for variables in all storage classes. + +eg. + +bit at 0x02 bvar; + +The above example will allocate the variable at offset 0x02 in the +bit-addressable space. There is no real advantage to assigning absolute +addresses to variables in this manner , unless you want strict control +over all the variables allocated. + +11 Interrupt Service Routines\label{Interrupt Service Rouines} + +SDCC allows interrupt service routines to be coded in C, with some +extended keywords. + +void timer_isr (void) interrupt 2 using 1 +{ +.. +} + +The number following the 'interrupt' keyword is the interrupt number +this routine will service. The compiler will insert a call to this +routine in the interrupt vector table for the interrupt number specified. +The 'using' keyword is used to tell the compiler to use the specified +register bank (8051 specific) when generating code for this function. +Note that when some function is called from an interrupt service routine +it should be preceded by a #pragma NOOVERLAY (if it is not reentrant) +. A special note here, int (16 bit) and long (32 bit) integer division, +multiplication & modulus operations are implemented using external +support routines developed in ANSI-C, if an interrupt service routine +needs to do any of these operations then the support routines (as +mentioned in a following section) will have to recompiled using the +--stack-auto option and the source file will need to be compiled using +the --int-long-rent compiler option. + +If you have multiple source files in your project, interrupt service +routines can be present in any of them, but a prototype of the isr +MUST be present in the file that contains the function 'main'. + +Interrupt Numbers and the corresponding address & descriptions for +the Standard 8051 are listed below. SDCC will automatically adjust +the interrupt vector table to the maximum interrupt number specified. + +Interrupt # Description Vector Address + 0 External 0 0x0003 + 1 Timer 0 0x000B + 2 External 1 0x0013 + 3 Timer 1 0x001B + 4 Serial 0x0023 + +If the interrupt service routine is defined without a register bank +or with register bank 0 (using 0), the compiler will save the registers +used by itself on the stack (upon entry and restore them at exit), +however if such an interrupt service routine calls another function +then the entire register bank will be saved on the stack. This scheme +may be advantageous for small interrupt service routines which have +low register usage. + +If the interrupt service routine is defined to be using a specific +register bank then only ``a'',''b'' & ``dptr'' are save and restored, +if such an interrupt service routine calls another function (using +another register bank) then the entire register bank of the called +function will be saved on the stack. This scheme is recommended for +larger interrupt service routines. + +Calling other functions from an interrupt service routine is not recommended +avoid it if possible. + +12 Startup Code\label{Startup} + +The compiler inserts a jump to the C routine _sdcc__external__startup() +at the start of the CODE area. This routine can be found in the file +SDCCDIR/sdcc51lib/_startup.c , by default this routine returns 0, +if this routine returns a non-zero value , the static & global variable +initialization will be skipped and the function main will be invoked, +other wise static & global variables will be initialized before the +function main is invoked. + +13 Inline assembler code.\label{Inline} + +SDCC allows the use of in-line assembler with a few restriction as +regards labels. All labels defined within inline assembler code HAS +TO BE of the form nnnnn$ where nnnn is a number less than 100 (which +implies a limit of utmost 100 inline assembler labels per function). +It is strongly recommended that each assembly instruction (including +labels) be placed in a separate line ( as the example shows). When +the --peep-asm command line option is used, the inline assembler code +will be passed through the peephole optimizer, this might cause some +unexpected changes in the inline assembler code, please go throught +the peephole optimizer rules defined in file 'SDCCpeeph.def' carefully +before using this option. + +eg + +_asm + mov b,#10 +00001$: + djnz b,00001$ +_endasm ; + +The inline assembler code can contain any valid code understood by +the assembler (this includes any assembler directives and comment +lines ) . The compiler does not do any validation of the code within +the _asm ... _endasm; keyword pair. + +Inline assembler code cannot reference any C-Labels however it can +reference labels defined by the inline assembler. + +eg + +foo() { +... /* some c code */ +_asm + ; some assembler code + ljmp $0003 +_endasm ; +... /* some more c code */ +clabel: /* inline assembler cannot reference this label */ +_asm + $0003: ;label (can be reference by inline assembler only) +_endasm ; +... +} + +In other words inline assembly code can access labels defined in inline +assembly. The same goes the other way, ie. labels defines in inline +assembly CANNOT be accessed by C statements. + +14 int (16 bit) and long (32 bit ) support.\label{int and long} + +For signed & unsigned int (16 bit) and long (32 bit) variables, division, +multiplication and modulus operations are implemented by support routines. +These support routines are all developed in ANSI-C to facilitate porting +to other MCUs. The following files contain the described routine, +all of them can be found in the directory SDCCDIR/sdcc51lib + +* _mulsint.c - signed 16 bit multiplication (calls _muluint) + +* _muluint.c - unsigned 16 bit multiplication + +* _divsint.c - signed 16 bit division (calls _divuint) + +* _divuint.c - unsigned 16 bit division. + +* _modsint.c - signed 16 bit modulus (call _moduint) + +* _moduint.c - unsigned 16 bit modulus. + +* _mulslong.c - signed 32 bit multiplication (calls _mululong) + +* _mululong.c - unsigned32 bit multiplication. + +* _divslong.c - signed 32 division (calls _divulong) + +* _divulong.c - unsigned 32 division. + +* _modslong.c - signed 32 bit modulus (calls _modulong). + +* _modulong.c - unsigned 32 bit modulus. + +All these routines are compiled as non-reentrant and small model. Since +they are compiled as non-reentrant, interrupt service routines should +not do any of the above operations, if this unavoidable then the above +routines will need to ne compiled with the --stack-auto option, after +which the source program will have to be compiled with --int-long-rent +option. + +15 Floating point support\label{Float} + +SDCC supports IEEE (single precision 4bytes) floating point numbers.The +floating point support routines are derived from gcc's floatlib.c +and consists of the following routines. + +* _fsadd.c - add floating point numbers. + +* _fssub.c - subtract floating point numbers + +* _fsdiv.c - divide floating point numbers + +* _fsmul.c - multiply floating point numbers + +* _fs2uchar.c - convert floating point to unsigned char + +* _fs2char.c - convert floating point to signed char. + +* _fs2uint.c - convert floating point to unsigned int. + +* _fs2int.c - convert floating point to signed int. + +* _fs2ulong.c - convert floating point to unsigned long. + +* _fs2long.c - convert floating point to signed long. + +* _uchar2fs.c - convert unsigned char to floating point + +* _char2fs.c - convert char to floating point number + +* _uint2fs.c - convert unsigned int to floating point + +* _int2fs.c - convert int to floating point numbers + +* _ulong2fs.c - convert unsigned long to floating point number + +* _long2fs.c - convert long to floating point number. + +Note if all these routines are used simultaneously the data space might +overflow. For serious floating point usage it is strongly recommended +that the Large model be used (in which case the floating point routines +mentioned above will need to recompiled with the --model-Large option). + +16 Memory Models\label{Memory Models} + +SDCC allows two memory models, modules compiled with different memory +models should be combined together, the results would be unpredictable. +The support routines supplied with the compiler are compiled in small-model +by default, and will need to be recompiled using the large model if +the large model is used. In general the use of the large model is +discouraged. + +When the large model is used all variables declared without a storage +class will be allocated into the external ram, this includes all parameters +and local variables (for non-reentrant functions). When the small +model is used variables without storage class are allocated in the +internal ram. + +Judicious usage of the processor specific storage classes and the 'reentrant' +function type will yield much more efficient code, than using the +large-model. + +17 Defines created by the compiler.\label{Defines.} + +The compiler creates the following #defines . + +* SDCC - this Symbol is always defined. + +* SDCC_STACK_AUTO - this symbol is defined when --stack-auto option + is used. + +* SDCC_MODEL_SMALL - when small model is used. + +* SDCC_MODEL_LARGE - when --model-large is used. + +* SDCC_USE_XSTACK - when --xstack option is used. + +18 Pragmas\label{Pragmaa} + +SDCC supports the following #pragma directives. This directives are +applicable only at a function level. + +* SAVE\label{pragma save} - this will save all the current options . + +* RESTORE \label{pragma restore}- will restore the saved options from + the last save. Note that SAVES & RESTOREs cannot be nested. SDCC + uses the same buffer to save the options each time a SAVE is called. + +* NOGCSE\label{pragma nogcse} - will stop global subexpression elimination. + +* NOINDUCTION \label{pragma noinduction}- will stop loop induction + optimizations . + +* NOJTBOUND \label{pragma nojtbound}- will not generate code for boundary + value checking , when switch statements are turned into jump-tables. + +* NOOVERLAY \label{pragma nooverlay}- the compiler will not overlay + the parameters and local variables of a function. + +* NOLOOPREVERSE \label{pragma noloopreverse}- Will not do loop reversal + optimization + +* EXCLUDE NONE | {acc[,b[,dpl[,dph]]]\label{pragma exclude} - The exclude + pragma disables generation of pair of push/pop instruction in ISR + function (using interrupt keyword). The directive should be placed + immediately before the ISR function definition and it affects ALL + ISR functions following it. To enable the normal register saving + for ISR functions use ``#pragma EXCLUDE none'' + +* CALLEE-SAVES function1[,function2[,function3...]]\label{pragma callee-saves} + - The compiler by default uses a caller saves convention for register + saving across function calls, however this can cause unneccessary + register pushing & popping when calling small functions from larger + functions. This option can be used to switch the register saving + convention for the function names specified. The compiler will not + save registers when calling these functions, extra code will be + generated at the entry & exit for these functions to save & restore + the registers used by these functions, this can SUBSTANTIALLY reduce + code & improve run time performance of the generated code. In future + the compiler (with interprocedural analysis) will be able to determine + the appropriate scheme to use for each function call. If --callee-saves\ref{--callee-saves} + command line option is used, the function names specified in #pragma + CALLEE-SAVES is appended to the list of functions specified inthe + command line. + +The pragma's are intended to be used to turn-off certain optimizations +which might cause the compiler to generate extra stack / data space +to store compiler generated temporary variables. This usually happens +in large functions. Pragma directives should be used as shown in the +following example, they are used to control options & optimizations +for a given function; pragmas should be placed before and/or after +a function, placing pragma's inside a function body could have unpredictable +results. + +eg + +#pragma SAVE /* save the current settings */ +#pragma NOGCSE /* turnoff global subexpression elimination */ +#pragma NOINDUCTION /* turn off induction optimizations */ +int foo () +{ + ... + /* large code */ + ... +} +#pragma RESTORE /* turn the optimizations back on */ + +The compiler will generate a warning message when extra space is allocated. +It is strongly recommended that the SAVE and RESTORE pragma's be used +when changing options for a function. + +19 Library routines.\label{Library} + +The following library routines are provided for your convenience. + +stdio.h - Contains the following functions printf & sprintf these routines +are developed by Martijn van Balen . + +%[flags][width][b|B|l|L]type + + flags: - left justify output in specified field width + + prefix output with +/- sign if output is signed type + space prefix output with a blank if it's a signed positive value + width: specifies minimum number of characters outputted for numbers + + or strings. + - For numbers, spaces are added on the left when needed. + If width starts with a zero character, zeroes and used + instead of spaces. + - For strings, spaces are are added on the left or right (when + flag '-' is used) when needed. + + b/B: byte argument (used by d, u, o, x, X) + l/L: long argument (used by d, u, o, x, X) + type: d decimal number + u unsigned decimal number + o unsigned octal number + x unsigned hexadecimal number (0-9, a-f) + X unsigned hexadecimal number (0-9, A-F) + c character + s string (generic pointer) + p generic pointer (I:data/idata, C:code, X:xdata, P:paged) + f float (still to be implemented) + +Also contains a very simple version of printf (printf_small). This +simplified version of printf supports only the following formats. + +format output type argument-type +%d decimal int +%ld decimal long +%hd decimal short/char +%x hexadecimal int +%lx hexadecimal long +%hx hexadecimal short/char +%o octal int +%lo octal long +%ho octal short/char +%c character char/short +%s character _generic pointer + + The routine is very stack intesive , --stack-after-data parameter + should be used when using this routine, the routine also takes about + 1K of code space .It also expects an external function named putchar(char + ) to be present (this can be changed). When using the %s format + the string / pointer should be cast to a generic pointer. eg. + + printf_small(``my str %s, my int %d\n'',(char _generic *)mystr,myint); + +* stdarg.h - contains definition for the following macros to be used + for variable parameter list, note that a function can have a variable + parameter list if and only if it is 'reentrant' + + va_list, va_start, va_arg, va_end. + +* setjmp.h - contains defintion for ANSI setjmp & longjmp routines. + Note in this case setjmp & longjmp can be used between functions + executing within the same register bank, if long jmp is executed + from a function that is using a different register bank from the + function issuing the setjmp function, the results may be unpredictable. + The jump buffer requires 3 bytes of data (the stack pointer & a + 16 byte return address), and can be placed in any address space. + +* stdlib.h - contains the following functions. + + atoi, atol. + +* string.h - contains the following functions. + + strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, + strspn, strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp, + memset. + +* ctype.h - contains the following routines. + + iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace, + isxdigit, isalnum, isalpha. + +* malloc.h - The malloc routines are developed by Dmitry S. Obukhov + (dso@usa.net). These routines will allocate memory from the external + ram. Here is a description on how to use them (as described by the + author). + + //Example: + // #define DYNAMIC_MEMORY_SIZE 0x2000 + // ..... + // unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE]; + + // unsigned char xdata * current_buffer; + // ..... + // void main(void) + // { + // ... + // init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE); + + // //Now it's possible to use malloc. + // ... + // current_buffer = malloc(0x100); + // + +* serial.h - Serial IO routines are also developed by Dmitry S. Obukhov + (dso@usa.net). These routines are interrupt driven with a 256 byte + circular buffer, they also expect external ram to be present. Please + see documentation in file SDCCDIR/sdcc51lib/serial.c . Note the + header file ``serial.h'' MUST be included in the file containing + the 'main' function. + +* ser.h - Alternate serial routine provided by Wolfgang Esslinger + these routines are more compact and faster. Please see documentation + in file SDCCDIR/sdcc51lib/ser.c + +* ser_ir.h - Another alternate set of serial routines provided by Josef + Wolf , these routines do not use the external + ram. + +* reg51.h - contains register definitions for a standard 8051 + +* reg552.h - contains register definitions for 80C552. + +* float.h - contains min, max and other floating point related stuff. + +All library routines are compiled as --model-small , they are all non-reentrant, +if you plan to use the large model or want to make these routines +reentrant, then they will have to be recompiled with the appropriate +compiler option. + +Have not had time to do the more involved routines like printf, will +get to them shortly. + +20 Interfacing with assembly routines.\label{Interface_asm} + +20.1 Global registers used for parameter passing. + +By default the compiler uses the global registers ``DPL,DPH,B,ACC'' +to pass the first parameter to a routine, the second parameter onwards +is either allocated on the stack (for reentrant routines or --stack-auto +is used) or in the internal / external ram (depending on the memory +model). + +20.1.1 Assembler routine non-reentrant + +In the following example the function cfunc calls an assembler routine +asm_func, which takes two parameters. + +extern int asm_func( unsigned short, unsigned short); + + +int c_func (unsigned short i, unsigned short j) +{ + return asm_func(i,j); +} +int main() +{ + return c_func(10,9); +} + +The corresponding assembler function is:- + + .globl _asm_func_PARM_2 + .globl _asm_func + .area OSEG +_asm_func_PARM_2: .ds 1 + .area CSEG +_asm_func: + mov a,dpl + add a,_asm_func_PARM_2 + mov dpl,a + mov dpl,#0x00 + ret + +Note here that the return values are placed in 'dpl' - One byte return +value, 'dpl' LSB & 'dph' MSB for two byte values. 'dpl', 'dph' and +'b' for three byte values (generic pointers) and 'dpl','dph','b' & +'acc' for four byte values. + +The parameter naming convention is __PARM_, where +n is the parameter number starting from 1, and counting from the left. +The first parameter is passed in ``dpl'' for One bye parameter, ``dptr'' +if two bytes, ``b,dptr'' for three bytes and ``acc,b,dptr'' for four +bytes, the varaible name for the second parameter will be __PARM_2. + +Assemble the assembler routine with the following command. + +asx8051 -losg asmfunc.asm + +Then compile and link the assembler routine to the C source file with +the following command, + +sdcc cfunc.c asmfunc.rel + +20.1.2 Assembler routine is reentrant + +In this case the second parameter onwards will be passed on the stack +, the parameters are pushed from right to left i.e. after the call +the left most parameter will be on the top of the stack. Here is an +example. + +extern int asm_func( unsigned short, unsigned short); + + + +int c_func (unsigned short i, unsigned short j) reentrant +{ + return asm_func(i,j); +} +int main() +{ + return c_func(10,9); +} + +The corresponding assembler routine is. + + .globl _asm_func +_asm_func: + push _bp + mov _bp,sp + mov r2,dpl + mov a,_bp + clr c + add a,#0xfd + mov r0,a + add a,#0xfc + mov r1,a + mov a,@r0 + add a,r2 + mov dpl,a + mov dph,#0x00 + mov sp,_bp + pop _bp + ret + +The compiling and linking procedure remains the same, however note +the extra entry & exit linkage required for the assembler code, _bp +is the stack frame pointer and is used to compute the offset into +the stack for parameters and local variables. + +20.2 With --noregparms option. + +When the source is compiled with --noregparms option , space is allocated +for each of the parameters passed to a routine. + +20.2.1 Assembler routine non-reentrant. + +In the following example the function cfunc calls an assembler routine +asm_func, which takes two parameters. + +extern int asm_func( unsigned short, unsigned short); + + +int c_func (unsigned short i, unsigned short j) +{ + return asm_func(i,j); +} +int main() +{ + return c_func(10,9); +} + +The corresponding assembler function is:- + + .globl _asm_func_PARM_1 + .globl _asm_func_PARM_2 + .globl _asm_func + .area OSEG +_asm_func_PARM_1: .ds 1 +_asm_func_PARM_2: .ds 1 + .area CSEG +_asm_func: + mov a,_asm_func_PARM_1 + add a,_asm_func_PARM_2 + mov dpl,a + mov dpl,#0x00 + ret + +Note here that the return values are placed in 'dpl' - One byte return +value, 'dpl' LSB & 'dph' MSB for two byte values. 'dpl', 'dph' and +'b' for three byte values (generic pointers) and 'dpl','dph','b' & +'acc' for four byte values. + +The parameter naming convention is __PARM_, where +n is the parameter number starting from 1, and counting from the left. +i.e. the left-most parameter name will be __PARM_1. + +Assemble the assembler routine with the following command. + +asx8051 -losg asmfunc.asm + +Then compile and link the assembler routine to the C source file with +the following command, + +sdcc cfunc.c asmfunc.rel + +20.2.2 Assembler routine is reentrant. + +In this case the parameters will be passed on the stack , the parameters +are pushed from right to left i.e. after the call the left most parameter +will be on the top of the stack. Here is an example. + +extern int asm_func( unsigned short, unsigned short); + + + +int c_func (unsigned short i, unsigned short j) reentrant +{ + return asm_func(i,j); +} +int main() +{ + return c_func(10,9); +} + +The corresponding assembler routine is. + + .globl _asm_func +_asm_func: + push _bp + mov _bp,sp + mov a,_bp + clr c + add a,#0xfd + mov r0,a + mov a,_bp + clr c + add a,#0xfc + mov r1,a + mov a,@r0 + add a,@r1 + mov dpl,a + mov dph,#0x00 + mov sp,_bp + pop _bp + ret + +The compiling and linking procedure remains the same, however note +the extra entry & exit linkage required for the assembler code, _bp +is the stack frame pointer and is used to compute the offset into +the stack for parameters and local variables. + +21 External Stack.\label{xstack} + +The external stack is located at the start of the external ram segment +, and is 256 bytes in size. When --xstack option is used to compile +the program , the parameters and local variables of all reentrant +functions are allocated in this area. This option is provided for +programs with large stack space requirements. When used with the --stack-auto +option, all parameters and local variables are allocated on the external +stack (note support libraries will need to be recompiled with the +same options). + +The compiler outputs the higher order address byte of the external +ram segment into PORT P2, therefore when using the External Stack +option, this port MAY NOT be used by the application program. + +22 ANSI-Compliance.\label{ANSI_Compliance} + +Deviations from the compliancy. + +1. functions are not always reentrant. + +2. structures cannot be assigned values directly, cannot be passed as + function parameters or assigned to each other and cannot be a return + value from a function. + + eg + +struct s { ... }; +struct s s1, s2; +foo() +{ +... +s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ +... +} + +struct s foo1 (struct s parms) /* is invalid in SDCC although allowed +in ANSI */ +{ +struct s rets; +... +return rets;/* is invalid in SDCC although allowed in ANSI */ +} + +1. 'long long' (64 bit integers) not supported. + +2. 'double' precision floating point not supported. + +3. integral promotions are suppressed. What does this mean ? The compiler + will not implicitly promote an integer expression to a higher order + integer, exception is an assignment or parameter passing. + +4. No support for setjmp and longjmp (for now). + +5. Old K&R style function declarations are NOT allowed. + +foo( i,j) /* this old style of function declarations */ +int i,j; /* are valid in ANSI .. not valid in SDCC */ +{ +... +} + +1. functions declared as pointers must be dereferenced during the call. + + int (*foo)(); + + ... + /* has to be called like this */ + (*foo)();/* ansi standard allows calls to be made like 'foo()' */ + +23 Cyclomatic Complexity\label{Cyclomatic} + +Cyclomatic complexity of a function is defined as the number of independent +paths the program can take during execution of the function. This +is an important number since it defines the number test cases you +have to generate to validate the function . The accepted industry +standard for complexity number is 10, if the cyclomatic complexity +reported by SDCC exceeds 10 you should think about simplification +of the function logic. + +Note that the complexity level is not related to the number of lines +of code in a function. Large functions can have low complexity, and +small functions can have large complexity levels. SDCC uses the following +formula to compute the complexity. + +complexity = (number of edges in control flow graph) - + (number of nodes in control flow graph) + 2; + +Having said that the industry standard is 10, you should be aware that +in some cases it may unavoidable to have a complexity level of less +than 10. For example if you have switch statement with more than 10 +case labels, each case label adds one to the complexity level. The +complexity level is by no means an absolute measure of the algorithmic +complexity of the function, it does however provide a good starting +point for which functions you might look at for further optimization. + +24 TIPS\label{Tips} + +Here are a few guide-lines that will help the compiler generate more +efficient code, some of the tips are specific to this compiler others +are generally good programming practice. + +* Use the smallest data type to represent your data-value. If it is + known in advance that the value is going to be less than 256 then + use a 'short' or 'char' instead of an 'int'. + +* Use unsigned when it is known in advance that the value is not going + to be negative. This helps especially if you are doing division + or multiplication. + +* NEVER jump into a LOOP. + +* Declare the variables to be local whenever possible, especially loop + control variables (induction). + +* Since the compiler does not do implicit integral promotion, the programmer + should do an explicit cast when integral promotion is required. + +* Reducing the size of division , multiplication & modulus operations + can reduce code size substantially. Take the following code for + example. + + foobar( unsigned int p1, unsigned char ch) + { + unsigned char ch1 = p1 % ch ; + .... + } + + For the modulus operation the variable ch will be promoted to unsigned + int first then the modulus operation will be performed (this will + lead to a call to a support routine). If the code is changed to + + foobar( unsigned int p1, unsigned char ch) + { + unsigned char ch1 = (unsigned char)p1 % ch ; + .... + } + + It would substantially reduce the code generated (future versions + of the compiler will be smart enough to detect such optimization + oppurtunities). + +Notes from an USER ( Trefor@magera.freeserve.co.uk ) + +The 8051 family of micro controller have a minimum of 128 bytes of +internal memory which is structured as follows + +- Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R7 +to R7 + +- Bytes 20-2F - 16 bytes to hold 128 bit variables and + +- Bytes 30-7F - 60 bytes for general purpose use. + +Normally the SDCC compiler will only utilise the first bank of registers, +but it is possible to specify that other banks of registers should +be used in interrupt routines. By default, the compiler will place +the stack after the last bank of used registers, i.e. if the first +2 banks of registers are used, it will position the base of the internal +stack at address 16 (0X10). This implies that as the stack grows, +it will use up the remaining register banks, and the 16 bytes used +by the 128 bit variables, and 60 bytes for general purpose use. + +By default, the compiler uses the 60 general purpose bytes to hold +"near data". The compiler/optimiser may also declare some Local Variables +in this area to hold local data. + +If any of the 128 bit variables are used, or near data is being used +then care needs to be taken to ensure that the stack does not grow +so much that it starts to over write either your bit variables or +"near data". There is no runtime checking to prevent this from happening. + +The amount of stack being used is affected by the use of the "internal +stack" to save registers before a subroutine call is made, - --stack-auto +will declare parameters and local variables on the stack - the number +of nested subroutines. + +If you detect that the stack is over writing you data, then the following +can be done. --xstack will cause an external stack to be used for +saving registers and (if --stack-auto is being used) storing parameters +and local variables. However this will produce more and code which +will be slower to execute. + +--stack-loc will allow you specify the start of the stack, i.e. you +could start it after any data in the general purpose area. However +this may waste the memory not used by the register banks and if the +size of the "near data" increases, it may creep into the bottom of +the stack. + +--stack-after-data, similar to the --stack-loc, but it automatically +places the stack after the end of the "near data". Again this could +waste any spare register space. + +--data-loc allows you to specify the start address of the near data. +This could be used to move the "near data" further away from the stack +giving it more room to grow. This will only work if no bit variables +are being used and the stack can grow to use the bit variable space. + +Conclusion. + +If you find that the stack is over writing your bit variables or "near +data" then the approach which best utilised the internal memory is +to position the "near data" after the last bank of used registers +or, if you use bit variables, after the last bit variable by using +the --data-loc, e.g. if two register banks are being used and no data +variables, --data-loc 16, and - use the --stack-after-data option. + +If bit variables are being used, another method would be to try and +squeeze the data area in the unused register banks if it will fit, +and start the stack after the last bit variable. + +25 Retargetting for other MCUs.\label{Retargetting} + +The issues for retargetting the compiler are far too numerous to be +covered by this document. What follows is a brief description of each +of the seven phases of the compiler and its MCU dependency. + +1. Parsing the source and building the annotated parse tree. This phase + is largely MCU independent (except for the language extensions). + Syntax & semantic checks are also done in this phase , along with + some initial optimizations like back patching labels and the pattern + matching optimizations like bit-rotation etc. + +2. The second phase involves generating an intermediate code which can + be easy manipulated during the later phases. This phase is entirely + MCU independent. The intermediate code generation assumes the target + machine has unlimited number of registers, and designates them with + the name iTemp. The compiler can be made to dump a human readable + form of the code generated by using the --dumpraw option. + +3. This phase does the bulk of the standard optimizations and is also + MCU independent. This phase can be broken down into several sub-phases. + + * Break down intermediate code (iCode) into basic blocks. + + * Do control flow & data flow analysis on the basic blocks. + + * Do local common subexpression elimination, then global subexpression + elimination + + * dead code elimination + + * loop optimizations + + * if loop optimizations caused any changes then do 'global subexpression + elimination' and 'dead code elimination' again. + +4. This phase determines the live-ranges; by live range I mean those + iTemp variables defined by the compiler that still survive after + all the optimizations. Live range analysis is essential for register + allocation, since these computation determines which of these iTemps + will be assigned to registers, and for how long. + +5. Phase five is register allocation. There are two parts to this process . + + (a) The first part I call 'register packing' (for lack of a better + term) . In this case several MCU specific expression folding is + done to reduce register pressure. + + (b) The second part is more MCU independent and deals with allocating + registers to the remaining live ranges. A lot of MCU specific + code does creep into this phase because of the limited number + of index registers available in the 8051. + +6. The Code generation phase is (unhappily), entirely MCU dependent + and very little (if any at all) of this code can be reused for other + MCU. However the scheme for allocating a homogenized assembler operand + for each iCode operand may be reused. + +7. As mentioned in the optimization section the peep-hole optimizer + is rule based system, which can reprogrammed for other MCUs. + +26 Reporting Bugs\label{Bugs} + +Shoot of an email to 'sandeep.dutta@usa.net', as a matter of principle +I always reply to all email's sent to me. Bugs will be fixed ASAP. +When reporting a bug , it is useful to include a small snippet of +code that is causing the problem, if possible compile your program +with the --dumpall option and send the dump files along with the bug +report. + +27 SDCDB - Source level debugger. + +SDCC is distributed with a source level debugger. The debugger uses +a command line interface, the command repertoire of the debugger has +been kept as close to gdb ( the GNU debugger) as possible. The configuration +and build process of the compiler see Installation \ref{Installation} +also builds and installs the debugger in the target directory specified +during configuration. The debugger allows you debug BOTH at the C +source and at the ASM source level. + +27.1 Compiling for debugging. + +The --debug option must be specified for all files for which debug +information is to be generated. The complier generates a .cdb file +for each of these files. The linker updates the .cdb file with the +address information. This .cdb is used by the debugger . + +27.2 How the debugger works. + +When the --debug option is specified the compiler generates extra symbol +information some of which are put into the the assembler source and +some are put into the .cdb file, the linker updates the .cdb file +with the address information for the symbols. The debugger reads the +symbolic information generated by the compiler & the address information +generated by the linker. It uses the SIMULATOR (Daniel's S51) to execute +the program, the program execution is controlled by the debugger. +When a command is issued for the debugger, it translates it into appropriate +commands for the simulator . + +27.3 Starting the debugger. + +The debugger can be started using the following command line. (Assume +the file you are debugging has + +the file name foo). + +>sdcdb foo + +The debugger will look for the following files. + +1. foo.c - the source file. + +2. foo.cdb - the debugger symbol information file. + +3. foo.ihx - the intel hex format object file. + +27.4 Command line options. + +* --directory= this option can used to specify + the directory search list. The debugger will look into the directory + list specified for source , cdb & ihx files. The items in the directory + list must be separated by ':' , e.g. if the source files can be + in the directories /home/src1 and /home/src2, the --directory option + should be --directory=/home/src1:/home/src2 . Note there can be + no spaces in the option. + +* -cd - change to the . + +* -fullname - used by GUI front ends. + +* -cpu - this argument is passed to the simulator please + see the simulator docs for details. + +* -X this options is passed to the simulator please + see simulator docs for details. + +* -s passed to simulator see simulator docs for + details. + +* -S passed to simulator see simulator docs for details. + +27.5 Debugger Commands. + +As mention earlier the command interface for the debugger has been +deliberately kept as close the GNU debugger gdb , as possible, this +will help int integration with existing graphical user interfaces +(like ddd, xxgdb or xemacs) existing for the GNU debugger. + +27.5.1 break [line | file:line | function | file:function] + +Set breakpoint at specified line or function. + +sdcdb>break 100 +sdcdb>break foo.c:100 +sdcdb>break funcfoo +sdcdb>break foo.c:funcfoo + +27.5.2 clear [line | file:line | function | file:function ] + +Clear breakpoint at specified line or function. + +sdcdb>clear 100 +sdcdb>clear foo.c:100 +sdcdb>clear funcfoo +sdcdb>clear foo.c:funcfoo + +27.5.3 continue + +Continue program being debugged, after breakpoint. + +27.5.4 finish + +Execute till the end of the current function. + +27.5.5 delete [n] + +Delete breakpoint number 'n'. If used without any option clear ALL +user defined break points. + +27.5.6 info [break | stack | frame | registers ] + +* info break - list all breakpoints + +* info stack - show the function call stack. + +* info frame - show information about the current execution frame. + +* info registers - show content of all registers. + +27.5.7 step + +Step program until it reaches a different source line. + +27.5.8 next + +Step program, proceeding through subroutine calls. + +27.5.9 run + +Start debugged program. + +27.5.10 ptype variable + +Print type information of the variable. + +27.5.11 print variable + +print value of variable. + +27.5.12 file filename + +load the given file name. Note this is an alternate method of loading +file for debugging. + +27.5.13 frame + +print information about current frame. + +27.5.14 set srcmode + +Toggle between C source & assembly source. + +27.5.15 ! simulator command + +Send the string following '!' to the simulator, the simulator response +is displayed. Note the debugger does not interpret the command being +sent to the simulator, so if a command like 'go' is sent the debugger +can loose its execution context and may display incorrect values. + +27.5.16 quit. + +"Watch me now. Iam going Down. My name is Bobby Brown" + +27.6 Interfacing with XEmacs. + +Two files are (in emacs lisp) are provided for the interfacing with +XEmacs, sdcdb.el and sdcdbsrc.el. These two files can be found in +the $(prefix)/bin directory after the installation is complete. These +files need to be loaded into XEmacs for the interface to work, this +can be done at XEmacs startup time by inserting the following into +your '.xemacs' file (which can be found in your HOME directory) (load-file +sdcdbsrc.el) [ .xemacs is a lisp file so the () around the command +is REQUIRED), the files can also be loaded dynamically while XEmacs +is running, set the environment variable 'EMACSLOADPATH' to the installation +bin directory [$(prefix)/bin], then enter the following command ESC-x +load-file sdcdbsrc . To start the interface enter the following command +ESC-x sdcdbsrc , you will prompted to enter the file name to be debugged. + +The command line options that are passed to the simulator directly +are bound to default values in the file sdcdbsrc.el the variables +are listed below these values maybe changed as required. + +* sdcdbsrc-cpu-type '51 + +* sdcdbsrc-frequency '11059200 + +* sdcdbsrc-serial nil + +The following is a list of key mapping for the debugger interface. + + +;; Current Listing :: +;;key binding Comment +;;--- ------- ------- +;; +;; n sdcdb-next-from-src SDCDB next command +;; b sdcdb-back-from-src SDCDB back command +;; c sdcdb-cont-from-src SDCDB continue command +;; s sdcdb-step-from-src SDCDB step command +;; ? sdcdb-whatis-c-sexp SDCDB ptypecommand for data at +;; buffer point +;; x sdcdbsrc-delete SDCDB Delete all breakpoints if no arg +;; given or delete arg (C-u arg x) +;; m sdcdbsrc-frame SDCDB Display current frame if no arg, +;; given or display frame arg +;; buffer point +;; ! sdcdbsrc-goto-sdcdb Goto the SDCDB output buffer +;; p sdcdb-print-c-sexp SDCDB print command for data at +;; buffer point +;; g sdcdbsrc-goto-sdcdb Goto the SDCDB output buffer +;; t sdcdbsrc-mode Toggles Sdcdbsrc mode (turns it off) +;; +;; C-c C-f sdcdb-finish-from-src SDCDB finish command +;; +;; C-x SPC sdcdb-break Set break for line with point +;; ESC t sdcdbsrc-mode Toggle Sdcdbsrc mode +;; ESC m sdcdbsrc-srcmode Toggle list mode +;; + + +28 Conclusion\label{Conclusion} + +SDCC is a large project , the compiler alone (without the Assembler +Package , Preprocessor & garbage collector) is about 40,000 lines +of code (blank stripped). As with any project of this size there are +bound to be bugs, I am more than willing to work to fix these bugs +, of course all the source code is included with the package. + +Where does it go from here ? I am planning to target the Atmel AVR +8-bit MCUs which seems to have a lot of users. I am also planning +to include an alias analysis system with this compiler (it does not +currently have one). + +29 Acknowledgments\label{Acknowledgements} + +Alan Baldwin (baldwin@shop-pdp.kent.edu) - Initial version of ASXXXX +& ASLINK. + +John Hartman (jhartman@compuserve.com) - Porting ASXXX & ASLINK for +8051 + +Dmitry S. Obukhov (dso@usa.net) - malloc & serial i/o routines. + +Daniel Drotos - for his Freeware +simulator + +Jans J Boehm(boehm@sgi.com) and Alan J Demers - Conservative garbage +collector for C & C++. + +Malini Dutta(malini@mediaone.net) - my wife for her patience and support. + +Unknown - for the GNU C - preprocessor. + +\index diff --git a/doc/SDCCWebPage.html b/doc/SDCCWebPage.html new file mode 100644 index 00000000..e018c6f3 --- /dev/null +++ b/doc/SDCCWebPage.html @@ -0,0 +1,399 @@ + + + + + + SDCC - Freeware, Optimizing C_Compiler (8051) + + + +
                  +
                  +
                  SDCC +
                  +

                  Official Home of SDCC

                  + +

                  What is SDCC ? +

                  +
                  +
                  +SDCC is a Free +ware , retargettable, optimizing ANSI - C compiler. The +current version targets Intel 8051 based +MCUs, it can be retargeted for other 8 bit MCUs or PICs. The  entire +source code for the compiler is distributed under GPL. SDCC uses ASXXXX +& ASLINK a Free ware, retargettable assembler & linker. SDCC has +extensive +MCU (8051) specific language extensions, which lets it utilize +the underlying hardware effectively. The front end (parser) will be enhanced +to handle language extensions for other MCUs as and when they are targeted. +In addition to the MCU Specific optimizations SDCC also does a host of +standard optimizations like global sub expression +elimination, loop optimizations (loop invariant , strength reduction of +induction variables and loop reversing ), constant folding & propagation, +copy propagation, dead code elimination and jump tables for 'switch' statements. +For the Back end SDCC uses a global +register allocation scheme which should be well suited for +other 8 bit MCUs , the peep hole optimizer uses a rule based substitution +mechanism which is MCU independent. Supported data types are short +(8 bits, 1 byte), char (8 +bits, 1 byte) , int (16 bits, 2 bytes ), long +(32 bit, 4 bytes) & float +(4 byte IEEE).  SDCC also comes with a source +level debugger SDCDB, the current version of the debugger uses +Daniel's s51 simulator. The compiler also allows inline +assembler code to be embedded anywhere in a function. In +addition routines developed in assembly can also be called. SDCC also provides +an option to report the relative complexity of a function, these functions +can then be further optimized , or hand coded in assembly if need be.
                  +
                  + +
                  + +
                  + +
                  Download [Sun Jan 16 12:08:15 CST 2000] +
                    +
                  To compile SDCC, Linux ( +and other Unix ) users will need to install gcc or +any other C compiler. Windows 95/NT users will need to download +the full development version of CYGWIN32 from http://sourceware.cygnus.com/cygwin/ +. +Note that cygnus distributes CYGWIN32 in two packages you will need +the full development package, this contains the compiler and other +utilities that you will need to compile SDCC, I have not tried compiling +the system with any other compiler under MS/Windows. +

                  Version 2.1.8 onwards will be distributed in *.tar.gz +format, the installation procedure will also change. Installation section +of the  documentation has been updated to include the new procedure. +Click here to download  sdcc-2.1.9Ga.tar.gz + in +the new distribution format. This distribution also contains Daniel's simulator +. +

                  Vote for the next target +of SDCC +

                  Having trouble downloading ? Here are some alternate site. +

                  +
                  + +
                  +
                  +Looking for Sample code ? Have some code developed for SDCC you want to +share ? +Click +here for the SDCC "Open Knowledge" website +
                    +

                  Binary distribution +of Version 2.1.9Ga for Windows is available +. The distribution is compiled to run from the directory /usr/local. Gunzip +& untar the binary distribution at the root (/) directory of the partition/drive +you want to install the software on. The source distribution of this version +compiles with CYGWIN. Click here to view more +detailed installation instructions for Win95/NT (provided by Michael +Jamet mjamet@computer.org). +

                  A binary distribution of the package for DOS can be downloaded +from SET's  page. +

                  Michael Hope <michaelh@earthling.net> is working on +a Z80 target ,a snapshot of which can be downloaded by clicking +here. +

                  The debugger works the DDD (Data Display debugger), Terry Porter <tp@gronk.apana.org.au> +has a screenshot and a brief HOWTO at http://www.odyssey.apana.org.au/~tjporter/ddd_sdcc.gif +

                  An alternate simulator & source level debugger can be downloaded +from Jens Altmann's JSIM page http://home.t-online.de/home/Jens.Altmann/jsim-e.htm +
                    +

                  Older versions can be downloaded +from Marcus Alanen's Page. +

                  + + + + + + + + + + + + + + +
                  Join our mailing list! Enter your email address +below, then click the 'Join List' button:
                  Powered +by ListBot
                  +
                  +

                  You can view +the archive of messages posted to the mailing +list (poor man's FAQ). +

                  Click +here for SDCC Message Board , maintained by Alex +Ratzefumm <ratzefumm@gmx.net> . +

                  +


                  +Documentation +
                    +
                  +
                  +SDCC User Guide :
                  + + +
                  +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  +Known Problems +
                  +
                  +
                • +MS/Windows Users note that due to some +bugs in the CYGWIN runtime library the compiler generated temporary files +are NOT cleared from the /tmp directory, +these have to be manually deleted.
                • + +
                • +--xstack options not yet fully implemented.
                • + +
                • +first storage class specified overrides +in declarations . e.g.,
                • + +
                  short xdata x, idata y.
                  +will declare both x & y in xdata +space. The work around for this is to declare variables with different +storage classes separately e.g.. +
                  xdata short x; +
                  idata  short y;
                  +
                  +
                  + +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  +Enhancements & Bugs Fixes.
                  + +
                  +
                  Click +here to see the enhancements and bug fixes +done till date.
                  + +
                  +What IDE to use ? +
                    +
                  I recommend using XEmacs, +it is free and is also a really GREAT editor. Linux / Unix users can download +binaries for their specific platforms from ftp://ftp.xemacs.org +.  Windows 95/98/NT Users , can download binaries from ftp://ftp.xemacs.org/pub/xemacs/binary-kits/win32/ +

                  The interface files required for the debugger to interact +with XEmacs is distributed with the source code.

                  + +
                  +
                   
                  + +
                  +Reporting Bugs.
                  + +
                  +
                  +
                  +Click on this sandeep.dutta@usa.netto +send me an email, also send an email +to the mailing list for the benefit of other +users .Bugs will be fixed according to their severity. I will update the +Known Problems section. The compiler alone without the assembler , linker, +Preprocessor & garbage collector is about 40,000 lines of blank skipped +code, as with any project of this size there are bound to be bugs, I will +try me level best to fix them as quickly as I can . If you can trace the +bug and fix it, please do so, do  send me a copy of the fixed source +code so I can update my copy.
                  + +
                  + +
                  + +
                  +
                  +
                  + +
                  +Things we are working on .
                  + +
                  +
                • +More optimizations.
                • + +
                • +Retargeting to for ATMEL AVR (8 bit RISC MCUs).
                • +
                  +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  +Notes for Users of Version 1.xx
                  + +
                  +
                  +For the benefit of  users of the previous Version, I +have kept the parser almost identical, I have added a few features, but +the programs developed using the first version should compile without change +with the new version. The command line options however have changed, the +compiler will generate a warning when it encounters an older option and +prompt you with the new option.
                  + +
                  +Version 2.xx is a almost a complete rewrite, it is much more +stable and ANSI Compliant than the previous version.
                  + +
                  + +
                  + +
                  +
                  +
                  + +
                  +Links
                  + +
                  +
                  +Here are some links I found useful.
                  + +
                    +
                  • +Daniel Drotos has a Freeware +simulator for MCS51.  This simulator is distributed with the compiler +. I found this simulator very very useful (MUST HAVE).
                  • + +
                  • +Joachim Elen  +has a 8051 Micro controller board with Packet Radio interface .
                  • + +
                  • +Goofee is +a very interesting visual programming environment. The software used to +be free now you have to buy his book, but worth taking a look.
                  • + +
                  • +www.8052.com is a great +site for 8051 programmers.
                  • + +
                  • +Dimitry Obukhov has +some useful routines in C, for  I2C  +and other stuff. His malloc & serial I/O routines are included with +the compiler.
                  • + +
                  • +John +Hartman sells NoICE, an emulator. He also created ASXXXX & ASLINK +for 8051. SDCC will eventually support NoICE.
                  • + +
                  • +Tayfun sells +a Single Board Computer based on Phillips 80C552.
                  • +
                  +
                  +
                  + +
                  +
                  +
                  + +
                  +Acknowledgments.
                  + + +
                  + +
                  This page has been accessed  times since +March 6th 1999
                  + + + diff --git a/doc/avr/avr_design.txt b/doc/avr/avr_design.txt new file mode 100644 index 00000000..779621b3 --- /dev/null +++ b/doc/avr/avr_design.txt @@ -0,0 +1,107 @@ +Design Document for AVR Port +---------------------------- + +The first release will support all AVR architectures except ATMega & ATtiny +(i.e. all variants with 64K or less of code/data space will be supported) + +All functions will be REENTRANT . + +I) Language extensions. +----------------------- + +a) Storage classes +------------------ + +"bit" - not applicable (will be returned to user name space) +"data" - not applicable (will be returned to user name space) +"idata" - not applicable (will be returned to user name space) +"xdata" - not applicable (will be returned to user name space) +"code" - will place variable in "code" space. NOTE code space is NOT read-only. +"eeprom"- (new) will place the variable in eeprom (read & write) +"sram" - (new) will place the variable in "SRAM" after the SFRs (default). + + +b) register/sfr bit access. +-------------------------- +Operator '.' will be overloaded ( the compiler will decide if it +is a structure access or register bit access depending on context) +eg. + +sfr SOME_SFR = 0x40; +sfr SOME_OTHER_SFR = 0x41; +foobar() +{ + ... + SOME_SFR.4 = 1; // set bit 4 of sfr SOME_SFR + ... + SOME_SFR.5 = SOME_OTHER_SFR.6; // copy bit 6 of SOME_OTHER_SFR to SOME_SFR's bit 5. + ... +} + +II) Pointers +------------ +As mentioned above initial releases will NOT support ATMega. + +Keeping with the three byte pointers for generic pointers, +the compiler will treat unqualified pointers as 3 byte pointers, +the storage area will be saved in the upper nibble of the third byte +(this will facilitate later support for ATMega). Here we differ for +IAR (they seem to make copies of variables in code & other address +spaces into data space, seemed like a needless waste of data space). + +pointer declaration examples. + +char *cp; /* generic three byte pointer */ +code char *cp; /* pointer to code space */ +eeprom char *cp; /* pointer to data in eepromp */ +sram char *cp; /* pointer to data in SRAM space */ + +III) Function calls +------------------- +The previous issue of function calls has been somewhat resolved. +SDCC will NOT support ATtiny & other variants (such as AT90S1200) +which have limited stack depth. It will however support variants +with 8 bit stack pointers. + +IV) Register Usage +------------------ + +R0-R7 - Paramter passing & return value (differs from IAR I don't + like IAR's usage of R16-R23, specially since R0-R1 has + to be kept free anyway for divide & multiply operations) +R8-R25 - General purpose registers for local variables. +R28-R29(Y) - Stack Frame (Same as IAR) +R26-R27(X) - GPRs assigned to pointers (non generic pointers). +R30-R31(Z) - GPRs assigned to pointers (non generic pointers). + +V) Parameter passing & return values +------------------------------------ +Registers R0-R7 (eight) registers will be used for parameter passing. +Unlike the 8051 port the AVR port will pass the first eight bytes of +parameters in a registers (8051 passes only yhe first parameter in +registers), the exception being.. part of a paramter will not be put +into registers. + +Examples +int foo (char a,long b); + R0 <- a, + R1-R4 <- b; + +int foo (long a, char b, long c) + R0-R3 <- a, + R4 <- b, + (STACK) <- c; + +int foo (long a,long b) + R0-R3 <- a, + R4-R7 <- b; + +Return values will be placed in registers R0-R3; + +VI) Memory models +----------------- +The memory model will be used primarily to determine the +width of the stack pointer. + +--model-small - stack pointer 8 bit +--model-large - stack pointer 16 bit. \ No newline at end of file diff --git a/doc/cdbfile.html b/doc/cdbfile.html new file mode 100644 index 00000000..7207ee80 --- /dev/null +++ b/doc/cdbfile.html @@ -0,0 +1,388 @@ + + + + + + + + +

                  +CDB File format Description

                  +The .cdb file created when the --debug option is used contains  the +following types of records. The records are stored one per  line, +and the first character determines the record type. +
                    +

                  +Type Description Generated by

                  + +
                    +
                  • +'S'    Symbol Record Compiler
                  • + +
                  • +'T'    Structure description record Compiler
                  • + +
                  • +'L'    Linker record assembler/linker
                  • + +
                  • +'F'    Function record Compiler
                  • + +
                  • +'M'   Module record Compiler
                  • +
                  + +

                  +Details of 'S'-Type (Symbol Record)

                  +A symbol record is generated for each named symbol in the source file (local, +global & parameter). The format of the symbol record is as follows. +

                  S:{G|F<filename>|L<functionName>}$<name>$<level>$<block> +(<type info>),<Address Space>,<on Stack?>,<stack offset> +

                  Following the record type is the scope information for the symbol.  +'G' indicates Global . F<filename> indicates the symbol is active for +a given file only (e.g. global variables declared as 'static') L<functionName> +indicates that the symbol is local to the function with the given name. +The follows the name of the variable (this is  the unmangled/user +given name of the variable). The level & block are used to further +scope local variables since C allows the  definitions like ... +

                  foo() +
                  { +
                      int c; /* block #1 , level #1 */ +
                      { +
                          int c; /* block #2, level +#2 */ +
                          ... +
                      } +

                      { +
                          int c; /* block #3 , level +#2 */ +
                          ... +
                      } +
                  } +

                  The type info is a chain of type (since C allows declarations of arbitrary +complexity. The type info has the following format . +

                  ({size}<type info chain>) +

                  size - size in bytes of the symbol. +

                  <type info chain> - should be parsed into a linked list of +type, the elements of the list are described below. +
                    +
                    +

                  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                  Type CodeDescription
                  DA<n>Array of n elements
                  DFFunction
                  DGGeneric pointer
                  DCCode pointer
                  DXXternal Ram pointer
                  DDInternal ram pointer
                  DPPaged pointer
                  DIUpper 128 byte pointer
                  SLlong
                  SIint
                  SCchar
                  SSshort
                  SVvoid
                  SFfloat
                  ST<name>structure of name <name>
                  SX sbit
                  SB<n>bit field of <n> bits.
                  + +

                  Address Space +
                  Code Description +
                  ---- ----------- +
                    +

                  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                  Address Space +
                  Code 
                  Description of address space
                  AExternal stack
                  BInternal stack
                  CCode
                  DCode/static segment
                  EInternal ram (lower 128) bytes
                  FExternal ram
                  GInternal ram
                  HBit addressable
                  ISFR space
                  JSBIT space
                  + +
                    +

                  Sign Information +
                  Code Description +
                  ---- ----------- +
                  S Signed +
                  U Unsigned +

                  Examples +
                  -------- +
                  This is best illustrated with a few examples. +

                  Declaration. +

                  idata char BCD_Cell[5]; +

                  Generates the following debug info. +

                  S:G$BCD_cell$0$0({5}DA5,SC:S),G,0,0 +
                    +

                  The following function declaration along with local variables and parameters. +

                  void uitoa(unsigned int value, char* string, int radix) +
                  { +
                  char buffer[NUMBER_OF_DIGITS]; +

                  .. +
                  } +

                  Will generate the following debug information. +

                  /* function "uitoa" */ +
                  F:G$uitoa$0$0({2}DF,SV:S),C,0,0 +

                  /* parameter "value" */ +
                  S:Luitoa$value$1$1({2}SI:S),E,0,0 +

                  /* parameter "string" */ +
                  S:Luitoa$string$1$1({3}DG,SC:S),E,0,0 +

                  /* parameter "radix" */ +
                  S:Luitoa$radix$1$1({2}SI:S),E,0,0 +

                  /* local variable "buffer" */ +
                  S:Luitoa$buffer$1$1({16}DA16,SC:S),E,0,0 +
                    +

                  Details of 'T'-Type (Structure Record) +
                  -------------------------------------- +
                  Structure definitions ALWAYS have file scope. Currently structure definitions +
                  within functions or blocks are not handled in the debug information. +Structure +
                  and unions are represented using the same debug format. The format +of the +
                  Structure record is as follows . +

                  T:F<filename>$tag[({offset}<Symbol Record 'S' type for 1st field>) +
                  ({offset}<Symbol Record 'S' type for 2nd field>) +
                  ... +
                  ... +
                  ] +

                  Example 1. +
                  ---------- +

                  Definition +

                  struct some_struct { +
                  int a; +
                  char b; +
                  long c; +
                  }; +

                  Generates the following 'T' - type record. +

                  T:Fprob38$some_struct[ +
                  /* field 'a' offset = 0 */ +
                  ({0}S:S$a$1$0({2}SI:S),Z,0,0) +
                  /* field 'b' offset = 2 */ +
                  ({2}S:S$b$1$0({1}SC:S),Z,0,0) +
                  /* field 'c' offset = 3 */ +
                  ({3}S:S$c$1$0({4}SL:S),Z,0,0)] +

                  The 'S' - type (symbol rescord for each of the fields is embedded inside +
                  the structure definition record. +

                  Example 2. +
                  ---------- +

                  Structure declarations with embeded structures. +

                  union bil { +
                  struct { +
                  volatile unsigned char b0, +
                  b1, +
                  b2, +
                  b3 ; +
                  } b; +
                  struct { +
                  volatile unsigned int lo,hi ; +
                  } i; +
                  unsigned volatile long l; +
                  struct { +
                  volatile unsigned char b0; +
                  unsigned int i12; +
                  unsigned char b3;} +
                  bi; +
                  } ; +
                    +

                  Generates the following debug information. NOTE: the embedded anonymous +
                  structures generates separate T - type records. +

                  T:Fprob38$bil[ +
                  /* field 'b' is of type Structure __00020000 , offset = 0 */ +
                  ({0}S:S$b$1$0({4}ST__00020000:S),Z,0,0) +

                  /* field 'i' is of type structre __00020001 , offset = 0 (union) */ +
                  ({0}S:S$i$1$0({4}ST__00020001:S),Z,0,0) +

                  /* field 'l' is of type unsigned long */ +
                  ({0}S:S$l$1$0({4}SL:U),Z,0,0) +

                  /* field 'bi' is of type structure __00020002 offset = 0 */ +
                  ({0}S:S$bi$1$0({4}ST__00020002:S),Z,0,0)] +

                  /* compiler generates these 'T'-type records for the +
                  anonymous structures */ +

                  /* T record for structure __00020000 (field 'b' in the above structure) +*/ +

                  T:Fprob38$__00020000[ +
                  /* field 'b0' type unsigned char , offset = 0 */ +
                  ({0}S:S$b0$2$0({1}SC:U),Z,0,0) +

                  /* field 'b1' type unsigned char , offset = 1 */ +
                  ({1}S:S$b1$2$0({1}SC:U),Z,0,0) +

                  /* field 'b2' type unsigned char, offset = 2 */ +
                  ({2}S:S$b2$2$0({1}SC:U),Z,0,0) +

                  /* field 'b3' type unsigned char , offset = 3 */ +
                  ({3}S:S$b3$2$0({1}SC:U),Z,0,0)] +

                  /* T record for structure __00020001 (field 'i' in union 'bil' ) */ +

                  T:Fprob38$__00020001[ +
                  /* field 'lo' type unsigned int offset 0 */ +
                  ({0}S:S$lo$2$0({2}SI:U),Z,0,0) +

                  /* field 'hi' type unsigned int offset 2 */ +
                  ({2}S:S$hi$2$0({2}SI:U),Z,0,0)] +

                  /* T record for structure __00020002 (field 'bi' in union 'bil' )*/ +

                  T:Fprob38$__00020002[ +
                  /* field 'b0' type unsigned char , offset 0 */ +
                  ({0}S:S$b0$2$0({1}SC:U),Z,0,0) +

                  /* field 'i1' type unsigned int , offset 1 */ +
                  ({1}S:S$i12$2$0({2}SI:U),Z,0,0) +

                  /* field 'b3' type unsigned char offset 3 */ +
                  ({3}S:S$b3$2$0({1}SC:U),Z,0,0)] +

                  Details of 'F'-Type (FUNCTION Record) +
                  -------------------------------------- +
                  A Function record is created for each function defined in the C Source +
                  file. The format of a function record is identical to that of the Symbol +
                  record. The function record contains information about the return value +
                  of a function, in addition it contains information about the register +bank +
                  the function uses and if the function is an interrupt service routine +the +
                  interrupt number of the function. +

                  Example 1. +
                  ---------- + + diff --git a/doc/cygwininst.txt b/doc/cygwininst.txt new file mode 100644 index 00000000..b8248753 --- /dev/null +++ b/doc/cygwininst.txt @@ -0,0 +1,151 @@ + + + sdcc - http://www.geocities.com/ResearchTriangle/Forum/1353 To all, + + First a correction. I had a typo in the Cygnus URL. Correct URL is shown below. + + Second, Douglas wrote: + + Why do you have to put cygnus on the c drive? I have run it for a while on + the D drive, which has worked fine until the latest release. Is there a + manual fix to let cygnus reside at D without problems? + + + The "bison" program (part of the Cygnus suite) is looking for a file on the c drive which is why the build does not work + properly. Actually, it just references a path like /abc/xyz... which IMPLIES the c drive. You can probably work around the + problem by mounting your D drive somewhere onto the main tree. I did not attempt this because I assumed most people + trying to build on a Win 32 system do not know about UNIX administration. + + I do not know why it worked prior to this release. I would have to go back and try to build one of the previous releases to + figure out if the problem resides with sdcc or Cygnus. + + Michael Jamet + mjamet@computer.org + + + ====================================================================== + How to install SDCC from source on a Windows 95 or Windows NT 4 system + + This document describes how to install SDCC on a Win 95 or Win NT 4 system. + These instructions probably work for Win 98 as well, but have not been + tested on that platform. + + There are lots of little differences between UNIX and the Win32 Cygnus + environment which make porting more difficult than it should be. If + you want the details, please contact me. Otherwise just follow these + instructions. + + 1. Install the Cygnus Software + Go to http://sourceware.cygnus.com/cygwin. Cygnus provides a UNIX like + environment for Win 32 systems. Download "full.exe" and install. You + MUST install it on your C drive. "full.exe" contains a shell AND many + common UNIX utilities. + + 2. Download and Extract the Latest SDCC + The latest version can be found at + www.geocities.com/ResearchTriange/Forum/1353. + It can be uncompressed with winzip. + + 3. Start a Cygnus Shell + There should be an entry in the Start Menu for Cygnus. Invoke the shell. + This gives you a UNIX like environment. FROM THIS POINT ON, DIRECTORIES + MUST BE SPECIFIED WITH FORWARD SLASHES (/) NOT THE DOS STYLE BACK + SLASHES (\) BECAUSE THIS IS WHAT UNIX EXPECTS. - + ex. "\winnt" would be "/winnt" under the shell. + + 4. Change Directory to Where SDCC was extracted (referred to as INSTALLDIR) + + ex. cd /sdcc218Da. If you extracted to a drive OTHER THAN C, the drive + must be specified as part of the path. For example, if you extracted to + your "g drive", type the following: "cd //g/mydir". You must use "//" + to specify the drive. + + 5. Make Dirs Which are Automatically Made During the UNIX Installation + From the INSTALLDIR, + + mkdir -p bin (not a typo, just "bin") + mkdir -p /bin + mkdir -p /usr/local/bin + mkdir -p /usr/local/share + mkdir -p /usr/local/share/sdcc51lib + mkdir -p /usr/local/share/sdcc51inc + mkdir -p /tmp + + (When a path from the root directory is specified WITHOUT a drive, the + drive defaults to c. For example /michael/newuser => c:\michael\newuser) + + 6. Add Programs to /bin Expected by the Installation Process + - Look at your path: echo $PATH + One of the fields is the diretory with the CYGNUS programs. + ex. /CYGNUS/CYGWIN~1/H-I586/BIN + + - cd to the directory found above. You may have to fiddle with the + case (upper or lower) here because the PATH is SHOWN as all upper + case, but is actually mixed. To help you along, you may type + a letter or 2 followed by the escape key. The shell will fill + out the remaining letters IF THEY describe a unique directory. + If you have problems here, cd one directory and type "ls". "ls" + is the equivalent of "dir/w". + + - Copy the following: + cp sh.exe /bin + cp pwd.exe /bin + cp echo.exe /bin + + 7. Go back to the INSTALLDIR + cd INSTALLDIR + ex. cd //d/sdcc218Da + + 8. Run the configure Program + ./configure + The "./" is important because your current directory is NOT in your path. + Under DOS, your current directory was implicitly always the first entry + in your path. + + 9. Run make + make + + This process takes quite some time under Win 32. + + 10. Install the Newly Built Software + make install + + This will partially install the software into the /usr/local directories + created in step 5. What it actually doing is copying the .c, .h and + library files to directories under /usr/local/share. + + It will NOT be able to install the actual programs (binaries) because + it does not know programs on Win32 systems have ".exe" extensions. + For example, it tries to install sdcc instead of sdcc.exe. + + After the automated part is finished, you must manually copy the binaries: + cd bin (This is the bin directory in your INSTALLDIR) + cp * /usr/local/bin + + 11. Make sure /usr/local/bin is in Your PATH + You may add c:\usr\local\bin to your path however your Win32 system allows. For + example you may add it to the PATH statement in autoexec.bat. + + Good luck. If you have any questions send them to me or post them + to the list. + + + + sdcc - http://www.geocities.com/ResearchTriangle/Forum/1353 To all, + + First a correction. I had a typo in the Cygnus URL. Correct URL is shown below. + + Second, Douglas wrote: + + Why do you have to put cygnus on the c drive? I have run it for a while on + the D drive, which has worked fine until the latest release. Is there a + manual fix to let cygnus reside at D without problems? + + + The "bison" program (part of the Cygnus suite) is looking for a file on the c drive which is why the build does not work + properly. Actually, it just references a path like /abc/xyz... which IMPLIES the c drive. You can probably work around the + problem by mounting your D drive somewhere onto the main tree. I did not attempt this because I assumed most people + trying to build on a Win 32 system do not know about UNIX administration. + + I do not know why it worked prior to this release. I would have to go back and try to build one of the previous releases to + figure out if the problem resides with sdcc or Cygnus. diff --git a/doc/readme.dj b/doc/readme.dj new file mode 100644 index 00000000..9907bcb3 --- /dev/null +++ b/doc/readme.dj @@ -0,0 +1,41 @@ +This file is for djgpp users that want to compile sdcc with djgpp under DOS. + +Requirements: + +* For the current release you'll need a system that supports long file names +(Win 95 or Win 98). That's because a lot of names aren't 8+3 clean and the +compile process will fail. +* You'll need fileutils (rm, ls, etc.) and maybe textutils too. +* bash is also needed to run the sdccbuild.sh script. +ATTENTION! use bash 2.03 or newer, *don't* use the old bash found in +simtelnet (bsh1147b.zip) it could crash. In my case generated a GPF in the +W95 kernel so I don't recommend using it. +* bison and flex are needed because the parser is done using bison. +* DJGPP v2.02 or newer, it won't work with 2.01. +* The usual djgpp stuff is of course needed (make, gcc, etc). +* Autoconf and automake are needed for 2.1.8 and newer SDCC versions. +* A lot of free memory, the parser generated by bison is over 700Kb so you +won't compile it with only 10Mb of free memory. + +How to compile: + +* Delete configure file and run "make configure". +* run it: + +bash sdccbuild.sh + +And follow the instructions. Ignore the warnings. +If all works ok you'll get sdcc in the bin directory and all the libc support +compiled in sdcc51lib. + +I think that's all. + +Notes: +* I patched gc 4.13pl3 (gc directory) to support djgpp v2.x, Hans told me the +patch will be part of 4.14. +* I patched the sources to avoid using fork/exec/wait and just use system. +* Also patched the sdccbuild.sh to detect MS-DOS and then use ; as the +PATH_SEPARATOR, if it fails in your system edit the file to make: +PATH_SEPARATOR=";" + +Salvador Eduardo Tropea (SET), salvador@inti.gov.ar or set@computer.org diff --git a/doc/z80/README b/doc/z80/README new file mode 100644 index 00000000..95bf69a7 --- /dev/null +++ b/doc/z80/README @@ -0,0 +1,6 @@ +For more information on the z80 port, see: + +http://earthling.net.nz/~michaelh/ + +-- Michael Hope + michaelh@earthling.net diff --git a/install-sh b/install-sh new file mode 100755 index 00000000..89fc9b09 --- /dev/null +++ b/install-sh @@ -0,0 +1,238 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. +# + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +tranformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/link/README b/link/README new file mode 100644 index 00000000..5aba86d3 --- /dev/null +++ b/link/README @@ -0,0 +1,8 @@ +sdcc/link +--------- + +In gbdk the linker and assembler were split into seperate packages. + +For now I'm keeping that split, and leaving the mcs51 version as is. + +-- Michael diff --git a/link/z80/Makefile b/link/z80/Makefile new file mode 100644 index 00000000..3848c519 --- /dev/null +++ b/link/z80/Makefile @@ -0,0 +1,21 @@ +TOPDIR = ../.. + +include $(TOPDIR)/Makefile.common + +OBJS = lkarea.o lkdata.o lkeval.o lkhead.o lkihx.o lklex.o \ + lklibr.o lklist.o lkmain.o lkrloc.o lks19.o lksym.o \ + lkgb.o lkgg.o +BINS = link$E + +CFLAGS += -funsigned-char -DUNIX + +all: $(BINS) + +$(BINS): $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) + +%.o: %.c + $(CC) -c $(CFLAGS) -I$(TOPDIR)/as/$(PORT) -o $@ $< + +clean: + rm -f $(OBJS) $(BINS) diff --git a/link/z80/aslink.h b/link/z80/aslink.h new file mode 100644 index 00000000..c241194d --- /dev/null +++ b/link/z80/aslink.h @@ -0,0 +1,713 @@ +/* aslink.h */ + +/* + * (C) Copyright 1989-1996 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#define VERSION "V01.75" + +/* + * Case Sensitivity Flag + */ +#define CASE_SENSITIVE 0 + +/*)Module asmlnk.h + * + * The module asmlnk.h contains the definitions for constants, + * structures, global variables, and LKxxxx functions + * contained in the LKxxxx.c files. + */ + +/*)BUILD + $(PROGRAM) = ASLINK + $(INCLUDE) = ASLINK.H + $(FILES) = { + LKMAIN.C + LKLEX.C + LKAREA.C + LKHEAD.C + LKSYM.C + LKEVAL.C + LKDATA.C + LKLIST.C + LKRLOC.C + LKLIBR.C + LKS19.C + LKIHX.C + } + $(STACK) = 2000 +*/ + +/* DECUS C void definition */ +/* File/extension seperator */ + +#ifdef decus +#define VOID char +#define FSEPX '.' +#endif + +/* PDOS C void definition */ +/* File/extension seperator */ + +#ifdef PDOS +#define VOID char +#define FSEPX ':' +#endif + +/* Default void definition */ +/* File/extension seperator */ + +#ifndef VOID +#define VOID void +#define FSEPX '.' +#define OTHERSYSTEM +#endif + +/* + * This file defines the format of the + * relocatable binary file. + */ + +#ifdef SDK +#define NCPS 32 /* characters per symbol */ +#else /* SDK */ +#define NCPS 8 /* characters per symbol */ +#endif /* SDK */ +/* #define NCPS 32 */ /* characters per symbol */ +#define NDATA 16 /* actual data */ +#define NINPUT 128 /* Input buffer size */ +#define NHASH 64 /* Buckets in hash table */ +#define HMASK 077 /* Hash mask */ +#define NLPP 60 /* Lines per page */ +#define NTXT 16 /* T values */ +#define FILSPC 80 /* File spec length */ + +/* + * The "R_" relocation constants define values used in + * generating the assembler relocation output data for + * areas, symbols, and code. + * + * + * Relocation types. + * + * 7 6 5 4 3 2 1 0 + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * | MSB | PAGn| PAG0| USGN| BYT2| PCR | SYM | BYT | + * +-----+-----+-----+-----+-----+-----+-----+-----+ + */ + +#define R_WORD 0000 /* 16 bit */ +#define R_BYTE 0001 /* 8 bit */ + +#define R_AREA 0000 /* Base type */ +#define R_SYM 0002 + +#define R_NORM 0000 /* PC adjust */ +#define R_PCR 0004 + +#define R_BYT1 0000 /* Byte count for R_BYTE = 1 */ +#define R_BYT2 0010 /* Byte count for R_BYTE = 2 */ + +#define R_SGND 0000 /* Signed value */ +#define R_USGN 0020 /* Unsigned value */ + +#define R_NOPAG 0000 /* Page Mode */ +#define R_PAG0 0040 /* Page '0' */ +#define R_PAG 0100 /* Page 'nnn' */ + +/* + * Valid for R_BYT2: + */ +#define R_LSB 0000 /* output low byte */ +#define R_MSB 0200 /* output high byte */ + +/* + * Global symbol types. + */ +#define S_REF 1 /* referenced */ +#define S_DEF 2 /* defined */ + +/* + * Area types + */ +#define A_CON 000 /* concatenate */ +#define A_OVR 004 /* overlay */ +#define A_REL 000 /* relocatable */ +#define A_ABS 010 /* absolute */ +#define A_NOPAG 000 /* non-paged */ +#define A_PAG 020 /* paged */ + +/* + * File types + */ +#define F_STD 1 /* stdin */ +#define F_LNK 2 /* File.lnk */ +#define F_REL 3 /* File.rel */ +#ifdef SDK +#define F_CMD 4 /* Command line */ +#endif /* SDK */ + +#ifdef GAMEBOY +/* + * Multiple banks support + */ +extern int nb_rom_banks; +extern int nb_ram_banks; +extern int current_rom_bank; +extern int mbc_type; +extern char cart_name[]; +/* + * ROM patching support + */ +typedef struct _patch { + unsigned int addr; + unsigned char value; + struct _patch *next; +} patch; +extern patch* patches; +#endif /* GAMEBOY */ +/* + * General assembler address type + */ +typedef unsigned int addr_t; + +/* + * The structures of head, area, areax, and sym are created + * as the REL files are read during the first pass of the + * linker. The struct head is created upon encountering a + * H directive in the REL file. The structure contains a + * link to a link file structure (struct lfile) which describes + * the file containing the H directive, the number of data/code + * areas contained in this header segment, the number of + * symbols referenced/defined in this header segment, a pointer + * to an array of pointers to areax structures (struct areax) + * created as each A directive is read, and a pointer to an + * array of pointers to symbol structures (struct sym) for + * all referenced/defined symbols. As H directives are read + * from the REL files a linked list of head structures is + * created by placing a link to the new head structure + * in the previous head structure. + */ +struct head +{ + struct head *h_hp; /* Header link */ + struct lfile *h_lfile;/* Associated file */ + int h_narea; /* # of areas */ + struct areax **a_list; /* Area list */ + int h_nglob; /* # of global symbols */ + struct sym **s_list; /* Globle symbol list */ + char m_id[NCPS]; /* Module name */ +}; + +/* + * A structure area is created for each 'unique' data/code + * area definition found as the REL files are read. The + * struct area contains the name of the area, a flag byte + * which contains the area attributes (REL/CON/OVR/ABS), + * an area subtype (not used in this assembler), and the + * area base address and total size which will be filled + * in at the end of the first pass through the REL files. + * As A directives are read from the REL files a linked + * list of unique area structures is created by placing a + * link to the new area structure in the previous area structure. + */ +struct area +{ + struct area *a_ap; /* Area link */ + struct areax *a_axp; /* Area extension link */ + addr_t a_addr; /* Beginning address of area */ + addr_t a_size; /* Total size of the area */ + char a_type; /* Area subtype */ + char a_flag; /* Flag byte */ + char a_id[NCPS]; /* Name */ +}; + +/* + * An areax structure is created for every A directive found + * while reading the REL files. The struct areax contains a + * link to the 'unique' area structure referenced by the A + * directive and to the head structure this area segment is + * a part of. The size of this area segment as read from the + * A directive is placed in the areax structure. The beginning + * address of this segment will be filled in at the end of the + * first pass through the REL files. As A directives are read + * from the REL files a linked list of areax structures is + * created for each unique area. The final areax linked + * list has at its head the 'unique' area structure linked + * to the linked areax structures (one areax structure for + * each A directive for this area). + */ +struct areax +{ + struct areax *a_axp; /* Area extension link */ + struct area *a_bap; /* Base area link */ + struct head *a_bhp; /* Base header link */ + addr_t a_addr; /* Beginning address of section */ + addr_t a_size; /* Size of the area in section */ +}; + +/* + * A sym structure is created for every unique symbol + * referenced/defined while reading the REL files. The + * struct sym contains the symbol's name, a flag value + * (not used in this linker), a symbol type denoting + * referenced/defined, and an address which is loaded + * with the relative address within the area in which + * the symbol was defined. The sym structure also + * contains a link to the area where the symbol was defined. + * The sym structures are linked into linked lists using + * the symbol link element. + */ +struct sym +{ + struct sym *s_sp; /* Symbol link */ + struct areax *s_axp; /* Symbol area link */ + char s_type; /* Symbol subtype */ + char s_flag; /* Flag byte */ + addr_t s_addr; /* Address */ + char s_id[NCPS]; /* Name */ +}; + +/* + * The structure lfile contains a pointer to a + * file specification string, the file type, and + * a link to the next lfile structure. + */ +struct lfile +{ + struct lfile *f_flp; /* lfile link */ + int f_type; /* File type */ + char *f_idp; /* Pointer to file spec */ +}; + +/* + * The struct base contains a pointer to a + * base definition string and a link to the next + * base structure. + */ +struct base +{ + struct base *b_base; /* Base link */ + char *b_strp; /* String pointer */ +}; + +/* + * The struct globl contains a pointer to a + * global definition string and a link to the next + * global structure. + */ +struct globl +{ + struct globl *g_globl; /* Global link */ + char *g_strp; /* String pointer */ +}; + +/* + * A structure sdp is created for each 'unique' paged + * area definition found as the REL files are read. + * As P directives are read from the REL files a linked + * list of unique sdp structures is created by placing a + * link to the new sdp structure in the previous area structure. + */ +struct sdp +{ + struct area *s_area; /* Paged Area link */ + struct areax *s_areax; /* Paged Area Extension Link */ + addr_t s_addr; /* Page address offset */ +}; + +/* + * The structure rerr is loaded with the information + * required to report an error during the linking + * process. The structure contains an index value + * which selects the areax structure from the header + * areax structure list, a mode value which selects + * symbol or area relocation, the base address in the + * area section, an area/symbol list index value, and + * an area/symbol offset value. + */ +struct rerr +{ + int aindex; /* Linking area */ + int mode; /* Relocation mode */ + addr_t rtbase; /* Base address in section */ + int rindex; /* Area/Symbol reloaction index */ + addr_t rval; /* Area/Symbol offset value */ +}; + +/* + * The structure lbpath is created for each library + * path specification input by the -k option. The + * lbpath structures are linked into a list using + * the next link element. + */ +struct lbpath { + struct lbpath *next; + char *path; +}; + +/* + * The structure lbname is created for all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file. The element path points to + * the path string, element libfil points to the library + * file string, and the element libspc is the concatenation + * of the valid path and libfil strings. + * + * The lbpath structures are linked into a list + * using the next link element. + * + * Each library file contains a list of object files + * that are contained in the particular library. e.g.: + * + * \iolib\termio + * \inilib\termio + * + * Only one specification per line is allowed. + */ +struct lbname { + struct lbname *next; + char *path; + char *libfil; + char *libspc; +}; + +/* + * The function fndsym() searches through all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file for a symbol definition. + * + * The structure lbfile is created for the first library + * object file which contains the definition for the + * specified undefined symbol. + * + * The element libspc points to the library file path specification + * and element relfil points to the object file specification string. + * The element filspc is the complete path/file specification for + * the library file to be imported into the linker. The + * file specicifation may be formed in one of two ways: + * + * (1) If the library file contained an absolute + * path/file specification then this becomes filspc. + * (i.e. C:\...) + * + * (2) If the library file contains a relative path/file + * specification then the concatenation of the path + * and this file specification becomes filspc. + * (i.e. \...) + * + * The lbpath structures are linked into a list + * using the next link element. + */ +struct lbfile { + struct lbfile *next; + char *libspc; + char *relfil; + char *filspc; +}; + +/* + * External Definitions for all Global Variables + */ + +extern char *_abs_; /* = { ". .ABS." }; + */ +extern int lkerr; /* ASLink error flag + */ +extern char *ip; /* pointer into the REL file + * text line in ib[] + */ +extern char ib[NINPUT]; /* REL file text line + */ +extern char *rp; /* pointer into the LST file + * text line in rb[] + */ +extern char rb[NINPUT]; /* LST file text line being + * address relocated + */ +extern char ctype[]; /* array of character types, one per + * ASCII character + */ + +/* + * Character Type Definitions + */ +#define SPACE 0000 +#define ETC 0000 +#define LETTER 0001 +#define DIGIT 0002 +#define BINOP 0004 +#define RAD2 0010 +#define RAD8 0020 +#define RAD10 0040 +#define RAD16 0100 +#define ILL 0200 + +#define DGT2 DIGIT|RAD16|RAD10|RAD8|RAD2 +#define DGT8 DIGIT|RAD16|RAD10|RAD8 +#define DGT10 DIGIT|RAD16|RAD10 +#define LTR16 LETTER|RAD16 + +#if CASE_SENSITIVE +#else +extern char ccase[]; /* an array of characters which + * perform the case translation function + */ +#endif + +extern struct lfile *filep; /* The pointers (lfile *) filep, + * (lfile *) cfp, and (FILE *) sfp + * are used in conjunction with + * the routine getline() to read + * asmlnk commands from + * (1) the standard input or + * (2) or a command file + * and to read the REL files + * sequentially as defined by the + * asmlnk input commands. + * + * The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + */ +extern struct lfile *cfp; /* The pointer *cfp points to the + * current lfile structure + */ +extern struct lfile *startp;/* asmlnk startup file structure + */ +extern struct lfile *linkp; /* pointer to first lfile structure + * containing an input REL file + * specification + */ +extern struct lfile *lfp; /* pointer to current lfile structure + * being processed by parse() + */ +extern struct head *headp; /* The pointer to the first + * head structure of a linked list + */ +extern struct head *hp; /* Pointer to the current + * head structure + */ +extern struct area *areap; /* The pointer to the first + * area structure of a linked list + */ +extern struct area *ap; /* Pointer to the current + * area structure + */ +extern struct areax *axp; /* Pointer to the current + * areax structure + */ +extern struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ +extern struct base *basep; /* The pointer to the first + * base structure + */ +extern struct base *bsp; /* Pointer to the current + * base structure + */ +extern struct globl *globlp;/* The pointer to the first + * globl structure + */ +extern struct globl *gsp; /* Pointer to the current + * globl structure + */ +extern struct sdp sdp; /* Base Paged structure + */ +extern struct rerr rerr; /* Structure containing the + * linker error information + */ +extern FILE *ofp; /* Linker Output file handle + */ +extern FILE *mfp; /* Map output file handle + */ +extern FILE *rfp; /* File handle for output + * address relocated ASxxxx + * listing file + */ +extern FILE *sfp; /* The file handle sfp points to the + * currently open file + */ +extern FILE *tfp; /* File handle for input + * ASxxxx listing file + */ +extern int oflag; /* Output file type flag + */ +extern int mflag; /* Map output flag + */ +#ifdef SDK +extern int symflag; /* no$gmb .sym output flag + */ +#endif +extern int xflag; /* Map file radix type flag + */ +extern int pflag; /* print linker command file flag + */ +extern int uflag; /* Listing relocation flag + */ +extern int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +extern int line; /* current line number + */ +extern int page; /* current page number + */ +extern int lop; /* current line number on page + */ +extern int pass; /* linker pass number + */ +extern int rtcnt; /* count of elements in the + * rtval[] and rtflg[] arrays + */ +extern addr_t rtval[]; /* data associated with relocation + */ +extern int rtflg[]; /* indicates if rtval[] value is + * to be sent to the output file. + * (always set in this linker) + */ +extern int hilo; /* REL file byte ordering + */ +extern int gline; /* LST file relocation active + * for current line + */ +extern int gcntr; /* LST file relocation active + * counter + */ +extern struct lbpath *lbphead; /* pointer to the first + * library path structure + */ +extern struct lbname *lbnhead; /* pointer to the first + * library name structure + */ +extern struct lbfile *lbfhead; /* pointer to the first + * library file structure + */ + +/* C Library function definitions */ +/* for reference only +extern VOID exit(); +extern int fclose(); +extern char * fgets(); +extern FILE * fopen(); +extern int fprintf(); +extern VOID free(); +extern VOID * malloc(); +extern char putc(); +extern char * strcpy(); +extern int strlen(); +extern char * strncpy(); +*/ + +/* Program function definitions */ + +/* lkmain.c */ +extern FILE * afile(); +extern VOID bassav(); +extern VOID gblsav(); +extern VOID link(); +extern VOID lkexit(); +extern VOID main(); +extern VOID map(); +#ifdef SDK +extern VOID sym(); +#endif +extern int parse(); +extern VOID setbas(); +extern VOID setgbl(); +extern VOID usage(); + +/* lklex.c */ +extern char endline(); +extern char get(); +extern VOID getfid(); +extern VOID getid(); +extern int getline(); +extern int getmap(); +extern char getnb(); +extern int more(); +extern VOID skip(); +extern VOID unget(); + +/* lkarea.c */ +extern VOID lkparea(); +extern VOID lnkarea(); +extern VOID lnksect(); +extern VOID newarea(); + +/* lkhead.c */ +extern VOID module(); +extern VOID newhead(); + +/* lksym.c */ +extern int hash(); +extern struct sym * lkpsym(); +extern VOID * new(); +extern struct sym * newsym(); +extern VOID symdef(); +extern int symeq(); +extern VOID syminit(); +extern VOID symmod(); +extern addr_t symval(); + +/* lkeval.c */ +extern int digit(); +extern addr_t eval(); +extern addr_t expr(); +extern int oprio(); +extern addr_t term(); + +/* lklist.c */ +extern int dgt(); +extern VOID lkulist(); +extern VOID lkalist(); +extern VOID lkglist(); +extern VOID lstarea(); +extern VOID newpag(); +extern VOID slew(); + +/* lkrloc.c */ +extern addr_t adb_b(); +extern addr_t adb_hi(); +extern addr_t adb_lo(); +extern addr_t adw_w(); +extern addr_t adw_hi(); +extern addr_t adw_lo(); +extern addr_t evword(); +extern VOID rele(); +extern VOID reloc(); +extern VOID relt(); +extern VOID relr(); +extern VOID relp(); +extern VOID relerr(); +extern char * errmsg[]; +extern VOID errdmp(); +extern VOID relerp(); +extern VOID erpdmp(); +extern VOID prntval(); + +/* lklibr.c */ +extern VOID addfile(); +extern VOID addlib(); +extern VOID addpath(); +extern int fndsym(); +extern VOID library(); +extern VOID loadfile(); +extern VOID search(); + +/* lks19.c */ +extern VOID s19(); + +/* lkihx.c */ +extern VOID ihx(); diff --git a/link/z80/lkarea.c b/link/z80/lkarea.c new file mode 100644 index 00000000..797b0b41 --- /dev/null +++ b/link/z80/lkarea.c @@ -0,0 +1,431 @@ +/* lkarea.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkarea.c + * + * The module lkarea.c contains the functions which + * create and link together all area definitions read + * from the .rel file(s). + * + * lkarea.c contains the following functions: + * VOID lnkarea() + * VOID lnksect() + * VOID lkparea() + * VOID newarea() + * + * lkarea.c contains no global variables. + */ + +/*)Function VOID newarea() + * + * The function newarea() creates and/or modifies area + * and areax structures for each A directive read from + * the .rel file(s). The function lkparea() is called + * to find tha area structure associated with this name. + * If the area does not yet exist then a new area + * structure is created and linked to any existing + * linked area structures. The area flags are copied + * into the area flag variable. For each occurence of + * an A directive an areax structure is created and + * linked to the areax structures associated with this + * area. The size of this area section is placed into + * the areax structure. The flag value for all subsequent + * area definitions for the same area are compared and + * flagged as an error if they are not identical. + * The areax structure created for every occurence of + * an A directive is loaded with a pointer to the base + * area structure and a pointer to the associated + * head structure. And finally, a pointer to this + * areax structure is loaded into the list of areax + * structures in the head structure. Refer to lkdata.c + * for details of the structures and their linkage. + * + * local variables: + * areax **halp pointer to an array of pointers + * int i counter, loop variable, value + * char id[] id string + * int narea number of areas in this head structure + * areax * taxp pointer to an areax structure + * to areax structures + * + * global variables: + * area *ap Pointer to the current + * area structure + * areax *axp Pointer to the current + * areax structure + * head *hp Pointer to the current + * head structure + * int lkerr error flag + * + * functions called: + * addr_t eval() lkeval.c + * VOID exit() c_library + * int fprintf() c_library + * VOID getid() lklex.c + * VOID lkparea() lkarea.c + * VOID skip() lklex.c + * + * side effects: + * The area and areax structures are created and + * linked with the appropriate head structures. + * Failure to allocate area or areax structure + * space will terminate the linker. Other internal + * errors most likely caused by corrupted .rel + * files will also terminate the linker. + */ + +/* + * Create an area entry. + * + * A xxxxxx size nnnn flags mm + * | | | + * | | `-- ap->a_flag + * | `------------- axp->a_size + * `------------------------- ap->a_id + * + */ +VOID +newarea() +{ + register i, narea; + struct areax *taxp; + struct areax **halp; + char id[NCPS]; + + /* + * Create Area entry + */ + getid(id, -1); + lkparea(id); + /* + * Evaluate area size + */ + skip(-1); + axp->a_size = eval(); + /* + * Evaluate flags + */ + skip(-1); + i = 0; + taxp = ap->a_axp; + while (taxp->a_axp) { + ++i; + taxp = taxp->a_axp; + } + if (i == 0) { + ap->a_flag = eval(); + } else { + i = eval(); + if (i && (ap->a_flag != i)) { + fprintf(stderr, "Conflicting flags in area %.8s\n", id); + lkerr++; + } + } + /* + * Place pointer in header area list + */ + if (headp == NULL) { + fprintf(stderr, "No header defined\n"); + lkexit(1); + } + narea = hp->h_narea; + halp = hp->a_list; + for (i=0; i < narea ;++i) { + if (halp[i] == NULL) { + halp[i] = taxp; + return; + } + } + fprintf(stderr, "Header area list overflow\n"); + lkexit(1); +} + +/*)Function VOID lkparea(id) + * + * char * id pointer to the area name string + * + * The function lkparea() searches the linked area structures + * for a name match. If the name is not found then an area + * structure is created. An areax structure is created and + * appended to the areax structures linked to the area structure. + * The associated base area and head structure pointers are + * loaded into the areax structure. + * + * local variables: + * area * tap pointer to an area structure + * areax * taxp pointer to an areax structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * areax *axp Pointer to the current + * areax structure + * + * functions called: + * VOID * new() lksym() + * char * strcpy() c_library + * int symeq() lksym.c + * + * side effects: + * Area and/or areax structures are created. + * Failure to allocate space for created structures + * will terminate the linker. + */ + +VOID +lkparea(id) +char *id; +{ + register struct area *tap; + register struct areax *taxp; + + ap = areap; + axp = (struct areax *) new (sizeof(struct areax)); + while (ap) { + if (symeq(id, ap->a_id)) { + taxp = ap->a_axp; + while (taxp->a_axp) + taxp = taxp->a_axp; + taxp->a_axp = axp; + axp->a_bap = ap; + axp->a_bhp = hp; + return; + } + ap = ap->a_ap; + } + ap = (struct area *) new (sizeof(struct area)); + if (areap == NULL) { + areap = ap; + } else { + tap = areap; + while (tap->a_ap) + tap = tap->a_ap; + tap->a_ap = ap; + } + ap->a_axp = axp; + axp->a_bap = ap; + axp->a_bhp = hp; + strncpy(ap->a_id, id, NCPS); +} + +/*)Function VOID lnkarea() + * + * The function lnkarea() resolves all area addresses. + * The function evaluates each area structure (and all + * the associated areax structures) in sequence. The + * linking process supports four (4) possible area types: + * + * ABS/OVR - All sections (each individual areax + * section) starts at the identical base + * area address overlaying all other + * areax sections for this area. The + * size of the area is largest of the area + * sections. + * + * ABS/CON - All sections (each individual areax + * section) are concatenated with the + * first section starting at the base + * area address. The size of the area + * is the sum of the section sizes. + * + * NOTE: Multiple absolute (ABS) areas are + * never concatenated with each other, + * thus absolute area A and absolute area + * B will overlay each other if they begin + * at the same location (the default is + * always address 0 for absolute areas). + * + * REL/OVR - All sections (each individual areax + * section) starts at the identical base + * area address overlaying all other + * areax sections for this area. The + * size of the area is largest of the area + * sections. + * + * REL/CON - All sections (each individual areax + * section) are concatenated with the + * first section starting at the base + * area address. The size of the area + * is the sum of the section sizes. + * + * NOTE: Relocatable (REL) areas ae always concatenated + * with each other, thus relocatable area B + * (defined after area A) will follow + * relocatable area A independent of the + * starting address of area A. Within a + * specific area each areax section may be + * overlayed or concatenated with other + * areax sections. + * + * + * If a base address for an area is specified then the + * area will start at that address. Any relocatable + * areas defined subsequently will be concatenated to the + * previous relocatable area if it does not have a base + * address specified. + * + * The names s_ and l_ are created to + * define the starting address and length of each area. + * + * local variables: + * addr_t rloc ;current relocation address + * char temp[] ;temporary string + * struct symbol *sp ;symbol structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * + * functions called: + * int fprintf() c_library + * VOID lnksect() lkarea.c + * symbol *lkpsym() lksysm.c + * char * strncpy() c_library + * int symeq() lksysm.c + * + * side effects: + * All area and areax addresses and sizes are + * determined and saved in their respective + * structures. + */ + +/* + * Resolve all area addresses. + */ +VOID +lnkarea() +{ + register rloc; + char temp[NCPS]; + struct sym *sp; + + rloc = 0; + ap = areap; + while (ap) { + if (ap->a_flag&A_ABS) { + /* + * Absolute sections + */ + lnksect(ap); + } else { + /* + * Relocatable sections + */ + if (ap->a_addr == 0) + ap->a_addr = rloc; + lnksect(ap); + rloc = ap->a_addr + ap->a_size; + } + + /* + * Create symbols called: + * s_ the start address of the area + * l_ the length of the area + */ + + if (! symeq(ap->a_id, _abs_)) { + strncpy(temp+2,ap->a_id,NCPS-2); + *(temp+1) = '_'; + + *temp = 's'; + sp = lkpsym(temp, 1); + sp->s_addr = ap->a_addr; + sp->s_axp = NULL; + sp->s_type |= S_DEF; + + *temp = 'l'; + sp = lkpsym(temp, 1); + sp->s_addr = ap->a_size; + sp->s_axp = NULL; + sp->s_type |= S_DEF; + } + ap = ap->a_ap; + } +} + +/*)Function VOID lnksect() + * + * area * tap pointer to an area structure + * + * The function lnksect() is the function called by + * lnkarea() to resolve the areax addresses. Refer + * to the function lnkarea() for more detail. Pageing + * boundary and length errors will be reported by this + * function. + * + * local variables: + * addr_t size size of area + * addr_t addr address of area + * areax * taxp pointer to an areax structure + * + * global variables: + * int lkerr error flag + * + * functions called: + * none + * + * side effects: + * All area and areax addresses and sizes area determined + * and linked into the structures. + */ + +VOID +lnksect(tap) +register struct area *tap; +{ + register addr_t size, addr; + register struct areax *taxp; + + size = 0; + addr = tap->a_addr; + if ((tap->a_flag&A_PAG) && (addr & 0xFF)) { + fprintf(stderr, + "\n?ASlink-Warning-Paged Area %.8s Boundary Error\n", tap->a_id); + lkerr++; + } + taxp = tap->a_axp; + if (tap->a_flag&A_OVR) { + /* + * Overlayed sections + */ + while (taxp) { + taxp->a_addr = addr; + if (taxp->a_size > size) + size = taxp->a_size; + taxp = taxp->a_axp; + } + } else { + /* + * Concatenated sections + */ + while (taxp) { + taxp->a_addr = addr; + addr += taxp->a_size; + size += taxp->a_size; + taxp = taxp->a_axp; + } + } + tap->a_size = size; + if ((tap->a_flag&A_PAG) && (size > 256)) { + fprintf(stderr, + "\n?ASlink-Warning-Paged Area %.8s Length Error\n", tap->a_id); + lkerr++; + } +} diff --git a/link/z80/lkdata.c b/link/z80/lkdata.c new file mode 100644 index 00000000..18751708 --- /dev/null +++ b/link/z80/lkdata.c @@ -0,0 +1,465 @@ +/* lkdata.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkdata.c + * + * The module lkdata contains the global variables + * and structures used in the linker aslink. + */ + +/* + * Definitions for all Global Variables + */ + +char *_abs_ = { ". .ABS." }; + +int lkerr; /* Linker error flag + */ +char *ip; /* Pointer into the REL file text line in ib[] + */ +char ib[NINPUT]; /* REL file text line + */ +char *rp; /* pointer into the LST file + * text line in rb[] + */ +char rb[NINPUT]; /* LST file text line being + * address relocated + */ +int oflag; /* Output file type flag + */ +int mflag; /* Map output flag + */ +#ifdef SDK +int symflag; /* no$gmb .sym output flag + */ +#endif +int xflag; /* Map file radix type flag + */ +int pflag; /* print linker command file flag + */ +int uflag; /* Listing relocation flag + */ +int radix; /* current number conversion radix: + * 2 (binary), 8 (octal), 10 (decimal), + * 16 (hexadecimal) + */ +int line; /* current line number + */ +int page; /* current page number + */ +int lop; /* current line number on page + */ +int pass; /* linker pass number + */ +int rtcnt; /* count of elements in the + * rtval[] and rtflg[] arrays + */ +addr_t rtval[NTXT]; /* data associated with relocation + */ +int rtflg[NTXT]; /* indicates if rtval[] value is + * to be sent to the output file. + * (always set in this linker) + */ +int hilo; /* REL file byte ordering + */ +int gline; /* LST file relocation active + * for current line + */ +int gcntr; /* LST file relocation active + * counter + */ + +/* + * The structure lfile contains a pointer to a + * file specification string, the file type, and + * a link to the next lfile structure. + * + * struct lfile + * { + * struct lfile *f_flp; lfile link + * int f_type; File type + * char *f_idp; Pointer to file spec + * }; + */ +struct lfile *filep; /* The pointers (lfile *) filep, + * (lfile *) cfp, and (FILE *) sfp + * are used in conjunction with + * the routine getline() to read + * asmlnk commands from + * (1) the standard input or + * (2) or a command file + * and to read the REL files + * sequentially as defined by the + * asmlnk input commands. + * + * The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + */ +struct lfile *cfp; /* The pointer *cfp points to the + * current lfile structure + */ +struct lfile *startp;/* asmlnk startup file structure + */ +struct lfile *linkp; /* pointer to first lfile structure + * containing an input REL file + * specification + */ +struct lfile *lfp; /* pointer to current lfile structure + * being processed by parse() + */ +FILE *ofp; /* Output file handle + * for word formats + */ +FILE *mfp; /* Map output file handle + */ +FILE *rfp; /* File handle for output + * address relocated ASxxxx + * listing file + */ +FILE *sfp; /* The file handle sfp points to the + * currently open file + */ +FILE *tfp; /* File handle for input + * ASxxxx listing file + */ + +/* + * The structures of head, area, areax, and sym are created + * as the REL files are read during the first pass of the + * linker. The struct head is created upon encountering a + * H directive in the REL file. The structure contains a + * link to a link file structure (struct lfile) which describes + * the file containing the H directive, the number of data/code + * areas contained in this header segment, the number of + * symbols referenced/defined in this header segment, a pointer + * to an array of pointers to areax structures (struct areax) + * created as each A directive is read, and a pointer to an + * array of pointers to symbol structures (struct sym) for + * all referenced/defined symbols. As H directives are read + * from the REL files a linked list of head structures is + * created by placing a link to the new head structure + * in the previous head structure. + * + * struct head + * { + * struct head *h_hp; Header link + * struct lfile *h_lfile; Associated file + * int h_narea; # of areas + * struct areax **a_list; Area list + * int h_nglob; # of global symbols + * struct sym **s_list; Global symbol list + * char m_id[NCPS]; Module name + * }; + */ +struct head *headp; /* The pointer to the first + * head structure of a linked list + */ +struct head *hp; /* Pointer to the current + * head structure + */ + +/* + * A structure area is created for each 'unique' data/code + * area definition found as the REL files are read. The + * struct area contains the name of the area, a flag byte + * which contains the area attributes (REL/CON/OVR/ABS), + * an area subtype (not used in this assembler), and the + * area base address and total size which will be filled + * in at the end of the first pass through the REL files. + * As A directives are read from the REL files a linked + * list of unique area structures is created by placing a + * link to the new area structure in the previous area structure. + * + * struct area + * { + * struct area *a_ap; Area link + * struct areax *a_axp; Area extension link + * addr_t a_addr; Beginning address of area + * addr_t a_size; Total size of the area + * char a_type; Area subtype + * char a_flag; Flag byte + * char a_id[NCPS]; Name + * }; + */ +struct area *areap; /* The pointer to the first + * area structure of a linked list + */ +struct area *ap; /* Pointer to the current + * area structure + */ + +/* + * An areax structure is created for every A directive found + * while reading the REL files. The struct areax contains a + * link to the 'unique' area structure referenced by the A + * directive and to the head structure this area segment is + * a part of. The size of this area segment as read from the + * A directive is placed in the areax structure. The beginning + * address of this segment will be filled in at the end of the + * first pass through the REL files. As A directives are read + * from the REL files a linked list of areax structures is + * created for each unique area. The final areax linked + * list has at its head the 'unique' area structure linked + * to the linked areax structures (one areax structure for + * each A directive for this area). + * + * struct areax + * { + * struct areax *a_axp; Area extension link + * struct area *a_bap; Base area link + * struct head *a_bhp; Base header link + * addr_t a_addr; Beginning address of section + * addr_t a_size; Size of the area in section + * }; + */ +struct areax *axp; /* Pointer to the current + * areax structure + */ + +/* + * A sym structure is created for every unique symbol + * referenced/defined while reading the REL files. The + * struct sym contains the symbol's name, a flag value + * (not used in this linker), a symbol type denoting + * referenced/defined, and an address which is loaded + * with the relative address within the area in which + * the symbol was defined. The sym structure also + * contains a link to the area where the symbol was defined. + * The sym structures are linked into linked lists using + * the symbol link element. + * + * struct sym + * { + * struct sym *s_sp; Symbol link + * struct areax *s_axp; Symbol area link + * char s_type; Symbol subtype + * char s_flag; Flag byte + * addr_t s_addr; Address + * char s_id[NCPS]; Name + * }; + */ +struct sym *symhash[NHASH]; /* array of pointers to NHASH + * linked symbol lists + */ +/* + * The struct base contains a pointer to a + * base definition string and a link to the next + * base structure. + * + * struct base + * { + * struct base *b_base; Base link + * char *b_strp; String pointer + * }; + */ +struct base *basep; /* The pointer to the first + * base structure + */ +struct base *bsp; /* Pointer to the current + * base structure + */ + +/* + * The struct globl contains a pointer to a + * global definition string and a link to the next + * global structure. + * + * struct globl + * { + * struct globl *g_globl; Global link + * char *g_strp; String pointer + * }; + */ +struct globl *globlp;/* The pointer to the first + * globl structure + */ +struct globl *gsp; /* Pointer to the current + * globl structure + */ + +/* + * A structure sdp is created for each 'unique' paged + * area definition found as the REL files are read. + * As P directives are read from the REL files a linked + * list of unique sdp structures is created by placing a + * link to the new sdp structure in the previous area structure. + * + * struct sdp + * { + * struct area *s_area; Paged Area link + * struct areax *s_areax; Paged Area Extension Link + * addr_t s_addr; Page address offset + * }; + */ +struct sdp sdp; /* Base Page Structure */ + +/* + * The structure rerr is loaded with the information + * required to report an error during the linking + * process. The structure contains an index value + * which selects the areax structure from the header + * areax structure list, a mode value which selects + * symbol or area relocation, the base address in the + * area section, an area/symbol list index value, and + * an area/symbol offset value. + * + * struct rerr + * { + * int aindex; Linking area + * int mode; Relocation mode + * addr_t rtbase; Base address in section + * int rindex; Area/Symbol reloaction index + * addr_t rval; Area/Symbol offset value + * }; + */ +struct rerr rerr; /* Structure containing the + * linker error information + */ + +/* + * The structure lbpath is created for each library + * path specification input by the -k option. The + * lbpath structures are linked into a list using + * the next link element. + * + * struct lbpath { + * struct lbpath *next; + * char *path; + * }; + */ +struct lbpath *lbphead; /* pointer to the first + * library path structure + */ + +/* + * The structure lbname is created for all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file. The element path points to + * the path string, element libfil points to the library + * file string, and the element libspc is the concatenation + * of the valid path and libfil strings. + * + * The lbpath structures are linked into a list + * using the next link element. + * + * Each library file contains a list of object files + * that are contained in the particular library. e.g.: + * + * \iolib\termio + * \inilib\termio + * + * Only one specification per line is allowed. + * + * struct lbname { + * struct lbname *next; + * char *path; + * char *libfil; + * char *libspc; + * }; + */ +struct lbname *lbnhead; /* pointer to the first + * library name structure + */ + +/* + * The function fndsym() searches through all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file for a symbol definition. + * + * The structure lbfile is created for the first library + * object file which contains the definition for the + * specified undefined symbol. + * + * The element libspc points to the library file path specification + * and element relfil points to the object file specification string. + * The element filspc is the complete path/file specification for + * the library file to be imported into the linker. The + * file specicifation may be formed in one of two ways: + * + * (1) If the library file contained an absolute + * path/file specification then this becomes filspc. + * (i.e. C:\...) + * + * (2) If the library file contains a relative path/file + * specification then the concatenation of the path + * and this file specification becomes filspc. + * (i.e. \...) + * + * The lbpath structures are linked into a list + * using the next link element. + * + * struct lbfile { + * struct lbfile *next; + * char *libspc; + * char *relfil; + * char *filspc; + * }; + */ +struct lbfile *lbfhead; /* pointer to the first + * library file structure + */ + +/* + * array of character types, one per + * ASCII character + */ +char ctype[128] = { +/*NUL*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*BS*/ ILL, SPACE, ILL, ILL, SPACE, ILL, ILL, ILL, +/*DLE*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*CAN*/ ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, +/*SPC*/ SPACE, ETC, ETC, ETC, LETTER, BINOP, BINOP, ETC, +/*(*/ ETC, ETC, BINOP, BINOP, ETC, BINOP, LETTER, BINOP, +/*0*/ DGT2, DGT2, DGT8, DGT8, DGT8, DGT8, DGT8, DGT8, +/*8*/ DGT10, DGT10, ETC, ETC, BINOP, ETC, BINOP, ETC, +/*@*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*H*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*P*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*X*/ LETTER, LETTER, LETTER, ETC, ETC, ETC, BINOP, LETTER, +/*`*/ ETC, LTR16, LTR16, LTR16, LTR16, LTR16, LTR16, LETTER, +/*h*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*p*/ LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, +/*x*/ LETTER, LETTER, LETTER, ETC, BINOP, ETC, ETC, ETC +}; + +/* + * an array of characters which + * perform the case translation function + */ +#if CASE_SENSITIVE +#else +char ccase[128] = { +/*NUL*/ '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', +/*BS*/ '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', +/*DLE*/ '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', +/*CAN*/ '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', +/*SPC*/ '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', +/*(*/ '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', +/*0*/ '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', +/*8*/ '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', +/*@*/ '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*H*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*P*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*X*/ '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', +/*`*/ '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', +/*h*/ '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', +/*p*/ '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', +/*x*/ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177' +}; +#endif diff --git a/link/z80/lkeval.c b/link/z80/lkeval.c new file mode 100644 index 00000000..573d6c8e --- /dev/null +++ b/link/z80/lkeval.c @@ -0,0 +1,396 @@ +/* lkeval.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkeval.c + * + * The module lkeval.c contains the routines to evaluate + * arithmetic/numerical expressions. The functions in + * lkeval.c perform a recursive evaluation of the arithmetic + * expression read from the input text line. + * The expression may include binary/unary operators, brackets, + * symbols, labels, and constants in hexadecimal, decimal, octal + * and binary. Arithmetic operations are prioritized and + * evaluated by normal arithmetic conventions. + * + * lkeval.c contains the following functions: + * int digit() + * addr_t eval() + * addr_t expr() + * int oprio() + * addr_t term() + * + * lkeval.c contains no local/static variables + */ + +/*)Function addr_t eval() + * + * The function eval() evaluates a character string to a + * numerical value. + * + * local variables: + * int c character from input string + * int v value of character in current radix + * addr_t n evaluation value + * + * global variables: + * int radix current number conversion radix + * + * functions called: + * int digit() lkeval.c + * char get() lklex.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * Input test is scanned and evaluated to a + * numerical value. + */ + +addr_t +eval() +{ + register c, v; + register addr_t n; + + c = getnb(); + n = 0; + while ((v = digit(c, radix)) >= 0) { + n = n*radix + v; + c = get(); + } + unget(c); + return(n); +} + +/*)Function addr_t expr(n) + * + * int n a firewall priority; all top + * level calls (from the user) + * should be made with n set to 0. + * + * The function expr() evaluates an expression and + * returns the value. + * + * local variables: + * int c current input text character + * int p current operator priority + * addr_t v value returned by term() + * addr_t ve value returned by a + * recursive call to expr() + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * int lkerr error flag + * FILE * stderr c_library + * + * functions called: + * VOID expr() lkeval.c + * int fprintf() c_library + * int getnb() lklex.c + * int oprio() lkeval.c + * VOID term() lkeval.c + * VOID unget() lklex.c + * + * + * side effects: + * An expression is evaluated by scanning the input + * text string. + */ + +addr_t +expr (n) +{ + register c, p; + register addr_t v, ve; + + v = term(); + while (ctype[c = getnb()] & BINOP) { + if ((p = oprio(c)) <= n) + break; + if ((c == '>' || c == '<') && c != get()) { + fprintf(stderr, "Invalid expression"); + lkerr++; + return(v); + } + ve = expr(p); + if (c == '+') { + v += ve; + } else + if (c == '-') { + v -= ve; + } else { + switch (c) { + + case '*': + v *= ve; + break; + + case '/': + v /= ve; + break; + + case '&': + v &= ve; + break; + + case '|': + v |= ve; + break; + + case '%': + v %= ve; + break; + + case '^': + v ^= ve; + break; + + case '<': + v <<= ve; + break; + + case '>': + v >>= ve; + break; + } + } + } + unget(c); + return(v); +} + +/*)Function addr_t term() + * + * The function term() evaluates a single constant + * or symbol value prefaced by any unary operator + * ( +, -, ~, ', ", >, or < ). + * + * local variables: + * int c current character + * char id[] symbol name + * int n value of digit in current radix + * int r current evaluation radix + * sym * sp pointer to a sym structure + * addr_t v evaluation value + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * int lkerr error flag + * + * functions called: + * int digit() lkeval.c + * VOID expr() lkeval.c + * int fprintf() c_library + * int get() lklex.c + * VOID getid() lklex.c + * int getmap() lklex.c + * int getnb() lklex.c + * sym * lkpsym() lksym.c + * addr_t symval() lksym.c + * VOID unget() lklex.c + * + * side effects: + * An arithmetic term is evaluated by scanning input text. + */ + +addr_t +term() +{ + register c, r, n; + register addr_t v; + struct sym *sp; + char id[NCPS]; + + c = getnb(); + if (c == '#') { c = getnb(); } + if (c == '(') { + v = expr(0); + if (getnb() != ')') { + fprintf(stderr, "Missing delimiter"); + lkerr++; + } + return(v); + } + if (c == '-') { + return(-expr(100)); + } + if (c == '~') { + return(~expr(100)); + } + if (c == '\'') { + return(getmap(-1)&0377); + } + if (c == '\"') { + if (hilo) { + v = (getmap(-1)&0377)<<8; + v |= getmap(-1)&0377; + } else { + v = getmap(-1)&0377; + v |= (getmap(-1)&0377)<<8; + } + return(v); + } + if (c == '>' || c == '<') { + v = expr(100); + if (c == '>') + v >>= 8; + return(v&0377); + } + if (ctype[c] & DIGIT) { + r = 10; + if (c == '0') { + c = get(); + switch (c) { + case 'b': + case 'B': + r = 2; + c = get(); + break; + case '@': + case 'o': + case 'O': + case 'q': + case 'Q': + r = 8; + c = get(); + break; + case 'd': + case 'D': + r = 10; + c = get(); + break; + case 'h': + case 'H': + case 'x': + case 'X': + r = 16; + c = get(); + break; + default: + break; + } + } + v = 0; + while ((n = digit(c, r)) >= 0) { + v = r*v + n; + c = get(); + } + unget(c); + return(v); + } + if (ctype[c] & LETTER) { + getid(id, c); + if ((sp = lkpsym(id, 0)) == NULL) { + fprintf(stderr, "Undefined symbol %8s\n", id); + lkerr++; + return(0); + } else { + return(symval(sp)); + } + } +} + +/*)Function int digit(c, r) + * + * int c digit character + * int r current radix + * + * The function digit() returns the value of c + * in the current radix r. If the c value is not + * a number of the current radix then a -1 is returned. + * + * local variables: + * none + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * none + * + * side effects: + * none + */ + +int +digit(c, r) +register c, r; +{ + if (r == 16) { + if (ctype[c] & RAD16) { + if (c >= 'A' && c <= 'F') + return (c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + return (c - '0'); + } + } else + if (r == 10) { + if (ctype[c] & RAD10) + return (c - '0'); + } else + if (r == 8) { + if (ctype[c] & RAD8) + return (c - '0'); + } else + if (r == 2) { + if (ctype[c] & RAD2) + return (c - '0'); + } + return (-1); +} + +/*)Function int oprio(c) + * + * int c operator character + * + * The function oprio() returns a relative priority + * for all valid unary and binary operators. + * + * local variables: + * none + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +int +oprio(c) +register c; +{ + if (c == '*' || c == '/' || c == '%') + return (10); + if (c == '+' || c == '-') + return (7); + if (c == '<' || c == '>') + return (5); + if (c == '^') + return (4); + if (c == '&') + return (3); + if (c == '|') + return (1); + return (0); +} diff --git a/link/z80/lkgb.c b/link/z80/lkgb.c new file mode 100644 index 00000000..9ecac07b --- /dev/null +++ b/link/z80/lkgb.c @@ -0,0 +1,190 @@ +/* lkgb.c */ + +/* + * P. Felber + */ + +#ifdef GAMEBOY + +#include +#include +#include +#include +#include "aslink.h" + +/* Value used to fill the unused portions of the image */ +/* FFh puts less stress on a EPROM/Flash */ +#define FILLVALUE 0xFF + +#define CARTSIZE ((unsigned long)nb_rom_banks*16UL*1024UL) +#define NBSEG 8UL +#define SEGSIZE (CARTSIZE/NBSEG) + +#define ROMSIZE 0x8000UL +#define BANKSTART 0x4000UL +#define BANKSIZE 0x4000UL + +unsigned char *cart[NBSEG]; + +int nb_rom_banks; +int nb_ram_banks; +int current_rom_bank; +int mbc_type; +char cart_name[16] = ""; + +patch* patches = NULL; + +VOID gb(int in) +{ + static int first = 1; + unsigned long pos, chk; + int i; + patch *p; + + if(first) { + for(i = 0; i < NBSEG; i++) { + if((cart[i] = malloc(SEGSIZE)) == NULL) { + fprintf(stderr, "ERROR: can't allocate %dth segment of memory (%d bytes)\n", i, (int)SEGSIZE); + exit(-1); + } + memset(cart[i], FILLVALUE, SEGSIZE); + } + first = 0; + } + if(in) { + if(rtcnt > 2) { + if(hilo == 0) + pos = rtval[0] | (rtval[1]<<8); + else + pos = rtval[1] | (rtval[0]<<8); + + /* Perform some validity checks */ + if(pos >= ROMSIZE) { + fprintf(stderr, "ERROR: address overflow (addr %lx >= %lx)\n", pos, ROMSIZE); + exit(-1); + } + if(current_rom_bank >= nb_rom_banks) { + fprintf(stderr, "ERROR: bank overflow (addr %x > %x)\n", current_rom_bank, nb_rom_banks); + exit(-1); + } + if(current_rom_bank > 0 && pos < BANKSTART) { + fprintf(stderr, "ERROR: address underflow (addr %lx < %lx)\n", pos, BANKSTART); + exit(-1); + } + if(nb_rom_banks == 2 && current_rom_bank > 0) { + fprintf(stderr, "ERROR: only 1 32kB segment with 2 bank\n"); + exit(-1); + } + if(current_rom_bank > 1) + pos += (current_rom_bank-1)*BANKSIZE; + for(i = 2; i < rtcnt; i++) { + if(rtflg[i]) { + if(pos < CARTSIZE) { + if(cart[pos/SEGSIZE][pos%SEGSIZE] != FILLVALUE) + fprintf(stderr, "WARNING: possibly wrote twice at addr %lx (%02X->%02X)\n", pos, rtval[i], cart[pos/SEGSIZE][pos%SEGSIZE]); + cart[pos/SEGSIZE][pos%SEGSIZE] = rtval[i]; + } else { + fprintf(stderr, "ERROR: cartridge size overflow (addr %lx >= %lx)\n", pos, CARTSIZE); + exit(-1); + } + pos++; + } + } + } + } else { + /* EOF */ + if(cart_name[0] == 0 && linkp->f_idp != NULL) { + for(i = strlen(linkp->f_idp); + i > 0 && (isalnum(linkp->f_idp[i-1]) || linkp->f_idp[i-1] == '.'); + i--) + ; + for(pos = 0; pos < 16 && linkp->f_idp[i] != '.'; pos++, i++) + cart_name[pos] = toupper(linkp->f_idp[i]); + if(pos < 16) + cart_name[pos] = 0; + } + for(pos = 0x0134, i = 0; + pos < 0x0144 && cart_name[i]; + pos++, i++) + cart[pos/SEGSIZE][pos%SEGSIZE] = cart_name[i]; + for(; pos < 0x0144; pos++) + cart[pos/SEGSIZE][pos%SEGSIZE] = 0; + cart[0x147/SEGSIZE][0x147%SEGSIZE] = mbc_type; + switch(nb_rom_banks) { + case 2: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 0; + break; + case 4: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 1; + break; + case 8: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 2; + break; + case 16: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 3; + break; + case 32: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 4; + break; + case 64: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 5; + break; + case 128: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 6; + break; + case 256: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 7; + break; + case 512: + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 8; + break; + default: + fprintf(stderr, "WARNING: unsupported number of ROM banks (%d)\n", nb_rom_banks); + cart[0x148/SEGSIZE][0x148%SEGSIZE] = 0; + break; + } + switch(nb_ram_banks) { + case 0: + cart[0x149/SEGSIZE][0x149%SEGSIZE] = 0; + break; + case 1: + cart[0x149/SEGSIZE][0x149%SEGSIZE] = 2; + break; + case 4: + cart[0x149/SEGSIZE][0x149%SEGSIZE] = 3; + break; + case 16: + cart[0x149/SEGSIZE][0x149%SEGSIZE] = 4; + break; + default: + fprintf(stderr, "WARNING: unsupported number of RAM banks (%d)\n", nb_ram_banks); + cart[0x149/SEGSIZE][0x149%SEGSIZE] = 0; + break; + } + + /* Patch before calculating the checksum */ + if(patches) + for(p = patches; p; p = p->next) + cart[p->addr/SEGSIZE][p->addr%SEGSIZE] = p->value; + + /* Update complement checksum */ + chk = 0; + for(pos = 0x0134; pos < 0x014D; pos++) + chk += cart[pos/SEGSIZE][pos%SEGSIZE]; + cart[0x014D/SEGSIZE][0x014D%SEGSIZE] = 0xE7 - (chk&0xFF); + /* Update checksum */ + chk = 0; + cart[0x014E/SEGSIZE][0x014E%SEGSIZE] = 0; + cart[0x014F/SEGSIZE][0x014F%SEGSIZE] = 0; + for(i = 0; i < NBSEG; i++) + for(pos = 0; pos < SEGSIZE; pos++) + chk += cart[i][pos]; + cart[0x014E/SEGSIZE][0x014E%SEGSIZE] = (chk>>8)&0xFF; + cart[0x014F/SEGSIZE][0x014F%SEGSIZE] = chk&0xFF; + + for(i = 0; i < NBSEG; i++) + fwrite(cart[i], 1, SEGSIZE, ofp); + } +} + +#endif /* GAMEBOY */ diff --git a/link/z80/lkgg.c b/link/z80/lkgg.c new file mode 100644 index 00000000..d8248d6e --- /dev/null +++ b/link/z80/lkgg.c @@ -0,0 +1,79 @@ +/* lkgg.c */ + +/* + * P. Felber + */ + +#ifdef GAMEGEAR + +#include +#include +#include +#include +#include +#include "aslink.h" + +#define CARTSIZE ((unsigned long)4*16UL*1024UL) +#define NBSEG 8UL +#define SEGSIZE (CARTSIZE/NBSEG) + +unsigned char *cart[NBSEG]; + +#define ROMSIZE 0x10000UL +#define BANKSIZE 0x4000UL + +int current_rom_bank; + +VOID gg(int in) +{ + static int first = 1; + unsigned long pos; + int i; + + if(first) { + for(i = 0; i < NBSEG; i++) { + if((cart[i] = malloc(SEGSIZE)) == NULL) { + fprintf(stderr, "ERROR: can't allocate %dth segment of memory (%d bytes)\n", i, (int)SEGSIZE); + exit(-1); + } + memset(cart[i], 0, SEGSIZE); + } + first = 0; + } + if(in) { + if(rtcnt > 2) { + if(hilo == 0) + pos = rtval[0] | (rtval[1]<<8); + else + pos = rtval[1] | (rtval[0]<<8); + + /* Perform some validity checks */ + if(pos >= ROMSIZE) { + fprintf(stderr, "ERROR: address overflow (addr %lx >= %lx)\n", pos, ROMSIZE); + exit(-1); + } + if(current_rom_bank > 1) + pos += (current_rom_bank-1)*BANKSIZE; + for(i = 2; i < rtcnt; i++) { + if(rtflg[i]) { + if(pos < CARTSIZE) { + if(cart[pos/SEGSIZE][pos%SEGSIZE] != 0) + fprintf(stderr, "WARNING: wrote twice at addr %lx (%02X->%02X)\n", pos, rtval[i], cart[pos/SEGSIZE][pos%SEGSIZE]); + cart[pos/SEGSIZE][pos%SEGSIZE] = rtval[i]; + } else { + fprintf(stderr, "ERROR: cartridge size overflow (addr %lx >= %lx)\n", pos, CARTSIZE); + exit(-1); + } + pos++; + } + } + } + } else { + /* EOF */ + /* Patch before calculating the checksum */ + for(i = 0; i < NBSEG; i++) + fwrite(cart[i], 1, SEGSIZE, ofp); + } +} + +#endif /* GAMEGEAR */ diff --git a/link/z80/lkhead.c b/link/z80/lkhead.c new file mode 100644 index 00000000..75c4f3d5 --- /dev/null +++ b/link/z80/lkhead.c @@ -0,0 +1,154 @@ +/* lkhead.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*Module lkhead.c + * + * The module lkhead.c contains the function newhead() which + * creates a head structure and the function module() which + * loads the module name into the current head structure. + * + * lkhead.c contains the following functions: + * VOID newhead() + * VOID module() + * + * lkhead.c contains no local variables. + */ + +/*)Function VOID newhead() + * + * The function newhead() creates a head structure. All head + * structures are linked to form a linked list of head structures + * with the current head structure at the tail of the list. + * + * local variables: + * int i evaluation value + * head * thp temporary pointer + * to a header structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * lfile *cfp The pointer *cfp points to the + * current lfile structure + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * + * functions called: + * addr_t expr() lkeval.c + * VOID * new() lksym.c + * VOID lkparea() lkarea.c + * + * side effects: + * A new head structure is created and linked to any + * existing linked head structure. The head structure + * parameters of file handle, number of areas, and number + * of global symbols are loaded into the structure. + * The default area "_abs_" is created when the first + * head structure is created and an areax structure is + * created for every head structure called. + */ + +/* + * Create a new header entry. + * + * H n areas n global symbols + * | | + * | `---- hp->h_nglob + * `------------ hp->h_narea + * + */ +VOID +newhead() +{ + register i; + struct head *thp; + + hp = (struct head *) new (sizeof(struct head)); + if (headp == NULL) { + headp = hp; + } else { + thp = headp; + while (thp->h_hp) + thp = thp->h_hp; + thp->h_hp = hp; + } + /* + * Set file pointer + */ + hp->h_lfile = cfp; + /* + * Evaluate and build Area pointer list + */ + i = hp->h_narea = eval(); + if (i) + hp->a_list = (struct areax **) new (i*sizeof(struct areax *)); + /* + * Evaluate and build Global symbol pointer list + */ + skip(-1); + i = hp->h_nglob = eval(); + if (i) + hp->s_list = (struct sym **) new (i*sizeof(struct sym *)); + /* + * Setup Absolute DEF linkage. + */ + lkparea(_abs_); + ap->a_flag = A_ABS|A_OVR; +} + +/*)Function VOID module() + * + * The function module() copies the module name into + * the current head structure. + * + * local variables: + * char id[] module id string + * + * global variables: + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * int lkerr error flag + * FILE * stderr c_library + * + * functions called: + * int fprintf() c_library + * VOID getid() lklex.c + * char * strncpy() c_library + * + * side effects: + * The module name is copied into the head structure. + */ + +/* + * Module Name + */ +VOID +module() +{ + char id[NCPS]; + + if (headp) { + getid(id, -1); + strncpy(hp->m_id, id, NCPS); + } else { + fprintf(stderr, "No header defined\n"); + lkerr++; + } +} diff --git a/link/z80/lkihx.c b/link/z80/lkihx.c new file mode 100644 index 00000000..d849c165 --- /dev/null +++ b/link/z80/lkihx.c @@ -0,0 +1,134 @@ +/* lkihx.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkihx.c + * + * The module lkihx.c contains the function to + * output the relocated object code in the + * Intel Hex format. + * + * lkihx.c contains the following function: + * VOID ihx(i) + * + * lkihx.c contains no local variables. + */ + +/*Intel Hex Format + * Record Mark Field - This field signifies the start of a + * record, and consists of an ascii colon + * (:). + * + * Record Length Field - This field consists of two ascii + * characters which indicate the number of + * data bytes in this record. The + * characters are the result of converting + * the number of bytes in binary to two + * ascii characters, high digit first. An + * End of File record contains two ascii + * zeros in this field. + * + * Load Address Field - This field consists of the four ascii + * characters which result from converting + * the the binary value of the address in + * which to begin loading this record. The + * order is as follows: + * + * High digit of high byte of address. + * Low digit of high byte of address. + * High digit of low byte of address. + * Low digit of low byte of address. + * + * In an End of File record this field con- + * sists of either four ascii zeros or the + * program entry address. Currently the + * entry address option is not supported. + * + * Record Type Field - This field identifies the record type, + * which is either 0 for data records or 1 + * for an End of File record. It consists + * of two ascii characters, with the high + * digit of the record type first, followed + * by the low digit of the record type. + * + * Data Field - This field consists of the actual data, + * converted to two ascii characters, high + * digit first. There are no data bytes in + * the End of File record. + * + * Checksum Field - The checksum field is the 8 bit binary + * sum of the record length field, the load + * address field, the record type field, + * and the data field. This sum is then + * negated (2's complement) and converted + * to two ascii characters, high digit + * first. + */ + +/*)Function ihx(i) + * + * int i 0 - process data + * 1 - end of data + * + * The function ihx() outputs the relocated data + * in the standard Intel Hex format. + * + * local variables: + * addr_t chksum byte checksum + * + * global variables: + * int hilo byte order + * FILE * ofp output file handle + * int rtcnt count of data words + * int rtflg[] output the data flag + * addr_t rtval[] relocated data + * + * functions called: + * int fprintf() c_library + * + * side effects: + * The data is output to the file defined by ofp. + */ + +VOID +ihx(i) +{ + register addr_t chksum; + + if (i) { + if (hilo == 0) { + chksum = rtval[0]; + rtval[0] = rtval[1]; + rtval[1] = chksum; + } + for (i = 0, chksum = -2; i < rtcnt; i++) { + if (rtflg[i]) + chksum++; + } + fprintf(ofp, ":%02X", chksum); + for (i = 0; i < rtcnt ; i++) { + if (rtflg[i]) { + fprintf(ofp, "%02X", rtval[i]); + chksum += rtval[i]; + } + if (i == 1) { + fprintf(ofp, "00"); + } + } + fprintf(ofp, "%02X\n", (-chksum) & 0xff); + } else { + fprintf(ofp, ":00000001FF\n"); + } +} diff --git a/link/z80/lklex.c b/link/z80/lklex.c new file mode 100644 index 00000000..8863809f --- /dev/null +++ b/link/z80/lklex.c @@ -0,0 +1,569 @@ +/* lklex.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber, M. Hope + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lklex.c + * + * The module lklex.c contains the general lexical analysis + * functions used to scan the text lines from the .rel files. + * + * lklex.c contains the fllowing functions: + * char endline() + * char get() + * VOID getfid() + * VOID getid() + * int getline() + * int getmap() + * char getnb() + * int more() + * VOID skip() + * VOID unget() + * + * lklex.c contains no local variables. + */ + +/*)Function VOID getid(id,c) + * + * char * id a pointer to a string of + * maximum length NCPS + * int c mode flag + * >=0 this is first character to + * copy to the string buffer + * <0 skip white space + * + * The function getid() scans the current input text line + * from the current position copying the next LETTER | DIGIT string + * into the external string buffer (id). The string ends when a non + * LETTER or DIGIT character is found. The maximum number of + * characters copied is NCPS. If the input string is larger than + * NCPS characters then the string is truncated, if the input string + * is shorter than NCPS characters then the string is NULL filled. + * If the mode argument (c) is >=0 then (c) is the first character + * copied to the string buffer, if (c) is <0 then intervening white + * space (SPACES and TABS) are skipped. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() lklex.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * use of getnb(), get(), and unget() updates the + * global pointer ip the position in the current + * input text line. + */ + +VOID +getid(id, c) +register c; +char *id; +{ + register char *p; + + if (c < 0) { + c = getnb(); + } + p = id; + do { + if (p < &id[NCPS]) + *p++ = c; + } while (ctype[c=get()] & (LETTER|DIGIT)); + unget(c); + while (p < &id[NCPS]) + *p++ = 0; +} + +/*)Function VOID getfid(fid,c) + * + * char * str a pointer to a string of + * maximum length FILSPC + * int c this is first character to + * copy to the string buffer + * + * The function getfid() scans the current input text line + * from the current position copying the next string + * into the external string buffer (str). The string ends when a + * non SPACE type character is found. The maximum number of + * characters copied is FILSPC. If the input string is larger than + * FILSPC characters then the string is truncated, if the input string + * is shorter than FILSPC characters then the string is NULL filled. + * + * local variables: + * char * p pointer to external string buffer + * int c current character value + * + * global variables: + * char ctype[] a character array which defines the + * type of character being processed. + * This index is the character + * being processed. + * + * called functions: + * char get() lklex.c + * + * side effects: + * use of get() updates the global pointer ip + * the position in the current input text line. + */ + +VOID +getfid(str, c) +register c; +char *str; +{ + register char *p; + + p = str; + do { + if (p < &str[FILSPC-1]) + *p++ = c; + c = get(); +#ifdef SDK + } while (c); +#else /* SDK */ + } while (c && (ctype[c] != SPACE)); +#endif /* SDK */ + while (p < &str[FILSPC]) + *p++ = 0; +} + +/*)Function char getnb() + * + * The function getnb() scans the current input text + * line returning the first character not a SPACE or TAB. + * + * local variables: + * int c current character from input + * + * global variables: + * none + * + * called functions: + * char get() lklex.c + * + * side effects: + * use of get() updates the global pointer ip, the position + * in the current input text line + */ + +char +getnb() +{ + register c; + + while ((c=get())==' ' || c=='\t') + ; + return (c); +} + +/*)Function VOID skip() + * + * The function skip() scans the input text skipping all + * letters and digits. + * + * local variables: + * none + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * + * functions called: + * char get() lklex.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * Input letters and digits are skipped. + */ + +VOID +skip(c) +register c; +{ + if (c < 0) + c = getnb(); + while (ctype[c=get()] & (LETTER|DIGIT)) { ; } + unget(c); +} + +/*)Function char get() + * + * The function get() returns the next character in the + * input text line, at the end of the line a + * NULL character is returned. + * + * local variables: + * int c current character from + * input text line + * + * global variables: + * char * ip pointer into the current + * input text line + * + * called functions: + * none + * + * side effects: + * updates ip to the next character position in the + * input text line. If ip is at the end of the + * line, ip is not updated. + */ + +char +get() +{ + register c; + + if ((c = *ip) != 0) + ++ip; + return (c); +} + +/*)Function VOID unget(c) + * + * int c value of last character + * read from input text line + * + * If (c) is not a NULL character then the global pointer ip + * is updated to point to the preceeding character in the + * input text line. + * + * NOTE: This function does not push the character (c) + * back into the input text line, only + * the pointer ip is changed. + * + * local variables: + * int c last character read + * from input text line + * + * global variables: + * char * ip position into the current + * input text line + * + * called functions: + * none + * + * side effects: + * ip decremented by 1 character position + */ + +VOID +unget(c) +{ + if (c != 0) + --ip; +} + +/*)Function int getmap(d) + * + * int d value to compare with the + * input text line character + * + * The function getmap() converts the 'C' style characters \b, \f, + * \n, \r, and \t to their equivalent ascii values and also + * converts 'C' style octal constants '\123' to their equivalent + * numeric values. If the first character is equivalent to (d) then + * a (-1) is returned, if the end of the line is detected then + * a 'q' error terminates the parse for this line, or if the first + * character is not a \ then the character value is returned. + * + * local variables: + * int c value of character + * from input text line + * int n looping counter + * int v current value of numeric conversion + * + * global variables: + * none + * + * called functions: + * char get() lklex.c + * VOID unget() lklex.c + * + * side effects: + * use of get() updates the global pointer ip the position + * in the current input text line + */ + +int +getmap(d) +{ + register c, n, v; + + if ((c = get()) == '\0') + return (-1); + if (c == d) + return (-1); + if (c == '\\') { + c = get(); + switch (c) { + + case 'b': + c = '\b'; + break; + + case 'f': + c = '\f'; + break; + + case 'n': + c = '\n'; + break; + + case 'r': + c = '\r'; + break; + + case 't': + c = '\t'; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + n = 0; + v = 0; + while (++n<=3 && c>='0' && c<='7') { + v = (v<<3) + c - '0'; + c = get(); + } + unget(c); + c = v; + break; + } + } + return (c); +} + +/*)Function int getline() + * + * The function getline() reads a line of input text from a + * .rel source text file, a .lnk command file or from stdin. + * Lines of text are processed from a single .lnk file or + * multiple .rel files until all files have been read. + * The input text line is copied into the global string ib[] + * and converted to a NULL terminated string. The function + * getline() returns a (1) after succesfully reading a line + * or a (0) if all files have been read. + * This function also opens each input .lst file and output + * .rst file as each .rel file is processed. + * + * local variables: + * int i string length + * int ftype file type + * char * fid file name + * + * global variables: + * lfile *cfp The pointer *cfp points to the + * current lfile structure + * lfile *filep The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + * int gline get a line from the LST file + * to translate for the RST file + * char ib[NINPUT] REL file text line + * int pass linker pass number + * int pflag print linker command file flag + * FILE *rfp The file handle to the current + * output RST file + * FILE *sfp The file handle sfp points to the + * currently open file + * FILE * stdin c_library + * FILE * stdout c_library + * FILE *tfp The file handle to the current + * LST file being scanned + * int uflag update listing flag + * + * called functions: + * FILE * afile() lkmain.c + * int fclose() c_library + * char * fgets() c_library + * int fprintf() c_library + * VOID lkulist() lklist.c + * VOID lkexit() lkmain.c + * int strlen() c_library + * + * side effects: + * The input stream is scanned. The .rel files will be + * opened and closed sequentially scanning each in turn. + */ + +int +getline() +{ + register i, ftype; + register char *fid; + +loop: if (pflag && cfp && cfp->f_type == F_STD) + fprintf(stdout, "ASlink >> "); + +#ifdef SDK + if(cfp == NULL && filep != NULL && filep->f_type == F_CMD) { + char **argv = (char **)filep->f_idp; + if(argv[0] != NULL && strlen(argv[0]) < sizeof ib) { + strcpy(ib, argv[0]); + filep->f_idp = (char *)&argv[1]; + } else { + filep = NULL; + return(0); + } + } else +#endif /* SDK */ + if (sfp == NULL || fgets(ib, sizeof ib, sfp) == NULL) { + if (sfp) { + fclose(sfp); +#ifdef SDK + sfp = NULL; +#endif /* SDK */ + lkulist(0); + } + if (cfp == NULL) { + cfp = filep; + } else { + cfp = cfp->f_flp; + } + if (cfp) { + ftype = cfp->f_type; + fid = cfp->f_idp; + if (ftype == F_STD) { + sfp = stdin; + } else + if (ftype == F_LNK) { +#ifdef SDK + sfp = afile(fid, "lnk", 0); +#else /* SDK */ + sfp = afile(fid, "LNK", 0); +#endif /* SDK */ + } else + if (ftype == F_REL) { +#ifdef SDK + sfp = afile(fid, "", 0); + if (uflag && pass != 0) { + if ((tfp = afile(fid, "lst", 0)) != NULL) { + if ((rfp = afile(fid, "rst", 1)) == NULL) { +#else /* SDK */ + sfp = afile(fid, "REL", 0); + if (uflag && pass != 0) { + if ((tfp = afile(fid, "LST", 0)) != NULL) { + if ((rfp = afile(fid, "RST", 1)) == NULL) { +#endif /* SDK */ + fclose(tfp); + tfp = NULL; + } + } + } + gline = 1; + } else { + fprintf(stderr, "Invalid file type\n"); + lkexit(1); + } + if (sfp == NULL) { + lkexit(1); + } + goto loop; + } else { + filep = NULL; + return(0); + } + } + i = strlen(ib) - 1; + if (ib[i] == '\n') + ib[i] = 0; + return (1); +} + +/*)Function int more() + * + * The function more() scans the input text line + * skipping white space (SPACES and TABS) and returns a (0) + * if the end of the line or a comment delimeter (;) is found, + * or a (1) if their are additional characters in the line. + * + * local variables: + * int c next character from + * the input text line + * + * global variables: + * none + * + * called functions: + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * use of getnb() and unget() updates the global pointer ip + * the position in the current input text line + */ + +int +more() +{ + register c; + + c = getnb(); + unget(c); + return( (c == '\0' || c == ';') ? 0 : 1 ); +} + +/*)Function char endline() + * + * The function endline() scans the input text line + * skipping white space (SPACES and TABS) and returns the next + * character or a (0) if the end of the line is found or a + * comment delimiter (;) is found. + * + * local variables: + * int c next character from + * the input text line + * + * global variables: + * none + * + * called functions: + * char getnb() lklex.c + * + * side effects: + * Use of getnb() updates the global pointer ip the + * position in the current input text line. + */ + +char +endline() +{ + register c; + + c = getnb(); + return( (c == '\0' || c == ';') ? 0 : c ); +} diff --git a/link/z80/lklibr.c b/link/z80/lklibr.c new file mode 100644 index 00000000..b6cd1bd2 --- /dev/null +++ b/link/z80/lklibr.c @@ -0,0 +1,812 @@ +/* lklibr.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + * + * With contributions for the + * object libraries from + * Ken Hornstein + * kenh@cmf.nrl.navy.mil + * + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lklibr.c + * + * The module lklibr.c contains the functions which + * (1) specify the path(s) to library files [.LIB] + * (2) specify the library file(s) [.LIB] to search + * (3) search the library files for specific symbols + * and link the module containing this symbol + * + * lklibr.c contains the following functions: + * VOID addpath() + * VOID addlib() + * VOID addfile() + * VOID search() + * VOID fndsym() + * VOID library() + * VOID loadfile() + * + */ + +#ifdef INDEXLIB +typedef struct slibrarysymbol mlibrarysymbol; +typedef struct slibrarysymbol *pmlibrarysymbol; + +struct slibrarysymbol { + char name[40]; + pmlibrarysymbol next; +}; + +typedef struct slibraryfile mlibraryfile; +typedef struct slibraryfile *pmlibraryfile; + +struct slibraryfile { + int loaded; + char *libspc; + char *str; + char relfil[80]; + char filename[80]; + pmlibrarysymbol symbols; + pmlibraryfile next; +}; + +int buildlibraryindex(); +#endif /* INDEXLIB */ + +/*)Function VOID addpath() + * + * The function addpath() creates a linked structure containing + * the paths to various object module library files. + * + * local variables: + * lbpath *lbph pointer to new path structure + * lbpath *lbp temporary pointer + * + * global variables: + * lbpath *lbphead The pointer to the first + * path structure + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * An lbpath structure may be created. + */ + +VOID +addpath() +{ + struct lbpath *lbph, *lbp; + + lbph = (struct lbpath *) new (sizeof(struct lbpath)); + if (lbphead == NULL) { + lbphead = lbph; + } else { + lbp = lbphead; + while (lbp->next) + lbp = lbp->next; + lbp->next = lbph; + } + unget(getnb()); + lbph->path = (char *) new (strlen(ip)+1); + strcpy(lbph->path, ip); +} + +/*)Function VOID addlib() + * + * The function addlib() tests for the existance of a + * library path structure to determine the method of + * adding this library file to the library search structure. + * + * This function calls the function addfile() to actually + * add the library file to the search list. + * + * local variables: + * lbpath *lbph pointer to path structure + * + * global variables: + * lbpath *lbphead The pointer to the first + * path structure + * + * functions called: + * VOID addfile() lklibr.c + * char getnb() lklex.c + * VOID unget() lklex.c + * + * side effects: + * The function addfile() may add the file to + * the library search list. + */ + +VOID +addlib() +{ + struct lbpath *lbph; + + unget(getnb()); + + if (lbphead == NULL) { + addfile(NULL,ip); + return; + } + for (lbph=lbphead; lbph; lbph=lbph->next) { + addfile(lbph->path,ip); + } +} + +/*)Function VOID addfile(path,libfil) + * + * char *path library path specification + * char *libfil library file specification + * + * The function addfile() searches for the library file + * by concatenating the path and libfil specifications. + * if the library is found, an lbname structure is created + * and linked to any previously defined structures. This + * linked list is used by the function fndsym() to attempt + * to find any undefined symbols. + * + * The function does not give report an error on invalid + * path / file specifications or if the file is not found. + * + * local variables: + * lbname *lbnh pointer to new name structure + * lbname *lbn temporary pointer + * + * global variables: + * lbname *lbnhead The pointer to the first + * path structure + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * An lbname structure may be created. + */ + +VOID +addfile(path,libfil) +char *path; +char *libfil; +{ + FILE *fp; + char *str; + struct lbname *lbnh, *lbn; + + if ((path != NULL) && (strchr(libfil,':') == NULL)){ + str = (char *) new (strlen(path) + strlen(libfil) + 6); + strcpy(str,path); +#ifdef OTHERSYSTEM +#ifdef SDK +#ifdef UNIX + if (str[strlen(str)-1] != '/') { + strcat(str,"/"); +#else /* UNIX */ + if (str[strlen(str)-1] != '\\') { + strcat(str,"\\"); +#endif /* UNIX */ +#else /* SDK */ + if (str[strlen(str)-1] != '\\') { + strcat(str,"\\"); +#endif /* SDK */ + } +#endif + } else { + str = (char *) new (strlen(libfil) + 5); + } +#ifdef OTHERSYSTEM +#ifdef SDK +#ifdef UNIX + if (libfil[0] == '/') { libfil++; } +#else /* UNIX */ + if (libfil[0] == '\\') { libfil++; } +#endif /* UNIX */ +#else /* SDK */ + if (libfil[0] == '\\') { libfil++; } +#endif /* SDK */ +#endif + strcat(str,libfil); + if(strchr(str,FSEPX) == NULL) { + sprintf(&str[strlen(str)], "%clib", FSEPX); + } + if ((fp = fopen(str, "r")) != NULL) { + fclose(fp); + lbnh = (struct lbname *) new (sizeof(struct lbname)); + if (lbnhead == NULL) { + lbnhead = lbnh; + } else { + lbn = lbnhead; + while (lbn->next) + lbn = lbn->next; + lbn->next = lbnh; + } + if ((path != NULL) && (strchr(libfil,':') == NULL)){ + lbnh->path = path; + } + lbnh->libfil = (char *) new (strlen(libfil) + 1); + strcpy(lbnh->libfil,libfil); + lbnh->libspc = str; + } else { + free(str); + } +} + +/*)Function VOID search() + * + * The function search() looks through all the symbol tables + * at the end of pass 1. If any undefined symbols are found + * then the function fndsym() is called. Function fndsym() + * searches any specified library files to automagically + * import the object modules containing the needed symbol. + * + * After a symbol is found and imported by the function + * fndsym() the symbol tables are again searched. The + * symbol tables are search until no more symbols can be + * resolved within the library files. This ensures that + * back references from one library module to another are + * also resolved. + * + * local variables: + * int i temporary counter + * sym *sp pointer to a symbol structure + * int symfnd found a symbol flag + * + * global variables: + * sym *symhash[] array of pointers to symbol tables + * + * functions called: + * int fndsym() lklibr.c + * + * side effects: + * If a symbol is found then the library object module + * containing the symbol will be imported and linked. + */ + +VOID +search() +{ + register struct sym *sp; + register i,symfnd; + + /* + * Look for undefined symbols. Keep + * searching until no more symbols are resolved. + */ + symfnd = 1; + while (symfnd) { + symfnd = 0; + /* + * Look through all the symbols + */ + for (i=0; is_type & S_DEF) == 0) { + if (fndsym(sp->s_id)) { + symfnd++; + } + } + sp = sp->s_sp; + } + } + } +} + + +/*)Function VOID fndsym(name) + * + * char *name symbol name to find + * + * The function fndsym() searches through all combinations of the + * library path specifications (input by the -k option) and the + * library file specifications (input by the -l option) that + * lead to an existing file. + * + * The file specicifation may be formed in one of two ways: + * + * (1) If the library file contained an absolute + * path/file specification then this becomes filspc. + * (i.e. C:\...) + * + * (2) If the library file contains a relative path/file + * specification then the concatenation of the path + * and this file specification becomes filspc. + * (i.e. \...) + * + * The structure lbfile is created for the first library + * object file which contains the definition for the + * specified undefined symbol. + * + * If the library file [.LIB] contains file specifications for + * non existant files, no errors are returned. + * + * local variables: + * char buf[] [.REL] file input line + * char c [.REL] file input character + * FILE *fp file handle for object file + * lbfile *lbf temporary pointer + * lbfile *lbfh pointer to lbfile structure + * FILE *libfp file handle for library file + * lbname *lbnh pointer to lbname structure + * char *path file specification path + * char relfil[] [.REL] file specification + * char *str combined path and file specification + * char symname[] [.REL] file symbol string + * + * global variables: + * lbname *lbnhead The pointer to the first + * name structure + * lbfile *lbfhead The pointer to the first + * file structure + * + * functions called: + * int fclose() c_library + * int fgets() c_library + * FILE *fopen() c_library + * VOID free() c_library + * char getnb() lklex.c + * VOID lkexit() lkmain.c + * VOID loadfile() lklibr.c + * VOID * new() lksym.c + * char * sprintf() c_library + * int sscanf() c_library + * char * strcat() c_library + * char * strchr() c_library + * char * strcpy() c_library + * int strlen() c_library + * int strncmp() c_library + * VOID unget() lklex.c + * + * side effects: + * If the symbol is found then a new lbfile structure + * is created and added to the linked list of lbfile + * structures. The file containing the found symbol + * is linked. + */ + +#ifdef INDEXLIB + +/* First entry in the library object symbol cache */ +mlibraryfile libr = { + "", NULL, NULL +}; + +int fndsym( char *name ) +{ + struct lbfile *lbfh, *lbf; + pmlibraryfile ThisLibr; + pmlibrarysymbol ThisSym = NULL; + + /* Build the index if this is the first call to fndsym */ + if (libr.next==NULL) + buildlibraryindex(); + + /* Iterate through all library object files */ + ThisLibr = libr.next; + while (ThisLibr) { + + /* Iterate through all symbols in an object file */ + ThisSym = ThisLibr->symbols->next; + + while (ThisSym) { + if (!strcmp(ThisSym->name, name)) { + if (!ThisLibr->loaded) { + /* Object file is not loaded - add it to the list */ + lbfh = (struct lbfile *) new (sizeof(struct lbfile)); + if (lbfhead == NULL) { + lbfhead = lbfh; + } else { + lbf = lbfhead; + while (lbf->next) + lbf = lbf->next; + lbf->next = lbfh; + } + lbfh->libspc = ThisLibr->libspc; + lbfh->filspc = ThisLibr->str; + lbfh->relfil = (char *) new (strlen(ThisLibr->relfil) + 1); + strcpy(lbfh->relfil,ThisLibr->relfil); + loadfile(lbfh->filspc); + ThisLibr->loaded=1; + } + return (1); /* Found the symbol, return */ + } + ThisSym=ThisSym->next; /* Next sym in library */ + } + ThisLibr=ThisLibr->next; /* Next library in list */ + } + return 0; /* Failure - symbol not found in any library */ +}; + +/* buildlibraryindex - build an in-memory cache of the symbols contained in + * the libraries + */ + +int buildlibraryindex() +{ + FILE *libfp, *fp; + struct lbname *lbnh; + char relfil[NINPUT+2], *str, *path; + char buf[NINPUT+2], c; + char symname[NINPUT+2]; + pmlibraryfile This; + pmlibrarysymbol ThisSym; + + This=&libr; + + /* Iterate through all library files */ +/*1*/ for (lbnh=lbnhead; lbnh; lbnh=lbnh->next) { + libfp = fopen( lbnh->libspc, "r" ); + if (libfp) { + path=lbnh->path; + + /* + * Read in a line from the library file. + * This is the relative file specification + * for a .REL file in this library. + */ + +/*2*/ while (fgets(relfil, NINPUT, libfp) != NULL) { + relfil[NINPUT+1] = '\0'; + relfil[strlen(relfil) - 1] = '\0'; + if (path != NULL) { + str = (char *)malloc(strlen(path)+strlen(relfil)+6); + strcpy(str,path); +#ifdef OTHERSYSTEM +#ifdef SDK +#ifdef UNIX + if (str[strlen(str)-1] != '/') { + strcat(str,"/"); +#else /* UNIX */ + if (str[strlen(str)-1] != '\\') { + strcat(str,"\\"); +#endif /* UNIX */ +#else /* SDK */ + if (str[strlen(str)-1] != '\\') { + strcat(str,"\\"); +#endif /* SDK */ + } +#endif + } else { + str = (char *)malloc(strlen(relfil) + 5); + } +#ifdef SDK +#ifdef UNIX + if (relfil[0] == '/') { +#else /* UNIX */ + if (relfil[0] == '\\') { +#endif /* UNIX */ +#else /* SDK */ + if (relfil[0] == '\\') { +#endif /* SDK */ + strcat(str,relfil+1); + } else { + strcat(str,relfil); + } + if(strchr(str,FSEPX) == NULL) { +#ifdef SDK + sprintf(&str[strlen(str)], "%co", FSEPX); +#else /* SDK */ + sprintf(&str[strlen(str)], "%crel", FSEPX); +#endif /* SDK */ + } +/*3*/ if ((fp = fopen(str, "r")) != NULL) { + + /* Opened OK - create a new libraryfile object for it */ + This->next = (pmlibraryfile)malloc( sizeof( mlibraryfile )); + if (This->next == NULL) { + printf("panic: cant allocate memory.\n"); + exit(-1); + } + + This=This->next; + This->next = NULL; + This->loaded=-1; + + strcpy( This->filename, str ); + + ThisSym = This->symbols = (pmlibrarysymbol)malloc( sizeof(mlibrarysymbol)); + ThisSym->next = NULL; + + /* + * Read in the object file. Look for lines that + * begin with "S" and end with "D". These are + * symbol table definitions. If we find one, see + * if it is our symbol. Make sure we only read in + * our object file and don't go into the next one. + */ + +/*4*/ while (fgets(buf, NINPUT, fp) != NULL) { + + buf[NINPUT+1] = '\0'; + buf[strlen(buf) - 1] = '\0'; + + /* + * Skip everything that's not a symbol record. + */ + if (buf[0] != 'S') + continue; + + /* + * When a 'T line' is found terminate file scan. + * All 'S line's preceed 'T line's in .REL files. + */ + if (buf[0] == 'T') + break; + + sscanf(buf, "S %s %c", symname, &c); + + /* If it's an actual symbol, record it */ +/*5*/ if (c == 'D') { + ThisSym->next = (pmlibrarysymbol)malloc(sizeof(mlibrarysymbol)); + ThisSym=ThisSym->next; + if (ThisSym == NULL) { + printf("panic: cant allocate memory.\n"); + exit(-2); + } + This->loaded=0; + ThisSym->next=NULL; + This->str = str; + strcpy(This->relfil,relfil); + strcpy(ThisSym->name, symname); + This->libspc = lbnh->libspc; + } + } /* Closes while - read object file */ + fclose(fp); + } /* Closes if object file opened OK */ + } /* Ends while - processing all in libr */ + fclose(libfp); + } /* Ends good open of libr file */ + } + return 0; +} +#else /* INDEXLIB */ + +int +fndsym(name) +char *name; +{ + FILE *libfp, *fp; + struct lbname *lbnh; + struct lbfile *lbfh, *lbf; + char relfil[NINPUT+2]; + char buf[NINPUT+2]; + char symname[NINPUT]; + char *path,*str; + char c; + + /* + * Search through every library in the linked list "lbnhead". + */ + +/*1*/ for (lbnh=lbnhead; lbnh; lbnh=lbnh->next) { + if ((libfp = fopen(lbnh->libspc, "r")) == NULL) { + fprintf(stderr, "Cannot open library file %s\n", + lbnh->libspc); + lkexit(1); + } + path = lbnh->path; + + /* + * Read in a line from the library file. + * This is the relative file specification + * for a .REL file in this library. + */ + +/*2*/ while (fgets(relfil, NINPUT, libfp) != NULL) { + relfil[NINPUT+1] = '\0'; + relfil[strlen(relfil) - 1] = '\0'; + if (path != NULL) { + str = (char *) new (strlen(path)+strlen(relfil)+6); + strcpy(str,path); +#ifdef OTHERSYSTEM +#ifdef SDK +#ifdef UNIX + if (str[strlen(str)-1] != '/') { + strcat(str,"/"); +#else /* UNIX */ + if (str[strlen(str)-1] != '\\') { + strcat(str,"\\"); +#endif /* UNIX */ +#else /* SDK */ + if (str[strlen(str)-1] != '\\') { + strcat(str,"\\"); +#endif /* SDK */ + } +#endif + } else { + str = (char *) new (strlen(relfil) + 5); + } +#ifdef SDK +#ifdef UNIX + if (relfil[0] == '/') { +#else /* UNIX */ + if (relfil[0] == '\\') { +#endif /* UNIX */ +#else /* SDK */ + if (relfil[0] == '\\') { +#endif /* SDK */ + strcat(str,relfil+1); + } else { + strcat(str,relfil); + } + if(strchr(str,FSEPX) == NULL) { +#ifdef SDK + sprintf(&str[strlen(str)], "%co", FSEPX); +#else /* SDK */ + sprintf(&str[strlen(str)], "%crel", FSEPX); +#endif /* SDK */ + } +/*3*/ if ((fp = fopen(str, "r")) != NULL) { + + /* + * Read in the object file. Look for lines that + * begin with "S" and end with "D". These are + * symbol table definitions. If we find one, see + * if it is our symbol. Make sure we only read in + * our object file and don't go into the next one. + */ + +/*4*/ while (fgets(buf, NINPUT, fp) != NULL) { + + buf[NINPUT+1] = '\0'; + buf[strlen(buf) - 1] = '\0'; + + /* + * Skip everything that's not a symbol record. + */ + if (buf[0] != 'S') + continue; + + /* + * When a 'T line' is found terminate file scan. + * All 'S line's preceed 'T line's in .REL files. + */ + if (buf[0] == 'T') + break; + + sscanf(buf, "S %s %c", symname, &c); + + /* + * If we find a symbol definition for the + * symbol we're looking for, load in the + * file and add it to lbfhead so it gets + * loaded on pass number 2. + */ +/*5*/ if (strncmp(symname, name, NCPS) == 0 && c == 'D') { + + lbfh = (struct lbfile *) new (sizeof(struct lbfile)); + if (lbfhead == NULL) { + lbfhead = lbfh; + } else { + lbf = lbfhead; + while (lbf->next) + lbf = lbf->next; + lbf->next = lbfh; + } + lbfh->libspc = lbnh->libspc; + lbfh->filspc = str; + lbfh->relfil = (char *) new (strlen(relfil) + 1); + strcpy(lbfh->relfil,relfil); + fclose(fp); + fclose(libfp); + loadfile(str); + return (1); + +/*5*/ } + +/*4*/ } + fclose(fp); +/*3*/ } + + free(str); +/*2*/ } + fclose(libfp); +/*1*/ } + return(0); +} +#endif /* INDEXLIB */ + +/*)Function VOID library() + * + * The function library() links all the library object files + * contained in the lbfile structures. + * + * local variables: + * lbfile *lbfh pointer to lbfile structure + * + * global variables: + * lbfile *lbfhead pointer to first lbfile structure + * + * functions called: + * VOID loadfile lklibr.c + * + * side effects: + * Links all files contained in the lbfile structures. + */ + +VOID +library() +{ + struct lbfile *lbfh; + + for (lbfh=lbfhead; lbfh; lbfh=lbfh->next) { + loadfile(lbfh->filspc); + } +} + +/*)Function VOID loadfile(filspc) + * + * char *filspc library object file specification + * + * The function loadfile() links the library object module. + * + * local variables: + * FILE *fp file handle + * int i input line length + * char str[] file input line + * + * global variables: + * char *ip pointer to linker input string + * + * functions called: + * int fclose() c_library + * int fgets() c_library + * FILE * fopen() c_library + * VOID link() lkmain.c + * int strlen() c_library + * + * side effects: + * If file exists it is linked. + */ + +VOID +loadfile(filspc) +char *filspc; +{ + FILE *fp; + char str[NINPUT+2]; + int i; + + if ((fp = fopen(filspc,"r")) != NULL) { + while (fgets(str, NINPUT, fp) != NULL) { + str[NINPUT+1] = '\0'; + i = strlen(str) - 1; + if (str[i] == '\n') + str[i] = '\0'; + ip = str; + link(); + } + fclose(fp); + } +} diff --git a/link/z80/lklist.c b/link/z80/lklist.c new file mode 100644 index 00000000..46ac9199 --- /dev/null +++ b/link/z80/lklist.c @@ -0,0 +1,1268 @@ +/* lklist.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lklist.c + * + * The module lklist.c contains the functions which + * output the linker .map file and produce a relocated + * listing .rst file. + * + * lklist.c contains the following functions: + * int dgt() + * VOID lstarea() + * VOID lkulist() + * VOID lkalist() + * VOID lkglist() + * VOID newpag() + * VOID slew() + * + * lklist.c contains no local variables. + */ + +/*)Function VOID slew(fp) + * + * FILE * fp output file handle + * + * The function slew() increments the page line counter. + * If the number of lines exceeds the maximum number of + * lines per page then a page skip and a page header are + * output. + * + * local variables: + * int i loop counter + * + * global variables: + * int lop current line number on page + * int xflag Map file radix type flag + * + * functions called: + * int fprintf() c_library + * VOID newpag() lklist.c + * + * side effects: + * The page line and the page count may be updated. + */ + +VOID +slew(fp) +FILE *fp; +{ + register i; + + if (lop++ >= NLPP) { + newpag(fp); + if (xflag == 0) { + fprintf(fp, "Hexidecimal\n\n"); + } else + if (xflag == 1) { + fprintf(fp, "Octal\n\n"); + } else + if (xflag == 2) { + fprintf(fp, "Decimal\n\n"); + } + fprintf(fp, "Area Addr Size"); + fprintf(fp, " Decimal Bytes (Attributes)\n"); + for(i=0;i<4;++i) + fprintf(fp, " Value--Global"); + fprintf(fp, "\n\n"); + lop += 6; + } +} + +/*)Function VOID newpag() + * + * The function newpag() outputs a page skip, writes the + * first page header line, sets the line count to 1, and + * increments the page counter. + * + * local variables: + * none + * + * global variables: + * int lop current line number on page + * int page current page number + * + * functions called: + * int fprintf() c_library + * + * side effects: + * The page and line counters are updated. + */ + +VOID +newpag(fp) +FILE *fp; +{ + fprintf(fp, "\fASxxxx Linker %s, page %u.\n", VERSION, ++page); + lop = 1; +} + +#if NCPS-8 + +/* NCPS != 8 */ +/*)Function VOID lstarea(xp) + * + * area * xp pointer to an area structure + * + * The function lstarea() creates the linker map output for + * the area specified by pointer xp. The generated output + * area header includes the area name, starting address, + * size of area, number of words (in decimal), and the + * area attributes. The symbols defined in this area are + * sorted by ascending address and output one per line + * in the selected radix. + * + * local variables: + * areax * oxp pointer to an area extension structure + * int c character value + * int i loop counter + * int j bubble sort update status + * char * ptr pointer to an id string + * int nmsym number of symbols in area + * addr_t a0 temporary + * addr_t ai temporary + * addr_t aj temporary + * sym * sp pointer to a symbol structure + * sym ** p pointer to an array of + * pointers to symbol structures + * + * global variables: + * FILE *mfp Map output file handle + * sym *symhash[NHASH] array of pointers to NHASH + * linked symbol lists + * int xflag Map file radix type flag + * + * functions called: + * int fprintf() c_library + * VOID free() c_library + * char * malloc() c_library + * char putc() c_library + * VOID slew() lklist.c + * + * side effects: + * Map output generated. + */ + +#ifndef MLH_MAP +VOID +lstarea(xp) +struct area *xp; +{ + register struct area *op; + register struct areax *oxp; + register c, i, j; + register char *ptr; + int nmsym; + addr_t a0, ai, aj; + struct sym *sp; + struct sym **p; + + putc('\n', mfp); + if (xflag == 0) { + fprintf(mfp, "Hexidecimal\n\n"); + } else + if (xflag == 1) { + fprintf(mfp, "Octal\n\n"); + } else + if (xflag == 2) { + fprintf(mfp, "Decimal\n\n"); + } + fprintf(mfp, "Area "); + fprintf(mfp, "Addr Size Decimal Bytes (Attributes)\n"); + fprintf(mfp, "-------------------------------- "); + fprintf(mfp, "---- ---- ------- ----- ------------\n"); + /* + * Output Area Header + */ + ptr = &xp->a_id[0]; + while (ptr < &xp->a_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, mfp); + } else { + putc(' ', mfp); + } + } + ai = xp->a_addr; + aj = xp->a_size; + if (xflag == 0) { + fprintf(mfp, " %04X %04X", ai, aj); + } else + if (xflag == 1) { + fprintf(mfp, " %06o %06o", ai, aj); + } else + if (xflag == 2) { + fprintf(mfp, " %05u %05u", ai, aj); + } + fprintf(mfp, " = %6u. bytes ", aj); + if (xp->a_flag & A_ABS) { + fprintf(mfp, "(ABS"); + } else { + fprintf(mfp, "(REL"); + } + if (xp->a_flag & A_OVR) { + fprintf(mfp, ",OVR"); + } else { + fprintf(mfp, ",CON"); + } + if (xp->a_flag & A_PAG) { + fprintf(mfp, ",PAG"); + } + fprintf(mfp, ")"); + if (xp->a_flag & A_PAG) { + ai = (ai & 0xFF); + aj = (aj > 256); + if (ai || aj) { fprintf(mfp, " "); } + if (ai) { fprintf(mfp, " Boundary"); } + if (ai & aj) { fprintf(mfp, " /"); } + if (aj) { fprintf(mfp, " Length"); } + if (ai || aj) { fprintf(mfp, " Error"); } + } + + /* + * Find number of symbols in area + */ + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) + ++nmsym; + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + if (nmsym == 0) { + putc('\n', mfp); + return; + } + + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) + == NULL) { + fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); + return; + } + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) { + p[nmsym++] = sp; + } + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Bubble Sort of Addresses in Symbol Table Array + */ + j = 1; + while (j) { + j = 0; + sp = p[0]; + a0 = sp->s_addr + sp->s_axp->a_addr; + for (i=1; is_addr + sp->s_axp->a_addr; + if (a0 > ai) { + j = 1; + p[i] = p[i-1]; + p[i-1] = sp; + } + a0 = ai; + } + } + + /* + * Symbol Table Output + */ + i = 0; + fprintf(mfp, "\n\n"); + fprintf(mfp, " Value Global\n"); + fprintf(mfp, " ----- --------------------------------"); + while (i < nmsym) { + fprintf(mfp, "\n"); + fprintf(mfp, " "); + + sp = p[i]; + aj = sp->s_addr + sp->s_axp->a_addr; + if (xflag == 0) { + fprintf(mfp, " %04X ", aj); + } else + if (xflag == 1) { + fprintf(mfp, "%06o ", aj); + } else + if (xflag == 2) { + fprintf(mfp, " %05u ", aj); + } + ptr = &sp->s_id[0]; + while (ptr < &sp->s_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, mfp); + } else { + putc(' ', mfp); + } + } + i++; + } + putc('\n', mfp); + free(p); +} +#else +VOID lstarea(struct area *xp) +{ + register struct area *op; + register struct areax *oxp; + register c, i, j; + register char *ptr; + int nmsym; + addr_t a0, ai, aj; + struct sym *sp; + struct sym **p; + + /* + * Find number of symbols in area + */ + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) + ++nmsym; + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Symbol Table Output + */ + if (!((xp->a_size==0)&&(xp->a_addr==0)&&(nmsym==0))) { + fprintf(mfp, "AREA %s\n", xp->a_id ); + switch (xflag) { + case 1: + fprintf(mfp, "\tRADIX OCTAL\n" ); + break; + case 2: + fprintf(mfp, "\tRADIX DEC\n" ); + break; + default: + fprintf(mfp, "\tRADIX HEX\n" ); + break; + } + fprintf( mfp, "\tBASE %04X\n" + "\tSIZE %04X\n" + "\tATTRIB " + , xp->a_addr, xp->a_size ); + if (xp->a_flag & A_ABS) { + fprintf(mfp, "ABS"); + } else { + fprintf(mfp, "REL"); + } + if (xp->a_flag & A_OVR) { + fprintf(mfp, " OVR"); + } else { + fprintf(mfp, " CON"); + } + if (xp->a_flag & A_PAG) { + fprintf(mfp, " PAG"); + } + if (xp->a_flag & A_PAG) { + ai = (ai & 0xFF); + aj = (aj > 256); + if (ai || aj) { fprintf(mfp, " "); } + if (ai) { fprintf(mfp, " Boundary"); } + if (ai & aj) { fprintf(mfp, " /"); } + if (aj) { fprintf(mfp, " Length"); } + if (ai || aj) { fprintf(mfp, " Error"); } + } + + fprintf( mfp,"\n"); + if (nmsym>0) { + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) + == NULL) { + fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); + return; + } + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) { + p[nmsym++] = sp; + } + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Bubble Sort of Addresses in Symbol Table Array + */ + j = 1; + while (j) { + j = 0; + sp = p[0]; + a0 = sp->s_addr + sp->s_axp->a_addr; + for (i=1; is_addr + sp->s_axp->a_addr; + if (a0 > ai) { + j = 1; + p[i] = p[i-1]; + p[i-1] = sp; + } + a0 = ai; + } + } + + fprintf( mfp, "\tGLOBALS\n"); + i = 0; + while (i < nmsym) { + fprintf(mfp, "\t\t%s\t%04X\n", p[i]->s_id, p[i]->s_addr + p[i]->s_axp->a_addr ); + i++; + } + free(p); + } + } +} +#endif /* MLH_MAP */ +#else + +/* NCPS == 8 */ +/*)Function VOID lstarea(xp) + * + * area * xp pointer to an area structure + * + * The function lstarea() creates the linker map output for + * the area specified by pointer xp. The generated output + * area header includes the area name, starting address, + * size of area, number of words (in decimal), and the + * area attributes. The symbols defined in this area are + * sorted by ascending address and output four per line + * in the selected radix. + * + * local variables: + * areax * oxp pointer to an area extension structure + * int c character value + * int i loop counter + * int j bubble sort update status + * char * ptr pointer to an id string + * int nmsym number of symbols in area + * addr_t a0 temporary + * addr_t ai temporary + * addr_t aj temporary + * sym * sp pointer to a symbol structure + * sym ** p pointer to an array of + * pointers to symbol structures + * + * global variables: + * FILE *mfp Map output file handle + * sym *symhash[NHASH] array of pointers to NHASH + * linked symbol lists + * int xflag Map file radix type flag + * + * functions called: + * int fprintf() c_library + * VOID free() c_library + * char * malloc() c_library + * char putc() c_library + * VOID slew() lklist.c + * + * side effects: + * Map output generated. + */ + +VOID +lstarea(xp) +struct area *xp; +{ + register struct areax *oxp; + register c, i, j; + register char *ptr; + int nmsym; + addr_t a0, ai, aj; + struct sym *sp; + struct sym **p; + + putc('\n', mfp); + slew(mfp); + /* + * Output Area Header + */ + ptr = &xp->a_id[0]; + while (ptr < &xp->a_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, mfp); + } else { + putc(' ', mfp); + } + } + ai = xp->a_addr; + aj = xp->a_size; + if (xflag == 0) { + fprintf(mfp, " %04X %04X", ai, aj); + } else + if (xflag == 1) { + fprintf(mfp, " %06o %06o", ai, aj); + } else + if (xflag == 2) { + fprintf(mfp, " %05u %05u", ai, aj); + } + fprintf(mfp, " = %6u. bytes ", aj); + if (xp->a_flag & A_ABS) { + fprintf(mfp, "(ABS"); + } else { + fprintf(mfp, "(REL"); + } + if (xp->a_flag & A_OVR) { + fprintf(mfp, ",OVR"); + } else { + fprintf(mfp, ",CON"); + } + if (xp->a_flag & A_PAG) { + fprintf(mfp, ",PAG"); + } + fprintf(mfp, ")"); + if (xp->a_flag & A_PAG) { + ai = (ai & 0xFF); + aj = (aj > 256); + if (ai || aj) { fprintf(mfp, " "); } + if (ai) { fprintf(mfp, " Boundary"); } + if (ai & aj) { fprintf(mfp, " /"); } + if (aj) { fprintf(mfp, " Length"); } + if (ai || aj) { fprintf(mfp, " Error"); } + } + + /* + * Find number of symbols in area + */ + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) + ++nmsym; + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + if (nmsym == 0) { + putc('\n', mfp); + slew(mfp); + return; + } + + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) + == NULL) { + fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); + slew(mfp); + return; + } + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) { + p[nmsym++] = sp; + } + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Bubble Sort of Addresses in Symbol Table Array + */ + j = 1; + while (j) { + j = 0; + sp = p[0]; + a0 = sp->s_addr + sp->s_axp->a_addr; + for (i=1; is_addr + sp->s_axp->a_addr; + if (a0 > ai) { + j = 1; + p[i] = p[i-1]; + p[i-1] = sp; + } + a0 = ai; + } + } + + /* + * Symbol Table Output + */ + i = 0; + while (i < nmsym) { + if (i % 4 == 0) { + fprintf(mfp, "\n"); + slew(mfp); + fprintf(mfp, " "); + } + sp = p[i]; + aj = sp->s_addr + sp->s_axp->a_addr; + if (xflag == 0) { + fprintf(mfp, " %04X ", aj); + } else + if (xflag == 1) { + fprintf(mfp, "%06o ", aj); + } else + if (xflag == 2) { + fprintf(mfp, " %05u ", aj); + } + ptr = &sp->s_id[0]; + while (ptr < &sp->s_id[NCPS]) { + if ((c = *ptr++) != 0) { + putc(c, mfp); + } else { + putc(' ', mfp); + } + } + if (++i < nmsym) + if (i % 4 != 0) + fprintf(mfp, " | "); + } + putc('\n', mfp); + free(p); + slew(mfp); +} +#endif + +#ifdef SDK +VOID lstareatosym(struct area *xp) +{ + /* Output the current area symbols to a NO$GMB .sym file */ + register struct areax *oxp; + register i, j; + int nmsym; + addr_t a0, ai; + struct sym *sp; + struct sym **p; + + /* + * Find number of symbols in area + */ + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) + ++nmsym; + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Symbol Table Output + */ + if (!((xp->a_size==0)&&(xp->a_addr==0)&&(nmsym==0))) { + /* Dont worry about any area information */ + fprintf(mfp, "; Area: %s\n", xp->a_id ); + if (nmsym>0) { + /* + * Allocate space for an array of pointers to symbols + * and load array. + */ + if ( (p = (struct sym **) malloc(nmsym*sizeof(struct sym *))) + == NULL) { + fprintf(mfp, "\nInsufficient space to build Map Segment.\n"); + return; + } + nmsym = 0; + oxp = xp->a_axp; + while (oxp) { + for (i=0; is_axp) { + p[nmsym++] = sp; + } + sp = sp->s_sp; + } + } + oxp = oxp->a_axp; + } + + /* + * Bubble Sort of Addresses in Symbol Table Array + */ + j = 1; + while (j) { + j = 0; + sp = p[0]; + a0 = sp->s_addr + sp->s_axp->a_addr; + for (i=1; is_addr + sp->s_axp->a_addr; + if (a0 > ai) { + j = 1; + p[i] = p[i-1]; + p[i-1] = sp; + } + a0 = ai; + } + } + i = 0; + while (i < nmsym) { + if ((strncmp("l__", p[i]->s_id, 3)!=0)&&(strchr(p[i]->s_id,' ')==NULL)) { + a0=p[i]->s_addr + p[i]->s_axp->a_addr; + if (a0>0x7FFFU) { + /* Not inside the ROM, so treat as being in bank zero */ + fprintf(mfp, "00:%04X %s\n", a0, p[i]->s_id); + } + else { + fprintf(mfp, "%02X:%04X %s\n", a0/16384, a0, p[i]->s_id ); + } + } + i++; + } + free(p); + } + } +} +#endif + +/*)Function VOID lkulist(i) + * + * int i i # 0 process LST to RST file + * i = 0 copy remainder of LST file + * to RST file and close files + * + * The function lkulist() creates a relocated listing (.rst) + * output file from the ASxxxx assembler listing (.lst) + * files. The .lst file's program address and code bytes + * are changed to reflect the changes made by ASlink as + * the .rel files are combined into a single relocated + * output file. + * + * local variables: + * addr_t pc current program counter address + * + * global variables: + * int hilo byte order + * int gline get a line from the LST file + * to translate for the RST file + * char rb[] read listing file text line + * FILE *rfp The file handle to the current + * output RST file + * int rtcnt count of data words + * int rtflg[] output the data flag + * addr_t rtval[] relocated data + * FILE *tfp The file handle to the current + * LST file being scanned + * + * functions called: + * int fclose() c_library + * int fgets() c_library + * int fprintf() c_library + * VOID lkalist() lklist.c + * VOID lkglist() lklist.c + * + * side effects: + * A .rst file is created for each available .lst + * file associated with a .rel file. + */ + +VOID +lkulist(i) +int i; +{ + addr_t pc; + + /* + * Exit if listing file is not open + */ + if (tfp == NULL) + return; + + /* + * Normal processing of LST to RST + */ + if (i) { + /* + * Evaluate current code address + */ + if (hilo == 0) { + pc = ((rtval[1] & 0xFF) << 8) + (rtval[0] & 0xFF); + } else { + pc = ((rtval[0] & 0xFF) << 8) + (rtval[1] & 0xFF); + } + + /* + * Line with only address + */ + if (rtcnt == 2) { + lkalist(pc); + + /* + * Line with address and code + */ + } else { + for (i=2; i < rtcnt; i++) { + if (rtflg[i]) { + lkglist(pc++, rtval[i] & 0xFF); + } + } + } + + /* + * Copy remainder of LST to RST + */ + } else { + if (gline == 0) + fprintf(rfp, rb); + + while (fgets(rb, sizeof(rb), tfp) != 0) { + fprintf(rfp, rb); + } + fclose(tfp); + tfp = NULL; + fclose(rfp); + rfp = NULL; + } +} + +/*)Function VOID lkalist(pc) + * + * int pc current program counter value + * + * The function lkalist() performs the following functions: + * + * (1) if the value of gline = 0 then the current listing + * file line is copied to the relocated listing file output. + * + * (2) the listing file is read line by line and copied to + * the relocated listing file until a valid source + * line number and a program counter value of the correct + * radix is found. The new relocated pc value is substituted + * and the line is written to the RST file. + * + * local variables: + * int i loop counter + * char str[] temporary string + * + * global variables: + * int gcntr data byte counter + * int gline get a line from the LST file + * to translate for the RST file + * char rb[] read listing file text line + * char *rp pointer to listing file text line + * FILE *rfp The file handle to the current + * output RST file + * FILE *tfp The file handle to the current + * LST file being scanned + * + * functions called: + * int dgt() lklist.c + * int fclose() c_library + * int fgets() c_library + * int fprintf() c_library + * int sprintf() c_library + * char * strncpy() c_library + * + * side effects: + * Lines of the LST file are copied to the RST file, + * the last line copied has the code address + * updated to reflect the program relocation. + */ + +VOID +lkalist(pc) +addr_t pc; +{ + char str[8]; + int i; + + /* + * Exit if listing file is not open + */ +loop: if (tfp == NULL) + return; + + /* + * Copy current LST to RST + */ + if (gline == 0) { + fprintf(rfp, rb); + gline = 1; + } + + /* + * Clear text line buffer + */ + for (i=0,rp=rb; i +#include +#include +#include "aslink.h" + +/*)Module lkmain.c + * + * The module lkmain.c contains the functions which + * (1) input the linker options, parameters, and specifications + * (2) perform a two pass link + * (3) produce the appropriate linked data output and/or + * link map file and/or relocated listing files. + * + * lkmain.c contains the following functions: + * FILE * afile(fn,ft,wf) + * VOID bassav() + * VOID gblsav() + * VOID link() + * VOID lkexit() + * VOID main(argc,argv) + * VOID map() + * int parse() + * VOID setbas() + * VOID setgbl() + * VOID usage() + * + * lkmain.c contains the following local variables: + * char * usetext[] array of pointers to the + * command option tect lines + * + */ + +/*)Function VOID main(argc,argv) + * + * int argc number of command line arguments + 1 + * char * argv[] array of pointers to the command line + * arguments + * + * The function main() evaluates the command line arguments to + * determine if the linker parameters are to input through 'stdin' + * or read from a command file. The functiond getline() and parse() + * are to input and evaluate the linker parameters. The linking process + * proceeds by making the first pass through each .rel file in the order + * presented to the linker. At the end of the first pass the setbase(), + * lnkarea(), setgbl(), and symdef() functions are called to evaluate + * the base address terms, link all areas, define global variables, + * and look for undefined symbols. Following these routines a linker + * map file may be produced and the linker output files may be opened. + * The second pass through the .rel files will output the linked data + * in one of the four supported formats. + * + * local variables: + * char * p pointer to an argument string + * int c character from argument string + * int i loop counter + * + * global variables: + * text line in ib[] + * lfile *cfp The pointer *cfp points to the + * current lfile structure + * char ctype[] array of character types, one per + * ASCII character + * lfile *filep The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + * head *hp Pointer to the current + * head structure + * char ib[NINPUT] .rel file text line + * char *ip pointer into the .rel file + * lfile *linkp pointer to first lfile structure + * containing an input .rel file + * specification + * int lkerr error flag + * int mflag Map output flag + * int oflag Output file type flag + * FILE *ofp Output file handle + * for word formats + * FILE *ofph Output file handle + * for high byte format + * FILE *ofpl Output file handle + * for low byte format + * int pass linker pass number + * int pflag print linker command file flag + * int radix current number conversion radix + * FILE *sfp The file handle sfp points to the + * currently open file + * lfile *startp asmlnk startup file structure + * FILE * stdin c_library + * FILE * stdout c_library + * + * functions called: + * FILE * afile() lkmain.c + * int fclose() c_library + * int fprintf() c_library + * int getline() lklex.c + * VOID library() lklibr.c + * VOID link() lkmain.c + * VOID lkexit() lkmain.c + * VOID lnkarea() lkarea.c + * VOID map() lkmain.c + * VOID new() lksym.c + * int parse() lkmain.c + * VOID reloc() lkreloc.c + * VOID search() lklibr.c + * VOID setbas() lkmain.c + * VOID setgbl() lkmain.c + * VOID symdef() lksym.c + * VOID usage() lkmain.c + * + * side effects: + * Completion of main() completes the linking process + * and may produce a map file (.map) and/or a linked + * data files (.ihx or .s19) and/or one or more + * relocated listing files (.rst). + */ + +#ifdef SDK +int binary = 0; +#endif /* SDK */ +#ifdef GAMEBOY +char *default_basep[] = { + "_CODE=0x0200", + "_BSS=0xC0A0", + NULL +}; + +char *default_globlp[] = { + /* DMA transfer must start at multiples of 0x100 */ + ".OAM=0xC000", + ".STACK=0xE000", + ".refresh_OAM=0xFF80", + + ".init=0x0000", + + NULL +}; +#endif /* GAMEBOY */ + +VOID +main(argc, argv) +char *argv[]; +{ + register char *p; + register c, i; + +#ifdef GAMEBOY + nb_rom_banks = 2; + nb_ram_banks = 0; + mbc_type = 0; + symflag=0; + + for(i = 0; default_basep[i] != NULL; i++) { + if(basep == NULL) { + basep = (struct base *)new(sizeof(struct base)); + bsp = basep; + } else { + bsp->b_base = (struct base *)new(sizeof(struct base)); + bsp = bsp->b_base; + } + bsp->b_strp = default_basep[i]; + } + for(i = 0; default_globlp[i] != NULL; i++) { + if(globlp == NULL) { + globlp = (struct globl *)new(sizeof(struct globl)); + gsp = globlp; + } else { + gsp->g_globl = (struct globl *)new(sizeof(struct globl)); + gsp = gsp->g_globl; + } + gsp->g_strp = default_globlp[i]; + } +#endif /* GAMEBOY */ +#ifndef SDK + fprintf(stdout, "\n"); +#endif /* SDK */ + + startp = (struct lfile *) new (sizeof (struct lfile)); + + pflag = 1; + for (i=1; if_type = F_STD; + break; + + case 'f': + case 'F': + startp->f_type = F_LNK; + break; + + case 'n': + case 'N': + pflag = 0; + break; + + case 'p': + case 'P': + pflag = 1; + break; + + default: + usage(); + } + } + +#ifdef SDK + if(c == '-') { + startp->f_type = F_CMD; + startp->f_idp = (char *)&argv[i+1]; + break; + } +#endif /* SDK */ + + } else { + if (startp->f_type == F_LNK) { + startp->f_idp = p; + } + } + } + if (startp->f_type == NULL) + usage(); + if (startp->f_type == F_LNK && startp->f_idp == NULL) + usage(); +#ifdef SDK + if (startp->f_type == F_CMD && startp->f_idp == NULL) + usage(); +#endif /* SDK */ + + cfp = NULL; + sfp = NULL; + filep = startp; + while (1) { + ip = ib; + if (getline() == 0) + break; + if (pflag && sfp != stdin) + fprintf(stdout, "%s\n", ip); + if (*ip == NULL || parse()) + break; + } + if (sfp) + fclose(sfp); + if (linkp == NULL) + usage(); +#ifdef SDK + if (linkp->f_flp == NULL) + usage(); +#endif /* SDK */ + +#ifdef GAMEBOY + for(i = 1; i < nb_rom_banks; i++) { + bsp->b_base = (struct base *)new(sizeof(struct base)); + bsp = bsp->b_base; + bsp->b_strp = (char *)malloc(18); + sprintf(bsp->b_strp, "_CODE_%d=0x4000", i); + } + for(i = 0; i < nb_ram_banks; i++) { + bsp->b_base = (struct base *)new(sizeof(struct base)); + bsp = bsp->b_base; + bsp->b_strp = (char *)malloc(18); + sprintf(bsp->b_strp, "_BSS_%d=0xA000", i); + } +#endif /* GAMEBOY */ + + syminit(); + for (pass=0; pass<2; ++pass) { + cfp = NULL; + sfp = NULL; +#ifdef SDK + filep = linkp->f_flp; +#else /* SDK */ + filep = linkp; +#endif /* SDK */ + hp = NULL; + radix = 10; + + while (getline()) { + ip = ib; + link(); + } + if (pass == 0) { + /* + * Search libraries for global symbols + */ + search(); + /* + * Set area base addresses. + */ + setbas(); + /* + * Link all area addresses. + */ + lnkarea(); + /* + * Process global definitions. + */ + setgbl(); + /* + * Check for undefined globals. + */ + symdef(stderr); +#ifdef SDK + if (symflag) + sym(); +#endif + /* + * Output Link Map. + */ + if (mflag) + map(); + /* + * Open output file + */ + if (oflag == 1) { +#ifdef SDK + ofp = afile(linkp->f_idp, "ihx", 1); +#else /* SDK */ + ofp = afile(linkp->f_idp, "IHX", 1); +#endif /* SDK */ + if (ofp == NULL) { + lkexit(1); + } + } else + if (oflag == 2) { +#ifdef SDK + ofp = afile(linkp->f_idp, "s19", 1); +#else /* SDK */ + ofp = afile(linkp->f_idp, "S19", 1); +#endif /* SDK */ + if (ofp == NULL) { + lkexit(1); + } +#ifdef SDK + } else + if (oflag == 3) { + binary = 1; + ofp = afile(linkp->f_idp, "", 1); + binary = 0; + if (ofp == NULL) { + lkexit(1); + } +#endif /* SDK */ + } + } else { + /* + * Link in library files + */ + library(); + reloc('E'); + } + } + lkexit(lkerr); +} + +/*)Function VOID lkexit(i) + * + * int i exit code + * + * The function lkexit() explicitly closes all open + * files and then terminates the program. + * + * local variables: + * none + * + * global variables: + * FILE * mfp file handle for .map + * FILE * ofp file handle for .ihx/.s19 + * FILE * rfp file hanlde for .rst + * FILE * sfp file handle for .rel + * FILE * tfp file handle for .lst + * + * functions called: + * int fclose() c_library + * VOID exit() c_library + * + * side effects: + * All files closed. Program terminates. + */ + +VOID +lkexit(i) +int i; +{ + if (mfp != NULL) fclose(mfp); + if (ofp != NULL) fclose(ofp); + if (rfp != NULL) fclose(rfp); + if (sfp != NULL) fclose(sfp); + if (tfp != NULL) fclose(tfp); + exit(i); +} + +/*)Function link() + * + * The function link() evaluates the directives for each line of + * text read from the .rel file(s). The valid directives processed + * are: + * X, D, Q, H, M, A, S, T, R, and P. + * + * local variables: + * int c first non blank character of a line + * + * global variables: + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * int pass linker pass number + * int radix current number conversion radix + * + * functions called: + * char endline() lklex.c + * VOID module() lkhead.c + * VOID newarea() lkarea.c + * VOID newhead() lkhead.c + * sym * newsym() lksym.c + * VOID reloc() lkreloc.c + * + * side effects: + * Head, area, and symbol structures are created and + * the radix is set as the .rel file(s) are read. + */ + +VOID +link() +{ + register c; + + if ((c=endline()) == 0) { return; } + switch (c) { + + case 'X': + radix = 16; + break; + + case 'D': + radix = 10; + break; + + case 'Q': + radix = 8; + break; + + case 'H': + if (pass == 0) { + newhead(); + } else { + if (hp == 0) { + hp = headp; + } else { + hp = hp->h_hp; + } + } + sdp.s_area = NULL; + sdp.s_areax = NULL; + sdp.s_addr = 0; + break; + + case 'M': + if (pass == 0) + module(); + break; + + case 'A': + if (pass == 0) + newarea(); + if (sdp.s_area == NULL) { + sdp.s_area = areap; + sdp.s_areax = areap->a_axp; + sdp.s_addr = 0; + } + break; + + case 'S': + if (pass == 0) + newsym(); + break; + + case 'T': + case 'R': + case 'P': + if (pass == 0) + break; + reloc(c); + break; + + default: + break; + } + if (c == 'X' || c == 'D' || c == 'Q') { + if ((c = get()) == 'H') { + hilo = 1; + } else + if (c == 'L') { + hilo = 0; + } + } +} + +/*)Function VOID map() + * + * The function map() opens the output map file and calls the various + * routines to + * (1) output the variables in each area, + * (2) list the files processed with module names, + * (3) list the libraries file processed, + * (4) list base address definitions, + * (5) list global variable definitions, and + * (6) list any undefined variables. + * + * local variables: + * int i counter + * head * hdp pointer to head structure + * lbfile *lbfh pointer to library file structure + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * base *basep The pointer to the first + * base structure + * base *bsp Pointer to the current + * base structure + * lfile *filep The pointer *filep points to the + * beginning of a linked list of + * lfile structures. + * globl *globlp The pointer to the first + * globl structure + * globl *gsp Pointer to the current + * globl structure + * head *headp The pointer to the first + * head structure of a linked list + * lbfile *lbfhead The pointer to the first + * lbfile structure of a linked list + * lfile *linkp pointer to first lfile structure + * containing an input REL file + * specification + * int lop current line number on page + * FILE *mfp Map output file handle + * int page current page number + * + * functions called: + * FILE * afile() lkmain.c + * int fprintf() c_library + * VOID lkexit() lkmain.c + * VOID lstarea() lklist.c + * VOID newpag() lklist.c + * VOID symdef() lksym.c + * + * side effects: + * The map file is created. + */ + +#ifndef MLH_MAP +VOID +map() +{ + register i; + register struct head *hdp; + register struct lbfile *lbfh; + + /* + * Open Map File + */ +#ifdef SDK + mfp = afile(linkp->f_idp, "map", 1); +#else /* SDK */ + mfp = afile(linkp->f_idp, "MAP", 1); +#endif /* SDK */ + if (mfp == NULL) { + lkexit(1); + } + + /* + * Output Map Area Lists + */ + page = 0; + lop = NLPP; + ap = areap; + while (ap) { + lstarea(ap); + ap = ap->a_ap; + } + /* + * List Linked Files + */ + newpag(mfp); + fprintf(mfp, "\nFiles Linked [ module(s) ]\n\n"); + hdp = headp; +#ifdef SDK + filep = linkp->f_flp; +#else /* SDK */ + filep = linkp; +#endif /* SDK */ + while (filep) { + fprintf(mfp, "%-16s", filep->f_idp); + i = 0; + while ((hdp != NULL) && (hdp->h_lfile == filep)) { + if (i % 5) { + fprintf(mfp, ", %8.8s", hdp->m_id); + } else { + if (i) { + fprintf(mfp, ",\n%20s%8.8s", "", hdp->m_id); + } else { + fprintf(mfp, " [ %8.8s", hdp->m_id); + } + } + hdp = hdp->h_hp; + i++; + } + if (i) + fprintf(mfp, " ]"); + fprintf(mfp, "\n"); + filep = filep->f_flp; + } + /* + * List Linked Libraries + */ + if (lbfhead != NULL) { + fprintf(mfp, + "\nLibraries Linked [ object file ]\n\n"); + for (lbfh=lbfhead; lbfh; lbfh=lbfh->next) { + fprintf(mfp, "%-32s [ %16.16s ]\n", + lbfh->libspc, lbfh->relfil); + } + fprintf(mfp, "\n"); + } + /* + * List Base Address Definitions + */ + if (basep) { + newpag(mfp); + fprintf(mfp, "\nUser Base Address Definitions\n\n"); + bsp = basep; + while (bsp) { + fprintf(mfp, "%s\n", bsp->b_strp); + bsp = bsp->b_base; + } + } + /* + * List Global Definitions + */ + if (globlp) { + newpag(mfp); + fprintf(mfp, "\nUser Global Definitions\n\n"); + gsp = globlp; + while (gsp) { + fprintf(mfp, "%s\n", gsp->g_strp); + gsp = gsp->g_globl; + } + } + fprintf(mfp, "\n\f"); + symdef(mfp); +} +#else +VOID map() +{ + register i; + register struct head *hdp; + register struct lbfile *lbfh; + + /* + * Open Map File + */ +#ifdef SDK + mfp = afile(linkp->f_idp, "map", 1); +#else /* SDK */ + mfp = afile(linkp->f_idp, "MAP", 1); +#endif /* SDK */ + if (mfp == NULL) { + lkexit(1); + } + + /* + *Output Map Area Lists + */ + page = 0; + lop = NLPP; + ap = areap; + while (ap) { + lstarea(ap); + ap = ap->a_ap; + } + /* + * List Linked Files + */ + hdp = headp; +#ifdef SDK + filep = linkp->f_flp; +#else /* SDK */ + filep = linkp; +#endif /* SDK */ + if (filep) { + fprintf( mfp, "MODULES\n"); + } + while (filep) { + fprintf(mfp, "\tFILE %s\n", filep->f_idp); + while ((hdp != NULL) && (hdp->h_lfile == filep)) { + if (strlen(hdp->m_id)>0) + fprintf(mfp, "\t\tNAME %s\n", hdp->m_id); + hdp = hdp->h_hp; + } + filep = filep->f_flp; + } + /* + * List Linked Libraries + */ + if (lbfhead != NULL) { + fprintf(mfp, "LIBRARIES\n"); + for (lbfh=lbfhead; lbfh; lbfh=lbfh->next) { + fprintf(mfp, "\tLIBRARY %s\n" + "\t\tMODULE %s\n", + lbfh->libspc, lbfh->relfil); + } + } + /* + * List Base Address Definitions + */ + if (basep) { + fprintf(mfp, "USERBASEDEF\n"); + bsp = basep; + while (bsp) { + fprintf(mfp, "\t%s\n", bsp->b_strp); + bsp = bsp->b_base; + } + } + /* + * List Global Definitions + */ + if (globlp) { + fprintf(mfp, "USERGLOBALDEF\n"); + gsp = globlp; + while (gsp) { + fprintf(mfp, "\t%s\n", gsp->g_strp); + gsp = gsp->g_globl; + } + } + symdef(mfp); +#ifdef SDK + if (mfp!=NULL) { + fclose(mfp); + mfp = NULL; + } +#endif +} +#endif /* MLH_MAP */ + +#ifdef SDK +VOID sym() +{ + register i; + register struct head *hdp; + register struct lbfile *lbfh; + + /* + * Open sym File + */ + mfp = afile(linkp->f_idp, "sym", 1); + if (mfp == NULL) { + lkexit(1); + } + fprintf( mfp, "; no$gmb format .sym file\n" + "; Generated automagically by ASxxxx linker %s (SDK " SDK_VERSION_STRING ")\n" + , VERSION ); + /* + * Output sym Area Lists + */ + page = 0; + lop = NLPP; + ap = areap; + while (ap) { + lstareatosym(ap); + ap = ap->a_ap; + } + if (mfp!=NULL) { + fclose(mfp); + mfp = NULL; + } +} +#endif /* SDK */ + +/*)Function int parse() + * + * The function parse() evaluates all command line or file input + * linker directives and updates the appropriate variables. + * + * local variables: + * int c character value + * char fid[] file id string + * + * global variables: + * char ctype[] array of character types, one per + * ASCII character + * lfile *lfp pointer to current lfile structure + * being processed by parse() + * lfile *linkp pointer to first lfile structure + * containing an input REL file + * specification + * int mflag Map output flag + * int oflag Output file type flag + * int pflag print linker command file flag + * FILE * stderr c_library + * int uflag Relocated listing flag + * int xflag Map file radix type flag + * + * Functions called: + * VOID addlib() lklibr.c + * VOID addpath() lklibr.c + * VOID bassav() lkmain.c + * int fprintf() c_library + * VOID gblsav() lkmain.c + * VOID getfid() lklex.c + * char getnb() lklex.c + * VOID lkexit() lkmain.c + * char * strcpy() c_library + * int strlen() c_library + * + * side effects: + * Various linker flags are updated and the linked + * structure lfile is created. + */ + +int +parse() +{ + register c; + char fid[NINPUT]; + + while ((c = getnb()) != 0) { + if ( c == '-') { + while (ctype[c=get()] & LETTER) { + switch(c) { + + case 'i': + case 'I': + oflag = 1; + break; + + case 's': + case 'S': + oflag = 2; + break; +#ifdef GAMEBOY + case 'y': + case 'Y': + c = get(); + if(c == 'O' || c == 'o') + nb_rom_banks = expr(0); + else if(c == 'A' || c == 'a') + nb_ram_banks = expr(0); + else if(c == 'T' || c == 't') + mbc_type = expr(0); + else if(c == 'N' || c == 'n') { + int i = 0; + if(getnb() != '=' || getnb() != '"') { + fprintf(stderr, "Syntax error in -YN=\"name\" flag\n"); + lkexit(1); + } + while((c = get()) != '"' && i < 16) { + cart_name[i++] = c; + } + if(i < 16) + cart_name[i] = 0; + else + while(get() != '"') + ; + } else if(c == 'P' || c == 'p') { + unsigned int addr; + unsigned char value; + patch *p = patches; + + patches = (patch *)malloc(sizeof(patch)); + patches->next = p; + patches->addr = expr(0); + if(getnb() != '=') { + fprintf(stderr, "Syntax error in -YHaddr=val flag\n"); + lkexit(1); + } + patches->value = expr(0); + } else { + fprintf(stderr, "Invalid option\n"); + lkexit(1); + } + break; + +#endif /* GAMEBOY */ +#ifdef SDK + case 'j': + case 'J': + ++symflag; + break; + case 'z': + case 'Z': + oflag = 3; + break; +#endif /* SDK */ + case 'm': + case 'M': + ++mflag; + break; + + case 'u': + case 'U': + uflag = 1; + break; + + case 'x': + case 'X': + xflag = 0; + break; + + case 'q': + case 'Q': + xflag = 1; + break; + + case 'd': + case 'D': + xflag = 2; + break; + + case 'e': + case 'E': + return(1); + + case 'n': + case 'N': + pflag = 0; + break; + + case 'p': + case 'P': + pflag = 1; + break; + + case 'b': + case 'B': + bassav(); + return(0); + + case 'g': + case 'G': + gblsav(); + return(0); + + case 'k': + case 'K': + addpath(); + return(0); + + case 'l': + case 'L': + addlib(); + return(0); + + default: + fprintf(stderr, "Invalid option\n"); + lkexit(1); + } + } + } else + if (ctype[c] != ILL) { + if (linkp == NULL) { + linkp = (struct lfile *) + new (sizeof (struct lfile)); + lfp = linkp; + } else { + lfp->f_flp = (struct lfile *) + new (sizeof (struct lfile)); + lfp = lfp->f_flp; + } + getfid(fid, c); + lfp->f_idp = (char *) new (strlen(fid)+1); + strcpy(lfp->f_idp, fid); + lfp->f_type = F_REL; + } else { + fprintf(stderr, "Invalid input"); + lkexit(1); + } + } + return(0); +} + +/*)Function VOID bassav() + * + * The function bassav() creates a linked structure containing + * the base address strings input to the linker. + * + * local variables: + * none + * + * global variables: + * base *basep The pointer to the first + * base structure + * base *bsp Pointer to the current + * base structure + * char *ip pointer into the REL file + * text line in ib[] + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * The basep structure is created. + */ + +VOID +bassav() +{ + if (basep == NULL) { + basep = (struct base *) + new (sizeof (struct base)); + bsp = basep; + } else { + bsp->b_base = (struct base *) + new (sizeof (struct base)); + bsp = bsp->b_base; + } + unget(getnb()); + bsp->b_strp = (char *) new (strlen(ip)+1); + strcpy(bsp->b_strp, ip); +} + +/*)Function VOID setbas() + * + * The function setbas() scans the base address lines in hte + * basep structure, evaluates the arguments, and sets beginning + * address of the specified areas. + * + * local variables: + * int v expression value + * char id[] base id string + * + * global variables: + * area *ap Pointer to the current + * area structure + * area *areap The pointer to the first + * area structure of a linked list + * base *basep The pointer to the first + * base structure + * base *bsp Pointer to the current + * base structure + * char *ip pointer into the REL file + * text line in ib[] + * int lkerr error flag + * + * functions called: + * addr_t expr() lkeval.c + * int fprintf() c_library + * VOID getid() lklex.c + * char getnb() lklex.c + * int symeq() lksym.c + * + * side effects: + * The base address of an area is set. + */ + +VOID +setbas() +{ + register v; + char id[NCPS]; + + bsp = basep; + while (bsp) { + ip = bsp->b_strp; + getid(id, -1); + if (getnb() == '=') { + v = expr(0); + for (ap = areap; ap != NULL; ap = ap->a_ap) { + if (symeq(id, ap->a_id)) + break; + } + if (ap == NULL) { +#ifndef SDK + fprintf(stderr, + "No definition of area %s\n", id); + lkerr++; +#endif /* SDK */ + } else { + ap->a_addr = v; + } + } else { + fprintf(stderr, "No '=' in base expression"); + lkerr++; + } + bsp = bsp->b_base; + } +} + +/*)Function VOID gblsav() + * + * The function gblsav() creates a linked structure containing + * the global variable strings input to the linker. + * + * local variable: + * none + * + * global variables: + * globl *globlp The pointer to the first + * globl structure + * globl *gsp Pointer to the current + * globl structure + * char *ip pointer into the REL file + * text line in ib[] + * int lkerr error flag + * + * functions called: + * char getnb() lklex.c + * VOID * new() lksym.c + * int strlen() c_library + * char * strcpy() c_library + * VOID unget() lklex.c + * + * side effects: + * The globlp structure is created. + */ + +VOID +gblsav() +{ + if (globlp == NULL) { + globlp = (struct globl *) + new (sizeof (struct globl)); + gsp = globlp; + } else { + gsp->g_globl = (struct globl *) + new (sizeof (struct globl)); + gsp = gsp->g_globl; + } + unget(getnb()); + gsp->g_strp = (char *) new (strlen(ip)+1); + strcpy(gsp->g_strp, ip); +} + +/*)Function VOID setgbl() + * + * The function setgbl() scans the global variable lines in hte + * globlp structure, evaluates the arguments, and sets a variable + * to this value. + * + * local variables: + * int v expression value + * char id[] base id string + * sym * sp pointer to a symbol structure + * + * global variables: + * char *ip pointer into the REL file + * text line in ib[] + * globl *globlp The pointer to the first + * globl structure + * globl *gsp Pointer to the current + * globl structure + * FILE * stderr c_library + * int lkerr error flag + * + * functions called: + * addr_t expr() lkeval.c + * int fprintf() c_library + * VOID getid() lklex.c + * char getnb() lklex.c + * sym * lkpsym() lksym.c + * + * side effects: + * The value of a variable is set. + */ + +VOID +setgbl() +{ + register v; + register struct sym *sp; + char id[NCPS]; + + gsp = globlp; + while (gsp) { + ip = gsp->g_strp; + getid(id, -1); + if (getnb() == '=') { + v = expr(0); + sp = lkpsym(id, 0); + if (sp == NULL) { +#ifndef SDK + fprintf(stderr, + "No definition of symbol %s\n", id); + lkerr++; +#endif /* SDK */ + } else { +#ifndef SDK + if (sp->s_flag & S_DEF) { + fprintf(stderr, + "Redefinition of symbol %s\n", id); + lkerr++; + sp->s_axp = NULL; + } +#endif /* SDK */ + sp->s_addr = v; + sp->s_type |= S_DEF; + } + } else { + fprintf(stderr, "No '=' in global expression"); + lkerr++; + } + gsp = gsp->g_globl; + } +} + +/*)Function FILE * afile(fn,, ft, wf) + * + * char * fn file specification string + * char * ft file type string + * int wf read(0)/write(1) flag + * + * The function afile() opens a file for reading or writing. + * (1) If the file type specification string ft + * is not NULL then a file specification is + * constructed with the file path\name in fn + * and the extension in ft. + * (2) If the file type specification string ft + * is NULL then the file specification is + * constructed from fn. If fn does not have + * a file type then the default .rel file + * type is appended to the file specification. + * + * afile() returns a file handle for the opened file or aborts + * the assembler on an open error. + * + * local variables: + * int c character value + * char fb[] constructed file specification string + * FILE * fp filehandle for opened file + * char * p1 pointer to filespec string fn + * char * p2 pointer to filespec string fb + * char * p3 pointer to filetype string ft + * + * global variables: + * int lkerr error flag + * + * functions called: + * FILE * fopen() c_library + * int fprintf() c_library + * + * side effects: + * File is opened for read or write. + */ + +FILE * +afile(fn, ft, wf) +char *fn; +char *ft; +{ + register char *p1, *p2, *p3; + register c; + FILE *fp; + char fb[FILSPC]; + + p1 = fn; + p2 = fb; + p3 = ft; + while ((c = *p1++) != 0 && c != FSEPX) { + if (p2 < &fb[FILSPC-4]) + *p2++ = c; + } + *p2++ = FSEPX; + if (*p3 == 0) { + if (c == FSEPX) { + p3 = p1; + } else { +#ifdef SDK + p3 = "rel"; +#else /* SDK */ + p3 = "REL"; +#endif /* SDK */ + } + } + while ((c = *p3++) != 0) { + if (p2 < &fb[FILSPC-1]) + *p2++ = c; + } + *p2++ = 0; +#ifdef SDK + if ((fp = fopen(fb, wf?(binary?"wb":"w"):(binary?"rb":"r"))) == NULL) { +#else /* SDK */ + if ((fp = fopen(fb, wf?"w":"r")) == NULL) { +#endif /* SDK */ + fprintf(stderr, "%s: cannot %s.\n", fb, wf?"create":"open"); + lkerr++; + } + return (fp); +} + +char *usetxt[] = { +#ifdef SDK + "Distributed with SDK " SDK_VERSION_STRING ", built on " __DATE__ " " __TIME__, + "Compile options: SDK Target " TARGET_STRING +#ifdef INDEXLIB + " INDEXLIB" +#endif + "\n", +#endif + "Startup:", +#ifdef SDK + " -- [Commands] Non-interactive command line input", +#endif /* SDK */ + " -c Command line input", + " -f file[LNK] File input", + " -p Prompt and echo of file[LNK] to stdout (default)", + " -n No echo of file[LNK] to stdout", +#ifdef SDK + "Usage: [-Options] outfile file [file ...]", +#else /* SDK */ + "Usage: [-Options] file [file ...]", +#endif /* SDK */ + "Librarys:", + " -k Library path specification, one per -k", + " -l Library file specification, one per -l", + "Relocation:", + " -b area base address = expression", + " -g global symbol = expression", +#ifdef GAMEBOY + " -yo Number of rom banks (default: 2)", + " -ya Number of ram banks (default: 0)", + " -yt MBC type (default: no MBC)", + " -yn Name of program (default: name of output file)", + " -yp# Patch one byte in the output GB file (# is: addr=byte)", +#endif /* GAMEBOY */ + "Map format:", + " -m Map output generated as file[MAP]", +#ifdef SDK + " -j no$gmb symbol file generated as file[SYM]", +#endif /* SDK */ + " -x Hexidecimal (default)", + " -d Decimal", + " -q Octal", + "Output:", + " -i Intel Hex as file[IHX]", + " -s Motorola S19 as file[S19]", +#ifdef SDK +#ifdef GAMEGEAR + " -z Gamegear image as file[GG]", +#else + " -z Gameboy image as file[GB]", +#endif /* GAMEGEAR */ +#endif /* SDK */ + "List:", + " -u Update listing file(s) with link data as file(s)[.RST]", + "End:", + " -e or null line terminates input", + "", + 0 +}; + +/*)Function VOID usage() + * + * The function usage() outputs to the stderr device the + * assembler name and version and a list of valid assembler options. + * + * local variables: + * char ** dp pointer to an array of + * text string pointers. + * + * global variables: + * FILE * stderr c_library + * + * functions called: + * int fprintf() c_library + * + * side effects: + * none + */ + +VOID +usage() +{ + register char **dp; + + fprintf(stderr, "\nASxxxx Linker %s\n\n", VERSION); + for (dp = usetxt; *dp; dp++) + fprintf(stderr, "%s\n", *dp); + lkexit(1); +} diff --git a/link/z80/lkrloc.c b/link/z80/lkrloc.c new file mode 100644 index 00000000..d5873e05 --- /dev/null +++ b/link/z80/lkrloc.c @@ -0,0 +1,1169 @@ +/* lkrloc.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +/* + * Extensions: P. Felber + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lkrloc.c + * + * The module lkrloc.c contains the functions which + * perform the relocation calculations. + * + * lkrloc.c contains the following functions: + * addr_t adb_b() + * addr_t adb_lo() + * addr_t adb_hi() + * addr_t adw_w() + * addr_t adw_lo() + * addr_t adw_hi() + * VOID erpdmp() + * VOID errdmp() + * addr_t evword() + * VOID prntval() + * VOID rele() + * VOID relerr() + * VOID relerp() + * VOID reloc() + * VOID relp() + * VOID relr() + * VOID relt() + * + * lkrloc.c the local variable errmsg[]. + * + */ + +/*)Function VOID reloc(c) + * + * char c process code + * + * The function reloc() calls a particular relocation + * function determined by the process code. + * + * local variable: + * none + * + * global variables: + * int lkerr error flag + * + * called functions: + * int fprintf() c_library + * VOID rele() lkrloc.c + * VOID relp() lkrloc.c + * VOID relr() lkrloc.c + * VOId relt() lkrloc.c + * + * side effects: + * Refer to the called relocation functions. + * + */ + +VOID +reloc(c) +char c; +{ + switch(c) { + + case 'T': + relt(); + break; + + case 'R': + relr(); + break; + + case 'P': + relp(); + break; + + case 'E': + rele(); + break; + + default: + fprintf(stderr, "Undefined Relocation Operation\n"); + lkerr++; + break; + + } +} + + +/*)Function VOID relt() + * + * The function relt() evaluates a T line read by + * the linker. Each byte value read is saved in the + * rtval[] array, rtflg[] is set, and the number of + * evaluations is maintained in rtcnt. + * + * T Line + * + * T xx xx nn nn nn nn nn ... + * + * + * In: "T n0 n1 n2 n3 ... nn" + * + * Out: 0 1 2 .. rtcnt + * +----+----+----+----+----+ + * rtval | n0 | n1 | n2 | .. | nn | + * +----+----+----+----+----+ + * rtflag| 1 | 1 | 1 | 1 | 1 | + * +----+----+----+----+----+ + * + * The T line contains the assembled code output by the assem- + * bler with xx xx being the offset address from the current area + * base address and nn being the assembled instructions and data in + * byte format. + * + * local variable: + * none + * + * global variables: + * int rtcnt number of values evaluated + * int rtflg[] array of evaluation flags + * int rtval[] array of evaluation values + * + * called functions: + * int eval() lkeval.c + * int more() lklex.c + * + * side effects: + * Linker input T line evaluated. + * + */ + +VOID +relt() +{ + rtcnt = 0; + while (more()) { + if (rtcnt < NTXT) { + rtval[rtcnt] = eval(); + rtflg[rtcnt] = 1; + rtcnt++; + } + } +} + +/*)Function VOID relr() + * + * The function relr() evaluates a R line read by + * the linker. The R line data is combined with the + * previous T line data to perform the relocation of + * code and data bytes. The S19 / IHX output and + * translation of the LST files to RST files may be + * performed. + * + * R Line + * + * R 0 0 nn nn n1 n2 xx xx ... + * + * The R line provides the relocation information to the linker. + * The nn nn value is the current area index, i.e. which area the + * current values were assembled. Relocation information is en- + * coded in groups of 4 bytes: + * + * 1. n1 is the relocation mode and object format + * 1. bit 0 word(0x00)/byte(0x01) + * 2. bit 1 relocatable area(0x00)/symbol(0x02) + * 3. bit 2 normal(0x00)/PC relative(0x04) relocation + * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for + * byte data + * 5. bit 4 signed(0x00)/unsigned(0x10) byte data + * 6. bit 5 normal(0x00)/page '0'(0x20) reference + * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference + * + * 2. n2 is a byte index into the corresponding (i.e. pre- + * ceeding) T line data (i.e. a pointer to the data to be + * updated by the relocation). The T line data may be + * 1-byte or 2-byte byte data format or 2-byte word + * format. + * + * 3. xx xx is the area/symbol index for the area/symbol be- + * ing referenced. the corresponding area/symbol is found + * in the header area/symbol lists. + * + * The groups of 4 bytes are repeated for each item requiring relo- + * cation in the preceeding T line. + * + * local variable: + * areax **a pointer to array of area pointers + * int aindex area index + * char *errmsg[] array of pointers to error strings + * int error error code + * int lkerr error flag + * int mode relocation mode + * adrr_t paga paging base area address + * addr_t pags paging symbol address + * addr_t pc relocated base address + * addr_t r PCR relocation value + * addr_t reli relocation initial value + * addr_t relv relocation final value + * int rindex symbol / area index + * addr_t rtbase base code address + * addr_t rtofst rtval[] index offset + * int rtp index into T data + * sym **s pointer to array of symbol pointers + * + * global variables: + * head *hp pointer to the head structure + * rerr rerr linker error structure + * FILE *stderr standard error device + * + * called functions: + * addr_t adb_b() lkrloc.c + * addr_t adb_lo() lkrloc.c + * addr_t adb_hi() lkrloc.c + * addr_t adw_w() lkrloc.c + * addr_t evword() lkrloc.c + * int eval() lkeval.c + * int fprintf() c_library + * VOID ihx() lkihx.c + * int lkulist lklist.c + * int more() lklex.c + * VOID relerr() lkrloc.c + * VOID s19() lks19.c + * int symval() lksym.c + * + * side effects: + * The R and T lines are combined to produce + * relocated code and data. Output S19 / IHX + * and relocated listing files may be produced. + * + */ + +VOID +relr() +{ + register mode; + register addr_t reli, relv; + int aindex, rindex, rtp, error; + addr_t r, rtbase, rtofst, paga, pags, pc; + struct areax **a; + struct sym **s; + + /* + * Get area and symbol lists + */ + a = hp->a_list; + s = hp->s_list; + + /* + * Verify Area Mode + */ + if (eval() != (R_WORD | R_AREA) || eval()) { + fprintf(stderr, "R input error\n"); + lkerr++; + } + + /* + * Get area pointer + */ + aindex = evword(); + if (aindex >= hp->h_narea) { + fprintf(stderr, "R area error\n"); + lkerr++; + return; + } + + /* + * Base values + */ + rtbase = adw_w(0, 0); + rtofst = 2; + + /* + * Relocate address + */ + pc = adw_w(a[aindex]->a_addr, 0); + +#ifdef GAMEBOY + { + char *s = strrchr(a[aindex]->a_bap->a_id, '_'); + if(s != NULL && isdigit(s[1])) + current_rom_bank = atoi(s+1); + else + current_rom_bank = 0; + } +#endif /* GAMEBOY */ + /* + * Do remaining relocations + */ + while (more()) { + error = 0; + mode = eval(); + rtp = eval(); + rindex = evword(); + + /* + * R_SYM or R_AREA references + */ + if (mode & R_SYM) { + if (rindex >= hp->h_nglob) { + fprintf(stderr, "R symbol error\n"); + lkerr++; + return; + } + reli = symval(s[rindex]); + } else { + if (rindex >= hp->h_narea) { + fprintf(stderr, "R area error\n"); + lkerr++; + return; + } + reli = a[rindex]->a_addr; + } + + /* + * R_PCR addressing + */ + if (mode & R_PCR) { + if (mode & R_BYTE) { + reli -= (pc + (rtp-rtofst) + 1); + } else { + reli -= (pc + (rtp-rtofst) + 2); + } + } + + /* + * R_PAG0 or R_PAG addressing + */ + if (mode & (R_PAG0|R_PAG)) { + paga = sdp.s_area->a_addr; + pags = sdp.s_addr; + reli -= paga + pags; + } + + /* + * R_BYTE or R_WORD operation + */ + if (mode & R_BYTE) { + if (mode & R_BYT2) { + if (mode & R_MSB) { + relv = adb_hi(reli, rtp); + } else { + relv = adb_lo(reli, rtp); + } + } else { + relv = adb_b(reli, rtp); + } + } else { + /* + * R_WORD with the R_BYT2 mode is flagged + * as an 'r' error by the assembler, + * but it is processed here anyway. + */ + if (mode & R_BYT2) { + if (mode & R_MSB) { + relv = adw_hi(reli, rtp); + } else { + relv = adw_lo(reli, rtp); + } + } else { + relv = adw_w(reli, rtp); + } + } + + /* + * R_BYTE with R_BYT2 offset adjust + */ + if (mode & R_BYTE) { + if (mode & R_BYT2) { + rtofst += 1; + } + } + + /* + * Unsigned Byte Checking + */ + if (mode & R_USGN && mode & R_BYTE && relv & ~0xFF) + error = 1; + + /* + * PCR Relocation Error Checking + */ + if (mode & R_PCR && mode & R_BYTE) { + r = relv & ~0x7F; + if (r != (addr_t) ~0x7F && r != 0) + error = 2; + } + + /* + * Page Relocation Error Checking + */ + if (mode & R_PAG0 && (relv & ~0xFF || paga || pags)) + error = 3; + if (mode & R_PAG && (relv & ~0xFF)) + error = 4; + + /* + * Error Processing + */ + if (error) { + rerr.aindex = aindex; + rerr.mode = mode; + rerr.rtbase = rtbase + rtp - rtofst - 1; + rerr.rindex = rindex; + rerr.rval = relv - reli; + relerr(errmsg[error-1]); + } + } + if (uflag != 0) { + lkulist(1); + } + if (oflag == 1) { + ihx(1); + } else + if (oflag == 2) { + s19(1); +#ifdef SDK + } else + if (oflag == 3) { +#ifdef GAMEGEAR + gg(1); +#endif /* GAMEGEAR */ +#ifdef GAMEBOY + gb(1); +#endif /* GAMEBOY */ +#endif /* SDK */ + } +} + +char *errmsg[] = { + "Unsigned Byte error", + "Byte PCR relocation error", + "Page0 relocation error", + "Page Mode relocation error" +}; + + +/*)Function VOID relp() + * + * The function relp() evaluates a P line read by + * the linker. The P line data is combined with the + * previous T line data to set the base page address + * and test the paging boundary and length. + * + * P Line + * + * P 0 0 nn nn n1 n2 xx xx + * + * The P line provides the paging information to the linker as + * specified by a .setdp directive. The format of the relocation + * information is identical to that of the R line. The correspond- + * ing T line has the following information: + * T xx xx aa aa bb bb + * + * Where aa aa is the area reference number which specifies the + * selected page area and bb bb is the base address of the page. + * bb bb will require relocation processing if the 'n1 n2 xx xx' is + * specified in the P line. The linker will verify that the base + * address is on a 256 byte boundary and that the page length of an + * area defined with the PAG type is not larger than 256 bytes. + * + * local variable: + * areax **a pointer to array of area pointers + * int aindex area index + * int mode relocation mode + * addr_t relv relocation value + * int rindex symbol / area index + * int rtp index into T data + * sym **s pointer to array of symbol pointers + * + * global variables: + * head *hp pointer to the head structure + * int lkerr error flag + * sdp sdp base page structure + * FILE *stderr standard error device + * + * called functions: + * addr_t adw_w() lkrloc.c + * addr_t evword() lkrloc.c + * int eval() lkeval.c + * int fprintf() c_library + * int more() lklex.c + * int symval() lksym.c + * + * side effects: + * The P and T lines are combined to set + * the base page address and report any + * paging errors. + * + */ + +VOID +relp() +{ + register aindex, rindex; + int mode, rtp; + addr_t relv; + struct areax **a; + struct sym **s; + + /* + * Get area and symbol lists + */ + a = hp->a_list; + s = hp->s_list; + + /* + * Verify Area Mode + */ + if (eval() != (R_WORD | R_AREA) || eval()) { + fprintf(stderr, "P input error\n"); + lkerr++; + } + + /* + * Get area pointer + */ + aindex = evword(); + if (aindex >= hp->h_narea) { + fprintf(stderr, "P area error\n"); + lkerr++; + return; + } + + /* + * Do remaining relocations + */ + while (more()) { + mode = eval(); + rtp = eval(); + rindex = evword(); + + /* + * R_SYM or R_AREA references + */ + if (mode & R_SYM) { + if (rindex >= hp->h_nglob) { + fprintf(stderr, "P symbol error\n"); + lkerr++; + return; + } + relv = symval(s[rindex]); + } else { + if (rindex >= hp->h_narea) { + fprintf(stderr, "P area error\n"); + lkerr++; + return; + } + relv = a[rindex]->a_addr; + } + adw_w(relv, rtp); + } + + /* + * Paged values + */ + aindex = adw_w(0,2); + if (aindex >= hp->h_narea) { + fprintf(stderr, "P area error\n"); + lkerr++; + return; + } + sdp.s_areax = a[aindex]; + sdp.s_area = sdp.s_areax->a_bap; + sdp.s_addr = adw_w(0,4); + if (sdp.s_area->a_addr & 0xFF || sdp.s_addr & 0xFF) + relerp("Page Definition Boundary Error"); +} + +/*)Function VOID rele() + * + * The function rele() closes all open output files + * at the end of the linking process. + * + * local variable: + * none + * + * global variables: + * int oflag output type flag + * int uflag relocation listing flag + * + * called functions: + * VOID ihx() lkihx.c + * VOID lkulist() lklist.c + * VOID s19() lks19.c + * + * side effects: + * All open output files are closed. + * + */ + +VOID +rele() +{ + if (uflag != 0) { + lkulist(0); + } + if (oflag == 1) { + ihx(0); + } else + if (oflag == 2) { + s19(0); +#ifdef SDK + } else + if (oflag == 3) { +#ifdef GAMEGEAR + gg(0); +#endif /* GAMEGEAR */ +#ifdef GAMEBOY + gb(0); +#endif /* GAMEBOY */ +#endif /* SDK */ + } +} + +/*)Function addr_t evword() + * + * The function evword() combines two byte values + * into a single word value. + * + * local variable: + * addr_t v temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * int eval() lkeval.c + * + * side effects: + * Relocation text line is scanned to combine + * two byte values into a single word value. + * + */ + +addr_t +evword() +{ + register addr_t v; + + if (hilo) { + v = (eval() << 8); + v += eval(); + } else { + v = eval(); + v += (eval() << 8); + } + return(v); +} + +/*)Function addr_t adb_b(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adb_b() adds the value of v to + * the single byte value contained in rtval[i]. + * The new value of rtval[i] is returned. + * + * local variable: + * none + * + * global variables: + * none + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * + */ + +addr_t +adb_b(v, i) +register addr_t v; +register int i; +{ + return(rtval[i] += v); +} + +/*)Function addr_t adb_lo(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adb_lo() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The MSB rtflg[] is cleared. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The rtflg[] value corresponding to the + * MSB of the word value is cleared to reflect + * the fact that the LSB is the selected byte. + * + */ + +addr_t +adb_lo(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * Remove Hi byte + */ + if (hilo) { + rtflg[i] = 0; + } else { + rtflg[i+1] = 0; + } + return (j); +} + +/*)Function addr_t adb_hi(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adb_hi() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The LSB rtflg[] is cleared. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The rtflg[] value corresponding to the + * LSB of the word value is cleared to reflect + * the fact that the MSB is the selected byte. + * + */ + +addr_t +adb_hi(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * Remove Lo byte + */ + if (hilo) { + rtflg[i+1] = 0; + } else { + rtflg[i] = 0; + } + return (j); +} + +/*)Function addr_t adw_w(v, i) + * + * int v value to add to word + * int i rtval[] index + * + * The function adw_w() adds the value of v to the + * word value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The word value of rtval[] is changed. + * + */ + +addr_t +adw_w(v, i) +register addr_t v; +register int i; +{ + register addr_t j; + + if (hilo) { + j = v + (rtval[i] << 8) + (rtval[i+1] & 0xff); + rtval[i] = (j >> 8) & 0xff; + rtval[i+1] = j & 0xff; + } else { + j = v + (rtval[i] & 0xff) + (rtval[i+1] << 8); + rtval[i] = j & 0xff; + rtval[i+1] = (j >> 8) & 0xff; + } + return(j); +} + +/*)Function addr_t adw_lo(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adw_lo() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The MSB rtval[] is zeroed. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The MSB of the word value is cleared to reflect + * the fact that the LSB is the selected byte. + * + */ + +addr_t +adw_lo(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * Clear Hi byte + */ + if (hilo) { + rtval[i] = 0; + } else { + rtval[i+1] = 0; + } + return (j); +} + +/*)Function addr_t adw_hi(v, i) + * + * int v value to add to byte + * int i rtval[] index + * + * The function adw_hi() adds the value of v to the + * double byte value contained in rtval[i] and rtval[i+1]. + * The new value of rtval[i] / rtval[i+1] is returned. + * The MSB and LSB values are interchanged. + * The MSB rtval[] is zeroed. + * + * local variable: + * addr_t j temporary evaluation variable + * + * global variables: + * hilo byte ordering parameter + * + * called functions: + * none + * + * side effects: + * The value of rtval[] is changed. + * The MSB and LSB values are interchanged and + * then the MSB cleared. + * + */ + +addr_t +adw_hi(v, i) +addr_t v; +int i; +{ + register addr_t j; + + j = adw_w(v, i); + /* + * LSB = MSB, Clear MSB + */ + if (hilo) { + rtval[i+1] = rtval[i]; + rtval[i] = 0; + } else { + rtval[i] = rtval[i+1]; + rtval[i+1] = 0; + } + return (j); +} + +/*)Function VOID relerr(str) + * + * char *str error string + * + * The function relerr() outputs the error string to + * stderr and to the map file (if it is open). + * + * local variable: + * none + * + * global variables: + * FILE *mfp handle for the map file + * + * called functions: + * VOID errdmp() lkrloc.c + * + * side effects: + * Error message inserted into map file. + * + */ + +VOID +relerr(str) +char *str; +{ + errdmp(stderr, str); + if (mfp) + errdmp(mfp, str); +} + +/*)Function VOID errdmp(fptr, str) + * + * FILE *fptr output file handle + * char *str error string + * + * The function errdmp() outputs the error string str + * to the device specified by fptr. Additional information + * is output about the definition and referencing of + * the symbol / area error. + * + * local variable: + * int mode error mode + * int aindex area index + * int lkerr error flag + * int rindex error index + * sym **s pointer to array of symbol pointers + * areax **a pointer to array of area pointers + * areax *raxp error area extension pointer + * + * global variables: + * sdp sdp base page structure + * + * called functions: + * int fprintf() c_library + * VOID prntval() lkrloc.c + * + * side effects: + * Error reported. + * + */ + +VOID +errdmp(fptr, str) +FILE *fptr; +char *str; +{ + int mode, aindex, rindex; + struct sym **s; + struct areax **a; + struct areax *raxp; + + a = hp->a_list; + s = hp->s_list; + + mode = rerr.mode; + aindex = rerr.aindex; + rindex = rerr.rindex; + + /* + * Print Error + */ + fprintf(fptr, "\n?ASlink-Warning-%s", str); + lkerr++; + + /* + * Print symbol if symbol based + */ + if (mode & R_SYM) { + fprintf(fptr, " for symbol %.*s\n", + NCPS, &s[rindex]->s_id[0]); + } else { + fprintf(fptr, "\n"); + } + + /* + * Print Ref Info + */ + fprintf(fptr, + " file module area offset\n"); + fprintf(fptr, + " Refby %-8.8s %-8.8s %-8.8s ", + hp->h_lfile->f_idp, + &hp->m_id[0], + &a[aindex]->a_bap->a_id[0]); + prntval(fptr, rerr.rtbase); + + /* + * Print Def Info + */ + if (mode & R_SYM) { + raxp = s[rindex]->s_axp; + } else { + raxp = a[rindex]; + } + fprintf(fptr, + " Defin %-8.8s %-8.8s %-8.8s ", + raxp->a_bhp->h_lfile->f_idp, + &raxp->a_bhp->m_id[0], + &raxp->a_bap->a_id[0]); + if (mode & R_SYM) { + prntval(fptr, s[rindex]->s_addr); + } else { + prntval(fptr, rerr.rval); + } +} + +/*)Function VOID prntval(fptr, v) + * + * FILE *fptr output file handle + * addr_t v value to output + * + * The function prntval() outputs the value v, in the + * currently selected radix, to the device specified + * by fptr. + * + * local variable: + * none + * + * global variables: + * int xflag current radix + * + * called functions: + * int fprintf() c_library + * + * side effects: + * none + * + */ + +VOID +prntval(fptr, v) +FILE *fptr; +addr_t v; +{ + if (xflag == 0) { + fprintf(fptr, "%04X\n", v); + } else + if (xflag == 1) { + fprintf(fptr, "%06o\n", v); + } else + if (xflag == 2) { + fprintf(fptr, "%05u\n", v); + } +} + +/*)Function VOID relerp(str) + * + * char *str error string + * + * The function relerp() outputs the paging error string to + * stderr and to the map file (if it is open). + * + * local variable: + * none + * + * global variables: + * FILE *mfp handle for the map file + * + * called functions: + * VOID erpdmp() lkrloc.c + * + * side effects: + * Error message inserted into map file. + * + */ + +VOID +relerp(str) +char *str; +{ + erpdmp(stderr, str); + if (mfp) + erpdmp(mfp, str); +} + +/*)Function VOID erpdmp(fptr, str) + * + * FILE *fptr output file handle + * char *str error string + * + * The function erpdmp() outputs the error string str + * to the device specified by fptr. + * + * local variable: + * head *thp pointer to head structure + * + * global variables: + * int lkerr error flag + * sdp sdp base page structure + * + * called functions: + * int fprintf() c_library + * VOID prntval() lkrloc.c + * + * side effects: + * Error reported. + * + */ + +VOID +erpdmp(fptr, str) +FILE *fptr; +char *str; +{ + register struct head *thp; + + thp = sdp.s_areax->a_bhp; + + /* + * Print Error + */ + fprintf(fptr, "\n?ASlink-Warning-%s\n", str); + lkerr++; + + /* + * Print PgDef Info + */ + fprintf(fptr, + " file module pgarea pgoffset\n"); + fprintf(fptr, + " PgDef %-8.8s %-8.8s %-8.8s ", + thp->h_lfile->f_idp, + &thp->m_id[0], + &sdp.s_area->a_id[0]); + prntval(fptr, sdp.s_area->a_addr + sdp.s_addr); +} diff --git a/link/z80/lks19.c b/link/z80/lks19.c new file mode 100644 index 00000000..cfbb5d18 --- /dev/null +++ b/link/z80/lks19.c @@ -0,0 +1,123 @@ +/* lks19.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lks19.c + * + * The module lks19.c contains the function to + * output the relocated object code in the + * Motorola S19 format. + * + * lks19.c contains the following function: + * VOID s19(i) + * + * lks19.c contains no local variables. + */ + +/*)S19 Format + * Record Type Field - This field signifies the start of a + * record and identifies the the record + * type as follows: + * + * Ascii S1 - Data Record + * Ascii S9 - End of File Record + * + * Record Length Field - This field specifies the record length + * which includes the address, data, and + * checksum fields. The 8 bit record + * length value is converted to two ascii + * characters, high digit first. + * + * Load Address Field - This field consists of the four ascii + * characters which result from converting + * the the binary value of the address in + * which to begin loading this record. The + * order is as follows: + * + * High digit of high byte of address. + * Low digit of high byte of address. + * High digit of low byte of address. + * Low digit of low byte of address. + * + * In an End of File record this field con- + * sists of either four ascii zeros or the + * program entry address. Currently the + * entry address option is not supported. + * + * Data Field - This field consists of the actual data, + * converted to two ascii characters, high + * digit first. There are no data bytes in + * the End of File record. + * + * Checksum Field - The checksum field is the 8 bit binary + * sum of the record length field, the load + * address field, and the data field. This + * sum is then complemented (1's comple- + * ment) and converted to two ascii + * characters, high digit first. + */ + +/*)Function s19(i) + * + * int i 0 - process data + * 1 - end of data + * + * The function s19() outputs the relocated data + * in the standard Motorola S19 format. + * + * local variables: + * addr_t chksum byte checksum + * + * global variables: + * int hilo byte order + * FILE * ofp output file handle + * int rtcnt count of data words + * int rtflg[] output the data flag + * addr_t rtval[] relocated data + * + * functions called: + * int fprintf() c_library + * + * side effects: + * The data is output to the file defined by ofp. + */ + +VOID +s19(i) +{ + register addr_t chksum; + + if (i) { + if (hilo == 0) { + chksum = rtval[0]; + rtval[0] = rtval[1]; + rtval[1] = chksum; + } + for (i = 0, chksum = 1; i < rtcnt; i++) { + if (rtflg[i]) + chksum++; + } + fprintf(ofp, "S1%02X", chksum); + for (i = 0; i < rtcnt ; i++) { + if (rtflg[i]) { + fprintf(ofp, "%02X", rtval[i]); + chksum += rtval[i]; + } + } + fprintf(ofp, "%02X\n", (-chksum-1) & 0xff); + } else { + fprintf(ofp, "S9030000FC\n"); + } +} diff --git a/link/z80/lksym.c b/link/z80/lksym.c new file mode 100644 index 00000000..03b96b92 --- /dev/null +++ b/link/z80/lksym.c @@ -0,0 +1,494 @@ +/* lksym.c */ + +/* + * (C) Copyright 1989-1995 + * All Rights Reserved + * + * Alan R. Baldwin + * 721 Berkeley St. + * Kent, Ohio 44240 + */ + +#include +#include +#include +#include "aslink.h" + +/*)Module lksym.c + * + * The module lksym.c contains the functions that operate + * on the symbol structures. + * + * lksym.c contains the following functions: + * int hash() + * sym * lkpsym() + * VOID * new() + * sym * newsym() + * VOID symdef() + * int symeq() + * VOID syminit() + * VOID symmod() + * addr_t symval() + * + * lksym.c contains no local/static variables. + */ + +/*)Function VOID syminit() + * + * The function syminit() is called to clear the hashtable. + * + * local variables: + * int h computed hash value + * sym ** spp pointer to an array of + * sym structure pointers + * + * global variables: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * none + * + * side effects: + * (1) The symbol hash tables are cleared + */ + +VOID +syminit() +{ + register h; + struct sym **spp; + + spp = &symhash[0]; + while (spp < &symhash[NHASH]) + *spp++ = NULL; +} + +/*)Function sym * newsym() + * + * The function newsym() is called to evaluate the symbol + * definition/reference directive from the .rel file(s). + * If the symbol is not found in the symbol table a new + * symbol structure is created. Evaluation of the + * directive determines if this is a reference or a definition. + * Multiple definitions of the same variable will be flagged + * as an error if the values are not identical. A symbol + * definition places the symbol value and area extension + * into the symbols data structure. And finally, a pointer + * to the symbol structure is placed into the head structure + * symbol list. Refer to the description of the header, symbol, + * area, and areax structures in lkdata.c for structure and + * linkage details. + * + * local variables: + * int c character from input text + * int i evaluation value + * char id[] symbol name + * int nglob number of symbols in this header + * sym * tsp pointer to symbol structure + * sym ** s list of pointers to symbol structures + * + * global variables: + * areax *axp Pointer to the current + * areax structure + * head *headp The pointer to the first + * head structure of a linked list + * int lkerr error flag + * + * functions called: + * addr_t eval() lkeval.c + * VOID exit() c_library + * int fprintf() c_library + * char get() lklex.c + * char getnb() lklex.c + * sym * lkpsym() lksym.c + * + * side effects: + * A symbol structure is created and/or modified. + * If structure space allocation fails linker will abort. + * Several severe errors (these are internal errors + * indicating a corrupted .rel file or corrupted + * assembler or linker) will terminated the linker. + */ + +/* + * Find/Create a global symbol entry. + * + * S xxxxxx Defnnnn + * | | | + * | | `-- sp->s_addr + * | `----- sp->s_type + * `------------ sp->s_id + * + */ +struct sym * +newsym() +{ + register c, i, nglob; + struct sym *tsp; + struct sym **s; + char id[NCPS]; + + getid(id, -1); + tsp = lkpsym(id, 1); + c = getnb();get();get(); + if (c == 'R') { + tsp->s_type |= S_REF; + if (eval()) { + fprintf(stderr, "Non zero S_REF\n"); + lkerr++; + } + } else + if (c == 'D') { + i = eval(); + if (tsp->s_type & S_DEF && tsp->s_addr != i) { +#ifdef SDK + fprintf(stderr, "Multiple definition of %s\n", id); +#else + fprintf(stderr, "Multiple definition of %.8s\n", id); +#endif + lkerr++; + } + tsp->s_type |= S_DEF; + /* + * Set value and area extension link. + */ + tsp->s_addr = i; + tsp->s_axp = axp; + } else { + fprintf(stderr, "Invalid symbol type %c for %.8s\n", c, id); + lkexit(1); + } + /* + * Place pointer in header symbol list + */ + if (headp == NULL) { + fprintf(stderr, "No header defined\n"); + lkexit(1); + } + nglob = hp->h_nglob; + s = hp->s_list; + for (i=0; i < nglob ;++i) { + if (s[i] == NULL) { + s[i] = tsp; + return(tsp); + } + } + fprintf(stderr, "Header symbol list overflow\n"); + lkexit(1); +} + +/*)Function sym * lkpsym(id,f) + * + * char * id symbol name string + * int f f == 0, lookup only + * f != 0, create if not found + * + * The function lookup() searches the symbol hash tables for + * a symbol name match returning a pointer to the sym structure. + * If the symbol is not found then a sym structure is created, + * initialized, and linked to the appropriate hash table if f != 0. + * A pointer to this new sym structure is returned or a NULL + * pointer is returned if f == 0. + * + * local variables: + * int h computed hash value + * sym * sp pointer to a sym structure + * + * global varaibles: + * sym * symhash[] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * int hash() lksym.c + * VOID * new() lksym.c + * int symeq() lksym.c + * + * side effects: + * If the function new() fails to allocate space + * for the new sym structure the linker terminates. + */ + +struct sym * +lkpsym(id, f) +char *id; +{ + register struct sym *sp; + register h; + + h = hash(id); + sp = symhash[h]; + while (sp != NULL) { + if (symeq(id, sp->s_id)) + return (sp); + sp = sp->s_sp; + } + if (f == 0) + return (NULL); + sp = (struct sym *) new (sizeof(struct sym)); + sp->s_sp = symhash[h]; + symhash[h] = sp; + strncpy(sp->s_id, id, NCPS); + return (sp); +} + +/*)Function addr_t symval(tsp) + * + * sym * tsp pointer to a symbol structure + * + * The function symval() returns the value of the + * relocated symbol by adding the variable definition + * value to the areax base address. + * + * local variables: + * addr_t val relocated address value + * + * global variables: + * none + * + * functions called: + * none + * + * side effects: + * none + */ + +addr_t +symval(tsp) +register struct sym *tsp; +{ + register addr_t val; + + val = tsp->s_addr; + if (tsp->s_axp) { + val += tsp->s_axp->a_addr; + } + return(val); +} + +/*)Function VOID symdef(fp) + * + * FILE * fp file handle for output + * + * The function symdef() scans the hashed symbol table + * searching for variables referenced but not defined. + * Undefined variables are linked to the default + * area "_CODE" and reported as referenced by the + * appropriate module. + * + * local variables: + * int i hash table index loop variable + * sym * sp pointer to linked symbol structure + * + * global variables: + * area *areap The pointer to the first + * area structure of a linked list + * sym *symhash[NHASH] array of pointers to NHASH + * linked symbol lists + * + * functions called: + * symmod() lksym.c + * + * side effects: + * Undefined variables have their areas set to "_CODE". + */ + +VOID +symdef(fp) +FILE *fp; +{ + register struct sym *sp; + register i; + + for (i=0; is_axp == NULL) + sp->s_axp = areap->a_axp; + if ((sp->s_type & S_DEF) == 0) + symmod(fp, sp); + sp = sp->s_sp; + } + } +} + +/*)Function VOID symmod(fp,tsp) + * + * FILE * fp output file handle + * sym * tsp pointer to a symbol structure + * + * The function symmod() scans the header structures + * searching for a reference to the symbol structure + * pointer to by tsp. The function then generates an error + * message whichs names the module having referenced the + * undefined variable. + * + * local variables: + * int i loop counter + * sym ** p pointer to a list of pointers + * to symbol structures + * + * global variables: + * head *headp The pointer to the first + * head structure of a linked list + * head *hp Pointer to the current + * head structure + * int lkerr error flag + * + * functions called: + * int fprintf() c_library + * + * side effects: + * Error output generated. + */ + +VOID +symmod(fp, tsp) +FILE *fp; +struct sym *tsp; +{ + register i, j; + struct sym **p; + + if ((hp = headp) != NULL) { + while(hp) { + p = hp->s_list; + for (i=0; ih_nglob; ++i) { + if (p[i] == tsp) { + fprintf(fp, "\n?ASlink-Warning-Undefined Global %s ", tsp->s_id); + fprintf(fp, "referenced by module %s\n", hp->m_id); + lkerr++; + } + } + hp = hp->h_hp; + } + } +} + +/*)Function int symeq(p1, p2) + * + * char * p1 name string + * char * p2 name string + * + * The function symeq() compares the two name strings for a match. + * The return value is 1 for a match and 0 for no match. + * + * local variables: + * int h loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + * + */ + +int +symeq(p1, p2) +register char *p1, *p2; +{ + register n; + + n = NCPS; + do { + +#if CASE_SENSITIVE + if (*p1++ != *p2++) + return (0); +#else + if (ccase[*p1++] != ccase[*p2++]) + return (0); +#endif + + } while (--n); + return (1); +} + +/*)Function int hash(p) + * + * char * p pointer to string to hash + * + * The function hash() computes a hash code using the sum + * of all characters mod table size algorithm. + * + * local variables: + * int h accumulated character sum + * int n loop counter + * + * global variables: + * char ccase[] an array of characters which + * perform the case translation function + * + * functions called: + * none + * + * side effects: + * none + * + */ + +int +hash(p) +register char *p; +{ + register h, n; + + h = 0; + n = NCPS; + do { + +#if CASE_SENSITIVE + h += *p++; +#else + h += ccase[*p++]; +#endif + + } while (--n); + return (h&HMASK); +} + +/*)Function VOID * new(n) + * + * unsigned int n allocation size in bytes + * + * The function new() allocates n bytes of space and returns + * a pointer to this memory. If no space is available the + * linker is terminated. + * + * local variables: + * char * p a general pointer + * char * q a general pointer + * + * global variables: + * none + * + * functions called: + * int fprintf() c_library + * VOID * malloc() c_library + * + * side effects: + * Memory is allocated, if allocation fails + * the linker is terminated. + */ + +VOID * +new(n) +unsigned int n; +{ + register char *p,*q; + register unsigned int i; + + if ((p = (char *) malloc(n)) == NULL) { + fprintf(stderr, "Out of space!\n"); + lkexit(1); + } + for (i=0,q=p; imain.dep + +#include main.dep +include clean.mk + +# My rules +# -------- +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +.y.c: + rm -f $*.cc $*.h + $(YACC) -d $< + mv y.tab.c $*.cc + mv y.tab.h $*.h + +.l.c: + rm -f $*.cc + $(LEX) -t $< >$*.cc + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" freshconf;\ + fi + +# End of main_in.mk/main.mk + diff --git a/sdccbuild.sh b/sdccbuild.sh new file mode 100644 index 00000000..f58b0792 --- /dev/null +++ b/sdccbuild.sh @@ -0,0 +1,216 @@ +# +sdccdir=$PWD +echo "/*-------------------------------------------------------------------------" +echo " sdccbuild.sh - installation & build script for SDCC" +echo +echo " Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)" +echo +echo " This program is free software; you can redistribute it and/or modify it" +echo " under the terms of the GNU General Public License as published by the" +echo " Free Software Foundation; either version 2, or (at your option) any" +echo " later version." +echo +echo " This program is distributed in the hope that it will be useful," +echo " but WITHOUT ANY WARRANTY; without even the implied warranty of" +echo " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" +echo " GNU General Public License for more details." +echo +echo " You should have received a copy of the GNU General Public License" +echo " along with this program; if not, write to the Free Software" +echo " Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA." +echo +echo " In other words, you are welcome to use, share and improve this program." +echo " You are forbidden to forbid anyone else to use, share and improve" +echo " what you give them. Help stamp out software-hoarding! " +echo "-------------------------------------------------------------------------*/" +echo +echo +echo "This script will compile and build sdcc compiler system. Executables will" +echo "be placed in the directory '" $sdccdir"/bin' . Make sure you add this" +echo " directory to your PATH environment variable." +echo +echo "Hit Enter to start the build process" +read junk +echo "----------------------------------------------------------" ; +echo " Building 'gc - a conservative garbage collector'" ; +echo "----------------------------------------------------------" ; + +if test -d $sdccdir/gc; + then cd $sdccdir/gc ; +# make -f Makefile clean + else + echo "----------------------------------------------------------" ; + echo " directory " $sdccdir/gc "not found . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +if make -f Makefile CC=gcc ; + then + echo "----------------------------------------------------------" ; + echo " gc - build successful" ; + echo "----------------------------------------------------------" ; + + else + echo "----------------------------------------------------------" ; + echo " gc - build failed . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +echo "----------------------------------------------------------" ; +echo " Building 'cpp - c-preprocessor'" ; +echo "----------------------------------------------------------" ; + +if test -d $sdccdir/cpp ; + then cd $sdccdir/cpp ; +# rm *.o ; + else + echo "----------------------------------------------------------" ; + echo " directory " $sdccdir/cpp "not found . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +if make -f Makefile SDCCDIR=$sdccdir; + then + echo "----------------------------------------------------------" ; + echo " cpp - build successful" ; + echo "----------------------------------------------------------" ; + + else + echo "----------------------------------------------------------" ; + echo " cpp - build failed . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +echo "----------------------------------------------------------" ; +echo " Building 'asx8051 - assembler'" ; +echo "----------------------------------------------------------" ; + +if test -d $sdccdir/asxxxx ; + then cd $sdccdir/asxxxx ; +# rm *.o ; + else + echo "----------------------------------------------------------" ; + echo " directory " $sdccdir/asxxxx "not found . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +if make -f Makefile.asx8051 SDCCDIR=$sdccdir ; + then + echo "----------------------------------------------------------" ; + echo " asx8051 - build successful" ; + echo "----------------------------------------------------------" ; + + else + echo "----------------------------------------------------------" ; + echo " asx8051 - build failed . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +echo "----------------------------------------------------------" ; +echo " Building 'aslink - linkage editor' " ; +echo "----------------------------------------------------------" ; + +if test -d $sdccdir/asxxxx ; + then cd $sdccdir/asxxxx ; +# rm *.o ; + else + echo "----------------------------------------------------------" ; + echo " directory " $sdccdir/asxxxx "not found . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +if make -f Makefile.aslink SDCCDIR=$sdccdir ; + then + echo "----------------------------------------------------------" ; + echo " aslink - build successful" ; + echo "----------------------------------------------------------" ; + + else + echo "----------------------------------------------------------" ; + echo " aslink - build failed . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +echo "----------------------------------------------------------" ; +echo " Building 'sdcc' " +echo "----------------------------------------------------------" ; + +cd $sdccdir +if test `uname` = "Linux"; + then + ldflag="-Wl,-defsym,_DYNAMIC=0" ; +fi + +#make -f Makefile clean +if make -f Makefile SDCCDIR=$sdccdir STD_LIB="libsdcc" STD_INT_LIB="libint" STD_LONG_LIB="liblong" STD_FP_LIB="libfloat" LDXFLAGS=$ldflag + then + echo "----------------------------------------------------------" ; + echo " sdcc - build successful" ; + echo "----------------------------------------------------------" ; + else + echo "----------------------------------------------------------" ; + echo " sdcc - build failed . Script terminated"; + echo "----------------------------------------------------------" ; + exit 1; +fi + +echo "----------------------------------------------------------" ; +echo " GREAT!! now we will use SDCC to compile the support rtns" +echo "----------------------------------------------------------" ; + +echo "To compile the support routines type 'Large' or 'Small' or Control-c to quit" +read size + +lowersize=`echo $size | awk '{ printf("%s", tolower($0)) }'` + +cd $sdccdir/sdcc51lib + +PATH_SEPARATOR=":" +if test `uname` = "MS-DOS"; + then + PATH_SEPARATOR=";" +fi + +PATH=$PATH$PATH_SEPARATOR$sdccdir/bin + +if test $lowersize = "large"; +then + echo "Compiling with the Large Model" + model="--model-large" +else + echo "Compiling with the Small Model" + model="--model-small" +fi + +for i in _*.c ; + do + echo "Compiling file " $i ; + sdcc -c $model -I$sdccdir/sdcc51inc $i ; + done; + +echo "Compiling file malloc.c" +sdcc -c $model malloc.c + +echo "Compiling file serial.c" +sdcc -c $model serial.c + + +echo "----------------------------------------------------------" ; +echo " Important Directories & files" +echo " Header <...h> files directory " $sdccdir"/sdcc51inc" +echo " Library .lib files directory " $sdccdir"/sdcc51lib" +echo " SDCC support libraries are :-" +echo " " $sdccdir"/sdcc51lib/libsdcc.lib - basic support routines" +echo " " $sdccdir"/sdcc51lib/libint.lib - (16 bit) arithmetic " +echo " " $sdccdir"/sdcc51lib/liblong.lib - (32 bit) arithmetic " +echo " " $sdccdir"/sdcc51lib/libfloat.lib- floating point routines" +echo " DON'T FORGET to add " $sdccdir"/bin to your PATH environment" +echo "----------------------------------------------------------" ; diff --git a/sdccconf_in.h b/sdccconf_in.h new file mode 100644 index 00000000..80abeae0 --- /dev/null +++ b/sdccconf_in.h @@ -0,0 +1,30 @@ +/* + */ + +#ifndef SDCCCONF_HEADER +#define SDCCCONF_HEADER + + +#undef SDCC_VERSION_HI +#undef SDCC_VERSION_LO +#undef SDCC_VERSION_P +#undef SDCC_VERSION_STR + +#undef PREFIX +#undef DATADIR +#undef SRCDIR + +#undef STANDARD_INCLUDE_DIR +#undef SDCC_INCLUDE_DIR +#undef SDCC_LIB_DIR +#undef STD_LIB +#undef STD_INT_LIB +#undef STD_LONG_LIB +#undef STD_FP_LIB +#undef HAVE_SYS_SOCKET_H +#undef HAVE_SYS_ISA_DEFS_H +#undef HAVE_ENDIAN_H + +#endif + +/* End of config.h */ diff --git a/sim/README b/sim/README new file mode 100644 index 00000000..e1fa4a78 --- /dev/null +++ b/sim/README @@ -0,0 +1,6 @@ +sdcc/simulator +-------------- + +I have no idea :) + +-- Michael diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 00000000..bcdf6ecc --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,137 @@ +# +# +# + +# Version +VERSION = @VERSION@ +VERSIONHI = @VERSIONHI@ +VERSIONLO = @VERSIONLO@ +VERSIONP = @VERSIONP@ + +# Programs +SHELL = /bin/sh +CC = @CC@ +CPP = @CPP@ +RANLIB = @RANLIB@ +INSTALL = @INSTALL@ +YACC = @YACC@ +LEX = @LEX@ +AWK = @AWK@ +# Directories +PRJDIR = .. + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +datadir = @datadir@ +includedir = @includedir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = @infodir@ +srcdir = @srcdir@ + +# Flags +DEFS = $(subs -DHAVE_CONFIG_H,,@DEFS@) +CPPFLAGS = @CPPFLAGS@ -I$(PRJDIR) -I$(PRJDIR)/support +CFLAGS = @CFLAGS@ -Wall +M_OR_MM = @M_OR_MM@ +LIBS = -lgc @LIBS@ +LIBDIRS = -L$(PRJDIR)/support/gc + +OBJECTS = SDCCy.o SDCClex.o SDCCerr.o SDCChasht.o SDCCmain.o \ + SDCCsymt.o SDCCopt.o SDCCast.o SDCCmem.o SDCCval.o \ + SDCCralloc.o SDCCicode.o SDCCbitv.o SDCCset.o SDCClabel.o \ + SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o \ + SDCClrange.o SDCCptropt.o SDCCgen51.o SDCCpeeph.o SDCCglue.o spawn.o +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) + +TARGET = $(PRJDIR)/bin/sdcc + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(PRJDIR)/support/gc/libgc.a $(TARGET) + +$(PRJDIR)/support/gc/libgc.a: + cd $(PRJDIR)/support/gc && $(MAKE) + + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) -s $(TARGET) $(bindir)/sdcc + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(bindir)/sdcc + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) *.h $(PRJDIR)/*.h + $(CPP) $(CPPFLAGS) $(M_OR_MM) $(SOURCES) >Makefile.dep + +include Makefile.dep +include clean.mk + + +# My rules +# -------- +$(TARGET): $(OBJECTS) + $(CC) -o $@ $(OBJECTS) $(LIBDIRS) $(LIBS) + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +SDCCy.c: SDCC.y + $(YACC) -d -v -o $@ $< + +SDCClex.c: SDCC.lex SDCCy.h + $(LEX) -t $< >$@ + +SDCCpeeph.rul: SDCCpeeph.def + $(AWK) -f SDCCpeeph.awk SDCCpeeph.def > SDCCpeeph.rul + +.y.c: + rm -f $*.cc $*.h + $(YACC) -d $< + mv y.tab.c $*.cc + mv y.tab.h $*.h + +.l.c: + rm -f $*.cc + $(LEX) -t $< >$*.cc + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \ + freshconf;\ + fi + +# End of main_in.mk/main.mk + diff --git a/src/README b/src/README new file mode 100644 index 00000000..ac1f53d8 --- /dev/null +++ b/src/README @@ -0,0 +1,8 @@ +sdcc/src +-------- + +C compiler source. + +Everything shared is in this directory. Port specific files like the +code generator (gen.c), register allocator (ralloc.c) and support +functions are in the appropriate port directory (ie mcs51 for the 8051). diff --git a/src/SDCC.lex b/src/SDCC.lex new file mode 100644 index 00000000..510981ad --- /dev/null +++ b/src/SDCC.lex @@ -0,0 +1,499 @@ +/*----------------------------------------------------------------------- + SDCC.lex - lexical analyser for use with sdcc ( a freeware compiler for + 8/16 bit microcontrollers) + Written by : Sandeep Dutta . sandeep.dutta@usa.net (1997) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +D [0-9] +L [a-zA-Z_] +H [a-fA-F0-9] +E [Ee][+-]?{D}+ +FS (f|F|l|L) +IS (u|U|l|L)* +%{ + +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCCval.h" +#include "SDCCast.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCmem.h" + +char *stringLiteral(); +char *currFname; + +extern int lineno ; +extern char *filename ; +extern char *fullSrcFileName ; +int yylineno = 1 ; +void count() ; +void comment(); +int process_pragma(char *); +#undef yywrap + +int yywrap YY_PROTO((void)) +{ + return(1); +} + +char asmbuff[MAX_INLINEASM] ; +char *asmp ; +extern int check_type ( ); +extern int checkCurrFile (char *); +extern int processPragma (char *); +extern int printListing (int ); +struct optimize save_optimize ; +struct options save_options ; + + enum { + P_SAVE = 1, + P_RESTORE , + P_NOINDUCTION, + P_NOINVARIANT, + P_INDUCTION , + P_STACKAUTO , + P_NOJTBOUND , + P_NOOVERLAY , + P_NOGCSE , + P_CALLEE_SAVES, + P_EXCLUDE , + P_LOOPREV + }; + +%} +%x asm +%% +"_asm" { count(); asmp = asmbuff ;BEGIN(asm) ;} +"_endasm" { count() ; + *asmp = '\0' ; + strcpy(yylval.yyinline,asmbuff) ; + BEGIN(INITIAL) ; + return (INLINEASM) ; } +. { *asmp++ = yytext[0] ; } +\n { count(); *asmp++ = '\n' ;} +"/*" { comment(); } +"at" { count(); return(AT) ; } +"auto" { count(); return(AUTO); } +"bit" { count(); return(BIT) ; } +"break" { count(); return(BREAK); } +"case" { count(); return(CASE); } +"char" { count(); return(CHAR); } +"code" { count(); return(CODE); } +"const" { count(); return(CONST); } +"continue" { count(); return(CONTINUE); } +"critical" { count(); return(CRITICAL); } +"data" { count(); return(DATA); } +"default" { count(); return(DEFAULT); } +"do" { count(); return(DO); } +"double" { count(); werror(W_DOUBLE_UNSUPPORTED);return(FLOAT); } +"else" { count(); return(ELSE); } +"enum" { count(); return(ENUM); } +"extern" { count(); return(EXTERN); } +"far" { count(); return(XDATA); } +"float" { count(); return(FLOAT); } +"for" { count(); return(FOR); } +"goto" { count(); return(GOTO); } +"idata" { count(); return(IDATA);} +"if" { count(); return(IF); } +"int" { count(); return(INT); } +"interrupt" { count(); return(INTERRUPT);} +"long" { count(); return(LONG); } +"near" { count(); return(DATA);} +"pdata" { count(); return(PDATA); } +"reentrant" { count(); return(REENTRANT);} +"register" { count(); return(REGISTER); } +"return" { count(); return(RETURN); } +"sfr" { count(); return(SFR) ; } +"sbit" { count(); return(SBIT) ; } +"short" { count(); return(SHORT); } +"signed" { count(); return(SIGNED); } +"sizeof" { count(); return(SIZEOF); } +"static" { count(); return(STATIC); } +"struct" { count(); return(STRUCT); } +"switch" { count(); return(SWITCH); } +"typedef" { count(); return(TYPEDEF); } +"union" { count(); return(UNION); } +"unsigned" { count(); return(UNSIGNED); } +"void" { count(); return(VOID); } +"volatile" { count(); return(VOLATILE); } +"using" { count(); return(USING); } +"while" { count(); return(WHILE); } +"xdata" { count(); return(XDATA); } +"_data" { count(); return(_NEAR); } +"_code" { count(); return(_CODE); } +"_generic" { count(); return(_GENERIC); } +"_near" { count(); return(_NEAR); } +"_xdata" { count(); return(_XDATA);} +"_pdata" { count () ; return(_PDATA); } +"_idata" { count () ; return(_IDATA); } +"..." { count(); return(VAR_ARGS);} +{L}({L}|{D})* { count(); return(check_type()); } +0[xX]{H}+{IS}? { count(); yylval.val = constVal(yytext); return(CONSTANT); } +0{D}+{IS}? { count(); yylval.val = constVal(yytext); return(CONSTANT); } +{D}+{IS}? { count(); yylval.val = constVal(yytext); return(CONSTANT); } +'(\\.|[^\\'])+' { count();yylval.val = charVal (yytext); return(CONSTANT); } +{D}+{E}{FS}? { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } +{D}*"."{D}+({E})?{FS}? { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } +{D}+"."{D}*({E})?{FS}? { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } +\" { count(); yylval.val=strVal(stringLiteral()); return(STRING_LITERAL);} +">>=" { count(); yylval.yyint = RIGHT_ASSIGN ; return(RIGHT_ASSIGN); } +"<<=" { count(); yylval.yyint = LEFT_ASSIGN ; return(LEFT_ASSIGN) ; } +"+=" { count(); yylval.yyint = ADD_ASSIGN ; return(ADD_ASSIGN) ; } +"-=" { count(); yylval.yyint = SUB_ASSIGN ; return(SUB_ASSIGN) ; } +"*=" { count(); yylval.yyint = MUL_ASSIGN ; return(MUL_ASSIGN) ; } +"/=" { count(); yylval.yyint = DIV_ASSIGN ; return(DIV_ASSIGN) ; } +"%=" { count(); yylval.yyint = MOD_ASSIGN ; return(MOD_ASSIGN) ; } +"&=" { count(); yylval.yyint = AND_ASSIGN ; return(AND_ASSIGN) ; } +"^=" { count(); yylval.yyint = XOR_ASSIGN ; return(XOR_ASSIGN) ; } +"|=" { count(); yylval.yyint = OR_ASSIGN ; return(OR_ASSIGN) ; } +">>" { count(); return(RIGHT_OP); } +"<<" { count(); return(LEFT_OP); } +"++" { count(); return(INC_OP); } +"--" { count(); return(DEC_OP); } +"->" { count(); return(PTR_OP); } +"&&" { count(); return(AND_OP); } +"||" { count(); return(OR_OP); } +"<=" { count(); return(LE_OP); } +">=" { count(); return(GE_OP); } +"==" { count(); return(EQ_OP); } +"!=" { count(); return(NE_OP); } +";" { count(); return(';'); } +"{" { count() ; NestLevel++ ; return('{'); } +"}" { count(); NestLevel--; return('}'); } +"," { count(); return(','); } +":" { count(); return(':'); } +"=" { count(); return('='); } +"(" { count(); return('('); } +")" { count(); return(')'); } +"[" { count(); return('['); } +"]" { count(); return(']'); } +"." { count(); return('.'); } +"&" { count(); return('&'); } +"!" { count(); return('!'); } +"~" { count(); return('~'); } +"-" { count(); return('-'); } +"+" { count(); return('+'); } +"*" { count(); return('*'); } +"/" { count(); return('/'); } +"%" { count(); return('%'); } +"<" { count(); return('<'); } +">" { count(); return('>'); } +"^" { count(); return('^'); } +"|" { count(); return('|'); } +"?" { count(); return('?'); } +^#line.*"\n" { count(); checkCurrFile(yytext); } +^#pragma.*"\n" { count(); process_pragma(yytext); } + +^[^(]+"("[0-9]+") : error"[^\n]+ { werror(E_PRE_PROC_FAILED,yytext);count(); } +^[^(]+"("[0-9]+") : warning"[^\n]+ { werror(W_PRE_PROC_WARNING,yytext);count(); } +"\r\n" { count(); } +"\n" { count(); } +[ \t\v\f] { count(); } +. { count() ; } +%% + +int checkCurrFile ( char *s) +{ + char lineNum[10] ; + int lNum ; + char *tptr ; + + /* first check if this is a #line */ + if ( strncmp(s,"#line",5) ) + return 0 ; + + /* get to the line number */ + while (!isdigit(*s)) + s++ ; + tptr = lineNum ; + while (isdigit(*s)) + *tptr++ = *s++ ; + *tptr = '\0'; + sscanf(lineNum,"%d",&lNum); + + /* now see if we have a file name */ + while (*s != '\"' && *s) + s++ ; + + /* if we don't have a filename then */ + /* set the current line number to */ + /* line number if printFlag is on */ + if (!*s) { + yylineno = lNum ; + return 0; + } + + /* if we have a filename then check */ + /* if it is "standard in" if yes then */ + /* get the currentfile name info */ + s++ ; + + if ( strncmp(s,fullSrcFileName,strlen(fullSrcFileName)) == 0) { + yylineno = lNum - 2; + currFname = fullSrcFileName ; + } else { + char *sb = s; + /* mark the end of the filename */ + while (*s != '"') s++; + *s = '\0'; + ALLOC_ATOMIC(currFname,strlen(sb)+1); + strcpy(currFname,sb); + yylineno = lNum - 2; + } + filename = currFname ; + return 0; +} + +void comment() +{ + char c, c1; + +loop: + while ((c = input()) != '*' && c != 0) + if ( c == '\n') + yylineno++ ; + + if ((c1 = input()) != '/' && c != 0) { + if ( c1 == '\n' ) + yylineno++ ; + + unput(c1); + goto loop; + } + +} + + + +int column = 0; +int plineIdx=0; + +void count() +{ + int i; + for (i = 0; yytext[i] != '\0'; i++) { + if (yytext[i] == '\n') { + column = 0; + lineno = ++yylineno ; + } + else + if (yytext[i] == '\t') + column += 8 - (column % 8); + else + column++; + } + + /* ECHO; */ +} + +int check_type() +{ + /* check if it is in the typedef table */ + if (findSym(TypedefTab,NULL,yytext)) { + strcpy(yylval.yychar,yytext); + return (TYPE_NAME) ; + } + else { + strcpy (yylval.yychar,yytext); + return(IDENTIFIER); + } +} + +char strLitBuff[2048] ; + +char *stringLiteral () +{ + int ch; + char *str = strLitBuff ; + + *str++ = '\"' ; + /* put into the buffer till we hit the */ + /* first \" */ + while (1) { + + ch = input() ; + if (!ch) break ; /* end of input */ + /* if it is a \ then everything allowed */ + if (ch == '\\') { + *str++ = ch ; /* backslash in place */ + *str++ = input() ; /* following char in place */ + continue ; /* carry on */ + } + + /* if new line we have a new line break */ + if (ch == '\n') break ; + + /* if this is a quote then we have work to do */ + /* find the next non whitespace character */ + /* if that is a double quote then carry on */ + if (ch == '\"') { + + while ((ch = input()) && isspace(ch)) ; + if (!ch) break ; + if (ch != '\"') { + unput(ch) ; + break ; + } + + continue ; + } + *str++ = ch; + } + *str++ = '\"' ; + *str = '\0'; + return strLitBuff ; +} + +void doPragma (int op, char *cp) +{ + switch (op) { + case P_SAVE: + memcpy(&save_options,&options,sizeof(options)); + memcpy(&save_optimize,&optimize,sizeof(optimize)); + break; + case P_RESTORE: + memcpy(&options,&save_options,sizeof(options)); + memcpy(&optimize,&save_optimize,sizeof(optimize)); + break; + case P_NOINDUCTION: + optimize.loopInduction = 0 ; + break; + case P_NOINVARIANT: + optimize.loopInvariant = 0 ; + break; + case P_INDUCTION: + optimize.loopInduction = 1 ; + break; + case P_STACKAUTO: + options.stackAuto = 1; + break; + case P_NOJTBOUND: + optimize.noJTabBoundary = 1; + break; + case P_NOGCSE: + optimize.global_cse = 0; + break; + case P_NOOVERLAY: + options.noOverlay = 1; + break; + case P_CALLEE_SAVES: + { + int i=0; + /* append to the functions already listed + in callee-saves */ + for (; options.calleeSaves[i] ;i++); + parseWithComma(&options.calleeSaves[i],strdup(cp)); + } + break; + case P_EXCLUDE: + parseWithComma(options.excludeRegs,strdup(cp)); + break; + case P_LOOPREV: + optimize.noLoopReverse = 1; + break; + } +} + +int process_pragma(char *s) +{ + char *cp ; + /* find the pragma */ + while (strncmp(s,"#pragma",7)) + s++; + s += 7; + + /* look for the directive */ + while(isspace(*s)) s++; + + cp = s; + /* look for the end of the directive */ + while ((! isspace(*s)) && + (*s != '\n')) + s++ ; + + /* now compare and do what needs to be done */ + if (strncmp(cp,PRAGMA_SAVE,strlen(PRAGMA_SAVE)) == 0) { + doPragma(P_SAVE,cp+strlen(PRAGMA_SAVE)); + return 0; + } + + if (strncmp(cp,PRAGMA_RESTORE,strlen(PRAGMA_RESTORE)) == 0) { + doPragma (P_RESTORE,cp+strlen(PRAGMA_RESTORE)); + return 0; + } + + if (strncmp(cp,PRAGMA_NOINDUCTION,strlen(PRAGMA_NOINDUCTION)) == 0) { + doPragma (P_NOINDUCTION,cp+strlen(PRAGMA_NOINDUCTION)) ; + return 0; + } + + if (strncmp(cp,PRAGMA_NOINVARIANT,strlen(PRAGMA_NOINVARIANT)) == 0) { + doPragma (P_NOINVARIANT,NULL) ; + return 0; + } + + if (strncmp(cp,PRAGMA_INDUCTION,strlen(PRAGMA_INDUCTION)) == 0) { + doPragma (P_INDUCTION,NULL) ; + return 0; + } + + if (strncmp(cp,PRAGMA_STACKAUTO,strlen(PRAGMA_STACKAUTO)) == 0) { + doPragma (P_STACKAUTO,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_NOJTBOUND,strlen(PRAGMA_NOJTBOUND)) == 0) { + doPragma (P_NOJTBOUND,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_NOGCSE,strlen(PRAGMA_NOGCSE)) == 0) { + doPragma (P_NOGCSE,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_NOOVERLAY,strlen(PRAGMA_NOOVERLAY)) == 0) { + doPragma (P_NOOVERLAY,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_CALLEESAVES,strlen(PRAGMA_CALLEESAVES)) == 0) { + doPragma(P_CALLEE_SAVES,cp+strlen(PRAGMA_CALLEESAVES)); + return 0; + } + + if (strncmp(cp,PRAGMA_EXCLUDE,strlen(PRAGMA_EXCLUDE)) == 0) { + doPragma(P_EXCLUDE,cp+strlen(PRAGMA_EXCLUDE)); + return 0; + } + + if (strncmp(cp,PRAGMA_NOLOOPREV,strlen(PRAGMA_NOLOOPREV)) == 0) { + doPragma(P_EXCLUDE,NULL); + return 0; + } + + werror(W_UNKNOWN_PRAGMA,cp); + return 0; +} diff --git a/src/SDCC.y b/src/SDCC.y new file mode 100644 index 00000000..e777a313 --- /dev/null +++ b/src/SDCC.y @@ -0,0 +1,1322 @@ +/*----------------------------------------------------------------------- + + SDCC.y - parser definition file for sdcc : + Written By : Sandeep Dutta . sandeep.dutta@usa.net (1997) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +%{ +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCChasht.h" +#include "SDCCval.h" +#include "SDCCmem.h" +#include "SDCCast.h" +extern int yyerror (char *); +extern FILE *yyin; +extern char srcLstFname[]; +int NestLevel = 0 ; /* current NestLevel */ +int stackPtr = 1 ; /* stack pointer */ +int xstackPtr = 0 ; /* xstack pointer */ +int reentrant = 0 ; +int blockNo = 0 ; /* sequential block number */ +int currBlockno=0 ; +extern int yylex(); +int yyparse(void); +extern int noLineno ; +char lbuff[1024]; /* local buffer */ + +/* break & continue stacks */ +STACK_DCL(continueStack ,symbol *,MAX_NEST_LEVEL) +STACK_DCL(breakStack ,symbol *,MAX_NEST_LEVEL) +STACK_DCL(forStack ,symbol *,MAX_NEST_LEVEL) +STACK_DCL(swStk ,ast *,MAX_NEST_LEVEL) +STACK_DCL(blockNum,int,MAX_NEST_LEVEL*3) + +value *cenum = NULL ; /* current enumeration type chain*/ + +%} +%union { + symbol *sym ; /* symbol table pointer */ + structdef *sdef; /* structure definition */ + char yychar[SDCC_NAME_MAX+1]; + link *lnk ; /* declarator or specifier */ + int yyint; /* integer value returned */ + value *val ; /* for integer constant */ + initList *ilist; /* initial list */ + char yyinline[MAX_INLINEASM]; /* inlined assembler code */ + ast *asts; /* expression tree */ +} + +%token IDENTIFIER TYPE_NAME +%token CONSTANT STRING_LITERAL +%token SIZEOF +%token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP +%token AND_OP OR_OP +%token MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN +%token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN +%token XOR_ASSIGN OR_ASSIGN +%token TYPEDEF EXTERN STATIC AUTO REGISTER CODE INTERRUPT SFR AT SBIT +%token REENTRANT USING XDATA DATA IDATA PDATA VAR_ARGS CRITICAL +%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID BIT +%token STRUCT UNION ENUM ELIPSIS RANGE FAR _XDATA _CODE _GENERIC _NEAR _PDATA _IDATA +%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN +%token INLINEASM +%token IFX ADDRESS_OF GET_VALUE_AT_ADDRESS SPIL UNSPIL GETHBIT +%token BITWISEAND UNARYMINUS IPUSH IPOP PCALL ENDFUNCTION JUMPTABLE +%token RRC RLC +%token CAST CALL PARAM NULLOP BLOCK LABEL RECEIVE SEND + +%type Interrupt_storage +%type identifier declarator declarator2 enumerator_list enumerator +%type struct_declarator +%type struct_declarator_list struct_declaration struct_declaration_list +%type declaration init_declarator_list init_declarator +%type declaration_list identifier_list parameter_identifier_list +%type declarator2_using_reentrant while do for +%type pointer type_specifier_list type_specifier type_name +%type storage_class_specifier struct_or_union_specifier +%type declaration_specifiers sfr_reg_bit type_specifier2 +%type using_reentrant using_reentrant_interrupt enum_specifier +%type abstract_declarator abstract_declarator2 far_near_pointer far_near +%type parameter_type_list parameter_list parameter_declaration opt_assign_expr +%type stag opt_stag +%type primary_expr +%type postfix_expr unary_expr cast_expr multiplicative_expr +%type additive_expr shift_expr relational_expr equality_expr +%type and_expr exclusive_or_expr inclusive_or_expr logical_or_expr +%type logical_and_expr conditional_expr assignment_expr constant_expr +%type expr argument_expr_list function_definition expr_opt +%type statement_list statement labeled_statement compound_statement +%type expression_statement selection_statement iteration_statement +%type jump_statement function_body else_statement string_literal +%type initializer initializer_list +%type unary_operator assignment_operator struct_or_union + +%start file + +%% + +file + : external_definition + | file external_definition + ; + +external_definition + : function_definition { blockNo=0;} + | declaration { + addSymChain ($1); + allocVariables ($1) ; + cleanUpLevel (SymbolTab,1); + } + ; + +function_definition + : declarator function_body { /* function type not specified */ + /* assume it to be 'int' */ + addDecl($1,0,newIntLink()); + $$ = createFunction($1,$2); + } + | declaration_specifiers declarator function_body + { + pointerTypes($2->type,copyLinkChain($1)); + addDecl($2,0,$1); + $$ = createFunction($2,$3); + } + ; + +using_reentrant + : using_reentrant_interrupt + | using_reentrant_interrupt using_reentrant { $$ = mergeSpec($1,$2); } + ; + +using_reentrant_interrupt + : USING CONSTANT { + $$ = newLink() ; + $$->class = SPECIFIER ; + SPEC_BNKF($$) = 1; + SPEC_BANK($$) = (int) floatFromVal($2); + } + | REENTRANT { $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_RENT($$) = 1; + } + | CRITICAL { $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_CRTCL($$) = 1; + } + | Interrupt_storage + { + $$ = newLink () ; + $$->class = SPECIFIER ; + SPEC_INTN($$) = $1 ; + SPEC_INTRTN($$) = 1; + } + ; + +function_body + : compound_statement + | declaration_list compound_statement + { + werror(E_OLD_STYLE,($1 ? $1->name: "")) ; + exit(1); + } + ; + +primary_expr + : identifier { $$ = newAst(EX_VALUE,symbolVal($1)); } + | CONSTANT { $$ = newAst(EX_VALUE,$1); } + | string_literal + | '(' expr ')' { $$ = $2 ; } + ; + +string_literal + : STRING_LITERAL { $$ = newAst(EX_VALUE,$1); } + ; + +postfix_expr + : primary_expr + | postfix_expr '[' expr ']' { $$ = newNode ('[', $1, $3) ; } + | postfix_expr '(' ')' { $$ = newNode (CALL,$1,NULL); + $$->left->funcName = 1;} + | postfix_expr '(' argument_expr_list ')' + { + $$ = newNode (CALL,$1,$3) ; $$->left->funcName = 1; + } + | postfix_expr '.' identifier + { + $3 = newSymbol($3->name,NestLevel); + $3->implicit = 1; + $$ = newNode(PTR_OP,newNode('&',$1,NULL),newAst(EX_VALUE,symbolVal($3))); +/* $$ = newNode('.',$1,newAst(EX_VALUE,symbolVal($3))) ; */ + } + | postfix_expr PTR_OP identifier + { + $3 = newSymbol($3->name,NestLevel); + $3->implicit = 1; + $$ = newNode(PTR_OP,$1,newAst(EX_VALUE,symbolVal($3))); + } + | postfix_expr INC_OP + { $$ = newNode(INC_OP,$1,NULL);} + | postfix_expr DEC_OP + { $$ = newNode(DEC_OP,$1,NULL); } + ; + +argument_expr_list + : assignment_expr + | assignment_expr ',' argument_expr_list { $$ = newNode(PARAM,$1,$3); } + ; + +unary_expr + : postfix_expr + | INC_OP unary_expr { $$ = newNode(INC_OP,NULL,$2); } + | DEC_OP unary_expr { $$ = newNode(DEC_OP,NULL,$2); } + | unary_operator cast_expr { $$ = newNode($1,$2,NULL) ; } + | SIZEOF unary_expr { $$ = newNode(SIZEOF,NULL,$2); } + | SIZEOF '(' type_name ')' { $$ = newAst(EX_VALUE,sizeofOp($3)); } + ; + +unary_operator + : '&' { $$ = '&' ;} + | '*' { $$ = '*' ;} + | '+' { $$ = '+' ;} + | '-' { $$ = '-' ;} + | '~' { $$ = '~' ;} + | '!' { $$ = '!' ;} + ; + +cast_expr + : unary_expr + | '(' type_name ')' cast_expr { $$ = newNode(CAST,newAst(EX_LINK,$2),$4); } + ; + +multiplicative_expr + : cast_expr + | multiplicative_expr '*' cast_expr { $$ = newNode('*',$1,$3);} + | multiplicative_expr '/' cast_expr { $$ = newNode('/',$1,$3);} + | multiplicative_expr '%' cast_expr { $$ = newNode('%',$1,$3);} + ; + +additive_expr + : multiplicative_expr + | additive_expr '+' multiplicative_expr { $$=newNode('+',$1,$3);} + | additive_expr '-' multiplicative_expr { $$=newNode('-',$1,$3);} + ; + +shift_expr + : additive_expr + | shift_expr LEFT_OP additive_expr { $$ = newNode(LEFT_OP,$1,$3); } + | shift_expr RIGHT_OP additive_expr { $$ = newNode(RIGHT_OP,$1,$3); } + ; + +relational_expr + : shift_expr + | relational_expr '<' shift_expr { $$ = newNode('<',$1,$3); } + | relational_expr '>' shift_expr { $$ = newNode('>',$1,$3); } + | relational_expr LE_OP shift_expr { + /* $$ = newNode(LE_OP,$1,$3); */ + /* getting 8051 specific here : will change + LE_OP operation to "not greater than" i.e. + ( a <= b ) === ( ! ( a > b )) */ + $$ = newNode('!', + newNode('>', $1 , $3 ), + NULL); + } + | relational_expr GE_OP shift_expr { + /* $$ = newNode(GE_OP,$1,$3) ; */ + /* getting 8051 specific here : will change + GE_OP operation to "not less than" i.e. + ( a >= b ) === ( ! ( a < b )) */ + $$ = newNode('!', + newNode('<', $1 , $3 ), + NULL); + } + ; + +equality_expr + : relational_expr + | equality_expr EQ_OP relational_expr { $$ = newNode(EQ_OP,$1,$3);} + | equality_expr NE_OP relational_expr + { + /* $$ = newNode(NE_OP,$1,$3); */ + /* NE_OP changed : + expr1 != expr2 is equivalent to + (! expr1 == expr2) */ + $$ = newNode('!', + newNode(EQ_OP,$1,$3), + NULL); + } + ; + +and_expr + : equality_expr + | and_expr '&' equality_expr { $$ = newNode('&',$1,$3);} + ; + +exclusive_or_expr + : and_expr + | exclusive_or_expr '^' and_expr { $$ = newNode('^',$1,$3);} + ; + +inclusive_or_expr + : exclusive_or_expr + | inclusive_or_expr '|' exclusive_or_expr { $$ = newNode('|',$1,$3);} + ; + +logical_and_expr + : inclusive_or_expr + | logical_and_expr AND_OP inclusive_or_expr + { $$ = newNode(AND_OP,$1,$3);} + ; + +logical_or_expr + : logical_and_expr + | logical_or_expr OR_OP logical_and_expr + { $$ = newNode(OR_OP,$1,$3); } + ; + +conditional_expr + : logical_or_expr + | logical_or_expr '?' logical_or_expr ':' conditional_expr + { + $$ = newNode(':',$3,$5) ; + $$ = newNode('?',$1,$$) ; + } + ; + +assignment_expr + : conditional_expr + | unary_expr assignment_operator assignment_expr + { + + switch ($2) { + case '=': + $$ = newNode($2,$1,$3); + break; + case MUL_ASSIGN: + $$ = newNode('=',$1,newNode('*',copyAst($1),$3)); + break; + case DIV_ASSIGN: + $$ = newNode('=',$1,newNode('/',copyAst($1),$3)); + break; + case ADD_ASSIGN: + $$ = newNode('=',$1,newNode('+',copyAst($1),$3)); + break; + case SUB_ASSIGN: + $$ = newNode('=',$1,newNode('-',copyAst($1),$3)); + break; + case LEFT_ASSIGN: + $$ = newNode('=',$1,newNode(LEFT_OP,copyAst($1),$3)); + break; + case RIGHT_ASSIGN: + $$ = newNode('=',$1,newNode(RIGHT_OP,copyAst($1),$3)); + break; + case AND_ASSIGN: + $$ = newNode('=',$1,newNode('&',copyAst($1),$3)); + break; + case XOR_ASSIGN: + $$ = newNode('=',$1,newNode('^',copyAst($1),$3)); + break; + case OR_ASSIGN: + $$ = newNode('=',$1,newNode('|',copyAst($1),$3)); + break; + default : + $$ = NULL; + } + + } +; + +assignment_operator + : '=' { $$ = '=' ;} + | MUL_ASSIGN + | DIV_ASSIGN + | MOD_ASSIGN + | ADD_ASSIGN + | SUB_ASSIGN + | LEFT_ASSIGN + | RIGHT_ASSIGN + | AND_ASSIGN + | XOR_ASSIGN + | OR_ASSIGN + ; + +expr + : assignment_expr + | expr ',' assignment_expr { $$ = newNode(',',$1,$3);} + ; + +constant_expr + : conditional_expr + ; + +declaration + : declaration_specifiers ';' { $$ = NULL ; } + | declaration_specifiers init_declarator_list ';' + { + /* add the specifier list to the id */ + symbol *sym , *sym1; + + for (sym1 = sym = reverseSyms($2);sym != NULL;sym = sym->next) { + link *lnk = copyLinkChain($1); + /* do the pointer stuff */ + pointerTypes(sym->type,lnk); + addDecl (sym,0,lnk) ; + } + + $$ = sym1 ; + } + ; + +declaration_specifiers + : storage_class_specifier { $$ = $1; } + | storage_class_specifier declaration_specifiers { + /* if the decl $2 is not a specifier */ + /* find the spec and replace it */ + if ( !IS_SPEC($2)) { + link *lnk = $2 ; + while (lnk && !IS_SPEC(lnk->next)) + lnk = lnk->next; + lnk->next = mergeSpec($1,lnk->next); + $$ = $2 ; + } + else + $$ = mergeSpec($1,$2); + } + | type_specifier { $$ = $1; } + | type_specifier declaration_specifiers { + /* if the decl $2 is not a specifier */ + /* find the spec and replace it */ + if ( !IS_SPEC($2)) { + link *lnk = $2 ; + while (lnk && !IS_SPEC(lnk->next)) + lnk = lnk->next; + lnk->next = mergeSpec($1,lnk->next); + $$ = $2 ; + } + else + $$ = mergeSpec($1,$2); + } + ; + +init_declarator_list + : init_declarator + | init_declarator_list ',' init_declarator { $3->next = $1 ; $$ = $3;} + ; + +init_declarator + : declarator { $1->ival = NULL ; } + | declarator '=' initializer { $1->ival = $3 ; } + ; + + +storage_class_specifier + : TYPEDEF { + $$ = newLink () ; + $$->class = SPECIFIER ; + SPEC_TYPEDEF($$) = 1 ; + } + | EXTERN { + $$ = newLink(); + $$->class = SPECIFIER ; + SPEC_EXTR($$) = 1 ; + } + | STATIC { + $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_STAT($$) = 1 ; + } + | AUTO { + $$ = newLink () ; + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_AUTO ; + } + | REGISTER { + $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_REGISTER ; + } + ; + +Interrupt_storage + : INTERRUPT CONSTANT { $$ = (int) floatFromVal($2) ; } + ; + +type_specifier + : type_specifier2 + | type_specifier2 AT CONSTANT + { + /* add this to the storage class specifier */ + SPEC_ABSA($1) = 1; /* set the absolute addr flag */ + /* now get the abs addr from value */ + SPEC_ADDR($1) = (int) floatFromVal ($3) ; + } + ; + +type_specifier2 + : CHAR { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_CHAR ; + } + | SHORT { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_LONG($$) = 0 ; + SPEC_SHORT($$) = 1 ; + } + | INT { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_INT ; + } + | LONG { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_LONG($$) = 1 ; + SPEC_SHORT($$) = 0; + } + | SIGNED { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_USIGN($$) = 0 ; + } + | UNSIGNED { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_USIGN($$) = 1 ; + } + | VOID { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_VOID ; + } + | CONST { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_CONSTANT ; + SPEC_CONST($$) = 1; + } + | VOLATILE { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_VOLATILE($$) = 1 ; + } + | FLOAT { + $$=newLink(); + SPEC_NOUN($$) = V_FLOAT; + $$->class = SPECIFIER ; + } + | XDATA { + $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_XDATA ; + } + | CODE { + $$ = newLink () ; + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_CODE ; + } + | DATA { + $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_DATA ; + } + | IDATA { + $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_IDATA ; + } + | PDATA { + $$ = newLink (); + $$->class = SPECIFIER ; + SPEC_SCLS($$) = S_PDATA ; + } + | BIT { + $$=newLink(); + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_BIT ; + SPEC_SCLS($$) = S_BIT ; + SPEC_BLEN($$) = 1; + SPEC_BSTR($$) = 0; + } + + | struct_or_union_specifier + | enum_specifier { + cenum = NULL ; + $$ = $1 ; + } + | TYPE_NAME + { + symbol *sym; + link *p ; + + sym = findSym(TypedefTab,NULL,$1) ; + $$ = p = copyLinkChain(sym->type); + SPEC_TYPEDEF(getSpec(p)) = 0; + } + | sfr_reg_bit + ; + +sfr_reg_bit + : SBIT { + $$ = newLink() ; + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_SBIT; + SPEC_SCLS($$) = S_SBIT; + } + | SFR { + $$ = newLink() ; + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_CHAR; + SPEC_SCLS($$) = S_SFR ; + SPEC_USIGN($$) = 1 ; + } + ; + +struct_or_union_specifier + : struct_or_union opt_stag '{' struct_declaration_list '}' + { + structdef *sdef ; + + /* Create a structdef */ + sdef = $2 ; + sdef->fields = reverseSyms($4) ; /* link the fields */ + sdef->size = compStructSize($1,sdef); /* update size of */ + + /* Create the specifier */ + $$ = newLink () ; + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_STRUCT; + SPEC_STRUCT($$)= sdef ; + } + | struct_or_union stag + { + $$ = newLink() ; + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_STRUCT; + SPEC_STRUCT($$) = $2 ; + } + ; + +struct_or_union + : STRUCT { $$ = STRUCT ; } + | UNION { $$ = UNION ; } + ; + +opt_stag + : stag + | { /* synthesize a name add to structtable */ + $$ = newStruct(genSymName(NestLevel)) ; + $$->level = NestLevel ; + addSym (StructTab, $$, $$->tag,$$->level,currBlockno) ; + } + ; + +stag + : identifier { /* add name to structure table */ + $$ = findSymWithBlock (StructTab,$1,currBlockno); + if (! $$ ) { + $$ = newStruct($1->name) ; + $$->level = NestLevel ; + addSym (StructTab, $$, $$->tag,$$->level,currBlockno) ; + } + } + ; + +struct_declaration_list + : struct_declaration + | struct_declaration_list struct_declaration + { + symbol *sym = $2; + /* go to the end of the chain */ + while (sym->next) sym = sym->next; + + sym->next = $1 ; + $$ = $2; + } + ; + +struct_declaration + : type_specifier_list struct_declarator_list ';' + { + /* add this type to all the symbols */ + symbol *sym ; + for ( sym = $2 ; sym != NULL ; sym = sym->next ) { + + pointerTypes(sym->type,copyLinkChain($1)); + if (!sym->type) { + sym->type = copyLinkChain($1); + sym->etype = getSpec(sym->type); + } + else + addDecl (sym,0,cloneSpec($1)); + + } + $$ = $2; + } + ; + +struct_declarator_list + : struct_declarator + | struct_declarator_list ',' struct_declarator + { + $3->next = $1 ; + $$ = $3 ; + } + ; + +struct_declarator + : declarator + | ':' constant_expr { + $$ = newSymbol (genSymName(NestLevel),NestLevel) ; + $$->bitVar = (int) floatFromVal(constExprValue($2,TRUE)); + } + | declarator ':' constant_expr + { + $1->bitVar = (int) floatFromVal(constExprValue($3,TRUE)); + } + ; + +enum_specifier + : ENUM '{' enumerator_list '}' { + addSymChain ($3); + allocVariables(reverseSyms($3)) ; + $$ = copyLinkChain(cenum->type); + } + | ENUM identifier '{' enumerator_list '}' { + symbol *csym ; + + $2->type = copyLinkChain(cenum->type); + $2->etype = getSpec($2->type); + /* add this to the enumerator table */ + if (!(csym=findSym(enumTab,$2,$2->name)) && + (csym && csym->level == $2->level)) + werror(E_DUPLICATE_TYPEDEF,csym->name); + + addSym ( enumTab,$2,$2->name,$2->level,$2->block); + addSymChain ($4); + allocVariables (reverseSyms($4)); + $$ = copyLinkChain(cenum->type); + SPEC_SCLS(getSpec($$)) = 0 ; + } + | ENUM identifier { + symbol *csym ; + + /* check the enumerator table */ + if ((csym = findSym(enumTab,$2,$2->name))) + $$ = copyLinkChain(csym->type); + else { + $$ = newLink() ; + $$->class = SPECIFIER ; + SPEC_NOUN($$) = V_INT ; + } + + SPEC_SCLS(getSpec($$)) = 0 ; + } + ; + +enumerator_list + : enumerator + | enumerator_list ',' enumerator { + $3->next = $1 ; + $$ = $3 ; + } + ; + +enumerator + : identifier opt_assign_expr { + /* make the symbol one level up */ + $1->level-- ; + $1->type = copyLinkChain($2->type); + $1->etype= getSpec($1->type); + SPEC_ENUM($1->etype) = 1; + $$ = $1 ; + + } + ; + +opt_assign_expr + : '=' constant_expr { + value *val ; + + val = constExprValue($2,TRUE); + $$ = cenum = val ; + } + | { + if (cenum) { + sprintf(lbuff,"%d",(int) floatFromVal(cenum)+1); + $$ = cenum = constVal(lbuff); + } + else { + sprintf(lbuff,"%d",0); + $$ = cenum = constVal(lbuff); + } + } + ; + +declarator + : declarator2_using_reentrant { $$ = $1; } + | pointer declarator2_using_reentrant + { + addDecl ($2,0,reverseLink($1)); + $$ = $2 ; + } + ; + +declarator2_using_reentrant + : declarator2 { $$ = $1 ; } + | declarator2 using_reentrant { addDecl ($1,0,$2); } + ; + +declarator2 + : identifier + | '(' declarator ')' { $$ = $2; } + | declarator2 '[' ']' + { + link *p; + + p = newLink (); + DCL_TYPE(p) = ARRAY ; + DCL_ELEM(p) = 0 ; + addDecl($1,0,p); + } + | declarator2 '[' constant_expr ']' + { + link *p ; + value *tval; + + p = (tval = constExprValue($3,TRUE))->etype; + /* if it is not a constant then Error */ + if ( SPEC_SCLS(p) != S_LITERAL) + werror(E_CONST_EXPECTED) ; + else { + p = newLink (); + DCL_TYPE(p) = ARRAY ; + DCL_ELEM(p) = (int) floatFromVal(tval) ; + addDecl($1,0,p); + } + } + | declarator2 '(' ')' { addDecl ($1,FUNCTION,NULL) ; } + | declarator2 '(' { NestLevel++ ; currBlockno++; } parameter_type_list ')' + { + + addDecl ($1,FUNCTION,NULL) ; + + $1->hasVargs = IS_VARG($4); + $1->args = reverseVal($4) ; + + /* nest level was incremented to take care of the parms */ + NestLevel-- ; + currBlockno--; + $$ = $1; + } + | declarator2 '(' parameter_identifier_list ')' + { + werror(E_OLD_STYLE,$1->name) ; + + /* assume it returns an it */ + $1->type = $1->etype = newIntLink(); + $$ = $1 ; + } + ; + +pointer + : far_near_pointer { $$ = $1 ;} + | far_near_pointer type_specifier_list + { + $$ = $1 ; + DCL_TSPEC($1) = $2; + } + | far_near_pointer pointer + { + $$ = $1 ; + $$->next = $2 ; + } + | far_near_pointer type_specifier_list pointer + { + $$ = $1 ; + if (IS_SPEC($2) && DCL_TYPE($3) == UPOINTER) { + DCL_PTR_CONST($1) = SPEC_CONST($2); + DCL_PTR_VOLATILE($1) = SPEC_VOLATILE($2); + switch (SPEC_SCLS($2)) { + case S_XDATA: + DCL_TYPE($3) = FPOINTER; + break; + case S_IDATA: + DCL_TYPE($3) = IPOINTER ; + break; + case S_PDATA: + DCL_TYPE($3) = PPOINTER ; + break; + case S_DATA: + DCL_TYPE($3) = POINTER ; + break; + case S_CODE: + DCL_PTR_CONST($3) = 1; + DCL_TYPE($3) = CPOINTER ; + break; + } + } + else + werror (W_PTR_TYPE_INVALID); + $$->next = $3 ; + } + ; + +far_near_pointer + : far_near '*' { + if ($1 == NULL) { + $$ = newLink(); + DCL_TYPE($$) = POINTER ; + } + else + $$ = $1 ; + } + ; + +far_near + : _XDATA { $$ = newLink() ; DCL_TYPE($$) = FPOINTER ; } + | _CODE { $$ = newLink() ; DCL_TYPE($$) = CPOINTER ; DCL_PTR_CONST($$) = 1;} + | _PDATA { $$ = newLink() ; DCL_TYPE($$) = PPOINTER ; } + | _IDATA { $$ = newLink() ; DCL_TYPE($$) = IPOINTER ; } + | _NEAR { $$ = NULL ; } + | _GENERIC { $$ = newLink() ; DCL_TYPE($$) = GPOINTER ; } + | { $$ = newLink() ; DCL_TYPE($$) = UPOINTER ; } + ; + +type_specifier_list + : type_specifier + | type_specifier_list type_specifier { $$ = mergeSpec ($1,$2); } + ; + +parameter_identifier_list + : identifier_list + | identifier_list ',' ELIPSIS + ; + +identifier_list + : identifier + | identifier_list ',' identifier + { + $3->next = $1; + $$ = $3 ; + } + ; + +parameter_type_list + : parameter_list + | parameter_list ',' VAR_ARGS { $1->vArgs = 1;} + ; + +parameter_list + : parameter_declaration + | parameter_list ',' parameter_declaration + { + $3->next = $1 ; + $$ = $3 ; + } + ; + +parameter_declaration + : type_specifier_list declarator + { + symbol *loop ; + pointerTypes($2->type,$1); + addDecl ($2,0,$1); + for (loop=$2;loop;loop->_isparm=1,loop=loop->next); + addSymChain ($2); + $$ = symbolVal($2); + } + | type_name { + $$ = newValue() ; + $$->type = $1; + $$->etype = getSpec($$->type); + } + ; + +type_name + : type_specifier_list { $$ = $1 ;} + | type_specifier_list abstract_declarator + { + /* go to the end of the list */ + link *p; + pointerTypes($2,$1); + for ( p = $2 ; p->next ; p=p->next); + p->next = $1 ; + $$ = $2 ; + } + ; + +abstract_declarator + : pointer { $$ = reverseLink($1); } + | abstract_declarator2 + | pointer abstract_declarator2 { $1 = reverseLink($1); $1->next = $2 ; $$ = $1;} + ; + +abstract_declarator2 + : '(' abstract_declarator ')' { $$ = $2 ; } + | '[' ']' { + $$ = newLink (); + DCL_TYPE($$) = ARRAY ; + DCL_ELEM($$) = 0 ; + } + | '[' constant_expr ']' { + value *val ; + $$ = newLink (); + DCL_TYPE($$) = ARRAY ; + DCL_ELEM($$) = (int) floatFromVal(val = constExprValue($2,TRUE)); + } + | abstract_declarator2 '[' ']' { + $$ = newLink (); + DCL_TYPE($$) = ARRAY ; + DCL_ELEM($$) = 0 ; + $$->next = $1 ; + } + | abstract_declarator2 '[' constant_expr ']' + { + value *val ; + $$ = newLink (); + DCL_TYPE($$) = ARRAY ; + DCL_ELEM($$) = (int) floatFromVal(val = constExprValue($3,TRUE)); + $$->next = $1 ; + } + | '(' ')' { $$ = NULL;} + | '(' parameter_type_list ')' { $$ = NULL;} + | abstract_declarator2 '(' ')' + | abstract_declarator2 '(' parameter_type_list ')' + ; + +initializer + : assignment_expr { $$ = newiList(INIT_NODE,$1); } + | '{' initializer_list '}' { $$ = newiList(INIT_DEEP,revinit($2)); } + | '{' initializer_list ',' '}' { $$ = newiList(INIT_DEEP,revinit($2)); } + ; + +initializer_list + : initializer + | initializer_list ',' initializer { $3->next = $1; $$ = $3; } + ; + +statement + : labeled_statement + | compound_statement + | expression_statement + | selection_statement + | iteration_statement + | jump_statement + | INLINEASM ';' { + ast *ex = newNode(INLINEASM,NULL,NULL); + ALLOC_ATOMIC(ex->values.inlineasm,strlen($1)); + strcpy(ex->values.inlineasm,$1); + $$ = ex; + } + ; + +labeled_statement + : identifier ':' statement { $$ = createLabel($1,$3); } + | CASE constant_expr ':' statement { $$ = createCase(STACK_PEEK(swStk),$2,$4); } + | DEFAULT ':' statement { $$ = createDefault(STACK_PEEK(swStk),$3); } + ; + +start_block : '{' { STACK_PUSH(blockNum,currBlockno); currBlockno = ++blockNo ; } + ; + +end_block : '}' { currBlockno = STACK_POP(blockNum); } + ; + +compound_statement + : start_block end_block { $$ = createBlock(NULL,NULL); } + | start_block statement_list end_block { $$ = createBlock(NULL,$2) ; } + | start_block + declaration_list { addSymChain($2); } + end_block { $$ = createBlock($2,NULL) ; } + | start_block + declaration_list { addSymChain ($2); } + statement_list + end_block {$$ = createBlock($2,$4) ; } + | error ';' { $$ = NULL ; } + ; + +declaration_list + : declaration + { + /* if this is typedef declare it immediately */ + if ( $1 && IS_TYPEDEF($1->etype)) { + allocVariables ($1); + $$ = NULL ; + } + else + $$ = $1 ; + } + + | declaration_list declaration + { + symbol *sym; + + /* if this is a typedef */ + if ($2 && IS_TYPEDEF($2->etype)) { + allocVariables ($2); + $$ = $1 ; + } + else { + /* get to the end of the previous decl */ + if ( $1 ) { + $$ = sym = $1 ; + while (sym->next) + sym = sym->next ; + sym->next = $2; + } + else + $$ = $2 ; + } + } + ; + +statement_list + : statement + | statement_list statement { $$ = newNode(NULLOP,$1,$2) ;} + ; + +expression_statement + : ';' { $$ = NULL;} + | expr ';' + ; + +else_statement + : ELSE statement { $$ = $2 ; } + | { $$ = NULL;} + ; + + +selection_statement + : IF '(' expr ')' statement else_statement { noLineno++ ; $$ = createIf ($3, $5, $6 ); noLineno--;} + | SWITCH '(' expr ')' { + ast *ex ; + static int swLabel = 0 ; + + /* create a node for expression */ + ex = newNode(SWITCH,$3,NULL); + STACK_PUSH(swStk,ex); /* save it in the stack */ + ex->values.switchVals.swNum = swLabel ; + + /* now create the label */ + sprintf(lbuff,"_swBrk_%d",swLabel++); + $$ = newSymbol(lbuff,NestLevel); + /* put label in the break stack */ + STACK_PUSH(breakStack,$$); + } + statement { + /* get back the switch form the stack */ + $$ = STACK_POP(swStk) ; + $$->right = newNode (NULLOP,$6,createLabel($5,NULL)); + STACK_POP(breakStack); + } + ; + +while : WHILE { /* create and push the continue , break & body labels */ + static int Lblnum = 0 ; + /* continue */ + sprintf (lbuff,"_whilecontinue_%d",Lblnum); + STACK_PUSH(continueStack,newSymbol(lbuff,NestLevel)); + /* break */ + sprintf (lbuff,"_whilebreak_%d",Lblnum); + STACK_PUSH(breakStack,newSymbol(lbuff,NestLevel)); + /* body */ + sprintf (lbuff,"_whilebody_%d",Lblnum++); + $$ = newSymbol(lbuff,NestLevel); + } + +do : DO { /* create and push the continue , break & body Labels */ + static int Lblnum = 0 ; + + /* continue */ + sprintf(lbuff,"_docontinue_%d",Lblnum); + STACK_PUSH(continueStack,newSymbol(lbuff,NestLevel)); + /* break */ + sprintf (lbuff,"_dobreak_%d",Lblnum); + STACK_PUSH(breakStack,newSymbol(lbuff,NestLevel)); + /* do body */ + sprintf (lbuff,"_dobody_%d",Lblnum++); + $$ = newSymbol (lbuff,NestLevel); + } +for : FOR { /* create & push continue, break & body labels */ + static int Lblnum = 0 ; + + /* continue */ + sprintf (lbuff,"_forcontinue_%d",Lblnum); + STACK_PUSH(continueStack,newSymbol(lbuff,NestLevel)); + /* break */ + sprintf (lbuff,"_forbreak_%d",Lblnum); + STACK_PUSH(breakStack,newSymbol(lbuff,NestLevel)); + /* body */ + sprintf (lbuff,"_forbody_%d",Lblnum); + $$ = newSymbol(lbuff,NestLevel); + /* condition */ + sprintf (lbuff,"_forcond_%d",Lblnum++); + STACK_PUSH(forStack,newSymbol(lbuff,NestLevel)); + } + +iteration_statement + : while '(' expr ')' statement + { + noLineno++ ; + $$ = createWhile ( $1, STACK_POP(continueStack), + STACK_POP(breakStack), $3, $5 ); + $$->lineno = $1->lineDef ; + noLineno-- ; + } + | do statement WHILE '(' expr ')' ';' + { + noLineno++ ; + $$ = createDo ( $1 , STACK_POP(continueStack), + STACK_POP(breakStack), $5, $2); + $$->lineno = $1->lineDef ; + noLineno-- ; + } + | for '(' expr_opt ';' expr_opt ';' expr_opt ')' statement + { + noLineno++ ; + + /* if break or continue statement present + then create a general case loop */ + if (STACK_PEEK(continueStack)->isref || + STACK_PEEK(breakStack)->isref) { + $$ = createFor ($1, STACK_POP(continueStack), + STACK_POP(breakStack) , + STACK_POP(forStack) , + $3 , $5 , $7, $9 ); + } else { + $$ = newNode(FOR,$9,NULL); + AST_FOR($$,trueLabel) = $1; + AST_FOR($$,continueLabel) = STACK_POP(continueStack); + AST_FOR($$,falseLabel) = STACK_POP(breakStack); + AST_FOR($$,condLabel) = STACK_POP(forStack) ; + AST_FOR($$,initExpr) = $3; + AST_FOR($$,condExpr) = $5; + AST_FOR($$,loopExpr) = $7; + } + + noLineno-- ; + } +; + +expr_opt + : { $$ = NULL ; } + | expr + ; + +jump_statement + : GOTO identifier ';' { + $2->islbl = 1; + $$ = newAst(EX_VALUE,symbolVal($2)); + $$ = newNode(GOTO,$$,NULL); + } + | CONTINUE ';' { + /* make sure continue is in context */ + if (STACK_PEEK(continueStack) == NULL) { + werror(E_BREAK_CONTEXT); + $$ = NULL; + } + else { + $$ = newAst(EX_VALUE,symbolVal(STACK_PEEK(continueStack))); + $$ = newNode(GOTO,$$,NULL); + /* mark the continue label as referenced */ + STACK_PEEK(continueStack)->isref = 1; + } + } + | BREAK ';' { + if (STACK_PEEK(breakStack) == NULL) { + werror(E_BREAK_CONTEXT); + $$ = NULL; + } else { + $$ = newAst(EX_VALUE,symbolVal(STACK_PEEK(breakStack))); + $$ = newNode(GOTO,$$,NULL); + STACK_PEEK(breakStack)->isref = 1; + } + } + | RETURN ';' { $$ = newNode(RETURN,NULL,NULL) ; } + | RETURN expr ';' { $$ = newNode(RETURN,NULL,$2) ; } + ; + +identifier + : IDENTIFIER { $$ = newSymbol ($1,NestLevel) ; } + ; +%% + +extern unsigned char *yytext; +extern int column; +extern char *filename; +extern int fatalError; + +int yyerror(char *s) +{ + fflush(stdout); + + if ( yylineno ) + fprintf(stderr,"\n%s(%d) %s: token -> '%s' ; column %d\n", + filename,yylineno, + s,yytext,column); + fatalError++; + return 0; +} + diff --git a/src/SDCCBBlock.c b/src/SDCCBBlock.c new file mode 100644 index 00000000..1b4eac79 --- /dev/null +++ b/src/SDCCBBlock.c @@ -0,0 +1,577 @@ +/*------------------------------------------------------------------------- + SDCCBBlock.c - routines to manipulate basic Blocks + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCCBBlock.h" + + +int eBBNum = 0; +set *graphEdges = NULL ; /* list of edges in this flow graph */ +extern int labelKey ; + +/*-----------------------------------------------------------------*/ +/* printEntryLabel - prints entry label of a ebblock */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(printEntryLabel) +{ + eBBlock *bp = item; + + fprintf (stdout," %-20s ",bp->entryLabel->name); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* neweBBlock - allocate & return a new extended basic block */ +/*-----------------------------------------------------------------*/ +eBBlock *neweBBlock () +{ + eBBlock *ebb; + + ALLOC(ebb,sizeof(eBBlock)); + return ebb ; +} + +/*-----------------------------------------------------------------*/ +/* newEdge - allocates & initialises an edge to given values */ +/*-----------------------------------------------------------------*/ +edge *newEdge (eBBlock *from, eBBlock *to) +{ + edge *ep ; + + ALLOC(ep,sizeof(edge)); + + ep->from = from; + ep->to = to; + return ep; +} + +/*-----------------------------------------------------------------*/ +/* dumpEbbsToFileExt - writeall the basic blocks to a file */ +/*-----------------------------------------------------------------*/ +void dumpEbbsToFileExt (char *ext,eBBlock **ebbs, int count) +{ + FILE *of; + int i; + + /* create the file name */ + strcpy(buffer,srcFileName); + strcat(buffer,ext); + + if (!(of = fopen(buffer,"a+"))) { + werror(E_FILE_OPEN_ERR,buffer); + exit(1); + } + + for (i=0; i < count ; i++ ) { + fprintf(of,"\n----------------------------------------------------------------\n"); + fprintf(of,"Basic Block %s : loop Depth = %d noPath = %d , lastinLoop = %d\n", + ebbs[i]->entryLabel->name, + ebbs[i]->depth, + ebbs[i]->noPath, + ebbs[i]->isLastInLoop); + fprintf(of,"\ndefines bitVector :"); + bitVectDebugOn(ebbs[i]->defSet,of); + fprintf(of,"\nlocal defines bitVector :"); + bitVectDebugOn(ebbs[i]->ldefs,of); + fprintf(of,"\npointers Set bitvector :"); + bitVectDebugOn(ebbs[i]->ptrsSet,of); + fprintf(of,"\n----------------------------------------------------------------\n"); + printiCChain(ebbs[i]->sch,of); + } + fclose(of); +} + +/*-----------------------------------------------------------------*/ +/* iCode2eBBlock - converts a sequnce till label to a ebb */ +/*-----------------------------------------------------------------*/ +eBBlock *iCode2eBBlock (iCode *ic) +{ + iCode *loop ; + eBBlock *ebb = neweBBlock(); /* a llocate an entry */ + + /* put the first one unconditionally */ + ebb->sch = ic ; + + /* if this is a label then */ + if (ic->op == LABEL) + ebb->entryLabel = ic->argLabel.label ; + else { + sprintf(buffer,"_eBBlock%d",eBBNum++); + ebb->entryLabel = newSymbol(buffer,1); + ebb->entryLabel->key = labelKey++; + } + + if (ic && + ( ic->op == GOTO || + ic->op == JUMPTABLE || + ic->op == IFX )) { + ebb->ech = ebb->sch; + return ebb; + } + + if ((ic->next && ic->next->op == LABEL) || + !ic->next ) { + ebb->ech = ebb->sch ; + return ebb ; + } + + /* loop thru till we find one with a label */ + for ( loop = ic->next ; loop ; loop = loop->next ) { + + /* if this is the last one */ + if (!loop->next) + break; + /* if this is a function call */ + if (loop->op == CALL || loop->op == PCALL) { + ebb->hasFcall = 1; + if (currFunc) + currFunc->hasFcall = 1; + } + + /* if the next one is a label */ + /* if this is a goto or ifx */ + if (loop->next->op == LABEL || + loop->op == GOTO || + loop->op == JUMPTABLE || + loop->op == IFX ) + break ; + } + + /* mark the end of the chain */ + ebb->ech = loop ; + + return ebb; +} + +/*-----------------------------------------------------------------*/ +/* eBBWithEntryLabel - finds the basic block with the entry label */ +/*-----------------------------------------------------------------*/ +eBBlock *eBBWithEntryLabel ( eBBlock **ebbs , symbol *eLabel, int count) +{ + int i; + + for ( i = 0 ; i < count ; i++ ) { + if (isSymbolEqual(ebbs[i]->entryLabel,eLabel)) + return ebbs[i] ; + } + + return NULL ; +} + + +/*-----------------------------------------------------------------*/ +/* ifFromIs - will return 1 if the from block matches this */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifFromIs) +{ + edge *ep = item; + V_ARG(eBBlock *,this); + + if (ep->from == this) + return 1; + + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* edgesTo - returns a set of edges with to == supplied value */ +/*-----------------------------------------------------------------*/ +set *edgesTo ( eBBlock *to ) +{ + set *result = NULL ; + edge *loop ; + + for (loop = setFirstItem(graphEdges) ; loop ; loop = setNextItem(graphEdges)) + if (loop->to == to && !loop->from->noPath) + addSet(&result,loop->from); + + return result ; +} + + +/*-----------------------------------------------------------------*/ +/* addiCodeToeBBlock - will add an iCode to the end of a block */ +/*-----------------------------------------------------------------*/ +void addiCodeToeBBlock ( eBBlock *ebp, iCode *ic , iCode *ip) +{ + ic->prev = ic->next = NULL; + /* if the insert point is given */ + if (ip) { + ic->lineno = ip->lineno; + ic->prev = ip->prev; + ip->prev = ic; + ic->next = ip; + if (!ic->prev) + ebp->sch = ic; + else + ic->prev->next = ic; + return; + } + + /* if the block has no instructions */ + if (ebp->ech == NULL ) { + ebp->sch = ebp->ech = ic; + ic->next = NULL; + return ; + } + + /* if the last instruction is a goto */ + /* we add it just before the goto */ + if ( ebp->ech->op == GOTO || ebp->ech->op == JUMPTABLE) { + ic->lineno = ebp->ech->lineno; + ic->prev = ebp->ech->prev; + ebp->ech->prev = ic; + ic->next = ebp->ech; + if (!ic->prev) /* was the last only on in the block */ + ebp->sch = ic; + else + ic->prev->next = ic; + return; + } + + /* if the last one was a ifx statement we check to see */ + /* if the condition was defined in the previous instruction */ + /* if this is true then we put it before the condition else */ + /* we put it before if, this is to reduce register pressure,*/ + /* we don't have to hold condition too long in a register */ + if ( ebp->ech->op == IFX ) { + iCode *ipoint ; + +/* if ( !ebp->ech->prev ) */ +/* ipoint = ebp->ech ; */ +/* else */ +/* if (!IC_RESULT(ebp->ech->prev)) */ +/* ipoint = ebp->ech ; */ +/* else */ +/* if (IC_COND(ebp->ech)->key == IC_RESULT(ebp->ech->prev)->key) */ +/* ipoint = ebp->ech->prev; */ +/* else */ +/* ipoint = ebp->ech ; */ + ipoint = ebp->ech ; + ic->lineno = ipoint->lineno; + ic->prev = ipoint->prev; + ipoint->prev = ic; + ic->next = ipoint; + if (!ic->prev) + ebp->sch = ic; + else + ic->prev->next = ic; + return; + } + + /* will add it to the very end */ + ip = ebp->ech; + ip->next = ic; + ic->prev = ip; + ic->next = NULL; + ebp->ech = ic; + + return ; +} + +/*-----------------------------------------------------------------*/ +/* remiCodeFromeBBlock - remove an iCode from BBlock */ +/*-----------------------------------------------------------------*/ +void remiCodeFromeBBlock (eBBlock *ebb, iCode *ic) +{ + if (ic->prev) + ic->prev->next = ic->next ; + else + ebb->sch = ic->next ; + + if (ic->next) + ic->next->prev = ic->prev; + else + ebb->ech = ic->prev; +} + +/*-----------------------------------------------------------------*/ +/* iCodeBreakDown : breakDown iCode chain to blocks */ +/*-----------------------------------------------------------------*/ +eBBlock **iCodeBreakDown (iCode *ic, int *count) +{ + eBBlock **ebbs = NULL ; + iCode *loop = ic; + + *count = 0 ; + + /* allocate for the first entry */ + ALLOC(ebbs,sizeof(eBBlock **)); + + while (loop) { + + /* convert 2 block */ + eBBlock *ebb = iCode2eBBlock(loop); + loop = ebb->ech->next ; + + ebb->ech->next = NULL ; /* mark the end of this chain */ + if (loop) + loop->prev = NULL ; + ebb->bbnum = *count ; /* save this block number */ + /* put it in the array */ + ebbs[(*count)++] = ebb ; + + /* allocate for the next one */ + if (!(ebbs = GC_realloc(ebbs,(*count + 1)*sizeof(eBBlock **)))) { + werror(E_OUT_OF_MEM,__FILE__,(*count + 1)*sizeof(eBBlock **)); + exit (1); + } + + /* if this one ends in a goto or a conditional */ + /* branch then check if the block it is going */ + /* to already exists, if yes then this could */ + /* be a loop, add a preheader to the block it */ + /* goes to if it does not already have one */ + if (ebbs[(*count) - 1]->ech && + (ebbs[(*count) - 1]->ech->op == GOTO || + ebbs[(*count) - 1]->ech->op == IFX )) { + + symbol *label ; + eBBlock *destBlock; + + if (ebbs[(*count) - 1]->ech->op == GOTO) + label = IC_LABEL(ebbs[(*count)-1]->ech); + else + if (!(label = IC_TRUE(ebbs[(*count)-1]->ech))) + label = IC_FALSE(ebbs[(*count)-1]->ech); + + if ((destBlock = eBBWithEntryLabel(ebbs,label,(*count))) && + destBlock->preHeader == NULL && + otherPathsPresent(ebbs,destBlock) ) { + + symbol *preHeaderLabel = newiTempPreheaderLabel(); + int i,j ; + eBBlock *pBlock ; + + /* go thru all block replacing the entryLabel with new label */ + /* till we reach the block , then we insert a new ebblock */ + for ( i = 0 ; i < (*count) ; i++ ) { + if ( ebbs[i] == destBlock ) + break ; + replaceLabel(ebbs[i],label,preHeaderLabel); + } + + (*count)++ ; + /* if we have stopped at the block , allocate for an extra one */ + if (!(ebbs = GC_realloc(ebbs,(*count + 1)*sizeof(eBBlock **)))) { + werror(E_OUT_OF_MEM,__FILE__,(*count + 1)*sizeof(eBBlock **)); + exit (1); + } + + /* then move the block down one count */ + pBlock = ebbs[j = i]; + for ( i += 1; i < (*count) ; i++ ) { + eBBlock *xBlock; + + xBlock = ebbs[i]; + ebbs[i] = pBlock; + ebbs[i]->bbnum = i; + pBlock = xBlock ; + } + + destBlock->preHeader = ebbs[j] = neweBBlock(); + ebbs[j]->bbnum = j; + ebbs[j]->entryLabel = preHeaderLabel ; + ebbs[j]->sch = ebbs[j]->ech = newiCodeLabelGoto(LABEL,preHeaderLabel); + ebbs[j]->sch->lineno = destBlock->sch->lineno; + } + } + } + + /* mark the end */ + ebbs[*count] = NULL ; + + return ebbs ; +} + +/*-----------------------------------------------------------------*/ +/* replaceSymBySym : - replace operand by operand in blocks */ +/* replaces only left & right in blocks */ +/*-----------------------------------------------------------------*/ + void replaceSymBySym (set *sset, operand *src, operand *dest) +{ + set *loop ; + eBBlock *rBlock ; + + /* for all blocks in the set do */ + for ( loop = sset ; loop ; loop = loop->next) { + iCode *ic ; + + rBlock = loop->item ; + /* for all instructions in this block do */ + for ( ic = rBlock->sch ; ic ; ic = ic->next ) { + + /* if we find usage */ + if (ic->op == IFX && isOperandEqual(src,IC_COND(ic))) { + bitVectUnSetBit (OP_USES(IC_COND(ic)),ic->key); + IC_COND(ic) = operandFromOperand(dest); + OP_USES(dest) = bitVectSetBit (OP_USES(dest),ic->key); + continue ; + } + + if (isOperandEqual(IC_RIGHT(ic),src)) { + bitVectUnSetBit (OP_USES(IC_RIGHT(ic)),ic->key); + IC_RIGHT(ic) = operandFromOperand(dest); + IC_RIGHT(ic)->isaddr = 0; + OP_USES(dest) = bitVectSetBit (OP_USES(dest),ic->key); + } + + if (isOperandEqual(IC_LEFT(ic),src)) { + bitVectUnSetBit (OP_USES(IC_LEFT(ic)),ic->key); + if (POINTER_GET(ic) && IS_ITEMP(dest)) { + IC_LEFT(ic) = operandFromOperand(dest); + IC_LEFT(ic)->isaddr = 1; + } else { + IC_LEFT(ic) = operandFromOperand(dest); + IC_LEFT(ic)->isaddr = 0; + } + OP_USES(dest) = bitVectSetBit (OP_USES(dest),ic->key); + } + + /* special case for pointer sets */ + if (POINTER_SET(ic) && + isOperandEqual(IC_RESULT(ic),src)) { + bitVectUnSetBit (OP_USES(IC_RESULT(ic)),ic->key); + IC_RESULT(ic) = operandFromOperand(dest); + IC_RESULT(ic)->isaddr = 1; + OP_USES(dest) = bitVectSetBit(OP_USES(dest),ic->key); + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* replaceLabel - replace reference to one label by another */ +/*-----------------------------------------------------------------*/ + void replaceLabel(eBBlock *ebp, symbol *fromLbl, symbol *toLbl) +{ + iCode *ic; + + if (!ebp) + return ; + + for (ic = ebp->sch ; ic ; ic = ic->next ) { + switch (ic->op) { + + case GOTO : + if (isSymbolEqual(IC_LABEL(ic),fromLbl)) + IC_LABEL(ic) = toLbl; + break; + + case IFX: + if (IC_TRUE(ic) && isSymbolEqual(IC_TRUE(ic),fromLbl)) + IC_TRUE(ic) = toLbl ; + else + if (isSymbolEqual(IC_FALSE(ic),fromLbl)) + IC_FALSE(ic) = toLbl; + break; + } + } + + return; + +} + + +/*-----------------------------------------------------------------*/ +/* iCodeFromeBBlock - convert basic block to iCode chain */ +/*-----------------------------------------------------------------*/ +iCode *iCodeFromeBBlock ( eBBlock **ebbs, int count) +{ + int i = 1 ; + iCode *ric = ebbs[0]->sch ; + iCode *lic = ebbs[0]->ech ; + + for ( ; i < count; i++ ) { + if ( ebbs[i]->sch == NULL) + continue ; + + if ( ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel )) { + werror(W_CODE_UNREACH,ebbs[i]->sch->filename,ebbs[i]->sch->lineno); + continue ; + } + + lic->next = ebbs[i]->sch ; + lic->next->prev = lic; + lic = ebbs[i]->ech ; + } + + return ric; +} + +/*-----------------------------------------------------------------*/ +/* otherPathsPresent - determines if there is a path from _entry */ +/* to this block in a half constructed set of blocks */ +/*-----------------------------------------------------------------*/ +int otherPathsPresent (eBBlock **ebbs, eBBlock *this) +{ + int i ; + + /* for all blocks preceding this block */ + for ( i = 0 ; i < this->bbnum ; i++ ) { + iCode *ic ; + + /* if there is a reference to the entry label of this block */ + for ( ic = ebbs[i]->sch ; ic ; ic = ic->next ) { + switch (ic->op) { + case GOTO : + if (IC_LABEL(ic)->key == this->entryLabel->key) + return 1; + break; + + case IFX : + if (IC_TRUE(ic)) { + if (IC_TRUE(ic)->key == this->entryLabel->key) + return 1; + } else + if (IC_FALSE(ic)->key == this->entryLabel->key) + return 1 ; + break; + } + } + } + + /* comes here means we have not found it yet */ + /* in this case check if the previous block */ + /* ends in a goto if it does then we have no */ + /* path else we have a path */ + if (this->bbnum && ebbs[this->bbnum - 1]->ech && + ebbs[this->bbnum - 1]->ech->op == GOTO ) + return 0; + else + return 1; +} + diff --git a/src/SDCCBBlock.h b/src/SDCCBBlock.h new file mode 100644 index 00000000..b8ad1aab --- /dev/null +++ b/src/SDCCBBlock.h @@ -0,0 +1,93 @@ +/*------------------------------------------------------------------------- + + SDCCBBlock.h - header file for Basic Blocks + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCCBBLOCK_H +#define SDCCBBLOCK_H 1 + +/* definition of a basic block */ +typedef struct eBasicBlock { + int dfnum ; /* depth first number */ + int bbnum ; /* index into array of numbers */ + int depth ; /* loop depth of this block */ + int fSeq ; /* sequence number of first iCode */ + int lSeq ; /* sequence number of the last iCode */ + unsigned int visited:1; /* visitied flag */ + unsigned int hasFcall:1;/* has a function call */ + unsigned int noPath :1; /* there is no path from _entry to this block */ + unsigned int isLastInLoop:1; /* is the last block in a loop */ + symbol *entryLabel ; /* entry label */ + + iCode *sch ; /* pointer to start of code chain */ + iCode *ech ; /* pointer to last of code chain */ + + struct eBasicBlock *preHeader ; /* preheader if this is a loop entry */ + struct region *partOfLoop; /* pointer to the loop region this block is part of */ + + /* control flow analysis */ + set *succList ; /* list eBBlocks which are successors */ + bitVect *succVect ; /* bitVector of successors */ + set *predList ; /* predecessors of this basic block */ + bitVect *domVect ; /* list of nodes this is dominated by */ + + /* data flow analysis */ + set *inExprs ; /* in coming common expressions */ + set *outExprs ; /* out going common expressions */ + bitVect *inDefs; /* in coming defintions */ + bitVect *outDefs; /* out going defintions */ + bitVect *defSet; /* symbols defined in block */ + bitVect *ldefs ; /* local definitions only */ + bitVect *usesDefs;/* which definitions are used in this block */ + bitVect *ptrsSet; /* pointers assigned values in the block */ + bitVect *inPtrsSet;/* in coming pointers assigned values */ + set *addrOf ; /* symbols for which addres has been taken in the block */ + bitVect *linds ; /* if loop exit this contains defNumbers + for the inductions */ +} eBBlock ; + +typedef struct edge { + + eBBlock *from ; /* from basic block */ + eBBlock *to ; /* to Basic Block */ +} edge ; + +extern int eBBNum ; +extern set *graphEdges ; + + +DEFSETFUNC(printEntryLabel) ; +eBBlock *neweBBlock () ; +edge *newEdge (eBBlock *, eBBlock *) ; +eBBlock *eBBWithEntryLabel ( eBBlock **, symbol *, int); +DEFSETFUNC(ifFromIs) ; +set *edgesTo ( eBBlock *); +void remiCodeFromeBBlock (eBBlock *, iCode *); +void addiCodeToeBBlock ( eBBlock *,iCode *,iCode *); +eBBlock **iCodeBreakDown (iCode *, int *); +void replaceSymBySym (set *, operand *, operand *); +iCode *iCodeFromeBBlock ( eBBlock **,int); +int otherPathsPresent (eBBlock **,eBBlock *); +void replaceLabel(eBBlock *,symbol *,symbol *); +void dumpEbbsToFileExt (char *,eBBlock **,int); +#endif diff --git a/src/SDCCast.c b/src/SDCCast.c new file mode 100644 index 00000000..9d534163 --- /dev/null +++ b/src/SDCCast.c @@ -0,0 +1,3630 @@ +/*------------------------------------------------------------------------- + SDCCast.c - source file for parser support & all ast related routines + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCicode.h" +#include "SDCCopt.h" + + +int currLineno = 0; +set *astList = NULL ; +set *operKeyReset = NULL; +extern char *currFname ; +ast *staticAutos = NULL; +int labelKey = 1 ; + +#define LRVAL(x) x->left->rvalue +#define RRVAL(x) x->right->rvalue +#define TRVAL(x) x->rvalue +#define LLVAL(x) x->left->lvalue +#define RLVAL(x) x->right->lvalue +#define TLVAL(x) x->lvalue +#define RTYPE(x) x->right->ftype +#define RETYPE(x) x->right->etype +#define LTYPE(x) x->left->ftype +#define LETYPE(x) x->left->etype +#define TTYPE(x) x->ftype +#define TETYPE(x) x->etype +#define ALLOCATE 1 +#define DEALLOCATE 2 + +char buffer[1024]; +int noLineno = 0; +int noAlloc = 0 ; +symbol *currFunc ; +extern int fatalError ; +extern int lineno; +extern char *filename ; +extern set *publics; +extern ast *createIval (ast *, link *, initList *, ast *); +extern ast *createIvalCharPtr (ast *, link *, ast *); +ast *optimizeRRCRLC ( ast * ); +ast *optimizeGetHbit(ast *); +ast *backPatchLabels (ast *,symbol *,symbol *); +int inInitMode = 0; +FILE *codeOutFile ; +int ptt(ast *tree) { + printTypeChain(tree->ftype,stdout); + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* newAst - creates a fresh node for an expression tree */ +/*-----------------------------------------------------------------*/ +ast *newAst (int type, void *op ) +{ + ast *ex ; + static int oldLineno = 0 ; + + ALLOC(ex,sizeof(ast)); + + ex->type = type ; + ex->lineno = (noLineno ? oldLineno : yylineno); + ex->filename = currFname ; + ex->level = NestLevel ; + ex->block = currBlockno ; + ex->initMode = inInitMode; + + /* depending on the type */ + switch (type) { + case EX_VALUE : + ex->opval.val = (value *) op; + break ; + case EX_OP : + ex->opval.op = (int) op ; + break ; + case EX_LINK : + ex->opval.lnk = (link *) op; + break ; + case EX_STMNT : + ex->opval.stmnt= (unsigned) op; + } + + return ex; +} + +/*-----------------------------------------------------------------*/ +/* newNode - creates a new node */ +/*-----------------------------------------------------------------*/ +ast *newNode ( int op, ast *left, ast *right ) +{ + ast *ex ; + + ex = newAst (EX_OP,(void *) op) ; + ex->left = left ; + ex->right = right; + + return ex ; +} + +/*-----------------------------------------------------------------*/ +/* newIfxNode - creates a new Ifx Node */ +/*-----------------------------------------------------------------*/ +ast *newIfxNode (ast *condAst, symbol *trueLabel, symbol *falseLabel) +{ + ast *ifxNode ; + + /* if this is a literal then we already know the result */ + if (condAst->etype && IS_LITERAL(condAst->etype)) { + + /* then depending on the expression value */ + if ( floatFromVal(condAst->opval.val) ) + ifxNode = newNode(GOTO, newAst(EX_VALUE, + symbolVal (trueLabel )),NULL); + else + ifxNode = newNode(GOTO, newAst(EX_VALUE, + symbolVal (falseLabel )),NULL); + } + else { + ifxNode = newNode(IFX,condAst,NULL); + ifxNode->trueLabel = trueLabel; + ifxNode->falseLabel= falseLabel; + } + + return ifxNode ; +} + +/*-----------------------------------------------------------------*/ +/* copyAstValues - copies value portion of ast if needed */ +/*-----------------------------------------------------------------*/ +void copyAstValues (ast *dest,ast *src) +{ + switch (src->opval.op) { + case BLOCK: + dest->values.sym = copySymbolChain(src->values.sym); + break; + + case SWITCH: + dest->values.switchVals.swVals = + copyValue(src->values.switchVals.swVals); + dest->values.switchVals.swDefault = + src->values.switchVals.swDefault ; + dest->values.switchVals.swNum = + src->values.switchVals.swNum ; + break ; + + case INLINEASM: + ALLOC_ATOMIC(dest->values.inlineasm,strlen(src->values.inlineasm)); + strcpy(dest->values.inlineasm,src->values.inlineasm); + + case FOR: + AST_FOR(dest,trueLabel) = copySymbol(AST_FOR(src,trueLabel)); + AST_FOR(dest,continueLabel) = copySymbol(AST_FOR(src,continueLabel)); + AST_FOR(dest,falseLabel) = copySymbol(AST_FOR(src,falseLabel)); + AST_FOR(dest,condLabel) = copySymbol(AST_FOR(src,condLabel)); + AST_FOR(dest,initExpr) = copyAst (AST_FOR(src,initExpr)) ; + AST_FOR(dest,condExpr) = copyAst (AST_FOR(src,condExpr)) ; + AST_FOR(dest,loopExpr) = copyAst (AST_FOR(src,loopExpr)) ; + } + +} + +/*-----------------------------------------------------------------*/ +/* copyAst - makes a copy of a given astession */ +/*-----------------------------------------------------------------*/ +ast *copyAst (ast *src) +{ + ast *dest; + + if (!src) return NULL ; + + ALLOC(dest,sizeof(ast)); + + dest->type = src->type ; + dest->lineno = src->lineno ; + dest->level = src->level ; + dest->funcName = src->funcName; + dest->argSym = src->argSym; + + /* if this is a leaf */ + /* if value */ + if (src->type == EX_VALUE) { + dest->opval.val = copyValue(src->opval.val); + goto exit; + } + + /* if link */ + if (src->type == EX_LINK) { + dest->opval.lnk = copyLinkChain(src->opval.lnk); + goto exit ; + } + + dest->opval.op = src->opval.op ; + + /* if this is a node that has special values */ + copyAstValues (dest,src); + + if ( src->ftype ) + dest->etype = getSpec(dest->ftype = copyLinkChain(src->ftype)) ; + + dest->trueLabel = copySymbol (src->trueLabel); + dest->falseLabel= copySymbol (src->falseLabel); + dest->left = copyAst(src->left); + dest->right= copyAst(src->right); + exit: + return dest ; + +} + +/*-----------------------------------------------------------------*/ +/* hasSEFcalls - returns TRUE if tree has a function call */ +/*-----------------------------------------------------------------*/ +bool hasSEFcalls ( ast *tree) +{ + if (!tree) + return FALSE ; + + if (tree->type == EX_OP && + ( tree->opval.op == CALL || + tree->opval.op == PCALL || + tree->opval.op == '=' || + tree->opval.op == INC_OP || + tree->opval.op == DEC_OP )) + return TRUE; + + return ( hasSEFcalls(tree->left) | + hasSEFcalls(tree->right)); +} + +/*-----------------------------------------------------------------*/ +/* isAstEqual - compares two asts & returns 1 if they are equal */ +/*-----------------------------------------------------------------*/ +int isAstEqual (ast *t1, ast *t2) +{ + if (!t1 && !t2) + return 1; + + if (!t1 || !t2) + return 0; + + /* match type */ + if (t1->type != t2->type) + return 0; + + switch (t1->type) { + case EX_OP: + if (t1->opval.op != t2->opval.op) + return 0; + return ( isAstEqual(t1->left,t2->left) && + isAstEqual(t1->right,t2->right)); + break; + + case EX_VALUE: + if (t1->opval.val->sym) { + if (!t2->opval.val->sym) + return 0; + else + return isSymbolEqual(t1->opval.val->sym, + t2->opval.val->sym); + } + else { + if (t2->opval.val->sym) + return 0; + else + return (floatFromVal(t1->opval.val) == + floatFromVal(t2->opval.val)); + } + break; + + /* only compare these two types */ + default : + return 0; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* resolveSymbols - resolve symbols from the symbol table */ +/*-----------------------------------------------------------------*/ +ast *resolveSymbols (ast *tree) +{ + /* walk the entire tree and check for values */ + /* with symbols if we find one then replace */ + /* symbol with that from the symbol table */ + + if ( tree == NULL ) + return tree ; + + /* print the line */ + /* if not block & function */ + if ( tree->type == EX_OP && + ( tree->opval.op != FUNCTION && + tree->opval.op != BLOCK && + tree->opval.op != NULLOP )) { + filename = tree->filename ; + lineno = tree->lineno ; + } + + /* make sure we resolve the true & false labels for ifx */ + if (tree->type == EX_OP && tree->opval.op == IFX ) { + symbol *csym ; + + if (tree->trueLabel) { + if (( csym = findSym(LabelTab,tree->trueLabel, + tree->trueLabel->name))) + tree->trueLabel = csym ; + else + werror(E_LABEL_UNDEF,tree->trueLabel->name); + } + + if (tree->falseLabel) { + if (( csym = findSym(LabelTab, + tree->falseLabel, + tree->falseLabel->name))) + tree->falseLabel = csym ; + else + werror(E_LABEL_UNDEF,tree->falseLabel->name); + } + + } + + /* if this is a label resolve it from the labelTab*/ + if (IS_AST_VALUE(tree) && + tree->opval.val->sym && + tree->opval.val->sym->islbl) { + + symbol *csym = findSym (LabelTab, tree->opval.val->sym , + tree->opval.val->sym->name); + + if (!csym) + werror (E_LABEL_UNDEF,tree->opval.val->sym->name); + else + tree->opval.val->sym = csym ; + + goto resolveChildren ; + } + + /* do only for leafs */ + if (IS_AST_VALUE(tree) && + tree->opval.val->sym && + ! tree->opval.val->sym->implicit ) { + + symbol *csym = findSymWithLevel (SymbolTab,tree->opval.val->sym); + + /* if found in the symbol table & they r not the same */ + if (csym && tree->opval.val->sym != csym ) { + tree->opval.val->sym = csym ; + tree->opval.val->type = csym->type; + tree->opval.val->etype = csym->etype; + } + + /* if not found in the symbol table */ + /* mark it as undefined assume it is*/ + /* an integer in data space */ + if (!csym && !tree->opval.val->sym->implicit) { + + /* if this is a function name then */ + /* mark it as returning an int */ + if (tree->funcName) { + tree->opval.val->sym->type = newLink(); + DCL_TYPE(tree->opval.val->sym->type) = FUNCTION; + tree->opval.val->sym->type->next = + tree->opval.val->sym->etype = newIntLink(); + tree->opval.val->etype = tree->opval.val->etype; + tree->opval.val->type = tree->opval.val->sym->type; + werror(W_IMPLICIT_FUNC,tree->opval.val->sym->name); + } else { + tree->opval.val->sym->undefined =1 ; + tree->opval.val->type = + tree->opval.val->etype = newIntLink(); + tree->opval.val->sym->type = + tree->opval.val->sym->etype = newIntLink(); + } + } + } + + resolveChildren: + resolveSymbols (tree->left); + resolveSymbols (tree->right); + + return tree; +} + +/*-----------------------------------------------------------------*/ +/* setAstLineno - walks a ast tree & sets the line number */ +/*-----------------------------------------------------------------*/ +int setAstLineno ( ast *tree, int lineno) +{ + if (!tree) + return 0; + + tree->lineno = lineno ; + setAstLineno ( tree->left, lineno); + setAstLineno ( tree->right, lineno); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* resolveFromTable - will return the symbal table value */ +/*-----------------------------------------------------------------*/ +value *resolveFromTable (value *val) +{ + symbol *csym ; + + if (!val->sym) + return val; + + csym = findSymWithLevel (SymbolTab,val->sym); + + /* if found in the symbol table & they r not the same */ + if (csym && val->sym != csym && + csym->level == val->sym->level && + csym->_isparm && + !csym->ismyparm) { + + val->sym = csym ; + val->type = csym->type; + val->etype = csym->etype; + } + + return val; +} + +/*-----------------------------------------------------------------*/ +/* funcOfType :- function of type with name */ +/*-----------------------------------------------------------------*/ +symbol *funcOfType (char *name, link *type, link *argType, + int nArgs , int rent) +{ + symbol *sym; + + /* create the symbol */ + sym = newSymbol (name,0); + + /* if arguments required */ + if (nArgs) { + + value *args ; + args = sym->args = newValue(); + + while (nArgs--) { + args->type = copyLinkChain(argType); + args->etype = getSpec(args->type); + if (!nArgs) + break; + args = args->next = newValue(); + } + } + + /* setup return value */ + sym->type = newLink(); + DCL_TYPE(sym->type) = FUNCTION; + sym->type->next = copyLinkChain(type); + sym->etype = getSpec(sym->type); + SPEC_RENT(sym->etype) = rent; + + /* save it */ + addSymChain(sym); + sym->cdef = 1; + allocVariables (sym); + return sym; + +} + +/*-----------------------------------------------------------------*/ +/* reverseParms - will reverse a parameter tree */ +/*-----------------------------------------------------------------*/ +void reverseParms (ast *ptree) +{ + ast *ttree; + if (!ptree) + return ; + + /* top down if we find a nonParm tree then quit */ + if (ptree->type == EX_OP && ptree->opval.op == PARAM ) { + ttree = ptree->left; + ptree->left = ptree->right; + ptree->right = ttree; + reverseParms(ptree->left); + reverseParms(ptree->right); + } + + return ; +} + +/*-----------------------------------------------------------------*/ +/* processParms - makes sure the parameters are okay and do some */ +/* processing with them */ +/*-----------------------------------------------------------------*/ +int processParms (ast *func, value *defParm, + ast *actParm, + int *parmNumber) +{ + link *fetype = func->etype; + + /* if none of them exist */ + if ( !defParm && !actParm) + return 0; + + /* if the function is being called via a pointer & */ + /* it has not been defined a reentrant then we cannot*/ + /* have parameters */ + if (func->type != EX_VALUE && !IS_RENT(fetype) && !options.stackAuto) { + werror (E_NONRENT_ARGS); + return 1; + } + + /* if defined parameters ended but actual parameters */ + /* exist and this is not defined as a variable arg */ + /* also check if statckAuto option is specified */ + if ((! defParm) && actParm && (!func->hasVargs ) && + !options.stackAuto && !IS_RENT(fetype)) { + werror(E_TOO_MANY_PARMS); + return 1; + } + + /* if defined parameters present and actual paramters ended */ + if ( defParm && ! actParm) { + werror(E_TO_FEW_PARMS); + return 1; + } + + /* if defined parameters ended but actual has not & */ + /* has a variable argument list or statckAuto */ + if (! defParm && actParm && + (func->hasVargs || options.stackAuto || IS_RENT(fetype))) + return 0; + + resolveSymbols(actParm); + /* if this is a PARAM node then match left & right */ + if ( actParm->type == EX_OP && actParm->opval.op == PARAM) { + + return (processParms (func,defParm,actParm->left,parmNumber) || + processParms (func,defParm->next, actParm->right,parmNumber) ); + } + + /* the parameter type must be atleast castable */ + if (checkType(defParm->type,actParm->ftype) == 0) { + werror(E_TYPE_MISMATCH_PARM,*parmNumber); + werror(E_CONTINUE,"defined type "); + printTypeChain(defParm->type,stderr);fprintf(stderr,"\n"); + werror(E_CONTINUE,"actual type "); + printTypeChain(actParm->ftype,stderr);fprintf(stderr,"\n"); + } + + /* if the parameter is castable then add the cast */ + if ( checkType (defParm->type,actParm->ftype) < 0) { + ast *pTree = resolveSymbols(copyAst(actParm)); + + /* now change the current one to a cast */ + actParm->type = EX_OP ; + actParm->opval.op = CAST ; + actParm->left = newAst(EX_LINK,defParm->type); + actParm->right= pTree ; + actParm->etype= defParm->etype; + actParm->ftype= defParm->type; + } + + actParm->argSym = resolveFromTable(defParm)->sym ; + /* make a copy and change the regparm type to the defined parm */ + actParm->etype = getSpec(actParm->ftype = copyLinkChain(actParm->ftype)); + SPEC_REGPARM(actParm->etype) = SPEC_REGPARM(defParm->etype); + return 0; +} +/*-----------------------------------------------------------------*/ +/* createIvalType - generates ival for basic types */ +/*-----------------------------------------------------------------*/ +ast *createIvalType ( ast *sym,link *type, initList *ilist) +{ + ast *iExpr; + + /* if initList is deep */ + if ( ilist->type == INIT_DEEP ) + ilist = ilist->init.deep ; + + iExpr = decorateType(resolveSymbols(list2expr(ilist))); + return newNode('=',sym,iExpr); +} + +/*-----------------------------------------------------------------*/ +/* createIvalStruct - generates initial value for structures */ +/*-----------------------------------------------------------------*/ +ast *createIvalStruct (ast *sym,link *type,initList *ilist) +{ + ast *rast = NULL ; + symbol *sflds ; + initList *iloop ; + + sflds = SPEC_STRUCT(type)->fields ; + if (ilist->type != INIT_DEEP) { + werror(E_INIT_STRUCT,""); + return NULL ; + } + + iloop = ilist->init.deep; + + for ( ; sflds ; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL )) { + ast *lAst ; + + /* if we have come to end */ + if (!iloop) + break; + sflds->implicit = 1; + lAst = decorateType(resolveSymbols(newNode('.',sym, + newAst(EX_VALUE,symbolVal(sflds))))); + rast = createIval (lAst, sflds->type, iloop,rast); + } + return rast ; +} + + +/*-----------------------------------------------------------------*/ +/* createIvalArray - generates code for array initialization */ +/*-----------------------------------------------------------------*/ +ast *createIvalArray (ast *sym, link *type, initList *ilist) +{ + ast *rast = NULL; + initList *iloop ; + int lcnt = 0, size =0 ; + + /* take care of the special case */ + /* array of characters can be init */ + /* by a string */ + if ( IS_CHAR(type->next) ) + if ( (rast = createIvalCharPtr(sym, + type, + decorateType(resolveSymbols(list2expr(ilist)))))) + + return rast; + + /* not the special case */ + if (ilist->type != INIT_DEEP) { + werror(E_INIT_STRUCT,""); + return NULL; + } + + iloop = ilist->init.deep ; + lcnt = DCL_ELEM(type); + + for (;;) { + ast *aSym ; + size++ ; + + aSym = newNode('[',sym,newAst(EX_VALUE,valueFromLit(size-1))); + aSym = decorateType(resolveSymbols(aSym)); + rast = createIval (aSym,type->next,iloop,rast) ; + iloop = (iloop ? iloop->next : NULL) ; + if (!iloop) + break; + /* if not array limits given & we */ + /* are out of initialisers then */ + if (!DCL_ELEM(type) && !iloop) + break ; + + /* no of elements given and we */ + /* have generated for all of them */ + if (!--lcnt) + break ; + } + + /* if we have not been given a size */ + if (!DCL_ELEM(type)) + DCL_ELEM(type) = size; + + return rast; +} + + +/*-----------------------------------------------------------------*/ +/* createIvalCharPtr - generates initial values for char pointers */ +/*-----------------------------------------------------------------*/ +ast *createIvalCharPtr (ast *sym, link *type, ast *iexpr) +{ + ast *rast = NULL ; + + /* if this is a pointer & right is a literal array then */ + /* just assignment will do */ + if ( IS_PTR(type) && (( IS_LITERAL(iexpr->etype) || + SPEC_SCLS(iexpr->etype) == S_CODE ) + && IS_ARRAY(iexpr->ftype))) + return newNode('=',sym,iexpr); + + /* left side is an array so we have to assign each */ + /* element */ + if (( IS_LITERAL(iexpr->etype) || + SPEC_SCLS(iexpr->etype) == S_CODE ) + && IS_ARRAY(iexpr->ftype)) { + + /* for each character generate an assignment */ + /* to the array element */ + char *s = SPEC_CVAL(iexpr->etype).v_char ; + int i = 0 ; + + while (*s) { + rast = newNode(NULLOP, + rast, + newNode('=', + newNode('[', sym, + newAst(EX_VALUE,valueFromLit(i))), + newAst(EX_VALUE,valueFromLit(*s)))); + i++; + s++; + } + rast = newNode(NULLOP, + rast, + newNode('=', + newNode('[', sym, + newAst(EX_VALUE,valueFromLit(i))), + newAst(EX_VALUE,valueFromLit(*s)))); + return rast; + } + + return NULL ; +} + +/*-----------------------------------------------------------------*/ +/* createIvalPtr - generates initial value for pointers */ +/*-----------------------------------------------------------------*/ +ast *createIvalPtr (ast *sym,link *type,initList *ilist) +{ + ast *rast; + ast *iexpr ; + + /* if deep then */ + if ( ilist->type == INIT_DEEP ) + ilist = ilist->init.deep ; + + iexpr = decorateType(resolveSymbols(list2expr(ilist))); + + /* if character pointer */ + if (IS_CHAR(type->next)) + if ((rast = createIvalCharPtr (sym,type,iexpr))) + return rast; + + return newNode('=',sym,iexpr); +} + +/*-----------------------------------------------------------------*/ +/* createIval - generates code for initial value */ +/*-----------------------------------------------------------------*/ +ast *createIval (ast *sym, link *type, initList *ilist, ast *wid) +{ + ast *rast = NULL; + + if (!ilist) + return NULL ; + + /* if structure then */ + if (IS_STRUCT(type)) + rast = createIvalStruct(sym, type,ilist); + else + /* if this is a pointer */ + if (IS_PTR(type)) + rast = createIvalPtr(sym, type,ilist); + else + /* if this is an array */ + if (IS_ARRAY(type)) + rast = createIvalArray(sym, type,ilist); + else + /* if type is SPECIFIER */ + if (IS_SPEC(type)) + rast = createIvalType (sym,type,ilist); + if ( wid ) + return newNode(NULLOP,wid,rast); + else + return rast ; +} + +/*-----------------------------------------------------------------*/ +/* initAggregates - initialises aggregate variables with initv */ +/*-----------------------------------------------------------------*/ +ast *initAggregates ( symbol *sym, initList *ival, ast *wid) +{ + return createIval (newAst(EX_VALUE,symbolVal(sym)),sym->type,ival,wid); +} + +/*-----------------------------------------------------------------*/ +/* gatherAutoInit - creates assignment expressions for initial */ +/* values */ +/*-----------------------------------------------------------------*/ +ast *gatherAutoInit ( symbol *autoChain ) +{ + ast *init = NULL ; + ast *work ; + symbol *sym; + + inInitMode =1; + for ( sym = autoChain ; sym ; sym = sym->next ) { + + /* resolve the symbols in the ival */ + if (sym->ival) + resolveIvalSym(sym->ival); + + /* if this is a static variable & has an */ + /* initial value the code needs to be lifted */ + /* here to the main portion since they can be */ + /* initialised only once at the start */ + if ( IS_STATIC(sym->etype) && sym->ival && + SPEC_SCLS(sym->etype) != S_CODE) { + symbol *newSym ; + + /* insert the symbol into the symbol table */ + /* with level = 0 & name = rname */ + newSym = copySymbol (sym); + addSym (SymbolTab,newSym,newSym->name,0,0); + + /* now lift the code to main */ + if (IS_AGGREGATE(sym->type)) + work = initAggregates (sym, sym->ival,NULL); + else + work = newNode('=' ,newAst(EX_VALUE,symbolVal(newSym)), + list2expr(sym->ival)); + + setAstLineno(work,sym->lineDef); + + sym->ival = NULL ; + if ( staticAutos ) + staticAutos = newNode(NULLOP,staticAutos,work); + else + staticAutos = work ; + + continue; + } + + /* if there is an initial value */ + if ( sym->ival && SPEC_SCLS(sym->etype)!=S_CODE) { + if (IS_AGGREGATE(sym->type)) + work = initAggregates (sym,sym->ival,NULL); + else + work = newNode('=' ,newAst(EX_VALUE,symbolVal(sym)), + list2expr(sym->ival)); + + setAstLineno (work,sym->lineDef); + sym->ival = NULL ; + if ( init ) + init = newNode(NULLOP,init,work); + else + init = work ; + } + } + inInitMode = 0; + return init ; +} + +/*-----------------------------------------------------------------*/ +/* stringToSymbol - creates a symbol from a literal string */ +/*-----------------------------------------------------------------*/ +static value *stringToSymbol (value *val) +{ + char name[SDCC_NAME_MAX+1]; + static int charLbl = 0; + symbol *sym ; + + sprintf(name,"_str_%d",charLbl++); + sym = newSymbol(name,0); /* make it @ level 0 */ + strcpy(sym->rname,name); + + /* copy the type from the value passed */ + sym->type = copyLinkChain(val->type); + sym->etype = getSpec(sym->type); + /* change to storage class & output class */ + SPEC_SCLS(sym->etype) = S_CODE ; + SPEC_CVAL(sym->etype).v_char = SPEC_CVAL(val->etype).v_char ; + SPEC_STAT(sym->etype) = 1; + /* make the level & block = 0 */ + sym->block = sym->level = 0; + sym->isstrlit = 1; + /* create an ival */ + sym->ival = newiList(INIT_NODE,newAst(EX_VALUE,val)); + if (noAlloc == 0) { + /* allocate it */ + addSymChain(sym); + allocVariables(sym); + } + sym->ival = NULL; + return symbolVal(sym); + +} + +/*-----------------------------------------------------------------*/ +/* processBlockVars - will go thru the ast looking for block if */ +/* a block is found then will allocate the syms */ +/* will also gather the auto inits present */ +/*-----------------------------------------------------------------*/ +ast *processBlockVars ( ast *tree , int *stack, int action) +{ + if (! tree) + return NULL ; + + /* if this is a block */ + if (tree->type == EX_OP && tree->opval.op == BLOCK ) { + ast *autoInit ; + + if (action == ALLOCATE) { + autoInit = gatherAutoInit (tree->values.sym); + *stack += allocVariables (tree->values.sym); + + /* if there are auto inits then do them */ + if (autoInit) + tree->left = newNode(NULLOP,autoInit,tree->left); + } else /* action is deallocate */ + deallocLocal (tree->values.sym) ; + } + + processBlockVars (tree->left, stack, action); + processBlockVars (tree->right, stack, action); + return tree ; +} + +/*-----------------------------------------------------------------*/ +/* constExprValue - returns the value of a constant expression */ +/*-----------------------------------------------------------------*/ +value *constExprValue (ast *cexpr, int check) +{ + cexpr = decorateType(resolveSymbols(cexpr)); + + /* if this is not a constant then */ + if (!IS_LITERAL(cexpr->ftype)) { + /* then check if this is a literal array + in code segment */ + if (SPEC_SCLS(cexpr->etype) == S_CODE && + SPEC_CVAL(cexpr->etype).v_char && + IS_ARRAY(cexpr->ftype)) { + value *val = valFromType(cexpr->ftype); + SPEC_SCLS(val->etype) = S_LITERAL; + val->sym =cexpr->opval.val->sym ; + val->sym->type = copyLinkChain(cexpr->ftype); + val->sym->etype = getSpec(val->sym->type); + strcpy(val->name,cexpr->opval.val->sym->rname); + return val; + } + + /* if we are casting a literal value then */ + if (IS_AST_OP(cexpr) && + cexpr->opval.op == CAST && + IS_LITERAL(cexpr->left->ftype)) + return valCastLiteral(cexpr->ftype, + floatFromVal(cexpr->left->opval.val)); + + if (IS_AST_VALUE(cexpr)) + return cexpr->opval.val; + + if (check) + werror(E_CONST_EXPECTED,"found expression"); + + return NULL ; + } + + /* return the value */ + return cexpr->opval.val ; + +} + +/*-----------------------------------------------------------------*/ +/* isLabelInAst - will return true if a given label is found */ +/*-----------------------------------------------------------------*/ +bool isLabelInAst (symbol *label, ast *tree) +{ + if (!tree || IS_AST_VALUE(tree) || IS_AST_LINK(tree)) + return FALSE ; + + if (IS_AST_OP(tree) && + tree->opval.op == LABEL && + isSymbolEqual(AST_SYMBOL(tree->left),label)) + return TRUE; + + return isLabelInAst(label,tree->right) && + isLabelInAst(label,tree->left); + +} + +/*-----------------------------------------------------------------*/ +/* isLoopCountable - return true if the loop count can be determi- */ +/* -ned at compile time . */ +/*-----------------------------------------------------------------*/ +bool isLoopCountable (ast *initExpr, ast *condExpr, ast *loopExpr, + symbol **sym,ast **init, ast **end) +{ + + /* the loop is considered countable if the following + conditions are true :- + + a) initExpr :- = + b) condExpr :- < + c) loopExpr :- ++ + */ + + /* first check the initExpr */ + if ( IS_AST_OP(initExpr) && + initExpr->opval.op == '=' && /* is assignment */ + IS_AST_SYM_VALUE(initExpr->left)) { /* left is a symbol */ + + *sym = AST_SYMBOL(initExpr->left); + *init= initExpr->right; + } + else + return FALSE; + + /* for now the symbol has to be of + integral type */ + if (!IS_INTEGRAL((*sym)->type)) + return FALSE; + + /* now check condExpr */ + if (IS_AST_OP(condExpr)) { + + switch (condExpr->opval.op) { + case '<': + if (IS_AST_SYM_VALUE(condExpr->left) && + isSymbolEqual (*sym,AST_SYMBOL(condExpr->left)) && + IS_AST_LIT_VALUE(condExpr->right)) { + *end = condExpr->right; + break; + } + return FALSE; + + case '!': + if (IS_AST_OP(condExpr->left) && + condExpr->left->opval.op == '>' && + IS_AST_LIT_VALUE(condExpr->left->right) && + IS_AST_SYM_VALUE(condExpr->left->left)&& + isSymbolEqual (*sym,AST_SYMBOL(condExpr->left->left))) { + + *end = newNode('+', condExpr->left->right, + newAst(EX_VALUE,constVal("1"))); + break; + } + return FALSE ; + + default: + return FALSE ; + } + + } + + /* check loop expression is of the form ++ */ + if (!IS_AST_OP(loopExpr)) + return FALSE ; + + /* check if ++ */ + if (loopExpr->opval.op == INC_OP) { + + if (loopExpr->left) { + /* pre */ + if (IS_AST_SYM_VALUE(loopExpr->left) && + isSymbolEqual(*sym,AST_SYMBOL(loopExpr->left))) + return TRUE ; + + } else { + /* post */ + if (IS_AST_SYM_VALUE(loopExpr->right) && + isSymbolEqual(*sym,AST_SYMBOL(loopExpr->right))) + return TRUE ; + } + + } + else { + /* check for += */ + if ( loopExpr->opval.op == ADD_ASSIGN ) { + + if (IS_AST_SYM_VALUE(loopExpr->left) && + isSymbolEqual(*sym,AST_SYMBOL(loopExpr->left)) && + IS_AST_LIT_VALUE(loopExpr->right) && + (int)AST_LIT_VALUE(loopExpr->right) != 1) + return TRUE ; + } + } + + return FALSE; +} + +/*-----------------------------------------------------------------*/ +/* astHasVolatile - returns true if ast contains any volatile */ +/*-----------------------------------------------------------------*/ +bool astHasVolatile (ast *tree) +{ + if (!tree) + return FALSE ; + + if (TETYPE(tree) && IS_VOLATILE(TETYPE(tree))) + return TRUE; + + if (IS_AST_OP(tree)) + return astHasVolatile(tree->left) || + astHasVolatile(tree->right); + else + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* astHasPointer - return true if the ast contains any ptr variable*/ +/*-----------------------------------------------------------------*/ +bool astHasPointer (ast *tree) +{ + if (!tree) + return FALSE ; + + if (IS_AST_LINK(tree)) + return TRUE; + + /* if we hit an array expression then check + only the left side */ + if (IS_AST_OP(tree) && tree->opval.op == '[') + return astHasPointer(tree->left); + + if (IS_AST_VALUE(tree)) + return IS_PTR(tree->ftype) || IS_ARRAY(tree->ftype); + + return astHasPointer(tree->left) || + astHasPointer(tree->right); + +} + +/*-----------------------------------------------------------------*/ +/* astHasSymbol - return true if the ast has the given symbol */ +/*-----------------------------------------------------------------*/ +bool astHasSymbol (ast *tree, symbol *sym) +{ + if (!tree || IS_AST_LINK(tree)) + return FALSE ; + + if (IS_AST_VALUE(tree)) { + if (IS_AST_SYM_VALUE(tree)) + return isSymbolEqual(AST_SYMBOL(tree),sym); + else + return FALSE; + } + + return astHasSymbol(tree->left,sym) || + astHasSymbol(tree->right,sym); +} + +/*-----------------------------------------------------------------*/ +/* isConformingBody - the loop body has to conform to a set of rules */ +/* for the loop to be considered reversible read on for rules */ +/*-----------------------------------------------------------------*/ +bool isConformingBody (ast *pbody, symbol *sym, ast *body) +{ + + /* we are going to do a pre-order traversal of the + tree && check for the following conditions. (essentially + a set of very shallow tests ) + a) the sym passed does not participate in + any arithmetic operation + b) There are no function calls + c) all jumps are within the body + d) address of loop control variable not taken + e) if an assignment has a pointer on the + left hand side make sure right does not have + loop control variable */ + + /* if we reach the end or a leaf then true */ + if (!pbody || IS_AST_LINK(pbody) || IS_AST_VALUE(pbody)) + return TRUE ; + + + /* if anything else is "volatile" */ + if (IS_VOLATILE(TETYPE(pbody))) + return FALSE; + + /* we will walk the body in a pre-order traversal for + efficiency sake */ + switch (pbody->opval.op) { + /*------------------------------------------------------------------*/ + case '[' : + return isConformingBody (pbody->right,sym,body); + + /*------------------------------------------------------------------*/ + case PTR_OP: + case '.' : + return TRUE; + + /*------------------------------------------------------------------*/ + case INC_OP: /* incerement operator unary so left only */ + case DEC_OP: + + /* sure we are not sym is not modified */ + if (pbody->left && + IS_AST_SYM_VALUE(pbody->left) && + isSymbolEqual(AST_SYMBOL(pbody->left),sym)) + return FALSE; + + if (pbody->right && + IS_AST_SYM_VALUE(pbody->right) && + isSymbolEqual(AST_SYMBOL(pbody->right),sym)) + return FALSE; + + return TRUE; + + /*------------------------------------------------------------------*/ + + case '*' : /* can be unary : if right is null then unary operation */ + case '+' : + case '-' : + case '&': + + /* if right is NULL then unary operation */ + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* address of */ + /*----------------------------*/ + if ( ! pbody->right ) { + if (IS_AST_SYM_VALUE(pbody->left) && + isSymbolEqual(AST_SYMBOL(pbody->left),sym)) + return FALSE; + else + return isConformingBody(pbody->left,sym,body) ; + } + + /*------------------------------------------------------------------*/ + case '|': + case '^': + case '/': + case '%': + case LEFT_OP: + case RIGHT_OP: + + if (IS_AST_SYM_VALUE(pbody->left) && + isSymbolEqual(AST_SYMBOL(pbody->left),sym)) + return FALSE ; + + if (IS_AST_SYM_VALUE(pbody->right) && + isSymbolEqual(AST_SYMBOL(pbody->right),sym)) + return FALSE ; + + return isConformingBody(pbody->left,sym,body) && + isConformingBody(pbody->right,sym,body); + + case '~' : + case '!' : + case RRC: + case RLC: + case GETHBIT: + if (IS_AST_SYM_VALUE(pbody->left) && + isSymbolEqual(AST_SYMBOL(pbody->left),sym)) + return FALSE; + return isConformingBody (pbody->left,sym,body); + + /*------------------------------------------------------------------*/ + + case AND_OP: + case OR_OP: + case '>' : + case '<' : + case LE_OP: + case GE_OP: + case EQ_OP: + case NE_OP: + case '?' : + case ':' : + case SIZEOF: /* evaluate wihout code generation */ + + return isConformingBody(pbody->left,sym,body) && + isConformingBody(pbody->right,sym,body); + + /*------------------------------------------------------------------*/ + case '=' : + + /* if left has a pointer & right has loop + control variable then we cannot */ + if (astHasPointer(pbody->left) && + astHasSymbol (pbody->right,sym)) + return FALSE ; + if (astHasVolatile(pbody->left)) + return FALSE ; + + if (IS_AST_SYM_VALUE(pbody->left) && + isSymbolEqual(AST_SYMBOL(pbody->left),sym)) + return FALSE ; + + if (astHasVolatile(pbody->left)) + return FALSE; + + return isConformingBody(pbody->left,sym,body) && + isConformingBody(pbody->right,sym,body); + + case MUL_ASSIGN: + case DIV_ASSIGN: + case AND_ASSIGN: + case OR_ASSIGN: + case XOR_ASSIGN: + case RIGHT_ASSIGN: + case LEFT_ASSIGN: + case SUB_ASSIGN: + case ADD_ASSIGN: + assert("Parser should not have generated this\n"); + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* comma operator */ + /*----------------------------*/ + case ',' : + return isConformingBody(pbody->left,sym,body) && + isConformingBody(pbody->right,sym,body); + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* function call */ + /*----------------------------*/ + case CALL: + return FALSE; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* return statement */ + /*----------------------------*/ + case RETURN: + return FALSE ; + + case GOTO: + if (isLabelInAst (AST_SYMBOL(pbody->left),body)) + return TRUE ; + else + return FALSE; + case SWITCH: + if (astHasSymbol(pbody->left,sym)) + return FALSE ; + + default: + break; + } + + return isConformingBody(pbody->left,sym,body) && + isConformingBody(pbody->right,sym,body); + + + +} + +/*-----------------------------------------------------------------*/ +/* isLoopReversible - takes a for loop as input && returns true */ +/* if the for loop is reversible. If yes will set the value of */ +/* the loop control var & init value & termination value */ +/*-----------------------------------------------------------------*/ +bool isLoopReversible (ast *loop, symbol **loopCntrl, + ast **init, ast **end ) +{ + /* if option says don't do it then don't */ + if (optimize.noLoopReverse) + return 0; + /* there are several tests to determine this */ + + /* for loop has to be of the form + for ( = ; + [ < ] ; + [++] | [ += 1] | [ = + 1] ) + forBody */ + if (! isLoopCountable (AST_FOR(loop,initExpr), + AST_FOR(loop,condExpr), + AST_FOR(loop,loopExpr), + loopCntrl,init,end)) + return 0; + + /* now do some serious checking on the body of the loop + */ + + return isConformingBody(loop->left,*loopCntrl,loop->left); + +} + +/*-----------------------------------------------------------------*/ +/* replLoopSym - replace the loop sym by loop sym -1 */ +/*-----------------------------------------------------------------*/ +static void replLoopSym ( ast *body, symbol *sym) +{ + /* reached end */ + if (!body || IS_AST_LINK(body)) + return ; + + if (IS_AST_SYM_VALUE(body)) { + + if (isSymbolEqual(AST_SYMBOL(body),sym)) { + + body->type = EX_OP; + body->opval.op = '-'; + body->left = newAst(EX_VALUE,symbolVal(sym)); + body->right= newAst(EX_VALUE,constVal("1")); + + } + + return; + + } + + replLoopSym(body->left,sym); + replLoopSym(body->right,sym); + +} + +/*-----------------------------------------------------------------*/ +/* reverseLoop - do the actual loop reversal */ +/*-----------------------------------------------------------------*/ +ast *reverseLoop (ast *loop, symbol *sym, ast *init, ast *end) +{ + ast *rloop ; + + /* create the following tree + = loopCount ; + for_continue: + forbody + -= 1; + if (sym) goto for_continue ; + = end - 1; */ + + /* put it together piece by piece */ + rloop = newNode (NULLOP, + createIf(newAst(EX_VALUE,symbolVal(sym)), + newNode(GOTO, + newAst(EX_VALUE, + symbolVal(AST_FOR(loop,continueLabel))), + NULL),NULL), + newNode('=', + newAst(EX_VALUE,symbolVal(sym)), + newNode('-', end, + newAst(EX_VALUE, + constVal("1"))))); + + replLoopSym(loop->left, sym); + + rloop = newNode(NULLOP, + newNode('=', + newAst(EX_VALUE,symbolVal(sym)), + newNode('-',end,init)), + createLabel(AST_FOR(loop,continueLabel), + newNode(NULLOP, + loop->left, + newNode(NULLOP, + newNode(SUB_ASSIGN, + newAst(EX_VALUE,symbolVal(sym)), + newAst(EX_VALUE,constVal("1"))), + rloop )))); + + return decorateType(rloop); + +} + +/*-----------------------------------------------------------------*/ +/* decorateType - compute type for this tree also does type cheking*/ +/* this is done bottom up, since type have to flow upwards*/ +/* it also does constant folding, and paramater checking */ +/*-----------------------------------------------------------------*/ +ast *decorateType (ast *tree) +{ + int parmNumber ; + link *p; + + if ( ! tree ) + return tree ; + + /* if already has type then do nothing */ + if ( tree->decorated ) + return tree ; + + tree->decorated = 1; + + /* print the line */ + /* if not block & function */ + if ( tree->type == EX_OP && + ( tree->opval.op != FUNCTION && + tree->opval.op != BLOCK && + tree->opval.op != NULLOP )) { + filename = tree->filename ; + lineno = tree->lineno ; + } + + /* if any child is an error | this one is an error do nothing */ + if ( tree->isError || + ( tree->left && tree->left->isError) || + ( tree->right && tree->right->isError )) + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* leaf has been reached */ + /*----------------------------*/ + /* if this is of type value */ + /* just get the type */ + if ( tree->type == EX_VALUE ) { + + if ( IS_LITERAL(tree->opval.val->etype) ) { + + /* if this is a character array then declare it */ + if (IS_ARRAY(tree->opval.val->type)) + tree->opval.val = stringToSymbol(tree->opval.val); + + /* otherwise just copy the type information */ + COPYTYPE(TTYPE(tree),TETYPE(tree),tree->opval.val->type); + return tree ; + } + + if ( tree->opval.val->sym ) { + /* if the undefined flag is set then give error message */ + if (tree->opval.val->sym->undefined ) { + werror(E_ID_UNDEF,tree->opval.val->sym->name) ; + /* assume int */ + TTYPE(tree) = TETYPE(tree) = + tree->opval.val->type = tree->opval.val->sym->type = + tree->opval.val->etype = tree->opval.val->sym->etype = + copyLinkChain(intType); + } + else { + + /* if impilicit i.e. struct/union member then no type */ + if (tree->opval.val->sym->implicit ) + TTYPE(tree) = TETYPE(tree) = NULL ; + + else { + + /* else copy the type */ + COPYTYPE(TTYPE(tree),TETYPE(tree),tree->opval.val->type); + + /* and mark it as referenced */ + tree->opval.val->sym->isref = 1; + /* if this is of type function or function pointer */ + if (funcInChain(tree->opval.val->type)) { + tree->hasVargs = tree->opval.val->sym->hasVargs; + tree->args = copyValueChain(tree->opval.val->sym->args) ; + + } + } + } + } + + return tree ; + } + + /* if type link for the case of cast */ + if ( tree->type == EX_LINK ) { + COPYTYPE(TTYPE(tree),TETYPE(tree),tree->opval.lnk); + return tree ; + } + + { + ast *dtl, *dtr; + + dtl = decorateType (tree->left); + dtr = decorateType (tree->right); + + /* this is to take care of situations + when the tree gets rewritten */ + if (dtl != tree->left) + tree->left = dtl; + if (dtr != tree->right) + tree->right = dtr; + } + + /* depending on type of operator do */ + + switch (tree->opval.op) { + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* array node */ + /*----------------------------*/ + case '[' : + + /* determine which is the array & which the index */ + if ((IS_ARRAY(RTYPE(tree)) || IS_PTR(RTYPE(tree))) && IS_INTEGRAL(LTYPE(tree))) { + + ast *tempTree = tree->left ; + tree->left = tree->right ; + tree->right= tempTree ; + } + + /* first check if this is a array or a pointer */ + if ( (!IS_ARRAY(LTYPE(tree))) && (!IS_PTR(LTYPE(tree)))) { + werror(E_NEED_ARRAY_PTR,"[]"); + goto errorTreeReturn ; + } + + /* check if the type of the idx */ + if (!IS_INTEGRAL(RTYPE(tree))) { + werror(E_IDX_NOT_INT); + goto errorTreeReturn ; + } + + /* if the left is an rvalue then error */ + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"array access"); + goto errorTreeReturn ; + } + RRVAL(tree) = 1; + COPYTYPE(TTYPE(tree),TETYPE(tree),LTYPE(tree)->next); + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* struct/union */ + /*----------------------------*/ + case '.' : + /* if this is not a structure */ + if (!IS_STRUCT(LTYPE(tree))) { + werror(E_STRUCT_UNION,"."); + goto errorTreeReturn ; + } + TTYPE(tree) = structElemType (LTYPE(tree), + (tree->right->type == EX_VALUE ? + tree->right->opval.val : NULL ),&tree->args); + TETYPE(tree) = getSpec(TTYPE(tree)); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* struct/union pointer */ + /*----------------------------*/ + case PTR_OP: + /* if not pointer to a structure */ + if (!IS_PTR(LTYPE(tree))) { + werror(E_PTR_REQD); + goto errorTreeReturn ; + } + + if (!IS_STRUCT(LTYPE(tree)->next)) { + werror(E_STRUCT_UNION,"->"); + goto errorTreeReturn ; + } + + TTYPE(tree) = structElemType (LTYPE(tree)->next, + (tree->right->type == EX_VALUE ? + tree->right->opval.val : NULL ),&tree->args); + TETYPE(tree) = getSpec(TTYPE(tree)); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* ++/-- operation */ + /*----------------------------*/ + case INC_OP: /* incerement operator unary so left only */ + case DEC_OP: + { + link *ltc = (tree->right ? RTYPE(tree) : LTYPE(tree) ); + COPYTYPE(TTYPE(tree),TETYPE(tree),ltc); + if (!tree->initMode && IS_CONSTANT(TETYPE(tree))) + werror(E_CODE_WRITE,"++/--"); + + if (tree->right) + RLVAL(tree) = 1; + else + LLVAL(tree) = 1; + return tree ; + } + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* bitwise and */ + /*----------------------------*/ + case '&': /* can be unary */ + /* if right is NULL then unary operation */ + if ( tree->right ) /* not an unary operation */ { + + if (!IS_INTEGRAL(LTYPE(tree)) || !IS_INTEGRAL(RTYPE(tree))) { + werror(E_BITWISE_OP); + werror(E_CONTINUE,"left & right types are "); + printTypeChain(LTYPE(tree),stderr); + fprintf(stderr,","); + printTypeChain(RTYPE(tree),stderr); + fprintf(stderr,"\n"); + goto errorTreeReturn ; + } + + /* if they are both literal */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valBitwise (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree)),'&'); + + tree->right = tree->left = NULL; + TETYPE(tree) = tree->opval.val->etype ; + TTYPE(tree) = tree->opval.val->type; + return tree ; + } + + /* see if this is a GETHBIT operation if yes + then return that */ + { + ast *otree = optimizeGetHbit(tree); + + if (otree != tree) + return decorateType(otree); + } + + /* if right or left is literal then result of that type*/ + if (IS_LITERAL(RTYPE(tree))) { + + TTYPE(tree) = copyLinkChain(RTYPE(tree)); + TETYPE(tree) = getSpec(TTYPE(tree)); + SPEC_SCLS(TETYPE(tree)) = S_AUTO; + } + else { + if (IS_LITERAL(LTYPE(tree))) { + TTYPE(tree) = copyLinkChain(LTYPE(tree)); + TETYPE(tree) = getSpec(TTYPE(tree)); + SPEC_SCLS(TETYPE(tree)) = S_AUTO; + + } + else { + TTYPE(tree) = + computeType (LTYPE(tree), RTYPE(tree)); + TETYPE(tree) = getSpec(TTYPE(tree)); + } + } + LRVAL(tree) = RRVAL(tree) = 1; + return tree ; + } + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* address of */ + /*----------------------------*/ + p = newLink(); + p->class = DECLARATOR; + /* if bit field then error */ + if (IS_BITVAR(tree->left->etype)) { + werror (E_ILLEGAL_ADDR,"addrress of bit variable"); + goto errorTreeReturn ; + } + + if (SPEC_SCLS(tree->left->etype)== S_REGISTER ) { + werror (E_ILLEGAL_ADDR,"address of register variable"); + goto errorTreeReturn; + } + + if (IS_FUNC(LTYPE(tree))) { + werror(E_ILLEGAL_ADDR,"address of function"); + goto errorTreeReturn ; + } + + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"address of"); + goto errorTreeReturn ; + } + if (SPEC_SCLS(tree->left->etype) == S_CODE) { + DCL_TYPE(p) = CPOINTER ; + DCL_PTR_CONST(p) = 1; + } + else + if (SPEC_SCLS(tree->left->etype) == S_XDATA) + DCL_TYPE(p) = FPOINTER; + else + if (SPEC_SCLS(tree->left->etype) == S_XSTACK ) + DCL_TYPE(p) = PPOINTER ; + else + if (SPEC_SCLS(tree->left->etype) == S_IDATA) + DCL_TYPE(p) = IPOINTER ; + else + DCL_TYPE(p) = POINTER ; + + if (IS_AST_SYM_VALUE(tree->left)) { + AST_SYMBOL(tree->left)->addrtaken = 1; + AST_SYMBOL(tree->left)->allocreq = 1; + } + + p->next = LTYPE(tree); + TTYPE(tree) = p; + TETYPE(tree) = getSpec(TTYPE(tree)); + DCL_PTR_CONST(p) = SPEC_CONST(TETYPE(tree)); + DCL_PTR_VOLATILE(p) = SPEC_VOLATILE(TETYPE(tree)); + LLVAL(tree) = 1; + TLVAL(tree) = 1; + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* bitwise or */ + /*----------------------------*/ + case '|': + /* if the rewrite succeeds then don't go any furthur */ + { + ast *wtree = optimizeRRCRLC ( tree ); + if (wtree != tree) + return decorateType(wtree) ; + } + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* bitwise xor */ + /*----------------------------*/ + case '^': + if (!IS_INTEGRAL(LTYPE(tree)) || !IS_INTEGRAL(RTYPE(tree))) { + werror(E_BITWISE_OP); + werror(E_CONTINUE,"left & right types are "); + printTypeChain(LTYPE(tree),stderr); + fprintf(stderr,","); + printTypeChain(RTYPE(tree),stderr); + fprintf(stderr,"\n"); + goto errorTreeReturn ; + } + + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valBitwise (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree)), + tree->opval.op); + tree->right = tree->left = NULL; + TETYPE(tree) = tree->opval.val->etype; + TTYPE(tree) = tree->opval.val->type; + return tree ; + } + LRVAL(tree) = RRVAL(tree) = 1; + TETYPE(tree) = getSpec (TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* division */ + /*----------------------------*/ + case '/': + if (!IS_ARITHMETIC(LTYPE(tree)) || !IS_ARITHMETIC(RTYPE(tree))) { + werror(E_INVALID_OP,"divide"); + goto errorTreeReturn ; + } + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valDiv (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree))); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + LRVAL(tree) = RRVAL(tree) = 1; + TETYPE(tree) = getSpec (TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* modulus */ + /*----------------------------*/ + case '%': + if (!IS_INTEGRAL(LTYPE(tree)) || !IS_INTEGRAL(RTYPE(tree))) { + werror(E_BITWISE_OP); + werror(E_CONTINUE,"left & right types are "); + printTypeChain(LTYPE(tree),stderr); + fprintf(stderr,","); + printTypeChain(RTYPE(tree),stderr); + fprintf(stderr,"\n"); + goto errorTreeReturn ; + } + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valMod (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree))); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + LRVAL(tree) = RRVAL(tree) = 1; + TETYPE(tree) = getSpec (TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* address dereference */ + /*----------------------------*/ + case '*': /* can be unary : if right is null then unary operation */ + if ( ! tree->right ) { + if (!IS_PTR(LTYPE(tree)) && !IS_ARRAY(LTYPE(tree))) { + werror(E_PTR_REQD); + goto errorTreeReturn ; + } + + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"pointer deref"); + goto errorTreeReturn ; + } + TTYPE(tree) = copyLinkChain ((IS_PTR(LTYPE(tree)) || IS_ARRAY(LTYPE(tree))) ? + LTYPE(tree)->next : NULL ); + TETYPE(tree) = getSpec(TTYPE(tree)); + tree->args = tree->left->args ; + tree->hasVargs = tree->left->hasVargs ; + SPEC_CONST(TETYPE(tree)) = DCL_PTR_CONST(LTYPE(tree)); + return tree ; + } + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* multiplication */ + /*----------------------------*/ + if (!IS_ARITHMETIC(LTYPE(tree)) || !IS_ARITHMETIC(RTYPE(tree))) { + werror(E_INVALID_OP,"multiplication"); + goto errorTreeReturn ; + } + + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valMult (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree))); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + + /* if left is a literal exchange left & right */ + if (IS_LITERAL(LTYPE(tree))) { + ast *tTree = tree->left ; + tree->left = tree->right ; + tree->right= tTree ; + } + + LRVAL(tree) = RRVAL(tree) = 1; + TETYPE(tree) = getSpec (TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* unary '+' operator */ + /*----------------------------*/ + case '+' : + /* if unary plus */ + if ( ! tree->right ) { + if (!IS_INTEGRAL(LTYPE(tree))) { + werror(E_UNARY_OP,'+'); + goto errorTreeReturn ; + } + + /* if left is a literal then do it */ + if (IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valFromType(LETYPE(tree)); + tree->left = NULL ; + TETYPE(tree) = TTYPE(tree) = tree->opval.val->type; + return tree ; + } + LRVAL(tree) = 1; + COPYTYPE(TTYPE(tree),TETYPE(tree),LTYPE(tree)); + return tree ; + } + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* addition */ + /*----------------------------*/ + + /* this is not a unary operation */ + /* if both pointers then problem */ + if ((IS_PTR(LTYPE(tree)) || IS_ARRAY(LTYPE(tree))) && + (IS_PTR(RTYPE(tree)) || IS_ARRAY(RTYPE(tree)))) { + werror(E_PTR_PLUS_PTR); + goto errorTreeReturn ; + } + + if (!IS_ARITHMETIC(LTYPE(tree)) && + !IS_PTR(LTYPE(tree)) && !IS_ARRAY(LTYPE(tree))) { + werror(E_PLUS_INVALID,"+"); + goto errorTreeReturn ; + } + + if (!IS_ARITHMETIC(RTYPE(tree)) && + !IS_PTR(RTYPE(tree)) && !IS_ARRAY(RTYPE(tree))) { + werror(E_PLUS_INVALID,"+"); + goto errorTreeReturn; + } + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valPlus (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree))); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + + /* if the right is a pointer or left is a literal + xchange left & right */ + if (IS_ARRAY(RTYPE(tree)) || + IS_PTR(RTYPE(tree)) || + IS_LITERAL(LTYPE(tree))) { + ast *tTree = tree->left ; + tree->left = tree->right ; + tree->right= tTree ; + } + + LRVAL(tree) = RRVAL(tree) = 1; + /* if the left is a pointer */ + if (IS_PTR(LTYPE(tree))) + TETYPE(tree) = getSpec(TTYPE(tree) = + LTYPE(tree)); + else + TETYPE(tree) = getSpec(TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* unary '-' */ + /*----------------------------*/ + case '-' : /* can be unary */ + /* if right is null then unary */ + if ( ! tree->right ) { + + if (!IS_ARITHMETIC(LTYPE(tree))) { + werror(E_UNARY_OP,tree->opval.op); + goto errorTreeReturn ; + } + + /* if left is a literal then do it */ + if (IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valUnaryPM(valFromType(LETYPE(tree))); + tree->left = NULL ; + TETYPE(tree) = TTYPE(tree) = tree->opval.val->type; + return tree ; + } + LRVAL(tree) = 1; + TTYPE(tree) = LTYPE(tree); + return tree ; + } + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* subtraction */ + /*----------------------------*/ + + if (!(IS_PTR(LTYPE(tree)) || + IS_ARRAY(LTYPE(tree)) || + IS_ARITHMETIC(LTYPE(tree)))) { + werror(E_PLUS_INVALID,"-"); + goto errorTreeReturn ; + } + + if (!(IS_PTR(RTYPE(tree)) || + IS_ARRAY(RTYPE(tree)) || + IS_ARITHMETIC(RTYPE(tree)))) { + werror(E_PLUS_INVALID,"-"); + goto errorTreeReturn ; + } + + if ( (IS_PTR(LTYPE(tree)) || IS_ARRAY(LTYPE(tree))) && + ! (IS_PTR(RTYPE(tree)) || IS_ARRAY(RTYPE(tree)) || + IS_INTEGRAL(RTYPE(tree))) ) { + werror(E_PLUS_INVALID,"-"); + goto errorTreeReturn ; + } + + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valMinus (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree))); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + + /* if the left & right are equal then zero */ + if (isAstEqual(tree->left,tree->right)) { + tree->type = EX_VALUE; + tree->left = tree->right = NULL; + tree->opval.val = constVal("0"); + TETYPE(tree) = TTYPE(tree) = tree->opval.val->type; + return tree; + } + + /* if both of them are pointers or arrays then */ + /* the result is going to be an integer */ + if (( IS_ARRAY(LTYPE(tree)) || IS_PTR(LTYPE(tree))) && + ( IS_ARRAY(RTYPE(tree)) || IS_PTR(RTYPE(tree)))) + TETYPE(tree) = TTYPE(tree) = newIntLink(); + else + /* if only the left is a pointer */ + /* then result is a pointer */ + if (IS_PTR(LTYPE(tree)) || IS_ARRAY(LTYPE(tree))) + TETYPE(tree) = getSpec(TTYPE(tree) = + LTYPE(tree)); + else + TETYPE(tree) = getSpec (TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + LRVAL(tree) = RRVAL(tree) = 1; + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* compliment */ + /*----------------------------*/ + case '~' : + /* can be only integral type */ + if (!IS_INTEGRAL(LTYPE(tree))) { + werror(E_UNARY_OP,tree->opval.op); + goto errorTreeReturn ; + } + + /* if left is a literal then do it */ + if (IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valComplement(valFromType(LETYPE(tree))); + tree->left = NULL ; + TETYPE(tree) = TTYPE(tree) = tree->opval.val->type; + return tree ; + } + LRVAL(tree) = 1; + COPYTYPE(TTYPE(tree),TETYPE(tree),LTYPE(tree)); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* not */ + /*----------------------------*/ + case '!' : + /* can be pointer */ + if (!IS_ARITHMETIC(LTYPE(tree)) && + !IS_PTR(LTYPE(tree)) && + !IS_ARRAY(LTYPE(tree))) { + werror(E_UNARY_OP,tree->opval.op); + goto errorTreeReturn ; + } + + /* if left is a literal then do it */ + if (IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valNot(valFromType(LETYPE(tree))); + tree->left = NULL ; + TETYPE(tree) = TTYPE(tree) = tree->opval.val->type; + return tree ; + } + LRVAL(tree) = 1; + TTYPE(tree) = TETYPE(tree) = newCharLink(); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* shift */ + /*----------------------------*/ + case RRC: + case RLC: + TTYPE(tree) = LTYPE(tree); + TETYPE(tree) = LETYPE(tree); + return tree ; + + case GETHBIT: + TTYPE(tree) = TETYPE(tree) = newCharLink(); + return tree; + + case LEFT_OP: + case RIGHT_OP: + if (!IS_INTEGRAL(LTYPE(tree)) || !IS_INTEGRAL(tree->left->etype)) { + werror(E_SHIFT_OP_INVALID); + werror(E_CONTINUE,"left & right types are "); + printTypeChain(LTYPE(tree),stderr); + fprintf(stderr,","); + printTypeChain(RTYPE(tree),stderr); + fprintf(stderr,"\n"); + goto errorTreeReturn ; + } + + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valShift (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree)), + (tree->opval.op == LEFT_OP ? 1 : 0)); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + /* if only the right side is a literal & we are + shifting more than size of the left operand then zero */ + if (IS_LITERAL(RTYPE(tree)) && + ((int)floatFromVal( valFromType(RETYPE(tree)))) >= + (getSize(LTYPE(tree))*8)) { + werror(W_SHIFT_CHANGED, + (tree->opval.op == LEFT_OP ? "left" : "right")); + tree->type = EX_VALUE; + tree->left = tree->right = NULL; + tree->opval.val = constVal("0"); + TETYPE(tree) = TTYPE(tree) = tree->opval.val->type; + return tree; + } + LRVAL(tree) = RRVAL(tree) = 1; + COPYTYPE(TTYPE(tree),TETYPE(tree),LTYPE(tree)); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* casting */ + /*----------------------------*/ + case CAST : /* change the type */ + /* cannot cast to an aggregate type */ + if (IS_AGGREGATE(LTYPE(tree))) { + werror(E_CAST_ILLEGAL); + goto errorTreeReturn ; + } + + /* if the right is a literal replace the tree */ + if (IS_LITERAL(RETYPE(tree)) && !IS_PTR(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = + valCastLiteral(LTYPE(tree), + floatFromVal(valFromType(RETYPE(tree)))); + tree->left = NULL; + tree->right = NULL; + TTYPE(tree) = tree->opval.val->type; + } + else { + TTYPE(tree) = LTYPE(tree); + LRVAL(tree) = 1; + } + + TETYPE(tree) = getSpec(TTYPE(tree)); + + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* logical &&, || */ + /*----------------------------*/ + case AND_OP: + case OR_OP : + /* each must me arithmetic type or be a pointer */ + if (!IS_PTR(LTYPE(tree)) && + !IS_ARRAY(LTYPE(tree)) && + !IS_INTEGRAL(LTYPE(tree))) { + werror(E_COMPARE_OP); + goto errorTreeReturn ; + } + + if (!IS_PTR(RTYPE(tree)) && + !IS_ARRAY(RTYPE(tree)) && + !IS_INTEGRAL(RTYPE(tree))) { + werror(E_COMPARE_OP); + goto errorTreeReturn ; + } + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && + IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valLogicAndOr (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree)), + tree->opval.op); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + LRVAL(tree) = RRVAL(tree) = 1; + TTYPE(tree) = TETYPE(tree) = newCharLink(); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* comparison operators */ + /*----------------------------*/ + case '>' : + case '<' : + case LE_OP : + case GE_OP : + case EQ_OP : + case NE_OP : + { + ast *lt = optimizeCompare(tree); + + if ( tree != lt ) + return lt; + } + + /* if they are pointers they must be castable */ + if ( IS_PTR(LTYPE(tree)) && IS_PTR(RTYPE(tree))) { + if (checkType(LTYPE(tree),RTYPE(tree)) == 0) { + werror(E_COMPARE_OP); + fprintf(stderr,"comparing type "); + printTypeChain(LTYPE(tree),stderr); + fprintf(stderr,"to type "); + printTypeChain(RTYPE(tree),stderr); + fprintf(stderr,"\n"); + goto errorTreeReturn ; + } + } + /* else they should be promotable to one another */ + else { + if (!( ( IS_PTR(LTYPE(tree)) && IS_LITERAL(RTYPE(tree))) || + ( IS_PTR(RTYPE(tree)) && IS_LITERAL(LTYPE(tree))))) + + if (checkType (LTYPE(tree),RTYPE(tree)) == 0 ) { + werror(E_COMPARE_OP); + fprintf(stderr,"comparing type "); + printTypeChain(LTYPE(tree),stderr); + fprintf(stderr,"to type "); + printTypeChain(RTYPE(tree),stderr); + fprintf(stderr,"\n"); + goto errorTreeReturn ; + } + } + + /* if they are both literal then */ + /* rewrite the tree */ + if (IS_LITERAL(RTYPE(tree)) && + IS_LITERAL(LTYPE(tree))) { + tree->type = EX_VALUE ; + tree->opval.val = valCompare (valFromType(LETYPE(tree)), + valFromType(RETYPE(tree)), + tree->opval.op); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree ; + } + LRVAL(tree) = RRVAL(tree) = 1; + TTYPE(tree) = TETYPE(tree) = newCharLink(); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* sizeof */ + /*----------------------------*/ + case SIZEOF : /* evaluate wihout code generation */ + /* change the type to a integer */ + tree->type = EX_VALUE; + sprintf(buffer,"%d",(getSize(tree->right->ftype))); + tree->opval.val = constVal(buffer); + tree->right = tree->left = NULL; + TETYPE(tree) = getSpec(TTYPE(tree) = + tree->opval.val->type); + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* conditional operator '?' */ + /*----------------------------*/ + case '?' : + /* the type is one on the left */ + TTYPE(tree) = LTYPE(tree); + TETYPE(tree)= getSpec (TTYPE(tree)); + return tree ; + + case ':' : + /* if they don't match we have a problem */ + if (checkType( LTYPE(tree), RTYPE(tree)) == 0) { + werror(E_TYPE_MISMATCH,"conditional operator"," "); + goto errorTreeReturn ; + } + + TTYPE(tree) = computeType(LTYPE(tree),RTYPE(tree)); + TETYPE(tree)= getSpec(TTYPE(tree)); + return tree ; + + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* assignment operators */ + /*----------------------------*/ + case MUL_ASSIGN: + case DIV_ASSIGN: + /* for these it must be both must be integral */ + if (!IS_ARITHMETIC(LTYPE(tree)) || + !IS_ARITHMETIC(RTYPE(tree))) { + werror (E_OPS_INTEGRAL); + goto errorTreeReturn ; + } + RRVAL(tree) = 1; + TETYPE(tree) = getSpec(TTYPE(tree) = LTYPE(tree)); + + if (!tree->initMode && IS_CONSTANT(LETYPE(tree))) + werror(E_CODE_WRITE," "); + + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"*= or /="); + goto errorTreeReturn ; + } + LLVAL(tree) = 1; + return tree ; + + case AND_ASSIGN: + case OR_ASSIGN: + case XOR_ASSIGN: + case RIGHT_ASSIGN: + case LEFT_ASSIGN: + /* for these it must be both must be integral */ + if (!IS_INTEGRAL(LTYPE(tree)) || + !IS_INTEGRAL(RTYPE(tree))) { + werror (E_OPS_INTEGRAL); + goto errorTreeReturn ; + } + RRVAL(tree) = 1; + TETYPE(tree) = getSpec(TTYPE(tree) = LTYPE(tree)); + + if (!tree->initMode && IS_CONSTANT(LETYPE(tree))) + werror(E_CODE_WRITE," "); + + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"&= or |= or ^= or >>= or <<="); + goto errorTreeReturn ; + } + LLVAL(tree) = 1; + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* -= operator */ + /*----------------------------*/ + case SUB_ASSIGN: + if (!(IS_PTR(LTYPE(tree)) || + IS_ARITHMETIC(LTYPE(tree)))) { + werror(E_PLUS_INVALID,"-="); + goto errorTreeReturn ; + } + + if (!(IS_PTR(RTYPE(tree)) || + IS_ARITHMETIC(RTYPE(tree)))) { + werror(E_PLUS_INVALID,"-="); + goto errorTreeReturn ; + } + RRVAL(tree) = 1; + TETYPE(tree) = getSpec (TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + + if (!tree->initMode && IS_CONSTANT(LETYPE(tree))) + werror(E_CODE_WRITE," "); + + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"-="); + goto errorTreeReturn ; + } + LLVAL(tree) = 1; + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* += operator */ + /*----------------------------*/ + case ADD_ASSIGN: + /* this is not a unary operation */ + /* if both pointers then problem */ + if (IS_PTR(LTYPE(tree)) && IS_PTR(RTYPE(tree)) ) { + werror(E_PTR_PLUS_PTR); + goto errorTreeReturn ; + } + + if (!IS_ARITHMETIC(LTYPE(tree)) && !IS_PTR(LTYPE(tree))) { + werror(E_PLUS_INVALID,"+="); + goto errorTreeReturn ; + } + + if (!IS_ARITHMETIC(RTYPE(tree)) && !IS_PTR(RTYPE(tree))) { + werror(E_PLUS_INVALID,"+="); + goto errorTreeReturn; + } + RRVAL(tree) = 1; + TETYPE(tree) = getSpec (TTYPE(tree) = + computeType(LTYPE(tree), + RTYPE(tree))); + + if (!tree->initMode && IS_CONSTANT(LETYPE(tree))) + werror(E_CODE_WRITE," "); + + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"+="); + goto errorTreeReturn ; + } + + tree->right = decorateType(newNode('+',copyAst(tree->left),tree->right)); + tree->opval.op = '='; + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* straight assignemnt */ + /*----------------------------*/ + case '=' : + /* cannot be an aggregate */ + if (IS_AGGREGATE(LTYPE(tree))) { + werror(E_AGGR_ASSIGN); + goto errorTreeReturn; + } + + /* they should either match or be castable */ + if (checkType (LTYPE(tree),RTYPE(tree)) == 0) { + werror(E_TYPE_MISMATCH,"assignment"," "); + fprintf(stderr,"type --> '"); + printTypeChain (RTYPE(tree),stderr); fprintf(stderr,"' "); + fprintf(stderr,"assigned to type --> '"); + printTypeChain (LTYPE(tree),stderr); fprintf(stderr,"'\n"); + goto errorTreeReturn ; + } + + /* if the left side of the tree is of type void + then report error */ + if (IS_VOID(LTYPE(tree))) { + werror(E_CAST_ZERO); + fprintf(stderr,"type --> '"); + printTypeChain (RTYPE(tree),stderr); fprintf(stderr,"' "); + fprintf(stderr,"assigned to type --> '"); + printTypeChain (LTYPE(tree),stderr); fprintf(stderr,"'\n"); + } + + /* extra checks for pointer types */ + if (IS_PTR(LTYPE(tree)) && IS_PTR(RTYPE(tree)) && + !IS_GENPTR(LTYPE(tree))) { + if (DCL_TYPE(LTYPE(tree)) != DCL_TYPE(RTYPE(tree))) + werror(W_PTR_ASSIGN); + } + + TETYPE(tree) = getSpec(TTYPE(tree) = + LTYPE(tree)); + RRVAL(tree) = 1; + LLVAL(tree) = 1; + if (!tree->initMode && IS_CONSTANT(LETYPE(tree))) + werror(E_CODE_WRITE," "); + + if (LRVAL(tree)) { + werror(E_LVALUE_REQUIRED,"="); + goto errorTreeReturn ; + } + + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* comma operator */ + /*----------------------------*/ + case ',' : + TETYPE(tree) = getSpec(TTYPE(tree) = RTYPE(tree)); + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* function call */ + /*----------------------------*/ + case CALL : + parmNumber = 1; + + + if (processParms (tree->left, + tree->left->args, + tree->right,&parmNumber)) + goto errorTreeReturn ; + + if (options.stackAuto || IS_RENT(LETYPE(tree))) { + tree->left->args = reverseVal(tree->left->args); + reverseParms(tree->right); + } + + tree->args = tree->left->args ; + TETYPE(tree) = getSpec (TTYPE(tree) = LTYPE(tree)->next); + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* return statement */ + /*----------------------------*/ + case RETURN : + if (!tree->right) + goto voidcheck ; + + if (checkType(currFunc->type->next,RTYPE(tree)) == 0) { + werror(E_RETURN_MISMATCH); + goto errorTreeReturn ; + } + + if (IS_VOID(currFunc->type->next) + && tree->right && + !IS_VOID(RTYPE(tree))) { + werror(E_FUNC_VOID); + goto errorTreeReturn ; + } + + /* if there is going to be a casing required then add it */ + if (checkType(currFunc->type->next,RTYPE(tree)) < 0 ) { + tree->right = + decorateType(newNode(CAST, + newAst(EX_LINK, + copyLinkChain(currFunc->type->next)), + tree->right)); + } + + RRVAL(tree) = 1; + return tree; + + voidcheck : + + if (!IS_VOID(currFunc->type->next) && tree->right == NULL ) { + werror(E_VOID_FUNC,currFunc->name); + goto errorTreeReturn ; + } + + TTYPE(tree) = TETYPE(tree) = NULL ; + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* switch statement */ + /*----------------------------*/ + case SWITCH: + /* the switch value must be an integer */ + if (!IS_INTEGRAL(LTYPE(tree))) { + werror (E_SWITCH_NON_INTEGER); + goto errorTreeReturn ; + } + LRVAL(tree) = 1; + TTYPE(tree) = TETYPE(tree) = NULL ; + return tree ; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* ifx Statement */ + /*----------------------------*/ + case IFX: + tree->left = backPatchLabels(tree->left, + tree->trueLabel, + tree->falseLabel); + TTYPE(tree) = TETYPE(tree) = NULL; + return tree; + + /*------------------------------------------------------------------*/ + /*----------------------------*/ + /* for Statement */ + /*----------------------------*/ + case FOR: + + decorateType(resolveSymbols(AST_FOR(tree,initExpr))); + decorateType(resolveSymbols(AST_FOR(tree,condExpr))); + decorateType(resolveSymbols(AST_FOR(tree,loopExpr))); + + /* if the for loop is reversible then + reverse it otherwise do what we normally + do */ + { + symbol *sym ; + ast *init, *end; + + if (isLoopReversible (tree,&sym,&init,&end)) + return reverseLoop (tree,sym,init,end); + else + return decorateType(createFor ( AST_FOR(tree,trueLabel), + AST_FOR(tree,continueLabel) , + AST_FOR(tree,falseLabel) , + AST_FOR(tree,condLabel) , + AST_FOR(tree,initExpr) , + AST_FOR(tree,condExpr) , + AST_FOR(tree,loopExpr), + tree->left ) ); + } + default : + TTYPE(tree) = TETYPE(tree) = NULL ; + return tree ; + } + + /* some error found this tree will be killed */ + errorTreeReturn : + TTYPE(tree) = TETYPE(tree) = newCharLink(); + tree->opval.op = NULLOP ; + tree->isError = 1; + + return tree ; +} + +/*-----------------------------------------------------------------*/ +/* sizeofOp - processes size of operation */ +/*-----------------------------------------------------------------*/ +value *sizeofOp( link *type) +{ + char buff[10]; + + /* get the size and convert it to character */ + sprintf (buff,"%d", getSize(type)); + + /* now convert into value */ + return constVal (buff); +} + + +#define IS_AND(ex) (ex->type == EX_OP && ex->opval.op == AND_OP ) +#define IS_OR(ex) (ex->type == EX_OP && ex->opval.op == OR_OP ) +#define IS_NOT(ex) (ex->type == EX_OP && ex->opval.op == '!' ) +#define IS_ANDORNOT(ex) (IS_AND(ex) || IS_OR(ex) || IS_NOT(ex)) +#define IS_IFX(ex) (ex->type == EX_OP && ex->opval.op == IFX ) +#define IS_LT(ex) (ex->type == EX_OP && ex->opval.op == '<' ) +#define IS_GT(ex) (ex->type == EX_OP && ex->opval.op == '>') + +/*-----------------------------------------------------------------*/ +/* backPatchLabels - change and or not operators to flow control */ +/*-----------------------------------------------------------------*/ +ast *backPatchLabels (ast *tree, symbol *trueLabel, symbol *falseLabel ) +{ + + if ( ! tree ) + return NULL ; + + if ( ! (IS_ANDORNOT(tree))) + return tree ; + + /* if this an and */ + if (IS_AND(tree)) { + static int localLbl = 0 ; + symbol *localLabel ; + + sprintf (buffer,"_and_%d",localLbl++); + localLabel = newSymbol(buffer,NestLevel); + + tree->left = backPatchLabels (tree->left, localLabel,falseLabel); + + /* if left is already a IFX then just change the if true label in that */ + if (!IS_IFX(tree->left)) + tree->left = newIfxNode(tree->left,localLabel,falseLabel); + + tree->right = backPatchLabels(tree->right,trueLabel,falseLabel); + /* right is a IFX then just join */ + if (IS_IFX(tree->right)) + return newNode(NULLOP,tree->left,createLabel(localLabel,tree->right)); + + tree->right = createLabel(localLabel,tree->right); + tree->right = newIfxNode(tree->right,trueLabel,falseLabel); + + return newNode(NULLOP,tree->left,tree->right); + } + + /* if this is an or operation */ + if (IS_OR(tree)) { + static int localLbl = 0 ; + symbol *localLabel ; + + sprintf (buffer,"_or_%d",localLbl++); + localLabel = newSymbol(buffer,NestLevel); + + tree->left = backPatchLabels (tree->left, trueLabel,localLabel); + + /* if left is already a IFX then just change the if true label in that */ + if (!IS_IFX(tree->left)) + tree->left = newIfxNode(tree->left,trueLabel,localLabel); + + tree->right = backPatchLabels(tree->right,trueLabel,falseLabel); + /* right is a IFX then just join */ + if (IS_IFX(tree->right)) + return newNode(NULLOP,tree->left,createLabel(localLabel,tree->right)); + + tree->right = createLabel(localLabel,tree->right); + tree->right = newIfxNode(tree->right,trueLabel,falseLabel); + + return newNode(NULLOP,tree->left,tree->right); + } + + /* change not */ + if (IS_NOT(tree)) { + tree->left = backPatchLabels (tree->left,trueLabel,falseLabel); + + /* if the left is already a IFX */ + if ( ! IS_IFX(tree->left) ) + tree->left = newNode (IFX,tree->left,NULL); + + tree->left->trueLabel = falseLabel ; + tree->left->falseLabel= trueLabel ; + return tree->left ; + } + + if (IS_IFX(tree)) { + tree->trueLabel = trueLabel ; + tree->falseLabel= falseLabel; + } + + return tree ; +} + + +/*-----------------------------------------------------------------*/ +/* createBlock - create expression tree for block */ +/*-----------------------------------------------------------------*/ +ast *createBlock ( symbol *decl, ast *body ) +{ + ast *ex ; + + /* if the block has nothing */ + if (!body) + return NULL; + + ex = newNode(BLOCK,NULL,body); + ex->values.sym = decl ; + + ex->right = ex->right ; + ex->level++ ; + ex->lineno = 0 ; + return ex; +} + +/*-----------------------------------------------------------------*/ +/* createLabel - creates the expression tree for labels */ +/*-----------------------------------------------------------------*/ +ast *createLabel ( symbol *label, ast *stmnt ) +{ + symbol *csym; + char name[SDCC_NAME_MAX+1]; + ast *rValue ; + + /* must create fresh symbol if the symbol name */ + /* exists in the symbol table, since there can */ + /* be a variable with the same name as the labl */ + if ((csym = findSym (SymbolTab,NULL,label->name)) && + (csym->level == label->level)) + label = newSymbol(label->name,label->level); + + /* change the name before putting it in add _*/ + sprintf (name,"%s",label->name); + + /* put the label in the LabelSymbol table */ + /* but first check if a label of the same */ + /* name exists */ + if ( (csym = findSym(LabelTab,NULL,name))) + werror(E_DUPLICATE_LABEL,label->name); + else + addSym (LabelTab, label, name,label->level,0); + + label->islbl = 1; + label->key = labelKey++ ; + rValue = newNode (LABEL,newAst(EX_VALUE,symbolVal(label)),stmnt); + rValue->lineno = 0; + + return rValue ; +} + +/*-----------------------------------------------------------------*/ +/* createCase - generates the parsetree for a case statement */ +/*-----------------------------------------------------------------*/ +ast *createCase (ast *swStat, ast *caseVal, ast *stmnt ) +{ + char caseLbl[SDCC_NAME_MAX+1]; + ast *rexpr; + value *val; + + /* if the switch statement does not exist */ + /* then case is out of context */ + if (!swStat) { + werror(E_CASE_CONTEXT); + return NULL ; + } + + caseVal = decorateType(resolveSymbols(caseVal)); + /* if not a constant then error */ + if (!IS_LITERAL(caseVal->ftype)) { + werror(E_CASE_CONSTANT); + return NULL ; + } + + /* if not a integer than error */ + if (!IS_INTEGRAL(caseVal->ftype)) { + werror(E_CASE_NON_INTEGER); + return NULL; + } + + /* find the end of the switch values chain */ + if (!(val = swStat->values.switchVals.swVals)) + swStat->values.switchVals.swVals = caseVal->opval.val ; + else { + /* also order the cases according to value */ + value *pval = NULL; + int cVal = (int) floatFromVal(caseVal->opval.val); + while (val && (int) floatFromVal(val) < cVal) { + pval = val; + val = val->next ; + } + + /* if we reached the end then */ + if (!val) { + pval->next = caseVal->opval.val; + } else { + /* we found a value greater than */ + /* the current value we must add this */ + /* before the value */ + caseVal->opval.val->next = val; + + /* if this was the first in chain */ + if (swStat->values.switchVals.swVals == val) + swStat->values.switchVals.swVals = + caseVal->opval.val; + else + pval->next = caseVal->opval.val; + } + + } + + /* create the case label */ + sprintf(caseLbl,"_case_%d_%d", + swStat->values.switchVals.swNum, + (int) floatFromVal(caseVal->opval.val)); + + rexpr = createLabel(newSymbol(caseLbl,0),stmnt); + rexpr->lineno = 0; + return rexpr; +} + +/*-----------------------------------------------------------------*/ +/* createDefault - creates the parse tree for the default statement*/ +/*-----------------------------------------------------------------*/ +ast *createDefault (ast *swStat, ast *stmnt) +{ + char defLbl[SDCC_NAME_MAX+1]; + + /* if the switch statement does not exist */ + /* then case is out of context */ + if (!swStat) { + werror(E_CASE_CONTEXT); + return NULL ; + } + + /* turn on the default flag */ + swStat->values.switchVals.swDefault = 1 ; + + /* create the label */ + sprintf (defLbl,"_default_%d",swStat->values.switchVals.swNum); + return createLabel(newSymbol(defLbl,0),stmnt); +} + +/*-----------------------------------------------------------------*/ +/* createIf - creates the parsetree for the if statement */ +/*-----------------------------------------------------------------*/ +ast *createIf ( ast *condAst, ast *ifBody, ast *elseBody ) +{ + static int Lblnum = 0 ; + ast *ifTree ; + symbol *ifTrue , *ifFalse, *ifEnd ; + + /* if neither exists */ + if (! elseBody && !ifBody) + return condAst ; + + /* create the labels */ + sprintf (buffer,"_iffalse_%d",Lblnum); + ifFalse = newSymbol (buffer,NestLevel); + /* if no else body then end == false */ + if ( ! elseBody ) + ifEnd = ifFalse ; + else { + sprintf (buffer,"_ifend_%d",Lblnum); + ifEnd = newSymbol (buffer,NestLevel); + } + + sprintf (buffer,"_iftrue_%d",Lblnum); + ifTrue = newSymbol (buffer,NestLevel); + + Lblnum++ ; + + /* attach the ifTrue label to the top of it body */ + ifBody = createLabel(ifTrue,ifBody); + /* attach a goto end to the ifBody if else is present */ + if ( elseBody ) { + ifBody = newNode(NULLOP,ifBody, + newNode(GOTO, + newAst(EX_VALUE,symbolVal(ifEnd)), + NULL)); + /* put the elseLabel on the else body */ + elseBody = createLabel (ifFalse,elseBody); + /* out the end at the end of the body */ + elseBody = newNode(NULLOP, + elseBody, + createLabel(ifEnd,NULL)); + } + else { + ifBody = newNode(NULLOP,ifBody, + createLabel(ifFalse,NULL)); + } + condAst = backPatchLabels (condAst,ifTrue,ifFalse); + if (IS_IFX(condAst)) + ifTree = condAst; + else + ifTree = newIfxNode(condAst,ifTrue,ifFalse); + + return newNode(NULLOP,ifTree, + newNode(NULLOP,ifBody,elseBody)); + +} + +/*-----------------------------------------------------------------*/ +/* createDo - creates parse tree for do */ +/* _dobody_n: */ +/* statements */ +/* _docontinue_n: */ +/* condition_expression +-> trueLabel -> _dobody_n */ +/* | */ +/* +-> falseLabel-> _dobreak_n */ +/* _dobreak_n: */ +/*-----------------------------------------------------------------*/ +ast *createDo ( symbol *trueLabel, symbol *continueLabel, + symbol *falseLabel, ast *condAst, ast *doBody ) +{ + ast *doTree ; + + + /* if the body does not exist then it is simple */ + if ( ! doBody ) { + condAst = backPatchLabels(condAst,continueLabel,NULL); + doTree = (IS_IFX(condAst) ? createLabel(continueLabel,condAst) + : newNode(IFX,createLabel(continueLabel,condAst),NULL)); + doTree->trueLabel = continueLabel ; + doTree->falseLabel= NULL ; + return doTree ; + } + + /* otherwise we have a body */ + condAst = backPatchLabels(condAst,trueLabel,falseLabel); + + /* attach the body label to the top */ + doBody = createLabel(trueLabel,doBody); + /* attach the continue label to end of body */ + doBody = newNode(NULLOP, doBody, + createLabel(continueLabel,NULL)); + + /* now put the break label at the end */ + if (IS_IFX(condAst)) + doTree = condAst; + else + doTree = newIfxNode(condAst,trueLabel,falseLabel); + + doTree = newNode(NULLOP,doTree,createLabel(falseLabel,NULL)); + + /* putting it together */ + return newNode(NULLOP,doBody,doTree); +} + +/*-----------------------------------------------------------------*/ +/* createFor - creates parse tree for 'for' statement */ +/* initExpr */ +/* _forcond_n: */ +/* condExpr +-> trueLabel -> _forbody_n */ +/* | */ +/* +-> falseLabel-> _forbreak_n */ +/* _forbody_n: */ +/* statements */ +/* _forcontinue_n: */ +/* loopExpr */ +/* goto _forcond_n ; */ +/* _forbreak_n: */ +/*-----------------------------------------------------------------*/ +ast *createFor ( symbol *trueLabel, symbol *continueLabel , + symbol *falseLabel,symbol *condLabel , + ast *initExpr, ast *condExpr, ast *loopExpr, + ast *forBody ) +{ + ast *forTree ; + + /* if loopexpression not present then we can generate it */ + /* the same way as a while */ + if ( ! loopExpr ) + return newNode(NULLOP,initExpr, + createWhile (trueLabel, continueLabel, + falseLabel,condExpr, forBody )); + /* vanilla for statement */ + condExpr = backPatchLabels(condExpr,trueLabel,falseLabel); + + if (!IS_IFX(condExpr)) + condExpr = newIfxNode(condExpr,trueLabel,falseLabel); + + + /* attach condition label to condition */ + condExpr = createLabel(condLabel,condExpr); + + /* attach body label to body */ + forBody = createLabel(trueLabel,forBody); + + /* attach continue to forLoop expression & attach */ + /* goto the forcond @ and of loopExpression */ + loopExpr = createLabel(continueLabel, + newNode(NULLOP, + loopExpr, + newNode(GOTO, + newAst(EX_VALUE,symbolVal(condLabel)), + NULL))); + /* now start putting them together */ + forTree = newNode(NULLOP,initExpr,condExpr); + forTree = newNode(NULLOP,forTree,forBody); + forTree = newNode(NULLOP,forTree,loopExpr); + /* finally add the break label */ + forTree = newNode(NULLOP,forTree, + createLabel(falseLabel,NULL)); + return forTree ; +} + +/*-----------------------------------------------------------------*/ +/* createWhile - creates parse tree for while statement */ +/* the while statement will be created as follows */ +/* */ +/* _while_continue_n: */ +/* condition_expression +-> trueLabel -> _while_boby_n */ +/* | */ +/* +-> falseLabel -> _while_break_n*/ +/* _while_body_n: */ +/* statements */ +/* goto _while_continue_n */ +/* _while_break_n: */ +/*-----------------------------------------------------------------*/ +ast *createWhile (symbol *trueLabel, symbol *continueLabel, + symbol *falseLabel,ast *condExpr, ast *whileBody ) +{ + ast *whileTree ; + + /* put the continue label */ + condExpr = backPatchLabels (condExpr,trueLabel,falseLabel); + condExpr = createLabel(continueLabel,condExpr); + condExpr->lineno = 0; + + /* put the body label in front of the body */ + whileBody = createLabel(trueLabel,whileBody); + whileBody->lineno = 0; + /* put a jump to continue at the end of the body */ + /* and put break label at the end of the body */ + whileBody = newNode(NULLOP, + whileBody, + newNode(GOTO, + newAst(EX_VALUE, + symbolVal(continueLabel)), + createLabel(falseLabel,NULL))); + + /* put it all together */ + if ( IS_IFX(condExpr) ) + whileTree = condExpr ; + else { + whileTree = newNode (IFX, condExpr,NULL ); + /* put the true & false labels in place */ + whileTree->trueLabel = trueLabel ; + whileTree->falseLabel= falseLabel; + } + + return newNode(NULLOP,whileTree,whileBody ); +} + +/*-----------------------------------------------------------------*/ +/* optimizeGetHbit - get highest order bit of the expression */ +/*-----------------------------------------------------------------*/ +ast *optimizeGetHbit (ast *tree) +{ + int i,j; + /* if this is not a bit and */ + if (!IS_BITAND(tree)) + return tree; + + /* will look for tree of the form + ( expr >> ((sizeof expr) -1) ) & 1 */ + if (!IS_AST_LIT_VALUE(tree->right)) + return tree; + + if (AST_LIT_VALUE(tree->right) != 1) + return tree; + + if (!IS_RIGHT_OP(tree->left)) + return tree; + + if (!IS_AST_LIT_VALUE(tree->left->right)) + return tree; + + if ((i = AST_LIT_VALUE(tree->left->right)) != + ( j = (getSize(TTYPE(tree->left->left))*8 - 1))) + return tree; + + return decorateType(newNode(GETHBIT,tree->left->left,NULL)); + +} + +/*-----------------------------------------------------------------*/ +/* optimizeRRCRLC :- optimize for Rotate Left/Right with carry */ +/*-----------------------------------------------------------------*/ +ast *optimizeRRCRLC ( ast *root ) +{ + /* will look for trees of the form + (?expr << 1) | (?expr >> 7) or + (?expr >> 7) | (?expr << 1) will make that + into a RLC : operation .. + Will also look for + (?expr >> 1) | (?expr << 7) or + (?expr << 7) | (?expr >> 1) will make that + into a RRC operation + note : by 7 I mean (number of bits required to hold the + variable -1 ) */ + /* if the root operations is not a | operation the not */ + if (!IS_BITOR(root)) + return root ; + + /* I have to think of a better way to match patterns this sucks */ + /* that aside let start looking for the first case : I use a the + negative check a lot to improve the efficiency */ + /* (?expr << 1) | (?expr >> 7) */ + if (IS_LEFT_OP(root->left) && + IS_RIGHT_OP(root->right) ) { + + if (!SPEC_USIGN(TETYPE(root->left->left))) + return root; + + if (!IS_AST_LIT_VALUE(root->left->right) || + !IS_AST_LIT_VALUE(root->right->right)) + goto tryNext0; + + /* make sure it is the same expression */ + if (!isAstEqual(root->left->left, + root->right->left)) + goto tryNext0; + + if (AST_LIT_VALUE(root->left->right) != 1 ) + goto tryNext0 ; + + if (AST_LIT_VALUE(root->right->right) != + (getSize(TTYPE(root->left->left))*8 - 1)) + goto tryNext0 ; + + /* whew got the first case : create the AST */ + return newNode(RLC,root->left->left,NULL); + } + + tryNext0: + /* check for second case */ + /* (?expr >> 7) | (?expr << 1) */ + if (IS_LEFT_OP(root->right) && + IS_RIGHT_OP(root->left) ) { + + if (!SPEC_USIGN(TETYPE(root->left->left))) + return root; + + if (!IS_AST_LIT_VALUE(root->left->right) || + !IS_AST_LIT_VALUE(root->right->right)) + goto tryNext1 ; + + /* make sure it is the same symbol */ + if (!isAstEqual(root->left->left, + root->right->left)) + goto tryNext1 ; + + if (AST_LIT_VALUE(root->right->right) != 1 ) + goto tryNext1 ; + + if (AST_LIT_VALUE(root->left->right) != + (getSize(TTYPE(root->left->left))*8 - 1)) + goto tryNext1 ; + + /* whew got the first case : create the AST */ + return newNode(RLC,root->left->left,NULL); + + } + + tryNext1: + /* third case for RRC */ + /* (?symbol >> 1) | (?symbol << 7) */ + if (IS_LEFT_OP(root->right) && + IS_RIGHT_OP(root->left) ) { + + if (!SPEC_USIGN(TETYPE(root->left->left))) + return root; + + if (!IS_AST_LIT_VALUE(root->left->right) || + !IS_AST_LIT_VALUE(root->right->right)) + goto tryNext2; + + /* make sure it is the same symbol */ + if (!isAstEqual(root->left->left, + root->right->left)) + goto tryNext2; + + if (AST_LIT_VALUE(root->left->right) != 1 ) + goto tryNext2; + + if (AST_LIT_VALUE(root->right->right) != + (getSize(TTYPE(root->left->left))*8 - 1)) + goto tryNext2; + + /* whew got the first case : create the AST */ + return newNode(RRC,root->left->left,NULL); + + } + tryNext2: + /* fourth and last case for now */ + /* (?symbol << 7) | (?symbol >> 1) */ + if (IS_RIGHT_OP(root->right) && + IS_LEFT_OP(root->left) ) { + + if (!SPEC_USIGN(TETYPE(root->left->left))) + return root; + + if (!IS_AST_LIT_VALUE(root->left->right) || + !IS_AST_LIT_VALUE(root->right->right)) + return root; + + /* make sure it is the same symbol */ + if (!isAstEqual(root->left->left, + root->right->left)) + return root; + + if (AST_LIT_VALUE(root->right->right) != 1 ) + return root ; + + if (AST_LIT_VALUE(root->left->right) != + (getSize(TTYPE(root->left->left))*8 - 1)) + return root ; + + /* whew got the first case : create the AST */ + return newNode(RRC,root->left->left,NULL); + + } + + /* not found return root */ + return root; +} + +/*-----------------------------------------------------------------*/ +/* optimizeCompare - otimizes compares for bit variables */ +/*-----------------------------------------------------------------*/ +ast *optimizeCompare ( ast *root ) +{ + ast *optExpr = NULL; + value *vleft; + value *vright; + unsigned int litValue ; + + /* if nothing then return nothing */ + if (!root) + return NULL ; + + /* if not a compare op then do leaves */ + if (!IS_COMPARE_OP(root)) { + root->left = optimizeCompare (root->left); + root->right= optimizeCompare (root->right); + return root ; + } + + /* if left & right are the same then depending + of the operation do */ + if (isAstEqual(root->left,root->right)) { + switch (root->opval.op) { + case '>' : + case '<' : + case NE_OP : + optExpr = newAst(EX_VALUE,constVal("0")); + break; + case GE_OP : + case LE_OP : + case EQ_OP : + optExpr = newAst(EX_VALUE,constVal("1")); + break; + } + + return decorateType(optExpr); + } + + vleft = (root->left->type == EX_VALUE ? + root->left->opval.val : NULL ); + + vright = (root->right->type == EX_VALUE ? + root->right->opval.val : NULL); + + /* if left is a BITVAR in BITSPACE */ + /* and right is a LITERAL then opt-*/ + /* imize else do nothing */ + if (vleft && vright && + IS_BITVAR(vleft->etype) && + IN_BITSPACE(SPEC_OCLS(vleft->etype)) && + IS_LITERAL(vright->etype)) { + + /* if right side > 1 then comparison may never succeed */ + if ( (litValue = (int) floatFromVal(vright)) > 1 ) { + werror(W_BAD_COMPARE); + goto noOptimize ; + } + + if ( litValue ) { + switch (root->opval.op) { + case '>' : /* bit value greater than 1 cannot be */ + werror(W_BAD_COMPARE); + goto noOptimize ; + break; + + case '<' : /* bit value < 1 means 0 */ + case NE_OP : + optExpr = newNode('!',newAst(EX_VALUE,vleft),NULL); + break; + + case LE_OP : /* bit value <= 1 means no check */ + optExpr = newAst(EX_VALUE,vright); + break; + + case GE_OP : /* bit value >= 1 means only check for = */ + case EQ_OP : + optExpr = newAst(EX_VALUE,vleft); + break; + } + } else { /* literal is zero */ + switch (root->opval.op) { + case '<' : /* bit value < 0 cannot be */ + werror(W_BAD_COMPARE); + goto noOptimize ; + break; + + case '>' : /* bit value > 0 means 1 */ + case NE_OP : + optExpr = newAst(EX_VALUE,vleft); + break; + + case LE_OP : /* bit value <= 0 means no check */ + case GE_OP : /* bit value >= 0 means no check */ + werror(W_BAD_COMPARE); + goto noOptimize ; + break; + + case EQ_OP : /* bit == 0 means ! of bit */ + optExpr = newNode('!',newAst(EX_VALUE,vleft),NULL); + break; + } + } + return decorateType(resolveSymbols(optExpr)); + } /* end-of-if of BITVAR */ + + noOptimize : + return root; +} +/*-----------------------------------------------------------------*/ +/* addSymToBlock : adds the symbol to the first block we find */ +/*-----------------------------------------------------------------*/ +void addSymToBlock (symbol *sym, ast *tree) +{ + /* reached end of tree or a leaf */ + if (!tree || IS_AST_LINK(tree) || IS_AST_VALUE(tree)) + return ; + + /* found a block */ + if (IS_AST_OP(tree) && + tree->opval.op == BLOCK ) { + + symbol *lsym = copySymbol(sym); + + lsym->next = AST_VALUES(tree,sym); + AST_VALUES(tree,sym) = lsym ; + return ; + } + + addSymToBlock(sym,tree->left); + addSymToBlock(sym,tree->right); +} + +/*-----------------------------------------------------------------*/ +/* processRegParms - do processing for register parameters */ +/*-----------------------------------------------------------------*/ +static void processRegParms (value *args, ast *body) +{ + while (args) { + if (IS_REGPARM(args->etype)) + addSymToBlock(args->sym,body); + args = args->next; + } +} + +/*-----------------------------------------------------------------*/ +/* resetParmKey - resets the operandkeys for the symbols */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(resetParmKey) +{ + symbol *sym = item; + + sym->key = 0 ; + sym->defs = NULL ; + sym->uses = NULL ; + sym->remat= 0; + return 1; +} + +/*-----------------------------------------------------------------*/ +/* createFunction - This is the key node that calls the iCode for */ +/* generating the code for a function. Note code */ +/* is generated function by function, later when */ +/* add inter-procedural analysis this will change */ +/*-----------------------------------------------------------------*/ +ast *createFunction (symbol *name, ast *body ) +{ + ast *ex ; + symbol *csym; + int stack = 0 ; + link *fetype; + iCode *piCode = NULL; + + /* if check function return 0 then some problem */ + if (checkFunction (name) == 0) + return NULL; + + /* create a dummy block if none exists */ + if (!body) + body = newNode(BLOCK,NULL,NULL); + + noLineno++ ; + + /* check if the function name already in the symbol table */ + if ((csym = findSym (SymbolTab,NULL,name->name))) { + name = csym ; + /* special case for compiler defined functions + we need to add the name to the publics list : this + actually means we are now compiling the compiler + support routine */ + if (name->cdef) + addSet(&publics,name); + } + else { + addSymChain(name); + allocVariables(name); + } + name->lastLine = yylineno; + currFunc = name ; + processFuncArgs(currFunc,0); + + /* set the stack pointer */ + stackPtr = -1 - (IS_ISR(name->etype)) - (IS_RENT(name->etype) | options.stackAuto); + xstackPtr= -1; + + fetype = getSpec(name->type); /* get the specifier for the function */ + /* if this is a reentrant function then */ + if (IS_RENT(fetype)) + reentrant++ ; + + allocParms (name->args); /* allocate the parameters */ + + /* do processing for parameters that are passed in registers */ + processRegParms (name->args,body); + + /* set the stack pointer */ + stackPtr = 0; + xstackPtr= -1; + + /* allocate & autoinit the block variables */ + processBlockVars (body, &stack,ALLOCATE); + + /* save the stack information */ + if (options.useXstack) + name->xstack = SPEC_STAK(fetype) = stack; + else + name->stack = SPEC_STAK(fetype) = stack; + + /* name needs to be mangled */ + sprintf (name->rname,"_%s",name->name); + + body = resolveSymbols(body); /* resolve the symbols */ + body = decorateType (body); /* propagateType & do semantic checks */ + + ex = newAst (EX_VALUE, symbolVal(name)); /* create name */ + ex = newNode (FUNCTION,ex,body); + ex->values.args = name->args ; + + if (fatalError) { + werror(E_FUNC_NO_CODE,name->name); + goto skipall ; + } + + /* create the node & generate intermediate code */ + codeOutFile = code->oFile; + piCode = iCodeFromAst(ex); + + if (fatalError) { + werror(E_FUNC_NO_CODE,name->name); + goto skipall ; + } + + eBBlockFromiCode(piCode); + + /* if there are any statics then do them */ + if (staticAutos) { + codeOutFile = statsg->oFile; + eBBlockFromiCode (iCodeFromAst (decorateType(resolveSymbols(staticAutos)))); + staticAutos = NULL; + } + + skipall: + + /* dealloc the block variables */ + processBlockVars(body, &stack,DEALLOCATE); + /* deallocate paramaters */ + deallocParms(name->args); + + if (IS_RENT(fetype)) + reentrant-- ; + + /* we are done freeup memory & cleanup */ + noLineno-- ; + labelKey = 1 ; + name->key = 0; + name->fbody = 1; + addSet(&operKeyReset,name); + applyToSet(operKeyReset,resetParmKey); + + if (options.debug) + cdbStructBlock(1,cdbFile); + + cleanUpLevel(LabelTab,0); + cleanUpBlock(StructTab,1); + cleanUpBlock(TypedefTab,1); + + xstack->syms = NULL; + istack->syms = NULL; + return NULL ; +} + + diff --git a/src/SDCCast.h b/src/SDCCast.h new file mode 100644 index 00000000..8c2ca162 --- /dev/null +++ b/src/SDCCast.h @@ -0,0 +1,182 @@ +/*------------------------------------------------------------------------- + SDCCast.h - header file for parser support & all ast related routines + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCCval.h" + +#ifndef SDCCEXPR_H +#define SDCCEXPR_H + +#define EX_OP 0 +#define EX_VALUE 1 +#define EX_LINK 2 +#define EX_STMNT 3 +#define EX_OPERAND 4 + +/* expression tree */ +typedef struct ast { + + unsigned type :3 ; + unsigned decorated :1 ; + unsigned hasVargs :1 ; + unsigned isError :1 ; + unsigned funcName :1 ; + unsigned rvalue :1 ; + unsigned lvalue :1 ; + unsigned initMode :1 ; + int level ; /* level for expr */ + int block ; /* block number */ + /* union of values expression can have */ + union { + value *val ; /* value if type = EX_VALUE */ + link *lnk ; /* link * if type= EX_LINK */ + struct operand *oprnd; /* used only for side effecting function calls */ + unsigned stmnt ; /* statement if type=EX_STMNT */ + unsigned op ; /* operator if type= EX_OP */ + } opval ; + + /* union for special processing */ + union { + char *inlineasm ; /* pointer to inline assembler code */ + symbol *sym ; /* if block then -> symbols */ + value *args ; /* if function then args */ + /* if switch then switch values */ + struct { + value *swVals ; /* switch comparison values */ + int swDefault ; /* default if present */ + int swNum ; /* switch number */ + } switchVals ; + /* if for then for values */ + struct { + struct ast *initExpr ; /* init portion */ + struct ast *condExpr ; /* conditional portion */ + struct ast *loopExpr ; /* iteration portion */ + symbol *trueLabel; /* entry point into body */ + symbol *falseLabel; /* exit point */ + symbol *continueLabel; /* conditional check */ + symbol *condLabel; /* conditional label */ + } forVals ; + } values ; + + int lineno ; /* source file line number */ + char *filename ; /* filename of the source file */ + + link *ftype ; /* start of type chain for this subtree */ + link *etype ; /* end of type chain for this subtree */ + + symbol *argSym ; /* argument symbols */ + value *args ; /* args of a function */ + struct ast *left ; /* pointer to left tree */ + struct ast *right; /* pointer to right tree */ + symbol *trueLabel ; /* if statement trueLabel */ + symbol *falseLabel ; /* if statement falseLabel */ +} ast ; + + +/* easy access macros */ +#define IS_AST_OP(x) (x && x->type == EX_OP) +#define IS_BITOR(x) (IS_AST_OP(x) && x->opval.op == '|') +#define IS_BITAND(x) (IS_AST_OP(x) && x->opval.op == '&' && \ + x->left && x->right ) +#define IS_FOR_STMT(x) (IS_AST_OP(x) && x->opval.op == FOR) +#define IS_LEFT_OP(x) (IS_AST_OP(x) && x->opval.op == LEFT_OP) +#define IS_RIGHT_OP(x) (IS_AST_OP(x) && x->opval.op == RIGHT_OP) +#define IS_AST_VALUE(x) (x && x->type == EX_VALUE && x->opval.val) +#define IS_AST_LINK(x) (x->type == EX_LINK) +#define IS_AST_NOT_OPER(x) (x && IS_AST_OP(x) && x->opval.op == '!') +#define IS_COMPARE_OP(x) (IS_AST_OP(x) && \ + (x->opval.op == '>' || \ + x->opval.op == '<' || \ + x->opval.op == LE_OP || \ + x->opval.op == GE_OP || \ + x->opval.op == EQ_OP || \ + x->opval.op == NE_OP )) +#define IS_CAST_OP(x) (IS_AST_OP(x) && x->opval.op == CAST) +#define IS_ADDRESS_OF_OP(x) (IS_AST_OP(x) && \ + x->opval.op == '&' && \ + x->right == NULL ) +#define IS_AST_LIT_VALUE(x) (IS_AST_VALUE(x) && \ + IS_LITERAL(x->opval.val->etype)) +#define IS_AST_SYM_VALUE(x) (IS_AST_VALUE(x) && x->opval.val->sym) +#define AST_LIT_VALUE(x) (floatFromVal(x->opval.val)) +#define AST_SYMBOL(x) (x->opval.val->sym) +#define AST_VALUE(x) (x->opval.val) +#define AST_VALUES(x,y) (x->values.y) +#define AST_FOR(x,y) x->values.forVals.y + +#define CAN_EVAL(x) ( x == '[' || x == '.' || x == PTR_OP || \ + x == '&' || x == '|' || x == '^' || x == '*' || \ + x == '-' || x == '+' || x == '~' || \ + x == '!' || x == LEFT_OP || x == RIGHT_OP || \ + x == '/' || x == '%' || x == '>' || x == '<' || \ + x == LE_OP || x == GE_OP || x == EQ_OP || x == NE_OP || \ + x == AND_OP || x == OR_OP || x == '=' ) + +#define LEFT_FIRST(x) ( x == AND_OP || x == OR_OP ) + +#define SIDE_EFFECTS_CHECK(op,rVal) if (!sideEffects) { \ + werror(W_NO_SIDE_EFFECTS,op); \ + return rVal ; \ + } +#define IS_MODIFYING_OP(x) ( x == INC_OP || x == DEC_OP || x == '=' || \ + x == AND_ASSIGN || x== OR_ASSIGN || x == XOR_ASSIGN ) + +#define IS_ASSIGN_OP(x) ( x == '=' || x == ADD_ASSIGN || x == SUB_ASSIGN ||\ + x == MUL_ASSIGN || x == DIV_ASSIGN || x == XOR_ASSIGN ||\ + x == AND_ASSIGN || x == OR_ASSIGN) +#define IS_DEREF_OP(x) (( x->opval.op == '*' && x->right == NULL) || x->opval.op == '.') + +/* forward declrations for global variables */ +extern ast *staticAutos ; + +/* forward definitions for functions */ +ast *newAst (int , void * ); +void initAst ( ); +ast *newNode (int ,ast * ,ast * ); +ast *copyAst (ast * ); +value *sizeofOp (link * ); +value *evalStmnt (ast * ); +ast *createFunction(symbol *,ast * ); +ast *createBlock (symbol *,ast * ); +ast *createLabel (symbol *,ast * ); +ast *createCase (ast *,ast *,ast *); +ast *createDefault (ast *,ast * ); +ast *optimizeCompare (ast * ); +ast *forLoopOptForm( ast * ); +ast *argAst ( ast * ); +ast *resolveSymbols (ast *) ; +ast *decorateType (ast *) ; +ast *createWhile (symbol *, symbol *, symbol *, ast *, ast *); +ast *createIf (ast *, ast *, ast *); +ast *createDo (symbol *,symbol *,symbol *,ast *,ast *); +ast *createFor (symbol *,symbol *,symbol *,symbol *,ast *,ast *,ast *, ast *); +void eval2icode (ast *); +value *constExprValue (ast *,int); +symbol *funcOfType (char *,link *,link *,int,int); +ast *initAggregates ( symbol *,initList *, ast *); +bool hasSEFcalls ( ast *); +void addSymToBlock (symbol *, ast *) ; + +#endif diff --git a/src/SDCCbitv.c b/src/SDCCbitv.c new file mode 100644 index 00000000..8796bcc4 --- /dev/null +++ b/src/SDCCbitv.c @@ -0,0 +1,367 @@ +/*----------------------------------------------------------------- + SDCCbitv.c - contains support routines for bitvectors + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include "SDCCbitv.h" +#ifndef ALLOC +#include "SDCCglobl.h" +#endif +int bitVectDefault = 1024; + +/* genernal note about a bitvectors: + bit vectors are stored from left to right i.e. + bit position 0 is the MS bit of the first byte + this also means that bit positions must start from 0*/ +/*-----------------------------------------------------------------*/ +/* newBitVect - returns a new bitvector of size */ +/*-----------------------------------------------------------------*/ +bitVect *newBitVect (int size) +{ + bitVect *bvp; + int byteSize ; + + ALLOC(bvp,sizeof (bitVect)); + + bvp->size = size; + bvp->bSize = byteSize = ( size / 8) + 1 ; + ALLOC(bvp->vect,byteSize); + return bvp; +} + +/*-----------------------------------------------------------------*/ +/* bitVectResize - changes the size of a bit vector */ +/*-----------------------------------------------------------------*/ +bitVect *bitVectResize (bitVect *bvp, int size) +{ + int bSize = ( size / 8) + 1 ; + + if (!bvp) + return newBitVect (size); + + /* if we already have enough space */ + if (bvp->bSize >= bSize ) { + if (size > bvp->size) + bvp->size = size ; + return bvp; + } + + bvp->size = size; + bvp->bSize= bSize; + bvp->vect = GC_realloc(bvp->vect, bSize); + return bvp; +} + +/*-----------------------------------------------------------------*/ +/* bitVectSetBit - sets a given bit in the bit vector */ +/*-----------------------------------------------------------------*/ +bitVect *bitVectSetBit (bitVect *bvp, int pos) +{ + int byteSize; + int offset ; + + /* if set is null then allocate it */ + if (!bvp) + bvp = newBitVect(bitVectDefault) ; /* allocate for twice the size */ + + if (bvp->size <= pos ) + bvp = bitVectResize (bvp,pos+2); /* conservatively resize */ + + byteSize = pos / 8 ; + offset = pos % 8; + bvp->vect[byteSize] |= (((unsigned char)1) << + (7 - offset)); + return bvp; +} + +/*-----------------------------------------------------------------*/ +/* bitVectUnSetBit - unsets the value of a bit in a bitvector */ +/*-----------------------------------------------------------------*/ +void bitVectUnSetBit (bitVect *bvp, int pos) +{ + int byteSize ; + int offset ; + + if (! bvp) + return ; + + byteSize = pos /8; + if (bvp->bSize <= byteSize) + return ; + + offset = pos % 8 ; + + bvp->vect[byteSize] &= ~ (((unsigned char)1) << + (7 - offset)); +} + +/*-----------------------------------------------------------------*/ +/* bitVectBitValue - returns value value at bit position */ +/*-----------------------------------------------------------------*/ +int bitVectBitValue (bitVect *bvp, int pos) +{ + int byteSize; + int offset ; + + if (! bvp) + return 0; + + byteSize = pos /8; + + if ( bvp->bSize <= byteSize ) + return 0; + + offset = pos % 8 ; + + return ((bvp->vect[byteSize] >> (7-offset)) & ((unsigned char)1) ); + +} + +/*-----------------------------------------------------------------*/ +/* bitVectUnion - unions two bitvectors */ +/*-----------------------------------------------------------------*/ +bitVect *bitVectUnion ( bitVect *bvp1, bitVect *bvp2) +{ + int i; + bitVect *newBvp; + + /* if both null */ + if (!bvp1 && !bvp2) + return NULL ; + + /* if one of them null then return the other */ + if (! bvp1 && bvp2 ) + return bitVectCopy (bvp2); + + if ( bvp1 && ! bvp2 ) + return bitVectCopy (bvp1); + + /* if they are not the same size */ + /* make them the same size */ + if (bvp1->bSize < bvp2->bSize) + bvp1 = bitVectResize (bvp1,bvp2->size); + else + if (bvp2->bSize < bvp1->bSize) + bvp2 = bitVectResize (bvp2,bvp1->size); + + newBvp = newBitVect(bvp1->size); + + for ( i = 0 ; i < bvp1->bSize ;i++) + newBvp->vect[i] = bvp1->vect[i] | bvp2->vect[i]; + + + return newBvp; +} + +/*-----------------------------------------------------------------*/ +/* bitVectIntersect - intersect two bitvectors */ +/*-----------------------------------------------------------------*/ +bitVect *bitVectIntersect ( bitVect *bvp1, bitVect *bvp2) +{ + int i; + bitVect *newBvp; + + if (! bvp2 || ! bvp1 ) + return NULL ; + + /* if they are not the same size */ + /* make them the same size */ + if (bvp1->bSize < bvp2->bSize) + bvp1 = bitVectResize (bvp1,bvp2->bSize); + else + if (bvp2->size < bvp1->size) + bvp2 = bitVectResize (bvp2,bvp1->size); + + newBvp = newBitVect(bvp1->size); + + for ( i = 0 ; i < bvp1->bSize ;i++) + newBvp->vect[i] = bvp1->vect[i] & bvp2->vect[i]; + + return newBvp; +} + +/*-----------------------------------------------------------------*/ +/* bitVectBitsInCommon - special case of intersection determines */ +/* if the vectors have any common bits set */ +/*-----------------------------------------------------------------*/ +int bitVectBitsInCommon ( bitVect *bvp1, bitVect *bvp2 ) +{ + int i ; + + if ( ! bvp1 || ! bvp2 ) + return 0; + + for ( i = 0 ; i < min(bvp1->bSize,bvp2->bSize) ; i ++ ) + if ( bvp1->vect[i] & bvp2->vect[i] ) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* bitVectCplAnd - complement the second & and it with the first */ +/*-----------------------------------------------------------------*/ +bitVect *bitVectCplAnd ( bitVect *bvp1, bitVect *bvp2) +{ + int i; + + if ( ! bvp2 ) + return bvp1 ; + + if ( ! bvp1 ) + return bvp1 ; + + /* if they are not the same size */ + /* make them the same size */ + if (bvp1->bSize < bvp2->bSize) + bvp1 = bitVectResize (bvp1,bvp2->bSize); + else + if (bvp2->size < bvp1->size) + bvp2 = bitVectResize (bvp2,bvp1->size); + + for ( i = 0 ; i < bvp1->bSize ;i++) + bvp1->vect[i] = bvp1->vect[i] & (~ bvp2->vect[i]); + + return bvp1; +} + +/*-----------------------------------------------------------------*/ +/* bitVectIsZero - bit vector has all bits turned off */ +/*-----------------------------------------------------------------*/ +int bitVectIsZero (bitVect *bvp) +{ + int i ; + + if (!bvp) + return 1; + + for ( i = 0 ; i < bvp->bSize ; i++ ) + if (bvp->vect[i] != 0) + return 0; + + return 1; +} + +/*-----------------------------------------------------------------*/ +/* bitVectsEqual - returns 1 if the two bit vectors are equal */ +/*-----------------------------------------------------------------*/ +int bitVectEqual ( bitVect *bvp1, bitVect *bvp2) +{ + int i ; + + if ( !bvp1 || !bvp1) + return 0; + + if (bvp1 == bvp2) + return 1; + + if (bvp1->bSize != bvp2->bSize) + return 0; + + for (i = 0 ; i < bvp1->bSize ; i++ ) + if ( bvp1->vect[i] != bvp2->vect[i] ) + return 0; + + return 1; +} + +/*-----------------------------------------------------------------*/ +/* bitVectCopy - creates a bitvector from another bit Vector */ +/*-----------------------------------------------------------------*/ +bitVect *bitVectCopy (bitVect *bvp) +{ + bitVect *newBvp; + int i; + + if (!bvp) + return NULL; + + newBvp = newBitVect(bvp->size); + for ( i = 0 ; i < bvp->bSize; i++ ) + newBvp->vect[i] = bvp->vect[i]; + + return newBvp; +} + +/*-----------------------------------------------------------------*/ +/* bitVectnBitsOn - returns the number of bits that are on */ +/*-----------------------------------------------------------------*/ +int bitVectnBitsOn (bitVect *bvp) +{ + int i, j, k; + unsigned char byte; + int count = 0 ; + + if (!bvp) + return 0; + + /* rip through most of the data in byte sized chunks */ + j = (bvp->size)/8; + for (i = 0 ; i < j; i++) { + byte = bvp->vect[i]; + for (k=0; k<8; k++) { count += byte&1; byte = byte>>1; } + } + + /* finish up the last fractional byte, if any */ + for (i = j*8 ; i < bvp->size; i++) + count += bitVectBitValue(bvp,i); + + return count; + +} + +/*-----------------------------------------------------------------*/ +/* bitVectFirstBit - returns the key for the first bit that is on */ +/*-----------------------------------------------------------------*/ +int bitVectFirstBit (bitVect *bvp) +{ + int i; + + if (!bvp) + return -1; + for (i = 0; i < bvp->size ; i++ ) + if (bitVectBitValue(bvp,i)) + return i; + + return -1; +} + +/*-----------------------------------------------------------------*/ +/* bitVectDebugOn - prints bits that are on */ +/*-----------------------------------------------------------------*/ +void bitVectDebugOn (bitVect *bvp, FILE *of) +{ + int i; + + if (of == NULL) + of = stdout; + if (!bvp) + return; + + fprintf(of,"bitvector Size = %d bSize = %d\n",bvp->size,bvp->bSize); + fprintf(of,"Bits on { "); + for (i = 0 ; i < bvp->size ; i++) { + if (bitVectBitValue(bvp,i)) + fprintf(of,"(%d) ",i); + } + fprintf(of,"}\n"); +} diff --git a/src/SDCCbitv.h b/src/SDCCbitv.h new file mode 100644 index 00000000..78f120eb --- /dev/null +++ b/src/SDCCbitv.h @@ -0,0 +1,60 @@ +/*----------------------------------------------------------------- + SDCCbitv.h - contains support routines for bitVectors + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +/* #include "SDCCglobl.h" */ +/* #include "SDCCsymt.h" */ + +#ifndef SDCCBITV_H +#define SDCCBITV_H + +/* bitvector */ +typedef struct bitVect +{ + int size ; + int bSize; + unsigned char *vect ; +} bitVect ; + + +extern int bitVectDefault ; +/*-----------------------------------------------------------------*/ +/* Forward definition for functions */ +/*-----------------------------------------------------------------*/ +/* bitvector related functions */ +bitVect *newBitVect (int); +bitVect *bitVectResize (bitVect *, int ); +bitVect *bitVectSetBit (bitVect *,int ); +void bitVectUnSetBit (bitVect *,int); +int bitVectBitValue (bitVect *,int); +bitVect *bitVectUnion (bitVect *,bitVect *); +bitVect *bitVectIntersect (bitVect *,bitVect *); +int bitVectBitsInCommon ( bitVect *, bitVect * ); +bitVect *bitVectCplAnd ( bitVect *, bitVect *); +int bitVectEqual (bitVect *,bitVect *); +bitVect *bitVectCopy (bitVect *); +int bitVectIsZero (bitVect *); +int bitVectnBitsOn(bitVect *); +int bitVectFirstBit (bitVect *); +void bitVectDebugOn (bitVect *, FILE *); +#endif diff --git a/src/SDCCcflow.c b/src/SDCCcflow.c new file mode 100644 index 00000000..0b379494 --- /dev/null +++ b/src/SDCCcflow.c @@ -0,0 +1,411 @@ +/*------------------------------------------------------------------------- + + SDCCcflow.c - source file for control flow analysis + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCcse.h" +#include "SDCCcflow.h" + +/*-----------------------------------------------------------------*/ +/* domSetFromVect - creates a domset from the vector */ +/*-----------------------------------------------------------------*/ +set *domSetFromVect (eBBlock **ebbs, bitVect *domVect) +{ + int i = 0 ; + set *domSet = NULL; + + if (!domVect) + return NULL ; + + for (i = 0 ; i < domVect->size ;i++ ) + if (bitVectBitValue(domVect,i)) + addSet(&domSet,ebbs[i]); + return domSet; +} + + +/*-----------------------------------------------------------------*/ +/* addSuccessor - will add bb to succ also add it to the pred of */ +/* the next one : */ +/*-----------------------------------------------------------------*/ +void addSuccessor (eBBlock *thisBlock, eBBlock *succ ) +{ + /* check for boundary conditions */ + if ( ! thisBlock || ! succ ) + return ; + + /* add it to the succ of thisBlock */ + addSetIfnotP (&thisBlock->succList,succ); + + thisBlock->succVect = + bitVectSetBit(thisBlock->succVect,succ->bbnum); + /* add this edge to the list of edges */ + addSet(&graphEdges,newEdge(thisBlock,succ)); + +} + +/*-----------------------------------------------------------------*/ +/* eBBPredecessors - find the predecessors for each block */ +/*-----------------------------------------------------------------*/ +void eBBPredecessors ( eBBlock **ebbs, int count) +{ + int i = 0, j ; + + /* for each block do */ + for ( i = 0 ; i < count ; i++ ) { + + /* if there is no path to this then continue */ + if (ebbs[i]->noPath) + continue; + + /* for each successor of this block if */ + /* it has depth first number > this block */ + /* then this block precedes the successor */ + for (j = 0; j < ebbs[i]->succVect->size ; j++) + + if ( bitVectBitValue(ebbs[i]->succVect,j) && + ebbs[j]->dfnum > ebbs[i]->dfnum ) + + addSet(&ebbs[j]->predList,ebbs[i]); + } +} + +/*-----------------------------------------------------------------*/ +/* eBBSuccessors- find out the successors of all the nodes */ +/*-----------------------------------------------------------------*/ +void eBBSuccessors ( eBBlock **ebbs , int count ) +{ + int i = 0 ; + + /* for all the blocks do */ + for (; i < count; i++ ) { + iCode *ic; + + if (ebbs[i]->noPath) + continue; + + ebbs[i]->succVect = newBitVect(count); + + /* if the next on exists & this one does not */ + /* end in a GOTO or RETURN then the next is */ + /* a natural successor of this. Note we have */ + /* consider eBBlocks with no instructions */ + if (ebbs[i+1]) { + + if (ebbs[i]->ech) { + + if (ebbs[i]->ech->op != GOTO && + ebbs[i]->ech->op != RETURN && + ebbs[i]->ech->op != JUMPTABLE) { + int j = i + 1; + + while (ebbs[j] && ebbs[j]->noPath) j++; + + addSuccessor (ebbs[i],ebbs[j]); /* add it */ + } + } /* no instructions in the block */ + /* could happen for dummy blocks*/ + else + addSuccessor (ebbs[i],ebbs[i+1]); + } + + /* go thru all the instructions: if we find a */ + /* goto or ifx or a return then we have a succ*/ + if ((ic = ebbs[i]->ech)) { + eBBlock *succ ; + + /* special case for jumptable */ + if (ic->op == JUMPTABLE ) { + symbol *lbl ; + for (lbl = setFirstItem(IC_JTLABELS(ic)); lbl; + lbl = setNextItem(IC_JTLABELS(ic))) + addSuccessor(ebbs[i], + eBBWithEntryLabel(ebbs,lbl,count)); + } else { + + succ = NULL ; + /* depending on the instruction operator */ + switch (ic->op) { + case GOTO : /* goto has edge to label */ + succ = eBBWithEntryLabel (ebbs,ic->argLabel.label,count); + break; + + case IFX : /* conditional jump */ + /* if true label is present */ + if (IC_TRUE(ic)) + succ = eBBWithEntryLabel (ebbs,IC_TRUE(ic),count); + else + succ = eBBWithEntryLabel (ebbs,IC_FALSE(ic),count); + break; + + case RETURN : /* block with return */ + succ = eBBWithEntryLabel (ebbs,returnLabel,count); + break; + } + + /* if there is a successor add to the list */ + /* if it is not already present in the list*/ + if (succ) + addSuccessor(ebbs[i],succ); + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* computeDominance - computes the dominance graph */ +/* for algorithm look at Dragon book section 10.10, algo 10.16 */ +/*-----------------------------------------------------------------*/ +void computeDominance ( eBBlock **ebbs, int count ) +{ + int i , j ; + + /* now do the initialisation */ + /* D(n0) := { n0 } */ + ebbs[0]->domVect = + bitVectSetBit(ebbs[0]->domVect = newBitVect(count),ebbs[0]->bbnum); + + + /* for n in N - { n0 } do D(n) = N */ + for (i = 1 ; i < count ; i++ ) { + ebbs[i]->domVect = newBitVect(count); + for (j = 0 ; j < count ; j++ ) { + ebbs[i]->domVect = + bitVectSetBit(ebbs[i]->domVect,ebbs[j]->bbnum); + } + } + + /* end of initialisation */ + + /* while changes to any D(n) occur do */ + /* for n in N - { n0 } do */ + /* D(n) := { n } U (intersection of D( all predecessors of n)) */ + while (1) { + int change ; + + change = 0 ; + for ( i = 1 ; i < count ; i++ ) { + bitVect *cDomVect ; + eBBlock *pred ; + + cDomVect = NULL; + + /* get the intersection of the dominance of all predecessors */ + for (pred = setFirstItem(ebbs[i]->predList) , + cDomVect = (pred ? bitVectCopy(pred->domVect) : NULL) ; + pred ; + pred = setNextItem(ebbs[i]->predList)) { + cDomVect = bitVectIntersect(cDomVect,pred->domVect); + } + if (!cDomVect) + cDomVect = newBitVect(count); + /* this node to the list */ + cDomVect = bitVectSetBit(cDomVect,ebbs[i]->bbnum); + + + if (!bitVectEqual(cDomVect,ebbs[i]->domVect)) { + ebbs[i]->domVect = cDomVect; + change = 1; + } + } + + /* if no change then exit */ + if (!change) + break ; + } +} + +/*-----------------------------------------------------------------*/ +/* immedDom - returns the immediate dominator of a block */ +/*-----------------------------------------------------------------*/ +eBBlock *immedDom (eBBlock **ebbs,eBBlock *ebp) +{ + /* first delete self from the list */ + set *iset = domSetFromVect(ebbs,ebp->domVect); + eBBlock *loop; + eBBlock *idom = NULL; + + deleteSetItem(&iset,ebp); + /* then just return the one with the greatest */ + /* depthfirst number, this will be the immed dominator */ + if ((loop = setFirstItem(iset))) + idom = loop; + for (; loop; loop = setNextItem(iset)) + if (loop->dfnum > idom->dfnum) + idom = loop ; + + setToNull ((void **)&iset); + return idom; + +} + +/*-----------------------------------------------------------------*/ +/* DFOrdering - is visited then nothing else call DFOrdering this */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(DFOrdering) +{ + eBBlock *ebbp = item ; + V_ARG(int *,count); + + if (ebbp->visited) + return 0; + + computeDFOrdering (ebbp,count); /* depthfirst */ + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* computeDFOrdering - computes the depth first ordering of the */ +/* flowgraph */ +/*-----------------------------------------------------------------*/ +void computeDFOrdering ( eBBlock *ebbp , int *count) +{ + + ebbp->visited = 1; + /* for each successor that is not visited */ + applyToSet(ebbp->succList,DFOrdering,count); + + /* set the depth first number */ + ebbp->dfnum = *count ; + *count -= 1; +} + +/*-----------------------------------------------------------------*/ +/* disconBBlock - removes all control flow links for a block */ +/*-----------------------------------------------------------------*/ +void disconBBlock (eBBlock *ebp, eBBlock **ebbs, int count) +{ + /* mark this block as noPath & recompute control flow */ + ebp->noPath = 1; + computeControlFlow (ebbs,count,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* markNoPath - marks those blocks which cannot be reached from top*/ +/*-----------------------------------------------------------------*/ +void markNoPath ( eBBlock **ebbs, int count ) +{ + int i; + + + /* for all blocks if the visited flag is not set : then there */ + /* is no path from _entry to this block push them down in the */ + /* depth first order */ + for ( i = 0 ; i < count ; i++ ) + if (!ebbs[i]->visited) + ebbs[i]->noPath = 1; +} +/*-----------------------------------------------------------------*/ +/* dfNumCompare - used by qsort to sort by dfNumber */ +/*-----------------------------------------------------------------*/ +int dfNumCompare (const void *a, const void *b) +{ + const eBBlock * const *i = a; + const eBBlock * const *j = b; + + if ( (*i)->dfnum > (*j)->dfnum ) + return 1; + + if ( (*i)->dfnum < (*j)->dfnum ) + return -1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* bbNumCompare - used by qsort to sort by bbNumber */ +/*-----------------------------------------------------------------*/ +int bbNumCompare (const void *a, const void *b) +{ + const eBBlock * const *i = a; + const eBBlock * const *j = b; + + if ( (*i)->bbnum > (*j)->bbnum ) + return 1; + + if ( (*i)->bbnum < (*j)->bbnum ) + return -1; + + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* computeControlFlow - does the control flow computation */ +/*-----------------------------------------------------------------*/ +void computeControlFlow (eBBlock **ebbs,int count, int reSort) +{ + int saveCount = count; + int i; + + /* initialise some things */ + + for ( i = 0 ; i < count ; i++ ) { + setToNull((void **)&ebbs[i]->predList); + setToNull((void **)&ebbs[i]->domVect); + setToNull((void **)&ebbs[i]->succList); + setToNull((void **)&ebbs[i]->succVect); + ebbs[i]->visited = 0; + ebbs[i]->dfnum = 0 ; + } + + if (reSort) + /* sort it back by block number */ + qsort (ebbs,saveCount,sizeof(eBBlock *),bbNumCompare); + + setToNull ((void **)&graphEdges); + /* this will put in the */ + /* successor information for each blk */ + eBBSuccessors (ebbs,count); + + /* compute the depth first ordering */ + computeDFOrdering (ebbs[0],&count); + + /* mark blocks with no paths to them */ + markNoPath (ebbs,saveCount); + + /* with the depth first info in place */ + /* add the predecessors for the blocks*/ + eBBPredecessors (ebbs,saveCount); + + /* compute the dominance graph */ + computeDominance (ebbs,saveCount); + + /* sort it by dfnumber */ + qsort (ebbs,saveCount,sizeof(eBBlock *),dfNumCompare); + +} + + diff --git a/src/SDCCcflow.h b/src/SDCCcflow.h new file mode 100644 index 00000000..4ba55bdf --- /dev/null +++ b/src/SDCCcflow.h @@ -0,0 +1,44 @@ +/*------------------------------------------------------------------------- + + SDCCcflow.h - header file for control flow analysis + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "SDCCset.h" + +#ifndef SDCCCFLOW_H +#define SDCCCFLOW_H 1 + +void computeDFOrdering ( eBBlock * , int *) ; +set *domSetFromVect (eBBlock **, bitVect *); +void addSuccessor (eBBlock *, eBBlock *); +void eBBSuccessors ( eBBlock **, int ); +void eBBPredecessors ( eBBlock **, int ); +eBBlock *immedDom (eBBlock **,eBBlock *); +DEFSETFUNC(DFOrdering); +void markNoPath ( eBBlock **, int); +void computeControlFlow (eBBlock **,int , int); +int dfNumCompare (const void *, const void *); +int bbNumCompare (const void *, const void *); +void disconBBlock (eBBlock *,eBBlock **,int); + +#endif diff --git a/src/SDCCcse.c b/src/SDCCcse.c new file mode 100644 index 00000000..210f8c1c --- /dev/null +++ b/src/SDCCcse.c @@ -0,0 +1,1435 @@ +/*------------------------------------------------------------------------- + SDCCcse.c - source file for Common Subexpressions and other utility + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCcflow.h" +#include "SDCCloop.h" +#include "SDCCcse.h" + +/*-----------------------------------------------------------------*/ +/* newCseDef - new cseDef */ +/*-----------------------------------------------------------------*/ +cseDef *newCseDef (operand *sym, iCode *ic) +{ + cseDef *cdp ; + + assert (sym); + ALLOC(cdp,sizeof(cseDef)); + + cdp->sym = sym; + cdp->diCode = ic; + cdp->key = sym->key; + + return cdp; +} + + + +/*-----------------------------------------------------------------*/ +/* int isCseDefEqual - two definitions are equal */ +/*-----------------------------------------------------------------*/ +int isCseDefEqual ( void *vsrc, void *vdest) +{ + cseDef *src = vsrc; + cseDef *dest = vdest; + + if (src == dest) + return 1; + + return (src->key == dest->key && + src->diCode == dest->diCode ) ; + +} + +/*-----------------------------------------------------------------*/ +/* pcseDef - in the cseDef */ +/*-----------------------------------------------------------------*/ +int pcseDef (void *item, va_list ap) +{ + cseDef *cdp = item; + iCodeTable *icTab ; + + if (!cdp->sym) + fprintf(stdout,"**null op**"); + printOperand(cdp->sym,stdout); + icTab = getTableEntry(cdp->diCode->op) ; + icTab->iCodePrint(stdout,cdp->diCode,icTab->printName); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* replaceAllSymBySym - replaces all operands by operand in an */ +/* instruction chain */ +/*-----------------------------------------------------------------*/ +void replaceAllSymBySym (iCode *ic, operand *from , operand *to) +{ + iCode *lic; + + for (lic = ic ; lic ; lic = lic->next ) { + int siaddr ; + + if (IC_RESULT(lic) && IC_RESULT(lic)->key == from->key ) { + /* maintain du chains */ + if (POINTER_SET(lic)) { + bitVectUnSetBit (OP_USES(from),lic->key); + OP_USES(to) = bitVectSetBit (OP_USES(to),lic->key); + } + else { + bitVectUnSetBit (OP_DEFS(from),lic->key); + OP_DEFS(to) = bitVectSetBit (OP_DEFS(to),lic->key); + } + siaddr = IC_RESULT(lic)->isaddr ; + IC_RESULT(lic) = operandFromOperand(to); + IC_RESULT(lic)->isaddr = siaddr ; + } + + if (IC_RIGHT(lic) && IC_RIGHT(lic)->key == from->key ) { + bitVectUnSetBit (OP_USES(from),lic->key); + OP_USES(to) = bitVectSetBit(OP_USES(to),lic->key); + siaddr = IC_RIGHT(lic)->isaddr ; + IC_RIGHT(lic) = operandFromOperand(to); + IC_RIGHT(lic)->isaddr = siaddr ; + } + + if (IC_LEFT(lic) && IC_LEFT(lic)->key == from->key ) { + bitVectUnSetBit (OP_USES(from),lic->key); + OP_USES(to) = bitVectSetBit(OP_USES(to),lic->key); + siaddr = IC_LEFT(lic)->isaddr ; + IC_LEFT(lic) = operandFromOperand(to); + IC_LEFT(lic)->isaddr = siaddr ; + } + } +} + +/*-----------------------------------------------------------------*/ +/* iCodeKeyIs - if the icode keys match then return 1 */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(iCodeKeyIs) +{ + cseDef *cdp = item; + V_ARG(int,key); + + if (cdp->diCode->key == key) + return 1; + else + return 0; +} + +/*-----------------------------------------------------------------*/ +/* removeFromInExprs - removes an icode from inexpressions */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(removeFromInExprs) +{ + eBBlock *ebp = item; + V_ARG(iCode *,ic); + V_ARG(operand *,from); + V_ARG(operand *,to); + V_ARG(eBBlock *,cbp); + + if (ebp->visited) + return 0; + + ebp->visited = 1; + deleteItemIf(&ebp->inExprs,iCodeKeyIs,ic->key); + if (ebp != cbp && !bitVectBitValue(cbp->domVect,ebp->bbnum)) + replaceAllSymBySym(ebp->sch,from,to); + + applyToSet(ebp->succList,removeFromInExprs,ic,from,to,cbp); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isGlobalInNearSpace - return TRUE if valriable is a globalin data */ +/*-----------------------------------------------------------------*/ +static bool isGlobalInNearSpace (operand *op) +{ + link *type = getSpec(operandType(op)); + /* this is 8051 specific: optimization + suggested by Jean-Louis VERN, with 8051s we have no + advantage of putting variables in near space into + registers */ + if (isOperandGlobal(op) && + IN_DIRSPACE(SPEC_OCLS(type))) + return TRUE; + else + return FALSE; +} + +/*-----------------------------------------------------------------*/ +/* findCheaperOp - cseBBlock support routine, will check to see if */ +/* we have a operand previously defined */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(findCheaperOp) +{ + cseDef *cdp = item ; + V_ARG(operand *,cop); + V_ARG(operand **,opp); + + /* if we have already found it */ + if (*opp) + return 1; + + /* not found it yet check if this is the one */ + /* and this is not the defining one */ + if (cop->key == cdp->key) { + + /* do a special check this will help in */ + /* constant propagation & dead code elim*/ + /* for assignments only */ + if (cdp->diCode->op == '=') { + /* if the result is volatile then return result */ + if (IS_OP_VOLATILE (IC_RESULT(cdp->diCode))) + *opp = IC_RESULT(cdp->diCode); + else + /* if this is a straight assignment and + left is a temp then prefer the temporary to the + true symbol */ + if (!POINTER_SET(cdp->diCode) && + IS_ITEMP(IC_RESULT(cdp->diCode)) && + IS_TRUE_SYMOP(IC_RIGHT(cdp->diCode))) + *opp = IC_RESULT(cdp->diCode); + else + /* if straight assignement && and both + are temps then prefer the one that + will not need extra space to spil, also + take into consideration if right side + an induction variable + */ + if (!POINTER_SET(cdp->diCode) && + IS_ITEMP(IC_RESULT(cdp->diCode)) && + IS_ITEMP(IC_RIGHT(cdp->diCode)) && + !OP_SYMBOL(IC_RIGHT(cdp->diCode))->isind && + ( (!SPIL_LOC(IC_RIGHT(cdp->diCode)) && + SPIL_LOC(IC_RESULT(cdp->diCode))) || + ( SPIL_LOC(IC_RESULT(cdp->diCode)) && + SPIL_LOC(IC_RESULT(cdp->diCode)) == + SPIL_LOC(IC_RIGHT(cdp->diCode))) ) + ) + *opp = IC_RESULT(cdp->diCode); + else + *opp = IC_RIGHT(cdp->diCode); + } + else + *opp = IC_RESULT(cdp->diCode) ; + } + + /* if this is an assign to a temp. then check + if the right side is this then return this */ + if (IS_TRUE_SYMOP(cop) && + cdp->diCode->op == '=' && + !POINTER_SET(cdp->diCode) && + cop->key == IC_RIGHT(cdp->diCode)->key && + !isGlobalInNearSpace (IC_RIGHT(cdp->diCode)) && + IS_ITEMP(IC_RESULT(cdp->diCode))) + *opp = IC_RESULT(cdp->diCode); + + if (*opp) { + + if ((isGlobalInNearSpace(cop) && + !isOperandLiteral(*opp)) || + isOperandVolatile(*opp,FALSE) + ) { + *opp = NULL; + return 0; + } + + if (cop->key == (*opp)->key ) { + *opp = NULL ; + return 0; + } + + if ((*opp)->isaddr != cop->isaddr && IS_ITEMP(cop)) { + *opp = operandFromOperand(*opp); + (*opp)->isaddr = cop->isaddr; + } + + return 1; + + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* findPointerSet - finds the right side of a pointer set op */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(findPointerSet) +{ + cseDef *cdp = item; + V_ARG(operand *,op); + V_ARG(operand **,opp); + + if (POINTER_SET(cdp->diCode) && + IC_RESULT(cdp->diCode)->key == op->key && + !isOperandVolatile(IC_RESULT(cdp->diCode),TRUE) && + !isOperandVolatile(IC_RIGHT(cdp->diCode),TRUE)) { + *opp = IC_RIGHT(cdp->diCode); + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* findPrevIc - cseBBlock support function will return the iCode */ +/* which matches the current one */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(findPrevIc) +{ + cseDef *cdp = item ; + V_ARG(iCode *,ic); + V_ARG(iCode **,icp); + + /* if already found */ + if (*icp) + return 1; + + /* if the iCodes are the same */ + if (isiCodeEqual(ic,cdp->diCode) && + isOperandEqual(cdp->sym,IC_RESULT(cdp->diCode))) { + *icp = cdp->diCode ; + return 1; + } + + /* if iCodes are not the same */ + /* see the operands maybe interchanged */ + if (ic->op == cdp->diCode->op && + ( ic->op == '+' || ic->op == '*' ) && + isOperandEqual(IC_LEFT(ic),IC_RIGHT(cdp->diCode)) && + isOperandEqual(IC_RIGHT(ic),IC_LEFT(cdp->diCode))) { + *icp = cdp->diCode ; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* ifDefGlobal - if definition is global */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifDefGlobal) +{ + cseDef *cdp = item; + + return (isOperandGlobal(cdp->sym)); +} + +/*-----------------------------------------------------------------*/ +/* ifOperandsHave - if any of the operand are the same as this */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifOperandsHave) +{ + cseDef *cdp = item; + V_ARG(operand *,op); + + + if (IC_LEFT(cdp->diCode) && + IS_SYMOP(IC_LEFT(cdp->diCode)) && + IC_LEFT(cdp->diCode)->key == op->key) + return 1; + + if (IC_RIGHT(cdp->diCode) && + IS_SYMOP(IC_RIGHT(cdp->diCode)) && + IC_RIGHT(cdp->diCode)->key == op->key) + return 1; + + /* or if any of the operands are volatile */ + if (IC_LEFT(cdp->diCode) && + IS_OP_VOLATILE(IC_LEFT(cdp->diCode))) + return 1; + + if (IC_RIGHT(cdp->diCode) && + IS_OP_VOLATILE(IC_RIGHT(cdp->diCode))) + return 1; + + + if (IC_RESULT(cdp->diCode) && + IS_OP_VOLATILE(IC_RESULT(cdp->diCode))) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* ifDefSymIs - if a definition is found in the set */ +/*-----------------------------------------------------------------*/ + int ifDefSymIs (set *cseSet, operand *sym) +{ + cseDef *loop ; + set *sl ; + + if (!sym || !IS_SYMOP(sym)) + return 0; + for (sl = cseSet ; sl ; sl = sl->next ) { + loop = sl->item; + if (loop->sym->key == sym->key ) + return 1; + } + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* ifDefSymIsX - will return 1 if the symbols match */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifDefSymIsX) +{ + cseDef *cdp = item; + V_ARG(operand *,op); + + if (op && cdp->sym) + return cdp->sym->key == op->key ; + else + return ( isOperandEqual(cdp->sym,op) ); + +} + + +/*-----------------------------------------------------------------*/ +/* ifDiCodeIs - returns truw if diCode is same */ +/*-----------------------------------------------------------------*/ + int ifDiCodeIs (set *cseSet, iCode *ic) +{ + cseDef *loop; + set *sl; + + if (!ic) + return 0; + + for (sl = cseSet ; sl ; sl = sl->next ) { + loop = sl->item ; + if (loop->diCode == ic) + return 1; + } + return 0; + +} + +/*-----------------------------------------------------------------*/ +/* ifPointerGet - returns true if the icode is pointer get sym */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifPointerGet) +{ + cseDef *cdp = item; + V_ARG(operand *,op); + + if (POINTER_GET(cdp->diCode) && + IC_LEFT(cdp->diCode)->key == op->key) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* ifPointerSet - returns true if the icode is pointer set sym */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifPointerSet) +{ + cseDef *cdp = item; + V_ARG(operand *,op); + + if (POINTER_SET(cdp->diCode) && + IC_RESULT(cdp->diCode)->key == op->key) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* ifDiCodeIsX - will return 1 if the symbols match */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifDiCodeIsX) +{ + cseDef *cdp = item; + V_ARG(iCode *,ic); + + return cdp->diCode == ic; + +} + +/*-----------------------------------------------------------------*/ +/* algebraicOpts - does some algebraic optimizations */ +/*-----------------------------------------------------------------*/ +void algebraicOpts (iCode *ic) +{ + /* we don't deal with the following iCodes + here */ + if (ic->op == IFX || + ic->op == IPUSH || + ic->op == IPOP || + ic->op == CALL || + ic->op == PCALL || + ic->op == RETURN || + POINTER_GET(ic)) + return ; + + /* if both operands present & ! IFX */ + /* then if they are both literal we */ + /* perform the operation right now */ + if (IC_RESULT(ic) && + IC_RIGHT(ic) && + IC_LEFT(ic) && + IS_OP_LITERAL(IC_LEFT(ic)) && + IS_OP_LITERAL(IC_RIGHT(ic))) { + + IC_RIGHT(ic) = operandOperation (IC_LEFT(ic), + IC_RIGHT(ic), + ic->op, + operandType(IC_RESULT(ic))); + ic->op = '='; + IC_LEFT(ic) = NULL ; + SET_RESULT_RIGHT(ic); + return ; + + } + /* if not ifx & only one operand present */ + if (IC_RESULT(ic) && + IC_LEFT(ic) && + IS_OP_LITERAL(IC_LEFT(ic)) && + !IC_RIGHT(ic)) { + + IC_RIGHT(ic) = operandOperation (IC_LEFT(ic), + IC_RIGHT(ic), + ic->op, + operandType(IC_RESULT(ic))); + ic->op = '='; + IC_LEFT(ic) = NULL ; + SET_RESULT_RIGHT(ic); + return ; + } + + + /* a special case : or in short a kludgy solution will think + about a better solution over a glass of wine someday */ + if ( ic->op == GET_VALUE_AT_ADDRESS ) { + + if (IS_ITEMP(IC_RESULT(ic)) && + IS_TRUE_SYMOP(IC_LEFT(ic))) { + + ic->op = '=' ; + IC_RIGHT(ic) = operandFromOperand(IC_LEFT(ic)); + IC_RIGHT(ic)->isaddr = 0; + IC_LEFT(ic) = NULL; + IC_RESULT(ic) = operandFromOperand(IC_RESULT(ic)); + IC_RESULT(ic)->isaddr = 0; + setOperandType(IC_RESULT(ic),operandType(IC_RIGHT(ic))); + return; + } + + if (IS_ITEMP(IC_LEFT(ic)) && + IS_ITEMP(IC_RESULT(ic)) && +/* !OP_SYMBOL(IC_RESULT(ic))->isreqv && */ +/* !OP_SYMBOL(IC_LEFT(ic))->isreqv && */ + !IC_LEFT(ic)->isaddr ) { + ic->op = '=' ; + IC_RIGHT(ic) = operandFromOperand(IC_LEFT(ic)); + IC_RIGHT(ic)->isaddr = 0; + IC_RESULT(ic) = operandFromOperand(IC_RESULT(ic)); + IC_RESULT(ic)->isaddr = 0; + IC_LEFT(ic) = NULL; + return; + } + + } + + + /* depending on the operation */ + switch (ic->op) { + case '+' : + /* if adding the same thing change to left shift by 1*/ + if (IC_LEFT(ic)->key == IC_RIGHT(ic)->key && + !IS_FLOAT(operandType(IC_RESULT(ic)))) { + ic->op = LEFT_OP ; + IC_RIGHT(ic) = operandFromLit(1); + return; + } + /* if addition then check if one of them is a zero */ + /* if yes turn it into assignmnt*/ + if (IS_OP_LITERAL(IC_LEFT(ic)) && + operandLitValue(IC_LEFT(ic)) == 0.0 ) { + + ic->op = '=' ; + IC_LEFT(ic) = NULL ; + SET_ISADDR(IC_RESULT(ic),0); + SET_ISADDR(IC_RIGHT(ic),0); + return ; + } + if (IS_OP_LITERAL(IC_RIGHT(ic)) && + operandLitValue(IC_RIGHT(ic)) == 0.0 ) { + + ic->op = '=' ; + IC_RIGHT(ic) = IC_LEFT(ic) ; + IC_LEFT(ic) = 0; + SET_ISADDR(IC_RIGHT(ic),0); + SET_ISADDR(IC_RESULT(ic),0); + return ; + } + break ; + case '-' : + /* if subtracting the the same thing then zero */ + if ( IC_LEFT(ic)->key == IC_RIGHT(ic)->key ) { + ic->op = '='; + IC_RIGHT(ic) = operandFromLit(0); + IC_LEFT(ic) = NULL ; + IC_RESULT(ic) = operandFromOperand(IC_RESULT(ic)); + IC_RESULT(ic)->isaddr = 0; + return ; + } + + /* if subtraction then check if one of the operand */ + /* is zero then depending on which operand change */ + /* to assignment or unary minus */ + if (IS_OP_LITERAL(IC_RIGHT(ic)) && + operandLitValue(IC_RIGHT(ic)) == 0.0 ) { + /* right size zero change to assignment */ + ic->op = '=' ; + IC_RIGHT(ic) = IC_LEFT(ic); + IC_LEFT(ic) = NULL; + SET_ISADDR(IC_RIGHT(ic),0); + SET_ISADDR(IC_RESULT(ic),0); + return ; + } + if (IS_OP_LITERAL(IC_LEFT(ic)) && + operandLitValue (IC_LEFT(ic)) == 0.0) { + /* left zero turn into an unary minus */ + ic->op = UNARYMINUS ; + IC_LEFT(ic) = IC_RIGHT(ic); + IC_RIGHT(ic) = NULL ; + return ; + } + break; + /* if multiplication then check if either of */ + /* them is zero then the result is zero */ + /* if either of them is one then result is */ + /* the other one */ + case '*' : + if (IS_OP_LITERAL(IC_LEFT(ic))) { + + if (operandLitValue(IC_LEFT(ic)) == 0.0) { + ic->op = '=' ; + IC_RIGHT(ic) = IC_LEFT(ic); + IC_LEFT(ic) = NULL; + SET_RESULT_RIGHT(ic); + return ; + } + if ( operandLitValue(IC_LEFT(ic)) == 1.0) { + ic->op = '=' ; + IC_LEFT(ic) = NULL ; + SET_RESULT_RIGHT(ic); + return ; + } + } + + if (IS_OP_LITERAL(IC_RIGHT(ic))) { + + if (operandLitValue(IC_RIGHT(ic)) == 0.0 ) { + ic->op = '='; + IC_LEFT(ic) = NULL ; + SET_RESULT_RIGHT(ic); + return ; + } + + if (operandLitValue(IC_RIGHT(ic)) == 1.0) { + ic->op = '=' ; + IC_RIGHT(ic) = IC_LEFT(ic); + IC_LEFT(ic) = NULL ; + SET_RESULT_RIGHT(ic); + return ; + } + } + break ; + case '/': + /* if division by self then 1 */ + if (IC_LEFT(ic)->key == IC_RIGHT(ic)->key) { + ic->op = '='; + IC_RIGHT(ic) = operandFromLit(1); + IC_LEFT(ic) = NULL; + IC_RESULT(ic) = operandFromOperand(IC_RESULT(ic)); + IC_RESULT(ic)->isaddr = 0; + } + /* if this is a division then check if right */ + /* is one then change it to an assignment */ + if (IS_OP_LITERAL(IC_RIGHT(ic)) && + operandLitValue(IC_RIGHT(ic)) == 1.0 ) { + + ic->op = '=' ; + IC_RIGHT(ic) = IC_LEFT(ic); + IC_LEFT(ic) = NULL; + SET_RESULT_RIGHT(ic); + return ; + } + break; + /* if both are the same for an comparison operators */ + case EQ_OP : + case LE_OP : + case GE_OP : + if (isOperandEqual(IC_LEFT(ic),IC_RIGHT(ic))) { + ic->op = '='; + IC_RIGHT(ic) = operandFromLit(1); + IC_LEFT(ic) = NULL; + SET_RESULT_RIGHT(ic); + } + break; + case NE_OP : + case '>' : + case '<' : + if (isOperandEqual(IC_LEFT(ic),IC_RIGHT(ic))) { + ic->op = '='; + IC_RIGHT(ic) = operandFromLit(0); + IC_LEFT(ic) = NULL ; + SET_RESULT_RIGHT(ic); + } + break ; + case CAST : + /* if this is a cast of a literal value */ + if ( IS_OP_LITERAL(IC_RIGHT(ic))) { + ic->op = '=' ; + IC_RIGHT(ic) = + operandFromValue (valCastLiteral(operandType(IC_LEFT(ic)), + operandLitValue(IC_RIGHT(ic)))); + IC_LEFT(ic) = NULL; + SET_ISADDR(IC_RESULT(ic),0); + } + /* if casting to the same */ + if ( checkType(operandType(IC_RESULT(ic)), + operandType(IC_RIGHT(ic))) == 1) { + ic->op = '='; + IC_LEFT(ic) = NULL; + SET_ISADDR(IC_RESULT(ic),0); + } + break; + case '!' : + if (IS_OP_LITERAL(IC_LEFT(ic))) { + ic->op = '=' ; + IC_RIGHT(ic) = + (operandLitValue(IC_LEFT(ic)) == 0 ? + operandFromLit(1) : operandFromLit(0)); + IC_LEFT(ic) = NULL; + SET_ISADDR(IC_RESULT(ic),0); + } + } + + return ; +} +#define OTHERS_PARM(s) (s->_isparm && !s->ismyparm) +/*-----------------------------------------------------------------*/ +/* updateSpillLocation - keeps track of register spill location */ +/*-----------------------------------------------------------------*/ +void updateSpillLocation ( iCode *ic) +{ + + link *setype; + + if (POINTER_SET(ic)) + return; + + if (ic->nosupdate) + return; + + /* for the form true_symbol := iTempNN */ + if (ASSIGN_ITEMP_TO_SYM(ic) + && !SPIL_LOC(IC_RIGHT(ic))) { + + setype = getSpec(operandType(IC_RESULT(ic))); + + if (!IC_RIGHT(ic)->noSpilLoc && + !IS_VOLATILE(setype) && + !IN_FARSPACE(SPEC_OCLS(setype)) && + !OTHERS_PARM(OP_SYMBOL(IC_RESULT(ic))) ) + + SPIL_LOC(IC_RIGHT(ic)) = + IC_RESULT(ic)->operand.symOperand; + } + + if (ASSIGN_ITEMP_TO_ITEMP(ic) && + !SPIL_LOC(IC_RIGHT(ic)) && + OP_SYMBOL(IC_RESULT(ic))->isreqv) { + + setype = getSpec(operandType(IC_RESULT(ic))); + + if (!IC_RIGHT(ic)->noSpilLoc && + !IS_VOLATILE(setype) && + !IN_FARSPACE(SPEC_OCLS(setype)) && + !OTHERS_PARM(OP_SYMBOL(IC_RESULT(ic))) ) + + SPIL_LOC(IC_RIGHT(ic)) = + SPIL_LOC(IC_RESULT(ic)); + } +} + +/*-----------------------------------------------------------------*/ +/* setUsesDef - sets the uses def bitvector for a given operand */ +/*-----------------------------------------------------------------*/ +void setUsesDefs (operand *op, bitVect *bdefs, + bitVect *idefs, bitVect **oud) +{ + /* compute the definitions alive at this point */ + bitVect *adefs = bitVectUnion(bdefs,idefs); + + /* of these definitions find the ones that are */ + /* for this operand */ + adefs = bitVectIntersect(adefs,OP_DEFS(op)); + + /* these are the definitions that this operand can use */ + op->usesDefs = adefs; + + /* the out defs is an union */ + *oud = bitVectUnion(*oud,adefs); +} + +/*-----------------------------------------------------------------*/ +/* ifxOptimize - changes ifx conditions if it can */ +/*-----------------------------------------------------------------*/ +void ifxOptimize (iCode *ic, set *cseSet, + int computeOnly , + eBBlock *ebb, int *change, + eBBlock **ebbs, int count) +{ + operand *pdop ; + symbol *label; + + /* if the condition can be replaced */ + if (!computeOnly) { + pdop = NULL ; + applyToSetFTrue (cseSet,findCheaperOp,IC_COND(ic),&pdop); + if (pdop) { + IC_COND(ic) = pdop ; + (*change)++; + } + } + + /* if the conditional is a literal then */ + if (IS_OP_LITERAL(IC_COND(ic))) { + + if ( operandLitValue(IC_COND(ic)) && IC_TRUE(ic)) { + + /* change to a goto */ + ic->op = GOTO ; + IC_LABEL(ic) = IC_TRUE(ic); + (*change)++; + + } else { + + if (!operandLitValue(IC_COND(ic)) && IC_FALSE(ic)) { + ic->op = GOTO ; + IC_LABEL(ic) = IC_FALSE(ic); + (*change)++; + + } else { + /* then kill this if condition */ + remiCodeFromeBBlock (ebb,ic); + } + } + + /* now we need to recompute the control flow */ + /* since the control flow has changed */ + /* this is very expensive but it does not happen */ + /* too often, if it does happen then the user pays */ + /* the price */ + computeControlFlow (ebbs,count,1); + werror (W_CONTROL_FLOW,ic->filename,ic->lineno); + return ; + } + + /* if there is only one successor and that successor + is the same one we are conditionally going to then + we can remove this conditional statement */ + label = (IC_TRUE(ic) ? IC_TRUE(ic) : IC_FALSE(ic)); + if (elementsInSet(ebb->succList) == 1 && + isinSet(ebb->succList,eBBWithEntryLabel(ebbs,label,count))) { + + remiCodeFromeBBlock(ebb,ic); + computeControlFlow (ebbs,count,1); + werror (W_CONTROL_FLOW,ic->filename,ic->lineno); + return ; + } + + + /* if it remains an IFX the update the use Set */ + OP_USES(IC_COND(ic)) = bitVectSetBit(OP_USES(IC_COND(ic)),ic->key); + setUsesDefs(IC_COND(ic),ebb->defSet,ebb->outDefs,&ebb->usesDefs); + return ; +} + +/*-----------------------------------------------------------------*/ +/* unsetDefsAndUses - clear this operation for the operands */ +/*-----------------------------------------------------------------*/ +void unsetDefsAndUses ( iCode *ic ) +{ + if ( ic->op == JUMPTABLE) + return ; + + /* take away this definition from the def chain of the */ + /* result & take away from use set of the operands */ + if (ic->op != IFX) { + /* turn off def set */ + if (IS_SYMOP(IC_RESULT(ic))) { + if ( !POINTER_SET(ic)) + bitVectUnSetBit(OP_DEFS(IC_RESULT(ic)),ic->key); + else + bitVectUnSetBit(OP_USES(IC_RESULT(ic)),ic->key); + } + /* turn off the useSet for the operands */ + if (IS_SYMOP(IC_LEFT(ic))) + bitVectUnSetBit (OP_USES(IC_LEFT(ic)),ic->key); + + if (IS_SYMOP(IC_RIGHT(ic))) + bitVectUnSetBit (OP_USES(IC_RIGHT(ic)),ic->key); + } + else /* must be ifx turn off the use */ + if (IS_SYMOP(IC_COND(ic))) + bitVectUnSetBit (OP_USES(IC_COND(ic)),ic->key); +} + +/*-----------------------------------------------------------------*/ +/* diCodeForSym - finds the definiting instruction for a symbol */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(diCodeForSym) +{ + cseDef *cdp = item; + V_ARG(operand *,sym); + V_ARG(iCode **,dic); + + /* if already found */ + if (*dic) + return 0; + + /* if not if this is the defining iCode */ + if (sym->key == cdp->key) { + *dic = cdp->diCode ; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* constFold - does some constant folding */ +/*-----------------------------------------------------------------*/ +int constFold (iCode *ic, set *cseSet) +{ + iCode *dic = NULL; + /* this routine will change + a = b + 10; + c = a + 10; + to + c = b + 20; */ + + /* deal with only + & - */ + if (ic->op != '+' && + ic->op != '-' ) + return 0; + + /* this check is a hueristic to prevent live ranges + from becoming too long */ + if (IS_PTR(operandType(IC_RESULT(ic)))) + return 0; + + /* check if operation with a literal */ + if (!IS_OP_LITERAL(IC_RIGHT(ic))) + return 0; + + /* check if we can find a definition for the + right hand side */ + if (!(applyToSet(cseSet,diCodeForSym,IC_LEFT(ic),&dic))) + return 0; + + /* check that this is also a +/- */ + if (dic->op != '+' && dic->op != '-') + return 0; + + /* with a literal */ + if (!IS_OP_LITERAL(IC_RIGHT(dic))) + return 0; + + /* it is if the operations are the same*/ + /* the literal parts need to be added */ + IC_LEFT(ic) = operandFromOperand(IC_LEFT(dic)); + if (ic->op == dic->op ) + IC_RIGHT(ic) = operandFromLit(operandLitValue(IC_RIGHT(ic))+ + operandLitValue(IC_RIGHT(dic))); + else + IC_RIGHT(ic) = operandFromLit(operandLitValue(IC_RIGHT(ic)) - + operandLitValue(IC_RIGHT(dic))); + + if (IS_ITEMP(IC_RESULT(ic))) { + SPIL_LOC(IC_RESULT(ic)) = NULL; + IC_RESULT(ic)->noSpilLoc = 1; + } + + + return 1; +} + +/*-----------------------------------------------------------------*/ +/* deleteGetPointers - called when a pointer is passed as parm */ +/* will delete from cseSet all get pointers computed from this */ +/* pointer. A simple ifOperandsHave is not good enough here */ +/*-----------------------------------------------------------------*/ +static void deleteGetPointers (set **cseSet,operand *op,eBBlock *ebb) +{ + set *compItems = NULL; + cseDef *cdp ; + operand *cop; + + /* easy return */ + if (!*cseSet) + return ; + + /* first find all items computed from this operand . + This done fairly simply go thru the list and find + those that are computed by arthimetic with this + op */ + for (cdp = setFirstItem(*cseSet); cdp ; cdp = setNextItem(*cseSet)) { + if (IS_ARITHMETIC_OP(cdp->diCode)) { + if (isOperandEqual(IC_LEFT(cdp->diCode),op) || + isOperandEqual(IC_RIGHT(cdp->diCode),op)) { + /* save it in our list of items */ + addSet(&compItems,IC_RESULT(cdp->diCode)); + } + /* also check for those computed from our computed + list . This will take care of situations like + iTemp1 = iTemp0 + 8; + iTemp2 = iTemp1 + 8; */ + if (isinSetWith(compItems,IC_LEFT(cdp->diCode),isOperandEqual) || + isinSetWith(compItems,IC_RIGHT(cdp->diCode),isOperandEqual)) { + addSet(&compItems,IC_RESULT(cdp->diCode)); + } + } + } + + /* now delete all pointer gets with this op */ + deleteItemIf(cseSet,ifPointerGet,op); + /* set the bit vector used by dataFlow computation later */ + ebb->ptrsSet = bitVectSetBit(ebb->ptrsSet,op->key); + /* now for the computed items */ + for (cop = setFirstItem(compItems); cop ; cop = setNextItem(compItems)) { + ebb->ptrsSet = bitVectSetBit(ebb->ptrsSet,cop->key); + deleteItemIf(cseSet,ifPointerGet,cop); + } +} + +/*-----------------------------------------------------------------*/ +/* delGetPointerSucc - delete get pointer from inExprs of succ with*/ +/* dfnum > supplied */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(delGetPointerSucc) +{ + eBBlock *ebp = item; + V_ARG(operand *,op); + V_ARG(int,dfnum); + + if (ebp->visited) + return 0; + + ebp->visited = 1; + if (ebp->dfnum > dfnum) { + deleteItemIf(&ebp->inExprs,ifPointerGet,op); + } + + return applyToSet(ebp->succList,delGetPointerSucc,op,dfnum); +} + +/*-----------------------------------------------------------------*/ +/* cseBBlock - common subexpression elimination for basic blocks */ +/* this is the hackiest kludgiest routine in the whole */ +/* system. also the most important, since almost all */ +/* data flow related information is computed by it */ +/*-----------------------------------------------------------------*/ +int cseBBlock ( eBBlock *ebb, int computeOnly, + eBBlock **ebbs, int count) +{ + set *cseSet ; + iCode *ic ; + int change = 0 ; + int i; + set *ptrSetSet = NULL; + + /* if this block is not reachable */ + if (ebb->noPath) + return change; + + /* set of common subexpressions */ + cseSet = setFromSet (ebb->inExprs) ; + + /* these will be computed by this routine */ + setToNull ((void **)&ebb->outDefs); + setToNull ((void **)&ebb->defSet); + setToNull ((void **)&ebb->usesDefs); + setToNull ((void **)&ebb->ptrsSet); + setToNull ((void **)&ebb->addrOf); + setToNull ((void **)&ebb->ldefs); + + ebb->outDefs = bitVectCopy (ebb->inDefs); + bitVectDefault = iCodeKey; + ebb->defSet = newBitVect(iCodeKey); + ebb->usesDefs=newBitVect(iCodeKey); + + /* for all the instructions in this block do */ + for (ic = ebb->sch ; ic ; ic = ic->next ) { + + iCode *pdic; + operand *pdop ; + iCode *defic; + + if (SKIP_IC2(ic)) + continue ; + + /* clear the def & use chains for the operands involved */ + /* in this operation . since it can change due to opts */ + unsetDefsAndUses (ic); + + if ( ic->op == PCALL || ic->op == CALL || ic->op == RECEIVE) { + /* add to defSet of the symbol */ + OP_DEFS(IC_RESULT(ic)) = + bitVectSetBit (OP_DEFS(IC_RESULT(ic)),ic->key); + /* add to the definition set of this block */ + ebb->defSet = bitVectSetBit (ebb->defSet,ic->key); + ebb->ldefs = bitVectSetBit (ebb->ldefs,ic->key); + ebb->outDefs= bitVectCplAnd (ebb->outDefs,OP_DEFS(IC_RESULT(ic))); + setUsesDefs(IC_RESULT(ic),ebb->defSet,ebb->outDefs,&ebb->usesDefs); + /* delete global variables from the cseSet + since they can be modified by the function call */ + deleteItemIf(&cseSet,ifDefGlobal); + } + + /* for pcall & ipush we need to add to the useSet */ + if ((ic->op == PCALL || + ic->op == IPUSH || + ic->op == IPOP || + ic->op == SEND) && + IS_SYMOP(IC_LEFT(ic))) { + + /* check if they can be replaced */ + if ( !computeOnly ) { + pdop = NULL ; + applyToSetFTrue(cseSet,findCheaperOp,IC_LEFT(ic),&pdop); + if (pdop) + IC_LEFT(ic) = pdop ; + } + /* the lookup could have changed it*/ + if (IS_SYMOP(IC_LEFT(ic))) { + OP_USES(IC_LEFT(ic)) = + bitVectSetBit(OP_USES(IC_LEFT(ic)),ic->key); + setUsesDefs(IC_LEFT(ic),ebb->defSet, + ebb->outDefs,&ebb->usesDefs); + } + /* if we a sending a pointer as a parameter + then kill all cse since the pointed to item + might be changed in the function being called */ + if (IS_PTR(operandType(IC_LEFT(ic)))) { + deleteGetPointers(&cseSet,IC_LEFT(ic),ebb); + } + continue; + } + + /* if jumptable then mark the usage */ + if (ic->op == JUMPTABLE ) { + OP_USES(IC_JTCOND(ic)) = + bitVectSetBit(OP_USES(IC_JTCOND(ic)),ic->key); + setUsesDefs(IC_JTCOND(ic),ebb->defSet, + ebb->outDefs,&ebb->usesDefs); + continue; + } + + if (SKIP_IC(ic)) + continue ; + + /* do some algebraic optimizations if possible */ + algebraicOpts (ic); + while (constFold(ic,cseSet)); + + /* if this is a condition statment then */ + /* check if the condition can be replaced */ + if (ic->op == IFX ) { + ifxOptimize (ic, cseSet, computeOnly, + ebb, &change, + ebbs, count); + continue ; + } + + /* if the assignment & result is a temp */ + /* see if we can replace it */ + if (ic->op == '=') { + + /* update the spill location for this */ + updateSpillLocation (ic); + + if (POINTER_SET(ic)) { + pdop = NULL ; + applyToSetFTrue (cseSet,findCheaperOp,IC_RESULT(ic),&pdop); + if (pdop && IS_ITEMP(pdop) && !computeOnly) + IC_RESULT(ic) = pdop; + } + } + + /* do the operand lookup i.e. for both the */ + /* right & left operand : check the cseSet */ + /* to see if they have been replaced if yes*/ + /* then replace them with those from cseSet*/ + /* left operand */ + /* and left is a symbol */ + if (IS_SYMOP(IC_LEFT(ic)) && + !computeOnly && ic->op != ADDRESS_OF ) { + + pdop = NULL; + applyToSetFTrue (cseSet,findCheaperOp,IC_LEFT(ic),&pdop) ; + if (pdop) { + if (POINTER_GET(ic)) { + if (IS_ITEMP(pdop) || IS_OP_LITERAL(pdop)) { + IC_LEFT(ic) = pdop; + change = 1; + } + /* check if there is a pointer set + for the same pointer visible if yes + then change this into an assignment */ + pdop = NULL; + if (applyToSetFTrue(cseSet,findPointerSet,IC_LEFT(ic),&pdop)){ + ic->op = '='; + IC_LEFT(ic) = NULL; + IC_RIGHT(ic) = pdop; + SET_ISADDR(IC_RESULT(ic),0); + } + + } + else { + IC_LEFT(ic) = pdop ; + change = 1; + } + } + } + + /*right operand */ + if (IS_SYMOP(IC_RIGHT(ic)) && !computeOnly) { + + pdop = NULL ; + applyToSetFTrue (cseSet,findCheaperOp,IC_RIGHT(ic),&pdop); + if (pdop) { + + IC_RIGHT(ic) = pdop; + change = 1; + } + } + + /* if left or right changed then do algebraic */ + if (change) { + algebraicOpts(ic); + while(constFold(ic,cseSet)); + } + + /* if after all this it becomes a assignment to self + then delete it and continue */ + if (ASSIGNMENT_TO_SELF(ic)) { + remiCodeFromeBBlock(ebb,ic); + continue; + } + + /* now we will check to see if the entire */ + /* operation has been performed before */ + /* and is available */ + /* don't do assignments they will be killed */ + /* by dead code elimination if required do */ + /* it only if result is a temporary */ + pdic = NULL ; + if (!( POINTER_GET(ic) && + (IS_BITFIELD(OP_SYMBOL(IC_RESULT(ic))->etype) || + isOperandVolatile(IC_LEFT(ic),TRUE))) && + ! ASSIGNMENT(ic) && + IS_ITEMP(IC_RESULT(ic)) && + ! computeOnly) { + applyToSet (cseSet,findPrevIc,ic,&pdic); + } + + /* if found then eliminate this and add to*/ + /* to cseSet an element containing result */ + /* of this with previous opcode */ + if (pdic) { + + if (IS_ITEMP(IC_RESULT(ic))) { + + /* replace in the remaining of this block */ + replaceAllSymBySym(ic->next,IC_RESULT(ic),IC_RESULT(pdic)); + /* remove this iCode from inexpressions of all + its successors, it cannot be in the in expressions + of any of the predecessors */ + for (i = 0 ; i < count ;ebbs[i++]->visited = 0); + applyToSet(ebb->succList,removeFromInExprs,ic,IC_RESULT(ic), + IC_RESULT(pdic),ebb); + + /* if this was moved from another block */ + /* then replace in those blocks too */ + if ( ic->movedFrom ) { + eBBlock *owner ; + for (owner = setFirstItem(ic->movedFrom); owner ; + owner = setNextItem(ic->movedFrom)) + replaceAllSymBySym(owner->sch,IC_RESULT(ic),IC_RESULT(pdic)); + } + pdic->movedFrom = unionSets(pdic->movedFrom,ic->movedFrom,THROW_NONE); + } + else + addSetHead (&cseSet,newCseDef(IC_RESULT(ic),pdic)); + + if (!computeOnly) + /* eliminate this */ + remiCodeFromeBBlock (ebb,ic); + + defic = pdic ; + change++ ; + + if (IS_ITEMP(IC_RESULT(ic))) + continue ; + + } else { + + /* just add this as a previous expression except in */ + /* case of a pointer access in which case this is a */ + /* usage not a definition */ + if (! (POINTER_SET(ic)) && IC_RESULT(ic)){ + deleteItemIf (&cseSet, ifDefSymIsX,IC_RESULT(ic)); + addSetHead(&cseSet,newCseDef(IC_RESULT(ic),ic)); + } + defic = ic; + + } + + /* if assignment to a parameter which is not + mine and type is a pointer then delete + pointerGets to take care of aliasing */ + if (ASSIGNMENT(ic) && + OTHERS_PARM(OP_SYMBOL(IC_RESULT(ic))) && + IS_PTR(operandType(IC_RESULT(ic)))) { + deleteGetPointers(&cseSet,IC_RIGHT(ic),ebb); + } + + /* if this is a pointerget then see if we can replace + this with a previously assigned pointer value */ + if (POINTER_GET(ic) && + !(IS_BITFIELD(OP_SYMBOL(IC_RESULT(ic))->etype) || + isOperandVolatile(IC_LEFT(ic),TRUE))) { + pdop = NULL; + applyToSet(ptrSetSet,findPointerSet,IC_LEFT(ic),&pdop); + /* if we find it then locally replace all + references to the result with what we assigned */ + if (pdop) { + replaceAllSymBySym(ic->next,IC_RESULT(ic),pdop); + } + } + + /* delete from the cseSet anything that has */ + /* operands matching the result of this */ + /* except in case of pointer access */ + if (!(POINTER_SET(ic)) && IC_RESULT(ic)) { + deleteItemIf (&cseSet,ifOperandsHave,IC_RESULT(ic)); + /* delete any previous definitions */ + ebb->defSet = bitVectCplAnd (ebb->defSet,OP_DEFS(IC_RESULT(ic))); + + } + + /* add the left & right to the defUse set */ + if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic))) { + OP_USES(IC_LEFT(ic)) = + bitVectSetBit (OP_USES(IC_LEFT(ic)),ic->key); + setUsesDefs(IC_LEFT(ic),ebb->defSet,ebb->outDefs,&ebb->usesDefs); + + } + + if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic))) { + OP_USES(IC_RIGHT(ic)) = + bitVectSetBit (OP_USES(IC_RIGHT(ic)),ic->key); + setUsesDefs(IC_RIGHT(ic),ebb->defSet,ebb->outDefs,&ebb->usesDefs); + + } + + /* for the result it is special case, put the result */ + /* in the defuseSet if it a pointer or array access */ + if ( POINTER_SET(defic) ) { + OP_USES(IC_RESULT(ic)) = + bitVectSetBit (OP_USES(IC_RESULT(ic)),ic->key); + setUsesDefs(IC_RESULT(ic),ebb->defSet,ebb->outDefs,&ebb->usesDefs); + deleteItemIf(&cseSet,ifPointerGet,IC_RESULT(ic)); + ebb->ptrsSet = bitVectSetBit(ebb->ptrsSet,IC_RESULT(ic)->key); + /* delete from inexpressions of all successors which + have dfNum > than this block */ + for (i = 0 ; i < count ;ebbs[i++]->visited = 0); + applyToSet(ebb->succList,delGetPointerSucc,IC_RESULT(ic),ebb->dfnum); + + /* delete from cseSet all other pointer sets + for this operand */ + deleteItemIf(&ptrSetSet,ifPointerSet,IC_RESULT(ic)); + /* add to the local pointerset set */ + addSetHead(&ptrSetSet,newCseDef(IC_RESULT(ic),ic)); + } + else /* add the result to defintion set */ + if (IC_RESULT(ic)) { + OP_DEFS(IC_RESULT(ic)) = + bitVectSetBit (OP_DEFS(IC_RESULT(ic)),ic->key); + ebb->defSet = bitVectSetBit (ebb->defSet,ic->key); + ebb->outDefs= bitVectCplAnd (ebb->outDefs,OP_DEFS(IC_RESULT(ic))); + ebb->ldefs = bitVectSetBit (ebb->ldefs,ic->key); + } + + + /* if this is an addressof instruction then */ + /* put the symbol in the address of list & */ + /* delete it from the cseSet */ + if (defic->op == ADDRESS_OF) { + addSetHead (&ebb->addrOf, IC_LEFT(ic)); + deleteItemIf(&cseSet,ifDefSymIsX,IC_LEFT(ic)); + } + } + + setToNull ((void **)&ebb->outExprs); + ebb->outExprs = cseSet; + ebb->outDefs = bitVectUnion (ebb->outDefs,ebb->defSet); + ebb->ptrsSet = bitVectUnion (ebb->ptrsSet,ebb->inPtrsSet); + return change ; +} + +/*-----------------------------------------------------------------*/ +/* cseAllBlocks - will sequentially go thru & do cse for all blocks*/ +/*-----------------------------------------------------------------*/ +int cseAllBlocks (eBBlock **ebbs,int count) +{ + int i; + int change = 0 ; + + /* if optimization turned off */ + + for (i = 0 ; i < count ;i++ ) + change += cseBBlock (ebbs[i],FALSE,ebbs,count); + + return change; +} + diff --git a/src/SDCCcse.h b/src/SDCCcse.h new file mode 100644 index 00000000..faf0b3ad --- /dev/null +++ b/src/SDCCcse.h @@ -0,0 +1,58 @@ +/*------------------------------------------------------------------------- + + SDCCcse.h - header file for Common Subexpressions + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "SDCCicode.h" + +#ifndef SDCCCSE_H +#define SDCCCSE_H 1 + +typedef struct cseDef { + + unsigned int key; + operand *sym ; /* defining symbol */ + iCode *diCode ; /* defining instruction */ + +} cseDef ; + + +cseDef *newCseDef (operand *, iCode *); +int isCseDefEqual ( void *, void *); +int pcseDef (void *, va_list ); +void algebraicOpts (iCode *); +DEFSETFUNC(ifDiCodeIsX); +int ifDiCodeIs (set *,iCode *); +DEFSETFUNC(ifDefSymIsX); +int ifDefSymIs (set *,operand *); +DEFSETFUNC(findPrevIc); +DEFSETFUNC(ifOperandsHave); +DEFSETFUNC(findCheaperOp) ; +int cseBBlock ( eBBlock *,int ,eBBlock **, int); +int cseAllBlocks (eBBlock **,int ); +void ifxOptimize (iCode *,set *,int,eBBlock *,int *,eBBlock **,int); +void unsetDefsAndUses ( iCode *) ; +void updateSpillLocation ( iCode *ic); +void setUsesDefs (operand *,bitVect *,bitVect *,bitVect **); +void replaceAllSymBySym (iCode *,operand *,operand *); +#endif diff --git a/src/SDCCdflow.c b/src/SDCCdflow.c new file mode 100644 index 00000000..1e8c50c8 --- /dev/null +++ b/src/SDCCdflow.c @@ -0,0 +1,368 @@ +/*------------------------------------------------------------------------- + + SDCCdflow.c - source file for data flow analysis and other utility + routines related to data flow. + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCloop.h" +#include "SDCCcse.h" +#include "SDCCcflow.h" +#include "SDCCdflow.h" + +/*-----------------------------------------------------------------*/ +/* ifKilledInBlock - will return 1 if the symbol is redefined in B */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifKilledInBlock) +{ + cseDef *cdp = item; + V_ARG(eBBlock *,src); + bitVect *outs ; + + /* if this is a global variable and this block + has a function call then delete it */ + if (isOperandGlobal(cdp->sym) && src->hasFcall) + return 1; + + /* if this is pointer get then it will be killed + if there is a pointer set for the same pointer + in this block */ + if (POINTER_GET(cdp->diCode) && + bitVectBitValue(src->ptrsSet, + IC_LEFT(cdp->diCode)->key)) + return 1; + + /* if assignment to iTmep then if right is defined + elsewhere kill this one */ + if (ASSIGNMENT(cdp->diCode) && + !POINTER_SET(cdp->diCode) && + IS_ITEMP(IC_RESULT(cdp->diCode)) && + IS_SYMOP(IC_RIGHT(cdp->diCode)) && + bitVectBitsInCommon(src->outDefs,OP_DEFS(IC_RIGHT(cdp->diCode)))) + return 1; + + /* if we find it in the defSet of this block */ + if (bitVectBitsInCommon(src->defSet,OP_DEFS(cdp->sym))) + return 1; + + /* if in the outdef we find a definition other than this one */ + /* to do this we make a copy of the out definitions and turn */ + /* this one off then check if there are other definitions */ + bitVectUnSetBit (outs = bitVectCopy (src->outDefs), + cdp->diCode->key); + if (bitVectBitsInCommon (outs,OP_DEFS(cdp->sym))) { + setToNull((void **) &outs); + return 1; + } + + setToNull((void **) &outs); + + /* if the operands of this one was changed in the block */ + /* then delete it */ + if (cdp->diCode && + ( (IS_SYMOP(IC_LEFT(cdp->diCode)) && + bitVectBitsInCommon (src->defSet,OP_DEFS(IC_LEFT(cdp->diCode)))) || + (IS_SYMOP(IC_RIGHT(cdp->diCode)) && + bitVectBitsInCommon (src->defSet,OP_DEFS(IC_RIGHT(cdp->diCode)))) )) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* mergeInExprs - copy the in expression if it dominates */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(mergeInExprs) +{ + eBBlock *ebp = item; + V_ARG(eBBlock *,dest); + V_ARG(int *,firstTime); + + /* if in the dominator list then */ + if (bitVectBitValue(dest->domVect,ebp->bbnum) && dest != ebp) { + /* if already present then intersect */ + if (!dest->inExprs && *firstTime) + dest->inExprs = setFromSet(ebp->outExprs); + else + dest->inExprs = intersectSets (dest->inExprs, + ebp->outExprs, + THROW_DEST); + /* copy the pointer set from the dominator */ + dest->inPtrsSet = bitVectCopy(ebp->ptrsSet); + } + else + /* delete only if killed in this block */ + deleteItemIf (&dest->inExprs,ifKilledInBlock, ebp); + + *firstTime = 0; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* mergeInDefs - merge in incoming definitions */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(mergeInDefs) +{ + eBBlock *ebp = item ; + V_ARG(eBBlock *,dest); + V_ARG(int *,firstTime); + + /* the in definition is the union of the out */ + /* of all blocks that come to this block */ + if (!dest->inDefs && *firstTime) + dest->inDefs = bitVectCopy (ebp->outDefs); + else + dest->inDefs = bitVectUnion (dest->inDefs, + ebp->outDefs) ; + + *firstTime = 0; + + return 0; + +} + +/*-----------------------------------------------------------------*/ +/* computeDataFlow - does computations for data flow accross blocks*/ +/*-----------------------------------------------------------------*/ +void computeDataFlow (eBBlock **ebbs, int count) +{ + int i; + int change = 1; + + while (change) { + + change = 0; + + /* for all blocks */ + for ( i = 0 ; i < count ; i++ ) { + + set *pred ; + set *oldOut; + int firstTime ; + eBBlock *pBlock ; + + /* if this is the entry block then continue */ + /* since entry block can never have any inExprs */ + if (ebbs[i]->noPath) + continue ; + + /* get blocks that can come to this block */ + pred = edgesTo(ebbs[i]); + + /* make a copy of the outExpressions : to be */ + /* used for iteration */ + oldOut = setFromSet(ebbs[i]->outExprs); + setToNull ((void **)&ebbs[i]->inDefs); + + /* indefitions are easy just merge them by union */ + /* these are the definitions that can possibly */ + /* reach this block */ + firstTime = 1; + applyToSet(pred,mergeInDefs,ebbs[i],&firstTime); + + + /* if none of the edges coming to this block */ + /* dominate this block then add the immediate dominator */ + /* of this block to the list of predecessors */ + for ( pBlock = setFirstItem(pred); pBlock ; + pBlock = setNextItem(pred)) { + if (bitVectBitValue(ebbs[i]->domVect,pBlock->bbnum)) + break ; + } + + /* get the immediate dominator and put it there */ + if (!pBlock) { + eBBlock *idom = immedDom(ebbs,ebbs[i]); + if (idom) + addSetHead (&pred,idom); + } + + /* figure out the incoming expressions */ + /* this is a little more complex */ + setToNull ((void **)&ebbs[i]->inExprs); + firstTime = 1; + applyToSet(pred,mergeInExprs,ebbs[i],&firstTime); + + setToNull ((void **)&pred); + + /* do cse with computeOnly flag set to TRUE */ + /* this by far the quickest way of computing*/ + cseBBlock(ebbs[i],TRUE,ebbs,count); + + /* if it change we will need to iterate */ + change += ! isSetsEqualWith(ebbs[i]->outExprs,oldOut,isCseDefEqual); + } + + if (!change) /* iterate till no change */ + break ; + } + + return ; +} + +/*-----------------------------------------------------------------*/ +/* usedBetweenPoints - used between start & end */ +/*-----------------------------------------------------------------*/ +int usedBetweenPoints ( operand *op, iCode *start, iCode *end ) +{ + iCode *lic = start; + + for (;lic != end; lic = lic->next) { + + /* if the operand is a parameter */ + /* then check for calls and return */ + /* true if there is a call */ + if (IS_PARM(op) && + ( lic->op == CALL || + lic->op == PCALL )) + if ( isParameterToCall(IC_ARGS(lic),op)) + return 1; + + if (SKIP_IC2(lic)) + continue ; + + /* if ifx then check the condition */ + if (lic->op == IFX && + IC_COND(lic)->key == op->key ) + return 1; + + if (lic->op == JUMPTABLE && + IC_JTCOND(lic)->key == op->key ) + return 1; + + if (IC_RIGHT(lic) && + IC_RIGHT(lic)->key == op->key ) + return 1; + + if (IC_LEFT(lic) && + IC_LEFT(lic)->key == op->key ) + return 1; + + /* for a pointer assignment usage */ + if (POINTER_SET(lic) && + op->key == IC_RESULT(lic)->key ) + return 1; + else + if (IC_RESULT(lic) && op->key == IC_RESULT(lic)->key) + return 0; + } + + return 0; + +} + + +/*-----------------------------------------------------------------*/ +/* usedInRemaining - returns point of usage for an operand if found*/ +/*-----------------------------------------------------------------*/ +iCode *usedInRemaining (operand *op, iCode *ic) +{ + iCode *lic = ic; + + if (!IS_SYMOP(op)) + return 0; + + for (;lic; lic = lic->next) { + + /* if the operand is a parameter */ + /* then check for calls and return */ + /* true if there is a call */ + /* if this is a global variable then + return true */ + if ( lic->op == CALL || lic->op == PCALL ) { + + if ((IS_PARM(op) && + isParameterToCall(IC_ARGS(lic),op)) || + isOperandGlobal (op)) + return lic; + } + + if (ic->op == SEND && + isOperandEqual (IC_LEFT(lic),op)) + return lic; + + if (SKIP_IC1(lic)) + continue ; + + /* if ifx then check the condition */ + if (lic->op == IFX && + isOperandEqual (IC_COND(lic),op)) + return lic; + + if (lic->op == JUMPTABLE && + isOperandEqual (IC_JTCOND(lic),op) ) + return lic; + + if (IC_RIGHT(lic) && + isOperandEqual(IC_RIGHT(lic),op)) + return lic; + + if (IC_LEFT(lic) && + isOperandEqual(IC_LEFT(lic),op) ) + return lic; + + /* for a pointer assignment usage */ + if (POINTER_SET(lic) && + isOperandEqual (op,IC_RESULT(lic))) + return lic; + else + if (IC_RESULT(lic) && isOperandEqual(IC_RESULT(lic),op)) + return NULL; + } + + return NULL; +} + + + +/*-----------------------------------------------------------------*/ +/* isDefAlive - will return true if definiton reaches a block & used */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(isDefAlive) +{ + eBBlock *ebp = item; + V_ARG(iCode *,diCode); + + if (ebp->visited) + return 0; + + ebp->visited = 1; + + /* if this definition is used in the block */ + if (bitVectBitValue(ebp->usesDefs,diCode->key)) + return 1; + + return applyToSet(ebp->succList,isDefAlive,diCode); +} + diff --git a/src/SDCCdflow.h b/src/SDCCdflow.h new file mode 100644 index 00000000..225d65e3 --- /dev/null +++ b/src/SDCCdflow.h @@ -0,0 +1,39 @@ +/*------------------------------------------------------------------------- + + SDCCdflow.h - header file for data flow analysis & utility routines + related to data flow. + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "SDCCset.h" + +#ifndef SDCCDFLOW_H +#define SDCCDFLOW_H 1 + +DEFSETFUNC(mergeInExprs); +DEFSETFUNC(ifKilledInBlock) ; +void computeDataFlow (eBBlock **, int ); +DEFSETFUNC(mergeInDefs); +DEFSETFUNC(isDefAlive); +iCode *usedInRemaining (operand *,iCode *); +int usedBetweenPoints ( operand *,iCode *,iCode *); +#endif diff --git a/src/SDCCerr.c b/src/SDCCerr.c new file mode 100644 index 00000000..29afccaf --- /dev/null +++ b/src/SDCCerr.c @@ -0,0 +1,169 @@ +/* SDCCerr.c - error handling routines */ +#include +#include +#include "SDCCglobl.h" +#include "SDCCmem.h" +#include "SDCCerr.h" + +#define ERROR 0 +#define WARNING 1 +extern FILE *lstFile; +extern int fatalError ; +extern int lineno ; +extern char *filename; +struct { + int errType ; + char *errText ; +} ErrTab [] = +{ +{ ERROR ,"error *** Duplicate symbol '%s', symbol IGNORED\n" }, +{ ERROR ,"error *** Syntax Error Declaration ingonerd\n" }, +{ ERROR ,"error *** Constant Expected Found Variable\n" }, +{ ERROR ,"error *** 'malloc' failed file '%s' for size %ld\n" }, +{ ERROR ,"error *** 'fopen' failed on file '%s'\n" }, +{ ERROR ,"error *** Internal Error Oclass invalid '%s'\n" }, +{ ERROR ,"error *** Cannot allocate variable '%s'.\n" }, +{ ERROR ,"error *** Old style C declaration. IGNORED '%s'\n" }, +{ ERROR ,"error *** Out of stack Space. '%s' not allocted\n" }, +{ ERROR ,"error *** FATAL Compiler Internal Error in file '%s' line number '%d' : %s \nContact Author with source code\n" }, +{ ERROR ,"error *** 'lvalue' required for '%s' operation .\n" }, +{ ERROR ,"error *** Creation of temp file failed\n" }, +{ ERROR ,"error *** Function expected here '%s'\n" }, +{ ERROR ,"error *** 'using', 'interrupt' or 'reentrant' must follow a function definiton .'%s'\n"}, +{ ERROR ,"error *** Absolute address & initial value both cannot be specified for\n a 'sfr','sbit' storage class, initial value ignored '%s'\n" }, +{ WARNING,"warning *** Variable in the storage class cannot be initialized.'%s'\n"}, +{ WARNING,"warning *** storage class not allowed for automatic variable '%s' in reentrant function\n" }, +{ ERROR ,"error *** absolute address not allowed for automatic var '%s' in reentrant function \n" }, +{ WARNING,"warning *** Initializer different levels of indirections\n" }, +{ ERROR ,"error *** Function name '%s' redefined \n" }, +{ ERROR ,"error *** Undefined identifier '%s'\n" }, +{ WARNING,"warning *** stack exceeds 256 bytes for function '%s'\n"}, +{ ERROR ,"error *** Array or pointer required for '%s' operation \n" }, +{ ERROR ,"error *** Array index not an integer\n" }, +{ ERROR ,"error *** Array bound Exceeded, assuming zero\n" }, +{ ERROR ,"error *** Structure/Union expected left of '.%s'\n" }, +{ ERROR ,"error *** '%s' not a structure/union member\n" }, +{ ERROR ,"error *** Pointer required\n" }, +{ ERROR ,"error *** 'unary %c': illegal operand\n" }, +{ ERROR ,"error *** convertion error: integral promotion failed\n" }, +{ ERROR ,"error *** type must be INT for bit field definition\n" }, +{ ERROR ,"error *** bit field size greater than 16 . assuming 16\n" }, +{ WARNING,"warning *** high order truncation might occur\n" }, +{ ERROR ,"error *** Attempt to assign value to a constant variable %s\n" }, +{ ERROR ,"error *** Lvalue specifies constant object\n" }, +{ ERROR ,"error *** '&' illegal operand , %s\n" }, +{ ERROR ,"error *** illegal cast (cast cannot be aggregate)\n" }, +{ ERROR ,"error *** '*' bad operand\n" }, +{ ERROR ,"error *** Argument count error, argument ignored\n" }, +{ ERROR ,"error *** Function was expecting more arguments\n" }, +{ ERROR ,"error *** Function name expected '%s'.ANSI style declaration REQUIRED\n"}, +{ ERROR ,"error *** invalid operand '%s'\n" }, +{ ERROR ,"error *** pointer + pointer invalid\n" }, +{ ERROR ,"error *** invalid operand for shift operator\n" }, +{ ERROR ,"error *** compare operand cannot be struct/union\n" }, +{ ERROR ,"error *** operand invalid for bitwise operation\n" }, +{ ERROR ,"error *** Invalid operand for '&&' or '||'\n" }, +{ WARNING,"warning *** indirections to different types %s %s \n" }, +{ ERROR ,"error *** cannot assign values to aggregates\n" }, +{ ERROR ,"error *** bit Arrays can be accessed by literal index only\n" }, +{ ERROR ,"error *** Array or Pointer to bit|sbit|sfr not allowed.'%s'\n" }, +{ ERROR ,"error *** typedef/enum '%s' duplicate.Previous definiton Ignored\n" }, +{ ERROR ,"error *** Actual Argument type different from declaration %d\n" }, +{ ERROR ,"error *** Function return value mismatch\n" }, +{ ERROR ,"error *** Function cannot return aggregate. Func body ignored\n" }, +{ ERROR ,"error *** ANSI Style declaration needed\n" }, +{ ERROR ,"error *** Label name redefined '%s'\n" }, +{ ERROR ,"error *** Label undefined '%s'\n" }, +{ ERROR ,"error *** void function returning value\n" }, +{ ERROR ,"error *** function '%s' must return value\n" }, +{ WARNING,"warning *** function return value mismatch\n" }, +{ ERROR ,"error *** 'case/default' found without 'switch'.statement ignored\n" }, +{ ERROR ,"error *** 'case' expression not constant. statement ignored\n" }, +{ ERROR ,"error *** 'break/continue' statement out of context\n" }, +{ ERROR ,"error *** nonintegral used in switch expression\n" }, +{ ERROR ,"error *** function '%s' already has body\n" }, +{ ERROR ,"error *** attempt to allocate variable of unknown size '%s'\n" }, +{ ERROR ,"error *** aggregate 'auto' variable '%s' cannot be initialized\n" }, +{ ERROR ,"error *** too many initializers\n" }, +{ ERROR ,"error *** struct/union/array '%s' :initialization needs curly braces\n"}, +{ ERROR ,"error *** non-address initialization expression\n" }, +{ ERROR ,"error *** interrupt no '%d' already has a service routine '%s'\n" }, +{ ERROR ,"error *** interrupt routine cannot have arguments, arguments ingored\n"}, +{ ERROR ,"error *** critical compiler #include file missing. \n" }, +{ ERROR ,"error *** function 'main' undefined\n" }, +{ ERROR ,"error *** 'extern' variable '%s' cannot be initialised \n" }, +{ ERROR ,"error *** Pre-Processor %s\n" }, +{ ERROR ,"error *** _dup call failed\n" }, +{ ERROR ,"error *** pointer being cast to incompatible type \n" }, +{ WARNING,"warning *** 'while' loop with 'zero' constant.loop eliminated\n" }, +{ WARNING,"warning *** %s expression has NO side effects.expr eliminated\n" }, +{ WARNING,"warning *** constant value '%s', out of range.\n" }, +{ WARNING,"warning *** comparison will either, ALWAYs succeed or ALWAYs fail\n" }, +{ ERROR ,"error *** Compiler Terminating , contact author with source\n" }, +{ WARNING,"warning *** 'auto' variable '%s' may be used before initialization at %s(%d)\n" }, +{ WARNING,"warning *** in function %s unreferenced %s : '%s'\n" }, +{ ERROR ,"error *** unknown size for operand\n" }, +{ WARNING,"warning *** '%s' 'long' not supported , declared as 'int' .\n" }, +{ WARNING,"warning *** LITERAL value being cast to '_generic' pointer\n" }, +{ ERROR ,"error *** %s '%s' address out of range\n" }, +{ ERROR ,"error *** storage class CANNOT be specified for bit variable '%s'\n" }, +{ WARNING,"warning *** extern definition for '%s' mismatches with declaration.\n" }, +{ WARNING,"warning *** Functions called via pointers must be 'reentrant' to take arguments\n" }, +{ WARNING,"warning *** type 'double' not supported assuming 'float'\n" }, +{ WARNING,"warning *** if-statement condition always false.if-statement not generated\n"}, +{ WARNING,"warning *** no 'return' statement found for function '%s'\n" }, +{ WARNING,"warning *** Pre-Processor %s\n" }, +{ WARNING,"warning *** structure '%s' passed as function argument changed to pointer\n"}, +{ ERROR ,"error *** conflict with previous definition of '%s' for attribute '%s'\n" }, +{ ERROR ,"error *** variable '%s' declared in code space must have initialiser\n" }, +{ ERROR ,"error *** operands not integral for assignment operation\n" }, +{ ERROR ,"error *** too many parameters \n" }, +{ ERROR ,"error *** to few parameters\n" }, +{ ERROR ,"error *** code not generated for '%s' due to previous errors\n"}, +{ WARNING,"warning *** type mismatch for parameter number %d\n"}, +{ ERROR ,"error *** invalid float constant '%s'\n"}, +{ ERROR ,"error *** invalid operand for '%s' operation\n"}, +{ ERROR ,"error *** switch value not an integer\n"}, +{ ERROR ,"error *** case label not an integer\n"}, +{ WARNING,"warning *** function '%s' too large for global optimization\n"}, +{ WARNING,"warning *** conditional flow changed by optimizer '%s(%d)':so said EVELYN the modified DOG\n"}, +{ WARNING,"warning *** invalid type specifier for pointer type specifier ignored\n"}, +{ WARNING,"warning *** function '%s' implicit declaration\n"}, +{ WARNING,"warning *** %s"}, +{ WARNING,"info *** %s extended by %d bytes for compiler temp(s) :in function '%s': %s \n"}, +{ WARNING,"warning *** unknown or unsupported #pragma directive '%s'\n"}, +{ WARNING,"warning *** %s shifting more than size of object changed to zero\n"}, +{ WARNING,"warning *** unknown compiler option '%s' ignored\n"}, +{ WARNING,"warning *** option '%s' no longer supported '%s' \n"}, +{ WARNING,"warning *** don't know what to do with file '%s'. file extension unsupported\n"}, +{ WARNING,"warning *** cannot compile more than one source file . file '%s' ignored\n"}, +{ WARNING,"info *** function '%s', # edges %d , # nodes %d , cyclomatic complexity %d\n"}, +{ ERROR ,"error *** dividing by ZERO\n"}, +{ ERROR ,"error *** function cannot return 'bit'\n"}, +{ ERROR ,"error *** casting from to type 'void' is illegal\n"}, +{ WARNING,"warning *** constant is out of range %s\n" }, +{ WARNING,"warning *** unreachable code %s(%d)\n"}, +{ WARNING,"warning *** non-pointer type cast to _generic pointer\n"}, +{ WARNING,"warning *** possible code generation error at line %d,\n send source to sandeep.dutta@usa.net\n"}, +{ WARNING,"warning *** pointer types incompatible \n" } +}; + +/****************************************************************************/ +/* werror - writes an error to the listing file & to standarderr */ +/****************************************************************************/ +void werror (int errNum, ... ) +{ + va_list marker; + + + if ( ErrTab[errNum].errType== ERROR ) + fatalError++ ; + + if ( lineno ) { + fprintf(stderr,"%s(%d):",filename,lineno); + } + va_start(marker,errNum); + vfprintf(stderr,ErrTab[errNum].errText,marker); + va_end( marker ); +} + diff --git a/src/SDCCerr.h b/src/SDCCerr.h new file mode 100644 index 00000000..61207652 --- /dev/null +++ b/src/SDCCerr.h @@ -0,0 +1,133 @@ +#include +/* ERROR MEssage Definition */ +#define E_DUPLICATE 0 /* Duplicate variable */ +#define E_SYNTAX_ERROR 1 /* Syntax Error */ +#define E_CONST_EXPECTED 2 /* constant expected */ +#define E_OUT_OF_MEM 3 /* malloc failed */ +#define E_FILE_OPEN_ERR 4 /* File open failed */ +#define E_INVALID_OCLASS 5 /* output class invalid */ +#define E_CANNOT_ALLOC 6 /* cannot allocate space*/ +#define E_OLD_STYLE 7 /* old style C ! allowed*/ +#define E_STACK_OUT 8 /* v r out of stack */ +#define E_INTERNAL_ERROR 9 /* unable to alloc tvar */ +#define E_LVALUE_REQUIRED 10 /* lvalue required */ +#define E_TMPFILE_FAILED 11 /* tmpfile creation failed */ +#define E_FUNCTION_EXPECTED 12 /* function expected */ +#define E_USING_ERROR 13 /* using in error */ +#define E_SFR_INIT 14 /* init error for sbit */ +#define E_INIT_IGNORED 15 /* initialiser ignored */ +#define E_AUTO_ASSUMED 16 /* sclass auto assumed */ +#define E_AUTO_ABSA 17 /* abs addr for auto var*/ +#define E_INIT_WRONG 18 /* initializer type != */ +#define E_FUNC_REDEF 19 /* func name redefined */ +#define E_ID_UNDEF 20 /* identifer undefined */ +#define W_STACK_OVERFLOW 21 /* stack overflow */ +#define E_NEED_ARRAY_PTR 22 /* array or pointer reqd*/ +#define E_IDX_NOT_INT 23 /* index not an integer */ +#define E_ARRAY_BOUND 24 /* array limit exceeded */ +#define E_STRUCT_UNION 25 /* struct,union expected*/ +#define E_NOT_MEMBER 26 /* !struct/union member */ +#define E_PTR_REQD 27 /* pointer required */ +#define E_UNARY_OP 28 /* unary operator bad op*/ +#define E_CONV_ERR 29 /* conversion error */ +#define E_INT_REQD 30 /* bit field must be int*/ +#define E_BITFLD_SIZE 31 /* bit field size > 16 */ +#define E_TRUNCATION 32 /* high order trucation */ +#define E_CODE_WRITE 33 /* trying 2 write to code */ +#define E_LVALUE_CONST 34 /* lvalue is a const */ +#define E_ILLEGAL_ADDR 35 /* address of bit */ +#define E_CAST_ILLEGAL 36 /* cast illegal */ +#define E_MULT_INTEGRAL 37 /* mult opernd must b integral */ +#define E_ARG_ERROR 38 /* argument count error*/ +#define E_ARG_COUNT 39 /* func expecting more */ +#define E_FUNC_EXPECTED 40 /* func name expected */ +#define E_PLUS_INVALID 41 /* plus invalid */ +#define E_PTR_PLUS_PTR 42 /* pointer + pointer */ +#define E_SHIFT_OP_INVALID 43 /* shft op op invalid */ +#define E_COMPARE_OP 44 /* compare operand */ +#define E_BITWISE_OP 45 /* bit op invalid op */ +#define E_ANDOR_OP 46 /* && || op invalid */ +#define E_TYPE_MISMATCH 47 /* type mismatch */ +#define E_AGGR_ASSIGN 48 /* aggr assign */ +#define E_ARRAY_DIRECT 49 /* array indexing in */ +#define E_BIT_ARRAY 50 /* bit array not allowed */ +#define E_DUPLICATE_TYPEDEF 51 /* typedef name duplicate */ +#define E_ARG_TYPE 52 /* arg type mismatch */ +#define E_RET_VALUE 53 /* return value mismatch */ +#define E_FUNC_AGGR 54 /* function returing aggr */ +#define E_FUNC_DEF 55 /* ANSI Style def neede */ +#define E_DUPLICATE_LABEL 56 /* duplicate label name */ +#define E_LABEL_UNDEF 57 /* undefined label used */ +#define E_FUNC_VOID 58 /* void func ret value */ +#define E_VOID_FUNC 59 /* func must return value */ +#define E_RETURN_MISMATCH 60 /* return value mismatch */ +#define E_CASE_CONTEXT 61 /* case stmnt without switch */ +#define E_CASE_CONSTANT 62 /* case expression ! const*/ +#define E_BREAK_CONTEXT 63 /* break statement invalid*/ +#define E_SWITCH_AGGR 64 /* non integral for switch*/ +#define E_FUNC_BODY 65 /* func has body already */ +#define E_UNKNOWN_SIZE 66 /* variable has unknown size */ +#define E_AUTO_AGGR_INIT 67 /* auto aggregates no init */ +#define E_INIT_COUNT 68 /* too many initializers */ +#define E_INIT_STRUCT 69 /* struct init wrong */ +#define E_INIT_NON_ADDR 70 /* non address xpr for init */ +#define E_INT_DEFINED 71 /* interrupt already over */ +#define E_INT_ARGS 72 /* interrupt rtn cannot have args */ +#define E_INCLUDE_MISSING 73 /* compiler include missing */ +#define E_NO_MAIN 74 /* main function undefined */ +#define E_EXTERN_INIT 75 /* extern variable initialised */ +#define E_PRE_PROC_FAILED 76 /* preprocessor failed */ +#define E_DUP_FAILED 77 /* file DUP failed */ +#define E_INCOMPAT_CAST 78 /* incompatible pointer casting */ +#define E_LOOP_ELIMINATE 79 /* loop eliminated */ +#define W_NO_SIDE_EFFECTS 80 /* expression has no side effects */ +#define E_CONST_TOO_LARGE 81 /* constant out of range */ +#define W_BAD_COMPARE 82 /* bad comparison */ +#define E_TERMINATING 83 /* compiler terminating */ +#define W_LOCAL_NOINIT 84 /* local reference before assignment */ +#define W_NO_REFERENCE 85 /* no reference to local variable */ +#define E_OP_UNKNOWN_SIZE 86 /* unknown size for operand */ +#define W_LONG_UNSUPPORTED 87 /* 'long' not supported yet */ +#define W_LITERAL_GENERIC 88 /* literal being cast to generic pointer */ +#define E_SFR_ADDR_RANGE 89 /* sfr address out of range */ +#define E_BITVAR_STORAGE 90 /* storage given for 'bit' variable */ +#define W_EXTERN_MISMATCH 91 /* extern declaration mismatches */ +#define E_NONRENT_ARGS 92 /* fptr non reentrant has args */ +#define W_DOUBLE_UNSUPPORTED 93 /* 'double' not supported yet */ +#define W_IF_NEVER_TRUE 94 /* if always false */ +#define W_FUNC_NO_RETURN 95 /* no return statement found */ +#define W_PRE_PROC_WARNING 96 /* preprocessor generated warning */ +#define W_STRUCT_AS_ARG 97 /* structure passed as argument */ +#define E_PREV_DEF_CONFLICT 98 /* previous definition conflicts with current */ +#define E_CODE_NO_INIT 99 /* vars in code space must have initializer */ +#define E_OPS_INTEGRAL 100 /* operans must be integral for certian assignments */ +#define E_TOO_MANY_PARMS 101 /* too many parameters */ +#define E_TO_FEW_PARMS 102 /* to few parameters */ +#define E_FUNC_NO_CODE 103 /* fatalError */ +#define E_TYPE_MISMATCH_PARM 104 /* type mismatch for parameter */ +#define E_INVALID_FLOAT_CONST 105 /* invalid floating point literal string */ +#define E_INVALID_OP 106 /* invalid operand for some operation */ +#define E_SWITCH_NON_INTEGER 107 /* switch value not integer */ +#define E_CASE_NON_INTEGER 108 /* case value not integer */ +#define E_FUNC_TOO_LARGE 109 /* function too large */ +#define W_CONTROL_FLOW 110 /* control flow changed due to optimization */ +#define W_PTR_TYPE_INVALID 111 /* invalid type specifier for pointer */ +#define W_IMPLICIT_FUNC 112 /* function declared implicitly */ +#define E_CONTINUE 113 /* more than one line */ +#define W_TOOMANY_SPILS 114 /* too many spils occured */ +#define W_UNKNOWN_PRAGMA 115 /* #pragma directive unsupported */ +#define W_SHIFT_CHANGED 116 /* shift changed to zero */ +#define W_UNKNOWN_OPTION 117 /* don't know the option */ +#define W_UNSUPP_OPTION 118 /* processor reset has been redifned */ +#define W_UNKNOWN_FEXT 119 /* unknown file extension */ +#define W_TOO_MANY_SRC 120 /* can only compile one .c file at a time */ +#define I_CYCLOMATIC 121 /* information message */ +#define E_DIVIDE_BY_ZERO 122 /* / 0 */ +#define E_FUNC_BIT 123 /* function cannot return bit */ +#define E_CAST_ZERO 124 /* casting to from size zero */ +#define W_CONST_RANGE 125 /* constant too large */ +#define W_CODE_UNREACH 126 /* unreachable code */ +#define W_NONPTR2_GENPTR 127 /* non pointer cast to generic pointer */ +#define W_POSSBUG 128 /* possible code generation error */ +#define W_PTR_ASSIGN 129 /* incampatible pointer assignment */ +void werror(int, ...); diff --git a/src/SDCCgen51.c b/src/SDCCgen51.c new file mode 100644 index 00000000..b7e238f8 --- /dev/null +++ b/src/SDCCgen51.c @@ -0,0 +1,7383 @@ +/*------------------------------------------------------------------------- + SDCCgen51.c - source file for code generation for 8051 + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + and - Jean-Louis VERN.jlvern@writeme.com (1999) + Bug Fixes - Wojciech Stryjewski wstryj1@tiger.lsu.edu (1999 v2.1.9a) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "SDCCglobl.h" + +#ifdef HAVE_SYS_ISA_DEFS_H +#include +#else +#ifdef HAVE_ENDIAN_H +#include +#else +#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" +#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" +#endif +#endif + +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCloop.h" +#include "SDCCcse.h" +#include "SDCCcflow.h" +#include "SDCCdflow.h" +#include "SDCClrange.h" +#include "SDCCralloc.h" +#include "SDCCgen51.h" +#include "SDCCpeeph.h" + +/* this is the down and dirty file with all kinds of +kludgy & hacky stuff. This is what it is all about +CODE GENERATION for a specific MCU . some of the +routines may be reusable, will have to see */ + +static char *zero = "#0x00"; +static char *one = "#0x01"; +static char *spname ; +static char *fReturn[] = {"dpl","dph","b","a" }; +static char *accUse[] = {"a","b"}; +short r0Pushed = 0; +short r1Pushed = 0; +short rbank = -1; +short accInUse = 0 ; +short inLine = 0; +short debugLine = 0; +short nregssaved = 0; +extern int ptrRegReq ; +extern int nRegs; +extern FILE *codeOutFile; +set *sendSet = NULL; +static void saverbank (int, iCode *,bool); +#define RESULTONSTACK(x) \ + (IC_RESULT(x) && IC_RESULT(x)->aop && \ + IC_RESULT(x)->aop->type == AOP_STK ) + +#define MOVA(x) if (strcmp(x,"a") && strcmp(x,"acc")) emitcode("mov","a,%s",x); +#define CLRC emitcode("clr","c"); + +lineNode *lineHead = NULL; +lineNode *lineCurr = NULL; + +unsigned char SLMask[] = {0xFF ,0xFE, 0xFC, 0xF8, 0xF0, +0xE0, 0xC0, 0x80, 0x00}; +unsigned char SRMask[] = {0xFF, 0x7F, 0x3F, 0x1F, 0x0F, +0x07, 0x03, 0x01, 0x00}; + +#define LSB 0 +#define MSB16 1 +#define MSB24 2 +#define MSB32 3 + +/*-----------------------------------------------------------------*/ +/* emitcode - writes the code into a file : for now it is simple */ +/*-----------------------------------------------------------------*/ +void emitcode (char *inst,char *fmt, ...) +{ + va_list ap; + char lb[MAX_INLINEASM]; + char *lbp = lb; + + va_start(ap,fmt); + + if (inst && *inst) { + if (fmt && *fmt) + sprintf(lb,"%s\t",inst); + else + sprintf(lb,"%s",inst); + vsprintf(lb+(strlen(lb)),fmt,ap); + } else + vsprintf(lb,fmt,ap); + + while (isspace(*lbp)) lbp++; + + if (lbp && *lbp) + lineCurr = (lineCurr ? + connectLine(lineCurr,newLineNode(lb)) : + (lineHead = newLineNode(lb))); + lineCurr->isInline = inLine; + lineCurr->isDebug = debugLine; + va_end(ap); +} + +/*-----------------------------------------------------------------*/ +/* getFreePtr - returns r0 or r1 whichever is free or can be pushed*/ +/*-----------------------------------------------------------------*/ +static regs *getFreePtr (iCode *ic, asmop **aopp, bool result) +{ + bool r0iu = FALSE , r1iu = FALSE; + bool r0ou = FALSE , r1ou = FALSE; + + /* the logic: if r0 & r1 used in the instruction + then we are in trouble otherwise */ + + /* first check if r0 & r1 are used by this + instruction, in which case we are in trouble */ + if ((r0iu = bitVectBitValue(ic->rUsed,R0_IDX)) && + (r1iu = bitVectBitValue(ic->rUsed,R1_IDX))) + goto endOfWorld; + + + r0ou = bitVectBitValue(ic->rMask,R0_IDX); + r1ou = bitVectBitValue(ic->rMask,R1_IDX); + + /* if no usage of r0 then return it */ + if (!r0iu && !r0ou) { + ic->rUsed = bitVectSetBit(ic->rUsed,R0_IDX); + (*aopp)->type = AOP_R0; + return (*aopp)->aopu.aop_ptr = regWithIdx(R0_IDX); + } + + /* if no usage of r1 then return it */ + if (!r1iu && !r1ou) { + ic->rUsed = bitVectSetBit(ic->rUsed,R1_IDX); + (*aopp)->type = AOP_R1; + return (*aopp)->aopu.aop_ptr = regWithIdx(R1_IDX); + } + + /* now we know they both have usage */ + /* if r0 not used in this instruction */ + if (!r0iu) { + /* push it if not already pushed */ + if (!r0Pushed) { + emitcode ("push","%s", + regWithIdx(R0_IDX)->dname); + r0Pushed++ ; + } + + ic->rUsed = bitVectSetBit(ic->rUsed,R0_IDX); + (*aopp)->type = AOP_R0; + + return (*aopp)->aopu.aop_ptr = regWithIdx(R0_IDX); + } + + /* if r1 not used then */ + + if (!r1iu) { + /* push it if not already pushed */ + if (!r1Pushed) { + emitcode ("push","%s", + regWithIdx(R1_IDX)->dname); + r1Pushed++ ; + } + + ic->rUsed = bitVectSetBit(ic->rUsed,R1_IDX); + (*aopp)->type = AOP_R1; + return regWithIdx(R1_IDX); + } + + +endOfWorld : + /* I said end of world but not quite end of world yet */ + /* if this is a result then we canpush it on the stack*/ + if (result) { + (*aopp)->type = AOP_STK; + return NULL; + } + + piCode(ic,stdout); + /* other wise this is true end of the world */ + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "getFreePtr should never reach here"); + exit(0); +} + +/*-----------------------------------------------------------------*/ +/* newAsmop - creates a new asmOp */ +/*-----------------------------------------------------------------*/ +static asmop *newAsmop (short type) +{ + asmop *aop; + + ALLOC(aop,sizeof(asmop)); + aop->type = type; + return aop; +} + +/*-----------------------------------------------------------------*/ +/* pointerCode - returns the code for a pointer type */ +/*-----------------------------------------------------------------*/ +static int pointerCode (link *etype) +{ + int p_type; + if (SPEC_OCLS(etype)->codesp ) { + p_type = CPOINTER ; + } + else + if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) + p_type = FPOINTER ; + else + if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) + p_type = PPOINTER; + else + if (SPEC_OCLS(etype) == idata ) + p_type = IPOINTER; + else + p_type = POINTER ; + return p_type; +} + +/*-----------------------------------------------------------------*/ +/* aopForSym - for a true symbol */ +/*-----------------------------------------------------------------*/ +static asmop *aopForSym (iCode *ic,symbol *sym,bool result) +{ + asmop *aop; + memmap *space= SPEC_OCLS(sym->etype); + + /* if already has one */ + if (sym->aop) + return sym->aop; + + /* assign depending on the storage class */ + /* if it is on the stack or indirectly addressable */ + /* space we need to assign either r0 or r1 to it */ + if (sym->onStack || sym->iaccess) { + sym->aop = aop = newAsmop(0); + aop->aopu.aop_ptr = getFreePtr(ic,&aop,result); + aop->size = getSize(sym->type); + + /* now assign the address of the variable to + the pointer register */ + if (aop->type != AOP_STK) { + + if (sym->onStack) { + + if ( accInUse ) + emitcode("push","acc"); + + emitcode("mov","a,_bp"); + emitcode("add","a,#0x%02x", + ((sym->stack < 0) ? + ((char)(sym->stack - nregssaved )) : + ((char)sym->stack)) & 0xff); + emitcode("mov","%s,a", + aop->aopu.aop_ptr->name); + + if ( accInUse ) + emitcode("pop","acc"); + + } else + emitcode("mov","%s,#%s", + aop->aopu.aop_ptr->name, + sym->rname); + aop->paged = space->paged; + } else + aop->aopu.aop_stk = sym->stack; + return aop; + } + + /* if in bit space */ + if (IN_BITSPACE(space)) { + sym->aop = aop = newAsmop (AOP_CRY); + aop->aopu.aop_dir = sym->rname ; + aop->size = getSize(sym->type); + return aop; + } + /* if it is in direct space */ + if (IN_DIRSPACE(space)) { + sym->aop = aop = newAsmop (AOP_DIR); + aop->aopu.aop_dir = sym->rname ; + aop->size = getSize(sym->type); + return aop; + } + + /* special case for a function */ + if (IS_FUNC(sym->type)) { + sym->aop = aop = newAsmop(AOP_IMMD); + ALLOC_ATOMIC(aop->aopu.aop_immd,strlen(sym->rname)+1); + strcpy(aop->aopu.aop_immd,sym->rname); + aop->size = 2; + return aop; + } + + /* only remaining is far space */ + /* in which case DPTR gets the address */ + sym->aop = aop = newAsmop(AOP_DPTR); + emitcode ("mov","dptr,#%s", sym->rname); + aop->size = getSize(sym->type); + + /* if it is in code space */ + if (IN_CODESPACE(space)) + aop->code = 1; + + return aop; +} + +/*-----------------------------------------------------------------*/ +/* aopForRemat - rematerialzes an object */ +/*-----------------------------------------------------------------*/ +static asmop *aopForRemat (symbol *sym) +{ + char *s = buffer; + iCode *ic = sym->rematiCode; + asmop *aop = newAsmop(AOP_IMMD); + + while (1) { + + /* if plus or minus print the right hand side */ + if (ic->op == '+' || ic->op == '-') { + sprintf(s,"0x%04x %c ",(int) operandLitValue(IC_RIGHT(ic)), + ic->op ); + s += strlen(s); + ic = OP_SYMBOL(IC_LEFT(ic))->rematiCode; + continue ; + } + + /* we reached the end */ + sprintf(s,"%s",OP_SYMBOL(IC_LEFT(ic))->rname); + break; + } + + ALLOC_ATOMIC(aop->aopu.aop_immd,strlen(buffer)+1); + strcpy(aop->aopu.aop_immd,buffer); + return aop; +} + +/*-----------------------------------------------------------------*/ +/* regsInCommon - two operands have some registers in common */ +/*-----------------------------------------------------------------*/ +bool regsInCommon (operand *op1, operand *op2) +{ + symbol *sym1, *sym2; + int i; + + /* if they have registers in common */ + if (!IS_SYMOP(op1) || !IS_SYMOP(op2)) + return FALSE ; + + sym1 = OP_SYMBOL(op1); + sym2 = OP_SYMBOL(op2); + + if (sym1->nRegs == 0 || sym2->nRegs == 0) + return FALSE ; + + for (i = 0 ; i < sym1->nRegs ; i++) { + int j; + if (!sym1->regs[i]) + continue ; + + for (j = 0 ; j < sym2->nRegs ;j++ ) { + if (!sym2->regs[j]) + continue ; + + if (sym2->regs[j] == sym1->regs[i]) + return TRUE ; + } + } + + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* operandsEqu - equivalent */ +/*-----------------------------------------------------------------*/ +bool operandsEqu ( operand *op1, operand *op2) +{ + symbol *sym1, *sym2; + + /* if they not symbols */ + if (!IS_SYMOP(op1) || !IS_SYMOP(op2)) + return FALSE; + + sym1 = OP_SYMBOL(op1); + sym2 = OP_SYMBOL(op2); + + /* if both are itemps & one is spilt + and the other is not then false */ + if (IS_ITEMP(op1) && IS_ITEMP(op2) && + sym1->isspilt != sym2->isspilt ) + return FALSE ; + + /* if they are the same */ + if (sym1 == sym2) + return TRUE ; + + if (strcmp(sym1->rname,sym2->rname) == 0) + return TRUE; + + + /* if left is a tmp & right is not */ + if (IS_ITEMP(op1) && + !IS_ITEMP(op2) && + sym1->isspilt && + (sym1->usl.spillLoc == sym2)) + return TRUE; + + if (IS_ITEMP(op2) && + !IS_ITEMP(op1) && + sym2->isspilt && + sym1->level > 0 && + (sym2->usl.spillLoc == sym1)) + return TRUE ; + + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* sameRegs - two asmops have the same registers */ +/*-----------------------------------------------------------------*/ +bool sameRegs (asmop *aop1, asmop *aop2 ) +{ + int i; + + if (aop1 == aop2) + return TRUE ; + + if (aop1->type != AOP_REG || + aop2->type != AOP_REG ) + return FALSE ; + + if (aop1->size != aop2->size ) + return FALSE ; + + for (i = 0 ; i < aop1->size ; i++ ) + if (aop1->aopu.aop_reg[i] != + aop2->aopu.aop_reg[i] ) + return FALSE ; + + return TRUE ; +} + +/*-----------------------------------------------------------------*/ +/* aopOp - allocates an asmop for an operand : */ +/*-----------------------------------------------------------------*/ +static void aopOp (operand *op, iCode *ic, bool result) +{ + asmop *aop; + symbol *sym; + int i; + + if (!op) + return ; + + /* if this a literal */ + if (IS_OP_LITERAL(op)) { + op->aop = aop = newAsmop(AOP_LIT); + aop->aopu.aop_lit = op->operand.valOperand; + aop->size = getSize(operandType(op)); + return; + } + + /* if already has a asmop then continue */ + if (op->aop) + return ; + + /* if the underlying symbol has a aop */ + if (IS_SYMOP(op) && OP_SYMBOL(op)->aop) { + op->aop = OP_SYMBOL(op)->aop; + return; + } + + /* if this is a true symbol */ + if (IS_TRUE_SYMOP(op)) { + op->aop = aopForSym(ic,OP_SYMBOL(op),result); + return ; + } + + /* this is a temporary : this has + only four choices : + a) register + b) spillocation + c) rematerialize + d) conditional + e) can be a return use only */ + + sym = OP_SYMBOL(op); + + + /* if the type is a conditional */ + if (sym->regType == REG_CND) { + aop = op->aop = sym->aop = newAsmop(AOP_CRY); + aop->size = 0; + return; + } + + /* if it is spilt then two situations + a) is rematerialize + b) has a spill location */ + if (sym->isspilt || sym->nRegs == 0) { + + /* rematerialize it NOW */ + if (sym->remat) { + sym->aop = op->aop = aop = + aopForRemat (sym); + aop->size = getSize(sym->type); + return; + } + + if (sym->accuse) { + int i; + aop = op->aop = sym->aop = newAsmop(AOP_ACC); + aop->size = getSize(sym->type); + for ( i = 0 ; i < 2 ; i++ ) + aop->aopu.aop_str[i] = accUse[i]; + return; + } + + if (sym->ruonly ) { + int i; + aop = op->aop = sym->aop = newAsmop(AOP_STR); + aop->size = getSize(sym->type); + for ( i = 0 ; i < 4 ; i++ ) + aop->aopu.aop_str[i] = fReturn[i]; + return; + } + + /* else spill location */ + sym->aop = op->aop = aop = + aopForSym(ic,sym->usl.spillLoc,result); + aop->size = getSize(sym->type); + return; + } + + /* must be in a register */ + sym->aop = op->aop = aop = newAsmop(AOP_REG); + aop->size = sym->nRegs; + for ( i = 0 ; i < sym->nRegs ;i++) + aop->aopu.aop_reg[i] = sym->regs[i]; +} + +/*-----------------------------------------------------------------*/ +/* freeAsmop - free up the asmop given to an operand */ +/*----------------------------------------------------------------*/ +static void freeAsmop (operand *op, asmop *aaop, iCode *ic, bool pop) +{ + asmop *aop ; + + if (!op) + aop = aaop; + else + aop = op->aop; + + if (!aop) + return ; + + if (aop->freed) + goto dealloc; + + aop->freed = 1; + + /* depending on the asmop type only three cases need work AOP_RO + , AOP_R1 && AOP_STK */ + switch (aop->type) { + case AOP_R0 : + if (r0Pushed ) { + if (pop) { + emitcode ("pop","ar0"); + r0Pushed--; + } + } + bitVectUnSetBit(ic->rUsed,R0_IDX); + break; + + case AOP_R1 : + if (r1Pushed ) { + if (pop) { + emitcode ("pop","ar1"); + r1Pushed--; + } + } + bitVectUnSetBit(ic->rUsed,R1_IDX); + break; + + case AOP_STK : + { + int sz = aop->size; + int stk = aop->aopu.aop_stk + aop->size; + bitVectUnSetBit(ic->rUsed,R0_IDX); + bitVectUnSetBit(ic->rUsed,R1_IDX); + + getFreePtr(ic,&aop,FALSE); + if (stk) { + emitcode ("mov","a,_bp"); + emitcode ("add","a,#0x%02x",((char)stk) & 0xff); + emitcode ("mov","%s,a",aop->aopu.aop_ptr->name); + } else + emitcode ("mov","%s,_bp",aop->aopu.aop_ptr->name); + + while (sz--) { + emitcode("pop","acc"); + emitcode("mov","@%s,a",aop->aopu.aop_ptr->name); + if (!sz) break; + emitcode("dec","%s",aop->aopu.aop_ptr->name); + } + op->aop = aop; + freeAsmop(op,NULL,ic,TRUE); + if (r0Pushed) { + emitcode("pop","ar0"); + r0Pushed--; + } + + if (r1Pushed) { + emitcode("pop","ar1"); + r1Pushed--; + } + } + } + +dealloc: + /* all other cases just dealloc */ + if (op ) { + op->aop = NULL; + if (IS_SYMOP(op)) { + OP_SYMBOL(op)->aop = NULL; + /* if the symbol has a spill */ + if (SPIL_LOC(op)) + SPIL_LOC(op)->aop = NULL; + } + } +} + +/*-----------------------------------------------------------------*/ +/* aopLiteral - string from a literal value */ +/*-----------------------------------------------------------------*/ +char *aopLiteral (value *val, int offset) +{ + char *rs; + union { + float f; + unsigned char c[4]; + } fl; + + /* if it is a float then it gets tricky */ + /* otherwise it is fairly simple */ + if (!IS_FLOAT(val->type)) { + unsigned long v = floatFromVal(val); + + v >>= (offset * 8); + sprintf(buffer,"#0x%02x",((char) v) & 0xff); + ALLOC_ATOMIC(rs,strlen(buffer)+1); + return strcpy (rs,buffer); + } + + /* it is type float */ + fl.f = (float) floatFromVal(val); +#ifdef _BIG_ENDIAN + sprintf(buffer,"#0x%02x",fl.c[3-offset]); +#else + sprintf(buffer,"#0x%02x",fl.c[offset]); +#endif + ALLOC_ATOMIC(rs,strlen(buffer)+1); + return strcpy (rs,buffer); +} + +/*-----------------------------------------------------------------*/ +/* aopGet - for fetching value of the aop */ +/*-----------------------------------------------------------------*/ +static char *aopGet (asmop *aop, int offset, bool bit16, bool dname) +{ + char *s = buffer ; + char *rs; + + /* offset is greater than + size then zero */ + if (offset > (aop->size - 1) && + aop->type != AOP_LIT) + return zero; + + /* depending on type */ + switch (aop->type) { + + case AOP_R0: + case AOP_R1: + /* if we need to increment it */ + while (offset > aop->coff) { + emitcode ("inc","%s",aop->aopu.aop_ptr->name); + aop->coff++; + } + + while (offset < aop->coff) { + emitcode("dec","%s",aop->aopu.aop_ptr->name); + aop->coff--; + } + + aop->coff = offset ; + if (aop->paged) { + emitcode("movx","a,@%s",aop->aopu.aop_ptr->name); + return (dname ? "acc" : "a"); + } + sprintf(s,"@%s",aop->aopu.aop_ptr->name); + ALLOC_ATOMIC(rs,strlen(s)+1); + strcpy(rs,s); + return rs; + + case AOP_DPTR: + while (offset > aop->coff) { + emitcode ("inc","dptr"); + aop->coff++; + } + + while (offset < aop->coff) { + emitcode("lcall","__decdptr"); + aop->coff--; + } + + aop->coff = offset; + if (aop->code) { + emitcode("clr","a"); + emitcode("movc","a,@a+dptr"); + } + else + emitcode("movx","a,@dptr"); + return (dname ? "acc" : "a"); + + + case AOP_IMMD: + if (bit16) + sprintf (s,"#(%s)",aop->aopu.aop_immd); + else + if (offset) + sprintf(s,"#(%s >> %d)", + aop->aopu.aop_immd, + offset*8); + else + sprintf(s,"#%s", + aop->aopu.aop_immd); + ALLOC_ATOMIC(rs,strlen(s)+1); + strcpy(rs,s); + return rs; + + case AOP_DIR: + if (offset) + sprintf(s,"(%s + %d)", + aop->aopu.aop_dir, + offset); + else + sprintf(s,"%s",aop->aopu.aop_dir); + ALLOC_ATOMIC(rs,strlen(s)+1); + strcpy(rs,s); + return rs; + + case AOP_REG: + if (dname) + return aop->aopu.aop_reg[offset]->dname; + else + return aop->aopu.aop_reg[offset]->name; + + case AOP_CRY: + emitcode("clr","a"); + emitcode("mov","c,%s",aop->aopu.aop_dir); + emitcode("rlc","a") ; + return (dname ? "acc" : "a"); + + case AOP_ACC: + if (!offset && dname) + return "acc"; + return aop->aopu.aop_str[offset]; + + case AOP_LIT: + return aopLiteral (aop->aopu.aop_lit,offset); + + case AOP_STR: + aop->coff = offset ; + if (strcmp(aop->aopu.aop_str[offset],"a") == 0 && + dname) + return "acc"; + + return aop->aopu.aop_str[offset]; + + } + + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "aopget got unsupported aop->type"); + exit(0); +} +/*-----------------------------------------------------------------*/ +/* aopPut - puts a string for a aop */ +/*-----------------------------------------------------------------*/ +static void aopPut (asmop *aop, char *s, int offset) +{ + char *d = buffer ; + symbol *lbl ; + + if (aop->size && offset > ( aop->size - 1)) { + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "aopPut got offset > aop->size"); + exit(0); + } + + /* will assign value to value */ + /* depending on where it is ofcourse */ + switch (aop->type) { + case AOP_DIR: + if (offset) + sprintf(d,"(%s + %d)", + aop->aopu.aop_dir,offset); + else + sprintf(d,"%s",aop->aopu.aop_dir); + + if (strcmp(d,s)) + emitcode("mov","%s,%s",d,s); + + break; + + case AOP_REG: + if (strcmp(aop->aopu.aop_reg[offset]->name,s) != 0 && + strcmp(aop->aopu.aop_reg[offset]->dname,s)!= 0){ + if (*s == '@' || + strcmp(s,"r0") == 0 || + strcmp(s,"r1") == 0 || + strcmp(s,"r2") == 0 || + strcmp(s,"r3") == 0 || + strcmp(s,"r4") == 0 || + strcmp(s,"r5") == 0 || + strcmp(s,"r6") == 0 || + strcmp(s,"r7") == 0 ) + emitcode("mov","%s,%s", + aop->aopu.aop_reg[offset]->dname,s); + else + emitcode("mov","%s,%s", + aop->aopu.aop_reg[offset]->name,s); + } + break; + + case AOP_DPTR: + if (aop->code) { + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "aopPut writting to code space"); + exit(0); + } + + while (offset > aop->coff) { + aop->coff++; + emitcode ("inc","dptr"); + } + + while (offset < aop->coff) { + aop->coff-- ; + emitcode("lcall","__decdptr"); + } + + aop->coff = offset; + + /* if not in accumulater */ + MOVA(s); + + emitcode ("movx","@dptr,a"); + break; + + case AOP_R0: + case AOP_R1: + while (offset > aop->coff) { + aop->coff++; + emitcode("inc","%s",aop->aopu.aop_ptr->name); + } + while (offset < aop->coff) { + aop->coff-- ; + emitcode ("dec","%s",aop->aopu.aop_ptr->name); + } + aop->coff = offset; + + if (aop->paged) { + MOVA(s); + emitcode("movx","@%s,a",aop->aopu.aop_ptr->name); + + } else + if (*s == '@') { + MOVA(s); + emitcode("mov","@%s,a",aop->aopu.aop_ptr->name); + } else + if (strcmp(s,"r0") == 0 || + strcmp(s,"r1") == 0 || + strcmp(s,"r2") == 0 || + strcmp(s,"r3") == 0 || + strcmp(s,"r4") == 0 || + strcmp(s,"r5") == 0 || + strcmp(s,"r6") == 0 || + strcmp(s,"r7") == 0 ) { + char buffer[10]; + sprintf(buffer,"a%s",s); + emitcode("mov","@%s,%s", + aop->aopu.aop_ptr->name,buffer); + } else + emitcode("mov","@%s,%s",aop->aopu.aop_ptr->name,s); + + break; + + case AOP_STK: + if (strcmp(s,"a") == 0) + emitcode("push","acc"); + else + emitcode("push","%s",s); + + break; + + case AOP_CRY: + /* if bit variable */ + if (!aop->aopu.aop_dir) { + emitcode("clr","a"); + emitcode("rlc","a"); + } else { + if (s == zero) + emitcode("clr","%s",aop->aopu.aop_dir); + else + if (s == one) + emitcode("setb","%s",aop->aopu.aop_dir); + else + if (!strcmp(s,"c")) + emitcode("mov","%s,c",aop->aopu.aop_dir); + else { + lbl = newiTempLabel(NULL); + + if (strcmp(s,"a")) { + MOVA(s); + } + emitcode("cjne","a,#0x01,%05d$",lbl->key+100); + emitcode("","%05d$:",lbl->key+100); + emitcode("cpl","c"); + emitcode("mov","%s,c",aop->aopu.aop_dir); + } + } + break; + + case AOP_STR: + aop->coff = offset; + if (strcmp(aop->aopu.aop_str[offset],s)) + emitcode ("mov","%s,%s",aop->aopu.aop_str[offset],s); + break; + + case AOP_ACC: + aop->coff = offset; + if (!offset && (strcmp(s,"acc") == 0)) + break; + + if (strcmp(aop->aopu.aop_str[offset],s)) + emitcode ("mov","%s,%s",aop->aopu.aop_str[offset],s); + break; + + default : + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "aopPut got unsupported aop->type"); + exit(0); + } + +} + + +#if 0 +/*-----------------------------------------------------------------*/ +/* pointToEnd :- points to the last byte of the operand */ +/*-----------------------------------------------------------------*/ +static void pointToEnd (asmop *aop) +{ + int count ; + if (!aop) + return ; + + aop->coff = count = (aop->size - 1); + switch (aop->type) { + case AOP_R0 : + case AOP_R1 : + while (count--) + emitcode("inc","%s",aop->aopu.aop_ptr->name); + break; + case AOP_DPTR : + while (count--) + emitcode("inc","dptr"); + break; + } + +} +#endif + +/*-----------------------------------------------------------------*/ +/* reAdjustPreg - points a register back to where it should */ +/*-----------------------------------------------------------------*/ +static void reAdjustPreg (asmop *aop) +{ + int size ; + + aop->coff = 0; + if ((size = aop->size) <= 1) + return ; + size-- ; + switch (aop->type) { + case AOP_R0 : + case AOP_R1 : + while (size--) + emitcode("dec","%s",aop->aopu.aop_ptr->name); + break; + case AOP_DPTR : + while (size--) + emitcode("lcall","__decdptr"); + break; + + } + +} + +#define AOP(op) op->aop +#define AOP_TYPE(op) AOP(op)->type +#define AOP_SIZE(op) AOP(op)->size +#define IS_AOP_PREG(x) (AOP(x) && (AOP_TYPE(x) == AOP_R1 || \ + AOP_TYPE(x) == AOP_R0)) + +#define AOP_NEEDSACC(x) (AOP(x) && (AOP_TYPE(x) == AOP_CRY || \ + AOP_TYPE(x) == AOP_DPTR || AOP(x)->paged)) + +#define AOP_INPREG(x) (x && (x->type == AOP_REG && \ + (x->aopu.aop_reg[0] == regWithIdx(R0_IDX) || \ + x->aopu.aop_reg[0] == regWithIdx(R1_IDX) ))) + +/*-----------------------------------------------------------------*/ +/* genNotFloat - generates not for float operations */ +/*-----------------------------------------------------------------*/ +static void genNotFloat (operand *op, operand *res) +{ + int size, offset; + char *l; + symbol *tlbl ; + + /* we will put 127 in the first byte of + the result */ + aopPut(AOP(res),"#127",0); + size = AOP_SIZE(op) - 1; + offset = 1; + + l = aopGet(op->aop,offset++,FALSE,FALSE); + MOVA(l); + + while(size--) { + emitcode("orl","a,%s", + aopGet(op->aop, + offset++,FALSE,FALSE)); + } + tlbl = newiTempLabel(NULL); + + tlbl = newiTempLabel(NULL); + aopPut(res->aop,one,1); + emitcode("jz","%05d$",(tlbl->key+100)); + aopPut(res->aop,zero,1); + emitcode("","%05d$:",(tlbl->key+100)); + + size = res->aop->size - 2; + offset = 2; + /* put zeros in the rest */ + while (size--) + aopPut(res->aop,zero,offset++); +} + +/*-----------------------------------------------------------------*/ +/* getDataSize - get the operand data size */ +/*-----------------------------------------------------------------*/ +int getDataSize(operand *op) +{ + int size; + size = AOP_SIZE(op); + if(size == 3) + /* pointer */ + size--; + return size; +} + +/*-----------------------------------------------------------------*/ +/* outAcc - output Acc */ +/*-----------------------------------------------------------------*/ +void outAcc(operand *result) +{ + int size, offset; + size = getDataSize(result); + if(size){ + aopPut(AOP(result),"a",0); + size--; + offset = 1; + /* unsigned or positive */ + while(size--){ + aopPut(AOP(result),zero,offset++); + } + } +} + +/*-----------------------------------------------------------------*/ +/* outBitC - output a bit C */ +/*-----------------------------------------------------------------*/ +void outBitC(operand *result) +{ + /* if the result is bit */ + if (AOP_TYPE(result) == AOP_CRY) + aopPut(AOP(result),"c",0); + else { + emitcode("clr","a"); + emitcode("rlc","a"); + outAcc(result); + } +} + +/*-----------------------------------------------------------------*/ +/* toBoolean - emit code for orl a,operator(sizeop) */ +/*-----------------------------------------------------------------*/ +void toBoolean(operand *oper) +{ + int size = AOP_SIZE(oper) - 1; + int offset = 1; + MOVA(aopGet(AOP(oper),0,FALSE,FALSE)); + while (size--) + emitcode("orl","a,%s",aopGet(AOP(oper),offset++,FALSE,FALSE)); +} + + +/*-----------------------------------------------------------------*/ +/* genNot - generate code for ! operation */ +/*-----------------------------------------------------------------*/ +static void genNot (iCode *ic) +{ + symbol *tlbl; + link *optype = operandType(IC_LEFT(ic)); + + /* assign asmOps to operand & result */ + aopOp (IC_LEFT(ic),ic,FALSE); + aopOp (IC_RESULT(ic),ic,TRUE); + + /* if in bit space then a special case */ + if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) { + emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir); + emitcode("cpl","c"); + outBitC(IC_RESULT(ic)); + goto release; + } + + /* if type float then do float */ + if (IS_FLOAT(optype)) { + genNotFloat(IC_LEFT(ic),IC_RESULT(ic)); + goto release; + } + + toBoolean(IC_LEFT(ic)); + + tlbl = newiTempLabel(NULL); + emitcode("cjne","a,#0x01,%05d$",tlbl->key+100); + emitcode("","%05d$:",tlbl->key+100); + outBitC(IC_RESULT(ic)); + +release: + /* release the aops */ + freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1)); + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); +} + + +/*-----------------------------------------------------------------*/ +/* genCpl - generate code for complement */ +/*-----------------------------------------------------------------*/ +static void genCpl (iCode *ic) +{ + int offset = 0; + int size ; + + + /* assign asmOps to operand & result */ + aopOp (IC_LEFT(ic),ic,FALSE); + aopOp (IC_RESULT(ic),ic,TRUE); + + /* if both are in bit space then + a special case */ + if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY && + AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) { + + emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir); + emitcode("cpl","c"); + emitcode("mov","%s,c",IC_RESULT(ic)->aop->aopu.aop_dir); + goto release; + } + + size = AOP_SIZE(IC_RESULT(ic)); + while (size--) { + char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE); + MOVA(l); + emitcode("cpl","a"); + aopPut(AOP(IC_RESULT(ic)),"a",offset++); + } + + +release: + /* release the aops */ + freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1)); + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genUminusFloat - unary minus for floating points */ +/*-----------------------------------------------------------------*/ +static void genUminusFloat(operand *op,operand *result) +{ + int size ,offset =0 ; + char *l; + /* for this we just need to flip the + first it then copy the rest in place */ + size = AOP_SIZE(op) - 1; + l = aopGet(AOP(op),3,FALSE,FALSE); + + MOVA(l); + + emitcode("cpl","acc.7"); + aopPut(AOP(result),"a",3); + + while(size--) { + aopPut(AOP(result), + aopGet(AOP(op),offset,FALSE,FALSE), + offset); + offset++; + } +} + +/*-----------------------------------------------------------------*/ +/* genUminus - unary minus code generation */ +/*-----------------------------------------------------------------*/ +static void genUminus (iCode *ic) +{ + int offset ,size ; + link *optype, *rtype; + + + /* assign asmops */ + aopOp(IC_LEFT(ic),ic,FALSE); + aopOp(IC_RESULT(ic),ic,TRUE); + + /* if both in bit space then special + case */ + if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY && + AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) { + + emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir); + emitcode("cpl","c"); + emitcode("mov","%s,c",IC_RESULT(ic)->aop->aopu.aop_dir); + goto release; + } + + optype = operandType(IC_LEFT(ic)); + rtype = operandType(IC_RESULT(ic)); + + /* if float then do float stuff */ + if (IS_FLOAT(optype)) { + genUminusFloat(IC_LEFT(ic),IC_RESULT(ic)); + goto release; + } + + /* otherwise subtract from zero */ + size = AOP_SIZE(IC_LEFT(ic)); + offset = 0 ; + CLRC ; + while(size--) { + char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE); + if (!strcmp(l,"a")) { + emitcode("cpl","a"); + emitcode("inc","a"); + } else { + emitcode("clr","a"); + emitcode("subb","a,%s",l); + } + aopPut(AOP(IC_RESULT(ic)),"a",offset++); + } + + /* if any remaining bytes in the result */ + /* we just need to propagate the sign */ + if ((size = (AOP_SIZE(IC_RESULT(ic)) - AOP_SIZE(IC_LEFT(ic))))) { + emitcode("rlc","a"); + emitcode("subb","a,acc"); + while (size--) + aopPut(AOP(IC_RESULT(ic)),"a",offset++); + } + +release: + /* release the aops */ + freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1)); + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* saveRegisters - will look for a call and save the registers */ +/*-----------------------------------------------------------------*/ +static void saveRegisters(iCode *lic) +{ + int i; + iCode *ic; + bitVect *rsave; + link *detype; + + /* look for call */ + for (ic = lic ; ic ; ic = ic->next) + if (ic->op == CALL || ic->op == PCALL) + break; + + if (!ic) { + fprintf(stderr,"found parameter push with no function call\n"); + return ; + } + + /* if the registers have been saved already then + do nothing */ + if (ic->regsSaved || (OP_SYMBOL(IC_LEFT(ic))->calleeSave)) + return ; + + /* find the registers in use at this time + and push them away to safety */ + rsave = bitVectCplAnd(bitVectCopy(ic->rMask), + ic->rUsed); + + ic->regsSaved = 1; + if (options.useXstack) { + if (bitVectBitValue(rsave,R0_IDX)) + emitcode("mov","b,r0"); + emitcode("mov","r0,%s",spname); + for (i = 0 ; i < nRegs ; i++) { + if (bitVectBitValue(rsave,i)) { + if (i == R0_IDX) + emitcode("mov","a,b"); + else + emitcode("mov","a,%s",regWithIdx(i)->name); + emitcode("movx","@r0,a"); + emitcode("inc","r0"); + } + } + emitcode("mov","%s,r0",spname); + if (bitVectBitValue(rsave,R0_IDX)) + emitcode("mov","r0,b"); + } else + for (i = 0 ; i < nRegs ; i++) { + if (bitVectBitValue(rsave,i)) + emitcode("push","%s",regWithIdx(i)->dname); + } + + detype = getSpec(operandType(IC_LEFT(ic))); + if (detype && + (SPEC_BANK(currFunc->etype) != SPEC_BANK(detype)) && + IS_ISR(currFunc->etype) && + !ic->bankSaved) + + saverbank(SPEC_BANK(detype),ic,TRUE); + +} +/*-----------------------------------------------------------------*/ +/* unsaveRegisters - pop the pushed registers */ +/*-----------------------------------------------------------------*/ +static void unsaveRegisters (iCode *ic) +{ + int i; + bitVect *rsave; + /* find the registers in use at this time + and push them away to safety */ + rsave = bitVectCplAnd(bitVectCopy(ic->rMask), + ic->rUsed); + + if (options.useXstack) { + emitcode("mov","r0,%s",spname); + for (i = nRegs ; i >= 0 ; i--) { + if (bitVectBitValue(rsave,i)) { + emitcode("dec","r0"); + emitcode("movx","a,@r0"); + if (i == R0_IDX) + emitcode("mov","b,a"); + else + emitcode("mov","%s,a",regWithIdx(i)->name); + } + + } + emitcode("mov","%s,r0",spname); + if (bitVectBitValue(rsave,R0_IDX)) + emitcode("mov","r0,b"); + } else + for (i = nRegs ; i >= 0 ; i--) { + if (bitVectBitValue(rsave,i)) + emitcode("pop","%s",regWithIdx(i)->dname); + } + +} + + +/*-----------------------------------------------------------------*/ +/* pushSide - */ +/*-----------------------------------------------------------------*/ +void pushSide(operand * oper, int size) +{ + int offset = 0; + while (size--) { + char *l = aopGet(AOP(oper),offset++,FALSE,TRUE); + if (AOP_TYPE(oper) != AOP_REG && + AOP_TYPE(oper) != AOP_DIR && + strcmp(l,"a") ) { + emitcode("mov","a,%s",l); + emitcode("push","acc"); + } else + emitcode("push","%s",l); + } +} + +/*-----------------------------------------------------------------*/ +/* assignResultValue - */ +/*-----------------------------------------------------------------*/ +void assignResultValue(operand * oper) +{ + int offset = 0; + int size = AOP_SIZE(oper); + while (size--) { + aopPut(AOP(oper),fReturn[offset],offset); + offset++; + } +} + + +/*-----------------------------------------------------------------*/ +/* genXpush - pushes onto the external stack */ +/*-----------------------------------------------------------------*/ +static void genXpush (iCode *ic) +{ + asmop *aop = newAsmop(0); + regs *r ; + int size,offset = 0; + + aopOp(IC_LEFT(ic),ic,FALSE); + r = getFreePtr(ic,&aop,FALSE); + + + emitcode("mov","%s,_spx",r->name); + + size = AOP_SIZE(IC_LEFT(ic)); + while(size--) { + + char *l = aopGet(AOP(IC_LEFT(ic)), + offset++,FALSE,FALSE); + MOVA(l); + emitcode("movx","@%s,a",r->name); + emitcode("inc","%s",r->name); + + } + + + emitcode("mov","_spx,%s",r->name); + + freeAsmop(NULL,aop,ic,TRUE); + freeAsmop(IC_LEFT(ic),NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genIpush - genrate code for pushing this gets a little complex */ +/*-----------------------------------------------------------------*/ +static void genIpush (iCode *ic) +{ + int size, offset = 0 ; + char *l; + + + /* if this is not a parm push : ie. it is spill push + and spill push is always done on the local stack */ + if (!ic->parmPush) { + + /* and the item is spilt then do nothing */ + if (OP_SYMBOL(IC_LEFT(ic))->isspilt) + return ; + + aopOp(IC_LEFT(ic),ic,FALSE); + size = AOP_SIZE(IC_LEFT(ic)); + /* push it on the stack */ + while(size--) { + l = aopGet(AOP(IC_LEFT(ic)),offset++,FALSE,TRUE); + if (*l == '#') { + MOVA(l); + l = "acc"; + } + emitcode("push","%s",l); + } + return ; + } + + /* this is a paramter push: in this case we call + the routine to find the call and save those + registers that need to be saved */ + saveRegisters(ic); + + /* if use external stack then call the external + stack pushing routine */ + if (options.useXstack) { + genXpush(ic); + return ; + } + + /* then do the push */ + aopOp(IC_LEFT(ic),ic,FALSE); + + + // pushSide(IC_LEFT(ic), AOP_SIZE(IC_LEFT(ic))); + size = AOP_SIZE(IC_LEFT(ic)); + + while (size--) { + l = aopGet(AOP(IC_LEFT(ic)),offset++,FALSE,TRUE); + if (AOP_TYPE(IC_LEFT(ic)) != AOP_REG && + AOP_TYPE(IC_LEFT(ic)) != AOP_DIR && + strcmp(l,"a") ) { + emitcode("mov","a,%s",l); + emitcode("push","acc"); + } else + emitcode("push","%s",l); + } + + freeAsmop(IC_LEFT(ic),NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genIpop - recover the registers: can happen only for spilling */ +/*-----------------------------------------------------------------*/ +static void genIpop (iCode *ic) +{ + int size,offset ; + + + /* if the temp was not pushed then */ + if (OP_SYMBOL(IC_LEFT(ic))->isspilt) + return ; + + aopOp(IC_LEFT(ic),ic,FALSE); + size = AOP_SIZE(IC_LEFT(ic)); + offset = (size-1); + while (size--) + emitcode("pop","%s",aopGet(AOP(IC_LEFT(ic)),offset--, + FALSE,TRUE)); + + freeAsmop(IC_LEFT(ic),NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* unsaverbank - restores the resgister bank from stack */ +/*-----------------------------------------------------------------*/ +static void unsaverbank (int bank,iCode *ic,bool popPsw) +{ + int i; + asmop *aop ; + regs *r = NULL; + + if (popPsw) { + if (options.useXstack) { + aop = newAsmop(0); + r = getFreePtr(ic,&aop,FALSE); + + + emitcode("mov","%s,_spx",r->name); + emitcode("movx","a,@%s",r->name); + emitcode("mov","psw,a"); + emitcode("dec","%s",r->name); + + }else + emitcode ("pop","psw"); + } + + for (i = (nRegs - 1) ; i >= 0 ;i--) { + if (options.useXstack) { + emitcode("movx","a,@%s",r->name); + emitcode("mov","(%s+%d),a", + regs8051[i].base,8*bank+regs8051[i].offset); + emitcode("dec","%s",r->name); + + } else + emitcode("pop","(%s+%d)", + regs8051[i].base,8*bank+regs8051[i].offset); + } + + if (options.useXstack) { + + emitcode("mov","_spx,%s",r->name); + freeAsmop(NULL,aop,ic,TRUE); + + } +} + +/*-----------------------------------------------------------------*/ +/* saverbank - saves an entire register bank on the stack */ +/*-----------------------------------------------------------------*/ +static void saverbank (int bank, iCode *ic, bool pushPsw) +{ + int i; + asmop *aop ; + regs *r = NULL; + + if (options.useXstack) { + + aop = newAsmop(0); + r = getFreePtr(ic,&aop,FALSE); + emitcode("mov","%s,_spx",r->name); + + } + + for (i = 0 ; i < nRegs ;i++) { + if (options.useXstack) { + emitcode("inc","%s",r->name); + emitcode("mov","a,(%s+%d)", + regs8051[i].base,8*bank+regs8051[i].offset); + emitcode("movx","@%s,a",r->name); + } else + emitcode("push","(%s+%d)", + regs8051[i].base,8*bank+regs8051[i].offset); + } + + if (pushPsw) { + if (options.useXstack) { + emitcode("mov","a,psw"); + emitcode("movx","@%s,a",r->name); + emitcode("inc","%s",r->name); + emitcode("mov","_spx,%s",r->name); + freeAsmop (NULL,aop,ic,TRUE); + + } else + emitcode("push","psw"); + + emitcode("mov","psw,#0x%02x",(bank << 3)&0x00ff); + } + ic->bankSaved = 1; + +} + +/*-----------------------------------------------------------------*/ +/* genCall - generates a call statement */ +/*-----------------------------------------------------------------*/ +static void genCall (iCode *ic) +{ + link *detype; + + /* if caller saves & we have not saved then */ + if (!ic->regsSaved) + saveRegisters(ic); + + /* if we are calling a function that is not using + the same register bank then we need to save the + destination registers on the stack */ + detype = getSpec(operandType(IC_LEFT(ic))); + if (detype && + (SPEC_BANK(currFunc->etype) != SPEC_BANK(detype)) && + IS_ISR(currFunc->etype) && + !ic->bankSaved) + + saverbank(SPEC_BANK(detype),ic,TRUE); + + /* if send set is not empty the assign */ + if (sendSet) { + iCode *sic ; + + for (sic = setFirstItem(sendSet) ; sic ; + sic = setNextItem(sendSet)) { + int size, offset = 0; + aopOp(IC_LEFT(sic),sic,FALSE); + size = AOP_SIZE(IC_LEFT(sic)); + while (size--) { + char *l = aopGet(AOP(IC_LEFT(sic)),offset, + FALSE,FALSE); + if (strcmp(l,fReturn[offset])) + emitcode("mov","%s,%s", + fReturn[offset], + l); + offset++; + } + freeAsmop (IC_LEFT(sic),NULL,sic,TRUE); + } + sendSet = NULL; + } + /* make the call */ + emitcode("lcall","%s",(OP_SYMBOL(IC_LEFT(ic))->rname[0] ? + OP_SYMBOL(IC_LEFT(ic))->rname : + OP_SYMBOL(IC_LEFT(ic))->name)); + + /* if we need assign a result value */ + if ((IS_ITEMP(IC_RESULT(ic)) && + (OP_SYMBOL(IC_RESULT(ic))->nRegs || + OP_SYMBOL(IC_RESULT(ic))->spildir )) || + IS_TRUE_SYMOP(IC_RESULT(ic)) ) { + + accInUse++; + aopOp(IC_RESULT(ic),ic,FALSE); + accInUse--; + + assignResultValue(IC_RESULT(ic)); + + freeAsmop(IC_RESULT(ic),NULL, ic,TRUE); + } + + /* adjust the stack for parameters if + required */ + if (IC_LEFT(ic)->parmBytes) { + int i; + if (IC_LEFT(ic)->parmBytes > 3) { + emitcode("mov","a,%s",spname); + emitcode("add","a,#0x%02x", (- IC_LEFT(ic)->parmBytes) & 0xff); + emitcode("mov","%s,a",spname); + } else + for ( i = 0 ; i < IC_LEFT(ic)->parmBytes ;i++) + emitcode("dec","%s",spname); + + } + + /* if register bank was saved then pop them */ + if (ic->bankSaved) + unsaverbank(SPEC_BANK(detype),ic,TRUE); + + /* if we hade saved some registers then unsave them */ + if (ic->regsSaved && !(OP_SYMBOL(IC_LEFT(ic))->calleeSave)) + unsaveRegisters (ic); + + +} + +/*-----------------------------------------------------------------*/ +/* genPcall - generates a call by pointer statement */ +/*-----------------------------------------------------------------*/ +static void genPcall (iCode *ic) +{ + link *detype; + symbol *rlbl = newiTempLabel(NULL); + + + /* if caller saves & we have not saved then */ + if (!ic->regsSaved) + saveRegisters(ic); + + /* if we are calling a function that is not using + the same register bank then we need to save the + destination registers on the stack */ + detype = getSpec(operandType(IC_LEFT(ic))); + if (detype && + IS_ISR(currFunc->etype) && + (SPEC_BANK(currFunc->etype) != SPEC_BANK(detype))) + saverbank(SPEC_BANK(detype),ic,TRUE); + + + /* push the return address on to the stack */ + emitcode("mov","a,#%05d$",(rlbl->key+100)); + emitcode("push","acc"); + emitcode("mov","a,#(%05d$ >> 8)",(rlbl->key+100)); + emitcode("push","acc"); + + /* now push the calling address */ + aopOp(IC_LEFT(ic),ic,FALSE); + + pushSide(IC_LEFT(ic), 2); + + freeAsmop(IC_LEFT(ic),NULL,ic,TRUE); + + /* if send set is not empty the assign */ + if (sendSet) { + iCode *sic ; + + for (sic = setFirstItem(sendSet) ; sic ; + sic = setNextItem(sendSet)) { + int size, offset = 0; + aopOp(IC_LEFT(sic),sic,FALSE); + size = AOP_SIZE(IC_LEFT(sic)); + while (size--) { + char *l = aopGet(AOP(IC_LEFT(sic)),offset, + FALSE,FALSE); + if (strcmp(l,fReturn[offset])) + emitcode("mov","%s,%s", + fReturn[offset], + l); + offset++; + } + freeAsmop (IC_LEFT(sic),NULL,sic,TRUE); + } + sendSet = NULL; + } + + emitcode("ret",""); + emitcode("","%05d$:",(rlbl->key+100)); + + + /* if we need assign a result value */ + if ((IS_ITEMP(IC_RESULT(ic)) && + (OP_SYMBOL(IC_RESULT(ic))->nRegs || + OP_SYMBOL(IC_RESULT(ic))->spildir)) || + IS_TRUE_SYMOP(IC_RESULT(ic)) ) { + + accInUse++; + aopOp(IC_RESULT(ic),ic,FALSE); + accInUse--; + + assignResultValue(IC_RESULT(ic)); + + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); + } + + /* adjust the stack for parameters if + required */ + if (IC_LEFT(ic)->parmBytes) { + int i; + if (IC_LEFT(ic)->parmBytes > 3) { + emitcode("mov","a,%s",spname); + emitcode("add","a,#0x%02x", (- IC_LEFT(ic)->parmBytes) & 0xff); + emitcode("mov","%s,a",spname); + } else + for ( i = 0 ; i < IC_LEFT(ic)->parmBytes ;i++) + emitcode("dec","%s",spname); + + } + + /* if register bank was saved then unsave them */ + if (detype && + (SPEC_BANK(currFunc->etype) != + SPEC_BANK(detype))) + unsaverbank(SPEC_BANK(detype),ic,TRUE); + + /* if we hade saved some registers then + unsave them */ + if (ic->regsSaved) + unsaveRegisters (ic); + +} + +/*-----------------------------------------------------------------*/ +/* resultRemat - result is rematerializable */ +/*-----------------------------------------------------------------*/ +static int resultRemat (iCode *ic) +{ + if (SKIP_IC(ic) || ic->op == IFX) + return 0; + + if (IC_RESULT(ic) && IS_ITEMP(IC_RESULT(ic))) { + symbol *sym = OP_SYMBOL(IC_RESULT(ic)); + if (sym->remat && !POINTER_SET(ic)) + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* inExcludeList - return 1 if the string is in exclude Reg list */ +/*-----------------------------------------------------------------*/ +static bool inExcludeList(char *s) +{ + int i =0; + + if (options.excludeRegs[i] && + strcasecmp(options.excludeRegs[i],"none") == 0) + return FALSE ; + + for ( i = 0 ; options.excludeRegs[i]; i++) { + if (options.excludeRegs[i] && + strcasecmp(s,options.excludeRegs[i]) == 0) + return TRUE; + } + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* genFunction - generated code for function entry */ +/*-----------------------------------------------------------------*/ +static void genFunction (iCode *ic) +{ + symbol *sym; + link *fetype; + + nregssaved = 0; + /* create the function header */ + emitcode(";","-----------------------------------------"); + emitcode(";"," function %s",(sym = OP_SYMBOL(IC_LEFT(ic)))->name); + emitcode(";","-----------------------------------------"); + + emitcode("","%s:",sym->rname); + fetype = getSpec(operandType(IC_LEFT(ic))); + + /* if critical function then turn interrupts off */ + if (SPEC_CRTCL(fetype)) + emitcode("clr","ea"); + + /* here we need to generate the equates for the + register bank if required */ + if (SPEC_BANK(fetype) != rbank) { + int i ; + + rbank = SPEC_BANK(fetype); + for ( i = 0 ; i < nRegs ; i++ ) { + if (strcmp(regs8051[i].base,"0") == 0) + emitcode("","%s = 0x%02x", + regs8051[i].dname, + 8*rbank+regs8051[i].offset); + else + emitcode ("","%s = %s + 0x%02x", + regs8051[i].dname, + regs8051[i].base, + 8*rbank+regs8051[i].offset); + } + } + + /* if this is an interrupt service routine then + save acc, b, dpl, dph */ + if (IS_ISR(sym->etype)) { + + if (!inExcludeList("acc")) + emitcode ("push","acc"); + if (!inExcludeList("b")) + emitcode ("push","b"); + if (!inExcludeList("dpl")) + emitcode ("push","dpl"); + if (!inExcludeList("dph")) + emitcode ("push","dph"); + + /* if this isr has no bank i.e. is going to + run with bank 0 , then we need to save more + registers :-) */ + if (!SPEC_BANK(sym->etype)) { + + /* if this function does not call any other + function then we can be economical and + save only those registers that are used */ + if (! sym->hasFcall) { + int i; + + /* if any registers used */ + if (sym->regsUsed) { + /* save the registers used */ + for ( i = 0 ; i < sym->regsUsed->size ; i++) { + if (bitVectBitValue(sym->regsUsed,i) || + (ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) + emitcode("push","%s",regWithIdx(i)->dname); + } + } + + } else { + /* this function has a function call cannot + determines register usage so we will have the + entire bank */ + saverbank(0,ic,FALSE); + } + } + } else { + /* if callee-save to be used for this function + then save the registers being used in this function */ + if (sym->calleeSave) { + int i; + + /* if any registers used */ + if (sym->regsUsed) { + /* save the registers used */ + for ( i = 0 ; i < sym->regsUsed->size ; i++) { + if (bitVectBitValue(sym->regsUsed,i) || + (ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) { + emitcode("push","%s",regWithIdx(i)->dname); + nregssaved++; + } + } + } + } + } + + /* set the register bank to the desired value */ + if (SPEC_BANK(sym->etype) || IS_ISR(sym->etype)) { + emitcode("push","psw"); + emitcode("mov","psw,#0x%02x",(SPEC_BANK(sym->etype) << 3)&0x00ff); + } + + if (IS_RENT(sym->etype) || options.stackAuto) { + + if (options.useXstack) { + emitcode("mov","r0,%s",spname); + emitcode("mov","a,_bp"); + emitcode("movx","@r0,a"); + emitcode("inc","%s",spname); + } + else + /* set up the stack */ + emitcode ("push","_bp"); /* save the callers stack */ + emitcode ("mov","_bp,%s",spname); + } + + /* adjust the stack for the function */ + if (sym->stack) { + + int i = sym->stack; + if (i > 256 ) + werror(W_STACK_OVERFLOW,sym->name); + + if (i > 3 && sym->recvSize < 4) { + + emitcode ("mov","a,sp"); + emitcode ("add","a,#0x%02x",((char)sym->stack & 0xff)); + emitcode ("mov","sp,a"); + + } + else + while(i--) + emitcode("inc","sp"); + } + + if (sym->xstack) { + + emitcode ("mov","a,_spx"); + emitcode ("add","a,#0x%02x",((char)sym->xstack & 0xff)); + emitcode ("mov","_spx,a"); + } + +} + +/*-----------------------------------------------------------------*/ +/* genEndFunction - generates epilogue for functions */ +/*-----------------------------------------------------------------*/ +static void genEndFunction (iCode *ic) +{ + symbol *sym = OP_SYMBOL(IC_LEFT(ic)); + + if (IS_RENT(sym->etype) || options.stackAuto) + emitcode ("mov","%s,_bp",spname); + + /* if use external stack but some variables were + added to the local stack then decrement the + local stack */ + if (options.useXstack && sym->stack) { + emitcode("mov","a,sp"); + emitcode("add","a,#0x%02x",((char)-sym->stack) & 0xff); + emitcode("mov","sp,a"); + } + + + if ((IS_RENT(sym->etype) || options.stackAuto)) { + if (options.useXstack) { + emitcode("mov","r0,%s",spname); + emitcode("movx","a,@r0"); + emitcode("mov","_bp,a"); + emitcode("dec","%s",spname); + } + else + emitcode ("pop","_bp"); + } + + /* restore the register bank */ + if (SPEC_BANK(sym->etype) || IS_ISR(sym->etype)) + emitcode ("pop","psw"); + + if (IS_ISR(sym->etype)) { + + /* now we need to restore the registers */ + /* if this isr has no bank i.e. is going to + run with bank 0 , then we need to save more + registers :-) */ + if (!SPEC_BANK(sym->etype)) { + + /* if this function does not call any other + function then we can be economical and + save only those registers that are used */ + if (! sym->hasFcall) { + int i; + + /* if any registers used */ + if (sym->regsUsed) { + /* save the registers used */ + for ( i = sym->regsUsed->size ; i >= 0 ; i--) { + if (bitVectBitValue(sym->regsUsed,i) || + (ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) + emitcode("pop","%s",regWithIdx(i)->dname); + } + } + + } else { + /* this function has a function call cannot + determines register usage so we will have the + entire bank */ + unsaverbank(0,ic,FALSE); + } + } + + if (!inExcludeList("dph")) + emitcode ("pop","dph"); + if (!inExcludeList("dpl")) + emitcode ("pop","dpl"); + if (!inExcludeList("b")) + emitcode ("pop","b"); + if (!inExcludeList("acc")) + emitcode ("pop","acc"); + + if (SPEC_CRTCL(sym->etype)) + emitcode("setb","ea"); + + /* if debug then send end of function */ +/* if (options.debug && currFunc) { */ + if (currFunc) { + debugLine = 1; + emitcode("","C$%s$%d$%d$%d ==.", + ic->filename,currFunc->lastLine, + ic->level,ic->block); + if (IS_STATIC(currFunc->etype)) + emitcode("","XF%s$%s$0$0 ==.",moduleName,currFunc->name); + else + emitcode("","XG$%s$0$0 ==.",currFunc->name); + debugLine = 0; + } + + emitcode ("reti",""); + } + else { + if (SPEC_CRTCL(sym->etype)) + emitcode("setb","ea"); + + if (sym->calleeSave) { + int i; + + /* if any registers used */ + if (sym->regsUsed) { + /* save the registers used */ + for ( i = sym->regsUsed->size ; i >= 0 ; i--) { + if (bitVectBitValue(sym->regsUsed,i) || + (ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) + emitcode("pop","%s",regWithIdx(i)->dname); + } + } + + } + + /* if debug then send end of function */ +/* if (options.debug && currFunc) { */ + if (currFunc) { + debugLine = 1; + emitcode("","C$%s$%d$%d$%d ==.", + ic->filename,currFunc->lastLine, + ic->level,ic->block); + if (IS_STATIC(currFunc->etype)) + emitcode("","XF%s$%s$0$0 ==.",moduleName,currFunc->name); + else + emitcode("","XG$%s$0$0 ==.",currFunc->name); + debugLine = 0; + } + + emitcode ("ret",""); + } + +} + +/*-----------------------------------------------------------------*/ +/* genRet - generate code for return statement */ +/*-----------------------------------------------------------------*/ +static void genRet (iCode *ic) +{ + int size,offset = 0 , pushed = 0; + + /* if we have no return value then + just generate the "ret" */ + if (!IC_LEFT(ic)) + goto jumpret; + + /* we have something to return then + move the return value into place */ + aopOp(IC_LEFT(ic),ic,FALSE); + size = AOP_SIZE(IC_LEFT(ic)); + + while (size--) { + char *l ; + if (AOP_TYPE(IC_LEFT(ic)) == AOP_DPTR) { + l = aopGet(AOP(IC_LEFT(ic)),offset++, + FALSE,TRUE); + emitcode("push","%s",l); + pushed++; + } else { + l = aopGet(AOP(IC_LEFT(ic)),offset, + FALSE,FALSE); + if (strcmp(fReturn[offset],l)) + emitcode("mov","%s,%s",fReturn[offset++],l); + } + } + + if (pushed) { + while(pushed) { + pushed--; + if (strcmp(fReturn[pushed],"a")) + emitcode("pop",fReturn[pushed]); + else + emitcode("pop","acc"); + } + } + freeAsmop (IC_LEFT(ic),NULL,ic,TRUE); + + jumpret: + /* generate a jump to the return label + if the next is not the return statement */ + if (!(ic->next && ic->next->op == LABEL && + IC_LABEL(ic->next) == returnLabel)) + + emitcode("ljmp","%05d$",(returnLabel->key+100)); + +} + +/*-----------------------------------------------------------------*/ +/* genLabel - generates a label */ +/*-----------------------------------------------------------------*/ +static void genLabel (iCode *ic) +{ + /* special case never generate */ + if (IC_LABEL(ic) == entryLabel) + return ; + + emitcode("","%05d$:",(IC_LABEL(ic)->key+100)); +} + +/*-----------------------------------------------------------------*/ +/* genGoto - generates a ljmp */ +/*-----------------------------------------------------------------*/ +static void genGoto (iCode *ic) +{ + emitcode ("ljmp","%05d$",(IC_LABEL(ic)->key+100)); +} + +/*-----------------------------------------------------------------*/ +/* genPlusIncr :- does addition with increment if possible */ +/*-----------------------------------------------------------------*/ +static bool genPlusIncr (iCode *ic) +{ + unsigned int icount ; + unsigned int size = getDataSize(IC_RESULT(ic)); + + /* will try to generate an increment */ + /* if the right side is not a literal + we cannot */ + if (AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT) + return FALSE ; + + /* if the literal value of the right hand side + is greater than 4 then it is not worth it */ + if ((icount = floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit)) > 4) + return FALSE ; + + /* if increment 16 bits in register */ + if (sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) && + (size > 1) && + (icount == 1)) { + symbol *tlbl = newiTempLabel(NULL); + emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE)); + if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG || + IS_AOP_PREG(IC_RESULT(ic))) + emitcode("cjne","%s,#0x00,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE) + ,tlbl->key+100); + else { + emitcode("clr","a"); + emitcode("cjne","a,%s,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE) + ,tlbl->key+100); + } + + emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE)); + if(size == 4){ + if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG || + IS_AOP_PREG(IC_RESULT(ic))) + emitcode("cjne","%s,#0x00,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE) + ,tlbl->key+100); + else + emitcode("cjne","a,%s,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE) + ,tlbl->key+100); + + emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE)); + if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG || + IS_AOP_PREG(IC_RESULT(ic))) + emitcode("cjne","%s,#0x00,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE) + ,tlbl->key+100); + else{ + emitcode("cjne","a,%s,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE) + ,tlbl->key+100); + } + emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE)); + } + emitcode("","%05d$:",tlbl->key+100); + return TRUE; + } + + /* if the sizes are greater than 1 then we cannot */ + if (AOP_SIZE(IC_RESULT(ic)) > 1 || + AOP_SIZE(IC_LEFT(ic)) > 1 ) + return FALSE ; + + /* we can if the aops of the left & result match or + if they are in registers and the registers are the + same */ + if (sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) { + + if (icount > 3) { + MOVA(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE)); + emitcode("add","a,#0x%02x",((char) icount) & 0xff); + aopPut(AOP(IC_RESULT(ic)),"a",0); + } else { + + while (icount--) + emitcode ("inc","%s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE)); + } + + return TRUE ; + } + + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* outBitAcc - output a bit in acc */ +/*-----------------------------------------------------------------*/ +void outBitAcc(operand *result) +{ + symbol *tlbl = newiTempLabel(NULL); + /* if the result is a bit */ + if (AOP_TYPE(result) == AOP_CRY){ + aopPut(AOP(result),"a",0); + } + else { + emitcode("jz","%05d$",tlbl->key+100); + emitcode("mov","a,%s",one); + emitcode("","%05d$:",tlbl->key+100); + outAcc(result); + } +} + +/*-----------------------------------------------------------------*/ +/* genPlusBits - generates code for addition of two bits */ +/*-----------------------------------------------------------------*/ +static void genPlusBits (iCode *ic) +{ + if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){ + symbol *lbl = newiTempLabel(NULL); + emitcode("mov","c,%s",AOP(IC_LEFT(ic))->aopu.aop_dir); + emitcode("jnb","%s,%05d$",AOP(IC_RIGHT(ic))->aopu.aop_dir,(lbl->key+100)); + emitcode("cpl","c"); + emitcode("","%05d$:",(lbl->key+100)); + outBitC(IC_RESULT(ic)); + } + else{ + emitcode("clr","a"); + emitcode("mov","c,%s",AOP(IC_LEFT(ic))->aopu.aop_dir); + emitcode("rlc","a"); + emitcode("mov","c,%s",AOP(IC_RIGHT(ic))->aopu.aop_dir); + emitcode("addc","a,#0x00"); + outAcc(IC_RESULT(ic)); + } +} + +/*-----------------------------------------------------------------*/ +/* genPlus - generates code for addition */ +/*-----------------------------------------------------------------*/ +static void genPlus (iCode *ic) +{ + int size, offset = 0; + + /* special cases :- */ + + aopOp (IC_LEFT(ic),ic,FALSE); + aopOp (IC_RIGHT(ic),ic,FALSE); + aopOp (IC_RESULT(ic),ic,TRUE); + + /* if literal, literal on the right or + if left requires ACC or right is already + in ACC */ + if ((AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) || + (AOP_NEEDSACC(IC_LEFT(ic))) || + AOP_TYPE(IC_RIGHT(ic)) == AOP_ACC ){ + operand *t = IC_RIGHT(ic); + IC_RIGHT(ic) = IC_LEFT(ic); + IC_LEFT(ic) = t; + } + + /* if both left & right are in bit + space */ + if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY && + AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) { + genPlusBits (ic); + goto release ; + } + + /* if left in bit space & right literal */ + if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY && + AOP_TYPE(IC_RIGHT(ic)) == AOP_LIT) { + emitcode("mov","c,%s",AOP(IC_LEFT(ic))->aopu.aop_dir); + /* if result in bit space */ + if(AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){ + if((unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit) != 0L) + emitcode("cpl","c"); + outBitC(IC_RESULT(ic)); + } else { + size = getDataSize(IC_RESULT(ic)); + while (size--) { + MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE)); + emitcode("addc","a,#00"); + aopPut(AOP(IC_RESULT(ic)),"a",offset++); + } + } + goto release ; + } + + /* if I can do an increment instead + of add then GOOD for ME */ + if (genPlusIncr (ic) == TRUE) + goto release; + + size = getDataSize(IC_RESULT(ic)); + + while(size--){ + if (AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) { + MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE)); + if(offset == 0) + emitcode("add","a,%s", + aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE)); + else + emitcode("addc","a,%s", + aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE)); + } else { + MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE)); + if(offset == 0) + emitcode("add","a,%s", + aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE)); + else + emitcode("addc","a,%s", + aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE)); + } + aopPut(AOP(IC_RESULT(ic)),"a",offset++); + } + + if (AOP_SIZE(IC_RESULT(ic)) == 3 && + AOP_SIZE(IC_LEFT(ic)) == 3 && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic)))) + aopPut(AOP(IC_RESULT(ic)), + aopGet(AOP(IC_LEFT(ic)),2,FALSE,FALSE), + 2); + + if (AOP_SIZE(IC_RESULT(ic)) == 3 && + AOP_SIZE(IC_RIGHT(ic)) == 3 && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) + aopPut(AOP(IC_RESULT(ic)), + aopGet(AOP(IC_RIGHT(ic)),2,FALSE,FALSE), + 2); + + if (AOP_SIZE(IC_RESULT(ic)) == 3 && + AOP_SIZE(IC_LEFT(ic)) < 3 && + AOP_SIZE(IC_RIGHT(ic)) < 3 && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))) && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) { + char buffer[5]; + sprintf(buffer,"#%d",pointerCode(getSpec(operandType(IC_LEFT(ic))))); + aopPut(AOP(IC_RESULT(ic)),buffer,2); + } +release: + freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(IC_RIGHT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genMinusDec :- does subtraction with deccrement if possible */ +/*-----------------------------------------------------------------*/ +static bool genMinusDec (iCode *ic) +{ + unsigned int icount ; + unsigned int size = getDataSize(IC_RESULT(ic)); + + /* will try to generate an increment */ + /* if the right side is not a literal + we cannot */ + if (AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT) + return FALSE ; + + /* if the literal value of the right hand side + is greater than 4 then it is not worth it */ + if ((icount = (unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit)) > 4) + return FALSE ; + + size = getDataSize(IC_RESULT(ic)); + /* if decrement 16 bits in register */ + if (sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) && + (size > 1) && + (icount == 1)) { + symbol *tlbl = newiTempLabel(NULL); + emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE)); + if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG || + IS_AOP_PREG(IC_RESULT(ic))) + emitcode("cjne","%s,#0xff,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE) + ,tlbl->key+100); + else{ + emitcode("mov","a,#0xff"); + emitcode("cjne","a,%s,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE) + ,tlbl->key+100); + } + emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE)); + if(size == 4){ + if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG || + IS_AOP_PREG(IC_RESULT(ic))) + emitcode("cjne","%s,#0xff,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE) + ,tlbl->key+100); + else{ + emitcode("cjne","a,%s,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE) + ,tlbl->key+100); + } + emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE)); + if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG || + IS_AOP_PREG(IC_RESULT(ic))) + emitcode("cjne","%s,#0xff,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE) + ,tlbl->key+100); + else{ + emitcode("cjne","a,%s,%05d$" + ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE) + ,tlbl->key+100); + } + emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE)); + } + emitcode("","%05d$:",tlbl->key+100); + return TRUE; + } + + /* if the sizes are greater than 1 then we cannot */ + if (AOP_SIZE(IC_RESULT(ic)) > 1 || + AOP_SIZE(IC_LEFT(ic)) > 1 ) + return FALSE ; + + /* we can if the aops of the left & result match or + if they are in registers and the registers are the + same */ + if (sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic)))) { + + while (icount--) + emitcode ("dec","%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE)); + + return TRUE ; + } + + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* addSign - complete with sign */ +/*-----------------------------------------------------------------*/ +static void addSign(operand *result, int offset, int sign) +{ + int size = (getDataSize(result) - offset); + if(size > 0){ + if(sign){ + emitcode("rlc","a"); + emitcode("subb","a,acc"); + while(size--) + aopPut(AOP(result),"a",offset++); + } else + while(size--) + aopPut(AOP(result),zero,offset++); + } +} + +/*-----------------------------------------------------------------*/ +/* genMinusBits - generates code for subtraction of two bits */ +/*-----------------------------------------------------------------*/ +static void genMinusBits (iCode *ic) +{ + symbol *lbl = newiTempLabel(NULL); + if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){ + emitcode("mov","c,%s",AOP(IC_LEFT(ic))->aopu.aop_dir); + emitcode("jnb","%s,%05d$",AOP(IC_RIGHT(ic))->aopu.aop_dir,(lbl->key+100)); + emitcode("cpl","c"); + emitcode("","%05d$:",(lbl->key+100)); + outBitC(IC_RESULT(ic)); + } + else{ + emitcode("mov","c,%s",AOP(IC_RIGHT(ic))->aopu.aop_dir); + emitcode("subb","a,acc"); + emitcode("jnb","%s,%05d$",AOP(IC_LEFT(ic))->aopu.aop_dir,(lbl->key+100)); + emitcode("inc","a"); + emitcode("","%05d$:",(lbl->key+100)); + aopPut(AOP(IC_RESULT(ic)),"a",0); + addSign(IC_RESULT(ic), MSB16, SPEC_USIGN(getSpec(operandType(IC_RESULT(ic))))); + } +} + +/*-----------------------------------------------------------------*/ +/* genMinus - generates code for subtraction */ +/*-----------------------------------------------------------------*/ +static void genMinus (iCode *ic) +{ + int size, offset = 0; + unsigned long lit = 0L; + + aopOp (IC_LEFT(ic),ic,FALSE); + aopOp (IC_RIGHT(ic),ic,FALSE); + aopOp (IC_RESULT(ic),ic,TRUE); + + /* special cases :- */ + /* if both left & right are in bit space */ + if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY && + AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) { + genMinusBits (ic); + goto release ; + } + + /* if I can do an decrement instead + of subtract then GOOD for ME */ + if (genMinusDec (ic) == TRUE) + goto release; + + size = getDataSize(IC_RESULT(ic)); + + if (AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT){ + CLRC; + } + else{ + lit = (unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit); + lit = - (long)lit; + } + + /* if literal, add a,#-lit, else normal subb */ + while (size--) { + MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE)); + if (AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT) + emitcode("subb","a,%s", + aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE)); + else{ + /* first add without previous c */ + if(!offset) + emitcode("add","a,#0x%02x", + (unsigned int)(lit & 0x0FFL)); + else + emitcode("addc","a,#0x%02x", + (unsigned int)((lit >> (offset*8)) & 0x0FFL)); + } + aopPut(AOP(IC_RESULT(ic)),"a",offset++); + } + + if (AOP_SIZE(IC_RESULT(ic)) == 3 && + AOP_SIZE(IC_LEFT(ic)) == 3 && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic)))) + aopPut(AOP(IC_RESULT(ic)), + aopGet(AOP(IC_LEFT(ic)),2,FALSE,FALSE), + 2); + + if (AOP_SIZE(IC_RESULT(ic)) == 3 && + AOP_SIZE(IC_RIGHT(ic)) == 3 && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) + aopPut(AOP(IC_RESULT(ic)), + aopGet(AOP(IC_RIGHT(ic)),2,FALSE,FALSE), + 2); + + if (AOP_SIZE(IC_RESULT(ic)) == 3 && + AOP_SIZE(IC_LEFT(ic)) < 3 && + AOP_SIZE(IC_RIGHT(ic)) < 3 && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))) && + !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) { + char buffer[5]; + sprintf(buffer,"#%d",pointerCode(getSpec(operandType(IC_LEFT(ic))))); + aopPut(AOP(IC_RESULT(ic)),buffer,2); + } +release: + freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(IC_RIGHT(ic),NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); +} + + +/*-----------------------------------------------------------------*/ +/* genMultbits :- multiplication of bits */ +/*-----------------------------------------------------------------*/ +static void genMultbits (operand *left, + operand *right, + operand *result) +{ + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("anl","c,%s",AOP(right)->aopu.aop_dir); + outBitC(result); +} + + +/*-----------------------------------------------------------------*/ +/* genMultOneByte : 8 bit multiplication & division */ +/*-----------------------------------------------------------------*/ +static void genMultOneByte (operand *left, + operand *right, + operand *result) +{ + link *opetype = operandType(result); + char *l ; + symbol *lbl ; + int size,offset; + + /* (if two literals, the value is computed before) */ + /* if one literal, literal on the right */ + if (AOP_TYPE(left) == AOP_LIT){ + operand *t = right; + right = left; + left = t; + } + + size = AOP_SIZE(result); + /* signed or unsigned */ + emitcode("mov","b,%s", aopGet(AOP(right),0,FALSE,FALSE)); + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + emitcode("mul","ab"); + /* if result size = 1, mul signed = mul unsigned */ + aopPut(AOP(result),"a",0); + if (size > 1){ + if (SPEC_USIGN(opetype)){ + aopPut(AOP(result),"b",1); + if (size > 2) + /* for filling the MSBs */ + emitcode("clr","a"); + } + else{ + emitcode("mov","a,b"); + + /* adjust the MSB if left or right neg */ + + /* if one literal */ + if (AOP_TYPE(right) == AOP_LIT){ + /* AND literal negative */ + if((int) floatFromVal (AOP(right)->aopu.aop_lit) < 0){ + /* adjust MSB (c==0 after mul) */ + emitcode("subb","a,%s", aopGet(AOP(left),0,FALSE,FALSE)); + } + } + else{ + lbl = newiTempLabel(NULL); + emitcode("xch","a,%s",aopGet(AOP(right),0,FALSE,FALSE)); + emitcode("cjne","a,#0x80,%05d$", (lbl->key+100)); + emitcode("","%05d$:",(lbl->key+100)); + emitcode("xch","a,%s",aopGet(AOP(right),0,FALSE,FALSE)); + lbl = newiTempLabel(NULL); + emitcode("jc","%05d$",(lbl->key+100)); + emitcode("subb","a,%s", aopGet(AOP(left),0,FALSE,FALSE)); + emitcode("","%05d$:",(lbl->key+100)); + } + + lbl = newiTempLabel(NULL); + emitcode("xch","a,%s",aopGet(AOP(left),0,FALSE,FALSE)); + emitcode("cjne","a,#0x80,%05d$", (lbl->key+100)); + emitcode("","%05d$:",(lbl->key+100)); + emitcode("xch","a,%s",aopGet(AOP(left),0,FALSE,FALSE)); + lbl = newiTempLabel(NULL); + emitcode("jc","%05d$",(lbl->key+100)); + emitcode("subb","a,%s", aopGet(AOP(right),0,FALSE,FALSE)); + emitcode("","%05d$:",(lbl->key+100)); + + aopPut(AOP(result),"a",1); + if(size > 2){ + /* get the sign */ + emitcode("rlc","a"); + emitcode("subb","a,acc"); + } + } + size -= 2; + offset = 2; + if (size > 0) + while (size--) + aopPut(AOP(result),"a",offset++); + } +} + +/*-----------------------------------------------------------------*/ +/* genMult - generates code for multiplication */ +/*-----------------------------------------------------------------*/ +static void genMult (iCode *ic) +{ + operand *left = IC_LEFT(ic); + operand *right = IC_RIGHT(ic); + operand *result= IC_RESULT(ic); + + /* assign the amsops */ + aopOp (left,ic,FALSE); + aopOp (right,ic,FALSE); + aopOp (result,ic,TRUE); + + /* special cases first */ + /* both are bits */ + if (AOP_TYPE(left) == AOP_CRY && + AOP_TYPE(right)== AOP_CRY) { + genMultbits(left,right,result); + goto release ; + } + + /* if both are of size == 1 */ + if (AOP_SIZE(left) == 1 && + AOP_SIZE(right) == 1 ) { + genMultOneByte(left,right,result); + goto release ; + } + + /* should have been converted to function call */ + assert(1) ; + +release : + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genDivbits :- division of bits */ +/*-----------------------------------------------------------------*/ +static void genDivbits (operand *left, + operand *right, + operand *result) +{ + + char *l; + + /* the result must be bit */ + emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE)); + l = aopGet(AOP(left),0,FALSE,FALSE); + + MOVA(l); + + emitcode("div","ab"); + emitcode("rrc","a"); + aopPut(AOP(result),"c",0); +} + +/*-----------------------------------------------------------------*/ +/* genDivOneByte : 8 bit division */ +/*-----------------------------------------------------------------*/ +static void genDivOneByte (operand *left, + operand *right, + operand *result) +{ + link *opetype = operandType(result); + char *l ; + symbol *lbl ; + int size,offset; + + size = AOP_SIZE(result) - 1; + offset = 1; + /* signed or unsigned */ + if (SPEC_USIGN(opetype)) { + /* unsigned is easy */ + emitcode("mov","b,%s", aopGet(AOP(right),0,FALSE,FALSE)); + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + emitcode("div","ab"); + aopPut(AOP(result),"a",0); + while (size--) + aopPut(AOP(result),zero,offset++); + return ; + } + + /* signed is a little bit more difficult */ + + /* save the signs of the operands */ + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + emitcode("xrl","a,%s",aopGet(AOP(right),0,FALSE,TRUE)); + emitcode("push","acc"); /* save it on the stack */ + + /* now sign adjust for both left & right */ + l = aopGet(AOP(right),0,FALSE,FALSE); + MOVA(l); + lbl = newiTempLabel(NULL); + emitcode("jnb","acc.7,%05d$",(lbl->key+100)); + emitcode("cpl","a"); + emitcode("inc","a"); + emitcode("","%05d$:",(lbl->key+100)); + emitcode("mov","b,a"); + + /* sign adjust left side */ + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + + lbl = newiTempLabel(NULL); + emitcode("jnb","acc.7,%05d$",(lbl->key+100)); + emitcode("cpl","a"); + emitcode("inc","a"); + emitcode("","%05d$:",(lbl->key+100)); + + /* now the division */ + emitcode("div","ab"); + /* we are interested in the lower order + only */ + emitcode("mov","b,a"); + lbl = newiTempLabel(NULL); + emitcode("pop","acc"); + /* if there was an over flow we don't + adjust the sign of the result */ + emitcode("jb","ov,%05d$",(lbl->key+100)); + emitcode("jnb","acc.7,%05d$",(lbl->key+100)); + CLRC; + emitcode("clr","a"); + emitcode("subb","a,b"); + emitcode("mov","b,a"); + emitcode("","%05d$:",(lbl->key+100)); + + /* now we are done */ + aopPut(AOP(result),"b",0); + if(size > 0){ + emitcode("mov","c,b.7"); + emitcode("subb","a,acc"); + } + while (size--) + aopPut(AOP(result),"a",offset++); + +} + +/*-----------------------------------------------------------------*/ +/* genDiv - generates code for division */ +/*-----------------------------------------------------------------*/ +static void genDiv (iCode *ic) +{ + operand *left = IC_LEFT(ic); + operand *right = IC_RIGHT(ic); + operand *result= IC_RESULT(ic); + + /* assign the amsops */ + aopOp (left,ic,FALSE); + aopOp (right,ic,FALSE); + aopOp (result,ic,TRUE); + + /* special cases first */ + /* both are bits */ + if (AOP_TYPE(left) == AOP_CRY && + AOP_TYPE(right)== AOP_CRY) { + genDivbits(left,right,result); + goto release ; + } + + /* if both are of size == 1 */ + if (AOP_SIZE(left) == 1 && + AOP_SIZE(right) == 1 ) { + genDivOneByte(left,right,result); + goto release ; + } + + /* should have been converted to function call */ + assert(1); +release : + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genModbits :- modulus of bits */ +/*-----------------------------------------------------------------*/ +static void genModbits (operand *left, + operand *right, + operand *result) +{ + + char *l; + + /* the result must be bit */ + emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE)); + l = aopGet(AOP(left),0,FALSE,FALSE); + + MOVA(l); + + emitcode("div","ab"); + emitcode("mov","a,b"); + emitcode("rrc","a"); + aopPut(AOP(result),"c",0); +} + +/*-----------------------------------------------------------------*/ +/* genModOneByte : 8 bit modulus */ +/*-----------------------------------------------------------------*/ +static void genModOneByte (operand *left, + operand *right, + operand *result) +{ + link *opetype = operandType(result); + char *l ; + symbol *lbl ; + + /* signed or unsigned */ + if (SPEC_USIGN(opetype)) { + /* unsigned is easy */ + emitcode("mov","b,%s", aopGet(AOP(right),0,FALSE,FALSE)); + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + emitcode("div","ab"); + aopPut(AOP(result),"b",0); + return ; + } + + /* signed is a little bit more difficult */ + + /* save the signs of the operands */ + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + + emitcode("xrl","a,%s",aopGet(AOP(right),0,FALSE,FALSE)); + emitcode("push","acc"); /* save it on the stack */ + + /* now sign adjust for both left & right */ + l = aopGet(AOP(right),0,FALSE,FALSE); + MOVA(l); + + lbl = newiTempLabel(NULL); + emitcode("jnb","acc.7,%05d$",(lbl->key+100)); + emitcode("cpl","a"); + emitcode("inc","a"); + emitcode("","%05d$:",(lbl->key+100)); + emitcode("mov","b,a"); + + /* sign adjust left side */ + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + + lbl = newiTempLabel(NULL); + emitcode("jnb","acc.7,%05d$",(lbl->key+100)); + emitcode("cpl","a"); + emitcode("inc","a"); + emitcode("","%05d$:",(lbl->key+100)); + + /* now the multiplication */ + emitcode("div","ab"); + /* we are interested in the lower order + only */ + lbl = newiTempLabel(NULL); + emitcode("pop","acc"); + /* if there was an over flow we don't + adjust the sign of the result */ + emitcode("jb","ov,%05d$",(lbl->key+100)); + emitcode("jnb","acc.7,%05d$",(lbl->key+100)); + CLRC ; + emitcode("clr","a"); + emitcode("subb","a,b"); + emitcode("mov","b,a"); + emitcode("","%05d$:",(lbl->key+100)); + + /* now we are done */ + aopPut(AOP(result),"b",0); + +} + +/*-----------------------------------------------------------------*/ +/* genMod - generates code for division */ +/*-----------------------------------------------------------------*/ +static void genMod (iCode *ic) +{ + operand *left = IC_LEFT(ic); + operand *right = IC_RIGHT(ic); + operand *result= IC_RESULT(ic); + + /* assign the amsops */ + aopOp (left,ic,FALSE); + aopOp (right,ic,FALSE); + aopOp (result,ic,TRUE); + + /* special cases first */ + /* both are bits */ + if (AOP_TYPE(left) == AOP_CRY && + AOP_TYPE(right)== AOP_CRY) { + genModbits(left,right,result); + goto release ; + } + + /* if both are of size == 1 */ + if (AOP_SIZE(left) == 1 && + AOP_SIZE(right) == 1 ) { + genModOneByte(left,right,result); + goto release ; + } + + /* should have been converted to function call */ + assert(1); + +release : + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genIfxJump :- will create a jump depending on the ifx */ +/*-----------------------------------------------------------------*/ +static void genIfxJump (iCode *ic, char *jval) +{ + symbol *jlbl ; + symbol *tlbl = newiTempLabel(NULL); + char *inst; + + /* if true label then we jump if condition + supplied is true */ + if ( IC_TRUE(ic) ) { + jlbl = IC_TRUE(ic); + inst = ((strcmp(jval,"a") == 0 ? "jz" : + (strcmp(jval,"c") == 0 ? "jnc" : "jnb" ))); + } + else { + /* false label is present */ + jlbl = IC_FALSE(ic) ; + inst = ((strcmp(jval,"a") == 0 ? "jnz" : + (strcmp(jval,"c") == 0 ? "jc" : "jb" ))); + } + if (strcmp(inst,"jb") == 0 || strcmp(inst,"jnb") == 0) + emitcode(inst,"%s,%05d$",jval,(tlbl->key+100)); + else + emitcode(inst,"%05d$",tlbl->key+100); + emitcode("ljmp","%05d$",jlbl->key+100); + emitcode("","%05d$:",tlbl->key+100); + + /* mark the icode as generated */ + ic->generated = 1; +} + +/*-----------------------------------------------------------------*/ +/* genCmp :- greater or less than comparison */ +/*-----------------------------------------------------------------*/ +static void genCmp (operand *left,operand *right, + operand *result, iCode *ifx, int sign) +{ + int size, offset = 0 ; + unsigned long lit = 0L; + + /* if left & right are bit variables */ + if (AOP_TYPE(left) == AOP_CRY && + AOP_TYPE(right) == AOP_CRY ) { + emitcode("mov","c,%s",AOP(right)->aopu.aop_dir); + emitcode("anl","c,/%s",AOP(left)->aopu.aop_dir); + } else { + /* subtract right from left if at the + end the carry flag is set then we know that + left is greater than right */ + size = max(AOP_SIZE(left),AOP_SIZE(right)); + + /* if unsigned char cmp with lit, do cjne left,#right,zz */ + if((size == 1) && !sign && + (AOP_TYPE(right) == AOP_LIT && AOP_TYPE(left) != AOP_DIR )){ + symbol *lbl = newiTempLabel(NULL); + emitcode("cjne","%s,%s,%05d$", + aopGet(AOP(left),offset,FALSE,FALSE), + aopGet(AOP(right),offset,FALSE,FALSE), + lbl->key+100); + emitcode("","%05d$:",lbl->key+100); + } else { + if(AOP_TYPE(right) == AOP_LIT){ + lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit); + /* optimize if(x < 0) or if(x >= 0) */ + if(lit == 0L){ + if(!sign){ + CLRC; + } + else{ + MOVA(aopGet(AOP(left),AOP_SIZE(left)-1,FALSE,FALSE)); + if(!(AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) && ifx){ + genIfxJump (ifx,"acc.7"); + return; + } + else + emitcode("rlc","a"); + } + goto release; + } + } + CLRC; + while (size--) { + MOVA(aopGet(AOP(left),offset,FALSE,FALSE)); + if (sign && size == 0) { + emitcode("xrl","a,#0x80"); + if (AOP_TYPE(right) == AOP_LIT){ + unsigned long lit = (unsigned long) + floatFromVal(AOP(right)->aopu.aop_lit); + emitcode("subb","a,#0x%02x", + 0x80 ^ (unsigned int)((lit >> (offset*8)) & 0x0FFL)); + } else { + emitcode("mov","b,%s",aopGet(AOP(right),offset++,FALSE,FALSE)); + emitcode("xrl","b,#0x80"); + emitcode("subb","a,b"); + } + } else + emitcode("subb","a,%s",aopGet(AOP(right),offset++,FALSE,FALSE)); + } + } + } + +release: + if (AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) { + outBitC(result); + } else { + /* if the result is used in the next + ifx conditional branch then generate + code a little differently */ + if (ifx ) + genIfxJump (ifx,"c"); + else + outBitC(result); + /* leave the result in acc */ + } +} + +/*-----------------------------------------------------------------*/ +/* genCmpGt :- greater than comparison */ +/*-----------------------------------------------------------------*/ +static void genCmpGt (iCode *ic, iCode *ifx) +{ + operand *left, *right, *result; + link *letype , *retype; + int sign ; + + left = IC_LEFT(ic); + right= IC_RIGHT(ic); + result = IC_RESULT(ic); + + letype = getSpec(operandType(left)); + retype =getSpec(operandType(right)); + sign = !(SPEC_USIGN(letype) | SPEC_USIGN(retype)); + /* assign the amsops */ + aopOp (left,ic,FALSE); + aopOp (right,ic,FALSE); + aopOp (result,ic,TRUE); + + genCmp(right, left, result, ifx, sign); + + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genCmpLt - less than comparisons */ +/*-----------------------------------------------------------------*/ +static void genCmpLt (iCode *ic, iCode *ifx) +{ + operand *left, *right, *result; + link *letype , *retype; + int sign ; + + left = IC_LEFT(ic); + right= IC_RIGHT(ic); + result = IC_RESULT(ic); + + letype = getSpec(operandType(left)); + retype =getSpec(operandType(right)); + sign = !(SPEC_USIGN(letype) | SPEC_USIGN(retype)); + + /* assign the amsops */ + aopOp (left,ic,FALSE); + aopOp (right,ic,FALSE); + aopOp (result,ic,TRUE); + + genCmp(left, right, result, ifx, sign); + + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* gencjneshort - compare and jump if not equal */ +/*-----------------------------------------------------------------*/ +static void gencjneshort(operand *left, operand *right, symbol *lbl) +{ + int size = max(AOP_SIZE(left),AOP_SIZE(right)); + int offset = 0; + unsigned long lit = 0L; + + /* if the left side is a literal or + if the right is in a pointer register and left + is not */ + if ((AOP_TYPE(left) == AOP_LIT) || + (IS_AOP_PREG(right) && !IS_AOP_PREG(left))) { + operand *t = right; + right = left; + left = t; + } + if(AOP_TYPE(right) == AOP_LIT) + lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit); + + /* if the right side is a literal then anything goes */ + if (AOP_TYPE(right) == AOP_LIT && + AOP_TYPE(left) != AOP_DIR ) { + while (size--) { + emitcode("cjne","%s,%s,%05d$", + aopGet(AOP(left),offset,FALSE,FALSE), + aopGet(AOP(right),offset,FALSE,FALSE), + lbl->key+100); + offset++; + } + } + + /* if the right side is in a register or in direct space or + if the left is a pointer register & right is not */ + else if (AOP_TYPE(right) == AOP_REG || + AOP_TYPE(right) == AOP_DIR || + (AOP_TYPE(left) == AOP_DIR && AOP_TYPE(right) == AOP_LIT) || + (IS_AOP_PREG(left) && !IS_AOP_PREG(right))) { + while (size--) { + MOVA(aopGet(AOP(left),offset,FALSE,FALSE)); + if((AOP_TYPE(left) == AOP_DIR && AOP_TYPE(right) == AOP_LIT) && + ((unsigned int)((lit >> (offset*8)) & 0x0FFL) == 0)) + emitcode("jnz","%05d$",lbl->key+100); + else + emitcode("cjne","a,%s,%05d$", + aopGet(AOP(right),offset,FALSE,TRUE), + lbl->key+100); + offset++; + } + } else { + /* right is a pointer reg need both a & b */ + while(size--) { + char *l = aopGet(AOP(left),offset,FALSE,FALSE); + if(strcmp(l,"b")) + emitcode("mov","b,%s",l); + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("cjne","a,b,%05d$",lbl->key+100); + offset++; + } + } +} + +/*-----------------------------------------------------------------*/ +/* gencjne - compare and jump if not equal */ +/*-----------------------------------------------------------------*/ +static void gencjne(operand *left, operand *right, symbol *lbl) +{ + symbol *tlbl = newiTempLabel(NULL); + + gencjneshort(left, right, lbl); + + emitcode("mov","a,%s",one); + emitcode("sjmp","%05d$",tlbl->key+100); + emitcode("","%05d$:",lbl->key+100); + emitcode("clr","a"); + emitcode("","%05d$:",tlbl->key+100); +} + +/*-----------------------------------------------------------------*/ +/* genCmpEq - generates code for equal to */ +/*-----------------------------------------------------------------*/ +static void genCmpEq (iCode *ic, iCode *ifx) +{ + operand *left, *right, *result; + + aopOp((left=IC_LEFT(ic)),ic,FALSE); + aopOp((right=IC_RIGHT(ic)),ic,FALSE); + aopOp((result=IC_RESULT(ic)),ic,TRUE); + + /* if literal, literal on the right or + if the right is in a pointer register and left + is not */ + if ((AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) || + (IS_AOP_PREG(right) && !IS_AOP_PREG(left))) { + operand *t = IC_RIGHT(ic); + IC_RIGHT(ic) = IC_LEFT(ic); + IC_LEFT(ic) = t; + } + + if(ifx && !AOP_SIZE(result)){ + symbol *tlbl; + /* if they are both bit variables */ + if (AOP_TYPE(left) == AOP_CRY && + ((AOP_TYPE(right) == AOP_CRY) || (AOP_TYPE(right) == AOP_LIT))) { + if(AOP_TYPE(right) == AOP_LIT){ + unsigned long lit = (unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit); + if(lit == 0L){ + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("cpl","c"); + } else if(lit == 1L) { + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + } else { + emitcode("clr","c"); + } + /* AOP_TYPE(right) == AOP_CRY */ + } else { + symbol *lbl = newiTempLabel(NULL); + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("jb","%s,%05d$",AOP(right)->aopu.aop_dir,(lbl->key+100)); + emitcode("cpl","c"); + emitcode("","%05d$:",(lbl->key+100)); + } + /* if true label then we jump if condition + supplied is true */ + tlbl = newiTempLabel(NULL); + if ( IC_TRUE(ifx) ) { + emitcode("jnc","%05d$",tlbl->key+100); + emitcode("ljmp","%05d$",IC_TRUE(ifx)->key+100); + } else { + emitcode("jc","%05d$",tlbl->key+100); + emitcode("ljmp","%05d$",IC_FALSE(ifx)->key+100); + } + emitcode("","%05d$:",tlbl->key+100); + } else { + tlbl = newiTempLabel(NULL); + gencjneshort(left, right, tlbl); + if ( IC_TRUE(ifx) ) { + emitcode("ljmp","%05d$",IC_TRUE(ifx)->key+100); + emitcode("","%05d$:",tlbl->key+100); + } else { + symbol *lbl = newiTempLabel(NULL); + emitcode("sjmp","%05d$",lbl->key+100); + emitcode("","%05d$:",tlbl->key+100); + emitcode("ljmp","%05d$",IC_FALSE(ifx)->key+100); + emitcode("","%05d$:",lbl->key+100); + } + } + /* mark the icode as generated */ + ifx->generated = 1; + goto release ; + } + + /* if they are both bit variables */ + if (AOP_TYPE(left) == AOP_CRY && + ((AOP_TYPE(right) == AOP_CRY) || (AOP_TYPE(right) == AOP_LIT))) { + if(AOP_TYPE(right) == AOP_LIT){ + unsigned long lit = (unsigned long)floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit); + if(lit == 0L){ + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("cpl","c"); + } else if(lit == 1L) { + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + } else { + emitcode("clr","c"); + } + /* AOP_TYPE(right) == AOP_CRY */ + } else { + symbol *lbl = newiTempLabel(NULL); + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("jb","%s,%05d$",AOP(right)->aopu.aop_dir,(lbl->key+100)); + emitcode("cpl","c"); + emitcode("","%05d$:",(lbl->key+100)); + } + /* c = 1 if egal */ + if (AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)){ + outBitC(result); + goto release ; + } + if (ifx) { + genIfxJump (ifx,"c"); + goto release ; + } + /* if the result is used in an arithmetic operation + then put the result in place */ + outBitC(result); + } else { + gencjne(left,right,newiTempLabel(NULL)); + if (AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) { + aopPut(AOP(result),"a",0); + goto release ; + } + if (ifx) { + genIfxJump (ifx,"a"); + goto release ; + } + /* if the result is used in an arithmetic operation + then put the result in place */ + if (AOP_TYPE(result) != AOP_CRY) + outAcc(result); + /* leave the result in acc */ + } + +release: + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* ifxForOp - returns the icode containing the ifx for operand */ +/*-----------------------------------------------------------------*/ +static iCode *ifxForOp ( operand *op, iCode *ic ) +{ + /* if true symbol then needs to be assigned */ + if (IS_TRUE_SYMOP(op)) + return NULL ; + + /* if this has register type condition and + the next instruction is ifx with the same operand + and live to of the operand is upto the ifx only then */ + if (ic->next && + ic->next->op == IFX && + IC_COND(ic->next)->key == op->key && + OP_SYMBOL(op)->liveTo <= ic->next->seq ) + return ic->next; + + return NULL; +} +/*-----------------------------------------------------------------*/ +/* genAndOp - for && operation */ +/*-----------------------------------------------------------------*/ +static void genAndOp (iCode *ic) +{ + operand *left,*right, *result; + symbol *tlbl; + + /* note here that && operations that are in an + if statement are taken away by backPatchLabels + only those used in arthmetic operations remain */ + aopOp((left=IC_LEFT(ic)),ic,FALSE); + aopOp((right=IC_RIGHT(ic)),ic,FALSE); + aopOp((result=IC_RESULT(ic)),ic,FALSE); + + /* if both are bit variables */ + if (AOP_TYPE(left) == AOP_CRY && + AOP_TYPE(right) == AOP_CRY ) { + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("anl","c,%s",AOP(right)->aopu.aop_dir); + outBitC(result); + } else { + tlbl = newiTempLabel(NULL); + toBoolean(left); + emitcode("jz","%05d$",tlbl->key+100); + toBoolean(right); + emitcode("","%05d$:",tlbl->key+100); + outBitAcc(result); + } + + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + + +/*-----------------------------------------------------------------*/ +/* genOrOp - for || operation */ +/*-----------------------------------------------------------------*/ +static void genOrOp (iCode *ic) +{ + operand *left,*right, *result; + symbol *tlbl; + + /* note here that || operations that are in an + if statement are taken away by backPatchLabels + only those used in arthmetic operations remain */ + aopOp((left=IC_LEFT(ic)),ic,FALSE); + aopOp((right=IC_RIGHT(ic)),ic,FALSE); + aopOp((result=IC_RESULT(ic)),ic,FALSE); + + /* if both are bit variables */ + if (AOP_TYPE(left) == AOP_CRY && + AOP_TYPE(right) == AOP_CRY ) { + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("orl","c,%s",AOP(right)->aopu.aop_dir); + outBitC(result); + } else { + tlbl = newiTempLabel(NULL); + toBoolean(left); + emitcode("jnz","%05d$",tlbl->key+100); + toBoolean(right); + emitcode("","%05d$:",tlbl->key+100); + outBitAcc(result); + } + + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* isLiteralBit - test if lit == 2^n */ +/*-----------------------------------------------------------------*/ +int isLiteralBit(unsigned long lit) +{ + unsigned long pw[32] = {1L,2L,4L,8L,16L,32L,64L,128L, + 0x100L,0x200L,0x400L,0x800L, + 0x1000L,0x2000L,0x4000L,0x8000L, + 0x10000L,0x20000L,0x40000L,0x80000L, + 0x100000L,0x200000L,0x400000L,0x800000L, + 0x1000000L,0x2000000L,0x4000000L,0x8000000L, + 0x10000000L,0x20000000L,0x40000000L,0x80000000L}; + int idx; + + for(idx = 0; idx < 32; idx++) + if(lit == pw[idx]) + return idx+1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* continueIfTrue - */ +/*-----------------------------------------------------------------*/ +static void continueIfTrue (iCode *ic) +{ + if(IC_TRUE(ic)) + emitcode("ljmp","%05d$",IC_TRUE(ic)->key+100); + ic->generated = 1; +} + +/*-----------------------------------------------------------------*/ +/* jmpIfTrue - */ +/*-----------------------------------------------------------------*/ +static void jumpIfTrue (iCode *ic) +{ + if(!IC_TRUE(ic)) + emitcode("ljmp","%05d$",IC_FALSE(ic)->key+100); + ic->generated = 1; +} + +/*-----------------------------------------------------------------*/ +/* jmpTrueOrFalse - */ +/*-----------------------------------------------------------------*/ +static void jmpTrueOrFalse (iCode *ic, symbol *tlbl) +{ + // ugly but optimized by peephole + if(IC_TRUE(ic)){ + symbol *nlbl = newiTempLabel(NULL); + emitcode("sjmp","%05d$",nlbl->key+100); + emitcode("","%05d$:",tlbl->key+100); + emitcode("ljmp","%05d$",IC_TRUE(ic)->key+100); + emitcode("","%05d$:",nlbl->key+100); + } + else{ + emitcode("ljmp","%05d$",IC_FALSE(ic)->key+100); + emitcode("","%05d$:",tlbl->key+100); + } + ic->generated = 1; +} + +/*-----------------------------------------------------------------*/ +/* genAnd - code for and */ +/*-----------------------------------------------------------------*/ +static void genAnd (iCode *ic, iCode *ifx) +{ + operand *left, *right, *result; + int size, offset=0; + unsigned long lit = 0L; + int bytelit = 0; + char buffer[10]; + + aopOp((left = IC_LEFT(ic)),ic,FALSE); + aopOp((right= IC_RIGHT(ic)),ic,FALSE); + aopOp((result=IC_RESULT(ic)),ic,TRUE); + +#ifdef DEBUG_TYPE + emitcode("","; Type res[%d] = l[%d]&r[%d]", + AOP_TYPE(result), + AOP_TYPE(left), AOP_TYPE(right)); + emitcode("","; Size res[%d] = l[%d]&r[%d]", + AOP_SIZE(result), + AOP_SIZE(left), AOP_SIZE(right)); +#endif + + /* if left is a literal & right is not then exchange them */ + if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) || + AOP_NEEDSACC(left)) { + operand *tmp = right ; + right = left; + left = tmp; + } + + /* if result = right then exchange them */ + if(sameRegs(AOP(result),AOP(right))){ + operand *tmp = right ; + right = left; + left = tmp; + } + + /* if right is bit then exchange them */ + if (AOP_TYPE(right) == AOP_CRY && + AOP_TYPE(left) != AOP_CRY){ + operand *tmp = right ; + right = left; + left = tmp; + } + if(AOP_TYPE(right) == AOP_LIT) + lit = (unsigned long)floatFromVal (AOP(right)->aopu.aop_lit); + + size = AOP_SIZE(result); + + // if(bit & yy) + // result = bit & yy; + if (AOP_TYPE(left) == AOP_CRY){ + // c = bit & literal; + if(AOP_TYPE(right) == AOP_LIT){ + if(lit & 1) { + if(size && sameRegs(AOP(result),AOP(left))) + // no change + goto release; + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + } else { + // bit(result) = 0; + if(size && (AOP_TYPE(result) == AOP_CRY)){ + emitcode("clr","%s",AOP(result)->aopu.aop_dir); + goto release; + } + if((AOP_TYPE(result) == AOP_CRY) && ifx){ + jumpIfTrue(ifx); + goto release; + } + emitcode("clr","c"); + } + } else { + if (AOP_TYPE(right) == AOP_CRY){ + // c = bit & bit; + emitcode("mov","c,%s",AOP(right)->aopu.aop_dir); + emitcode("anl","c,%s",AOP(left)->aopu.aop_dir); + } else { + // c = bit & val; + MOVA(aopGet(AOP(right),0,FALSE,FALSE)); + // c = lsb + emitcode("rrc","a"); + emitcode("anl","c,%s",AOP(left)->aopu.aop_dir); + } + } + // bit = c + // val = c + if(size) + outBitC(result); + // if(bit & ...) + else if((AOP_TYPE(result) == AOP_CRY) && ifx) + genIfxJump(ifx, "c"); + goto release ; + } + + // if(val & 0xZZ) - size = 0, ifx != FALSE - + // bit = val & 0xZZ - size = 1, ifx = FALSE - + if((AOP_TYPE(right) == AOP_LIT) && + (AOP_TYPE(result) == AOP_CRY) && + (AOP_TYPE(left) != AOP_CRY)){ + int posbit = isLiteralBit(lit); + /* left & 2^n */ + if(posbit){ + posbit--; + MOVA(aopGet(AOP(left),posbit>>3,FALSE,FALSE)); + // bit = left & 2^n + if(size) + emitcode("mov","c,acc.%d",posbit&0x07); + // if(left & 2^n) + else{ + if(ifx){ + sprintf(buffer,"acc.%d",posbit&0x07); + genIfxJump(ifx, buffer); + } + goto release; + } + } else { + symbol *tlbl = newiTempLabel(NULL); + int sizel = AOP_SIZE(left); + if(size) + emitcode("setb","c"); + while(sizel--){ + if((bytelit = ((lit >> (offset*8)) & 0x0FFL)) != 0x0L){ + MOVA( aopGet(AOP(left),offset,FALSE,FALSE)); + // byte == 2^n ? + if((posbit = isLiteralBit(bytelit)) != 0) + emitcode("jb","acc.%d,%05d$",(posbit-1)&0x07,tlbl->key+100); + else{ + if(bytelit != 0x0FFL) + emitcode("anl","a,%s", + aopGet(AOP(right),offset,FALSE,TRUE)); + emitcode("jnz","%05d$",tlbl->key+100); + } + } + offset++; + } + // bit = left & literal + if(size){ + emitcode("clr","c"); + emitcode("","%05d$:",tlbl->key+100); + } + // if(left & literal) + else{ + if(ifx) + jmpTrueOrFalse(ifx, tlbl); + goto release ; + } + } + outBitC(result); + goto release ; + } + + /* if left is same as result */ + if(sameRegs(AOP(result),AOP(left))){ + for(;size--; offset++) { + if(AOP_TYPE(right) == AOP_LIT){ + if((bytelit = (int)((lit >> (offset*8)) & 0x0FFL)) == 0x0FF) + continue; + else + if (bytelit == 0) + aopPut(AOP(result),zero,offset); + else + if (IS_AOP_PREG(result)) { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("anl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE)); + aopPut(AOP(result),"a",offset); + } else + emitcode("anl","%s,%s", + aopGet(AOP(left),offset,FALSE,TRUE), + aopGet(AOP(right),offset,FALSE,FALSE)); + } else { + if (AOP_TYPE(left) == AOP_ACC) + emitcode("anl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE)); + else { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + if (IS_AOP_PREG(result)) { + emitcode("anl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE)); + aopPut(AOP(result),"a",offset); + + } else + emitcode("anl","%s,a", + aopGet(AOP(left),offset,FALSE,TRUE)); + } + } + } + } else { + // left & result in different registers + if(AOP_TYPE(result) == AOP_CRY){ + // result = bit + // if(size), result in bit + // if(!size && ifx), conditional oper: if(left & right) + symbol *tlbl = newiTempLabel(NULL); + int sizer = min(AOP_SIZE(left),AOP_SIZE(right)); + if(size) + emitcode("setb","c"); + while(sizer--){ + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("anl","a,%s", + aopGet(AOP(left),offset,FALSE,FALSE)); + emitcode("jnz","%05d$",tlbl->key+100); + offset++; + } + if(size){ + CLRC; + emitcode("","%05d$:",tlbl->key+100); + outBitC(result); + } else if(ifx) + jmpTrueOrFalse(ifx, tlbl); + } else { + for(;(size--);offset++) { + // normal case + // result = left & right + if(AOP_TYPE(right) == AOP_LIT){ + if((bytelit = (int)((lit >> (offset*8)) & 0x0FFL)) == 0x0FF){ + aopPut(AOP(result), + aopGet(AOP(left),offset,FALSE,FALSE), + offset); + continue; + } else if(bytelit == 0){ + aopPut(AOP(result),zero,offset); + continue; + } + } + // faster than result <- left, anl result,right + // and better if result is SFR + if (AOP_TYPE(left) == AOP_ACC) + emitcode("anl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE)); + else { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("anl","a,%s", + aopGet(AOP(left),offset,FALSE,FALSE)); + } + aopPut(AOP(result),"a",offset); + } + } + } + +release : + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genOr - code for or */ +/*-----------------------------------------------------------------*/ +static void genOr (iCode *ic, iCode *ifx) +{ + operand *left, *right, *result; + int size, offset=0; + unsigned long lit = 0L; + + aopOp((left = IC_LEFT(ic)),ic,FALSE); + aopOp((right= IC_RIGHT(ic)),ic,FALSE); + aopOp((result=IC_RESULT(ic)),ic,TRUE); + +#ifdef DEBUG_TYPE + emitcode("","; Type res[%d] = l[%d]&r[%d]", + AOP_TYPE(result), + AOP_TYPE(left), AOP_TYPE(right)); + emitcode("","; Size res[%d] = l[%d]&r[%d]", + AOP_SIZE(result), + AOP_SIZE(left), AOP_SIZE(right)); +#endif + + /* if left is a literal & right is not then exchange them */ + if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) || + AOP_NEEDSACC(left)) { + operand *tmp = right ; + right = left; + left = tmp; + } + + /* if result = right then exchange them */ + if(sameRegs(AOP(result),AOP(right))){ + operand *tmp = right ; + right = left; + left = tmp; + } + + /* if right is bit then exchange them */ + if (AOP_TYPE(right) == AOP_CRY && + AOP_TYPE(left) != AOP_CRY){ + operand *tmp = right ; + right = left; + left = tmp; + } + if(AOP_TYPE(right) == AOP_LIT) + lit = (unsigned long)floatFromVal (AOP(right)->aopu.aop_lit); + + size = AOP_SIZE(result); + + // if(bit | yy) + // xx = bit | yy; + if (AOP_TYPE(left) == AOP_CRY){ + if(AOP_TYPE(right) == AOP_LIT){ + // c = bit & literal; + if(lit){ + // lit != 0 => result = 1 + if(AOP_TYPE(result) == AOP_CRY){ + if(size) + emitcode("setb","%s",AOP(result)->aopu.aop_dir); + else if(ifx) + continueIfTrue(ifx); + goto release; + } + emitcode("setb","c"); + } else { + // lit == 0 => result = left + if(size && sameRegs(AOP(result),AOP(left))) + goto release; + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + } + } else { + if (AOP_TYPE(right) == AOP_CRY){ + // c = bit | bit; + emitcode("mov","c,%s",AOP(right)->aopu.aop_dir); + emitcode("orl","c,%s",AOP(left)->aopu.aop_dir); + } + else{ + // c = bit | val; + symbol *tlbl = newiTempLabel(NULL); + if(!((AOP_TYPE(result) == AOP_CRY) && ifx)) + emitcode("setb","c"); + emitcode("jb","%s,%05d$", + AOP(left)->aopu.aop_dir,tlbl->key+100); + toBoolean(right); + emitcode("jnz","%05d$",tlbl->key+100); + if((AOP_TYPE(result) == AOP_CRY) && ifx){ + jmpTrueOrFalse(ifx, tlbl); + goto release; + } else { + CLRC; + emitcode("","%05d$:",tlbl->key+100); + } + } + } + // bit = c + // val = c + if(size) + outBitC(result); + // if(bit | ...) + else if((AOP_TYPE(result) == AOP_CRY) && ifx) + genIfxJump(ifx, "c"); + goto release ; + } + + // if(val | 0xZZ) - size = 0, ifx != FALSE - + // bit = val | 0xZZ - size = 1, ifx = FALSE - + if((AOP_TYPE(right) == AOP_LIT) && + (AOP_TYPE(result) == AOP_CRY) && + (AOP_TYPE(left) != AOP_CRY)){ + if(lit){ + // result = 1 + if(size) + emitcode("setb","%s",AOP(result)->aopu.aop_dir); + else + continueIfTrue(ifx); + goto release; + } else { + // lit = 0, result = boolean(left) + if(size) + emitcode("setb","c"); + toBoolean(right); + if(size){ + symbol *tlbl = newiTempLabel(NULL); + emitcode("jnz","%05d$",tlbl->key+100); + CLRC; + emitcode("","%05d$:",tlbl->key+100); + } else { + genIfxJump (ifx,"a"); + goto release; + } + } + outBitC(result); + goto release ; + } + + /* if left is same as result */ + if(sameRegs(AOP(result),AOP(left))){ + for(;size--; offset++) { + if(AOP_TYPE(right) == AOP_LIT){ + if(((lit >> (offset*8)) & 0x0FFL) == 0x00L) + continue; + else + if (IS_AOP_PREG(left)) { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE)); + aopPut(AOP(result),"a",offset); + } else + emitcode("orl","%s,%s", + aopGet(AOP(left),offset,FALSE,TRUE), + aopGet(AOP(right),offset,FALSE,FALSE)); + } else { + if (AOP_TYPE(left) == AOP_ACC) + emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE)); + else { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + if (IS_AOP_PREG(left)) { + emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE)); + aopPut(AOP(result),"a",offset); + } else + emitcode("orl","%s,a", + aopGet(AOP(left),offset,FALSE,TRUE)); + } + } + } + } else { + // left & result in different registers + if(AOP_TYPE(result) == AOP_CRY){ + // result = bit + // if(size), result in bit + // if(!size && ifx), conditional oper: if(left | right) + symbol *tlbl = newiTempLabel(NULL); + int sizer = max(AOP_SIZE(left),AOP_SIZE(right)); + if(size) + emitcode("setb","c"); + while(sizer--){ + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("orl","a,%s", + aopGet(AOP(left),offset,FALSE,FALSE)); + emitcode("jnz","%05d$",tlbl->key+100); + offset++; + } + if(size){ + CLRC; + emitcode("","%05d$:",tlbl->key+100); + outBitC(result); + } else if(ifx) + jmpTrueOrFalse(ifx, tlbl); + } else for(;(size--);offset++){ + // normal case + // result = left & right + if(AOP_TYPE(right) == AOP_LIT){ + if(((lit >> (offset*8)) & 0x0FFL) == 0x00L){ + aopPut(AOP(result), + aopGet(AOP(left),offset,FALSE,FALSE), + offset); + continue; + } + } + // faster than result <- left, anl result,right + // and better if result is SFR + if (AOP_TYPE(left) == AOP_ACC) + emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE)); + else { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("orl","a,%s", + aopGet(AOP(left),offset,FALSE,FALSE)); + } + aopPut(AOP(result),"a",offset); + } + } + +release : + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genXor - code for xclusive or */ +/*-----------------------------------------------------------------*/ +static void genXor (iCode *ic, iCode *ifx) +{ + operand *left, *right, *result; + int size, offset=0; + unsigned long lit = 0L; + + aopOp((left = IC_LEFT(ic)),ic,FALSE); + aopOp((right= IC_RIGHT(ic)),ic,FALSE); + aopOp((result=IC_RESULT(ic)),ic,TRUE); + +#ifdef DEBUG_TYPE + emitcode("","; Type res[%d] = l[%d]&r[%d]", + AOP_TYPE(result), + AOP_TYPE(left), AOP_TYPE(right)); + emitcode("","; Size res[%d] = l[%d]&r[%d]", + AOP_SIZE(result), + AOP_SIZE(left), AOP_SIZE(right)); +#endif + + /* if left is a literal & right is not || + if left needs acc & right does not */ + if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) || + (AOP_NEEDSACC(left) && !AOP_NEEDSACC(right))) { + operand *tmp = right ; + right = left; + left = tmp; + } + + /* if result = right then exchange them */ + if(sameRegs(AOP(result),AOP(right))){ + operand *tmp = right ; + right = left; + left = tmp; + } + + /* if right is bit then exchange them */ + if (AOP_TYPE(right) == AOP_CRY && + AOP_TYPE(left) != AOP_CRY){ + operand *tmp = right ; + right = left; + left = tmp; + } + if(AOP_TYPE(right) == AOP_LIT) + lit = (unsigned long)floatFromVal (AOP(right)->aopu.aop_lit); + + size = AOP_SIZE(result); + + // if(bit ^ yy) + // xx = bit ^ yy; + if (AOP_TYPE(left) == AOP_CRY){ + if(AOP_TYPE(right) == AOP_LIT){ + // c = bit & literal; + if(lit>>1){ + // lit>>1 != 0 => result = 1 + if(AOP_TYPE(result) == AOP_CRY){ + if(size) + emitcode("setb","%s",AOP(result)->aopu.aop_dir); + else if(ifx) + continueIfTrue(ifx); + goto release; + } + emitcode("setb","c"); + } else{ + // lit == (0 or 1) + if(lit == 0){ + // lit == 0, result = left + if(size && sameRegs(AOP(result),AOP(left))) + goto release; + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + } else{ + // lit == 1, result = not(left) + if(size && sameRegs(AOP(result),AOP(left))){ + emitcode("cpl","%s",AOP(result)->aopu.aop_dir); + goto release; + } else { + emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); + emitcode("cpl","c"); + } + } + } + + } else { + // right != literal + symbol *tlbl = newiTempLabel(NULL); + if (AOP_TYPE(right) == AOP_CRY){ + // c = bit ^ bit; + emitcode("mov","c,%s",AOP(right)->aopu.aop_dir); + } + else{ + int sizer = AOP_SIZE(right); + // c = bit ^ val + // if val>>1 != 0, result = 1 + emitcode("setb","c"); + while(sizer--){ + MOVA(aopGet(AOP(right),sizer-1,FALSE,FALSE)); + if(sizer == 1) + // test the msb of the lsb + emitcode("anl","a,#0xfe"); + emitcode("jnz","%05d$",tlbl->key+100); + } + // val = (0,1) + emitcode("rrc","a"); + } + emitcode("jnb","%s,%05d$",AOP(left)->aopu.aop_dir,(tlbl->key+100)); + emitcode("cpl","c"); + emitcode("","%05d$:",(tlbl->key+100)); + } + // bit = c + // val = c + if(size) + outBitC(result); + // if(bit | ...) + else if((AOP_TYPE(result) == AOP_CRY) && ifx) + genIfxJump(ifx, "c"); + goto release ; + } + + if(sameRegs(AOP(result),AOP(left))){ + /* if left is same as result */ + for(;size--; offset++) { + if(AOP_TYPE(right) == AOP_LIT){ + if(((lit >> (offset*8)) & 0x0FFL) == 0x00L) + continue; + else + if (IS_AOP_PREG(left)) { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE)); + aopPut(AOP(result),"a",offset); + } else + emitcode("xrl","%s,%s", + aopGet(AOP(left),offset,FALSE,TRUE), + aopGet(AOP(right),offset,FALSE,FALSE)); + } else { + if (AOP_TYPE(left) == AOP_ACC) + emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE)); + else { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + if (IS_AOP_PREG(left)) { + emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE)); + aopPut(AOP(result),"a",offset); + } else + emitcode("xrl","%s,a", + aopGet(AOP(left),offset,FALSE,TRUE)); + } + } + } + } else { + // left & result in different registers + if(AOP_TYPE(result) == AOP_CRY){ + // result = bit + // if(size), result in bit + // if(!size && ifx), conditional oper: if(left ^ right) + symbol *tlbl = newiTempLabel(NULL); + int sizer = max(AOP_SIZE(left),AOP_SIZE(right)); + if(size) + emitcode("setb","c"); + while(sizer--){ + if((AOP_TYPE(right) == AOP_LIT) && + (((lit >> (offset*8)) & 0x0FFL) == 0x00L)){ + MOVA(aopGet(AOP(left),offset,FALSE,FALSE)); + } else { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("xrl","a,%s", + aopGet(AOP(left),offset,FALSE,FALSE)); + } + emitcode("jnz","%05d$",tlbl->key+100); + offset++; + } + if(size){ + CLRC; + emitcode("","%05d$:",tlbl->key+100); + outBitC(result); + } else if(ifx) + jmpTrueOrFalse(ifx, tlbl); + } else for(;(size--);offset++){ + // normal case + // result = left & right + if(AOP_TYPE(right) == AOP_LIT){ + if(((lit >> (offset*8)) & 0x0FFL) == 0x00L){ + aopPut(AOP(result), + aopGet(AOP(left),offset,FALSE,FALSE), + offset); + continue; + } + } + // faster than result <- left, anl result,right + // and better if result is SFR + if (AOP_TYPE(left) == AOP_ACC) + emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE)); + else { + MOVA(aopGet(AOP(right),offset,FALSE,FALSE)); + emitcode("xrl","a,%s", + aopGet(AOP(left),offset,FALSE,TRUE)); + } + aopPut(AOP(result),"a",offset); + } + } + +release : + freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE)); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genInline - write the inline code out */ +/*-----------------------------------------------------------------*/ +static void genInline (iCode *ic) +{ + char buffer[MAX_INLINEASM]; + char *bp = buffer; + char *bp1= buffer; + + inLine += (!options.asmpeep); + strcpy(buffer,IC_INLINE(ic)); + + /* emit each line as a code */ + while (*bp) { + if (*bp == '\n') { + *bp++ = '\0'; + emitcode(bp1,""); + bp1 = bp; + } else { + if (*bp == ':') { + bp++; + *bp = '\0'; + bp++; + emitcode(bp1,""); + bp1 = bp; + } else + bp++; + } + } + if (bp1 != bp) + emitcode(bp1,""); + /* emitcode("",buffer); */ + inLine -= (!options.asmpeep); +} + +/*-----------------------------------------------------------------*/ +/* genRRC - rotate right with carry */ +/*-----------------------------------------------------------------*/ +static void genRRC (iCode *ic) +{ + operand *left , *result ; + int size, offset = 0; + char *l; + + /* rotate right with carry */ + left = IC_LEFT(ic); + result=IC_RESULT(ic); + aopOp (left,ic,FALSE); + aopOp (result,ic,FALSE); + + /* move it to the result */ + size = AOP_SIZE(result); + offset = size - 1 ; + CLRC; + while (size--) { + l = aopGet(AOP(left),offset,FALSE,FALSE); + MOVA(l); + emitcode("rrc","a"); + if (AOP_SIZE(result) > 1) + aopPut(AOP(result),"a",offset--); + } + /* now we need to put the carry into the + highest order byte of the result */ + if (AOP_SIZE(result) > 1) { + l = aopGet(AOP(result),AOP_SIZE(result)-1,FALSE,FALSE); + MOVA(l); + } + emitcode("mov","acc.7,c"); + aopPut(AOP(result),"a",AOP_SIZE(result)-1); + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genRLC - generate code for rotate left with carry */ +/*-----------------------------------------------------------------*/ +static void genRLC (iCode *ic) +{ + operand *left , *result ; + int size, offset = 0; + char *l; + + /* rotate right with carry */ + left = IC_LEFT(ic); + result=IC_RESULT(ic); + aopOp (left,ic,FALSE); + aopOp (result,ic,FALSE); + + /* move it to the result */ + size = AOP_SIZE(result); + offset = 0 ; + if (size--) { + l = aopGet(AOP(left),offset,FALSE,FALSE); + MOVA(l); + emitcode("add","a,acc"); + if (AOP_SIZE(result) > 1) + aopPut(AOP(result),"a",offset++); + while (size--) { + l = aopGet(AOP(left),offset,FALSE,FALSE); + MOVA(l); + emitcode("rlc","a"); + if (AOP_SIZE(result) > 1) + aopPut(AOP(result),"a",offset++); + } + } + /* now we need to put the carry into the + highest order byte of the result */ + if (AOP_SIZE(result) > 1) { + l = aopGet(AOP(result),0,FALSE,FALSE); + MOVA(l); + } + emitcode("mov","acc.0,c"); + aopPut(AOP(result),"a",0); + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genGetHbit - generates code get highest order bit */ +/*-----------------------------------------------------------------*/ +static void genGetHbit (iCode *ic) +{ + operand *left, *result; + left = IC_LEFT(ic); + result=IC_RESULT(ic); + aopOp (left,ic,FALSE); + aopOp (result,ic,FALSE); + + /* get the highest order byte into a */ + MOVA(aopGet(AOP(left),AOP_SIZE(left) - 1,FALSE,FALSE)); + if(AOP_TYPE(result) == AOP_CRY){ + emitcode("rlc","a"); + outBitC(result); + } + else{ + emitcode("rl","a"); + emitcode("anl","a,#0x01"); + outAcc(result); + } + + + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* AccRol - rotate left accumulator by known count */ +/*-----------------------------------------------------------------*/ +static void AccRol (int shCount) +{ + shCount &= 0x0007; // shCount : 0..7 + switch(shCount){ + case 0 : + break; + case 1 : + emitcode("rl","a"); + break; + case 2 : + emitcode("rl","a"); + emitcode("rl","a"); + break; + case 3 : + emitcode("swap","a"); + emitcode("rr","a"); + break; + case 4 : + emitcode("swap","a"); + break; + case 5 : + emitcode("swap","a"); + emitcode("rl","a"); + break; + case 6 : + emitcode("rr","a"); + emitcode("rr","a"); + break; + case 7 : + emitcode("rr","a"); + break; + } +} + +/*-----------------------------------------------------------------*/ +/* AccLsh - left shift accumulator by known count */ +/*-----------------------------------------------------------------*/ +static void AccLsh (int shCount) +{ + if(shCount != 0){ + if(shCount == 1) + emitcode("add","a,acc"); + else + if(shCount == 2) { + emitcode("add","a,acc"); + emitcode("add","a,acc"); + } else { + /* rotate left accumulator */ + AccRol(shCount); + /* and kill the lower order bits */ + emitcode("anl","a,#0x%02x", SLMask[shCount]); + } + } +} + +/*-----------------------------------------------------------------*/ +/* AccRsh - right shift accumulator by known count */ +/*-----------------------------------------------------------------*/ +static void AccRsh (int shCount) +{ + if(shCount != 0){ + if(shCount == 1){ + CLRC; + emitcode("rrc","a"); + } else { + /* rotate right accumulator */ + AccRol(8 - shCount); + /* and kill the higher order bits */ + emitcode("anl","a,#0x%02x", SRMask[shCount]); + } + } +} + +/*-----------------------------------------------------------------*/ +/* AccSRsh - signed right shift accumulator by known count */ +/*-----------------------------------------------------------------*/ +static void AccSRsh (int shCount) +{ + symbol *tlbl ; + if(shCount != 0){ + if(shCount == 1){ + emitcode("mov","c,acc.7"); + emitcode("rrc","a"); + } else if(shCount == 2){ + emitcode("mov","c,acc.7"); + emitcode("rrc","a"); + emitcode("mov","c,acc.7"); + emitcode("rrc","a"); + } else { + tlbl = newiTempLabel(NULL); + /* rotate right accumulator */ + AccRol(8 - shCount); + /* and kill the higher order bits */ + emitcode("anl","a,#0x%02x", SRMask[shCount]); + emitcode("jnb","acc.%d,%05d$",7-shCount,tlbl->key+100); + emitcode("orl","a,#0x%02x", + (unsigned char)~SRMask[shCount]); + emitcode("","%05d$:",tlbl->key+100); + } + } +} + +/*-----------------------------------------------------------------*/ +/* shiftR1Left2Result - shift right one byte from left to result */ +/*-----------------------------------------------------------------*/ +static void shiftR1Left2Result (operand *left, int offl, + operand *result, int offr, + int shCount, int sign) +{ + MOVA(aopGet(AOP(left),offl,FALSE,FALSE)); + /* shift right accumulator */ + if(sign) + AccSRsh(shCount); + else + AccRsh(shCount); + aopPut(AOP(result),"a",offr); +} + +/*-----------------------------------------------------------------*/ +/* shiftL1Left2Result - shift left one byte from left to result */ +/*-----------------------------------------------------------------*/ +static void shiftL1Left2Result (operand *left, int offl, + operand *result, int offr, int shCount) +{ + char *l; + l = aopGet(AOP(left),offl,FALSE,FALSE); + MOVA(l); + /* shift left accumulator */ + AccLsh(shCount); + aopPut(AOP(result),"a",offr); +} + +/*-----------------------------------------------------------------*/ +/* movLeft2Result - move byte from left to result */ +/*-----------------------------------------------------------------*/ +static void movLeft2Result (operand *left, int offl, + operand *result, int offr, int sign) +{ + char *l; + if(!sameRegs(AOP(left),AOP(result)) || (offl != offr)){ + l = aopGet(AOP(left),offl,FALSE,FALSE); + + if (*l == '@' && (IS_AOP_PREG(result))) { + emitcode("mov","a,%s",l); + aopPut(AOP(result),"a",offr); + } else { + if(!sign) + aopPut(AOP(result),l,offr); + else{ + /* MSB sign in acc.7 ! */ + if(getDataSize(left) == offl+1){ + emitcode("mov","a,%s",l); + aopPut(AOP(result),"a",offr); + } + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* AccAXRrl1 - right rotate c->a:x->c by 1 */ +/*-----------------------------------------------------------------*/ +static void AccAXRrl1 (char *x) +{ + emitcode("rrc","a"); + emitcode("xch","a,%s", x); + emitcode("rrc","a"); + emitcode("xch","a,%s", x); +} + +/*-----------------------------------------------------------------*/ +/* AccAXLrl1 - left rotate c<-a:x<-c by 1 */ +/*-----------------------------------------------------------------*/ +static void AccAXLrl1 (char *x) +{ + emitcode("xch","a,%s",x); + emitcode("rlc","a"); + emitcode("xch","a,%s",x); + emitcode("rlc","a"); +} + +/*-----------------------------------------------------------------*/ +/* AccAXLsh1 - left shift a:x<-0 by 1 */ +/*-----------------------------------------------------------------*/ +static void AccAXLsh1 (char *x) +{ + emitcode("xch","a,%s",x); + emitcode("add","a,acc"); + emitcode("xch","a,%s",x); + emitcode("rlc","a"); +} + +/*-----------------------------------------------------------------*/ +/* AccAXLsh - left shift a:x by known count (0..7) */ +/*-----------------------------------------------------------------*/ +static void AccAXLsh (char *x, int shCount) +{ + switch(shCount){ + case 0 : + break; + case 1 : + AccAXLsh1(x); + break; + case 2 : + AccAXLsh1(x); + AccAXLsh1(x); + break; + case 3 : + case 4 : + case 5 : // AAAAABBB:CCCCCDDD + AccRol(shCount); // BBBAAAAA:CCCCCDDD + emitcode("anl","a,#0x%02x", + SLMask[shCount]); // BBB00000:CCCCCDDD + emitcode("xch","a,%s",x); // CCCCCDDD:BBB00000 + AccRol(shCount); // DDDCCCCC:BBB00000 + emitcode("xch","a,%s",x); // BBB00000:DDDCCCCC + emitcode("xrl","a,%s",x); // (BBB^DDD)CCCCC:DDDCCCCC + emitcode("xch","a,%s",x); // DDDCCCCC:(BBB^DDD)CCCCC + emitcode("anl","a,#0x%02x", + SLMask[shCount]); // DDD00000:(BBB^DDD)CCCCC + emitcode("xch","a,%s",x); // (BBB^DDD)CCCCC:DDD00000 + emitcode("xrl","a,%s",x); // BBBCCCCC:DDD00000 + break; + case 6 : // AAAAAABB:CCCCCCDD + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 000000BB:CCCCCCDD + emitcode("mov","c,acc.0"); // c = B + emitcode("xch","a,%s",x); // CCCCCCDD:000000BB + AccAXRrl1(x); // BCCCCCCD:D000000B + AccAXRrl1(x); // BBCCCCCC:DD000000 + break; + case 7 : // a:x <<= 7 + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 0000000B:CCCCCCCD + emitcode("mov","c,acc.0"); // c = B + emitcode("xch","a,%s",x); // CCCCCCCD:0000000B + AccAXRrl1(x); // BCCCCCCC:D0000000 + break; + default : + break; + } +} + +/*-----------------------------------------------------------------*/ +/* AccAXRsh - right shift a:x known count (0..7) */ +/*-----------------------------------------------------------------*/ +static void AccAXRsh (char *x, int shCount) +{ + switch(shCount){ + case 0 : + break; + case 1 : + CLRC; + AccAXRrl1(x); // 0->a:x + break; + case 2 : + CLRC; + AccAXRrl1(x); // 0->a:x + CLRC; + AccAXRrl1(x); // 0->a:x + break; + case 3 : + case 4 : + case 5 : // AAAAABBB:CCCCCDDD = a:x + AccRol(8 - shCount); // BBBAAAAA:DDDCCCCC + emitcode("xch","a,%s",x); // CCCCCDDD:BBBAAAAA + AccRol(8 - shCount); // DDDCCCCC:BBBAAAAA + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 000CCCCC:BBBAAAAA + emitcode("xrl","a,%s",x); // BBB(CCCCC^AAAAA):BBBAAAAA + emitcode("xch","a,%s",x); // BBBAAAAA:BBB(CCCCC^AAAAA) + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 000AAAAA:BBB(CCCCC^AAAAA) + emitcode("xch","a,%s",x); // BBB(CCCCC^AAAAA):000AAAAA + emitcode("xrl","a,%s",x); // BBBCCCCC:000AAAAA + emitcode("xch","a,%s",x); // 000AAAAA:BBBCCCCC + break; + case 6 : // AABBBBBB:CCDDDDDD + emitcode("mov","c,acc.7"); + AccAXLrl1(x); // ABBBBBBC:CDDDDDDA + AccAXLrl1(x); // BBBBBBCC:DDDDDDAA + emitcode("xch","a,%s",x); // DDDDDDAA:BBBBBBCC + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 000000AA:BBBBBBCC + break; + case 7 : // ABBBBBBB:CDDDDDDD + emitcode("mov","c,acc.7"); // c = A + AccAXLrl1(x); // BBBBBBBC:DDDDDDDA + emitcode("xch","a,%s",x); // DDDDDDDA:BBBBBBCC + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 0000000A:BBBBBBBC + break; + default : + break; + } +} + +/*-----------------------------------------------------------------*/ +/* AccAXRshS - right shift signed a:x known count (0..7) */ +/*-----------------------------------------------------------------*/ +static void AccAXRshS (char *x, int shCount) +{ + symbol *tlbl ; + switch(shCount){ + case 0 : + break; + case 1 : + emitcode("mov","c,acc.7"); + AccAXRrl1(x); // s->a:x + break; + case 2 : + emitcode("mov","c,acc.7"); + AccAXRrl1(x); // s->a:x + emitcode("mov","c,acc.7"); + AccAXRrl1(x); // s->a:x + break; + case 3 : + case 4 : + case 5 : // AAAAABBB:CCCCCDDD = a:x + tlbl = newiTempLabel(NULL); + AccRol(8 - shCount); // BBBAAAAA:CCCCCDDD + emitcode("xch","a,%s",x); // CCCCCDDD:BBBAAAAA + AccRol(8 - shCount); // DDDCCCCC:BBBAAAAA + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 000CCCCC:BBBAAAAA + emitcode("xrl","a,%s",x); // BBB(CCCCC^AAAAA):BBBAAAAA + emitcode("xch","a,%s",x); // BBBAAAAA:BBB(CCCCC^AAAAA) + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 000AAAAA:BBB(CCCCC^AAAAA) + emitcode("xch","a,%s",x); // BBB(CCCCC^AAAAA):000AAAAA + emitcode("xrl","a,%s",x); // BBBCCCCC:000AAAAA + emitcode("xch","a,%s",x); // 000SAAAA:BBBCCCCC + emitcode("jnb","acc.%d,%05d$",7-shCount,tlbl->key+100); + emitcode("orl","a,#0x%02x", + (unsigned char)~SRMask[shCount]); // 111AAAAA:BBBCCCCC + emitcode("","%05d$:",tlbl->key+100); + break; // SSSSAAAA:BBBCCCCC + case 6 : // AABBBBBB:CCDDDDDD + tlbl = newiTempLabel(NULL); + emitcode("mov","c,acc.7"); + AccAXLrl1(x); // ABBBBBBC:CDDDDDDA + AccAXLrl1(x); // BBBBBBCC:DDDDDDAA + emitcode("xch","a,%s",x); // DDDDDDAA:BBBBBBCC + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 000000AA:BBBBBBCC + emitcode("jnb","acc.%d,%05d$",7-shCount,tlbl->key+100); + emitcode("orl","a,#0x%02x", + (unsigned char)~SRMask[shCount]); // 111111AA:BBBBBBCC + emitcode("","%05d$:",tlbl->key+100); + break; + case 7 : // ABBBBBBB:CDDDDDDD + tlbl = newiTempLabel(NULL); + emitcode("mov","c,acc.7"); // c = A + AccAXLrl1(x); // BBBBBBBC:DDDDDDDA + emitcode("xch","a,%s",x); // DDDDDDDA:BBBBBBCC + emitcode("anl","a,#0x%02x", + SRMask[shCount]); // 0000000A:BBBBBBBC + emitcode("jnb","acc.%d,%05d$",7-shCount,tlbl->key+100); + emitcode("orl","a,#0x%02x", + (unsigned char)~SRMask[shCount]); // 1111111A:BBBBBBBC + emitcode("","%05d$:",tlbl->key+100); + break; + default : + break; + } +} + +/*-----------------------------------------------------------------*/ +/* shiftL2Left2Result - shift left two bytes from left to result */ +/*-----------------------------------------------------------------*/ +static void shiftL2Left2Result (operand *left, int offl, + operand *result, int offr, int shCount) +{ + if(sameRegs(AOP(result), AOP(left)) && + ((offl + MSB16) == offr)){ + /* don't crash result[offr] */ + MOVA(aopGet(AOP(left),offl,FALSE,FALSE)); + emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE)); + } else { + movLeft2Result(left,offl, result, offr, 0); + MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE)); + } + /* ax << shCount (x = lsb(result))*/ + AccAXLsh( aopGet(AOP(result),offr,FALSE,FALSE) , shCount); + aopPut(AOP(result),"a",offr+MSB16); +} + + +/*-----------------------------------------------------------------*/ +/* shiftR2Left2Result - shift right two bytes from left to result */ +/*-----------------------------------------------------------------*/ +static void shiftR2Left2Result (operand *left, int offl, + operand *result, int offr, + int shCount, int sign) +{ + if(sameRegs(AOP(result), AOP(left)) && + ((offl + MSB16) == offr)){ + /* don't crash result[offr] */ + MOVA(aopGet(AOP(left),offl,FALSE,FALSE)); + emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE)); + } else { + movLeft2Result(left,offl, result, offr, 0); + MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE)); + } + /* a:x >> shCount (x = lsb(result))*/ + if(sign) + AccAXRshS( aopGet(AOP(result),offr,FALSE,FALSE) , shCount); + else + AccAXRsh( aopGet(AOP(result),offr,FALSE,FALSE) , shCount); + if(getDataSize(result) > 1) + aopPut(AOP(result),"a",offr+MSB16); +} + +/*-----------------------------------------------------------------*/ +/* shiftLLeftOrResult - shift left one byte from left, or to result*/ +/*-----------------------------------------------------------------*/ +static void shiftLLeftOrResult (operand *left, int offl, + operand *result, int offr, int shCount) +{ + MOVA(aopGet(AOP(left),offl,FALSE,FALSE)); + /* shift left accumulator */ + AccLsh(shCount); + /* or with result */ + emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE)); + /* back to result */ + aopPut(AOP(result),"a",offr); +} + +/*-----------------------------------------------------------------*/ +/* shiftRLeftOrResult - shift right one byte from left,or to result*/ +/*-----------------------------------------------------------------*/ +static void shiftRLeftOrResult (operand *left, int offl, + operand *result, int offr, int shCount) +{ + MOVA(aopGet(AOP(left),offl,FALSE,FALSE)); + /* shift right accumulator */ + AccRsh(shCount); + /* or with result */ + emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE)); + /* back to result */ + aopPut(AOP(result),"a",offr); +} + +/*-----------------------------------------------------------------*/ +/* genlshOne - left shift a one byte quantity by known count */ +/*-----------------------------------------------------------------*/ +static void genlshOne (operand *result, operand *left, int shCount) +{ + shiftL1Left2Result(left, LSB, result, LSB, shCount); +} + +/*-----------------------------------------------------------------*/ +/* genlshTwo - left shift two bytes by known amount != 0 */ +/*-----------------------------------------------------------------*/ +static void genlshTwo (operand *result,operand *left, int shCount) +{ + int size = AOP_SIZE(result); + + if (size == 3) + size--; + + /* if shCount >= 8 */ + if (shCount >= 8) { + shCount -= 8 ; + + if (size > 1){ + if (shCount) + shiftL1Left2Result(left, LSB, result, MSB16, shCount); + else + movLeft2Result(left, LSB, result, MSB16, 0); + } + aopPut(AOP(result),zero,LSB); + } + + /* 1 <= shCount <= 7 */ + else { + if(size == 1) + shiftL1Left2Result(left, LSB, result, LSB, shCount); + else + shiftL2Left2Result(left, LSB, result, LSB, shCount); + } +} + +/*-----------------------------------------------------------------*/ +/* shiftLLong - shift left one long from left to result */ +/* offl = LSB or MSB16 */ +/*-----------------------------------------------------------------*/ +static void shiftLLong (operand *left, operand *result, int offr ) +{ + char *l; + int size = AOP_SIZE(result); + + if(size >= LSB+offr){ + l = aopGet(AOP(left),LSB,FALSE,FALSE); + MOVA(l); + emitcode("add","a,acc"); + if (sameRegs(AOP(left),AOP(result)) && + size >= MSB16+offr && offr != LSB ) + emitcode("xch","a,%s", + aopGet(AOP(left),LSB+offr,FALSE,FALSE)); + else + aopPut(AOP(result),"a",LSB+offr); + } + + if(size >= MSB16+offr){ + if (!(sameRegs(AOP(result),AOP(left)) && size >= MSB16+offr && offr != LSB) ) { + l = aopGet(AOP(left),MSB16,FALSE,FALSE); + MOVA(l); + } + emitcode("rlc","a"); + if (sameRegs(AOP(left),AOP(result)) && + size >= MSB24+offr && offr != LSB) + emitcode("xch","a,%s", + aopGet(AOP(left),MSB16+offr,FALSE,FALSE)); + else + aopPut(AOP(result),"a",MSB16+offr); + } + + if(size >= MSB24+offr){ + if (!(sameRegs(AOP(left),AOP(left)) && size >= MSB24+offr && offr != LSB)) { + l = aopGet(AOP(left),MSB24,FALSE,FALSE); + MOVA(l); + } + emitcode("rlc","a"); + if (sameRegs(AOP(left),AOP(result)) && + size >= MSB32+offr && offr != LSB ) + emitcode("xch","a,%s", + aopGet(AOP(left),MSB24+offr,FALSE,FALSE)); + else + aopPut(AOP(result),"a",MSB24+offr); + } + + if(size > MSB32+offr){ + if (!(sameRegs(AOP(result),AOP(left)) && size >= MSB32+offr && offr != LSB)) { + l = aopGet(AOP(left),MSB32,FALSE,FALSE); + MOVA(l); + } + emitcode("rlc","a"); + aopPut(AOP(result),"a",MSB32+offr); + } + if(offr != LSB) + aopPut(AOP(result),zero,LSB); +} + +/*-----------------------------------------------------------------*/ +/* genlshFour - shift four byte by a known amount != 0 */ +/*-----------------------------------------------------------------*/ +static void genlshFour (operand *result, operand *left, int shCount) +{ + int size; + + size = AOP_SIZE(result); + + /* if shifting more that 3 bytes */ + if (shCount >= 24 ) { + shCount -= 24; + if (shCount) + /* lowest order of left goes to the highest + order of the destination */ + shiftL1Left2Result(left, LSB, result, MSB32, shCount); + else + movLeft2Result(left, LSB, result, MSB32, 0); + aopPut(AOP(result),zero,LSB); + aopPut(AOP(result),zero,MSB16); + aopPut(AOP(result),zero,MSB32); + return; + } + + /* more than two bytes */ + else if ( shCount >= 16 ) { + /* lower order two bytes goes to higher order two bytes */ + shCount -= 16; + /* if some more remaining */ + if (shCount) + shiftL2Left2Result(left, LSB, result, MSB24, shCount); + else { + movLeft2Result(left, MSB16, result, MSB32, 0); + movLeft2Result(left, LSB, result, MSB24, 0); + } + aopPut(AOP(result),zero,MSB16); + aopPut(AOP(result),zero,LSB); + return; + } + + /* if more than 1 byte */ + else if ( shCount >= 8 ) { + /* lower order three bytes goes to higher order three bytes */ + shCount -= 8; + if(size == 2){ + if(shCount) + shiftL1Left2Result(left, LSB, result, MSB16, shCount); + else + movLeft2Result(left, LSB, result, MSB16, 0); + } + else{ /* size = 4 */ + if(shCount == 0){ + movLeft2Result(left, MSB24, result, MSB32, 0); + movLeft2Result(left, MSB16, result, MSB24, 0); + movLeft2Result(left, LSB, result, MSB16, 0); + aopPut(AOP(result),zero,LSB); + } + else if(shCount == 1) + shiftLLong(left, result, MSB16); + else{ + shiftL2Left2Result(left, MSB16, result, MSB24, shCount); + shiftL1Left2Result(left, LSB, result, MSB16, shCount); + shiftRLeftOrResult(left, LSB, result, MSB24, 8 - shCount); + aopPut(AOP(result),zero,LSB); + } + } + } + + /* 1 <= shCount <= 7 */ + else if(shCount <= 2){ + shiftLLong(left, result, LSB); + if(shCount == 2) + shiftLLong(result, result, LSB); + } + /* 3 <= shCount <= 7, optimize */ + else{ + shiftL2Left2Result(left, MSB24, result, MSB24, shCount); + shiftRLeftOrResult(left, MSB16, result, MSB24, 8 - shCount); + shiftL2Left2Result(left, LSB, result, LSB, shCount); + } +} + +/*-----------------------------------------------------------------*/ +/* genLeftShiftLiteral - left shifting by known count */ +/*-----------------------------------------------------------------*/ +static void genLeftShiftLiteral (operand *left, + operand *right, + operand *result, + iCode *ic) +{ + int shCount = (int) floatFromVal (AOP(right)->aopu.aop_lit); + int size; + + freeAsmop(right,NULL,ic,TRUE); + + aopOp(left,ic,FALSE); + aopOp(result,ic,FALSE); + + size = getSize(operandType(result)); + +#if VIEW_SIZE + emitcode("; shift left ","result %d, left %d",size, + AOP_SIZE(left)); +#endif + + /* I suppose that the left size >= result size */ + if(shCount == 0){ + while(size--){ + movLeft2Result(left, size, result, size, 0); + } + } + + else if(shCount >= (size * 8)) + while(size--) + aopPut(AOP(result),zero,size); + else{ + switch (size) { + case 1: + genlshOne (result,left,shCount); + break; + + case 2: + case 3: + genlshTwo (result,left,shCount); + break; + + case 4: + genlshFour (result,left,shCount); + break; + } + } + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genLeftShift - generates code for left shifting */ +/*-----------------------------------------------------------------*/ +static void genLeftShift (iCode *ic) +{ + operand *left,*right, *result; + int size, offset; + char *l; + symbol *tlbl , *tlbl1; + + right = IC_RIGHT(ic); + left = IC_LEFT(ic); + result = IC_RESULT(ic); + + aopOp(right,ic,FALSE); + + /* if the shift count is known then do it + as efficiently as possible */ + if (AOP_TYPE(right) == AOP_LIT) { + genLeftShiftLiteral (left,right,result,ic); + return ; + } + + /* shift count is unknown then we have to form + a loop get the loop count in B : Note: we take + only the lower order byte since shifting + more that 32 bits make no sense anyway, ( the + largest size of an object can be only 32 bits ) */ + + emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE)); + emitcode("inc","b"); + freeAsmop (right,NULL,ic,TRUE); + aopOp(left,ic,FALSE); + aopOp(result,ic,FALSE); + + /* now move the left to the result if they are not the + same */ + if (!sameRegs(AOP(left),AOP(result)) && + AOP_SIZE(result) > 1) { + + size = AOP_SIZE(result); + offset=0; + while (size--) { + l = aopGet(AOP(left),offset,FALSE,TRUE); + if (*l == '@' && (IS_AOP_PREG(result))) { + + emitcode("mov","a,%s",l); + aopPut(AOP(result),"a",offset); + } else + aopPut(AOP(result),l,offset); + offset++; + } + } + + tlbl = newiTempLabel(NULL); + size = AOP_SIZE(result); + offset = 0 ; + tlbl1 = newiTempLabel(NULL); + + /* if it is only one byte then */ + if (size == 1) { + symbol *tlbl1 = newiTempLabel(NULL); + + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + emitcode("sjmp","%05d$",tlbl1->key+100); + emitcode("","%05d$:",tlbl->key+100); + emitcode("add","a,acc"); + emitcode("","%05d$:",tlbl1->key+100); + emitcode("djnz","b,%05d$",tlbl->key+100); + aopPut(AOP(result),"a",0); + goto release ; + } + + reAdjustPreg(AOP(result)); + + emitcode("sjmp","%05d$",tlbl1->key+100); + emitcode("","%05d$:",tlbl->key+100); + l = aopGet(AOP(result),offset,FALSE,FALSE); + MOVA(l); + emitcode("add","a,acc"); + aopPut(AOP(result),"a",offset++); + while (--size) { + l = aopGet(AOP(result),offset,FALSE,FALSE); + MOVA(l); + emitcode("rlc","a"); + aopPut(AOP(result),"a",offset++); + } + reAdjustPreg(AOP(result)); + + emitcode("","%05d$:",tlbl1->key+100); + emitcode("djnz","b,%05d$",tlbl->key+100); +release: + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genrshOne - right shift a one byte quantity by known count */ +/*-----------------------------------------------------------------*/ +static void genrshOne (operand *result, operand *left, + int shCount, int sign) +{ + shiftR1Left2Result(left, LSB, result, LSB, shCount, sign); +} + +/*-----------------------------------------------------------------*/ +/* genrshTwo - right shift two bytes by known amount != 0 */ +/*-----------------------------------------------------------------*/ +static void genrshTwo (operand *result,operand *left, + int shCount, int sign) +{ + /* if shCount >= 8 */ + if (shCount >= 8) { + shCount -= 8 ; + if (shCount) + shiftR1Left2Result(left, MSB16, result, LSB, + shCount, sign); + else + movLeft2Result(left, MSB16, result, LSB, sign); + addSign(result, MSB16, sign); + } + + /* 1 <= shCount <= 7 */ + else + shiftR2Left2Result(left, LSB, result, LSB, shCount, sign); +} + +/*-----------------------------------------------------------------*/ +/* shiftRLong - shift right one long from left to result */ +/* offl = LSB or MSB16 */ +/*-----------------------------------------------------------------*/ +static void shiftRLong (operand *left, int offl, + operand *result, int sign) +{ + if(!sign) + emitcode("clr","c"); + MOVA(aopGet(AOP(left),MSB32,FALSE,FALSE)); + if(sign) + emitcode("mov","c,acc.7"); + emitcode("rrc","a"); + aopPut(AOP(result),"a",MSB32-offl); + if(offl == MSB16) + /* add sign of "a" */ + addSign(result, MSB32, sign); + + MOVA(aopGet(AOP(left),MSB24,FALSE,FALSE)); + emitcode("rrc","a"); + aopPut(AOP(result),"a",MSB24-offl); + + MOVA(aopGet(AOP(left),MSB16,FALSE,FALSE)); + emitcode("rrc","a"); + aopPut(AOP(result),"a",MSB16-offl); + + if(offl == LSB){ + MOVA(aopGet(AOP(left),LSB,FALSE,FALSE)); + emitcode("rrc","a"); + aopPut(AOP(result),"a",LSB); + } +} + +/*-----------------------------------------------------------------*/ +/* genrshFour - shift four byte by a known amount != 0 */ +/*-----------------------------------------------------------------*/ +static void genrshFour (operand *result, operand *left, + int shCount, int sign) +{ + /* if shifting more that 3 bytes */ + if(shCount >= 24 ) { + shCount -= 24; + if(shCount) + shiftR1Left2Result(left, MSB32, result, LSB, shCount, sign); + else + movLeft2Result(left, MSB32, result, LSB, sign); + addSign(result, MSB16, sign); + } + else if(shCount >= 16){ + shCount -= 16; + if(shCount) + shiftR2Left2Result(left, MSB24, result, LSB, shCount, sign); + else{ + movLeft2Result(left, MSB24, result, LSB, 0); + movLeft2Result(left, MSB32, result, MSB16, sign); + } + addSign(result, MSB24, sign); + } + else if(shCount >= 8){ + shCount -= 8; + if(shCount == 1) + shiftRLong(left, MSB16, result, sign); + else if(shCount == 0){ + movLeft2Result(left, MSB16, result, LSB, 0); + movLeft2Result(left, MSB24, result, MSB16, 0); + movLeft2Result(left, MSB32, result, MSB24, sign); + addSign(result, MSB32, sign); + } + else{ + shiftR2Left2Result(left, MSB16, result, LSB, shCount, 0); + shiftLLeftOrResult(left, MSB32, result, MSB16, 8 - shCount); + /* the last shift is signed */ + shiftR1Left2Result(left, MSB32, result, MSB24, shCount, sign); + addSign(result, MSB32, sign); + } + } + else{ /* 1 <= shCount <= 7 */ + if(shCount <= 2){ + shiftRLong(left, LSB, result, sign); + if(shCount == 2) + shiftRLong(result, LSB, result, sign); + } + else{ + shiftR2Left2Result(left, LSB, result, LSB, shCount, 0); + shiftLLeftOrResult(left, MSB24, result, MSB16, 8 - shCount); + shiftR2Left2Result(left, MSB24, result, MSB24, shCount, sign); + } + } +} + +/*-----------------------------------------------------------------*/ +/* genRightShiftLiteral - right shifting by known count */ +/*-----------------------------------------------------------------*/ +static void genRightShiftLiteral (operand *left, + operand *right, + operand *result, + iCode *ic, + int sign) +{ + int shCount = (int) floatFromVal (AOP(right)->aopu.aop_lit); + int size; + + freeAsmop(right,NULL,ic,TRUE); + + aopOp(left,ic,FALSE); + aopOp(result,ic,FALSE); + +#if VIEW_SIZE + emitcode("; shift right ","result %d, left %d",AOP_SIZE(result), + AOP_SIZE(left)); +#endif + + size = getDataSize(left); + /* test the LEFT size !!! */ + + /* I suppose that the left size >= result size */ + if(shCount == 0){ + size = getDataSize(result); + while(size--) + movLeft2Result(left, size, result, size, 0); + } + + else if(shCount >= (size * 8)){ + if(sign) + /* get sign in acc.7 */ + MOVA(aopGet(AOP(left),size-1,FALSE,FALSE)); + addSign(result, LSB, sign); + } else{ + switch (size) { + case 1: + genrshOne (result,left,shCount,sign); + break; + + case 2: + genrshTwo (result,left,shCount,sign); + break; + + case 4: + genrshFour (result,left,shCount,sign); + break; + default : + break; + } + + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); + } +} + +/*-----------------------------------------------------------------*/ +/* genSignedRightShift - right shift of signed number */ +/*-----------------------------------------------------------------*/ +static void genSignedRightShift (iCode *ic) +{ + operand *right, *left, *result; + int size, offset; + char *l; + symbol *tlbl, *tlbl1 ; + + /* we do it the hard way put the shift count in b + and loop thru preserving the sign */ + + right = IC_RIGHT(ic); + left = IC_LEFT(ic); + result = IC_RESULT(ic); + + aopOp(right,ic,FALSE); + + + if ( AOP_TYPE(right) == AOP_LIT) { + genRightShiftLiteral (left,right,result,ic,1); + return ; + } + /* shift count is unknown then we have to form + a loop get the loop count in B : Note: we take + only the lower order byte since shifting + more that 32 bits make no sense anyway, ( the + largest size of an object can be only 32 bits ) */ + + emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE)); + emitcode("inc","b"); + freeAsmop (right,NULL,ic,TRUE); + aopOp(left,ic,FALSE); + aopOp(result,ic,FALSE); + + /* now move the left to the result if they are not the + same */ + if (!sameRegs(AOP(left),AOP(result)) && + AOP_SIZE(result) > 1) { + + size = AOP_SIZE(result); + offset=0; + while (size--) { + l = aopGet(AOP(left),offset,FALSE,TRUE); + if (*l == '@' && IS_AOP_PREG(result)) { + + emitcode("mov","a,%s",l); + aopPut(AOP(result),"a",offset); + } else + aopPut(AOP(result),l,offset); + offset++; + } + } + + /* mov the highest order bit to OVR */ + tlbl = newiTempLabel(NULL); + tlbl1= newiTempLabel(NULL); + + size = AOP_SIZE(result); + offset = size - 1; + emitcode("mov","a,%s",aopGet(AOP(left),offset,FALSE,FALSE)); + emitcode("rlc","a"); + emitcode("mov","ov,c"); + /* if it is only one byte then */ + if (size == 1) { + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + emitcode("sjmp","%05d$",tlbl1->key+100); + emitcode("","%05d$:",tlbl->key+100); + emitcode("mov","c,ov"); + emitcode("rrc","a"); + emitcode("","%05d$:",tlbl1->key+100); + emitcode("djnz","b,%05d$",tlbl->key+100); + aopPut(AOP(result),"a",0); + goto release ; + } + + reAdjustPreg(AOP(result)); + emitcode("sjmp","%05d$",tlbl1->key+100); + emitcode("","%05d$:",tlbl->key+100); + emitcode("mov","c,ov"); + while (size--) { + l = aopGet(AOP(result),offset,FALSE,FALSE); + MOVA(l); + emitcode("rrc","a"); + aopPut(AOP(result),"a",offset--); + } + reAdjustPreg(AOP(result)); + emitcode("","%05d$:",tlbl1->key+100); + emitcode("djnz","b,%05d$",tlbl->key+100); + +release: + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genRightShift - generate code for right shifting */ +/*-----------------------------------------------------------------*/ +static void genRightShift (iCode *ic) +{ + operand *right, *left, *result; + link *retype ; + int size, offset; + char *l; + symbol *tlbl, *tlbl1 ; + + /* if signed then we do it the hard way preserve the + sign bit moving it inwards */ + retype = getSpec(operandType(IC_RESULT(ic))); + + if (!SPEC_USIGN(retype)) { + genSignedRightShift (ic); + return ; + } + + /* signed & unsigned types are treated the same : i.e. the + signed is NOT propagated inwards : quoting from the + ANSI - standard : "for E1 >> E2, is equivalent to division + by 2**E2 if unsigned or if it has a non-negative value, + otherwise the result is implementation defined ", MY definition + is that the sign does not get propagated */ + + right = IC_RIGHT(ic); + left = IC_LEFT(ic); + result = IC_RESULT(ic); + + aopOp(right,ic,FALSE); + + /* if the shift count is known then do it + as efficiently as possible */ + if (AOP_TYPE(right) == AOP_LIT) { + genRightShiftLiteral (left,right,result,ic, 0); + return ; + } + + /* shift count is unknown then we have to form + a loop get the loop count in B : Note: we take + only the lower order byte since shifting + more that 32 bits make no sense anyway, ( the + largest size of an object can be only 32 bits ) */ + + emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE)); + emitcode("inc","b"); + freeAsmop (right,NULL,ic,TRUE); + aopOp(left,ic,FALSE); + aopOp(result,ic,FALSE); + + /* now move the left to the result if they are not the + same */ + if (!sameRegs(AOP(left),AOP(result)) && + AOP_SIZE(result) > 1) { + + size = AOP_SIZE(result); + offset=0; + while (size--) { + l = aopGet(AOP(left),offset,FALSE,TRUE); + if (*l == '@' && IS_AOP_PREG(result)) { + + emitcode("mov","a,%s",l); + aopPut(AOP(result),"a",offset); + } else + aopPut(AOP(result),l,offset); + offset++; + } + } + + tlbl = newiTempLabel(NULL); + tlbl1= newiTempLabel(NULL); + size = AOP_SIZE(result); + offset = size - 1; + + /* if it is only one byte then */ + if (size == 1) { + l = aopGet(AOP(left),0,FALSE,FALSE); + MOVA(l); + emitcode("sjmp","%05d$",tlbl1->key+100); + emitcode("","%05d$:",tlbl->key+100); + CLRC; + emitcode("rrc","a"); + emitcode("","%05d$:",tlbl1->key+100); + emitcode("djnz","b,%05d$",tlbl->key+100); + aopPut(AOP(result),"a",0); + goto release ; + } + + reAdjustPreg(AOP(result)); + emitcode("sjmp","%05d$",tlbl1->key+100); + emitcode("","%05d$:",tlbl->key+100); + CLRC; + while (size--) { + l = aopGet(AOP(result),offset,FALSE,FALSE); + MOVA(l); + emitcode("rrc","a"); + aopPut(AOP(result),"a",offset--); + } + reAdjustPreg(AOP(result)); + + emitcode("","%05d$:",tlbl1->key+100); + emitcode("djnz","b,%05d$",tlbl->key+100); + +release: + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genUnpackBits - generates code for unpacking bits */ +/*-----------------------------------------------------------------*/ +static void genUnpackBits (operand *result, char *rname, int ptype) +{ + int shCnt ; + int rlen = 0 ; + link *etype; + int offset = 0 ; + + etype = getSpec(operandType(result)); + + /* read the first byte */ + switch (ptype) { + + case POINTER: + case IPOINTER: + emitcode("mov","a,@%s",rname); + break; + + case PPOINTER: + emitcode("movx","a,@%s",rname); + break; + + case FPOINTER: + emitcode("movx","a,@dptr"); + break; + + case CPOINTER: + emitcode("clr","a"); + emitcode("movc","a","@a+dptr"); + break; + + case GPOINTER: + emitcode("lcall","__gptrget"); + break; + } + + /* if we have bitdisplacement then it fits */ + /* into this byte completely or if length is */ + /* less than a byte */ + if ((shCnt = SPEC_BSTR(etype)) || + (SPEC_BLEN(etype) <= 8)) { + + /* shift right acc */ + AccRsh(shCnt); + + emitcode("anl","a,#0x%02x", + ((unsigned char) -1)>>(8 - SPEC_BLEN(etype))); + aopPut(AOP(result),"a",offset); + return ; + } + + /* bit field did not fit in a byte */ + rlen = SPEC_BLEN(etype) - 8; + aopPut(AOP(result),"a",offset++); + + while (1) { + + switch (ptype) { + case POINTER: + case IPOINTER: + emitcode("inc","%s",rname); + emitcode("mov","a,@%s",rname); + break; + + case PPOINTER: + emitcode("inc","%s",rname); + emitcode("movx","a,@%s",rname); + break; + + case FPOINTER: + emitcode("inc","dptr"); + emitcode("movx","a,@dptr"); + break; + + case CPOINTER: + emitcode("clr","a"); + emitcode("inc","dptr"); + emitcode("movc","a","@a+dptr"); + break; + + case GPOINTER: + emitcode("inc","dptr"); + emitcode("lcall","__gptrget"); + break; + } + + rlen -= 8; + /* if we are done */ + if ( rlen <= 0 ) + break ; + + aopPut(AOP(result),"a",offset++); + + } + + if (rlen) { + emitcode("anl","a,#0x%02x",((unsigned char)-1)>>(-rlen)); + aopPut(AOP(result),"a",offset); + } + + return ; +} + + +/*-----------------------------------------------------------------*/ +/* genDataPointerGet - generates code when ptr offset is known */ +/*-----------------------------------------------------------------*/ +static void genDataPointerGet (operand *left, + operand *result, + iCode *ic) +{ + char *l; + char buffer[256]; + int size , offset = 0; + aopOp(result,ic,TRUE); + + /* get the string representation of the name */ + l = aopGet(AOP(left),0,FALSE,TRUE); + size = AOP_SIZE(result); + while (size--) { + if (offset) + sprintf(buffer,"(%s + %d)",l+1,offset); + else + sprintf(buffer,"%s",l+1); + aopPut(AOP(result),buffer,offset++); + } + + freeAsmop(left,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genNearPointerGet - emitcode for near pointer fetch */ +/*-----------------------------------------------------------------*/ +static void genNearPointerGet (operand *left, + operand *result, + iCode *ic) +{ + asmop *aop = NULL; + regs *preg = NULL ; + char *rname ; + link *rtype, *retype; + link *ltype = operandType(left); + char buffer[80]; + + rtype = operandType(result); + retype= getSpec(rtype); + + aopOp(left,ic,FALSE); + + /* if left is rematerialisable and + result is not bit variable type and + the left is pointer to data space i.e + lower 128 bytes of space */ + if (AOP_TYPE(left) == AOP_IMMD && + !IS_BITVAR(retype) && + DCL_TYPE(ltype) == POINTER) { + genDataPointerGet (left,result,ic); + return ; + } + + /* if the value is already in a pointer register + then don't need anything more */ + if (!AOP_INPREG(AOP(left))) { + /* otherwise get a free pointer register */ + aop = newAsmop(0); + preg = getFreePtr(ic,&aop,FALSE); + emitcode("mov","%s,%s", + preg->name, + aopGet(AOP(left),0,FALSE,TRUE)); + rname = preg->name ; + } else + rname = aopGet(AOP(left),0,FALSE,FALSE); + + freeAsmop(left,NULL,ic,TRUE); + aopOp (result,ic,FALSE); + + /* if bitfield then unpack the bits */ + if (IS_BITVAR(retype)) + genUnpackBits (result,rname,POINTER); + else { + /* we have can just get the values */ + int size = AOP_SIZE(result); + int offset = 0 ; + + while (size--) { + if (IS_AOP_PREG(result) || AOP_TYPE(result) == AOP_STK ) { + + emitcode("mov","a,@%s",rname); + aopPut(AOP(result),"a",offset); + } else { + sprintf(buffer,"@%s",rname); + aopPut(AOP(result),buffer,offset); + } + offset++ ; + if (size) + emitcode("inc","%s",rname); + } + } + + /* now some housekeeping stuff */ + if (aop) { + /* we had to allocate for this iCode */ + freeAsmop(NULL,aop,ic,TRUE); + } else { + /* we did not allocate which means left + already in a pointer register, then + if size > 0 && this could be used again + we have to point it back to where it + belongs */ + if (AOP_SIZE(result) > 1 && + !OP_SYMBOL(left)->remat && + ( OP_SYMBOL(left)->liveTo > ic->seq || + ic->depth )) { + int size = AOP_SIZE(result) - 1; + while (size--) + emitcode("dec","%s",rname); + } + } + + /* done */ + freeAsmop(result,NULL,ic,TRUE); + +} + +/*-----------------------------------------------------------------*/ +/* genPagedPointerGet - emitcode for paged pointer fetch */ +/*-----------------------------------------------------------------*/ +static void genPagedPointerGet (operand *left, + operand *result, + iCode *ic) +{ + asmop *aop = NULL; + regs *preg = NULL ; + char *rname ; + link *rtype, *retype; + + rtype = operandType(result); + retype= getSpec(rtype); + + aopOp(left,ic,FALSE); + + /* if the value is already in a pointer register + then don't need anything more */ + if (!AOP_INPREG(AOP(left))) { + /* otherwise get a free pointer register */ + aop = newAsmop(0); + preg = getFreePtr(ic,&aop,FALSE); + emitcode("mov","%s,%s", + preg->name, + aopGet(AOP(left),0,FALSE,TRUE)); + rname = preg->name ; + } else + rname = aopGet(AOP(left),0,FALSE,FALSE); + + freeAsmop(left,NULL,ic,TRUE); + aopOp (result,ic,FALSE); + + /* if bitfield then unpack the bits */ + if (IS_BITVAR(retype)) + genUnpackBits (result,rname,PPOINTER); + else { + /* we have can just get the values */ + int size = AOP_SIZE(result); + int offset = 0 ; + + while (size--) { + + emitcode("movx","a,@%s",rname); + aopPut(AOP(result),"a",offset); + + offset++ ; + + if (size) + emitcode("inc","%s",rname); + } + } + + /* now some housekeeping stuff */ + if (aop) { + /* we had to allocate for this iCode */ + freeAsmop(NULL,aop,ic,TRUE); + } else { + /* we did not allocate which means left + already in a pointer register, then + if size > 0 && this could be used again + we have to point it back to where it + belongs */ + if (AOP_SIZE(result) > 1 && + !OP_SYMBOL(left)->remat && + ( OP_SYMBOL(left)->liveTo > ic->seq || + ic->depth )) { + int size = AOP_SIZE(result) - 1; + while (size--) + emitcode("dec","%s",rname); + } + } + + /* done */ + freeAsmop(result,NULL,ic,TRUE); + + +} + +/*-----------------------------------------------------------------*/ +/* genFarPointerGet - gget value from far space */ +/*-----------------------------------------------------------------*/ +static void genFarPointerGet (operand *left, + operand *result, iCode *ic) +{ + int size, offset ; + link *retype = getSpec(operandType(result)); + + aopOp(left,ic,FALSE); + + /* if the operand is already in dptr + then we do nothing else we move the value to dptr */ + if (AOP_TYPE(left) != AOP_STR) { + /* if this is remateriazable */ + if (AOP_TYPE(left) == AOP_IMMD) + emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE)); + else { /* we need to get it byte by byte */ + emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE)); + emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE)); + } + } + /* so dptr know contains the address */ + freeAsmop(left,NULL,ic,TRUE); + aopOp(result,ic,FALSE); + + /* if bit then unpack */ + if (IS_BITVAR(retype)) + genUnpackBits(result,"dptr",FPOINTER); + else { + size = AOP_SIZE(result); + offset = 0 ; + + while (size--) { + emitcode("movx","a,@dptr"); + aopPut(AOP(result),"a",offset++); + if (size) + emitcode("inc","dptr"); + } + } + + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* emitcodePointerGet - gget value from code space */ +/*-----------------------------------------------------------------*/ +static void emitcodePointerGet (operand *left, + operand *result, iCode *ic) +{ + int size, offset ; + link *retype = getSpec(operandType(result)); + + aopOp(left,ic,FALSE); + + /* if the operand is already in dptr + then we do nothing else we move the value to dptr */ + if (AOP_TYPE(left) != AOP_STR) { + /* if this is remateriazable */ + if (AOP_TYPE(left) == AOP_IMMD) + emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE)); + else { /* we need to get it byte by byte */ + emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE)); + emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE)); + } + } + /* so dptr know contains the address */ + freeAsmop(left,NULL,ic,TRUE); + aopOp(result,ic,FALSE); + + /* if bit then unpack */ + if (IS_BITVAR(retype)) + genUnpackBits(result,"dptr",CPOINTER); + else { + size = AOP_SIZE(result); + offset = 0 ; + + while (size--) { + emitcode("clr","a"); + emitcode("movc","a,@a+dptr"); + aopPut(AOP(result),"a",offset++); + if (size) + emitcode("inc","dptr"); + } + } + + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genGenPointerGet - gget value from generic pointer space */ +/*-----------------------------------------------------------------*/ +static void genGenPointerGet (operand *left, + operand *result, iCode *ic) +{ + int size, offset ; + link *retype = getSpec(operandType(result)); + + aopOp(left,ic,FALSE); + + /* if the operand is already in dptr + then we do nothing else we move the value to dptr */ + if (AOP_TYPE(left) != AOP_STR) { + /* if this is remateriazable */ + if (AOP_TYPE(left) == AOP_IMMD) { + emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE)); + emitcode("mov","b,#%d",pointerCode(retype)); + } + else { /* we need to get it byte by byte */ + emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE)); + emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE)); + emitcode("mov","b,%s",aopGet(AOP(left),2,FALSE,FALSE)); + } + } + /* so dptr know contains the address */ + freeAsmop(left,NULL,ic,TRUE); + aopOp(result,ic,FALSE); + + /* if bit then unpack */ + if (IS_BITVAR(retype)) + genUnpackBits(result,"dptr",GPOINTER); + else { + size = AOP_SIZE(result); + offset = 0 ; + + while (size--) { + emitcode("lcall","__gptrget"); + aopPut(AOP(result),"a",offset++); + if (size) + emitcode("inc","dptr"); + } + } + + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genPointerGet - generate code for pointer get */ +/*-----------------------------------------------------------------*/ +static void genPointerGet (iCode *ic) +{ + operand *left, *result ; + link *type, *etype; + int p_type; + + left = IC_LEFT(ic); + result = IC_RESULT(ic) ; + + /* depending on the type of pointer we need to + move it to the correct pointer register */ + type = operandType(left); + etype = getSpec(type); + /* if left is of type of pointer then it is simple */ + if (IS_PTR(type) && !IS_FUNC(type->next)) + p_type = DCL_TYPE(type); + else { + + /* we have to go by the storage class */ + if (SPEC_OCLS(etype)->codesp ) { + p_type = CPOINTER ; + } + else + if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) + p_type = FPOINTER ; + else + if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) + p_type = PPOINTER; + else + if (SPEC_OCLS(etype) == idata ) + p_type = IPOINTER; + else + p_type = POINTER ; + } + + /* now that we have the pointer type we assign + the pointer values */ + switch (p_type) { + + case POINTER: + case IPOINTER: + genNearPointerGet (left,result,ic); + break; + + case PPOINTER: + genPagedPointerGet(left,result,ic); + break; + + case FPOINTER: + genFarPointerGet (left,result,ic); + break; + + case CPOINTER: + emitcodePointerGet (left,result,ic); + break; + + case GPOINTER: + genGenPointerGet (left,result,ic); + break; + } + +} + +/*-----------------------------------------------------------------*/ +/* genPackBits - generates code for packed bit storage */ +/*-----------------------------------------------------------------*/ +static void genPackBits (link *etype , + operand *right , + char *rname, int p_type) +{ + int shCount = 0 ; + int offset = 0 ; + int rLen = 0 ; + int blen, bstr ; + char *l ; + + blen = SPEC_BLEN(etype); + bstr = SPEC_BSTR(etype); + + l = aopGet(AOP(right),offset++,FALSE,FALSE); + MOVA(l); + + /* if the bit lenth is less than or */ + /* it exactly fits a byte then */ + if (SPEC_BLEN(etype) <= 8 ) { + shCount = SPEC_BSTR(etype) ; + + /* shift left acc */ + AccLsh(shCount); + + if (SPEC_BLEN(etype) < 8 ) { /* if smaller than a byte */ + + + switch (p_type) { + case POINTER: + emitcode ("mov","b,a"); + emitcode("mov","a,@%s",rname); + break; + + case FPOINTER: + emitcode ("mov","b,a"); + emitcode("movx","a,@dptr"); + break; + + case GPOINTER: + emitcode ("push","b"); + emitcode ("push","acc"); + emitcode ("lcall","__gptrget"); + emitcode ("pop","b"); + break; + } + + emitcode ("anl","a,#0x%02x",(unsigned char) + ((unsigned char)(0xFF << (blen+bstr)) | + (unsigned char)(0xFF >> (8-bstr)) ) ); + emitcode ("orl","a,b"); + if (p_type == GPOINTER) + emitcode("pop","b"); + } + } + + switch (p_type) { + case POINTER: + emitcode("mov","@%s,a",rname); + break; + + case FPOINTER: + emitcode("movx","@dptr,a"); + break; + + case GPOINTER: + emitcode("lcall","__gptrput"); + break; + } + + /* if we r done */ + if ( SPEC_BLEN(etype) <= 8 ) + return ; + + emitcode("inc","%s",rname); + rLen = SPEC_BLEN(etype) ; + + /* now generate for lengths greater than one byte */ + while (1) { + + l = aopGet(AOP(right),offset++,FALSE,TRUE); + + rLen -= 8 ; + if (rLen <= 0 ) + break ; + + switch (p_type) { + case POINTER: + if (*l == '@') { + MOVA(l); + emitcode("mov","@%s,a",rname); + } else + emitcode("mov","@%s,%s",rname,l); + break; + + case FPOINTER: + MOVA(l); + emitcode("movx","@dptr,a"); + break; + + case GPOINTER: + MOVA(l); + emitcode("lcall","__gptrput"); + break; + } + emitcode ("inc","%s",rname); + } + + MOVA(l); + + /* last last was not complete */ + if (rLen) { + /* save the byte & read byte */ + switch (p_type) { + case POINTER: + emitcode ("mov","b,a"); + emitcode("mov","a,@%s",rname); + break; + + case FPOINTER: + emitcode ("mov","b,a"); + emitcode("movx","a,@dptr"); + break; + + case GPOINTER: + emitcode ("push","b"); + emitcode ("push","acc"); + emitcode ("lcall","__gptrget"); + emitcode ("pop","b"); + break; + } + + emitcode ("anl","a,#0x%02x",((unsigned char)-1 << -rLen) ); + emitcode ("orl","a,b"); + } + + if (p_type == GPOINTER) + emitcode("pop","b"); + + switch (p_type) { + + case POINTER: + emitcode("mov","@%s,a",rname); + break; + + case FPOINTER: + emitcode("movx","@dptr,a"); + break; + + case GPOINTER: + emitcode("lcall","__gptrput"); + break; + } +} +/*-----------------------------------------------------------------*/ +/* genDataPointerSet - remat pointer to data space */ +/*-----------------------------------------------------------------*/ +static void genDataPointerSet(operand *right, + operand *result, + iCode *ic) +{ + int size, offset = 0 ; + char *l, buffer[256]; + + aopOp(right,ic,FALSE); + + l = aopGet(AOP(result),0,FALSE,TRUE); + size = AOP_SIZE(right); + while (size--) { + if (offset) + sprintf(buffer,"(%s + %d)",l+1,offset); + else + sprintf(buffer,"%s",l+1); + emitcode("mov","%s,%s",buffer, + aopGet(AOP(right),offset++,FALSE,FALSE)); + } + + freeAsmop(right,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genNearPointerSet - emitcode for near pointer put */ +/*-----------------------------------------------------------------*/ +static void genNearPointerSet (operand *right, + operand *result, + iCode *ic) +{ + asmop *aop = NULL; + regs *preg = NULL ; + char *rname , *l; + link *retype; + link *ptype = operandType(result); + + retype= getSpec(operandType(right)); + + aopOp(result,ic,FALSE); + + /* if the result is rematerializable & + in data space & not a bit variable */ + if (AOP_TYPE(result) == AOP_IMMD && + DCL_TYPE(ptype) == POINTER && + !IS_BITVAR(retype)) { + genDataPointerSet (right,result,ic); + return; + } + + /* if the value is already in a pointer register + then don't need anything more */ + if (!AOP_INPREG(AOP(result))) { + /* otherwise get a free pointer register */ + aop = newAsmop(0); + preg = getFreePtr(ic,&aop,FALSE); + emitcode("mov","%s,%s", + preg->name, + aopGet(AOP(result),0,FALSE,TRUE)); + rname = preg->name ; + } else + rname = aopGet(AOP(result),0,FALSE,FALSE); + + freeAsmop(result,NULL,ic,TRUE); + aopOp (right,ic,FALSE); + + /* if bitfield then unpack the bits */ + if (IS_BITVAR(retype)) + genPackBits (retype,right,rname,POINTER); + else { + /* we have can just get the values */ + int size = AOP_SIZE(right); + int offset = 0 ; + + while (size--) { + l = aopGet(AOP(right),offset,FALSE,TRUE); + if (*l == '@' ) { + MOVA(l); + emitcode("mov","@%s,a",rname); + } else + emitcode("mov","@%s,%s",rname,l); + if (size) + emitcode("inc","%s",rname); + offset++; + } + } + + /* now some housekeeping stuff */ + if (aop) { + /* we had to allocate for this iCode */ + freeAsmop(NULL,aop,ic,TRUE); + } else { + /* we did not allocate which means left + already in a pointer register, then + if size > 0 && this could be used again + we have to point it back to where it + belongs */ + if (AOP_SIZE(right) > 1 && + !OP_SYMBOL(result)->remat && + ( OP_SYMBOL(result)->liveTo > ic->seq || + ic->depth )) { + int size = AOP_SIZE(right) - 1; + while (size--) + emitcode("dec","%s",rname); + } + } + + /* done */ + freeAsmop(right,NULL,ic,TRUE); + + +} + +/*-----------------------------------------------------------------*/ +/* genPagedPointerSet - emitcode for Paged pointer put */ +/*-----------------------------------------------------------------*/ +static void genPagedPointerSet (operand *right, + operand *result, + iCode *ic) +{ + asmop *aop = NULL; + regs *preg = NULL ; + char *rname , *l; + link *retype; + + retype= getSpec(operandType(right)); + + aopOp(result,ic,FALSE); + + /* if the value is already in a pointer register + then don't need anything more */ + if (!AOP_INPREG(AOP(result))) { + /* otherwise get a free pointer register */ + aop = newAsmop(0); + preg = getFreePtr(ic,&aop,FALSE); + emitcode("mov","%s,%s", + preg->name, + aopGet(AOP(result),0,FALSE,TRUE)); + rname = preg->name ; + } else + rname = aopGet(AOP(result),0,FALSE,FALSE); + + freeAsmop(result,NULL,ic,TRUE); + aopOp (right,ic,FALSE); + + /* if bitfield then unpack the bits */ + if (IS_BITVAR(retype)) + genPackBits (retype,right,rname,PPOINTER); + else { + /* we have can just get the values */ + int size = AOP_SIZE(right); + int offset = 0 ; + + while (size--) { + l = aopGet(AOP(right),offset,FALSE,TRUE); + + MOVA(l); + emitcode("movx","@%s,a",rname); + + if (size) + emitcode("inc","%s",rname); + + offset++; + } + } + + /* now some housekeeping stuff */ + if (aop) { + /* we had to allocate for this iCode */ + freeAsmop(NULL,aop,ic,TRUE); + } else { + /* we did not allocate which means left + already in a pointer register, then + if size > 0 && this could be used again + we have to point it back to where it + belongs */ + if (AOP_SIZE(right) > 1 && + !OP_SYMBOL(result)->remat && + ( OP_SYMBOL(result)->liveTo > ic->seq || + ic->depth )) { + int size = AOP_SIZE(right) - 1; + while (size--) + emitcode("dec","%s",rname); + } + } + + /* done */ + freeAsmop(right,NULL,ic,TRUE); + + +} + +/*-----------------------------------------------------------------*/ +/* genFarPointerSet - set value from far space */ +/*-----------------------------------------------------------------*/ +static void genFarPointerSet (operand *right, + operand *result, iCode *ic) +{ + int size, offset ; + link *retype = getSpec(operandType(right)); + + aopOp(result,ic,FALSE); + + /* if the operand is already in dptr + then we do nothing else we move the value to dptr */ + if (AOP_TYPE(result) != AOP_STR) { + /* if this is remateriazable */ + if (AOP_TYPE(result) == AOP_IMMD) + emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE)); + else { /* we need to get it byte by byte */ + emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE)); + emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE)); + } + } + /* so dptr know contains the address */ + freeAsmop(result,NULL,ic,TRUE); + aopOp(right,ic,FALSE); + + /* if bit then unpack */ + if (IS_BITVAR(retype)) + genPackBits(retype,right,"dptr",FPOINTER); + else { + size = AOP_SIZE(right); + offset = 0 ; + + while (size--) { + char *l = aopGet(AOP(right),offset++,FALSE,FALSE); + MOVA(l); + emitcode("movx","@dptr,a"); + if (size) + emitcode("inc","dptr"); + } + } + + freeAsmop(right,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genGenPointerSet - set value from generic pointer space */ +/*-----------------------------------------------------------------*/ +static void genGenPointerSet (operand *right, + operand *result, iCode *ic) +{ + int size, offset ; + link *retype = getSpec(operandType(right)); + + aopOp(result,ic,FALSE); + + /* if the operand is already in dptr + then we do nothing else we move the value to dptr */ + if (AOP_TYPE(result) != AOP_STR) { + /* if this is remateriazable */ + if (AOP_TYPE(result) == AOP_IMMD) { + emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE)); + emitcode("mov","b,%s + 1",aopGet(AOP(result),0,TRUE,FALSE)); + } + else { /* we need to get it byte by byte */ + emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE)); + emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE)); + emitcode("mov","b,%s",aopGet(AOP(result),2,FALSE,FALSE)); + } + } + /* so dptr know contains the address */ + freeAsmop(result,NULL,ic,TRUE); + aopOp(right,ic,FALSE); + + /* if bit then unpack */ + if (IS_BITVAR(retype)) + genPackBits(retype,right,"dptr",GPOINTER); + else { + size = AOP_SIZE(right); + offset = 0 ; + + while (size--) { + char *l = aopGet(AOP(right),offset++,FALSE,FALSE); + MOVA(l); + emitcode("lcall","__gptrput"); + if (size) + emitcode("inc","dptr"); + } + } + + freeAsmop(right,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genPointerSet - stores the value into a pointer location */ +/*-----------------------------------------------------------------*/ +static void genPointerSet (iCode *ic) +{ + operand *right, *result ; + link *type, *etype; + int p_type; + + right = IC_RIGHT(ic); + result = IC_RESULT(ic) ; + + /* depending on the type of pointer we need to + move it to the correct pointer register */ + type = operandType(result); + etype = getSpec(type); + /* if left is of type of pointer then it is simple */ + if (IS_PTR(type) && !IS_FUNC(type->next)) { + p_type = DCL_TYPE(type); + } + else { + + /* we have to go by the storage class */ + if (SPEC_OCLS(etype)->codesp ) { + p_type = CPOINTER ; + } + else + if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) + p_type = FPOINTER ; + else + if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) + p_type = PPOINTER ; + else + if (SPEC_OCLS(etype) == idata ) + p_type = IPOINTER ; + else + p_type = POINTER ; + } + + /* now that we have the pointer type we assign + the pointer values */ + switch (p_type) { + + case POINTER: + case IPOINTER: + genNearPointerSet (right,result,ic); + break; + + case PPOINTER: + genPagedPointerSet (right,result,ic); + break; + + case FPOINTER: + genFarPointerSet (right,result,ic); + break; + + case GPOINTER: + genGenPointerSet (right,result,ic); + break; + } + +} + +/*-----------------------------------------------------------------*/ +/* genIfx - generate code for Ifx statement */ +/*-----------------------------------------------------------------*/ +static void genIfx (iCode *ic, iCode *popIc) +{ + operand *cond = IC_COND(ic); + int isbit =0; + + aopOp(cond,ic,FALSE); + + /* get the value into acc */ + if (AOP_TYPE(cond) != AOP_CRY) + toBoolean(cond); + else + isbit = 1; + /* the result is now in the accumulator */ + freeAsmop(cond,NULL,ic,TRUE); + + /* if there was something to be popped then do it */ + if (popIc) + genIpop(popIc); + + /* if the condition is a bit variable */ + if (isbit && IS_ITEMP(cond) && + SPIL_LOC(cond)) + genIfxJump(ic,SPIL_LOC(cond)->rname); + else + if (isbit && !IS_ITEMP(cond)) + genIfxJump(ic,OP_SYMBOL(cond)->rname); + else + genIfxJump(ic,"a"); + + ic->generated = 1; +} + +/*-----------------------------------------------------------------*/ +/* genAddrOf - generates code for address of */ +/*-----------------------------------------------------------------*/ +static void genAddrOf (iCode *ic) +{ + symbol *sym = OP_SYMBOL(IC_LEFT(ic)); + int size, offset ; + + aopOp(IC_RESULT(ic),ic,FALSE); + + /* if the operand is on the stack then we + need to get the stack offset of this + variable */ + if (sym->onStack) { + /* if it has an offset then we need to compute + it */ + if (sym->stack) { + emitcode("mov","a,_bp"); + emitcode("add","a,#0x%02x",((char) sym->stack & 0xff)); + aopPut(AOP(IC_RESULT(ic)),"a",0); + } else + /* we can just move _bp */ + aopPut(AOP(IC_RESULT(ic)),"_bp",0); + /* fill the result with zero */ + size = AOP_SIZE(IC_RESULT(ic)) - 1; + offset = 1; + while (size--) + aopPut(AOP(IC_RESULT(ic)),zero,offset++); + + goto release; + } + + /* object not on stack then we need the name */ + size = AOP_SIZE(IC_RESULT(ic)); + offset = 0; + + while (size--) { + char s[SDCC_NAME_MAX]; + if (offset) + sprintf(s,"#(%s >> %d)", + sym->rname, + offset*8); + else + sprintf(s,"#%s",sym->rname); + aopPut(AOP(IC_RESULT(ic)),s,offset++); + } + +release: + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); + +} + +/*-----------------------------------------------------------------*/ +/* genFarFarAssign - assignment when both are in far space */ +/*-----------------------------------------------------------------*/ +static void genFarFarAssign (operand *result, operand *right, iCode *ic) +{ + int size = AOP_SIZE(right); + int offset = 0; + char *l ; + /* first push the right side on to the stack */ + while (size--) { + l = aopGet(AOP(right),offset++,FALSE,FALSE); + MOVA(l); + emitcode ("push","acc"); + } + + freeAsmop(right,NULL,ic,FALSE); + /* now assign DPTR to result */ + aopOp(result,ic,FALSE); + size = AOP_SIZE(result); + while (size--) { + emitcode ("pop","acc"); + aopPut(AOP(result),"a",--offset); + } + freeAsmop(result,NULL,ic,FALSE); + +} + +/*-----------------------------------------------------------------*/ +/* genAssign - generate code for assignment */ +/*-----------------------------------------------------------------*/ +static void genAssign (iCode *ic) +{ + operand *result, *right; + int size, offset ; + unsigned long lit = 0L; + + result = IC_RESULT(ic); + right = IC_RIGHT(ic) ; + + /* if they are the same */ + if (operandsEqu (IC_RESULT(ic),IC_RIGHT(ic))) + return ; + + aopOp(right,ic,FALSE); + + /* special case both in far space */ + if (AOP_TYPE(right) == AOP_DPTR && + IS_TRUE_SYMOP(result) && + isOperandInFarSpace(result)) { + + genFarFarAssign (result,right,ic); + return ; + } + + aopOp(result,ic,TRUE); + + /* if they are the same registers */ + if (sameRegs(AOP(right),AOP(result))) + goto release; + + /* if the result is a bit */ + if (AOP_TYPE(result) == AOP_CRY) { + + /* if the right size is a literal then + we know what the value is */ + if (AOP_TYPE(right) == AOP_LIT) { + if (((int) operandLitValue(right))) + aopPut(AOP(result),one,0); + else + aopPut(AOP(result),zero,0); + goto release; + } + + /* the right is also a bit variable */ + if (AOP_TYPE(right) == AOP_CRY) { + emitcode("mov","c,%s",AOP(right)->aopu.aop_dir); + aopPut(AOP(result),"c",0); + goto release ; + } + + /* we need to or */ + toBoolean(right); + aopPut(AOP(result),"a",0); + goto release ; + } + + /* bit variables done */ + /* general case */ + size = AOP_SIZE(result); + offset = 0 ; + if(AOP_TYPE(right) == AOP_LIT) + lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit); + if((size > 1) && + (AOP_TYPE(result) != AOP_REG) && + (AOP_TYPE(right) == AOP_LIT) && + !IS_FLOAT(operandType(right)) && + (lit < 256L)){ + emitcode("clr","a"); + while (size--) { + if((unsigned int)((lit >> (size*8)) & 0x0FFL)== 0) + aopPut(AOP(result),"a",size); + else + aopPut(AOP(result), + aopGet(AOP(right),size,FALSE,FALSE), + size); + } + } else { + while (size--) { + aopPut(AOP(result), + aopGet(AOP(right),offset,FALSE,FALSE), + offset); + offset++; + } + } + +release: + freeAsmop (right,NULL,ic,FALSE); + freeAsmop (result,NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* genJumpTab - genrates code for jump table */ +/*-----------------------------------------------------------------*/ +static void genJumpTab (iCode *ic) +{ + symbol *jtab; + char *l; + + aopOp(IC_JTCOND(ic),ic,FALSE); + /* get the condition into accumulator */ + l = aopGet(AOP(IC_JTCOND(ic)),0,FALSE,FALSE); + MOVA(l); + /* multiply by three */ + emitcode("add","a,acc"); + emitcode("add","a,%s",aopGet(AOP(IC_JTCOND(ic)),0,FALSE,FALSE)); + freeAsmop(IC_JTCOND(ic),NULL,ic,TRUE); + + jtab = newiTempLabel(NULL); + emitcode("mov","dptr,#%05d$",jtab->key+100); + emitcode("jmp","@a+dptr"); + emitcode("","%05d$:",jtab->key+100); + /* now generate the jump labels */ + for (jtab = setFirstItem(IC_JTLABELS(ic)) ; jtab; + jtab = setNextItem(IC_JTLABELS(ic))) + emitcode("ljmp","%05d$",jtab->key+100); + +} + +/*-----------------------------------------------------------------*/ +/* genCast - gen code for casting */ +/*-----------------------------------------------------------------*/ +static void genCast (iCode *ic) +{ + operand *result = IC_RESULT(ic); + link *ctype = operandType(IC_LEFT(ic)); + operand *right = IC_RIGHT(ic); + int size, offset ; + + /* if they are equivalent then do nothing */ + if (operandsEqu(IC_RESULT(ic),IC_RIGHT(ic))) + return ; + + aopOp(right,ic,FALSE) ; + aopOp(result,ic,FALSE); + + /* if the result is a bit */ + if (AOP_TYPE(result) == AOP_CRY) { + /* if the right size is a literal then + we know what the value is */ + if (AOP_TYPE(right) == AOP_LIT) { + if (((int) operandLitValue(right))) + aopPut(AOP(result),one,0); + else + aopPut(AOP(result),zero,0); + + goto release; + } + + /* the right is also a bit variable */ + if (AOP_TYPE(right) == AOP_CRY) { + emitcode("mov","c,%s",AOP(right)->aopu.aop_dir); + aopPut(AOP(result),"c",0); + goto release ; + } + + /* we need to or */ + toBoolean(right); + aopPut(AOP(result),"a",0); + goto release ; + } + + /* if they are the same size : or less */ + if (AOP_SIZE(result) <= AOP_SIZE(right)) { + + /* if they are in the same place */ + if (sameRegs(AOP(right),AOP(result))) + goto release; + + /* if they in different places then copy */ + size = AOP_SIZE(result); + offset = 0 ; + while (size--) { + aopPut(AOP(result), + aopGet(AOP(right),offset,FALSE,FALSE), + offset); + offset++; + } + goto release; + } + + + /* if the result is of type pointer */ + if (IS_PTR(ctype)) { + + int p_type; + link *type = operandType(right); + link *etype = getSpec(type); + + /* pointer to generic pointer */ + if (IS_GENPTR(ctype)) { + char *l = zero; + + if (IS_PTR(type)) + p_type = DCL_TYPE(type); + else { + /* we have to go by the storage class */ + if (SPEC_OCLS(etype)->codesp ) + p_type = CPOINTER ; + else + if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) + p_type = FPOINTER ; + else + if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) + p_type = PPOINTER; + else + if (SPEC_OCLS(etype) == idata ) + p_type = IPOINTER ; + else + p_type = POINTER ; + } + + /* the first two bytes are known */ + size = 2; + offset = 0 ; + while (size--) { + aopPut(AOP(result), + aopGet(AOP(right),offset,FALSE,FALSE), + offset); + offset++; + } + /* the last byte depending on type */ + switch (p_type) { + case IPOINTER: + case POINTER: + l = zero; + break; + case FPOINTER: + l = one; + break; + case CPOINTER: + l = "#0x02"; + break; + case PPOINTER: + l = "#0x03"; + break; + + default: + /* this should never happen */ + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "got unknown pointer type"); + exit(1); + } + aopPut(AOP(result),l,2); + goto release ; + } + + /* just copy the pointers */ + size = AOP_SIZE(result); + offset = 0 ; + while (size--) { + aopPut(AOP(result), + aopGet(AOP(right),offset,FALSE,FALSE), + offset); + offset++; + } + goto release ; + } + + /* so we now know that the size of destination is greater + than the size of the source */ + /* we move to result for the size of source */ + size = AOP_SIZE(right); + offset = 0 ; + while (size--) { + aopPut(AOP(result), + aopGet(AOP(right),offset,FALSE,FALSE), + offset); + offset++; + } + + /* now depending on the sign of the destination */ + size = AOP_SIZE(result) - AOP_SIZE(right); + /* if unsigned or not an integral type */ + if (SPEC_USIGN(ctype) || !IS_SPEC(ctype)) { + while (size--) + aopPut(AOP(result),zero,offset++); + } else { + /* we need to extend the sign :{ */ + char *l = aopGet(AOP(right),AOP_SIZE(right) - 1, + FALSE,FALSE); + MOVA(l); + emitcode("rlc","a"); + emitcode("subb","a,acc"); + while (size--) + aopPut(AOP(result),"a",offset++); + } + + /* we are done hurray !!!! */ + +release: + freeAsmop(right,NULL,ic,TRUE); + freeAsmop(result,NULL,ic,TRUE); + +} + +/*-----------------------------------------------------------------*/ +/* genDjnz - generate decrement & jump if not zero instrucion */ +/*-----------------------------------------------------------------*/ +static int genDjnz (iCode *ic, iCode *ifx) +{ + symbol *lbl, *lbl1; + if (!ifx) + return 0; + + /* if the if condition has a false label + then we cannot save */ + if (IC_FALSE(ifx)) + return 0; + + /* if the minus is not of the form + a = a - 1 */ + if (!isOperandEqual(IC_RESULT(ic),IC_LEFT(ic)) || + !IS_OP_LITERAL(IC_RIGHT(ic))) + return 0; + + if (operandLitValue(IC_RIGHT(ic)) != 1) + return 0; + + /* if the size of this greater than one then no + saving */ + if (getSize(operandType(IC_RESULT(ic))) > 1) + return 0; + + /* otherwise we can save BIG */ + lbl = newiTempLabel(NULL); + lbl1= newiTempLabel(NULL); + + aopOp(IC_RESULT(ic),ic,FALSE); + + if (IS_AOP_PREG(IC_RESULT(ic))) { + emitcode("dec","%s", + aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE)); + emitcode("mov","a,%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE)); + emitcode("jnz","%05d$",lbl->key+100); + } else { + emitcode ("djnz","%s,%05d$",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE), + lbl->key+100); + } + emitcode ("sjmp","%05d$",lbl1->key+100); + emitcode ("","%05d$:",lbl->key+100); + emitcode ("ljmp","%05d$",IC_TRUE(ifx)->key+100); + emitcode ("","%05d$:",lbl1->key+100); + + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); + ifx->generated = 1; + return 1; +} + +/*-----------------------------------------------------------------*/ +/* genReceive - generate code for a receive iCode */ +/*-----------------------------------------------------------------*/ +static void genReceive (iCode *ic) +{ + if (isOperandInFarSpace(IC_RESULT(ic)) && + ( OP_SYMBOL(IC_RESULT(ic))->isspilt || + IS_TRUE_SYMOP(IC_RESULT(ic))) ) { + + int size = getSize(operandType(IC_RESULT(ic))); + int offset = 4 - size; + while (size--) { + emitcode ("push","%s", (strcmp(fReturn[3 - offset],"a") ? + fReturn[3 - offset] : "acc")); + offset++; + } + aopOp(IC_RESULT(ic),ic,FALSE); + size = AOP_SIZE(IC_RESULT(ic)); + offset = 0; + while (size--) { + emitcode ("pop","acc"); + aopPut (AOP(IC_RESULT(ic)),"a",offset++); + } + + } else { + accInUse++; + aopOp(IC_RESULT(ic),ic,FALSE); + accInUse--; + assignResultValue(IC_RESULT(ic)); + } + + freeAsmop(IC_RESULT(ic),NULL,ic,TRUE); +} + +/*-----------------------------------------------------------------*/ +/* gen51Code - generate code for 8051 based controllers */ +/*-----------------------------------------------------------------*/ +void gen51Code (iCode *lic) +{ + iCode *ic; + int cln = 0; + + lineHead = lineCurr = NULL; + + /* if debug information required */ +/* if (options.debug && currFunc) { */ + if (currFunc) { + cdbSymbol(currFunc,cdbFile,FALSE,TRUE); + debugLine = 1; + if (IS_STATIC(currFunc->etype)) + emitcode("","F%s$%s$0$0 ==.",moduleName,currFunc->name); + else + emitcode("","G$%s$0$0 ==.",currFunc->name); + debugLine = 0; + } + /* stack pointer name */ + if (options.useXstack) + spname = "_spx"; + else + spname = "sp"; + + + for (ic = lic ; ic ; ic = ic->next ) { + + if ( cln != ic->lineno ) { + if ( options.debug ) { + debugLine = 1; + emitcode("","C$%s$%d$%d$%d ==.", + ic->filename,ic->lineno, + ic->level,ic->block); + debugLine = 0; + } + emitcode(";","%s %d",ic->filename,ic->lineno); + cln = ic->lineno ; + } + /* if the result is marked as + spilt and rematerializable or code for + this has already been generated then + do nothing */ + if (resultRemat(ic) || ic->generated ) + continue ; + + /* depending on the operation */ + switch (ic->op) { + case '!' : + genNot(ic); + break; + + case '~' : + genCpl(ic); + break; + + case UNARYMINUS: + genUminus (ic); + break; + + case IPUSH: + genIpush (ic); + break; + + case IPOP: + /* IPOP happens only when trying to restore a + spilt live range, if there is an ifx statement + following this pop then the if statement might + be using some of the registers being popped which + would destory the contents of the register so + we need to check for this condition and handle it */ + if (ic->next && + ic->next->op == IFX && + regsInCommon(IC_LEFT(ic),IC_COND(ic->next))) + genIfx (ic->next,ic); + else + genIpop (ic); + break; + + case CALL: + genCall (ic); + break; + + case PCALL: + genPcall (ic); + break; + + case FUNCTION: + genFunction (ic); + break; + + case ENDFUNCTION: + genEndFunction (ic); + break; + + case RETURN: + genRet (ic); + break; + + case LABEL: + genLabel (ic); + break; + + case GOTO: + genGoto (ic); + break; + + case '+' : + genPlus (ic) ; + break; + + case '-' : + if ( ! genDjnz (ic,ifxForOp(IC_RESULT(ic),ic))) + genMinus (ic); + break; + + case '*' : + genMult (ic); + break; + + case '/' : + genDiv (ic) ; + break; + + case '%' : + genMod (ic); + break; + + case '>' : + genCmpGt (ic,ifxForOp(IC_RESULT(ic),ic)); + break; + + case '<' : + genCmpLt (ic,ifxForOp(IC_RESULT(ic),ic)); + break; + + case LE_OP: + case GE_OP: + case NE_OP: + + /* note these two are xlated by algebraic equivalence + during parsing SDCC.y */ + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "got '>=' or '<=' shouldn't have come here"); + break; + + case EQ_OP: + genCmpEq (ic,ifxForOp(IC_RESULT(ic),ic)); + break; + + case AND_OP: + genAndOp (ic); + break; + + case OR_OP: + genOrOp (ic); + break; + + case '^' : + genXor (ic,ifxForOp(IC_RESULT(ic),ic)); + break; + + case '|' : + genOr (ic,ifxForOp(IC_RESULT(ic),ic)); + break; + + case BITWISEAND: + genAnd (ic,ifxForOp(IC_RESULT(ic),ic)); + break; + + case INLINEASM: + genInline (ic); + break; + + case RRC: + genRRC (ic); + break; + + case RLC: + genRLC (ic); + break; + + case GETHBIT: + genGetHbit (ic); + break; + + case LEFT_OP: + genLeftShift (ic); + break; + + case RIGHT_OP: + genRightShift (ic); + break; + + case GET_VALUE_AT_ADDRESS: + genPointerGet(ic); + break; + + case '=' : + if (POINTER_SET(ic)) + genPointerSet(ic); + else + genAssign(ic); + break; + + case IFX: + genIfx (ic,NULL); + break; + + case ADDRESS_OF: + genAddrOf (ic); + break; + + case JUMPTABLE: + genJumpTab (ic); + break; + + case CAST: + genCast (ic); + break; + + case RECEIVE: + genReceive(ic); + break; + + case SEND: + addSet(&sendSet,ic); + break; + + default : + ic = ic; + /* piCode(ic,stdout); */ + + } + } + + + /* now we are ready to call the + peep hole optimizer */ + if (!options.nopeep) + peepHole (&lineHead); + + /* now do the actual printing */ + printLine (lineHead,codeOutFile); + return; +} diff --git a/src/SDCCgen51.h b/src/SDCCgen51.h new file mode 100644 index 00000000..3c56dcfd --- /dev/null +++ b/src/SDCCgen51.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------- + SDCCgen51.h - header file for code generation for 8051 + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCCGEN51_H +#define SDCCGEN51_H + +enum { + AOP_LIT = 1, + AOP_REG, AOP_DIR, + AOP_DPTR,AOP_R0,AOP_R1, + AOP_STK ,AOP_IMMD, AOP_STR, + AOP_CRY, AOP_ACC }; + +/* type asmop : a homogenised type for + all the different spaces an operand can be + in */ +typedef struct asmop { + + short type ; /* can have values + AOP_LIT - operand is a literal value + AOP_REG - is in registers + AOP_DIR - direct just a name + AOP_DPTR - dptr contains address of operand + AOP_R0/R1 - r0/r1 contains address of operand + AOP_STK - should be pushed on stack this + can happen only for the result + AOP_IMMD - immediate value for eg. remateriazable + AOP_CRY - carry contains the value of this + AOP_STR - array of strings + AOP_ACC - result is in the acc:b pair + */ + short coff ; /* current offset */ + short size ; /* total size */ + unsigned code :1 ; /* is in Code space */ + unsigned paged:1 ; /* in paged memory */ + unsigned freed:1 ; /* already freed */ + union { + value *aop_lit ; /* if literal */ + regs *aop_reg[4]; /* array of registers */ + char *aop_dir ; /* if direct */ + regs *aop_ptr ; /* either -> to r0 or r1 */ + char *aop_immd; /* if immediate others are implied */ + int aop_stk ; /* stack offset when AOP_STK */ + char *aop_str[4]; /* just a string array containing the location */ + } aopu; +} asmop; + +void gen51Code (iCode *); + + +#endif diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h new file mode 100644 index 00000000..62068c3e --- /dev/null +++ b/src/SDCCglobl.h @@ -0,0 +1,229 @@ +/* SDCCglobl.h - global macros etc required by all files */ +#ifndef SDCCGLOBL_H +#define SDCCGLOBL_H +#include +#include +#include +#include +#include "sdccconf.h" +#include "SDCCerr.h" + +#ifdef _NO_GC + +#define GC_malloc malloc +#define GC_free free +#define GC_realloc realloc +#define GC_malloc_atomic malloc +#else + +#include "./gc/gc.h" + +#endif + +#define SPACE ' ' +#define ZERO 0 + +#define MAX_FNAME_LEN 128 +#define MAX_REG_PARMS 1 +typedef int bool; + +#ifndef max +#define max(a,b) (a > b ? a : b) +#endif + +#ifndef min +#define min(a,b) (a < b ? a : b) +#endif + +#ifndef THROWS +#define THROWS +#define THROW_NONE 0 +#define THROW_SRC 1 +#define THROW_DEST 2 +#define THROW_BOTH 3 +#endif + +/* size's in bytes */ +#define CHARSIZE 1 +#define SHORTSIZE 1 +#define INTSIZE 2 +#define LONGSIZE 4 +#define PTRSIZE 1 +#define FPTRSIZE 2 +#define GPTRSIZE 3 +#define BITSIZE 1 +#define FLOATSIZE 4 +#define MAXBASESIZE 4 + + +#define PRAGMA_SAVE "SAVE" +#define PRAGMA_RESTORE "RESTORE" +#define PRAGMA_NOINDUCTION "NOINDUCTION" +#define PRAGMA_NOINVARIANT "NOINVARIANT" +#define PRAGMA_NOLOOPREV "NOLOOPREVERSE" +#define PRAGMA_INDUCTION "INDUCTION" +#define PRAGMA_STACKAUTO "STACKAUTO" +#define PRAGMA_NOJTBOUND "NOJTBOUND" +#define PRAGMA_NOGCSE "NOGCSE" +#define PRAGMA_NOOVERLAY "NOOVERLAY" +#define PRAGMA_CALLEESAVES "CALLEE-SAVES" +#define PRAGMA_EXCLUDE "EXCLUDE" +#define PRAGMA_NOREGPARMS "NOREGPARMS" +#define SMALL_MODEL 0 +#define LARGE_MODEL 1 +#define TRUE 1 +#define FALSE 0 + +#define MAX_TVAR 6 +#define MAX_INLINEASM 4*1024 +#define DEFPOOLSTACK(type,size) \ + type *type##Pool ; \ + type *type##FreeStack [size] ; \ + int type##StackPtr = 0 ; + +#define ALLOCTYPE(type,size) if (!(type##Pool = GC_malloc(size*sizeof(type)))) \ + { \ + werror(E_OUT_OF_MEM,__FILE__,(long) size); \ + exit (1); \ + } + +#define PUSH(x,y) x##FreeStack[x##StackPtr++] = y +#define PEEK(x) x##FreeStack[x##StackPtr-1] +#define POP(type) type##FreeStack[--type##StackPtr] +/* #define POP(x) (x##StackPtr ? x##FreeStack[--x##StackPtr] : \ + (assert(x##StackPtr),0)) */ +#ifdef UNIX +#define EMPTY(x) (x##StackPtr <= 1 ? 1 : 0) +#else +#define EMPTY(x) (x##StackPtr == 0 ? 1 : 0) +#endif + +#define ALLOC(x,sz) if (!(x = GC_malloc(sz))) \ + { \ + werror(E_OUT_OF_MEM,__FILE__,(long) sz);\ + exit (1); \ + } + +#define ALLOC_ATOMIC(x,sz) if (!(x = GC_malloc_atomic(sz))) \ + { \ + werror(E_OUT_OF_MEM,__FILE__,(long) sz); \ + exit (1); \ + } + +#define COPYTYPE(start,end,from) (end = getSpec (start = from)) + + +/* generalpurpose stack related macros */ +#define STACK_DCL(stack,type,size) \ + typedef type t_##stack ; \ + t_##stack stack[size] ; \ + t_##stack (*p_##stack) = stack + (size); \ + +/* define extern stack */ +#define EXTERN_STACK_DCL(stack,type,size) \ + typedef type t_##stack ; \ + extern t_##stack stack[size] ; \ + extern t_##stack *p_##stack; + +#define STACK_FULL(stack) ((p_##stack) <= stack ) +#define STACK_EMPTY(stack) ((p_##stack) >= (stack + \ + sizeof(stack)/sizeof(*stack)) ) + +#define STACK_PUSH_(stack,x) (*--p_##stack = (x)) +#define STACK_POP_(stack) (*p_##stack++) + +#define STACK_PUSH(stack,x) (STACK_FULL(stack) \ + ?((t_##stack)(long)(STACK_ERR(1))) \ + : STACK_PUSH_(stack,x) ) + +#define STACK_POP(stack) (STACK_EMPTY(stack) \ + ?((t_##stack)(long)(STACK_ERR(0))) \ + : STACK_POP_(stack) ) + +#define STACK_PEEK(stack) (STACK_EMPTY(stack) \ + ?((t_##stack) NULL) \ + : *p_##stack ) + +#define STACK_ERR(o) ( o \ + ? fprintf(stderr,"stack Overflow\n")\ + : fprintf(stderr,"stack underflow\n")) + +/* optimization options */ +struct optimize { + unsigned global_cse : 1 ; + unsigned ptrArithmetic :1; + unsigned label1 : 1 ; + unsigned label2 : 1 ; + unsigned label3 : 1 ; + unsigned label4 : 1 ; + unsigned loopInvariant: 1; + unsigned loopInduction: 1; + unsigned noJTabBoundary:1; + unsigned noLoopReverse :1; +} ; + +/* other command line options */ +struct options { + int model : 1 ; /* LARGE == 1 */ + int stackAuto : 3 ; /* Stack Automatic */ + int useXstack : 3 ; /* use Xternal Stack */ + int genericPtr: 1 ; /* use generic pointers */ + int regExtend : 1 ; /* don't use extended registers */ + int dump_raw : 1 ; /* dump after intermediate code generation */ + int dump_gcse : 1 ; /* dump after gcse */ + int dump_loop : 1 ; /* dump after loop optimizations */ + int dump_kill : 1 ; /* dump after dead code elimination */ + int dump_range: 1 ; /* dump after live range analysis */ + int dump_pack : 1 ; /* dump after register packing */ + int dump_rassgn:1 ; /* dump after register assignment */ + int cc_only : 1 ; /* compile only flag */ + int intlong_rent:1 ; /* integer & long support routines reentrant */ + int float_rent: 1 ; /* floating point routines are reentrant */ + int out_fmt : 1 ; /* 1 = motorola S19 format 0 = intel Hex format */ + int cyclomatic: 1 ; /* print cyclomatic information */ + int noOverlay : 1 ; /* don't overlay local variables & parameters */ + int mainreturn: 1 ; /* issue a return after main */ + int nopeep : 1 ; /* no peep hole optimization */ + int asmpeep : 1 ; /* pass inline assembler thru peep hole */ + int debug : 1 ; /* generate extra debug info */ + int stackOnData:1 ; /* stack after data segment */ + int noregparms: 1 ; /* do not pass parameters in registers */ + char *peep_file ; /* additional rules for peep hole */ + + char *calleeSaves[128]; /* list of functions using callee save */ + char *excludeRegs[32] ; /* registers excluded from saving */ + + /* starting address of the segments */ + int xstack_loc ; /* initial location of external stack */ + int stack_loc ; /* initial value of internal stack pointer */ + int xdata_loc ; /* xternal ram starts at address */ + int data_loc ; /* interram start location */ + int idata_loc ; /* indirect address space */ + int code_loc ; /* code location start */ + int iram_size ; /* internal ram size (used only for error checking) */ +} ; + +/* forward definition for variables accessed globally */ +extern char *currFname ; +extern char *srcFileName; /* source file name without the extenstion */ +extern char *moduleName ; /* source file name without path & extension */ +extern int currLineno ; /* current line number */ +extern int yylineno ; /* line number of the current file SDCC.lex */ +extern FILE *yyin ; /* */ +extern FILE *asmFile ; /* assembly output file */ +extern FILE *cdbFile ; /* debugger symbol file */ +extern int NestLevel ; /* NestLevel SDCC.y */ +extern int stackPtr ; /* stack pointer SDCC.y */ +extern int xstackPtr ; /* external stack pointer SDCC.y */ +extern int reentrant ; /* /X flag has been sent SDCC.y */ +extern char buffer[] ;/* general buffer SDCCgen.c */ +extern int currRegBank; /* register bank being used SDCCgens.c */ +extern struct symbol *currFunc; /* current function SDCCgens.c */ +extern int cNestLevel; /* block nest level SDCCval.c */ +extern int currBlockno; /* sequentail block number */ +extern struct optimize optimize ; +extern struct options options; +extern int maxInterrupts; +void parseWithComma (char **,char *) ; + +#endif diff --git a/src/SDCCglue.c b/src/SDCCglue.c new file mode 100644 index 00000000..a5d1e194 --- /dev/null +++ b/src/SDCCglue.c @@ -0,0 +1,1022 @@ +/*------------------------------------------------------------------------- + + SDCCglue.c - glues everything we have done together into one file. + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCCmem.h" +#include "SDCCval.h" +#include "SDCCast.h" +#include "SDCChasht.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCCopt.h" +#include "SDCCy.h" +#include "SDCCglue.h" + +symbol *interrupts[256]; +extern char *aopLiteral (value *, int); +void printIval (symbol *, link *, initList *, FILE *); +extern int noAlloc; +set *publics = NULL; /* public variables */ +int maxInterrupts = 6; +extern int maxRegBank ; +symbol *mainf; +extern char *VersionString; +extern FILE *codeOutFile; +set *tmpfileSet = NULL; /* set of tmp file created by the compiler */ +/*-----------------------------------------------------------------*/ +/* closeTmpFiles - closes all tmp files created by the compiler */ +/* because of BRAIN DEAD MS/DOS & CYGNUS Libraries */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(closeTmpFiles) +{ + FILE *tfile = item; + + if (tfile) + fclose(tfile); + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* copyFile - copies source file to destination file */ +/*-----------------------------------------------------------------*/ +void copyFile (FILE * dest, FILE * src) +{ + int ch; + + rewind (src); + while (!feof (src)) + if ((ch = fgetc (src)) != EOF) + fputc (ch, dest); +} + +/*-----------------------------------------------------------------*/ +/* emitRegularMap - emit code for maps with no special cases */ +/*-----------------------------------------------------------------*/ +static void emitRegularMap (memmap * map, bool addPublics, bool arFlag) +{ + symbol *sym; + + if (addPublics) + fprintf (map->oFile, "\t.area\t%s\n", map->sname); + + /* print the area name */ + for (sym = setFirstItem (map->syms); sym; + sym = setNextItem (map->syms)) { + + /* if extern then do nothing */ + if (IS_EXTERN (sym->etype)) + continue; + + /* if allocation required check is needed + then check if the symbol really requires + allocation only for local variables */ + if (arFlag && !IS_AGGREGATE(sym->type) && + !(sym->_isparm && !IS_REGPARM(sym->etype)) && + !sym->allocreq && sym->level) + continue ; + + /* if global variable & not static or extern + and addPublics allowed then add it to the public set */ + if ((sym->level == 0 || + (sym->_isparm && !IS_REGPARM(sym->etype))) && + addPublics && + !IS_STATIC (sym->etype)) + addSetHead (&publics, sym); + + /* if extern then do nothing or is a function + then do nothing */ + if (IS_FUNC (sym->type)) + continue; + + /* print extra debug info if required */ + if (options.debug || sym->level == 0) { + + cdbSymbol(sym,cdbFile,FALSE,FALSE); + + if (!sym->level) /* global */ + if (IS_STATIC(sym->etype)) + fprintf(map->oFile,"F%s$",moduleName); /* scope is file */ + else + fprintf(map->oFile,"G$"); /* scope is global */ + else + /* symbol is local */ + fprintf(map->oFile,"L%s$",(sym->localof ? sym->localof->name : "-null-")); + fprintf(map->oFile,"%s$%d$%d",sym->name,sym->level,sym->block); + } + + /* if is has an absolute address then generate + an equate for this no need to allocate space */ + if (SPEC_ABSA (sym->etype)) { + if (options.debug || sym->level == 0) + fprintf (map->oFile," == 0x%04x\n",SPEC_ADDR (sym->etype)); + + fprintf (map->oFile, "%s\t=\t0x%04x\n", + sym->rname, + SPEC_ADDR (sym->etype)); + } + else { + /* allocate space */ + if (options.debug || sym->level == 0) + fprintf(map->oFile,"==.\n"); + fprintf (map->oFile, "%s:\n", sym->rname); + fprintf (map->oFile, "\t.ds\t0x%04x\n", (unsigned int)getSize (sym->type) & 0xffff); + } + + /* if it has a initial value then do it only if + it is a global variable */ + if (sym->ival && sym->level == 0) { + ast *ival = NULL; + + if (IS_AGGREGATE (sym->type)) + ival = initAggregates (sym, sym->ival, NULL); + else + ival = newNode ('=', newAst (EX_VALUE, symbolVal (sym)), + decorateType (resolveSymbols (list2expr (sym->ival)))); + codeOutFile = statsg->oFile; + eBBlockFromiCode (iCodeFromAst (ival)); + sym->ival = NULL; + } + } +} + + +/*-----------------------------------------------------------------*/ +/* initPointer - pointer initialization code massaging */ +/*-----------------------------------------------------------------*/ +value *initPointer (initList *ilist) +{ + value *val; + ast *expr = list2expr(ilist); + + if (!expr) + goto wrong; + + /* try it the oldway first */ + if ((val = constExprValue(expr,FALSE))) + return val; + + /* no then we have to do these cludgy checks */ + /* pointers can be initialized with address of + a variable or address of an array element */ + if (IS_AST_OP(expr) && expr->opval.op == '&') { + /* address of symbol */ + if (IS_AST_SYM_VALUE(expr->left)) { + val = copyValue(AST_VALUE(expr->left)); + val->type = newLink(); + if (SPEC_SCLS(expr->left->etype) == S_CODE) { + DCL_TYPE(val->type) = CPOINTER ; + DCL_PTR_CONST(val->type) = 1; + } + else + if (SPEC_SCLS(expr->left->etype) == S_XDATA) + DCL_TYPE(val->type) = FPOINTER; + else + if (SPEC_SCLS(expr->left->etype) == S_XSTACK ) + DCL_TYPE(val->type) = PPOINTER ; + else + if (SPEC_SCLS(expr->left->etype) == S_IDATA) + DCL_TYPE(val->type) = IPOINTER ; + else + DCL_TYPE(val->type) = POINTER ; + val->type->next = expr->left->ftype; + val->etype = getSpec(val->type); + return val; + } + + /* if address of indexed array */ + if (IS_AST_OP(expr->left) && expr->left->opval.op == '[') + return valForArray(expr->left); + + /* if address of structure element then + case 1. a.b ; */ + if (IS_AST_OP(expr->left) && + expr->left->opval.op == '.' ) { + return valForStructElem(expr->left->left, + expr->left->right); + } + + /* case 2. (&a)->b ; + (&some_struct)->element */ + if (IS_AST_OP(expr->left) && + expr->left->opval.op == PTR_OP && + IS_ADDRESS_OF_OP(expr->left->left)) + return valForStructElem(expr->left->left->left, + expr->left->right); + } + + wrong: + werror(E_INIT_WRONG); + return NULL; + +} + +/*-----------------------------------------------------------------*/ +/* printChar - formats and prints a characater string with DB */ +/*-----------------------------------------------------------------*/ +void printChar (FILE * ofile, char *s, int plen) +{ + int i; + int len = strlen (s); + int pplen = 0; + + while (len && pplen < plen) { + + fprintf (ofile, "\t.ascii /"); + i = 60; + while (i && *s && pplen < plen) { + if (*s < ' ' || *s == '/') { + fprintf (ofile, "/\n\t.byte 0x%02x\n\t.ascii /", *s++); + } + else + fprintf (ofile, "%c", *s++); + pplen++; + i--; + } + fprintf (ofile, "/\n"); + + if (len > 60) + len -= 60; + else + len = 0; + } + if (pplen < plen) + fprintf(ofile,"\t.byte\t0\n"); +} + +/*-----------------------------------------------------------------*/ +/* printIvalType - generates ival for int/char */ +/*-----------------------------------------------------------------*/ +void printIvalType (link * type, initList * ilist, FILE * oFile) +{ + value *val; + + /* if initList is deep */ + if (ilist->type == INIT_DEEP) + ilist = ilist->init.deep; + + val = list2val (ilist); + switch (getSize (type)) { + case 1: + if (!val) + fprintf (oFile, "\t.byte 0\n"); + else + fprintf (oFile, "\t.byte %s\n", + aopLiteral (val, 0)); + break; + + case 2: + if (!val) + fprintf (oFile, "\t.word 0\n"); + else + fprintf (oFile, "\t.byte %s,%s\n", + aopLiteral (val, 0), aopLiteral (val, 1)); + break; + + case 4: + if (!val) + fprintf (oFile, "\t.word 0,0\n"); + else + fprintf (oFile, "\t.byte %s,%s,%s,%s\n", + aopLiteral (val, 0), aopLiteral (val, 1), + aopLiteral (val, 2), aopLiteral (val, 3)); + break; + } + + return; +} + +/*-----------------------------------------------------------------*/ +/* printIvalStruct - generates initial value for structures */ +/*-----------------------------------------------------------------*/ +void printIvalStruct (symbol * sym,link * type, + initList * ilist, FILE * oFile) +{ + symbol *sflds; + initList *iloop; + + sflds = SPEC_STRUCT (type)->fields; + if (ilist->type != INIT_DEEP) { + werror (E_INIT_STRUCT, sym->name); + return; + } + + iloop = ilist->init.deep; + + for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) + printIval (sflds, sflds->type, iloop, oFile); + + return; +} + +/*-----------------------------------------------------------------*/ +/* printIvalChar - generates initital value for character array */ +/*-----------------------------------------------------------------*/ +int printIvalChar (link * type, initList * ilist, FILE * oFile, char *s) +{ + value *val; + int remain; + + if (!s) { + + val = list2val (ilist); + /* if the value is a character string */ + if (IS_ARRAY (val->type) && IS_CHAR (val->etype)) { + if (!DCL_ELEM (type)) + DCL_ELEM (type) = strlen (SPEC_CVAL (val->etype).v_char) + 1; + + /* if size mismatch */ +/* if (DCL_ELEM (type) < ((int) strlen (SPEC_CVAL (val->etype).v_char) + 1)) */ +/* werror (E_ARRAY_BOUND); */ + + printChar (oFile, SPEC_CVAL (val->etype).v_char,DCL_ELEM(type)); + + if ((remain = (DCL_ELEM (type) - strlen (SPEC_CVAL (val->etype).v_char) -1))>0) + while (remain--) + fprintf (oFile, "\t.byte 0\n"); + + return 1; + } + else + return 0; + } + else + printChar (oFile, s,strlen(s)+1); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* printIvalArray - generates code for array initialization */ +/*-----------------------------------------------------------------*/ +void printIvalArray (symbol * sym, link * type, initList * ilist, + FILE * oFile) +{ + initList *iloop; + int lcnt = 0, size = 0; + + /* take care of the special case */ + /* array of characters can be init */ + /* by a string */ + if (IS_CHAR (type->next)) + if (printIvalChar (type, + (ilist->type == INIT_DEEP ? ilist->init.deep : ilist), + oFile, SPEC_CVAL (sym->etype).v_char)) + return; + + /* not the special case */ + if (ilist->type != INIT_DEEP) { + werror (E_INIT_STRUCT, sym->name); + return; + } + + iloop = ilist->init.deep; + lcnt = DCL_ELEM (type); + + for (;;) { + size++; + printIval (sym, type->next, iloop, oFile); + iloop = (iloop ? iloop->next : NULL); + + + /* if not array limits given & we */ + /* are out of initialisers then */ + if (!DCL_ELEM (type) && !iloop) + break; + + /* no of elements given and we */ + /* have generated for all of them */ + if (!--lcnt) + break; + } + + /* if we have not been given a size */ + if (!DCL_ELEM (type)) + DCL_ELEM (type) = size; + + return; +} + +/*-----------------------------------------------------------------*/ +/* printIvalFuncPtr - generate initial value for function pointers */ +/*-----------------------------------------------------------------*/ +void printIvalFuncPtr (link * type, initList * ilist, FILE * oFile) +{ + value *val; + int dLvl = 0; + + val = list2val (ilist); + /* check the types */ + if ((dLvl = checkType (val->type, type->next)) <= 0) { + + fprintf (oFile, "\t.word 0\n"); + return; + } + + /* now generate the name */ + if (!val->sym) { + if (IS_LITERAL (val->etype)) + fprintf (oFile, "\t.byte %s,%s\n", + aopLiteral (val, 0), aopLiteral (val, 1)); + else + fprintf (oFile, "\t.byte %s,(%s >> 8)\n", + val->name, val->name); + } + else + fprintf (oFile, "\t.byte %s,(%s >> 8)\n", + val->sym->rname, val->sym->rname); + + return; +} + +/*-----------------------------------------------------------------*/ +/* printIvalCharPtr - generates initial values for character pointers */ +/*-----------------------------------------------------------------*/ +int printIvalCharPtr (symbol * sym, link * type, value * val, FILE * oFile) +{ + int size = 0; + + size = getSize (type); + + if (size == 1) + fprintf(oFile, + "\t.byte %s", val->name) ; + else + fprintf (oFile, + "\t.byte %s,(%s >> 8)", + val->name, val->name); + + if (size > 2) + fprintf (oFile, ",#0x02\n"); + else + fprintf (oFile, "\n"); + + if (val->sym && val->sym->isstrlit) + addSet (&statsg->syms, val->sym); + + return 1; +} + +/*-----------------------------------------------------------------*/ +/* printIvalPtr - generates initial value for pointers */ +/*-----------------------------------------------------------------*/ +void printIvalPtr (symbol * sym, link * type, initList * ilist, FILE * oFile) +{ + value *val; + + /* if deep then */ + if (ilist->type == INIT_DEEP) + ilist = ilist->init.deep; + + /* function pointer */ + if (IS_FUNC (type->next)) { + printIvalFuncPtr (type, ilist, oFile); + return; + } + + if (!(val = initPointer (ilist))) + return ; + + /* if character pointer */ + if (IS_CHAR (type->next)) + if (printIvalCharPtr (sym, type, val, oFile)) + return; + + /* check the type */ + if (checkType (type, val->type) != 1) + werror (E_INIT_WRONG); + + /* if val is literal */ + if (IS_LITERAL (val->etype)) { + switch (getSize (type)) { + case 1: + fprintf (oFile, "\t.byte 0x%02x\n", ((char) floatFromVal (val)) & 0xff); + break; + case 2: + fprintf (oFile, "\t.byte %s,%s\n", + aopLiteral (val, 0), aopLiteral (val, 1)); + + break; + case 3: + fprintf (oFile, "\t.byte %s,%s,0x%02x\n", + aopLiteral (val, 0), aopLiteral (val, 1), CPOINTER); + } + return; + } + + + switch (getSize (type)) { + case 1: + fprintf (oFile, "\t.byte %s\n", val->name); + break; + case 2: + fprintf (oFile, "\t.byte %s,(%s >> 8)\n", val->name, val->name); + break; + + case 3: + fprintf (oFile, "\t.byte %s,(%s >> 8),0x%02x\n", + val->name, val->name, DCL_TYPE(val->type)); + } + return; +} + +/*-----------------------------------------------------------------*/ +/* printIval - generates code for initial value */ +/*-----------------------------------------------------------------*/ +void printIval (symbol * sym, link * type, initList * ilist, FILE * oFile) +{ + if (!ilist) + return; + + /* if structure then */ + if (IS_STRUCT (type)) { + printIvalStruct (sym, type, ilist, oFile); + return; + } + + /* if this is a pointer */ + if (IS_PTR (type)) { + printIvalPtr (sym, type, ilist, oFile); + return; + } + + /* if this is an array */ + if (IS_ARRAY (type)) { + printIvalArray (sym, type, ilist, oFile); + return; + } + + /* if type is SPECIFIER */ + if (IS_SPEC (type)) { + printIvalType (type, ilist, oFile); + return; + } +} + +/*-----------------------------------------------------------------*/ +/* emitStaticSeg - emitcode for the static segment */ +/*-----------------------------------------------------------------*/ +void emitStaticSeg (memmap * map) +{ + symbol *sym; + + /* fprintf(map->oFile,"\t.area\t%s\n",map->sname); */ + + + /* for all variables in this segment do */ + for (sym = setFirstItem (map->syms); sym; + sym = setNextItem (map->syms)) { + + /* if it is "extern" then do nothing */ + if (IS_EXTERN (sym->etype)) + continue; + + /* if it is not static add it to the public + table */ + if (!IS_STATIC (sym->etype)) + addSetHead (&publics, sym); + + /* print extra debug info if required */ + if (options.debug || sym->level == 0) { + + cdbSymbol(sym,cdbFile,FALSE,FALSE); + + if (!sym->level) { /* global */ + if (IS_STATIC(sym->etype)) + fprintf(code->oFile,"F%s$",moduleName); /* scope is file */ + else + fprintf(code->oFile,"G$"); /* scope is global */ + } + else + /* symbol is local */ + fprintf(code->oFile,"L%s$", + (sym->localof ? sym->localof->name : "-null-")); + fprintf(code->oFile,"%s$%d$%d",sym->name,sym->level,sym->block); + } + + /* if it has an absolute address */ + if (SPEC_ABSA (sym->etype)) { + if (options.debug || sym->level == 0) + fprintf(code->oFile," == 0x%04x\n", SPEC_ADDR (sym->etype)); + + fprintf (code->oFile, "%s\t=\t0x%04x\n", + sym->rname, + SPEC_ADDR (sym->etype)); + } + else { + if (options.debug || sym->level == 0) + fprintf(code->oFile," == .\n"); + + /* if it has an initial value */ + if (sym->ival) { + fprintf (code->oFile, "%s:\n", sym->rname); + noAlloc++; + resolveIvalSym (sym->ival); + printIval (sym, sym->type, sym->ival, code->oFile); + noAlloc--; + } + else { + /* allocate space */ + fprintf (code->oFile, "%s:\n", sym->rname); + /* special case for character strings */ + if (IS_ARRAY (sym->type) && IS_CHAR (sym->type->next) && + SPEC_CVAL (sym->etype).v_char) + printChar (code->oFile, + SPEC_CVAL (sym->etype).v_char, + strlen(SPEC_CVAL (sym->etype).v_char)+1); + else + fprintf (code->oFile, "\t.ds\t0x%04x\n", (unsigned int)getSize (sym->type)& 0xffff); + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* emitMaps - emits the code for the data portion the code */ +/*-----------------------------------------------------------------*/ +void emitMaps () +{ + /* no special considerations for the following + data, idata & bit & xdata */ + emitRegularMap (data, TRUE, TRUE); + emitRegularMap (idata, TRUE,TRUE); + emitRegularMap (bit, TRUE,FALSE); + emitRegularMap (xdata, TRUE,TRUE); + emitRegularMap (sfr, FALSE,FALSE); + emitRegularMap (sfrbit, FALSE,FALSE); + emitRegularMap (code, TRUE,FALSE); + emitStaticSeg (statsg); +} + +/*-----------------------------------------------------------------*/ +/* createInterruptVect - creates the interrupt vector */ +/*-----------------------------------------------------------------*/ +void createInterruptVect (FILE * vFile) +{ + int i = 0; + mainf = newSymbol ("main", 0); + mainf->block = 0; + + /* only if the main function exists */ + if (!(mainf = findSymWithLevel (SymbolTab, mainf))) { + if (!options.cc_only) + werror(E_NO_MAIN); + return; + } + + /* if the main is only a prototype ie. no body then do nothing */ + if (!mainf->fbody) { + /* if ! compile only then main function should be present */ + if (!options.cc_only) + werror(E_NO_MAIN); + return; + } + + fprintf (vFile, "\t.area\tCODE (CODE)\n"); + fprintf (vFile, "__interrupt_vect:\n"); + + fprintf (vFile, "\tljmp\t__sdcc_gsinit_startup\n"); + + + /* now for the other interrupts */ + for (; i < maxInterrupts; i++) { + if (interrupts[i]) + fprintf (vFile, "\tljmp\t%s\n\t.ds\t5\n", interrupts[i]->rname); + else + fprintf (vFile, "\treti\n\t.ds\t7\n"); + } +} + +char *iComments1 = +{ + ";--------------------------------------------------------\n" + "; File Created by SDCC : FreeWare ANSI-C Compiler\n"}; + +char *iComments2 = +{ + ";--------------------------------------------------------\n"}; + + +/*-----------------------------------------------------------------*/ +/* initialComments - puts in some initial comments */ +/*-----------------------------------------------------------------*/ +void initialComments (FILE * afile) +{ + time_t t; + time(&t); + fprintf (afile, "%s", iComments1); + fprintf (afile, "; Version %s %s\n", VersionString,asctime(localtime(&t))); + fprintf (afile, "%s", iComments2); +} + +/*-----------------------------------------------------------------*/ +/* printPublics - generates .global for publics */ +/*-----------------------------------------------------------------*/ +void printPublics (FILE * afile) +{ + symbol *sym; + + fprintf (afile, "%s", iComments2); + fprintf (afile, "; publics variables in this module\n"); + fprintf (afile, "%s", iComments2); + + for (sym = setFirstItem (publics); sym; + sym = setNextItem (publics)) + fprintf (afile, "\t.globl %s\n", sym->rname); +} + +/*-----------------------------------------------------------------*/ +/* emitOverlay - will emit code for the overlay stuff */ +/*-----------------------------------------------------------------*/ +static void emitOverlay(FILE *afile) +{ + set *ovrset; + + if (!elementsInSet(ovrSetSets)) + fprintf(afile,"\t.area\tOSEG\t(OVR,DATA)\n"); + + /* for each of the sets in the overlay segment do */ + for (ovrset = setFirstItem(ovrSetSets); ovrset; + ovrset = setNextItem(ovrSetSets)) { + + symbol *sym ; + + if (elementsInSet(ovrset)) { + /* this dummy area is used to fool the assembler + otherwise the assembler will append each of these + declarations into one chunk and will not overlay + sad but true */ + fprintf(afile,"\t.area _DUMMY\n"); + /* output the area informtion */ + fprintf(afile,"\t.area\tOSEG\t(OVR,DATA)\n"); /* MOF */ + } + + for (sym = setFirstItem(ovrset); sym; + sym = setNextItem(ovrset)) { + + /* if extern then do nothing */ + if (IS_EXTERN (sym->etype)) + continue; + + /* if allocation required check is needed + then check if the symbol really requires + allocation only for local variables */ + if (!IS_AGGREGATE(sym->type) && + !(sym->_isparm && !IS_REGPARM(sym->etype)) + && !sym->allocreq && sym->level) + continue ; + + /* if global variable & not static or extern + and addPublics allowed then add it to the public set */ + if ((sym->_isparm && !IS_REGPARM(sym->etype)) + && !IS_STATIC (sym->etype)) + addSetHead (&publics, sym); + + /* if extern then do nothing or is a function + then do nothing */ + if (IS_FUNC (sym->type)) + continue; + + /* print extra debug info if required */ + if (options.debug || sym->level == 0) { + + cdbSymbol(sym,cdbFile,FALSE,FALSE); + + if (!sym->level) { /* global */ + if (IS_STATIC(sym->etype)) + fprintf(afile,"F%s$",moduleName); /* scope is file */ + else + fprintf(afile,"G$"); /* scope is global */ + } + else + /* symbol is local */ + fprintf(afile,"L%s$", + (sym->localof ? sym->localof->name : "-null-")); + fprintf(afile,"%s$%d$%d",sym->name,sym->level,sym->block); + } + + /* if is has an absolute address then generate + an equate for this no need to allocate space */ + if (SPEC_ABSA (sym->etype)) { + + if (options.debug || sym->level == 0) + fprintf (afile," == 0x%04x\n",SPEC_ADDR (sym->etype)); + + fprintf (afile, "%s\t=\t0x%04x\n", + sym->rname, + SPEC_ADDR (sym->etype)); + } + else { + if (options.debug || sym->level == 0) + fprintf(afile,"==.\n"); + + /* allocate space */ + fprintf (afile, "%s:\n", sym->rname); + fprintf (afile, "\t.ds\t0x%04x\n", (unsigned int)getSize (sym->type) & 0xffff); + } + + } + } +} + +/*-----------------------------------------------------------------*/ +/* glue - the final glue that hold the whole thing together */ +/*-----------------------------------------------------------------*/ +void glue () +{ + FILE *vFile; + FILE *asmFile; + FILE *ovrFile = tmpfile(); + + addSetHead(&tmpfileSet,ovrFile); + /* print the global struct definitions */ + if (options.debug) + cdbStructBlock (0,cdbFile); + + /* create the interrupt vector table */ + createInterruptVect ((vFile = tmpfile ())); + addSetHead(&tmpfileSet,vFile); + + /* emit code for the all the variables declared */ + emitMaps (); + /* do the overlay segments */ + emitOverlay(ovrFile); + + /* now put it all together into the assembler file */ + /* create the assembler file name */ + sprintf (buffer, srcFileName); + strcat (buffer, ".asm"); + if (!(asmFile = fopen (buffer, "w"))) { + werror (E_FILE_OPEN_ERR, buffer); + exit (1); + } + + /* initial comments */ + initialComments (asmFile); + + /* print module name */ + fprintf (asmFile, "\t.module %s\n", moduleName); + + /* print the global variables in this module */ + printPublics (asmFile); + + + /* copy the sfr segment */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; special function registers\n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, sfr->oFile); + + /* copy the sbit segment */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; special function bits \n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, sfrbit->oFile); + + /* copy the data segment */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; internal ram data\n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, data->oFile); + + + /* create the overlay segments */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; overlayable items in internal ram \n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, ovrFile); + + /* create the stack segment MOF */ + if (mainf && mainf->fbody) { + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; Stack segment in internal ram \n"); + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "\t.area\tSSEG\t(DATA)\n" + "__start__stack:\n\t.ds\t1\n\n"); + } + + /* create the idata segment */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; indirectly addressable internal ram data\n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, idata->oFile); + + /* copy the bit segment */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; bit data\n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, bit->oFile); + + /* if external stack then reserve space of it */ + if (mainf && mainf->fbody && options.useXstack ) { + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; external stack \n"); + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile,"\t.area XSEG (XDATA)\n"); /* MOF */ + fprintf (asmFile,"\t.ds 256\n"); + } + + + /* copy xtern ram data */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; external ram data\n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, xdata->oFile); + + /* copy the interrupt vector table */ + if (mainf && mainf->fbody) { + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; interrupt vector \n"); + fprintf (asmFile, "%s", iComments2); + copyFile (asmFile, vFile); + } + + /* copy global & static initialisations */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; global & static initialisations\n"); + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "\t.area GSINIT (CODE)\n"); /* MOF */ + if (mainf && mainf->fbody) { + fprintf (asmFile,"__sdcc_gsinit_startup:\n"); + /* if external stack is specified then the + higher order byte of the xdatalocation is + going into P2 and the lower order going into + spx */ + if (options.useXstack) { + fprintf(asmFile,"\tmov\tP2,#0x%02x\n", + (((unsigned int)options.xdata_loc) >> 8) & 0xff); + fprintf(asmFile,"\tmov\t_spx,#0x%02x\n", + (unsigned int)options.xdata_loc & 0xff); + } + + /* initialise the stack pointer */ + /* if the user specified a value then use it */ + if (options.stack_loc) + fprintf(asmFile,"\tmov\tsp,#%d\n",options.stack_loc); + else + /* no: we have to compute it */ + if (!options.stackOnData && maxRegBank <= 3) + fprintf(asmFile,"\tmov\tsp,#%d\n",((maxRegBank + 1) * 8) -1); + else + fprintf(asmFile,"\tmov\tsp,#__start__stack\n"); /* MOF */ + + fprintf (asmFile,"\tlcall\t__sdcc_external_startup\n"); + fprintf (asmFile,"\tmov\ta,dpl\n"); + fprintf (asmFile,"\tjz\t__sdcc_init_data\n"); + fprintf (asmFile,"\tljmp\t__sdcc_program_startup\n"); + fprintf (asmFile,"__sdcc_init_data:\n"); + + } + copyFile (asmFile, statsg->oFile); + + /* copy over code */ + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "; code\n"); + fprintf (asmFile, "%s", iComments2); + fprintf (asmFile, "\t.area CSEG (CODE)\n"); + if (mainf && mainf->fbody) { + + /* entry point @ start of CSEG */ + fprintf (asmFile,"__sdcc_program_startup:\n"); + + /* put in the call to main */ + fprintf(asmFile,"\tlcall\t_main\n"); + if (options.mainreturn) { + + fprintf(asmFile,";\treturn from main ; will return to caller\n"); + fprintf(asmFile,"\tret\n"); + + } else { + + fprintf(asmFile,";\treturn from main will lock up\n"); + fprintf(asmFile,"\tsjmp .\n"); + } + } + copyFile (asmFile, code->oFile); + + fclose (asmFile); + applyToSet(tmpfileSet,closeTmpFiles); +} diff --git a/src/SDCCglue.h b/src/SDCCglue.h new file mode 100644 index 00000000..645b225d --- /dev/null +++ b/src/SDCCglue.h @@ -0,0 +1,32 @@ +/*------------------------------------------------------------------------- + + SDCCglue.h - glues everything we have done together into one file. + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "SDCCglobl.h" +#include "SDCCmem.h" + +#ifndef SDCCGLUE_H +#define SDCCGLUE_H 1 + +void glue(); + +#endif diff --git a/src/SDCChasht.c b/src/SDCChasht.c new file mode 100644 index 00000000..1bf0af52 --- /dev/null +++ b/src/SDCChasht.c @@ -0,0 +1,398 @@ +/*----------------------------------------------------------------- + SDCChast.c - contains support routines for hashtables + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include "SDCChasht.h" + + +#define DEFAULT_HTAB_SIZE 128 + +/*-----------------------------------------------------------------*/ +/* newHashtItem - creates a new hashtable Item */ +/*-----------------------------------------------------------------*/ + hashtItem *newHashtItem (int key, void *item) +{ + hashtItem *htip; + + ALLOC(htip,sizeof(hashtItem)); + + htip->key = key ; + htip->item = item; + htip->next = NULL ; + return htip; +} + +/*-----------------------------------------------------------------*/ +/* newHashTable - allocates a new hashtable of size */ +/*-----------------------------------------------------------------*/ +hTab *newHashTable (int size) +{ + hTab *htab; + + ALLOC(htab,sizeof(hTab)); + + if (!(htab->table = GC_malloc((size +1)* sizeof(hashtItem *)))) { + fprintf(stderr,"out of virtual memory %s %d\n", + __FILE__,(size +1)* sizeof(hashtItem *)); + exit(1); + } + htab->minKey = htab->size = size ; + return htab; +} + + +/*-----------------------------------------------------------------*/ +/* hTabAddItem - adds an item to the hash table */ +/*-----------------------------------------------------------------*/ +void hTabAddItem (hTab **htab, int key, void *item ) +{ + hashtItem *htip ; + hashtItem *last ; + + if (!(*htab) ) + *htab = newHashTable ( DEFAULT_HTAB_SIZE ); + + if (key > (*htab)->size ) { + int i; + (*htab)->table = GC_realloc ((*htab)->table, + (key*2 + 2)*sizeof(hashtItem *)); + for ( i = (*htab)->size +1; i <= (key*2 + 1); i++ ) + (*htab)->table[i] = NULL ; + (*htab)->size = key*2 + 1; + } + + /* update the key */ + if ((*htab)->maxKey < key ) + (*htab)->maxKey = key ; + + if ((*htab)->minKey > key ) + (*htab)->minKey = key ; + + /* create the item */ + htip = newHashtItem (key,item); + + /* if there is a clash then goto end of chain */ + if ((last = (*htab)->table[key])) { + while (last->next) + last = last->next ; + last->next = htip ; + } else + /* else just add it */ + (*htab)->table[key] = htip ; + (*htab)->nItems++ ; +} + +/*-----------------------------------------------------------------*/ +/* hTabDeleteItem - either delete an item */ +/*-----------------------------------------------------------------*/ +void hTabDeleteItem (hTab **htab, int key , + void *item, int action , + int (*compareFunc)(void *,void *)) +{ + hashtItem *htip, **htipp ; + + if (!(*htab)) + return ; + + /* first check if anything exists in the slot */ + if (! (*htab)->table[key] ) + return ; + + /* if delete chain */ + if ( action == DELETE_CHAIN ) + (*htab)->table[key] = NULL ; + else { + + /* delete specific item */ + /* if a compare function is given then use the compare */ + /* function to find the item, else just compare the items */ + + htipp = &((*htab)->table[key]); + htip = (*htab)->table[key]; + for (; htip; htip = htip->next) { + + if (compareFunc ? (*compareFunc)(item,htip->item) : + (item == htip->item) ) { + *htipp=htip->next; + break; + } + + htipp=&(htip->next); + } + + /* GC_free(htip); */ + } + + (*htab)->nItems-- ; + + if (!(*htab)->nItems) { + *htab = NULL; + } +} + +/*-----------------------------------------------------------------*/ +/* hTabDeleteAll - deletes all items in a hash table to reduce mem */ +/* leaks written by */ +/* "BESSIERE Jerome" */ +/*-----------------------------------------------------------------*/ +void hTabDeleteAll(hTab * p) +{ + if (p && p->table) { + register int i; + register hashtItem *jc,*jn; + for (i=0;isize;i++) { + + if (!(jc = p->table[i])) continue; + jn = jc->next; + while(jc){ + GC_free(jc); + if((jc=jn)) jn = jc->next; + } + p->table[i] = NULL ; + } + GC_free(p->table); + } +} + +/*-----------------------------------------------------------------*/ +/* hTabClearAll - clear all entries inthe table (does not free) */ +/*-----------------------------------------------------------------*/ +void hTabClearAll (hTab *htab) +{ + + if (!htab || !htab->table) { + printf("null table\n"); + return ; + } + memset(htab->table, 0, htab->size*sizeof(hashtItem *)); + + htab->minKey = htab->size; + htab->currKey = htab->nItems = htab->maxKey = 0; +} + +/*-----------------------------------------------------------------*/ +/* hTabIsInTable - will determine if an Item is in the hasht */ +/*-----------------------------------------------------------------*/ +int hTabIsInTable (hTab *htab, int key, + void *item , int (*compareFunc)(void *,void *)) +{ + hashtItem *htip ; + + for (htip = htab->table[key] ; htip ; htip = htip->next ) { + /* if a compare function is given use it */ + if (compareFunc && (*compareFunc)(item,htip->item)) + break ; + else + if (item == htip->item) + break; + } + + if ( htip) + return 1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* hTabFirstItem - returns the first Item in the hTab */ +/*-----------------------------------------------------------------*/ +void *hTabFirstItem (hTab *htab, int *k) +{ + int key ; + + if (!htab) + return NULL ; + + for ( key = htab->minKey ; key <= htab->maxKey ; key++ ) { + if (htab->table[key]) { + htab->currItem = htab->table[key]; + htab->currKey = key ; + *k = key ; + return htab->table[key]->item; + } + } + return NULL ; +} + +/*-----------------------------------------------------------------*/ +/* hTabNextItem - returns the next item in the hTab */ +/*-----------------------------------------------------------------*/ +void *hTabNextItem (hTab *htab, int *k) +{ + int key ; + + if (!htab) + return NULL; + + /* if this chain not ended then */ + if (htab->currItem->next) { + *k = htab->currItem->key ; + return (htab->currItem = htab->currItem->next)->item ; + } + + /* find the next chain which has something */ + for ( key = htab->currKey + 1; key <= htab->maxKey ; key++ ) { + if (htab->table[key]) { + htab->currItem = htab->table[key]; + *k = htab->currKey = key ; + return htab->table[key]->item; + } + } + + return NULL ; +} + +/*-----------------------------------------------------------------*/ +/* hTabFirstItemWK - returns the first Item in the hTab for a key */ +/*-----------------------------------------------------------------*/ +void *hTabFirstItemWK (hTab *htab, int wk) +{ + + if (!htab) + return NULL ; + + if (wk < htab->minKey || wk > htab->maxKey ) + return NULL; + + htab->currItem = htab->table[wk] ; + htab->currKey = wk ; + + return (htab->table[wk] ? htab->table[wk]->item : NULL); +} + +/*-----------------------------------------------------------------*/ +/* hTabNextItem - returns the next item in the hTab for a key */ +/*-----------------------------------------------------------------*/ +void *hTabNextItemWK (hTab *htab ) +{ + + if (!htab) + return NULL; + + /* if this chain not ended then */ + if (htab->currItem->next) { + return (htab->currItem = htab->currItem->next)->item ; + } + + return NULL ; +} + +/*-----------------------------------------------------------------*/ +/* hTabFromTable - hash Table from a hash table */ +/*-----------------------------------------------------------------*/ +hTab *hTabFromTable (hTab *htab) +{ + hTab *nhtab ; + hashtItem *htip; + int key ; + + if (!htab) + return NULL ; + + nhtab = newHashTable(htab->size); + + for (key = htab->minKey; key <= htab->maxKey ; key++ ) { + + for (htip = htab->table[key] ; htip ; htip = htip->next) + hTabAddItem (&nhtab, htip->key, htip->item); + } + + return nhtab ; +} + +/*-----------------------------------------------------------------*/ +/* isHtabsEqual - returns 1 if all items in htab1 is found in htab2*/ +/*-----------------------------------------------------------------*/ +int isHtabsEqual (hTab *htab1, hTab *htab2, + int (*compareFunc)(void *,void *)) +{ + void *item; + int key; + + if ( htab1 == htab2 ) + return 1; + + if (htab1 == NULL || htab2 == NULL ) + return 0; + + /* if they are different sizes then */ + if ( htab1->nItems != htab2->nItems) + return 0; + + /* now do an item by item check */ + for ( item = hTabFirstItem (htab1,&key) ;item; + item = hTabNextItem (htab1,&key)) + if (!hTabIsInTable (htab2, key, item, compareFunc)) + return 0; + + return 1; +} + + +/*-----------------------------------------------------------------*/ +/* hTabSearch - returns the first Item with the specified key */ +/*-----------------------------------------------------------------*/ +hashtItem *hTabSearch (hTab *htab, int key ) +{ + if (!htab) + return NULL ; + + if ((key < htab->minKey)||(key>htab->maxKey)) + return NULL ; + + if (!htab->table[key]) + return NULL ; + + return htab->table[key] ; +} + +/*-----------------------------------------------------------------*/ +/* hTabItemWithKey - returns the first item with the gievn key */ +/*-----------------------------------------------------------------*/ +void *hTabItemWithKey (hTab *htab, int key ) +{ + hashtItem *htip; + + if (!(htip = hTabSearch(htab,key))) + return NULL; + + return htip->item; +} + +/*-----------------------------------------------------------------*/ +/*hTabAddItemIfNotP - adds an item with nothing found with key */ +/*-----------------------------------------------------------------*/ +void hTabAddItemIfNotP (hTab **htab, int key, void *item) +{ + if (!*htab) { + hTabAddItem (htab,key,item); + return; + } + + if (hTabItemWithKey(*htab,key)) + return ; + + hTabAddItem(htab,key,item); +} diff --git a/src/SDCChasht.h b/src/SDCChasht.h new file mode 100644 index 00000000..dcca3f9e --- /dev/null +++ b/src/SDCChasht.h @@ -0,0 +1,113 @@ +/*----------------------------------------------------------------- + SDCChast.h - contains support routines for hashtables/sets . + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + + +#ifndef SDCCHASHT_H +#define SDCCHASHT_H + +#ifdef _NO_GC + +#define GC_malloc malloc +#define GC_free free +#define GC_realloc realloc +#define GC_malloc_atomic malloc + +#else + +#include "./gc/gc.h" + +#endif + +#ifndef ALLOC + +#define ALLOC(x,sz) if (!(x = GC_malloc(sz))) \ + { \ + fprintf(stderr,"out of virtual memory %s , %d",__FILE__,__LINE__);\ + exit (1); \ + } + +#define ALLOC_ATOMIC(x,sz) if (!(x = GC_malloc_atomic(sz))) \ + { \ + fprintf(stderr,"out of virtual memory %s , %d",__FILE__,__LINE__);\ + exit (1); \ + } + + + +#endif + + +/* hashtable item */ +typedef struct hashtItem +{ + int key ; + void *item ; + struct hashtItem *next ; +} hashtItem ; + +/* hashtable */ +typedef struct hTab +{ + int size ; /* max number of items */ + int minKey; /* minimum key value */ + int maxKey ; /* maximum key value */ + hashtItem **table ; /* the actual table */ + int currKey ; /* used for iteration */ + hashtItem *currItem ; /* current item within the list */ + int nItems ; +} hTab ; + + + +enum { + DELETE_CHAIN = 1, + DELETE_ITEM }; + + +/*-----------------------------------------------------------------*/ +/* Forward definition for functions */ +/*-----------------------------------------------------------------*/ + +/* hashtable related functions */ +hTab *newHashTable (int); +void hTabAddItem (hTab **, int , void * ); +void hTabDeleteItem (hTab **, int , + void *, int , + int (*compareFunc)(void *,void *)); +int hTabIsInTable (hTab *, int , void * , + int (*compareFunc)(void *,void *)); +void *hTabFirstItem (hTab *, int *); +void *hTabNextItem (hTab *, int *); +hTab *hTabFromTable (hTab *); +int isHtabsEqual (hTab *,hTab *, int (*compareFunc)(void *,void *)); +hashtItem *hTabSearch (hTab *, int ); +void *hTabItemWithKey(hTab *,int ); +void hTabAddItemIfNotP(hTab **,int, void *); +void hTabDeleteAll(hTab *); +void *hTabFirstItemWK (hTab *htab, int wk); +void *hTabNextItemWK (hTab *htab ); +void hTabClearAll (hTab *htab); + + +#endif diff --git a/src/SDCCicode.c b/src/SDCCicode.c new file mode 100644 index 00000000..c405c1af --- /dev/null +++ b/src/SDCCicode.c @@ -0,0 +1,3019 @@ +/*------------------------------------------------------------------------- + + SDCCicode.c - intermediate code generation etc. + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCicode.h" +#include "SDCCerr.h" +#include "SDCCralloc.h" + +/*-----------------------------------------------------------------*/ +/* global variables */ + +set *iCodeChain = NULL ; +int iTempNum = 0; +int iTempLblNum = 0; +int operandKey = 0 ; +int iCodeKey = 0; +char *filename ; +int lineno ; +int block; +int scopeLevel; +int lvaluereq; + +extern int labelKey ; + +symbol *returnLabel ; /* function return label */ +symbol *entryLabel ; /* function entry label */ +/*-----------------------------------------------------------------*/ +/* forward definition of some functions */ +operand *geniCodeDivision (operand *,operand *); +operand *geniCodeAssign (operand *,operand *,int); +operand *geniCodeArray (operand *,operand *); +operand *geniCodeArray2Ptr (operand *); +operand *geniCodeRValue (operand *, bool ); +operand *geniCodeDerefPtr (operand *); + +#define PRINTFUNC(x) void x (FILE *of, iCode *ic, char *s) + +/* forward definition of print functions */ +PRINTFUNC(picGetValueAtAddr); +PRINTFUNC(picSetValueAtAddr); +PRINTFUNC(picAddrOf); +PRINTFUNC(picGeneric); +PRINTFUNC(picGenericOne); +PRINTFUNC(picCast); +PRINTFUNC(picIncrement); +PRINTFUNC(picDecrement); +PRINTFUNC(picAssign); +PRINTFUNC(picLabel); +PRINTFUNC(picGoto); +PRINTFUNC(picIfx); +PRINTFUNC(picJumpTable); +PRINTFUNC(picInline); +PRINTFUNC(picReceive); + +iCodeTable codeTable[] = { + { '!' , "not", picGenericOne , NULL }, + { '~' , "~" , picGenericOne , NULL }, + { RRC , "rrc", picGenericOne , NULL }, + { RLC , "rlc", picGenericOne , NULL }, + { GETHBIT ,"ghbit", picGenericOne , NULL }, + { UNARYMINUS , "-" , picGenericOne , NULL }, + { IPUSH , "push",picGenericOne , NULL }, + { IPOP , "pop", picGenericOne , NULL }, + { CALL , "call",picGenericOne , NULL }, + { PCALL , "pcall",picGenericOne , NULL }, + { FUNCTION , "proc", picGenericOne , NULL }, + { ENDFUNCTION ,"eproc", picGenericOne , NULL }, + { RETURN , "ret", picGenericOne , NULL }, + { '+' , "+" , picGeneric , NULL }, + { '-' , "-" , picGeneric , NULL }, + { '*' , "*" , picGeneric , NULL }, + { '/' , "/" , picGeneric , NULL }, + { '%' , "%" , picGeneric , NULL }, + { '>' , ">" , picGeneric , NULL }, + { '<' , "<" , picGeneric , NULL }, + { LE_OP , "<=" , picGeneric , NULL }, + { GE_OP , ">=" , picGeneric , NULL }, + { EQ_OP , "==" , picGeneric , NULL }, + { NE_OP , "!=" , picGeneric , NULL }, + { AND_OP , "&&" , picGeneric , NULL }, + { OR_OP , "||" , picGeneric , NULL }, + { '^' , "^" , picGeneric , NULL }, + { '|' , "|" , picGeneric , NULL }, + { BITWISEAND , "&" , picGeneric , NULL }, + { LEFT_OP , "<<" , picGeneric , NULL }, + { RIGHT_OP , ">>" , picGeneric , NULL }, + { GET_VALUE_AT_ADDRESS, "@" , picGetValueAtAddr, NULL }, + { ADDRESS_OF , "&" , picAddrOf , NULL }, + { CAST , "<>" , picCast , NULL }, + { '=' , ":=" , picAssign , NULL }, + { LABEL , "" , picLabel , NULL }, + { GOTO , "" , picGoto , NULL }, + { JUMPTABLE ,"jtab" , picJumpTable , NULL }, + { IFX , "if" , picIfx , NULL }, + { INLINEASM , "" , picInline , NULL }, + { RECEIVE , "recv", picReceive , NULL }, + { SEND , "send", picGenericOne , NULL } +}; + + +/*-----------------------------------------------------------------*/ +/* operandName - returns the name of the operand */ +/*-----------------------------------------------------------------*/ +int printOperand (operand *op, FILE *file) +{ + link *opetype; + int pnl = 0; + + if (!op) + return 1; + + if (!file) { + file = stdout; + pnl = 1; + } + switch (op->type) { + + case VALUE: + opetype = getSpec (operandType(op)); + if (SPEC_NOUN(opetype) == V_FLOAT) + fprintf (file,"%g {", SPEC_CVAL(opetype).v_float); + else + fprintf (file,"0x%x {",(int) floatFromVal(op->operand.valOperand)); + printTypeChain(operandType(op),file); + fprintf(file,"}"); + break; + + case SYMBOL : +#define REGA 1 +#ifdef REGA + fprintf (file,"%s [k%d lr%d:%d so:%d]{ ia%d re%d rm%d}",/*{ar%d rm%d ru%d p%d a%d u%d i%d au%d k%d ks%d}" ,*/ + (OP_SYMBOL(op)->rname[0] ? OP_SYMBOL(op)->rname : OP_SYMBOL(op)->name), + op->key, + OP_LIVEFROM(op),OP_LIVETO(op), + OP_SYMBOL(op)->stack, + op->isaddr, OP_SYMBOL(op)->isreqv,OP_SYMBOL(op)->remat +/* , */ +/* OP_SYMBOL(op)->allocreq,OP_SYMBOL(op)->remat, */ +/* OP_SYMBOL(op)->ruonly, */ +/* OP_SYMBOL(op)->isptr,op->isaddr,OP_SYMBOL(op)->used, */ +/* OP_SYMBOL(op)->isind, */ +/* OP_SYMBOL(op)->accuse, op->key, OP_SYMBOL(op)->key */ + ); + { + fprintf(file,"{"); printTypeChain(operandType(op),file); + if (SPIL_LOC(op) && IS_ITEMP(op)) + fprintf(file,"}{ sir@ %s",SPIL_LOC(op)->rname); + fprintf(file,"}"); + + } + + /* if assigned to registers */ + if (OP_SYMBOL(op)->nRegs) { + if (OP_SYMBOL(op)->isspilt) { + if (!OP_SYMBOL(op)->remat) + if (OP_SYMBOL(op)->usl.spillLoc) + fprintf(file,"[%s]",(OP_SYMBOL(op)->usl.spillLoc->rname[0] ? + OP_SYMBOL(op)->usl.spillLoc->rname : + OP_SYMBOL(op)->usl.spillLoc->name)); + else + fprintf(file,"[err]"); + else + fprintf(file,"[remat]"); + } + else { + int i; + fprintf(file,"["); + for(i=0;inRegs;i++) + fprintf(file,"%s ",(OP_SYMBOL(op)->regs[i] ? + OP_SYMBOL(op)->regs[i]->name : + "err")); + fprintf(file,"]"); + } + } +#else + fprintf(file,"%s",(OP_SYMBOL(op)->rname[0] ? + OP_SYMBOL(op)->rname : OP_SYMBOL(op)->name)); + /* if assigned to registers */ + if (OP_SYMBOL(op)->nRegs && !OP_SYMBOL(op)->isspilt) { + int i; + fprintf(file,"["); + for(i=0;inRegs;i++) + fprintf(file,"%s ",(OP_SYMBOL(op)->regs[i] ? + OP_SYMBOL(op)->regs[i]->name : + "err")); + fprintf(file,"]"); + } +#endif + break ; + + case TYPE: + fprintf(file,"("); + printTypeChain(op->operand.typeOperand,file); + fprintf(file,")"); + break; + } + + if (pnl) + fprintf(file,"\n"); + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* print functions */ +/*-----------------------------------------------------------------*/ +PRINTFUNC(picGetValueAtAddr) +{ + fprintf(of,"\t"); + printOperand (IC_RESULT(ic),of); + fprintf (of," = "); + fprintf (of,"@["); + printOperand (IC_LEFT(ic), of); + fprintf (of,"]"); + + fprintf(of,"\n"); +} + +PRINTFUNC(picSetValueAtAddr) +{ + fprintf(of,"\t"); + fprintf(of,"*["); + printOperand(IC_LEFT(ic),of); + fprintf(of,"] = "); + printOperand(IC_RIGHT(ic),of); + fprintf (of,"\n"); +} + +PRINTFUNC(picAddrOf) +{ + fprintf(of,"\t"); + printOperand(IC_RESULT(ic),of); + if (IS_ITEMP(IC_LEFT(ic))) + fprintf(of," = "); + else + fprintf(of," = &["); + printOperand(IC_LEFT(ic),of); + if (IC_RIGHT(ic)) { + if (IS_ITEMP(IC_LEFT(ic))) + fprintf(of," offsetAdd "); + else + fprintf(of," , "); + printOperand(IC_RIGHT(ic),of); + } + if (IS_ITEMP(IC_LEFT(ic))) + fprintf (of,"\n"); + else + fprintf (of,"]\n"); +} + +PRINTFUNC(picJumpTable) +{ + symbol *sym; + + fprintf(of,"\t"); + fprintf(of,"%s\t",s); + printOperand(IC_JTCOND(ic),of); + fprintf(of,"\n"); + for ( sym = setFirstItem(IC_JTLABELS(ic)); sym; + sym = setNextItem(IC_JTLABELS(ic))) + fprintf(of,"\t\t\t%s\n",sym->name); +} + +PRINTFUNC(picGeneric) +{ + fprintf(of,"\t"); + printOperand(IC_RESULT(ic),of); + fprintf(of," = "); + printOperand(IC_LEFT(ic),of); + fprintf(of," %s ",s); + printOperand(IC_RIGHT(ic),of); + fprintf(of,"\n"); +} + +PRINTFUNC(picGenericOne) +{ + fprintf(of,"\t"); + if ( IC_RESULT(ic) ) { + printOperand(IC_RESULT(ic),of); + fprintf (of," = "); + } + + if (IC_LEFT(ic)) { + fprintf (of,"%s ",s); + printOperand(IC_LEFT(ic),of); + } + + if (! IC_RESULT(ic) && !IC_LEFT(ic)) + fprintf (of,s); + + fprintf(of,"\n"); +} + +PRINTFUNC(picCast) +{ + fprintf(of,"\t"); + printOperand(IC_RESULT(ic),of); + fprintf (of," = "); + printOperand(IC_LEFT(ic),of); + printOperand(IC_RIGHT(ic),of); + fprintf(of,"\n"); +} + + +PRINTFUNC(picAssign) +{ + fprintf(of,"\t"); + + if (IC_RESULT(ic)->isaddr && IS_ITEMP(IC_RESULT(ic))) + fprintf(of,"*("); + + printOperand(IC_RESULT(ic),of); + + if (IC_RESULT(ic)->isaddr && IS_ITEMP(IC_RESULT(ic))) + fprintf(of,")"); + + fprintf(of," %s ", s); + printOperand (IC_RIGHT(ic),of); + + fprintf(of,"\n"); +} + +PRINTFUNC(picLabel) +{ + fprintf(of," %s($%d) :\n",IC_LABEL(ic)->name,IC_LABEL(ic)->key); +} + +PRINTFUNC(picGoto) +{ + fprintf(of,"\t"); + fprintf (of," goto %s($%d)\n", IC_LABEL(ic)->name,IC_LABEL(ic)->key); +} + +PRINTFUNC(picIfx) +{ + fprintf(of,"\t"); + fprintf (of,"if "); + printOperand(IC_COND(ic),of); + + if ( ! IC_TRUE(ic) ) + fprintf (of," == 0 goto %s($%d)\n",IC_FALSE(ic)->name,IC_FALSE(ic)->key); + else { + fprintf (of," != 0 goto %s($%d)\n",IC_TRUE(ic)->name,IC_TRUE(ic)->key); + if (IC_FALSE(ic)) + fprintf (of,"\tzzgoto %s\n",IC_FALSE(ic)->name); + } +} + +PRINTFUNC(picInline) +{ + fprintf(of,"%s",IC_INLINE(ic)); +} + +PRINTFUNC(picReceive) +{ + printOperand(IC_RESULT(ic),of); + fprintf(of," = %s ",s); + printOperand(IC_LEFT(ic),of); + fprintf(of,"\n"); +} + +/*-----------------------------------------------------------------*/ +/* piCode - prints one iCode */ +/*-----------------------------------------------------------------*/ +int piCode (void *item, FILE *of) +{ + iCode *ic = item; + iCodeTable *icTab ; + + if (!of) + of = stdout; + + icTab = getTableEntry(ic->op) ; + fprintf(stdout,"%s(%d:%d:%d:%d:%d)\t", + ic->filename,ic->lineno, + ic->seq,ic->key,ic->depth,ic->supportRtn); + icTab->iCodePrint(of,ic,icTab->printName); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* printiCChain - prints intermediate code for humans */ +/*-----------------------------------------------------------------*/ +void printiCChain (iCode *icChain, FILE *of) +{ + iCode *loop ; + iCodeTable *icTab ; + + if (!of) + of = stdout; + for ( loop = icChain ; loop ; loop = loop->next ) { + if ((icTab = getTableEntry (loop->op ))) { + fprintf(of,"%s(%d:%d:%d:%d:%d)\t", + loop->filename,loop->lineno, + loop->seq,loop->key,loop->depth,loop->supportRtn); + + icTab->iCodePrint (of,loop,icTab->printName); + } + } +} + + +/*-----------------------------------------------------------------*/ +/* newOperand - allocate, init & return a new iCode */ +/*-----------------------------------------------------------------*/ +operand *newOperand () +{ + operand *op ; + + ALLOC(op,sizeof(operand)); + + op->key = 0 ; + return op; +} + +/*-----------------------------------------------------------------*/ +/* newiCode - create and return a new iCode entry initialised */ +/*-----------------------------------------------------------------*/ +iCode *newiCode (int op, operand *left, operand *right) +{ + iCode *ic ; + + ALLOC(ic,sizeof(iCode)); + + ic->lineno = lineno ; + ic->filename= filename ; + ic->block = block; + ic->level = scopeLevel; + ic->op = op; + ic->key= iCodeKey++ ; + IC_LEFT(ic) = left; + IC_RIGHT(ic)= right; + + return ic; +} + +/*-----------------------------------------------------------------*/ +/* newiCode for conditional statements */ +/*-----------------------------------------------------------------*/ +iCode *newiCodeCondition (operand *condition, + symbol *trueLabel, + symbol *falseLabel ) +{ + iCode *ic ; + + ic = newiCode(IFX,NULL,NULL); + IC_COND(ic) = condition ; + IC_TRUE(ic) = trueLabel ; + IC_FALSE(ic) = falseLabel; + return ic; +} + +/*-----------------------------------------------------------------*/ +/* newiCodeLabelGoto - unconditional goto statement| label stmnt */ +/*-----------------------------------------------------------------*/ +iCode *newiCodeLabelGoto (int op, symbol *label) +{ + iCode *ic ; + + ic = newiCode(op,NULL,NULL); + ic->op = op ; + ic->argLabel.label = label ; + IC_LEFT(ic) = NULL ; + IC_RIGHT(ic) = NULL ; + IC_RESULT(ic) = NULL ; + return ic; +} + +/*-----------------------------------------------------------------*/ +/* newiTemp - allocate & return a newItemp Variable */ +/*-----------------------------------------------------------------*/ +symbol *newiTemp (char *s) +{ + symbol *itmp; + + if (s) + sprintf(buffer,"%s",s); + else + sprintf (buffer,"iTemp%d",iTempNum++); + itmp = newSymbol (buffer,1); + strcpy(itmp->rname,itmp->name); + itmp->isitmp = 1; + + return itmp; +} + +/*-----------------------------------------------------------------*/ +/* newiTempLabel - creates a temp variable label */ +/*-----------------------------------------------------------------*/ +symbol *newiTempLabel (char *s) +{ + symbol *itmplbl; + + /* check if this alredy exists */ + if (s && (itmplbl = findSym(LabelTab, NULL, s))) + return itmplbl ; + + if (s) + itmplbl = newSymbol(s,1); + else { + sprintf(buffer,"iTempLbl%d",iTempLblNum++); + itmplbl = newSymbol(buffer,1); + } + + itmplbl->isitmp = 1; + itmplbl->islbl = 1; + itmplbl->key = labelKey++ ; + addSym (LabelTab, itmplbl, itmplbl->name,0,0); + return itmplbl ; +} + +/*-----------------------------------------------------------------*/ +/* newiTempPreheaderLabel - creates a new preheader label */ +/*-----------------------------------------------------------------*/ +symbol *newiTempPreheaderLabel() +{ + symbol *itmplbl ; + + sprintf(buffer,"preHeaderLbl%d",iTempLblNum++); + itmplbl = newSymbol(buffer,1); + + itmplbl->isitmp = 1; + itmplbl->islbl = 1; + itmplbl->key = labelKey++ ; + addSym (LabelTab, itmplbl, itmplbl->name,0,0); + return itmplbl ; +} + + +/*-----------------------------------------------------------------*/ +/* initiCode - initialises some iCode related stuff */ +/*-----------------------------------------------------------------*/ +void initiCode () +{ + +} + +/*-----------------------------------------------------------------*/ +/* getTableEntry - gets the table entry for the given operator */ +/*-----------------------------------------------------------------*/ +iCodeTable *getTableEntry (int oper ) +{ + int i ; + + for ( i = 0 ; i < (sizeof(codeTable)/sizeof(iCodeTable)); i++ ) + if (oper == codeTable[i].icode) + return &codeTable[i] ; + + return NULL ; +} + +/*-----------------------------------------------------------------*/ +/* newiTempOperand - new intermediate temp operand */ +/*-----------------------------------------------------------------*/ +operand *newiTempOperand (link *type, char throwType) +{ + symbol *itmp; + operand *op = newOperand(); + link *etype; + + op->type = SYMBOL ; + itmp = newiTemp(NULL); + + etype = getSpec(type); + + if (IS_LITERAL(etype) ) + throwType = 0 ; + + /* copy the type information */ + if (type) + itmp->etype = getSpec (itmp->type = (throwType ? type : + copyLinkChain(type))); + if (IS_LITERAL(itmp->etype)) { + SPEC_SCLS(itmp->etype) = S_REGISTER ; + SPEC_OCLS(itmp->etype) = reg; + } + + op->operand.symOperand = itmp; + op->key = itmp->key = ++operandKey ; + return op; +} + +/*-----------------------------------------------------------------*/ +/* operandType - returns the type chain for an operand */ +/*-----------------------------------------------------------------*/ +link *operandType (operand *op) +{ + /* depending on type of operand */ + switch (op->type) { + + case VALUE : + return op->operand.valOperand->type ; + + case SYMBOL: + return op->operand.symOperand->type ; + + case TYPE : + return op->operand.typeOperand ; + } + + werror (E_INTERNAL_ERROR,__FILE__,__LINE__, + " operand type not known "); + assert (0) ; /* should never come here */ + /* Just to keep the compiler happy */ + return (link *)0; +} + +/*-----------------------------------------------------------------*/ +/* isParamterToCall - will return 1 if op is a parameter to args */ +/*-----------------------------------------------------------------*/ +int isParameterToCall (value *args, operand *op) +{ + value *tval = args ; + + while (tval) { + if (tval->sym && + isSymbolEqual(op->operand.symOperand,tval->sym)) + return 1; + tval = tval->next ; + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isOperandGlobal - return 1 if operand is a global variable */ +/*-----------------------------------------------------------------*/ +int isOperandGlobal ( operand *op ) +{ + if (!op) + return 0; + + if (IS_ITEMP(op)) + return 0; + + if (op->type == SYMBOL && + (op->operand.symOperand->level == 0 || + IS_STATIC(op->operand.symOperand->etype) || + IS_EXTERN(op->operand.symOperand->etype)) + ) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isOperandVolatile - return 1 if the operand is volatile */ +/*-----------------------------------------------------------------*/ +int isOperandVolatile ( operand *op , bool chkTemp) +{ + link *optype ; + link *opetype ; + + if (IS_ITEMP(op) && !chkTemp) + return 0; + + opetype = getSpec(optype = operandType(op)); + + if (IS_PTR(optype) && DCL_PTR_VOLATILE(optype)) + return 1; + + if (IS_VOLATILE(opetype)) + return 1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isOperandLiteral - returns 1 if an operand contains a literal */ +/*-----------------------------------------------------------------*/ +int isOperandLiteral ( operand *op ) +{ + link *opetype ; + + if (!op) + return 0; + + opetype = getSpec (operandType(op)); + + if (IS_LITERAL(opetype)) + return 1; + + return 0; +} +/*-----------------------------------------------------------------*/ +/* isOperandInFarSpace - will return true if operand is in farSpace*/ +/*-----------------------------------------------------------------*/ +bool isOperandInFarSpace (operand *op) +{ + link *etype; + + if (!op) + return FALSE; + + if (!IS_SYMOP(op)) + return FALSE ; + + if (!IS_TRUE_SYMOP(op)) { + if (SPIL_LOC(op)) + etype = SPIL_LOC(op)->etype; + else + return FALSE; + } + + etype = getSpec(operandType(op)); + return (IN_FARSPACE(SPEC_OCLS(etype)) ? TRUE : FALSE); +} + +/*-----------------------------------------------------------------*/ +/* operandLitValue - literal value of an operand */ +/*-----------------------------------------------------------------*/ +double operandLitValue ( operand *op ) +{ + assert(isOperandLiteral(op)); + + return floatFromVal(op->operand.valOperand); +} + +/*-----------------------------------------------------------------*/ +/* operandOperation - perforoms operations on operands */ +/*-----------------------------------------------------------------*/ +operand *operandOperation (operand *left,operand *right, + int op, link *type) +{ + operand *retval = (operand *)0; + + assert(isOperandLiteral(left)); + if (right) + assert(isOperandLiteral(right)); + + switch (op) { + case '+' : + retval = operandFromValue (valCastLiteral(type, + operandLitValue(left) + + operandLitValue(right))); + break ; + case '-' : + retval = operandFromValue(valCastLiteral(type, + operandLitValue(left) - + operandLitValue(right))); + break; + case '*': + retval = operandFromValue(valCastLiteral(type, + operandLitValue(left) * + operandLitValue(right))); + break; + case '/': + if ((unsigned long) operandLitValue(right) == 0){ + werror(E_DIVIDE_BY_ZERO); + retval = right; + + } + else + retval = operandFromValue (valCastLiteral(type, + operandLitValue(left) / + operandLitValue(right))); + break; + case '%': + if ((unsigned long) operandLitValue(right) == 0){ + werror(E_DIVIDE_BY_ZERO); + retval = right; + } + else + retval = operandFromLit ((unsigned long) operandLitValue(left) % + (unsigned long) operandLitValue(right)); + break; + case LEFT_OP : + retval = operandFromLit ((unsigned long) operandLitValue(left) << + (unsigned long) operandLitValue(right)); + break; + case RIGHT_OP : + retval = operandFromLit ((unsigned long) operandLitValue(left) >> + (unsigned long) operandLitValue(right)); + break; + case EQ_OP : + retval = operandFromLit (operandLitValue(left) == + operandLitValue(right)); + break; + case '<' : + retval = operandFromLit (operandLitValue(left) < + operandLitValue(right)); + break; + case LE_OP : + retval = operandFromLit (operandLitValue(left) <= + operandLitValue(right)); + break; + case NE_OP : + retval = operandFromLit (operandLitValue(left) != + operandLitValue(right)); + break; + case '>' : + retval = operandFromLit (operandLitValue(left) > + operandLitValue(right)); + break; + case GE_OP : + retval = operandFromLit (operandLitValue(left) >= + operandLitValue(right)); + break; + case BITWISEAND : + retval = operandFromLit ((unsigned long) operandLitValue(left) & + (unsigned long) operandLitValue(right)); + break; + case '|' : + retval = operandFromLit ((unsigned long) operandLitValue(left) | + (unsigned long) operandLitValue(right)); + break; + case '^' : + retval = operandFromLit ((unsigned long) operandLitValue(left) ^ + (unsigned long) operandLitValue(right)); + break; + case AND_OP: + retval = operandFromLit (operandLitValue(left) && + operandLitValue(right)); + break; + case OR_OP: + retval = operandFromLit (operandLitValue(left) || + operandLitValue(right)); + break; + case RRC: + { + long i = operandLitValue(left); + + retval = operandFromLit ((i >> (getSize(operandType(left))*8 - 1)) | + (i << 1)); + } + break; + case RLC: + { + long i = operandLitValue(left); + + retval = operandFromLit ((i << (getSize(operandType(left))*8 - 1)) | + (i >> 1)); + } + break; + + case UNARYMINUS: + retval = operandFromLit(-1 * operandLitValue(left)); + break; + + case '~': + retval = operandFromLit(~ ((long) operandLitValue(left))); + break; + + case '!': + retval = operandFromLit(! operandLitValue(left)); + break; + + default : + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + " operandOperation invalid operator "); + assert (0); + } + + return retval; +} + + +/*-----------------------------------------------------------------*/ +/* isOperandEqual - compares two operand & return 1 if they r = */ +/*-----------------------------------------------------------------*/ +int isOperandEqual (operand *left, operand *right) +{ + /* if the pointers are equal then they are equal */ + if ( left == right ) + return 1; + + /* if either of them null then false */ + if ( !left || !right) + return 0; + + if (left->type != right->type) + return 0; + + if (IS_SYMOP(left) && IS_SYMOP(right)) + return left->key == right->key ; + + /* if types are the same */ + switch (left->type) { + case SYMBOL : + return isSymbolEqual(left->operand.symOperand, + right->operand.symOperand); + case VALUE : + return (floatFromVal(left->operand.valOperand) == + floatFromVal(right->operand.valOperand)); + case TYPE : + if (checkType(left->operand.typeOperand, + right->operand.typeOperand) == 1) + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isiCodeEqual - comapres two iCodes are returns true if yes */ +/*-----------------------------------------------------------------*/ +int isiCodeEqual (iCode *left, iCode *right) +{ + /* if the same pointer */ + if (left == right) + return 1; + + /* if either of them null */ + if (!left || !right) + return 0; + + /* if operand are the same */ + if ( left->op == right->op ) { + + /* compare all the elements depending on type */ + if (left->op != IFX ) { + if (!isOperandEqual(IC_LEFT(left),IC_LEFT(right))) + return 0; + if (!isOperandEqual(IC_RIGHT(left),IC_RIGHT(right))) + return 0; + + } else { + if (!isOperandEqual(IC_COND(left),IC_COND(right))) + return 0; + if (!isSymbolEqual (IC_TRUE(left),IC_TRUE(right))) + return 0; + if (!isSymbolEqual(IC_FALSE(left),IC_FALSE(right))) + return 0; + } + return 1; + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* operand from operand - creates an operand holder for the type */ +/*-----------------------------------------------------------------*/ +operand *operandFromOperand (operand *op) +{ + operand *nop = newOperand(); + + nop->type = op->type; + nop->isaddr = op->isaddr ; + nop->key = op->key ; + nop->isvolatile = op->isvolatile ; + nop->isGlobal = op->isGlobal ; + nop->isLiteral= op->isLiteral ; + nop->noSpilLoc= op->noSpilLoc; + nop->usesDefs = op->usesDefs; + nop->isParm = op->isParm; + nop->parmBytes = op->parmBytes; + + switch (nop->type) { + case SYMBOL : + nop->operand.symOperand = op->operand.symOperand ; + break; + case VALUE : + nop->operand.valOperand = op->operand.valOperand; + break; + case TYPE : + nop->operand.typeOperand = op->operand.typeOperand ; + break ; + } + + return nop; +} + +/*-----------------------------------------------------------------*/ +/* opFromOpWithDU - makes a copy of the operand and DU chains */ +/*-----------------------------------------------------------------*/ +operand *opFromOpWithDU (operand *op, bitVect *defs, bitVect *uses) +{ + operand *nop = operandFromOperand(op); + + if (nop->type == SYMBOL) { + OP_SYMBOL(nop)->defs = bitVectCopy(defs); + OP_SYMBOL(nop)->uses = bitVectCopy(uses); + } + + return nop; +} + +/*-----------------------------------------------------------------*/ +/* operandFromSymbol - creates an operand from a symbol */ +/*-----------------------------------------------------------------*/ +operand *operandFromSymbol (symbol *sym) +{ + operand *op ; + iCode *ic ; + + /* if the symbol's type is a literal */ + /* then it is an enumerator type */ + if (IS_LITERAL(sym->etype) && SPEC_ENUM(sym->etype)) + return operandFromValue (valFromType(sym->etype)); + + if (!sym->key) + sym->key = ++operandKey ; + + /* if this an implicit variable, means struct/union */ + /* member so just return it */ + if (sym->implicit || IS_FUNC(sym->type)) { + op = newOperand(); + op->type = SYMBOL ; + op->operand.symOperand = sym; + op->key = sym->key ; + op->isvolatile = isOperandVolatile(op,TRUE); + op->isGlobal = isOperandGlobal(op); + return op; + } + + /* under the following conditions create a + register equivalent for a local symbol */ + if (!IS_AGGREGATE(sym->type) && /* not an aggregate */ + !IS_FUNC(sym->type) && /* not a function */ + !sym->_isparm && /* not a parameter */ + sym->level && /* is a local variable */ + !sym->addrtaken && /* whose address has not been taken */ + !sym->reqv && /* does not already have a register euivalence */ + !IS_VOLATILE(sym->etype) && /* not declared as volatile */ + !IS_STATIC(sym->etype) && /* and not declared static */ + !sym->islbl && + !IN_FARSPACE(SPEC_OCLS(sym->etype))) { /* not a label */ + + /* we will use it after all optimizations + and before liveRange calculation */ + sym->reqv = newiTempOperand(sym->type,0); + sym->reqv->key = sym->key ; + OP_SYMBOL(sym->reqv)->key = sym->key; + OP_SYMBOL(sym->reqv)->isreqv = 1; + OP_SYMBOL(sym->reqv)->islocal = 1; + SPIL_LOC(sym->reqv) = sym; + } + + if (!IS_AGGREGATE(sym->type)) { + op = newOperand(); + op->type = SYMBOL; + op->operand.symOperand = sym; + op->isaddr = 1; + op->key = sym->key; + op->isvolatile = isOperandVolatile(op,TRUE); + op->isGlobal = isOperandGlobal(op); + op->isPtr = IS_PTR(operandType(op)); + op->isParm = sym->_isparm ; + return op; + } + + /* create :- */ + /* itemp = &[_symbol] */ + + ic = newiCode(ADDRESS_OF,newOperand(),NULL); + IC_LEFT(ic)->type = SYMBOL ; + IC_LEFT(ic)->operand.symOperand = sym ; + IC_LEFT(ic)->key = sym->key; + (IC_LEFT(ic))->isvolatile = isOperandVolatile(IC_LEFT(ic),TRUE); + (IC_LEFT(ic))->isGlobal = isOperandGlobal(IC_LEFT(ic)); + IC_LEFT(ic)->isPtr = IS_PTR(operandType(IC_LEFT(ic))); + + /* create result */ + IC_RESULT(ic) = newiTempOperand(sym->type,0); + if (IS_ARRAY(sym->type)) { + IC_RESULT(ic) = geniCodeArray2Ptr (IC_RESULT(ic)); + IC_RESULT(ic)->isaddr = 0; + } else + IC_RESULT(ic)->isaddr = (!IS_AGGREGATE(sym->type)); + + IC_RESULT(ic)->operand.symOperand->args = sym->args; + + ADDTOCHAIN(ic); + + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* operandFromValue - creates an operand from value */ +/*-----------------------------------------------------------------*/ +operand *operandFromValue (value *val) +{ + operand *op ; + + /* if this is a symbol then do the symbol thing */ + if (val->sym) + return operandFromSymbol (val->sym); + + /* this is not a symbol */ + op = newOperand(); + op->type = VALUE ; + op->operand.valOperand = val ; + op->isLiteral = isOperandLiteral(op); + return op; +} + +/*-----------------------------------------------------------------*/ +/* operandFromLink - operand from typeChain */ +/*-----------------------------------------------------------------*/ +operand *operandFromLink (link *type) +{ + operand *op ; + + /* operand from link */ + if ( ! type ) + return NULL ; + + op = newOperand(); + op->type = TYPE ; + op->operand.typeOperand = copyLinkChain(type); + return op; +} + +/*-----------------------------------------------------------------*/ +/* operandFromLit - makes an operand from a literal value */ +/*-----------------------------------------------------------------*/ +operand *operandFromLit ( float i) +{ + return operandFromValue (valueFromLit (i)); +} + +/*-----------------------------------------------------------------*/ +/* operandFromAst - creates an operand from an ast */ +/*-----------------------------------------------------------------*/ +operand *operandFromAst ( ast *tree ) +{ + + if (! tree ) + return NULL ; + + /* depending on type do */ + switch (tree->type ) { + case EX_OP : + return ast2iCode (tree) ; + break ; + + case EX_VALUE : + return operandFromValue(tree->opval.val) ; + break ; + + case EX_LINK : + return operandFromLink (tree->opval.lnk) ; + } + + assert(0); + /* Just to keep the comiler happy */ + return (operand *)0; +} + +/*-----------------------------------------------------------------*/ +/* setOperandType - sets the operand's type to the given type */ +/*-----------------------------------------------------------------*/ +void setOperandType (operand *op, link *type) +{ + /* depending on the type of operand */ + switch (op->type) { + + case VALUE : + op->operand.valOperand->etype = + getSpec( op->operand.valOperand->type = + copyLinkChain (type )) ; + return ; + + case SYMBOL : + if (op->operand.symOperand->isitmp ) + op->operand.symOperand->etype = + getSpec( op->operand.symOperand->type = + copyLinkChain (type )) ; + else + werror (E_INTERNAL_ERROR,__FILE__,__LINE__, + "attempt to modify type of source"); + return; + + case TYPE: + op->operand.typeOperand = copyLinkChain (type); + return ; + } + +} + +/*-----------------------------------------------------------------*/ +/* geniCodeValueAtAddress - generate intermeditate code for value */ +/* at address */ +/*-----------------------------------------------------------------*/ +operand *geniCodeRValue (operand *op, bool force) +{ + iCode *ic ; + link *type = operandType(op); + link *etype= getSpec(type); + + /* if this is an array & already */ + /* an address then return this */ + if (IS_AGGREGATE(type) || + (IS_PTR(type) && !force && !op->isaddr)) + return operandFromOperand(op); + + /* if this is not an address then must be */ + /* rvalue already so return this one */ + if (!op->isaddr) + return op ; + + /* if this is not a temp symbol then */ + if (!IS_ITEMP(op) && + !force && + !IN_FARSPACE(SPEC_OCLS(etype))) { + op = operandFromOperand(op); + op->isaddr = 0; + return op; + } + + if (IS_SPEC(type) && + IS_TRUE_SYMOP(op) && + !IN_FARSPACE(SPEC_OCLS(etype))) { + op = operandFromOperand(op); + op->isaddr = 0; + return op; + } + + ic = newiCode(GET_VALUE_AT_ADDRESS,op,NULL); + if (IS_PTR(type) && op->isaddr && force) + type = type->next; + + type = copyLinkChain(type); + + IC_RESULT(ic) = newiTempOperand (type,1); + IC_RESULT(ic)->isaddr = 0; + +/* ic->supportRtn = ((IS_GENPTR(type) | op->isGptr) & op->isaddr); */ + + /* if the right is a symbol */ + if (op->type == SYMBOL) + IC_RESULT(ic)->operand.symOperand->args = + op->operand.symOperand->args ; + ADDTOCHAIN(ic); + + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeCast - changes the value from one type to another */ +/*-----------------------------------------------------------------*/ +operand *geniCodeCast (link *type, operand *op, bool implicit) +{ + iCode *ic ; + link *optype ; + link *opetype = getSpec(optype = operandType(op)); + link *restype ; + + /* one of them has size zero then error */ + if (IS_VOID(optype)) { + werror(E_CAST_ZERO); + return op; + } + + /* if the operand is already the desired type then do nothing */ + if ( checkType (type,optype) == 1) + return op; + + /* if this is a literal then just change the type & return */ + if (IS_LITERAL(opetype) && !IS_PTR(type) && !IS_PTR(optype)) + return operandFromValue(valCastLiteral(type, + operandLitValue(op))); + + /* if casting to some pointer type && + the destination is not a generic pointer + then give a warning : (only for implicit casts)*/ + if (IS_PTR(optype) && implicit && + (DCL_TYPE(optype) != DCL_TYPE(type)) && + !IS_GENPTR(type)) { + werror(E_INCOMPAT_CAST); + werror(E_CONTINUE,"from type '"); + printTypeChain(optype,stderr);fprintf(stderr,"' to type '"); + printTypeChain(type,stderr);fprintf(stderr,"'\n"); + } + + /* if they are the same size create an assignment */ + if (getSize(type) == getSize(optype) && + !IS_BITFIELD(type) && + !IS_FLOAT(type) && + !IS_FLOAT(optype) && + ((IS_SPEC(type) && IS_SPEC(optype)) || + (!IS_SPEC(type) && !IS_SPEC(optype)))) { + + ic = newiCode('=',NULL,op); + IC_RESULT(ic) = newiTempOperand(type,0); + SPIL_LOC(IC_RESULT(ic)) = + (IS_TRUE_SYMOP(op) ? OP_SYMBOL(op) : NULL); + IC_RESULT(ic)->isaddr = 0; + } else { + ic = newiCode(CAST,operandFromLink(type), + geniCodeRValue(op,FALSE)); + + IC_RESULT(ic)= newiTempOperand(type,0); + } + + /* preserve the storage class & output class */ + /* of the original variable */ + restype = getSpec(operandType(IC_RESULT(ic))); + SPEC_SCLS(restype) = SPEC_SCLS(opetype); + SPEC_OCLS(restype) = SPEC_OCLS(opetype); + + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeLabel - will create a Label */ +/*-----------------------------------------------------------------*/ +void geniCodeLabel (symbol *label) +{ + iCode *ic; + + ic = newiCodeLabelGoto(LABEL,label); + ADDTOCHAIN(ic); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeGoto - will create a Goto */ +/*-----------------------------------------------------------------*/ +void geniCodeGoto (symbol *label) +{ + iCode *ic; + + ic = newiCodeLabelGoto(GOTO,label); + ADDTOCHAIN(ic); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeMultiply - gen intermediate code for multiplication */ +/*-----------------------------------------------------------------*/ +operand *geniCodeMultiply (operand *left, operand *right) +{ + iCode *ic ; + int p2 = 0; + link *resType ; + LRTYPE ; + + /* if they are both literal then we know the result */ + if (IS_LITERAL(letype) && IS_LITERAL(retype)) + return operandFromValue (valMult(left->operand.valOperand, + right->operand.valOperand)); + + resType = computeType (ltype,rtype) ; + left = geniCodeCast(resType,left,TRUE); + right= geniCodeCast(resType,right,TRUE); + + /* if the right is a literal & power of 2 */ + /* then make it a left shift */ + if (IS_LITERAL(retype) && !IS_FLOAT(letype) && + (p2 = powof2 ((unsigned long)floatFromVal(right->operand.valOperand)))) + ic = newiCode(LEFT_OP, left,operandFromLit(p2)); /* left shift */ + else { + ic = newiCode('*',left,right); /* normal multiplication */ + /* if the size left or right > 1 then support routine */ + if (getSize(ltype) > 1 || getSize(rtype) > 1) + ic->supportRtn = 1; + + } + IC_RESULT(ic) = newiTempOperand(resType,1); + + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeDivision - gen intermediate code for division */ +/*-----------------------------------------------------------------*/ +operand *geniCodeDivision (operand *left, operand *right) +{ + iCode *ic ; + int p2 = 0; + link *resType; + link *rtype = operandType(right); + link *retype= getSpec(rtype); + link *ltype = operandType(left); + link *letype= getSpec(ltype); + + resType = computeType (ltype,rtype) ; + left = geniCodeCast(resType,left,TRUE); + right= geniCodeCast(resType,right,TRUE); + + /* if the right is a literal & power of 2 */ + /* then make it a right shift */ + if (IS_LITERAL(retype) && + !IS_FLOAT(letype) && + (p2 = powof2 ((unsigned long) + floatFromVal(right->operand.valOperand)))) + ic = newiCode(RIGHT_OP, left,operandFromLit(p2)); /* right shift */ + else { + ic = newiCode('/',left,right); /* normal division */ + /* if the size left or right > 1 then support routine */ + if (getSize(ltype) > 1 || getSize(rtype) > 1) + ic->supportRtn = 1; + } + IC_RESULT(ic) = newiTempOperand(resType,0); + + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} +/*-----------------------------------------------------------------*/ +/* geniCodeModulus - gen intermediate code for modulus */ +/*-----------------------------------------------------------------*/ +operand *geniCodeModulus (operand *left, operand *right) +{ + iCode *ic ; + link *resType; + LRTYPE ; + + /* if they are both literal then we know the result */ + if (IS_LITERAL(letype) && IS_LITERAL(retype)) + return operandFromValue (valMod(left->operand.valOperand, + right->operand.valOperand)); + + resType = computeType (ltype,rtype) ; + left = geniCodeCast(resType,left,TRUE); + right= geniCodeCast(resType,right,TRUE); + + /* now they are the same size */ + ic = newiCode('%',left,right); + + /* if the size left or right > 1 then support routine */ + if (getSize(ltype) > 1 || getSize(rtype) > 1) + ic->supportRtn = 1; + IC_RESULT(ic) = newiTempOperand(resType,0); + + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodePtrPtrSubtract - subtracts pointer from pointer */ +/*-----------------------------------------------------------------*/ +operand *geniCodePtrPtrSubtract (operand *left, operand *right) +{ + iCode *ic ; + operand *result; + LRTYPE ; + + /* if they are both literals then */ + if (IS_LITERAL(letype) && IS_LITERAL(retype)) { + result = operandFromValue (valMinus(left->operand.valOperand, + right->operand.valOperand)); + goto subtractExit; + } + + ic = newiCode('-',left,right); + + IC_RESULT(ic) = result = newiTempOperand(newIntLink(),1); + ADDTOCHAIN(ic); + + subtractExit: + return geniCodeDivision (result, + operandFromLit(getSize(ltype->next))); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeSubtract - generates code for subtraction */ +/*-----------------------------------------------------------------*/ +operand *geniCodeSubtract (operand *left, operand *right) +{ + iCode *ic ; + int isarray= 0; + link *resType; + LRTYPE ; + + /* if they both pointers then */ + if ((IS_PTR(ltype) || IS_ARRAY(ltype)) && + (IS_PTR(rtype) || IS_ARRAY(rtype))) + return geniCodePtrPtrSubtract (left,right); + + /* if they are both literal then we know the result */ + if (IS_LITERAL(letype) && IS_LITERAL(retype)) + return operandFromValue (valMinus(left->operand.valOperand, + right->operand.valOperand)); + + /* if left is an array or pointer */ + if ( IS_PTR(ltype) || IS_ARRAY(ltype) ) { + isarray = left->isaddr ; + right = geniCodeMultiply (right, + operandFromLit(getSize(ltype->next))); + resType = copyLinkChain(IS_ARRAY(ltype) ? ltype->next : ltype); + } + else { /* make them the same size */ + resType = computeType (ltype,rtype) ; + left = geniCodeCast(resType,left,TRUE); + right= geniCodeCast(resType,right,TRUE); + } + + ic = newiCode('-',left,right); + + IC_RESULT(ic)= newiTempOperand(resType,1); + IC_RESULT(ic)->isaddr = (isarray ? 1 : 0); + + /* if left or right is a float */ + if (IS_FLOAT(ltype) || IS_FLOAT(rtype)) + ic->supportRtn = 1; + + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeAdd - generates iCode for addition */ +/*-----------------------------------------------------------------*/ +operand *geniCodeAdd (operand *left, operand *right ) +{ + iCode *ic ; + link *resType ; + operand *size ; + int isarray = 0; + LRTYPE ; + + /* if left is an array then array access */ + if (IS_ARRAY(ltype)) + return geniCodeArray (left,right); + + /* if the right side is LITERAL zero */ + /* return the left side */ + if (IS_LITERAL(retype) && !floatFromVal(valFromType(retype))) + return left; + + /* if left is literal zero return right */ + if (IS_LITERAL(letype) && !floatFromVal(valFromType(letype))) + return right ; + + /* if left is an array or pointer then size */ + if (IS_PTR(ltype)) { + + isarray = left->isaddr; + size = + operandFromLit(getSize(ltype->next)); + right = geniCodeMultiply (right ,size); + resType = copyLinkChain(ltype); + } + else { /* make them the same size */ + resType = computeType (ltype,rtype) ; + left = geniCodeCast(resType,left,TRUE); + right= geniCodeCast(resType,right,TRUE); + } + + /* if they are both literals then we know */ + if (IS_LITERAL(letype) && IS_LITERAL(retype)) + return operandFromValue (valPlus(valFromType(letype), + valFromType(retype))); + + ic = newiCode('+',left,right); + + IC_RESULT(ic) = newiTempOperand(resType,1); + IC_RESULT(ic)->isaddr = ( isarray ? 1 : 0); + + /* if left or right is a float then support + routine */ + if (IS_FLOAT(ltype) || IS_FLOAT(rtype)) + ic->supportRtn = 1; + + ADDTOCHAIN(ic); + + return IC_RESULT(ic) ; + +} + +/*-----------------------------------------------------------------*/ +/* aggrToPtr - changes an aggregate to pointer to an aggregate */ +/*-----------------------------------------------------------------*/ +link *aggrToPtr ( link *type, bool force) +{ + link *etype ; + link *ptype ; + + + if (IS_PTR(type) && !force) + return type; + + etype = getSpec(type); + ptype = newLink(); + + ptype->next = type; + /* if the output class is generic */ + if (SPEC_OCLS(etype) == generic) + DCL_TYPE(ptype) = GPOINTER; + else + if (SPEC_OCLS(etype)->codesp ) { + DCL_TYPE(ptype) = CPOINTER ; + DCL_PTR_CONST(ptype) = 1; + } + else + if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) + DCL_TYPE(ptype) = FPOINTER ; + else + if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) + DCL_TYPE(ptype) = PPOINTER ; + else + if (SPEC_OCLS(etype) == idata) + DCL_TYPE(ptype) = IPOINTER; + else + DCL_TYPE(ptype) = POINTER ; + + /* if the variable was declared a constant */ + /* then the pointer points to a constant */ + if (IS_CONSTANT(etype) ) + DCL_PTR_CONST(ptype) = 1; + + /* the variable was volatile then pointer to volatile */ + if (IS_VOLATILE(etype)) + DCL_PTR_VOLATILE(ptype) = 1; + return ptype; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeArray2Ptr - array to pointer */ +/*-----------------------------------------------------------------*/ +operand *geniCodeArray2Ptr (operand *op) +{ + link *optype = operandType(op); + link *opetype = getSpec(optype); + + /* set the pointer depending on the storage class */ + if (SPEC_OCLS(opetype)->codesp ) { + DCL_TYPE(optype) = CPOINTER ; + DCL_PTR_CONST(optype) = 1; + } + else + if (SPEC_OCLS(opetype)->fmap && !SPEC_OCLS(opetype)->paged) + DCL_TYPE(optype) = FPOINTER ; + else + if (SPEC_OCLS(opetype)->fmap && SPEC_OCLS(opetype)->paged) + DCL_TYPE(optype) = PPOINTER ; + else + if (SPEC_OCLS(opetype) == idata) + DCL_TYPE(optype) = IPOINTER; + else + DCL_TYPE(optype) = POINTER ; + + /* if the variable was declared a constant */ + /* then the pointer points to a constant */ + if (IS_CONSTANT(opetype) ) + DCL_PTR_CONST(optype) = 1; + + /* the variable was volatile then pointer to volatile */ + if (IS_VOLATILE(opetype)) + DCL_PTR_VOLATILE(optype) = 1; + op->isaddr = 0; + return op; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeArray - array access */ +/*-----------------------------------------------------------------*/ +operand *geniCodeArray (operand *left,operand *right) +{ + iCode *ic; + link *ltype = operandType(left); + + if (IS_PTR(ltype)) { + operand *r ; + int olval = lvaluereq ; + lvaluereq = IS_PTR(ltype->next); + r= geniCodeDerefPtr(geniCodeAdd(left,right)); + lvaluereq = olval; + return r; + } + + /* array access */ + right = geniCodeMultiply(right, + operandFromLit(getSize(ltype->next))); + + /* we can check for limits here */ + if (isOperandLiteral(right) && + IS_ARRAY(ltype) && + DCL_ELEM(ltype) && + (operandLitValue(right)/getSize(ltype->next)) >= DCL_ELEM(ltype)) { + werror(E_ARRAY_BOUND); + right = operandFromLit(0); + } + + ic = newiCode('+',left,right); + + IC_RESULT(ic) = newiTempOperand(((IS_PTR(ltype) && + !IS_AGGREGATE(ltype->next) && + !IS_PTR(ltype->next)) + ? ltype : ltype->next),0); +/* IC_RESULT(ic) = newiTempOperand(ltype->next,0); */ + IC_RESULT(ic)->isaddr = (!IS_AGGREGATE(ltype->next)); + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeStruct - generates intermediate code for structres */ +/*-----------------------------------------------------------------*/ +operand *geniCodeStruct (operand *left, operand *right, bool islval) +{ + iCode *ic ; + link *type = operandType(left); + link *etype = getSpec(type); + link *retype ; + symbol *element = getStructElement(SPEC_STRUCT(etype), + right->operand.symOperand); + + /* add the offset */ + ic = newiCode('+',left,operandFromLit(element->offset)); + + IC_RESULT(ic) = newiTempOperand(element->type,0); + + /* preserve the storage & output class of the struct */ + /* as well as the volatile attribute */ + retype = getSpec(operandType(IC_RESULT(ic))); + SPEC_SCLS(retype) = SPEC_SCLS(etype); + SPEC_OCLS(retype) = SPEC_OCLS(etype); + SPEC_VOLATILE(retype) |= SPEC_VOLATILE(etype); + + if (IS_PTR(element->type)) + setOperandType(IC_RESULT(ic),aggrToPtr(operandType(IC_RESULT(ic)),TRUE)); + + IC_RESULT(ic)->isaddr = (!IS_AGGREGATE(element->type)); + + + ADDTOCHAIN(ic); + return (islval ? IC_RESULT(ic) : geniCodeRValue(IC_RESULT(ic),TRUE)); +} + +/*-----------------------------------------------------------------*/ +/* geniCodePostInc - generate int code for Post increment */ +/*-----------------------------------------------------------------*/ +operand *geniCodePostInc (operand *op) +{ + iCode *ic ; + operand *rOp ; + link *optype = operandType(op); + operand *result ; + operand *rv = (IS_ITEMP(op) ? + geniCodeRValue(op,(IS_PTR(optype) ? TRUE : FALSE)) : + op); + link *rvtype = operandType(rv); + int diff = (IS_PTR(rvtype) && DCL_TYPE(optype) != DCL_TYPE(rvtype)); + int size = 0; + + /* if this is not an address we have trouble */ + if ( ! op->isaddr ) { + werror (E_LVALUE_REQUIRED,"++"); + return op ; + } + + rOp = newiTempOperand((diff ? rvtype : optype),0); + rOp->noSpilLoc = 1; + + if (IS_ITEMP(rv)) + rv->noSpilLoc = 1; + + geniCodeAssign(rOp,rv,0); + + size = (IS_PTR(rvtype) ? getSize(rvtype->next) : 1); + ic = newiCode('+',rv,operandFromLit(size)); + IC_RESULT(ic) = result =newiTempOperand((diff ? rvtype : optype),0); + ADDTOCHAIN(ic); + + geniCodeAssign(op,result,0); + + return rOp; + +} + +/*-----------------------------------------------------------------*/ +/* geniCodePreInc - generate code for preIncrement */ +/*-----------------------------------------------------------------*/ +operand *geniCodePreInc (operand *op) +{ + iCode *ic ; + link *optype = operandType(op); + operand *rop = (IS_ITEMP(op) ? + geniCodeRValue (op,(IS_PTR(optype) ? TRUE : FALSE)) : + op); + link *roptype = operandType(rop); + int diff = (IS_PTR(roptype) && (DCL_TYPE(roptype) != DCL_TYPE(optype))); + operand *result; + int size = 0; + + if ( ! op->isaddr ) { + werror(E_LVALUE_REQUIRED,"++"); + return op ; + } + + + size = (IS_PTR(roptype) ? getSize(roptype->next) : 1); + ic = newiCode('+',rop,operandFromLit(size)); + IC_RESULT(ic) = result = newiTempOperand((diff ? roptype : optype),0) ; + ADDTOCHAIN(ic); + + + return geniCodeAssign(op,result,0) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodePostDec - generates code for Post decrement */ +/*-----------------------------------------------------------------*/ +operand *geniCodePostDec (operand *op) +{ + iCode *ic ; + operand *rOp ; + link *optype = operandType(op); + operand *result ; + operand *rv = (IS_ITEMP(op) ? + geniCodeRValue(op,(IS_PTR(optype) ? TRUE : FALSE)) : + op); + link *rvtype = operandType(rv); + int diff = (IS_PTR(rvtype) && DCL_TYPE(optype) != DCL_TYPE(rvtype)); + int size = 0; + + /* if this is not an address we have trouble */ + if ( ! op->isaddr ) { + werror (E_LVALUE_REQUIRED,"++"); + return op ; + } + + rOp = newiTempOperand((diff ? rvtype : optype),0); + rOp->noSpilLoc = 1; + + if (IS_ITEMP(rv)) + rv->noSpilLoc = 1; + + geniCodeAssign(rOp,rv,0); + + size = (IS_PTR(rvtype) ? getSize(rvtype->next) : 1); + ic = newiCode('-',rv,operandFromLit(size)); + IC_RESULT(ic) = result =newiTempOperand((diff ? rvtype : optype),0); + ADDTOCHAIN(ic); + + geniCodeAssign(op,result,0); + + return rOp; + +} + +/*-----------------------------------------------------------------*/ +/* geniCodePreDec - generate code for pre decrement */ +/*-----------------------------------------------------------------*/ +operand *geniCodePreDec (operand *op) +{ + iCode *ic ; + link *optype = operandType(op); + operand *rop = (IS_ITEMP(op) ? + geniCodeRValue (op,(IS_PTR(optype) ? TRUE : FALSE)) : + op); + link *roptype = operandType(rop); + int diff = (IS_PTR(roptype) && (DCL_TYPE(roptype) != DCL_TYPE(optype))); + operand *result; + int size = 0; + + if ( ! op->isaddr ) { + werror(E_LVALUE_REQUIRED,"++"); + return op ; + } + + + size = (IS_PTR(roptype) ? getSize(roptype->next) : 1); + ic = newiCode('-',rop,operandFromLit(size)); + IC_RESULT(ic) = result = newiTempOperand((diff ? roptype : optype),0) ; + ADDTOCHAIN(ic); + + + return geniCodeAssign(op,result,0) ; +} + + +/*-----------------------------------------------------------------*/ +/* geniCodeBitwise - gen int code for bitWise operators */ +/*-----------------------------------------------------------------*/ +operand *geniCodeBitwise (operand *left, operand *right, + int oper, link *resType) +{ + iCode *ic; + + left = geniCodeCast(resType,left,TRUE); + right= geniCodeCast(resType,right,TRUE); + + ic = newiCode(oper,left,right); + IC_RESULT(ic) = newiTempOperand(resType,0); + + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeAddressOf - gens icode for '&' address of operator */ +/*-----------------------------------------------------------------*/ +operand *geniCodeAddressOf (operand *op) +{ + iCode *ic; + link *p ; + link *optype = operandType(op); + link *opetype= getSpec(optype); + + /* this must be a lvalue */ + if (!op->isaddr && !IS_AGGREGATE(optype)) { + werror (E_LVALUE_REQUIRED,"&"); + return op; + } + + p = newLink(); + p->class = DECLARATOR ; + /* set the pointer depending on the storage class */ + if (SPEC_OCLS(opetype)->codesp ) { + DCL_TYPE(p) = CPOINTER ; + DCL_PTR_CONST(p) = 1; + } + else + if (SPEC_OCLS(opetype)->fmap && !SPEC_OCLS(opetype)->paged) + DCL_TYPE(p) = FPOINTER ; + else + if (SPEC_OCLS(opetype)->fmap && SPEC_OCLS(opetype)->paged) + DCL_TYPE(p) = PPOINTER ; + else + if (SPEC_OCLS(opetype) == idata) + DCL_TYPE(p) = IPOINTER; + else + if (SPEC_OCLS(opetype) == data || + SPEC_OCLS(opetype) == overlay) + DCL_TYPE(p) = POINTER ; + else + DCL_TYPE(p) = GPOINTER; + + /* make sure we preserve the const & volatile */ + if (IS_CONSTANT(opetype)) + DCL_PTR_CONST(p) = 1; + + if (IS_VOLATILE(opetype)) + DCL_PTR_VOLATILE(p) = 1; + + p->next = copyLinkChain(optype); + + /* if already a temp */ + if (IS_ITEMP(op)) { + setOperandType (op,p); + op->isaddr= 0; + return op; + } + + /* other wise make this of the type coming in */ + ic = newiCode(ADDRESS_OF,op,NULL); + IC_RESULT(ic) = newiTempOperand(p,1); + IC_RESULT(ic)->isaddr = 0; + ADDTOCHAIN(ic); + return IC_RESULT(ic); +} +/*-----------------------------------------------------------------*/ +/* setOClass - sets the output class depending on the pointer type */ +/*-----------------------------------------------------------------*/ +void setOClass (link *ptr, link *spec) +{ + switch (DCL_TYPE(ptr)) { + case POINTER: + SPEC_OCLS(spec) = data ; + break ; + + case GPOINTER: + SPEC_OCLS(spec) = generic; + break; + + case FPOINTER: + SPEC_OCLS(spec) = xdata ; + break ; + + case CPOINTER: + SPEC_OCLS(spec) = code ; + break ; + + case IPOINTER: + SPEC_OCLS(spec) = idata; + break; + + case PPOINTER: + SPEC_OCLS(spec) = xstack; + break; + + } +} + +/*-----------------------------------------------------------------*/ +/* geniCodeDerefPtr - dereference pointer with '*' */ +/*-----------------------------------------------------------------*/ +operand *geniCodeDerefPtr (operand *op) +{ + link *rtype , *retype ; + link *optype = operandType(op); + + /* if this is a pointer then generate the rvalue */ + if (IS_PTR(optype)) { + if (IS_TRUE_SYMOP(op)) { + op->isaddr = 1; + op = geniCodeRValue(op,TRUE); + } + else + op = geniCodeRValue(op,TRUE); + } + + /* now get rid of the pointer part */ + if (lvaluereq && IS_ITEMP(op)) + retype = getSpec(rtype = copyLinkChain(optype)) ; + else + retype = getSpec(rtype = copyLinkChain(optype->next)) ; + + /* if this is a pointer then outputclass needs 2b updated */ + if (IS_PTR(optype)) + setOClass(optype,retype); + + op = geniCodeRValue(op,TRUE); + op->isGptr = IS_GENPTR(optype); + + /* if the pointer was declared as a constant */ + /* then we cannot allow assignment to the derefed */ + if (IS_PTR_CONST(optype)) + SPEC_CONST(retype) = 1; + + + setOperandType(op,rtype); + op->isaddr = (IS_PTR(rtype) || + IS_STRUCT(rtype) || + IS_INT(rtype) || + IS_CHAR(rtype) || + IS_FLOAT(rtype) ); + + return op; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeUnaryMinus - does a unary minus of the operand */ +/*-----------------------------------------------------------------*/ +operand *geniCodeUnaryMinus (operand *op) +{ + iCode *ic ; + link *optype = operandType(op); + + if (IS_LITERAL(optype)) + return operandFromLit(- floatFromVal(op->operand.valOperand)); + + ic = newiCode(UNARYMINUS,op,NULL); + IC_RESULT(ic) = newiTempOperand(optype,0); + ADDTOCHAIN(ic); + return IC_RESULT(ic); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeLeftShift - gen i code for left shift */ +/*-----------------------------------------------------------------*/ +operand *geniCodeLeftShift (operand *left, operand *right) +{ + iCode *ic; + link *ltype = operandType(left); + + ic = newiCode(LEFT_OP,left,right); + IC_RESULT(ic) = newiTempOperand(ltype,0); + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeRightShift - gen i code for right shift */ +/*-----------------------------------------------------------------*/ +operand *geniCodeRightShift (operand *left, operand *right) +{ + iCode *ic; + link *ltype = operandType(left); + + ic = newiCode(RIGHT_OP,left,right); + IC_RESULT(ic) = newiTempOperand(ltype,0); + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeLogic- logic code */ +/*-----------------------------------------------------------------*/ +operand *geniCodeLogic (operand *left, operand *right, int op ) +{ + iCode *ic ; + link *ctype; + link *rtype = operandType(right); + link *ltype = operandType(left); + + /* left is integral type and right is literal then + check if the literal value is within bounds */ + if (IS_INTEGRAL(ltype) && IS_LITERAL(rtype)) { + int nbits = bitsForType(ltype); + long v = operandLitValue(right); + + if (v > ((long long) 1 << nbits) && v > 0) + werror(W_CONST_RANGE," compare operation "); + } + + ctype = computeType(ltype,rtype); + left = geniCodeCast(ctype,left,TRUE); + right= geniCodeCast(ctype,right,TRUE); + + ic = newiCode(op,left,right); + IC_RESULT(ic) = newiTempOperand (newCharLink(),1); + + /* if comparing anything greater than one byte + and not a '==' || '!=' || '&&' || '||' (these + will be inlined */ + if (getSize(ctype) > 1 && + op != EQ_OP && + op != NE_OP && + op != AND_OP && + op != OR_OP ) + ic->supportRtn = 1; + + ADDTOCHAIN(ic); + return IC_RESULT(ic); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeUnary - for a a generic unary operation */ +/*-----------------------------------------------------------------*/ +operand *geniCodeUnary (operand *op, int oper ) +{ + iCode *ic = newiCode (oper,op,NULL); + + IC_RESULT(ic)= newiTempOperand(operandType(op),0); + ADDTOCHAIN(ic); + return IC_RESULT(ic) ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeConditional - geniCode for '?' ':' operation */ +/*-----------------------------------------------------------------*/ +operand *geniCodeConditional (ast *tree) +{ + iCode *ic ; + symbol *falseLabel = newiTempLabel(NULL); + symbol *exitLabel = newiTempLabel(NULL); + operand *cond = ast2iCode(tree->left); + operand *true, *false , *result; + + ic = newiCodeCondition(geniCodeRValue(cond,FALSE), + NULL,falseLabel); + ADDTOCHAIN(ic); + + true = ast2iCode(tree->right->left); + + /* move the value to a new Operand */ + result = newiTempOperand(operandType(true),0); + geniCodeAssign(result,geniCodeRValue(true,FALSE),0); + + /* generate an unconditional goto */ + geniCodeGoto(exitLabel); + + /* now for the right side */ + geniCodeLabel(falseLabel); + + false = ast2iCode(tree->right->right); + geniCodeAssign(result,geniCodeRValue(false,FALSE),0); + + /* create the exit label */ + geniCodeLabel(exitLabel); + + return result ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeAssign - generate code for assignment */ +/*-----------------------------------------------------------------*/ +operand *geniCodeAssign (operand *left, operand *right, int nosupdate) +{ + iCode *ic ; + link *ltype = operandType(left); + link *rtype = operandType(right); + + if (!left->isaddr && !IS_ITEMP(left)) { + werror(E_LVALUE_REQUIRED,"assignment"); + return left; + } + + /* left is integral type and right is literal then + check if the literal value is within bounds */ + if (IS_INTEGRAL(ltype) && IS_LITERAL(rtype)) { + int nbits = bitsForType(ltype); + long v = operandLitValue(right); + + if (v > ((long long)1 << nbits) && v > 0) + werror(W_CONST_RANGE," = operation"); + } + /* if the left & right type don't exactly match */ + /* if pointer set then make sure the check is + done with the type & not the pointer */ + /* then cast rights type to left */ + + /* first check the type for pointer assignement */ + if (left->isaddr && IS_PTR(ltype) && IS_ITEMP(left) && + checkType(ltype,rtype)<0) { + if (checkType(ltype->next,rtype) < 0) + right = geniCodeCast(ltype->next,right,TRUE); + } else + if (checkType(ltype,rtype) < 0 ) + right = geniCodeCast(ltype,right,TRUE); + + /* if left is a true symbol & ! volatile + create an assignment to temporary for + the right & then assign this temporary + to the symbol this is SSA . isn't it simple + and folks have published mountains of paper on it */ + if (IS_TRUE_SYMOP(left) && + !isOperandVolatile(left,FALSE) && + isOperandGlobal(left)) { + symbol *sym = NULL; + + if (IS_TRUE_SYMOP(right)) + sym = OP_SYMBOL(right); + ic = newiCode('=',NULL,right); + IC_RESULT(ic) = right = newiTempOperand(ltype,0); + SPIL_LOC(right) = sym ; + ADDTOCHAIN(ic); + } + + ic = newiCode('=',NULL,right); + IC_RESULT(ic) = left; + ADDTOCHAIN(ic); + + /* if left isgptr flag is set then support + routine will be required */ + if (left->isGptr) + ic->supportRtn = 1; + + ic->nosupdate = nosupdate; + return left; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeSEParms - generate code for side effecting fcalls */ +/*-----------------------------------------------------------------*/ +static void geniCodeSEParms (ast *parms) +{ + if (!parms) + return ; + + if (parms->type == EX_OP && parms->opval.op == PARAM) { + geniCodeSEParms (parms->left) ; + geniCodeSEParms (parms->right); + return ; + } + + /* hack don't like this but too lazy to think of + something better */ + if (IS_ADDRESS_OF_OP(parms)) + parms->left->lvalue = 1; + + if (IS_CAST_OP(parms) && + IS_PTR(parms->ftype) && + IS_ADDRESS_OF_OP(parms->right)) + parms->right->left->lvalue = 1; + + parms->opval.oprnd = + geniCodeRValue(ast2iCode (parms),TRUE); + + parms->type = EX_OPERAND ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeParms - generates parameters */ +/*-----------------------------------------------------------------*/ +static void geniCodeParms ( ast *parms , int *stack, link *fetype) +{ + iCode *ic ; + operand *pval ; + + if ( ! parms ) + return ; + + /* if this is a param node then do the left & right */ + if (parms->type == EX_OP && parms->opval.op == PARAM) { + geniCodeParms (parms->left, stack,fetype) ; + geniCodeParms (parms->right, stack,fetype); + return ; + } + + /* get the parameter value */ + if (parms->type == EX_OPERAND) + pval = parms->opval.oprnd ; + else { + /* maybe this else should go away ?? */ + /* hack don't like this but too lazy to think of + something better */ + if (IS_ADDRESS_OF_OP(parms)) + parms->left->lvalue = 1; + + if (IS_CAST_OP(parms) && + IS_PTR(parms->ftype) && + IS_ADDRESS_OF_OP(parms->right)) + parms->right->left->lvalue = 1; + + pval = geniCodeRValue(ast2iCode (parms),FALSE); + } + + /* if register parm then make it a send */ + if ((parms->argSym && IS_REGPARM(parms->argSym->etype)) || + IS_REGPARM(parms->etype)) { + ic = newiCode(SEND,pval,NULL); + ADDTOCHAIN(ic); + } else { + /* now decide whether to push or assign */ + if (!(options.stackAuto || IS_RENT(fetype))) { + + /* assign */ + operand *top = operandFromSymbol(parms->argSym); + geniCodeAssign(top,pval,1); + } + else { + + /* push */ + ic = newiCode(IPUSH,pval,NULL); + ic->parmPush = 1; + /* update the stack adjustment */ + *stack += getSize(operandType(pval)); + ADDTOCHAIN(ic); + } + } + +} + +/*-----------------------------------------------------------------*/ +/* geniCodeCall - generates temp code for calling */ +/*-----------------------------------------------------------------*/ +operand *geniCodeCall (operand *left, ast *parms) +{ + iCode *ic ; + operand *result ; + link *type, *etype; + int stack = 0 ; + + /* take care of parameters with side-effecting + function calls in them, this is required to take care + of overlaying function parameters */ + geniCodeSEParms ( parms ); + + /* first the parameters */ + geniCodeParms ( parms , &stack , getSpec(operandType(left))); + + /* now call : if symbol then pcall */ + if (IS_ITEMP(left)) + ic = newiCode(PCALL,left,NULL); + else + ic = newiCode(CALL,left,NULL); + + IC_ARGS(ic) = left->operand.symOperand->args ; + type = copyLinkChain(operandType(left)->next); + etype = getSpec(type); + SPEC_EXTR(etype) = 0; + IC_RESULT(ic) = result = newiTempOperand(type,1); + + ADDTOCHAIN(ic); + + /* stack adjustment after call */ + left->parmBytes = stack; + + return result; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeReceive - generate intermediate code for "receive" */ +/*-----------------------------------------------------------------*/ +static void geniCodeReceive (value *args) +{ + /* for all arguments that are passed in registers */ + while (args) { + + if (IS_REGPARM(args->etype)) { + operand *opr = operandFromValue(args); + operand *opl ; + symbol *sym = OP_SYMBOL(opr); + iCode *ic ; + + /* we will use it after all optimizations + and before liveRange calculation */ + if (!sym->addrtaken && + !IS_VOLATILE(sym->etype) && + !IN_FARSPACE(SPEC_OCLS(sym->etype))) { + opl = newiTempOperand(args->type,0); + sym->reqv = opl ; + sym->reqv->key = sym->key ; + OP_SYMBOL(sym->reqv)->key = sym->key; + OP_SYMBOL(sym->reqv)->isreqv = 1; + OP_SYMBOL(sym->reqv)->islocal= 0; + SPIL_LOC(sym->reqv) = sym; + } + + ic = newiCode(RECEIVE,NULL,NULL); + currFunc->recvSize = getSize(sym->etype); + IC_RESULT(ic) = opr; + ADDTOCHAIN(ic); + } + + args = args->next; + } +} + +/*-----------------------------------------------------------------*/ +/* geniCodeFunctionBody - create the function body */ +/*-----------------------------------------------------------------*/ +void geniCodeFunctionBody (ast *tree) +{ + iCode *ic ; + operand *func ; + link *fetype ; + int savelineno ; + + /* reset the auto generation */ + /* numbers */ + iTempNum = 0 ; + iTempLblNum = 0; + operandKey = 0 ; + iCodeKey = 0 ; + func = ast2iCode(tree->left); + fetype = getSpec(operandType(func)); + + savelineno = lineno; + lineno = OP_SYMBOL(func)->lineDef; + /* create an entry label */ + geniCodeLabel(entryLabel); + lineno = savelineno; + + /* create a proc icode */ + ic = newiCode(FUNCTION,func,NULL); + /* if the function has parmas then */ + /* save the parameters information */ + ic->argLabel.args = tree->values.args ; + ic->lineno = OP_SYMBOL(func)->lineDef; + + ADDTOCHAIN(ic); + + /* for all parameters that are passed + on registers add a "receive" */ + geniCodeReceive( tree->values.args ); + + /* generate code for the body */ + ast2iCode(tree->right); + + /* create a label for return */ + geniCodeLabel(returnLabel); + + /* now generate the end proc */ + ic = newiCode(ENDFUNCTION,func,NULL); + ADDTOCHAIN(ic); + return ; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeReturn - gen icode for 'return' statement */ +/*-----------------------------------------------------------------*/ +void geniCodeReturn (operand *op) +{ + iCode *ic; + + /* if the operand is present force an rvalue */ + if (op) + op = geniCodeRValue(op,FALSE); + + ic = newiCode(RETURN,op,NULL); + ADDTOCHAIN(ic); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeIfx - generates code for extended if statement */ +/*-----------------------------------------------------------------*/ +void geniCodeIfx (ast *tree) +{ + iCode *ic; + operand *condition = ast2iCode(tree->left); +/* link *ctype = operandType(condition); */ + link *cetype; + + /* if condition is null then exit */ + if (!condition) + goto exit ; + else + condition = geniCodeRValue(condition,FALSE); + + cetype = getSpec(operandType(condition)); + /* if the condition is a literal */ + if (IS_LITERAL(cetype)) { + if (floatFromVal(condition->operand.valOperand)) { + if (tree->trueLabel) + geniCodeGoto(tree->trueLabel); + else + assert(1); + } + else { + if (tree->falseLabel) + geniCodeGoto (tree->falseLabel); + else + assert(1); + } + goto exit; + } + + if ( tree->trueLabel ) { + ic = newiCodeCondition(condition, + tree->trueLabel, + NULL ); + ADDTOCHAIN(ic); + + if ( tree->falseLabel) + geniCodeGoto(tree->falseLabel); + } + else { + ic = newiCodeCondition (condition, + NULL, + tree->falseLabel); + ADDTOCHAIN(ic); + } + + exit: + ast2iCode(tree->right); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeJumpTable - tries to create a jump table for switch */ +/*-----------------------------------------------------------------*/ +int geniCodeJumpTable (operand *cond, value *caseVals, ast *tree) +{ + int min = 0 ,max = 0, t, cnt = 0; + value *vch; + iCode *ic; + operand *boundary; + symbol *falseLabel; + set *labels = NULL ; + + if (!tree || !caseVals) + return 0; + + /* the criteria for creating a jump table is */ + /* all integer numbers between the maximum & minimum must */ + /* be present , the maximum value should not exceed 255 */ + min = max = (int)floatFromVal(vch = caseVals); + sprintf(buffer,"_case_%d_%d", + tree->values.switchVals.swNum, + min); + addSet(&labels,newiTempLabel(buffer)); + + /* if there is only one case value then no need */ + if (!(vch = vch->next )) + return 0; + + while (vch) { + if (((t = (int)floatFromVal(vch)) - max) != 1) + return 0; + sprintf(buffer,"_case_%d_%d", + tree->values.switchVals.swNum, + t); + addSet(&labels,newiTempLabel(buffer)); + max = t; + cnt++ ; + vch = vch->next ; + } + + /* if the number of case statements <= 2 then */ + /* it is not economical to create the jump table */ + /* since two compares are needed for boundary conditions */ + if ((! optimize.noJTabBoundary && cnt <= 2) || max > (255/3)) + return 0; + + if ( tree->values.switchVals.swDefault ) + sprintf (buffer,"_default_%d",tree->values.switchVals.swNum); + else + sprintf (buffer,"_swBrk_%d",tree->values.switchVals.swNum ); + + falseLabel = newiTempLabel (buffer); + + /* so we can create a jumptable */ + /* first we rule out the boundary conditions */ + /* if only optimization says so */ + if ( ! optimize.noJTabBoundary ) { + link *cetype = getSpec(operandType(cond)); + /* no need to check the lower bound if + the condition is unsigned & minimum value is zero */ + if (!( min == 0 && SPEC_USIGN(cetype))) { + boundary = geniCodeLogic (cond,operandFromLit(min),'<'); + ic = newiCodeCondition (boundary,falseLabel,NULL); + ADDTOCHAIN(ic); + } + + /* now for upper bounds */ + boundary = geniCodeLogic(cond,operandFromLit(max),'>'); + ic = newiCodeCondition (boundary,falseLabel,NULL); + ADDTOCHAIN(ic); + } + + /* if the min is not zero then we no make it zero */ + if (min) { + cond = geniCodeSubtract(cond,operandFromLit(min)); + setOperandType(cond,ucharType); + } + + /* now create the jumptable */ + ic = newiCode(JUMPTABLE,NULL,NULL); + IC_JTCOND(ic) = cond; + IC_JTLABELS(ic) = labels; + ADDTOCHAIN(ic); + return 1; +} + +/*-----------------------------------------------------------------*/ +/* geniCodeSwitch - changes a switch to a if statement */ +/*-----------------------------------------------------------------*/ +void geniCodeSwitch (ast *tree) +{ + iCode *ic ; + operand *cond = geniCodeRValue(ast2iCode (tree->left),FALSE); + value *caseVals = tree->values.switchVals.swVals ; + symbol *trueLabel , *falseLabel; + + /* if we can make this a jump table */ + if ( geniCodeJumpTable (cond,caseVals,tree) ) + goto jumpTable ; /* no need for the comparison */ + + /* for the cases defined do */ + while (caseVals) { + + operand *compare = geniCodeLogic (cond, + operandFromValue(caseVals), + EQ_OP); + + sprintf(buffer,"_case_%d_%d", + tree->values.switchVals.swNum, + (int) floatFromVal(caseVals)); + trueLabel = newiTempLabel(buffer); + + ic = newiCodeCondition(compare,trueLabel,NULL); + ADDTOCHAIN(ic); + caseVals = caseVals->next; + } + + + + /* if default is present then goto break else break */ + if ( tree->values.switchVals.swDefault ) + sprintf (buffer,"_default_%d",tree->values.switchVals.swNum); + else + sprintf (buffer,"_swBrk_%d",tree->values.switchVals.swNum ); + + falseLabel = newiTempLabel (buffer); + geniCodeGoto(falseLabel); + + jumpTable: + ast2iCode(tree->right); +} + +/*-----------------------------------------------------------------*/ +/* geniCodeInline - intermediate code for inline assembler */ +/*-----------------------------------------------------------------*/ +static void geniCodeInline (ast *tree) +{ + iCode *ic; + + ic = newiCode(INLINEASM,NULL,NULL); + IC_INLINE(ic) = tree->values.inlineasm; + ADDTOCHAIN(ic); +} + +/*-----------------------------------------------------------------*/ +/* ast2iCode - creates an icodeList from an ast */ +/*-----------------------------------------------------------------*/ +operand *ast2iCode (ast *tree) +{ + operand *left = NULL; + operand *right= NULL; + + if (!tree) + return NULL ; + + /* set the global variables for filename & line number */ + if ( tree->filename ) + filename = tree->filename ; + if ( tree->lineno) + lineno = tree->lineno ; + if (tree->block) + block = tree->block ; + if (tree->level) + scopeLevel = tree->level; + + if (tree->type == EX_VALUE ) + return operandFromValue(tree->opval.val); + + if (tree->type == EX_LINK ) + return operandFromLink (tree->opval.lnk); + + /* if we find a nullop */ + if (tree->type == EX_OP && + ( tree->opval.op == NULLOP || + tree->opval.op == BLOCK )) { + ast2iCode (tree->left); + ast2iCode (tree->right); + return NULL ; + } + + /* special cases for not evaluating */ + if ( tree->opval.op != ':' && + tree->opval.op != '?' && + tree->opval.op != CALL && + tree->opval.op != IFX && + tree->opval.op != LABEL && + tree->opval.op != GOTO && + tree->opval.op != SWITCH && + tree->opval.op != FUNCTION && + tree->opval.op != INLINEASM ) { + if (IS_ASSIGN_OP(tree->opval.op) || IS_DEREF_OP(tree)) { + lvaluereq++; + left = operandFromAst(tree->left); + lvaluereq--; + } else { + left = operandFromAst(tree->left); + } + right= operandFromAst(tree->right); + } + + /* now depending on the type of operand */ + /* this will be a biggy */ + switch (tree->opval.op) { + + case '[' : /* array operation */ + left= geniCodeRValue (left,FALSE); + right=geniCodeRValue (right,TRUE); + + return geniCodeArray (left,right); + + case '.' : /* structure dereference */ + if (IS_PTR(operandType(left))) + left = geniCodeRValue(left,TRUE); + else + left = geniCodeRValue(left,FALSE); + + return geniCodeStruct (left,right,tree->lvalue); + + case PTR_OP: /* structure pointer dereference */ + { + link *pType; + pType = operandType(left); + left = geniCodeRValue(left,TRUE); + + setOClass (pType,getSpec(operandType(left))); + } + + return geniCodeStruct (left, right,tree->lvalue); + + case INC_OP: /* increment operator */ + if ( left ) + return geniCodePostInc (left); + else + return geniCodePreInc (right); + + case DEC_OP: /* decrement operator */ + if ( left ) + return geniCodePostDec (left); + else + return geniCodePreDec (right); + + case '&' : /* bitwise and or address of operator */ + if ( right ) { /* this is a bitwise operator */ + left= geniCodeRValue(left,FALSE); + right= geniCodeRValue(right,FALSE); + return geniCodeBitwise (left,right,BITWISEAND,tree->ftype); + } else + return geniCodeAddressOf (left); + + case '|': /* bitwise or & xor */ + case '^': + return geniCodeBitwise (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE), + tree->opval.op, + tree->ftype); + + case '/': + return geniCodeDivision (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE)); + + case '%' : + return geniCodeModulus (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE)); + case '*': + if ( right ) + return geniCodeMultiply (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE)); + else + return geniCodeDerefPtr (geniCodeRValue(left,FALSE)); + + case '-' : + if ( right ) + return geniCodeSubtract (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE)); + else + return geniCodeUnaryMinus (geniCodeRValue(left,FALSE)); + + case '+' : + if ( right ) + return geniCodeAdd (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE)); + else + return geniCodeRValue(left,FALSE) ; /* unary '+' has no meaning */ + + case LEFT_OP: + return geniCodeLeftShift (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE)); + + case RIGHT_OP: + return geniCodeRightShift (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE)); + case CAST: + return geniCodeCast (operandType(left), + geniCodeRValue(right,FALSE),FALSE); + + case '~' : + case '!' : + case RRC: + case RLC: + return geniCodeUnary (geniCodeRValue(left,FALSE),tree->opval.op); + + case GETHBIT: + { + operand *op = geniCodeUnary (geniCodeRValue(left,FALSE),tree->opval.op); + setOperandType(op,ucharType); + return op; + } + case '>' : + case '<' : + case LE_OP: + case GE_OP: + case EQ_OP: + case NE_OP: + case AND_OP: + case OR_OP: + return geniCodeLogic (geniCodeRValue(left,FALSE), + geniCodeRValue(right,FALSE), + tree->opval.op); + case '?' : + return geniCodeConditional (tree); + + case SIZEOF: + return operandFromLit(getSize(tree->right->ftype)); + + case '=' : + { + link *rtype = operandType(right); + link *ltype = operandType(left); + if (IS_PTR(rtype) && IS_ITEMP(right) + && right->isaddr && checkType(rtype->next,ltype)==1) + right = geniCodeRValue(right,TRUE); + else + right = geniCodeRValue(right,FALSE); + + geniCodeAssign (left,right,0); + return right ; + } + case MUL_ASSIGN: + return + geniCodeAssign(left, + geniCodeMultiply(geniCodeRValue (operandFromOperand(left), + FALSE), + geniCodeRValue(right,FALSE)),0); + + case DIV_ASSIGN: + return + geniCodeAssign(left, + geniCodeDivision(geniCodeRValue(operandFromOperand(left), + FALSE), + geniCodeRValue(right,FALSE)),0); + case MOD_ASSIGN: + return + geniCodeAssign(left, + geniCodeModulus(geniCodeRValue(operandFromOperand(left), + FALSE), + geniCodeRValue(right,FALSE)),0); + case ADD_ASSIGN: + { + link *rtype = operandType(right); + link *ltype = operandType(left); + if (IS_PTR(rtype) && IS_ITEMP(right) + && right->isaddr && checkType(rtype->next,ltype)==1) + right = geniCodeRValue(right,TRUE); + else + right = geniCodeRValue(right,FALSE); + + + return geniCodeAssign(left, + geniCodeAdd (geniCodeRValue(operandFromOperand(left), + FALSE), + right),0); + } + case SUB_ASSIGN: + { + link *rtype = operandType(right); + link *ltype = operandType(left); + if (IS_PTR(rtype) && IS_ITEMP(right) + && right->isaddr && checkType(rtype->next,ltype)==1) { + right = geniCodeRValue(right,TRUE); + } + else { + right = geniCodeRValue(right,FALSE); + } + return + geniCodeAssign (left, + geniCodeSubtract(geniCodeRValue(operandFromOperand(left), + FALSE), + right),0); + } + case LEFT_ASSIGN: + return + geniCodeAssign (left, + geniCodeLeftShift(geniCodeRValue(operandFromOperand(left) + ,FALSE), + geniCodeRValue(right,FALSE)),0); + case RIGHT_ASSIGN: + return + geniCodeAssign(left, + geniCodeRightShift(geniCodeRValue(operandFromOperand(left) + ,FALSE), + geniCodeRValue(right,FALSE)),0); + case AND_ASSIGN: + return + geniCodeAssign (left, + geniCodeBitwise(geniCodeRValue(operandFromOperand(left), + FALSE), + geniCodeRValue(right,FALSE), + BITWISEAND, + operandType(left)),0); + case XOR_ASSIGN: + return + geniCodeAssign (left, + geniCodeBitwise (geniCodeRValue(operandFromOperand(left), + FALSE), + geniCodeRValue(right,FALSE), + '^', + operandType(left)),0); + case OR_ASSIGN: + return + geniCodeAssign (left, + geniCodeBitwise (geniCodeRValue(operandFromOperand(left) + ,FALSE), + geniCodeRValue(right,FALSE), + '|', + operandType(left)),0); + case ',' : + return geniCodeRValue(right,FALSE); + + case CALL: + return geniCodeCall (ast2iCode(tree->left), + tree->right); + case LABEL: + geniCodeLabel(ast2iCode(tree->left)->operand.symOperand); + return ast2iCode (tree->right); + + case GOTO: + geniCodeGoto (ast2iCode(tree->left)->operand.symOperand); + return ast2iCode (tree->right); + + case FUNCTION: + geniCodeFunctionBody ( tree ); + return NULL ; + + case RETURN: + geniCodeReturn (right); + return NULL ; + + case IFX: + geniCodeIfx (tree); + return NULL ; + + case SWITCH: + geniCodeSwitch (tree); + return NULL; + + case INLINEASM: + geniCodeInline (tree); + return NULL ; + } + + return NULL; +} + +/*-----------------------------------------------------------------*/ +/* reverseICChain - gets from the list and creates a linkedlist */ +/*-----------------------------------------------------------------*/ +iCode *reverseiCChain () +{ + iCode *loop = NULL ; + iCode *prev = NULL ; + + while ((loop = getSet(&iCodeChain))) { + loop->next = prev ; + if ( prev ) + prev->prev = loop; + prev = loop ; + } + + return prev; +} + + +/*-----------------------------------------------------------------*/ +/* iCodeFromAst - given an ast will convert it to iCode */ +/*-----------------------------------------------------------------*/ +iCode *iCodeFromAst ( ast *tree ) +{ + returnLabel = newiTempLabel("_return"); + entryLabel = newiTempLabel("_entry") ; + ast2iCode (tree); + return reverseiCChain (); +} + diff --git a/src/SDCCicode.h b/src/SDCCicode.h new file mode 100644 index 00000000..041573f8 --- /dev/null +++ b/src/SDCCicode.h @@ -0,0 +1,277 @@ +/*------------------------------------------------------------------------- + + SDCCicode.h - intermediate code generation etc. + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "SDCCbitv.h" +#include "SDCCset.h" + +#ifndef SDCCICODE_H +#define SDCCICODE_H 1 + +extern symbol *returnLabel ; +extern symbol *entryLabel ; +extern int iCodeKey ; +extern int operandKey ; + +enum { + CONDITIONAL = 0 , + EXPRESSION , + STATEMENT , + LEAF }; +enum optype { + SYMBOL =1, + VALUE , + TYPE }; + +#define IS_SYMOP(op) (op && op->type == SYMBOL) +#define ADDTOCHAIN(x) addSetHead(&iCodeChain,x) + +#define LRFTYPE link *ltype = operandType(left), \ + *rtype = operandType(right) ; +#define LRETYPE link *letype= getSpec(ltype) , \ + *retype= getSpec(rtype); +#define LRTYPE LRFTYPE LRETYPE +#define IS_ITEMP(op) (IS_SYMOP(op) && op->operand.symOperand->isitmp == 1) +#define IS_PARM(op) (IS_SYMOP(op) && op->operand.symOperand->_isparm) +#define IS_ITEMPLBL(op) (IS_ITEMP(op) && op->operand.symOperand->isilbl == 1); +#define IS_OP_VOLATILE(op) (IS_SYMOP(op) && op->isvolatile) +#define IS_OP_LITERAL(op) (op && op->isLiteral) +#define IS_OP_GLOBAL(op) (IS_SYMOP(op) && op->isGlobal) +#define IS_OP_POINTER(op) (IS_SYMOP(op) && op->isPtr) +#define IS_OP_PARM(op) (IS_SYMOP(op) && op->isParm) +#define OP_SYMBOL(op) op->operand.symOperand +#define OP_SYM_TYPE(op) op->operand.symOperand->type +#define OP_SYM_ETYPE(op) op->operand.symOperand->etype +#define SPIL_LOC(op) op->operand.symOperand->usl.spillLoc +#define OP_LIVEFROM(op) op->operand.symOperand->liveFrom +#define OP_LIVETO(op) op->operand.symOperand->liveTo +#define OP_REQV(op) op->operand.symOperand->reqv + +/* typedef for operand */ +typedef struct operand { + unsigned int type: 6 ; /* type of operand */ + unsigned int isaddr : 1; /* is an address */ + unsigned int isvolatile: 1; /* is a volatile operand */ + unsigned int isGlobal :1 ; /* is a global operand */ + unsigned int isPtr :1 ; /* is assigned a pointer */ + unsigned int isGptr :1 ; /* is a generic pointer */ + unsigned int isParm :1 ; /* is a parameter */ + unsigned int isLiteral:1 ; /* operand is literal */ + unsigned int noSpilLoc:1 ; /* cannot be assigned a spil location */ + + unsigned key ; + int parmBytes; + union { + struct symbol *symOperand ; /* operand is of type symbol */ + struct value *valOperand ; /* operand is of type value */ + struct link *typeOperand; /* operand is of type typechain */ + } operand ; + + bitVect *usesDefs; /* which definitions are used by this */ + struct asmop *aop ; /* asm op for this operand */ +} operand ; + +/* definition for intermediate code */ +#define IC_RESULT(x) x->ulrrcnd.lrr.result +#define IC_LEFT(x) x->ulrrcnd.lrr.left +#define IC_RIGHT(x) x->ulrrcnd.lrr.right +#define IC_COND(x) x->ulrrcnd.cnd.condition +#define IC_TRUE(x) x->ulrrcnd.cnd.trueLabel +#define IC_FALSE(x) x->ulrrcnd.cnd.falseLabel +#define IC_LABEL(x) x->argLabel.label +#define IC_ARGS(x) x->argLabel.args +#define IC_JTCOND(x) x->ulrrcnd.jmpTab.condition +#define IC_JTLABELS(x) x->ulrrcnd.jmpTab.labels +#define IC_INLINE(x) x->inlineAsm + +typedef struct iCode +{ + unsigned int op ; /* operation defined */ + int key ; /* running key for this iCode */ + int seq ; /* sequence number within routine */ + short depth ; /* loop depth of this iCode */ + short level ; /* scope level */ + short block ; /* sequential block number */ + unsigned nosupdate:1; /* don't update spillocation with this */ + unsigned generated:1; /* code generated for this one */ + unsigned parmPush :1; /* parameter push Vs spill push */ + unsigned supportRtn:1; /* will cause a call to a support routine */ + unsigned regsSaved:1 ; /* registers have been saved */ + unsigned bankSaved:1 ; /* register bank has been saved */ + + struct iCode *next ; /* next in chain */ + struct iCode *prev ; /* previous in chain */ + set *movedFrom; /* if this iCode gets moved to another block */ + bitVect *rlive ; /* ranges that are live at this point */ + int defKey ; /* key for the operand being defined */ + bitVect *uses ; /* vector of key of used symbols */ + bitVect *rUsed ; /* registers used by this instruction */ + bitVect *rMask ; /* registers in use during this instruction */ + union { + struct { + operand *left ; /* left if any */ + operand *right ; /* right if any */ + operand *result ; /* result of this op */ + } lrr ; + + struct { + operand *condition ; /* if this is a conditional */ + symbol *trueLabel ; /* true for conditional */ + symbol *falseLabel; /* false for conditional */ + } cnd; + + struct { + operand *condition ; /* condition for the jump */ + set *labels ; /* ordered set of labels */ + } jmpTab ; + + } ulrrcnd; + + union { + symbol *label ; /* for a goto statement */ + value *args ; + } argLabel ; + + char *inlineAsm ; /* pointer to inline assembler code */ + + int lineno ; /* file & lineno for debug information */ + char *filename ; +} iCode ; + +/* various functions associated to iCode */ +typedef struct icodeFuncTable +{ + int icode ; + char *printName ; + void (*iCodePrint)(FILE *,iCode *,char *) ; + void (*iCodeGen)() ; +} iCodeTable ; + +/* useful macros */ +#define SKIP_IC2(x) (x->op == GOTO || \ + x->op == LABEL || \ + x->op == FUNCTION || \ + x->op == INLINEASM || \ + x->op == ENDFUNCTION ) + +#define SKIP_IC1(x) (x->op == CALL || \ + SKIP_IC2(x) ) + +#define SKIP_IC(x) (x->op == PCALL || \ + x->op == IPUSH || \ + x->op == IPOP || \ + x->op == JUMPTABLE || \ + x->op == RECEIVE || \ + SKIP_IC1(x)|| \ + x->op == SEND ) + +#define IS_CONDITIONAL(x) (x->op == EQ_OP || \ + x->op == '<' || \ + x->op == '>' || \ + x->op == LE_OP || \ + x->op == GE_OP || \ + x->op == NE_OP ) + +#define IS_TRUE_SYMOP(op) (op && IS_SYMOP(op) && !IS_ITEMP(op)) + +#define POINTER_SET(ic) ( ic && ic->op == '=' \ + && IS_ITEMP(IC_RESULT(ic)) \ + && IC_RESULT(ic)->isaddr ) + +#define POINTER_GET(ic) ( ic && ic->op == GET_VALUE_AT_ADDRESS \ + && (IS_ITEMP(IC_LEFT(ic)) || IS_OP_LITERAL(IC_LEFT(ic)))\ + && IC_LEFT(ic)->isaddr ) + +#define IS_ARITHMETIC_OP(x) (x && (x->op == '+' || \ + x->op == '-' || \ + x->op == '/' || \ + x->op == '*' || \ + x->op == '%')) +#define IS_BITWISE_OP(x) (x && (x->op == BITWISEAND || \ + x->op == '|' || \ + x->op == '^')) + +#define ASSIGNMENT(ic) ( ic && ic->op == '=') + +#define ASSIGN_SYM_TO_ITEMP(ic) (ic && ic->op == '=' && \ + IS_TRUE_SYMOP(IC_RIGHT(ic)) && \ + IS_ITEMP(IC_RESULT(ic))) + +#define ASSIGN_ITEMP_TO_SYM(ic) (ic && ic->op == '=' && \ + IS_TRUE_SYMOP(IC_RESULT(ic)) && \ + IS_ITEMP(IC_RIGHT(ic))) + +#define ASSIGN_ITEMP_TO_ITEMP(ic) (ic && ic->op == '=' &&\ + !POINTER_SET(ic) &&\ + IS_ITEMP(IC_RIGHT(ic)) &&\ + IS_ITEMP(IC_RESULT(ic))) + +#define ADD_SUBTRACT_ITEMP(ic) (ic && (ic->op == '+' || ic->op == '-') && \ + IS_ITEMP(IC_RESULT(ic)) && \ + ( ( IS_ITEMP(IC_LEFT(ic)) ) || ( IS_SYMOP(IC_LEFT(ic)) ) ) && \ + IS_OP_LITERAL(IC_RIGHT(ic))) + +#define ASSIGNMENT_TO_SELF(ic) (!POINTER_SET(ic) && !POINTER_GET(ic) && \ + ic->op == '=' && IC_RESULT(ic)->key == IC_RIGHT(ic)->key ) + +#define SET_ISADDR(op,v) {op = operandFromOperand(op); op->isaddr = v;} +#define SET_RESULT_RIGHT(ic) {SET_ISADDR(IC_RIGHT(ic),0); SET_ISADDR(IC_RESULT(ic),0);} + +#define OP_DEFS(op) op->operand.symOperand->defs +#define OP_USES(op) op->operand.symOperand->uses +/*-----------------------------------------------------------------*/ +/* forward references for functions */ +/*-----------------------------------------------------------------*/ +iCode *reverseiCChain ( ); +int isOperandVolatile (operand *,bool); +int isOperandGlobal (operand *); +void printiCChain ( iCode * , FILE *); +operand *ast2iCode ( ast *); +operand *geniCodeCast ( link *, operand *,bool); +operand *geniCodePtrPtrSubtract (operand *, operand *); +void initiCode (); +iCode *iCodeFromAst ( ast * ); +int isiCodeEqual ( iCode *,iCode *) ; +int isOperandEqual ( operand *, operand *); +iCodeTable *getTableEntry (int ); +int isOperandLiteral (operand *); +operand *operandOperation (operand *,operand *,int,link *); +double operandLitValue ( operand * ); +operand *operandFromLit (float); +operand *operandFromOperand(operand *); +int isParameterToCall (value *,operand *); +iCode *newiCodeLabelGoto (int , symbol *); +symbol *newiTemp(char *); +symbol *newiTempLabel (char *); +symbol *newiTempPreheaderLabel (); +iCode *newiCode (int, operand *, operand *); +link *operandType(operand *); +operand *operandFromValue (value *); +operand *operandFromSymbol(symbol *); +link *aggrToPtr ( link *, bool); +int piCode (void *, FILE * ); +int printOperand (operand *,FILE *); +void setOperandType (operand *, link *); +bool isOperandInFarSpace (operand *); +operand *opFromOpWithDU (operand *,bitVect *,bitVect *); + +#endif diff --git a/src/SDCClabel.c b/src/SDCClabel.c new file mode 100644 index 00000000..99d3080e --- /dev/null +++ b/src/SDCClabel.c @@ -0,0 +1,441 @@ +/*----------------------------------------------------------------- + SDCClabel.c - label optimizations on iCode (intermediate code) + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" + +hTab *labelRef = NULL ; +hTab *labelDef = NULL ; + +/*-----------------------------------------------------------------*/ +/* buildLabelRefTable - creates an hashTable of label referneces */ +/*-----------------------------------------------------------------*/ +void buildLabelRefTable (iCode *ic) +{ + iCode *lic; + + setToNull ((void **)&labelRef); + setToNull ((void **)&labelDef); + labelRef = newHashTable(labelKey + 1); + labelDef = newHashTable(labelKey + 1); + + for (lic = ic ; lic ; lic = lic->next ) { + if ( lic->op == GOTO ) + hTabAddItem (&labelRef, (IC_LABEL(lic))->key, lic); + + if ( lic->op == JUMPTABLE ) { + symbol *lbl ; + for (lbl = setFirstItem(IC_JTLABELS(lic)); lbl; + lbl = setNextItem(IC_JTLABELS(lic))) { + hTabAddItem(&labelRef,lbl->key,lic); + } + } + + if (lic->op == IFX ) { + if (IC_TRUE(lic)) + hTabAddItem(&labelRef,(IC_TRUE(lic))->key, lic); + else + hTabAddItem(&labelRef,(IC_FALSE(lic))->key, lic); + } + if ( lic->op == LABEL ) + hTabAddItem (&labelDef,(IC_LABEL(lic))->key, lic); + + } +} + +/*-----------------------------------------------------------------*/ +/* labelGotoNext - kills gotos to next statement */ +/*-----------------------------------------------------------------*/ +int labelGotoNext (iCode *ic) +{ + iCode *loop; + int change = 0 ; + + for ( loop = ic ; loop ; loop = loop->next) { + + if (loop->op == GOTO && /* if this is a goto */ + loop->next && /* and we have a next one */ + loop->next->op == LABEL && /* next one is a label */ + loop->next->argLabel.label->key == loop->argLabel.label->key) /* same label */ + { + loop->prev->next = loop->next ; /* get this out of the chain */ + loop->next->prev = loop->prev ; + hTabDeleteItem (&labelRef,(IC_LABEL(loop))->key, loop, DELETE_ITEM, NULL); + change++ ; + } + } + + return change ; +} + +/*-----------------------------------------------------------------*/ +/* labelIfx - special case Ifx elimination */ +/*-----------------------------------------------------------------*/ +int labelIfx ( iCode *ic) +{ + iCode *loop ; + int change = 0; + + + for ( loop = ic ; loop ; loop = loop->next ) { + /* if condition goto label */ + /* goto label */ + /* i.e. the flow is going to the same location + regardless of the condition in this case the + condition can be eliminated with a WARNING ofcource */ + if ( loop->op == IFX && + loop->next && + loop->next->op == GOTO ) { + if (IC_TRUE(loop) && + IC_TRUE(loop)->key == IC_LABEL(loop->next)->key) { + + /* get rid of this if */ + werror(W_CONTROL_FLOW,loop->filename,loop->lineno); + loop->prev->next = loop->next; + loop->next->prev = loop->prev; + hTabDeleteItem(&labelRef, + (IC_TRUE(loop))->key, + loop, DELETE_ITEM,NULL); + change++ ; + continue ; + } + else { + if (IC_FALSE(loop) && + IC_FALSE(loop)->key == IC_LABEL(loop->next)->key){ + /* get rid of this if */ + werror(W_CONTROL_FLOW,loop->filename,loop->lineno); + loop->prev->next = loop->next; + loop->next->prev = loop->prev; + hTabDeleteItem(&labelRef, + (IC_FALSE(loop))->key, + loop, DELETE_ITEM,NULL); + change++; + continue ; + } + } + } + /* same as above but with a twist */ + /* if condition goto label */ + /* label: */ + if (loop->op == IFX && + loop->next && + loop->next->op == LABEL && + ((IC_TRUE(loop) && IC_TRUE(loop)->key == IC_LABEL(loop->next)->key) || + (IC_FALSE(loop) && IC_FALSE(loop)->key == IC_LABEL(loop->next)->key))) { + + werror(W_CONTROL_FLOW,loop->filename,loop->lineno); + loop->prev->next = loop->next; + loop->next->prev = loop->prev; + hTabDeleteItem(&labelRef, + IC_LABEL(loop->next)->key, + loop, DELETE_ITEM,NULL); + change++; + continue ; + } + + /* we will eliminate certain special case situations*/ + /* of the conditional statement :- */ + /* if cond != 0 goto _trueLabel */ + /* goto _falseLabel */ + /* _trueLabel : */ + /* ... */ + /* in these cases , if this is the only reference */ + /* to the _trueLabel, we can change it to :- */ + /* if cond == 0 goto _falseLabel */ + /* ... */ + /* similarly if we have a situation like :- */ + /* if cond == 0 goto _falseLabel */ + /* goto _someLabel */ + /* _falseLabel : */ + /* we can change this to */ + /* if cond != 0 goto _someLabel */ + /* ... */ + if (loop->op == IFX && + loop->next && + loop->next->op == GOTO && + loop->next->next && + loop->next->next->op == LABEL ) { + + + /* now check that the last label is the */ + /* same as the _trueLabel of this */ + if (IC_TRUE(loop)) + if ( (IC_TRUE(loop))->key != (IC_LABEL(loop->next->next))->key ) + continue ; + else ; + else + if ( (IC_FALSE(loop))->key != (IC_LABEL(loop->next->next))->key ) + continue; + + /* now make sure that this is the only */ + /* referenece to the _trueLabel */ + if ( IC_TRUE(loop) && hTabItemWithKey(labelRef,(IC_TRUE(loop))->key) ) { + + /* we just change the falseLabel */ + /* to the next goto statement */ + /* unreferenced label will take */ + /* care of removing the label */ + /* delete reference to the true label */ + + hTabDeleteItem(&labelRef, (IC_TRUE(loop))->key, loop, DELETE_ITEM,NULL); + IC_TRUE(loop) = NULL ; + IC_FALSE(loop) = IC_LABEL(loop->next); + /* add reference to the LABEL */ + hTabAddItem (&labelRef,(IC_FALSE(loop))->key,loop); + /* next remove the goto */ + hTabDeleteItem(&labelRef, + (IC_LABEL(loop->next))->key,loop->next,DELETE_ITEM,NULL); + loop->next = loop->next->next ; + loop->next->prev = loop ; + change++; + continue ; + } + + /* now do the same with the false labels */ + if (IC_FALSE(loop) && + hTabItemWithKey(labelRef,(IC_FALSE(loop))->key)) { + + hTabDeleteItem(&labelRef, (IC_FALSE(loop))->key, loop, DELETE_ITEM,NULL); + IC_FALSE(loop) = NULL ; + IC_TRUE(loop) = IC_LABEL(loop->next); + hTabAddItem (&labelRef,(IC_TRUE(loop))->key,loop); + hTabDeleteItem(&labelRef,(IC_LABEL(loop->next))->key,loop->next,DELETE_ITEM,NULL); + loop->next = loop->next->next ; + loop->next->prev = loop ; + change++; + continue ; + } + } + } + + return change ; +} + +/*-----------------------------------------------------------------*/ +/* labelGotoGoto - target of a goto is a goto */ +/*-----------------------------------------------------------------*/ +int labelGotoGoto (iCode *ic) +{ + iCode *loop; + int change = 0 ; + + for ( loop = ic ; loop ; loop = loop->next ) { + iCode *stat ; + symbol *sLabel = NULL; + stat = NULL ; + switch (loop->op) { + case GOTO: /* for a goto statement */ + stat = hTabItemWithKey(labelDef,(sLabel = IC_LABEL(loop))->key) ; + break ; + case IFX : /* for a conditional jump */ + if (IC_TRUE(loop)) + stat = hTabItemWithKey(labelDef,(sLabel = IC_TRUE(loop))->key); + else + stat = hTabItemWithKey (labelDef,(sLabel = IC_FALSE(loop))->key); + } + + /* if we have a target statement then check if the next */ + /* one is a goto: this means target of goto is a goto */ + if ( stat && stat->next && + ( stat->next->op == GOTO || + stat->next->op == LABEL) && + stat->next != loop ) { + + symbol *repLabel = stat->next->argLabel.label ; /* replace with label */ + + /* if they are the same then continue */ + if (repLabel->key == sLabel->key) + continue ; + + /* replacement depends on the statement type */ + switch (loop->op) { + + case GOTO: /* for a goto statement */ + + hTabDeleteItem (&labelRef, (IC_LABEL(loop))->key, loop,DELETE_ITEM,NULL); + loop->argLabel.label = repLabel ; + hTabAddItem (&labelRef, repLabel->key, loop); + break ; + + case IFX : /* for a conditional jump */ + if (IC_TRUE(loop)) { + + hTabDeleteItem (&labelRef, (IC_TRUE(loop))->key, loop,DELETE_ITEM,NULL); + IC_TRUE(loop) = repLabel ; + } + else { + + hTabDeleteItem (&labelRef, (IC_FALSE(loop))->key, loop,DELETE_ITEM,NULL); + IC_FALSE(loop) = repLabel; + } + hTabAddItem (&labelRef, repLabel->key, loop); + + } + change++ ; + } + } + + return change ; +} + +/*-----------------------------------------------------------------*/ +/* labelUnrefLabel - remove unreferneced labels */ +/*-----------------------------------------------------------------*/ +int labelUnrefLabel (iCode *ic) +{ + iCode *loop; + int change = 0 ; + + for ( loop = ic ; loop ; loop = loop->next) { + + /* if this is a label */ + if (loop->op == LABEL) { + set *refs ; + + refs = NULL ; + if ( ( (IC_LABEL(loop))->key == returnLabel->key ) || + ( (IC_LABEL(loop))->key == entryLabel->key ) ) + continue ; + + if (hTabItemWithKey(labelRef,(IC_LABEL(loop))->key) ) + continue ; + + /* else eliminitate this one */ + loop->prev->next = loop->next ; /* get this out of the chain */ + loop->next->prev = loop->prev ; + change ++ ; + } + } + + return change ; +} + +/*-----------------------------------------------------------------*/ +/* labelUnreach - remove unreachable code */ +/*-----------------------------------------------------------------*/ +int labelUnreach (iCode *ic) +{ + iCode *loop; + iCode *tic; + int change = 0 ; + + /* if we hit a return statement or a goto statement */ + /* remove all statements till we hit the next label */ + for (loop = ic ; loop ; loop = loop->next) { + iCode *loop2 ; + + /* found a goto || return && the next */ + /* statement is not a label */ + if (loop->op == GOTO || loop->op == RETURN ) { + + if (loop->next && + (loop->next->op == LABEL || + loop->next->op == ENDFUNCTION )) + continue ; + + /* loop till we find a label */ + loop2 = loop->next ; + while (loop2 && loop2->op != LABEL) + loop2 = loop2->next; + + /* throw away those in between */ + for (tic = loop->next ; tic && tic != loop2 ; tic=tic->next) { + /* remove label references if any */ + switch (tic->op) { + case GOTO : + hTabDeleteItem (&labelRef,IC_LABEL(tic)->key,tic,DELETE_ITEM,NULL); + break; + case IFX : + if (IC_TRUE(tic)) + hTabDeleteItem (&labelRef,IC_TRUE(tic)->key,tic,DELETE_ITEM,NULL); + else + hTabDeleteItem (&labelRef,IC_FALSE(tic)->key,tic,DELETE_ITEM,NULL); + break; + + } + } + + /* now set up the pointers */ + loop->next = loop2; + if (loop2) + loop2->prev = loop ; + change++; + } + } + return change ; +} + +/*-----------------------------------------------------------------*/ +/* iCodeLabelOptimize - some obvious & general optimizations */ +/*-----------------------------------------------------------------*/ +iCode *iCodeLabelOptimize (iCode *ic) +{ + if (!optimize.label1 && + !optimize.label2 && + !optimize.label3 && + !optimize.label4 ) + return ic; + + /* build labelreferences */ + buildLabelRefTable (ic); + + /* the following transformations need to ne done */ + /* repeatedly till a fixed point is reached */ + while (1) { + int change ; + change = 0 ; + + /* first eliminate any goto statement */ + /* that goes to the next statement */ + if (optimize.label1) + change += labelGotoNext (ic); + + if ( optimize.label2 ) + change += labelIfx (ic); + + /* target of a goto is a goto then rename this goto */ + if (optimize.label3 ) + change += labelGotoGoto (ic); + + /* remove unreference labels */ + if (optimize.label4) + change += labelUnrefLabel (ic); + + /* remove unreachable code */ + change += labelUnreach (ic); + + if (!change) /* fixed point reached */ + break; + } + + return ic; +} diff --git a/src/SDCClabel.h b/src/SDCClabel.h new file mode 100644 index 00000000..3ece83d6 --- /dev/null +++ b/src/SDCClabel.h @@ -0,0 +1,38 @@ +/*----------------------------------------------------------------- + SDCClabel.h - label optimizations on iCode (intermediate code) + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include "SDCCglobl.h" +#include "SDCCsymt.h" + +#ifndef SDCCLABEL_H +#define SDCCLABEL_H + +extern hTab *labelRef ; +extern hTab *labelDef ; +extern int labelKey; + +iCode *iCodeLabelOptimize (iCode *); + + +#endif diff --git a/src/SDCClex.c b/src/SDCClex.c new file mode 100644 index 00000000..0cfdc4ec --- /dev/null +++ b/src/SDCClex.c @@ -0,0 +1,3040 @@ +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header$ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 123 +#define YY_END_OF_BUFFER 124 +static yyconst short int yy_accept[767] = + { 0, + 0, 0, 0, 0, 124, 122, 121, 120, 122, 103, + 69, 109, 102, 122, 97, 98, 107, 106, 94, 105, + 101, 108, 64, 64, 95, 91, 110, 96, 111, 114, + 61, 99, 100, 112, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 92, 113, 93, 104, 122, 121, 120, + 122, 103, 69, 122, 109, 102, 122, 98, 107, 106, + 94, 105, 101, 108, 64, 64, 95, 91, 110, 96, + 111, 114, 61, 99, 100, 112, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + + 61, 61, 61, 61, 61, 92, 113, 93, 104, 3, + 4, 3, 119, 90, 76, 85, 77, 0, 0, 74, + 82, 72, 83, 73, 84, 0, 67, 5, 75, 68, + 63, 0, 64, 0, 64, 81, 87, 89, 88, 80, + 61, 78, 61, 61, 61, 61, 61, 61, 61, 61, + 6, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 18, 61, 61, 61, 61, 61, 61, 61, 61, 28, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 79, 86, 0, + 0, 119, 90, 0, 0, 76, 85, 77, 0, 0, + + 0, 74, 82, 72, 83, 73, 84, 0, 67, 5, + 75, 68, 63, 0, 64, 0, 64, 81, 87, 89, + 88, 80, 61, 78, 61, 61, 61, 61, 61, 61, + 61, 61, 6, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 18, 61, 61, 61, 61, 61, 61, 61, + 61, 28, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 79, + 86, 0, 65, 60, 0, 67, 67, 0, 68, 63, + 0, 66, 62, 71, 70, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 8, 61, 61, 61, 61, 61, + + 61, 61, 61, 61, 61, 61, 61, 23, 61, 25, + 61, 61, 29, 61, 61, 61, 61, 61, 61, 61, + 37, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 0, 0, 0, 65, 0, + 60, 0, 67, 67, 0, 68, 63, 0, 66, 62, + 71, 70, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 8, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 23, 61, 25, 61, 61, 29, + 61, 61, 61, 61, 61, 61, 61, 37, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + + 61, 61, 0, 0, 67, 0, 67, 0, 68, 66, + 62, 1, 61, 61, 61, 61, 61, 61, 61, 7, + 61, 10, 11, 12, 61, 61, 61, 16, 61, 61, + 20, 21, 61, 61, 26, 61, 61, 31, 32, 61, + 61, 61, 61, 38, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 48, 61, 61, 61, 0, 0, + 0, 0, 0, 67, 0, 67, 0, 68, 66, 62, + 1, 61, 61, 61, 61, 61, 61, 61, 7, 61, + 10, 11, 12, 61, 61, 61, 16, 61, 61, 20, + 21, 61, 61, 26, 61, 61, 31, 32, 61, 61, + + 61, 61, 38, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 48, 61, 61, 61, 0, 0, 67, + 54, 53, 61, 61, 56, 61, 61, 9, 13, 61, + 61, 61, 61, 61, 24, 27, 61, 33, 61, 61, + 61, 39, 61, 61, 61, 61, 61, 61, 46, 61, + 50, 61, 51, 52, 0, 0, 0, 0, 0, 67, + 54, 53, 61, 61, 56, 61, 61, 9, 13, 61, + 61, 61, 61, 61, 24, 27, 61, 33, 61, 61, + 61, 39, 61, 61, 61, 61, 61, 61, 46, 61, + 50, 61, 51, 52, 0, 61, 59, 58, 57, 61, + + 61, 61, 19, 22, 61, 61, 61, 36, 40, 41, + 42, 43, 44, 61, 61, 61, 0, 0, 115, 0, + 0, 0, 61, 59, 58, 57, 61, 61, 61, 19, + 22, 61, 61, 61, 36, 40, 41, 42, 43, 44, + 61, 61, 61, 0, 61, 61, 61, 17, 61, 61, + 61, 45, 61, 61, 0, 0, 115, 0, 0, 0, + 61, 61, 61, 17, 61, 61, 61, 45, 61, 61, + 2, 55, 14, 15, 61, 61, 35, 47, 49, 0, + 0, 0, 0, 116, 0, 0, 0, 55, 14, 15, + 61, 61, 35, 47, 49, 30, 34, 0, 0, 0, + + 0, 116, 0, 0, 0, 30, 34, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 117, 0, 0, 0, + 0, 117, 65, 117, 0, 0, 0, 0, 0, 0, + 0, 118, 0, 0, 0, 0, 118, 65, 118, 0, + 0, 0, 0, 117, 0, 0, 0, 0, 0, 0, + 118, 117, 0, 0, 118, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 6, 7, 8, 1, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 22, 23, 24, + 25, 26, 27, 1, 28, 28, 28, 28, 29, 30, + 31, 31, 31, 31, 31, 32, 31, 31, 31, 31, + 31, 31, 31, 31, 33, 31, 31, 34, 31, 31, + 35, 36, 37, 38, 39, 1, 40, 41, 42, 43, + + 44, 45, 46, 47, 48, 31, 49, 50, 51, 52, + 53, 54, 31, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[68] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 4, + 4, 1, 1, 1, 1, 1, 1, 4, 4, 4, + 5, 5, 5, 5, 1, 1, 1, 1, 5, 4, + 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 1, 1, 1, 1 + } ; + +static yyconst short int yy_base[785] = + { 0, + 0, 67, 132, 133, 1347, 1348, 1348, 1348, 1343, 1320, + 1348, 1319, 127, 1307, 1348, 1348, 1317, 123, 1348, 124, + 122, 130, 155, 133, 1348, 1348, 121, 1316, 131, 1348, + 0, 1348, 1348, 1315, 150, 101, 112, 154, 142, 118, + 168, 1286, 167, 1285, 1293, 1293, 1291, 179, 1272, 122, + 1280, 1285, 1288, 1348, 138, 1348, 1348, 1318, 1317, 1316, + 194, 203, 1315, 188, 205, 219, 211, 1314, 220, 225, + 1313, 229, 231, 244, 258, 253, 1312, 1311, 236, 241, + 255, 1310, 319, 1309, 1308, 247, 253, 123, 209, 347, + 260, 338, 351, 1266, 232, 1265, 1273, 1273, 1271, 348, + + 1252, 242, 1260, 1265, 1268, 1298, 385, 1297, 1296, 1348, + 1348, 1263, 1348, 1348, 1348, 1348, 1348, 128, 158, 1348, + 1348, 1348, 1348, 1348, 1348, 1288, 386, 1348, 1348, 393, + 424, 412, 402, 0, 443, 1280, 1348, 1348, 1348, 1279, + 0, 1348, 1247, 1249, 1261, 1256, 1256, 1254, 1254, 1253, + 0, 1238, 1237, 1249, 1236, 1251, 182, 1242, 1232, 1243, + 1229, 1230, 1227, 1227, 1228, 1229, 1226, 1223, 1239, 0, + 1221, 1225, 1236, 1235, 382, 1226, 1218, 1219, 243, 228, + 1223, 1216, 261, 1221, 185, 1220, 1227, 1348, 1348, 1254, + 242, 1253, 1252, 399, 386, 1251, 1250, 1249, 437, 458, + + 400, 1248, 1247, 1246, 1245, 1244, 1243, 300, 468, 1242, + 1241, 487, 509, 450, 478, 556, 531, 434, 1240, 1239, + 1238, 471, 0, 1237, 1192, 1194, 1206, 1201, 1201, 1199, + 1199, 1198, 0, 1183, 1182, 1194, 1181, 1196, 434, 1187, + 1177, 1188, 1174, 1175, 1172, 1172, 1173, 1174, 1171, 1168, + 1184, 0, 1166, 1170, 1181, 1180, 458, 1171, 1163, 1164, + 346, 400, 1168, 1161, 410, 1166, 369, 1165, 1172, 1199, + 1198, 1157, 1348, 1348, 505, 1348, 558, 541, 1348, 507, + 400, 562, 522, 1348, 1348, 1157, 1164, 1149, 1153, 1164, + 1163, 1162, 1161, 1147, 0, 1159, 1154, 1142, 1152, 428, + + 1138, 1154, 1153, 1151, 1147, 1139, 1145, 0, 1148, 0, + 1134, 1129, 1141, 1138, 1128, 1125, 1129, 1132, 1121, 1121, + 0, 1122, 1124, 1131, 1117, 1115, 1115, 1127, 1117, 1121, + 1116, 1124, 1126, 1115, 1107, 553, 439, 469, 1151, 593, + 1150, 603, 1149, 605, 621, 1148, 598, 607, 631, 670, + 1147, 1146, 1106, 1113, 1098, 1102, 1113, 1112, 1111, 1110, + 1096, 0, 1108, 1103, 1091, 1101, 449, 1087, 1103, 1102, + 1100, 1096, 1088, 1094, 0, 1097, 0, 1083, 1078, 1090, + 1087, 1077, 1074, 1078, 1081, 1070, 1070, 0, 1071, 1073, + 1080, 1066, 1064, 1064, 1076, 1066, 1070, 1065, 1073, 1075, + + 1064, 1056, 1069, 503, 638, 645, 1348, 513, 674, 1348, + 589, 0, 1067, 1070, 1065, 1051, 1052, 1049, 1048, 0, + 1055, 0, 0, 0, 1046, 1054, 1053, 0, 1042, 1049, + 0, 0, 1043, 1040, 0, 1056, 1040, 0, 0, 1054, + 1036, 1036, 1036, 0, 1033, 1045, 1035, 1039, 1044, 1043, + 1041, 1031, 1036, 1035, 0, 1023, 1035, 1038, 1072, 491, + 502, 635, 633, 697, 652, 1064, 665, 711, 1063, 675, + 0, 1030, 1033, 1028, 1014, 1015, 1012, 1011, 0, 1018, + 0, 0, 0, 1009, 1017, 1016, 0, 1005, 1012, 0, + 0, 1006, 1003, 0, 1019, 1003, 0, 0, 1017, 999, + + 999, 999, 0, 996, 1008, 998, 1002, 1007, 1006, 1004, + 994, 999, 998, 0, 986, 998, 1001, 1000, 524, 714, + 0, 0, 984, 998, 0, 997, 996, 0, 0, 983, + 992, 983, 988, 979, 0, 0, 975, 0, 974, 971, + 975, 0, 983, 980, 982, 966, 975, 977, 0, 968, + 0, 971, 0, 0, 996, 672, 558, 694, 728, 733, + 0, 0, 962, 976, 0, 975, 974, 0, 0, 961, + 970, 961, 966, 957, 0, 0, 953, 0, 952, 949, + 953, 0, 961, 958, 960, 944, 953, 955, 0, 946, + 0, 949, 0, 0, 940, 947, 0, 0, 0, 936, + + 953, 935, 0, 0, 933, 950, 945, 0, 0, 0, + 0, 0, 0, 943, 943, 936, 980, 677, 972, 676, + 604, 746, 935, 0, 0, 0, 924, 941, 923, 0, + 0, 921, 938, 933, 0, 0, 0, 0, 0, 0, + 931, 931, 924, 894, 893, 855, 838, 0, 833, 834, + 830, 0, 839, 837, 551, 877, 1348, 747, 689, 726, + 837, 833, 826, 0, 819, 820, 816, 0, 827, 825, + 1348, 0, 0, 0, 810, 808, 0, 0, 0, 806, + 820, 566, 763, 846, 718, 741, 744, 0, 0, 0, + 799, 796, 0, 0, 0, 0, 0, 797, 796, 671, + + 847, 1348, 768, 758, 761, 0, 0, 796, 684, 588, + 771, 762, 768, 671, 674, 782, 784, 781, 782, 0, + 626, 492, 755, 796, 797, 791, 0, 586, 602, 800, + 787, 808, 0, 547, 799, 0, 788, 802, 804, 806, + 821, 0, 809, 818, 819, 820, 826, 0, 543, 489, + 811, 825, 831, 451, 822, 835, 836, 421, 312, 837, + 307, 285, 845, 211, 182, 1348, 891, 896, 898, 903, + 908, 143, 913, 918, 923, 928, 933, 938, 943, 948, + 953, 958, 963, 968 + } ; + +static yyconst short int yy_def[785] = + { 0, + 766, 766, 767, 767, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 768, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 769, 766, 766, 766, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 766, 766, 766, 766, 770, 770, 770, + 770, 770, 770, 770, 770, 770, 771, 770, 770, 770, + 770, 770, 770, 770, 770, 770, 770, 770, 770, 770, + 770, 770, 766, 770, 770, 770, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + + 83, 83, 83, 83, 83, 770, 770, 770, 770, 766, + 766, 766, 766, 766, 766, 766, 766, 768, 768, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 772, 766, 766, 766, 766, 766, 766, + 769, 766, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 766, 766, 770, + 766, 770, 770, 770, 770, 770, 770, 770, 771, 768, + + 771, 770, 770, 770, 770, 770, 770, 770, 770, 770, + 770, 770, 770, 770, 770, 770, 770, 770, 770, 770, + 770, 770, 83, 770, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 770, + 770, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 772, 766, 766, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 766, 770, 770, 770, 768, + 770, 770, 770, 770, 770, 770, 770, 770, 770, 770, + 770, 770, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + + 83, 83, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 766, 770, + 770, 768, 770, 770, 770, 770, 770, 770, 770, 770, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 766, 766, 766, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 766, 773, 770, 768, 770, 770, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 766, 769, 769, 769, 769, 769, + + 769, 769, 769, 769, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 769, 769, 766, 773, 770, 774, + 770, 768, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 766, 769, 769, 769, 769, 769, 769, + 769, 769, 769, 769, 766, 774, 766, 774, 775, 768, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 766, 769, 769, 769, 769, 769, 769, 769, 769, 766, + 766, 774, 775, 770, 776, 768, 768, 83, 83, 83, + 83, 83, 83, 83, 83, 769, 769, 766, 766, 774, + + 776, 766, 776, 768, 768, 83, 83, 766, 766, 774, + 776, 768, 768, 766, 766, 774, 776, 768, 768, 777, + 766, 774, 774, 776, 778, 768, 777, 766, 774, 774, + 776, 778, 777, 778, 768, 779, 774, 774, 776, 776, + 780, 779, 774, 774, 776, 776, 780, 779, 780, 781, + 774, 776, 776, 781, 774, 776, 776, 782, 783, 776, + 782, 783, 776, 784, 784, 0, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766 + } ; + +static yyconst short int yy_nxt[1416] = + { 0, + 6, 7, 8, 9, 7, 10, 11, 6, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 31, 31, + 31, 31, 31, 31, 32, 6, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 31, 43, 31, 44, + 31, 45, 31, 46, 47, 48, 49, 50, 51, 52, + 53, 31, 31, 54, 55, 56, 57, 58, 59, 60, + 61, 59, 62, 63, 64, 65, 66, 67, 15, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 83, 83, 83, 83, 83, + + 83, 84, 58, 85, 86, 87, 88, 89, 90, 91, + 92, 93, 94, 83, 95, 83, 96, 83, 97, 83, + 98, 99, 100, 101, 102, 103, 104, 105, 83, 83, + 106, 107, 108, 109, 111, 111, 116, 121, 273, 126, + 123, 127, 127, 128, 136, 137, 283, 122, 124, 125, + 130, 117, 135, 135, 129, 139, 140, 151, 152, 153, + 766, 132, 188, 119, 133, 133, 154, 162, 118, 163, + 112, 112, 130, 183, 131, 131, 132, 184, 164, 233, + 234, 159, 133, 132, 702, 160, 133, 133, 134, 143, + 133, 144, 145, 155, 161, 146, 192, 147, 132, 191, + + 156, 148, 189, 149, 133, 191, 157, 165, 158, 169, + 150, 170, 133, 702, 191, 134, 191, 166, 171, 176, + 167, 190, 200, 177, 299, 178, 179, 193, 197, 196, + 191, 191, 332, 300, 333, 180, 191, 194, 181, 203, + 191, 195, 191, 198, 202, 205, 201, 191, 208, 204, + 209, 209, 191, 206, 207, 191, 235, 210, 191, 218, + 219, 336, 336, 236, 191, 220, 191, 325, 211, 191, + 212, 224, 217, 217, 251, 212, 252, 213, 213, 221, + 222, 214, 326, 253, 215, 215, 214, 702, 323, 215, + 215, 216, 225, 265, 226, 227, 214, 266, 228, 241, + + 229, 214, 215, 242, 230, 324, 231, 215, 329, 657, + 215, 191, 243, 232, 702, 215, 330, 341, 216, 190, + 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, + 191, 190, 190, 190, 190, 190, 190, 190, 223, 223, + 190, 190, 190, 190, 190, 190, 223, 223, 223, 223, + 223, 223, 223, 190, 190, 190, 190, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 190, 190, 190, 190, 237, 244, 258, 245, + 247, 390, 259, 238, 260, 261, 191, 191, 246, 239, + + 248, 240, 190, 249, 262, 127, 127, 263, 391, 270, + 191, 200, 277, 277, 275, 276, 399, 276, 400, 282, + 282, 278, 279, 657, 279, 317, 281, 318, 281, 275, + 276, 282, 282, 133, 133, 276, 278, 279, 319, 392, + 338, 130, 279, 131, 131, 191, 337, 339, 200, 271, + 191, 133, 132, 657, 393, 280, 280, 396, 351, 133, + 130, 191, 135, 135, 348, 397, 348, 132, 273, 349, + 349, 132, 201, 280, 133, 133, 366, 340, 340, 191, + 191, 280, 191, 425, 426, 367, 132, 209, 209, 191, + 460, 657, 133, 119, 657, 352, 342, 343, 191, 343, + + 133, 384, 191, 385, 484, 485, 344, 344, 461, 215, + 215, 342, 343, 191, 386, 345, 346, 343, 346, 404, + 191, 404, 405, 405, 405, 405, 212, 215, 213, 213, + 345, 346, 409, 409, 556, 215, 346, 214, 280, 280, + 347, 347, 191, 520, 520, 766, 729, 557, 212, 766, + 217, 217, 214, 411, 411, 408, 280, 408, 347, 214, + 409, 409, 215, 215, 280, 459, 347, 191, 657, 191, + 700, 411, 336, 336, 214, 350, 350, 277, 277, 411, + 215, 282, 282, 350, 350, 350, 406, 407, 215, 407, + 657, 410, 716, 410, 680, 350, 350, 350, 350, 350, + + 350, 406, 407, 273, 657, 462, 410, 407, 621, 191, + 681, 410, 340, 340, 191, 191, 191, 463, 191, 463, + 411, 411, 464, 464, 344, 344, 349, 349, 119, 347, + 347, 736, 191, 465, 466, 467, 466, 467, 411, 558, + 468, 468, 191, 659, 191, 273, 411, 347, 465, 466, + 349, 349, 464, 464, 466, 347, 737, 405, 405, 519, + 469, 519, 469, 191, 520, 520, 559, 276, 559, 276, + 119, 560, 560, 657, 619, 469, 191, 728, 657, 619, + 469, 191, 276, 620, 468, 468, 191, 276, 620, 350, + 350, 684, 710, 409, 409, 658, 658, 350, 350, 350, + + 685, 470, 470, 279, 273, 279, 470, 470, 191, 350, + 350, 350, 350, 350, 350, 622, 464, 464, 279, 470, + 702, 721, 191, 279, 470, 720, 343, 470, 343, 119, + 468, 468, 470, 520, 520, 715, 273, 703, 703, 191, + 346, 343, 346, 407, 191, 407, 343, 560, 560, 657, + 660, 273, 560, 560, 273, 346, 273, 657, 407, 682, + 346, 119, 466, 407, 466, 684, 658, 658, 273, 686, + 702, 273, 273, 702, 685, 717, 119, 466, 273, 119, + 711, 119, 466, 705, 657, 687, 702, 703, 703, 702, + 657, 273, 273, 119, 730, 704, 119, 119, 702, 118, + + 731, 273, 657, 119, 657, 724, 702, 733, 702, 273, + 118, 657, 712, 657, 718, 713, 119, 119, 733, 719, + 657, 702, 702, 118, 657, 722, 119, 702, 118, 726, + 739, 748, 734, 702, 119, 725, 748, 702, 702, 702, + 743, 723, 735, 734, 741, 746, 740, 702, 714, 702, + 709, 708, 707, 744, 738, 706, 749, 191, 745, 699, + 698, 749, 755, 750, 697, 751, 696, 758, 695, 694, + 693, 692, 691, 752, 753, 690, 689, 756, 688, 657, + 679, 678, 757, 760, 677, 676, 675, 674, 763, 759, + 764, 110, 110, 110, 110, 110, 118, 118, 673, 118, + + 118, 141, 141, 190, 190, 190, 190, 190, 199, 199, + 199, 199, 199, 618, 618, 618, 618, 618, 656, 656, + 656, 656, 656, 683, 683, 683, 683, 683, 701, 701, + 701, 701, 701, 727, 672, 727, 727, 727, 732, 732, + 732, 732, 732, 742, 671, 742, 742, 742, 747, 747, + 747, 747, 747, 754, 754, 754, 754, 754, 761, 761, + 761, 761, 761, 762, 762, 762, 762, 762, 765, 765, + 765, 765, 765, 670, 669, 668, 667, 666, 665, 664, + 663, 662, 661, 191, 655, 654, 653, 652, 651, 650, + 649, 648, 647, 646, 645, 644, 643, 642, 641, 640, + + 639, 638, 637, 636, 635, 634, 633, 632, 631, 630, + 629, 628, 627, 626, 625, 624, 623, 617, 616, 615, + 614, 613, 612, 611, 610, 609, 608, 607, 606, 605, + 604, 603, 602, 601, 600, 599, 598, 597, 596, 595, + 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, + 584, 583, 582, 581, 580, 579, 578, 577, 576, 575, + 574, 573, 572, 571, 570, 569, 568, 567, 566, 565, + 564, 563, 562, 561, 191, 191, 555, 554, 553, 552, + 551, 550, 549, 548, 547, 546, 545, 544, 543, 542, + 541, 540, 539, 538, 537, 536, 535, 534, 533, 532, + + 531, 530, 529, 528, 527, 526, 525, 524, 523, 522, + 521, 518, 517, 516, 515, 514, 513, 512, 511, 510, + 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, + 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, + 489, 488, 487, 486, 483, 482, 481, 480, 479, 478, + 477, 476, 475, 474, 473, 472, 471, 191, 191, 191, + 191, 191, 191, 458, 457, 456, 455, 454, 453, 452, + 451, 450, 449, 448, 447, 446, 445, 444, 443, 442, + 441, 440, 439, 438, 437, 436, 435, 434, 433, 432, + 431, 430, 429, 428, 427, 424, 423, 422, 421, 420, + + 419, 418, 417, 416, 415, 414, 413, 412, 403, 191, + 191, 402, 401, 398, 395, 394, 389, 388, 387, 383, + 382, 381, 380, 379, 378, 377, 376, 375, 374, 373, + 372, 371, 370, 369, 368, 365, 364, 363, 362, 361, + 360, 359, 358, 357, 356, 355, 354, 353, 191, 191, + 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, + 191, 191, 191, 191, 191, 191, 335, 334, 331, 328, + 327, 322, 321, 320, 316, 315, 314, 313, 312, 311, + 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, + 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, + + 288, 287, 286, 285, 284, 274, 272, 191, 191, 191, + 269, 268, 267, 264, 257, 256, 255, 254, 250, 191, + 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, + 187, 186, 185, 182, 175, 174, 173, 172, 168, 142, + 138, 120, 119, 115, 114, 113, 766, 5, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766 + } ; + +static yyconst short int yy_chk[1416] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 4, 13, 18, 118, 21, + 20, 21, 21, 22, 27, 27, 772, 18, 20, 20, + 24, 13, 24, 24, 22, 29, 29, 36, 36, 37, + 119, 24, 55, 118, 24, 24, 37, 40, 119, 40, + 3, 4, 23, 50, 23, 23, 24, 50, 40, 88, + 88, 39, 24, 23, 765, 39, 23, 23, 23, 35, + 24, 35, 35, 38, 39, 35, 61, 35, 23, 64, + + 38, 35, 55, 35, 23, 61, 38, 41, 38, 43, + 35, 43, 23, 764, 62, 23, 65, 41, 43, 48, + 41, 67, 67, 48, 157, 48, 48, 62, 66, 65, + 66, 69, 185, 157, 185, 48, 70, 64, 48, 70, + 72, 64, 73, 66, 69, 72, 67, 79, 73, 70, + 73, 73, 80, 72, 72, 74, 89, 74, 86, 79, + 79, 191, 191, 89, 76, 80, 81, 180, 74, 75, + 76, 86, 76, 76, 95, 75, 95, 75, 75, 81, + 81, 76, 180, 95, 76, 76, 75, 762, 179, 75, + 75, 75, 87, 102, 87, 87, 76, 102, 87, 91, + + 87, 75, 76, 91, 87, 179, 87, 75, 183, 761, + 76, 208, 91, 87, 759, 75, 183, 208, 75, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 90, 92, 100, 92, + 93, 261, 100, 90, 100, 100, 107, 195, 92, 90, + + 93, 90, 201, 93, 100, 127, 127, 100, 261, 107, + 194, 201, 130, 130, 127, 127, 267, 127, 267, 281, + 281, 130, 130, 758, 130, 175, 132, 175, 132, 127, + 127, 132, 132, 133, 133, 127, 130, 130, 175, 262, + 195, 131, 130, 131, 131, 218, 194, 199, 199, 107, + 337, 133, 131, 754, 262, 131, 131, 265, 218, 133, + 135, 214, 135, 135, 214, 265, 214, 131, 200, 214, + 214, 135, 199, 131, 135, 135, 239, 200, 200, 209, + 338, 131, 222, 300, 300, 239, 135, 209, 209, 215, + 337, 750, 135, 200, 722, 222, 209, 209, 212, 209, + + 135, 257, 460, 257, 367, 367, 212, 212, 338, 215, + 215, 209, 209, 461, 257, 212, 212, 209, 212, 275, + 213, 275, 404, 404, 275, 275, 213, 215, 213, 213, + 212, 212, 408, 408, 460, 215, 212, 213, 280, 280, + 213, 213, 217, 519, 519, 749, 722, 461, 217, 734, + 217, 217, 213, 283, 283, 278, 280, 278, 213, 217, + 278, 278, 217, 217, 280, 336, 213, 216, 682, 557, + 682, 283, 336, 336, 217, 216, 216, 277, 277, 283, + 217, 282, 282, 216, 216, 216, 277, 277, 217, 277, + 710, 282, 710, 282, 655, 216, 216, 216, 216, 216, + + 216, 277, 277, 340, 729, 340, 282, 277, 557, 347, + 655, 282, 340, 340, 342, 621, 344, 342, 348, 342, + 411, 411, 342, 342, 344, 344, 348, 348, 340, 347, + 347, 728, 345, 344, 344, 345, 344, 345, 411, 462, + 345, 345, 349, 621, 463, 462, 411, 347, 344, 344, + 349, 349, 463, 463, 344, 347, 729, 405, 405, 406, + 349, 406, 349, 465, 406, 406, 465, 405, 465, 405, + 462, 465, 465, 700, 556, 349, 467, 721, 620, 618, + 349, 350, 405, 556, 467, 467, 470, 405, 618, 350, + 350, 659, 700, 409, 409, 620, 620, 350, 350, 350, + + 659, 350, 350, 409, 558, 409, 470, 470, 464, 350, + 350, 350, 350, 350, 350, 558, 464, 464, 409, 350, + 685, 715, 468, 409, 470, 714, 464, 350, 464, 558, + 468, 468, 470, 520, 520, 709, 660, 685, 685, 559, + 468, 464, 468, 520, 560, 520, 464, 559, 559, 658, + 622, 686, 560, 560, 687, 468, 622, 723, 520, 658, + 468, 660, 560, 520, 560, 683, 658, 658, 704, 660, + 703, 705, 712, 711, 683, 711, 686, 560, 713, 687, + 703, 622, 560, 687, 716, 660, 717, 703, 703, 731, + 737, 718, 719, 704, 723, 686, 705, 712, 724, 725, + + 724, 726, 730, 713, 738, 717, 739, 725, 740, 735, + 732, 743, 704, 751, 712, 705, 718, 719, 732, 713, + 744, 745, 746, 741, 755, 716, 726, 752, 747, 719, + 731, 741, 725, 753, 735, 718, 747, 756, 757, 760, + 737, 716, 726, 732, 735, 740, 731, 763, 708, 701, + 699, 698, 692, 738, 730, 691, 741, 684, 739, 681, + 680, 747, 751, 743, 676, 744, 675, 755, 670, 669, + 667, 666, 665, 745, 746, 663, 662, 752, 661, 656, + 654, 653, 753, 757, 651, 650, 649, 647, 760, 756, + 763, 767, 767, 767, 767, 767, 768, 768, 646, 768, + + 768, 769, 769, 770, 770, 770, 770, 770, 771, 771, + 771, 771, 771, 773, 773, 773, 773, 773, 774, 774, + 774, 774, 774, 775, 775, 775, 775, 775, 776, 776, + 776, 776, 776, 777, 645, 777, 777, 777, 778, 778, + 778, 778, 778, 779, 644, 779, 779, 779, 780, 780, + 780, 780, 780, 781, 781, 781, 781, 781, 782, 782, + 782, 782, 782, 783, 783, 783, 783, 783, 784, 784, + 784, 784, 784, 643, 642, 641, 634, 633, 632, 629, + 628, 627, 623, 619, 617, 616, 615, 614, 607, 606, + 605, 602, 601, 600, 596, 595, 592, 590, 588, 587, + + 586, 585, 584, 583, 581, 580, 579, 577, 574, 573, + 572, 571, 570, 567, 566, 564, 563, 555, 552, 550, + 548, 547, 546, 545, 544, 543, 541, 540, 539, 537, + 534, 533, 532, 531, 530, 527, 526, 524, 523, 518, + 517, 516, 515, 513, 512, 511, 510, 509, 508, 507, + 506, 505, 504, 502, 501, 500, 499, 496, 495, 493, + 492, 489, 488, 486, 485, 484, 480, 478, 477, 476, + 475, 474, 473, 472, 469, 466, 459, 458, 457, 456, + 454, 453, 452, 451, 450, 449, 448, 447, 446, 445, + 443, 442, 441, 440, 437, 436, 434, 433, 430, 429, + + 427, 426, 425, 421, 419, 418, 417, 416, 415, 414, + 413, 403, 402, 401, 400, 399, 398, 397, 396, 395, + 394, 393, 392, 391, 390, 389, 387, 386, 385, 384, + 383, 382, 381, 380, 379, 378, 376, 374, 373, 372, + 371, 370, 369, 368, 366, 365, 364, 363, 361, 360, + 359, 358, 357, 356, 355, 354, 353, 352, 351, 346, + 343, 341, 339, 335, 334, 333, 332, 331, 330, 329, + 328, 327, 326, 325, 324, 323, 322, 320, 319, 318, + 317, 316, 315, 314, 313, 312, 311, 309, 307, 306, + 305, 304, 303, 302, 301, 299, 298, 297, 296, 294, + + 293, 292, 291, 290, 289, 288, 287, 286, 272, 271, + 270, 269, 268, 266, 264, 263, 260, 259, 258, 256, + 255, 254, 253, 251, 250, 249, 248, 247, 246, 245, + 244, 243, 242, 241, 240, 238, 237, 236, 235, 234, + 232, 231, 230, 229, 228, 227, 226, 225, 224, 221, + 220, 219, 211, 210, 207, 206, 205, 204, 203, 202, + 198, 197, 196, 193, 192, 190, 187, 186, 184, 182, + 181, 178, 177, 176, 174, 173, 172, 171, 169, 168, + 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, + 156, 155, 154, 153, 152, 150, 149, 148, 147, 146, + + 145, 144, 143, 140, 136, 126, 112, 109, 108, 106, + 105, 104, 103, 101, 99, 98, 97, 96, 94, 85, + 84, 82, 78, 77, 71, 68, 63, 60, 59, 58, + 53, 52, 51, 49, 47, 46, 45, 44, 42, 34, + 28, 17, 14, 12, 10, 9, 5, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + + 766, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 766, 766, 766 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "SDCC.lex" +#define INITIAL 0 +/*----------------------------------------------------------------------- + SDCC.lex - lexical analyser for use with sdcc ( a freeware compiler for + 8/16 bit microcontrollers) + Written by : Sandeep Dutta . sandeep.dutta@usa.net (1997) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#line 32 "SDCC.lex" + +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCCval.h" +#include "SDCCast.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCmem.h" + +char *stringLiteral(); +char *currFname; + +extern int lineno ; +extern char *filename ; +extern char *fullSrcFileName ; +int yylineno = 1 ; +void count() ; +void comment(); +int process_pragma(char *); +#undef yywrap + +int yywrap YY_PROTO((void)) +{ + return(1); +} + +char asmbuff[MAX_INLINEASM] ; +char *asmp ; +extern int check_type ( ); +extern int checkCurrFile (char *); +extern int processPragma (char *); +extern int printListing (int ); +struct optimize save_optimize ; +struct options save_options ; + + enum { + P_SAVE = 1, + P_RESTORE , + P_NOINDUCTION, + P_NOINVARIANT, + P_INDUCTION , + P_STACKAUTO , + P_NOJTBOUND , + P_NOOVERLAY , + P_NOGCSE , + P_CALLEE_SAVES, + P_EXCLUDE , + P_LOOPREV + }; + +#define asm 1 + + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + yy_current_buffer->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 87 "SDCC.lex" + + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 767 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 1348 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 88 "SDCC.lex" +{ count(); asmp = asmbuff ;BEGIN(asm) ;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 89 "SDCC.lex" +{ count() ; + *asmp = '\0' ; + strcpy(yylval.yyinline,asmbuff) ; + BEGIN(INITIAL) ; + return (INLINEASM) ; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 94 "SDCC.lex" +{ *asmp++ = yytext[0] ; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 95 "SDCC.lex" +{ count(); *asmp++ = '\n' ;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 96 "SDCC.lex" +{ comment(); } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 97 "SDCC.lex" +{ count(); return(AT) ; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 98 "SDCC.lex" +{ count(); return(AUTO); } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 99 "SDCC.lex" +{ count(); return(BIT) ; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 100 "SDCC.lex" +{ count(); return(BREAK); } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 101 "SDCC.lex" +{ count(); return(CASE); } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 102 "SDCC.lex" +{ count(); return(CHAR); } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 103 "SDCC.lex" +{ count(); return(CODE); } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 104 "SDCC.lex" +{ count(); return(CONST); } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 105 "SDCC.lex" +{ count(); return(CONTINUE); } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 106 "SDCC.lex" +{ count(); return(CRITICAL); } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 107 "SDCC.lex" +{ count(); return(DATA); } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 108 "SDCC.lex" +{ count(); return(DEFAULT); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 109 "SDCC.lex" +{ count(); return(DO); } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 110 "SDCC.lex" +{ count(); werror(W_DOUBLE_UNSUPPORTED);return(FLOAT); } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 111 "SDCC.lex" +{ count(); return(ELSE); } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 112 "SDCC.lex" +{ count(); return(ENUM); } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 113 "SDCC.lex" +{ count(); return(EXTERN); } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 114 "SDCC.lex" +{ count(); return(XDATA); } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 115 "SDCC.lex" +{ count(); return(FLOAT); } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 116 "SDCC.lex" +{ count(); return(FOR); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 117 "SDCC.lex" +{ count(); return(GOTO); } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 118 "SDCC.lex" +{ count(); return(IDATA);} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 119 "SDCC.lex" +{ count(); return(IF); } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 120 "SDCC.lex" +{ count(); return(INT); } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 121 "SDCC.lex" +{ count(); return(INTERRUPT);} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 122 "SDCC.lex" +{ count(); return(LONG); } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 123 "SDCC.lex" +{ count(); return(DATA);} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 124 "SDCC.lex" +{ count(); return(PDATA); } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 125 "SDCC.lex" +{ count(); return(REENTRANT);} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 126 "SDCC.lex" +{ count(); return(REGISTER); } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 127 "SDCC.lex" +{ count(); return(RETURN); } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 128 "SDCC.lex" +{ count(); return(SFR) ; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 129 "SDCC.lex" +{ count(); return(SBIT) ; } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 130 "SDCC.lex" +{ count(); return(SHORT); } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 131 "SDCC.lex" +{ count(); return(SIGNED); } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 132 "SDCC.lex" +{ count(); return(SIZEOF); } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 133 "SDCC.lex" +{ count(); return(STATIC); } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 134 "SDCC.lex" +{ count(); return(STRUCT); } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 135 "SDCC.lex" +{ count(); return(SWITCH); } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 136 "SDCC.lex" +{ count(); return(TYPEDEF); } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 137 "SDCC.lex" +{ count(); return(UNION); } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 138 "SDCC.lex" +{ count(); return(UNSIGNED); } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 139 "SDCC.lex" +{ count(); return(VOID); } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 140 "SDCC.lex" +{ count(); return(VOLATILE); } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 141 "SDCC.lex" +{ count(); return(USING); } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 142 "SDCC.lex" +{ count(); return(WHILE); } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 143 "SDCC.lex" +{ count(); return(XDATA); } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 144 "SDCC.lex" +{ count(); return(_NEAR); } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 145 "SDCC.lex" +{ count(); return(_CODE); } + YY_BREAK +case 55: +YY_RULE_SETUP +#line 146 "SDCC.lex" +{ count(); return(_GENERIC); } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 147 "SDCC.lex" +{ count(); return(_NEAR); } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 148 "SDCC.lex" +{ count(); return(_XDATA);} + YY_BREAK +case 58: +YY_RULE_SETUP +#line 149 "SDCC.lex" +{ count () ; return(_PDATA); } + YY_BREAK +case 59: +YY_RULE_SETUP +#line 150 "SDCC.lex" +{ count () ; return(_IDATA); } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 151 "SDCC.lex" +{ count(); return(VAR_ARGS);} + YY_BREAK +case 61: +YY_RULE_SETUP +#line 152 "SDCC.lex" +{ count(); return(check_type()); } + YY_BREAK +case 62: +YY_RULE_SETUP +#line 153 "SDCC.lex" +{ count(); yylval.val = constVal(yytext); return(CONSTANT); } + YY_BREAK +case 63: +YY_RULE_SETUP +#line 154 "SDCC.lex" +{ count(); yylval.val = constVal(yytext); return(CONSTANT); } + YY_BREAK +case 64: +YY_RULE_SETUP +#line 155 "SDCC.lex" +{ count(); yylval.val = constVal(yytext); return(CONSTANT); } + YY_BREAK +case 65: +YY_RULE_SETUP +#line 156 "SDCC.lex" +{ count();yylval.val = charVal (yytext); return(CONSTANT); } + YY_BREAK +case 66: +YY_RULE_SETUP +#line 157 "SDCC.lex" +{ count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } + YY_BREAK +case 67: +YY_RULE_SETUP +#line 158 "SDCC.lex" +{ count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } + YY_BREAK +case 68: +YY_RULE_SETUP +#line 159 "SDCC.lex" +{ count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } + YY_BREAK +case 69: +YY_RULE_SETUP +#line 160 "SDCC.lex" +{ count(); yylval.val=strVal(stringLiteral()); return(STRING_LITERAL);} + YY_BREAK +case 70: +YY_RULE_SETUP +#line 161 "SDCC.lex" +{ count(); yylval.yyint = RIGHT_ASSIGN ; return(RIGHT_ASSIGN); } + YY_BREAK +case 71: +YY_RULE_SETUP +#line 162 "SDCC.lex" +{ count(); yylval.yyint = LEFT_ASSIGN ; return(LEFT_ASSIGN) ; } + YY_BREAK +case 72: +YY_RULE_SETUP +#line 163 "SDCC.lex" +{ count(); yylval.yyint = ADD_ASSIGN ; return(ADD_ASSIGN) ; } + YY_BREAK +case 73: +YY_RULE_SETUP +#line 164 "SDCC.lex" +{ count(); yylval.yyint = SUB_ASSIGN ; return(SUB_ASSIGN) ; } + YY_BREAK +case 74: +YY_RULE_SETUP +#line 165 "SDCC.lex" +{ count(); yylval.yyint = MUL_ASSIGN ; return(MUL_ASSIGN) ; } + YY_BREAK +case 75: +YY_RULE_SETUP +#line 166 "SDCC.lex" +{ count(); yylval.yyint = DIV_ASSIGN ; return(DIV_ASSIGN) ; } + YY_BREAK +case 76: +YY_RULE_SETUP +#line 167 "SDCC.lex" +{ count(); yylval.yyint = MOD_ASSIGN ; return(MOD_ASSIGN) ; } + YY_BREAK +case 77: +YY_RULE_SETUP +#line 168 "SDCC.lex" +{ count(); yylval.yyint = AND_ASSIGN ; return(AND_ASSIGN) ; } + YY_BREAK +case 78: +YY_RULE_SETUP +#line 169 "SDCC.lex" +{ count(); yylval.yyint = XOR_ASSIGN ; return(XOR_ASSIGN) ; } + YY_BREAK +case 79: +YY_RULE_SETUP +#line 170 "SDCC.lex" +{ count(); yylval.yyint = OR_ASSIGN ; return(OR_ASSIGN) ; } + YY_BREAK +case 80: +YY_RULE_SETUP +#line 171 "SDCC.lex" +{ count(); return(RIGHT_OP); } + YY_BREAK +case 81: +YY_RULE_SETUP +#line 172 "SDCC.lex" +{ count(); return(LEFT_OP); } + YY_BREAK +case 82: +YY_RULE_SETUP +#line 173 "SDCC.lex" +{ count(); return(INC_OP); } + YY_BREAK +case 83: +YY_RULE_SETUP +#line 174 "SDCC.lex" +{ count(); return(DEC_OP); } + YY_BREAK +case 84: +YY_RULE_SETUP +#line 175 "SDCC.lex" +{ count(); return(PTR_OP); } + YY_BREAK +case 85: +YY_RULE_SETUP +#line 176 "SDCC.lex" +{ count(); return(AND_OP); } + YY_BREAK +case 86: +YY_RULE_SETUP +#line 177 "SDCC.lex" +{ count(); return(OR_OP); } + YY_BREAK +case 87: +YY_RULE_SETUP +#line 178 "SDCC.lex" +{ count(); return(LE_OP); } + YY_BREAK +case 88: +YY_RULE_SETUP +#line 179 "SDCC.lex" +{ count(); return(GE_OP); } + YY_BREAK +case 89: +YY_RULE_SETUP +#line 180 "SDCC.lex" +{ count(); return(EQ_OP); } + YY_BREAK +case 90: +YY_RULE_SETUP +#line 181 "SDCC.lex" +{ count(); return(NE_OP); } + YY_BREAK +case 91: +YY_RULE_SETUP +#line 182 "SDCC.lex" +{ count(); return(';'); } + YY_BREAK +case 92: +YY_RULE_SETUP +#line 183 "SDCC.lex" +{ count() ; NestLevel++ ; return('{'); } + YY_BREAK +case 93: +YY_RULE_SETUP +#line 184 "SDCC.lex" +{ count(); NestLevel--; return('}'); } + YY_BREAK +case 94: +YY_RULE_SETUP +#line 185 "SDCC.lex" +{ count(); return(','); } + YY_BREAK +case 95: +YY_RULE_SETUP +#line 186 "SDCC.lex" +{ count(); return(':'); } + YY_BREAK +case 96: +YY_RULE_SETUP +#line 187 "SDCC.lex" +{ count(); return('='); } + YY_BREAK +case 97: +YY_RULE_SETUP +#line 188 "SDCC.lex" +{ count(); return('('); } + YY_BREAK +case 98: +YY_RULE_SETUP +#line 189 "SDCC.lex" +{ count(); return(')'); } + YY_BREAK +case 99: +YY_RULE_SETUP +#line 190 "SDCC.lex" +{ count(); return('['); } + YY_BREAK +case 100: +YY_RULE_SETUP +#line 191 "SDCC.lex" +{ count(); return(']'); } + YY_BREAK +case 101: +YY_RULE_SETUP +#line 192 "SDCC.lex" +{ count(); return('.'); } + YY_BREAK +case 102: +YY_RULE_SETUP +#line 193 "SDCC.lex" +{ count(); return('&'); } + YY_BREAK +case 103: +YY_RULE_SETUP +#line 194 "SDCC.lex" +{ count(); return('!'); } + YY_BREAK +case 104: +YY_RULE_SETUP +#line 195 "SDCC.lex" +{ count(); return('~'); } + YY_BREAK +case 105: +YY_RULE_SETUP +#line 196 "SDCC.lex" +{ count(); return('-'); } + YY_BREAK +case 106: +YY_RULE_SETUP +#line 197 "SDCC.lex" +{ count(); return('+'); } + YY_BREAK +case 107: +YY_RULE_SETUP +#line 198 "SDCC.lex" +{ count(); return('*'); } + YY_BREAK +case 108: +YY_RULE_SETUP +#line 199 "SDCC.lex" +{ count(); return('/'); } + YY_BREAK +case 109: +YY_RULE_SETUP +#line 200 "SDCC.lex" +{ count(); return('%'); } + YY_BREAK +case 110: +YY_RULE_SETUP +#line 201 "SDCC.lex" +{ count(); return('<'); } + YY_BREAK +case 111: +YY_RULE_SETUP +#line 202 "SDCC.lex" +{ count(); return('>'); } + YY_BREAK +case 112: +YY_RULE_SETUP +#line 203 "SDCC.lex" +{ count(); return('^'); } + YY_BREAK +case 113: +YY_RULE_SETUP +#line 204 "SDCC.lex" +{ count(); return('|'); } + YY_BREAK +case 114: +YY_RULE_SETUP +#line 205 "SDCC.lex" +{ count(); return('?'); } + YY_BREAK +case 115: +YY_RULE_SETUP +#line 206 "SDCC.lex" +{ count(); checkCurrFile(yytext); } + YY_BREAK +case 116: +YY_RULE_SETUP +#line 207 "SDCC.lex" +{ count(); process_pragma(yytext); } + YY_BREAK +case 117: +YY_RULE_SETUP +#line 209 "SDCC.lex" +{ werror(E_PRE_PROC_FAILED,yytext);count(); } + YY_BREAK +case 118: +YY_RULE_SETUP +#line 210 "SDCC.lex" +{ werror(W_PRE_PROC_WARNING,yytext);count(); } + YY_BREAK +case 119: +YY_RULE_SETUP +#line 211 "SDCC.lex" +{ count(); } + YY_BREAK +case 120: +YY_RULE_SETUP +#line 212 "SDCC.lex" +{ count(); } + YY_BREAK +case 121: +YY_RULE_SETUP +#line 213 "SDCC.lex" +{ count(); } + YY_BREAK +case 122: +YY_RULE_SETUP +#line 214 "SDCC.lex" +{ count() ; } + YY_BREAK +case 123: +YY_RULE_SETUP +#line 215 "SDCC.lex" +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(asm): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 767 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 767 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 766); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + yy_current_buffer->yy_at_bol = (c == '\n'); + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 215 "SDCC.lex" + + +int checkCurrFile ( char *s) +{ + char lineNum[10] ; + int lNum ; + char *tptr ; + + /* first check if this is a #line */ + if ( strncmp(s,"#line",5) ) + return 0 ; + + /* get to the line number */ + while (!isdigit(*s)) + s++ ; + tptr = lineNum ; + while (isdigit(*s)) + *tptr++ = *s++ ; + *tptr = '\0'; + sscanf(lineNum,"%d",&lNum); + + /* now see if we have a file name */ + while (*s != '\"' && *s) + s++ ; + + /* if we don't have a filename then */ + /* set the current line number to */ + /* line number if printFlag is on */ + if (!*s) { + yylineno = lNum ; + return 0; + } + + /* if we have a filename then check */ + /* if it is "standard in" if yes then */ + /* get the currentfile name info */ + s++ ; + + if ( strncmp(s,fullSrcFileName,strlen(fullSrcFileName)) == 0) { + yylineno = lNum - 2; + currFname = fullSrcFileName ; + } else { + char *sb = s; + /* mark the end of the filename */ + while (*s != '"') s++; + *s = '\0'; + ALLOC_ATOMIC(currFname,strlen(sb)+1); + strcpy(currFname,sb); + yylineno = lNum - 2; + } + filename = currFname ; + return 0; +} + +void comment() +{ + char c, c1; + +loop: + while ((c = input()) != '*' && c != 0) + if ( c == '\n') + yylineno++ ; + + if ((c1 = input()) != '/' && c != 0) { + if ( c1 == '\n' ) + yylineno++ ; + + unput(c1); + goto loop; + } + +} + + + +int column = 0; +int plineIdx=0; + +void count() +{ + int i; + for (i = 0; yytext[i] != '\0'; i++) { + if (yytext[i] == '\n') { + column = 0; + lineno = ++yylineno ; + } + else + if (yytext[i] == '\t') + column += 8 - (column % 8); + else + column++; + } + + /* ECHO; */ +} + +int check_type() +{ + /* check if it is in the typedef table */ + if (findSym(TypedefTab,NULL,yytext)) { + strcpy(yylval.yychar,yytext); + return (TYPE_NAME) ; + } + else { + strcpy (yylval.yychar,yytext); + return(IDENTIFIER); + } +} + +char strLitBuff[2048] ; + +char *stringLiteral () +{ + int ch; + char *str = strLitBuff ; + + *str++ = '\"' ; + /* put into the buffer till we hit the */ + /* first \" */ + while (1) { + + ch = input() ; + if (!ch) break ; /* end of input */ + /* if it is a \ then everything allowed */ + if (ch == '\\') { + *str++ = ch ; /* backslash in place */ + *str++ = input() ; /* following char in place */ + continue ; /* carry on */ + } + + /* if new line we have a new line break */ + if (ch == '\n') break ; + + /* if this is a quote then we have work to do */ + /* find the next non whitespace character */ + /* if that is a double quote then carry on */ + if (ch == '\"') { + + while ((ch = input()) && isspace(ch)) ; + if (!ch) break ; + if (ch != '\"') { + unput(ch) ; + break ; + } + + continue ; + } + *str++ = ch; + } + *str++ = '\"' ; + *str = '\0'; + return strLitBuff ; +} + +void doPragma (int op, char *cp) +{ + switch (op) { + case P_SAVE: + memcpy(&save_options,&options,sizeof(options)); + memcpy(&save_optimize,&optimize,sizeof(optimize)); + break; + case P_RESTORE: + memcpy(&options,&save_options,sizeof(options)); + memcpy(&optimize,&save_optimize,sizeof(optimize)); + break; + case P_NOINDUCTION: + optimize.loopInduction = 0 ; + break; + case P_NOINVARIANT: + optimize.loopInvariant = 0 ; + break; + case P_INDUCTION: + optimize.loopInduction = 1 ; + break; + case P_STACKAUTO: + options.stackAuto = 1; + break; + case P_NOJTBOUND: + optimize.noJTabBoundary = 1; + break; + case P_NOGCSE: + optimize.global_cse = 0; + break; + case P_NOOVERLAY: + options.noOverlay = 1; + break; + case P_CALLEE_SAVES: + { + int i=0; + /* append to the functions already listed + in callee-saves */ + for (; options.calleeSaves[i] ;i++); + parseWithComma(&options.calleeSaves[i],strdup(cp)); + } + break; + case P_EXCLUDE: + parseWithComma(options.excludeRegs,strdup(cp)); + break; + case P_LOOPREV: + optimize.noLoopReverse = 1; + break; + } +} + +int process_pragma(char *s) +{ + char *cp ; + /* find the pragma */ + while (strncmp(s,"#pragma",7)) + s++; + s += 7; + + /* look for the directive */ + while(isspace(*s)) s++; + + cp = s; + /* look for the end of the directive */ + while ((! isspace(*s)) && + (*s != '\n')) + s++ ; + + /* now compare and do what needs to be done */ + if (strncmp(cp,PRAGMA_SAVE,strlen(PRAGMA_SAVE)) == 0) { + doPragma(P_SAVE,cp+strlen(PRAGMA_SAVE)); + return 0; + } + + if (strncmp(cp,PRAGMA_RESTORE,strlen(PRAGMA_RESTORE)) == 0) { + doPragma (P_RESTORE,cp+strlen(PRAGMA_RESTORE)); + return 0; + } + + if (strncmp(cp,PRAGMA_NOINDUCTION,strlen(PRAGMA_NOINDUCTION)) == 0) { + doPragma (P_NOINDUCTION,cp+strlen(PRAGMA_NOINDUCTION)) ; + return 0; + } + + if (strncmp(cp,PRAGMA_NOINVARIANT,strlen(PRAGMA_NOINVARIANT)) == 0) { + doPragma (P_NOINVARIANT,NULL) ; + return 0; + } + + if (strncmp(cp,PRAGMA_INDUCTION,strlen(PRAGMA_INDUCTION)) == 0) { + doPragma (P_INDUCTION,NULL) ; + return 0; + } + + if (strncmp(cp,PRAGMA_STACKAUTO,strlen(PRAGMA_STACKAUTO)) == 0) { + doPragma (P_STACKAUTO,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_NOJTBOUND,strlen(PRAGMA_NOJTBOUND)) == 0) { + doPragma (P_NOJTBOUND,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_NOGCSE,strlen(PRAGMA_NOGCSE)) == 0) { + doPragma (P_NOGCSE,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_NOOVERLAY,strlen(PRAGMA_NOOVERLAY)) == 0) { + doPragma (P_NOOVERLAY,NULL); + return 0; + } + + if (strncmp(cp,PRAGMA_CALLEESAVES,strlen(PRAGMA_CALLEESAVES)) == 0) { + doPragma(P_CALLEE_SAVES,cp+strlen(PRAGMA_CALLEESAVES)); + return 0; + } + + if (strncmp(cp,PRAGMA_EXCLUDE,strlen(PRAGMA_EXCLUDE)) == 0) { + doPragma(P_EXCLUDE,cp+strlen(PRAGMA_EXCLUDE)); + return 0; + } + + if (strncmp(cp,PRAGMA_NOLOOPREV,strlen(PRAGMA_NOLOOPREV)) == 0) { + doPragma(P_EXCLUDE,NULL); + return 0; + } + + werror(W_UNKNOWN_PRAGMA,cp); + return 0; +} diff --git a/src/SDCCloop.c b/src/SDCCloop.c new file mode 100644 index 00000000..73782f3f --- /dev/null +++ b/src/SDCCloop.c @@ -0,0 +1,1124 @@ +/*------------------------------------------------------------------------- + + SDCCloop.c - source file for loop detection & optimizations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCdflow.h" +#include "SDCCloop.h" + +DEFSETFUNC(isDefAlive); + +STACK_DCL(regionStack,eBBlock *, MAX_NEST_LEVEL * 10); + +/*-----------------------------------------------------------------*/ +/* newInduction - creates a new induction variable */ +/*-----------------------------------------------------------------*/ +induction *newInduction (operand *sym, unsigned int op, + long constVal, iCode *ic, operand *asym) +{ + induction *ip; + + ALLOC(ip,sizeof(induction)); + + ip->sym = sym; + ip->asym= asym; + ip->op = op; + ip->cval = constVal; + ip->ic = ic; + + return ip; +} + +/*-----------------------------------------------------------------*/ +/* newRegion - allocate & returns a loop structure */ +/*-----------------------------------------------------------------*/ +region *newRegion () +{ + region *lp ; + + ALLOC(lp,sizeof(region)); + + return lp; +} + + +/*-----------------------------------------------------------------*/ +/* pinduction - prints induction */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(pinduction) +{ + induction *ip = item; + iCodeTable *icTab; + + fprintf(stdout,"\t"); + printOperand(ip->sym,stdout); + icTab = getTableEntry(ip->ic->op); + icTab->iCodePrint(stdout,ip->ic,icTab->printName); + fprintf(stdout," %04d\n",(int)ip->cval); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* pregion - prints loop information */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(pregion) +{ + region *lp = item; + + printf("================\n"); + printf(" loop with entry -- > "); printEntryLabel(lp->entry,ap); + printf("\n"); + printf(" loop body --> "); applyToSet(lp->regBlocks,printEntryLabel); + printf("\n"); + printf(" loop exits --> "); applyToSet(lp->exits,printEntryLabel); + printf("\n"); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* backEdges - returns a list of back edges */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(backEdges) +{ + edge *ep = item; + V_ARG(set **,bEdges); + + /* if this is a back edge ; to determine this we check */ + /* to see if the 'to' is in the dominator list of the */ + /* 'from' if yes then this is a back edge */ + if (bitVectBitValue (ep->from->domVect,ep->to->bbnum)) { + addSetHead (bEdges,ep); + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* intersectLoopSucc - returns intersection of loop Successors */ +/*-----------------------------------------------------------------*/ +static bitVect *intersectLoopSucc ( set *lexits, eBBlock **ebbs) +{ + bitVect *succVect = NULL; + eBBlock *exit = setFirstItem(lexits); + + if (!exit) + return NULL; + + succVect = bitVectCopy(exit->succVect); + + for (exit = setNextItem(lexits); exit ; + exit = setNextItem(lexits)) { + succVect = bitVectIntersect(succVect, + exit->succVect); + } + + return succVect ; +} + + +/*-----------------------------------------------------------------*/ +/* loopInsert will insert a block into the loop set */ +/*-----------------------------------------------------------------*/ +static void loopInsert (set **regionSet, eBBlock *block) +{ + if (!isinSet (*regionSet,block)) { + addSetHead (regionSet,block); + STACK_PUSH(regionStack,block); + } +} + +/*-----------------------------------------------------------------*/ +/* insertIntoLoop - insert item into loop */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(insertIntoLoop) +{ + eBBlock *ebp = item ; + V_ARG(set **,regionSet); + + loopInsert (regionSet,ebp); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isNotInBlocks - will return 1 if not is blocks */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(isNotInBlocks) +{ + eBBlock *ebp = item; + V_ARG(set *,blocks); + + if (! isinSet (blocks,ebp)) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* hasIncomingDefs - has definitions coming into the loop. i.e. */ +/* check to see if the preheaders outDefs has any definitions */ +/*-----------------------------------------------------------------*/ +int hasIncomingDefs (region *lreg, operand *op) +{ + eBBlock *preHdr = lreg->entry->preHeader; + + if (preHdr && bitVectBitsInCommon(preHdr->outDefs,OP_DEFS(op))) + return 1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* findLoopEndSeq - will return the sequence number of the last */ +/* iCode with the maximum dfNumber in the region */ +/*-----------------------------------------------------------------*/ +int findLoopEndSeq (region *lreg) +{ + eBBlock *block; + eBBlock *lblock; + + for (block = lblock =setFirstItem(lreg->regBlocks); block; + block = setNextItem(lreg->regBlocks)) { + if (block != lblock && block->lSeq > lblock->lSeq) + lblock = block; + } + + return lblock->lSeq; +} + +/*-----------------------------------------------------------------*/ +/* addToExitsMarkDepth - will add the the exitSet all blocks that */ +/* have exits, will also update the depth field in the blocks */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(addToExitsMarkDepth) +{ + eBBlock *ebp = item ; + V_ARG(set *,loopBlocks); + V_ARG(set **,exits); + V_ARG(int, depth); + V_ARG(region *,lr); + + /* mark the loop depth of this block */ + if (!ebp->depth) + ebp->depth = depth; + + /* put the loop region info in the block */ + /* NOTE: here we will update only the inner most loop + that it is a part of */ + if (!ebp->partOfLoop) + ebp->partOfLoop = lr; + + /* if any of the successors go out of the loop then */ + /* we add this one to the exits */ + if ( applyToSet(ebp->succList,isNotInBlocks,loopBlocks)) { + addSetHead (exits,ebp); + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* createLoop - will create a set of region */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(createLoop) +{ + edge *ep = item; + V_ARG(set **,allRegion); + region *aloop = newRegion(); + eBBlock *block; + + /* make sure regionStack is empty */ + while (!STACK_EMPTY(regionStack)) + STACK_POP(regionStack); + + /* add the entryBlock */ + addSet (&aloop->regBlocks,ep->to); + loopInsert (&aloop->regBlocks,ep->from); + + while (!STACK_EMPTY(regionStack)) { + block = STACK_POP(regionStack); + /* if block != entry */ + if (block != ep->to) + applyToSet(block->predList,insertIntoLoop,&aloop->regBlocks); + } + + aloop->entry = ep->to ; + + /* now add it to the set */ + addSetHead (allRegion,aloop); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* dominatedBy - will return 1 if item is dominated by block */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(dominatedBy) +{ + eBBlock *ebp = item; + V_ARG(eBBlock *,block); + + return bitVectBitValue (ebp->domVect,block->bbnum); +} + +/*-----------------------------------------------------------------*/ +/* addDefInExprs - adds an expression into the inexpressions */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(addDefInExprs) +{ + eBBlock *ebp = item; + V_ARG(cseDef *,cdp); + V_ARG(eBBlock **,ebbs); + V_ARG(int,count); + + addSetHead(&ebp->inExprs,cdp); + cseBBlock (ebp,0,ebbs,count); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* assignmentsToSym - for a set of blocks determine # time assigned*/ +/*-----------------------------------------------------------------*/ + int assignmentsToSym (set *sset, operand *sym) +{ + eBBlock *ebp ; + int assigns = 0; + set *blocks = setFromSet(sset); + + for (ebp = setFirstItem(blocks) ; ebp ; + ebp = setNextItem(blocks)) { + + /* get all the definitions for this symbol + in this block */ + bitVect *defs = bitVectIntersect(ebp->ldefs,OP_DEFS(sym)); + assigns += bitVectnBitsOn(defs); + setToNull((void **)&defs); + + } + + return assigns; +} + + +/*-----------------------------------------------------------------*/ +/* isOperandInvariant - determines if an operand is an invariant */ +/*-----------------------------------------------------------------*/ +int isOperandInvariant (operand *op, region *theLoop, set *lInvars) +{ + int opin = 0 ; + /* operand is an invariant if it is a */ + /* a. constants . */ + /* b. that have defintions reaching loop entry */ + /* c. that are already defined as invariant */ + /* d. has no assignments in the loop */ + if (op) { + if (IS_OP_LITERAL(op)) + opin = 1 ; + else + if (IS_SYMOP(op) && + OP_SYMBOL(op)->addrtaken) + opin = 0 ; + else + if (ifDefSymIs(theLoop->entry->inExprs,op)) + opin = 1 ; + else + if (ifDefSymIs(lInvars,op)) + opin = 1 ; + else + if (IS_SYMOP(op) && + ! IS_OP_GLOBAL(op) && + ! IS_OP_VOLATILE(op) && + assignmentsToSym (theLoop->regBlocks,op) == 0 ) + opin = 1 ; + } else opin++ ; + + return opin ; +} + +/*-----------------------------------------------------------------*/ +/* pointerAssigned - will return 1 if pointer set found */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(pointerAssigned) +{ + eBBlock *ebp = item; + V_ARG(operand *,op); + + return ebp->hasFcall || bitVectBitValue(ebp->ptrsSet,op->key); +} + +/*-----------------------------------------------------------------*/ +/* hasNonPtrUse - returns true if operand has non pointer usage */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(hasNonPtrUse) +{ + eBBlock *ebp = item; + V_ARG(operand *,op); + iCode *ic = usedInRemaining(op,ebp->sch); + + if (ic && !POINTER_SET(ic) && !POINTER_GET(ic)) + return 1; + + return 0; + +} + +/*-----------------------------------------------------------------*/ +/* loopInvariants - takes loop invariants out of region */ +/*-----------------------------------------------------------------*/ + int loopInvariants( region *theLoop , eBBlock **ebbs, int count) +{ + eBBlock *lBlock ; + set *lInvars = NULL ; + + int change = 0 ; + + /* if the preHeader does not exist then do nothing */ + /* or no exits then do nothing ( have to think about this situation */ + if (theLoop->entry->preHeader == NULL || + theLoop->exits == NULL ) + return 0; + + /* we will do the elimination for those blocks */ + /* in the loop that dominates all exits from the loop */ + for (lBlock = setFirstItem(theLoop->regBlocks); lBlock; + lBlock = setNextItem(theLoop->regBlocks)) { + + iCode *ic; + int domsAllExits ; + int i ; + + /* mark the dominates all exits flag */ + domsAllExits = ( applyToSet (theLoop->exits,dominatedBy,lBlock) == + elementsInSet (theLoop->exits)); + + + /* now we go thru the instructions of this block and */ + /* collect those instructions with invariant operands*/ + for ( ic = lBlock->sch ; ic ; ic = ic->next ) { + + int lin , rin ; + cseDef *ivar ; + + if (SKIP_IC(ic) || POINTER_SET(ic) || ic->op == IFX) + continue ; + + /* if result is volatile then skip */ + if (IC_RESULT(ic) && + ( isOperandVolatile(IC_RESULT(ic),TRUE) || + IS_OP_PARM(IC_RESULT(ic)))) + continue ; + + lin = rin = 0 ; + + /* special case */ + /* if address of then it is an invariant */ + if (ic->op == ADDRESS_OF && + IS_SYMOP(IC_LEFT(ic)) && + IS_AGGREGATE(operandType(IC_LEFT(ic)))) + lin++; + else + /* check if left operand is an invariant */ + if ( (lin = isOperandInvariant (IC_LEFT(ic),theLoop,lInvars))) + /* if this is a pointer get then make sure + that the pointer set does not exist in + any of the blocks */ + if (POINTER_GET(ic) && + ( applyToSet (theLoop->regBlocks,pointerAssigned,IC_LEFT(ic)) )) + lin = 0; + + /* do the same for right */ + rin = isOperandInvariant (IC_RIGHT(ic),theLoop, lInvars); + + /* if this is a POINTER_GET then special case, make sure all + usages within the loop are POINTER_GET any other usage + would mean that this is not an invariant , since the pointer + could then be passed as a parameter */ + if (POINTER_GET(ic) && + applyToSet(theLoop->regBlocks,hasNonPtrUse,IC_LEFT(ic))) + continue ; + + /* if both the left & right are invariants : then check that*/ + /* this definition exists in the out definition of all the */ + /* blocks, this will ensure that this is not assigned any */ + /* other value in the loop , and not used in this block */ + /* prior to this definition which means only this definition*/ + /* is used in this loop */ + if (lin && rin && IC_RESULT(ic)) { + eBBlock *sBlock ; + set *lSet = setFromSet(theLoop->regBlocks); + + /* if this block does not dominate all exists */ + /* make sure this defintion is not used anywhere else */ + if (!domsAllExits) { + + if (isOperandGlobal(IC_RESULT(ic))) + continue; + /* for successors for all exits */ + for ( sBlock = setFirstItem(theLoop->exits); sBlock; + sBlock = setNextItem(theLoop->exits)) { + + for(i=0; i < count; ebbs[i++]->visited = 0); + lBlock->visited = 1; + if ( applyToSet (sBlock->succList,isDefAlive,ic)) + break ; + } + + /* we have found usage */ + if (sBlock ) + continue ; + } + + /* now make sure this is the only definition */ + for (sBlock = setFirstItem(lSet); sBlock ; + sBlock = setNextItem (lSet)) { + /* if this is the block make sure the definition */ + /* reaches the end of the block */ + if (sBlock == lBlock ) { + if (! ifDiCodeIs (sBlock->outExprs,ic)) + break; + } + else + if (bitVectBitsInCommon (sBlock->defSet,OP_DEFS(IC_RESULT(ic)))) + break; + } + + if (sBlock) + continue ; /* another definition present in the block */ + + /* now check if it exists in the in of this block */ + /* if not then it was killed before this instruction */ + if (! bitVectBitValue (lBlock->inDefs,ic->key)) + continue ; + + /* now we know it is a true invariant */ + /* remove it from the insts chain & put */ + /* in the invariant set */ + OP_SYMBOL(IC_RESULT(ic))->isinvariant = 1; + remiCodeFromeBBlock (lBlock,ic); + + /* maintain the data flow */ + /* this means removing from definition from the */ + /* defset of this block and adding it to the */ + /* inexpressions of all blocks within the loop */ + bitVectUnSetBit (lBlock->defSet,ic->key); + bitVectUnSetBit (lBlock->ldefs,ic->key); + ivar = newCseDef(IC_RESULT(ic),ic); + applyToSet (theLoop->regBlocks, addDefInExprs, ivar,ebbs,count); + addSet(&lInvars,ivar); + } + } + } /* for all loop blocks */ + + /* if we have some invariants then */ + if (lInvars) { + eBBlock *preHdr= theLoop->entry->preHeader ; + iCode *icFirst = NULL , *icLast = NULL ; + cseDef *cdp; + + /* create an iCode chain from it */ + for (cdp = setFirstItem(lInvars); cdp ; cdp = setNextItem(lInvars)) { + + /* maintain data flow .. add it to the */ + /* defSet & outExprs of the preheader */ + preHdr->defSet = bitVectSetBit (preHdr->defSet,cdp->diCode->key); + cdp->diCode->lineno = preHdr->ech->lineno; + addSetHead (&preHdr->outExprs,cdp); + + + if (!icFirst) + icFirst = cdp->diCode; + if (icLast) { + icLast->next = cdp->diCode; + cdp->diCode->prev = icLast; + icLast = cdp->diCode ; + } else + icLast = cdp->diCode; + change++ ; + } + + /* add the instruction chain to the end of the + preheader for this loop, preheaders will always + have atleast a label */ + preHdr->ech->next = icFirst ; + icFirst->prev = preHdr->ech ; + preHdr->ech = icLast; + icLast->next = NULL; + + } + return change ; +} + +/*-----------------------------------------------------------------*/ +/* addressTaken - returns true if the symbol is found in the addrof*/ +/*-----------------------------------------------------------------*/ +int addressTaken (set *sset ,operand *sym) +{ + set *loop; + eBBlock *ebp ; + set *loop2; + + for (loop = sset; loop ; loop = loop->next) { + ebp = loop->item; + loop2 = ebp->addrOf ; + while (loop2) { + if (isOperandEqual((operand *)loop2->item,sym)) + return 1; + loop2 = loop2->next; + } + } + + return 0; +} + + +/*-----------------------------------------------------------------*/ +/* findInduction :- returns 1 & the item if the induction is found */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(findInduction) +{ + induction *ip = item; + V_ARG(operand *,sym); + V_ARG(induction **,ipp); + + if (isOperandEqual(ip->sym,sym)) { + *ipp = ip; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* findDefInRegion - finds the definition within the region */ +/*-----------------------------------------------------------------*/ +iCode *findDefInRegion (set *regBlocks, operand *defOp, eBBlock **owner) +{ + eBBlock *lBlock ; + + /* for all blocks in the region */ + for (lBlock = setFirstItem(regBlocks); lBlock ; + lBlock = setNextItem(regBlocks)) { + + /* if a definition for this exists */ + if (bitVectBitsInCommon(lBlock->defSet,OP_DEFS(defOp))) { + iCode *ic; + + /* go thru the instruction chain to find it */ + for (ic = lBlock->sch ; ic ; ic = ic->next ) + if (bitVectBitValue (OP_DEFS(defOp),ic->key)) { + if (owner) + *owner = lBlock ; + return ic; + } + } + } + + return NULL ; +} + +/*-----------------------------------------------------------------*/ +/* basicInduction - finds the basic induction variables in a loop */ +/*-----------------------------------------------------------------*/ +set *basicInduction (region *loopReg , eBBlock **ebbs, int count) +{ + eBBlock *lBlock ; + set *indVars = NULL ; + + /* i.e. all assignments of the form a := a +/- const*/ + /* for all blocks within the loop do */ + for ( lBlock = setFirstItem(loopReg->regBlocks); lBlock ; + lBlock = setNextItem(loopReg->regBlocks)) { + + iCode *ic, *dic ; + + /* for all instructions in the blocks do */ + for ( ic = lBlock->sch ; ic ; ic = ic->next ) { + + operand *aSym ; + unsigned long litValue ; + induction *ip; + iCode *indIc; + eBBlock *owner = NULL; + int nexits; + + /* look for assignments of the form */ + /* symbolVar := iTempNN */ + if ( ic->op != '=') + continue ; + + if (!IS_TRUE_SYMOP(IC_RESULT(ic)) && + !OP_SYMBOL(IC_RESULT(ic))->isreqv) + continue ; + + if (isOperandGlobal(IC_RESULT(ic))) + continue ; + + if (!IS_ITEMP(IC_RIGHT(ic))) + continue ; + + /* if it has multiple assignments within the loop then skip */ + if (assignmentsToSym (loopReg->regBlocks,IC_RESULT(ic)) > 1 ) + continue ; + + /* if the address of this was taken inside the loop then continue */ + if (addressTaken (loopReg->regBlocks,IC_RESULT(ic))) + continue ; + + /* find the definition for the result in the block */ + if (! (dic = findDefInRegion (setFromSet(loopReg->regBlocks), + IC_RIGHT(ic),&owner))) + continue ; + + /* if not +/- continue */ + if (dic->op != '+' && dic->op != '-') + continue ; + + /* make sure definition is of the form a +/- c */ + if (!IS_OP_LITERAL(IC_LEFT(dic)) && !IS_OP_LITERAL(IC_RIGHT(dic))) + continue ; + + aSym = (IS_OP_LITERAL(IC_RIGHT(dic)) ? + (litValue = operandLitValue(IC_RIGHT(dic)),IC_LEFT(dic)) : + (litValue = operandLitValue(IC_LEFT(dic)),IC_RIGHT(dic))); + + if (!isOperandEqual(IC_RESULT(ic),aSym) && + !isOperandEqual(IC_RIGHT(ic),aSym)) { + iCode *ddic ; + /* find the definition for this and check */ + if (!(ddic = findDefInRegion (setFromSet(loopReg->regBlocks), + aSym,&owner))) + continue ; + + if (ddic->op != '=') + continue ; + + if (!isOperandEqual(IC_RESULT(ddic),aSym) || + !isOperandEqual(IC_RIGHT(ddic),IC_RESULT(ic))) + continue ; + } + + /* if the right hand side has more than one usage then + don't make it an induction (will have to think some more) */ + if (bitVectnBitsOn(OP_USES(IC_RIGHT(ic))) > 1) + continue; + + /* if the definition is volatile then it cannot be + an induction object */ + if (isOperandVolatile(IC_RIGHT(ic),FALSE) || + isOperandVolatile(IC_RESULT(ic),FALSE)) + continue; + + /* whew !! that was a lot of work to find the definition */ + /* create an induction object */ + indIc = newiCode('=',NULL,IC_RESULT(ic)); + indIc->lineno = ic->lineno; + IC_RESULT(indIc) = operandFromOperand(IC_RIGHT(ic)); + IC_RESULT(indIc)->isaddr = 0; + OP_SYMBOL(IC_RESULT(indIc))->isind = 1; + ip = newInduction (IC_RIGHT(ic),dic->op,litValue,indIc,NULL); + + /* replace the inducted variable by the iTemp */ + replaceSymBySym (loopReg->regBlocks,IC_RESULT(ic),IC_RIGHT(ic)); + + /* if it has only one exit then remove it from here + and put it in the exit block */ + nexits = elementsInSet (loopReg->exits); + if (nexits == 1) { + eBBlock *exit = setFirstItem(loopReg->exits); + + /* if it is the same block then there is no + need to move it about */ + if ( exit != lBlock) { + iCode *saveic = ic->prev; + /* remove it */ + remiCodeFromeBBlock(lBlock,ic); + /* clear the definition */ + bitVectUnSetBit(lBlock->defSet,ic->key); + /* add it to the exit */ + addiCodeToeBBlock(exit,ic,NULL); + /* set the definition bit */ + exit->defSet = bitVectSetBit(exit->defSet,ic->key); + ic = saveic ; + } + } + + /* if the number of exits is greater than one then + we use another trick ; we will create an intersection + of succesors of the exits, then take those that are not + part of the loop and have dfNumber greater loop entry + and insert a new definition in them */ + if ( nexits > 1) { + + bitVect *loopSuccs = intersectLoopSucc (loopReg->exits,ebbs); + + /* loopSuccs now contains intersection + of all the loops successors */ + if (loopSuccs) { + int i; + for (i = 0 ; i < loopSuccs->size; i++) { + if (bitVectBitValue(loopSuccs,i)) { + + eBBlock *eblock = ebbs[i]; + + /* if the successor does not belong to the loop + and will be executed after the loop : then + add a definition to the block */ + if ( !isinSet(loopReg->regBlocks,eblock) && + eblock->dfnum > loopReg->entry->dfnum) { + /* create the definition */ + iCode *newic = newiCode('=',NULL, + operandFromOperand(IC_RIGHT(ic))); + IC_RESULT(newic) = operandFromOperand(IC_RESULT(ic)); + OP_DEFS(IC_RESULT(newic)) = + bitVectSetBit(OP_DEFS(IC_RESULT(newic)),newic->key); + OP_USES(IC_RIGHT(newic)) = + bitVectSetBit(OP_USES(IC_RIGHT(newic)),newic->key); + /* and add it */ + if (eblock->sch && eblock->sch->op == LABEL) + addiCodeToeBBlock(eblock,newic,eblock->sch->next); + else + addiCodeToeBBlock(eblock,newic,eblock->sch); + /* set the definition bit */ + eblock->defSet = bitVectSetBit(eblock->defSet,ic->key); + } + } + } + } + } + + addSet (&indVars,ip); + } + + } /* end of all blocks for basic induction variables */ + + return indVars; +} + +/*-----------------------------------------------------------------*/ +/* loopInduction - remove induction variables from a loop */ +/*-----------------------------------------------------------------*/ + int loopInduction( region *loopReg, eBBlock **ebbs, int count) +{ + int change = 0 ; + eBBlock *lBlock, *lastBlock = NULL; + set *indVars = NULL ; + set *basicInd=NULL ; + + if (loopReg->entry->preHeader == NULL) + return 0; + + /* we first determine the basic Induction variables */ + basicInd = setFromSet(indVars = basicInduction(loopReg, ebbs,count)); + + /* find other induction variables : by other we mean definitions of */ + /* the form x := y (* | / ) .. we will move this one to */ + /* beginning of the loop and reduce strength i.e. replace with +/- */ + /* these expensive expressions: OH! and y must be induction too */ + for ( lBlock = setFirstItem(loopReg->regBlocks), lastBlock = lBlock; + lBlock && indVars; + lBlock = setNextItem(loopReg->regBlocks)) { + + iCode *ic, *indIc; + induction *ip; + + /* last block is the one with the highest block + number */ + if (lastBlock->bbnum < lBlock->bbnum ) + lastBlock = lBlock; + + for ( ic = lBlock->sch ; ic ; ic = ic->next ) { + operand *aSym ; + unsigned long litVal ; + int lr = 0; + + /* consider only * & / */ + if (ic->op != '*' && ic->op != '/') + continue ; + + /* if the result has more definitions then */ + if (assignmentsToSym(loopReg->regBlocks,IC_RESULT(ic)) > 1) + continue ; + + /* check if the operands are what we want */ + /* i.e. one of them an symbol the other a literal */ + if (! ( (IS_SYMOP(IC_LEFT(ic)) && IS_OP_LITERAL(IC_RIGHT(ic))) || + (IS_OP_LITERAL(IC_LEFT(ic)) && IS_SYMOP(IC_RIGHT(ic))) )) + continue ; + + aSym = (IS_SYMOP(IC_LEFT(ic)) ? + (lr = 1, litVal = operandLitValue(IC_RIGHT(ic)), IC_LEFT(ic) ) : + (litVal= operandLitValue(IC_LEFT(ic)), IC_RIGHT(ic) ) ) ; + + ip = NULL ; + /* check if this is an induction variable */ + if (! applyToSetFTrue (basicInd,findInduction,aSym,&ip)) + continue ; + + /* if this is a division then the remainder should be zero + for it to be inducted */ + if (ic->op == '/' && (ip->cval % litVal)) + continue ; + + /* create the iCode to be placed in the loop header */ + /* and create the induction object */ + + /* create an instruction */ + /* this will be put on the loop header */ + indIc = newiCode(ic->op, + operandFromOperand(aSym), + operandFromLit(litVal)); + indIc->lineno = ic->lineno; + IC_RESULT(indIc) = operandFromOperand(IC_RESULT(ic)); + OP_SYMBOL(IC_RESULT(indIc))->isind = 1; + + /* keep track of the inductions */ + litVal = (ic->op == '*' ? (litVal * ip->cval) : + (ip->cval / litVal)); + + addSet (&indVars, + newInduction (IC_RESULT(ic),ip->op,litVal,indIc,NULL)); + + /* now change this instruction */ + ic->op = ip->op; + if (lr) { + IC_LEFT(ic) = operandFromOperand(IC_RESULT(ic)); + IC_RIGHT(ic) = operandFromLit(litVal); + } else { + IC_RIGHT(ic) = operandFromOperand(IC_RESULT(ic)); + IC_LEFT(ic) = operandFromLit(litVal); + } + + /* we need somemore initialisation code */ + /* we subtract the litVal from itself if increment */ + if ( ic->op == '+' ) { + indIc = newiCode('-', + operandFromOperand(IC_RESULT(ic)), + operandFromLit(litVal)); + indIc->lineno = ic->lineno; + IC_RESULT(indIc) = operandFromOperand(IC_RESULT(ic)); + + addSet (&indVars, + newInduction (IC_RESULT(ic),ip->op,litVal,indIc,NULL)); + } + } + } + + /* if we have some induction variables then */ + if ( indVars ) { + eBBlock *preHdr = loopReg->entry->preHeader ; + iCode *icFirst = NULL , *icLast = NULL ; + induction *ip; + bitVect *indVect = NULL; + + /* create an iCode chain from it */ + for (ip = setFirstItem(indVars); + ip ; + ip = setNextItem(indVars)) { + + indVect = bitVectSetBit(indVect,ip->ic->key); + ip->ic->lineno = preHdr->ech->lineno; + if (!icFirst) + icFirst = ip->ic; + if (icLast) { + icLast->next = ip->ic; + ip->ic->prev = icLast; + icLast = ip->ic ; + } else + icLast = ip->ic; + change++ ; + } + + /* add the instruction chain to the end of the */ + /* preheader for this loop */ + preHdr->ech->next = icFirst ; + icFirst->prev = preHdr->ech ; + preHdr->ech = icLast; + icLast->next = NULL; + + /* add the induction variable vector to the last + block in the loop */ + lastBlock->isLastInLoop = 1; + lastBlock->linds = indVect; + } + + setToNull ((void **)&indVars); + return change ; +} + +/*-----------------------------------------------------------------*/ +/* mergeRegions - will merge region with same entry point */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(mergeRegions) +{ + region *theLoop = item; + V_ARG(set*,allRegion) ; + region *lp ; + + /* if this has already been merged then do nothing */ + if (theLoop->merged) + return 0; + + /* go thru all the region and check if any of them have the */ + /* entryPoint as the Loop */ + for (lp = setFirstItem(allRegion); lp ; lp = setNextItem(allRegion)) { + + if (lp == theLoop) + continue ; + + if (lp->entry == theLoop->entry) { + theLoop->regBlocks = unionSets (theLoop->regBlocks, + lp->regBlocks,THROW_BOTH); + lp->merged = 1; + } + } + + return 1; +} + +/*-----------------------------------------------------------------*/ +/* ifMerged - return 1 if the merge flag is 1 */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(ifMerged) +{ + region *lp = item; + + return lp->merged ; +} + +/*-----------------------------------------------------------------*/ +/* mergeInnerLoops - will merge into body when entry is present */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(mergeInnerLoops) +{ + region *theLoop = item; + V_ARG(set *,allRegion); + V_ARG(int *,maxDepth); + region *lp; + + /* check if the entry point is present in the body of any */ + /* loop then put the body of this loop into the outer loop*/ + for (lp = setFirstItem(allRegion); lp ; lp = setNextItem(allRegion)) { + + if ( lp == theLoop ) + continue ; + + if (isinSet(lp->regBlocks, theLoop->entry)) { + lp->containsLoops += theLoop->containsLoops + 1 ; + if ( lp->containsLoops > (*maxDepth)) + *maxDepth = lp->containsLoops; + + lp->regBlocks = unionSets (lp->regBlocks, + theLoop->regBlocks,THROW_DEST); + } + } + + return 1; +} + + +/*-----------------------------------------------------------------*/ +/* createLoopRegions - will detect and create a set of natural loops */ +/*-----------------------------------------------------------------*/ +hTab *createLoopRegions (eBBlock **ebbs , int count ) +{ + set *allRegion = NULL; /* set of all loops */ + hTab *orderedLoops = NULL ; + set *bEdges = NULL; + int maxDepth = 0; + region *lp; + + /* get all the back edges in the graph */ + if (! applyToSet(graphEdges,backEdges,&bEdges)) + return 0 ; /* found no loops */ + + /* for each of these back edges get the blocks that */ + /* constitute the loops */ + applyToSet(bEdges,createLoop,&allRegion); + + /* now we will create regions from these loops */ + /* loops with the same entry points are considered to be the */ + /* same loop & they are merged. If the entry point of a loop */ + /* is found in the body of another loop then , all the blocks*/ + /* in that loop are added to the loops containing the header */ + applyToSet(allRegion, mergeRegions , allRegion); + + /* delete those already merged */ + deleteItemIf (&allRegion, ifMerged); + + applyToSet(allRegion, mergeInnerLoops, allRegion, &maxDepth); + maxDepth++; + /* now create all the exits .. also */ + /* create an ordered set of loops */ + /* i.e. we process loops in the inner to outer order */ + for (lp = setFirstItem(allRegion) ; lp ; lp = setNextItem(allRegion)) { + applyToSet (lp->regBlocks,addToExitsMarkDepth, + lp->regBlocks,&lp->exits, + (maxDepth - lp->containsLoops),lp); + + hTabAddItem (&orderedLoops,lp->containsLoops,lp); + + } + return orderedLoops ; +} + +/*-----------------------------------------------------------------*/ +/* loopOptimizations - identify region & remove invariants & ind */ +/*-----------------------------------------------------------------*/ +int loopOptimizations (hTab *orderedLoops, eBBlock **ebbs, int count) +{ + region *lp ; + int change = 0 ; + int k; + + + /* if no loop optimizations requested */ + if (! optimize.loopInvariant && + ! optimize.loopInduction ) + return 0; + + /* now we process the loops inner to outer order */ + /* this is essential to maintain data flow information */ + /* the other choice is an ugly iteration for the depth */ + /* of the loops would hate that */ + for ( lp = hTabFirstItem(orderedLoops,&k); lp ; + lp = hTabNextItem(orderedLoops,&k)) { + + if (optimize.loopInvariant) + change += loopInvariants(lp, ebbs, count); + + if (optimize.loopInduction) + change += loopInduction(lp, ebbs, count); + } + + return change; +} diff --git a/src/SDCCloop.h b/src/SDCCloop.h new file mode 100644 index 00000000..dc43c91c --- /dev/null +++ b/src/SDCCloop.h @@ -0,0 +1,60 @@ +/*------------------------------------------------------------------------- + + SDCCloop.h - header file for loop detection & optimizations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "SDCCBBlock.h" +#include "SDCCcse.h" + +#ifndef SDCCLOOP_H +#define SDCCLOOP_H 1 + +typedef struct region { + + unsigned int merged:1; + eBBlock *entry ; /* entry Block */ + int containsLoops; /* contains other loops */ + set *regBlocks ; /* set of all blocks */ + set *exits ; /* set of exits */ +} region ; + +typedef struct induction { + + operand *sym ; + operand *asym; + unsigned int op ; + long cval ; + iCode *ic; +} induction ; + +DEFSETFUNC(backEdges); +DEFSETFUNC(pregion); +DEFSETFUNC(pinduction); +int loopOptimizations (hTab *, eBBlock **, int); +int addressTaken (set *,operand *); +hTab *createLoopRegions (eBBlock **, int ); +iCode *findDefInRegion (set *, operand *, eBBlock **); +int hasIncomingDefs (region *, operand *); +int findLoopEndSeq(region *); + + +#endif diff --git a/src/SDCClrange.c b/src/SDCClrange.c new file mode 100644 index 00000000..5dd93356 --- /dev/null +++ b/src/SDCClrange.c @@ -0,0 +1,523 @@ +/*------------------------------------------------------------------------- + + SDCClrange.c - source file for live range computations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCloop.h" +#include "SDCCcse.h" +#include "SDCCcflow.h" +#include "SDCCdflow.h" +#include "SDCClrange.h" + +int iCodeSeq = 0 ; +hTab *liveRanges = NULL; +hTab *iCodehTab = NULL; + +/*-----------------------------------------------------------------*/ +/* sequenceiCode - creates a sequence number for the iCode & add */ +/*-----------------------------------------------------------------*/ +void sequenceiCode (eBBlock **ebbs, int count) +{ + int i; + + for (i = 0 ; i < count ; i++ ) { + + iCode *ic; + ebbs[i]->fSeq = iCodeSeq + 1; + for ( ic = ebbs[i]->sch ; ic ; ic= ic->next) { + ic->seq = ++iCodeSeq; + ic->depth = ebbs[i]->depth; + hTabAddItem(&iCodehTab,ic->key,ic); + } + ebbs[i]->lSeq = iCodeSeq ; + } +} + +/*-----------------------------------------------------------------*/ +/* markVisited - will set the visited flag for the given Block */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(markVisited) +{ + eBBlock *ebp = item; + + if (ebp->visited) + return 0; + ebp->visited = 1; + applyToSet(ebp->succList,markVisited); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isOpAlive - checks to see if the usage in this block is the */ +/* uses the same definitions as this one */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(isOpAlive) +{ + eBBlock *ebp = item; + V_ARG(operand *,op); + V_ARG(eBBlock *,orig); + V_ARG(iCode *,ic); + + if (ebp->visited) + return 0; + + ebp->visited = 1; + + /* if we have reached the originating block */ + /* or this block has some definiton for it */ + /* then check if it is used between start & */ + /* this point */ + if ( ebp == orig || + bitVectBitsInCommon(OP_DEFS(op),ebp->defSet)) + if (usedBetweenPoints (op,ebp->sch,ic)) + return 1; + else { + applyToSet(ebp->succList,markVisited); + return 0; + } + else + /* choosing this more expensive one since + killDeadCode will take away some definitions + but there is not way right now to take away + the usage information for the corresponding + usages, this will lead to longer live ranges */ + if (usedInRemaining(op,ebp->sch)) + return 1; + + + return (applyToSet(ebp->succList,isOpAlive,op,orig,ic)); +} + +/*-----------------------------------------------------------------*/ +/* isLastUse - return TRUE if no usage of this operand after this */ +/*-----------------------------------------------------------------*/ +int isLastUse (operand *op, eBBlock *ebp, iCode *ic, + eBBlock **ebbs, int count) +{ + int i; + + /* if this is used in the remaining */ + if (usedInRemaining(op,ic)) + return 0; + + /* if not then check any of the successor blocks use it */ + for (i = 0 ; i < count ; ebbs[i++]->visited = 0); + if (applyToSet(ebp->succList,isOpAlive,op,ebp,ic)) + return 0; + + /* this is the last use */ + return 1; +} + +/*-----------------------------------------------------------------*/ +/* unionDefsUsed - unions the defsUsed in a block */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(unionDefsUsed) +{ + eBBlock *ebp = item; + V_ARG(bitVect **,bvp); + + if (ebp->visited) + return 0; + + ebp->visited = 1; + + *bvp = bitVectUnion(*bvp, ebp->usesDefs); + applyToSet(ebp->succList,unionDefsUsed,bvp); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* setFromRange - sets the from range of a given operand */ +/*-----------------------------------------------------------------*/ +void setFromRange (operand *op, int from) +{ + /* only for compiler defined temporaries */ + if (!IS_ITEMP(op)) + return ; + + hTabAddItemIfNotP (&liveRanges,op->key,OP_SYMBOL(op)); + + if (op->isaddr) + OP_SYMBOL(op)->isptr = 1; + + if (!OP_LIVEFROM(op) || + OP_LIVEFROM(op) > from) + OP_LIVEFROM(op) = from; +} + +/*-----------------------------------------------------------------*/ +/* setToRange - set the range to for an operand */ +/*-----------------------------------------------------------------*/ +void setToRange (operand *op,int to, bool check) +{ + /* only for compiler defined temps */ + if (!IS_ITEMP(op)) + return ; + + OP_SYMBOL(op)->key = op->key; + hTabAddItemIfNotP (&liveRanges,op->key,OP_SYMBOL(op)); + + if (op->isaddr) + OP_SYMBOL(op)->isptr = 1; + + if (check) + if (!OP_LIVETO(op)) + OP_LIVETO(op) = to; + else ; + else + OP_LIVETO(op) = to; +} + + +/*-----------------------------------------------------------------*/ +/* operandLUse - check and set the last use for a given operand */ +/*-----------------------------------------------------------------*/ +operand *operandLUse (operand *op, eBBlock **ebbs, + int count, iCode *ic, eBBlock *ebp) +{ + setFromRange(op,ic->seq); + if (ic->depth) + OP_SYMBOL(op)->used += (((unsigned int)1 << ic->depth) + 1); + else + OP_SYMBOL(op)->used += 1; + + if (isLastUse(op,ebp,ic->next,ebbs,count) || + (OP_LIVETO(op) && OP_LIVETO(op) < ic->seq)) { + int torange = ic->seq; + /* if this is the last use then if this block belongs + to a loop & some definition comes into the loop + then extend the live range to the end of the loop */ + if (ebp->partOfLoop && + hasIncomingDefs(ebp->partOfLoop,op)) { + torange = findLoopEndSeq(ebp->partOfLoop); + } + op = operandFromOperand(op); + setToRange(op,torange,FALSE); + } + ic->uses = bitVectSetBit(ic->uses,op->key); + + { + link *type = operandType(op); + link *etype = getSpec(type); + + /* good place to check if unintialised */ + if ((IS_TRUE_SYMOP(op) || OP_SYMBOL(op)->isreqv) && + OP_SYMBOL(op)->islocal && + !IS_AGGREGATE(type) && + !IS_FUNC(type) && + ic->op != ADDRESS_OF && + !IS_STATIC(etype) ) { + +/* if (OP_SYMBOL(op)->isreqv && !OP_SYMBOL(op)->_isparm){ */ + +/* if (SPIL_LOC(op) && */ +/* bitVectIsZero(SPIL_LOC(op)->defs)) { */ +/* OP_SYMBOL(op)->isspilt = 1; */ +/* werror(W_LOCAL_NOINIT, */ +/* SPIL_LOC(op)->name, */ +/* ic->filename,ic->lineno); */ +/* } */ +/* } else { */ + + if (bitVectIsZero(op->usesDefs)) { + OP_SYMBOL(op)->isspilt = 1; + werror(W_LOCAL_NOINIT, + OP_SYMBOL(op)->name, + ic->filename,ic->lineno); + } +/* } */ + } + } + return op; +} + +/*-----------------------------------------------------------------*/ +/* compLastUse - computes the last usage with certainty */ +/*-----------------------------------------------------------------*/ +void compLastUse () +{ + symbol *sym; + int key; + /* the strategy here is to look for live ranges that are not + induction variables, and find out the usage icode with the + highest sequence number then set the to range to that icode + sequence */ + /* once fully tested we can use only this routine to mark the + to range that will reduce a lot of computations in the + markLiveRanges routine */ + for (sym = hTabFirstItem(liveRanges,&key) ; sym; + sym = hTabNextItem(liveRanges,&key)) { + + int i ; + int maxKey = 0 ; + + if (sym->isind) + continue ; + + if (!sym->uses) + continue ; + + /* go thru all the usages of this live range and find out + the maximum sequence number of the icode that used it */ + for (i = 0 ; i < sym->uses->size ; i++ ) { + iCode *uic ; + + if (!bitVectBitValue(sym->uses,i)) + continue ; + + if ((uic = hTabItemWithKey(iCodehTab,i))) + maxKey = ( uic->seq > maxKey ? uic->seq : maxKey ); + } + + /* got it */ + if (maxKey) + sym->liveTo = maxKey; + } +} + +/*-----------------------------------------------------------------*/ +/* killAllAlive - mark all the definitions living with this seq */ +/*-----------------------------------------------------------------*/ +void killAllAlive (int seq) +{ + symbol *sym; + int k; + + for (sym = hTabFirstItem(liveRanges,&k); sym; + sym = hTabNextItem(liveRanges,&k)) + if (!sym->liveTo || (sym->liveTo < sym->liveFrom)) + sym->liveTo = seq; +} +/*-----------------------------------------------------------------*/ +/* defUsedAfterLoop - all definitions & usages before sequence num */ +/*-----------------------------------------------------------------*/ +bool defUsedAfterLoop (operand *op, int seq) +{ + int i; + iCode *ic; + + /* check for the usages first */ + if (OP_SYMBOL(op)->uses && !bitVectIsZero(OP_SYMBOL(op)->uses)) { + for (i = 0 ; i < OP_SYMBOL(op)->uses->size ; i++ ) { + + if (bitVectBitValue( OP_SYMBOL(op)->uses,i) && /* usage found */ + (ic = hTabItemWithKey(iCodehTab,i)) && /* "" */ + ic->seq > seq ) /* & is after the seq */ + return TRUE ; + } + } + + return FALSE; +} + +/*-----------------------------------------------------------------*/ +/* markLiveRanges - for each operand mark the liveFrom & liveTo */ +/*-----------------------------------------------------------------*/ +void markLiveRanges (eBBlock *ebp, eBBlock **ebbs, int count) +{ + iCode *ic; + bitVect *defsUsed = NULL; + bitVect *defsNotUsed = NULL; + int i; + /* for all the instructions */ + for (ic = ebp->sch ; ic ; ic = ic->next ) { + + if (ic->op == CALL || ic->op == PCALL) { + setFromRange(IC_RESULT(ic),ic->seq); + /* if the result has no usage then + mark this as the end of its life too + and take it away from the defs for the block*/ + if (bitVectIsZero(OP_SYMBOL(IC_RESULT(ic))->uses)) { + setToRange(IC_RESULT(ic),ic->seq,FALSE); + bitVectUnSetBit(ebp->defSet,ic->key); + } + } + + if (SKIP_IC2(ic)) + continue ; + + /* take care of the special icodes first */ + if (ic->op == JUMPTABLE && IS_SYMOP(IC_JTCOND(ic))) { + operandLUse (IC_JTCOND(ic),ebbs,count,ic,ebp); + continue; + } + + if (ic->op == IFX && IS_SYMOP(IC_COND(ic))) { + operandLUse (IC_COND(ic),ebbs,count,ic,ebp); + continue ; + } + + if (IS_SYMOP(IC_LEFT(ic))) + operandLUse (IC_LEFT(ic),ebbs,count,ic,ebp); + + if (IS_SYMOP(IC_RIGHT(ic))) + operandLUse (IC_RIGHT(ic),ebbs,count,ic,ebp); + + if (POINTER_SET(ic)) + operandLUse(IC_RESULT(ic),ebbs,count,ic,ebp); + else + if (IC_RESULT(ic)) + ic->defKey = IC_RESULT(ic)->key ; + } + + + /* for all the definitions in the block */ + /* compute and set the live from */ + if ( ebp->defSet && ! bitVectIsZero(ebp->defSet)) { + for ( i = 0 ; i < ebp->defSet->size ; i++ ) { + iCode *dic; + + if (bitVectBitValue(ebp->defSet,i) && + (dic = hTabItemWithKey(iCodehTab,i))) { + + /* if the definition has a from & it is greater */ + /* than the defininng iCode->seq then change it */ + setFromRange(IC_RESULT(dic),dic->seq); + } + } + } + + /* special case for lastBlock in a loop: here we + mark the end of all the induction variables for the + loop */ + if (ebp->isLastInLoop && !bitVectIsZero(ebp->linds)) { + for ( i = 0 ; i <= ebp->linds->size ; i++ ) { + iCode *dic; + + if (bitVectBitValue(ebp->linds,i) && + (dic = hTabItemWithKey(iCodehTab,i))) { + + /* if this is a register equvalent make sure + it is not defined or used anywhere after the loop */ + if (OP_SYMBOL(IC_RESULT(dic))->isreqv && + defUsedAfterLoop(IC_RESULT(dic), ebp->lSeq)) + continue; + + setToRange(IC_RESULT(dic),( ebp->lSeq ),FALSE); + } + } + } + + /* for defnitions coming into the block if they */ + /* not used by itself & any of its successors */ + /* they are dead */ + /* first union the definitions used in all successors + and itself */ + for (i = 0; i < count ; ebbs[i++]->visited = 0); + applyToSet(ebp->succList,unionDefsUsed,&defsUsed); + defsUsed = bitVectUnion(defsUsed,ebp->usesDefs); + + /* now subract the result of these unions from */ + /* the incoming definitions this will give the */ + /* definitions that are never used in the future */ + defsNotUsed = bitVectCplAnd(bitVectCopy(ebp->inDefs), + defsUsed); + + /* mark the end of the defintions */ + if ( !bitVectIsZero(defsNotUsed) && ebp->sch ) { + for ( i = 0 ; i < defsNotUsed->size; i++ ) { + iCode *dic; + + if (bitVectBitValue(defsNotUsed,i) && + (dic = hTabItemWithKey(iCodehTab,i))) { + + setToRange(IC_RESULT(dic),( ebp->fSeq - 1),TRUE); + } + } + } + + + /* if we reach a lock with noPath to it then kill all + the live ranges alive at this point */ +/* if (ebp->noPath || ebp->entryLabel == returnLabel) */ + if (ebp->entryLabel == returnLabel) + killAllAlive(ebp->fSeq); +} + +/*-----------------------------------------------------------------*/ +/* rlivePoint - for each point compute the ranges that are alive */ +/*-----------------------------------------------------------------*/ +void rlivePoint (eBBlock **ebbs, int count) +{ + int i; + + /* for all blocks do */ + for ( i = 0 ; i < count ; i++ ) { + iCode *ic; + + /* for all instruction in the block do */ + for ( ic = ebbs[i]->sch ; ic ; ic = ic->next ) { + symbol *lrange; + int k; + + ic->rlive = newBitVect(operandKey); + /* for all symbols in the liverange table */ + for ( lrange = hTabFirstItem(liveRanges,&k); lrange; + lrange = hTabNextItem(liveRanges,&k)) { + + if (lrange->liveFrom <= ic->seq && + lrange->liveTo >= ic->seq ) + ic->rlive = bitVectSetBit(ic->rlive,lrange->key); + } + } + } +} + + +/*-----------------------------------------------------------------*/ +/* computeLiveRanges - computes the live ranges for variables */ +/*-----------------------------------------------------------------*/ +void computeLiveRanges (eBBlock **ebbs, int count ) +{ + int i = 0 ; + /* sequence the code the live ranges are computed + in terms of this sequence additionally the + routine will also create a hashtable of instructions */ + iCodeSeq = 0 ; + setToNull((void **)&iCodehTab); + iCodehTab = newHashTable (iCodeKey); + sequenceiCode(ebbs,count); + + /* call routine to mark the from & to live ranges for + variables used */ + setToNull((void **)&liveRanges); + for ( i = 0 ; i < count; i++ ) + markLiveRanges (ebbs[i],ebbs,count); + +/* compLastUse(); */ + /* mark the ranges live for each point */ + rlivePoint (ebbs,count); +} diff --git a/src/SDCClrange.h b/src/SDCClrange.h new file mode 100644 index 00000000..7e2be396 --- /dev/null +++ b/src/SDCClrange.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + + SDCClrange.h - header file for live range computations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCCLRANGE_H +#define SDCCLRANGE_H 1 + +extern hTab *liveRanges; +extern hTab *iCodehTab ; + +void computeLiveRanges (eBBlock **, int); + +#endif diff --git a/src/SDCCmain.c b/src/SDCCmain.c new file mode 100644 index 00000000..f971cc40 --- /dev/null +++ b/src/SDCCmain.c @@ -0,0 +1,1078 @@ +/*------------------------------------------------------------------------- + SDCCmain.c - main file + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include +#include + +#include "spawn.h" +#include "SDCCglobl.h" + +extern void initSymt (); +extern void initMem (); +extern void initExpr (); +extern void initiCode (); +extern void initCSupport (); +extern void initPeepHole (); +extern void createObject (); +extern int yyparse (); +extern void glue (); +extern struct value *constVal(char *s); +extern double floatFromVal(struct value *); +extern int fatalError ; +FILE *srcFile ;/* source file */ +FILE *cdbFile = NULL ;/* debugger information output file */ +char *fullSrcFileName ;/* full name for the source file */ +char *srcFileName ;/* source file name with the .c stripped */ +char *moduleName ;/* module name is srcFilename stripped of any path */ +char *preArgv[128] ;/* pre-processor arguments */ +int preArgc = 0 ;/* pre-processor argument count */ +int currRegBank = 0 ; +struct optimize optimize ; +struct options options ; +char *VersionString = SDCC_VERSION_STR /*"Version 2.1.8a"*/; +short preProcOnly = 0; +short noAssemble = 0; +char *linkOptions[128]; +char *asmOptions[128]; +char *libFiles[128] ; +int nlibFiles = 0; +char *libPaths[128] ; +int nlibPaths = 0; +char *relFiles[128]; +int nrelFiles = 0; +//extern int wait (int *); +char *preOutName; + +#define OPTION_LARGE_MODEL "-model-large" +#define OPTION_SMALL_MODEL "-model-small" +#define OPTION_STACK_AUTO "-stack-auto" +#define OPTION_XSTACK "-xstack" +#define OPTION_GENERIC "-generic" +#define OPTION_NO_GCSE "-nogcse" +#define OPTION_NO_LOOP_INV "-noinvariant" +#define OPTION_NO_LOOP_IND "-noinduction" +#define OPTION_NO_JTBOUND "-nojtbound" +#define OPTION_NO_LOOPREV "-noloopreverse" +#define OPTION_XREGS "-regextend" +#define OPTION_COMP_ONLY "-compile-only" +#define OPTION_DUMP_RAW "-dumpraw" +#define OPTION_DUMP_GCSE "-dumpgcse" +#define OPTION_DUMP_LOOP "-dumploop" +#define OPTION_DUMP_KILL "-dumpdeadcode" +#define OPTION_DUMP_RANGE "-dumpliverange" +#define OPTION_DUMP_PACK "-dumpregpack" +#define OPTION_DUMP_RASSGN "-dumpregassign" +#define OPTION_DUMP_ALL "-dumpall" +#define OPTION_XRAM_LOC "-xram-loc" +#define OPTION_IRAM_SIZE "-iram-size" +#define OPTION_XSTACK_LOC "-xstack-loc" +#define OPTION_CODE_LOC "-code-loc" +#define OPTION_STACK_LOC "-stack-loc" +#define OPTION_DATA_LOC "-data-loc" +#define OPTION_IDATA_LOC "-idata-loc" +#define OPTION_PEEP_FILE "-peep-file" +#define OPTION_LIB_PATH "-lib-path" +#define OPTION_INTLONG_RENT "-int-long-reent" +#define OPTION_FLOAT_RENT "-float-reent" +#define OPTION_OUT_FMT_IHX "-out-fmt-ihx" +#define OPTION_OUT_FMT_S19 "-out-fmt-s19" +#define OPTION_CYCLOMATIC "-cyclomatic" +#define OPTION_NOOVERLAY "-nooverlay" +#define OPTION_MAINRETURN "-main-return" +#define OPTION_NOPEEP "-no-peep" +#define OPTION_ASMPEEP "-peep-asm" +#define OPTION_DEBUG "-debug" +#define OPTION_VERSION "-version" +#define OPTION_STKAFTRDATA "-stack-after-data" +#define OPTION_PREPROC_ONLY "-preprocessonly" +#define OPTION_HELP "-help" +#define OPTION_CALLEE_SAVES "-callee-saves" +#define OPTION_NOREGPARMS "-noregparms" +/*-----------------------------------------------------------------*/ +/* printVersionInfo - prints the version info */ +/*-----------------------------------------------------------------*/ +void printVersionInfo () +{ + + + fprintf (stderr , + "SDCC : MCU 8051 %s " +#ifdef __CYGWIN32__ + " (CYGWIN32)\n" +#else +# ifdef __DJGPP__ + " (DJGPP) \n" +# else + " (UNIX) \n" +# endif +#endif + , VersionString + ); +} + +/*-----------------------------------------------------------------*/ +/* printUsage - prints command line syntax */ +/*-----------------------------------------------------------------*/ +void printUsage () +{ + printVersionInfo (); + fprintf (stderr, + "Usage : [options] filename\n" + "Options :-\n" + "\t--model-large - Large Model\n" + "\t--model-small - Small Model (default)\n" + "\t--stack-auto - Stack automatic variables\n" + "\t--xstack - Use external stack\n" + "\t--xram-loc - External Ram start location\n" + "\t--xstack-loc - Xternal Stack Location\n" + "\t--code-loc - Code Segment Location\n" + "\t--stack-loc - Stack pointer initial value\n" + "\t--data-loc - Direct data start location\n" + "\t--idata-loc - Indirect data start location\n" + "\t--iram-size - Internal Ram size\n" + "\t--nojtbound - Don't generate boundary check for jump tables\n" + "\t--generic - All unqualified ptrs converted to '_generic'\n" + "PreProcessor Options :-\n" + "\t-Dmacro - Define Macro\n" + "\t-Ipath - Include \"*.h\" path\n" + "Note: this is a complete list of options see docs for details\n"); + exit (0); +} + +/*-----------------------------------------------------------------*/ +/* parseWithComma - separates string with comma */ +/*-----------------------------------------------------------------*/ +void parseWithComma (char **dest,char *src) +{ + int i = 0; + + strtok(src,"\n \t"); + /* skip the initial white spaces */ + while (isspace(*src)) src++; + dest[i++] = src; + while (*src) { + if (*src == ',') { + *src = '\0'; + src++; + if (*src) + dest[i++] = src; + continue ; + } + src++; + } +} + +/*-----------------------------------------------------------------*/ +/* setDefaultOptions - sets the default options */ +/*-----------------------------------------------------------------*/ +static void setDefaultOptions() +{ + int i ; + + for ( i = 0 ; i < 128 ; i++) + preArgv[i] = linkOptions [i] = + asmOptions[i] = relFiles[i] = libFiles[i] = + libPaths[i] = NULL ; + preArgv[preArgc++] = "-version"; + preArgv[preArgc++] = "-Wall"; + preArgv[preArgc++] = "-lang-c++"; + preArgv[preArgc++] = "-DSDCC=1"; + preArgv[preArgc++] = "-I" SDCC_INCLUDE_DIR ; + + /* first the options part */ + options.stack_loc = 0; /* stack pointer initialised to 0 */ + options.xstack_loc= 0; /* xternal stack starts at 0 */ + options.code_loc = 0; /* code starts at 0 */ + options.data_loc = 0x0030; /* data starts at 0x0030 */ + options.xdata_loc = 0; + options.idata_loc = 0x80; + options.genericPtr = 1; /* default on */ + options.nopeep = 0; + + /* now for the optimizations */ + /* turn on the everything */ + optimize.global_cse = 1; + optimize.label1 = 1; + optimize.label2 = 1; + optimize.label3 = 1; + optimize.label4 = 1; + optimize.loopInvariant = 1; + optimize.loopInduction = 1; +} + +/*-----------------------------------------------------------------*/ +/* processFile - determines the type of file from the extension */ +/*-----------------------------------------------------------------*/ +static void processFile (char *s) +{ + char *fext = NULL; + + /* get the file extension */ + fext = s + strlen(s); + while ((fext != s) && *fext != '.') fext--; + + /* now if no '.' then we don't know what the file type is + so give a warning and return */ + if (fext == s) { + werror(W_UNKNOWN_FEXT,s); + return ; + } + + /* otherwise depending on the file type */ + if (strcmp(fext,".c") == 0 || strcmp(fext,".C") == 0) { + /* source file name : not if we already have a + source file */ + if (srcFileName) { + werror(W_TOO_MANY_SRC,s); + return ; + } + + /* the only source file */ + if (!(srcFile = fopen((fullSrcFileName = s),"r"))) { + werror(E_FILE_OPEN_ERR,s); + exit (1); + } + + /* copy the file name into the buffer */ + strcpy(buffer,s); + + /* get rid of the "." */ + strtok(buffer,"."); + ALLOC_ATOMIC(srcFileName,strlen(buffer)+1); + strcpy(srcFileName,buffer); + + /* get rid of any path information + for the module name; do this by going + backwards till we get to either '/' or '\' or ':' + or start of buffer */ + fext = buffer + strlen(buffer); + while (fext != buffer && + *(fext -1) != '\\' && + *(fext-1) != '/' && + *(fext-1) != ':') + fext--; + ALLOC_ATOMIC(moduleName,strlen(fext)+1); + strcpy(moduleName,fext); + + return ; + } + + /* if the extention is type .rel or .r or .REL or .R + addtional object file will be passed to the linker */ + if (strcmp(fext,".r") == 0 || strcmp(fext,".rel") == 0 || + strcmp(fext,".R") == 0 || strcmp(fext,".REL") == 0) { + + relFiles[nrelFiles++] = s; + return ; + } + + /* if .lib or .LIB */ + if (strcmp(fext,".lib") == 0 || strcmp(fext,".LIB") == 0) { + libFiles[nlibFiles++] = s; + return; + } + + werror(W_UNKNOWN_FEXT,s); + +} + + +/*-----------------------------------------------------------------*/ +/* parseCmdLine - parses the command line and sets the options */ +/*-----------------------------------------------------------------*/ +int parseCmdLine ( int argc, char **argv ) +{ + int i ; + char cdbfnbuf[50]; + + /* go thru all whole command line */ + for ( i = 1; i < argc; i++ ) { + if ( i >= argc ) + break ; + + /* options */ + if (argv[i][0] == '-' && argv[i][1] == '-') { + + if (strcmp(&argv[i][1],OPTION_HELP) == 0) { + printUsage(); + exit(0); + } + + if (strcmp(&argv[i][1],OPTION_XREGS) == 0) { + options.regExtend = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_LARGE_MODEL) == 0) { + options.model = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_SMALL_MODEL) == 0) { + options.model = 0; + continue; + } + + if (strcmp(&argv[i][1],OPTION_STACK_AUTO) == 0) { + options.stackAuto = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DUMP_RAW) == 0) { + options.dump_raw = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_CYCLOMATIC) == 0) { + options.cyclomatic = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DUMP_GCSE) == 0) { + options.dump_gcse = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DUMP_LOOP) == 0) { + options.dump_loop = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DUMP_KILL) == 0) { + options.dump_kill = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_INTLONG_RENT) == 0) { + options.intlong_rent = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_FLOAT_RENT) == 0) { + options.float_rent = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DUMP_RANGE) == 0) { + options.dump_range = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DUMP_PACK) == 0) { + options.dump_pack = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DUMP_RASSGN) == 0) { + options.dump_rassgn = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_OUT_FMT_IHX) == 0) { + options.out_fmt = 0; + continue; + } + + if (strcmp(&argv[i][1],OPTION_OUT_FMT_S19) == 0) { + options.out_fmt = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NOOVERLAY) == 0) { + options.noOverlay = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_STKAFTRDATA) == 0) { + options.stackOnData = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_PREPROC_ONLY) == 0) { + preProcOnly = 1; + continue; + } + + + if (strcmp(&argv[i][1],OPTION_DUMP_ALL) == 0) { + options.dump_rassgn = + options.dump_pack = + options.dump_range = + options.dump_kill = + options.dump_loop = + options.dump_gcse = + options.dump_raw = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_COMP_ONLY) == 0) { + options.cc_only = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_GENERIC) == 0) { + options.genericPtr = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NOPEEP) == 0) { + options.nopeep = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_ASMPEEP) == 0) { + options.asmpeep = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_DEBUG) == 0) { + options.debug = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NOREGPARMS) == 0) { + options.noregparms = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_PEEP_FILE) == 0) { + if (argv[i][1+strlen(OPTION_PEEP_FILE)]) + options.peep_file = + &argv[i][1+strlen(OPTION_PEEP_FILE)]; + else + options.peep_file = argv[++i]; + continue ; + } + + if (strcmp(&argv[i][1],OPTION_LIB_PATH) == 0) { + if (argv[i][1+strlen(OPTION_LIB_PATH)]) + libPaths[nlibPaths++] = + &argv[i][1+strlen(OPTION_PEEP_FILE)]; + else + libPaths[nlibPaths++] = argv[++i]; + continue ; + } + + if (strcmp(&argv[i][1],OPTION_XSTACK_LOC) == 0) { + + if (argv[i][1+strlen(OPTION_XSTACK_LOC)]) + options.xstack_loc = + (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_XSTACK_LOC)])); + else + options.xstack_loc = + (int) floatFromVal(constVal(argv[++i])); + continue ; + } + + if (strcmp(&argv[i][1],OPTION_XSTACK) == 0) { + options.useXstack = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_MAINRETURN) == 0) { + options.mainreturn = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_CALLEE_SAVES) == 0) { + if (argv[i][1+strlen(OPTION_CALLEE_SAVES)]) + parseWithComma(options.calleeSaves + ,&argv[i][1+strlen(OPTION_CALLEE_SAVES)]); + else + parseWithComma(options.calleeSaves,argv[++i]); + continue; + } + + if (strcmp(&argv[i][1],OPTION_STACK_LOC) == 0) { + + if (argv[i][1+strlen(OPTION_STACK_LOC)]) + options.stack_loc = + (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_STACK_LOC)])); + else + options.stack_loc = + (int) floatFromVal(constVal(argv[++i])); + continue; + } + + if (strcmp(&argv[i][1],OPTION_XRAM_LOC) == 0) { + + if (argv[i][1+strlen(OPTION_XRAM_LOC)]) + options.xdata_loc = + (unsigned int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_XRAM_LOC)])); + else + options.xdata_loc = + (unsigned int) floatFromVal(constVal(argv[++i])); + continue; + } + + if (strcmp(&argv[i][1],OPTION_IRAM_SIZE) == 0) { + + if (argv[i][1+strlen(OPTION_IRAM_SIZE)]) + options.iram_size = + (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_IRAM_SIZE)])); + else + options.iram_size = + (int) floatFromVal(constVal(argv[++i])); + continue; + } + + if (strcmp(&argv[i][1],OPTION_VERSION) == 0) { + printVersionInfo(); + exit(0); + continue; + } + + if (strcmp(&argv[i][1],OPTION_DATA_LOC) == 0) { + + if (argv[i][1+strlen(OPTION_DATA_LOC)]) + options.data_loc = + (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_DATA_LOC)])); + else + options.data_loc = + (int) floatFromVal(constVal(argv[++i])); + continue; + } + + if (strcmp(&argv[i][1],OPTION_IDATA_LOC) == 0) { + + if (argv[i][1+strlen(OPTION_IDATA_LOC)]) + options.idata_loc = + (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_IDATA_LOC)])); + else + options.idata_loc = + (int) floatFromVal(constVal(argv[++i])); + continue; + } + + if (strcmp(&argv[i][1],OPTION_CODE_LOC) == 0) { + + if (argv[i][1+strlen(OPTION_CODE_LOC)]) + options.code_loc = + (int) floatFromVal(constVal(&argv[i][1+strlen(OPTION_CODE_LOC)])); + else + options.code_loc = + (int) floatFromVal(constVal(argv[++i])); + continue; + } + + + if (strcmp(&argv[i][1],OPTION_NO_JTBOUND) == 0) { + optimize.noJTabBoundary = 1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NO_GCSE) == 0) { + optimize.global_cse = 0; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NO_LOOP_INV) == 0) { + optimize.loopInvariant = 0; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NO_LOOP_IND) == 0) { + optimize.loopInduction = 0; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NO_LOOPREV) == 0) { + optimize.noLoopReverse = 1; + continue; + } + + werror(W_UNKNOWN_OPTION,argv[i]); + } + + /* these are undocumented options */ + /* if preceded by '/' then turn off certain optmizations, used + for debugging only these are also the legacy options from + version 1.xx will be removed gradually */ + if ( *argv[i] == '/') { + switch (argv[i][1]) { + + case 'p': + optimize.ptrArithmetic=0; + break; + + case 'L': + switch (argv[i][2]) { + case '\0': + optimize.label1 = + optimize.label2 = + optimize.label3 = + optimize.label4 = 0 ; + break; + case '1': + optimize.label1 = 0; + break; + case '2': + optimize.label2 = 0; + break; + case '3': + optimize.label3 = 0; + break; + case '4': + optimize.label4 = 0; + break; + } + break; + + case 'l' : + switch (argv[i][2]) { + case 'i' : + optimize.loopInvariant = 0; + break; + case 'n' : + optimize.loopInduction = 0; + break; + + + } + break ; + case 'g' : + optimize.global_cse = 0; + break; + + } + continue ; + } + + /* if preceded by '-' then option */ + if ( *argv[i] == '-' ) { + switch (argv[i][1]) { + case 'h' : + printUsage(); + exit(0); + break; + + case 'E': + preProcOnly = 1; + break; + + case 'm': + werror(W_UNSUPP_OPTION,"-mL/-mS","use --model-large/--model-small instead"); + break; + + case 'a' : + werror(W_UNSUPP_OPTION,"-a","use --stack-auto instead"); + break ; + + case 'g' : + werror(W_UNSUPP_OPTION,"-g","use --generic instead"); + break; + + case 'X' : /* use external stack */ + werror(W_UNSUPP_OPTION,"-X","use --xstack-loc instead"); + break ; + + case 'x' : + werror(W_UNSUPP_OPTION,"-x","use --xstack instead"); + break; + + case 'p' : /* stack pointer intial value */ + case 'P' : + werror(W_UNSUPP_OPTION,"-p","use --stack-loc instead"); + break ; + + case 'i' : + werror(W_UNSUPP_OPTION,"-i","use --idata-loc instead"); + break ; + + case 'r' : + werror(W_UNSUPP_OPTION,"-r","use --xdata-loc instead"); + break ; + + case 's' : + werror(W_UNSUPP_OPTION,"-s","use --code-loc instead"); + break ; + + case 'c': + options.cc_only = 1; + break; + + case 'Y': + werror(W_UNSUPP_OPTION,"-Y","use -I instead"); + break; + + case 'L' : + if (argv[i][2]) + libPaths[nlibPaths++] = &argv[i][2]; + else + libPaths[nlibPaths++] = argv[++i]; + break; + + case 'W': + /* linker options */ + if (argv[i][2] == 'l') { + if (argv[i][3]) + parseWithComma(linkOptions,&argv[i][3]); + else + parseWithComma(linkOptions,argv[++i]); + } else { + /* assembler options */ + if (argv[i][2] == 'a') { + if (argv[i][3]) + parseWithComma(asmOptions,&argv[i][3]); + else + parseWithComma(asmOptions,argv[++i]); + + } else { + werror(W_UNKNOWN_OPTION,argv[i]); + } + } + break; + case 'S': + noAssemble = 1; + break; + + case 'v': + printVersionInfo(); + exit(0); + break; + + /* preprocessor options */ + case 'd': + case 'D': + case 'I': + case 'M': + case 'C': + case 'A': + case 'U': + { + char sOpt = argv[i][1] ; + char *rest ; + + if ( argv[i][2] == ' ' || argv[i][2] == '\0') { + i++ ; + rest = argv[i] ; + } + else + rest = &argv[i][2] ; + + /* increase allocation for preprocessor argv + if (!(preArgv = realloc(preArgv,(preArgc+1)*sizeof(char **)))) { + werror (E_OUT_OF_MEM); + exit (1); + } */ + if ( argv[i][1] == 'Y' ) + argv[i][1] = 'I'; + if (argv[i][1] == 'M') + preProcOnly = 1; + + if (!(preArgv[preArgc] = GC_malloc(strlen(rest)+3))) { + werror(E_OUT_OF_MEM,__FILE__,strlen(rest)+3); + exit (1); + } + + sprintf(preArgv[preArgc],"-%c%s",sOpt,rest); + preArgc++ ; + } + break ; + + default: + werror(W_UNKNOWN_OPTION,argv[i]); + } + continue ; + } + + /* no option must be a filename */ + processFile(argv[i]); + + + } + + /* set up external stack location if not explicitly specified */ + if ( !options.xstack_loc ) + options.xstack_loc = options.xdata_loc ; + + /* if debug option is set the open the cdbFile */ + if (/* options.debug && */ srcFileName) { + sprintf(cdbfnbuf,"%s.cdb",srcFileName); + if ((cdbFile = fopen(cdbfnbuf,"w")) == NULL) + werror(E_FILE_OPEN_ERR,cdbfnbuf); + else { + /* add a module record */ + fprintf(cdbFile,"M:%s\n",moduleName); + } + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* my_system - will call a program with arguments */ +/*-----------------------------------------------------------------*/ +char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL}; +int my_system (const char *cmd, char **cmd_argv) +{ + + char *dir, *got= NULL; int i= 0; + while (!got && try_dir[i]) { + dir= (char*)malloc(strlen(try_dir[i])+strlen(cmd)+10); + strcpy(dir, try_dir[i]); strcat(dir, "/"); strcat(dir, cmd); + if (access(dir, X_OK) == 0) + got= strdup(dir); + free(dir); + i++; + } + if (got) + i= spawnv(P_WAIT,got,cmd_argv) == -1; + else + i= spawnvp(P_WAIT,cmd,cmd_argv) == -1; + if (i) { + perror("Cannot exec process "); + return -1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* linkEdit : - calls the linkage editor with options */ +/*-----------------------------------------------------------------*/ +static void linkEdit (char **envp) +{ + FILE *lnkfile ; + char *lnkArgs[4]; + int i; + if (!srcFileName) + srcFileName = "temp"; + + /* first we need to create the .lnk file */ + sprintf(buffer,"%s.lnk",srcFileName); + if (!(lnkfile = fopen(buffer,"w"))) { + werror(E_FILE_OPEN_ERR,buffer); + exit(1); + } + + /* now write the options */ + fprintf(lnkfile,"-mux%c\n", (options.out_fmt ? 's' : 'i')); + + /* if iram size specified */ + if (options.iram_size) + fprintf(lnkfile,"-a 0x%04x\n",options.iram_size); + + /*if (options.debug) */ + fprintf(lnkfile,"-z\n"); + /* code segment start */ + fprintf (lnkfile,"-b CODE = 0x%04x\n",options.code_loc); + /* data segment start */ + fprintf (lnkfile,"-b DSEG = 0x%04x\n",options.data_loc); + /* xdata start */ + fprintf (lnkfile,"-b XSEG = 0x%04x\n",options.xdata_loc); + /* indirect data */ + fprintf (lnkfile,"-b ISEG = 0x%04x\n",options.idata_loc); + /* bit segment start */ + fprintf (lnkfile,"-b BSEG = 0x%04x\n",0); + + /* add the extra linker options */ + for (i=0; linkOptions[i] ; i++) + fprintf(lnkfile,"%s\n",linkOptions[i]); + + /* standard library path */ + fprintf (lnkfile,"-k %s/%s\n",SDCC_LIB_DIR/*STD_LIB_PATH*/, + ( (options.model==0) ? "small": "large")); + + /* other library paths if specified */ + for (i = 0 ; i < nlibPaths ; i++ ) + fprintf (lnkfile,"-k %s\n",libPaths[i]); + + /* standard library files */ + fprintf (lnkfile,"-l %s\n",STD_LIB); + fprintf (lnkfile,"-l %s\n",STD_INT_LIB); + fprintf (lnkfile,"-l %s\n",STD_LONG_LIB); + fprintf (lnkfile,"-l %s\n",STD_FP_LIB); + + /* additional libraries if any */ + for (i = 0 ; i < nlibFiles; i++) + fprintf (lnkfile,"-l %s\n",libFiles[i]); + + /* put in the object files */ + if (strcmp(srcFileName,"temp")) + fprintf (lnkfile,"%s ",srcFileName); + + for (i = 0 ; i < nrelFiles ; i++ ) + fprintf (lnkfile,"%s\n",relFiles[i]); + + fprintf (lnkfile,"\n-e\n"); + fclose(lnkfile); + + /* call the linker */ + lnkArgs[0] = "aslink"; + lnkArgs[1] = "-nf"; + lnkArgs[2] = srcFileName; + lnkArgs[3] = NULL; + + if (my_system("aslink",lnkArgs)) { + perror("Cannot exec linker"); + exit(1); + } + + if (strcmp(srcFileName,"temp") == 0) { + /* rename "temp.cdb" to "firstRelFile.cdb" */ + char *f = strtok(strdup(relFiles[0]),"."); + f = strcat(f,".cdb"); + rename("temp.cdb",f); + srcFileName = NULL; + } +} + +/*-----------------------------------------------------------------*/ +/* assemble - spawns the assembler with arguments */ +/*-----------------------------------------------------------------*/ +static void assemble (char **envp) +{ + char *asmArgs[128]; /* assembler arguments */ + int i = 2; + + asmArgs[0] = "asx8051"; + +/* if (options.debug) */ + asmArgs[1] = "-plosgffc" ; +/* else */ +/* asmArgs[1] = "-plosgff"; */ + + /* add the extra options if any */ + for (; asmOptions[i-2] ; i++) + asmArgs[i] = asmOptions[i-2]; + + /* create the assembler file name */ + sprintf (buffer, srcFileName); + strcat (buffer, ".asm"); + asmArgs[i++] = buffer; + + asmArgs[i] = 0; /* end of args */ + + if (my_system("asx8051",asmArgs)) { + perror("Cannot exec linker"); + exit(1); + } +} + + +/*-----------------------------------------------------------------*/ +/* preProcess - spawns the preprocessor with arguments */ +/*-----------------------------------------------------------------*/ +static int preProcess (char **envp) +{ + + /* if using external stack define the macro */ + if ( options.useXstack ) + preArgv[preArgc++] = "-DSDCC_USE_XSTACK" ; + + /* set the macro for stack autos */ + if ( options.stackAuto ) + preArgv[preArgc++] = "-DSDCC_STACK_AUTO"; + + /* set the macro for large model */ + if ( options.model ) + preArgv[preArgc++] = "-DSDCC_MODEL_LARGE" ; + else + preArgv[preArgc++] = "-DSDCC_MODEL_SMALL" ; + + preArgv[preArgc++] = fullSrcFileName ; + if (!preProcOnly) + preArgv[preArgc++] = preOutName = strdup(tmpnam(NULL)); + preArgv[preArgc] = NULL; + + preArgv[0] = "sdcpp"; + + if (my_system("sdcpp",preArgv)) { + unlink (preOutName); + perror("Cannot exec Preprocessor"); + exit(1); + } + + if (preProcOnly) + exit(0); + + yyin = fopen(preOutName,"r"); + if (yyin == NULL) { + perror("Preproc file not found\n"); + exit(1); + } + + return 0; +} + +/* + * main routine + * initialises and calls the parser + */ + +int main ( int argc, char **argv , char **envp) +{ + /* turn all optimizations off by default */ + memset(&optimize,0,sizeof(struct optimize)); + + /*printVersionInfo ();*/ + + setDefaultOptions(); + parseCmdLine (argc,argv); + + /* if no input then printUsage & exit */ + if (!srcFileName && !nrelFiles) { + printUsage(); + exit(0); + } + + if (srcFileName) + preProcess(envp) ; + + if (srcFileName) { + + initSymt(); + initMem(); + initiCode(); + initCSupport (); + initPeepHole(); + yyparse(); + + if (!fatalError) { + glue(); + assemble(envp); + } + + } + + if (cdbFile) + fclose(cdbFile); + + if (!options.cc_only && + !fatalError && + !noAssemble && + (srcFileName || nrelFiles)) + linkEdit (envp); + + if (yyin && yyin != stdin) + fclose(yyin); + + if (preOutName) { + unlink(preOutName); + free(preOutName); + } + return 0; + +} diff --git a/src/SDCCmem.c b/src/SDCCmem.c new file mode 100644 index 00000000..df35a568 --- /dev/null +++ b/src/SDCCmem.c @@ -0,0 +1,776 @@ +/*-----------------------------------------------------------------*/ +/* SDCCmem.c - 8051 memory management routines */ +/*-----------------------------------------------------------------*/ + +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCCmem.h" +#include "SDCCval.h" +#include "SDCCast.h" +#include "SDCChasht.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCCopt.h" + +/* memory segments */ +memmap *xstack= NULL ; /* xternal stack data */ +memmap *istack= NULL; /* internal stack */ +memmap *code = NULL; /* code segment */ +memmap *data = NULL; /* internal data upto 128 */ +memmap *xdata = NULL; /* external data */ +memmap *idata = NULL; /* internal data upto 256 */ +memmap *bit = NULL; /* bit addressable space */ +memmap *statsg= NULL; /* the constant data segment */ +memmap *sfr = NULL; /* register space */ +memmap *reg = NULL; /* register space */ +memmap *sfrbit= NULL; /* sfr bit space */ +memmap *generic=NULL; /* is a generic pointer */ +memmap *overlay=NULL; /* overlay segment */ + +/* this is a set of sets each set containing + symbols in a single overlay */ +set *ovrSetSets = NULL; + +extern set *operKeyReset ; +extern set *tmpfileSet ; +extern symbol *interrupts[]; +int maxRegBank = 0; +int fatalError = 0 ;/* fatal error flag */ + +/*-----------------------------------------------------------------*/ +/* allocMap - allocates a memory map */ +/*-----------------------------------------------------------------*/ +memmap *allocMap (char rspace, /* sfr space */ + char farmap, /* far or near segment */ + char paged , /* can this segment be paged */ + char direct, /* directly addressable */ + char bitaddr, /* bit addressable space*/ + char codemap, /* this is code space */ + unsigned sloc, /* starting location */ + char *name, /* 2 character name */ + char dbName + ) +{ + memmap *map ; + + if (!(map = GC_malloc(sizeof(memmap)))) { + werror(E_OUT_OF_MEM,__FILE__,sizeof(memmap)); + exit (1); + } + + memset(map, ZERO, sizeof(memmap)); + map->regsp = rspace ; + map->fmap = farmap ; + map->paged = paged ; + map->direct = direct ; + map->bitsp = bitaddr ; + map->codesp = codemap ; + map->sloc = sloc ; + map->sname = name ; + map->dbName = dbName ; + if (!(map->oFile = tmpfile())) { + werror(E_TMPFILE_FAILED); + exit (1); + } + addSetHead (&tmpfileSet,map->oFile); + map->syms = NULL ; + return map; +} + +/*-----------------------------------------------------------------*/ +/* initMem - allocates and initializes all the segments */ +/*-----------------------------------------------------------------*/ +void initMem () +{ + + /* allocate all the segments */ + /* xternal stack segment ; + SFRSPACE - NO + FAR-SPACE - YES + PAGED - YES + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACESS - NO */ + xstack = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, XSTACK_NAME,'A'); + + /* internal stack segment ; + SFRSPACE - NO + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACESS - NO */ + istack = allocMap (0, 0, 0, 0, 0, 0,options.stack_loc, ISTACK_NAME,'B'); + + /* code segment ; + SFRSPACE - NO + FAR-SPACE - YES + PAGED - NO + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACESS - YES */ + code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME,'C'); + + /* Static segment (code for variables ); + SFRSPACE - NO + FAR-SPACE - YES + PAGED - NO + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACESS - YES */ + statsg = allocMap (0, 1, 0, 0, 0, 1,0, STATIC_NAME,'D'); + + /* Data segment - internal storage segment ; + SFRSPACE - NO + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - YES + BIT-ACCESS - NO + CODE-ACESS - NO */ + data = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME,'E'); + + /* overlay segment - same as internal storage segment ; + SFRSPACE - NO + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - YES + BIT-ACCESS - NO + CODE-ACESS - NO */ + overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME,'E'); + + /* Xternal Data segment - + SFRSPACE - NO + FAR-SPACE - YES + PAGED - NO + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACESS - NO */ + xdata = allocMap (0, 1, 0, 0, 0, 0, options.xdata_loc, XDATA_NAME,'F' ); + + /* Inderectly addressed internal data segment + SFRSPACE - NO + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACESS - NO */ + idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc,IDATA_NAME,'G' ); + + /* Static segment (code for variables ); + SFRSPACE - NO + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - YES + BIT-ACCESS - YES + CODE-ACESS - NO */ + bit = allocMap (0, 0, 0, 1, 1, 0,0, BIT_NAME,'H'); + + /* Special function register space :- + SFRSPACE - YES + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - YES + BIT-ACCESS - NO + CODE-ACESS - NO */ + sfr = allocMap (1,0, 0, 1, 0, 0,0, REG_NAME,'I'); + + /* Register space ; + SFRSPACE - YES + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - NO + BIT-ACCESS - NO + CODE-ACESS - NO */ + reg = allocMap (1,0, 0, 0, 0, 0, 0,REG_NAME,' '); + + /* SFR bit space + SFRSPACE - YES + FAR-SPACE - NO + PAGED - NO + DIRECT-ACCESS - YES + BIT-ACCESS - YES + CODE-ACESS - NO */ + sfrbit = allocMap (1,0, 0, 1, 1, 0,0, REG_NAME,'J' ); + + /* the unknown map */ + generic = allocMap (1,0, 0, 1, 1, 0,0, REG_NAME,' ' ); + +} + +/*-----------------------------------------------------------------*/ +/* allocIntoSeg - puts a symbol into a memory segment */ +/*-----------------------------------------------------------------*/ +void allocIntoSeg (symbol *sym) +{ + memmap *segment = SPEC_OCLS(sym->etype); + + addSet (&segment->syms,sym); +} + +/*-----------------------------------------------------------------*/ +/* allocGlobal - aassigns the output segment to a global var */ +/*-----------------------------------------------------------------*/ +void allocGlobal ( symbol *sym ) +{ + /* symbol name is internal name */ + sprintf (sym->rname,"_%s",sym->name); + + /* add it to the operandKey reset */ + addSet(&operKeyReset,sym); + + /* if this is a literal e.g. enumerated type */ + /* put it in the data segment & do nothing */ + if (IS_LITERAL(sym->etype)) { + SPEC_OCLS(sym->etype) = data ; + return ; + } + + /* if this is a function then assign code space */ + if (IS_FUNC(sym->type)) { + SPEC_OCLS(sym->etype) = code ; + /* if this is an interrupt service routine + then put it in the interrupt service array */ + if (IS_ISR(sym->etype)) { + + if (interrupts[SPEC_INTN(sym->etype)]) + werror(E_INT_DEFINED, + SPEC_INTN(sym->etype), + interrupts[SPEC_INTN(sym->etype)]->name); + else + interrupts[SPEC_INTN(sym->etype)] = sym; + + /* automagically extend the maximum interrupts */ + if (SPEC_INTN(sym->etype) >= maxInterrupts ) + maxInterrupts = SPEC_INTN(sym->etype) + 1; + } + /* if it is not compiler defined */ + if (!sym->cdef) + allocIntoSeg(sym); + + return ; + } + + /* if this is a SFR or SBIT */ + if ( SPEC_SCLS(sym->etype) == S_SFR || + SPEC_SCLS(sym->etype) == S_SBIT ) { + + /* if both absolute address & initial */ + /* value specified then error */ + if ( IS_ABSOLUTE (sym->etype) && sym->ival ) { + werror(E_SFR_INIT,sym->name); + sym->ival = NULL ; + } + + SPEC_OCLS(sym->etype) = + (SPEC_SCLS(sym->etype) == S_SFR ? sfr : sfrbit); + + allocIntoSeg (sym); + return ; + } + + /* if this is a bit variable and no storage class */ + if ( SPEC_NOUN(sym->etype) == V_BIT + && SPEC_SCLS(sym->etype) == S_BIT ) { + SPEC_OCLS(sym->etype) = bit ; + allocIntoSeg (sym); + return ; + } + + /* if bit storage class */ + if ( SPEC_SCLS(sym->etype) == S_SBIT ) { + SPEC_OCLS(sym->etype) = bit; + allocIntoSeg(sym); + return ; + } + + /* register storage class ignored changed to FIXED */ + if ( SPEC_SCLS(sym->etype) == S_REGISTER ) + SPEC_SCLS(sym->etype) = S_FIXED ; + + /* if data specified then */ + if (SPEC_SCLS(sym->etype) == S_DATA) { + /* set the output class */ + SPEC_OCLS(sym->etype) = data ; + /* generate the symbol */ + allocIntoSeg (sym) ; + return ; + } + + /* if it is fixed, then allocate depending on the */ + /* current memory model,same for automatics */ + if ( SPEC_SCLS(sym->etype) == S_FIXED || + SPEC_SCLS(sym->etype) == S_AUTO ) { + /* set the output class */ + SPEC_OCLS(sym->etype) = ( options.model ? xdata : data ) ; + /* generate the symbol */ + allocIntoSeg (sym) ; + return ; + } + + /* if code change to constant */ + if ( SPEC_SCLS(sym->etype) == S_CODE || + SPEC_SCLS(sym->etype) == S_CONSTANT ) { + SPEC_OCLS(sym->etype) = statsg ; + allocIntoSeg (sym) ; + return ; + } + + if ( SPEC_SCLS(sym->etype) == S_XDATA ) { + SPEC_OCLS(sym->etype) = xdata ; + allocIntoSeg(sym) ; + return ; + } + + if ( SPEC_SCLS(sym->etype) == S_IDATA ) { + SPEC_OCLS(sym->etype) = idata ; + sym->iaccess = 1; + allocIntoSeg (sym) ; + return ; + } + + return ; +} + +/*-----------------------------------------------------------------*/ +/* allocParms - parameters are always passed on stack */ +/*-----------------------------------------------------------------*/ +void allocParms ( value *val ) +{ + value *lval ; + int pNum = 1; + + for ( lval = val ; lval ; lval = lval->next, pNum++ ) { + + /* if this is a literal e.g. enumerated type */ + if (IS_LITERAL(lval->etype)) { + SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = + ( options.model ? xdata : data ); + continue; + } + /* if this a register parm then allocate + it as a local variable by adding it + to the first block we see in the body */ + if (IS_REGPARM(lval->etype)) + continue ; + + /* check the declaration */ + checkDecl (lval->sym); + + /* mark it as my parameter */ + lval->sym->ismyparm = 1; + lval->sym->localof = currFunc; + + + /* if automatic variables r 2b stacked */ + if ( options.stackAuto || IS_RENT(currFunc->etype)) { + + if (lval->sym) + lval->sym->onStack = 1; + + /* choose which stack 2 use */ + /* use xternal stack */ + if ( options.useXstack ) { + SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = xstack ; + SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack = + xstackPtr - getSize(lval->type); + xstackPtr -= getSize (lval->type); + } + else { /* use internal stack */ + SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = istack ; + SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack = + stackPtr - ( SPEC_BANK(currFunc->etype) ? 1 : 0) - + getSize(lval->type) - + (IS_ISR(currFunc->etype) ? 4 : 0); + stackPtr -= getSize (lval->type); + } + allocIntoSeg(lval->sym); + } + else { /* allocate them in the automatic space */ + /* generate a unique name */ + sprintf (lval->sym->rname,"_%s_PARM_%d",currFunc->name,pNum); + strcpy (lval->name,lval->sym->rname); + + /* if declared in external storage */ + if (SPEC_SCLS(lval->etype) == S_XDATA) + SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = xdata; + else + /* other wise depending on the memory model + note here that we put it into the overlay segment + first, we will remove it from the overlay segment + after the overlay determination has been done */ + SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = + ( options.model ? xdata : (options.noOverlay ? data :overlay )); + + allocIntoSeg(lval->sym); + } + } + + return ; +} + +/*-----------------------------------------------------------------*/ +/* deallocParms - parameters are always passed on stack */ +/*-----------------------------------------------------------------*/ +void deallocParms ( value *val ) +{ + value *lval ; + + for ( lval = val ; lval ; lval = lval->next ) { + + /* unmark is myparm */ + lval->sym->ismyparm = 0; + /* if on stack then depending on which stack */ + + /* delete it from the symbol table */ + deleteSym (SymbolTab,lval->sym,lval->sym->name); + + if (!lval->sym->isref) { + lval->sym->allocreq = 1; + werror(W_NO_REFERENCE,currFunc->name, + "function argument",lval->sym->name); + } + + /* move the rname if any to the name for both val & sym */ + /* and leave a copy of it in the symbol table */ + if (lval->sym->rname[0]) { + char buffer[SDCC_NAME_MAX]; + strcpy(buffer,lval->sym->rname); + lval->sym = copySymbol(lval->sym); + strcpy(lval->sym->rname,buffer); + strcpy(lval->name,strcpy(lval->sym->name,lval->sym->rname)); + addSym (SymbolTab, lval->sym, lval->sym->name, + lval->sym->level,lval->sym->block); + lval->sym->_isparm = 1; + addSet(&operKeyReset,lval->sym); + } + + } + + return ; +} + +/*-----------------------------------------------------------------*/ +/* allocLocal - allocate local variables */ +/*-----------------------------------------------------------------*/ +void allocLocal ( symbol *sym ) +{ + + /* generate an unique name */ + sprintf(sym->rname,"_%s_%s_%d_%d", + currFunc->name,sym->name,sym->level,sym->block); + + sym->islocal = 1; + sym->localof = currFunc; + + /* if this is a static variable */ + if ( IS_STATIC (sym->etype)) { + SPEC_OCLS(sym->etype) = (options.model ? xdata : data ); + allocIntoSeg (sym); + sym->allocreq = 1; + return ; + } + + /* if volatile then */ + if (IS_VOLATILE(sym->etype)) + sym->allocreq = 1; + + /* this is automatic */ + + /* if it to be placed on the stack */ + if ( options.stackAuto || reentrant) { + + sym->onStack = 1; + if ( options.useXstack ) { + SPEC_OCLS(sym->etype) = xstack ; + SPEC_STAK(sym->etype) = sym->stack = (xstackPtr + 1); + xstackPtr += getSize (sym->type) ; + } + else { + SPEC_OCLS(sym->etype) = istack ; + SPEC_STAK(sym->etype) = sym->stack = ( stackPtr + 1); + stackPtr += getSize (sym->type) ; + } + allocIntoSeg(sym); + return ; + } + + /* else depending on the storage class specified */ + if ( SPEC_SCLS(sym->etype) == S_XDATA ) { + SPEC_OCLS(sym->etype) = xdata ; + allocIntoSeg(sym) ; + return ; + } + + if ( (SPEC_SCLS(sym->etype) == S_CODE || + SPEC_SCLS(sym->etype) == S_CONSTANT) && + !sym->_isparm) { + SPEC_OCLS(sym->etype) = statsg ; + allocIntoSeg (sym) ; + return ; + } + + if ( SPEC_SCLS(sym->etype) == S_IDATA ) { + SPEC_OCLS(sym->etype) = idata ; + sym->iaccess = 1; + allocIntoSeg (sym) ; + return ; + } + + /* if this is a function then assign code space */ + if (IS_FUNC(sym->type)) { + SPEC_OCLS(sym->etype) = code ; + return ; + } + + /* if this is a SFR or SBIT */ + if ( SPEC_SCLS(sym->etype) == S_SFR || + SPEC_SCLS(sym->etype) == S_SBIT ) { + + /* if both absolute address & initial */ + /* value specified then error */ + if ( IS_ABSOLUTE (sym->etype) && sym->ival ) { + werror(E_SFR_INIT,sym->name); + sym->ival = NULL ; + } + + SPEC_OCLS(sym->etype) = + (SPEC_SCLS(sym->etype) == S_SFR ? sfr : sfrbit); + + allocIntoSeg (sym); + return ; + } + + /* if this is a bit variable and no storage class */ + if ( SPEC_NOUN(sym->etype) == V_BIT + && (SPEC_SCLS(sym->etype) == S_BIT)) { + SPEC_OCLS(sym->etype) = bit ; + allocIntoSeg (sym); + return ; + } + + /* again note that we have put it into the overlay segment + will remove and put into the 'data' segment if required after + overlay analysis has been done */ + SPEC_OCLS(sym->etype) = ( options.model ? xdata : + (options.noOverlay ? data : overlay )) ; + allocIntoSeg (sym); +} + +/*-----------------------------------------------------------------*/ +/* deallocLocal - deallocates the local variables */ +/*-----------------------------------------------------------------*/ +void deallocLocal ( symbol *csym ) +{ + symbol *sym ; + + for ( sym = csym ; sym ; sym = sym->next) { + if (sym->_isparm) + continue ; + + /* if it is on the stack */ + if (sym->onStack) { + if (options.useXstack) + xstackPtr -= getSize(sym->type); + else + stackPtr -= getSize(sym->type); + } + /* if not used give a warning */ + if (!sym->isref && !IS_STATIC(sym->etype)) + werror(W_NO_REFERENCE,currFunc->name, + "local variable",sym->name); + /* now delete it from the symbol table */ + deleteSym (SymbolTab,sym,sym->name); + } +} + +/*-----------------------------------------------------------------*/ +/* overlay2data - moves declarations from the overlay seg to data */ +/*-----------------------------------------------------------------*/ +void overlay2data() +{ + symbol *sym; + + for (sym = setFirstItem(overlay->syms); sym; + sym = setNextItem(overlay->syms)) { + + SPEC_OCLS(sym->etype) = data; + allocIntoSeg(sym); + } + + setToNull((void **) &overlay->syms); + +} + +/*-----------------------------------------------------------------*/ +/* overlay2Set - will add all symbols from the overlay segment to */ +/* the set of sets containing the overlable symbols */ +/*-----------------------------------------------------------------*/ +void overlay2Set () +{ + symbol *sym; + set *oset = NULL; + + for (sym = setFirstItem(overlay->syms); sym; + sym = setNextItem(overlay->syms)) { + + addSet(&oset,sym); + } + + setToNull((void **) &overlay->syms); + addSet (&ovrSetSets,oset); + +} + +/*-----------------------------------------------------------------*/ +/* allocVariables - creates decl & assign storage class for a v */ +/*-----------------------------------------------------------------*/ +int allocVariables ( symbol *symChain ) +{ + symbol *sym; + symbol *csym; + int stack = 0; + int saveLevel = 0 ; + + /* go thru the symbol chain */ + for ( sym = symChain ; sym ; sym = sym->next ) { + + /* if this is a typedef then add it */ + /* to the typedef table */ + if (IS_TYPEDEF(sym->etype)) { + /* check if the typedef already exists */ + csym = findSym (TypedefTab, NULL, sym->name ); + if ( csym && csym->level == sym->level ) + werror(E_DUPLICATE_TYPEDEF,sym->name); + + addSym (TypedefTab, sym , sym->name,sym->level,sym->block); + continue ; /* go to the next one */ + } + /* make sure it already exist */ + csym = findSymWithLevel (SymbolTab, sym); + if (! csym || (csym && csym->level != sym->level) ) + csym = sym; + + /* check the declaration */ + checkDecl (csym); + + /* if this is a function or a pointer to function */ + /* then args processing */ + if (funcInChain(csym->type)) { + + processFuncArgs (csym, 1); + /* if register bank specified then update maxRegBank */ + if (maxRegBank < SPEC_BANK(csym->etype)) + maxRegBank = SPEC_BANK(csym->etype); + } + + /* if this is a extern variable then change the */ + /* level to zero temporarily */ + if (IS_EXTERN(csym->etype) || IS_FUNC(csym->type) ) { + saveLevel = csym->level ; + csym->level = 0 ; + } + + /* if this is a literal then it is an enumerated */ + /* type so need not allocate it space for it */ + if (IS_LITERAL(sym->etype)) + continue ; + + /* generate the actual declaration */ + if ( csym->level ) { + allocLocal (csym); + if (csym->onStack) + stack += getSize(csym->type) ; + } + else + allocGlobal (csym); + + /* restore the level */ + if (IS_EXTERN(csym->etype) || IS_FUNC(csym->type)) + csym->level = saveLevel; + } + + return stack ; +} + +/*-----------------------------------------------------------------*/ +/* redoStackOffsets :- will reassign the values for stack offsets */ +/*-----------------------------------------------------------------*/ +void redoStackOffsets () +{ + symbol *sym; + int sPtr = 0; + int xsPtr=-1; + + /* after register allocation is complete we know + which variables will need to be assigned space + on the stack. We will eliminate those variables + which do not have the allocReq flag thus reducing + the stack space */ + for ( sym = setFirstItem(istack->syms); sym; + sym = setNextItem(istack->syms)) { + + int size = getSize(sym->type); + /* nothing to do with parameters so continue */ + if ((sym->_isparm && !IS_REGPARM(sym->etype))) + continue ; + + if ( IS_AGGREGATE(sym->type)) { + SPEC_STAK(sym->etype) = sym->stack = ( sPtr + 1); + sPtr += size; + continue ; + } + + /* if allocation not required then subtract + size from overall stack size & continue */ + if (!sym->allocreq) { + currFunc->stack -= size; + SPEC_STAK(currFunc->etype) -= size; + continue ; + } + + SPEC_STAK(sym->etype) = sym->stack = ( sPtr + 1); + sPtr += size ; + } + + /* do the same for the external stack */ + + for ( sym = setFirstItem(xstack->syms); sym; + sym = setNextItem(xstack->syms)) { + + int size = getSize(sym->type); + /* nothing to do with parameters so continue */ + if ((sym->_isparm && !IS_REGPARM(sym->etype))) + continue ; + + if (IS_AGGREGATE(sym->type)) { + SPEC_STAK(sym->etype) = sym->stack = ( xsPtr + 1); + xsPtr += size ; + continue ; + } + + /* if allocation not required then subtract + size from overall stack size & continue */ + if (!sym->allocreq) { + currFunc->xstack -= size; + SPEC_STAK(currFunc->etype) -= size; + continue ; + } + + SPEC_STAK(sym->etype) = sym->stack = ( xsPtr + 1); + xsPtr += size ; + } + + /* if the debug option is set then output the + symbols to the map file */ + if (options.debug) { + for (sym = setFirstItem(istack->syms); sym; + sym = setNextItem(istack->syms)) + cdbSymbol(sym,cdbFile,FALSE,FALSE); + + for (sym = setFirstItem(xstack->syms); sym; + sym = setNextItem(xstack->syms)) + cdbSymbol(sym,cdbFile,FALSE,FALSE); + } +} diff --git a/src/SDCCmem.h b/src/SDCCmem.h new file mode 100644 index 00000000..09ce432b --- /dev/null +++ b/src/SDCCmem.h @@ -0,0 +1,78 @@ +/*-----------------------------------------------------------------*/ +/* SDCCmem.h - header file for memory management */ +/*-----------------------------------------------------------------*/ + +#ifndef SDCCMEM_H +#define SDCCMEM_H + +struct set ; +struct value ; +typedef struct memmap{ + unsigned char pageno;/* page no for this variable */ + char *sname; /* character prefix for map */ + char dbName ; /* debugger address space name */ + int slbl ; /* label counter for space */ + unsigned sloc ; /* starting location */ + unsigned fmap : 1; /* 1 = 16bit addressing reqd */ + unsigned paged : 1; /* this is a paged mem space */ + unsigned direct: 1; /* 1= indirect access only */ + unsigned bitsp: 1; /* 1 = bit addressable space */ + unsigned codesp:1; /* 1 = code space */ + unsigned regsp: 1; /* 1= sfr space */ + FILE *oFile ; /* object file associated */ + struct set *syms; /* symbols defined in this segment */ +} memmap ; + +extern FILE *junkFile ; + +/* memory map prefixes MOF added the DATA,CODE,XDATA,BIT */ +#define XSTACK_NAME "XSEG (XDATA)" +#define ISTACK_NAME "STACK (DATA)" +#define CODE_NAME "CSEG (CODE)" +#define DATA_NAME "DSEG (DATA)" +#define IDATA_NAME "ISEG (DATA)" +#define XDATA_NAME "XSEG (XDATA)" +#define BIT_NAME "BSEG (BIT)" +#define REG_NAME "RSEG (DATA)" +#define STATIC_NAME "GSINIT (CODE)" + +/* forward definition for variables */ +extern memmap *xstack; /* xternal stack data */ +extern memmap *istack; /* internal stack */ +extern memmap *code ; /* code segment */ +extern memmap *data ; /* internal data upto 128 */ +extern memmap *xdata ; /* external data */ +extern memmap *idata ; /* internal data upto 256 */ +extern memmap *bit ; /* bit addressable space */ +extern memmap *statsg; /* static code segment */ +extern memmap *sfr ; /* register space */ +extern memmap *sfrbit; /* sfr bit space */ +extern memmap *reg ; /* register space */ +extern memmap *_const; /* constant segment */ +extern memmap *generic; /* unknown */ +extern memmap *overlay; /* the overlay segment */ + +extern struct set *ovrSetSets; + +/* easy access macros */ +#define IN_BITSPACE(map) (map && map->bitsp) +#define IN_STACK(x) (IS_SPEC(x) && (SPEC_OCLS(x) == xstack || SPEC_OCLS(x) == istack )) +#define IN_FARSPACE(map) (map && map->fmap) +#define IN_DIRSPACE(map) (map && map->direct) +#define IN_PAGEDSPACE(map) (map && map->paged ) +#define IN_CODESPACE(map) (map && map->codesp) + +/* forward decls for functions */ +memmap *allocMap (char,char,char,char,char,char,unsigned,char *,char ); +void initMem ( ); +void allocGlobal (struct symbol * ); +void allocLocal (struct symbol * ); +void allocParms (struct value * ); +void deallocParms (struct value * ); +void deallocLocal (struct symbol * ); +int allocVariables (struct symbol * ); +void overlay2Set ( ); +void overlay2data ( ); +void redoStackOffsets( ); + +#endif diff --git a/src/SDCCopt.c b/src/SDCCopt.c new file mode 100644 index 00000000..23899f89 --- /dev/null +++ b/src/SDCCopt.c @@ -0,0 +1,826 @@ +/*------------------------------------------------------------------------- + SDCCopt.c - calls all the optimizations routines and does some of the + hackier transformations, these include translating iCodes + to function calls and replacing local variables with their + register equivalents etc. Also contains the driver routine + for dead code elimination + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCloop.h" +#include "SDCCcse.h" +#include "SDCCcflow.h" +#include "SDCCdflow.h" +#include "SDCClrange.h" +#include "SDCCralloc.h" +#include "SDCCptropt.h" +#include "SDCCopt.h" + + +/*-----------------------------------------------------------------*/ +/* global variables */ +int cseDefNum = 0 ; + +char flowChanged = 0; + + +/*-----------------------------------------------------------------*/ +/* printSymName - prints the symbol names */ +/*-----------------------------------------------------------------*/ +int printSymName (void *vsym) +{ + symbol *sym = vsym ; + fprintf (stdout, " %s ", sym->name); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* cnvToFcall - does the actual conversion to function call */ +/*-----------------------------------------------------------------*/ +static void cnvToFcall (iCode *ic,eBBlock *ebp) +{ + iCode *ip ; + iCode *newic; + operand *left ; + operand *right; + symbol *func = NULL; + int lineno = ic->lineno; + + ip = ic->next ; /* insertion point */ + /* remove it from the iCode */ + remiCodeFromeBBlock (ebp,ic); + + left = IC_LEFT(ic); + right= IC_RIGHT(ic); + + switch (ic->op) { + case '+' : + func = __fsadd ; + break; + case '-' : + func = __fssub; + break; + case '/' : + func = __fsdiv; + break; + case '*' : + func = __fsmul; + break; + case EQ_OP : + func = __fseq; + break; + case NE_OP : + func = __fsneq ; + break; + case '<' : + func = __fslt ; + break; + case '>': + func = __fsgt; + break; + case LE_OP : + func = __fslteq; + break; + case GE_OP : + func = __fsgteq ; + break; + } + + /* if float support routines NOT compiled as reentrant */ + if (! options.float_rent) { + + /* first one */ + if (IS_REGPARM(func->args->etype)) { + newic = newiCode(SEND,IC_LEFT(ic),NULL); + } else { + newic = newiCode('=',NULL,IC_LEFT(ic)); + IC_RESULT(newic) = operandFromValue(func->args); + } + + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + + /* second one */ + if (IS_REGPARM(func->args->next->etype)) { + newic = newiCode(SEND,IC_LEFT(ic),NULL); + } else { + newic = newiCode('=',NULL,IC_RIGHT(ic)); + IC_RESULT(newic) = operandFromValue(func->args->next); + } + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + + } else { + + /* push right */ + if (IS_REGPARM(func->args->next->etype)) { + newic = newiCode(SEND,right,NULL); + } else { + newic = newiCode(IPUSH,right,NULL); + newic->parmPush = 1; + } + + addiCodeToeBBlock (ebp,newic,ip); + newic->lineno = lineno; + + /* insert push left */ + if (IS_REGPARM(func->args->etype)) { + newic = newiCode(SEND,left,NULL); + } else { + newic = newiCode(IPUSH,left,NULL); + newic->parmPush = 1; + } + addiCodeToeBBlock (ebp,newic,ip); + newic->lineno = lineno; + } + /* insert the call */ + newic = newiCode(CALL,operandFromSymbol(func),NULL); + IC_RESULT(newic) = IC_RESULT(ic); + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; +} + +/*-----------------------------------------------------------------*/ +/* cnvToFloatCast - converts casts to floats to function calls */ +/*-----------------------------------------------------------------*/ +static void cnvToFloatCast (iCode *ic, eBBlock *ebp) +{ + iCode *ip, *newic; + symbol *func; + link *type = operandType(IC_RIGHT(ic)); + int linenno = ic->lineno; + + ip = ic->next ; + /* remove it from the iCode */ + remiCodeFromeBBlock (ebp,ic); + /* depending on the type */ + if (checkType(type,charType) == 1) + func = __char2fs ; + else + if (checkType(type,ucharType) == 1) + func = __uchar2fs; + else + if (checkType(type,intType) == 1) + func = __int2fs; + else + if (checkType(type,uintType) == 1) + func = __uint2fs ; + else + if (checkType(type,longType) == 1) + func = __long2fs; + else + func = __ulong2fs ; + + /* if float support routines NOT compiled as reentrant */ + if (! options.float_rent) { + /* first one */ + if (IS_REGPARM(func->args->etype)) + newic = newiCode(SEND,IC_RIGHT(ic),NULL); + else { + newic = newiCode('=',NULL,IC_RIGHT(ic)); + IC_RESULT(newic) = operandFromValue(func->args); + } + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = linenno; + + } else { + /* push the left */ + if (IS_REGPARM(func->args->etype)) + newic = newiCode(SEND,IC_RIGHT(ic),NULL); + else { + newic = newiCode(IPUSH,IC_RIGHT(ic),NULL); + newic->parmPush = 1; + } + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = linenno; + + } + + /* make the call */ + newic = newiCode(CALL,operandFromSymbol(func),NULL); + IC_RESULT(newic) = IC_RESULT(ic); + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = linenno; + +} + +/*-----------------------------------------------------------------*/ +/* cnvFromFloatCast - converts casts From floats to function calls */ +/*-----------------------------------------------------------------*/ +static void cnvFromFloatCast (iCode *ic, eBBlock *ebp) +{ + iCode *ip, *newic; + symbol *func; + link *type = operandType(IC_LEFT(ic)); + int lineno = ic->lineno ; + + ip = ic->next ; + /* remove it from the iCode */ + remiCodeFromeBBlock (ebp,ic); + + /* depending on the type */ + if (checkType(type,charType) == 1) + func = __fs2char ; + else + if (checkType(type,ucharType) == 1) + func = __fs2uchar; + else + if (checkType(type,intType) == 1) + func = __fs2int; + else + if (checkType(type,uintType) == 1) + func = __fs2uint ; + else + if (checkType(type,longType) == 1) + func = __fs2long; + else + func = __fs2ulong ; + + /* if float support routines NOT compiled as reentrant */ + if (! options.float_rent) { + /* first one */ + if (IS_REGPARM(func->args->etype)) + newic = newiCode(SEND,IC_RIGHT(ic),NULL); + else { + newic = newiCode('=',NULL,IC_RIGHT(ic)); + IC_RESULT(newic) = operandFromValue(func->args); + } + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + + } else { + + /* push the left */ + if (IS_REGPARM(func->args->etype)) + newic = newiCode(SEND,IC_RIGHT(ic),NULL); + else { + newic = newiCode(IPUSH,IC_RIGHT(ic),NULL); + newic->parmPush = 1; + } + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + + } + + /* make the call */ + newic = newiCode(CALL,operandFromSymbol(func),NULL); + IC_RESULT(newic) = IC_RESULT(ic); + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + +} + +/*-----------------------------------------------------------------*/ +/* convilong - converts int or long mults or divs to fcalls */ +/*-----------------------------------------------------------------*/ +static void convilong (iCode *ic, eBBlock *ebp, link *type, int op) +{ + symbol *func; + iCode *ip = ic->next; + iCode *newic ; + int lineno = ic->lineno; + + remiCodeFromeBBlock (ebp,ic); + + /* depending on the type */ + if (checkType(type,intType) == 1) + func = (op == '*' ? __mulsint : + (op == '%' ? __modsint :__divsint)); + else + if (checkType(type,uintType) == 1) + func = (op == '*' ? __muluint : + (op == '%' ? __moduint : __divuint)); + else + if (checkType(type,longType) == 1) + func = (op == '*' ? __mulslong : + (op == '%' ? __modslong : __divslong)); + else + func = (op == '*'? __mululong : + (op == '%' ? __modulong : __divulong)); + + /* if int & long support routines NOT compiled as reentrant */ + if (! options.intlong_rent) { + /* first one */ + if (IS_REGPARM(func->args->etype)) + newic = newiCode(SEND,IC_LEFT(ic),NULL); + else { + newic = newiCode('=',NULL,IC_LEFT(ic)); + IC_RESULT(newic) = operandFromValue(func->args); + } + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + + /* second one */ + if (IS_REGPARM(func->args->next->etype)) + newic = newiCode(SEND,IC_RIGHT(ic),NULL); + else { + newic = newiCode('=',NULL,IC_RIGHT(ic)); + IC_RESULT(newic) = operandFromValue(func->args->next); + } + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + + + } else { + + /* compiled as reentrant then push */ + /* push right */ + if (IS_REGPARM(func->args->next->etype)) + newic = newiCode(SEND,IC_RIGHT(ic),NULL); + else { + newic = newiCode(IPUSH,IC_RIGHT(ic),NULL); + newic->parmPush = 1; + } + addiCodeToeBBlock (ebp,newic,ip); + newic->lineno = lineno; + + /* insert push left */ + if (IS_REGPARM(func->args->etype)) + newic = newiCode(SEND,IC_LEFT(ic),NULL); + else { + newic = newiCode(IPUSH,IC_LEFT(ic),NULL); + newic->parmPush = 1; + } + addiCodeToeBBlock (ebp,newic,ip); + newic->lineno = lineno; + + } + + /* for the result */ + newic = newiCode(CALL,operandFromSymbol(func),NULL); + IC_RESULT(newic) = IC_RESULT(ic); + addiCodeToeBBlock(ebp,newic,ip); + newic->lineno = lineno; + +} + +/*-----------------------------------------------------------------*/ +/* convertToFcall - converts some operations to fcalls */ +/*-----------------------------------------------------------------*/ +static void convertToFcall (eBBlock **ebbs, int count) +{ + int i ; + + /* for all blocks do */ + for (i = 0 ; i < count ; i++ ) { + iCode *ic ; + + /* for all instructions in the block do */ + for (ic = ebbs[i]->sch ; ic ; ic = ic->next ) { + + /* floating point operations are + converted to function calls */ + if ((IS_CONDITIONAL(ic) || + IS_ARITHMETIC_OP(ic) ) && + (IS_FLOAT(operandType(IC_RIGHT(ic))))) { + + cnvToFcall(ic,ebbs[i]); + } + + /* casting is a little different */ + if (ic->op == CAST ) { + if (IS_FLOAT(operandType(IC_RIGHT(ic)))) + cnvFromFloatCast (ic,ebbs[i]); + else + if (IS_FLOAT(operandType(IC_LEFT(ic)))) + cnvToFloatCast (ic,ebbs[i]); + } + + /* if long / int mult or divide or mod */ + if (ic->op == '*' || ic->op == '/' || ic->op == '%' ) { + + link *type = operandType(IC_LEFT(ic)); + if (IS_INTEGRAL(type) && getSize(type) > 1) + convilong (ic,ebbs[i],type,ic->op); + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* replaceRegEqv - replace all local variables with their reqv */ +/*-----------------------------------------------------------------*/ +static void replaceRegEqv ( eBBlock **ebbs, int count) +{ + int i; + + for (i = 0 ; i < count ; i++ ) { + + iCode *ic ; + + for (ic = ebbs[i]->sch ; ic ; ic = ic->next) { + + if (SKIP_IC2(ic)) + continue ; + + if (ic->op == IFX) { + + if (IS_TRUE_SYMOP(IC_COND(ic)) && + OP_REQV(IC_COND(ic))) + IC_COND(ic) = opFromOpWithDU(OP_REQV(IC_COND(ic)), + OP_SYMBOL(IC_COND(ic))->defs, + OP_SYMBOL(IC_COND(ic))->uses); + + continue ; + } + + if (ic->op == JUMPTABLE) { + if (IS_TRUE_SYMOP(IC_JTCOND(ic)) && + OP_REQV(IC_JTCOND(ic))) + IC_JTCOND(ic) = opFromOpWithDU(OP_REQV(IC_JTCOND(ic)), + OP_SYMBOL(IC_JTCOND(ic))->defs, + OP_SYMBOL(IC_JTCOND(ic))->uses); + continue ; + } + + if (ic->op == RECEIVE) { + if (OP_SYMBOL(IC_RESULT(ic))->addrtaken) + OP_SYMBOL(IC_RESULT(ic))->isspilt = 1; + } + + /* general case */ + if (IC_RESULT(ic) && + IS_TRUE_SYMOP(IC_RESULT(ic)) && + OP_REQV(IC_RESULT(ic)) ) { + if (POINTER_SET(ic)) { + IC_RESULT(ic) = opFromOpWithDU(OP_REQV(IC_RESULT(ic)), + OP_SYMBOL(IC_RESULT(ic))->defs, + OP_SYMBOL(IC_RESULT(ic))->uses); + IC_RESULT(ic)->isaddr = 1; + } else + IC_RESULT(ic) = opFromOpWithDU(OP_REQV(IC_RESULT(ic)), + OP_SYMBOL(IC_RESULT(ic))->defs, + OP_SYMBOL(IC_RESULT(ic))->uses); + } + + if (IC_RIGHT(ic) && + IS_TRUE_SYMOP(IC_RIGHT(ic)) && + OP_REQV(IC_RIGHT(ic)) ) { + IC_RIGHT(ic) = opFromOpWithDU(OP_REQV(IC_RIGHT(ic)), + OP_SYMBOL(IC_RIGHT(ic))->defs, + OP_SYMBOL(IC_RIGHT(ic))->uses); + IC_RIGHT(ic)->isaddr = 0; + } + + if (IC_LEFT(ic) && + IS_TRUE_SYMOP(IC_LEFT(ic)) && + OP_REQV(IC_LEFT(ic)) ) { + IC_LEFT(ic) = opFromOpWithDU(OP_REQV(IC_LEFT(ic)), + OP_SYMBOL(IC_LEFT(ic))->defs, + OP_SYMBOL(IC_LEFT(ic))->uses); + IC_LEFT(ic)->isaddr = 0; + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* killDeadCode - eliminates dead assignments */ +/*-----------------------------------------------------------------*/ +int killDeadCode ( eBBlock **ebbs, int count) +{ + int change = 1; + int gchange = 0 ; + int i = 0 ; + + + /* basic algorithm :- */ + /* first the exclusion rules :- */ + /* 1. if result is a global or volatile then skip */ + /* 2. if assignment and result is a temp & isaddr then skip */ + /* since this means array & pointer access, will be taken */ + /* care of by alias analysis. */ + /* 3. if the result is used in the remainder of the block skip*/ + /* 4. if this definition does not reach the end of the block */ + /* i.e. the result is not present in the outExprs then KILL*/ + /* 5. if it reaches the end of block & is used by some success*/ + /* or then skip */ + /* else KILL */ + /* this whole process is carried on iteratively till no change */ + while (1) { + + change = 0 ; + /* for all blocks do */ + for ( i = 0 ; i < count ; i++ ) { + iCode *ic ; + + /* for all instructions in the block do */ + for ( ic = ebbs[i]->sch ; ic ; ic = ic->next ) { + int kill, j ; + kill = 0 ; + + if (SKIP_IC(ic) || + ic->op == IFX || + ic->op == RETURN ) + continue ; + + /* if the result is volatile then continue */ + if (IC_RESULT(ic) && isOperandVolatile(IC_RESULT(ic),FALSE)) + continue ; + + /* if the result is a temp & isaddr then skip */ + if (IC_RESULT(ic) && POINTER_SET(ic)) + continue ; + + /* if the result is used in the remainder of the */ + /* block then skip */ + if (usedInRemaining (IC_RESULT(ic),ic->next)) + continue ; + + /* does this definition reach the end of the block + or the usage is zero then we can kill */ + if (! bitVectBitValue(ebbs[i]->outDefs,ic->key)) + kill = 1; /* if not we can kill it */ + else { + /* if this is a global variable or function parameter */ + /* we cannot kill anyway */ + if (isOperandGlobal(IC_RESULT(ic)) || + (OP_SYMBOL(IC_RESULT(ic))->_isparm && + !OP_SYMBOL(IC_RESULT(ic))->ismyparm)) + continue ; + + /* if we are sure there are no usages */ + if (bitVectIsZero(OP_USES(IC_RESULT(ic)))) { + kill = 1 ; + goto kill ; + } + + /* reset visited flag */ + for(j=0; j < count ; ebbs[j++]->visited = 0); + + /* find out if this definition is alive */ + if ( applyToSet (ebbs[i]->succList, + isDefAlive, + ic)) + continue ; + + kill = 1; + } + + kill : + /* kill this one if required */ + if (kill) { + change = 1; + gchange++ ; + /* eliminate this */ + remiCodeFromeBBlock(ebbs[i],ic); + + /* now delete from defUseSet */ + deleteItemIf (&ebbs[i]->outExprs,ifDiCodeIsX,ic); + bitVectUnSetBit (ebbs[i]->outDefs,ic->key); + + /* and defset of the block */ + bitVectUnSetBit (ebbs[i]->defSet,ic->key); + + /* for the left & right remove the usage */ + if (IS_SYMOP(IC_LEFT(ic))) + bitVectUnSetBit(OP_USES(IC_LEFT(ic)),ic->key); + + if (IS_SYMOP(IC_RIGHT(ic))) + bitVectUnSetBit(OP_USES(IC_RIGHT(ic)),ic->key); + } + + } /* end of all instructions */ + + if (!ebbs[i]->sch && !ebbs[i]->noPath) + disconBBlock(ebbs[i],ebbs,count); + + } /* end of for all blocks */ + + if (!change) + break; + } /* end of while(1) */ + + return gchange ; +} + +/*-----------------------------------------------------------------*/ +/* printCyclomatic - prints the cyclomatic information */ +/*-----------------------------------------------------------------*/ +static void printCyclomatic (eBBlock **ebbs, int count) +{ + int nEdges = elementsInSet(graphEdges); + int i, nNodes =0; + + for (i = 0 ; i < count ; i++) + nNodes += (! ebbs[i]->noPath); + + /* print the information */ + werror(I_CYCLOMATIC,currFunc->name,nEdges,nNodes, nEdges - nNodes + 2); +} + +/*-----------------------------------------------------------------*/ +/* canOverlayLocals - returns true if the local variables can overlayed */ +/*-----------------------------------------------------------------*/ +static bool canOverlayLocals (eBBlock **ebbs, int count) +{ + int i; + /* if staticAuto is in effect or the current function + being compiled is reentrant or the overlay segment + is empty or no overlay option is in effect then */ + if (options.noOverlay || + options.stackAuto || + (currFunc && + (IS_RENT(currFunc->etype) || + IS_ISR(currFunc->etype))) || + elementsInSet(overlay->syms) == 0) + + return FALSE; + + /* otherwise do thru the blocks and see if there + any function calls if found then return false */ + for (i = 0; i < count ; i++ ) { + iCode *ic; + + for (ic = ebbs[i]->sch; ic ; ic = ic->next) + if (ic && ( ic->op == CALL || ic->op == PCALL)) + return FALSE; + } + + /* no function calls found return TRUE */ + return TRUE; +} + + +/*-----------------------------------------------------------------*/ +/* eBBlockFromiCode - creates extended basic blocks from iCode */ +/* will return an array of eBBlock pointers */ +/*-----------------------------------------------------------------*/ +eBBlock **eBBlockFromiCode (iCode *ic) +{ + eBBlock **ebbs = NULL ; + int count = 0; + int saveCount = 0 ; + int change = 1; + int lchange = 0 ; + int kchange = 0; + hTab *loops ; + + /* if nothing passed then return nothing */ + if (!ic) + return NULL ; + + count = 0; + eBBNum = 0; + + /* optimize the chain for labels & gotos + this will eliminate redundant labels and + will change jump to jumps by jumps */ + ic = iCodeLabelOptimize (ic); + + /* break it down into basic blocks */ + ebbs = iCodeBreakDown (ic,&count); + saveCount = count ; + + /* compute the control flow */ + computeControlFlow (ebbs,count,0); + + /* dumpraw if asked for */ + if (options.dump_raw) + dumpEbbsToFileExt(".dumpraw0",ebbs,count); + + /* replace the local variables with their + register equivalents : the liveRange computation + along with the register allocation will determine + if it finally stays in the registers */ + replaceRegEqv (ebbs,count); + + /* create loop regions */ + loops = createLoopRegions (ebbs,count); + + /* dumpraw if asked for */ + if (options.dump_raw) + dumpEbbsToFileExt(".dumpraw1",ebbs,count); + + /* do common subexpression elimination for each block */ + change = cseAllBlocks(ebbs,saveCount); + + /* dumpraw if asked for */ + if (options.dump_raw) + dumpEbbsToFileExt(".dumpcse",ebbs,count); + + /* compute the data flow */ + computeDataFlow (ebbs,saveCount); + + /* dumpraw if asked for */ + if (options.dump_raw) + dumpEbbsToFileExt(".dumpdflow",ebbs,count); + + /* global common subexpression elimination */ + if ( optimize.global_cse ) { + change += cseAllBlocks(ebbs,saveCount); + if (options.dump_gcse) + dumpEbbsToFileExt(".dumpgcse",ebbs,saveCount); + } + /* kill dead code */ + kchange = killDeadCode (ebbs, saveCount); + + if (options.dump_kill) + dumpEbbsToFileExt(".dumpdeadcode",ebbs,count); + + /* do loop optimizations */ + change += (lchange = loopOptimizations (loops,ebbs,count)); + if (options.dump_loop) + dumpEbbsToFileExt(".dumploop",ebbs,count); + + /* recompute the data flow and apply global cse again + if loops optimizations or dead code caused a change: + loops will brings out of the loop which then may be + available for use in the later blocks: dead code + elimination could potentially disconnect some blocks + conditional flow may be efected so we need to apply + subexpression once more */ + if ( lchange || kchange ) { + + computeDataFlow (ebbs,saveCount); + change += cseAllBlocks(ebbs,saveCount); + if (options.dump_loop) + dumpEbbsToFileExt(".dumploopg",ebbs,count); + + /* if loop optimizations caused a change then do + dead code elimination once more : this will + get rid of the extra assignments to the induction + variables created during loop optimizations */ + killDeadCode (ebbs, saveCount); + + if (options.dump_loop) + dumpEbbsToFileExt(".dumploopd",ebbs,count); + + } + + + /* sort it back by block number */ + qsort (ebbs,saveCount,sizeof(eBBlock *),bbNumCompare); + + /* if cyclomatic info requested then print it */ + if (options.cyclomatic) + printCyclomatic(ebbs,saveCount); + + + /* convert operations with support routines + written in C to function calls : Iam doing + this at this point since I want all the + operations to be as they are for optimzations */ + convertToFcall (ebbs,count); + + /* check if the parameters and local variables + of this function can be put in the overlay segment + This check is essentially to see if the function + calls any other functions if yes then we cannot + overlay */ + if (canOverlayLocals(ebbs,count)) + /* if we can then put the parameters & + local variables in the overlay set */ + overlay2Set(); + else + /* otherwise put them into data where + they belong */ + overlay2data(); + + /* compute the live ranges */ + computeLiveRanges (ebbs,count); + + if (options.dump_range) + dumpEbbsToFileExt(".dumprange",ebbs,count); + + /* allocate registers & generate code */ + assignRegisters (ebbs,count); + + /* throw away blocks */ + setToNull ((void **)&graphEdges); + ebbs = NULL ; + + + return NULL; +} +/* (add-hook 'c-mode-hook (lambda () (setq c-basic-offset 4))) */ diff --git a/src/SDCCopt.h b/src/SDCCopt.h new file mode 100644 index 00000000..234086e7 --- /dev/null +++ b/src/SDCCopt.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + + SDCCopt.h - header file for Optimizations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "SDCCBBlock.h" + +#ifndef SDCCOPT_H +#define SDCCOPT_H 1 + + +/*----------------------------------------------------------------------------*/ +eBBlock **eBBlockFromiCode (iCode *); +void printEbbs (eBBlock **) ; +iCode *iCodeLabelOptimize (iCode *); +eBBlock *iCode2eBBlock (iCode *ic); + +#endif diff --git a/src/SDCCpeeph.awk b/src/SDCCpeeph.awk new file mode 100644 index 00000000..160e0694 --- /dev/null +++ b/src/SDCCpeeph.awk @@ -0,0 +1,14 @@ +BEGIN { + print "/* Generated file DO NOT Edit */" + print "/* To Make changes to rules */" + print "/* edit file SDCCpeeph.def */" +} + +/^\/\// { next} + +{ printf "\"" ; + printf "%s",$0; + print "\\n\""; +} + + diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c new file mode 100644 index 00000000..b9298508 --- /dev/null +++ b/src/SDCCpeeph.c @@ -0,0 +1,721 @@ +/*------------------------------------------------------------------------- + SDCCpeeph.c - The peep hole optimizer: for interpreting the + peep hole rules + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCChasht.h" +#include "SDCCset.h" +#include "SDCCpeeph.h" + + +peepRule *rootRules = NULL; +peepRule *currRule = NULL; + +char *defaultRules = +{ +#include "SDCCpeeph.rul" +}; + +static bool matchLine (char *, char *, hTab **); + +#define FBYNAME(x) int x (hTab *vars, lineNode *currPl, lineNode *head) + +/*-----------------------------------------------------------------*/ +/* pcDistance - afinds a label back ward or forward */ +/*-----------------------------------------------------------------*/ +int pcDistance (lineNode *cpos, char *lbl, bool back) +{ + lineNode *pl = cpos; + char buff[MAX_PATTERN_LEN]; + int dist = 0 ; + + sprintf(buff,"%s:",lbl); + while (pl) { + + if (pl->line && + *pl->line != ';' && + pl->line[strlen(pl->line)-1] != ':' && + !pl->isDebug) + + dist ++; + + if (strncmp(pl->line,buff,strlen(buff)) == 0) + return dist; + + if (back) + pl = pl->prev; + else + pl = pl->next; + + } + return 0; +} + +/*-----------------------------------------------------------------*/ +/* labelInRange - will check to see if label %5 is within range */ +/*-----------------------------------------------------------------*/ +FBYNAME(labelInRange) +{ + /* assumes that %5 pattern variable has the label name */ + char *lbl = hTabItemWithKey(vars,5); + int dist = 0 ; + + if (!lbl) + return FALSE; + + /* if the previous teo instructions are "ljmp"s then don't + do it since it can be part of a jump table */ + if (currPl->prev && currPl->prev->prev && + strstr(currPl->prev->line,"ljmp") && + strstr(currPl->prev->prev->line,"ljmp")) + return FALSE ; + + /* calculate the label distance : the jump for reladdr can be + +/- 127 bytes, here Iam assuming that an average 8051 + instruction is 2 bytes long, so if the label is more than + 63 intructions away, the label is considered out of range + for a relative jump. we could get more precise this will + suffice for now since it catches > 90% cases */ + dist = (pcDistance(currPl,lbl,TRUE) + + pcDistance(currPl,lbl,FALSE)) ; + + if (!dist || dist > 45) + return FALSE; + + return TRUE; +} + +/*-----------------------------------------------------------------*/ +/* operandsNotSame - check if %1 & %2 are the same */ +/*-----------------------------------------------------------------*/ +FBYNAME(operandsNotSame) +{ + char *op1 = hTabItemWithKey(vars,1); + char *op2 = hTabItemWithKey(vars,2); + + if (strcmp(op1,op2) == 0) + return FALSE; + else + return TRUE; +} + +/*-----------------------------------------------------------------*/ +/* callFuncByName - calls a function as defined in the table */ +/*-----------------------------------------------------------------*/ +int callFuncByName ( char *fname, + hTab *vars, + lineNode *currPl, + lineNode *head) +{ + struct ftab { + char *fname ; + int (*func)(hTab *,lineNode *,lineNode *) ; + } ftab[] = { + {"labelInRange", labelInRange }, + {"operandsNotSame", operandsNotSame } + }; + int i; + + for ( i = 0 ; i < ((sizeof (ftab))/(sizeof(struct ftab))); i++) + if (strcmp(ftab[i].fname,fname) == 0) + return (*ftab[i].func)(vars,currPl,head); + fprintf(stderr,"could not find named function in function table\n"); + return TRUE; +} + +/*-----------------------------------------------------------------*/ +/* printLine - prints a line chain into a given file */ +/*-----------------------------------------------------------------*/ +void printLine (lineNode *head, FILE *of) +{ + if (!of) + of = stdout ; + + while (head) { + /* don't indent comments & labels */ + if (head->line && + ( *head->line == ';' || + head->line[strlen(head->line)-1] == ':')) + fprintf(of,"%s\n",head->line); + else + fprintf(of,"\t%s\n",head->line); + head = head->next; + } +} + +/*-----------------------------------------------------------------*/ +/* newPeepRule - creates a new peeprule and attach it to the root */ +/*-----------------------------------------------------------------*/ +peepRule *newPeepRule (lineNode *match , + lineNode *replace, + char *cond , + int restart) +{ + peepRule *pr ; + + ALLOC(pr,sizeof(peepRule)); + pr->match = match; + pr->replace= replace; + pr->restart = restart; + + if (cond && *cond) { + ALLOC_ATOMIC(pr->cond,strlen(cond)+1); + strcpy(pr->cond,cond); + } else + pr->cond = NULL ; + + pr->vars = newHashTable(100); + + /* if root is empty */ + if (!rootRules) + rootRules = currRule = pr; + else + currRule = currRule->next = pr; + + return pr; +} + +/*-----------------------------------------------------------------*/ +/* newLineNode - creates a new peep line */ +/*-----------------------------------------------------------------*/ +lineNode *newLineNode (char *line) +{ + lineNode *pl; + + ALLOC(pl,sizeof(lineNode)); + ALLOC_ATOMIC(pl->line,strlen(line)+1); + strcpy(pl->line,line); + return pl; +} + +/*-----------------------------------------------------------------*/ +/* connectLine - connects two lines */ +/*-----------------------------------------------------------------*/ +lineNode *connectLine (lineNode *pl1, lineNode *pl2) +{ + if (!pl1 || !pl2) { + fprintf (stderr,"trying to connect null line\n"); + return NULL ; + } + + pl2->prev = pl1; + pl1->next = pl2; + + return pl2; +} + +#define SKIP_SPACE(x,y) { while (*x && (isspace(*x) || *x == '\n')) x++; \ + if (!*x) { fprintf(stderr,y); return ; } } + +#define EXPECT_STR(x,y,z) { while (*x && strncmp(x,y,strlen(y))) x++ ; \ + if (!*x) { fprintf(stderr,z); return ; } } +#define EXPECT_CHR(x,y,z) { while (*x && *x != y) x++ ; \ + if (!*x) { fprintf(stderr,z); return ; } } + +/*-----------------------------------------------------------------*/ +/* getPeepLine - parses the peep lines */ +/*-----------------------------------------------------------------*/ +static void getPeepLine (lineNode **head, char **bpp) +{ + char lines[MAX_PATTERN_LEN]; + char *lp; + + lineNode *currL = NULL ; + char *bp = *bpp; + while (1) { + + if (!*bp) { + fprintf(stderr,"unexpected end of match pattern\n"); + return ; + } + + if (*bp == '\n') { + bp++ ; + while (isspace(*bp) || + *bp == '\n') bp++; + } + + if (*bp == '}') { + bp++ ; + break; + } + + /* read till end of line */ + lp = lines ; + while ((*bp != '\n' && *bp != '}' ) && *bp) + *lp++ = *bp++ ; + + *lp = '\0'; + if (!currL) + *head = currL = newLineNode (lines); + else + currL = connectLine(currL,newLineNode(lines)); + } + + *bpp = bp; +} + +/*-----------------------------------------------------------------*/ +/* readRules - reads the rules from a string buffer */ +/*-----------------------------------------------------------------*/ +static void readRules (char *bp) +{ + char restart = 0 ; + char lines[MAX_PATTERN_LEN]; + char *lp; + lineNode *match; + lineNode *replace; + lineNode *currL = NULL; + + if (!bp) + return; + top: + restart = 0; + /* look for the token "replace" that is the + start of a rule */ + while (*bp && strncmp(bp,"replace",7)) bp++; + + /* if not found */ + if (!*bp) + return ; + + /* then look for either "restart" or '{' */ + while (strncmp(bp,"restart",7) && + *bp != '{' && bp ) bp++ ; + + /* not found */ + if (!*bp) { + fprintf(stderr,"expected 'restart' or '{'\n"); + return ; + } + + /* if brace */ + if (*bp == '{') + bp++ ; + else { /* must be restart */ + restart++; + bp += strlen("restart"); + /* look for '{' */ + EXPECT_CHR(bp,'{',"expected '{'\n"); + bp++; + } + + /* skip thru all the blank space */ + SKIP_SPACE(bp,"unexpected end of rule\n"); + + match = replace = currL = NULL ; + /* we are the start of a rule */ + getPeepLine(&match, &bp); + + /* now look for by */ + EXPECT_STR(bp,"by","expected 'by'\n"); + + /* then look for a '{' */ + EXPECT_CHR(bp,'{',"expected '{'\n"); + bp++ ; + + SKIP_SPACE(bp,"unexpected end of rule\n"); + getPeepLine (&replace, &bp); + + /* look for a 'if' */ + while ((isspace(*bp) || *bp == '\n') && *bp) bp++; + + if (strncmp(bp,"if",2) == 0) { + bp += 2; + while ((isspace(*bp) || *bp == '\n') && *bp) bp++; + if (!*bp) { + fprintf(stderr,"expected condition name\n"); + return; + } + + /* look for the condition */ + lp = lines; + while (isalnum(*bp)) { + *lp++ = *bp++; + } + *lp = '\0'; + + newPeepRule(match,replace,lines,restart); + } else + newPeepRule(match,replace,NULL,restart); + goto top; + +} + +/*-----------------------------------------------------------------*/ +/* keyForVar - returns the numeric key for a var */ +/*-----------------------------------------------------------------*/ +static int keyForVar (char *d) +{ + int i = 0; + + while (isdigit(*d)) { + i *= 10 ; + i += (*d++ - '0') ; + } + + return i; +} + +/*-----------------------------------------------------------------*/ +/* bindVar - binds a value to a variable in the given hashtable */ +/*-----------------------------------------------------------------*/ +static void bindVar (int key, char **s, hTab **vtab) +{ + char vval[MAX_PATTERN_LEN]; + char *vvx; + char *vv = vval; + + /* first get the value of the variable */ + vvx = *s; + /* the value is ended by a ',' or space or newline or null */ + while (*vvx && + *vvx != ',' && + !isspace(*vvx) && + *vvx != '\n' && + *vvx != ':' ) { + char ubb = 0 ; + /* if we find a '(' then we need to balance it */ + if (*vvx == '(') { + ubb++ ; + while (ubb) { + *vv++ = *vvx++ ; + if (*vvx == '(') ubb++; + if (*vvx == ')') ubb--; + } + } else + *vv++ = *vvx++ ; + } + *s = vvx ; + *vv = '\0'; + /* got value */ + ALLOC_ATOMIC(vvx,strlen(vval)+1); + strcpy(vvx,vval); + hTabAddItem(vtab,key,vvx); + +} + +/*-----------------------------------------------------------------*/ +/* matchLine - matches one line */ +/*-----------------------------------------------------------------*/ +static bool matchLine (char *s, char *d, hTab **vars) +{ + + if (!s || !(*s)) + return FALSE; + + while (*s && *d) { + + /* skip white space in both */ + while (isspace(*s)) s++; + while (isspace(*d)) d++; + + /* if the destination is a var */ + if (*d == '%' && isdigit(*(d+1))) { + char *v = hTabItemWithKey(*vars,keyForVar(d+1)); + /* if the variable is already bound + then it MUST match with dest */ + if (v) { + while (*v) + if (*v++ != *s++) return FALSE; + } else + /* variable not bound we need to + bind it */ + bindVar (keyForVar(d+1),&s,vars); + + /* in either case go past the variable */ + d++ ; + while (isdigit(*d)) d++; + } + + /* they should be an exact match other wise */ + if (*s && *d) { + while (isspace(*s))s++; + while (isspace(*d))d++; + if (*s++ != *d++) + return FALSE; + } + + } + + /* get rid of the trailing spaces + in both source & destination */ + if (*s) + while (isspace(*s)) s++; + + if (*d) + while (isspace(*d)) d++; + + /* after all this if only one of them + has something left over then no match */ + if (*s || *d) + return FALSE ; + + return TRUE ; +} + +/*-----------------------------------------------------------------*/ +/* matchRule - matches a all the rule lines */ +/*-----------------------------------------------------------------*/ +static bool matchRule (lineNode *pl, + lineNode **mtail, + peepRule *pr, + lineNode *head) +{ + lineNode *spl ; /* source pl */ + lineNode *rpl ; /* rule peep line */ + + hTabClearAll(pr->vars); +/* setToNull((void **) &pr->vars); */ +/* pr->vars = newHashTable(100); */ + + /* for all the lines defined in the rule */ + rpl = pr->match; + spl = pl ; + while (spl && rpl) { + + /* if the source line starts with a ';' then + comment line don't process or the source line + contains == . debugger information skip it */ + if (spl->line && + (*spl->line == ';' || spl->isDebug)) { + spl = spl->next; + continue; + } + + if (!matchLine(spl->line,rpl->line,&pr->vars)) + return FALSE ; + + rpl = rpl->next ; + if (rpl) + spl = spl->next ; + } + + /* if rules ended */ + if (!rpl) { + /* if this rule has additional conditions */ + if ( pr->cond) { + if (callFuncByName (pr->cond, pr->vars,pl,head) ) { + *mtail = spl; + return TRUE; + } else + return FALSE; + } else { + *mtail = spl; + return TRUE; + } + } + else + return FALSE; +} + +/*-----------------------------------------------------------------*/ +/* replaceRule - does replacement of a matching pattern */ +/*-----------------------------------------------------------------*/ +static void replaceRule (lineNode **shead, lineNode *stail, peepRule *pr) +{ + lineNode *cl = NULL; + lineNode *pl = NULL , *lhead = NULL; + char lb[MAX_PATTERN_LEN]; + char *lbp; + lineNode *comment = NULL; + + /* collect all the comment lines in the source */ + for (cl = *shead ; cl != stail ; cl = cl->next) { + if (cl->line && ( *cl->line == ';' || cl->isDebug)) { + pl = (pl ? connectLine (pl,newLineNode(cl->line)) : + (comment = newLineNode(cl->line))); + pl->isDebug = cl->isDebug; + } + } + cl = NULL; + + /* for all the lines in the replacement pattern do */ + for ( pl = pr->replace ; pl ; pl = pl->next ) { + char *v; + char *l; + lbp = lb; + + l = pl->line; + while (*l) { + /* if the line contains a variable */ + if (*l == '%' && isdigit(*(l+1))) { + v = hTabItemWithKey(pr->vars,keyForVar(l+1)); + if (!v) { + fprintf(stderr,"used unbound variable in replacement\n"); + l++; + continue; + } + while (*v) + *lbp++ = *v++; + l++; + while (isdigit(*l)) l++; + continue ; + } + *lbp++ = *l++; + } + + *lbp = '\0'; + if (cl) + cl = connectLine(cl,newLineNode(lb)); + else + lhead = cl = newLineNode(lb); + } + + /* add the comments if any to the head of list */ + if (comment) { + lineNode *lc = comment; + while (lc->next) lc = lc->next; + lc->next = lhead; + if (lhead) + lhead->prev = lc; + lhead = comment; + } + + /* now we need to connect / replace the original chain */ + /* if there is a prev then change it */ + if ((*shead)->prev) { + (*shead)->prev->next = lhead; + lhead->prev = (*shead)->prev; + } else + *shead = lhead; + /* now for the tail */ + if (stail && stail->next) { + stail->next->prev = cl; + if (cl) + cl->next = stail->next; + } +} + +/*-----------------------------------------------------------------*/ +/* peepHole - matches & substitutes rules */ +/*-----------------------------------------------------------------*/ +void peepHole (lineNode **pls ) +{ + lineNode *spl ; + peepRule *pr ; + lineNode *mtail = NULL; + + top: + /* for all rules */ + for (pr = rootRules ; pr ; pr = pr->next ) { + + for (spl = *pls ; spl ; spl = spl->next ) { + + /* if inline assembler then no peep hole */ + if (spl->isInline) + continue ; + + mtail = NULL ; + + /* if it matches */ + if (matchRule (spl,&mtail,pr, *pls)) { + + /* then replace */ + if (spl == *pls) + replaceRule(pls, mtail, pr); + else + replaceRule (&spl, mtail,pr); + + /* if it was the start then replace + the start */ + + /* if restart rule type then + start at the top again */ + if (pr->restart) + goto top; + } + } + } +} + + +/*-----------------------------------------------------------------*/ +/* readFileIntoBuffer - reads a file into a string buffer */ +/*-----------------------------------------------------------------*/ +static char *readFileIntoBuffer (char *fname) +{ + FILE *f; + char *rs = NULL; + int nch = 0 ; + int ch; + char lb[MAX_PATTERN_LEN]; + + if (!(f = fopen(fname,"r"))) { + fprintf(stderr,"cannot open peep rule file\n"); + return NULL; + } + + while ((ch = fgetc(f)) != EOF) { + lb[nch++] = ch; + + /* if we maxed out our local buffer */ + if (nch >= (MAX_PATTERN_LEN - 2)) { + lb[nch] = '\0'; + /* copy it into allocated buffer */ + if (rs) { + rs = GC_realloc(rs,strlen(rs)+strlen(lb)+1); + strcat(rs,lb); + } else { + ALLOC_ATOMIC(rs,strlen(lb)+1); + strcpy(rs,lb); + } + nch = 0 ; + } + } + + /* if some charaters left over */ + if (nch) { + lb[nch] = '\0'; + /* copy it into allocated buffer */ + if (rs) { + rs = GC_realloc(rs,strlen(rs)+strlen(lb)+1); + strcat(rs,lb); + } else { + ALLOC_ATOMIC(rs,strlen(lb)+1); + strcpy(rs,lb); + } + } + return rs; +} + +/*-----------------------------------------------------------------*/ +/* initPeepHole - initiaises the peep hole optimizer stuff */ +/*-----------------------------------------------------------------*/ +void initPeepHole () +{ + char *s; + + /* read in the default rules */ + readRules(defaultRules); + + /* if we have any additional file read it too */ + if (options.peep_file) { + readRules(s=readFileIntoBuffer(options.peep_file)); + setToNull((void **) &s); + } +} diff --git a/src/SDCCpeeph.def b/src/SDCCpeeph.def new file mode 100644 index 00000000..75778704 --- /dev/null +++ b/src/SDCCpeeph.def @@ -0,0 +1,1626 @@ +//replace restart { +// pop %1 +// push %1 +//} by { +// ; Peephole 1 removed pop %1 push %1 (not push pop) +//} + +//replace restart { +// pop %1 +// mov %2,%3 +// push %1 +//} by { +// ; Peephole 2 removed pop %1 push %1 (not push pop) +// mov %2,%3 +//} + +// +// added by Jean Louis VERN for +// his shift stuff +replace restart { + xch a,%1 + xch a,%1 +} by { + ; Peephole 2.a removed redundant xch xch +} + +replace restart { +// saving 2 byte + mov %1,#0x00 + mov a,#0x00 +} by { + ; Peephole 3.a changed mov to clr + clr a + mov %1,a +} + +replace restart { +// saving 1 byte + mov %1,#0x00 + clr a +} by { + ; Peephole 3.b changed mov to clr + clr a + mov %1,a +} + +replace restart { +// saving 1 byte, loosing 1 cycle but maybe allowing peephole 3.b to start + mov %1,#0x00 + mov %2,#0x00 + mov a,%3 +} by { + ; Peephole 3.c changed mov to clr + clr a + mov %1,a + mov %2,a + mov a,%3 +} + + + +replace { + mov %1,a + mov dptr,#%2 + mov a,%1 + movx @dptr,a +} by { + ; Peephole 100 removed redundant mov + mov %1,a + mov dptr,#%2 + movx @dptr,a +} + +replace { + mov a,acc +} by { + ; Peephole 100.a removed redundant mov +} + +replace { + mov a,%1 + movx @dptr,a + inc dptr + mov a,%1 + movx @dptr,a +} by { + ; Peephole 101 removed redundant mov + mov a,%1 + movx @dptr,a + inc dptr + movx @dptr,a +} + +replace { + mov %1,%2 + ljmp %3 +%4: + mov %1,%5 +%3: + mov dpl,%1 +%7: + mov sp,bp + pop bp +} by { + ; Peephole 102 removed redundant mov + mov dpl,%2 + ljmp %3 +%4: + mov dpl,%5 +%3: +%7: + mov sp,bp + pop bp +} + +replace { + mov %1,%2 + ljmp %3 +%4: + mov a%1,%5 +%3: + mov dpl,%1 +%7: + mov sp,bp + pop bp +} by { + ; Peephole 103 removed redundant mov + mov dpl,%2 + ljmp %3 +%4: + mov dpl,%5 +%3: +%7: + mov sp,bp + pop bp +} + +replace { + mov a,bp + clr c + add a,#0x01 + mov r%1,a +} by { + ; Peephole 104 optimized increment (acc not set to r%1, flags undefined) + mov r%1,bp + inc r%1 +} + +replace { + mov %1,a + mov a,%1 +} by { + ; Peephole 105 removed redundant mov + mov %1,a +} + +replace { + mov %1,a + clr c + mov a,%1 +} by { + ; Peephole 106 removed redundant mov + mov %1,a + clr c +} + +replace { + ljmp %1 +%1: +} by { + ; Peephole 107 removed redundant ljmp +%1: +} + +replace { + jc %1 + ljmp %5 +%1: +} by { + ; Peephole 108 removed ljmp by inverse jump logic + jnc %5 +%1: +} if labelInRange + +replace { + jz %1 + ljmp %5 +%1: +} by { + ; Peephole 109 removed ljmp by inverse jump logic + jnz %5 +%1: +} if labelInRange + +replace { + jnz %1 + ljmp %5 +%1: +} by { + ; Peephole 110 removed ljmp by inverse jump logic + jz %5 +%1: +} if labelInRange + +replace { + jb %1,%2 + ljmp %5 +%2: +} by { + ; Peephole 111 removed ljmp by inverse jump logic + jnb %1,%5 +%2: +} if labelInRange + +replace { + jnb %1,%2 + ljmp %5 +%2: +} by { + ; Peephole 112 removed ljmp by inverse jump logic + jb %1,%5 +%2: +} if labelInRange + +replace { + clr a + cjne %1,%2,%3 + cpl a +%3: + rrc a + mov %4,c +} by { + ; Peephole 113 optimized misc sequence + clr %4 + cjne %1,%2,%3 + setb %4 +%3: +} + +replace { + clr a + cjne %1,%2,%3 + cjne %10,%11,%3 + cpl a +%3: + rrc a + mov %4,c +} by { + ; Peephole 114 optimized misc sequence + clr %4 + cjne %1,%2,%3 + cjne %10,%11,%3 + setb %4 +%3: +} + +replace { + clr a + cjne %1,%2,%3 + cpl a +%3: + jnz %4 +} by { + ; Peephole 115 jump optimization + cjne %1,%2,%3 + sjmp %4 +%3: +} + +replace { + clr a + cjne %1,%2,%3 + cjne %9,%10,%3 + cpl a +%3: + jnz %4 +} by { + ; Peephole 116 jump optimization + cjne %1,%2,%3 + cjne %9,%10,%3 + sjmp %4 +%3: +} + +replace { + clr a + cjne %1,%2,%3 + cjne %9,%10,%3 + cjne %11,%12,%3 + cpl a +%3: + jnz %4 +} by { + ; Peephole 117 jump optimization + cjne %1,%2,%3 + cjne %9,%10,%3 + cjne %11,%12,%3 + sjmp %4 +%3: +} + +replace { + clr a + cjne %1,%2,%3 + cjne %9,%10,%3 + cjne %11,%12,%3 + cjne %13,%14,%3 + cpl a +%3: + jnz %4 +} by { + ; Peephole 118 jump optimization + cjne %1,%2,%3 + cjne %9,%10,%3 + cjne %11,%12,%3 + cjne %13,%14,%3 + sjmp %4 +%3: +} +replace { + mov a,#0x01 + cjne %1,%2,%3 + clr a +%3: + jnz %4 +} by { + ; Peephole 119 jump optimization + cjne %1,%2,%4 +%3: +} + +replace { + mov a,#0x01 + cjne %1,%2,%3 + cjne %10,%11,%3 + clr a +%3: + jnz %4 +} by { + ; Peephole 120 jump optimization + cjne %1,%2,%4 + cjne %10,%11,%4 +%3: +} +replace { + mov a,#0x01 + cjne %1,%2,%3 + cjne %10,%11,%3 + cjne %12,%13,%3 + clr a +%3: + jnz %4 +} by { + ; Peephole 121 jump optimization + cjne %1,%2,%4 + cjne %10,%11,%4 + cjne %12,%13,%4 +%3: +} + +replace { + mov a,#0x01 + cjne %1,%2,%3 + cjne %10,%11,%3 + cjne %12,%13,%3 + cjne %14,%15,%3 + clr a +%3: + jnz %4 +} by { + ; Peephole 122 jump optimization + cjne %1,%2,%4 + cjne %10,%11,%4 + cjne %12,%13,%4 + cjne %14,%15,%4 +%3: +} + +replace { + mov a,#0x01 + cjne %1,%2,%3 + clr a +%3: + jz %4 +} by { + ; Peephole 123 jump optimization + cjne %1,%2,%3 + smp %4 +%3: +} +replace { + mov a,#0x01 + cjne %1,%2,%3 + cjne %10,%11,%3 + clr a +%3: + jz %4 +} by { + ; Peephole 124 jump optimization + cjne %1,%2,%3 + cjne %10,%11,%3 + smp %4 +%3: +} + +replace { + mov a,#0x01 + cjne %1,%2,%3 + cjne %10,%11,%3 + cjne %12,%13,%3 + clr a +%3: + jz %4 +} by { + ; Peephole 125 jump optimization + cjne %1,%2,%3 + cjne %10,%11,%3 + cjne %12,%13,%3 + sjmp %4 +%3: +} + +replace { + mov a,#0x01 + cjne %1,%2,%3 + cjne %10,%11,%3 + cjne %12,%13,%3 + cjne %14,%15,%3 + clr a +%3: + jz %4 +} by { + ; Peephole 126 jump optimization + cjne %1,%2,%3 + cjne %10,%11,%3 + cjne %12,%13,%3 + cjne %14,%15,%3 + sjmp %4 +%3: +} + +replace { + push psw + mov psw,%1 + push bp + mov bp,%2 +%3: + mov %2,bp + pop bp + pop psw + ret +} by { + ; Peephole 127 removed misc sequence + ret +} + +replace { + clr a + rlc a + jz %1 +} by { + ; Peephole 128 jump optimization + jnc %1 +} + +replace { + clr a + rlc a + jnz %1 +} by { + ; Peephole 129 jump optimization + jc %1 +} + +replace { + mov r%1,@r%2 +} by { + ; Peephole 130 changed target address mode r%1 to ar%1 + mov ar%1,@r%2 +} + +replace { + mov a,%1 + subb a,#0x01 + mov %2,a + mov %1,%2 +} by { + ; Peephole 131 optimized decrement (not caring for c) + dec %1 + mov %2,%1 +} + +replace { + ljmp %5 +%1: +} by { + ; Peephole 132 changed ljmp to sjmp + sjmp %5 +%1: +} if labelInRange + +replace { + mov r%1,%2 + mov ar%3,@r%1 + inc r%3 + mov r%4,%2 + mov @r%4,ar%3 +} by { + ; Peephole 133 removed redundant moves + mov r%1,%2 + inc @r%1 + mov ar%3,@r%1 +} + +replace { + mov r%1,%2 + mov ar%3,@r%1 + dec r%3 + mov r%4,%2 + mov @r%4,ar%3 +} by { + ; Peephole 134 removed redundant moves + mov r%1,%2 + dec @r%1 + mov ar%3,@r%1 +} + +replace { + mov r%1,a + mov a,r%2 + orl a,r%1 +} by { + ; Peephole 135 removed redundant mov + mov r%1,a + orl a,r%2 +} + +replace { + mov %1,a + mov dpl,%2 + mov dph,%3 + mov a,%1 +} by { + ; Peephole 136 removed redundant moves + mov %1,a + mov dpl,%2 + mov dph,%3 +} + +replace { + mov b,#0x00 + mov a,%1 + cjne %2,%3,%4 + mov b,#0x01 +%4: + mov a,b + jz %5 +} by { + ; Peephole 137 optimized misc jump sequence + mov a,%1 + cjne %2,%3,%5 +%4: +} + +replace { + mov b,#0x00 + mov a,%1 + cjne %2,%3,%4 + mov b,#0x01 +%4: + mov a,b + jnz %5 +} by { + ; Peephole 138 optimized misc jump sequence + mov a,%1 + cjne %2,%3,%4 + sjmp %5 +%4: +} + +replace { + mov r%1,a + anl ar%1,%2 + mov a,r%1 +} by { + ; Peephole 139 removed redundant mov + anl a,%2 + mov r%1,a +} + +replace { + mov r%1,a + orl ar%1,%2 + mov a,r%1 +} by { + ; Peephole 140 removed redundant mov + orl a,%2 + mov r%1,a } + +replace { + mov r%1,a + xrl ar%1,%2 + mov a,r%1 +} by { + ; Peephole 141 removed redundant mov + xrl a,%2 + mov r%1,a +} + +replace { + mov r%1,a + mov r%2,ar%1 + mov ar%1,@r%2 +} by { + ; Peephole 142 removed redundant moves + mov r%2,a + mov ar%1,@r%2 +} + +replace { + rlc a + mov acc.0,c +} by { + ; Peephole 143 converted rlc to rl + rl a +} + +replace { + rrc a + mov acc.7,c +} by { + ; Peephole 144 converted rrc to rc + rr a +} + +replace { + clr c + addc a,%1 +} by { + ; Peephole 145 changed to add without carry + add a,%1 +} + +replace { + clr c + mov a,%1 + addc a,%2 +} by { + ; Peephole 146 changed to add without carry + mov a,%1 + add a,%2 +} + +replace { + orl r%1,a +} by { + ; Peephole 147 changed target address mode r%1 to ar%1 + orl ar%1,a +} + +replace { + anl r%1,a +} by { + ; Peephole 148 changed target address mode r%1 to ar%1 + anl ar%1,a +} + +replace { + xrl r%1,a +} by { + ; Peephole 149 changed target address mode r%1 to ar%1 + xrl ar%1,a +} + +replace { + mov %1,dpl + mov dpl,%1 +%9: + ret +} by { + ; Peephole 150 removed misc moves via dpl before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov dpl,%1 + mov dph,%2 +%9: + ret +} by { + ; Peephole 151 removed misc moves via dph, dpl before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov dpl,%1 +%9: + ret +} by { + ; Peephole 152 removed misc moves via dph, dpl before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov %3,b + mov dpl,%1 + mov dph,%2 + mov b,%3 +%9: + ret +} by { + ; Peephole 153 removed misc moves via dph, dpl, b before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov %3,b + mov dpl,%1 +%9: + ret +} by { + ; Peephole 154 removed misc moves via dph, dpl, b before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov %3,b + mov dpl,%1 + mov dph,%2 +%9: + ret +} by { + ; Peephole 155 removed misc moves via dph, dpl, b before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov %3,b + mov %4,a + mov dpl,%1 + mov dph,%2 + mov b,%3 + mov a,%4 +%9: + ret +} by { + ; Peephole 156 removed misc moves via dph, dpl, b, a before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov %3,b + mov %4,a + mov dpl,%1 + mov dph,%2 +%9: + ret +} by { + ; Peephole 157 removed misc moves via dph, dpl, b, a before return +%9: + ret +} + +replace { + mov %1,dpl + mov %2,dph + mov %3,b + mov %4,a + mov dpl,%1 +%9: + ret } by { + ; Peephole 158 removed misc moves via dph, dpl, b, a before return +%9: + ret } + +replace { + mov %1,#%2 + xrl %1,#0x80 +} by { + ; Peephole 159 avoided xrl during execution + mov %1,#(%2 ^ 0x80) +} + +replace { + jnc %1 + sjmp %2 +%1: +} by { + ; Peephole 160 removed sjmp by inverse jump logic + jc %2 +%1:} + +replace { + jc %1 + sjmp %2 +%1: +} by { + ; Peephole 161 removed sjmp by inverse jump logic + jnc %2 +%1:} + +replace { + jnz %1 + sjmp %2 +%1: +} by { + ; Peephole 162 removed sjmp by inverse jump logic + jz %2 +%1:} + +replace { + jz %1 + sjmp %2 +%1: +} by { + ; Peephole 163 removed sjmp by inverse jump logic + jnz %2 +%1:} + +replace { + jnb %3,%1 + sjmp %2 +%1: +} by { + ; Peephole 164 removed sjmp by inverse jump logic + jb %3,%2 +%1:} + +replace { + jb %3,%1 + sjmp %2 +%1: +} by { + ; Peephole 165 removed sjmp by inverse jump logic + jnb %3,%2 +%1:} + +replace { + mov %1,%2 + mov %3,%1 + mov %2,%1 +} by { + ; Peephole 166 removed redundant mov + mov %1,%2 + mov %3,%1 } + +replace { + mov c,%1 + cpl c + mov %1,c +} by { + ; Peephole 167 removed redundant bit moves (c not set to %1) + cpl %1 } + +replace { + jnb %1,%2 + sjmp %3 +%2:} by { + ; Peephole 168 jump optimization + jb %1,%3 +%2:} + +replace { + jb %1,%2 + sjmp %3 +%2:} by { + ; Peephole 169 jump optimization + jnb %1,%3 +%2:} + +replace { + clr a + cjne %1,%2,%3 + cpl a +%3: + jz %4 +} by { + ; Peephole 170 jump optimization + cjne %1,%2,%4 +%3:} + +replace { + clr a + cjne %1,%2,%3 + cjne %9,%10,%3 + cpl a +%3: + jz %4 +} by { + ; Peephole 171 jump optimization + cjne %1,%2,%4 + cjne %9,%10,%4 +%3:} + +replace { + clr a + cjne %1,%2,%3 + cjne %9,%10,%3 + cjne %11,%12,%3 + cpl a +%3: + jz %4 +} by { + ; Peephole 172 jump optimization + cjne %1,%2,%4 + cjne %9,%10,%4 + cjne %11,%12,%4 +%3:} + +replace { + clr a + cjne %1,%2,%3 + cjne %9,%10,%3 + cjne %11,%12,%3 + cjne %13,%14,%3 + cpl a +%3: + jz %4 +} by { + ; Peephole 173 jump optimization + cjne %1,%2,%4 + cjne %9,%10,%4 + cjne %11,%12,%4 + cjne %13,%14,%4 +%3:} + +replace { + mov r%1,%2 + clr c + mov a,r%1 + subb a,#0x01 + mov %2,a +} by { + ; Peephole 174 optimized decrement (acc not set to %2, flags undefined) + mov r%1,%2 + dec %2 +} + + +replace { + mov r%1,%2 + mov a,r%1 + add a,#0x01 + mov %2,a +} by { + ; Peephole 175 optimized increment (acc not set to %2, flags undefined) + mov r%1,%2 + inc %2 +} + +replace { + mov %1,@r%2 + inc %1 + mov @r%2,%1 +} by { + ; Peephole 176 optimized increment, removed redundant mov + inc @r%2 + mov %1,@r%2 +} + +replace { + mov %1,%2 + mov %2,%1 +} by { + ; Peephole 177 removed redundant mov + mov %1,%2 +} + +replace { + mov a,%1 + mov b,a + mov a,%2 +} by { + ; Peephole 178 removed redundant mov + mov b,%1 + mov a,%2 +} + +// rules 179-182 provided by : Frieder +// saving 2 byte, 1 cycle +replace { + mov b,#0x00 + mov a,#0x00 +} by { + ; Peephole 179 changed mov to clr + clr a + mov b,a +} + +// saving 1 byte, 0 cycles +replace { + mov a,#0x00 +} by { + ; Peephole 180 changed mov to clr + clr a +} + +// saving 3 byte, 2 cycles, return(NULL) profits here +replace { + mov dpl,#0x00 + mov dph,#0x00 +} by { + ; Peephole 181 used 16 bit load of dptr + mov dptr,#0x0000 +} + +// saving 3 byte, 2 cycles, return(float_constant) profits here +replace { + mov dpl,#%1 + mov dph,#%2 +} by { + ; Peephole 182 used 16 bit load of dptr + mov dptr,#(((%2)<<8) + %1) +} + +replace { + anl %1,#%2 + anl %1,#%3 +} by { + ; Peephole 183 avoided anl during execution + anl %1,#(%2 & %3) +} + +replace { + mov %1,a + cpl a + mov %1,a +} by { + ; Peephole 184 removed redundant mov + cpl a + mov %1,a +} + +replace { +// acc being incremented might cause problems + mov %1,a + inc %1 +} by { + ; Peephole 185 changed order of increment (acc incremented also!) + inc a + mov %1,a +} + +replace { + add a,#%1 + mov dpl,a + clr a + addc a,#(%1 >> 8) + mov dph,a + clr a + movc a,@a+dptr + mov %2,a + inc dptr + clr a + movc a,@a+dptr + mov %3,a + inc dptr + clr a + movc a,@a+dptr + mov %4,a + inc dptr + clr a +} by { + ; Peephole 186.a optimized movc sequence + mov dptr,#%1 + mov b,acc + movc a,@a+dptr + mov %2,a + mov acc,b + inc dptr + movc a,@a+dptr + mov %3,a + mov acc,b + inc dptr + mov %4,a + mov acc,b + inc dptr +} + +replace { + add a,#%1 + mov dpl,a + clr a + addc a,#(%1 >> 8) + mov dph,a + clr a + movc a,@a+dptr + mov %2,a + inc dptr + clr a + movc a,@a+dptr + mov %3,a + inc dptr + clr a +} by { + ; Peephole 186.b optimized movc sequence + mov dptr,#%1 + mov b,acc + movc a,@a+dptr + mov %2,a + mov acc,b + inc dptr + movc a,@a+dptr + mov %3,a + mov acc,b + inc dptr +} + +replace { + add a,#%1 + mov dpl,a + clr a + addc a,#(%1 >> 8) + mov dph,a + clr a + movc a,@a+dptr + mov %2,a + inc dptr + clr a +} by { + ; Peephole 186.c optimized movc sequence + mov dptr,#%1 + mov b,acc + movc a,@a+dptr + mov %2,a + mov acc,b + inc dptr +} + +replace { + add a,#%1 + mov dpl,a + clr a + addc a,#(%1 >> 8) + mov dph,a + clr a + movc a,@a+dptr +} by { + ; Peephole 186 optimized movc sequence + mov dptr,#%1 + movc a,@a+dptr +} + +replace { + mov r%1,%2 + anl ar%1,#%3 + mov a,r%1 +} by { + ; Peephole 187 used a instead of ar%1 for anl + mov a,%2 + anl a,#%3 + mov r%1,a +} + +replace { + mov %1,a + mov dptr,%2 + movc a,@a+dptr + mov %1,a +} by { + ; Peephole 188 removed redundant mov + mov dptr,%2 + movc a,@a+dptr + mov %1,a +} + +replace { + anl a,#0x0f + mov %1,a + mov a,#0x0f + anl a,%1 +} by { + ; Peephole 189 removed redundant mov and anl + anl a,#0x0f + mov %1,a +} + +// rules 190 & 191 need to be in order +replace { + mov a,%1 + lcall __gptrput + mov a,%1 +} by { + ; Peephole 190 removed redundant mov + mov a,%1 + lcall __gptrput +} + +replace { + mov %1,a + mov dpl,%2 + mov dph,%3 + mov b,%4 + mov a,%1 +} by { + ; Peephole 191 removed redundant mov + mov %1,a + mov dpl,%2 + mov dph,%3 + mov b,%4 +} + +replace { + mov r%1,a + mov @r%2,ar%1 +} by { + ; Peephole 192 used a instead of ar%1 as source + mov r%1,a + mov @r%2,a +} + +replace { + jnz %3 + mov a,%4 + jnz %3 + mov a,%9 + jnz %3 + mov a,%12 + cjne %13,%14,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 193.a optimized misc jump sequence + jnz %8 + mov a,%4 + jnz %8 + mov a,%9 + jnz %8 + mov a,%12 + cjne %13,%14,%8 + sjmp %7 +%3: +} + +replace { + cjne %1,%2,%3 + mov a,%4 + cjne %5,%6,%3 + mov a,%9 + cjne %10,%11,%3 + mov a,%12 + cjne %13,%14,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 193 optimized misc jump sequence + cjne %1,%2,%8 + mov a,%4 + cjne %5,%6,%8 + mov a,%9 + cjne %10,%11,%8 + mov a,%12 + cjne %13,%14,%8 + sjmp %7 +%3: +} + +replace { + cjne %1,%2,%3 + cjne %5,%6,%3 + cjne %10,%11,%3 + cjne %13,%14,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 194 optimized misc jump sequence + cjne %1,%2,%8 + cjne %5,%6,%8 + cjne %10,%11,%8 + cjne %13,%14,%8 + sjmp %7 +%3: +} + +replace { + jnz %3 + mov a,%4 + jnz %3 + mov a,%9 + cjne %10,%11,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 195.a optimized misc jump sequence + jnz %8 + mov a,%4 + jnz %8 + mov a,%9 + cjne %10,%11,%8 + sjmp %7 +%3: +} + +replace { + cjne %1,%2,%3 + mov a,%4 + cjne %5,%6,%3 + mov a,%9 + cjne %10,%11,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 195 optimized misc jump sequence + cjne %1,%2,%8 + mov a,%4 + cjne %5,%6,%8 + mov a,%9 + cjne %10,%11,%8 + sjmp %7 +%3: +} + +replace { + cjne %1,%2,%3 + cjne %5,%6,%3 + cjne %10,%11,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 196 optimized misc jump sequence + cjne %1,%2,%8 + cjne %5,%6,%8 + cjne %10,%11,%8 + sjmp %7 +%3: +} + +replace { + jnz %3 + mov a,%4 + cjne %5,%6,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 197.a optimized misc jump sequence + jnz %8 + mov a,%4 + cjne %5,%6,%8 + sjmp %7 +%3: +} + +replace { + cjne %1,%2,%3 + mov a,%4 + cjne %5,%6,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 197 optimized misc jump sequence + cjne %1,%2,%8 + mov a,%4 + cjne %5,%6,%8 + sjmp %7 +%3: +} + +replace { + cjne %1,%2,%3 + cjne %5,%6,%3 + sjmp %7 +%3: + sjmp %8 +} by { + ; Peephole 198 optimized misc jump sequence + cjne %1,%2,%8 + cjne %5,%6,%8 + sjmp %7 +%3: +} + +replace { + cjne %1,%2,%3 + sjmp %4 +%3: + sjmp %5 +} by { + ; Peephole 199 optimized misc jump sequence + cjne %1,%2,%5 + sjmp %4 +%3: +} + +replace { + sjmp %1 +%1: +} by { + ; Peephole 200 removed redundant sjmp +%1: +} + +replace { + sjmp %1 +%2: +%1: +} by { + ; Peephole 201 removed redundant sjmp +%2: +%1: +} + +replace { + push acc + mov dptr,%1 + pop acc +} by { + ; Peephole 202 removed redundant push pop + mov dptr,%1 +} + +replace { + mov r%1,_spx + lcall %2 + mov r%1,_spx +} by { + ; Peephole 203 removed mov r%1,_spx + lcall %2 +} + +replace { + mov %1,a + add a,acc + mov %1,a +} by { + ; Peephole 204 removed redundant mov + add a,acc + mov %1,a +} + +replace { + djnz %1,%2 + sjmp %3 +%2: + sjmp %4 +%3: +} by { + ; Peephole 205 optimized misc jump sequence + djnz %1,%4 +%2: +%3: +} + +replace { + mov %1,%1 +} by { + ; Peephole 206 removed redundant mov %1,%1 +} + +replace { + mov a,_bp + add a,#0x00 + mov %1,a +} by { + ; Peephole 207 removed zero add (acc not set to %1, flags undefined) + mov %1,_bp +} + +replace { + push acc + mov r%1,_bp + pop acc +} by { + ; Peephole 208 removed redundant push pop + mov r%1,_bp +} + +replace { + mov a,_bp + add a,#0x00 + inc a + mov %1,a +} by { + ; Peephole 209 optimized increment (acc not set to %1, flags undefined) + mov %1,_bp + inc %1 +} + +replace { + mov dptr,#((((%1 >> 8)) <<8) + %1) +} by { + ; Peephole 210 simplified expression + mov dptr,#%1 +} + +replace { + push %1 + pop %1 +} by { + ; Peephole 211 removed redundant push %1 pop %1 +} + +replace { + mov a,_bp + add a,#0x01 + mov r%1,a +} by { + ; Peephole 212 reduced add sequence to inc + mov r%1,_bp + inc r%1 +} + +replace { + mov %1,#(( %2 >> 8 ) ^ 0x80) +} by { + mov %1,#(%2 >> 8) + xrl %1,#0x80 +} + +replace { + mov %1,#(( %2 + %3 >> 8 ) ^ 0x80) +} by { + mov %1,#((%2 + %3) >> 8) + xrl %1,#0x80 +} + +replace { + mov %1,a + mov a,%2 + add a,%1 +} by { + ; Peephole 214 reduced some extra movs + mov %1,a + add a,%2 +} if operandsNotSame + +replace { + mov %1,a + add a,%2 + mov %1,a +} by { + ; Peephole 215 removed some movs + add a,%2 + mov %1,a +} if operandsNotSame + +replace { + mov r%1,%2 + clr a + inc r%1 + mov @r%1,a + dec r%1 + mov @r%1,a +} by { + ; Peephole 216 simplified clear (2bytes) + mov r%1,%2 + clr a + mov @r%1,a + inc r%1 + mov @r%1,a +} + +replace { + mov r%1,%2 + clr a + inc r%1 + inc r%1 + mov @r%1,a + dec r%1 + mov @r%1,a + dec r%1 + mov @r%1,a +} by { + ; Peephole 217 simplified clear (3bytes) + mov r%1,%2 + clr a + mov @r%1,a + inc r%1 + mov @r%1,a + inc r%1 + mov @r%1,a +} + +replace { + mov r%1,%2 + clr a + inc r%1 + inc r%1 + inc r%1 + mov @r%1,a + dec r%1 + mov @r%1,a + dec r%1 + mov @r%1,a + dec r%1 + mov @r%1,a +} by { + ; Peephole 218 simplified clear (4bytes) + mov r%1,%2 + clr a + mov @r%1,a + inc r%1 + mov @r%1,a + inc r%1 + mov @r%1,a + inc r%1 + mov @r%1,a +} diff --git a/src/SDCCpeeph.h b/src/SDCCpeeph.h new file mode 100644 index 00000000..23b4a451 --- /dev/null +++ b/src/SDCCpeeph.h @@ -0,0 +1,56 @@ +/*------------------------------------------------------------------------- + SDCCpeeph.h - Header file for The peep hole optimizer: for interpreting + the peep hole rules + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCCPEEPH_H +#define SDCCPEEPH_H 1 + +#define MAX_PATTERN_LEN 128 + +typedef struct lineNode +{ + char *line ; + unsigned int isInline:1; + unsigned int isComment:1; + unsigned int isDebug:1; + struct lineNode *prev; + struct lineNode *next; +} lineNode; + +typedef struct peepRule +{ + lineNode *match ; + lineNode *replace ; + unsigned int restart : 1; + char *cond; + hTab *vars; + struct peepRule *next; +} peepRule; + +void printLine (lineNode *,FILE *); +lineNode *newLineNode (char *); +lineNode *connectLine (lineNode *,lineNode *); +void peepHole (lineNode **); + +#endif diff --git a/src/SDCCpeeph.rul b/src/SDCCpeeph.rul new file mode 100644 index 00000000..b6127c7c --- /dev/null +++ b/src/SDCCpeeph.rul @@ -0,0 +1,1602 @@ +/* Generated file DO NOT Edit */ +/* To Make changes to rules */ +/* edit file SDCCpeeph.def */ +"\n" +"\n" +"replace restart {\n" +" xch a,%1\n" +" xch a,%1\n" +"} by {\n" +" ; Peephole 2.a removed redundant xch xch\n" +"}\n" +"\n" +"replace restart {\n" +" mov %1,#0x00\n" +" mov a,#0x00\n" +"} by {\n" +" ; Peephole 3.a changed mov to clr\n" +" clr a\n" +" mov %1,a\n" +"}\n" +"\n" +"replace restart {\n" +" mov %1,#0x00\n" +" clr a\n" +"} by {\n" +" ; Peephole 3.b changed mov to clr\n" +" clr a\n" +" mov %1,a\n" +"}\n" +"\n" +"replace restart {\n" +" mov %1,#0x00\n" +" mov %2,#0x00\n" +" mov a,%3\n" +"} by {\n" +" ; Peephole 3.c changed mov to clr\n" +" clr a\n" +" mov %1,a\n" +" mov %2,a\n" +" mov a,%3\n" +"}\n" +"\n" +"\n" +"\n" +"replace {\n" +" mov %1,a\n" +" mov dptr,#%2\n" +" mov a,%1\n" +" movx @dptr,a\n" +"} by {\n" +" ; Peephole 100 removed redundant mov\n" +" mov %1,a\n" +" mov dptr,#%2\n" +" movx @dptr,a\n" +"}\n" +"\n" +"replace {\n" +" mov a,acc\n" +"} by {\n" +" ; Peephole 100.a removed redundant mov\n" +"}\n" +"\n" +"replace {\n" +" mov a,%1\n" +" movx @dptr,a\n" +" inc dptr\n" +" mov a,%1\n" +" movx @dptr,a\n" +"} by {\n" +" ; Peephole 101 removed redundant mov\n" +" mov a,%1\n" +" movx @dptr,a\n" +" inc dptr\n" +" movx @dptr,a\n" +"}\n" +"\n" +"replace {\n" +" mov %1,%2\n" +" ljmp %3\n" +"%4:\n" +" mov %1,%5\n" +"%3:\n" +" mov dpl,%1\n" +"%7:\n" +" mov sp,bp\n" +" pop bp\n" +"} by {\n" +" ; Peephole 102 removed redundant mov\n" +" mov dpl,%2\n" +" ljmp %3\n" +"%4:\n" +" mov dpl,%5\n" +"%3:\n" +"%7:\n" +" mov sp,bp\n" +" pop bp\n" +"}\n" +"\n" +"replace {\n" +" mov %1,%2\n" +" ljmp %3\n" +"%4:\n" +" mov a%1,%5\n" +"%3:\n" +" mov dpl,%1\n" +"%7:\n" +" mov sp,bp\n" +" pop bp\n" +"} by {\n" +" ; Peephole 103 removed redundant mov\n" +" mov dpl,%2\n" +" ljmp %3\n" +"%4:\n" +" mov dpl,%5\n" +"%3:\n" +"%7:\n" +" mov sp,bp\n" +" pop bp\n" +"}\n" +"\n" +"replace {\n" +" mov a,bp\n" +" clr c\n" +" add a,#0x01\n" +" mov r%1,a\n" +"} by {\n" +" ; Peephole 104 optimized increment (acc not set to r%1, flags undefined)\n" +" mov r%1,bp\n" +" inc r%1\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" mov a,%1\n" +"} by {\n" +" ; Peephole 105 removed redundant mov\n" +" mov %1,a\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" clr c\n" +" mov a,%1\n" +"} by {\n" +" ; Peephole 106 removed redundant mov \n" +" mov %1,a\n" +" clr c\n" +"}\n" +"\n" +"replace {\n" +" ljmp %1\n" +"%1:\n" +"} by {\n" +" ; Peephole 107 removed redundant ljmp\n" +"%1:\n" +"}\n" +"\n" +"replace {\n" +" jc %1\n" +" ljmp %5\n" +"%1:\n" +"} by {\n" +" ; Peephole 108 removed ljmp by inverse jump logic\n" +" jnc %5\n" +"%1:\n" +"} if labelInRange\n" +"\n" +"replace {\n" +" jz %1\n" +" ljmp %5\n" +"%1:\n" +"} by {\n" +" ; Peephole 109 removed ljmp by inverse jump logic\n" +" jnz %5\n" +"%1:\n" +"} if labelInRange\n" +"\n" +"replace {\n" +" jnz %1\n" +" ljmp %5\n" +"%1:\n" +"} by {\n" +" ; Peephole 110 removed ljmp by inverse jump logic\n" +" jz %5\n" +"%1:\n" +"} if labelInRange\n" +"\n" +"replace {\n" +" jb %1,%2\n" +" ljmp %5\n" +"%2:\n" +"} by {\n" +" ; Peephole 111 removed ljmp by inverse jump logic\n" +" jnb %1,%5\n" +"%2:\n" +"} if labelInRange\n" +"\n" +"replace {\n" +" jnb %1,%2\n" +" ljmp %5\n" +"%2:\n" +"} by {\n" +" ; Peephole 112 removed ljmp by inverse jump logic\n" +" jb %1,%5\n" +"%2:\n" +"} if labelInRange\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cpl a\n" +"%3:\n" +" rrc a\n" +" mov %4,c\n" +"} by {\n" +" ; Peephole 113 optimized misc sequence\n" +" clr %4\n" +" cjne %1,%2,%3\n" +" setb %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" cpl a\n" +"%3:\n" +" rrc a\n" +" mov %4,c\n" +"} by {\n" +" ; Peephole 114 optimized misc sequence\n" +" clr %4\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" setb %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cpl a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 115 jump optimization \n" +" cjne %1,%2,%3\n" +" sjmp %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cpl a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 116 jump optimization\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" sjmp %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cjne %11,%12,%3\n" +" cpl a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 117 jump optimization\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cjne %11,%12,%3\n" +" sjmp %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cjne %11,%12,%3\n" +" cjne %13,%14,%3\n" +" cpl a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 118 jump optimization\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cjne %11,%12,%3\n" +" cjne %13,%14,%3\n" +" sjmp %4\n" +"%3:\n" +"}\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" clr a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 119 jump optimization\n" +" cjne %1,%2,%4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" clr a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 120 jump optimization\n" +" cjne %1,%2,%4\n" +" cjne %10,%11,%4\n" +"%3:\n" +"}\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" cjne %12,%13,%3\n" +" clr a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 121 jump optimization\n" +" cjne %1,%2,%4\n" +" cjne %10,%11,%4\n" +" cjne %12,%13,%4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" cjne %12,%13,%3\n" +" cjne %14,%15,%3\n" +" clr a\n" +"%3:\n" +" jnz %4\n" +"} by {\n" +" ; Peephole 122 jump optimization\n" +" cjne %1,%2,%4\n" +" cjne %10,%11,%4\n" +" cjne %12,%13,%4\n" +" cjne %14,%15,%4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" clr a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 123 jump optimization\n" +" cjne %1,%2,%3\n" +" smp %4\n" +"%3:\n" +"}\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" clr a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 124 jump optimization\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" smp %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" cjne %12,%13,%3\n" +" clr a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 125 jump optimization\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" cjne %12,%13,%3\n" +" sjmp %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" mov a,#0x01\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" cjne %12,%13,%3\n" +" cjne %14,%15,%3\n" +" clr a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 126 jump optimization\n" +" cjne %1,%2,%3\n" +" cjne %10,%11,%3\n" +" cjne %12,%13,%3\n" +" cjne %14,%15,%3\n" +" sjmp %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" push psw\n" +" mov psw,%1\n" +" push bp\n" +" mov bp,%2\n" +"%3:\n" +" mov %2,bp\n" +" pop bp\n" +" pop psw\n" +" ret\n" +"} by {\n" +" ; Peephole 127 removed misc sequence\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" clr a\n" +" rlc a\n" +" jz %1\n" +"} by {\n" +" ; Peephole 128 jump optimization\n" +" jnc %1\n" +"}\n" +"\n" +"replace {\n" +" clr a\n" +" rlc a\n" +" jnz %1\n" +"} by {\n" +" ; Peephole 129 jump optimization\n" +" jc %1\n" +"}\n" +"\n" +"replace { \n" +" mov r%1,@r%2\n" +"} by {\n" +" ; Peephole 130 changed target address mode r%1 to ar%1\n" +" mov ar%1,@r%2\n" +"}\n" +"\n" +"replace { \n" +" mov a,%1\n" +" subb a,#0x01\n" +" mov %2,a\n" +" mov %1,%2\n" +"} by {\n" +" ; Peephole 131 optimized decrement (not caring for c)\n" +" dec %1 \n" +" mov %2,%1 \n" +"}\n" +"\n" +"replace {\n" +" ljmp %5\n" +"%1:\n" +"} by {\n" +" ; Peephole 132 changed ljmp to sjmp\n" +" sjmp %5\n" +"%1:\n" +"} if labelInRange\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" mov ar%3,@r%1\n" +" inc r%3\n" +" mov r%4,%2\n" +" mov @r%4,ar%3\n" +"} by {\n" +" ; Peephole 133 removed redundant moves\n" +" mov r%1,%2\n" +" inc @r%1\n" +" mov ar%3,@r%1\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" mov ar%3,@r%1\n" +" dec r%3\n" +" mov r%4,%2\n" +" mov @r%4,ar%3\n" +"} by {\n" +" ; Peephole 134 removed redundant moves\n" +" mov r%1,%2\n" +" dec @r%1\n" +" mov ar%3,@r%1\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,a\n" +" mov a,r%2\n" +" orl a,r%1\n" +"} by {\n" +" ; Peephole 135 removed redundant mov\n" +" mov r%1,a\n" +" orl a,r%2\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" mov dpl,%2\n" +" mov dph,%3\n" +" mov a,%1\n" +"} by {\n" +" ; Peephole 136 removed redundant moves\n" +" mov %1,a\n" +" mov dpl,%2\n" +" mov dph,%3\n" +"}\n" +"\n" +"replace {\n" +" mov b,#0x00\n" +" mov a,%1\n" +" cjne %2,%3,%4\n" +" mov b,#0x01\n" +"%4:\n" +" mov a,b\n" +" jz %5\n" +"} by {\n" +" ; Peephole 137 optimized misc jump sequence\n" +" mov a,%1\n" +" cjne %2,%3,%5\n" +"%4:\n" +"}\n" +"\n" +"replace {\n" +" mov b,#0x00\n" +" mov a,%1\n" +" cjne %2,%3,%4\n" +" mov b,#0x01\n" +"%4:\n" +" mov a,b\n" +" jnz %5\n" +"} by {\n" +" ; Peephole 138 optimized misc jump sequence\n" +" mov a,%1\n" +" cjne %2,%3,%4\n" +" sjmp %5\n" +"%4:\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,a\n" +" anl ar%1,%2\n" +" mov a,r%1\n" +"} by {\n" +" ; Peephole 139 removed redundant mov\n" +" anl a,%2\n" +" mov r%1,a\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,a\n" +" orl ar%1,%2\n" +" mov a,r%1\n" +"} by {\n" +" ; Peephole 140 removed redundant mov\n" +" orl a,%2\n" +" mov r%1,a }\n" +"\n" +"replace {\n" +" mov r%1,a\n" +" xrl ar%1,%2\n" +" mov a,r%1\n" +"} by {\n" +" ; Peephole 141 removed redundant mov\n" +" xrl a,%2\n" +" mov r%1,a\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,a\n" +" mov r%2,ar%1\n" +" mov ar%1,@r%2\n" +"} by {\n" +" ; Peephole 142 removed redundant moves\n" +" mov r%2,a\n" +" mov ar%1,@r%2\n" +"}\n" +"\n" +"replace {\n" +" rlc a\n" +" mov acc.0,c\n" +"} by {\n" +" ; Peephole 143 converted rlc to rl\n" +" rl a\n" +"}\n" +"\n" +"replace {\n" +" rrc a\n" +" mov acc.7,c\n" +"} by {\n" +" ; Peephole 144 converted rrc to rc\n" +" rr a\n" +"}\n" +"\n" +"replace {\n" +" clr c\n" +" addc a,%1\n" +"} by {\n" +" ; Peephole 145 changed to add without carry \n" +" add a,%1\n" +"}\n" +"\n" +"replace {\n" +" clr c\n" +" mov a,%1\n" +" addc a,%2\n" +"} by {\n" +" ; Peephole 146 changed to add without carry\n" +" mov a,%1\n" +" add a,%2\n" +"}\n" +"\n" +"replace {\n" +" orl r%1,a\n" +"} by {\n" +" ; Peephole 147 changed target address mode r%1 to ar%1\n" +" orl ar%1,a\n" +"}\n" +"\n" +"replace {\n" +" anl r%1,a\n" +"} by {\n" +" ; Peephole 148 changed target address mode r%1 to ar%1\n" +" anl ar%1,a\n" +"}\n" +"\n" +"replace {\n" +" xrl r%1,a\n" +"} by {\n" +" ; Peephole 149 changed target address mode r%1 to ar%1\n" +" xrl ar%1,a\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov dpl,%1\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 150 removed misc moves via dpl before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov dpl,%1\n" +" mov dph,%2\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 151 removed misc moves via dph, dpl before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov dpl,%1\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 152 removed misc moves via dph, dpl before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov %3,b\n" +" mov dpl,%1\n" +" mov dph,%2\n" +" mov b,%3\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 153 removed misc moves via dph, dpl, b before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov %3,b\n" +" mov dpl,%1\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 154 removed misc moves via dph, dpl, b before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov %3,b\n" +" mov dpl,%1\n" +" mov dph,%2\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 155 removed misc moves via dph, dpl, b before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov %3,b\n" +" mov %4,a\n" +" mov dpl,%1\n" +" mov dph,%2\n" +" mov b,%3\n" +" mov a,%4\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 156 removed misc moves via dph, dpl, b, a before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov %3,b\n" +" mov %4,a\n" +" mov dpl,%1\n" +" mov dph,%2\n" +"%9:\n" +" ret\n" +"} by {\n" +" ; Peephole 157 removed misc moves via dph, dpl, b, a before return\n" +"%9:\n" +" ret\n" +"}\n" +"\n" +"replace {\n" +" mov %1,dpl\n" +" mov %2,dph\n" +" mov %3,b\n" +" mov %4,a\n" +" mov dpl,%1\n" +"%9:\n" +" ret } by {\n" +" ; Peephole 158 removed misc moves via dph, dpl, b, a before return\n" +"%9:\n" +" ret }\n" +"\n" +"replace {\n" +" mov %1,#%2\n" +" xrl %1,#0x80\n" +"} by {\n" +" ; Peephole 159 avoided xrl during execution\n" +" mov %1,#(%2 ^ 0x80)\n" +"}\n" +"\n" +"replace {\n" +" jnc %1\n" +" sjmp %2\n" +"%1:\n" +"} by {\n" +" ; Peephole 160 removed sjmp by inverse jump logic\n" +" jc %2\n" +"%1:}\n" +"\n" +"replace {\n" +" jc %1\n" +" sjmp %2\n" +"%1:\n" +"} by {\n" +" ; Peephole 161 removed sjmp by inverse jump logic\n" +" jnc %2\n" +"%1:}\n" +"\n" +"replace {\n" +" jnz %1\n" +" sjmp %2\n" +"%1:\n" +"} by {\n" +" ; Peephole 162 removed sjmp by inverse jump logic\n" +" jz %2\n" +"%1:}\n" +"\n" +"replace {\n" +" jz %1\n" +" sjmp %2\n" +"%1:\n" +"} by {\n" +" ; Peephole 163 removed sjmp by inverse jump logic\n" +" jnz %2\n" +"%1:}\n" +"\n" +"replace {\n" +" jnb %3,%1\n" +" sjmp %2\n" +"%1:\n" +"} by {\n" +" ; Peephole 164 removed sjmp by inverse jump logic\n" +" jb %3,%2\n" +"%1:}\n" +"\n" +"replace {\n" +" jb %3,%1\n" +" sjmp %2\n" +"%1:\n" +"} by {\n" +" ; Peephole 165 removed sjmp by inverse jump logic\n" +" jnb %3,%2\n" +"%1:}\n" +"\n" +"replace {\n" +" mov %1,%2\n" +" mov %3,%1\n" +" mov %2,%1\n" +"} by {\n" +" ; Peephole 166 removed redundant mov\n" +" mov %1,%2\n" +" mov %3,%1 }\n" +"\n" +"replace {\n" +" mov c,%1\n" +" cpl c\n" +" mov %1,c\n" +"} by {\n" +" ; Peephole 167 removed redundant bit moves (c not set to %1)\n" +" cpl %1 }\n" +"\n" +"replace {\n" +" jnb %1,%2\n" +" sjmp %3\n" +"%2:} by {\n" +" ; Peephole 168 jump optimization\n" +" jb %1,%3\n" +"%2:}\n" +"\n" +"replace {\n" +" jb %1,%2\n" +" sjmp %3\n" +"%2:} by {\n" +" ; Peephole 169 jump optimization\n" +" jnb %1,%3\n" +"%2:}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cpl a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 170 jump optimization\n" +" cjne %1,%2,%4\n" +"%3:}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cpl a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 171 jump optimization\n" +" cjne %1,%2,%4\n" +" cjne %9,%10,%4\n" +"%3:}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cjne %11,%12,%3\n" +" cpl a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 172 jump optimization\n" +" cjne %1,%2,%4\n" +" cjne %9,%10,%4\n" +" cjne %11,%12,%4\n" +"%3:}\n" +"\n" +"replace {\n" +" clr a\n" +" cjne %1,%2,%3\n" +" cjne %9,%10,%3\n" +" cjne %11,%12,%3\n" +" cjne %13,%14,%3\n" +" cpl a\n" +"%3:\n" +" jz %4\n" +"} by {\n" +" ; Peephole 173 jump optimization\n" +" cjne %1,%2,%4\n" +" cjne %9,%10,%4\n" +" cjne %11,%12,%4\n" +" cjne %13,%14,%4\n" +"%3:}\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" clr c\n" +" mov a,r%1\n" +" subb a,#0x01\n" +" mov %2,a\n" +"} by {\n" +" ; Peephole 174 optimized decrement (acc not set to %2, flags undefined)\n" +" mov r%1,%2\n" +" dec %2\n" +"}\n" +"\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" mov a,r%1\n" +" add a,#0x01\n" +" mov %2,a\n" +"} by {\n" +" ; Peephole 175 optimized increment (acc not set to %2, flags undefined)\n" +" mov r%1,%2\n" +" inc %2\n" +"}\n" +"\n" +"replace {\n" +" mov %1,@r%2\n" +" inc %1\n" +" mov @r%2,%1\n" +"} by {\n" +" ; Peephole 176 optimized increment, removed redundant mov\n" +" inc @r%2\n" +" mov %1,@r%2\n" +"}\n" +"\n" +"replace {\n" +" mov %1,%2\n" +" mov %2,%1\n" +"} by {\n" +" ; Peephole 177 removed redundant mov\n" +" mov %1,%2\n" +"}\n" +"\n" +"replace {\n" +" mov a,%1\n" +" mov b,a\n" +" mov a,%2\n" +"} by {\n" +" ; Peephole 178 removed redundant mov\n" +" mov b,%1\n" +" mov a,%2\n" +"}\n" +"\n" +"replace {\n" +" mov b,#0x00\n" +" mov a,#0x00\n" +"} by {\n" +" ; Peephole 179 changed mov to clr\n" +" clr a\n" +" mov b,a\n" +"}\n" +"\n" +"replace {\n" +" mov a,#0x00\n" +"} by {\n" +" ; Peephole 180 changed mov to clr\n" +" clr a\n" +"}\n" +"\n" +"replace {\n" +" mov dpl,#0x00\n" +" mov dph,#0x00\n" +"} by {\n" +" ; Peephole 181 used 16 bit load of dptr\n" +" mov dptr,#0x0000\n" +"}\n" +"\n" +"replace {\n" +" mov dpl,#%1\n" +" mov dph,#%2\n" +"} by {\n" +" ; Peephole 182 used 16 bit load of dptr\n" +" mov dptr,#(((%2)<<8) + %1)\n" +"}\n" +"\n" +"replace {\n" +" anl %1,#%2\n" +" anl %1,#%3\n" +"} by {\n" +" ; Peephole 183 avoided anl during execution\n" +" anl %1,#(%2 & %3)\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" cpl a\n" +" mov %1,a\n" +"} by {\n" +" ; Peephole 184 removed redundant mov\n" +" cpl a\n" +" mov %1,a\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" inc %1\n" +"} by {\n" +" ; Peephole 185 changed order of increment (acc incremented also!)\n" +" inc a\n" +" mov %1,a\n" +"}\n" +"\n" +"replace {\n" +" add a,#%1\n" +" mov dpl,a\n" +" clr a\n" +" addc a,#(%1 >> 8)\n" +" mov dph,a\n" +" clr a\n" +" movc a,@a+dptr\n" +" mov %2,a\n" +" inc dptr\n" +" clr a\n" +" movc a,@a+dptr\n" +" mov %3,a\n" +" inc dptr\n" +" clr a\n" +" movc a,@a+dptr\n" +" mov %4,a\n" +" inc dptr\n" +" clr a \n" +"} by {\n" +" ; Peephole 186.a optimized movc sequence\n" +" mov dptr,#%1\n" +" mov b,acc\n" +" movc a,@a+dptr\n" +" mov %2,a\n" +" mov acc,b\n" +" inc dptr \n" +" movc a,@a+dptr\n" +" mov %3,a\n" +" mov acc,b\n" +" inc dptr\n" +" mov %4,a\n" +" mov acc,b\n" +" inc dptr\n" +"}\n" +"\n" +"replace {\n" +" add a,#%1\n" +" mov dpl,a\n" +" clr a\n" +" addc a,#(%1 >> 8)\n" +" mov dph,a\n" +" clr a\n" +" movc a,@a+dptr\n" +" mov %2,a\n" +" inc dptr\n" +" clr a\n" +" movc a,@a+dptr\n" +" mov %3,a\n" +" inc dptr\n" +" clr a\n" +"} by {\n" +" ; Peephole 186.b optimized movc sequence\n" +" mov dptr,#%1\n" +" mov b,acc\n" +" movc a,@a+dptr\n" +" mov %2,a\n" +" mov acc,b\n" +" inc dptr \n" +" movc a,@a+dptr\n" +" mov %3,a\n" +" mov acc,b\n" +" inc dptr \n" +"}\n" +"\n" +"replace {\n" +" add a,#%1\n" +" mov dpl,a\n" +" clr a\n" +" addc a,#(%1 >> 8)\n" +" mov dph,a\n" +" clr a\n" +" movc a,@a+dptr\n" +" mov %2,a\n" +" inc dptr\n" +" clr a\n" +"} by {\n" +" ; Peephole 186.c optimized movc sequence\n" +" mov dptr,#%1\n" +" mov b,acc\n" +" movc a,@a+dptr\n" +" mov %2,a\n" +" mov acc,b\n" +" inc dptr\n" +"}\n" +"\n" +"replace {\n" +" add a,#%1\n" +" mov dpl,a\n" +" clr a\n" +" addc a,#(%1 >> 8)\n" +" mov dph,a\n" +" clr a\n" +" movc a,@a+dptr\n" +"} by {\n" +" ; Peephole 186 optimized movc sequence\n" +" mov dptr,#%1\n" +" movc a,@a+dptr\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" anl ar%1,#%3\n" +" mov a,r%1\n" +"} by {\n" +" ; Peephole 187 used a instead of ar%1 for anl\n" +" mov a,%2\n" +" anl a,#%3\n" +" mov r%1,a\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" mov dptr,%2\n" +" movc a,@a+dptr\n" +" mov %1,a\n" +"} by {\n" +" ; Peephole 188 removed redundant mov\n" +" mov dptr,%2\n" +" movc a,@a+dptr\n" +" mov %1,a\n" +"}\n" +"\n" +"replace {\n" +" anl a,#0x0f\n" +" mov %1,a\n" +" mov a,#0x0f\n" +" anl a,%1\n" +"} by {\n" +" ; Peephole 189 removed redundant mov and anl\n" +" anl a,#0x0f\n" +" mov %1,a\n" +"}\n" +"\n" +"replace {\n" +" mov a,%1\n" +" lcall __gptrput\n" +" mov a,%1\n" +"} by {\n" +" ; Peephole 190 removed redundant mov\n" +" mov a,%1\n" +" lcall __gptrput\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" mov dpl,%2\n" +" mov dph,%3\n" +" mov b,%4\n" +" mov a,%1\n" +"} by {\n" +" ; Peephole 191 removed redundant mov\n" +" mov %1,a\n" +" mov dpl,%2\n" +" mov dph,%3\n" +" mov b,%4\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,a\n" +" mov @r%2,ar%1\n" +"} by {\n" +" ; Peephole 192 used a instead of ar%1 as source\n" +" mov r%1,a\n" +" mov @r%2,a\n" +"}\n" +"\n" +"replace {\n" +" jnz %3\n" +" mov a,%4\n" +" jnz %3\n" +" mov a,%9\n" +" jnz %3\n" +" mov a,%12\n" +" cjne %13,%14,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 193.a optimized misc jump sequence\n" +" jnz %8\n" +" mov a,%4\n" +" jnz %8\n" +" mov a,%9\n" +" jnz %8\n" +" mov a,%12\n" +" cjne %13,%14,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" cjne %1,%2,%3\n" +" mov a,%4\n" +" cjne %5,%6,%3\n" +" mov a,%9\n" +" cjne %10,%11,%3\n" +" mov a,%12\n" +" cjne %13,%14,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 193 optimized misc jump sequence\n" +" cjne %1,%2,%8\n" +" mov a,%4\n" +" cjne %5,%6,%8\n" +" mov a,%9\n" +" cjne %10,%11,%8\n" +" mov a,%12\n" +" cjne %13,%14,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" cjne %1,%2,%3\n" +" cjne %5,%6,%3\n" +" cjne %10,%11,%3\n" +" cjne %13,%14,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 194 optimized misc jump sequence\n" +" cjne %1,%2,%8\n" +" cjne %5,%6,%8\n" +" cjne %10,%11,%8\n" +" cjne %13,%14,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" jnz %3\n" +" mov a,%4\n" +" jnz %3\n" +" mov a,%9\n" +" cjne %10,%11,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 195.a optimized misc jump sequence\n" +" jnz %8\n" +" mov a,%4\n" +" jnz %8\n" +" mov a,%9\n" +" cjne %10,%11,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" cjne %1,%2,%3\n" +" mov a,%4\n" +" cjne %5,%6,%3\n" +" mov a,%9\n" +" cjne %10,%11,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 195 optimized misc jump sequence\n" +" cjne %1,%2,%8\n" +" mov a,%4\n" +" cjne %5,%6,%8\n" +" mov a,%9\n" +" cjne %10,%11,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" cjne %1,%2,%3\n" +" cjne %5,%6,%3\n" +" cjne %10,%11,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 196 optimized misc jump sequence\n" +" cjne %1,%2,%8\n" +" cjne %5,%6,%8\n" +" cjne %10,%11,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" jnz %3\n" +" mov a,%4\n" +" cjne %5,%6,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8 \n" +"} by {\n" +" ; Peephole 197.a optimized misc jump sequence\n" +" jnz %8\n" +" mov a,%4\n" +" cjne %5,%6,%8\n" +" sjmp %7\n" +"%3: \n" +"}\n" +"\n" +"replace {\n" +" cjne %1,%2,%3\n" +" mov a,%4\n" +" cjne %5,%6,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 197 optimized misc jump sequence\n" +" cjne %1,%2,%8\n" +" mov a,%4\n" +" cjne %5,%6,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" cjne %1,%2,%3\n" +" cjne %5,%6,%3\n" +" sjmp %7\n" +"%3:\n" +" sjmp %8\n" +"} by {\n" +" ; Peephole 198 optimized misc jump sequence\n" +" cjne %1,%2,%8\n" +" cjne %5,%6,%8\n" +" sjmp %7\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" cjne %1,%2,%3\n" +" sjmp %4\n" +"%3:\n" +" sjmp %5\n" +"} by {\n" +" ; Peephole 199 optimized misc jump sequence\n" +" cjne %1,%2,%5\n" +" sjmp %4\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" sjmp %1\n" +"%1:\n" +"} by {\n" +" ; Peephole 200 removed redundant sjmp\n" +"%1:\n" +"}\n" +"\n" +"replace {\n" +" sjmp %1\n" +"%2:\n" +"%1:\n" +"} by {\n" +" ; Peephole 201 removed redundant sjmp\n" +"%2:\n" +"%1:\n" +"}\n" +"\n" +"replace {\n" +" push acc\n" +" mov dptr,%1\n" +" pop acc\n" +"} by {\n" +" ; Peephole 202 removed redundant push pop\n" +" mov dptr,%1\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,_spx\n" +" lcall %2\n" +" mov r%1,_spx\n" +"} by {\n" +" ; Peephole 203 removed mov r%1,_spx\n" +" lcall %2\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" add a,acc\n" +" mov %1,a\n" +"} by {\n" +" ; Peephole 204 removed redundant mov\n" +" add a,acc\n" +" mov %1,a\n" +"}\n" +"\n" +"replace {\n" +" djnz %1,%2\n" +" sjmp %3\n" +"%2:\n" +" sjmp %4\n" +"%3:\n" +"} by {\n" +" ; Peephole 205 optimized misc jump sequence\n" +" djnz %1,%4\n" +"%2:\n" +"%3:\n" +"}\n" +"\n" +"replace {\n" +" mov %1,%1\n" +"} by {\n" +" ; Peephole 206 removed redundant mov %1,%1\n" +"}\n" +"\n" +"replace {\n" +" mov a,_bp\n" +" add a,#0x00\n" +" mov %1,a\n" +"} by {\n" +" ; Peephole 207 removed zero add (acc not set to %1, flags undefined)\n" +" mov %1,_bp\n" +"}\n" +"\n" +"replace {\n" +" push acc\n" +" mov r%1,_bp\n" +" pop acc\n" +"} by {\n" +" ; Peephole 208 removed redundant push pop\n" +" mov r%1,_bp\n" +"}\n" +"\n" +"replace {\n" +" mov a,_bp\n" +" add a,#0x00\n" +" inc a\n" +" mov %1,a\n" +"} by {\n" +" ; Peephole 209 optimized increment (acc not set to %1, flags undefined)\n" +" mov %1,_bp\n" +" inc %1\n" +"}\n" +"\n" +"replace {\n" +" mov dptr,#((((%1 >> 8)) <<8) + %1)\n" +"} by {\n" +" ; Peephole 210 simplified expression\n" +" mov dptr,#%1\n" +"}\n" +"\n" +"replace {\n" +" push %1\n" +" pop %1\n" +"} by {\n" +" ; Peephole 211 removed redundant push %1 pop %1 \n" +"} \n" +"\n" +"replace {\n" +" mov a,_bp\n" +" add a,#0x01\n" +" mov r%1,a\n" +"} by {\n" +" ; Peephole 212 reduced add sequence to inc\n" +" mov r%1,_bp\n" +" inc r%1\n" +"}\n" +"\n" +"replace {\n" +" mov %1,#(( %2 >> 8 ) ^ 0x80)\n" +"} by { \n" +" mov %1,#(%2 >> 8)\n" +" xrl %1,#0x80\n" +"}\n" +"\n" +"replace {\n" +" mov %1,#(( %2 + %3 >> 8 ) ^ 0x80)\n" +"} by { \n" +" mov %1,#((%2 + %3) >> 8)\n" +" xrl %1,#0x80\n" +"}\n" +"\n" +"replace {\n" +" mov %1,a\n" +" mov a,%2\n" +" add a,%1\n" +"} by {\n" +" ; Peephole 214 reduced some extra movs\n" +" mov %1,a\n" +" add a,%2 \n" +"} if operandsNotSame\n" +"\n" +"replace {\n" +" mov %1,a\n" +" add a,%2\n" +" mov %1,a\n" +"} by {\n" +" ; Peephole 215 removed some movs\n" +" add a,%2\n" +" mov %1,a\n" +"} if operandsNotSame\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" clr a\n" +" inc r%1\n" +" mov @r%1,a\n" +" dec r%1\n" +" mov @r%1,a\n" +"} by {\n" +" ; Peephole 216 simplified clear (2bytes)\n" +" mov r%1,%2\n" +" clr a\n" +" mov @r%1,a\n" +" inc r%1\n" +" mov @r%1,a\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" clr a\n" +" inc r%1\n" +" inc r%1\n" +" mov @r%1,a\n" +" dec r%1\n" +" mov @r%1,a\n" +" dec r%1\n" +" mov @r%1,a\n" +"} by {\n" +" ; Peephole 217 simplified clear (3bytes)\n" +" mov r%1,%2\n" +" clr a\n" +" mov @r%1,a\n" +" inc r%1\n" +" mov @r%1,a\n" +" inc r%1\n" +" mov @r%1,a\n" +"}\n" +"\n" +"replace {\n" +" mov r%1,%2\n" +" clr a\n" +" inc r%1\n" +" inc r%1\n" +" inc r%1\n" +" mov @r%1,a\n" +" dec r%1\n" +" mov @r%1,a\n" +" dec r%1\n" +" mov @r%1,a\n" +" dec r%1\n" +" mov @r%1,a\n" +"} by {\n" +" ; Peephole 218 simplified clear (4bytes)\n" +" mov r%1,%2\n" +" clr a\n" +" mov @r%1,a\n" +" inc r%1\n" +" mov @r%1,a\n" +" inc r%1\n" +" mov @r%1,a\n" +" inc r%1\n" +" mov @r%1,a\n" +"}\n" diff --git a/src/SDCCptropt.c b/src/SDCCptropt.c new file mode 100644 index 00000000..24e7ccc1 --- /dev/null +++ b/src/SDCCptropt.c @@ -0,0 +1,189 @@ +/*------------------------------------------------------------------------- + + SDCCptropt.c - source file for pointer arithmetic Optimizations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCcflow.h" +#include "SDCCloop.h" +#include "SDCCcse.h" + + +/*-----------------------------------------------------------------*/ +/* pointerArithOpts - does some pointer arithmetic operations */ +/*-----------------------------------------------------------------*/ + int pointerArithOpts (iCode *ic, hTab *ptrs) +{ + operand *asym ; + long cval; + hashtItem *htip; + induction *ip ; + int lr = 0 ; + + /* the aim here is to reduce the arithmetics performed */ + /* during repeated pointer access . for eg. there are */ + /* lot of places the code generated looks like this */ + /* iTempNN = &[somevar] */ + /* iTempNX = iTempNN + constant-1 */ + /* *(iTempNX) := somevalue */ + /* iTempNY = iTempNN + constant-2 */ + /* *(iTempNY) := somevalue */ + /* we want to change this sequence to */ + /* iTempNN = &[somevar] */ + /* iTempNN = iTempNN + constant-1 */ + /* (*iTempNN) := someValue */ + /* WHY ? this will reduce the number of definitions */ + /* as well as help us in register allocation */ + + /* first check if +/- */ + if (ic->op != '+' && ic->op != '-' ) + return 0; + + /* if the result is not an iTemp */ + if (!IS_ITEMP(IC_RESULT(ic))) + return 0; + + /* if +/- then check if one of them is literal */ + if (! IS_OP_LITERAL(IC_LEFT(ic)) && + ! IS_OP_LITERAL(IC_RIGHT(ic)) ) + return 0; + + /* get the operand & literal value */ + if (IS_OP_LITERAL(IC_LEFT(ic))) { + cval = operandLitValue(IC_LEFT(ic)); + asym = IC_RIGHT(ic) ; + } else { + cval = operandLitValue(IC_RIGHT(ic)) ; + lr++ ; + asym = IC_LEFT(ic); + } + + /* if this symbol does not exist the address of */ + /* or if the symbol is the same as the result */ + if (asym->key == IC_RESULT(ic)->key || + (htip = hTabSearch(ptrs,asym->key)) == NULL ) + return 0; + + ip = htip->item; + + + /* if the constant value in induction is zero */ + /* then we just change the operand */ + if (ip->cval == 0) { + ip->asym = IC_RESULT(ic) ; + ip->cval = cval ; /* update the offset info */ + return 0; + } + /* we can do the substitution */ + replaceAllSymBySym (ic->next, IC_RESULT(ic),ip->asym); + IC_RESULT(ic) = operandFromOperand(ip->asym); + + /* now we know that the constant value is greater than zero */ + /* we have to do some arithmetic here : if the offset is greater */ + /* than what we want then rechange it to subtraction */ + if ( ip->cval > cval) { + ic->op = '-' ; + if (lr) { + IC_LEFT(ic) = operandFromOperand(ip->asym); + IC_RIGHT(ic) = operandFromLit(ip->cval - cval); + } + else { + IC_RIGHT(ic) = operandFromOperand(ip->asym); + IC_LEFT(ic) = operandFromLit(ip->cval - cval); + } + } else { + if (lr) { + IC_LEFT(ic) = operandFromOperand(ip->asym); + IC_RIGHT(ic) = operandFromLit(cval - ip->cval); + } + else { + IC_RIGHT(ic) = operandFromOperand (ip->asym); + IC_LEFT(ic) = operandFromLit(cval - ip->cval); + } + } + + ip->cval = cval ; + return 1; +} + +/*-----------------------------------------------------------------*/ +/* ptrAopts - pointer arithmetic optimizations for a basic block */ +/*-----------------------------------------------------------------*/ +void ptrAopts (eBBlock **ebbs, int count) +{ + int i; + + hTab *pointers ; + + /* for each basic block do */ + for (i = 0 ; i < count ; i++ ) { + iCode *ic; + + setToNull((void **) &pointers); + /* iterate thru intructions in the basic block */ + for (ic = ebbs[i]->sch ; ic ; ic = ic->next ) { + + if (SKIP_IC(ic) ||ic->op == IFX) + continue ; + + if (pointers) + pointerArithOpts(ic,pointers); + + if (!POINTER_SET(ic) && IC_RESULT(ic)) + /* delete from pointer access */ + hTabDeleteItem (&pointers, IC_RESULT(ic)->key,NULL,DELETE_CHAIN,NULL); + + /* set up for pointers */ + if ((ic->op == ADDRESS_OF || ADD_SUBTRACT_ITEMP(ic)) && + IS_ITEMP(IC_RESULT(ic)) ) { + operand *sym ; + operand *asym ; + long cval ; + + if ( ic->op == ADDRESS_OF){ + sym = IC_RESULT(ic); + asym = NULL ; + cval = 0; + } else { + sym = IC_LEFT(ic); + asym = IC_RESULT(ic); + cval = operandLitValue(IC_RIGHT(ic)); + } + + /* put it in the pointer set */ + } + } + + } +} diff --git a/src/SDCCptropt.h b/src/SDCCptropt.h new file mode 100644 index 00000000..2160b607 --- /dev/null +++ b/src/SDCCptropt.h @@ -0,0 +1,31 @@ +/*------------------------------------------------------------------------- + + SDCCptropt.h - header file for pointer arithmetic Optimizations + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCCPTROPT_H +#define SDCCPTROPT_H 1 + +void ptrAopts (eBBlock **, int ); + +#endif diff --git a/src/SDCCralloc.c b/src/SDCCralloc.c new file mode 100644 index 00000000..2a7dc805 --- /dev/null +++ b/src/SDCCralloc.c @@ -0,0 +1,2313 @@ +/*------------------------------------------------------------------------ + + SDCCralloc.c - source file for register allocation. (8051) specific + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include "SDCCglobl.h" +#include "SDCCast.h" +#include "SDCCmem.h" +#include "SDCCy.h" +#include "SDCChasht.h" +#include "SDCCbitv.h" +#include "SDCCset.h" +#include "SDCCicode.h" +#include "SDCClabel.h" +#include "SDCCBBlock.h" +#include "SDCCloop.h" +#include "SDCCcse.h" +#include "SDCCcflow.h" +#include "SDCCdflow.h" +#include "SDCClrange.h" +#include "SDCCralloc.h" + +/*-----------------------------------------------------------------*/ +/* At this point we start getting processor specific although */ +/* some routines are non-processor specific & can be reused when */ +/* targetting other processors. The decision for this will have */ +/* to be made on a routine by routine basis */ +/* routines used to pack registers are most definitely not reusable*/ +/* since the pack the registers depending strictly on the MCU */ +/*-----------------------------------------------------------------*/ + +bitVect *spiltSet = NULL ; +set *stackSpil = NULL; +bitVect *regAssigned = NULL; +short blockSpil = 0; +int slocNum = 0 ; +extern void gen51Code(iCode *); +int ptrRegReq = 0; /* one byte pointer register required */ +bitVect *funcrUsed = NULL; /* registers used in a function */ +int stackExtend = 0; +int dataExtend = 0; + +/* 8051 registers */ +regs regs8051[] = +{ + + { REG_GPR ,R2_IDX , REG_GPR , "r2", "ar2", "0", 2, 1 }, + { REG_GPR ,R3_IDX , REG_GPR , "r3", "ar3", "0", 3, 1 }, + { REG_GPR ,R4_IDX , REG_GPR , "r4", "ar4", "0", 4, 1 }, + { REG_GPR ,R5_IDX , REG_GPR , "r5", "ar5", "0", 5, 1 }, + { REG_GPR ,R6_IDX , REG_GPR , "r6", "ar6", "0", 6, 1 }, + { REG_GPR ,R7_IDX , REG_GPR , "r7", "ar7", "0", 7, 1 }, + { REG_PTR ,R0_IDX , REG_PTR , "r0" , "ar0", "0", 0, 1 }, + { REG_PTR ,R1_IDX , REG_PTR , "r1" , "ar1", "0", 1, 1 }, + { REG_GPR ,X8_IDX , REG_GPR , "x8", "x8" , "xreg", 0, 1 }, + { REG_GPR ,X9_IDX , REG_GPR , "x9", "x9" , "xreg", 1, 1 }, + { REG_GPR ,X10_IDX,REG_GPR , "x10", "x10", "xreg", 2, 1 }, + { REG_GPR ,X11_IDX,REG_GPR , "x11", "x11", "xreg", 3, 1 }, + { REG_GPR ,X12_IDX,REG_GPR , "x12", "x12", "xreg", 4, 1 }, + { REG_CND ,CND_IDX,REG_CND , "C" , "C" , "xreg", 0, 1 }, +}; +int nRegs = 13; +void spillThis (symbol *); + +/*-----------------------------------------------------------------*/ +/* allocReg - allocates register of given type */ +/*-----------------------------------------------------------------*/ +regs *allocReg (short type) +{ + int i; + + for ( i = 0 ; i < nRegs ; i++ ) { + + /* if type is given as 0 then any + free register will do */ + if (!type && + regs8051[i].isFree ) { + regs8051[i].isFree = 0; + if (currFunc) + currFunc->regsUsed = + bitVectSetBit(currFunc->regsUsed,i); + return ®s8051[i]; + } + /* other wise look for specific type + of register */ + if (regs8051[i].isFree && + regs8051[i].type == type) { + regs8051[i].isFree = 0; + if (currFunc) + currFunc->regsUsed = + bitVectSetBit(currFunc->regsUsed,i); + return ®s8051[i]; + } + } + return NULL; +} + +/*-----------------------------------------------------------------*/ +/* regWithIdx - returns pointer to register wit index number */ +/*-----------------------------------------------------------------*/ +regs *regWithIdx (int idx) +{ + int i ; + + for (i=0;i < nRegs;i++) + if (regs8051[i].rIdx == idx) + return ®s8051[i]; + + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "regWithIdx not found"); + exit(1); +} + +/*-----------------------------------------------------------------*/ +/* freeReg - frees a register */ +/*-----------------------------------------------------------------*/ +void freeReg (regs *reg) +{ + reg->isFree = 1; +} + + +/*-----------------------------------------------------------------*/ +/* nFreeRegs - returns number of free registers */ +/*-----------------------------------------------------------------*/ +int nFreeRegs (int type) +{ + int i; + int nfr=0; + + for (i = 0 ; i < nRegs; i++ ) + if (regs8051[i].isFree && regs8051[i].type == type) + nfr++; + return nfr; +} + +/*-----------------------------------------------------------------*/ +/* nfreeRegsType - free registers with type */ +/*-----------------------------------------------------------------*/ +int nfreeRegsType (int type) +{ + int nfr ; + if (type == REG_PTR) { + if ((nfr = nFreeRegs(type)) == 0) + return nFreeRegs(REG_GPR); + } + + return nFreeRegs(type); +} + + +/*-----------------------------------------------------------------*/ +/* allDefsOutOfRange - all definitions are out of a range */ +/*-----------------------------------------------------------------*/ +bool allDefsOutOfRange (bitVect *defs,int fseq, int toseq) +{ + int i ; + + if (!defs) + return TRUE ; + + for ( i = 0 ;i < defs->size ; i++ ) { + iCode *ic; + + if (bitVectBitValue(defs,i) && + (ic = hTabItemWithKey(iCodehTab,i)) && + ( ic->seq >= fseq && ic->seq <= toseq)) + + return FALSE; + + } + + return TRUE; +} + +/*-----------------------------------------------------------------*/ +/* computeSpillable - given a point find the spillable live ranges */ +/*-----------------------------------------------------------------*/ +bitVect *computeSpillable (iCode *ic) +{ + bitVect *spillable ; + + /* spillable live ranges are those that are live at this + point . the following categories need to be subtracted + from this set. + a) - those that are already spilt + b) - if being used by this one + c) - defined by this one */ + + spillable = bitVectCopy(ic->rlive); + spillable = + bitVectCplAnd(spillable,spiltSet); /* those already spilt */ + spillable = + bitVectCplAnd(spillable,ic->uses); /* used in this one */ + bitVectUnSetBit(spillable,ic->defKey); + spillable = bitVectIntersect(spillable,regAssigned); + return spillable; + +} + +/*-----------------------------------------------------------------*/ +/* noSpilLoc - return true if a variable has no spil location */ +/*-----------------------------------------------------------------*/ +int noSpilLoc (symbol *sym, eBBlock *ebp,iCode *ic) +{ + return (sym->usl.spillLoc ? 0 : 1); +} + +/*-----------------------------------------------------------------*/ +/* hasSpilLoc - will return 1 if the symbol has spil location */ +/*-----------------------------------------------------------------*/ +int hasSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) +{ + return (sym->usl.spillLoc ? 1 : 0); +} + +/*-----------------------------------------------------------------*/ +/* directSpilLoc - will return 1 if the splilocation is in direct */ +/*-----------------------------------------------------------------*/ +int directSpilLoc (symbol *sym, eBBlock *ebp, iCode *ic) +{ + if ( sym->usl.spillLoc && + (IN_DIRSPACE(SPEC_OCLS(sym->usl.spillLoc->etype)))) + return 1; + else + return 0; +} + +/*-----------------------------------------------------------------*/ +/* hasSpilLocnoUptr - will return 1 if the symbol has spil location*/ +/* but is not used as a pointer */ +/*-----------------------------------------------------------------*/ +int hasSpilLocnoUptr (symbol *sym, eBBlock *ebp, iCode *ic) +{ + return ((sym->usl.spillLoc && !sym->uptr) ? 1 : 0); +} + +/*-----------------------------------------------------------------*/ +/* rematable - will return 1 if the remat flag is set */ +/*-----------------------------------------------------------------*/ +int rematable (symbol *sym, eBBlock *ebp, iCode *ic) +{ + return sym->remat; +} + +/*-----------------------------------------------------------------*/ +/* notUsedInBlock - not used in this block */ +/*-----------------------------------------------------------------*/ +int notUsedInBlock (symbol *sym, eBBlock *ebp, iCode *ic) +{ + return (!bitVectBitsInCommon(sym->defs,ebp->usesDefs) && + allDefsOutOfRange (sym->defs,ebp->fSeq,ebp->lSeq)); +/* return (!bitVectBitsInCommon(sym->defs,ebp->usesDefs)); */ +} + +/*-----------------------------------------------------------------*/ +/* notUsedInRemaining - not used or defined in remain of the block */ +/*-----------------------------------------------------------------*/ +int notUsedInRemaining (symbol *sym, eBBlock *ebp, iCode *ic) +{ + return ((usedInRemaining (operandFromSymbol(sym),ic) ? 0 : 1) && + allDefsOutOfRange (sym->defs,ic->seq,ebp->lSeq)); +} + +/*-----------------------------------------------------------------*/ +/* allLRs - return true for all */ +/*-----------------------------------------------------------------*/ +int allLRs (symbol *sym, eBBlock *ebp, iCode *ic) +{ + return 1; +} + +/*-----------------------------------------------------------------*/ +/* liveRangesWith - applies function to a given set of live range */ +/*-----------------------------------------------------------------*/ +set *liveRangesWith (bitVect *lrs, int (func)(symbol *,eBBlock *, iCode *), + eBBlock *ebp, iCode *ic) +{ + set *rset = NULL; + int i; + + if (!lrs || !lrs->size) + return NULL; + + for ( i = 1 ; i < lrs->size ; i++ ) { + symbol *sym; + if (!bitVectBitValue(lrs,i)) + continue ; + + /* if we don't find it in the live range + hash table we are in serious trouble */ + if (!(sym = hTabItemWithKey(liveRanges,i))) { + werror(E_INTERNAL_ERROR,__FILE__,__LINE__, + "liveRangesWith could not find liveRange"); + exit(1); + } + + if (func(sym,ebp,ic) && bitVectBitValue(regAssigned,sym->key)) + addSetHead(&rset,sym); + } + + return rset; +} + + +/*-----------------------------------------------------------------*/ +/* leastUsedLR - given a set determines which is the least used */ +/*-----------------------------------------------------------------*/ +symbol *leastUsedLR (set *sset) +{ + symbol *sym = NULL, *lsym = NULL ; + + sym = lsym = setFirstItem(sset); + + if (!lsym) + return NULL; + + for (; lsym; lsym = setNextItem(sset)) { + + /* if usage is the same then prefer + the spill the smaller of the two */ + if ( lsym->used == sym->used ) + if (getSize(lsym->type) < getSize(sym->type)) + sym = lsym; + + /* if less usage */ + if (lsym->used < sym->used ) + sym = lsym; + + } + + setToNull((void **)&sset); + sym->blockSpil = 0; + return sym; +} + +/*-----------------------------------------------------------------*/ +/* noOverLap - will iterate through the list looking for over lap */ +/*-----------------------------------------------------------------*/ +int noOverLap (set *itmpStack, symbol *fsym) +{ + symbol *sym; + + + for (sym = setFirstItem(itmpStack); sym; + sym = setNextItem(itmpStack)) { + if (sym->liveTo > fsym->liveFrom ) + return 0; + + } + + return 1; +} + +/*-----------------------------------------------------------------*/ +/* isFree - will return 1 if the a free spil location is found */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(isFree) +{ + symbol *sym = item; + V_ARG(symbol **,sloc); + V_ARG(symbol *,fsym); + + /* if already found */ + if (*sloc) + return 0; + + /* if it is free && and the itmp assigned to + this does not have any overlapping live ranges + with the one currently being assigned and + the size can be accomodated */ + if (sym->isFree && + noOverLap(sym->usl.itmpStack,fsym) && + getSize(sym->type) >= getSize(fsym->type)) { + *sloc = sym; + return 1; + } + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* spillLRWithPtrReg :- will spil those live ranges which use PTR */ +/*-----------------------------------------------------------------*/ +void spillLRWithPtrReg (symbol *forSym) +{ + symbol *lrsym; + regs *r0,*r1; + int k; + + if (!regAssigned || + bitVectIsZero(regAssigned)) + return; + + r0 = regWithIdx(R0_IDX); + r1 = regWithIdx(R1_IDX); + + /* for all live ranges */ + for (lrsym = hTabFirstItem(liveRanges,&k) ; lrsym ; + lrsym = hTabNextItem(liveRanges,&k) ) { + int j; + + /* if no registers assigned to it or + spilt */ + /* if it does not overlap with this then + not need to spill it */ + + if (lrsym->isspilt || !lrsym->nRegs || + (lrsym->liveTo < forSym->liveFrom)) + continue ; + + /* go thru the registers : if it is either + r0 or r1 then spil it */ + for (j = 0 ; j < lrsym->nRegs ; j++ ) + if (lrsym->regs[j] == r0 || + lrsym->regs[j] == r1 ) { + spillThis (lrsym); + break; + } + } + +} + +/*-----------------------------------------------------------------*/ +/* createStackSpil - create a location on the stack to spil */ +/*-----------------------------------------------------------------*/ +symbol *createStackSpil (symbol *sym) +{ + symbol *sloc= NULL; + int useXstack, model, noOverlay; + int stackAuto; + + /* first go try and find a free one that is already + existing on the stack */ + if (applyToSet(stackSpil,isFree,&sloc, sym)) { + /* found a free one : just update & return */ + sym->usl.spillLoc = sloc; + sym->stackSpil= 1; + sloc->isFree = 0; + addSetHead(&sloc->usl.itmpStack,sym); + return sym; + } + + /* could not then have to create one , this is the hard part + we need to allocate this on the stack : this is really a + hack!! but cannot think of anything better at this time */ + + sprintf(buffer,"sloc%d",slocNum++); + sloc = newiTemp(buffer); + + /* set the type to the spilling symbol */ + sloc->type = copyLinkChain(sym->type); + sloc->etype = getSpec(sloc->type); + SPEC_SCLS(sloc->etype) = S_AUTO ; + SPEC_EXTR(sloc->etype) = 0; + + /* we don't allow it to be allocated` + onto the external stack since : so we + temporarily turn it off ; we also + turn off memory model to prevent + the spil from going to the external storage + and turn off overlaying + */ + + useXstack = options.useXstack; + model = options.model; + noOverlay = options.noOverlay; + stackAuto = options.stackAuto; + options.noOverlay = 1; + options.model = options.useXstack = 0; + + allocLocal(sloc); + + options.useXstack = useXstack; + options.model = model; + options.noOverlay = noOverlay; + options.stackAuto = stackAuto; + sloc->isref = 1; /* to prevent compiler warning */ + + /* if it is on the stack then update the stack */ + if (IN_STACK(sloc->etype)) { + currFunc->stack += getSize(sloc->type); + stackExtend += getSize(sloc->type); + } else + dataExtend += getSize(sloc->type); + + /* add it to the stackSpil set */ + addSetHead(&stackSpil,sloc); + sym->usl.spillLoc = sloc; + sym->stackSpil = 1; + + /* add it to the set of itempStack set + of the spill location */ + addSetHead(&sloc->usl.itmpStack,sym); + return sym; +} + +/*-----------------------------------------------------------------*/ +/* isSpiltOnStack - returns true if the spil location is on stack */ +/*-----------------------------------------------------------------*/ +bool isSpiltOnStack (symbol *sym) +{ + link *etype; + + if (!sym) + return FALSE ; + + if (!sym->isspilt) + return FALSE ; + +/* if (sym->stackSpil) */ +/* return TRUE; */ + + if (!sym->usl.spillLoc) + return FALSE; + + etype = getSpec(sym->usl.spillLoc->type); + if (IN_STACK(etype)) + return TRUE; + + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* spillThis - spils a specific operand */ +/*-----------------------------------------------------------------*/ +void spillThis (symbol *sym) +{ + int i; + /* if this is rematerializable or has a spillLocation + we are okay, else we need to create a spillLocation + for it */ + if (!(sym->remat || sym->usl.spillLoc)) + createStackSpil (sym); + + + /* mark it has spilt & put it in the spilt set */ + sym->isspilt = 1; + spiltSet = bitVectSetBit(spiltSet,sym->key); + + bitVectUnSetBit(regAssigned,sym->key); + + for (i = 0 ; i < sym->nRegs ; i++) + + if (sym->regs[i]) { + freeReg(sym->regs[i]); + sym->regs[i] = NULL; + } + + /* if spilt on stack then free up r0 & r1 + if they could have been assigned to some + LIVE ranges */ + if (!ptrRegReq && isSpiltOnStack(sym)) { + ptrRegReq++ ; + spillLRWithPtrReg(sym); + } + + if (sym->usl.spillLoc && !sym->remat) + sym->usl.spillLoc->allocreq = 1; + return; +} + +/*-----------------------------------------------------------------*/ +/* selectSpil - select a iTemp to spil : rather a simple procedure */ +/*-----------------------------------------------------------------*/ +symbol *selectSpil (iCode *ic, eBBlock *ebp, symbol *forSym) +{ + bitVect *lrcs= NULL ; + set *selectS ; + symbol *sym; + + /* get the spillable live ranges */ + lrcs = computeSpillable (ic); + + /* get all live ranges that are rematerizable */ + if ((selectS = liveRangesWith(lrcs,rematable,ebp,ic))) { + + /* return the least used of these */ + return leastUsedLR(selectS); + } + + /* get live ranges with spillLocations in direct space */ + if ((selectS = liveRangesWith(lrcs,directSpilLoc,ebp,ic))) { + sym = leastUsedLR(selectS); + strcpy(sym->rname,(sym->usl.spillLoc->rname[0] ? + sym->usl.spillLoc->rname : + sym->usl.spillLoc->name)); + sym->spildir = 1; + /* mark it as allocation required */ + sym->usl.spillLoc->allocreq = 1; + return sym; + } + + /* if the symbol is local to the block then */ + if (forSym->liveTo < ebp->lSeq ) { + + /* check if there are any live ranges allocated + to registers that are not used in this block */ + if (!blockSpil && (selectS = liveRangesWith(lrcs,notUsedInBlock,ebp,ic))) { + sym = leastUsedLR(selectS); + /* if this is not rematerializable */ + if (!sym->remat) { + blockSpil++; + sym->blockSpil = 1; + } + return sym; + } + + /* check if there are any live ranges that not + used in the remainder of the block */ + if (!blockSpil && (selectS = liveRangesWith(lrcs,notUsedInRemaining,ebp,ic))) { + sym = leastUsedLR (selectS); + if (!sym->remat) { + sym->remainSpil = 1; + blockSpil++; + } + return sym; + } + } + + /* find live ranges with spillocation && not used as pointers */ + if ((selectS = liveRangesWith(lrcs,hasSpilLocnoUptr,ebp,ic))) { + + sym = leastUsedLR(selectS); + /* mark this as allocation required */ + sym->usl.spillLoc->allocreq = 1; + return sym; + } + + /* find live ranges with spillocation */ + if ((selectS = liveRangesWith(lrcs,hasSpilLoc,ebp,ic))) { + + sym = leastUsedLR(selectS); + sym->usl.spillLoc->allocreq = 1; + return sym; + } + + /* couldn't find then we need to create a spil + location on the stack , for which one? the least + used ofcourse */ + if ((selectS = liveRangesWith(lrcs,noSpilLoc,ebp,ic))) { + + /* return a created spil location */ + sym = createStackSpil(leastUsedLR(selectS)); + sym->usl.spillLoc->allocreq = 1; + return sym; + } + + /* this is an extreme situation we will spill + this one : happens very rarely but it does happen */ + spillThis ( forSym ); + return forSym ; + +} + +/*-----------------------------------------------------------------*/ +/* spilSomething - spil some variable & mark registers as free */ +/*-----------------------------------------------------------------*/ +bool spilSomething (iCode *ic, eBBlock *ebp, symbol *forSym) +{ + symbol *ssym; + int i ; + + /* get something we can spil */ + ssym = selectSpil(ic,ebp,forSym); + + /* mark it as spilt */ + ssym->isspilt = 1; + spiltSet = bitVectSetBit(spiltSet,ssym->key); + + /* mark it as not register assigned & + take it away from the set */ + bitVectUnSetBit(regAssigned,ssym->key); + + /* mark the registers as free */ + for (i = 0 ; i < ssym->nRegs ;i++ ) + if (ssym->regs[i]) + freeReg(ssym->regs[i]); + + /* if spilt on stack then free up r0 & r1 + if they could have been assigned to as gprs */ + if (!ptrRegReq && isSpiltOnStack(ssym) ) { + ptrRegReq++ ; + spillLRWithPtrReg(ssym); + } + + /* if this was a block level spil then insert push & pop + at the start & end of block respectively */ + if (ssym->blockSpil) { + iCode *nic = newiCode(IPUSH,operandFromSymbol(ssym),NULL); + /* add push to the start of the block */ + addiCodeToeBBlock(ebp,nic,( ebp->sch->op == LABEL ? + ebp->sch->next : ebp->sch)); + nic = newiCode(IPOP,operandFromSymbol(ssym),NULL); + /* add pop to the end of the block */ + addiCodeToeBBlock(ebp,nic,NULL); + } + + /* if spilt because not used in the remainder of the + block then add a push before this instruction and + a pop at the end of the block */ + if (ssym->remainSpil) { + + iCode *nic = newiCode(IPUSH,operandFromSymbol(ssym),NULL); + /* add push just before this instruction */ + addiCodeToeBBlock(ebp,nic,ic); + + nic = newiCode(IPOP,operandFromSymbol(ssym),NULL); + /* add pop to the end of the block */ + addiCodeToeBBlock(ebp,nic,NULL); + } + + if (ssym == forSym ) + return FALSE ; + else + return TRUE ; +} + +/*-----------------------------------------------------------------*/ +/* getRegPtr - will try for PTR if not a GPR type if not spil */ +/*-----------------------------------------------------------------*/ +regs *getRegPtr (iCode *ic, eBBlock *ebp, symbol *sym) +{ + regs *reg; + + tryAgain: + /* try for a ptr type */ + if ((reg = allocReg(REG_PTR))) + return reg; + + /* try for gpr type */ + if ((reg = allocReg(REG_GPR))) + return reg; + + /* we have to spil */ + if (!spilSomething (ic,ebp,sym)) + return NULL ; + + /* this looks like an infinite loop but + in really selectSpil will abort */ + goto tryAgain ; +} + +/*-----------------------------------------------------------------*/ +/* getRegGpr - will try for GPR if not spil */ +/*-----------------------------------------------------------------*/ +regs *getRegGpr (iCode *ic, eBBlock *ebp,symbol *sym) +{ + regs *reg; + + tryAgain: + /* try for gpr type */ + if ((reg = allocReg(REG_GPR))) + return reg; + + if (!ptrRegReq) + if ((reg = allocReg(REG_PTR))) + return reg ; + + /* we have to spil */ + if (!spilSomething (ic,ebp,sym)) + return NULL ; + + /* this looks like an infinite loop but + in really selectSpil will abort */ + goto tryAgain ; +} + +/*-----------------------------------------------------------------*/ +/* symHasReg - symbol has a given register */ +/*-----------------------------------------------------------------*/ +static bool symHasReg(symbol *sym,regs *reg) +{ + int i; + + for ( i = 0 ; i < sym->nRegs ; i++) + if (sym->regs[i] == reg) + return TRUE; + + return FALSE; +} + +/*-----------------------------------------------------------------*/ +/* deassignLRs - check the live to and if they have registers & are*/ +/* not spilt then free up the registers */ +/*-----------------------------------------------------------------*/ +void deassignLRs (iCode *ic, eBBlock *ebp) +{ + symbol *sym; + int k; + symbol *result; + + for (sym = hTabFirstItem(liveRanges,&k); sym; + sym = hTabNextItem(liveRanges,&k)) { + + symbol *psym= NULL; + /* if it does not end here */ + if (sym->liveTo > ic->seq ) + continue ; + + /* if it was spilt on stack then we can + mark the stack spil location as free */ + if (sym->isspilt ) { + if (sym->stackSpil) { + sym->usl.spillLoc->isFree = 1; + sym->stackSpil = 0; + } + continue ; + } + + if (!bitVectBitValue(regAssigned,sym->key)) + continue; + + /* special case check if this is an IFX & + the privious one was a pop and the + previous one was not spilt then keep track + of the symbol */ + if (ic->op == IFX && ic->prev && + ic->prev->op == IPOP && + !ic->prev->parmPush && + !OP_SYMBOL(IC_LEFT(ic->prev))->isspilt) + psym = OP_SYMBOL(IC_LEFT(ic->prev)); + + if (sym->nRegs) { + int i = 0; + + bitVectUnSetBit(regAssigned,sym->key); + + /* if the result of this one needs registers + and does not have it then assign it right + away */ + if (IC_RESULT(ic) && + ! (SKIP_IC2(ic) || /* not a special icode */ + ic->op == JUMPTABLE || + ic->op == IFX || + ic->op == IPUSH || + ic->op == IPOP || + ic->op == RETURN || + POINTER_SET(ic)) && + (result = OP_SYMBOL(IC_RESULT(ic))) && /* has a result */ + result->liveTo > ic->seq && /* and will live beyond this */ + result->liveTo <= ebp->lSeq && /* does not go beyond this block */ + result->regType == sym->regType && /* same register types */ + result->nRegs && /* which needs registers */ + ! result->isspilt && /* and does not already have them */ + ! result->remat && + ! bitVectBitValue(regAssigned,result->key) && + /* the number of free regs + number of regs in this LR + can accomodate the what result Needs */ + ((nfreeRegsType(result->regType) + + sym->nRegs) >= result->nRegs) + ) { + + for (i = 0 ; i < max(sym->nRegs,result->nRegs) ; i++) + if (i < sym->nRegs ) + result->regs[i] = sym->regs[i] ; + else + result->regs[i] = getRegGpr (ic,ebp,result); + + regAssigned = bitVectSetBit(regAssigned,result->key); + + } + + /* free the remaining */ + for (; i < sym->nRegs ; i++) { + if (psym) { + if (!symHasReg(psym,sym->regs[i])) + freeReg(sym->regs[i]); + } else + freeReg(sym->regs[i]); + } + } + } +} + + +/*-----------------------------------------------------------------*/ +/* reassignLR - reassign this to registers */ +/*-----------------------------------------------------------------*/ +void reassignLR (operand *op) +{ + symbol *sym = OP_SYMBOL(op); + int i; + + /* not spilt any more */ + sym->isspilt = sym->blockSpil = sym->remainSpil = 0; + bitVectUnSetBit(spiltSet,sym->key); + + regAssigned = bitVectSetBit(regAssigned,sym->key); + + blockSpil--; + + for (i=0;inRegs;i++) + sym->regs[i]->isFree = 0; +} + +/*-----------------------------------------------------------------*/ +/* willCauseSpill - determines if allocating will cause a spill */ +/*-----------------------------------------------------------------*/ +int willCauseSpill ( int nr, int rt) +{ + /* first check if there are any avlb registers + of te type required */ + if (rt == REG_PTR) { + /* special case for pointer type + if pointer type not avlb then + check for type gpr */ + if (nFreeRegs(rt) >= nr) + return 0; + if (nFreeRegs(REG_GPR) >= nr) + return 0; + } else { + if (ptrRegReq) { + if (nFreeRegs(rt) >= nr) + return 0; + } else { + if (nFreeRegs(REG_PTR) + + nFreeRegs(REG_GPR) >= nr) + return 0; + } + } + + /* it will cause a spil */ + return 1; +} + +/*-----------------------------------------------------------------*/ +/* positionRegs - the allocator can allocate same registers to res-*/ +/* ult and operand, if this happens make sure they are in the same */ +/* position as the operand otherwise chaos results */ +/*-----------------------------------------------------------------*/ +static void positionRegs (symbol *result, symbol *opsym, int lineno) +{ + int count = min(result->nRegs,opsym->nRegs); + int i , j = 0, shared = 0; + + /* if the result has been spilt then cannot share */ + if (opsym->isspilt) + return ; + again: + shared = 0; + /* first make sure that they actually share */ + for ( i = 0 ; i < count; i++ ) { + for (j = 0 ; j < count ; j++ ) { + if (result->regs[i] == opsym->regs[j] && i !=j) { + shared = 1; + goto xchgPositions; + } + } + } + xchgPositions: + if (shared) { + regs *tmp = result->regs[i]; + result->regs[i] = result->regs[j]; + result->regs[j] = tmp; + goto again; + } +} + +/*-----------------------------------------------------------------*/ +/* serialRegAssign - serially allocate registers to the variables */ +/*-----------------------------------------------------------------*/ +void serialRegAssign (eBBlock **ebbs, int count) +{ + int i; + + /* for all blocks */ + for (i = 0; i < count ; i++ ) { + + iCode *ic; + + if (ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel )) + continue ; + + /* of all instructions do */ + for (ic = ebbs[i]->sch ; ic ; ic = ic->next) { + + /* if this is an ipop that means some live + range will have to be assigned again */ + if (ic->op == IPOP) + reassignLR (IC_LEFT(ic)); + + /* if result is present && is a true symbol */ + if (IC_RESULT(ic) && ic->op != IFX && + IS_TRUE_SYMOP(IC_RESULT(ic))) + OP_SYMBOL(IC_RESULT(ic))->allocreq = 1; + + /* take away registers from live + ranges that end at this instruction */ + deassignLRs (ic, ebbs[i]) ; + + /* some don't need registers */ + if (SKIP_IC2(ic) || + ic->op == JUMPTABLE || + ic->op == IFX || + ic->op == IPUSH || + ic->op == IPOP || + (IC_RESULT(ic) &&POINTER_SET(ic)) ) + continue; + + /* now we need to allocate registers + only for the result */ + if (IC_RESULT(ic)) { + symbol *sym = OP_SYMBOL(IC_RESULT(ic)); + bitVect *spillable; + int willCS ; + int j; + int ptrRegSet = 0; + + /* if it does not need or is spilt + or is already assigned to registers + or will not live beyond this instructions */ + if (!sym->nRegs || + sym->isspilt || + bitVectBitValue(regAssigned,sym->key) || + sym->liveTo <= ic->seq) + continue ; + + /* if some liverange has been spilt at the block level + and this one live beyond this block then spil this + to be safe */ + if (blockSpil && sym->liveTo > ebbs[i]->lSeq) { + spillThis (sym); + continue ; + } + /* if trying to allocate this will cause + a spill and there is nothing to spill + or this one is rematerializable then + spill this one */ + willCS = willCauseSpill(sym->nRegs,sym->regType); + spillable = computeSpillable(ic); + if ( sym->remat || + (willCS && bitVectIsZero(spillable) ) ) { + + spillThis (sym) ; + continue ; + + } + + /* if it has a spillocation & is used less than + all other live ranges then spill this */ + if ( willCS && sym->usl.spillLoc ) { + + symbol *leastUsed = + leastUsedLR(liveRangesWith (spillable , + allLRs, + ebbs[i], + ic)); + if (leastUsed && + leastUsed->used > sym->used) { + spillThis (sym); + continue; + } + } + + /* if we need ptr regs for the right side + then mark it */ + if (POINTER_GET(ic) && getSize(OP_SYMBOL(IC_LEFT(ic))->type) < 2) { + ptrRegReq++; + ptrRegSet = 1; + } + /* else we assign registers to it */ + regAssigned = bitVectSetBit(regAssigned,sym->key); + + for (j = 0 ; j < sym->nRegs ;j++ ) { + if (sym->regType == REG_PTR) + sym->regs[j] = getRegPtr(ic,ebbs[i],sym); + else + sym->regs[j] = getRegGpr(ic,ebbs[i],sym); + + /* if the allocation falied which means + this was spilt then break */ + if (!sym->regs[j]) + break; + } + /* if it shares registers with operands make sure + that they are in the same position */ + if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) && + OP_SYMBOL(IC_LEFT(ic))->nRegs && ic->op != '=') + positionRegs(OP_SYMBOL(IC_RESULT(ic)), + OP_SYMBOL(IC_LEFT(ic)),ic->lineno); + /* do the same for the right operand */ + if (IC_RIGHT(ic) && IS_SYMOP(IC_RIGHT(ic)) && + OP_SYMBOL(IC_RIGHT(ic))->nRegs && ic->op != '=') + positionRegs(OP_SYMBOL(IC_RESULT(ic)), + OP_SYMBOL(IC_RIGHT(ic)),ic->lineno); + + if (ptrRegSet) { + ptrRegReq--; + ptrRegSet = 0; + } + + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* rUmaskForOp :- returns register mask for an operand */ +/*-----------------------------------------------------------------*/ +bitVect *rUmaskForOp (operand *op) +{ + bitVect *rumask; + symbol *sym; + int j; + + /* only temporaries are assigned registers */ + if (!IS_ITEMP(op)) + return NULL; + + sym = OP_SYMBOL(op); + + /* if spilt or no registers assigned to it + then nothing */ + if (sym->isspilt || !sym->nRegs) + return NULL; + + rumask = newBitVect(nRegs); + + for (j = 0; j < sym->nRegs; j++) { + rumask = bitVectSetBit(rumask, + sym->regs[j]->rIdx); + } + + return rumask; +} + +/*-----------------------------------------------------------------*/ +/* regsUsedIniCode :- returns bit vector of registers used in iCode*/ +/*-----------------------------------------------------------------*/ +bitVect *regsUsedIniCode (iCode *ic) +{ + bitVect *rmask = newBitVect(nRegs); + + /* do the special cases first */ + if (ic->op == IFX ) { + rmask = bitVectUnion(rmask, + rUmaskForOp(IC_COND(ic))); + goto ret; + } + + /* for the jumptable */ + if (ic->op == JUMPTABLE) { + rmask = bitVectUnion(rmask, + rUmaskForOp(IC_JTCOND(ic))); + + goto ret; + } + + /* of all other cases */ + if (IC_LEFT(ic)) + rmask = bitVectUnion(rmask, + rUmaskForOp(IC_LEFT(ic))); + + + if (IC_RIGHT(ic)) + rmask = bitVectUnion(rmask, + rUmaskForOp(IC_RIGHT(ic))); + + if (IC_RESULT(ic)) + rmask = bitVectUnion(rmask, + rUmaskForOp(IC_RESULT(ic))); + + ret: + return rmask; +} + +/*-----------------------------------------------------------------*/ +/* createRegMask - for each instruction will determine the regsUsed*/ +/*-----------------------------------------------------------------*/ +void createRegMask (eBBlock **ebbs, int count) +{ + int i; + + /* for all blocks */ + for (i = 0; i < count ; i++ ) { + iCode *ic ; + + if ( ebbs[i]->noPath && + ( ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel )) + continue ; + + /* for all instructions */ + for ( ic = ebbs[i]->sch ; ic ; ic = ic->next ) { + + int j; + + if (SKIP_IC2(ic) || !ic->rlive) + continue ; + + /* first mark the registers used in this + instruction */ + ic->rUsed = regsUsedIniCode(ic); + funcrUsed = bitVectUnion(funcrUsed,ic->rUsed); + + /* now create the register mask for those + registers that are in use : this is a + super set of ic->rUsed */ + ic->rMask = newBitVect(nRegs+1); + + /* for all live Ranges alive at this point */ + for (j = 1; j < ic->rlive->size; j++ ) { + symbol *sym; + int k; + + /* if not alive then continue */ + if (!bitVectBitValue(ic->rlive,j)) + continue ; + + /* find the live range we are interested in */ + if (!(sym = hTabItemWithKey(liveRanges,j))) { + werror (E_INTERNAL_ERROR,__FILE__,__LINE__, + "createRegMask cannot find live range"); + exit(0); + } + + /* if no register assigned to it */ + if (!sym->nRegs || sym->isspilt) + continue ; + + /* for all the registers allocated to it */ + for (k = 0 ; k < sym->nRegs ;k++) + if (sym->regs[k]) + ic->rMask = + bitVectSetBit(ic->rMask,sym->regs[k]->rIdx); + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* rematStr - returns the rematerialized string for a remat var */ +/*-----------------------------------------------------------------*/ +char *rematStr (symbol *sym) +{ + char *s = buffer; + iCode *ic = sym->rematiCode; + + while (1) { + + /* if plus or minus print the right hand side */ + if (ic->op == '+' || ic->op == '-') { + sprintf(s,"0x%04x %c ",(int) operandLitValue(IC_RIGHT(ic)), + ic->op ); + s += strlen(s); + ic = OP_SYMBOL(IC_LEFT(ic))->rematiCode; + continue ; + } + + /* we reached the end */ + sprintf(s,"%s",OP_SYMBOL(IC_LEFT(ic))->rname); + break; + } + + return buffer ; +} + +/*-----------------------------------------------------------------*/ +/* regTypeNum - computes the type & number of registers required */ +/*-----------------------------------------------------------------*/ +void regTypeNum () +{ + symbol *sym; + int k; + iCode *ic; + + /* for each live range do */ + for ( sym = hTabFirstItem(liveRanges,&k); sym ; + sym = hTabNextItem(liveRanges,&k)) { + + /* if used zero times then no registers needed */ + if ((sym->liveTo - sym->liveFrom) == 0) + continue ; + + + /* if the live range is a temporary */ + if (sym->isitmp) { + + /* if the type is marked as a conditional */ + if (sym->regType == REG_CND) + continue ; + + /* if used in return only then we don't + need registers */ + if (sym->ruonly || sym->accuse) { + if (IS_AGGREGATE(sym->type) || sym->isptr) + sym->type = aggrToPtr(sym->type,FALSE); + continue ; + } + + /* if the symbol has only one definition & + that definition is a get_pointer and the + pointer we are getting is rematerializable and + in "data" space */ + + if (bitVectnBitsOn(sym->defs) == 1 && + (ic = hTabItemWithKey(iCodehTab, + bitVectFirstBit(sym->defs))) && + POINTER_GET(ic) && + !IS_BITVAR(sym->etype)) { + + + /* if remat in data space */ + if (OP_SYMBOL(IC_LEFT(ic))->remat && + DCL_TYPE(aggrToPtr(sym->type,FALSE)) == POINTER) { + + /* create a psuedo symbol & force a spil */ + symbol *psym = newSymbol(rematStr(OP_SYMBOL(IC_LEFT(ic))),1); + psym->type = sym->type; + psym->etype = sym->etype; + strcpy(psym->rname,psym->name); + sym->isspilt = 1; + sym->usl.spillLoc = psym; + continue ; + } + + /* if in data space or idata space then try to + allocate pointer register */ + + } + + /* if not then we require registers */ + sym->nRegs = ((IS_AGGREGATE(sym->type) || sym->isptr ) ? + getSize(sym->type = aggrToPtr(sym->type,FALSE)) : + getSize(sym->type)); + + if (sym->nRegs > 4) { + fprintf(stderr,"allocated more than 4 or 0 registers for type "); + printTypeChain(sym->type,stderr);fprintf(stderr,"\n"); + } + + /* determine the type of register required */ + if (sym->nRegs == 1 && + IS_PTR(sym->type) && + sym->uptr) + sym->regType = REG_PTR ; + else + sym->regType = REG_GPR ; + + } else + /* for the first run we don't provide */ + /* registers for true symbols we will */ + /* see how things go */ + sym->nRegs = 0 ; + } + +} + +/*-----------------------------------------------------------------*/ +/* freeAllRegs - mark all registers as free */ +/*-----------------------------------------------------------------*/ +void freeAllRegs() +{ + int i; + + for (i=0;i< nRegs;i++ ) + regs8051[i].isFree = 1; +} + +/*-----------------------------------------------------------------*/ +/* deallocStackSpil - this will set the stack pointer back */ +/*-----------------------------------------------------------------*/ +DEFSETFUNC(deallocStackSpil) +{ + symbol *sym = item; + + deallocLocal(sym); + return 0; +} + +/*-----------------------------------------------------------------*/ +/* farSpacePackable - returns the packable icode for far variables */ +/*-----------------------------------------------------------------*/ +static iCode *farSpacePackable (iCode *ic) +{ + iCode *dic ; + + /* go thru till we find a definition for the + symbol on the right */ + for ( dic = ic->prev ; dic ; dic = dic->prev) { + + /* if the definition is a call then no */ + if ((dic->op == CALL || dic->op == PCALL) && + IC_RESULT(dic)->key == IC_RIGHT(ic)->key) { + return NULL; + } + + /* if shift by unknown amount then not */ + if ((dic->op == LEFT_OP || dic->op == RIGHT_OP) && + IC_RESULT(dic)->key == IC_RIGHT(ic)->key) + return NULL; + + /* if pointer get and size > 1 */ + if (POINTER_GET(dic) && + getSize(aggrToPtr(operandType(IC_LEFT(dic)),FALSE)) > 1) + return NULL ; + + if (POINTER_SET(dic) && + getSize(aggrToPtr(operandType(IC_RESULT(dic)),FALSE)) > 1) + return NULL ; + + /* if any three is a true symbol in far space */ + if (IC_RESULT(dic) && + IS_TRUE_SYMOP(IC_RESULT(dic)) && + isOperandInFarSpace(IC_RESULT(dic))) + return NULL; + + if (IC_RIGHT(dic) && + IS_TRUE_SYMOP(IC_RIGHT(dic)) && + isOperandInFarSpace(IC_RIGHT(dic)) && + !isOperandEqual(IC_RIGHT(dic),IC_RESULT(ic))) + return NULL; + + if (IC_LEFT(dic) && + IS_TRUE_SYMOP(IC_LEFT(dic)) && + isOperandInFarSpace(IC_LEFT(dic)) && + !isOperandEqual(IC_LEFT(dic),IC_RESULT(ic))) + return NULL; + + if (isOperandEqual(IC_RIGHT(ic),IC_RESULT(dic))) { + if ( (dic->op == LEFT_OP || + dic->op == RIGHT_OP || + dic->op == '-') && + IS_OP_LITERAL(IC_RIGHT(dic))) + return NULL; + else + return dic; + } + } + + return NULL; +} + +/*-----------------------------------------------------------------*/ +/* packRegsForAssign - register reduction for assignment */ +/*-----------------------------------------------------------------*/ +int packRegsForAssign (iCode *ic,eBBlock *ebp) +{ + iCode *dic, *sic; + + if ( +/* !IS_TRUE_SYMOP(IC_RESULT(ic)) || */ + !IS_ITEMP(IC_RIGHT(ic)) || + OP_LIVETO(IC_RIGHT(ic)) > ic->seq || + OP_SYMBOL(IC_RIGHT(ic))->isind) + return 0; + + /* if the true symbol is defined in far space or on stack + then we should not since this will increase register pressure */ + if (isOperandInFarSpace(IC_RESULT(ic))) { + if ((dic = farSpacePackable(ic))) + goto pack; + else + return 0; + + } + /* find the definition of iTempNN scanning backwards if we find a + a use of the true symbol in before we find the definition then + we cannot */ + for ( dic = ic->prev ; dic ; dic = dic->prev) { + + /* if there is a function call and this is + a parameter & not my parameter then don't pack it */ + if ( (dic->op == CALL || dic->op == PCALL) && + (OP_SYMBOL(IC_RESULT(ic))->_isparm && + !OP_SYMBOL(IC_RESULT(ic))->ismyparm)) { + dic = NULL; + break; + } + + if (SKIP_IC2(dic)) + continue; + + if (IS_SYMOP(IC_RESULT(dic)) && + IC_RESULT(dic)->key == IC_RIGHT(ic)->key) { + if (POINTER_SET(dic)) + dic = NULL; + + break; + } + + if (IS_SYMOP(IC_RIGHT(dic)) && + (IC_RIGHT(dic)->key == IC_RESULT(ic)->key || + IC_RIGHT(dic)->key == IC_RIGHT(ic)->key)) { + dic = NULL; + break; + } + + if (IS_SYMOP(IC_LEFT(dic)) && + (IC_LEFT(dic)->key == IC_RESULT(ic)->key || + IC_LEFT(dic)->key == IC_RIGHT(ic)->key)) { + dic = NULL; + break; + } + + if (POINTER_SET(dic) && + IC_RESULT(dic)->key == IC_RESULT(ic)->key ) { + dic = NULL ; + break; + } + } + + if (!dic) + return 0 ; /* did not find */ + + /* if the result is on stack or iaccess then it must be + the same atleast one of the operands */ + if (OP_SYMBOL(IC_RESULT(ic))->onStack || + OP_SYMBOL(IC_RESULT(ic))->iaccess ) { + + /* the operation has only one symbol + operator then we can pack */ + if ((IC_LEFT(dic) && !IS_SYMOP(IC_LEFT(dic))) || + (IC_RIGHT(dic) && !IS_SYMOP(IC_RIGHT(dic)))) + goto pack; + + if (!((IC_LEFT(dic) && + IC_RESULT(ic)->key == IC_LEFT(dic)->key) || + (IC_RIGHT(dic) && + IC_RESULT(ic)->key == IC_RIGHT(dic)->key))) + return 0; + } +pack: + /* found the definition */ + /* replace the result with the result of */ + /* this assignment and remove this assignment */ + IC_RESULT(dic) = IC_RESULT(ic) ; + + if (IS_ITEMP(IC_RESULT(dic)) && OP_SYMBOL(IC_RESULT(dic))->liveFrom > dic->seq) { + OP_SYMBOL(IC_RESULT(dic))->liveFrom = dic->seq; + } + /* delete from liverange table also + delete from all the points inbetween and the new + one */ + for ( sic = dic; sic != ic ; sic = sic->next ) { + bitVectUnSetBit(sic->rlive,IC_RESULT(ic)->key); + if (IS_ITEMP(IC_RESULT(dic))) + bitVectSetBit(sic->rlive,IC_RESULT(dic)->key); + } + + remiCodeFromeBBlock(ebp,ic); + return 1; + +} + +/*-----------------------------------------------------------------*/ +/* findAssignToSym : scanning backwards looks for first assig found*/ +/*-----------------------------------------------------------------*/ +iCode *findAssignToSym (operand *op,iCode *ic) +{ + iCode *dic; + + for (dic = ic->prev ; dic ; dic = dic->prev) { + + /* if definition by assignment */ + if (dic->op == '=' && + !POINTER_SET(dic) && + IC_RESULT(dic)->key == op->key +/* && IS_TRUE_SYMOP(IC_RIGHT(dic)) */ + ) { + + /* we are interested only if defined in far space */ + /* or in stack space in case of + & - */ + + /* if assigned to a non-symbol then return + true */ + if (!IS_SYMOP(IC_RIGHT(dic))) + break ; + + /* if the symbol is in far space then + we should not */ + if (isOperandInFarSpace(IC_RIGHT(dic))) + return NULL ; + + /* for + & - operations make sure that + if it is on the stack it is the same + as one of the three operands */ + if ((ic->op == '+' || ic->op == '-') && + OP_SYMBOL(IC_RIGHT(dic))->onStack) { + + if ( IC_RESULT(ic)->key != IC_RIGHT(dic)->key && + IC_LEFT(ic)->key != IC_RIGHT(dic)->key && + IC_RIGHT(ic)->key != IC_RIGHT(dic)->key) + return NULL; + } + + break ; + + } + + /* if we find an usage then we cannot delete it */ + if (IC_LEFT(dic) && IC_LEFT(dic)->key == op->key) + return NULL; + + if (IC_RIGHT(dic) && IC_RIGHT(dic)->key == op->key) + return NULL; + + if (POINTER_SET(dic) && IC_RESULT(dic)->key == op->key) + return NULL; + } + + /* now make sure that the right side of dic + is not defined between ic & dic */ + if (dic) { + iCode *sic = dic->next ; + + for (; sic != ic ; sic = sic->next) + if (IC_RESULT(sic) && + IC_RESULT(sic)->key == IC_RIGHT(dic)->key) + return NULL; + } + + return dic; + + +} + +/*-----------------------------------------------------------------*/ +/* packRegsForSupport :- reduce some registers for support calls */ +/*-----------------------------------------------------------------*/ +int packRegsForSupport (iCode *ic, eBBlock *ebp) +{ + int change = 0 ; + /* for the left & right operand :- look to see if the + left was assigned a true symbol in far space in that + case replace them */ + if (IS_ITEMP(IC_LEFT(ic)) && + OP_SYMBOL(IC_LEFT(ic))->liveTo <= ic->seq) { + iCode *dic = findAssignToSym(IC_LEFT(ic),ic); + iCode *sic; + + if (!dic) + goto right ; + + /* found it we need to remove it from the + block */ + for ( sic = dic; sic != ic ; sic = sic->next ) + bitVectUnSetBit(sic->rlive,IC_LEFT(ic)->key); + + IC_LEFT(ic)->operand.symOperand = + IC_RIGHT(dic)->operand.symOperand; + IC_LEFT(ic)->key = IC_RIGHT(dic)->operand.symOperand->key; + remiCodeFromeBBlock(ebp,dic); + change++; + } + + /* do the same for the right operand */ + right: + if (!change && + IS_ITEMP(IC_RIGHT(ic)) && + OP_SYMBOL(IC_RIGHT(ic))->liveTo <= ic->seq) { + iCode *dic = findAssignToSym(IC_RIGHT(ic),ic); + iCode *sic; + + if (!dic) + return change ; + + /* if this is a subtraction & the result + is a true symbol in far space then don't pack */ + if (ic->op == '-' && IS_TRUE_SYMOP(IC_RESULT(dic))) { + link *etype =getSpec(operandType(IC_RESULT(dic))); + if (IN_FARSPACE(SPEC_OCLS(etype))) + return change ; + } + /* found it we need to remove it from the + block */ + for ( sic = dic; sic != ic ; sic = sic->next ) + bitVectUnSetBit(sic->rlive,IC_RIGHT(ic)->key); + + IC_RIGHT(ic)->operand.symOperand = + IC_RIGHT(dic)->operand.symOperand; + IC_RIGHT(ic)->key = IC_RIGHT(dic)->operand.symOperand->key; + + remiCodeFromeBBlock(ebp,dic); + change ++; + } + + return change ; +} + +#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) + + +/*-----------------------------------------------------------------*/ +/* packRegsForOneuse : - will reduce some registers for single Use */ +/*-----------------------------------------------------------------*/ +static iCode *packRegsForOneuse (iCode *ic, operand *op , eBBlock *ebp) +{ + bitVect *uses ; + iCode *dic, *sic; + + /* if returning a literal then do nothing */ + if (!IS_SYMOP(op)) + return NULL; + + /* only upto 2 bytes since we cannot predict + the usage of b, & acc */ + if (getSize(operandType(op)) > 2 && + ic->op != RETURN && + ic->op != SEND) + return NULL; + + /* this routine will mark the a symbol as used in one + instruction use only && if the defintion is local + (ie. within the basic block) && has only one definition && + that definiion is either a return value from a + function or does not contain any variables in + far space */ + uses = bitVectCopy(OP_USES(op)); + bitVectUnSetBit(uses,ic->key); /* take away this iCode */ + if (!bitVectIsZero(uses)) /* has other uses */ + return NULL ; + + /* if it has only one defintion */ + if (bitVectnBitsOn(OP_DEFS(op)) > 1) + return NULL ; /* has more than one definition */ + + /* get the that definition */ + if (!(dic = + hTabItemWithKey(iCodehTab, + bitVectFirstBit(OP_DEFS(op))))) + return NULL ; + + /* found the definition now check if it is local */ + if (dic->seq < ebp->fSeq || + dic->seq > ebp->lSeq) + return NULL ; /* non-local */ + + /* now check if it is the return from + a function call */ + if (dic->op == CALL || dic->op == PCALL ) { + if (ic->op != SEND && ic->op != RETURN) { + OP_SYMBOL(op)->ruonly = 1; + return dic; + } + dic = dic->next ; + } + + + /* otherwise check that the definition does + not contain any symbols in far space */ + if (isOperandInFarSpace(IC_LEFT(dic)) || + isOperandInFarSpace(IC_RIGHT(dic)) || + IS_OP_RUONLY(IC_LEFT(ic)) || + IS_OP_RUONLY(IC_RIGHT(ic)) ) { + return NULL; + } + + /* if pointer set then make sure the pointer + is one byte */ + if (POINTER_SET(dic) && + !IS_DATA_PTR(aggrToPtr(operandType(IC_RESULT(dic)),FALSE))) + return NULL ; + + if (POINTER_GET(dic) && + !IS_DATA_PTR(aggrToPtr(operandType(IC_LEFT(dic)),FALSE))) + return NULL ; + + sic = dic; + + /* also make sure the intervenening instructions + don't have any thing in far space */ + for (dic = dic->next ; dic && dic != ic ; dic = dic->next) { + + /* if there is an intervening function call then no */ + if (dic->op == CALL || dic->op == PCALL) + return NULL; + /* if pointer set then make sure the pointer + is one byte */ + if (POINTER_SET(dic) && + !IS_DATA_PTR(aggrToPtr(operandType(IC_RESULT(dic)),FALSE))) + return NULL ; + + if (POINTER_GET(dic) && + !IS_DATA_PTR(aggrToPtr(operandType(IC_LEFT(dic)),FALSE))) + return NULL ; + + /* if address of & the result is remat the okay */ + if (dic->op == ADDRESS_OF && + OP_SYMBOL(IC_RESULT(dic))->remat) + continue ; + + /* if operand has size of three or more & this + operation is a '*','/' or '%' then 'b' may + cause a problem */ + if (( dic->op == '%' || dic->op == '/' || dic->op == '*') && + getSize(aggrToPtr(operandType(op),FALSE)) >= 3) + return NULL; + + /* if left or right or result is in far space */ + if (isOperandInFarSpace(IC_LEFT(dic)) || + isOperandInFarSpace(IC_RIGHT(dic)) || + isOperandInFarSpace(IC_RESULT(dic)) || + IS_OP_RUONLY(IC_LEFT(dic)) || + IS_OP_RUONLY(IC_RIGHT(dic)) || + IS_OP_RUONLY(IC_RESULT(dic)) ) { + return NULL; + } + } + + OP_SYMBOL(op)->ruonly = 1; + return sic; + +} + +/*-----------------------------------------------------------------*/ +/* isBitwiseOptimizable - requirements of JEAN LOUIS VERN */ +/*-----------------------------------------------------------------*/ +static bool isBitwiseOptimizable (iCode *ic) +{ + link *ltype = getSpec(operandType(IC_LEFT(ic))); + link *rtype = getSpec(operandType(IC_RIGHT(ic))); + + /* bitwise operations are considered optimizable + under the following conditions (Jean-Louis VERN) + + x & lit + bit & bit + bit & x + bit ^ bit + bit ^ x + x ^ lit + x | lit + bit | bit + bit | x + */ + if ( IS_LITERAL(rtype) || + (IS_BITVAR(ltype) && IN_BITSPACE(SPEC_OCLS(ltype)))) + return TRUE ; + else + return FALSE ; +} + +/*-----------------------------------------------------------------*/ +/* packRegsForAccUse - pack registers for acc use */ +/*-----------------------------------------------------------------*/ +void packRegsForAccUse (iCode *ic) +{ + iCode *uic; + + /* if + or - then it has to be one byte result */ + if ((ic->op == '+' || ic->op == '-') + && getSize(operandType(IC_RESULT(ic))) > 1) + return ; + + /* if shift operation make sure right side is not a literal */ + if (ic->op == RIGHT_OP && + ( isOperandLiteral(IC_RIGHT(ic)) || + getSize(operandType(IC_RESULT(ic))) > 1)) + return ; + + if (ic->op == LEFT_OP && + ( isOperandLiteral(IC_RIGHT(ic)) || + getSize(operandType(IC_RESULT(ic))) > 1)) + return ; + + + /* has only one definition */ + if (bitVectnBitsOn(OP_DEFS(IC_RESULT(ic))) > 1) + return ; + + /* has only one use */ + if (bitVectnBitsOn(OP_USES(IC_RESULT(ic))) > 1) + return ; + + /* and the usage immediately follows this iCode */ + if (!(uic = hTabItemWithKey(iCodehTab, + bitVectFirstBit(OP_USES(IC_RESULT(ic)))))) + return ; + + if (ic->next != uic) + return ; + + /* if it is a conditional branch then we definitely can */ + if (uic->op == IFX ) + goto accuse; + + if ( uic->op == JUMPTABLE ) + return ; + + /* if the usage is not is an assignment + or an arithmetic / bitwise / shift operation then not */ + if (POINTER_SET(uic) && + getSize(aggrToPtr(operandType(IC_RESULT(uic)),FALSE)) > 1) + return; + + if (uic->op != '=' && + !IS_ARITHMETIC_OP(uic) && + !IS_BITWISE_OP(uic) && + uic->op != LEFT_OP && + uic->op != RIGHT_OP ) + return; + + /* if used in ^ operation then make sure right is not a + literl */ + if (uic->op == '^' && isOperandLiteral(IC_RIGHT(uic))) + return ; + + /* if shift operation make sure right side is not a literal */ + if (uic->op == RIGHT_OP && + ( isOperandLiteral(IC_RIGHT(uic)) || + getSize(operandType(IC_RESULT(uic))) > 1)) + return ; + + if (uic->op == LEFT_OP && + ( isOperandLiteral(IC_RIGHT(uic)) || + getSize(operandType(IC_RESULT(uic))) > 1)) + return ; + + /* make sure that the result of this icode is not on the + stack, since acc is used to compute stack offset */ + if (IS_TRUE_SYMOP(IC_RESULT(uic)) && + OP_SYMBOL(IC_RESULT(uic))->onStack) + return ; + + /* if either one of them in far space then we cannot */ + if ((IS_TRUE_SYMOP(IC_LEFT(uic)) && + isOperandInFarSpace(IC_LEFT(uic))) || + (IS_TRUE_SYMOP(IC_RIGHT(uic)) && + isOperandInFarSpace(IC_RIGHT(uic)))) + return ; + + /* if the usage has only one operand then we can */ + if (IC_LEFT(uic) == NULL || + IC_RIGHT(uic) == NULL) + goto accuse; + + /* make sure this is on the left side if not + a '+' since '+' is commutative */ + if (ic->op != '+' && + IC_LEFT(uic)->key != IC_RESULT(ic)->key) + return; + + /* if one of them is a literal then we can */ + if ((IC_LEFT(uic) && IS_OP_LITERAL(IC_LEFT(uic))) || + (IC_RIGHT(uic) && IS_OP_LITERAL(IC_RIGHT(uic)))) { + OP_SYMBOL(IC_RESULT(ic))->accuse = 1; + return ; + } + + /* if the other one is not on stack then we can */ + if (IC_LEFT(uic)->key == IC_RESULT(ic)->key && + (IS_ITEMP(IC_RIGHT(uic)) || + (IS_TRUE_SYMOP(IC_RIGHT(uic)) && + !OP_SYMBOL(IC_RIGHT(uic))->onStack))) + goto accuse; + + if (IC_RIGHT(uic)->key == IC_RESULT(ic)->key && + (IS_ITEMP(IC_LEFT(uic)) || + (IS_TRUE_SYMOP(IC_LEFT(uic)) && + !OP_SYMBOL(IC_LEFT(uic))->onStack))) + goto accuse ; + + return ; + + accuse: + OP_SYMBOL(IC_RESULT(ic))->accuse = 1; + + +} + +/*-----------------------------------------------------------------*/ +/* packForPush - hueristics to reduce iCode for pushing */ +/*-----------------------------------------------------------------*/ +static void packForPush(iCode *ic, eBBlock *ebp) +{ + iCode *dic; + + if (ic->op != IPUSH || !IS_ITEMP(IC_LEFT(ic))) + return ; + + /* must have only definition & one usage */ + if (bitVectnBitsOn(OP_DEFS(IC_LEFT(ic))) != 1 || + bitVectnBitsOn(OP_USES(IC_LEFT(ic))) != 1 ) + return ; + + /* find the definition */ + if (!(dic = hTabItemWithKey(iCodehTab, + bitVectFirstBit(OP_DEFS(IC_LEFT(ic)))))) + return ; + + if (dic->op != '=' || POINTER_SET(dic)) + return; + + /* we now we know that it has one & only one def & use + and the that the definition is an assignment */ + IC_LEFT(ic) = IC_RIGHT(dic); + + remiCodeFromeBBlock(ebp,dic); +} + +/*-----------------------------------------------------------------*/ +/* packRegisters - does some transformations to reduce register */ +/* pressure */ +/*-----------------------------------------------------------------*/ +static void packRegisters (eBBlock *ebp) +{ + iCode *ic ; + int change = 0 ; + + while (1) { + + change = 0; + + /* look for assignments of the form */ + /* iTempNN = TRueSym (someoperation) SomeOperand */ + /* .... */ + /* TrueSym := iTempNN:1 */ + for ( ic = ebp->sch ; ic ; ic = ic->next ) { + + + /* find assignment of the form TrueSym := iTempNN:1 */ + if (ic->op == '=' && !POINTER_SET(ic)) + change += packRegsForAssign(ic,ebp); + } + + if (!change) + break; + } + + for ( ic = ebp->sch ; ic ; ic = ic->next ) { + + /* if this is an itemp & result of a address of a true sym + then mark this as rematerialisable */ + if (ic->op == ADDRESS_OF && + IS_ITEMP(IC_RESULT(ic)) && + IS_TRUE_SYMOP(IC_LEFT(ic)) && + bitVectnBitsOn(OP_DEFS(IC_RESULT(ic))) == 1 && + !OP_SYMBOL(IC_LEFT(ic))->onStack ) { + + OP_SYMBOL(IC_RESULT(ic))->remat = 1; + OP_SYMBOL(IC_RESULT(ic))->rematiCode = ic; + OP_SYMBOL(IC_RESULT(ic))->usl.spillLoc = NULL; + + } + + /* if straight assignment then carry remat flag if + this is the only definition */ + if (ic->op == '=' && + !POINTER_SET(ic) && + IS_SYMOP(IC_RIGHT(ic)) && + OP_SYMBOL(IC_RIGHT(ic))->remat && + bitVectnBitsOn(OP_SYMBOL(IC_RESULT(ic))->defs) <= 1) { + + OP_SYMBOL(IC_RESULT(ic))->remat = + OP_SYMBOL(IC_RIGHT(ic))->remat; + OP_SYMBOL(IC_RESULT(ic))->rematiCode = + OP_SYMBOL(IC_RIGHT(ic))->rematiCode ; + } + + /* if this is a +/- operation with a rematerizable + then mark this as rematerializable as well only + if the literal value is within the range -255 and + 255 + the assembler cannot handle it other wise */ + if ((ic->op == '+' || ic->op == '-') && + + (IS_SYMOP(IC_LEFT(ic)) && + IS_ITEMP(IC_RESULT(ic)) && + OP_SYMBOL(IC_LEFT(ic))->remat && + bitVectnBitsOn(OP_DEFS(IC_RESULT(ic))) == 1 && + IS_OP_LITERAL(IC_RIGHT(ic))) ) { + + int i = operandLitValue(IC_RIGHT(ic)); + if ( i < 255 && i > -255) { + OP_SYMBOL(IC_RESULT(ic))->remat = 1; + OP_SYMBOL(IC_RESULT(ic))->rematiCode = ic; + OP_SYMBOL(IC_RESULT(ic))->usl.spillLoc = NULL; + } + } + + /* mark the pointer usages */ + if (POINTER_SET(ic)) + OP_SYMBOL(IC_RESULT(ic))->uptr = 1; + + if (POINTER_GET(ic)) + OP_SYMBOL(IC_LEFT(ic))->uptr = 1; + + if (!SKIP_IC2(ic)) { + /* if we are using a symbol on the stack + then we should say ptrRegReq */ + if (ic->op == IFX && IS_SYMOP(IC_COND(ic))) + ptrRegReq += ((OP_SYMBOL(IC_COND(ic))->onStack || + OP_SYMBOL(IC_COND(ic))->iaccess) ? 1 : 0); + else + if (ic->op == JUMPTABLE && IS_SYMOP(IC_JTCOND(ic))) + ptrRegReq += ((OP_SYMBOL(IC_JTCOND(ic))->onStack || + OP_SYMBOL(IC_JTCOND(ic))->iaccess) ? 1 : 0); + else { + if (IS_SYMOP(IC_LEFT(ic))) + ptrRegReq += ((OP_SYMBOL(IC_LEFT(ic))->onStack || + OP_SYMBOL(IC_LEFT(ic))->iaccess) ? 1 : 0); + if (IS_SYMOP(IC_RIGHT(ic))) + ptrRegReq += ((OP_SYMBOL(IC_RIGHT(ic))->onStack || + OP_SYMBOL(IC_RIGHT(ic))->iaccess) ? 1 : 0); + if (IS_SYMOP(IC_RESULT(ic))) + ptrRegReq += ((OP_SYMBOL(IC_RESULT(ic))->onStack || + OP_SYMBOL(IC_RESULT(ic))->iaccess) ? 1 : 0); + } + } + + /* if the condition of an if instruction + is defined in the previous instruction then + mark the itemp as a conditional */ + if ((IS_CONDITIONAL(ic) || + ( ( ic->op == BITWISEAND || + ic->op == '|' || + ic->op == '^' ) && + isBitwiseOptimizable(ic))) && + ic->next && ic->next->op == IFX && + isOperandEqual(IC_RESULT(ic),IC_COND(ic->next)) && + OP_SYMBOL(IC_RESULT(ic))->liveTo <= ic->next->seq) { + + OP_SYMBOL(IC_RESULT(ic))->regType = REG_CND; + continue ; + } + + /* reduce for support function calls */ + if (ic->supportRtn || ic->op == '+' || ic->op == '-' ) + packRegsForSupport (ic,ebp); + + /* some cases the redundant moves can + can be eliminated for return statements */ + if ((ic->op == RETURN || ic->op == SEND) && + !isOperandInFarSpace(IC_LEFT(ic)) && + !options.model) + packRegsForOneuse (ic,IC_LEFT(ic),ebp); + + /* if pointer set & left has a size more than + one and right is not in far space */ + if (POINTER_SET(ic) && + !isOperandInFarSpace(IC_RIGHT(ic)) && + !OP_SYMBOL(IC_RESULT(ic))->remat && + !IS_OP_RUONLY(IC_RIGHT(ic)) && + getSize(aggrToPtr(operandType(IC_RESULT(ic)),FALSE)) > 1 ) + + packRegsForOneuse (ic,IC_RESULT(ic),ebp); + + /* if pointer get */ + if (POINTER_GET(ic) && + !isOperandInFarSpace(IC_RESULT(ic))&& + !OP_SYMBOL(IC_LEFT(ic))->remat && + !IS_OP_RUONLY(IC_RESULT(ic)) && + getSize(aggrToPtr(operandType(IC_LEFT(ic)),FALSE)) > 1 ) + + packRegsForOneuse (ic,IC_LEFT(ic),ebp); + + + /* if this is cast for intergral promotion then + check if only use of the definition of the + operand being casted/ if yes then replace + the result of that arithmetic operation with + this result and get rid of the cast */ + if (ic->op == CAST) { + link *fromType = operandType(IC_RIGHT(ic)); + link *toType = operandType(IC_LEFT(ic)); + + if (IS_INTEGRAL(fromType) && IS_INTEGRAL(toType) && + getSize(fromType) != getSize(toType) ) { + + iCode *dic = packRegsForOneuse(ic,IC_RIGHT(ic),ebp); + if (dic) { + if (IS_ARITHMETIC_OP(dic)) { + IC_RESULT(dic) = IC_RESULT(ic); + remiCodeFromeBBlock(ebp,ic); + ic = ic->prev; + } else + OP_SYMBOL(IC_RIGHT(ic))->ruonly = 0; + } + } else { + + /* if the type from and type to are the same + then if this is the only use then packit */ + if (checkType(operandType(IC_RIGHT(ic)), + operandType(IC_LEFT(ic))) == 1) { + iCode *dic = packRegsForOneuse (ic,IC_RIGHT(ic),ebp); + if (dic) { + IC_RESULT(dic) = IC_RESULT(ic); + remiCodeFromeBBlock(ebp,ic); + ic = ic->prev; + } + } + } + } + + /* pack for PUSH + iTempNN := (some variable in farspace) V1 + push iTempNN ; + ------------- + push V1 + */ + if (ic->op == IPUSH ) { + packForPush(ic,ebp); + } + + + /* pack registers for accumulator use, when the + result of an arithmetic or bit wise operation + has only one use, that use is immediately following + the defintion and the using iCode has only one + operand or has two operands but one is literal & + the result of that operation is not on stack then + we can leave the result of this operation in acc:b + combination */ + if ((IS_ARITHMETIC_OP(ic) + + || IS_BITWISE_OP(ic) + + || ic->op == LEFT_OP || ic->op == RIGHT_OP + + ) && + IS_ITEMP(IC_RESULT(ic)) && + getSize(operandType(IC_RESULT(ic))) <= 2) + + packRegsForAccUse (ic); + + } +} + +/*-----------------------------------------------------------------*/ +/* assignRegisters - assigns registers to each live range as need */ +/*-----------------------------------------------------------------*/ +void assignRegisters (eBBlock **ebbs, int count) +{ + iCode *ic; + int i ; + + setToNull((void *)&funcrUsed); + ptrRegReq = stackExtend = dataExtend = 0; + /* if not register extentions then reduce number + of registers */ + if (options.regExtend) + nRegs = 13; + else + nRegs = 8; + + /* change assignments this will remove some + live ranges reducing some register pressure */ + for (i = 0 ; i < count ;i++ ) + packRegisters (ebbs[i]); + + if (options.dump_pack) + dumpEbbsToFileExt(".dumppack",ebbs,count); + + /* first determine for each live range the number of + registers & the type of registers required for each */ + regTypeNum (); + + /* and serially allocate registers */ + serialRegAssign(ebbs,count); + + /* if stack was extended then tell the user */ + if (stackExtend) { +/* werror(W_TOOMANY_SPILS,"stack", */ +/* stackExtend,currFunc->name,""); */ + stackExtend = 0 ; + } + + if (dataExtend) { +/* werror(W_TOOMANY_SPILS,"data space", */ +/* dataExtend,currFunc->name,""); */ + dataExtend = 0 ; + } + + /* after that create the register mask + for each of the instruction */ + createRegMask (ebbs,count); + + /* redo that offsets for stacked automatic variables */ + redoStackOffsets (); + + if (options.dump_rassgn) + dumpEbbsToFileExt(".dumprassgn",ebbs,count); + + /* now get back the chain */ + ic = iCodeLabelOptimize(iCodeFromeBBlock (ebbs,count)); + + + gen51Code(ic); + + /* free up any stackSpil locations allocated */ + applyToSet(stackSpil,deallocStackSpil); + slocNum = 0; + setToNull((void **)&stackSpil); + setToNull((void **)&spiltSet); + /* mark all registers as free */ + freeAllRegs(); + + return ; +} diff --git a/src/SDCCralloc.h b/src/SDCCralloc.h new file mode 100644 index 00000000..4db755fb --- /dev/null +++ b/src/SDCCralloc.h @@ -0,0 +1,58 @@ +/*------------------------------------------------------------------------- + + SDCCralloc.h - header file register allocation + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "SDCCicode.h" +#include "SDCCBBlock.h" +#ifndef SDCCRALLOC_H +#define SDCCRALLOC_H 1 + +enum { R2_IDX = 0, R3_IDX , R4_IDX , + R5_IDX ,R6_IDX , R7_IDX , + R0_IDX ,R1_IDX , X8_IDX , + X9_IDX ,X10_IDX , X11_IDX , + X12_IDX ,CND_IDX }; + + +#define REG_PTR 0x01 +#define REG_GPR 0x02 +#define REG_CND 0x04 +/* definition for the registers */ +typedef struct regs +{ + short type; /* can have value + REG_GPR, REG_PTR or REG_CND */ + short rIdx ; /* index into register table */ + short otype; + char *name ; /* name */ + char *dname; /* name when direct access needed */ + char *base ; /* base address */ + short offset; /* offset from the base */ + unsigned isFree :1; /* is currently unassigned */ +} regs; +extern regs regs8051[]; + +void assignRegisters (eBBlock **, int ); +regs *regWithIdx (int); + +#endif diff --git a/src/SDCCset.c b/src/SDCCset.c new file mode 100644 index 00000000..a4844a37 --- /dev/null +++ b/src/SDCCset.c @@ -0,0 +1,500 @@ +/*----------------------------------------------------------------- + SDCCset.c - contains support routines for sets + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include "SDCCset.h" + +/*-----------------------------------------------------------------*/ +/* newSet - will allocate & return a new set entry */ +/*-----------------------------------------------------------------*/ +set *newSet () +{ + set *lp ; + + ALLOC(lp,sizeof(set)) ; + + lp->item = lp->curr= lp->next = NULL; + return lp; +} + + +/*-----------------------------------------------------------------*/ +/* setFromSet - creates a list from another list */ +/*-----------------------------------------------------------------*/ +set *setFromSet (set *lp) +{ + set *lfl = NULL ; + + while (lp) { + addSetHead(&lfl,lp->item); + lp = lp->next ; + } + + return lfl ; + +} + +/*-----------------------------------------------------------------*/ +/* isSetsEqual - are the lists equal, they are equal if they have */ +/* the same objects & the same number of objects */ +/*-----------------------------------------------------------------*/ +int isSetsEqual ( set *dest, set *src ) +{ + set *src1 = src ; + + for (; dest && src ; dest=dest->next , src=src->next) { + if (!isinSet(src1, dest->item)) + return 0; + } + if ( !dest && !src) + return 1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isSetsEqualWith - are the lists equal, they are equal if they have */ +/* the same objects & the same number of objects , compare function */ +/*-----------------------------------------------------------------*/ +int isSetsEqualWith ( set *dest, set *src , int (*cFunc)(void *,void *)) +{ + set *src1 = src ; + + for (; dest && src ; dest=dest->next , src=src->next) { + if (!isinSetWith(src1, dest->item,cFunc)) + return 0; + } + if ( !dest && !src) + return 1; + return 0; +} + +/*-----------------------------------------------------------------*/ +/* addSetIfnotP - adds to a linked list if not already present */ +/*-----------------------------------------------------------------*/ +void *addSetIfnotP ( set **list, void *item) +{ + + if (isinSet(*list,item)) + return item ; + + addSetHead(list,item); + + return item; +} + +/*-----------------------------------------------------------------*/ +/* addSetHead - add item to head of linked list */ +/*-----------------------------------------------------------------*/ +void *addSetHead (set **list, void *item ) +{ + set *lp = newSet(); + + lp->item = item ; + lp->next = *list ; + + assert(lp != lp->item); + *list = lp ; + return item ; + +} + +/*-----------------------------------------------------------------*/ +/* addSet - add an item to a linear linked list */ +/*-----------------------------------------------------------------*/ +void *addSet ( set **list , void *item ) +{ + set *lp ; + + /* item added to the tail of the list */ + + /* if the list is empty */ + if (*list == NULL ) { + lp = *list = newSet(); + } else { + /* go to the end of the list */ + for (lp = *list ; lp->next ; lp = lp->next ); + lp = lp->next = newSet(); + } + + /* lp now all set */ + lp->item = item ; + + return item ; +} + +/*-----------------------------------------------------------------*/ +/* deleteItemIf - will delete from set if cond function returns 1 */ +/*-----------------------------------------------------------------*/ +void deleteItemIf ( set **sset, int (*cond) (void *, va_list), ... ) +{ + set *sp = *sset ; + va_list ap; + + va_start(ap,cond); + + while (sp) { + if ((*cond)(sp->item,ap)) { + deleteSetItem(sset,sp->item); + sp = *sset ; + continue ; + } + + sp = sp->next ; + } +} + +/*-----------------------------------------------------------------*/ +/* deleteSetItem - will delete a given item from the list */ +/*-----------------------------------------------------------------*/ +void deleteSetItem ( set **list, void *item ) +{ + set *lp , *lp1; + + /* if list is empty */ + if (*list == NULL ) + return ; + + /* if this item is at the head of the list */ + if ((*list)->item == item ) { + lp = *list ; + *list = (*list)->next ; + return ; + } + + /* find the item in the list */ + for (lp = *list ; lp->next ; lp = lp->next ) { + if (lp->next->item == item ) /* the next one is it */ { + lp1 = lp->next ; /* this one will need to be freed */ + lp->next = lp->next->next ; /* take out of list */ + return ; + } + } + + /* could not find it */ + return ; +} + +/*-----------------------------------------------------------------*/ +/* isinSet - the item is present in the linked list */ +/*-----------------------------------------------------------------*/ +int isinSet (set *list, void *item ) +{ + set *lp ; + + for (lp = list ; lp ; lp = lp->next ) + if ( lp->item == item ) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* isinSetWith - the item is present in the linked list */ +/*-----------------------------------------------------------------*/ +int isinSetWith (set *list, void *item , int (*cFunc)(void *,void *) ) +{ + set *lp ; + + for (lp = list ; lp ; lp = lp->next ) + if ( (*cFunc)(lp->item,item) ) + return 1; + + return 0; +} + +/*-----------------------------------------------------------------*/ +/* unionSets - will return the union of the two lists */ +/*-----------------------------------------------------------------*/ +set *unionSets (set *list1 , set *list2, int throw) +{ + set *un = NULL ; + set *lp ; + + /* add all elements in the first list */ + for (lp = list1 ; lp ; lp = lp->next ) + addSet(&un,lp->item); + + /* now for all those in list2 which does not */ + /* already exist in the list add */ + for (lp = list2 ; lp ; lp = lp->next ) + if (!isinSet(un,lp->item)) + addSet (&un,lp->item); + + switch (throw) { + case THROW_SRC : + setToNull ((void **)&list2); + break; + case THROW_DEST : + setToNull ((void **)&list1); + break; + case THROW_BOTH : + setToNull ((void **)&list1); + setToNull ((void **)&list2); + } + + return un; +} + +/*-----------------------------------------------------------------*/ +/* unionSetsWith - will return the union of the two lists */ +/*-----------------------------------------------------------------*/ +set *unionSetsWith (set *list1 , set *list2, int (*cFunc)(),int throw) +{ + set *un = NULL ; + set *lp ; + + /* add all elements in the first list */ + for (lp = list1 ; lp ; lp = lp->next ) + addSet (&un,lp->item); + + /* now for all those in list2 which does not */ + /* already exist in the list add */ + for (lp = list2 ; lp ; lp = lp->next ) + if (!isinSetWith(un,lp->item,cFunc)) + addSet (&un,lp->item); + + switch (throw) { + case THROW_SRC : + setToNull ((void **)&list2); + break; + case THROW_DEST : + setToNull ((void **)&list1); + break; + case THROW_BOTH : + setToNull ((void **)&list1); + setToNull ((void **)&list2); + } + + return un; +} + +/*-----------------------------------------------------------------*/ +/* intersectSets - returns list of items in common to two lists */ +/*-----------------------------------------------------------------*/ +set *intersectSets (set *list1, set *list2, int throw) +{ + set *in = NULL; + set *lp ; + + /* we can take any one of the lists and iterate over it */ + for (lp = list1 ; lp ; lp = lp->next ) + if (isinSet (list2,lp->item) ) + addSetHead(&in,lp->item); + + switch (throw) { + case THROW_SRC : + setToNull ((void **)&list2); + break; + case THROW_DEST : + setToNull ((void **)&list1); + break; + case THROW_BOTH : + setToNull ((void **)&list1); + setToNull ((void **)&list2); + } + + return in; +} + +/*-----------------------------------------------------------------*/ +/* intersectSetsWith - returns list of items in common to two lists*/ +/*-----------------------------------------------------------------*/ +set *intersectSetsWith (set *list1, set *list2, + int (*cFunc)(void *,void *),int throw) +{ + set *in = NULL; + set *lp ; + + /* we can take any one of the lists and iterate over it */ + for (lp = list1 ; lp ; lp = lp->next ) + if (isinSetWith (list2,lp->item,cFunc) ) + addSetHead(&in,lp->item); + + switch (throw) { + case THROW_SRC : + setToNull ((void **)&list2); + break; + case THROW_DEST : + setToNull ((void **)&list1); + break; + case THROW_BOTH : + setToNull ((void **)&list1); + setToNull ((void **)&list2); + } + + return in; +} + +/*-----------------------------------------------------------------*/ +/* elementsInSet - elements count of a set */ +/*-----------------------------------------------------------------*/ +int elementsInSet (set *s) +{ + set *loop = s; + int count = 0 ; + + while (loop) { + count++ ; + loop = loop->next ; + } + + return count ; +} + +/*-----------------------------------------------------------------*/ +/* subtractFromSet - take away from set1 elements of set2 */ +/*-----------------------------------------------------------------*/ +set *subtractFromSet (set *left, set *right, int throw) +{ + set *result = setFromSet(left); + set *loop ; + + if (right) { + for (loop = right ; loop ; loop = loop->next) + if (isinSet(result,loop->item)) + deleteSetItem (&result,loop->item); + } + + switch (throw) { + case THROW_SRC : + setToNull ((void **)&right); + break; + case THROW_DEST : + setToNull ((void **)&left); + break; + case THROW_BOTH : + setToNull ((void **)&left); + setToNull ((void **)&right); + break ; + } + + return result ; +} + +/*-----------------------------------------------------------------*/ +/* applyToSet - will call the supplied function with each item */ +/*-----------------------------------------------------------------*/ +int applyToSet ( set *list , int (*somefunc)(void *, va_list ), ...) +{ + set *lp ; + va_list ap; + int rvalue = 0 ; + + va_start(ap,somefunc); + for (lp = list ; lp ; lp = lp->next ) + rvalue += (*somefunc)(lp->item,ap) ; + va_end(ap); + return rvalue; +} + +/*-----------------------------------------------------------------*/ +/* applyToSetFTrue - will call the supplied function with each item*/ +/* until list is exhausted or a true is returned */ +/*-----------------------------------------------------------------*/ +int applyToSetFTrue ( set *list , int (*somefunc)(void *, va_list ), ...) +{ + set *lp ; + va_list ap; + int rvalue = 0 ; + + va_start(ap,somefunc); + for (lp = list ; lp ; lp = lp->next ) + if (rvalue += (*somefunc)(lp->item,ap)) + break; + va_end(ap); + return rvalue; +} + +/*-----------------------------------------------------------------*/ +/* peekSet - will return the first element of the set */ +/*-----------------------------------------------------------------*/ +void *peekSet ( set *sp) +{ + if (!sp) + return NULL ; + + return sp->item; +} + +/*-----------------------------------------------------------------*/ +/* setFirstItem - gets the first item in the set, begins iteration */ +/*-----------------------------------------------------------------*/ +void *setFirstItem (set *sset) +{ + if (sset) { + sset->curr = sset ; + return sset->item ; + } + + return NULL ; +} +/*-----------------------------------------------------------------*/ +/* setNextItem - gets the next item, changes the iteration */ +/*-----------------------------------------------------------------*/ +void *setNextItem (set *sset) +{ + if (sset && sset->curr ) { + sset->curr = sset->curr->next ; + if ( sset->curr ) + return sset->curr->item ; + } + return NULL ; +} + +/*-----------------------------------------------------------------*/ +/* getSet - will delete & return the first item from the set */ +/*-----------------------------------------------------------------*/ +void *getSet (set **list) +{ + set *lp; + void *item ; + + /* if list is empty then we cannot delete */ + if (*list == NULL ) + return (void *) NULL ; + + + /* find the item in the list */ + lp = *list ; + item = lp->item; /* save the item */ + + *list = lp->next ; + return item ; +} + +/*-----------------------------------------------------------------*/ +/* setToNull - will throw away the entire list */ +/*-----------------------------------------------------------------*/ +void setToNull (void **item ) +{ + + if ( !item ) + return ; + + if (! *item ) + return ; + GC_free(*item); + *item = NULL ; +} diff --git a/src/SDCCset.h b/src/SDCCset.h new file mode 100644 index 00000000..26bed1c3 --- /dev/null +++ b/src/SDCCset.h @@ -0,0 +1,95 @@ +/*----------------------------------------------------------------- + SDCCset.h - contains support routines for sets . + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCCSET_H +#define SDCCSET_H +#include +#ifdef _NO_GC + +#define GC_malloc malloc +#define GC_free free +#define GC_realloc realloc + +#else + +#include "./gc/gc.h" + +#endif + +#ifndef ALLOC + +#define ALLOC(x,sz) if (!(x = GC_malloc(sz))) \ + { \ + fprintf(stderr,"out of virtual memory %s , %d",__FILE__,__LINE__);\ + exit (1); \ + } + +#endif + +#ifndef THROWS +#define THROWS +#define THROW_NONE 0 +#define THROW_SRC 1 +#define THROW_DEST 2 +#define THROW_BOTH 3 +#endif + +/* linear linked list generic */ +typedef struct set +{ + void *item ; + struct set *curr ; + struct set *next ; +} set ; + +#define DEFSETFUNC(fname) int fname ( void *item, va_list ap) +#define V_ARG(type,var) type var = va_arg(ap,type) + +/* set related functions */ +void *addSet ( set ** , void * ); +void *addSetHead ( set ** , void * ); +void *getSet ( set ** ); +void deleteSetItem ( set ** , void * ); +void deleteItemIf ( set ** , int (*cond) (void *, va_list), ... ); +int isinSet ( set * , void * ); +int isinSetWith ( set *, void *, int (*cfunc)()); +int applyToSet ( set *list ,int (*somefunc)(void *,va_list), ...); +int applyToSetFTrue ( set *list ,int (*somefunc)(void *,va_list), ...); +set *unionSets ( set *, set *, int); +set *unionSetsWith ( set *, set *, int (*cFunc)(),int); +set *intersectSets ( set *, set *, int); +void *addSetIfnotP ( set **, void *); +set *setFromSet ( set * ); +int isSetsEqual ( set *, set *); +set *subtractFromSet ( set *, set *,int); +int elementsInSet (set *); +set *intersectSetsWith (set *, set *,int (*cFunc)(),int ); +int isSetsEqualWith ( set *, set *, int (*cFunc)()); +void *peekSet ( set *); +void *setFirstItem ( set *); +void *setNextItem ( set *); +void setToNull (void ** ); + + +#endif diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c new file mode 100644 index 00000000..45cb114c --- /dev/null +++ b/src/SDCCsymt.c @@ -0,0 +1,1919 @@ +/*------------------------------------------------------------------------- + SDCCsymt.c - Code file for Symbols table related structures and MACRO's. + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCCval.h" +#include "SDCCast.h" +#include "SDCCy.h" +#include "SDCCset.h" + +bucket *SymbolTab [256] ; /* the symbol table */ +bucket *StructTab [256] ; /* the structure table */ +bucket *TypedefTab[256] ; /* the typedef table */ +bucket *LabelTab [256] ; /* the Label table */ +bucket *enumTab [256] ; /* enumerated table */ + +extern struct set *publics; + +/*------------------------------------------------------------------*/ +/* initSymt () - initialises symbol table related stuff */ +/*------------------------------------------------------------------*/ +void initSymt () +{ + int i = 0 ; + + for ( i = 0 ; i < 256 ; i++ ) + SymbolTab[i] = StructTab[i] = (void *) NULL ; + + +} +/*-----------------------------------------------------------------*/ +/* newBucket - allocates & returns a new bucket */ +/*-----------------------------------------------------------------*/ +bucket *newBucket () +{ + bucket *bp ; + + ALLOC(bp,sizeof(bucket)); + + return bp ; +} + +/*-----------------------------------------------------------------*/ +/* hashKey - computes the hashkey given a symbol name */ +/*-----------------------------------------------------------------*/ +int hashKey (char *s) +{ + unsigned long key = 0; + + while (*s) + key += *s++ ; + return key % 256 ; +} + +/*-----------------------------------------------------------------*/ +/* addSym - adds a symbol to the hash Table */ +/*-----------------------------------------------------------------*/ +void addSym ( bucket **stab , + void *sym , + char *sname , + int level , + int block) +{ + int i ; /* index into the hash Table */ + bucket *bp ; /* temp bucket * */ + + /* the symbols are always added at the head of the list */ + i = hashKey(sname) ; + /* get a free entry */ + ALLOC(bp,sizeof(bucket)); + + bp->sym = sym ; /* update the symbol pointer */ + bp->level = level; /* update the nest level */ + bp->block = block; + strcpy(bp->name,sname); /* copy the name into place */ + + /* if this is the first entry */ + if (stab[i] == NULL) { + bp->prev = bp->next = (void *) NULL ; /* point to nothing */ + stab[i] = bp ; + } + /* not first entry then add @ head of list */ + else { + bp->prev = NULL ; + stab[i]->prev = bp ; + bp->next = stab[i] ; + stab[i] = bp ; + } +} + +/*-----------------------------------------------------------------*/ +/* deleteSym - deletes a symbol from the hash Table entry */ +/*-----------------------------------------------------------------*/ +void deleteSym ( bucket **stab, void *sym, char *sname) +{ + int i = 0 ; + bucket *bp ; + + i = hashKey(sname) ; + + bp = stab[i] ; + /* find the symbol */ + while (bp) { + if (bp->sym == sym) /* found it then break out */ + break ; /* of the loop */ + bp = bp->next ; + } + + if (!bp) /* did not find it */ + return ; + /* if this is the first one in the chain */ + if ( ! bp->prev ) { + stab[i] = bp->next ; + if ( stab[i] ) /* if chain ! empty */ + stab[i]->prev = (void *) NULL ; + } + /* middle || end of chain */ + else { + if ( bp->next ) /* if not end of chain */ + bp->next->prev = bp->prev ; + + bp->prev->next = bp->next ; + } + +} + +/*-----------------------------------------------------------------*/ +/* findSym - finds a symbol in a table */ +/*-----------------------------------------------------------------*/ +void *findSym ( bucket **stab, void *sym, char *sname) +{ + bucket *bp ; + + bp = stab[hashKey(sname)] ; + while (bp) + { + if ( bp->sym == sym || strcmp (bp->name,sname) == 0 ) + break ; + bp = bp->next ; + } + + return ( bp ? bp->sym : (void *) NULL ) ; +} + +/*-----------------------------------------------------------------*/ +/* findSymWithLevel - finds a symbol with a name & level */ +/*-----------------------------------------------------------------*/ +void *findSymWithLevel ( bucket **stab, symbol *sym) +{ + bucket *bp ; + + bp = stab[hashKey(sym->name)]; + + /** + ** do the search from the head of the list since the + ** elements are added at the head it is ensured that + ** we will find the deeper definitions before we find + ** the global ones. we need to check for symbols with + ** level <= to the level given, if levels match then block + ** numbers need to match as well + **/ + while (bp) { + + if ( strcmp(bp->name,sym->name) == 0 && bp->level <= sym->level) { + /* if this is parameter then nothing else need to be checked */ + if (((symbol *)(bp->sym))->_isparm) + return (bp->sym) ; + /* if levels match then block numbers hsould also match */ + if (bp->level && bp->level == sym->level && bp->block == sym->block ) + return ( bp->sym ); + /* if levels don't match then we are okay */ + if (bp->level && bp->level != sym->level) + return ( bp->sym ); + /* if this is a global variable then we are ok too */ + if (bp->level == 0 ) + return (bp->sym); + } + + bp = bp->next; + } + + return (void *) NULL ; +} + +/*-----------------------------------------------------------------*/ +/* findSymWithBlock - finds a symbol with name in with a block */ +/*-----------------------------------------------------------------*/ +void *findSymWithBlock ( bucket **stab, symbol *sym, int block) +{ + bucket *bp ; + + bp = stab[hashKey(sym->name)] ; + while (bp) + { + if ( strcmp (bp->name,sym->name) == 0 && + bp->block <= block ) + break ; + bp = bp->next ; + } + + return ( bp ? bp->sym : (void *) NULL ) ; +} + +/*------------------------------------------------------------------*/ +/* newSymbol () - returns a new pointer to a symbol */ +/*------------------------------------------------------------------*/ +symbol *newSymbol (char *name, int scope ) +{ + symbol *sym ; + + ALLOC(sym,sizeof(symbol)); + + strcpy(sym->name,name); /* copy the name */ + sym->level = scope ; /* set the level */ + sym->block = currBlockno ; + sym->lineDef = yylineno ; /* set the line number */ + return sym ; +} + +/*------------------------------------------------------------------*/ +/* newLink - creates a new link (declarator,specifier) */ +/*------------------------------------------------------------------*/ +link *newLink () +{ + link *p ; + + ALLOC(p,sizeof(link)); + + return p; +} + +/*------------------------------------------------------------------*/ +/* newStruct - creats a new structdef from the free list */ +/*------------------------------------------------------------------*/ +structdef *newStruct ( char *tag ) +{ + structdef *s; + + ALLOC(s,sizeof(structdef)); + + strcpy(s->tag,tag) ; /* copy the tag */ + return s ; +} + +/*------------------------------------------------------------------*/ +/* pointerTypes - do the computation for the pointer types */ +/*------------------------------------------------------------------*/ +void pointerTypes (link *ptr, link *type) +{ + if (IS_SPEC(ptr)) + return ; + + /* find the first pointer type */ + while (ptr && !IS_PTR(ptr)) + ptr = ptr->next; + + /* could not find it */ + if (!ptr || IS_SPEC(ptr) || + DCL_TYPE(ptr) != UPOINTER) + return ; + + /* change the pointer type depending on the + storage class of the type */ + if (IS_SPEC(type)) { + DCL_PTR_CONST(ptr) = SPEC_CONST(type); + DCL_PTR_VOLATILE(ptr) = SPEC_VOLATILE(type); + switch (SPEC_SCLS(type)) { + case S_XDATA: + DCL_TYPE(ptr) = FPOINTER; + break; + case S_IDATA: + DCL_TYPE(ptr) = IPOINTER ; + break; + case S_PDATA: + DCL_TYPE(ptr) = PPOINTER ; + break; + case S_DATA: + DCL_TYPE(ptr) = POINTER ; + break; + case S_CODE: + DCL_PTR_CONST(ptr) = 1; + DCL_TYPE(ptr) = CPOINTER ; + break; + default: + DCL_TYPE(ptr) = GPOINTER; + break; + } + /* the storage class of type ends here */ + SPEC_SCLS(type) = + SPEC_CONST(type) = + SPEC_VOLATILE(type) = 0; + } + + /* now change all the remaining unknown pointers + to generic pointers */ + while (ptr) { + if (!IS_SPEC(ptr) && DCL_TYPE(ptr) == UPOINTER) + DCL_TYPE(ptr) = GPOINTER; + ptr = ptr->next; + } + + /* same for the type although it is highly unlikely that + type will have a pointer */ + while (type) { + if (!IS_SPEC(type) && DCL_TYPE(type) == UPOINTER) + DCL_TYPE(type) = GPOINTER; + type = type->next; + } + +} + +/*------------------------------------------------------------------*/ +/* addDecl - adds a declarator @ the end of a chain */ +/*------------------------------------------------------------------*/ +void addDecl ( symbol *sym, int type , link *p ) +{ + link *head; + link *tail; + link *t ; + + /* if we are passed a link then set head & tail */ + if ( p ) { + tail = head = p ; + while ( tail->next ) + tail = tail->next ; + } + else { + head = tail = newLink() ; + DCL_TYPE(head) = type ; + } + + /* if this is the first entry */ + if ( !sym->type ) { + sym->type = head ; + sym->etype = tail ; + } + else { + if ( IS_SPEC(sym->etype) && IS_SPEC(head) && head == tail ) { + sym->etype = mergeSpec(sym->etype,head); + } + else { + if ( IS_SPEC(sym->etype) && !IS_SPEC(head) && head == tail ) { + t = sym->type ; + while (t->next != sym->etype) t = t->next ; + t->next = head ; + tail->next = sym->etype; + } else { + sym->etype->next = head; + sym->etype = tail; + } + } + } + + /* if the type is a unknown pointer and has + a tspec then take the storage class const & volatile + attribute from the tspec & make it those of this + symbol */ + if (p && + !IS_SPEC(p) && + DCL_TYPE(p) == UPOINTER && + DCL_TSPEC(p)) { + if (!IS_SPEC(sym->etype)) { + sym->etype = sym->etype->next = newLink(); + sym->etype->class = SPECIFIER; + } + SPEC_SCLS(sym->etype) = SPEC_SCLS(DCL_TSPEC(p)); + SPEC_CONST(sym->etype) = SPEC_CONST(DCL_TSPEC(p)); + SPEC_VOLATILE(sym->etype) = SPEC_VOLATILE(DCL_TSPEC(p)); + DCL_TSPEC(p) = NULL; + } + return ; +} + +/*------------------------------------------------------------------*/ +/* mergeSpec - merges two specifiers and returns the new one */ +/*------------------------------------------------------------------*/ +link *mergeSpec ( link *dest, link *src ) +{ + /* if noun different then src overrides */ + if ( SPEC_NOUN(dest) != SPEC_NOUN(src) && !SPEC_NOUN(dest)) + SPEC_NOUN(dest) = SPEC_NOUN(src) ; + + if (! SPEC_SCLS(dest)) /* if destination has no storage class */ + SPEC_SCLS(dest) = SPEC_SCLS(src) ; + + /* copy all the specifications */ + SPEC_LONG(dest) |= SPEC_LONG(src); + SPEC_SHORT(dest) |= SPEC_SHORT(src); + SPEC_USIGN(dest) |= SPEC_USIGN(src); + SPEC_STAT(dest) |= SPEC_STAT(src); + SPEC_EXTR(dest) |= SPEC_EXTR(src); + SPEC_ABSA(dest) |= SPEC_ABSA(src); + SPEC_RENT(dest) |= SPEC_RENT(src); + SPEC_INTN(dest) |= SPEC_INTN(src); + SPEC_BANK(dest) |= SPEC_BANK(src); + SPEC_VOLATILE(dest) |= SPEC_VOLATILE(src); + SPEC_CRTCL(dest) |= SPEC_CRTCL(src); + SPEC_ADDR(dest) |= SPEC_ADDR(src); + SPEC_OCLS(dest) = SPEC_OCLS(src); + SPEC_BLEN(dest) |= SPEC_BLEN(src); + SPEC_BSTR(dest) |= SPEC_BSTR(src); + SPEC_TYPEDEF(dest) |= SPEC_TYPEDEF(src); + + if ( IS_STRUCT(dest) && SPEC_STRUCT(dest) == NULL ) + SPEC_STRUCT(dest) = SPEC_STRUCT(src); + + return dest ; +} + +/*------------------------------------------------------------------*/ +/* cloneSpec - copies the entire spec and returns a new spec */ +/*------------------------------------------------------------------*/ +link *cloneSpec ( link *src ) +{ + link *spec ; + + /* go thru chain till we find the specifier */ + while ( src && src->class != SPECIFIER ) + src = src->next ; + + spec = newLink() ; + memcpy (spec,src,sizeof(link)); + return spec ; +} + +/*------------------------------------------------------------------*/ +/* genSymName - generates and returns a name used for anonymous vars*/ +/*------------------------------------------------------------------*/ +char *genSymName ( int level ) +{ + static int gCount = 0 ; + static char gname[SDCC_NAME_MAX+1] ; + + sprintf (gname,"__%04d%04d",level,gCount++); + return gname ; +} + +/*------------------------------------------------------------------*/ +/* getSpec - returns the specifier part from a declaration chain */ +/*------------------------------------------------------------------*/ +link *getSpec ( link *p ) +{ + link *loop ; + + loop = p ; + while ( p && ! (IS_SPEC(p))) + p = p->next ; + + return p ; +} + +/*------------------------------------------------------------------*/ +/* newCharLink() - creates an int type */ +/*------------------------------------------------------------------*/ +link *newCharLink() +{ + link *p; + + p = newLink(); + p->class = SPECIFIER ; + SPEC_NOUN(p) = V_CHAR ; + + return p; +} + +/*------------------------------------------------------------------*/ +/* newFloatLink - a new Float type */ +/*------------------------------------------------------------------*/ +link *newFloatLink() +{ + link *p; + + p = newLink(); + p->class = SPECIFIER ; + SPEC_NOUN(p) = V_FLOAT ; + + return p; +} + +/*------------------------------------------------------------------*/ +/* newLongLink() - new long type */ +/*------------------------------------------------------------------*/ +link *newLongLink() +{ + link *p; + + p = newLink(); + p->class = SPECIFIER ; + SPEC_NOUN(p) = V_INT ; + SPEC_LONG(p) = 1; + + return p; +} + +/*------------------------------------------------------------------*/ +/* newIntLink() - creates an int type */ +/*------------------------------------------------------------------*/ +link *newIntLink() +{ + link *p; + + p = newLink(); + p->class = SPECIFIER ; + SPEC_NOUN(p) = V_INT ; + + return p; +} + +/*------------------------------------------------------------------*/ +/* getSize - returns size of a type chain in bits */ +/*------------------------------------------------------------------*/ +unsigned int getSize ( link *p ) +{ + /* if nothing return 0 */ + if ( ! p ) + return 0 ; + + if ( IS_SPEC(p) ) { /* if this is the specifier then */ + + switch (SPEC_NOUN(p)) { /* depending on the specifier type */ + case V_INT: + return (IS_LONG(p) ? LONGSIZE : ( IS_SHORT(p) ? SHORTSIZE: INTSIZE)) ; + case V_FLOAT: + return FLOATSIZE ; + case V_CHAR: + return CHARSIZE ; + case V_VOID: + return 0 ; + case V_STRUCT: + return SPEC_STRUCT(p)->size ; + case V_LABEL: + return 0 ; + case V_SBIT: + return BITSIZE ; + case V_BIT: + return ((SPEC_BLEN(p) / 8) + (SPEC_BLEN(p) % 8 ? 1 : 0)) ; + default : + return 0 ; + } + } + + /* this is a specifier */ + switch (DCL_TYPE(p)) { + case FUNCTION: + return 2; + case ARRAY: + return DCL_ELEM(p) * getSize (p->next) ; + case IPOINTER: + case PPOINTER: + case POINTER: + return ( PTRSIZE ) ; + case FPOINTER: + case CPOINTER: + return ( FPTRSIZE ); + case GPOINTER: + return ( GPTRSIZE ); + + default : + return 0 ; + } +} + +/*------------------------------------------------------------------*/ +/* bitsForType - returns # of bits required to store this type */ +/*------------------------------------------------------------------*/ +unsigned int bitsForType ( link *p ) +{ + /* if nothing return 0 */ + if ( ! p ) + return 0 ; + + if ( IS_SPEC(p) ) { /* if this is the specifier then */ + + switch (SPEC_NOUN(p)) { /* depending on the specifier type */ + case V_INT: + return (IS_LONG(p) ? LONGSIZE*8 : ( IS_SHORT(p) ? SHORTSIZE*8: INTSIZE*8)) ; + case V_FLOAT: + return FLOATSIZE*8 ; + case V_CHAR: + return CHARSIZE*8 ; + case V_VOID: + return 0 ; + case V_STRUCT: + return SPEC_STRUCT(p)->size*8 ; + case V_LABEL: + return 0 ; + case V_SBIT: + return 1 ; + case V_BIT: + return SPEC_BLEN(p); + default : + return 0 ; + } + } + + /* this is a specifier */ + switch (DCL_TYPE(p)) { + case FUNCTION: + return 2; + case ARRAY: + return DCL_ELEM(p) * getSize (p->next) *8 ; + case IPOINTER: + case PPOINTER: + case POINTER: + return ( PTRSIZE * 8) ; + case FPOINTER: + case CPOINTER: + return ( FPTRSIZE * 8); + case GPOINTER: + return ( GPTRSIZE * 8); + + default : + return 0 ; + } +} + +/*------------------------------------------------------------------*/ +/* copySymbolChain - copies a symbol chain */ +/*------------------------------------------------------------------*/ +symbol *copySymbolChain (symbol *src) +{ + symbol *dest ; + + if (!src) + return NULL ; + + dest = copySymbol(src); + dest->next = copySymbolChain(src->next); + return dest ; +} + +/*------------------------------------------------------------------*/ +/* copySymbol - makes a copy of a symbol */ +/*------------------------------------------------------------------*/ +symbol *copySymbol (symbol *src) +{ + symbol *dest; + + if (!src ) + return NULL ; + + dest = newSymbol( src->name, src->level ); + memcpy(dest,src,sizeof(symbol)); + dest->level = src->level ; + dest->block = src->block ; + dest->ival = copyIlist(src->ival); + dest->type = copyLinkChain(src->type); + dest->etype= getSpec(dest->type); + dest->next = NULL ; + dest->args = copyValueChain (src->args); + dest->key = src->key; + dest->calleeSave = src->calleeSave; + dest->allocreq = src->allocreq; + return dest; +} + +/*------------------------------------------------------------------*/ +/* reverseSyms - reverses the links for a symbol chain */ +/*------------------------------------------------------------------*/ +symbol *reverseSyms ( symbol *sym) +{ + symbol *prev , *curr, *next ; + + if (!sym) + return NULL ; + + prev = sym ; + curr = sym->next ; + + while (curr) + { + next = curr->next ; + curr->next = prev ; + prev = curr ; + curr = next ; + } + sym->next = (void *) NULL ; + return prev ; +} + +/*------------------------------------------------------------------*/ +/* reverseLink - reverses the links for a type chain */ +/*------------------------------------------------------------------*/ +link *reverseLink ( link *type) +{ + link *prev , *curr, *next ; + + if (!type) + return NULL ; + + prev = type ; + curr = type->next ; + + while (curr) + { + next = curr->next ; + curr->next = prev ; + prev = curr ; + curr = next ; + } + type->next = (void *) NULL ; + return prev ; +} + +/*------------------------------------------------------------------*/ +/* addSymChain - adds a symbol chain to the symboltable */ +/*------------------------------------------------------------------*/ +void addSymChain ( symbol *symHead ) +{ + symbol *sym = symHead ; + symbol *csym = NULL ; + + for (;sym != NULL ; sym = sym->next ) { + + /* if already exists in the symbol table then check if + the previous was an extern definition if yes then + then check if the type match, if the types match then + delete the current entry and add the new entry */ + if ((csym = findSymWithLevel (SymbolTab,sym)) && + csym->level == sym->level) { + + /* previous definition extern ? */ + if ( IS_EXTERN(csym->etype) ) { + /* do types match ? */ + if (checkType ( csym->type,sym->type) != 1) + /* no then error */ + werror (E_DUPLICATE,csym->name); + + /* delete current entry */ + deleteSym (SymbolTab, csym, csym->name ); + /* add new entry */ + addSym (SymbolTab, sym, sym->name, sym->level,sym->block); + } else /* not extern */ + werror(E_DUPLICATE,sym->name) ; + continue ; + } + + /* check if previously defined */ + if (csym && csym->level == sym->level ) { + /* if the previous one was declared as extern */ + /* then check the type with the current one */ + if ( IS_EXTERN(csym->etype) ) { + if ( checkType (csym->type, sym->type ) <= 0 ) + werror (W_EXTERN_MISMATCH,csym->name); + } + } + + addSym (SymbolTab,sym,sym->name,sym->level,sym->block) ; + } +} + + +/*------------------------------------------------------------------*/ +/* funcInChain - DCL Type 'FUNCTION' found in type chain */ +/*------------------------------------------------------------------*/ +int funcInChain (link *lnk) +{ + while (lnk) { + if (IS_FUNC(lnk)) + return 1; + lnk = lnk->next; + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* structElemType - returns the type info of a sturct member */ +/*------------------------------------------------------------------*/ +link *structElemType (link *stype, value *id ,value **argsp) +{ + symbol *fields = (SPEC_STRUCT(stype) ? SPEC_STRUCT(stype)->fields : NULL); + + if ( ! fields || ! id) + return NULL ; + + /* look for the id */ + while (fields) { + if (strcmp(fields->rname,id->name) == 0) { + if (argsp) { + *argsp = fields->args; + } + return copyLinkChain (fields->type) ; + } + fields = fields->next ; + } + werror(E_NOT_MEMBER,id->name); + + return NULL ; +} + +/*------------------------------------------------------------------*/ +/* getStructElement - returns element of a tructure definition */ +/*------------------------------------------------------------------*/ +symbol *getStructElement ( structdef *sdef, symbol *sym) +{ + symbol *field ; + + for ( field = sdef->fields ; field ; field = field->next ) + if ( strcmp(field->name,sym->name) == 0) + return field ; + + werror(E_NOT_MEMBER,sym->name); + + return sdef->fields ; +} + +/*------------------------------------------------------------------*/ +/* compStructSize - computes the size of a structure */ +/*------------------------------------------------------------------*/ +int compStructSize (int su, structdef *sdef ) +{ + int sum = 0 , usum =0; + int bitOffset = 0 ; + symbol *loop ; + + /* for the identifiers */ + loop = sdef->fields ; + while ( loop ) { + + /* create the internal name for this variable */ + sprintf (loop->rname,"_%s",loop->name); + loop->offset = ( su == UNION ? sum = 0 : sum ) ; + SPEC_VOLATILE(loop->etype) |= (su == UNION ? 1 : 0); + + /* if this is a bit field */ + if (loop->bitVar) { + + /* change it to a unsigned bit */ + SPEC_NOUN(loop->etype) = V_BIT ; + SPEC_USIGN(loop->etype) = 1 ; + /* check if this fit into the remaining */ + /* bits of this byte else align it to the */ + /* next byte boundary */ + if ((SPEC_BLEN(loop->etype)=loop->bitVar) <= (8 - bitOffset)) { + SPEC_BSTR(loop->etype) = bitOffset ; + sum += (loop->bitVar / 8) ; + bitOffset += (loop->bitVar % 8); + } + else /* does not fit */ + { + bitOffset = 0 ; + loop->offset++; /* go to the next byte */ + sum++ ; + SPEC_BSTR(loop->etype) = bitOffset ; + sum += (loop->bitVar / 8) ; + bitOffset += (loop->bitVar % 8); + } + /* if this is the last field then pad */ + if (!loop->next && bitOffset) { + bitOffset = 0 ; + sum++ ; + } + } + else { + checkDecl (loop); + sum += getSize (loop->type) ; + } + + /* if function then do the arguments for it */ + if (funcInChain(loop->type)) { + processFuncArgs (loop, 1); + } + + loop = loop->next ; + + /* if this is not a bitfield but the */ + /* previous one was and did not take */ + /* the whole byte then pad the rest */ + if ((loop && !loop->bitVar) && bitOffset) { + bitOffset = 0 ; + sum++ ; + } + + /* if union then size = sizeof larget field */ + if (su == UNION) + usum = max(usum,sum); + + } + + return (su == UNION ? usum : sum); +} + +/*------------------------------------------------------------------*/ +/* checkSClass - check the storage class specification */ +/*------------------------------------------------------------------*/ +void checkSClass ( symbol *sym ) +{ + /* if sfr or sbit then must also be */ + /* volatile the initial value will be xlated */ + /* to an absolute address */ + if (SPEC_SCLS(sym->etype) == S_SBIT || + SPEC_SCLS(sym->etype) == S_SFR ) { + SPEC_VOLATILE(sym->etype) = 1; + /* if initial value given */ + if (sym->ival) { + SPEC_ABSA(sym->etype) = 1; + SPEC_ADDR(sym->etype) = + (int) list2int(sym->ival); + sym->ival = NULL; + } + } + + /* if absolute address given then it mark it as + volatile */ + if (IS_ABSOLUTE(sym->etype)) + SPEC_VOLATILE(sym->etype) = 1; + + /* global variables declared const put into code */ + if (sym->level == 0 && + SPEC_SCLS(sym->etype) == S_CONSTANT) + SPEC_SCLS(sym->etype) = S_CODE ; + + + /* global variable in code space is a constant */ + if (sym->level == 0 && + SPEC_SCLS(sym->etype) == S_CODE) + SPEC_CONST(sym->etype) = 1; + + + /* if bit variable then no storage class can be */ + /* specified since bit is already a storage */ + if ( IS_BITVAR(sym->etype) && + ( SPEC_SCLS(sym->etype) != S_FIXED && + SPEC_SCLS(sym->etype) != S_SBIT && + SPEC_SCLS(sym->etype) != S_BIT ) + ) { + werror (E_BITVAR_STORAGE,sym->name); + SPEC_SCLS(sym->etype) = S_FIXED ; + } + + /* extern variables cannot be initialized */ + if (IS_EXTERN(sym->etype) && sym->ival) { + werror(E_EXTERN_INIT,sym->name); + sym->ival = NULL; + } + + /* if this is an automatic symbol then */ + /* storage class will be ignored and */ + /* symbol will be allocated on stack/ */ + /* data depending on flag */ + if ( sym->level && + (options.stackAuto || reentrant ) && + ( SPEC_SCLS(sym->etype) != S_AUTO && + SPEC_SCLS(sym->etype) != S_FIXED && + SPEC_SCLS(sym->etype) != S_REGISTER && + SPEC_SCLS(sym->etype) != S_CONSTANT )) { + + werror(E_AUTO_ASSUMED,sym->name) ; + SPEC_SCLS(sym->etype) = S_AUTO ; + } + + /* automatic symbols cannot be given */ + /* an absolute address ignore it */ + if ( sym->level && + SPEC_ABSA(sym->etype) && + (options.stackAuto || reentrant) ) { + werror(E_AUTO_ABSA,sym->name); + SPEC_ABSA(sym->etype) = 0 ; + } + + /* arrays & pointers cannot be defined for bits */ + /* SBITS or SFRs or BIT */ + if ((IS_ARRAY(sym->type) || IS_PTR(sym->type)) && + ( SPEC_NOUN(sym->etype) == V_BIT || + SPEC_NOUN(sym->etype) == V_SBIT || + SPEC_SCLS(sym->etype) == S_SFR )) + werror(E_BIT_ARRAY,sym->name); + + /* if this is a bit|sbit then set length & start */ + if (SPEC_NOUN(sym->etype) == V_BIT || + SPEC_NOUN(sym->etype) == V_SBIT ) { + SPEC_BLEN(sym->etype) = 1 ; + SPEC_BSTR(sym->etype) = 0 ; + } + + /* variables declared in CODE space must have */ + /* initializers if not an extern */ + if (SPEC_SCLS(sym->etype) == S_CODE && + sym->ival == NULL && + !sym->level && + !IS_EXTERN(sym->etype)) + werror(E_CODE_NO_INIT,sym->name); + + /* if parameter or local variable then change */ + /* the storage class to reflect where the var will go */ + if ( sym->level && SPEC_SCLS(sym->etype) == S_FIXED) { + if ( options.stackAuto || (currFunc && IS_RENT(currFunc->etype))) + SPEC_SCLS(sym->etype) = (options.model ? + S_XSTACK : S_STACK ) ; + else + SPEC_SCLS(sym->etype) = (options.model ? + S_XDATA :S_DATA ) ; + } +} + +/*------------------------------------------------------------------*/ +/* changePointer - change pointer to functions */ +/*------------------------------------------------------------------*/ +void changePointer (symbol *sym) +{ + link *p ; + + /* go thru the chain of declarations */ + /* if we find a pointer to a function */ + /* unconditionally change it to a ptr */ + /* to code area */ + for ( p = sym->type ; p ; p = p->next) { + if ( !IS_SPEC(p) && DCL_TYPE(p) == UPOINTER) + DCL_TYPE(p) = GPOINTER ; + if ( IS_PTR(p) && IS_FUNC(p->next)) + DCL_TYPE(p) = CPOINTER ; + } +} + +/*------------------------------------------------------------------*/ +/* checkDecl - does semantic validation of a declaration */ +/*------------------------------------------------------------------*/ +int checkDecl ( symbol *sym ) +{ + + checkSClass (sym); /* check the storage class */ + changePointer(sym); /* change pointers if required */ + + /* if this is an array without any dimension + then update the dimension from the initial value */ + if (IS_ARRAY(sym->type) && !DCL_ELEM(sym->type)) + DCL_ELEM(sym->type) = getNelements (sym->type,sym->ival); + + return 0 ; +} + +/*------------------------------------------------------------------*/ +/* copyLinkChain - makes a copy of the link chain & rets ptr 2 head */ +/*------------------------------------------------------------------*/ +link *copyLinkChain ( link *p) +{ + link *head, *curr , *loop; + + curr = p ; + head = loop = ( curr ? newLink() : (void *) NULL) ; + while (curr) { + memcpy(loop,curr,sizeof(link)) ; /* copy it */ + loop->next = (curr->next ? newLink() : (void *) NULL) ; + loop = loop->next ; + curr = curr->next ; + } + + return head ; +} + + +/*------------------------------------------------------------------*/ +/* cleanUpBlock - cleansup the symbol table specified for all the */ +/* symbols in the given block */ +/*------------------------------------------------------------------*/ +void cleanUpBlock ( bucket **table, int block) +{ + int i ; + bucket *chain; + + /* go thru the entire table */ + for ( i = 0 ; i < 256; i++ ) { + for ( chain = table[i]; chain ; chain = chain->next ) { + if (chain->block >= block) { + deleteSym (table,chain->sym,chain->name); + } + } + } +} + +/*------------------------------------------------------------------*/ +/* cleanUpLevel - cleansup the symbol table specified for all the */ +/* symbols in the given level */ +/*------------------------------------------------------------------*/ +void cleanUpLevel (bucket **table, int level ) +{ + int i ; + bucket *chain; + + /* go thru the entire table */ + for ( i = 0 ; i < 256; i++ ) { + for ( chain = table[i]; chain ; chain = chain->next ) { + if (chain->level >= level) { + deleteSym (table,chain->sym,chain->name); + } + } + } +} + +/*------------------------------------------------------------------*/ +/* computeType - computes the resultant type from two types */ +/*------------------------------------------------------------------*/ +link *computeType ( link *type1, link *type2) +{ + link *rType ; + link *reType; + link *etype1 = getSpec(type1); + link *etype2 = getSpec(type2); + + /* if one of them is a float then result is a float */ + /* here we assume that the types passed are okay */ + /* and can be cast to one another */ + /* which ever is greater in size */ + if (IS_FLOAT(etype1) || IS_FLOAT(etype2)) + rType = newFloatLink(); + else + /* if only one of them is a bit variable + then the other one prevails */ + if (IS_BITVAR(etype1) && !IS_BITVAR(etype2)) + rType = copyLinkChain(type2); + else + if (IS_BITVAR(etype2) && !IS_BITVAR(etype1)) + rType = copyLinkChain(type1); + else + /* if one of them is a pointer then that + prevails */ + if (IS_PTR(type1)) + rType = copyLinkChain(type1); + else + if (IS_PTR(type2)) + rType = copyLinkChain(type2); + else + if (getSize (type1) > getSize(type2) ) + rType = copyLinkChain(type1); + else + rType = copyLinkChain(type2); + + reType = getSpec(rType); + + /* if either of them unsigned then make this unsigned */ + if ((SPEC_USIGN(etype1) || SPEC_USIGN(etype2)) && !IS_FLOAT(reType)) + SPEC_USIGN(reType) = 1; + + /* if result is a literal then make not so */ + if (IS_LITERAL(reType)) + SPEC_SCLS(reType) = S_REGISTER ; + + return rType; +} + +/*------------------------------------------------------------------*/ +/* checkType - will do type check return 1 if match */ +/*------------------------------------------------------------------*/ +int checkType ( link *dest, link *src ) +{ + if ( !dest && !src) + return 1; + + if (dest && !src) + return 0; + + if (src && !dest) + return 0; + + /* if dest is a declarator then */ + if (IS_DECL(dest)) { + if (IS_DECL(src)) { + if (DCL_TYPE(src) == DCL_TYPE(dest)) + return checkType(dest->next,src->next); + else + if (IS_PTR(src) && IS_PTR(dest)) + return -1; + else + if (IS_PTR(dest) && IS_ARRAY(src)) + return -1; + else + if (IS_PTR(dest) && IS_FUNC(dest->next) && IS_FUNC(src)) + return -1 * checkType (dest->next,src) ; + else + return 0; + } + else + if (IS_PTR(dest) && IS_INTEGRAL(src)) + return -1; + else + return 0; + } + + /* if one of them is a void then ok */ + if (SPEC_NOUN(dest) == V_VOID && + SPEC_NOUN(src) != V_VOID ) + return -1 ; + + if (SPEC_NOUN(dest) != V_VOID && + SPEC_NOUN(src) == V_VOID ) + return -1; + + /* char === to short */ + if (SPEC_NOUN(dest) == V_CHAR && + SPEC_NOUN(src) == V_INT && + SPEC_SHORT(src) ) + return (SPEC_USIGN(src) == SPEC_USIGN(dest) ? 1 : -2); + + if (SPEC_NOUN(src) == V_CHAR && + SPEC_NOUN(dest) == V_INT && + SPEC_SHORT(dest) ) + return (SPEC_USIGN(src) == SPEC_USIGN(dest) ? 1 : -2); + + /* if they are both bitfields then if the lengths + and starts don't match */ + if (IS_BITFIELD(dest) && IS_BITFIELD(src) && + (SPEC_BLEN(dest) != SPEC_BLEN(src) || + SPEC_BSTR(dest) != SPEC_BSTR(src))) + return -1; + + /* it is a specifier */ + if (SPEC_NOUN(dest) != SPEC_NOUN(src)) { + if (SPEC_USIGN(dest) == SPEC_USIGN(src) && + IS_INTEGRAL(dest) && IS_INTEGRAL(src) && + getSize(dest) == getSize(src)) + return 1; + else + if (IS_ARITHMETIC(dest) && IS_ARITHMETIC(src)) + return -1; + else + return 0; + } + else + if (IS_STRUCT(dest)) { + if (SPEC_STRUCT(dest) != SPEC_STRUCT(src)) + return 0 ; + else + return 1 ; + } + if (SPEC_LONG(dest) != SPEC_LONG(src)) + return -1; + + if (SPEC_SHORT(dest) != SPEC_SHORT(src)) + return -1; + + if (SPEC_USIGN(dest) != SPEC_USIGN(src)) + return -2; + + return 1; +} + +/*------------------------------------------------------------------*/ +/* inCalleeSaveList - return 1 if found in calle save list */ +/*------------------------------------------------------------------*/ +bool inCalleeSaveList ( char *s) +{ + int i; + + for (i = 0 ; options.calleeSaves[i] ; i++ ) + if (strcmp(options.calleeSaves[i],s) == 0) + return 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* checkFunction - does all kinds of check on a function */ +/*------------------------------------------------------------------*/ +int checkFunction (symbol *sym) +{ + symbol *csym ; + value *exargs, *acargs ; + int argCnt = 0 ; + + /* if not type then some kind of error */ + if ( !sym->type ) + return 0; + + /* if the function has no type then make it return int */ + if ( !sym->type->next ) + sym->type->next = sym->etype = newIntLink(); + + /* function cannot return aggregate */ + if (IS_AGGREGATE(sym->type->next)) { + werror(E_FUNC_AGGR,sym->name); + return 0; + } + + /* function cannot return bit */ + if (IS_BITVAR(sym->type->next)) { + werror(E_FUNC_BIT,sym->name); + return 0; + } + + /* check if this function is defined as calleeSaves + then mark it as such */ + sym->calleeSave = inCalleeSaveList(sym->name); + + /* if interrupt service routine */ + /* then it cannot have arguments */ + if ( sym->args && IS_ISR(sym->etype) && !IS_VOID(sym->args->type)) { + werror(E_INT_ARGS,sym->name); + sym->args = NULL ; + } + + if (!(csym = findSym (SymbolTab, sym, sym->name ))) + return 1 ; /* not defined nothing more to check */ + + /* check if body already present */ + if ( csym && csym->fbody ) { + werror(E_FUNC_BODY,sym->name); + return 0; + } + + /* check the return value type */ + if (checkType (csym->type,sym->type) <= 0) { + werror(E_PREV_DEF_CONFLICT,csym->name,"type") ; + werror (E_CONTINUE,"previous defintion type "); + printTypeChain(csym->type,stderr);fprintf(stderr,"\n"); + werror (E_CONTINUE,"current definition type "); + printTypeChain(sym->type,stderr);fprintf(stderr,"\n"); + return 0; + } + + if ( SPEC_INTRTN(csym->etype) != SPEC_INTRTN(sym->etype)) { + werror (E_PREV_DEF_CONFLICT,csym->name,"interrupt"); + return 0; + } + + if (SPEC_BANK(csym->etype) != SPEC_BANK(sym->etype)) { + werror (E_PREV_DEF_CONFLICT,csym->name,"using"); + return 0; + } + + /* compare expected agrs with actual args */ + exargs = csym->args ; + acargs = sym->args ; + + /* for all the expected args do */ + for (argCnt = 1 ; + exargs && acargs ; + exargs = exargs->next, acargs = acargs->next, argCnt++ ) { + if ( checkType(exargs->type,acargs->type) <= 0) { + werror(E_ARG_TYPE,argCnt); + return 0; + } + } + + /* if one them ended we have a problem */ + if ((exargs && !acargs && !IS_VOID(exargs->type)) || + (!exargs && acargs && !IS_VOID(acargs->type))) + werror(E_ARG_COUNT); + + /* replace with this defition */ + sym->cdef = csym->cdef; + deleteSym (SymbolTab,csym,csym->name); + addSym (SymbolTab,sym,sym->name,sym->level,sym->block); + if (IS_EXTERN(csym->etype) && ! + IS_EXTERN(sym->etype)) + addSet(&publics,sym); + return 1 ; +} + +/*-----------------------------------------------------------------*/ +/* processFuncArgs - does some processing with function args */ +/*-----------------------------------------------------------------*/ +void processFuncArgs (symbol *func, int ignoreName) +{ + value *val ; + int pNum = 1; + + /* if this function has variable argument list */ + /* then make the function a reentrant one */ + if (func->hasVargs) + SPEC_RENT(func->etype) = 1; + + /* check if this function is defined as calleeSaves + then mark it as such */ + func->calleeSave = inCalleeSaveList(func->name); + + val = func->args; /* loop thru all the arguments */ + + /* if it is void then remove parameters */ + if (val && IS_VOID(val->type)) { + func->args = NULL ; + return ; + } + + /* if any of the arguments is an aggregate */ + /* change it to pointer to the same type */ + while (val) { + + /* mark it as a register parameter if + the function does nit have VA_ARG + and MAX_REG_PARMS not exceeded && + not inhibited by command line option or #pragma */ + if (pNum <= MAX_REG_PARMS && + !options.noregparms && + !func->hasVargs) + SPEC_REGPARM(val->etype) = 1; + + if ( IS_AGGREGATE(val->type)) { + /* if this is a structure */ + /* then we need to add a new link */ + if (IS_STRUCT(val->type)) { + /* first lets add DECLARATOR type */ + link *p = val->type ; + + werror(W_STRUCT_AS_ARG,val->name); + val->type = newLink(); + val->type->next = p ; + } + + /* change to a pointer depending on the */ + /* storage class specified */ + switch (SPEC_SCLS(val->etype)) { + case S_IDATA: + DCL_TYPE(val->type) = IPOINTER; + break; + case S_PDATA: + DCL_TYPE(val->type) = PPOINTER; + break; + case S_FIXED: + case S_AUTO: + case S_DATA: + case S_REGISTER: + DCL_TYPE(val->type) = POINTER ; + break; + case S_CODE: + DCL_TYPE(val->type) = CPOINTER; + break; + case S_XDATA: + DCL_TYPE(val->type) = FPOINTER; + break; + default : + DCL_TYPE(val->type) = GPOINTER; + } + + /* is there is a symbol associated then */ + /* change the type of the symbol as well*/ + if ( val->sym ) { + val->sym->type = copyLinkChain(val->type); + val->sym->etype = getSpec(val->sym->type); + } + } + + val = val->next ; + pNum++; + } + + /* if this function is reentrant or */ + /* automatics r 2b stacked then nothing */ + if (IS_RENT(func->etype) || options.stackAuto ) + return ; + + val = func->args; + pNum = 1; + while (val) { + + /* if a symbolname is not given */ + /* synthesize a variable name */ + if (!val->sym) { + + sprintf(val->name,"_%s_PARM_%d",func->name,pNum++); + val->sym = newSymbol(val->name,1); + SPEC_OCLS(val->etype) = (options.model ? xdata : data); + val->sym->type = copyLinkChain (val->type); + val->sym->etype = getSpec (val->sym->type); + val->sym->_isparm = 1; + strcpy (val->sym->rname,val->name); + SPEC_STAT(val->etype) = SPEC_STAT(val->sym->etype) = + SPEC_STAT(func->etype); + addSymChain(val->sym); + + } + else /* symbol name given create synth name */ { + + sprintf(val->name,"_%s_PARM_%d",func->name,pNum++); + strcpy (val->sym->rname,val->name); + val->sym->_isparm = 1; + SPEC_OCLS(val->etype) = SPEC_OCLS(val->sym->etype) = + (options.model ? xdata : data); + SPEC_STAT(val->etype) = SPEC_STAT(val->sym->etype) = + SPEC_STAT(func->etype); + } + val = val->next ; + } +} + +/*-----------------------------------------------------------------*/ +/* isSymbolEqual - compares two symbols return 1 if they match */ +/*-----------------------------------------------------------------*/ +int isSymbolEqual (symbol *dest, symbol *src) +{ + /* if pointers match then equal */ + if (dest == src) + return 1; + + /* if one of them is null then don't match */ + if (!dest || !src) + return 0; + + /* if both of them have rname match on rname */ + if (dest->rname[0] && src->rname[0]) + return (!strcmp(dest->rname,src->rname)); + + /* otherwise match on name */ + return (!strcmp(dest->name,src->name)); +} + +/*-----------------------------------------------------------------*/ +/* printTypeChain - prints the type chain in human readable form */ +/*-----------------------------------------------------------------*/ +void printTypeChain (link *type, FILE *of) +{ + int nlr = 0; + + if (!of) { + of = stdout; + nlr = 1; + } + + while (type) { + if (IS_DECL(type)) { + switch (DCL_TYPE(type)) { + case FUNCTION: + fprintf (of,"function "); + break; + case GPOINTER: + fprintf (of,"_generic * "); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + case CPOINTER: + fprintf (of,"_code * "); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + case FPOINTER: + fprintf (of,"_far * "); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + case POINTER: + fprintf (of,"_near * "); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + case IPOINTER: + fprintf (of,"_idata *"); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + case PPOINTER: + fprintf (of,"_pdata *"); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + case UPOINTER: + fprintf (of," _unkown *"); + if (DCL_PTR_CONST(type)) + fprintf(of,"const "); + break; + + case ARRAY : + fprintf (of,"array of "); + break; + } + } else { + if (SPEC_VOLATILE(type)) + fprintf (of,"volatile "); + if (SPEC_USIGN(type)) + fprintf (of,"unsigned "); + + switch (SPEC_NOUN(type)) { + case V_INT: + if (IS_LONG(type)) + fprintf (of,"long "); + else + if (IS_SHORT(type)) + fprintf (of,"short "); + else + fprintf (of,"int "); + break; + + case V_CHAR: + fprintf(of,"char "); + break; + + case V_VOID: + fprintf(of,"void "); + break; + + case V_FLOAT: + fprintf(of,"float "); + break; + + case V_STRUCT: + fprintf(of,"struct %s",SPEC_STRUCT(type)->tag); + break; + + case V_SBIT: + fprintf(of,"sbit "); + break; + + case V_BIT: + fprintf(of,"bit {%d,%d}",SPEC_BSTR(type),SPEC_BLEN(type)); + break; + } + } + type = type->next; + } + if (nlr) + fprintf(of,"\n"); +} + +/*-----------------------------------------------------------------*/ +/* cdbTypeInfo - print the type information for debugger */ +/*-----------------------------------------------------------------*/ +void cdbTypeInfo (link *type,FILE *of) +{ + fprintf(of,"{%d}",getSize(type)); + while (type) { + if (IS_DECL(type)) { + switch (DCL_TYPE(type)) { + case FUNCTION: + fprintf (of,"DF,"); + break; + case GPOINTER: + fprintf (of,"DG,"); + break; + case CPOINTER: + fprintf (of,"DC,"); + break; + case FPOINTER: + fprintf (of,"DX,"); + break; + case POINTER: + fprintf (of,"DD,"); + break; + case IPOINTER: + fprintf (of,"DI,"); + break; + case PPOINTER: + fprintf (of,"DP,"); + break; + case ARRAY : + fprintf (of,"DA%d,",DCL_ELEM(type)); + break; + } + } else { + switch (SPEC_NOUN(type)) { + case V_INT: + if (IS_LONG(type)) + fprintf (of,"SL"); + else + if (IS_SHORT(type)) + fprintf (of,"SS"); + else + fprintf (of,"SI"); + break; + + case V_CHAR: + fprintf(of,"SC"); + break; + + case V_VOID: + fprintf(of,"SV"); + break; + + case V_FLOAT: + fprintf(of,"SF"); + break; + + case V_STRUCT: + fprintf(of,"ST%s",SPEC_STRUCT(type)->tag); + break; + + case V_SBIT: + fprintf(of,"SX"); + break; + + case V_BIT: + fprintf(of,"SB%d$%d",SPEC_BSTR(type),SPEC_BLEN(type)); + break; + } + fputs(":",of); + if (SPEC_USIGN(type)) + fputs("U",of); + else + fputs("S",of); + } + type = type->next; + } +} +/*-----------------------------------------------------------------*/ +/* cdbSymbol - prints a symbol & its type information for debugger */ +/*-----------------------------------------------------------------*/ +void cdbSymbol ( symbol *sym, FILE *of, int isStructSym, int isFunc) +{ + memmap *map; + + if (!sym) + return ; + if (!of) + of = stdout; + + if (isFunc) + fprintf(of,"F:"); + else + fprintf(of,"S:"); /* symbol record */ + /* if this is not a structure symbol then + we need to figure out the scope information */ + if (!isStructSym) { + if (!sym->level) { + /* global */ + if (IS_STATIC(sym->etype)) + fprintf(of,"F%s$",moduleName); /* scope is file */ + else + fprintf(of,"G$"); /* scope is global */ + } + else + /* symbol is local */ + fprintf(of,"L%s$",(sym->localof ? sym->localof->name : "-null-")); + } else + fprintf(of,"S$"); /* scope is structure */ + + /* print the name, & mangled name */ + fprintf(of,"%s$%d$%d(",sym->name, + sym->level,sym->block); + + cdbTypeInfo(sym->type,of); + fprintf(of,"),"); + + /* print the address space */ + map = SPEC_OCLS(sym->etype); + fprintf(of,"%c,%d,%d", + (map ? map->dbName : 'Z') ,sym->onStack,SPEC_STAK(sym->etype)); + + /* if assigned to registers then output register names */ + /* if this is a function then print + if is it an interrupt routine & interrupt number + and the register bank it is using */ + if (isFunc) + fprintf(of,",%d,%d,%d",SPEC_INTRTN(sym->etype), + SPEC_INTN(sym->etype),SPEC_BANK(sym->etype)); + /* alternate location to find this symbol @ : eg registers + or spillication */ + + if (!isStructSym) + fprintf(of,"\n"); +} + +/*-----------------------------------------------------------------*/ +/* cdbStruct - print a structure for debugger */ +/*-----------------------------------------------------------------*/ +void cdbStruct ( structdef *sdef,int block,FILE *of, + int inStruct, char *tag) +{ + symbol *sym; + + fprintf(of,"T:"); + /* if block # then must have function scope */ + fprintf(of,"F%s$",moduleName); + fprintf(of,"%s[",(tag ? tag : sdef->tag)); + for (sym=sdef->fields ; sym ; sym = sym->next) { + fprintf(of,"({%d}",sym->offset); + cdbSymbol(sym,of,TRUE,FALSE); + fprintf(of,")"); + } + fprintf(of,"]"); + if (!inStruct) + fprintf(of,"\n"); +} + +/*------------------------------------------------------------------*/ +/* cdbStructBlock - calls struct printing for a blcks */ +/*------------------------------------------------------------------*/ +void cdbStructBlock (int block , FILE *of) +{ + int i ; + bucket **table = StructTab; + bucket *chain; + + /* go thru the entire table */ + for ( i = 0 ; i < 256; i++ ) { + for ( chain = table[i]; chain ; chain = chain->next ) { + if (chain->block >= block) { + cdbStruct((structdef *)chain->sym, chain->block ,of,0,NULL); + } + } + } +} + +/*-----------------------------------------------------------------*/ +/* powof2 - returns power of two for the number if number is pow 2 */ +/*-----------------------------------------------------------------*/ +int powof2 (unsigned long num) +{ + int nshifts = 0; + int n1s = 0 ; + + while (num) { + if (num & 1) n1s++ ; + num >>= 1 ; + nshifts++ ; + } + + if (n1s > 1 || nshifts == 0) return 0; + return nshifts - 1 ; +} + +symbol *__fsadd ; +symbol *__fssub ; +symbol *__fsmul ; +symbol *__fsdiv ; +symbol *__fseq ; +symbol *__fsneq ; +symbol *__fslt ; +symbol *__fslteq; +symbol *__fsgt ; +symbol *__fsgteq; +symbol *__fs2uchar; +symbol *__fs2uint ; +symbol *__fs2ulong; +symbol *__fs2char; +symbol *__fs2int ; +symbol *__fs2long; +symbol *__long2fs; +symbol *__ulong2fs; +symbol *__int2fs; +symbol *__uint2fs; +symbol *__char2fs; +symbol *__uchar2fs; +symbol *__muluint; +symbol *__mulsint; +symbol *__divuint; +symbol *__divsint; +symbol *__mululong; +symbol *__mulslong; +symbol *__divulong; +symbol *__divslong; +symbol *__moduint; +symbol *__modsint; +symbol *__modulong; +symbol *__modslong; + +link *charType ; +link *intType ; +link *floatType; +link *longType ; +link *ucharType ; +link *uintType ; +link *ulongType ; + +/*-----------------------------------------------------------------*/ +/* initCSupport - create functions for C support routines */ +/*-----------------------------------------------------------------*/ +void initCSupport () +{ + charType = newCharLink(); + intType = newIntLink(); + floatType= newFloatLink(); + longType = newLongLink(); + ucharType = copyLinkChain(charType); + SPEC_USIGN(ucharType) = 1; + ulongType = copyLinkChain(longType); + SPEC_USIGN(ulongType) = 1; + uintType = copyLinkChain(intType); + SPEC_USIGN(uintType) = 1; + + + __fsadd = funcOfType ("__fsadd", floatType, floatType, 2, options.float_rent); + __fssub = funcOfType ("__fssub", floatType, floatType, 2, options.float_rent); + __fsmul = funcOfType ("__fsmul", floatType, floatType, 2, options.float_rent); + __fsdiv = funcOfType ("__fsdiv", floatType, floatType, 2, options.float_rent); + __fseq = funcOfType ("__fseq", charType, floatType, 2, options.float_rent); + __fsneq = funcOfType ("__fsneq", charType, floatType, 2, options.float_rent); + __fslt = funcOfType ("__fslt", charType, floatType, 2, options.float_rent); + __fslteq= funcOfType ("__fslteq", charType, floatType, 2, options.float_rent); + __fsgt = funcOfType ("__fsgt", charType, floatType, 2, options.float_rent); + __fsgteq= funcOfType ("__fsgteq", charType, floatType, 2, options.float_rent); + + __fs2uchar = funcOfType ("__fs2uchar",ucharType,floatType,1, options.float_rent); + __fs2uint = funcOfType ("__fs2uint",uintType,floatType,1, options.float_rent); + __fs2ulong = funcOfType ("__fs2ulong",ulongType,floatType,1, options.float_rent); + __fs2char = funcOfType ("__fs2char",charType,floatType,1, options.float_rent); + __fs2int = funcOfType ("__fs2int",intType,floatType,1, options.float_rent); + __fs2long = funcOfType ("__fs2long",longType,floatType,1, options.float_rent); + + __long2fs = funcOfType ("__long2fs",floatType,longType,1, options.float_rent); + __ulong2fs = funcOfType ("__ulong2fs",floatType,ulongType,1, options.float_rent); + __int2fs = funcOfType ("__int2fs",floatType,intType,1, options.float_rent); + __uint2fs = funcOfType ("__uint2fs",floatType,uintType,1, options.float_rent); + __char2fs = funcOfType ("__char2fs",floatType,charType,1, options.float_rent); + __uchar2fs = funcOfType ("__uchar2fs",floatType,ucharType,1, options.float_rent); + + __muluint = funcOfType ("_muluint",uintType,uintType,2,options.intlong_rent); + __mulsint = funcOfType ("_mulsint",intType,intType,2,options.intlong_rent); + __divuint = funcOfType ("_divuint",uintType,uintType,2,options.intlong_rent); + __divsint = funcOfType ("_divsint",intType,intType,2,options.intlong_rent); + __moduint = funcOfType ("_moduint",uintType,uintType,2,options.intlong_rent); + __modsint = funcOfType ("_modsint",intType,intType,2,options.intlong_rent); + + __mululong = funcOfType ("_mululong",ulongType,ulongType,2,options.intlong_rent); + __mulslong = funcOfType ("_mulslong",longType,longType,2,options.intlong_rent); + __divulong = funcOfType ("_divulong",ulongType,ulongType,2,options.intlong_rent); + __divslong = funcOfType ("_divslong",longType,longType,2,options.intlong_rent); + __modulong = funcOfType ("_modulong",ulongType,ulongType,2,options.intlong_rent); + __modslong = funcOfType ("_modslong",longType,longType,2,options.intlong_rent); + +} diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h new file mode 100644 index 00000000..eff25e9f --- /dev/null +++ b/src/SDCCsymt.h @@ -0,0 +1,422 @@ +/*------------------------------------------------------------------------- + SDCCsymt.h - Header file for Symbols table related structures and MACRO's. + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef SDCCSYMT_H +#define SDCCSYMT_H + +#define MAX_NEST_LEVEL 256 +#define SDCC_NAME_MAX 64 +#include "SDCChasht.h" + + +#define HASHTAB_SIZE 256 + +/* hash table bucket */ +typedef struct bucket +{ + void *sym ; /* pointer to the object */ + char name[SDCC_NAME_MAX+1]; /* name of this symbol */ + int level ; /* nest level for this symbol */ + int block ; /* belongs to which block */ + struct bucket *prev ; /* ptr 2 previous bucket */ + struct bucket *next ; /* ptr 2 next bucket */ +} bucket ; + +typedef struct structdef { + char tag[SDCC_NAME_MAX+1]; /* tag part of structure */ + unsigned char level ; /* Nesting level */ + struct symbol *fields ; /* pointer to fields */ + unsigned size ; /* sizeof the table in bytes */ +} structdef ; + +/* noun definitions */ +enum { V_INT = 0, + V_FLOAT , + V_CHAR , + V_VOID , + V_STRUCT , + V_LABEL , + V_BIT , + V_SBIT }; + +/* storage class */ +enum { S_FIXED = 0, + S_AUTO , + S_REGISTER , + S_CONSTANT , + S_SFR , + S_SBIT , + S_CODE , + S_XDATA , + S_DATA , + S_IDATA , + S_PDATA , + S_LITERAL , + S_STACK , + S_XSTACK , + S_BIT }; + +/* specifier is the last in the type-chain */ +typedef struct specifier { + unsigned noun ; /* CHAR INT STRUCTURE LABEL */ + unsigned sclass ; /* REGISTER,AUTO,FIX,CONSTANT */ + struct memmap *oclass ; /* output storage class */ + unsigned _long : 1 ; /* 1=long */ + unsigned _short: 1 ; /* 1=short int */ + unsigned _unsigned: 1 ; /* 1=unsigned, 0=signed */ + unsigned _static: 1 ; /* 1=static keyword found */ + unsigned _extern: 1 ; /* 1=extern found */ + unsigned _absadr: 1 ; /* absolute address specfied */ + unsigned _reent : 1 ; /* function is reentrant */ + unsigned _intrtn: 1 ; /* this is an interrupt routin*/ + unsigned _rbank : 1 ; /* seperate register bank */ + unsigned _volatile : 1; /* is marked as volatile */ + unsigned _const:1 ; /* is a constant */ + unsigned _critical:1 ; /* critical function */ + unsigned _typedef :1 ; /* is typedefed */ + unsigned _isregparm:1 ; /* is the first parameter */ + unsigned _isenum :1 ; /* is an enumerated type */ + unsigned _IntNo ; /* 1=Interrupt svc routine */ + short _regbank ; /* register bank 2b used */ + unsigned _addr ; /* address of symbol */ + unsigned _stack ; /* stack offset for stacked v */ + unsigned _bitStart ; /* bit start position */ + int _bitLength ; /* bit length */ + + union { /* Values if constant or enum */ + int v_int ; /* int and char values */ + char *v_char; /* character string */ + unsigned v_uint; /* unsigned int const value */ + long v_long; /* long constant value */ + unsigned long v_ulong; /* unsigned long constant val */ + double v_float; /* floating point constant value */ + struct symbol *v_enum; /* ptr 2 enum_list if enum==1 */ + } const_val ; + struct structdef *v_struct; /* structure pointer */ +} specifier ; + +/* types of declarators */ +enum { POINTER = 0, /* pointer to near data */ + FPOINTER , /* pointer to far data */ + CPOINTER , /* pointer to code space */ + GPOINTER , /* _generic pointer */ + PPOINTER , /* paged area pointer */ + IPOINTER , /* pointer to upper 128 bytes */ + UPOINTER , /* unknown pointer used only when parsing */ + ARRAY , + FUNCTION }; + +typedef struct declarator { + short dcl_type; /* POINTER,ARRAY or FUNCTION */ + short num_elem; /* # of elems if type==array */ + short ptr_const :1; /* pointer is constant */ + short ptr_volatile:1; /* pointer is volatile */ + struct link *tspec; /* pointer type specifier */ +} declarator ; + +#define DECLARATOR 0 +#define SPECIFIER 1 + +typedef struct link { + unsigned class : 1 ; /* DECLARATOR or SPECIFIER */ + unsigned tdef : 1 ; /* current link created by */ + /* typedef if this flag is set*/ + union { + specifier s ; /* if CLASS == SPECIFIER */ + declarator d ; /* if CLASS == DECLARATOR */ + } select ; + + struct link *next ; /* next element on the chain */ +} link ; + +typedef struct symbol { + char name [SDCC_NAME_MAX+1] ; /* Input Variable Name */ + char rname[SDCC_NAME_MAX+1] ; /* internal name */ + + short level ; /* declration lev,fld offset */ + short block ; /* sequential block # of defintion */ + int key; + unsigned fbody :1 ; /* function body defined */ + unsigned implicit :1 ; /* implicit flag */ + unsigned undefined :1 ; /* undefined variable */ + unsigned ret :1 ; /* return statement for a function */ + unsigned hasVargs :1 ; /* has a variable argument list */ + unsigned _isparm :1 ; /* is a parameter */ + unsigned ismyparm :1 ; /* is parameter of the function being generated */ + unsigned isitmp :1 ; /* is an intermediate temp */ + unsigned islbl :1 ; /* is a temporary label */ + unsigned isref :1 ; /* has been referenced */ + unsigned isind :1 ; /* is a induction variable */ + unsigned isinvariant:1 ; /* is a loop invariant */ + unsigned isstrlit :1 ; /* is a string literal */ + unsigned cdef :1 ; /* compiler defined symbol */ + unsigned allocreq :1 ; /* allocation is required for this variable */ + unsigned addrtaken :1 ; /* address of the symbol was taken */ + unsigned isreqv :1 ; /* is the register quivalent of a symbol */ + unsigned hasFcall :1 ; /* for functions does it call other functions */ + unsigned calleeSave :1 ; /* for functions uses callee save paradigm */ + + /* following flags are used by the backend + for code generation and can be changed + if a better scheme for backend is thought of */ + + unsigned isspilt :1 ; /* has to be spilt */ + unsigned remat :1 ; /* can be remateriazed */ + unsigned isptr :1 ; /* is a pointer */ + unsigned uptr :1 ; /* used as a pointer */ + unsigned isFree :1 ; /* used by register allocator */ + unsigned islocal :1 ; /* is a local variable */ + unsigned blockSpil :1 ; /* spilt at block level */ + unsigned remainSpil :1 ; /* spilt because not used in remainder */ + unsigned stackSpil :1 ; /* has been spilt on temp stack location */ + unsigned onStack :1 ; /* this symbol allocated on the stack */ + unsigned iaccess :1 ; /* indirect access */ + unsigned ruonly :1 ; /* used in return statement only */ + unsigned accuse :1 ; /* can be left in the accumulator */ + unsigned spildir :1 ; /* spilt in direct space */ + unsigned ptrreg :1 ; /* this symbol assigned to a ptr reg */ + + int stack ; /* offset on stack */ + int xstack ; /* offset on xternal stack */ + short nRegs ; /* number of registers required */ + short regType ; /* type of register required */ + + struct regs *regs[4] ; /* can have at the most 4 registers */ + struct asmop *aop ; /* asmoperand for this symbol */ + struct iCode *fuse ; /* furthest use */ + struct iCode *rematiCode ; /* rematerialse with which instruction */ + struct operand *reqv ; /* register equivalent of a local variable */ + union { + struct symbol *spillLoc; /* register spil location */ + struct set *itmpStack; /* symbols spilt @ this stack location */ + } usl; + short bitVar ; /* this is a bit variable */ + unsigned offset ; /* offset from top if struct */ + + int lineDef ; /* defined line number */ + int lastLine ; /* for functions the last line*/ + struct link *type ; /* 1st link to declator chain */ + struct link *etype ; /* last link to declarator chn*/ + struct value *args ; /* arguments if function */ + struct symbol *next ; /* crosslink to next symbol */ + struct symbol *localof ; /* local variable of which function */ + struct initList *ival ; /* ptr to initializer if any */ + struct bitVect *defs ; /* bit vector for definitions */ + struct bitVect *uses ; /* bit vector for uses */ + struct bitVect *regsUsed ; /* for functions registers used */ + int liveFrom ; /* live from iCode sequence number */ + int liveTo ; /* live to sequence number */ + int used ; /* no. of times this was used */ + int recvSize ; /* size of first argument */ + +} symbol ; + +/* Easy Access Macros */ +#define DCL_TYPE(l) l->select.d.dcl_type +#define DCL_ELEM(l) l->select.d.num_elem +#define DCL_PTR_CONST(l) l->select.d.ptr_const +#define DCL_PTR_VOLATILE(l) l->select.d.ptr_volatile +#define DCL_TSPEC(l) l->select.d.tspec +#define SPEC_NOUN(x) x->select.s.noun +#define SPEC_LONG(x) x->select.s._long +#define SPEC_SHORT(x) x->select.s._short +#define SPEC_USIGN(x) x->select.s._unsigned +#define SPEC_SCLS(x) x->select.s.sclass +#define SPEC_ENUM(x) x->select.s._isenum +#define SPEC_OCLS(x) x->select.s.oclass +#define SPEC_STAT(x) x->select.s._static +#define SPEC_EXTR(x) x->select.s._extern +#define SPEC_CODE(x) x->select.s._codesg +#define SPEC_RENT(x) x->select.s._reent +#define SPEC_INTN(x) x->select.s._IntNo +#define SPEC_ABSA(x) x->select.s._absadr +#define SPEC_BANK(x) x->select.s._regbank +#define SPEC_ADDR(x) x->select.s._addr +#define SPEC_STAK(x) x->select.s._stack +#define SPEC_CVAL(x) x->select.s.const_val +#define SPEC_BSTR(x) x->select.s._bitStart +#define SPEC_BLEN(x) x->select.s._bitLength +#define SPEC_BNKF(x) x->select.s._rbank +#define SPEC_INTRTN(x) x->select.s._intrtn +#define SPEC_CRTCL(x) x->select.s._critical +#define SPEC_VOLATILE(x) x->select.s._volatile +#define SPEC_CONST(x) x->select.s._const +#define SPEC_STRUCT(x) x->select.s.v_struct +#define SPEC_TYPEDEF(x) x->select.s._typedef +#define SPEC_REGPARM(x) x->select.s._isregparm + +/* type check macros */ +#define IS_DECL(x) ( x && x->class == DECLARATOR ) +#define IS_SPEC(x) ( x && x->class == SPECIFIER ) +#define IS_ARRAY(x) (IS_DECL(x) && DCL_TYPE(x) == ARRAY) +#define IS_DATA_PTR(x) (IS_DECL(x) && DCL_TYPE(x) == POINTER) +#define IS_PTR(x) (IS_DECL(x) && (DCL_TYPE(x) == POINTER || \ + DCL_TYPE(x) == FPOINTER || \ + DCL_TYPE(x) == GPOINTER || \ + DCL_TYPE(x) == IPOINTER || \ + DCL_TYPE(x) == PPOINTER || \ + DCL_TYPE(x) == CPOINTER || \ + DCL_TYPE(x) == UPOINTER )) +#define IS_PTR_CONST(x) (IS_PTR(x) && DCL_PTR_CONST(x)) +#define IS_FARPTR(x) (IS_DECL(x) && DCL_TYPE(x) == FPOINTER) +#define IS_GENPTR(x) (IS_DECL(x) && DCL_TYPE(x) == GPOINTER) +#define IS_FUNC(x) (IS_DECL(x) && DCL_TYPE(x) == FUNCTION) +#define IS_LONG(x) (IS_SPEC(x) && x->select.s._long) +#define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short) +#define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef) +#define IS_CONSTANT(x) (IS_SPEC(x) && (x->select.s.sclass == S_CONSTANT ||\ + x->select.s._const == 1)) +#define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT) +#define IS_ABSOLUTE(x) (IS_SPEC(x) && x->select.s._absadr ) +#define IS_REGISTER(x) (IS_SPEC(x) && SPEC_SCLS(x) == S_REGISTER) +#define IS_RENT(x) (IS_SPEC(x) && x->select.s._reent ) +#define IS_STATIC(x) (IS_SPEC(x) && SPEC_STAT(x)) +#define IS_INT(x) (IS_SPEC(x) && x->select.s.noun == V_INT) +#define IS_VOID(x) (IS_SPEC(x) && x->select.s.noun == V_VOID) +#define IS_CHAR(x) (IS_SPEC(x) && x->select.s.noun == V_CHAR) +#define IS_EXTERN(x) (IS_SPEC(x) && x->select.s._extern) +#define IS_VOLATILE(x) (IS_SPEC(x) && x->select.s._volatile ) +#define IS_INTEGRAL(x) (IS_SPEC(x) && (x->select.s.noun == V_INT || \ + x->select.s.noun == V_CHAR || \ + x->select.s.noun == V_BIT || \ + x->select.s.noun == V_SBIT )) +#define IS_BITFIELD(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT)) +#define IS_BITVAR(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT || \ + x->select.s.noun == V_SBIT )) +#define IS_FLOAT(x) (IS_SPEC(x) && x->select.s.noun == V_FLOAT) +#define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x)) +#define IS_AGGREGATE(x) (IS_ARRAY(x) || IS_STRUCT(x)) +#define IS_LITERAL(x) (IS_SPEC(x) && x->select.s.sclass == S_LITERAL) +#define IS_ISR(x) (IS_SPEC(x) && SPEC_INTRTN(x)) +#define IS_REGPARM(x) (IS_SPEC(x) && SPEC_REGPARM(x)) + +/* forward declaration for the global vars */ +extern bucket *SymbolTab[] ; +extern bucket *StructTab[] ; +extern bucket *TypedefTab[]; +extern bucket *LabelTab[] ; +extern bucket *enumTab[]; +extern symbol *__fsadd ; +extern symbol *__fssub ; +extern symbol *__fsmul ; +extern symbol *__fsdiv ; +extern symbol *__fseq ; +extern symbol *__fsneq ; +extern symbol *__fslt ; +extern symbol *__fslteq; +extern symbol *__fsgt ; +extern symbol *__fsgteq; +extern symbol *__fs2uchar; +extern symbol *__fs2uint ; +extern symbol *__fs2ulong; +extern symbol *__fs2char; +extern symbol *__fs2int ; +extern symbol *__fs2long; +extern symbol *__long2fs; +extern symbol *__ulong2fs; +extern symbol *__int2fs; +extern symbol *__uint2fs; +extern symbol *__char2fs; +extern symbol *__uchar2fs; +extern symbol *__muluint; +extern symbol *__mulsint; +extern symbol *__divuint; +extern symbol *__divsint; +extern symbol *__mululong; +extern symbol *__mulslong; +extern symbol *__divulong; +extern symbol *__divslong; +extern symbol *__moduint; +extern symbol *__modsint; +extern symbol *__modulong; +extern symbol *__modslong; + +extern link *charType ; +extern link *intType ; +extern link *floatType; +extern link *longType ; +extern link *ucharType ; +extern link *uintType ; +extern link *ulongType ; + +#include "SDCCval.h" + +/* forward definitions for the symbol table related functions */ +void initSymt ( ); +symbol *newSymbol ( char *, int ); +link *newLink ( ); +structdef *newStruct ( char * ); +void addDecl ( symbol *, int , link * ); +link *mergeSpec ( link *, link * ); +link *cloneSpec ( link * ); +symbol *reverseSyms ( symbol * ); +link *reverseLink ( link * ); +symbol *copySymbol ( symbol * ); +symbol *copySymbolChain ( symbol * ); +void printSymChain ( symbol *, int ); +void printStruct ( structdef *, int ); +char *genSymName ( int ); +link *getSpec ( link * ); +char *genSymName ( int ); +int compStructSize ( int ,structdef * ); +link *copyLinkChain ( link * ); +int checkDecl ( symbol * ); +void checkSClass ( symbol * ); +void checkBasic ( link *, link * ); +value *checkPointerIval ( link *, value * ); +value *checkStructIval ( symbol *, value * ); +value *checkArrayIval ( link *, value * ); +value *checkIval ( link *, value * ); +unsigned int getSize ( link * ); +unsigned int bitsForType ( link * ); +link *newIntLink ( ); +link *newCharLink ( ); +link *newLongLink ( ); +int checkType ( link *, link * ); +int checkFunction ( symbol * ); +void cleanUpLevel ( bucket **,int ); +void cleanUpBlock ( bucket **,int ); +int funcInChain ( link * ); +void addSymChain ( symbol * ); +link *structElemType ( link *, value * , value ** ); +symbol *getStructElement ( structdef *, symbol *) ; +link *computeType ( link *, link *); +void processFuncArgs (symbol *,int); +int isSymbolEqual (symbol *, symbol *); +int powof2 (unsigned long ); +void printTypeChain (link *,FILE *); +void initCSupport (); +void pointerTypes (link *, link * ); +void cdbTypeInfo (link *,FILE *); +void cdbSymbol (symbol *,FILE *,int,int); +void cdbStructBlock (int ,FILE *); +void initHashT ( ); +bucket *newBucket ( ); +void addSym ( bucket ** , void *, char *, int, int); +void deleteSym ( bucket ** , void *, char *); +void *findSym ( bucket ** , void *, char *); +void *findSymWithLevel ( bucket ** , struct symbol * ); +void *findSymWithBlock ( bucket ** , struct symbol *,int ); +#include "SDCCmem.h" + +#endif diff --git a/src/SDCCval.c b/src/SDCCval.c new file mode 100644 index 00000000..3c20fe8a --- /dev/null +++ b/src/SDCCval.c @@ -0,0 +1,1291 @@ +/*---------------------------------------------------------------------- + SDCCval.c :- has routine to do all kinds of fun stuff with the + value wrapper & with initialiser lists. + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCCval.h" +#include "SDCCast.h" +#include "SDCCy.h" + +int cNestLevel ; + +/*-----------------------------------------------------------------*/ +/* newValue - allocates and returns a new value */ +/*-----------------------------------------------------------------*/ +value *newValue () +{ + value *val ; + + ALLOC(val,sizeof(value)); + + return val ; +} + +/*-----------------------------------------------------------------*/ +/* newiList - new initializer list */ +/*-----------------------------------------------------------------*/ +initList *newiList ( int type, void *ilist) +{ + initList *nilist; + + + ALLOC(nilist,sizeof(initList)); + + nilist->type = type ; + nilist->lineno = yylineno ; + + switch (type) { + case INIT_NODE : + nilist->init.node = (struct ast *) ilist ; + break ; + + case INIT_DEEP : + nilist->init.deep = (struct initList *) ilist ; + break ; + } + + return nilist ; +} + +/*------------------------------------------------------------------*/ +/* revinit - reverses the initial values for a value chain */ +/*------------------------------------------------------------------*/ +initList *revinit ( initList *val) +{ + initList *prev , *curr, *next ; + + if (!val) + return NULL ; + + prev = val ; + curr = val->next ; + + while (curr) { + next = curr->next ; + curr->next = prev ; + prev = curr ; + curr = next ; + } + val->next = (void *) NULL ; + return prev ; +} + +/*------------------------------------------------------------------*/ +/* copyIlist - copy initializer list */ +/*------------------------------------------------------------------*/ +initList *copyIlist (initList *src) +{ + initList *dest = NULL; + + if (!src) + return NULL ; + + switch (src->type) { + case INIT_DEEP : + dest = newiList (INIT_DEEP,copyIlist (src->init.deep)); + break; + case INIT_NODE : + dest = newiList (INIT_NODE,copyAst (src->init.node)) ; + break; + } + + if ( src->next ) + dest->next = copyIlist(src->next); + + return dest ; +} + +/*------------------------------------------------------------------*/ +/* list2int - converts the first element of the list to value */ +/*------------------------------------------------------------------*/ +double list2int (initList *val) +{ + initList *i = val; + + if ( i->type == INIT_DEEP ) + return list2int (val->init.deep) ; + + return floatFromVal(constExprValue(val->init.node,TRUE)); +} + +/*------------------------------------------------------------------*/ +/* list2val - converts the first element of the list to value */ +/*------------------------------------------------------------------*/ +value *list2val (initList *val) +{ + if (!val) + return NULL; + + if ( val->type == INIT_DEEP ) + return list2val (val->init.deep) ; + + return constExprValue(val->init.node,TRUE); +} + +/*------------------------------------------------------------------*/ +/* list2expr - returns the first expression in the initializer list */ +/*------------------------------------------------------------------*/ +ast *list2expr ( initList *ilist) +{ + if ( ilist->type == INIT_DEEP ) + return list2expr (ilist->init.deep) ; + return ilist->init.node ; +} + +/*------------------------------------------------------------------*/ +/* resolveIvalSym - resolve symbols in initial values */ +/*------------------------------------------------------------------*/ +void resolveIvalSym ( initList *ilist) +{ + if ( ! ilist ) + return ; + + if ( ilist->type == INIT_NODE ) + ilist->init.node = decorateType(resolveSymbols (ilist->init.node)); + + if ( ilist->type == INIT_DEEP ) + resolveIvalSym (ilist->init.deep); + + resolveIvalSym (ilist->next); +} + +/*-----------------------------------------------------------------*/ +/* symbolVal - creates a value for a symbol */ +/*-----------------------------------------------------------------*/ +value *symbolVal ( symbol *sym ) +{ + value *val ; + + if (!sym) + return NULL ; + + val = newValue(); + val->sym = sym ; + + if ( sym->type ) { + val->type = sym->type; + val->etype= getSpec(val->type); + } + + if ( *sym->rname ) + sprintf (val->name,"%s",sym->rname); + else + sprintf(val->name,"_%s",sym->name); + + + return val ; +} + +/*-----------------------------------------------------------------*/ +/* valueFromLit - creates a value from a literal */ +/*-----------------------------------------------------------------*/ +value *valueFromLit (float lit) +{ + char buffer[50]; + + if ( ( ((long) lit ) - lit ) == 0 ) { + sprintf(buffer,"%ld",(long) lit); + return constVal (buffer); + } + + sprintf(buffer,"%f",lit); + return constFloatVal (buffer); +} + +/*-----------------------------------------------------------------*/ +/* constFloatVal - converts a FLOAT constant to value */ +/*-----------------------------------------------------------------*/ +value *constFloatVal ( char *s ) +{ + value *val = newValue(); + float sval; + + if(sscanf (s,"%f",&sval) != 1) { + werror(E_INVALID_FLOAT_CONST,s); + return constVal("0"); + } + + val->type = val->etype = newLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = V_FLOAT ; + SPEC_SCLS(val->type) = S_LITERAL; + SPEC_CVAL(val->type).v_float = sval; + + return val; +} + +/*-----------------------------------------------------------------*/ +/* constVal - converts a INTEGER constant into a value */ +/*-----------------------------------------------------------------*/ +value *constVal (char *s) +{ + value *val ; + short hex = 0 , octal = 0 ; + char scanFmt[10] ; + int scI = 0 ; + unsigned long sval ; + + val = newValue() ; /* alloc space for value */ + + val->type = val->etype = newLink() ; /* create the spcifier */ + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = V_INT ; + SPEC_SCLS(val->type) = S_LITERAL ; + + /* set the _unsigned flag if 'uU' found */ + if (strchr(s,'u') || strchr(s,'U')) + SPEC_USIGN(val->type) = 1; + + /* set the _long flag if 'lL' is found */ + if (strchr(s,'l') || strchr(s,'L')) + SPEC_LONG(val->type) = 1; + + hex = ((strchr(s,'x') || strchr(s,'X')) ? 1 : 0) ; + + /* set the octal flag */ + if (!hex && *s == '0' && *(s+1) ) + octal = 1 ; + + /* create the scan string */ + scanFmt[scI++] = '%' ; + + if (octal) + scanFmt[scI++] = 'o' ; + else + if (hex) + scanFmt[scI++] = 'x' ; + else + if (SPEC_USIGN(val->type)) + scanFmt[scI++] = 'u' ; + else + scanFmt[scI++] = 'd' ; + + scanFmt[scI++] = '\0' ; + + /* if hex or octal then set the unsigned flag */ + if ( hex || octal ) { + SPEC_USIGN(val->type) = 1 ; + sscanf(s,scanFmt,&sval); + } else + sval = atol(s); + + + if (SPEC_LONG(val->type) || sval > 32768) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = sval ; + else + SPEC_CVAL(val->type).v_long = sval ; + SPEC_LONG(val->type) = 1; + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = sval ; + else + SPEC_CVAL(val->type).v_int = sval ; + } + + // check the size and make it a short if required + if (sval < 256 ) + SPEC_SHORT(val->etype) = 1; + + return val ; + +} + +/*------------------------------------------------------------------*/ +/* copyStr - copies src to dest ignoring leading & trailing \"s */ +/*------------------------------------------------------------------*/ +void copyStr (char *dest, char *src ) +{ + unsigned int x; + while (*src) { + if (*src == '\"' ) + src++ ; + else + if ( *src == '\\' ) { + src++ ; + switch (*src) { + case 'n' : + *dest++ = '\n'; + break ; + case 't' : + *dest++ = '\t'; + break; + case 'v' : + *dest++ = '\v'; + break; + case 'b' : + *dest++ = '\b'; + break; + case 'r' : + *dest++ = '\r'; + break; + case 'f' : + *dest++ = '\f'; + break; + case 'a' : + *dest++ = '\a'; + break; + case '0': + /* embedded octal or hex constant */ + if (*(src+1) == 'x' || + *(src+1) == 'X') { + x = strtol(src,&src,16); + *dest++ = x; + } else { + /* must be octal */ + x = strtol(src,&src,8); + *dest++ = x; + } + break; + + case '\\': + *dest++ = '\\'; + break; + case '\?': + *dest++ = '\?'; + break; + case '\'': + *dest++ = '\''; + break; + case '\"': + *dest++ = '\"'; + break; + default : + *dest++ = *src ; + } + src++ ; + } + else + *dest++ = *src++ ; + } + + *dest = '\0' ; +} + +/*------------------------------------------------------------------*/ +/* strVal - converts a string constant to a value */ +/*------------------------------------------------------------------*/ +value *strVal ( char *s ) +{ + value *val ; + + val = newValue() ; /* get a new one */ + + /* get a declarator */ + val->type = newLink(); + DCL_TYPE(val->type) = ARRAY ; + DCL_ELEM(val->type) = strlen(s) - 1; + val->type->next = val->etype = newLink() ; + val->etype->class = SPECIFIER; + SPEC_NOUN(val->etype) = V_CHAR ; + SPEC_SCLS(val->etype) = S_LITERAL; + + ALLOC_ATOMIC(SPEC_CVAL(val->etype).v_char,strlen(s)+1); + copyStr (SPEC_CVAL(val->etype).v_char,s); + return val; +} + + +/*------------------------------------------------------------------*/ +/* reverseValWithType - reverses value chain with type & etype */ +/*------------------------------------------------------------------*/ +value *reverseValWithType ( value *val ) +{ + link *type ; + link *etype; + + if (!val) + return NULL ; + + /* save the type * etype chains */ + type = val->type ; + etype = val->etype ; + + /* set the current one 2b null */ + val->type = val->etype = NULL; + val = reverseVal (val); + + /* restore type & etype */ + val->type = type ; + val->etype = etype ; + + return val; +} + +/*------------------------------------------------------------------*/ +/* reverseVal - reverses the values for a value chain */ +/*------------------------------------------------------------------*/ +value *reverseVal ( value *val) +{ + value *prev , *curr, *next ; + + if (!val) + return NULL ; + + prev = val ; + curr = val->next ; + + while (curr) { + next = curr->next ; + curr->next = prev ; + prev = curr ; + curr = next ; + } + val->next = (void *) NULL ; + return prev ; +} + +/*------------------------------------------------------------------*/ +/* copyValueChain - will copy a chain of values */ +/*------------------------------------------------------------------*/ +value *copyValueChain ( value *src ) +{ + value *dest ; + + if ( ! src ) + return NULL ; + + dest = copyValue (src); + dest->next = copyValueChain (src->next); + + return dest ; +} + +/*------------------------------------------------------------------*/ +/* copyValue - copies contents of a vlue to a fresh one */ +/*------------------------------------------------------------------*/ +value *copyValue (value *src) +{ + value *dest ; + + dest = newValue(); + dest->sym = copySymbol(src->sym); + strcpy(dest->name,src->name); + dest->type = (src->type ? copyLinkChain(src->type) : NULL) ; + dest->etype = (src->type ? getSpec(dest->type) : NULL); + + return dest ; +} + +/*------------------------------------------------------------------*/ +/* charVal - converts a character constant to a value */ +/*------------------------------------------------------------------*/ +value *charVal ( char *s ) +{ + value *val ; + + val = newValue (); + + val->type = val->etype = newLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = V_CHAR ; + SPEC_SCLS(val->type) = S_LITERAL ; + + s++ ; /* get rid of quotation */ + /* if \ then special processing */ + if ( *s == '\\' ) { + s++ ; /* go beyond the backslash */ + switch (*s) { + case 'n' : + SPEC_CVAL(val->type).v_int = '\n'; + break ; + case 't' : + SPEC_CVAL(val->type).v_int = '\t'; + break; + case 'v' : + SPEC_CVAL(val->type).v_int = '\v'; + break; + case 'b' : + SPEC_CVAL(val->type).v_int = '\b'; + break; + case 'r' : + SPEC_CVAL(val->type).v_int = '\r'; + break; + case 'f' : + SPEC_CVAL(val->type).v_int = '\f'; + break; + case 'a' : + SPEC_CVAL(val->type).v_int = '\a'; + break; + case '\\': + SPEC_CVAL(val->type).v_int = '\\'; + break; + case '\?': + SPEC_CVAL(val->type).v_int = '\?'; + break; + case '\'': + SPEC_CVAL(val->type).v_int = '\''; + break; + case '\"': + SPEC_CVAL(val->type).v_int = '\"'; + break; + case '0' : + sscanf(s,"%o",&SPEC_CVAL(val->type).v_int); + break; + case 'x' : + s++ ; /* go behond the 'x' */ + sscanf(s,"%x",&SPEC_CVAL(val->type).v_int); + break; + default : + SPEC_CVAL(val->type).v_int = *s; + break; + } + } + else /* not a backslash */ + SPEC_CVAL(val->type).v_int = *s; + + return val ; +} + +/*------------------------------------------------------------------*/ +/* valFromType - creates a value from type given */ +/*------------------------------------------------------------------*/ +value *valFromType ( link *type) +{ + value *val = newValue(); + val->type = copyLinkChain(type); + val->etype = getSpec(val->type); + return val; +} + +/*------------------------------------------------------------------*/ +/* floatFromVal - value to unsinged integer conversion */ +/*------------------------------------------------------------------*/ +double floatFromVal ( value *val ) +{ + if (!val) + return 0; + + if (SPEC_SCLS(val->etype) != S_LITERAL) { + werror(E_CONST_EXPECTED,val->name); + return 0; + } + + /* if it is not a specifier then we can assume that */ + /* it will be an unsigned long */ + if (!IS_SPEC(val->type)) + return (double) SPEC_CVAL(val->etype).v_ulong; + + if (SPEC_NOUN(val->etype) == V_FLOAT ) + return (double) SPEC_CVAL(val->etype).v_float ; + else { + if (SPEC_LONG(val->etype)) { + if (SPEC_USIGN(val->etype)) + return (double) SPEC_CVAL(val->etype).v_ulong ; + else + return (double) SPEC_CVAL(val->etype).v_long ; + } + else { + if (SPEC_USIGN(val->etype)) + return (double) SPEC_CVAL(val->etype).v_uint ; + else + return (double) SPEC_CVAL(val->etype).v_int ; + } + } +} + + +/*------------------------------------------------------------------*/ +/* valUnaryPM - dones the unary +/- operation on a constant */ +/*------------------------------------------------------------------*/ +value *valUnaryPM (value *val) +{ + /* depending on type */ + if (SPEC_NOUN(val->etype) == V_FLOAT ) + SPEC_CVAL(val->etype).v_float = -1.0 * SPEC_CVAL(val->etype).v_float; + else { + if ( SPEC_LONG(val->etype)) { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_ulong = - SPEC_CVAL(val->etype).v_ulong ; + else + SPEC_CVAL(val->etype).v_long = - SPEC_CVAL(val->etype).v_long; + } + else { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_uint = - SPEC_CVAL(val->etype).v_uint ; + else + SPEC_CVAL(val->etype).v_int = - SPEC_CVAL(val->etype).v_int ; + } + } + return val ; + +} + +/*------------------------------------------------------------------*/ +/* valueComplement - complements a constant */ +/*------------------------------------------------------------------*/ +value *valComplement ( value *val) +{ + /* depending on type */ + if ( SPEC_LONG(val->etype)) { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_ulong = ~SPEC_CVAL(val->etype).v_ulong ; + else + SPEC_CVAL(val->etype).v_long = ~SPEC_CVAL(val->etype).v_long; + } + else { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_uint = ~SPEC_CVAL(val->etype).v_uint ; + else + SPEC_CVAL(val->etype).v_int = ~SPEC_CVAL(val->etype).v_int ; + } + return val ; +} + +/*------------------------------------------------------------------*/ +/* valueNot - complements a constant */ +/*------------------------------------------------------------------*/ +value *valNot ( value *val) +{ + /* depending on type */ + if ( SPEC_LONG(val->etype)) { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_ulong = !SPEC_CVAL(val->etype).v_ulong ; + else + SPEC_CVAL(val->etype).v_long = !SPEC_CVAL(val->etype).v_long; + } + else { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_uint = !SPEC_CVAL(val->etype).v_uint ; + else + SPEC_CVAL(val->etype).v_int = !SPEC_CVAL(val->etype).v_int ; + } + return val ; +} + +/*------------------------------------------------------------------*/ +/* valMult - multiply constants */ +/*------------------------------------------------------------------*/ +value *valMult (value *lval, value *rval) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = val->etype = newLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = (IS_FLOAT(lval->etype) || + IS_FLOAT(rval->etype) ? V_FLOAT : V_INT ); + SPEC_SCLS(val->type) = S_LITERAL;/* will remain literal */ + SPEC_USIGN(val->type) = (SPEC_USIGN(lval->etype) | SPEC_USIGN(rval->etype)); + SPEC_LONG(val->type) = (SPEC_LONG(lval->etype) | SPEC_LONG(rval->etype)); + + if (IS_FLOAT(val->type)) + SPEC_CVAL(val->type).v_float = floatFromVal(lval) * floatFromVal(rval); + else { + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) * + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) * + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) * + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (int) floatFromVal(lval) * + (int) floatFromVal(rval); + } + } + return val ; +} + +/*------------------------------------------------------------------*/ +/* valDiv - Divide constants */ +/*------------------------------------------------------------------*/ +value *valDiv (value *lval, value *rval) +{ + value *val ; + + if (floatFromVal(rval) == 0) { + werror(E_DIVIDE_BY_ZERO); + return rval; + } + + /* create a new value */ + val = newValue(); + val->type = val->etype = ((floatFromVal(lval) / floatFromVal(rval)) < 256 ? + newCharLink() : newIntLink()); + if (IS_FLOAT(lval->etype) || IS_FLOAT(rval->etype)) + SPEC_NOUN(val->etype) = V_FLOAT ; + SPEC_SCLS(val->etype) = S_LITERAL ; + SPEC_USIGN(val->type) = (SPEC_USIGN(lval->etype) | SPEC_USIGN(rval->etype)); + SPEC_LONG(val->type) = (SPEC_LONG(lval->etype) | SPEC_LONG(rval->etype)); + + if (IS_FLOAT(val->type)) + SPEC_CVAL(val->type).v_float = floatFromVal(lval) / floatFromVal(rval); + else { + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) / + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) / + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) / + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (int) floatFromVal(lval) / + (int) floatFromVal(rval); + } + } + return val ; +} + +/*------------------------------------------------------------------*/ +/* valMod - Modulus constants */ +/*------------------------------------------------------------------*/ +value *valMod (value *lval, value *rval) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = val->etype = newLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = V_INT ; /* type is int */ + SPEC_SCLS(val->type) = S_LITERAL;/* will remain literal */ + SPEC_USIGN(val->type) = (SPEC_USIGN(lval->etype) | SPEC_USIGN(rval->etype)); + SPEC_LONG(val->type) = (SPEC_LONG(lval->etype) | SPEC_LONG(rval->etype)); + + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) % + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (unsigned long) floatFromVal(lval) % + (unsigned long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) % + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (unsigned) floatFromVal(lval) % + (unsigned) floatFromVal(rval); + } + + return val ; +} + +/*------------------------------------------------------------------*/ +/* valPlus - Addition constants */ +/*------------------------------------------------------------------*/ +value *valPlus (value *lval, value *rval) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = val->etype = newLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = (IS_FLOAT(lval->etype) || + IS_FLOAT(rval->etype) ? V_FLOAT : V_INT ); + SPEC_SCLS(val->type) = S_LITERAL;/* will remain literal */ + SPEC_USIGN(val->type) = (SPEC_USIGN(lval->etype) | SPEC_USIGN(rval->etype)); + SPEC_LONG(val->type) = (SPEC_LONG(lval->etype) | SPEC_LONG(rval->etype)); + + if (IS_FLOAT(val->type)) + SPEC_CVAL(val->type).v_float = floatFromVal(lval) + floatFromVal(rval); + else { + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) + + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) + + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) + + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (int) floatFromVal(lval) + + (int) floatFromVal(rval); + } + } + return val ; +} + +/*------------------------------------------------------------------*/ +/* valMinus - Addition constants */ +/*------------------------------------------------------------------*/ +value *valMinus (value *lval, value *rval) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = val->etype = newLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = (IS_FLOAT(lval->etype) || + IS_FLOAT(rval->etype) ? V_FLOAT : V_INT ); + SPEC_SCLS(val->type) = S_LITERAL;/* will remain literal */ + SPEC_USIGN(val->type) = (SPEC_USIGN(lval->etype) | SPEC_USIGN(rval->etype)); + SPEC_LONG(val->type) = (SPEC_LONG(lval->etype) | SPEC_LONG(rval->etype)); + + if (IS_FLOAT(val->type)) + SPEC_CVAL(val->type).v_float = floatFromVal(lval) - floatFromVal(rval); + else { + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) - + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) - + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) - + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (int) floatFromVal(lval) - (int) floatFromVal(rval); + } + } + return val ; +} + +/*------------------------------------------------------------------*/ +/* valShift - Shift left or right */ +/*------------------------------------------------------------------*/ +value *valShift (value *lval, value *rval, int lr) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = val->etype = newLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = V_INT ; /* type is int */ + SPEC_SCLS(val->type) = S_LITERAL;/* will remain literal */ + SPEC_USIGN(val->type) = (SPEC_USIGN(lval->etype) | SPEC_USIGN(rval->etype)); + SPEC_LONG(val->type) = (SPEC_LONG(lval->etype) | SPEC_LONG(rval->etype)); + + if (lr) { + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) << + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) << + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) << + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (int) floatFromVal(lval) << + (int) floatFromVal(rval); + } + } + else { + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) >> + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) >> + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) >> + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (int) floatFromVal(lval) >> + (int) floatFromVal(rval); + } + } + + return val ; +} + +/*------------------------------------------------------------------*/ +/* valCompare- Compares two literal */ +/*------------------------------------------------------------------*/ +value *valCompare (value *lval, value *rval, int ctype) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = val->etype = newCharLink(); + val->type->class = SPECIFIER ; + SPEC_NOUN(val->type) = V_INT ; /* type is int */ + SPEC_SCLS(val->type) = S_LITERAL;/* will remain literal */ + + switch (ctype) + { + case '<' : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) < floatFromVal(rval); + break ; + + case '>' : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) > floatFromVal(rval); + break ; + + case LE_OP : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) <= floatFromVal(rval); + break ; + + case GE_OP : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) >= floatFromVal(rval); + break ; + + case EQ_OP : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) == floatFromVal(rval); + break ; + + case NE_OP : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) != floatFromVal(rval); + break ; + + } + + return val ; +} + +/*------------------------------------------------------------------*/ +/* valBitwise - Bitwise operation */ +/*------------------------------------------------------------------*/ +value *valBitwise (value *lval, value *rval, int op) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = copyLinkChain (lval->type); + val->etype = getSpec(val->type); + + switch (op) + { + case '&' : + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) & + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) & + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) & + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = (int) floatFromVal(lval) & (int) floatFromVal(rval); + } + break ; + + case '|' : + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) | + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) | + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) | + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = + (int) floatFromVal(lval) | (int) floatFromVal(rval); + } + + break ; + + case '^' : + if (SPEC_LONG(val->type)) { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_ulong = (unsigned long) floatFromVal(lval) ^ + (unsigned long) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_long = (long) floatFromVal(lval) ^ + (long) floatFromVal(rval); + } + else { + if (SPEC_USIGN(val->type)) + SPEC_CVAL(val->type).v_uint = (unsigned) floatFromVal(lval) ^ + (unsigned) floatFromVal(rval); + else + SPEC_CVAL(val->type).v_int = + (int) floatFromVal(lval) ^ (int) floatFromVal(rval); + } + break ; + } + + return val ; +} + +/*------------------------------------------------------------------*/ +/* valAndOr - Generates code for and / or operation */ +/*------------------------------------------------------------------*/ +value *valLogicAndOr (value *lval, value *rval, int op) +{ + value *val ; + + /* create a new value */ + val = newValue(); + val->type = val->etype = newCharLink(); + val->type->class = SPECIFIER ; + SPEC_SCLS(val->type) = S_LITERAL;/* will remain literal */ + + switch (op) + { + case AND_OP : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) && floatFromVal(rval); + break ; + + case OR_OP : + SPEC_CVAL(val->type).v_int = floatFromVal(lval) || floatFromVal(rval); + break ; + } + + + return val ; +} + +/*------------------------------------------------------------------*/ +/* valCastLiteral - casts a literal value to another type */ +/*------------------------------------------------------------------*/ +value *valCastLiteral (link *dtype, double fval) +{ + value *val ; + + if (!dtype) + return NULL ; + + val = newValue(); + val->etype = getSpec (val->type = copyLinkChain(dtype)); + SPEC_SCLS(val->etype) = S_LITERAL ; + /* if it is not a specifier then we can assume that */ + /* it will be an unsigned long */ + if (!IS_SPEC(val->type)) { + SPEC_CVAL(val->etype).v_ulong = (unsigned long) fval; + return val; + } + + if (SPEC_NOUN(val->etype) == V_FLOAT ) + SPEC_CVAL(val->etype).v_float = fval; + else { + if (SPEC_LONG(val->etype)) { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_ulong = (unsigned long) fval; + else + SPEC_CVAL(val->etype).v_long = (long) fval; + } + else { + if (SPEC_USIGN(val->etype)) + SPEC_CVAL(val->etype).v_uint = (unsigned int) fval; + else + SPEC_CVAL(val->etype).v_int = (int) fval; + } + } + return val; +} + +/*------------------------------------------------------------------*/ +/* getNelements - determines # of elements from init list */ +/*------------------------------------------------------------------*/ +int getNelements (link *type,initList *ilist) +{ + link *etype = getSpec(type); + int i; + + if (! ilist) + return 0; + + if (ilist->type == INIT_DEEP) + ilist = ilist->init.deep; + + /* if type is a character array and there is only one + initialiser then get the length of the string */ + if (IS_ARRAY(type) && IS_CHAR(etype) && !ilist->next) { + ast *iast = ilist->init.node; + value *v = (iast->type == EX_VALUE ? iast->opval.val : NULL); + if (!v) { + werror(E_INIT_WRONG); + return 0; + } + if (!IS_ARRAY(v->type) || !IS_CHAR(v->etype)) { + werror(E_INIT_WRONG); + return 0; + } + return DCL_ELEM(v->type); + } + + i = 0 ; + while (ilist) { + i++; + ilist = ilist->next; + } + + return i; +} + +/*-----------------------------------------------------------------*/ +/* valForArray - returns a value with name of array index */ +/*-----------------------------------------------------------------*/ +value *valForArray (ast *arrExpr) +{ + value *val, *lval = NULL ; + char buffer[128]; + int size = getSize(arrExpr->left->ftype->next); + /* if the right or left is an array + resolve it first */ + if (IS_AST_OP(arrExpr->left)) { + if (arrExpr->left->opval.op == '[') + lval = valForArray(arrExpr->left); + else + if (arrExpr->left->opval.op == '.') + lval = valForStructElem(arrExpr->left->left, + arrExpr->left->right); + else + if (arrExpr->left->opval.op == PTR_OP && + IS_ADDRESS_OF_OP(arrExpr->left->left)) + lval = valForStructElem(arrExpr->left->left->left, + arrExpr->left->right); + else + return NULL; + + } else + if (!IS_AST_SYM_VALUE(arrExpr->left)) + return NULL ; + + if (!IS_AST_LIT_VALUE(arrExpr->right)) + return NULL; + + val = newValue(); + if (!lval) + sprintf(buffer,"%s",AST_SYMBOL(arrExpr->left)->rname); + else + sprintf(buffer,"%s",lval->name); + + sprintf(val->name,"(%s + %d)",buffer, + (int)AST_LIT_VALUE(arrExpr->right)*size); + + val->type = newLink(); + if (SPEC_SCLS(arrExpr->left->etype) == S_CODE) { + DCL_TYPE(val->type) = CPOINTER ; + DCL_PTR_CONST(val->type) = 1; + } + else + if (SPEC_SCLS(arrExpr->left->etype) == S_XDATA) + DCL_TYPE(val->type) = FPOINTER; + else + if (SPEC_SCLS(arrExpr->left->etype) == S_XSTACK ) + DCL_TYPE(val->type) = PPOINTER ; + else + if (SPEC_SCLS(arrExpr->left->etype) == S_IDATA) + DCL_TYPE(val->type) = IPOINTER ; + else + DCL_TYPE(val->type) = POINTER ; + val->type->next = arrExpr->left->ftype; + val->etype = getSpec(val->type); + return val; +} + +/*-----------------------------------------------------------------*/ +/* valForStructElem - returns value with name of struct element */ +/*-----------------------------------------------------------------*/ +value *valForStructElem(ast *structT, ast *elemT) +{ + value *val, *lval = NULL; + char buffer[128]; + symbol *sym; + + /* left could be furthur derefed */ + if (IS_AST_OP(structT)) { + if (structT->opval.op == '[') + lval = valForArray(structT); + else + if (structT->opval.op == '.') + lval = valForStructElem(structT->left,structT->right); + else + if (structT->opval.op == PTR_OP && + IS_ADDRESS_OF_OP(structT->left)) + lval = valForStructElem(structT->left->left, + structT->right); + else + return NULL; + } + + if (!IS_AST_SYM_VALUE(elemT)) + return NULL; + + if (!IS_STRUCT(structT->etype)) + return NULL; + + if ((sym = getStructElement(SPEC_STRUCT(structT->etype), + AST_SYMBOL(elemT))) == NULL) { + return NULL; + } + + val = newValue(); + if (!lval) + sprintf(buffer,"%s",AST_SYMBOL(structT)->rname); + else + sprintf(buffer,"%s",lval->name); + + sprintf(val->name,"(%s + %d)",buffer, + (int)sym->offset); + + val->type = newLink(); + if (SPEC_SCLS(structT->etype) == S_CODE) { + DCL_TYPE(val->type) = CPOINTER ; + DCL_PTR_CONST(val->type) = 1; + } + else + if (SPEC_SCLS(structT->etype) == S_XDATA) + DCL_TYPE(val->type) = FPOINTER; + else + if (SPEC_SCLS(structT->etype) == S_XSTACK ) + DCL_TYPE(val->type) = PPOINTER ; + else + if (SPEC_SCLS(structT->etype) == S_IDATA) + DCL_TYPE(val->type) = IPOINTER ; + else + DCL_TYPE(val->type) = POINTER ; + val->type->next = sym->type; + val->etype = getSpec(val->type); + return val; +} diff --git a/src/SDCCval.h b/src/SDCCval.h new file mode 100644 index 00000000..23b03936 --- /dev/null +++ b/src/SDCCval.h @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------- + SDCCval.h - value wrapper related header information + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1997) + + 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, 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; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ +#include "SDCCsymt.h" +#ifndef SDCCVAL_H +#define SDCCVAL_H + +/* value wrapper */ +typedef struct value { + char name[ SDCC_NAME_MAX + 1 ]; /* operand accessing this value */ + link *type ; /* start of type chain */ + link *etype; /* end of type chain */ + symbol *sym ; /* Original Symbol */ + struct value *next ; /* used in initializer list*/ + unsigned vArgs : 1 ; /* arg list ended with variable arg */ + +} value ; + +enum { + INIT_NODE , + INIT_DEEP , + INIT_HOLE +}; + +/* initializer lists use this structure */ +typedef struct initList { + int type ; + int lineno ; + union { + struct ast *node ; + struct initList *deep ; + } init ; + + struct initList *next ; +} initList ; + +#define IS_VARG(x) (x->vArgs) + +/* forward definitions for the symbol table related functions */ +void initValue ( ); +value *newValue ( ); +value *constVal (char * ); +value *reverseVal (value * ); +value *reverseValWithType(value * ); +value *copyValue (value * ); +value *copyValueChain (value * ); +value *strVal (char * ); +value *charVal (char * ); +value *symbolVal (symbol * ); +void printVal (value * ); +double floatFromVal (value * ); +value *array2Ptr (value * ); +value *valUnaryPM (value * ); +value *valComplement (value * ); +value *valNot (value * ); +value *valMult (value *, value * ); +value *valDiv (value *, value * ); +value *valMod (value *, value * ); +value *valPlus (value *, value * ); +value *valMinus (value *, value * ); +value *valShift (value *, value *,int); +value *valCompare (value *, value *,int); +value *valBitwise (value *, value *,int); +value *valLogicAndOr (value *, value *,int); +value *valCastLiteral (link *, double ); +value *valueFromLit (float ); +initList *newiList (int , void * ); +initList *revinit (initList * ); +initList *copyIlist (initList * ); +double list2int (initList * ); +value *list2val (initList * ); +struct ast *list2expr (initList * ); +void resolveIvalSym (initList * ); +value *valFromType (link * ); +value *constFloatVal (char * ); +int getNelements (link *, initList * ); +value *valForArray (struct ast * ); +value *valForStructElem (struct ast *, struct ast *); + +#endif diff --git a/src/SDCCy.c b/src/SDCCy.c new file mode 100644 index 00000000..596ca698 --- /dev/null +++ b/src/SDCCy.c @@ -0,0 +1,3093 @@ + +/* A Bison parser, made from SDCC.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define IDENTIFIER 257 +#define TYPE_NAME 258 +#define CONSTANT 259 +#define STRING_LITERAL 260 +#define SIZEOF 261 +#define PTR_OP 262 +#define INC_OP 263 +#define DEC_OP 264 +#define LEFT_OP 265 +#define RIGHT_OP 266 +#define LE_OP 267 +#define GE_OP 268 +#define EQ_OP 269 +#define NE_OP 270 +#define AND_OP 271 +#define OR_OP 272 +#define MUL_ASSIGN 273 +#define DIV_ASSIGN 274 +#define MOD_ASSIGN 275 +#define ADD_ASSIGN 276 +#define SUB_ASSIGN 277 +#define LEFT_ASSIGN 278 +#define RIGHT_ASSIGN 279 +#define AND_ASSIGN 280 +#define XOR_ASSIGN 281 +#define OR_ASSIGN 282 +#define TYPEDEF 283 +#define EXTERN 284 +#define STATIC 285 +#define AUTO 286 +#define REGISTER 287 +#define CODE 288 +#define INTERRUPT 289 +#define SFR 290 +#define AT 291 +#define SBIT 292 +#define REENTRANT 293 +#define USING 294 +#define XDATA 295 +#define DATA 296 +#define IDATA 297 +#define PDATA 298 +#define VAR_ARGS 299 +#define CRITICAL 300 +#define CHAR 301 +#define SHORT 302 +#define INT 303 +#define LONG 304 +#define SIGNED 305 +#define UNSIGNED 306 +#define FLOAT 307 +#define DOUBLE 308 +#define CONST 309 +#define VOLATILE 310 +#define VOID 311 +#define BIT 312 +#define STRUCT 313 +#define UNION 314 +#define ENUM 315 +#define ELIPSIS 316 +#define RANGE 317 +#define FAR 318 +#define _XDATA 319 +#define _CODE 320 +#define _GENERIC 321 +#define _NEAR 322 +#define _PDATA 323 +#define _IDATA 324 +#define CASE 325 +#define DEFAULT 326 +#define IF 327 +#define ELSE 328 +#define SWITCH 329 +#define WHILE 330 +#define DO 331 +#define FOR 332 +#define GOTO 333 +#define CONTINUE 334 +#define BREAK 335 +#define RETURN 336 +#define INLINEASM 337 +#define IFX 338 +#define ADDRESS_OF 339 +#define GET_VALUE_AT_ADDRESS 340 +#define SPIL 341 +#define UNSPIL 342 +#define GETHBIT 343 +#define BITWISEAND 344 +#define UNARYMINUS 345 +#define IPUSH 346 +#define IPOP 347 +#define PCALL 348 +#define ENDFUNCTION 349 +#define JUMPTABLE 350 +#define RRC 351 +#define RLC 352 +#define CAST 353 +#define CALL 354 +#define PARAM 355 +#define NULLOP 356 +#define BLOCK 357 +#define LABEL 358 +#define RECEIVE 359 +#define SEND 360 + +#line 24 "SDCC.y" + +#include +#include +#include +#include "SDCCglobl.h" +#include "SDCCsymt.h" +#include "SDCChasht.h" +#include "SDCCval.h" +#include "SDCCmem.h" +#include "SDCCast.h" +extern int yyerror (char *); +extern FILE *yyin; +extern char srcLstFname[]; +int NestLevel = 0 ; /* current NestLevel */ +int stackPtr = 1 ; /* stack pointer */ +int xstackPtr = 0 ; /* xstack pointer */ +int reentrant = 0 ; +int blockNo = 0 ; /* sequential block number */ +int currBlockno=0 ; +extern int yylex(); +int yyparse(void); +extern int noLineno ; +char lbuff[1024]; /* local buffer */ + +/* break & continue stacks */ +STACK_DCL(continueStack ,symbol *,MAX_NEST_LEVEL) +STACK_DCL(breakStack ,symbol *,MAX_NEST_LEVEL) +STACK_DCL(forStack ,symbol *,MAX_NEST_LEVEL) +STACK_DCL(swStk ,ast *,MAX_NEST_LEVEL) +STACK_DCL(blockNum,int,MAX_NEST_LEVEL*3) + +value *cenum = NULL ; /* current enumeration type chain*/ + + +#line 58 "SDCC.y" +typedef union { + symbol *sym ; /* symbol table pointer */ + structdef *sdef; /* structure definition */ + char yychar[SDCC_NAME_MAX+1]; + link *lnk ; /* declarator or specifier */ + int yyint; /* integer value returned */ + value *val ; /* for integer constant */ + initList *ilist; /* initial list */ + char yyinline[MAX_INLINEASM]; /* inlined assembler code */ + ast *asts; /* expression tree */ +} YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 392 +#define YYFLAG -32768 +#define YYNTBASE 131 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 360 ? yytranslate[x] : 218) + +static const short yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 118, 2, 2, 2, 120, 113, 2, 107, + 108, 114, 115, 112, 116, 111, 119, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 126, 128, 121, + 127, 122, 125, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 109, 2, 110, 123, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 129, 124, 130, 117, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 5, 7, 9, 12, 16, 18, 21, 24, + 26, 28, 30, 32, 35, 37, 39, 41, 45, 47, + 49, 54, 58, 63, 67, 71, 74, 77, 79, 83, + 85, 88, 91, 94, 97, 102, 104, 106, 108, 110, + 112, 114, 116, 121, 123, 127, 131, 135, 137, 141, + 145, 147, 151, 155, 157, 161, 165, 169, 173, 175, + 179, 183, 185, 189, 191, 195, 197, 201, 203, 207, + 209, 213, 215, 221, 223, 227, 229, 231, 233, 235, + 237, 239, 241, 243, 245, 247, 249, 251, 255, 257, + 260, 264, 266, 269, 271, 274, 276, 280, 282, 286, + 288, 290, 292, 294, 296, 299, 301, 305, 307, 309, + 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, + 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, + 355, 358, 360, 362, 364, 365, 367, 369, 372, 376, + 378, 382, 384, 387, 391, 396, 402, 405, 407, 411, + 414, 417, 418, 420, 423, 425, 428, 430, 434, 438, + 443, 447, 448, 454, 459, 461, 464, 467, 471, 474, + 476, 478, 480, 482, 484, 486, 487, 489, 492, 494, + 498, 500, 504, 506, 510, 512, 516, 519, 521, 523, + 526, 528, 530, 533, 537, 540, 544, 548, 553, 556, + 560, 564, 569, 571, 575, 580, 582, 586, 588, 590, + 592, 594, 596, 598, 601, 605, 610, 614, 616, 618, + 621, 625, 626, 631, 632, 638, 641, 643, 646, 648, + 651, 653, 656, 659, 660, 667, 668, 675, 677, 679, + 681, 687, 695, 705, 706, 708, 712, 715, 718, 721, + 725 +}; + +static const short yyrhs[] = { 132, + 0, 131, 132, 0, 133, 0, 159, 0, 180, 136, + 0, 160, 180, 136, 0, 135, 0, 135, 134, 0, + 40, 5, 0, 39, 0, 46, 0, 164, 0, 202, + 0, 205, 202, 0, 217, 0, 5, 0, 138, 0, + 107, 157, 108, 0, 6, 0, 137, 0, 139, 109, + 157, 110, 0, 139, 107, 108, 0, 139, 107, 140, + 108, 0, 139, 111, 217, 0, 139, 8, 217, 0, + 139, 9, 0, 139, 10, 0, 155, 0, 155, 112, + 140, 0, 139, 0, 9, 141, 0, 10, 141, 0, + 142, 143, 0, 7, 141, 0, 7, 107, 193, 108, + 0, 113, 0, 114, 0, 115, 0, 116, 0, 117, + 0, 118, 0, 141, 0, 107, 193, 108, 143, 0, + 143, 0, 144, 114, 143, 0, 144, 119, 143, 0, + 144, 120, 143, 0, 144, 0, 145, 115, 144, 0, + 145, 116, 144, 0, 145, 0, 146, 11, 145, 0, + 146, 12, 145, 0, 146, 0, 147, 121, 146, 0, + 147, 122, 146, 0, 147, 13, 146, 0, 147, 14, + 146, 0, 147, 0, 148, 15, 147, 0, 148, 16, + 147, 0, 148, 0, 149, 113, 148, 0, 149, 0, + 150, 123, 149, 0, 150, 0, 151, 124, 150, 0, + 151, 0, 152, 17, 151, 0, 152, 0, 153, 18, + 152, 0, 153, 0, 153, 125, 153, 126, 154, 0, + 154, 0, 141, 156, 155, 0, 127, 0, 19, 0, + 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, + 25, 0, 26, 0, 27, 0, 28, 0, 155, 0, + 157, 112, 155, 0, 154, 0, 160, 128, 0, 160, + 161, 128, 0, 163, 0, 163, 160, 0, 165, 0, + 165, 160, 0, 162, 0, 161, 112, 162, 0, 180, + 0, 180, 127, 196, 0, 29, 0, 30, 0, 31, + 0, 32, 0, 33, 0, 35, 5, 0, 166, 0, + 166, 37, 5, 0, 47, 0, 48, 0, 49, 0, + 50, 0, 51, 0, 52, 0, 57, 0, 55, 0, + 56, 0, 53, 0, 41, 0, 34, 0, 42, 0, + 43, 0, 44, 0, 58, 0, 168, 0, 176, 0, + 4, 0, 167, 0, 38, 0, 36, 0, 169, 170, + 129, 172, 130, 0, 169, 171, 0, 59, 0, 60, + 0, 171, 0, 0, 217, 0, 173, 0, 172, 173, + 0, 187, 174, 128, 0, 175, 0, 174, 112, 175, + 0, 180, 0, 126, 158, 0, 180, 126, 158, 0, + 61, 129, 177, 130, 0, 61, 217, 129, 177, 130, + 0, 61, 217, 0, 178, 0, 177, 112, 178, 0, + 217, 179, 0, 127, 158, 0, 0, 181, 0, 184, + 181, 0, 182, 0, 182, 134, 0, 217, 0, 107, + 180, 108, 0, 182, 109, 110, 0, 182, 109, 158, + 110, 0, 182, 107, 108, 0, 0, 182, 107, 183, + 190, 108, 0, 182, 107, 188, 108, 0, 185, 0, + 185, 187, 0, 185, 184, 0, 185, 187, 184, 0, + 186, 114, 0, 65, 0, 66, 0, 69, 0, 70, + 0, 68, 0, 67, 0, 0, 165, 0, 187, 165, + 0, 189, 0, 189, 112, 62, 0, 217, 0, 189, + 112, 217, 0, 191, 0, 191, 112, 45, 0, 192, + 0, 191, 112, 192, 0, 187, 180, 0, 193, 0, + 187, 0, 187, 194, 0, 184, 0, 195, 0, 184, + 195, 0, 107, 194, 108, 0, 109, 110, 0, 109, + 158, 110, 0, 195, 109, 110, 0, 195, 109, 158, + 110, 0, 107, 108, 0, 107, 190, 108, 0, 195, + 107, 108, 0, 195, 107, 190, 108, 0, 155, 0, + 129, 197, 130, 0, 129, 197, 112, 130, 0, 196, + 0, 197, 112, 196, 0, 199, 0, 202, 0, 207, + 0, 209, 0, 214, 0, 216, 0, 83, 128, 0, + 217, 126, 198, 0, 71, 158, 126, 198, 0, 72, + 126, 198, 0, 129, 0, 130, 0, 200, 201, 0, + 200, 206, 201, 0, 0, 200, 205, 203, 201, 0, + 0, 200, 205, 204, 206, 201, 0, 1, 128, 0, + 159, 0, 205, 159, 0, 198, 0, 206, 198, 0, + 128, 0, 157, 128, 0, 74, 198, 0, 0, 73, + 107, 157, 108, 198, 208, 0, 0, 75, 107, 157, + 108, 210, 198, 0, 76, 0, 77, 0, 78, 0, + 211, 107, 157, 108, 198, 0, 212, 198, 76, 107, + 157, 108, 128, 0, 213, 107, 215, 128, 215, 128, + 215, 108, 198, 0, 0, 157, 0, 79, 217, 128, + 0, 80, 128, 0, 81, 128, 0, 82, 128, 0, + 82, 157, 128, 0, 3, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 120, 121, 125, 126, 134, 139, 148, 149, 153, 159, + 163, 167, 177, 178, 186, 187, 188, 189, 193, 197, + 198, 199, 201, 205, 212, 218, 220, 225, 226, 230, + 231, 232, 233, 234, 235, 239, 240, 241, 242, 243, + 244, 248, 249, 253, 254, 255, 256, 260, 261, 262, + 266, 267, 268, 272, 273, 274, 275, 284, 296, 297, + 298, 311, 312, 316, 317, 321, 322, 326, 327, 332, + 333, 338, 339, 347, 348, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 399, 400, 404, 405, 409, 413, + 414, 431, 432, 445, 446, 462, 463, 467, 468, 473, + 478, 483, 488, 493, 501, 505, 506, 516, 521, 527, + 532, 538, 543, 548, 553, 559, 564, 569, 574, 579, + 584, 589, 594, 603, 604, 608, 617, 621, 627, 637, + 652, 662, 663, 667, 668, 676, 687, 688, 700, 720, + 721, 729, 730, 734, 741, 746, 762, 779, 780, 787, + 799, 805, 818, 819, 827, 828, 832, 833, 834, 843, + 859, 860, 860, 873, 884, 885, 890, 895, 927, 938, + 939, 940, 941, 942, 943, 944, 948, 949, 953, 954, + 958, 959, 967, 968, 972, 973, 981, 990, 998, 999, + 1011, 1012, 1013, 1017, 1018, 1023, 1029, 1035, 1043, 1044, + 1045, 1046, 1050, 1051, 1052, 1056, 1057, 1061, 1062, 1063, + 1064, 1065, 1066, 1067, 1076, 1077, 1078, 1081, 1084, 1088, + 1089, 1090, 1092, 1093, 1096, 1097, 1101, 1112, 1136, 1137, + 1141, 1142, 1146, 1147, 1152, 1153, 1168, 1176, 1189, 1202, + 1220, 1228, 1236, 1264, 1265, 1269, 1274, 1287, 1297, 1298, + 1302 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","IDENTIFIER", +"TYPE_NAME","CONSTANT","STRING_LITERAL","SIZEOF","PTR_OP","INC_OP","DEC_OP", +"LEFT_OP","RIGHT_OP","LE_OP","GE_OP","EQ_OP","NE_OP","AND_OP","OR_OP","MUL_ASSIGN", +"DIV_ASSIGN","MOD_ASSIGN","ADD_ASSIGN","SUB_ASSIGN","LEFT_ASSIGN","RIGHT_ASSIGN", +"AND_ASSIGN","XOR_ASSIGN","OR_ASSIGN","TYPEDEF","EXTERN","STATIC","AUTO","REGISTER", +"CODE","INTERRUPT","SFR","AT","SBIT","REENTRANT","USING","XDATA","DATA","IDATA", +"PDATA","VAR_ARGS","CRITICAL","CHAR","SHORT","INT","LONG","SIGNED","UNSIGNED", +"FLOAT","DOUBLE","CONST","VOLATILE","VOID","BIT","STRUCT","UNION","ENUM","ELIPSIS", +"RANGE","FAR","_XDATA","_CODE","_GENERIC","_NEAR","_PDATA","_IDATA","CASE","DEFAULT", +"IF","ELSE","SWITCH","WHILE","DO","FOR","GOTO","CONTINUE","BREAK","RETURN","INLINEASM", +"IFX","ADDRESS_OF","GET_VALUE_AT_ADDRESS","SPIL","UNSPIL","GETHBIT","BITWISEAND", +"UNARYMINUS","IPUSH","IPOP","PCALL","ENDFUNCTION","JUMPTABLE","RRC","RLC","CAST", +"CALL","PARAM","NULLOP","BLOCK","LABEL","RECEIVE","SEND","'('","')'","'['","']'", +"'.'","','","'&'","'*'","'+'","'-'","'~'","'!'","'/'","'%'","'<'","'>'","'^'", +"'|'","'?'","':'","'='","';'","'{'","'}'","file","external_definition","function_definition", +"using_reentrant","using_reentrant_interrupt","function_body","primary_expr", +"string_literal","postfix_expr","argument_expr_list","unary_expr","unary_operator", +"cast_expr","multiplicative_expr","additive_expr","shift_expr","relational_expr", +"equality_expr","and_expr","exclusive_or_expr","inclusive_or_expr","logical_and_expr", +"logical_or_expr","conditional_expr","assignment_expr","assignment_operator", +"expr","constant_expr","declaration","declaration_specifiers","init_declarator_list", +"init_declarator","storage_class_specifier","Interrupt_storage","type_specifier", +"type_specifier2","sfr_reg_bit","struct_or_union_specifier","struct_or_union", +"opt_stag","stag","struct_declaration_list","struct_declaration","struct_declarator_list", +"struct_declarator","enum_specifier","enumerator_list","enumerator","opt_assign_expr", +"declarator","declarator2_using_reentrant","declarator2","@1","pointer","far_near_pointer", +"far_near","type_specifier_list","parameter_identifier_list","identifier_list", +"parameter_type_list","parameter_list","parameter_declaration","type_name","abstract_declarator", +"abstract_declarator2","initializer","initializer_list","statement","labeled_statement", +"start_block","end_block","compound_statement","@2","@3","declaration_list", +"statement_list","expression_statement","else_statement","selection_statement", +"@4","while","do","for","iteration_statement","expr_opt","jump_statement","identifier", NULL +}; +#endif + +static const short yyr1[] = { 0, + 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, + 135, 135, 136, 136, 137, 137, 137, 137, 138, 139, + 139, 139, 139, 139, 139, 139, 139, 140, 140, 141, + 141, 141, 141, 141, 141, 142, 142, 142, 142, 142, + 142, 143, 143, 144, 144, 144, 144, 145, 145, 145, + 146, 146, 146, 147, 147, 147, 147, 147, 148, 148, + 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, + 153, 154, 154, 155, 155, 156, 156, 156, 156, 156, + 156, 156, 156, 156, 156, 156, 157, 157, 158, 159, + 159, 160, 160, 160, 160, 161, 161, 162, 162, 163, + 163, 163, 163, 163, 164, 165, 165, 166, 166, 166, + 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, + 166, 166, 166, 166, 166, 166, 166, 167, 167, 168, + 168, 169, 169, 170, 170, 171, 172, 172, 173, 174, + 174, 175, 175, 175, 176, 176, 176, 177, 177, 178, + 179, 179, 180, 180, 181, 181, 182, 182, 182, 182, + 182, 183, 182, 182, 184, 184, 184, 184, 185, 186, + 186, 186, 186, 186, 186, 186, 187, 187, 188, 188, + 189, 189, 190, 190, 191, 191, 192, 192, 193, 193, + 194, 194, 194, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 196, 196, 196, 197, 197, 198, 198, 198, + 198, 198, 198, 198, 199, 199, 199, 200, 201, 202, + 202, 203, 202, 204, 202, 202, 205, 205, 206, 206, + 207, 207, 208, 208, 209, 210, 209, 211, 212, 213, + 214, 214, 214, 215, 215, 216, 216, 216, 216, 216, + 217 +}; + +static const short yyr2[] = { 0, + 1, 2, 1, 1, 2, 3, 1, 2, 2, 1, + 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, + 4, 3, 4, 3, 3, 2, 2, 1, 3, 1, + 2, 2, 2, 2, 4, 1, 1, 1, 1, 1, + 1, 1, 4, 1, 3, 3, 3, 1, 3, 3, + 1, 3, 3, 1, 3, 3, 3, 3, 1, 3, + 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, + 3, 1, 5, 1, 3, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, + 3, 1, 2, 1, 2, 1, 3, 1, 3, 1, + 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, + 2, 1, 1, 1, 0, 1, 1, 2, 3, 1, + 3, 1, 2, 3, 4, 5, 2, 1, 3, 2, + 2, 0, 1, 2, 1, 2, 1, 3, 3, 4, + 3, 0, 5, 4, 1, 2, 2, 3, 2, 1, + 1, 1, 1, 1, 1, 0, 1, 2, 1, 3, + 1, 3, 1, 3, 1, 3, 2, 1, 1, 2, + 1, 1, 2, 3, 2, 3, 3, 4, 2, 3, + 3, 4, 1, 3, 4, 1, 3, 1, 1, 1, + 1, 1, 1, 2, 3, 4, 3, 1, 1, 2, + 3, 0, 4, 0, 5, 2, 1, 2, 1, 2, + 1, 2, 2, 0, 6, 0, 6, 1, 1, 1, + 5, 7, 9, 0, 1, 3, 2, 2, 2, 3, + 1 +}; + +static const short yydefact[] = { 176, + 251, 126, 100, 101, 102, 103, 104, 119, 129, 128, + 118, 120, 121, 122, 108, 109, 110, 111, 112, 113, + 117, 115, 116, 114, 123, 132, 133, 0, 170, 171, + 175, 174, 172, 173, 176, 176, 1, 3, 4, 176, + 92, 94, 106, 127, 124, 135, 125, 0, 153, 155, + 0, 165, 0, 157, 0, 147, 0, 2, 90, 0, + 96, 0, 93, 95, 0, 0, 131, 136, 0, 218, + 5, 227, 176, 0, 13, 0, 0, 10, 0, 11, + 162, 0, 156, 7, 12, 154, 177, 167, 166, 169, + 0, 148, 152, 0, 158, 176, 91, 0, 6, 107, + 0, 226, 98, 16, 19, 0, 0, 0, 0, 0, + 0, 0, 238, 239, 240, 0, 0, 0, 0, 0, + 0, 36, 37, 38, 39, 40, 41, 231, 219, 20, + 17, 30, 42, 0, 44, 48, 51, 54, 59, 62, + 64, 66, 68, 70, 72, 74, 87, 0, 229, 208, + 220, 209, 224, 0, 210, 211, 0, 0, 0, 212, + 213, 15, 228, 14, 105, 9, 161, 0, 0, 179, + 181, 159, 42, 89, 0, 15, 8, 178, 168, 0, + 145, 0, 150, 0, 97, 0, 203, 99, 0, 137, + 176, 0, 34, 0, 31, 32, 0, 0, 0, 0, + 0, 247, 248, 249, 0, 214, 0, 176, 0, 0, + 26, 27, 0, 0, 0, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 76, 0, 33, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 232, 0, + 0, 230, 221, 0, 0, 244, 0, 189, 0, 183, + 185, 188, 164, 0, 160, 149, 151, 146, 206, 0, + 130, 138, 0, 0, 140, 142, 0, 0, 217, 0, + 0, 246, 250, 18, 176, 0, 191, 190, 192, 0, + 25, 22, 0, 28, 0, 24, 75, 45, 46, 47, + 49, 50, 52, 53, 57, 58, 55, 56, 60, 61, + 63, 65, 67, 69, 71, 0, 88, 223, 0, 0, + 0, 245, 0, 215, 176, 187, 191, 163, 0, 180, + 182, 0, 204, 143, 176, 139, 0, 35, 216, 0, + 236, 199, 0, 0, 195, 0, 193, 0, 0, 43, + 23, 0, 21, 0, 225, 0, 0, 244, 184, 186, + 205, 207, 141, 144, 234, 0, 200, 194, 196, 201, + 0, 197, 0, 29, 73, 241, 0, 0, 0, 235, + 237, 202, 198, 0, 244, 233, 242, 0, 0, 243, + 0, 0 +}; + +static const short yydefgoto[] = { 36, + 37, 38, 83, 84, 71, 130, 131, 132, 293, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 227, 148, 175, 72, 73, 60, + 61, 41, 85, 87, 43, 44, 45, 46, 66, 67, + 189, 190, 274, 275, 47, 91, 92, 183, 48, 49, + 50, 168, 51, 52, 53, 258, 169, 170, 343, 260, + 261, 262, 288, 289, 188, 270, 149, 150, 74, 151, + 152, 250, 251, 76, 154, 155, 380, 156, 366, 157, + 158, 159, 160, 323, 161, 176 +}; + +static const short yypact[] = { 1568, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768, 11,-32768,-32768, +-32768,-32768,-32768,-32768, 317, 1267,-32768,-32768,-32768, 53, + 1610, 1610, -7,-32768,-32768, 19,-32768, 634,-32768, 165, + 30, 1193, -26,-32768, 19, 21, 45,-32768,-32768, -33, +-32768, 598,-32768,-32768, 173, 55, 58,-32768, 62,-32768, +-32768,-32768, 53, 412,-32768, 634, 189,-32768, 191,-32768, + 24, 906,-32768, 126,-32768,-32768,-32768,-32768, 1193,-32768, + -93,-32768, 70, 19,-32768, 317,-32768, 430,-32768,-32768, + 1452,-32768, 72,-32768,-32768, 987, 1022, 1022, 1034, 76, + 100, 102,-32768,-32768,-32768, 19, 84, 92, 776, 93, + 892,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 40, 348, 1034,-32768, -44, -15, 46, 12, 129, + 110, 105, 101, 212, 16,-32768,-32768, -25,-32768,-32768, +-32768,-32768, 699, 496,-32768,-32768, 123, 695, 125,-32768, +-32768, 108,-32768,-32768,-32768,-32768,-32768, 1452, 136, 134, +-32768,-32768,-32768,-32768, 137,-32768,-32768,-32768,-32768, 19, +-32768, 1034,-32768, -69,-32768, 430,-32768,-32768, 784,-32768, + 812, 892,-32768, 1034,-32768,-32768, 122, 695, 1034, 1034, + 124,-32768,-32768,-32768, 27,-32768, 2, 1411, 145, 19, +-32768,-32768, 951, 1034, 19,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768, 1034,-32768, 1034, 1034, + 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, + 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034,-32768, 130, + 695,-32768,-32768, 1034, 178, 1034, 695, 1119, 147, 149, +-32768,-32768,-32768, 18,-32768,-32768,-32768,-32768,-32768, -58, +-32768,-32768, 1034, 31,-32768, 139, 154, 695,-32768, 63, + 65,-32768,-32768,-32768, 1487, 963, -62,-32768, 4, 1034, +-32768,-32768, 158, 163, 52,-32768,-32768,-32768,-32768,-32768, + -44, -44, -15, -15, 46, 46, 46, 46, 12, 12, + 129, 110, 105, 101, 212, -2,-32768,-32768, 496, 71, + 166, 170, 155,-32768, 1335,-32768, 29,-32768, 1376,-32768, +-32768, 232,-32768,-32768, 60,-32768, 1034,-32768,-32768, 695, +-32768,-32768, 177, 179,-32768, 176, 4, 1160, 975,-32768, +-32768, 1034,-32768, 1034,-32768, 695, 1034, 1034,-32768,-32768, +-32768,-32768,-32768,-32768, 214, 695,-32768,-32768,-32768,-32768, + 181,-32768, 180,-32768,-32768,-32768, 77, 164, 695,-32768, +-32768,-32768,-32768, 168, 1034,-32768,-32768, 185, 695,-32768, + 294,-32768 +}; + +static const short yypgoto[] = {-32768, + 261,-32768, 215,-32768, 236,-32768,-32768,-32768, -50, 161, +-32768, -122, -165, -42, -20, -14, 61, 64, 67, 59, + 66, 68, -78, -96,-32768, -108, -104, 17, 41,-32768, + 209,-32768,-32768, 23,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 117,-32768, -27,-32768, 219, 138,-32768, -34, -48, +-32768,-32768, -45,-32768,-32768, 14,-32768,-32768, -160,-32768, + -13, -103, -265, -258, -176,-32768, -56,-32768,-32768, -145, + -24,-32768,-32768, 235, 73,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768, -343,-32768, 0 +}; + + +#define YYLAST 1675 + + +static const short yytable[] = { 54, + 57, 187, 86, 174, 197, 62, 88, 259, 253, 269, + 205, 228, 207, 1, 378, 246, 39, 209, 180, 344, + 1, 1, 42, 75, 236, 237, 1, 56, 347, 65, + 174, 1, 1, 246, 54, 54, 181, 75, 103, 54, + 40, 388, 180, 179, 285, 68, 286, 210, 211, 212, + 54, 164, 39, 332, 93, 1, 234, 235, 42, 344, + 268, 103, 1, 42, 42, 89, 301, 302, 347, 229, + 42, 333, 54, 162, 230, 231, 40, 267, 96, 330, + 171, 63, 64, 207, 42, 207, 248, 90, 277, 187, + 280, 281, 163, 93, 97, 54, 42, 252, 42, 232, + 233, 255, 249, 174, 318, 295, 298, 299, 300, 284, + 348, 178, 349, 248, 191, 201, 294, 29, 30, 31, + 32, 33, 34, 354, 29, 30, 31, 32, 33, 34, + 297, 167, 238, 239, 208, 325, 35, 286, 248, 55, + 247, 279, 335, 240, 241, 320, 213, 322, 214, 94, + 215, 317, 95, 162, 283, 362, 276, 162, 336, 35, + 77, 353, 287, 248, 78, 79, 35, 350, 334, 163, + 340, 80, 341, 355, 248, 42, 248, 100, 356, 93, + 59, 346, 248, 101, 384, 273, -134, 371, 248, 102, + 54, 303, 304, 165, 174, 166, 182, 162, 98, 77, + 324, 198, 191, 78, 79, 208, 199, 174, 200, 291, + 80, 202, 327, 178, 296, 305, 306, 307, 308, 203, + 206, 339, 242, 326, 244, 309, 310, 243, 245, 254, + 178, 256, 364, 257, 1, 187, 104, 105, 106, 287, + 107, 108, 173, 263, 373, 264, 265, 278, 377, 322, + 162, 282, 290, 321, 328, 294, 162, 54, 174, 129, + 329, 338, 252, 331, 337, 351, 193, 195, 196, 173, + 174, 81, 357, 82, 352, 375, 322, 162, 86, 327, + 178, 248, 358, 365, 367, 369, 368, 379, 382, 383, + 57, 385, 389, 392, 173, 387, 58, 99, 177, 376, + 276, 374, 311, 314, 185, 272, 312, 363, 153, 381, + 313, 315, 184, 0, 316, 360, 0, 266, 162, 1, + 0, 0, 386, 319, 54, 0, 54, 0, 0, 0, + 0, 0, 390, 0, 54, 0, 0, 0, 121, 162, + 0, 0, 173, 0, 122, 123, 124, 125, 126, 127, + 0, 0, 0, 0, 0, 162, 0, 0, 0, 0, + 186, 361, 0, 0, 0, 162, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 0, 0, 162, 0, + 0, 29, 30, 31, 32, 33, 34, 0, 162, 173, + 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, + 173, 173, 173, 173, 173, 173, 173, 173, 0, 0, + 0, 0, 69, 0, 1, 2, 104, 105, 106, 0, + 107, 108, 0, 35, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 173, 104, 105, 106, 0, 107, 108, + 3, 4, 5, 6, 7, 8, 173, 9, 0, 10, + 173, 0, 11, 12, 13, 14, 0, 0, 15, 16, + 17, 18, 19, 20, 21, 0, 22, 23, 24, 25, + 26, 27, 28, 0, 226, 0, 0, 0, 0, 0, + 0, 0, 109, 110, 111, 0, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 0, 69, 173, 1, 0, + 104, 105, 106, 0, 107, 108, 0, 0, 0, 173, + 0, 0, 0, 0, 173, 0, 0, 0, 121, 0, + 0, 0, 0, 0, 122, 123, 124, 125, 126, 127, + 0, 0, 0, 0, 0, 0, 121, 0, 0, 128, + 70, 129, 122, 123, 124, 125, 126, 127, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 186, 0, + 0, 0, 0, 0, 0, 0, 109, 110, 111, 0, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, + 0, 2, 121, 0, 0, 0, 0, 0, 122, 123, + 124, 125, 126, 127, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 128, 70, 129, 3, 4, 5, 6, + 7, 8, 0, 9, 69, 10, 0, 2, 11, 12, + 13, 14, 0, 0, 15, 16, 17, 18, 19, 20, + 21, 0, 22, 23, 24, 25, 26, 27, 28, 0, + 0, 0, 3, 4, 5, 6, 7, 8, 0, 9, + 0, 10, 0, 0, 11, 12, 13, 14, 0, 0, + 15, 16, 17, 18, 19, 20, 21, 0, 22, 23, + 24, 25, 26, 27, 28, 69, 0, 1, 0, 104, + 105, 106, 2, 107, 108, 0, 0, 0, 0, -98, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 98, -98, 70, 3, 4, 5, + 6, 7, 8, 0, 9, 0, 10, 0, 0, 11, + 12, 13, 14, 0, 0, 15, 16, 17, 18, 19, + 20, 21, 0, 22, 23, 24, 25, 26, 27, 28, + 0, 0, 70, 0, 0, 109, 110, 111, 0, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 1, 0, + 104, 105, 106, 0, 107, 108, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 121, 0, 0, 0, 0, 0, 122, 123, 124, + 125, 126, 127, 0, 1, 2, 0, 8, 0, 9, + 0, 10, 128, 70, 11, 12, 13, 14, -222, 0, + 15, 16, 17, 18, 19, 20, 21, 0, 22, 23, + 24, 25, 26, 27, 28, 8, 0, 9, 0, 10, + 0, 0, 11, 12, 13, 14, 0, 0, 15, 16, + 17, 18, 19, 20, 21, 0, 22, 23, 24, 25, + 26, 27, 28, 0, 0, 0, 29, 30, 31, 32, + 33, 34, 121, 0, 0, 0, 0, 0, 122, 123, + 124, 125, 126, 127, 1, 2, 104, 105, 106, 0, + 107, 108, 0, 204, 0, 0, 0, 0, 1, 0, + 104, 105, 106, 271, 107, 108, 0, 0, 35, 0, + 0, 0, 0, 0, 0, 8, 0, 9, 0, 10, + 0, 0, 11, 12, 13, 14, 0, 273, 15, 16, + 17, 18, 19, 20, 21, 0, 22, 23, 24, 25, + 26, 27, 28, 1, 0, 104, 105, 106, 0, 107, + 108, 0, 0, 0, 0, 1, 0, 104, 105, 106, + 0, 107, 108, 0, 0, 0, 0, 1, 0, 104, + 105, 106, 0, 107, 108, 0, 0, 0, 0, 1, + 0, 104, 105, 106, 0, 107, 108, 0, 121, 0, + 0, 0, 0, 0, 122, 123, 124, 125, 126, 127, + 0, 0, 121, 0, 0, 172, 0, 0, 122, 123, + 124, 125, 126, 127, 1, 0, 104, 105, 106, 0, + 107, 108, 0, 0, 0, 0, 1, 0, 104, 105, + 106, 0, 107, 108, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 121, 292, 0, + 0, 0, 0, 122, 123, 124, 125, 126, 127, 121, + 0, 0, 345, 0, 0, 122, 123, 124, 125, 126, + 127, 121, 0, 0, 372, 0, 0, 122, 123, 124, + 125, 126, 127, 192, 0, 0, 0, 0, 0, 122, + 123, 124, 125, 126, 127, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 2, 0, 0, 0, 0, 0, 194, 0, + 0, 0, 0, 0, 122, 123, 124, 125, 126, 127, + 121, 0, 0, 0, 0, 0, 122, 123, 124, 125, + 126, 127, 8, 0, 9, 0, 10, 0, 0, 11, + 12, 13, 14, 2, 0, 15, 16, 17, 18, 19, + 20, 21, 0, 22, 23, 24, 25, 26, 27, 28, + 0, 0, 0, 29, 30, 31, 32, 33, 34, 0, + 0, 0, 0, 8, 0, 9, 2, 10, 0, 0, + 11, 12, 13, 14, 0, 0, 15, 16, 17, 18, + 19, 20, 21, 0, 22, 23, 24, 25, 26, 27, + 28, 0, 0, 0, 0, 325, 8, 286, 9, 0, + 10, 0, -176, 11, 12, 13, 14, 0, 0, 15, + 16, 17, 18, 19, 20, 21, 0, 22, 23, 24, + 25, 26, 27, 28, 0, 0, 0, 29, 30, 31, + 32, 33, 34, 0, 0, 0, 391, 370, 0, 1, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3, 4, 5, 6, 7, + 8, 0, 9, 0, 10, 0, -176, 11, 12, 13, + 14, 0, 0, 15, 16, 17, 18, 19, 20, 21, + 0, 22, 23, 24, 25, 26, 27, 28, 0, 0, + 0, 29, 30, 31, 32, 33, 34, 1, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, + 9, 0, 10, 35, 0, 11, 12, 13, 14, 2, + 0, 15, 16, 17, 18, 19, 20, 21, 0, 22, + 23, 24, 25, 26, 27, 28, 0, 0, 0, 29, + 30, 31, 32, 33, 34, 0, 0, 0, 0, 8, + 0, 9, 0, 10, 2, 0, 11, 12, 13, 14, + 359, 0, 15, 16, 17, 18, 19, 20, 21, 0, + 22, 23, 24, 25, 26, 27, 28, 0, 0, 0, + 0, 325, 342, 286, 8, 0, 9, 0, 10, 0, + 0, 11, 12, 13, 14, 2, 0, 15, 16, 17, + 18, 19, 20, 21, 0, 22, 23, 24, 25, 26, + 27, 28, 0, 0, 0, 29, 30, 31, 32, 33, + 34, 0, 0, 0, 0, 8, 0, 9, 0, 10, + 2, 0, 11, 12, 13, 14, 0, 0, 15, 16, + 17, 18, 19, 20, 21, 0, 22, 23, 24, 25, + 26, 27, 28, 0, 0, 0, 0, 285, -189, 286, + 8, 0, 9, 0, 10, 0, 0, 11, 12, 13, + 14, 0, 0, 15, 16, 17, 18, 19, 20, 21, + 0, 22, 23, 24, 25, 26, 27, 28, 0, 0, + 0, 29, 30, 31, 32, 33, 34, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 285, 342, 286, 3, 4, 5, 6, + 7, 8, 0, 9, 0, 10, 0, 0, 11, 12, + 13, 14, 0, 2, 15, 16, 17, 18, 19, 20, + 21, 0, 22, 23, 24, 25, 26, 27, 28, 0, + 0, 0, 29, 30, 31, 32, 33, 34, 3, 4, + 5, 6, 7, 8, 0, 9, 0, 10, 0, 0, + 11, 12, 13, 14, 0, 0, 15, 16, 17, 18, + 19, 20, 21, 0, 22, 23, 24, 25, 26, 27, + 28, 0, 0, 0, 35 +}; + +static const short yycheck[] = { 0, + 35, 98, 51, 82, 109, 40, 52, 168, 154, 186, + 119, 134, 121, 3, 358, 18, 0, 121, 112, 285, + 3, 3, 0, 48, 13, 14, 3, 28, 287, 37, + 109, 3, 3, 18, 35, 36, 130, 62, 73, 40, + 0, 385, 112, 89, 107, 46, 109, 8, 9, 10, + 51, 76, 36, 112, 55, 3, 11, 12, 36, 325, + 130, 96, 3, 41, 42, 52, 232, 233, 327, 114, + 48, 130, 73, 74, 119, 120, 36, 182, 112, 62, + 81, 41, 42, 192, 62, 194, 112, 114, 192, 186, + 199, 200, 76, 94, 128, 96, 74, 154, 76, 115, + 116, 158, 128, 182, 250, 214, 229, 230, 231, 108, + 107, 89, 109, 112, 101, 116, 213, 65, 66, 67, + 68, 69, 70, 126, 65, 66, 67, 68, 69, 70, + 227, 108, 121, 122, 121, 107, 107, 109, 112, 129, + 125, 198, 112, 15, 16, 254, 107, 256, 109, 129, + 111, 248, 108, 154, 128, 332, 191, 158, 128, 107, + 35, 110, 208, 112, 39, 40, 107, 290, 273, 153, + 108, 46, 108, 319, 112, 153, 112, 5, 108, 180, + 128, 286, 112, 129, 108, 126, 129, 348, 112, 128, + 191, 234, 235, 5, 273, 5, 127, 198, 127, 35, + 257, 126, 189, 39, 40, 192, 107, 286, 107, 210, + 46, 128, 258, 191, 215, 236, 237, 238, 239, 128, + 128, 278, 113, 258, 124, 240, 241, 123, 17, 107, + 208, 107, 337, 126, 3, 332, 5, 6, 7, 285, + 9, 10, 82, 108, 349, 112, 110, 126, 357, 358, + 251, 128, 108, 76, 108, 352, 257, 258, 337, 130, + 112, 108, 319, 264, 126, 108, 106, 107, 108, 109, + 349, 107, 107, 109, 112, 354, 385, 278, 327, 325, + 258, 112, 128, 340, 108, 110, 108, 74, 108, 110, + 325, 128, 108, 0, 134, 128, 36, 62, 84, 356, + 335, 352, 242, 245, 96, 189, 243, 335, 74, 366, + 244, 246, 94, -1, 247, 329, -1, 180, 319, 3, + -1, -1, 379, 251, 325, -1, 327, -1, -1, -1, + -1, -1, 389, -1, 335, -1, -1, -1, 107, 340, + -1, -1, 182, -1, 113, 114, 115, 116, 117, 118, + -1, -1, -1, -1, -1, 356, -1, -1, -1, -1, + 129, 130, -1, -1, -1, 366, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, -1, -1, 379, -1, + -1, 65, 66, 67, 68, 69, 70, -1, 389, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, -1, -1, + -1, -1, 1, -1, 3, 4, 5, 6, 7, -1, + 9, 10, -1, 107, -1, -1, -1, -1, -1, -1, + -1, -1, 3, 273, 5, 6, 7, -1, 9, 10, + 29, 30, 31, 32, 33, 34, 286, 36, -1, 38, + 290, -1, 41, 42, 43, 44, -1, -1, 47, 48, + 49, 50, 51, 52, 53, -1, 55, 56, 57, 58, + 59, 60, 61, -1, 127, -1, -1, -1, -1, -1, + -1, -1, 71, 72, 73, -1, 75, 76, 77, 78, + 79, 80, 81, 82, 83, -1, 1, 337, 3, -1, + 5, 6, 7, -1, 9, 10, -1, -1, -1, 349, + -1, -1, -1, -1, 354, -1, -1, -1, 107, -1, + -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, + -1, -1, -1, -1, -1, -1, 107, -1, -1, 128, + 129, 130, 113, 114, 115, 116, 117, 118, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 129, -1, + -1, -1, -1, -1, -1, -1, 71, 72, 73, -1, + 75, 76, 77, 78, 79, 80, 81, 82, 83, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, + -1, 4, 107, -1, -1, -1, -1, -1, 113, 114, + 115, 116, 117, 118, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 128, 129, 130, 29, 30, 31, 32, + 33, 34, -1, 36, 1, 38, -1, 4, 41, 42, + 43, 44, -1, -1, 47, 48, 49, 50, 51, 52, + 53, -1, 55, 56, 57, 58, 59, 60, 61, -1, + -1, -1, 29, 30, 31, 32, 33, 34, -1, 36, + -1, 38, -1, -1, 41, 42, 43, 44, -1, -1, + 47, 48, 49, 50, 51, 52, 53, -1, 55, 56, + 57, 58, 59, 60, 61, 1, -1, 3, -1, 5, + 6, 7, 4, 9, 10, -1, -1, -1, -1, 112, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 127, 128, 129, 29, 30, 31, + 32, 33, 34, -1, 36, -1, 38, -1, -1, 41, + 42, 43, 44, -1, -1, 47, 48, 49, 50, 51, + 52, 53, -1, 55, 56, 57, 58, 59, 60, 61, + -1, -1, 129, -1, -1, 71, 72, 73, -1, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 3, -1, + 5, 6, 7, -1, 9, 10, -1, 4, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 107, -1, -1, -1, -1, -1, 113, 114, 115, + 116, 117, 118, -1, 3, 4, -1, 34, -1, 36, + -1, 38, 128, 129, 41, 42, 43, 44, 130, -1, + 47, 48, 49, 50, 51, 52, 53, -1, 55, 56, + 57, 58, 59, 60, 61, 34, -1, 36, -1, 38, + -1, -1, 41, 42, 43, 44, -1, -1, 47, 48, + 49, 50, 51, 52, 53, -1, 55, 56, 57, 58, + 59, 60, 61, -1, -1, -1, 65, 66, 67, 68, + 69, 70, 107, -1, -1, -1, -1, -1, 113, 114, + 115, 116, 117, 118, 3, 4, 5, 6, 7, -1, + 9, 10, -1, 128, -1, -1, -1, -1, 3, -1, + 5, 6, 7, 130, 9, 10, -1, -1, 107, -1, + -1, -1, -1, -1, -1, 34, -1, 36, -1, 38, + -1, -1, 41, 42, 43, 44, -1, 126, 47, 48, + 49, 50, 51, 52, 53, -1, 55, 56, 57, 58, + 59, 60, 61, 3, -1, 5, 6, 7, -1, 9, + 10, -1, -1, -1, -1, 3, -1, 5, 6, 7, + -1, 9, 10, -1, -1, -1, -1, 3, -1, 5, + 6, 7, -1, 9, 10, -1, -1, -1, -1, 3, + -1, 5, 6, 7, -1, 9, 10, -1, 107, -1, + -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, + -1, -1, 107, -1, -1, 110, -1, -1, 113, 114, + 115, 116, 117, 118, 3, -1, 5, 6, 7, -1, + 9, 10, -1, -1, -1, -1, 3, -1, 5, 6, + 7, -1, 9, 10, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 107, 108, -1, + -1, -1, -1, 113, 114, 115, 116, 117, 118, 107, + -1, -1, 110, -1, -1, 113, 114, 115, 116, 117, + 118, 107, -1, -1, 110, -1, -1, 113, 114, 115, + 116, 117, 118, 107, -1, -1, -1, -1, -1, 113, + 114, 115, 116, 117, 118, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 3, 4, -1, -1, -1, -1, -1, 107, -1, + -1, -1, -1, -1, 113, 114, 115, 116, 117, 118, + 107, -1, -1, -1, -1, -1, 113, 114, 115, 116, + 117, 118, 34, -1, 36, -1, 38, -1, -1, 41, + 42, 43, 44, 4, -1, 47, 48, 49, 50, 51, + 52, 53, -1, 55, 56, 57, 58, 59, 60, 61, + -1, -1, -1, 65, 66, 67, 68, 69, 70, -1, + -1, -1, -1, 34, -1, 36, 4, 38, -1, -1, + 41, 42, 43, 44, -1, -1, 47, 48, 49, 50, + 51, 52, 53, -1, 55, 56, 57, 58, 59, 60, + 61, -1, -1, -1, -1, 107, 34, 109, 36, -1, + 38, -1, 114, 41, 42, 43, 44, -1, -1, 47, + 48, 49, 50, 51, 52, 53, -1, 55, 56, 57, + 58, 59, 60, 61, -1, -1, -1, 65, 66, 67, + 68, 69, 70, -1, -1, -1, 0, 108, -1, 3, + 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 29, 30, 31, 32, 33, + 34, -1, 36, -1, 38, -1, 114, 41, 42, 43, + 44, -1, -1, 47, 48, 49, 50, 51, 52, 53, + -1, 55, 56, 57, 58, 59, 60, 61, -1, -1, + -1, 65, 66, 67, 68, 69, 70, 3, 4, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 34, -1, + 36, -1, 38, 107, -1, 41, 42, 43, 44, 4, + -1, 47, 48, 49, 50, 51, 52, 53, -1, 55, + 56, 57, 58, 59, 60, 61, -1, -1, -1, 65, + 66, 67, 68, 69, 70, -1, -1, -1, -1, 34, + -1, 36, -1, 38, 4, -1, 41, 42, 43, 44, + 45, -1, 47, 48, 49, 50, 51, 52, 53, -1, + 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, + -1, 107, 108, 109, 34, -1, 36, -1, 38, -1, + -1, 41, 42, 43, 44, 4, -1, 47, 48, 49, + 50, 51, 52, 53, -1, 55, 56, 57, 58, 59, + 60, 61, -1, -1, -1, 65, 66, 67, 68, 69, + 70, -1, -1, -1, -1, 34, -1, 36, -1, 38, + 4, -1, 41, 42, 43, 44, -1, -1, 47, 48, + 49, 50, 51, 52, 53, -1, 55, 56, 57, 58, + 59, 60, 61, -1, -1, -1, -1, 107, 108, 109, + 34, -1, 36, -1, 38, -1, -1, 41, 42, 43, + 44, -1, -1, 47, 48, 49, 50, 51, 52, 53, + -1, 55, 56, 57, 58, 59, 60, 61, -1, -1, + -1, 65, 66, 67, 68, 69, 70, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 107, 108, 109, 29, 30, 31, 32, + 33, 34, -1, 36, -1, 38, -1, -1, 41, 42, + 43, 44, -1, 4, 47, 48, 49, 50, 51, 52, + 53, -1, 55, 56, 57, 58, 59, 60, 61, -1, + -1, -1, 65, 66, 67, 68, 69, 70, 29, 30, + 31, 32, 33, 34, -1, 36, -1, 38, -1, -1, + 41, 42, 43, 44, -1, -1, 47, 48, 49, 50, + 51, 52, 53, -1, 55, 56, 57, 58, 59, 60, + 61, -1, -1, -1, 107 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/misc/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + 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, 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; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/share/misc/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 3: +#line 125 "SDCC.y" +{ blockNo=0;; + break;} +case 4: +#line 126 "SDCC.y" +{ + addSymChain (yyvsp[0].sym); + allocVariables (yyvsp[0].sym) ; + cleanUpLevel (SymbolTab,1); + ; + break;} +case 5: +#line 134 "SDCC.y" +{ /* function type not specified */ + /* assume it to be 'int' */ + addDecl(yyvsp[-1].sym,0,newIntLink()); + yyval.asts = createFunction(yyvsp[-1].sym,yyvsp[0].asts); + ; + break;} +case 6: +#line 140 "SDCC.y" +{ + pointerTypes(yyvsp[-1].sym->type,copyLinkChain(yyvsp[-2].lnk)); + addDecl(yyvsp[-1].sym,0,yyvsp[-2].lnk); + yyval.asts = createFunction(yyvsp[-1].sym,yyvsp[0].asts); + ; + break;} +case 8: +#line 149 "SDCC.y" +{ yyval.lnk = mergeSpec(yyvsp[-1].lnk,yyvsp[0].lnk); ; + break;} +case 9: +#line 153 "SDCC.y" +{ + yyval.lnk = newLink() ; + yyval.lnk->class = SPECIFIER ; + SPEC_BNKF(yyval.lnk) = 1; + SPEC_BANK(yyval.lnk) = (int) floatFromVal(yyvsp[0].val); + ; + break;} +case 10: +#line 159 "SDCC.y" +{ yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_RENT(yyval.lnk) = 1; + ; + break;} +case 11: +#line 163 "SDCC.y" +{ yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_CRTCL(yyval.lnk) = 1; + ; + break;} +case 12: +#line 168 "SDCC.y" +{ + yyval.lnk = newLink () ; + yyval.lnk->class = SPECIFIER ; + SPEC_INTN(yyval.lnk) = yyvsp[0].yyint ; + SPEC_INTRTN(yyval.lnk) = 1; + ; + break;} +case 14: +#line 179 "SDCC.y" +{ + werror(E_OLD_STYLE,(yyvsp[-1].sym ? yyvsp[-1].sym->name: "")) ; + exit(1); + ; + break;} +case 15: +#line 186 "SDCC.y" +{ yyval.asts = newAst(EX_VALUE,symbolVal(yyvsp[0].sym)); ; + break;} +case 16: +#line 187 "SDCC.y" +{ yyval.asts = newAst(EX_VALUE,yyvsp[0].val); ; + break;} +case 18: +#line 189 "SDCC.y" +{ yyval.asts = yyvsp[-1].asts ; ; + break;} +case 19: +#line 193 "SDCC.y" +{ yyval.asts = newAst(EX_VALUE,yyvsp[0].val); ; + break;} +case 21: +#line 198 "SDCC.y" +{ yyval.asts = newNode ('[', yyvsp[-3].asts, yyvsp[-1].asts) ; ; + break;} +case 22: +#line 199 "SDCC.y" +{ yyval.asts = newNode (CALL,yyvsp[-2].asts,NULL); + yyval.asts->left->funcName = 1;; + break;} +case 23: +#line 202 "SDCC.y" +{ + yyval.asts = newNode (CALL,yyvsp[-3].asts,yyvsp[-1].asts) ; yyval.asts->left->funcName = 1; + ; + break;} +case 24: +#line 206 "SDCC.y" +{ + yyvsp[0].sym = newSymbol(yyvsp[0].sym->name,NestLevel); + yyvsp[0].sym->implicit = 1; + yyval.asts = newNode(PTR_OP,newNode('&',yyvsp[-2].asts,NULL),newAst(EX_VALUE,symbolVal(yyvsp[0].sym))); +/* $$ = newNode('.',$1,newAst(EX_VALUE,symbolVal($3))) ; */ + ; + break;} +case 25: +#line 213 "SDCC.y" +{ + yyvsp[0].sym = newSymbol(yyvsp[0].sym->name,NestLevel); + yyvsp[0].sym->implicit = 1; + yyval.asts = newNode(PTR_OP,yyvsp[-2].asts,newAst(EX_VALUE,symbolVal(yyvsp[0].sym))); + ; + break;} +case 26: +#line 219 "SDCC.y" +{ yyval.asts = newNode(INC_OP,yyvsp[-1].asts,NULL);; + break;} +case 27: +#line 221 "SDCC.y" +{ yyval.asts = newNode(DEC_OP,yyvsp[-1].asts,NULL); ; + break;} +case 29: +#line 226 "SDCC.y" +{ yyval.asts = newNode(PARAM,yyvsp[-2].asts,yyvsp[0].asts); ; + break;} +case 31: +#line 231 "SDCC.y" +{ yyval.asts = newNode(INC_OP,NULL,yyvsp[0].asts); ; + break;} +case 32: +#line 232 "SDCC.y" +{ yyval.asts = newNode(DEC_OP,NULL,yyvsp[0].asts); ; + break;} +case 33: +#line 233 "SDCC.y" +{ yyval.asts = newNode(yyvsp[-1].yyint,yyvsp[0].asts,NULL) ; ; + break;} +case 34: +#line 234 "SDCC.y" +{ yyval.asts = newNode(SIZEOF,NULL,yyvsp[0].asts); ; + break;} +case 35: +#line 235 "SDCC.y" +{ yyval.asts = newAst(EX_VALUE,sizeofOp(yyvsp[-1].lnk)); ; + break;} +case 36: +#line 239 "SDCC.y" +{ yyval.yyint = '&' ;; + break;} +case 37: +#line 240 "SDCC.y" +{ yyval.yyint = '*' ;; + break;} +case 38: +#line 241 "SDCC.y" +{ yyval.yyint = '+' ;; + break;} +case 39: +#line 242 "SDCC.y" +{ yyval.yyint = '-' ;; + break;} +case 40: +#line 243 "SDCC.y" +{ yyval.yyint = '~' ;; + break;} +case 41: +#line 244 "SDCC.y" +{ yyval.yyint = '!' ;; + break;} +case 43: +#line 249 "SDCC.y" +{ yyval.asts = newNode(CAST,newAst(EX_LINK,yyvsp[-2].lnk),yyvsp[0].asts); ; + break;} +case 45: +#line 254 "SDCC.y" +{ yyval.asts = newNode('*',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 46: +#line 255 "SDCC.y" +{ yyval.asts = newNode('/',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 47: +#line 256 "SDCC.y" +{ yyval.asts = newNode('%',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 49: +#line 261 "SDCC.y" +{ yyval.asts=newNode('+',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 50: +#line 262 "SDCC.y" +{ yyval.asts=newNode('-',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 52: +#line 267 "SDCC.y" +{ yyval.asts = newNode(LEFT_OP,yyvsp[-2].asts,yyvsp[0].asts); ; + break;} +case 53: +#line 268 "SDCC.y" +{ yyval.asts = newNode(RIGHT_OP,yyvsp[-2].asts,yyvsp[0].asts); ; + break;} +case 55: +#line 273 "SDCC.y" +{ yyval.asts = newNode('<',yyvsp[-2].asts,yyvsp[0].asts); ; + break;} +case 56: +#line 274 "SDCC.y" +{ yyval.asts = newNode('>',yyvsp[-2].asts,yyvsp[0].asts); ; + break;} +case 57: +#line 275 "SDCC.y" +{ + /* $$ = newNode(LE_OP,$1,$3); */ + /* getting 8051 specific here : will change + LE_OP operation to "not greater than" i.e. + ( a <= b ) === ( ! ( a > b )) */ + yyval.asts = newNode('!', + newNode('>', yyvsp[-2].asts , yyvsp[0].asts ), + NULL); + ; + break;} +case 58: +#line 284 "SDCC.y" +{ + /* $$ = newNode(GE_OP,$1,$3) ; */ + /* getting 8051 specific here : will change + GE_OP operation to "not less than" i.e. + ( a >= b ) === ( ! ( a < b )) */ + yyval.asts = newNode('!', + newNode('<', yyvsp[-2].asts , yyvsp[0].asts ), + NULL); + ; + break;} +case 60: +#line 297 "SDCC.y" +{ yyval.asts = newNode(EQ_OP,yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 61: +#line 299 "SDCC.y" +{ + /* $$ = newNode(NE_OP,$1,$3); */ + /* NE_OP changed : + expr1 != expr2 is equivalent to + (! expr1 == expr2) */ + yyval.asts = newNode('!', + newNode(EQ_OP,yyvsp[-2].asts,yyvsp[0].asts), + NULL); + ; + break;} +case 63: +#line 312 "SDCC.y" +{ yyval.asts = newNode('&',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 65: +#line 317 "SDCC.y" +{ yyval.asts = newNode('^',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 67: +#line 322 "SDCC.y" +{ yyval.asts = newNode('|',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 69: +#line 328 "SDCC.y" +{ yyval.asts = newNode(AND_OP,yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 71: +#line 334 "SDCC.y" +{ yyval.asts = newNode(OR_OP,yyvsp[-2].asts,yyvsp[0].asts); ; + break;} +case 73: +#line 340 "SDCC.y" +{ + yyval.asts = newNode(':',yyvsp[-2].asts,yyvsp[0].asts) ; + yyval.asts = newNode('?',yyvsp[-4].asts,yyval.asts) ; + ; + break;} +case 75: +#line 349 "SDCC.y" +{ + + switch (yyvsp[-1].yyint) { + case '=': + yyval.asts = newNode(yyvsp[-1].yyint,yyvsp[-2].asts,yyvsp[0].asts); + break; + case MUL_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode('*',copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case DIV_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode('/',copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case ADD_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode('+',copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case SUB_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode('-',copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case LEFT_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode(LEFT_OP,copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case RIGHT_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode(RIGHT_OP,copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case AND_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode('&',copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case XOR_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode('^',copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + case OR_ASSIGN: + yyval.asts = newNode('=',yyvsp[-2].asts,newNode('|',copyAst(yyvsp[-2].asts),yyvsp[0].asts)); + break; + default : + yyval.asts = NULL; + } + + ; + break;} +case 76: +#line 390 "SDCC.y" +{ yyval.yyint = '=' ;; + break;} +case 88: +#line 405 "SDCC.y" +{ yyval.asts = newNode(',',yyvsp[-2].asts,yyvsp[0].asts);; + break;} +case 90: +#line 413 "SDCC.y" +{ yyval.sym = NULL ; ; + break;} +case 91: +#line 415 "SDCC.y" +{ + /* add the specifier list to the id */ + symbol *sym , *sym1; + + for (sym1 = sym = reverseSyms(yyvsp[-1].sym);sym != NULL;sym = sym->next) { + link *lnk = copyLinkChain(yyvsp[-2].lnk); + /* do the pointer stuff */ + pointerTypes(sym->type,lnk); + addDecl (sym,0,lnk) ; + } + + yyval.sym = sym1 ; + ; + break;} +case 92: +#line 431 "SDCC.y" +{ yyval.lnk = yyvsp[0].lnk; ; + break;} +case 93: +#line 432 "SDCC.y" +{ + /* if the decl $2 is not a specifier */ + /* find the spec and replace it */ + if ( !IS_SPEC(yyvsp[0].lnk)) { + link *lnk = yyvsp[0].lnk ; + while (lnk && !IS_SPEC(lnk->next)) + lnk = lnk->next; + lnk->next = mergeSpec(yyvsp[-1].lnk,lnk->next); + yyval.lnk = yyvsp[0].lnk ; + } + else + yyval.lnk = mergeSpec(yyvsp[-1].lnk,yyvsp[0].lnk); + ; + break;} +case 94: +#line 445 "SDCC.y" +{ yyval.lnk = yyvsp[0].lnk; ; + break;} +case 95: +#line 446 "SDCC.y" +{ + /* if the decl $2 is not a specifier */ + /* find the spec and replace it */ + if ( !IS_SPEC(yyvsp[0].lnk)) { + link *lnk = yyvsp[0].lnk ; + while (lnk && !IS_SPEC(lnk->next)) + lnk = lnk->next; + lnk->next = mergeSpec(yyvsp[-1].lnk,lnk->next); + yyval.lnk = yyvsp[0].lnk ; + } + else + yyval.lnk = mergeSpec(yyvsp[-1].lnk,yyvsp[0].lnk); + ; + break;} +case 97: +#line 463 "SDCC.y" +{ yyvsp[0].sym->next = yyvsp[-2].sym ; yyval.sym = yyvsp[0].sym;; + break;} +case 98: +#line 467 "SDCC.y" +{ yyvsp[0].sym->ival = NULL ; ; + break;} +case 99: +#line 468 "SDCC.y" +{ yyvsp[-2].sym->ival = yyvsp[0].ilist ; ; + break;} +case 100: +#line 473 "SDCC.y" +{ + yyval.lnk = newLink () ; + yyval.lnk->class = SPECIFIER ; + SPEC_TYPEDEF(yyval.lnk) = 1 ; + ; + break;} +case 101: +#line 478 "SDCC.y" +{ + yyval.lnk = newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_EXTR(yyval.lnk) = 1 ; + ; + break;} +case 102: +#line 483 "SDCC.y" +{ + yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_STAT(yyval.lnk) = 1 ; + ; + break;} +case 103: +#line 488 "SDCC.y" +{ + yyval.lnk = newLink () ; + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_AUTO ; + ; + break;} +case 104: +#line 493 "SDCC.y" +{ + yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_REGISTER ; + ; + break;} +case 105: +#line 501 "SDCC.y" +{ yyval.yyint = (int) floatFromVal(yyvsp[0].val) ; ; + break;} +case 107: +#line 507 "SDCC.y" +{ + /* add this to the storage class specifier */ + SPEC_ABSA(yyvsp[-2].lnk) = 1; /* set the absolute addr flag */ + /* now get the abs addr from value */ + SPEC_ADDR(yyvsp[-2].lnk) = (int) floatFromVal (yyvsp[0].val) ; + ; + break;} +case 108: +#line 516 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_CHAR ; + ; + break;} +case 109: +#line 521 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_LONG(yyval.lnk) = 0 ; + SPEC_SHORT(yyval.lnk) = 1 ; + ; + break;} +case 110: +#line 527 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_INT ; + ; + break;} +case 111: +#line 532 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_LONG(yyval.lnk) = 1 ; + SPEC_SHORT(yyval.lnk) = 0; + ; + break;} +case 112: +#line 538 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_USIGN(yyval.lnk) = 0 ; + ; + break;} +case 113: +#line 543 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_USIGN(yyval.lnk) = 1 ; + ; + break;} +case 114: +#line 548 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_VOID ; + ; + break;} +case 115: +#line 553 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_CONSTANT ; + SPEC_CONST(yyval.lnk) = 1; + ; + break;} +case 116: +#line 559 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_VOLATILE(yyval.lnk) = 1 ; + ; + break;} +case 117: +#line 564 "SDCC.y" +{ + yyval.lnk=newLink(); + SPEC_NOUN(yyval.lnk) = V_FLOAT; + yyval.lnk->class = SPECIFIER ; + ; + break;} +case 118: +#line 569 "SDCC.y" +{ + yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_XDATA ; + ; + break;} +case 119: +#line 574 "SDCC.y" +{ + yyval.lnk = newLink () ; + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_CODE ; + ; + break;} +case 120: +#line 579 "SDCC.y" +{ + yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_DATA ; + ; + break;} +case 121: +#line 584 "SDCC.y" +{ + yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_IDATA ; + ; + break;} +case 122: +#line 589 "SDCC.y" +{ + yyval.lnk = newLink (); + yyval.lnk->class = SPECIFIER ; + SPEC_SCLS(yyval.lnk) = S_PDATA ; + ; + break;} +case 123: +#line 594 "SDCC.y" +{ + yyval.lnk=newLink(); + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_BIT ; + SPEC_SCLS(yyval.lnk) = S_BIT ; + SPEC_BLEN(yyval.lnk) = 1; + SPEC_BSTR(yyval.lnk) = 0; + ; + break;} +case 125: +#line 604 "SDCC.y" +{ + cenum = NULL ; + yyval.lnk = yyvsp[0].lnk ; + ; + break;} +case 126: +#line 609 "SDCC.y" +{ + symbol *sym; + link *p ; + + sym = findSym(TypedefTab,NULL,yyvsp[0].yychar) ; + yyval.lnk = p = copyLinkChain(sym->type); + SPEC_TYPEDEF(getSpec(p)) = 0; + ; + break;} +case 128: +#line 621 "SDCC.y" +{ + yyval.lnk = newLink() ; + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_SBIT; + SPEC_SCLS(yyval.lnk) = S_SBIT; + ; + break;} +case 129: +#line 627 "SDCC.y" +{ + yyval.lnk = newLink() ; + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_CHAR; + SPEC_SCLS(yyval.lnk) = S_SFR ; + SPEC_USIGN(yyval.lnk) = 1 ; + ; + break;} +case 130: +#line 638 "SDCC.y" +{ + structdef *sdef ; + + /* Create a structdef */ + sdef = yyvsp[-3].sdef ; + sdef->fields = reverseSyms(yyvsp[-1].sym) ; /* link the fields */ + sdef->size = compStructSize(yyvsp[-4].yyint,sdef); /* update size of */ + + /* Create the specifier */ + yyval.lnk = newLink () ; + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_STRUCT; + SPEC_STRUCT(yyval.lnk)= sdef ; + ; + break;} +case 131: +#line 653 "SDCC.y" +{ + yyval.lnk = newLink() ; + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_STRUCT; + SPEC_STRUCT(yyval.lnk) = yyvsp[0].sdef ; + ; + break;} +case 132: +#line 662 "SDCC.y" +{ yyval.yyint = STRUCT ; ; + break;} +case 133: +#line 663 "SDCC.y" +{ yyval.yyint = UNION ; ; + break;} +case 135: +#line 668 "SDCC.y" +{ /* synthesize a name add to structtable */ + yyval.sdef = newStruct(genSymName(NestLevel)) ; + yyval.sdef->level = NestLevel ; + addSym (StructTab, yyval.sdef, yyval.sdef->tag,yyval.sdef->level,currBlockno) ; + ; + break;} +case 136: +#line 676 "SDCC.y" +{ /* add name to structure table */ + yyval.sdef = findSymWithBlock (StructTab,yyvsp[0].sym,currBlockno); + if (! yyval.sdef ) { + yyval.sdef = newStruct(yyvsp[0].sym->name) ; + yyval.sdef->level = NestLevel ; + addSym (StructTab, yyval.sdef, yyval.sdef->tag,yyval.sdef->level,currBlockno) ; + } + ; + break;} +case 138: +#line 689 "SDCC.y" +{ + symbol *sym = yyvsp[0].sym; + /* go to the end of the chain */ + while (sym->next) sym = sym->next; + + sym->next = yyvsp[-1].sym ; + yyval.sym = yyvsp[0].sym; + ; + break;} +case 139: +#line 701 "SDCC.y" +{ + /* add this type to all the symbols */ + symbol *sym ; + for ( sym = yyvsp[-1].sym ; sym != NULL ; sym = sym->next ) { + + pointerTypes(sym->type,copyLinkChain(yyvsp[-2].lnk)); + if (!sym->type) { + sym->type = copyLinkChain(yyvsp[-2].lnk); + sym->etype = getSpec(sym->type); + } + else + addDecl (sym,0,cloneSpec(yyvsp[-2].lnk)); + + } + yyval.sym = yyvsp[-1].sym; + ; + break;} +case 141: +#line 722 "SDCC.y" +{ + yyvsp[0].sym->next = yyvsp[-2].sym ; + yyval.sym = yyvsp[0].sym ; + ; + break;} +case 143: +#line 730 "SDCC.y" +{ + yyval.sym = newSymbol (genSymName(NestLevel),NestLevel) ; + yyval.sym->bitVar = (int) floatFromVal(constExprValue(yyvsp[0].asts,TRUE)); + ; + break;} +case 144: +#line 735 "SDCC.y" +{ + yyvsp[-2].sym->bitVar = (int) floatFromVal(constExprValue(yyvsp[0].asts,TRUE)); + ; + break;} +case 145: +#line 741 "SDCC.y" +{ + addSymChain (yyvsp[-1].sym); + allocVariables(reverseSyms(yyvsp[-1].sym)) ; + yyval.lnk = copyLinkChain(cenum->type); + ; + break;} +case 146: +#line 746 "SDCC.y" +{ + symbol *csym ; + + yyvsp[-3].sym->type = copyLinkChain(cenum->type); + yyvsp[-3].sym->etype = getSpec(yyvsp[-3].sym->type); + /* add this to the enumerator table */ + if (!(csym=findSym(enumTab,yyvsp[-3].sym,yyvsp[-3].sym->name)) && + (csym && csym->level == yyvsp[-3].sym->level)) + werror(E_DUPLICATE_TYPEDEF,csym->name); + + addSym ( enumTab,yyvsp[-3].sym,yyvsp[-3].sym->name,yyvsp[-3].sym->level,yyvsp[-3].sym->block); + addSymChain (yyvsp[-1].sym); + allocVariables (reverseSyms(yyvsp[-1].sym)); + yyval.lnk = copyLinkChain(cenum->type); + SPEC_SCLS(getSpec(yyval.lnk)) = 0 ; + ; + break;} +case 147: +#line 762 "SDCC.y" +{ + symbol *csym ; + + /* check the enumerator table */ + if ((csym = findSym(enumTab,yyvsp[0].sym,yyvsp[0].sym->name))) + yyval.lnk = copyLinkChain(csym->type); + else { + yyval.lnk = newLink() ; + yyval.lnk->class = SPECIFIER ; + SPEC_NOUN(yyval.lnk) = V_INT ; + } + + SPEC_SCLS(getSpec(yyval.lnk)) = 0 ; + ; + break;} +case 149: +#line 780 "SDCC.y" +{ + yyvsp[0].sym->next = yyvsp[-2].sym ; + yyval.sym = yyvsp[0].sym ; + ; + break;} +case 150: +#line 787 "SDCC.y" +{ + /* make the symbol one level up */ + yyvsp[-1].sym->level-- ; + yyvsp[-1].sym->type = copyLinkChain(yyvsp[0].val->type); + yyvsp[-1].sym->etype= getSpec(yyvsp[-1].sym->type); + SPEC_ENUM(yyvsp[-1].sym->etype) = 1; + yyval.sym = yyvsp[-1].sym ; + + ; + break;} +case 151: +#line 799 "SDCC.y" +{ + value *val ; + + val = constExprValue(yyvsp[0].asts,TRUE); + yyval.val = cenum = val ; + ; + break;} +case 152: +#line 805 "SDCC.y" +{ + if (cenum) { + sprintf(lbuff,"%d",(int) floatFromVal(cenum)+1); + yyval.val = cenum = constVal(lbuff); + } + else { + sprintf(lbuff,"%d",0); + yyval.val = cenum = constVal(lbuff); + } + ; + break;} +case 153: +#line 818 "SDCC.y" +{ yyval.sym = yyvsp[0].sym; ; + break;} +case 154: +#line 820 "SDCC.y" +{ + addDecl (yyvsp[0].sym,0,reverseLink(yyvsp[-1].lnk)); + yyval.sym = yyvsp[0].sym ; + ; + break;} +case 155: +#line 827 "SDCC.y" +{ yyval.sym = yyvsp[0].sym ; ; + break;} +case 156: +#line 828 "SDCC.y" +{ addDecl (yyvsp[-1].sym,0,yyvsp[0].lnk); ; + break;} +case 158: +#line 833 "SDCC.y" +{ yyval.sym = yyvsp[-1].sym; ; + break;} +case 159: +#line 835 "SDCC.y" +{ + link *p; + + p = newLink (); + DCL_TYPE(p) = ARRAY ; + DCL_ELEM(p) = 0 ; + addDecl(yyvsp[-2].sym,0,p); + ; + break;} +case 160: +#line 844 "SDCC.y" +{ + link *p ; + value *tval; + + p = (tval = constExprValue(yyvsp[-1].asts,TRUE))->etype; + /* if it is not a constant then Error */ + if ( SPEC_SCLS(p) != S_LITERAL) + werror(E_CONST_EXPECTED) ; + else { + p = newLink (); + DCL_TYPE(p) = ARRAY ; + DCL_ELEM(p) = (int) floatFromVal(tval) ; + addDecl(yyvsp[-3].sym,0,p); + } + ; + break;} +case 161: +#line 859 "SDCC.y" +{ addDecl (yyvsp[-2].sym,FUNCTION,NULL) ; ; + break;} +case 162: +#line 860 "SDCC.y" +{ NestLevel++ ; currBlockno++; ; + break;} +case 163: +#line 861 "SDCC.y" +{ + + addDecl (yyvsp[-4].sym,FUNCTION,NULL) ; + + yyvsp[-4].sym->hasVargs = IS_VARG(yyvsp[-1].val); + yyvsp[-4].sym->args = reverseVal(yyvsp[-1].val) ; + + /* nest level was incremented to take care of the parms */ + NestLevel-- ; + currBlockno--; + yyval.sym = yyvsp[-4].sym; + ; + break;} +case 164: +#line 874 "SDCC.y" +{ + werror(E_OLD_STYLE,yyvsp[-3].sym->name) ; + + /* assume it returns an it */ + yyvsp[-3].sym->type = yyvsp[-3].sym->etype = newIntLink(); + yyval.sym = yyvsp[-3].sym ; + ; + break;} +case 165: +#line 884 "SDCC.y" +{ yyval.lnk = yyvsp[0].lnk ;; + break;} +case 166: +#line 886 "SDCC.y" +{ + yyval.lnk = yyvsp[-1].lnk ; + DCL_TSPEC(yyvsp[-1].lnk) = yyvsp[0].lnk; + ; + break;} +case 167: +#line 891 "SDCC.y" +{ + yyval.lnk = yyvsp[-1].lnk ; + yyval.lnk->next = yyvsp[0].lnk ; + ; + break;} +case 168: +#line 896 "SDCC.y" +{ + yyval.lnk = yyvsp[-2].lnk ; + if (IS_SPEC(yyvsp[-1].lnk) && DCL_TYPE(yyvsp[0].lnk) == UPOINTER) { + DCL_PTR_CONST(yyvsp[-2].lnk) = SPEC_CONST(yyvsp[-1].lnk); + DCL_PTR_VOLATILE(yyvsp[-2].lnk) = SPEC_VOLATILE(yyvsp[-1].lnk); + switch (SPEC_SCLS(yyvsp[-1].lnk)) { + case S_XDATA: + DCL_TYPE(yyvsp[0].lnk) = FPOINTER; + break; + case S_IDATA: + DCL_TYPE(yyvsp[0].lnk) = IPOINTER ; + break; + case S_PDATA: + DCL_TYPE(yyvsp[0].lnk) = PPOINTER ; + break; + case S_DATA: + DCL_TYPE(yyvsp[0].lnk) = POINTER ; + break; + case S_CODE: + DCL_PTR_CONST(yyvsp[0].lnk) = 1; + DCL_TYPE(yyvsp[0].lnk) = CPOINTER ; + break; + } + } + else + werror (W_PTR_TYPE_INVALID); + yyval.lnk->next = yyvsp[0].lnk ; + ; + break;} +case 169: +#line 927 "SDCC.y" +{ + if (yyvsp[-1].lnk == NULL) { + yyval.lnk = newLink(); + DCL_TYPE(yyval.lnk) = POINTER ; + } + else + yyval.lnk = yyvsp[-1].lnk ; + ; + break;} +case 170: +#line 938 "SDCC.y" +{ yyval.lnk = newLink() ; DCL_TYPE(yyval.lnk) = FPOINTER ; ; + break;} +case 171: +#line 939 "SDCC.y" +{ yyval.lnk = newLink() ; DCL_TYPE(yyval.lnk) = CPOINTER ; DCL_PTR_CONST(yyval.lnk) = 1;; + break;} +case 172: +#line 940 "SDCC.y" +{ yyval.lnk = newLink() ; DCL_TYPE(yyval.lnk) = PPOINTER ; ; + break;} +case 173: +#line 941 "SDCC.y" +{ yyval.lnk = newLink() ; DCL_TYPE(yyval.lnk) = IPOINTER ; ; + break;} +case 174: +#line 942 "SDCC.y" +{ yyval.lnk = NULL ; ; + break;} +case 175: +#line 943 "SDCC.y" +{ yyval.lnk = newLink() ; DCL_TYPE(yyval.lnk) = GPOINTER ; ; + break;} +case 176: +#line 944 "SDCC.y" +{ yyval.lnk = newLink() ; DCL_TYPE(yyval.lnk) = UPOINTER ; ; + break;} +case 178: +#line 949 "SDCC.y" +{ yyval.lnk = mergeSpec (yyvsp[-1].lnk,yyvsp[0].lnk); ; + break;} +case 182: +#line 960 "SDCC.y" +{ + yyvsp[0].sym->next = yyvsp[-2].sym; + yyval.sym = yyvsp[0].sym ; + ; + break;} +case 184: +#line 968 "SDCC.y" +{ yyvsp[-2].val->vArgs = 1;; + break;} +case 186: +#line 974 "SDCC.y" +{ + yyvsp[0].val->next = yyvsp[-2].val ; + yyval.val = yyvsp[0].val ; + ; + break;} +case 187: +#line 982 "SDCC.y" +{ + symbol *loop ; + pointerTypes(yyvsp[0].sym->type,yyvsp[-1].lnk); + addDecl (yyvsp[0].sym,0,yyvsp[-1].lnk); + for (loop=yyvsp[0].sym;loop;loop->_isparm=1,loop=loop->next); + addSymChain (yyvsp[0].sym); + yyval.val = symbolVal(yyvsp[0].sym); + ; + break;} +case 188: +#line 990 "SDCC.y" +{ + yyval.val = newValue() ; + yyval.val->type = yyvsp[0].lnk; + yyval.val->etype = getSpec(yyval.val->type); + ; + break;} +case 189: +#line 998 "SDCC.y" +{ yyval.lnk = yyvsp[0].lnk ;; + break;} +case 190: +#line 1000 "SDCC.y" +{ + /* go to the end of the list */ + link *p; + pointerTypes(yyvsp[0].lnk,yyvsp[-1].lnk); + for ( p = yyvsp[0].lnk ; p->next ; p=p->next); + p->next = yyvsp[-1].lnk ; + yyval.lnk = yyvsp[0].lnk ; + ; + break;} +case 191: +#line 1011 "SDCC.y" +{ yyval.lnk = reverseLink(yyvsp[0].lnk); ; + break;} +case 193: +#line 1013 "SDCC.y" +{ yyvsp[-1].lnk = reverseLink(yyvsp[-1].lnk); yyvsp[-1].lnk->next = yyvsp[0].lnk ; yyval.lnk = yyvsp[-1].lnk;; + break;} +case 194: +#line 1017 "SDCC.y" +{ yyval.lnk = yyvsp[-1].lnk ; ; + break;} +case 195: +#line 1018 "SDCC.y" +{ + yyval.lnk = newLink (); + DCL_TYPE(yyval.lnk) = ARRAY ; + DCL_ELEM(yyval.lnk) = 0 ; + ; + break;} +case 196: +#line 1023 "SDCC.y" +{ + value *val ; + yyval.lnk = newLink (); + DCL_TYPE(yyval.lnk) = ARRAY ; + DCL_ELEM(yyval.lnk) = (int) floatFromVal(val = constExprValue(yyvsp[-1].asts,TRUE)); + ; + break;} +case 197: +#line 1029 "SDCC.y" +{ + yyval.lnk = newLink (); + DCL_TYPE(yyval.lnk) = ARRAY ; + DCL_ELEM(yyval.lnk) = 0 ; + yyval.lnk->next = yyvsp[-2].lnk ; + ; + break;} +case 198: +#line 1036 "SDCC.y" +{ + value *val ; + yyval.lnk = newLink (); + DCL_TYPE(yyval.lnk) = ARRAY ; + DCL_ELEM(yyval.lnk) = (int) floatFromVal(val = constExprValue(yyvsp[-1].asts,TRUE)); + yyval.lnk->next = yyvsp[-3].lnk ; + ; + break;} +case 199: +#line 1043 "SDCC.y" +{ yyval.lnk = NULL;; + break;} +case 200: +#line 1044 "SDCC.y" +{ yyval.lnk = NULL;; + break;} +case 203: +#line 1050 "SDCC.y" +{ yyval.ilist = newiList(INIT_NODE,yyvsp[0].asts); ; + break;} +case 204: +#line 1051 "SDCC.y" +{ yyval.ilist = newiList(INIT_DEEP,revinit(yyvsp[-1].ilist)); ; + break;} +case 205: +#line 1052 "SDCC.y" +{ yyval.ilist = newiList(INIT_DEEP,revinit(yyvsp[-2].ilist)); ; + break;} +case 207: +#line 1057 "SDCC.y" +{ yyvsp[0].ilist->next = yyvsp[-2].ilist; yyval.ilist = yyvsp[0].ilist; ; + break;} +case 214: +#line 1067 "SDCC.y" +{ + ast *ex = newNode(INLINEASM,NULL,NULL); + ALLOC_ATOMIC(ex->values.inlineasm,strlen(yyvsp[-1].yyinline)); + strcpy(ex->values.inlineasm,yyvsp[-1].yyinline); + yyval.asts = ex; + ; + break;} +case 215: +#line 1076 "SDCC.y" +{ yyval.asts = createLabel(yyvsp[-2].sym,yyvsp[0].asts); ; + break;} +case 216: +#line 1077 "SDCC.y" +{ yyval.asts = createCase(STACK_PEEK(swStk),yyvsp[-2].asts,yyvsp[0].asts); ; + break;} +case 217: +#line 1078 "SDCC.y" +{ yyval.asts = createDefault(STACK_PEEK(swStk),yyvsp[0].asts); ; + break;} +case 218: +#line 1081 "SDCC.y" +{ STACK_PUSH(blockNum,currBlockno); currBlockno = ++blockNo ; ; + break;} +case 219: +#line 1084 "SDCC.y" +{ currBlockno = STACK_POP(blockNum); ; + break;} +case 220: +#line 1088 "SDCC.y" +{ yyval.asts = createBlock(NULL,NULL); ; + break;} +case 221: +#line 1089 "SDCC.y" +{ yyval.asts = createBlock(NULL,yyvsp[-1].asts) ; ; + break;} +case 222: +#line 1091 "SDCC.y" +{ addSymChain(yyvsp[0].sym); ; + break;} +case 223: +#line 1092 "SDCC.y" +{ yyval.asts = createBlock(yyvsp[-2].sym,NULL) ; ; + break;} +case 224: +#line 1094 "SDCC.y" +{ addSymChain (yyvsp[0].sym); ; + break;} +case 225: +#line 1096 "SDCC.y" +{yyval.asts = createBlock(yyvsp[-3].sym,yyvsp[-1].asts) ; ; + break;} +case 226: +#line 1097 "SDCC.y" +{ yyval.asts = NULL ; ; + break;} +case 227: +#line 1102 "SDCC.y" +{ + /* if this is typedef declare it immediately */ + if ( yyvsp[0].sym && IS_TYPEDEF(yyvsp[0].sym->etype)) { + allocVariables (yyvsp[0].sym); + yyval.sym = NULL ; + } + else + yyval.sym = yyvsp[0].sym ; + ; + break;} +case 228: +#line 1113 "SDCC.y" +{ + symbol *sym; + + /* if this is a typedef */ + if (yyvsp[0].sym && IS_TYPEDEF(yyvsp[0].sym->etype)) { + allocVariables (yyvsp[0].sym); + yyval.sym = yyvsp[-1].sym ; + } + else { + /* get to the end of the previous decl */ + if ( yyvsp[-1].sym ) { + yyval.sym = sym = yyvsp[-1].sym ; + while (sym->next) + sym = sym->next ; + sym->next = yyvsp[0].sym; + } + else + yyval.sym = yyvsp[0].sym ; + } + ; + break;} +case 230: +#line 1137 "SDCC.y" +{ yyval.asts = newNode(NULLOP,yyvsp[-1].asts,yyvsp[0].asts) ;; + break;} +case 231: +#line 1141 "SDCC.y" +{ yyval.asts = NULL;; + break;} +case 233: +#line 1146 "SDCC.y" +{ yyval.asts = yyvsp[0].asts ; ; + break;} +case 234: +#line 1147 "SDCC.y" +{ yyval.asts = NULL;; + break;} +case 235: +#line 1152 "SDCC.y" +{ noLineno++ ; yyval.asts = createIf (yyvsp[-3].asts, yyvsp[-1].asts, yyvsp[0].asts ); noLineno--;; + break;} +case 236: +#line 1153 "SDCC.y" +{ + ast *ex ; + static int swLabel = 0 ; + + /* create a node for expression */ + ex = newNode(SWITCH,yyvsp[-1].asts,NULL); + STACK_PUSH(swStk,ex); /* save it in the stack */ + ex->values.switchVals.swNum = swLabel ; + + /* now create the label */ + sprintf(lbuff,"_swBrk_%d",swLabel++); + yyval.sym = newSymbol(lbuff,NestLevel); + /* put label in the break stack */ + STACK_PUSH(breakStack,yyval.sym); + ; + break;} +case 237: +#line 1168 "SDCC.y" +{ + /* get back the switch form the stack */ + yyval.asts = STACK_POP(swStk) ; + yyval.asts->right = newNode (NULLOP,yyvsp[0].asts,createLabel(yyvsp[-1].sym,NULL)); + STACK_POP(breakStack); + ; + break;} +case 238: +#line 1176 "SDCC.y" +{ /* create and push the continue , break & body labels */ + static int Lblnum = 0 ; + /* continue */ + sprintf (lbuff,"_whilecontinue_%d",Lblnum); + STACK_PUSH(continueStack,newSymbol(lbuff,NestLevel)); + /* break */ + sprintf (lbuff,"_whilebreak_%d",Lblnum); + STACK_PUSH(breakStack,newSymbol(lbuff,NestLevel)); + /* body */ + sprintf (lbuff,"_whilebody_%d",Lblnum++); + yyval.sym = newSymbol(lbuff,NestLevel); + ; + break;} +case 239: +#line 1189 "SDCC.y" +{ /* create and push the continue , break & body Labels */ + static int Lblnum = 0 ; + + /* continue */ + sprintf(lbuff,"_docontinue_%d",Lblnum); + STACK_PUSH(continueStack,newSymbol(lbuff,NestLevel)); + /* break */ + sprintf (lbuff,"_dobreak_%d",Lblnum); + STACK_PUSH(breakStack,newSymbol(lbuff,NestLevel)); + /* do body */ + sprintf (lbuff,"_dobody_%d",Lblnum++); + yyval.sym = newSymbol (lbuff,NestLevel); + ; + break;} +case 240: +#line 1202 "SDCC.y" +{ /* create & push continue, break & body labels */ + static int Lblnum = 0 ; + + /* continue */ + sprintf (lbuff,"_forcontinue_%d",Lblnum); + STACK_PUSH(continueStack,newSymbol(lbuff,NestLevel)); + /* break */ + sprintf (lbuff,"_forbreak_%d",Lblnum); + STACK_PUSH(breakStack,newSymbol(lbuff,NestLevel)); + /* body */ + sprintf (lbuff,"_forbody_%d",Lblnum); + yyval.sym = newSymbol(lbuff,NestLevel); + /* condition */ + sprintf (lbuff,"_forcond_%d",Lblnum++); + STACK_PUSH(forStack,newSymbol(lbuff,NestLevel)); + ; + break;} +case 241: +#line 1221 "SDCC.y" +{ + noLineno++ ; + yyval.asts = createWhile ( yyvsp[-4].sym, STACK_POP(continueStack), + STACK_POP(breakStack), yyvsp[-2].asts, yyvsp[0].asts ); + yyval.asts->lineno = yyvsp[-4].sym->lineDef ; + noLineno-- ; + ; + break;} +case 242: +#line 1229 "SDCC.y" +{ + noLineno++ ; + yyval.asts = createDo ( yyvsp[-6].sym , STACK_POP(continueStack), + STACK_POP(breakStack), yyvsp[-2].asts, yyvsp[-5].asts); + yyval.asts->lineno = yyvsp[-6].sym->lineDef ; + noLineno-- ; + ; + break;} +case 243: +#line 1237 "SDCC.y" +{ + noLineno++ ; + + /* if break or continue statement present + then create a general case loop */ + if (STACK_PEEK(continueStack)->isref || + STACK_PEEK(breakStack)->isref) { + yyval.asts = createFor (yyvsp[-8].sym, STACK_POP(continueStack), + STACK_POP(breakStack) , + STACK_POP(forStack) , + yyvsp[-6].asts , yyvsp[-4].asts , yyvsp[-2].asts, yyvsp[0].asts ); + } else { + yyval.asts = newNode(FOR,yyvsp[0].asts,NULL); + AST_FOR(yyval.asts,trueLabel) = yyvsp[-8].sym; + AST_FOR(yyval.asts,continueLabel) = STACK_POP(continueStack); + AST_FOR(yyval.asts,falseLabel) = STACK_POP(breakStack); + AST_FOR(yyval.asts,condLabel) = STACK_POP(forStack) ; + AST_FOR(yyval.asts,initExpr) = yyvsp[-6].asts; + AST_FOR(yyval.asts,condExpr) = yyvsp[-4].asts; + AST_FOR(yyval.asts,loopExpr) = yyvsp[-2].asts; + } + + noLineno-- ; + ; + break;} +case 244: +#line 1264 "SDCC.y" +{ yyval.asts = NULL ; ; + break;} +case 246: +#line 1269 "SDCC.y" +{ + yyvsp[-1].sym->islbl = 1; + yyval.asts = newAst(EX_VALUE,symbolVal(yyvsp[-1].sym)); + yyval.asts = newNode(GOTO,yyval.asts,NULL); + ; + break;} +case 247: +#line 1274 "SDCC.y" +{ + /* make sure continue is in context */ + if (STACK_PEEK(continueStack) == NULL) { + werror(E_BREAK_CONTEXT); + yyval.asts = NULL; + } + else { + yyval.asts = newAst(EX_VALUE,symbolVal(STACK_PEEK(continueStack))); + yyval.asts = newNode(GOTO,yyval.asts,NULL); + /* mark the continue label as referenced */ + STACK_PEEK(continueStack)->isref = 1; + } + ; + break;} +case 248: +#line 1287 "SDCC.y" +{ + if (STACK_PEEK(breakStack) == NULL) { + werror(E_BREAK_CONTEXT); + yyval.asts = NULL; + } else { + yyval.asts = newAst(EX_VALUE,symbolVal(STACK_PEEK(breakStack))); + yyval.asts = newNode(GOTO,yyval.asts,NULL); + STACK_PEEK(breakStack)->isref = 1; + } + ; + break;} +case 249: +#line 1297 "SDCC.y" +{ yyval.asts = newNode(RETURN,NULL,NULL) ; ; + break;} +case 250: +#line 1298 "SDCC.y" +{ yyval.asts = newNode(RETURN,NULL,yyvsp[-1].asts) ; ; + break;} +case 251: +#line 1302 "SDCC.y" +{ yyval.sym = newSymbol (yyvsp[0].yychar,NestLevel) ; ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/share/misc/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 1304 "SDCC.y" + + +extern unsigned char *yytext; +extern int column; +extern char *filename; +extern int fatalError; + +int yyerror(char *s) +{ + fflush(stdout); + + if ( yylineno ) + fprintf(stderr,"\n%s(%d) %s: token -> '%s' ; column %d\n", + filename,yylineno, + s,yytext,column); + fatalError++; + return 0; +} + diff --git a/src/SDCCy.h b/src/SDCCy.h new file mode 100644 index 00000000..631737f8 --- /dev/null +++ b/src/SDCCy.h @@ -0,0 +1,118 @@ +typedef union { + symbol *sym ; /* symbol table pointer */ + structdef *sdef; /* structure definition */ + char yychar[SDCC_NAME_MAX+1]; + link *lnk ; /* declarator or specifier */ + int yyint; /* integer value returned */ + value *val ; /* for integer constant */ + initList *ilist; /* initial list */ + char yyinline[MAX_INLINEASM]; /* inlined assembler code */ + ast *asts; /* expression tree */ +} YYSTYPE; +#define IDENTIFIER 257 +#define TYPE_NAME 258 +#define CONSTANT 259 +#define STRING_LITERAL 260 +#define SIZEOF 261 +#define PTR_OP 262 +#define INC_OP 263 +#define DEC_OP 264 +#define LEFT_OP 265 +#define RIGHT_OP 266 +#define LE_OP 267 +#define GE_OP 268 +#define EQ_OP 269 +#define NE_OP 270 +#define AND_OP 271 +#define OR_OP 272 +#define MUL_ASSIGN 273 +#define DIV_ASSIGN 274 +#define MOD_ASSIGN 275 +#define ADD_ASSIGN 276 +#define SUB_ASSIGN 277 +#define LEFT_ASSIGN 278 +#define RIGHT_ASSIGN 279 +#define AND_ASSIGN 280 +#define XOR_ASSIGN 281 +#define OR_ASSIGN 282 +#define TYPEDEF 283 +#define EXTERN 284 +#define STATIC 285 +#define AUTO 286 +#define REGISTER 287 +#define CODE 288 +#define INTERRUPT 289 +#define SFR 290 +#define AT 291 +#define SBIT 292 +#define REENTRANT 293 +#define USING 294 +#define XDATA 295 +#define DATA 296 +#define IDATA 297 +#define PDATA 298 +#define VAR_ARGS 299 +#define CRITICAL 300 +#define CHAR 301 +#define SHORT 302 +#define INT 303 +#define LONG 304 +#define SIGNED 305 +#define UNSIGNED 306 +#define FLOAT 307 +#define DOUBLE 308 +#define CONST 309 +#define VOLATILE 310 +#define VOID 311 +#define BIT 312 +#define STRUCT 313 +#define UNION 314 +#define ENUM 315 +#define ELIPSIS 316 +#define RANGE 317 +#define FAR 318 +#define _XDATA 319 +#define _CODE 320 +#define _GENERIC 321 +#define _NEAR 322 +#define _PDATA 323 +#define _IDATA 324 +#define CASE 325 +#define DEFAULT 326 +#define IF 327 +#define ELSE 328 +#define SWITCH 329 +#define WHILE 330 +#define DO 331 +#define FOR 332 +#define GOTO 333 +#define CONTINUE 334 +#define BREAK 335 +#define RETURN 336 +#define INLINEASM 337 +#define IFX 338 +#define ADDRESS_OF 339 +#define GET_VALUE_AT_ADDRESS 340 +#define SPIL 341 +#define UNSPIL 342 +#define GETHBIT 343 +#define BITWISEAND 344 +#define UNARYMINUS 345 +#define IPUSH 346 +#define IPOP 347 +#define PCALL 348 +#define ENDFUNCTION 349 +#define JUMPTABLE 350 +#define RRC 351 +#define RLC 352 +#define CAST 353 +#define CALL 354 +#define PARAM 355 +#define NULLOP 356 +#define BLOCK 357 +#define LABEL 358 +#define RECEIVE 359 +#define SEND 360 + + +extern YYSTYPE yylval; diff --git a/src/clean.mk b/src/clean.mk new file mode 100644 index 00000000..4b8f0618 --- /dev/null +++ b/src/clean.mk @@ -0,0 +1,26 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] *.output + rm -f .[a-z]*~ + rm -f $(PRJDIR)/bin/sdcc sdcc + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean + rm -f SDCCy.c + rm -f SDCCy.h + rm -f SDCClex.c diff --git a/src/conf.mk b/src/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/src/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/src/spawn.c b/src/spawn.c new file mode 100644 index 00000000..5ae21361 --- /dev/null +++ b/src/spawn.c @@ -0,0 +1,66 @@ +/**[txh]******************************************************************** + + Module: Spawn replacement for UNIXes + Description: + This module provides spawnv and spawnvp functions for UNIX.@* + Copyright 1999 by Salvador E. Tropea. You can use it under the terms of +the GPL license. e-mail: salvador@inti.gov.ar, set@computer.org + + Include: spawn.h + +***************************************************************************/ + +#ifndef __DJGPP__ + +#include +#include +#include "spawn.h" + +/**[txh]******************************************************************** + + Description: + That's a replacement for the DOS spawnv function which was POSIX during +the drafts but then was removed. It avoids the need of the fork/exec/wait +sequence which doesn't work for djgpp. + +***************************************************************************/ + +int spawnv(int mode, const char *path, char *const argv[]) +{ + int pStatus; + + if (mode==P_OVERLAY) + return execv(path,argv); + if (!fork()) + { + if (execv(path,argv)) + return -1; + } + if (mode==P_WAIT) + wait(&pStatus); + return 0; +} + +/**[txh]******************************************************************** + + Description: + Same as spawnv but using execvp. @x{spawnv}. + +***************************************************************************/ + +int spawnvp(int mode, const char *path, char *const argv[]) +{ + int pStatus; + + if (mode==P_OVERLAY) + return execv(path,argv); + if (!fork()) + { + if (execvp(path,argv)) + return -1; + } + if (mode==P_WAIT) + wait(&pStatus); + return 0; +} +#endif diff --git a/src/spawn.h b/src/spawn.h new file mode 100644 index 00000000..4d0be572 --- /dev/null +++ b/src/spawn.h @@ -0,0 +1,13 @@ +#ifdef __DJGPP__ +/* They exist in DOS */ +#include +#else +/* Specially defined for UNIX and Cygwin */ +int spawnv(int mode, const char *path, char *const argv[]); +int spawnvp(int mode, const char *path, char *const argv[]); + +#define P_WAIT 1 +#define P_NOWAIT 2 /* always generates error for DJGPP! */ +#define P_OVERLAY 3 + +#endif diff --git a/support/README b/support/README new file mode 100644 index 00000000..c951fb27 --- /dev/null +++ b/support/README @@ -0,0 +1,5 @@ +sdcc/support +------------ + +This directory contains support programs and libraries that may +not be provided by your system. diff --git a/support/cpp/1 b/support/cpp/1 new file mode 100644 index 00000000..fa09f805 --- /dev/null +++ b/support/cpp/1 @@ -0,0 +1,186 @@ +In file included from i386/att.h:22, + from i386/linux.h:29, + from config.h:1, + from cppalloc.c:25: +i386/unix.h:77: parse error before `do' +i386/unix.h:77: stray '\' in program +i386/unix.h:78: parse error before `(' +i386/unix.h:78: stray '\' in program +i386/unix.h:90: stray '\' in program +i386/unix.h:91: stray '\' in program +i386/unix.h:92: stray '\' in program +i386/unix.h:93: stray '\' in program +i386/unix.h:93: stray '\' in program +i386/unix.h:94: stray '\' in program +i386/unix.h:94: stray '\' in program +i386/unix.h:95: parse error before character constant +i386/unix.h:130: parse error before string constant +i386/unix.h:141: stray '\' in program +In file included from i386/linux.h:29, + from config.h:1, + from cppalloc.c:25: +i386/att.h:41: stray '\' in program +i386/att.h:42: stray '\' in program +i386/att.h:43: stray '\' in program +i386/att.h:44: stray '\' in program +i386/att.h:45: parse error before `(' +i386/att.h:45: stray '\' in program +i386/att.h:46: stray '\' in program +i386/att.h:47: parse error before `(' +i386/att.h:47: stray '\' in program +i386/att.h:48: parse error before `(' +i386/att.h:48: stray '\' in program +i386/att.h:74: stray '\' in program +i386/att.h:75: stray '\' in program +i386/att.h:76: stray '\' in program +i386/att.h:77: stray '\' in program +i386/att.h:78: stray '\' in program +i386/att.h:79: stray '\' in program +i386/att.h:80: `in_bss' undeclared here (not in a function) +i386/att.h:80: warning: data definition has no type or storage class +i386/att.h:80: stray '\' in program +i386/att.h:81: parse error before `}' +i386/att.h:81: stray '\' in program +i386/att.h:93: parse error before `(' +In file included from config.h:1, + from cppalloc.c:25: +i386/linux.h:108: stray '\' in program +i386/linux.h:109: stray '\' in program +i386/linux.h:110: stray '\' in program +i386/linux.h:111: stray '\' in program +i386/linux.h:112: stray '\' in program +i386/linux.h:113: stray '\' in program +i386/linux.h:114: stray '\' in program +i386/linux.h:115: stray '\' in program +i386/linux.h:116: stray '\' in program +i386/linux.h:124: stray '\' in program +i386/linux.h:125: stray '\' in program +i386/linux.h:126: stray '\' in program +i386/linux.h:127: stray '\' in program +i386/linux.h:128: stray '\' in program +i386/linux.h:129: parse error before string constant +i386/linux.h:129: warning: data definition has no type or storage class +i386/linux.h:129: stray '\' in program +i386/linux.h:130: stray '\' in program +i386/linux.h:131: stray '\' in program +i386/linux.h:132: stray '\' in program +i386/linux.h:133: stray '\' in program +i386/linux.h:134: parse error before string constant +i386/linux.h:134: warning: data definition has no type or storage class +i386/linux.h:134: stray '\' in program +i386/linux.h:135: stray '\' in program +i386/linux.h:185: warning: unknown escape sequence: `\' followed by char code 0xd +In file included from i386/linux.h:235, + from config.h:1, + from cppalloc.c:25: +i386/perform.h:31: stray '\' in program +i386/perform.h:32: stray '\' in program +i386/perform.h:33: warning: call-clobbered register used for global register variable +i386/perform.h:33: stray '\' in program +i386/perform.h:34: stray '\' in program +i386/perform.h:35: warning: data definition has no type or storage class +i386/perform.h:35: stray '\' in program +i386/perform.h:36: conflicting declarations of `ax' +i386/perform.h:33: `ax' previously declared here +i386/perform.h:36: `arg0' undeclared here (not in a function) +i386/perform.h:36: warning: data definition has no type or storage class +i386/perform.h:36: stray '\' in program +i386/perform.h:37: parse error before `:' +i386/perform.h:37: stray '\' in program +i386/perform.h:38: stray '\' in program +i386/perform.h:42: stray '\' in program +i386/perform.h:43: stray '\' in program +i386/perform.h:44: conflicting declarations of `ax' +i386/perform.h:36: `ax' previously defined here +i386/perform.h:44: stray '\' in program +i386/perform.h:45: warning: call-clobbered register used for global register variable +i386/perform.h:45: stray '\' in program +i386/perform.h:46: stray '\' in program +i386/perform.h:47: redefinition of `ax' +i386/perform.h:36: `ax' previously defined here +i386/perform.h:47: `arg0' undeclared here (not in a function) +i386/perform.h:47: warning: data definition has no type or storage class +i386/perform.h:47: stray '\' in program +i386/perform.h:48: conflicting declarations of `cx' +i386/perform.h:45: `cx' previously declared here +i386/perform.h:48: `arg1' undeclared here (not in a function) +i386/perform.h:48: warning: data definition has no type or storage class +i386/perform.h:48: stray '\' in program +i386/perform.h:49: parse error before `:' +i386/perform.h:49: stray '\' in program +i386/perform.h:50: stray '\' in program +i386/perform.h:54: stray '\' in program +i386/perform.h:55: stray '\' in program +i386/perform.h:56: conflicting declarations of `ax' +i386/perform.h:47: `ax' previously defined here +i386/perform.h:56: stray '\' in program +i386/perform.h:57: stray '\' in program +i386/perform.h:58: redefinition of `dx' +i386/perform.h:35: `dx' previously defined here +i386/perform.h:58: warning: data definition has no type or storage class +i386/perform.h:58: stray '\' in program +i386/perform.h:59: redefinition of `ax' +i386/perform.h:47: `ax' previously defined here +i386/perform.h:59: `arg0' undeclared here (not in a function) +i386/perform.h:59: warning: data definition has no type or storage class +i386/perform.h:59: stray '\' in program +i386/perform.h:60: parse error before `:' +i386/perform.h:60: stray '\' in program +i386/perform.h:61: stray '\' in program +i386/perform.h:65: stray '\' in program +i386/perform.h:66: stray '\' in program +i386/perform.h:67: conflicting declarations of `ax' +i386/perform.h:59: `ax' previously defined here +i386/perform.h:67: stray '\' in program +i386/perform.h:68: conflicting declarations of `cx' +i386/perform.h:48: `cx' previously defined here +i386/perform.h:68: stray '\' in program +i386/perform.h:69: stray '\' in program +i386/perform.h:70: redefinition of `ax' +i386/perform.h:59: `ax' previously defined here +i386/perform.h:70: `arg0' undeclared here (not in a function) +i386/perform.h:70: warning: data definition has no type or storage class +i386/perform.h:70: stray '\' in program +i386/perform.h:71: redefinition of `cx' +i386/perform.h:48: `cx' previously defined here +i386/perform.h:71: `arg1' undeclared here (not in a function) +i386/perform.h:71: warning: data definition has no type or storage class +i386/perform.h:71: stray '\' in program +i386/perform.h:72: parse error before `:' +i386/perform.h:72: stray '\' in program +i386/perform.h:73: stray '\' in program +i386/perform.h:77: stray '\' in program +i386/perform.h:78: stray '\' in program +i386/perform.h:79: top-level declaration of `nstatus' specifies `auto' +i386/perform.h:79: stray '\' in program +i386/perform.h:80: top-level declaration of `ret' specifies `auto' +i386/perform.h:80: stray '\' in program +i386/perform.h:81: top-level declaration of `tmp' specifies `auto' +i386/perform.h:81: stray '\' in program +i386/perform.h:82: stray '\' in program +i386/perform.h:83: parse error before `&' +i386/perform.h:83: stray '\' in program +i386/perform.h:84: stray '\' in program +i386/perform.h:85: stray '\' in program +i386/perform.h:86: stray '\' in program +i386/perform.h:87: stray '\' in program +i386/perform.h:88: stray '\' in program +i386/perform.h:89: conflicting types for `nstatus' +i386/perform.h:79: previous declaration of `nstatus' +i386/perform.h:89: `ostatus' undeclared here (not in a function) +i386/perform.h:89: initializer element is not constant +i386/perform.h:89: warning: data definition has no type or storage class +i386/perform.h:89: stray '\' in program +i386/perform.h:90: parse error before `volatile' +i386/perform.h:90: stray '\' in program +i386/perform.h:91: conflicting types for `tmp' +i386/perform.h:81: previous declaration of `tmp' +i386/perform.h:91: `arg0' undeclared here (not in a function) +i386/perform.h:91: warning: data definition has no type or storage class +i386/perform.h:91: stray '\' in program +i386/perform.h:92: parse error before `volatile' +i386/perform.h:92: stray '\' in program +i386/perform.h:93: stray '\' in program +i386/perform.h:94: stray '\' in program +i386/perform.h:95: stray '\' in program +i386/perform.h:96: stray '\' in program diff --git a/support/cpp/Makefile b/support/cpp/Makefile new file mode 100644 index 00000000..513e98c2 --- /dev/null +++ b/support/cpp/Makefile @@ -0,0 +1,100 @@ +# Generated automatically from Makefile.in by configure. +# +# +# + +VERSION = 2.1.9Ga +VERSIONHI = 2 +VERSIONLO = 1 +VERSIONP = 9Ga + +SHELL = /bin/sh +CC = gcc +CPP = gcc -E +INSTALL = /usr/bin/install -c + +PRJDIR = ../.. + +srcdir = . +prefix = /usr/local +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +includedir = ${prefix}/include +mandir = ${prefix}/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = ${prefix}/info + +STD_INC = @sdcc_include_dir@ +CPPFLAGS = -I. -I$(PRJDIR) -D_FORASXXXX_ +CFLAGS = -ggdb -O2 -pipe +M_OR_MM = -MM +LDFLAGS = + +OBJECTS = cppalloc.o cpperror.o cppexp.o cpphash.o cpplib.o cppmain.o +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) + +TARGET = $(PRJDIR)/bin/sdcpp + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) -o $@ $(OBJECTS) + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) -s $(TARGET) $(bindir)/sdcpp + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(bindir)/sdcpp + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) *.h $(PRJDIR)/*.h + $(CPP) $(CPPFLAGS) $(M_OR_MM) $(SOURCES) >Makefile.dep + +include Makefile.dep +include clean.mk + +# My rules +# -------- +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of cpp/Makefile diff --git a/support/cpp/Makefile.dep b/support/cpp/Makefile.dep new file mode 100644 index 00000000..4b674457 --- /dev/null +++ b/support/cpp/Makefile.dep @@ -0,0 +1,7 @@ +cppalloc.o: cppalloc.c config.h i386/i386.h i386/xm-linux.h +cpperror.o: cpperror.c cpplib.h +cppexp.o: cppexp.c config.h i386/i386.h i386/xm-linux.h cpplib.h +cpphash.o: cpphash.c cpplib.h cpphash.h +cpplib.o: cpplib.c ../../sdccconf.h config.h i386/i386.h \ + i386/xm-linux.h cpplib.h cpphash.h +cppmain.o: cppmain.c cpplib.h diff --git a/support/cpp/Makefile.in b/support/cpp/Makefile.in new file mode 100644 index 00000000..9bf1a000 --- /dev/null +++ b/support/cpp/Makefile.in @@ -0,0 +1,99 @@ +# +# +# + +VERSION = @VERSION@ +VERSIONHI = @VERSIONHI@ +VERSIONLO = @VERSIONLO@ +VERSIONP = @VERSIONP@ + +SHELL = /bin/sh +CC = @CC@ +CPP = @CPP@ +INSTALL = @INSTALL@ + +PRJDIR = ../.. + +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +includedir = ${prefix}/include +mandir = ${prefix}/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = ${prefix}/info + +STD_INC = @sdcc_include_dir@ +CPPFLAGS = @CPPFLAGS@ -I. -I$(PRJDIR) -D_FORASXXXX_ +CFLAGS = @CFLAGS@ +M_OR_MM = @M_OR_MM@ +LDFLAGS = @LDFLAGS@ + +OBJECTS = cppalloc.o cpperror.o cppexp.o cpphash.o cpplib.o cppmain.o +SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) + +TARGET = $(PRJDIR)/bin/sdcpp + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) -o $@ $(OBJECTS) + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + $(INSTALL) -s $(TARGET) $(bindir)/sdcpp + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(bindir)/sdcpp + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + $(INSTALL) -d $(bindir) + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: $(SOURCES) *.h $(PRJDIR)/*.h + $(CPP) $(CPPFLAGS) $(M_OR_MM) $(SOURCES) >Makefile.dep + +include Makefile.dep +include clean.mk + +# My rules +# -------- +.c.o: + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of cpp/Makefile diff --git a/support/cpp/Makefile.org b/support/cpp/Makefile.org new file mode 100644 index 00000000..5779248f --- /dev/null +++ b/support/cpp/Makefile.org @@ -0,0 +1,14 @@ + + +YACC=bison +CC=gcc +LEX=flex +TARGETS=$(SDCCDIR)/bin/sdcpp +STD_INC=$(SDCCDIR)/sdcc51inc +CFLAGS=-I . -DSTANDARD_INCLUDE_DIR='"$(STD_INC)"' -O2 +ALLOBJECTS=cppalloc.o cpperror.o cppexp.o cpphash.o cpplib.o cppmain.o +all: $(TARGETS) + +${TARGETS}: ${ALLOBJECTS} + ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${ALLOBJECTS} + diff --git a/support/cpp/clean.mk b/support/cpp/clean.mk new file mode 100644 index 00000000..c94cd6c4 --- /dev/null +++ b/support/cpp/clean.mk @@ -0,0 +1,24 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f $(PRJDIR)/bin/sdcpp + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f config.cache config.log config.status + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/support/cpp/conf.mk b/support/cpp/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/support/cpp/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/support/cpp/config.h b/support/cpp/config.h new file mode 100644 index 00000000..c1bbb067 --- /dev/null +++ b/support/cpp/config.h @@ -0,0 +1,4 @@ +#include "i386/i386.h" +#include "i386/xm-linux.h" + +#define alloca malloc diff --git a/support/cpp/cpp.1 b/support/cpp/cpp.1 new file mode 100644 index 00000000..54c4dfb1 --- /dev/null +++ b/support/cpp/cpp.1 @@ -0,0 +1 @@ +.so man1/cccp.1 diff --git a/support/cpp/cpp.aux b/support/cpp/cpp.aux new file mode 100644 index 00000000..be541303 --- /dev/null +++ b/support/cpp/cpp.aux @@ -0,0 +1,132 @@ +'xrdef {Top-title}{The C Preprocessor} +'xrdef {Top-pg}{1} +'xrdef {Top-snt}{Chapter'tie1} +'xrdef {Global Actions-title}{Transformations Made Globally} +'xrdef {Global Actions-pg}{1} +'xrdef {Global Actions-snt}{Section'tie1.1} +'xrdef {Commands-title}{Preprocessor Commands} +'xrdef {Commands-pg}{3} +'xrdef {Commands-snt}{Section'tie1.2} +'xrdef {Header Files-title}{Header Files} +'xrdef {Header Files-pg}{3} +'xrdef {Header Files-snt}{Section'tie1.3} +'xrdef {Header Uses-title}{Uses of Header Files} +'xrdef {Header Uses-pg}{4} +'xrdef {Header Uses-snt}{Section'tie1.3.1} +'xrdef {Include Syntax-title}{The \samp {#include} Command} +'xrdef {Include Syntax-pg}{4} +'xrdef {Include Syntax-snt}{Section'tie1.3.2} +'xrdef {Include Operation-title}{How \samp {#include} Works} +'xrdef {Include Operation-pg}{5} +'xrdef {Include Operation-snt}{Section'tie1.3.3} +'xrdef {Once-Only-title}{Once-Only Include Files} +'xrdef {Once-Only-pg}{6} +'xrdef {Once-Only-snt}{Section'tie1.3.4} +'xrdef {Inheritance-title}{Inheritance and Header Files} +'xrdef {Inheritance-pg}{8} +'xrdef {Inheritance-snt}{Section'tie1.3.5} +'xrdef {Macros-title}{Macros} +'xrdef {Macros-pg}{9} +'xrdef {Macros-snt}{Section'tie1.4} +'xrdef {Simple Macros-title}{Simple Macros} +'xrdef {Simple Macros-pg}{9} +'xrdef {Simple Macros-snt}{Section'tie1.4.1} +'xrdef {Argument Macros-title}{Macros with Arguments} +'xrdef {Argument Macros-pg}{10} +'xrdef {Argument Macros-snt}{Section'tie1.4.2} +'xrdef {Predefined-title}{Predefined Macros} +'xrdef {Predefined-pg}{13} +'xrdef {Predefined-snt}{Section'tie1.4.3} +'xrdef {Standard Predefined-title}{Standard Predefined Macros} +'xrdef {Standard Predefined-pg}{13} +'xrdef {Standard Predefined-snt}{Section'tie1.4.3.1} +'xrdef {Nonstandard Predefined-title}{Nonstandard Predefined Macros} +'xrdef {Nonstandard Predefined-pg}{15} +'xrdef {Nonstandard Predefined-snt}{Section'tie1.4.3.2} +'xrdef {Stringification-title}{Stringification} +'xrdef {Stringification-pg}{17} +'xrdef {Stringification-snt}{Section'tie1.4.4} +'xrdef {Concatenation-title}{Concatenation} +'xrdef {Concatenation-pg}{18} +'xrdef {Concatenation-snt}{Section'tie1.4.5} +'xrdef {Undefining-title}{Undefining Macros} +'xrdef {Undefining-pg}{20} +'xrdef {Undefining-snt}{Section'tie1.4.6} +'xrdef {Redefining-title}{Redefining Macros} +'xrdef {Redefining-pg}{20} +'xrdef {Redefining-snt}{Section'tie1.4.7} +'xrdef {Macro Pitfalls-title}{Pitfalls and Subtleties of Macros} +'xrdef {Macro Pitfalls-pg}{21} +'xrdef {Macro Pitfalls-snt}{Section'tie1.4.8} +'xrdef {Misnesting-title}{Improperly Nested Constructs} +'xrdef {Misnesting-pg}{21} +'xrdef {Misnesting-snt}{Section'tie1.4.8.1} +'xrdef {Macro Parentheses-title}{Unintended Grouping of Arithmetic} +'xrdef {Macro Parentheses-pg}{22} +'xrdef {Macro Parentheses-snt}{Section'tie1.4.8.2} +'xrdef {Swallow Semicolon-title}{Swallowing the Semicolon} +'xrdef {Swallow Semicolon-pg}{23} +'xrdef {Swallow Semicolon-snt}{Section'tie1.4.8.3} +'xrdef {Side Effects-title}{Duplication of Side Effects} +'xrdef {Side Effects-pg}{24} +'xrdef {Side Effects-snt}{Section'tie1.4.8.4} +'xrdef {Self-Reference-title}{Self-Referential Macros} +'xrdef {Self-Reference-pg}{25} +'xrdef {Self-Reference-snt}{Section'tie1.4.8.5} +'xrdef {Argument Prescan-title}{Separate Expansion of Macro Arguments} +'xrdef {Argument Prescan-pg}{26} +'xrdef {Argument Prescan-snt}{Section'tie1.4.8.6} +'xrdef {Cascaded Macros-title}{Cascaded Use of Macros} +'xrdef {Cascaded Macros-pg}{29} +'xrdef {Cascaded Macros-snt}{Section'tie1.4.8.7} +'xrdef {Newlines in Args-title}{Newlines in Macro Arguments} +'xrdef {Newlines in Args-pg}{30} +'xrdef {Newlines in Args-snt}{Section'tie1.4.9} +'xrdef {Conditionals-title}{Conditionals} +'xrdef {Conditionals-pg}{30} +'xrdef {Conditionals-snt}{Section'tie1.5} +'xrdef {Conditional Uses-title}{Why Conditionals are Used} +'xrdef {Conditional Uses-pg}{31} +'xrdef {Conditional Uses-snt}{Section'tie1.5.1} +'xrdef {Conditional Syntax-title}{Syntax of Conditionals} +'xrdef {Conditional Syntax-pg}{31} +'xrdef {Conditional Syntax-snt}{Section'tie1.5.2} +'xrdef {#if Command-title}{The \samp {#if} Command} +'xrdef {#if Command-pg}{31} +'xrdef {#if Command-snt}{Section'tie1.5.2.1} +'xrdef {#else Command-title}{The \samp {#else} Command} +'xrdef {#else Command-pg}{32} +'xrdef {#else Command-snt}{Section'tie1.5.2.2} +'xrdef {#elif Command-title}{The \samp {#elif} Command} +'xrdef {#elif Command-pg}{33} +'xrdef {#elif Command-snt}{Section'tie1.5.2.3} +'xrdef {Deleted Code-title}{Keeping Deleted Code for Future Reference} +'xrdef {Deleted Code-pg}{34} +'xrdef {Deleted Code-snt}{Section'tie1.5.3} +'xrdef {Conditionals-Macros-title}{Conditionals and Macros} +'xrdef {Conditionals-Macros-pg}{34} +'xrdef {Conditionals-Macros-snt}{Section'tie1.5.4} +'xrdef {Assertions-title}{Assertions} +'xrdef {Assertions-pg}{36} +'xrdef {Assertions-snt}{Section'tie1.5.5} +'xrdef {#error Command-title}{The \samp {#error} and \samp {#warning} Commands} +'xrdef {#error Command-pg}{38} +'xrdef {#error Command-snt}{Section'tie1.5.6} +'xrdef {Combining Sources-title}{Combining Source Files} +'xrdef {Combining Sources-pg}{39} +'xrdef {Combining Sources-snt}{Section'tie1.6} +'xrdef {Other Commands-title}{Miscellaneous Preprocessor Commands} +'xrdef {Other Commands-pg}{40} +'xrdef {Other Commands-snt}{Section'tie1.7} +'xrdef {Output-title}{C Preprocessor Output} +'xrdef {Output-pg}{41} +'xrdef {Output-snt}{Section'tie1.8} +'xrdef {Invocation-title}{Invoking the C Preprocessor} +'xrdef {Invocation-pg}{41} +'xrdef {Invocation-snt}{Section'tie1.9} +'xrdef {Concept Index-title}{Concept Index} +'xrdef {Concept Index-pg}{47} +'xrdef {Concept Index-snt}{} +'xrdef {Index-title}{Index of Commands, Macros and Options} +'xrdef {Index-pg}{49} +'xrdef {Index-snt}{} diff --git a/support/cpp/cpp.cps b/support/cpp/cpp.cps new file mode 100644 index 00000000..63ca498f --- /dev/null +++ b/support/cpp/cpp.cps @@ -0,0 +1,66 @@ +\initial {#} +\entry {\samp {##}}{18} +\initial {A} +\entry {arguments in macro definitions}{10} +\entry {assertions}{36} +\entry {assertions, undoing}{37} +\initial {B} +\entry {blank macro arguments}{12} +\initial {C} +\entry {cascaded macros}{29} +\entry {commands}{3} +\entry {commenting out code}{34} +\entry {computed \samp {#include}}{5} +\entry {concatenation}{18} +\entry {conditionals}{30} +\initial {E} +\entry {expansion of arguments}{26} +\initial {F} +\entry {function-like macro}{10} +\initial {H} +\entry {header file}{3} +\initial {I} +\entry {including just once}{6} +\entry {inheritance}{8} +\entry {invocation of the preprocessor}{41} +\initial {L} +\entry {line control}{39} +\initial {M} +\entry {macro argument expansion}{26} +\entry {macro body uses macro}{29} +\entry {macros with argument}{10} +\entry {manifest constant}{9} +\initial {N} +\entry {newlines in macro arguments}{30} +\entry {null command}{40} +\initial {O} +\entry {options}{41} +\entry {output format}{41} +\entry {overriding a header file}{8} +\initial {P} +\entry {parentheses in macro bodies}{22} +\entry {pitfalls of macros}{21} +\entry {predefined macros}{13} +\entry {predicates}{36} +\entry {preprocessor commands}{3} +\entry {prescan of macro arguments}{26} +\entry {problems with macros}{21} +\initial {R} +\entry {redefining macros}{20} +\entry {repeated inclusion}{6} +\entry {retracting assertions}{37} +\initial {S} +\entry {second include path}{45} +\entry {self-reference}{25} +\entry {semicolons (after macro calls)}{23} +\entry {side effects (in macro arguments)}{24} +\entry {simple macro}{9} +\entry {space as macro argument}{12} +\entry {standard predefined macros}{13} +\entry {stringification}{17} +\initial {T} +\entry {testing predicates}{36} +\initial {U} +\entry {unassert}{37} +\entry {undefining macros}{20} +\entry {unsafe macros}{24} diff --git a/support/cpp/cpp.fns b/support/cpp/cpp.fns new file mode 100644 index 00000000..849b4b26 --- /dev/null +++ b/support/cpp/cpp.fns @@ -0,0 +1,94 @@ +\initial {#} +\entry {\code {#assert}}{37} +\entry {\code {#cpu}}{36} +\entry {\code {#define}}{10} +\entry {\code {#elif}}{33} +\entry {\code {#else}}{32} +\entry {\code {#error}}{38} +\entry {\code {#ident}}{40} +\entry {\code {#if}}{31} +\entry {\code {#ifdef}}{35} +\entry {\code {#ifndef}}{35} +\entry {\code {#import}}{7} +\entry {\code {#include}}{4} +\entry {\code {#include{\_}next}}{8} +\entry {\code {#line}}{39} +\entry {\code {#machine}}{36} +\entry {\code {#pragma}}{40} +\entry {\code {#pragma once}}{7} +\entry {\code {#system}}{36} +\entry {\code {#unassert}}{37} +\entry {\code {#warning}}{38} +\initial {-} +\entry {\code {-$}}{46} +\entry {\code {-A}}{44} +\entry {\code {-C}}{42} +\entry {\code {-D}}{43} +\entry {\code {-dD}}{44} +\entry {\code {-dM}}{44} +\entry {\code {-H}}{45} +\entry {\code {-I}}{43} +\entry {\code {-idirafter}}{45} +\entry {\code {-imacros}}{45} +\entry {\code {-include}}{45} +\entry {\code {-iprefix}}{45} +\entry {\code {-isystem}}{45} +\entry {\code {-iwithprefix}}{45} +\entry {\code {-lang-c}}{45} +\entry {\code {-lang-c{\tt\char43}{\tt\char43}}}{45} +\entry {\code {-lang-objc}}{45} +\entry {\code {-lang-objc{\tt\char43}{\tt\char43}}}{45} +\entry {\code {-M}}{44} +\entry {\code {-MD}}{44} +\entry {\code {-MM}}{44} +\entry {\code {-MMD}}{45} +\entry {\code {-nostdinc}}{43} +\entry {\code {-nostdinc{\tt\char43}{\tt\char43}}}{43} +\entry {\code {-P}}{42} +\entry {\code {-pedantic}}{43} +\entry {\code {-pedantic-errors}}{43} +\entry {\code {-traditional}}{42} +\entry {\code {-trigraphs}}{42} +\entry {\code {-U}}{44} +\entry {\code {-undef}}{44} +\entry {\code {-Wall}}{43} +\entry {\code {-Wcomment}}{43} +\entry {\code {-Wtraditional}}{43} +\entry {\code {-Wtrigraphs}}{43} +\initial {{\_}} +\entry {\code {{\_}{\_}BASE{\_}FILE{\_}{\_}}}{15} +\entry {\code {{\_}{\_}CHAR{\_}UNSIGNED{\_}{\_}}}{15} +\entry {\code {{\_}{\_}cplusplus}}{14} +\entry {\code {{\_}{\_}DATE{\_}{\_}}}{14} +\entry {\code {{\_}{\_}FILE{\_}{\_}}}{13} +\entry {\code {{\_}{\_}GNUC{\_}{\_}}}{14} +\entry {\code {{\_}{\_}GNUG{\_}{\_}}}{14} +\entry {\code {{\_}{\_}INCLUDE{\_}LEVEL{\_}}}{14} +\entry {\code {{\_}{\_}LINE{\_}{\_}}}{13} +\entry {\code {{\_}{\_}OPTIMIZE{\_}{\_}}}{15} +\entry {\code {{\_}{\_}STDC{\_}{\_}}}{14} +\entry {\code {{\_}{\_}STRICT{\_}ANSI{\_}{\_}}}{15} +\entry {\code {{\_}{\_}TIME{\_}{\_}}}{14} +\entry {\code {{\_}{\_}VERSION{\_}{\_}}}{15} +\entry {\code {{\_}AM29000}}{16} +\entry {\code {{\_}AM29K}}{16} +\initial {B} +\entry {\code {BSD}}{16} +\initial {D} +\entry {\code {defined}}{34} +\initial {M} +\entry {\code {M68020}}{16} +\entry {\code {m68k}}{16} +\entry {\code {mc68000}}{16} +\initial {N} +\entry {\code {ns32000}}{16} +\initial {P} +\entry {\code {pyr}}{16} +\initial {S} +\entry {\code {sequent}}{16} +\entry {\code {sun}}{16} +\entry {\code {system header files}}{4} +\initial {U} +\entry {\code {unix}}{16} +\initial {V} +\entry {\code {vax}}{16} diff --git a/support/cpp/cpp.info b/support/cpp/cpp.info new file mode 100644 index 00000000..7ab558bd --- /dev/null +++ b/support/cpp/cpp.info @@ -0,0 +1,75 @@ +This is Info file cpp.info, produced by Makeinfo version 1.67 from the +input file cpp.texi. + + This file documents the GNU C Preprocessor. + + Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software +Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +Indirect: +cpp.info-1: 798 +cpp.info-2: 50204 +cpp.info-3: 90189 + +Tag Table: +(Indirect) +Node: Top798 +Node: Global Actions3370 +Node: Directives5890 +Node: Header Files7577 +Node: Header Uses8236 +Node: Include Syntax9728 +Node: Include Operation12870 +Node: Once-Only14732 +Node: Inheritance17157 +Node: Macros19719 +Node: Simple Macros20633 +Node: Argument Macros23621 +Node: Predefined29419 +Node: Standard Predefined29849 +Node: Nonstandard Predefined36986 +Node: Stringification40562 +Node: Concatenation43488 +Node: Undefining46761 +Node: Redefining47800 +Node: Macro Pitfalls49100 +Node: Misnesting50204 +Node: Macro Parentheses51218 +Node: Swallow Semicolon53095 +Node: Side Effects54995 +Node: Self-Reference56693 +Node: Argument Prescan58969 +Node: Cascaded Macros63971 +Node: Newlines in Args65116 +Node: Conditionals66461 +Node: Conditional Uses67813 +Node: Conditional Syntax69236 +Node: #if Directive69822 +Node: #else Directive72111 +Node: #elif Directive72778 +Node: Deleted Code74156 +Node: Conditionals-Macros75217 +Node: Assertions78902 +Node: #error Directive83137 +Node: Combining Sources84577 +Node: Other Directives87488 +Node: Output88950 +Node: Invocation90189 +Node: Concept Index102013 +Node: Index104866 + +End Tag Table diff --git a/support/cpp/cpp.info-1 b/support/cpp/cpp.info-1 new file mode 100644 index 00000000..d7694a77 --- /dev/null +++ b/support/cpp/cpp.info-1 @@ -0,0 +1,1189 @@ +This is Info file cpp.info, produced by Makeinfo version 1.67 from the +input file cpp.texi. + + This file documents the GNU C Preprocessor. + + Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software +Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: cpp.info, Node: Top, Next: Global Actions, Up: (DIR) + +The C Preprocessor +****************** + + The C preprocessor is a "macro processor" that is used automatically +by the C compiler to transform your program before actual compilation. +It is called a macro processor because it allows you to define "macros", +which are brief abbreviations for longer constructs. + + The C preprocessor provides four separate facilities that you can +use as you see fit: + + * Inclusion of header files. These are files of declarations that + can be substituted into your program. + + * Macro expansion. You can define "macros", which are abbreviations + for arbitrary fragments of C code, and then the C preprocessor will + replace the macros with their definitions throughout the program. + + * Conditional compilation. Using special preprocessing directives, + you can include or exclude parts of the program according to + various conditions. + + * Line control. If you use a program to combine or rearrange source + files into an intermediate file which is then compiled, you can + use line control to inform the compiler of where each source line + originally came from. + + C preprocessors vary in some details. This manual discusses the GNU +C preprocessor, the C Compatible Compiler Preprocessor. The GNU C +preprocessor provides a superset of the features of ANSI Standard C. + + ANSI Standard C requires the rejection of many harmless constructs +commonly used by today's C programs. Such incompatibility would be +inconvenient for users, so the GNU C preprocessor is configured to +accept these constructs by default. Strictly speaking, to get ANSI +Standard C, you must use the options `-trigraphs', `-undef' and +`-pedantic', but in practice the consequences of having strict ANSI +Standard C make it undesirable to do this. *Note Invocation::. + +* Menu: + +* Global Actions:: Actions made uniformly on all input files. +* Directives:: General syntax of preprocessing directives. +* Header Files:: How and why to use header files. +* Macros:: How and why to use macros. +* Conditionals:: How and why to use conditionals. +* Combining Sources:: Use of line control when you combine source files. +* Other Directives:: Miscellaneous preprocessing directives. +* Output:: Format of output from the C preprocessor. +* Invocation:: How to invoke the preprocessor; command options. +* Concept Index:: Index of concepts and terms. +* Index:: Index of directives, predefined macros and options. + + +File: cpp.info, Node: Global Actions, Next: Directives, Prev: Top, Up: Top + +Transformations Made Globally +============================= + + Most C preprocessor features are inactive unless you give specific +directives to request their use. (Preprocessing directives are lines +starting with `#'; *note Directives::.). But there are three +transformations that the preprocessor always makes on all the input it +receives, even in the absence of directives. + + * All C comments are replaced with single spaces. + + * Backslash-Newline sequences are deleted, no matter where. This + feature allows you to break long lines for cosmetic purposes + without changing their meaning. + + * Predefined macro names are replaced with their expansions (*note + Predefined::.). + + The first two transformations are done *before* nearly all other +parsing and before preprocessing directives are recognized. Thus, for +example, you can split a line cosmetically with Backslash-Newline +anywhere (except when trigraphs are in use; see below). + + /* + */ # /* + */ defi\ + ne FO\ + O 10\ + 20 + +is equivalent into `#define FOO 1020'. You can split even an escape +sequence with Backslash-Newline. For example, you can split `"foo\bar"' +between the `\' and the `b' to get + + "foo\\ + bar" + +This behavior is unclean: in all other contexts, a Backslash can be +inserted in a string constant as an ordinary character by writing a +double Backslash, and this creates an exception. But the ANSI C +standard requires it. (Strict ANSI C does not allow Newlines in string +constants, so they do not consider this a problem.) + + But there are a few exceptions to all three transformations. + + * C comments and predefined macro names are not recognized inside a + `#include' directive in which the file name is delimited with `<' + and `>'. + + * C comments and predefined macro names are never recognized within a + character or string constant. (Strictly speaking, this is the + rule, not an exception, but it is worth noting here anyway.) + + * Backslash-Newline may not safely be used within an ANSI "trigraph". + Trigraphs are converted before Backslash-Newline is deleted. If + you write what looks like a trigraph with a Backslash-Newline + inside, the Backslash-Newline is deleted as usual, but it is then + too late to recognize the trigraph. + + This exception is relevant only if you use the `-trigraphs' option + to enable trigraph processing. *Note Invocation::. + + +File: cpp.info, Node: Directives, Next: Header Files, Prev: Global Actions, Up: Top + +Preprocessing Directives +======================== + + Most preprocessor features are active only if you use preprocessing +directives to request their use. + + Preprocessing directives are lines in your program that start with +`#'. The `#' is followed by an identifier that is the "directive name". +For example, `#define' is the directive that defines a macro. +Whitespace is also allowed before and after the `#'. + + The set of valid directive names is fixed. Programs cannot define +new preprocessing directives. + + Some directive names require arguments; these make up the rest of +the directive line and must be separated from the directive name by +whitespace. For example, `#define' must be followed by a macro name +and the intended expansion of the macro. *Note Simple Macros::. + + A preprocessing directive cannot be more than one line in normal +circumstances. It may be split cosmetically with Backslash-Newline, +but that has no effect on its meaning. Comments containing Newlines +can also divide the directive into multiple lines, but the comments are +changed to Spaces before the directive is interpreted. The only way a +significant Newline can occur in a preprocessing directive is within a +string constant or character constant. Note that most C compilers that +might be applied to the output from the preprocessor do not accept +string or character constants containing Newlines. + + The `#' and the directive name cannot come from a macro expansion. +For example, if `foo' is defined as a macro expanding to `define', that +does not make `#foo' a valid preprocessing directive. + + +File: cpp.info, Node: Header Files, Next: Macros, Prev: Directives, Up: Top + +Header Files +============ + + A header file is a file containing C declarations and macro +definitions (*note Macros::.) to be shared between several source +files. You request the use of a header file in your program with the C +preprocessing directive `#include'. + +* Menu: + +* Header Uses:: What header files are used for. +* Include Syntax:: How to write `#include' directives. +* Include Operation:: What `#include' does. +* Once-Only:: Preventing multiple inclusion of one header file. +* Inheritance:: Including one header file in another header file. + + +File: cpp.info, Node: Header Uses, Next: Include Syntax, Prev: Header Files, Up: Header Files + +Uses of Header Files +-------------------- + + Header files serve two kinds of purposes. + + * System header files declare the interfaces to parts of the + operating system. You include them in your program to supply the + definitions and declarations you need to invoke system calls and + libraries. + + * Your own header files contain declarations for interfaces between + the source files of your program. Each time you have a group of + related declarations and macro definitions all or most of which + are needed in several different source files, it is a good idea to + create a header file for them. + + Including a header file produces the same results in C compilation as +copying the header file into each source file that needs it. But such +copying would be time-consuming and error-prone. With a header file, +the related declarations appear in only one place. If they need to be +changed, they can be changed in one place, and programs that include +the header file will automatically use the new version when next +recompiled. The header file eliminates the labor of finding and +changing all the copies as well as the risk that a failure to find one +copy will result in inconsistencies within a program. + + The usual convention is to give header files names that end with +`.h'. Avoid unusual characters in header file names, as they reduce +portability. + + +File: cpp.info, Node: Include Syntax, Next: Include Operation, Prev: Header Uses, Up: Header Files + +The `#include' Directive +------------------------ + + Both user and system header files are included using the +preprocessing directive `#include'. It has three variants: + +`#include ' + This variant is used for system header files. It searches for a + file named FILE in a list of directories specified by you, then in + a standard list of system directories. You specify directories to + search for header files with the command option `-I' (*note + Invocation::.). The option `-nostdinc' inhibits searching the + standard system directories; in this case only the directories you + specify are searched. + + The parsing of this form of `#include' is slightly special because + comments are not recognized within the `<...>'. Thus, in + `#include ' the `/*' does not start a comment and the + directive specifies inclusion of a system header file named + `x/*y'. Of course, a header file with such a name is unlikely to + exist on Unix, where shell wildcard features would make it hard to + manipulate. + + The argument FILE may not contain a `>' character. It may, + however, contain a `<' character. + +`#include "FILE"' + This variant is used for header files of your own program. It + searches for a file named FILE first in the current directory, + then in the same directories used for system header files. The + current directory is the directory of the current input file. It + is tried first because it is presumed to be the location of the + files that the current input file refers to. (If the `-I-' option + is used, the special treatment of the current directory is + inhibited.) + + The argument FILE may not contain `"' characters. If backslashes + occur within FILE, they are considered ordinary text characters, + not escape characters. None of the character escape sequences + appropriate to string constants in C are processed. Thus, + `#include "x\n\\y"' specifies a filename containing three + backslashes. It is not clear why this behavior is ever useful, but + the ANSI standard specifies it. + +`#include ANYTHING ELSE' + This variant is called a "computed #include". Any `#include' + directive whose argument does not fit the above two forms is a + computed include. The text ANYTHING ELSE is checked for macro + calls, which are expanded (*note Macros::.). When this is done, + the result must fit one of the above two variants--in particular, + the expanded text must in the end be surrounded by either quotes + or angle braces. + + This feature allows you to define a macro which controls the file + name to be used at a later point in the program. One application + of this is to allow a site-specific configuration file for your + program to specify the names of the system include files to be + used. This can help in porting the program to various operating + systems in which the necessary system header files are found in + different places. + + +File: cpp.info, Node: Include Operation, Next: Once-Only, Prev: Include Syntax, Up: Header Files + +How `#include' Works +-------------------- + + The `#include' directive works by directing the C preprocessor to +scan the specified file as input before continuing with the rest of the +current file. The output from the preprocessor contains the output +already generated, followed by the output resulting from the included +file, followed by the output that comes from the text after the +`#include' directive. For example, given a header file `header.h' as +follows, + + char *test (); + +and a main program called `program.c' that uses the header file, like +this, + + int x; + #include "header.h" + + main () + { + printf (test ()); + } + +the output generated by the C preprocessor for `program.c' as input +would be + + int x; + char *test (); + + main () + { + printf (test ()); + } + + Included files are not limited to declarations and macro +definitions; those are merely the typical uses. Any fragment of a C +program can be included from another file. The include file could even +contain the beginning of a statement that is concluded in the +containing file, or the end of a statement that was started in the +including file. However, a comment or a string or character constant +may not start in the included file and finish in the including file. +An unterminated comment, string constant or character constant in an +included file is considered to end (with an error message) at the end +of the file. + + It is possible for a header file to begin or end a syntactic unit +such as a function definition, but that would be very confusing, so +don't do it. + + The line following the `#include' directive is always treated as a +separate line by the C preprocessor even if the included file lacks a +final newline. + + +File: cpp.info, Node: Once-Only, Next: Inheritance, Prev: Include Operation, Up: Header Files + +Once-Only Include Files +----------------------- + + Very often, one header file includes another. It can easily result +that a certain header file is included more than once. This may lead +to errors, if the header file defines structure types or typedefs, and +is certainly wasteful. Therefore, we often wish to prevent multiple +inclusion of a header file. + + The standard way to do this is to enclose the entire real contents +of the file in a conditional, like this: + + #ifndef FILE_FOO_SEEN + #define FILE_FOO_SEEN + + THE ENTIRE FILE + + #endif /* FILE_FOO_SEEN */ + + The macro `FILE_FOO_SEEN' indicates that the file has been included +once already. In a user header file, the macro name should not begin +with `_'. In a system header file, this name should begin with `__' to +avoid conflicts with user programs. In any kind of header file, the +macro name should contain the name of the file and some additional +text, to avoid conflicts with other header files. + + The GNU C preprocessor is programmed to notice when a header file +uses this particular construct and handle it efficiently. If a header +file is contained entirely in a `#ifndef' conditional, then it records +that fact. If a subsequent `#include' specifies the same file, and the +macro in the `#ifndef' is already defined, then the file is entirely +skipped, without even reading it. + + There is also an explicit directive to tell the preprocessor that it +need not include a file more than once. This is called `#pragma once', +and was used *in addition to* the `#ifndef' conditional around the +contents of the header file. `#pragma once' is now obsolete and should +not be used at all. + + In the Objective C language, there is a variant of `#include' called +`#import' which includes a file, but does so at most once. If you use +`#import' *instead of* `#include', then you don't need the conditionals +inside the header file to prevent multiple execution of the contents. + + `#import' is obsolete because it is not a well designed feature. It +requires the users of a header file--the applications programmers--to +know that a certain header file should only be included once. It is +much better for the header file's implementor to write the file so that +users don't need to know this. Using `#ifndef' accomplishes this goal. + + +File: cpp.info, Node: Inheritance, Prev: Once-Only, Up: Header Files + +Inheritance and Header Files +---------------------------- + + "Inheritance" is what happens when one object or file derives some +of its contents by virtual copying from another object or file. In the +case of C header files, inheritance means that one header file includes +another header file and then replaces or adds something. + + If the inheriting header file and the base header file have different +names, then inheritance is straightforward: simply write `#include +"BASE"' in the inheriting file. + + Sometimes it is necessary to give the inheriting file the same name +as the base file. This is less straightforward. + + For example, suppose an application program uses the system header +file `sys/signal.h', but the version of `/usr/include/sys/signal.h' on +a particular system doesn't do what the application program expects. +It might be convenient to define a "local" version, perhaps under the +name `/usr/local/include/sys/signal.h', to override or add to the one +supplied by the system. + + You can do this by using the option `-I.' for compilation, and +writing a file `sys/signal.h' that does what the application program +expects. But making this file include the standard `sys/signal.h' is +not so easy--writing `#include ' in that file doesn't +work, because it includes your own version of the file, not the +standard system version. Used in that file itself, this leads to an +infinite recursion and a fatal error in compilation. + + `#include ' would find the proper file, +but that is not clean, since it makes an assumption about where the +system header file is found. This is bad for maintenance, since it +means that any change in where the system's header files are kept +requires a change somewhere else. + + The clean way to solve this problem is to use `#include_next', which +means, "Include the *next* file with this name." This directive works +like `#include' except in searching for the specified file: it starts +searching the list of header file directories *after* the directory in +which the current file was found. + + Suppose you specify `-I /usr/local/include', and the list of +directories to search also includes `/usr/include'; and suppose that +both directories contain a file named `sys/signal.h'. Ordinary +`#include ' finds the file under `/usr/local/include'. +If that file contains `#include_next ', it starts +searching after that directory, and finds the file in `/usr/include'. + + +File: cpp.info, Node: Macros, Next: Conditionals, Prev: Header Files, Up: Top + +Macros +====== + + A macro is a sort of abbreviation which you can define once and then +use later. There are many complicated features associated with macros +in the C preprocessor. + +* Menu: + +* Simple Macros:: Macros that always expand the same way. +* Argument Macros:: Macros that accept arguments that are substituted + into the macro expansion. +* Predefined:: Predefined macros that are always available. +* Stringification:: Macro arguments converted into string constants. +* Concatenation:: Building tokens from parts taken from macro arguments. +* Undefining:: Cancelling a macro's definition. +* Redefining:: Changing a macro's definition. +* Macro Pitfalls:: Macros can confuse the unwary. Here we explain + several common problems and strange features. + + +File: cpp.info, Node: Simple Macros, Next: Argument Macros, Prev: Macros, Up: Macros + +Simple Macros +------------- + + A "simple macro" is a kind of abbreviation. It is a name which +stands for a fragment of code. Some people refer to these as "manifest +constants". + + Before you can use a macro, you must "define" it explicitly with the +`#define' directive. `#define' is followed by the name of the macro +and then the code it should be an abbreviation for. For example, + + #define BUFFER_SIZE 1020 + +defines a macro named `BUFFER_SIZE' as an abbreviation for the text +`1020'. If somewhere after this `#define' directive there comes a C +statement of the form + + foo = (char *) xmalloc (BUFFER_SIZE); + +then the C preprocessor will recognize and "expand" the macro +`BUFFER_SIZE', resulting in + + foo = (char *) xmalloc (1020); + + The use of all upper case for macro names is a standard convention. +Programs are easier to read when it is possible to tell at a glance +which names are macros. + + Normally, a macro definition must be a single line, like all C +preprocessing directives. (You can split a long macro definition +cosmetically with Backslash-Newline.) There is one exception: Newlines +can be included in the macro definition if within a string or character +constant. This is because it is not possible for a macro definition to +contain an unbalanced quote character; the definition automatically +extends to include the matching quote character that ends the string or +character constant. Comments within a macro definition may contain +Newlines, which make no difference since the comments are entirely +replaced with Spaces regardless of their contents. + + Aside from the above, there is no restriction on what can go in a +macro body. Parentheses need not balance. The body need not resemble +valid C code. (But if it does not, you may get error messages from the +C compiler when you use the macro.) + + The C preprocessor scans your program sequentially, so macro +definitions take effect at the place you write them. Therefore, the +following input to the C preprocessor + + foo = X; + #define X 4 + bar = X; + +produces as output + + foo = X; + + bar = 4; + + After the preprocessor expands a macro name, the macro's definition +body is appended to the front of the remaining input, and the check for +macro calls continues. Therefore, the macro body can contain calls to +other macros. For example, after + + #define BUFSIZE 1020 + #define TABLESIZE BUFSIZE + +the name `TABLESIZE' when used in the program would go through two +stages of expansion, resulting ultimately in `1020'. + + This is not at all the same as defining `TABLESIZE' to be `1020'. +The `#define' for `TABLESIZE' uses exactly the body you specify--in +this case, `BUFSIZE'--and does not check to see whether it too is the +name of a macro. It's only when you *use* `TABLESIZE' that the result +of its expansion is checked for more macro names. *Note Cascaded +Macros::. + + +File: cpp.info, Node: Argument Macros, Next: Predefined, Prev: Simple Macros, Up: Macros + +Macros with Arguments +--------------------- + + A simple macro always stands for exactly the same text, each time it +is used. Macros can be more flexible when they accept "arguments". +Arguments are fragments of code that you supply each time the macro is +used. These fragments are included in the expansion of the macro +according to the directions in the macro definition. A macro that +accepts arguments is called a "function-like macro" because the syntax +for using it looks like a function call. + + To define a macro that uses arguments, you write a `#define' +directive with a list of "argument names" in parentheses after the name +of the macro. The argument names may be any valid C identifiers, +separated by commas and optionally whitespace. The open-parenthesis +must follow the macro name immediately, with no space in between. + + For example, here is a macro that computes the minimum of two numeric +values, as it is defined in many C programs: + + #define min(X, Y) ((X) < (Y) ? (X) : (Y)) + +(This is not the best way to define a "minimum" macro in GNU C. *Note +Side Effects::, for more information.) + + To use a macro that expects arguments, you write the name of the +macro followed by a list of "actual arguments" in parentheses, +separated by commas. The number of actual arguments you give must +match the number of arguments the macro expects. Examples of use of +the macro `min' include `min (1, 2)' and `min (x + 28, *p)'. + + The expansion text of the macro depends on the arguments you use. +Each of the argument names of the macro is replaced, throughout the +macro definition, with the corresponding actual argument. Using the +same macro `min' defined above, `min (1, 2)' expands into + + ((1) < (2) ? (1) : (2)) + +where `1' has been substituted for `X' and `2' for `Y'. + + Likewise, `min (x + 28, *p)' expands into + + ((x + 28) < (*p) ? (x + 28) : (*p)) + + Parentheses in the actual arguments must balance; a comma within +parentheses does not end an argument. However, there is no requirement +for brackets or braces to balance, and they do not prevent a comma from +separating arguments. Thus, + + macro (array[x = y, x + 1]) + +passes two arguments to `macro': `array[x = y' and `x + 1]'. If you +want to supply `array[x = y, x + 1]' as an argument, you must write it +as `array[(x = y, x + 1)]', which is equivalent C code. + + After the actual arguments are substituted into the macro body, the +entire result is appended to the front of the remaining input, and the +check for macro calls continues. Therefore, the actual arguments can +contain calls to other macros, either with or without arguments, or +even to the same macro. The macro body can also contain calls to other +macros. For example, `min (min (a, b), c)' expands into this text: + + ((((a) < (b) ? (a) : (b))) < (c) + ? (((a) < (b) ? (a) : (b))) + : (c)) + +(Line breaks shown here for clarity would not actually be generated.) + + If a macro `foo' takes one argument, and you want to supply an empty +argument, you must write at least some whitespace between the +parentheses, like this: `foo ( )'. Just `foo ()' is providing no +arguments, which is an error if `foo' expects an argument. But `foo0 +()' is the correct way to call a macro defined to take zero arguments, +like this: + + #define foo0() ... + + If you use the macro name followed by something other than an +open-parenthesis (after ignoring any spaces, tabs and comments that +follow), it is not a call to the macro, and the preprocessor does not +change what you have written. Therefore, it is possible for the same +name to be a variable or function in your program as well as a macro, +and you can choose in each instance whether to refer to the macro (if +an actual argument list follows) or the variable or function (if an +argument list does not follow). + + Such dual use of one name could be confusing and should be avoided +except when the two meanings are effectively synonymous: that is, when +the name is both a macro and a function and the two have similar +effects. You can think of the name simply as a function; use of the +name for purposes other than calling it (such as, to take the address) +will refer to the function, while calls will expand the macro and +generate better but equivalent code. For example, you can use a +function named `min' in the same source file that defines the macro. +If you write `&min' with no argument list, you refer to the function. +If you write `min (x, bb)', with an argument list, the macro is +expanded. If you write `(min) (a, bb)', where the name `min' is not +followed by an open-parenthesis, the macro is not expanded, so you wind +up with a call to the function `min'. + + You may not define the same name as both a simple macro and a macro +with arguments. + + In the definition of a macro with arguments, the list of argument +names must follow the macro name immediately with no space in between. +If there is a space after the macro name, the macro is defined as +taking no arguments, and all the rest of the line is taken to be the +expansion. The reason for this is that it is often useful to define a +macro that takes no arguments and whose definition begins with an +identifier in parentheses. This rule about spaces makes it possible +for you to do either this: + + #define FOO(x) - 1 / (x) + +(which defines `FOO' to take an argument and expand into minus the +reciprocal of that argument) or this: + + #define BAR (x) - 1 / (x) + +(which defines `BAR' to take no argument and always expand into `(x) - +1 / (x)'). + + Note that the *uses* of a macro with arguments can have spaces before +the left parenthesis; it's the *definition* where it matters whether +there is a space. + + +File: cpp.info, Node: Predefined, Next: Stringification, Prev: Argument Macros, Up: Macros + +Predefined Macros +----------------- + + Several simple macros are predefined. You can use them without +giving definitions for them. They fall into two classes: standard +macros and system-specific macros. + +* Menu: + +* Standard Predefined:: Standard predefined macros. +* Nonstandard Predefined:: Nonstandard predefined macros. + + +File: cpp.info, Node: Standard Predefined, Next: Nonstandard Predefined, Prev: Predefined, Up: Predefined + +Standard Predefined Macros +.......................... + + The standard predefined macros are available with the same meanings +regardless of the machine or operating system on which you are using +GNU C. Their names all start and end with double underscores. Those +preceding `__GNUC__' in this table are standardized by ANSI C; the rest +are GNU C extensions. + +`__FILE__' + This macro expands to the name of the current input file, in the + form of a C string constant. The precise name returned is the one + that was specified in `#include' or as the input file name + argument. + +`__LINE__' + This macro expands to the current input line number, in the form + of a decimal integer constant. While we call it a predefined + macro, it's a pretty strange macro, since its "definition" changes + with each new line of source code. + + This and `__FILE__' are useful in generating an error message to + report an inconsistency detected by the program; the message can + state the source line at which the inconsistency was detected. + For example, + + fprintf (stderr, "Internal error: " + "negative string length " + "%d at %s, line %d.", + length, __FILE__, __LINE__); + + A `#include' directive changes the expansions of `__FILE__' and + `__LINE__' to correspond to the included file. At the end of that + file, when processing resumes on the input file that contained the + `#include' directive, the expansions of `__FILE__' and `__LINE__' + revert to the values they had before the `#include' (but + `__LINE__' is then incremented by one as processing moves to the + line after the `#include'). + + The expansions of both `__FILE__' and `__LINE__' are altered if a + `#line' directive is used. *Note Combining Sources::. + +`__DATE__' + This macro expands to a string constant that describes the date on + which the preprocessor is being run. The string constant contains + eleven characters and looks like `"Jan 29 1987"' or `"Apr 1 1905"'. + +`__TIME__' + This macro expands to a string constant that describes the time at + which the preprocessor is being run. The string constant contains + eight characters and looks like `"23:59:01"'. + +`__STDC__' + This macro expands to the constant 1, to signify that this is ANSI + Standard C. (Whether that is actually true depends on what C + compiler will operate on the output from the preprocessor.) + +`__STDC_VERSION__' + This macro expands to the C Standard's version number, a long + integer constant of the form `YYYYMML' where YYYY and MM are the + year and month of the Standard version. This signifies which + version of the C Standard the preprocessor conforms to. Like + `__STDC__', whether this version number is accurate for the entire + implementation depends on what C compiler will operate on the + output from the preprocessor. + +`__GNUC__' + This macro is defined if and only if this is GNU C. This macro is + defined only when the entire GNU C compiler is in use; if you + invoke the preprocessor directly, `__GNUC__' is undefined. The + value identifies the major version number of GNU CC (`1' for GNU CC + version 1, which is now obsolete, and `2' for version 2). + +`__GNUC_MINOR__' + The macro contains the minor version number of the compiler. This + can be used to work around differences between different releases + of the compiler (for example, if gcc 2.6.3 is known to support a + feature, you can test for `__GNUC__ > 2 || (__GNUC__ == 2 && + __GNUC_MINOR__ >= 6)'). The last number, `3' in the example + above, denotes the bugfix level of the compiler; no macro contains + this value. + +`__GNUG__' + The GNU C compiler defines this when the compilation language is + C++; use `__GNUG__' to distinguish between GNU C and GNU C++. + +`__cplusplus' + The draft ANSI standard for C++ used to require predefining this + variable. Though it is no longer required, GNU C++ continues to + define it, as do other popular C++ compilers. You can use + `__cplusplus' to test whether a header is compiled by a C compiler + or a C++ compiler. + +`__STRICT_ANSI__' + This macro is defined if and only if the `-ansi' switch was + specified when GNU C was invoked. Its definition is the null + string. This macro exists primarily to direct certain GNU header + files not to define certain traditional Unix constructs which are + incompatible with ANSI C. + +`__BASE_FILE__' + This macro expands to the name of the main input file, in the form + of a C string constant. This is the source file that was specified + as an argument when the C compiler was invoked. + +`__INCLUDE_LEVEL__' + This macro expands to a decimal integer constant that represents + the depth of nesting in include files. The value of this macro is + incremented on every `#include' directive and decremented at every + end of file. For input files specified by command line arguments, + the nesting level is zero. + +`__VERSION__' + This macro expands to a string which describes the version number + of GNU C. The string is normally a sequence of decimal numbers + separated by periods, such as `"2.6.0"'. The only reasonable use + of this macro is to incorporate it into a string constant. + +`__OPTIMIZE__' + This macro is defined in optimizing compilations. It causes + certain GNU header files to define alternative macro definitions + for some system library functions. It is unwise to refer to or + test the definition of this macro unless you make very sure that + programs will execute with the same effect regardless. + +`__CHAR_UNSIGNED__' + This macro is defined if and only if the data type `char' is + unsigned on the target machine. It exists to cause the standard + header file `limit.h' to work correctly. It is bad practice to + refer to this macro yourself; instead, refer to the standard + macros defined in `limit.h'. The preprocessor uses this macro to + determine whether or not to sign-extend large character constants + written in octal; see *Note The `#if' Directive: #if Directive. + +`__REGISTER_PREFIX__' + This macro expands to a string describing the prefix applied to cpu + registers in assembler code. It can be used to write assembler + code that is usable in multiple environments. For example, in the + `m68k-aout' environment it expands to the string `""', but in the + `m68k-coff' environment it expands to the string `"%"'. + +`__USER_LABEL_PREFIX__' + This macro expands to a string describing the prefix applied to + user generated labels in assembler code. It can be used to write + assembler code that is usable in multiple environments. For + example, in the `m68k-aout' environment it expands to the string + `"_"', but in the `m68k-coff' environment it expands to the string + `""'. + + +File: cpp.info, Node: Nonstandard Predefined, Prev: Standard Predefined, Up: Predefined + +Nonstandard Predefined Macros +............................. + + The C preprocessor normally has several predefined macros that vary +between machines because their purpose is to indicate what type of +system and machine is in use. This manual, being for all systems and +machines, cannot tell you exactly what their names are; instead, we +offer a list of some typical ones. You can use `cpp -dM' to see the +values of predefined macros; see *Note Invocation::. + + Some nonstandard predefined macros describe the operating system in +use, with more or less specificity. For example, + +`unix' + `unix' is normally predefined on all Unix systems. + +`BSD' + `BSD' is predefined on recent versions of Berkeley Unix (perhaps + only in version 4.3). + + Other nonstandard predefined macros describe the kind of CPU, with +more or less specificity. For example, + +`vax' + `vax' is predefined on Vax computers. + +`mc68000' + `mc68000' is predefined on most computers whose CPU is a Motorola + 68000, 68010 or 68020. + +`m68k' + `m68k' is also predefined on most computers whose CPU is a 68000, + 68010 or 68020; however, some makers use `mc68000' and some use + `m68k'. Some predefine both names. What happens in GNU C depends + on the system you are using it on. + +`M68020' + `M68020' has been observed to be predefined on some systems that + use 68020 CPUs--in addition to `mc68000' and `m68k', which are + less specific. + +`_AM29K' +`_AM29000' + Both `_AM29K' and `_AM29000' are predefined for the AMD 29000 CPU + family. + +`ns32000' + `ns32000' is predefined on computers which use the National + Semiconductor 32000 series CPU. + + Yet other nonstandard predefined macros describe the manufacturer of +the system. For example, + +`sun' + `sun' is predefined on all models of Sun computers. + +`pyr' + `pyr' is predefined on all models of Pyramid computers. + +`sequent' + `sequent' is predefined on all models of Sequent computers. + + These predefined symbols are not only nonstandard, they are contrary +to the ANSI standard because their names do not start with underscores. +Therefore, the option `-ansi' inhibits the definition of these symbols. + + This tends to make `-ansi' useless, since many programs depend on the +customary nonstandard predefined symbols. Even system header files +check them and will generate incorrect declarations if they do not find +the names that are expected. You might think that the header files +supplied for the Uglix computer would not need to test what machine +they are running on, because they can simply assume it is the Uglix; +but often they do, and they do so using the customary names. As a +result, very few C programs will compile with `-ansi'. We intend to +avoid such problems on the GNU system. + + What, then, should you do in an ANSI C program to test the type of +machine it will run on? + + GNU C offers a parallel series of symbols for this purpose, whose +names are made from the customary ones by adding `__' at the beginning +and end. Thus, the symbol `__vax__' would be available on a Vax, and +so on. + + The set of nonstandard predefined names in the GNU C preprocessor is +controlled (when `cpp' is itself compiled) by the macro +`CPP_PREDEFINES', which should be a string containing `-D' options, +separated by spaces. For example, on the Sun 3, we use the following +definition: + + #define CPP_PREDEFINES "-Dmc68000 -Dsun -Dunix -Dm68k" + +This macro is usually specified in `tm.h'. + + +File: cpp.info, Node: Stringification, Next: Concatenation, Prev: Predefined, Up: Macros + +Stringification +--------------- + + "Stringification" means turning a code fragment into a string +constant whose contents are the text for the code fragment. For +example, stringifying `foo (z)' results in `"foo (z)"'. + + In the C preprocessor, stringification is an option available when +macro arguments are substituted into the macro definition. In the body +of the definition, when an argument name appears, the character `#' +before the name specifies stringification of the corresponding actual +argument when it is substituted at that point in the definition. The +same argument may be substituted in other places in the definition +without stringification if the argument name appears in those places +with no `#'. + + Here is an example of a macro definition that uses stringification: + + #define WARN_IF(EXP) \ + do { if (EXP) \ + fprintf (stderr, "Warning: " #EXP "\n"); } \ + while (0) + +Here the actual argument for `EXP' is substituted once as given, into +the `if' statement, and once as stringified, into the argument to +`fprintf'. The `do' and `while (0)' are a kludge to make it possible +to write `WARN_IF (ARG);', which the resemblance of `WARN_IF' to a +function would make C programmers want to do; see *Note Swallow +Semicolon::. + + The stringification feature is limited to transforming one macro +argument into one string constant: there is no way to combine the +argument with other text and then stringify it all together. But the +example above shows how an equivalent result can be obtained in ANSI +Standard C using the feature that adjacent string constants are +concatenated as one string constant. The preprocessor stringifies the +actual value of `EXP' into a separate string constant, resulting in +text like + + do { if (x == 0) \ + fprintf (stderr, "Warning: " "x == 0" "\n"); } \ + while (0) + +but the C compiler then sees three consecutive string constants and +concatenates them into one, producing effectively + + do { if (x == 0) \ + fprintf (stderr, "Warning: x == 0\n"); } \ + while (0) + + Stringification in C involves more than putting doublequote +characters around the fragment; it is necessary to put backslashes in +front of all doublequote characters, and all backslashes in string and +character constants, in order to get a valid C string constant with the +proper contents. Thus, stringifying `p = "foo\n";' results in `"p = +\"foo\\n\";"'. However, backslashes that are not inside of string or +character constants are not duplicated: `\n' by itself stringifies to +`"\n"'. + + Whitespace (including comments) in the text being stringified is +handled according to precise rules. All leading and trailing +whitespace is ignored. Any sequence of whitespace in the middle of the +text is converted to a single space in the stringified result. + + +File: cpp.info, Node: Concatenation, Next: Undefining, Prev: Stringification, Up: Macros + +Concatenation +------------- + + "Concatenation" means joining two strings into one. In the context +of macro expansion, concatenation refers to joining two lexical units +into one longer one. Specifically, an actual argument to the macro can +be concatenated with another actual argument or with fixed text to +produce a longer name. The longer name might be the name of a function, +variable or type, or a C keyword; it might even be the name of another +macro, in which case it will be expanded. + + When you define a macro, you request concatenation with the special +operator `##' in the macro body. When the macro is called, after +actual arguments are substituted, all `##' operators are deleted, and +so is any whitespace next to them (including whitespace that was part +of an actual argument). The result is to concatenate the syntactic +tokens on either side of the `##'. + + Consider a C program that interprets named commands. There probably +needs to be a table of commands, perhaps an array of structures +declared as follows: + + struct command + { + char *name; + void (*function) (); + }; + + struct command commands[] = + { + { "quit", quit_command}, + { "help", help_command}, + ... + }; + + It would be cleaner not to have to give each command name twice, +once in the string constant and once in the function name. A macro +which takes the name of a command as an argument can make this +unnecessary. The string constant can be created with stringification, +and the function name by concatenating the argument with `_command'. +Here is how it is done: + + #define COMMAND(NAME) { #NAME, NAME ## _command } + + struct command commands[] = + { + COMMAND (quit), + COMMAND (help), + ... + }; + + The usual case of concatenation is concatenating two names (or a +name and a number) into a longer name. But this isn't the only valid +case. It is also possible to concatenate two numbers (or a number and +a name, such as `1.5' and `e3') into a number. Also, multi-character +operators such as `+=' can be formed by concatenation. In some cases +it is even possible to piece together a string constant. However, two +pieces of text that don't together form a valid lexical unit cannot be +concatenated. For example, concatenation with `x' on one side and `+' +on the other is not meaningful because those two characters can't fit +together in any lexical unit of C. The ANSI standard says that such +attempts at concatenation are undefined, but in the GNU C preprocessor +it is well defined: it puts the `x' and `+' side by side with no +particular special results. + + Keep in mind that the C preprocessor converts comments to whitespace +before macros are even considered. Therefore, you cannot create a +comment by concatenating `/' and `*': the `/*' sequence that starts a +comment is not a lexical unit, but rather the beginning of a "long" +space character. Also, you can freely use comments next to a `##' in a +macro definition, or in actual arguments that will be concatenated, +because the comments will be converted to spaces at first sight, and +concatenation will later discard the spaces. + + +File: cpp.info, Node: Undefining, Next: Redefining, Prev: Concatenation, Up: Macros + +Undefining Macros +----------------- + + To "undefine" a macro means to cancel its definition. This is done +with the `#undef' directive. `#undef' is followed by the macro name to +be undefined. + + Like definition, undefinition occurs at a specific point in the +source file, and it applies starting from that point. The name ceases +to be a macro name, and from that point on it is treated by the +preprocessor as if it had never been a macro name. + + For example, + + #define FOO 4 + x = FOO; + #undef FOO + x = FOO; + +expands into + + x = 4; + + x = FOO; + +In this example, `FOO' had better be a variable or function as well as +(temporarily) a macro, in order for the result of the expansion to be +valid C code. + + The same form of `#undef' directive will cancel definitions with +arguments or definitions that don't expect arguments. The `#undef' +directive has no effect when used on a name not currently defined as a +macro. + + +File: cpp.info, Node: Redefining, Next: Macro Pitfalls, Prev: Undefining, Up: Macros + +Redefining Macros +----------------- + + "Redefining" a macro means defining (with `#define') a name that is +already defined as a macro. + + A redefinition is trivial if the new definition is transparently +identical to the old one. You probably wouldn't deliberately write a +trivial redefinition, but they can happen automatically when a header +file is included more than once (*note Header Files::.), so they are +accepted silently and without effect. + + Nontrivial redefinition is considered likely to be an error, so it +provokes a warning message from the preprocessor. However, sometimes it +is useful to change the definition of a macro in mid-compilation. You +can inhibit the warning by undefining the macro with `#undef' before the +second definition. + + In order for a redefinition to be trivial, the new definition must +exactly match the one already in effect, with two possible exceptions: + + * Whitespace may be added or deleted at the beginning or the end. + + * Whitespace may be changed in the middle (but not inside strings). + However, it may not be eliminated entirely, and it may not be added + where there was no whitespace at all. + + Recall that a comment counts as whitespace. + + +File: cpp.info, Node: Macro Pitfalls, Prev: Redefining, Up: Macros + +Pitfalls and Subtleties of Macros +--------------------------------- + + In this section we describe some special rules that apply to macros +and macro expansion, and point out certain cases in which the rules have +counterintuitive consequences that you must watch out for. + +* Menu: + +* Misnesting:: Macros can contain unmatched parentheses. +* Macro Parentheses:: Why apparently superfluous parentheses + may be necessary to avoid incorrect grouping. +* Swallow Semicolon:: Macros that look like functions + but expand into compound statements. +* Side Effects:: Unsafe macros that cause trouble when + arguments contain side effects. +* Self-Reference:: Macros whose definitions use the macros' own names. +* Argument Prescan:: Actual arguments are checked for macro calls + before they are substituted. +* Cascaded Macros:: Macros whose definitions use other macros. +* Newlines in Args:: Sometimes line numbers get confused. + diff --git a/support/cpp/cpp.info-2 b/support/cpp/cpp.info-2 new file mode 100644 index 00000000..8407c2b3 --- /dev/null +++ b/support/cpp/cpp.info-2 @@ -0,0 +1,1032 @@ +This is Info file cpp.info, produced by Makeinfo version 1.67 from the +input file cpp.texi. + + This file documents the GNU C Preprocessor. + + Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software +Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: cpp.info, Node: Misnesting, Next: Macro Parentheses, Prev: Macro Pitfalls, Up: Macro Pitfalls + +Improperly Nested Constructs +............................ + + Recall that when a macro is called with arguments, the arguments are +substituted into the macro body and the result is checked, together with +the rest of the input file, for more macro calls. + + It is possible to piece together a macro call coming partially from +the macro body and partially from the actual arguments. For example, + + #define double(x) (2*(x)) + #define call_with_1(x) x(1) + +would expand `call_with_1 (double)' into `(2*(1))'. + + Macro definitions do not have to have balanced parentheses. By +writing an unbalanced open parenthesis in a macro body, it is possible +to create a macro call that begins inside the macro body but ends +outside of it. For example, + + #define strange(file) fprintf (file, "%s %d", + ... + strange(stderr) p, 35) + +This bizarre example expands to `fprintf (stderr, "%s %d", p, 35)'! + + +File: cpp.info, Node: Macro Parentheses, Next: Swallow Semicolon, Prev: Misnesting, Up: Macro Pitfalls + +Unintended Grouping of Arithmetic +................................. + + You may have noticed that in most of the macro definition examples +shown above, each occurrence of a macro argument name had parentheses +around it. In addition, another pair of parentheses usually surround +the entire macro definition. Here is why it is best to write macros +that way. + + Suppose you define a macro as follows, + + #define ceil_div(x, y) (x + y - 1) / y + +whose purpose is to divide, rounding up. (One use for this operation is +to compute how many `int' objects are needed to hold a certain number +of `char' objects.) Then suppose it is used as follows: + + a = ceil_div (b & c, sizeof (int)); + +This expands into + + a = (b & c + sizeof (int) - 1) / sizeof (int); + +which does not do what is intended. The operator-precedence rules of C +make it equivalent to this: + + a = (b & (c + sizeof (int) - 1)) / sizeof (int); + +But what we want is this: + + a = ((b & c) + sizeof (int) - 1)) / sizeof (int); + +Defining the macro as + + #define ceil_div(x, y) ((x) + (y) - 1) / (y) + +provides the desired result. + + However, unintended grouping can result in another way. Consider +`sizeof ceil_div(1, 2)'. That has the appearance of a C expression +that would compute the size of the type of `ceil_div (1, 2)', but in +fact it means something very different. Here is what it expands to: + + sizeof ((1) + (2) - 1) / (2) + +This would take the size of an integer and divide it by two. The +precedence rules have put the division outside the `sizeof' when it was +intended to be inside. + + Parentheses around the entire macro definition can prevent such +problems. Here, then, is the recommended way to define `ceil_div': + + #define ceil_div(x, y) (((x) + (y) - 1) / (y)) + + +File: cpp.info, Node: Swallow Semicolon, Next: Side Effects, Prev: Macro Parentheses, Up: Macro Pitfalls + +Swallowing the Semicolon +........................ + + Often it is desirable to define a macro that expands into a compound +statement. Consider, for example, the following macro, that advances a +pointer (the argument `p' says where to find it) across whitespace +characters: + + #define SKIP_SPACES (p, limit) \ + { register char *lim = (limit); \ + while (p != lim) { \ + if (*p++ != ' ') { \ + p--; break; }}} + +Here Backslash-Newline is used to split the macro definition, which must +be a single line, so that it resembles the way such C code would be +laid out if not part of a macro definition. + + A call to this macro might be `SKIP_SPACES (p, lim)'. Strictly +speaking, the call expands to a compound statement, which is a complete +statement with no need for a semicolon to end it. But it looks like a +function call. So it minimizes confusion if you can use it like a +function call, writing a semicolon afterward, as in `SKIP_SPACES (p, +lim);' + + But this can cause trouble before `else' statements, because the +semicolon is actually a null statement. Suppose you write + + if (*p != 0) + SKIP_SPACES (p, lim); + else ... + +The presence of two statements--the compound statement and a null +statement--in between the `if' condition and the `else' makes invalid C +code. + + The definition of the macro `SKIP_SPACES' can be altered to solve +this problem, using a `do ... while' statement. Here is how: + + #define SKIP_SPACES (p, limit) \ + do { register char *lim = (limit); \ + while (p != lim) { \ + if (*p++ != ' ') { \ + p--; break; }}} \ + while (0) + + Now `SKIP_SPACES (p, lim);' expands into + + do {...} while (0); + +which is one statement. + + +File: cpp.info, Node: Side Effects, Next: Self-Reference, Prev: Swallow Semicolon, Up: Macro Pitfalls + +Duplication of Side Effects +........................... + + Many C programs define a macro `min', for "minimum", like this: + + #define min(X, Y) ((X) < (Y) ? (X) : (Y)) + + When you use this macro with an argument containing a side effect, +as shown here, + + next = min (x + y, foo (z)); + +it expands as follows: + + next = ((x + y) < (foo (z)) ? (x + y) : (foo (z))); + +where `x + y' has been substituted for `X' and `foo (z)' for `Y'. + + The function `foo' is used only once in the statement as it appears +in the program, but the expression `foo (z)' has been substituted twice +into the macro expansion. As a result, `foo' might be called two times +when the statement is executed. If it has side effects or if it takes +a long time to compute, the results might not be what you intended. We +say that `min' is an "unsafe" macro. + + The best solution to this problem is to define `min' in a way that +computes the value of `foo (z)' only once. The C language offers no +standard way to do this, but it can be done with GNU C extensions as +follows: + + #define min(X, Y) \ + ({ typeof (X) __x = (X), __y = (Y); \ + (__x < __y) ? __x : __y; }) + + If you do not wish to use GNU C extensions, the only solution is to +be careful when *using* the macro `min'. For example, you can +calculate the value of `foo (z)', save it in a variable, and use that +variable in `min': + + #define min(X, Y) ((X) < (Y) ? (X) : (Y)) + ... + { + int tem = foo (z); + next = min (x + y, tem); + } + +(where we assume that `foo' returns type `int'). + + +File: cpp.info, Node: Self-Reference, Next: Argument Prescan, Prev: Side Effects, Up: Macro Pitfalls + +Self-Referential Macros +....................... + + A "self-referential" macro is one whose name appears in its +definition. A special feature of ANSI Standard C is that the +self-reference is not considered a macro call. It is passed into the +preprocessor output unchanged. + + Let's consider an example: + + #define foo (4 + foo) + +where `foo' is also a variable in your program. + + Following the ordinary rules, each reference to `foo' will expand +into `(4 + foo)'; then this will be rescanned and will expand into `(4 ++ (4 + foo))'; and so on until it causes a fatal error (memory full) in +the preprocessor. + + However, the special rule about self-reference cuts this process +short after one step, at `(4 + foo)'. Therefore, this macro definition +has the possibly useful effect of causing the program to add 4 to the +value of `foo' wherever `foo' is referred to. + + In most cases, it is a bad idea to take advantage of this feature. A +person reading the program who sees that `foo' is a variable will not +expect that it is a macro as well. The reader will come across the +identifier `foo' in the program and think its value should be that of +the variable `foo', whereas in fact the value is four greater. + + The special rule for self-reference applies also to "indirect" +self-reference. This is the case where a macro X expands to use a +macro `y', and the expansion of `y' refers to the macro `x'. The +resulting reference to `x' comes indirectly from the expansion of `x', +so it is a self-reference and is not further expanded. Thus, after + + #define x (4 + y) + #define y (2 * x) + +`x' would expand into `(4 + (2 * x))'. Clear? + + But suppose `y' is used elsewhere, not from the definition of `x'. +Then the use of `x' in the expansion of `y' is not a self-reference +because `x' is not "in progress". So it does expand. However, the +expansion of `x' contains a reference to `y', and that is an indirect +self-reference now because `y' is "in progress". The result is that +`y' expands to `(2 * (4 + y))'. + + It is not clear that this behavior would ever be useful, but it is +specified by the ANSI C standard, so you may need to understand it. + + +File: cpp.info, Node: Argument Prescan, Next: Cascaded Macros, Prev: Self-Reference, Up: Macro Pitfalls + +Separate Expansion of Macro Arguments +..................................... + + We have explained that the expansion of a macro, including the +substituted actual arguments, is scanned over again for macro calls to +be expanded. + + What really happens is more subtle: first each actual argument text +is scanned separately for macro calls. Then the results of this are +substituted into the macro body to produce the macro expansion, and the +macro expansion is scanned again for macros to expand. + + The result is that the actual arguments are scanned *twice* to expand +macro calls in them. + + Most of the time, this has no effect. If the actual argument +contained any macro calls, they are expanded during the first scan. +The result therefore contains no macro calls, so the second scan does +not change it. If the actual argument were substituted as given, with +no prescan, the single remaining scan would find the same macro calls +and produce the same results. + + You might expect the double scan to change the results when a +self-referential macro is used in an actual argument of another macro +(*note Self-Reference::.): the self-referential macro would be expanded +once in the first scan, and a second time in the second scan. But this +is not what happens. The self-references that do not expand in the +first scan are marked so that they will not expand in the second scan +either. + + The prescan is not done when an argument is stringified or +concatenated. Thus, + + #define str(s) #s + #define foo 4 + str (foo) + +expands to `"foo"'. Once more, prescan has been prevented from having +any noticeable effect. + + More precisely, stringification and concatenation use the argument as +written, in un-prescanned form. The same actual argument would be used +in prescanned form if it is substituted elsewhere without +stringification or concatenation. + + #define str(s) #s lose(s) + #define foo 4 + str (foo) + + expands to `"foo" lose(4)'. + + You might now ask, "Why mention the prescan, if it makes no +difference? And why not skip it and make the preprocessor faster?" +The answer is that the prescan does make a difference in three special +cases: + + * Nested calls to a macro. + + * Macros that call other macros that stringify or concatenate. + + * Macros whose expansions contain unshielded commas. + + We say that "nested" calls to a macro occur when a macro's actual +argument contains a call to that very macro. For example, if `f' is a +macro that expects one argument, `f (f (1))' is a nested pair of calls +to `f'. The desired expansion is made by expanding `f (1)' and +substituting that into the definition of `f'. The prescan causes the +expected result to happen. Without the prescan, `f (1)' itself would +be substituted as an actual argument, and the inner use of `f' would +appear during the main scan as an indirect self-reference and would not +be expanded. Here, the prescan cancels an undesirable side effect (in +the medical, not computational, sense of the term) of the special rule +for self-referential macros. + + But prescan causes trouble in certain other cases of nested macro +calls. Here is an example: + + #define foo a,b + #define bar(x) lose(x) + #define lose(x) (1 + (x)) + + bar(foo) + +We would like `bar(foo)' to turn into `(1 + (foo))', which would then +turn into `(1 + (a,b))'. But instead, `bar(foo)' expands into +`lose(a,b)', and you get an error because `lose' requires a single +argument. In this case, the problem is easily solved by the same +parentheses that ought to be used to prevent misnesting of arithmetic +operations: + + #define foo (a,b) + #define bar(x) lose((x)) + + The problem is more serious when the operands of the macro are not +expressions; for example, when they are statements. Then parentheses +are unacceptable because they would make for invalid C code: + + #define foo { int a, b; ... } + +In GNU C you can shield the commas using the `({...})' construct which +turns a compound statement into an expression: + + #define foo ({ int a, b; ... }) + + Or you can rewrite the macro definition to avoid such commas: + + #define foo { int a; int b; ... } + + There is also one case where prescan is useful. It is possible to +use prescan to expand an argument and then stringify it--if you use two +levels of macros. Let's add a new macro `xstr' to the example shown +above: + + #define xstr(s) str(s) + #define str(s) #s + #define foo 4 + xstr (foo) + + This expands into `"4"', not `"foo"'. The reason for the difference +is that the argument of `xstr' is expanded at prescan (because `xstr' +does not specify stringification or concatenation of the argument). +The result of prescan then forms the actual argument for `str'. `str' +uses its argument without prescan because it performs stringification; +but it cannot prevent or undo the prescanning already done by `xstr'. + + +File: cpp.info, Node: Cascaded Macros, Next: Newlines in Args, Prev: Argument Prescan, Up: Macro Pitfalls + +Cascaded Use of Macros +...................... + + A "cascade" of macros is when one macro's body contains a reference +to another macro. This is very common practice. For example, + + #define BUFSIZE 1020 + #define TABLESIZE BUFSIZE + + This is not at all the same as defining `TABLESIZE' to be `1020'. +The `#define' for `TABLESIZE' uses exactly the body you specify--in +this case, `BUFSIZE'--and does not check to see whether it too is the +name of a macro. + + It's only when you *use* `TABLESIZE' that the result of its expansion +is checked for more macro names. + + This makes a difference if you change the definition of `BUFSIZE' at +some point in the source file. `TABLESIZE', defined as shown, will +always expand using the definition of `BUFSIZE' that is currently in +effect: + + #define BUFSIZE 1020 + #define TABLESIZE BUFSIZE + #undef BUFSIZE + #define BUFSIZE 37 + +Now `TABLESIZE' expands (in two stages) to `37'. (The `#undef' is to +prevent any warning about the nontrivial redefinition of `BUFSIZE'.) + + +File: cpp.info, Node: Newlines in Args, Prev: Cascaded Macros, Up: Macro Pitfalls + +Newlines in Macro Arguments +--------------------------- + + Traditional macro processing carries forward all newlines in macro +arguments into the expansion of the macro. This means that, if some of +the arguments are substituted more than once, or not at all, or out of +order, newlines can be duplicated, lost, or moved around within the +expansion. If the expansion consists of multiple statements, then the +effect is to distort the line numbers of some of these statements. The +result can be incorrect line numbers, in error messages or displayed in +a debugger. + + The GNU C preprocessor operating in ANSI C mode adjusts appropriately +for multiple use of an argument--the first use expands all the +newlines, and subsequent uses of the same argument produce no newlines. +But even in this mode, it can produce incorrect line numbering if +arguments are used out of order, or not used at all. + + Here is an example illustrating this problem: + + #define ignore_second_arg(a,b,c) a; c + + ignore_second_arg (foo (), + ignored (), + syntax error); + +The syntax error triggered by the tokens `syntax error' results in an +error message citing line four, even though the statement text comes +from line five. + + +File: cpp.info, Node: Conditionals, Next: Combining Sources, Prev: Macros, Up: Top + +Conditionals +============ + + In a macro processor, a "conditional" is a directive that allows a +part of the program to be ignored during compilation, on some +conditions. In the C preprocessor, a conditional can test either an +arithmetic expression or whether a name is defined as a macro. + + A conditional in the C preprocessor resembles in some ways an `if' +statement in C, but it is important to understand the difference between +them. The condition in an `if' statement is tested during the execution +of your program. Its purpose is to allow your program to behave +differently from run to run, depending on the data it is operating on. +The condition in a preprocessing conditional directive is tested when +your program is compiled. Its purpose is to allow different code to be +included in the program depending on the situation at the time of +compilation. + +* Menu: + +* Uses: Conditional Uses. What conditionals are for. +* Syntax: Conditional Syntax. How conditionals are written. +* Deletion: Deleted Code. Making code into a comment. +* Macros: Conditionals-Macros. Why conditionals are used with macros. +* Assertions:: How and why to use assertions. +* Errors: #error Directive. Detecting inconsistent compilation parameters. + + +File: cpp.info, Node: Conditional Uses, Next: Conditional Syntax, Up: Conditionals + +Why Conditionals are Used +------------------------- + + Generally there are three kinds of reason to use a conditional. + + * A program may need to use different code depending on the machine + or operating system it is to run on. In some cases the code for + one operating system may be erroneous on another operating system; + for example, it might refer to library routines that do not exist + on the other system. When this happens, it is not enough to avoid + executing the invalid code: merely having it in the program makes + it impossible to link the program and run it. With a + preprocessing conditional, the offending code can be effectively + excised from the program when it is not valid. + + * You may want to be able to compile the same source file into two + different programs. Sometimes the difference between the programs + is that one makes frequent time-consuming consistency checks on its + intermediate data, or prints the values of those data for + debugging, while the other does not. + + * A conditional whose condition is always false is a good way to + exclude code from the program but keep it as a sort of comment for + future reference. + + Most simple programs that are intended to run on only one machine +will not need to use preprocessing conditionals. + + +File: cpp.info, Node: Conditional Syntax, Next: Deleted Code, Prev: Conditional Uses, Up: Conditionals + +Syntax of Conditionals +---------------------- + + A conditional in the C preprocessor begins with a "conditional +directive": `#if', `#ifdef' or `#ifndef'. *Note Conditionals-Macros::, +for information on `#ifdef' and `#ifndef'; only `#if' is explained here. + +* Menu: + +* If: #if Directive. Basic conditionals using `#if' and `#endif'. +* Else: #else Directive. Including some text if the condition fails. +* Elif: #elif Directive. Testing several alternative possibilities. + + +File: cpp.info, Node: #if Directive, Next: #else Directive, Up: Conditional Syntax + +The `#if' Directive +................... + + The `#if' directive in its simplest form consists of + + #if EXPRESSION + CONTROLLED TEXT + #endif /* EXPRESSION */ + + The comment following the `#endif' is not required, but it is a good +practice because it helps people match the `#endif' to the +corresponding `#if'. Such comments should always be used, except in +short conditionals that are not nested. In fact, you can put anything +at all after the `#endif' and it will be ignored by the GNU C +preprocessor, but only comments are acceptable in ANSI Standard C. + + EXPRESSION is a C expression of integer type, subject to stringent +restrictions. It may contain + + * Integer constants, which are all regarded as `long' or `unsigned + long'. + + * Character constants, which are interpreted according to the + character set and conventions of the machine and operating system + on which the preprocessor is running. The GNU C preprocessor uses + the C data type `char' for these character constants; therefore, + whether some character codes are negative is determined by the C + compiler used to compile the preprocessor. If it treats `char' as + signed, then character codes large enough to set the sign bit will + be considered negative; otherwise, no character code is considered + negative. + + * Arithmetic operators for addition, subtraction, multiplication, + division, bitwise operations, shifts, comparisons, and logical + operations (`&&' and `||'). + + * Identifiers that are not macros, which are all treated as zero(!). + + * Macro calls. All macro calls in the expression are expanded before + actual computation of the expression's value begins. + + Note that `sizeof' operators and `enum'-type values are not allowed. +`enum'-type values, like all other identifiers that are not taken as +macro calls and expanded, are treated as zero. + + The CONTROLLED TEXT inside of a conditional can include +preprocessing directives. Then the directives inside the conditional +are obeyed only if that branch of the conditional succeeds. The text +can also contain other conditional groups. However, the `#if' and +`#endif' directives must balance. + + +File: cpp.info, Node: #else Directive, Next: #elif Directive, Prev: #if Directive, Up: Conditional Syntax + +The `#else' Directive +..................... + + The `#else' directive can be added to a conditional to provide +alternative text to be used if the condition is false. This is what it +looks like: + + #if EXPRESSION + TEXT-IF-TRUE + #else /* Not EXPRESSION */ + TEXT-IF-FALSE + #endif /* Not EXPRESSION */ + + If EXPRESSION is nonzero, and thus the TEXT-IF-TRUE is active, then +`#else' acts like a failing conditional and the TEXT-IF-FALSE is +ignored. Contrariwise, if the `#if' conditional fails, the +TEXT-IF-FALSE is considered included. + + +File: cpp.info, Node: #elif Directive, Prev: #else Directive, Up: Conditional Syntax + +The `#elif' Directive +..................... + + One common case of nested conditionals is used to check for more +than two possible alternatives. For example, you might have + + #if X == 1 + ... + #else /* X != 1 */ + #if X == 2 + ... + #else /* X != 2 */ + ... + #endif /* X != 2 */ + #endif /* X != 1 */ + + Another conditional directive, `#elif', allows this to be abbreviated +as follows: + + #if X == 1 + ... + #elif X == 2 + ... + #else /* X != 2 and X != 1*/ + ... + #endif /* X != 2 and X != 1*/ + + `#elif' stands for "else if". Like `#else', it goes in the middle +of a `#if'-`#endif' pair and subdivides it; it does not require a +matching `#endif' of its own. Like `#if', the `#elif' directive +includes an expression to be tested. + + The text following the `#elif' is processed only if the original +`#if'-condition failed and the `#elif' condition succeeds. More than +one `#elif' can go in the same `#if'-`#endif' group. Then the text +after each `#elif' is processed only if the `#elif' condition succeeds +after the original `#if' and any previous `#elif' directives within it +have failed. `#else' is equivalent to `#elif 1', and `#else' is +allowed after any number of `#elif' directives, but `#elif' may not +follow `#else'. + + +File: cpp.info, Node: Deleted Code, Next: Conditionals-Macros, Prev: Conditional Syntax, Up: Conditionals + +Keeping Deleted Code for Future Reference +----------------------------------------- + + If you replace or delete a part of the program but want to keep the +old code around as a comment for future reference, the easy way to do +this is to put `#if 0' before it and `#endif' after it. This is better +than using comment delimiters `/*' and `*/' since those won't work if +the code already contains comments (C comments do not nest). + + This works even if the code being turned off contains conditionals, +but they must be entire conditionals (balanced `#if' and `#endif'). + + Conversely, do not use `#if 0' for comments which are not C code. +Use the comment delimiters `/*' and `*/' instead. The interior of `#if +0' must consist of complete tokens; in particular, singlequote +characters must balance. But comments often contain unbalanced +singlequote characters (known in English as apostrophes). These +confuse `#if 0'. They do not confuse `/*'. + + +File: cpp.info, Node: Conditionals-Macros, Next: Assertions, Prev: Deleted Code, Up: Conditionals + +Conditionals and Macros +----------------------- + + Conditionals are useful in connection with macros or assertions, +because those are the only ways that an expression's value can vary +from one compilation to another. A `#if' directive whose expression +uses no macros or assertions is equivalent to `#if 1' or `#if 0'; you +might as well determine which one, by computing the value of the +expression yourself, and then simplify the program. + + For example, here is a conditional that tests the expression +`BUFSIZE == 1020', where `BUFSIZE' must be a macro. + + #if BUFSIZE == 1020 + printf ("Large buffers!\n"); + #endif /* BUFSIZE is large */ + + (Programmers often wish they could test the size of a variable or +data type in `#if', but this does not work. The preprocessor does not +understand `sizeof', or typedef names, or even the type keywords such +as `int'.) + + The special operator `defined' is used in `#if' expressions to test +whether a certain name is defined as a macro. Either `defined NAME' or +`defined (NAME)' is an expression whose value is 1 if NAME is defined +as macro at the current point in the program, and 0 otherwise. For the +`defined' operator it makes no difference what the definition of the +macro is; all that matters is whether there is a definition. Thus, for +example, + + #if defined (vax) || defined (ns16000) + +would succeed if either of the names `vax' and `ns16000' is defined as +a macro. You can test the same condition using assertions (*note +Assertions::.), like this: + + #if #cpu (vax) || #cpu (ns16000) + + If a macro is defined and later undefined with `#undef', subsequent +use of the `defined' operator returns 0, because the name is no longer +defined. If the macro is defined again with another `#define', +`defined' will recommence returning 1. + + Conditionals that test whether just one name is defined are very +common, so there are two special short conditional directives for this +case. + +`#ifdef NAME' + is equivalent to `#if defined (NAME)'. + +`#ifndef NAME' + is equivalent to `#if ! defined (NAME)'. + + Macro definitions can vary between compilations for several reasons. + + * Some macros are predefined on each kind of machine. For example, + on a Vax, the name `vax' is a predefined macro. On other + machines, it would not be defined. + + * Many more macros are defined by system header files. Different + systems and machines define different macros, or give them + different values. It is useful to test these macros with + conditionals to avoid using a system feature on a machine where it + is not implemented. + + * Macros are a common way of allowing users to customize a program + for different machines or applications. For example, the macro + `BUFSIZE' might be defined in a configuration file for your + program that is included as a header file in each source file. You + would use `BUFSIZE' in a preprocessing conditional in order to + generate different code depending on the chosen configuration. + + * Macros can be defined or undefined with `-D' and `-U' command + options when you compile the program. You can arrange to compile + the same source file into two different programs by choosing a + macro name to specify which program you want, writing conditionals + to test whether or how this macro is defined, and then controlling + the state of the macro with compiler command options. *Note + Invocation::. + + Assertions are usually predefined, but can be defined with +preprocessor directives or command-line options. + + +File: cpp.info, Node: Assertions, Next: #error Directive, Prev: Conditionals-Macros, Up: Conditionals + +Assertions +---------- + + "Assertions" are a more systematic alternative to macros in writing +conditionals to test what sort of computer or system the compiled +program will run on. Assertions are usually predefined, but you can +define them with preprocessing directives or command-line options. + + The macros traditionally used to describe the type of target are not +classified in any way according to which question they answer; they may +indicate a hardware architecture, a particular hardware model, an +operating system, a particular version of an operating system, or +specific configuration options. These are jumbled together in a single +namespace. In contrast, each assertion consists of a named question and +an answer. The question is usually called the "predicate". An +assertion looks like this: + + #PREDICATE (ANSWER) + +You must use a properly formed identifier for PREDICATE. The value of +ANSWER can be any sequence of words; all characters are significant +except for leading and trailing whitespace, and differences in internal +whitespace sequences are ignored. Thus, `x + y' is different from +`x+y' but equivalent to `x + y'. `)' is not allowed in an answer. + + Here is a conditional to test whether the answer ANSWER is asserted +for the predicate PREDICATE: + + #if #PREDICATE (ANSWER) + +There may be more than one answer asserted for a given predicate. If +you omit the answer, you can test whether *any* answer is asserted for +PREDICATE: + + #if #PREDICATE + + Most of the time, the assertions you test will be predefined +assertions. GNU C provides three predefined predicates: `system', +`cpu', and `machine'. `system' is for assertions about the type of +software, `cpu' describes the type of computer architecture, and +`machine' gives more information about the computer. For example, on a +GNU system, the following assertions would be true: + + #system (gnu) + #system (mach) + #system (mach 3) + #system (mach 3.SUBVERSION) + #system (hurd) + #system (hurd VERSION) + +and perhaps others. The alternatives with more or less version +information let you ask more or less detailed questions about the type +of system software. + + On a Unix system, you would find `#system (unix)' and perhaps one of: +`#system (aix)', `#system (bsd)', `#system (hpux)', `#system (lynx)', +`#system (mach)', `#system (posix)', `#system (svr3)', `#system +(svr4)', or `#system (xpg4)' with possible version numbers following. + + Other values for `system' are `#system (mvs)' and `#system (vms)'. + + *Portability note:* Many Unix C compilers provide only one answer +for the `system' assertion: `#system (unix)', if they support +assertions at all. This is less than useful. + + An assertion with a multi-word answer is completely different from +several assertions with individual single-word answers. For example, +the presence of `system (mach 3.0)' does not mean that `system (3.0)' +is true. It also does not directly imply `system (mach)', but in GNU +C, that last will normally be asserted as well. + + The current list of possible assertion values for `cpu' is: `#cpu +(a29k)', `#cpu (alpha)', `#cpu (arm)', `#cpu (clipper)', `#cpu +(convex)', `#cpu (elxsi)', `#cpu (tron)', `#cpu (h8300)', `#cpu +(i370)', `#cpu (i386)', `#cpu (i860)', `#cpu (i960)', `#cpu (m68k)', +`#cpu (m88k)', `#cpu (mips)', `#cpu (ns32k)', `#cpu (hppa)', `#cpu +(pyr)', `#cpu (ibm032)', `#cpu (rs6000)', `#cpu (sh)', `#cpu (sparc)', +`#cpu (spur)', `#cpu (tahoe)', `#cpu (vax)', `#cpu (we32000)'. + + You can create assertions within a C program using `#assert', like +this: + + #assert PREDICATE (ANSWER) + +(Note the absence of a `#' before PREDICATE.) + + Each time you do this, you assert a new true answer for PREDICATE. +Asserting one answer does not invalidate previously asserted answers; +they all remain true. The only way to remove an assertion is with +`#unassert'. `#unassert' has the same syntax as `#assert'. You can +also remove all assertions about PREDICATE like this: + + #unassert PREDICATE + + You can also add or cancel assertions using command options when you +run `gcc' or `cpp'. *Note Invocation::. + + +File: cpp.info, Node: #error Directive, Prev: Assertions, Up: Conditionals + +The `#error' and `#warning' Directives +-------------------------------------- + + The directive `#error' causes the preprocessor to report a fatal +error. The rest of the line that follows `#error' is used as the error +message. + + You would use `#error' inside of a conditional that detects a +combination of parameters which you know the program does not properly +support. For example, if you know that the program will not run +properly on a Vax, you might write + + #ifdef __vax__ + #error Won't work on Vaxen. See comments at get_last_object. + #endif + +*Note Nonstandard Predefined::, for why this works. + + If you have several configuration parameters that must be set up by +the installation in a consistent way, you can use conditionals to detect +an inconsistency and report it with `#error'. For example, + + #if HASH_TABLE_SIZE % 2 == 0 || HASH_TABLE_SIZE % 3 == 0 \ + || HASH_TABLE_SIZE % 5 == 0 + #error HASH_TABLE_SIZE should not be divisible by a small prime + #endif + + The directive `#warning' is like the directive `#error', but causes +the preprocessor to issue a warning and continue preprocessing. The +rest of the line that follows `#warning' is used as the warning message. + + You might use `#warning' in obsolete header files, with a message +directing the user to the header file which should be used instead. + + +File: cpp.info, Node: Combining Sources, Next: Other Directives, Prev: Conditionals, Up: Top + +Combining Source Files +====================== + + One of the jobs of the C preprocessor is to inform the C compiler of +where each line of C code came from: which source file and which line +number. + + C code can come from multiple source files if you use `#include'; +both `#include' and the use of conditionals and macros can cause the +line number of a line in the preprocessor output to be different from +the line's number in the original source file. You will appreciate the +value of making both the C compiler (in error messages) and symbolic +debuggers such as GDB use the line numbers in your source file. + + The C preprocessor builds on this feature by offering a directive by +which you can control the feature explicitly. This is useful when a +file for input to the C preprocessor is the output from another program +such as the `bison' parser generator, which operates on another file +that is the true source file. Parts of the output from `bison' are +generated from scratch, other parts come from a standard parser file. +The rest are copied nearly verbatim from the source file, but their +line numbers in the `bison' output are not the same as their original +line numbers. Naturally you would like compiler error messages and +symbolic debuggers to know the original source file and line number of +each line in the `bison' input. + + `bison' arranges this by writing `#line' directives into the output +file. `#line' is a directive that specifies the original line number +and source file name for subsequent input in the current preprocessor +input file. `#line' has three variants: + +`#line LINENUM' + Here LINENUM is a decimal integer constant. This specifies that + the line number of the following line of input, in its original + source file, was LINENUM. + +`#line LINENUM FILENAME' + Here LINENUM is a decimal integer constant and FILENAME is a + string constant. This specifies that the following line of input + came originally from source file FILENAME and its line number there + was LINENUM. Keep in mind that FILENAME is not just a file name; + it is surrounded by doublequote characters so that it looks like a + string constant. + +`#line ANYTHING ELSE' + ANYTHING ELSE is checked for macro calls, which are expanded. The + result should be a decimal integer constant followed optionally by + a string constant, as described above. + + `#line' directives alter the results of the `__FILE__' and +`__LINE__' predefined macros from that point on. *Note Standard +Predefined::. + + The output of the preprocessor (which is the input for the rest of +the compiler) contains directives that look much like `#line' +directives. They start with just `#' instead of `#line', but this is +followed by a line number and file name as in `#line'. *Note Output::. + + +File: cpp.info, Node: Other Directives, Next: Output, Prev: Combining Sources, Up: Top + +Miscellaneous Preprocessing Directives +====================================== + + This section describes three additional preprocessing directives. +They are not very useful, but are mentioned for completeness. + + The "null directive" consists of a `#' followed by a Newline, with +only whitespace (including comments) in between. A null directive is +understood as a preprocessing directive but has no effect on the +preprocessor output. The primary significance of the existence of the +null directive is that an input line consisting of just a `#' will +produce no output, rather than a line of output containing just a `#'. +Supposedly some old C programs contain such lines. + + The ANSI standard specifies that the `#pragma' directive has an +arbitrary, implementation-defined effect. In the GNU C preprocessor, +`#pragma' directives are not used, except for `#pragma once' (*note +Once-Only::.). However, they are left in the preprocessor output, so +they are available to the compilation pass. + + The `#ident' directive is supported for compatibility with certain +other systems. It is followed by a line of text. On some systems, the +text is copied into a special place in the object file; on most systems, +the text is ignored and this directive has no effect. Typically +`#ident' is only used in header files supplied with those systems where +it is meaningful. + + +File: cpp.info, Node: Output, Next: Invocation, Prev: Other Directives, Up: Top + +C Preprocessor Output +===================== + + The output from the C preprocessor looks much like the input, except +that all preprocessing directive lines have been replaced with blank +lines and all comments with spaces. Whitespace within a line is not +altered; however, a space is inserted after the expansions of most +macro calls. + + Source file name and line number information is conveyed by lines of +the form + + # LINENUM FILENAME FLAGS + +which are inserted as needed into the middle of the input (but never +within a string or character constant). Such a line means that the +following line originated in file FILENAME at line LINENUM. + + After the file name comes zero or more flags, which are `1', `2', +`3', or `4'. If there are multiple flags, spaces separate them. Here +is what the flags mean: + +`1' + This indicates the start of a new file. + +`2' + This indicates returning to a file (after having included another + file). + +`3' + This indicates that the following text comes from a system header + file, so certain warnings should be suppressed. + +`4' + This indicates that the following text should be treated as C. + diff --git a/support/cpp/cpp.info-3 b/support/cpp/cpp.info-3 new file mode 100644 index 00000000..30fa3116 --- /dev/null +++ b/support/cpp/cpp.info-3 @@ -0,0 +1,466 @@ +This is Info file cpp.info, produced by Makeinfo version 1.67 from the +input file cpp.texi. + + This file documents the GNU C Preprocessor. + + Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software +Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided also +that the entire resulting derived work is distributed under the terms +of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions. + + +File: cpp.info, Node: Invocation, Next: Concept Index, Prev: Output, Up: Top + +Invoking the C Preprocessor +=========================== + + Most often when you use the C preprocessor you will not have to +invoke it explicitly: the C compiler will do so automatically. +However, the preprocessor is sometimes useful on its own. + + The C preprocessor expects two file names as arguments, INFILE and +OUTFILE. The preprocessor reads INFILE together with any other files +it specifies with `#include'. All the output generated by the combined +input files is written in OUTFILE. + + Either INFILE or OUTFILE may be `-', which as INFILE means to read +from standard input and as OUTFILE means to write to standard output. +Also, if OUTFILE or both file names are omitted, the standard output +and standard input are used for the omitted file names. + + Here is a table of command options accepted by the C preprocessor. +These options can also be given when compiling a C program; they are +passed along automatically to the preprocessor when it is invoked by the +compiler. + +`-P' + Inhibit generation of `#'-lines with line-number information in + the output from the preprocessor (*note Output::.). This might be + useful when running the preprocessor on something that is not C + code and will be sent to a program which might be confused by the + `#'-lines. + +`-C' + Do not discard comments: pass them through to the output file. + Comments appearing in arguments of a macro call will be copied to + the output before the expansion of the macro call. + +`-traditional' + Try to imitate the behavior of old-fashioned C, as opposed to ANSI + C. + + * Traditional macro expansion pays no attention to singlequote + or doublequote characters; macro argument symbols are + replaced by the argument values even when they appear within + apparent string or character constants. + + * Traditionally, it is permissible for a macro expansion to end + in the middle of a string or character constant. The + constant continues into the text surrounding the macro call. + + * However, traditionally the end of the line terminates a + string or character constant, with no error. + + * In traditional C, a comment is equivalent to no text at all. + (In ANSI C, a comment counts as whitespace.) + + * Traditional C does not have the concept of a "preprocessing + number". It considers `1.0e+4' to be three tokens: `1.0e', + `+', and `4'. + + * A macro is not suppressed within its own definition, in + traditional C. Thus, any macro that is used recursively + inevitably causes an error. + + * The character `#' has no special meaning within a macro + definition in traditional C. + + * In traditional C, the text at the end of a macro expansion + can run together with the text after the macro call, to + produce a single token. (This is impossible in ANSI C.) + + * Traditionally, `\' inside a macro argument suppresses the + syntactic significance of the following character. + +`-trigraphs' + Process ANSI standard trigraph sequences. These are + three-character sequences, all starting with `??', that are + defined by ANSI C to stand for single characters. For example, + `??/' stands for `\', so `'??/n'' is a character constant for a + newline. Strictly speaking, the GNU C preprocessor does not + support all programs in ANSI Standard C unless `-trigraphs' is + used, but if you ever notice the difference it will be with relief. + + You don't want to know any more about trigraphs. + +`-pedantic' + Issue warnings required by the ANSI C standard in certain cases + such as when text other than a comment follows `#else' or `#endif'. + +`-pedantic-errors' + Like `-pedantic', except that errors are produced rather than + warnings. + +`-Wtrigraphs' + Warn if any trigraphs are encountered (assuming they are enabled). + +`-Wcomment' + Warn whenever a comment-start sequence `/*' appears in a comment. + +`-Wall' + Requests both `-Wtrigraphs' and `-Wcomment' (but not + `-Wtraditional'). + +`-Wtraditional' + Warn about certain constructs that behave differently in + traditional and ANSI C. + +`-I DIRECTORY' + Add the directory DIRECTORY to the head of the list of directories + to be searched for header files (*note Include Syntax::.). This + can be used to override a system header file, substituting your + own version, since these directories are searched before the system + header file directories. If you use more than one `-I' option, + the directories are scanned in left-to-right order; the standard + system directories come after. + +`-I-' + Any directories specified with `-I' options before the `-I-' + option are searched only for the case of `#include "FILE"'; they + are not searched for `#include '. + + If additional directories are specified with `-I' options after + the `-I-', these directories are searched for all `#include' + directives. + + In addition, the `-I-' option inhibits the use of the current + directory as the first search directory for `#include "FILE"'. + Therefore, the current directory is searched only if it is + requested explicitly with `-I.'. Specifying both `-I-' and `-I.' + allows you to control precisely which directories are searched + before the current one and which are searched after. + +`-nostdinc' + Do not search the standard system directories for header files. + Only the directories you have specified with `-I' options (and the + current directory, if appropriate) are searched. + +`-nostdinc++' + Do not search for header files in the C++-specific standard + directories, but do still search the other standard directories. + (This option is used when building libg++.) + +`-D NAME' + Predefine NAME as a macro, with definition `1'. + +`-D NAME=DEFINITION' + Predefine NAME as a macro, with definition DEFINITION. There are + no restrictions on the contents of DEFINITION, but if you are + invoking the preprocessor from a shell or shell-like program you + may need to use the shell's quoting syntax to protect characters + such as spaces that have a meaning in the shell syntax. If you + use more than one `-D' for the same NAME, the rightmost definition + takes effect. + +`-U NAME' + Do not predefine NAME. If both `-U' and `-D' are specified for + one name, the `-U' beats the `-D' and the name is not predefined. + +`-undef' + Do not predefine any nonstandard macros. + +`-A PREDICATE(ANSWER)' + Make an assertion with the predicate PREDICATE and answer ANSWER. + *Note Assertions::. + + You can use `-A-' to disable all predefined assertions; it also + undefines all predefined macros that identify the type of target + system. + +`-dM' + Instead of outputting the result of preprocessing, output a list of + `#define' directives for all the macros defined during the + execution of the preprocessor, including predefined macros. This + gives you a way of finding out what is predefined in your version + of the preprocessor; assuming you have no file `foo.h', the command + + touch foo.h; cpp -dM foo.h + + will show the values of any predefined macros. + +`-dD' + Like `-dM' except in two respects: it does *not* include the + predefined macros, and it outputs *both* the `#define' directives + and the result of preprocessing. Both kinds of output go to the + standard output file. + +`-M [-MG]' + Instead of outputting the result of preprocessing, output a rule + suitable for `make' describing the dependencies of the main source + file. The preprocessor outputs one `make' rule containing the + object file name for that source file, a colon, and the names of + all the included files. If there are many included files then the + rule is split into several lines using `\'-newline. + + `-MG' says to treat missing header files as generated files and + assume they live in the same directory as the source file. It + must be specified in addition to `-M'. + + This feature is used in automatic updating of makefiles. + +`-MM [-MG]' + Like `-M' but mention only the files included with `#include + "FILE"'. System header files included with `#include ' are + omitted. + +`-MD FILE' + Like `-M' but the dependency information is written to FILE. This + is in addition to compiling the file as specified--`-MD' does not + inhibit ordinary compilation the way `-M' does. + + When invoking gcc, do not specify the FILE argument. Gcc will + create file names made by replacing ".c" with ".d" at the end of + the input file names. + + In Mach, you can use the utility `md' to merge multiple dependency + files into a single dependency file suitable for using with the + `make' command. + +`-MMD FILE' + Like `-MD' except mention only user header files, not system + header files. + +`-H' + Print the name of each header file used, in addition to other + normal activities. + +`-imacros FILE' + Process FILE as input, discarding the resulting output, before + processing the regular input file. Because the output generated + from FILE is discarded, the only effect of `-imacros FILE' is to + make the macros defined in FILE available for use in the main + input. + +`-include FILE' + Process FILE as input, and include all the resulting output, + before processing the regular input file. + +`-idirafter DIR' + Add the directory DIR to the second include path. The directories + on the second include path are searched when a header file is not + found in any of the directories in the main include path (the one + that `-I' adds to). + +`-iprefix PREFIX' + Specify PREFIX as the prefix for subsequent `-iwithprefix' options. + +`-iwithprefix DIR' + Add a directory to the second include path. The directory's name + is made by concatenating PREFIX and DIR, where PREFIX was + specified previously with `-iprefix'. + +`-isystem DIR' + Add a directory to the beginning of the second include path, + marking it as a system directory, so that it gets the same special + treatment as is applied to the standard system directories. + +`-lang-c' +`-lang-c89' +`-lang-c++' +`-lang-objc' +`-lang-objc++' + Specify the source language. `-lang-c' is the default; it allows + recognition of C++ comments (comments that begin with `//' and end + at end of line), since this is a common feature and it will most + likely be in the next C standard. `-lang-c89' disables + recognition of C++ comments. `-lang-c++' handles C++ comment + syntax and includes extra default include directories for C++. + `-lang-objc' enables the Objective C `#import' directive. + `-lang-objc++' enables both C++ and Objective C extensions. + + These options are generated by the compiler driver `gcc', but not + passed from the `gcc' command line unless you use the driver's + `-Wp' option. + +`-lint' + Look for commands to the program checker `lint' embedded in + comments, and emit them preceded by `#pragma lint'. For example, + the comment `/* NOTREACHED */' becomes `#pragma lint NOTREACHED'. + + This option is available only when you call `cpp' directly; `gcc' + will not pass it from its command line. + +`-$' + Forbid the use of `$' in identifiers. This is required for ANSI + conformance. `gcc' automatically supplies this option to the + preprocessor if you specify `-ansi', but `gcc' doesn't recognize + the `-$' option itself--to use it without the other effects of + `-ansi', you must call the preprocessor directly. + + +File: cpp.info, Node: Concept Index, Next: Index, Prev: Invocation, Up: Top + +Concept Index +************* + +* Menu: + +* ##: Concatenation. +* arguments in macro definitions: Argument Macros. +* assertions: Assertions. +* assertions, undoing: Assertions. +* blank macro arguments: Argument Macros. +* cascaded macros: Cascaded Macros. +* commenting out code: Deleted Code. +* computed #include: Include Syntax. +* concatenation: Concatenation. +* conditionals: Conditionals. +* directives: Directives. +* expansion of arguments: Argument Prescan. +* function-like macro: Argument Macros. +* header file: Header Files. +* including just once: Once-Only. +* inheritance: Inheritance. +* invocation of the preprocessor: Invocation. +* line control: Combining Sources. +* macro argument expansion: Argument Prescan. +* macro body uses macro: Cascaded Macros. +* macros with argument: Argument Macros. +* manifest constant: Simple Macros. +* newlines in macro arguments: Newlines in Args. +* null directive: Other Directives. +* options: Invocation. +* output format: Output. +* overriding a header file: Inheritance. +* parentheses in macro bodies: Macro Parentheses. +* pitfalls of macros: Macro Pitfalls. +* predefined macros: Predefined. +* predicates: Assertions. +* preprocessing directives: Directives. +* prescan of macro arguments: Argument Prescan. +* problems with macros: Macro Pitfalls. +* redefining macros: Redefining. +* repeated inclusion: Once-Only. +* retracting assertions: Assertions. +* second include path: Invocation. +* self-reference: Self-Reference. +* semicolons (after macro calls): Swallow Semicolon. +* side effects (in macro arguments): Side Effects. +* simple macro: Simple Macros. +* space as macro argument: Argument Macros. +* standard predefined macros: Standard Predefined. +* stringification: Stringification. +* testing predicates: Assertions. +* unassert: Assertions. +* undefining macros: Undefining. +* unsafe macros: Side Effects. + + +File: cpp.info, Node: Index, Prev: Concept Index, Up: Top + +Index of Directives, Macros and Options +*************************************** + +* Menu: + +* #assert: Assertions. +* #cpu: Assertions. +* #define: Argument Macros. +* #elif: #elif Directive. +* #else: #else Directive. +* #error: #error Directive. +* #ident: Other Directives. +* #if: Conditional Syntax. +* #ifdef: Conditionals-Macros. +* #ifndef: Conditionals-Macros. +* #import: Once-Only. +* #include: Include Syntax. +* #include_next: Inheritance. +* #line: Combining Sources. +* #machine: Assertions. +* #pragma: Other Directives. +* #pragma once: Once-Only. +* #system: Assertions. +* #unassert: Assertions. +* #warning: #error Directive. +* -$: Invocation. +* -A: Invocation. +* -C: Invocation. +* -D: Invocation. +* -dD: Invocation. +* -dM: Invocation. +* -H: Invocation. +* -I: Invocation. +* -idirafter: Invocation. +* -imacros: Invocation. +* -include: Invocation. +* -iprefix: Invocation. +* -isystem: Invocation. +* -iwithprefix: Invocation. +* -lang-c: Invocation. +* -lang-c++: Invocation. +* -lang-c89: Invocation. +* -lang-objc: Invocation. +* -lang-objc++: Invocation. +* -M: Invocation. +* -MD: Invocation. +* -MM: Invocation. +* -MMD: Invocation. +* -nostdinc: Invocation. +* -nostdinc++: Invocation. +* -P: Invocation. +* -pedantic: Invocation. +* -pedantic-errors: Invocation. +* -traditional: Invocation. +* -trigraphs: Invocation. +* -U: Invocation. +* -undef: Invocation. +* -Wall: Invocation. +* -Wcomment: Invocation. +* -Wtraditional: Invocation. +* -Wtrigraphs: Invocation. +* __BASE_FILE__: Standard Predefined. +* __CHAR_UNSIGNED__: Standard Predefined. +* __cplusplus: Standard Predefined. +* __DATE__: Standard Predefined. +* __FILE__: Standard Predefined. +* __GNUC__: Standard Predefined. +* __GNUC_MINOR__: Standard Predefined. +* __GNUG__: Standard Predefined. +* __INCLUDE_LEVEL_: Standard Predefined. +* __LINE__: Standard Predefined. +* __OPTIMIZE__: Standard Predefined. +* __REGISTER_PREFIX__: Standard Predefined. +* __STDC__: Standard Predefined. +* __STDC_VERSION__: Standard Predefined. +* __STRICT_ANSI__: Standard Predefined. +* __TIME__: Standard Predefined. +* __USER_LABEL_PREFIX__: Standard Predefined. +* __VERSION__: Standard Predefined. +* _AM29000: Nonstandard Predefined. +* _AM29K: Nonstandard Predefined. +* BSD: Nonstandard Predefined. +* defined: Conditionals-Macros. +* M68020: Nonstandard Predefined. +* m68k: Nonstandard Predefined. +* mc68000: Nonstandard Predefined. +* ns32000: Nonstandard Predefined. +* pyr: Nonstandard Predefined. +* sequent: Nonstandard Predefined. +* sun: Nonstandard Predefined. +* system header files: Header Uses. +* unix: Nonstandard Predefined. +* vax: Nonstandard Predefined. + + diff --git a/support/cpp/cpp.texi b/support/cpp/cpp.texi new file mode 100644 index 00000000..1de83717 --- /dev/null +++ b/support/cpp/cpp.texi @@ -0,0 +1,2856 @@ +\input texinfo +@setfilename cpp.info +@settitle The C Preprocessor + +@ignore +@ifinfo +@format +START-INFO-DIR-ENTRY +* Cpp: (cpp). The C preprocessor. +END-INFO-DIR-ENTRY +@end format +@end ifinfo +@end ignore + +@c @smallbook +@c @cropmarks +@c @finalout +@setchapternewpage odd +@ifinfo +This file documents the GNU C Preprocessor. + +Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software +Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through Tex and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions. +@end ifinfo + +@titlepage +@c @finalout +@title The C Preprocessor +@subtitle Last revised July 1992 +@subtitle for GCC version 2 +@author Richard M. Stallman +@page +@vskip 2pc +This booklet is eventually intended to form the first chapter of a GNU +C Language manual. + +@vskip 0pt plus 1filll +Copyright @copyright{} 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free +Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions. +@end titlepage +@page + +@node Top, Global Actions,, (DIR) +@chapter The C Preprocessor + +The C preprocessor is a @dfn{macro processor} that is used automatically by +the C compiler to transform your program before actual compilation. It is +called a macro processor because it allows you to define @dfn{macros}, +which are brief abbreviations for longer constructs. + +The C preprocessor provides four separate facilities that you can use as +you see fit: + +@itemize @bullet +@item +Inclusion of header files. These are files of declarations that can be +substituted into your program. + +@item +Macro expansion. You can define @dfn{macros}, which are abbreviations +for arbitrary fragments of C code, and then the C preprocessor will +replace the macros with their definitions throughout the program. + +@item +Conditional compilation. Using special preprocessing directives, you +can include or exclude parts of the program according to various +conditions. + +@item +Line control. If you use a program to combine or rearrange source files into +an intermediate file which is then compiled, you can use line control +to inform the compiler of where each source line originally came from. +@end itemize + +C preprocessors vary in some details. This manual discusses the GNU C +preprocessor, the C Compatible Compiler Preprocessor. The GNU C +preprocessor provides a superset of the features of ANSI Standard C. + +ANSI Standard C requires the rejection of many harmless constructs commonly +used by today's C programs. Such incompatibility would be inconvenient for +users, so the GNU C preprocessor is configured to accept these constructs +by default. Strictly speaking, to get ANSI Standard C, you must use the +options @samp{-trigraphs}, @samp{-undef} and @samp{-pedantic}, but in +practice the consequences of having strict ANSI Standard C make it +undesirable to do this. @xref{Invocation}. + +@menu +* Global Actions:: Actions made uniformly on all input files. +* Directives:: General syntax of preprocessing directives. +* Header Files:: How and why to use header files. +* Macros:: How and why to use macros. +* Conditionals:: How and why to use conditionals. +* Combining Sources:: Use of line control when you combine source files. +* Other Directives:: Miscellaneous preprocessing directives. +* Output:: Format of output from the C preprocessor. +* Invocation:: How to invoke the preprocessor; command options. +* Concept Index:: Index of concepts and terms. +* Index:: Index of directives, predefined macros and options. +@end menu + +@node Global Actions, Directives, Top, Top +@section Transformations Made Globally + +Most C preprocessor features are inactive unless you give specific directives +to request their use. (Preprocessing directives are lines starting with +@samp{#}; @pxref{Directives}). But there are three transformations that the +preprocessor always makes on all the input it receives, even in the absence +of directives. + +@itemize @bullet +@item +All C comments are replaced with single spaces. + +@item +Backslash-Newline sequences are deleted, no matter where. This +feature allows you to break long lines for cosmetic purposes without +changing their meaning. + +@item +Predefined macro names are replaced with their expansions +(@pxref{Predefined}). +@end itemize + +The first two transformations are done @emph{before} nearly all other parsing +and before preprocessing directives are recognized. Thus, for example, you +can split a line cosmetically with Backslash-Newline anywhere (except +when trigraphs are in use; see below). + +@example +/* +*/ # /* +*/ defi\ +ne FO\ +O 10\ +20 +@end example + +@noindent +is equivalent into @samp{#define FOO 1020}. You can split even an escape +sequence with Backslash-Newline. For example, you can split @code{"foo\bar"} +between the @samp{\} and the @samp{b} to get + +@example +"foo\\ +bar" +@end example + +@noindent +This behavior is unclean: in all other contexts, a Backslash can be +inserted in a string constant as an ordinary character by writing a double +Backslash, and this creates an exception. But the ANSI C standard requires +it. (Strict ANSI C does not allow Newlines in string constants, so they +do not consider this a problem.) + +But there are a few exceptions to all three transformations. + +@itemize @bullet +@item +C comments and predefined macro names are not recognized inside a +@samp{#include} directive in which the file name is delimited with +@samp{<} and @samp{>}. + +@item +C comments and predefined macro names are never recognized within a +character or string constant. (Strictly speaking, this is the rule, +not an exception, but it is worth noting here anyway.) + +@item +Backslash-Newline may not safely be used within an ANSI ``trigraph''. +Trigraphs are converted before Backslash-Newline is deleted. If you +write what looks like a trigraph with a Backslash-Newline inside, the +Backslash-Newline is deleted as usual, but it is then too late to +recognize the trigraph. + +This exception is relevant only if you use the @samp{-trigraphs} +option to enable trigraph processing. @xref{Invocation}. +@end itemize + +@node Directives, Header Files, Global Actions, Top +@section Preprocessing Directives + +@cindex preprocessing directives +@cindex directives +Most preprocessor features are active only if you use preprocessing directives +to request their use. + +Preprocessing directives are lines in your program that start with @samp{#}. +The @samp{#} is followed by an identifier that is the @dfn{directive name}. +For example, @samp{#define} is the directive that defines a macro. +Whitespace is also allowed before and after the @samp{#}. + +The set of valid directive names is fixed. Programs cannot define new +preprocessing directives. + +Some directive names require arguments; these make up the rest of the directive +line and must be separated from the directive name by whitespace. For example, +@samp{#define} must be followed by a macro name and the intended expansion +of the macro. @xref{Simple Macros}. + +A preprocessing directive cannot be more than one line in normal circumstances. +It may be split cosmetically with Backslash-Newline, but that has no effect +on its meaning. Comments containing Newlines can also divide the +directive into multiple lines, but the comments are changed to Spaces +before the directive is interpreted. The only way a significant Newline +can occur in a preprocessing directive is within a string constant or +character constant. Note that +most C compilers that might be applied to the output from the preprocessor +do not accept string or character constants containing Newlines. + +The @samp{#} and the directive name cannot come from a macro expansion. For +example, if @samp{foo} is defined as a macro expanding to @samp{define}, +that does not make @samp{#foo} a valid preprocessing directive. + +@node Header Files, Macros, Directives, Top +@section Header Files + +@cindex header file +A header file is a file containing C declarations and macro definitions +(@pxref{Macros}) to be shared between several source files. You request +the use of a header file in your program with the C preprocessing directive +@samp{#include}. + +@menu +* Header Uses:: What header files are used for. +* Include Syntax:: How to write @samp{#include} directives. +* Include Operation:: What @samp{#include} does. +* Once-Only:: Preventing multiple inclusion of one header file. +* Inheritance:: Including one header file in another header file. +@end menu + +@node Header Uses, Include Syntax, Header Files, Header Files +@subsection Uses of Header Files + +Header files serve two kinds of purposes. + +@itemize @bullet +@item +@findex system header files +System header files declare the interfaces to parts of the operating +system. You include them in your program to supply the definitions and +declarations you need to invoke system calls and libraries. + +@item +Your own header files contain declarations for interfaces between the +source files of your program. Each time you have a group of related +declarations and macro definitions all or most of which are needed in +several different source files, it is a good idea to create a header +file for them. +@end itemize + +Including a header file produces the same results in C compilation as +copying the header file into each source file that needs it. But such +copying would be time-consuming and error-prone. With a header file, the +related declarations appear in only one place. If they need to be changed, +they can be changed in one place, and programs that include the header file +will automatically use the new version when next recompiled. The header +file eliminates the labor of finding and changing all the copies as well as +the risk that a failure to find one copy will result in inconsistencies +within a program. + +The usual convention is to give header files names that end with +@file{.h}. Avoid unusual characters in header file names, as they +reduce portability. + +@node Include Syntax, Include Operation, Header Uses, Header Files +@subsection The @samp{#include} Directive + +@findex #include +Both user and system header files are included using the preprocessing +directive @samp{#include}. It has three variants: + +@table @code +@item #include <@var{file}> +This variant is used for system header files. It searches for a file +named @var{file} in a list of directories specified by you, then in a +standard list of system directories. You specify directories to +search for header files with the command option @samp{-I} +(@pxref{Invocation}). The option @samp{-nostdinc} inhibits searching +the standard system directories; in this case only the directories +you specify are searched. + +The parsing of this form of @samp{#include} is slightly special +because comments are not recognized within the @samp{<@dots{}>}. +Thus, in @samp{#include } the @samp{/*} does not start a comment +and the directive specifies inclusion of a system header file named +@file{x/*y}. Of course, a header file with such a name is unlikely to +exist on Unix, where shell wildcard features would make it hard to +manipulate.@refill + +The argument @var{file} may not contain a @samp{>} character. It may, +however, contain a @samp{<} character. + +@item #include "@var{file}" +This variant is used for header files of your own program. It +searches for a file named @var{file} first in the current directory, +then in the same directories used for system header files. The +current directory is the directory of the current input file. It is +tried first because it is presumed to be the location of the files +that the current input file refers to. (If the @samp{-I-} option is +used, the special treatment of the current directory is inhibited.) + +The argument @var{file} may not contain @samp{"} characters. If +backslashes occur within @var{file}, they are considered ordinary text +characters, not escape characters. None of the character escape +sequences appropriate to string constants in C are processed. Thus, +@samp{#include "x\n\\y"} specifies a filename containing three +backslashes. It is not clear why this behavior is ever useful, but +the ANSI standard specifies it. + +@item #include @var{anything else} +@cindex computed @samp{#include} +This variant is called a @dfn{computed #include}. Any @samp{#include} +directive whose argument does not fit the above two forms is a computed +include. The text @var{anything else} is checked for macro calls, +which are expanded (@pxref{Macros}). When this is done, the result +must fit one of the above two variants---in particular, the expanded +text must in the end be surrounded by either quotes or angle braces. + +This feature allows you to define a macro which controls the file name +to be used at a later point in the program. One application of this is +to allow a site-specific configuration file for your program to specify +the names of the system include files to be used. This can help in +porting the program to various operating systems in which the necessary +system header files are found in different places. +@end table + +@node Include Operation, Once-Only, Include Syntax, Header Files +@subsection How @samp{#include} Works + +The @samp{#include} directive works by directing the C preprocessor to scan +the specified file as input before continuing with the rest of the current +file. The output from the preprocessor contains the output already +generated, followed by the output resulting from the included file, +followed by the output that comes from the text after the @samp{#include} +directive. For example, given a header file @file{header.h} as follows, + +@example +char *test (); +@end example + +@noindent +and a main program called @file{program.c} that uses the header file, +like this, + +@example +int x; +#include "header.h" + +main () +@{ + printf (test ()); +@} +@end example + +@noindent +the output generated by the C preprocessor for @file{program.c} as input +would be + +@example +int x; +char *test (); + +main () +@{ + printf (test ()); +@} +@end example + +Included files are not limited to declarations and macro definitions; those +are merely the typical uses. Any fragment of a C program can be included +from another file. The include file could even contain the beginning of a +statement that is concluded in the containing file, or the end of a +statement that was started in the including file. However, a comment or a +string or character constant may not start in the included file and finish +in the including file. An unterminated comment, string constant or +character constant in an included file is considered to end (with an error +message) at the end of the file. + +It is possible for a header file to begin or end a syntactic unit such +as a function definition, but that would be very confusing, so don't do +it. + +The line following the @samp{#include} directive is always treated as a +separate line by the C preprocessor even if the included file lacks a final +newline. + +@node Once-Only, Inheritance, Include Operation, Header Files +@subsection Once-Only Include Files +@cindex repeated inclusion +@cindex including just once + +Very often, one header file includes another. It can easily result that a +certain header file is included more than once. This may lead to errors, +if the header file defines structure types or typedefs, and is certainly +wasteful. Therefore, we often wish to prevent multiple inclusion of a +header file. + +The standard way to do this is to enclose the entire real contents of the +file in a conditional, like this: + +@example +#ifndef FILE_FOO_SEEN +#define FILE_FOO_SEEN + +@var{the entire file} + +#endif /* FILE_FOO_SEEN */ +@end example + +The macro @code{FILE_FOO_SEEN} indicates that the file has been included +once already. In a user header file, the macro name should not begin +with @samp{_}. In a system header file, this name should begin with +@samp{__} to avoid conflicts with user programs. In any kind of header +file, the macro name should contain the name of the file and some +additional text, to avoid conflicts with other header files. + +The GNU C preprocessor is programmed to notice when a header file uses +this particular construct and handle it efficiently. If a header file +is contained entirely in a @samp{#ifndef} conditional, then it records +that fact. If a subsequent @samp{#include} specifies the same file, +and the macro in the @samp{#ifndef} is already defined, then the file +is entirely skipped, without even reading it. + +@findex #pragma once +There is also an explicit directive to tell the preprocessor that it need +not include a file more than once. This is called @samp{#pragma once}, +and was used @emph{in addition to} the @samp{#ifndef} conditional around +the contents of the header file. @samp{#pragma once} is now obsolete +and should not be used at all. + +@findex #import +In the Objective C language, there is a variant of @samp{#include} +called @samp{#import} which includes a file, but does so at most once. +If you use @samp{#import} @emph{instead of} @samp{#include}, then you +don't need the conditionals inside the header file to prevent multiple +execution of the contents. + +@samp{#import} is obsolete because it is not a well designed feature. +It requires the users of a header file---the applications +programmers---to know that a certain header file should only be included +once. It is much better for the header file's implementor to write the +file so that users don't need to know this. Using @samp{#ifndef} +accomplishes this goal. + +@node Inheritance,, Once-Only, Header Files +@subsection Inheritance and Header Files +@cindex inheritance +@cindex overriding a header file + +@dfn{Inheritance} is what happens when one object or file derives some +of its contents by virtual copying from another object or file. In +the case of C header files, inheritance means that one header file +includes another header file and then replaces or adds something. + +If the inheriting header file and the base header file have different +names, then inheritance is straightforward: simply write @samp{#include +"@var{base}"} in the inheriting file. + +Sometimes it is necessary to give the inheriting file the same name as +the base file. This is less straightforward. + +For example, suppose an application program uses the system header file +@file{sys/signal.h}, but the version of @file{/usr/include/sys/signal.h} +on a particular system doesn't do what the application program expects. +It might be convenient to define a ``local'' version, perhaps under the +name @file{/usr/local/include/sys/signal.h}, to override or add to the +one supplied by the system. + +You can do this by using the option @samp{-I.} for compilation, and +writing a file @file{sys/signal.h} that does what the application +program expects. But making this file include the standard +@file{sys/signal.h} is not so easy---writing @samp{#include +} in that file doesn't work, because it includes your own +version of the file, not the standard system version. Used in that file +itself, this leads to an infinite recursion and a fatal error in +compilation. + +@samp{#include } would find the proper file, +but that is not clean, since it makes an assumption about where the +system header file is found. This is bad for maintenance, since it +means that any change in where the system's header files are kept +requires a change somewhere else. + +@findex #include_next +The clean way to solve this problem is to use +@samp{#include_next}, which means, ``Include the @emph{next} file with +this name.'' This directive works like @samp{#include} except in +searching for the specified file: it starts searching the list of header +file directories @emph{after} the directory in which the current file +was found. + +Suppose you specify @samp{-I /usr/local/include}, and the list of +directories to search also includes @file{/usr/include}; and suppose that +both directories contain a file named @file{sys/signal.h}. Ordinary +@samp{#include } finds the file under +@file{/usr/local/include}. If that file contains @samp{#include_next +}, it starts searching after that directory, and finds the +file in @file{/usr/include}. + +@node Macros, Conditionals, Header Files, Top +@section Macros + +A macro is a sort of abbreviation which you can define once and then +use later. There are many complicated features associated with macros +in the C preprocessor. + +@menu +* Simple Macros:: Macros that always expand the same way. +* Argument Macros:: Macros that accept arguments that are substituted + into the macro expansion. +* Predefined:: Predefined macros that are always available. +* Stringification:: Macro arguments converted into string constants. +* Concatenation:: Building tokens from parts taken from macro arguments. +* Undefining:: Cancelling a macro's definition. +* Redefining:: Changing a macro's definition. +* Macro Pitfalls:: Macros can confuse the unwary. Here we explain + several common problems and strange features. +@end menu + +@node Simple Macros, Argument Macros, Macros, Macros +@subsection Simple Macros +@cindex simple macro +@cindex manifest constant + +A @dfn{simple macro} is a kind of abbreviation. It is a name which +stands for a fragment of code. Some people refer to these as +@dfn{manifest constants}. + +Before you can use a macro, you must @dfn{define} it explicitly with the +@samp{#define} directive. @samp{#define} is followed by the name of the +macro and then the code it should be an abbreviation for. For example, + +@example +#define BUFFER_SIZE 1020 +@end example + +@noindent +defines a macro named @samp{BUFFER_SIZE} as an abbreviation for the text +@samp{1020}. If somewhere after this @samp{#define} directive there comes +a C statement of the form + +@example +foo = (char *) xmalloc (BUFFER_SIZE); +@end example + +@noindent +then the C preprocessor will recognize and @dfn{expand} the macro +@samp{BUFFER_SIZE}, resulting in + +@example +foo = (char *) xmalloc (1020); +@end example + +The use of all upper case for macro names is a standard convention. +Programs are easier to read when it is possible to tell at a glance which +names are macros. + +Normally, a macro definition must be a single line, like all C +preprocessing directives. (You can split a long macro definition +cosmetically with Backslash-Newline.) There is one exception: Newlines +can be included in the macro definition if within a string or character +constant. This is because it is not possible for a macro definition to +contain an unbalanced quote character; the definition automatically +extends to include the matching quote character that ends the string or +character constant. Comments within a macro definition may contain +Newlines, which make no difference since the comments are entirely +replaced with Spaces regardless of their contents. + +Aside from the above, there is no restriction on what can go in a macro +body. Parentheses need not balance. The body need not resemble valid C +code. (But if it does not, you may get error messages from the C +compiler when you use the macro.) + +The C preprocessor scans your program sequentially, so macro definitions +take effect at the place you write them. Therefore, the following input to +the C preprocessor + +@example +foo = X; +#define X 4 +bar = X; +@end example + +@noindent +produces as output + +@example +foo = X; + +bar = 4; +@end example + +After the preprocessor expands a macro name, the macro's definition body is +appended to the front of the remaining input, and the check for macro calls +continues. Therefore, the macro body can contain calls to other macros. +For example, after + +@example +#define BUFSIZE 1020 +#define TABLESIZE BUFSIZE +@end example + +@noindent +the name @samp{TABLESIZE} when used in the program would go through two +stages of expansion, resulting ultimately in @samp{1020}. + +This is not at all the same as defining @samp{TABLESIZE} to be @samp{1020}. +The @samp{#define} for @samp{TABLESIZE} uses exactly the body you +specify---in this case, @samp{BUFSIZE}---and does not check to see whether +it too is the name of a macro. It's only when you @emph{use} @samp{TABLESIZE} +that the result of its expansion is checked for more macro names. +@xref{Cascaded Macros}. + +@node Argument Macros, Predefined, Simple Macros, Macros +@subsection Macros with Arguments +@cindex macros with argument +@cindex arguments in macro definitions +@cindex function-like macro + +A simple macro always stands for exactly the same text, each time it is +used. Macros can be more flexible when they accept @dfn{arguments}. +Arguments are fragments of code that you supply each time the macro is +used. These fragments are included in the expansion of the macro +according to the directions in the macro definition. A macro that +accepts arguments is called a @dfn{function-like macro} because the +syntax for using it looks like a function call. + +@findex #define +To define a macro that uses arguments, you write a @samp{#define} directive +with a list of @dfn{argument names} in parentheses after the name of the +macro. The argument names may be any valid C identifiers, separated by +commas and optionally whitespace. The open-parenthesis must follow the +macro name immediately, with no space in between. + +For example, here is a macro that computes the minimum of two numeric +values, as it is defined in many C programs: + +@example +#define min(X, Y) ((X) < (Y) ? (X) : (Y)) +@end example + +@noindent +(This is not the best way to define a ``minimum'' macro in GNU C. +@xref{Side Effects}, for more information.) + +To use a macro that expects arguments, you write the name of the macro +followed by a list of @dfn{actual arguments} in parentheses, separated by +commas. The number of actual arguments you give must match the number of +arguments the macro expects. Examples of use of the macro @samp{min} +include @samp{min (1, 2)} and @samp{min (x + 28, *p)}. + +The expansion text of the macro depends on the arguments you use. +Each of the argument names of the macro is replaced, throughout the +macro definition, with the corresponding actual argument. Using the +same macro @samp{min} defined above, @samp{min (1, 2)} expands into + +@example +((1) < (2) ? (1) : (2)) +@end example + +@noindent +where @samp{1} has been substituted for @samp{X} and @samp{2} for @samp{Y}. + +Likewise, @samp{min (x + 28, *p)} expands into + +@example +((x + 28) < (*p) ? (x + 28) : (*p)) +@end example + +Parentheses in the actual arguments must balance; a comma within +parentheses does not end an argument. However, there is no requirement +for brackets or braces to balance, and they do not prevent a comma from +separating arguments. Thus, + +@example +macro (array[x = y, x + 1]) +@end example + +@noindent +passes two arguments to @code{macro}: @samp{array[x = y} and @samp{x + +1]}. If you want to supply @samp{array[x = y, x + 1]} as an argument, +you must write it as @samp{array[(x = y, x + 1)]}, which is equivalent C +code. + +After the actual arguments are substituted into the macro body, the entire +result is appended to the front of the remaining input, and the check for +macro calls continues. Therefore, the actual arguments can contain calls +to other macros, either with or without arguments, or even to the same +macro. The macro body can also contain calls to other macros. For +example, @samp{min (min (a, b), c)} expands into this text: + +@example +((((a) < (b) ? (a) : (b))) < (c) + ? (((a) < (b) ? (a) : (b))) + : (c)) +@end example + +@noindent +(Line breaks shown here for clarity would not actually be generated.) + +@cindex blank macro arguments +@cindex space as macro argument +If a macro @code{foo} takes one argument, and you want to supply an +empty argument, you must write at least some whitespace between the +parentheses, like this: @samp{foo ( )}. Just @samp{foo ()} is providing +no arguments, which is an error if @code{foo} expects an argument. But +@samp{foo0 ()} is the correct way to call a macro defined to take zero +arguments, like this: + +@example +#define foo0() @dots{} +@end example + +If you use the macro name followed by something other than an +open-parenthesis (after ignoring any spaces, tabs and comments that +follow), it is not a call to the macro, and the preprocessor does not +change what you have written. Therefore, it is possible for the same name +to be a variable or function in your program as well as a macro, and you +can choose in each instance whether to refer to the macro (if an actual +argument list follows) or the variable or function (if an argument list +does not follow). + +Such dual use of one name could be confusing and should be avoided +except when the two meanings are effectively synonymous: that is, when the +name is both a macro and a function and the two have similar effects. You +can think of the name simply as a function; use of the name for purposes +other than calling it (such as, to take the address) will refer to the +function, while calls will expand the macro and generate better but +equivalent code. For example, you can use a function named @samp{min} in +the same source file that defines the macro. If you write @samp{&min} with +no argument list, you refer to the function. If you write @samp{min (x, +bb)}, with an argument list, the macro is expanded. If you write +@samp{(min) (a, bb)}, where the name @samp{min} is not followed by an +open-parenthesis, the macro is not expanded, so you wind up with a call to +the function @samp{min}. + +You may not define the same name as both a simple macro and a macro with +arguments. + +In the definition of a macro with arguments, the list of argument names +must follow the macro name immediately with no space in between. If there +is a space after the macro name, the macro is defined as taking no +arguments, and all the rest of the line is taken to be the expansion. The +reason for this is that it is often useful to define a macro that takes no +arguments and whose definition begins with an identifier in parentheses. +This rule about spaces makes it possible for you to do either this: + +@example +#define FOO(x) - 1 / (x) +@end example + +@noindent +(which defines @samp{FOO} to take an argument and expand into minus the +reciprocal of that argument) or this: + +@example +#define BAR (x) - 1 / (x) +@end example + +@noindent +(which defines @samp{BAR} to take no argument and always expand into +@samp{(x) - 1 / (x)}). + +Note that the @emph{uses} of a macro with arguments can have spaces before +the left parenthesis; it's the @emph{definition} where it matters whether +there is a space. + +@node Predefined, Stringification, Argument Macros, Macros +@subsection Predefined Macros + +@cindex predefined macros +Several simple macros are predefined. You can use them without giving +definitions for them. They fall into two classes: standard macros and +system-specific macros. + +@menu +* Standard Predefined:: Standard predefined macros. +* Nonstandard Predefined:: Nonstandard predefined macros. +@end menu + +@node Standard Predefined, Nonstandard Predefined, Predefined, Predefined +@subsubsection Standard Predefined Macros +@cindex standard predefined macros + +The standard predefined macros are available with the same meanings +regardless of the machine or operating system on which you are using GNU C. +Their names all start and end with double underscores. Those preceding +@code{__GNUC__} in this table are standardized by ANSI C; the rest are +GNU C extensions. + +@table @code +@item __FILE__ +@findex __FILE__ +This macro expands to the name of the current input file, in the form of +a C string constant. The precise name returned is the one that was +specified in @samp{#include} or as the input file name argument. + +@item __LINE__ +@findex __LINE__ +This macro expands to the current input line number, in the form of a +decimal integer constant. While we call it a predefined macro, it's +a pretty strange macro, since its ``definition'' changes with each +new line of source code. + +This and @samp{__FILE__} are useful in generating an error message to +report an inconsistency detected by the program; the message can state +the source line at which the inconsistency was detected. For example, + +@smallexample +fprintf (stderr, "Internal error: " + "negative string length " + "%d at %s, line %d.", + length, __FILE__, __LINE__); +@end smallexample + +A @samp{#include} directive changes the expansions of @samp{__FILE__} +and @samp{__LINE__} to correspond to the included file. At the end of +that file, when processing resumes on the input file that contained +the @samp{#include} directive, the expansions of @samp{__FILE__} and +@samp{__LINE__} revert to the values they had before the +@samp{#include} (but @samp{__LINE__} is then incremented by one as +processing moves to the line after the @samp{#include}). + +The expansions of both @samp{__FILE__} and @samp{__LINE__} are altered +if a @samp{#line} directive is used. @xref{Combining Sources}. + +@item __DATE__ +@findex __DATE__ +This macro expands to a string constant that describes the date on +which the preprocessor is being run. The string constant contains +eleven characters and looks like @samp{"Jan 29 1987"} or @w{@samp{"Apr +1 1905"}}. + +@item __TIME__ +@findex __TIME__ +This macro expands to a string constant that describes the time at +which the preprocessor is being run. The string constant contains +eight characters and looks like @samp{"23:59:01"}. + +@item __STDC__ +@findex __STDC__ +This macro expands to the constant 1, to signify that this is ANSI +Standard C. (Whether that is actually true depends on what C compiler +will operate on the output from the preprocessor.) + +@item __STDC_VERSION__ +@findex __STDC_VERSION__ +This macro expands to the C Standard's version number, +a long integer constant of the form @samp{@var{yyyy}@var{mm}L} +where @var{yyyy} and @var{mm} are the year and month of the Standard version. +This signifies which version of the C Standard the preprocessor conforms to. +Like @samp{__STDC__}, whether this version number is accurate +for the entire implementation depends on what C compiler +will operate on the output from the preprocessor. + +@item __GNUC__ +@findex __GNUC__ +This macro is defined if and only if this is GNU C. This macro is +defined only when the entire GNU C compiler is in use; if you invoke the +preprocessor directly, @samp{__GNUC__} is undefined. The value +identifies the major version number of GNU CC (@samp{1} for GNU CC +version 1, which is now obsolete, and @samp{2} for version 2). + +@item __GNUC_MINOR__ +@findex __GNUC_MINOR__ +The macro contains the minor version number of the compiler. This can +be used to work around differences between different releases of the +compiler (for example, if gcc 2.6.3 is known to support a feature, you +can test for @code{__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6)}). +The last number, @samp{3} in the +example above, denotes the bugfix level of the compiler; no macro +contains this value. + +@item __GNUG__ +@findex __GNUG__ +The GNU C compiler defines this when the compilation language is +C++; use @samp{__GNUG__} to distinguish between GNU C and GNU +C++. + +@item __cplusplus +@findex __cplusplus +The draft ANSI standard for C++ used to require predefining this +variable. Though it is no longer required, GNU C++ continues to define +it, as do other popular C++ compilers. You can use @samp{__cplusplus} +to test whether a header is compiled by a C compiler or a C++ compiler. + +@item __STRICT_ANSI__ +@findex __STRICT_ANSI__ +This macro is defined if and only if the @samp{-ansi} switch was +specified when GNU C was invoked. Its definition is the null string. +This macro exists primarily to direct certain GNU header files not to +define certain traditional Unix constructs which are incompatible with +ANSI C. + +@item __BASE_FILE__ +@findex __BASE_FILE__ +This macro expands to the name of the main input file, in the form +of a C string constant. This is the source file that was specified +as an argument when the C compiler was invoked. + +@item __INCLUDE_LEVEL__ +@findex __INCLUDE_LEVEL_ +This macro expands to a decimal integer constant that represents the +depth of nesting in include files. The value of this macro is +incremented on every @samp{#include} directive and decremented at every +end of file. For input files specified by command line arguments, +the nesting level is zero. + +@item __VERSION__ +@findex __VERSION__ +This macro expands to a string which describes the version number of +GNU C. The string is normally a sequence of decimal numbers separated +by periods, such as @samp{"2.6.0"}. The only reasonable use of this +macro is to incorporate it into a string constant. + +@item __OPTIMIZE__ +@findex __OPTIMIZE__ +This macro is defined in optimizing compilations. It causes certain +GNU header files to define alternative macro definitions for some +system library functions. It is unwise to refer to or test the +definition of this macro unless you make very sure that programs will +execute with the same effect regardless. + +@item __CHAR_UNSIGNED__ +@findex __CHAR_UNSIGNED__ +This macro is defined if and only if the data type @code{char} is +unsigned on the target machine. It exists to cause the standard +header file @file{limit.h} to work correctly. It is bad practice +to refer to this macro yourself; instead, refer to the standard +macros defined in @file{limit.h}. The preprocessor uses +this macro to determine whether or not to sign-extend large character +constants written in octal; see @ref{#if Directive,,The @samp{#if} Directive}. + +@item __REGISTER_PREFIX__ +@findex __REGISTER_PREFIX__ +This macro expands to a string describing the prefix applied to cpu +registers in assembler code. It can be used to write assembler code +that is usable in multiple environments. For example, in the +@samp{m68k-aout} environment it expands to the string @samp{""}, +but in the @samp{m68k-coff} environment it expands to the string +@samp{"%"}. + +@item __USER_LABEL_PREFIX__ +@findex __USER_LABEL_PREFIX__ +This macro expands to a string describing the prefix applied to +user generated labels in assembler code. It can be used to write +assembler code that is usable in multiple environments. +For example, in the @samp{m68k-aout} environment it expands to the +string @samp{"_"}, but in the @samp{m68k-coff} environment it expands +to the string @samp{""}. +@end table + +@node Nonstandard Predefined,, Standard Predefined, Predefined +@subsubsection Nonstandard Predefined Macros + +The C preprocessor normally has several predefined macros that vary between +machines because their purpose is to indicate what type of system and +machine is in use. This manual, being for all systems and machines, cannot +tell you exactly what their names are; instead, we offer a list of some +typical ones. You can use @samp{cpp -dM} to see the values of +predefined macros; see @ref{Invocation}. + +Some nonstandard predefined macros describe the operating system in use, +with more or less specificity. For example, + +@table @code +@item unix +@findex unix +@samp{unix} is normally predefined on all Unix systems. + +@item BSD +@findex BSD +@samp{BSD} is predefined on recent versions of Berkeley Unix +(perhaps only in version 4.3). +@end table + +Other nonstandard predefined macros describe the kind of CPU, with more or +less specificity. For example, + +@table @code +@item vax +@findex vax +@samp{vax} is predefined on Vax computers. + +@item mc68000 +@findex mc68000 +@samp{mc68000} is predefined on most computers whose CPU is a Motorola +68000, 68010 or 68020. + +@item m68k +@findex m68k +@samp{m68k} is also predefined on most computers whose CPU is a 68000, +68010 or 68020; however, some makers use @samp{mc68000} and some use +@samp{m68k}. Some predefine both names. What happens in GNU C +depends on the system you are using it on. + +@item M68020 +@findex M68020 +@samp{M68020} has been observed to be predefined on some systems that +use 68020 CPUs---in addition to @samp{mc68000} and @samp{m68k}, which +are less specific. + +@item _AM29K +@findex _AM29K +@itemx _AM29000 +@findex _AM29000 +Both @samp{_AM29K} and @samp{_AM29000} are predefined for the AMD 29000 +CPU family. + +@item ns32000 +@findex ns32000 +@samp{ns32000} is predefined on computers which use the National +Semiconductor 32000 series CPU. +@end table + +Yet other nonstandard predefined macros describe the manufacturer of +the system. For example, + +@table @code +@item sun +@findex sun +@samp{sun} is predefined on all models of Sun computers. + +@item pyr +@findex pyr +@samp{pyr} is predefined on all models of Pyramid computers. + +@item sequent +@findex sequent +@samp{sequent} is predefined on all models of Sequent computers. +@end table + +These predefined symbols are not only nonstandard, they are contrary to the +ANSI standard because their names do not start with underscores. +Therefore, the option @samp{-ansi} inhibits the definition of these +symbols. + +This tends to make @samp{-ansi} useless, since many programs depend on the +customary nonstandard predefined symbols. Even system header files check +them and will generate incorrect declarations if they do not find the names +that are expected. You might think that the header files supplied for the +Uglix computer would not need to test what machine they are running on, +because they can simply assume it is the Uglix; but often they do, and they +do so using the customary names. As a result, very few C programs will +compile with @samp{-ansi}. We intend to avoid such problems on the GNU +system. + +What, then, should you do in an ANSI C program to test the type of machine +it will run on? + +GNU C offers a parallel series of symbols for this purpose, whose names +are made from the customary ones by adding @samp{__} at the beginning +and end. Thus, the symbol @code{__vax__} would be available on a Vax, +and so on. + +The set of nonstandard predefined names in the GNU C preprocessor is +controlled (when @code{cpp} is itself compiled) by the macro +@samp{CPP_PREDEFINES}, which should be a string containing @samp{-D} +options, separated by spaces. For example, on the Sun 3, we use the +following definition: + +@example +#define CPP_PREDEFINES "-Dmc68000 -Dsun -Dunix -Dm68k" +@end example + +@noindent +This macro is usually specified in @file{tm.h}. + +@node Stringification, Concatenation, Predefined, Macros +@subsection Stringification + +@cindex stringification +@dfn{Stringification} means turning a code fragment into a string constant +whose contents are the text for the code fragment. For example, +stringifying @samp{foo (z)} results in @samp{"foo (z)"}. + +In the C preprocessor, stringification is an option available when macro +arguments are substituted into the macro definition. In the body of the +definition, when an argument name appears, the character @samp{#} before +the name specifies stringification of the corresponding actual argument +when it is substituted at that point in the definition. The same argument +may be substituted in other places in the definition without +stringification if the argument name appears in those places with no +@samp{#}. + +Here is an example of a macro definition that uses stringification: + +@smallexample +@group +#define WARN_IF(EXP) \ +do @{ if (EXP) \ + fprintf (stderr, "Warning: " #EXP "\n"); @} \ +while (0) +@end group +@end smallexample + +@noindent +Here the actual argument for @samp{EXP} is substituted once as given, +into the @samp{if} statement, and once as stringified, into the +argument to @samp{fprintf}. The @samp{do} and @samp{while (0)} are +a kludge to make it possible to write @samp{WARN_IF (@var{arg});}, +which the resemblance of @samp{WARN_IF} to a function would make +C programmers want to do; see @ref{Swallow Semicolon}. + +The stringification feature is limited to transforming one macro argument +into one string constant: there is no way to combine the argument with +other text and then stringify it all together. But the example above shows +how an equivalent result can be obtained in ANSI Standard C using the +feature that adjacent string constants are concatenated as one string +constant. The preprocessor stringifies the actual value of @samp{EXP} +into a separate string constant, resulting in text like + +@smallexample +@group +do @{ if (x == 0) \ + fprintf (stderr, "Warning: " "x == 0" "\n"); @} \ +while (0) +@end group +@end smallexample + +@noindent +but the C compiler then sees three consecutive string constants and +concatenates them into one, producing effectively + +@smallexample +do @{ if (x == 0) \ + fprintf (stderr, "Warning: x == 0\n"); @} \ +while (0) +@end smallexample + +Stringification in C involves more than putting doublequote characters +around the fragment; it is necessary to put backslashes in front of all +doublequote characters, and all backslashes in string and character +constants, in order to get a valid C string constant with the proper +contents. Thus, stringifying @samp{p = "foo\n";} results in @samp{"p = +\"foo\\n\";"}. However, backslashes that are not inside of string or +character constants are not duplicated: @samp{\n} by itself stringifies to +@samp{"\n"}. + +Whitespace (including comments) in the text being stringified is handled +according to precise rules. All leading and trailing whitespace is ignored. +Any sequence of whitespace in the middle of the text is converted to +a single space in the stringified result. + +@node Concatenation, Undefining, Stringification, Macros +@subsection Concatenation +@cindex concatenation +@cindex @samp{##} +@dfn{Concatenation} means joining two strings into one. In the context +of macro expansion, concatenation refers to joining two lexical units +into one longer one. Specifically, an actual argument to the macro can be +concatenated with another actual argument or with fixed text to produce +a longer name. The longer name might be the name of a function, +variable or type, or a C keyword; it might even be the name of another +macro, in which case it will be expanded. + +When you define a macro, you request concatenation with the special +operator @samp{##} in the macro body. When the macro is called, +after actual arguments are substituted, all @samp{##} operators are +deleted, and so is any whitespace next to them (including whitespace +that was part of an actual argument). The result is to concatenate +the syntactic tokens on either side of the @samp{##}. + +Consider a C program that interprets named commands. There probably needs +to be a table of commands, perhaps an array of structures declared as +follows: + +@example +struct command +@{ + char *name; + void (*function) (); +@}; + +struct command commands[] = +@{ + @{ "quit", quit_command@}, + @{ "help", help_command@}, + @dots{} +@}; +@end example + +It would be cleaner not to have to give each command name twice, once in +the string constant and once in the function name. A macro which takes the +name of a command as an argument can make this unnecessary. The string +constant can be created with stringification, and the function name by +concatenating the argument with @samp{_command}. Here is how it is done: + +@example +#define COMMAND(NAME) @{ #NAME, NAME ## _command @} + +struct command commands[] = +@{ + COMMAND (quit), + COMMAND (help), + @dots{} +@}; +@end example + +The usual case of concatenation is concatenating two names (or a name and a +number) into a longer name. But this isn't the only valid case. It is +also possible to concatenate two numbers (or a number and a name, such as +@samp{1.5} and @samp{e3}) into a number. Also, multi-character operators +such as @samp{+=} can be formed by concatenation. In some cases it is even +possible to piece together a string constant. However, two pieces of text +that don't together form a valid lexical unit cannot be concatenated. For +example, concatenation with @samp{x} on one side and @samp{+} on the other +is not meaningful because those two characters can't fit together in any +lexical unit of C. The ANSI standard says that such attempts at +concatenation are undefined, but in the GNU C preprocessor it is well +defined: it puts the @samp{x} and @samp{+} side by side with no particular +special results. + +Keep in mind that the C preprocessor converts comments to whitespace before +macros are even considered. Therefore, you cannot create a comment by +concatenating @samp{/} and @samp{*}: the @samp{/*} sequence that starts a +comment is not a lexical unit, but rather the beginning of a ``long'' space +character. Also, you can freely use comments next to a @samp{##} in a +macro definition, or in actual arguments that will be concatenated, because +the comments will be converted to spaces at first sight, and concatenation +will later discard the spaces. + +@node Undefining, Redefining, Concatenation, Macros +@subsection Undefining Macros + +@cindex undefining macros +To @dfn{undefine} a macro means to cancel its definition. This is done +with the @samp{#undef} directive. @samp{#undef} is followed by the macro +name to be undefined. + +Like definition, undefinition occurs at a specific point in the source +file, and it applies starting from that point. The name ceases to be a +macro name, and from that point on it is treated by the preprocessor as if +it had never been a macro name. + +For example, + +@example +#define FOO 4 +x = FOO; +#undef FOO +x = FOO; +@end example + +@noindent +expands into + +@example +x = 4; + +x = FOO; +@end example + +@noindent +In this example, @samp{FOO} had better be a variable or function as well +as (temporarily) a macro, in order for the result of the expansion to be +valid C code. + +The same form of @samp{#undef} directive will cancel definitions with +arguments or definitions that don't expect arguments. The @samp{#undef} +directive has no effect when used on a name not currently defined as a macro. + +@node Redefining, Macro Pitfalls, Undefining, Macros +@subsection Redefining Macros + +@cindex redefining macros +@dfn{Redefining} a macro means defining (with @samp{#define}) a name that +is already defined as a macro. + +A redefinition is trivial if the new definition is transparently identical +to the old one. You probably wouldn't deliberately write a trivial +redefinition, but they can happen automatically when a header file is +included more than once (@pxref{Header Files}), so they are accepted +silently and without effect. + +Nontrivial redefinition is considered likely to be an error, so +it provokes a warning message from the preprocessor. However, sometimes it +is useful to change the definition of a macro in mid-compilation. You can +inhibit the warning by undefining the macro with @samp{#undef} before the +second definition. + +In order for a redefinition to be trivial, the new definition must +exactly match the one already in effect, with two possible exceptions: + +@itemize @bullet +@item +Whitespace may be added or deleted at the beginning or the end. + +@item +Whitespace may be changed in the middle (but not inside strings). +However, it may not be eliminated entirely, and it may not be added +where there was no whitespace at all. +@end itemize + +Recall that a comment counts as whitespace. + +@node Macro Pitfalls,, Redefining, Macros +@subsection Pitfalls and Subtleties of Macros +@cindex problems with macros +@cindex pitfalls of macros + +In this section we describe some special rules that apply to macros and +macro expansion, and point out certain cases in which the rules have +counterintuitive consequences that you must watch out for. + +@menu +* Misnesting:: Macros can contain unmatched parentheses. +* Macro Parentheses:: Why apparently superfluous parentheses + may be necessary to avoid incorrect grouping. +* Swallow Semicolon:: Macros that look like functions + but expand into compound statements. +* Side Effects:: Unsafe macros that cause trouble when + arguments contain side effects. +* Self-Reference:: Macros whose definitions use the macros' own names. +* Argument Prescan:: Actual arguments are checked for macro calls + before they are substituted. +* Cascaded Macros:: Macros whose definitions use other macros. +* Newlines in Args:: Sometimes line numbers get confused. +@end menu + +@node Misnesting, Macro Parentheses, Macro Pitfalls, Macro Pitfalls +@subsubsection Improperly Nested Constructs + +Recall that when a macro is called with arguments, the arguments are +substituted into the macro body and the result is checked, together with +the rest of the input file, for more macro calls. + +It is possible to piece together a macro call coming partially from the +macro body and partially from the actual arguments. For example, + +@example +#define double(x) (2*(x)) +#define call_with_1(x) x(1) +@end example + +@noindent +would expand @samp{call_with_1 (double)} into @samp{(2*(1))}. + +Macro definitions do not have to have balanced parentheses. By writing an +unbalanced open parenthesis in a macro body, it is possible to create a +macro call that begins inside the macro body but ends outside of it. For +example, + +@example +#define strange(file) fprintf (file, "%s %d", +@dots{} +strange(stderr) p, 35) +@end example + +@noindent +This bizarre example expands to @samp{fprintf (stderr, "%s %d", p, 35)}! + +@node Macro Parentheses, Swallow Semicolon, Misnesting, Macro Pitfalls +@subsubsection Unintended Grouping of Arithmetic +@cindex parentheses in macro bodies + +You may have noticed that in most of the macro definition examples shown +above, each occurrence of a macro argument name had parentheses around it. +In addition, another pair of parentheses usually surround the entire macro +definition. Here is why it is best to write macros that way. + +Suppose you define a macro as follows, + +@example +#define ceil_div(x, y) (x + y - 1) / y +@end example + +@noindent +whose purpose is to divide, rounding up. (One use for this operation is +to compute how many @samp{int} objects are needed to hold a certain +number of @samp{char} objects.) Then suppose it is used as follows: + +@example +a = ceil_div (b & c, sizeof (int)); +@end example + +@noindent +This expands into + +@example +a = (b & c + sizeof (int) - 1) / sizeof (int); +@end example + +@noindent +which does not do what is intended. The operator-precedence rules of +C make it equivalent to this: + +@example +a = (b & (c + sizeof (int) - 1)) / sizeof (int); +@end example + +@noindent +But what we want is this: + +@example +a = ((b & c) + sizeof (int) - 1)) / sizeof (int); +@end example + +@noindent +Defining the macro as + +@example +#define ceil_div(x, y) ((x) + (y) - 1) / (y) +@end example + +@noindent +provides the desired result. + +However, unintended grouping can result in another way. Consider +@samp{sizeof ceil_div(1, 2)}. That has the appearance of a C expression +that would compute the size of the type of @samp{ceil_div (1, 2)}, but in +fact it means something very different. Here is what it expands to: + +@example +sizeof ((1) + (2) - 1) / (2) +@end example + +@noindent +This would take the size of an integer and divide it by two. The precedence +rules have put the division outside the @samp{sizeof} when it was intended +to be inside. + +Parentheses around the entire macro definition can prevent such problems. +Here, then, is the recommended way to define @samp{ceil_div}: + +@example +#define ceil_div(x, y) (((x) + (y) - 1) / (y)) +@end example + +@node Swallow Semicolon, Side Effects, Macro Parentheses, Macro Pitfalls +@subsubsection Swallowing the Semicolon + +@cindex semicolons (after macro calls) +Often it is desirable to define a macro that expands into a compound +statement. Consider, for example, the following macro, that advances a +pointer (the argument @samp{p} says where to find it) across whitespace +characters: + +@example +#define SKIP_SPACES (p, limit) \ +@{ register char *lim = (limit); \ + while (p != lim) @{ \ + if (*p++ != ' ') @{ \ + p--; break; @}@}@} +@end example + +@noindent +Here Backslash-Newline is used to split the macro definition, which must +be a single line, so that it resembles the way such C code would be +laid out if not part of a macro definition. + +A call to this macro might be @samp{SKIP_SPACES (p, lim)}. Strictly +speaking, the call expands to a compound statement, which is a complete +statement with no need for a semicolon to end it. But it looks like a +function call. So it minimizes confusion if you can use it like a function +call, writing a semicolon afterward, as in @samp{SKIP_SPACES (p, lim);} + +But this can cause trouble before @samp{else} statements, because the +semicolon is actually a null statement. Suppose you write + +@example +if (*p != 0) + SKIP_SPACES (p, lim); +else @dots{} +@end example + +@noindent +The presence of two statements---the compound statement and a null +statement---in between the @samp{if} condition and the @samp{else} +makes invalid C code. + +The definition of the macro @samp{SKIP_SPACES} can be altered to solve +this problem, using a @samp{do @dots{} while} statement. Here is how: + +@example +#define SKIP_SPACES (p, limit) \ +do @{ register char *lim = (limit); \ + while (p != lim) @{ \ + if (*p++ != ' ') @{ \ + p--; break; @}@}@} \ +while (0) +@end example + +Now @samp{SKIP_SPACES (p, lim);} expands into + +@example +do @{@dots{}@} while (0); +@end example + +@noindent +which is one statement. + +@node Side Effects, Self-Reference, Swallow Semicolon, Macro Pitfalls +@subsubsection Duplication of Side Effects + +@cindex side effects (in macro arguments) +@cindex unsafe macros +Many C programs define a macro @samp{min}, for ``minimum'', like this: + +@example +#define min(X, Y) ((X) < (Y) ? (X) : (Y)) +@end example + +When you use this macro with an argument containing a side effect, +as shown here, + +@example +next = min (x + y, foo (z)); +@end example + +@noindent +it expands as follows: + +@example +next = ((x + y) < (foo (z)) ? (x + y) : (foo (z))); +@end example + +@noindent +where @samp{x + y} has been substituted for @samp{X} and @samp{foo (z)} +for @samp{Y}. + +The function @samp{foo} is used only once in the statement as it appears +in the program, but the expression @samp{foo (z)} has been substituted +twice into the macro expansion. As a result, @samp{foo} might be called +two times when the statement is executed. If it has side effects or +if it takes a long time to compute, the results might not be what you +intended. We say that @samp{min} is an @dfn{unsafe} macro. + +The best solution to this problem is to define @samp{min} in a way that +computes the value of @samp{foo (z)} only once. The C language offers no +standard way to do this, but it can be done with GNU C extensions as +follows: + +@example +#define min(X, Y) \ +(@{ typeof (X) __x = (X), __y = (Y); \ + (__x < __y) ? __x : __y; @}) +@end example + +If you do not wish to use GNU C extensions, the only solution is to be +careful when @emph{using} the macro @samp{min}. For example, you can +calculate the value of @samp{foo (z)}, save it in a variable, and use that +variable in @samp{min}: + +@example +#define min(X, Y) ((X) < (Y) ? (X) : (Y)) +@dots{} +@{ + int tem = foo (z); + next = min (x + y, tem); +@} +@end example + +@noindent +(where we assume that @samp{foo} returns type @samp{int}). + +@node Self-Reference, Argument Prescan, Side Effects, Macro Pitfalls +@subsubsection Self-Referential Macros + +@cindex self-reference +A @dfn{self-referential} macro is one whose name appears in its definition. +A special feature of ANSI Standard C is that the self-reference is not +considered a macro call. It is passed into the preprocessor output +unchanged. + +Let's consider an example: + +@example +#define foo (4 + foo) +@end example + +@noindent +where @samp{foo} is also a variable in your program. + +Following the ordinary rules, each reference to @samp{foo} will expand into +@samp{(4 + foo)}; then this will be rescanned and will expand into @samp{(4 ++ (4 + foo))}; and so on until it causes a fatal error (memory full) in the +preprocessor. + +However, the special rule about self-reference cuts this process short +after one step, at @samp{(4 + foo)}. Therefore, this macro definition +has the possibly useful effect of causing the program to add 4 to +the value of @samp{foo} wherever @samp{foo} is referred to. + +In most cases, it is a bad idea to take advantage of this feature. A +person reading the program who sees that @samp{foo} is a variable will +not expect that it is a macro as well. The reader will come across the +identifier @samp{foo} in the program and think its value should be that +of the variable @samp{foo}, whereas in fact the value is four greater. + +The special rule for self-reference applies also to @dfn{indirect} +self-reference. This is the case where a macro @var{x} expands to use a +macro @samp{y}, and the expansion of @samp{y} refers to the macro +@samp{x}. The resulting reference to @samp{x} comes indirectly from the +expansion of @samp{x}, so it is a self-reference and is not further +expanded. Thus, after + +@example +#define x (4 + y) +#define y (2 * x) +@end example + +@noindent +@samp{x} would expand into @samp{(4 + (2 * x))}. Clear? + +But suppose @samp{y} is used elsewhere, not from the definition of @samp{x}. +Then the use of @samp{x} in the expansion of @samp{y} is not a self-reference +because @samp{x} is not ``in progress''. So it does expand. However, +the expansion of @samp{x} contains a reference to @samp{y}, and that +is an indirect self-reference now because @samp{y} is ``in progress''. +The result is that @samp{y} expands to @samp{(2 * (4 + y))}. + +It is not clear that this behavior would ever be useful, but it is specified +by the ANSI C standard, so you may need to understand it. + +@node Argument Prescan, Cascaded Macros, Self-Reference, Macro Pitfalls +@subsubsection Separate Expansion of Macro Arguments +@cindex expansion of arguments +@cindex macro argument expansion +@cindex prescan of macro arguments + +We have explained that the expansion of a macro, including the substituted +actual arguments, is scanned over again for macro calls to be expanded. + +What really happens is more subtle: first each actual argument text is scanned +separately for macro calls. Then the results of this are substituted into +the macro body to produce the macro expansion, and the macro expansion +is scanned again for macros to expand. + +The result is that the actual arguments are scanned @emph{twice} to expand +macro calls in them. + +Most of the time, this has no effect. If the actual argument contained +any macro calls, they are expanded during the first scan. The result +therefore contains no macro calls, so the second scan does not change it. +If the actual argument were substituted as given, with no prescan, +the single remaining scan would find the same macro calls and produce +the same results. + +You might expect the double scan to change the results when a +self-referential macro is used in an actual argument of another macro +(@pxref{Self-Reference}): the self-referential macro would be expanded once +in the first scan, and a second time in the second scan. But this is not +what happens. The self-references that do not expand in the first scan are +marked so that they will not expand in the second scan either. + +The prescan is not done when an argument is stringified or concatenated. +Thus, + +@example +#define str(s) #s +#define foo 4 +str (foo) +@end example + +@noindent +expands to @samp{"foo"}. Once more, prescan has been prevented from +having any noticeable effect. + +More precisely, stringification and concatenation use the argument as +written, in un-prescanned form. The same actual argument would be used in +prescanned form if it is substituted elsewhere without stringification or +concatenation. + +@example +#define str(s) #s lose(s) +#define foo 4 +str (foo) +@end example + +expands to @samp{"foo" lose(4)}. + +You might now ask, ``Why mention the prescan, if it makes no difference? +And why not skip it and make the preprocessor faster?'' The answer is +that the prescan does make a difference in three special cases: + +@itemize @bullet +@item +Nested calls to a macro. + +@item +Macros that call other macros that stringify or concatenate. + +@item +Macros whose expansions contain unshielded commas. +@end itemize + +We say that @dfn{nested} calls to a macro occur when a macro's actual +argument contains a call to that very macro. For example, if @samp{f} +is a macro that expects one argument, @samp{f (f (1))} is a nested +pair of calls to @samp{f}. The desired expansion is made by +expanding @samp{f (1)} and substituting that into the definition of +@samp{f}. The prescan causes the expected result to happen. +Without the prescan, @samp{f (1)} itself would be substituted as +an actual argument, and the inner use of @samp{f} would appear +during the main scan as an indirect self-reference and would not +be expanded. Here, the prescan cancels an undesirable side effect +(in the medical, not computational, sense of the term) of the special +rule for self-referential macros. + +But prescan causes trouble in certain other cases of nested macro calls. +Here is an example: + +@example +#define foo a,b +#define bar(x) lose(x) +#define lose(x) (1 + (x)) + +bar(foo) +@end example + +@noindent +We would like @samp{bar(foo)} to turn into @samp{(1 + (foo))}, which +would then turn into @samp{(1 + (a,b))}. But instead, @samp{bar(foo)} +expands into @samp{lose(a,b)}, and you get an error because @code{lose} +requires a single argument. In this case, the problem is easily solved +by the same parentheses that ought to be used to prevent misnesting of +arithmetic operations: + +@example +#define foo (a,b) +#define bar(x) lose((x)) +@end example + +The problem is more serious when the operands of the macro are not +expressions; for example, when they are statements. Then parentheses +are unacceptable because they would make for invalid C code: + +@example +#define foo @{ int a, b; @dots{} @} +@end example + +@noindent +In GNU C you can shield the commas using the @samp{(@{@dots{}@})} +construct which turns a compound statement into an expression: + +@example +#define foo (@{ int a, b; @dots{} @}) +@end example + +Or you can rewrite the macro definition to avoid such commas: + +@example +#define foo @{ int a; int b; @dots{} @} +@end example + +There is also one case where prescan is useful. It is possible +to use prescan to expand an argument and then stringify it---if you use +two levels of macros. Let's add a new macro @samp{xstr} to the +example shown above: + +@example +#define xstr(s) str(s) +#define str(s) #s +#define foo 4 +xstr (foo) +@end example + +This expands into @samp{"4"}, not @samp{"foo"}. The reason for the +difference is that the argument of @samp{xstr} is expanded at prescan +(because @samp{xstr} does not specify stringification or concatenation of +the argument). The result of prescan then forms the actual argument for +@samp{str}. @samp{str} uses its argument without prescan because it +performs stringification; but it cannot prevent or undo the prescanning +already done by @samp{xstr}. + +@node Cascaded Macros, Newlines in Args, Argument Prescan, Macro Pitfalls +@subsubsection Cascaded Use of Macros + +@cindex cascaded macros +@cindex macro body uses macro +A @dfn{cascade} of macros is when one macro's body contains a reference +to another macro. This is very common practice. For example, + +@example +#define BUFSIZE 1020 +#define TABLESIZE BUFSIZE +@end example + +This is not at all the same as defining @samp{TABLESIZE} to be @samp{1020}. +The @samp{#define} for @samp{TABLESIZE} uses exactly the body you +specify---in this case, @samp{BUFSIZE}---and does not check to see whether +it too is the name of a macro. + +It's only when you @emph{use} @samp{TABLESIZE} that the result of its expansion +is checked for more macro names. + +This makes a difference if you change the definition of @samp{BUFSIZE} +at some point in the source file. @samp{TABLESIZE}, defined as shown, +will always expand using the definition of @samp{BUFSIZE} that is +currently in effect: + +@example +#define BUFSIZE 1020 +#define TABLESIZE BUFSIZE +#undef BUFSIZE +#define BUFSIZE 37 +@end example + +@noindent +Now @samp{TABLESIZE} expands (in two stages) to @samp{37}. (The +@samp{#undef} is to prevent any warning about the nontrivial +redefinition of @code{BUFSIZE}.) + +@node Newlines in Args,, Cascaded Macros, Macro Pitfalls +@subsection Newlines in Macro Arguments +@cindex newlines in macro arguments + +Traditional macro processing carries forward all newlines in macro +arguments into the expansion of the macro. This means that, if some of +the arguments are substituted more than once, or not at all, or out of +order, newlines can be duplicated, lost, or moved around within the +expansion. If the expansion consists of multiple statements, then the +effect is to distort the line numbers of some of these statements. The +result can be incorrect line numbers, in error messages or displayed in +a debugger. + +The GNU C preprocessor operating in ANSI C mode adjusts appropriately +for multiple use of an argument---the first use expands all the +newlines, and subsequent uses of the same argument produce no newlines. +But even in this mode, it can produce incorrect line numbering if +arguments are used out of order, or not used at all. + +Here is an example illustrating this problem: + +@example +#define ignore_second_arg(a,b,c) a; c + +ignore_second_arg (foo (), + ignored (), + syntax error); +@end example + +@noindent +The syntax error triggered by the tokens @samp{syntax error} results +in an error message citing line four, even though the statement text +comes from line five. + +@node Conditionals, Combining Sources, Macros, Top +@section Conditionals + +@cindex conditionals +In a macro processor, a @dfn{conditional} is a directive that allows a part +of the program to be ignored during compilation, on some conditions. +In the C preprocessor, a conditional can test either an arithmetic expression +or whether a name is defined as a macro. + +A conditional in the C preprocessor resembles in some ways an @samp{if} +statement in C, but it is important to understand the difference between +them. The condition in an @samp{if} statement is tested during the execution +of your program. Its purpose is to allow your program to behave differently +from run to run, depending on the data it is operating on. The condition +in a preprocessing conditional directive is tested when your program is compiled. +Its purpose is to allow different code to be included in the program depending +on the situation at the time of compilation. + +@menu +* Uses: Conditional Uses. What conditionals are for. +* Syntax: Conditional Syntax. How conditionals are written. +* Deletion: Deleted Code. Making code into a comment. +* Macros: Conditionals-Macros. Why conditionals are used with macros. +* Assertions:: How and why to use assertions. +* Errors: #error Directive. Detecting inconsistent compilation parameters. +@end menu + +@node Conditional Uses +@subsection Why Conditionals are Used + +Generally there are three kinds of reason to use a conditional. + +@itemize @bullet +@item +A program may need to use different code depending on the machine or +operating system it is to run on. In some cases the code for one +operating system may be erroneous on another operating system; for +example, it might refer to library routines that do not exist on the +other system. When this happens, it is not enough to avoid executing +the invalid code: merely having it in the program makes it impossible +to link the program and run it. With a preprocessing conditional, the +offending code can be effectively excised from the program when it is +not valid. + +@item +You may want to be able to compile the same source file into two +different programs. Sometimes the difference between the programs is +that one makes frequent time-consuming consistency checks on its +intermediate data, or prints the values of those data for debugging, +while the other does not. + +@item +A conditional whose condition is always false is a good way to exclude +code from the program but keep it as a sort of comment for future +reference. +@end itemize + +Most simple programs that are intended to run on only one machine will +not need to use preprocessing conditionals. + +@node Conditional Syntax +@subsection Syntax of Conditionals + +@findex #if +A conditional in the C preprocessor begins with a @dfn{conditional +directive}: @samp{#if}, @samp{#ifdef} or @samp{#ifndef}. +@xref{Conditionals-Macros}, for information on @samp{#ifdef} and +@samp{#ifndef}; only @samp{#if} is explained here. + +@menu +* If: #if Directive. Basic conditionals using @samp{#if} and @samp{#endif}. +* Else: #else Directive. Including some text if the condition fails. +* Elif: #elif Directive. Testing several alternative possibilities. +@end menu + +@node #if Directive +@subsubsection The @samp{#if} Directive + +The @samp{#if} directive in its simplest form consists of + +@example +#if @var{expression} +@var{controlled text} +#endif /* @var{expression} */ +@end example + +The comment following the @samp{#endif} is not required, but it is a good +practice because it helps people match the @samp{#endif} to the +corresponding @samp{#if}. Such comments should always be used, except in +short conditionals that are not nested. In fact, you can put anything at +all after the @samp{#endif} and it will be ignored by the GNU C preprocessor, +but only comments are acceptable in ANSI Standard C. + +@var{expression} is a C expression of integer type, subject to stringent +restrictions. It may contain + +@itemize @bullet +@item +Integer constants, which are all regarded as @code{long} or +@code{unsigned long}. + +@item +Character constants, which are interpreted according to the character +set and conventions of the machine and operating system on which the +preprocessor is running. The GNU C preprocessor uses the C data type +@samp{char} for these character constants; therefore, whether some +character codes are negative is determined by the C compiler used to +compile the preprocessor. If it treats @samp{char} as signed, then +character codes large enough to set the sign bit will be considered +negative; otherwise, no character code is considered negative. + +@item +Arithmetic operators for addition, subtraction, multiplication, +division, bitwise operations, shifts, comparisons, and logical +operations (@samp{&&} and @samp{||}). + +@item +Identifiers that are not macros, which are all treated as zero(!). + +@item +Macro calls. All macro calls in the expression are expanded before +actual computation of the expression's value begins. +@end itemize + +Note that @samp{sizeof} operators and @code{enum}-type values are not allowed. +@code{enum}-type values, like all other identifiers that are not taken +as macro calls and expanded, are treated as zero. + +The @var{controlled text} inside of a conditional can include +preprocessing directives. Then the directives inside the conditional are +obeyed only if that branch of the conditional succeeds. The text can +also contain other conditional groups. However, the @samp{#if} and +@samp{#endif} directives must balance. + +@node #else Directive +@subsubsection The @samp{#else} Directive + +@findex #else +The @samp{#else} directive can be added to a conditional to provide +alternative text to be used if the condition is false. This is what +it looks like: + +@example +#if @var{expression} +@var{text-if-true} +#else /* Not @var{expression} */ +@var{text-if-false} +#endif /* Not @var{expression} */ +@end example + +If @var{expression} is nonzero, and thus the @var{text-if-true} is +active, then @samp{#else} acts like a failing conditional and the +@var{text-if-false} is ignored. Contrariwise, if the @samp{#if} +conditional fails, the @var{text-if-false} is considered included. + +@node #elif Directive +@subsubsection The @samp{#elif} Directive + +@findex #elif +One common case of nested conditionals is used to check for more than two +possible alternatives. For example, you might have + +@example +#if X == 1 +@dots{} +#else /* X != 1 */ +#if X == 2 +@dots{} +#else /* X != 2 */ +@dots{} +#endif /* X != 2 */ +#endif /* X != 1 */ +@end example + +Another conditional directive, @samp{#elif}, allows this to be abbreviated +as follows: + +@example +#if X == 1 +@dots{} +#elif X == 2 +@dots{} +#else /* X != 2 and X != 1*/ +@dots{} +#endif /* X != 2 and X != 1*/ +@end example + +@samp{#elif} stands for ``else if''. Like @samp{#else}, it goes in the +middle of a @samp{#if}-@samp{#endif} pair and subdivides it; it does not +require a matching @samp{#endif} of its own. Like @samp{#if}, the +@samp{#elif} directive includes an expression to be tested. + +The text following the @samp{#elif} is processed only if the original +@samp{#if}-condition failed and the @samp{#elif} condition succeeds. +More than one @samp{#elif} can go in the same @samp{#if}-@samp{#endif} +group. Then the text after each @samp{#elif} is processed only if the +@samp{#elif} condition succeeds after the original @samp{#if} and any +previous @samp{#elif} directives within it have failed. @samp{#else} is +equivalent to @samp{#elif 1}, and @samp{#else} is allowed after any +number of @samp{#elif} directives, but @samp{#elif} may not follow +@samp{#else}. + +@node Deleted Code +@subsection Keeping Deleted Code for Future Reference +@cindex commenting out code + +If you replace or delete a part of the program but want to keep the old +code around as a comment for future reference, the easy way to do this +is to put @samp{#if 0} before it and @samp{#endif} after it. This is +better than using comment delimiters @samp{/*} and @samp{*/} since those +won't work if the code already contains comments (C comments do not +nest). + +This works even if the code being turned off contains conditionals, but +they must be entire conditionals (balanced @samp{#if} and @samp{#endif}). + +Conversely, do not use @samp{#if 0} for comments which are not C code. +Use the comment delimiters @samp{/*} and @samp{*/} instead. The +interior of @samp{#if 0} must consist of complete tokens; in particular, +singlequote characters must balance. But comments often contain +unbalanced singlequote characters (known in English as apostrophes). +These confuse @samp{#if 0}. They do not confuse @samp{/*}. + +@node Conditionals-Macros +@subsection Conditionals and Macros + +Conditionals are useful in connection with macros or assertions, because +those are the only ways that an expression's value can vary from one +compilation to another. A @samp{#if} directive whose expression uses no +macros or assertions is equivalent to @samp{#if 1} or @samp{#if 0}; you +might as well determine which one, by computing the value of the +expression yourself, and then simplify the program. + +For example, here is a conditional that tests the expression +@samp{BUFSIZE == 1020}, where @samp{BUFSIZE} must be a macro. + +@example +#if BUFSIZE == 1020 + printf ("Large buffers!\n"); +#endif /* BUFSIZE is large */ +@end example + +(Programmers often wish they could test the size of a variable or data +type in @samp{#if}, but this does not work. The preprocessor does not +understand @code{sizeof}, or typedef names, or even the type keywords +such as @code{int}.) + +@findex defined +The special operator @samp{defined} is used in @samp{#if} expressions to +test whether a certain name is defined as a macro. Either @samp{defined +@var{name}} or @samp{defined (@var{name})} is an expression whose value +is 1 if @var{name} is defined as macro at the current point in the +program, and 0 otherwise. For the @samp{defined} operator it makes no +difference what the definition of the macro is; all that matters is +whether there is a definition. Thus, for example,@refill + +@example +#if defined (vax) || defined (ns16000) +@end example + +@noindent +would succeed if either of the names @samp{vax} and @samp{ns16000} is +defined as a macro. You can test the same condition using assertions +(@pxref{Assertions}), like this: + +@example +#if #cpu (vax) || #cpu (ns16000) +@end example + +If a macro is defined and later undefined with @samp{#undef}, +subsequent use of the @samp{defined} operator returns 0, because +the name is no longer defined. If the macro is defined again with +another @samp{#define}, @samp{defined} will recommence returning 1. + +@findex #ifdef +@findex #ifndef +Conditionals that test whether just one name is defined are very common, +so there are two special short conditional directives for this case. + +@table @code +@item #ifdef @var{name} +is equivalent to @samp{#if defined (@var{name})}. + +@item #ifndef @var{name} +is equivalent to @samp{#if ! defined (@var{name})}. +@end table + +Macro definitions can vary between compilations for several reasons. + +@itemize @bullet +@item +Some macros are predefined on each kind of machine. For example, on a +Vax, the name @samp{vax} is a predefined macro. On other machines, it +would not be defined. + +@item +Many more macros are defined by system header files. Different +systems and machines define different macros, or give them different +values. It is useful to test these macros with conditionals to avoid +using a system feature on a machine where it is not implemented. + +@item +Macros are a common way of allowing users to customize a program for +different machines or applications. For example, the macro +@samp{BUFSIZE} might be defined in a configuration file for your +program that is included as a header file in each source file. You +would use @samp{BUFSIZE} in a preprocessing conditional in order to +generate different code depending on the chosen configuration. + +@item +Macros can be defined or undefined with @samp{-D} and @samp{-U} +command options when you compile the program. You can arrange to +compile the same source file into two different programs by choosing +a macro name to specify which program you want, writing conditionals +to test whether or how this macro is defined, and then controlling +the state of the macro with compiler command options. +@xref{Invocation}. +@end itemize + +@ifinfo +Assertions are usually predefined, but can be defined with preprocessor +directives or command-line options. +@end ifinfo + +@node Assertions +@subsection Assertions + +@cindex assertions +@dfn{Assertions} are a more systematic alternative to macros in writing +conditionals to test what sort of computer or system the compiled +program will run on. Assertions are usually predefined, but you can +define them with preprocessing directives or command-line options. + +@cindex predicates +The macros traditionally used to describe the type of target are not +classified in any way according to which question they answer; they may +indicate a hardware architecture, a particular hardware model, an +operating system, a particular version of an operating system, or +specific configuration options. These are jumbled together in a single +namespace. In contrast, each assertion consists of a named question and +an answer. The question is usually called the @dfn{predicate}. +An assertion looks like this: + +@example +#@var{predicate} (@var{answer}) +@end example + +@noindent +You must use a properly formed identifier for @var{predicate}. The +value of @var{answer} can be any sequence of words; all characters are +significant except for leading and trailing whitespace, and differences +in internal whitespace sequences are ignored. Thus, @samp{x + y} is +different from @samp{x+y} but equivalent to @samp{x + y}. @samp{)} is +not allowed in an answer. + +@cindex testing predicates +Here is a conditional to test whether the answer @var{answer} is asserted +for the predicate @var{predicate}: + +@example +#if #@var{predicate} (@var{answer}) +@end example + +@noindent +There may be more than one answer asserted for a given predicate. If +you omit the answer, you can test whether @emph{any} answer is asserted +for @var{predicate}: + +@example +#if #@var{predicate} +@end example + +@findex #system +@findex #machine +@findex #cpu +Most of the time, the assertions you test will be predefined assertions. +GNU C provides three predefined predicates: @code{system}, @code{cpu}, +and @code{machine}. @code{system} is for assertions about the type of +software, @code{cpu} describes the type of computer architecture, and +@code{machine} gives more information about the computer. For example, +on a GNU system, the following assertions would be true: + +@example +#system (gnu) +#system (mach) +#system (mach 3) +#system (mach 3.@var{subversion}) +#system (hurd) +#system (hurd @var{version}) +@end example + +@noindent +and perhaps others. The alternatives with +more or less version information let you ask more or less detailed +questions about the type of system software. + +On a Unix system, you would find @code{#system (unix)} and perhaps one of: +@code{#system (aix)}, @code{#system (bsd)}, @code{#system (hpux)}, +@code{#system (lynx)}, @code{#system (mach)}, @code{#system (posix)}, +@code{#system (svr3)}, @code{#system (svr4)}, or @code{#system (xpg4)} +with possible version numbers following. + +Other values for @code{system} are @code{#system (mvs)} +and @code{#system (vms)}. + +@strong{Portability note:} Many Unix C compilers provide only one answer +for the @code{system} assertion: @code{#system (unix)}, if they support +assertions at all. This is less than useful. + +An assertion with a multi-word answer is completely different from several +assertions with individual single-word answers. For example, the presence +of @code{system (mach 3.0)} does not mean that @code{system (3.0)} is true. +It also does not directly imply @code{system (mach)}, but in GNU C, that +last will normally be asserted as well. + +The current list of possible assertion values for @code{cpu} is: +@code{#cpu (a29k)}, @code{#cpu (alpha)}, @code{#cpu (arm)}, @code{#cpu +(clipper)}, @code{#cpu (convex)}, @code{#cpu (elxsi)}, @code{#cpu +(tron)}, @code{#cpu (h8300)}, @code{#cpu (i370)}, @code{#cpu (i386)}, +@code{#cpu (i860)}, @code{#cpu (i960)}, @code{#cpu (m68k)}, @code{#cpu +(m88k)}, @code{#cpu (mips)}, @code{#cpu (ns32k)}, @code{#cpu (hppa)}, +@code{#cpu (pyr)}, @code{#cpu (ibm032)}, @code{#cpu (rs6000)}, +@code{#cpu (sh)}, @code{#cpu (sparc)}, @code{#cpu (spur)}, @code{#cpu +(tahoe)}, @code{#cpu (vax)}, @code{#cpu (we32000)}. + +@findex #assert +You can create assertions within a C program using @samp{#assert}, like +this: + +@example +#assert @var{predicate} (@var{answer}) +@end example + +@noindent +(Note the absence of a @samp{#} before @var{predicate}.) + +@cindex unassert +@cindex assertions, undoing +@cindex retracting assertions +@findex #unassert +Each time you do this, you assert a new true answer for @var{predicate}. +Asserting one answer does not invalidate previously asserted answers; +they all remain true. The only way to remove an assertion is with +@samp{#unassert}. @samp{#unassert} has the same syntax as +@samp{#assert}. You can also remove all assertions about +@var{predicate} like this: + +@example +#unassert @var{predicate} +@end example + +You can also add or cancel assertions using command options +when you run @code{gcc} or @code{cpp}. @xref{Invocation}. + +@node #error Directive +@subsection The @samp{#error} and @samp{#warning} Directives + +@findex #error +The directive @samp{#error} causes the preprocessor to report a fatal +error. The rest of the line that follows @samp{#error} is used as the +error message. + +You would use @samp{#error} inside of a conditional that detects a +combination of parameters which you know the program does not properly +support. For example, if you know that the program will not run +properly on a Vax, you might write + +@smallexample +@group +#ifdef __vax__ +#error Won't work on Vaxen. See comments at get_last_object. +#endif +@end group +@end smallexample + +@noindent +@xref{Nonstandard Predefined}, for why this works. + +If you have several configuration parameters that must be set up by +the installation in a consistent way, you can use conditionals to detect +an inconsistency and report it with @samp{#error}. For example, + +@smallexample +#if HASH_TABLE_SIZE % 2 == 0 || HASH_TABLE_SIZE % 3 == 0 \ + || HASH_TABLE_SIZE % 5 == 0 +#error HASH_TABLE_SIZE should not be divisible by a small prime +#endif +@end smallexample + +@findex #warning +The directive @samp{#warning} is like the directive @samp{#error}, but causes +the preprocessor to issue a warning and continue preprocessing. The rest of +the line that follows @samp{#warning} is used as the warning message. + +You might use @samp{#warning} in obsolete header files, with a message +directing the user to the header file which should be used instead. + +@node Combining Sources, Other Directives, Conditionals, Top +@section Combining Source Files + +@cindex line control +One of the jobs of the C preprocessor is to inform the C compiler of where +each line of C code came from: which source file and which line number. + +C code can come from multiple source files if you use @samp{#include}; +both @samp{#include} and the use of conditionals and macros can cause +the line number of a line in the preprocessor output to be different +from the line's number in the original source file. You will appreciate +the value of making both the C compiler (in error messages) and symbolic +debuggers such as GDB use the line numbers in your source file. + +The C preprocessor builds on this feature by offering a directive by which +you can control the feature explicitly. This is useful when a file for +input to the C preprocessor is the output from another program such as the +@code{bison} parser generator, which operates on another file that is the +true source file. Parts of the output from @code{bison} are generated from +scratch, other parts come from a standard parser file. The rest are copied +nearly verbatim from the source file, but their line numbers in the +@code{bison} output are not the same as their original line numbers. +Naturally you would like compiler error messages and symbolic debuggers to +know the original source file and line number of each line in the +@code{bison} input. + +@findex #line +@code{bison} arranges this by writing @samp{#line} directives into the output +file. @samp{#line} is a directive that specifies the original line number +and source file name for subsequent input in the current preprocessor input +file. @samp{#line} has three variants: + +@table @code +@item #line @var{linenum} +Here @var{linenum} is a decimal integer constant. This specifies that +the line number of the following line of input, in its original source file, +was @var{linenum}. + +@item #line @var{linenum} @var{filename} +Here @var{linenum} is a decimal integer constant and @var{filename} +is a string constant. This specifies that the following line of input +came originally from source file @var{filename} and its line number there +was @var{linenum}. Keep in mind that @var{filename} is not just a +file name; it is surrounded by doublequote characters so that it looks +like a string constant. + +@item #line @var{anything else} +@var{anything else} is checked for macro calls, which are expanded. +The result should be a decimal integer constant followed optionally +by a string constant, as described above. +@end table + +@samp{#line} directives alter the results of the @samp{__FILE__} and +@samp{__LINE__} predefined macros from that point on. @xref{Standard +Predefined}. + +The output of the preprocessor (which is the input for the rest of the +compiler) contains directives that look much like @samp{#line} directives. +They start with just @samp{#} instead of @samp{#line}, but this is +followed by a line number and file name as in @samp{#line}. @xref{Output}. + +@node Other Directives, Output, Combining Sources, Top +@section Miscellaneous Preprocessing Directives + +@cindex null directive +This section describes three additional preprocessing directives. They are +not very useful, but are mentioned for completeness. + +The @dfn{null directive} consists of a @samp{#} followed by a Newline, with +only whitespace (including comments) in between. A null directive is +understood as a preprocessing directive but has no effect on the preprocessor +output. The primary significance of the existence of the null directive is +that an input line consisting of just a @samp{#} will produce no output, +rather than a line of output containing just a @samp{#}. Supposedly +some old C programs contain such lines. + +@findex #pragma +The ANSI standard specifies that the @samp{#pragma} directive has an +arbitrary, implementation-defined effect. In the GNU C preprocessor, +@samp{#pragma} directives are not used, except for @samp{#pragma once} +(@pxref{Once-Only}). However, they are left in the preprocessor output, +so they are available to the compilation pass. + +@findex #ident +The @samp{#ident} directive is supported for compatibility with certain +other systems. It is followed by a line of text. On some systems, the +text is copied into a special place in the object file; on most systems, +the text is ignored and this directive has no effect. Typically +@samp{#ident} is only used in header files supplied with those systems +where it is meaningful. + +@node Output, Invocation, Other Directives, Top +@section C Preprocessor Output + +@cindex output format +The output from the C preprocessor looks much like the input, except +that all preprocessing directive lines have been replaced with blank lines +and all comments with spaces. Whitespace within a line is not altered; +however, a space is inserted after the expansions of most macro calls. + +Source file name and line number information is conveyed by lines of +the form + +@example +# @var{linenum} @var{filename} @var{flags} +@end example + +@noindent +which are inserted as needed into the middle of the input (but never +within a string or character constant). Such a line means that the +following line originated in file @var{filename} at line @var{linenum}. + +After the file name comes zero or more flags, which are @samp{1}, +@samp{2}, @samp{3}, or @samp{4}. If there are multiple flags, spaces separate +them. Here is what the flags mean: + +@table @samp +@item 1 +This indicates the start of a new file. +@item 2 +This indicates returning to a file (after having included another file). +@item 3 +This indicates that the following text comes from a system header file, +so certain warnings should be suppressed. +@item 4 +This indicates that the following text should be treated as C. +@c maybe cross reference NO_IMPLICIT_EXTERN_C +@end table + +@node Invocation, Concept Index, Output, Top +@section Invoking the C Preprocessor +@cindex invocation of the preprocessor + +Most often when you use the C preprocessor you will not have to invoke it +explicitly: the C compiler will do so automatically. However, the +preprocessor is sometimes useful on its own. + +The C preprocessor expects two file names as arguments, @var{infile} and +@var{outfile}. The preprocessor reads @var{infile} together with any other +files it specifies with @samp{#include}. All the output generated by the +combined input files is written in @var{outfile}. + +Either @var{infile} or @var{outfile} may be @samp{-}, which as @var{infile} +means to read from standard input and as @var{outfile} means to write to +standard output. Also, if @var{outfile} or both file names are omitted, +the standard output and standard input are used for the omitted file names. + +@cindex options +Here is a table of command options accepted by the C preprocessor. +These options can also be given when compiling a C program; they are +passed along automatically to the preprocessor when it is invoked by the +compiler. + +@table @samp +@item -P +@findex -P +Inhibit generation of @samp{#}-lines with line-number information in +the output from the preprocessor (@pxref{Output}). This might be +useful when running the preprocessor on something that is not C code +and will be sent to a program which might be confused by the +@samp{#}-lines. + +@item -C +@findex -C +Do not discard comments: pass them through to the output file. +Comments appearing in arguments of a macro call will be copied to the +output before the expansion of the macro call. + +@item -traditional +@findex -traditional +Try to imitate the behavior of old-fashioned C, as opposed to ANSI C. + +@itemize @bullet +@item +Traditional macro expansion pays no attention to singlequote or +doublequote characters; macro argument symbols are replaced by the +argument values even when they appear within apparent string or +character constants. + +@item +Traditionally, it is permissible for a macro expansion to end in the +middle of a string or character constant. The constant continues into +the text surrounding the macro call. + +@item +However, traditionally the end of the line terminates a string or +character constant, with no error. + +@item +In traditional C, a comment is equivalent to no text at all. (In ANSI +C, a comment counts as whitespace.) + +@item +Traditional C does not have the concept of a ``preprocessing number''. +It considers @samp{1.0e+4} to be three tokens: @samp{1.0e}, @samp{+}, +and @samp{4}. + +@item +A macro is not suppressed within its own definition, in traditional C. +Thus, any macro that is used recursively inevitably causes an error. + +@item +The character @samp{#} has no special meaning within a macro definition +in traditional C. + +@item +In traditional C, the text at the end of a macro expansion can run +together with the text after the macro call, to produce a single token. +(This is impossible in ANSI C.) + +@item +Traditionally, @samp{\} inside a macro argument suppresses the syntactic +significance of the following character. +@end itemize + +@item -trigraphs +@findex -trigraphs +Process ANSI standard trigraph sequences. These are three-character +sequences, all starting with @samp{??}, that are defined by ANSI C to +stand for single characters. For example, @samp{??/} stands for +@samp{\}, so @samp{'??/n'} is a character constant for a newline. +Strictly speaking, the GNU C preprocessor does not support all +programs in ANSI Standard C unless @samp{-trigraphs} is used, but if +you ever notice the difference it will be with relief. + +You don't want to know any more about trigraphs. + +@item -pedantic +@findex -pedantic +Issue warnings required by the ANSI C standard in certain cases such +as when text other than a comment follows @samp{#else} or @samp{#endif}. + +@item -pedantic-errors +@findex -pedantic-errors +Like @samp{-pedantic}, except that errors are produced rather than +warnings. + +@item -Wtrigraphs +@findex -Wtrigraphs +Warn if any trigraphs are encountered (assuming they are enabled). + +@item -Wcomment +@findex -Wcomment +@ignore +@c "Not worth documenting" both singular and plural forms of this +@c option, per RMS. But also unclear which is better; hence may need to +@c switch this at some future date. pesch@cygnus.com, 2jan92. +@itemx -Wcomments +(Both forms have the same effect). +@end ignore +Warn whenever a comment-start sequence @samp{/*} appears in a comment. + +@item -Wall +@findex -Wall +Requests both @samp{-Wtrigraphs} and @samp{-Wcomment} (but not +@samp{-Wtraditional}). + +@item -Wtraditional +@findex -Wtraditional +Warn about certain constructs that behave differently in traditional and +ANSI C. + +@item -I @var{directory} +@findex -I +Add the directory @var{directory} to the head of the list of +directories to be searched for header files (@pxref{Include Syntax}). +This can be used to override a system header file, substituting your +own version, since these directories are searched before the system +header file directories. If you use more than one @samp{-I} option, +the directories are scanned in left-to-right order; the standard +system directories come after. + +@item -I- +Any directories specified with @samp{-I} options before the @samp{-I-} +option are searched only for the case of @samp{#include "@var{file}"}; +they are not searched for @samp{#include <@var{file}>}. + +If additional directories are specified with @samp{-I} options after +the @samp{-I-}, these directories are searched for all @samp{#include} +directives. + +In addition, the @samp{-I-} option inhibits the use of the current +directory as the first search directory for @samp{#include "@var{file}"}. +Therefore, the current directory is searched only if it is requested +explicitly with @samp{-I.}. Specifying both @samp{-I-} and @samp{-I.} +allows you to control precisely which directories are searched before +the current one and which are searched after. + +@item -nostdinc +@findex -nostdinc +Do not search the standard system directories for header files. +Only the directories you have specified with @samp{-I} options +(and the current directory, if appropriate) are searched. + +@item -nostdinc++ +@findex -nostdinc++ +Do not search for header files in the C++-specific standard directories, +but do still search the other standard directories. +(This option is used when building libg++.) + +@item -D @var{name} +@findex -D +Predefine @var{name} as a macro, with definition @samp{1}. + +@item -D @var{name}=@var{definition} +Predefine @var{name} as a macro, with definition @var{definition}. +There are no restrictions on the contents of @var{definition}, but if +you are invoking the preprocessor from a shell or shell-like program you +may need to use the shell's quoting syntax to protect characters such as +spaces that have a meaning in the shell syntax. If you use more than +one @samp{-D} for the same @var{name}, the rightmost definition takes +effect. + +@item -U @var{name} +@findex -U +Do not predefine @var{name}. If both @samp{-U} and @samp{-D} are +specified for one name, the @samp{-U} beats the @samp{-D} and the name +is not predefined. + +@item -undef +@findex -undef +Do not predefine any nonstandard macros. + +@item -A @var{predicate}(@var{answer}) +@findex -A +Make an assertion with the predicate @var{predicate} and answer +@var{answer}. @xref{Assertions}. + +@noindent +You can use @samp{-A-} to disable all predefined assertions; it also +undefines all predefined macros that identify the type of target system. + +@item -dM +@findex -dM +Instead of outputting the result of preprocessing, output a list of +@samp{#define} directives for all the macros defined during the +execution of the preprocessor, including predefined macros. This gives +you a way of finding out what is predefined in your version of the +preprocessor; assuming you have no file @samp{foo.h}, the command + +@example +touch foo.h; cpp -dM foo.h +@end example + +@noindent +will show the values of any predefined macros. + +@item -dD +@findex -dD +Like @samp{-dM} except in two respects: it does @emph{not} include the +predefined macros, and it outputs @emph{both} the @samp{#define} +directives and the result of preprocessing. Both kinds of output go to +the standard output file. + +@item -M [-MG] +@findex -M +Instead of outputting the result of preprocessing, output a rule +suitable for @code{make} describing the dependencies of the main +source file. The preprocessor outputs one @code{make} rule containing +the object file name for that source file, a colon, and the names of +all the included files. If there are many included files then the +rule is split into several lines using @samp{\}-newline. + +@samp{-MG} says to treat missing header files as generated files and assume +they live in the same directory as the source file. It must be specified +in addition to @samp{-M}. + +This feature is used in automatic updating of makefiles. + +@item -MM [-MG] +@findex -MM +Like @samp{-M} but mention only the files included with @samp{#include +"@var{file}"}. System header files included with @samp{#include +<@var{file}>} are omitted. + +@item -MD @var{file} +@findex -MD +Like @samp{-M} but the dependency information is written to @var{file}. +This is in addition to compiling the file as specified---@samp{-MD} does +not inhibit ordinary compilation the way @samp{-M} does. + +When invoking gcc, do not specify the @var{file} argument. +Gcc will create file names made by replacing ".c" with ".d" at +the end of the input file names. + +In Mach, you can use the utility @code{md} to merge multiple dependency +files into a single dependency file suitable for using with the @samp{make} +command. + +@item -MMD @var{file} +@findex -MMD +Like @samp{-MD} except mention only user header files, not system +header files. + +@item -H +@findex -H +Print the name of each header file used, in addition to other normal +activities. + +@item -imacros @var{file} +@findex -imacros +Process @var{file} as input, discarding the resulting output, before +processing the regular input file. Because the output generated from +@var{file} is discarded, the only effect of @samp{-imacros @var{file}} +is to make the macros defined in @var{file} available for use in the +main input. + +@item -include @var{file} +@findex -include +Process @var{file} as input, and include all the resulting output, +before processing the regular input file. + +@item -idirafter @var{dir} +@findex -idirafter +@cindex second include path +Add the directory @var{dir} to the second include path. The directories +on the second include path are searched when a header file is not found +in any of the directories in the main include path (the one that +@samp{-I} adds to). + +@item -iprefix @var{prefix} +@findex -iprefix +Specify @var{prefix} as the prefix for subsequent @samp{-iwithprefix} +options. + +@item -iwithprefix @var{dir} +@findex -iwithprefix +Add a directory to the second include path. The directory's name is +made by concatenating @var{prefix} and @var{dir}, where @var{prefix} +was specified previously with @samp{-iprefix}. + +@item -isystem @var{dir} +@findex -isystem +Add a directory to the beginning of the second include path, marking it +as a system directory, so that it gets the same special treatment as +is applied to the standard system directories. + +@item -lang-c +@itemx -lang-c89 +@itemx -lang-c++ +@itemx -lang-objc +@itemx -lang-objc++ +@findex -lang-c +@findex -lang-c89 +@findex -lang-c++ +@findex -lang-objc +@findex -lang-objc++ +Specify the source language. @samp{-lang-c} is the default; it +allows recognition of C++ comments (comments that begin with +@samp{//} and end at end of line), since this is +a common feature and it will most likely be in the next C standard. +@samp{-lang-c89} disables recognition of C++ comments. @samp{-lang-c++} +handles C++ comment syntax and includes extra default include +directories for C++. @samp{-lang-objc} enables the Objective C +@samp{#import} directive. @samp{-lang-objc++} enables both C++ and Objective C +extensions. + +These options are generated by the compiler driver @code{gcc}, but not +passed from the @samp{gcc} command line unless you use the driver's +@samp{-Wp} option. + +@item -lint +Look for commands to the program checker @code{lint} embedded in +comments, and emit them preceded by @samp{#pragma lint}. For example, +the comment @samp{/* NOTREACHED */} becomes @samp{#pragma lint +NOTREACHED}. + +This option is available only when you call @code{cpp} directly; +@code{gcc} will not pass it from its command line. + +@item -$ +@findex -$ +Forbid the use of @samp{$} in identifiers. This is required for ANSI +conformance. @code{gcc} automatically supplies this option to the +preprocessor if you specify @samp{-ansi}, but @code{gcc} doesn't +recognize the @samp{-$} option itself---to use it without the other +effects of @samp{-ansi}, you must call the preprocessor directly. + +@end table + +@node Concept Index, Index, Invocation, Top +@unnumbered Concept Index +@printindex cp + +@node Index,, Concept Index, Top +@unnumbered Index of Directives, Macros and Options +@printindex fn + +@contents +@bye diff --git a/support/cpp/cppalloc.c b/support/cpp/cppalloc.c new file mode 100644 index 00000000..8e06b98d --- /dev/null +++ b/support/cpp/cppalloc.c @@ -0,0 +1,60 @@ +/* Part of CPP library. (memory allocation - xmalloc etc) + Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + Written by Per Bothner, 1994. + Based on CCCP program by by Paul Rubin, June 1986 + Adapted to ANSI C, Richard Stallman, Jan 1987 + +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, 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; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! */ + +#include "config.h" + +static void +memory_full () +{ + perror ("Memory exhausted."); +} + +char *xmalloc ( unsigned size) +{ + register char *ptr = (char *) malloc (size); + if (ptr != 0) return (ptr); + memory_full (); + /*NOTREACHED*/ + return 0; +} + +char *xrealloc ( + char *old, + unsigned size ) +{ + register char *ptr = (char *) realloc (old, size); + if (ptr == 0) + memory_full (); + return ptr; +} + +char *xcalloc ( + unsigned number, unsigned size) +{ + register unsigned total = number * size; + register char *ptr = (char *) calloc (number, size); + if (ptr == 0) + memory_full (); + return ptr; +} diff --git a/support/cpp/cpperror.c b/support/cpp/cpperror.c new file mode 100644 index 00000000..13d5ae55 --- /dev/null +++ b/support/cpp/cpperror.c @@ -0,0 +1,132 @@ +/* Default error handlers for CPP Library. + Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + Written by Per Bothner, 1994. + Based on CCCP program by by Paul Rubin, June 1986 + Adapted to ANSI C, Richard Stallman, Jan 1987 + +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, 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; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! */ + +#define EMACS +#define FATAL_EXIT_CODE 33 +#ifndef EMACS +#include "config.h" +#endif /* not EMACS */ + +#include "cpplib.h" +#include +#include + +/* Print the file names and line numbers of the #include + commands which led to the current file. */ + +void +cpp_print_containing_files ( + cpp_reader *pfile) +{ + cpp_buffer *ip; + int first = 1; + + /* If stack of files hasn't changed since we last printed + this info, don't repeat it. */ + if (pfile->input_stack_listing_current) + return; + + ip = cpp_file_buffer (pfile); + + /* Give up if we don't find a source file. */ + if (ip == NULL) + return; + + /* Find the other, outer source files. */ + while ((ip = CPP_PREV_BUFFER (ip)), ip != CPP_NULL_BUFFER (pfile)) + { + long line, col; + cpp_buf_line_and_col (ip, &line, &col); + if (ip->fname != NULL) + { + if (first) + { + first = 0; + fprintf (stderr, "In file included"); + } + else + fprintf (stderr, ",\n "); + } + + fprintf (stderr, " from %s:%d", ip->nominal_fname, line); + } + if (! first) + fprintf (stderr, ":\n"); + + /* Record we have printed the status as of this time. */ + pfile->input_stack_listing_current = 1; +} + +void +cpp_file_line_for_message ( + cpp_reader *pfile, + char *filename , + int line, int column) +{ + if (column > 0) + fprintf (stderr, "%s:%d:%d: ", filename, line, column); + else + fprintf (stderr, "%s:%d: ", filename, line); +} + +/* IS_ERROR is 1 for error, 0 for warning */ +void cpp_message ( + cpp_reader *pfile, + int is_error, + char *msg, + char *arg1, char *arg2, char *arg3) +{ + if (is_error) { + pfile->errors++; + fprintf (stderr,"error:"); + } + else { + fprintf (stderr, "warning: "); + } + fprintf (stderr, msg, arg1, arg2, arg3); + fprintf (stderr, "\n"); +} + +void +fatal (char *str,char *arg) +{ + fprintf (stderr, "%s: ", progname); + fprintf (stderr, str, arg); + fprintf (stderr, "\n"); + exit (FATAL_EXIT_CODE); +} + + +void +cpp_pfatal_with_name ( + cpp_reader *pfile, + char *name) +{ + cpp_perror_with_name (pfile, name); +#ifdef VMS + exit (vaxc$errno); +#else + exit (FATAL_EXIT_CODE); +#endif +} diff --git a/support/cpp/cppexp.c b/support/cpp/cppexp.c new file mode 100644 index 00000000..4d4b1d2b --- /dev/null +++ b/support/cpp/cppexp.c @@ -0,0 +1,998 @@ +/* Parse C expressions for CCCP. + Copyright (C) 1987, 1992, 1994, 1995 Free Software Foundation. + +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, 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; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! + +Written by Per Bothner 1994. */ + +/* Parse a C expression from text in a string */ + +#include "config.h" +#include "cpplib.h" + +extern char *xmalloc PARAMS ((unsigned)); +extern char *xrealloc PARAMS ((char *, unsigned)); + +#ifdef MULTIBYTE_CHARS +#include +#include +#endif + +#include +#include + +/* This is used for communicating lists of keywords with cccp.c. */ +struct arglist { + struct arglist *next; + U_CHAR *name; + int length; + int argno; +}; + +/* Define a generic NULL if one hasn't already been defined. */ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef GENERIC_PTR +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define GENERIC_PTR void * +#else +#define GENERIC_PTR char * +#endif +#endif + +#ifndef NULL_PTR +#define NULL_PTR ((GENERIC_PTR)0) +#endif + +extern char *xmalloc (); + +#ifndef CHAR_TYPE_SIZE +#define CHAR_TYPE_SIZE BITS_PER_UNIT +#endif + +#ifndef INT_TYPE_SIZE +#define INT_TYPE_SIZE BITS_PER_WORD +#endif + +#ifndef LONG_TYPE_SIZE +#define LONG_TYPE_SIZE BITS_PER_WORD +#endif + +#ifndef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE INT_TYPE_SIZE +#endif + +#ifndef MAX_CHAR_TYPE_SIZE +#define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE +#endif + +#ifndef MAX_INT_TYPE_SIZE +#define MAX_INT_TYPE_SIZE INT_TYPE_SIZE +#endif + +#ifndef MAX_LONG_TYPE_SIZE +#define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE +#endif + +#ifndef MAX_WCHAR_TYPE_SIZE +#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE +#endif + +/* Yield nonzero if adding two numbers with A's and B's signs can yield a + number with SUM's sign, where A, B, and SUM are all C integers. */ +#define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0) + +static void integer_overflow (); +static long left_shift (); +static long right_shift (); + +#define ERROR 299 +#define OROR 300 +#define ANDAND 301 +#define EQUAL 302 +#define NOTEQUAL 303 +#define LEQ 304 +#define GEQ 305 +#define LSH 306 +#define RSH 307 +#define NAME 308 +#define INT 309 +#define CHAR 310 + +#define LEFT_OPERAND_REQUIRED 1 +#define RIGHT_OPERAND_REQUIRED 2 +#define HAVE_VALUE 4 +/*#define UNSIGNEDP 8*/ + +#ifndef HOST_BITS_PER_WIDE_INT + +#if HOST_BITS_PER_LONG > HOST_BITS_PER_INT +#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG +#define HOST_WIDE_INT long +#else +#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT +#define HOST_WIDE_INT int +#endif + +#endif + +struct operation { + short op; + char rprio; /* Priority of op (relative to it right operand). */ + char flags; + char unsignedp; /* true if value should be treated as unsigned */ + HOST_WIDE_INT value; /* The value logically "right" of op. */ +}; + +/* Take care of parsing a number (anything that starts with a digit). + LEN is the number of characters in it. */ + +/* maybe needs to actually deal with floating point numbers */ + +struct operation +parse_number ( + cpp_reader *pfile, + char *start, + int olen) +{ + struct operation op; + register char *p = start; + register int c; + register unsigned long n = 0, nd, ULONG_MAX_over_base; + register int base = 10; + register int len = olen; + register int overflow = 0; + register int digit, largest_digit = 0; + int spec_long = 0; + + op.unsignedp = 0; + + for (c = 0; c < len; c++) + if (p[c] == '.') { + /* It's a float since it contains a point. */ + cpp_error (pfile, + "floating point numbers not allowed in #if expressions"); + op.op = ERROR; + return op; + } + + if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) { + p += 2; + base = 16; + len -= 2; + } + else if (*p == '0') + base = 8; + + /* Some buggy compilers (e.g. MPW C) seem to need both casts. */ + ULONG_MAX_over_base = ((unsigned long) -1) / ((unsigned long) base); + + for (; len > 0; len--) { + c = *p++; + + if (c >= '0' && c <= '9') + digit = c - '0'; + else if (base == 16 && c >= 'a' && c <= 'f') + digit = c - 'a' + 10; + else if (base == 16 && c >= 'A' && c <= 'F') + digit = c - 'A' + 10; + else { + /* `l' means long, and `u' means unsigned. */ + while (1) { + if (c == 'l' || c == 'L') + { + if (spec_long) + cpp_error (pfile, "two `l's in integer constant"); + spec_long = 1; + } + else if (c == 'u' || c == 'U') + { + if (op.unsignedp) + cpp_error (pfile, "two `u's in integer constant"); + op.unsignedp = 1; + } + else + break; + + if (--len == 0) + break; + c = *p++; + } + /* Don't look for any more digits after the suffixes. */ + break; + } + if (largest_digit < digit) + largest_digit = digit; + nd = n * base + digit; + overflow |= ULONG_MAX_over_base < n | nd < n; + n = nd; + } + + if (len != 0) + { + cpp_error (pfile, "Invalid number in #if expression"); + op.op = ERROR; + return op; + } + + if (base <= largest_digit) + cpp_warning (pfile, "integer constant contains digits beyond the radix"); + + if (overflow) + cpp_warning (pfile, "integer constant out of range"); + + /* If too big to be signed, consider it unsigned. */ + if ((long) n < 0 && ! op.unsignedp) + { + if (base == 10) + cpp_warning (pfile, "integer constant is so large that it is unsigned"); + op.unsignedp = 1; + } + + op.value = n; + op.op = INT; + return op; +} + +struct token { + char *operator; + int token; +}; + +static struct token tokentab2[] = { + {"&&", ANDAND}, + {"||", OROR}, + {"<<", LSH}, + {">>", RSH}, + {"==", EQUAL}, + {"!=", NOTEQUAL}, + {"<=", LEQ}, + {">=", GEQ}, + {"++", ERROR}, + {"--", ERROR}, + {NULL, ERROR} +}; + +/* Read one token. */ + +struct operation +cpp_lex ( +cpp_reader *pfile) +{ + register int c; + register int namelen; + register struct token *toktab; + enum cpp_token token; + struct operation op; + U_CHAR *tok_start, *tok_end; + int old_written; + + retry: + + old_written = CPP_WRITTEN (pfile); + cpp_skip_hspace (pfile); + c = CPP_BUF_PEEK (CPP_BUFFER (pfile)); + if (c == '#') + return parse_number (pfile, + cpp_read_check_assertion (pfile) ? "1" : "0", 1); + + if (c == '\n') + { + op.op = 0; + return op; + } + + token = cpp_get_token (pfile); + tok_start = pfile->token_buffer + old_written; + tok_end = CPP_PWRITTEN (pfile); + pfile->limit = tok_start; + switch (token) + { + case CPP_EOF: /* Should not happen ... */ + op.op = 0; + return op; + case CPP_VSPACE: + case CPP_POP: + if (CPP_BUFFER (pfile)->fname != NULL) + { + op.op = 0; + return op; + } + goto retry; + case CPP_HSPACE: case CPP_COMMENT: + goto retry; + case CPP_NUMBER: + return parse_number (pfile, tok_start, tok_end - tok_start); + case CPP_STRING: + cpp_error (pfile, "string constants not allowed in #if expressions"); + op.op = ERROR; + return op; + case CPP_CHAR: + /* This code for reading a character constant + handles multicharacter constants and wide characters. + It is mostly copied from c-lex.c. */ + { + register int result = 0; + register num_chars = 0; + unsigned width = MAX_CHAR_TYPE_SIZE; + int wide_flag = 0; + int max_chars; + U_CHAR *ptr = tok_start; +#ifdef MULTIBYTE_CHARS + char token_buffer[MAX_LONG_TYPE_SIZE/MAX_CHAR_TYPE_SIZE + MB_CUR_MAX]; +#else + char token_buffer[MAX_LONG_TYPE_SIZE/MAX_CHAR_TYPE_SIZE + 1]; +#endif + + if (*ptr == 'L') + { + ptr++; + wide_flag = 1; + width = MAX_WCHAR_TYPE_SIZE; +#ifdef MULTIBYTE_CHARS + max_chars = MB_CUR_MAX; +#else + max_chars = 1; +#endif + } + else + max_chars = MAX_LONG_TYPE_SIZE / width; + + ++ptr; + while (ptr < tok_end && ((c = *ptr++) != '\'')) + { + if (c == '\\') + { + c = cpp_parse_escape (pfile, &ptr); + if (width < HOST_BITS_PER_INT + && (unsigned) c >= (1 << width)) + cpp_pedwarn (pfile, + "escape sequence out of range for character"); + } + + num_chars++; + + /* Merge character into result; ignore excess chars. */ + if (num_chars < max_chars + 1) + { + if (width < HOST_BITS_PER_INT) + result = (result << width) | (c & ((1 << width) - 1)); + else + result = c; + token_buffer[num_chars - 1] = c; + } + } + + token_buffer[num_chars] = 0; + + if (c != '\'') + cpp_error (pfile, "malformatted character constant"); + else if (num_chars == 0) + cpp_error (pfile, "empty character constant"); + else if (num_chars > max_chars) + { + num_chars = max_chars; + cpp_error (pfile, "character constant too long"); + } + else if (num_chars != 1 && ! CPP_TRADITIONAL (pfile)) + cpp_warning (pfile, "multi-character character constant"); + + /* If char type is signed, sign-extend the constant. */ + if (! wide_flag) + { + int num_bits = num_chars * width; + + if (cpp_lookup (pfile, "__CHAR_UNSIGNED__", + sizeof ("__CHAR_UNSIGNED__")-1, -1) + || ((result >> (num_bits - 1)) & 1) == 0) + op.value + = result & ((unsigned long) ~0 >> (HOST_BITS_PER_LONG - num_bits)); + else + op.value + = result | ~((unsigned long) ~0 >> (HOST_BITS_PER_LONG - num_bits)); + } + else + { +#ifdef MULTIBYTE_CHARS + /* Set the initial shift state and convert the next sequence. */ + result = 0; + /* In all locales L'\0' is zero and mbtowc will return zero, + so don't use it. */ + if (num_chars > 1 + || (num_chars == 1 && token_buffer[0] != '\0')) + { + wchar_t wc; + (void) mbtowc (NULL_PTR, NULL_PTR, 0); + if (mbtowc (& wc, token_buffer, num_chars) == num_chars) + result = wc; + else + cpp_warning (pfile,"Ignoring invalid multibyte character"); + } +#endif + op.value = result; + } + } + + /* This is always a signed type. */ + op.unsignedp = 0; + op.op = CHAR; + + return op; + + case CPP_NAME: + return parse_number (pfile, "0", 0); + + case CPP_OTHER: + /* See if it is a special token of length 2. */ + if (tok_start + 2 == tok_end) + { + for (toktab = tokentab2; toktab->operator != NULL; toktab++) + if (tok_start[0] == toktab->operator[0] + && tok_start[1] == toktab->operator[1]) + break; + if (toktab->token == ERROR) + { + char *buf = (char *) alloca (40); + sprintf (buf, "`%s' not allowed in operand of `#if'", tok_start); + cpp_error (pfile, buf); + } + op.op = toktab->token; + return op; + } + /* fall through */ + default: + op.op = *tok_start; + return op; + } +} + + +/* Parse a C escape sequence. STRING_PTR points to a variable + containing a pointer to the string to parse. That pointer + is updated past the characters we use. The value of the + escape sequence is returned. + + A negative value means the sequence \ newline was seen, + which is supposed to be equivalent to nothing at all. + + If \ is followed by a null character, we return a negative + value and leave the string pointer pointing at the null character. + + If \ is followed by 000, we return 0 and leave the string pointer + after the zeros. A value of 0 does not mean end of string. */ + +int +cpp_parse_escape ( + cpp_reader *pfile, + char **string_ptr) +{ + register int c = *(*string_ptr)++; + switch (c) + { + case 'a': + return TARGET_BELL; + case 'b': + return TARGET_BS; + case 'e': + case 'E': + if (CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "non-ANSI-standard escape sequence, `\\%c'", c); + return 033; + case 'f': + return TARGET_FF; + case 'n': + return TARGET_NEWLINE; + case 'r': + return TARGET_CR; + case 't': + return TARGET_TAB; + case 'v': + return TARGET_VT; + case '\n': + return -2; + case 0: + (*string_ptr)--; + return 0; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + register int i = c - '0'; + register int count = 0; + while (++count < 3) + { + c = *(*string_ptr)++; + if (c >= '0' && c <= '7') + i = (i << 3) + c - '0'; + else + { + (*string_ptr)--; + break; + } + } + if ((i & ~((1 << MAX_CHAR_TYPE_SIZE) - 1)) != 0) + { + i &= (1 << MAX_CHAR_TYPE_SIZE) - 1; + cpp_warning (pfile, + "octal character constant does not fit in a byte"); + } + return i; + } + case 'x': + { + register unsigned i = 0, overflow = 0, digits_found = 0, digit; + for (;;) + { + c = *(*string_ptr)++; + if (c >= '0' && c <= '9') + digit = c - '0'; + else if (c >= 'a' && c <= 'f') + digit = c - 'a' + 10; + else if (c >= 'A' && c <= 'F') + digit = c - 'A' + 10; + else + { + (*string_ptr)--; + break; + } + overflow |= i ^ (i << 4 >> 4); + i = (i << 4) + digit; + digits_found = 1; + } + if (!digits_found) + cpp_error (pfile, "\\x used with no following hex digits"); + if (overflow | (i & ~((1 << BITS_PER_UNIT) - 1))) + { + i &= (1 << BITS_PER_UNIT) - 1; + cpp_warning (pfile, + "hex character constant does not fit in a byte"); + } + return i; + } + default: + return c; + } +} + +static void +integer_overflow ( + cpp_reader *pfile) +{ + if (CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "integer overflow in preprocessor expression"); +} + +static long +left_shift ( + cpp_reader *pfile, + long a, + int unsignedp, + unsigned long b) +{ + if (b >= HOST_BITS_PER_LONG) + { + if (! unsignedp && a != 0) + integer_overflow (pfile); + return 0; + } + else if (unsignedp) + return (unsigned long) a << b; + else + { + long l = a << b; + if (l >> b != a) + integer_overflow (pfile); + return l; + } +} + +static long +right_shift ( + cpp_reader *pfile, + long a, + int unsignedp, + unsigned long b) +{ + if (b >= HOST_BITS_PER_LONG) + return unsignedp ? 0 : a >> (HOST_BITS_PER_LONG - 1); + else if (unsignedp) + return (unsigned long) a >> b; + else + return a >> b; +} + +/* These priorities are all even, so we can handle associatively. */ +#define PAREN_INNER_PRIO 0 +#define COMMA_PRIO 4 +#define COND_PRIO (COMMA_PRIO+2) +#define OROR_PRIO (COND_PRIO+2) +#define ANDAND_PRIO (OROR_PRIO+2) +#define OR_PRIO (ANDAND_PRIO+2) +#define XOR_PRIO (OR_PRIO+2) +#define AND_PRIO (XOR_PRIO+2) +#define EQUAL_PRIO (AND_PRIO+2) +#define LESS_PRIO (EQUAL_PRIO+2) +#define SHIFT_PRIO (LESS_PRIO+2) +#define PLUS_PRIO (SHIFT_PRIO+2) +#define MUL_PRIO (PLUS_PRIO+2) +#define UNARY_PRIO (MUL_PRIO+2) +#define PAREN_OUTER_PRIO (UNARY_PRIO+2) + +#define COMPARE(OP) \ + top->unsignedp = 0;\ + top->value = (unsigned1 || unsigned2) ? (unsigned long) v1 OP v2 : (v1 OP v2) + +/* Parse and evaluate a C expression, reading from PFILE. + Returns the value of the expression. */ + +HOST_WIDE_INT +cpp_parse_expr ( + cpp_reader *pfile) +{ + /* The implementation is an operator precedence parser, + i.e. a bottom-up parser, using a stack for not-yet-reduced tokens. + + The stack base is 'stack', and the current stack pointer is 'top'. + There is a stack element for each operator (only), + and the most recently pushed operator is 'top->op'. + An operand (value) is stored in the 'value' field of the stack + element of the operator that precedes it. + In that case the 'flags' field has the HAVE_VALUE flag set. */ + +#define INIT_STACK_SIZE 20 + struct operation init_stack[INIT_STACK_SIZE]; + struct operation *stack = init_stack; + struct operation *limit = stack + INIT_STACK_SIZE; + register struct operation *top = stack; + int lprio, rprio; + + top->rprio = 0; + top->flags = 0; + for (;;) + { + struct operation op; + char flags = 0; + + /* Read a token */ + op = cpp_lex (pfile); + + /* See if the token is an operand, in which case go to set_value. + If the token is an operator, figure out its left and right + priorities, and then goto maybe_reduce. */ + + switch (op.op) + { + case NAME: + top->value = 0, top->unsignedp = 0; + goto set_value; + case INT: case CHAR: + top->value = op.value; + top->unsignedp = op.unsignedp; + goto set_value; + case 0: + lprio = 0; goto maybe_reduce; + case '+': case '-': + /* Is this correct if unary ? FIXME */ + flags = RIGHT_OPERAND_REQUIRED; + lprio = PLUS_PRIO; rprio = lprio + 1; goto maybe_reduce; + case '!': case '~': + flags = RIGHT_OPERAND_REQUIRED; + rprio = UNARY_PRIO; lprio = rprio + 1; goto maybe_reduce; + case '*': case '/': case '%': + lprio = MUL_PRIO; goto binop; + case '<': case '>': case LEQ: case GEQ: + lprio = LESS_PRIO; goto binop; + case EQUAL: case NOTEQUAL: + lprio = EQUAL_PRIO; goto binop; + case LSH: case RSH: + lprio = SHIFT_PRIO; goto binop; + case '&': lprio = AND_PRIO; goto binop; + case '^': lprio = XOR_PRIO; goto binop; + case '|': lprio = OR_PRIO; goto binop; + case ANDAND: lprio = ANDAND_PRIO; goto binop; + case OROR: lprio = OROR_PRIO; goto binop; + case ',': + lprio = COMMA_PRIO; goto binop; + case '(': + lprio = PAREN_OUTER_PRIO; rprio = PAREN_INNER_PRIO; + goto maybe_reduce; + case ')': + lprio = PAREN_INNER_PRIO; rprio = PAREN_OUTER_PRIO; + goto maybe_reduce; + case ':': + lprio = COND_PRIO; rprio = COND_PRIO; + goto maybe_reduce; + case '?': + lprio = COND_PRIO + 1; rprio = COND_PRIO; + goto maybe_reduce; + binop: + flags = LEFT_OPERAND_REQUIRED|RIGHT_OPERAND_REQUIRED; + rprio = lprio + 1; + goto maybe_reduce; + default: + cpp_error (pfile, "invalid character in #if"); + goto syntax_error; + } + + set_value: + /* Push a value onto the stack. */ + if (top->flags & HAVE_VALUE) + { + cpp_error (pfile, "syntax error in #if"); + goto syntax_error; + } + top->flags |= HAVE_VALUE; + continue; + + maybe_reduce: + /* Push an operator, and check if we can reduce now. */ + while (top->rprio > lprio) + { + long v1 = top[-1].value, v2 = top[0].value; + int unsigned1 = top[-1].unsignedp, unsigned2 = top[0].unsignedp; + top--; + if ((top[1].flags & LEFT_OPERAND_REQUIRED) + && ! (top[0].flags & HAVE_VALUE)) + { + cpp_error (pfile, "syntax error - missing left operand"); + goto syntax_error; + } + if ((top[1].flags & RIGHT_OPERAND_REQUIRED) + && ! (top[1].flags & HAVE_VALUE)) + { + cpp_error (pfile, "syntax error - missing right operand"); + goto syntax_error; + } + /* top[0].value = (top[1].op)(v1, v2);*/ + switch (top[1].op) + { + case '+': + if (!(top->flags & HAVE_VALUE)) + { /* Unary '+' */ + top->value = v2; + top->unsignedp = unsigned2; + top->flags |= HAVE_VALUE; + } + else + { + top->value = v1 + v2; + top->unsignedp = unsigned1 || unsigned2; + if (! top->unsignedp + && ! possible_sum_sign (v1, v2, top->value)) + integer_overflow (pfile); + } + break; + case '-': + if (!(top->flags & HAVE_VALUE)) + { /* Unary '-' */ + top->value = - v2; + if ((top->value & v2) < 0 && ! unsigned2) + integer_overflow (pfile); + top->unsignedp = unsigned2; + top->flags |= HAVE_VALUE; + } + else + { /* Binary '-' */ + top->value = v1 - v2; + top->unsignedp = unsigned1 || unsigned2; + if (! top->unsignedp + && ! possible_sum_sign (top->value, v2, v1)) + integer_overflow (pfile); + } + break; + case '*': + top->unsignedp = unsigned1 || unsigned2; + if (top->unsignedp) + top->value = (unsigned long) v1 * v2; + else + { + top->value = v1 * v2; + if (v1 + && (top->value / v1 != v2 + || (top->value & v1 & v2) < 0)) + integer_overflow (pfile); + } + break; + case '/': + if (v2 == 0) + { + cpp_error (pfile, "division by zero in #if"); + v2 = 1; + } + top->unsignedp = unsigned1 || unsigned2; + if (top->unsignedp) + top->value = (unsigned long) v1 / v2; + else + { + top->value = v1 / v2; + if ((top->value & v1 & v2) < 0) + integer_overflow (pfile); + } + break; + case '%': + if (v2 == 0) + { + cpp_error (pfile, "division by zero in #if"); + v2 = 1; + } + top->unsignedp = unsigned1 || unsigned2; + if (top->unsignedp) + top->value = (unsigned long) v1 % v2; + else + top->value = v1 % v2; + break; + case '!': + if (top->flags & HAVE_VALUE) + { + cpp_error (pfile, "syntax error"); + goto syntax_error; + } + top->value = ! v2; + top->unsignedp = 0; + top->flags |= HAVE_VALUE; + break; + case '~': + if (top->flags & HAVE_VALUE) + { + cpp_error (pfile, "syntax error"); + goto syntax_error; + } + top->value = ~ v2; + top->unsignedp = unsigned2; + top->flags |= HAVE_VALUE; + break; + case '<': COMPARE(<); break; + case '>': COMPARE(>); break; + case LEQ: COMPARE(<=); break; + case GEQ: COMPARE(>=); break; + case EQUAL: + top->value = (v1 == v2); + top->unsignedp = 0; + break; + case NOTEQUAL: + top->value = (v1 != v2); + top->unsignedp = 0; + break; + case LSH: + top->unsignedp = unsigned1; + if (v2 < 0 && ! unsigned2) + top->value = right_shift (pfile, v1, unsigned1, -v2); + else + top->value = left_shift (pfile, v1, unsigned1, v2); + break; + case RSH: + top->unsignedp = unsigned1; + if (v2 < 0 && ! unsigned2) + top->value = left_shift (pfile, v1, unsigned1, -v2); + else + top->value = right_shift (pfile, v1, unsigned1, v2); + break; +#define LOGICAL(OP) \ + top->value = v1 OP v2;\ + top->unsignedp = unsigned1 || unsigned2; + case '&': LOGICAL(&); break; + case '^': LOGICAL(^); break; + case '|': LOGICAL(|); break; + case ANDAND: + top->value = v1 && v2; top->unsignedp = 0; break; + case OROR: + top->value = v1 || v2; top->unsignedp = 0; break; + case ',': + if (CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "comma operator in operand of `#if'"); + top->value = v2; + top->unsignedp = unsigned2; + break; + case '(': case '?': + cpp_error (pfile, "syntax error in #if"); + goto syntax_error; + case ':': + if (top[0].op != '?') + { + cpp_error (pfile, + "syntax error ':' without preceding '?'"); + goto syntax_error; + } + else if (! (top[1].flags & HAVE_VALUE) + || !(top[-1].flags & HAVE_VALUE) + || !(top[0].flags & HAVE_VALUE)) + { + cpp_error (pfile, "bad syntax for ?: operator"); + goto syntax_error; + } + else + { + top--; + top->value = top->value ? v1 : v2; + top->unsignedp = unsigned1 || unsigned2; + } + break; + case ')': + if ((top[1].flags & HAVE_VALUE) + || ! (top[0].flags & HAVE_VALUE) + || top[0].op != '(' + || (top[-1].flags & HAVE_VALUE)) + { + cpp_error (pfile, "mismatched parentheses in #if"); + goto syntax_error; + } + else + { + top--; + top->value = v1; + top->unsignedp = unsigned1; + top->flags |= HAVE_VALUE; + } + break; + default: + fprintf (stderr, + top[1].op >= ' ' && top[1].op <= '~' + ? "unimplemented operator '%c'\n" + : "unimplemented operator '\\%03o'\n", + top[1].op); + } + } + if (op.op == 0) + { + if (top != stack) + cpp_error (pfile, "internal error in #if expression"); + if (stack != init_stack) + free (stack); + return top->value; + } + top++; + + /* Check for and handle stack overflow. */ + if (top == limit) + { + struct operation *new_stack; + int old_size = (char*)limit - (char*)stack; + int new_size = 2 * old_size; + if (stack != init_stack) + new_stack = (struct operation*) xrealloc (stack, new_size); + else + { + new_stack = (struct operation*) xmalloc (new_size); + bcopy ((char *) stack, (char *) new_stack, old_size); + } + stack = new_stack; + top = (struct operation*)((char*) new_stack + old_size); + limit = (struct operation*)((char*) new_stack + new_size); + } + + top->flags = flags; + top->rprio = rprio; + top->op = op.op; + } + syntax_error: + if (stack != init_stack) + free (stack); + skip_rest_of_line (pfile); + return 0; +} diff --git a/support/cpp/cpphash.c b/support/cpp/cpphash.c new file mode 100644 index 00000000..e9645aa6 --- /dev/null +++ b/support/cpp/cpphash.c @@ -0,0 +1,213 @@ +/* Part of CPP library. (Macro hash table support.) + Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + Written by Per Bothner, 1994. + Based on CCCP program by by Paul Rubin, June 1986 + Adapted to ANSI C, Richard Stallman, Jan 1987 + +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, 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; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! */ + +#include "cpplib.h" +#include "cpphash.h" +extern char *xmalloc PARAMS ((unsigned)); + +/* Define a generic NULL if one hasn't already been defined. */ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef __STDC__ +#define const +#define volatile +#endif + +/* + * return hash function on name. must be compatible with the one + * computed a step at a time, elsewhere + */ +int +hashf ( + register const U_CHAR *name, + register int len, + int hashsize) +{ + register int r = 0; + + while (len--) + r = HASHSTEP (r, *name++); + + return MAKE_POS (r) % hashsize; +} + +/* + * find the most recent hash node for name name (ending with first + * non-identifier char) installed by install + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ +HASHNODE * +cpp_lookup ( + struct parse_file *pfile, + const U_CHAR *name, + int len, + int hash) +{ + register const U_CHAR *bp; + register HASHNODE *bucket; + + if (len < 0) + { + for (bp = name; is_idchar[*bp]; bp++) ; + len = bp - name; + } + + if (hash < 0) + hash = hashf (name, len, HASHSIZE); + + bucket = hashtab[hash]; + while (bucket) { + if (bucket->length == len && strncmp (bucket->name, name, len) == 0) + return bucket; + bucket = bucket->next; + } + return (HASHNODE*) 0; +} + +/* + * Delete a hash node. Some weirdness to free junk from macros. + * More such weirdness will have to be added if you define more hash + * types that need it. + */ + +/* Note that the DEFINITION of a macro is removed from the hash table + but its storage is not freed. This would be a storage leak + except that it is not reasonable to keep undefining and redefining + large numbers of macros many times. + In any case, this is necessary, because a macro can be #undef'd + in the middle of reading the arguments to a call to it. + If #undef freed the DEFINITION, that would crash. */ + +void +delete_macro ( + HASHNODE *hp) +{ + + if (hp->prev != NULL) + hp->prev->next = hp->next; + if (hp->next != NULL) + hp->next->prev = hp->prev; + + /* make sure that the bucket chain header that + the deleted guy was on points to the right thing afterwards. */ + if (hp == *hp->bucket_hdr) + *hp->bucket_hdr = hp->next; + + if (hp->type == T_MACRO) + { + DEFINITION *d = hp->value.defn; + struct reflist *ap, *nextap; + + for (ap = d->pattern; ap != NULL; ap = nextap) + { + nextap = ap->next; + free (ap); + } + if (d->nargs >= 0) + free (d->args.argnames); + free (d); + } + + free (hp); +} +/* + * install a name in the main hash table, even if it is already there. + * name stops with first non alphanumeric, except leading '#'. + * caller must check against redefinition if that is desired. + * delete_macro () removes things installed by install () in fifo order. + * this is important because of the `defined' special symbol used + * in #if, and also if pushdef/popdef directives are ever implemented. + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ +HASHNODE * +install ( + U_CHAR *name, + int len, + enum node_type type, + int ivalue, + char *value, + int hash) +{ + register HASHNODE *hp; + register int i, bucket; + register U_CHAR *p, *q; + + if (len < 0) { + p = name; + while (is_idchar[*p]) + p++; + len = p - name; + } + + if (hash < 0) + hash = hashf (name, len, HASHSIZE); + + i = sizeof (HASHNODE) + len + 1; + hp = (HASHNODE *) xmalloc (i); + bucket = hash; + hp->bucket_hdr = &hashtab[bucket]; + hp->next = hashtab[bucket]; + hashtab[bucket] = hp; + hp->prev = NULL; + if (hp->next != NULL) + hp->next->prev = hp; + hp->type = type; + hp->length = len; + if (hp->type == T_CONST) + hp->value.ival = ivalue; + else + hp->value.cpval = value; + hp->name = ((U_CHAR *) hp) + sizeof (HASHNODE); + p = hp->name; + q = name; + for (i = 0; i < len; i++) + *p++ = *q++; + hp->name[len] = 0; + return hp; +} + +void +cpp_hash_cleanup ( + cpp_reader *pfile) +{ + register int i; + for (i = HASHSIZE; --i >= 0; ) + { + while (hashtab[i]) + delete_macro (hashtab[i]); + } +} diff --git a/support/cpp/cpphash.h b/support/cpp/cpphash.h new file mode 100644 index 00000000..914a12f5 --- /dev/null +++ b/support/cpp/cpphash.h @@ -0,0 +1,38 @@ +/* different kinds of things that can appear in the value field + of a hash node. Actually, this may be useless now. */ +union hashval { + int ival; + char *cpval; + DEFINITION *defn; +#if 0 + KEYDEF *keydef; +#endif +}; + +struct hashnode { + struct hashnode *next; /* double links for easy deletion */ + struct hashnode *prev; + struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash + chain is kept, in case the node is the head + of the chain and gets deleted. */ + enum node_type type; /* type of special token */ + int length; /* length of token, for quick comparison */ + U_CHAR *name; /* the actual name */ + union hashval value; /* pointer to expansion, or whatever */ +}; + +typedef struct hashnode HASHNODE; + +/* Some definitions for the hash table. The hash function MUST be + computed as shown in hashf () below. That is because the rescan + loop computes the hash value `on the fly' for most tokens, + in order to avoid the overhead of a lot of procedure calls to + the hashf () function. Hashf () only exists for the sake of + politeness, for use when speed isn't so important. */ + +#define HASHSIZE 1403 +static HASHNODE *hashtab[HASHSIZE]; +#define HASHSTEP(old, c) ((old << 2) + c) +#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */ + +extern HASHNODE* install PARAMS ((U_CHAR*,int,enum node_type, int,char*,int)); diff --git a/support/cpp/cpplib.c b/support/cpp/cpplib.c new file mode 100644 index 00000000..a7f2c8ac --- /dev/null +++ b/support/cpp/cpplib.c @@ -0,0 +1,7542 @@ +/* CPP Library. + Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + Written by Per Bothner, 1994-95. + Based on CCCP program by by Paul Rubin, June 1986 + Adapted to ANSI C, Richard Stallman, Jan 1987 + +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, 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; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! */ + +#include "sdccconf.h" + +#ifdef EMACS +#define NO_SHORTNAMES +#include "../src/config.h" +#ifdef open +#undef open +#undef read +#undef write +#endif /* open */ +#endif /* EMACS */ + + +/* The macro EMACS is defined when cpp is distributed as part of Emacs, + for the sake of machines with limited C compilers. */ +#ifndef EMACS +#include "config.h" +#include +#include +#endif /* not EMACS */ +#define GCC_INCLUDE_DIR "/usr/local/lib/gcc-lib/i386-unknown-freebsd_1.0/2.5.8/include" +#ifndef STANDARD_INCLUDE_DIR +#define STANDARD_INCLUDE_DIR "/usr/include" +#endif + +#ifndef LOCAL_INCLUDE_DIR +#define LOCAL_INCLUDE_DIR "/usr/local/include" +#endif + +#if 0 /* We can't get ptrdiff_t, so I arranged not to need PTR_INT_TYPE. */ +#ifdef __STDC__ +#define PTR_INT_TYPE ptrdiff_t +#else +#define PTR_INT_TYPE long +#endif +#endif /* 0 */ + +#include "cpplib.h" +#include "cpphash.h" + +#ifndef STDC_VALUE +#define STDC_VALUE 1 +#endif + +/* By default, colon separates directories in a path. */ +#ifndef PATH_SEPARATOR +#define PATH_SEPARATOR ':' +#endif + +#include +#include +#include +#ifdef __STDC__ +#include +#endif + +#ifndef VMS +#ifndef USG +#include /* for __DATE__ and __TIME__ */ +#include +#else +/*#include CYGNUS LOCAL: shebs -noquiet */ +// #include +#include +#include +#endif /* USG */ +#endif /* not VMS */ + +/* This defines "errno" properly for VMS, and gives us EACCES. */ +#include + +extern char *index (); +extern char *rindex (); + +#ifndef O_RDONLY +#define O_RDONLY 0 +#endif + +#undef MIN +#undef MAX +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) + +/* Find the largest host integer type and set its size and type. */ + +#ifndef HOST_BITS_PER_WIDE_INT + +#if HOST_BITS_PER_LONG > HOST_BITS_PER_INT +#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG +#define HOST_WIDE_INT long +#else +#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT +#define HOST_WIDE_INT int +#endif + +#endif + +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* Define a generic NULL if one hasn't already been defined. */ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef GENERIC_PTR +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define GENERIC_PTR void * +#else +#define GENERIC_PTR char * +#endif +#endif + +#ifndef NULL_PTR +#define NULL_PTR ((GENERIC_PTR)0) +#endif + +#ifndef INCLUDE_LEN_FUDGE +#define INCLUDE_LEN_FUDGE 0 +#endif + +/* Symbols to predefine. */ + +#ifdef CPP_PREDEFINES +static char *predefs = CPP_PREDEFINES; +#else +static char *predefs = ""; +#endif + +/* We let tm.h override the types used here, to handle trivial differences + such as the choice of unsigned int or long unsigned int for size_t. + When machines start needing nontrivial differences in the size type, + it would be best to do something here to figure out automatically + from other information what type to use. */ + +/* The string value for __SIZE_TYPE__. */ + +#ifndef SIZE_TYPE +#define SIZE_TYPE "long unsigned int" +#endif + +/* The string value for __PTRDIFF_TYPE__. */ + +#ifndef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" +#endif + +/* The string value for __WCHAR_TYPE__. */ + +#ifndef WCHAR_TYPE +#define WCHAR_TYPE "int" +#endif +#define CPP_WCHAR_TYPE(PFILE) \ + (CPP_OPTIONS (PFILE)->cplusplus ? "__wchar_t" : WCHAR_TYPE) + +/* The string value for __USER_LABEL_PREFIX__ */ + +#ifndef USER_LABEL_PREFIX +#define USER_LABEL_PREFIX "" +#endif + +/* The string value for __REGISTER_PREFIX__ */ + +#ifndef REGISTER_PREFIX +#define REGISTER_PREFIX "" +#endif + + +/* In the definition of a #assert name, this structure forms + a list of the individual values asserted. + Each value is itself a list of "tokens". + These are strings that are compared by name. */ + +struct tokenlist_list { + struct tokenlist_list *next; + struct arglist *tokens; +}; + +struct assertion_hashnode { + struct assertion_hashnode *next; /* double links for easy deletion */ + struct assertion_hashnode *prev; + /* also, a back pointer to this node's hash + chain is kept, in case the node is the head + of the chain and gets deleted. */ + struct assertion_hashnode **bucket_hdr; + int length; /* length of token, for quick comparison */ + U_CHAR *name; /* the actual name */ + /* List of token-sequences. */ + struct tokenlist_list *value; +}; + +#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0) +#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0) + +#define PEEKN(N) (CPP_BUFFER (pfile)->rlimit - CPP_BUFFER (pfile)->cur >= (N) ? CPP_BUFFER (pfile)->cur[N] : EOF) +#define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N)) +#define GETC() CPP_BUF_GET (CPP_BUFFER (pfile)) +#define PEEKC() CPP_BUF_PEEK (CPP_BUFFER (pfile)) +/* CPP_IS_MACRO_BUFFER is true if the buffer contains macro expansion. + (Note that it is false while we're expanding marco *arguments*.) */ +#define CPP_IS_MACRO_BUFFER(PBUF) ((PBUF)->cleanup == macro_cleanup) + +/* Move all backslash-newline pairs out of embarrassing places. + Exchange all such pairs following BP + with any potentially-embarrassing characters that follow them. + Potentially-embarrassing characters are / and * + (because a backslash-newline inside a comment delimiter + would cause it not to be recognized). */ + +#define NEWLINE_FIX \ + do {while (PEEKC() == '\\' && PEEKN(1) == '\n') FORWARD(2); } while(0) + +/* Same, but assume we've already read the potential '\\' into C. */ +#define NEWLINE_FIX1(C) do { \ + while ((C) == '\\' && PEEKC() == '\n') { FORWARD(1); (C) = GETC(); }\ + } while(0) + +struct cpp_pending { + struct cpp_pending *next; + char *cmd; + char *arg; +}; + +/* Forward declarations. */ + +extern char *xmalloc (); + +static void add_import (); +static void append_include_chain (); +static void make_undef (); +static void make_assertion (); +static void path_include (); +static void initialize_builtins (); +static void initialize_char_syntax (); +static void dump_arg_n (); +static void dump_defn_1 (); +extern void delete_macro (); +static void trigraph_pcp (); +static int finclude (); +static void validate_else (); +static int comp_def_part (); +extern void fancy_abort (); +static void pipe_closed (); +static void print_containing_files (); +static int lookup_import (); +static int redundant_include_p (); +static is_system_include (); +static struct file_name_map *read_name_map (); +static char *read_filename_string (); +static int open_include_file (); +static int check_preconditions (); +static void pcfinclude (); +static void pcstring_used (); +static int check_macro_name (); +static int compare_defs (); +static int compare_token_lists (); +static HOST_WIDE_INT eval_if_expression (); +static int change_newlines (); +extern int hashf (); +static int file_size_and_mode (); +static struct arglist *read_token_list (); +static void free_token_list (); +static int safe_read (); +static void push_macro_expansion PARAMS ((cpp_reader *, + U_CHAR*, int, HASHNODE*)); +static struct cpp_pending *nreverse_pending PARAMS ((struct cpp_pending*)); +extern char *xrealloc (); +extern char *xcalloc (); +static char *savestring (); + +static void conditional_skip (); +static void skip_if_group (); + +/* Last arg to output_line_command. */ +enum file_change_code {same_file, enter_file, leave_file}; + +/* External declarations. */ + +extern HOST_WIDE_INT cpp_parse_expr PARAMS ((cpp_reader*)); + +extern char *getenv (); +extern FILE *fdopen (); +extern char *version_string; +extern struct tm *localtime (); + +/* These functions are declared to return int instead of void since they + are going to be placed in a table and some old compilers have trouble with + pointers to functions returning void. */ + +static int do_define (); +static int do_line (); +static int do_include (); +static int do_undef (); +static int do_error (); +static int do_pragma (); +static int do_ident (); +static int do_if (); +static int do_xifdef (); +static int do_else (); +static int do_elif (); +static int do_endif (); +static int do_sccs (); +static int do_once (); +static int do_assert (); +static int do_unassert (); +static int do_warning (); + +struct file_name_list + { + struct file_name_list *next; + char *fname; + /* If the following is nonzero, it is a macro name. + Don't include the file again if that macro is defined. */ + U_CHAR *control_macro; + /* If the following is nonzero, it is a C-language system include + directory. */ + int c_system_include_path; + /* Mapping of file names for this directory. */ + struct file_name_map *name_map; + /* Non-zero if name_map is valid. */ + int got_name_map; + }; + +/* If a buffer's dir field is SELF_DIR_DUMMY, it means the file was found + via the same directory as the file that #included it. */ +#define SELF_DIR_DUMMY ((struct file_name_list*)(~0)) + +/* #include "file" looks in source file dir, then stack. */ +/* #include just looks in the stack. */ +/* -I directories are added to the end, then the defaults are added. */ +/* The */ +static struct default_include { + char *fname; /* The name of the directory. */ + int cplusplus; /* Only look here if we're compiling C++. */ + int cxx_aware; /* Includes in this directory don't need to + be wrapped in extern "C" when compiling + C++. */ +} include_defaults_array[] +#ifdef INCLUDE_DEFAULTS + = INCLUDE_DEFAULTS; +#else + = { + /* Pick up GNU C++ specific include files. */ + { GPLUSPLUS_INCLUDE_DIR, 1, 1 }, +#ifdef CROSS_COMPILE + /* This is the dir for fixincludes. Put it just before + the files that we fix. */ + { GCC_INCLUDE_DIR, 0, 0 }, + /* For cross-compilation, this dir name is generated + automatically in Makefile.in. */ + { CROSS_INCLUDE_DIR, 0, 0 }, + /* This is another place that the target system's headers might be. */ + { TOOL_INCLUDE_DIR, 0, 1 }, + { LOCAL_INCLUDE_DIR, 0, 1 }, +#else /* not CROSS_COMPILE */ + /* This should be /usr/local/include and should come before + the fixincludes-fixed header files. */ + { LOCAL_INCLUDE_DIR, 0, 1 }, + /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here. + Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */ + { TOOL_INCLUDE_DIR, 0, 1 }, + /* This is the dir for fixincludes. Put it just before + the files that we fix. */ + { GCC_INCLUDE_DIR, 0, 0 }, + /* Some systems have an extra dir of include files. */ +#ifdef SYSTEM_INCLUDE_DIR + { SYSTEM_INCLUDE_DIR, 0, 0 }, +#endif + { STANDARD_INCLUDE_DIR, 0, 0 }, +#endif /* not CROSS_COMPILE */ + { 0, 0, 0 } + }; +#endif /* no INCLUDE_DEFAULTS */ + +/* `struct directive' defines one #-directive, including how to handle it. */ + +struct directive { + int length; /* Length of name */ + int (*func)(); /* Function to handle directive */ + char *name; /* Name of directive */ + enum node_type type; /* Code which describes which directive. */ + char command_reads_line; /* One if rest of line is read by func. */ + char traditional_comments; /* Nonzero: keep comments if -traditional. */ + char pass_thru; /* Copy preprocessed directive to output file.*/ +}; + +/* Here is the actual list of #-directives, most-often-used first. + The initialize_builtins function assumes #define is the very first. */ + +static struct directive directive_table[] = { + { 6, do_define, "define", T_DEFINE, 0, 1}, + { 5, do_xifdef, "ifdef", T_IFDEF, 1}, + { 6, do_xifdef, "ifndef", T_IFNDEF, 1}, + { 7, do_include, "include", T_INCLUDE, 1}, + { 12, do_include, "include_next", T_INCLUDE_NEXT, 1}, + { 6, do_include, "import", T_IMPORT, 1}, + { 5, do_endif, "endif", T_ENDIF, 1}, + { 4, do_else, "else", T_ELSE, 1}, + { 2, do_if, "if", T_IF, 1}, + { 4, do_elif, "elif", T_ELIF, 1}, + { 5, do_undef, "undef", T_UNDEF}, + { 5, do_error, "error", T_ERROR}, + { 7, do_warning, "warning", T_WARNING}, + { 6, do_pragma, "pragma", T_PRAGMA, 0, 0, 1}, + { 4, do_line, "line", T_LINE, 1}, + { 5, do_ident, "ident", T_IDENT, 1, 0, 1}, +#ifdef SCCS_DIRECTIVE + { 4, do_sccs, "sccs", T_SCCS}, +#endif + { 6, do_assert, "assert", T_ASSERT, 1}, + { 8, do_unassert, "unassert", T_UNASSERT, 1}, + { -1, 0, "", T_UNUSED}, +}; + +/* table to tell if char can be part of a C identifier. */ +U_CHAR is_idchar[256]; +/* table to tell if char can be first char of a c identifier. */ +U_CHAR is_idstart[256]; +/* table to tell if c is horizontal space. */ +U_CHAR is_hor_space[256]; +/* table to tell if c is horizontal or vertical space. */ +static U_CHAR is_space[256]; + +/* Initialize syntactic classifications of characters. */ + +static void +initialize_char_syntax ( + struct cpp_options *opts) +{ + register int i; + + /* + * Set up is_idchar and is_idstart tables. These should be + * faster than saying (is_alpha (c) || c == '_'), etc. + * Set up these things before calling any routines tthat + * refer to them. + */ + for (i = 'a'; i <= 'z'; i++) { + is_idchar[i - 'a' + 'A'] = 1; + is_idchar[i] = 1; + is_idstart[i - 'a' + 'A'] = 1; + is_idstart[i] = 1; + } + for (i = '0'; i <= '9'; i++) + is_idchar[i] = 1; + is_idchar['_'] = 1; + is_idstart['_'] = 1; + is_idchar['$'] = opts->dollars_in_ident; + is_idstart['$'] = opts->dollars_in_ident; + + /* horizontal space table */ + is_hor_space[' '] = 1; + is_hor_space['\t'] = 1; + is_hor_space['\v'] = 1; + is_hor_space['\f'] = 1; + is_hor_space['\r'] = 1; + + is_space[' '] = 1; + is_space['\t'] = 1; + is_space['\v'] = 1; + is_space['\f'] = 1; + is_space['\n'] = 1; + is_space['\r'] = 1; +} + + +/* Place into PFILE a quoted string representing the string SRC. + Caller must reserve enough space in pfile->token_buffer. */ +static void +quote_string ( + cpp_reader *pfile, + char *src) +{ + U_CHAR c; + + CPP_PUTC_Q (pfile, '\"'); + for (;;) + switch ((c = *src++)) + { + default: + if (isprint (c)) + CPP_PUTC_Q (pfile, c); + else + { + sprintf (CPP_PWRITTEN (pfile), "\\%03o", c); + CPP_ADJUST_WRITTEN (pfile, 4); + } + break; + + case '\"': + case '\\': + CPP_PUTC_Q (pfile, '\\'); + CPP_PUTC_Q (pfile, c); + break; + + case '\0': + CPP_PUTC_Q (pfile, '\"'); + CPP_NUL_TERMINATE_Q (pfile); + return; + } +} + +/* Make sure PFILE->token_buffer will hold at least N more chars. */ + +void +cpp_grow_buffer ( + cpp_reader *pfile, + long n) +{ + long old_written = CPP_WRITTEN (pfile); + pfile->token_buffer_size = n + 2 * pfile->token_buffer_size; + pfile->token_buffer = (U_CHAR*) + xrealloc(pfile->token_buffer, pfile->token_buffer_size); + CPP_SET_WRITTEN (pfile, old_written); +} + + +/* + * process a given definition string, for initialization + * If STR is just an identifier, define it with value 1. + * If STR has anything after the identifier, then it should + * be identifier=definition. + */ + +void +cpp_define ( + cpp_reader *pfile, + U_CHAR *str) +{ + U_CHAR *buf, *p; + + buf = str; + p = str; + if (!is_idstart[*p]) + { + cpp_error (pfile, "malformed option `-D %s'", str); + return; + } + while (is_idchar[*++p]) + ; + if (*p == 0) + { + buf = (U_CHAR *) alloca (p - buf + 4); + strcpy ((char *)buf, str); + strcat ((char *)buf, " 1"); + } + else if (*p != '=') + { + cpp_error (pfile, "malformed option `-D %s'", str); + return; + } + else + { + U_CHAR *q; + /* Copy the entire option so we can modify it. */ + buf = (U_CHAR *) alloca (2 * strlen (str) + 1); + strncpy (buf, str, p - str); + /* Change the = to a space. */ + buf[p - str] = ' '; + /* Scan for any backslash-newline and remove it. */ + p++; + q = &buf[p - str]; + while (*p) + { + if (*p == '\\' && p[1] == '\n') + p += 2; + else + *q++ = *p++; + } + *q = 0; + } + + do_define (pfile, NULL, buf, buf + strlen (buf)); +} + +/* Process the string STR as if it appeared as the body of a #assert. + OPTION is the option name for which STR was the argument. */ + +static void +make_assertion ( + cpp_reader *pfile, + char *option, + U_CHAR *str) +{ + cpp_buffer *ip; + struct directive *kt; + U_CHAR *buf, *p, *q; + + /* Copy the entire option so we can modify it. */ + buf = (U_CHAR *) alloca (strlen (str) + 1); + strcpy ((char *) buf, str); + /* Scan for any backslash-newline and remove it. */ + p = q = buf; + while (*p) { +#if 0 + if (*p == '\\' && p[1] == '\n') + p += 2; + else +#endif + *q++ = *p++; + } + *q = 0; + + p = buf; + if (!is_idstart[*p]) { + cpp_error (pfile, "malformed option `%s %s'", option, str); + return; + } + while (is_idchar[*++p]) + ; + while (*p == ' ' || *p == '\t') p++; + if (! (*p == 0 || *p == '(')) { + cpp_error (pfile, "malformed option `%s %s'", option, str); + return; + } + + ip = cpp_push_buffer (pfile, buf, strlen (buf)); + do_assert (pfile, NULL, NULL, NULL); + cpp_pop_buffer (pfile); +} + +/* Append a chain of `struct file_name_list's + to the end of the main include chain. + FIRST is the beginning of the chain to append, and LAST is the end. */ + +static void +append_include_chain ( + cpp_reader *pfile, + struct file_name_list *first,struct file_name_list *last) +{ + struct cpp_options *opts = CPP_OPTIONS (pfile); + struct file_name_list *dir; + + if (!first || !last) + return; + + if (opts->include == 0) + opts->include = first; + else + opts->last_include->next = first; + + if (opts->first_bracket_include == 0) + opts->first_bracket_include = first; + + for (dir = first; ; dir = dir->next) { + int len = strlen (dir->fname) + INCLUDE_LEN_FUDGE; + if (len > pfile->max_include_len) + pfile->max_include_len = len; + if (dir == last) + break; + } + + last->next = NULL; + opts->last_include = last; +} + +/* Add output to `deps_buffer' for the -M switch. + STRING points to the text to be output. + SPACER is ':' for targets, ' ' for dependencies, zero for text + to be inserted literally. */ + +static void +deps_output ( + cpp_reader *pfile, + char *string, + int spacer) +{ + int size = strlen (string); + + if (size == 0) + return; + +#ifndef MAX_OUTPUT_COLUMNS +#define MAX_OUTPUT_COLUMNS 72 +#endif + if (spacer + && pfile->deps_column > 0 + && (pfile->deps_column + size) > MAX_OUTPUT_COLUMNS) + { + deps_output (pfile, " \\\n ", 0); + pfile->deps_column = 0; + } + + if (pfile->deps_size + size + 8 > pfile->deps_allocated_size) + { + pfile->deps_allocated_size = (pfile->deps_size + size + 50) * 2; + pfile->deps_buffer = (char *) xrealloc (pfile->deps_buffer, + pfile->deps_allocated_size); + } + if (spacer == ' ' && pfile->deps_column > 0) + pfile->deps_buffer[pfile->deps_size++] = ' '; + bcopy (string, &pfile->deps_buffer[pfile->deps_size], size); + pfile->deps_size += size; + pfile->deps_column += size; + if (spacer == ':') + pfile->deps_buffer[pfile->deps_size++] = ':'; + pfile->deps_buffer[pfile->deps_size] = 0; +} + +/* Given a colon-separated list of file names PATH, + add all the names to the search path for include files. */ + +static void +path_include ( + cpp_reader *pfile, + char *path) +{ + char *p; + + p = path; + + if (*p) + while (1) { + char *q = p; + char *name; + struct file_name_list *dirtmp; + + /* Find the end of this name. */ + while (*q != 0 && *q != PATH_SEPARATOR) q++; + if (p == q) { + /* An empty name in the path stands for the current directory. */ + name = (char *) xmalloc (2); + name[0] = '.'; + name[1] = 0; + } else { + /* Otherwise use the directory that is named. */ + name = (char *) xmalloc (q - p + 1); + bcopy (p, name, q - p); + name[q - p] = 0; + } + + dirtmp = (struct file_name_list *) + xmalloc (sizeof (struct file_name_list)); + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + dirtmp->fname = name; + dirtmp->got_name_map = 0; + append_include_chain (pfile, dirtmp, dirtmp); + + /* Advance past this name. */ + p = q; + if (*p == 0) + break; + /* Skip the colon. */ + p++; + } +} + +void +init_parse_options ( + struct cpp_options *opts) +{ + bzero ((char *) opts, sizeof *opts); + opts->in_fname = NULL; + opts->out_fname = NULL; + + /* Initialize is_idchar to allow $. */ + opts->dollars_in_ident = 1; + initialize_char_syntax (opts); + opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 0; + + opts->no_line_commands = 0; + opts->no_trigraphs = 1; + opts->put_out_comments = 0; + opts->print_include_names = 0; + opts->dump_macros = dump_none; + opts->no_output = 0; + opts->cplusplus = 0; + opts->cplusplus_comments = 0; + + opts->verbose = 0; + opts->objc = 0; + opts->lang_asm = 0; + opts->for_lint = 0; + opts->chill = 0; + opts->pedantic_errors = 0; + opts->inhibit_warnings = 0; + opts->warn_comments = 0; + opts->warn_import = 1; + opts->warnings_are_errors = 0; +} + +enum cpp_token +null_underflow ( + cpp_reader *pfile) +{ + return CPP_EOF; +} + +int +null_cleanup ( + cpp_buffer *pbuf, + cpp_reader *pfile) +{ + return 0; +} + +int +macro_cleanup ( + cpp_buffer *pbuf, + cpp_reader *pfile) +{ + HASHNODE *macro = (HASHNODE*)pbuf->data; + if (macro->type == T_DISABLED) + macro->type = T_MACRO; + if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion) + free (pbuf->buf); + return 0; +} + +int +file_cleanup ( + cpp_buffer *pbuf, + cpp_reader *pfile) +{ + if (pbuf->buf) + { + free (pbuf->buf); + pbuf->buf = 0; + } + return 0; +} + +static void +newline_fix ( + cpp_reader *pfile) +{ +#if 1 + NEWLINE_FIX; +#else + register U_CHAR *p = bp; + + /* First count the backslash-newline pairs here. */ + + while (p[0] == '\\' && p[1] == '\n') + p += 2; + + /* What follows the backslash-newlines is not embarrassing. */ + + if (*p != '/' && *p != '*') + return; + + /* Copy all potentially embarrassing characters + that follow the backslash-newline pairs + down to where the pairs originally started. */ + + while (*p == '*' || *p == '/') + *bp++ = *p++; + + /* Now write the same number of pairs after the embarrassing chars. */ + while (bp < p) { + *bp++ = '\\'; + *bp++ = '\n'; + } +#endif +} + +/* Assuming we have read '/'. + If this is the start of a comment (followed by '*' or '/'), + skip to the end of the comment, and return ' '. + Return EOF if we reached the end of file before the end of the comment. + If not the start of a comment, return '/'. */ + +static int +skip_comment ( + cpp_reader *pfile, + long *linep) +{ + int c; + while (PEEKC() == '\\' && PEEKN(1) == '\n') + { + if (linep) + (*linep)++; + FORWARD(2); + } + if (PEEKC() == '*') + { + FORWARD(1); + for (;;) + { + int prev_c = c; + c = GETC (); + if (c == EOF) + return EOF; + while (c == '\\' && PEEKC() == '\n') + { + if (linep) + (*linep)++; + FORWARD(1), c = GETC(); + } + if (prev_c == '*' && c == '/') + return ' '; + if (c == '\n' && linep) + (*linep)++; + } + } + else if (PEEKC() == '/' && CPP_OPTIONS (pfile)->cplusplus_comments) + { + FORWARD(1); + for (;;) + { + c = GETC (); + if (c == EOF) + return ' '; /* Allow // to be terminated by EOF. */ + while (c == '\\' && PEEKC() == '\n') + { + FORWARD(1); + c = GETC(); + if (linep) + (*linep)++; + } + if (c == '\n') + { + /* Don't consider final '\n' to be part of comment. */ + FORWARD(-1); + return ' '; + } + } + } + else + return '/'; +} + +/* Skip whitespace \-newline and comments. Does not macro-expand. */ +void +cpp_skip_hspace ( + cpp_reader *pfile) +{ + while (1) + { + int c = PEEKC(); + if (c == EOF) + return; /* FIXME */ + if (is_hor_space[c]) + { + if ((c == '\f' || c == '\v') && CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "%s in preprocessing directive", + c == '\f' ? "formfeed" : "vertical tab"); + FORWARD(1); + } + else if (c == '/') + { + FORWARD (1); + c = skip_comment (pfile, NULL); + if (c == '/') + FORWARD(-1); + if (c == EOF || c == '/') + return; + } + else if (c == '\\' && PEEKN(1) == '\n') { + FORWARD(2); + } + else if (c == '@' && CPP_BUFFER (pfile)->has_escapes + && is_hor_space[PEEKN(1)]) + FORWARD(2); + else return; + } +} + +/* Read the rest of the current line. + The line is appended to PFILE's output buffer. */ + +void +copy_rest_of_line ( + cpp_reader *pfile) +{ + struct cpp_options *opts = CPP_OPTIONS (pfile); + for (;;) + { + int c = GETC(); + int nextc; + switch (c) + { + case EOF: + goto end_directive; + case '\\': + if (PEEKC() == '\n') + { + FORWARD (1); + continue; + } + case '\'': + case '\"': + goto scan_directive_token; + break; + case '/': + nextc = PEEKC(); + if (nextc == '*' || (opts->cplusplus_comments && nextc == '*')) + goto scan_directive_token; + break; + case '\f': + case '\v': + if (CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "%s in preprocessing directive", + c == '\f' ? "formfeed" : "vertical tab"); + break; + + case '\n': + FORWARD(-1); + goto end_directive; + scan_directive_token: + FORWARD(-1); + cpp_get_token (pfile); + continue; + } + CPP_PUTC (pfile, c); + } + end_directive: ; + CPP_NUL_TERMINATE (pfile); +} + +void +skip_rest_of_line ( + cpp_reader *pfile) +{ + long old = CPP_WRITTEN (pfile); + copy_rest_of_line (pfile); + CPP_SET_WRITTEN (pfile, old); +} + +/* Handle a possible # directive. + '#' has already been read. */ + +int +handle_directive ( + cpp_reader *pfile) +{ int c; + register struct directive *kt; + int ident_length; + long after_ident; + U_CHAR *ident, *line_end; + long old_written = CPP_WRITTEN (pfile); + + cpp_skip_hspace (pfile); + + c = PEEKC (); + if (c >= '0' && c <= '9') + { + /* Handle # followed by a line number. */ + if (CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "`#' followed by integer"); + do_line (pfile, NULL); + goto done_a_directive; + } + + /* Now find the directive name. */ + CPP_PUTC (pfile, '#'); + parse_name (pfile, GETC()); + ident = pfile->token_buffer + old_written + 1; + ident_length = CPP_PWRITTEN (pfile) - ident; + if (ident_length == 0 && PEEKC() == '\n') + { + /* A line of just `#' becomes blank. */ + goto done_a_directive; + } + +#if 0 + if (ident_length == 0 || !is_idstart[*ident]) { + U_CHAR *p = ident; + while (is_idchar[*p]) { + if (*p < '0' || *p > '9') + break; + p++; + } + /* Avoid error for `###' and similar cases unless -pedantic. */ + if (p == ident) { + while (*p == '#' || is_hor_space[*p]) p++; + if (*p == '\n') { + if (pedantic && !lang_asm) + cpp_warning (pfile, "invalid preprocessor directive"); + return 0; + } + } + + if (!lang_asm) + cpp_error (pfile, "invalid preprocessor directive name"); + + return 0; + } +#endif + /* + * Decode the keyword and call the appropriate expansion + * routine, after moving the input pointer up to the next line. + */ + for (kt = directive_table; ; kt++) { + if (kt->length <= 0) + goto not_a_directive; + if (kt->length == ident_length && !strncmp (kt->name, ident, ident_length)) + break; + } + + if (! kt->command_reads_line) + { + /* Nonzero means do not delete comments within the directive. + #define needs this when -traditional. */ + int comments = CPP_TRADITIONAL (pfile) && kt->traditional_comments; + int save_put_out_comments = CPP_OPTIONS (pfile)->put_out_comments; + CPP_OPTIONS (pfile)->put_out_comments = comments; + after_ident = CPP_WRITTEN (pfile); + copy_rest_of_line (pfile); + CPP_OPTIONS (pfile)->put_out_comments = save_put_out_comments; + } + + /* For #pragma and #define, we may want to pass through the directive. + Other directives may create output, but we don't want the directive + itself out, so we pop it now. For example #include may write a + command (see comment in do_include), and conditionals may emit + #failed ... #endfailed stuff. But note that popping the buffer + means the parameters to kt->func may point after pfile->limit + so these parameters are invalid as soon as something gets appended + to the token_buffer. */ + + line_end = CPP_PWRITTEN (pfile); + if (!kt->pass_thru && kt->type != T_DEFINE) + CPP_SET_WRITTEN (pfile, old_written); + + (*kt->func) (pfile, kt, pfile->token_buffer + after_ident, line_end); + if (kt->pass_thru + || (kt->type == T_DEFINE + && CPP_OPTIONS (pfile)->dump_macros == dump_definitions)) + { + /* Just leave the entire #define in the output stack. */ + } + else if (kt->type == T_DEFINE + && CPP_OPTIONS (pfile)->dump_macros == dump_names) + { + U_CHAR *p = pfile->token_buffer + old_written + 7; /* Skip "#define". */ + SKIP_WHITE_SPACE (p); + while (is_idchar[*p]) p++; + pfile->limit = p; + CPP_PUTC (pfile, '\n'); + } + else if (kt->type == T_DEFINE) + CPP_SET_WRITTEN (pfile, old_written); + done_a_directive: + return 1; + + not_a_directive: + return 0; +} + +/* Pass a directive through to the output file. + BUF points to the contents of the directive, as a contiguous string. + LIMIT points to the first character past the end of the directive. + KEYWORD is the keyword-table entry for the directive. */ + +static void +pass_thru_directive ( + U_CHAR *buf, U_CHAR *limit, + cpp_reader *pfile, + struct directive *keyword) +{ + register unsigned keyword_length = keyword->length; + + CPP_RESERVE (pfile, 1 + keyword_length + (limit - buf)); + CPP_PUTC_Q (pfile, '#'); + CPP_PUTS_Q (pfile, keyword->name, keyword_length); + if (limit != buf && buf[0] != ' ') + CPP_PUTC_Q (pfile, ' '); + CPP_PUTS_Q (pfile, buf, limit - buf); +#if 0 + CPP_PUTS_Q (pfile, '\n'); + /* Count the line we have just made in the output, + to get in sync properly. */ + pfile->lineno++; +#endif +} + +/* The arglist structure is built by do_define to tell + collect_definition where the argument names begin. That + is, for a define like "#define f(x,y,z) foo+x-bar*y", the arglist + would contain pointers to the strings x, y, and z. + Collect_definition would then build a DEFINITION node, + with reflist nodes pointing to the places x, y, and z had + appeared. So the arglist is just convenience data passed + between these two routines. It is not kept around after + the current #define has been processed and entered into the + hash table. */ + +struct arglist { + struct arglist *next; + U_CHAR *name; + int length; + int argno; + char rest_args; +}; + +/* Read a replacement list for a macro with parameters. + Build the DEFINITION structure. + Reads characters of text starting at BUF until END. + ARGLIST specifies the formal parameters to look for + in the text of the definition; NARGS is the number of args + in that list, or -1 for a macro name that wants no argument list. + MACRONAME is the macro name itself (so we can avoid recursive expansion) + and NAMELEN is its length in characters. + + Note that comments, backslash-newlines, and leading white space + have already been deleted from the argument. */ + +static DEFINITION * +collect_expansion ( + cpp_reader *pfile, + U_CHAR *buf, U_CHAR *limit, + int nargs, + struct arglist *arglist) +{ + DEFINITION *defn; + register U_CHAR *p, *lastp, *exp_p; + struct reflist *endpat = NULL; + /* Pointer to first nonspace after last ## seen. */ + U_CHAR *concat = 0; + /* Pointer to first nonspace after last single-# seen. */ + U_CHAR *stringify = 0; + int maxsize; + int expected_delimiter = '\0'; + + /* Scan thru the replacement list, ignoring comments and quoted + strings, picking up on the macro calls. It does a linear search + thru the arg list on every potential symbol. Profiling might say + that something smarter should happen. */ + + if (limit < buf) + abort (); + + /* Find the beginning of the trailing whitespace. */ + p = buf; + while (p < limit && is_space[limit[-1]]) limit--; + + /* Allocate space for the text in the macro definition. + Leading and trailing whitespace chars need 2 bytes each. + Each other input char may or may not need 1 byte, + so this is an upper bound. The extra 5 are for invented + leading and trailing newline-marker and final null. */ + maxsize = (sizeof (DEFINITION) + + (limit - p) + 5); + /* Occurrences of '@' get doubled, so allocate extra space for them. */ + while (p < limit) + if (*p++ == '@') + maxsize++; + defn = (DEFINITION *) xcalloc (1, maxsize); + + defn->nargs = nargs; + exp_p = defn->expansion = (U_CHAR *) defn + sizeof (DEFINITION); + lastp = exp_p; + + p = buf; + + /* Add one initial space escape-marker to prevent accidental + token-pasting (often removed by macroexpand). */ + *exp_p++ = '@'; + *exp_p++ = ' '; + + if (limit - p >= 2 && p[0] == '#' && p[1] == '#') { + cpp_error (pfile, "`##' at start of macro definition"); + p += 2; + } + + /* Process the main body of the definition. */ + while (p < limit) { + int skipped_arg = 0; + register U_CHAR c = *p++; + + *exp_p++ = c; + + if (!CPP_TRADITIONAL (pfile)) { + switch (c) { + case '\'': + case '\"': + if (expected_delimiter != '\0') { + if (c == expected_delimiter) + expected_delimiter = '\0'; + } else + expected_delimiter = c; + break; + + case '\\': + if (p < limit && expected_delimiter) { + /* In a string, backslash goes through + and makes next char ordinary. */ + *exp_p++ = *p++; + } + break; + + case '@': + /* An '@' in a string or character constant stands for itself, + and does not need to be escaped. */ + if (!expected_delimiter) + *exp_p++ = c; + break; + + case '#': + /* # is ordinary inside a string. */ + if (expected_delimiter) + break; + if (p < limit && *p == '#') { + /* ##: concatenate preceding and following tokens. */ + /* Take out the first #, discard preceding whitespace. */ + exp_p--; + while (exp_p > lastp && is_hor_space[exp_p[-1]]) + --exp_p; + /* Skip the second #. */ + p++; + /* Discard following whitespace. */ + SKIP_WHITE_SPACE (p); + concat = p; + if (p == limit) + cpp_error (pfile, "`##' at end of macro definition"); + } else if (nargs >= 0) { + /* Single #: stringify following argument ref. + Don't leave the # in the expansion. */ + exp_p--; + SKIP_WHITE_SPACE (p); + if (p == limit || ! is_idstart[*p]) + cpp_error (pfile, + "`#' operator is not followed by a macro argument name"); + else + stringify = p; + } + break; + } + } else { + /* In -traditional mode, recognize arguments inside strings and + and character constants, and ignore special properties of #. + Arguments inside strings are considered "stringified", but no + extra quote marks are supplied. */ + switch (c) { + case '\'': + case '\"': + if (expected_delimiter != '\0') { + if (c == expected_delimiter) + expected_delimiter = '\0'; + } else + expected_delimiter = c; + break; + + case '\\': + /* Backslash quotes delimiters and itself, but not macro args. */ + if (expected_delimiter != 0 && p < limit + && (*p == expected_delimiter || *p == '\\')) { + *exp_p++ = *p++; + continue; + } + break; + + case '/': + if (expected_delimiter != '\0') /* No comments inside strings. */ + break; + if (*p == '*') { + /* If we find a comment that wasn't removed by handle_directive, + this must be -traditional. So replace the comment with + nothing at all. */ + exp_p--; + p += 1; + while (p < limit && !(p[-2] == '*' && p[-1] == '/')) + p++; +#if 0 + /* Mark this as a concatenation-point, as if it had been ##. */ + concat = p; +#endif + } + break; + } + } + + /* Handle the start of a symbol. */ + if (is_idchar[c] && nargs > 0) { + U_CHAR *id_beg = p - 1; + int id_len; + + --exp_p; + while (p != limit && is_idchar[*p]) p++; + id_len = p - id_beg; + + if (is_idstart[c]) { + register struct arglist *arg; + + for (arg = arglist; arg != NULL; arg = arg->next) { + struct reflist *tpat; + + if (arg->name[0] == c + && arg->length == id_len + && strncmp (arg->name, id_beg, id_len) == 0) { + if (expected_delimiter && CPP_OPTIONS (pfile)->warn_stringify) { + if (CPP_TRADITIONAL (pfile)) { + cpp_warning (pfile, "macro argument `%.*s' is stringified.", + id_len, arg->name); + } else { + cpp_warning (pfile, + "macro arg `%.*s' would be stringified with -traditional.", + id_len, arg->name); + } + } + /* If ANSI, don't actually substitute inside a string. */ + if (!CPP_TRADITIONAL (pfile) && expected_delimiter) + break; + /* make a pat node for this arg and append it to the end of + the pat list */ + tpat = (struct reflist *) xmalloc (sizeof (struct reflist)); + tpat->next = NULL; + tpat->raw_before = concat == id_beg; + tpat->raw_after = 0; + tpat->rest_args = arg->rest_args; + tpat->stringify = (CPP_TRADITIONAL (pfile) + ? expected_delimiter != '\0' + : stringify == id_beg); + + if (endpat == NULL) + defn->pattern = tpat; + else + endpat->next = tpat; + endpat = tpat; + + tpat->argno = arg->argno; + tpat->nchars = exp_p - lastp; + { + register U_CHAR *p1 = p; + SKIP_WHITE_SPACE (p1); + if (p1 + 2 <= limit && p1[0] == '#' && p1[1] == '#') + tpat->raw_after = 1; + } + lastp = exp_p; /* place to start copying from next time */ + skipped_arg = 1; + break; + } + } + } + + /* If this was not a macro arg, copy it into the expansion. */ + if (! skipped_arg) { + register U_CHAR *lim1 = p; + p = id_beg; + while (p != lim1) + *exp_p++ = *p++; + if (stringify == id_beg) + cpp_error (pfile, + "`#' operator should be followed by a macro argument name"); + } + } + } + + if (!CPP_TRADITIONAL (pfile) && expected_delimiter == 0) + { + /* If ANSI, put in a "@ " marker to prevent token pasting. + But not if "inside a string" (which in ANSI mode + happens only for -D option). */ + *exp_p++ = '@'; + *exp_p++ = ' '; + } + + *exp_p = '\0'; + + defn->length = exp_p - defn->expansion; + + /* Crash now if we overrun the allocated size. */ + if (defn->length + 1 > maxsize) + abort (); + +#if 0 +/* This isn't worth the time it takes. */ + /* give back excess storage */ + defn->expansion = (U_CHAR *) xrealloc (defn->expansion, defn->length + 1); +#endif + + return defn; +} + +/* + * special extension string that can be added to the last macro argument to + * allow it to absorb the "rest" of the arguments when expanded. Ex: + * #define wow(a, b...) process (b, a, b) + * { wow (1, 2, 3); } -> { process (2, 3, 1, 2, 3); } + * { wow (one, two); } -> { process (two, one, two); } + * if this "rest_arg" is used with the concat token '##' and if it is not + * supplied then the token attached to with ## will not be outputted. Ex: + * #define wow (a, b...) process (b ## , a, ## b) + * { wow (1, 2); } -> { process (2, 1, 2); } + * { wow (one); } -> { process (one); { + */ +static char rest_extension[] = "..."; +#define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1) + +/* Create a DEFINITION node from a #define directive. Arguments are + as for do_define. */ +static MACRODEF +create_definition ( + U_CHAR *buf, U_CHAR *limit, + cpp_reader *pfile, + int predefinition) +{ + U_CHAR *bp; /* temp ptr into input buffer */ + U_CHAR *symname; /* remember where symbol name starts */ + int sym_length; /* and how long it is */ + int rest_args = 0; + long line, col; + char *file = CPP_BUFFER (pfile) ? CPP_BUFFER (pfile)->nominal_fname : ""; + DEFINITION *defn; + int arglengths = 0; /* Accumulate lengths of arg names + plus number of args. */ + MACRODEF mdef; + cpp_buf_line_and_col (CPP_BUFFER (pfile), &line, &col); + + bp = buf; + + while (is_hor_space[*bp]) + bp++; + + symname = bp; /* remember where it starts */ + + sym_length = check_macro_name (pfile, bp, "macro"); + bp += sym_length; + + /* Lossage will occur if identifiers or control keywords are broken + across lines using backslash. This is not the right place to take + care of that. */ + + if (*bp == '(') { + struct arglist *arg_ptrs = NULL; + int argno = 0; + + bp++; /* skip '(' */ + SKIP_WHITE_SPACE (bp); + + /* Loop over macro argument names. */ + while (*bp != ')') { + struct arglist *temp; + + temp = (struct arglist *) alloca (sizeof (struct arglist)); + temp->name = bp; + temp->next = arg_ptrs; + temp->argno = argno++; + temp->rest_args = 0; + arg_ptrs = temp; + + if (rest_args) + cpp_pedwarn (pfile, "another parameter follows `%s'", rest_extension); + + if (!is_idstart[*bp]) + cpp_pedwarn (pfile, "invalid character in macro parameter name"); + + /* Find the end of the arg name. */ + while (is_idchar[*bp]) { + bp++; + /* do we have a "special" rest-args extension here? */ + if (limit - bp > REST_EXTENSION_LENGTH && + strncmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0) { + rest_args = 1; + temp->rest_args = 1; + break; + } + } + temp->length = bp - temp->name; + if (rest_args == 1) + bp += REST_EXTENSION_LENGTH; + arglengths += temp->length + 2; + SKIP_WHITE_SPACE (bp); + if (temp->length == 0 || (*bp != ',' && *bp != ')')) { + cpp_error (pfile, "badly punctuated parameter list in `#define'"); + goto nope; + } + if (*bp == ',') { + bp++; + SKIP_WHITE_SPACE (bp); + } + if (bp >= limit) { + cpp_error (pfile, "unterminated parameter list in `#define'"); + goto nope; + } + { + struct arglist *otemp; + + for (otemp = temp->next; otemp != NULL; otemp = otemp->next) + if (temp->length == otemp->length && + strncmp (temp->name, otemp->name, temp->length) == 0) { + U_CHAR *name; + + name = (U_CHAR *) alloca (temp->length + 1); + (void) strncpy (name, temp->name, temp->length); + name[temp->length] = '\0'; + cpp_error (pfile, + "duplicate argument name `%s' in `#define'", name); + goto nope; + } + } + } + + ++bp; /* skip paren */ + SKIP_WHITE_SPACE (bp); + /* now everything from bp before limit is the definition. */ + defn = collect_expansion (pfile, bp, limit, argno, arg_ptrs); + defn->rest_args = rest_args; + + /* Now set defn->args.argnames to the result of concatenating + the argument names in reverse order + with comma-space between them. */ + defn->args.argnames = (U_CHAR *) xmalloc (arglengths + 1); + { + struct arglist *temp; + int i = 0; + for (temp = arg_ptrs; temp; temp = temp->next) { + bcopy (temp->name, &defn->args.argnames[i], temp->length); + i += temp->length; + if (temp->next != 0) { + defn->args.argnames[i++] = ','; + defn->args.argnames[i++] = ' '; + } + } + defn->args.argnames[i] = 0; + } + } else { + /* Simple expansion or empty definition. */ + + if (bp < limit) + { + if (is_hor_space[*bp]) { + bp++; + SKIP_WHITE_SPACE (bp); + } else { + switch (*bp) { + case '!': case '"': case '#': case '%': case '&': case '\'': + case ')': case '*': case '+': case ',': case '-': case '.': + case '/': case ':': case ';': case '<': case '=': case '>': + case '?': case '[': case '\\': case ']': case '^': case '{': + case '|': case '}': case '~': + cpp_warning (pfile, "missing white space after `#define %.*s'", + sym_length, symname); + break; + + default: + cpp_pedwarn (pfile, "missing white space after `#define %.*s'", + sym_length, symname); + break; + } + } + } + /* now everything from bp before limit is the definition. */ + defn = collect_expansion (pfile, bp, limit, -1, NULL_PTR); + defn->args.argnames = (U_CHAR *) ""; + } + + defn->line = line; + defn->file = file; + + /* OP is null if this is a predefinition */ + defn->predefined = predefinition; + mdef.defn = defn; + mdef.symnam = symname; + mdef.symlen = sym_length; + + return mdef; + + nope: + mdef.defn = 0; + return mdef; +} + +/* Check a purported macro name SYMNAME, and yield its length. + USAGE is the kind of name this is intended for. */ + +static int +check_macro_name ( + cpp_reader *pfile, + U_CHAR *symname, + char *usage) +{ + U_CHAR *p; + int sym_length; + + for (p = symname; is_idchar[*p]; p++) + ; + sym_length = p - symname; + if (sym_length == 0) + cpp_error (pfile, "invalid %s name", usage); + else if (!is_idstart[*symname]) { + U_CHAR *msg; /* what pain... */ + msg = (U_CHAR *) alloca (sym_length + 1); + bcopy (symname, msg, sym_length); + msg[sym_length] = 0; + cpp_error (pfile, "invalid %s name `%s'", usage, msg); + } else { + if (! strncmp (symname, "defined", 7) && sym_length == 7) + cpp_error (pfile, "invalid %s name `defined'", usage); + } + return sym_length; +} + +/* + * return zero if two DEFINITIONs are isomorphic + */ +static int +compare_defs ( + DEFINITION *d1, DEFINITION *d2) +{ + register struct reflist *a1, *a2; + register U_CHAR *p1 = d1->expansion; + register U_CHAR *p2 = d2->expansion; + int first = 1; + + if (d1->nargs != d2->nargs) + return 1; + if (strcmp ((char *)d1->args.argnames, (char *)d2->args.argnames)) + return 1; + for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2; + a1 = a1->next, a2 = a2->next) { + if (!((a1->nchars == a2->nchars && ! strncmp (p1, p2, a1->nchars)) + || ! comp_def_part (first, p1, a1->nchars, p2, a2->nchars, 0)) + || a1->argno != a2->argno + || a1->stringify != a2->stringify + || a1->raw_before != a2->raw_before + || a1->raw_after != a2->raw_after) + return 1; + first = 0; + p1 += a1->nchars; + p2 += a2->nchars; + } + if (a1 != a2) + return 1; + if (comp_def_part (first, p1, d1->length - (p1 - d1->expansion), + p2, d2->length - (p2 - d2->expansion), 1)) + return 1; + return 0; +} + +/* Return 1 if two parts of two macro definitions are effectively different. + One of the parts starts at BEG1 and has LEN1 chars; + the other has LEN2 chars at BEG2. + Any sequence of whitespace matches any other sequence of whitespace. + FIRST means these parts are the first of a macro definition; + so ignore leading whitespace entirely. + LAST means these parts are the last of a macro definition; + so ignore trailing whitespace entirely. */ + +static int +comp_def_part ( + int first, + U_CHAR *beg1, int len1, + U_CHAR *beg2, int len2 , + int last) +{ + register U_CHAR *end1 = beg1 + len1; + register U_CHAR *end2 = beg2 + len2; + if (first) { + while (beg1 != end1 && is_space[*beg1]) beg1++; + while (beg2 != end2 && is_space[*beg2]) beg2++; + } + if (last) { + while (beg1 != end1 && is_space[end1[-1]]) end1--; + while (beg2 != end2 && is_space[end2[-1]]) end2--; + } + while (beg1 != end1 && beg2 != end2) { + if (is_space[*beg1] && is_space[*beg2]) { + while (beg1 != end1 && is_space[*beg1]) beg1++; + while (beg2 != end2 && is_space[*beg2]) beg2++; + } else if (*beg1 == *beg2) { + beg1++; beg2++; + } else break; + } + return (beg1 != end1) || (beg2 != end2); +} + +/* Process a #define command. +BUF points to the contents of the #define command, as a contiguous string. +LIMIT points to the first character past the end of the definition. +KEYWORD is the keyword-table entry for #define, +or NULL for a "predefined" macro. */ + +static int +do_define ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf, U_CHAR *limit) +{ + int hashcode; + MACRODEF mdef; + HASHNODE *hp; + +#if 0 + /* If this is a precompiler run (with -pcp) pass thru #define commands. */ + if (pcp_outfile && keyword) + pass_thru_directive (buf, limit, pfile, keyword); +#endif + + mdef = create_definition (buf, limit, pfile, keyword == NULL); + if (mdef.defn == 0) + goto nope; + + hashcode = hashf (mdef.symnam, mdef.symlen, HASHSIZE); + + if ((hp = cpp_lookup (pfile, mdef.symnam, mdef.symlen, hashcode)) != NULL) + { + int ok = 0; + /* Redefining a precompiled key is ok. */ + if (hp->type == T_PCSTRING) + ok = 1; + /* Redefining a macro is ok if the definitions are the same. */ + else if (hp->type == T_MACRO) + ok = ! compare_defs (mdef.defn, hp->value.defn); + /* Redefining a constant is ok with -D. */ + else if (hp->type == T_CONST) + ok = ! CPP_OPTIONS (pfile)->done_initializing; + /* Print the warning if it's not ok. */ + if (!ok) + { + U_CHAR *msg; /* what pain... */ + + /* If we are passing through #define and #undef directives, do + that for this re-definition now. */ + if (CPP_OPTIONS (pfile)->debug_output && keyword) + pass_thru_directive (buf, limit, pfile, keyword); + + msg = (U_CHAR *) alloca (mdef.symlen + 22); + *msg = '`'; + bcopy (mdef.symnam, msg + 1, mdef.symlen); + strcpy ((char *) (msg + mdef.symlen + 1), "' redefined"); + cpp_pedwarn (pfile, msg); + if (hp->type == T_MACRO) + cpp_pedwarn_with_file_and_line (pfile, hp->value.defn->file, hp->value.defn->line, + "this is the location of the previous definition"); + } + /* Replace the old definition. */ + hp->type = T_MACRO; + hp->value.defn = mdef.defn; + } + else + { + /* If we are passing through #define and #undef directives, do + that for this new definition now. */ + if (CPP_OPTIONS (pfile)->debug_output && keyword) + pass_thru_directive (buf, limit, pfile, keyword); + install (mdef.symnam, mdef.symlen, T_MACRO, 0, + (char *) mdef.defn, hashcode); + } + + return 0; + +nope: + + return 1; +} + +/* This structure represents one parsed argument in a macro call. + `raw' points to the argument text as written (`raw_length' is its length). + `expanded' points to the argument's macro-expansion + (its length is `expand_length'). + `stringified_length' is the length the argument would have + if stringified. + `use_count' is the number of times this macro arg is substituted + into the macro. If the actual use count exceeds 10, + the value stored is 10. */ + +/* raw and expanded are relative to ARG_BASE */ +#define ARG_BASE ((pfile)->token_buffer) + +struct argdata { + /* Strings relative to pfile->token_buffer */ + long raw, expanded, stringified; + int raw_length, expand_length; + int stringified_length; + char newlines; + char use_count; +}; + + +cpp_buffer* +cpp_push_buffer ( + cpp_reader *pfile, + U_CHAR *buffer, + long length) +{ +#ifdef STATIC_BUFFERS + register cpp_buffer *buf = CPP_BUFFER (pfile); + if (buf == pfile->buffer_stack) + fatal ("%s: macro or `#include' recursion too deep", buf->fname); + buf--; + bzero ((char *) buf, sizeof (cpp_buffer)); + CPP_BUFFER (pfile) = buf; +#else + register cpp_buffer *buf = (cpp_buffer*) xmalloc (sizeof(cpp_buffer)); + bzero ((char *) buf, sizeof (cpp_buffer)); + CPP_PREV_BUFFER (buf) = CPP_BUFFER (pfile); + CPP_BUFFER (pfile) = buf; +#endif + buf->if_stack = pfile->if_stack; + buf->cleanup = null_cleanup; + buf->underflow = null_underflow; + buf->buf = buf->cur = buffer; + buf->alimit = buf->rlimit = buffer + length; + + return buf; +} + +cpp_buffer* +cpp_pop_buffer (pfile) + cpp_reader *pfile; +{ + cpp_buffer *buf = CPP_BUFFER (pfile); +#ifdef STATIC_BUFFERS + (*buf->cleanup) (buf, pfile); + return ++CPP_BUFFER (pfile); +#else + cpp_buffer *next_buf = CPP_PREV_BUFFER (buf); + (*buf->cleanup) (buf, pfile); + CPP_BUFFER (pfile) = next_buf; + free (buf); + return next_buf; +#endif +} + +/* Scan until CPP_BUFFER (PFILE) is exhausted into PFILE->token_buffer. + Pop the buffer when done. */ + +void +cpp_scan_buffer ( + cpp_reader *pfile ) +{ + cpp_buffer *buffer = CPP_BUFFER (pfile); + for (;;) + { + enum cpp_token token = cpp_get_token (pfile); + if (token == CPP_EOF) /* Should not happen ... */ + break; + if (token == CPP_POP && CPP_BUFFER (pfile) == buffer) + { + cpp_pop_buffer (pfile); + break; + } + } +} + +/* + * Rescan a string (which may have escape marks) into pfile's buffer. + * Place the result in pfile->token_buffer. + * + * The input is copied before it is scanned, so it is safe to pass + * it something from the token_buffer that will get overwritten + * (because it follows CPP_WRITTEN). This is used by do_include. + */ + +static void +cpp_expand_to_buffer ( + cpp_reader *pfile, + U_CHAR *buf, + int length) +{ + register cpp_buffer *ip; + cpp_buffer obuf; + U_CHAR *limit = buf + length; + U_CHAR *buf1; +#if 0 + int odepth = indepth; +#endif + + if (length < 0) + abort (); + + /* Set up the input on the input stack. */ + + buf1 = (U_CHAR *) alloca (length + 1); + { + register U_CHAR *p1 = buf; + register U_CHAR *p2 = buf1; + + while (p1 != limit) + *p2++ = *p1++; + } + buf1[length] = 0; + + ip = cpp_push_buffer (pfile, buf1, length); + ip->has_escapes = 1; +#if 0 + ip->lineno = obuf.lineno = 1; +#endif + + /* Scan the input, create the output. */ + cpp_scan_buffer (pfile); + +#if 0 + if (indepth != odepth) + abort (); +#endif + + CPP_NUL_TERMINATE (pfile); +} + + +static void +adjust_position ( + U_CHAR *buf, + U_CHAR *limit, + long *linep, + long *colp) +{ + while (buf < limit) + { + U_CHAR ch = *buf++; + if (ch == '\n') + (*linep)++, (*colp) = 1; + else + (*colp)++; + } +} + +/* Move line_base forward, updating lineno and colno. */ + +static void +update_position ( + register cpp_buffer *pbuf) +{ + unsigned char *old_pos = pbuf->buf + pbuf->line_base; + unsigned char *new_pos = pbuf->cur; + register struct parse_marker *mark; + for (mark = pbuf->marks; mark != NULL; mark = mark->next) + { + if (pbuf->buf + mark->position < new_pos) + new_pos = pbuf->buf + mark->position; + } + pbuf->line_base += new_pos - old_pos; + adjust_position (old_pos, new_pos, &pbuf->lineno, &pbuf->colno); +} + +void +cpp_buf_line_and_col ( + register cpp_buffer *pbuf, + long *linep,long *colp) +{ + long dummy; + if (colp == NULL) + colp = &dummy; + if (pbuf) + { + *linep = pbuf->lineno; + *colp = pbuf->colno; + adjust_position (pbuf->buf + pbuf->line_base, pbuf->cur, linep, colp); + } + else + { + *linep = 0; + *colp = 0; + } +} + +/* Return the cpp_buffer that corresponds to a file (not a macro). */ + +cpp_buffer* +cpp_file_buffer ( + cpp_reader *pfile) +{ + cpp_buffer *ip = CPP_BUFFER (pfile); + + for ( ; ip != CPP_NULL_BUFFER (pfile); ip = CPP_PREV_BUFFER (ip)) + if (ip->fname != NULL) + return ip; + return NULL; +} + +static long +count_newlines ( + register U_CHAR *buf, + register U_CHAR *limit) +{ + register long count = 0; + while (buf < limit) + { + U_CHAR ch = *buf++; + if (ch == '\n') + count++; + } + return count; +} + +/* + * write out a #line command, for instance, after an #include file. + * If CONDITIONAL is nonzero, we can omit the #line if it would + * appear to be a no-op, and we can output a few newlines instead + * if we want to increase the line number by a small amount. + * FILE_CHANGE says whether we are entering a file, leaving, or neither. + */ + +static void +output_line_command ( + cpp_reader *pfile, + int conditional, + enum file_change_code file_change) +{ + int len; + char *line_cmd_buf, *line_end; + long line, col; + cpp_buffer *ip = CPP_BUFFER (pfile); + + if (ip->fname == NULL || CPP_OPTIONS (pfile)->no_output) { + return; + } + + update_position (ip); + line = CPP_BUFFER (pfile)->lineno; + col = CPP_BUFFER (pfile)->colno; + adjust_position (CPP_LINE_BASE (ip), ip->cur, &line, &col); + + if (CPP_OPTIONS (pfile)->no_line_commands) + return; + + if (conditional) { + if (line == pfile->lineno) + return; + + /* If the inherited line number is a little too small, + output some newlines instead of a #line command. */ + if (line > pfile->lineno && line < pfile->lineno + 8) { + CPP_RESERVE (pfile, 20); + while (line > pfile->lineno) { + CPP_PUTC_Q (pfile, '\n'); + pfile->lineno++; + } + return; + } + } + +#if 0 + /* Don't output a line number of 0 if we can help it. */ + if (ip->lineno == 0 && ip->bufp - ip->buf < ip->length + && *ip->bufp == '\n') { + ip->lineno++; + ip->bufp++; + } +#endif + + CPP_RESERVE (pfile, 4 * strlen (ip->nominal_fname) + 50); + { + static char sharp_line[] = "#line "; + CPP_PUTS_Q (pfile, sharp_line, sizeof(sharp_line)-1); + } + + sprintf (CPP_PWRITTEN (pfile), "%d ", line+2); + CPP_ADJUST_WRITTEN (pfile, strlen (CPP_PWRITTEN (pfile))); + +// modification for SDC51 + if (*ip->nominal_fname == '\0') + quote_string (pfile,"standard input"); + else + quote_string (pfile, ip->nominal_fname); + if (file_change != same_file) { + CPP_PUTC_Q (pfile, ' '); + CPP_PUTC_Q (pfile, file_change == enter_file ? '1' : '2'); + } + /* Tell cc1 if following text comes from a system header file. */ + if (ip->system_header_p) { + CPP_PUTC_Q (pfile, ' '); + CPP_PUTC_Q (pfile, '3'); + } +#ifndef NO_IMPLICIT_EXTERN_C + /* Tell cc1plus if following text should be treated as C. */ + if (ip->system_header_p == 2 && CPP_OPTIONS (pfile)->cplusplus) { + CPP_PUTC_Q (pfile, ' '); + CPP_PUTC_Q (pfile, '4'); + } +#endif + CPP_PUTC_Q (pfile, '\n'); + pfile->lineno = line; +} + +/* + * Parse a macro argument and append the info on PFILE's token_buffer. + * REST_ARGS means to absorb the rest of the args. + * Return nonzero to indicate a syntax error. + */ + +static enum cpp_token +macarg ( + cpp_reader *pfile, + int rest_args) +{ + int paren = 0; + enum cpp_token token; + long arg_start = CPP_WRITTEN (pfile); + char save_put_out_comments = CPP_OPTIONS (pfile)->put_out_comments; + CPP_OPTIONS (pfile)->put_out_comments = 0; + + /* Try to parse as much of the argument as exists at this + input stack level. */ + pfile->no_macro_expand++; + for (;;) + { + token = cpp_get_token (pfile); + switch (token) + { + case CPP_EOF: + goto done; + case CPP_POP: + /* If we've hit end of file, it's an error (reported by caller). + Ditto if it's the end of cpp_expand_to_buffer text. + If we've hit end of macro, just continue. */ + if (! CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile))) + goto done; + break; + case CPP_LPAREN: + paren++; + break; + case CPP_RPAREN: + if (--paren < 0) + goto found; + break; + case CPP_COMMA: + /* if we've returned to lowest level and + we aren't absorbing all args */ + if (paren == 0 && rest_args == 0) + goto found; + break; + found: + /* Remove ',' or ')' from argument buffer. */ + CPP_ADJUST_WRITTEN (pfile, -1); + goto done; + default: ; + } + } + + done: + CPP_OPTIONS (pfile)->put_out_comments = save_put_out_comments; + pfile->no_macro_expand--; + + return token; +} + +/* Turn newlines to spaces in the string of length LENGTH at START, + except inside of string constants. + The string is copied into itself with its beginning staying fixed. */ + +static int +change_newlines ( + U_CHAR *start, + int length) +{ + register U_CHAR *ibp; + register U_CHAR *obp; + register U_CHAR *limit; + register int c; + + ibp = start; + limit = start + length; + obp = start; + + while (ibp < limit) { + *obp++ = c = *ibp++; + switch (c) { + + case '\'': + case '\"': + /* Notice and skip strings, so that we don't delete newlines in them. */ + { + int quotec = c; + while (ibp < limit) { + *obp++ = c = *ibp++; + if (c == quotec) + break; + if (c == '\n' && quotec == '\'') + break; + } + } + break; + } + } + + return obp - start; +} + + +static struct tm * +timestamp ( + cpp_reader *pfile) +{ + if (!pfile->timebuf) { + time_t t = time ((time_t *)0); + pfile->timebuf = localtime (&t); + } + return pfile->timebuf; +} + +static char *monthnames[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", + }; + +/* + * expand things like __FILE__. Place the expansion into the output + * buffer *without* rescanning. + */ + +static void +special_symbol ( + HASHNODE *hp, + cpp_reader *pfile) +{ + char *buf; + int i, len; + int true_indepth; + cpp_buffer *ip = NULL; + struct tm *timebuf; + + int paren = 0; /* For special `defined' keyword */ + +#if 0 + if (pcp_outfile && pcp_inside_if + && hp->type != T_SPEC_DEFINED && hp->type != T_CONST) + cpp_error (pfile, + "Predefined macro `%s' used inside `#if' during precompilation", + hp->name); +#endif + + for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip)) + { + if (ip == NULL) + { + cpp_error (pfile, "cccp error: not in any file?!"); + return; /* the show must go on */ + } + if (ip->fname != NULL) + break; + } + + switch (hp->type) + { + case T_FILE: + case T_BASE_FILE: + { + char *string; + if (hp->type == T_BASE_FILE) + { + while (CPP_PREV_BUFFER (ip)) + ip = CPP_PREV_BUFFER (ip); + } + string = ip->nominal_fname; + + if (!string) + string = ""; + CPP_RESERVE (pfile, 3 + 4 * strlen (string)); + quote_string (pfile, string); + return; + } + + case T_INCLUDE_LEVEL: + true_indepth = 0; + for (ip = CPP_BUFFER (pfile); ip != NULL; ip = CPP_PREV_BUFFER (ip)) + if (ip->fname != NULL) + true_indepth++; + + buf = (char *) alloca (8); /* Eight bytes ought to be more than enough */ + sprintf (buf, "%d", true_indepth - 1); + break; + + case T_VERSION: + buf = (char *) alloca (3 + strlen (version_string)); + sprintf (buf, "\"%s\"", version_string); + break; + +#ifndef NO_BUILTIN_SIZE_TYPE + case T_SIZE_TYPE: + buf = SIZE_TYPE; + break; +#endif + +#ifndef NO_BUILTIN_PTRDIFF_TYPE + case T_PTRDIFF_TYPE: + buf = PTRDIFF_TYPE; + break; +#endif + + case T_WCHAR_TYPE: + buf = CPP_WCHAR_TYPE (pfile); + break; + + case T_USER_LABEL_PREFIX_TYPE: + buf = USER_LABEL_PREFIX; + break; + + case T_REGISTER_PREFIX_TYPE: + buf = REGISTER_PREFIX; + break; + + case T_CONST: + buf = (char *) alloca (4 * sizeof (int)); + sprintf (buf, "%d", hp->value.ival); +#if 0 + if (pcp_inside_if && pcp_outfile) + /* Output a precondition for this macro use */ + fprintf (pcp_outfile, "#define %s %d\n", hp->name, hp->value.ival); +#endif + break; + + case T_SPECLINE: + { + long line = ip->lineno; + long col = ip->colno; + adjust_position (CPP_LINE_BASE (ip), ip->cur, &line, &col); + + buf = (char *) alloca (10); + sprintf (buf, "%d", line); + } + break; + + case T_DATE: + case T_TIME: + buf = (char *) alloca (20); + timebuf = timestamp (pfile); + if (hp->type == T_DATE) + sprintf (buf, "\"%s %2d %4d\"", monthnames[timebuf->tm_mon], + timebuf->tm_mday, timebuf->tm_year + 1900); + else + sprintf (buf, "\"%02d:%02d:%02d\"", timebuf->tm_hour, timebuf->tm_min, + timebuf->tm_sec); + break; + + case T_SPEC_DEFINED: + buf = " 0 "; /* Assume symbol is not defined */ + ip = CPP_BUFFER (pfile); + SKIP_WHITE_SPACE (ip->cur); + if (*ip->cur == '(') + { + paren++; + ip->cur++; /* Skip over the paren */ + SKIP_WHITE_SPACE (ip->cur); + } + + if (!is_idstart[*ip->cur]) + goto oops; + if (hp = cpp_lookup (pfile, ip->cur, -1, -1)) + { +#if 0 + if (pcp_outfile && pcp_inside_if + && (hp->type == T_CONST + || (hp->type == T_MACRO && hp->value.defn->predefined))) + /* Output a precondition for this macro use. */ + fprintf (pcp_outfile, "#define %s\n", hp->name); +#endif + buf = " 1 "; + } +#if 0 + else + if (pcp_outfile && pcp_inside_if) + { + /* Output a precondition for this macro use */ + U_CHAR *cp = ip->bufp; + fprintf (pcp_outfile, "#undef "); + while (is_idchar[*cp]) /* Ick! */ + fputc (*cp++, pcp_outfile); + putc ('\n', pcp_outfile); + } +#endif + while (is_idchar[*ip->cur]) + ++ip->cur; + SKIP_WHITE_SPACE (ip->cur); + if (paren) + { + if (*ip->cur != ')') + goto oops; + ++ip->cur; + } + break; + + oops: + + cpp_error (pfile, "`defined' without an identifier"); + break; + + default: + cpp_error (pfile, "cccp error: invalid special hash type"); /* time for gdb */ + abort (); + } + len = strlen (buf); + CPP_RESERVE (pfile, len + 1); + CPP_PUTS_Q (pfile, buf, len); + CPP_NUL_TERMINATE_Q (pfile); + + return; +} + +/* Initialize the built-in macros. */ + +static void +initialize_builtins ( + cpp_reader *pfile) +{ + install ("__LINE__", -1, T_SPECLINE, 0, 0, -1); + install ("__DATE__", -1, T_DATE, 0, 0, -1); + install ("__FILE__", -1, T_FILE, 0, 0, -1); + install ("__BASE_FILE__", -1, T_BASE_FILE, 0, 0, -1); + install ("__INCLUDE_LEVEL__", -1, T_INCLUDE_LEVEL, 0, 0, -1); + install ("__VERSION__", -1, T_VERSION, 0, 0, -1); +#ifndef NO_BUILTIN_SIZE_TYPE + install ("__SIZE_TYPE__", -1, T_SIZE_TYPE, 0, 0, -1); +#endif +#ifndef NO_BUILTIN_PTRDIFF_TYPE + install ("__PTRDIFF_TYPE__ ", -1, T_PTRDIFF_TYPE, 0, 0, -1); +#endif + install ("__WCHAR_TYPE__", -1, T_WCHAR_TYPE, 0, 0, -1); + install ("__USER_LABEL_PREFIX__", -1, T_USER_LABEL_PREFIX_TYPE, 0, 0, -1); + install ("__REGISTER_PREFIX__", -1, T_REGISTER_PREFIX_TYPE, 0, 0, -1); + install ("__TIME__", -1, T_TIME, 0, 0, -1); + if (!CPP_TRADITIONAL (pfile)) + install ("__STDC__", -1, T_CONST, STDC_VALUE, 0, -1); + if (CPP_OPTIONS (pfile)->objc) + install ("__OBJC__", -1, T_CONST, 1, 0, -1); +/* This is supplied using a -D by the compiler driver + so that it is present only when truly compiling with GNU C. */ +/* install ("__GNUC__", -1, T_CONST, 2, 0, -1); */ + + if (CPP_OPTIONS (pfile)->debug_output) + { + char directive[2048]; + register struct directive *dp = &directive_table[0]; + struct tm *timebuf = timestamp (pfile); + cpp_buffer *pbuffer = CPP_BUFFER (pfile); + + while (CPP_PREV_BUFFER (pbuffer)) + pbuffer = CPP_PREV_BUFFER (pbuffer); + sprintf (directive, " __BASE_FILE__ \"%s\"\n", + pbuffer->nominal_fname); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp); + + sprintf (directive, " __VERSION__ \"%s\"\n", version_string); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp); + +#ifndef NO_BUILTIN_SIZE_TYPE + sprintf (directive, " __SIZE_TYPE__ %s\n", SIZE_TYPE); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp); +#endif + +#ifndef NO_BUILTIN_PTRDIFF_TYPE + sprintf (directive, " __PTRDIFF_TYPE__ %s\n", PTRDIFF_TYPE); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp); +#endif + + sprintf (directive, " __WCHAR_TYPE__ %s\n", CPP_WCHAR_TYPE (pfile)); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp); + + sprintf (directive, " __DATE__ \"%s %2d %4d\"\n", + monthnames[timebuf->tm_mon], + timebuf->tm_mday, timebuf->tm_year + 1900); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp); + + sprintf (directive, " __TIME__ \"%02d:%02d:%02d\"\n", + timebuf->tm_hour, timebuf->tm_min, timebuf->tm_sec); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], pfile, dp); + + if (!CPP_TRADITIONAL (pfile)) + { + sprintf (directive, " __STDC__ 1"); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], + pfile, dp); + } + if (CPP_OPTIONS (pfile)->objc) + { + sprintf (directive, " __OBJC__ 1"); + output_line_command (pfile, 0, same_file); + pass_thru_directive (directive, &directive[strlen (directive)], + pfile, dp); + } + } +} + +/* Return 1 iff a token ending in C1 followed directly by a token C2 + could cause mis-tokenization. */ + +static int +unsafe_chars ( + int c1, int c2) +{ + switch (c1) + { + case '+': case '-': + if (c2 == c1 || c2 == '=') + return 1; + goto letter; + case '.': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'e': case 'E': + if (c2 == '-' || c2 == '+') + return 1; /* could extend a pre-processing number */ + goto letter; + case 'L': + if (c2 == '\'' || c2 == '\"') + return 1; /* Could turn into L"xxx" or L'xxx'. */ + goto letter; + letter: + case '_': + case 'a': case 'b': case 'c': case 'd': case 'f': + case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': + case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': + case 's': case 't': case 'u': case 'v': case 'w': case 'x': + case 'y': case 'z': + case 'A': case 'B': case 'C': case 'D': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': + /* We're in the middle of either a name or a pre-processing number. */ + return (is_idchar[c2] || c2 == '.'); + case '<': case '>': case '!': case '%': case '#': case ':': + case '^': case '&': case '|': case '*': case '/': case '=': + return (c2 == c1 || c2 == '='); + } + return 0; +} + +/* Expand a macro call. + HP points to the symbol that is the macro being called. + Put the result of expansion onto the input stack + so that subsequent input by our caller will use it. + + If macro wants arguments, caller has already verified that + an argument list follows; arguments come from the input stack. */ + +static void +macroexpand ( + cpp_reader *pfile, + HASHNODE *hp) +{ + int nargs; + DEFINITION *defn = hp->value.defn; + register U_CHAR *xbuf; + long start_line, start_column; + int xbuf_len; + struct argdata *args; + long old_written = CPP_WRITTEN (pfile); +#if 0 + int start_line = instack[indepth].lineno; +#endif + int rest_args, rest_zero; + register int i; + +#if 0 + CHECK_DEPTH (return;); +#endif + +#if 0 + /* This macro is being used inside a #if, which means it must be */ + /* recorded as a precondition. */ + if (pcp_inside_if && pcp_outfile && defn->predefined) + dump_single_macro (hp, pcp_outfile); +#endif + + pfile->output_escapes++; + cpp_buf_line_and_col (cpp_file_buffer (pfile), &start_line, &start_column); + + nargs = defn->nargs; + + if (nargs >= 0) + { + enum cpp_token token; + + args = (struct argdata *) alloca ((nargs + 1) * sizeof (struct argdata)); + + for (i = 0; i < nargs; i++) + { + args[i].raw = args[i].expanded = 0; + args[i].raw_length = 0; + args[i].expand_length = args[i].stringified_length = -1; + args[i].use_count = 0; + } + + /* Parse all the macro args that are supplied. I counts them. + The first NARGS args are stored in ARGS. + The rest are discarded. If rest_args is set then we assume + macarg absorbed the rest of the args. */ + i = 0; + rest_args = 0; + rest_args = 0; + FORWARD(1); /* Discard the open-parenthesis before the first arg. */ + do + { + if (rest_args) + continue; + if (i < nargs || (nargs == 0 && i == 0)) + { + /* if we are working on last arg which absorbs rest of args... */ + if (i == nargs - 1 && defn->rest_args) + rest_args = 1; + args[i].raw = CPP_WRITTEN (pfile); + token = macarg (pfile, rest_args); + args[i].raw_length = CPP_WRITTEN (pfile) - args[i].raw; + args[i].newlines = 0; /* FIXME */ + } + else + token = macarg (pfile, 0); + if (token == CPP_EOF || token == CPP_POP) + { + cpp_error_with_line (pfile, start_line, start_column, + "unterminated macro call"); + return; + } + i++; + } while (token == CPP_COMMA); + + /* If we got one arg but it was just whitespace, call that 0 args. */ + if (i == 1) + { + register U_CHAR *bp = ARG_BASE + args[0].raw; + register U_CHAR *lim = bp + args[0].raw_length; + /* cpp.texi says for foo ( ) we provide one argument. + However, if foo wants just 0 arguments, treat this as 0. */ + if (nargs == 0) + while (bp != lim && is_space[*bp]) bp++; + if (bp == lim) + i = 0; + } + + /* Don't output an error message if we have already output one for + a parse error above. */ + rest_zero = 0; + if (nargs == 0 && i > 0) + { + cpp_error (pfile, "arguments given to macro `%s'", hp->name); + } + else if (i < nargs) + { + /* traditional C allows foo() if foo wants one argument. */ + if (nargs == 1 && i == 0 && CPP_TRADITIONAL (pfile)) + ; + /* the rest args token is allowed to absorb 0 tokens */ + else if (i == nargs - 1 && defn->rest_args) + rest_zero = 1; + else if (i == 0) + cpp_error (pfile, "macro `%s' used without args", hp->name); + else if (i == 1) + cpp_error (pfile, "macro `%s' used with just one arg", hp->name); + else + cpp_error (pfile, "macro `%s' used with only %d args", + hp->name, i); + } + else if (i > nargs) + { + cpp_error (pfile, + "macro `%s' used with too many (%d) args", hp->name, i); + } + } + + /* If macro wants zero args, we parsed the arglist for checking only. + Read directly from the macro definition. */ + if (nargs <= 0) + { + xbuf = defn->expansion; + xbuf_len = defn->length; + } + else + { + register U_CHAR *exp = defn->expansion; + register int offset; /* offset in expansion, + copied a piece at a time */ + register int totlen; /* total amount of exp buffer filled so far */ + + register struct reflist *ap, *last_ap; + + /* Macro really takes args. Compute the expansion of this call. */ + + /* Compute length in characters of the macro's expansion. + Also count number of times each arg is used. */ + xbuf_len = defn->length; + for (ap = defn->pattern; ap != NULL; ap = ap->next) + { + if (ap->stringify) + { + register struct argdata *arg = &args[ap->argno]; + /* Stringify it it hasn't already been */ + if (arg->stringified_length < 0) + { + int arglen = arg->raw_length; + int escaped = 0; + int in_string = 0; + int c; + /* Initially need_space is -1. Otherwise, 1 means the + previous character was a space, but we suppressed it; + 0 means the previous character was a non-space. */ + int need_space = -1; + i = 0; + arg->stringified = CPP_WRITTEN (pfile); + if (!CPP_TRADITIONAL (pfile)) + CPP_PUTC (pfile, '\"'); /* insert beginning quote */ + for (; i < arglen; i++) + { + c = (ARG_BASE + arg->raw)[i]; + + if (! in_string) + { + /* Internal sequences of whitespace are replaced by + one space except within an string or char token.*/ + if (is_space[c]) + { + if (CPP_WRITTEN (pfile) > arg->stringified + && (CPP_PWRITTEN (pfile))[-1] == '@') + { + /* "@ " escape markers are removed */ + CPP_ADJUST_WRITTEN (pfile, -1); + continue; + } + if (need_space == 0) + need_space = 1; + continue; + } + else if (need_space > 0) + CPP_PUTC (pfile, ' '); + need_space = 0; + } + + if (escaped) + escaped = 0; + else + { + if (c == '\\') + escaped = 1; + if (in_string) + { + if (c == in_string) + in_string = 0; + } + else if (c == '\"' || c == '\'') + in_string = c; + } + + /* Escape these chars */ + if (c == '\"' || (in_string && c == '\\')) + CPP_PUTC (pfile, '\\'); + if (isprint (c)) + CPP_PUTC (pfile, c); + else + { + CPP_RESERVE (pfile, 4); + sprintf (CPP_PWRITTEN (pfile), "\\%03o", + (unsigned int) c); + CPP_ADJUST_WRITTEN (pfile, 4); + } + } + if (!CPP_TRADITIONAL (pfile)) + CPP_PUTC (pfile, '\"'); /* insert ending quote */ + arg->stringified_length + = CPP_WRITTEN (pfile) - arg->stringified; + } + xbuf_len += args[ap->argno].stringified_length; + } + else if (ap->raw_before || ap->raw_after || CPP_TRADITIONAL (pfile)) + /* Add 4 for two newline-space markers to prevent + token concatenation. */ + xbuf_len += args[ap->argno].raw_length + 4; + else + { + /* We have an ordinary (expanded) occurrence of the arg. + So compute its expansion, if we have not already. */ + if (args[ap->argno].expand_length < 0) + { + args[ap->argno].expanded = CPP_WRITTEN (pfile); + cpp_expand_to_buffer (pfile, + ARG_BASE + args[ap->argno].raw, + args[ap->argno].raw_length); + + args[ap->argno].expand_length + = CPP_WRITTEN (pfile) - args[ap->argno].expanded; + } + + /* Add 4 for two newline-space markers to prevent + token concatenation. */ + xbuf_len += args[ap->argno].expand_length + 4; + } + if (args[ap->argno].use_count < 10) + args[ap->argno].use_count++; + } + + xbuf = (U_CHAR *) xmalloc (xbuf_len + 1); + + /* Generate in XBUF the complete expansion + with arguments substituted in. + TOTLEN is the total size generated so far. + OFFSET is the index in the definition + of where we are copying from. */ + offset = totlen = 0; + for (last_ap = NULL, ap = defn->pattern; ap != NULL; + last_ap = ap, ap = ap->next) + { + register struct argdata *arg = &args[ap->argno]; + int count_before = totlen; + + /* Add chars to XBUF. */ + for (i = 0; i < ap->nchars; i++, offset++) + xbuf[totlen++] = exp[offset]; + + /* If followed by an empty rest arg with concatenation, + delete the last run of nonwhite chars. */ + if (rest_zero && totlen > count_before + && ((ap->rest_args && ap->raw_before) + || (last_ap != NULL && last_ap->rest_args + && last_ap->raw_after))) + { + /* Delete final whitespace. */ + while (totlen > count_before && is_space[xbuf[totlen - 1]]) + totlen--; + + /* Delete the nonwhites before them. */ + while (totlen > count_before && ! is_space[xbuf[totlen - 1]]) + totlen--; + } + + if (ap->stringify != 0) + { + bcopy (ARG_BASE + arg->stringified, + xbuf + totlen, arg->stringified_length); + totlen += arg->stringified_length; + } + else if (ap->raw_before || ap->raw_after || CPP_TRADITIONAL (pfile)) + { + U_CHAR *p1 = ARG_BASE + arg->raw; + U_CHAR *l1 = p1 + arg->raw_length; + if (ap->raw_before) + { + while (p1 != l1 && is_space[*p1]) p1++; + while (p1 != l1 && is_idchar[*p1]) + xbuf[totlen++] = *p1++; + } + if (ap->raw_after) + { + /* Arg is concatenated after: delete trailing whitespace, + whitespace markers, and no-reexpansion markers. */ + while (p1 != l1) + { + if (is_space[l1[-1]]) l1--; + else if (l1[-1] == '-') + { + U_CHAR *p2 = l1 - 1; + /* If a `-' is preceded by an odd number of newlines then it + and the last newline are a no-reexpansion marker. */ + while (p2 != p1 && p2[-1] == '\n') p2--; + if ((l1 - 1 - p2) & 1) { + l1 -= 2; + } + else break; + } + else break; + } + } + + bcopy (p1, xbuf + totlen, l1 - p1); + totlen += l1 - p1; + } + else + { + U_CHAR *expanded = ARG_BASE + arg->expanded; + if (!ap->raw_before && totlen > 0 && arg->expand_length + && !CPP_TRADITIONAL(pfile) + && unsafe_chars (xbuf[totlen-1], expanded[0])) + { + xbuf[totlen++] = '@'; + xbuf[totlen++] = ' '; + } + + bcopy (expanded, xbuf + totlen, arg->expand_length); + totlen += arg->expand_length; + + if (!ap->raw_after && totlen > 0 && offset < defn->length + && !CPP_TRADITIONAL(pfile) + && unsafe_chars (xbuf[totlen-1], exp[offset])) + { + xbuf[totlen++] = '@'; + xbuf[totlen++] = ' '; + } + + /* If a macro argument with newlines is used multiple times, + then only expand the newlines once. This avoids creating + output lines which don't correspond to any input line, + which confuses gdb and gcov. */ + if (arg->use_count > 1 && arg->newlines > 0) + { + /* Don't bother doing change_newlines for subsequent + uses of arg. */ + arg->use_count = 1; + arg->expand_length + = change_newlines (expanded, arg->expand_length); + } + } + + if (totlen > xbuf_len) + abort (); + } + + /* if there is anything left of the definition + after handling the arg list, copy that in too. */ + + for (i = offset; i < defn->length; i++) + { + /* if we've reached the end of the macro */ + if (exp[i] == ')') + rest_zero = 0; + if (! (rest_zero && last_ap != NULL && last_ap->rest_args + && last_ap->raw_after)) + xbuf[totlen++] = exp[i]; + } + + xbuf[totlen] = 0; + xbuf_len = totlen; + + } + + pfile->output_escapes--; + + /* Now put the expansion on the input stack + so our caller will commence reading from it. */ + push_macro_expansion (pfile, xbuf, xbuf_len, hp); + CPP_BUFFER (pfile)->has_escapes = 1; + + /* Pop the space we've used in the token_buffer for argument expansion. */ + CPP_SET_WRITTEN (pfile, old_written); + + /* Recursive macro use sometimes works traditionally. + #define foo(x,y) bar (x (y,0), y) + foo (foo, baz) */ + + if (!CPP_TRADITIONAL (pfile)) + hp->type = T_DISABLED; +} + +static void +push_macro_expansion ( + cpp_reader *pfile, + register U_CHAR *xbuf, + int xbuf_len, + HASHNODE *hp) +{ + register cpp_buffer *mbuf = cpp_push_buffer (pfile, xbuf, xbuf_len); + mbuf->cleanup = macro_cleanup; + mbuf->data = hp; + + /* The first chars of the expansion should be a "@ " added by + collect_expansion. This is to prevent accidental token-pasting + between the text preceding the macro invocation, and the macro + expansion text. + + We would like to avoid adding unneeded spaces (for the sake of + tools that use cpp, such as imake). In some common cases we can + tell that it is safe to omit the space. + + The character before the macro invocation cannot have been an + idchar (or else it would have been pasted with the idchars of + the macro name). Therefore, if the first non-space character + of the expansion is an idchar, we do not need the extra space + to prevent token pasting. + + Also, we don't need the extra space if the first char is '(', + or some other (less common) characters. */ + + if (xbuf[0] == '@' && xbuf[1] == ' ' + && (is_idchar[xbuf[2]] || xbuf[2] == '(' || xbuf[2] == '\'' + || xbuf[2] == '\"')) + mbuf->cur += 2; +} + +/* Like cpp_get_token, except that it does not read past end-of-line. + Also, horizontal space is skipped, and macros are popped. */ + +static enum cpp_token +get_directive_token ( + cpp_reader *pfile) +{ + for (;;) + { + long old_written = CPP_WRITTEN (pfile); + enum cpp_token token; + cpp_skip_hspace (pfile); + if (PEEKC () == '\n') + return CPP_VSPACE; + token = cpp_get_token (pfile); + switch (token) + { + case CPP_POP: + if (! CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile))) + return token; + /* ... else fall though ... */ + case CPP_HSPACE: case CPP_COMMENT: + CPP_SET_WRITTEN (pfile, old_written); + break; + default: + return token; + } + } +} + +/* Handle #include and #import. + This function expects to see "fname" or on the input. + + The input is normally in part of the output_buffer following + CPP_WRITTEN, and will get overwritten by output_line_command. + I.e. in input file specification has been popped by handle_directive. + This is safe. */ + +static int +do_include ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *unused1, U_CHAR *unused2) +{ + int importing = (keyword->type == T_IMPORT); + int skip_dirs = (keyword->type == T_INCLUDE_NEXT); + char *fname; /* Dynamically allocated fname buffer */ + char *pcftry; + char *pcfname; + U_CHAR *fbeg, *fend; /* Beginning and end of fname */ + enum cpp_token token; + + /* Chain of dirs to search */ + struct file_name_list *search_start = CPP_OPTIONS (pfile)->include; + struct file_name_list dsp[1]; /* First in chain, if #include "..." */ + struct file_name_list *searchptr = 0; + long old_written = CPP_WRITTEN (pfile); + + int flen; + + int f; /* file number */ + + int retried = 0; /* Have already tried macro + expanding the include line*/ + int angle_brackets = 0; /* 0 for "...", 1 for <...> */ + int pcf = -1; + char *pcfbuf; + char *pcfbuflimit; + int pcfnum; + f= -1; /* JF we iz paranoid! */ + + if (importing && CPP_OPTIONS (pfile)->warn_import + && !CPP_OPTIONS (pfile)->inhibit_warnings + && !CPP_BUFFER (pfile)->system_header_p && !pfile->import_warning) + { + pfile->import_warning = 1; + cpp_warning (pfile, "using `#import' is not recommended"); + fprintf (stderr, "The fact that a certain header file need not be processed more than once\n"); + fprintf (stderr, "should be indicated in the header file, not where it is used.\n"); + fprintf (stderr, "The best way to do this is with a conditional of this form:\n\n"); + fprintf (stderr, " #ifndef _FOO_H_INCLUDED\n"); + fprintf (stderr, " #define _FOO_H_INCLUDED\n"); + fprintf (stderr, " ... ...\n"); + fprintf (stderr, " #endif /* Not _FOO_H_INCLUDED */\n\n"); + fprintf (stderr, "Then users can use `#include' any number of times.\n"); + fprintf (stderr, "GNU C automatically avoids processing the file more than once\n"); + fprintf (stderr, "when it is equipped with such a conditional.\n"); + } + + pfile->parsing_include_directive++; + token = get_directive_token (pfile); + pfile->parsing_include_directive--; + + if (token == CPP_STRING) + { + /* FIXME - check no trailing garbage */ + fbeg = pfile->token_buffer + old_written + 1; + fend = CPP_PWRITTEN (pfile) - 1; + if (fbeg[-1] == '<') + { + angle_brackets = 1; + /* If -I-, start with the first -I dir after the -I-. */ + if (CPP_OPTIONS (pfile)->first_bracket_include) + search_start = CPP_OPTIONS (pfile)->first_bracket_include; + } + /* If -I- was specified, don't search current dir, only spec'd ones. */ + else if (! CPP_OPTIONS (pfile)->ignore_srcdir) + { + cpp_buffer *fp; + /* We have "filename". Figure out directory this source + file is coming from and put it on the front of the list. */ + + for (fp = CPP_BUFFER (pfile); fp != NULL; fp = CPP_PREV_BUFFER (fp)) + { + int n; + char *ep,*nam; + + if ((nam = fp->nominal_fname) != NULL) + { + /* Found a named file. Figure out dir of the file, + and put it in front of the search list. */ + dsp[0].next = search_start; + search_start = dsp; +#ifndef VMS + ep = rindex (nam, '/'); +#else /* VMS */ + ep = rindex (nam, ']'); + if (ep == NULL) ep = rindex (nam, '>'); + if (ep == NULL) ep = rindex (nam, ':'); + if (ep != NULL) ep++; +#endif /* VMS */ + if (ep != NULL) + { + n = ep - nam; + dsp[0].fname = (char *) alloca (n + 1); + strncpy (dsp[0].fname, nam, n); + dsp[0].fname[n] = '\0'; + if (n + INCLUDE_LEN_FUDGE > pfile->max_include_len) + pfile->max_include_len = n + INCLUDE_LEN_FUDGE; + } + else + { + dsp[0].fname = 0; /* Current directory */ + } + dsp[0].got_name_map = 0; + break; + } + } + } + } +#ifdef VMS + else if (token == CPP_NAME) + { + /* + * Support '#include xyz' like VAX-C to allow for easy use of all the + * decwindow include files. It defaults to '#include ' (so the + * code from case '<' is repeated here) and generates a warning. + */ + cpp_warning (pfile, + "VAX-C-style include specification found, use '#include ' !"); + angle_brackets = 1; + /* If -I-, start with the first -I dir after the -I-. */ + if (CPP_OPTIONS (pfile)->first_bracket_include) + search_start = CPP_OPTIONS (pfile)->first_bracket_include; + fbeg = pfile->token_buffer + old_written; + fend = CPP_PWRITTEN (pfile); + } +#endif + else + { + cpp_error (pfile, + "`#%s' expects \"FILENAME\" or ", keyword->name); + CPP_SET_WRITTEN (pfile, old_written); + skip_rest_of_line (pfile); + return 0; + } + + *fend = 0; + + token = get_directive_token (pfile); + if (token != CPP_VSPACE) + { + cpp_error (pfile, "junk at end of `#include'"); + while (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP) + token = get_directive_token (pfile); + } + + /* For #include_next, skip in the search path + past the dir in which the containing file was found. */ + if (skip_dirs) + { + cpp_buffer *fp; + for (fp = CPP_BUFFER (pfile); fp != NULL; fp = CPP_PREV_BUFFER (fp)) + if (fp->fname != NULL) + { + /* fp->dir is null if the containing file was specified with + an absolute file name. In that case, don't skip anything. */ + if (fp->dir == SELF_DIR_DUMMY) + search_start = CPP_OPTIONS (pfile)->include; + else if (fp->dir) + search_start = fp->dir->next; + break; + } + } + + CPP_SET_WRITTEN (pfile, old_written); + + flen = fend - fbeg; + + if (flen == 0) + { + cpp_error (pfile, "empty file name in `#%s'", keyword->name); + return 0; + } + + /* Allocate this permanently, because it gets stored in the definitions + of macros. */ + fname = (char *) xmalloc (pfile->max_include_len + flen + 4); + /* + 2 above for slash and terminating null. */ + /* + 2 added for '.h' on VMS (to support '#include filename') */ + + /* If specified file name is absolute, just open it. */ + + if (*fbeg == '/') { + strncpy (fname, fbeg, flen); + fname[flen] = 0; + if (redundant_include_p (pfile, fname)) + return 0; + if (importing) + f = lookup_import (pfile, fname, NULL_PTR); + else + f = open_include_file (pfile, fname, NULL_PTR); + if (f == -2) + return 0; /* Already included this file */ + } else { + /* Search directory path, trying to open the file. + Copy each filename tried into FNAME. */ + + for (searchptr = search_start; searchptr; searchptr = searchptr->next) { + if (searchptr->fname) { + /* The empty string in a search path is ignored. + This makes it possible to turn off entirely + a standard piece of the list. */ + if (searchptr->fname[0] == 0) + continue; + strcpy (fname, searchptr->fname); + strcat (fname, "/"); + fname[strlen (fname) + flen] = 0; + } else { + fname[0] = 0; + } + strncat (fname, fbeg, flen); +#ifdef VMS + /* Change this 1/2 Unix 1/2 VMS file specification into a + full VMS file specification */ + if (searchptr->fname && (searchptr->fname[0] != 0)) { + /* Fix up the filename */ + hack_vms_include_specification (fname); + } else { + /* This is a normal VMS filespec, so use it unchanged. */ + strncpy (fname, fbeg, flen); + fname[flen] = 0; + /* if it's '#include filename', add the missing .h */ + if (index(fname,'.')==NULL) { + strcat (fname, ".h"); + } + } +#endif /* VMS */ + /* ??? There are currently 3 separate mechanisms for avoiding processing + of redundant include files: #import, #pragma once, and + redundant_include_p. It would be nice if they were unified. */ + if (redundant_include_p (pfile, fname)) + return 0; + if (importing) + f = lookup_import (pfile, fname, searchptr); + else + f = open_include_file (pfile, fname, searchptr); + if (f == -2) + return 0; /* Already included this file */ +#ifdef EACCES + else if (f == -1 && errno == EACCES) + cpp_warning (pfile, "Header file %s exists, but is not readable", + fname); +#endif + if (f >= 0) + break; + } + } + + if (f < 0) + { + /* A file that was not found. */ + strncpy (fname, fbeg, flen); + fname[flen] = 0; + /* If generating dependencies and -MG was specified, we assume missing + files are leaf files, living in the same directory as the source file + or other similar place; these missing files may be generated from + other files and may not exist yet (eg: y.tab.h). */ + + if (CPP_OPTIONS(pfile)->print_deps_missing_files + && CPP_PRINT_DEPS (pfile) + > (angle_brackets || (pfile->system_include_depth > 0))) + { + /* If it was requested as a system header file, + then assume it belongs in the first place to look for such. */ + if (angle_brackets) + { + for (searchptr = search_start; searchptr; + searchptr = searchptr->next) + { + if (searchptr->fname) + { + char *p; + + if (searchptr->fname[0] == 0) + continue; + p = (char *) alloca (strlen (searchptr->fname) + + strlen (fname) + 2); + strcpy (p, searchptr->fname); + strcat (p, "/"); + strcat (p, fname); + deps_output (pfile, p, ' '); + break; + } + } + } + else + { + /* Otherwise, omit the directory, as if the file existed + in the directory with the source. */ + deps_output (pfile, fname, ' '); + } + } + /* If -M was specified, and this header file won't be added to the + dependency list, then don't count this as an error, because we can + still produce correct output. Otherwise, we can't produce correct + output, because there may be dependencies we need inside the missing + file, and we don't know what directory this missing file exists in.*/ + else if (CPP_PRINT_DEPS (pfile) + && (CPP_PRINT_DEPS (pfile) + <= (angle_brackets || (pfile->system_include_depth > 0)))) + cpp_warning (pfile, "No include path in which to find %s", fname); + else if (search_start) + cpp_error_from_errno (pfile, fname); + else + cpp_error (pfile, "No include path in which to find %s", fname); + } + else { + /* Check to see if this include file is a once-only include file. + If so, give up. */ + + struct file_name_list* ptr; + + for (ptr = pfile->dont_repeat_files; ptr; ptr = ptr->next) { + if (!strcmp (ptr->fname, fname)) { + close (f); + return 0; /* This file was once'd. */ + } + } + + for (ptr = pfile->all_include_files; ptr; ptr = ptr->next) { + if (!strcmp (ptr->fname, fname)) + break; /* This file was included before. */ + } + + if (ptr == 0) { + /* This is the first time for this file. */ + /* Add it to list of files included. */ + + ptr = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + ptr->control_macro = 0; + ptr->c_system_include_path = 0; + ptr->next = pfile->all_include_files; + pfile->all_include_files = ptr; + ptr->fname = savestring (fname); + ptr->got_name_map = 0; + + /* For -M, add this file to the dependencies. */ + if (CPP_PRINT_DEPS (pfile) + > (angle_brackets || (pfile->system_include_depth > 0))) + deps_output (pfile, fname, ' '); + } + + /* Handle -H option. */ + if (CPP_OPTIONS(pfile)->print_include_names) + { + cpp_buffer *buf = CPP_BUFFER (pfile); + while ((buf = CPP_PREV_BUFFER (buf)) != NULL) + putc ('.', stderr); + fprintf (stderr, "%s\n", fname); + } + + if (angle_brackets) + pfile->system_include_depth++; + + /* Actually process the file. */ + + /* Record file on "seen" list for #import. */ + add_import (pfile, f, fname); + + pcftry = (char *) alloca (strlen (fname) + 30); + pcfbuf = 0; + pcfnum = 0; + +#if 0 + if (!no_precomp) + { + struct stat stat_f; + + fstat (f, &stat_f); + + do { + sprintf (pcftry, "%s%d", fname, pcfnum++); + + pcf = open (pcftry, O_RDONLY, 0666); + if (pcf != -1) + { + struct stat s; + + fstat (pcf, &s); + if (bcmp ((char *) &stat_f.st_ino, (char *) &s.st_ino, + sizeof (s.st_ino)) + || stat_f.st_dev != s.st_dev) + { + pcfbuf = check_precompiled (pcf, fname, &pcfbuflimit); + /* Don't need it any more. */ + close (pcf); + } + else + { + /* Don't need it at all. */ + close (pcf); + break; + } + } + } while (pcf != -1 && !pcfbuf); + } +#endif + + /* Actually process the file */ + cpp_push_buffer (pfile, NULL, 0); + if (finclude (pfile, f, fname, is_system_include (pfile, fname), + searchptr != dsp ? searchptr : SELF_DIR_DUMMY)) + { + output_line_command (pfile, 0, enter_file); + pfile->only_seen_white = 2; + } + + if (angle_brackets) + pfile->system_include_depth--; + } + return 0; +} + +/* Return nonzero if there is no need to include file NAME + because it has already been included and it contains a conditional + to make a repeated include do nothing. */ + +static int +redundant_include_p ( + cpp_reader *pfile, + char *name) +{ + struct file_name_list *l = pfile->all_include_files; + for (; l; l = l->next) + if (! strcmp (name, l->fname) + && l->control_macro + && cpp_lookup (pfile, l->control_macro, -1, -1)) + return 1; + return 0; +} + +/* Return nonzero if the given FILENAME is an absolute pathname which + designates a file within one of the known "system" include file + directories. We assume here that if the given FILENAME looks like + it is the name of a file which resides either directly in a "system" + include file directory, or within any subdirectory thereof, then the + given file must be a "system" include file. This function tells us + if we should suppress pedantic errors/warnings for the given FILENAME. + + The value is 2 if the file is a C-language system header file + for which C++ should (on most systems) assume `extern "C"'. */ + +static int +is_system_include ( + cpp_reader *pfile, + register char *filename) +{ + struct file_name_list *searchptr; + + for (searchptr = CPP_OPTIONS (pfile)->first_system_include; searchptr; + searchptr = searchptr->next) + if (searchptr->fname) { + register char *sys_dir = searchptr->fname; + register unsigned length = strlen (sys_dir); + + if (! strncmp (sys_dir, filename, length) && filename[length] == '/') + { + if (searchptr->c_system_include_path) + return 2; + else + return 1; + } + } + return 0; +} + + +/* + * Install a name in the assertion hash table. + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ +static ASSERTION_HASHNODE * +assertion_install ( + cpp_reader *pfile, + U_CHAR *name, + int len, + int hash) +{ + register ASSERTION_HASHNODE *hp; + register int i, bucket; + register U_CHAR *p, *q; + + i = sizeof (ASSERTION_HASHNODE) + len + 1; + hp = (ASSERTION_HASHNODE *) xmalloc (i); + bucket = hash; + hp->bucket_hdr = &pfile->assertion_hashtab[bucket]; + hp->next = pfile->assertion_hashtab[bucket]; + pfile->assertion_hashtab[bucket] = hp; + hp->prev = NULL; + if (hp->next != NULL) + hp->next->prev = hp; + hp->length = len; + hp->value = 0; + hp->name = ((U_CHAR *) hp) + sizeof (ASSERTION_HASHNODE); + p = hp->name; + q = name; + for (i = 0; i < len; i++) + *p++ = *q++; + hp->name[len] = 0; + return hp; +} +/* + * find the most recent hash node for name name (ending with first + * non-identifier char) installed by install + * + * If LEN is >= 0, it is the length of the name. + * Otherwise, compute the length by scanning the entire name. + * + * If HASH is >= 0, it is the precomputed hash code. + * Otherwise, compute the hash code. + */ + +static ASSERTION_HASHNODE * +assertion_lookup ( + cpp_reader *pfile, + U_CHAR *name, + int len, + int hash) +{ + register ASSERTION_HASHNODE *bucket; + + bucket = pfile->assertion_hashtab[hash]; + while (bucket) { + if (bucket->length == len && strncmp (bucket->name, name, len) == 0) + return bucket; + bucket = bucket->next; + } + return NULL; +} + +static void +delete_assertion ( + ASSERTION_HASHNODE *hp) +{ + struct tokenlist_list *tail; + if (hp->prev != NULL) + hp->prev->next = hp->next; + if (hp->next != NULL) + hp->next->prev = hp->prev; + + for (tail = hp->value; tail; ) + { + struct tokenlist_list *next = tail->next; + free_token_list (tail->tokens); + free (tail); + tail = next; + } + + /* make sure that the bucket chain header that + the deleted guy was on points to the right thing afterwards. */ + if (hp == *hp->bucket_hdr) + *hp->bucket_hdr = hp->next; + + free (hp); +} + +/* Convert a character string literal into a nul-terminated string. + The input string is [IN ... LIMIT). + The result is placed in RESULT. RESULT can be the same as IN. + The value returned in the end of the string written to RESULT, + or NULL on error. */ + +static U_CHAR* +convert_string ( + cpp_reader *pfile, + register U_CHAR *result, U_CHAR *in,U_CHAR *limit, + int handle_escapes) +{ + U_CHAR c; + c = *in++; + if (c != '\"') + return NULL; + while (in < limit) + { + U_CHAR c = *in++; + switch (c) + { + case '\0': + return NULL; + case '\"': + limit = in; + break; + case '\\': + if (handle_escapes) + { + char *bpc = (char *) in; + int i = (U_CHAR) cpp_parse_escape (pfile, &bpc); + in = (U_CHAR *) bpc; + if (i >= 0) + *result++ = (U_CHAR)c; + break; + } + /* else fall through */ + default: + *result++ = c; + } + } + *result = 0; + return result; +} + +/* + * interpret #line command. Remembers previously seen fnames + * in its very own hash table. + */ +#define FNAME_HASHSIZE 37 + +static int +do_line ( + cpp_reader *pfile, + struct directive *keyword) +{ + cpp_buffer *ip = CPP_BUFFER (pfile); + int new_lineno; + long old_written = CPP_WRITTEN (pfile); + enum file_change_code file_change = same_file; + enum cpp_token token; + int i; + + token = get_directive_token (pfile); + + if (token != CPP_NUMBER + || !isdigit(pfile->token_buffer[old_written])) + { + cpp_error (pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + + /* The Newline at the end of this line remains to be processed. + To put the next line at the specified line number, + we must store a line number now that is one less. */ + new_lineno = atoi (pfile->token_buffer + old_written) - 1; + CPP_SET_WRITTEN (pfile, old_written); + + /* NEW_LINENO is one less than the actual line number here. */ + if (CPP_PEDANTIC (pfile) && new_lineno < 0) + cpp_pedwarn (pfile, "line number out of range in `#line' command"); + +#if 0 /* #line 10"foo.c" is supposed to be allowed. */ + if (PEEKC() && !is_space[PEEKC()]) { + cpp_error (pfile, "invalid format `#line' command"); + goto bad_line_directive; + } +#endif + + token = get_directive_token (pfile); + + if (token == CPP_STRING) { + U_CHAR *fname = pfile->token_buffer + old_written; + U_CHAR *end_name; + static HASHNODE *fname_table[FNAME_HASHSIZE]; + HASHNODE *hp, **hash_bucket; + U_CHAR *p; + long num_start; + int fname_length; + + /* Turn the file name, which is a character string literal, + into a null-terminated string. Do this in place. */ + end_name = convert_string (pfile, fname, fname, CPP_PWRITTEN (pfile), 1); + if (end_name == NULL) + { + cpp_error (pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + + fname_length = end_name - fname; + + num_start = CPP_WRITTEN (pfile); + token = get_directive_token (pfile); + if (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP) { + p = pfile->token_buffer + num_start; + if (CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "garbage at end of `#line' command"); + + if (token != CPP_NUMBER || *p < '0' || *p > '4' || p[1] != '\0') + { + cpp_error (pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + if (*p == '1') + file_change = enter_file; + else if (*p == 2) + file_change = leave_file; + else if (*p == 3) + ip->system_header_p = 1; + else /* if (*p == 4) */ + ip->system_header_p = 2; + + CPP_SET_WRITTEN (pfile, num_start); + token = get_directive_token (pfile); + p = pfile->token_buffer + num_start; + if (token == CPP_NUMBER && p[1] == '\0' && (*p == '3' || *p== '4')) { + ip->system_header_p = *p == 3 ? 1 : 2; + token = get_directive_token (pfile); + } + if (token != CPP_VSPACE) { + cpp_error (pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + } + + hash_bucket = + &fname_table[hashf (fname, fname_length, FNAME_HASHSIZE)]; + for (hp = *hash_bucket; hp != NULL; hp = hp->next) + if (hp->length == fname_length && + strncmp (hp->value.cpval, fname, fname_length) == 0) { + ip->nominal_fname = hp->value.cpval; + break; + } + if (hp == 0) { + /* Didn't find it; cons up a new one. */ + hp = (HASHNODE *) xcalloc (1, sizeof (HASHNODE) + fname_length + 1); + hp->next = *hash_bucket; + *hash_bucket = hp; + + hp->length = fname_length; + ip->nominal_fname = hp->value.cpval = ((char *) hp) + sizeof (HASHNODE); + bcopy (fname, hp->value.cpval, fname_length); + } + } + else if (token != CPP_VSPACE && token != CPP_EOF) { + cpp_error (pfile, "invalid format `#line' command"); + goto bad_line_directive; + } + + ip->lineno = new_lineno; + bad_line_directive: + skip_rest_of_line (pfile); + CPP_SET_WRITTEN (pfile, old_written); + output_line_command (pfile, 0, file_change); + return 0; +} + +/* + * remove the definition of a symbol from the symbol table. + * according to un*x /lib/cpp, it is not an error to undef + * something that has no definitions, so it isn't one here either. + */ + +static int +do_undef ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf, U_CHAR *limit) +{ + int sym_length; + HASHNODE *hp; + U_CHAR *orig_buf = buf; + +#if 0 + /* If this is a precompiler run (with -pcp) pass thru #undef commands. */ + if (pcp_outfile && keyword) + pass_thru_directive (buf, limit, pfile, keyword); +#endif + + SKIP_WHITE_SPACE (buf); + sym_length = check_macro_name (pfile, buf, "macro"); + + while ((hp = cpp_lookup (pfile, buf, sym_length, -1)) != NULL) + { + /* If we are generating additional info for debugging (with -g) we + need to pass through all effective #undef commands. */ + if (CPP_OPTIONS (pfile)->debug_output && keyword) + pass_thru_directive (orig_buf, limit, pfile, keyword); + if (hp->type != T_MACRO) + cpp_warning (pfile, "undefining `%s'", hp->name); + delete_macro (hp); + } + + if (CPP_PEDANTIC (pfile)) { + buf += sym_length; + SKIP_WHITE_SPACE (buf); + if (buf != limit) + cpp_pedwarn (pfile, "garbage after `#undef' directive"); + } + return 0; +} + +/* + * Report an error detected by the program we are processing. + * Use the text of the line in the error message. + * (We use error because it prints the filename & line#.) + */ + +static int +do_error ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf,U_CHAR *limit) +{ + int length = limit - buf; + U_CHAR *copy = (U_CHAR *) xmalloc (length + 1); + bcopy (buf, copy, length); + copy[length] = 0; + SKIP_WHITE_SPACE (copy); + cpp_error (pfile, "#error %s", copy); + return 0; +} + +/* + * Report a warning detected by the program we are processing. + * Use the text of the line in the warning message, then continue. + * (We use error because it prints the filename & line#.) + */ + +static int +do_warning ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf,U_CHAR *limit) +{ + int length = limit - buf; + U_CHAR *copy = (U_CHAR *) xmalloc (length + 1); + bcopy (buf, copy, length); + copy[length] = 0; + SKIP_WHITE_SPACE (copy); + cpp_warning (pfile, "#warning %s", copy); + return 0; +} + +/* Remember the name of the current file being read from so that we can + avoid ever including it again. */ + +static int +do_once ( + cpp_reader *pfile) +{ + cpp_buffer *ip = NULL; + struct file_name_list *new; + + for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip)) + { + if (ip == NULL) + return 0; + if (ip->fname != NULL) + break; + } + + + new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + new->next = pfile->dont_repeat_files; + pfile->dont_repeat_files = new; + new->fname = savestring (ip->fname); + new->control_macro = 0; + new->got_name_map = 0; + new->c_system_include_path = 0; + + return 0; +} + +/* #ident has already been copied to the output file, so just ignore it. */ + +static int +do_ident ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf, U_CHAR *limit) +{ +/* long old_written = CPP_WRITTEN (pfile);*/ + int len; + + /* Allow #ident in system headers, since that's not user's fault. */ + if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p) + cpp_pedwarn (pfile, "ANSI C does not allow `#ident'"); + + /* Leave rest of line to be read by later calls to cpp_get_token. */ + + return 0; +} + +/* #pragma and its argument line have already been copied to the output file. + Just check for some recognized pragmas that need validation here. */ + +static int +do_pragma ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf,U_CHAR *limit) +{ + while (*buf == ' ' || *buf == '\t') + buf++; + if (!strncmp (buf, "once", 4)) { + /* Allow #pragma once in system headers, since that's not the user's + fault. */ + if (!CPP_BUFFER (pfile)->system_header_p) + cpp_warning (pfile, "`#pragma once' is obsolete"); + do_once (pfile); + } + + if (!strncmp (buf, "implementation", 14)) { + /* Be quiet about `#pragma implementation' for a file only if it hasn't + been included yet. */ + struct file_name_list *ptr; + U_CHAR *p = buf + 14, *fname, *inc_fname; + int fname_len; + SKIP_WHITE_SPACE (p); + if (*p == '\n' || *p != '\"') + return 0; + + fname = p + 1; + p = (U_CHAR *) index (fname, '\"'); + fname_len = p != NULL ? p - fname : strlen (fname); + + for (ptr = pfile->all_include_files; ptr; ptr = ptr->next) { + inc_fname = (U_CHAR *) rindex (ptr->fname, '/'); + inc_fname = inc_fname ? inc_fname + 1 : (U_CHAR *) ptr->fname; + if (inc_fname && !strncmp (inc_fname, fname, fname_len)) + cpp_warning (pfile, + "`#pragma implementation' for `%s' appears after file is included", + fname); + } + } + + return 0; +} + +#if 0 +/* This was a fun hack, but #pragma seems to start to be useful. + By failing to recognize it, we pass it through unchanged to cc1. */ + +/* + * the behavior of the #pragma directive is implementation defined. + * this implementation defines it as follows. + */ + +static int +do_pragma () +{ + close (0); + if (open ("/dev/tty", O_RDONLY, 0666) != 0) + goto nope; + close (1); + if (open ("/dev/tty", O_WRONLY, 0666) != 1) + goto nope; + execl ("/usr/games/hack", "#pragma", 0); + execl ("/usr/games/rogue", "#pragma", 0); + execl ("/usr/new/emacs", "-f", "hanoi", "9", "-kill", 0); + execl ("/usr/local/emacs", "-f", "hanoi", "9", "-kill", 0); +nope: + fatal ("You are in a maze of twisty compiler features, all different"); +} +#endif + +/* Just ignore #sccs, on systems where we define it at all. */ + +static int +do_sccs ( + cpp_reader *pfile , + struct directive *keyword, + U_CHAR *buf,U_CHAR *limit) +{ + if (CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "ANSI C does not allow `#sccs'"); + return 0; +} + +/* + * handle #if command by + * 1) inserting special `defined' keyword into the hash table + * that gets turned into 0 or 1 by special_symbol (thus, + * if the luser has a symbol called `defined' already, it won't + * work inside the #if command) + * 2) rescan the input into a temporary output buffer + * 3) pass the output buffer to the yacc parser and collect a value + * 4) clean up the mess left from steps 1 and 2. + * 5) call conditional_skip to skip til the next #endif (etc.), + * or not, depending on the value from step 3. + */ + +static int +do_if ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf,U_CHAR *limit) +{ + HOST_WIDE_INT value = eval_if_expression (pfile, buf, limit - buf); + conditional_skip (pfile, value == 0, T_IF, NULL_PTR); + return 0; +} + +/* + * handle a #elif directive by not changing if_stack either. + * see the comment above do_else. + */ + +static int +do_elif ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf,U_CHAR *limit) +{ + if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack) { + cpp_error (pfile, "`#elif' not within a conditional"); + return 0; + } else { + if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF) { + cpp_error (pfile, "`#elif' after `#else'"); +#if 0 + fprintf (stderr, " (matches line %d", pfile->if_stack->lineno); +#endif + if (pfile->if_stack->fname != NULL && CPP_BUFFER (pfile)->fname != NULL + && strcmp (pfile->if_stack->fname, + CPP_BUFFER (pfile)->nominal_fname) != 0) + fprintf (stderr, ", file %s", pfile->if_stack->fname); + fprintf (stderr, ")\n"); + } + pfile->if_stack->type = T_ELIF; + } + + if (pfile->if_stack->if_succeeded) + skip_if_group (pfile, 0); + else { + HOST_WIDE_INT value = eval_if_expression (pfile, buf, limit - buf); + if (value == 0) + skip_if_group (pfile, 0); + else { + ++pfile->if_stack->if_succeeded; /* continue processing input */ + output_line_command (pfile, 1, same_file); + } + } + return 0; +} + +/* + * evaluate a #if expression in BUF, of length LENGTH, + * then parse the result as a C expression and return the value as an int. + */ +static HOST_WIDE_INT +eval_if_expression ( + cpp_reader *pfile, + U_CHAR *buf, + int length) +{ + HASHNODE *save_defined; + HOST_WIDE_INT value; + long old_written = CPP_WRITTEN (pfile); + + save_defined = install ("defined", -1, T_SPEC_DEFINED, 0, 0, -1); + pfile->pcp_inside_if = 1; + + value = cpp_parse_expr (pfile); + pfile->pcp_inside_if = 0; + delete_macro (save_defined); /* clean up special symbol */ + + CPP_SET_WRITTEN (pfile, old_written); /* Pop */ + + return value; +} + +/* + * routine to handle ifdef/ifndef. Try to look up the symbol, + * then do or don't skip to the #endif/#else/#elif depending + * on what directive is actually being processed. + */ + +static int +do_xifdef ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *unused1, U_CHAR *unused2) +{ + int skip; + cpp_buffer *ip = CPP_BUFFER (pfile); + U_CHAR* ident; + int ident_length; + enum cpp_token token; + int start_of_file = 0; + U_CHAR *control_macro = 0; + int old_written = CPP_WRITTEN (pfile); + + /* Detect a #ifndef at start of file (not counting comments). */ + if (ip->fname != 0 && keyword->type == T_IFNDEF) + start_of_file = pfile->only_seen_white == 2; + + pfile->no_macro_expand++; + token = get_directive_token (pfile); + pfile->no_macro_expand--; + + ident = pfile->token_buffer + old_written; + ident_length = CPP_WRITTEN (pfile) - old_written; + CPP_SET_WRITTEN (pfile, old_written); /* Pop */ + + if (token == CPP_VSPACE || token == CPP_POP || token == CPP_EOF) + { + skip = (keyword->type == T_IFDEF); + if (! CPP_TRADITIONAL (pfile)) + cpp_pedwarn (pfile, "`#%s' with no argument", keyword->name); + } + else if (token == CPP_NAME) + { + HASHNODE *hp = cpp_lookup (pfile, ident, ident_length, -1); + skip = (hp == NULL) ^ (keyword->type == T_IFNDEF); + if (start_of_file && !skip) + { + control_macro = (U_CHAR *) xmalloc (ident_length + 1); + bcopy (ident, control_macro, ident_length + 1); + } + } + else + { + skip = (keyword->type == T_IFDEF); + if (! CPP_TRADITIONAL (pfile)) + cpp_error (pfile, "`#%s' with invalid argument", keyword->name); + } + + if (!CPP_TRADITIONAL (pfile)) + { int c; + cpp_skip_hspace (pfile); + c = PEEKC (); + if (c != EOF && c != '\n') + cpp_pedwarn (pfile, "garbage at end of `#%s' argument", keyword->name); + } + skip_rest_of_line (pfile); + +#if 0 + if (pcp_outfile) { + /* Output a precondition for this macro. */ + if (hp && hp->value.defn->predefined) + fprintf (pcp_outfile, "#define %s\n", hp->name); + else { + U_CHAR *cp = buf; + fprintf (pcp_outfile, "#undef "); + while (is_idchar[*cp]) /* Ick! */ + fputc (*cp++, pcp_outfile); + putc ('\n', pcp_outfile); + } +#endif + + conditional_skip (pfile, skip, T_IF, control_macro); + return 0; +} + +/* Push TYPE on stack; then, if SKIP is nonzero, skip ahead. + If this is a #ifndef starting at the beginning of a file, + CONTROL_MACRO is the macro name tested by the #ifndef. + Otherwise, CONTROL_MACRO is 0. */ + +static void +conditional_skip ( + cpp_reader *pfile, + int skip, + enum node_type type, + U_CHAR *control_macro) +{ + IF_STACK_FRAME *temp; + + temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); + temp->fname = CPP_BUFFER (pfile)->nominal_fname; +#if 0 + temp->lineno = CPP_BUFFER (pfile)->lineno; +#endif + temp->next = pfile->if_stack; + temp->control_macro = control_macro; + pfile->if_stack = temp; + + pfile->if_stack->type = type; + + if (skip != 0) { + skip_if_group (pfile, 0); + return; + } else { + ++pfile->if_stack->if_succeeded; + output_line_command (pfile, 1, same_file); + } +} + +/* + * skip to #endif, #else, or #elif. adjust line numbers, etc. + * leaves input ptr at the sharp sign found. + * If ANY is nonzero, return at next directive of any sort. + */ +static void +skip_if_group ( + cpp_reader *pfile, + int any) +{ + int c; + int at_beg_of_line = 1; + struct directive *kt; + IF_STACK_FRAME *save_if_stack = pfile->if_stack; /* don't pop past here */ +#if 0 + U_CHAR *beg_of_line = bp; +#endif + register int ident_length; + U_CHAR *ident, *after_ident; + struct parse_marker line_start_mark; + + parse_set_mark (&line_start_mark, pfile); + + if (CPP_OPTIONS (pfile)->output_conditionals) { + static char failed[] = "#failed\n"; + CPP_PUTS (pfile, failed, sizeof(failed)-1); + pfile->lineno++; + output_line_command (pfile, 1, same_file); + } + + beg_of_line: + if (CPP_OPTIONS (pfile)->output_conditionals) + { + cpp_buffer *pbuf = CPP_BUFFER (pfile); + U_CHAR *start_line = pbuf->buf + line_start_mark.position; + CPP_PUTS (pfile, start_line, pbuf->cur - start_line); + } + parse_move_mark (&line_start_mark, pfile); + if (!CPP_TRADITIONAL (pfile)) + cpp_skip_hspace (pfile); + c = GETC(); + if (c == '#') + { + int old_written = CPP_WRITTEN (pfile); + cpp_skip_hspace (pfile); + + parse_name (pfile, GETC()); + ident_length = CPP_WRITTEN (pfile) - old_written; + ident = pfile->token_buffer + old_written; + pfile->limit = ident; +#if 0 + if (ident_length == 0) + goto not_a_directive; + + /* Handle # followed by a line number. */ + + /* Avoid error for `###' and similar cases unless -pedantic. */ +#endif + + for (kt = directive_table; kt->length >= 0; kt++) + { + IF_STACK_FRAME *temp; + if (ident_length == kt->length + && strncmp (ident, kt->name, kt->length) == 0) + { + /* If we are asked to return on next directive, do so now. */ + if (any) + goto done; + + switch (kt->type) + { + case T_IF: + case T_IFDEF: + case T_IFNDEF: + temp + = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); + temp->next = pfile->if_stack; + pfile->if_stack = temp; +#if 0 + temp->lineno = CPP_BUFFER(pfile)->lineno; +#endif + temp->fname = CPP_BUFFER(pfile)->nominal_fname; + temp->type = kt->type; + break; + case T_ELSE: + case T_ENDIF: + if (CPP_PEDANTIC (pfile) && pfile->if_stack != save_if_stack) + validate_else (pfile, + kt->type == T_ELSE ? "#else" : "#endif"); + case T_ELIF: + if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack) + { + cpp_error (pfile, + "`#%s' not within a conditional", kt->name); + break; + } + else if (pfile->if_stack == save_if_stack) + goto done; /* found what we came for */ + + if (kt->type != T_ENDIF) + { + if (pfile->if_stack->type == T_ELSE) + cpp_error (pfile, "`#else' or `#elif' after `#else'"); + pfile->if_stack->type = kt->type; + break; + } + + temp = pfile->if_stack; + pfile->if_stack = temp->next; + free (temp); + break; + default: ; + } + break; + } + /* Don't let erroneous code go by. */ + if (kt->length < 0 && !CPP_OPTIONS (pfile)->lang_asm + && CPP_PEDANTIC (pfile)) + cpp_pedwarn (pfile, "invalid preprocessor directive name"); + } + c = GETC (); + } + /* We're in the middle of a line. Skip the rest of it. */ + for (;;) { + switch (c) + { + long old; + case EOF: + goto done; + case '/': /* possible comment */ + c = skip_comment (pfile, NULL); + if (c == EOF) + goto done; + break; + case '\"': + case '\'': + FORWARD(-1); + old = CPP_WRITTEN (pfile); + cpp_get_token (pfile); + CPP_SET_WRITTEN (pfile, old); + break; + case '\\': + /* Char after backslash loses its special meaning. */ + if (PEEKC() == '\n') + FORWARD (1); + break; + case '\n': + goto beg_of_line; + break; + } + c = GETC (); + } + done: + if (CPP_OPTIONS (pfile)->output_conditionals) { + static char end_failed[] = "#endfailed\n"; + CPP_PUTS (pfile, end_failed, sizeof(end_failed)-1); + pfile->lineno++; + } + pfile->only_seen_white = 1; + parse_goto_mark (&line_start_mark, pfile); + parse_clear_mark (&line_start_mark); +} + +/* + * handle a #else directive. Do this by just continuing processing + * without changing if_stack ; this is so that the error message + * for missing #endif's etc. will point to the original #if. It + * is possible that something different would be better. + */ + +static int +do_else ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf, U_CHAR *limit) +{ + cpp_buffer *ip = CPP_BUFFER (pfile); + + if (CPP_PEDANTIC (pfile)) + validate_else (pfile, "#else"); + skip_rest_of_line (pfile); + + if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack) { + cpp_error (pfile, "`#else' not within a conditional"); + return 0; + } else { + /* #ifndef can't have its special treatment for containing the whole file + if it has a #else clause. */ + pfile->if_stack->control_macro = 0; + + if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF) { + cpp_error (pfile, "`#else' after `#else'"); + fprintf (stderr, " (matches line %d", pfile->if_stack->lineno); + if (strcmp (pfile->if_stack->fname, ip->nominal_fname) != 0) + fprintf (stderr, ", file %s", pfile->if_stack->fname); + fprintf (stderr, ")\n"); + } + pfile->if_stack->type = T_ELSE; + } + + if (pfile->if_stack->if_succeeded) + skip_if_group (pfile, 0); + else { + ++pfile->if_stack->if_succeeded; /* continue processing input */ + output_line_command (pfile, 1, same_file); + } + return 0; +} + +/* + * unstack after #endif command + */ + +static int +do_endif ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf, U_CHAR *limit) +{ + if (CPP_PEDANTIC (pfile)) + validate_else (pfile, "#endif"); + skip_rest_of_line (pfile); + + if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack) + cpp_error (pfile, "unbalanced `#endif'"); + else + { + IF_STACK_FRAME *temp = pfile->if_stack; + pfile->if_stack = temp->next; + if (temp->control_macro != 0) + { + /* This #endif matched a #ifndef at the start of the file. + See if it is at the end of the file. */ + struct parse_marker start_mark; + int c; + + parse_set_mark (&start_mark, pfile); + + for (;;) + { + cpp_skip_hspace (pfile); + c = GETC (); + if (c != '\n') + break; + } + parse_goto_mark (&start_mark, pfile); + parse_clear_mark (&start_mark); + + if (c == EOF) + { + /* If we get here, this #endif ends a #ifndef + that contains all of the file (aside from whitespace). + Arrange not to include the file again + if the macro that was tested is defined. + + Do not do this for the top-level file in a -include or any + file in a -imacros. */ +#if 0 +FIXME! + if (indepth != 0 + && ! (indepth == 1 && pfile->no_record_file) + && ! (pfile->no_record_file && no_output)) +#endif + { + struct file_name_list *ifile = pfile->all_include_files; + + for ( ; ifile != NULL; ifile = ifile->next) + { + if (!strcmp (ifile->fname, CPP_BUFFER (pfile)->fname)) + { + ifile->control_macro = temp->control_macro; + break; + } + } + } + } + } + free (temp); + output_line_command (pfile, 1, same_file); + } + return 0; +} + +/* When an #else or #endif is found while skipping failed conditional, + if -pedantic was specified, this is called to warn about text after + the command name. P points to the first char after the command name. */ + +static void +validate_else ( + cpp_reader *pfile, + char *directive) +{ + int c; + cpp_skip_hspace (pfile); + c = PEEKC (); + if (c != EOF && c != '\n') + cpp_pedwarn (pfile, + "text following `%s' violates ANSI standard", directive); +} + +/* Get the next token, and add it to the text in pfile->token_buffer. + Return the kind of token we got. */ + + +enum cpp_token +cpp_get_token ( + cpp_reader *pfile) +{ + register int c, c2, c3; + long old_written; + long start_line, start_column; + enum cpp_token token; + struct cpp_options *opts = CPP_OPTIONS (pfile); + CPP_BUFFER (pfile)->prev = CPP_BUFFER (pfile)->cur; + get_next: + c = GETC(); + if (c == EOF) + { + handle_eof: + if (CPP_BUFFER (pfile)->seen_eof) + { + if (cpp_pop_buffer (pfile) != CPP_NULL_BUFFER (pfile)) + goto get_next; + else + return CPP_EOF; + } + else + { + cpp_buffer *next_buf + = CPP_PREV_BUFFER (CPP_BUFFER (pfile)); + CPP_BUFFER (pfile)->seen_eof = 1; + if (CPP_BUFFER (pfile)->nominal_fname && next_buf != 0) + { + /* We're about to return from an #include file. + Emit #line information now (as part of the CPP_POP) result. + But the #line refers to the file we will pop to. */ + cpp_buffer *cur_buffer = CPP_BUFFER (pfile); + CPP_BUFFER (pfile) = next_buf; + pfile->input_stack_listing_current = 0; + output_line_command (pfile, 0, leave_file); + CPP_BUFFER (pfile) = cur_buffer; + } + return CPP_POP; + } + } + else + { + switch (c) + { + long newlines; + struct parse_marker start_mark; + case '/': + if (PEEKC () == '=') + goto op2; + if (opts->put_out_comments) + parse_set_mark (&start_mark, pfile); + newlines = 0; + cpp_buf_line_and_col (cpp_file_buffer (pfile), + &start_line, &start_column); + c = skip_comment (pfile, &newlines); + if (opts->put_out_comments && (c == '/' || c == EOF)) + parse_clear_mark (&start_mark); + if (c == '/') + goto randomchar; + if (c == EOF) + { + cpp_error_with_line (pfile, start_line, start_column, + "unterminated comment"); + goto handle_eof; + } + c = '/'; /* Initial letter of comment. */ + return_comment: + /* Comments are equivalent to spaces. + For -traditional, a comment is equivalent to nothing. */ + if (opts->put_out_comments) + { + cpp_buffer *pbuf = CPP_BUFFER (pfile); + long dummy; + U_CHAR *start = pbuf->buf + start_mark.position; + int len = pbuf->cur - start; + CPP_RESERVE(pfile, 1 + len); + CPP_PUTC_Q (pfile, c); + CPP_PUTS_Q (pfile, start, len); + pfile->lineno += newlines; + parse_clear_mark (&start_mark); + return CPP_COMMENT; + } + else if (CPP_TRADITIONAL (pfile)) + { + return CPP_COMMENT; + } + else + { +#if 0 + /* This may not work if cpp_get_token is called recursively, + since many places look for horizontal space. */ + if (newlines) + { + /* Copy the newlines into the output buffer, in order to + avoid the pain of a #line every time a multiline comment + is seen. */ + CPP_RESERVE(pfile, newlines); + while (--newlines >= 0) + { + CPP_PUTC_Q (pfile, '\n'); + pfile->lineno++; + } + return CPP_VSPACE; + } +#endif + CPP_RESERVE(pfile, 1); + CPP_PUTC_Q (pfile, ' '); + return CPP_HSPACE; + } +#if 0 + if (opts->for_lint) { + U_CHAR *argbp; + int cmdlen, arglen; + char *lintcmd = get_lintcmd (ibp, limit, &argbp, &arglen, &cmdlen); + + if (lintcmd != NULL) { + /* I believe it is always safe to emit this newline: */ + obp[-1] = '\n'; + bcopy ("#pragma lint ", (char *) obp, 13); + obp += 13; + bcopy (lintcmd, (char *) obp, cmdlen); + obp += cmdlen; + + if (arglen != 0) { + *(obp++) = ' '; + bcopy (argbp, (char *) obp, arglen); + obp += arglen; + } + + /* OK, now bring us back to the state we were in before we entered + this branch. We need #line b/c the newline for the pragma + could fuck things up. */ + output_line_command (pfile, 0, same_file); + *(obp++) = ' '; /* just in case, if comments are copied thru */ + *(obp++) = '/'; + } + } +#endif + + case '#': +#if 0 + /* If this is expanding a macro definition, don't recognize + preprocessor directives. */ + if (ip->macro != 0) + goto randomchar; + /* If this is expand_into_temp_buffer, recognize them + only after an actual newline at this level, + not at the beginning of the input level. */ + if (ip->fname == 0 && beg_of_line == ip->buf) + goto randomchar; + if (ident_length) + goto specialchar; +#endif + + if (!pfile->only_seen_white) + goto randomchar; + if (handle_directive (pfile)) + return CPP_DIRECTIVE; + pfile->only_seen_white = 0; + return CPP_OTHER; + + case '\"': + case '\'': + /* A single quoted string is treated like a double -- some + programs (e.g., troff) are perverse this way */ + cpp_buf_line_and_col (cpp_file_buffer (pfile), + &start_line, &start_column); + old_written = CPP_WRITTEN (pfile); + string: + CPP_PUTC (pfile, c); + while (1) + { + int cc = GETC(); + if (cc == EOF) + { + if (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile))) + { + /* try harder: this string crosses a macro expansion + boundary. This can happen naturally if -traditional. + Otherwise, only -D can make a macro with an unmatched + quote. */ + cpp_buffer *next_buf + = CPP_PREV_BUFFER (CPP_BUFFER (pfile)); + (*CPP_BUFFER (pfile)->cleanup) + (CPP_BUFFER (pfile), pfile); + CPP_BUFFER (pfile) = next_buf; + continue; + } + if (!CPP_TRADITIONAL (pfile)) + { + cpp_error_with_line (pfile, start_line, start_column, + "unterminated string or character constant"); + if (pfile->multiline_string_line != start_line + && pfile->multiline_string_line != 0) + cpp_error_with_line (pfile, + pfile->multiline_string_line, -1, + "possible real start of unterminated constant"); + pfile->multiline_string_line = 0; + } + break; + } + CPP_PUTC (pfile, cc); + switch (cc) + { + case '\n': + /* Traditionally, end of line ends a string constant with + no error. So exit the loop and record the new line. */ + if (CPP_TRADITIONAL (pfile)) + goto while2end; + if (c == '\'') + { + cpp_error_with_line (pfile, start_line, start_column, + "unterminated character constant"); + goto while2end; + } + if (CPP_PEDANTIC (pfile) + && pfile->multiline_string_line == 0) + { + cpp_pedwarn_with_line (pfile, start_line, start_column, + "string constant runs past end of line"); + } + if (pfile->multiline_string_line == 0) + pfile->multiline_string_line = start_line; + break; + + case '\\': + cc = GETC(); + if (cc == '\n') + { + /* Backslash newline is replaced by nothing at all. */ + CPP_ADJUST_WRITTEN (pfile, -1); + pfile->lineno++; + } + else + { + /* ANSI stupidly requires that in \\ the second \ + is *not* prevented from combining with a newline. */ + NEWLINE_FIX1(cc); + if (cc != EOF) + CPP_PUTC (pfile, cc); + } + break; + + case '\"': + case '\'': + if (cc == c) + goto while2end; + break; + } + } + while2end: + pfile->lineno += count_newlines (pfile->token_buffer + old_written, + CPP_PWRITTEN (pfile)); + pfile->only_seen_white = 0; + return c == '\'' ? CPP_CHAR : CPP_STRING; + + case '$': + if (!opts->dollars_in_ident) + goto randomchar; + goto letter; + + case ':': + if (opts->cplusplus && PEEKC () == ':') + goto op2; + goto randomchar; + + case '&': + case '+': + case '|': + NEWLINE_FIX; + c2 = PEEKC (); + if (c2 == c || c2 == '=') + goto op2; + goto randomchar; + + case '*': + case '!': + case '%': + case '=': + case '^': + NEWLINE_FIX; + if (PEEKC () == '=') + goto op2; + goto randomchar; + + case '-': + NEWLINE_FIX; + c2 = PEEKC (); + if (c2 == '-' && opts->chill) + { + /* Chill style comment */ + if (opts->put_out_comments) + parse_set_mark (&start_mark, pfile); + FORWARD(1); /* Skip second '-'. */ + for (;;) + { + c = GETC (); + if (c == EOF) + break; + if (c == '\n') + { + /* Don't consider final '\n' to be part of comment. */ + FORWARD(-1); + break; + } + } + c = '-'; + goto return_comment; + } + if (c2 == '-' || c2 == '=' || c2 == '>') + goto op2; + goto randomchar; + + case '<': + if (pfile->parsing_include_directive) + { + for (;;) + { + CPP_PUTC (pfile, c); + if (c == '>') + break; + c = GETC (); + NEWLINE_FIX1 (c); + if (c == '\n' || c == EOF) + { + cpp_error (pfile, + "missing '>' in `#include '"); + break; + } + } + return CPP_STRING; + } + /* else fall through */ + case '>': + NEWLINE_FIX; + c2 = PEEKC (); + if (c2 == '=') + goto op2; + if (c2 != c) + goto randomchar; + FORWARD(1); + CPP_RESERVE (pfile, 4); + CPP_PUTC (pfile, c); + CPP_PUTC (pfile, c2); + NEWLINE_FIX; + c3 = PEEKC (); + if (c3 == '=') + CPP_PUTC_Q (pfile, GETC ()); + CPP_NUL_TERMINATE_Q (pfile); + pfile->only_seen_white = 0; + return CPP_OTHER; + + case '@': + if (CPP_BUFFER (pfile)->has_escapes) + { + c = GETC (); + if (c == '-') + { + if (pfile->output_escapes) + CPP_PUTS (pfile, "@-", 2); + parse_name (pfile, GETC ()); + return CPP_NAME; + } + else if (is_space [c]) + { + CPP_RESERVE (pfile, 2); + if (pfile->output_escapes) + CPP_PUTC_Q (pfile, '@'); + CPP_PUTC_Q (pfile, c); + return CPP_HSPACE; + } + } + if (pfile->output_escapes) + { + CPP_PUTS (pfile, "@@", 2); + return CPP_OTHER; + } + goto randomchar; + + case '.': + NEWLINE_FIX; + c2 = PEEKC (); + if (isdigit(c2)) + { + CPP_RESERVE(pfile, 2); + CPP_PUTC_Q (pfile, '.'); + c = GETC (); + goto number; + } + /* FIXME - misses the case "..\\\n." */ + if (c2 == '.' && PEEKN(1) == '.') + { + CPP_RESERVE(pfile, 4); + CPP_PUTC_Q (pfile, '.'); + CPP_PUTC_Q (pfile, '.'); + CPP_PUTC_Q (pfile, '.'); + FORWARD (2); + CPP_NUL_TERMINATE_Q (pfile); + pfile->only_seen_white = 0; + return CPP_3DOTS; + } + goto randomchar; + + op2: + token = CPP_OTHER; + pfile->only_seen_white = 0; + op2any: + CPP_RESERVE(pfile, 3); + CPP_PUTC_Q (pfile, c); + CPP_PUTC_Q (pfile, GETC ()); + CPP_NUL_TERMINATE_Q (pfile); + return token; + + case 'L': + NEWLINE_FIX; + c2 = PEEKC (); + if ((c2 == '\'' || c2 == '\"') && !CPP_TRADITIONAL (pfile)) + { + CPP_PUTC (pfile, c); + c = GETC (); + goto string; + } + goto letter; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + number: + c2 = '.'; + for (;;) + { + CPP_RESERVE (pfile, 2); + CPP_PUTC_Q (pfile, c); + NEWLINE_FIX; + c = PEEKC (); + if (c == EOF) + break; + if (!is_idchar[c] && c != '.' + && ((c2 != 'e' && c2 != 'E') || (c != '+' && c != '-'))) + break; + FORWARD(1); + c2= c; + } + CPP_NUL_TERMINATE_Q (pfile); + pfile->only_seen_white = 0; + return CPP_NUMBER; + case 'b': case 'c': case 'd': case 'h': case 'o': + case 'B': case 'C': case 'D': case 'H': case 'O': + if (opts->chill && PEEKC () == '\'') + { + pfile->only_seen_white = 0; + CPP_RESERVE (pfile, 2); + CPP_PUTC_Q (pfile, c); + CPP_PUTC_Q (pfile, '\''); + FORWARD(1); + for (;;) + { + c = GETC(); + if (c == EOF) + goto chill_number_eof; + if (!is_idchar[c]) + { + if (c == '\\' && PEEKC() == '\n') + { + FORWARD(2); + continue; + } + break; + } + CPP_PUTC (pfile, c); + } + if (c == '\'') + { + CPP_RESERVE (pfile, 2); + CPP_PUTC_Q (pfile, c); + CPP_NUL_TERMINATE_Q (pfile); + return CPP_STRING; + } + else + { + FORWARD(-1); + chill_number_eof: + CPP_NUL_TERMINATE (pfile); + return CPP_NUMBER; + } + } + else + goto letter; + case '_': + case 'a': case 'e': case 'f': case 'g': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'p': case 'q': + case 'r': case 's': case 't': case 'u': case 'v': case 'w': + case 'x': case 'y': case 'z': + case 'A': case 'E': case 'F': case 'G': case 'I': case 'J': + case 'K': case 'M': case 'N': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': + letter: + { + HASHNODE *hp; + unsigned char *ident; + int before_name_written = CPP_WRITTEN (pfile); + int ident_len; + parse_name (pfile, c); + pfile->only_seen_white = 0; + if (pfile->no_macro_expand) + return CPP_NAME; + ident = pfile->token_buffer + before_name_written; + ident_len = CPP_PWRITTEN (pfile) - ident; + hp = cpp_lookup (pfile, ident, ident_len, -1); + if (!hp) + return CPP_NAME; + if (hp->type == T_DISABLED) + { + if (pfile->output_escapes) + { /* Return "@-IDENT", followed by '\0'. */ + int i; + CPP_RESERVE (pfile, 3); + ident = pfile->token_buffer + before_name_written; + CPP_ADJUST_WRITTEN (pfile, 2); + for (i = ident_len; i >= 0; i--) ident[i+2] = ident[i]; + ident[0] = '@'; + ident[1] = '-'; + } + return CPP_NAME; + } + + /* If macro wants an arglist, verify that a '(' follows. + first skip all whitespace, copying it to the output + after the macro name. Then, if there is no '(', + decide this is not a macro call and leave things that way. */ + if (hp->type == T_MACRO && hp->value.defn->nargs >= 0) + { + struct parse_marker macro_mark; + int is_macro_call; + while (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile))) + { + cpp_buffer *next_buf; + cpp_skip_hspace (pfile); + if (PEEKC () != EOF) + break; + next_buf = CPP_PREV_BUFFER (CPP_BUFFER (pfile)); + (*CPP_BUFFER (pfile)->cleanup) (CPP_BUFFER (pfile), pfile); + CPP_BUFFER (pfile) = next_buf; + } + parse_set_mark (¯o_mark, pfile); + for (;;) + { + cpp_skip_hspace (pfile); + c = PEEKC (); + is_macro_call = c == '('; + if (c != '\n') + break; + FORWARD (1); + } + if (!is_macro_call) + parse_goto_mark (¯o_mark, pfile); + parse_clear_mark (¯o_mark); + if (!is_macro_call) + return CPP_NAME; + } + /* This is now known to be a macro call. */ + + /* it might not actually be a macro. */ + if (hp->type != T_MACRO) { + int xbuf_len; U_CHAR *xbuf; + CPP_SET_WRITTEN (pfile, before_name_written); + special_symbol (hp, pfile); + xbuf_len = CPP_WRITTEN (pfile) - before_name_written; + xbuf = (U_CHAR *) xmalloc (xbuf_len + 1); + CPP_SET_WRITTEN (pfile, before_name_written); + bcopy (CPP_PWRITTEN (pfile), xbuf, xbuf_len + 1); + push_macro_expansion (pfile, xbuf, xbuf_len, hp); + } + else + { + /* Expand the macro, reading arguments as needed, + and push the expansion on the input stack. */ + macroexpand (pfile, hp); + CPP_SET_WRITTEN (pfile, before_name_written); + } + + /* An extra "@ " is added to the end of a macro expansion + to prevent accidental token pasting. We prefer to avoid + unneeded extra spaces (for the sake of cpp-using tools like + imake). Here we remove the space if it is safe to do so. */ + if (pfile->buffer->rlimit - pfile->buffer->cur >= 3 + && pfile->buffer->rlimit[-2] == '@' + && pfile->buffer->rlimit[-1] == ' ') + { + int c1 = pfile->buffer->rlimit[-3]; + int c2 = CPP_BUF_PEEK (CPP_PREV_BUFFER (CPP_BUFFER (pfile))); + if (c2 == EOF || ! unsafe_chars (c1, c2)) + pfile->buffer->rlimit -= 2; + } + } + goto get_next; + + case ' ': case '\t': case '\v': case '\r': + for (;;) + { + CPP_PUTC (pfile, c); + c = PEEKC (); + if (c == EOF || !is_hor_space[c]) + break; + FORWARD(1); + } + return CPP_HSPACE; + + case '\\': + c2 = PEEKC (); + if (c2 != '\n') + goto randomchar; + token = CPP_HSPACE; + goto op2any; + + case '\n': + CPP_PUTC (pfile, c); + if (pfile->only_seen_white == 0) + pfile->only_seen_white = 1; + pfile->lineno++; + output_line_command (pfile, 1, same_file); + return CPP_VSPACE; + + case '(': token = CPP_LPAREN; goto char1; + case ')': token = CPP_RPAREN; goto char1; + case '{': token = CPP_LBRACE; goto char1; + case '}': token = CPP_RBRACE; goto char1; + case ',': token = CPP_COMMA; goto char1; + case ';': token = CPP_SEMICOLON; goto char1; + + randomchar: + default: + token = CPP_OTHER; + char1: + pfile->only_seen_white = 0; + CPP_PUTC (pfile, c); + return token; + } + } +} + +/* Like cpp_get_token, but skip spaces and comments. */ +enum cpp_token +cpp_get_non_space_token ( + cpp_reader *pfile) +{ + int old_written = CPP_WRITTEN (pfile); + for (;;) + { + enum cpp_token token = cpp_get_token (pfile); + if (token != CPP_COMMENT && token != CPP_POP + && token != CPP_HSPACE && token != CPP_VSPACE) + return token; + CPP_SET_WRITTEN (pfile, old_written); + } +} + +/* Parse an identifier starting with C. */ + +int +parse_name ( + cpp_reader *pfile, int c) +{ + for (;;) + { + if (! is_idchar[c]) + { + if (c == '\\' && PEEKC() == '\n') + { + FORWARD(2); + continue; + } + FORWARD (-1); + break; + } + + CPP_RESERVE(pfile, 2); /* One more for final NUL. */ + CPP_PUTC_Q (pfile, c); + c = GETC(); + if (c == EOF) + break; + } + CPP_NUL_TERMINATE_Q (pfile); + return 1; +} + + +/* Maintain and search list of included files, for #import. */ + +/* Hash a file name for import_hash_table. */ + +static int +import_hash ( + char *f) +{ + int val = 0; + + while (*f) val += *f++; + return (val%IMPORT_HASH_SIZE); +} + +/* Search for file FILENAME in import_hash_table. + Return -2 if found, either a matching name or a matching inode. + Otherwise, open the file and return a file descriptor if successful + or -1 if unsuccessful. */ + +static int +lookup_import ( + cpp_reader *pfile, + char *filename, + struct file_name_list *searchptr) +{ + struct import_file *i; + int h; + int hashval; + struct stat sb; + int fd; + + hashval = import_hash (filename); + + /* Attempt to find file in list of already included files */ + i = pfile->import_hash_table[hashval]; + + while (i) { + if (!strcmp (filename, i->name)) + return -2; /* return found */ + i = i->next; + } + /* Open it and try a match on inode/dev */ + fd = open_include_file (pfile, filename, searchptr); + if (fd < 0) + return fd; + fstat (fd, &sb); + for (h = 0; h < IMPORT_HASH_SIZE; h++) { + i = pfile->import_hash_table[h]; + while (i) { + /* Compare the inode and the device. + Supposedly on some systems the inode is not a scalar. */ + if (!bcmp ((char *) &i->inode, (char *) &sb.st_ino, sizeof (sb.st_ino)) + && i->dev == sb.st_dev) { + close (fd); + return -2; /* return found */ + } + i = i->next; + } + } + return fd; /* Not found, return open file */ +} + +/* Add the file FNAME, open on descriptor FD, to import_hash_table. */ + +static void +add_import ( + cpp_reader *pfile, + int fd, + char *fname) +{ + struct import_file *i; + int hashval; + struct stat sb; + + hashval = import_hash (fname); + fstat (fd, &sb); + i = (struct import_file *)xmalloc (sizeof (struct import_file)); + i->name = (char *)xmalloc (strlen (fname)+1); + strcpy (i->name, fname); + bcopy ((char *) &sb.st_ino, (char *) &i->inode, sizeof (sb.st_ino)); + i->dev = sb.st_dev; + i->next = pfile->import_hash_table[hashval]; + pfile->import_hash_table[hashval] = i; +} + +/* The file_name_map structure holds a mapping of file names for a + particular directory. This mapping is read from the file named + FILE_NAME_MAP_FILE in that directory. Such a file can be used to + map filenames on a file system with severe filename restrictions, + such as DOS. The format of the file name map file is just a series + of lines with two tokens on each line. The first token is the name + to map, and the second token is the actual name to use. */ + +struct file_name_map +{ + struct file_name_map *map_next; + char *map_from; + char *map_to; +}; + +#define FILE_NAME_MAP_FILE "header.gcc" + +/* Read a space delimited string of unlimited length from a stdio + file. */ + +static char * +read_filename_string ( + int ch, + FILE *f) +{ + char *alloc, *set; + int len; + + len = 20; + set = alloc = xmalloc (len + 1); + if (! is_space[ch]) + { + *set++ = ch; + while ((ch = getc (f)) != EOF && ! is_space[ch]) + { + if (set - alloc == len) + { + len *= 2; + alloc = xrealloc (alloc, len + 1); + set = alloc + len / 2; + } + *set++ = ch; + } + } + *set = '\0'; + ungetc (ch, f); + return alloc; +} + +/* This structure holds a linked list of file name maps, one per directory. */ +struct file_name_map_list +{ + struct file_name_map_list *map_list_next; + char *map_list_name; + struct file_name_map *map_list_map; +}; + +/* Read the file name map file for DIRNAME. */ + +static struct file_name_map * +read_name_map ( + cpp_reader *pfile, + char *dirname) +{ + register struct file_name_map_list *map_list_ptr; + char *name; + FILE *f; + + for (map_list_ptr = CPP_OPTIONS (pfile)->map_list; map_list_ptr; + map_list_ptr = map_list_ptr->map_list_next) + if (! strcmp (map_list_ptr->map_list_name, dirname)) + return map_list_ptr->map_list_map; + + map_list_ptr = ((struct file_name_map_list *) + xmalloc (sizeof (struct file_name_map_list))); + map_list_ptr->map_list_name = savestring (dirname); + map_list_ptr->map_list_map = NULL; + + name = (char *) alloca (strlen (dirname) + strlen (FILE_NAME_MAP_FILE) + 2); + strcpy (name, dirname); + if (*dirname) + strcat (name, "/"); + strcat (name, FILE_NAME_MAP_FILE); + f = fopen (name, "r"); + if (!f) + map_list_ptr->map_list_map = NULL; + else + { + int ch; + int dirlen = strlen (dirname); + + while ((ch = getc (f)) != EOF) + { + char *from, *to; + struct file_name_map *ptr; + + if (is_space[ch]) + continue; + from = read_filename_string (ch, f); + while ((ch = getc (f)) != EOF && is_hor_space[ch]) + ; + to = read_filename_string (ch, f); + + ptr = ((struct file_name_map *) + xmalloc (sizeof (struct file_name_map))); + ptr->map_from = from; + + /* Make the real filename absolute. */ + if (*to == '/') + ptr->map_to = to; + else + { + ptr->map_to = xmalloc (dirlen + strlen (to) + 2); + strcpy (ptr->map_to, dirname); + ptr->map_to[dirlen] = '/'; + strcpy (ptr->map_to + dirlen + 1, to); + free (to); + } + + ptr->map_next = map_list_ptr->map_list_map; + map_list_ptr->map_list_map = ptr; + + while ((ch = getc (f)) != '\n') + if (ch == EOF) + break; + } + fclose (f); + } + + map_list_ptr->map_list_next = CPP_OPTIONS (pfile)->map_list; + CPP_OPTIONS (pfile)->map_list = map_list_ptr; + + return map_list_ptr->map_list_map; +} + +/* Try to open include file FILENAME. SEARCHPTR is the directory + being tried from the include file search path. This function maps + filenames on file systems based on information read by + read_name_map. */ + +static int +open_include_file ( + cpp_reader *pfile, + char *filename, + struct file_name_list *searchptr) +{ + register struct file_name_map *map; + register char *from; + char *p, *dir; + + if (searchptr && ! searchptr->got_name_map) + { + searchptr->name_map = read_name_map (pfile, + searchptr->fname + ? searchptr->fname : "."); + searchptr->got_name_map = 1; + } + + /* First check the mapping for the directory we are using. */ + if (searchptr && searchptr->name_map) + { + from = filename; + if (searchptr->fname) + from += strlen (searchptr->fname) + 1; + for (map = searchptr->name_map; map; map = map->map_next) + { + if (! strcmp (map->map_from, from)) + { + /* Found a match. */ + return open (map->map_to, O_RDONLY, 0666); + } + } + } + + /* Try to find a mapping file for the particular directory we are + looking in. Thus #include will look up sys/types.h + in /usr/include/header.gcc and look up types.h in + /usr/include/sys/header.gcc. */ + p = rindex (filename, '/'); + if (! p) + p = filename; + if (searchptr + && searchptr->fname + && strlen (searchptr->fname) == p - filename + && ! strncmp (searchptr->fname, filename, p - filename)) + { + /* FILENAME is in SEARCHPTR, which we've already checked. */ + return open (filename, O_RDONLY, 0666); + } + + if (p == filename) + { + dir = "."; + from = filename; + } + else + { + dir = (char *) alloca (p - filename + 1); + bcopy (filename, dir, p - filename); + dir[p - filename] = '\0'; + from = p + 1; + } + for (map = read_name_map (pfile, dir); map; map = map->map_next) + if (! strcmp (map->map_from, from)) + return open (map->map_to, O_RDONLY, 0666); + + return open (filename, O_RDONLY, 0666); +} + +/* Process the contents of include file FNAME, already open on descriptor F, + with output to OP. + SYSTEM_HEADER_P is 1 if this file resides in any one of the known + "system" include directories (as decided by the `is_system_include' + function above). + DIRPTR is the link in the dir path through which this file was found, + or 0 if the file name was absolute or via the current directory. + Return 1 on success, 0 on failure. + + The caller is responsible for the cpp_push_buffer. */ + +static int +finclude ( + cpp_reader *pfile, + int f, + char *fname, + int system_header_p, + struct file_name_list *dirptr) +{ + int st_mode; + long st_size; + long i; + int length; + cpp_buffer *fp; /* For input stack frame */ + int missing_newline = 0; + + if (file_size_and_mode (f, &st_mode, &st_size) < 0) + { + cpp_perror_with_name (pfile, fname); + close (f); + cpp_pop_buffer (pfile); + return 0; + } + + fp = CPP_BUFFER (pfile); + fp->nominal_fname = fp->fname = fname; +#if 0 + fp->length = 0; +#endif + fp->dir = dirptr; + fp->system_header_p = system_header_p; + fp->lineno = 1; + fp->colno = 1; + fp->cleanup = file_cleanup; + + if (S_ISREG (st_mode)) { + fp->buf = (U_CHAR *) xmalloc (st_size + 2); + fp->alimit = fp->buf + st_size + 2; + fp->cur = fp->buf; + + /* Read the file contents, knowing that st_size is an upper bound + on the number of bytes we can read. */ + length = safe_read (f, fp->buf, st_size); + fp->rlimit = fp->buf + length; + if (length < 0) goto nope; + } + else if (S_ISDIR (st_mode)) { + cpp_error (pfile, "directory `%s' specified in #include", fname); + close (f); + return 0; + } else { + /* Cannot count its file size before reading. + First read the entire file into heap and + copy them into buffer on stack. */ + + int bsize = 2000; + + st_size = 0; + fp->buf = (U_CHAR *) xmalloc (bsize + 2); + + for (;;) { + i = safe_read (f, fp->buf + st_size, bsize - st_size); + if (i < 0) + goto nope; /* error! */ + st_size += i; + if (st_size != bsize) + break; /* End of file */ + bsize *= 2; + fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2); + } + fp->cur = fp->buf; + length = st_size; + } + + if ((length > 0 && fp->buf[length - 1] != '\n') + /* Backslash-newline at end is not good enough. */ + || (length > 1 && fp->buf[length - 2] == '\\')) { + fp->buf[length++] = '\n'; +#if 0 + missing_newline = 1; +#endif + } + fp->buf[length] = '\0'; + fp->rlimit = fp->buf + length; + + /* Close descriptor now, so nesting does not use lots of descriptors. */ + close (f); + + /* Must do this before calling trigraph_pcp, so that the correct file name + will be printed in warning messages. */ + + pfile->input_stack_listing_current = 0; + +#if 0 + if (!no_trigraphs) + trigraph_pcp (fp); +#endif + +#if 0 + rescan (op, 0); + + if (missing_newline) + fp->lineno--; + + if (CPP_PEDANTIC (pfile) && missing_newline) + pedwarn ("file does not end in newline"); + + indepth--; + input_file_stack_tick++; + free (fp->buf); +#endif + return 1; + + nope: + + cpp_perror_with_name (pfile, fname); + close (f); + free (fp->buf); + return 1; +} + +int +push_parse_file ( + cpp_reader *pfile, + char *fname) +{ + struct cpp_options *opts = CPP_OPTIONS (pfile); + struct cpp_pending *pend; + char *p; + int f; + cpp_buffer *fp; + + /* The code looks at the defaults through this pointer, rather than through + the constant structure above. This pointer gets changed if an environment + variable specifies other defaults. */ + struct default_include *include_defaults = include_defaults_array; + + /* Add dirs from CPATH after dirs from -I. */ + /* There seems to be confusion about what CPATH should do, + so for the moment it is not documented. */ + /* Some people say that CPATH should replace the standard include dirs, + but that seems pointless: it comes before them, so it overrides them + anyway. */ + p = (char *) getenv ("CPATH"); + if (p != 0 && ! opts->no_standard_includes) + path_include (pfile, p); + + /* Now that dollars_in_ident is known, initialize is_idchar. */ + initialize_char_syntax (opts); + + /* Do partial setup of input buffer for the sake of generating + early #line directives (when -g is in effect). */ + fp = cpp_push_buffer (pfile, NULL, 0); + if (opts->in_fname == NULL) + opts->in_fname = ""; + fp->nominal_fname = fp->fname = opts->in_fname; + fp->lineno = 0; + + /* Install __LINE__, etc. Must follow initialize_char_syntax + and option processing. */ + initialize_builtins (pfile); + + /* Do standard #defines and assertions + that identify system and machine type. */ + + if (!opts->inhibit_predefs) { + char *p = (char *) alloca (strlen (predefs) + 1); + strcpy (p, predefs); + while (*p) { + char *q; + while (*p == ' ' || *p == '\t') + p++; + /* Handle -D options. */ + if (p[0] == '-' && p[1] == 'D') { + q = &p[2]; + while (*p && *p != ' ' && *p != '\t') + p++; + if (*p != 0) + *p++= 0; + if (opts->debug_output) + output_line_command (pfile, 0, same_file); + cpp_define (pfile, q); + while (*p == ' ' || *p == '\t') + p++; + } else if (p[0] == '-' && p[1] == 'A') { + /* Handle -A options (assertions). */ + char *assertion; + char *past_name; + char *value; + char *past_value; + char *termination; + int save_char; + + assertion = &p[2]; + past_name = assertion; + /* Locate end of name. */ + while (*past_name && *past_name != ' ' + && *past_name != '\t' && *past_name != '(') + past_name++; + /* Locate `(' at start of value. */ + value = past_name; + while (*value && (*value == ' ' || *value == '\t')) + value++; + if (*value++ != '(') + abort (); + while (*value && (*value == ' ' || *value == '\t')) + value++; + past_value = value; + /* Locate end of value. */ + while (*past_value && *past_value != ' ' + && *past_value != '\t' && *past_value != ')') + past_value++; + termination = past_value; + while (*termination && (*termination == ' ' || *termination == '\t')) + termination++; + if (*termination++ != ')') + abort (); + if (*termination && *termination != ' ' && *termination != '\t') + abort (); + /* Temporarily null-terminate the value. */ + save_char = *termination; + *termination = '\0'; + /* Install the assertion. */ + make_assertion (pfile, "-A", assertion); + *termination = (char) save_char; + p = termination; + while (*p == ' ' || *p == '\t') + p++; + } else { + abort (); + } + } + } + + /* Now handle the command line options. */ + + /* Do -U's, -D's and -A's in the order they were seen. */ + /* First reverse the list. */ + opts->pending = nreverse_pending (opts->pending); + + for (pend = opts->pending; pend; pend = pend->next) + { + if (pend->cmd != NULL && pend->cmd[0] == '-') + { + switch (pend->cmd[1]) + { + case 'U': + if (opts->debug_output) + output_line_command (pfile, 0, same_file); + do_undef (pfile, NULL, pend->arg, pend->arg + strlen (pend->arg)); + break; + case 'D': + if (opts->debug_output) + output_line_command (pfile, 0, same_file); + cpp_define (pfile, pend->arg); + break; + case 'A': + make_assertion (pfile, "-A", pend->arg); + break; + } + } + } + + opts->done_initializing = 1; + + { /* read the appropriate environment variable and if it exists + replace include_defaults with the listed path. */ + char *epath = 0; + switch ((opts->objc << 1) + opts->cplusplus) + { + case 0: + epath = getenv ("C_INCLUDE_PATH"); + break; + case 1: + epath = getenv ("CPLUS_INCLUDE_PATH"); + break; + case 2: + epath = getenv ("OBJC_INCLUDE_PATH"); + break; + case 3: + epath = getenv ("OBJCPLUS_INCLUDE_PATH"); + break; + } + /* If the environment var for this language is set, + add to the default list of include directories. */ + if (epath) { + char *nstore = (char *) alloca (strlen (epath) + 2); + int num_dirs; + char *startp, *endp; + + for (num_dirs = 1, startp = epath; *startp; startp++) + if (*startp == PATH_SEPARATOR) + num_dirs++; + include_defaults + = (struct default_include *) xmalloc ((num_dirs + * sizeof (struct default_include)) + + sizeof (include_defaults_array)); + startp = endp = epath; + num_dirs = 0; + while (1) { + /* Handle cases like c:/usr/lib:d:/gcc/lib */ + if ((*endp == PATH_SEPARATOR) + || *endp == 0) { + strncpy (nstore, startp, endp-startp); + if (endp == startp) + strcpy (nstore, "."); + else + nstore[endp-startp] = '\0'; + + include_defaults[num_dirs].fname = savestring (nstore); + include_defaults[num_dirs].cplusplus = opts->cplusplus; + include_defaults[num_dirs].cxx_aware = 1; + num_dirs++; + if (*endp == '\0') + break; + endp = startp = endp + 1; + } else + endp++; + } + /* Put the usual defaults back in at the end. */ + bcopy ((char *) include_defaults_array, + (char *) &include_defaults[num_dirs], + sizeof (include_defaults_array)); + } + } + + append_include_chain (pfile, opts->before_system, opts->last_before_system); + opts->first_system_include = opts->before_system; + + /* Unless -fnostdinc, + tack on the standard include file dirs to the specified list */ + if (!opts->no_standard_includes) { + struct default_include *p = include_defaults; + char *specd_prefix = opts->include_prefix; + char *default_prefix = savestring (GCC_INCLUDE_DIR); + int default_len = 0; + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp (default_prefix + strlen (default_prefix) - 8, "/include")) { + default_len = strlen (default_prefix) - 7; + default_prefix[default_len] = 0; + } + /* Search "translated" versions of GNU directories. + These have /usr/local/lib/gcc... replaced by specd_prefix. */ + if (specd_prefix != 0 && default_len != 0) + for (p = include_defaults; p->fname; p++) { + /* Some standard dirs are only for C++. */ + if (!p->cplusplus + || (opts->cplusplus && !opts->no_standard_cplusplus_includes)) { + /* Does this dir start with the prefix? */ + if (!strncmp (p->fname, default_prefix, default_len)) { + /* Yes; change prefix and add to search list. */ + struct file_name_list *new + = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + int this_len = strlen (specd_prefix) + strlen (p->fname) - default_len; + char *str = (char *) xmalloc (this_len + 1); + strcpy (str, specd_prefix); + strcat (str, p->fname + default_len); + new->fname = str; + new->control_macro = 0; + new->c_system_include_path = !p->cxx_aware; + new->got_name_map = 0; + append_include_chain (pfile, new, new); + if (opts->first_system_include == 0) + opts->first_system_include = new; + } + } + } + /* Search ordinary names for GNU include directories. */ + for (p = include_defaults; p->fname; p++) { + /* Some standard dirs are only for C++. */ + if (!p->cplusplus + || (opts->cplusplus && !opts->no_standard_cplusplus_includes)) { + struct file_name_list *new + = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); + new->control_macro = 0; + new->c_system_include_path = !p->cxx_aware; + new->fname = p->fname; + new->got_name_map = 0; + append_include_chain (pfile, new, new); + if (opts->first_system_include == 0) + opts->first_system_include = new; + } + } + } + + /* Tack the after_include chain at the end of the include chain. */ + append_include_chain (pfile, opts->after_include, opts->last_after_include); + if (opts->first_system_include == 0) + opts->first_system_include = opts->after_include; + + /* With -v, print the list of dirs to search. */ + if (opts->verbose) { + struct file_name_list *p; + fprintf (stderr, "#include \"...\" search starts here:\n"); + for (p = opts->include; p; p = p->next) { + if (p == opts->first_bracket_include) + fprintf (stderr, "#include <...> search starts here:\n"); + fprintf (stderr, " %s\n", p->fname); + } + fprintf (stderr, "End of search list.\n"); + } + + /* Scan the -imacros files before the main input. + Much like #including them, but with no_output set + so that only their macro definitions matter. */ + + opts->no_output++; pfile->no_record_file++; + for (pend = opts->pending; pend; pend = pend->next) + { + if (pend->cmd != NULL && strcmp (pend->cmd, "-imacros") == 0) + { + int fd = open (pend->arg, O_RDONLY, 0666); + if (fd < 0) + { + cpp_perror_with_name (pfile, pend->arg); + return FATAL_EXIT_CODE; + } + cpp_push_buffer (pfile, NULL, 0); + finclude (pfile, fd, pend->arg, 0, NULL_PTR); + cpp_scan_buffer (pfile); + } + } + opts->no_output--; pfile->no_record_file--; + + /* Copy the entire contents of the main input file into + the stacked input buffer previously allocated for it. */ + if (fname == NULL || *fname == 0) { + fname = ""; + f = 0; + } else if ((f = open (fname, O_RDONLY, 0666)) < 0) + cpp_pfatal_with_name (pfile, fname); + + /* -MG doesn't select the form of output and must be specified with one of + -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't + inhibit compilation. */ + if (opts->print_deps_missing_files + && (opts->print_deps == 0 || !opts->no_output)) + fatal (pfile, "-MG must be specified with one of -M or -MM"); + + /* Either of two environment variables can specify output of deps. + Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET", + where OUTPUT_FILE is the file to write deps info to + and DEPS_TARGET is the target to mention in the deps. */ + + if (opts->print_deps == 0 + && (getenv ("SUNPRO_DEPENDENCIES") != 0 + || getenv ("DEPENDENCIES_OUTPUT") != 0)) { + char *spec = getenv ("DEPENDENCIES_OUTPUT"); + char *s; + char *output_file; + + if (spec == 0) + { + spec = getenv ("SUNPRO_DEPENDENCIES"); + opts->print_deps = 2; + } + else + opts->print_deps = 1; + + s = spec; + /* Find the space before the DEPS_TARGET, if there is one. */ + /* This should use index. (mrs) */ + while (*s != 0 && *s != ' ') s++; + if (*s != 0) + { + opts->deps_target = s + 1; + output_file = (char *) xmalloc (s - spec + 1); + bcopy (spec, output_file, s - spec); + output_file[s - spec] = 0; + } + else + { + opts->deps_target = 0; + output_file = spec; + } + + opts->deps_file = output_file; + opts->print_deps_append = 1; + } + + /* For -M, print the expected object file name + as the target of this Make-rule. */ + if (opts->print_deps) + { + pfile->deps_allocated_size = 200; + pfile->deps_buffer = (char *) xmalloc (pfile->deps_allocated_size); + pfile->deps_buffer[0] = 0; + pfile->deps_size = 0; + pfile->deps_column = 0; + + if (opts->deps_target) + deps_output (pfile, opts->deps_target, ':'); + else if (*opts->in_fname == 0) + deps_output (pfile, "-", ':'); + else + { + char *p, *q; + int len; + + /* Discard all directory prefixes from filename. */ + if ((q = rindex (opts->in_fname, '/')) != NULL +#ifdef DIR_SEPARATOR + && (q = rindex (opts->in_fname, DIR_SEPARATOR)) != NULL +#endif + ) + ++q; + else + q = opts->in_fname; + + /* Copy remainder to mungable area. */ + p = (char *) alloca (strlen(q) + 8); + strcpy (p, q); + + /* Output P, but remove known suffixes. */ + len = strlen (p); + q = p + len; + if (len >= 2 + && p[len - 2] == '.' + && index("cCsSm", p[len - 1])) + q = p + (len - 2); + else if (len >= 3 + && p[len - 3] == '.' + && p[len - 2] == 'c' + && p[len - 1] == 'c') + q = p + (len - 3); + else if (len >= 4 + && p[len - 4] == '.' + && p[len - 3] == 'c' + && p[len - 2] == 'x' + && p[len - 1] == 'x') + q = p + (len - 4); + else if (len >= 4 + && p[len - 4] == '.' + && p[len - 3] == 'c' + && p[len - 2] == 'p' + && p[len - 1] == 'p') + q = p + (len - 4); + + /* Supply our own suffix. */ +#ifndef VMS +#ifdef _FORASXXXX_ + strcpy (q,".rel"); +#else + strcpy (q, ".o"); +#endif +#else + strcpy (q, ".obj"); +#endif + + deps_output (pfile, p, ':'); + deps_output (pfile, opts->in_fname, ' '); + } + } + +#if 0 + /* Make sure data ends with a newline. And put a null after it. */ + + if ((fp->length > 0 && fp->buf[fp->length - 1] != '\n') + /* Backslash-newline at end is not good enough. */ + || (fp->length > 1 && fp->buf[fp->length - 2] == '\\')) { + fp->buf[fp->length++] = '\n'; + missing_newline = 1; + } + fp->buf[fp->length] = '\0'; + + /* Unless inhibited, convert trigraphs in the input. */ + + if (!no_trigraphs) + trigraph_pcp (fp); +#endif + + /* Scan the -include files before the main input. + We push these in reverse order, so that the first one is handled first. */ + + pfile->no_record_file++; + opts->pending = nreverse_pending (opts->pending); + for (pend = opts->pending; pend; pend = pend->next) + { + if (pend->cmd != NULL && strcmp (pend->cmd, "-include") == 0) + { + int fd = open (pend->arg, O_RDONLY, 0666); + if (fd < 0) + { + cpp_perror_with_name (pfile, pend->arg); + return FATAL_EXIT_CODE; + } + cpp_push_buffer (pfile, NULL, 0); + finclude (pfile, fd, pend->arg, 0, NULL_PTR); + } + } + pfile->no_record_file--; + + /* Free the pending list. */ + for (pend = opts->pending; pend; ) + { + struct cpp_pending *next = pend->next; + free (pend); + pend = next; + } + opts->pending = NULL; + +#if 0 + /* Scan the input, processing macros and directives. */ + + rescan (&outbuf, 0); + + if (missing_newline) + fp->lineno--; + + if (CPP_PEDANTIC (pfile) && missing_newline) + pedwarn ("file does not end in newline"); + +#endif + if (finclude (pfile, f, fname, 0, NULL_PTR)) + output_line_command (pfile, 0, same_file); + return SUCCESS_EXIT_CODE; +} + +void +init_parse_file ( + cpp_reader *pfile) +{ + bzero ((char *) pfile, sizeof (cpp_reader)); + pfile->get_token = cpp_get_token; + + pfile->token_buffer_size = 200; + pfile->token_buffer = (U_CHAR*)xmalloc (pfile->token_buffer_size); + CPP_SET_WRITTEN (pfile, 0); + + pfile->system_include_depth = 0; + pfile->dont_repeat_files = 0; + pfile->all_include_files = 0; + pfile->max_include_len = 0; + pfile->timebuf = NULL; + pfile->only_seen_white = 1; + pfile->buffer = CPP_NULL_BUFFER(pfile); +} + +static struct cpp_pending * +nreverse_pending ( + struct cpp_pending *list) + +{ + register struct cpp_pending *prev = 0, *next, *pend; + for (pend = list; pend; pend = next) + { + next = pend->next; + pend->next = prev; + prev = pend; + } + return prev; +} + +static void +push_pending ( + cpp_reader *pfile, + char *cmd, + char *arg) +{ + struct cpp_pending *pend + = (struct cpp_pending*)xmalloc (sizeof (struct cpp_pending)); + pend->cmd = cmd; + pend->arg = arg; + pend->next = CPP_OPTIONS (pfile)->pending; + CPP_OPTIONS (pfile)->pending = pend; +} + +/* Handle command-line options in (argc, argv). + Can be called multiple times, to handle multiple sets of options. + Returns if an unrecognized option is seen. + Returns number of handled arguments. */ + +int +cpp_handle_options ( + cpp_reader *pfile, + int argc, + char **argv) +{ + int i; + struct cpp_options *opts = CPP_OPTIONS (pfile); + for (i = 0; i < argc; i++) { + if (argv[i][0] != '-') { + if (opts->out_fname != NULL) + fatal ("Usage: %s [switches] input output", argv[0]); + else if (opts->in_fname != NULL) + opts->out_fname = argv[i]; + else + opts->in_fname = argv[i]; + } else { + switch (argv[i][1]) { + + case 'i': + if (!strcmp (argv[i], "-include") + || !strcmp (argv[i], "-imacros")) { + if (i + 1 == argc) + fatal ("Filename missing after `%s' option", argv[i]); + else + push_pending (pfile, argv[i], argv[i+1]), i++; + } + if (!strcmp (argv[i], "-iprefix")) { + if (i + 1 == argc) + fatal ("Filename missing after `-iprefix' option"); + else + opts->include_prefix = argv[++i]; + } + if (!strcmp (argv[i], "-ifoutput")) { + opts->output_conditionals = 1; + } + if (!strcmp (argv[i], "-isystem")) { + struct file_name_list *dirtmp; + + if (i + 1 == argc) + fatal ("Filename missing after `-isystem' option"); + + dirtmp = (struct file_name_list *) + xmalloc (sizeof (struct file_name_list)); + dirtmp->next = 0; + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 1; + dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + 1); + strcpy (dirtmp->fname, argv[++i]); + dirtmp->got_name_map = 0; + + if (opts->before_system == 0) + opts->before_system = dirtmp; + else + opts->last_before_system->next = dirtmp; + opts->last_before_system = dirtmp; /* Tail follows the last one */ + } + /* Add directory to end of path for includes, + with the default prefix at the front of its name. */ + if (!strcmp (argv[i], "-iwithprefix")) { + struct file_name_list *dirtmp; + char *prefix; + + if (opts->include_prefix != 0) + prefix = opts->include_prefix; + else { + prefix = savestring (GCC_INCLUDE_DIR); + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp (prefix + strlen (prefix) - 8, "/include")) + prefix[strlen (prefix) - 7] = 0; + } + + dirtmp = (struct file_name_list *) + xmalloc (sizeof (struct file_name_list)); + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (i + 1 == argc) + fatal ("Directory name missing after `-iwithprefix' option"); + + dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + + strlen (prefix) + 1); + strcpy (dirtmp->fname, prefix); + strcat (dirtmp->fname, argv[++i]); + dirtmp->got_name_map = 0; + + if (opts->after_include == 0) + opts->after_include = dirtmp; + else + opts->last_after_include->next = dirtmp; + opts->last_after_include = dirtmp; /* Tail follows the last one */ + } + /* Add directory to main path for includes, + with the default prefix at the front of its name. */ + if (!strcmp (argv[i], "-iwithprefixbefore")) { + struct file_name_list *dirtmp; + char *prefix; + + if (opts->include_prefix != 0) + prefix = opts->include_prefix; + else { + prefix = savestring (GCC_INCLUDE_DIR); + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp (prefix + strlen (prefix) - 8, "/include")) + prefix[strlen (prefix) - 7] = 0; + } + + dirtmp = (struct file_name_list *) + xmalloc (sizeof (struct file_name_list)); + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (i + 1 == argc) + fatal ("Directory name missing after `-iwithprefixbefore' option"); + + dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + + strlen (prefix) + 1); + strcpy (dirtmp->fname, prefix); + strcat (dirtmp->fname, argv[++i]); + dirtmp->got_name_map = 0; + + append_include_chain (pfile, dirtmp, dirtmp); + } + /* Add directory to end of path for includes. */ + if (!strcmp (argv[i], "-idirafter")) { + struct file_name_list *dirtmp; + + dirtmp = (struct file_name_list *) + xmalloc (sizeof (struct file_name_list)); + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (i + 1 == argc) + fatal ("Directory name missing after `-idirafter' option"); + else + dirtmp->fname = argv[++i]; + dirtmp->got_name_map = 0; + + if (opts->after_include == 0) + opts->after_include = dirtmp; + else + opts->last_after_include->next = dirtmp; + opts->last_after_include = dirtmp; /* Tail follows the last one */ + } + break; + + case 'o': + if (opts->out_fname != NULL) + fatal ("Output filename specified twice"); + if (i + 1 == argc) + fatal ("Filename missing after -o option"); + opts->out_fname = argv[++i]; + if (!strcmp (opts->out_fname, "-")) + opts->out_fname = ""; + break; + + case 'p': + if (!strcmp (argv[i], "-pedantic")) + CPP_PEDANTIC (pfile) = 1; + else if (!strcmp (argv[i], "-pedantic-errors")) { + CPP_PEDANTIC (pfile) = 1; + opts->pedantic_errors = 1; + } +#if 0 + else if (!strcmp (argv[i], "-pcp")) { + char *pcp_fname = argv[++i]; + pcp_outfile = + ((pcp_fname[0] != '-' || pcp_fname[1] != '\0') + ? fopen (pcp_fname, "w") + : fdopen (dup (fileno (stdout)), "w")); + if (pcp_outfile == 0) + cpp_pfatal_with_name (pfile, pcp_fname); + no_precomp = 1; + } +#endif + break; + + case 't': + if (!strcmp (argv[i], "-traditional")) { + opts->traditional = 1; + if (opts->dollars_in_ident > 0) + opts->dollars_in_ident = 1; + } else if (!strcmp (argv[i], "-trigraphs")) { + if (!opts->chill) + opts->no_trigraphs = 0; + } + break; + + case 'l': + if (! strcmp (argv[i], "-lang-c")) + opts->cplusplus = 0, opts->cplusplus_comments = 0, opts->objc = 0; + if (! strcmp (argv[i], "-lang-c++")) + opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->objc = 0; + if (! strcmp (argv[i], "-lang-c-c++-comments")) + opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->objc = 0; + if (! strcmp (argv[i], "-lang-objc")) + opts->objc = 1, opts->cplusplus = 0, opts->cplusplus_comments = 1; + if (! strcmp (argv[i], "-lang-objc++")) + opts->objc = 1, opts->cplusplus = 1, opts->cplusplus_comments = 1; + if (! strcmp (argv[i], "-lang-asm")) + opts->lang_asm = 1; + if (! strcmp (argv[i], "-lint")) + opts->for_lint = 1; + if (! strcmp (argv[i], "-lang-chill")) + opts->objc = 0, opts->cplusplus = 0, opts->chill = 1, + opts->traditional = 1, opts->no_trigraphs = 1; + break; + + case '+': + opts->cplusplus = 1, opts->cplusplus_comments = 1; + break; + + case 'w': + opts->inhibit_warnings = 1; + break; + + case 'W': + if (!strcmp (argv[i], "-Wtrigraphs")) + opts->warn_trigraphs = 1; + else if (!strcmp (argv[i], "-Wno-trigraphs")) + opts->warn_trigraphs = 0; + else if (!strcmp (argv[i], "-Wcomment")) + opts->warn_comments = 1; + else if (!strcmp (argv[i], "-Wno-comment")) + opts->warn_comments = 0; + else if (!strcmp (argv[i], "-Wcomments")) + opts->warn_comments = 1; + else if (!strcmp (argv[i], "-Wno-comments")) + opts->warn_comments = 0; + else if (!strcmp (argv[i], "-Wtraditional")) + opts->warn_stringify = 1; + else if (!strcmp (argv[i], "-Wno-traditional")) + opts->warn_stringify = 0; + else if (!strcmp (argv[i], "-Wimport")) + opts->warn_import = 1; + else if (!strcmp (argv[i], "-Wno-import")) + opts->warn_import = 0; + else if (!strcmp (argv[i], "-Werror")) + opts->warnings_are_errors = 1; + else if (!strcmp (argv[i], "-Wno-error")) + opts->warnings_are_errors = 0; + else if (!strcmp (argv[i], "-Wall")) + { + opts->warn_trigraphs = 1; + opts->warn_comments = 1; + } + break; + + case 'M': + /* The style of the choices here is a bit mixed. + The chosen scheme is a hybrid of keeping all options in one string + and specifying each option in a separate argument: + -M|-MM|-MD file|-MMD file [-MG]. An alternative is: + -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely: + -M[M][G][D file]. This is awkward to handle in specs, and is not + as extensible. */ + /* ??? -MG must be specified in addition to one of -M or -MM. + This can be relaxed in the future without breaking anything. + The converse isn't true. */ + + /* -MG isn't valid with -MD or -MMD. This is checked for later. */ + if (!strcmp (argv[i], "-MG")) + { + opts->print_deps_missing_files = 1; + break; + } + if (!strcmp (argv[i], "-M")) + opts->print_deps = 2; + else if (!strcmp (argv[i], "-MM")) + opts->print_deps = 1; + else if (!strcmp (argv[i], "-MD")) + opts->print_deps = 2; + else if (!strcmp (argv[i], "-MMD")) + opts->print_deps = 1; + /* For -MD and -MMD options, write deps on file named by next arg. */ + if (!strcmp (argv[i], "-MD") || !strcmp (argv[i], "-MMD")) + { + if (i+1 == argc) + fatal ("Filename missing after %s option", argv[i]); + opts->deps_file = argv[++i]; + } + else + { + /* For -M and -MM, write deps on standard output + and suppress the usual output. */ + opts->no_output = 1; + } + break; + + case 'd': + { + char *p = argv[i] + 2; + char c; + while ((c = *p++) != 0) { + /* Arg to -d specifies what parts of macros to dump */ + switch (c) { + case 'M': + opts->dump_macros = dump_only; + opts->no_output = 1; + break; + case 'N': + opts->dump_macros = dump_names; + break; + case 'D': + opts->dump_macros = dump_definitions; + break; + } + } + } + break; + + case 'g': + if (argv[i][2] == '3') + opts->debug_output = 1; + break; + + case 'v': + fprintf (stderr, "GNU CPP version %s", version_string); +#ifdef TARGET_VERSION + TARGET_VERSION; +#endif + fprintf (stderr, "\n"); + // opts->verbose = 1; + break; + + case 'H': + opts->print_include_names = 1; + break; + + case 'D': + if (argv[i][2] != 0) + push_pending (pfile, "-D", argv[i] + 2); + else if (i + 1 == argc) + fatal ("Macro name missing after -D option"); + else + i++, push_pending (pfile, "-D", argv[i]); + break; + + case 'A': + { + char *p; + + if (argv[i][2] != 0) + p = argv[i] + 2; + else if (i + 1 == argc) + fatal ("Assertion missing after -A option"); + else + p = argv[++i]; + + if (!strcmp (p, "-")) { + struct cpp_pending **ptr; + /* -A- eliminates all predefined macros and assertions. + Let's include also any that were specified earlier + on the command line. That way we can get rid of any + that were passed automatically in from GCC. */ + int j; + opts->inhibit_predefs = 1; + for (ptr = &opts->pending; *ptr != NULL; ) + { + struct cpp_pending *pend = *ptr; + if (pend->cmd && pend->cmd[0] == '-' + && (pend->cmd[1] == 'D' || pend->cmd[1] == 'A')) + { + *ptr = pend->next; + free (pend); + } + else + ptr = &pend->next; + } + } else { + push_pending (pfile, "-A", p); + } + } + break; + + case 'U': /* JF #undef something */ + if (argv[i][2] != 0) + push_pending (pfile, "-U", argv[i] + 2); + else if (i + 1 == argc) + fatal ("Macro name missing after -U option"); + else + push_pending (pfile, "-U", argv[i+1]), i++; + break; + + case 'C': + opts->put_out_comments = 1; + break; + + case 'E': /* -E comes from cc -E; ignore it. */ + break; + + case 'P': + opts->no_line_commands = 1; + break; + + case '$': /* Don't include $ in identifiers. */ + opts->dollars_in_ident = 0; + break; + + case 'I': /* Add directory to path for includes. */ + { + struct file_name_list *dirtmp; + + if (! CPP_OPTIONS(pfile)->ignore_srcdir + && !strcmp (argv[i] + 2, "-")) { + CPP_OPTIONS (pfile)->ignore_srcdir = 1; + /* Don't use any preceding -I directories for #include <...>. */ + CPP_OPTIONS (pfile)->first_bracket_include = 0; + } + else { + dirtmp = (struct file_name_list *) + xmalloc (sizeof (struct file_name_list)); + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + dirtmp->c_system_include_path = 0; + if (argv[i][2] != 0) + dirtmp->fname = argv[i] + 2; + else if (i + 1 == argc) + fatal ("Directory name missing after -I option"); + else + dirtmp->fname = argv[++i]; + dirtmp->got_name_map = 0; + append_include_chain (pfile, dirtmp, dirtmp); + } + } + break; + + case 'n': + if (!strcmp (argv[i], "-nostdinc")) + /* -nostdinc causes no default include directories. + You must specify all include-file directories with -I. */ + opts->no_standard_includes = 1; + else if (!strcmp (argv[i], "-nostdinc++")) + /* -nostdinc++ causes no default C++-specific include directories. */ + opts->no_standard_cplusplus_includes = 1; +#if 0 + else if (!strcmp (argv[i], "-noprecomp")) + no_precomp = 1; +#endif + break; + + case 'u': + /* Sun compiler passes undocumented switch "-undef". + Let's assume it means to inhibit the predefined symbols. */ + opts->inhibit_predefs = 1; + break; + + case '\0': /* JF handle '-' as file name meaning stdin or stdout */ + if (opts->in_fname == NULL) { + opts->in_fname = ""; + break; + } else if (opts->out_fname == NULL) { + opts->out_fname = ""; + break; + } /* else fall through into error */ + + default: + return i; + } + } + } + return i; +} + +void +cpp_finish ( + cpp_reader *pfile) +{ + struct cpp_options *opts = CPP_OPTIONS (pfile); + + if (opts->print_deps) + { + /* Stream on which to print the dependency information. */ + FILE *deps_stream; + + /* Don't actually write the deps file if compilation has failed. */ + if (pfile->errors == 0) + { + char *deps_mode = opts->print_deps_append ? "a" : "w"; + if (opts->deps_file == 0) + deps_stream = stdout; + else if ((deps_stream = fopen (opts->deps_file, deps_mode)) == 0) + cpp_pfatal_with_name (pfile, opts->deps_file); + fputs (pfile->deps_buffer, deps_stream); + putc ('\n', deps_stream); + if (opts->deps_file) + { + if (ferror (deps_stream) || fclose (deps_stream) != 0) + fatal ("I/O error on output"); + } + } + } +} + +/* Free resources used by PFILE. */ + +void +cpp_cleanup ( + cpp_reader *pfile) +{ + int i; + while ( CPP_BUFFER (pfile) != CPP_NULL_BUFFER (pfile)) + cpp_pop_buffer (pfile); + + if (pfile->token_buffer) + { + free (pfile->token_buffer); + pfile->token_buffer = NULL; + } + + if (pfile->deps_buffer) + { + free (pfile->deps_buffer); + pfile->deps_buffer = NULL; + pfile->deps_allocated_size = 0; + } + + while (pfile->if_stack) + { + IF_STACK_FRAME *temp = pfile->if_stack; + pfile->if_stack = temp->next; + free (temp); + } + + while (pfile->dont_repeat_files) + { + struct file_name_list *temp = pfile->dont_repeat_files; + pfile->dont_repeat_files = temp->next; + free (temp->fname); + free (temp); + } + + while (pfile->all_include_files) + { + struct file_name_list *temp = pfile->all_include_files; + pfile->all_include_files = temp->next; + free (temp->fname); + free (temp); + } + + for (i = IMPORT_HASH_SIZE; --i >= 0; ) + { + register struct import_file *imp = pfile->import_hash_table[i]; + while (imp) + { + struct import_file *next = imp->next; + free (imp->name); + free (imp); + imp = next; + } + pfile->import_hash_table[i] = 0; + } + + for (i = ASSERTION_HASHSIZE; --i >= 0; ) + { + while (pfile->assertion_hashtab[i]) + delete_assertion (pfile->assertion_hashtab[i]); + } + + cpp_hash_cleanup (pfile); +} + +static int +do_assert ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf, U_CHAR *limit) +{ + long symstart; /* remember where symbol name starts */ + int c; + int sym_length; /* and how long it is */ + struct arglist *tokens = NULL; + + if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->done_initializing + && !CPP_BUFFER (pfile)->system_header_p) + cpp_pedwarn (pfile, "ANSI C does not allow `#assert'"); + + cpp_skip_hspace (pfile); + symstart = CPP_WRITTEN (pfile); /* remember where it starts */ + parse_name (pfile, GETC()); + sym_length = check_macro_name (pfile, pfile->token_buffer + symstart, + "assertion"); + + cpp_skip_hspace (pfile); + if (PEEKC() != '(') { + cpp_error (pfile, "missing token-sequence in `#assert'"); + goto error; + } + + { + int error_flag = 0; + tokens = read_token_list (pfile, &error_flag); + if (error_flag) + goto error; + if (tokens == 0) { + cpp_error (pfile, "empty token-sequence in `#assert'"); + goto error; + } + cpp_skip_hspace (pfile); + c = PEEKC (); + if (c != EOF && c != '\n') + cpp_pedwarn (pfile, "junk at end of `#assert'"); + skip_rest_of_line (pfile); + } + + /* If this name isn't already an assertion name, make it one. + Error if it was already in use in some other way. */ + + { + ASSERTION_HASHNODE *hp; + U_CHAR *symname = pfile->token_buffer + symstart; + int hashcode = hashf (symname, sym_length, ASSERTION_HASHSIZE); + struct tokenlist_list *value + = (struct tokenlist_list *) xmalloc (sizeof (struct tokenlist_list)); + + hp = assertion_lookup (pfile, symname, sym_length, hashcode); + if (hp == NULL) { + if (sym_length == 7 && ! strncmp (symname, "defined", sym_length)) + cpp_error (pfile, "`defined' redefined as assertion"); + hp = assertion_install (pfile, symname, sym_length, hashcode); + } + + /* Add the spec'd token-sequence to the list of such. */ + value->tokens = tokens; + value->next = hp->value; + hp->value = value; + } + CPP_SET_WRITTEN (pfile, symstart); /* Pop */ + return 0; + error: + CPP_SET_WRITTEN (pfile, symstart); /* Pop */ + skip_rest_of_line (pfile); + return 1; +} + +static int +do_unassert ( + cpp_reader *pfile, + struct directive *keyword, + U_CHAR *buf, U_CHAR *limit) +{ + long symstart; /* remember where symbol name starts */ + int sym_length; /* and how long it is */ + int c; + + struct arglist *tokens = NULL; + int tokens_specified = 0; + + if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->done_initializing + && !CPP_BUFFER (pfile)->system_header_p) + cpp_pedwarn (pfile, "ANSI C does not allow `#unassert'"); + + cpp_skip_hspace (pfile); + + symstart = CPP_WRITTEN (pfile); /* remember where it starts */ + parse_name (pfile, GETC()); + sym_length = check_macro_name (pfile, pfile->token_buffer + symstart, + "assertion"); + + cpp_skip_hspace (pfile); + if (PEEKC() == '(') { + int error_flag = 0; + + tokens = read_token_list (pfile, &error_flag); + if (error_flag) + goto error; + if (tokens == 0) { + cpp_error (pfile, "empty token list in `#unassert'"); + goto error; + } + + tokens_specified = 1; + } + + cpp_skip_hspace (pfile); + c = PEEKC (); + if (c != EOF && c != '\n') + cpp_error (pfile, "junk at end of `#unassert'"); + skip_rest_of_line (pfile); + + { + ASSERTION_HASHNODE *hp; + U_CHAR *symname = pfile->token_buffer + symstart; + int hashcode = hashf (symname, sym_length, ASSERTION_HASHSIZE); + struct tokenlist_list *tail, *prev; + + hp = assertion_lookup (pfile, symname, sym_length, hashcode); + if (hp == NULL) + return 1; + + /* If no token list was specified, then eliminate this assertion + entirely. */ + if (! tokens_specified) + delete_assertion (hp); + else { + /* If a list of tokens was given, then delete any matching list. */ + + tail = hp->value; + prev = 0; + while (tail) { + struct tokenlist_list *next = tail->next; + if (compare_token_lists (tail->tokens, tokens)) { + if (prev) + prev->next = next; + else + hp->value = tail->next; + free_token_list (tail->tokens); + free (tail); + } else { + prev = tail; + } + tail = next; + } + } + } + + CPP_SET_WRITTEN (pfile, symstart); /* Pop */ + return 0; + error: + CPP_SET_WRITTEN (pfile, symstart); /* Pop */ + skip_rest_of_line (pfile); + return 1; +} + +/* Test whether there is an assertion named NAME + and optionally whether it has an asserted token list TOKENS. + NAME is not null terminated; its length is SYM_LENGTH. + If TOKENS_SPECIFIED is 0, then don't check for any token list. */ + +int +check_assertion ( + cpp_reader *pfile, + U_CHAR *name, + int sym_length, + int tokens_specified, + struct arglist *tokens) +{ + ASSERTION_HASHNODE *hp; + int hashcode = hashf (name, sym_length, ASSERTION_HASHSIZE); + + if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p) + cpp_pedwarn (pfile, "ANSI C does not allow testing assertions"); + + hp = assertion_lookup (pfile, name, sym_length, hashcode); + if (hp == NULL) + /* It is not an assertion; just return false. */ + return 0; + + /* If no token list was specified, then value is 1. */ + if (! tokens_specified) + return 1; + + { + struct tokenlist_list *tail; + + tail = hp->value; + + /* If a list of tokens was given, + then succeed if the assertion records a matching list. */ + + while (tail) { + if (compare_token_lists (tail->tokens, tokens)) + return 1; + tail = tail->next; + } + + /* Fail if the assertion has no matching list. */ + return 0; + } +} + +/* Compare two lists of tokens for equality including order of tokens. */ + +static int +compare_token_lists ( + struct arglist *l1, struct arglist *l2 ) +{ + while (l1 && l2) { + if (l1->length != l2->length) + return 0; + if (strncmp (l1->name, l2->name, l1->length)) + return 0; + l1 = l1->next; + l2 = l2->next; + } + + /* Succeed if both lists end at the same time. */ + return l1 == l2; +} + +struct arglist * +reverse_token_list ( + struct arglist *tokens) +{ + register struct arglist *prev = 0, *this, *next; + for (this = tokens; this; this = next) + { + next = this->next; + this->next = prev; + prev = this; + } + return prev; +} + +/* Read a space-separated list of tokens ending in a close parenthesis. + Return a list of strings, in the order they were written. + (In case of error, return 0 and store -1 in *ERROR_FLAG.) */ + +static struct arglist * +read_token_list ( + cpp_reader *pfile, + int *error_flag) +{ + struct arglist *token_ptrs = 0; + int depth = 1; + int length; + + *error_flag = 0; + FORWARD (1); /* Skip '(' */ + + /* Loop over the assertion value tokens. */ + while (depth > 0) + { + struct arglist *temp; + long name_written = CPP_WRITTEN (pfile); + int eofp = 0; int c; + + cpp_skip_hspace (pfile); + + c = GETC (); + + /* Find the end of the token. */ + if (c == '(') + { + CPP_PUTC (pfile, c); + depth++; + } + else if (c == ')') + { + depth--; + if (depth == 0) + break; + CPP_PUTC (pfile, c); + } + else if (c == '"' || c == '\'') + { + FORWARD(-1); + cpp_get_token (pfile); + } + else if (c == '\n') + break; + else + { + while (c != EOF && ! is_space[c] && c != '(' && c != ')' + && c != '"' && c != '\'') + { + CPP_PUTC (pfile, c); + c = GETC(); + } + if (c != EOF) FORWARD(-1); + } + + length = CPP_WRITTEN (pfile) - name_written; + temp = (struct arglist *) + xmalloc (sizeof (struct arglist) + length + 1); + temp->name = (U_CHAR *) (temp + 1); + bcopy ((char *) (pfile->token_buffer + name_written), + (char *) temp->name, length); + temp->name[length] = 0; + temp->next = token_ptrs; + token_ptrs = temp; + temp->length = length; + + CPP_ADJUST_WRITTEN (pfile, -length); /* pop */ + + if (c == EOF || c == '\n') + { /* FIXME */ + cpp_error (pfile, + "unterminated token sequence following `#' operator"); + return 0; + } + } + + /* We accumulated the names in reverse order. + Now reverse them to get the proper order. */ + return reverse_token_list (token_ptrs); +} + +static void +free_token_list ( + struct arglist *tokens) +{ + while (tokens) { + struct arglist *next = tokens->next; + free (tokens->name); + free (tokens); + tokens = next; + } +} + +/* Get the file-mode and data size of the file open on FD + and store them in *MODE_POINTER and *SIZE_POINTER. */ + +static int +file_size_and_mode ( + int fd, + int *mode_pointer, + long int *size_pointer) +{ + struct stat sbuf; + + if (fstat (fd, &sbuf) < 0) return (-1); + if (mode_pointer) *mode_pointer = sbuf.st_mode; + if (size_pointer) *size_pointer = sbuf.st_size; + return 0; +} + +/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME, + retrying if necessary. Return a negative value if an error occurs, + otherwise return the actual number of bytes read, + which must be LEN unless end-of-file was reached. */ + +static int +safe_read ( + int desc, + char *ptr, + int len) +{ + int left = len; + while (left > 0) { + int nchars = read (desc, ptr, left); + if (nchars < 0) + { +#ifdef EINTR + if (errno == EINTR) + continue; +#endif + return nchars; + } + if (nchars == 0) + break; + ptr += nchars; + left -= nchars; + } + return len - left; +} + +static char * +savestring ( + char *input) +{ + unsigned size = strlen (input); + char *output = xmalloc (size + 1); + strcpy (output, input); + return output; +} + +/* Initialize PMARK to remember the current position of PFILE. */ +void +parse_set_mark ( + struct parse_marker *pmark, + cpp_reader *pfile) +{ + cpp_buffer *pbuf = CPP_BUFFER (pfile); + pmark->next = pbuf->marks; + pbuf->marks = pmark; + pmark->buf = pbuf; + pmark->position = pbuf->cur - pbuf->buf; +} + +/* Cleanup PMARK - we no longer need it. */ +void +parse_clear_mark ( + struct parse_marker *pmark) +{ + struct parse_marker **pp = &pmark->buf->marks; + for (; ; pp = &(*pp)->next) { + if (*pp == NULL) fatal ("internal error", "in parse_set_mark"); + if (*pp == pmark) break; + } + *pp = pmark->next; +} + +/* Backup the current position of PFILE to that saved in PMARK. */ + +void +parse_goto_mark ( + struct parse_marker *pmark, + cpp_reader *pfile) +{ + cpp_buffer *pbuf = CPP_BUFFER (pfile); + if (pbuf != pmark->buf) + fatal ("internal error %s", "parse_goto_mark"); + pbuf->cur = pbuf->buf + pmark->position; +} + +/* Reset PMARK to point to the current position of PFILE. (Same + as parse_clear_mark (PMARK), parse_set_mark (PMARK, PFILE) but faster. */ + +void +parse_move_mark ( + struct parse_marker *pmark, + cpp_reader *pfile) +{ + cpp_buffer *pbuf = CPP_BUFFER (pfile); + if (pbuf != pmark->buf) + fatal ("internal error %s", "parse_move_mark"); + pmark->position = pbuf->cur - pbuf->buf; +} + +int +cpp_read_check_assertion ( + cpp_reader *pfile) +{ + int name_start = CPP_WRITTEN (pfile); + int name_length, name_written; + int result; + FORWARD (1); /* Skip '#' */ + cpp_skip_hspace (pfile); + parse_name (pfile, GETC ()); + name_written = CPP_WRITTEN (pfile); + name_length = name_written - name_start; + cpp_skip_hspace (pfile); + if (CPP_BUF_PEEK (CPP_BUFFER (pfile)) == '(') + { + int error_flag; + struct arglist *token_ptrs = read_token_list (pfile, &error_flag); + result = check_assertion (pfile, + pfile->token_buffer + name_start, name_length, + 1, token_ptrs); + } + else + result = check_assertion (pfile, + pfile->token_buffer + name_start, name_length, + 0, NULL_PTR); + CPP_ADJUST_WRITTEN (pfile, - name_length); /* pop */ + return result; +} + +void +cpp_print_file_and_line (pfile) + cpp_reader *pfile; +{ + cpp_buffer *ip = cpp_file_buffer (pfile); + + if (ip != NULL) + { + long line, col; + cpp_buf_line_and_col (ip, &line, &col); + cpp_file_line_for_message (pfile, ip->nominal_fname, + line, pfile->show_column ? col : -1); + } +} + +void +cpp_error (pfile, msg, arg1, arg2, arg3) + cpp_reader *pfile; + char *msg; + char *arg1, *arg2, *arg3; +{ + cpp_print_containing_files (pfile); + cpp_print_file_and_line (pfile); + cpp_message (pfile, 1, msg, arg1, arg2, arg3); +} + +/* Print error message but don't count it. */ + +void +cpp_warning (pfile, msg, arg1, arg2, arg3) + cpp_reader *pfile; + char *msg; + char *arg1, *arg2, *arg3; +{ + if (CPP_OPTIONS (pfile)->inhibit_warnings) + return; + + if (CPP_OPTIONS (pfile)->warnings_are_errors) + pfile->errors++; + + cpp_print_containing_files (pfile); + cpp_print_file_and_line (pfile); + cpp_message (pfile, 0, msg, arg1, arg2, arg3); +} + +/* Print an error message and maybe count it. */ + +void +cpp_pedwarn (pfile, msg, arg1, arg2, arg3) + cpp_reader *pfile; + char *msg; + char *arg1, *arg2, *arg3; +{ + if (CPP_OPTIONS (pfile)->pedantic_errors) + cpp_error (pfile, msg, arg1, arg2, arg3); + else + cpp_warning (pfile, msg, arg1, arg2, arg3); +} + +void +cpp_error_with_line (pfile, line, column, msg, arg1, arg2, arg3) + cpp_reader *pfile; + int line, column; + char *msg; + char *arg1, *arg2, *arg3; +{ + int i; + cpp_buffer *ip = cpp_file_buffer (pfile); + + cpp_print_containing_files (pfile); + + if (ip != NULL) + cpp_file_line_for_message (pfile, ip->nominal_fname, line, column); + + cpp_message (pfile, 1, msg, arg1, arg2, arg3); +} + +static void +cpp_warning_with_line (pfile, line, column, msg, arg1, arg2, arg3) + cpp_reader *pfile; + int line, column; + char *msg; + char *arg1, *arg2, *arg3; +{ + int i; + cpp_buffer *ip; + + if (CPP_OPTIONS (pfile)->inhibit_warnings) + return; + + if (CPP_OPTIONS (pfile)->warnings_are_errors) + pfile->errors++; + + cpp_print_containing_files (pfile); + + ip = cpp_file_buffer (pfile); + + if (ip != NULL) + cpp_file_line_for_message (pfile, ip->nominal_fname, line, column); + + cpp_message (pfile, 0, msg, arg1, arg2, arg3); +} + +void +cpp_pedwarn_with_line (pfile, line, column, msg, arg1, arg2, arg3) + cpp_reader *pfile; + int line; + char *msg; + char *arg1, *arg2, *arg3; +{ + if (CPP_OPTIONS (pfile)->pedantic_errors) + cpp_error_with_line (pfile, column, line, msg, arg1, arg2, arg3); + else + cpp_warning_with_line (pfile, line, column, msg, arg1, arg2, arg3); +} + +/* Report a warning (or an error if pedantic_errors) + giving specified file name and line number, not current. */ + +void +cpp_pedwarn_with_file_and_line (pfile, file, line, msg, arg1, arg2, arg3) + cpp_reader *pfile; + char *file; + int line; + char *msg; + char *arg1, *arg2, *arg3; +{ + if (!CPP_OPTIONS (pfile)->pedantic_errors + && CPP_OPTIONS (pfile)->inhibit_warnings) + return; + if (file != NULL) + cpp_file_line_for_message (pfile, file, line, -1); + cpp_message (pfile, CPP_OPTIONS (pfile)->pedantic_errors, + msg, arg1, arg2, arg3); +} + +/* This defines "errno" properly for VMS, and gives us EACCES. */ +#include +#ifndef errno +extern int errno; +#endif + +#ifndef VMS +#ifndef HAVE_STRERROR +extern int sys_nerr; +#if defined(bsd4_4) +extern const char *const sys_errlist[]; +#else +#if !defined(linux) +extern char *sys_errlist[]; +#endif +#endif +#else /* HAVE_STRERROR */ +char *strerror (); +#endif +#else /* VMS */ +char *strerror (int,...); +#endif + +/* + * my_strerror - return the descriptive text associated with an `errno' code. + */ + +char * +my_strerror (errnum) + int errnum; +{ + char *result; + +#ifndef VMS +#ifndef HAVE_STRERROR + result = (char *) ((errnum < sys_nerr) ? sys_errlist[errnum] : 0); +#else + result = strerror (errnum); +#endif +#else /* VMS */ + /* VAXCRTL's strerror() takes an optional second argument, which only + matters when the first argument is EVMSERR. However, it's simplest + just to pass it unconditionally. `vaxc$errno' is declared in + , and maintained by the library in parallel with `errno'. + We assume that caller's `errnum' either matches the last setting of + `errno' by the library or else does not have the value `EVMSERR'. */ + + result = strerror (errnum, vaxc$errno); +#endif + + if (!result) + result = "undocumented I/O error"; + + return result; +} + +/* Error including a message from `errno'. */ + +void +cpp_error_from_errno ( + cpp_reader *pfile, + char *name) +{ + int i; + + + cpp_buffer *ip = cpp_file_buffer (pfile); + + cpp_print_containing_files (pfile); + + if (ip != NULL) + cpp_file_line_for_message (pfile, ip->nominal_fname, ip->lineno, -1); + + cpp_message (pfile, 1, "%s: %s", name, my_strerror (errno)); +} + +void +cpp_perror_with_name ( + cpp_reader *pfile, + char *name) +{ + cpp_message (pfile, 1, "%s: %s: %s", progname, name, my_strerror (errno)); +} + +/* TODO: + * No pre-compiled header file support. + * + * Possibly different enum token codes for each C/C++ token. + * + * Should clean up remaining directives to that do_XXX functions + * only take two arguments and all have command_reads_line. + * + * Find and cleanup remaining uses of static variables, + * + * Support for trigraphs. + * + * Support -dM flag (dump_all_macros). + * + * Support for_lint flag. + */ diff --git a/support/cpp/cpplib.h b/support/cpp/cpplib.h new file mode 100644 index 00000000..39c0ed7d --- /dev/null +++ b/support/cpp/cpplib.h @@ -0,0 +1,651 @@ +/* Definitions for CPP library. + Copyright (C) 1995 Free Software Foundation, Inc. + Written by Per Bothner, 1994-95. + +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, 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; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! */ + +#include +#include +#define EMACS +#ifdef __cplusplus +extern "C" { +#endif + +#define STATIC_BUFFERS + +typedef unsigned char U_CHAR; + +struct parse_file; +typedef struct cpp_reader cpp_reader; +typedef struct cpp_buffer cpp_buffer; +typedef struct cpp_options cpp_options; +typedef struct hashnode cpp_hashnode; + +enum cpp_token { + CPP_EOF = -1, + CPP_OTHER = 0, + CPP_COMMENT = 1, + CPP_HSPACE, + CPP_VSPACE, /* newlines and #line directives */ + CPP_NAME, + CPP_NUMBER, + CPP_CHAR, + CPP_STRING, + CPP_DIRECTIVE, + CPP_LPAREN, /* "(" */ + CPP_RPAREN, /* ")" */ + CPP_LBRACE, /* "{" */ + CPP_RBRACE, /* "}" */ + CPP_COMMA, /* "," */ + CPP_SEMICOLON,/* ";" */ + CPP_3DOTS, /* "..." */ +#if 0 + CPP_ANDAND, /* "&&" */ + CPP_OROR, /* "||" */ + CPP_LSH, /* "<<" */ + CPP_RSH, /* ">>" */ + CPP_EQL, /* "==" */ + CPP_NEQ, /* "!=" */ + CPP_LEQ, /* "<=" */ + CPP_GEQ, /* ">=" */ + CPP_PLPL, /* "++" */ + CPP_MINMIN, /* "--" */ +#endif + /* POP_TOKEN is returned when we've popped a cpp_buffer. */ + CPP_POP +}; + +#ifndef PARAMS +#ifdef __STDC +#define PARAMS(P) P +#else +#define PARAMS(P) () +#endif +#endif /* !PARAMS */ + +typedef enum cpp_token (*parse_underflow_t) PARAMS((cpp_reader*)); +typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader*)); + +/* A parse_marker indicates a previous position, + which we can backtrack to. */ + +struct parse_marker { + cpp_buffer *buf; + struct parse_marker *next; + int position; +}; + +extern void parse_set_mark PARAMS ((struct parse_marker*, cpp_reader*)); +extern void parse_clear_mark PARAMS ((struct parse_marker*)); +extern void parse_goto_mark PARAMS((struct parse_marker*, cpp_reader*)); +extern void parse_move_mark PARAMS((struct parse_marker*, cpp_reader*)); + +extern int cpp_handle_options PARAMS ((cpp_reader*, int, char**)); +extern enum cpp_token cpp_get_token PARAMS ((struct parse_marker*)); +extern void cpp_skip_hspace PARAMS((cpp_reader*)); +extern enum cpp_token cpp_get_non_space_token PARAMS ((cpp_reader *)); + + +/* Maintain and search list of included files, for #import. */ + +#define IMPORT_HASH_SIZE 31 + +struct import_file { + char *name; + ino_t inode; + dev_t dev; + struct import_file *next; +}; + +/* If we have a huge buffer, may need to cache more recent counts */ +#define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base) + +struct cpp_buffer { + unsigned char *buf; + unsigned char *cur; + unsigned char *rlimit; /* end of valid data */ + unsigned char *alimit; /* end of allocated buffer */ + unsigned char *prev; /* start of current token */ + + char *fname; + /* Filename specified with #line command. */ + char *nominal_fname; + + /* Record where in the search path this file was found. + For #include_next. */ + struct file_name_list *dir; + + long line_base; + long lineno; /* Line number at CPP_LINE_BASE. */ + long colno; /* Column number at CPP_LINE_BASE. */ +#ifndef STATIC_BUFFERS + cpp_buffer *chain; +#endif + parse_underflow_t underflow; + parse_cleanup_t cleanup; + void *data; + struct parse_marker *marks; + /* Value of if_stack at start of this file. + Used to prohibit unmatched #endif (etc) in an include file. */ + struct if_stack *if_stack; + + /* True if this is a header file included using . */ + char system_header_p; + char seen_eof; + + /* True if buffer contains escape sequences. + Currently there are are only two kind: + "@-" means following identifier should not be macro-expanded. + "@ " means a token-separator. This turns into " " in final output + if not stringizing and needed to separate tokens; otherwise nothing. + "@@" means a normal '@'. + (An '@' inside a string stands for itself and is never an escape.) */ + char has_escapes; +}; + +struct cpp_pending; /* Forward declaration - for C++. */ +struct file_name_map_list; + +typedef struct assertion_hashnode ASSERTION_HASHNODE; +#define ASSERTION_HASHSIZE 37 + +#ifdef STATIC_BUFFERS +/* Maximum nesting of cpp_buffers. We use a static limit, partly for + efficiency, and partly to limit runaway recursion. */ +#define CPP_STACK_MAX 200 +#endif + +struct cpp_reader { + unsigned char *limit; + parse_underflow_t get_token; + cpp_buffer *buffer; +#ifdef STATIC_BUFFERS + cpp_buffer buffer_stack[CPP_STACK_MAX]; +#endif + + int errors; /* Error counter for exit code */ + void *data; + + U_CHAR *token_buffer; + int token_buffer_size; + + /* Line where a newline was first seen in a string constant. */ + int multiline_string_line; + + /* Current depth in #include directives that use <...>. */ + int system_include_depth; + + /* List of included files that contained #pragma once. */ + struct file_name_list *dont_repeat_files; + + /* List of other included files. + If ->control_macro if nonzero, the file had a #ifndef + around the entire contents, and ->control_macro gives the macro name. */ + struct file_name_list *all_include_files; + + /* Current maximum length of directory names in the search path + for include files. (Altered as we get more of them.) */ + int max_include_len; + + /* Hash table of files already included with #include or #import. */ + struct import_file *import_hash_table[IMPORT_HASH_SIZE]; + + struct if_stack *if_stack; + + /* Nonzero means we are inside an IF during a -pcp run. In this mode + macro expansion is done, and preconditions are output for all macro + uses requiring them. */ + char pcp_inside_if; + + /* Nonzero means we have printed (while error reporting) a list of + containing files that matches the current status. */ + char input_stack_listing_current; + + /* If non-zero, macros are not expanded. */ + char no_macro_expand; + + /* Print column number in error messages. */ + char show_column; + + /* We're printed a warning recommending against using #import. */ + char import_warning; + + /* If true, character between '<' and '>' are a single (string) token. */ + char parsing_include_directive; + + /* True if escape sequences (as described for has_escapes in + parse_buffer) should be emitted. */ + char output_escapes; + + /* 0: Have seen non-white-space on this line. + 1: Only seen white space so far on this line. + 2: Only seen white space so far in this file. */ + char only_seen_white; + + /* Nonzero means this file was included with a -imacros or -include + command line and should not be recorded as an include file. */ + + int no_record_file; + + long lineno; + + struct tm *timebuf; + + ASSERTION_HASHNODE *assertion_hashtab[ASSERTION_HASHSIZE]; + + /* Buffer of -M output. */ + char *deps_buffer; + + /* Number of bytes allocated in above. */ + int deps_allocated_size; + + /* Number of bytes used. */ + int deps_size; + + /* Number of bytes since the last newline. */ + int deps_column; +}; + +#define CPP_BUF_PEEK(BUFFER) \ + ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur : EOF) +#define CPP_BUF_GET(BUFFER) \ + ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur++ : EOF) +#define CPP_FORWARD(BUFFER, N) ((BUFFER)->cur += (N)) + +/* Number of characters currently in PFILE's output buffer. */ +#define CPP_WRITTEN(PFILE) ((PFILE)->limit - (PFILE)->token_buffer) +#define CPP_PWRITTEN(PFILE) ((PFILE)->limit) + +/* Make sure PFILE->token_buffer has space for at least N more characters. */ +#define CPP_RESERVE(PFILE, N) \ + (CPP_WRITTEN (PFILE) + N > (PFILE)->token_buffer_size \ + && (cpp_grow_buffer (PFILE, N), 0)) + +/* Append string STR (of length N) to PFILE's output buffer. + Assume there is enough space. */ +#define CPP_PUTS_Q(PFILE, STR, N) \ + (bcopy (STR, (PFILE)->limit, (N)), (PFILE)->limit += (N)) +/* Append string STR (of length N) to PFILE's output buffer. Make space. */ +#define CPP_PUTS(PFILE, STR, N) CPP_RESERVE(PFILE, N), CPP_PUTS_Q(PFILE, STR,N) +/* Append character CH to PFILE's output buffer. Assume sufficient space. */ +#define CPP_PUTC_Q(PFILE, CH) (*(PFILE)->limit++ = (CH)) +/* Append character CH to PFILE's output buffer. Make space if need be. */ +#define CPP_PUTC(PFILE, CH) (CPP_RESERVE (PFILE, 1), CPP_PUTC_Q (PFILE, CH)) +/* Make sure PFILE->limit is followed by '\0'. */ +#define CPP_NUL_TERMINATE_Q(PFILE) (*(PFILE)->limit = 0) +#define CPP_NUL_TERMINATE(PFILE) (CPP_RESERVE(PFILE, 1), *(PFILE)->limit = 0) +#define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA)) +#define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N)) + +#define CPP_OPTIONS(PFILE) ((cpp_options*)(PFILE)->data) +#define CPP_BUFFER(PFILE) ((PFILE)->buffer) +#ifdef STATIC_BUFFERS +#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1) +#define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX]) +#else +#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->chain) +#define CPP_NULL_BUFFER(PFILE) ((cpp_buffer*)0) +#endif + +/* Pointed to by parse_file::data. */ +struct cpp_options { + char *in_fname; + + /* Name of output file, for error messages. */ + char *out_fname; + + struct file_name_map_list *map_list; + + /* Non-0 means -v, so print the full set of include dirs. */ + char verbose; + + /* Nonzero means use extra default include directories for C++. */ + + char cplusplus; + + /* Nonzero means handle cplusplus style comments */ + + char cplusplus_comments; + + /* Nonzero means handle #import, for objective C. */ + + char objc; + + /* Nonzero means this is an assembly file, and allow + unknown directives, which could be comments. */ + + int lang_asm; + + /* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */ + + char for_lint; + + /* Nonzero means handle CHILL comment syntax + and output CHILL string delimiter for __DATE___ etc. */ + + char chill; + + /* Nonzero means copy comments into the output file. */ + + char put_out_comments; + + /* Nonzero means don't process the ANSI trigraph sequences. */ + + char no_trigraphs; + + /* Nonzero means print the names of included files rather than + the preprocessed output. 1 means just the #include "...", + 2 means #include <...> as well. */ + + char print_deps; + + /* Nonzero if missing .h files in -M output are assumed to be generated + files and not errors. */ + + char print_deps_missing_files; + + /* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */ + char print_deps_append; + + /* Nonzero means print names of header files (-H). */ + + char print_include_names; + + /* Nonzero means try to make failure to fit ANSI C an error. */ + + char pedantic_errors; + + /* Nonzero means don't print warning messages. -w. */ + + char inhibit_warnings; + + /* Nonzero means warn if slash-star appears in a comment. */ + + char warn_comments; + + /* Nonzero means warn if there are any trigraphs. */ + + char warn_trigraphs; + + /* Nonzero means warn if #import is used. */ + + char warn_import; + + /* Nonzero means warn if a macro argument is (or would be) + stringified with -traditional. */ + + char warn_stringify; + + /* Nonzero means turn warnings into errors. */ + + char warnings_are_errors; + + /* Nonzero causes output not to be done, + but directives such as #define that have side effects + are still obeyed. */ + + char no_output; + + /* Nonzero means don't output line number information. */ + + char no_line_commands; + +/* Nonzero means output the text in failing conditionals, + inside #failed ... #endfailed. */ + + char output_conditionals; + + /* Nonzero means -I- has been seen, + so don't look for #include "foo" the source-file directory. */ + char ignore_srcdir; + +/* Zero means dollar signs are punctuation. + -$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise. + This must be 0 for correct processing of this ANSI C program: + #define foo(a) #a + #define lose(b) foo (b) + #define test$ + lose (test) */ + char dollars_in_ident; +#ifndef DOLLARS_IN_IDENTIFIERS +#define DOLLARS_IN_IDENTIFIERS 1 +#endif + + /* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */ + char traditional; + + /* Nonzero means give all the error messages the ANSI standard requires. */ + char pedantic; + + char done_initializing; + + struct file_name_list *include; /* First dir to search */ + /* First dir to search for */ + /* This is the first element to use for #include <...>. + If it is 0, use the entire chain for such includes. */ + struct file_name_list *first_bracket_include; + /* This is the first element in the chain that corresponds to + a directory of system header files. */ + struct file_name_list *first_system_include; + struct file_name_list *last_include; /* Last in chain */ + + /* Chain of include directories to put at the end of the other chain. */ + struct file_name_list *after_include; + struct file_name_list *last_after_include; /* Last in chain */ + + /* Chain to put at the start of the system include files. */ + struct file_name_list *before_system; + struct file_name_list *last_before_system; /* Last in chain */ + + /* Directory prefix that should replace `/usr' in the standard + include file directories. */ + char *include_prefix; + + char inhibit_predefs; + char no_standard_includes; + char no_standard_cplusplus_includes; + +/* dump_only means inhibit output of the preprocessed text + and instead output the definitions of all user-defined + macros in a form suitable for use as input to cccp. + dump_names means pass #define and the macro name through to output. + dump_definitions means pass the whole definition (plus #define) through +*/ + + enum {dump_none = 0, dump_only, dump_names, dump_definitions} + dump_macros; + +/* Nonzero means pass all #define and #undef directives which we actually + process through to the output stream. This feature is used primarily + to allow cc1 to record the #defines and #undefs for the sake of + debuggers which understand about preprocessor macros, but it may + also be useful with -E to figure out how symbols are defined, and + where they are defined. */ + int debug_output; + + /* Pending -D, -U and -A options, in reverse order. */ + struct cpp_pending *pending; + + /* File name which deps are being written to. + This is 0 if deps are being written to stdout. */ + char *deps_file; + + /* Target-name to write with the dependency information. */ + char *deps_target; +}; + +#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional) +#define CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic) +#define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps) + +/* Name under which this program was invoked. */ + +extern char *progname; + +/* The structure of a node in the hash table. The hash table + has entries for all tokens defined by #define commands (type T_MACRO), + plus some special tokens like __LINE__ (these each have their own + type, and the appropriate code is run when that type of node is seen. + It does not contain control words like "#define", which are recognized + by a separate piece of code. */ + +/* different flavors of hash nodes --- also used in keyword table */ +enum node_type { + T_DEFINE = 1, /* the `#define' keyword */ + T_INCLUDE, /* the `#include' keyword */ + T_INCLUDE_NEXT, /* the `#include_next' keyword */ + T_IMPORT, /* the `#import' keyword */ + T_IFDEF, /* the `#ifdef' keyword */ + T_IFNDEF, /* the `#ifndef' keyword */ + T_IF, /* the `#if' keyword */ + T_ELSE, /* `#else' */ + T_PRAGMA, /* `#pragma' */ + T_ELIF, /* `#elif' */ + T_UNDEF, /* `#undef' */ + T_LINE, /* `#line' */ + T_ERROR, /* `#error' */ + T_WARNING, /* `#warning' */ + T_ENDIF, /* `#endif' */ + T_SCCS, /* `#sccs', used on system V. */ + T_IDENT, /* `#ident', used on system V. */ + T_ASSERT, /* `#assert', taken from system V. */ + T_UNASSERT, /* `#unassert', taken from system V. */ + T_SPECLINE, /* special symbol `__LINE__' */ + T_DATE, /* `__DATE__' */ + T_FILE, /* `__FILE__' */ + T_BASE_FILE, /* `__BASE_FILE__' */ + T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */ + T_VERSION, /* `__VERSION__' */ + T_SIZE_TYPE, /* `__SIZE_TYPE__' */ + T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */ + T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */ + T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */ + T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */ + T_TIME, /* `__TIME__' */ + T_CONST, /* Constant value, used by `__STDC__' */ + T_MACRO, /* macro defined by `#define' */ + T_DISABLED, /* macro temporarily turned off for rescan */ + T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */ + T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */ + T_UNUSED /* Used for something not defined. */ + }; + +/* Structure returned by create_definition */ +typedef struct macrodef MACRODEF; +struct macrodef +{ + struct definition *defn; + U_CHAR *symnam; + int symlen; +}; + +/* Structure allocated for every #define. For a simple replacement + such as + #define foo bar , + nargs = -1, the `pattern' list is null, and the expansion is just + the replacement text. Nargs = 0 means a functionlike macro with no args, + e.g., + #define getchar() getc (stdin) . + When there are args, the expansion is the replacement text with the + args squashed out, and the reflist is a list describing how to + build the output from the input: e.g., "3 chars, then the 1st arg, + then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg". + The chars here come from the expansion. Whatever is left of the + expansion after the last arg-occurrence is copied after that arg. + Note that the reflist can be arbitrarily long--- + its length depends on the number of times the arguments appear in + the replacement text, not how many args there are. Example: + #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and + pattern list + { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL } + where (x, y) means (nchars, argno). */ + +typedef struct definition DEFINITION; +struct definition { + int nargs; + int length; /* length of expansion string */ + int predefined; /* True if the macro was builtin or */ + /* came from the command line */ + U_CHAR *expansion; + int line; /* Line number of definition */ + char *file; /* File of definition */ + char rest_args; /* Nonzero if last arg. absorbs the rest */ + struct reflist { + struct reflist *next; + char stringify; /* nonzero if this arg was preceded by a + # operator. */ + char raw_before; /* Nonzero if a ## operator before arg. */ + char raw_after; /* Nonzero if a ## operator after arg. */ + char rest_args; /* Nonzero if this arg. absorbs the rest */ + int nchars; /* Number of literal chars to copy before + this arg occurrence. */ + int argno; /* Number of arg to substitute (origin-0) */ + } *pattern; + union { + /* Names of macro args, concatenated in reverse order + with comma-space between them. + The only use of this is that we warn on redefinition + if this differs between the old and new definitions. */ + U_CHAR *argnames; + } args; +}; + +extern U_CHAR is_idchar[256]; + +/* Stack of conditionals currently in progress + (including both successful and failing conditionals). */ + +struct if_stack { + struct if_stack *next; /* for chaining to the next stack frame */ + char *fname; /* copied from input when frame is made */ + int lineno; /* similarly */ + int if_succeeded; /* true if a leg of this if-group + has been passed through rescan */ + U_CHAR *control_macro; /* For #ifndef at start of file, + this is the macro name tested. */ + enum node_type type; /* type of last directive seen in this group */ +}; +typedef struct if_stack IF_STACK_FRAME; + +extern void cpp_buf_line_and_col PARAMS((cpp_buffer*, long*, long*)); +extern cpp_buffer* cpp_file_buffer PARAMS((cpp_reader*)); +extern void cpp_define PARAMS ((cpp_reader*, U_CHAR*)); + +extern void cpp_error (); +extern void cpp_warning (); +extern void cpp_pedwarn (); +extern void cpp_error_with_line (); +extern void cpp_pedwarn_with_line (); +extern void cpp_pedwarn_with_file_and_line (); +extern void fatal (); +extern void cpp_error_from_errno (); +extern void cpp_perror_with_name (); +extern void cpp_pfatal_with_name (); + +extern void cpp_grow_buffer PARAMS ((cpp_reader*, long)); +extern int cpp_parse_escape PARAMS ((cpp_reader*, char**)); +extern cpp_buffer* cpp_push_buffer PARAMS ((cpp_reader *, U_CHAR*, long)); +extern cpp_buffer* cpp_pop_buffer PARAMS ((cpp_reader *)); + +extern cpp_hashnode* cpp_lookup PARAMS ((cpp_reader*, const U_CHAR*, + int, int)); + +#ifdef __cplusplus +} +#endif diff --git a/support/cpp/cppmain.c b/support/cpp/cppmain.c new file mode 100644 index 00000000..cb9ab534 --- /dev/null +++ b/support/cpp/cppmain.c @@ -0,0 +1,105 @@ +/* CPP main program, using CPP Library. + Copyright (C) 1995 Free Software Foundation, Inc. + Written by Per Bothner, 1994-95. + +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, 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; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! */ + +#include "cpplib.h" +#include +#include +#include + +#define SUCCESS_EXIT_CODE 0 +#define FATAL_EXIT_CODE 33 +#define EMACS +#ifndef EMACS +#include "config.h" +#endif /* not EMACS */ + +extern char *getenv (); +char *version_string = " for SDC51"; +char *progname; + +cpp_reader parse_in; +cpp_options options; + +/* More 'friendly' abort that prints the line and file. + config.h can #define abort fancy_abort if you like that sort of thing. */ + +void +fancy_abort () +{ + fatal ("Internal gcc abort."); +} + + +int +main (argc, argv) + int argc; + char **argv; +{ + char *p; + int i; + int argi = 1; /* Next argument to handle. */ + struct cpp_options *opts = &options; + + p = argv[0] + strlen (argv[0]); + while (p != argv[0] && p[-1] != '/') --p; + progname = p; + + init_parse_file (&parse_in); + parse_in.data = opts; + + init_parse_options (opts); + + argi += cpp_handle_options (&parse_in, argc - argi , argv + argi); + if (argi < argc) + fatal ("Invalid option `%s'", argv[argi]); + parse_in.show_column = 1; + + i = push_parse_file (&parse_in, opts->in_fname); + if (i != SUCCESS_EXIT_CODE) + return i; + + /* Now that we know the input file is valid, open the output. */ + + if (!opts->out_fname || !strcmp (opts->out_fname, "")) + opts->out_fname = "stdout"; + else if (! freopen (opts->out_fname, "w", stdout)) + cpp_pfatal_with_name (&parse_in, opts->out_fname); + + for (;;) + { + enum cpp_token kind; + if (! opts->no_output) + { + fwrite (parse_in.token_buffer, 1, CPP_WRITTEN (&parse_in), stdout); + } + parse_in.limit = parse_in.token_buffer; + kind = cpp_get_token (&parse_in); + if (kind == CPP_EOF) + break; + } + + cpp_finish (&parse_in); + + if (parse_in.errors) + exit (FATAL_EXIT_CODE); + exit (SUCCESS_EXIT_CODE); +} diff --git a/support/cpp/i386/386bsd.h b/support/cpp/i386/386bsd.h new file mode 100644 index 00000000..cdab5f57 --- /dev/null +++ b/support/cpp/i386/386bsd.h @@ -0,0 +1,81 @@ +/* Configuration for an i386 running 386BSD as the target machine. */ + +/* This is tested by i386gas.h. */ +#define YES_UNDERSCORES + +#include "i386/gstabs.h" + +/* Get perform_* macros to build libgcc.a. */ +#include "i386/perform.h" + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -D____386BSD____ -D__386BSD__ -DBSD_NET2 -Asystem(unix) -Asystem(bsd) -Acpu(i386) -Amachine(i386)" + +/* Like the default, except no -lg. */ +#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "short unsigned int" + +#define WCHAR_UNSIGNED 1 + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 16 + +/* 386BSD does have atexit. */ + +#define HAVE_ATEXIT + +/* Redefine this to use %eax instead of %edx. */ +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ +{ \ + if (flag_pic) \ + { \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \ + LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall mcount\n"); \ + } \ +} + +/* There are conflicting reports about whether this system uses + a different assembler syntax. wilson@cygnus.com says # is right. */ +#undef COMMENT_BEGIN +#define COMMENT_BEGIN "#" + +#undef ASM_APP_ON +#define ASM_APP_ON "#APP\n" + +#undef ASM_APP_OFF +#define ASM_APP_OFF "#NO_APP\n" + +/* The following macros are stolen from i386v4.h */ +/* These have to be defined to get PIC code correct */ + +/* This is how to output an element of a case-vector that is relative. + This is only used for PIC code. See comments by the `casesi' insn in + i386.md for an explanation of the expression this outputs. */ + +#undef ASM_OUTPUT_ADDR_DIFF_ELT +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ + fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) + +/* Indicate that jump tables go in the text section. This is + necessary when compiling PIC code. */ + +#define JUMP_TABLES_IN_TEXT_SECTION + +/* Don't default to pcc-struct-return, because gcc is the only compiler, and + we want to retain compatibility with older gcc versions. */ +#define DEFAULT_PCC_STRUCT_RETURN 0 diff --git a/support/cpp/i386/aix386.h b/support/cpp/i386/aix386.h new file mode 100644 index 00000000..e0498e79 --- /dev/null +++ b/support/cpp/i386/aix386.h @@ -0,0 +1,69 @@ +/* Definitions for IBM PS2 running AIX/386 with gas. + From: Minh Tran-Le + Copyright (C) 1988 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* + * This configuration file is for gcc with gas-2.x and gnu ld 2.x + * with aix ps/2 1.3.x. + */ + +/* Define USE_GAS if you have the new version of gas that can handle + * multiple segments and .section pseudo op. This will allow gcc to + * use the .init section for g++ ctor/dtor. + * + * If you don't have gas then undefined USE_GAS. You will also have + * to use collect if you want to use g++ + */ +#define USE_GAS + +#include "i386/aix386ng.h" + +/* Use crt1.o as a startup file and crtn.o as a closing file. + And add crtbegin.o and crtend.o for ctors and dtors */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} crtbegin.o%s" +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + "crtend.o%s crtn.o%s" + +/* Removed the -K flags because the gnu ld does not handle it */ +#undef LINK_SPEC +#define LINK_SPEC "%{T*} %{z:-lm}" + +/* Define a few machine-specific details of the implementation of + constructors. */ + +#undef INIT_SECTION_ASM_OP +#define INIT_SECTION_ASM_OP ".section .init,\"x\"" + +#define CTOR_LIST_BEGIN \ + asm (INIT_SECTION_ASM_OP); \ + asm ("pushl $0") +#define CTOR_LIST_END CTOR_LIST_BEGIN + +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + init_section (); \ + fprintf (FILE, "\tpushl $"); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) diff --git a/support/cpp/i386/aix386ng.h b/support/cpp/i386/aix386ng.h new file mode 100644 index 00000000..5d09fc30 --- /dev/null +++ b/support/cpp/i386/aix386ng.h @@ -0,0 +1,143 @@ +/* Definitions for IBM PS2 running AIX/386. + From: Minh Tran-Le + Copyright (C) 1988 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +#include "i386/i386.h" + +/* Get the generic definitions for system V.3. */ + +#include "svr3.h" + +/* Use the ATT assembler syntax. + This overrides at least one macro (ASM_OUTPUT_LABELREF) from svr3.h. */ + +#include "i386/att.h" + +/* Use crt1.o as a startup file and crtn.o as a closing file. */ + +#define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}" +#define ENDFILE_SPEC "crtn.o%s" + +#define LIB_SPEC "%{shlib:-lc_s} -lc" + +/* Special flags for the linker. I don't know what they do. */ + +#define LINK_SPEC "%{K} %{!K:-K} %{T*} %{z:-lm}" + +/* Specify predefined symbols in preprocessor. */ + +#define CPP_PREDEFINES "-Dps2 -Dunix -Di386 -Asystem(unix) -Asystem(aix) -Acpu(i386) -Amachine(i386)" + +#define CPP_SPEC \ + "%{posix:-D_POSIX_SOURCE}%{!posix:-DAIX} -D_I386 -D_AIX -D_MBCS" + +/* special flags for the aix assembler to generate the short form for all + qualifying forward reference */ +/* The buggy /bin/as of aix ps/2 1.2.x cannot always handle it. */ +#if 0 +#define ASM_SPEC "-s2" +#endif /* 0 */ + +#undef ASM_FILE_START +#define ASM_FILE_START(FILE) \ + do { fprintf (FILE, "\t.file\t"); \ + output_quoted_string (FILE, dump_base_name); \ + fprintf (FILE, "\n"); \ + if (optimize) \ + ASM_FILE_START_1 (FILE); \ + else \ + fprintf (FILE, "\t.noopt\n"); \ + } while (0) + +/* This was suggested, but it shouldn't be right for DBX output. -- RMS + #define ASM_OUTPUT_SOURCE_FILENAME(FILE, NAME) */ + +/* Writing `int' for a bitfield forces int alignment for the structure. */ + +#define PCC_BITFIELD_TYPE_MATTERS 1 + +#ifndef USE_GAS +/* Don't write a `.optim' pseudo; this assembler + is said to have a bug when .optim is used. */ + +#undef ASM_FILE_START_1 +#define ASM_FILE_START_1(FILE) fprintf (FILE, "\t.noopt\n") +#endif + +/* Output assembler code to FILE to increment profiler label # LABELNO + for profiling a function entry. */ + +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ + fprintf (FILE, "\tleal %sP%d,%%eax\n\tcall mcount\n", LPREFIX, (LABELNO)); + +/* Note that using bss_section here caused errors + in building shared libraries on system V.3. + but AIX 1.2 does not have yet shareable libraries on PS2 */ +#undef ASM_OUTPUT_LOCAL +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ + (bss_section (), \ + ASM_OUTPUT_LABEL ((FILE), (NAME)), \ + fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED))) + + +/* Undef all the .init and .fini section stuff if we are not using gas and + * gnu ld so that we can use collect because the standard /bin/as and /bin/ld + * cannot handle those. + */ +#ifndef USE_GAS +# undef INIT_SECTION_ASM_OP +# undef FINI_SECTION_ASM_OP +# undef CTORS_SECTION_ASM_OP +# undef DTORS_SECTION_ASM_OP +# undef ASM_OUTPUT_CONSTRUCTOR +# undef ASM_OUTPUT_DESTRUCTOR +# undef DO_GLOBAL_CTORS_BODY + +# undef CTOR_LIST_BEGIN +# define CTOR_LIST_BEGIN +# undef CTOR_LIST_END +# define CTOR_LIST_END +# undef DTOR_LIST_BEGIN +# define DTOR_LIST_BEGIN +# undef DTOR_LIST_END +# define DTOR_LIST_END + +# undef CONST_SECTION_FUNCTION +# define CONST_SECTION_FUNCTION \ +void \ +const_section () \ +{ \ + extern void text_section(); \ + text_section(); \ +} + +# undef EXTRA_SECTION_FUNCTIONS +# define EXTRA_SECTION_FUNCTIONS \ + CONST_SECTION_FUNCTION \ + BSS_SECTION_FUNCTION + +/* for collect2 */ +# define OBJECT_FORMAT_COFF +# define MY_ISCOFF(magic) \ + ((magic) == I386MAGIC || (magic) == I386SVMAGIC) + +#endif /* !USE_GAS */ diff --git a/support/cpp/i386/att.h b/support/cpp/i386/att.h new file mode 100644 index 00000000..f8bbb764 --- /dev/null +++ b/support/cpp/i386/att.h @@ -0,0 +1,106 @@ +/* Definitions for AT&T assembler syntax for the Intel 80386. + Copyright (C) 1988 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Include common aspects of all 386 Unix assemblers. */ +#include "i386/unix.h" + +#define TARGET_VERSION fprintf (stderr, " (80386, ATT syntax)"); + +/* Define the syntax of instructions and addresses. */ + +/* Prefix for internally generated assembler labels. */ +#define LPREFIX ".L" + +/* Assembler pseudos to introduce constants of various size. */ + +/* #define ASM_BYTE_OP "\t.byte" Now in svr3.h or svr4.h. */ +#define ASM_SHORT "\t.value" +#define ASM_LONG "\t.long" +#define ASM_DOUBLE "\t.double" + +/* How to output an ASCII string constant. */ + +#define ASM_OUTPUT_ASCII(FILE, p, size) \ +do \ +{ int i = 0; \ + while (i < (size)) \ + { if (i%10 == 0) { if (i!=0) fprintf ((FILE), "\n"); \ + fprintf ((FILE), "%s ", ASM_BYTE_OP); } \ + else fprintf ((FILE), ","); \ + fprintf ((FILE), "0x%x", ((p)[i++] & 0377)) ;} \ + fprintf ((FILE), "\n"); \ +} while (0) + +/* Do use .optim by default on this machine. */ +#undef ASM_FILE_START_1 +#define ASM_FILE_START_1(FILE) fprintf (FILE, "\t.optim\n") + +/* This is how to output an assembler line + that says to advance the location counter + to a multiple of 2**LOG bytes. */ + +#define ASM_OUTPUT_ALIGN(FILE,LOG) \ + if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) + +/* This is how to output an assembler line + that says to advance the location counter by SIZE bytes. */ + +#define ASM_OUTPUT_SKIP(FILE,SIZE) \ + fprintf ((FILE), "\t.set .,.+%u\n", (SIZE)) + +/* Can't use ASM_OUTPUT_SKIP in text section; it doesn't leave 0s. */ + +#define ASM_NO_SKIP_IN_TEXT 1 + +#undef BSS_SECTION_FUNCTION /* Override the definition from svr3.h. */ +#define BSS_SECTION_FUNCTION \ +void \ +bss_section () \ +{ \ + if (in_section != in_bss) \ + { \ + fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP); \ + in_section = in_bss; \ + } \ +} + +/* Define the syntax of labels and symbol definitions/declarations. */ + +/* This is how to store into the string BUF + the symbol_ref name of an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. + This is suitable for output with `assemble_name'. */ + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), ".%s%d", (PREFIX), (NUMBER)) + +/* This is how to output an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. */ + +#undef ASM_OUTPUT_INTERNAL_LABEL +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + fprintf (FILE, ".%s%d:\n", PREFIX, NUM) + +/* This is how to output a reference to a user-level label named NAME. */ + +#undef ASM_OUTPUT_LABELREF +#define ASM_OUTPUT_LABELREF(FILE,NAME) \ + fprintf (FILE, "%s", NAME) diff --git a/support/cpp/i386/bsd.h b/support/cpp/i386/bsd.h new file mode 100644 index 00000000..6bf7399d --- /dev/null +++ b/support/cpp/i386/bsd.h @@ -0,0 +1,130 @@ +/* Definitions for BSD assembler syntax for Intel 386 + (actually AT&T syntax for insns and operands, + adapted to BSD conventions for symbol names and debugging.) + Copyright (C) 1988 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Include common aspects of all 386 Unix assemblers. */ +#include "i386/unix.h" + +/* Use the Sequent Symmetry assembler syntax. */ + +#define TARGET_VERSION fprintf (stderr, " (80386, BSD syntax)"); + +/* Define the syntax of pseudo-ops, labels and comments. */ + +/* Prefix for internally generated assembler labels. If we aren't using + underscores, we are using prefix `.'s to identify labels that should + be ignored, as in `i386/gas.h' --karl@cs.umb.edu */ +#ifdef NO_UNDERSCORES +#define LPREFIX ".L" +#else +#define LPREFIX "L" +#endif /* not NO_UNDERSCORES */ + +/* Assembler pseudos to introduce constants of various size. */ + +#define ASM_BYTE_OP "\t.byte" +#define ASM_SHORT "\t.word" +#define ASM_LONG "\t.long" +#define ASM_DOUBLE "\t.double" + +/* Output at beginning of assembler file. + ??? I am skeptical of this -- RMS. */ + +#define ASM_FILE_START(FILE) \ + do { fprintf (FILE, "\t.file\t"); \ + output_quoted_string (FILE, dump_base_name); \ + fprintf (FILE, "\n"); \ + } while (0) + +/* This was suggested, but it shouldn't be right for DBX output. -- RMS + #define ASM_OUTPUT_SOURCE_FILENAME(FILE, NAME) */ + + +/* Define the syntax of labels and symbol definitions/declarations. */ + +/* This is how to output an assembler line + that says to advance the location counter by SIZE bytes. */ + +#define ASM_OUTPUT_SKIP(FILE,SIZE) \ + fprintf (FILE, "\t.space %u\n", (SIZE)) + +/* Define the syntax of labels and symbol definitions/declarations. */ + +/* This says how to output an assembler line + to define a global common symbol. */ + +#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ +( fputs (".comm ", (FILE)), \ + assemble_name ((FILE), (NAME)), \ + fprintf ((FILE), ",%u\n", (ROUNDED))) + +/* This says how to output an assembler line + to define a local common symbol. */ + +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ +( fputs (".lcomm ", (FILE)), \ + assemble_name ((FILE), (NAME)), \ + fprintf ((FILE), ",%u\n", (ROUNDED))) + +/* This is how to output an assembler line + that says to advance the location counter + to a multiple of 2**LOG bytes. */ + +#define ASM_OUTPUT_ALIGN(FILE,LOG) \ + if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", (LOG)) + +/* This is how to store into the string BUF + the symbol_ref name of an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. + This is suitable for output with `assemble_name'. */ + +#ifdef NO_UNDERSCORES +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), "*.%s%d", (PREFIX), (NUMBER)) +#else +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), "*%s%d", (PREFIX), (NUMBER)) +#endif + +/* This is how to output an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. */ + +#ifdef NO_UNDERSCORES +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + fprintf (FILE, ".%s%d:\n", PREFIX, NUM) +#else +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + fprintf (FILE, "%s%d:\n", PREFIX, NUM) +#endif + +/* This is how to output a reference to a user-level label named NAME. */ + +#ifdef NO_UNDERSCORES +#define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "%s", NAME) +#else +#define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "_%s", NAME) +#endif /* not NO_UNDERSCORES */ + +/* Sequent has some changes in the format of DBX symbols. */ +#define DBX_NO_XREFS 1 + +/* Don't split DBX symbols into continuations. */ +#define DBX_CONTIN_LENGTH 0 diff --git a/support/cpp/i386/bsd386.h b/support/cpp/i386/bsd386.h new file mode 100644 index 00000000..935a2e06 --- /dev/null +++ b/support/cpp/i386/bsd386.h @@ -0,0 +1,18 @@ +/* Configuration for an i386 running BSDI's BSD/386 1.1 as the target + machine. */ + +#include "i386/386bsd.h" + +/* We exist mostly to add -Dbsdi and such to the predefines. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -Dbsdi -D__i386__ -D__bsdi__ -D____386BSD____ -D__386BSD__ -DBSD_NET2 -Asystem(unix) -Asystem(bsd) -Acpu(i386) -Amachine(i386)" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_UNSIGNED +#define WCHAR_UNSIGNED 0 + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 diff --git a/support/cpp/i386/config-nt.sed b/support/cpp/i386/config-nt.sed new file mode 100644 index 00000000..6c86b27e --- /dev/null +++ b/support/cpp/i386/config-nt.sed @@ -0,0 +1,38 @@ +/^Makefile/,/^ rm -f config.run/d +s/rm -f/del/ +s/|| cp/|| copy/ +/^config.status/,/ fi/d +s/config.status//g +s/\/dev\/null/NUL/g +s/$(srcdir)\/c-parse/c-parse/g +s/$(srcdir)\/c-gperf/c-gperf/g +/^multilib.h/ s/multilib/not-multilib/ +/^target=/ c\ +target=winnt3.5 +/^xmake_file=/ d +/^tmake_file=/ d +/^out_file/ c\ +out_file=config/i386/i386.c +/^out_object_file/ c\ +out_object_file=i386.obj +/^md_file/ c\ +md_file=config/i386/i386.md +/^tm_file/ c\ +tm_file=config/i386/win-nt.h +/^build_xm_file/ c\ +build_xm_file=config/i386/xm-winnt.h +/^host_xm_file/ c\ +host_xm_file=config/i386/xm-winnt.h +/^####target/ i\ +CC = cl \ +CLIB = libc.lib kernel32.lib \ +CFLAGS = -Di386 -DWIN32 -D_WIN32 -D_M_IX86=300 -D_X86_=1 \\\ + -DALMOST_STDC -D_MSC_VER=800 \ +LDFLAGS = -align:0x1000 -subsystem:console -entry:mainCRTStartup \\\ + -stack:1000000,1000 \ +\ +EXTRA_OBJS=winnt.obj \ +winnt.obj: $(srcdir)/config/i386/winnt.c \ +\ $(CC) $(CFLAGS) \\\ +\ -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/i386/winnt.c \ + diff --git a/support/cpp/i386/freebsd.h b/support/cpp/i386/freebsd.h new file mode 100644 index 00000000..c4e9991c --- /dev/null +++ b/support/cpp/i386/freebsd.h @@ -0,0 +1,250 @@ +/* Definitions of target machine for GNU compiler for Intel 80386 + running FreeBSD. + Copyright (C) 1988, 1992, 1994 Free Software Foundation, Inc. + Contributed by Poul-Henning Kamp + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This goes away when the math-emulator is fixed */ +#define TARGET_CPU_DEFAULT 0400 /* TARGET_NO_FANCY_MATH_387 */ + +/* This is tested by i386gas.h. */ +#define YES_UNDERSCORES + +/* Don't assume anything about the header files. */ +#define NO_IMPLICIT_EXTERN_C + +#include "i386/gstabs.h" + +/* Get perform_* macros to build libgcc.a. */ +#include "i386/perform.h" + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -D__FreeBSD__ -D__386BSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)" + +/* Like the default, except no -lg. */ +#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "short unsigned int" + +#define WCHAR_UNSIGNED 1 + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 16 + +#define HAVE_ATEXIT + +/* There are conflicting reports about whether this system uses + a different assembler syntax. wilson@cygnus.com says # is right. */ +#undef COMMENT_BEGIN +#define COMMENT_BEGIN "#" + +#undef ASM_APP_ON +#define ASM_APP_ON "#APP\n" + +#undef ASM_APP_OFF +#define ASM_APP_OFF "#NO_APP\n" + +/* The following macros are stolen from i386v4.h */ +/* These have to be defined to get PIC code correct */ + +/* This is how to output an element of a case-vector that is relative. + This is only used for PIC code. See comments by the `casesi' insn in + i386.md for an explanation of the expression this outputs. */ + +#undef ASM_OUTPUT_ADDR_DIFF_ELT +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ + fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) + +/* Indicate that jump tables go in the text section. This is + necessary when compiling PIC code. */ + +#define JUMP_TABLES_IN_TEXT_SECTION + +/* Don't default to pcc-struct-return, because gcc is the only compiler, and + we want to retain compatibility with older gcc versions. */ +#define DEFAULT_PCC_STRUCT_RETURN 0 + +/* Profiling routines, partially copied from i386/osfrose.h. */ + +/* Redefine this to use %eax instead of %edx. */ +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ +{ \ + if (flag_pic) \ + { \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \ + LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall mcount\n"); \ + } \ +} + +/* + * Some imports from svr4.h in support of shared libraries. + * Currently, we need the DECLARE_OBJECT_SIZE stuff. + */ + +/* Define the strings used for the special svr4 .type and .size directives. + These strings generally do not vary from one system running svr4 to + another, but if a given system (e.g. m88k running svr) needs to use + different pseudo-op names for these, they may be overridden in the + file which includes this one. */ + +#define TYPE_ASM_OP ".type" +#define SIZE_ASM_OP ".size" + +/* The following macro defines the format used to output the second + operand of the .type assembler directive. Different svr4 assemblers + expect various different forms for this operand. The one given here + is just a default. You may need to override it in your machine- + specific tm.h file (depending upon the particulars of your assembler). */ + +#define TYPE_OPERAND_FMT "@%s" + +/* Write the extra assembler code needed to declare a function's result. + Most svr4 assemblers don't require any special declaration of the + result value, but there are exceptions. */ + +#ifndef ASM_DECLARE_RESULT +#define ASM_DECLARE_RESULT(FILE, RESULT) +#endif + +/* These macros generate the special .type and .size directives which + are used to set the corresponding fields of the linker symbol table + entries in an ELF object file under SVR4. These macros also output + the starting labels for the relevant functions/objects. */ + +/* Write the extra assembler code needed to declare a function properly. + Some svr4 assemblers need to also have something extra said about the + function's return value. We allow for that here. */ + +#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ + do { \ + fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ + assemble_name (FILE, NAME); \ + putc (',', FILE); \ + fprintf (FILE, TYPE_OPERAND_FMT, "function"); \ + putc ('\n', FILE); \ + ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ + ASM_OUTPUT_LABEL(FILE, NAME); \ + } while (0) + +/* Write the extra assembler code needed to declare an object properly. */ + +#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ + do { \ + fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ + assemble_name (FILE, NAME); \ + putc (',', FILE); \ + fprintf (FILE, TYPE_OPERAND_FMT, "object"); \ + putc ('\n', FILE); \ + size_directive_output = 0; \ + if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ + { \ + size_directive_output = 1; \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ + } \ + ASM_OUTPUT_LABEL(FILE, NAME); \ + } while (0) + +/* Output the size directive for a decl in rest_of_decl_compilation + in the case where we did not do so before the initializer. + Once we find the error_mark_node, we know that the value of + size_directive_output was set + by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ + +#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ +do { \ + char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ + if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ + && ! AT_END && TOP_LEVEL \ + && DECL_INITIAL (DECL) == error_mark_node \ + && !size_directive_output) \ + { \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, name); \ + fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL)));\ + } \ + } while (0) + + +/* This is how to declare the size of a function. */ + +#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ + do { \ + if (!flag_inhibit_size_directive) \ + { \ + char label[256]; \ + static int labelno; \ + labelno++; \ + ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \ + ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, (FNAME)); \ + fprintf (FILE, ","); \ + assemble_name (FILE, label); \ + fprintf (FILE, "-"); \ + assemble_name (FILE, (FNAME)); \ + putc ('\n', FILE); \ + } \ + } while (0) + +#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}" +#define LINK_SPEC \ + "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*}" + +/* This is defined when gcc is compiled in the BSD-directory-tree, and must + * make up for the gap to all the stuff done in the GNU-makefiles. + */ + +#ifdef FREEBSD_NATIVE + +#define INCLUDE_DEFAULTS { \ + { "/usr/include", 0 }, \ + { "/usr/include/g++", 1 }, \ + { 0, 0} \ + } + +#undef MD_EXEC_PREFIX +#define MD_EXEC_PREFIX "/usr/libexec/" + +#undef STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "/usr/lib" + +#if 0 /* This is very wrong!!! */ +#define DEFAULT_TARGET_MACHINE "i386-unknown-freebsd_1.0" +#define GPLUSPLUS_INCLUDE_DIR "/usr/local/lib/gcc-lib/i386-unknown-freebsd_1.0/2.5.8/include" +#define TOOL_INCLUDE_DIR "/usr/local/i386-unknown-freebsd_1.0/include" +#define GCC_INCLUDE_DIR "/usr/local/lib/gcc-lib/i386-unknown-freebsd_1.0/2.5.8/include" +#endif + +#endif /* FREEBSD_NATIVE */ diff --git a/support/cpp/i386/gas.h b/support/cpp/i386/gas.h new file mode 100644 index 00000000..d0201572 --- /dev/null +++ b/support/cpp/i386/gas.h @@ -0,0 +1,155 @@ +/* Definitions for Intel 386 running system V with gnu tools + Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Note that i386/seq-gas.h is a GAS configuration that does not use this + file. */ + +#include "i386/i386.h" + +#ifndef YES_UNDERSCORES +/* Define this now, because i386/bsd.h tests it. */ +#define NO_UNDERSCORES +#endif + +/* Use the bsd assembler syntax. */ +/* we need to do this because gas is really a bsd style assembler, + * and so doesn't work well this these att-isms: + * + * ASM_OUTPUT_SKIP is .set .,.+N, which isn't implemented in gas + * ASM_OUTPUT_LOCAL is done with .set .,.+N, but that can't be + * used to define bss static space + * + * Next is the question of whether to uses underscores. RMS didn't + * like this idea at first, but since it is now obvious that we + * need this separate tm file for use with gas, at least to get + * dbx debugging info, I think we should also switch to underscores. + * We can keep i386v for real att style output, and the few + * people who want both form will have to compile twice. + */ + +#include "i386/bsd.h" + +/* these come from i386/bsd.h, but are specific to sequent */ +#undef DBX_NO_XREFS +#undef DBX_CONTIN_LENGTH + +/* Ask for COFF symbols. */ + +#define SDB_DEBUGGING_INFO + +/* Specify predefined symbols in preprocessor. */ + +#define CPP_PREDEFINES "-Dunix -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386)" +#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}" + +/* Allow #sccs in preprocessor. */ + +#define SCCS_DIRECTIVE + +/* Output #ident as a .ident. */ + +#define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME); + +/* Implicit library calls should use memcpy, not bcopy, etc. */ + +#define TARGET_MEM_FUNCTIONS + +#if 0 /* People say gas uses the log as the arg to .align. */ +/* When using gas, .align N aligns to an N-byte boundary. */ + +#undef ASM_OUTPUT_ALIGN +#define ASM_OUTPUT_ALIGN(FILE,LOG) \ + if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) +#endif + +/* Align labels, etc. at 4-byte boundaries. + For the 486, align to 16-byte boundary for sake of cache. */ + +#undef ASM_OUTPUT_ALIGN_CODE +#define ASM_OUTPUT_ALIGN_CODE(FILE) \ + fprintf ((FILE), "\t.align %d,0x90\n", i386_align_jumps) + +/* Align start of loop at 4-byte boundary. */ + +#undef ASM_OUTPUT_LOOP_ALIGN +#define ASM_OUTPUT_LOOP_ALIGN(FILE) \ + fprintf ((FILE), "\t.align %d,0x90\n", i386_align_loops) + + +/* A C statement or statements which output an assembler instruction + opcode to the stdio stream STREAM. The macro-operand PTR is a + variable of type `char *' which points to the opcode name in its + "internal" form--the form that is written in the machine description. + + GAS version 1.38.1 doesn't understand the `repz' opcode mnemonic. + So use `repe' instead. */ + +#define ASM_OUTPUT_OPCODE(STREAM, PTR) \ +{ \ + if ((PTR)[0] == 'r' \ + && (PTR)[1] == 'e' \ + && (PTR)[2] == 'p') \ + { \ + if ((PTR)[3] == 'z') \ + { \ + fprintf (STREAM, "repe"); \ + (PTR) += 4; \ + } \ + else if ((PTR)[3] == 'n' && (PTR)[4] == 'z') \ + { \ + fprintf (STREAM, "repne"); \ + (PTR) += 5; \ + } \ + } \ +} + +/* Define macro used to output shift-double opcodes when the shift + count is in %cl. Some assemblers require %cl as an argument; + some don't. + + GAS requires the %cl argument, so override i386/unix.h. */ + +#undef AS3_SHIFT_DOUBLE +#define AS3_SHIFT_DOUBLE(a,b,c,d) AS3 (a,b,c,d) + +/* Print opcodes the way that GAS expects them. */ +#define GAS_MNEMONICS 1 + +#ifdef NO_UNDERSCORES /* If user-symbols don't have underscores, + then it must take more than `L' to identify + a label that should be ignored. */ + +/* This is how to store into the string BUF + the symbol_ref name of an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. + This is suitable for output with `assemble_name'. */ + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), ".%s%d", (PREFIX), (NUMBER)) + +/* This is how to output an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. */ + +#undef ASM_OUTPUT_INTERNAL_LABEL +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + fprintf (FILE, ".%s%d:\n", PREFIX, NUM) + +#endif /* NO_UNDERSCORES */ diff --git a/support/cpp/i386/gnu.h b/support/cpp/i386/gnu.h new file mode 100644 index 00000000..1ad5df99 --- /dev/null +++ b/support/cpp/i386/gnu.h @@ -0,0 +1,20 @@ +/* Configuration for an i386 running GNU with ELF as the target machine. */ + +/* This does it mostly for us. */ +#include + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES GNU_CPP_PREDEFINES("i386") + +#undef LINK_SPEC +#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker:-dynamic-linker /lib/ld.so} \ + %{!rpath:-rpath /lib/}} %{static:-static}}}" + + +/* Get machine-independent configuration parameters for the GNU system. */ +#include diff --git a/support/cpp/i386/go32.h b/support/cpp/i386/go32.h new file mode 100644 index 00000000..5618a0dd --- /dev/null +++ b/support/cpp/i386/go32.h @@ -0,0 +1,64 @@ +/* Configuration for an i386 running MS-DOS with djgpp/go32. */ + +/* Don't assume anything about the header files. */ +#define NO_IMPLICIT_EXTERN_C + +#define HANDLE_SYSV_PRAGMA + +#define YES_UNDERSCORES + +#include "i386/gas.h" + +#ifdef CPP_PREDEFINES +#undef CPP_PREDEFINES +#endif +#define CPP_PREDEFINES "-Dunix -Di386 -DGO32 -DMSDOS \ + -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386)" + +#undef EXTRA_SECTIONS +#define EXTRA_SECTIONS in_ctor, in_dtor + +#undef EXTRA_SECTION_FUNCTIONS +#define EXTRA_SECTION_FUNCTIONS \ + CTOR_SECTION_FUNCTION \ + DTOR_SECTION_FUNCTION + +#define CTOR_SECTION_FUNCTION \ +void \ +ctor_section () \ +{ \ + if (in_section != in_ctor) \ + { \ + fprintf (asm_out_file, "\t.section .ctor\n"); \ + in_section = in_ctor; \ + } \ +} + +#define DTOR_SECTION_FUNCTION \ +void \ +dtor_section () \ +{ \ + if (in_section != in_dtor) \ + { \ + fprintf (asm_out_file, "\t.section .dtor\n"); \ + in_section = in_dtor; \ + } \ +} + +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + ctor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + +#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ + do { \ + dtor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + + diff --git a/support/cpp/i386/gstabs.h b/support/cpp/i386/gstabs.h new file mode 100644 index 00000000..5f0ae348 --- /dev/null +++ b/support/cpp/i386/gstabs.h @@ -0,0 +1,9 @@ +#include "i386/gas.h" + +/* We do not want to output SDB debugging information. */ + +#undef SDB_DEBUGGING_INFO + +/* We want to output DBX debugging information. */ + +#define DBX_DEBUGGING_INFO diff --git a/support/cpp/i386/i386-aout.h b/support/cpp/i386/i386-aout.h new file mode 100644 index 00000000..e4be8d5d --- /dev/null +++ b/support/cpp/i386/i386-aout.h @@ -0,0 +1,34 @@ +/* Definitions for "naked" Intel 386 using a.out (or coff encap'd + a.out) object format and stabs debugging info. + + Copyright (C) 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* This is tested by gas.h. */ +#define YES_UNDERSCORES + +#include "i386/gstabs.h" + +/* Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Di386" + +/* end of i386-aout.h */ diff --git a/support/cpp/i386/i386-coff.h b/support/cpp/i386/i386-coff.h new file mode 100644 index 00000000..915e307d --- /dev/null +++ b/support/cpp/i386/i386-coff.h @@ -0,0 +1,97 @@ +/* Definitions for "naked" Intel 386 using coff object format files + and coff debugging info. + + Copyright (C) 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +#include "i386/gas.h" + +/* Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Di386" + +#undef DBX_DEBUGGING_INFO +#define SDB_DEBUGGING_INFO + +/* Support the ctors and dtors sections for g++. */ + +#define CTORS_SECTION_ASM_OP ".section\t.ctors,\"x\"" +#define DTORS_SECTION_ASM_OP ".section\t.dtors,\"x\"" + +/* A list of other sections which the compiler might be "in" at any + given time. */ + +#undef EXTRA_SECTIONS +#define EXTRA_SECTIONS in_ctors, in_dtors + +/* A list of extra section function definitions. */ + +#undef EXTRA_SECTION_FUNCTIONS +#define EXTRA_SECTION_FUNCTIONS \ + CTORS_SECTION_FUNCTION \ + DTORS_SECTION_FUNCTION + +#define CTORS_SECTION_FUNCTION \ +void \ +ctors_section () \ +{ \ + if (in_section != in_ctors) \ + { \ + fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \ + in_section = in_ctors; \ + } \ +} + +#define DTORS_SECTION_FUNCTION \ +void \ +dtors_section () \ +{ \ + if (in_section != in_dtors) \ + { \ + fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \ + in_section = in_dtors; \ + } \ +} + +#define INT_ASM_OP ".long" + +/* A C statement (sans semicolon) to output an element in the table of + global constructors. */ +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + ctors_section (); \ + fprintf (FILE, "\t%s\t ", INT_ASM_OP); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + +/* A C statement (sans semicolon) to output an element in the table of + global destructors. */ +#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ + do { \ + dtors_section (); \ + fprintf (FILE, "\t%s\t ", INT_ASM_OP); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + + +/* end of i386-coff.h */ diff --git a/support/cpp/i386/i386.c b/support/cpp/i386/i386.c new file mode 100644 index 00000000..48c58a09 --- /dev/null +++ b/support/cpp/i386/i386.c @@ -0,0 +1,3245 @@ +/* Subroutines for insn-output.c for Intel X86. + Copyright (C) 1988, 1992, 1994, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include "config.h" +#include "rtl.h" +#include "regs.h" +#include "hard-reg-set.h" +#include "real.h" +#include "insn-config.h" +#include "conditions.h" +#include "insn-flags.h" +#include "output.h" +#include "insn-attr.h" +#include "tree.h" +#include "flags.h" +#include "function.h" + +#ifdef EXTRA_CONSTRAINT +/* If EXTRA_CONSTRAINT is defined, then the 'S' + constraint in REG_CLASS_FROM_LETTER will no longer work, and various + asm statements that need 'S' for class SIREG will break. */ + error EXTRA_CONSTRAINT conflicts with S constraint letter +/* The previous line used to be #error, but some compilers barf + even if the conditional was untrue. */ +#endif + +#define AT_BP(mode) (gen_rtx (MEM, (mode), frame_pointer_rtx)) + +extern FILE *asm_out_file; +extern char *strcat (); + +char *singlemove_string (); +char *output_move_const_single (); +char *output_fp_cc0_set (); + +char *hi_reg_name[] = HI_REGISTER_NAMES; +char *qi_reg_name[] = QI_REGISTER_NAMES; +char *qi_high_reg_name[] = QI_HIGH_REGISTER_NAMES; + +/* Array of the smallest class containing reg number REGNO, indexed by + REGNO. Used by REGNO_REG_CLASS in i386.h. */ + +enum reg_class regclass_map[FIRST_PSEUDO_REGISTER] = +{ + /* ax, dx, cx, bx */ + AREG, DREG, CREG, BREG, + /* si, di, bp, sp */ + SIREG, DIREG, INDEX_REGS, GENERAL_REGS, + /* FP registers */ + FP_TOP_REG, FP_SECOND_REG, FLOAT_REGS, FLOAT_REGS, + FLOAT_REGS, FLOAT_REGS, FLOAT_REGS, FLOAT_REGS, + /* arg pointer */ + INDEX_REGS +}; + +/* Test and compare insns in i386.md store the information needed to + generate branch and scc insns here. */ + +struct rtx_def *i386_compare_op0 = NULL_RTX; +struct rtx_def *i386_compare_op1 = NULL_RTX; +struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); + +/* Register allocation order */ +char *i386_reg_alloc_order; +static char regs_allocated[FIRST_PSEUDO_REGISTER]; + +/* # of registers to use to pass arguments. */ +char *i386_regparm_string; /* # registers to use to pass args */ +int i386_regparm; /* i386_regparm_string as a number */ + +/* Alignment to use for loops and jumps */ +char *i386_align_loops_string; /* power of two alignment for loops */ +char *i386_align_jumps_string; /* power of two alignment for non-loop jumps */ +char *i386_align_funcs_string; /* power of two alignment for functions */ + +int i386_align_loops; /* power of two alignment for loops */ +int i386_align_jumps; /* power of two alignment for non-loop jumps */ +int i386_align_funcs; /* power of two alignment for functions */ + + +/* Sometimes certain combinations of command options do not make + sense on a particular target machine. You can define a macro + `OVERRIDE_OPTIONS' to take account of this. This macro, if + defined, is executed once just after all the command options have + been parsed. + + Don't use this macro to turn on various extra optimizations for + `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */ + +void +override_options () +{ + int ch, i, regno; + char *p; + int def_align; + +#ifdef SUBTARGET_OVERRIDE_OPTIONS + SUBTARGET_OVERRIDE_OPTIONS; +#endif + + /* Validate registers in register allocation order */ + if (i386_reg_alloc_order) + { + for (i = 0; (ch = i386_reg_alloc_order[i]) != '\0'; i++) + { + switch (ch) + { + case 'a': regno = 0; break; + case 'd': regno = 1; break; + case 'c': regno = 2; break; + case 'b': regno = 3; break; + case 'S': regno = 4; break; + case 'D': regno = 5; break; + case 'B': regno = 6; break; + + default: fatal ("Register '%c' is unknown", ch); + } + + if (regs_allocated[regno]) + fatal ("Register '%c' was already specified in the allocation order", ch); + + regs_allocated[regno] = 1; + } + } + + /* Validate -mregparm= value */ + if (i386_regparm_string) + { + i386_regparm = atoi (i386_regparm_string); + if (i386_regparm < 0 || i386_regparm > REGPARM_MAX) + fatal ("-mregparm=%d is not between 0 and %d", i386_regparm, REGPARM_MAX); + } + + def_align = (TARGET_386) ? 2 : 4; + + /* Validate -malign-loops= value, or provide default */ + if (i386_align_loops_string) + { + i386_align_loops = atoi (i386_align_loops_string); + if (i386_align_loops < 0 || i386_align_loops > MAX_CODE_ALIGN) + fatal ("-malign-loops=%d is not between 0 and %d", + i386_align_loops, MAX_CODE_ALIGN); + } + else + i386_align_loops = 2; + + /* Validate -malign-jumps= value, or provide default */ + if (i386_align_jumps_string) + { + i386_align_jumps = atoi (i386_align_jumps_string); + if (i386_align_jumps < 0 || i386_align_jumps > MAX_CODE_ALIGN) + fatal ("-malign-jumps=%d is not between 0 and %d", + i386_align_jumps, MAX_CODE_ALIGN); + } + else + i386_align_jumps = def_align; + + /* Validate -malign-functions= value, or provide default */ + if (i386_align_funcs_string) + { + i386_align_funcs = atoi (i386_align_funcs_string); + if (i386_align_funcs < 0 || i386_align_funcs > MAX_CODE_ALIGN) + fatal ("-malign-functions=%d is not between 0 and %d", + i386_align_funcs, MAX_CODE_ALIGN); + } + else + i386_align_funcs = def_align; +} + +/* A C statement (sans semicolon) to choose the order in which to + allocate hard registers for pseudo-registers local to a basic + block. + + Store the desired register order in the array `reg_alloc_order'. + Element 0 should be the register to allocate first; element 1, the + next register; and so on. + + The macro body should not assume anything about the contents of + `reg_alloc_order' before execution of the macro. + + On most machines, it is not necessary to define this macro. */ + +void +order_regs_for_local_alloc () +{ + int i, ch, order, regno; + + /* User specified the register allocation order */ + if (i386_reg_alloc_order) + { + for (i = order = 0; (ch = i386_reg_alloc_order[i]) != '\0'; i++) + { + switch (ch) + { + case 'a': regno = 0; break; + case 'd': regno = 1; break; + case 'c': regno = 2; break; + case 'b': regno = 3; break; + case 'S': regno = 4; break; + case 'D': regno = 5; break; + case 'B': regno = 6; break; + } + + reg_alloc_order[order++] = regno; + } + + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + { + if (!regs_allocated[i]) + reg_alloc_order[order++] = i; + } + } + + /* If users did not specify a register allocation order, favor eax + normally except if DImode variables are used, in which case + favor edx before eax, which seems to cause less spill register + not found messages. */ + else + { + rtx insn; + + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + reg_alloc_order[i] = i; + + if (optimize) + { + int use_dca = FALSE; + + for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) + { + if (GET_CODE (insn) == INSN) + { + rtx set = NULL_RTX; + rtx pattern = PATTERN (insn); + + if (GET_CODE (pattern) == SET) + set = pattern; + + else if ((GET_CODE (pattern) == PARALLEL + || GET_CODE (pattern) == SEQUENCE) + && GET_CODE (XVECEXP (pattern, 0, 0)) == SET) + set = XVECEXP (pattern, 0, 0); + + if (set && GET_MODE (SET_SRC (set)) == DImode) + { + use_dca = TRUE; + break; + } + } + } + + if (use_dca) + { + reg_alloc_order[0] = 1; /* edx */ + reg_alloc_order[1] = 2; /* ecx */ + reg_alloc_order[2] = 0; /* eax */ + } + } + } +} + + +/* Return nonzero if IDENTIFIER with arguments ARGS is a valid machine specific + attribute for DECL. The attributes in ATTRIBUTES have previously been + assigned to DECL. */ + +int +i386_valid_decl_attribute_p (decl, attributes, identifier, args) + tree decl; + tree attributes; + tree identifier; + tree args; +{ + return 0; +} + +/* Return nonzero if IDENTIFIER with arguments ARGS is a valid machine specific + attribute for TYPE. The attributes in ATTRIBUTES have previously been + assigned to TYPE. */ + +int +i386_valid_type_attribute_p (type, attributes, identifier, args) + tree type; + tree attributes; + tree identifier; + tree args; +{ + if (TREE_CODE (type) != FUNCTION_TYPE + && TREE_CODE (type) != FIELD_DECL + && TREE_CODE (type) != TYPE_DECL) + return 0; + + /* Stdcall attribute says callee is responsible for popping arguments + if they are not variable. */ + if (is_attribute_p ("stdcall", identifier)) + return (args == NULL_TREE); + + /* Cdecl attribute says the callee is a normal C declaration */ + if (is_attribute_p ("cdecl", identifier)) + return (args == NULL_TREE); + + /* Regparm attribute specifies how many integer arguments are to be + passed in registers */ + if (is_attribute_p ("regparm", identifier)) + { + tree cst; + + if (!args || TREE_CODE (args) != TREE_LIST + || TREE_CHAIN (args) != NULL_TREE + || TREE_VALUE (args) == NULL_TREE) + return 0; + + cst = TREE_VALUE (args); + if (TREE_CODE (cst) != INTEGER_CST) + return 0; + + if (TREE_INT_CST_HIGH (cst) != 0 + || TREE_INT_CST_LOW (cst) < 0 + || TREE_INT_CST_LOW (cst) > REGPARM_MAX) + return 0; + + return 1; + } + + return 0; +} + +/* Return 0 if the attributes for two types are incompatible, 1 if they + are compatible, and 2 if they are nearly compatible (which causes a + warning to be generated). */ + +int +i386_comp_type_attributes (type1, type2) + tree type1; + tree type2; +{ + return 1; +} + + +/* Value is the number of bytes of arguments automatically + popped when returning from a subroutine call. + FUNDECL is the declaration node of the function (as a tree), + FUNTYPE is the data type of the function (as a tree), + or for a library call it is an identifier node for the subroutine name. + SIZE is the number of bytes of arguments passed on the stack. + + On the 80386, the RTD insn may be used to pop them if the number + of args is fixed, but if the number is variable then the caller + must pop them all. RTD can't be used for library calls now + because the library is compiled with the Unix compiler. + Use of RTD is a selectable option, since it is incompatible with + standard Unix calling sequences. If the option is not selected, + the caller must always pop the args. + + The attribute stdcall is equivalent to RTD on a per module basis. */ + +int +i386_return_pops_args (fundecl, funtype, size) + tree fundecl; + tree funtype; + int size; +{ + int rtd = TARGET_RTD; + + if (TREE_CODE (funtype) == IDENTIFIER_NODE) + return 0; + + /* Cdecl functions override -mrtd, and never pop the stack */ + if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (funtype))) + return 0; + + /* Stdcall functions will pop the stack if not variable args */ + if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (funtype))) + rtd = 1; + + if (rtd) + { + if (TYPE_ARG_TYPES (funtype) == NULL_TREE + || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (funtype))) == void_type_node)) + return size; + + if (aggregate_value_p (TREE_TYPE (funtype))) + return GET_MODE_SIZE (Pmode); + } + + return 0; +} + + +/* Argument support functions. */ + +/* Initialize a variable CUM of type CUMULATIVE_ARGS + for a call to a function whose data type is FNTYPE. + For a library call, FNTYPE is 0. */ + +void +init_cumulative_args (cum, fntype, libname) + CUMULATIVE_ARGS *cum; /* argument info to initialize */ + tree fntype; /* tree ptr for function decl */ + rtx libname; /* SYMBOL_REF of library name or 0 */ +{ + static CUMULATIVE_ARGS zero_cum; + tree param, next_param; + + if (TARGET_DEBUG_ARG) + { + fprintf (stderr, "\ninit_cumulative_args ("); + if (fntype) + { + tree ret_type = TREE_TYPE (fntype); + fprintf (stderr, "fntype code = %s, ret code = %s", + tree_code_name[ (int)TREE_CODE (fntype) ], + tree_code_name[ (int)TREE_CODE (ret_type) ]); + } + else + fprintf (stderr, "no fntype"); + + if (libname) + fprintf (stderr, ", libname = %s", XSTR (libname, 0)); + } + + *cum = zero_cum; + + /* Set up the number of registers to use for passing arguments. */ + cum->nregs = i386_regparm; + if (fntype) + { + tree attr = lookup_attribute ("regparm", TYPE_ATTRIBUTES (fntype)); + if (attr) + cum->nregs = TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attr))); + } + + /* Determine if this function has variable arguments. This is + indicated by the last argument being 'void_type_mode' if there + are no variable arguments. If there are variable arguments, then + we won't pass anything in registers */ + + if (cum->nregs) + { + for (param = (fntype) ? TYPE_ARG_TYPES (fntype) : 0; + param != (tree)0; + param = next_param) + { + next_param = TREE_CHAIN (param); + if (next_param == (tree)0 && TREE_VALUE (param) != void_type_node) + cum->nregs = 0; + } + } + + if (TARGET_DEBUG_ARG) + fprintf (stderr, ", nregs=%d )\n", cum->nregs); + + return; +} + +/* Update the data in CUM to advance over an argument + of mode MODE and data type TYPE. + (TYPE is null for libcalls where that information may not be available.) */ + +void +function_arg_advance (cum, mode, type, named) + CUMULATIVE_ARGS *cum; /* current arg information */ + enum machine_mode mode; /* current arg mode */ + tree type; /* type of the argument or 0 if lib support */ + int named; /* whether or not the argument was named */ +{ + int bytes = (mode == BLKmode) ? int_size_in_bytes (type) : GET_MODE_SIZE (mode); + int words = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD; + + if (TARGET_DEBUG_ARG) + fprintf (stderr, + "function_adv( size=%d, words=%2d, nregs=%d, mode=%4s, named=%d )\n\n", + words, cum->words, cum->nregs, GET_MODE_NAME (mode), named); + + cum->words += words; + cum->nregs -= words; + cum->regno += words; + + if (cum->nregs <= 0) + { + cum->nregs = 0; + cum->regno = 0; + } + + return; +} + +/* Define where to put the arguments to a function. + Value is zero to push the argument on the stack, + or a hard register in which to store the argument. + + MODE is the argument's machine mode. + TYPE is the data type of the argument (as a tree). + This is null for libcalls where that information may + not be available. + CUM is a variable of type CUMULATIVE_ARGS which gives info about + the preceding args and about the function being called. + NAMED is nonzero if this argument is a named parameter + (otherwise it is an extra parameter matching an ellipsis). */ + +struct rtx_def * +function_arg (cum, mode, type, named) + CUMULATIVE_ARGS *cum; /* current arg information */ + enum machine_mode mode; /* current arg mode */ + tree type; /* type of the argument or 0 if lib support */ + int named; /* != 0 for normal args, == 0 for ... args */ +{ + rtx ret = NULL_RTX; + int bytes = (mode == BLKmode) ? int_size_in_bytes (type) : GET_MODE_SIZE (mode); + int words = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD; + + switch (mode) + { + default: /* for now, pass fp/complex values on the stack */ + break; + + case BLKmode: + case DImode: + case SImode: + case HImode: + case QImode: + if (words <= cum->nregs) + ret = gen_rtx (REG, mode, cum->regno); + break; + } + + if (TARGET_DEBUG_ARG) + { + fprintf (stderr, + "function_arg( size=%d, words=%2d, nregs=%d, mode=%4s, named=%d", + words, cum->words, cum->nregs, GET_MODE_NAME (mode), named); + + if (ret) + fprintf (stderr, ", reg=%%e%s", reg_names[ REGNO(ret) ]); + else + fprintf (stderr, ", stack"); + + fprintf (stderr, " )\n"); + } + + return ret; +} + +/* For an arg passed partly in registers and partly in memory, + this is the number of registers used. + For args passed entirely in registers or entirely in memory, zero. */ + +int +function_arg_partial_nregs (cum, mode, type, named) + CUMULATIVE_ARGS *cum; /* current arg information */ + enum machine_mode mode; /* current arg mode */ + tree type; /* type of the argument or 0 if lib support */ + int named; /* != 0 for normal args, == 0 for ... args */ +{ + return 0; +} + + +/* Output an insn whose source is a 386 integer register. SRC is the + rtx for the register, and TEMPLATE is the op-code template. SRC may + be either SImode or DImode. + + The template will be output with operands[0] as SRC, and operands[1] + as a pointer to the top of the 386 stack. So a call from floatsidf2 + would look like this: + + output_op_from_reg (operands[1], AS1 (fild%z0,%1)); + + where %z0 corresponds to the caller's operands[1], and is used to + emit the proper size suffix. + + ??? Extend this to handle HImode - a 387 can load and store HImode + values directly. */ + +void +output_op_from_reg (src, template) + rtx src; + char *template; +{ + rtx xops[4]; + int size = GET_MODE_SIZE (GET_MODE (src)); + + xops[0] = src; + xops[1] = AT_SP (Pmode); + xops[2] = GEN_INT (size); + xops[3] = stack_pointer_rtx; + + if (size > UNITS_PER_WORD) + { + rtx high; + if (size > 2 * UNITS_PER_WORD) + { + high = gen_rtx (REG, SImode, REGNO (src) + 2); + output_asm_insn (AS1 (push%L0,%0), &high); + } + high = gen_rtx (REG, SImode, REGNO (src) + 1); + output_asm_insn (AS1 (push%L0,%0), &high); + } + output_asm_insn (AS1 (push%L0,%0), &src); + + output_asm_insn (template, xops); + + output_asm_insn (AS2 (add%L3,%2,%3), xops); +} + +/* Output an insn to pop an value from the 387 top-of-stack to 386 + register DEST. The 387 register stack is popped if DIES is true. If + the mode of DEST is an integer mode, a `fist' integer store is done, + otherwise a `fst' float store is done. */ + +void +output_to_reg (dest, dies) + rtx dest; + int dies; +{ + rtx xops[4]; + int size = GET_MODE_SIZE (GET_MODE (dest)); + + xops[0] = AT_SP (Pmode); + xops[1] = stack_pointer_rtx; + xops[2] = GEN_INT (size); + xops[3] = dest; + + output_asm_insn (AS2 (sub%L1,%2,%1), xops); + + if (GET_MODE_CLASS (GET_MODE (dest)) == MODE_INT) + { + if (dies) + output_asm_insn (AS1 (fistp%z3,%y0), xops); + else + output_asm_insn (AS1 (fist%z3,%y0), xops); + } + else if (GET_MODE_CLASS (GET_MODE (dest)) == MODE_FLOAT) + { + if (dies) + output_asm_insn (AS1 (fstp%z3,%y0), xops); + else + { + if (GET_MODE (dest) == XFmode) + { + output_asm_insn (AS1 (fstp%z3,%y0), xops); + output_asm_insn (AS1 (fld%z3,%y0), xops); + } + else + output_asm_insn (AS1 (fst%z3,%y0), xops); + } + } + else + abort (); + + output_asm_insn (AS1 (pop%L0,%0), &dest); + + if (size > UNITS_PER_WORD) + { + dest = gen_rtx (REG, SImode, REGNO (dest) + 1); + output_asm_insn (AS1 (pop%L0,%0), &dest); + if (size > 2 * UNITS_PER_WORD) + { + dest = gen_rtx (REG, SImode, REGNO (dest) + 1); + output_asm_insn (AS1 (pop%L0,%0), &dest); + } + } +} + +char * +singlemove_string (operands) + rtx *operands; +{ + rtx x; + if (GET_CODE (operands[0]) == MEM + && GET_CODE (x = XEXP (operands[0], 0)) == PRE_DEC) + { + if (XEXP (x, 0) != stack_pointer_rtx) + abort (); + return "push%L1 %1"; + } + else if (GET_CODE (operands[1]) == CONST_DOUBLE) + { + return output_move_const_single (operands); + } + else if (GET_CODE (operands[0]) == REG || GET_CODE (operands[1]) == REG) + return AS2 (mov%L0,%1,%0); + else if (CONSTANT_P (operands[1])) + return AS2 (mov%L0,%1,%0); + else + { + output_asm_insn ("push%L1 %1", operands); + return "pop%L0 %0"; + } +} + +/* Return a REG that occurs in ADDR with coefficient 1. + ADDR can be effectively incremented by incrementing REG. */ + +static rtx +find_addr_reg (addr) + rtx addr; +{ + while (GET_CODE (addr) == PLUS) + { + if (GET_CODE (XEXP (addr, 0)) == REG) + addr = XEXP (addr, 0); + else if (GET_CODE (XEXP (addr, 1)) == REG) + addr = XEXP (addr, 1); + else if (CONSTANT_P (XEXP (addr, 0))) + addr = XEXP (addr, 1); + else if (CONSTANT_P (XEXP (addr, 1))) + addr = XEXP (addr, 0); + else + abort (); + } + if (GET_CODE (addr) == REG) + return addr; + abort (); +} + + +/* Output an insn to add the constant N to the register X. */ + +static void +asm_add (n, x) + int n; + rtx x; +{ + rtx xops[2]; + xops[0] = x; + + if (n == -1) + output_asm_insn (AS1 (dec%L0,%0), xops); + else if (n == 1) + output_asm_insn (AS1 (inc%L0,%0), xops); + else if (n < 0) + { + xops[1] = GEN_INT (-n); + output_asm_insn (AS2 (sub%L0,%1,%0), xops); + } + else if (n > 0) + { + xops[1] = GEN_INT (n); + output_asm_insn (AS2 (add%L0,%1,%0), xops); + } +} + + +/* Output assembler code to perform a doubleword move insn + with operands OPERANDS. */ + +char * +output_move_double (operands) + rtx *operands; +{ + enum {REGOP, OFFSOP, MEMOP, PUSHOP, POPOP, CNSTOP, RNDOP } optype0, optype1; + rtx latehalf[2]; + rtx middlehalf[2]; + rtx xops[2]; + rtx addreg0 = 0, addreg1 = 0; + int dest_overlapped_low = 0; + int size = GET_MODE_SIZE (GET_MODE (operands[0])); + + middlehalf[0] = 0; + middlehalf[1] = 0; + + /* First classify both operands. */ + + if (REG_P (operands[0])) + optype0 = REGOP; + else if (offsettable_memref_p (operands[0])) + optype0 = OFFSOP; + else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC) + optype0 = POPOP; + else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) + optype0 = PUSHOP; + else if (GET_CODE (operands[0]) == MEM) + optype0 = MEMOP; + else + optype0 = RNDOP; + + if (REG_P (operands[1])) + optype1 = REGOP; + else if (CONSTANT_P (operands[1])) + optype1 = CNSTOP; + else if (offsettable_memref_p (operands[1])) + optype1 = OFFSOP; + else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC) + optype1 = POPOP; + else if (GET_CODE (XEXP (operands[1], 0)) == PRE_DEC) + optype1 = PUSHOP; + else if (GET_CODE (operands[1]) == MEM) + optype1 = MEMOP; + else + optype1 = RNDOP; + + /* Check for the cases that the operand constraints are not + supposed to allow to happen. Abort if we get one, + because generating code for these cases is painful. */ + + if (optype0 == RNDOP || optype1 == RNDOP) + abort (); + + /* If one operand is decrementing and one is incrementing + decrement the former register explicitly + and change that operand into ordinary indexing. */ + + if (optype0 == PUSHOP && optype1 == POPOP) + { + /* ??? Can this ever happen on i386? */ + operands[0] = XEXP (XEXP (operands[0], 0), 0); + asm_add (-size, operands[0]); + if (GET_MODE (operands[1]) == XFmode) + operands[0] = gen_rtx (MEM, XFmode, operands[0]); + else if (GET_MODE (operands[0]) == DFmode) + operands[0] = gen_rtx (MEM, DFmode, operands[0]); + else + operands[0] = gen_rtx (MEM, DImode, operands[0]); + optype0 = OFFSOP; + } + + if (optype0 == POPOP && optype1 == PUSHOP) + { + /* ??? Can this ever happen on i386? */ + operands[1] = XEXP (XEXP (operands[1], 0), 0); + asm_add (-size, operands[1]); + if (GET_MODE (operands[1]) == XFmode) + operands[1] = gen_rtx (MEM, XFmode, operands[1]); + else if (GET_MODE (operands[1]) == DFmode) + operands[1] = gen_rtx (MEM, DFmode, operands[1]); + else + operands[1] = gen_rtx (MEM, DImode, operands[1]); + optype1 = OFFSOP; + } + + /* If an operand is an unoffsettable memory ref, find a register + we can increment temporarily to make it refer to the second word. */ + + if (optype0 == MEMOP) + addreg0 = find_addr_reg (XEXP (operands[0], 0)); + + if (optype1 == MEMOP) + addreg1 = find_addr_reg (XEXP (operands[1], 0)); + + /* Ok, we can do one word at a time. + Normally we do the low-numbered word first, + but if either operand is autodecrementing then we + do the high-numbered word first. + + In either case, set up in LATEHALF the operands to use + for the high-numbered word and in some cases alter the + operands in OPERANDS to be suitable for the low-numbered word. */ + + if (size == 12) + { + if (optype0 == REGOP) + { + middlehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); + latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 2); + } + else if (optype0 == OFFSOP) + { + middlehalf[0] = adj_offsettable_operand (operands[0], 4); + latehalf[0] = adj_offsettable_operand (operands[0], 8); + } + else + { + middlehalf[0] = operands[0]; + latehalf[0] = operands[0]; + } + + if (optype1 == REGOP) + { + middlehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); + latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); + } + else if (optype1 == OFFSOP) + { + middlehalf[1] = adj_offsettable_operand (operands[1], 4); + latehalf[1] = adj_offsettable_operand (operands[1], 8); + } + else if (optype1 == CNSTOP) + { + if (GET_CODE (operands[1]) == CONST_DOUBLE) + { + REAL_VALUE_TYPE r; long l[3]; + + REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]); + REAL_VALUE_TO_TARGET_LONG_DOUBLE (r, l); + operands[1] = GEN_INT (l[0]); + middlehalf[1] = GEN_INT (l[1]); + latehalf[1] = GEN_INT (l[2]); + } + else if (CONSTANT_P (operands[1])) + /* No non-CONST_DOUBLE constant should ever appear here. */ + abort (); + } + else + { + middlehalf[1] = operands[1]; + latehalf[1] = operands[1]; + } + } + else /* size is not 12: */ + { + if (optype0 == REGOP) + latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); + else if (optype0 == OFFSOP) + latehalf[0] = adj_offsettable_operand (operands[0], 4); + else + latehalf[0] = operands[0]; + + if (optype1 == REGOP) + latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); + else if (optype1 == OFFSOP) + latehalf[1] = adj_offsettable_operand (operands[1], 4); + else if (optype1 == CNSTOP) + split_double (operands[1], &operands[1], &latehalf[1]); + else + latehalf[1] = operands[1]; + } + + /* If insn is effectively movd N (sp),-(sp) then we will do the + high word first. We should use the adjusted operand 1 + (which is N+4 (sp) or N+8 (sp)) + for the low word and middle word as well, + to compensate for the first decrement of sp. */ + if (optype0 == PUSHOP + && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM + && reg_overlap_mentioned_p (stack_pointer_rtx, operands[1])) + middlehalf[1] = operands[1] = latehalf[1]; + + /* For (set (reg:DI N) (mem:DI ... (reg:SI N) ...)), + if the upper part of reg N does not appear in the MEM, arrange to + emit the move late-half first. Otherwise, compute the MEM address + into the upper part of N and use that as a pointer to the memory + operand. */ + if (optype0 == REGOP + && (optype1 == OFFSOP || optype1 == MEMOP)) + { + if (reg_mentioned_p (operands[0], XEXP (operands[1], 0)) + && reg_mentioned_p (latehalf[0], XEXP (operands[1], 0))) + { + /* If both halves of dest are used in the src memory address, + compute the address into latehalf of dest. */ +compadr: + xops[0] = latehalf[0]; + xops[1] = XEXP (operands[1], 0); + output_asm_insn (AS2 (lea%L0,%a1,%0), xops); + if( GET_MODE (operands[1]) == XFmode ) + { +/* abort (); */ + operands[1] = gen_rtx (MEM, XFmode, latehalf[0]); + middlehalf[1] = adj_offsettable_operand (operands[1], size-8); + latehalf[1] = adj_offsettable_operand (operands[1], size-4); + } + else + { + operands[1] = gen_rtx (MEM, DImode, latehalf[0]); + latehalf[1] = adj_offsettable_operand (operands[1], size-4); + } + } + else if (size == 12 + && reg_mentioned_p (middlehalf[0], XEXP (operands[1], 0))) + { + /* Check for two regs used by both source and dest. */ + if (reg_mentioned_p (operands[0], XEXP (operands[1], 0)) + || reg_mentioned_p (latehalf[0], XEXP (operands[1], 0))) + goto compadr; + + /* JRV says this can't happen: */ + if (addreg0 || addreg1) + abort(); + + /* Only the middle reg conflicts; simply put it last. */ + output_asm_insn (singlemove_string (operands), operands); + output_asm_insn (singlemove_string (latehalf), latehalf); + output_asm_insn (singlemove_string (middlehalf), middlehalf); + return ""; + } + else if (reg_mentioned_p (operands[0], XEXP (operands[1], 0))) + /* If the low half of dest is mentioned in the source memory + address, the arrange to emit the move late half first. */ + dest_overlapped_low = 1; + } + + /* If one or both operands autodecrementing, + do the two words, high-numbered first. */ + + /* Likewise, the first move would clobber the source of the second one, + do them in the other order. This happens only for registers; + such overlap can't happen in memory unless the user explicitly + sets it up, and that is an undefined circumstance. */ + +/* + if (optype0 == PUSHOP || optype1 == PUSHOP + || (optype0 == REGOP && optype1 == REGOP + && REGNO (operands[0]) == REGNO (latehalf[1])) + || dest_overlapped_low) +*/ + if (optype0 == PUSHOP || optype1 == PUSHOP + || (optype0 == REGOP && optype1 == REGOP + && ((middlehalf[1] && REGNO (operands[0]) == REGNO (middlehalf[1])) + || REGNO (operands[0]) == REGNO (latehalf[1]))) + || dest_overlapped_low) + { + /* Make any unoffsettable addresses point at high-numbered word. */ + if (addreg0) + asm_add (size-4, addreg0); + if (addreg1) + asm_add (size-4, addreg1); + + /* Do that word. */ + output_asm_insn (singlemove_string (latehalf), latehalf); + + /* Undo the adds we just did. */ + if (addreg0) + asm_add (-4, addreg0); + if (addreg1) + asm_add (-4, addreg1); + + if (size == 12) + { + output_asm_insn (singlemove_string (middlehalf), middlehalf); + if (addreg0) + asm_add (-4, addreg0); + if (addreg1) + asm_add (-4, addreg1); + } + + /* Do low-numbered word. */ + return singlemove_string (operands); + } + + /* Normal case: do the two words, low-numbered first. */ + + output_asm_insn (singlemove_string (operands), operands); + + /* Do the middle one of the three words for long double */ + if (size == 12) + { + if (addreg0) + asm_add (4, addreg0); + if (addreg1) + asm_add (4, addreg1); + + output_asm_insn (singlemove_string (middlehalf), middlehalf); + } + + /* Make any unoffsettable addresses point at high-numbered word. */ + if (addreg0) + asm_add (4, addreg0); + if (addreg1) + asm_add (4, addreg1); + + /* Do that word. */ + output_asm_insn (singlemove_string (latehalf), latehalf); + + /* Undo the adds we just did. */ + if (addreg0) + asm_add (4-size, addreg0); + if (addreg1) + asm_add (4-size, addreg1); + + return ""; +} + + +#define MAX_TMPS 2 /* max temporary registers used */ + +/* Output the appropriate code to move push memory on the stack */ + +char * +output_move_pushmem (operands, insn, length, tmp_start, n_operands) + rtx operands[]; + rtx insn; + int length; + int tmp_start; + int n_operands; +{ + + struct { + char *load; + char *push; + rtx xops[2]; + } tmp_info[MAX_TMPS]; + + rtx src = operands[1]; + int max_tmps = 0; + int offset = 0; + int stack_p = reg_overlap_mentioned_p (stack_pointer_rtx, src); + int stack_offset = 0; + int i, num_tmps; + rtx xops[1]; + + if (!offsettable_memref_p (src)) + fatal_insn ("Source is not offsettable", insn); + + if ((length & 3) != 0) + fatal_insn ("Pushing non-word aligned size", insn); + + /* Figure out which temporary registers we have available */ + for (i = tmp_start; i < n_operands; i++) + { + if (GET_CODE (operands[i]) == REG) + { + if (reg_overlap_mentioned_p (operands[i], src)) + continue; + + tmp_info[ max_tmps++ ].xops[1] = operands[i]; + if (max_tmps == MAX_TMPS) + break; + } + } + + if (max_tmps == 0) + for (offset = length - 4; offset >= 0; offset -= 4) + { + xops[0] = adj_offsettable_operand (src, offset + stack_offset); + output_asm_insn (AS1(push%L0,%0), xops); + if (stack_p) + stack_offset += 4; + } + + else + for (offset = length - 4; offset >= 0; ) + { + for (num_tmps = 0; num_tmps < max_tmps && offset >= 0; num_tmps++) + { + tmp_info[num_tmps].load = AS2(mov%L0,%0,%1); + tmp_info[num_tmps].push = AS1(push%L0,%1); + tmp_info[num_tmps].xops[0] = adj_offsettable_operand (src, offset + stack_offset); + offset -= 4; + } + + for (i = 0; i < num_tmps; i++) + output_asm_insn (tmp_info[i].load, tmp_info[i].xops); + + for (i = 0; i < num_tmps; i++) + output_asm_insn (tmp_info[i].push, tmp_info[i].xops); + + if (stack_p) + stack_offset += 4*num_tmps; + } + + return ""; +} + + + +/* Output the appropriate code to move data between two memory locations */ + +char * +output_move_memory (operands, insn, length, tmp_start, n_operands) + rtx operands[]; + rtx insn; + int length; + int tmp_start; + int n_operands; +{ + struct { + char *load; + char *store; + rtx xops[3]; + } tmp_info[MAX_TMPS]; + + rtx dest = operands[0]; + rtx src = operands[1]; + rtx qi_tmp = NULL_RTX; + int max_tmps = 0; + int offset = 0; + int i, num_tmps; + rtx xops[3]; + + if (GET_CODE (dest) == MEM + && GET_CODE (XEXP (dest, 0)) == PRE_INC + && XEXP (XEXP (dest, 0), 0) == stack_pointer_rtx) + return output_move_pushmem (operands, insn, length, tmp_start, n_operands); + + if (!offsettable_memref_p (src)) + fatal_insn ("Source is not offsettable", insn); + + if (!offsettable_memref_p (dest)) + fatal_insn ("Destination is not offsettable", insn); + + /* Figure out which temporary registers we have available */ + for (i = tmp_start; i < n_operands; i++) + { + if (GET_CODE (operands[i]) == REG) + { + if ((length & 1) != 0 && !qi_tmp && QI_REG_P (operands[i])) + qi_tmp = operands[i]; + + if (reg_overlap_mentioned_p (operands[i], dest)) + fatal_insn ("Temporary register overlaps the destination", insn); + + if (reg_overlap_mentioned_p (operands[i], src)) + fatal_insn ("Temporary register overlaps the source", insn); + + tmp_info[ max_tmps++ ].xops[2] = operands[i]; + if (max_tmps == MAX_TMPS) + break; + } + } + + if (max_tmps == 0) + fatal_insn ("No scratch registers were found to do memory->memory moves", insn); + + if ((length & 1) != 0) + { + if (!qi_tmp) + fatal_insn ("No byte register found when moving odd # of bytes.", insn); + } + + while (length > 1) + { + for (num_tmps = 0; num_tmps < max_tmps; num_tmps++) + { + if (length >= 4) + { + tmp_info[num_tmps].load = AS2(mov%L0,%1,%2); + tmp_info[num_tmps].store = AS2(mov%L0,%2,%0); + tmp_info[num_tmps].xops[0] = adj_offsettable_operand (dest, offset); + tmp_info[num_tmps].xops[1] = adj_offsettable_operand (src, offset); + offset += 4; + length -= 4; + } + else if (length >= 2) + { + tmp_info[num_tmps].load = AS2(mov%W0,%1,%2); + tmp_info[num_tmps].store = AS2(mov%W0,%2,%0); + tmp_info[num_tmps].xops[0] = adj_offsettable_operand (dest, offset); + tmp_info[num_tmps].xops[1] = adj_offsettable_operand (src, offset); + offset += 2; + length -= 2; + } + else + break; + } + + for (i = 0; i < num_tmps; i++) + output_asm_insn (tmp_info[i].load, tmp_info[i].xops); + + for (i = 0; i < num_tmps; i++) + output_asm_insn (tmp_info[i].store, tmp_info[i].xops); + } + + if (length == 1) + { + xops[0] = adj_offsettable_operand (dest, offset); + xops[1] = adj_offsettable_operand (src, offset); + xops[2] = qi_tmp; + output_asm_insn (AS2(mov%B0,%1,%2), xops); + output_asm_insn (AS2(mov%B0,%2,%0), xops); + } + + return ""; +} + + +int +standard_80387_constant_p (x) + rtx x; +{ +#if ! defined (REAL_IS_NOT_DOUBLE) || defined (REAL_ARITHMETIC) + REAL_VALUE_TYPE d; + jmp_buf handler; + int is0, is1; + + if (setjmp (handler)) + return 0; + + set_float_handler (handler); + REAL_VALUE_FROM_CONST_DOUBLE (d, x); + is0 = REAL_VALUES_EQUAL (d, dconst0); + is1 = REAL_VALUES_EQUAL (d, dconst1); + set_float_handler (NULL_PTR); + + if (is0) + return 1; + + if (is1) + return 2; + + /* Note that on the 80387, other constants, such as pi, + are much slower to load as standard constants + than to load from doubles in memory! */ +#endif + + return 0; +} + +char * +output_move_const_single (operands) + rtx *operands; +{ + if (FP_REG_P (operands[0])) + { + int conval = standard_80387_constant_p (operands[1]); + + if (conval == 1) + return "fldz"; + + if (conval == 2) + return "fld1"; + } + if (GET_CODE (operands[1]) == CONST_DOUBLE) + { + REAL_VALUE_TYPE r; long l; + + if (GET_MODE (operands[1]) == XFmode) + abort (); + + REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]); + REAL_VALUE_TO_TARGET_SINGLE (r, l); + operands[1] = GEN_INT (l); + } + return singlemove_string (operands); +} + +/* Returns 1 if OP is either a symbol reference or a sum of a symbol + reference and a constant. */ + +int +symbolic_operand (op, mode) + register rtx op; + enum machine_mode mode; +{ + switch (GET_CODE (op)) + { + case SYMBOL_REF: + case LABEL_REF: + return 1; + case CONST: + op = XEXP (op, 0); + return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF + || GET_CODE (XEXP (op, 0)) == LABEL_REF) + && GET_CODE (XEXP (op, 1)) == CONST_INT); + default: + return 0; + } +} + +/* Test for a valid operand for a call instruction. + Don't allow the arg pointer register or virtual regs + since they may change into reg + const, which the patterns + can't handle yet. */ + +int +call_insn_operand (op, mode) + rtx op; + enum machine_mode mode; +{ + if (GET_CODE (op) == MEM + && ((CONSTANT_ADDRESS_P (XEXP (op, 0)) + /* This makes a difference for PIC. */ + && general_operand (XEXP (op, 0), Pmode)) + || (GET_CODE (XEXP (op, 0)) == REG + && XEXP (op, 0) != arg_pointer_rtx + && !(REGNO (XEXP (op, 0)) >= FIRST_PSEUDO_REGISTER + && REGNO (XEXP (op, 0)) <= LAST_VIRTUAL_REGISTER)))) + return 1; + return 0; +} + +/* Like call_insn_operand but allow (mem (symbol_ref ...)) + even if pic. */ + +int +expander_call_insn_operand (op, mode) + rtx op; + enum machine_mode mode; +{ + if (GET_CODE (op) == MEM + && (CONSTANT_ADDRESS_P (XEXP (op, 0)) + || (GET_CODE (XEXP (op, 0)) == REG + && XEXP (op, 0) != arg_pointer_rtx + && !(REGNO (XEXP (op, 0)) >= FIRST_PSEUDO_REGISTER + && REGNO (XEXP (op, 0)) <= LAST_VIRTUAL_REGISTER)))) + return 1; + return 0; +} + +/* Return 1 if OP is a comparison operator that can use the condition code + generated by an arithmetic operation. */ + +int +arithmetic_comparison_operator (op, mode) + register rtx op; + enum machine_mode mode; +{ + enum rtx_code code; + + if (mode != VOIDmode && mode != GET_MODE (op)) + return 0; + code = GET_CODE (op); + if (GET_RTX_CLASS (code) != '<') + return 0; + + return (code != GT && code != LE); +} + +/* Returns 1 if OP contains a symbol reference */ + +int +symbolic_reference_mentioned_p (op) + rtx op; +{ + register char *fmt; + register int i; + + if (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == LABEL_REF) + return 1; + + fmt = GET_RTX_FORMAT (GET_CODE (op)); + for (i = GET_RTX_LENGTH (GET_CODE (op)) - 1; i >= 0; i--) + { + if (fmt[i] == 'E') + { + register int j; + + for (j = XVECLEN (op, i) - 1; j >= 0; j--) + if (symbolic_reference_mentioned_p (XVECEXP (op, i, j))) + return 1; + } + else if (fmt[i] == 'e' && symbolic_reference_mentioned_p (XEXP (op, i))) + return 1; + } + + return 0; +} + +/* This function generates the assembly code for function entry. + FILE is an stdio stream to output the code to. + SIZE is an int: how many units of temporary storage to allocate. */ + +void +function_prologue (file, size) + FILE *file; + int size; +{ + register int regno; + int limit; + rtx xops[4]; + int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table + || current_function_uses_const_pool); + + xops[0] = stack_pointer_rtx; + xops[1] = frame_pointer_rtx; + xops[2] = GEN_INT (size); + if (frame_pointer_needed) + { + output_asm_insn ("push%L1 %1", xops); + output_asm_insn (AS2 (mov%L0,%0,%1), xops); + } + + if (size) + output_asm_insn (AS2 (sub%L0,%2,%0), xops); + + /* Note If use enter it is NOT reversed args. + This one is not reversed from intel!! + I think enter is slower. Also sdb doesn't like it. + But if you want it the code is: + { + xops[3] = const0_rtx; + output_asm_insn ("enter %2,%3", xops); + } + */ + limit = (frame_pointer_needed ? FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM); + for (regno = limit - 1; regno >= 0; regno--) + if ((regs_ever_live[regno] && ! call_used_regs[regno]) + || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used)) + { + xops[0] = gen_rtx (REG, SImode, regno); + output_asm_insn ("push%L0 %0", xops); + } + + if (pic_reg_used) + { + xops[0] = pic_offset_table_rtx; + xops[1] = (rtx) gen_label_rtx (); + + output_asm_insn (AS1 (call,%P1), xops); + ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (xops[1])); + output_asm_insn (AS1 (pop%L0,%0), xops); + output_asm_insn ("addl $_GLOBAL_OFFSET_TABLE_+[.-%P1],%0", xops); + } +} + +/* Return 1 if it is appropriate to emit `ret' instructions in the + body of a function. Do this only if the epilogue is simple, needing a + couple of insns. Prior to reloading, we can't tell how many registers + must be saved, so return 0 then. + + If NON_SAVING_SETJMP is defined and true, then it is not possible + for the epilogue to be simple, so return 0. This is a special case + since NON_SAVING_SETJMP will not cause regs_ever_live to change until + final, but jump_optimize may need to know sooner if a `return' is OK. */ + +int +simple_386_epilogue () +{ + int regno; + int nregs = 0; + int reglimit = (frame_pointer_needed + ? FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM); + int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table + || current_function_uses_const_pool); + +#ifdef NON_SAVING_SETJMP + if (NON_SAVING_SETJMP && current_function_calls_setjmp) + return 0; +#endif + + if (! reload_completed) + return 0; + + for (regno = reglimit - 1; regno >= 0; regno--) + if ((regs_ever_live[regno] && ! call_used_regs[regno]) + || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used)) + nregs++; + + return nregs == 0 || ! frame_pointer_needed; +} + + +/* This function generates the assembly code for function exit. + FILE is an stdio stream to output the code to. + SIZE is an int: how many units of temporary storage to deallocate. */ + +void +function_epilogue (file, size) + FILE *file; + int size; +{ + register int regno; + register int nregs, limit; + int offset; + rtx xops[3]; + int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table + || current_function_uses_const_pool); + + /* Compute the number of registers to pop */ + + limit = (frame_pointer_needed + ? FRAME_POINTER_REGNUM + : STACK_POINTER_REGNUM); + + nregs = 0; + + for (regno = limit - 1; regno >= 0; regno--) + if ((regs_ever_live[regno] && ! call_used_regs[regno]) + || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used)) + nregs++; + + /* sp is often unreliable so we must go off the frame pointer, + */ + + /* In reality, we may not care if sp is unreliable, because we can + restore the register relative to the frame pointer. In theory, + since each move is the same speed as a pop, and we don't need the + leal, this is faster. For now restore multiple registers the old + way. */ + + offset = -size - (nregs * UNITS_PER_WORD); + + xops[2] = stack_pointer_rtx; + + if (nregs > 1 || ! frame_pointer_needed) + { + if (frame_pointer_needed) + { + xops[0] = adj_offsettable_operand (AT_BP (Pmode), offset); + output_asm_insn (AS2 (lea%L2,%0,%2), xops); + } + + for (regno = 0; regno < limit; regno++) + if ((regs_ever_live[regno] && ! call_used_regs[regno]) + || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used)) + { + xops[0] = gen_rtx (REG, SImode, regno); + output_asm_insn ("pop%L0 %0", xops); + } + } + else + for (regno = 0; regno < limit; regno++) + if ((regs_ever_live[regno] && ! call_used_regs[regno]) + || (regno == PIC_OFFSET_TABLE_REGNUM && pic_reg_used)) + { + xops[0] = gen_rtx (REG, SImode, regno); + xops[1] = adj_offsettable_operand (AT_BP (Pmode), offset); + output_asm_insn (AS2 (mov%L0,%1,%0), xops); + offset += 4; + } + + if (frame_pointer_needed) + { + /* On i486, mov & pop is faster than "leave". */ + + if (!TARGET_386) + { + xops[0] = frame_pointer_rtx; + output_asm_insn (AS2 (mov%L2,%0,%2), xops); + output_asm_insn ("pop%L0 %0", xops); + } + else + output_asm_insn ("leave", xops); + } + else if (size) + { + /* If there is no frame pointer, we must still release the frame. */ + + xops[0] = GEN_INT (size); + output_asm_insn (AS2 (add%L2,%0,%2), xops); + } + + if (current_function_pops_args && current_function_args_size) + { + xops[1] = GEN_INT (current_function_pops_args); + + /* i386 can only pop 32K bytes (maybe 64K? Is it signed?). If + asked to pop more, pop return address, do explicit add, and jump + indirectly to the caller. */ + + if (current_function_pops_args >= 32768) + { + /* ??? Which register to use here? */ + xops[0] = gen_rtx (REG, SImode, 2); + output_asm_insn ("pop%L0 %0", xops); + output_asm_insn (AS2 (add%L2,%1,%2), xops); + output_asm_insn ("jmp %*%0", xops); + } + else + output_asm_insn ("ret %1", xops); + } + else + output_asm_insn ("ret", xops); +} + + +/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression + that is a valid memory address for an instruction. + The MODE argument is the machine mode for the MEM expression + that wants to use this address. + + On x86, legitimate addresses are: + base movl (base),reg + displacement movl disp,reg + base + displacement movl disp(base),reg + index + base movl (base,index),reg + (index + base) + displacement movl disp(base,index),reg + index*scale movl (,index,scale),reg + index*scale + disp movl disp(,index,scale),reg + index*scale + base movl (base,index,scale),reg + (index*scale + base) + disp movl disp(base,index,scale),reg + + In each case, scale can be 1, 2, 4, 8. */ + +/* This is exactly the same as print_operand_addr, except that + it recognizes addresses instead of printing them. + + It only recognizes address in canonical form. LEGITIMIZE_ADDRESS should + convert common non-canonical forms to canonical form so that they will + be recognized. */ + +#define ADDR_INVALID(msg,insn) \ +do { \ + if (TARGET_DEBUG_ADDR) \ + { \ + fprintf (stderr, msg); \ + debug_rtx (insn); \ + } \ +} while (0) + +int +legitimate_address_p (mode, addr, strict) + enum machine_mode mode; + register rtx addr; + int strict; +{ + rtx base = NULL_RTX; + rtx indx = NULL_RTX; + rtx scale = NULL_RTX; + rtx disp = NULL_RTX; + + if (TARGET_DEBUG_ADDR) + { + fprintf (stderr, + "\n==========\nGO_IF_LEGITIMATE_ADDRESS, mode = %s, strict = %d\n", + GET_MODE_NAME (mode), strict); + + debug_rtx (addr); + } + + if (GET_CODE (addr) == REG || GET_CODE (addr) == SUBREG) + base = addr; /* base reg */ + + else if (GET_CODE (addr) == PLUS) + { + rtx op0 = XEXP (addr, 0); + rtx op1 = XEXP (addr, 1); + enum rtx_code code0 = GET_CODE (op0); + enum rtx_code code1 = GET_CODE (op1); + + if (code0 == REG || code0 == SUBREG) + { + if (code1 == REG || code1 == SUBREG) + { + indx = op0; /* index + base */ + base = op1; + } + + else + { + base = op0; /* base + displacement */ + disp = op1; + } + } + + else if (code0 == MULT) + { + indx = XEXP (op0, 0); + scale = XEXP (op0, 1); + + if (code1 == REG || code1 == SUBREG) + base = op1; /* index*scale + base */ + + else + disp = op1; /* index*scale + disp */ + } + + else if (code0 == PLUS && GET_CODE (XEXP (op0, 0)) == MULT) + { + indx = XEXP (XEXP (op0, 0), 0); /* index*scale + base + disp */ + scale = XEXP (XEXP (op0, 0), 1); + base = XEXP (op0, 1); + disp = op1; + } + + else if (code0 == PLUS) + { + indx = XEXP (op0, 0); /* index + base + disp */ + base = XEXP (op0, 1); + disp = op1; + } + + else + { + ADDR_INVALID ("PLUS subcode is not valid.\n", op0); + return FALSE; + } + } + + else if (GET_CODE (addr) == MULT) + { + indx = XEXP (addr, 0); /* index*scale */ + scale = XEXP (addr, 1); + } + + else + disp = addr; /* displacement */ + + /* Allow arg pointer and stack pointer as index if there is not scaling */ + if (base && indx && !scale + && (indx == arg_pointer_rtx || indx == stack_pointer_rtx)) + { + rtx tmp = base; + base = indx; + indx = tmp; + } + + /* Validate base register */ + /* Don't allow SUBREG's here, it can lead to spill failures when the base + is one word out of a two word structure, which is represented internally + as a DImode int. */ + if (base) + { + if (GET_CODE (base) != REG) + { + ADDR_INVALID ("Base is not a register.\n", base); + return FALSE; + } + + if ((strict && !REG_OK_FOR_BASE_STRICT_P (base)) + || (!strict && !REG_OK_FOR_BASE_NONSTRICT_P (base))) + { + ADDR_INVALID ("Base is not valid.\n", base); + return FALSE; + } + } + + /* Validate index register */ + /* Don't allow SUBREG's here, it can lead to spill failures when the index + is one word out of a two word structure, which is represented internally + as a DImode int. */ + if (indx) + { + if (GET_CODE (indx) != REG) + { + ADDR_INVALID ("Index is not a register.\n", indx); + return FALSE; + } + + if ((strict && !REG_OK_FOR_INDEX_STRICT_P (indx)) + || (!strict && !REG_OK_FOR_INDEX_NONSTRICT_P (indx))) + { + ADDR_INVALID ("Index is not valid.\n", indx); + return FALSE; + } + } + else if (scale) + abort (); /* scale w/o index invalid */ + + /* Validate scale factor */ + if (scale) + { + HOST_WIDE_INT value; + + if (GET_CODE (scale) != CONST_INT) + { + ADDR_INVALID ("Scale is not valid.\n", scale); + return FALSE; + } + + value = INTVAL (scale); + if (value != 1 && value != 2 && value != 4 && value != 8) + { + ADDR_INVALID ("Scale is not a good multiplier.\n", scale); + return FALSE; + } + } + + /* Validate displacement */ + if (disp) + { + if (!CONSTANT_ADDRESS_P (disp)) + { + ADDR_INVALID ("Displacement is not valid.\n", disp); + return FALSE; + } + + if (GET_CODE (disp) == CONST_DOUBLE) + { + ADDR_INVALID ("Displacement is a const_double.\n", disp); + return FALSE; + } + + if (flag_pic && SYMBOLIC_CONST (disp) && base != pic_offset_table_rtx + && (indx != pic_offset_table_rtx || scale != NULL_RTX)) + { + ADDR_INVALID ("Displacement is an invalid pic reference.\n", disp); + return FALSE; + } + + if (HALF_PIC_P () && HALF_PIC_ADDRESS_P (disp) + && (base != NULL_RTX || indx != NULL_RTX)) + { + ADDR_INVALID ("Displacement is an invalid half-pic reference.\n", disp); + return FALSE; + } + } + + if (TARGET_DEBUG_ADDR) + fprintf (stderr, "Address is valid.\n"); + + /* Everything looks valid, return true */ + return TRUE; +} + + +/* Return a legitimate reference for ORIG (an address) using the + register REG. If REG is 0, a new pseudo is generated. + + There are three types of references that must be handled: + + 1. Global data references must load the address from the GOT, via + the PIC reg. An insn is emitted to do this load, and the reg is + returned. + + 2. Static data references must compute the address as an offset + from the GOT, whose base is in the PIC reg. An insn is emitted to + compute the address into a reg, and the reg is returned. Static + data objects have SYMBOL_REF_FLAG set to differentiate them from + global data objects. + + 3. Constant pool addresses must be handled special. They are + considered legitimate addresses, but only if not used with regs. + When printed, the output routines know to print the reference with the + PIC reg, even though the PIC reg doesn't appear in the RTL. + + GO_IF_LEGITIMATE_ADDRESS rejects symbolic references unless the PIC + reg also appears in the address (except for constant pool references, + noted above). + + "switch" statements also require special handling when generating + PIC code. See comments by the `casesi' insn in i386.md for details. */ + +rtx +legitimize_pic_address (orig, reg) + rtx orig; + rtx reg; +{ + rtx addr = orig; + rtx new = orig; + + if (GET_CODE (addr) == SYMBOL_REF || GET_CODE (addr) == LABEL_REF) + { + if (GET_CODE (addr) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (addr)) + reg = new = orig; + else + { + if (reg == 0) + reg = gen_reg_rtx (Pmode); + + if ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FLAG (addr)) + || GET_CODE (addr) == LABEL_REF) + new = gen_rtx (PLUS, Pmode, pic_offset_table_rtx, orig); + else + new = gen_rtx (MEM, Pmode, + gen_rtx (PLUS, Pmode, + pic_offset_table_rtx, orig)); + + emit_move_insn (reg, new); + } + current_function_uses_pic_offset_table = 1; + return reg; + } + else if (GET_CODE (addr) == CONST || GET_CODE (addr) == PLUS) + { + rtx base; + + if (GET_CODE (addr) == CONST) + { + addr = XEXP (addr, 0); + if (GET_CODE (addr) != PLUS) + abort (); + } + + if (XEXP (addr, 0) == pic_offset_table_rtx) + return orig; + + if (reg == 0) + reg = gen_reg_rtx (Pmode); + + base = legitimize_pic_address (XEXP (addr, 0), reg); + addr = legitimize_pic_address (XEXP (addr, 1), + base == reg ? NULL_RTX : reg); + + if (GET_CODE (addr) == CONST_INT) + return plus_constant (base, INTVAL (addr)); + + if (GET_CODE (addr) == PLUS && CONSTANT_P (XEXP (addr, 1))) + { + base = gen_rtx (PLUS, Pmode, base, XEXP (addr, 0)); + addr = XEXP (addr, 1); + } + return gen_rtx (PLUS, Pmode, base, addr); + } + return new; +} + + +/* Emit insns to move operands[1] into operands[0]. */ + +void +emit_pic_move (operands, mode) + rtx *operands; + enum machine_mode mode; +{ + rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode); + + if (GET_CODE (operands[0]) == MEM && SYMBOLIC_CONST (operands[1])) + operands[1] = (rtx) force_reg (SImode, operands[1]); + else + operands[1] = legitimize_pic_address (operands[1], temp); +} + + +/* Try machine-dependent ways of modifying an illegitimate address + to be legitimate. If we find one, return the new, valid address. + This macro is used in only one place: `memory_address' in explow.c. + + OLDX is the address as it was before break_out_memory_refs was called. + In some cases it is useful to look at this to decide what needs to be done. + + MODE and WIN are passed so that this macro can use + GO_IF_LEGITIMATE_ADDRESS. + + It is always safe for this macro to do nothing. It exists to recognize + opportunities to optimize the output. + + For the 80386, we handle X+REG by loading X into a register R and + using R+REG. R will go in a general reg and indexing will be used. + However, if REG is a broken-out memory address or multiplication, + nothing needs to be done because REG can certainly go in a general reg. + + When -fpic is used, special handling is needed for symbolic references. + See comments by legitimize_pic_address in i386.c for details. */ + +rtx +legitimize_address (x, oldx, mode) + register rtx x; + register rtx oldx; + enum machine_mode mode; +{ + int changed = 0; + unsigned log; + + if (TARGET_DEBUG_ADDR) + { + fprintf (stderr, "\n==========\nLEGITIMIZE_ADDRESS, mode = %s\n", GET_MODE_NAME (mode)); + debug_rtx (x); + } + + if (flag_pic && SYMBOLIC_CONST (x)) + return legitimize_pic_address (x, 0); + + /* Canonicalize shifts by 0, 1, 2, 3 into multiply */ + if (GET_CODE (x) == ASHIFT + && GET_CODE (XEXP (x, 1)) == CONST_INT + && (log = (unsigned)exact_log2 (INTVAL (XEXP (x, 1)))) < 4) + { + changed = 1; + x = gen_rtx (MULT, Pmode, + force_reg (Pmode, XEXP (x, 0)), + GEN_INT (1 << log)); + } + + if (GET_CODE (x) == PLUS) + { + /* Canonicalize shifts by 0, 1, 2, 3 into multiply */ + if (GET_CODE (XEXP (x, 0)) == ASHIFT + && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT + && (log = (unsigned)exact_log2 (INTVAL (XEXP (XEXP (x, 0), 1)))) < 4) + { + changed = 1; + XEXP (x, 0) = gen_rtx (MULT, Pmode, + force_reg (Pmode, XEXP (XEXP (x, 0), 0)), + GEN_INT (1 << log)); + } + + if (GET_CODE (XEXP (x, 1)) == ASHIFT + && GET_CODE (XEXP (XEXP (x, 1), 1)) == CONST_INT + && (log = (unsigned)exact_log2 (INTVAL (XEXP (XEXP (x, 1), 1)))) < 4) + { + changed = 1; + XEXP (x, 1) = gen_rtx (MULT, Pmode, + force_reg (Pmode, XEXP (XEXP (x, 1), 0)), + GEN_INT (1 << log)); + } + + /* Put multiply first if it isn't already */ + if (GET_CODE (XEXP (x, 1)) == MULT) + { + rtx tmp = XEXP (x, 0); + XEXP (x, 0) = XEXP (x, 1); + XEXP (x, 1) = tmp; + changed = 1; + } + + /* Canonicalize (plus (mult (reg) (const)) (plus (reg) (const))) + into (plus (plus (mult (reg) (const)) (reg)) (const)). This can be + created by virtual register instantiation, register elimination, and + similar optimizations. */ + if (GET_CODE (XEXP (x, 0)) == MULT && GET_CODE (XEXP (x, 1)) == PLUS) + { + changed = 1; + x = gen_rtx (PLUS, Pmode, + gen_rtx (PLUS, Pmode, XEXP (x, 0), XEXP (XEXP (x, 1), 0)), + XEXP (XEXP (x, 1), 1)); + } + + /* Canonicalize (plus (plus (mult (reg) (const)) (plus (reg) (const))) const) + into (plus (plus (mult (reg) (const)) (reg)) (const)). */ + else if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 0)) == PLUS + && GET_CODE (XEXP (XEXP (x, 0), 0)) == MULT + && GET_CODE (XEXP (XEXP (x, 0), 1)) == PLUS + && CONSTANT_P (XEXP (x, 1))) + { + rtx constant, other; + + if (GET_CODE (XEXP (x, 1)) == CONST_INT) + { + constant = XEXP (x, 1); + other = XEXP (XEXP (XEXP (x, 0), 1), 1); + } + else if (GET_CODE (XEXP (XEXP (XEXP (x, 0), 1), 1)) == CONST_INT) + { + constant = XEXP (XEXP (XEXP (x, 0), 1), 1); + other = XEXP (x, 1); + } + else + constant = 0; + + if (constant) + { + changed = 1; + x = gen_rtx (PLUS, Pmode, + gen_rtx (PLUS, Pmode, XEXP (XEXP (x, 0), 0), + XEXP (XEXP (XEXP (x, 0), 1), 0)), + plus_constant (other, INTVAL (constant))); + } + } + + if (changed && legitimate_address_p (mode, x, FALSE)) + return x; + + if (GET_CODE (XEXP (x, 0)) == MULT) + { + changed = 1; + XEXP (x, 0) = force_operand (XEXP (x, 0), 0); + } + + if (GET_CODE (XEXP (x, 1)) == MULT) + { + changed = 1; + XEXP (x, 1) = force_operand (XEXP (x, 1), 0); + } + + if (changed + && GET_CODE (XEXP (x, 1)) == REG + && GET_CODE (XEXP (x, 0)) == REG) + return x; + + if (flag_pic && SYMBOLIC_CONST (XEXP (x, 1))) + { + changed = 1; + x = legitimize_pic_address (x, 0); + } + + if (changed && legitimate_address_p (mode, x, FALSE)) + return x; + + if (GET_CODE (XEXP (x, 0)) == REG) + { + register rtx temp = gen_reg_rtx (Pmode); + register rtx val = force_operand (XEXP (x, 1), temp); + if (val != temp) + emit_move_insn (temp, val); + + XEXP (x, 1) = temp; + return x; + } + + else if (GET_CODE (XEXP (x, 1)) == REG) + { + register rtx temp = gen_reg_rtx (Pmode); + register rtx val = force_operand (XEXP (x, 0), temp); + if (val != temp) + emit_move_insn (temp, val); + + XEXP (x, 0) = temp; + return x; + } + } + + return x; +} + + +/* Print an integer constant expression in assembler syntax. Addition + and subtraction are the only arithmetic that may appear in these + expressions. FILE is the stdio stream to write to, X is the rtx, and + CODE is the operand print code from the output string. */ + +static void +output_pic_addr_const (file, x, code) + FILE *file; + rtx x; + int code; +{ + char buf[256]; + + switch (GET_CODE (x)) + { + case PC: + if (flag_pic) + putc ('.', file); + else + abort (); + break; + + case SYMBOL_REF: + case LABEL_REF: + if (GET_CODE (x) == SYMBOL_REF) + assemble_name (file, XSTR (x, 0)); + else + { + ASM_GENERATE_INTERNAL_LABEL (buf, "L", + CODE_LABEL_NUMBER (XEXP (x, 0))); + assemble_name (asm_out_file, buf); + } + + if (GET_CODE (x) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (x)) + fprintf (file, "@GOTOFF(%%ebx)"); + else if (code == 'P') + fprintf (file, "@PLT"); + else if (GET_CODE (x) == LABEL_REF) + fprintf (file, "@GOTOFF"); + else if (! SYMBOL_REF_FLAG (x)) + fprintf (file, "@GOT"); + else + fprintf (file, "@GOTOFF"); + + break; + + case CODE_LABEL: + ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x)); + assemble_name (asm_out_file, buf); + break; + + case CONST_INT: + fprintf (file, "%d", INTVAL (x)); + break; + + case CONST: + /* This used to output parentheses around the expression, + but that does not work on the 386 (either ATT or BSD assembler). */ + output_pic_addr_const (file, XEXP (x, 0), code); + break; + + case CONST_DOUBLE: + if (GET_MODE (x) == VOIDmode) + { + /* We can use %d if the number is <32 bits and positive. */ + if (CONST_DOUBLE_HIGH (x) || CONST_DOUBLE_LOW (x) < 0) + fprintf (file, "0x%x%08x", + CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x)); + else + fprintf (file, "%d", CONST_DOUBLE_LOW (x)); + } + else + /* We can't handle floating point constants; + PRINT_OPERAND must handle them. */ + output_operand_lossage ("floating constant misused"); + break; + + case PLUS: + /* Some assemblers need integer constants to appear last (eg masm). */ + if (GET_CODE (XEXP (x, 0)) == CONST_INT) + { + output_pic_addr_const (file, XEXP (x, 1), code); + if (INTVAL (XEXP (x, 0)) >= 0) + fprintf (file, "+"); + output_pic_addr_const (file, XEXP (x, 0), code); + } + else + { + output_pic_addr_const (file, XEXP (x, 0), code); + if (INTVAL (XEXP (x, 1)) >= 0) + fprintf (file, "+"); + output_pic_addr_const (file, XEXP (x, 1), code); + } + break; + + case MINUS: + output_pic_addr_const (file, XEXP (x, 0), code); + fprintf (file, "-"); + output_pic_addr_const (file, XEXP (x, 1), code); + break; + + default: + output_operand_lossage ("invalid expression as operand"); + } +} + +/* Meaning of CODE: + f -- float insn (print a CONST_DOUBLE as a float rather than in hex). + D,L,W,B,Q,S -- print the opcode suffix for specified size of operand. + R -- print the prefix for register names. + z -- print the opcode suffix for the size of the current operand. + * -- print a star (in certain assembler syntax) + w -- print the operand as if it's a "word" (HImode) even if it isn't. + c -- don't print special prefixes before constant operands. + J -- print the appropriate jump operand. +*/ + +void +print_operand (file, x, code) + FILE *file; + rtx x; + int code; +{ + if (code) + { + switch (code) + { + case '*': + if (USE_STAR) + putc ('*', file); + return; + + case 'L': + PUT_OP_SIZE (code, 'l', file); + return; + + case 'W': + PUT_OP_SIZE (code, 'w', file); + return; + + case 'B': + PUT_OP_SIZE (code, 'b', file); + return; + + case 'Q': + PUT_OP_SIZE (code, 'l', file); + return; + + case 'S': + PUT_OP_SIZE (code, 's', file); + return; + + case 'T': + PUT_OP_SIZE (code, 't', file); + return; + + case 'z': + /* 387 opcodes don't get size suffixes if the operands are + registers. */ + + if (STACK_REG_P (x)) + return; + + /* this is the size of op from size of operand */ + switch (GET_MODE_SIZE (GET_MODE (x))) + { + case 1: + PUT_OP_SIZE ('B', 'b', file); + return; + + case 2: + PUT_OP_SIZE ('W', 'w', file); + return; + + case 4: + if (GET_MODE (x) == SFmode) + { + PUT_OP_SIZE ('S', 's', file); + return; + } + else + PUT_OP_SIZE ('L', 'l', file); + return; + + case 12: + PUT_OP_SIZE ('T', 't', file); + return; + + case 8: + if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT) + { +#ifdef GAS_MNEMONICS + PUT_OP_SIZE ('Q', 'q', file); + return; +#else + PUT_OP_SIZE ('Q', 'l', file); /* Fall through */ +#endif + } + + PUT_OP_SIZE ('Q', 'l', file); + return; + } + + case 'b': + case 'w': + case 'k': + case 'h': + case 'y': + case 'P': + break; + + case 'J': + switch (GET_CODE (x)) + { + /* These conditions are appropriate for testing the result + of an arithmetic operation, not for a compare operation. + Cases GE, LT assume CC_NO_OVERFLOW true. All cases assume + CC_Z_IN_NOT_C false and not floating point. */ + case NE: fputs ("jne", file); return; + case EQ: fputs ("je", file); return; + case GE: fputs ("jns", file); return; + case LT: fputs ("js", file); return; + case GEU: fputs ("jmp", file); return; + case GTU: fputs ("jne", file); return; + case LEU: fputs ("je", file); return; + case LTU: fputs ("#branch never", file); return; + + /* no matching branches for GT nor LE */ + } + abort (); + + default: + { + char str[50]; + + sprintf (str, "invalid operand code `%c'", code); + output_operand_lossage (str); + } + } + } + if (GET_CODE (x) == REG) + { + PRINT_REG (x, code, file); + } + else if (GET_CODE (x) == MEM) + { + PRINT_PTR (x, file); + if (CONSTANT_ADDRESS_P (XEXP (x, 0))) + { + if (flag_pic) + output_pic_addr_const (file, XEXP (x, 0), code); + else + output_addr_const (file, XEXP (x, 0)); + } + else + output_address (XEXP (x, 0)); + } + else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == SFmode) + { + REAL_VALUE_TYPE r; long l; + REAL_VALUE_FROM_CONST_DOUBLE (r, x); + REAL_VALUE_TO_TARGET_SINGLE (r, l); + PRINT_IMMED_PREFIX (file); + fprintf (file, "0x%x", l); + } + /* These float cases don't actually occur as immediate operands. */ + else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == DFmode) + { + REAL_VALUE_TYPE r; char dstr[30]; + REAL_VALUE_FROM_CONST_DOUBLE (r, x); + REAL_VALUE_TO_DECIMAL (r, "%.22e", dstr); + fprintf (file, "%s", dstr); + } + else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == XFmode) + { + REAL_VALUE_TYPE r; char dstr[30]; + REAL_VALUE_FROM_CONST_DOUBLE (r, x); + REAL_VALUE_TO_DECIMAL (r, "%.22e", dstr); + fprintf (file, "%s", dstr); + } + else + { + if (code != 'P') + { + if (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE) + PRINT_IMMED_PREFIX (file); + else if (GET_CODE (x) == CONST || GET_CODE (x) == SYMBOL_REF + || GET_CODE (x) == LABEL_REF) + PRINT_OFFSET_PREFIX (file); + } + if (flag_pic) + output_pic_addr_const (file, x, code); + else + output_addr_const (file, x); + } +} + +/* Print a memory operand whose address is ADDR. */ + +void +print_operand_address (file, addr) + FILE *file; + register rtx addr; +{ + register rtx reg1, reg2, breg, ireg; + rtx offset; + + switch (GET_CODE (addr)) + { + case REG: + ADDR_BEG (file); + fprintf (file, "%se", RP); + fputs (hi_reg_name[REGNO (addr)], file); + ADDR_END (file); + break; + + case PLUS: + reg1 = 0; + reg2 = 0; + ireg = 0; + breg = 0; + offset = 0; + if (CONSTANT_ADDRESS_P (XEXP (addr, 0))) + { + offset = XEXP (addr, 0); + addr = XEXP (addr, 1); + } + else if (CONSTANT_ADDRESS_P (XEXP (addr, 1))) + { + offset = XEXP (addr, 1); + addr = XEXP (addr, 0); + } + if (GET_CODE (addr) != PLUS) ; + else if (GET_CODE (XEXP (addr, 0)) == MULT) + { + reg1 = XEXP (addr, 0); + addr = XEXP (addr, 1); + } + else if (GET_CODE (XEXP (addr, 1)) == MULT) + { + reg1 = XEXP (addr, 1); + addr = XEXP (addr, 0); + } + else if (GET_CODE (XEXP (addr, 0)) == REG) + { + reg1 = XEXP (addr, 0); + addr = XEXP (addr, 1); + } + else if (GET_CODE (XEXP (addr, 1)) == REG) + { + reg1 = XEXP (addr, 1); + addr = XEXP (addr, 0); + } + if (GET_CODE (addr) == REG || GET_CODE (addr) == MULT) + { + if (reg1 == 0) reg1 = addr; + else reg2 = addr; + addr = 0; + } + if (offset != 0) + { + if (addr != 0) abort (); + addr = offset; + } + if ((reg1 && GET_CODE (reg1) == MULT) + || (reg2 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg2)))) + { + breg = reg2; + ireg = reg1; + } + else if (reg1 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg1))) + { + breg = reg1; + ireg = reg2; + } + + if (ireg != 0 || breg != 0) + { + int scale = 1; + + if (addr != 0) + { + if (flag_pic) + output_pic_addr_const (file, addr, 0); + + else if (GET_CODE (addr) == LABEL_REF) + output_asm_label (addr); + + else + output_addr_const (file, addr); + } + + if (ireg != 0 && GET_CODE (ireg) == MULT) + { + scale = INTVAL (XEXP (ireg, 1)); + ireg = XEXP (ireg, 0); + } + + /* The stack pointer can only appear as a base register, + never an index register, so exchange the regs if it is wrong. */ + + if (scale == 1 && ireg && REGNO (ireg) == STACK_POINTER_REGNUM) + { + rtx tmp; + + tmp = breg; + breg = ireg; + ireg = tmp; + } + + /* output breg+ireg*scale */ + PRINT_B_I_S (breg, ireg, scale, file); + break; + } + + case MULT: + { + int scale; + if (GET_CODE (XEXP (addr, 0)) == CONST_INT) + { + scale = INTVAL (XEXP (addr, 0)); + ireg = XEXP (addr, 1); + } + else + { + scale = INTVAL (XEXP (addr, 1)); + ireg = XEXP (addr, 0); + } + output_addr_const (file, const0_rtx); + PRINT_B_I_S ((rtx) 0, ireg, scale, file); + } + break; + + default: + if (GET_CODE (addr) == CONST_INT + && INTVAL (addr) < 0x8000 + && INTVAL (addr) >= -0x8000) + fprintf (file, "%d", INTVAL (addr)); + else + { + if (flag_pic) + output_pic_addr_const (file, addr, 0); + else + output_addr_const (file, addr); + } + } +} + +/* Set the cc_status for the results of an insn whose pattern is EXP. + On the 80386, we assume that only test and compare insns, as well + as SI, HI, & DI mode ADD, SUB, NEG, AND, IOR, XOR, ASHIFT, + ASHIFTRT, and LSHIFTRT instructions set the condition codes usefully. + Also, we assume that jumps, moves and sCOND don't affect the condition + codes. All else clobbers the condition codes, by assumption. + + We assume that ALL integer add, minus, etc. instructions effect the + condition codes. This MUST be consistent with i386.md. + + We don't record any float test or compare - the redundant test & + compare check in final.c does not handle stack-like regs correctly. */ + +void +notice_update_cc (exp) + rtx exp; +{ + if (GET_CODE (exp) == SET) + { + /* Jumps do not alter the cc's. */ + if (SET_DEST (exp) == pc_rtx) + return; + /* Moving register or memory into a register: + it doesn't alter the cc's, but it might invalidate + the RTX's which we remember the cc's came from. + (Note that moving a constant 0 or 1 MAY set the cc's). */ + if (REG_P (SET_DEST (exp)) + && (REG_P (SET_SRC (exp)) || GET_CODE (SET_SRC (exp)) == MEM + || GET_RTX_CLASS (GET_CODE (SET_SRC (exp))) == '<')) + { + if (cc_status.value1 + && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value1)) + cc_status.value1 = 0; + if (cc_status.value2 + && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value2)) + cc_status.value2 = 0; + return; + } + /* Moving register into memory doesn't alter the cc's. + It may invalidate the RTX's which we remember the cc's came from. */ + if (GET_CODE (SET_DEST (exp)) == MEM + && (REG_P (SET_SRC (exp)) + || GET_RTX_CLASS (GET_CODE (SET_SRC (exp))) == '<')) + { + if (cc_status.value1 && GET_CODE (cc_status.value1) == MEM) + cc_status.value1 = 0; + if (cc_status.value2 && GET_CODE (cc_status.value2) == MEM) + cc_status.value2 = 0; + return; + } + /* Function calls clobber the cc's. */ + else if (GET_CODE (SET_SRC (exp)) == CALL) + { + CC_STATUS_INIT; + return; + } + /* Tests and compares set the cc's in predictable ways. */ + else if (SET_DEST (exp) == cc0_rtx) + { + CC_STATUS_INIT; + cc_status.value1 = SET_SRC (exp); + return; + } + /* Certain instructions effect the condition codes. */ + else if (GET_MODE (SET_SRC (exp)) == SImode + || GET_MODE (SET_SRC (exp)) == HImode + || GET_MODE (SET_SRC (exp)) == QImode) + switch (GET_CODE (SET_SRC (exp))) + { + case ASHIFTRT: case LSHIFTRT: + case ASHIFT: + /* Shifts on the 386 don't set the condition codes if the + shift count is zero. */ + if (GET_CODE (XEXP (SET_SRC (exp), 1)) != CONST_INT) + { + CC_STATUS_INIT; + break; + } + /* We assume that the CONST_INT is non-zero (this rtx would + have been deleted if it were zero. */ + + case PLUS: case MINUS: case NEG: + case AND: case IOR: case XOR: + cc_status.flags = CC_NO_OVERFLOW; + cc_status.value1 = SET_SRC (exp); + cc_status.value2 = SET_DEST (exp); + break; + + default: + CC_STATUS_INIT; + } + else + { + CC_STATUS_INIT; + } + } + else if (GET_CODE (exp) == PARALLEL + && GET_CODE (XVECEXP (exp, 0, 0)) == SET) + { + if (SET_DEST (XVECEXP (exp, 0, 0)) == pc_rtx) + return; + if (SET_DEST (XVECEXP (exp, 0, 0)) == cc0_rtx) + { + CC_STATUS_INIT; + if (stack_regs_mentioned_p (SET_SRC (XVECEXP (exp, 0, 0)))) + cc_status.flags |= CC_IN_80387; + else + cc_status.value1 = SET_SRC (XVECEXP (exp, 0, 0)); + return; + } + CC_STATUS_INIT; + } + else + { + CC_STATUS_INIT; + } +} + +/* Split one or more DImode RTL references into pairs of SImode + references. The RTL can be REG, offsettable MEM, integer constant, or + CONST_DOUBLE. "operands" is a pointer to an array of DImode RTL to + split and "num" is its length. lo_half and hi_half are output arrays + that parallel "operands". */ + +void +split_di (operands, num, lo_half, hi_half) + rtx operands[]; + int num; + rtx lo_half[], hi_half[]; +{ + while (num--) + { + if (GET_CODE (operands[num]) == REG) + { + lo_half[num] = gen_rtx (REG, SImode, REGNO (operands[num])); + hi_half[num] = gen_rtx (REG, SImode, REGNO (operands[num]) + 1); + } + else if (CONSTANT_P (operands[num])) + { + split_double (operands[num], &lo_half[num], &hi_half[num]); + } + else if (offsettable_memref_p (operands[num])) + { + lo_half[num] = operands[num]; + hi_half[num] = adj_offsettable_operand (operands[num], 4); + } + else + abort(); + } +} + +/* Return 1 if this is a valid binary operation on a 387. + OP is the expression matched, and MODE is its mode. */ + +int +binary_387_op (op, mode) + register rtx op; + enum machine_mode mode; +{ + if (mode != VOIDmode && mode != GET_MODE (op)) + return 0; + + switch (GET_CODE (op)) + { + case PLUS: + case MINUS: + case MULT: + case DIV: + return GET_MODE_CLASS (GET_MODE (op)) == MODE_FLOAT; + + default: + return 0; + } +} + + +/* Return 1 if this is a valid shift or rotate operation on a 386. + OP is the expression matched, and MODE is its mode. */ + +int +shift_op (op, mode) + register rtx op; + enum machine_mode mode; +{ + rtx operand = XEXP (op, 0); + + if (mode != VOIDmode && mode != GET_MODE (op)) + return 0; + + if (GET_MODE (operand) != GET_MODE (op) + || GET_MODE_CLASS (GET_MODE (op)) != MODE_INT) + return 0; + + return (GET_CODE (op) == ASHIFT + || GET_CODE (op) == ASHIFTRT + || GET_CODE (op) == LSHIFTRT + || GET_CODE (op) == ROTATE + || GET_CODE (op) == ROTATERT); +} + +/* Return 1 if OP is COMPARE rtx with mode VOIDmode. + MODE is not used. */ + +int +VOIDmode_compare_op (op, mode) + register rtx op; + enum machine_mode mode; +{ + return GET_CODE (op) == COMPARE && GET_MODE (op) == VOIDmode; +} + +/* Output code to perform a 387 binary operation in INSN, one of PLUS, + MINUS, MULT or DIV. OPERANDS are the insn operands, where operands[3] + is the expression of the binary operation. The output may either be + emitted here, or returned to the caller, like all output_* functions. + + There is no guarantee that the operands are the same mode, as they + might be within FLOAT or FLOAT_EXTEND expressions. */ + +char * +output_387_binary_op (insn, operands) + rtx insn; + rtx *operands; +{ + rtx temp; + char *base_op; + static char buf[100]; + + switch (GET_CODE (operands[3])) + { + case PLUS: + if (GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT + || GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT) + base_op = "fiadd"; + else + base_op = "fadd"; + break; + + case MINUS: + if (GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT + || GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT) + base_op = "fisub"; + else + base_op = "fsub"; + break; + + case MULT: + if (GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT + || GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT) + base_op = "fimul"; + else + base_op = "fmul"; + break; + + case DIV: + if (GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT + || GET_MODE_CLASS (GET_MODE (operands[2])) == MODE_INT) + base_op = "fidiv"; + else + base_op = "fdiv"; + break; + + default: + abort (); + } + + strcpy (buf, base_op); + + switch (GET_CODE (operands[3])) + { + case MULT: + case PLUS: + if (REG_P (operands[2]) && REGNO (operands[0]) == REGNO (operands[2])) + { + temp = operands[2]; + operands[2] = operands[1]; + operands[1] = temp; + } + + if (GET_CODE (operands[2]) == MEM) + return strcat (buf, AS1 (%z2,%2)); + + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], strcat (buf, AS1 (%z0,%1))); + RET; + } + else if (NON_STACK_REG_P (operands[2])) + { + output_op_from_reg (operands[2], strcat (buf, AS1 (%z0,%1))); + RET; + } + + if (find_regno_note (insn, REG_DEAD, REGNO (operands[2]))) + return strcat (buf, AS2 (p,%2,%0)); + + if (STACK_TOP_P (operands[0])) + return strcat (buf, AS2C (%y2,%0)); + else + return strcat (buf, AS2C (%2,%0)); + + case MINUS: + case DIV: + if (GET_CODE (operands[1]) == MEM) + return strcat (buf, AS1 (r%z1,%1)); + + if (GET_CODE (operands[2]) == MEM) + return strcat (buf, AS1 (%z2,%2)); + + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], strcat (buf, AS1 (r%z0,%1))); + RET; + } + else if (NON_STACK_REG_P (operands[2])) + { + output_op_from_reg (operands[2], strcat (buf, AS1 (%z0,%1))); + RET; + } + + if (! STACK_REG_P (operands[1]) || ! STACK_REG_P (operands[2])) + abort (); + + if (find_regno_note (insn, REG_DEAD, REGNO (operands[2]))) + return strcat (buf, AS2 (rp,%2,%0)); + + if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) + return strcat (buf, AS2 (p,%1,%0)); + + if (STACK_TOP_P (operands[0])) + { + if (STACK_TOP_P (operands[1])) + return strcat (buf, AS2C (%y2,%0)); + else + return strcat (buf, AS2 (r,%y1,%0)); + } + else if (STACK_TOP_P (operands[1])) + return strcat (buf, AS2C (%1,%0)); + else + return strcat (buf, AS2 (r,%2,%0)); + + default: + abort (); + } +} + +/* Output code for INSN to convert a float to a signed int. OPERANDS + are the insn operands. The output may be SFmode or DFmode and the + input operand may be SImode or DImode. As a special case, make sure + that the 387 stack top dies if the output mode is DImode, because the + hardware requires this. */ + +char * +output_fix_trunc (insn, operands) + rtx insn; + rtx *operands; +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + rtx xops[2]; + + if (! STACK_TOP_P (operands[1]) || + (GET_MODE (operands[0]) == DImode && ! stack_top_dies)) + abort (); + + xops[0] = GEN_INT (12); + xops[1] = operands[4]; + + output_asm_insn (AS1 (fnstc%W2,%2), operands); + output_asm_insn (AS2 (mov%L2,%2,%4), operands); + output_asm_insn (AS2 (mov%B1,%0,%h1), xops); + output_asm_insn (AS2 (mov%L4,%4,%3), operands); + output_asm_insn (AS1 (fldc%W3,%3), operands); + + if (NON_STACK_REG_P (operands[0])) + output_to_reg (operands[0], stack_top_dies); + else if (GET_CODE (operands[0]) == MEM) + { + if (stack_top_dies) + output_asm_insn (AS1 (fistp%z0,%0), operands); + else + output_asm_insn (AS1 (fist%z0,%0), operands); + } + else + abort (); + + return AS1 (fldc%W2,%2); +} + +/* Output code for INSN to compare OPERANDS. The two operands might + not have the same mode: one might be within a FLOAT or FLOAT_EXTEND + expression. If the compare is in mode CCFPEQmode, use an opcode that + will not fault if a qNaN is present. */ + +char * +output_float_compare (insn, operands) + rtx insn; + rtx *operands; +{ + int stack_top_dies; + rtx body = XVECEXP (PATTERN (insn), 0, 0); + int unordered_compare = GET_MODE (SET_SRC (body)) == CCFPEQmode; + + if (! STACK_TOP_P (operands[0])) + abort (); + + stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + if (STACK_REG_P (operands[1]) + && stack_top_dies + && find_regno_note (insn, REG_DEAD, REGNO (operands[1])) + && REGNO (operands[1]) != FIRST_STACK_REG) + { + /* If both the top of the 387 stack dies, and the other operand + is also a stack register that dies, then this must be a + `fcompp' float compare */ + + if (unordered_compare) + output_asm_insn ("fucompp", operands); + else + output_asm_insn ("fcompp", operands); + } + else + { + static char buf[100]; + + /* Decide if this is the integer or float compare opcode, or the + unordered float compare. */ + + if (unordered_compare) + strcpy (buf, "fucom"); + else if (GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_FLOAT) + strcpy (buf, "fcom"); + else + strcpy (buf, "ficom"); + + /* Modify the opcode if the 387 stack is to be popped. */ + + if (stack_top_dies) + strcat (buf, "p"); + + if (NON_STACK_REG_P (operands[1])) + output_op_from_reg (operands[1], strcat (buf, AS1 (%z0,%1))); + else + output_asm_insn (strcat (buf, AS1 (%z1,%y1)), operands); + } + + /* Now retrieve the condition code. */ + + return output_fp_cc0_set (insn); +} + +/* Output opcodes to transfer the results of FP compare or test INSN + from the FPU to the CPU flags. If TARGET_IEEE_FP, ensure that if the + result of the compare or test is unordered, no comparison operator + succeeds except NE. Return an output template, if any. */ + +char * +output_fp_cc0_set (insn) + rtx insn; +{ + rtx xops[3]; + rtx unordered_label; + rtx next; + enum rtx_code code; + + xops[0] = gen_rtx (REG, HImode, 0); + output_asm_insn (AS1 (fnsts%W0,%0), xops); + + if (! TARGET_IEEE_FP) + return "sahf"; + + next = next_cc0_user (insn); + if (next == NULL_RTX) + abort (); + + if (GET_CODE (next) == JUMP_INSN + && GET_CODE (PATTERN (next)) == SET + && SET_DEST (PATTERN (next)) == pc_rtx + && GET_CODE (SET_SRC (PATTERN (next))) == IF_THEN_ELSE) + { + code = GET_CODE (XEXP (SET_SRC (PATTERN (next)), 0)); + } + else if (GET_CODE (PATTERN (next)) == SET) + { + code = GET_CODE (SET_SRC (PATTERN (next))); + } + else + abort (); + + xops[0] = gen_rtx (REG, QImode, 0); + + switch (code) + { + case GT: + xops[1] = GEN_INT (0x45); + output_asm_insn (AS2 (and%B0,%1,%h0), xops); + /* je label */ + break; + + case LT: + xops[1] = GEN_INT (0x45); + xops[2] = GEN_INT (0x01); + output_asm_insn (AS2 (and%B0,%1,%h0), xops); + output_asm_insn (AS2 (cmp%B0,%2,%h0), xops); + /* je label */ + break; + + case GE: + xops[1] = GEN_INT (0x05); + output_asm_insn (AS2 (and%B0,%1,%h0), xops); + /* je label */ + break; + + case LE: + xops[1] = GEN_INT (0x45); + xops[2] = GEN_INT (0x40); + output_asm_insn (AS2 (and%B0,%1,%h0), xops); + output_asm_insn (AS1 (dec%B0,%h0), xops); + output_asm_insn (AS2 (cmp%B0,%2,%h0), xops); + /* jb label */ + break; + + case EQ: + xops[1] = GEN_INT (0x45); + xops[2] = GEN_INT (0x40); + output_asm_insn (AS2 (and%B0,%1,%h0), xops); + output_asm_insn (AS2 (cmp%B0,%2,%h0), xops); + /* je label */ + break; + + case NE: + xops[1] = GEN_INT (0x44); + xops[2] = GEN_INT (0x40); + output_asm_insn (AS2 (and%B0,%1,%h0), xops); + output_asm_insn (AS2 (xor%B0,%2,%h0), xops); + /* jne label */ + break; + + case GTU: + case LTU: + case GEU: + case LEU: + default: + abort (); + } + RET; +} + +#define MAX_386_STACK_LOCALS 2 + +static rtx i386_stack_locals[(int) MAX_MACHINE_MODE][MAX_386_STACK_LOCALS]; + +/* Define the structure for the machine field in struct function. */ +struct machine_function +{ + rtx i386_stack_locals[(int) MAX_MACHINE_MODE][MAX_386_STACK_LOCALS]; +}; + +/* Functions to save and restore i386_stack_locals. + These will be called, via pointer variables, + from push_function_context and pop_function_context. */ + +void +save_386_machine_status (p) + struct function *p; +{ + p->machine = (struct machine_function *) xmalloc (sizeof i386_stack_locals); + bcopy ((char *) i386_stack_locals, (char *) p->machine->i386_stack_locals, + sizeof i386_stack_locals); +} + +void +restore_386_machine_status (p) + struct function *p; +{ + bcopy ((char *) p->machine->i386_stack_locals, (char *) i386_stack_locals, + sizeof i386_stack_locals); + free (p->machine); +} + +/* Clear stack slot assignments remembered from previous functions. + This is called from INIT_EXPANDERS once before RTL is emitted for each + function. */ + +void +clear_386_stack_locals () +{ + enum machine_mode mode; + int n; + + for (mode = VOIDmode; (int) mode < (int) MAX_MACHINE_MODE; + mode = (enum machine_mode) ((int) mode + 1)) + for (n = 0; n < MAX_386_STACK_LOCALS; n++) + i386_stack_locals[(int) mode][n] = NULL_RTX; + + /* Arrange to save and restore i386_stack_locals around nested functions. */ + save_machine_status = save_386_machine_status; + restore_machine_status = restore_386_machine_status; +} + +/* Return a MEM corresponding to a stack slot with mode MODE. + Allocate a new slot if necessary. + + The RTL for a function can have several slots available: N is + which slot to use. */ + +rtx +assign_386_stack_local (mode, n) + enum machine_mode mode; + int n; +{ + if (n < 0 || n >= MAX_386_STACK_LOCALS) + abort (); + + if (i386_stack_locals[(int) mode][n] == NULL_RTX) + i386_stack_locals[(int) mode][n] + = assign_stack_local (mode, GET_MODE_SIZE (mode), 0); + + return i386_stack_locals[(int) mode][n]; +} diff --git a/support/cpp/i386/i386.h b/support/cpp/i386/i386.h new file mode 100644 index 00000000..1e44218e --- /dev/null +++ b/support/cpp/i386/i386.h @@ -0,0 +1,1934 @@ +/* Definitions of target machine for GNU compiler for Intel X86 + (386, 486, Pentium). + Copyright (C) 1988, 1992, 1994, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* The purpose of this file is to define the characteristics of the i386, + independent of assembler syntax or operating system. + + Three other files build on this one to describe a specific assembler syntax: + bsd386.h, att386.h, and sun386.h. + + The actual tm.h file for a particular system should include + this file, and then the file for the appropriate assembler syntax. + + Many macros that specify assembler syntax are omitted entirely from + this file because they really belong in the files for particular + assemblers. These include AS1, AS2, AS3, RP, IP, LPREFIX, L_SIZE, + PUT_OP_SIZE, USE_STAR, ADDR_BEG, ADDR_END, PRINT_IREG, PRINT_SCALE, + PRINT_B_I_S, and many that start with ASM_ or end in ASM_OP. */ + +/* Names to predefine in the preprocessor for this target machine. */ + +#define I386 1 + +/* Stubs for half-pic support if not OSF/1 reference platform. */ + +#ifndef HALF_PIC_P +#define HALF_PIC_P() 0 +#define HALF_PIC_NUMBER_PTRS 0 +#define HALF_PIC_NUMBER_REFS 0 +#define HALF_PIC_ENCODE(DECL) +#define HALF_PIC_DECLARE(NAME) +#define HALF_PIC_INIT() error ("half-pic init called on systems that don't support it.") +#define HALF_PIC_ADDRESS_P(X) 0 +#define HALF_PIC_PTR(X) X +#define HALF_PIC_FINISH(STREAM) +#endif + +/* Run-time compilation parameters selecting different hardware subsets. */ + +extern int target_flags; + +/* Macros used in the machine description to test the flags. */ + +/* configure can arrange to make this 2, to force a 486. */ +#ifndef TARGET_CPU_DEFAULT +#define TARGET_CPU_DEFAULT 0 +#endif + +/* Masks for the -m switches */ +#define MASK_80387 000000000001 /* Hardware floating point */ +#define MASK_486 000000000002 /* 80486 specific */ +#define MASK_NOTUSED1 000000000004 /* bit not currently used */ +#define MASK_RTD 000000000010 /* Use ret that pops args */ +#define MASK_ALIGN_DOUBLE 000000000020 /* align doubles to 2 word boundary */ +#define MASK_SVR3_SHLIB 000000000040 /* Uninit locals into bss */ +#define MASK_IEEE_FP 000000000100 /* IEEE fp comparisons */ +#define MASK_FLOAT_RETURNS 000000000200 /* Return float in st(0) */ +#define MASK_NO_FANCY_MATH_387 000000000400 /* Disable sin, cos, sqrt */ + + /* Temporary codegen switches */ +#define MASK_DEBUG_ADDR 000001000000 /* Debug GO_IF_LEGITIMATE_ADDRESS */ +#define MASK_NO_WIDE_MULTIPLY 000002000000 /* Disable 32x32->64 multiplies */ +#define MASK_NO_MOVE 000004000000 /* Don't generate mem->mem */ +#define MASK_DEBUG_ARG 000010000000 /* Debug function_arg */ + +/* Use the floating point instructions */ +#define TARGET_80387 (target_flags & MASK_80387) + +/* Compile using ret insn that pops args. + This will not work unless you use prototypes at least + for all functions that can take varying numbers of args. */ +#define TARGET_RTD (target_flags & MASK_RTD) + +/* Align doubles to a two word boundary. This breaks compatibility with + the published ABI's for structures containing doubles, but produces + faster code on the pentium. */ +#define TARGET_ALIGN_DOUBLE (target_flags & MASK_ALIGN_DOUBLE) + +/* Put uninitialized locals into bss, not data. + Meaningful only on svr3. */ +#define TARGET_SVR3_SHLIB (target_flags & MASK_SVR3_SHLIB) + +/* Use IEEE floating point comparisons. These handle correctly the cases + where the result of a comparison is unordered. Normally SIGFPE is + generated in such cases, in which case this isn't needed. */ +#define TARGET_IEEE_FP (target_flags & MASK_IEEE_FP) + +/* Functions that return a floating point value may return that value + in the 387 FPU or in 386 integer registers. If set, this flag causes + the 387 to be used, which is compatible with most calling conventions. */ +#define TARGET_FLOAT_RETURNS_IN_80387 (target_flags & MASK_FLOAT_RETURNS) + +/* Disable generation of FP sin, cos and sqrt operations for 387. + This is because FreeBSD lacks these in the math-emulator-code */ +#define TARGET_NO_FANCY_MATH_387 (target_flags & MASK_NO_FANCY_MATH_387) + +/* Temporary switches for tuning code generation */ + +/* Disable 32x32->64 bit multiplies that are used for long long multiplies + and division by constants, but sometimes cause reload problems. */ +#define TARGET_NO_WIDE_MULTIPLY (target_flags & MASK_NO_WIDE_MULTIPLY) +#define TARGET_WIDE_MULTIPLY (!TARGET_NO_WIDE_MULTIPLY) + +/* Debug GO_IF_LEGITIMATE_ADDRESS */ +#define TARGET_DEBUG_ADDR (target_flags & MASK_DEBUG_ADDR) + +/* Debug FUNCTION_ARG macros */ +#define TARGET_DEBUG_ARG (target_flags & MASK_DEBUG_ARG) + +/* Hack macros for tuning code generation */ +#define TARGET_MOVE ((target_flags & MASK_NO_MOVE) == 0) /* Don't generate memory->memory */ + +/* Specific hardware switches */ +#define TARGET_486 (target_flags & MASK_486) /* 80486DX, 80486SX, 80486DX[24] */ +#define TARGET_386 (!TARGET_486) /* 80386 */ + +#define TARGET_SWITCHES \ +{ { "80387", MASK_80387 }, \ + { "no-80387", -MASK_80387 }, \ + { "hard-float", MASK_80387 }, \ + { "soft-float", -MASK_80387 }, \ + { "no-soft-float", MASK_80387 }, \ + { "386", -MASK_486 }, \ + { "no-386", MASK_486 }, \ + { "486", MASK_486 }, \ + { "no-486", -MASK_486 }, \ + { "rtd", MASK_RTD }, \ + { "no-rtd", -MASK_RTD }, \ + { "align-double", MASK_ALIGN_DOUBLE }, \ + { "no-align-double", -MASK_ALIGN_DOUBLE }, \ + { "svr3-shlib", MASK_SVR3_SHLIB }, \ + { "no-svr3-shlib", -MASK_SVR3_SHLIB }, \ + { "ieee-fp", MASK_IEEE_FP }, \ + { "no-ieee-fp", -MASK_IEEE_FP }, \ + { "fp-ret-in-387", MASK_FLOAT_RETURNS }, \ + { "no-fp-ret-in-387", -MASK_FLOAT_RETURNS }, \ + { "no-fancy-math-387", MASK_NO_FANCY_MATH_387 }, \ + { "fancy-math-387", -MASK_NO_FANCY_MATH_387 }, \ + { "no-wide-multiply", MASK_NO_WIDE_MULTIPLY }, \ + { "wide-multiply", -MASK_NO_WIDE_MULTIPLY }, \ + { "debug-addr", MASK_DEBUG_ADDR }, \ + { "no-debug-addr", -MASK_DEBUG_ADDR }, \ + { "move", -MASK_NO_MOVE }, \ + { "no-move", MASK_NO_MOVE }, \ + { "debug-arg", MASK_DEBUG_ARG }, \ + { "no-debug-arg", -MASK_DEBUG_ARG }, \ + SUBTARGET_SWITCHES \ + { "", TARGET_DEFAULT | TARGET_CPU_DEFAULT}} + +/* This macro is similar to `TARGET_SWITCHES' but defines names of + command options that have values. Its definition is an + initializer with a subgrouping for each command option. + + Each subgrouping contains a string constant, that defines the + fixed part of the option name, and the address of a variable. The + variable, type `char *', is set to the variable part of the given + option if the fixed part matches. The actual option name is made + by appending `-m' to the specified name. */ +#define TARGET_OPTIONS \ +{ { "reg-alloc=", &i386_reg_alloc_order }, \ + { "regparm=", &i386_regparm_string }, \ + { "align-loops=", &i386_align_loops_string }, \ + { "align-jumps=", &i386_align_jumps_string }, \ + { "align-functions=", &i386_align_funcs_string }, \ + SUBTARGET_OPTIONS \ +} + +/* Sometimes certain combinations of command options do not make + sense on a particular target machine. You can define a macro + `OVERRIDE_OPTIONS' to take account of this. This macro, if + defined, is executed once just after all the command options have + been parsed. + + Don't use this macro to turn on various extra optimizations for + `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */ + +#define OVERRIDE_OPTIONS override_options () + +/* These are meant to be redefined in the host dependent files */ +#define SUBTARGET_SWITCHES +#define SUBTARGET_OPTIONS + + +/* target machine storage layout */ + +/* Define for XFmode extended real floating point support. + This will automatically cause REAL_ARITHMETIC to be defined. */ +#define LONG_DOUBLE_TYPE_SIZE 96 + +/* Define if you don't want extended real, but do want to use the + software floating point emulator for REAL_ARITHMETIC and + decimal <-> binary conversion. */ +/* #define REAL_ARITHMETIC */ + +/* Define this if most significant byte of a word is the lowest numbered. */ +/* That is true on the 80386. */ + +#define BITS_BIG_ENDIAN 0 + +/* Define this if most significant byte of a word is the lowest numbered. */ +/* That is not true on the 80386. */ +#define BYTES_BIG_ENDIAN 0 + +/* Define this if most significant word of a multiword number is the lowest + numbered. */ +/* Not true for 80386 */ +#define WORDS_BIG_ENDIAN 0 + +/* number of bits in an addressable storage unit */ +#define BITS_PER_UNIT 8 + +/* Width in bits of a "word", which is the contents of a machine register. + Note that this is not necessarily the width of data type `int'; + if using 16-bit ints on a 80386, this would still be 32. + But on a machine with 16-bit registers, this would be 16. */ +#define BITS_PER_WORD 32 + +/* Width of a word, in units (bytes). */ +#define UNITS_PER_WORD 4 + +/* Width in bits of a pointer. + See also the macro `Pmode' defined below. */ +#define POINTER_SIZE 32 + +/* Allocation boundary (in *bits*) for storing arguments in argument list. */ +#define PARM_BOUNDARY 32 + +/* Boundary (in *bits*) on which stack pointer should be aligned. */ +#define STACK_BOUNDARY 32 + +/* Allocation boundary (in *bits*) for the code of a function. + For i486, we get better performance by aligning to a cache + line (i.e. 16 byte) boundary. */ +#define FUNCTION_BOUNDARY (1 << (i386_align_funcs + 3)) + +/* Alignment of field after `int : 0' in a structure. */ + +#define EMPTY_FIELD_BOUNDARY 32 + +/* Minimum size in bits of the largest boundary to which any + and all fundamental data types supported by the hardware + might need to be aligned. No data type wants to be aligned + rounder than this. The i386 supports 64-bit floating point + quantities, but these can be aligned on any 32-bit boundary. + The published ABIs say that doubles should be aligned on word + boundaries, but the Pentium gets better performance with them + aligned on 64 bit boundaries. */ +#define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32) + +/* Set this non-zero if move instructions will actually fail to work + when given unaligned data. */ +#define STRICT_ALIGNMENT 0 + +/* If bit field type is int, don't let it cross an int, + and give entire struct the alignment of an int. */ +/* Required on the 386 since it doesn't have bitfield insns. */ +#define PCC_BITFIELD_TYPE_MATTERS 1 + +/* Maximum power of 2 that code can be aligned to. */ +#define MAX_CODE_ALIGN 6 /* 64 byte alignment */ + +/* Align loop starts for optimal branching. */ +#define ASM_OUTPUT_LOOP_ALIGN(FILE) ASM_OUTPUT_ALIGN (FILE, i386_align_loops) + +/* This is how to align an instruction for optimal branching. + On i486 we'll get better performance by aligning on a + cache line (i.e. 16 byte) boundary. */ +#define ASM_OUTPUT_ALIGN_CODE(FILE) ASM_OUTPUT_ALIGN ((FILE), i386_align_jumps) + + +/* Standard register usage. */ + +/* This processor has special stack-like registers. See reg-stack.c + for details. */ + +#define STACK_REGS + +/* Number of actual hardware registers. + The hardware registers are assigned numbers for the compiler + from 0 to just below FIRST_PSEUDO_REGISTER. + All registers that the compiler knows about must be given numbers, + even those that are not normally considered general registers. + + In the 80386 we give the 8 general purpose registers the numbers 0-7. + We number the floating point registers 8-15. + Note that registers 0-7 can be accessed as a short or int, + while only 0-3 may be used with byte `mov' instructions. + + Reg 16 does not correspond to any hardware register, but instead + appears in the RTL as an argument pointer prior to reload, and is + eliminated during reloading in favor of either the stack or frame + pointer. */ + +#define FIRST_PSEUDO_REGISTER 17 + +/* 1 for registers that have pervasive standard uses + and are not available for the register allocator. + On the 80386, the stack pointer is such, as is the arg pointer. */ +#define FIXED_REGISTERS \ +/*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \ +{ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 } + +/* 1 for registers not available across function calls. + These must include the FIXED_REGISTERS and also any + registers that can be used without being saved. + The latter must include the registers where values are returned + and the register where structure-value addresses are passed. + Aside from that, you can include as many other registers as you like. */ + +#define CALL_USED_REGISTERS \ +/*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \ +{ 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } + +/* Order in which to allocate registers. Each register must be + listed once, even those in FIXED_REGISTERS. List frame pointer + late and fixed registers last. Note that, in general, we prefer + registers listed in CALL_USED_REGISTERS, keeping the others + available for storage of persistent values. + + Three different versions of REG_ALLOC_ORDER have been tried: + + If the order is edx, ecx, eax, ... it produces a slightly faster compiler, + but slower code on simple functions returning values in eax. + + If the order is eax, ecx, edx, ... it causes reload to abort when compiling + perl 4.036 due to not being able to create a DImode register (to hold a 2 + word union). + + If the order is eax, edx, ecx, ... it produces better code for simple + functions, and a slightly slower compiler. Users complained about the code + generated by allocating edx first, so restore the 'natural' order of things. */ + +#define REG_ALLOC_ORDER \ +/*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \ +{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 } + +/* A C statement (sans semicolon) to choose the order in which to + allocate hard registers for pseudo-registers local to a basic + block. + + Store the desired register order in the array `reg_alloc_order'. + Element 0 should be the register to allocate first; element 1, the + next register; and so on. + + The macro body should not assume anything about the contents of + `reg_alloc_order' before execution of the macro. + + On most machines, it is not necessary to define this macro. */ + +#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc () + +/* Macro to conditionally modify fixed_regs/call_used_regs. */ +#define CONDITIONAL_REGISTER_USAGE \ + { \ + if (flag_pic) \ + { \ + fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ + call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ + } \ + if (! TARGET_80387 && ! TARGET_FLOAT_RETURNS_IN_80387) \ + { \ + int i; \ + HARD_REG_SET x; \ + COPY_HARD_REG_SET (x, reg_class_contents[(int)FLOAT_REGS]); \ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ + if (TEST_HARD_REG_BIT (x, i)) \ + fixed_regs[i] = call_used_regs[i] = 1; \ + } \ + } + +/* Return number of consecutive hard regs needed starting at reg REGNO + to hold something of mode MODE. + This is ordinarily the length in words of a value of mode MODE + but can be less for certain modes in special long registers. + + Actually there are no two word move instructions for consecutive + registers. And only registers 0-3 may have mov byte instructions + applied to them. + */ + +#define HARD_REGNO_NREGS(REGNO, MODE) \ + (FP_REGNO_P (REGNO) ? 1 \ + : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) + +/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. + On the 80386, the first 4 cpu registers can hold any mode + while the floating point registers may hold only floating point. + Make it clear that the fp regs could not hold a 16-byte float. */ + +/* The casts to int placate a compiler on a microvax, + for cross-compiler testing. */ + +#define HARD_REGNO_MODE_OK(REGNO, MODE) \ + ((REGNO) < 2 ? 1 \ + : (REGNO) < 4 ? 1 \ + : FP_REGNO_P (REGNO) \ + ? (((int) GET_MODE_CLASS (MODE) == (int) MODE_FLOAT \ + || (int) GET_MODE_CLASS (MODE) == (int) MODE_COMPLEX_FLOAT) \ + && GET_MODE_UNIT_SIZE (MODE) <= 12) \ + : (int) (MODE) != (int) QImode) + +/* Value is 1 if it is a good idea to tie two pseudo registers + when one has mode MODE1 and one has mode MODE2. + If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, + for any hard reg, then this must be 0 for correct output. */ + +#define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) == (MODE2)) + +/* A C expression returning the cost of moving data from a register of class + CLASS1 to one of CLASS2. + + On the i386, copying between floating-point and fixed-point + registers is expensive. */ + +#define REGISTER_MOVE_COST(CLASS1, CLASS2) \ + (((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2)) \ + || (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2))) ? 10 \ + : 2) + +/* Specify the registers used for certain standard purposes. + The values of these macros are register numbers. */ + +/* on the 386 the pc register is %eip, and is not usable as a general + register. The ordinary mov instructions won't work */ +/* #define PC_REGNUM */ + +/* Register to use for pushing function arguments. */ +#define STACK_POINTER_REGNUM 7 + +/* Base register for access to local variables of the function. */ +#define FRAME_POINTER_REGNUM 6 + +/* First floating point reg */ +#define FIRST_FLOAT_REG 8 + +/* First & last stack-like regs */ +#define FIRST_STACK_REG FIRST_FLOAT_REG +#define LAST_STACK_REG (FIRST_FLOAT_REG + 7) + +/* Value should be nonzero if functions must have frame pointers. + Zero means the frame pointer need not be set up (and parms + may be accessed via the stack pointer) in functions that seem suitable. + This is computed in `reload', in reload1.c. */ +#define FRAME_POINTER_REQUIRED 0 + +/* Base register for access to arguments of the function. */ +#define ARG_POINTER_REGNUM 16 + +/* Register in which static-chain is passed to a function. */ +#define STATIC_CHAIN_REGNUM 2 + +/* Register to hold the addressing base for position independent + code access to data items. */ +#define PIC_OFFSET_TABLE_REGNUM 3 + +/* Register in which address to store a structure value + arrives in the function. On the 386, the prologue + copies this from the stack to register %eax. */ +#define STRUCT_VALUE_INCOMING 0 + +/* Place in which caller passes the structure value address. + 0 means push the value on the stack like an argument. */ +#define STRUCT_VALUE 0 + +/* A C expression which can inhibit the returning of certain function + values in registers, based on the type of value. A nonzero value + says to return the function value in memory, just as large + structures are always returned. Here TYPE will be a C expression + of type `tree', representing the data type of the value. + + Note that values of mode `BLKmode' must be explicitly handled by + this macro. Also, the option `-fpcc-struct-return' takes effect + regardless of this macro. On most systems, it is possible to + leave the macro undefined; this causes a default definition to be + used, whose value is the constant 1 for `BLKmode' values, and 0 + otherwise. + + Do not use this macro to indicate that structures and unions + should always be returned in memory. You should instead use + `DEFAULT_PCC_STRUCT_RETURN' to indicate this. */ + +#define RETURN_IN_MEMORY(TYPE) \ + ((TYPE_MODE (TYPE) == BLKmode) || int_size_in_bytes (TYPE) > 12) + + +/* Define the classes of registers for register constraints in the + machine description. Also define ranges of constants. + + One of the classes must always be named ALL_REGS and include all hard regs. + If there is more than one class, another class must be named NO_REGS + and contain no registers. + + The name GENERAL_REGS must be the name of a class (or an alias for + another name such as ALL_REGS). This is the class of registers + that is allowed by "g" or "r" in a register constraint. + Also, registers outside this class are allocated only when + instructions express preferences for them. + + The classes must be numbered in nondecreasing order; that is, + a larger-numbered class must never be contained completely + in a smaller-numbered class. + + For any two classes, it is very desirable that there be another + class that represents their union. + + It might seem that class BREG is unnecessary, since no useful 386 + opcode needs reg %ebx. But some systems pass args to the OS in ebx, + and the "b" register constraint is useful in asms for syscalls. */ + +//enum reg_class +//{ +// NO_REGS, +// AREG, DREG, CREG, BREG, +// AD_REGS, /* %eax/%edx for DImode */ +// Q_REGS, /* %eax %ebx %ecx %edx */ +// SIREG, DIREG, +// INDEX_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp */ +// GENERAL_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */ +// FP_TOP_REG, FP_SECOND_REG, /* %st(0) %st(1) */ +// FLOAT_REGS, +// ALL_REGS, LIM_REG_CLASSES +//}; + +#define N_REG_CLASSES (int) LIM_REG_CLASSES + +#define FLOAT_CLASS_P(CLASS) (reg_class_subset_p (CLASS, FLOAT_REGS)) + +/* Give names of register classes as strings for dump file. */ + +#define REG_CLASS_NAMES \ +{ "NO_REGS", \ + "AREG", "DREG", "CREG", "BREG", \ + "AD_REGS", \ + "Q_REGS", \ + "SIREG", "DIREG", \ + "INDEX_REGS", \ + "GENERAL_REGS", \ + "FP_TOP_REG", "FP_SECOND_REG", \ + "FLOAT_REGS", \ + "ALL_REGS" } + +/* Define which registers fit in which classes. + This is an initializer for a vector of HARD_REG_SET + of length N_REG_CLASSES. */ + +#define REG_CLASS_CONTENTS \ +{ 0, \ + 0x1, 0x2, 0x4, 0x8, /* AREG, DREG, CREG, BREG */ \ + 0x3, /* AD_REGS */ \ + 0xf, /* Q_REGS */ \ + 0x10, 0x20, /* SIREG, DIREG */ \ + 0x07f, /* INDEX_REGS */ \ + 0x100ff, /* GENERAL_REGS */ \ + 0x0100, 0x0200, /* FP_TOP_REG, FP_SECOND_REG */ \ + 0xff00, /* FLOAT_REGS */ \ + 0x1ffff } + +/* The same information, inverted: + Return the class number of the smallest class containing + reg number REGNO. This could be a conditional expression + or could index an array. */ + +#define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO]) + +/* When defined, the compiler allows registers explicitly used in the + rtl to be used as spill registers but prevents the compiler from + extending the lifetime of these registers. */ + +#define SMALL_REGISTER_CLASSES + +#define QI_REG_P(X) \ + (REG_P (X) && REGNO (X) < 4) +#define NON_QI_REG_P(X) \ + (REG_P (X) && REGNO (X) >= 4 && REGNO (X) < FIRST_PSEUDO_REGISTER) + +#define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X))) +#define FP_REGNO_P(n) ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) + +#define STACK_REG_P(xop) (REG_P (xop) && \ + REGNO (xop) >= FIRST_STACK_REG && \ + REGNO (xop) <= LAST_STACK_REG) + +#define NON_STACK_REG_P(xop) (REG_P (xop) && ! STACK_REG_P (xop)) + +#define STACK_TOP_P(xop) (REG_P (xop) && REGNO (xop) == FIRST_STACK_REG) + +/* Try to maintain the accuracy of the death notes for regs satisfying the + following. Important for stack like regs, to know when to pop. */ + +/* #define PRESERVE_DEATH_INFO_REGNO_P(x) FP_REGNO_P(x) */ + +/* 1 if register REGNO can magically overlap other regs. + Note that nonzero values work only in very special circumstances. */ + +/* #define OVERLAPPING_REGNO_P(REGNO) FP_REGNO_P (REGNO) */ + +/* The class value for index registers, and the one for base regs. */ + +#define INDEX_REG_CLASS INDEX_REGS +#define BASE_REG_CLASS GENERAL_REGS + +/* Get reg_class from a letter such as appears in the machine description. */ + +#define REG_CLASS_FROM_LETTER(C) \ + ((C) == 'r' ? GENERAL_REGS : \ + (C) == 'q' ? Q_REGS : \ + (C) == 'f' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \ + ? FLOAT_REGS \ + : NO_REGS) : \ + (C) == 't' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \ + ? FP_TOP_REG \ + : NO_REGS) : \ + (C) == 'u' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \ + ? FP_SECOND_REG \ + : NO_REGS) : \ + (C) == 'a' ? AREG : \ + (C) == 'b' ? BREG : \ + (C) == 'c' ? CREG : \ + (C) == 'd' ? DREG : \ + (C) == 'A' ? AD_REGS : \ + (C) == 'D' ? DIREG : \ + (C) == 'S' ? SIREG : NO_REGS) + +/* The letters I, J, K, L and M in a register constraint string + can be used to stand for particular ranges of immediate operands. + This macro defines what the ranges are. + C is the letter, and VALUE is a constant value. + Return 1 if VALUE is in the range specified by C. + + I is for non-DImode shifts. + J is for DImode shifts. + K and L are for an `andsi' optimization. + M is for shifts that can be executed by the "lea" opcode. + */ + +#define CONST_OK_FOR_LETTER_P(VALUE, C) \ + ((C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 31 : \ + (C) == 'J' ? (VALUE) >= 0 && (VALUE) <= 63 : \ + (C) == 'K' ? (VALUE) == 0xff : \ + (C) == 'L' ? (VALUE) == 0xffff : \ + (C) == 'M' ? (VALUE) >= 0 && (VALUE) <= 3 : \ + (C) == 'N' ? (VALUE) >= 0 && (VALUE) <= 255 :\ + 0) + +/* Similar, but for floating constants, and defining letters G and H. + Here VALUE is the CONST_DOUBLE rtx itself. We allow constants even if + TARGET_387 isn't set, because the stack register converter may need to + load 0.0 into the function value register. */ + +#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ + ((C) == 'G' ? standard_80387_constant_p (VALUE) : 0) + +/* Place additional restrictions on the register class to use when it + is necessary to be able to hold a value of mode MODE in a reload + register for which class CLASS would ordinarily be used. */ + +#define LIMIT_RELOAD_CLASS(MODE, CLASS) \ + ((MODE) == QImode && ((CLASS) == ALL_REGS || (CLASS) == GENERAL_REGS) \ + ? Q_REGS : (CLASS)) + +/* Given an rtx X being reloaded into a reg required to be + in class CLASS, return the class of reg to actually use. + In general this is just CLASS; but on some machines + in some cases it is preferable to use a more restrictive class. + On the 80386 series, we prevent floating constants from being + reloaded into floating registers (since no move-insn can do that) + and we ensure that QImodes aren't reloaded into the esi or edi reg. */ + +/* Put float CONST_DOUBLE in the constant pool instead of fp regs. + QImode must go into class Q_REGS. + Narrow ALL_REGS to GENERAL_REGS. This supports allowing movsf and + movdf to do mem-to-mem moves through integer regs. */ + +#define PREFERRED_RELOAD_CLASS(X,CLASS) \ + (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode ? NO_REGS \ + : GET_MODE (X) == QImode && ! reg_class_subset_p (CLASS, Q_REGS) ? Q_REGS \ + : ((CLASS) == ALL_REGS \ + && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) ? GENERAL_REGS \ + : (CLASS)) + +/* If we are copying between general and FP registers, we need a memory + location. */ + +#define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \ + ((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2)) \ + || (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2))) + +/* Return the maximum number of consecutive registers + needed to represent mode MODE in a register of class CLASS. */ +/* On the 80386, this is the size of MODE in words, + except in the FP regs, where a single reg is always enough. */ +#define CLASS_MAX_NREGS(CLASS, MODE) \ + (FLOAT_CLASS_P (CLASS) ? 1 : \ + ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) + +/* A C expression whose value is nonzero if pseudos that have been + assigned to registers of class CLASS would likely be spilled + because registers of CLASS are needed for spill registers. + + The default value of this macro returns 1 if CLASS has exactly one + register and zero otherwise. On most machines, this default + should be used. Only define this macro to some other expression + if pseudo allocated by `local-alloc.c' end up in memory because + their hard registers were needed for spill registers. If this + macro returns nonzero for those classes, those pseudos will only + be allocated by `global.c', which knows how to reallocate the + pseudo to another register. If there would not be another + register available for reallocation, you should not change the + definition of this macro since the only effect of such a + definition would be to slow down register allocation. */ + +#define CLASS_LIKELY_SPILLED_P(CLASS) \ + (((CLASS) == AREG) \ + || ((CLASS) == DREG) \ + || ((CLASS) == CREG) \ + || ((CLASS) == BREG) \ + || ((CLASS) == AD_REGS) \ + || ((CLASS) == SIREG) \ + || ((CLASS) == DIREG)) + + +/* Stack layout; function entry, exit and calling. */ + +/* Define this if pushing a word on the stack + makes the stack pointer a smaller address. */ +#define STACK_GROWS_DOWNWARD + +/* Define this if the nominal address of the stack frame + is at the high-address end of the local variables; + that is, each additional local variable allocated + goes at a more negative offset in the frame. */ +#define FRAME_GROWS_DOWNWARD + +/* Offset within stack frame to start allocating local variables at. + If FRAME_GROWS_DOWNWARD, this is the offset to the END of the + first local allocated. Otherwise, it is the offset to the BEGINNING + of the first local allocated. */ +#define STARTING_FRAME_OFFSET 0 + +/* If we generate an insn to push BYTES bytes, + this says how many the stack pointer really advances by. + On 386 pushw decrements by exactly 2 no matter what the position was. + On the 386 there is no pushb; we use pushw instead, and this + has the effect of rounding up to 2. */ + +#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & (-2)) + +/* Offset of first parameter from the argument pointer register value. */ +#define FIRST_PARM_OFFSET(FNDECL) 0 + +/* Value is the number of bytes of arguments automatically + popped when returning from a subroutine call. + FUNDECL is the declaration node of the function (as a tree), + FUNTYPE is the data type of the function (as a tree), + or for a library call it is an identifier node for the subroutine name. + SIZE is the number of bytes of arguments passed on the stack. + + On the 80386, the RTD insn may be used to pop them if the number + of args is fixed, but if the number is variable then the caller + must pop them all. RTD can't be used for library calls now + because the library is compiled with the Unix compiler. + Use of RTD is a selectable option, since it is incompatible with + standard Unix calling sequences. If the option is not selected, + the caller must always pop the args. + + The attribute stdcall is equivalent to RTD on a per module basis. */ + +#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ + (i386_return_pops_args (FUNDECL, FUNTYPE, SIZE)) + +/* Define how to find the value returned by a function. + VALTYPE is the data type of the value (as a tree). + If the precise function being called is known, FUNC is its FUNCTION_DECL; + otherwise, FUNC is 0. */ +#define FUNCTION_VALUE(VALTYPE, FUNC) \ + gen_rtx (REG, TYPE_MODE (VALTYPE), \ + VALUE_REGNO (TYPE_MODE (VALTYPE))) + +/* Define how to find the value returned by a library function + assuming the value has mode MODE. */ + +#define LIBCALL_VALUE(MODE) \ + gen_rtx (REG, MODE, VALUE_REGNO (MODE)) + +/* Define the size of the result block used for communication between + untyped_call and untyped_return. The block contains a DImode value + followed by the block used by fnsave and frstor. */ + +#define APPLY_RESULT_SIZE (8+108) + +/* 1 if N is a possible register number for function argument passing. */ +#define FUNCTION_ARG_REGNO_P(N) ((N) >= 0 && (N) < REGPARM_MAX) + +/* Define a data type for recording info about an argument list + during the scan of that argument list. This data type should + hold all necessary information about the function itself + and about the args processed so far, enough to enable macros + such as FUNCTION_ARG to determine where the next arg should go. */ + +//typedef struct i386_args { +// int words; /* # words passed so far */ +// int nregs; /* # registers available for passing */ +// int regno; /* next available register number */ +//} CUMULATIVE_ARGS; + +/* Initialize a variable CUM of type CUMULATIVE_ARGS + for a call to a function whose data type is FNTYPE. + For a library call, FNTYPE is 0. */ + +#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \ + (init_cumulative_args (&CUM, FNTYPE, LIBNAME)) + +/* Update the data in CUM to advance over an argument + of mode MODE and data type TYPE. + (TYPE is null for libcalls where that information may not be available.) */ + +#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ + (function_arg_advance (&CUM, MODE, TYPE, NAMED)) + +/* Define where to put the arguments to a function. + Value is zero to push the argument on the stack, + or a hard register in which to store the argument. + + MODE is the argument's machine mode. + TYPE is the data type of the argument (as a tree). + This is null for libcalls where that information may + not be available. + CUM is a variable of type CUMULATIVE_ARGS which gives info about + the preceding args and about the function being called. + NAMED is nonzero if this argument is a named parameter + (otherwise it is an extra parameter matching an ellipsis). */ + +#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ + (function_arg (&CUM, MODE, TYPE, NAMED)) + +/* For an arg passed partly in registers and partly in memory, + this is the number of registers used. + For args passed entirely in registers or entirely in memory, zero. */ + +#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \ + (function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)) + +/* This macro generates the assembly code for function entry. + FILE is a stdio stream to output the code to. + SIZE is an int: how many units of temporary storage to allocate. + Refer to the array `regs_ever_live' to determine which registers + to save; `regs_ever_live[I]' is nonzero if register number I + is ever used in the function. This macro is responsible for + knowing which registers should not be saved even if used. */ + +#define FUNCTION_PROLOGUE(FILE, SIZE) \ + function_prologue (FILE, SIZE) + +/* Output assembler code to FILE to increment profiler label # LABELNO + for profiling a function entry. */ + +#define FUNCTION_PROFILER(FILE, LABELNO) \ +{ \ + if (flag_pic) \ + { \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ + LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall *_mcount@GOT(%%ebx)\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall _mcount\n"); \ + } \ +} + +/* A C statement or compound statement to output to FILE some + assembler code to initialize basic-block profiling for the current + object module. This code should call the subroutine + `__bb_init_func' once per object module, passing it as its sole + argument the address of a block allocated in the object module. + + The name of the block is a local symbol made with this statement: + + ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0); + + Of course, since you are writing the definition of + `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you + can take a short cut in the definition of this macro and use the + name that you know will result. + + The first word of this block is a flag which will be nonzero if the + object module has already been initialized. So test this word + first, and do not call `__bb_init_func' if the flag is nonzero. */ + +#undef FUNCTION_BLOCK_PROFILER +#define FUNCTION_BLOCK_PROFILER(STREAM, LABELNO) \ +do \ + { \ + static int num_func = 0; \ + rtx xops[8]; \ + char block_table[80], false_label[80]; \ + \ + ASM_GENERATE_INTERNAL_LABEL (block_table, "LPBX", 0); \ + ASM_GENERATE_INTERNAL_LABEL (false_label, "LPBZ", num_func); \ + \ + xops[0] = const0_rtx; \ + xops[1] = gen_rtx (SYMBOL_REF, VOIDmode, block_table); \ + xops[2] = gen_rtx (MEM, Pmode, gen_rtx (SYMBOL_REF, VOIDmode, false_label)); \ + xops[3] = gen_rtx (MEM, Pmode, gen_rtx (SYMBOL_REF, VOIDmode, "__bb_init_func")); \ + xops[4] = gen_rtx (MEM, Pmode, xops[1]); \ + xops[5] = stack_pointer_rtx; \ + xops[6] = GEN_INT (4); \ + xops[7] = gen_rtx (REG, Pmode, 0); /* eax */ \ + \ + CONSTANT_POOL_ADDRESS_P (xops[1]) = TRUE; \ + CONSTANT_POOL_ADDRESS_P (xops[2]) = TRUE; \ + \ + output_asm_insn (AS2(cmp%L4,%0,%4), xops); \ + output_asm_insn (AS1(jne,%2), xops); \ + \ + if (!flag_pic) \ + output_asm_insn (AS1(push%L1,%1), xops); \ + else \ + { \ + output_asm_insn (AS2 (lea%L7,%a1,%7), xops); \ + output_asm_insn (AS1 (push%L7,%7), xops); \ + } \ + \ + output_asm_insn (AS1(call,%P3), xops); \ + output_asm_insn (AS2(add%L0,%6,%5), xops); \ + ASM_OUTPUT_INTERNAL_LABEL (STREAM, "LPBZ", num_func); \ + num_func++; \ + } \ +while (0) + + +/* A C statement or compound statement to increment the count + associated with the basic block number BLOCKNO. Basic blocks are + numbered separately from zero within each compilation. The count + associated with block number BLOCKNO is at index BLOCKNO in a + vector of words; the name of this array is a local symbol made + with this statement: + + ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 2); + + Of course, since you are writing the definition of + `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you + can take a short cut in the definition of this macro and use the + name that you know will result. */ + +#define BLOCK_PROFILER(STREAM, BLOCKNO) \ +do \ + { \ + rtx xops[1], cnt_rtx; \ + char counts[80]; \ + \ + ASM_GENERATE_INTERNAL_LABEL (counts, "LPBX", 2); \ + cnt_rtx = gen_rtx (SYMBOL_REF, VOIDmode, counts); \ + SYMBOL_REF_FLAG (cnt_rtx) = TRUE; \ + \ + if (BLOCKNO) \ + cnt_rtx = plus_constant (cnt_rtx, (BLOCKNO)*4); \ + \ + if (flag_pic) \ + cnt_rtx = gen_rtx (PLUS, Pmode, pic_offset_table_rtx, cnt_rtx); \ + \ + xops[0] = gen_rtx (MEM, SImode, cnt_rtx); \ + output_asm_insn (AS1(inc%L0,%0), xops); \ + } \ +while (0) + +/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, + the stack pointer does not matter. The value is tested only in + functions that have frame pointers. + No definition is equivalent to always zero. */ +/* Note on the 386 it might be more efficient not to define this since + we have to restore it ourselves from the frame pointer, in order to + use pop */ + +#define EXIT_IGNORE_STACK 1 + +/* This macro generates the assembly code for function exit, + on machines that need it. If FUNCTION_EPILOGUE is not defined + then individual return instructions are generated for each + return statement. Args are same as for FUNCTION_PROLOGUE. + + The function epilogue should not depend on the current stack pointer! + It should use the frame pointer only. This is mandatory because + of alloca; we also take advantage of it to omit stack adjustments + before returning. + + If the last non-note insn in the function is a BARRIER, then there + is no need to emit a function prologue, because control does not fall + off the end. This happens if the function ends in an "exit" call, or + if a `return' insn is emitted directly into the function. */ + +#define FUNCTION_EPILOGUE(FILE, SIZE) \ +do { \ + rtx last = get_last_insn (); \ + if (last && GET_CODE (last) == NOTE) \ + last = prev_nonnote_insn (last); \ + if (! last || GET_CODE (last) != BARRIER) \ + function_epilogue (FILE, SIZE); \ +} while (0) + +/* Output assembler code for a block containing the constant parts + of a trampoline, leaving space for the variable parts. */ + +/* On the 386, the trampoline contains three instructions: + mov #STATIC,ecx + mov #FUNCTION,eax + jmp @eax */ +#define TRAMPOLINE_TEMPLATE(FILE) \ +{ \ + ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb9)); \ + ASM_OUTPUT_SHORT (FILE, const0_rtx); \ + ASM_OUTPUT_SHORT (FILE, const0_rtx); \ + ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb8)); \ + ASM_OUTPUT_SHORT (FILE, const0_rtx); \ + ASM_OUTPUT_SHORT (FILE, const0_rtx); \ + ASM_OUTPUT_CHAR (FILE, GEN_INT (0xff)); \ + ASM_OUTPUT_CHAR (FILE, GEN_INT (0xe0)); \ +} + +/* Length in units of the trampoline for entering a nested function. */ + +#define TRAMPOLINE_SIZE 12 + +/* Emit RTL insns to initialize the variable parts of a trampoline. + FNADDR is an RTX for the address of the function's pure code. + CXT is an RTX for the static chain value for the function. */ + +#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \ +{ \ + emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 1)), CXT); \ + emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 6)), FNADDR); \ +} + +/* Definitions for register eliminations. + + This is an array of structures. Each structure initializes one pair + of eliminable registers. The "from" register number is given first, + followed by "to". Eliminations of the same "from" register are listed + in order of preference. + + We have two registers that can be eliminated on the i386. First, the + frame pointer register can often be eliminated in favor of the stack + pointer register. Secondly, the argument pointer register can always be + eliminated; it is replaced with either the stack or frame pointer. */ + +#define ELIMINABLE_REGS \ +{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ + { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ + { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}} + +/* Given FROM and TO register numbers, say whether this elimination is allowed. + Frame pointer elimination is automatically handled. + + For the i386, if frame pointer elimination is being done, we would like to + convert ap into sp, not fp. + + All other eliminations are valid. */ + +#define CAN_ELIMINATE(FROM, TO) \ + ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \ + ? ! frame_pointer_needed \ + : 1) + +/* Define the offset between two registers, one to be eliminated, and the other + its replacement, at the start of a routine. */ + +#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ +{ \ + if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \ + (OFFSET) = 8; /* Skip saved PC and previous frame pointer */ \ + else \ + { \ + int regno; \ + int offset = 0; \ + \ + for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \ + if ((regs_ever_live[regno] && ! call_used_regs[regno]) \ + || (current_function_uses_pic_offset_table \ + && regno == PIC_OFFSET_TABLE_REGNUM)) \ + offset += 4; \ + \ + (OFFSET) = offset + get_frame_size (); \ + \ + if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \ + (OFFSET) += 4; /* Skip saved PC */ \ + } \ +} + +/* Addressing modes, and classification of registers for them. */ + +/* #define HAVE_POST_INCREMENT */ +/* #define HAVE_POST_DECREMENT */ + +/* #define HAVE_PRE_DECREMENT */ +/* #define HAVE_PRE_INCREMENT */ + +/* Macros to check register numbers against specific register classes. */ + +/* These assume that REGNO is a hard or pseudo reg number. + They give nonzero only if REGNO is a hard reg of the suitable class + or a pseudo reg currently allocated to a suitable hard reg. + Since they use reg_renumber, they are safe only once reg_renumber + has been allocated, which happens in local-alloc.c. */ + +#define REGNO_OK_FOR_INDEX_P(REGNO) \ + ((REGNO) < STACK_POINTER_REGNUM \ + || (unsigned) reg_renumber[REGNO] < STACK_POINTER_REGNUM) + +#define REGNO_OK_FOR_BASE_P(REGNO) \ + ((REGNO) <= STACK_POINTER_REGNUM \ + || (REGNO) == ARG_POINTER_REGNUM \ + || (unsigned) reg_renumber[REGNO] <= STACK_POINTER_REGNUM) + +#define REGNO_OK_FOR_SIREG_P(REGNO) ((REGNO) == 4 || reg_renumber[REGNO] == 4) +#define REGNO_OK_FOR_DIREG_P(REGNO) ((REGNO) == 5 || reg_renumber[REGNO] == 5) + +/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx + and check its validity for a certain class. + We have two alternate definitions for each of them. + The usual definition accepts all pseudo regs; the other rejects + them unless they have been allocated suitable hard regs. + The symbol REG_OK_STRICT causes the latter definition to be used. + + Most source files want to accept pseudo regs in the hope that + they will get allocated to the class that the insn wants them to be in. + Source files for reload pass need to be strict. + After reload, it makes no difference, since pseudo regs have + been eliminated by then. */ + + +/* Non strict versions, pseudos are ok */ +#define REG_OK_FOR_INDEX_NONSTRICT_P(X) \ + (REGNO (X) < STACK_POINTER_REGNUM \ + || REGNO (X) >= FIRST_PSEUDO_REGISTER) + +#define REG_OK_FOR_BASE_NONSTRICT_P(X) \ + (REGNO (X) <= STACK_POINTER_REGNUM \ + || REGNO (X) == ARG_POINTER_REGNUM \ + || REGNO (X) >= FIRST_PSEUDO_REGISTER) + +#define REG_OK_FOR_STRREG_NONSTRICT_P(X) \ + (REGNO (X) == 4 || REGNO (X) == 5 || REGNO (X) >= FIRST_PSEUDO_REGISTER) + +/* Strict versions, hard registers only */ +#define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) +#define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) +#define REG_OK_FOR_STRREG_STRICT_P(X) \ + (REGNO_OK_FOR_DIREG_P (REGNO (X)) || REGNO_OK_FOR_SIREG_P (REGNO (X))) + +#ifndef REG_OK_STRICT +#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P(X) +#define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P(X) +#define REG_OK_FOR_STRREG_P(X) REG_OK_FOR_STRREG_NONSTRICT_P(X) + +#else +#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P(X) +#define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P(X) +#define REG_OK_FOR_STRREG_P(X) REG_OK_FOR_STRREG_STRICT_P(X) +#endif + +/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression + that is a valid memory address for an instruction. + The MODE argument is the machine mode for the MEM expression + that wants to use this address. + + The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS, + except for CONSTANT_ADDRESS_P which is usually machine-independent. + + See legitimize_pic_address in i386.c for details as to what + constitutes a legitimate address when -fpic is used. */ + +#define MAX_REGS_PER_ADDRESS 2 + +#define CONSTANT_ADDRESS_P(X) \ + (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ + || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ + || GET_CODE (X) == HIGH) + +/* Nonzero if the constant value X is a legitimate general operand. + It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ + +#define LEGITIMATE_CONSTANT_P(X) 1 + +#ifdef REG_OK_STRICT +#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ +{ \ + if (legitimate_address_p (MODE, X, 1)) \ + goto ADDR; \ +} + +#else +#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ +{ \ + if (legitimate_address_p (MODE, X, 0)) \ + goto ADDR; \ +} + +#endif + +/* Try machine-dependent ways of modifying an illegitimate address + to be legitimate. If we find one, return the new, valid address. + This macro is used in only one place: `memory_address' in explow.c. + + OLDX is the address as it was before break_out_memory_refs was called. + In some cases it is useful to look at this to decide what needs to be done. + + MODE and WIN are passed so that this macro can use + GO_IF_LEGITIMATE_ADDRESS. + + It is always safe for this macro to do nothing. It exists to recognize + opportunities to optimize the output. + + For the 80386, we handle X+REG by loading X into a register R and + using R+REG. R will go in a general reg and indexing will be used. + However, if REG is a broken-out memory address or multiplication, + nothing needs to be done because REG can certainly go in a general reg. + + When -fpic is used, special handling is needed for symbolic references. + See comments by legitimize_pic_address in i386.c for details. */ + +#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \ +{ \ + rtx orig_x = (X); \ + (X) = legitimize_address (X, OLDX, MODE); \ + if (memory_address_p (MODE, X)) \ + goto WIN; \ +} + +/* Nonzero if the constant value X is a legitimate general operand + when generating PIC code. It is given that flag_pic is on and + that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ + +#define LEGITIMATE_PIC_OPERAND_P(X) \ + (! SYMBOLIC_CONST (X) \ + || (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (X))) + +#define SYMBOLIC_CONST(X) \ +(GET_CODE (X) == SYMBOL_REF \ + || GET_CODE (X) == LABEL_REF \ + || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X))) + +/* Go to LABEL if ADDR (a legitimate address expression) + has an effect that depends on the machine mode it is used for. + On the 80386, only postdecrement and postincrement address depend thus + (the amount of decrement or increment being the length of the operand). */ +#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \ + if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == POST_DEC) goto LABEL + +/* Define this macro if references to a symbol must be treated + differently depending on something about the variable or + function named by the symbol (such as what section it is in). + + On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol + so that we may access it directly in the GOT. */ + +#define ENCODE_SECTION_INFO(DECL) \ +do \ + { \ + if (flag_pic) \ + { \ + rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \ + SYMBOL_REF_FLAG (XEXP (rtl, 0)) \ + = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + || ! TREE_PUBLIC (DECL)); \ + } \ + } \ +while (0) + +/* Initialize data used by insn expanders. This is called from + init_emit, once for each function, before code is generated. + For 386, clear stack slot assignments remembered from previous + functions. */ + +#define INIT_EXPANDERS clear_386_stack_locals () + +/* The `FINALIZE_PIC' macro serves as a hook to emit these special + codes once the function is being compiled into assembly code, but + not before. (It is not done before, because in the case of + compiling an inline function, it would lead to multiple PIC + prologues being included in functions which used inline functions + and were compiled to assembly language.) */ + +#define FINALIZE_PIC \ +do \ + { \ + extern int current_function_uses_pic_offset_table; \ + \ + current_function_uses_pic_offset_table |= profile_flag | profile_block_flag; \ + } \ +while (0) + + +/* If defined, a C expression whose value is nonzero if IDENTIFIER + with arguments ARGS is a valid machine specific attribute for DECL. + The attributes in ATTRIBUTES have previously been assigned to DECL. */ + +#define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, NAME, ARGS) \ + (i386_valid_decl_attribute_p (DECL, ATTRIBUTES, NAME, ARGS)) + +/* If defined, a C expression whose value is nonzero if IDENTIFIER + with arguments ARGS is a valid machine specific attribute for TYPE. + The attributes in ATTRIBUTES have previously been assigned to TYPE. */ + +#define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, NAME, ARGS) \ + (i386_valid_type_attribute_p (TYPE, ATTRIBUTES, NAME, ARGS)) + +/* If defined, a C expression whose value is zero if the attributes on + TYPE1 and TYPE2 are incompatible, one if they are compatible, and + two if they are nearly compatible (which causes a warning to be + generated). */ + +#define COMP_TYPE_ATTRIBUTES(TYPE1, TYPE2) \ + (i386_comp_type_attributes (TYPE1, TYPE2)) + +/* If defined, a C statement that assigns default attributes to newly + defined TYPE. */ + +/* #define SET_DEFAULT_TYPE_ATTRIBUTES (TYPE) */ + +/* Max number of args passed in registers. If this is more than 3, we will + have problems with ebx (register #4), since it is a caller save register and + is also used as the pic register in ELF. So for now, don't allow more than + 3 registers to be passed in registers. */ + +#define REGPARM_MAX 3 + + +/* Specify the machine mode that this machine uses + for the index in the tablejump instruction. */ +#define CASE_VECTOR_MODE Pmode + +/* Define this if the tablejump instruction expects the table + to contain offsets from the address of the table. + Do not define this if the table should contain absolute addresses. */ +/* #define CASE_VECTOR_PC_RELATIVE */ + +/* Specify the tree operation to be used to convert reals to integers. + This should be changed to take advantage of fist --wfs ?? + */ +#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR + +/* This is the kind of divide that is easiest to do in the general case. */ +#define EASY_DIV_EXPR TRUNC_DIV_EXPR + +/* Define this as 1 if `char' should by default be signed; else as 0. */ +#define DEFAULT_SIGNED_CHAR 1 + +/* Max number of bytes we can move from memory to memory + in one reasonably fast instruction. */ +#define MOVE_MAX 4 + +/* MOVE_RATIO is the number of move instructions that is better than a + block move. Make this large on i386, since the block move is very + inefficient with small blocks, and the hard register needs of the + block move require much reload work. */ +#define MOVE_RATIO 5 + +/* Define this if zero-extension is slow (more than one real instruction). */ +/* #define SLOW_ZERO_EXTEND */ + +/* Nonzero if access to memory by bytes is slow and undesirable. */ +#define SLOW_BYTE_ACCESS 0 + +/* Define if shifts truncate the shift count + which implies one can omit a sign-extension or zero-extension + of a shift count. */ +/* One i386, shifts do truncate the count. But bit opcodes don't. */ + +/* #define SHIFT_COUNT_TRUNCATED */ + +/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits + is done just by pretending it is already truncated. */ +#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 + +/* We assume that the store-condition-codes instructions store 0 for false + and some other value for true. This is the value stored for true. */ + +#define STORE_FLAG_VALUE 1 + +/* When a prototype says `char' or `short', really pass an `int'. + (The 386 can't easily push less than an int.) */ + +#define PROMOTE_PROTOTYPES + +/* Specify the machine mode that pointers have. + After generation of rtl, the compiler makes no further distinction + between pointers and any other objects of this machine mode. */ +#define Pmode SImode + +/* A function address in a call instruction + is a byte address (for indexing purposes) + so give the MEM rtx a byte's mode. */ +#define FUNCTION_MODE QImode + +/* Define this if addresses of constant functions + shouldn't be put through pseudo regs where they can be cse'd. + Desirable on the 386 because a CALL with a constant address is + not much slower than one with a register address. On a 486, + it is faster to call with a constant address than indirect. */ +#define NO_FUNCTION_CSE + +/* Provide the costs of a rtl expression. This is in the body of a + switch on CODE. */ + +#define RTX_COSTS(X,CODE,OUTER_CODE) \ + case MULT: \ + return COSTS_N_INSNS (20); \ + case DIV: \ + case UDIV: \ + case MOD: \ + case UMOD: \ + return COSTS_N_INSNS (20); \ + case ASHIFTRT: \ + case LSHIFTRT: \ + case ASHIFT: \ + return (4 + rtx_cost (XEXP (X, 0), OUTER_CODE) \ + + rtx_cost (XEXP (X, 1), OUTER_CODE)); \ + case PLUS: \ + if (GET_CODE (XEXP (X, 0)) == MULT \ + && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \ + && (INTVAL (XEXP (XEXP (X, 0), 1)) == 2 \ + || INTVAL (XEXP (XEXP (X, 0), 1)) == 4 \ + || INTVAL (XEXP (XEXP (X, 0), 1)) == 8)) \ + return (2 + rtx_cost (XEXP (XEXP (X, 0), 0), OUTER_CODE) \ + + rtx_cost (XEXP (X, 1), OUTER_CODE)); \ + break; + + +/* Compute the cost of computing a constant rtl expression RTX + whose rtx-code is CODE. The body of this macro is a portion + of a switch statement. If the code is computed here, + return it with a return statement. Otherwise, break from the switch. */ + +#define CONST_COSTS(RTX,CODE,OUTER_CODE) \ + case CONST_INT: \ + case CONST: \ + case LABEL_REF: \ + case SYMBOL_REF: \ + return flag_pic && SYMBOLIC_CONST (RTX) ? 2 : 0; \ + case CONST_DOUBLE: \ + { \ + int code; \ + if (GET_MODE (RTX) == VOIDmode) \ + return 2; \ + code = standard_80387_constant_p (RTX); \ + return code == 1 ? 0 : \ + code == 2 ? 1 : \ + 2; \ + } + +/* Compute the cost of an address. This is meant to approximate the size + and/or execution delay of an insn using that address. If the cost is + approximated by the RTL complexity, including CONST_COSTS above, as + is usually the case for CISC machines, this macro should not be defined. + For aggressively RISCy machines, only one insn format is allowed, so + this macro should be a constant. The value of this macro only matters + for valid addresses. + + For i386, it is better to use a complex address than let gcc copy + the address into a reg and make a new pseudo. But not if the address + requires to two regs - that would mean more pseudos with longer + lifetimes. */ + +#define ADDRESS_COST(RTX) \ + ((CONSTANT_P (RTX) \ + || (GET_CODE (RTX) == PLUS && CONSTANT_P (XEXP (RTX, 1)) \ + && REG_P (XEXP (RTX, 0)))) ? 0 \ + : REG_P (RTX) ? 1 \ + : 2) + +/* Add any extra modes needed to represent the condition code. + + For the i386, we need separate modes when floating-point equality + comparisons are being done. */ + +#define EXTRA_CC_MODES CCFPEQmode + +/* Define the names for the modes specified above. */ +#define EXTRA_CC_NAMES "CCFPEQ" + +/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, + return the mode to be used for the comparison. + + For floating-point equality comparisons, CCFPEQmode should be used. + VOIDmode should be used in all other cases. */ + +#define SELECT_CC_MODE(OP,X,Y) \ + (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ + && ((OP) == EQ || (OP) == NE) ? CCFPEQmode : VOIDmode) + +/* Define the information needed to generate branch and scc insns. This is + stored from the compare operation. Note that we can't use "rtx" here + since it hasn't been defined! */ + +extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); + +/* Tell final.c how to eliminate redundant test instructions. */ + +/* Here we define machine-dependent flags and fields in cc_status + (see `conditions.h'). */ + +/* Set if the cc value is actually in the 80387, so a floating point + conditional branch must be output. */ +#define CC_IN_80387 04000 + +/* Set if the CC value was stored in a nonstandard way, so that + the state of equality is indicated by zero in the carry bit. */ +#define CC_Z_IN_NOT_C 010000 + +/* Store in cc_status the expressions + that the condition codes will describe + after execution of an instruction whose pattern is EXP. + Do not alter them if the instruction would not alter the cc's. */ + +#define NOTICE_UPDATE_CC(EXP, INSN) \ + notice_update_cc((EXP)) + +/* Output a signed jump insn. Use template NORMAL ordinarily, or + FLOAT following a floating point comparison. + Use NO_OV following an arithmetic insn that set the cc's + before a test insn that was deleted. + NO_OV may be zero, meaning final should reinsert the test insn + because the jump cannot be handled properly without it. */ + +#define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \ +{ \ + if (cc_prev_status.flags & CC_IN_80387) \ + return FLOAT; \ + if (cc_prev_status.flags & CC_NO_OVERFLOW) \ + return NO_OV; \ + return NORMAL; \ +} + +/* Control the assembler format that we output, to the extent + this does not vary between assemblers. */ + +/* How to refer to registers in assembler output. + This sequence is indexed by compiler's hard-register-number (see above). */ + +/* In order to refer to the first 8 regs as 32 bit regs prefix an "e" + For non floating point regs, the following are the HImode names. + + For float regs, the stack top is sometimes referred to as "%st(0)" + instead of just "%st". PRINT_REG handles this with the "y" code. */ + +#define HI_REGISTER_NAMES \ +{"ax","dx","cx","bx","si","di","bp","sp", \ + "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)","" } + +#define REGISTER_NAMES HI_REGISTER_NAMES + +/* Table of additional register names to use in user input. */ + +#define ADDITIONAL_REGISTER_NAMES \ +{ "eax", 0, "edx", 1, "ecx", 2, "ebx", 3, \ + "esi", 4, "edi", 5, "ebp", 6, "esp", 7, \ + "al", 0, "dl", 1, "cl", 2, "bl", 3, \ + "ah", 0, "dh", 1, "ch", 2, "bh", 3 } + +/* Note we are omitting these since currently I don't know how +to get gcc to use these, since they want the same but different +number as al, and ax. +*/ + +/* note the last four are not really qi_registers, but + the md will have to never output movb into one of them + only a movw . There is no movb into the last four regs */ + +#define QI_REGISTER_NAMES \ +{"al", "dl", "cl", "bl", "si", "di", "bp", "sp",} + +/* These parallel the array above, and can be used to access bits 8:15 + of regs 0 through 3. */ + +#define QI_HIGH_REGISTER_NAMES \ +{"ah", "dh", "ch", "bh", } + +/* How to renumber registers for dbx and gdb. */ + +/* {0,2,1,3,6,7,4,5,12,13,14,15,16,17} */ +#define DBX_REGISTER_NUMBER(n) \ +((n) == 0 ? 0 : \ + (n) == 1 ? 2 : \ + (n) == 2 ? 1 : \ + (n) == 3 ? 3 : \ + (n) == 4 ? 6 : \ + (n) == 5 ? 7 : \ + (n) == 6 ? 4 : \ + (n) == 7 ? 5 : \ + (n) + 4) + +/* This is how to output the definition of a user-level label named NAME, + such as the label on a static function or variable NAME. */ + +#define ASM_OUTPUT_LABEL(FILE,NAME) \ + (assemble_name (FILE, NAME), fputs (":\n", FILE)) + +/* This is how to output an assembler line defining a `double' constant. */ + +#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ +do { long l[2]; \ + REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \ + if (sizeof (int) == sizeof (long)) \ + fprintf (FILE, "%s 0x%x,0x%x\n", ASM_LONG, l[0], l[1]); \ + else \ + fprintf (FILE, "%s 0x%lx,0x%lx\n", ASM_LONG, l[0], l[1]); \ + } while (0) + +/* This is how to output a `long double' extended real constant. */ + +#undef ASM_OUTPUT_LONG_DOUBLE +#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \ +do { long l[3]; \ + REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \ + if (sizeof (int) == sizeof (long)) \ + fprintf (FILE, "%s 0x%x,0x%x,0x%x\n", ASM_LONG, l[0], l[1], l[2]); \ + else \ + fprintf (FILE, "%s 0x%lx,0x%lx,0x%lx\n", ASM_LONG, l[0], l[1], l[2]); \ + } while (0) + +/* This is how to output an assembler line defining a `float' constant. */ + +#define ASM_OUTPUT_FLOAT(FILE,VALUE) \ +do { long l; \ + REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ + if (sizeof (int) == sizeof (long)) \ + fprintf ((FILE), "%s 0x%x\n", ASM_LONG, l); \ + else \ + fprintf ((FILE), "%s 0x%lx\n", ASM_LONG, l); \ + } while (0) + +/* Store in OUTPUT a string (made with alloca) containing + an assembler-name for a local static variable named NAME. + LABELNO is an integer which is different for each call. */ + +#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ +( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ + sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO))) + + + +/* This is how to output an assembler line defining an `int' constant. */ + +#define ASM_OUTPUT_INT(FILE,VALUE) \ +( fprintf (FILE, "%s ", ASM_LONG), \ + output_addr_const (FILE,(VALUE)), \ + putc('\n',FILE)) + +/* Likewise for `char' and `short' constants. */ +/* is this supposed to do align too?? */ + +#define ASM_OUTPUT_SHORT(FILE,VALUE) \ +( fprintf (FILE, "%s ", ASM_SHORT), \ + output_addr_const (FILE,(VALUE)), \ + putc('\n',FILE)) + +/* +#define ASM_OUTPUT_SHORT(FILE,VALUE) \ +( fprintf (FILE, "%s ", ASM_BYTE_OP), \ + output_addr_const (FILE,(VALUE)), \ + fputs (",", FILE), \ + output_addr_const (FILE,(VALUE)), \ + fputs (" >> 8\n",FILE)) +*/ + + +#define ASM_OUTPUT_CHAR(FILE,VALUE) \ +( fprintf (FILE, "%s ", ASM_BYTE_OP), \ + output_addr_const (FILE, (VALUE)), \ + putc ('\n', FILE)) + +/* This is how to output an assembler line for a numeric constant byte. */ + +#define ASM_OUTPUT_BYTE(FILE,VALUE) \ + fprintf ((FILE), "%s 0x%x\n", ASM_BYTE_OP, (VALUE)) + +/* This is how to output an insn to push a register on the stack. + It need not be very fast code. */ + +#define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ + fprintf (FILE, "\tpushl e%s\n", reg_names[REGNO]) + +/* This is how to output an insn to pop a register from the stack. + It need not be very fast code. */ + +#define ASM_OUTPUT_REG_POP(FILE,REGNO) \ + fprintf (FILE, "\tpopl e%s\n", reg_names[REGNO]) + +/* This is how to output an element of a case-vector that is absolute. + */ + +#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ + fprintf (FILE, "%s %s%d\n", ASM_LONG, LPREFIX, VALUE) + +/* This is how to output an element of a case-vector that is relative. + We don't use these on the 386 yet, because the ATT assembler can't do + forward reference the differences. + */ + +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ + fprintf (FILE, "\t.word %s%d-%s%d\n",LPREFIX, VALUE,LPREFIX, REL) + +/* Define the parentheses used to group arithmetic operations + in assembler code. */ + +#define ASM_OPEN_PAREN "" +#define ASM_CLOSE_PAREN "" + +/* Define results of standard character escape sequences. */ +#define TARGET_BELL 007 +#define TARGET_BS 010 +#define TARGET_TAB 011 +#define TARGET_NEWLINE 012 +#define TARGET_VT 013 +#define TARGET_FF 014 +#define TARGET_CR 015 + +/* Print operand X (an rtx) in assembler syntax to file FILE. + CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. + The CODE z takes the size of operand from the following digit, and + outputs b,w,or l respectively. + + On the 80386, we use several such letters: + f -- float insn (print a CONST_DOUBLE as a float rather than in hex). + L,W,B,Q,S,T -- print the opcode suffix for specified size of operand. + R -- print the prefix for register names. + z -- print the opcode suffix for the size of the current operand. + * -- print a star (in certain assembler syntax) + w -- print the operand as if it's a "word" (HImode) even if it isn't. + b -- print the operand as if it's a byte (QImode) even if it isn't. + c -- don't print special prefixes before constant operands. */ + +#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ + ((CODE) == '*') + +/* Print the name of a register based on its machine mode and number. + If CODE is 'w', pretend the mode is HImode. + If CODE is 'b', pretend the mode is QImode. + If CODE is 'k', pretend the mode is SImode. + If CODE is 'h', pretend the reg is the `high' byte register. + If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op. */ + +extern char *hi_reg_name[]; +extern char *qi_reg_name[]; +extern char *qi_high_reg_name[]; + +#define PRINT_REG(X, CODE, FILE) \ + do { if (REGNO (X) == ARG_POINTER_REGNUM) \ + abort (); \ + fprintf (FILE, "%s", RP); \ + switch ((CODE == 'w' ? 2 \ + : CODE == 'b' ? 1 \ + : CODE == 'k' ? 4 \ + : CODE == 'y' ? 3 \ + : CODE == 'h' ? 0 \ + : GET_MODE_SIZE (GET_MODE (X)))) \ + { \ + case 3: \ + if (STACK_TOP_P (X)) \ + { \ + fputs ("st(0)", FILE); \ + break; \ + } \ + case 4: \ + case 8: \ + case 12: \ + if (! FP_REG_P (X)) fputs ("e", FILE); \ + case 2: \ + fputs (hi_reg_name[REGNO (X)], FILE); \ + break; \ + case 1: \ + fputs (qi_reg_name[REGNO (X)], FILE); \ + break; \ + case 0: \ + fputs (qi_high_reg_name[REGNO (X)], FILE); \ + break; \ + } \ + } while (0) + +#define PRINT_OPERAND(FILE, X, CODE) \ + print_operand (FILE, X, CODE) + +#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \ + print_operand_address (FILE, ADDR) + +/* Print the name of a register for based on its machine mode and number. + This macro is used to print debugging output. + This macro is different from PRINT_REG in that it may be used in + programs that are not linked with aux-output.o. */ + +#define DEBUG_PRINT_REG(X, CODE, FILE) \ + do { static char *hi_name[] = HI_REGISTER_NAMES; \ + static char *qi_name[] = QI_REGISTER_NAMES; \ + fprintf (FILE, "%d %s", REGNO (X), RP); \ + if (REGNO (X) == ARG_POINTER_REGNUM) \ + { fputs ("argp", FILE); break; } \ + if (STACK_TOP_P (X)) \ + { fputs ("st(0)", FILE); break; } \ + if (FP_REG_P (X)) \ + { fputs (hi_name[REGNO(X)], FILE); break; } \ + switch (GET_MODE_SIZE (GET_MODE (X))) \ + { \ + default: \ + fputs ("e", FILE); \ + case 2: \ + fputs (hi_name[REGNO (X)], FILE); \ + break; \ + case 1: \ + fputs (qi_name[REGNO (X)], FILE); \ + break; \ + } \ + } while (0) + +/* Output the prefix for an immediate operand, or for an offset operand. */ +#define PRINT_IMMED_PREFIX(FILE) fputs (IP, (FILE)) +#define PRINT_OFFSET_PREFIX(FILE) fputs (IP, (FILE)) + +/* Routines in libgcc that return floats must return them in an fp reg, + just as other functions do which return such values. + These macros make that happen. */ + +#define FLOAT_VALUE_TYPE float +#define INTIFY(FLOATVAL) FLOATVAL + +/* Nonzero if INSN magically clobbers register REGNO. */ + +/* #define INSN_CLOBBERS_REGNO_P(INSN, REGNO) \ + (FP_REGNO_P (REGNO) \ + && (GET_CODE (INSN) == JUMP_INSN || GET_CODE (INSN) == BARRIER)) +*/ + +/* a letter which is not needed by the normal asm syntax, which + we can use for operand syntax in the extended asm */ + +#define ASM_OPERAND_LETTER '#' + +#define RET return "" +#define AT_SP(mode) (gen_rtx (MEM, (mode), stack_pointer_rtx)) + +/* Functions in i386.c */ +extern void override_options (); +extern void order_regs_for_local_alloc (); +extern int i386_valid_decl_attribute_p (); +extern int i386_valid_type_attribute_p (); +extern int i386_return_pops_args (); +extern int i386_comp_type_attributes (); +extern void init_cumulative_args (); +extern void function_arg_advance (); +extern struct rtx_def *function_arg (); +extern int function_arg_partial_nregs (); +extern void output_op_from_reg (); +extern void output_to_reg (); +extern char *singlemove_string (); +extern char *output_move_double (); +extern char *output_move_memory (); +extern char *output_move_pushmem (); +extern int standard_80387_constant_p (); +extern char *output_move_const_single (); +extern int symbolic_operand (); +extern int call_insn_operand (); +extern int expander_call_insn_operand (); +extern int symbolic_reference_mentioned_p (); +extern void emit_pic_move (); +extern void function_prologue (); +extern int simple_386_epilogue (); +extern void function_epilogue (); +extern int legitimate_address_p (); +extern struct rtx_def *legitimize_pic_address (); +extern struct rtx_def *legitimize_address (); +extern void print_operand (); +extern void print_operand_address (); +extern void notice_update_cc (); +extern void split_di (); +extern int binary_387_op (); +extern int shift_op (); +extern int VOIDmode_compare_op (); +extern char *output_387_binary_op (); +extern char *output_fix_trunc (); +extern char *output_float_compare (); +extern char *output_fp_cc0_set (); +extern void save_386_machine_status (); +extern void restore_386_machine_status (); +extern void clear_386_stack_locals (); +extern struct rtx_def *assign_386_stack_local (); + +/* Variables in i386.c */ +extern char *i386_reg_alloc_order; /* register allocation order */ +extern char *i386_regparm_string; /* # registers to use to pass args */ +extern char *i386_align_loops_string; /* power of two alignment for loops */ +extern char *i386_align_jumps_string; /* power of two alignment for non-loop jumps */ +extern char *i386_align_funcs_string; /* power of two alignment for functions */ +extern int i386_regparm; /* i386_regparm_string as a number */ +extern int i386_align_loops; /* power of two alignment for loops */ +extern int i386_align_jumps; /* power of two alignment for non-loop jumps */ +extern int i386_align_funcs; /* power of two alignment for functions */ +extern char *hi_reg_name[]; /* names for 16 bit regs */ +extern char *qi_reg_name[]; /* names for 8 bit regs (low) */ +extern char *qi_high_reg_name[]; /* names for 8 bit regs (high) */ +extern enum reg_class regclass_map[]; /* smalled class containing REGNO */ +extern struct rtx_def *i386_compare_op0; /* operand 0 for comparisons */ +extern struct rtx_def *i386_compare_op1; /* operand 1 for comparisons */ + +/* External variables used */ +extern int optimize; /* optimization level */ +extern int obey_regdecls; /* TRUE if stupid register allocation */ + +/* External functions used */ +extern struct rtx_def *force_operand (); + +/* +Local variables: +version-control: t +End: +*/ diff --git a/support/cpp/i386/i386.md b/support/cpp/i386/i386.md new file mode 100644 index 00000000..ff011963 --- /dev/null +++ b/support/cpp/i386/i386.md @@ -0,0 +1,5775 @@ +;; GCC machine description for Intel X86. +;; Copyright (C) 1988, 1994, 1995 Free Software Foundation, Inc. +;; Mostly by William Schelter. + +;; This file is part of GNU CC. + +;; GNU CC 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, or (at your option) +;; any later version. + +;; GNU CC 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 GNU CC; see the file COPYING. If not, write to +;; the Free Software Foundation, 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;; The original PO technology requires these to be ordered by speed, +;; so that assigner will pick the fastest. + +;; See file "rtl.def" for documentation on define_insn, match_*, et. al. + +;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code +;; updates for most instructions. + +;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register +;; constraint letters. + +;; the special asm out single letter directives following a '%' are: +;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of +;; operands[1]. +;; 'L' Print the opcode suffix for a 32-bit integer opcode. +;; 'W' Print the opcode suffix for a 16-bit integer opcode. +;; 'B' Print the opcode suffix for an 8-bit integer opcode. +;; 'S' Print the opcode suffix for a 32-bit float opcode. +;; 'Q' Print the opcode suffix for a 64-bit float opcode. +;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode. +;; 'J' Print the appropriate jump operand. + +;; 'b' Print the QImode name of the register for the indicated operand. +;; %b0 would print %al if operands[0] is reg 0. +;; 'w' Likewise, print the HImode name of the register. +;; 'k' Likewise, print the SImode name of the register. +;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh. +;; 'y' Print "st(0)" instead of "st" as a register. + +;; UNSPEC usage: +;; 0 This is a `scas' operation. The mode of the UNSPEC is always SImode. +;; operand 0 is the memory address to scan. +;; operand 1 is a register containing the value to scan for. The mode +;; of the scas opcode will be the same as the mode of this operand. +;; operand 2 is the known alignment of operand 0. +;; 1 This is a `sin' operation. The mode of the UNSPEC is MODE_FLOAT. +;; operand 0 is the argument for `sin'. +;; 2 This is a `cos' operation. The mode of the UNSPEC is MODE_FLOAT. +;; operand 0 is the argument for `cos'. + +;; "movl MEM,REG / testl REG,REG" is faster on a 486 than "cmpl $0,MEM". +;; But restricting MEM here would mean that gcc could not remove a redundant +;; test in cases like "incl MEM / je TARGET". +;; +;; We don't want to allow a constant operand for test insns because +;; (set (cc0) (const_int foo)) has no mode information. Such insns will +;; be folded while optimizing anyway. + +;; All test insns have expanders that save the operands away without +;; actually generating RTL. The bCOND or sCOND (emitted immediately +;; after the tstM or cmp) will actually emit the tstM or cmpM. + +(define_insn "tstsi_1" + [(set (cc0) + (match_operand:SI 0 "nonimmediate_operand" "rm"))] + "" + "* +{ + if (REG_P (operands[0])) + return AS2 (test%L0,%0,%0); + + operands[1] = const0_rtx; + return AS2 (cmp%L0,%1,%0); +}") + +(define_expand "tstsi" + [(set (cc0) + (match_operand:SI 0 "nonimmediate_operand" ""))] + "" + " +{ + i386_compare_gen = gen_tstsi_1; + i386_compare_op0 = operands[0]; + DONE; +}") + +(define_insn "tsthi_1" + [(set (cc0) + (match_operand:HI 0 "nonimmediate_operand" "rm"))] + "" + "* +{ + if (REG_P (operands[0])) + return AS2 (test%W0,%0,%0); + + operands[1] = const0_rtx; + return AS2 (cmp%W0,%1,%0); +}") + +(define_expand "tsthi" + [(set (cc0) + (match_operand:HI 0 "nonimmediate_operand" ""))] + "" + " +{ + i386_compare_gen = gen_tsthi_1; + i386_compare_op0 = operands[0]; + DONE; +}") + +(define_insn "tstqi_1" + [(set (cc0) + (match_operand:QI 0 "nonimmediate_operand" "qm"))] + "" + "* +{ + if (REG_P (operands[0])) + return AS2 (test%B0,%0,%0); + + operands[1] = const0_rtx; + return AS2 (cmp%B0,%1,%0); +}") + +(define_expand "tstqi" + [(set (cc0) + (match_operand:QI 0 "nonimmediate_operand" ""))] + "" + " +{ + i386_compare_gen = gen_tstqi_1; + i386_compare_op0 = operands[0]; + DONE; +}") + +(define_insn "tstsf_cc" + [(set (cc0) + (match_operand:SF 0 "register_operand" "f")) + (clobber (match_scratch:HI 1 "=a"))] + "TARGET_80387 && ! TARGET_IEEE_FP" + "* +{ + if (! STACK_TOP_P (operands[0])) + abort (); + + output_asm_insn (\"ftst\", operands); + + if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fstp,%y0), operands); + + return output_fp_cc0_set (insn); +}") + +;; Don't generate tstsf if generating IEEE code, since the `ftst' opcode +;; isn't IEEE compliant. + +(define_expand "tstsf" + [(parallel [(set (cc0) + (match_operand:SF 0 "register_operand" "")) + (clobber (match_scratch:HI 1 ""))])] + "TARGET_80387 && ! TARGET_IEEE_FP" + " +{ + i386_compare_gen = gen_tstsf_cc; + i386_compare_op0 = operands[0]; + DONE; +}") + +(define_insn "tstdf_cc" + [(set (cc0) + (match_operand:DF 0 "register_operand" "f")) + (clobber (match_scratch:HI 1 "=a"))] + "TARGET_80387 && ! TARGET_IEEE_FP" + "* +{ + if (! STACK_TOP_P (operands[0])) + abort (); + + output_asm_insn (\"ftst\", operands); + + if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fstp,%y0), operands); + + return output_fp_cc0_set (insn); +}") + +;; Don't generate tstdf if generating IEEE code, since the `ftst' opcode +;; isn't IEEE compliant. + +(define_expand "tstdf" + [(parallel [(set (cc0) + (match_operand:DF 0 "register_operand" "")) + (clobber (match_scratch:HI 1 ""))])] + "TARGET_80387 && ! TARGET_IEEE_FP" + " +{ + i386_compare_gen = gen_tstdf_cc; + i386_compare_op0 = operands[0]; + DONE; +}") + +(define_insn "tstxf_cc" + [(set (cc0) + (match_operand:XF 0 "register_operand" "f")) + (clobber (match_scratch:HI 1 "=a"))] + "TARGET_80387 && ! TARGET_IEEE_FP" + "* +{ + if (! STACK_TOP_P (operands[0])) + abort (); + + output_asm_insn (\"ftst\", operands); + + if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fstp,%y0), operands); + + return output_fp_cc0_set (insn); +}") + +;; Don't generate tstdf if generating IEEE code, since the `ftst' opcode +;; isn't IEEE compliant. + +(define_expand "tstxf" + [(parallel [(set (cc0) + (match_operand:XF 0 "register_operand" "")) + (clobber (match_scratch:HI 1 ""))])] + "TARGET_80387 && ! TARGET_IEEE_FP" + " +{ + i386_compare_gen = gen_tstxf_cc; + i386_compare_op0 = operands[0]; + DONE; +}") + +;;- compare instructions. See comments above tstM patterns about +;; expansion of these insns. + +(define_insn "cmpsi_1" + [(set (cc0) + (compare (match_operand:SI 0 "nonimmediate_operand" "mr,r") + (match_operand:SI 1 "general_operand" "ri,mr")))] + "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" + "* +{ + if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) + { + cc_status.flags |= CC_REVERSED; + return AS2 (cmp%L0,%0,%1); + } + return AS2 (cmp%L0,%1,%0); +}") + +(define_expand "cmpsi" + [(set (cc0) + (compare (match_operand:SI 0 "nonimmediate_operand" "") + (match_operand:SI 1 "general_operand" "")))] + "" + " +{ + if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) + operands[0] = force_reg (SImode, operands[0]); + + i386_compare_gen = gen_cmpsi_1; + i386_compare_op0 = operands[0]; + i386_compare_op1 = operands[1]; + DONE; +}") + +(define_insn "cmphi_1" + [(set (cc0) + (compare (match_operand:HI 0 "nonimmediate_operand" "mr,r") + (match_operand:HI 1 "general_operand" "ri,mr")))] + "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" + "* +{ + if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) + { + cc_status.flags |= CC_REVERSED; + return AS2 (cmp%W0,%0,%1); + } + return AS2 (cmp%W0,%1,%0); +}") + +(define_expand "cmphi" + [(set (cc0) + (compare (match_operand:HI 0 "nonimmediate_operand" "") + (match_operand:HI 1 "general_operand" "")))] + "" + " +{ + if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) + operands[0] = force_reg (HImode, operands[0]); + + i386_compare_gen = gen_cmphi_1; + i386_compare_op0 = operands[0]; + i386_compare_op1 = operands[1]; + DONE; +}") + +(define_insn "cmpqi_1" + [(set (cc0) + (compare (match_operand:QI 0 "nonimmediate_operand" "q,mq") + (match_operand:QI 1 "general_operand" "qm,nq")))] + "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" + "* +{ + if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) + { + cc_status.flags |= CC_REVERSED; + return AS2 (cmp%B0,%0,%1); + } + return AS2 (cmp%B0,%1,%0); +}") + +(define_expand "cmpqi" + [(set (cc0) + (compare (match_operand:QI 0 "nonimmediate_operand" "") + (match_operand:QI 1 "general_operand" "")))] + "" + " +{ + if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) + operands[0] = force_reg (QImode, operands[0]); + + i386_compare_gen = gen_cmpqi_1; + i386_compare_op0 = operands[0]; + i386_compare_op1 = operands[1]; + DONE; +}") + +;; These implement float point compares. For each of DFmode and +;; SFmode, there is the normal insn, and an insn where the second operand +;; is converted to the desired mode. + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:XF 0 "nonimmediate_operand" "f") + (match_operand:XF 1 "nonimmediate_operand" "f")])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387 + && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:XF 0 "register_operand" "f") + (float:XF + (match_operand:SI 1 "nonimmediate_operand" "rm"))])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(float:XF + (match_operand:SI 0 "nonimmediate_operand" "rm")) + (match_operand:XF 1 "register_operand" "f")])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:XF 0 "register_operand" "f") + (float_extend:XF + (match_operand:DF 1 "nonimmediate_operand" "fm"))])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:XF 0 "register_operand" "f") + (float_extend:XF + (match_operand:SF 1 "nonimmediate_operand" "fm"))])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (compare:CCFPEQ (match_operand:XF 0 "register_operand" "f") + (match_operand:XF 1 "register_operand" "f"))) + (clobber (match_scratch:HI 2 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:DF 0 "nonimmediate_operand" "f,fm") + (match_operand:DF 1 "nonimmediate_operand" "fm,f")])) + (clobber (match_scratch:HI 3 "=a,a"))] + "TARGET_80387 + && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:DF 0 "register_operand" "f") + (float:DF + (match_operand:SI 1 "nonimmediate_operand" "rm"))])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(float:DF + (match_operand:SI 0 "nonimmediate_operand" "rm")) + (match_operand:DF 1 "register_operand" "f")])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:DF 0 "register_operand" "f") + (float_extend:DF + (match_operand:SF 1 "nonimmediate_operand" "fm"))])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(float_extend:DF + (match_operand:SF 0 "nonimmediate_operand" "fm")) + (match_operand:DF 1 "register_operand" "f")])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (compare:CCFPEQ (match_operand:DF 0 "register_operand" "f") + (match_operand:DF 1 "register_operand" "f"))) + (clobber (match_scratch:HI 2 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +;; These two insns will never be generated by combine due to the mode of +;; the COMPARE. +;(define_insn "" +; [(set (cc0) +; (compare:CCFPEQ (match_operand:DF 0 "register_operand" "f") +; (float_extend:DF +; (match_operand:SF 1 "register_operand" "f")))) +; (clobber (match_scratch:HI 2 "=a"))] +; "TARGET_80387" +; "* return output_float_compare (insn, operands);") +; +;(define_insn "" +; [(set (cc0) +; (compare:CCFPEQ (float_extend:DF +; (match_operand:SF 0 "register_operand" "f")) +; (match_operand:DF 1 "register_operand" "f"))) +; (clobber (match_scratch:HI 2 "=a"))] +; "TARGET_80387" +; "* return output_float_compare (insn, operands);") + +(define_insn "cmpsf_cc_1" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:SF 0 "nonimmediate_operand" "f,fm") + (match_operand:SF 1 "nonimmediate_operand" "fm,f")])) + (clobber (match_scratch:HI 3 "=a,a"))] + "TARGET_80387 + && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(match_operand:SF 0 "register_operand" "f") + (float:SF + (match_operand:SI 1 "nonimmediate_operand" "rm"))])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (match_operator 2 "VOIDmode_compare_op" + [(float:SF + (match_operand:SI 0 "nonimmediate_operand" "rm")) + (match_operand:SF 1 "register_operand" "f")])) + (clobber (match_scratch:HI 3 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_insn "" + [(set (cc0) + (compare:CCFPEQ (match_operand:SF 0 "register_operand" "f") + (match_operand:SF 1 "register_operand" "f"))) + (clobber (match_scratch:HI 2 "=a"))] + "TARGET_80387" + "* return output_float_compare (insn, operands);") + +(define_expand "cmpxf" + [(set (cc0) + (compare (match_operand:XF 0 "register_operand" "") + (match_operand:XF 1 "nonimmediate_operand" "")))] + "TARGET_80387" + " +{ + i386_compare_gen = gen_cmpxf_cc; + i386_compare_gen_eq = gen_cmpxf_ccfpeq; + i386_compare_op0 = operands[0]; + i386_compare_op1 = operands[1]; + DONE; +}") + +(define_expand "cmpdf" + [(set (cc0) + (compare (match_operand:DF 0 "register_operand" "") + (match_operand:DF 1 "nonimmediate_operand" "")))] + "TARGET_80387" + " +{ + i386_compare_gen = gen_cmpdf_cc; + i386_compare_gen_eq = gen_cmpdf_ccfpeq; + i386_compare_op0 = operands[0]; + i386_compare_op1 = operands[1]; + DONE; +}") + +(define_expand "cmpsf" + [(set (cc0) + (compare (match_operand:SF 0 "register_operand" "") + (match_operand:SF 1 "nonimmediate_operand" "")))] + "TARGET_80387" + " +{ + i386_compare_gen = gen_cmpsf_cc; + i386_compare_gen_eq = gen_cmpsf_ccfpeq; + i386_compare_op0 = operands[0]; + i386_compare_op1 = operands[1]; + DONE; +}") + +(define_expand "cmpxf_cc" + [(parallel [(set (cc0) + (compare (match_operand:XF 0 "register_operand" "") + (match_operand:XF 1 "register_operand" ""))) + (clobber (match_scratch:HI 2 ""))])] + "TARGET_80387" + "") + +(define_expand "cmpxf_ccfpeq" + [(parallel [(set (cc0) + (compare:CCFPEQ (match_operand:XF 0 "register_operand" "") + (match_operand:XF 1 "register_operand" ""))) + (clobber (match_scratch:HI 2 ""))])] + "TARGET_80387" + " +{ + if (! register_operand (operands[1], XFmode)) + operands[1] = copy_to_mode_reg (XFmode, operands[1]); +}") + +(define_expand "cmpdf_cc" + [(parallel [(set (cc0) + (compare (match_operand:DF 0 "register_operand" "") + (match_operand:DF 1 "register_operand" ""))) + (clobber (match_scratch:HI 2 ""))])] + "TARGET_80387" + "") + +(define_expand "cmpdf_ccfpeq" + [(parallel [(set (cc0) + (compare:CCFPEQ (match_operand:DF 0 "register_operand" "") + (match_operand:DF 1 "register_operand" ""))) + (clobber (match_scratch:HI 2 ""))])] + "TARGET_80387" + " +{ + if (! register_operand (operands[1], DFmode)) + operands[1] = copy_to_mode_reg (DFmode, operands[1]); +}") + +(define_expand "cmpsf_cc" + [(parallel [(set (cc0) + (compare (match_operand:SF 0 "register_operand" "") + (match_operand:SF 1 "register_operand" ""))) + (clobber (match_scratch:HI 2 ""))])] + "TARGET_80387" + "") + +(define_expand "cmpsf_ccfpeq" + [(parallel [(set (cc0) + (compare:CCFPEQ (match_operand:SF 0 "register_operand" "") + (match_operand:SF 1 "register_operand" ""))) + (clobber (match_scratch:HI 2 ""))])] + "TARGET_80387" + " +{ + if (! register_operand (operands[1], SFmode)) + operands[1] = copy_to_mode_reg (SFmode, operands[1]); +}") + +;; logical compare + +(define_insn "" + [(set (cc0) + (and:SI (match_operand:SI 0 "general_operand" "%ro") + (match_operand:SI 1 "general_operand" "ri")))] + "" + "* +{ + /* For small integers, we may actually use testb. */ + if (GET_CODE (operands[1]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])) + && (! REG_P (operands[0]) || QI_REG_P (operands[0]))) + { + /* We may set the sign bit spuriously. */ + + if ((INTVAL (operands[1]) & ~0xff) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + return AS2 (test%B0,%1,%b0); + } + + if ((INTVAL (operands[1]) & ~0xff00) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + operands[1] = GEN_INT (INTVAL (operands[1]) >> 8); + + if (QI_REG_P (operands[0])) + return AS2 (test%B0,%1,%h0); + else + { + operands[0] = adj_offsettable_operand (operands[0], 1); + return AS2 (test%B0,%1,%b0); + } + } + + if (GET_CODE (operands[0]) == MEM + && (INTVAL (operands[1]) & ~0xff0000) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + operands[1] = GEN_INT (INTVAL (operands[1]) >> 16); + operands[0] = adj_offsettable_operand (operands[0], 2); + return AS2 (test%B0,%1,%b0); + } + + if (GET_CODE (operands[0]) == MEM + && (INTVAL (operands[1]) & ~0xff000000) == 0) + { + operands[1] = GEN_INT ((INTVAL (operands[1]) >> 24) & 0xff); + operands[0] = adj_offsettable_operand (operands[0], 3); + return AS2 (test%B0,%1,%b0); + } + } + + if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) + return AS2 (test%L0,%1,%0); + + return AS2 (test%L1,%0,%1); +}") + +(define_insn "" + [(set (cc0) + (and:HI (match_operand:HI 0 "general_operand" "%ro") + (match_operand:HI 1 "general_operand" "ri")))] + "" + "* +{ + if (GET_CODE (operands[1]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])) + && (! REG_P (operands[0]) || QI_REG_P (operands[0]))) + { + if ((INTVAL (operands[1]) & 0xff00) == 0) + { + /* ??? This might not be necessary. */ + if (INTVAL (operands[1]) & 0xffff0000) + operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff); + + /* We may set the sign bit spuriously. */ + cc_status.flags |= CC_NOT_NEGATIVE; + return AS2 (test%B0,%1,%b0); + } + + if ((INTVAL (operands[1]) & 0xff) == 0) + { + operands[1] = GEN_INT ((INTVAL (operands[1]) >> 8) & 0xff); + + if (QI_REG_P (operands[0])) + return AS2 (test%B0,%1,%h0); + else + { + operands[0] = adj_offsettable_operand (operands[0], 1); + return AS2 (test%B0,%1,%b0); + } + } + } + + if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) + return AS2 (test%W0,%1,%0); + + return AS2 (test%W1,%0,%1); +}") + +(define_insn "" + [(set (cc0) + (and:QI (match_operand:QI 0 "general_operand" "%qm") + (match_operand:QI 1 "general_operand" "qi")))] + "" + "* +{ + if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) + return AS2 (test%B0,%1,%0); + + return AS2 (test%B1,%0,%1); +}") + +;; move instructions. +;; There is one for each machine mode, +;; and each is preceded by a corresponding push-insn pattern +;; (since pushes are not general_operands on the 386). + +(define_insn "" + [(set (match_operand:SI 0 "push_operand" "=<") + (match_operand:SI 1 "general_operand" "g"))] + "TARGET_386" + "push%L0 %1") + +;; On a 486, it is faster to move MEM to a REG and then push, rather than +;; push MEM directly. + +(define_insn "" + [(set (match_operand:SI 0 "push_operand" "=<") + (match_operand:SI 1 "nonmemory_operand" "ri"))] + "!TARGET_386 && TARGET_MOVE" + "push%L0 %1") + +(define_insn "" + [(set (match_operand:SI 0 "push_operand" "=<") + (match_operand:SI 1 "general_operand" "ri"))] + "!TARGET_386 && !TARGET_MOVE" + "push%L0 %1") + +;; General case of fullword move. + +;; If generating PIC code and operands[1] is a symbolic CONST, emit a +;; move to get the address of the symbolic object from the GOT. + +(define_expand "movsi" + [(set (match_operand:SI 0 "general_operand" "") + (match_operand:SI 1 "general_operand" ""))] + "" + " +{ + extern int flag_pic; + + if (flag_pic && SYMBOLIC_CONST (operands[1])) + emit_pic_move (operands, SImode); + + /* Don't generate memory->memory moves, go through a register */ + else if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && GET_CODE (operands[1]) == MEM) + { + operands[1] = force_reg (SImode, operands[1]); + } +}") + +;; On i486, incl reg is faster than movl $1,reg. + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=g,r") + (match_operand:SI 1 "general_operand" "ri,m"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + rtx link; + if (operands[1] == const0_rtx && REG_P (operands[0])) + return AS2 (xor%L0,%0,%0); + + if (operands[1] == const1_rtx + && (link = find_reg_note (insn, REG_WAS_0, 0)) + /* Make sure the insn that stored the 0 is still present. */ + && ! INSN_DELETED_P (XEXP (link, 0)) + && GET_CODE (XEXP (link, 0)) != NOTE + /* Make sure cross jumping didn't happen here. */ + && no_labels_between_p (XEXP (link, 0), insn) + /* Make sure the reg hasn't been clobbered. */ + && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) + /* Fastest way to change a 0 to a 1. */ + return AS1 (inc%L0,%0); + + if (flag_pic && SYMBOLIC_CONST (operands[1])) + return AS2 (lea%L0,%a1,%0); + + return AS2 (mov%L0,%1,%0); +}") + +(define_insn "" + [(set (match_operand:HI 0 "push_operand" "=<") + (match_operand:HI 1 "general_operand" "g"))] + "TARGET_386" + "push%W0 %1") + +(define_insn "" + [(set (match_operand:HI 0 "push_operand" "=<") + (match_operand:HI 1 "nonmemory_operand" "ri"))] + "!TARGET_386 && TARGET_MOVE" + "push%W0 %1") + +(define_insn "" + [(set (match_operand:HI 0 "push_operand" "=<") + (match_operand:HI 1 "general_operand" "ri"))] + "!TARGET_386 && !TARGET_MOVE" + "push%W0 %1") + +;; On i486, an incl and movl are both faster than incw and movw. + +(define_expand "movhi" + [(set (match_operand:HI 0 "general_operand" "") + (match_operand:HI 1 "general_operand" ""))] + "" + " +{ + /* Don't generate memory->memory moves, go through a register */ + if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && GET_CODE (operands[1]) == MEM) + { + operands[1] = force_reg (HImode, operands[1]); + } +}") + +(define_insn "" + [(set (match_operand:HI 0 "general_operand" "=g,r") + (match_operand:HI 1 "general_operand" "ri,m"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + rtx link; + if (REG_P (operands[0]) && operands[1] == const0_rtx) + return AS2 (xor%L0,%k0,%k0); + + if (REG_P (operands[0]) && operands[1] == const1_rtx + && (link = find_reg_note (insn, REG_WAS_0, 0)) + /* Make sure the insn that stored the 0 is still present. */ + && ! INSN_DELETED_P (XEXP (link, 0)) + && GET_CODE (XEXP (link, 0)) != NOTE + /* Make sure cross jumping didn't happen here. */ + && no_labels_between_p (XEXP (link, 0), insn) + /* Make sure the reg hasn't been clobbered. */ + && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) + /* Fastest way to change a 0 to a 1. */ + return AS1 (inc%L0,%k0); + + if (REG_P (operands[0])) + { + if (REG_P (operands[1])) + return AS2 (mov%L0,%k1,%k0); + else if (CONSTANT_P (operands[1])) + return AS2 (mov%L0,%1,%k0); + } + + return AS2 (mov%W0,%1,%0); +}") + +(define_expand "movstricthi" + [(set (strict_low_part (match_operand:HI 0 "general_operand" "")) + (match_operand:HI 1 "general_operand" ""))] + "" + " +{ + /* Don't generate memory->memory moves, go through a register */ + if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && GET_CODE (operands[1]) == MEM) + { + operands[1] = force_reg (HImode, operands[1]); + } +}") + +(define_insn "" + [(set (strict_low_part (match_operand:HI 0 "general_operand" "+g,r")) + (match_operand:HI 1 "general_operand" "ri,m"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + rtx link; + if (operands[1] == const0_rtx && REG_P (operands[0])) + return AS2 (xor%W0,%0,%0); + + if (operands[1] == const1_rtx + && (link = find_reg_note (insn, REG_WAS_0, 0)) + /* Make sure the insn that stored the 0 is still present. */ + && ! INSN_DELETED_P (XEXP (link, 0)) + && GET_CODE (XEXP (link, 0)) != NOTE + /* Make sure cross jumping didn't happen here. */ + && no_labels_between_p (XEXP (link, 0), insn) + /* Make sure the reg hasn't been clobbered. */ + && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) + /* Fastest way to change a 0 to a 1. */ + return AS1 (inc%W0,%0); + + return AS2 (mov%W0,%1,%0); +}") + +;; emit_push_insn when it calls move_by_pieces +;; requires an insn to "push a byte". +;; But actually we use pushw, which has the effect of rounding +;; the amount pushed up to a halfword. +(define_insn "" + [(set (match_operand:QI 0 "push_operand" "=<") + (match_operand:QI 1 "immediate_operand" "n"))] + "" + "* return AS1 (push%W0,%1);") + +(define_insn "" + [(set (match_operand:QI 0 "push_operand" "=<") + (match_operand:QI 1 "nonimmediate_operand" "q"))] + "!TARGET_MOVE" + "* +{ + operands[1] = gen_rtx (REG, HImode, REGNO (operands[1])); + return AS1 (push%W0,%1); +}") + +(define_insn "" + [(set (match_operand:QI 0 "push_operand" "=<") + (match_operand:QI 1 "register_operand" "q"))] + "TARGET_MOVE" + "* +{ + operands[1] = gen_rtx (REG, HImode, REGNO (operands[1])); + return AS1 (push%W0,%1); +}") + +;; On i486, incb reg is faster than movb $1,reg. + +;; ??? Do a recognizer for zero_extract that looks just like this, but reads +;; or writes %ah, %bh, %ch, %dh. + +(define_expand "movqi" + [(set (match_operand:QI 0 "general_operand" "") + (match_operand:QI 1 "general_operand" ""))] + "" + " +{ + /* Don't generate memory->memory moves, go through a register */ + if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && GET_CODE (operands[1]) == MEM) + { + operands[1] = force_reg (QImode, operands[1]); + } +}") + +(define_insn "" + [(set (match_operand:QI 0 "general_operand" "=q,*r,qm") + (match_operand:QI 1 "general_operand" "*g,q,qn"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + rtx link; + if (operands[1] == const0_rtx && REG_P (operands[0])) + return AS2 (xor%B0,%0,%0); + + if (operands[1] == const1_rtx + && (link = find_reg_note (insn, REG_WAS_0, 0)) + /* Make sure the insn that stored the 0 is still present. */ + && ! INSN_DELETED_P (XEXP (link, 0)) + && GET_CODE (XEXP (link, 0)) != NOTE + /* Make sure cross jumping didn't happen here. */ + && no_labels_between_p (XEXP (link, 0), insn) + /* Make sure the reg hasn't been clobbered. */ + && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) + /* Fastest way to change a 0 to a 1. */ + return AS1 (inc%B0,%0); + + /* If mov%B0 isn't allowed for one of these regs, use mov%L0. */ + if (NON_QI_REG_P (operands[0]) || NON_QI_REG_P (operands[1])) + return (AS2 (mov%L0,%k1,%k0)); + + return (AS2 (mov%B0,%1,%0)); +}") + +;; If it becomes necessary to support movstrictqi into %esi or %edi, +;; use the insn sequence: +;; +;; shrdl $8,srcreg,dstreg +;; rorl $24,dstreg +;; +;; If operands[1] is a constant, then an andl/orl sequence would be +;; faster. + +(define_expand "movstrictqi" + [(set (strict_low_part (match_operand:QI 0 "general_operand" "")) + (match_operand:QI 1 "general_operand" ""))] + "" + " +{ + /* Don't generate memory->memory moves, go through a register */ + if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && GET_CODE (operands[1]) == MEM) + { + operands[1] = force_reg (QImode, operands[1]); + } +}") + +(define_insn "" + [(set (strict_low_part (match_operand:QI 0 "general_operand" "+qm,q")) + (match_operand:QI 1 "general_operand" "*qn,m"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + rtx link; + if (operands[1] == const0_rtx && REG_P (operands[0])) + return AS2 (xor%B0,%0,%0); + + if (operands[1] == const1_rtx + && (link = find_reg_note (insn, REG_WAS_0, 0)) + /* Make sure the insn that stored the 0 is still present. */ + && ! INSN_DELETED_P (XEXP (link, 0)) + && GET_CODE (XEXP (link, 0)) != NOTE + /* Make sure cross jumping didn't happen here. */ + && no_labels_between_p (XEXP (link, 0), insn) + /* Make sure the reg hasn't been clobbered. */ + && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) + /* Fastest way to change a 0 to a 1. */ + return AS1 (inc%B0,%0); + + /* If mov%B0 isn't allowed for one of these regs, use mov%L0. */ + if (NON_QI_REG_P (operands[0]) || NON_QI_REG_P (operands[1])) + { + abort (); + return (AS2 (mov%L0,%k1,%k0)); + } + + return AS2 (mov%B0,%1,%0); +}") + +(define_expand "movsf" + [(set (match_operand:SF 0 "general_operand" "") + (match_operand:SF 1 "general_operand" ""))] + "" + " +{ + /* Special case memory->memory moves and pushes */ + if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && (GET_CODE (operands[1]) == MEM || push_operand (operands[0], SFmode))) + { + rtx (*genfunc) PROTO((rtx, rtx)) = (push_operand (operands[0], SFmode)) + ? gen_movsf_push + : gen_movsf_mem; + + emit_insn ((*genfunc) (operands[0], operands[1])); + DONE; + } + + /* If we are loading a floating point constant that isn't 0 or 1 into a register, + indicate we need the pic register loaded. This could be optimized into stores + of constants if the target eventually moves to memory, but better safe than + sorry. */ + if (flag_pic + && GET_CODE (operands[0]) != MEM + && GET_CODE (operands[1]) == CONST_DOUBLE + && !standard_80387_constant_p (operands[1])) + { + current_function_uses_pic_offset_table = 1; + } +}") + +(define_insn "movsf_push_nomove" + [(set (match_operand:SF 0 "push_operand" "=<,<") + (match_operand:SF 1 "general_operand" "gF,f"))] + "!TARGET_MOVE" + "* +{ + if (STACK_REG_P (operands[1])) + { + rtx xops[3]; + + if (! STACK_TOP_P (operands[1])) + abort (); + + xops[0] = AT_SP (SFmode); + xops[1] = GEN_INT (4); + xops[2] = stack_pointer_rtx; + + output_asm_insn (AS2 (sub%L2,%1,%2), xops); + + if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fstp%S0,%0), xops); + else + output_asm_insn (AS1 (fst%S0,%0), xops); + RET; + } + return AS1 (push%L1,%1); +}") + +(define_insn "movsf_push" + [(set (match_operand:SF 0 "push_operand" "=<,<,<,<") + (match_operand:SF 1 "general_operand" "rF,f,m,m")) + (clobber (match_scratch:SI 2 "=X,X,r,X"))] + "" + "* +{ + if (STACK_REG_P (operands[1])) + { + rtx xops[3]; + + if (! STACK_TOP_P (operands[1])) + abort (); + + xops[0] = AT_SP (SFmode); + xops[1] = GEN_INT (4); + xops[2] = stack_pointer_rtx; + + output_asm_insn (AS2 (sub%L2,%1,%2), xops); + + if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fstp%S0,%0), xops); + else + output_asm_insn (AS1 (fst%S0,%0), xops); + RET; + } + + else if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != REG) + return AS1 (push%L1,%1); + + else + { + output_asm_insn (AS2 (mov%L2,%1,%2), operands); + return AS1 (push%L2,%2); + } +}") + +;; Special memory<->memory pattern that combine will recreate from the +;; moves to pseudos. +(define_insn "movsf_mem" + [(set (match_operand:SF 0 "memory_operand" "=m") + (match_operand:SF 1 "memory_operand" "m")) + (clobber (match_scratch:SI 2 "=&r"))] + "" + "* +{ + output_asm_insn (AS2 (mov%L2,%1,%2), operands); + return AS2 (mov%L0,%2,%0); +}") + +;; For the purposes of regclass, prefer FLOAT_REGS. +(define_insn "movsf_normal" + [(set (match_operand:SF 0 "general_operand" "=*rfm,*rf,f,!*rm") + (match_operand:SF 1 "general_operand" "*rf,*rfm,fG,fF"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + /* First handle a `pop' insn or a `fld %st(0)' */ + + if (STACK_TOP_P (operands[0]) && STACK_TOP_P (operands[1])) + { + if (stack_top_dies) + return AS1 (fstp,%y0); + else + return AS1 (fld,%y0); + } + + /* Handle a transfer between the 387 and a 386 register */ + + if (STACK_TOP_P (operands[0]) && NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); + RET; + } + + if (STACK_TOP_P (operands[1]) && NON_STACK_REG_P (operands[0])) + { + output_to_reg (operands[0], stack_top_dies); + RET; + } + + /* Handle other kinds of writes from the 387 */ + + if (STACK_TOP_P (operands[1])) + { + if (stack_top_dies) + return AS1 (fstp%z0,%y0); + else + return AS1 (fst%z0,%y0); + } + + /* Handle other kinds of reads to the 387 */ + + if (STACK_TOP_P (operands[0]) && GET_CODE (operands[1]) == CONST_DOUBLE) + return output_move_const_single (operands); + + if (STACK_TOP_P (operands[0])) + return AS1 (fld%z1,%y1); + + /* Handle all SFmode moves not involving the 387 */ + + return singlemove_string (operands); +}") + +(define_insn "swapsf" + [(set (match_operand:SF 0 "register_operand" "f") + (match_operand:SF 1 "register_operand" "f")) + (set (match_dup 1) + (match_dup 0))] + "" + "* +{ + if (STACK_TOP_P (operands[0])) + return AS1 (fxch,%1); + else + return AS1 (fxch,%0); +}") + +(define_expand "movdf" + [(set (match_operand:DF 0 "general_operand" "") + (match_operand:DF 1 "general_operand" ""))] + "" + " +{ + /* Special case memory->memory moves and pushes */ + if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && (GET_CODE (operands[1]) == MEM || push_operand (operands[0], DFmode))) + { + rtx (*genfunc) PROTO((rtx, rtx)) = (push_operand (operands[0], DFmode)) + ? gen_movdf_push + : gen_movdf_mem; + + emit_insn ((*genfunc) (operands[0], operands[1])); + DONE; + } + + /* If we are loading a floating point constant that isn't 0 or 1 into a register, + indicate we need the pic register loaded. This could be optimized into stores + of constants if the target eventually moves to memory, but better safe than + sorry. */ + if (flag_pic + && GET_CODE (operands[0]) != MEM + && GET_CODE (operands[1]) == CONST_DOUBLE + && !standard_80387_constant_p (operands[1])) + { + current_function_uses_pic_offset_table = 1; + } +}") + +(define_insn "movdf_push_nomove" + [(set (match_operand:DF 0 "push_operand" "=<,<") + (match_operand:DF 1 "general_operand" "gF,f"))] + "!TARGET_MOVE" + "* +{ + if (STACK_REG_P (operands[1])) + { + rtx xops[3]; + + xops[0] = AT_SP (SFmode); + xops[1] = GEN_INT (8); + xops[2] = stack_pointer_rtx; + + output_asm_insn (AS2 (sub%L2,%1,%2), xops); + + if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fstp%Q0,%0), xops); + else + output_asm_insn (AS1 (fst%Q0,%0), xops); + + RET; + } + else + return output_move_double (operands); +}") + +(define_insn "movdf_push" + [(set (match_operand:DF 0 "push_operand" "=<,<,<,<,<") + (match_operand:DF 1 "general_operand" "rF,f,o,o,o")) + (clobber (match_scratch:SI 2 "=X,X,&r,&r,X")) + (clobber (match_scratch:SI 3 "=X,X,&r,X,X"))] + "" + "* +{ + if (STACK_REG_P (operands[1])) + { + rtx xops[3]; + + xops[0] = AT_SP (SFmode); + xops[1] = GEN_INT (8); + xops[2] = stack_pointer_rtx; + + output_asm_insn (AS2 (sub%L2,%1,%2), xops); + + if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fstp%Q0,%0), xops); + else + output_asm_insn (AS1 (fst%Q0,%0), xops); + + RET; + } + + else if (GET_CODE (operands[1]) != MEM) + return output_move_double (operands); + + else + return output_move_pushmem (operands, insn, GET_MODE_SIZE (DFmode), 2, 4); +}") + +(define_insn "movdf_mem" + [(set (match_operand:DF 0 "memory_operand" "=o,o") + (match_operand:DF 1 "memory_operand" "o,o")) + (clobber (match_scratch:SI 2 "=&r,&r")) + (clobber (match_scratch:SI 3 "=&r,X"))] + "" + "* return output_move_memory (operands, insn, GET_MODE_SIZE (DFmode), 2, 4);") + +;; For the purposes of regclass, prefer FLOAT_REGS. +(define_insn "movdf_normal" + [(set (match_operand:DF 0 "general_operand" "=f,fm,!*rf,!*rm") + (match_operand:DF 1 "general_operand" "fmG,f,*rfm,*rfF"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + /* First handle a `pop' insn or a `fld %st(0)' */ + + if (STACK_TOP_P (operands[0]) && STACK_TOP_P (operands[1])) + { + if (stack_top_dies) + return AS1 (fstp,%y0); + else + return AS1 (fld,%y0); + } + + /* Handle a transfer between the 387 and a 386 register */ + + if (STACK_TOP_P (operands[0]) && NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); + RET; + } + + if (STACK_TOP_P (operands[1]) && NON_STACK_REG_P (operands[0])) + { + output_to_reg (operands[0], stack_top_dies); + RET; + } + + /* Handle other kinds of writes from the 387 */ + + if (STACK_TOP_P (operands[1])) + { + if (stack_top_dies) + return AS1 (fstp%z0,%y0); + else + return AS1 (fst%z0,%y0); + } + + /* Handle other kinds of reads to the 387 */ + + if (STACK_TOP_P (operands[0]) && GET_CODE (operands[1]) == CONST_DOUBLE) + return output_move_const_single (operands); + + if (STACK_TOP_P (operands[0])) + return AS1 (fld%z1,%y1); + + /* Handle all DFmode moves not involving the 387 */ + + return output_move_double (operands); +}") + +(define_insn "swapdf" + [(set (match_operand:DF 0 "register_operand" "f") + (match_operand:DF 1 "register_operand" "f")) + (set (match_dup 1) + (match_dup 0))] + "" + "* +{ + if (STACK_TOP_P (operands[0])) + return AS1 (fxch,%1); + else + return AS1 (fxch,%0); +}") + +(define_expand "movxf" + [(set (match_operand:XF 0 "general_operand" "") + (match_operand:XF 1 "general_operand" ""))] + "" + " +{ + /* Special case memory->memory moves and pushes */ + if (TARGET_MOVE + && (reload_in_progress | reload_completed) == 0 + && GET_CODE (operands[0]) == MEM + && (GET_CODE (operands[1]) == MEM || push_operand (operands[0], XFmode))) + { + rtx (*genfunc) PROTO((rtx, rtx)) = (push_operand (operands[0], XFmode)) + ? gen_movxf_push + : gen_movxf_mem; + + emit_insn ((*genfunc) (operands[0], operands[1])); + DONE; + } + + /* If we are loading a floating point constant that isn't 0 or 1 into a register, + indicate we need the pic register loaded. This could be optimized into stores + of constants if the target eventually moves to memory, but better safe than + sorry. */ + if (flag_pic + && GET_CODE (operands[0]) != MEM + && GET_CODE (operands[1]) == CONST_DOUBLE + && !standard_80387_constant_p (operands[1])) + { + current_function_uses_pic_offset_table = 1; + } +}") + + +(define_insn "movxf_push_nomove" + [(set (match_operand:XF 0 "push_operand" "=<,<") + (match_operand:XF 1 "general_operand" "gF,f"))] + "!TARGET_MOVE" + "* +{ + if (STACK_REG_P (operands[1])) + { + rtx xops[3]; + + xops[0] = AT_SP (SFmode); + xops[1] = GEN_INT (12); + xops[2] = stack_pointer_rtx; + + output_asm_insn (AS2 (sub%L2,%1,%2), xops); + output_asm_insn (AS1 (fstp%T0,%0), xops); + if (! find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fld%T0,%0), xops); + + RET; + } + else + return output_move_double (operands); + }") + +(define_insn "movxf_push" + [(set (match_operand:XF 0 "push_operand" "=<,<,<,<,<") + (match_operand:XF 1 "general_operand" "rF,f,o,o,o")) + (clobber (match_scratch:SI 2 "=X,X,&r,&r,X")) + (clobber (match_scratch:SI 3 "=X,X,&r,X,X"))] + "" + "* +{ + if (STACK_REG_P (operands[1])) + { + rtx xops[3]; + + xops[0] = AT_SP (SFmode); + xops[1] = GEN_INT (12); + xops[2] = stack_pointer_rtx; + + output_asm_insn (AS2 (sub%L2,%1,%2), xops); + output_asm_insn (AS1 (fstp%T0,%0), xops); + if (! find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) + output_asm_insn (AS1 (fld%T0,%0), xops); + + RET; + } + + else if (GET_CODE (operands[1]) != MEM + || GET_CODE (operands[2]) != REG) + return output_move_double (operands); + + else + return output_move_pushmem (operands, insn, GET_MODE_SIZE (XFmode), 2, 4); +}") + +(define_insn "movxf_mem" + [(set (match_operand:XF 0 "memory_operand" "=o,o") + (match_operand:XF 1 "memory_operand" "o,o")) + (clobber (match_scratch:SI 2 "=&r,&r")) + (clobber (match_scratch:SI 3 "=&r,X"))] + "" + "* return output_move_memory (operands, insn, GET_MODE_SIZE (XFmode), 2, 4);") + +(define_insn "movxf_normal" + [(set (match_operand:XF 0 "general_operand" "=f,fm,!*rf,!*rm") + (match_operand:XF 1 "general_operand" "fmG,f,*rfm,*rfF"))] + "(!TARGET_MOVE || GET_CODE (operands[0]) != MEM) || (GET_CODE (operands[1]) != MEM)" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + /* First handle a `pop' insn or a `fld %st(0)' */ + + if (STACK_TOP_P (operands[0]) && STACK_TOP_P (operands[1])) + { + if (stack_top_dies) + return AS1 (fstp,%y0); + else + return AS1 (fld,%y0); + } + + /* Handle a transfer between the 387 and a 386 register */ + + if (STACK_TOP_P (operands[0]) && NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); + RET; + } + + if (STACK_TOP_P (operands[1]) && NON_STACK_REG_P (operands[0])) + { + output_to_reg (operands[0], stack_top_dies); + RET; + } + + /* Handle other kinds of writes from the 387 */ + + if (STACK_TOP_P (operands[1])) + { + output_asm_insn (AS1 (fstp%z0,%y0), operands); + if (! stack_top_dies) + return AS1 (fld%z0,%y0); + + RET; + } + + /* Handle other kinds of reads to the 387 */ + + if (STACK_TOP_P (operands[0]) && GET_CODE (operands[1]) == CONST_DOUBLE) + return output_move_const_single (operands); + + if (STACK_TOP_P (operands[0])) + return AS1 (fld%z1,%y1); + + /* Handle all XFmode moves not involving the 387 */ + + return output_move_double (operands); +}") + +(define_insn "swapxf" + [(set (match_operand:XF 0 "register_operand" "f") + (match_operand:XF 1 "register_operand" "f")) + (set (match_dup 1) + (match_dup 0))] + "" + "* +{ + if (STACK_TOP_P (operands[0])) + return AS1 (fxch,%1); + else + return AS1 (fxch,%0); +}") + +(define_insn "" + [(set (match_operand:DI 0 "push_operand" "=<,<,<,<") + (match_operand:DI 1 "general_operand" "riF,o,o,o")) + (clobber (match_scratch:SI 2 "=X,&r,&r,X")) + (clobber (match_scratch:SI 3 "=X,&r,X,X"))] + "" + "* +{ + if (GET_CODE (operands[1]) != MEM) + return output_move_double (operands); + + else + return output_move_pushmem (operands, insn, GET_MODE_SIZE (DImode), 2, 4); +}") + +(define_insn "movdi" + [(set (match_operand:DI 0 "general_operand" "=o,o,r,rm") + (match_operand:DI 1 "general_operand" "o,o,m,riF")) + (clobber (match_scratch:SI 2 "=&r,&r,X,X")) + (clobber (match_scratch:SI 3 "=&r,X,X,X"))] + "" + "* +{ + rtx low[2], high[2], xop[6]; + + if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) + return output_move_double (operands); + else + return output_move_memory (operands, insn, GET_MODE_SIZE (DImode), 2, 4); +}") + + +;;- conversion instructions +;;- NONE + +;;- zero extension instructions +;; See comments by `andsi' for when andl is faster than movzx. + +(define_insn "zero_extendhisi2" + [(set (match_operand:SI 0 "general_operand" "=r") + (zero_extend:SI + (match_operand:HI 1 "nonimmediate_operand" "rm")))] + "" + "* +{ + if ((!TARGET_386 || REGNO (operands[0]) == 0) + && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) + { + rtx xops[2]; + xops[0] = operands[0]; + xops[1] = GEN_INT (0xffff); + output_asm_insn (AS2 (and%L0,%1,%k0), xops); + RET; + } + +#ifdef INTEL_SYNTAX + return AS2 (movzx,%1,%0); +#else + return AS2 (movz%W0%L0,%1,%0); +#endif +}") + +(define_insn "zero_extendqihi2" + [(set (match_operand:HI 0 "general_operand" "=r") + (zero_extend:HI + (match_operand:QI 1 "nonimmediate_operand" "qm")))] + "" + "* +{ + if ((!TARGET_386 || REGNO (operands[0]) == 0) + && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) + { + rtx xops[2]; + xops[0] = operands[0]; + xops[1] = GEN_INT (0xff); + output_asm_insn (AS2 (and%L0,%1,%k0), xops); + RET; + } + +#ifdef INTEL_SYNTAX + return AS2 (movzx,%1,%0); +#else + return AS2 (movz%B0%W0,%1,%0); +#endif +}") + +(define_insn "zero_extendqisi2" + [(set (match_operand:SI 0 "general_operand" "=r") + (zero_extend:SI + (match_operand:QI 1 "nonimmediate_operand" "qm")))] + "" + "* +{ + if ((!TARGET_386 || REGNO (operands[0]) == 0) + && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) + { + rtx xops[2]; + xops[0] = operands[0]; + xops[1] = GEN_INT (0xff); + output_asm_insn (AS2 (and%L0,%1,%k0), xops); + RET; + } + +#ifdef INTEL_SYNTAX + return AS2 (movzx,%1,%0); +#else + return AS2 (movz%B0%L0,%1,%0); +#endif +}") + +(define_insn "zero_extendsidi2" + [(set (match_operand:DI 0 "register_operand" "=r") + (zero_extend:DI + (match_operand:SI 1 "register_operand" "0")))] + "" + "* +{ + operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); + return AS2 (xor%L0,%0,%0); +}") + +;;- sign extension instructions + +(define_insn "extendsidi2" + [(set (match_operand:DI 0 "register_operand" "=r") + (sign_extend:DI + (match_operand:SI 1 "register_operand" "0")))] + "" + "* +{ + if (REGNO (operands[0]) == 0) + { + /* This used to be cwtl, but that extends HI to SI somehow. */ +#ifdef INTEL_SYNTAX + return \"cdq\"; +#else + return \"cltd\"; +#endif + } + + operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); + output_asm_insn (AS2 (mov%L0,%0,%1), operands); + + operands[0] = GEN_INT (31); + return AS2 (sar%L1,%0,%1); +}") + +;; Note that the i386 programmers' manual says that the opcodes +;; are named movsx..., but the assembler on Unix does not accept that. +;; We use what the Unix assembler expects. + +(define_insn "extendhisi2" + [(set (match_operand:SI 0 "general_operand" "=r") + (sign_extend:SI + (match_operand:HI 1 "nonimmediate_operand" "rm")))] + "" + "* +{ + if (REGNO (operands[0]) == 0 + && REG_P (operands[1]) && REGNO (operands[1]) == 0) +#ifdef INTEL_SYNTAX + return \"cwde\"; +#else + return \"cwtl\"; +#endif + +#ifdef INTEL_SYNTAX + return AS2 (movsx,%1,%0); +#else + return AS2 (movs%W0%L0,%1,%0); +#endif +}") + +(define_insn "extendqihi2" + [(set (match_operand:HI 0 "general_operand" "=r") + (sign_extend:HI + (match_operand:QI 1 "nonimmediate_operand" "qm")))] + "" + "* +{ + if (REGNO (operands[0]) == 0 + && REG_P (operands[1]) && REGNO (operands[1]) == 0) + return \"cbtw\"; + +#ifdef INTEL_SYNTAX + return AS2 (movsx,%1,%0); +#else + return AS2 (movs%B0%W0,%1,%0); +#endif +}") + +(define_insn "extendqisi2" + [(set (match_operand:SI 0 "general_operand" "=r") + (sign_extend:SI + (match_operand:QI 1 "nonimmediate_operand" "qm")))] + "" + "* +{ +#ifdef INTEL_SYNTAX + return AS2 (movsx,%1,%0); +#else + return AS2 (movs%B0%L0,%1,%0); +#endif +}") + +;; Conversions between float and double. + +(define_insn "extendsfdf2" + [(set (match_operand:DF 0 "general_operand" "=fm,f") + (float_extend:DF + (match_operand:SF 1 "general_operand" "f,fm")))] + "TARGET_80387" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); + RET; + } + + if (NON_STACK_REG_P (operands[0])) + { + output_to_reg (operands[0], stack_top_dies); + RET; + } + + if (STACK_TOP_P (operands[0])) + return AS1 (fld%z1,%y1); + + if (GET_CODE (operands[0]) == MEM) + { + if (stack_top_dies) + return AS1 (fstp%z0,%y0); + else + return AS1 (fst%z0,%y0); + } + + abort (); +}") + +(define_insn "extenddfxf2" + [(set (match_operand:XF 0 "general_operand" "=fm,f,f,!*r") + (float_extend:XF + (match_operand:DF 1 "general_operand" "f,fm,!*r,f")))] + "TARGET_80387" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); + RET; + } + + if (NON_STACK_REG_P (operands[0])) + { + output_to_reg (operands[0], stack_top_dies); + RET; + } + + if (STACK_TOP_P (operands[0])) + return AS1 (fld%z1,%y1); + + if (GET_CODE (operands[0]) == MEM) + { + output_asm_insn (AS1 (fstp%z0,%y0), operands); + if (! stack_top_dies) + return AS1 (fld%z0,%y0); + RET; + } + + abort (); +}") + +(define_insn "extendsfxf2" + [(set (match_operand:XF 0 "general_operand" "=fm,f,f,!*r") + (float_extend:XF + (match_operand:SF 1 "general_operand" "f,fm,!*r,f")))] + "TARGET_80387" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); + RET; + } + + if (NON_STACK_REG_P (operands[0])) + { + output_to_reg (operands[0], stack_top_dies); + RET; + } + + if (STACK_TOP_P (operands[0])) + return AS1 (fld%z1,%y1); + + if (GET_CODE (operands[0]) == MEM) + { + output_asm_insn (AS1 (fstp%z0,%y0), operands); + if (! stack_top_dies) + return AS1 (fld%z0,%y0); + RET; + } + + abort (); +}") + +(define_expand "truncdfsf2" + [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "") + (float_truncate:SF + (match_operand:DF 1 "register_operand" ""))) + (clobber (match_dup 2))])] + "TARGET_80387" + " +{ + operands[2] = (rtx) assign_386_stack_local (SFmode, 0); +}") + +;; This cannot output into an f-reg because there is no way to be sure +;; of truncating in that case. Otherwise this is just like a simple move +;; insn. So we pretend we can output to a reg in order to get better +;; register preferencing, but we really use a stack slot. + +(define_insn "" + [(set (match_operand:SF 0 "nonimmediate_operand" "=f,m") + (float_truncate:SF + (match_operand:DF 1 "register_operand" "0,f"))) + (clobber (match_operand:SF 2 "memory_operand" "m,m"))] + "TARGET_80387" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + if (GET_CODE (operands[0]) == MEM) + { + if (stack_top_dies) + return AS1 (fstp%z0,%0); + else + return AS1 (fst%z0,%0); + } + else if (STACK_TOP_P (operands[0])) + { + output_asm_insn (AS1 (fstp%z2,%y2), operands); + return AS1 (fld%z2,%y2); + } + else + abort (); +}") + +(define_insn "truncxfsf2" + [(set (match_operand:SF 0 "general_operand" "=m,!*r") + (float_truncate:SF + (match_operand:XF 1 "register_operand" "f,f")))] + "TARGET_80387" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + if (NON_STACK_REG_P (operands[0])) + { + if (stack_top_dies == 0) + { + output_asm_insn (AS1 (fld,%y1), operands); + stack_top_dies = 1; + } + output_to_reg (operands[0], stack_top_dies); + RET; + } + else if (GET_CODE (operands[0]) == MEM) + { + if (stack_top_dies) + return AS1 (fstp%z0,%0); + else + { + output_asm_insn (AS1 (fld,%y1), operands); + return AS1 (fstp%z0,%0); + } + } + else + abort (); +}") + +(define_insn "truncxfdf2" + [(set (match_operand:DF 0 "general_operand" "=m,!*r") + (float_truncate:DF + (match_operand:XF 1 "register_operand" "f,f")))] + "TARGET_80387" + "* +{ + int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; + + if (NON_STACK_REG_P (operands[0])) + { + if (stack_top_dies == 0) + { + output_asm_insn (AS1 (fld,%y1), operands); + stack_top_dies = 1; + } + output_to_reg (operands[0], stack_top_dies); + RET; + } + else if (GET_CODE (operands[0]) == MEM) + { + if (stack_top_dies) + return AS1 (fstp%z0,%0); + else + { + output_asm_insn (AS1 (fld,%y1), operands); + return AS1 (fstp%z0,%0); + } + } + else + abort (); +}") + + +;; The 387 requires that the stack top dies after converting to DImode. + +;; Represent an unsigned conversion from SImode to MODE_FLOAT by first +;; doing a signed conversion to DImode, and then taking just the low +;; part. + +(define_expand "fixuns_truncxfsi2" + [(set (match_dup 4) + (match_operand:XF 1 "register_operand" "")) + (parallel [(set (match_dup 2) + (fix:DI (fix:XF (match_dup 4)))) + (clobber (match_dup 4)) + (clobber (match_dup 5)) + (clobber (match_dup 6)) + (clobber (match_scratch:SI 7 ""))]) + (set (match_operand:SI 0 "general_operand" "") + (match_dup 3))] + "TARGET_80387" + " +{ + operands[2] = gen_reg_rtx (DImode); + operands[3] = gen_lowpart (SImode, operands[2]); + operands[4] = gen_reg_rtx (XFmode); + operands[5] = (rtx) assign_386_stack_local (SImode, 0); + operands[6] = (rtx) assign_386_stack_local (SImode, 1); +}") + +(define_expand "fixuns_truncdfsi2" + [(set (match_dup 4) + (match_operand:DF 1 "register_operand" "")) + (parallel [(set (match_dup 2) + (fix:DI (fix:DF (match_dup 4)))) + (clobber (match_dup 4)) + (clobber (match_dup 5)) + (clobber (match_dup 6)) + (clobber (match_scratch:SI 7 ""))]) + (set (match_operand:SI 0 "general_operand" "") + (match_dup 3))] + "TARGET_80387" + " +{ + operands[2] = gen_reg_rtx (DImode); + operands[3] = gen_lowpart (SImode, operands[2]); + operands[4] = gen_reg_rtx (DFmode); + operands[5] = (rtx) assign_386_stack_local (SImode, 0); + operands[6] = (rtx) assign_386_stack_local (SImode, 1); +}") + +(define_expand "fixuns_truncsfsi2" + [(set (match_dup 4) + (match_operand:SF 1 "register_operand" "")) + (parallel [(set (match_dup 2) + (fix:DI (fix:SF (match_dup 4)))) + (clobber (match_dup 4)) + (clobber (match_dup 5)) + (clobber (match_dup 6)) + (clobber (match_scratch:SI 7 ""))]) + (set (match_operand:SI 0 "general_operand" "") + (match_dup 3))] + "TARGET_80387" + " +{ + operands[2] = gen_reg_rtx (DImode); + operands[3] = gen_lowpart (SImode, operands[2]); + operands[4] = gen_reg_rtx (SFmode); + operands[5] = (rtx) assign_386_stack_local (SImode, 0); + operands[6] = (rtx) assign_386_stack_local (SImode, 1); +}") + +;; Signed conversion to DImode. + +(define_expand "fix_truncxfdi2" + [(set (match_dup 2) + (match_operand:XF 1 "register_operand" "")) + (parallel [(set (match_operand:DI 0 "general_operand" "") + (fix:DI (fix:XF (match_dup 2)))) + (clobber (match_dup 2)) + (clobber (match_dup 3)) + (clobber (match_dup 4)) + (clobber (match_scratch:SI 5 ""))])] + "TARGET_80387" + " +{ + operands[1] = copy_to_mode_reg (XFmode, operands[1]); + operands[2] = gen_reg_rtx (XFmode); + operands[3] = (rtx) assign_386_stack_local (SImode, 0); + operands[4] = (rtx) assign_386_stack_local (SImode, 1); +}") + +(define_expand "fix_truncdfdi2" + [(set (match_dup 2) + (match_operand:DF 1 "register_operand" "")) + (parallel [(set (match_operand:DI 0 "general_operand" "") + (fix:DI (fix:DF (match_dup 2)))) + (clobber (match_dup 2)) + (clobber (match_dup 3)) + (clobber (match_dup 4)) + (clobber (match_scratch:SI 5 ""))])] + "TARGET_80387" + " +{ + operands[1] = copy_to_mode_reg (DFmode, operands[1]); + operands[2] = gen_reg_rtx (DFmode); + operands[3] = (rtx) assign_386_stack_local (SImode, 0); + operands[4] = (rtx) assign_386_stack_local (SImode, 1); +}") + +(define_expand "fix_truncsfdi2" + [(set (match_dup 2) + (match_operand:SF 1 "register_operand" "")) + (parallel [(set (match_operand:DI 0 "general_operand" "") + (fix:DI (fix:SF (match_dup 2)))) + (clobber (match_dup 2)) + (clobber (match_dup 3)) + (clobber (match_dup 4)) + (clobber (match_scratch:SI 5 ""))])] + "TARGET_80387" + " +{ + operands[1] = copy_to_mode_reg (SFmode, operands[1]); + operands[2] = gen_reg_rtx (SFmode); + operands[3] = (rtx) assign_386_stack_local (SImode, 0); + operands[4] = (rtx) assign_386_stack_local (SImode, 1); +}") + +;; These match a signed conversion of either DFmode or SFmode to DImode. + +(define_insn "" + [(set (match_operand:DI 0 "general_operand" "=rm") + (fix:DI (fix:XF (match_operand:XF 1 "register_operand" "f")))) + (clobber (match_dup 1)) + (clobber (match_operand:SI 2 "memory_operand" "m")) + (clobber (match_operand:SI 3 "memory_operand" "m")) + (clobber (match_scratch:SI 4 "=&q"))] + "TARGET_80387" + "* return output_fix_trunc (insn, operands);") + +(define_insn "" + [(set (match_operand:DI 0 "general_operand" "=rm") + (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f")))) + (clobber (match_dup 1)) + (clobber (match_operand:SI 2 "memory_operand" "m")) + (clobber (match_operand:SI 3 "memory_operand" "m")) + (clobber (match_scratch:SI 4 "=&q"))] + "TARGET_80387" + "* return output_fix_trunc (insn, operands);") + +(define_insn "" + [(set (match_operand:DI 0 "general_operand" "=rm") + (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f")))) + (clobber (match_dup 1)) + (clobber (match_operand:SI 2 "memory_operand" "m")) + (clobber (match_operand:SI 3 "memory_operand" "m")) + (clobber (match_scratch:SI 4 "=&q"))] + "TARGET_80387" + "* return output_fix_trunc (insn, operands);") + +;; Signed MODE_FLOAT conversion to SImode. + +(define_expand "fix_truncxfsi2" + [(parallel [(set (match_operand:SI 0 "general_operand" "") + (fix:SI + (fix:XF (match_operand:XF 1 "register_operand" "")))) + (clobber (match_dup 2)) + (clobber (match_dup 3)) + (clobber (match_scratch:SI 4 ""))])] + "TARGET_80387" + " +{ + operands[2] = (rtx) assign_386_stack_local (SImode, 0); + operands[3] = (rtx) assign_386_stack_local (SImode, 1); +}") + +(define_expand "fix_truncdfsi2" + [(parallel [(set (match_operand:SI 0 "general_operand" "") + (fix:SI + (fix:DF (match_operand:DF 1 "register_operand" "")))) + (clobber (match_dup 2)) + (clobber (match_dup 3)) + (clobber (match_scratch:SI 4 ""))])] + "TARGET_80387" + " +{ + operands[2] = (rtx) assign_386_stack_local (SImode, 0); + operands[3] = (rtx) assign_386_stack_local (SImode, 1); +}") + +(define_expand "fix_truncsfsi2" + [(parallel [(set (match_operand:SI 0 "general_operand" "") + (fix:SI + (fix:SF (match_operand:SF 1 "register_operand" "")))) + (clobber (match_dup 2)) + (clobber (match_dup 3)) + (clobber (match_scratch:SI 4 ""))])] + "TARGET_80387" + " +{ + operands[2] = (rtx) assign_386_stack_local (SImode, 0); + operands[3] = (rtx) assign_386_stack_local (SImode, 1); +}") + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=rm") + (fix:SI (fix:XF (match_operand:XF 1 "register_operand" "f")))) + (clobber (match_operand:SI 2 "memory_operand" "m")) + (clobber (match_operand:SI 3 "memory_operand" "m")) + (clobber (match_scratch:SI 4 "=&q"))] + "TARGET_80387" + "* return output_fix_trunc (insn, operands);") + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=rm") + (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f")))) + (clobber (match_operand:SI 2 "memory_operand" "m")) + (clobber (match_operand:SI 3 "memory_operand" "m")) + (clobber (match_scratch:SI 4 "=&q"))] + "TARGET_80387" + "* return output_fix_trunc (insn, operands);") + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=rm") + (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f")))) + (clobber (match_operand:SI 2 "memory_operand" "m")) + (clobber (match_operand:SI 3 "memory_operand" "m")) + (clobber (match_scratch:SI 4 "=&q"))] + "TARGET_80387" + "* return output_fix_trunc (insn, operands);") + +;; Conversion between fixed point and floating point. +;; The actual pattern that matches these is at the end of this file. + +;; ??? Possibly represent floatunssidf2 here in gcc2. + +(define_expand "floatsisf2" + [(set (match_operand:SF 0 "register_operand" "") + (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "floatdisf2" + [(set (match_operand:SF 0 "register_operand" "") + (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "floatsidf2" + [(set (match_operand:DF 0 "register_operand" "") + (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "floatdidf2" + [(set (match_operand:DF 0 "register_operand" "") + (float:DF (match_operand:DI 1 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "floatsixf2" + [(set (match_operand:XF 0 "register_operand" "") + (float:XF (match_operand:SI 1 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "floatdixf2" + [(set (match_operand:XF 0 "register_operand" "") + (float:XF (match_operand:DI 1 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +;; This will convert from SImode or DImode to MODE_FLOAT. + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f") + (float:XF (match_operand:DI 1 "general_operand" "rm")))] + "TARGET_80387" + "* +{ + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fild%z0,%1)); + RET; + } + else if (GET_CODE (operands[1]) == MEM) + return AS1 (fild%z1,%1); + else + abort (); +}") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (float:DF (match_operand:DI 1 "nonimmediate_operand" "rm")))] + "TARGET_80387" + "* +{ + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fild%z0,%1)); + RET; + } + else if (GET_CODE (operands[1]) == MEM) + return AS1 (fild%z1,%1); + else + abort (); +}") + +(define_insn "" + [(set (match_operand:SF 0 "register_operand" "=f") + (float:SF (match_operand:DI 1 "nonimmediate_operand" "rm")))] + "TARGET_80387" + "* +{ + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fild%z0,%1)); + RET; + } + else if (GET_CODE (operands[1]) == MEM) + return AS1 (fild%z1,%1); + else + abort (); +}") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (float:DF (match_operand:SI 1 "nonimmediate_operand" "rm")))] + "TARGET_80387" + "* +{ + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fild%z0,%1)); + RET; + } + else if (GET_CODE (operands[1]) == MEM) + return AS1 (fild%z1,%1); + else + abort (); +}") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f,f") + (float:XF (match_operand:SI 1 "general_operand" "m,!*r")))] + "TARGET_80387" + "* +{ + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fild%z0,%1)); + RET; + } + else if (GET_CODE (operands[1]) == MEM) + return AS1 (fild%z1,%1); + else + abort (); +}") + +(define_insn "" + [(set (match_operand:SF 0 "register_operand" "=f") + (float:SF (match_operand:SI 1 "nonimmediate_operand" "rm")))] + "TARGET_80387" + "* +{ + if (NON_STACK_REG_P (operands[1])) + { + output_op_from_reg (operands[1], AS1 (fild%z0,%1)); + RET; + } + else if (GET_CODE (operands[1]) == MEM) + return AS1 (fild%z1,%1); + else + abort (); +}") + +;;- add instructions + +(define_insn "adddi3" + [(set (match_operand:DI 0 "general_operand" "=&r,ro,o,&r,ro,o,&r,o,o,o") + (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,o,riF,o,or,riF,riF,o") + (match_operand:DI 2 "general_operand" "o,riF,o,0,0,0,oriF,riF,o,o"))) + (clobber (match_scratch:SI 3 "=X,X,&r,X,&r,&r,X,&r,&r,&r"))] + "" + "* +{ + rtx low[3], high[3], xops[7], temp; + + CC_STATUS_INIT; + + if (rtx_equal_p (operands[0], operands[2])) + { + temp = operands[1]; + operands[1] = operands[2]; + operands[2] = temp; + } + + split_di (operands, 3, low, high); + if (!rtx_equal_p (operands[0], operands[1])) + { + xops[0] = high[0]; + xops[1] = low[0]; + xops[2] = high[1]; + xops[3] = low[1]; + + if (GET_CODE (operands[0]) != MEM) + { + output_asm_insn (AS2 (mov%L1,%3,%1), xops); + output_asm_insn (AS2 (mov%L0,%2,%0), xops); + } + else + { + xops[4] = high[2]; + xops[5] = low[2]; + xops[6] = operands[3]; + output_asm_insn (AS2 (mov%L6,%3,%6), xops); + output_asm_insn (AS2 (add%L6,%5,%6), xops); + output_asm_insn (AS2 (mov%L1,%6,%1), xops); + output_asm_insn (AS2 (mov%L6,%2,%6), xops); + output_asm_insn (AS2 (adc%L6,%4,%6), xops); + output_asm_insn (AS2 (mov%L0,%6,%0), xops); + RET; + } + } + + if (GET_CODE (operands[3]) == REG && GET_CODE (operands[2]) != REG) + { + xops[0] = high[0]; + xops[1] = low[0]; + xops[2] = high[2]; + xops[3] = low[2]; + xops[4] = operands[3]; + + output_asm_insn (AS2 (mov%L4,%3,%4), xops); + output_asm_insn (AS2 (add%L1,%4,%1), xops); + output_asm_insn (AS2 (mov%L4,%2,%4), xops); + output_asm_insn (AS2 (adc%L0,%4,%0), xops); + } + + else if (GET_CODE (low[2]) != CONST_INT || INTVAL (low[2]) != 0) + { + output_asm_insn (AS2 (add%L0,%2,%0), low); + output_asm_insn (AS2 (adc%L0,%2,%0), high); + } + + else + output_asm_insn (AS2 (add%L0,%2,%0), high); + + RET; +}") + +;; On a 486, it is faster to do movl/addl than to do a single leal if +;; operands[1] and operands[2] are both registers. + +(define_insn "addsi3" + [(set (match_operand:SI 0 "general_operand" "=?r,rm,r") + (plus:SI (match_operand:SI 1 "general_operand" "%r,0,0") + (match_operand:SI 2 "general_operand" "ri,ri,rm")))] + "" + "* +{ + if (REG_P (operands[0]) && REGNO (operands[0]) != REGNO (operands[1])) + { + if (REG_P (operands[2]) && REGNO (operands[0]) == REGNO (operands[2])) + return AS2 (add%L0,%1,%0); + + if (operands[2] == stack_pointer_rtx) + { + rtx temp; + + temp = operands[1]; + operands[1] = operands[2]; + operands[2] = temp; + } + + if (operands[2] != stack_pointer_rtx) + { + CC_STATUS_INIT; + operands[1] = SET_SRC (PATTERN (insn)); + return AS2 (lea%L0,%a1,%0); + } + + output_asm_insn (AS2 (mov%L0,%1,%0), operands); + } + + if (operands[2] == const1_rtx) + return AS1 (inc%L0,%0); + + if (operands[2] == constm1_rtx) + return AS1 (dec%L0,%0); + + return AS2 (add%L0,%2,%0); +}") + +;; ??? `lea' here, for three operand add? If leaw is used, only %bx, +;; %si and %di can appear in SET_SRC, and output_asm_insn might not be +;; able to handle the operand. But leal always works? + +(define_insn "addhi3" + [(set (match_operand:HI 0 "general_operand" "=rm,r") + (plus:HI (match_operand:HI 1 "general_operand" "%0,0") + (match_operand:HI 2 "general_operand" "ri,rm")))] + "" + "* +{ + /* ??? what about offsettable memory references? */ + if (QI_REG_P (operands[0]) + && GET_CODE (operands[2]) == CONST_INT + && (INTVAL (operands[2]) & 0xff) == 0) + { + int byteval = (INTVAL (operands[2]) >> 8) & 0xff; + CC_STATUS_INIT; + + if (byteval == 1) + return AS1 (inc%B0,%h0); + else if (byteval == 255) + return AS1 (dec%B0,%h0); + + operands[2] = GEN_INT (byteval); + return AS2 (add%B0,%2,%h0); + } + + if (operands[2] == const1_rtx) + return AS1 (inc%W0,%0); + + if (operands[2] == constm1_rtx + || (GET_CODE (operands[2]) == CONST_INT + && INTVAL (operands[2]) == 65535)) + return AS1 (dec%W0,%0); + + return AS2 (add%W0,%2,%0); +}") + +(define_insn "addqi3" + [(set (match_operand:QI 0 "general_operand" "=qm,q") + (plus:QI (match_operand:QI 1 "general_operand" "%0,0") + (match_operand:QI 2 "general_operand" "qn,qmn")))] + "" + "* +{ + if (operands[2] == const1_rtx) + return AS1 (inc%B0,%0); + + if (operands[2] == constm1_rtx + || (GET_CODE (operands[2]) == CONST_INT + && INTVAL (operands[2]) == 255)) + return AS1 (dec%B0,%0); + + return AS2 (add%B0,%2,%0); +}") + +;Lennart Augustsson +;says this pattern just makes slower code: +; pushl %ebp +; addl $-80,(%esp) +;instead of +; leal -80(%ebp),%eax +; pushl %eax +; +;(define_insn "" +; [(set (match_operand:SI 0 "push_operand" "=<") +; (plus:SI (match_operand:SI 1 "general_operand" "%r") +; (match_operand:SI 2 "general_operand" "ri")))] +; "" +; "* +;{ +; rtx xops[4]; +; xops[0] = operands[0]; +; xops[1] = operands[1]; +; xops[2] = operands[2]; +; xops[3] = gen_rtx (MEM, SImode, stack_pointer_rtx); +; output_asm_insn (\"push%z1 %1\", xops); +; output_asm_insn (AS2 (add%z3,%2,%3), xops); +; RET; +;}") + +;; addsi3 is faster, so put this after. + +(define_insn "movsi_lea" + [(set (match_operand:SI 0 "register_operand" "=r") + (match_operand:QI 1 "address_operand" "p"))] + "" + "* +{ + CC_STATUS_INIT; + /* Adding a constant to a register is faster with an add. */ + /* ??? can this ever happen? */ + if (GET_CODE (operands[1]) == PLUS + && GET_CODE (XEXP (operands[1], 1)) == CONST_INT + && rtx_equal_p (operands[0], XEXP (operands[1], 0))) + { + operands[1] = XEXP (operands[1], 1); + + if (operands[1] == const1_rtx) + return AS1 (inc%L0,%0); + + if (operands[1] == constm1_rtx) + return AS1 (dec%L0,%0); + + return AS2 (add%L0,%1,%0); + } + return AS2 (lea%L0,%a1,%0); +}") + +;; The patterns that match these are at the end of this file. + +(define_expand "addxf3" + [(set (match_operand:XF 0 "register_operand" "") + (plus:XF (match_operand:XF 1 "nonimmediate_operand" "") + (match_operand:XF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "adddf3" + [(set (match_operand:DF 0 "register_operand" "") + (plus:DF (match_operand:DF 1 "nonimmediate_operand" "") + (match_operand:DF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "addsf3" + [(set (match_operand:SF 0 "register_operand" "") + (plus:SF (match_operand:SF 1 "nonimmediate_operand" "") + (match_operand:SF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +;;- subtract instructions + +(define_insn "subdi3" + [(set (match_operand:DI 0 "general_operand" "=&r,ro,&r,o,o") + (minus:DI (match_operand:DI 1 "general_operand" "0,0,roiF,riF,o") + (match_operand:DI 2 "general_operand" "o,riF,roiF,riF,o"))) + (clobber (match_scratch:SI 3 "=X,X,X,&r,&r"))] + "" + "* +{ + rtx low[3], high[3], xops[7]; + + CC_STATUS_INIT; + + split_di (operands, 3, low, high); + + if (!rtx_equal_p (operands[0], operands[1])) + { + xops[0] = high[0]; + xops[1] = low[0]; + xops[2] = high[1]; + xops[3] = low[1]; + + if (GET_CODE (operands[0]) != MEM) + { + output_asm_insn (AS2 (mov%L1,%3,%1), xops); + output_asm_insn (AS2 (mov%L0,%2,%0), xops); + } + else + { + xops[4] = high[2]; + xops[5] = low[2]; + xops[6] = operands[3]; + output_asm_insn (AS2 (mov%L6,%3,%6), xops); + output_asm_insn (AS2 (sub%L6,%5,%6), xops); + output_asm_insn (AS2 (mov%L1,%6,%1), xops); + output_asm_insn (AS2 (mov%L6,%2,%6), xops); + output_asm_insn (AS2 (sbb%L6,%4,%6), xops); + output_asm_insn (AS2 (mov%L0,%6,%0), xops); + RET; + } + } + + if (GET_CODE (operands[3]) == REG) + { + xops[0] = high[0]; + xops[1] = low[0]; + xops[2] = high[2]; + xops[3] = low[2]; + xops[4] = operands[3]; + + output_asm_insn (AS2 (mov%L4,%3,%4), xops); + output_asm_insn (AS2 (sub%L1,%4,%1), xops); + output_asm_insn (AS2 (mov%L4,%2,%4), xops); + output_asm_insn (AS2 (sbb%L0,%4,%0), xops); + } + + else if (GET_CODE (low[2]) != CONST_INT || INTVAL (low[2]) != 0) + { + output_asm_insn (AS2 (sub%L0,%2,%0), low); + output_asm_insn (AS2 (sbb%L0,%2,%0), high); + } + + else + output_asm_insn (AS2 (sub%L0,%2,%0), high); + + RET; +}") + +(define_insn "subsi3" + [(set (match_operand:SI 0 "general_operand" "=rm,r") + (minus:SI (match_operand:SI 1 "general_operand" "0,0") + (match_operand:SI 2 "general_operand" "ri,rm")))] + "" + "* return AS2 (sub%L0,%2,%0);") + +(define_insn "subhi3" + [(set (match_operand:HI 0 "general_operand" "=rm,r") + (minus:HI (match_operand:HI 1 "general_operand" "0,0") + (match_operand:HI 2 "general_operand" "ri,rm")))] + "" + "* return AS2 (sub%W0,%2,%0);") + +(define_insn "subqi3" + [(set (match_operand:QI 0 "general_operand" "=qm,q") + (minus:QI (match_operand:QI 1 "general_operand" "0,0") + (match_operand:QI 2 "general_operand" "qn,qmn")))] + "" + "* return AS2 (sub%B0,%2,%0);") + +;; The patterns that match these are at the end of this file. + +(define_expand "subxf3" + [(set (match_operand:XF 0 "register_operand" "") + (minus:XF (match_operand:XF 1 "nonimmediate_operand" "") + (match_operand:XF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "subdf3" + [(set (match_operand:DF 0 "register_operand" "") + (minus:DF (match_operand:DF 1 "nonimmediate_operand" "") + (match_operand:DF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "subsf3" + [(set (match_operand:SF 0 "register_operand" "") + (minus:SF (match_operand:SF 1 "nonimmediate_operand" "") + (match_operand:SF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +;;- multiply instructions + +;(define_insn "mulqi3" +; [(set (match_operand:QI 0 "general_operand" "=a") +; (mult:QI (match_operand:QI 1 "general_operand" "%0") +; (match_operand:QI 2 "general_operand" "qm")))] +; "" +; "imul%B0 %2,%0") + +(define_insn "" + [(set (match_operand:HI 0 "general_operand" "=r") + (mult:HI (match_operand:HI 1 "general_operand" "%0") + (match_operand:HI 2 "general_operand" "r")))] + "GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x80" + "* return AS2 (imul%W0,%2,%0);") + +(define_insn "mulhi3" + [(set (match_operand:HI 0 "general_operand" "=r,r") + (mult:HI (match_operand:HI 1 "general_operand" "%0,rm") + (match_operand:HI 2 "general_operand" "g,i")))] + "" + "* +{ + if (GET_CODE (operands[1]) == REG + && REGNO (operands[1]) == REGNO (operands[0]) + && (GET_CODE (operands[2]) == MEM || GET_CODE (operands[2]) == REG)) + /* Assembler has weird restrictions. */ + return AS2 (imul%W0,%2,%0); + return AS3 (imul%W0,%2,%1,%0); +}") + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r") + (mult:SI (match_operand:SI 1 "general_operand" "%0") + (match_operand:SI 2 "general_operand" "r")))] + "GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x80" + "* return AS2 (imul%L0,%2,%0);") + +(define_insn "mulsi3" + [(set (match_operand:SI 0 "general_operand" "=r,r") + (mult:SI (match_operand:SI 1 "general_operand" "%0,rm") + (match_operand:SI 2 "general_operand" "g,i")))] + "" + "* +{ + if (GET_CODE (operands[1]) == REG + && REGNO (operands[1]) == REGNO (operands[0]) + && (GET_CODE (operands[2]) == MEM || GET_CODE (operands[2]) == REG)) + /* Assembler has weird restrictions. */ + return AS2 (imul%L0,%2,%0); + return AS3 (imul%L0,%2,%1,%0); +}") + +(define_insn "umulqihi3" + [(set (match_operand:HI 0 "general_operand" "=a") + (mult:HI (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0")) + (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))] + "" + "mul%B0 %2") + +(define_insn "mulqihi3" + [(set (match_operand:HI 0 "general_operand" "=a") + (mult:HI (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0")) + (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))] + "" + "imul%B0 %2") + +(define_insn "umulsidi3" + [(set (match_operand:DI 0 "register_operand" "=A") + (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0")) + (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))] + "TARGET_WIDE_MULTIPLY" + "mul%L0 %2") + +(define_insn "mulsidi3" + [(set (match_operand:DI 0 "register_operand" "=A") + (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%0")) + (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))] + "TARGET_WIDE_MULTIPLY" + "imul%L0 %2") + +(define_insn "umulsi3_highpart" + [(set (match_operand:SI 0 "register_operand" "=d") + (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%a")) + (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))) + (const_int 32)))) + (clobber (match_scratch:SI 3 "=a"))] + "TARGET_WIDE_MULTIPLY" + "mul%L0 %2") + +(define_insn "smulsi3_highpart" + [(set (match_operand:SI 0 "register_operand" "=d") + (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%a")) + (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))) + (const_int 32)))) + (clobber (match_scratch:SI 3 "=a"))] + "TARGET_WIDE_MULTIPLY" + "imul%L0 %2") + +;; The patterns that match these are at the end of this file. + +(define_expand "mulxf3" + [(set (match_operand:XF 0 "register_operand" "") + (mult:XF (match_operand:XF 1 "nonimmediate_operand" "") + (match_operand:XF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "muldf3" + [(set (match_operand:DF 0 "register_operand" "") + (mult:DF (match_operand:DF 1 "nonimmediate_operand" "") + (match_operand:DF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "mulsf3" + [(set (match_operand:SF 0 "register_operand" "") + (mult:SF (match_operand:SF 1 "nonimmediate_operand" "") + (match_operand:SF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +;;- divide instructions + +(define_insn "divqi3" + [(set (match_operand:QI 0 "general_operand" "=a") + (div:QI (match_operand:HI 1 "general_operand" "0") + (match_operand:QI 2 "general_operand" "qm")))] + "" + "idiv%B0 %2") + +(define_insn "udivqi3" + [(set (match_operand:QI 0 "general_operand" "=a") + (udiv:QI (match_operand:HI 1 "general_operand" "0") + (match_operand:QI 2 "general_operand" "qm")))] + "" + "div%B0 %2") + +;; The patterns that match these are at the end of this file. + +(define_expand "divxf3" + [(set (match_operand:XF 0 "register_operand" "") + (div:XF (match_operand:XF 1 "nonimmediate_operand" "") + (match_operand:XF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "divdf3" + [(set (match_operand:DF 0 "register_operand" "") + (div:DF (match_operand:DF 1 "nonimmediate_operand" "") + (match_operand:DF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +(define_expand "divsf3" + [(set (match_operand:SF 0 "register_operand" "") + (div:SF (match_operand:SF 1 "nonimmediate_operand" "") + (match_operand:SF 2 "nonimmediate_operand" "")))] + "TARGET_80387" + "") + +;; Remainder instructions. + +(define_insn "divmodsi4" + [(set (match_operand:SI 0 "register_operand" "=a") + (div:SI (match_operand:SI 1 "register_operand" "0") + (match_operand:SI 2 "general_operand" "rm"))) + (set (match_operand:SI 3 "register_operand" "=&d") + (mod:SI (match_dup 1) (match_dup 2)))] + "" + "* +{ +#ifdef INTEL_SYNTAX + output_asm_insn (\"cdq\", operands); +#else + output_asm_insn (\"cltd\", operands); +#endif + return AS1 (idiv%L0,%2); +}") + +(define_insn "divmodhi4" + [(set (match_operand:HI 0 "register_operand" "=a") + (div:HI (match_operand:HI 1 "register_operand" "0") + (match_operand:HI 2 "general_operand" "rm"))) + (set (match_operand:HI 3 "register_operand" "=&d") + (mod:HI (match_dup 1) (match_dup 2)))] + "" + "cwtd\;idiv%W0 %2") + +;; ??? Can we make gcc zero extend operand[0]? +(define_insn "udivmodsi4" + [(set (match_operand:SI 0 "register_operand" "=a") + (udiv:SI (match_operand:SI 1 "register_operand" "0") + (match_operand:SI 2 "general_operand" "rm"))) + (set (match_operand:SI 3 "register_operand" "=&d") + (umod:SI (match_dup 1) (match_dup 2)))] + "" + "* +{ + output_asm_insn (AS2 (xor%L3,%3,%3), operands); + return AS1 (div%L0,%2); +}") + +;; ??? Can we make gcc zero extend operand[0]? +(define_insn "udivmodhi4" + [(set (match_operand:HI 0 "register_operand" "=a") + (udiv:HI (match_operand:HI 1 "register_operand" "0") + (match_operand:HI 2 "general_operand" "rm"))) + (set (match_operand:HI 3 "register_operand" "=&d") + (umod:HI (match_dup 1) (match_dup 2)))] + "" + "* +{ + output_asm_insn (AS2 (xor%W0,%3,%3), operands); + return AS1 (div%W0,%2); +}") + +/* +;;this should be a valid double division which we may want to add + +(define_insn "" + [(set (match_operand:SI 0 "register_operand" "=a") + (udiv:DI (match_operand:DI 1 "register_operand" "a") + (match_operand:SI 2 "general_operand" "rm"))) + (set (match_operand:SI 3 "register_operand" "=d") + (umod:SI (match_dup 1) (match_dup 2)))] + "" + "div%L0 %2,%0") +*/ + +;;- and instructions + +;; On i386, +;; movzbl %bl,%ebx +;; is faster than +;; andl $255,%ebx +;; +;; but if the reg is %eax, then the "andl" is faster. +;; +;; On i486, the "andl" is always faster than the "movzbl". +;; +;; On both i386 and i486, a three operand AND is as fast with movzbl or +;; movzwl as with andl, if operands[0] != operands[1]. + +;; The `r' in `rm' for operand 3 looks redundant, but it causes +;; optional reloads to be generated if op 3 is a pseudo in a stack slot. + +;; ??? What if we only change one byte of an offsettable memory reference? +(define_insn "andsi3" + [(set (match_operand:SI 0 "general_operand" "=r,r,rm,r") + (and:SI (match_operand:SI 1 "general_operand" "%rm,qm,0,0") + (match_operand:SI 2 "general_operand" "L,K,ri,rm")))] + "" + "* +{ + if (GET_CODE (operands[2]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) + { + if (INTVAL (operands[2]) == 0xffff && REG_P (operands[0]) + && (! REG_P (operands[1]) + || REGNO (operands[0]) != 0 || REGNO (operands[1]) != 0) + && (TARGET_386 || ! rtx_equal_p (operands[0], operands[1]))) + { + /* ??? tege: Should forget CC_STATUS only if we clobber a + remembered operand. Fix that later. */ + CC_STATUS_INIT; +#ifdef INTEL_SYNTAX + return AS2 (movzx,%w1,%0); +#else + return AS2 (movz%W0%L0,%w1,%0); +#endif + } + + if (INTVAL (operands[2]) == 0xff && REG_P (operands[0]) + && !(REG_P (operands[1]) && NON_QI_REG_P (operands[1])) + && (! REG_P (operands[1]) + || REGNO (operands[0]) != 0 || REGNO (operands[1]) != 0) + && (TARGET_386 || ! rtx_equal_p (operands[0], operands[1]))) + { + /* ??? tege: Should forget CC_STATUS only if we clobber a + remembered operand. Fix that later. */ + CC_STATUS_INIT; +#ifdef INTEL_SYNTAX + return AS2 (movzx,%b1,%0); +#else + return AS2 (movz%B0%L0,%b1,%0); +#endif + } + + if (QI_REG_P (operands[0]) && ~(INTVAL (operands[2]) | 0xff) == 0) + { + CC_STATUS_INIT; + + if (INTVAL (operands[2]) == 0xffffff00) + { + operands[2] = const0_rtx; + return AS2 (mov%B0,%2,%b0); + } + + operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff); + return AS2 (and%B0,%2,%b0); + } + + if (QI_REG_P (operands[0]) && ~(INTVAL (operands[2]) | 0xff00) == 0) + { + CC_STATUS_INIT; + + if (INTVAL (operands[2]) == 0xffff00ff) + { + operands[2] = const0_rtx; + return AS2 (mov%B0,%2,%h0); + } + + operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); + return AS2 (and%B0,%2,%h0); + } + + if (GET_CODE (operands[0]) == MEM && INTVAL (operands[2]) == 0xffff0000) + { + operands[2] = const0_rtx; + return AS2 (mov%W0,%2,%w0); + } + } + + return AS2 (and%L0,%2,%0); +}") + +(define_insn "andhi3" + [(set (match_operand:HI 0 "general_operand" "=rm,r") + (and:HI (match_operand:HI 1 "general_operand" "%0,0") + (match_operand:HI 2 "general_operand" "ri,rm")))] + "" + "* +{ + if (GET_CODE (operands[2]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) + { + /* Can we ignore the upper byte? */ + if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) + && (INTVAL (operands[2]) & 0xff00) == 0xff00) + { + CC_STATUS_INIT; + + if ((INTVAL (operands[2]) & 0xff) == 0) + { + operands[2] = const0_rtx; + return AS2 (mov%B0,%2,%b0); + } + + operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff); + return AS2 (and%B0,%2,%b0); + } + + /* Can we ignore the lower byte? */ + /* ??? what about offsettable memory references? */ + if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & 0xff) == 0xff) + { + CC_STATUS_INIT; + + if ((INTVAL (operands[2]) & 0xff00) == 0) + { + operands[2] = const0_rtx; + return AS2 (mov%B0,%2,%h0); + } + + operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); + return AS2 (and%B0,%2,%h0); + } + } + + return AS2 (and%W0,%2,%0); +}") + +(define_insn "andqi3" + [(set (match_operand:QI 0 "general_operand" "=qm,q") + (and:QI (match_operand:QI 1 "general_operand" "%0,0") + (match_operand:QI 2 "general_operand" "qn,qmn")))] + "" + "* return AS2 (and%B0,%2,%0);") + +/* I am nervous about these two.. add them later.. +;I presume this means that we have something in say op0= eax which is small +;and we want to and it with memory so we can do this by just an +;andb m,%al and have success. +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=r") + (and:SI (zero_extend:SI + (match_operand:HI 1 "nonimmediate_operand" "rm")) + (match_operand:SI 2 "general_operand" "0")))] + "GET_CODE (operands[2]) == CONST_INT + && (unsigned int) INTVAL (operands[2]) < (1 << GET_MODE_BITSIZE (HImode))" + "and%W0 %1,%0") + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=q") + (and:SI + (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")) + (match_operand:SI 2 "general_operand" "0")))] + "GET_CODE (operands[2]) == CONST_INT + && (unsigned int) INTVAL (operands[2]) < (1 << GET_MODE_BITSIZE (QImode))" + "and%L0 %1,%0") + +*/ + +;;- Bit set (inclusive or) instructions + +;; ??? What if we only change one byte of an offsettable memory reference? +(define_insn "iorsi3" + [(set (match_operand:SI 0 "general_operand" "=rm,r") + (ior:SI (match_operand:SI 1 "general_operand" "%0,0") + (match_operand:SI 2 "general_operand" "ri,rm")))] + "" + "* +{ + if (GET_CODE (operands[2]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) + { + if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) + && (INTVAL (operands[2]) & ~0xff) == 0) + { + CC_STATUS_INIT; + + if (INTVAL (operands[2]) == 0xff) + return AS2 (mov%B0,%2,%b0); + + return AS2 (or%B0,%2,%b0); + } + + if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & ~0xff00) == 0) + { + CC_STATUS_INIT; + operands[2] = GEN_INT (INTVAL (operands[2]) >> 8); + + if (INTVAL (operands[2]) == 0xff) + return AS2 (mov%B0,%2,%h0); + + return AS2 (or%B0,%2,%h0); + } + } + + return AS2 (or%L0,%2,%0); +}") + +(define_insn "iorhi3" + [(set (match_operand:HI 0 "general_operand" "=rm,r") + (ior:HI (match_operand:HI 1 "general_operand" "%0,0") + (match_operand:HI 2 "general_operand" "ri,rm")))] + "" + "* +{ + if (GET_CODE (operands[2]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) + { + /* Can we ignore the upper byte? */ + if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) + && (INTVAL (operands[2]) & 0xff00) == 0) + { + CC_STATUS_INIT; + if (INTVAL (operands[2]) & 0xffff0000) + operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff); + + if (INTVAL (operands[2]) == 0xff) + return AS2 (mov%B0,%2,%b0); + + return AS2 (or%B0,%2,%b0); + } + + /* Can we ignore the lower byte? */ + /* ??? what about offsettable memory references? */ + if (QI_REG_P (operands[0]) + && (INTVAL (operands[2]) & 0xff) == 0) + { + CC_STATUS_INIT; + operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); + + if (INTVAL (operands[2]) == 0xff) + return AS2 (mov%B0,%2,%h0); + + return AS2 (or%B0,%2,%h0); + } + } + + return AS2 (or%W0,%2,%0); +}") + +(define_insn "iorqi3" + [(set (match_operand:QI 0 "general_operand" "=qm,q") + (ior:QI (match_operand:QI 1 "general_operand" "%0,0") + (match_operand:QI 2 "general_operand" "qn,qmn")))] + "" + "* return AS2 (or%B0,%2,%0);") + +;;- xor instructions + +;; ??? What if we only change one byte of an offsettable memory reference? +(define_insn "xorsi3" + [(set (match_operand:SI 0 "general_operand" "=rm,r") + (xor:SI (match_operand:SI 1 "general_operand" "%0,0") + (match_operand:SI 2 "general_operand" "ri,rm")))] + "" + "* +{ + if (GET_CODE (operands[2]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) + { + if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) + && (INTVAL (operands[2]) & ~0xff) == 0) + { + CC_STATUS_INIT; + + if (INTVAL (operands[2]) == 0xff) + return AS1 (not%B0,%b0); + + return AS2 (xor%B0,%2,%b0); + } + + if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & ~0xff00) == 0) + { + CC_STATUS_INIT; + operands[2] = GEN_INT (INTVAL (operands[2]) >> 8); + + if (INTVAL (operands[2]) == 0xff) + return AS1 (not%B0,%h0); + + return AS2 (xor%B0,%2,%h0); + } + } + + return AS2 (xor%L0,%2,%0); +}") + +(define_insn "xorhi3" + [(set (match_operand:HI 0 "general_operand" "=rm,r") + (xor:HI (match_operand:HI 1 "general_operand" "%0,0") + (match_operand:HI 2 "general_operand" "ri,rm")))] + "" + "* +{ + if (GET_CODE (operands[2]) == CONST_INT + && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) + { + /* Can we ignore the upper byte? */ + if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) + && (INTVAL (operands[2]) & 0xff00) == 0) + { + CC_STATUS_INIT; + if (INTVAL (operands[2]) & 0xffff0000) + operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff); + + if (INTVAL (operands[2]) == 0xff) + return AS1 (not%B0,%b0); + + return AS2 (xor%B0,%2,%b0); + } + + /* Can we ignore the lower byte? */ + /* ??? what about offsettable memory references? */ + if (QI_REG_P (operands[0]) + && (INTVAL (operands[2]) & 0xff) == 0) + { + CC_STATUS_INIT; + operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); + + if (INTVAL (operands[2]) == 0xff) + return AS1 (not%B0,%h0); + + return AS2 (xor%B0,%2,%h0); + } + } + + return AS2 (xor%W0,%2,%0); +}") + +(define_insn "xorqi3" + [(set (match_operand:QI 0 "general_operand" "=qm,q") + (xor:QI (match_operand:QI 1 "general_operand" "%0,0") + (match_operand:QI 2 "general_operand" "qn,qm")))] + "" + "* return AS2 (xor%B0,%2,%0);") + +;;- negation instructions + +(define_insn "negdi2" + [(set (match_operand:DI 0 "general_operand" "=&ro") + (neg:DI (match_operand:DI 1 "general_operand" "0")))] + "" + "* +{ + rtx xops[2], low[1], high[1]; + + CC_STATUS_INIT; + + split_di (operands, 1, low, high); + xops[0] = const0_rtx; + xops[1] = high[0]; + + output_asm_insn (AS1 (neg%L0,%0), low); + output_asm_insn (AS2 (adc%L1,%0,%1), xops); + output_asm_insn (AS1 (neg%L0,%0), high); + RET; +}") + +(define_insn "negsi2" + [(set (match_operand:SI 0 "general_operand" "=rm") + (neg:SI (match_operand:SI 1 "general_operand" "0")))] + "" + "neg%L0 %0") + +(define_insn "neghi2" + [(set (match_operand:HI 0 "general_operand" "=rm") + (neg:HI (match_operand:HI 1 "general_operand" "0")))] + "" + "neg%W0 %0") + +(define_insn "negqi2" + [(set (match_operand:QI 0 "general_operand" "=qm") + (neg:QI (match_operand:QI 1 "general_operand" "0")))] + "" + "neg%B0 %0") + +(define_insn "negsf2" + [(set (match_operand:SF 0 "register_operand" "=f") + (neg:SF (match_operand:SF 1 "general_operand" "0")))] + "TARGET_80387" + "fchs") + +(define_insn "negdf2" + [(set (match_operand:DF 0 "register_operand" "=f") + (neg:DF (match_operand:DF 1 "general_operand" "0")))] + "TARGET_80387" + "fchs") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (neg:DF (float_extend:DF (match_operand:SF 1 "general_operand" "0"))))] + "TARGET_80387" + "fchs") + +(define_insn "negxf2" + [(set (match_operand:XF 0 "register_operand" "=f") + (neg:XF (match_operand:XF 1 "general_operand" "0")))] + "TARGET_80387" + "fchs") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f") + (neg:XF (float_extend:XF (match_operand:DF 1 "general_operand" "0"))))] + "TARGET_80387" + "fchs") + +;; Absolute value instructions + +(define_insn "abssf2" + [(set (match_operand:SF 0 "register_operand" "=f") + (abs:SF (match_operand:SF 1 "general_operand" "0")))] + "TARGET_80387" + "fabs") + +(define_insn "absdf2" + [(set (match_operand:DF 0 "register_operand" "=f") + (abs:DF (match_operand:DF 1 "general_operand" "0")))] + "TARGET_80387" + "fabs") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (abs:DF (float_extend:DF (match_operand:SF 1 "general_operand" "0"))))] + "TARGET_80387" + "fabs") + +(define_insn "absxf2" + [(set (match_operand:XF 0 "register_operand" "=f") + (abs:XF (match_operand:XF 1 "general_operand" "0")))] + "TARGET_80387" + "fabs") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f") + (abs:XF (float_extend:XF (match_operand:DF 1 "general_operand" "0"))))] + "TARGET_80387" + "fabs") + +(define_insn "sqrtsf2" + [(set (match_operand:SF 0 "register_operand" "=f") + (sqrt:SF (match_operand:SF 1 "general_operand" "0")))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsqrt") + +(define_insn "sqrtdf2" + [(set (match_operand:DF 0 "register_operand" "=f") + (sqrt:DF (match_operand:DF 1 "general_operand" "0")))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsqrt") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (sqrt:DF (float_extend:DF + (match_operand:SF 1 "general_operand" "0"))))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsqrt") + +(define_insn "sqrtxf2" + [(set (match_operand:XF 0 "register_operand" "=f") + (sqrt:XF (match_operand:XF 1 "general_operand" "0")))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsqrt") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f") + (sqrt:XF (float_extend:XF + (match_operand:DF 1 "general_operand" "0"))))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsqrt") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f") + (sqrt:XF (float_extend:XF + (match_operand:SF 1 "general_operand" "0"))))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsqrt") + +(define_insn "sindf2" + [(set (match_operand:DF 0 "register_operand" "=f") + (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 1))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsin") + +(define_insn "sinsf2" + [(set (match_operand:SF 0 "register_operand" "=f") + (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 1))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsin") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (unspec:DF [(float_extend:DF + (match_operand:SF 1 "register_operand" "0"))] 1))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsin") + +(define_insn "sinxf2" + [(set (match_operand:XF 0 "register_operand" "=f") + (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 1))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fsin") + +(define_insn "cosdf2" + [(set (match_operand:DF 0 "register_operand" "=f") + (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 2))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fcos") + +(define_insn "cossf2" + [(set (match_operand:SF 0 "register_operand" "=f") + (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 2))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fcos") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (unspec:DF [(float_extend:DF + (match_operand:SF 1 "register_operand" "0"))] 2))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fcos") + +(define_insn "cosxf2" + [(set (match_operand:XF 0 "register_operand" "=f") + (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 2))] + "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 + && (TARGET_IEEE_FP || flag_fast_math) " + "fcos") + +;;- one complement instructions + +(define_insn "one_cmplsi2" + [(set (match_operand:SI 0 "general_operand" "=rm") + (not:SI (match_operand:SI 1 "general_operand" "0")))] + "" + "not%L0 %0") + +(define_insn "one_cmplhi2" + [(set (match_operand:HI 0 "general_operand" "=rm") + (not:HI (match_operand:HI 1 "general_operand" "0")))] + "" + "not%W0 %0") + +(define_insn "one_cmplqi2" + [(set (match_operand:QI 0 "general_operand" "=qm") + (not:QI (match_operand:QI 1 "general_operand" "0")))] + "" + "not%B0 %0") + +;;- arithmetic shift instructions + +;; DImode shifts are implemented using the i386 "shift double" opcode, +;; which is written as "sh[lr]d[lw] imm,reg,reg/mem". If the shift count +;; is variable, then the count is in %cl and the "imm" operand is dropped +;; from the assembler input. + +;; This instruction shifts the target reg/mem as usual, but instead of +;; shifting in zeros, bits are shifted in from reg operand. If the insn +;; is a left shift double, bits are taken from the high order bits of +;; reg, else if the insn is a shift right double, bits are taken from the +;; low order bits of reg. So if %eax is "1234" and %edx is "5678", +;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345". + +;; Since sh[lr]d does not change the `reg' operand, that is done +;; separately, making all shifts emit pairs of shift double and normal +;; shift. Since sh[lr]d does not shift more than 31 bits, and we wish to +;; support a 63 bit shift, each shift where the count is in a reg expands +;; to three pairs. If the overall shift is by N bits, then the first two +;; pairs shift by N / 2 and the last pair by N & 1. + +;; If the shift count is a constant, we need never emit more than one +;; shift pair, instead using moves and sign extension for counts greater +;; than 31. + +(define_expand "ashldi3" + [(set (match_operand:DI 0 "register_operand" "") + (ashift:DI (match_operand:DI 1 "register_operand" "") + (match_operand:QI 2 "nonmemory_operand" "")))] + "" + " +{ + if (GET_CODE (operands[2]) != CONST_INT + || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) + { + operands[2] = copy_to_mode_reg (QImode, operands[2]); + emit_insn (gen_ashldi3_non_const_int (operands[0], operands[1], + operands[2])); + } + else + emit_insn (gen_ashldi3_const_int (operands[0], operands[1], operands[2])); + + DONE; +}") + +(define_insn "ashldi3_const_int" + [(set (match_operand:DI 0 "register_operand" "=&r") + (ashift:DI (match_operand:DI 1 "register_operand" "0") + (match_operand:QI 2 "const_int_operand" "J")))] + "" + "* +{ + rtx xops[4], low[1], high[1]; + + CC_STATUS_INIT; + + split_di (operands, 1, low, high); + xops[0] = operands[2]; + xops[1] = const1_rtx; + xops[2] = low[0]; + xops[3] = high[0]; + + if (INTVAL (xops[0]) > 31) + { + output_asm_insn (AS2 (mov%L3,%2,%3), xops); /* Fast shift by 32 */ + output_asm_insn (AS2 (xor%L2,%2,%2), xops); + + if (INTVAL (xops[0]) > 32) + { + xops[0] = GEN_INT (INTVAL (xops[0]) - 32); + output_asm_insn (AS2 (sal%L3,%0,%3), xops); /* Remaining shift */ + } + } + else + { + output_asm_insn (AS3 (shld%L3,%0,%2,%3), xops); + output_asm_insn (AS2 (sal%L2,%0,%2), xops); + } + RET; +}") + +(define_insn "ashldi3_non_const_int" + [(set (match_operand:DI 0 "register_operand" "=&r") + (ashift:DI (match_operand:DI 1 "register_operand" "0") + (match_operand:QI 2 "register_operand" "c"))) + (clobber (match_dup 2))] + "" + "* +{ + rtx xops[4], low[1], high[1]; + + CC_STATUS_INIT; + + split_di (operands, 1, low, high); + xops[0] = operands[2]; + xops[1] = const1_rtx; + xops[2] = low[0]; + xops[3] = high[0]; + + output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ + + output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); + output_asm_insn (AS2 (sal%L2,%0,%2), xops); + output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); + output_asm_insn (AS2 (sal%L2,%0,%2), xops); + + xops[1] = GEN_INT (7); /* shift count & 1 */ + + output_asm_insn (AS2 (shr%B0,%1,%0), xops); + + output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); + output_asm_insn (AS2 (sal%L2,%0,%2), xops); + + RET; +}") + +;; On i386 and i486, "addl reg,reg" is faster than "sall $1,reg" +;; On i486, movl/sall appears slightly faster than leal, but the leal +;; is smaller - use leal for now unless the shift count is 1. + +(define_insn "ashlsi3" + [(set (match_operand:SI 0 "general_operand" "=r,rm") + (ashift:SI (match_operand:SI 1 "general_operand" "r,0") + (match_operand:SI 2 "nonmemory_operand" "M,cI")))] + "" + "* +{ + if (REG_P (operands[0]) && REGNO (operands[0]) != REGNO (operands[1])) + { + if (!TARGET_386 && INTVAL (operands[2]) == 1) + { + output_asm_insn (AS2 (mov%L0,%1,%0), operands); + return AS2 (add%L0,%1,%0); + } + else + { + CC_STATUS_INIT; + + if (operands[1] == stack_pointer_rtx) + { + output_asm_insn (AS2 (mov%L0,%1,%0), operands); + operands[1] = operands[0]; + } + operands[1] = gen_rtx (MULT, SImode, operands[1], + GEN_INT (1 << INTVAL (operands[2]))); + return AS2 (lea%L0,%a1,%0); + } + } + + if (REG_P (operands[2])) + return AS2 (sal%L0,%b2,%0); + + if (REG_P (operands[0]) && operands[2] == const1_rtx) + return AS2 (add%L0,%0,%0); + + return AS2 (sal%L0,%2,%0); +}") + +(define_insn "ashlhi3" + [(set (match_operand:HI 0 "general_operand" "=rm") + (ashift:HI (match_operand:HI 1 "general_operand" "0") + (match_operand:HI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (sal%W0,%b2,%0); + + if (REG_P (operands[0]) && operands[2] == const1_rtx) + return AS2 (add%W0,%0,%0); + + return AS2 (sal%W0,%2,%0); +}") + +(define_insn "ashlqi3" + [(set (match_operand:QI 0 "general_operand" "=qm") + (ashift:QI (match_operand:QI 1 "general_operand" "0") + (match_operand:QI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (sal%B0,%b2,%0); + + if (REG_P (operands[0]) && operands[2] == const1_rtx) + return AS2 (add%B0,%0,%0); + + return AS2 (sal%B0,%2,%0); +}") + +;; See comment above `ashldi3' about how this works. + +(define_expand "ashrdi3" + [(set (match_operand:DI 0 "register_operand" "") + (ashiftrt:DI (match_operand:DI 1 "register_operand" "") + (match_operand:QI 2 "nonmemory_operand" "")))] + "" + " +{ + if (GET_CODE (operands[2]) != CONST_INT + || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) + { + operands[2] = copy_to_mode_reg (QImode, operands[2]); + emit_insn (gen_ashrdi3_non_const_int (operands[0], operands[1], + operands[2])); + } + else + emit_insn (gen_ashrdi3_const_int (operands[0], operands[1], operands[2])); + + DONE; +}") + +(define_insn "ashrdi3_const_int" + [(set (match_operand:DI 0 "register_operand" "=&r") + (ashiftrt:DI (match_operand:DI 1 "register_operand" "0") + (match_operand:QI 2 "const_int_operand" "J")))] + "" + "* +{ + rtx xops[4], low[1], high[1]; + + CC_STATUS_INIT; + + split_di (operands, 1, low, high); + xops[0] = operands[2]; + xops[1] = const1_rtx; + xops[2] = low[0]; + xops[3] = high[0]; + + if (INTVAL (xops[0]) > 31) + { + xops[1] = GEN_INT (31); + output_asm_insn (AS2 (mov%L2,%3,%2), xops); + output_asm_insn (AS2 (sar%L3,%1,%3), xops); /* shift by 32 */ + + if (INTVAL (xops[0]) > 32) + { + xops[0] = GEN_INT (INTVAL (xops[0]) - 32); + output_asm_insn (AS2 (sar%L2,%0,%2), xops); /* Remaining shift */ + } + } + else + { + output_asm_insn (AS3 (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (sar%L3,%0,%3), xops); + } + + RET; +}") + +(define_insn "ashrdi3_non_const_int" + [(set (match_operand:DI 0 "register_operand" "=&r") + (ashiftrt:DI (match_operand:DI 1 "register_operand" "0") + (match_operand:QI 2 "register_operand" "c"))) + (clobber (match_dup 2))] + "" + "* +{ + rtx xops[4], low[1], high[1]; + + CC_STATUS_INIT; + + split_di (operands, 1, low, high); + xops[0] = operands[2]; + xops[1] = const1_rtx; + xops[2] = low[0]; + xops[3] = high[0]; + + output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ + + output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (sar%L3,%0,%3), xops); + output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (sar%L3,%0,%3), xops); + + xops[1] = GEN_INT (7); /* shift count & 1 */ + + output_asm_insn (AS2 (shr%B0,%1,%0), xops); + + output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (sar%L3,%0,%3), xops); + + RET; +}") + +(define_insn "ashrsi3" + [(set (match_operand:SI 0 "general_operand" "=rm") + (ashiftrt:SI (match_operand:SI 1 "general_operand" "0") + (match_operand:SI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (sar%L0,%b2,%0); + else + return AS2 (sar%L0,%2,%0); +}") + +(define_insn "ashrhi3" + [(set (match_operand:HI 0 "general_operand" "=rm") + (ashiftrt:HI (match_operand:HI 1 "general_operand" "0") + (match_operand:HI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (sar%W0,%b2,%0); + else + return AS2 (sar%W0,%2,%0); +}") + +(define_insn "ashrqi3" + [(set (match_operand:QI 0 "general_operand" "=qm") + (ashiftrt:QI (match_operand:QI 1 "general_operand" "0") + (match_operand:QI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (sar%B0,%b2,%0); + else + return AS2 (sar%B0,%2,%0); +}") + +;;- logical shift instructions + +;; See comment above `ashldi3' about how this works. + +(define_expand "lshrdi3" + [(set (match_operand:DI 0 "register_operand" "") + (lshiftrt:DI (match_operand:DI 1 "register_operand" "") + (match_operand:QI 2 "nonmemory_operand" "")))] + "" + " +{ + if (GET_CODE (operands[2]) != CONST_INT + || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) + { + operands[2] = copy_to_mode_reg (QImode, operands[2]); + emit_insn (gen_lshrdi3_non_const_int (operands[0], operands[1], + operands[2])); + } + else + emit_insn (gen_lshrdi3_const_int (operands[0], operands[1], operands[2])); + + DONE; +}") + +(define_insn "lshrdi3_const_int" + [(set (match_operand:DI 0 "register_operand" "=&r") + (lshiftrt:DI (match_operand:DI 1 "register_operand" "0") + (match_operand:QI 2 "const_int_operand" "J")))] + "" + "* +{ + rtx xops[4], low[1], high[1]; + + CC_STATUS_INIT; + + split_di (operands, 1, low, high); + xops[0] = operands[2]; + xops[1] = const1_rtx; + xops[2] = low[0]; + xops[3] = high[0]; + + if (INTVAL (xops[0]) > 31) + { + output_asm_insn (AS2 (mov%L2,%3,%2), xops); /* Fast shift by 32 */ + output_asm_insn (AS2 (xor%L3,%3,%3), xops); + + if (INTVAL (xops[0]) > 32) + { + xops[0] = GEN_INT (INTVAL (xops[0]) - 32); + output_asm_insn (AS2 (shr%L2,%0,%2), xops); /* Remaining shift */ + } + } + else + { + output_asm_insn (AS3 (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (shr%L3,%0,%3), xops); + } + + RET; +}") + +(define_insn "lshrdi3_non_const_int" + [(set (match_operand:DI 0 "register_operand" "=&r") + (lshiftrt:DI (match_operand:DI 1 "register_operand" "0") + (match_operand:QI 2 "register_operand" "c"))) + (clobber (match_dup 2))] + "" + "* +{ + rtx xops[4], low[1], high[1]; + + CC_STATUS_INIT; + + split_di (operands, 1, low, high); + xops[0] = operands[2]; + xops[1] = const1_rtx; + xops[2] = low[0]; + xops[3] = high[0]; + + output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ + + output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (shr%L3,%0,%3), xops); + output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (shr%L3,%0,%3), xops); + + xops[1] = GEN_INT (7); /* shift count & 1 */ + + output_asm_insn (AS2 (shr%B0,%1,%0), xops); + + output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); + output_asm_insn (AS2 (shr%L3,%0,%3), xops); + + RET; +}") + +(define_insn "lshrsi3" + [(set (match_operand:SI 0 "general_operand" "=rm") + (lshiftrt:SI (match_operand:SI 1 "general_operand" "0") + (match_operand:SI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (shr%L0,%b2,%0); + else + return AS2 (shr%L0,%2,%1); +}") + +(define_insn "lshrhi3" + [(set (match_operand:HI 0 "general_operand" "=rm") + (lshiftrt:HI (match_operand:HI 1 "general_operand" "0") + (match_operand:HI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (shr%W0,%b2,%0); + else + return AS2 (shr%W0,%2,%0); +}") + +(define_insn "lshrqi3" + [(set (match_operand:QI 0 "general_operand" "=qm") + (lshiftrt:QI (match_operand:QI 1 "general_operand" "0") + (match_operand:QI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (shr%B0,%b2,%0); + else + return AS2 (shr%B0,%2,%0); +}") + +;;- rotate instructions + +(define_insn "rotlsi3" + [(set (match_operand:SI 0 "general_operand" "=rm") + (rotate:SI (match_operand:SI 1 "general_operand" "0") + (match_operand:SI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (rol%L0,%b2,%0); + else + return AS2 (rol%L0,%2,%0); +}") + +(define_insn "rotlhi3" + [(set (match_operand:HI 0 "general_operand" "=rm") + (rotate:HI (match_operand:HI 1 "general_operand" "0") + (match_operand:HI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (rol%W0,%b2,%0); + else + return AS2 (rol%W0,%2,%0); +}") + +(define_insn "rotlqi3" + [(set (match_operand:QI 0 "general_operand" "=qm") + (rotate:QI (match_operand:QI 1 "general_operand" "0") + (match_operand:QI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (rol%B0,%b2,%0); + else + return AS2 (rol%B0,%2,%0); +}") + +(define_insn "rotrsi3" + [(set (match_operand:SI 0 "general_operand" "=rm") + (rotatert:SI (match_operand:SI 1 "general_operand" "0") + (match_operand:SI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (ror%L0,%b2,%0); + else + return AS2 (ror%L0,%2,%0); +}") + +(define_insn "rotrhi3" + [(set (match_operand:HI 0 "general_operand" "=rm") + (rotatert:HI (match_operand:HI 1 "general_operand" "0") + (match_operand:HI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (ror%W0,%b2,%0); + else + return AS2 (ror%W0,%2,%0); +}") + +(define_insn "rotrqi3" + [(set (match_operand:QI 0 "general_operand" "=qm") + (rotatert:QI (match_operand:QI 1 "general_operand" "0") + (match_operand:QI 2 "nonmemory_operand" "cI")))] + "" + "* +{ + if (REG_P (operands[2])) + return AS2 (ror%B0,%b2,%0); + else + return AS2 (ror%B0,%2,%0); +}") + +/* +;; This usually looses. But try a define_expand to recognize a few case +;; we can do efficiently, such as accessing the "high" QImode registers, +;; %ah, %bh, %ch, %dh. +(define_insn "insv" + [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+&r") + (match_operand:SI 1 "general_operand" "i") + (match_operand:SI 2 "general_operand" "i")) + (match_operand:SI 3 "general_operand" "ri"))] + "" + "* +{ + if (INTVAL (operands[1]) + INTVAL (operands[2]) > GET_MODE_BITSIZE (SImode)) + abort (); + if (GET_CODE (operands[3]) == CONST_INT) + { + unsigned int mask = (1 << INTVAL (operands[1])) - 1; + operands[1] = GEN_INT (~(mask << INTVAL (operands[2]))); + output_asm_insn (AS2 (and%L0,%1,%0), operands); + operands[3] = GEN_INT (INTVAL (operands[3]) << INTVAL (operands[2])); + output_asm_insn (AS2 (or%L0,%3,%0), operands); + } + else + { + operands[0] = gen_rtx (REG, SImode, REGNO (operands[0])); + if (INTVAL (operands[2])) + output_asm_insn (AS2 (ror%L0,%2,%0), operands); + output_asm_insn (AS3 (shrd%L0,%1,%3,%0), operands); + operands[2] = GEN_INT (BITS_PER_WORD + - INTVAL (operands[1]) - INTVAL (operands[2])); + if (INTVAL (operands[2])) + output_asm_insn (AS2 (ror%L0,%2,%0), operands); + } + RET; +}") +*/ +/* +;; ??? There are problems with the mode of operand[3]. The point of this +;; is to represent an HImode move to a "high byte" register. + +(define_expand "insv" + [(set (zero_extract:SI (match_operand:SI 0 "general_operand" "") + (match_operand:SI 1 "immediate_operand" "") + (match_operand:SI 2 "immediate_operand" "")) + (match_operand:QI 3 "general_operand" "ri"))] + "" + " +{ + if (GET_CODE (operands[1]) != CONST_INT + || GET_CODE (operands[2]) != CONST_INT) + FAIL; + + if (! (INTVAL (operands[1]) == 8 + && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 0)) + && ! INTVAL (operands[1]) == 1) + FAIL; +}") + +;; ??? Are these constraints right? +(define_insn "" + [(set (zero_extract:SI (match_operand:SI 0 "general_operand" "+&qo") + (const_int 8) + (const_int 8)) + (match_operand:QI 1 "general_operand" "qn"))] + "" + "* +{ + if (REG_P (operands[0])) + return AS2 (mov%B0,%1,%h0); + + operands[0] = adj_offsettable_operand (operands[0], 1); + return AS2 (mov%B0,%1,%0); +}") +*/ + +;; On i386, the register count for a bit operation is *not* truncated, +;; so SHIFT_COUNT_TRUNCATED must not be defined. + +;; On i486, the shift & or/and code is faster than bts or btr. If +;; operands[0] is a MEM, the bt[sr] is half as fast as the normal code. + +;; On i386, bts is a little faster if operands[0] is a reg, and a +;; little slower if operands[0] is a MEM, than the shift & or/and code. +;; Use bts & btr, since they reload better. + +;; General bit set and clear. +(define_insn "" + [(set (zero_extract:SI (match_operand:SI 0 "general_operand" "+rm") + (const_int 1) + (match_operand:SI 2 "general_operand" "r")) + (match_operand:SI 3 "const_int_operand" "n"))] + "TARGET_386 && GET_CODE (operands[2]) != CONST_INT" + "* +{ + CC_STATUS_INIT; + + if (INTVAL (operands[3]) == 1) + return AS2 (bts%L0,%2,%0); + else + return AS2 (btr%L0,%2,%0); +}") + +;; Bit complement. See comments on previous pattern. +;; ??? Is this really worthwhile? +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=rm") + (xor:SI (ashift:SI (const_int 1) + (match_operand:SI 1 "general_operand" "r")) + (match_operand:SI 2 "general_operand" "0")))] + "TARGET_386 && GET_CODE (operands[1]) != CONST_INT" + "* +{ + CC_STATUS_INIT; + + return AS2 (btc%L0,%1,%0); +}") + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=rm") + (xor:SI (match_operand:SI 1 "general_operand" "0") + (ashift:SI (const_int 1) + (match_operand:SI 2 "general_operand" "r"))))] + "TARGET_386 && GET_CODE (operands[2]) != CONST_INT" + "* +{ + CC_STATUS_INIT; + + return AS2 (btc%L0,%2,%0); +}") + +;; Recognizers for bit-test instructions. + +;; The bt opcode allows a MEM in operands[0]. But on both i386 and +;; i486, it is faster to copy a MEM to REG and then use bt, than to use +;; bt on the MEM directly. + +;; ??? The first argument of a zero_extract must not be reloaded, so +;; don't allow a MEM in the operand predicate without allowing it in the +;; constraint. + +(define_insn "" + [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "r") + (const_int 1) + (match_operand:SI 1 "general_operand" "r")))] + "GET_CODE (operands[1]) != CONST_INT" + "* +{ + cc_status.flags |= CC_Z_IN_NOT_C; + return AS2 (bt%L0,%1,%0); +}") + +(define_insn "" + [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "r") + (match_operand:SI 1 "const_int_operand" "n") + (match_operand:SI 2 "const_int_operand" "n")))] + "" + "* +{ + unsigned int mask; + + mask = ((1 << INTVAL (operands[1])) - 1) << INTVAL (operands[2]); + operands[1] = GEN_INT (mask); + + if (QI_REG_P (operands[0])) + { + if ((mask & ~0xff) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + return AS2 (test%B0,%1,%b0); + } + + if ((mask & ~0xff00) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + operands[1] = GEN_INT (mask >> 8); + return AS2 (test%B0,%1,%h0); + } + } + + return AS2 (test%L0,%1,%0); +}") + +;; ??? All bets are off if operand 0 is a volatile MEM reference. +;; The CPU may access unspecified bytes around the actual target byte. + +(define_insn "" + [(set (cc0) (zero_extract (match_operand:QI 0 "general_operand" "rm") + (match_operand:SI 1 "const_int_operand" "n") + (match_operand:SI 2 "const_int_operand" "n")))] + "GET_CODE (operands[0]) != MEM || ! MEM_VOLATILE_P (operands[0])" + "* +{ + unsigned int mask; + + mask = ((1 << INTVAL (operands[1])) - 1) << INTVAL (operands[2]); + operands[1] = GEN_INT (mask); + + if (! REG_P (operands[0]) || QI_REG_P (operands[0])) + { + if ((mask & ~0xff) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + return AS2 (test%B0,%1,%b0); + } + + if ((mask & ~0xff00) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + operands[1] = GEN_INT (mask >> 8); + + if (QI_REG_P (operands[0])) + return AS2 (test%B0,%1,%h0); + else + { + operands[0] = adj_offsettable_operand (operands[0], 1); + return AS2 (test%B0,%1,%b0); + } + } + + if (GET_CODE (operands[0]) == MEM && (mask & ~0xff0000) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + operands[1] = GEN_INT (mask >> 16); + operands[0] = adj_offsettable_operand (operands[0], 2); + return AS2 (test%B0,%1,%b0); + } + + if (GET_CODE (operands[0]) == MEM && (mask & ~0xff000000) == 0) + { + cc_status.flags |= CC_NOT_NEGATIVE; + operands[1] = GEN_INT (mask >> 24); + operands[0] = adj_offsettable_operand (operands[0], 3); + return AS2 (test%B0,%1,%b0); + } + } + + if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) + return AS2 (test%L0,%1,%0); + + return AS2 (test%L1,%0,%1); +}") + +;; Store-flag instructions. + +;; For all sCOND expanders, also expand the compare or test insn that +;; generates cc0. Generate an equality comparison if `seq' or `sne'. + +;; The 386 sCOND opcodes can write to memory. But a gcc sCOND insn may +;; not have any input reloads. A MEM write might need an input reload +;; for the address of the MEM. So don't allow MEM as the SET_DEST. + +(define_expand "seq" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (eq:QI (cc0) (const_int 0)))] + "" + " +{ + if (TARGET_IEEE_FP + && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) + operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); + else + operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); +}") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (eq:QI (cc0) (const_int 0)))] + "" + "* +{ + if (cc_prev_status.flags & CC_Z_IN_NOT_C) + return AS1 (setnb,%0); + else + return AS1 (sete,%0); +}") + +(define_expand "sne" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (ne:QI (cc0) (const_int 0)))] + "" + " +{ + if (TARGET_IEEE_FP + && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) + operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); + else + operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); +}") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (ne:QI (cc0) (const_int 0)))] + "" + "* +{ + if (cc_prev_status.flags & CC_Z_IN_NOT_C) + return AS1 (setb,%0); + else + return AS1 (setne,%0); +} +") + +(define_expand "sgt" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (gt:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (gt:QI (cc0) (const_int 0)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (sete,%0); + + OUTPUT_JUMP (\"setg %0\", \"seta %0\", NULL_PTR); +}") + +(define_expand "sgtu" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (gtu:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (gtu:QI (cc0) (const_int 0)))] + "" + "* return \"seta %0\"; ") + +(define_expand "slt" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (lt:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (lt:QI (cc0) (const_int 0)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (sete,%0); + + OUTPUT_JUMP (\"setl %0\", \"setb %0\", \"sets %0\"); +}") + +(define_expand "sltu" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (ltu:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (ltu:QI (cc0) (const_int 0)))] + "" + "* return \"setb %0\"; ") + +(define_expand "sge" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (ge:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (ge:QI (cc0) (const_int 0)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (sete,%0); + + OUTPUT_JUMP (\"setge %0\", \"setae %0\", \"setns %0\"); +}") + +(define_expand "sgeu" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (geu:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (geu:QI (cc0) (const_int 0)))] + "" + "* return \"setae %0\"; ") + +(define_expand "sle" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (le:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (le:QI (cc0) (const_int 0)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (setb,%0); + + OUTPUT_JUMP (\"setle %0\", \"setbe %0\", NULL_PTR); +}") + +(define_expand "sleu" + [(match_dup 1) + (set (match_operand:QI 0 "register_operand" "") + (leu:QI (cc0) (const_int 0)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (match_operand:QI 0 "register_operand" "=q") + (leu:QI (cc0) (const_int 0)))] + "" + "* return \"setbe %0\"; ") + +;; Basic conditional jump instructions. +;; We ignore the overflow flag for signed branch instructions. + +;; For all bCOND expanders, also expand the compare or test insn that +;; generates cc0. Generate an equality comparison if `beq' or `bne'. + +(define_expand "beq" + [(match_dup 1) + (set (pc) + (if_then_else (eq (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + " +{ + if (TARGET_IEEE_FP + && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) + operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); + else + operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); +}") + +(define_insn "" + [(set (pc) + (if_then_else (eq (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "* +{ + if (cc_prev_status.flags & CC_Z_IN_NOT_C) + return \"jnc %l0\"; + else + return \"je %l0\"; +}") + +(define_expand "bne" + [(match_dup 1) + (set (pc) + (if_then_else (ne (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + " +{ + if (TARGET_IEEE_FP + && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) + operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); + else + operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); +}") + +(define_insn "" + [(set (pc) + (if_then_else (ne (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "* +{ + if (cc_prev_status.flags & CC_Z_IN_NOT_C) + return \"jc %l0\"; + else + return \"jne %l0\"; +}") + +(define_expand "bgt" + [(match_dup 1) + (set (pc) + (if_then_else (gt (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (gt (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (je,%l0); + + OUTPUT_JUMP (\"jg %l0\", \"ja %l0\", NULL_PTR); +}") + +(define_expand "bgtu" + [(match_dup 1) + (set (pc) + (if_then_else (gtu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (gtu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "ja %l0") + +(define_expand "blt" + [(match_dup 1) + (set (pc) + (if_then_else (lt (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (lt (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (je,%l0); + + OUTPUT_JUMP (\"jl %l0\", \"jb %l0\", \"js %l0\"); +}") + +(define_expand "bltu" + [(match_dup 1) + (set (pc) + (if_then_else (ltu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (ltu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "jb %l0") + +(define_expand "bge" + [(match_dup 1) + (set (pc) + (if_then_else (ge (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (ge (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (je,%l0); + + OUTPUT_JUMP (\"jge %l0\", \"jae %l0\", \"jns %l0\"); +}") + +(define_expand "bgeu" + [(match_dup 1) + (set (pc) + (if_then_else (geu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (geu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "jae %l0") + +(define_expand "ble" + [(match_dup 1) + (set (pc) + (if_then_else (le (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (le (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (jb,%l0); + + OUTPUT_JUMP (\"jle %l0\", \"jbe %l0\", NULL_PTR); +}") + +(define_expand "bleu" + [(match_dup 1) + (set (pc) + (if_then_else (leu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1);") + +(define_insn "" + [(set (pc) + (if_then_else (leu (cc0) + (const_int 0)) + (label_ref (match_operand 0 "" "")) + (pc)))] + "" + "jbe %l0") + +;; Negated conditional jump instructions. + +(define_insn "" + [(set (pc) + (if_then_else (eq (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "* +{ + if (cc_prev_status.flags & CC_Z_IN_NOT_C) + return \"jc %l0\"; + else + return \"jne %l0\"; +}") + +(define_insn "" + [(set (pc) + (if_then_else (ne (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "* +{ + if (cc_prev_status.flags & CC_Z_IN_NOT_C) + return \"jnc %l0\"; + else + return \"je %l0\"; +}") + +(define_insn "" + [(set (pc) + (if_then_else (gt (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (jne,%l0); + + OUTPUT_JUMP (\"jle %l0\", \"jbe %l0\", NULL_PTR); +}") + +(define_insn "" + [(set (pc) + (if_then_else (gtu (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "jbe %l0") + +(define_insn "" + [(set (pc) + (if_then_else (lt (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (jne,%l0); + + OUTPUT_JUMP (\"jge %l0\", \"jae %l0\", \"jns %l0\"); +}") + +(define_insn "" + [(set (pc) + (if_then_else (ltu (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "jae %l0") + +(define_insn "" + [(set (pc) + (if_then_else (ge (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (jne,%l0); + + OUTPUT_JUMP (\"jl %l0\", \"jb %l0\", \"js %l0\"); +}") + +(define_insn "" + [(set (pc) + (if_then_else (geu (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "jb %l0") + +(define_insn "" + [(set (pc) + (if_then_else (le (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "* +{ + if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) + return AS1 (jae,%l0); + + OUTPUT_JUMP (\"jg %l0\", \"ja %l0\", NULL_PTR); +}") + +(define_insn "" + [(set (pc) + (if_then_else (leu (cc0) + (const_int 0)) + (pc) + (label_ref (match_operand 0 "" ""))))] + "" + "ja %l0") + +;; Unconditional and other jump instructions + +(define_insn "jump" + [(set (pc) + (label_ref (match_operand 0 "" "")))] + "" + "jmp %l0") + +(define_insn "indirect_jump" + [(set (pc) (match_operand:SI 0 "general_operand" "rm"))] + "" + "* +{ + CC_STATUS_INIT; + + return AS1 (jmp,%*%0); +}") + +;; ??? could transform while(--i > 0) S; to if (--i > 0) do S; while(--i); +;; if S does not change i + +(define_expand "decrement_and_branch_until_zero" + [(parallel [(set (pc) + (if_then_else (ge (plus:SI (match_operand:SI 0 "general_operand" "") + (const_int -1)) + (const_int 0)) + (label_ref (match_operand 1 "" "")) + (pc))) + (set (match_dup 0) + (plus:SI (match_dup 0) + (const_int -1)))])] + "" + "") + +(define_insn "" + [(set (pc) + (if_then_else (match_operator 0 "arithmetic_comparison_operator" + [(plus:SI (match_operand:SI 1 "general_operand" "+r,m") + (match_operand:SI 2 "general_operand" "rmi,ri")) + (const_int 0)]) + (label_ref (match_operand 3 "" "")) + (pc))) + (set (match_dup 1) + (plus:SI (match_dup 1) + (match_dup 2)))] + "" + "* +{ + CC_STATUS_INIT; + if (operands[2] == constm1_rtx) + output_asm_insn (AS1 (dec%L1,%1), operands); + + else if (operands[1] == const1_rtx) + output_asm_insn (AS1 (inc%L1,%1), operands); + + else + output_asm_insn (AS2 (add%L1,%2,%1), operands); + + return AS1 (%J0,%l3); +}") + +(define_insn "" + [(set (pc) + (if_then_else (match_operator 0 "arithmetic_comparison_operator" + [(minus:SI (match_operand:SI 1 "general_operand" "+r,m") + (match_operand:SI 2 "general_operand" "rmi,ri")) + (const_int 0)]) + (label_ref (match_operand 3 "" "")) + (pc))) + (set (match_dup 1) + (minus:SI (match_dup 1) + (match_dup 2)))] + "" + "* +{ + CC_STATUS_INIT; + if (operands[2] == const1_rtx) + output_asm_insn (AS1 (dec%L1,%1), operands); + + else if (operands[1] == constm1_rtx) + output_asm_insn (AS1 (inc%L1,%1), operands); + + else + output_asm_insn (AS2 (sub%L1,%2,%1), operands); + + return AS1 (%J0,%l3); +}") + +;; Implement switch statements when generating PIC code. Switches are +;; implemented by `tablejump' when not using -fpic. + +;; Emit code here to do the range checking and make the index zero based. + +(define_expand "casesi" + [(set (match_dup 5) + (minus:SI (match_operand:SI 0 "general_operand" "") + (match_operand:SI 1 "general_operand" ""))) + (set (cc0) + (compare:CC (match_dup 5) + (match_operand:SI 2 "general_operand" ""))) + (set (pc) + (if_then_else (gtu (cc0) + (const_int 0)) + (label_ref (match_operand 4 "" "")) + (pc))) + (parallel + [(set (pc) + (minus:SI (reg:SI 3) + (mem:SI (plus:SI (mult:SI (match_dup 5) + (const_int 4)) + (label_ref (match_operand 3 "" "")))))) + (clobber (match_scratch:SI 6 ""))])] + "flag_pic" + " +{ + operands[5] = gen_reg_rtx (SImode); + current_function_uses_pic_offset_table = 1; +}") + +;; Implement a casesi insn. + +;; Each entry in the "addr_diff_vec" looks like this as the result of the +;; two rules below: +;; +;; .long _GLOBAL_OFFSET_TABLE_+[.-.L2] +;; +;; 1. An expression involving an external reference may only use the +;; addition operator, and only with an assembly-time constant. +;; The example above satisfies this because ".-.L2" is a constant. +;; +;; 2. The symbol _GLOBAL_OFFSET_TABLE_ is magic, and at link time is +;; given the value of "GOT - .", where GOT is the actual address of +;; the Global Offset Table. Therefore, the .long above actually +;; stores the value "( GOT - . ) + [ . - .L2 ]", or "GOT - .L2". The +;; expression "GOT - .L2" by itself would generate an error from as(1). +;; +;; The pattern below emits code that looks like this: +;; +;; movl %ebx,reg +;; subl TABLE@GOTOFF(%ebx,index,4),reg +;; jmp reg +;; +;; The addr_diff_vec contents may be directly referenced with @GOTOFF, since +;; the addr_diff_vec is known to be part of this module. +;; +;; The subl above calculates "GOT - (( GOT - . ) + [ . - .L2 ])", which +;; evaluates to just ".L2". + +(define_insn "" + [(set (pc) + (minus:SI (reg:SI 3) + (mem:SI (plus:SI + (mult:SI (match_operand:SI 0 "register_operand" "r") + (const_int 4)) + (label_ref (match_operand 1 "" "")))))) + (clobber (match_scratch:SI 2 "=&r"))] + "" + "* +{ + rtx xops[4]; + + xops[0] = operands[0]; + xops[1] = operands[1]; + xops[2] = operands[2]; + xops[3] = pic_offset_table_rtx; + + output_asm_insn (AS2 (mov%L2,%3,%2), xops); + output_asm_insn (\"sub%L2 %l1@GOTOFF(%3,%0,4),%2\", xops); + output_asm_insn (AS1 (jmp,%*%2), xops); + ASM_OUTPUT_ALIGN_CODE (asm_out_file); + RET; +}") + +(define_insn "tablejump" + [(set (pc) (match_operand:SI 0 "general_operand" "rm")) + (use (label_ref (match_operand 1 "" "")))] + "" + "* +{ + CC_STATUS_INIT; + + return AS1 (jmp,%*%0); +}") + +;; Call insns. + +;; If generating PIC code, the predicate indirect_operand will fail +;; for operands[0] containing symbolic references on all of the named +;; call* patterns. Each named pattern is followed by an unnamed pattern +;; that matches any call to a symbolic CONST (ie, a symbol_ref). The +;; unnamed patterns are only used while generating PIC code, because +;; otherwise the named patterns match. + +;; Call subroutine returning no value. + +(define_expand "call_pop" + [(parallel [(call (match_operand:QI 0 "indirect_operand" "") + (match_operand:SI 1 "general_operand" "")) + (set (reg:SI 7) + (plus:SI (reg:SI 7) + (match_operand:SI 3 "immediate_operand" "")))])] + "" + " +{ + rtx addr; + + if (flag_pic) + current_function_uses_pic_offset_table = 1; + + /* With half-pic, force the address into a register. */ + addr = XEXP (operands[0], 0); + if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) + XEXP (operands[0], 0) = force_reg (Pmode, addr); + + if (! expander_call_insn_operand (operands[0], QImode)) + operands[0] + = change_address (operands[0], VOIDmode, + copy_to_mode_reg (Pmode, XEXP (operands[0], 0))); +}") + +(define_insn "" + [(call (match_operand:QI 0 "call_insn_operand" "m") + (match_operand:SI 1 "general_operand" "g")) + (set (reg:SI 7) (plus:SI (reg:SI 7) + (match_operand:SI 3 "immediate_operand" "i")))] + "" + "* +{ + if (GET_CODE (operands[0]) == MEM + && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) + { + operands[0] = XEXP (operands[0], 0); + return AS1 (call,%*%0); + } + else + return AS1 (call,%P0); +}") + +(define_insn "" + [(call (mem:QI (match_operand:SI 0 "symbolic_operand" "")) + (match_operand:SI 1 "general_operand" "g")) + (set (reg:SI 7) (plus:SI (reg:SI 7) + (match_operand:SI 3 "immediate_operand" "i")))] + "!HALF_PIC_P ()" + "call %P0") + +(define_expand "call" + [(call (match_operand:QI 0 "indirect_operand" "") + (match_operand:SI 1 "general_operand" ""))] + ;; Operand 1 not used on the i386. + "" + " +{ + rtx addr; + + if (flag_pic) + current_function_uses_pic_offset_table = 1; + + /* With half-pic, force the address into a register. */ + addr = XEXP (operands[0], 0); + if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) + XEXP (operands[0], 0) = force_reg (Pmode, addr); + + if (! expander_call_insn_operand (operands[0], QImode)) + operands[0] + = change_address (operands[0], VOIDmode, + copy_to_mode_reg (Pmode, XEXP (operands[0], 0))); +}") + +(define_insn "" + [(call (match_operand:QI 0 "call_insn_operand" "m") + (match_operand:SI 1 "general_operand" "g"))] + ;; Operand 1 not used on the i386. + "" + "* +{ + if (GET_CODE (operands[0]) == MEM + && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) + { + operands[0] = XEXP (operands[0], 0); + return AS1 (call,%*%0); + } + else + return AS1 (call,%P0); +}") + +(define_insn "" + [(call (mem:QI (match_operand:SI 0 "symbolic_operand" "")) + (match_operand:SI 1 "general_operand" "g"))] + ;; Operand 1 not used on the i386. + "!HALF_PIC_P ()" + "call %P0") + +;; Call subroutine, returning value in operand 0 +;; (which must be a hard register). + +(define_expand "call_value_pop" + [(parallel [(set (match_operand 0 "" "") + (call (match_operand:QI 1 "indirect_operand" "") + (match_operand:SI 2 "general_operand" ""))) + (set (reg:SI 7) + (plus:SI (reg:SI 7) + (match_operand:SI 4 "immediate_operand" "")))])] + "" + " +{ + rtx addr; + + if (flag_pic) + current_function_uses_pic_offset_table = 1; + + /* With half-pic, force the address into a register. */ + addr = XEXP (operands[1], 0); + if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) + XEXP (operands[1], 0) = force_reg (Pmode, addr); + + if (! expander_call_insn_operand (operands[1], QImode)) + operands[1] + = change_address (operands[1], VOIDmode, + copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); +}") + +(define_insn "" + [(set (match_operand 0 "" "=rf") + (call (match_operand:QI 1 "call_insn_operand" "m") + (match_operand:SI 2 "general_operand" "g"))) + (set (reg:SI 7) (plus:SI (reg:SI 7) + (match_operand:SI 4 "immediate_operand" "i")))] + "" + "* +{ + if (GET_CODE (operands[1]) == MEM + && ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0))) + { + operands[1] = XEXP (operands[1], 0); + output_asm_insn (AS1 (call,%*%1), operands); + } + else + output_asm_insn (AS1 (call,%P1), operands); + + RET; +}") + +(define_insn "" + [(set (match_operand 0 "" "=rf") + (call (mem:QI (match_operand:SI 1 "symbolic_operand" "")) + (match_operand:SI 2 "general_operand" "g"))) + (set (reg:SI 7) (plus:SI (reg:SI 7) + (match_operand:SI 4 "immediate_operand" "i")))] + "!HALF_PIC_P ()" + "call %P1") + +(define_expand "call_value" + [(set (match_operand 0 "" "") + (call (match_operand:QI 1 "indirect_operand" "") + (match_operand:SI 2 "general_operand" "")))] + ;; Operand 2 not used on the i386. + "" + " +{ + rtx addr; + + if (flag_pic) + current_function_uses_pic_offset_table = 1; + + /* With half-pic, force the address into a register. */ + addr = XEXP (operands[1], 0); + if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) + XEXP (operands[1], 0) = force_reg (Pmode, addr); + + if (! expander_call_insn_operand (operands[1], QImode)) + operands[1] + = change_address (operands[1], VOIDmode, + copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); +}") + +(define_insn "" + [(set (match_operand 0 "" "=rf") + (call (match_operand:QI 1 "call_insn_operand" "m") + (match_operand:SI 2 "general_operand" "g")))] + ;; Operand 2 not used on the i386. + "" + "* +{ + if (GET_CODE (operands[1]) == MEM + && ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0))) + { + operands[1] = XEXP (operands[1], 0); + output_asm_insn (AS1 (call,%*%1), operands); + } + else + output_asm_insn (AS1 (call,%P1), operands); + + RET; +}") + +(define_insn "" + [(set (match_operand 0 "" "=rf") + (call (mem:QI (match_operand:SI 1 "symbolic_operand" "")) + (match_operand:SI 2 "general_operand" "g")))] + ;; Operand 2 not used on the i386. + "!HALF_PIC_P ()" + "call %P1") + +;; Call subroutine returning any type. + +(define_expand "untyped_call" + [(parallel [(call (match_operand 0 "" "") + (const_int 0)) + (match_operand 1 "" "") + (match_operand 2 "" "")])] + "" + " +{ + int i; + + /* In order to give reg-stack an easier job in validating two + coprocessor registers as containing a possible return value, + simply pretend the untyped call returns a complex long double + value. */ + emit_call_insn (TARGET_80387 + ? gen_call_value (gen_rtx (REG, XCmode, FIRST_FLOAT_REG), + operands[0], const0_rtx) + : gen_call (operands[0], const0_rtx)); + + for (i = 0; i < XVECLEN (operands[2], 0); i++) + { + rtx set = XVECEXP (operands[2], 0, i); + emit_move_insn (SET_DEST (set), SET_SRC (set)); + } + + /* The optimizer does not know that the call sets the function value + registers we stored in the result block. We avoid problems by + claiming that all hard registers are used and clobbered at this + point. */ + emit_insn (gen_blockage ()); + + DONE; +}") + +;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and +;; all of memory. This blocks insns from being moved across this point. + +(define_insn "blockage" + [(unspec_volatile [(const_int 0)] 0)] + "" + "") + +;; Insn emitted into the body of a function to return from a function. +;; This is only done if the function's epilogue is known to be simple. +;; See comments for simple_386_epilogue in i386.c. + +(define_insn "return" + [(return)] + "simple_386_epilogue ()" + "* +{ + function_epilogue (asm_out_file, get_frame_size ()); + RET; +}") + +(define_insn "nop" + [(const_int 0)] + "" + "nop") + +(define_expand "movstrsi" + [(parallel [(set (match_operand:BLK 0 "memory_operand" "") + (match_operand:BLK 1 "memory_operand" "")) + (use (match_operand:SI 2 "const_int_operand" "")) + (use (match_operand:SI 3 "const_int_operand" "")) + (clobber (match_scratch:SI 4 "")) + (clobber (match_dup 5)) + (clobber (match_dup 6))])] + "" + " +{ + rtx addr0, addr1; + + if (GET_CODE (operands[2]) != CONST_INT) + FAIL; + + addr0 = copy_to_mode_reg (Pmode, XEXP (operands[0], 0)); + addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); + + operands[5] = addr0; + operands[6] = addr1; + + operands[0] = gen_rtx (MEM, BLKmode, addr0); + operands[1] = gen_rtx (MEM, BLKmode, addr1); +}") + +;; It might seem that operands 0 & 1 could use predicate register_operand. +;; But strength reduction might offset the MEM expression. So we let +;; reload put the address into %edi & %esi. + +(define_insn "" + [(set (mem:BLK (match_operand:SI 0 "address_operand" "D")) + (mem:BLK (match_operand:SI 1 "address_operand" "S"))) + (use (match_operand:SI 2 "const_int_operand" "n")) + (use (match_operand:SI 3 "immediate_operand" "i")) + (clobber (match_scratch:SI 4 "=&c")) + (clobber (match_dup 0)) + (clobber (match_dup 1))] + "" + "* +{ + rtx xops[2]; + + output_asm_insn (\"cld\", operands); + if (GET_CODE (operands[2]) == CONST_INT) + { + if (INTVAL (operands[2]) & ~0x03) + { + xops[0] = GEN_INT ((INTVAL (operands[2]) >> 2) & 0x3fffffff); + xops[1] = operands[4]; + + output_asm_insn (AS2 (mov%L1,%0,%1), xops); +#ifdef INTEL_SYNTAX + output_asm_insn (\"rep movsd\", xops); +#else + output_asm_insn (\"rep\;movsl\", xops); +#endif + } + if (INTVAL (operands[2]) & 0x02) + output_asm_insn (\"movsw\", operands); + if (INTVAL (operands[2]) & 0x01) + output_asm_insn (\"movsb\", operands); + } + else + abort (); + RET; +}") + +(define_expand "cmpstrsi" + [(parallel [(set (match_operand:SI 0 "general_operand" "") + (compare:SI (match_operand:BLK 1 "general_operand" "") + (match_operand:BLK 2 "general_operand" ""))) + (use (match_operand:SI 3 "general_operand" "")) + (use (match_operand:SI 4 "immediate_operand" "")) + (clobber (match_dup 5)) + (clobber (match_dup 6)) + (clobber (match_dup 3))])] + "" + " +{ + rtx addr1, addr2; + + addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); + addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0)); + operands[3] = copy_to_mode_reg (SImode, operands[3]); + + operands[5] = addr1; + operands[6] = addr2; + + operands[1] = gen_rtx (MEM, BLKmode, addr1); + operands[2] = gen_rtx (MEM, BLKmode, addr2); + +}") + +;; memcmp recognizers. The `cmpsb' opcode does nothing if the count is +;; zero. Emit extra code to make sure that a zero-length compare is EQ. + +;; It might seem that operands 0 & 1 could use predicate register_operand. +;; But strength reduction might offset the MEM expression. So we let +;; reload put the address into %edi & %esi. + +;; ??? Most comparisons have a constant length, and it's therefore +;; possible to know that the length is non-zero, and to avoid the extra +;; code to handle zero-length compares. + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=&r") + (compare:SI (mem:BLK (match_operand:SI 1 "address_operand" "S")) + (mem:BLK (match_operand:SI 2 "address_operand" "D")))) + (use (match_operand:SI 3 "register_operand" "c")) + (use (match_operand:SI 4 "immediate_operand" "i")) + (clobber (match_dup 1)) + (clobber (match_dup 2)) + (clobber (match_dup 3))] + "" + "* +{ + rtx xops[4], label; + + label = gen_label_rtx (); + + output_asm_insn (\"cld\", operands); + output_asm_insn (AS2 (xor%L0,%0,%0), operands); + output_asm_insn (\"repz\;cmps%B2\", operands); + output_asm_insn (\"je %l0\", &label); + + xops[0] = operands[0]; + xops[1] = gen_rtx (MEM, QImode, + gen_rtx (PLUS, SImode, operands[1], constm1_rtx)); + xops[2] = gen_rtx (MEM, QImode, + gen_rtx (PLUS, SImode, operands[2], constm1_rtx)); + xops[3] = operands[3]; + + output_asm_insn (AS2 (movz%B1%L0,%1,%0), xops); + output_asm_insn (AS2 (movz%B2%L3,%2,%3), xops); + + output_asm_insn (AS2 (sub%L0,%3,%0), xops); + ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (label)); + RET; +}") + +(define_insn "" + [(set (cc0) + (compare:SI (mem:BLK (match_operand:SI 0 "address_operand" "S")) + (mem:BLK (match_operand:SI 1 "address_operand" "D")))) + (use (match_operand:SI 2 "register_operand" "c")) + (use (match_operand:SI 3 "immediate_operand" "i")) + (clobber (match_dup 0)) + (clobber (match_dup 1)) + (clobber (match_dup 2))] + "" + "* +{ + rtx xops[2]; + + cc_status.flags |= CC_NOT_SIGNED; + + xops[0] = gen_rtx (REG, QImode, 0); + xops[1] = CONST0_RTX (QImode); + + output_asm_insn (\"cld\", operands); + output_asm_insn (AS2 (test%B0,%1,%0), xops); + return \"repz\;cmps%B2\"; +}") + +(define_expand "ffssi2" + [(set (match_dup 2) + (plus:SI (ffs:SI (match_operand:SI 1 "general_operand" "")) + (const_int -1))) + (set (match_operand:SI 0 "general_operand" "") + (plus:SI (match_dup 2) (const_int 1)))] + "" + "operands[2] = gen_reg_rtx (SImode);") + +;; Note, you cannot optimize away the branch following the bsfl by assuming +;; that the destination is not modified if the input is 0, since not all +;; x86 implementations do this. + +(define_insn "" + [(set (match_operand:SI 0 "general_operand" "=&r") + (plus:SI (ffs:SI (match_operand:SI 1 "general_operand" "rm")) + (const_int -1)))] + "" + "* +{ + rtx xops[3]; + static int ffssi_label_number; + char buffer[30]; + + xops[0] = operands[0]; + xops[1] = operands[1]; + xops[2] = constm1_rtx; + output_asm_insn (AS2 (bsf%L0,%1,%0), xops); +#ifdef LOCAL_LABEL_PREFIX + sprintf (buffer, \"jnz %sLFFSSI%d\", + LOCAL_LABEL_PREFIX, ffssi_label_number); +#else + sprintf (buffer, \"jnz %sLFFSSI%d\", + \"\", ffssi_label_number); +#endif + output_asm_insn (buffer, xops); + output_asm_insn (AS2 (mov%L0,%2,%0), xops); +#ifdef LOCAL_LABEL_PREFIX + sprintf (buffer, \"%sLFFSSI%d:\", + LOCAL_LABEL_PREFIX, ffssi_label_number); +#else + sprintf (buffer, \"%sLFFSSI%d:\", + \"\", ffssi_label_number); +#endif + output_asm_insn (buffer, xops); + + ffssi_label_number++; + return \"\"; +}") + +(define_expand "ffshi2" + [(set (match_dup 2) + (plus:HI (ffs:HI (match_operand:HI 1 "general_operand" "")) + (const_int -1))) + (set (match_operand:HI 0 "general_operand" "") + (plus:HI (match_dup 2) (const_int 1)))] + "" + "operands[2] = gen_reg_rtx (HImode);") + +(define_insn "" + [(set (match_operand:HI 0 "general_operand" "=&r") + (plus:HI (ffs:HI (match_operand:SI 1 "general_operand" "rm")) + (const_int -1)))] + "" + "* +{ + rtx xops[3]; + static int ffshi_label_number; + char buffer[30]; + + xops[0] = operands[0]; + xops[1] = operands[1]; + xops[2] = constm1_rtx; + output_asm_insn (AS2 (bsf%W0,%1,%0), xops); +#ifdef LOCAL_LABEL_PREFIX + sprintf (buffer, \"jnz %sLFFSHI%d\", + LOCAL_LABEL_PREFIX, ffshi_label_number); +#else + sprintf (buffer, \"jnz %sLFFSHI%d\", + \"\", ffshi_label_number); +#endif + output_asm_insn (buffer, xops); + output_asm_insn (AS2 (mov%W0,%2,%0), xops); +#ifdef LOCAL_LABEL_PREFIX + sprintf (buffer, \"%sLFFSHI%d:\", + LOCAL_LABEL_PREFIX, ffshi_label_number); +#else + sprintf (buffer, \"%sLFFSHI%d:\", + \"\", ffshi_label_number); +#endif + output_asm_insn (buffer, xops); + + ffshi_label_number++; + return \"\"; +}") + +;; These patterns match the binary 387 instructions for addM3, subM3, +;; mulM3 and divM3. There are three patterns for each of DFmode and +;; SFmode. The first is the normal insn, the second the same insn but +;; with one operand a conversion, and the third the same insn but with +;; the other operand a conversion. The conversion may be SFmode or +;; SImode if the target mode DFmode, but only SImode if the target mode +;; is SFmode. + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f,f") + (match_operator:DF 3 "binary_387_op" + [(match_operand:DF 1 "nonimmediate_operand" "0,fm") + (match_operand:DF 2 "nonimmediate_operand" "fm,0")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (match_operator:DF 3 "binary_387_op" + [(float:DF (match_operand:SI 1 "general_operand" "rm")) + (match_operand:DF 2 "general_operand" "0")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f,f") + (match_operator:XF 3 "binary_387_op" + [(match_operand:XF 1 "nonimmediate_operand" "0,f") + (match_operand:XF 2 "nonimmediate_operand" "f,0")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f") + (match_operator:XF 3 "binary_387_op" + [(float:XF (match_operand:SI 1 "general_operand" "rm")) + (match_operand:XF 2 "general_operand" "0")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f,f") + (match_operator:XF 3 "binary_387_op" + [(float_extend:XF (match_operand:SF 1 "general_operand" "fm,0")) + (match_operand:XF 2 "general_operand" "0,f")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f") + (match_operator:XF 3 "binary_387_op" + [(match_operand:XF 1 "general_operand" "0") + (float:XF (match_operand:SI 2 "general_operand" "rm"))]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:XF 0 "register_operand" "=f,f") + (match_operator:XF 3 "binary_387_op" + [(match_operand:XF 1 "general_operand" "0,f") + (float_extend:XF + (match_operand:SF 2 "general_operand" "fm,0"))]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f,f") + (match_operator:DF 3 "binary_387_op" + [(float_extend:DF (match_operand:SF 1 "general_operand" "fm,0")) + (match_operand:DF 2 "general_operand" "0,f")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f") + (match_operator:DF 3 "binary_387_op" + [(match_operand:DF 1 "general_operand" "0") + (float:DF (match_operand:SI 2 "general_operand" "rm"))]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:DF 0 "register_operand" "=f,f") + (match_operator:DF 3 "binary_387_op" + [(match_operand:DF 1 "general_operand" "0,f") + (float_extend:DF + (match_operand:SF 2 "general_operand" "fm,0"))]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:SF 0 "register_operand" "=f,f") + (match_operator:SF 3 "binary_387_op" + [(match_operand:SF 1 "nonimmediate_operand" "0,fm") + (match_operand:SF 2 "nonimmediate_operand" "fm,0")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:SF 0 "register_operand" "=f") + (match_operator:SF 3 "binary_387_op" + [(float:SF (match_operand:SI 1 "general_operand" "rm")) + (match_operand:SF 2 "general_operand" "0")]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_insn "" + [(set (match_operand:SF 0 "register_operand" "=f") + (match_operator:SF 3 "binary_387_op" + [(match_operand:SF 1 "general_operand" "0") + (float:SF (match_operand:SI 2 "general_operand" "rm"))]))] + "TARGET_80387" + "* return output_387_binary_op (insn, operands);") + +(define_expand "strlensi" + [(parallel [(set (match_dup 4) + (unspec:SI [(mem:BLK (match_operand:BLK 1 "general_operand" "")) + (match_operand:QI 2 "register_operand" "") + (match_operand:SI 3 "immediate_operand" "")] 0)) + (clobber (match_dup 1))]) + (set (match_dup 5) + (not:SI (match_dup 4))) + (set (match_operand:SI 0 "register_operand" "") + (minus:SI (match_dup 5) + (const_int 1)))] + "" + " +{ + operands[1] = copy_to_mode_reg (SImode, XEXP (operands[1], 0)); + operands[4] = gen_reg_rtx (SImode); + operands[5] = gen_reg_rtx (SImode); +}") + +;; It might seem that operands 0 & 1 could use predicate register_operand. +;; But strength reduction might offset the MEM expression. So we let +;; reload put the address into %edi. + +(define_insn "" + [(set (match_operand:SI 0 "register_operand" "=&c") + (unspec:SI [(mem:BLK (match_operand:SI 1 "address_operand" "D")) + (match_operand:QI 2 "register_operand" "a") + (match_operand:SI 3 "immediate_operand" "i")] 0)) + (clobber (match_dup 1))] + "" + "* +{ + rtx xops[2]; + + xops[0] = operands[0]; + xops[1] = constm1_rtx; + output_asm_insn (\"cld\", operands); + output_asm_insn (AS2 (mov%L0,%1,%0), xops); + return \"repnz\;scas%B2\"; +}") diff --git a/support/cpp/i386/i386iscgas.h b/support/cpp/i386/i386iscgas.h new file mode 100644 index 00000000..526fe374 --- /dev/null +++ b/support/cpp/i386/i386iscgas.h @@ -0,0 +1,67 @@ +/* Definitions for Intel 386 running Interactive Unix System V, + producing stabs-in-coff output (using a slightly modified gas). + Specifically, this is for recent versions that support POSIX; + for version 2.0.2, use configuration option i386-sysv instead. */ + +/* Underscores are not used on ISC systems (probably not on any COFF + system), despite the comments in i386/gas.h. If this is not defined, + enquire (for example) will fail to link. --karl@cs.umb.edu */ +#define NO_UNDERSCORES + +/* Mostly like other gas-using systems. */ +#include "i386/gas.h" + +/* But with ISC-specific additions. */ +#include "i386/isc.h" + +/* We do not want to output SDB debugging information. */ + +#undef SDB_DEBUGGING_INFO + +/* We want to output DBX debugging information. */ + +#define DBX_DEBUGGING_INFO + + +/* The function `dbxout_init' in dbxout.c omits the first character of + `ltext_label_name' when outputting the main source directory and main + source filename. I don't understand why, but rather than making a + system-independent change there, I override dbxout.c's defaults. + Perhaps it would be better to use ".Ltext0" instead of + `ltext_label_name', but we've already generated the label, so we just + use it here. --karl@cs.umb.edu */ +#define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(asmfile, cwd) \ + do { fprintf (asmfile, "%s ", ASM_STABS_OP); \ + output_quoted_string (asmfile, cwd); \ + fprintf (asmfile, ",%d,0,0,%s\n", N_SO, ltext_label_name); \ + } while (0) +#define DBX_OUTPUT_MAIN_SOURCE_FILENAME(asmfile, input_file_name) \ + fprintf (asmfile, "%s ", ASM_STABS_OP); \ + output_quoted_string (input_file_name); \ + fprintf (asmfile, ",%d,0,0,%s\n", N_SO, ltext_label_name); \ + text_section (); \ + ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0) + + +/* Because we don't include `svr3.h', we haven't yet defined SIZE_TYPE + and PTRDIFF_TYPE. ISC's definitions don't match GCC's defaults, so: */ + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + + +/* But we can't use crtbegin.o and crtend.o, because gas 1.38.1 doesn't + grok .section. The definitions here are otherwise identical to those + in i386/isc.h. */ +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!shlib:%{posix:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ + %{!posix:%{pg:mcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}\ + %{p:-L/lib/libp} %{pg:-L/lib/libp}}}\ + %{shlib:%{posix:crtp1.o%s}%{!posix:crt1.o%s}}" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "crtn.o%s" diff --git a/support/cpp/i386/isc.h b/support/cpp/i386/isc.h new file mode 100644 index 00000000..cf8c5f69 --- /dev/null +++ b/support/cpp/i386/isc.h @@ -0,0 +1,89 @@ +/* Assembler-independent definitions for an Intel 386 running + Interactive Unix System V. Specifically, this is for recent versions + that support POSIX. */ + +/* Use crt1.o, not crt0.o, as a startup file, and crtn.o as a closing file. */ +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!shlib:%{posix:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ + %{Xp:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ + %{!posix:%{!Xp:%{pg:mcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}\ + %{p:-L/lib/libp} %{pg:-L/lib/libp}}}}\ + %{shlib:%{Xp:crtp1.o%s}%{posix:crtp1.o%s}%{!posix:%{!Xp:crt1.o%s}}}\ + crtbegin.o%s" + +#define ENDFILE_SPEC "crtend.o%s crtn.o%s" + +/* Library spec */ +#undef LIB_SPEC +#define LIB_SPEC "%{shlib:-lc_s} %{posix:-lcposix} %{Xp:-lcposix} -lc -lg" + +#undef CPP_SPEC +#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{Xp:-D_POSIX_SOURCE}" + +/* ISC 2.2 uses `char' for `wchar_t'. */ +#undef WCHAR_TYPE +#define WCHAR_TYPE "char" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE BITS_PER_UNIT + +#if 0 +/* This is apparently not true: ISC versions up to 3.0, at least, use + the standard calling sequence in which the called function pops the + extra arg. */ +/* caller has to pop the extra argument passed to functions that return + structures. */ + +#undef RETURN_POPS_ARGS +#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ + (TREE_CODE (FUNTYPE) == IDENTIFIER_NODE ? 0 \ + : (TARGET_RTD \ + && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ + || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ + == void_type_node))) ? (SIZE) \ + : 0) +/* On other 386 systems, the last line looks like this: + : (aggregate_value_p (TREE_TYPE (FUNTYPE))) ? GET_MODE_SIZE (Pmode) : 0) */ +#endif + +/* Handle #pragma pack and #pragma weak. */ +#define HANDLE_SYSV_PRAGMA + +/* By default, target has a 80387, uses IEEE compatible arithmetic, + and returns float values in the 387, ie, + (TARGET_80387 | TARGET_FLOAT_RETURNS_IN_80387) + + ISC's software emulation of a 387 fails to handle the `fucomp' + opcode. fucomp is only used when generating IEEE compliant code. + So don't make TARGET_IEEE_FP default for ISC. */ + +#undef TARGET_DEFAULT +#define TARGET_DEFAULT 0201 + +/* The ISC 2.0.2 software FPU emulator apparently can't handle + 80-bit XFmode insns, so don't generate them. */ +#undef LONG_DOUBLE_TYPE_SIZE +#define LONG_DOUBLE_TYPE_SIZE 64 + +/* The ISC assembler does not like a .file directive with a name + longer than 14 characters. Truncating it will not permit + debugging to work properly, but at least we won't get an error + message. */ + +#undef ASM_FILE_START +#define ASM_FILE_START(FILE) \ + do { \ + char c; \ + int max = 0; \ + char *string = dump_base_name; \ + \ + fputs ("\t.file\t\"", FILE); \ + \ + while ((c = *string++) != 0 && max++ < 14) { \ + if (c == '\"' || c == '\\') \ + putc ('\\', FILE); \ + putc (c, FILE); \ + } \ + fputs ("\"\n", FILE); \ + } while (0) diff --git a/support/cpp/i386/isccoff.h b/support/cpp/i386/isccoff.h new file mode 100644 index 00000000..383b9813 --- /dev/null +++ b/support/cpp/i386/isccoff.h @@ -0,0 +1,12 @@ +/* Definitions for Intel 386 running Interactive Unix System V. + Specifically, this is for recent versions that support POSIX; + for version 2.0.2, use configuration option i386-sysv instead. + (But set TARGET_DEFAULT to 0201 if you do that, + if you don't have a real 80387.) */ + +/* Mostly it's like AT&T Unix System V. */ + +#include "i386/sysv3.h" + +/* But with a few changes. */ +#include "i386/isc.h" diff --git a/support/cpp/i386/iscdbx.h b/support/cpp/i386/iscdbx.h new file mode 100644 index 00000000..6c2d42e4 --- /dev/null +++ b/support/cpp/i386/iscdbx.h @@ -0,0 +1,43 @@ +/* Definitions for Intel 386 running Interactive Unix System V, + using dbx-in-coff encapsulation. + Specifically, this is for recent versions that support POSIX. + Copyright (C) 1992, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Mostly it's like AT&T Unix System V with dbx-in-coff. */ + +#include "i386/svr3dbx.h" + +/* But with a few changes. */ +#undef ENDFILE_SPEC +#include "i386/isc.h" + +/* Overridden defines for ifile usage. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!r:%{!z:svr3.ifile%s}%{z:svr3z.ifile%s}}\ + %{!shlib:%{posix:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ + %{Xp:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ + %{!posix:%{!Xp:%{pg:mcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}}\ + %{p:-L/usr/lib/libp} %{pg:-L/usr/lib/libp}}\ + %{shlib:%{posix:crtp1.o%s}%{Xp:crtp1.o%s}%{!posix:%{!Xp:crt1.o%s}}}" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "crtn.o%s" diff --git a/support/cpp/i386/linux-aout.h b/support/cpp/i386/linux-aout.h new file mode 100644 index 00000000..7e46c68b --- /dev/null +++ b/support/cpp/i386/linux-aout.h @@ -0,0 +1,76 @@ +/* Definitions for Intel 386 running Linux + Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc. + Contributed by H.J. Lu (hjl@nynexst.com) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This is tested by i386/gas.h. */ +#define YES_UNDERSCORES + +#include +#include /* some common stuff */ + +/* Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#if TARGET_CPU_DEFAULT == 2 +#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}" +#else +#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}" +#endif + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "long int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE BITS_PER_WORD + +/* Don't default to pcc-struct-return, because gcc is the only compiler, + and we want to retain compatibility with older gcc versions. */ +#define DEFAULT_PCC_STRUCT_RETURN 0 + +#undef LIB_SPEC + +#if 1 +/* We no longer link with libc_p.a or libg.a by default. If you + * want to profile or debug the Linux C library, please add + * -lc_p or -ggdb to LDFLAGS at the link time, respectively. + */ +#define LIB_SPEC \ +"%{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} %{!ggdb:-lc} %{ggdb:-lg}" +#else +#define LIB_SPEC \ +"%{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \ + %{!p:%{!pg:%{!g*:-lc} %{g*:-lg -static}}}" +#endif + + +#undef LINK_SPEC +#define LINK_SPEC "-m i386linux" + +/* Get perform_* macros to build libgcc.a. */ +#include "i386/perform.h" diff --git a/support/cpp/i386/linux-oldld.h b/support/cpp/i386/linux-oldld.h new file mode 100644 index 00000000..c3066ba1 --- /dev/null +++ b/support/cpp/i386/linux-oldld.h @@ -0,0 +1,76 @@ +/* Definitions for Intel 386 running Linux with pre-BFD a.out linkers + Copyright (C) 1995 Free Software Foundation, Inc. + Contributed by Michael Meissner (meissner@cygnus.com) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This is tested by i386/gas.h. */ +#define YES_UNDERSCORES + +#include +#include /* some common stuff */ + +/* Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#if TARGET_CPU_DEFAULT == 2 +#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}" +#else +#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}" +#endif + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "long int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE BITS_PER_WORD + +/* Don't default to pcc-struct-return, because gcc is the only compiler, + and we want to retain compatibility with older gcc versions. */ +#define DEFAULT_PCC_STRUCT_RETURN 0 + +#undef LIB_SPEC + +#if 1 +/* We no longer link with libc_p.a or libg.a by default. If you + * want to profile or debug the Linux C library, please add + * -lc_p or -ggdb to LDFLAGS at the link time, respectively. + */ +#define LIB_SPEC \ +"%{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} %{!ggdb:-lc} %{ggdb:-lg}" +#else +#define LIB_SPEC \ +"%{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \ + %{!p:%{!pg:%{!g*:-lc} %{g*:-lg -static}}}" +#endif + + +#undef LINK_SPEC +#define LINK_SPEC "" + +/* Get perform_* macros to build libgcc.a. */ +#include diff --git a/support/cpp/i386/linux.h b/support/cpp/i386/linux.h new file mode 100644 index 00000000..a0b49bab --- /dev/null +++ b/support/cpp/i386/linux.h @@ -0,0 +1,235 @@ +/* Definitions for Intel 386 running Linux with ELF format + Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Contributed by Eric Youngdale. + Modified for stabs-in-ELF by H.J. Lu. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define LINUX_DEFAULT_ELF + +/* A lie, I guess, but the general idea behind linux/ELF is that we are + supposed to be outputting something that will assemble under SVr4. + This gets us pretty close. */ +#include /* Base i386 target machine definitions */ +#include /* Use the i386 AT&T assembler syntax */ +#include /* some common stuff */ + +#undef TARGET_VERSION +#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)"); + +/* The svr4 ABI for the i386 says that records and unions are returned + in memory. */ +#undef DEFAULT_PCC_STRUCT_RETURN +#define DEFAULT_PCC_STRUCT_RETURN 1 + +/* This is how to output an element of a case-vector that is relative. + This is only used for PIC code. See comments by the `casesi' insn in + i386.md for an explanation of the expression this outputs. */ +#undef ASM_OUTPUT_ADDR_DIFF_ELT +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ + fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) + +/* Indicate that jump tables go in the text section. This is + necessary when compiling PIC code. */ +#define JUMP_TABLES_IN_TEXT_SECTION + +/* Copy this from the svr4 specifications... */ +/* Define the register numbers to be used in Dwarf debugging information. + The SVR4 reference port C compiler uses the following register numbers + in its Dwarf output code: + 0 for %eax (gnu regno = 0) + 1 for %ecx (gnu regno = 2) + 2 for %edx (gnu regno = 1) + 3 for %ebx (gnu regno = 3) + 4 for %esp (gnu regno = 7) + 5 for %ebp (gnu regno = 6) + 6 for %esi (gnu regno = 4) + 7 for %edi (gnu regno = 5) + The following three DWARF register numbers are never generated by + the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 + believes these numbers have these meanings. + 8 for %eip (no gnu equivalent) + 9 for %eflags (no gnu equivalent) + 10 for %trapno (no gnu equivalent) + It is not at all clear how we should number the FP stack registers + for the x86 architecture. If the version of SDB on x86/svr4 were + a bit less brain dead with respect to floating-point then we would + have a precedent to follow with respect to DWARF register numbers + for x86 FP registers, but the SDB on x86/svr4 is so completely + broken with respect to FP registers that it is hardly worth thinking + of it as something to strive for compatibility with. + The version of x86/svr4 SDB I have at the moment does (partially) + seem to believe that DWARF register number 11 is associated with + the x86 register %st(0), but that's about all. Higher DWARF + register numbers don't seem to be associated with anything in + particular, and even for DWARF regno 11, SDB only seems to under- + stand that it should say that a variable lives in %st(0) (when + asked via an `=' command) if we said it was in DWARF regno 11, + but SDB still prints garbage when asked for the value of the + variable in question (via a `/' command). + (Also note that the labels SDB prints for various FP stack regs + when doing an `x' command are all wrong.) + Note that these problems generally don't affect the native SVR4 + C compiler because it doesn't allow the use of -O with -g and + because when it is *not* optimizing, it allocates a memory + location for each floating-point variable, and the memory + location is what gets described in the DWARF AT_location + attribute for the variable in question. + Regardless of the severe mental illness of the x86/svr4 SDB, we + do something sensible here and we use the following DWARF + register numbers. Note that these are all stack-top-relative + numbers. + 11 for %st(0) (gnu regno = 8) + 12 for %st(1) (gnu regno = 9) + 13 for %st(2) (gnu regno = 10) + 14 for %st(3) (gnu regno = 11) + 15 for %st(4) (gnu regno = 12) + 16 for %st(5) (gnu regno = 13) + 17 for %st(6) (gnu regno = 14) + 18 for %st(7) (gnu regno = 15) +*/ +#undef DBX_REGISTER_NUMBER +#define DBX_REGISTER_NUMBER(n) \ +((n) == 0 ? 0 \ + : (n) == 1 ? 2 \ + : (n) == 2 ? 1 \ + : (n) == 3 ? 3 \ + : (n) == 4 ? 6 \ + : (n) == 5 ? 7 \ + : (n) == 6 ? 5 \ + : (n) == 7 ? 4 \ + : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ + : (-1)) + +/* Output assembler code to FILE to increment profiler label # LABELNO + for profiling a function entry. */ + +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ +{ \ + if (flag_pic) \ + { \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ + LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall mcount\n"); \ + } \ +} + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "long int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE BITS_PER_WORD + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#ifdef USE_GNULIBC_1 +#if TARGET_CPU_DEFAULT == 2 +#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}" +#else +#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}" +#endif +#else /* not USE_GNULIBC_1 */ +#define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" +#endif /* not USE_GNULIBC_1 */ + +#undef LIBGCC_SPEC +#define LIBGCC_SPEC "-lgcc" + +#undef LIB_SPEC +#ifdef USE_GNULIBC_1 +#if 1 +/* We no longer link with libc_p.a or libg.a by default. If you + * want to profile or debug the Linux C library, please add + * -lc_p or -ggdb to LDFLAGS at the link time, respectively. + */ +#define LIB_SPEC \ + "%{!shared: %{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} \ + %{!ggdb:-lc} %{ggdb:-lg}}" +#else +#define LIB_SPEC \ + "%{!shared: \ + %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \ + %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}" +#endif +#else +#define LIB_SPEC \ + "%{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \ + %{profile:-lc_p} %{!profile: -lc}}" +#endif /* not USE_GNULIBC_1 */ + +/* Provide a LINK_SPEC appropriate for Linux. Here we provide support + for the special GCC options -static and -shared, which allow us to + link things in one of these three modes by applying the appropriate + combinations of options at link-time. We like to support here for + as many of the other GNU linker options as possible. But I don't + have the time to search for those flags. I am sure how to add + support for -soname shared_object_name. H.J. + + I took out %{v:%{!V:-V}}. It is too much :-(. They can use + -Wl,-V. + + When the -shared link option is used a final link is not being + done. */ + +/* If ELF is the default format, we should not use /lib/elf. */ + +#undef LINK_SPEC +#ifdef USE_GNULIBC_1 +#ifndef LINUX_DEFAULT_ELF +#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \ + %{!rpath:-rpath /lib/elf/}} %{static:-static}}}" +#else +#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \ + %{static:-static}}}" +#endif +#else /* not USE_GNULIBC_1 */ +#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ + %{static:-static}}}" +#endif /* not USE_GNULIBC_1 */ + +/* Get perform_* macros to build libgcc.a. */ +#include "i386/perform.h" diff --git a/support/cpp/i386/lynx-ng.h b/support/cpp/i386/lynx-ng.h new file mode 100644 index 00000000..ec4e2961 --- /dev/null +++ b/support/cpp/i386/lynx-ng.h @@ -0,0 +1,37 @@ +/* Definitions for Intel 386 running LynxOS, using Lynx's old as and ld. + Copyright (C) 1993, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include +#include + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -DI386 -DLynx -DIBITS32 -Asystem(unix) -Asystem(lynx) -Acpu(i386) -Amachine(i386)" + +/* Provide required defaults for linker switches. */ + +#undef LINK_SPEC +#define LINK_SPEC "-P1000 %{msystem-v:-V} %{mcoff:-k}" + +/* Apparently LynxOS clobbers ebx when you call into the OS. */ + +#undef CALL_USED_REGISTERS +#define CALL_USED_REGISTERS \ +/*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \ +{ 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } diff --git a/support/cpp/i386/lynx.h b/support/cpp/i386/lynx.h new file mode 100644 index 00000000..4ac00a05 --- /dev/null +++ b/support/cpp/i386/lynx.h @@ -0,0 +1,39 @@ +/* Definitions for Intel 386 running LynxOS. + Copyright (C) 1993, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include +#include + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -DI386 -DLynx -DIBITS32 -Asystem(unix) -Asystem(lynx) -Acpu(i386) -Amachine(i386)" + +/* This is how to output a reference to a user-level label named NAME. */ + +/* Override the svr3 convention of adding a leading underscore. */ + +#undef ASM_OUTPUT_LABELREF +#define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "%s", NAME) + +/* Apparently LynxOS clobbers ebx when you call into the OS. */ + +#undef CALL_USED_REGISTERS +#define CALL_USED_REGISTERS \ +/*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \ +{ 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } diff --git a/support/cpp/i386/mach.h b/support/cpp/i386/mach.h new file mode 100644 index 00000000..4b7cf37e --- /dev/null +++ b/support/cpp/i386/mach.h @@ -0,0 +1,20 @@ +/* Configuration for an i386 running Mach as the target machine. */ + +/* We do want to add an underscore to the front of each user symbol. + i386/gas.h checks this. */ +#define YES_UNDERSCORES + +#include "i386/gstabs.h" + +/* Get perform_* macros to build libgcc.a. */ +#include "i386/perform.h" + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -DMACH -Asystem(unix) -Asystem(mach) -Acpu(i386) -Amachine(i386)" + +/* Specify extra dir to search for include files. */ +#define SYSTEM_INCLUDE_DIR "/usr/mach/include" + +/* Don't default to pcc-struct-return, because gcc is the only compiler, and + we want to retain compatibility with older gcc versions. */ +#define DEFAULT_PCC_STRUCT_RETURN 0 diff --git a/support/cpp/i386/netbsd.h b/support/cpp/i386/netbsd.h new file mode 100644 index 00000000..180ff353 --- /dev/null +++ b/support/cpp/i386/netbsd.h @@ -0,0 +1,80 @@ +/* This goes away when the math-emulator is fixed */ +#define TARGET_CPU_DEFAULT 0400 /* TARGET_NO_FANCY_MATH_387 */ + +/* This is tested by i386gas.h. */ +#define YES_UNDERSCORES + +#include + +/* Get perform_* macros to build libgcc.a. */ +#include + +/* Get generic NetBSD definitions. */ +#include + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -D__NetBSD__ -Asystem(unix) -Asystem(NetBSD) -Acpu(i386) -Amachine(i386)" + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#undef WCHAR_UNSIGNED +#define WCHAR_UNSIGNED 0 + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +#define HANDLE_SYSV_PRAGMA + +/* There are conflicting reports about whether this system uses + a different assembler syntax. wilson@cygnus.com says # is right. */ +#undef COMMENT_BEGIN +#define COMMENT_BEGIN "#" + +#undef ASM_APP_ON +#define ASM_APP_ON "#APP\n" + +#undef ASM_APP_OFF +#define ASM_APP_OFF "#NO_APP\n" + +/* The following macros are stolen from i386v4.h */ +/* These have to be defined to get PIC code correct */ + +/* This is how to output an element of a case-vector that is relative. + This is only used for PIC code. See comments by the `casesi' insn in + i386.md for an explanation of the expression this outputs. */ + +#undef ASM_OUTPUT_ADDR_DIFF_ELT +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ + fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) + +/* Indicate that jump tables go in the text section. This is + necessary when compiling PIC code. */ + +#define JUMP_TABLES_IN_TEXT_SECTION + +/* Don't default to pcc-struct-return, because gcc is the only compiler, and + we want to retain compatibility with older gcc versions. */ +#define DEFAULT_PCC_STRUCT_RETURN 0 + +/* Profiling routines, partially copied from i386/osfrose.h. */ + +/* Redefine this to use %eax instead of %edx. */ +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ +{ \ + if (flag_pic) \ + { \ + fprintf (FILE, "\tcall mcount@PLT\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tcall mcount\n"); \ + } \ +} diff --git a/support/cpp/i386/next.c b/support/cpp/i386/next.c new file mode 100644 index 00000000..f249647a --- /dev/null +++ b/support/cpp/i386/next.c @@ -0,0 +1,7 @@ +/* next.c: Functions for NeXT as target machine for GNU C compiler. */ + +/* Note that the include below means that we can't debug routines in + i386.c when running on a COFF system. */ + +#include "i386/i386.c" +#include "nextstep.c" diff --git a/support/cpp/i386/next.h b/support/cpp/i386/next.h new file mode 100644 index 00000000..c0d6d729 --- /dev/null +++ b/support/cpp/i386/next.h @@ -0,0 +1,226 @@ +/* Target definitions for GNU compiler for Intel x86 CPU running NeXTSTEP + Copyright (C) 1993, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "i386/gas.h" +#include "nextstep.h" + +/* By default, target has a 80387, with IEEE FP. */ + +#undef TARGET_DEFAULT +#define TARGET_DEFAULT (1|0100) + +/* Implicit library calls should use memcpy, not bcopy, etc. */ + +#define TARGET_MEM_FUNCTIONS + +/* Machines that use the AT&T assembler syntax + also return floating point values in an FP register. + Define how to find the value returned by a function. + VALTYPE is the data type of the value (as a tree). + If the precise function being called is known, FUNC is its FUNCTION_DECL; + otherwise, FUNC is 0. */ + +#undef VALUE_REGNO +#define VALUE_REGNO(MODE) \ + ((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode \ + ? FIRST_FLOAT_REG : 0) + +/* 1 if N is a possible register number for a function value. */ + +#undef FUNCTION_VALUE_REGNO_P +#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N)== FIRST_FLOAT_REG) + +#ifdef REAL_VALUE_TO_TARGET_LONG_DOUBLE +#undef ASM_OUTPUT_LONG_DOUBLE +#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \ + do { \ + long hex[3]; \ + REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, hex); \ + if (sizeof (int) == sizeof (long)) \ + fprintf (FILE, "\t.long 0x%x\n\t.long 0x%x\n\t.long 0x%x\n", \ + hex[0], hex[1], hex[2]); \ + else \ + fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n\t.long 0x%lx\n", \ + hex[0], hex[1], hex[2]); \ + } while (0) +#endif + +#ifdef REAL_VALUE_TO_TARGET_DOUBLE +#undef ASM_OUTPUT_DOUBLE +#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ + do { \ + long hex[2]; \ + REAL_VALUE_TO_TARGET_DOUBLE (VALUE, hex); \ + if (sizeof (int) == sizeof (long)) \ + fprintf (FILE, "\t.long 0x%x\n\t.long 0x%x\n", hex[0], hex[1]); \ + else \ + fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n", hex[0], hex[1]); \ + } while (0) +#endif + +/* This is how to output an assembler line defining a `float' constant. */ + +#ifdef REAL_VALUE_TO_TARGET_SINGLE +#undef ASM_OUTPUT_FLOAT +#define ASM_OUTPUT_FLOAT(FILE,VALUE) \ + do { \ + long hex; \ + REAL_VALUE_TO_TARGET_SINGLE (VALUE, hex); \ + if (sizeof (int) == sizeof (long)) \ + fprintf (FILE, "\t.long 0x%x\n", hex); \ + else \ + fprintf (FILE, "\t.long 0x%lx\n", hex); \ + } while (0) +#endif + +/* A C statement or statements which output an assembler instruction + opcode to the stdio stream STREAM. The macro-operand PTR is a + variable of type `char *' which points to the opcode name in its + "internal" form--the form that is written in the machine description. + + GAS version 1.38.1 doesn't understand the `repz' opcode mnemonic. + So use `repe' instead. */ + +#undef ASM_OUTPUT_OPCODE +#define ASM_OUTPUT_OPCODE(STREAM, PTR) \ +{ \ + if ((PTR)[0] == 'r' \ + && (PTR)[1] == 'e' \ + && (PTR)[2] == 'p') \ + { \ + if ((PTR)[3] == 'z') \ + { \ + fprintf (STREAM, "repe"); \ + (PTR) += 4; \ + } \ + else if ((PTR)[3] == 'n' && (PTR)[4] == 'z') \ + { \ + fprintf (STREAM, "repne"); \ + (PTR) += 5; \ + } \ + } \ +} + +/* Define macro used to output shift-double opcodes when the shift + count is in %cl. Some assemblers require %cl as an argument; + some don't. + + GAS requires the %cl argument, so override unx386.h. */ + +#undef AS3_SHIFT_DOUBLE +#define AS3_SHIFT_DOUBLE(a,b,c,d) AS3 (a,b,c,d) + +/* Print opcodes the way that GAS expects them. */ +#define GAS_MNEMONICS 1 + +/* Names to predefine in the preprocessor for this target machine. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Di386 -DNeXT -Dunix -D__MACH__ -D__LITTLE_ENDIAN__ -D__ARCHITECTURE__=\"i386\" -Asystem(unix) -Asystem(mach) -Acpu(i386) -Amachine(i386)" + +/* This accounts for the return pc and saved fp on the i386. */ + +#define OBJC_FORWARDING_STACK_OFFSET 8 +#define OBJC_FORWARDING_MIN_OFFSET 8 + +/* We do not want a dot in internal labels. */ + +#undef LPREFIX +#define LPREFIX "L" + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), "*%s%d", (PREFIX), (NUMBER)) + +#undef ASM_OUTPUT_INTERNAL_LABEL +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + fprintf (FILE, "%s%d:\n", PREFIX, NUM) + +/* Output to assembler file text saying following lines + may contain character constants, extra white space, comments, etc. */ + +#undef ASM_APP_ON +#define ASM_APP_ON "#APP\n" + +/* Output to assembler file text saying following lines + no longer contain unusual constructs. */ + +#undef ASM_APP_OFF +#define ASM_APP_OFF "#NO_APP\n" + +#undef ASM_OUTPUT_REG_PUSH +#define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ + fprintf (FILE, "\tpushl %se%s\n", "%", reg_names[REGNO]) + +#undef ASM_OUTPUT_REG_POP +#define ASM_OUTPUT_REG_POP(FILE,REGNO) \ + fprintf (FILE, "\tpopl %se%s\n", "%", reg_names[REGNO]) + +/* This is being overridden because the default i386 configuration + generates calls to "_mcount". NeXT system libraries all use + "mcount". */ + +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ +{ \ + if (flag_pic) \ + { \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ + LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall mcount\n"); \ + } \ +} + +/* BEGIN Calling Convention CHANGES */ + +/* These changes violate the Intel/Unix ABI. Specifically, they + change the way that space for a block return value is passed to a + function. The ABI says that the pointer is passed on the stack. + We change to pass the pointer in %ebx. This makes the NeXT + Objective-C forwarding mechanism possible to implement on an i386. */ + +/* Do NOT pass address of structure values on the stack. */ + +#undef STRUCT_VALUE_INCOMING +#undef STRUCT_VALUE + +/* Pass them in %ebx. */ + +#undef STRUCT_VALUE_REGNUM +#define STRUCT_VALUE_REGNUM 3 + +/* Because we are passing the pointer in a register, we don't need to + rely on the callee to pop it. */ + +#undef RETURN_POPS_ARGS +#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ + (TREE_CODE (FUNTYPE) == IDENTIFIER_NODE \ + ? 0 \ + : (TARGET_RTD \ + && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ + || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ + == void_type_node))) ? (SIZE) : 0) + +/* END Calling Convention CHANGES */ diff --git a/support/cpp/i386/os2.h b/support/cpp/i386/os2.h new file mode 100644 index 00000000..8bbab361 --- /dev/null +++ b/support/cpp/i386/os2.h @@ -0,0 +1,76 @@ +/* Definitions of target machine for GNU compiler + for an Intel i386 or later processor running OS/2 2.x. + Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. + Contributed by Samuel Figueroa (figueroa@cs.nyu.edu) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef DEFAULT_TARGET_MACHINE +#define DEFAULT_TARGET_MACHINE "i386-os2" +#endif +#ifndef LINK_SPEC +#define LINK_SPEC "/st:1048576/pm:vio/noi/a:16/e/bas:65536/nol" +#endif +#ifndef LIB_SPEC +#define LIB_SPEC "libgcc libc" +#endif +#ifndef STARTFILE_SPEC +#define STARTFILE_SPEC "libcrt.lib" +#endif +#ifndef MD_EXEC_PREFIX +#define MD_EXEC_PREFIX "\\gcc\\bin\\" +#endif +#ifndef STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "\\gcc\\lib\\" +#endif +#ifndef LOCAL_INCLUDE_DIR +#define LOCAL_INCLUDE_DIR "\\gcc\\include" +#endif + +#define YES_UNDERSCORES +#include "i386/gstabs.h" + +#define USE_COLLECT + +#define BIGGEST_FIELD_ALIGNMENT \ + (maximum_field_alignment ? maximum_field_alignment : 32) + +extern int maximum_field_alignment; + +#undef PCC_BITFIELD_TYPE_MATTERS +#define PCC_BITFIELD_TYPE_MATTERS (maximum_field_alignment == 0) + +/* Define this macro if it is advisable to hold scalars in registers + in a wider mode than that declared by the program. In such cases, + the value is constrained to be within the bounds of the declared + type, but kept valid in the wider mode. The signedness of the + extension may differ from that of the type. */ + +#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \ + if (GET_MODE_CLASS (MODE) == MODE_INT \ + && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \ + (MODE) = SImode; + +/* Define this if function arguments should also be promoted using the above + procedure. */ + +#define PROMOTE_FUNCTION_ARGS + +/* Likewise, if the function return value is promoted. */ + +#define PROMOTE_FUNCTION_RETURN diff --git a/support/cpp/i386/osfelf.h b/support/cpp/i386/osfelf.h new file mode 100644 index 00000000..7e71fe98 --- /dev/null +++ b/support/cpp/i386/osfelf.h @@ -0,0 +1,79 @@ +/* Definitions of target machine for GNU compiler. + Intel 386 (OSF/1 with ELF) version. + Copyright (C) 1993 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "config/i386/osfrose.h" + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-DOSF -DOSF1 -Dunix -Di386 -Asystem(unix) -Asystem(xpg4) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#define CPP_SPEC "\ +%{mrose: -D__ROSE__ %{!pic-none: -D__SHARED__}} \ +%{!mrose: -D__ELF__ %{fpic: -D__SHARED__}} \ +%{mno-underscores: -D__NO_UNDERSCORES__} \ +%{!mrose: %{!munderscores: -D__NO_UNDERSCORES__}} \ +%{.S: %{!ansi:%{!traditional:%{!traditional-cpp:%{!ftraditional: -traditional}}}}} \ +%{.S: -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ +%{.cc: -D__LANGUAGE_C_PLUS_PLUS} \ +%{.cxx: -D__LANGUAGE_C_PLUS_PLUS} \ +%{.C: -D__LANGUAGE_C_PLUS_PLUS} \ +%{.m: -D__LANGUAGE_OBJECTIVE_C} \ +%{!.S: -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}" + +/* Turn on -pic-extern by default for OSF/rose, -fpic for ELF. */ +#undef CC1_SPEC +#define CC1_SPEC "\ +%{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \ +%{!melf: %{!mrose: -melf }} \ +%{!mrose: %{!munderscores: %{!mno-underscores: -mno-underscores }} \ + %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount-ptr }}}} \ +%{mrose: %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount }}} \ + %{pic-extern: -mhalf-pic } %{pic-lib: -mhalf-pic } \ + %{!pic-extern: %{!pic-lib: %{pic-none: -mno-half-pic} %{!pic-none: -mhalf-pic}}} \ + %{pic-calls: } %{pic-names*: }}" + +#undef ASM_SPEC +#define ASM_SPEC "%{v*: -v}" + +#undef LINK_SPEC +#define LINK_SPEC "%{v*: -v} \ +%{mrose: %{!noshrlib: %{pic-none: -noshrlib} %{!pic-none: -warn_nopic}} \ + %{nostdlib} %{noshrlib} %{glue}} \ +%{!mrose: %{dy} %{dn} %{glue: } \ + %{h*} %{z*} \ + %{static:-dn -Bstatic} \ + %{shared:-G -dy} \ + %{symbolic:-Bsymbolic -G -dy} \ + %{G:-G} \ + %{!dy: %{!dn: %{!static: %{!shared: %{!symbolic: \ + %{noshrlib: -dn } %{pic-none: -dn } \ + %{!noshrlib: %{!pic-none: -dy}}}}}}}}" + +#undef TARGET_VERSION_INTERNAL +#undef TARGET_VERSION + +#undef I386_VERSION +#define I386_VERSION " 80386, ELF objects" + +#define TARGET_VERSION_INTERNAL(STREAM) fputs (I386_VERSION, STREAM) +#define TARGET_VERSION TARGET_VERSION_INTERNAL (stderr) + +#undef OBJECT_FORMAT_ROSE diff --git a/support/cpp/i386/osfrose.h b/support/cpp/i386/osfrose.h new file mode 100644 index 00000000..3aae1e1b --- /dev/null +++ b/support/cpp/i386/osfrose.h @@ -0,0 +1,923 @@ +/* Definitions of target machine for GNU compiler. + Intel 386 (OSF/1 with OSF/rose) version. + Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "halfpic.h" +#include "i386/gstabs.h" + +/* Get perform_* macros to build libgcc.a. */ +#include "i386/perform.h" + +#define OSF_OS + +#undef WORD_SWITCH_TAKES_ARG +#define WORD_SWITCH_TAKES_ARG(STR) \ + (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) || !strcmp (STR, "pic-names")) + +/* This defines which switch letters take arguments. On svr4, most of + the normal cases (defined in gcc.c) apply, and we also have -h* and + -z* options (for the linker). */ + +#define SWITCH_TAKES_ARG(CHAR) \ + ( (CHAR) == 'D' \ + || (CHAR) == 'U' \ + || (CHAR) == 'o' \ + || (CHAR) == 'e' \ + || (CHAR) == 'T' \ + || (CHAR) == 'u' \ + || (CHAR) == 'I' \ + || (CHAR) == 'm' \ + || (CHAR) == 'L' \ + || (CHAR) == 'A' \ + || (CHAR) == 'h' \ + || (CHAR) == 'z') + +#define MASK_HALF_PIC 010000000000 /* Mask for half-pic code */ +#define MASK_HALF_PIC_DEBUG 004000000000 /* Debug flag */ +#define MASK_ELF 002000000000 /* ELF not rose */ +#define MASK_NO_IDENT 001000000000 /* suppress .ident */ +#define MASK_NO_UNDERSCORES 000400000000 /* suppress leading _ */ +#define MASK_LARGE_ALIGN 000200000000 /* align to >word boundaries */ +#define MASK_NO_MCOUNT 000100000000 /* profiling uses mcount_ptr */ + +#define TARGET_HALF_PIC (target_flags & MASK_HALF_PIC) +#define TARGET_DEBUG (target_flags & MASK_HALF_PIC_DEBUG) +#define HALF_PIC_DEBUG TARGET_DEBUG +#define TARGET_ELF (target_flags & MASK_ELF) +#define TARGET_ROSE ((target_flags & MASK_ELF) == 0) +#define TARGET_IDENT ((target_flags & MASK_NO_IDENT) == 0) +#define TARGET_UNDERSCORES ((target_flags & MASK_NO_UNDERSCORES) == 0) +#define TARGET_LARGE_ALIGN (target_flags & MASK_LARGE_ALIGN) +#define TARGET_MCOUNT ((target_flags & MASK_NO_MCOUNT) == 0) + +#undef SUBTARGET_SWITCHES +#define SUBTARGET_SWITCHES \ + { "half-pic", MASK_HALF_PIC}, \ + { "no-half-pic", -MASK_HALF_PIC}, \ + { "debug-half-pic", MASK_HALF_PIC_DEBUG}, \ + { "debugb", MASK_HALF_PIC_DEBUG}, \ + { "elf", MASK_ELF}, \ + { "rose", -MASK_ELF}, \ + { "ident", -MASK_NO_IDENT}, \ + { "no-ident", MASK_NO_IDENT}, \ + { "underscores", -MASK_NO_UNDERSCORES}, \ + { "no-underscores", MASK_NO_UNDERSCORES}, \ + { "large-align", MASK_LARGE_ALIGN}, \ + { "no-large-align", -MASK_LARGE_ALIGN}, \ + { "mcount", -MASK_NO_MCOUNT}, \ + { "mcount-ptr", MASK_NO_MCOUNT}, \ + { "no-mcount", MASK_NO_MCOUNT}, + +/* OSF/rose uses stabs, not dwarf. */ +#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG + +#ifndef DWARF_DEBUGGING_INFO +#define DWARF_DEBUGGING_INFO /* enable dwarf debugging for testing */ +#endif + +/* Handle #pragma weak and #pragma pack. */ + +#define HANDLE_SYSV_PRAGMA +#define SUPPORTS_WEAK TARGET_ELF + +/* Change default predefines. */ +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-DOSF -DOSF1 -Dunix -Di386 -Asystem(unix) -Asystem(xpg4) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#define CPP_SPEC "\ +%{!melf: -D__ROSE__ %{!pic-none: -D__SHARED__}} \ +%{melf: -D__ELF__ %{fpic: -D__SHARED__}} \ +%{mno-underscores: -D__NO_UNDERSCORES__} \ +%{melf: %{!munderscores: -D__NO_UNDERSCORES__}} \ +%{.S: %{!ansi:%{!traditional:%{!traditional-cpp:%{!ftraditional: -traditional}}}}} \ +%{.S: -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ +%{.cc: -D__LANGUAGE_C_PLUS_PLUS} \ +%{.cxx: -D__LANGUAGE_C_PLUS_PLUS} \ +%{.C: -D__LANGUAGE_C_PLUS_PLUS} \ +%{.m: -D__LANGUAGE_OBJECTIVE_C} \ +%{!.S: -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}" + +/* Turn on -pic-extern by default for OSF/rose, -fpic for ELF. */ +#undef CC1_SPEC +#define CC1_SPEC "\ +%{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \ +%{!melf: %{!mrose: -mrose }} \ +%{melf: %{!munderscores: %{!mno-underscores: -mno-underscores }} \ + %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount-ptr }}}} \ +%{!melf: %{!munderscores: %{!mno-underscores: -munderscores }} \ + %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount }}} \ + %{pic-extern: -mhalf-pic } %{pic-lib: -mhalf-pic } \ + %{!pic-extern: %{!pic-lib: %{pic-none: -mno-half-pic} %{!pic-none: -mhalf-pic}}} \ + %{pic-calls: } %{pic-names*: }}" + +#undef ASM_SPEC +#define ASM_SPEC "%{v*: -v}" + +#undef LINK_SPEC +#define LINK_SPEC "%{v*: -v} \ +%{!melf: %{!noshrlib: %{pic-none: -noshrlib} %{!pic-none: -warn_nopic}} \ + %{nostdlib} %{noshrlib} %{glue}} \ +%{melf: %{dy} %{dn} %{glue: } \ + %{h*} %{z*} \ + %{static:-dn -Bstatic} \ + %{shared:-G -dy} \ + %{symbolic:-Bsymbolic -G -dy} \ + %{G:-G} \ + %{!dy: %{!dn: %{!static: %{!shared: %{!symbolic: \ + %{noshrlib: -dn } %{pic-none: -dn } \ + %{!noshrlib: %{!pic-none: -dy}}}}}}}}" + +#undef LIB_SPEC +#define LIB_SPEC "-lc" + +#undef LIBG_SPEC +#define LIBG_SPEC "" + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}" + +#undef TARGET_VERSION_INTERNAL +#undef TARGET_VERSION + +#define I386_VERSION " 80386, OSF/rose objects" + +#define TARGET_VERSION_INTERNAL(STREAM) fputs (I386_VERSION, STREAM) +#define TARGET_VERSION TARGET_VERSION_INTERNAL (stderr) + +#undef MD_EXEC_PREFIX +#define MD_EXEC_PREFIX "/usr/ccs/gcc/" + +#undef MD_STARTFILE_PREFIX +#define MD_STARTFILE_PREFIX "/usr/ccs/lib/" + +/* Specify size_t, ptrdiff_t, and wchar_t types. */ +#undef SIZE_TYPE +#undef PTRDIFF_TYPE +#undef WCHAR_TYPE +#undef WCHAR_TYPE_SIZE + +#define SIZE_TYPE "long unsigned int" +#define PTRDIFF_TYPE "int" +#define WCHAR_TYPE "unsigned int" +#define WCHAR_TYPE_SIZE BITS_PER_WORD + +/* Define this macro if the system header files support C++ as well + as C. This macro inhibits the usual method of using system header + files in C++, which is to pretend that the file's contents are + enclosed in `extern "C" {...}'. */ +#define NO_IMPLICIT_EXTERN_C + +/* Turn off long double being 96 bits. */ +#undef LONG_DOUBLE_TYPE_SIZE +#define LONG_DOUBLE_TYPE_SIZE 64 + +/* This macro generates the assembly code for function entry. + FILE is a stdio stream to output the code to. + SIZE is an int: how many units of temporary storage to allocate. + Refer to the array `regs_ever_live' to determine which registers + to save; `regs_ever_live[I]' is nonzero if register number I + is ever used in the function. This macro is responsible for + knowing which registers should not be saved even if used. + + We override it here to allow for the new profiling code to go before + the prologue and the old mcount code to go after the prologue (and + after %ebx has been set up for ELF shared library support). */ + +#define OSF_PROFILE_BEFORE_PROLOGUE \ + (!TARGET_MCOUNT \ + && !current_function_needs_context \ + && (!flag_pic \ + || !frame_pointer_needed \ + || (!current_function_uses_pic_offset_table \ + && !current_function_uses_const_pool))) + +#undef FUNCTION_PROLOGUE +#define FUNCTION_PROLOGUE(FILE, SIZE) \ +do \ + { \ + char *prefix = (TARGET_UNDERSCORES) ? "_" : ""; \ + char *lprefix = LPREFIX; \ + int labelno = profile_label_no; \ + \ + if (profile_flag && OSF_PROFILE_BEFORE_PROLOGUE) \ + { \ + if (!flag_pic && !HALF_PIC_P ()) \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tcall *%s_mcount_ptr\n", prefix); \ + } \ + \ + else if (HALF_PIC_P ()) \ + { \ + rtx symref; \ + \ + HALF_PIC_EXTERNAL ("_mcount_ptr"); \ + symref = HALF_PIC_PTR (gen_rtx (SYMBOL_REF, Pmode, \ + "_mcount_ptr")); \ + \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tmovl %s%s,%%eax\n", prefix, \ + XSTR (symref, 0)); \ + fprintf (FILE, "\tcall *(%%eax)\n"); \ + } \ + \ + else \ + { \ + static int call_no = 0; \ + \ + fprintf (FILE, "\tcall %sPc%d\n", lprefix, call_no); \ + fprintf (FILE, "%sPc%d:\tpopl %%eax\n", lprefix, call_no); \ + fprintf (FILE, "\taddl $_GLOBAL_OFFSET_TABLE_+[.-%sPc%d],%%eax\n", \ + lprefix, call_no++); \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%eax),%%edx\n", \ + lprefix, labelno); \ + fprintf (FILE, "\tmovl %s_mcount_ptr@GOT(%%eax),%%eax\n", \ + prefix); \ + fprintf (FILE, "\tcall *(%%eax)\n"); \ + } \ + } \ + \ + function_prologue (FILE, SIZE); \ + } \ +while (0) + +/* A C statement or compound statement to output to FILE some assembler code to + call the profiling subroutine `mcount'. Before calling, the assembler code + must load the address of a counter variable into a register where `mcount' + expects to find the address. The name of this variable is `LP' followed by + the number LABELNO, so you would generate the name using `LP%d' in a + `fprintf'. + + The details of how the address should be passed to `mcount' are determined + by your operating system environment, not by GNU CC. To figure them out, + compile a small program for profiling using the system's installed C + compiler and look at the assembler code that results. */ + +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ +do \ + { \ + if (!OSF_PROFILE_BEFORE_PROLOGUE) \ + { \ + char *prefix = (TARGET_UNDERSCORES) ? "_" : ""; \ + char *lprefix = LPREFIX; \ + int labelno = LABELNO; \ + \ + /* Note that OSF/rose blew it in terms of calling mcount, \ + since OSF/rose prepends a leading underscore, but mcount's \ + doesn't. At present, we keep this kludge for ELF as well \ + to allow old kernels to build profiling. */ \ + \ + if (flag_pic \ + && !current_function_uses_pic_offset_table \ + && !current_function_uses_const_pool) \ + abort (); \ + \ + if (TARGET_MCOUNT && flag_pic) \ + { \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ + lprefix, labelno); \ + fprintf (FILE, "\tcall *%smcount@GOT(%%ebx)\n", prefix); \ + } \ + \ + else if (TARGET_MCOUNT && HALF_PIC_P ()) \ + { \ + rtx symdef; \ + \ + HALF_PIC_EXTERNAL ("mcount"); \ + symdef = HALF_PIC_PTR (gen_rtx (SYMBOL_REF, Pmode, "mcount")); \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tcall *%s%s\n", prefix, XSTR (symdef, 0)); \ + } \ + \ + else if (TARGET_MCOUNT) \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tcall %smcount\n", prefix); \ + } \ + \ + else if (flag_pic && frame_pointer_needed) \ + { \ + fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n"); \ + fprintf (FILE, "\tpushl %%ecx\n"); \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ + lprefix, labelno); \ + fprintf (FILE, "\tmovl _mcount_ptr@GOT(%%ebx),%%eax\n"); \ + fprintf (FILE, "\tcall *(%%eax)\n"); \ + fprintf (FILE, "\tpopl %%eax\n"); \ + } \ + \ + else if (frame_pointer_needed) \ + { \ + fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n"); \ + fprintf (FILE, "\tpushl %%ecx\n"); \ + fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ + fprintf (FILE, "\tcall *_mcount_ptr\n"); \ + fprintf (FILE, "\tpopl %%eax\n"); \ + } \ + \ + else \ + abort (); \ + } \ + } \ +while (0) + +/* A C function or functions which are needed in the library to + support block profiling. When support goes into libc, undo + the #if 0. */ + +#if 0 +#undef BLOCK_PROFILING_CODE +#define BLOCK_PROFILING_CODE +#endif + +/* Prefix for internally generated assembler labels. If we aren't using + underscores, we are using prefix `.'s to identify labels that should + be ignored, as in `i386/gas.h' --karl@cs.umb.edu */ +#undef LPREFIX +#define LPREFIX ((TARGET_UNDERSCORES) ? "L" : ".L") + +/* This is how to store into the string BUF + the symbol_ref name of an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. + This is suitable for output with `assemble_name'. */ + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), "*%s%s%d", (TARGET_UNDERSCORES) ? "" : ".", \ + (PREFIX), (NUMBER)) + +/* This is how to output an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. */ + +#undef ASM_OUTPUT_INTERNAL_LABEL +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + fprintf (FILE, "%s%s%d:\n", (TARGET_UNDERSCORES) ? "" : ".", \ + PREFIX, NUM) + +/* This is how to output a reference to a user-level label named NAME. */ + +#undef ASM_OUTPUT_LABELREF +#define ASM_OUTPUT_LABELREF(FILE,NAME) \ + fprintf (FILE, "%s%s", (TARGET_UNDERSCORES) ? "_" : "", NAME) + +/* This is how to output an element of a case-vector that is relative. + This is only used for PIC code. See comments by the `casesi' insn in + i386.md for an explanation of the expression this outputs. */ + +#undef ASM_OUTPUT_ADDR_DIFF_ELT +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ + fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) + +/* Output a definition */ +#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ +do \ +{ \ + fprintf ((FILE), "\t%s\t", SET_ASM_OP); \ + assemble_name (FILE, LABEL1); \ + fprintf (FILE, ","); \ + assemble_name (FILE, LABEL2); \ + fprintf (FILE, "\n"); \ + } \ +while (0) + +/* A C expression to output text to align the location counter in the + way that is desirable at a point in the code that is reached only + by jumping. + + This macro need not be defined if you don't want any special + alignment to be done at such a time. Most machine descriptions do + not currently define the macro. */ + +#undef ASM_OUTPUT_ALIGN_CODE +#define ASM_OUTPUT_ALIGN_CODE(STREAM) \ + fprintf (STREAM, "\t.align\t%d\n", \ + (!TARGET_LARGE_ALIGN && i386_align_jumps > 2) ? 2 : i386_align_jumps) + +/* A C expression to output text to align the location counter in the + way that is desirable at the beginning of a loop. + + This macro need not be defined if you don't want any special + alignment to be done at such a time. Most machine descriptions do + not currently define the macro. */ + +#undef ASM_OUTPUT_LOOP_ALIGN +#define ASM_OUTPUT_LOOP_ALIGN(STREAM) \ + fprintf (STREAM, "\t.align\t%d\n", i386_align_loops) + +/* A C statement to output to the stdio stream STREAM an assembler + command to advance the location counter to a multiple of 2 to the + POWER bytes. POWER will be a C expression of type `int'. */ + +#undef ASM_OUTPUT_ALIGN +#define ASM_OUTPUT_ALIGN(STREAM, POWER) \ + fprintf (STREAM, "\t.align\t%d\n", \ + (!TARGET_LARGE_ALIGN && (POWER) > 2) ? 2 : (POWER)) + +/* A C expression that is 1 if the RTX X is a constant which is a + valid address. On most machines, this can be defined as + `CONSTANT_P (X)', but a few machines are more restrictive in + which constant addresses are supported. + + `CONSTANT_P' accepts integer-values expressions whose values are + not explicitly known, such as `symbol_ref', `label_ref', and + `high' expressions and `const' arithmetic expressions, in + addition to `const_int' and `const_double' expressions. */ + +#define CONSTANT_ADDRESS_P_ORIG(X) \ + (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ + || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ + || GET_CODE (X) == HIGH) + +#undef CONSTANT_ADDRESS_P +#define CONSTANT_ADDRESS_P(X) \ + ((CONSTANT_ADDRESS_P_ORIG (X)) && (!HALF_PIC_P () || !HALF_PIC_ADDRESS_P (X))) + +/* Nonzero if the constant value X is a legitimate general operand. + It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ + +#undef LEGITIMATE_CONSTANT_P +#define LEGITIMATE_CONSTANT_P(X) \ + (!HALF_PIC_P () \ + || GET_CODE (X) == CONST_DOUBLE \ + || GET_CODE (X) == CONST_INT \ + || !HALF_PIC_ADDRESS_P (X)) + +/* Sometimes certain combinations of command options do not make sense + on a particular target machine. You can define a macro + `OVERRIDE_OPTIONS' to take account of this. This macro, if + defined, is executed once just after all the command options have + been parsed. */ + +#undef SUBTARGET_OVERRIDE_OPTIONS +#define SUBTARGET_OVERRIDE_OPTIONS \ +{ \ + /* \ + if (TARGET_ELF && TARGET_HALF_PIC) \ + { \ + target_flags &= ~MASK_HALF_PIC; \ + flag_pic = 1; \ + } \ + */ \ + \ + if (TARGET_ROSE && flag_pic) \ + { \ + target_flags |= MASK_HALF_PIC; \ + flag_pic = 0; \ + } \ + \ + if (TARGET_HALF_PIC) \ + half_pic_init (); \ +} + +/* Define this macro if references to a symbol must be treated + differently depending on something about the variable or + function named by the symbol (such as what section it is in). + + The macro definition, if any, is executed immediately after the + rtl for DECL has been created and stored in `DECL_RTL (DECL)'. + The value of the rtl will be a `mem' whose address is a + `symbol_ref'. + + The usual thing for this macro to do is to a flag in the + `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified + name string in the `symbol_ref' (if one bit is not enough + information). + + The best way to modify the name string is by adding text to the + beginning, with suitable punctuation to prevent any ambiguity. + Allocate the new name in `saveable_obstack'. You will have to + modify `ASM_OUTPUT_LABELREF' to remove and decode the added text + and output the name accordingly. + + You can also check the information stored in the `symbol_ref' in + the definition of `GO_IF_LEGITIMATE_ADDRESS' or + `PRINT_OPERAND_ADDRESS'. */ + +#undef ENCODE_SECTION_INFO +#define ENCODE_SECTION_INFO(DECL) \ +do \ + { \ + if (HALF_PIC_P ()) \ + HALF_PIC_ENCODE (DECL); \ + \ + else if (flag_pic) \ + { \ + rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \ + SYMBOL_REF_FLAG (XEXP (rtl, 0)) \ + = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + || ! TREE_PUBLIC (DECL)); \ + } \ + } \ +while (0) + + +/* On most machines, read-only variables, constants, and jump tables + are placed in the text section. If this is not the case on your + machine, this macro should be defined to be the name of a function + (either `data_section' or a function defined in `EXTRA_SECTIONS') + that switches to the section to be used for read-only items. + + If these items should be placed in the text section, this macro + should not be defined. */ + +#if 0 +#undef READONLY_DATA_SECTION +#define READONLY_DATA_SECTION() \ +do \ + { \ + if (TARGET_ELF) \ + { \ + if (in_section != in_rodata) \ + { \ + fprintf (asm_out_file, "\t.section \"rodata\"\n"); \ + in_section = in_rodata; \ + } \ + } \ + else \ + text_section (); \ + } \ +while (0) +#endif + +/* A list of names for sections other than the standard two, which are + `in_text' and `in_data'. You need not define this macro on a + system with no other sections (that GCC needs to use). */ + +#undef EXTRA_SECTIONS +#define EXTRA_SECTIONS in_rodata, in_data1 + +/* Given a decl node or constant node, choose the section to output it in + and select that section. */ + +#undef SELECT_RTX_SECTION +#define SELECT_RTX_SECTION(MODE, RTX) \ +do \ + { \ + if (MODE == Pmode && HALF_PIC_P () && HALF_PIC_ADDRESS_P (RTX)) \ + data_section (); \ + else \ + readonly_data_section (); \ + } \ +while (0) + +#undef SELECT_SECTION +#define SELECT_SECTION(DECL, RELOC) \ +{ \ + if (RELOC && HALF_PIC_P ()) \ + data_section (); \ + \ + else if (TREE_CODE (DECL) == STRING_CST) \ + { \ + if (flag_writable_strings) \ + data_section (); \ + else \ + readonly_data_section (); \ + } \ + \ + else if (TREE_CODE (DECL) != VAR_DECL) \ + readonly_data_section (); \ + \ + else if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ + || !DECL_INITIAL (DECL) \ + || (DECL_INITIAL (DECL) != error_mark_node \ + && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ + data_section (); \ + \ + else \ + readonly_data_section (); \ +} + + +/* Define the strings used for the special svr4 .type and .size directives. + These strings generally do not vary from one system running svr4 to + another, but if a given system (e.g. m88k running svr) needs to use + different pseudo-op names for these, they may be overridden in the + file which includes this one. */ + +#define TYPE_ASM_OP ".type" +#define SIZE_ASM_OP ".size" +#define SET_ASM_OP ".set" + +/* This is how we tell the assembler that a symbol is weak. */ + +#define ASM_WEAKEN_LABEL(FILE,NAME) \ + do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ + fputc ('\n', FILE); } while (0) + +/* The following macro defines the format used to output the second + operand of the .type assembler directive. Different svr4 assemblers + expect various different forms for this operand. The one given here + is just a default. You may need to override it in your machine- + specific tm.h file (depending upon the particulars of your assembler). */ + +#define TYPE_OPERAND_FMT "@%s" + +/* A C statement (sans semicolon) to output to the stdio stream + STREAM any text necessary for declaring the name NAME of an + initialized variable which is being defined. This macro must + output the label definition (perhaps using `ASM_OUTPUT_LABEL'). + The argument DECL is the `VAR_DECL' tree node representing the + variable. + + If this macro is not defined, then the variable name is defined + in the usual manner as a label (by means of `ASM_OUTPUT_LABEL'). */ + +#undef ASM_DECLARE_OBJECT_NAME +#define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \ +do \ + { \ + ASM_OUTPUT_LABEL(STREAM,NAME); \ + HALF_PIC_DECLARE (NAME); \ + if (TARGET_ELF) \ + { \ + fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP); \ + assemble_name (STREAM, NAME); \ + putc (',', STREAM); \ + fprintf (STREAM, TYPE_OPERAND_FMT, "object"); \ + putc ('\n', STREAM); \ + size_directive_output = 0; \ + if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ + { \ + size_directive_output = 1; \ + fprintf (STREAM, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (STREAM, NAME); \ + fprintf (STREAM, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ + } \ + } \ + } \ +while (0) + +/* Output the size directive for a decl in rest_of_decl_compilation + in the case where we did not do so before the initializer. + Once we find the error_mark_node, we know that the value of + size_directive_output was set + by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ + +#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ +do { \ + char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ + if (TARGET_ELF \ + && !flag_inhibit_size_directive && DECL_SIZE (DECL) \ + && ! AT_END && TOP_LEVEL \ + && DECL_INITIAL (DECL) == error_mark_node \ + && !size_directive_output) \ + { \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, name); \ + fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ + } \ + } while (0) + +/* This is how to declare a function name. */ + +#undef ASM_DECLARE_FUNCTION_NAME +#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \ +do \ + { \ + ASM_OUTPUT_LABEL(STREAM,NAME); \ + HALF_PIC_DECLARE (NAME); \ + if (TARGET_ELF) \ + { \ + fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP); \ + assemble_name (STREAM, NAME); \ + putc (',', STREAM); \ + fprintf (STREAM, TYPE_OPERAND_FMT, "function"); \ + putc ('\n', STREAM); \ + ASM_DECLARE_RESULT (STREAM, DECL_RESULT (DECL)); \ + } \ + } \ +while (0) + +/* Write the extra assembler code needed to declare a function's result. + Most svr4 assemblers don't require any special declaration of the + result value, but there are exceptions. */ + +#ifndef ASM_DECLARE_RESULT +#define ASM_DECLARE_RESULT(FILE, RESULT) +#endif + +/* This is how to declare the size of a function. */ + +#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ +do \ + { \ + if (TARGET_ELF && !flag_inhibit_size_directive) \ + { \ + char label[256]; \ + static int labelno; \ + labelno++; \ + ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \ + ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, (FNAME)); \ + fprintf (FILE, ","); \ + assemble_name (FILE, label); \ + fprintf (FILE, "-"); \ + assemble_name (FILE, (FNAME)); \ + putc ('\n', FILE); \ + } \ + } \ +while (0) + +/* Attach a special .ident directive to the end of the file to identify + the version of GCC which compiled this code. The format of the + .ident string is patterned after the ones produced by native svr4 + C compilers. */ + +#define IDENT_ASM_OP ".ident" + +/* Allow #sccs in preprocessor. */ + +#define SCCS_DIRECTIVE + +/* This says what to print at the end of the assembly file */ +#define ASM_FILE_END(STREAM) \ +do \ + { \ + if (HALF_PIC_P ()) \ + HALF_PIC_FINISH (STREAM); \ + \ + if (TARGET_IDENT) \ + { \ + char *fstart = main_input_filename; \ + char *fname; \ + \ + if (!fstart) \ + fstart = ""; \ + \ + fname = fstart + strlen (fstart) - 1; \ + while (fname > fstart && *fname != '/') \ + fname--; \ + \ + if (*fname == '/') \ + fname++; \ + \ + fprintf ((STREAM), "\t%s\t\"GCC: (GNU) %s %s -O%d", \ + IDENT_ASM_OP, version_string, fname, optimize); \ + \ + if (write_symbols == PREFERRED_DEBUGGING_TYPE) \ + fprintf ((STREAM), " -g%d", (int)debug_info_level); \ + \ + else if (write_symbols == DBX_DEBUG) \ + fprintf ((STREAM), " -gstabs%d", (int)debug_info_level); \ + \ + else if (write_symbols == DWARF_DEBUG) \ + fprintf ((STREAM), " -gdwarf%d", (int)debug_info_level); \ + \ + else if (write_symbols != NO_DEBUG) \ + fprintf ((STREAM), " -g??%d", (int)debug_info_level); \ + \ + if (flag_omit_frame_pointer) \ + fprintf ((STREAM), " -fomit-frame-pointer"); \ + \ + if (flag_strength_reduce) \ + fprintf ((STREAM), " -fstrength-reduce"); \ + \ + if (flag_unroll_loops) \ + fprintf ((STREAM), " -funroll-loops"); \ + \ + if (flag_schedule_insns) \ + fprintf ((STREAM), " -fschedule-insns"); \ + \ + if (flag_schedule_insns_after_reload) \ + fprintf ((STREAM), " -fschedule-insns2"); \ + \ + if (flag_force_mem) \ + fprintf ((STREAM), " -fforce-mem"); \ + \ + if (flag_force_addr) \ + fprintf ((STREAM), " -fforce-addr"); \ + \ + if (flag_inline_functions) \ + fprintf ((STREAM), " -finline-functions"); \ + \ + if (flag_caller_saves) \ + fprintf ((STREAM), " -fcaller-saves"); \ + \ + if (flag_pic) \ + fprintf ((STREAM), (flag_pic > 1) ? " -fPIC" : " -fpic"); \ + \ + if (flag_inhibit_size_directive) \ + fprintf ((STREAM), " -finhibit-size-directive"); \ + \ + if (flag_gnu_linker) \ + fprintf ((STREAM), " -fgnu-linker"); \ + \ + if (profile_flag) \ + fprintf ((STREAM), " -p"); \ + \ + if (profile_block_flag) \ + fprintf ((STREAM), " -a"); \ + \ + if (TARGET_IEEE_FP) \ + fprintf ((STREAM), " -mieee-fp"); \ + \ + if (TARGET_HALF_PIC) \ + fprintf ((STREAM), " -mhalf-pic"); \ + \ + if (!TARGET_MOVE) \ + fprintf ((STREAM), " -mno-move"); \ + \ + if (TARGET_386) \ + fprintf ((STREAM), " -m386"); \ + \ + else if (TARGET_486) \ + fprintf ((STREAM), " -m486"); \ + \ + else \ + fprintf ((STREAM), " -munknown-machine"); \ + \ + fprintf ((STREAM), (TARGET_ELF) ? " -melf\"\n" : " -mrose\"\n"); \ + } \ + } \ +while (0) + +/* Tell collect that the object format is OSF/rose. */ +#define OBJECT_FORMAT_ROSE + +/* Tell collect where the appropriate binaries are. */ +#define REAL_NM_FILE_NAME "/usr/ccs/gcc/bfd-nm" +#define REAL_STRIP_FILE_NAME "/usr/ccs/bin/strip" + +/* Use atexit for static constructors/destructors, instead of defining + our own exit function. */ +#define HAVE_ATEXIT + +/* Define this macro meaning that gcc should find the library 'libgcc.a' + by hand, rather than passing the argument '-lgcc' to tell the linker + to do the search */ +#define LINK_LIBGCC_SPECIAL + +/* A C statement to output assembler commands which will identify the object + file as having been compile with GNU CC. We don't need or want this for + OSF1. GDB doesn't need it and kdb doesn't like it */ +#define ASM_IDENTIFY_GCC(FILE) + +/* Identify the front-end which produced this file. To keep symbol + space down, and not confuse kdb, only do this if the language is + not C. */ + +#define ASM_IDENTIFY_LANGUAGE(STREAM) \ +{ \ + if (strcmp (lang_identify (), "c") != 0) \ + output_lang_identify (STREAM); \ +} + +/* Generate calls to memcpy, etc., not bcopy, etc. */ +#define TARGET_MEM_FUNCTIONS + +/* Don't default to pcc-struct-return, because gcc is the only compiler, and + we want to retain compatibility with older gcc versions. */ +#define DEFAULT_PCC_STRUCT_RETURN 0 + +/* Map i386 registers to the numbers dwarf expects. Of course this is different + from what stabs expects. */ + +#define DWARF_DBX_REGISTER_NUMBER(n) \ +((n) == 0 ? 0 \ + : (n) == 1 ? 2 \ + : (n) == 2 ? 1 \ + : (n) == 3 ? 3 \ + : (n) == 4 ? 6 \ + : (n) == 5 ? 7 \ + : (n) == 6 ? 5 \ + : (n) == 7 ? 4 \ + : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ + : (-1)) + +/* Now what stabs expects in the register. */ +#define STABS_DBX_REGISTER_NUMBER(n) \ +((n) == 0 ? 0 : \ + (n) == 1 ? 2 : \ + (n) == 2 ? 1 : \ + (n) == 3 ? 3 : \ + (n) == 4 ? 6 : \ + (n) == 5 ? 7 : \ + (n) == 6 ? 4 : \ + (n) == 7 ? 5 : \ + (n) + 4) + +#undef DBX_REGISTER_NUMBER +#define DBX_REGISTER_NUMBER(n) ((write_symbols == DWARF_DEBUG) \ + ? DWARF_DBX_REGISTER_NUMBER(n) \ + : STABS_DBX_REGISTER_NUMBER(n)) diff --git a/support/cpp/i386/perform.h b/support/cpp/i386/perform.h new file mode 100644 index 00000000..8d6d0b71 --- /dev/null +++ b/support/cpp/i386/perform.h @@ -0,0 +1,98 @@ +/* Definitions for AT&T assembler syntax for the Intel 80386. + Copyright (C) 1993 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Defines to be able to build libgcc.a with GCC. */ + +/* It might seem that these are not important, since gcc 2 will never + call libgcc for these functions. But programs might be linked with + code compiled by gcc 1, and then these will be used. */ + +/* The arg names used to be a and b, but `a' appears inside strings + and that confuses non-ANSI cpp. */ + +#define perform_udivsi3(arg0,arg1) \ +{ \ + register int dx asm("dx"); \ + register int ax asm("ax"); \ + \ + dx = 0; \ + ax = arg0; \ + asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1), "d" (dx)); \ + return ax; \ +} + +#define perform_divsi3(arg0,arg1) \ +{ \ + register int dx asm("dx"); \ + register int ax asm("ax"); \ + register int cx asm("cx"); \ + \ + ax = arg0; \ + cx = arg1; \ + asm ("cltd\n\tidivl %3" : "=a" (ax), "=&d" (dx) : "a" (ax), "c" (cx)); \ + return ax; \ +} + +#define perform_umodsi3(arg0,arg1) \ +{ \ + register int dx asm("dx"); \ + register int ax asm("ax"); \ + \ + dx = 0; \ + ax = arg0; \ + asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1), "d" (dx)); \ + return dx; \ +} + +#define perform_modsi3(arg0,arg1) \ +{ \ + register int dx asm("dx"); \ + register int ax asm("ax"); \ + register int cx asm("cx"); \ + \ + ax = arg0; \ + cx = arg1; \ + asm ("cltd\n\tidivl %3" : "=a" (ax), "=&d" (dx) : "a" (ax), "c" (cx)); \ + return dx; \ +} + +#define perform_fixdfsi(arg0) \ +{ \ + auto unsigned short ostatus; \ + auto unsigned short nstatus; \ + auto int ret; \ + auto double tmp; \ + \ + &ostatus; /* guarantee these land in memory */ \ + &nstatus; \ + &ret; \ + &tmp; \ + \ + asm volatile ("fnstcw %0" : "=m" (ostatus)); \ + nstatus = ostatus | 0x0c00; \ + asm volatile ("fldcw %0" : /* no outputs */ : "m" (nstatus)); \ + tmp = arg0; \ + asm volatile ("fldl %0" : /* no outputs */ : "m" (tmp)); \ + asm volatile ("fistpl %0" : "=m" (ret)); \ + asm volatile ("fldcw %0" : /* no outputs */ : "m" (ostatus)); \ + \ + return ret; \ +} + diff --git a/support/cpp/i386/sco.h b/support/cpp/i386/sco.h new file mode 100644 index 00000000..37dc0326 --- /dev/null +++ b/support/cpp/i386/sco.h @@ -0,0 +1,117 @@ +/* Definitions for Intel 386 running SCO Unix System V. + Copyright (C) 1988, 1992, 1994, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Mostly it's like AT&T Unix System V. */ + +#include "i386/sysv3.h" + +/* By default, target has a 80387, uses IEEE compatible arithmetic, + and returns float values in the 387, ie, + (TARGET_80387 | TARGET_FLOAT_RETURNS_IN_80387) + + SCO's software emulation of a 387 fails to handle the `fucomp' + opcode. fucomp is only used when generating IEEE compliant code. + So don't make TARGET_IEEE_FP default for SCO. */ + +#undef TARGET_DEFAULT +#define TARGET_DEFAULT 0201 + +/* Let's guess that the SCO software FPU emulator can't handle + 80-bit XFmode insns, so don't generate them. */ +#undef LONG_DOUBLE_TYPE_SIZE +#define LONG_DOUBLE_TYPE_SIZE 64 + +/* Use crt1.o as a startup file and crtn.o as a closing file. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} crtbegin.o%s" + +#define ENDFILE_SPEC "crtend.o%s crtn.o%s" + +/* Library spec, including SCO international language support. */ + +#undef LIB_SPEC +#define LIB_SPEC \ + "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} %{scointl:libintl.a%s} -lc" + +/* Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -DM_UNIX -DM_I386 -DM_COFF -DM_WORDSWAP -Asystem(unix) -Asystem(svr3) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#define CPP_SPEC "%{scointl:-DM_INTERNAT}" + +/* This spec is used for telling cpp whether char is signed or not. */ + +#undef SIGNED_CHAR_SPEC +#if DEFAULT_SIGNED_CHAR +#define SIGNED_CHAR_SPEC \ + "%{funsigned-char:-D__CHAR_UNSIGNED__ -D_CHAR_UNSIGNED}" +#else +#define SIGNED_CHAR_SPEC \ + "%{!fsigned-char:-D__CHAR_UNSIGNED__ -D_CHAR_UNSIGNED}" +#endif + +/* Use atexit for static destructors, instead of defining + our own exit function. */ +#define HAVE_ATEXIT + +/* Specify the size_t type. */ +#define SIZE_TYPE "unsigned int" + +#if 0 /* Not yet certain whether this is needed. */ +/* If no 387, use the general regs to return floating values, + since this system does not emulate the 80387. */ + +#undef VALUE_REGNO +#define VALUE_REGNO(MODE) \ + ((TARGET_80387 + && ((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode) + ? FIRST_FLOAT_REG : 0) + +#undef HARD_REGNO_MODE_OK +#define HARD_REGNO_MODE_OK(REGNO, MODE) \ + ((REGNO) < 2 ? 1 \ + : (REGNO) < 4 ? 1 \ + : FP_REGNO_P (REGNO) ? ((GET_MODE_CLASS (MODE) == MODE_FLOAT \ + || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \ + && TARGET_80387 \ + && GET_MODE_UNIT_SIZE (MODE) <= 8) \ + : (MODE) != QImode) +#endif + +/* caller has to pop the extra argument passed to functions that return + structures. */ + +#undef RETURN_POPS_ARGS +#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ + (TREE_CODE (FUNTYPE) == IDENTIFIER_NODE ? 0 \ + : (TARGET_RTD \ + && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ + || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ + == void_type_node))) ? (SIZE) \ + : 0) +/* On other 386 systems, the last line looks like this: + : (aggregate_value_p (TREE_TYPE (FUNTYPE))) ? GET_MODE_SIZE (Pmode) : 0) */ + +/* Handle #pragma pack. */ +#define HANDLE_SYSV_PRAGMA diff --git a/support/cpp/i386/sco4.h b/support/cpp/i386/sco4.h new file mode 100644 index 00000000..fc389b4d --- /dev/null +++ b/support/cpp/i386/sco4.h @@ -0,0 +1,86 @@ +/* Definitions for Intel 386 running SCO Unix System V 3.2 Version 4. + Written by Chip Salzenberg. + Copyright (C) 1992, 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* Mostly it's like earlier SCO UNIX. */ + +#include "i386/sco.h" + +/* Use crt1.o as a startup file and crtn.o as a closing file. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{scoxpg3:%{p:mcrt1X.o%s}%{!p:crt1X.o%s}} \ + %{!scoxpg3:\ + %{posix:%{p:mcrt1P.o%s}%{!p:crt1P.o%s}} \ + %{!posix:\ + %{ansi:%{p:mcrt1A.o%s}%{!p:crt1A.o%s}} \ + %{!ansi:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}}} \ + crtbegin.o%s" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + "crtend.o%s \ + %{scoxpg3:crtnX.o%s} \ + %{!scoxpg3:\ + %{posix:crtnP.o%s} \ + %{!posix:\ + %{ansi:crtnA.o%s} \ + %{!ansi:crtn.o%s}}}" + +/* Library spec. */ + +#undef LIB_SPEC +#define LIB_SPEC \ + "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} \ + %{scoxpg3:-lcX -lcP -lcA} \ + %{!scoxpg3:\ + %{posix:-lcP -lcA} \ + %{!posix:\ + %{ansi:-lcA} \ + %{!ansi:%{scointl:-lintl} -lc}}}" + +/* Macros, macros everywhere: + Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES \ + "-Asystem(unix) -Asystem(svr3) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#define CPP_SPEC \ + "-D_i386 -D_M_I386 -D_M_I86 -D_M_I86SM -D_M_SDATA -D_M_STEXT \ + -D_unix -D_M_UNIX -D_M_XENIX \ + -D_M_SYS5 -D_M_SYSV -D_M_SYS3 -D_M_SYSIII \ + -D_M_COFF -D_M_BITFIELDS -D_M_WORDSWAP \ + %{scoxpg3:-D_XOPEN_SOURCE -D_STRICT_NAMES} \ + %{!scoxpg3:%{posix:-D_POSIX_SOURCE -D_STRICT_NAMES}} \ + %{!scoxpg3:%{!posix:\ + %{ansi:-D_STRICT_NAMES}%{!ansi:\ + -Di386 -DM_I386 -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT \ + -Dunix -DM_UNIX -DM_XENIX \ + -DM_SYS5 -DM_SYSV -DM_SYS3 -DM_SYSIII \ + -DM_COFF -DM_BITFIELDS -DM_WORDSWAP \ + %{scointl:-D_M_INTERNAT -DM_INTERNAT} \ + %{traditional:-D_KR -D_SVID -D_NO_PROTOTYPE}}}}" + +/* The system headers are C++-aware. */ +#define NO_IMPLICIT_EXTERN_C diff --git a/support/cpp/i386/sco4dbx.h b/support/cpp/i386/sco4dbx.h new file mode 100644 index 00000000..0387c243 --- /dev/null +++ b/support/cpp/i386/sco4dbx.h @@ -0,0 +1,81 @@ +/* Definitions for Intel 386 running SCO Unix System V 3.2 Version 4.s, + using dbx-in-coff encapsulation. + Copyright (C) 1992 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* Mostly it's like earlier SCO UNIX. */ + +#include "i386/scodbx.h" + +/* Use crt1.o as a startup file and crtn.o as a closing file. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!r:%{!z:gcc.ifile%s}%{z:gccz.ifile%s}}\ + %{scoxpg3:%{p:mcrt1X.o%s}%{!p:crt1X.o%s}} \ + %{!scoxpg3:\ + %{posix:%{p:mcrt1P.o%s}%{!p:crt1P.o%s}} \ + %{!posix:\ + %{ansi:%{p:mcrt1A.o%s}%{!p:crt1A.o%s}} \ + %{!ansi:%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}}}" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + "%{scoxpg3:crtnX.o%s} \ + %{!scoxpg3:\ + %{posix:crtnP.o%s} \ + %{!posix:\ + %{ansi:crtnA.o%s} \ + %{!ansi:crtn.o%s}}}" + +/* Library spec. */ + +#undef LIB_SPEC +#define LIB_SPEC \ + "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} \ + %{scoxpg3:-lcX -lcP -lcA} \ + %{!scoxpg3:\ + %{posix:-lcP -lcA} \ + %{!posix:\ + %{ansi:-lcA} \ + %{!ansi:%{scointl:-lintl} -lc}}}" + +/* Macros, macros everywhere: + Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Di386 -Dunix -Asystem(unix) -Asystem(svr3) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#define CPP_SPEC \ + "-D_M_I386 -D_M_I86 -D_M_I86SM -D_M_SDATA -D_M_STEXT \ + -D_M_UNIX -D_M_XENIX \ + -D_M_SYS5 -D_M_SYSV -D_M_SYS3 -D_M_SYSIII \ + -D_M_COFF -D_M_BITFIELDS -D_M_WORDSWAP \ + %{scoxpg3:-D_XOPEN_SOURCE -D_STRICT_NAMES} \ + %{!scoxpg3:%{posix:-D_POSIX_SOURCE -D_STRICT_NAMES}} \ + %{!scoxpg3:%{!posix:\ + %{ansi:-D_STRICT_NAMES}%{!ansi:\ + -DM_I386 -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT \ + -DM_UNIX -DM_XENIX \ + -DM_SYS5 -DM_SYSV -DM_SYS3 -DM_SYSIII \ + -DM_COFF -DM_BITFIELDS -DM_WORDSWAP \ + %{scointl:-D_M_INTERNAT -DM_INTERNAT} \ + %{traditional:-D_KR -D_SVID -D_NO_PROTOTYPE}}}}" diff --git a/support/cpp/i386/scodbx.h b/support/cpp/i386/scodbx.h new file mode 100644 index 00000000..1309735c --- /dev/null +++ b/support/cpp/i386/scodbx.h @@ -0,0 +1,92 @@ +/* Definitions for Intel 386 running SCO Unix System V, + using dbx-in-coff encapsulation. + Copyright (C) 1992, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "i386/svr3dbx.h" + +/* Overridden defines for SCO systems from sco.h. */ + +/* By default, target has a 80387, uses IEEE compatible arithmetic, + and returns float values in the 387, ie, + (TARGET_80387 | TARGET_FLOAT_RETURNS_IN_80387) + + SCO's software emulation of a 387 fails to handle the `fucomp' + opcode. fucomp is only used when generating IEEE compliant code. + So don't make TARGET_IEEE_FP default for SCO. */ + +#undef TARGET_DEFAULT +#define TARGET_DEFAULT 0201 + +/* Use crt1.o as a startup file and crtn.o as a closing file. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!r:%{!z:svr3.ifile%s}%{z:svr3z.ifile%s}}\ + %{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}" + +/* Library spec, including SCO international language support. */ + +#undef LIB_SPEC +#define LIB_SPEC \ + "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} %{scointl:libintl.a%s} -lc" + +/* Specify predefined symbols in preprocessor. */ + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -DM_UNIX -DM_I386 -DM_COFF -DM_WORDSWAP -Asystem(unix) -Asystem(svr3) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#define CPP_SPEC "%{scointl:-DM_INTERNAT}" + +/* This spec is used for telling cpp whether char is signed or not. */ + +#undef SIGNED_CHAR_SPEC +#if DEFAULT_SIGNED_CHAR +#define SIGNED_CHAR_SPEC \ + "%{funsigned-char:-D__CHAR_UNSIGNED__ -D_CHAR_UNSIGNED}" +#else +#define SIGNED_CHAR_SPEC \ + "%{!fsigned-char:-D__CHAR_UNSIGNED__ -D_CHAR_UNSIGNED}" +#endif + +/* Use atexit for static destructors, instead of defining + our own exit function. */ +#define HAVE_ATEXIT + +/* caller has to pop the extra argument passed to functions that return + structures. */ + +#undef RETURN_POPS_ARGS +#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ + (TREE_CODE (FUNTYPE) == IDENTIFIER_NODE ? 0 \ + : (TARGET_RTD \ + && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ + || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ + == void_type_node))) ? (SIZE) \ + : 0) +/* On other 386 systems, the last line looks like this: + : (aggregate_value_p (TREE_TYPE (FUNTYPE))) ? GET_MODE_SIZE (Pmode) : 0) */ + +/* Use periods rather than dollar signs in special g++ assembler names. */ + +#define NO_DOLLAR_IN_LABEL + +/* Handle #pragma pack. */ +#define HANDLE_SYSV_PRAGMA diff --git a/support/cpp/i386/seq-gas.h b/support/cpp/i386/seq-gas.h new file mode 100644 index 00000000..2ee07192 --- /dev/null +++ b/support/cpp/i386/seq-gas.h @@ -0,0 +1,46 @@ +/* Definitions for Sequent Intel 386 using GAS. + Copyright (C) 1992 Free Software Foundation, Inc. + +/* Mostly it's like a Sequent 386 without GAS. */ + +#include "i386/sequent.h" + +/* A C statement or statements which output an assembler instruction + opcode to the stdio stream STREAM. The macro-operand PTR is a + variable of type `char *' which points to the opcode name in its + "internal" form--the form that is written in the machine description. + + GAS version 1.38.1 doesn't understand the `repz' opcode mnemonic. + So use `repe' instead. */ + +#undef ASM_OUTPUT_OPCODE +#define ASM_OUTPUT_OPCODE(STREAM, PTR) \ +{ \ + if ((PTR)[0] == 'r' \ + && (PTR)[1] == 'e' \ + && (PTR)[2] == 'p') \ + { \ + if ((PTR)[3] == 'z') \ + { \ + fprintf (STREAM, "repe"); \ + (PTR) += 4; \ + } \ + else if ((PTR)[3] == 'n' && (PTR)[4] == 'z') \ + { \ + fprintf (STREAM, "repne"); \ + (PTR) += 5; \ + } \ + } \ +} + +/* Define macro used to output shift-double opcodes when the shift + count is in %cl. Some assemblers require %cl as an argument; + some don't. + + GAS requires the %cl argument, so override i386/unix.h. */ + +#undef AS3_SHIFT_DOUBLE +#define AS3_SHIFT_DOUBLE(a,b,c,d) AS3 (a,b,c,d) + +/* Print opcodes the way that GAS expects them. */ +#define GAS_MNEMONICS 1 diff --git a/support/cpp/i386/seq-sysv3.h b/support/cpp/i386/seq-sysv3.h new file mode 100644 index 00000000..e3182ee1 --- /dev/null +++ b/support/cpp/i386/seq-sysv3.h @@ -0,0 +1,56 @@ +/* Sequent DYNIX/ptx 1.x (SVr3) */ + +#include "i386/sysv3.h" + +/* Sequent Symmetry SVr3 doesn't have crtn.o; crt1.o doesn't work + but crt0.o does. */ + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ +"%{pg:gcrt0.o%s}\ + %{!pg:%{posix:%{p:mcrtp0.o%s}%{!p:crtp0.o%s}}\ + %{!posix:%{p:mcrt0.o%s}%{!p:crt0.o%s}}} crtbegin.o%s\ + %{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp}" + +#undef LIB_SPEC +#define LIB_SPEC \ +"%{posix:-lcposix}\ + %{shlib:-lc_s}\ + %{fshared-data:-lpps -lseq} -lc crtend.o%s" + +#undef CPP_SPEC +#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} -D_SEQUENT_=1" + +/* Although the .init section is used, it is not automatically invoked. + This because the _start() function in /lib/crt0.o never calls anything + from the .init section */ +#define INVOKE__main + +/* Assembler pseudo-op for initialized shared variables (.shdata). */ +#undef SHARED_SECTION_ASM_OP +#define SHARED_SECTION_ASM_OP ".section .shdata, \"ws\"" + +/* Assembler pseudo-op for uninitialized shared global variables (.shbss). */ +#undef ASM_OUTPUT_SHARED_COMMON +#define ASM_OUTPUT_SHARED_COMMON(FILE, NAME, SIZE, ROUNDED) \ +( fputs(".comm ", (FILE)), \ + assemble_name((FILE), (NAME)), \ + fprintf((FILE), ",%u,-3\n", (SIZE))) + +/* Assembler pseudo-op for uninitialized shared local variables (.shbss). */ +#undef SHARED_BSS_SECTION_ASM_OP +#define SHARED_BSS_SECTION_ASM_OP ".section .shbss, \"bs\"" +#undef BSS_SECTION_FUNCTION +#define BSS_SECTION_FUNCTION \ +void \ +bss_section () \ +{ \ + if (in_section != in_bss) \ + { \ + if (flag_shared_data) \ + fprintf (asm_out_file, "%s\n", SHARED_BSS_SECTION_ASM_OP); \ + else \ + fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP); \ + in_section = in_bss; \ + } \ +} diff --git a/support/cpp/i386/seq2-sysv3.h b/support/cpp/i386/seq2-sysv3.h new file mode 100644 index 00000000..763c5f0a --- /dev/null +++ b/support/cpp/i386/seq2-sysv3.h @@ -0,0 +1,8 @@ +/* Sequent DYNIX/ptx 2.x (SVr3) */ + +#include "i386/seq-sysv3.h" + +/* Use atexit for static destructors, instead of defining + our own exit function. */ +#define HAVE_ATEXIT + diff --git a/support/cpp/i386/sequent.h b/support/cpp/i386/sequent.h new file mode 100644 index 00000000..4d76c389 --- /dev/null +++ b/support/cpp/i386/sequent.h @@ -0,0 +1,152 @@ +/* Definitions for Sequent Intel 386. + Copyright (C) 1988, 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "i386/i386.h" + +/* Use the BSD assembler syntax. */ + +#include "i386/bsd.h" + +/* By default, don't use IEEE compatible arithmetic comparisons + because the assembler can't handle the fucom insn. + Return float values in the 387. + (TARGET_80387 | TARGET_FLOAT_RETURNS_IN_80387) */ + +#undef TARGET_DEFAULT +#define TARGET_DEFAULT 0201 + +/* Specify predefined symbols in preprocessor. */ + +#define CPP_PREDEFINES "-Dunix -Di386 -Dsequent -Asystem(unix) -Acpu(i386) -Amachine(i386)" + +/* Pass -Z and -ZO options to the linker. */ + +#define LINK_SPEC "%{Z*}" + +#if 0 /* Dynix 3.1 is said to accept -L. */ +/* Dynix V3.0.12 doesn't accept -L at all. */ + +#define LINK_LIBGCC_SPECIAL +#endif + +/* Link with libg.a when debugging, for dbx's sake. */ + +#define LIB_SPEC "%{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} " + +/* We don't want to output SDB debugging information. */ + +#undef SDB_DEBUGGING_INFO + +/* We want to output DBX debugging information. */ + +#define DBX_DEBUGGING_INFO + +/* Sequent Symmetry has size_t defined as int in /usr/include/sys/types.h */ +#define SIZE_TYPE "int" + +/* gcc order is ax, dx, cx, bx, si, di, bp, sp, st, st. + * dbx order is ax, dx, cx, st(0), st(1), bx, si, di, st(2), st(3), + * st(4), st(5), st(6), st(7), sp, bp */ + +/* ??? The right thing would be to change the ordering of the + registers to correspond to the conventions of this system, + and get rid of DBX_REGISTER_NUMBER. */ + +#undef DBX_REGISTER_NUMBER +#define DBX_REGISTER_NUMBER(n) \ +((n) < 3 ? (n) : (n) < 6 ? (n) + 2 \ + : (n) == 6 ? 15 : (n) == 7 ? 14 : 3) + +/* malcolmp@hydra.maths.unsw.EDU.AU says these two definitions + fix trouble in dbx. */ +#undef DBX_OUTPUT_LBRAC +#define DBX_OUTPUT_LBRAC(file,name) \ + fprintf (asmfile, "%s %d,0,%d,", ASM_STABN_OP, N_LBRAC, depth); \ + assemble_name (asmfile, buf); \ + fprintf (asmfile, "\n"); + +#undef DBX_OUTPUT_RBRAC +#define DBX_OUTPUT_RBRAC(file,name) \ + fprintf (asmfile, "%s %d,0,%d,", ASM_STABN_OP, N_RBRAC, depth); \ + assemble_name (asmfile, buf); \ + fprintf (asmfile, "\n"); + +/* Prevent anything from being allocated in the register pair cx/bx, + since that would confuse GDB. */ + +#undef HARD_REGNO_MODE_OK +#define HARD_REGNO_MODE_OK(REGNO, MODE) \ + (((REGNO) < 2 ? 1 \ + : (REGNO) < 4 ? 1 \ + : FP_REGNO_P (REGNO) ? (GET_MODE_CLASS (MODE) == MODE_FLOAT \ + || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \ + : (MODE) != QImode) \ + && ! (REGNO == 2 && GET_MODE_UNIT_SIZE (MODE) > 4)) + +/* Output assembler code to FILE to increment profiler label # LABELNO + for profiling a function entry. */ + +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ + fprintf (FILE, "\tmovl $.LP%d,%%eax\n\tcall mcount\n", (LABELNO)); + +/* Assembler pseudo-op for shared data segment. */ +#define SHARED_SECTION_ASM_OP ".shdata" + +/* A C statement or statements which output an assembler instruction + opcode to the stdio stream STREAM. The macro-operand PTR is a + variable of type `char *' which points to the opcode name in its + "internal" form--the form that is written in the machine description. + + The Sequent assembler (identified as "Balance 8000 Assembler + 07/17/85 3.90" by "as -v") does not understand the `movs[bwl]' string + move mnemonics - it uses `smov[bwl]' instead. Change "movs" into + "smov", carefully avoiding the sign-extend opcodes. */ + +#define ASM_OUTPUT_OPCODE(STREAM, PTR) \ +{ \ + if ((PTR)[0] == 'm' \ + && (PTR)[1] == 'o' \ + && (PTR)[2] == 'v' \ + && (PTR)[3] == 's' \ + && ((PTR)[4] == 'b' || (PTR)[4] == 'w' || (PTR)[4] == 'l') \ + && ((PTR)[5] == ' ' || (PTR)[5] == '\t'|| (PTR)[5] == '\0')) \ + { \ + fprintf (STREAM, "smov"); \ + (PTR) += 4; \ + } \ +} + +/* 10-Aug-92 pes Local labels are prefixed with ".L" */ +#undef LPREFIX +#define LPREFIX ".L" + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER)\ + sprintf ((BUF), "*.%s%d", (PREFIX), (NUMBER)) + +#undef ASM_OUTPUT_INTERNAL_LABEL +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)\ + fprintf (FILE, ".%s%d:\n", PREFIX, NUM) + +/* The native compiler passes the address of the returned structure in eax. */ +#undef STRUCT_VALUE +#undef STRUCT_VALUE_INCOMING +#define STRUCT_VALUE_REGNUM 0 diff --git a/support/cpp/i386/sol2-c1.asm b/support/cpp/i386/sol2-c1.asm new file mode 100644 index 00000000..72fdfb87 --- /dev/null +++ b/support/cpp/i386/sol2-c1.asm @@ -0,0 +1,156 @@ +! crt1.s for Solaris 2, x86 + +! Copyright (C) 1993 Free Software Foundation, Inc. +! Written By Fred Fish, Nov 1992 +! +! This file 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, or (at your option) any +! later version. +! +! In addition to the permissions in the GNU General Public License, the +! Free Software Foundation gives you unlimited permission to link the +! compiled version of this file with other programs, and to distribute +! those programs without any restriction coming from the use of this +! file. (The General Public License restrictions do apply in other +! respects; for example, they cover modification of the file, and +! distribution when not linked into another program.) +! +! 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; see the file COPYING. If not, write to +! the Free Software Foundation, 59 Temple Place - Suite 330, +! Boston, MA 02111-1307, USA. +! +! As a special exception, if you link this library with files +! compiled with GCC to produce an executable, this does not cause +! the resulting executable to be covered by the GNU General Public License. +! This exception does not however invalidate any other reasons why +! the executable file might be covered by the GNU General Public License. +! + +! This file takes control of the process from the kernel, as specified +! in section 3 of the System V Application Binary Interface, Intel386 +! Processor Supplement. It has been constructed from information obtained +! from the ABI, information obtained from single stepping existing +! Solaris executables through their startup code with gdb, and from +! information obtained by single stepping executables on other i386 SVR4 +! implementations. This file is the first thing linked into any executable. + + .file "crt1.s" + .ident "GNU C crt1.s" + .weak _cleanup + .weak _DYNAMIC + .text + +! Start creating the initial frame by pushing a NULL value for the return +! address of the initial frame, and mark the end of the stack frame chain +! (the innermost stack frame) with a NULL value, per page 3-32 of the ABI. +! Initialize the first stack frame pointer in %ebp (the contents of which +! are unspecified at process initialization). + + .globl _start +_start: + pushl $0x0 + pushl $0x0 + movl %esp,%ebp + +! As specified per page 3-32 of the ABI, %edx contains a function +! pointer that should be registered with atexit(), for proper +! shared object termination. Just push it onto the stack for now +! to preserve it. We want to register _cleanup() first. + + pushl %edx + +! Check to see if there is an _cleanup() function linked in, and if +! so, register it with atexit() as the last thing to be run by +! atexit(). + + movl $_cleanup,%eax + testl %eax,%eax + je .L1 + pushl $_cleanup + call atexit + addl $0x4,%esp +.L1: + +! Now check to see if we have an _DYNAMIC table, and if so then +! we need to register the function pointer previously in %edx, but +! now conveniently saved on the stack as the argument to pass to +! atexit(). + + movl $_DYNAMIC,%eax + testl %eax,%eax + je .L2 + call atexit +.L2: + +! Register _fini() with atexit(). We will take care of calling _init() +! directly. + + pushl $_fini + call atexit + +! Compute the address of the environment vector on the stack and load +! it into the global variable _environ. Currently argc is at 8 off +! the frame pointer. Fetch the argument count into %eax, scale by the +! size of each arg (4 bytes) and compute the address of the environment +! vector which is 16 bytes (the two zero words we pushed, plus argc, +! plus the null word terminating the arg vector) further up the stack, +! off the frame pointer (whew!). + + movl 8(%ebp),%eax + leal 16(%ebp,%eax,4),%edx + movl %edx,_environ + +! Push the environment vector pointer, the argument vector pointer, +! and the argument count on to the stack to set up the arguments +! for _init(), _fpstart(), and main(). Note that the environment +! vector pointer and the arg count were previously loaded into +! %edx and %eax respectively. The only new value we need to compute +! is the argument vector pointer, which is at a fixed address off +! the initial frame pointer. + + pushl %edx + leal 12(%ebp),%edx + pushl %edx + pushl %eax + +! Call _init(argc, argv, environ), _fpstart(argc, argv, environ), and +! main(argc, argv, environ). + + call _init + call __fpstart + call main + +! Pop the argc, argv, and environ arguments off the stack, push the +! value returned from main(), and call exit(). + + addl $12,%esp + pushl %eax + call exit + +! An inline equivalent of _exit, as specified in Figure 3-26 of the ABI. + + pushl $0x0 + movl $0x1,%eax + lcall $7,$0 + +! If all else fails, just try a halt! + + hlt + .type _start,@function + .size _start,.-_start + +! A dummy profiling support routine for non-profiling executables, +! in case we link in some objects that have been compiled for profiling. + + .globl _mcount +_mcount: + ret + .type _mcount,@function + .size _mcount,.-_mcount diff --git a/support/cpp/i386/sol2-ci.asm b/support/cpp/i386/sol2-ci.asm new file mode 100644 index 00000000..439c709b --- /dev/null +++ b/support/cpp/i386/sol2-ci.asm @@ -0,0 +1,51 @@ +! crti.s for Solaris 2, x86. + +! Copyright (C) 1993 Free Software Foundation, Inc. +! Written By Fred Fish, Nov 1992 +! +! This file 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, or (at your option) any +! later version. +! +! In addition to the permissions in the GNU General Public License, the +! Free Software Foundation gives you unlimited permission to link the +! compiled version of this file with other programs, and to distribute +! those programs without any restriction coming from the use of this +! file. (The General Public License restrictions do apply in other +! respects; for example, they cover modification of the file, and +! distribution when not linked into another program.) +! +! 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; see the file COPYING. If not, write to +! the Free Software Foundation, 59 Temple Place - Suite 330, +! Boston, MA 02111-1307, USA. +! +! As a special exception, if you link this library with files +! compiled with GCC to produce an executable, this does not cause +! the resulting executable to be covered by the GNU General Public License. +! This exception does not however invalidate any other reasons why +! the executable file might be covered by the GNU General Public License. +! + +! This file just supplies labeled starting points for the .init and .fini +! sections. It is linked in before the values-Xx.o files and also before +! crtbegin.o. + + .file "crti.s" + .ident "GNU C crti.s" + + .section .init + .globl _init + .type _init,@function +_init: + + .section .fini + .globl _fini + .type _fini,@function +_fini: diff --git a/support/cpp/i386/sol2-cn.asm b/support/cpp/i386/sol2-cn.asm new file mode 100644 index 00000000..3f3bad93 --- /dev/null +++ b/support/cpp/i386/sol2-cn.asm @@ -0,0 +1,46 @@ +! crtn.s for Solaris 2, x86. + +! Copyright (C) 1993 Free Software Foundation, Inc. +! Written By Fred Fish, Nov 1992 +! +! This file 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, or (at your option) any +! later version. +! +! In addition to the permissions in the GNU General Public License, the +! Free Software Foundation gives you unlimited permission to link the +! compiled version of this file with other programs, and to distribute +! those programs without any restriction coming from the use of this +! file. (The General Public License restrictions do apply in other +! respects; for example, they cover modification of the file, and +! distribution when not linked into another program.) +! +! 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; see the file COPYING. If not, write to +! the Free Software Foundation, 59 Temple Place - Suite 330, +! Boston, MA 02111-1307, USA. +! +! As a special exception, if you link this library with files +! compiled with GCC to produce an executable, this does not cause +! the resulting executable to be covered by the GNU General Public License. +! This exception does not however invalidate any other reasons why +! the executable file might be covered by the GNU General Public License. +! + +! This file just supplies returns for the .init and .fini sections. It is +! linked in after all other files. + + .file "crtn.o" + .ident "GNU C crtn.o" + + .section .init + ret $0x0 + + .section .fini + ret $0x0 diff --git a/support/cpp/i386/sol2.h b/support/cpp/i386/sol2.h new file mode 100644 index 00000000..cc5ebca7 --- /dev/null +++ b/support/cpp/i386/sol2.h @@ -0,0 +1,91 @@ +/* Target definitions for GNU compiler for Intel 80386 running Solaris 2 + Copyright (C) 1993, 1995 Free Software Foundation, Inc. + + Written by Fred Fish (fnf@cygnus.com). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "i386/sysv4.h" + +/* The Solaris 2.0 x86 linker botches alignment of code sections. + It tries to align to a 16 byte boundary by padding with 0x00000090 + ints, rather than 0x90 bytes (nop). This generates trash in the + ".init" section since the contribution from crtbegin.o is only 7 + bytes. The linker pads it to 16 bytes with a single 0x90 byte, and + two 0x00000090 ints, which generates a segmentation violation when + executed. This macro forces the assembler to do the padding, since + it knows what it is doing. */ + +#define FORCE_INIT_SECTION_ALIGN do { asm (ALIGN_ASM_OP ## " 16"); } while (0) +#define FORCE_FINI_SECTION_ALIGN FORCE_INIT_SECTION_ALIGN + +/* Add "sun" to the list of symbols defined for SVR4. */ +#undef CPP_PREDEFINES +#define CPP_PREDEFINES \ + "-Di386 -Dunix -D__svr4__ -D__SVR4 -Dsun \ + -Asystem(unix) -Asystem(svr4) -Acpu(i386) -Amachine(i386)" + +#undef CPP_SPEC +#define CPP_SPEC "\ + %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude}" + +#undef LIB_SPEC +#define LIB_SPEC \ + "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} %{!shared:%{!symbolic:-lc}}" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "crtend.o%s %{pg:crtn.o%s}%{!pg:crtn.o%s}" + +/* This should be the same as in svr4.h, except with -R added. */ +#undef LINK_SPEC +#define LINK_SPEC \ + "%{h*} %{V} %{v:%{!V:-V}} \ + %{b} %{Wl,*:%*} \ + %{static:-dn -Bstatic} \ + %{shared:-G -dy -z text} \ + %{symbolic:-Bsymbolic -G -dy -z text} \ + %{G:-G} \ + %{YP,*} \ + %{R*} \ + %{compat-bsd: \ + %{!YP,*:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \ + %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}} \ + -R /usr/ucblib} \ + %{!compat-bsd: \ + %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \ + %{!p:-Y P,/usr/ccs/lib:/usr/lib}}} \ + %{Qy:} %{!Qn:-Qy}" + +/* This defines which switch letters take arguments. + It is as in svr4.h but with -R added. */ + +#undef SWITCH_TAKES_ARG +#define SWITCH_TAKES_ARG(CHAR) \ + ( (CHAR) == 'D' \ + || (CHAR) == 'U' \ + || (CHAR) == 'o' \ + || (CHAR) == 'e' \ + || (CHAR) == 'u' \ + || (CHAR) == 'I' \ + || (CHAR) == 'm' \ + || (CHAR) == 'L' \ + || (CHAR) == 'R' \ + || (CHAR) == 'A' \ + || (CHAR) == 'h' \ + || (CHAR) == 'z') + diff --git a/support/cpp/i386/sun.h b/support/cpp/i386/sun.h new file mode 100644 index 00000000..ecc0e829 --- /dev/null +++ b/support/cpp/i386/sun.h @@ -0,0 +1,83 @@ +/* Definitions for Intel 386 running SunOS 4.0. + Copyright (C) 1988, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +#include "i386/i386.h" + +/* Use the Sun assembler syntax. */ + +#include "i386/sun386.h" + +/* Use crt0.o as a startup file. */ + +#define STARTFILE_SPEC \ + "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}" + +#define LIB_SPEC "%{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} \ +%{g:-lg} %{sun386:}" +/* That last item is just to prevent a spurious error. */ + +#undef LINK_SPEC +#define LINK_SPEC \ + "%{!nostdlib:%{!r*:%{!e*:-e _start}}} -dc -dp %{static:-Bstatic}" + +/* Extra switches to give the assembler. */ + +#define ASM_SPEC "%{R} -i386 %{keep-local-as-symbols:-L}" + +/* Specify predefined symbols in preprocessor. */ + +#define CPP_PREDEFINES "-Dunix -Di386 -Dsun386 -Dsun -Asystem(unix) -Asystem(bsd) -Acpu(i386) -Amachine(i386)" + +/* Allow #sccs in preprocessor. */ + +#define SCCS_DIRECTIVE + +/* Output #ident as a .ident. */ + +#define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME); + +/* We don't want to output SDB debugging information. */ + +#undef SDB_DEBUGGING_INFO + +/* We want to output DBX debugging information. */ + +#define DBX_DEBUGGING_INFO + +/* Implicit library calls should use memcpy, not bcopy, etc. */ + +#define TARGET_MEM_FUNCTIONS + +/* Force structure alignment to the type used for a bitfield. */ + +#define PCC_BITFIELD_TYPE_MATTERS 1 + +/* This is partly guess. */ + +#undef DBX_REGISTER_NUMBER +#define DBX_REGISTER_NUMBER(n) \ + ((n) == 0 ? 11 : (n) == 1 ? 9 : (n) == 2 ? 10 : (n) == 3 ? 8 \ + : (n) == 4 ? 5 : (n) == 5 ? 4 : (n) == 6 ? 6 : (n)) + +/* Every debugger symbol must be in the text section. + Otherwise the assembler or the linker screws up. */ + +#define DEBUG_SYMS_TEXT diff --git a/support/cpp/i386/sun386.h b/support/cpp/i386/sun386.h new file mode 100644 index 00000000..6e268078 --- /dev/null +++ b/support/cpp/i386/sun386.h @@ -0,0 +1,143 @@ +/* Definitions for Sun assembler syntax for the Intel 80386. + Copyright (C) 1988 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* Include common aspects of all 386 Unix assemblers. */ +#include "i386/unix.h" + +#define TARGET_VERSION fprintf (stderr, " (80386, Sun syntax)"); + +/* Define the syntax of instructions and addresses. */ + +/* Prefix for internally generated assembler labels. */ +#define LPREFIX ".L" + +/* Define the syntax of pseudo-ops, labels and comments. */ + +/* Assembler pseudos to introduce constants of various size. */ + +#define ASM_BYTE_OP "\t.byte" +#define ASM_SHORT "\t.value" +#define ASM_LONG "\t.long" +#define ASM_DOUBLE "\t.double" + +/* How to output an ASCII string constant. */ + +#define ASM_OUTPUT_ASCII(FILE, p, size) \ +do \ +{ int i = 0; \ + while (i < (size)) \ + { if (i%10 == 0) { if (i!=0) fprintf ((FILE), "\n"); \ + fprintf ((FILE), "%s ", ASM_BYTE_OP); } \ + else fprintf ((FILE), ","); \ + fprintf ((FILE), "0x%x", ((p)[i++] & 0377)) ;} \ + fprintf ((FILE), "\n"); \ +} while (0) + +/* Output at beginning of assembler file. */ +/* The .file command should always begin the output. */ + +#undef ASM_FILE_START +#define ASM_FILE_START(FILE) \ + do { \ + extern char *version_string, *language_string; \ + { \ + int len = strlen (dump_base_name); \ + char *na = dump_base_name + len; \ + char shorter[15]; \ + /* NA gets DUMP_BASE_NAME sans directory names. */\ + while (na > dump_base_name) \ + { \ + if (na[-1] == '/') \ + break; \ + na--; \ + } \ + strncpy (shorter, na, 14); \ + shorter[14] = 0; \ + fprintf (FILE, "\t.file\t"); \ + output_quoted_string (FILE, shorter); \ + fprintf (FILE, "\n"); \ + } \ + fprintf (FILE, "\t.version\t\"%s %s\"\n", \ + language_string, version_string); \ + if (optimize) ASM_FILE_START_1 (FILE); \ + } while (0) + +#define ASM_FILE_START_1(FILE) fprintf (FILE, "\t.optim\n") + +/* This is how to output an assembler line + that says to advance the location counter + to a multiple of 2**LOG bytes. */ + +#define ASM_OUTPUT_ALIGN(FILE,LOG) \ + if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) + +/* This is how to output an assembler line + that says to advance the location counter by SIZE bytes. */ + +#define ASM_OUTPUT_SKIP(FILE,SIZE) \ + fprintf ((FILE), "\t.set\t.,.+%u\n", (SIZE)) + +/* Output before read-only data. */ + +#undef TEXT_SECTION_ASM_OP +#define TEXT_SECTION_ASM_OP ".text" + +/* Output before writable data. */ + +#undef DATA_SECTION_ASM_OP +#define DATA_SECTION_ASM_OP ".data" + +/* Define the syntax of labels and symbol definitions/declarations. */ + +/* This says how to output an assembler line + to define a global common symbol. */ + +#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ +( fputs (".comm ", (FILE)), \ + assemble_name ((FILE), (NAME)), \ + fprintf ((FILE), ",%u\n", (ROUNDED))) + +/* This says how to output an assembler line + to define a local common symbol. */ + +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ +( fputs (".lcomm ", (FILE)), \ + assemble_name ((FILE), (NAME)), \ + fprintf ((FILE), ",%u\n", (ROUNDED))) + +/* This is how to store into the string BUF + the symbol_ref name of an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. + This is suitable for output with `assemble_name'. */ + +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), "*.%s%d", (PREFIX), (NUMBER)) + +/* This is how to output a reference to a user-level label named NAME. */ + +#define ASM_OUTPUT_LABELREF(FILE,NAME) \ + fprintf (FILE, "%s", NAME) + +/* This is how to output an internal numbered label where + PREFIX is the class of label and NUM is the number within the class. */ + +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ + fprintf (FILE, ".%s%d:\n", PREFIX, NUM) diff --git a/support/cpp/i386/svr3.ifile b/support/cpp/i386/svr3.ifile new file mode 100644 index 00000000..f0bb3a0f --- /dev/null +++ b/support/cpp/i386/svr3.ifile @@ -0,0 +1,45 @@ +/* + * svr3.ifile - for collectless G++ on i386 System V. + * Leaves memory configured at address 0. + * + * Install this file as $prefix/gcc-lib/TARGET/VERSION/gcc.ifile + * + * BLOCK to an offset that leaves room for many headers ( the value + * here allows for a file header, an outheader, and up to 11 section + * headers on most systems. + * BIND to an address that includes page 0 in mapped memory. The value + * used for BLOCK should be or'd into this value. Here I'm setting BLOCK + * to 0x200 and BIND to ( value_used_for(BLOCK) ) + * If you are using shared libraries, watch that you don't overlap the + * address ranges assigned for shared libs. + * + * GROUP BIND to a location in the next segment. Here, the only value + * that you should change (I think) is that within NEXT, which I've set + * to my hardware segment size. You can always use a larger size, but not + * a smaller one. + */ +SECTIONS +{ + .text BIND(0x000200) BLOCK (0x200) : + { + /* plenty for room for headers */ + *(.init) + *(.text) + vfork = fork; /* I got tired of editing peoples sloppy code */ + *(.fini) + } + GROUP BIND( NEXT(0x400000) + (ADDR(.text) + (SIZEOF(.text)) % 0x1000)): + { + .data : { + __CTOR_LIST__ = . ; + . += 4 ; /* leading NULL */ + *(.ctor) + . += 4 ; /* trailing NULL */ + __DTOR_LIST__ = . ; + . += 4 ; /* leading NULL */ + *(.dtor) + . += 4 ; /* trailing NULL */ + } + .bss : { } + } +} diff --git a/support/cpp/i386/svr3dbx.h b/support/cpp/i386/svr3dbx.h new file mode 100644 index 00000000..d3348d55 --- /dev/null +++ b/support/cpp/i386/svr3dbx.h @@ -0,0 +1,97 @@ +/* Definitions for Intel 386 running system V, using dbx-in-coff encapsulation. + Copyright (C) 1992, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "i386/svr3gas.h" + +/* We do not want to output SDB debugging information. */ + +#undef SDB_DEBUGGING_INFO + +/* We want to output DBX debugging information. */ + +#define DBX_DEBUGGING_INFO + +/* Compensate for botch in dbxout_init/dbxout_source_file which + unconditionally drops the first character from ltext_label_name */ + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ + sprintf ((BUF), "*.%s%d", (PREFIX), (NUMBER)) + +/* With the current gas, .align N aligns to an N-byte boundary. + This is done to be compatible with the system assembler. + You must specify -DOTHER_ALIGN when building gas-1.38.1. */ + +#undef ASM_OUTPUT_ALIGN +#define ASM_OUTPUT_ALIGN(FILE,LOG) \ + if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) + +/* Align labels, etc. at 4-byte boundaries. + For the 486, align to 16-byte boundary for sake of cache. */ + +#undef ASM_OUTPUT_ALIGN_CODE +#define ASM_OUTPUT_ALIGN_CODE(FILE) \ + fprintf ((FILE), "\t.align %d,0x90\n", \ + 1 << i386_align_jumps) + +/* Align start of loop at 4-byte boundary. */ + +#undef ASM_OUTPUT_LOOP_ALIGN +#define ASM_OUTPUT_LOOP_ALIGN(FILE) \ + fprintf ((FILE), "\t.align %d,0x90\n", 1 << i386_align_loops); + + +/* Additional overrides needed for dbx-in-coff gas, mostly taken from pbb.h */ + +/* Although the gas we use can create .ctor and .dtor sections from N_SETT + stabs, it does not support section directives, so we need to have the loader + define the lists. + */ +#define CTOR_LISTS_DEFINED_EXTERNALLY + +/* similar to default, but allows for the table defined by ld with svr3.ifile. + nptrs is always 0. So we need to instead check that __DTOR_LIST__[1] != 0. + The old check is left in so that the same macro can be used if and when + a future version of gas does support section directives. */ + +#define DO_GLOBAL_DTORS_BODY {int nptrs = *(int *)__DTOR_LIST__; int i; \ + if (nptrs == -1 || (__DTOR_LIST__[0] == 0 && __DTOR_LIST__[1] != 0)) \ + for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++); \ + for (i = nptrs; i >= 1; i--) \ + __DTOR_LIST__[i] (); } + +/* Use crt1.o as a startup file and crtn.o as a closing file. */ +/* + * The loader directive file svr3.ifile defines how to merge the constructor + * sections into the data section. Also, since gas only puts out those + * sections in response to N_SETT stabs, and does not (yet) have a + * ".sections" directive, svr3.ifile also defines the list symbols + * __DTOR_LIST__ and __CTOR_LIST__. + */ +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + "%{!r:%{!z:svr3.ifile%s}%{z:svr3z.ifile%s}}\ + %{pg:gcrt1.o%s}%{!pg:%{posix:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}%{!posix:%{p:mcrt1.o%s}%{!p:crt1.o%s}}} \ + %{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp}" + +#define ENDFILE_SPEC "crtn.o%s" + +#undef LIB_SPEC +#define LIB_SPEC "%{posix:-lcposix} %{shlib:-lc_s} -lc -lg" diff --git a/support/cpp/i386/svr3gas.h b/support/cpp/i386/svr3gas.h new file mode 100644 index 00000000..401c7661 --- /dev/null +++ b/support/cpp/i386/svr3gas.h @@ -0,0 +1,305 @@ +/* Definitions for Intel 386 running system V, using gas. + Copyright (C) 1992 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "i386/gas.h" + +/* Add stuff that normally comes from i386/sysv3.h */ + +/* longjmp may fail to restore the registers if called from the same + function that called setjmp. To compensate, the compiler avoids + putting variables in registers in functions that use both setjmp + and longjmp. */ + +#define NON_SAVING_SETJMP \ + (current_function_calls_setjmp && current_function_calls_longjmp) + +/* longjmp may fail to restore the stack pointer if the saved frame + pointer is the same as the caller's frame pointer. Requiring a frame + pointer in any function that calls setjmp or longjmp avoids this + problem, unless setjmp and longjmp are called from the same function. + Since a frame pointer will be required in such a function, it is OK + that the stack pointer is not restored. */ + +#undef FRAME_POINTER_REQUIRED +#define FRAME_POINTER_REQUIRED \ + (current_function_calls_setjmp || current_function_calls_longjmp) + +/* Modify ASM_OUTPUT_LOCAL slightly to test -msvr3-shlib, adapted to gas */ +#undef ASM_OUTPUT_LOCAL +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ + do { \ + int align = exact_log2 (ROUNDED); \ + if (align > 2) align = 2; \ + if (TARGET_SVR3_SHLIB) \ + { \ + data_section (); \ + ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \ + ASM_OUTPUT_LABEL ((FILE), (NAME)); \ + fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)); \ + } \ + else \ + { \ + fputs (".lcomm ", (FILE)); \ + assemble_name ((FILE), (NAME)); \ + fprintf ((FILE), ",%u\n", (ROUNDED)); \ + } \ + } while (0) + +/* Add stuff that normally comes from i386/sysv3.h via svr3.h */ + +/* Define the actual types of some ANSI-mandated types. These + definitions should work for most SVR3 systems. */ + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "long int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE BITS_PER_WORD + +/* ??? This stuff is copied from config/svr3.h. In the future, + this file should be rewritten to include config/svr3.h + and override what isn't right. */ + +/* Support const sections and the ctors and dtors sections for g++. + Note that there appears to be two different ways to support const + sections at the moment. You can either #define the symbol + READONLY_DATA_SECTION (giving it some code which switches to the + readonly data section) or else you can #define the symbols + EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and + SELECT_RTX_SECTION. We do both here just to be on the safe side. + However, use of the const section is turned off by default + unless the specific tm.h file turns it on by defining + USE_CONST_SECTION as 1. */ + +/* Define a few machine-specific details of the implementation of + constructors. + + The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN + and CTOR_LIST_END to contribute to the .init section an instruction to + push a word containing 0 (or some equivalent of that). + + Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor. */ + +#define USE_CONST_SECTION 0 + +#define INIT_SECTION_ASM_OP ".section\t.init" +#define FINI_SECTION_ASM_OP ".section .fini,\"x\"" +#define CONST_SECTION_ASM_OP ".section\t.rodata, \"x\"" +#define CTORS_SECTION_ASM_OP INIT_SECTION_ASM_OP +#define DTORS_SECTION_ASM_OP FINI_SECTION_ASM_OP + +/* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent + because they push on the stack. */ + +#ifdef STACK_GROWS_DOWNWARD + +/* Constructor list on stack is in reverse order. Go to the end of the + list and go backwards to call constructors in the right order. */ +#define DO_GLOBAL_CTORS_BODY \ +do { \ + func_ptr *p, *beg = alloca (0); \ + for (p = beg; *p; p++) \ + ; \ + while (p != beg) \ + (*--p) (); \ +} while (0) + +#else + +/* Constructor list on stack is in correct order. Just call them. */ +#define DO_GLOBAL_CTORS_BODY \ +do { \ + func_ptr *p, *beg = alloca (0); \ + for (p = beg; *p; ) \ + (*p++) (); \ +} while (0) + +#endif /* STACK_GROWS_DOWNWARD */ + +/* Add extra sections .init and .fini, in addition to .bss from att386.h. */ + +#undef EXTRA_SECTIONS +#define EXTRA_SECTIONS in_const, in_bss, in_init, in_fini + +#undef EXTRA_SECTION_FUNCTIONS +#define EXTRA_SECTION_FUNCTIONS \ + CONST_SECTION_FUNCTION \ + BSS_SECTION_FUNCTION \ + INIT_SECTION_FUNCTION \ + FINI_SECTION_FUNCTION + +#define BSS_SECTION_FUNCTION \ +void \ +bss_section () \ +{ \ + if (in_section != in_bss) \ + { \ + fprintf (asm_out_file, "\t%s\n", BSS_SECTION_ASM_OP); \ + in_section = in_bss; \ + } \ +} + +#define INIT_SECTION_FUNCTION \ +void \ +init_section () \ +{ \ + if (in_section != in_init) \ + { \ + fprintf (asm_out_file, "\t%s\n", INIT_SECTION_ASM_OP); \ + in_section = in_init; \ + } \ +} + +#define FINI_SECTION_FUNCTION \ +void \ +fini_section () \ +{ \ + if (in_section != in_fini) \ + { \ + fprintf (asm_out_file, "\t%s\n", FINI_SECTION_ASM_OP); \ + in_section = in_fini; \ + } \ +} + +#define READONLY_DATA_SECTION() const_section () + +#define CONST_SECTION_FUNCTION \ +void \ +const_section () \ +{ \ + extern void text_section(); \ + if (!USE_CONST_SECTION) \ + text_section(); \ + else if (in_section != in_const) \ + { \ + fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \ + in_section = in_const; \ + } \ +} + +/* The ctors and dtors sections are not normally put into use + by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h, + but it can't hurt to define these macros for whatever systems use them. */ +#define CTORS_SECTION_FUNCTION \ +void \ +ctors_section () \ +{ \ + if (in_section != in_ctors) \ + { \ + fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \ + in_section = in_ctors; \ + } \ +} + +#define DTORS_SECTION_FUNCTION \ +void \ +dtors_section () \ +{ \ + if (in_section != in_dtors) \ + { \ + fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \ + in_section = in_dtors; \ + } \ +} + +/* This is machine-dependent + because it needs to push something on the stack. */ +#undef ASM_OUTPUT_CONSTRUCTOR + +/* A C statement (sans semicolon) to output an element in the table of + global destructors. */ +#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ + do { \ + fini_section (); \ + fprintf (FILE, "%s\t ", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + +/* A C statement or statements to switch to the appropriate + section for output of DECL. DECL is either a `VAR_DECL' node + or a constant of some sort. RELOC indicates whether forming + the initial value of DECL requires link-time relocations. */ + +#define SELECT_SECTION(DECL,RELOC) \ +{ \ + if (TREE_CODE (DECL) == STRING_CST) \ + { \ + if (! flag_writable_strings) \ + const_section (); \ + else \ + data_section (); \ + } \ + else if (TREE_CODE (DECL) == VAR_DECL) \ + { \ + if ((0 && RELOC) /* should be (flag_pic && RELOC) */ \ + || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ + || !DECL_INITIAL (DECL) \ + || (DECL_INITIAL (DECL) != error_mark_node \ + && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ + data_section (); \ + else \ + const_section (); \ + } \ + else \ + const_section (); \ +} + +/* A C statement or statements to switch to the appropriate + section for output of RTX in mode MODE. RTX is some kind + of constant in RTL. The argument MODE is redundant except + in the case of a `const_int' rtx. Currently, these always + go into the const section. */ + +#define SELECT_RTX_SECTION(MODE,RTX) const_section() + +/* This is copied from i386/sysv3.h. */ + +/* Define a few machine-specific details of the implementation of + constructors. + + The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN + and CTOR_LIST_END to contribute to the .init section an instruction to + push a word containing 0 (or some equivalent of that). + + ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the + constructor. */ + +#undef INIT_SECTION_ASM_OP +#define INIT_SECTION_ASM_OP ".section .init,\"x\"" + +#define CTOR_LIST_BEGIN \ + asm (INIT_SECTION_ASM_OP); \ + asm ("pushl $0") +#define CTOR_LIST_END CTOR_LIST_BEGIN + +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + init_section (); \ + fprintf (FILE, "\tpushl $"); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) diff --git a/support/cpp/i386/svr3z.ifile b/support/cpp/i386/svr3z.ifile new file mode 100644 index 00000000..4fdbb937 --- /dev/null +++ b/support/cpp/i386/svr3z.ifile @@ -0,0 +1,45 @@ +/* + * svr3z.ifile - for collectless G++ on i386 System V. + * Leaves memory unconfigured at address 0. + * + * Install this file as $prefix/gcc-lib/TARGET/VERSION/gccz.ifile + * + * BLOCK to an offset that leaves room for many headers ( the value + * here allows for a file header, an outheader, and up to 11 section + * headers on most systems. + * BIND to an address that excludes page 0 from being mapped. The value + * used for BLOCK should be or'd into this value. Here I'm setting BLOCK + * to 0x200 and BIND to ( 0x400000 | value_used_for(BLOCK) ) + * If you are using shared libraries, watch that you don't overlap the + * address ranges assigned for shared libs. + * + * GROUP BIND to a location in the next segment. Here, the only value + * that you should change (I think) is that within NEXT, which I've set + * to my hardware segment size. You can always use a larger size, but not + * a smaller one. + */ +SECTIONS +{ + .text BIND(0x400200) BLOCK (0x200) : + { + /* plenty for room for headers */ + *(.init) + *(.text) + vfork = fork; /* I got tired of editing peoples sloppy code */ + *(.fini) + } + GROUP BIND( NEXT(0x400000) + (ADDR(.text) + (SIZEOF(.text)) % 0x1000)): + { + .data : { + __CTOR_LIST__ = . ; + . += 4 ; /* leading NULL */ + *(.ctor) + . += 4 ; /* trailing NULL */ + __DTOR_LIST__ = . ; + . += 4 ; /* leading NULL */ + *(.dtor) + . += 4 ; /* trailing NULL */ + } + .bss : { } + } +} diff --git a/support/cpp/i386/sysv3.h b/support/cpp/i386/sysv3.h new file mode 100644 index 00000000..8c5cfc41 --- /dev/null +++ b/support/cpp/i386/sysv3.h @@ -0,0 +1,124 @@ +/* Definitions for Intel 386 running system V. + Copyright (C) 1988 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +#include "i386/i386.h" + +/* Use default settings for system V.3. */ + +#include "svr3.h" + +/* Use the ATT assembler syntax. + This overrides at least one macro (ASM_OUTPUT_LABELREF) from svr3.h. */ + +#include "i386/att.h" + +/* Use crt1.o as a startup file and crtn.o as a closing file. */ + +#define STARTFILE_SPEC \ + "%{pg:gcrt1.o%s}%{!pg:%{posix:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}%{!posix:%{p:mcrt1.o%s}%{!p:crt1.o%s}}} crtbegin.o%s\ + %{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp}" + +/* ??? There is a suggestion that -lg is needed here. + Does anyone know whether this is right? */ +#define LIB_SPEC "%{posix:-lcposix} %{shlib:-lc_s} -lc crtend.o%s crtn.o%s" + +/* Specify predefined symbols in preprocessor. */ + +#define CPP_PREDEFINES "-Dunix -Di386 -Asystem(unix) -Asystem(svr3) -Acpu(i386) -Amachine(i386)" + +#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}" + +/* Writing `int' for a bitfield forces int alignment for the structure. */ + +#define PCC_BITFIELD_TYPE_MATTERS 1 + +/* Don't write a `.optim' pseudo; this assembler doesn't handle them. */ + +#undef ASM_FILE_START_1 +#define ASM_FILE_START_1(FILE) + +/* We want to be able to get DBX debugging information via -gstabs. */ + +#undef DBX_DEBUGGING_INFO +#define DBX_DEBUGGING_INFO + +#undef PREFERRED_DEBUGGING_TYPE +#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG + +/* longjmp may fail to restore the registers if called from the same + function that called setjmp. To compensate, the compiler avoids + putting variables in registers in functions that use both setjmp + and longjmp. */ + +#define NON_SAVING_SETJMP \ + (current_function_calls_setjmp && current_function_calls_longjmp) + +/* longjmp may fail to restore the stack pointer if the saved frame + pointer is the same as the caller's frame pointer. Requiring a frame + pointer in any function that calls setjmp or longjmp avoids this + problem, unless setjmp and longjmp are called from the same function. + Since a frame pointer will be required in such a function, it is OK + that the stack pointer is not restored. */ + +#undef FRAME_POINTER_REQUIRED +#define FRAME_POINTER_REQUIRED \ + (current_function_calls_setjmp || current_function_calls_longjmp) + +/* Modify ASM_OUTPUT_LOCAL slightly to test -msvr3-shlib. */ +#undef ASM_OUTPUT_LOCAL +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ + do { \ + int align = exact_log2 (ROUNDED); \ + if (align > 2) align = 2; \ + if (TARGET_SVR3_SHLIB) \ + data_section (); \ + else \ + bss_section (); \ + ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \ + ASM_OUTPUT_LABEL ((FILE), (NAME)); \ + fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)); \ + } while (0) + +/* Define a few machine-specific details of the implementation of + constructors. + + The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN + and CTOR_LIST_END to contribute to the .init section an instruction to + push a word containing 0 (or some equivalent of that). + + ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the + constructor. */ + +#undef INIT_SECTION_ASM_OP +#define INIT_SECTION_ASM_OP ".section .init,\"x\"" + +#define CTOR_LIST_BEGIN \ + asm (INIT_SECTION_ASM_OP); \ + asm ("pushl $0") +#define CTOR_LIST_END CTOR_LIST_BEGIN + +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + init_section (); \ + fprintf (FILE, "\tpushl $"); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) diff --git a/support/cpp/i386/sysv4.h b/support/cpp/i386/sysv4.h new file mode 100644 index 00000000..92fcada0 --- /dev/null +++ b/support/cpp/i386/sysv4.h @@ -0,0 +1,245 @@ +/* Target definitions for GNU compiler for Intel 80386 running System V.4 + Copyright (C) 1991 Free Software Foundation, Inc. + + Written by Ron Guilmette (rfg@netcom.com). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "i386/i386.h" /* Base i386 target machine definitions */ +#include "i386/att.h" /* Use the i386 AT&T assembler syntax */ +#include "svr4.h" /* Definitions common to all SVR4 targets */ + +#undef TARGET_VERSION +#define TARGET_VERSION fprintf (stderr, " (i386 System V Release 4)"); + +/* The svr4 ABI for the i386 says that records and unions are returned + in memory. */ + +#undef RETURN_IN_MEMORY +#define RETURN_IN_MEMORY(TYPE) \ + (TYPE_MODE (TYPE) == BLKmode) + +/* Define which macros to predefine. __svr4__ is our extension. */ +/* This used to define X86, but james@bigtex.cactus.org says that + is supposed to be defined optionally by user programs--not by default. */ +#define CPP_PREDEFINES \ + "-Di386 -Dunix -D__svr4__ -Asystem(unix) -Asystem(svr4) -Acpu(i386) -Amachine(i386)" + +/* This is how to output assembly code to define a `float' constant. + We always have to use a .long pseudo-op to do this because the native + SVR4 ELF assembler is buggy and it generates incorrect values when we + try to use the .float pseudo-op instead. */ + +#undef ASM_OUTPUT_FLOAT +#define ASM_OUTPUT_FLOAT(FILE,VALUE) \ +do { long value; \ + REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value); \ + if (sizeof (int) == sizeof (long)) \ + fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value); \ + else \ + fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value); \ + } while (0) + +/* This is how to output assembly code to define a `double' constant. + We always have to use a pair of .long pseudo-ops to do this because + the native SVR4 ELF assembler is buggy and it generates incorrect + values when we try to use the the .double pseudo-op instead. */ + +#undef ASM_OUTPUT_DOUBLE +#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ +do { long value[2]; \ + REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value); \ + if (sizeof (int) == sizeof (long)) \ + { \ + fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[0]); \ + fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[1]); \ + } \ + else \ + { \ + fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[0]); \ + fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[1]); \ + } \ + } while (0) + + +#undef ASM_OUTPUT_LONG_DOUBLE +#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \ +do { long value[3]; \ + REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), value); \ + if (sizeof (int) == sizeof (long)) \ + { \ + fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[0]); \ + fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[1]); \ + fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[2]); \ + } \ + else \ + { \ + fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[0]); \ + fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[1]); \ + fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[2]); \ + } \ + } while (0) + +/* Output at beginning of assembler file. */ +/* The .file command should always begin the output. */ + +#undef ASM_FILE_START +#define ASM_FILE_START(FILE) \ + do { \ + output_file_directive (FILE, main_input_filename); \ + fprintf (FILE, "\t.version\t\"01.01\"\n"); \ + } while (0) + +/* Define the register numbers to be used in Dwarf debugging information. + The SVR4 reference port C compiler uses the following register numbers + in its Dwarf output code: + + 0 for %eax (gnu regno = 0) + 1 for %ecx (gnu regno = 2) + 2 for %edx (gnu regno = 1) + 3 for %ebx (gnu regno = 3) + 4 for %esp (gnu regno = 7) + 5 for %ebp (gnu regno = 6) + 6 for %esi (gnu regno = 4) + 7 for %edi (gnu regno = 5) + + The following three DWARF register numbers are never generated by + the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 + believes these numbers have these meanings. + + 8 for %eip (no gnu equivalent) + 9 for %eflags (no gnu equivalent) + 10 for %trapno (no gnu equivalent) + + It is not at all clear how we should number the FP stack registers + for the x86 architecture. If the version of SDB on x86/svr4 were + a bit less brain dead with respect to floating-point then we would + have a precedent to follow with respect to DWARF register numbers + for x86 FP registers, but the SDB on x86/svr4 is so completely + broken with respect to FP registers that it is hardly worth thinking + of it as something to strive for compatibility with. + + The version of x86/svr4 SDB I have at the moment does (partially) + seem to believe that DWARF register number 11 is associated with + the x86 register %st(0), but that's about all. Higher DWARF + register numbers don't seem to be associated with anything in + particular, and even for DWARF regno 11, SDB only seems to under- + stand that it should say that a variable lives in %st(0) (when + asked via an `=' command) if we said it was in DWARF regno 11, + but SDB still prints garbage when asked for the value of the + variable in question (via a `/' command). + + (Also note that the labels SDB prints for various FP stack regs + when doing an `x' command are all wrong.) + + Note that these problems generally don't affect the native SVR4 + C compiler because it doesn't allow the use of -O with -g and + because when it is *not* optimizing, it allocates a memory + location for each floating-point variable, and the memory + location is what gets described in the DWARF AT_location + attribute for the variable in question. + + Regardless of the severe mental illness of the x86/svr4 SDB, we + do something sensible here and we use the following DWARF + register numbers. Note that these are all stack-top-relative + numbers. + + 11 for %st(0) (gnu regno = 8) + 12 for %st(1) (gnu regno = 9) + 13 for %st(2) (gnu regno = 10) + 14 for %st(3) (gnu regno = 11) + 15 for %st(4) (gnu regno = 12) + 16 for %st(5) (gnu regno = 13) + 17 for %st(6) (gnu regno = 14) + 18 for %st(7) (gnu regno = 15) +*/ + +#undef DBX_REGISTER_NUMBER +#define DBX_REGISTER_NUMBER(n) \ +((n) == 0 ? 0 \ + : (n) == 1 ? 2 \ + : (n) == 2 ? 1 \ + : (n) == 3 ? 3 \ + : (n) == 4 ? 6 \ + : (n) == 5 ? 7 \ + : (n) == 6 ? 5 \ + : (n) == 7 ? 4 \ + : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ + : (-1)) + +/* The routine used to output sequences of byte values. We use a special + version of this for most svr4 targets because doing so makes the + generated assembly code more compact (and thus faster to assemble) + as well as more readable. Note that if we find subparts of the + character sequence which end with NUL (and which are shorter than + STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ + +#undef ASM_OUTPUT_ASCII +#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ + do \ + { \ + register unsigned char *_ascii_bytes = (unsigned char *) (STR); \ + register unsigned char *limit = _ascii_bytes + (LENGTH); \ + register unsigned bytes_in_chunk = 0; \ + for (; _ascii_bytes < limit; _ascii_bytes++) \ + { \ + register unsigned char *p; \ + if (bytes_in_chunk >= 64) \ + { \ + fputc ('\n', (FILE)); \ + bytes_in_chunk = 0; \ + } \ + for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ + continue; \ + if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT) \ + { \ + if (bytes_in_chunk > 0) \ + { \ + fputc ('\n', (FILE)); \ + bytes_in_chunk = 0; \ + } \ + ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \ + _ascii_bytes = p; \ + } \ + else \ + { \ + if (bytes_in_chunk == 0) \ + fprintf ((FILE), "\t.byte\t"); \ + else \ + fputc (',', (FILE)); \ + fprintf ((FILE), "0x%02x", *_ascii_bytes); \ + bytes_in_chunk += 5; \ + } \ + } \ + if (bytes_in_chunk > 0) \ + fprintf ((FILE), "\n"); \ + } \ + while (0) + +/* This is how to output an element of a case-vector that is relative. + This is only used for PIC code. See comments by the `casesi' insn in + i386.md for an explanation of the expression this outputs. */ + +#undef ASM_OUTPUT_ADDR_DIFF_ELT +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ + fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) + +/* Indicate that jump tables go in the text section. This is + necessary when compiling PIC code. */ + +#define JUMP_TABLES_IN_TEXT_SECTION diff --git a/support/cpp/i386/sysv4gdb.h b/support/cpp/i386/sysv4gdb.h new file mode 100644 index 00000000..dd1e8f25 --- /dev/null +++ b/support/cpp/i386/sysv4gdb.h @@ -0,0 +1,7 @@ +/* Target definitions for GNU compiler for Intel 80386 running System V.4 + with gas and gdb. */ + +/* Use stabs instead of DWARF debug format. */ +#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG + +#include "i386/sysv4.h" diff --git a/support/cpp/i386/t-crtpic b/support/cpp/i386/t-crtpic new file mode 100644 index 00000000..f5dd073a --- /dev/null +++ b/support/cpp/i386/t-crtpic @@ -0,0 +1,9 @@ +# The pushl in CTOR initialization interferes with frame pointer elimination. + +# We need to use -fPIC when we are using gcc to compile the routines in +# crtstuff.c. This is only really needed when we are going to use gcc/g++ +# to produce a shared library, but since we don't know ahead of time when +# we will be doing that, we just always use -fPIC when compiling the +# routines in crtstuff.c. + +CRTSTUFF_T_CFLAGS = -fPIC -fno-omit-frame-pointer diff --git a/support/cpp/i386/t-crtstuff b/support/cpp/i386/t-crtstuff new file mode 100644 index 00000000..a202df66 --- /dev/null +++ b/support/cpp/i386/t-crtstuff @@ -0,0 +1,2 @@ +# The pushl in CTOR initialization interferes with frame pointer elimination. +CRTSTUFF_T_CFLAGS = -fno-omit-frame-pointer diff --git a/support/cpp/i386/t-i386bare b/support/cpp/i386/t-i386bare new file mode 100644 index 00000000..2970fa71 --- /dev/null +++ b/support/cpp/i386/t-i386bare @@ -0,0 +1,3 @@ +# The i386 md has all of these taken care of, according to sef. +LIBGCC1 = +CROSS_LIBGCC1 = diff --git a/support/cpp/i386/t-iscscodbx b/support/cpp/i386/t-iscscodbx new file mode 100644 index 00000000..928a7589 --- /dev/null +++ b/support/cpp/i386/t-iscscodbx @@ -0,0 +1,2 @@ +# The one that comes with the system is POSIX-compliant. +LIMITS_H = diff --git a/support/cpp/i386/t-next b/support/cpp/i386/t-next new file mode 100644 index 00000000..ec6373f9 --- /dev/null +++ b/support/cpp/i386/t-next @@ -0,0 +1,9 @@ +# libgcc1.c is not needed, since the standard library has these functions. +LIBGCC1=libgcc1.null +CROSS_LIBGCC1=libgcc1.null + +# Specify other dirs of system header files to be fixed. +OTHER_FIXINCLUDES_DIRS= /LocalDeveloper/Headers + +# is sometimes in /usr/include/ansi/limits.h. +LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h -o -f $(SYSTEM_HEADER_DIR)/ansi/limits.h ] diff --git a/support/cpp/i386/t-sol2 b/support/cpp/i386/t-sol2 new file mode 100644 index 00000000..f79f6ca0 --- /dev/null +++ b/support/cpp/i386/t-sol2 @@ -0,0 +1,32 @@ +# we need to supply our own assembly versions of libgcc1.c files, +# since the user may not have native 'cc' available + +LIBGCC1 = libgcc1.null +CROSS_LIBGCC1 = libgcc1.null + +# gmon build rule: +gmon.o: $(srcdir)/config/i386/gmon-sol2.c $(GCC_PASSES) $(CONFIG_H) + $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) \ + -c $(srcdir)/config/i386/gmon-sol2.c -o gmon.o + +# Assemble startup files. +# Apparently Sun believes that assembler files don't need comments, because no +# single ASCII character is valid (tried them all). So we manually strip out +# the comments with sed. This bug may only be in the Early Access releases. +crt1.o: $(srcdir)/config/i386/sol2-c1.asm + sed -e '/^!/d' <$(srcdir)/config/i386/sol2-c1.asm >crt1.s + $(AS) -o crt1.o crt1.s +crti.o: $(srcdir)/config/i386/sol2-ci.asm + sed -e '/^!/d' <$(srcdir)/config/i386/sol2-ci.asm >crti.s + $(AS) -o crti.o crti.s +crtn.o: $(srcdir)/config/i386/sol2-cn.asm + sed -e '/^!/d' <$(srcdir)/config/i386/sol2-cn.asm >crtn.s + $(AS) -o crtn.o crtn.s + +# We need to use -fPIC when we are using gcc to compile the routines in +# crtstuff.c. This is only really needed when we are going to use gcc/g++ +# to produce a shared library, but since we don't know ahead of time when +# we will be doing that, we just always use -fPIC when compiling the +# routines in crtstuff.c. + +CRTSTUFF_T_CFLAGS = -fPIC diff --git a/support/cpp/i386/t-svr3dbx b/support/cpp/i386/t-svr3dbx new file mode 100644 index 00000000..51711379 --- /dev/null +++ b/support/cpp/i386/t-svr3dbx @@ -0,0 +1,7 @@ +# gas 1.38.1 supporting dbx-in-coff requires a link script. + +svr3.ifile: $(srcdir)/config/i386/svr3.ifile + rm -f svr3.ifile; cp $(srcdir)/config/i386/svr3.ifile . + +svr3z.ifile: $(srcdir)/config/i386/svr3z.ifile + rm -f svr3z.ifile; cp $(srcdir)/config/i386/svr3z.ifile . diff --git a/support/cpp/i386/t-vsta b/support/cpp/i386/t-vsta new file mode 100644 index 00000000..6160b7ec --- /dev/null +++ b/support/cpp/i386/t-vsta @@ -0,0 +1,2 @@ +LIBGCC1 = libgcc1.null +CROSS_LIBGCC1 = libgcc1.null diff --git a/support/cpp/i386/t-winnt b/support/cpp/i386/t-winnt new file mode 100644 index 00000000..e8e1a0af --- /dev/null +++ b/support/cpp/i386/t-winnt @@ -0,0 +1,2 @@ +winnt.o: $(srcdir)/config/i386/winnt.c + $(CC) -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/i386/winnt.c diff --git a/support/cpp/i386/tmp b/support/cpp/i386/tmp new file mode 100644 index 00000000..d36d2cdb --- /dev/null +++ b/support/cpp/i386/tmp @@ -0,0 +1,24 @@ +/* Configuration for GNU compiler + for an Intel i386 or later processor running Windows NT 3.x. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "winnt/xm-winnt.h" +#include "i386/xm-i386.h" diff --git a/support/cpp/i386/unix.h b/support/cpp/i386/unix.h new file mode 100644 index 00000000..f38fe270 --- /dev/null +++ b/support/cpp/i386/unix.h @@ -0,0 +1,148 @@ +/* Definitions for Unix assembler syntax for the Intel 80386. + Copyright (C) 1988, 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This file defines the aspects of assembler syntax + that are the same for all the i386 Unix systems + (though they may differ in non-Unix systems). */ + +/* Define some concatenation macros to concatenate an opcode + and one, two or three operands. In other assembler syntaxes + they may alter the order of ther operands. */ + +/* Note that the other files fail to use these + in some of the places where they should. */ + +#if defined(__STDC__) || defined(ALMOST_STDC) +#define AS2(a,b,c) #a " " #b "," #c +#define AS2C(b,c) " " #b "," #c +#define AS3(a,b,c,d) #a " " #b "," #c "," #d +#define AS1(a,b) #a " " #b +#else +#define AS1(a,b) "a b" +#define AS2(a,b,c) "a b,c" +#define AS2C(b,c) " b,c" +#define AS3(a,b,c,d) "a b,c,d" +#endif + +/* Define macro used to output shift-double opcodes when the shift + count is in %cl. Some assemblers require %cl as an argument; + some don't. This macro controls what to do: by default, don't + print %cl. */ +#define AS3_SHIFT_DOUBLE(a,b,c,d) AS2 (a,c,d) + +/* Output the size-letter for an opcode. + CODE is the letter used in an operand spec (L, B, W, S or Q). + CH is the corresponding lower case letter + (except if CODE is `Q' then CH is `l', unless GAS_MNEMONICS). */ +#define PUT_OP_SIZE(CODE,CH,FILE) putc (CH,(FILE)) + +/* Opcode suffix for fullword insn. */ +#define L_SIZE "l" + +/* Prefix for register names in this syntax. */ +#define RP "%" + +/* Prefix for immediate operands in this syntax. */ +#define IP "$" + +/* Indirect call instructions should use `*'. */ +#define USE_STAR 1 + +/* Prefix for a memory-operand X. */ +#define PRINT_PTR(X, FILE) + +/* Delimiters that surround base reg and index reg. */ +#define ADDR_BEG(FILE) putc('(', (FILE)) +#define ADDR_END(FILE) putc(')', (FILE)) + +/* Print an index register (whose rtx is IREG). */ +#define PRINT_IREG(FILE,IREG) \ + do \ + { fputs (",", (FILE)); PRINT_REG ((IREG), 0, (FILE)); } \ + while (0) + +/* Print an index scale factor SCALE. */ +#define PRINT_SCALE(FILE,SCALE) \ + if ((SCALE) != 1) fprintf ((FILE), ",%d", (SCALE)) + +/* Print a base/index combination. + BREG is the base reg rtx, IREG is the index reg rtx, + and SCALE is the index scale factor (an integer). */ + +#define PRINT_B_I_S(BREG,IREG,SCALE,FILE) \ + { ADDR_BEG (FILE); \ + if (BREG) PRINT_REG ((BREG), 0, (FILE)); \ + if ((IREG) != 0) \ + { PRINT_IREG ((FILE), (IREG)); \ + PRINT_SCALE ((FILE), (SCALE)); } \ + ADDR_END (FILE); } + +/* Define the syntax of pseudo-ops, labels and comments. */ + +/* String containing the assembler's comment-starter. */ + +#define ASM_COMMENT_START "/" +#define COMMENT_BEGIN "/" + +/* Output to assembler file text saying following lines + may contain character constants, extra white space, comments, etc. */ + +#define ASM_APP_ON "/APP\n" + +/* Output to assembler file text saying following lines + no longer contain unusual constructs. */ + +#define ASM_APP_OFF "/NO_APP\n" + +/* Output before read-only data. */ + +#define TEXT_SECTION_ASM_OP ".text" + +/* Output before writable (initialized) data. */ + +#define DATA_SECTION_ASM_OP ".data" + +/* Output before writable (uninitialized) data. */ + +#define BSS_SECTION_ASM_OP ".bss" + +/* This is how to output a command to make the user-level label named NAME + defined for reference from other files. */ + +#define ASM_GLOBALIZE_LABEL(FILE,NAME) \ + (fputs (".globl ", FILE), assemble_name (FILE, NAME), fputs ("\n", FILE)) + +/* By default, target has a 80387, uses IEEE compatible arithmetic, + and returns float values in the 387, ie, + (TARGET_80387 | TARGET_IEEE_FP | TARGET_FLOAT_RETURNS_IN_80387) */ + +#define TARGET_DEFAULT 0301 + +/* Floating-point return values come in the FP register. */ + +#define VALUE_REGNO(MODE) \ + (GET_MODE_CLASS (MODE) == MODE_FLOAT \ + && TARGET_FLOAT_RETURNS_IN_80387 ? FIRST_FLOAT_REG : 0) + +/* 1 if N is a possible register number for a function value. */ + +#define FUNCTION_VALUE_REGNO_P(N) \ + ((N) == 0 || ((N)== FIRST_FLOAT_REG && TARGET_FLOAT_RETURNS_IN_80387)) + diff --git a/support/cpp/i386/v3gas.h b/support/cpp/i386/v3gas.h new file mode 100644 index 00000000..fe558d26 --- /dev/null +++ b/support/cpp/i386/v3gas.h @@ -0,0 +1,80 @@ +/* Definitions for Intel 386 running system V, using gas. + Copyright (C) 1992, 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + +/* Add stuff that normally comes from i386v.h */ + +/* longjmp may fail to restore the registers if called from the same + function that called setjmp. To compensate, the compiler avoids + putting variables in registers in functions that use both setjmp + and longjmp. */ + +#define NON_SAVING_SETJMP \ + (current_function_calls_setjmp && current_function_calls_longjmp) + +/* longjmp may fail to restore the stack pointer if the saved frame + pointer is the same as the caller's frame pointer. Requiring a frame + pointer in any function that calls setjmp or longjmp avoids this + problem, unless setjmp and longjmp are called from the same function. + Since a frame pointer will be required in such a function, it is OK + that the stack pointer is not restored. */ + +#undef FRAME_POINTER_REQUIRED +#define FRAME_POINTER_REQUIRED \ + (current_function_calls_setjmp || current_function_calls_longjmp) + +/* Modify ASM_OUTPUT_LOCAL slightly to test -msvr3-shlib, adapted to gas */ +#undef ASM_OUTPUT_LOCAL +#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ + do { \ + int align = exact_log2 (ROUNDED); \ + if (align > 2) align = 2; \ + if (TARGET_SVR3_SHLIB) \ + { \ + data_section (); \ + ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \ + ASM_OUTPUT_LABEL ((FILE), (NAME)); \ + fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)); \ + } \ + else \ + { \ + fputs (".lcomm ", (FILE)); \ + assemble_name ((FILE), (NAME)); \ + fprintf ((FILE), ",%u\n", (ROUNDED)); \ + } \ + } while (0) + +/* Add stuff that normally comes from i386v.h via svr3.h */ + +/* Define the actual types of some ANSI-mandated types. These + definitions should work for most SVR3 systems. */ + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "long int" + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE BITS_PER_WORD diff --git a/support/cpp/i386/vsta.h b/support/cpp/i386/vsta.h new file mode 100644 index 00000000..ee7fab91 --- /dev/null +++ b/support/cpp/i386/vsta.h @@ -0,0 +1,78 @@ +/* Configuration for an i386 running VSTa micro-kernel. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Rob Savoye (rob@cygnus.com). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define YES_UNDERSCORES + +#include "i386/gas.h" + +#ifdef CPP_PREDEFINES +#undef CPP_PREDEFINES +#endif +#define CPP_PREDEFINES "-Dunix -Di386 -DVSTA \ + -Asystem(unix) -Asystem(vsta) -Acpu(i386) -Amachine(i386)" + +#undef EXTRA_SECTIONS +#define EXTRA_SECTIONS in_ctor, in_dtor + +#undef EXTRA_SECTION_FUNCTIONS +#define EXTRA_SECTION_FUNCTIONS \ + CTOR_SECTION_FUNCTION \ + DTOR_SECTION_FUNCTION + +#define CTOR_SECTION_FUNCTION \ +void \ +ctor_section () \ +{ \ + if (in_section != in_ctor) \ + { \ + fprintf (asm_out_file, "\t.section .ctor\n"); \ + in_section = in_ctor; \ + } \ +} + +#define DTOR_SECTION_FUNCTION \ +void \ +dtor_section () \ +{ \ + if (in_section != in_dtor) \ + { \ + fprintf (asm_out_file, "\t.section .dtor\n"); \ + in_section = in_dtor; \ + } \ +} + +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + ctor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + +#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ + do { \ + dtor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + + diff --git a/support/cpp/i386/win-nt.h b/support/cpp/i386/win-nt.h new file mode 100644 index 00000000..60c0bb6a --- /dev/null +++ b/support/cpp/i386/win-nt.h @@ -0,0 +1,152 @@ +/* Operating system specific defines to be used when targeting GCC for + Windows NT 3.x on an i386. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define YES_UNDERSCORES + +#include "i386/gas.h" + +#ifdef CPP_PREDEFINES +#undef CPP_PREDEFINES +#endif +#define CPP_PREDEFINES "-Dunix -Di386 -DWIN32 -D_WIN32 \ + -DWINNT -D_M_IX86=300 -D_X86_=1 -D__STDC__=0 -DALMOST_STDC -D_MSC_VER=800 \ + -D__stdcall=__attribute__((__stdcall__)) \ + -D__cdecl=__attribute__((__cdecl__)) \ + -D_cdecl=__attribute__((__cdecl__)) \ + -Asystem(unix) -Asystem(winnt) -Acpu(i386) -Amachine(i386)" + +#define SIZE_TYPE "unsigned int" +#define PTRDIFF_TYPE "int" +#define WCHAR_UNSIGNED 1 +#define WCHAR_TYPE_SIZE 16 +#define WCHAR_TYPE "short unsigned int" +#undef LONG_DOUBLE_TYPE_SIZE +#define LONG_DOUBLE_TYPE_SIZE 64 +#define HAVE_ATEXIT 1 + +#undef EXTRA_SECTIONS +#define EXTRA_SECTIONS in_ctor, in_dtor + +#undef EXTRA_SECTION_FUNCTIONS +#define EXTRA_SECTION_FUNCTIONS \ + CTOR_SECTION_FUNCTION \ + DTOR_SECTION_FUNCTION + +#define CTOR_SECTION_FUNCTION \ +void \ +ctor_section () \ +{ \ + if (in_section != in_ctor) \ + { \ + fprintf (asm_out_file, "\t.section .ctor\n"); \ + in_section = in_ctor; \ + } \ +} + +#define DTOR_SECTION_FUNCTION \ +void \ +dtor_section () \ +{ \ + if (in_section != in_dtor) \ + { \ + fprintf (asm_out_file, "\t.section .dtor\n"); \ + in_section = in_dtor; \ + } \ +} + +#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ + do { \ + ctor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + +#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ + do { \ + dtor_section (); \ + fprintf (FILE, "%s\t", ASM_LONG); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, "\n"); \ + } while (0) + +/* Define this macro if references to a symbol must be treated + differently depending on something about the variable or + function named by the symbol (such as what section it is in). + + On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol + so that we may access it directly in the GOT. + + On i386 running Windows NT, modify the assembler name with a suffix + consisting of an atsign (@) followed by string of digits that represents + the number of bytes of arguments passed to the function, if it has the + attribute STDCALL. */ + +#ifdef ENCODE_SECTION_INFO +#undef ENCODE_SECTION_INFO +#define ENCODE_SECTION_INFO(DECL) \ +do \ + { \ + if (flag_pic) \ + { \ + rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \ + SYMBOL_REF_FLAG (XEXP (rtl, 0)) \ + = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ + || ! TREE_PUBLIC (DECL)); \ + } \ + if (TREE_CODE (DECL) == FUNCTION_DECL) \ + if (lookup_attribute ("stdcall", \ + TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \ + XEXP (DECL_RTL (DECL), 0) = \ + gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \ + } \ +while (0) +#endif + +/* The global __fltused is necessary to cause the printf/scanf routines + for outputting/inputting floating point numbers to be loaded. Since this + is kind of hard to detect, we just do it all the time. */ + +#ifdef ASM_FILE_START +#undef ASM_FILE_START +#endif +#define ASM_FILE_START(FILE) \ + do { fprintf (FILE, "\t.file\t"); \ + output_quoted_string (FILE, dump_base_name); \ + fprintf (FILE, "\n"); \ + fprintf (FILE, ".global\t__fltused\n"); \ + } while (0) + +/* if the switch "-mwindows" is passed to ld, then specify to the Microsoft + linker the proper switches and libraries to build a graphical program */ + +#undef LIB_SPEC +#define LIB_SPEC "%{mwindows:-subsystem windows -e _WinMainCRTStartup \ + USER32.LIB%s GDI32.LIB%s COMDLG32.LIB%s WINSPOOL.LIB%s} \ + %{!mwindows:-subsystem console -e _mainCRTStartup} \ + %{mcrtmt:LIBCMT.LIB%s KERNEL32.LIB%s ADVAPI32.LIB%s} \ + %{!mcrtmt:LIBC.LIB%s KERNEL32.LIB%s ADVAPI32.LIB%s} \ + %{v}" + +#include "winnt/win-nt.h" + diff --git a/support/cpp/i386/winnt.c b/support/cpp/i386/winnt.c new file mode 100644 index 00000000..3a7ebf1b --- /dev/null +++ b/support/cpp/i386/winnt.c @@ -0,0 +1,60 @@ +/* Subroutines for insn-output.c for Windows NT. + Contributed by Douglas Rupp (drupp@cs.washington.edu) + Copyright (C) 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include +#include "config.h" +#include "rtl.h" +#include "regs.h" +#include "hard-reg-set.h" +#include "output.h" +#include "tree.h" +#include "flags.h" + +/* Return string which is the former assembler name modified with a + suffix consisting of an atsign (@) followed by the number of bytes of + arguments */ + +char * +gen_stdcall_suffix (decl) + tree decl; +{ + int total = 0; + char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + char *newsym; + + if (TYPE_ARG_TYPES (TREE_TYPE (decl))) + if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl)))) + == void_type_node) + { + tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl)); + + while (TREE_VALUE (formal_type) != void_type_node) + { + total += TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type))); + formal_type = TREE_CHAIN (formal_type); + } + } + + newsym = xmalloc (strlen (asmname) + 10); + sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT); + return IDENTIFIER_POINTER (get_identifier (newsym)); +} + diff --git a/support/cpp/i386/x-aix b/support/cpp/i386/x-aix new file mode 100644 index 00000000..b191e48f --- /dev/null +++ b/support/cpp/i386/x-aix @@ -0,0 +1,12 @@ +# There is an alloca in -lbsd, but it is limited to 32K +ALLOCA = alloca.o + +# If you are running out of memory while compiling gcc, with the standard +# /bin/cc uncomment MALLOCLIB line. That version of malloc is slower but +# has less overhead than the one in libc. +#MALLOCLIB = -lmalloc + +# Uncomment out the next line if you want to link with the shareable libc_s. +#CLIB_S = -lc_s + +CLIB = -lld $(MALLOCLIB) $(CLIB_S) diff --git a/support/cpp/i386/x-freebsd b/support/cpp/i386/x-freebsd new file mode 100644 index 00000000..a9b13ba5 --- /dev/null +++ b/support/cpp/i386/x-freebsd @@ -0,0 +1,3 @@ +# Don't run fixproto +STMP_FIXPROTO = +CLIB=-lgnumalloc diff --git a/support/cpp/i386/x-isc b/support/cpp/i386/x-isc new file mode 100644 index 00000000..ea65ec88 --- /dev/null +++ b/support/cpp/i386/x-isc @@ -0,0 +1,3 @@ +CLIB = -lPW -lcposix +X_CFLAGS = -D_POSIX_SOURCE +ENQUIRE_LDFLAGS = -posix $(LDFLAGS) diff --git a/support/cpp/i386/x-isc3 b/support/cpp/i386/x-isc3 new file mode 100644 index 00000000..527cca81 --- /dev/null +++ b/support/cpp/i386/x-isc3 @@ -0,0 +1,4 @@ +CLIB = -lPW +# One person said it needs -DPOSIX_JC, but daa@CERF.NET says no. +X_CFLAGS = -D_SYSV3 -Xp +ENQUIRE_LDFLAGS = $(LDFLAGS) diff --git a/support/cpp/i386/x-ncr3000 b/support/cpp/i386/x-ncr3000 new file mode 100644 index 00000000..4ae168b1 --- /dev/null +++ b/support/cpp/i386/x-ncr3000 @@ -0,0 +1,34 @@ +# Makefile additions for the NCR3000 as host system. + +# Using -O with the AT&T compiler fails, with a message about a missing +# /usr/ccs/lib/optim pass. So override the default in Makefile.in + +CCLIBFLAGS= + +## Supposedly not needed now that xm-sysv4.h includes alloc.h for Metaware. +### NCR3000 ships with a MetaWare compiler installed as CC, which chokes and +### dies all over the place on GCC source. However, the AT&T compiler, +### crusty as it is, can be used to bootstrap GCC. It can be found in +### /usr/ccs/ATT/cc. It is also used to compile the things that should +### not be compiled with GCC. +## +##CC = /usr/ccs/ATT/cc +##OLDCC = /usr/ccs/ATT/cc + +# The rest is just x-i386v4. + +# Some versions of SVR4 have an alloca in /usr/ucblib/libucb.a, and if we are +# careful to link that in after libc we can use it, but since newer versions of +# SVR4 are dropping libucb, it is better to just use the portable C version for +# bootstrapping. Do this by defining ALLOCA. + +ALLOCA = alloca.o + +# We used to build all stages *without* shared libraries because that may make +# debugging the compiler easier (until there is a GDB which supports +# both Dwarf *and* svr4 shared libraries). + +# But james@bigtex.cactus.org says that redefining GCC_CFLAGS causes trouble, +# and that it is easy enough to debug using shared libraries. +# CCLIBFLAGS=-Bstatic -dn -g +# GCC_CFLAGS=-static -g -O2 -B./ diff --git a/support/cpp/i386/x-next b/support/cpp/i386/x-next new file mode 100644 index 00000000..a16b918e --- /dev/null +++ b/support/cpp/i386/x-next @@ -0,0 +1,3 @@ +# Make assignments for compiling on NeXT with their compiler version. +CC=cc -traditional-cpp +OLDCC=cc -traditional-cpp diff --git a/support/cpp/i386/x-osfrose b/support/cpp/i386/x-osfrose new file mode 100644 index 00000000..a419bdb7 --- /dev/null +++ b/support/cpp/i386/x-osfrose @@ -0,0 +1,31 @@ +# Define CC and OLDCC as the same, so that the tests: +# if [ x"$(OLDCC)" = x"$(CC)" ] ... +# +# will succeed (if OLDCC != CC, it is assumed that GCC is +# being used in secondary stage builds). + +BUILD = +CC = $(OLDCC) +CLIB = -lld +X_CFLAGS = $(DEB_OPT) $(MSTATS) $(SHLIB) $(X_DEFINES) +X_CFLAGS_NODEBUG = $(NO_DEBUG) $(MSTATS) $(OPT) $(PROFILE) $(SHLIB) $(X_DEFINES) $(XCFLAGS) +CPP_ABORT = # -Dabort=fancy_abort +CPPFLAGS = $(CPP_ABORT) $(SYSTEM_INCLUDES) +DEB_OPT = $(OPT) $(DEBUG) $(PROFILE) +DEBUG = +DEBUG_COLLECT = # -DDEBUG +CCLIBFLAGS = -O -DNO_HALF_PIC +GCC_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) -B./ -DPOSIX -DNO_HALF_PIC +INSTALL = installbsd -c +LDFLAGS = +MSTATS = # -mstats +OLDCC = /usr/ccs/gcc/gcc +OPT = -O +PROFILE = +SHLIB = -pic-none +SYSTEM_INCLUDES = # -I${BUILD}/usr/include +X_DEFINES = -Dvfork=fork + +libdir = /usr/ccs +mandir = /usr/ccs/gcc/$(target)/$(version) +bindir = /usr/ccs/gcc/$(target)/$(version) diff --git a/support/cpp/i386/x-sco b/support/cpp/i386/x-sco new file mode 100644 index 00000000..f7f14e9f --- /dev/null +++ b/support/cpp/i386/x-sco @@ -0,0 +1,7 @@ +RANLIB = : +RANLIB_TEST = false +CC = rcc $(RCCFLAGS) +OLDCC = rcc $(RCCFLAGS) +RCCFLAGS = -Dunix -Di386 -DM_UNIX -DM_I386 -DNULL=0 +CCLIBFLAGS = +CLIB = -lmalloc -lPW diff --git a/support/cpp/i386/x-sco4 b/support/cpp/i386/x-sco4 new file mode 100644 index 00000000..be6080f8 --- /dev/null +++ b/support/cpp/i386/x-sco4 @@ -0,0 +1,10 @@ +RANLIB = : +RANLIB_TEST = false +CC = rcc $(RCCFLAGS) +OLDCC = rcc $(RCCFLAGS) +RCCFLAGS = -Dunix -Di386 -DM_UNIX -DM_I386 -DNULL=0 +CCLIBFLAGS = +CLIB = -lmalloc -lPW + +# See all the declarations. +FIXPROTO_DEFINES = -D_XOPEN_SOURCE diff --git a/support/cpp/i386/x-sysv3 b/support/cpp/i386/x-sysv3 new file mode 100644 index 00000000..a1391df8 --- /dev/null +++ b/support/cpp/i386/x-sysv3 @@ -0,0 +1 @@ +CLIB=-lPW diff --git a/support/cpp/i386/x-vsta b/support/cpp/i386/x-vsta new file mode 100644 index 00000000..e2279a4b --- /dev/null +++ b/support/cpp/i386/x-vsta @@ -0,0 +1 @@ +CLIB=-lm diff --git a/support/cpp/i386/xm-aix.h b/support/cpp/i386/xm-aix.h new file mode 100644 index 00000000..5e5d4028 --- /dev/null +++ b/support/cpp/i386/xm-aix.h @@ -0,0 +1,37 @@ +/* Configuration for GNU C-compiler for IBM PS/2 running AIX/386. + Copyright (C) 1988, 1993 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define USG + +#undef TRUE +#undef FALSE + +#include "i386/xm-i386.h" + +#define bcopy(a,b,c) memcpy (b,a,c) +#define bzero(a,b) memset (a,0,b) +#define bcmp(a,b,c) memcmp (a,b,c) + +/* If not compiled with GNU C, use the portable alloca. */ +#ifndef __GNUC__ +#define USE_C_ALLOCA +#endif + +#define HAVE_PUTENV diff --git a/support/cpp/i386/xm-bsd386.h b/support/cpp/i386/xm-bsd386.h new file mode 100644 index 00000000..9deb7ef6 --- /dev/null +++ b/support/cpp/i386/xm-bsd386.h @@ -0,0 +1,6 @@ +/* Configuration for GCC for Intel i386 running BSDI's BSD/386 as host. */ + +#include "i386/xm-i386.h" + +#define HAVE_STRERROR + diff --git a/support/cpp/i386/xm-dos.h b/support/cpp/i386/xm-dos.h new file mode 100644 index 00000000..1dd0c013 --- /dev/null +++ b/support/cpp/i386/xm-dos.h @@ -0,0 +1,20 @@ +#include "i386/xm-i386.h" + +/* Inhibit cccp.c's definition of putenv. */ +#define HAVE_PUTENV + +/* Use semicolons to separate elements of a path. */ +#define PATH_SEPARATOR ';' + +/* Use backslashs to separate levels of directory. */ +#define DIR_SEPARATOR '\\' + +/* Suffix for executable file names. */ +#define EXECUTABLE_SUFFIX ".exe" + +#define MKTEMP_EACH_FILE 1 + +#define NO_PRECOMPILES 1 + +/* sys_errlist proto in cccp.c doesn't match djgpp */ +#define HAVE_STRERROR diff --git a/support/cpp/i386/xm-freebsd.h b/support/cpp/i386/xm-freebsd.h new file mode 100644 index 00000000..007a609f --- /dev/null +++ b/support/cpp/i386/xm-freebsd.h @@ -0,0 +1,4 @@ +/* Configuration for GCC for Intel i386 running FreeBSD as host. */ + +#include +#include diff --git a/support/cpp/i386/xm-gnu.h b/support/cpp/i386/xm-gnu.h new file mode 100644 index 00000000..0b5985f9 --- /dev/null +++ b/support/cpp/i386/xm-gnu.h @@ -0,0 +1,5 @@ +/* Configuration for GCC for Intel i386 running GNU as host. */ + +#include +#include + diff --git a/support/cpp/i386/xm-i386.h b/support/cpp/i386/xm-i386.h new file mode 100644 index 00000000..acc16576 --- /dev/null +++ b/support/cpp/i386/xm-i386.h @@ -0,0 +1,43 @@ +/* Configuration for GNU C-compiler for Intel 80386. + Copyright (C) 1988, 1993 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef i386 +#define i386 +#endif + +/* #defines that need visibility everywhere. */ +#define FALSE 0 +#define TRUE 1 + +/* This describes the machine the compiler is hosted on. */ +#define HOST_BITS_PER_CHAR 8 +#define HOST_BITS_PER_SHORT 16 +#define HOST_BITS_PER_INT 32 +#define HOST_BITS_PER_LONG 32 +#define HOST_BITS_PER_LONGLONG 64 + +/* Arguments to use with `exit'. */ +#define SUCCESS_EXIT_CODE 0 +#define FATAL_EXIT_CODE 33 + +/* target machine dependencies. + tm.h is a symbolic link to the actual target specific file. */ + +#include "tm.h" diff --git a/support/cpp/i386/xm-isc.h b/support/cpp/i386/xm-isc.h new file mode 100644 index 00000000..7a0a47c4 --- /dev/null +++ b/support/cpp/i386/xm-isc.h @@ -0,0 +1,6 @@ +#include "i386/xm-sysv3.h" + +#ifndef REAL_ARITHMETIC +#define REAL_VALUE_ATOF(x, mode) strtod ((x), (char **)0) +extern double strtod (); +#endif diff --git a/support/cpp/i386/xm-linux.h b/support/cpp/i386/xm-linux.h new file mode 100644 index 00000000..d5e97b8a --- /dev/null +++ b/support/cpp/i386/xm-linux.h @@ -0,0 +1,24 @@ +/* Configuration for GCC for Intel i386 running Linux. + Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. + Contributed by H.J. Lu (hjl@nynexst.com) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include +/* #include */ + diff --git a/support/cpp/i386/xm-lynx.h b/support/cpp/i386/xm-lynx.h new file mode 100644 index 00000000..359e41bb --- /dev/null +++ b/support/cpp/i386/xm-lynx.h @@ -0,0 +1,33 @@ +/* Configuration for GNU C-compiler for i386 platforms running LynxOS. + Copyright (C) 1995 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + +/* This describes the machine the compiler is hosted on. */ +#define HOST_BITS_PER_CHAR 8 +#define HOST_BITS_PER_SHORT 16 +#define HOST_BITS_PER_INT 32 +#define HOST_BITS_PER_LONG 32 +#define HOST_BITS_PER_LONGLONG 64 + +/* target machine dependencies. + tm.h is a symbolic link to the actual target specific file. */ + +#include "tm.h" diff --git a/support/cpp/i386/xm-netbsd.h b/support/cpp/i386/xm-netbsd.h new file mode 100644 index 00000000..3a9f3241 --- /dev/null +++ b/support/cpp/i386/xm-netbsd.h @@ -0,0 +1,4 @@ +/* Configuration for GCC for Intel i386 running NetBSD as host. */ + +#include +#include diff --git a/support/cpp/i386/xm-next.h b/support/cpp/i386/xm-next.h new file mode 100644 index 00000000..bf903281 --- /dev/null +++ b/support/cpp/i386/xm-next.h @@ -0,0 +1,5 @@ +#include "i386/xm-i386.h" + +/* malloc does better with chunks the size of a page. */ + +#define OBSTACK_CHUNK_SIZE (getpagesize ()) diff --git a/support/cpp/i386/xm-os2.h b/support/cpp/i386/xm-os2.h new file mode 100644 index 00000000..5ff2899c --- /dev/null +++ b/support/cpp/i386/xm-os2.h @@ -0,0 +1,57 @@ +/* Configuration for GNU compiler + for an Intel i386 or later processor running OS/2 2.x. + Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. + Contributed by Samuel Figueroa (figueroa@cs.nyu.edu) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifndef OS2 +#define OS2 +#endif + +#ifdef __IBMC__ +#include /* this defines alloca */ +#define USG +#define ONLY_INT_FIELDS +#define HAVE_PUTENV +#define USE_PROTOTYPES 1 +#define bcmp(a,b,c) memcmp (a,b,c) +#define bcopy(a,b,c) memcpy (b,a,c) +#define bzero(a,b) memset (a,0,b) +#define index strchr +#define rindex strrchr +#define strcasecmp stricmp +#define kill(a,b) raise(b) +#define mktemp tmpnam +#else +#define ____386BSD____ +int spawnv (int modeflag, char *path, char *argv[]); +int spawnvp (int modeflag, char *path, char *argv[]); +#endif /* __IBMC__ */ + +#ifndef PATH_SEPARATOR +#define PATH_SEPARATOR ';' +#endif +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '\\' +#endif + +#define EXECUTABLE_SUFFIX ".exe" +#define OBJECT_SUFFIX ".obj" + +#include "i386/xm-i386.h" diff --git a/support/cpp/i386/xm-osf.h b/support/cpp/i386/xm-osf.h new file mode 100644 index 00000000..fda50d98 --- /dev/null +++ b/support/cpp/i386/xm-osf.h @@ -0,0 +1,32 @@ +/* Configuration for GNU C-compiler for 386 running OSF/1 + Copyright (C) 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#undef TRUE +#undef FALSE + +#include "i386/xm-i386.h" + +#define bcopy(a,b,c) memcpy (b,a,c) +#define bzero(a,b) memset (a,0,b) +#define bcmp(a,b,c) memcmp (a,b,c) + +#define HAVE_PUTENV +#define HAVE_VPRINTF + diff --git a/support/cpp/i386/xm-sco.h b/support/cpp/i386/xm-sco.h new file mode 100644 index 00000000..01a63d90 --- /dev/null +++ b/support/cpp/i386/xm-sco.h @@ -0,0 +1,22 @@ +/* Configuration for GCC for Intel i386 running SCO. */ + +#include "i386/xm-sysv3.h" + +/* On SCO 3.2.1, ldexp rejects values outside [0.5, 1). */ + +#define BROKEN_LDEXP + +/* Big buffers improve performance. */ + +#define IO_BUFFER_SIZE (0x8000 - 1024) + +/* SCO has a very small ARG_MAX. */ +#define SMALL_ARG_MAX + +#ifndef __GNUC__ +/* The SCO compiler gets it wrong, and treats enumerated bitfields + as signed quantities, making it impossible to use an 8-bit enum + for compiling GNU C++. */ +#define ONLY_INT_FIELDS 1 +#define CODE_FIELD_BUG 1 +#endif diff --git a/support/cpp/i386/xm-sun.h b/support/cpp/i386/xm-sun.h new file mode 100644 index 00000000..d2e714ec --- /dev/null +++ b/support/cpp/i386/xm-sun.h @@ -0,0 +1,27 @@ +/* Configuration for GNU C-compiler for Intel 80386 running SunOS 4.0. + Copyright (C) 1988 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define USG + +#include "i386/xm-i386.h" + +#define bcopy(a,b,c) memcpy (b,a,c) +#define bzero(a,b) memset (a,0,b) +#define bcmp(a,b,c) memcmp (a,b,c) diff --git a/support/cpp/i386/xm-sysv3.h b/support/cpp/i386/xm-sysv3.h new file mode 100644 index 00000000..72078bb1 --- /dev/null +++ b/support/cpp/i386/xm-sysv3.h @@ -0,0 +1,4 @@ +/* Configuration for GCC for Intel i386 running System V Release 3. */ + +#include "i386/xm-i386.h" +#include "xm-svr3.h" diff --git a/support/cpp/i386/xm-sysv4.h b/support/cpp/i386/xm-sysv4.h new file mode 100644 index 00000000..49d52b4e --- /dev/null +++ b/support/cpp/i386/xm-sysv4.h @@ -0,0 +1,16 @@ +/* Configuration for GCC for Intel i386 running System V Release 4. */ + +#include "i386/xm-i386.h" +#include "xm-svr4.h" + +/* If not compiled with GNU C, use the portable alloca. */ +#ifndef __GNUC__ +#define USE_C_ALLOCA +#endif +#ifdef __HIGHC__ +#include /* for MetaWare High-C on NCR System 3000 */ +#endif + +/* Univel, at least, has a small ARG_MAX. Defining this is harmless + except for causing extra stat calls in the driver program. */ +#define SMALL_ARG_MAX diff --git a/support/cpp/i386/xm-vsta.h b/support/cpp/i386/xm-vsta.h new file mode 100644 index 00000000..bb333aea --- /dev/null +++ b/support/cpp/i386/xm-vsta.h @@ -0,0 +1,26 @@ +/* Configuration for GNU C-compiler for Intel 80386. + Copyright (C) 1994 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define NO_STAB_H + +#include "i386/xm-i386.h" + +/* Use semicolons to separate elements of a path. */ +#define PATH_SEPARATOR ';' diff --git a/support/cpp/i386/xm-winnt.h b/support/cpp/i386/xm-winnt.h new file mode 100644 index 00000000..d36d2cdb --- /dev/null +++ b/support/cpp/i386/xm-winnt.h @@ -0,0 +1,24 @@ +/* Configuration for GNU compiler + for an Intel i386 or later processor running Windows NT 3.x. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "winnt/xm-winnt.h" +#include "i386/xm-i386.h" diff --git a/support/cpp/tm.h b/support/cpp/tm.h new file mode 100644 index 00000000..0fb54981 --- /dev/null +++ b/support/cpp/tm.h @@ -0,0 +1 @@ +#include "i386/win-nt.h" diff --git a/support/cpp/winnt/Makefile b/support/cpp/winnt/Makefile new file mode 100644 index 00000000..1a8f5824 --- /dev/null +++ b/support/cpp/winnt/Makefile @@ -0,0 +1,6 @@ +# Makefile generated by "config-nt.bat" +all.nt: cpp.exe cc1.exe cc1obj.exe xgcc.exe ld.exe stmp-headers libgcc.lib stmp-float_h specs stamp-objlist +lang.mostlyclean: +lang.clean: +lang.distclean: +lang.realclean: diff --git a/support/cpp/winnt/config-nt.bat b/support/cpp/winnt/config-nt.bat new file mode 100755 index 00000000..59a00863 --- /dev/null +++ b/support/cpp/winnt/config-nt.bat @@ -0,0 +1,51 @@ +echo Configuring GCC for Windows NT on %2 +rem This batch file assumes a unix-type "sed" program + +echo #include "%2/xm-winnt.h" >config.h +echo #include "%2/xm-winnt.h" >hconfig.h +echo #include "%2/xm-winnt.h" >tconfig.h +echo #include "%2/win-nt.h" >tm.h + +rem This batch file assumes a unix-type "sed" program + +echo # Makefile generated by "config-nt.bat"> Makefile +echo all.nt: cpp.exe cc1.exe cc1obj.exe xgcc.exe ld.exe stmp-headers libgcc.lib stmp-float_h specs stamp-objlist>> Makefile +sed -f config/%2/config-nt.sed -f config/winnt/config-nt.sed Makefile.in >> Makefile + +set LANG= + +echo # >specs.h +echo # >options.h + +if not exist cp\make-lang.in goto no_cp +if exist cp\lang-specs.h echo #include "cp/lang-specs.h">>specs.h +if exist cp\lang-options.h echo #include "cp/lang-options.h">>options.h +sed -f config/%2/config-nt.sed -f config/winnt/config-nt.sed cp\make-lang.in >> Makefile +sed -f config/%2/config-nt.sed -f config/winnt/config-nt.sed cp\makefile.in > cp\Makefile +set LANG=%LANG% c++.# +:no_cp + +if not exist ada\make-lang.in goto no_ada +if exist ada\lang-specs.h echo #include "ada/lang-specs.h">>specs.h +if exist ada\lang-options.h echo #include "ada/lang-options.h">>options.h +sed -f config/%2/config-nt.sed -f config/winnt/config-nt.sed ada\make-lang.in >> Makefile +sed -f config/%2/config-nt.sed -f config/winnt/config-nt.sed ada\makefile.in > ada\Makefile +set LANG=%LANG% ada.# +:no_ada + +if not exist f\make-lang.in goto no_f +if exist f\lang-specs.h echo #include "f/lang-specs.h">>specs.h +if exist f\lang-options.h echo #include "f/lang-options.h">>options.h +sed -f config/%2/config-nt.sed -f config/winnt/config-nt.sed f\make-lang.in >> Makefile +sed -f config/%2/config-nt.sed -f config/winnt/config-nt.sed f\makefile.in > f\Makefile +set LANG=%LANG% f.# +:no_f + +echo lang.mostlyclean: %LANG% | sed "s/#/mostlyclean/g" >> Makefile +echo lang.clean: %LANG% | sed "s/#/clean/g" >> Makefile +echo lang.distclean: %LANG% | sed "s/#/distclean/g" >> Makefile +echo lang.realclean: %LANG% | sed "s/#/realclean/g" >> Makefile + +echo #define MULTILIB_SELECT ". ;" > multilib.h1 +copy multilib.h1 multilib.h +del multilib.h1 diff --git a/support/cpp/winnt/config-nt.sed b/support/cpp/winnt/config-nt.sed new file mode 100644 index 00000000..d70f5c6c --- /dev/null +++ b/support/cpp/winnt/config-nt.sed @@ -0,0 +1,130 @@ +/^Makefile/,/^ rm -f config.run/d +s/rm -f/del/ +s/|| cp/|| copy/ +/^config.status/,/ fi/d +s/config.status//g +s/\/dev\/null/NUL/g +s/$(srcdir)\/c-parse/c-parse/g +s/$(srcdir)\/objc-parse.y/objc-parse.y/g +s/$(srcdir)\/c-gperf/c-gperf/g +/^multilib.h/ s/multilib/not-multilib/ +/^xmake_file=/ d +/^tmake_file=/ d +/^lang_specs_files=/ d +/^lang_options_files=/ d +/^version=/ c\ +version=2.7.2.1 +s/CC = cc/CC = cl/ +s/^SHELL =.*/SHELL =/ +s/CFLAGS = -g/CFLAGS =/ +s/:\$/: \$/g +s/<\ *\$(srcdir)\//< $(srcdir)\\/g +s/^ \$(srcdir)\/move-if-change/ copy/ +s/^USE_/# USE_/ +s/`echo \$(srcdir)\///g +s/ | sed 's,\^\\\.\/,,'`//g +s/^ cd \$(srcdir)[ ]*;/ / +/^stamp-attrtab/,/copy/ { + /\\$/d + / fi/d + /copy/ i\ +\ genattrtab $(md_file) > tmp-attrtab.c +} +/^enquire[ ]*:/ s/\$(GCC_PARTS)//g +/^enquire.o[ ]*:/ s/\$(GCC_PASSES)//g +/^GCC_FOR_TARGET =/ c\ +GCC_FOR_TARGET = xgcc +/^ENQUIRE_LDFLAGS =/ c\ +ENQUIRE_LDFLAGS = +s/; *@true// +/> *stamp-objlist/ c\ + echo.exe $(OBJS) $(BC_OBJS) | sed -e "s, \([a-z]\), ../\1,g" >stamp-objlist +/^OBJS.*stamp-objlist/ s?`cat ../stamp-objlist`?@../stamp-objlist? +s/^\(SUBDIR_OBSTACK *=\).*$/\1 ..\/obstack.o/ +s/^\(SUBDIR_USE_ALLOCA *=\).*$/\1/ +s/^\(SUBDIR_MALLOC *=\).*$/\1/ +/####target/ i\ +STMP_FIXPROTO = \ +OTHER_FIXINCLUDES_DIRS=. \ +RANLIB = : \ +RANLIB_TEST = false \ +OLDCC = cl \ +MAKE = nmake \ +SYMLINK = copy \ +INSTALL = $(srcdir)/install.sh -c \ +exeext = .exe \ +objext = .obj \ +oldobjext = .obj \ +\ +EXTRA_PROGRAMS=ld.exe \ +\ +ld.obj: $(srcdir)/config/winnt/ld.c \ +\ $(CC) $(CFLAGS) \\\ +\ -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/winnt/ld.c \ +\ +ld.exe: ld.obj \ + link -out:ld.exe ld.obj $(LDFLAGS) $(CLIB) \ +\ +EXTRA_GCC_OBJS=spawnv.obj oldnames.obj \ +spawnv.obj: $(srcdir)/config/winnt/spawnv.c \ +\ $(CC) $(CFLAGS) \\\ +\ -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/winnt/spawnv.c \ +\ +oldnames.obj: $(srcdir)/config/winnt/oldnames.c \ +\ $(CC) $(CFLAGS) \\\ +\ -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/winnt/oldnames.c +s/^C c:/Cc:/ +s/\${OBJS}/\$(OBJS)/g +s/\${SYSTEM_HEADER_DIR}/\$(SYSTEM_HEADER_DIR)/g +s/\${HOST_CC}/\$(HOST_CC)/g +s/ \${srcdir}\// /g +s/\${mainversion}/\$(mainversion)/g +s/\ $(srcdir)\/move-if-change$// +s/\$(srcdir)\/move-if-change/copy/g +/^# USE_HOST_OBSTACK/ i\ +USE_HOST_OBSTACK=obstack.obj +/^# USE_ALLOCA/ i\ +USE_ALLOCA=alloca.obj +/^# USE_HOST_ALLOCA/ i\ +USE_HOST_ALLOCA=alloca.obj +s/^ALLOCA =/ALLOCA = alloca.obj/ +s/^ALLOCA_FINISH = true/ALLOCA_FINISH =/ +s/ \.\// / +s/^bi-\([a-z]*\) *:/bi-\1.exe :/ +s/ bi-\([a-z]*\)$/ bi-\1.exe/ +s/ bi-\([a-z]*\) / bi-\1.exe /g +s/^gen\([a-z]*\) *:/gen\1.exe :/ +s/ gen\([a-z]*\)$/ gen\1.exe/ +s/ gen\([a-z]*\) / gen\1.exe /g +s/genmultilib.exe/genmultilib/g +s/^cccp *:/cccp.exe :/ +s/cccp$/cccp.exe/ +s/cccp /cccp.exe / +s/CCCP=cccp.exe/CCCP=cccp/ +s/(CCCP)$/(CCCP)$(exeext)/ +s/^cpp *:/cpp.exe :/ +s/cpp$/cpp.exe/ +s/cpp /cpp.exe / +s/^cc1 *:/cc1.exe :/ +s/cc1$/cc1.exe/ +s/cc1 /cc1.exe / +s/^cc1obj *:/cc1obj.exe :/ +s/cc1obj$/cc1obj.exe/ +s/cc1obj /cc1obj.exe / +s/^xgcc *:/xgcc.exe :/ +s/xgcc$/xgcc.exe/ +s/xgcc /xgcc.exe / +s/^enquire *:/enquire.exe :/ +s/enquire$/enquire.exe/ +s/enquire /enquire.exe / +s/\.o *:/.obj :/ +s/\.o$/.obj/ +s/\.o /.obj /g +s/-rm -f cpp.exe/del cpp.exe/ +s/\$(CC) \$(ALL_CFLAGS) \$(LDFLAGS) -o /link $(LDFLAGS) -out:/ +s/\$(HOST_CC) \$(HOST_CFLAGS) \$(HOST_LDFLAGS) -o /link $(HOST_LDFLAGS) -out:/ +/^# Build libgcc.a/ r config/winnt/libgcc.mak +/^# Build libgcc.a/,/ / d +/^# Build the include directory\./ r config/winnt/headers.mak +/^# Build the include directory\./,/touch objc-headers/ d +s/^\ // diff --git a/support/cpp/winnt/config.h b/support/cpp/winnt/config.h new file mode 100644 index 00000000..2f7d731d --- /dev/null +++ b/support/cpp/winnt/config.h @@ -0,0 +1 @@ +#include "/xm-winnt.h" diff --git a/support/cpp/winnt/dirent.c b/support/cpp/winnt/dirent.c new file mode 100644 index 00000000..59f7dc1c --- /dev/null +++ b/support/cpp/winnt/dirent.c @@ -0,0 +1,360 @@ +/* + * @(#)msd_dir.c 1.4 87/11/06 Public Domain. + * + * A public domain implementation of BSD directory routines for + * MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield), + * August 1897 + * + * Modified by Ian Stewartson, Data Logic (istewart@datlog.co.uk). + * + * Updates: 1. To support OS/2 1.x + * 2. To support HPFS long filenames + * 3. To support OS/2 2.x + * 4. To support TurboC + * 5. To support Windows NT + */ + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + + +#define WIN32_LEAN_AND_MEAN +#include + +#define FILE_NAME_E cFileName +#define OS_CloseFH(a) FindClose (a) +#define FIND_BUFFER WIN32_FIND_DATA +#define DISABLE_HARD_ERRORS SetErrorMode (0) +#define ENABLE_HARD_ERRORS SetErrorMode (SEM_FAILCRITICALERRORS | \ + SEM_NOOPENFILEERRORBOX); + +# define ERROR_EMPTY_DIR ERROR_FILE_NOT_FOUND + +# define ATTRIBUTES (_A_SUBDIR | _A_HIDDEN | _A_SYSTEM | \ + _A_NORMAL | _A_RDONLY | _A_ARCH) + +/* + * missing ?? + */ + +#ifndef ENOTDIR +# define ENOTDIR 120 /* Not a directory */ +#endif + +#ifndef S_IFMT +# define S_IFMT 0xf000 /* type of file */ +#endif + +#ifndef S_ISDIR +# define S_ISDIR(m) ((((m) & S_IFMT) == S_IFDIR)) +#endif + +/* + * Internals + */ + +typedef struct _dircontents DIRCONT; +static void free_dircontents (DIRCONT *); + +/* + * Open the directory stream + */ + +DIR * +opendir (name) + const char *name; +{ + struct stat statb; + DIR *dirp; + char *last; + DIRCONT *dp; + char *nbuf; + int len = strlen (name); + unsigned long rc; + FIND_BUFFER dtabuf; + HANDLE d_handle; + bool HPFS = FALSE; + + if (!len) + { + errno = ENOTDIR; + return (DIR *)NULL; + } + + if ((nbuf = malloc (len + 5)) == (char *)NULL) + return (DIR *) NULL; + + strcpy (nbuf, name); + last = &nbuf[len - 1]; + +/* Ok, DOS is very picky about its directory names. The following are + * valid. + * + * c:/ + * c:. + * c:name/name1 + * + * c:name/ is not valid + */ + + if (((*last == '\\') || (*last == '/')) && (len > 1) && + (!((len == 3) && (name[1] == ':')))) + *(last--) = 0; + +/* Check its a directory */ + + DISABLE_HARD_ERRORS; + rc = stat (nbuf, &statb); + ENABLE_HARD_ERRORS; + + if (rc) + { + free (nbuf); + return (DIR *) NULL; + } + + if (!S_ISDIR (statb.st_mode)) + { + free (nbuf); + errno = ENOTDIR; + return (DIR *)NULL; + } + + if ((dirp = (DIR *) malloc (sizeof (DIR))) == (DIR *) NULL) + { + free (nbuf); + return (DIR *) NULL; + } + +/* Set up to find everything */ + + if ((*last != '\\') && (*last != '/')) + strcat (last, "/"); + + strcat (last, "*.*"); + +/* Find the file system type */ + + HPFS = IsHPFSFileSystem (nbuf); + + dirp->dd_loc = 0; + dirp->dd_cp = (DIRCONT *) NULL; + dirp->dd_contents = (DIRCONT *) NULL; + + DISABLE_HARD_ERRORS; + + d_handle = FindFirstFile (nbuf, &dtabuf); + rc = (d_handle == INVALID_HANDLE_VALUE) ? GetLastError () : 0; + + ENABLE_HARD_ERRORS; + +/* Check for errors */ + + if (rc) + { + free (nbuf); + +/* Empty directory */ + +#if defined (ERROR_EMPTY_DIR) + if (rc == ERROR_EMPTY_DIR) + return dirp; +#endif + + free (dirp); + return (DIR *) NULL; + } + +/* Process the directory */ + + do + { + if (((dp = (DIRCONT *) malloc (sizeof (DIRCONT))) == (DIRCONT *)NULL) || + ((dp->_d_entry = strdup (dtabuf.FILE_NAME_E)) == (char *) NULL)) + { + if (dp->_d_entry != (char *)NULL) + free ((char *)dp); + + free (nbuf); + free_dircontents (dirp->dd_contents); + + OS_CloseFH (d_handle); + return (DIR *) NULL; + } + + if (!HPFS) + strlwr (dp->_d_entry); + + if (dirp->dd_contents != (DIRCONT *) NULL) + dirp->dd_cp = dirp->dd_cp->_d_next = dp; + + else + dirp->dd_contents = dirp->dd_cp = dp; + + dp->_d_next = (DIRCONT *) NULL; + + } while (FindNextFile (d_handle, &dtabuf)); + + dirp->dd_cp = dirp->dd_contents; + free (nbuf); + + OS_CloseFH (d_handle); + return dirp; +} + + +/* + * Close the directory stream + */ + +int +closedir (dirp) + DIR *dirp; +{ + if (dirp != (DIR *)NULL) + { + free_dircontents (dirp->dd_contents); + free ((char *)dirp); + } + + return 0; +} + +/* + * Read the next record from the stream + */ + +struct dirent * +readdir (dirp) + DIR *dirp; +{ + static struct dirent dp; + + if ((dirp == (DIR *)NULL) || (dirp->dd_cp == (DIRCONT *) NULL)) + return (struct dirent *) NULL; + + dp.d_reclen = strlen (strcpy (dp.d_name, dirp->dd_cp->_d_entry)); + dp.d_off = dirp->dd_loc * 32; + dp.d_ino = (ino_t)++dirp->dd_loc; + dirp->dd_cp = dirp->dd_cp->_d_next; + + return &dp; +} + +/* + * Restart the directory stream + */ + +void +rewinddir (dirp) + DIR *dirp; +{ + seekdir (dirp, (off_t)0); +} + +/* + * Move to a know position in the stream + */ + +void +seekdir (dirp, off) + DIR *dirp; + off_t off; +{ + long i = off; + DIRCONT *dp; + + if ((dirp == (DIR *)NULL) || (off < 0L)) + return; + + for (dp = dirp->dd_contents; (--i >= 0) && (dp != (DIRCONT *)NULL); + dp = dp->_d_next) + ; + + dirp->dd_loc = off - (i + 1); + dirp->dd_cp = dp; +} + +/* + * Get the current position + */ + +off_t +telldir(dirp) + DIR *dirp; +{ + return (dirp == (DIR *)NULL) ? (off_t) -1 : dirp->dd_loc; +} + +/* + * Release the internal structure + */ + +static void +free_dircontents (dp) + DIRCONT *dp; +{ + DIRCONT *odp; + + while ((odp = dp) != (DIRCONT *)NULL) + { + if (dp->_d_entry != (char *)NULL) + free (dp->_d_entry); + + dp = dp->_d_next; + free ((char *)odp); + } +} + + +/* + * Windows NT version + */ + +bool +IsHPFSFileSystem (directory) + char *directory; +{ + char bName[4]; + DWORD flags; + DWORD maxname; + BOOL rc; + unsigned int nDrive; + char szCurDir [MAX_PATH]; + + if (isalpha (directory[0]) && (directory[1] == ':')) + nDrive = toupper (directory[0]) - '@'; + + else + { + GetCurrentDirectory (MAX_PATH, szCurDir); + nDrive = szCurDir[0] - 'A' + 1; + } + +/* Set up the drive name */ + + strcpy (bName, "x:\\"); + bName[0] = (char) (nDrive + '@'); + +/* Read the volume info, if we fail - assume non-HPFS */ + + DISABLE_HARD_ERRORS; + + rc = GetVolumeInformation (bName, (LPTSTR)NULL, 0, (LPDWORD)NULL, + &maxname, &flags, (LPTSTR)NULL, 0); + ENABLE_HARD_ERRORS; + + return ((rc) && (flags & (FS_CASE_SENSITIVE | FS_CASE_IS_PRESERVED))) + ? TRUE : FALSE; +} + diff --git a/support/cpp/winnt/dirent.h b/support/cpp/winnt/dirent.h new file mode 100644 index 00000000..822bd2ca --- /dev/null +++ b/support/cpp/winnt/dirent.h @@ -0,0 +1,96 @@ +/* + * dirent.h + */ + +#ifndef _DIRENT_H +# define _DIRENT_H + +# include +# include + +#define MAXNAMLEN 255 /* maximum filename length */ + +#ifndef NAME_MAX +#define NAME_MAX (MAXNAMLEN - 1) +#endif + +struct dirent /* data from getdents()/readdir() */ +{ + ino_t d_ino; /* inode number of entry */ + off_t d_off; /* offset of disk directory entry */ + wchar_t d_reclen; /* length of this record */ + char d_name[MAXNAMLEN + 1]; +}; + + +/* The following nonportable ugliness could have been avoided by defining + * DIRENTSIZ and DIRENTBASESIZ to also have (struct dirent *) arguments. + * There shouldn't be any problem if you avoid using the DIRENTSIZ() macro. + */ + +#define DIRENTBASESIZ (((struct dirent *)0)->d_name \ + - (char *)&((struct dirent *)0)->d_ino) + +#define DIRENTSIZ(namlen) ((DIRENTBASESIZ + sizeof(long) + (namlen)) \ + / sizeof(long) * sizeof(long)) + + + +# ifndef _BOOL_T_DEFINED +typedef unsigned char bool; +# define _BOOL_T_DEFINED +# endif + +# define DIRBUF 8192 /* buffer size for fs-indep. dirs */ + /* must in general be larger than the */ + /* filesystem buffer size */ + +struct _dircontents { + char *_d_entry; + struct _dircontents *_d_next; +}; + +typedef struct _dirdesc { + int dd_id; /* uniquely identify each open directory */ + long dd_loc; /* where we are in directory entry is this */ + struct _dircontents *dd_contents; /* pointer to contents of dir */ + struct _dircontents *dd_cp; /* pointer to current position */ +} DIR; + + +#if defined (__STDC__) +# define _PROTO(p) p +#else +# define _PROTO(p) () +# undef const +# undef volatile +#endif + +/* Functions */ + +extern DIR * opendir _PROTO ((const char *)); +extern struct dirent * readdir _PROTO ((DIR *)); +extern void rewinddir _PROTO ((DIR *)); + +extern int closedir _PROTO ((DIR *)); +extern void seekdir _PROTO ((DIR *, off_t)); +extern off_t telldir _PROTO ((DIR *)); + +extern int chdir _PROTO ((const char *)); +extern char * getcwd _PROTO ((char *, size_t)); + +extern int mkdir _PROTO ((const char *)); + +extern int rmdir _PROTO ((const char *)); +extern int scandir _PROTO ((char *, + struct dirent ***, + int (*)(const void *, const void *), + int (*)(const void *, const void *))); + +extern int _chdrive _PROTO ((int)); +extern int _getdrive _PROTO ((void)); +extern char * _getdcwd _PROTO ((int, char *, int)); + +extern bool IsHPFSFileSystem _PROTO ((char *)); + +#endif diff --git a/support/cpp/winnt/fixinc-nt.c b/support/cpp/winnt/fixinc-nt.c new file mode 100644 index 00000000..f49d6dda --- /dev/null +++ b/support/cpp/winnt/fixinc-nt.c @@ -0,0 +1,260 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +static char *concat(); +static char *concat3(); +static char *concat4(); +static int onlyonedir; +static int atleastone; +static char *fixeddirs, *origdirs; + +/* Convert all /'s to \'s */ + +char * +slash2slash (dirname) + char *dirname; +{ + int i; + for (i=0; dirname[i]; i++) + if (dirname [i] == '/') + dirname [i] = '\\'; + + return dirname; +} + +/* Examine each directory component of a path and create the directory */ + +int +mkdirpath (dirpath) + char *dirpath; +{ + char *ndirpath = strdup (dirpath); + char *bp, *fp; + + fp = bp = ndirpath; + + while (bp) + { + bp = strchr (fp, '\\'); + if (bp) + { + *bp = 0; + _mkdir (ndirpath); + *bp = '\\'; + fp = ++bp; + } + else + _mkdir (ndirpath); + } +} + +/* Construct a relative directory path from a given path by removing the + leading slash, if it exists and changing a drive letter from X: to X-. */ + +char * +newname (olddirname) + char *olddirname; +{ + char *newname = strdup (olddirname); + + if ((strlen (newname) >= 2) + && (isalpha (newname[0]) && newname[1] == ':')) + newname [1] = '-'; + else if ((strlen (newname) >= 1) + && (newname [0] == '/' || newname [0] == '\\')) + newname = &newname[1]; + + return newname; + +} + +/* Run the sed script on one header file. If no modifications were made, then + delete the newly created file. */ + +int +doheader (oneheader, outheader, oldsize) + char *oneheader, *outheader; + int oldsize; +{ + char *newbuff, *oldbuff; + char *newheader = concat3 ("include", "\\", newname (outheader)); + struct _stat newstatbuf; + int newdesc, olddesc; + int i; + + system (concat4 ("sed -f fixinc-nt.sed ", oneheader, " > ", newheader)); + _stat (newheader, &newstatbuf); + if (oldsize != newstatbuf.st_size) + { + atleastone = 1; + printf ("Fixing: %s\n", oneheader); + return 0; + } + oldbuff = malloc (oldsize); + newbuff = malloc (newstatbuf.st_size); + olddesc = open (oneheader, _O_RDONLY | _O_BINARY); + newdesc = open (newheader, _O_RDONLY | _O_BINARY); + read (olddesc, oldbuff, oldsize); + read (newdesc, newbuff, newstatbuf.st_size); + close (olddesc); + close (newdesc); + for (i=0; id_name[0] == '.') + continue; + + intempbuf = slash2slash (concat3 (indir, "\\", dire->d_name)); + outtempbuf = slash2slash (concat3 (outdir, "\\", dire->d_name)); + _stat (intempbuf, &statbuf); + + /* If directory ... */ + if (statbuf.st_mode & _S_IFDIR) + dodir (intempbuf, outtempbuf); + + /* If regular file ... */ + if (statbuf.st_mode & _S_IFREG) + doheader (intempbuf, outtempbuf, statbuf.st_size); + } + closedir (dir); + return 0; +} + +/* Retrieve the value of the Include environment variable, copy it into a + temporary and append a semi-colon for book-keeping purposes. Then call + dodir () for each complete directory that is named therein. If there is + only one directory, then direct the output to use include\. as the + root instead of include/, where is a path + constructed from the path named in the Include environment variable. + I.e. if Include=C:\MSTOOLS\Include;D:\MSVC20\Include then the modified + header files will be in include\C-\MSTOOLS\Include and + include\D-\MSVC20\Include. However if Include=C:\MSTOOLS\Include then the + modified files will be in include\. */ + +int +main () +{ + char *fp, *bp, *foobar; + char *incvar = getenv ("Include"); + int varlen = 0; + struct _stat statbuf; + + if (incvar == NULL) return 0; + + varlen = strlen (incvar); + foobar = (char *) malloc (varlen + 2); + + strcpy (foobar, incvar); + foobar = slash2slash (foobar); + if (foobar [varlen-1] != ';') strcat (foobar, ";"); + fp = bp = foobar; + + if (strchr (fp, ';') == strrchr (fp, ';')) + onlyonedir = 1; + else + onlyonedir = 0; + + fixeddirs = strdup(".\\include"); + origdirs = strdup(""); + + while (bp) + { + bp = strchr (fp, ';'); + if (bp) + { + *bp = 0; + _stat (fp, &statbuf); + if (statbuf.st_mode & _S_IFDIR) + { + atleastone = 0; + if (onlyonedir) + dodir (fp, "."); + else + dodir (fp, fp); + if (atleastone && !onlyonedir) + { + origdirs = concat3 (origdirs, ";", fp); + fixeddirs = concat3 (fixeddirs, ";", + concat3 (".\\include", "\\", newname(fp))); + } + } + fp = ++bp; + } + } + printf ("set C_Include_Path=%s%s\n", fixeddirs, origdirs); + return 0; +} + +/* Utility function that mallocs space and concatenates two strings. */ + +static char * +concat (s1, s2) + char *s1, *s2; +{ + int len1 = strlen (s1); + int len2 = strlen (s2); + char *result = malloc (len1 + len2 + 1); + + strcpy (result, s1); + strcpy (result + len1, s2); + *(result + len1 + len2) = 0; + + return result; +} + +/* Utility function that concatenates three strings. */ + +static char * +concat3 (s1, s2, s3) + char *s1, *s2, *s3; +{ + return concat (concat (s1, s2), s3); +} + +/* Utility function that concatenates four strings. */ + +static char * +concat4 (s1, s2, s3, s4) + char *s1, *s2, *s3, *s4; +{ + return concat (concat (s1, s2), concat (s3, s4)); +} diff --git a/support/cpp/winnt/hconfig.h b/support/cpp/winnt/hconfig.h new file mode 100644 index 00000000..2f7d731d --- /dev/null +++ b/support/cpp/winnt/hconfig.h @@ -0,0 +1 @@ +#include "/xm-winnt.h" diff --git a/support/cpp/winnt/headers.mak b/support/cpp/winnt/headers.mak new file mode 100644 index 00000000..8dec3413 --- /dev/null +++ b/support/cpp/winnt/headers.mak @@ -0,0 +1,51 @@ +# Build the include directory. The stamp files are stmp-* rather than +# stamp-* so that mostlyclean does not force the include directory to +# be rebuilt. + + +# Copy in the headers provided with gcc. +USER_H = $(srcdir)\ginclude\stdarg.h $(srcdir)\ginclude\stddef.h \ + $(srcdir)\ginclude\varargs.h $(srcdir)\ginclude\va-alpha.h \ + $(srcdir)\ginclude\va-h8300.h $(srcdir)\ginclude\va-i860.h \ + $(srcdir)\ginclude\va-i960.h $(srcdir)\ginclude\va-mips.h \ + $(srcdir)\ginclude\va-m88k.h $(srcdir)\ginclude\va-pa.h \ + $(srcdir)\ginclude\va-pyr.h $(srcdir)\ginclude\va-sparc.h \ + $(srcdir)\ginclude\va-clipper.h $(srcdir)\ginclude\va-spur.h \ + $(srcdir)\ginclude\iso646.h \ + $(srcdir)\ginclude\proto.h + +# Build the include directory except for float.h (which depends upon +# enquire). + +stmp-int-hdrs: $(USER_H) + type $(srcdir)\limitx.h >xlimits.h + type $(srcdir)\glimits.h >>xlimits.h + type $(srcdir)\limity.h >>xlimits.h + + -mkdir include + for %%f in ($(USER_H)) do copy %%f include + del include\limits.h + copy xlimits.h include\limits.h + del include\syslimits.h + copy $(srcdir)\gsyslimits.h include\syslimits.h + copy include\limits.h include\syslimits.h + del include\README + copy $(srcdir)\README-fixinc include\README + touch stmp-int-hdrs + +stmp-headers: stmp-int-hdrs fixinc-nt.exe + fixinc-nt + touch stmp-headers + +# Build float.h. +stmp-float_h: libgcc.lib enquire.exe + -.\enquire -f > tmp-float.h + del include\float.h + copy tmp-float.h include\float.h + touch stmp-float_h + +fixinc-nt.obj: $(srcdir)/config/winnt/fixinc-nt.c + cl -c -I. -I$(srcdir) -I$(srcdir)/include -I$(srcdir)/config/winnt $(srcdir)/config/winnt/fixinc-nt.c + +fixinc-nt.exe: fixinc-nt.obj dirent.obj + cl fixinc-nt.obj dirent.obj libc.lib kernel32.lib diff --git a/support/cpp/winnt/ld.c b/support/cpp/winnt/ld.c new file mode 100644 index 00000000..67d53e78 --- /dev/null +++ b/support/cpp/winnt/ld.c @@ -0,0 +1,348 @@ +/* Call Windows NT 3.x linker. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "config.h" +#include +#include +#include +#include +#include +#include + +static char *concat (); +static char *concat3 (); + +/* These can be set by command line arguments */ +char *linker_path = 0; +int verbose = 0; +int subsystem = 0; +int entry = 0; + +int link_arg_max = -1; +char **link_args = (char **) 0; +int link_arg_index = -1; + +char *search_dirs = "."; + +static int is_regular_file (char *name); + +/* Add the argument contained in STR to the list of arguments to pass to the + linker */ + +static void +addarg (str) + char *str; +{ + int i; + + if (++link_arg_index >= link_arg_max) + { + char **new_link_args + = (char **) calloc (link_arg_max + 1000, sizeof (char *)); + + for (i = 0; i <= link_arg_max; i++) + new_link_args [i] = link_args [i]; + + if (link_args) + free (link_args); + + link_arg_max += 1000; + link_args = new_link_args; + } + + link_args [link_arg_index] = str; +} + +/* Locate the file named in FILE_NAME in the set of paths contained in + PATH_VAL */ + +static char * +locate_file (file_name, path_val) + char *file_name; + char *path_val; +{ + char buf [1000]; + int file_len = strlen (file_name); + char *end_path = path_val + strlen (path_val); + char *ptr; + + /* Handle absolute pathnames */ + if (file_name [0] == '/' || file_name [0] == DIR_SEPARATOR + || isalpha (file_name [0]) && file_name [1] == ':') + { + strncpy (buf, file_name, sizeof buf); + buf[sizeof buf - 1] = '\0'; + if (is_regular_file (buf)) + return strdup (buf); + else + return 0; + } + + if (! path_val) + return 0; + + for (;;) + { + for (; *path_val == PATH_SEPARATOR ; path_val++) + ; + if (! *path_val) + return 0; + + for (ptr = buf; *path_val && *path_val != PATH_SEPARATOR; ) + *ptr++ = *path_val++; + + ptr--; + if (*ptr != '/' && *ptr != DIR_SEPARATOR) + *++ptr = DIR_SEPARATOR; + + strcpy (++ptr, file_name); + + if (is_regular_file (buf)) + return strdup (buf); + } + + return 0; +} + +/* Given a library name in NAME, i.e. foo. Look first for libfoo.lib and then + libfoo.a in the set of directories we are allowed to search in */ + +static char * +expand_lib (name) + char *name; +{ + char *lib, *lib_path; + + lib = malloc (strlen (name) + 8); + strcpy (lib, "lib"); + strcat (lib, name); + strcat (lib, ".lib"); + lib_path = locate_file (lib, search_dirs); + if (!lib_path) + { + strcpy (lib, "lib"); + strcat (lib, name); + strcat (lib, ".a"); + lib_path = locate_file (lib, search_dirs); + if (!lib_path) + { + fprintf + (stderr, + "Couldn't locate library: lib%s.a or lib%s.lib\n", name, name); + exit (1); + } + } + + return lib_path; +} + +/* Check to see if the file named in NAME is a regular file, i.e. not a + directory */ + +static int +is_regular_file (name) + char *name; +{ + int ret; + struct stat statbuf; + + ret = stat(name, &statbuf); + return !ret && S_ISREG (statbuf.st_mode); +} + +/* Process the number of args in P_ARGC and contained in ARGV. Look for + special flags, etc. that must be handled for the Microsoft linker */ + +static void +process_args (p_argc, argv) + int *p_argc; + char *argv[]; +{ + int i, j; + + for (i = 1; i < *p_argc; i++) + { + /* -v turns on verbose option here and is passed on to gcc */ + if (! strcmp (argv [i], "-v")) + verbose = 1; + else if (! strncmp (argv [i], "-g", 2)) + { + addarg ("-debugtype:coff -debug:full"); + } + else if (! strncmp (argv [i], "-stack", 6)) + { + i++; + addarg (concat ("-stack:",argv[i])); + } + else if (! strncmp (argv [i], "-subsystem", 10)) + { + subsystem = 1; + i++; + addarg (concat ("-subsystem:",argv[i])); + } + else if (! strncmp (argv [i], "-e", 2)) + { + entry = 1; + i++; + addarg (concat ("-entry:",&argv[i][1])); + } + } +} + +/* The main program. Spawn the Microsoft linker after fixing up the + Unix-like flags and args to be what the Microsoft linker wants */ + +main (argc, argv) + int argc; + char *argv[]; +{ + int i; + int done_an_ali = 0; + int file_name_index; + char *pathval = getenv ("PATH"); + char *spawn_args [5]; + char *tmppathval = malloc (strlen (pathval) + 3); + + strcpy (tmppathval, ".;"); + pathval = strcat (tmppathval, pathval); + + linker_path = locate_file ("link32.exe", pathval); + if (!linker_path) + { + linker_path = locate_file ("link.exe", pathval); + if (!linker_path) + { + fprintf (stderr, "Couldn't locate link32 or link\n"); + exit (1); + } + } + + addarg (linker_path); + + process_args (&argc , argv); + if (! subsystem) addarg ("-subsystem:console"); + if (! entry) addarg ("-entry:mainCRTStartup"); + + for (i = 1; i < argc; i++) + { + int arg_len = strlen (argv [i]); + + if (!strcmp (argv [i], "-o")) + { + char *buff, *ptr; + int out_len; + + i++; + out_len = strlen (argv[i]) + 10; + buff = malloc (out_len); + strcpy (buff, "-out:"); + strcat (buff, argv[i]); + ptr = strstr (buff, ".exe"); + if (ptr == NULL || strlen (ptr) != 4) + strcat (buff, ".exe"); + addarg (buff); + } + else if (arg_len > 2 && !strncmp (argv [i], "-L", 2)) + { + char *nbuff, *sdbuff; + int j, new_len, search_dirs_len; + + new_len = strlen (&argv[i][2]); + search_dirs_len = strlen (search_dirs); + + nbuff = malloc (new_len + 1); + strcpy (nbuff, &argv[i][2]); + + for (j = 0; j < new_len; j++) + if (nbuff[j] == '/') nbuff[j] = DIR_SEPARATOR; + + sdbuff = malloc (search_dirs_len + new_len + 2); + strcpy (sdbuff, search_dirs); + sdbuff[search_dirs_len] = PATH_SEPARATOR; + sdbuff[search_dirs_len+1] = 0; + strcat (sdbuff, nbuff); + + search_dirs = sdbuff; + } + + else if (arg_len > 2 && !strncmp (argv [i], "-l", 2)) + { + addarg (expand_lib (&argv[i][2])); + } + else if (!strcmp (argv [i], "-v") + || !strcmp (argv [i], "-g") + || !strcmp (argv [i], "-noinhibit-exec")) + { + ; + } + else if (!strcmp (argv [i], "-stack") + || !strcmp (argv [i], "-subsystem") + || !strcmp (argv [i], "-e")) + { + i++; + } + else + { + addarg (argv [i]); + } + } + + addarg (NULL); + + if (verbose) + { + int i; + + for (i = 0; i < link_arg_index; i++) + printf ("%s ", link_args [i]); + putchar ('\n'); + } + + if (spawnvp (P_WAIT, linker_path, (const char * const *)link_args) != 0) + { + fprintf (stderr, "Error executing %s\n", link_args[0]); + exit (1); + } + + exit (0); +} + +static char * +concat (s1, s2) + char *s1, *s2; +{ + int len1 = strlen (s1); + int len2 = strlen (s2); + char *result = malloc (len1 + len2 + 1); + + strcpy (result, s1); + strcpy (result + len1, s2); + *(result + len1 + len2) = 0; + + return result; +} + +static char * +concat3 (s1, s2, s3) + char *s1, *s2, *s3; +{ + return concat (concat (s1, s2), s3); +} diff --git a/support/cpp/winnt/libgcc.mak b/support/cpp/winnt/libgcc.mak new file mode 100644 index 00000000..adfb57e6 --- /dev/null +++ b/support/cpp/winnt/libgcc.mak @@ -0,0 +1,19 @@ +# Build libgcc.a + +libgcc.lib : libgcc1.c libgcc2.c mklibgcc.exe + mklibgcc -c + mklibgcc "cl -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES)" libgcc1.c $(LIB1FUNCS) + mklibgcc "xgcc -B./ -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES)" libgcc2.c $(LIB2FUNCS) + mklibnow.bat + -del libgcc.lib + lib -verbose -out:libgcc.lib lgcctmp/*.obj + +mklibgcc.obj : $(srcdir)/config/winnt/mklibgcc.c + cl -I. -I$(srcdir) -I$(srcdir)/config/winnt -c $(srcdir)/config/winnt/mklibgcc.c + +dirent.obj : $(srcdir)/config/winnt/dirent.c stmp-int-hdrs + cl -I. -I$(srcdir) -I$(srcdir)/include -I$(srcdir)/config/winnt -c $(srcdir)/config/winnt/dirent.c + +mklibgcc.exe : mklibgcc.obj dirent.obj + cl mklibgcc.obj dirent.obj libc.lib kernel32.lib + diff --git a/support/cpp/winnt/mklibgcc.c b/support/cpp/winnt/mklibgcc.c new file mode 100644 index 00000000..081e4ec2 --- /dev/null +++ b/support/cpp/winnt/mklibgcc.c @@ -0,0 +1,97 @@ +#include +#include +#include + +char *skips[] = { + 0 +}; + +int +do_clean() +{ + DIR *dir; + struct dirent *de; + remove("mklibnow.bat"); + + dir = opendir("lgcctmp"); + if (!dir) + return 0; + while ((de=readdir(dir))) + { + char buf[30]; + if (de->d_name[0] == '.') + continue; + sprintf(buf, "lgcctmp/%s", de->d_name); + unlink(buf); + } + closedir(dir); + return 0; +} + +int +main(int argc, char **argv) +{ + char *cc = argv[1]; + char *csrc=argv[2]; + int i; + FILE *batfile; + FILE *cfile; + + if (argc > 1 && strcmp(argv[1], "-c")==0) + return do_clean(); + + _mkdir("lgcctmp", 0755); + + batfile = fopen("mklibnow.bat", "a"); + if (!batfile) + { + perror("mklibnow.bat"); + return 1; + } +/* fprintf(batfile, "@echo off\n"); */ + + for (i=3; i + +#ifndef USG +#define USG 1 +#endif + +#ifndef ONLY_INT_FIELD +#define ONLY_INT_FIELDS 1 +#endif + +#ifndef USE_PROTOTYPES +#define USE_PROTOTYPES 1 +#endif + +#ifndef HAVE_PUTENV +#define HAVE_PUTENV 1 +#endif + +#ifndef HAVE_VPRINTF +#define HAVE_VPRINTF 1 +#endif + +#define NO_SYS_SIGLIST 1 +#define bcmp(a,b,c) memcmp (a,b,c) +#define bcopy(a,b,c) memcpy (b,a,c) +#define bzero(a,b) memset (a,0,b) +#define index strchr +#define rindex strrchr +#define kill(a,b) raise(b) + +#define OBJECT_SUFFIX ".obj" +#define EXECUTABLE_SUFFIX ".exe" +#define PATH_SEPARATOR ';' +#define DIR_SEPARATOR '\\' + +#define S_IRUSR 0000400 +#define S_IWUSR 0000200 +#define S_IXUSR 0000100 +#define S_IRGRP 0000040 +#define S_IWGRP 0000020 +#define S_IXGRP 0000010 +#define S_IROTH 0000004 +#define S_IWOTH 0000002 +#define S_IXOTH 0000001 +#define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR +#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) + diff --git a/support/cpp/winnt/win-nt.h b/support/cpp/winnt/win-nt.h new file mode 100644 index 00000000..4b93f8c1 --- /dev/null +++ b/support/cpp/winnt/win-nt.h @@ -0,0 +1,58 @@ +/* Operating system specific defines to be used when targeting GCC for + Windows NT 3.x. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu). + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#define TARGET_MEM_FUNCTIONS + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "" + +#undef LINK_SPEC +#define LINK_SPEC "-stack 5000000,5000000 -noinhibit-exec %{g}" + +#undef CPP_SPEC +#define CPP_SPEC "-lang-c-c++-comments" + +#undef STANDARD_EXEC_PREFIX +#define STANDARD_EXEC_PREFIX "" + +#undef STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "" + +#undef TOOLDIR_BASE_PREFIX +#define TOOLDIR_BASE_PREFIX "" + +#ifdef STANDARD_INCLUDE_DIR +#undef STANDARD_INCLUDE_DIR +#endif +#define STANDARD_INCLUDE_DIR "" + +#undef LOCAL_INCLUDE_DIR +#define LOCAL_INCLUDE_DIR "" + +#undef INCLUDE_DEFAULTS +#define INCLUDE_DEFAULTS \ + { \ + { 0, 0, 0 } \ + } + +#undef STDC_VALUE +#define STDC_VALUE 0 diff --git a/support/cpp/winnt/x-winnt b/support/cpp/winnt/x-winnt new file mode 100644 index 00000000..36e36b9c --- /dev/null +++ b/support/cpp/winnt/x-winnt @@ -0,0 +1,34 @@ +STMP_FIXPROTO = +OTHER_FIXINCLUDES_DIRS=${srcdir} +RANLIB = : +RANLIB_TEST = false +OLDCC = cl +MAKE = make +SHELL = sh +SYMLINK = cp +INSTALL = $(srcdir)/install.sh -c +.SUFFIXES: .obj +.c.obj: + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< +.adb.obj: + $(CC) -c $(ALL_ADAFLAGS) $< +.ads.obj: + $(CC) -c $(ALL_ADAFLAGS) $< +exeext = .exe +objext = .obj + +CC = gcc +CLIB = +LDFLAGS = + +ld.o: $(srcdir)/config/winnt/ld.c + $(CC) -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/winnt/ld.c + +ld.exe: ld.o + $(CC) -o ld.exe ld.o + +oldnames.o: $(srcdir)/config/winnt/oldnames.c + $(CC) -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/winnt/oldnames.c + +spawnv.o: $(srcdir)/config/winnt/spawnv.c + $(CC) -I. -I$(srcdir) -I$(srcdir)/config -c $(srcdir)/config/winnt/spawnv.c diff --git a/support/cpp/winnt/xm-winnt.h b/support/cpp/winnt/xm-winnt.h new file mode 100644 index 00000000..be62d020 --- /dev/null +++ b/support/cpp/winnt/xm-winnt.h @@ -0,0 +1,69 @@ +/* Configuration for GNU compiler for processor running Windows NT 3.x. + Copyright (C) 1993, 1995 Free Software Foundation, Inc. + Contributed by Douglas B. Rupp (drupp@cs.washington.edu) + +This file is part of GNU CC. + +GNU CC 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, or (at your option) +any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include + +#ifndef USG +#define USG 1 +#endif + +#ifndef ONLY_INT_FIELD +#define ONLY_INT_FIELDS 1 +#endif + +#ifndef USE_PROTOTYPES +#define USE_PROTOTYPES 1 +#endif + +#ifndef HAVE_PUTENV +#define HAVE_PUTENV 1 +#endif + +#ifndef HAVE_VPRINTF +#define HAVE_VPRINTF 1 +#endif + +#define NO_SYS_SIGLIST 1 +#define bcmp(a,b,c) memcmp (a,b,c) +#define bcopy(a,b,c) memcpy (b,a,c) +#define bzero(a,b) memset (a,0,b) +#define index strchr +#define rindex strrchr +#define kill(a,b) raise(b) + +#define OBJECT_SUFFIX ".obj" +#define EXECUTABLE_SUFFIX ".exe" +#define PATH_SEPARATOR ';' +#define DIR_SEPARATOR '\\' + +#define S_IRUSR 0000400 +#define S_IWUSR 0000200 +#define S_IXUSR 0000100 +#define S_IRGRP 0000040 +#define S_IWGRP 0000020 +#define S_IXGRP 0000010 +#define S_IROTH 0000004 +#define S_IWOTH 0000002 +#define S_IXOTH 0000001 +#define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR +#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) + diff --git a/support/gc/BCC_MAKEFILE b/support/gc/BCC_MAKEFILE new file mode 100644 index 00000000..6aa89edb --- /dev/null +++ b/support/gc/BCC_MAKEFILE @@ -0,0 +1,82 @@ +# Makefile for Borland C++ 4.5 on NT +# For Borland 5.0, replace bc45 by bc5. +# If you have the Borland assembler, remove "-DUSE_GENERIC" +# +bc= c:\bc45 +bcbin= $(bc)\bin +bclib= $(bc)\lib +bcinclude= $(bc)\include + +cc= $(bcbin)\bcc32 +rc= $(bcbin)\brc32 +lib= $(bcbin)\tlib +link= $(bcbin)\tlink32 +cflags= -R -v -vi -H -H=gc.csm -I$(bcinclude);cord -L$(bclib) \ + -w-pro -w-aus -w-par -w-ccc -w-rch -a4 -D__STDC__=0 +#defines= -DSILENT +defines= -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS -DUSE_GENERIC + +.c.obj: + $(cc) @&&| + $(cdebug) $(cflags) $(cvars) $(defines) -o$* -c $*.c +| + +.cpp.obj: + $(cc) @&&| + $(cdebug) $(cflags) $(cvars) $(defines) -o$* -c $*.cpp +| + +.rc.res: + $(rc) -i$(bcinclude) -r -fo$* $*.rc + +XXXOBJS= XXXalloc.obj XXXreclaim.obj XXXallchblk.obj XXXmisc.obj \ + XXXmach_dep.obj XXXos_dep.obj XXXmark_rts.obj XXXheaders.obj XXXmark.obj \ + XXXobj_map.obj XXXblacklst.obj XXXfinalize.obj XXXnew_hblk.obj \ + XXXdbg_mlc.obj XXXmalloc.obj XXXstubborn.obj XXXdyn_load.obj \ + XXXtypd_mlc.obj XXXptr_chck.obj XXXgc_cpp.obj XXXmallocx.obj + +OBJS= $(XXXOBJS:XXX=) + +all: gctest.exe cord\de.exe test_cpp.exe + +$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h gcconfig.h MAKEFILE + +gc.lib: $(OBJS) + -del gc.lib + tlib $* @&&| + $(XXXOBJS:XXX=+) +| + +gctest.exe: test.obj gc.lib + $(cc) @&&| + $(cflags) -W -e$* test.obj gc.lib +| + +cord\de.obj cord\de_win.obj: cord\cord.h cord\private\cord_pos.h cord\de_win.h \ + cord\de_cmds.h + +cord\de.exe: cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj \ + cord\de_win.res gc.lib + $(cc) @&&| + $(cflags) -W -e$* cord\cordbscs.obj cord\cordxtra.obj \ + cord\de.obj cord\de_win.obj gc.lib +| + $(rc) cord\de_win.res cord\de.exe + +gc_cpp.obj: gc_cpp.h gc.h + +gc_cpp.cpp: gc_cpp.cc + copy gc_cpp.cc gc_cpp.cpp + +test_cpp.cpp: test_cpp.cc + copy test_cpp.cc test_cpp.cpp + +test_cpp.exe: test_cpp.obj gc_cpp.h gc.h gc.lib + $(cc) @&&| + $(cflags) -W -e$* test_cpp.obj gc.lib +| + +scratch: + -del *.obj *.res *.exe *.csm cord\*.obj cord\*.res cord\*.exe cord\*.csm + + diff --git a/support/gc/EMX_MAKEFILE b/support/gc/EMX_MAKEFILE new file mode 100644 index 00000000..54a06ce3 --- /dev/null +++ b/support/gc/EMX_MAKEFILE @@ -0,0 +1,141 @@ +# +# OS/2 specific Makefile for the EMX environment +# +# You need GNU Make 3.71, gcc 2.5.7, emx 0.8h and GNU fileutils 3.9 +# or similar tools. C++ interface and de.exe weren't tested. +# +# Rename this file "Makefile". +# + +# Primary targets: +# gc.a - builds basic library +# c++ - adds C++ interface to library and include directory +# cords - adds cords (heavyweight strings) to library and include directory +# test - prints porting information, then builds basic version of gc.a, and runs +# some tests of collector and cords. Does not add cords or c++ interface to gc.a +# cord/de.exe - builds dumb editor based on cords. +CC= gcc +CXX=g++ +# Needed only for "make c++", which adds the c++ interface + +CFLAGS= -O -DALL_INTERIOR_POINTERS -DSILENT +# Setjmp_test may yield overly optimistic results when compiled +# without optimization. +# -DSILENT disables statistics printing, and improves performance. +# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly +# altered stubborn objects, at substantial performance cost. +# -DFIND_LEAK causes the collector to assume that all inaccessible +# objects should have been explicitly deallocated, and reports exceptions +# -DSOLARIS_THREADS enables support for Solaris (thr_) threads. +# (Clients should also define SOLARIS_THREADS and then include +# gc.h before performing thr_ or GC_ operations.) +# -DALL_INTERIOR_POINTERS allows all pointers to the interior +# of objects to be recognized. (See gc_private.h for consequences.) +# -DSMALL_CONFIG tries to tune the collector for small heap sizes, +# usually causing it to use less space in such situations. +# Incremental collection no longer works in this case. +# -DDONT_ADD_BYTE_AT_END is meaningful only with +# -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS +# causes all objects to be padded so that pointers just past the end of +# an object can be recognized. This can be expensive. (The padding +# is normally more than one byte due to alignment constraints.) +# -DDONT_ADD_BYTE_AT_END disables the padding. + +AR= ar +RANLIB= ar s + +# Redefining srcdir allows object code for the nonPCR version of the collector +# to be generated in different directories +srcdir = . +VPATH = $(srcdir) + +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dyn_load.o dbg_mlc.o malloc.o stubborn.o checksums.o typd_mlc.o ptr_chck.o mallocx.o + +CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o + +CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \ + $(srcdir)/cord/cord_pos.h + +# Libraries needed for curses applications. Only needed for de. +CURSES= -lcurses -ltermlib + +# The following is irrelevant on most systems. But a few +# versions of make otherwise fork the shell specified in +# the SHELL environment variable. +SHELL= bash + +SPECIALCFLAGS = +# Alternative flags to the C compiler for mach_dep.c. +# Mach_dep.c often doesn't like optimization, and it's +# not time-critical anyway. + +all: gc.a gctest.exe + +$(OBJS) test.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \ + $(srcdir)/gcconfig.h $(srcdir)/gc_typed.h +# The dependency on Makefile is needed. Changing +# options such as -DSILENT affects the size of GC_arrays, +# invalidating all .o files that rely on gc_priv.h + +mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h + +gc.a: $(OBJS) + $(AR) ru gc.a $(OBJS) + $(RANLIB) gc.a + +cords: $(CORD_OBJS) cord/cordtest.exe + $(AR) ru gc.a $(CORD_OBJS) + $(RANLIB) gc.a + cp $(srcdir)/cord/cord.h include/cord.h + cp $(srcdir)/cord/ec.h include/ec.h + cp $(srcdir)/cord/cord_pos.h include/cord_pos.h + +gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h + $(CXX) -c -O $(srcdir)/gc_cpp.cc + +c++: gc_cpp.o $(srcdir)/gc_cpp.h + $(AR) ru gc.a gc_cpp.o + $(RANLIB) gc.a + cp $(srcdir)/gc_cpp.h include/gc_cpp.h + +mach_dep.o: $(srcdir)/mach_dep.c + $(CC) -o mach_dep.o -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c + +mark_rts.o: $(srcdir)/mark_rts.c + $(CC) -o mark_rts.o -c $(CFLAGS) $(srcdir)/mark_rts.c + +cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordbscs.c -o cord/cordbscs.o + +cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordxtra.c -o cord/cordxtra.o + +cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordprnt.c -o cord/cordprnt.o + +cord/cordtest.exe: $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a + $(CC) $(CFLAGS) -o cord/cordtest.exe $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a + +cord/de.exe: $(srcdir)/cord/de.c $(srcdir)/cord/cordbscs.o $(srcdir)/cord/cordxtra.o gc.a + $(CC) $(CFLAGS) -o cord/de.exe $(srcdir)/cord/de.c $(srcdir)/cord/cordbscs.o $(srcdir)/cord/cordxtra.o gc.a $(CURSES) + +clean: + rm -f gc.a test.o gctest.exe output-local output-diff $(OBJS) \ + setjmp_test mon.out gmon.out a.out core \ + $(CORD_OBJS) cord/cordtest.exe cord/de.exe + -rm -f *~ + +gctest.exe: test.o gc.a + $(CC) $(CFLAGS) -o gctest.exe test.o gc.a + +# If an optimized setjmp_test generates a segmentation fault, +# odds are your compiler is broken. Gctest may still work. +# Try compiling setjmp_t.c unoptimized. +setjmp_test.exe: $(srcdir)/setjmp_t.c $(srcdir)/gc.h + $(CC) $(CFLAGS) -o setjmp_test.exe $(srcdir)/setjmp_t.c + +test: setjmp_test.exe gctest.exe + ./setjmp_test + ./gctest + make cord/cordtest.exe + cord/cordtest diff --git a/support/gc/MacOS.c b/support/gc/MacOS.c new file mode 100644 index 00000000..cc12cd15 --- /dev/null +++ b/support/gc/MacOS.c @@ -0,0 +1,154 @@ +/* + MacOS.c + + Some routines for the Macintosh OS port of the Hans-J. Boehm, Alan J. Demers + garbage collector. + + + + 11/22/94 pcb StripAddress the temporary memory handle for 24-bit mode. + 11/30/94 pcb Tracking all memory usage so we can deallocate it all at once. + 02/10/96 pcb Added routine to perform a final collection when +unloading shared library. + + by Patrick C. Beard. + */ +/* Boehm, February 15, 1996 2:55 pm PST */ + +#include +#include +#include +#include +#include +#include + +#include "gc.h" +#include "gc_priv.h" + +// use 'CODE' resource 0 to get exact location of the beginning of global space. + +typedef struct { + unsigned long aboveA5; + unsigned long belowA5; + unsigned long JTSize; + unsigned long JTOffset; +} *CodeZeroPtr, **CodeZeroHandle; + +void* GC_MacGetDataStart() +{ + CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0); + if (code0) { + long belowA5Size = (**code0).belowA5; + ReleaseResource((Handle)code0); + return (LMGetCurrentA5() - belowA5Size); + } + fprintf(stderr, "Couldn't load the jump table."); + exit(-1); + return 0; +} + +/* track the use of temporary memory so it can be freed all at once. */ + +typedef struct TemporaryMemoryBlock TemporaryMemoryBlock, **TemporaryMemoryHandle; + +struct TemporaryMemoryBlock { + TemporaryMemoryHandle nextBlock; + char data[]; +}; + +static TemporaryMemoryHandle theTemporaryMemory = NULL; +static Boolean firstTime = true; + +void GC_MacFreeTemporaryMemory(void); + +Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory) +{ + static Boolean firstTime = true; + OSErr result; + TemporaryMemoryHandle tempMemBlock; + Ptr tempPtr = nil; + + tempMemBlock = (TemporaryMemoryHandle)TempNewHandle(size + sizeof(TemporaryMemoryBlock), &result); + if (tempMemBlock && result == noErr) { + HLockHi((Handle)tempMemBlock); + tempPtr = (**tempMemBlock).data; + if (clearMemory) memset(tempPtr, 0, size); + tempPtr = StripAddress(tempPtr); + + // keep track of the allocated blocks. + (**tempMemBlock).nextBlock = theTemporaryMemory; + theTemporaryMemory = tempMemBlock; + } + +# if !defined(SHARED_LIBRARY_BUILD) + // install an exit routine to clean up the memory used at the end. + if (firstTime) { + atexit(&GC_MacFreeTemporaryMemory); + firstTime = false; + } +# endif + + return tempPtr; +} + +extern word GC_fo_entries; + +static void perform_final_collection() +{ + unsigned i; + word last_fo_entries = 0; + + /* adjust the stack bottom, because CFM calls us from another stack + location. */ + GC_stackbottom = (ptr_t)&i; + + /* try to collect and finalize everything in sight */ + for (i = 0; i < 2 || GC_fo_entries < last_fo_entries; i++) { + last_fo_entries = GC_fo_entries; + GC_gcollect(); + } +} + + +void GC_MacFreeTemporaryMemory() +{ +# if defined(SHARED_LIBRARY_BUILD) + /* if possible, collect all memory, and invoke all finalizers. */ + perform_final_collection(); +# endif + + if (theTemporaryMemory != NULL) { + long totalMemoryUsed = 0; + TemporaryMemoryHandle tempMemBlock = theTemporaryMemory; + while (tempMemBlock != NULL) { + TemporaryMemoryHandle nextBlock = (**tempMemBlock).nextBlock; + totalMemoryUsed += GetHandleSize((Handle)tempMemBlock); + DisposeHandle((Handle)tempMemBlock); + tempMemBlock = nextBlock; + } + theTemporaryMemory = NULL; + +# if !defined(SILENT) && !defined(SHARED_LIBRARY_BUILD) + fprintf(stdout, "[total memory used: %ld bytes.]\n", + totalMemoryUsed); + fprintf(stdout, "[total collections: %ld.]\n", GC_gc_no); +# endif + } +} + +#if __option(far_data) + + void* GC_MacGetDataEnd() + { + CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0); + if (code0) { + long aboveA5Size = (**code0).aboveA5; + ReleaseResource((Handle)code0); + return (LMGetCurrentA5() + aboveA5Size); + } + fprintf(stderr, "Couldn't load the jump table."); + exit(-1); + return 0; + } + +#endif /* __option(far_data) */ diff --git a/support/gc/MacProjects.sit.hqx b/support/gc/MacProjects.sit.hqx new file mode 100644 index 00000000..99dff88b --- /dev/null +++ b/support/gc/MacProjects.sit.hqx @@ -0,0 +1,886 @@ +(This file must be converted with BinHex 4.0) + +:$deKBe"bEfTPBh4c,R0TG!"6594%8dP8)3#3"&)e!!!"4UiT8dP8)3!(!!"50A* + +-BA8#ZJ#3!aB"#3d0#'GM,MBi5bkjBf038%-ZZ3#3%)Zi!*!8"@`!N!6rN!4069" + +568e$3`%!UbqAD+X`19S!!!Ba!!!,*J!!!F%!!!-PfTmj1`#3"PET)d31)LTH6H4 + +#*AqG5b5HI*)QjY$IIb00%ReTJSi6rG$jG(bZ,"Rc,9Umf[IRj)6FZ-j`GfGR)#! + +m-#qLqB#cj'G%46qffB3q8AppLXKc+P&*il4FMJMq3N32r[U,(PlSNdrQm-J(4!p + +jK)NHmKJSHY!,&chS$4)pk%8mL3I)B0'$AU6S3'q)k%%[5[5J&ffa#68)0ZM&#T! + +!*fHC-2dFZ3i83[Vr[4Xh'+DNQrm'J)rrpqe%ST`,FeVi6b,*qHH")4eQc28NFMN + +ZT*m,L"Y%-`pdAk6RLHDaeVV0a,,@P(4UUK66rUM'8bf91llS("lTh81)MBQ+4*q + +rfHENEhD)Ke#3!09'M%bL[P1+G88fa$3e)5Gpf0kARpBf*6eIH*0`ZBHR%ii"PbN + ++D&*)688M)Sm$Bm[cCdDjh2YIjmAc`(TVpi*Vka((A*&Yl@'LTSH1M*AMP#,2[A$ + +(FHA@S"dL4dER#3b!EfBYem(C9P5iGH"a-bb-AL(F"bb-AL,F6)%a9pJUL,(hf%B + +TeQb["X5ib4DQXV!-fa6&mZf&3,(C&UDd-((SpeMBEIB`8Zc,BcZR3A5'X+jYj$' + +6)6HVV+R[!`#3!`X!(E@*MFQ%R4d"))`m[3JM[c)bBS54Tj'M(AP+MK&f%VD5SdG + +SANFB@3Rqc$Am83(+)`"G(D%A'9!bBQ6!b)b4Sq3SH8D1NDGNX$)bBi54!51--$* + +Kj0L!M"KKK"dC--,)-h+-6#KKC-$)-F)NamL!!Z06#X!!b&%bBUHp8RcN'%%6!b, + +i!!kV"`"DLHFaK*!!"Ym4K,,2i2X4c[,`c5!GIPf!ZcNi'8'VfJFpSfdpq+CY$8j + +-V'f-DZr2[36#1(ael5hmfT@1cSU66D5pqDSA89pdTP-`Z[jj6T&!PmZBFZjal"& + +5iG6#blE$+&kLh#QZ118&(0T1J(hZ,9)5MJ9ic*qPI!ac'RJ96QMZjSbkMq()Ui6 + +B+f,,#'N1icbM4N"aaBr1`3Z9U'8RY'XAiVXFKp#&k2D5Be%VCdh4%,+2QS'b"Q2 + +%0PNT4rE#%kTUFqYDM56bVjfe!p8MqmL)1VmjVkJY`U[*$&*L3AMSpB@LCQ*U&l% + +T+3890rL,V9klFN*4@f0UTf8Z&&afN!"4GC6G8p3fN9$4+4[-@DAeK%lej"@eAAL + +eU@&4[Tm28%mqqUkS(F+VDa#lB&'rlRAllRP&l460Qc,)MHR$jMh@$8Y4Xc'e`cd + +ZE2AUUiH+fK96feb$epq&'RAQeLG&lCDjmP+"Kr8k9#qp'eI8RPf[6R$dS+$UcqI + +ELYSV[*ETFL&j[@lr803qd9I2A#bi4Vei3*d[+@Urk*!!&abe0HTVm%44"i4A6JN + +c(2I!kjRl6a9e813DK"A6p(LjRZZGaGH+1L5SiBT[(6ekd2*ILMSXU(l)#m3QMDB + +V+QTG!r*NG#RQai#DNh4,l0&!Ie`dYi98Y1%1A$5hKP4,`d9cHdKP'LkD@q4hYC* + +%dfdLeCCNN@i9UIBNLh5l5(8N68qhM&4R`d9cfdKP'bkD@dHU+qe&XRfNZSqc10j + +#8Me*&ZNfNZT0hSYd+dP&ri-FGM6G6P,p5D,rPNT0`dQLk5+6'NLb5"HDe'$L)Pe + +X8N2bj-Z'$r$6-$NZjLGC)1lB-"jQSff@[ak%LJ[rI#%p2ddAGREN(@"V+,S6CI! + +I!!!0$3KRBbj38%-ZZ@0M8&"$,VN!N"#$BJ#3%4B!!!d'!*!%rj!%68e38Ne33d- + +"!+X[PfqV-$P*!!!'-3!!&UB!!!(&!!!&C80(jji!N!BMM#0%$L)UANhN3L9rV@9 + +B`f#c2p$XpAVVCc-[`k20Y5bJ+CTHPScj`Z'!lmr*#EPaRH(ZcR!J!!rqMKG"q)# + +cj'G%46qffB3q8Aqp4R6FA83PM6`KUjaYD&IlZ@jDrY"pk[b&AZrdH*kFbb9PM*S + +`4Kh$c8Lf0bVe+Y`Q$amM6mc%*C1(jF&1bFSdGIlLpc*04b#X&D8[&6R%+-#6HhJ + +kX"#A+Bp6%6RGkB&kM%'jh$ZLmam[1Irq,r82rGM"5H4bh1ZB+b"Z%&-pD)5CL9( + +AP(4UUK6$!(lkH+UPFXFARF-MIHHMXf!5Nd%SZYRQj'pfL)G3N!$94X#(q25G8U` + +VXL'QU3Njk8[phV2@0Q92J#d6rA2N1["[!%c(M4X-8p,0IcYJf2lRBmD2c)*RQEF + +68m'9jqq*MjHTji&GqDp$kh501r9fqVPJe4iQDRS)L!)ELqiX08i#@40jpP1+F@p + +iC&))L)Qq4Bk-cK-i*h`cDlN1cMBUbZA3+beKhX*-&UD`X%ME%F91fHB3BaCC''Y + +KNba-C@(,"-40Yl"l,#c8`YCDf%#"XGD%F4m3'*i'k"iah[Ddam+k"Xd3eV@02'B + +bj'D90I9p!!!-q)[jAU2HhQ[NiCQC&f(Ne`JR!hlN1''4Sjc`)hcL5IK+f(@8(q& + +(1&Nj2XreTBI[M!0dGB4'MK01#CFF2c,JK"*1MNZ1(q&(11@5ii5EKimF*ja``Np + +#bA(#bBL6BpQ6jq5imT-m2mQ!dq2N'H&2RT2M%Nii'6$J,PF!#N#jGS3IS9Uba%G + +'A-)*8[#%!j-9'#r3@EpUPQ9+NL6$ldj*kVS6INIK@`*q'q$hGRJCPb,`pUJm(fQ + +3!#mGrdQqe$Nm22hkJ2cerNp"i3$m4Z62S5YA40V([V`MbHF@)QPT2IN@3@$ceHm + +I&dT3GqF9K,'&&8[6LKMTbQ6@-*%bJE#4RM,b'FA*'VC5`0BBdTa"@aNXM#)mU'" + +N@d@XSIKMMiMh#RbbLSjLT49GG9"F84)Q8QfN&![N1hK"A'V5F,,dJIF@+`iNJEb + +H-(5Nar84j!"*Q54MH+j&08dYQc,(ipT9I+aFqIQc-XP313&803UUPPD4*+UAIlj + +$U+jMAP1QUSfEYV2Qp4HKfZ#TYQTCT)hEaCbp+ZXH0"m5USfHDV1HbL4cCT@41rr + +5+d+eL4&+'hR90)iLRp$LYcm)e5McQN@UMR#&$kKqr%eHU-DBejbUCC-k+P4N5r% + +Iha+Uc5aj)kVfm*'ej*8Dali5ULfHDLah-l$Zfer1#G9@6l8TTf*r,RKTZ2#Q8'h + +MA2&i%MYq(0aCicHKfPlfDYLeJ3*FFEG3l@"HmfJbqFrdHU&IU+jRHE95BmQFkJF + +29)qp)93hX!aCGLfYP0!jSEU4HF9)-e8M9rADGfC4U(BbVVC66+8XR2Hj2RAmGk' + +kLDNk8`@p0[6F"hrG,e3h`kmm(BhDMQjBm@`ejDH1pG)YbUXYM'Y'5aD`-H(VPZ) + +,*i6A,Nqe)D1Y'5@UV@HM3VAE)a3$3MT+9jAGa)HI#%*E@9ie+jmf-PA9dY#66`Z + +[fkMA!l&$eZ3)bP996crcal6`ZRdT$9NG0S#+V([`rRZ&eae,A%dMGB2V4H%9YPL + +LfZ3B194,NC[ik!QKZSYlaE"deVc1$3[9(XVeFJIG0T,9**@'AVXJZ2Db$%'!,$a + +e+d2+8SES`Z&RD1(C`m,VlM*Aj)cP#M@ZlJI#Djp(U28`fl)VL9dKY+IXeFM!HRJ + +MVc0#YCpj6@!,M0VrHYh,CMQN!FBjl1ZVEPhjaCK)``"6,6JiU@@ekMjdmEEPI@M + +3DpXKj3pi+f`LFFpIUPrF058)N4X)f4ZQ*P5c1[&!pGhC4i@Ue2BCE"bRL&haLRk + +Thb#ZUK&ZK-Kc9k4Z-[QKhdaf&1KhN!#*#IdZ-XfJhdPQ)I6l#![SYjD'HXp$hdA + +f$1LhNlN-r4DbV8$I8iS[RSEqj#URqY@$9b3dJG1XG))%khUHJMX,Vh896Z%"I%B + +PFK1MejpP2[@,$LpbTe[Q%h#[hhai0BBHF+r-MrTeL9G6k!!IKHa1rmf2qMf,9c6 + +d)%I[5Hq$1hVVq60(`H@-9fb&cfkb$BBDc1-Ck@@#jrVH%0cXH$@cIK[C#F&2Q9X + +[qpl(HTpEQ9F`KqVA3&iYS3Pl6#ARpIXMVpCP6[+ma`PkbJPkbJPkbJPkbJPkbJP + +kbJPkbJPkbJPk1MHKTlbJTlbJpqGlF2RNe4CD`1XDTfUZEYjDHE@[F0T$,KbK"Vc + +mA!9AAPiGS3Qjm[HQi+l-LraVj'p1i3&mcNKce1@eZ4pFX(PY@1(66rD18)Im"eF + +YAJ1K#AYcK92peXpVBfM#AZAIKi*r&r$U$"h)dkhp2[JI!kp0S3GjhdZZV))A!43 + +jH4kk(TLQKF4pTXhHI!ITRb%hcX3KfeN#**1EI54a"'@Z8(9Dm%D@b"Y#qhm!N!- + +0!!PRBfaTBLda,VPM8&"$,VN!N"#ah3#3%!9X!!!I``#3"2q3"&"56dT,38K-!3# + +TY1))Uc!eD!!!@F-!N!B563#3"2$I!*!)22J1`2KbNQaPEr+hGEX``Jk!Vpa0&eT + +RDl*eSGZ&%EEAc@iGG+hAYBDRapHZd6ETQH'lV2AbpMVJ4lN,ck0G4lMb)fcKAQi + +*AeLhm1)VRfPGM,"Zi8pBG1%a3VYZi@m,@rM#2'iAfhjHacE,K"[bJGYB,ZcNP&# + +"$cqJ[fRG`SmXR'aMC-H6r-)AXTaNHE+Fj"HkN!"0"R[G!H4jITB&`!(!dKX"PZ# + +Z+PX+S(dCS&YGZI3,cN3L+P4H)V5R@D3p,54$JD"3'!j')mhRcl%mUJ)9e2PVUaF + +j[6lNX)ll!4,jajb6UrZK!hSTX[caD`$ZIHl,pdeVm&EaLeKG-YjQB6AKT)84pF, + +kB$+55%ID`b-4QF0T19ckfSl,d['15$X-4cTr0"2!dIR5%1j[S4JQa0,J4lT!pkc + +"EjcQ2ZmmNDF36,1DH)X!8($N3ihbR+mcX1GC!E!0fi)+ra)rCUL`#HU&V9)ke`6 + +IhTB!b&RK%B!&4fA8Ecr8+8IBcr)4Z8L+$bmVaA0$-Lr)$3+SMf0Xkh!%1L(hiM$ + +H56i!P'Q(V3ZXrmCRE,f[6f'0N!"Z$E6%fl(AqCL20Ka-#kRdjh`qA&CRACe[!5i + ++PSiKjh)6PJM4H$#5%&U%HF#GqF0F$MM6fH)T68dFSQ!hQ*["e3hGME'TS#e`Fmq + +Sl`'0qRTZMfEcM@b8M`(hV,a,kqB4N8iZ[4Sh5b!9ddQpT9YP#5UK!NX`BDbr,"E + +!TME)X#08Bm,*$)fP2Ci@G1bTGUbETe@@q%4QL60h[2d5)BQGX-U5,*6)q)99'NX + +bP3a1pJZTH#BC&"!P%4'5XP`!Fm82LidDE@#h&eejC#m'cSQd"k1C&S(CD`*"Va" + +S%C+TmmkE6aJ*6S3kTd8)4GS&PNjQ"#DY1419T&!JQT+cV-0*5@'9$$5+K-58Y"% + +N8Ea'&)q3!*!!UeBZ'qd'!&14D",LQVJ'$qTI1DUU3$%0cAD!e9HMkl`KaGAASBj + +TJ#pMhSb5Rq0c+LJ3l3LJkD2dcrJM2Q%3Kh&mZL-JR(&m+L$L-)j29b,%B4br8)j + +X!Y$j4ZUh`)[eI!A!R(d!4AHG`LH[d[f@re6*b2mAI`)H5F0aI+2XYq2iC)+N`6M + +qC$b5"Z2ij,N%KHI*24K!$k@Plm*Hm'Rd8-bci0h@*rK6m%JDM[-[aZ1Nhq+IKNH + +UJA&mE-V&'KM(2a129!2Mq2,5(2qIrSHmNfTSR2rTH+3D'XHRfL81irM8FE,Ep4r + +eTUeM[5Ra8bilkJJ6f!)lF0e(0'p*Cke+2Nq9ccEjh#UIZq6c&[RmM(3ZV*!!cL0 + +k&5l"Jp4$Ilc)-m$9BDMqeV0m$l6LhM(EAX9A,10lG,aR)2GNb6Sm29&b0@CfmMd + +&Mr!pHLh'hX&p"qiPVV#h)jIcaN(YAHVY!-im,lH&lp&Fc$pX!KD$+,qKqbMQh", + +@BjDAX[M-KFF0&bH!le%r'GC@E`LVXP9mKXdeG)3QcED[U18Vq4jY2c-fD8XFl$a + +Jb0pEdXPRCYXVR!e1c(f%qF`GKAUQcPT3T6E-YjCF2GYHhq#[aqa0'*p@XJl4r*8 + +qM(Fa(e1(MAb2DUZDVTq-SD2mJ+kFAj*ldAQmX-KFQf"C5i,E1fA&P2jHj`!8*c4 + +Cbq,eU+LUqmriLrQ-H$8"RJ(GXC,YKXYCKk(M!EcN!3MV-HG3b@DB@MEAd"P5,9[ + +2CjDYplkH1ckr$1D5aNf'jH[,p0ehXaPCKe@(eI0#11SC',UQT)X9K3qD(G8hK#c + +C@GQUfADhU*AQPE#2X"A&i-9KaAUdDe$"bpQU)@mfJNfL,U61YQ4RBFiKFac+[hC + +Y@49Fi(Ye4UjKII9Fl[b`UM[(Ca+6ZhF[@mq`0Seer)R3*#Y$$IcK`pPc%EI6FKZ + +I`IV"'%bLZK'Mdl!5jqQ+3J!feU'k*f(FZf(EGY@@N!!CGAmMqd9@CrDD68d'jf( + +3TlQV6AYhAEJlGh4$epjV3bSqBiDXKA!BPjeTVUYp1pI,DPfESAK1"2eSD[B-elh + +H#"KCEIFl0K-Um0E-CFr[,$HC6Hhc`fDr-eb-HmN5*`iSE-8)!#TL+mfKpUV"jrc + +$X6fMXIlRYZ5'5$I94YXX-&C(`""L$Dkf)VmVe*%)GZr'mh(#3i3EqlYKNKblRf* + +'9fi`h"aV43`ejERI0DPfA"MDB``XX)HHa#bYS3h1c!hCcPlQ0+mDh0Yr`mEU8Hk + +YrAmUXCIMj8SFBkA%6iNVCjRI%C(IMj&E3@l3G[C&a#hGId-rBQbXrT)c0e6q'2p + +eC)89`[fJmPd62,qrh"5fBCA-$%rb1d1R5hbj`ddQ1G,60%Q1l'T#EqB1)110@)h + +%i!95M+ekEiM0HfqSHM1k9UQY&%V$jTQPB&VZFVm*4FmG"[Acbff$#qbZ,a3IKUr + +B"VZ2A1J-[B%elK$paa&k8Z63JaakNVNdL$c1fP%+A`QGIJ'bm6iH0ZklkX(0S"E + +8jP*3Mb,[3pbE@&fLD'2RS@ZY1`pG"kj1X1j#2R9*X*QX*TAMbYcVef*YX2)T6FA + +Q@D$Hf'AE5@VBGSP+2*elSqN#9T4Gc"`I)"SMr!P3K8hPL)Se--@E+!*#j8qBAdA + +F)f`H'*JMT!TSH@V*`'V2IZI1K@DpeEljYRXA2YJ9eU,IcfjLaVQJjXS%LTUELM' + +UNU1Q*M@HTVX(FV[-AA`QqadqFr3i9[JU81PlSB$r%d$A3iqhZfXV+KG!GjBeeU( + +[-cfI+9deX0(XqqDqeeCrEqGcqm6iUPf$i$#AQd`B@p0rSjJ6NR2d'hX'fX5-"MQ + +MU,pRS%(-F-NCDZeUk[$*BA*h$2XG9RaZHj-D6bq3!1YJC6AD61@QEFZ@lXi09,[ + +#3r`40LMRE"V0'C!!FecYKJh1Q(D[`hN%90BLbX@@Y!c8C8j3QmY!ApD)[GhVGTJ + +**CcApF6MTA!ZjkemqUrh9AKG,PI[cVeVI+q#h6`$QIm$kKcXmZ"@c&ph+[pbaRf + ++-2[6I1-)JqV1YQR9UpZ-&Cd9Uc'6i5P6JCdV6"8c-TKV%$1eQ*@af2(L22GJCe" + +VaTDFcfaEffcXh1Pef-$Pm$Vic)0VQmqbL$(+mRVQJpGcr8kVcZZakIJ-9F5"VJ2 + +A)XVacTfpDfd&ZhSY"9l2XleH6rpD3Epa6E1D10FlQJjH!G34SPGS&qM3*fC3Pe2 + +L`2L%lVY,CV!*T39qcpXH[fHHVQRU'%UAhk2&Qk`VKaD[,i2ZHk`cX2[6K&iQRrQ + +lbPXmS@QX)1Y!&RH`da"Y"8BfPYDc4GPC#3lV4AhlG+E(2&HTGaMM!VD)&65CaPL + +Dr4lQB&J09`k9kE(,mhf[0f[T[[2#[mfpH2-6*6k4bk,U5Z`kcd%Ia$UcfEZ2Z!G + +1&'%PEF2B1aKl$'0hBH`R',X1BjX`pP1-h6AD-aHa8TJD0Z"T@[KdIJ$5L*0!R+1 + +)NmCi#mDEj(J5i`fS4KaV[49[Y[ASjjGJCfSIkdaR)f+)e-#cLpMMH4iTJQFE+B$ + +RFiN4RXfXNFpBZGXAc[3QM,G2Yh*CMh@3!(q8lFE6#ID-P'YZ"AefKT9M99N2Re% + +Z5UJ[cKd0UjR$Y@%N5eQr[bVdDANH1X3[2[#XjcJ0%Se1!jKa'U#f[M%BE`p&`TC + +@-mfEF*1J""c`J'Sc4b0!`0Q1cH9X!e(3aCl!)H`k4qIhpfYS1)*',+EMMLJR'JM + +*XAVRp4,L3*6EFHJLENI+bThcfZ@BBX$BV8U1Sr-@+@iljX&F'M+D6*J-'5#(%1k + +[1&EhlT'("@L3!%(&RA-a6V0,2#9X9%3D8*&8fT'k`V(k5V),NCZX$kh*MY@GDYV + +4Y-8%c[bAlh!l-U6&69c*e@N4Mj-C)C2d+XbiMLZjUSJ3--Aq8HQ-$[R0RcMaPa8 + +e&lLqlpUj[TGS[iMVqri'VZr9AUl[KhZi[J-YA0r"GUl[d&eFhq'YA0rr0h*pEml + +RqYlHa2Ap"212)[Ba!pGh2-6e$Gc+p3dqbr80[FMe`hbZAjA&I4IA2aN0'##DQ-I + +F0B%8$M1bX*!!6V&dUi!$KD&N2-DNDAZFBic&F2BrKF2r6-!j%"D+4)8c'q,aD,f + +3!-3j51B9SJP@RdlLA(j+(8X++A@L25E3BD9ki@,HV9l@i1F0$6KDbP$RC(bL'2* + +%ikP8)(QCZL15MXe30%"dDAVbI)DMURqBCV&i5b4dfDrbrk!LN!!@@#SGL#9B+*j + +N3JH#Y3HLV#@5r"fhhq@IS5Jp9LM&BLQF6+PSMTk2cbS%9c)KQ@5a90K#Sf4N5PN + +S5M[3da4hiQK)k+XiA(ND$YpSYSe-m)LIZ,6N5rL%!p$M"e)Z2G@JJJ8FXU,((EM + +pQ)@$C4*&(*ZN6`SqKSGP)q02Q+F@[iqA@RaFJFBHbCM4qfMF%h!%89`D('LN6e` + +k'KDkIh4i5)XM8r4*4)JcM9hKZ+)%Kcj2Rl4%aj+pAcSALTmN,qQmF&6[3Z`$k*0 + +%H%M18RJEF-b22R&0qM&+6,@P[&-a!BIik*1U!BGKe64B611lY)`iBNHI9"S+Ab9 + +l)JjKd5HT3V25,H+!P%`9Z`rkT%9kNCS1THY!pHQ6Q&%@$8)T99L%Sfhd5H*hI$J + +64C28Y,C`Djl#m$6b!XGfTmrR*X8$d@L`Y6QkdK+%4i(E8[b59GP&,"cqQPC3ih4 + +MlA''N6k&X1iVfl4IfC%6%hNG3kaD8[4Nmd+LGcpXR+[Xb-XNFZZYEkLS`Q4G+Yd + +5L413!'S-T`$1NR'U9P55`+R)+U%aM8!K9-"b-+[Xk$GR5FTkh)hN*rJB5@-L'EP + +%j(6IK+GdbSlH-e9"XT!!TkM$335*3-%BFqd`miD+#P4)M`VKJ,5STAS-5DFJ,A9 + +lRF6mdQ"V)#Q+K-c,[YUNl&M9XNEZ@PkXmY(k8'eCj+P3G[5T%69*)e+cY5@CqV" + +#$%SP0969B)9`fR3N*L#-jAfF#50kqURL8%pU-)M3+FmipZBILqkTH!E9YJip)aj + +%`mKhi"GMeDhkeqSZq1IU*VIi[,SeRcM3"dM$M['C$j!!BhcZ!m11mCN2&2k,$aK + +qi32[Hr5%Rh[d,hX-I&T(k6&F2UIBBc4(!m'9d93k(d+2NBr*-djj`D*SpBJAZ,f + +9j!86F'3iZ$+9LDAqShqJf[jh,cLPbr2V[SPKZ8BUA*j'UT'@jR"M,2UIAFerUC* + +hbU&Hqqk24KaUB492qKV`$C4!&+Z"V#$rQ"GJ24rmKPrCa6X4KAZ0c$d@5+lmTal + +hVejS(qNI[*91V#iSP&p#b,2@2paR1A6E52mJe6FBBMJ1dGJL*2+9p3qIhj!![Bp + +M('C8fB"h)XK)5,I&%TpfThIZ`BHa&(9Vm2+9kL#QA,kQIZdYiIaLYrARRVV2f2q + +YNG[k'UGr%8DeBN-EK0EmEAlarTd(p5,rIHIa&j&hIpETLXk#R@jbC@-b,9jkj$[ + +SG20dc3jaep#MG,*Rm*9,kClGd#jFfLM2Qq@TmibVrRcNcU2@95h1CX5Efl"&%5r + +8mURGV@U5ZdHGS,k4EYRemG4[EPCrFjZ4PqYQYFV$Li`LB4cI%5Ak4CIabTc4cV5 + +Z`5pfTSPdXM(B'Xb,d*RQlCVl-6rbfNK(iUpddhemB9))4J14@"k%hM42efh'efl + +%*i192U1qBE',qSa81Y2F(%qfjbIV-mbRlM2Dk!QiiGN-X@CeBXhQjHJG2R%#l)P + +%*m$r!"'46R)DGS+2k[XNTp(qiGGq@r81$FI)IYZ`[)lZM!cTba)YbQKh2VHq(T' + +iYATPahXMf583L9i#-b!5'SA3JP$LMk5FV"eL5P&e,)!2AM(fqq[&rAqqJEX3ZJ0 + +4GUAcq1#I[$MlrpXrj3jb$ZiY+2BkkdRM@qKR3r"mcb,mia%m2lM89dZ[Vqh!-,f + +QqNbpVjjZ29qJCq04M`2d!b+N'UT5MqGLqX832%q[Aej$mA2Gr%)2D,J,T!VQVUK + +`%6jhAB9V+HAI4,rjJHFl+Pb,m4eQEZZ5@KrPp5aF@N9GqC2+ql1S&YkPdTmG6Gr + +!qEV`09U+&4c&223NLQNk-DpALZNdR1mDqVXNM'QAB`crlBKL%mp(M*G"*FCZ`&J + +DZ&cZG*Ki-f,J@mmLMhX`*R29E-FB[Qe,XDNr4DlPFZc[1GrDKlkqQYkKeBBaYUl + +YEqK(@E3aM+N[HKM14ThU%2X*Hb(-`McNHXhpB"3j2BDaPJB6I!Ne%&qEaD`r`V` + +YU-G"k"3ar)MaKKaEKl'$NQC6hd1-Lq4B$Q0G-XB+e-BRajCJ,+'*V3bd4NrqAp, + +B[bJT[kddmXG*R(e#AIa5)9RRT[cr!`!!$3!*Cf0XD@)Y-LkjBe"33bkj!*!3qL) + +!N"!0"J!!,h3!N!6rN!438Np+5d&)6!%!UE6L#+X`0A!!!#*k!*!'$d%!N!43[J# + +3#1j"$F$iCXbcEQ9ffFS2dS@*jbZl63NYVcACZY$0##1XPDZ$V[@ke[$dmVQ6K5h + +FYGEmE+(Rmc@246PGf0D9hF)@VNAi`VhS`KGM(GQA+lmmdfiI)f`c`Tq`63P23V[ + +Y`VEH`KHqX)9f(@(E*!Zrf-)@IZi)AhKXi3[E,M3j*432"&!HrHaD@&$M#f(,qq3 + +@XL1hN!$"3Rk6AcKCb%+1%di@J&@""TeG+a&(42abSQ*m9@@VL(4[%29TUPEGj%S + +NfN09'd1a&"q0T8,*F(-`0#85E)pZZ-eZrEB+Z[80G6A,A6ir2'5jYd$i*mlPdrI + +-@8-1XA6I6r6dUG[h&cAjUSAPI(dbhQEPDb0*+mqX6fN-*U1*9$3@'8GN$c0%(%0 + +GelfTH&Fd4Q0)jLrR%MNc2aM&pcf8d``Y,Ak!B(cHb*GQH1E2Phb'JLQq0Yi5)P* + +IZ&DMccNrDX`mDiN1BLbSE&MC!)B+3p!!(FM4Z3"pmf##5,64Fd39&fA9Eck6N4( + +q-Kr+TK`qGQ`-&dGPAb51%'Q'J"dB3bK$iZYMHPIm%$'QJ`j8f2l6cq5j@TmTYD& + +8Dh0,2)CCjkGqG*&J+Y5CqU@IDmIQUUrh9q!`X*4GG$59b(1#DBYLrXT3Hc`B6B4 + +D3NZ)Zr'(SNLFq4ETPX+0#01J@-c9Mci&E"ETe"lZK'B2D682F5pVpcl#6cM0`cF + +VIh2RdI%LA6N'$6l@jXi1I@kfp+LX3395@i-*Bq1p(FdBDS-m*N)0#&FB@QXXRJV + +TqHr&d$F[UDca!YiDjchaf-C3%T1`bTUFNM26%1V@@T1GbH#dKP"R2*d-KU#5L)D + +5FVQ)&NXr0"XEY)Prh,6j`NN!Fk+aB(Zk*F3lDTZ$[P"c5bMC1Arq8UD4i#5T15f + +KF$3@iP2*G)M2RB8&#LRFh0iTXfaMT'5S@aDD8))aK6DZ*"9[2BV(P+51c4hG,L+ + +c53S*k44Xa8Acmd49U9R$Xk-p6,4P'e,Rh4bZH3"e6"(G$Pjab5Ikh&MNk*3JKBH + +am`[rd,p4KJ)IdrpGAkQ!SYrdArSB+K6p(4q-kaYR%DeiK@MHTTrT+airpFpf(!c + +C6D6hMrH[fSGq[SpSi@NLdj2ApC8!q05rrM0pH5A%p,FGr*AqP!RpYPrTjl,kIr) + +Mrc0p)kiXJcl9Cb(1%'6hP`BRQ0MP'EU4U`lF@CCrSLp0(%#3!"HAp98B52*lSGq + +&ZrfkrM3CD5@kEp'%2R+m!*ldPFM#f(9p0R-`C#rdT5&)cLr`#Kk#rMULrlIXZ[j + +d'6P$Y0N+!(Y!54rDdc&h'$"brDYqB3l4$[hhr$0$4PE$2eXNb2ieb2fErJLM)1T + +RZCa*(rQIH68r2Xk[*I+#iKreEj!!r52r-kc1XRmYjSpI3ai@B(RaKIqI,BSqG$# + +E'MkH69X[ckB'iJEe$Qi`RhhAFB-&cq&lKKZFKRc"-D9m50)#'Z6Fp%2+jFLffS0 + +N5Tj%4@C5"GI&cC(ZFcD,h$e838lFZmM*m-eX'F$dP%A,,mqff[SF8$&N-KPiM91 + +9NF2XSa0J@f1fH(J8"hGPCVYkTSRLJ,V55r6R486P'%J,"U5PdFrVi(p*UM20Z#1 + +AjGIGE[0r"EdLeqdcjp[mNSplX,Y)hCYJ5aj0I@@G*jb-Gm65lHf-'iiR1d+aG!I + +M4Q-YACfKpTEfZ,40CpQLY-XkZ5B+lNFp6BS(cVppFXHLm)JE3biI%jRZ4TD29iR + +SY!R1P$QEBbjeBD*lqi'1GccMbIje'bEC1H@a56dI1a@*I@9pEqBF-qYcdaaAM`b + +5FjP9B(QLVT*e4Aa$'kXN*T*FX[j[jrbLXcJ8Me@X&Eh%AL-JTT!!Gd4B3#S&rjI + +6(0UBDSje*M'BT4+G-9BhC9*@-5jcH$[1@!XpJKl'$ZGDCHXmRb03ICB4reapCC! + +!(Mqj("6&rGSNfp+B@FQGKfZV'cfXb6ZLR8&V%2h"l5[mJ8hjJPR%eT0&kPUA"r- + +MPcHq*D-)FI[,GTp4[[$$5jiqJ&BGP+G#UkjaI6!H#dFM9NbNa28pDebXI1(,,(N + +ED'bUV!CChjPULFDCN!"U8NG00mXke@ZV@1Ge4VY$ke-3#PpeT"PAmJT`"+9)V,N + +pTl6IHLkVI,'RZ6PAIkpR2HXM[+GCRdK'0dVZpqGr6kpmXC'CT5KCd3'NL33K%LA + +eT(2pQ21Q5[3dR+GDX116UUkC9$)S5UXm2KGcINq`Y6NTP421bhiMS(ba5j&Vj+N + +6f#aTQ1JNeElPhNVPLj`GVbDV%DYQDdZbmeS[j5Xpee4GLelLG+PS4`JbeUXka[& + +k0V$H4$f6H2FMHFHjNP0bI"Sd(Fh4'2DERk5`R-%10TmaEFjrI`$I68b$mrG)kq6 + +aHBBP*&LlQC0%8Xl9HQQfr9b!L@&XcMHPT*eJ*QI3,1Ibj`$iNqZ&q@YbPJ1Ha&! + +Tc3P+,rc(E-IjIaGE%9QEH@4l"'92bccba&FiN!#)&l6[jHikPAbI*GrYmVe9[[I + +)phhbr86Z2U8bGeIk!)'b%TGV)mAiNDCMGeGHc9GI%IUT&GqZ"BjUSA+ed+mA[-2 + +LXC)(FAZaC"ZB'D&IrCc3Ep!"HarI&r!YF8GmAD,SLj2'YmVA4CaPLEK2k0IH*6a + +V*Vk$fS9GI4I"H5aL!-[(@%*ka9$HA3N5qMA()VUDA4&9YPT)mi[cZX*6&cM@eJP + +93VpZN!!h"R3P6RiqmI$[+mN)k3@15PH6#pcRH,qPD`T@&9NVUY3'[UeNf`)(%Um + +4l0h!LdSHK&T$P4pi$qrR04'Md+mkS'(0E3aI&)EejF*+mAAAd"56T5l"Ckd*lZ6 + +dYG-("ec$9*M3CUehlN4&9Aer+0`PT+AR#H3GeRp3FMK[%pq9er8Y223JLKM!HEY + +N,mdU@jbA#DY@la65UhIkhK'(PTE4BPEM30kDR@@'[UIiiUc6TNIh["CTp`k2hPr + +5`jXLjbc1QSI$eZbmE28#KdHUPIB[)RkQV95-AKqV@,pZ+bUiLHmHp@@M''(eB8f + +f*6X2R,FYF5Vrc4ePeE6)rfDaf,5cCM&h@d69*`VTa,5qikYhmZK0Ble`+6c9aU- + +'$C(cf9ZKQl&q68LMIi$490Bh%PU%6PbL0f'aB1Hl9(X5aT1l$Kj@l3YE82GhXer + +JkbdqLcQ3!1Fk6iB8YmemmZL+iq,&A6dRGi493YT#@5[6iERXA%YphBr&!El1[CF + ++&dD44l1b0lLIpNA*b0Ie[@mhS`,[c9hpkT&bXm8F@aUa0,JLKIL@V(3KLJm!)8* + +&l+8LDUmD1G8`KVdmJ3fHfLH1XVUTHZhcb&J6TE``hq4Z-c@i`ef*B0pah)HB(K3 + +H'HbMU6,f$BBChH*)C%0(+c3dM1IjL9Re`SV`bmEQ#NIi'&Lk[$Dk84behl,DCHN + +H16RiF'r0K2I@`Gr,ZCIaFJ8(9XVm+EKbPreGN!$mr6@mUF84qbhVQ,I8i-1$d1L + +YqD*,(#erAVJEVY!Kh&Y92c(6UfI+c4%lZQ4ZC'U$+c`cjjFl(c$,5(pJUS`F$5# + +EZE0`h)YZC!jHBaAMZcmFjCGm1&U$M9+Ne&j+T4(,h&)bVh&lrSC-Tmk6jY8epT% + ++KrZQ`[0dKhfNlm)+9rKGp,K6bKpRq*MNS4mHqT0LLL3I0lp35RH%Cbk#'pph)mE + +6[h0S,fP#'NXTD5D86d2hbhap`Y5EHAZ(lFME$j!!1d1fSr"6Rb5lf@C@BB2jcJl + +d"Pmq29"SQ8HDhKll%9B0qe'T%Lq*l`B@mDEXREcc)d9M9,K%USLj(+VSJHQqK)Q + +BUR$*mLCd,r",+)phKPA01S'YCFRQb(lRkmXX"TYMlpHHARDS*k*$hLm)m'`$`C@ + +&''S*&!*9bDJjS-&YYQGB2'VT%G,Cl`MTLd2Sm'j5'3C),I`f)I@3!2%1,)HU+UJ + +[bkq[4qlc"L&GfMhFDr(rrZQrf[,p)kG15hMhd4&b@XV0CQ"E"aq41''CBqMY(fk + +6'%db`c6B2p`N-G`b3k2E`LC4PM$L%f0jKiiA$`FdZ,h'8JHGYGjZ,MFIA,hUZ$K + +Fiik-#KIi%CQcHi)c,(2FXEaGVJlG5DIV!UPX*XE&5&T'QM)AD5aPC#KEMpRZ(3F + +@d#@FcrhLGd[T9XjApG)IRkldZGhZJ5-RYrVI*)HP'-lr3A8KTMck#[J2AZG[`VV + +Jha3@r)a[((G3NfNVUYR5CUc-9'i"NmFYABR*P@C*M$5iH4*6"eEDLVfl+"l+"(8 + +@M14#qZ$f$FE-%Cr66QkRcbQN$fhIF,09`KM,jee+2Zp$4fakRpHZ&p+X)mlfR0d + +"PD(-NB(YG[A4!D[DjheP`1FGh"ibp'lGS''H'jf"FrF4Q`L4&ES+2A+LQ%dj*8l + +JqAe2P46cqDAU"Zq2[3hH*IV!V%Q9RJD[$Y[IcD0hlLbM[MffBNarf[!E,'IqV1S + +aElL)9fHGF2%%2`0UDi(dPMEbbl2c%Kck4I2iE0i!RV[80kDaL&r1U`2Q5CH@"Lr + +[j0%0QdI,$*Mbr0mIb&Vl[VlL6mAA(hfaa#pj@9j6KDPc$R)3I@Chp&h`$&mbSC- + +1!RXIf22!RJ6fYm!H!,BEf0m"Hh*LCMEaT63VNSGE8@5Q-%`Tk#5JFa%k+H!Y`!- + +bRJ6HK'V%dHZYf,SBN!$R'c'C1LBRd`93$,0Ui1jQlR&I`LU#Zje9!2GEQ52F,Ia + +k)@hM(PmfejF`2MlEaQ@pYK(Kfraah#la*h*F5bXCXX8fMUr1HS@dXLKKFl&i-D, + +KRHjGikbVar'Y9la$l2RB6pmR,LdS'+0CVLaC,H`"dT@r%Z!F2cScr3P3LVMhU0$ + +RDQ6lXmIBIJ6h2FZaT-(pd#Tr(GX$[`!BEfIS4+1rNEepHBe0*1LCXfaR!QFkYKh + +"[C!!E89`RpfiTTEKYhU%C9l5FSYb1eVZ[NShdqFHU(5[B[`[Xmd%lNp8ZZr%``V + +Z`-Sk2q2e,eY9c6DeamCH2MPq""hf),AJ0Z`'mAk4BHU,`2"fN@(D$$6B3eKJHLe + +ijh+BEJhfCmrNX"X@BR0iMP35pJI3b"!RLM2TKUm#`jj4mR%B@%X1Qrhh`&k8X3q + +"I82'4(M5h,f&[F[64H#l[1e2f"XKA3FdhPMh,0f#,XX(PR*-SARJ23cXC6*+rTj + +($GBeQHQ,U+Ad,JkXA`G[(hJpP*%d'S#PC1a"B'rNDPDX"RC'a[6!hT)eeX&I3XE + +f-%rDMYpUEQfrmLafmJQYmYTfr+%XjmL[Mpm65YCl'2rr!!d!#'GMG'9cG#kjZ@0 + +38%-ZZ3#3%%0D!*!3(m-!!%+&!*!%rj!%8&*25NY"5%`"!+QdiJLV-$9B!!"5l3# + +3"K+K!*!%$I3!N!Me"!i!pCQCc1abX2*Ef-,&mj8EA@KjV4fRQfkf--,fZP@[Eld + +Z$dq2VmN'A5Bp-hbAY9lHAJFXfQdl+AG,Z2)ME*&GEJRrA-libQIDl@-,fic`*fc + +6K5HKhAEKE`YIq-)mEQiRK(pXXmb@iapGq-+kKCfFELT3q1c,IZ&ZXPf1@pl#b%) + +ffjdZC,)F@FK#&m,)B+r,!D4[CPq-FBbaqZ@-eH&@A,@%-I9,M(@V+THFE3i'I@, + +PFV%p`R[E)f,)lA5*'SmV)SBMaKm`"H(DkkSAQQdeb1%*lP8%I"Kcj(3rX&H6m0M + +IZTkaqjrj`UCT$PZ9X*!!V`m&fSamV5GNj#ReR!CAb"Z-H0XpDBqF`ePa(%eGaiT + +)S-2EcP+HcTr1B+bXmm9Kh'q$6Mf`X[$"KF4R$RhYV2*CXk3m49H%V`fdL)`T"cl + +J+-2j13Fpcq@-E8&E8'&IE%H%!Ne3,pZF#1HDf2Hf""Q,&l1('*Yr8%EphJ1GXSF + +r%JrNr)3rGBV*(aq@mf,a)FC8Kq$ER2+`6KCr)B9h0"r'+0,%0Xm[rQdqSqFB2cQ + +eBU69f4*S4krcbhc8LClZG$iIR'*cIAh0I"abUXM3iXkAEq$(ilQ,49r!j3f+,H) + +maNhp56c112ejNK@"P6JkPXIB&fjK8aKcR!drZX6iG+jqq&li[TdQiqM4U(!CR@& + +rGU+(,&FBA8QAdZJ+kKT@q*eSAPdm1Mm9!Sj'C"RE!a%aQhqm(IAaK-)B'-FE!ha + +jS(fj'%,(Uc#'FK,*f-@9@FC3113DEaI$J@M)*3)Pk"9$i'!+Qm`pccf[0,(*#J2 + +h%ZcNS8*JE#k(6ij38,[0q$[cVaRB"FIjhRDA,pSLmUCDTmXQ1P[%8(M@V%X))mK + +*81HhL'j[ZmK(3P'46jb,ab@$h%jI@)iU6J@&a*8bd!J5%NZ'TC%NDKY",5%K9lA + +%%1kQ%f8Z9IE(4kQ5X*9Mq!UPK%dirih2+53-k[E(m!QELQ!-Rl#ccq$6B)6Z-I` + +FQ(52iC0Hd6f'2a&QlKPm`YDG`5GX%V)aI-*'%r+rq)3prJ`qB9260)C2f"21i"- + +feI!B2QRI@@I`#A[5'Ic*-1NH`dIV+GeMrFY8Q(52j8mG(mdXar#TGUKe(X1R`pq + +T1G'EYSlfTT4IFZ446jL-RfpLA2G!eYX*@kf3!1dTXPdLfkfbh5AE'fAlbB5G8j' + +`4rJkCZFXKT(SUhpj-0jKc0+KVIl1dd)2DmAG-GY8*93X&AUb"HYJr,'#0E!H,EJ + +1NCe#Mr)KS8HMKZmGh)rJ,V"iE"haZ#h!9,BPYJl''HE&0`Sp@9F+$qSClfFqB9h + +h3F6FlY%JbNC43[653pSVJdcS86hQ89H[mbKL98+8Rk[YF1I00PeH*e3+2HTqAYH + +N,LMMCc%HqGX+1SASE&1&f@&'l%0mMD%M4m1VBND`e)EiiS,VCTXD(2B'40m'rl5 + +#08#c9pE!hmAAm#U26ZK4E&E48%VR2LJ-CTF+Lq-[Q!rPj"[UJRc-'14f6EKm3Rq + +[HC!!63aQaBb,eS*44IHY`T9#9"TN-1YJpRX&fl4AmahDMZpMp-1B4i1Br38Ef*5 + +LZGT1Yf,T@L'kG+hYpILK5iVBA1+i5A[CfL*0plhmp&KCF6DUCir(CadF[VkJLmr + +hl$189GrN0XCQaUTQQmSPVV*HpY33GT)apN++X4le+M"i0Epbf"EcSZR0GUYL,E' + +CL0P[#,$5,pp39-AQe,`b2HjB@cfAZmLMk)i,dH$ilTe,er+S69fpF0LG9mb$!l[ + +R31a#i(BDla#LU"ri@"l9MH5GKNUFPjh[CUb%le$F&p6Y@VGPQf+Mf`$HhiaG`0F + +EE!CpNpCmJ'NLh(AkA6XZh4NrZ+jVe`eZK4!eX*L4F(JZ0X03ArHcH#pICpR!*Pl + +XK4j0L8ffh'rc-KeIere1L4i-[$eMkE2E5r8'IIXP(S2Gl*Q)Zf#a'@X,Qq&K$)b + +8&-E"[@,S'A[+pp5)VrqCMI&KiNfa[Q3Qde9lQGE01baYqAD,Zb2SkYi*qa$K!H( + +QrQk@*rZq5ckG*6lNDIDh!N0&FHA[kK@2A1Tq5ZHFEh)rKLLeYSe0M3qAR,I8E&J + +jY+[rT[A9)lQhp[p4)R[CAjVd`eG)q5Ap59[1Ed$+lfq3!*Xb2P4bhK@8@k6rTRj + +JV+rq[$NqA2U`m"9NK3VKAUem9mqHIDj8lbP"PFc`j0R0lNQ*I,N$6AVCdp18*hY + +f0%'EZEh)H$fUN6,B3ica+pmIjZHp2ebp!DT9@&,)#Mf''B9-IjQPr#f@rm`"TRV + +fXT+Kq5E,f4-2X#q@$(82A'Tf[iND,j2dTmcpQ*4$$h,S#F8M6-VMR%F+f4IGNqB + +J'pZ22,VGhpLkJDP%PD'3!+P'N!"h!rF@[MkB[ljcr`h&frIIb#bGV(J(mUN2X4* + +pX9j4GNhmp4Y3'hcTK+D*KTP-YEkVC$Za8E*$BZ+*q*Y0FrMmf#+ql$LLcLXFCJU + +2[K5SU)%*YQ!q)e6KX1%9i!l`mjL@,h-VR'U"@M4@E)Vpm1i&"NfaDF-GpbrBfZ9 + +43qpR0r'kZ8c&&BRN0640K&FKHr90+PMRPJr'GaLkK'MXKd,di#&8q%UQd23bTI" + +9"Y@$aT[+kbSUjl2Z'0pB$phR08+dF1AJHN20YhDrGZhcfjrC,IPAlKKLCBC5[4k + +q9Idh5c&Z18Dc[QH`6BT`b"(jr6f$$LR#)NHSe0H#a(a5Q2KG+Ee$aFHh0DPJl5( + +93@8ePZK,p9Z@,YNC(kbfH)D&!Aj)MVPY*'C3MV'dDpHCrHTGCHB"TLM1TeLdU%9 + +-9@4Q+N-4da3eSVGlhF4QX!,1CRRd4iAX3Xj@qF4Il+k`@5b@hZfl9Y@m`Nb'kFM + +m(e%[4TI(rJ6aDdl'AmecRb,-rM4HPmkJZV0Y@[@eEEU+cSTV%FR$LPDJFf96T)J + +SBV95T"T4851Qcr(ieNkAfS!@ABKZ@GfXkpaZ+bYKPM*EQ4$GZVVj(+2NSbLEp4* + +QXhjcHh'fc9U5,85T)[CflEd"+)FkYrHZ,P(Zk$8UEGDRHfh@rY@LC[fUCKAPh&$ + +@Y1rVM$T#D)9kIMCdBMTe139Pm1GfheX`RFmY90UY2l2DVI1bQkD-SR6CVHVV',Y + +QH0(D)YCpAr&dG(pClTG)CrkkmRDVHaU[M*8KLl[iXi"f16cV#a[iKE'C33leSVV + +cA&k$1%ZK,B8aKer)+j[dSeNDl&DqM%FeA$0FT%'A9r0mEmcBIIHPIa9riGZ2&Y4 + +)Z5bXVN6AH6jd%(9@BZSH+"mmR)p+fJ,I1r!p$0mpm2dGI$I#GaYmI`rI25-pFcj + +Ib+CiY,#QH5B*Jb`#R#"`$J)R!Rm,r%fb2`5r!f`%81ZYQ*CVS1I,dCQD4M[6f8" + +d%aZ`,C3pl(R%#1`5BJ$fKC34E!2I+%5,Z6XAc,!&GAHH@mc&V-9$`JriRE!1mdm + +QBJfY6"1EAXca96'V%%d15UJ[MKrdU2JbblTde+I(r2fRV)GU*0F[GKFZ'6FZ&@C + +!@&e$S`1V*BfZ3,[Ekc'f'QM#1TGaI6mfFAd[dRd&lTYa2mhe[DcQqPkGarAYVFD + +pRq[EGj!!kh[Gb2@pdFVerHebVZqYjlLqJ6bZladIehI`(Ul[(a4Fhf(J[@rMqRk + +qJHZ,jh2ph!,FAqIkPGrNqY@YA,rQDG`$A2piD5R$)dE#I+49a0+%1a6`miQp3Qa + +bq2hBFJaMcC%A-H[Lh9kI1084#2JDa"!f3ALEk![b$C%30K$$+Rp)$+Z#lAk4M'@ + +U"BZ%FY95Keh3%Y-m5!m&aNNZUbm3$MY$+e3GhSKrHRQY-ib9%UaRb2XM&r&Bb[Q + +$#1m2Y(MG+riPr[FUR"'4$dHFrL$[$S4iX30Jl8iIhq)0r5khhm926M)p@LJ6T9) + +i'P,4l,[)jI1kP[&L+-6l`aiMMHaaP!k@(kR(!$5jIF64)2HV9c"fkm2Bb8M[NA, + +5*ahe$KKB9T9'TSPBKI4**`H4UR2Kk*+M&9J[`FHC*Q&NUD#pVUA83F[45Jadk'0 + +F3Yf1$dpTM65,Hfl&AGM3!#1U'a&eQabGKF82I&eA%c-D$%HjjT%"U4TMFAb*[&A + +h)@)HETXFRBf&$h`V0NVHj1U3!,`K#cY(qL511H*j`3MI14L%iN0H')LU%pY@kEb + +e@+I!ap@!&jDr$K6[395bNR+a,%&ISM6!LST@Uj*V5MUX3Y#A)"$4+kM@NKY`il$ + +S30pF$R`T#q@S*(BHeKMSieHp#Flf)`,0AQTaDcb@&2)PHQQ)5fb5Xdb1cXF+!Vj + +N8DB2,Ic5f4Kjid'T!M!XRlE0,$48%8&NcjVeLhiPLG[pfVbedR#BF'qX0CFl+(- + +SP#2N$)DCki1*FLTMEYAMF%qMfLlECUkT+5IZR$kIUlACYmcS)YhC12(&iZ3YB9' + +@5Q5*+ZHdkID)X$BCAmp+hXKTKT6AHm#U3r4C*hSQB(BrU*ZE[*&EJ[hH"NF&f1H + +b`j%@Ei"`&+-i5TRYhSDUbbZ*lE"hTGJB!9#%@0JA5pj3Yh-5l&V,'fQFRq0a03C + +$hZ956TYb(mp1hP#k+8NN)bQBbZ-#L*FT4c0ATc*h9&5!)3dB`XSCTF08SdMC5D3 + +Pj6BcCAk9Up8CNNK#jN9IDNVH8!QCSr)k39+0G(N`aFD&eSVN$99-XdNF%CZY,D( + +`"a@L69D5SkS@&F+T)ekr#"MM-CcF0*pfUMM`5Hd-*A450pjlk`mPT8VU"Y9h0R3 + +Mi#,4b)#J'D-9V[Mh#PIqZX**-8jAH0BrUp"aT*4UR0)#8Sh6@T!!8Se6@T!!maX + +Yd(kN"FGd1[HIG2TA[3DH,8Mf'TBDXp4V02ZFVQ8q2,U3!#'KemM%T"XRp@#KVcU + +Y"q@f5Y+$A#aMZCD&Srj`4S3qiL3hckljPY445pa8@+b09#FYcCj'[bpc@BGcr'Q + +!%69iq@)m[C*8URU(RG4!'ib%'PfYVS`*8j,-6"h[aReIXbG[D8k5c,e@cYh[$#h + +lT)pilFFr65[(JLU"+N',p`QF2Y40KM[Pq2-plHN1e&CT4R@a((P61@0C"rU4'Q` + +blVmMh8FNDTaTr9MRD@`4JjR-qSM6-pGM1,T84T8160L3!*%BDI-(2jh'hIh8YR5 + +r8BZ42Y@"2cR5GhfQ,m$+0,B(FZ(*qFCchdR[JG5Dl3[K98[0EFBhc6Jf!k'Hj$p + +R)(rUIIG)ebZT#lVHd,,'8%3DJQ5UfdlEP"@LKiU5A8P9!ff@U2hH-(@biF`FQ[( + +KV+6++NJeiI9JS(a#A@K@FPTGe,p@Pj4QR&)AdSc6kT,5M&2U3T15dqU5QT4mULl + +T5FPrl#eaeipXJ`L95k4YN!"fmDV'M(FlXp`hrMJpBDZc9%XlCB(Q0M6#dJJhdpT + +%2bZdFd30'KTT[d-6#2rA22prCQFCZHEjar[pNj2C69PYp)K@DM)V+8'fT!3C%RU + +0$!Sc%%F&0K8NII&jQb@NScQPp1@%DKc0DD4,rDbV-ccd@PV(lCAPY$H4%a*G2UI + +ARl'MdM)(c3+5MpDF8)f1Rr4*kNc)faB*9I4DMcVDlZfJPej1UXfAEck8RMde1"C + +Ci0@')p(QjN#S(A*Mr%a[J*8"E)T3G!%pL5YhHBl+"RVj4bhpa)5,Y@G#d)*M[FH + +rp@3IGap(N9*kF+TlbrUSQrlA5IIaD[aidXeYj&CVNMH83&CM+!&9RaC+%&Q"[`% + +!PM5C'9(,)ph(*fUTr9!YMqT9DV2iP&iGfErj4+r'r8D[mMkHFibb02iMPNjf1PA + +[d("$VLh(CI8d(p1LX&VN*cJbP(8k[pfF2kE#ZPqTX(51-%LC%ZXU[a22)[*i8[E + +rZJ[cIcUGL4G#pHMBk,e2kCF0VX,2PP#E5Iik[#T1$qmHrqXJc[6'Fa2`XLUETTM + +$*YV-$D3cYp12%m#qEb(qhJ$feL8eGE5PqJMF0!YqXU&'QZAY39+9b(8[r8`"-MX + +Ah$6![T!!ITF!pTb'bfV*EbNA&PMaKL[H#UA+i@kTX"!qGeH&C3R&EkCI&X"$k6d + +9PN9@f#m[VUY"R%+aB%N90%@4PhahPUZj([c3IkY-$A%eUr''+[Q8"m(LQS3[kcE + +1G+!PiF[1j8b6mBiYqG4I![EZK'rFji"Ab"55leDmdYV+9*,[$[MHa&2kj,XIH(K + +90KkIa-Ep'I$!Tj5(&h&2b4cN`,G2pSf$$kqZ5Vi*m(hh+pHLCV(B#pqMEAp*2`L + +K$S-ce482X[1!F4&mDd`jE#EL`-(e-DD6q,X(FCd12IXm1+#IdU#-2SFi1q)HB*d + +54KI`ANVie'C`8jVJFZTNa%85A%ip'ebqP1"bkZr$jj-acJ0'8-Di!,i@'@-Q-2E + +*q68KTiMXZ`ja[9RqCFj@hp%rG"RpQjINMlqNrpQ&-qA@"ki53rAP&2rr!!!0$3p + +YGbpRBh4PFh3Z0MK,,VN!N""453#3%#pd!!"+8`#3"2q3"%e08&*0680$!3#V,jH + +ZUc!jB!!!"M%!!"R%!!!"V3!!"E(*MaZS!*!'[VXM4!iL+Pj0j%)PIdhl9fbRBC! + +!DR1(JAFp3hUJ2KNcZ@(k&LeHlIYc*cMM1X2GRCf"!*`N(81C&iAQNTm4&Ifii1" + +EpGII4h6#PiP+'R-jb[e$&IeM12rA3hh-XBk+D2XK9#@U!P9e!@eRU22XRT!!%ar + +%6jaP3[FjFKhiIjQ@hidE$&25cAm$`-IrIXai*1U*jZd88q%pXX1%F$M`RNJbAQS + +ih%%N0J*@A""6p[pE#%1,cL9X%K8j[Z%i38$F)*'R%8!QpTQQT&06TCMf4amme9+ + +jii[1iC(HE43E%aa#QlrCjZ4[GSL(8*!!e8D-E"#r6LR@&GN3aF6F'028K*cdTGk + +aT$fkUhhK6F,P(Tj11!CFTLJ+QQSXDINp,M$RL-+Cm9q6j"VK+Hr'rhrjXB16b1@ + +iec&AC&Z,)bAP)A[QZNkT`brFF9bj0@L(b*(4H3)$i*YCbh9`YK90aj%$0a!Gm&! + +,de[B3!XlC'%$"-Eme,D0'(Z229-8DlB`9Q$FC!Y6@9L'KA%@PQm[")V0YM#PKBP + +$[mI#m!L#i#MfjAH50i4eE512Q3bj@@90I4m!N!--!'XcXfpJlh2Ij$4lRaZHF-P + +a`Tr-D)4&@%FjIAiV9hi5rZ3i@3NqRhV5`hI'm8m[3MNjENHi%AjN`!NMR"`rbB$ + +bTrc)FA,m$%r*F51Fm*03FTa`FTa`-Q#%%hlN'4R`Pa`RA(+FF+mMamRa)mq2m$2 + +#bB!#GjN8B'@Y6-+0iUpN*rl)-F)*2m)*8[#%!j-9H"9SN!!()1QkKK#+`Hm@K$S + +HJ&m,rN[#E`hmIJLEJ,q0bk)PQTCS@&q4J@q@4d"9U,FU)md-(0Yrf-'kLSC3Ech + +QTZ6PDfM!,6kXTJh48"8c3%-B$Af2ZR8CG9Ip2$-35k-p#&9[4Zd)$4`EE%%G46! + +,R0"9-23T99CN34j4,-#2%@HJ4P(6T'aDQa#N[iMDX5G2a3J5j8hqU`G8AI)J-HU + +[2pc+8DXTel3Q5K1DDDe`rC'MeMLS#5QV5"2QC-jFKV@(Y,XiDUf$'TI6Q941+fY + +NIrEXmabeMLSdTZC&6Ae8m48krm8h(,@HFXdUSU`BRMk!q[lRHBlD3,RQ4#QENT@ + +#"cXRI2X+4ie6jif)dMfM+mkEUadrc9%E(G5'h+TKlGFqRHHS#3He,LFDrPe`h($ + +QCBlDa(3e*P+'jG["RP9riDM0,PI9V"`8d09SikJYP'YH1C5kHVfHlZ'SDkKIpI4 + +i+LIkaJ28)bpbe,88e9!N694cCG6ZNqFjkMUUN!"T6DE6ZT(h&AViKGmikRVU"NX + +TAdR(H9q1FY4@bY@D,XL9SfF2rY6286HiPp,*+'9G,aJIFG50p#Uce14Gj3Y'd81 + +Ek"h5cFV&)blrQ+1f8B8b8UTJU&0#eN-9cVh+8GXGe*U-j!-kU)P6p4b9*UB'dj* + +PCDb-E#IIrF$K4qBkCkfIRK)eFi@ZrFEXr4ae-h@$T1I(e%`C&K,!AUi3T&L#1U` + +I'P&bCG3h(rRp#Fje+d8&50fBrKHeFp&j@4Q5M3GV$pea1eGSfk+(0$9pa80R1GF + +ZCkfce*a5FDbGI1mKMRSpifUSq482fFRj!BlD6Id+#UPkaDr(MfcMU0YGVSSeRLY + +8Z0V[F05H43q4)19lk0aM"lL(GMKViS"LkT1'T(MH+rPeTkZ3!*U"!([&H8FjkLl + ++0@RS306mKfX[64ZJ+`31D"5@fGUaCaUiVRd8Y@!C+5NVP42Ef6h&a0E[S,D5e*Z + +k$e*4k[,4R"1qUq@S0cKV-k$Hk86c@fiEqT2V*rYSlLHcfePEppip1YM9Hl2Del9 + +2!&`"@TQ,U#F1&[Z''jdelZ4b1(ZHmdimH"0(45eR)(&!*q9f)f6q6PCX0VTUBad + +IAd$pf!@`[ik1Br'KUlR)+fakrN"cHF(H36)2h%jb&H(+NrX0&jMF9VMIj$*$&L) + +T"p)0cLf`Yq1%"AXR6JQ`Yq'FKMf0GB,GdbRXPYLiZ+lq4#IBL8k`%jeJ*cV"6R5 + +#RHJ%1p%*GU)6l%3Rf)P1h%qc#+[@Y15RS-eL8qhT&"fJcd&k4dVkK,dC'pb'AVi + +MRZjKXmB'HccD3(IrcJ8G(KYmfk)&p1R"5Hkrqa'fKQc`$Bdfm0&Ek'dF5*Cm&25 + +6E"T+qQc(16M5i"iI4FpKHCCb3p#-XSR6I3[1YF$(e@dVrAm(hAhGA,f#1a4fVQ` + +D)a0bM1IcX19PNiJXd-QrQrjp$rTP0Nh4$ljDEE6C0*GdfSPEQNJ$[AaI"9dkQjE + +)"&rjZ5PSlpQXL6c)65I42'&jkHi((6HE659pGY(F%GhJrk#CBp-AQC!!QcfG`RF + +BE0C'2GbTm18(Qh@4"hI+cbI"'a-fkb-2I05,Qq*VI86`ZS90Dq6"IEUNPpZrZ6d + +IkmP@hp@`f9$5UmK,"LjZ2dGjKIdd'pTRSrf,Re6[[[HdcbYXX0R3aK[KcVI)#mr + +A-dm"R8jJFcLjAc2T0r!1Xr%Ph(NRKdhm"Y1PM9qd9#9(PFc#![X)[SNKr!e@jAm + +!N!-0$3pYGbpRBh4PFh3Z8&"$,VN!N"!4c!#3%%+&!*!)rj!%68e38Ne33d-"!+X + +[PkkV-$P&!!!'-3!!'Z!!!!'T!!!&bE5F%03!N!B"fL0%$L)UANhN3L9r6IYAE+G + +KN!"UFiH"Gce$HU!q'61jBIV#iB$[cjhJM1X-GhH'!`%ib6Q'-Lm+c58r)bVkFF( + +"YqU[[irS4$#9MENFjIkKL[iaR2rVS6lQ@%G&Y2d3UK*9JDUkJ,Bce(Pf6fJm&6R + +b2Z8HRJiXa'A+ir""h#2TreqK*11PKX-G4'@dI[MrP@fl(cXiL9b1Haec4BbeKmP + +aeJj"iNA$iL1d#Y1J+HR89#QQrG%86l98l[LLFhLNlhad)NaL2JK&0pZFr-d1m4! + ++XYS)fcSm[diTeKAC%-A8h"M6e)5Fp+AHXD3p1ZNm1FY%rabj$[`E!$0bi`E$P26 + +rG@!p"$aQr-JXH*CjLX,-Um9UPGj1-5VH)fY@`*(4VHaDSf,&r6CPrlq&--R1K6X + +*#r!9a`Q#"HZ@0$hdcLR&Z$Fm-LN%a%6I)NG'j`NF&EkCY9`(CaX9iFL4(fpK!IC + +B8#c-*P,XP1dG-@D4KE%@0XR#9"C'PcdhhF,ZXE"3#eYVB3-&a[CDHNU"FB-@YXI + +#PPJD!bcX5f0T(aH0)DaV'hR-C-M0+Q[Uq``!Da0l'f3fmMSr"jhCCQZ%N3NRNdf + +14LJRP"rPR[a@3Sqr%8D1NjAJmk5Hp2#G-Ic6Le"1MJm)Pachb(2###I(6c*J%8k + +j%8k1RiHRj,J46[K*+$P11$P11"P3`JNrmS`-q)!-Z'6!D6eKj2L4C`f-F$+J`(8 + +Q"D$m9QE4e,T1r"&qK,q%%k6J#3FQ+c!qS%%HJ+LU#N)S",rE%'S`i2Fjq"D$ha, + +iI4qf+2P[K53BJQi)Q['&0I#IjBQL)Y4CP"42pjcUHm,'ZSf'8'HBF--Ck@qdLS0 + +b3K-d'HXH'L*+S#ZS9C93Dp(hThY##E32SH*'Y!@KRP2p0@MV!TJ"6QM*DZUi,'% + +T+JeJ!r"$PM03TD!SBLUKM%E&Qd60d0-c)3Z*mVDqK3&9&I13!!6eTfr[iUM&P'Y + +#%F4446G@Z(l(88YXe)LB`Z+S2TE@Pf(0!mTp(,A84Uf3!",*H&STD'4qmZcc(,@ + +-+M3XC`4&IJbl#Phql%Z1'UCF8eL3!,#@e`G3hrdd`e(,+GHd)+EL%XlQBDHLAlh + +-85ZSm`B%mB'K&HG0PBjFj+L90QTjHXf`jUXI6h28L)eDPKBdpblBE[Mm*BjDaA6 + +94Z1DiGV"R*4rj+M9$PGCAcdSS+ZfQD2@8+iCI$4qqhSpdmj4DkPIeF4)2#fiaJ2 + +8Bbpbe(889F1L)XMT!QVVKFXFYBiUT"YMLB5UC9b&(RhKCikkRVV"`)8VDEQKZf- + +V4kfRA)f*V,4kp-cqUedFGB0c+Hf-8Y$eQ[B"4pe)Vc*,6IQVI%eEm0!QHSG8IIA + +L@5lrN!#MEUCQhhrr8(p,Ec3@kie#4,V"pIbK)a`9-T!!GBlk-`E@KJ84,f%LG'i + +f[T!!!'KLUKNie$XiPM(N0&lQH[KU'dGYS"j+L['X*Sp(8hPGSl0R1'UMM9U5&&e + +!'c8b%qDSN!"L,3rTKL6Ki3+b'A[l2CZI0G[Y06`a,LMk#PhcpFQ(1'S6pDZSCSE + +PC!&fUR[r&Uj3-eASS(Td!+F,U1H1r2)8jpT#83&5e5EZS1kBGej+JZb9Kc82h(- + +h9kKehN1+R,MPS8ZFDjZpPPPABF@aCZbG`abeRA(9j-b+KmcBG!p(lD"q"B9NGG@ + +[CimeFp5G$PGXM+5cUec0YcMUVRN2@9(2pG$Xii2F3jhf'KR%ZMUQL6M[[CaIGcX + ++b8Q)f,HFGj+MGP'Z-8d&S[SrA2I32!5k3L5#cQ1CV4NkAXjer4pehS"JT*BMJmh + +eq+jHMVUAFXdD@Pa-LB8NHQRI3K)PI3p-0D6jHqhb!-,0lkJIrAq#kpTYIkZh1S$ + +iJj!!%H0,"hSUqR8TjiTU6d$LH!3qd"l'QVp5(*Z0MQj%N5IR8$IK#2YVk#b4%AU + +KAhRjVG*[D*cA0T*HB1mJp`hf9R+*B@mR9a,f0R*MBGp1mJVX655"`0j)XK,X1mL + +pKlf"*+irG2*l,$B1E[#"6T2S$,#X@[56ejba+FlV&"bJcm2dMZ6dm6Xk0U4jAES + +MHGhp&Sp0DH#"lZkGmrT#0Q@"!rVX)TRXhr[K0j4X`S%(2RS$[3RXDKCpj(@KE-T + +cqZ`NL6E3i"kI4160319LE["D@$B9G'mQ#4Ai1,Ued1qGG(GeFr6blT!!hqqbU3a + +-b$&jRrZ0-TY)B)&1lYedll[ACE1T#Rl`e9TlcUBkTp0ZdVF%-H4Z[lGR8a1Bi#X + +h0hN["GM8"KlNTJYSfQ*jrHjlI6UE66PpZQMZ#'l`[pH@XGNEQ*!!Qr-kq@mqf+` + +,HVK6rLX60R@""hI+c5IHHaBfk`-2I,5(G,jrpK(H5aSfpB%(pqQkANlrj[4mV#G + +EHm2$CN01V`9H%R"aqMR+bhpj`iDqe%&p8bAIR!qTj%[4$kpFY(MK'lcmYcPXk&Z + +H1lcmlTi0lIT[mPVbJIFUL!elGjRM4BM8c8"+#$@"@kr%qK5GrJGH8d5JeDSp%6Z + +S`aY94TZmpLQ+$H(Nh"cl%r`RK-KrL#Vr!3#3!aq$!!!"!*!$!43!N!-8!*!$-Tr + +lRLe!rr#`!,K[$#eZd!6rm2rdd"lm`FAKdkSV8FY+$deKBe"bEfTPBh4c,R0TG!) + +!N!06594%8dP8)3#3"P0*9%46593K!*!BUc!jI3!!8M8!!!&'"1"2l'mDG@6JrHc + +K@5U#NI*HN@GK!Z"2kQ`FG&2UN!"S!!,L@5[48(adA`CdC!EJ6qj[8hJS!!EJEHl + +LEe5!)D$!FJC1ANl!*IrX51FI-#D`jL63G!*&0K!+1Li!&Ri!)VX-S"lbUKQJ(Z` + +3!+SDI!$!#3ZT8,aIE!!!Q$!'8!6"aG!!N!-3!#X!"3%B!J#3"`-!N!-"!*!$!43 + +!N!-8!*!$-J$j(l!@#J#3!a`!-J!!8f9dC`#3!`S!!2rr!*!&q@G%'@B: + diff --git a/support/gc/Mac_files/MacOS_Test_config.h b/support/gc/Mac_files/MacOS_Test_config.h new file mode 100644 index 00000000..c95f4bb2 --- /dev/null +++ b/support/gc/Mac_files/MacOS_Test_config.h @@ -0,0 +1,91 @@ +/* + MacOS_Test_config.h + + Configuration flags for Macintosh development systems. + + Test version. + + + + 11/16/95 pcb Updated compilation flags to reflect latest 4.6 Makefile. + + by Patrick C. Beard. + */ +/* Boehm, November 17, 1995 12:05 pm PST */ + +#ifdef __MWERKS__ + +// for CodeWarrior Pro with Metrowerks Standard Library (MSL). +// #define MSL_USE_PRECOMPILED_HEADERS 0 +#include +#ifndef __STDC__ +#define __STDC__ 0 +#endif + +#endif + +// these are defined again in gc_priv.h. +#undef TRUE +#undef FALSE + +#define ALL_INTERIOR_POINTERS // follows interior pointers. +//#define SILENT // want collection messages. +//#define DONT_ADD_BYTE_AT_END // no padding. +//#define SMALL_CONFIG // whether to a smaller heap. +#define NO_SIGNALS // signals aren't real on the Macintosh. +#define USE_TEMPORARY_MEMORY // use Macintosh temporary memory. + +// CFLAGS= -O -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DSILENT +// +//LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \ +// -DREDIRECT_MALLOC=GC_malloc_uncollectable \ +// -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS +// Flags for building libgc.a -- the last two are required. +// +// Setjmp_test may yield overly optimistic results when compiled +// without optimization. +// -DSILENT disables statistics printing, and improves performance. +// -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly +// altered stubborn objects, at substantial performance cost. +// Use only for incremental collector debugging. +// -DFIND_LEAK causes the collector to assume that all inaccessible +// objects should have been explicitly deallocated, and reports exceptions. +// Finalization and the test program are not usable in this mode. +// -DSOLARIS_THREADS enables support for Solaris (thr_) threads. +// (Clients should also define SOLARIS_THREADS and then include +// gc.h before performing thr_ or GC_ operations.) +// This is broken on nonSPARC machines. +// -DALL_INTERIOR_POINTERS allows all pointers to the interior +// of objects to be recognized. (See gc_priv.h for consequences.) +// -DSMALL_CONFIG tries to tune the collector for small heap sizes, +// usually causing it to use less space in such situations. +// Incremental collection no longer works in this case. +// -DLARGE_CONFIG tunes the collector for unusually large heaps. +// Necessary for heaps larger than about 500 MB on most machines. +// Recommended for heaps larger than about 64 MB. +// -DDONT_ADD_BYTE_AT_END is meaningful only with +// -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS +// causes all objects to be padded so that pointers just past the end of +// an object can be recognized. This can be expensive. (The padding +// is normally more than one byte due to alignment constraints.) +// -DDONT_ADD_BYTE_AT_END disables the padding. +// -DNO_SIGNALS does not disable signals during critical parts of +// the GC process. This is no less correct than many malloc +// implementations, and it sometimes has a significant performance +// impact. However, it is dangerous for many not-quite-ANSI C +// programs that call things like printf in asynchronous signal handlers. +// -DOPERATOR_NEW_ARRAY declares that the C++ compiler supports the +// new syntax "operator new[]" for allocating and deleting arrays. +// See gc_cpp.h for details. No effect on the C part of the collector. +// This is defined implicitly in a few environments. +// -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined +// as aliases for X, GC_realloc, and GC_free, respectively. +// Calloc is redefined in terms of the new malloc. X should +// be either GC_malloc or GC_malloc_uncollectable. +// The former is occasionally useful for working around leaks in code +// you don't want to (or can't) look at. It may not work for +// existing code, but it often does. Neither works on all platforms, +// since some ports use malloc or calloc to obtain system memory. +// (Probably works for UNIX, and win32.) +// -DNO_DEBUG removes GC_dump and the debugging routines it calls. +// Reduces code size slightly at the expense of debuggability. diff --git a/support/gc/Mac_files/MacOS_config.h b/support/gc/Mac_files/MacOS_config.h new file mode 100644 index 00000000..93c3c97a --- /dev/null +++ b/support/gc/Mac_files/MacOS_config.h @@ -0,0 +1,89 @@ +/* + MacOS_config.h + + Configuration flags for Macintosh development systems. + + + + 11/16/95 pcb Updated compilation flags to reflect latest 4.6 Makefile. + + by Patrick C. Beard. + */ +/* Boehm, November 17, 1995 12:10 pm PST */ + +#ifdef __MWERKS__ + +// for CodeWarrior Pro with Metrowerks Standard Library (MSL). +// #define MSL_USE_PRECOMPILED_HEADERS 0 +#include +#ifndef __STDC__ +#define __STDC__ 0 +#endif + +#endif /* __MWERKS__ */ + +// these are defined again in gc_priv.h. +#undef TRUE +#undef FALSE + +#define ALL_INTERIOR_POINTERS // follows interior pointers. +#define SILENT // no collection messages. +//#define DONT_ADD_BYTE_AT_END // no padding. +//#define SMALL_CONFIG // whether to use a smaller heap. +#define NO_SIGNALS // signals aren't real on the Macintosh. +#define USE_TEMPORARY_MEMORY // use Macintosh temporary memory. + +// CFLAGS= -O -DNO_SIGNALS -DSILENT -DALL_INTERIOR_POINTERS +// +//LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \ +// -DREDIRECT_MALLOC=GC_malloc_uncollectable \ +// -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS +// Flags for building libgc.a -- the last two are required. +// +// Setjmp_test may yield overly optimistic results when compiled +// without optimization. +// -DSILENT disables statistics printing, and improves performance. +// -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly +// altered stubborn objects, at substantial performance cost. +// Use only for incremental collector debugging. +// -DFIND_LEAK causes the collector to assume that all inaccessible +// objects should have been explicitly deallocated, and reports exceptions. +// Finalization and the test program are not usable in this mode. +// -DSOLARIS_THREADS enables support for Solaris (thr_) threads. +// (Clients should also define SOLARIS_THREADS and then include +// gc.h before performing thr_ or GC_ operations.) +// This is broken on nonSPARC machines. +// -DALL_INTERIOR_POINTERS allows all pointers to the interior +// of objects to be recognized. (See gc_priv.h for consequences.) +// -DSMALL_CONFIG tries to tune the collector for small heap sizes, +// usually causing it to use less space in such situations. +// Incremental collection no longer works in this case. +// -DLARGE_CONFIG tunes the collector for unusually large heaps. +// Necessary for heaps larger than about 500 MB on most machines. +// Recommended for heaps larger than about 64 MB. +// -DDONT_ADD_BYTE_AT_END is meaningful only with +// -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS +// causes all objects to be padded so that pointers just past the end of +// an object can be recognized. This can be expensive. (The padding +// is normally more than one byte due to alignment constraints.) +// -DDONT_ADD_BYTE_AT_END disables the padding. +// -DNO_SIGNALS does not disable signals during critical parts of +// the GC process. This is no less correct than many malloc +// implementations, and it sometimes has a significant performance +// impact. However, it is dangerous for many not-quite-ANSI C +// programs that call things like printf in asynchronous signal handlers. +// -DOPERATOR_NEW_ARRAY declares that the C++ compiler supports the +// new syntax "operator new[]" for allocating and deleting arrays. +// See gc_cpp.h for details. No effect on the C part of the collector. +// This is defined implicitly in a few environments. +// -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined +// as aliases for X, GC_realloc, and GC_free, respectively. +// Calloc is redefined in terms of the new malloc. X should +// be either GC_malloc or GC_malloc_uncollectable. +// The former is occasionally useful for working around leaks in code +// you don't want to (or can't) look at. It may not work for +// existing code, but it often does. Neither works on all platforms, +// since some ports use malloc or calloc to obtain system memory. +// (Probably works for UNIX, and win32.) +// -DNO_DEBUG removes GC_dump and the debugging routines it calls. +// Reduces code size slightly at the expense of debuggability. \ No newline at end of file diff --git a/support/gc/Mac_files/dataend.c b/support/gc/Mac_files/dataend.c new file mode 100644 index 00000000..a3e3fe84 --- /dev/null +++ b/support/gc/Mac_files/dataend.c @@ -0,0 +1,9 @@ +/* + dataend.c + + A hack to get the extent of global data for the Macintosh. + + by Patrick C. Beard. + */ + +long __dataend; diff --git a/support/gc/Mac_files/datastart.c b/support/gc/Mac_files/datastart.c new file mode 100644 index 00000000..a9e0dd59 --- /dev/null +++ b/support/gc/Mac_files/datastart.c @@ -0,0 +1,9 @@ +/* + datastart.c + + A hack to get the extent of global data for the Macintosh. + + by Patrick C. Beard. + */ + +long __datastart; diff --git a/support/gc/Makefile b/support/gc/Makefile new file mode 100644 index 00000000..7f708715 --- /dev/null +++ b/support/gc/Makefile @@ -0,0 +1,417 @@ +# Generated automatically from Makefile.in by configure. +# Primary targets: +# gc.a - builds basic library +# libgc.a - builds library for use with g++ "-fgc-keyword" extension +# c++ - adds C++ interface to library +# cords - adds cords (heavyweight strings) to library +# test - prints porting information, then builds basic version of gc.a, +# and runs some tests of collector and cords. Does not add cords or +# c++ interface to gc.a +# cord/de - builds dumb editor based on cords. +ABI_FLAG= +CC = gcc $(ABI_FLAG) +CXX = c++ $(ABI_FLAG) +AS = as $(ABI_FLAG) +PRJDIR = ../.. +srcdir = . +# The above doesn't work with gas, which doesn't run cpp. +# Define AS as `gcc -c -x assembler-with-cpp' instead. +# Under Irix 6, you will have to specify the ABI for as if you specify +# it for the C compiler. + +CFLAGS= -O2 -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT -I /usr/local/include + +# For dynamic library builds, it may be necessary to add flags to generate +# PIC code, e.g. -fPIC on Linux. + +# Setjmp_test may yield overly optimistic results when compiled +# without optimization. +# -DSILENT disables statistics printing, and improves performance. +# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly +# altered stubborn objects, at substantial performance cost. +# Use only for incremental collector debugging. +# -DFIND_LEAK causes the collector to assume that all inaccessible +# objects should have been explicitly deallocated, and reports exceptions. +# Finalization and the test program are not usable in this mode. +# -DSOLARIS_THREADS enables support for Solaris (thr_) threads. +# (Clients should also define SOLARIS_THREADS and then include +# gc.h before performing thr_ or dl* or GC_ operations.) +# Must also define -D_REENTRANT. +# -D_SOLARIS_PTHREADS enables support for Solaris pthreads. +# Define SOLARIS_THREADS as well. +# -DIRIX_THREADS enables support for Irix pthreads. See README.irix. +# _DLINUX_THREADS enables support for Xavier Leroy's Linux threads. +# see README.linux. -D_REENTRANT may also be required. +# -DALL_INTERIOR_POINTERS allows all pointers to the interior +# of objects to be recognized. (See gc_priv.h for consequences.) +# -DSMALL_CONFIG tries to tune the collector for small heap sizes, +# usually causing it to use less space in such situations. +# Incremental collection no longer works in this case. +# -DLARGE_CONFIG tunes the collector for unusually large heaps. +# Necessary for heaps larger than about 500 MB on most machines. +# Recommended for heaps larger than about 64 MB. +# -DDONT_ADD_BYTE_AT_END is meaningful only with +# -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS +# causes all objects to be padded so that pointers just past the end of +# an object can be recognized. This can be expensive. (The padding +# is normally more than one byte due to alignment constraints.) +# -DDONT_ADD_BYTE_AT_END disables the padding. +# -DNO_SIGNALS does not disable signals during critical parts of +# the GC process. This is no less correct than many malloc +# implementations, and it sometimes has a significant performance +# impact. However, it is dangerous for many not-quite-ANSI C +# programs that call things like printf in asynchronous signal handlers. +# -DNO_EXECUTE_PERMISSION may cause some or all of the heap to not +# have execute permission, i.e. it may be impossible to execute +# code from the heap. Currently this only affects the incremental +# collector on UNIX machines. It may greatly improve its performance, +# since this may avoid some expensive cache synchronization. +# -DOPERATOR_NEW_ARRAY declares that the C++ compiler supports the +# new syntax "operator new[]" for allocating and deleting arrays. +# See gc_cpp.h for details. No effect on the C part of the collector. +# This is defined implicitly in a few environments. +# -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined +# as aliases for X, GC_realloc, and GC_free, respectively. +# Calloc is redefined in terms of the new malloc. X should +# be either GC_malloc or GC_malloc_uncollectable. +# The former is occasionally useful for working around leaks in code +# you don't want to (or can't) look at. It may not work for +# existing code, but it often does. Neither works on all platforms, +# since some ports use malloc or calloc to obtain system memory. +# (Probably works for UNIX, and win32.) +# -DIGNORE_FREE turns calls to free into a noop. Only useful with +# -DREDIRECT_MALLOC. +# -DNO_DEBUGGING removes GC_dump and the debugging routines it calls. +# Reduces code size slightly at the expense of debuggability. +# -DJAVA_FINALIZATION makes it somewhat safer to finalize objects out of +# order by specifying a nonstandard finalization mark procedure (see +# finalize.c). Objects reachable from finalizable objects will be marked +# in a sepearte postpass, and hence their memory won't be reclaimed. +# Not recommended unless you are implementing a language that specifies +# these semantics. +# -DFINALIZE_ON_DEMAND causes finalizers to be run only in response +# to explicit GC_invoke_finalizers() calls. +# -DATOMIC_UNCOLLECTABLE includes code for GC_malloc_atomic_uncollectable. +# This is useful if either the vendor malloc implementation is poor, +# or if REDIRECT_MALLOC is used. +# -DHBLKSIZE=ddd, where ddd is a power of 2 between 512 and 16384, explicitly +# sets the heap block size. Each heap block is devoted to a single size and +# kind of object. For the incremental collector it makes sense to match +# the most likely page size. Otherwise large values result in more +# fragmentation, but generally better performance for large heaps. +# -DUSE_MMAP use MMAP instead of sbrk to get new memory. +# Works for Solaris and Irix. +# -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than +# GC_scratch_alloc() to get stack memory. +# -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever +# the garbage collector detects a value that looks almost, but not quite, +# like a pointer, print both the address containing the value, and the +# value of the near-bogus-pointer. Can be used to identifiy regions of +# memory that are likely to contribute misidentified pointers. +# -DOLD_BLOCK_ALLOC Use the old, possibly faster, large block +# allocation strategy. The new strategy tries harder to minimize +# fragmentation, sometimes at the expense of spending more time in the +# large block allocator and/or collecting more frequently. +# If you expect the allocator to promtly use an explicitly expanded +# heap, this is highly recommended. +# + + + +LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \ + -DREDIRECT_MALLOC=GC_malloc_uncollectable \ + -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS +# Flags for building libgc.a -- the last two are required. + +CXXFLAGS= $(CFLAGS) +AR= ar +RANLIB= ranlib + + +# Redefining srcdir allows object code for the nonPCR version of the collector +# to be generated in different directories. In this case, the destination directory +# should contain a copy of the original include directory. +srcdir = . + +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o + +CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c + +CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga + +CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o + +SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \ + sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \ + gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \ + threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \ + gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \ + include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \ + solaris_threads.h $(CORD_SRCS) + +OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \ + README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \ + SCoptions.amiga README.amiga README.win32 cord/README \ + cord/gc.h include/gc.h include/gc_typed.h include/cord.h \ + include/ec.h include/private/cord_pos.h include/private/gcconfig.h \ + include/private/gc_hdrs.h include/private/gc_priv.h \ + include/gc_cpp.h README.rs6000 \ + include/weakpointer.h README.QUICK callprocs pc_excludes \ + barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \ + MacOS.c EMX_MAKEFILE makefile.depend README.debugging \ + include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \ + Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \ + add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \ + win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \ + README.alpha README.linux version.h Makefile.DLLs gc_watcom.asm \ + WCC_MAKEFILE + +CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \ + $(srcdir)/cord/private/cord_pos.h + +UTILS= if_mach if_not_there threadlibs + +# Libraries needed for curses applications. Only needed for de. +CURSES= -lcurses -ltermlib + +# The following is irrelevant on most systems. But a few +# versions of make otherwise fork the shell specified in +# the SHELL environment variable. +SHELL= /bin/sh + +SPECIALCFLAGS = +# Alternative flags to the C compiler for mach_dep.c. +# Mach_dep.c often doesn't like optimization, and it's +# not time-critical anyway. +# Set SPECIALCFLAGS to -q nodirect_code on Encore. + +#all: checkconf libgc.a gctest +all: checkconf libgc.a + +pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS) + make -f PCR-Makefile depend + make -f PCR-Makefile + +$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \ + $(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile +# The dependency on Makefile is needed. Changing +# options such as -DSILENT affects the size of GC_arrays, +# invalidating all .o files that rely on gc_priv.h + +mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h + +base_lib libgc.a: $(OBJS) dyn_load.o $(UTILS) + echo > base_lib + rm -f on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 $(AR) rus libgc.a $(OBJS) dyn_load.o + ./if_not_there on_sparc_sunos5_1 $(AR) ru libgc.a $(OBJS) dyn_load.o + ./if_not_there on_sparc_sunos5_1 $(RANLIB) libgc.a || cat /dev/null +# ignore ranlib failure; that usually means it doesn't exist, and isn't needed + +cords: $(CORD_OBJS) cord/cordtest $(UTILS) + rm -f on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 $(AR) rus libgc.a $(CORD_OBJS) + ./if_not_there on_sparc_sunos5_3 $(AR) ru libgc.a $(CORD_OBJS) + ./if_not_there on_sparc_sunos5_3 $(RANLIB) libgc.a || cat /dev/null + +gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile + $(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc + +test_cpp: $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \ +base_lib $(UTILS) + rm -f test_cpp + ./if_mach HP_PA "" $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o libgc.a -ldld + ./if_not_there test_cpp $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o libgc.a `./threadlibs` + +c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp + rm -f on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 $(AR) rus libgc.a gc_cpp.o + ./if_not_there on_sparc_sunos5_4 $(AR) ru libgc.a gc_cpp.o + ./if_not_there on_sparc_sunos5_4 $(RANLIB) libgc.a || cat /dev/null + ./test_cpp 1 + echo > c++ + +dyn_load_sunos53.o: dyn_load.c + $(CC) $(CFLAGS) -DSUNOS53_SHARED_LIB -c $(srcdir)/dyn_load.c -o $@ + +# SunOS5 shared library version of the collector +sunos5gc.so: $(OBJS) dyn_load_sunos53.o + $(CC) -G -o sunos5gc.so $(OBJS) dyn_load_sunos53.o -ldl + ln sunos5gc.so libgc.so + +# Alpha/OSF shared library version of the collector +libalphagc.so: $(OBJS) + ld -shared -o libalphagc.so $(OBJS) dyn_load.o -lc + ln libalphagc.so libgc.so + +# IRIX shared library version of the collector +libirixgc.so: $(OBJS) dyn_load.o + ld -shared $(ABI_FLAG) -o libirixgc.so $(OBJS) dyn_load.o -lc + ln libirixgc.so libgc.so + +# Linux shared library version of the collector +liblinuxgc.so: $(OBJS) dyn_load.o + gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo + ln liblinuxgc.so libgc.so + +mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS) + rm -f mach_dep.o + ./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s + ./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s + ./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s + ./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s + ./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s + ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c + +mark_rts.o: $(srcdir)/mark_rts.c if_mach if_not_there $(UTILS) + rm -f mark_rts.o + -./if_mach ALPHA OSF1 $(CC) -c $(CFLAGS) -Wo,-notail $(srcdir)/mark_rts.c + ./if_not_there mark_rts.o $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c +# Work-around for DEC optimizer tail recursion elimination bug. +# The ALPHA-specific line should be removed if gcc is used. + +alloc.o: version.h + +cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordbscs.c + mv cordbscs.o cord/cordbscs.o +# not all compilers understand -o filename + +cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordxtra.c + mv cordxtra.o cord/cordxtra.o + +cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordprnt.c + mv cordprnt.o cord/cordprnt.o + +cord/cordtest: $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a $(UTILS) + rm -f cord/cordtest + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a -ldld + ./if_not_there cord/cordtest $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a `./threadlibs` + +cord/de: $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(UTILS) + rm -f cord/de + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(CURSES) -lucb `./threadlibs` + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(CURSES) -ldld + ./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a -lcurses + ./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a -lcurses `./threadlibs` + ./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a -lcurses + ./if_not_there cord/de $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(CURSES) `./threadlibs` + +if_mach: $(srcdir)/if_mach.c $(srcdir)/gcconfig.h + $(CC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c + +threadlibs: $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile + $(CC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c + +if_not_there: $(srcdir)/if_not_there.c + $(CC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c + +clean: + rm -f libgc.a *.o gctest gctest_dyn_link test_cpp \ + setjmp_test mon.out gmon.out a.out core if_not_there if_mach \ + threadlibs $(CORD_OBJS) cord/cordtest cord/de + -rm -f *~ + +gctest: test.o libgc.a if_mach if_not_there + rm -f gctest + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest test.o libgc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o gctest test.o libgc.a -ldld + ./if_not_there gctest $(CC) $(CFLAGS) -o gctest test.o libgc.a `./threadlibs` + +# If an optimized setjmp_test generates a segmentation fault, +# odds are your compiler is broken. Gctest may still work. +# Try compiling setjmp_t.c unoptimized. +setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/gc.h if_mach if_not_there + $(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c + +test: KandRtest cord/cordtest + cord/cordtest + +# Those tests that work even with a K&R C compiler: +KandRtest: setjmp_test gctest + ./setjmp_test + ./gctest + +add_gc_prefix: add_gc_prefix.c + $(CC) -o add_gc_prefix $(srcdir)/add_gc_prefix.c + +gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix + ./add_gc_prefix $(SRCS) $(OTHER_FILES) > /tmp/gc.tar-files + (cd $(srcdir)/.. ; tar cvfh - `cat /tmp/gc.tar-files`) > gc.tar + +pc_gc.tar: $(SRCS) $(OTHER_FILES) + tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES) + +floppy: pc_gc.tar + -mmd a:/cord + -mmd a:/cord/private + -mmd a:/include + -mmd a:/include/private + mkdir /tmp/pc_gc + cat pc_gc.tar | (cd /tmp/pc_gc; tar xvf -) + -mcopy -tmn /tmp/pc_gc/* a: + -mcopy -tmn /tmp/pc_gc/cord/* a:/cord + -mcopy -mn /tmp/pc_gc/cord/de_win.ICO a:/cord + -mcopy -tmn /tmp/pc_gc/cord/private/* a:/cord/private + -mcopy -tmn /tmp/pc_gc/include/* a:/include + -mcopy -tmn /tmp/pc_gc/include/private/* a:/include/private + rm -r /tmp/pc_gc + +gc.tar.Z: gc.tar + compress gc.tar + +gc.tar.gz: gc.tar + gzip gc.tar + +lint: $(CSRCS) test.c + lint -DLINT $(CSRCS) test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall" + +# BTL: added to test shared library version of collector. +# Currently works only under SunOS5. Requires GC_INIT call from statically +# loaded client code. +ABSDIR = `pwd` +gctest_dyn_link: test.o libgc.so + $(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread + +gctest_irix_dyn_link: test.o libirixgc.so + $(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc + +test_dll.o: test.c libgc_globals.h + $(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o + +test_dll: test_dll.o libgc_dll.a libgc.dll + $(CC) test_dll.o -L$(ABSDIR) -lgc_dll -o test_dll + +SYM_PREFIX-libgc=GC + +# Uncomment the following line to build a GNU win32 DLL +# include Makefile.DLLs + +reserved_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/GC_/_GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done + +user_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/_GC_/GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done + +# Remake configuration +checkconf: + @if [ -f $(srcdir)/../devel ]; then \ + $(MAKE) -f $(srcdir)/conf.mk freshconf \ + srcdir="$(srcdir)" PRJDIR="$(PRJDIR)"; \ + fi + +# End of Makefile diff --git a/support/gc/Makefile.DLLs b/support/gc/Makefile.DLLs new file mode 100644 index 00000000..011f49d3 --- /dev/null +++ b/support/gc/Makefile.DLLs @@ -0,0 +1,107 @@ +#-----------------------------------------------------------------------------# + +# Makefile.DLLs, version 0.4. + +# Contributed by Fergus Henderson. + +# This Makefile contains rules for creating DLLs on Windows using gnu-win32. + +#-----------------------------------------------------------------------------# + +# This rule creates a `.def' file, which lists the symbols that are exported +# from the DLL. We use `nm' to get a list of all the exported text (`T') +# symbols and data symbols -- including uninitialized data (`B'), +# initialized data (`D'), read-only data (`R'), and common blocks (`C'). +%.def: %.a + echo EXPORTS > $@ + nm $< | grep '^........ [BCDRT] _' | sed 's/[^_]*_//' >> $@ + +# We need to use macros to access global data: +# the user of the DLL must refer to `foo' as `(*__imp_foo)'. +# This rule creates a `_globals.h' file, which contains macros +# for doing this. + +SYM_PREFIX = $(firstword $(SYM_PREFIX-$*) $*) +DLL_MACRO = $(SYM_PREFIX)_USE_DLL +IMP_MACRO = $(SYM_PREFIX)_IMP +GLOBAL_MACRO = $(SYM_PREFIX)_GLOBAL + +%_globals.h: %.a + echo "/* automatically generated by Makefile.DLLs */" > $@ + echo "#if defined(__GNUC__) && defined(_WIN32) \\" >> $@ + echo " && defined($(DLL_MACRO))" >> $@ + echo "# define $(IMP_MACRO)(name) __imp_##name" >> $@ + echo "# define $(GLOBAL_MACRO)(name) (*$(IMP_MACRO)(name))" >> $@ + echo "#else" >> $@ + echo "# define $(GLOBAL_MACRO)(name) name" >> $@ + echo "#endif" >> $@ + echo "" >> $@ + for sym in `nm $< | grep '^........ [BCDR] _' | sed 's/[^_]*_//'`; do \ + echo "#define $$sym $(GLOBAL_MACRO)($$sym)" >> $@; \ + done + +# This rule creates the export object file (`foo.exp') which contains the +# jump table array; this export object file becomes part of the DLL. +# This rule also creates the import library (`foo_dll.a') which contains small +# stubs for all the functions exported by the DLL which jump to them via the +# jump table. Executables that will use the DLL must be linked against this +# stub library. +%.exp %_dll.a : %.def + dlltool $(DLLTOOLFLAGS) $(DLLTOOLFLAGS-$*) \ + --def $< \ + --dllname $*.dll \ + --output-exp $*.exp \ + --output-lib $*_dll.a + +# The `sed' commands below are to convert DOS-style `C:\foo\bar' +# pathnames into Unix-style `//c/foo/bar' pathnames. +CYGWIN32_LIBS = $(shell echo \ + -L`dirname \`gcc -print-file-name=libgcc.a | \ + sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \ + -L`dirname \`gcc -print-file-name=libcygwin.a | \ + sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \ + -L`dirname \`gcc -print-file-name=libkernel32.a | \ + sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \ + -lgcc -lcygwin -lkernel32 -lgcc) + +RELOCATABLE=yes + +ifeq "$(strip $(RELOCATABLE))" "yes" + +# to create relocatable DLLs, we need to do two passes +%.dll: %.exp %.a dll_fixup.o dll_init.o + $(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll -o $*.base \ + -e _dll_entry@12 dll_init.o \ + dll_fixup.o $*.exp $*.a \ + $(LDLIBS) $(LDLIBS-$*) \ + $(CYGWIN32_LIBS) + $(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll --base-file $*.base -o $@ \ + -e _dll_entry@12 dll_init.o \ + dll_fixup.o $*.exp $*.a \ + $(LDLIBS) $(LDLIBS-$*) \ + $(CYGWIN32_LIBS) + rm -f $*.base +else + +%.dll: %.exp %.a dll_fixup.o dll_init.o + $(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll -o $@ \ + -e _dll_entry@12 dll_init.o \ + dll_fixup.o $*.exp $*.a \ + $(LDLIBS) $(LDLIBS-$*) \ + $(CYGWIN32_LIBS) + +endif + +# This black magic piece of assembler needs to be linked in in order to +# properly terminate the list of imported DLLs. +dll_fixup.s: + echo '.section .idata$$3' > dll_fixup.s + echo '.long 0,0,0,0, 0,0,0,0' >> dll_fixup.s + +# This bit is necessary to provide an initialization function for the DLL. +dll_init.c: + echo '__attribute__((stdcall))' > dll_init.c + echo 'int dll_entry(int handle, int reason, void *ptr)' >> dll_init.c + echo '{return 1; }' >> dll_init.c + +dont_throw_away: dll_fixup.o dll_init.o diff --git a/support/gc/Makefile.dj b/support/gc/Makefile.dj new file mode 100644 index 00000000..54f77db9 --- /dev/null +++ b/support/gc/Makefile.dj @@ -0,0 +1,436 @@ +# Primary targets: +# gc.a - builds basic library +# libgc.a - builds library for use with g++ "-fgc-keyword" extension +# c++ - adds C++ interface to library +# cords - adds cords (heavyweight strings) to library +# test - prints porting information, then builds basic version of gc.a, +# and runs some tests of collector and cords. Does not add cords or +# c++ interface to gc.a +# cord/de$(EXE_SUFFIX) - builds dumb editor based on cords. +ABI_FLAG= +CC=gcc $(ABI_FLAG) +CXX=gxx $(ABI_FLAG) +AS=gcc -c -x assembler-with-cpp $(ABI_FLAG) +# The above doesn't work with gas, which doesn't run cpp. +# Define AS as `gcc -c -x assembler-with-cpp' instead. +# Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64) +# if you use something other than the default ABI on your machine. + +# special defines for DJGPP +CXXLD=gxx $(ABI_FLAG) +EXE_SUFFIX=.exe + +CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT + +# For dynamic library builds, it may be necessary to add flags to generate +# PIC code, e.g. -fPIC on Linux. + +# Setjmp_test may yield overly optimistic results when compiled +# without optimization. +# -DSILENT disables statistics printing, and improves performance. +# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly +# altered stubborn objects, at substantial performance cost. +# Use only for incremental collector debugging. +# -DFIND_LEAK causes the collector to assume that all inaccessible +# objects should have been explicitly deallocated, and reports exceptions. +# Finalization and the test program are not usable in this mode. +# -DSOLARIS_THREADS enables support for Solaris (thr_) threads. +# (Clients should also define SOLARIS_THREADS and then include +# gc.h before performing thr_ or dl* or GC_ operations.) +# Must also define -D_REENTRANT. +# -D_SOLARIS_PTHREADS enables support for Solaris pthreads. +# Define SOLARIS_THREADS as well. +# -DIRIX_THREADS enables support for Irix pthreads. See README.irix. +# -DLINUX_THREADS enables support for Xavier Leroy's Linux threads. +# see README.linux. -D_REENTRANT may also be required. +# -DALL_INTERIOR_POINTERS allows all pointers to the interior +# of objects to be recognized. (See gc_priv.h for consequences.) +# -DSMALL_CONFIG tries to tune the collector for small heap sizes, +# usually causing it to use less space in such situations. +# Incremental collection no longer works in this case. +# -DLARGE_CONFIG tunes the collector for unusually large heaps. +# Necessary for heaps larger than about 500 MB on most machines. +# Recommended for heaps larger than about 64 MB. +# -DDONT_ADD_BYTE_AT_END is meaningful only with +# -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS +# causes all objects to be padded so that pointers just past the end of +# an object can be recognized. This can be expensive. (The padding +# is normally more than one byte due to alignment constraints.) +# -DDONT_ADD_BYTE_AT_END disables the padding. +# -DNO_SIGNALS does not disable signals during critical parts of +# the GC process. This is no less correct than many malloc +# implementations, and it sometimes has a significant performance +# impact. However, it is dangerous for many not-quite-ANSI C +# programs that call things like printf in asynchronous signal handlers. +# -DNO_EXECUTE_PERMISSION may cause some or all of the heap to not +# have execute permission, i.e. it may be impossible to execute +# code from the heap. Currently this only affects the incremental +# collector on UNIX machines. It may greatly improve its performance, +# since this may avoid some expensive cache synchronization. +# -DOPERATOR_NEW_ARRAY declares that the C++ compiler supports the +# new syntax "operator new[]" for allocating and deleting arrays. +# See gc_cpp.h for details. No effect on the C part of the collector. +# This is defined implicitly in a few environments. +# -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined +# as aliases for X, GC_realloc, and GC_free, respectively. +# Calloc is redefined in terms of the new malloc. X should +# be either GC_malloc or GC_malloc_uncollectable. +# The former is occasionally useful for working around leaks in code +# you don't want to (or can't) look at. It may not work for +# existing code, but it often does. Neither works on all platforms, +# since some ports use malloc or calloc to obtain system memory. +# (Probably works for UNIX, and win32.) +# -DIGNORE_FREE turns calls to free into a noop. Only useful with +# -DREDIRECT_MALLOC. +# -DNO_DEBUGGING removes GC_dump and the debugging routines it calls. +# Reduces code size slightly at the expense of debuggability. +# -DJAVA_FINALIZATION makes it somewhat safer to finalize objects out of +# order by specifying a nonstandard finalization mark procedure (see +# finalize.c). Objects reachable from finalizable objects will be marked +# in a sepearte postpass, and hence their memory won't be reclaimed. +# Not recommended unless you are implementing a language that specifies +# these semantics. +# -DFINALIZE_ON_DEMAND causes finalizers to be run only in response +# to explicit GC_invoke_finalizers() calls. +# -DATOMIC_UNCOLLECTABLE includes code for GC_malloc_atomic_uncollectable. +# This is useful if either the vendor malloc implementation is poor, +# or if REDIRECT_MALLOC is used. +# -DHBLKSIZE=ddd, where ddd is a power of 2 between 512 and 16384, explicitly +# sets the heap block size. Each heap block is devoted to a single size and +# kind of object. For the incremental collector it makes sense to match +# the most likely page size. Otherwise large values result in more +# fragmentation, but generally better performance for large heaps. +# -DUSE_MMAP use MMAP instead of sbrk to get new memory. +# Works for Solaris and Irix. +# -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than +# GC_scratch_alloc() to get stack memory. +# -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever +# the garbage collector detects a value that looks almost, but not quite, +# like a pointer, print both the address containing the value, and the +# value of the near-bogus-pointer. Can be used to identifiy regions of +# memory that are likely to contribute misidentified pointers. +# -DOLD_BLOCK_ALLOC Use the old, possibly faster, large block +# allocation strategy. The new strategy tries harder to minimize +# fragmentation, sometimes at the expense of spending more time in the +# large block allocator and/or collecting more frequently. +# If you expect the allocator to promtly use an explicitly expanded +# heap, this is highly recommended. +# + + + +LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \ + -DREDIRECT_MALLOC=GC_malloc_uncollectable \ + -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS +# Flags for building libgc.a -- the last two are required. + +CXXFLAGS= $(CFLAGS) -DOPERATOR_NEW_ARRAY +AR= ar +RANLIB= ranlib + + +# Redefining srcdir allows object code for the nonPCR version of the collector +# to be generated in different directories. In this case, the destination directory +# should contain a copy of the original include directory. +srcdir = . +VPATH = $(srcdir) + +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o + +CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c + +CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga + +CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o + +SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \ + sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \ + gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \ + threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \ + gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \ + include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \ + solaris_threads.h $(CORD_SRCS) + +OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \ + README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \ + SCoptions.amiga README.amiga README.win32 cord/README \ + cord/gc.h include/gc.h include/gc_typed.h include/cord.h \ + include/ec.h include/private/cord_pos.h include/private/gcconfig.h \ + include/private/gc_hdrs.h include/private/gc_priv.h \ + include/gc_cpp.h README.rs6000 \ + include/weakpointer.h README.QUICK callprocs pc_excludes \ + barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \ + MacOS.c EMX_MAKEFILE makefile.depend README.debugging \ + include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \ + Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \ + add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \ + win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \ + README.alpha README.linux version.h Makefile.DLLs \ + WCC_MAKEFILE + +CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \ + $(srcdir)/cord/private/cord_pos.h + +UTILS= if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX) + +# Libraries needed for curses applications. Only needed for de. +CURSES= -lcurses -ltermlib + +# The following is irrelevant on most systems. But a few +# versions of make otherwise fork the shell specified in +# the SHELL environment variable. +SHELL= /bin/sh + +SPECIALCFLAGS = +# Alternative flags to the C compiler for mach_dep.c. +# Mach_dep.c often doesn't like optimization, and it's +# not time-critical anyway. +# Set SPECIALCFLAGS to -q nodirect_code on Encore. + +all: gc.a gctest$(EXE_SUFFIX) + +pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS) + make -f PCR-Makefile depend + make -f PCR-Makefile + +$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \ + $(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile +# The dependency on Makefile is needed. Changing +# options such as -DSILENT affects the size of GC_arrays, +# invalidating all .o files that rely on gc_priv.h + +mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h + +base_lib gc.a: $(OBJS) dyn_load.o $(UTILS) + echo > base_lib + rm -f on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 $(AR) rus gc.a $(OBJS) dyn_load.o + ./if_not_there on_sparc_sunos5_1 $(AR) ru gc.a $(OBJS) dyn_load.o + -./if_not_there on_sparc_sunos5_1 $(RANLIB) gc.a +# ignore ranlib failure; that usually means it doesn't exist, and isn't needed + +cords: $(CORD_OBJS) cord/cordtest$(EXE_SUFFIX) $(UTILS) + rm -f on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 $(AR) rus gc.a $(CORD_OBJS) + ./if_not_there on_sparc_sunos5_3 $(AR) ru gc.a $(CORD_OBJS) + -./if_not_there on_sparc_sunos5_3 $(RANLIB) gc.a + +gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile + $(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc + +test_cpp$(EXE_SUFFIX): $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \ +base_lib $(UTILS) + rm -f test_cpp test_cpp$(EXE_SUFFIX) + ./if_mach HP_PA "" $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a -ldld + ./if_not_there test_cpp$(EXE_SUFFIX) $(CXXLD) $(CXXFLAGS) -o test_cpp$(EXE_SUFFIX) $(srcdir)/test_cpp.cc gc_cpp.o gc.a + rm -f test_cpp + +c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp$(EXE_SUFFIX) + rm -f on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 $(AR) rus gc.a gc_cpp.o + ./if_not_there on_sparc_sunos5_4 $(AR) ru gc.a gc_cpp.o + -./if_not_there on_sparc_sunos5_4 $(RANLIB) gc.a + ./test_cpp$(EXE_SUFFIX) 1 + echo > c++ + +dyn_load_sunos53.o: dyn_load.c + $(CC) $(CFLAGS) -DSUNOS53_SHARED_LIB -c $(srcdir)/dyn_load.c -o $@ + +# SunOS5 shared library version of the collector +sunos5gc.so: $(OBJS) dyn_load_sunos53.o + $(CC) -G -o sunos5gc.so $(OBJS) dyn_load_sunos53.o -ldl + ln sunos5gc.so libgc.so + +# Alpha/OSF shared library version of the collector +libalphagc.so: $(OBJS) + ld -shared -o libalphagc.so $(OBJS) dyn_load.o -lc + ln libalphagc.so libgc.so + +# IRIX shared library version of the collector +libirixgc.so: $(OBJS) dyn_load.o + ld -shared $(ABI_FLAG) -o libirixgc.so $(OBJS) dyn_load.o -lc + ln libirixgc.so libgc.so + +# Linux shared library version of the collector +liblinuxgc.so: $(OBJS) dyn_load.o + gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo + ln liblinuxgc.so libgc.so + +mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS) + rm -f mach_dep.o + ./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s + ./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s + ./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s + ./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s + ./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s + ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c + +mark_rts.o: $(srcdir)/mark_rts.c if_mach if_not_there $(UTILS) + rm -f mark_rts.o + -./if_mach ALPHA OSF1 $(CC) -c $(CFLAGS) -Wo,-notail $(srcdir)/mark_rts.c + ./if_not_there mark_rts.o $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c +# Work-around for DEC optimizer tail recursion elimination bug. +# The ALPHA-specific line should be removed if gcc is used. + +alloc.o: version.h + +cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordbscs.c + mv cordbscs.o cord/cordbscs.o +# not all compilers understand -o filename + +cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordxtra.c + mv cordxtra.o cord/cordxtra.o + +cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordprnt.c + mv cordprnt.o cord/cordprnt.o + +cord/cordtest$(EXE_SUFFIX): $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a $(UTILS) /tmp + rm -f cord/cordtest$(EXE_SUFFIX) + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/cordtest$(EXE_SUFFIX) $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/cordtest$(EXE_SUFFIX) $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -ldld + ./if_not_there cord/cordtest$(EXE_SUFFIX) $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a + rm -f cord/cordtest cordtest + -mv cordtest$(EXE_SUFFIX) cord/ + +/tmp: $(UTILS) + ./if_not_there /tmp mkdir /tmp + +cord/de$(EXE_SUFFIX): $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(UTILS) + rm -f cord/de cord/de$(EXE_SUFFIX) + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -lucb `./threadlibs` + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -ldld + ./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses + ./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs` + ./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses + ./if_not_there cord/de$(EXE_SUFFIX) $(CC) $(CFLAGS) -o cord/de$(EXE_SUFFIX) $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) + +if_mach$(EXE_SUFFIX): $(srcdir)/if_mach.c $(srcdir)/gcconfig.h + rm -f if_mach if_mach$(EXE_SUFFIX) + $(CC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c + rm -f if_mach + +threadlibs$(EXE_SUFFIX): $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile + rm -f threadlibs threadlibs$(EXE_SUFFIX) + $(CC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c + rm -f threadlibs + +if_not_there$(EXE_SUFFIX): $(srcdir)/if_not_there.c + rm -f if_not_there if_not_there$(EXE_SUFFIX) + $(CC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c + rm -f if_not_there + +# Clean removes *.o several times, +# because as the first one doesn't seem to get them all! +clean: + rm -f gc.a *.o + rm -f *.o + rm -f *.o + rm -f cord/*.o + rm -f gctest gctest_dyn_link test_cpp + rm -f setjmp_test mon.out gmon.out a.out core if_not_there if_mach + rm -f threadlibs $(CORD_OBJS) cordtest cord/cordtest de cord/de + rm -f gctest$(EXE_SUFFIX) gctest_dyn_link$(EXE_SUFFIX) test_cpp$(EXE_SUFFIX) + rm -f setjmp_test$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX) if_mach$(EXE_SUFFIX) + rm -f threadlibs$(EXE_SUFFIX) cord/cordtest$(EXE_SUFFIX) + -rm -f *~ + +gctest$(EXE_SUFFIX): test.o gc.a if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX) + rm -f gctest gctest$(EXE_SUFFIX) + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest test.o gc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o gctest test.o gc.a -ldld + ./if_not_there gctest$(EXE_SUFFIX) $(CC) $(CFLAGS) -o gctest$(EXE_SUFFIX) test.o gc.a + rm -f gctest + +# If an optimized setjmp_test generates a segmentation fault, +# odds are your compiler is broken. Gctest may still work. +# Try compiling setjmp_t.c unoptimized. +setjmp_test$(EXE_SUFFIX): $(srcdir)/setjmp_t.c $(srcdir)/gc.h \ + if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX) + rm -f setjmp_test$(EXE_SUFFIX) + $(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c + rm -f setjmp_test + +test: KandRtest cord/cordtest$(EXE_SUFFIX) + ./cord/cordtest$(EXE_SUFFIX) + +# Those tests that work even with a K&R C compiler: +KandRtest: setjmp_test$(EXE_SUFFIX) gctest$(EXE_SUFFIX) + ./setjmp_test$(EXE_SUFFIX) + ./gctest$(EXE_SUFFIX) + +add_gc_prefix$(EXE_SUFFIX): add_gc_prefix.c + $(CC) -o add_gc_prefix$(EXE_SUFFIX) $(srcdir)/add_gc_prefix.c + rm -f add_gc_prefix + +gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix + ./add_gc_prefix$(EXE_SUFFIX) $(SRCS) $(OTHER_FILES) > /tmp/gc.tar-files + (cd $(srcdir)/.. ; tar cvfh - `cat /tmp/gc.tar-files`) > gc.tar + +pc_gc.tar: $(SRCS) $(OTHER_FILES) + tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES) + +floppy: pc_gc.tar + -mmd a:/cord + -mmd a:/cord/private + -mmd a:/include + -mmd a:/include/private + mkdir /tmp/pc_gc + cat pc_gc.tar | (cd /tmp/pc_gc; tar xvf -) + -mcopy -tmn /tmp/pc_gc/* a: + -mcopy -tmn /tmp/pc_gc/cord/* a:/cord + -mcopy -mn /tmp/pc_gc/cord/de_win.ICO a:/cord + -mcopy -tmn /tmp/pc_gc/cord/private/* a:/cord/private + -mcopy -tmn /tmp/pc_gc/include/* a:/include + -mcopy -tmn /tmp/pc_gc/include/private/* a:/include/private + rm -r /tmp/pc_gc + +gc.tar.Z: gc.tar + compress gc.tar + +gc.tar.gz: gc.tar + gzip gc.tar + +lint: $(CSRCS) test.c + lint -DLINT $(CSRCS) test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall" + +# BTL: added to test shared library version of collector. +# Currently works only under SunOS5. Requires GC_INIT call from statically +# loaded client code. +ABSDIR = `pwd` +gctest_dyn_link: test.o libgc.so + $(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread + +gctest_irix_dyn_link: test.o libirixgc.so + $(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc + +test_dll.o: test.c libgc_globals.h + $(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o + +test_dll: test_dll.o libgc_dll.a libgc.dll + $(CC) test_dll.o -L$(ABSDIR) -lgc_dll -o test_dll + +SYM_PREFIX-libgc=GC + +# Uncomment the following line to build a GNU win32 DLL +# include Makefile.DLLs + +reserved_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/GC_/_GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done + +user_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/_GC_/GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done + diff --git a/support/gc/Makefile.in b/support/gc/Makefile.in new file mode 100644 index 00000000..c3982968 --- /dev/null +++ b/support/gc/Makefile.in @@ -0,0 +1,417 @@ +# Primary targets: +# gc.a - builds basic library +# libgc.a - builds library for use with g++ "-fgc-keyword" extension +# c++ - adds C++ interface to library +# cords - adds cords (heavyweight strings) to library +# test - prints porting information, then builds basic version of gc.a, +# and runs some tests of collector and cords. Does not add cords or +# c++ interface to gc.a +# cord/de - builds dumb editor based on cords. +ABI_FLAG= +CC = @CC@ $(ABI_FLAG) +CXX = @CXX@ $(ABI_FLAG) +AS = @AS@ $(ABI_FLAG) +PRJDIR = ../.. +srcdir = @srcdir@ +# The above doesn't work with gas, which doesn't run cpp. +# Define AS as `gcc -c -x assembler-with-cpp' instead. +# Under Irix 6, you will have to specify the ABI for as if you specify +# it for the C compiler. + +CFLAGS= -O2 -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT -I /usr/local/include + +# For dynamic library builds, it may be necessary to add flags to generate +# PIC code, e.g. -fPIC on Linux. + +# Setjmp_test may yield overly optimistic results when compiled +# without optimization. +# -DSILENT disables statistics printing, and improves performance. +# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly +# altered stubborn objects, at substantial performance cost. +# Use only for incremental collector debugging. +# -DFIND_LEAK causes the collector to assume that all inaccessible +# objects should have been explicitly deallocated, and reports exceptions. +# Finalization and the test program are not usable in this mode. +# -DSOLARIS_THREADS enables support for Solaris (thr_) threads. +# (Clients should also define SOLARIS_THREADS and then include +# gc.h before performing thr_ or dl* or GC_ operations.) +# Must also define -D_REENTRANT. +# -D_SOLARIS_PTHREADS enables support for Solaris pthreads. +# Define SOLARIS_THREADS as well. +# -DIRIX_THREADS enables support for Irix pthreads. See README.irix. +# _DLINUX_THREADS enables support for Xavier Leroy's Linux threads. +# see README.linux. -D_REENTRANT may also be required. +# -DALL_INTERIOR_POINTERS allows all pointers to the interior +# of objects to be recognized. (See gc_priv.h for consequences.) +# -DSMALL_CONFIG tries to tune the collector for small heap sizes, +# usually causing it to use less space in such situations. +# Incremental collection no longer works in this case. +# -DLARGE_CONFIG tunes the collector for unusually large heaps. +# Necessary for heaps larger than about 500 MB on most machines. +# Recommended for heaps larger than about 64 MB. +# -DDONT_ADD_BYTE_AT_END is meaningful only with +# -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS +# causes all objects to be padded so that pointers just past the end of +# an object can be recognized. This can be expensive. (The padding +# is normally more than one byte due to alignment constraints.) +# -DDONT_ADD_BYTE_AT_END disables the padding. +# -DNO_SIGNALS does not disable signals during critical parts of +# the GC process. This is no less correct than many malloc +# implementations, and it sometimes has a significant performance +# impact. However, it is dangerous for many not-quite-ANSI C +# programs that call things like printf in asynchronous signal handlers. +# -DNO_EXECUTE_PERMISSION may cause some or all of the heap to not +# have execute permission, i.e. it may be impossible to execute +# code from the heap. Currently this only affects the incremental +# collector on UNIX machines. It may greatly improve its performance, +# since this may avoid some expensive cache synchronization. +# -DOPERATOR_NEW_ARRAY declares that the C++ compiler supports the +# new syntax "operator new[]" for allocating and deleting arrays. +# See gc_cpp.h for details. No effect on the C part of the collector. +# This is defined implicitly in a few environments. +# -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined +# as aliases for X, GC_realloc, and GC_free, respectively. +# Calloc is redefined in terms of the new malloc. X should +# be either GC_malloc or GC_malloc_uncollectable. +# The former is occasionally useful for working around leaks in code +# you don't want to (or can't) look at. It may not work for +# existing code, but it often does. Neither works on all platforms, +# since some ports use malloc or calloc to obtain system memory. +# (Probably works for UNIX, and win32.) +# -DIGNORE_FREE turns calls to free into a noop. Only useful with +# -DREDIRECT_MALLOC. +# -DNO_DEBUGGING removes GC_dump and the debugging routines it calls. +# Reduces code size slightly at the expense of debuggability. +# -DJAVA_FINALIZATION makes it somewhat safer to finalize objects out of +# order by specifying a nonstandard finalization mark procedure (see +# finalize.c). Objects reachable from finalizable objects will be marked +# in a sepearte postpass, and hence their memory won't be reclaimed. +# Not recommended unless you are implementing a language that specifies +# these semantics. +# -DFINALIZE_ON_DEMAND causes finalizers to be run only in response +# to explicit GC_invoke_finalizers() calls. +# -DATOMIC_UNCOLLECTABLE includes code for GC_malloc_atomic_uncollectable. +# This is useful if either the vendor malloc implementation is poor, +# or if REDIRECT_MALLOC is used. +# -DHBLKSIZE=ddd, where ddd is a power of 2 between 512 and 16384, explicitly +# sets the heap block size. Each heap block is devoted to a single size and +# kind of object. For the incremental collector it makes sense to match +# the most likely page size. Otherwise large values result in more +# fragmentation, but generally better performance for large heaps. +# -DUSE_MMAP use MMAP instead of sbrk to get new memory. +# Works for Solaris and Irix. +# -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than +# GC_scratch_alloc() to get stack memory. +# -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever +# the garbage collector detects a value that looks almost, but not quite, +# like a pointer, print both the address containing the value, and the +# value of the near-bogus-pointer. Can be used to identifiy regions of +# memory that are likely to contribute misidentified pointers. +# -DOLD_BLOCK_ALLOC Use the old, possibly faster, large block +# allocation strategy. The new strategy tries harder to minimize +# fragmentation, sometimes at the expense of spending more time in the +# large block allocator and/or collecting more frequently. +# If you expect the allocator to promtly use an explicitly expanded +# heap, this is highly recommended. +# + + + +LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \ + -DREDIRECT_MALLOC=GC_malloc_uncollectable \ + -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS +# Flags for building libgc.a -- the last two are required. + +CXXFLAGS= $(CFLAGS) +AR= ar +RANLIB= ranlib + + +# Redefining srcdir allows object code for the nonPCR version of the collector +# to be generated in different directories. In this case, the destination directory +# should contain a copy of the original include directory. +srcdir = . +VPATH = $(srcdir) + +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o + +CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c + +CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga + +CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o + +SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \ + sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \ + gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \ + threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \ + gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \ + include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \ + solaris_threads.h $(CORD_SRCS) + +OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \ + README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \ + SCoptions.amiga README.amiga README.win32 cord/README \ + cord/gc.h include/gc.h include/gc_typed.h include/cord.h \ + include/ec.h include/private/cord_pos.h include/private/gcconfig.h \ + include/private/gc_hdrs.h include/private/gc_priv.h \ + include/gc_cpp.h README.rs6000 \ + include/weakpointer.h README.QUICK callprocs pc_excludes \ + barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \ + MacOS.c EMX_MAKEFILE makefile.depend README.debugging \ + include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \ + Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \ + add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \ + win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \ + README.alpha README.linux version.h Makefile.DLLs gc_watcom.asm \ + WCC_MAKEFILE + +CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \ + $(srcdir)/cord/private/cord_pos.h + +UTILS= if_mach if_not_there threadlibs + +# Libraries needed for curses applications. Only needed for de. +CURSES= -lcurses -ltermlib + +# The following is irrelevant on most systems. But a few +# versions of make otherwise fork the shell specified in +# the SHELL environment variable. +SHELL= /bin/sh + +SPECIALCFLAGS = +# Alternative flags to the C compiler for mach_dep.c. +# Mach_dep.c often doesn't like optimization, and it's +# not time-critical anyway. +# Set SPECIALCFLAGS to -q nodirect_code on Encore. + +#all: checkconf libgc.a gctest +all: checkconf libgc.a + +pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS) + make -f PCR-Makefile depend + make -f PCR-Makefile + +$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \ + $(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile +# The dependency on Makefile is needed. Changing +# options such as -DSILENT affects the size of GC_arrays, +# invalidating all .o files that rely on gc_priv.h + +mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h + +base_lib libgc.a: $(OBJS) dyn_load.o $(UTILS) + echo > base_lib + rm -f on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 $(AR) rus libgc.a $(OBJS) dyn_load.o + ./if_not_there on_sparc_sunos5_1 $(AR) ru libgc.a $(OBJS) dyn_load.o + ./if_not_there on_sparc_sunos5_1 $(RANLIB) libgc.a || cat /dev/null +# ignore ranlib failure; that usually means it doesn't exist, and isn't needed + +cords: $(CORD_OBJS) cord/cordtest $(UTILS) + rm -f on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 $(AR) rus libgc.a $(CORD_OBJS) + ./if_not_there on_sparc_sunos5_3 $(AR) ru libgc.a $(CORD_OBJS) + ./if_not_there on_sparc_sunos5_3 $(RANLIB) libgc.a || cat /dev/null + +gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile + $(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc + +test_cpp: $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \ +base_lib $(UTILS) + rm -f test_cpp + ./if_mach HP_PA "" $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o libgc.a -ldld + ./if_not_there test_cpp $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o libgc.a `./threadlibs` + +c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp + rm -f on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 $(AR) rus libgc.a gc_cpp.o + ./if_not_there on_sparc_sunos5_4 $(AR) ru libgc.a gc_cpp.o + ./if_not_there on_sparc_sunos5_4 $(RANLIB) libgc.a || cat /dev/null + ./test_cpp 1 + echo > c++ + +dyn_load_sunos53.o: dyn_load.c + $(CC) $(CFLAGS) -DSUNOS53_SHARED_LIB -c $(srcdir)/dyn_load.c -o $@ + +# SunOS5 shared library version of the collector +sunos5gc.so: $(OBJS) dyn_load_sunos53.o + $(CC) -G -o sunos5gc.so $(OBJS) dyn_load_sunos53.o -ldl + ln sunos5gc.so libgc.so + +# Alpha/OSF shared library version of the collector +libalphagc.so: $(OBJS) + ld -shared -o libalphagc.so $(OBJS) dyn_load.o -lc + ln libalphagc.so libgc.so + +# IRIX shared library version of the collector +libirixgc.so: $(OBJS) dyn_load.o + ld -shared $(ABI_FLAG) -o libirixgc.so $(OBJS) dyn_load.o -lc + ln libirixgc.so libgc.so + +# Linux shared library version of the collector +liblinuxgc.so: $(OBJS) dyn_load.o + gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo + ln liblinuxgc.so libgc.so + +mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS) + rm -f mach_dep.o + ./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s + ./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s + ./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s + ./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s + ./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s + ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c + +mark_rts.o: $(srcdir)/mark_rts.c if_mach if_not_there $(UTILS) + rm -f mark_rts.o + -./if_mach ALPHA OSF1 $(CC) -c $(CFLAGS) -Wo,-notail $(srcdir)/mark_rts.c + ./if_not_there mark_rts.o $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c +# Work-around for DEC optimizer tail recursion elimination bug. +# The ALPHA-specific line should be removed if gcc is used. + +alloc.o: version.h + +cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordbscs.c + mv cordbscs.o cord/cordbscs.o +# not all compilers understand -o filename + +cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordxtra.c + mv cordxtra.o cord/cordxtra.o + +cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordprnt.c + mv cordprnt.o cord/cordprnt.o + +cord/cordtest: $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a $(UTILS) + rm -f cord/cordtest + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a -ldld + ./if_not_there cord/cordtest $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) libgc.a `./threadlibs` + +cord/de: $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(UTILS) + rm -f cord/de + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(CURSES) -lucb `./threadlibs` + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(CURSES) -ldld + ./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a -lcurses + ./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a -lcurses `./threadlibs` + ./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a -lcurses + ./if_not_there cord/de $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o libgc.a $(CURSES) `./threadlibs` + +if_mach: $(srcdir)/if_mach.c $(srcdir)/gcconfig.h + $(CC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c + +threadlibs: $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile + $(CC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c + +if_not_there: $(srcdir)/if_not_there.c + $(CC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c + +clean: + rm -f libgc.a *.o gctest gctest_dyn_link test_cpp \ + setjmp_test mon.out gmon.out a.out core if_not_there if_mach \ + threadlibs $(CORD_OBJS) cord/cordtest cord/de + -rm -f *~ + +gctest: test.o libgc.a if_mach if_not_there + rm -f gctest + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest test.o libgc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o gctest test.o libgc.a -ldld + ./if_not_there gctest $(CC) $(CFLAGS) -o gctest test.o libgc.a `./threadlibs` + +# If an optimized setjmp_test generates a segmentation fault, +# odds are your compiler is broken. Gctest may still work. +# Try compiling setjmp_t.c unoptimized. +setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/gc.h if_mach if_not_there + $(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c + +test: KandRtest cord/cordtest + cord/cordtest + +# Those tests that work even with a K&R C compiler: +KandRtest: setjmp_test gctest + ./setjmp_test + ./gctest + +add_gc_prefix: add_gc_prefix.c + $(CC) -o add_gc_prefix $(srcdir)/add_gc_prefix.c + +gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix + ./add_gc_prefix $(SRCS) $(OTHER_FILES) > /tmp/gc.tar-files + (cd $(srcdir)/.. ; tar cvfh - `cat /tmp/gc.tar-files`) > gc.tar + +pc_gc.tar: $(SRCS) $(OTHER_FILES) + tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES) + +floppy: pc_gc.tar + -mmd a:/cord + -mmd a:/cord/private + -mmd a:/include + -mmd a:/include/private + mkdir /tmp/pc_gc + cat pc_gc.tar | (cd /tmp/pc_gc; tar xvf -) + -mcopy -tmn /tmp/pc_gc/* a: + -mcopy -tmn /tmp/pc_gc/cord/* a:/cord + -mcopy -mn /tmp/pc_gc/cord/de_win.ICO a:/cord + -mcopy -tmn /tmp/pc_gc/cord/private/* a:/cord/private + -mcopy -tmn /tmp/pc_gc/include/* a:/include + -mcopy -tmn /tmp/pc_gc/include/private/* a:/include/private + rm -r /tmp/pc_gc + +gc.tar.Z: gc.tar + compress gc.tar + +gc.tar.gz: gc.tar + gzip gc.tar + +lint: $(CSRCS) test.c + lint -DLINT $(CSRCS) test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall" + +# BTL: added to test shared library version of collector. +# Currently works only under SunOS5. Requires GC_INIT call from statically +# loaded client code. +ABSDIR = `pwd` +gctest_dyn_link: test.o libgc.so + $(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread + +gctest_irix_dyn_link: test.o libirixgc.so + $(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc + +test_dll.o: test.c libgc_globals.h + $(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o + +test_dll: test_dll.o libgc_dll.a libgc.dll + $(CC) test_dll.o -L$(ABSDIR) -lgc_dll -o test_dll + +SYM_PREFIX-libgc=GC + +# Uncomment the following line to build a GNU win32 DLL +# include Makefile.DLLs + +reserved_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/GC_/_GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done + +user_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/_GC_/GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done + +# Remake configuration +checkconf: + @if [ -f $(srcdir)/../devel ]; then \ + $(MAKE) -f $(srcdir)/conf.mk freshconf \ + srcdir="$(srcdir)" PRJDIR="$(PRJDIR)"; \ + fi + +# End of Makefile diff --git a/support/gc/Makefile.org b/support/gc/Makefile.org new file mode 100644 index 00000000..654d5e69 --- /dev/null +++ b/support/gc/Makefile.org @@ -0,0 +1,405 @@ +# Primary targets: +# gc.a - builds basic library +# libgc.a - builds library for use with g++ "-fgc-keyword" extension +# c++ - adds C++ interface to library +# cords - adds cords (heavyweight strings) to library +# test - prints porting information, then builds basic version of gc.a, +# and runs some tests of collector and cords. Does not add cords or +# c++ interface to gc.a +# cord/de - builds dumb editor based on cords. +ABI_FLAG= +CC=cc $(ABI_FLAG) +CXX=CC $(ABI_FLAG) +AS=as $(ABI_FLAG) +# The above doesn't work with gas, which doesn't run cpp. +# Define AS as `gcc -c -x assembler-with-cpp' instead. +# Under Irix 6, you will have to specify the ABI for as if you specify +# it for the C compiler. + +CFLAGS= -O2 -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT + +# For dynamic library builds, it may be necessary to add flags to generate +# PIC code, e.g. -fPIC on Linux. + +# Setjmp_test may yield overly optimistic results when compiled +# without optimization. +# -DSILENT disables statistics printing, and improves performance. +# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly +# altered stubborn objects, at substantial performance cost. +# Use only for incremental collector debugging. +# -DFIND_LEAK causes the collector to assume that all inaccessible +# objects should have been explicitly deallocated, and reports exceptions. +# Finalization and the test program are not usable in this mode. +# -DSOLARIS_THREADS enables support for Solaris (thr_) threads. +# (Clients should also define SOLARIS_THREADS and then include +# gc.h before performing thr_ or dl* or GC_ operations.) +# Must also define -D_REENTRANT. +# -D_SOLARIS_PTHREADS enables support for Solaris pthreads. +# Define SOLARIS_THREADS as well. +# -DIRIX_THREADS enables support for Irix pthreads. See README.irix. +# _DLINUX_THREADS enables support for Xavier Leroy's Linux threads. +# see README.linux. -D_REENTRANT may also be required. +# -DALL_INTERIOR_POINTERS allows all pointers to the interior +# of objects to be recognized. (See gc_priv.h for consequences.) +# -DSMALL_CONFIG tries to tune the collector for small heap sizes, +# usually causing it to use less space in such situations. +# Incremental collection no longer works in this case. +# -DLARGE_CONFIG tunes the collector for unusually large heaps. +# Necessary for heaps larger than about 500 MB on most machines. +# Recommended for heaps larger than about 64 MB. +# -DDONT_ADD_BYTE_AT_END is meaningful only with +# -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS +# causes all objects to be padded so that pointers just past the end of +# an object can be recognized. This can be expensive. (The padding +# is normally more than one byte due to alignment constraints.) +# -DDONT_ADD_BYTE_AT_END disables the padding. +# -DNO_SIGNALS does not disable signals during critical parts of +# the GC process. This is no less correct than many malloc +# implementations, and it sometimes has a significant performance +# impact. However, it is dangerous for many not-quite-ANSI C +# programs that call things like printf in asynchronous signal handlers. +# -DNO_EXECUTE_PERMISSION may cause some or all of the heap to not +# have execute permission, i.e. it may be impossible to execute +# code from the heap. Currently this only affects the incremental +# collector on UNIX machines. It may greatly improve its performance, +# since this may avoid some expensive cache synchronization. +# -DOPERATOR_NEW_ARRAY declares that the C++ compiler supports the +# new syntax "operator new[]" for allocating and deleting arrays. +# See gc_cpp.h for details. No effect on the C part of the collector. +# This is defined implicitly in a few environments. +# -DREDIRECT_MALLOC=X causes malloc, realloc, and free to be defined +# as aliases for X, GC_realloc, and GC_free, respectively. +# Calloc is redefined in terms of the new malloc. X should +# be either GC_malloc or GC_malloc_uncollectable. +# The former is occasionally useful for working around leaks in code +# you don't want to (or can't) look at. It may not work for +# existing code, but it often does. Neither works on all platforms, +# since some ports use malloc or calloc to obtain system memory. +# (Probably works for UNIX, and win32.) +# -DIGNORE_FREE turns calls to free into a noop. Only useful with +# -DREDIRECT_MALLOC. +# -DNO_DEBUGGING removes GC_dump and the debugging routines it calls. +# Reduces code size slightly at the expense of debuggability. +# -DJAVA_FINALIZATION makes it somewhat safer to finalize objects out of +# order by specifying a nonstandard finalization mark procedure (see +# finalize.c). Objects reachable from finalizable objects will be marked +# in a sepearte postpass, and hence their memory won't be reclaimed. +# Not recommended unless you are implementing a language that specifies +# these semantics. +# -DFINALIZE_ON_DEMAND causes finalizers to be run only in response +# to explicit GC_invoke_finalizers() calls. +# -DATOMIC_UNCOLLECTABLE includes code for GC_malloc_atomic_uncollectable. +# This is useful if either the vendor malloc implementation is poor, +# or if REDIRECT_MALLOC is used. +# -DHBLKSIZE=ddd, where ddd is a power of 2 between 512 and 16384, explicitly +# sets the heap block size. Each heap block is devoted to a single size and +# kind of object. For the incremental collector it makes sense to match +# the most likely page size. Otherwise large values result in more +# fragmentation, but generally better performance for large heaps. +# -DUSE_MMAP use MMAP instead of sbrk to get new memory. +# Works for Solaris and Irix. +# -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than +# GC_scratch_alloc() to get stack memory. +# -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever +# the garbage collector detects a value that looks almost, but not quite, +# like a pointer, print both the address containing the value, and the +# value of the near-bogus-pointer. Can be used to identifiy regions of +# memory that are likely to contribute misidentified pointers. +# -DOLD_BLOCK_ALLOC Use the old, possibly faster, large block +# allocation strategy. The new strategy tries harder to minimize +# fragmentation, sometimes at the expense of spending more time in the +# large block allocator and/or collecting more frequently. +# If you expect the allocator to promtly use an explicitly expanded +# heap, this is highly recommended. +# + + + +LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \ + -DREDIRECT_MALLOC=GC_malloc_uncollectable \ + -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS +# Flags for building libgc.a -- the last two are required. + +CXXFLAGS= $(CFLAGS) +AR= ar +RANLIB= ranlib + + +# Redefining srcdir allows object code for the nonPCR version of the collector +# to be generated in different directories. In this case, the destination directory +# should contain a copy of the original include directory. +srcdir = . +VPATH = $(srcdir) + +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o + +CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c + +CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga + +CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o + +SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \ + sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \ + gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \ + threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \ + gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \ + include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \ + solaris_threads.h $(CORD_SRCS) + +OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \ + README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \ + SCoptions.amiga README.amiga README.win32 cord/README \ + cord/gc.h include/gc.h include/gc_typed.h include/cord.h \ + include/ec.h include/private/cord_pos.h include/private/gcconfig.h \ + include/private/gc_hdrs.h include/private/gc_priv.h \ + include/gc_cpp.h README.rs6000 \ + include/weakpointer.h README.QUICK callprocs pc_excludes \ + barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \ + MacOS.c EMX_MAKEFILE makefile.depend README.debugging \ + include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \ + Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \ + add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \ + win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \ + README.alpha README.linux version.h Makefile.DLLs gc_watcom.asm \ + WCC_MAKEFILE + +CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \ + $(srcdir)/cord/private/cord_pos.h + +UTILS= if_mach if_not_there threadlibs + +# Libraries needed for curses applications. Only needed for de. +CURSES= -lcurses -ltermlib + +# The following is irrelevant on most systems. But a few +# versions of make otherwise fork the shell specified in +# the SHELL environment variable. +SHELL= /bin/sh + +SPECIALCFLAGS = +# Alternative flags to the C compiler for mach_dep.c. +# Mach_dep.c often doesn't like optimization, and it's +# not time-critical anyway. +# Set SPECIALCFLAGS to -q nodirect_code on Encore. + +all: gc.a gctest + +pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS) + make -f PCR-Makefile depend + make -f PCR-Makefile + +$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \ + $(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile +# The dependency on Makefile is needed. Changing +# options such as -DSILENT affects the size of GC_arrays, +# invalidating all .o files that rely on gc_priv.h + +mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h + +base_lib gc.a: $(OBJS) dyn_load.o $(UTILS) + echo > base_lib + rm -f on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_1 + ./if_mach SPARC SUNOS5 $(AR) rus gc.a $(OBJS) dyn_load.o + ./if_not_there on_sparc_sunos5_1 $(AR) ru gc.a $(OBJS) dyn_load.o + ./if_not_there on_sparc_sunos5_1 $(RANLIB) gc.a || cat /dev/null +# ignore ranlib failure; that usually means it doesn't exist, and isn't needed + +cords: $(CORD_OBJS) cord/cordtest $(UTILS) + rm -f on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_3 + ./if_mach SPARC SUNOS5 $(AR) rus gc.a $(CORD_OBJS) + ./if_not_there on_sparc_sunos5_3 $(AR) ru gc.a $(CORD_OBJS) + ./if_not_there on_sparc_sunos5_3 $(RANLIB) gc.a || cat /dev/null + +gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile + $(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc + +test_cpp: $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \ +base_lib $(UTILS) + rm -f test_cpp + ./if_mach HP_PA "" $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a -ldld + ./if_not_there test_cpp $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a `./threadlibs` + +c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp + rm -f on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 touch on_sparc_sunos5_4 + ./if_mach SPARC SUNOS5 $(AR) rus gc.a gc_cpp.o + ./if_not_there on_sparc_sunos5_4 $(AR) ru gc.a gc_cpp.o + ./if_not_there on_sparc_sunos5_4 $(RANLIB) gc.a || cat /dev/null + ./test_cpp 1 + echo > c++ + +dyn_load_sunos53.o: dyn_load.c + $(CC) $(CFLAGS) -DSUNOS53_SHARED_LIB -c $(srcdir)/dyn_load.c -o $@ + +# SunOS5 shared library version of the collector +sunos5gc.so: $(OBJS) dyn_load_sunos53.o + $(CC) -G -o sunos5gc.so $(OBJS) dyn_load_sunos53.o -ldl + ln sunos5gc.so libgc.so + +# Alpha/OSF shared library version of the collector +libalphagc.so: $(OBJS) + ld -shared -o libalphagc.so $(OBJS) dyn_load.o -lc + ln libalphagc.so libgc.so + +# IRIX shared library version of the collector +libirixgc.so: $(OBJS) dyn_load.o + ld -shared $(ABI_FLAG) -o libirixgc.so $(OBJS) dyn_load.o -lc + ln libirixgc.so libgc.so + +# Linux shared library version of the collector +liblinuxgc.so: $(OBJS) dyn_load.o + gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo + ln liblinuxgc.so libgc.so + +mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS) + rm -f mach_dep.o + ./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s + ./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s + ./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s + ./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s + ./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s + ./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s + ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c + +mark_rts.o: $(srcdir)/mark_rts.c if_mach if_not_there $(UTILS) + rm -f mark_rts.o + -./if_mach ALPHA OSF1 $(CC) -c $(CFLAGS) -Wo,-notail $(srcdir)/mark_rts.c + ./if_not_there mark_rts.o $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c +# Work-around for DEC optimizer tail recursion elimination bug. +# The ALPHA-specific line should be removed if gcc is used. + +alloc.o: version.h + +cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordbscs.c + mv cordbscs.o cord/cordbscs.o +# not all compilers understand -o filename + +cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordxtra.c + mv cordxtra.o cord/cordxtra.o + +cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES) + $(CC) $(CFLAGS) -c $(srcdir)/cord/cordprnt.c + mv cordprnt.o cord/cordprnt.o + +cord/cordtest: $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a $(UTILS) + rm -f cord/cordtest + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -ldld + ./if_not_there cord/cordtest $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a `./threadlibs` + +cord/de: $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(UTILS) + rm -f cord/de + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -lucb `./threadlibs` + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -ldld + ./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses + ./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs` + ./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses + ./if_not_there cord/de $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) `./threadlibs` + +if_mach: $(srcdir)/if_mach.c $(srcdir)/gcconfig.h + $(CC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c + +threadlibs: $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile + $(CC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c + +if_not_there: $(srcdir)/if_not_there.c + $(CC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c + +clean: + rm -f gc.a *.o gctest gctest_dyn_link test_cpp \ + setjmp_test mon.out gmon.out a.out core if_not_there if_mach \ + threadlibs $(CORD_OBJS) cord/cordtest cord/de + -rm -f *~ + +gctest: test.o gc.a if_mach if_not_there + rm -f gctest + ./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest test.o gc.a -lucb + ./if_mach HP_PA "" $(CC) $(CFLAGS) -o gctest test.o gc.a -ldld + ./if_not_there gctest $(CC) $(CFLAGS) -o gctest test.o gc.a `./threadlibs` + +# If an optimized setjmp_test generates a segmentation fault, +# odds are your compiler is broken. Gctest may still work. +# Try compiling setjmp_t.c unoptimized. +setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/gc.h if_mach if_not_there + $(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c + +test: KandRtest cord/cordtest + cord/cordtest + +# Those tests that work even with a K&R C compiler: +KandRtest: setjmp_test gctest + ./setjmp_test + ./gctest + +add_gc_prefix: add_gc_prefix.c + $(CC) -o add_gc_prefix $(srcdir)/add_gc_prefix.c + +gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix + ./add_gc_prefix $(SRCS) $(OTHER_FILES) > /tmp/gc.tar-files + (cd $(srcdir)/.. ; tar cvfh - `cat /tmp/gc.tar-files`) > gc.tar + +pc_gc.tar: $(SRCS) $(OTHER_FILES) + tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES) + +floppy: pc_gc.tar + -mmd a:/cord + -mmd a:/cord/private + -mmd a:/include + -mmd a:/include/private + mkdir /tmp/pc_gc + cat pc_gc.tar | (cd /tmp/pc_gc; tar xvf -) + -mcopy -tmn /tmp/pc_gc/* a: + -mcopy -tmn /tmp/pc_gc/cord/* a:/cord + -mcopy -mn /tmp/pc_gc/cord/de_win.ICO a:/cord + -mcopy -tmn /tmp/pc_gc/cord/private/* a:/cord/private + -mcopy -tmn /tmp/pc_gc/include/* a:/include + -mcopy -tmn /tmp/pc_gc/include/private/* a:/include/private + rm -r /tmp/pc_gc + +gc.tar.Z: gc.tar + compress gc.tar + +gc.tar.gz: gc.tar + gzip gc.tar + +lint: $(CSRCS) test.c + lint -DLINT $(CSRCS) test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall" + +# BTL: added to test shared library version of collector. +# Currently works only under SunOS5. Requires GC_INIT call from statically +# loaded client code. +ABSDIR = `pwd` +gctest_dyn_link: test.o libgc.so + $(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread + +gctest_irix_dyn_link: test.o libirixgc.so + $(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc + +test_dll.o: test.c libgc_globals.h + $(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o + +test_dll: test_dll.o libgc_dll.a libgc.dll + $(CC) test_dll.o -L$(ABSDIR) -lgc_dll -o test_dll + +SYM_PREFIX-libgc=GC + +# Uncomment the following line to build a GNU win32 DLL +# include Makefile.DLLs + +reserved_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/GC_/_GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done + +user_namespace: $(SRCS) + for file in $(SRCS) test.c test_cpp.cc; do \ + sed s/_GC_/GC_/g < $$file > tmp; \ + cp tmp $$file; \ + done diff --git a/support/gc/NT_MAKEFILE b/support/gc/NT_MAKEFILE new file mode 100644 index 00000000..52f6f4ae --- /dev/null +++ b/support/gc/NT_MAKEFILE @@ -0,0 +1,59 @@ +# Makefile for Windows NT. Assumes Microsoft compiler, and a single thread. +# DLLs are included in the root set under NT, but not under win32S. +# Use "nmake nodebug=1 all" for optimized versions of library, gctest and editor. + +CPU= i386 +!include + +OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_rts.obj headers.obj mark.obj obj_map.obj blacklst.obj finalize.obj new_hblk.obj dbg_mlc.obj malloc.obj stubborn.obj dyn_load.obj typd_mlc.obj ptr_chck.obj gc_cpp.obj mallocx.obj + +all: gctest.exe cord\de.exe test_cpp.exe + +.c.obj: + $(cc) $(cdebug) $(cflags) $(cvars) -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ $*.c /Fo$*.obj + +.cpp.obj: + $(cc) $(cdebug) $(cflags) $(cvars) -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /Fo$*.obj + +$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h + +gc.lib: $(OBJS) + lib /MACHINE:i386 /out:gc.lib $(OBJS) +# The original NT SDK used lib32 instead of lib + +gctest.exe: test.obj gc.lib +# The following works for win32 debugging. For win32s debugging use debugtype:coff +# and add mapsympe line. +# This produces a "GUI" applications that opens no windows and writes to the log file +# "gc.log". This is done to make the result runnable under win32s. + $(link) -debug:full -debugtype:cv $(guiflags) -stack:131072 -out:$*.exe test.obj $(guilibs) gc.lib +# mapsympe -n -o gctest.sym gctest.exe + +cord\de_win.rbj: cord\de_win.res + cvtres -$(CPU) cord\de_win.res -o cord\de_win.rbj + +cord\de.obj cord\de_win.obj: cord\cord.h cord\private\cord_pos.h cord\de_win.h cord\de_cmds.h + +cord\de_win.res: cord\de_win.rc cord\de_win.h cord\de_cmds.h + $(rc) $(rcvars) -r -fo cord\de_win.res $(cvars) cord\de_win.rc + +# Cord/de is a real win32 gui application. +cord\de.exe: cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib + $(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:cord\de.exe cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib $(guilibs) + +gc_cpp.obj: gc_cpp.h gc.h + +gc_cpp.cpp: gc_cpp.cc + copy gc_cpp.cc gc_cpp.cpp + +test_cpp.cpp: test_cpp.cc + copy test_cpp.cc test_cpp.cpp + +# This generates the C++ test executable. The executable expects +# a single numeric argument, which is the number of iterations. +# The output appears in the file "gc.log". +test_cpp.exe: test_cpp.obj gc_cpp.h gc.h gc.lib + $(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:test_cpp.exe test_cpp.obj gc.lib $(guilibs) + + + diff --git a/support/gc/NT_THREADS_MAKEFILE b/support/gc/NT_THREADS_MAKEFILE new file mode 100644 index 00000000..0fd22b70 --- /dev/null +++ b/support/gc/NT_THREADS_MAKEFILE @@ -0,0 +1,2087 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.10 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +!IF "$(CFG)" == "" +CFG=gctest - Win32 Release +!MESSAGE No configuration specified. Defaulting to cord - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "gc - Win32 Release" && "$(CFG)" != "gc - Win32 Debug" &&\ + "$(CFG)" != "gctest - Win32 Release" && "$(CFG)" != "gctest - Win32 Debug" &&\ + "$(CFG)" != "cord - Win32 Release" && "$(CFG)" != "cord - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "gc.mak" CFG="cord - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "gc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "gc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "gctest - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "gctest - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "cord - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "cord - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "gctest - Win32 Debug" + +!IF "$(CFG)" == "gc - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : ".\Release\gc.dll" ".\Release\gc.bsc" + +CLEAN : + -@erase ".\Release\allchblk.obj" + -@erase ".\Release\allchblk.sbr" + -@erase ".\Release\alloc.obj" + -@erase ".\Release\alloc.sbr" + -@erase ".\Release\blacklst.obj" + -@erase ".\Release\blacklst.sbr" + -@erase ".\Release\checksums.obj" + -@erase ".\Release\checksums.sbr" + -@erase ".\Release\dbg_mlc.obj" + -@erase ".\Release\dbg_mlc.sbr" + -@erase ".\Release\dyn_load.obj" + -@erase ".\Release\dyn_load.sbr" + -@erase ".\Release\finalize.obj" + -@erase ".\Release\finalize.sbr" + -@erase ".\Release\gc.bsc" + -@erase ".\Release\gc.dll" + -@erase ".\Release\gc.exp" + -@erase ".\Release\gc.lib" + -@erase ".\Release\headers.obj" + -@erase ".\Release\headers.sbr" + -@erase ".\Release\mach_dep.obj" + -@erase ".\Release\mach_dep.sbr" + -@erase ".\Release\malloc.obj" + -@erase ".\Release\malloc.sbr" + -@erase ".\Release\mallocx.obj" + -@erase ".\Release\mallocx.sbr" + -@erase ".\Release\mark.obj" + -@erase ".\Release\mark.sbr" + -@erase ".\Release\mark_rts.obj" + -@erase ".\Release\mark_rts.sbr" + -@erase ".\Release\misc.obj" + -@erase ".\Release\misc.sbr" + -@erase ".\Release\new_hblk.obj" + -@erase ".\Release\new_hblk.sbr" + -@erase ".\Release\obj_map.obj" + -@erase ".\Release\obj_map.sbr" + -@erase ".\Release\os_dep.obj" + -@erase ".\Release\os_dep.sbr" + -@erase ".\Release\ptr_chck.obj" + -@erase ".\Release\ptr_chck.sbr" + -@erase ".\Release\reclaim.obj" + -@erase ".\Release\reclaim.sbr" + -@erase ".\Release\stubborn.obj" + -@erase ".\Release\stubborn.sbr" + -@erase ".\Release\typd_mlc.obj" + -@erase ".\Release\typd_mlc.sbr" + -@erase ".\Release\win32_threads.obj" + -@erase ".\Release\win32_threads.sbr" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\ + "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ + "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS=.\Release/ + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gc.bsc" +BSC32_SBRS= \ + ".\Release\allchblk.sbr" \ + ".\Release\alloc.sbr" \ + ".\Release\blacklst.sbr" \ + ".\Release\checksums.sbr" \ + ".\Release\dbg_mlc.sbr" \ + ".\Release\dyn_load.sbr" \ + ".\Release\finalize.sbr" \ + ".\Release\headers.sbr" \ + ".\Release\mach_dep.sbr" \ + ".\Release\malloc.sbr" \ + ".\Release\mallocx.sbr" \ + ".\Release\mark.sbr" \ + ".\Release\mark_rts.sbr" \ + ".\Release\misc.sbr" \ + ".\Release\new_hblk.sbr" \ + ".\Release\obj_map.sbr" \ + ".\Release\os_dep.sbr" \ + ".\Release\ptr_chck.sbr" \ + ".\Release\reclaim.sbr" \ + ".\Release\stubborn.sbr" \ + ".\Release\typd_mlc.sbr" \ + ".\Release\win32_threads.sbr" + +".\Release\gc.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /dll /incremental:no\ + /pdb:"$(OUTDIR)/gc.pdb" /machine:I386 /out:"$(OUTDIR)/gc.dll"\ + /implib:"$(OUTDIR)/gc.lib" +LINK32_OBJS= \ + ".\Release\allchblk.obj" \ + ".\Release\alloc.obj" \ + ".\Release\blacklst.obj" \ + ".\Release\checksums.obj" \ + ".\Release\dbg_mlc.obj" \ + ".\Release\dyn_load.obj" \ + ".\Release\finalize.obj" \ + ".\Release\headers.obj" \ + ".\Release\mach_dep.obj" \ + ".\Release\malloc.obj" \ + ".\Release\mallocx.obj" \ + ".\Release\mark.obj" \ + ".\Release\mark_rts.obj" \ + ".\Release\misc.obj" \ + ".\Release\new_hblk.obj" \ + ".\Release\obj_map.obj" \ + ".\Release\os_dep.obj" \ + ".\Release\ptr_chck.obj" \ + ".\Release\reclaim.obj" \ + ".\Release\stubborn.obj" \ + ".\Release\typd_mlc.obj" \ + ".\Release\win32_threads.obj" + +".\Release\gc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +OUTDIR=.\Debug +INTDIR=.\Debug + +ALL : ".\Debug\gc.dll" ".\Debug\gc.bsc" + +CLEAN : + -@erase ".\Debug\allchblk.obj" + -@erase ".\Debug\allchblk.sbr" + -@erase ".\Debug\alloc.obj" + -@erase ".\Debug\alloc.sbr" + -@erase ".\Debug\blacklst.obj" + -@erase ".\Debug\blacklst.sbr" + -@erase ".\Debug\checksums.obj" + -@erase ".\Debug\checksums.sbr" + -@erase ".\Debug\dbg_mlc.obj" + -@erase ".\Debug\dbg_mlc.sbr" + -@erase ".\Debug\dyn_load.obj" + -@erase ".\Debug\dyn_load.sbr" + -@erase ".\Debug\finalize.obj" + -@erase ".\Debug\finalize.sbr" + -@erase ".\Debug\gc.bsc" + -@erase ".\Debug\gc.dll" + -@erase ".\Debug\gc.exp" + -@erase ".\Debug\gc.lib" + -@erase ".\Debug\gc.map" + -@erase ".\Debug\gc.pdb" + -@erase ".\Debug\headers.obj" + -@erase ".\Debug\headers.sbr" + -@erase ".\Debug\mach_dep.obj" + -@erase ".\Debug\mach_dep.sbr" + -@erase ".\Debug\malloc.obj" + -@erase ".\Debug\malloc.sbr" + -@erase ".\Debug\mallocx.obj" + -@erase ".\Debug\mallocx.sbr" + -@erase ".\Debug\mark.obj" + -@erase ".\Debug\mark.sbr" + -@erase ".\Debug\mark_rts.obj" + -@erase ".\Debug\mark_rts.sbr" + -@erase ".\Debug\misc.obj" + -@erase ".\Debug\misc.sbr" + -@erase ".\Debug\new_hblk.obj" + -@erase ".\Debug\new_hblk.sbr" + -@erase ".\Debug\obj_map.obj" + -@erase ".\Debug\obj_map.sbr" + -@erase ".\Debug\os_dep.obj" + -@erase ".\Debug\os_dep.sbr" + -@erase ".\Debug\ptr_chck.obj" + -@erase ".\Debug\ptr_chck.sbr" + -@erase ".\Debug\reclaim.obj" + -@erase ".\Debug\reclaim.sbr" + -@erase ".\Debug\stubborn.obj" + -@erase ".\Debug\stubborn.sbr" + -@erase ".\Debug\typd_mlc.obj" + -@erase ".\Debug\typd_mlc.sbr" + -@erase ".\Debug\vc40.idb" + -@erase ".\Debug\vc40.pdb" + -@erase ".\Debug\win32_threads.obj" + -@erase ".\Debug\win32_threads.sbr" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\ + /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ + "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\ + /Fd"$(INTDIR)/" /c +CPP_OBJS=.\Debug/ +CPP_SBRS=.\Debug/ + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gc.bsc" +BSC32_SBRS= \ + ".\Debug\allchblk.sbr" \ + ".\Debug\alloc.sbr" \ + ".\Debug\blacklst.sbr" \ + ".\Debug\checksums.sbr" \ + ".\Debug\dbg_mlc.sbr" \ + ".\Debug\dyn_load.sbr" \ + ".\Debug\finalize.sbr" \ + ".\Debug\headers.sbr" \ + ".\Debug\mach_dep.sbr" \ + ".\Debug\malloc.sbr" \ + ".\Debug\mallocx.sbr" \ + ".\Debug\mark.sbr" \ + ".\Debug\mark_rts.sbr" \ + ".\Debug\misc.sbr" \ + ".\Debug\new_hblk.sbr" \ + ".\Debug\obj_map.sbr" \ + ".\Debug\os_dep.sbr" \ + ".\Debug\ptr_chck.sbr" \ + ".\Debug\reclaim.sbr" \ + ".\Debug\stubborn.sbr" \ + ".\Debug\typd_mlc.sbr" \ + ".\Debug\win32_threads.sbr" + +".\Debug\gc.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /machine:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /dll /incremental:no\ + /pdb:"$(OUTDIR)/gc.pdb" /map:"$(INTDIR)/gc.map" /debug /machine:I386\ + /out:"$(OUTDIR)/gc.dll" /implib:"$(OUTDIR)/gc.lib" +LINK32_OBJS= \ + ".\Debug\allchblk.obj" \ + ".\Debug\alloc.obj" \ + ".\Debug\blacklst.obj" \ + ".\Debug\checksums.obj" \ + ".\Debug\dbg_mlc.obj" \ + ".\Debug\dyn_load.obj" \ + ".\Debug\finalize.obj" \ + ".\Debug\headers.obj" \ + ".\Debug\mach_dep.obj" \ + ".\Debug\malloc.obj" \ + ".\Debug\mallocx.obj" \ + ".\Debug\mark.obj" \ + ".\Debug\mark_rts.obj" \ + ".\Debug\misc.obj" \ + ".\Debug\new_hblk.obj" \ + ".\Debug\obj_map.obj" \ + ".\Debug\os_dep.obj" \ + ".\Debug\ptr_chck.obj" \ + ".\Debug\reclaim.obj" \ + ".\Debug\stubborn.obj" \ + ".\Debug\typd_mlc.obj" \ + ".\Debug\win32_threads.obj" + +".\Debug\gc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "gctest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "gctest\Release" +# PROP BASE Intermediate_Dir "gctest\Release" +# PROP BASE Target_Dir "gctest" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "gctest\Release" +# PROP Intermediate_Dir "gctest\Release" +# PROP Target_Dir "gctest" +OUTDIR=.\gctest\Release +INTDIR=.\gctest\Release + +ALL : "gc - Win32 Release" ".\Release\gctest.exe" + +CLEAN : + -@erase ".\gctest\Release\test.obj" + -@erase ".\Release\gctest.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c +CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\ + "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS"\ + /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\gctest\Release/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gctest.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"Release/gctest.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:no\ + /pdb:"$(OUTDIR)/gctest.pdb" /machine:I386 /out:"Release/gctest.exe" +LINK32_OBJS= \ + ".\gctest\Release\test.obj" \ + ".\Release\gc.lib" + +".\Release\gctest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "gctest\Debug" +# PROP BASE Intermediate_Dir "gctest\Debug" +# PROP BASE Target_Dir "gctest" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "gctest\Debug" +# PROP Intermediate_Dir "gctest\Debug" +# PROP Target_Dir "gctest" +OUTDIR=.\gctest\Debug +INTDIR=.\gctest\Debug + +ALL : "gc - Win32 Debug" ".\Debug\gctest.exe" ".\gctest\Debug\gctest.bsc" + +CLEAN : + -@erase ".\Debug\gctest.exe" + -@erase ".\gctest\Debug\gctest.bsc" + -@erase ".\gctest\Debug\gctest.map" + -@erase ".\gctest\Debug\gctest.pdb" + -@erase ".\gctest\Debug\test.obj" + -@erase ".\gctest\Debug\test.sbr" + -@erase ".\gctest\Debug\vc40.idb" + -@erase ".\gctest\Debug\vc40.pdb" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\ + /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR"$(INTDIR)/"\ + /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c +CPP_OBJS=.\gctest\Debug/ +CPP_SBRS=.\gctest\Debug/ + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gctest.bsc" +BSC32_SBRS= \ + ".\gctest\Debug\test.sbr" + +".\gctest\Debug\gctest.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /map /debug /machine:I386 /out:"Debug/gctest.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:no\ + /pdb:"$(OUTDIR)/gctest.pdb" /map:"$(INTDIR)/gctest.map" /debug /machine:I386\ + /out:"Debug/gctest.exe" +LINK32_OBJS= \ + ".\Debug\gc.lib" \ + ".\gctest\Debug\test.obj" + +".\Debug\gctest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "cord - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "cord\Release" +# PROP BASE Intermediate_Dir "cord\Release" +# PROP BASE Target_Dir "cord" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "cord\Release" +# PROP Intermediate_Dir "cord\Release" +# PROP Target_Dir "cord" +OUTDIR=.\cord\Release +INTDIR=.\cord\Release + +ALL : "gc - Win32 Release" ".\Release\de.exe" + +CLEAN : + -@erase ".\cord\Release\cordbscs.obj" + -@erase ".\cord\Release\cordxtra.obj" + -@erase ".\cord\Release\de.obj" + -@erase ".\cord\Release\de_win.obj" + -@erase ".\cord\Release\de_win.res" + -@erase ".\Release\de.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c +CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\ + "ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\cord\Release/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +RSC_PROJ=/l 0x809 /fo"$(INTDIR)/de_win.res" /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/cord.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"Release/de.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)/de.pdb"\ + /machine:I386 /out:"Release/de.exe" +LINK32_OBJS= \ + ".\cord\Release\cordbscs.obj" \ + ".\cord\Release\cordxtra.obj" \ + ".\cord\Release\de.obj" \ + ".\cord\Release\de_win.obj" \ + ".\cord\Release\de_win.res" \ + ".\Release\gc.lib" + +".\Release\de.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "cord\Debug" +# PROP BASE Intermediate_Dir "cord\Debug" +# PROP BASE Target_Dir "cord" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "cord\Debug" +# PROP Intermediate_Dir "cord\Debug" +# PROP Target_Dir "cord" +OUTDIR=.\cord\Debug +INTDIR=.\cord\Debug + +ALL : "gc - Win32 Debug" ".\Debug\de.exe" + +CLEAN : + -@erase ".\cord\Debug\cordbscs.obj" + -@erase ".\cord\Debug\cordxtra.obj" + -@erase ".\cord\Debug\de.obj" + -@erase ".\cord\Debug\de.pdb" + -@erase ".\cord\Debug\de_win.obj" + -@erase ".\cord\Debug\de_win.res" + -@erase ".\cord\Debug\vc40.idb" + -@erase ".\cord\Debug\vc40.pdb" + -@erase ".\Debug\de.exe" + -@erase ".\Debug\de.ilk" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c +CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D\ + "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX\ + /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c +CPP_OBJS=.\cord\Debug/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +RSC_PROJ=/l 0x809 /fo"$(INTDIR)/de_win.res" /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/cord.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Debug/de.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:yes\ + /pdb:"$(OUTDIR)/de.pdb" /debug /machine:I386 /out:"Debug/de.exe" +LINK32_OBJS= \ + ".\cord\Debug\cordbscs.obj" \ + ".\cord\Debug\cordxtra.obj" \ + ".\cord\Debug\de.obj" \ + ".\cord\Debug\de_win.obj" \ + ".\cord\Debug\de_win.res" \ + ".\Debug\gc.lib" + +".\Debug\de.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + +################################################################################ +# Begin Target + +# Name "gc - Win32 Release" +# Name "gc - Win32 Debug" + +!IF "$(CFG)" == "gc - Win32 Release" + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\reclaim.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_RECLA=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_RECLA=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\reclaim.obj" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + +".\Release\reclaim.sbr" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_RECLA=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_RECLA=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\reclaim.obj" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + +".\Debug\reclaim.sbr" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\os_dep.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_OS_DE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OS_DE=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + ".\vd\PCR_VD.h"\ + + +".\Release\os_dep.obj" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + +".\Release\os_dep.sbr" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_OS_DE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OS_DE=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + ".\vd\PCR_VD.h"\ + + +".\Debug\os_dep.obj" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + +".\Debug\os_dep.sbr" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\misc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MISC_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MISC_=\ + ".\il\PCR_IL.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\misc.obj" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + +".\Release\misc.sbr" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MISC_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MISC_=\ + ".\il\PCR_IL.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\misc.obj" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + +".\Debug\misc.sbr" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mark_rts.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MARK_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mark_rts.obj" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + +".\Release\mark_rts.sbr" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MARK_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mark_rts.obj" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + +".\Debug\mark_rts.sbr" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mach_dep.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MACH_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MACH_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mach_dep.obj" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + +".\Release\mach_dep.sbr" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MACH_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MACH_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mach_dep.obj" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + +".\Debug\mach_dep.sbr" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\headers.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_HEADE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_HEADE=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\headers.obj" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + +".\Release\headers.sbr" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_HEADE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_HEADE=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\headers.obj" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + +".\Debug\headers.sbr" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\alloc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_ALLOC=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLOC=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\alloc.obj" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + +".\Release\alloc.sbr" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_ALLOC=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLOC=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\alloc.obj" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + +".\Debug\alloc.sbr" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\allchblk.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_ALLCH=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLCH=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\allchblk.obj" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + +".\Release\allchblk.sbr" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_ALLCH=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLCH=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\allchblk.obj" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + +".\Debug\allchblk.sbr" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\stubborn.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_STUBB=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_STUBB=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\stubborn.obj" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + +".\Release\stubborn.sbr" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_STUBB=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_STUBB=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\stubborn.obj" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + +".\Debug\stubborn.sbr" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\obj_map.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_OBJ_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OBJ_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\obj_map.obj" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + +".\Release\obj_map.sbr" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_OBJ_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OBJ_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\obj_map.obj" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + +".\Debug\obj_map.sbr" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\new_hblk.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_NEW_H=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_NEW_H=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\new_hblk.obj" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + +".\Release\new_hblk.sbr" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_NEW_H=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_NEW_H=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\new_hblk.obj" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + +".\Debug\new_hblk.sbr" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mark.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MARK_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mark.obj" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + +".\Release\mark.sbr" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MARK_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mark.obj" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + +".\Debug\mark.sbr" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\malloc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MALLO=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLO=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\malloc.obj" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + +".\Release\malloc.sbr" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MALLO=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLO=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\malloc.obj" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + +".\Debug\malloc.sbr" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mallocx.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MALLX=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLX=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mallocx.obj" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + +".\Release\mallocx.sbr" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MALLX=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLX=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mallocx.obj" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + +".\Debug\mallocx.sbr" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\finalize.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_FINAL=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_FINAL=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\finalize.obj" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + +".\Release\finalize.sbr" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_FINAL=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_FINAL=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\finalize.obj" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + +".\Debug\finalize.sbr" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\dbg_mlc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_DBG_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DBG_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\dbg_mlc.obj" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + +".\Release\dbg_mlc.sbr" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_DBG_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DBG_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\dbg_mlc.obj" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + +".\Debug\dbg_mlc.sbr" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\blacklst.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_BLACK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_BLACK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\blacklst.obj" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + +".\Release\blacklst.sbr" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_BLACK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_BLACK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\blacklst.obj" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + +".\Debug\blacklst.sbr" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\typd_mlc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_TYPD_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + ".\gc_typed.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_TYPD_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\typd_mlc.obj" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + +".\Release\typd_mlc.sbr" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_TYPD_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + ".\gc_typed.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_TYPD_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\typd_mlc.obj" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + +".\Debug\typd_mlc.sbr" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\ptr_chck.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_PTR_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_PTR_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\ptr_chck.obj" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + +".\Release\ptr_chck.sbr" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_PTR_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_PTR_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\ptr_chck.obj" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + +".\Debug\ptr_chck.sbr" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\dyn_load.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_DYN_L=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DYN_L=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\dyn_load.obj" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + +".\Release\dyn_load.sbr" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_DYN_L=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DYN_L=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\dyn_load.obj" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + +".\Debug\dyn_load.sbr" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\win32_threads.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_WIN32=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_WIN32=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\win32_threads.obj" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + +".\Release\win32_threads.sbr" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_WIN32=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_WIN32=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\win32_threads.obj" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + +".\Debug\win32_threads.sbr" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\checksums.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_CHECK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_CHECK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\checksums.obj" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + +".\Release\checksums.sbr" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_CHECK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_CHECK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\checksums.obj" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + +".\Debug\checksums.sbr" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + + +!ENDIF + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "gctest - Win32 Release" +# Name "gctest - Win32 Debug" + +!IF "$(CFG)" == "gctest - Win32 Release" + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Project Dependency + +# Project_Dep_Name "gc" + +!IF "$(CFG)" == "gctest - Win32 Release" + +"gc - Win32 Release" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Release" + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + +"gc - Win32 Debug" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Debug" + +!ENDIF + +# End Project Dependency +################################################################################ +# Begin Source File + +SOURCE=.\test.c +DEP_CPP_TEST_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + ".\gc_typed.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_TEST_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +!IF "$(CFG)" == "gctest - Win32 Release" + + +".\gctest\Release\test.obj" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + + +".\gctest\Debug\test.obj" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)" + +".\gctest\Debug\test.sbr" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)" + + +!ENDIF + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "cord - Win32 Release" +# Name "cord - Win32 Debug" + +!IF "$(CFG)" == "cord - Win32 Release" + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Project Dependency + +# Project_Dep_Name "gc" + +!IF "$(CFG)" == "cord - Win32 Release" + +"gc - Win32 Release" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Release" + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + +"gc - Win32 Debug" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Debug" + +!ENDIF + +# End Project Dependency +################################################################################ +# Begin Source File + +SOURCE=.\cord\de_win.c +DEP_CPP_DE_WI=\ + ".\cord\cord.h"\ + ".\cord\de_cmds.h"\ + ".\cord\de_win.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_DE_WI=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\de_win.obj" : $(SOURCE) $(DEP_CPP_DE_WI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\de_win.obj" : $(SOURCE) $(DEP_CPP_DE_WI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\de.c +DEP_CPP_DE_C2e=\ + ".\cord\cord.h"\ + ".\cord\de_cmds.h"\ + ".\cord\de_win.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_DE_C2e=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\de.obj" : $(SOURCE) $(DEP_CPP_DE_C2e) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\de.obj" : $(SOURCE) $(DEP_CPP_DE_C2e) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\cordxtra.c +DEP_CPP_CORDX=\ + ".\cord\cord.h"\ + ".\cord\ec.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_CORDX=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\cordxtra.obj" : $(SOURCE) $(DEP_CPP_CORDX) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\cordxtra.obj" : $(SOURCE) $(DEP_CPP_CORDX) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\cordbscs.c +DEP_CPP_CORDB=\ + ".\cord\cord.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_CORDB=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\cordbscs.obj" : $(SOURCE) $(DEP_CPP_CORDB) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\cordbscs.obj" : $(SOURCE) $(DEP_CPP_CORDB) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\de_win.RC + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\de_win.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x809 /fo"$(INTDIR)/de_win.res" /i "cord" /d "NDEBUG" $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\de_win.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x809 /fo"$(INTDIR)/de_win.res" /i "cord" /d "_DEBUG" $(SOURCE) + + +!ENDIF + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/support/gc/OS2_MAKEFILE b/support/gc/OS2_MAKEFILE new file mode 100644 index 00000000..7b816218 --- /dev/null +++ b/support/gc/OS2_MAKEFILE @@ -0,0 +1,45 @@ +# Makefile for OS/2. Assumes IBM's compiler, static linking, and a single thread. +# Adding dynamic linking support seems easy, but takes a little bit of work. +# Adding thread support may be nontrivial, since we haven't yet figured out how to +# look at another thread's registers. + +# Significantly revised for GC version 4.4 by Mark Boulter (Jan 1994). + +OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_rts.obj headers.obj mark.obj obj_map.obj blacklst.obj finalize.obj new_hblk.obj dbg_mlc.obj malloc.obj stubborn.obj typd_mlc.obj ptr_chck.obj mallocx.obj + +CORDOBJS= cord\cordbscs.obj cord\cordxtra.obj cord\cordprnt.obj + +CC= icc +CFLAGS= /O /Q /DSILENT /DSMALL_CONFIG /DALL_INTERIOR_POINTERS +# Use /Ti instead of /O for debugging +# Setjmp_test may yield overly optimistic results when compiled +# without optimization. + +all: $(OBJS) gctest.exe cord\cordtest.exe + +$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h + +## ERASE THE LIB FIRST - if it is already there then this command will fail +## (make sure its there or erase will fail!) +gc.lib: $(OBJS) + echo . > gc.lib + erase gc.lib + LIB gc.lib $(OBJS), gc.lst + +mach_dep.obj: mach_dep.c + $(CC) $(CFLAGS) /C mach_dep.c + +gctest.exe: test.obj gc.lib + $(CC) $(CFLAGS) /B"/STACK:524288" /Fegctest test.obj gc.lib + +cord\cordbscs.obj: cord\cordbscs.c cord\cord.h cord\private\cord_pos.h + $(CC) $(CFLAGS) /C /Focord\cordbscs cord\cordbscs.c + +cord\cordxtra.obj: cord\cordxtra.c cord\cord.h cord\private\cord_pos.h cord\ec.h + $(CC) $(CFLAGS) /C /Focord\cordxtra cord\cordxtra.c + +cord\cordprnt.obj: cord\cordprnt.c cord\cord.h cord\private\cord_pos.h cord\ec.h + $(CC) $(CFLAGS) /C /Focord\cordprnt cord\cordprnt.c + +cord\cordtest.exe: cord\cordtest.c cord\cord.h cord\private\cord_pos.h cord\ec.h $(CORDOBJS) gc.lib + $(CC) $(CFLAGS) /B"/STACK:65536" /Fecord\cordtest cord\cordtest.c gc.lib $(CORDOBJS) diff --git a/support/gc/PCR-Makefile b/support/gc/PCR-Makefile new file mode 100644 index 00000000..1eae3672 --- /dev/null +++ b/support/gc/PCR-Makefile @@ -0,0 +1,68 @@ +# +# Default target +# + +default: gc.o + +include ../config/common.mk + +# +# compilation flags, etc. +# + + +CPPFLAGS = $(INCLUDE) $(CONFIG_CPPFLAGS) \ + -DPCR_NO_RENAME -DPCR_NO_HOSTDEP_ERR +#CFLAGS = -DPCR -DSILENT $(CONFIG_CFLAGS) +CFLAGS = -DPCR $(CONFIG_CFLAGS) +SPECIALCFLAGS = # For code involving asm's + +ASPPFLAGS = $(INCLUDE) $(CONFIG_ASPPFLAGS) \ + -DPCR_NO_RENAME -DPCR_NO_HOSTDEP_ERR -DASM + +ASFLAGS = $(CONFIG_ASFLAGS) + +LDRFLAGS = $(CONFIG_LDRFLAGS) + +LDFLAGS = $(CONFIG_LDFLAGS) + +# +# +# +# +# BEGIN PACKAGE-SPECIFIC PART +# +# +# +# + +# Fix to point to local pcr installation directory. +PCRDIR= .. + +COBJ= alloc.o reclaim.o allchblk.o misc.o os_dep.o mark_rts.o headers.o mark.o obj_map.o pcr_interface.o blacklst.o finalize.o new_hblk.o real_malloc.o dyn_load.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o typd_mlc.o ptr_chck.o mallocx.o + +CSRC= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c typd_mlc.c ptr_chck.c mallocx.c + +SHELL= /bin/sh + +default: gc.o + +gc.o: $(COBJ) mach_dep.o + $(LDR) $(CONFIG_LDRFLAGS) -o gc.o $(COBJ) mach_dep.o + + +mach_dep.o: mach_dep.c mips_mach_dep.s rs6000_mach_dep.s if_mach if_not_there + rm -f mach_dep.o + ./if_mach MIPS "" as -o mach_dep.o mips_mach_dep.s + ./if_mach RS6000 "" as -o mach_dep.o rs6000_mach_dep.s + ./if_mach ALPHA "" as -o mach_dep.o alpha_mach_dep.s + ./if_mach SPARC SUNOS5 as -o mach_dep.o sparc_mach_dep.s + ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) mach_dep.c + +if_mach: if_mach.c gcconfig.h + $(CC) $(CFLAGS) -o if_mach if_mach.c + +if_not_there: if_not_there.c + $(CC) $(CFLAGS) -o if_not_there if_not_there.c + + diff --git a/support/gc/README b/support/gc/README new file mode 100644 index 00000000..80cb26ab --- /dev/null +++ b/support/gc/README @@ -0,0 +1,1517 @@ +Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers +Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved. +Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + +Permission is hereby granted to use or copy this program +for any purpose, provided the above notices are retained on all copies. +Permission to modify the code and to distribute modified code is granted, +provided the above notices are retained, and a notice that the code was +modified is included with the above copyright notice. + +This is version 5.0alpha3 of a conservative garbage collector for C and C++. + +You might find a more recent version of this at + +http://www.hpl.hp.com/personal/Hans_Boehm/gc + +HISTORY - + + Early versions of this collector were developed as a part of research +projects supported in part by the National Science Foundation +and the Defense Advance Research Projects Agency. +Much of the code was rewritten by Hans-J. Boehm (boehm@acm.org) at Xerox PARC +and at SGI. + +Some other contributors: + +More recent contributors are mentioned in the modification history at the +end of this file. My apologies for any omissions. + +The SPARC specific code was contributed by Mark Weiser +(weiser@parc.xerox.com). The Encore Multimax modifications were supplied by +Kevin Kenny (kenny@m.cs.uiuc.edu). The adaptation to the RT is largely due +to Vernon Lee (scorpion@rice.edu), on machines made available by IBM. +Much of the HP specific code and a number of good suggestions for improving the +generic code are due to Walter Underwood (wunder@hp-ses.sde.hp.com). +Robert Brazile (brazile@diamond.bbn.com) originally supplied the ULTRIX code. +Al Dosser (dosser@src.dec.com) and Regis Cridlig (Regis.Cridlig@cl.cam.ac.uk) +subsequently provided updates and information on variation between ULTRIX +systems. Parag Patel (parag@netcom.com) supplied the A/UX code. +Jesper Peterson(jep@mtiame.mtia.oz.au), Michel Schinz, and +Martin Tauchmann (martintauchmann@bigfoot.com) supplied the Amiga port. +Thomas Funke (thf@zelator.in-berlin.de(?)) and +Brian D.Carlstrom (bdc@clark.lcs.mit.edu) supplied the NeXT ports. +Douglas Steel (doug@wg.icl.co.uk) provided ICL DRS6000 code. +Bill Janssen (janssen@parc.xerox.com) supplied the SunOS dynamic loader +specific code. Manuel Serrano (serrano@cornas.inria.fr) supplied linux and +Sony News specific code. Al Dosser provided Alpha/OSF/1 code. He and +Dave Detlefs(detlefs@src.dec.com) also provided several generic bug fixes. +Alistair G. Crooks(agc@uts.amdahl.com) supplied the NetBSD and 386BSD ports. +Jeffrey Hsu (hsu@soda.berkeley.edu) provided the FreeBSD port. +Brent Benson (brent@jade.ssd.csd.harris.com) ported the collector to +a Motorola 88K processor running CX/UX (Harris NightHawk). +Ari Huttunen (Ari.Huttunen@hut.fi) generalized the OS/2 port to +nonIBM development environments (a nontrivial task). +Patrick Beard (beard@cs.ucdavis.edu) provided the initial MacOS port. +David Chase, then at Olivetti Research, suggested several improvements. +Scott Schwartz (schwartz@groucho.cse.psu.edu) supplied some of the +code to save and print call stacks for leak detection on a SPARC. +Jesse Hull and John Ellis supplied the C++ interface code. +Zhong Shao performed much of the experimentation that led to the +current typed allocation facility. (His dynamic type inference code hasn't +made it into the released version of the collector, yet.) +(Blame for misinstallation of these modifications goes to the first author, +however.) + +OVERVIEW + + This is intended to be a general purpose, garbage collecting storage +allocator. The algorithms used are described in: + +Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment", +Software Practice & Experience, September 1988, pp. 807-820. + +Boehm, H., A. Demers, and S. Shenker, "Mostly Parallel Garbage Collection", +Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design +and Implementation, SIGPLAN Notices 26, 6 (June 1991), pp. 157-164. + +Boehm, H., "Space Efficient Conservative Garbage Collection", Proceedings +of the ACM SIGPLAN '91 Conference on Programming Language Design and +Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206. + + Possible interactions between the collector and optimizing compilers are +discussed in + +Boehm, H., and D. Chase, "A Proposal for GC-safe C Compilation", +The Journal of C Language Translation 4, 2 (December 1992). + +and + +Boehm H., "Simple GC-safe Compilation", Proceedings +of the ACM SIGPLAN '96 Conference on Programming Language Design and +Implementation. + +(Both are also available from +http://reality.sgi.com/boehm/papers/, among other places.) + + Unlike the collector described in the second reference, this collector +operates either with the mutator stopped during the entire collection +(default) or incrementally during allocations. (The latter is supported +on only a few machines.) It does not rely on threads, but is intended +to be thread-safe. + + Some of the ideas underlying the collector have previously been explored +by others. (Doug McIlroy wrote a vaguely similar collector that is part of +version 8 UNIX (tm).) However none of this work appears to have been widely +disseminated. + + Rudimentary tools for use of the collector as a leak detector are included, as +is a fairly sophisticated string package "cord" that makes use of the collector. +(See cord/README.) + + +GENERAL DESCRIPTION + + This is a garbage collecting storage allocator that is intended to be +used as a plug-in replacement for C's malloc. + + Since the collector does not require pointers to be tagged, it does not +attempt to ensure that all inaccessible storage is reclaimed. However, +in our experience, it is typically more successful at reclaiming unused +memory than most C programs using explicit deallocation. Unlike manually +introduced leaks, the amount of unreclaimed memory typically stays +bounded. + + In the following, an "object" is defined to be a region of memory allocated +by the routines described below. + + Any objects not intended to be collected must be pointed to either +from other such accessible objects, or from the registers, +stack, data, or statically allocated bss segments. Pointers from +the stack or registers may point to anywhere inside an object. +The same is true for heap pointers if the collector is compiled with + ALL_INTERIOR_POINTERS defined, as is now the default. + +Compiling without ALL_INTERIOR_POINTERS may reduce accidental retention +of garbage objects, by requiring pointers from the heap to to the beginning +of an object. But this no longer appears to be a significant +issue for most programs. + +There are a number of routines which modify the pointer recognition +algorithm. GC_register_displacement allows certain interior pointers +to be recognized even if ALL_INTERIOR_POINTERS is nor defined. +GC_malloc_ignore_off_page allows some pointers into the middle of large objects +to be disregarded, greatly reducing the probablility of accidental +retention of large objects. For most purposes it seems best to compile +with ALL_INTERIOR_POINTERS and to use GC_malloc_ignore_off_page if +you get collector warnings from allocations of very large objects. +See README.debugging for details. + + Note that pointers inside memory allocated by the standard "malloc" are not +seen by the garbage collector. Thus objects pointed to only from such a +region may be prematurely deallocated. It is thus suggested that the +standard "malloc" be used only for memory regions, such as I/O buffers, that +are guaranteed not to contain pointers to garbage collectable memory. +Pointers in C language automatic, static, or register variables, +are correctly recognized. (Note that GC_malloc_uncollectable has semantics +similar to standard malloc, but allocates objects that are traced by the +collector.) + + The collector does not always know how to find pointers in data +areas that are associated with dynamic libraries. This is easy to +remedy IF you know how to find those data areas on your operating +system (see GC_add_roots). Code for doing this under SunOS, IRIX 5.X and 6.X, +HP/UX, Alpha OSF/1, Linux, and win32 is included and used by default. (See +README.win32 for win32 details.) On other systems pointers from dynamic +library data areas may not be considered by the collector. + + Note that the garbage collector does not need to be informed of shared +read-only data. However if the shared library mechanism can introduce +discontiguous data areas that may contain pointers, then the collector does +need to be informed. + + Signal processing for most signals may be deferred during collection, +and during uninterruptible parts of the allocation process. Unlike +standard ANSI C mallocs, it can be safe to invoke malloc +from a signal handler while another malloc is in progress, provided +the original malloc is not restarted. (Empirically, many UNIX +applications already assume this.) To obtain this level of signal +safety, remove the definition of -DNO_SIGNALS in Makefile. This incurs +a minor performance penalty, and hence is no longer the default. + + The allocator/collector can also be configured for thread-safe operation. +(Full signal safety can also be achieved, but only at the cost of two system +calls per malloc, which is usually unacceptable.) + +INSTALLATION AND PORTABILITY + + As distributed, the macro SILENT is defined in Makefile. +In the event of problems, this can be removed to obtain a moderate +amount of descriptive output for each collection. +(The given statistics exhibit a few peculiarities. +Things don't appear to add up for a variety of reasons, most notably +fragmentation losses. These are probably much more significant for the +contrived program "test.c" than for your application.) + + Note that typing "make test" will automatically build the collector +and then run setjmp_test and gctest. Setjmp_test will give you information +about configuring the collector, which is useful primarily if you have +a machine that's not already supported. Gctest is a somewhat superficial +test of collector functionality. Failure is indicated by a core dump or +a message to the effect that the collector is broken. Gctest takes about +35 seconds to run on a SPARCstation 2. On a slower machine, +expect it to take a while. It may use up to 8 MB of memory. (The +multi-threaded version will use more.) "Make test" will also, as +its last step, attempt to build and test the "cord" string library. +This will fail without an ANSI C compiler. + + The Makefile will generate a library gc.a which you should link against. +Typing "make cords" will add the cord library to gc.a. +Note that this requires an ANSI C compiler. + + It is suggested that if you need to replace a piece of the collector +(e.g. GC_mark_rts.c) you simply list your version ahead of gc.a on the + work.) +ld command line, rather than replacing the one in gc.a. (This will +generate numerous warnings under some versions of AIX, but it still +works.) + + All include files that need to be used by clients will be put in the +include subdirectory. (Normally this is just gc.h. "Make cords" adds +"cord.h" and "ec.h".) + + The collector currently is designed to run essentially unmodified on +machines that use a flat 32-bit or 64-bit address space. +That includes the vast majority of Workstations and X86 (X >= 3) PCs. +(The list here was deleted because it was getting too long and constantly +out of date.) + It does NOT run under plain 16-bit DOS or Windows 3.X. There are however +various packages (e.g. win32s, djgpp) that allow flat 32-bit address +applications to run under those systemsif the have at least an 80386 processor, +and several of those are compatible with the collector. + + In a few cases (Amiga, OS/2, Win32, MacOS) a separate makefile +or equivalent is supplied. Many of these have separate README.system +files. + + Dynamic libraries are completely supported only under SunOS +(and even that support is not functional on the last Sun 3 release), +IRIX 5&6, HP-PA, Win32 (not Win32S) and OSF/1 on DEC AXP machines. +On other machines we recommend that you do one of the following: + + 1) Add dynamic library support (and send us the code). + 2) Use static versions of the libraries. + 3) Arrange for dynamic libraries to use the standard malloc. + This is still dangerous if the library stores a pointer to a + garbage collected object. But nearly all standard interfaces + prohibit this, because they deal correctly with pointers + to stack allocated objects. (Strtok is an exception. Don't + use it.) + + In all cases we assume that pointer alignment is consistent with that +enforced by the standard C compilers. If you use a nonstandard compiler +you may have to adjust the alignment parameters defined in gc_priv.h. + + A port to a machine that is not byte addressed, or does not use 32 bit +or 64 bit addresses will require a major effort. A port to plain MSDOS +or win16 is hard. + + For machines not already mentioned, or for nonstandard compilers, the +following are likely to require change: + +1. The parameters in gcconfig.h. + The parameters that will usually require adjustment are + STACKBOTTOM, ALIGNMENT and DATASTART. Setjmp_test + prints its guesses of the first two. + DATASTART should be an expression for computing the + address of the beginning of the data segment. This can often be + &etext. But some memory management units require that there be + some unmapped space between the text and the data segment. Thus + it may be more complicated. On UNIX systems, this is rarely + documented. But the adb "$m" command may be helpful. (Note + that DATASTART will usually be a function of &etext. Thus a + single experiment is usually insufficient.) + STACKBOTTOM is used to initialize GC_stackbottom, which + should be a sufficient approximation to the coldest stack address. + On some machines, it is difficult to obtain such a value that is + valid across a variety of MMUs, OS releases, etc. A number of + alternatives exist for using the collector in spite of this. See the + discussion in gcconfig.h immediately preceding the various + definitions of STACKBOTTOM. + +2. mach_dep.c. + The most important routine here is one to mark from registers. + The distributed file includes a generic hack (based on setjmp) that + happens to work on many machines, and may work on yours. Try + compiling and running setjmp_t.c to see whether it has a chance of + working. (This is not correct C, so don't blame your compiler if it + doesn't work. Based on limited experience, register window machines + are likely to cause trouble. If your version of setjmp claims that + all accessible variables, including registers, have the value they + had at the time of the longjmp, it also will not work. Vanilla 4.2 BSD + on Vaxen makes such a claim. SunOS does not.) + If your compiler does not allow in-line assembly code, or if you prefer + not to use such a facility, mach_dep.c may be replaced by a .s file + (as we did for the MIPS machine and the PC/RT). + At this point enough architectures are supported by mach_dep.c + that you will rarely need to do more than adjust for assembler + syntax. + +3. os_dep.c (and gc_priv.h). + Several kinds of operating system dependent routines reside here. + Many are optional. Several are invoked only through corresponding + macros in gc_priv.h, which may also be redefined as appropriate. + The routine GC_register_data_segments is crucial. It registers static + data areas that must be traversed by the collector. (User calls to + GC_add_roots may sometimes be used for similar effect.) + Routines to obtain memory from the OS also reside here. + Alternatively this can be done entirely by the macro GET_MEM + defined in gc_priv.h. Routines to disable and reenable signals + also reside here if they are need by the macros DISABLE_SIGNALS + and ENABLE_SIGNALS defined in gc_priv.h. + In a multithreaded environment, the macros LOCK and UNLOCK + in gc_priv.h will need to be suitably redefined. + The incremental collector requires page dirty information, which + is acquired through routines defined in os_dep.c. Unless directed + otherwise by gcconfig.h, these are implemented as stubs that simply + treat all pages as dirty. (This of course makes the incremental + collector much less useful.) + +4. dyn_load.c + This provides a routine that allows the collector to scan data + segments associated with dynamic libraries. Often it is not + necessary to provide this routine unless user-written dynamic + libraries are used. + + For a different version of UN*X or different machines using the +Motorola 68000, Vax, SPARC, 80386, NS 32000, PC/RT, or MIPS architecture, +it should frequently suffice to change definitions in gcconfig.h. + + +THE C INTERFACE TO THE ALLOCATOR + + The following routines are intended to be directly called by the user. +Note that usually only GC_malloc is necessary. GC_clear_roots and GC_add_roots +calls may be required if the collector has to trace from nonstandard places +(e.g. from dynamic library data areas on a machine on which the +collector doesn't already understand them.) On some machines, it may +be desirable to set GC_stacktop to a good approximation of the stack base. +(This enhances code portability on HP PA machines, since there is no +good way for the collector to compute this value.) Client code may include +"gc.h", which defines all of the following, plus many others. + +1) GC_malloc(nbytes) + - allocate an object of size nbytes. Unlike malloc, the object is + cleared before being returned to the user. Gc_malloc will + invoke the garbage collector when it determines this to be appropriate. + GC_malloc may return 0 if it is unable to acquire sufficient + space from the operating system. This is the most probable + consequence of running out of space. Other possible consequences + are that a function call will fail due to lack of stack space, + or that the collector will fail in other ways because it cannot + maintain its internal data structures, or that a crucial system + process will fail and take down the machine. Most of these + possibilities are independent of the malloc implementation. + +2) GC_malloc_atomic(nbytes) + - allocate an object of size nbytes that is guaranteed not to contain any + pointers. The returned object is not guaranteed to be cleared. + (Can always be replaced by GC_malloc, but results in faster collection + times. The collector will probably run faster if large character + arrays, etc. are allocated with GC_malloc_atomic than if they are + statically allocated.) + +3) GC_realloc(object, new_size) + - change the size of object to be new_size. Returns a pointer to the + new object, which may, or may not, be the same as the pointer to + the old object. The new object is taken to be atomic iff the old one + was. If the new object is composite and larger than the original object, + then the newly added bytes are cleared (we hope). This is very likely + to allocate a new object, unless MERGE_SIZES is defined in gc_priv.h. + Even then, it is likely to recycle the old object only if the object + is grown in small additive increments (which, we claim, is generally bad + coding practice.) + +4) GC_free(object) + - explicitly deallocate an object returned by GC_malloc or + GC_malloc_atomic. Not necessary, but can be used to minimize + collections if performance is critical. Probably a performance + loss for very small objects (<= 8 bytes). + +5) GC_expand_hp(bytes) + - Explicitly increase the heap size. (This is normally done automatically + if a garbage collection failed to GC_reclaim enough memory. Explicit + calls to GC_expand_hp may prevent unnecessarily frequent collections at + program startup.) + +6) GC_malloc_ignore_off_page(bytes) + - identical to GC_malloc, but the client promises to keep a pointer to + the somewhere within the first 256 bytes of the object while it is + live. (This pointer should nortmally be declared volatile to prevent + interference from compiler optimizations.) This is the recommended + way to allocate anything that is likely to be larger than 100Kbytes + or so. (GC_malloc may result in failure to reclaim such objects.) + +7) GC_set_warn_proc(proc) + - Can be used to redirect warnings from the collector. Such warnings + should be rare, and should not be ignored during code development. + +8) GC_enable_incremental() + - Enables generational and incremental collection. Useful for large + heaps on machines that provide access to page dirty information. + Some dirty bit implementations may interfere with debugging + (by catching address faults) and place restrictions on heap arguments + to system calls (since write faults inside a system call may not be + handled well). + +9) Several routines to allow for registration of finalization code. + User supplied finalization code may be invoked when an object becomes + unreachable. To call (*f)(obj, x) when obj becomes inaccessible, use + GC_register_finalizer(obj, f, x, 0, 0); + For more sophisticated uses, and for finalization ordering issues, + see gc.h. + + The global variable GC_free_space_divisor may be adjusted up from its +default value of 4 to use less space and more collection time, or down for +the opposite effect. Setting it to 1 or 0 will effectively disable collections +and cause all allocations to simply grow the heap. + + The variable GC_non_gc_bytes, which is normally 0, may be changed to reflect +the amount of memory allocated by the above routines that should not be +considered as a candidate for collection. Careless use may, of course, result +in excessive memory consumption. + + Some additional tuning is possible through the parameters defined +near the top of gc_priv.h. + + If only GC_malloc is intended to be used, it might be appropriate to define: + +#define malloc(n) GC_malloc(n) +#define calloc(m,n) GC_malloc((m)*(n)) + + For small pieces of VERY allocation intensive code, gc_inl.h +includes some allocation macros that may be used in place of GC_malloc +and friends. + + All externally visible names in the garbage collector start with "GC_". +To avoid name conflicts, client code should avoid this prefix, except when +accessing garbage collector routines or variables. + + There are provisions for allocation with explicit type information. +This is rarely necessary. Details can be found in gc_typed.h. + +THE C++ INTERFACE TO THE ALLOCATOR: + + The Ellis-Hull C++ interface to the collector is included in +the collector distribution. If you intend to use this, type +"make c++" after the initial build of the collector is complete. +See gc_cpp.h for the definition of the interface. This interface +tries to approximate the Ellis-Detlefs C++ garbage collection +proposal without compiler changes. + +Cautions: +1. Arrays allocated without new placement syntax are +allocated as uncollectable objects. They are traced by the +collector, but will not be reclaimed. + +2. Failure to use "make c++" in combination with (1) will +result in arrays allocated using the default new operator. +This is likely to result in disaster without linker warnings. + +3. If your compiler supports an overloaded new[] operator, +then gc_cpp.cc and gc_cpp.h should be suitably modified. + +4. Many current C++ compilers have deficiencies that +break some of the functionality. See the comments in gc_cpp.h +for suggested workarounds. + +USE AS LEAK DETECTOR: + + The collector may be used to track down leaks in C programs that are +intended to run with malloc/free (e.g. code with extreme real-time or +portability constraints). To do so define FIND_LEAK in Makefile +This will cause the collector to invoke the report_leak +routine defined near the top of reclaim.c whenever an inaccessible +object is found that has not been explicitly freed. The collector will +no longer reclaim inaccessible memory; in this form it is purely a +debugging tool. + Productive use of this facility normally involves redefining report_leak +to do something more intelligent. This typically requires annotating +objects with additional information (e.g. creation time stack trace) that +identifies their origin. Such code is typically not very portable, and is +not included here, except on SPARC machines. + If all objects are allocated with GC_DEBUG_MALLOC (see next section), +then the default version of report_leak will report the source file +and line number at which the leaked object was allocated. This may +sometimes be sufficient. (On SPARC/SUNOS4 machines, it will also report +a cryptic stack trace. This can often be turned into a sympolic stack +trace by invoking program "foo" with "callprocs foo". Callprocs is +a short shell script that invokes adb to expand program counter values +to symbolic addresses. It was largely supplied by Scott Schwartz.) + Note that the debugging facilities described in the next section can +sometimes be slightly LESS effective in leak finding mode, since in +leak finding mode, GC_debug_free actually results in reuse of the object. +(Otherwise the object is simply marked invalid.) Also note that the test +program is not designed to run meaningfully in FIND_LEAK mode. +Use "make gc.a" to build the collector. + +DEBUGGING FACILITIES: + + The routines GC_debug_malloc, GC_debug_malloc_atomic, GC_debug_realloc, +and GC_debug_free provide an alternate interface to the collector, which +provides some help with memory overwrite errors, and the like. +Objects allocated in this way are annotated with additional +information. Some of this information is checked during garbage +collections, and detected inconsistencies are reported to stderr. + + Simple cases of writing past the end of an allocated object should +be caught if the object is explicitly deallocated, or if the +collector is invoked while the object is live. The first deallocation +of an object will clear the debugging info associated with an +object, so accidentally repeated calls to GC_debug_free will report the +deallocation of an object without debugging information. Out of +memory errors will be reported to stderr, in addition to returning +NIL. + + GC_debug_malloc checking during garbage collection is enabled +with the first call to GC_debug_malloc. This will result in some +slowdown during collections. If frequent heap checks are desired, +this can be achieved by explicitly invoking GC_gcollect, e.g. from +the debugger. + + GC_debug_malloc allocated objects should not be passed to GC_realloc +or GC_free, and conversely. It is however acceptable to allocate only +some objects with GC_debug_malloc, and to use GC_malloc for other objects, +provided the two pools are kept distinct. In this case, there is a very +low probablility that GC_malloc allocated objects may be misidentified as +having been overwritten. This should happen with probability at most +one in 2**32. This probability is zero if GC_debug_malloc is never called. + + GC_debug_malloc, GC_malloc_atomic, and GC_debug_realloc take two +additional trailing arguments, a string and an integer. These are not +interpreted by the allocator. They are stored in the object (the string is +not copied). If an error involving the object is detected, they are printed. + + The macros GC_MALLOC, GC_MALLOC_ATOMIC, GC_REALLOC, GC_FREE, and +GC_REGISTER_FINALIZER are also provided. These require the same arguments +as the corresponding (nondebugging) routines. If gc.h is included +with GC_DEBUG defined, they call the debugging versions of these +functions, passing the current file name and line number as the two +extra arguments, where appropriate. If gc.h is included without GC_DEBUG +defined, then all these macros will instead be defined to their nondebugging +equivalents. (GC_REGISTER_FINALIZER is necessary, since pointers to +objects with debugging information are really pointers to a displacement +of 16 bytes form the object beginning, and some translation is necessary +when finalization routines are invoked. For details, about what's stored +in the header, see the definition of the type oh in debug_malloc.c) + +INCREMENTAL/GENERATIONAL COLLECTION: + +The collector normally interrupts client code for the duration of +a garbage collection mark phase. This may be unacceptable if interactive +response is needed for programs with large heaps. The collector +can also run in a "generational" mode, in which it usually attempts to +collect only objects allocated since the last garbage collection. +Furthermore, in this mode, garbage collections run mostly incrementally, +with a small amount of work performed in response to each of a large number of +GC_malloc requests. + +This mode is enabled by a call to GC_enable_incremental(). + +Incremental and generational collection is effective in reducing +pause times only if the collector has some way to tell which objects +or pages have been recently modified. The collector uses two sources +of information: + +1. Information provided by the VM system. This may be provided in +one of several forms. Under Solaris 2.X (and potentially under other +similar systems) information on dirty pages can be read from the +/proc file system. Under other systems (currently SunOS4.X) it is +possible to write-protect the heap, and catch the resulting faults. +On these systems we require that system calls writing to the heap +(other than read) be handled specially by client code. +See os_dep.c for details. + +2. Information supplied by the programmer. We define "stubborn" +objects to be objects that are rarely changed. Such an object +can be allocated (and enabled for writing) with GC_malloc_stubborn. +Once it has been initialized, the collector should be informed with +a call to GC_end_stubborn_change. Subsequent writes that store +pointers into the object must be preceded by a call to +GC_change_stubborn. + +This mechanism performs best for objects that are written only for +initialization, and such that only one stubborn object is writable +at once. It is typically not worth using for short-lived +objects. Stubborn objects are treated less efficiently than pointerfree +(atomic) objects. + +A rough rule of thumb is that, in the absence of VM information, garbage +collection pauses are proportional to the amount of pointerful storage +plus the amount of modified "stubborn" storage that is reachable during +the collection. + +Initial allocation of stubborn objects takes longer than allocation +of other objects, since other data structures need to be maintained. + +We recommend against random use of stubborn objects in client +code, since bugs caused by inappropriate writes to stubborn objects +are likely to be very infrequently observed and hard to trace. +However, their use may be appropriate in a few carefully written +library routines that do not make the objects themselves available +for writing by client code. + + +BUGS: + + Any memory that does not have a recognizable pointer to it will be +reclaimed. Exclusive-or'ing forward and backward links in a list +doesn't cut it. + Some C optimizers may lose the last undisguised pointer to a memory +object as a consequence of clever optimizations. This has almost +never been observed in practice. Send mail to boehm@acm.org +for suggestions on how to fix your compiler. + This is not a real-time collector. In the standard configuration, +percentage of time required for collection should be constant across +heap sizes. But collection pauses will increase for larger heaps. +(On SPARCstation 2s collection times will be on the order of 300 msecs +per MB of accessible memory that needs to be scanned. Your mileage +may vary.) The incremental/generational collection facility helps, +but is portable only if "stubborn" allocation is used. + Please address bug reports to boehm@acm.org. If you are +contemplating a major addition, you might also send mail to ask whether +it's already been done (or whether we tried and discarded it). + +RECENT VERSIONS: + + Version 1.3 and immediately preceding versions contained spurious +assembly language assignments to TMP_SP. Only the assignment in the PC/RT +code is necessary. On other machines, with certain compiler options, +the assignments can lead to an unsaved register being overwritten. +Known to cause problems under SunOS 3.5 WITHOUT the -O option. (With +-O the compiler recognizes it as dead code. It probably shouldn't, +but that's another story.) + + Version 1.4 and earlier versions used compile time determined values +for the stack base. This no longer works on Sun 3s, since Sun 3/80s use +a different stack base. We now use a straightforward heuristic on all +machines on which it is known to work (incl. Sun 3s) and compile-time +determined values for the rest. There should really be library calls +to determine such values. + + Version 1.5 and earlier did not ensure 8 byte alignment for objects +allocated on a sparc based machine. + + Version 1.8 added ULTRIX support in gc_private.h. + + Version 1.9 fixed a major bug in gc_realloc. + + Version 2.0 introduced a consistent naming convention for collector +routines and added support for registering dynamic library data segments +in the standard mark_roots.c. Most of the data structures were revamped. +The treatment of interior pointers was completely changed. Finalization +was added. Support for locking was added. Object kinds were added. +We added a black listing facility to avoid allocating at addresses known +to occur as integers somewhere in the address space. Much of this +was accomplished by adapting ideas and code from the PCR collector. +The test program was changed and expanded. + + Version 2.1 was the first stable version since 1.9, and added support +for PPCR. + + Version 2.2 added debugging allocation, and fixed various bugs. Among them: +- GC_realloc could fail to extend the size of the object for certain large object sizes. +- A blatant subscript range error in GC_printf, which unfortunately + wasn't exercised on machines with sufficient stack alignment constraints. +- GC_register_displacement did the wrong thing if it was called after + any allocation had taken place. +- The leak finding code would eventually break after 2048 byte + byte objects leaked. +- interface.c didn't compile. +- The heap size remained much too small for large stacks. +- The stack clearing code behaved badly for large stacks, and perhaps + on HP/PA machines. + + Version 2.3 added ALL_INTERIOR_POINTERS and fixed the following bugs: +- Missing declaration of etext in the A/UX version. +- Some PCR root-finding problems. +- Blacklisting was not 100% effective, because the plausible future + heap bounds were being miscalculated. +- GC_realloc didn't handle out-of-memory correctly. +- GC_base could return a nonzero value for addresses inside free blocks. +- test.c wasn't really thread safe, and could erroneously report failure + in a multithreaded environment. (The locking primitives need to be + replaced for other threads packages.) +- GC_CONS was thoroughly broken. +- On a SPARC with dynamic linking, signals stayed diabled while the + client code was running. + (Thanks to Manuel Serrano at INRIA for reporting the last two.) + + Version 2.4 added GC_free_space_divisor as a tuning knob, added + support for OS/2 and linux, and fixed the following bugs: +- On machines with unaligned pointers (e.g. Sun 3), every 128th word could + fail to be considered for marking. +- Dynamic_load.c erroneously added 4 bytes to the length of the data and + bss sections of the dynamic library. This could result in a bad memory + reference if the actual length was a multiple of a page. (Observed on + Sun 3. Can probably also happen on a Sun 4.) + (Thanks to Robert Brazile for pointing out that the Sun 3 version + was broken. Dynamic library handling is still broken on Sun 3s + under 4.1.1U1, but apparently not 4.1.1. If you have such a machine, + use -Bstatic.) + + Version 2.5 fixed the following bugs: +- Removed an explicit call to exit(1) +- Fixed calls to GC_printf and GC_err_printf, so the correct number of + arguments are always supplied. The OS/2 C compiler gets confused if + the number of actuals and the number of formals differ. (ANSI C + doesn't require this to work. The ANSI sanctioned way of doing things + causes too many compatibility problems.) + + Version 3.0 added generational/incremental collection and stubborn + objects. + + Version 3.1 added the following features: +- A workaround for a SunOS 4.X SPARC C compiler + misfeature that caused problems when the collector was turned into + a dynamic library. +- A fix for a bug in GC_base that could result in a memory fault. +- A fix for a performance bug (and several other misfeatures) pointed + out by Dave Detlefs and Al Dosser. +- Use of dirty bit information for static data under Solaris 2.X. +- DEC Alpha/OSF1 support (thanks to Al Dosser). +- Incremental collection on more platforms. +- A more refined heap expansion policy. Less space usage by default. +- Various minor enhancements to reduce space usage, and to reduce + the amount of memory scanned by the collector. +- Uncollectable allocation without per object overhead. +- More conscientious handling of out-of-memory conditions. +- Fixed a bug in debugging stubborn allocation. +- Fixed a bug that resulted in occasional erroneous reporting of smashed + objects with debugging allocation. +- Fixed bogus leak reports of size 4096 blocks with FIND_LEAK. + + Version 3.2 fixed a serious and not entirely repeatable bug in + the incremental collector. It appeared only when dirty bit info + on the roots was available, which is normally only under Solaris. + It also added GC_general_register_disappearing_link, and some + testing code. Interface.c disappeared. + + Version 3.3 fixes several bugs and adds new ports: +- PCR-specific bugs. +- Missing locking in GC_free, redundant FASTUNLOCK + in GC_malloc_stubborn, and 2 bugs in + GC_unregister_disappearing_link. + All of the above were pointed out by Neil Sharman + (neil@cs.mu.oz.au). +- Common symbols allocated by the SunOS4.X dynamic loader + were not included in the root set. +- Bug in GC_finalize (reported by Brian Beuning and Al Dosser) +- Merged Amiga port from Jesper Peterson (untested) +- Merged NeXT port from Thomas Funke (significantly + modified and untested) + + Version 3.4: +- Fixed a performance bug in GC_realloc. +- Updated the amiga port. +- Added NetBSD and 386BSD ports. +- Added cord library. +- Added trivial performance enhancement for + ALL_INTERIOR_POINTERS. (Don't scan last word.) + + Version 3.5 +- Minor collections now mark from roots only once, if that + doesn't cause an excessive pause. +- The stack clearing heuristic was refined to prevent anomalies + with very heavily recursive programs and sparse stacks. +- Fixed a bug that prevented mark stack growth in some cases. + GC_objects_are_marked should be set to TRUE after a call + to GC_push_roots and as part of GC_push_marked, since + both can now set mark bits. I think this is only a performance + bug, but I wouldn't bet on it. It's certainly very hard to argue + that the old version was correct. +- Fixed an incremental collection bug that prevented it from + working at all when HBLKSIZE != getpagesize() +- Changed dynamic_loading.c to include gc_priv.h before testing + DYNAMIC_LOADING. SunOS dynamic library scanning + must have been broken in 3.4. +- Object size rounding now adapts to program behavior. +- Added a workaround (provided by Manuel Serrano and + colleagues) to a long-standing SunOS 4.X (and 3.X?) ld bug + that I had incorrectly assumed to have been squished. + The collector was broken if the text segment size was within + 32 bytes of a multiple of 8K bytes, and if the beginning of + the data segment contained interesting roots. The workaround + assumes a demand-loadable executable. The original may have + have "worked" in some other cases. +- Added dynamic library support under IRIX5. +- Added support for EMX under OS/2 (thanks to Ari Huttunen). + +Version 3.6: +- fixed a bug in the mark stack growth code that was introduced + in 3.4. +- fixed Makefile to work around DEC AXP compiler tail recursion + bug. + +Version 3.7: +- Added a workaround for an HP/UX compiler bug. +- Fixed another stack clearing performance bug. Reworked + that code once more. + +Version 4.0: +- Added support for Solaris threads (which was possible + only by reimplementing some fraction of Solaris threads, + since Sun doesn't currently make the thread debugging + interface available). +- Added non-threads win32 and win32S support. +- (Grudgingly, with suitable muttering of obscenities) renamed + files so that the collector distribution could live on a FAT + file system. Files that are guaranteed to be useless on + a PC still have long names. Gc_inline.h and gc_private.h + still exist, but now just include gc_inl.h and gc_priv.h. +- Fixed a really obscure bug in finalization that could cause + undetected mark stack overflows. (I would be surprised if + any real code ever tickled this one.) +- Changed finalization code to dynamically resize the hash + tables it maintains. (This probably does not matter for well- + -written code. It no doubt does for C++ code that overuses + destructors.) +- Added typed allocation primitives. Rewrote the marker to + accommodate them with more reasonable efficiency. This + change should also speed up marking for GC_malloc allocated + objects a little. See gc_typed.h for new primitives. +- Improved debugging facilities slightly. Allocation time + stack traces are now kept by default on SPARC/SUNOS4. + (Thanks to Scott Schwartz.) +- Added better support for small heap applications. +- Significantly extended cord package. Fixed a bug in the + implementation of lazily read files. Printf and friends now + have cord variants. Cord traversals are a bit faster. +- Made ALL_INTERIOR_POINTERS recognition the default. +- Fixed de so that it can run in constant space, independent + of file size. Added simple string searching to cords and de. +- Added the Hull-Ellis C++ interface. +- Added dynamic library support for OSF/1. + (Thanks to Al Dosser and Tim Bingham at DEC.) +- Changed argument to GC_expand_hp to be expressed + in units of bytes instead of heap blocks. (Necessary + since the heap block size now varies depending on + configuration. The old version was never very clean.) +- Added GC_get_heap_size(). The previous "equivalent" + was broken. +- Restructured the Makefile a bit. + +Since version 4.0: +- Changed finalization implementation to guarantee that + finalization procedures are called outside of the allocation + lock, making direct use of the interface a little less dangerous. + MAY BREAK EXISTING CLIENTS that assume finalizers + are protected by a lock. Since there seem to be few multithreaded + clients that use finalization, this is hopefully not much of + a problem. +- Fixed a gross bug in CORD_prev. +- Fixed a bug in blacklst.c that could result in unbounded + heap growth during startup on machines that do not clear + memory obtained from the OS (e.g. win32S). +- Ported de editor to win32/win32S. (This is now the only + version with a mouse-sensitive UI.) +- Added GC_malloc_ignore_off_page to allocate large arrays + in the presence of ALL_INTERIOR_POINTERS. +- Changed GC_call_with_alloc_lock to not disable signals in + the single-threaded case. +- Reduced retry count in GC_collect_or_expand for garbage + collecting when out of memory. +- Made uncollectable allocations bypass black-listing, as they + should. +- Fixed a bug in typed_test in test.c that could cause (legitimate) + GC crashes. +- Fixed some potential synchronization problems in finalize.c +- Fixed a real locking problem in typd_mlc.c. +- Worked around an AIX 3.2 compiler feature that results in + out of bounds memory references. +- Partially worked around an IRIX5.2 beta problem (which may + or may not persist to the final release). +- Fixed a bug in the heap integrity checking code that could + result in explicitly deallocated objects being identified as + smashed. Fixed a bug in the dbg_mlc stack saving code + that caused old argument pointers to be considered live. +- Fixed a bug in CORD_ncmp (and hence CORD_str). +- Repaired the OS2 port, which had suffered from bit rot + in 4.0. Worked around what appears to be CSet/2 V1.0 + optimizer bug. +- Fixed a Makefile bug for target "c++". + +Since version 4.1: +- Multiple bug fixes/workarounds in the Solaris threads version. + (It occasionally failed to locate some register contents for + marking. It also turns out that thr_suspend and friends are + unreliable in Solaris 2.3. Dirty bit reads appear + to be unreliable under some weird + circumstances. My stack marking code + contained a serious performance bug. The new code is + extremely defensive, and has not failed in several cpu + hours of testing. But no guarantees ...) +- Added MacOS support (thanks to Patrick Beard.) +- Fixed several syntactic bugs in gc_c++.h and friends. (These + didn't bother g++, but did bother most other compilers.) + Fixed gc_c++.h finalization interface. (It didn't.) +- 64 bit alignment for allocated objects was not guaranteed in a + few cases in which it should have been. +- Added GC_malloc_atomic_ignore_off_page. +- Added GC_collect_a_little. +- Added some prototypes to gc.h. +- Some other minor bug fixes (notably in Makefile). +- Fixed OS/2 / EMX port (thanks to Ari Huttunen). +- Fixed AmigaDOS port. (thanks to Michel Schinz). +- Fixed the DATASTART definition under Solaris. There + was a 1 in 16K chance of the collector missing the first + 64K of static data (and thus crashing). +- Fixed some blatant anachronisms in the README file. +- Fixed PCR-Makefile for upcoming PPCR release. + +Since version 4.2: +- Fixed SPARC alignment problem with GC_DEBUG. +- Fixed Solaris threads /proc workaround. The real + problem was an interaction with mprotect. +- Incorporated fix from Patrick Beard for gc_c++.h (now gc_cpp.h). +- Slightly improved allocator space utilization by + fixing the GC_size_map mechanism. +- Integrated some Sony News and MIPS RISCos 4.51 + patches. (Thanks to Nobuyuki Hikichi of + Software Research Associates, Inc. Japan) +- Fixed HP_PA alignment problem. (Thanks to + xjam@cork.cs.berkeley.edu.) +- Added GC_same_obj and friends. Changed GC_base + to return 0 for pointers past the end of large objects. + Improved GC_base performance with ALL_INTERIOR_POINTERS + on machines with a slow integer mod operation. + Added GC_PTR_ADD, GC_PTR_STORE, etc. to prepare + for preprocessor. +- changed the default on most UNIX machines to be that + signals are not disabled during critical GC operations. + This is still ANSI-conforming, though somewhat dangerous + in the presence of signal handlers. But the performance + cost of the alternative is sometimes problematic. + Can be changed back with a minor Makefile edit. +- renamed IS_STRING in gc.h, to CORD_IS_STRING, thus + following my own naming convention. Added the function + CORD_to_const_char_star. +- Fixed a gross bug in GC_finalize. Symptom: occasional + address faults in that function. (Thanks to Anselm + Baird-Smith (Anselm.BairdSmith@inria.fr) +- Added port to ICL DRS6000 running DRS/NX. Restructured + things a bit to factor out common code, and remove obsolete + code. Collector should now run under SUNOS5 with either + mprotect or /proc dirty bits. (Thanks to Douglas Steel + (doug@wg.icl.co.uk)). +- More bug fixes and workarounds for Solaris 2.X. (These were + mostly related to putting the collector in a dynamic library, + which didn't really work before. Also SOLARIS_THREADS + didn't interact well with dl_open.) Thanks to btlewis@eng.sun.com. +- Fixed a serious performance bug on the DEC Alpha. The text + segment was getting registered as part of the root set. + (Amazingly, the result was still fast enough that the bug + was not conspicuous.) The fix works on OSF/1, version 1.3. + Hopefully it also works on other versions of OSF/1 ... +- Fixed a bug in GC_clear_roots. +- Fixed a bug in GC_generic_malloc_words_small that broke + gc_inl.h. (Reported by Antoine de Maricourt. I broke it + in trying to tweak the Mac port.) +- Fixed some problems with cord/de under Linux. +- Fixed some cord problems, notably with CORD_riter4. +- Added DG/UX port. + Thanks to Ben A. Mesander (ben@piglet.cr.usgs.gov) +- Added finalization registration routines with weaker ordering + constraints. (This is necessary for C++ finalization with + multiple inheritance, since the compiler often adds self-cycles.) +- Filled the holes in the SCO port. (Thanks to Michael Arnoldus + .) +- John Ellis' additions to the C++ support: From John: + +* I completely rewrote the documentation in the interface gc_c++.h +(later renamed gc_cpp.h). I've tried to make it both clearer and more +precise. + +* The definition of accessibility now ignores pointers from an +finalizable object (an object with a clean-up function) to itself. +This allows objects with virtual base classes to be finalizable by the +collector. Compilers typically implement virtual base classes using +pointers from an object to itself, which under the old definition of +accessibility prevented objects with virtual base classes from ever +being collected or finalized. + +* gc_cleanup now includes gc as a virtual base. This was enabled by +the change in the definition of accessibility. + +* I added support for operator new[]. Since most (all?) compilers +don't yet support operator new[], it is conditionalized on +-DOPERATOR_NEW_ARRAY. The code is untested, but its trivial and looks +correct. + +* The test program test_gc_c++ (later renamed test_cpp.cc) +tries to test for the C++-specific functionality not tested by the +other programs. +- Added include to misc.c. (Needed for ppcr.) +- Added PowerMac port. (Thanks to Patrick Beard again.) +- Fixed "srcdir"-related Makefile problems. Changed things so + that all externally visible include files always appear in the + include subdirectory of the source. Made gc.h directly + includable from C++ code. (These were at Per + Bothner's suggestion.) +- Changed Intel code to also mark from ebp (Kevin Warne's + suggestion). +- Renamed C++ related files so they could live in a FAT + file system. (Charles Fiterman's suggestion.) +- Changed Windows NT Makefile to include C++ support in + gc.lib. Added C++ test as Makefile target. + +Since version 4.3: + - ASM_CLEAR_CODE was erroneously defined for HP + PA machines, resulting in a compile error. + - Fixed OS/2 Makefile to create a library. (Thanks to + Mark Boulter (mboulter@vnet.ibm.com)). + - Gc_cleanup objects didn't work if they were created on + the stack. Fixed. + - One copy of Gc_cpp.h in the distribution was out of + synch, and failed to document some known compiler + problems with explicit destructor invocation. Partially + fixed. There are probably other compilers on which + gc_cleanup is miscompiled. + - Fixed Makefile to pass C compiler flags to C++ compiler. + - Added Mac fixes. + - Fixed os_dep.c to work around what appears to be + a new and different VirtualQuery bug under newer + versions of win32S. + - GC_non_gc_bytes was not correctly maintained by + GC_free. Fixed. Thanks to James Clark (jjc@jclark.com). + - Added GC_set_max_heap_size. + - Changed allocation code to ignore blacklisting if it is preventing + use of a very large block of memory. This has the advantage + that naive code allocating very large objects is much more + likely to work. The downside is you might no + longer find out that such code should really use + GC_malloc_ignore_off_page. + - Changed GC_printf under win32 to close and reopen the file + between calls. FAT file systems otherwise make the log file + useless for debugging. + - Added GC_try_to_collect and GC_get_bytes_since_gc. These + allow starting an abortable collection during idle times. + This facility does not require special OS support. (Thanks to + Michael Spertus of Geodesic Systems for suggesting this. It was + actually an easy addition. Kumar Srikantan previously added a similar + facility to a now ancient version of the collector. At the time + this was much harder, and the result was less convincing.) + - Added some support for the Borland development environment. (Thanks + to John Ellis and Michael Spertus.) + - Removed a misfeature from checksums.c that caused unexpected + heap growth. (Thanks to Scott Schwartz.) + - Changed finalize.c to call WARN if it encounters a finalization cycle. + WARN is defined in gc_priv.h to write a message, usually to stdout. + In many environments, this may be inappropriate. + - Renamed NO_PARAMS in gc.h to GC_NO_PARAMS, thus adhering to my own + naming convention. + - Added GC_set_warn_proc to intercept warnings. + - Fixed Amiga port. (Thanks to Michel Schinz (schinz@alphanet.ch).) + - Fixed a bug in mark.c that could result in an access to unmapped + memory from GC_mark_from_mark_stack on machines with unaligned + pointers. + - Fixed a win32 specific performance bug that could result in scanning of + objects allocated with the system malloc. + - Added REDIRECT_MALLOC. + +Since version 4.4: + - Fixed many minor and one major README bugs. (Thanks to Franklin Chen + (chen@adi.com) for pointing out many of them.) + - Fixed ALPHA/OSF/1 dynamic library support. (Thanks to Jonathan Bachrach + (jonathan@harlequin.com)). + - Added incremental GC support (MPROTECT_VDB) for Linux (with some + help from Bruno Haible). + - Altered SPARC recognition tests in gc.h and config.h (mostly as + suggested by Fergus Henderson). + - Added basic incremental GC support for win32, as implemented by + Windows NT and Windows 95. GC_enable_incremental is a noop + under win32s, which doesn't implement enough of the VM interface. + - Added -DLARGE_CONFIG. + - Fixed GC_..._ignore_off_page to also function without + -DALL_INTERIOR_POINTERS. + - (Hopefully) fixed RS/6000 port. (Only the test was broken.) + - Fixed a performance bug in the nonincremental collector running + on machines supporting incremental collection with MPROTECT_VDB + (e.g. SunOS 4, DEC AXP). This turned into a correctness bug under + win32s with win32 incremental collection. (Not all memory protection + was disabled.) + - Fixed some ppcr related bit rot. + - Caused dynamic libraries to be unregistered before reregistering. + The old way turned out to be a performance bug on some machines. + - GC_root_size was not properly maintained under MSWIN32. + - Added -DNO_DEBUGGING and GC_dump. + - Fixed a couple of bugs arising with SOLARIS_THREADS + + REDIRECT_MALLOC. + - Added NetBSD/M68K port. (Thanks to Peter Seebach + .) + - Fixed a serious realloc bug. For certain object sizes, the collector + wouldn't scan the expanded part of the object. (Thanks to Clay Spence + (cds@peanut.sarnoff.com) for noticing the problem, and helping me to + track it down.) + +Since version 4.5: + - Added Linux ELF support. (Thanks to Arrigo Triulzi .) + - GC_base crashed if it was called before any other GC_ routines. + This could happen if a gc_cleanup object was allocated outside the heap + before any heap allocation. + - The heap expansion heuristic was not stable if all objects had finalization + enabled. Fixed finalize.c to count memory in finalization queue and + avoid explicit deallocation. Changed alloc.c to also consider this count. + (This is still not recommended. It's expensive if nothing else.) Thanks + to John Ellis for pointing this out. + - GC_malloc_uncollectable(0) was broken. Thanks to Phong Vo for pointing + this out. + - The collector didn't compile under Linux 1.3.X. (Thanks to Fred Gilham for + pointing this out.) The current workaround is ugly, but expected to be + temporary. + - Fixed a formatting problem for SPARC stack traces. + - Fixed some '=='s in os_dep.c that should have been assignments. + Fortunately these were in code that should never be executed anyway. + (Thanks to Fergus Henderson.) + - Fixed the heap block allocator to only drop blacklisted blocks in small + chunks. Made BL_LIMIT self adjusting. (Both of these were in response + to heap growth observed by Paul Graham.) + - Fixed the Metrowerks/68K Mac code to also mark from a6. (Thanks + to Patrick Beard.) + - Significantly updated README.debugging. + - Fixed some problems with longjmps out of signal handlers, especially under + Solaris. Added a workaround for the fact that siglongjmp doesn't appear to + do the right thing with -lthread under Solaris. + - Added MSDOS/djgpp port. (Thanks to Mitch Harris (maharri@uiuc.edu).) + - Added "make reserved_namespace" and "make user_namespace". The + first renames ALL "GC_xxx" identifiers as "_GC_xxx". The second is the + inverse transformation. Note that doing this is guaranteed to break all + clients written for the other names. + - descriptor field for kind NORMAL in GC_obj_kinds with ADD_BYTE_AT_END + defined should be -ALIGNMENT not WORDS_TO_BYTES(-1). This is + a serious bug on machines with pointer alignment of less than a word. + - GC_ignore_self_finalize_mark_proc didn't handle pointers to very near the + end of the object correctly. Caused failures of the C++ test on a DEC Alpha + with g++. + - gc_inl.h still had problems. Partially fixed. Added warnings at the + beginning to hopefully specify the remaining dangers. + - Added DATAEND definition to config.h. + - Fixed some of the .h file organization. Fixed "make floppy". + +Since version 4.6: + - Fixed some compilation problems with -DCHECKSUMS (thanks to Ian Searle) + - Updated some Mac specific files to synchronize with Patrick Beard. + - Fixed a serious bug for machines with non-word-aligned pointers. + (Thanks to Patrick Beard for pointing out the problem. The collector + should fail almost any conceivable test immediately on such machines.) + +Since version 4.7: + - Changed a "comment" in a MacOS specific part of mach-dep.c that caused + gcc to fail on other platforms. + +Since version 4.8 + - More README.debugging fixes. + - Objects ready for finalization, but not finalized in the same GC + cycle, could be prematurely collected. This occasionally happened + in test_cpp. + - Too little memory was obtained from the system for very large + objects. That could cause a heap explosion if these objects were + not contiguous (e.g. under PCR), and too much of them was blacklisted. + - Due to an improper initialization, the collector was too hesitant to + allocate blacklisted objects immediately after system startup. + - Moved GC_arrays from the data into the bss segment by not explicitly + initializing it to zero. This significantly + reduces the size of executables, and probably avoids some disk accesses + on program startup. It's conceivable that it might break a port that I + didn't test. + - Fixed EMX_MAKEFILE to reflect the gc_c++.h to gc_cpp.h renaming which + occurred a while ago. + +Since 4.9: + - Fixed a typo around a call to GC_collect_or_expand in alloc.c. It broke + handling of out of memory. (Thanks to Patrick Beard for noticing.) + +Since 4.10: + - Rationalized (hopefully) GC_try_to_collect in an incremental collection + environment. It appeared to not handle a call while a collection was in + progress, and was otherwise too conservative. + - Merged GC_reclaim_or_delete_all into GC_reclaim_all to get rid of some + code. + - Added Patrick Beard's Mac fixes, with substantial completely untested + modifications. + - Fixed the MPROTECT_VDB code to deal with large pages and imprecise + fault addresses (as on an UltraSPARC running Solaris 2.5). Note that this + was not a problem in the default configuration, which uses PROC_VDB. + - The DEC Alpha assembly code needed to restore $gp between calls. + Thanks to Fergus Henderson for tracking this down and supplying a + patch. + - The write command for "de" was completely broken for large files. + I used the easiest portable fix, which involved changing the semantics + so that f.new is written instead of overwriting f. That's safer anyway. + - Added README.solaris2 with a discussion of the possible problems of + mixing the collector's sbrk allocation with malloc/realloc. + - Changed the data segment starting address for SGI machines. The + old code failed under IRIX6. + - Required double word alignment for MIPS. + - Various minor fixes to remove warnings. + - Attempted to fix some Solaris threads problems reported by Zhiying Chen. + In particular, the collector could try to fork a thread with the + world stopped as part of GC_thr_init. It also failed to deal with + the case in which the original thread terminated before the whole + process did. + - Added -DNO_EXECUTE_PERMISSION. This has a major performance impact + on the incremental collector under Irix, and perhaps under other + operating systems. + - Added some code to support allocating the heap with mmap. This may + be preferable under some circumstances. + - Integrated dynamic library support for HP. + (Thanks to Knut Tvedten .) + - Integrated James Clark's win32 threads support, and made a number + of changes to it, many of which were suggested by Pontus Rydin. + This is still not 100% solid. + - Integrated Alistair Crooks' support for UTS4 running on an Amdahl + 370-class machine. + - Fixed a serious bug in explicitly typed allocation. Objects requiring + large descriptors where handled in a way that usually resulted in + a segmentation fault in the marker. (Thanks to Jeremy Fitzhardinge + for helping to track this down.) + - Added partial support for GNU win32 development. (Thanks to Fergus + Henderson.) + - Added optional support for Java-style finalization semantics. (Thanks + to Patrick Bridges.) This is recommended only for Java implementations. + - GC_malloc_uncollectable faulted instead of returning 0 when out of + memory. (Thanks to dan@math.uiuc.edu for noticing.) + - Calls to GC_base before the collector was initialized failed on a + DEC Alpha. (Thanks to Matthew Flatt.) + - Added base pointer checking to GC_REGISTER_FINALIZER in debugging + mode, at the suggestion of Jeremy Fitzhardinge. + - GC_debug_realloc failed for uncollectable objects. (Thanks to + Jeremy Fitzhardinge.) + - Explicitly typed allocation could crash if it ran out of memory. + (Thanks to Jeremy Fitzhardinge.) + - Added minimal support for a DEC Alpha running Linux. + - Fixed a problem with allocation of objects whose size overflowed + ptrdiff_t. (This now fails unconditionally, as it should.) + - Added the beginning of Irix pthread support. + - Integrated Xiaokun Zhu's fixes for djgpp 2.01. + - Added SGI-style STL allocator support (gc_alloc.h). + - Fixed a serious bug in README.solaris2. Multithreaded programs must include + gc.h with SOLARIS_THREADS defined. + - Changed GC_free so it actually deallocates uncollectable objects. + (Thanks to Peter Chubb for pointing out the problem.) + - Added Linux ELF support for dynamic libararies. (Thanks again to + Patrick Bridges.) + - Changed the Borland cc configuration so that the assembler is not + required. + - Fixed a bug in the C++ test that caused it to fail in 64-bit + environments. + +Since 4.11: + - Fixed ElfW definition in dyn_load.c. (Thanks to Fergus Henderson.) + This prevented the dynamic library support from compiling on some + older ELF Linux systems. + - Fixed UTS4 port (which I apparently mangled during the integration) + (Thanks to again to Alistair Crooks.) + - "Make C++" failed on Suns with SC4.0, due to a problem with "bool". + Fixed in gc_priv.h. + - Added more pieces for GNU win32. (Thanks to Timothy N. Newsham.) + The current state of things should suffice for at least some + applications. + - Changed the out of memory retry count handling as suggested by + Kenjiro Taura. (This matters only if GC_max_retries > 0, which + is no longer the default.) + - If a /proc read failed repeatedly, GC_written_pages was not updated + correctly. (Thanks to Peter Chubb for diagnosing this.) + - Under unlikely circumstances, the allocator could infinite loop in + an out of memory situation. (Thanks again to Kenjiro Taura for + identifying the problem and supplying a fix.) + - Fixed a syntactic error in the DJGPP code. (Thanks to Fergus + Henderson for finding this by inspection.) Also fixed a test program + problem with DJGPP (Thanks to Peter Monks.) + - Atomic uncollectable objects were not treated correctly by the + incremental collector. This resulted in weird log statistics and + occasional performance problems. (Thanks to Peter Chubb for pointing + this out.) + - Fixed some problems resulting from compilers that dont define + __STDC__. In this case void * and char * were used inconsistently + in some cases. (Void * should not have been used at all. If + you have an ANSI superset compiler that does not define __STDC__, + please compile with -D__STDC__=0. Thanks to Manuel Serrano and others + for pointing out the problem.) + - Fixed a compilation problem on Irix with -n32 and -DIRIX_THREADS. + Also fixed some other IRIX_THREADS problems which may or may not have + had observable symptoms. + - Fixed an HP PA compilation problem in dyn_load.c. (Thanks to + Philippe Queinnec.) + - SEGV fault handlers sometimes did not get reset correctly. (Thanks + to David Pickens.) + - Added a fix for SOLARIS_THREADS on Intel. (Thanks again to David + Pickens.) This probably needs more work to become functional. + - Fixed struct sigcontext_struct in os_dep.c for compilation under + Linux 2.1.X. (Thanks to Fergus Henderson.) + - Changed the DJGPP STACKBOTTOM and DATASTART values to those suggested + by Kristian Kristensen. These may still not be right, but it is + it is likely to work more often than what was there before. They may + even be exactly right. + - Added a #include to test_cpp.cc. This appears to help + with HP/UX and gcc. (Thanks to assar@sics.se.) + - Version 4.11 failed to run in incremental mode on recent 64-bit Irix + kernels. This was a problem related to page unaligned heap segments. + Changed the code to page align heap sections on all platforms. + (I had mistakenly identified this as a kernel problem earlier. + It was not.) + - Version 4.11 did not make allocated storage executable, except on + one or two platforms, due to a bug in a #if test. (Thanks to Dave + Grove for pointing this out.) + - Added sparc_sunos4_mach_dep.s to support Sun's compilers under SunOS4. + - Added GC_exclude_static_roots. + - Fixed the object size mapping algorithm. This shouldn't matter, + but the old code was ugly. + - Heap checking code could die if one of the allocated objects was + larger than its base address. (Unsigned underflow problem. Thanks + to Clay Spence for isolating the problem.) + - Added RS6000 (AIX) dynamic library support and fixed STACK_BOTTOM. + (Thanks to Fred Stearns.) + - Added Fergus Henderson's patches for improved robustness with large + heaps and lots of blacklisting. + - Added Peter Chubb's changes to support Solaris Pthreads, to support + MMAP allocation in Solaris, to allow Solaris to find dynamic libraries + through /proc, to add malloc_typed_ignore_off_page, and a few other + minor features and bug fixes. + - The Solaris 2 port should not use sbrk. I received confirmation from + Sun that the use of sbrk and malloc in the same program is not + supported. The collector now defines USE_MMAP by default on Solaris. + - Replaced the djgpp makefile with Gary Leavens' version. + - Fixed MSWIN32 detection test. + - Added Fergus Henderson's patches to allow putting the collector into + a DLL under GNU win32. + - Added Ivan V. Demakov's port to Watcom C on X86. + - Added Ian Piumarta's Linux/PowerPC port. + - On Brian Burton's suggestion added PointerFreeGC to the placement + options in gc_cpp.h. This is of course unsafe, and may be controversial. + On the other hand, it seems to be needed often enough that it's worth + adding as a standard facility. + +Since 4.12: + - Fixed a crucial bug in the Watcom port. There was a redundant decl + of GC_push_one in gc_priv.h. + - Added FINALIZE_ON_DEMAND. + - Fixed some pre-ANSI cc problems in test.c. + - Removed getpagesize() use for Solaris. It seems to be missing in one + or two versions. + - Fixed bool handling for SPARCCompiler version 4.2. + - Fixed some files in include that had gotten unlinked from the main + copy. + - Some RS/6000 fixes (missing casts). Thanks to Toralf Foerster. + - Fixed several problems in GC_debug_realloc, affecting mostly the + FIND_LEAK case. + - GC_exclude_static_roots contained a buggy unsigned comparison to + terminate a loop. (Thanks to Wilson Ho.) + - CORD_str failed if the substring occurred at the last possible position. + (Only affects cord users.) + - Fixed Linux code to deal with RedHat 5.0 and integrated Peter Bigot's + os_dep.c code for dealing with various Linux versions. + - Added workaround for Irix pthreads sigaction bug and possible signal + misdirection problems. +Since alpha1: + - Changed RS6000 STACKBOTTOM. + - Integrated Patrick Beard's Mac changes. + - Alpha1 didn't compile on Irix m.n, m < 6. + - Replaced Makefile.dj with a new one from Gary Leavens. + - Added Andrew Stitcher's changes to support SCO OpenServer. + - Added PRINT_BLACK_LIST, to allow debugging of high densities of false + pointers. + - Added code to debug allocator to keep track of return address + in GC_malloc caller, thus giving a bit more context. + - Changed default behavior of large block allocator to more + aggressively avoid fragmentation. This is likely to slow down the + collector when it succeeds at reducing space cost. + - Integrated Fergus Henderson's CYGWIN32 changes. They are untested, + but needed for newer versions. + - USE_MMAP had some serious bugs. This caused the collector to fail + consistently on Solaris with -DSMALL_CONFIG. + - Added Linux threads support, thanks largely to Fergus Henderson. +Since alpha2: + - Fixed more Linux threads problems. + - Changed default GC_free_space_divisor to 3 with new large block allocation. + (Thanks to Matthew Flatt for some measurements that suggest the old + value sometimes favors space too much over time.) + - More CYGWIN32 fixes. + - Integrated Tyson-Dowd's Linux-M68K port. + - Minor HP PA and DEC UNIX fixes from Fergus Henderson. + - Integrated Christoffe Raffali's Linux-SPARC changes. + - Allowed for one more GC fixup iteration after a full GC in incremental + mode. Some quick measurements suggested that this significantly + reduces pause times even with smaller GC_RATE values. + - Moved some more GC data structures into GC_arrays. This decreases + pause times and GC overhead, but makes debugging slightly less convenient. + - Fixed namespace pollution problem ("excl_table"). + - Made GC_incremental a constant for -DSMALL_CONFIG, hopefully shrinking + that slightly. + - Added some win32 threads fixes. + - Integrated Ivan Demakov and David Stes' Watcom fixes. + - Various other minor fixes contributed by many people. + - Renamed config.h to gcconfig.h, since config.h tends to be used for + many other things. + - Integrated Matthew Flatt's support for 68K MacOS "far globals". + - Fixed up some of the dynamic library Makefile targets for consistency + across platforms. + - Fixed a USE_MMAP typo that caused out-of-memory handling to fail + on Solaris. + - Added code to test.c to test thread creation a bit more. + - Integrated GC_win32_free_heap, as suggested by Ivan Demakov. + - Fixed Solaris 2.7 stack base finding problem. (This may actually + have been done in an earlier alpha release.) +Since alpha3: + - Fixed MSWIN32 recognition test, which interfered with cygwin. + - Removed unnecessary gc_watcom.asm from distribution. Removed + some obsolete README.win32 text. + - Added Alpha Linux incremental GC support. (Thanks to Philipp Tomsich + for code for retrieving the fault address in a signal handler.) + Changed Linux signal handler context argument to be a pointer. + - Took care of some new warnings generated by the 7.3 SGI compiler. + - Integrated Phillip Musumeci's FreeBSD/ELF fixes. + - -DIRIX_THREADS was broken with the -o32 ABI (typo in gc_priv.h> + +Since 4.13: + - Fixed GC_print_source_ptr to not use a prototype. + - generalized CYGWIN test. + - gc::new did the wrong thing with PointerFreeGC placement. + (Thanks to Rauli Ruohonen.) + - In the ALL_INTERIOR_POINTERS (default) case, some callee-save register + values could fail to be scanned if the register was saved and + reused in a GC frame. This showed up in verbose mode with gctest + compiled with an unreleased SGI compiler. I vaguely recall an old + bug report that may have been related. The bug was probably quite old. + (The problem was that the stack scanning could be deferred until + after the relevant frame was overwritten, and the new save location + might be outside the scanned area. Fixed by more eager stack scanning.) + - PRINT_BLACK_LIST had some problems. A few source addresses were garbage. + - Replaced Makefile.dj and added -I flags to cord make targets. + (Thanks to Gary Leavens.) + - GC_try_to_collect was broken with the nonincremental collector. + - gc_cleanup destructors could pass the wrong address to + GC_register_finalizer_ignore_self in the presence of multiple + inheritance. (Thanks to Darrell Schiebel.) + - Changed PowerPC Linux stack finding code. + +Since 4.14alpha1 + - -DSMALL_CONFIG did not work reliably with large (> 4K) pages. + Recycling the mark stack during expansion could result in a size + zero heap segment, which confused things. (This was probably also an + issue with the normal config and huge pages.) + - Did more work to make sure that callee-save registers were scanned + completely, even with the setjmp-based code. Added USE_GENERIC_PUSH_REGS + macro to facilitate testing on machines I have access to. + - Added code to explicitly push register contents for win32 threads. + This seems to be necessary. (Thanks to Pierre de Rop.) + +Since 4.14alpha2 + - changed STACKBOTTOM for DJGPP (Thanks to Salvador Eduardo Tropea). + +Since 4.14 + - Reworked large block allocator. Now uses multiple doubly linked free + lists to approximate best fit. + - Changed heap expansion heuristic. Entirely free blocks are no longer + counted towards the heap size. This seems to have a major impact on + heap size stability; the old version could expand the heap way too + much in the presence of large block fragmentation. + - added -DGC_ASSERTIONS and some simple assertions inside the collector. + This is mainlyt for collector debugging. + - added -DUSE_MUNMAP to allow the heap to shrink. Suupported on only + a few UNIX-like platforms for now. + - added GC_dump_regions() for debugging of fragmentation issues. + - Changed PowerPC pointer alignment under Linux to 4. (This needs + checking by someone who has one. The suggestions came to me via a + rather circuitous path.) + - Changed the Linux/Alpha port to walk the data segment backwards until + it encounters a SIGSEGV. The old way to find the start of the data + segment broke with a recent release. + - cordxtra.c needed to call GC_REGISTER_FINALIZER instead of + GC_register_finalizer, so that it would continue to work with GC_DEBUG. + - allochblk sometimes cleared the wrong block for debugging purposes + when it dropped blacklisted blocks. This could result in spurious + error reports with GC_DEBUG. + - added MACOS X Server support. (Thanks to Andrew Stone.) + - Changed the Solaris threads code to ignore stack limits > 8 MB with + a warning. Empirically, it is not safe to access arbitrary pages + in such large stacks. And the dirty bit implementation does not + guarantee that none of them will be accessed. + - Integrated Martin Tauchmann's Amiga changes. + - Integrated James Dominy's OpenBSD/SPARC port. + +Since 5.0alpha1 + - Fixed bugs introduced in alpha1 (OpenBSD & large block initialization). + - Added -DKEEP_BACK_PTRS and backptr.h interface. (The implementation + idea came from Al Demers.) + +Since 5.0alpha2 + - Added some highly incomplete code to support a copied young generation. + Comments on nursery.h are appreciated. + - Changed -DFIND_LEAK, -DJAVA_FINALIZATION, and -DFINALIZE_ON_DEMAND, + so the same effect could be obtained with a runtime switch. This is + a step towards standardizing on a single dynamic GC library. + - Significantly changed the way leak detection is handled, as a consequence + of the above. + +To do: + - Very large root set sizes (> 16 MB or so) could cause the collector + to abort with an unexpected mark stack overflow. (Thanks again to + Peter Chubb.) NOT YET FIXED. Workaround is to increase the initial + size. + - The SGI version of the collector marks from mmapped pages, even + if they are not part of dynamic library static data areas. This + causes performance problems with some SGI libraries that use mmap + as a bitmap allocator. NOT YET FIXED. It may be possible to turn + off DYNAMIC_LOADING in the collector as a workaround. It may also + be possible to conditionally intercept mmap and use GC_exclude_static_roots. + The real fix is to walk rld data structures, which looks possible. + - Integrate MIT and DEC pthreads ports. + - Deal with very uneven black-listing distributions. If all the black listed + blocks reside in the newly allocated heap section, the heuristic for + temporarily ignoring black-listing fails, and the heap grows too much. + (This was observed in only one case, and could be worked around, but ...) + - Some platform specific updates are waiting for 4.15alpha1. diff --git a/support/gc/README.Mac b/support/gc/README.Mac new file mode 100644 index 00000000..04f46825 --- /dev/null +++ b/support/gc/README.Mac @@ -0,0 +1,385 @@ +Patrick Beard's Notes for building GC v4.12 with CodeWarrior Pro 2: +---------------------------------------------------------------------------- +The current build environment for the collector is CodeWarrior Pro 2. +Projects for CodeWarrior Pro 2 (and for quite a few older versions) +are distributed in the file Mac_projects.sit.hqx. The project file +:Mac_projects:gc.prj builds static library versions of the collector. +:Mac_projects:gctest.prj builds the GC test suite. + +Configuring the collector is still done by editing the files +:Mac_files:MacOS_config.h and :Mac_files:MacOS_Test_config.h. + +Lars Farm's suggestions on building the collector: +---------------------------------------------------------------------------- +Garbage Collection on MacOS - a manual 'MakeFile' +------------------------------------------------- + +Project files and IDE's are great on the Macintosh, but they do have +problems when used as distribution media. This note tries to provide +porting instructions in pure TEXT form to avoid those problems. A manual +'makefile' if you like. + + GC version: 4.12a2 + Codewarrior: CWPro1 + date: 18 July 1997 + +The notes may or may not apply to earlier or later versions of the +GC/CWPro. Actually, they do apply to earlier versions of both except that +until recently a project could only build one target so each target was a +separate project. The notes will most likely apply to future versions too. +Possibly with minor tweaks. + +This is just to record my experiences. These notes do not mean I now +provide a supported port of the GC to MacOS. It works for me. If it works +for you, great. If it doesn't, sorry, try again...;-) Still, if you find +errors, please let me know. + + mailto: lars.farm@ite.mh.se + + address: Lars Farm + Krönvägen 33b + 856 44 Sundsvall + Sweden + +Porting to MacOS is a bit more complex than it first seems. Which MacOS? +68K/PowerPC? Which compiler? Each supports both 68K and PowerPC and offer a +large number of (unique to each environment) compiler settings. Each +combination of compiler/68K/PPC/settings require a unique combination of +standard libraries. And the IDE's does not select them for you. They don't +even check that the library is built with compatible setting and this is +the major source of problems when porting the GC (and otherwise too). + +You will have to make choices when you configure the GC. I've made some +choices here, but there are other combinations of settings and #defines +that work too. + +As for target settings the major obstacles may be: +- 68K Processor: check "4-byte Ints". +- PPC Processor: uncheck "Store Static Data in TOC". + +What you need to do: +=================== + +1) Build the GC as a library +2) Test that the library works with 'test.c'. +3) Test that the C++ interface 'gc_cpp.cc/h' works with 'test_cpp.cc'. + +1) The Libraries: +================= +I made one project with four targets (68K/PPC tempmem or appheap). One target +will suffice if you're able to decide which one you want. I wasn't... + +Codewarrior allows a large number of compiler/linker settings. I used these: + +Settings shared by all targets: +------------------------------ +o Access Paths: + - User Paths: the GC folder + - System Paths: {Compiler}:Metrowerks Standard Library: + {Compiler}:MacOS Support:Headers: + {Compiler}:MacOS Support:MacHeaders: +o C/C++ language: + - inlining: normal + - direct to SOM: off + - enable/check: exceptions, RTTI, bool (and if you like pool strings) + +PowerPC target settings +----------------------- +o Target Settings: + - name of target + - MacOS PPC Linker +o PPC Target + - name of library +o C/C++ language + - prefix file as described below +o PPC Processor + - Struct Alignment: PowerPC + - uncheck "Store Static Data in TOC" -- important! + I don't think the others matter, I use full optimization and its ok +o PPC Linker + - Factory Settings (SYM file with full paths, faster linking, dead-strip + static init, Main: __start) + + +68K target settings +------------------- +o Target Settings: + - name of target + - MacOS 68K Linker +o 68K Target + - name of library + - A5 relative data +o C/C++ language + - prefix file as described below +o 68K Processor + - Code model: smart + - Struct alignment: 68K + - FP: SANE + - enable 4-Byte Ints -- important! + I don't think the others matter. I selected... + - enable: 68020 + - enable: global register allocation +o IR Optimizer + - enable: Optimize Space, Optimize Speed + I suppose the others would work too, but haven't tried... +o 68K Linker + - Factory Settings (New Style MacsBug,SYM file with full paths, + A6 Frames, fast link, Merge compiler glue into segment 1, + dead-strip static init) + +Prefix Files to configure the GC sources +---------------------------------------- +The Codewarrior equivalent of commandline compilers -DNAME=X is to use +prefix-files. A TEXT file that is automatically #included before the first byte +of every source file. I used these: + +---- ( cut here ) ---- gc_prefix_tempmem.h -- 68K and PPC ----- + #include "gc_prefix_common.h" + #undef USE_TEMPORARY_MEMORY + #define USE_TEMPORARY_MEMORY +---- ( cut here ) ---- gc_prefix_appmem.h -- 68K and PPC ----- + #include "gc_prefix_common.h" + #undef USE_TEMPORARY_MEMORY +// #define USE_TEMPORARY_MEMORY + +---- ( cut here ) ---- gc_prefix_common.h -------------------- +// gc_prefix_common.h +// ------------------ +// Codewarrior prefix file to configure the GC libraries +// +// prefix files are the Codewarrior equivalent of the +// command line option -Dname=x frequently seen in makefiles + +#if !__MWERKS__ + #error only tried this with Codewarrior +#endif + +#if macintosh + #define MSL_USE_PRECOMPILED_HEADERS 0 + #include + #ifndef __STDC__ + #define __STDC__ 0 + #endif + + // See list of #defines to configure the library in: 'MakeFile' + // see also README + + #define SILENT // no collection messages. In case + // of trouble you might want this off + #define ALL_INTERIOR_POINTERS // follows interior pointers. +//#define DONT_ADD_BYTE_AT_END // disables the padding if defined. +//#define SMALL_CONFIG // whether to use a smaller heap. + #define NO_SIGNALS // signals aren't real on the Macintosh. + #define ATOMIC_UNCOLLECTABLE // GC_malloc_atomic_uncollectable() + + // define either or none as per personal preference + // used in malloc.c + #define REDIRECT_MALLOC GC_malloc +//#define REDIRECT_MALLOC GC_malloc_uncollectable + // if REDIRECT_MALLOC is #defined make sure that the GC library + // is listed before the ANSI/ISO libs in the Codewarrior + // 'Link order' panel +//#define IGNORE_FREE + + // mac specific configs +//#define USE_TEMPORARY_MEMORY // use Macintosh temporary memory. +//#define SHARED_LIBRARY_BUILD // build for use in a shared library. + +#else + // could build Win32 here too, or in the future + // Rhapsody PPC-mach, Rhapsody PPC-MacOS, + // Rhapsody Intel-mach, Rhapsody Intel-Win32,... + // ... ugh this will get messy ... +#endif + +// make sure ints are at least 32-bit +// ( could be set to 16-bit by compiler settings (68K) ) + +struct gc_private_assert_intsize_{ char x[ sizeof(int)>=4 ? 1 : 0 ]; }; + +#if __powerc + #if __option(toc_data) + #error turn off "store static data in TOC" when using GC + // ... or find a way to add TOC to the root set...(?) + #endif +#endif +---- ( cut here ) ---- end of gc_prefix_common.h ----------------- + +Files to build the GC libraries: +-------------------------------- + allchblk.c + alloc.c + blacklst.c + checksums.c + dbg_mlc.c + finalize.c + headers.c + mach_dep.c + MacOS.c -- contains MacOS code + malloc.c + mallocx.c + mark.c + mark_rts.c + misc.c + new_hblk.c + obj_map.c + os_dep.c -- contains MacOS code + ptr_chck.c + reclaim.c + stubborn.c + typd_mlc.c + gc++.cc -- this is 'gc_cpp.cc' with less 'inline' and + -- throw std::bad_alloc when out of memory + -- gc_cpp.cc works just fine too + +2) Test that the library works with 'test.c'. +============================================= + +The test app is just an ordinary ANSI-C console app. Make sure settings +match the library you're testing. + +Files +----- + test.c + the GC library to test -- link order before ANSI libs + suitable Mac+ANSI libraries + +prefix: +------ +---- ( cut here ) ---- gc_prefix_testlib.h -- all libs ----- +#define MSL_USE_PRECOMPILED_HEADERS 0 +#include +#undef NDEBUG + +#define ALL_INTERIOR_POINTERS /* for GC_priv.h */ +---- ( cut here ) ---- + +3) Test that the C++ interface 'gc_cpp.cc/h' works with 'test_cpp.cc'. + +The test app is just an ordinary ANSI-C console app. Make sure settings match +the library you're testing. + +Files +----- + test_cpp.cc + the GC library to test -- link order before ANSI libs + suitable Mac+ANSI libraries + +prefix: +------ +same as for test.c + +For convenience I used one test-project with several targets so that all +test apps are build at once. Two for each library to test: test.c and +gc_app.cc. When I was satisfied that the libraries were ok. I put the +libraries + gc.h + the c++ interface-file in a folder that I then put into +the MSL hierarchy so that I don't have to alter access-paths in projects +that use the GC. + +After that, just add the proper GC library to your project and the GC is in +action! malloc will call GC_malloc and free GC_free, new/delete too. You +don't have to call free or delete. You may have to be a bit cautious about +delete if you're freeing other resources than RAM. See gc_cpp.h. You can +also keep coding as always with delete/free. That works too. If you want, +"include and tweak it's use a bit. + +Symantec SPM +============ +It has been a while since I tried the GC in SPM, but I think that the above +instructions should be sufficient to guide you through in SPM too. SPM +needs to know where the global data is. Use the files 'datastart.c' and +'dataend.c'. Put 'datastart.c' at the top of your project and 'dataend.c' +at the bottom of your project so that all data is surrounded. This is not +needed in Codewarrior because it provides intrinsic variables +__datastart__, __data_end__ that wraps all globals. + +Source Changes (GC 4.12a2) +========================== +Very few. Just one tiny in the GC, not strictly needed. +- MacOS.c line 131 in routine GC_MacFreeTemporaryMemory() + change # if !defined(SHARED_LIBRARY_BUILD) + to # if !defined(SILENT) && !defined(SHARED_LIBRARY_BUILD) + To turn off a message when the application quits (actually, I faked + this change by #defining SHARED_LIBRARY_BUILD in a statically linked + library for more than a year without ill effects but perhaps this is + better). + +- test_cpp.cc + made the first lines of main() look like this: + ------------ + int main( int argc, char* argv[] ) { + #endif + #if macintosh // MacOS + char* argv_[] = {"test_cpp","10"}; // doesn't + argv=argv_; // have a + argc = sizeof(argv_)/sizeof(argv_[0]); // commandline + #endif // + + int i, iters, n; + # ifndef __GNUC__ + alloc dummy_to_fool_the_compiler_into_doing_things_it_currently_cant_handle; + ------------ + +- config.h [now gcconfig.h] + __MWERKS__ does not have to mean MACOS. You can use Codewarrior to + build a Win32 or BeOS library and soon a Rhapsody library. You may + have to change that #if... + + + + It worked for me, hope it works for you. + + Lars Farm + 18 July 1997 +---------------------------------------------------------------------------- + + +Patrick Beard's instructions (may be dated): + +v4.3 of the collector now runs under Symantec C++/THINK C v7.0.4, and +Metrowerks C/C++ v4.5 both 68K and PowerPC. Project files are provided +to build and test the collector under both development systems. + +Configuration +------------- + +To configure the collector, under both development systems, a prefix file +is used to set preprocessor directives. This file is called "MacOS_config.h". +Also to test the collector, "MacOS_Test_config.h" is provided. + +Testing +------- + +To test the collector (always a good idea), build one of the gctest projects, +gctest.¹ (Symantec C++/THINK C), mw/gctest.68K.¹, or mw/gctest.PPC.¹. The +test will ask you how many times to run; 1 should be sufficient. + +Building +-------- + +For your convenience project files for the major Macintosh development +systems are provided. + +For Symantec C++/THINK C, you must build the two projects gclib-1.¹ and +gclib-2.¹. It has to be split up because the collector has more than 32k +of static data and no library can have more than this in the Symantec +environment. (Future versions will probably fix this.) + +For Metrowerks C/C++ 4.5 you build gc.68K.¹/gc.PPC.¹ and the result will +be a library called gc.68K.lib/gc.PPC.lib. + +Using +----- + +Under Symantec C++/THINK C, you can just add the gclib-1.¹ and gclib-2.¹ +projects to your own project. Under Metrowerks, you add gc.68K.lib or +gc.PPC.lib and two additional files. You add the files called datastart.c +and dataend.c to your project, bracketing all files that use the collector. +See mw/gctest.¹ for an example. + +Include the projects/libraries you built above into your own project, +#include "gc.h", and call GC_malloc. You don't have to call GC_free. + + +Patrick C. Beard +January 4, 1995 diff --git a/support/gc/README.OS2 b/support/gc/README.OS2 new file mode 100644 index 00000000..5345bbd0 --- /dev/null +++ b/support/gc/README.OS2 @@ -0,0 +1,6 @@ +The code assumes static linking, and a single thread. The editor de has +not been ported. The cord test program has. The supplied OS2_MAKEFILE +assumes the IBM C Set/2 environment, but the code shouldn't. + +Since we haven't figured out hoe to do perform partial links or to build static +libraries, clients currently need to link against a long list of executables. diff --git a/support/gc/README.QUICK b/support/gc/README.QUICK new file mode 100644 index 00000000..3273c8ba --- /dev/null +++ b/support/gc/README.QUICK @@ -0,0 +1,41 @@ +Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers +Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + +Permission is hereby granted to use or copy this program +for any purpose, provided the above notices are retained on all copies. +Permission to modify the code and to distribute modified code is granted, +provided the above notices are retained, and a notice that the code was +modified is included with the above copyright notice. + + +For more details and the names of other contributors, see the +README file and gc.h. This file describes typical use of +the collector on a machine that is already supported. + +INSTALLATION: +Under UN*X, type "make test". Under OS/2 or Windows NT, copy the +appropriate makefile to MAKEFILE, read it, and type "nmake test". +Read the machine specific README if one exists. The only way to +develop code with the collector for Windows 3.1 is to develop under +Windows NT, and then to use win32S. + +If you wish to use the cord (structured string) library type +"make cords". (This requires an ANSI C compiler. You may need +to redefine CC in the Makefile.) + +If you wish to use the collector from C++, type +"make c++". These add further files to gc.a and to the include +subdirectory. See cord/cord.h and gc_c++.h. + +TYPICAL USE: +Include "gc.h" from this directory. Link against the appropriate library +("gc.a" under UN*X). Replace calls to malloc by calls to GC_MALLOC, +and calls to realloc by calls to GC_REALLOC. If the object is known +to never contain pointers, use GC_MALLOC_ATOMIC instead of +GC_MALLOC. + +Define GC_DEBUG before including gc.h for additional checking. + diff --git a/support/gc/README.alpha b/support/gc/README.alpha new file mode 100644 index 00000000..213a13e3 --- /dev/null +++ b/support/gc/README.alpha @@ -0,0 +1,22 @@ +Should work under OSF/1 and Linux. Currently no VMS or NT support, though +the latter shouldn't be hard. + +Incremental gc not yet supported under Linux because signal handler +for SIGSEGV can't get a hold of fault address. Dynamic library support +is also missing from Linux/alpha, probably for no good reason. + +Currently there is no thread support in the standard distribution. There +exists a separate port to DEC Unix pthreads. It should be possible to +port the X86 Linux threads support to Alpha without much trouble. + +If you get asssembler errors, be sure to read the first few lines of the +Makefile. + +From Philippe Queinnec: + +System: DEC/Alpha OSF1 v3.2, vendor cc +Problem: can't link if libgc has been compiled with "cc -std1". + It works if the library has been compiled with either gcc or "cc" + alone. The problem is because the variable "end" is not defined if + compiling in std1 mode (see man ld). +Proposed fix: none. Don't use cc -std1 ! diff --git a/support/gc/README.amiga b/support/gc/README.amiga new file mode 100644 index 00000000..47b15884 --- /dev/null +++ b/support/gc/README.amiga @@ -0,0 +1,180 @@ +=========================================================================== + Martin Tauchmann's notes (1-Apr-99) +=========================================================================== + +Works now, also with the GNU-C compiler V2.7.2.1. +Modify the `Makefile` +CC=cc $(ABI_FLAG) +to +CC=gcc $(ABI_FLAG) + +TECHNICAL NOTES + +- `GC_get_stack_base()`, `GC_register_data_segments()` works now with every + C compiler; also Workbench. + +- Removed AMIGA_SKIP_SEG, but the Code-Segment must not be scanned by GC. + + +PROBLEMS +- When the Linker, does`t merge all Code-Segments to an single one. LD of GCC + do it always. + +- With ixemul.library V47.3, when an GC program launched from another program + (example: `Make` or `if_mach M68K AMIGA gctest`), `GC_register_data_segments()` + found the Segment-List of the caller program. + Can be fixed, if the run-time initialization code (for C programs, usually *crt0*) + support `__data` and `__bss`. + +- PowerPC Amiga currently not supported. + +- Dynamic libraries (dyn_load.c) not supported. + + +TESTED WITH SOFTWARE + +`Optimized Oberon 2 C` (oo2c) + + +TESTED WITH HARDWARE + +MC68030 + + +CONTACT + +Please, contact me at , when you change the +Amiga port. + +=========================================================================== + Michel Schinz's notes +=========================================================================== +WHO DID WHAT + +The original Amiga port was made by Jesper Peterson. I (Michel Schinz) +modified it slightly to reflect the changes made in the new official +distributions, and to take advantage of the new SAS/C 6.x features. I also +created a makefile to compile the "cord" package (see the cord +subdirectory). + +TECHNICAL NOTES + +In addition to Jesper's notes, I have the following to say: + +- Starting with version 4.3, gctest checks to see if the code segment is + added to the root set or not, and complains if it is. Previous versions + of this Amiga port added the code segment to the root set, so I tried to + fix that. The only problem is that, as far as I know, it is impossible to + know which segments are code segments and which are data segments (there + are indeed solutions to this problem, like scanning the program on disk + or patch the LoadSeg functions, but they are rather complicated). The + solution I have chosen (see os_dep.c) is to test whether the program + counter is in the segment we are about to add to the root set, and if it + is, to skip the segment. The problems are that this solution is rather + awkward and that it works only for one code segment. This means that if + your program has more than one code segment, all of them but one will be + added to the root set. This isn't a big problem in fact, since the + collector will continue to work correctly, but it may be slower. + + Anyway, the code which decides whether to skip a segment or not can be + removed simply by not defining AMIGA_SKIP_SEG. But notice that if you do + so, gctest will complain (it will say that "GC_is_visible produced wrong + failure indication"). However, it may be useful if you happen to have + pointers stored in a code segment (you really shouldn't). + + If anyone has a good solution to the problem of finding, when a program + is loaded in memory, whether a segment is a code or a data segment, + please let me know. + +PROBLEMS + +If you have any problem with this version, please contact me at +schinz@alphanet.ch (but do *not* send long files, since we pay for +every mail!). + +=========================================================================== + Jesper Peterson's notes +=========================================================================== + +ADDITIONAL NOTES FOR AMIGA PORT + +These notes assume some familiarity with Amiga internals. + +WHY I PORTED TO THE AMIGA + +The sole reason why I made this port was as a first step in getting +the Sather(*) language on the Amiga. A port of this language will +be done as soon as the Sather 1.0 sources are made available to me. +Given this motivation, the garbage collection (GC) port is rather +minimal. + +(*) For information on Sather read the comp.lang.sather newsgroup. + +LIMITATIONS + +This port assumes that the startup code linked with target programs +is that supplied with SAS/C versions 6.0 or later. This allows +assumptions to be made about where to find the stack base pointer +and data segments when programs are run from WorkBench, as opposed +to running from the CLI. The compiler dependent code is all in the +GC_get_stack_base() and GC_register_data_segments() functions, but +may spread as I add Amiga specific features. + +Given that SAS/C was assumed, the port is set up to be built with +"smake" using the "SMakefile". Compiler options in "SCoptions" can +be set with "scopts" program. Both "smake" and "scopts" are part of +the SAS/C commercial development system. + +In keeping with the porting philosophy outlined above, this port +will not behave well with Amiga specific code. Especially not inter- +process comms via messages, and setting up public structures like +Intuition objects or anything else in the system lists. For the +time being the use of this library is limited to single threaded +ANSI/POSIX compliant or near-complient code. (ie. Stick to stdio +for now). Given this limitation there is currently no mechanism for +allocating "CHIP" or "PUBLIC" memory under the garbage collector. +I'll add this after giving it considerable thought. The major +problem is the entire physical address space may have to me scanned, +since there is no telling who we may have passed memory to. + +If you allocate your own stack in client code, you will have to +assign the pointer plus stack size to GC_stackbottom. + +The initial stack size of the target program can be compiled in by +setting the __stack symbol (see SAS documentaion). It can be over- +ridden from the CLI by running the AmigaDOS "stack" program, or from +the WorkBench by setting the stack size in the tool types window. + +SAS/C COMPILER OPTIONS (SCoptions) + +You may wish to check the "CPU" code option is appropriate for your +intended target system. + +Under no circumstances set the "StackExtend" code option in either +compiling the library or *ANY* client code. + +All benign compiler warnings have been suppressed. These mainly +involve lack of prototypes in the code, and dead assignments +detected by the optimizer. + +THE GOOD NEWS + +The library as it stands is compatible with the GigaMem commercial +virtual memory software, and probably similar PD software. + +The performance of "gctest" on an Amiga 2630 (68030 @ 25Mhz) +compares favourably with an HP9000 with similar architecture (a 325 +with a 68030 I think). + +----------------------------------------------------------------------- + +The Amiga port has been brought to you by: + +Jesper Peterson. + +jep@mtiame.mtia.oz.au (preferred, but 1 week turnaround) +jep@orca1.vic.design.telecom.au (that's orca, 1 day turnaround) + +At least one of these addresses should be around for a while, even +though I don't work for either of the companies involved. + diff --git a/support/gc/README.debugging b/support/gc/README.debugging new file mode 100644 index 00000000..80635c22 --- /dev/null +++ b/support/gc/README.debugging @@ -0,0 +1,58 @@ +Debugging suggestions: + +****If you get a segmentation fault or bus error while debugging with a debugger: +If the fault occurred in GC_find_limit, or with incremental collection enabled, this is probably normal. The collector installs handlers to take care of these. You will not see these unless you are using a debugger. Your debugger should allow you to continue. It's preferable to tell the debugger to ignore SIGBUS and SIGSEGV ("handle" in gdb, "ignore" in most versions of dbx) and set a breakpoint in abort. The collector will call abort if the signal had another cause, and there was not other handler previously installed. I recommend debugging without incremental collection if possible. (This applies directly to UNIX systems. Debugging with incremental collection under win32 is worse. See README.win32.) + +****If you get warning messages informing you that the collector needed to allocate blacklisted blocks: + +0) Ignore these warnings while you are using GC_DEBUG. Some of the routines mentioned below don't have debugging equivalents. (Alternatively, write the missing routines and send them to me.) + +1) Replace allocator calls that request large blocks with calls to GC_malloc_ignore_off_page or GC_malloc_atomic_ignore_off_page. You may want to set a breakpoint in GC_default_warn_proc to help you identify such calls. Make sure that a pointer to somewhere near the beginning of the resulting block is maintained in a (preferably volatile) variable as long as the block is needed. + +2) If the large blocks are allocated with realloc, I suggest instead allocating them with something like the following. Note that the realloc size increment should be fairly large (e.g. a factor of 3/2) for this to exhibit reasonable performance. But we all know we should do that anyway. + +void * big_realloc(void *p, size_t new_size) +{ + size_t old_size = GC_size(p); + void * result; + + if (new_size <= 10000) return(GC_realloc(p, new_size)); + if (new_size <= old_size) return(p); + result = GC_malloc_ignore_off_page(new_size); + if (result == 0) return(0); + memcpy(result,p,old_size); + GC_free(p); + return(result); +} + +3) In the unlikely case that even relatively small object (<20KB) allocations are triggering these warnings, then your address space contains lots of "bogus pointers", i.e. values that appear to be pointers but aren't. Usually this can be solved by using GC_malloc_atomic or the routines in gc_typed.h to allocate large pointerfree regions of bitmaps, etc. Sometimes the problem can be solved with trivial changes of encoding in certain values. It is possible, though not pleasant, to identify the source of the bogus pointers by setting a breakpoint in GC_add_to_black_list_stack, and looking at the value of current_p in the GC_mark_from_mark_stack frame. Current_p contains the address of the bogus pointer. + +4) If you get only a fixed number of these warnings, you are probably only introducing a bounded leak by ignoring them. If the data structures being allocated are intended to be permanent, then it is also safe to ignore them. The warnings can be turned off by calling GC_set_warn_proc with a procedure that ignores these warnings (e.g. by doing absolutely nothing). + + +****If the collector dies in GC_malloc while trying to remove a free list element: + +1) With > 99% probability, you wrote past the end of an allocated object. Try setting GC_DEBUG and using the debugging facilities in gc.h. + + +****If the heap grows too much: + +1) Consider using GC_malloc_atomic for objects containing nonpointers. This is especially important for large arrays containg compressed data, pseudo-random numbers, and the like. (This isn't all that likely to solve your problem, but it's a useful and easy optimization anyway, and this is a good time to try it.) If you allocate large objects containg only one or two pointers at the beginning, either try the typed allocation primitives is gc.h, or separate out the pointerfree component. +2) If you are using the collector in its default mode, with interior pointer recognition enabled, consider using GC_malloc_ignore_off_page to allocate large objects. (See gc.h and above for details. Large means > 100K in most environments.) +3) GC_print_block_list() will print a list of all currently allocated heap blocks and what size objects they contain. GC_print_hblkfreelist() will print a list of free heap blocks, and whether they are blacklisted. GC_dump calls both of these, and also prints information about heap sections, and root segments. +4) Write a tool that traces back references to the appropriate root. Send me the code. (I have code that does this for old PCR.) + + +****If the collector appears to be losing objects: + +1) Replace all calls to GC_malloc_atomic and typed allocation by GC_malloc calls. If this fixes the problem, gradually reinsert your optimizations. +2) You may also want to try the safe(r) pointer manipulation primitives in gc.h. But those are hard to use until the preprocessor becomes available. +3) Try using the GC_DEBUG facilities. This is less likely to be successful here than if the collector crashes. +[The rest of these are primarily for wizards. You shouldn't need them unless you're doing something really strange, or debugging a collector port.] +4) Don't turn on incremental collection. If that fixes the problem, suspect a bug in the dirty bit implementation. Try compiling with -DCHECKSUMS to check for modified, but supposedly clean, pages. +5) On a SPARC, in a single-threaded environment, GC_print_callers(GC_arrays._last_stack) prints a cryptic stack trace as of the time of the last collection. (You will need a debugger to decipher the result.) The question to ask then is "why should this object have been accessible at the time of the last collection? Where was a pointer to it stored?". This facility should be easy to add for some other collector ports (namely if it's easy to traverse stack frames), but will be hard for others. +6) "print *GC_find_header(p)" in dbx or gdb will print the garbage collector block header information associated with the object p (e.g. object size, etc.) +7) GC_is_marked(p) determines whether p is the base address of a marked object. Note that objects allocated since the last collection should not be marked, and that unmarked objects are reclaimed incrementally. It's usually most interesting to set a breakpoint in GC_finish_collection and then to determine how much of the damaged data structure is marked at that point. +8) Look at the tracing facility in mark.c. (Ignore this suggestion unless you are very familiar with collector internals.) + + diff --git a/support/gc/README.dj b/support/gc/README.dj new file mode 100644 index 00000000..613bc423 --- /dev/null +++ b/support/gc/README.dj @@ -0,0 +1,12 @@ +[Original version supplied by Xiaokun Zhu ] +[This version came mostly from Gary Leavens. ] + +Look first at Makefile.dj, and possibly change the definitions of +RM and MV if you don't have rm and mv installed. +Then use Makefile.dj to compile the garbage collector. +For example, you can do: + + make -f Makefile.dj test + +All the tests should work fine. + diff --git a/support/gc/README.hp b/support/gc/README.hp new file mode 100644 index 00000000..b290590d --- /dev/null +++ b/support/gc/README.hp @@ -0,0 +1,11 @@ +Dynamic loading support requires that executables be linked with -ldld. +The alternative is to build the collector without defining DYNAMIC_LOADING +in gcconfig.h and ensuring that all garbage collectable objects are +accessible without considering statically allocated variables in dynamic +libraries. + +The collector should compile with either plain cc or cc -Ae. CC -Aa +fails to define _HPUX_SOURCE and thus will not configure the collector +correctly. + +There is currently no thread support. diff --git a/support/gc/README.linux b/support/gc/README.linux new file mode 100644 index 00000000..b4f136af --- /dev/null +++ b/support/gc/README.linux @@ -0,0 +1,50 @@ +See README.alpha for Linux on DEC AXP info. + +This file applies mostly to Linux/Intel IA32. Ports to Linux on an M68K +and PowerPC are also integrated. They should behave similarly, except that +the PowerPC port lacks incremental GC support, and it is unknown to what +extent the Linux threads code is functional. + +Incremental GC is supported on Intel IA32 and M68K. + +Dynamic libraries are supported on an ELF system. A static executable +should be linked with the gcc option "-Wl,-defsym,_DYNAMIC=0". + +The collector appears to work with Linux threads. We have seen +intermittent hangs in sem_wait. So far we have been unable to reproduce +these unless the process was being debugged or traced. Thus it's +possible that the only real issue is that the debugger loses +signals on rare occasions. + +The garbage collector uses SIGPWR and SIGXCPU if it is used with +Linux threads. These should not be touched by the client program. + +To use threads, you need to abide by the following requirements: + +1) You need to use LinuxThreads (which are included in libc6). + + The collector relies on some implementation details of the LinuxThreads + package. It is unlikely that this code will work on other + pthread implementations (in particular it will *not* work with + MIT pthreads). + +2) You must compile the collector with -DLINUX_THREADS and -D_REENTRANT + specified in the Makefile. + +3) Every file that makes thread calls should define LINUX_THREADS and + _REENTRANT and then include gc.h. Gc.h redefines some of the + pthread primitives as macros which also provide the collector with + information it requires. + +4) Currently dlopen() is probably not safe. The collector must traverse + the list of libraries maintained by the runtime loader. That can + probably be an inconsistent state when a thread calling the loader is + is stopped for GC. (It's possible that this is fixable in the + same way it is handled for SOLARIS_THREADS, with GC_dlopen.) + +5) The combination of LINUX_THREADS, REDIRECT_MALLOC, and incremental + collection fails in seemingly random places. This hasn't been tracked + down yet, but is perhaps not completely astonishing. The thread package + uses malloc, and thus can presumably get SIGSEGVs while inside the + package. There is no real guarantee that signals are handled properly + at that point. diff --git a/support/gc/README.rs6000 b/support/gc/README.rs6000 new file mode 100644 index 00000000..f5630b20 --- /dev/null +++ b/support/gc/README.rs6000 @@ -0,0 +1,9 @@ +We have so far failed to find a good way to determine the stack base. +It is highly recommended that GC_stackbottom be set explicitly on program +startup. The supplied value sometimes causes failure under AIX 4.1, though +it appears to work under 3.X. HEURISTIC2 seems to work under 4.1, but +involves a substantial performance penalty, and will fail if there is +no limit on stack size. + +There is no thread support. (I assume recent versions of AIX provide +pthreads? I no longer have access to a machine ...) diff --git a/support/gc/README.sgi b/support/gc/README.sgi new file mode 100644 index 00000000..e67124b5 --- /dev/null +++ b/support/gc/README.sgi @@ -0,0 +1,41 @@ +Performance of the incremental collector can be greatly enhanced with +-DNO_EXECUTE_PERMISSION. + +The collector should run with all of the -32, -n32 and -64 ABIs. Remember to +define the AS macro in the Makefile to be "as -64", or "as -n32". + +If you use -DREDIRECT_MALLOC=GC_malloc with C++ code, your code should make +at least one explicit call to malloc instead of new to ensure that the proper +version of malloc is linked in. + +Sproc threads are not supported in this version, though there may exist other +ports. + +Pthreads support is provided. This requires that: + +1) You compile the collector with -DIRIX_THREADS specified in the Makefile. + +2) You have the latest pthreads patches installed. + +(Though the collector makes only documented pthread calls, +it relies on signal/threads interactions working just right in ways +that are not required by the standard. It is unlikely that this code +will run on other pthreads platforms. But please tell me if it does.) + +3) Every file that makes thread calls should define IRIX_THREADS and then +include gc.h. Gc.h redefines some of the pthread primitives as macros which +also provide the collector with information it requires. + +4) pthread_cond_wait and pthread_cond_timed_wait should be prepared for +premature wakeups. (I believe the pthreads and realted standards require this +anyway. Irix pthreads often terminate a wait if a signal arrives. +The garbage collector uses signals to stop threads.) + +5) It is expensive to stop a thread waiting in IO at the time the request is +initiated. Applications with many such threads may not exhibit acceptable +performance with the collector. (Increasing the heap size may help.) + +6) The collector should not be compiled with -DREDIRECT_MALLOC. This +confuses some library calls made by the pthreads implementation, which +expect the standard malloc. + diff --git a/support/gc/README.solaris2 b/support/gc/README.solaris2 new file mode 100644 index 00000000..e5935131 --- /dev/null +++ b/support/gc/README.solaris2 @@ -0,0 +1,65 @@ +The collector supports both incremental collection and threads under +Solaris 2. The incremental collector normally retrieves page dirty information +through the appropriate /proc calls. But it can also be configured +(by defining MPROTECT_VDB instead of PROC_VDB in gcconfig.h) to use mprotect +and signals. This may result in shorter pause times, but it is no longer +safe to issue arbitrary system calls that write to the heap. + +Under other UNIX versions, +the collector normally obtains memory through sbrk. There is some reason +to expect that this is not safe if the client program also calls the system +malloc, or especially realloc. The sbrk man page strongly suggests this is +not safe: "Many library routines use malloc() internally, so use brk() +and sbrk() only when you know that malloc() definitely will not be used by +any library routine." This doesn't make a lot of sense to me, since there +seems to be no documentation as to which routines can transitively call malloc. +Nonetheless, under Solaris2, the collector now (since 4.12) allocates +memory using mmap by default. (It defines USE_MMAP in gcconfig.h.) +You may want to reverse this decisions if you use -DREDIRECT_MALLOC=... + + +SOLARIS THREADS: + +The collector must be compiled with -DSOLARIS_THREADS to be thread safe. +It is also essential that gc.h be included in files that call thr_create, +thr_join, thr_suspend, thr_continue, or dlopen. Gc.h macro defines +these to also do GC bookkeeping, etc. Gc.h must be included with +SOLARIS_THREADS defined, otherwise these replacements are not visible. +A collector built in this way way only be used by programs that are +linked with the threads library. + +If you are using the Pthreads interface, also define _SOLARIS_PTHREADS. + +In this mode, the collector contains various workarounds for older Solaris +bugs. Mostly, these should not be noticeable unless you look at system +call traces. However, it cannot protect a guard page at the end of +a thread stack. If you know that you will only be running Solaris2.5 +or later, it should be possible to fix this by compiling the collector +with -DSOLARIS23_MPROTECT_BUG_FIXED. + +Jeremy Fitzhardinge points out that there is a problem with the dlopen +replacement, in that startup code in the library is run while the allocation +lock is held. This appears to be difficult to fix, since the collector does +look at data structures maintained by dlopen, and hence some locking is needed +around the dlopen call. Defining USE_PROC_FOR_LIBRARIES will get address +space layout information from /proc avoiding the dlopen lock. But this has +other disadvanatages, e.g. mmapped files may be scanned. + +If solaris_threads are used on an X86 processor with malloc redirected to +GC_malloc, it is necessary to call GC_thr_init explicitly before forking the +first thread. (This avoids a deadlock arising from calling GC_thr_init +with the allocation lock held.) + +It appears that there is a problem in using gc_cpp.h in conjunction with +Solaris threads and Sun's C++ runtime. Apparently the overloaded new operator +is invoked by some iostream initialization code before threads are correctly +initialized. As a result, call to thr_self() in garbage collector +initialization segfaults. Currently the only known workaround is to not +invoke the garbage collector from a user defined global operator new, or to +have it invoke the garbage-collector's allocators only after main has started. +(Note that the latter requires a moderately expensive test in operator +delete.) + +Hans-J. Boehm +(The above contains my personal opinions, which are probably not shared +by anyone else.) diff --git a/support/gc/README.uts b/support/gc/README.uts new file mode 100644 index 00000000..6be49667 --- /dev/null +++ b/support/gc/README.uts @@ -0,0 +1,2 @@ +Alistair Crooks supplied the port. He used Lexa C version 2.1.3 with +-Xa to compile. diff --git a/support/gc/README.win32 b/support/gc/README.win32 new file mode 100644 index 00000000..d78816b5 --- /dev/null +++ b/support/gc/README.win32 @@ -0,0 +1,149 @@ +The collector has only been compiled under Windows NT, with the +original Microsoft SDK, with Visual C++ 2.0 and later, with +the GNU win32 environment, with Borland 4.5, and recently with +Watcom C. + +It runs under both win32s and win32, but with different semantics. +Under win32, all writable pages outside of the heaps and stack are +scanned for roots. Thus the collector sees pointers in DLL data +segments. Under win32s, only the main data segment is scanned. +(The main data segment should always be scanned. Under some +versions of win32s, other regions may also be scanned.) +Thus all accessible objects should be accessible from local variables +or variables in the main data segment. Alternatively, other data +segments (e.g. in DLLs) may be registered with the collector by +calling GC_init() and then GC_register_root_section(a), where +a is the address of some variable inside the data segment. (Duplicate +registrations are ignored, but not terribly quickly.) + +(There are two reasons for this. We didn't want to see many 16:16 +pointers. And the VirtualQuery call has different semantics under +the two systems, and under different versions of win32s.) + +The collector test program "gctest" is linked as a GUI application, +but does not open any windows. Its output appears in the file +"gc.log". It may be started from the file manager. The hour glass +cursor will appear as long as it's running. If it is started from the +command line, it will usually run in the background. Wait a few +minutes (a few seconds on a modern machine) before you check the output. +You should see either a failure indication or a "Collector appears to +work" message. + +The cord test program has not been ported (but should port +easily). A toy editor (cord/de.exe) based on cords (heavyweight +strings represented as trees) has been ported and is included. +It runs fine under either win32 or win32S. It serves as an example +of a true Windows application, except that it was written by a +nonexpert Windows programmer. (There are some peculiarities +in the way files are displayed. The is displayed explicitly +for standard DOS text files. As in the UNIX version, control +characters are displayed explicitly, but in this case as red text. +This may be suboptimal for some tastes and/or sets of default +window colors.) + +For Microsoft development tools, rename NT_MAKEFILE as +MAKEFILE. (Make sure that the CPU environment variable is defined +to be i386.) + +For GNU-win32, use the regular makefile, possibly after uncommenting +the line "include Makefile.DLLs". The latter should be necessary only +if you want to package the collector as a DLL. The GNU-win32 port is +believed to work only for b18, not b19, probably dues to linker changes +in b19. This is probably fixable with a different definition of +DATASTART and DATAEND in gcconfig.h. + +For Borland tools, use BCC_MAKEFILE. Note that +Borland's compiler defaults to 1 byte alignment in structures (-a1), +whereas Visual C++ appears to default to 8 byte alignment (/Zp8). +The garbage collector in its default configuration EXPECTS AT +LEAST 4 BYTE ALIGNMENT. Thus the BORLAND DEFAULT MUST +BE OVERRIDDEN. (In my opinion, it should usually be anyway. +I expect that -a1 introduces major performance penalties on a +486 or Pentium.) Note that this changes structure layouts. (As a last +resort, gcconfig.h can be changed to allow 1 byte alignment. But +this has significant negative performance implications.) +The Makefile is set up to assume Borland 4.5. If you have another +version, change the line near the top. By default, it does not +require the assembler. If you do have the assembler, I recommend +removing the -DUSE_GENERIC. + +Incremental collection support was recently added. This is +currently pretty simpleminded. Pages are protected. Protection +faults are caught by a handler installed at the bottom of the handler +stack. This is both slow and interacts poorly with a debugger. +Whenever possible, I recommend adding a call to +GC_enable_incremental at the last possible moment, after most +debugging is complete. Unlike the UNIX versions, no system +calls are wrapped by the collector itself. It may be necessary +to wrap ReadFile calls that use a buffer in the heap, so that the +call does not encounter a protection fault while it's running. +(As usual, none of this is an issue unless GC_enable_incremental +is called.) + +Note that incremental collection is disabled with -DSMALL_CONFIG, +which is the default for win32. If you need incremental collection, +undefine SMALL_CONFIG. + +Incremental collection is not supported under win32s, and it may not +be possible to do so. However, win32 applications that attempt to use +incremental collection should continue to run, since the +collector detects if it's running under win32s and turns calls to +GC_enable_incremental() into noops. + +James Clark has contributed the necessary code to support win32 threads. +This code is known to exhibit some problems with incremental collection +enabled. Use NT_THREADS_MAKEFILE (a.k.a gc.mak) instead of NT_MAKEFILE +to build this version. Note that this requires some files whose names +are more than 8 + 3 characters long. Thus you should unpack the tar file +so that long file names are preserved. To build the garbage collector +test with VC++ from the command line, use + +nmake /F ".\gc.mak" CFG="gctest - Win32 Release" + +This requires that the subdirectory gctest\Release exist. +The test program and DLL will reside in the Release directory. + +This version relies on the collector residing in a dll. + +This version currently supports incremental collection only if it is +enabled before any additional threads are created. +Version 4.13 attempts to fix some of the earlier problems, but there +may be other issues. If you need solid support for win32 threads, you +might check with Geodesic Systems. Their collector must be licensed, +but they have invested far more time in win32-specific issues. + +Hans + +Ivan V. Demakov's README for the Watcom port: + +The collector has been compiled with Watcom C 10.6 and 11.0. +It runs under win32, win32s, and even under msdos with dos4gw +dos-extender. It should also run under OS/2, though this isn't +tested. Under win32 the collector can be built either as dll +or as static library. + +Note that all compilations were done under Windows 95 or NT. +For unknown reason compiling under Windows 3.11 for NT (one +attempt has been made) leads to broken executables. + +Incremental collection is not supported. + +cord is not ported. + +Before compiling you may need to edit WCC_MAKEFILE to set target +platform, library type (dynamic or static), calling conventions, and +optimization options. + +To compile the collector and testing programs use the command: + wmake -f WCC_MAKEFILE + +All programs using gc should be compiled with 4-byte alignment. +For further explanations on this see comments about Borland. + +If gc compiled as dll, the macro ``GC_DLL'' should be defined before +including "gc.h" (for example, with -DGC_DLL compiler option). It's +important, otherwise resulting programs will not run. + +Ivan Demakov (email: ivan@tgrad.nsk.su) + + diff --git a/support/gc/SCoptions.amiga b/support/gc/SCoptions.amiga new file mode 100644 index 00000000..a61e0cb1 --- /dev/null +++ b/support/gc/SCoptions.amiga @@ -0,0 +1,16 @@ +CPU=68030 +NOSTACKCHECK +OPTIMIZE +VERBOSE +MAPHUNK +NOVERSION +NOICONS +OPTIMIZERTIME +DEFINE SILENT +DEFINE AMIGA_SKIP_SEG +IGNORE=85 +IGNORE=154 +IGNORE=161 +IGNORE=100 +OPTIMIZERCOMPLEXITY=4 +OPTIMIZERDEPTH=3 diff --git a/support/gc/SMakefile.amiga b/support/gc/SMakefile.amiga new file mode 100644 index 00000000..e9602c08 --- /dev/null +++ b/support/gc/SMakefile.amiga @@ -0,0 +1,48 @@ +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o real_malloc.o dyn_load.o dbg_mlc.o malloc.o stubborn.o checksums.o typd_mlc.o ptr_chck.o + +INC= gc_private.h gc_hdrs.h gc.h gcconfig.h + +all: gctest setjmp_t + +alloc.o : alloc.c $(INC) +reclaim.o : reclaim.c $(INC) +allchblk.o : allchblk.c $(INC) +misc.o : misc.c $(INC) +os_dep.o : os_dep.c $(INC) +mark_rts.o : mark_rts.c $(INC) +headers.o : headers.c $(INC) +mark.o : mark.c $(INC) +obj_map.o : obj_map.c $(INC) +blacklst.o : blacklst.c $(INC) +finalize.o : finalize.c $(INC) + sc noopt finalize.c # There seems to be a bug in the optimizer (V6.51). + # gctest won't work if you remove this... +new_hblk.o : new_hblk.c $(INC) +real_malloc.o : real_malloc.c $(INC) +dyn_load.o : dyn_load.c $(INC) +dbg_mlc.o : dbg_mlc.c $(INC) +malloc.o : malloc.c $(INC) +mallocx.o : malloc.c $(INC) +stubborn.o : stubborn.c $(INC) +checksums.o : checksums.c $(INC) +typd_mlc.o: typd_mlc.c $(INC) +mach_dep.o : mach_dep.c $(INC) +ptr_chck.o: ptr_chck.c $(INC) +test.o : test.c $(INC) + +gc.lib: $(OBJS) + oml gc.lib r $(OBJS) + +clean: + delete gc.lib gctest setjmp_t \#?.o + +gctest: gc.lib test.o + slink LIB:c.o test.o to $@ lib gc.lib LIB:sc.lib LIB:scm.lib + +setjmp_t: setjmp_t.c gc.h + sc setjmp_t.c + slink LIB:c.o $@.o to $@ lib LIB:sc.lib + +test: setjmp_t gctest + setjmp_t + gctest diff --git a/support/gc/WCC_MAKEFILE b/support/gc/WCC_MAKEFILE new file mode 100644 index 00000000..087ff6a3 --- /dev/null +++ b/support/gc/WCC_MAKEFILE @@ -0,0 +1,196 @@ +# Makefile for Watcom C/C++ 10.5, 10.6, 11.0 on NT, OS2 and DOS4GW. +# May work with Watcom 10.0. + +# Uncoment one of the lines below for cross compilation. +SYSTEM=MSWIN32 +#SYSTEM=DOS4GW +#SYSTEM=OS2 + +# The collector can be built either as dynamic or as static library. +# Select the library type you need. +#MAKE_AS_DLL=1 +MAKE_AS_LIB=1 + +# Select calling conventions. +# Possible choices are r and s. +CALLING=s + +# Select target CPU. +# Possible choices are 3, 4, 5, and 6. +# The last choice available only since version 11.0. +CPU=5 + +# Set optimization options. +# Watcom before 11.0 does not support option "-oh". +OPTIM=-oneatx -s +#OPTIM=-ohneatx -s + +DEFS=-DALL_INTERIOR_POINTERS -DSILENT -DNO_SIGNALS #-DSMALL_CONFIG #-DGC_DEBUG + + +##### + +!ifndef SYSTEM +!ifdef __MSDOS__ +SYSTEM=DOS4GW +!else ifdef __NT__ +SYSTEM=MSWIN32 +!else ifdef __OS2__ +SYSTEM=OS2 +!else +SYSTEM=Unknown +!endif +!endif + +!define $(SYSTEM) + +!ifdef DOS4GW +SYSFLAG=-DDOS4GW -bt=dos +!else ifdef MSWIN32 +SYSFLAG=-DMSWIN32 -bt=nt +!else ifdef OS2 +SYSFLAG=-DOS2 -bt=os2 +!else +!error undefined or unsupported target platform: $(SYSTEM) +!endif +!ifdef MAKE_AS_DLL +DLLFLAG=-bd -DGC_DLL +TEST_DLLFLAG=-DGC_DLL +!else ifdef MAKE_AS_LIB +DLLFLAG= +TEST_DLLFLAG= +!else +!error Either MAKE_AS_LIB or MAKE_AS_DLL should be defined +!endif + +CC=wcc386 +CXX=wpp386 + +# -DUSE_GENERIC is required ! +CFLAGS=-$(CPU)$(CALLING) $(OPTIM) -zp4 -zc $(SYSFLAG) $(DLLFLAG) -DGC_BUILD -DUSE_GENERIC $(DEFS) +CXXFLAGS= $(CFLAGS) +TEST_CFLAGS=-$(CPU)$(CALLING) $(OPTIM) -zp4 -zc $(SYSFLAG) $(TEST_DLLFLAG) $(DEFS) +TEST_CXXFLAGS= $(TEST_CFLAGS) + +OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj & + mach_dep.obj os_dep.obj mark_rts.obj headers.obj mark.obj & + obj_map.obj blacklst.obj finalize.obj new_hblk.obj & + dbg_mlc.obj malloc.obj stubborn.obj dyn_load.obj & + typd_mlc.obj ptr_chck.obj mallocx.obj + +all: gc.lib gctest.exe test_cpp.exe + +!ifdef MAKE_AS_DLL + +gc.lib: gc.dll gc_cpp.obj + *wlib -b -c -n -p=512 $@ +gc.dll +gc_cpp.obj + +gc.dll: $(OBJS) .AUTODEPEND + @%create $*.lnk +!ifdef DOS4GW + @%append $*.lnk sys os2v2_dll +!else ifdef MSWIN32 + @%append $*.lnk sys nt_dll +!else ifdef OS2 + @%append $*.lnk sys os2v2_dll +!endif + @%append $*.lnk name $* + @for %i in ($(OBJS)) do @%append $*.lnk file '%i' +!ifeq CALLING s + @%append $*.lnk export GC_is_marked + @%append $*.lnk export GC_incr_words_allocd + @%append $*.lnk export GC_incr_mem_freed + @%append $*.lnk export GC_generic_malloc_words_small +!else + @%append $*.lnk export GC_is_marked_ + @%append $*.lnk export GC_incr_words_allocd_ + @%append $*.lnk export GC_incr_mem_freed_ + @%append $*.lnk export GC_generic_malloc_words_small_ +!endif + *wlink @$*.lnk +!else +gc.lib: $(OBJS) gc_cpp.obj + @%create $*.lb1 + @for %i in ($(OBJS)) do @%append $*.lb1 +'%i' + @%append $*.lb1 +'gc_cpp.obj' + *wlib -b -c -n -p=512 $@ @$*.lb1 + +!endif + + +gctest.exe: test.obj gc.lib + %create $*.lnk +!ifdef DOS4GW + @%append $*.lnk sys dos4g +!else ifdef MSWIN32 + @%append $*.lnk sys nt +!else ifdef OS2 + @%append $*.lnk sys os2v2 +!endif + @%append $*.lnk op case + @%append $*.lnk op stack=256K + @%append $*.lnk name $* + @%append $*.lnk file test.obj + @%append $*.lnk library gc.lib +!ifdef MAKE_AS_DLL +!ifeq CALLING s + @%append $*.lnk import GC_is_marked gc +!else + @%append $*.lnk import GC_is_marked_ gc +!endif +!endif + *wlink @$*.lnk +test_cpp.exe: test_cpp.obj gc.lib + %create $*.lnk +!ifdef DOS4GW + @%append $*.lnk sys dos4g +!else ifdef MSWIN32 + @%append $*.lnk sys nt +!else ifdef OS2 + @%append $*.lnk sys os2v2 +!endif + @%append $*.lnk op case + @%append $*.lnk op stack=256K + @%append $*.lnk name $* + @%append $*.lnk file test_cpp.obj + @%append $*.lnk library gc.lib +!ifdef MAKE_AS_DLL +!ifeq CALLING s + @%append $*.lnk import GC_incr_words_allocd gc + @%append $*.lnk import GC_incr_mem_freed gc + @%append $*.lnk import GC_generic_malloc_words_small gc +!else + @%append $*.lnk import GC_incr_words_allocd_ gc + @%append $*.lnk import GC_incr_mem_freed_ gc + @%append $*.lnk import GC_generic_malloc_words_small_ gc +!endif +!endif + *wlink @$*.lnk + +gc_cpp.obj: gc_cpp.cc .AUTODEPEND + $(CXX) $(TEST_CXXFLAGS) -iinclude $*.cc +test.obj: test.c .AUTODEPEND + $(CC) $(TEST_CFLAGS) $*.c +test_cpp.obj: test_cpp.cc .AUTODEPEND + $(CXX) $(TEST_CXXFLAGS) -iinclude $*.cc + + +.c.obj: .AUTODEPEND + $(CC) $(CFLAGS) $*.c + +.cc.obj: .AUTODEPEND + $(CXX) $(CXXFLAGS) $*.cc + +clean : .SYMBOLIC + @if exist *.obj del *.obj + @if exist *.map del *.map + @if exist *.lnk del *.lnk + @if exist *.lb1 del *.lb1 + @if exist *.sym del *.sym + @if exist *.err del *.err + @if exist *.tmp del *.tmp + @if exist *.lst del *.lst + @if exist *.exe del *.exe + @if exist *.log del *.log + @if exist *.lib del *.lib + @if exist *.dll del *.dll diff --git a/support/gc/add_gc_prefix.c b/support/gc/add_gc_prefix.c new file mode 100644 index 00000000..0d1ab6d4 --- /dev/null +++ b/support/gc/add_gc_prefix.c @@ -0,0 +1,14 @@ +# include + +int main(argc, argv, envp) +int argc; +char ** argv; +char ** envp; +{ + int i; + + for (i = 1; i < argc; i++) { + printf("gc/%s ", argv[i]); + } + return(0); +} diff --git a/support/gc/allchblk.c b/support/gc/allchblk.c new file mode 100644 index 00000000..d8d0afdf --- /dev/null +++ b/support/gc/allchblk.c @@ -0,0 +1,726 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1998-1999 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#define DEBUG +#undef DEBUG +#include +#include "gc_priv.h" + + +/* + * Free heap blocks are kept on one of several free lists, + * depending on the size of the block. Each free list is doubly linked. + * Adjacent free blocks are coalesced. + */ + + +# define MAX_BLACK_LIST_ALLOC (2*HBLKSIZE) + /* largest block we will allocate starting on a black */ + /* listed block. Must be >= HBLKSIZE. */ + + +# define UNIQUE_THRESHOLD 32 + /* Sizes up to this many HBLKs each have their own free list */ +# define HUGE_THRESHOLD 256 + /* Sizes of at least this many heap blocks are mapped to a */ + /* single free list. */ +# define FL_COMPRESSION 8 + /* In between sizes map this many distinct sizes to a single */ + /* bin. */ + +# define N_HBLK_FLS (HUGE_THRESHOLD - UNIQUE_THRESHOLD)/FL_COMPRESSION \ + + UNIQUE_THRESHOLD + +struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 }; + +/* Map a number of blocks to the appropriate large block free list index. */ +int GC_hblk_fl_from_blocks(blocks_needed) +word blocks_needed; +{ + if (blocks_needed <= UNIQUE_THRESHOLD) return blocks_needed; + if (blocks_needed >= HUGE_THRESHOLD) return N_HBLK_FLS; + return (blocks_needed - UNIQUE_THRESHOLD)/FL_COMPRESSION + + UNIQUE_THRESHOLD; + +} + +# define HBLK_IS_FREE(hdr) ((hdr) -> hb_map == GC_invalid_map) +# define PHDR(hhdr) HDR(hhdr -> hb_prev) +# define NHDR(hhdr) HDR(hhdr -> hb_next) + +# ifdef USE_MUNMAP +# define IS_MAPPED(hhdr) (((hhdr) -> hb_flags & WAS_UNMAPPED) == 0) +# else /* !USE_MMAP */ +# define IS_MAPPED(hhdr) 1 +# endif /* USE_MUNMAP */ + +# if !defined(NO_DEBUGGING) +void GC_print_hblkfreelist() +{ + struct hblk * h; + word total_free = 0; + hdr * hhdr; + word sz; + int i; + + for (i = 0; i <= N_HBLK_FLS; ++i) { + h = GC_hblkfreelist[i]; + if (0 != h) GC_printf1("Free list %ld:\n", (unsigned long)i); + while (h != 0) { + hhdr = HDR(h); + sz = hhdr -> hb_sz; + GC_printf2("\t0x%lx size %lu ", (unsigned long)h, (unsigned long)sz); + total_free += sz; + if (GC_is_black_listed(h, HBLKSIZE) != 0) { + GC_printf0("start black listed\n"); + } else if (GC_is_black_listed(h, hhdr -> hb_sz) != 0) { + GC_printf0("partially black listed\n"); + } else { + GC_printf0("not black listed\n"); + } + h = hhdr -> hb_next; + } + } + if (total_free != GC_large_free_bytes) { + GC_printf1("GC_large_free_bytes = %lu (INCONSISTENT!!)\n", + (unsigned long) GC_large_free_bytes); + } + GC_printf1("Total of %lu bytes on free list\n", (unsigned long)total_free); +} + +/* Return the free list index on which the block described by the header */ +/* appears, or -1 if it appears nowhere. */ +int free_list_index_of(wanted) +hdr * wanted; +{ + struct hblk * h; + hdr * hhdr; + int i; + + for (i = 0; i <= N_HBLK_FLS; ++i) { + h = GC_hblkfreelist[i]; + while (h != 0) { + hhdr = HDR(h); + if (hhdr == wanted) return i; + h = hhdr -> hb_next; + } + } + return -1; +} + +void GC_dump_regions() +{ + int i; + ptr_t start, end; + ptr_t p; + size_t bytes; + hdr *hhdr; + for (i = 0; i < GC_n_heap_sects; ++i) { + start = GC_heap_sects[i].hs_start; + bytes = GC_heap_sects[i].hs_bytes; + end = start + bytes; + /* Merge in contiguous sections. */ + while (i+1 < GC_n_heap_sects && GC_heap_sects[i+1].hs_start == end) { + ++i; + end = GC_heap_sects[i].hs_start + GC_heap_sects[i].hs_bytes; + } + GC_printf2("***Section from 0x%lx to 0x%lx\n", start, end); + for (p = start; p < end;) { + hhdr = HDR(p); + GC_printf1("\t0x%lx ", (unsigned long)p); + if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + GC_printf1("Missing header!!\n", hhdr); + p += HBLKSIZE; + continue; + } + if (HBLK_IS_FREE(hhdr)) { + int correct_index = GC_hblk_fl_from_blocks( + divHBLKSZ(hhdr -> hb_sz)); + int actual_index; + + GC_printf1("\tfree block of size 0x%lx bytes", + (unsigned long)(hhdr -> hb_sz)); + if (IS_MAPPED(hhdr)) { + GC_printf0("\n"); + } else { + GC_printf0("(unmapped)\n"); + } + actual_index = free_list_index_of(hhdr); + if (-1 == actual_index) { + GC_printf1("\t\tBlock not on free list %ld!!\n", + correct_index); + } else if (correct_index != actual_index) { + GC_printf2("\t\tBlock on list %ld, should be on %ld!!\n", + actual_index, correct_index); + } + p += hhdr -> hb_sz; + } else { + GC_printf1("\tused for blocks of size 0x%lx bytes\n", + (unsigned long)WORDS_TO_BYTES(hhdr -> hb_sz)); + p += HBLKSIZE * OBJ_SZ_TO_BLOCKS(hhdr -> hb_sz); + } + } + } +} + +# endif /* NO_DEBUGGING */ + +/* Initialize hdr for a block containing the indicated size and */ +/* kind of objects. */ +/* Return FALSE on failure. */ +static GC_bool setup_header(hhdr, sz, kind, flags) +register hdr * hhdr; +word sz; /* object size in words */ +int kind; +unsigned char flags; +{ + register word descr; + + /* Add description of valid object pointers */ + if (!GC_add_map_entry(sz)) return(FALSE); + hhdr -> hb_map = GC_obj_map[sz > MAXOBJSZ? 0 : sz]; + + /* Set size, kind and mark proc fields */ + hhdr -> hb_sz = sz; + hhdr -> hb_obj_kind = kind; + hhdr -> hb_flags = flags; + descr = GC_obj_kinds[kind].ok_descriptor; + if (GC_obj_kinds[kind].ok_relocate_descr) descr += WORDS_TO_BYTES(sz); + hhdr -> hb_descr = descr; + + /* Clear mark bits */ + GC_clear_hdr_marks(hhdr); + + hhdr -> hb_last_reclaimed = (unsigned short)GC_gc_no; + return(TRUE); +} + +#define FL_UNKNOWN -1 +/* + * Remove hhdr from the appropriate free list. + * We assume it is on the nth free list, or on the size + * appropriate free list if n is FL_UNKNOWN. + */ +void GC_remove_from_fl(hhdr, n) +hdr * hhdr; +int n; +{ + GC_ASSERT(((hhdr -> hb_sz) & (HBLKSIZE-1)) == 0); + if (hhdr -> hb_prev == 0) { + int index; + if (FL_UNKNOWN == n) { + index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz)); + } else { + index = n; + } + GC_ASSERT(HDR(GC_hblkfreelist[index]) == hhdr); + GC_hblkfreelist[index] = hhdr -> hb_next; + } else { + PHDR(hhdr) -> hb_next = hhdr -> hb_next; + } + if (0 != hhdr -> hb_next) { + GC_ASSERT(!IS_FORWARDING_ADDR_OR_NIL(NHDR(hhdr))); + NHDR(hhdr) -> hb_prev = hhdr -> hb_prev; + } +} + +/* + * Return a pointer to the free block ending just before h, if any. + */ +struct hblk * GC_free_block_ending_at(h) +struct hblk *h; +{ + struct hblk * p = h - 1; + hdr * phdr = HDR(p); + + while (0 != phdr && IS_FORWARDING_ADDR_OR_NIL(phdr)) { + p = FORWARDED_ADDR(p,phdr); + phdr = HDR(p); + } + if (0 != phdr && HBLK_IS_FREE(phdr)) return p; + p = GC_prev_block(h - 1); + if (0 != p) { + phdr = HDR(p); + if (HBLK_IS_FREE(phdr) && (ptr_t)p + phdr -> hb_sz == (ptr_t)h) { + return p; + } + } + return 0; +} + +/* + * Add hhdr to the appropriate free list. + * We maintain individual free lists sorted by address. + */ +void GC_add_to_fl(h, hhdr) +struct hblk *h; +hdr * hhdr; +{ + int index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz)); + struct hblk *second = GC_hblkfreelist[index]; +# ifdef GC_ASSERTIONS + struct hblk *next = (struct hblk *)((word)h + hhdr -> hb_sz); + hdr * nexthdr = HDR(next); + struct hblk *prev = GC_free_block_ending_at(h); + hdr * prevhdr = HDR(prev); + GC_ASSERT(nexthdr == 0 || !HBLK_IS_FREE(nexthdr) || !IS_MAPPED(nexthdr)); + GC_ASSERT(prev == 0 || !HBLK_IS_FREE(prevhdr) || !IS_MAPPED(prevhdr)); +# endif + GC_ASSERT(((hhdr -> hb_sz) & (HBLKSIZE-1)) == 0); + GC_hblkfreelist[index] = h; + hhdr -> hb_next = second; + hhdr -> hb_prev = 0; + if (0 != second) HDR(second) -> hb_prev = h; + GC_invalidate_map(hhdr); +} + +#ifdef USE_MUNMAP + +/* Unmap blocks that haven't been recently touched. This is the only way */ +/* way blocks are ever unmapped. */ +void GC_unmap_old(void) +{ + struct hblk * h; + hdr * hhdr; + word sz; + unsigned short last_rec, threshold; + int i; +# define UNMAP_THRESHOLD 6 + + for (i = 0; i <= N_HBLK_FLS; ++i) { + for (h = GC_hblkfreelist[i]; 0 != h; h = hhdr -> hb_next) { + hhdr = HDR(h); + if (!IS_MAPPED(hhdr)) continue; + threshold = (unsigned short)(GC_gc_no - UNMAP_THRESHOLD); + last_rec = hhdr -> hb_last_reclaimed; + if (last_rec > GC_gc_no + || last_rec < threshold && threshold < GC_gc_no + /* not recently wrapped */) { + sz = hhdr -> hb_sz; + GC_unmap((ptr_t)h, sz); + hhdr -> hb_flags |= WAS_UNMAPPED; + } + } + } +} + +/* Merge all unmapped blocks that are adjacent to other free */ +/* blocks. This may involve remapping, since all blocks are either */ +/* fully mapped or fully unmapped. */ +void GC_merge_unmapped(void) +{ + struct hblk * h, *next; + hdr * hhdr, *nexthdr; + word size, nextsize; + int i; + + for (i = 0; i <= N_HBLK_FLS; ++i) { + h = GC_hblkfreelist[i]; + while (h != 0) { + hhdr = HDR(h); + size = hhdr->hb_sz; + next = (struct hblk *)((word)h + size); + nexthdr = HDR(next); + /* Coalesce with successor, if possible */ + if (0 != nexthdr && HBLK_IS_FREE(nexthdr)) { + nextsize = nexthdr -> hb_sz; + if (IS_MAPPED(hhdr)) { + GC_ASSERT(!IS_MAPPED(nexthdr)); + /* make both consistent, so that we can merge */ + if (size > nextsize) { + GC_remap((ptr_t)next, nextsize); + } else { + GC_unmap((ptr_t)h, size); + hhdr -> hb_flags |= WAS_UNMAPPED; + } + } else if (IS_MAPPED(nexthdr)) { + GC_ASSERT(!IS_MAPPED(hhdr)); + if (size > nextsize) { + GC_unmap((ptr_t)next, nextsize); + } else { + GC_remap((ptr_t)h, size); + hhdr -> hb_flags &= ~WAS_UNMAPPED; + } + } else { + /* Unmap any gap in the middle */ + GC_unmap_gap((ptr_t)h, size, (ptr_t)next, nexthdr -> hb_sz); + } + /* If they are both unmapped, we merge, but leave unmapped. */ + GC_remove_from_fl(hhdr, i); + GC_remove_from_fl(nexthdr, FL_UNKNOWN); + hhdr -> hb_sz += nexthdr -> hb_sz; + GC_remove_header(next); + GC_add_to_fl(h, hhdr); + /* Start over at beginning of list */ + h = GC_hblkfreelist[i]; + } else /* not mergable with successor */ { + h = hhdr -> hb_next; + } + } /* while (h != 0) ... */ + } /* for ... */ +} + +#endif /* USE_MUNMAP */ + +/* + * Return a pointer to a block starting at h of length bytes. + * Memory for the block is mapped. + * Remove the block from its free list, and return the remainder (if any) + * to its appropriate free list. + * May fail by returning 0. + * The header for the returned block must be set up by the caller. + * If the return value is not 0, then hhdr is the header for it. + */ +struct hblk * GC_get_first_part(h, hhdr, bytes, index) +struct hblk *h; +hdr * hhdr; +word bytes; +int index; +{ + word total_size = hhdr -> hb_sz; + struct hblk * rest; + hdr * rest_hdr; + + GC_ASSERT((total_size & (HBLKSIZE-1)) == 0); + GC_remove_from_fl(hhdr, index); + if (total_size == bytes) return h; + rest = (struct hblk *)((word)h + bytes); + if (!GC_install_header(rest)) return(0); + rest_hdr = HDR(rest); + rest_hdr -> hb_sz = total_size - bytes; + rest_hdr -> hb_flags = 0; +# ifdef GC_ASSERTIONS + // Mark h not free, to avoid assertion about adjacent free blocks. + hhdr -> hb_map = 0; +# endif + GC_add_to_fl(rest, rest_hdr); + return h; +} + +/* + * H is a free block. N points at an address inside it. + * A new header for n has already been set up. Fix up h's header + * to reflect the fact that it is being split, move it to the + * appropriate free list. + * N replaces h in the original free list. + * + * Nhdr is not completely filled in, since it is about to allocated. + * It may in fact end up on the wrong free list for its size. + * (Hence adding it to a free list is silly. But this path is hopefully + * rare enough that it doesn't matter. The code is cleaner this way.) + */ +void GC_split_block(h, hhdr, n, nhdr, index) +struct hblk *h; +hdr * hhdr; +struct hblk *n; +hdr * nhdr; +int index; /* Index of free list */ +{ + word total_size = hhdr -> hb_sz; + word h_size = (word)n - (word)h; + struct hblk *prev = hhdr -> hb_prev; + struct hblk *next = hhdr -> hb_next; + + /* Replace h with n on its freelist */ + nhdr -> hb_prev = prev; + nhdr -> hb_next = next; + nhdr -> hb_sz = total_size - h_size; + nhdr -> hb_flags = 0; + if (0 != prev) { + HDR(prev) -> hb_next = n; + } else { + GC_hblkfreelist[index] = n; + } + if (0 != next) { + HDR(next) -> hb_prev = n; + } +# ifdef GC_ASSERTIONS + nhdr -> hb_map = 0; /* Don't fail test for consecutive */ + /* free blocks in GC_add_to_fl. */ +# endif +# ifdef USE_MUNMAP + hhdr -> hb_last_reclaimed = GC_gc_no; +# endif + hhdr -> hb_sz = h_size; + GC_add_to_fl(h, hhdr); + GC_invalidate_map(nhdr); +} + +struct hblk * GC_allochblk_nth(); + +/* + * Allocate (and return pointer to) a heap block + * for objects of size sz words, searching the nth free list. + * + * NOTE: We set obj_map field in header correctly. + * Caller is responsible for building an object freelist in block. + * + * We clear the block if it is destined for large objects, and if + * kind requires that newly allocated objects be cleared. + */ +struct hblk * +GC_allochblk(sz, kind, flags) +word sz; +int kind; +unsigned char flags; /* IGNORE_OFF_PAGE or 0 */ +{ + int start_list = GC_hblk_fl_from_blocks(OBJ_SZ_TO_BLOCKS(sz)); + int i; + for (i = start_list; i <= N_HBLK_FLS; ++i) { + struct hblk * result = GC_allochblk_nth(sz, kind, flags, i); + if (0 != result) return result; + } + return 0; +} +/* + * The same, but with search restricted to nth free list. + */ +struct hblk * +GC_allochblk_nth(sz, kind, flags, n) +word sz; +int kind; +unsigned char flags; /* IGNORE_OFF_PAGE or 0 */ +int n; +{ + register struct hblk *hbp; + register hdr * hhdr; /* Header corr. to hbp */ + register struct hblk *thishbp; + register hdr * thishdr; /* Header corr. to hbp */ + signed_word size_needed; /* number of bytes in requested objects */ + signed_word size_avail; /* bytes available in this block */ + + size_needed = HBLKSIZE * OBJ_SZ_TO_BLOCKS(sz); + + /* search for a big enough block in free list */ + hbp = GC_hblkfreelist[n]; + hhdr = HDR(hbp); + for(; 0 != hbp; hbp = hhdr -> hb_next, hhdr = HDR(hbp)) { + size_avail = hhdr->hb_sz; + if (size_avail < size_needed) continue; +# ifdef PRESERVE_LAST + if (size_avail != size_needed + && !GC_incremental && GC_should_collect()) { + continue; + } +# endif + /* If the next heap block is obviously better, go on. */ + /* This prevents us from disassembling a single large block */ + /* to get tiny blocks. */ + { + signed_word next_size; + + thishbp = hhdr -> hb_next; + if (thishbp != 0) { + thishdr = HDR(thishbp); + next_size = (signed_word)(thishdr -> hb_sz); + if (next_size < size_avail + && next_size >= size_needed + && !GC_is_black_listed(thishbp, (word)size_needed)) { + continue; + } + } + } + if ( !IS_UNCOLLECTABLE(kind) && + (kind != PTRFREE || size_needed > MAX_BLACK_LIST_ALLOC)) { + struct hblk * lasthbp = hbp; + ptr_t search_end = (ptr_t)hbp + size_avail - size_needed; + signed_word orig_avail = size_avail; + signed_word eff_size_needed = ((flags & IGNORE_OFF_PAGE)? + HBLKSIZE + : size_needed); + + + while ((ptr_t)lasthbp <= search_end + && (thishbp = GC_is_black_listed(lasthbp, + (word)eff_size_needed))) { + lasthbp = thishbp; + } + size_avail -= (ptr_t)lasthbp - (ptr_t)hbp; + thishbp = lasthbp; + if (size_avail >= size_needed) { + if (thishbp != hbp && GC_install_header(thishbp)) { + /* Make sure it's mapped before we mangle it. */ +# ifdef USE_MUNMAP + if (!IS_MAPPED(hhdr)) { + GC_remap((ptr_t)hbp, size_avail); + hhdr -> hb_flags &= ~WAS_UNMAPPED; + } +# endif + /* Split the block at thishbp */ + thishdr = HDR(thishbp); + GC_split_block(hbp, hhdr, thishbp, thishdr, n); + /* Advance to thishbp */ + hbp = thishbp; + hhdr = thishdr; + /* We must now allocate thishbp, since it may */ + /* be on the wrong free list. */ + } + } else if (size_needed > (signed_word)BL_LIMIT + && orig_avail - size_needed + > (signed_word)BL_LIMIT) { + /* Punt, since anything else risks unreasonable heap growth. */ + WARN("Needed to allocate blacklisted block at 0x%lx\n", + (word)hbp); + size_avail = orig_avail; + } else if (size_avail == 0 && size_needed == HBLKSIZE + && IS_MAPPED(hhdr)) { + if (!GC_find_leak) { + static unsigned count = 0; + + /* The block is completely blacklisted. We need */ + /* to drop some such blocks, since otherwise we spend */ + /* all our time traversing them if pointerfree */ + /* blocks are unpopular. */ + /* A dropped block will be reconsidered at next GC. */ + if ((++count & 3) == 0) { + /* Allocate and drop the block in small chunks, to */ + /* maximize the chance that we will recover some */ + /* later. */ + word total_size = hhdr -> hb_sz; + struct hblk * limit = hbp + divHBLKSZ(total_size); + struct hblk * h; + struct hblk * prev = hhdr -> hb_prev; + + GC_words_wasted += total_size; + GC_large_free_bytes -= total_size; + GC_remove_from_fl(hhdr, n); + for (h = hbp; h < limit; h++) { + if (h == hbp || GC_install_header(h)) { + hhdr = HDR(h); + (void) setup_header( + hhdr, + BYTES_TO_WORDS(HBLKSIZE - HDR_BYTES), + PTRFREE, 0); /* Cant fail */ + if (GC_debugging_started) { + BZERO(h + HDR_BYTES, HBLKSIZE - HDR_BYTES); + } + } + } + /* Restore hbp to point at free block */ + hbp = prev; + if (0 == hbp) { + return GC_allochblk_nth(sz, kind, flags, n); + } + hhdr = HDR(hbp); + } + } + } + } + if( size_avail >= size_needed ) { +# ifdef USE_MUNMAP + if (!IS_MAPPED(hhdr)) { + GC_remap((ptr_t)hbp, size_avail); + hhdr -> hb_flags &= ~WAS_UNMAPPED; + } +# endif + /* hbp may be on the wrong freelist; the parameter n */ + /* is important. */ + hbp = GC_get_first_part(hbp, hhdr, size_needed, n); + break; + } + } + + if (0 == hbp) return 0; + + /* Notify virtual dirty bit implementation that we are about to write. */ + GC_write_hint(hbp); + + /* Add it to map of valid blocks */ + if (!GC_install_counts(hbp, (word)size_needed)) return(0); + /* This leaks memory under very rare conditions. */ + + /* Set up header */ + if (!setup_header(hhdr, sz, kind, flags)) { + GC_remove_counts(hbp, (word)size_needed); + return(0); /* ditto */ + } + + /* Clear block if necessary */ + if (GC_debugging_started + || sz > MAXOBJSZ && GC_obj_kinds[kind].ok_init) { + BZERO(hbp + HDR_BYTES, size_needed - HDR_BYTES); + } + + /* We just successfully allocated a block. Restart count of */ + /* consecutive failures. */ + { + extern unsigned GC_fail_count; + + GC_fail_count = 0; + } + + GC_large_free_bytes -= size_needed; + + GC_ASSERT(IS_MAPPED(hhdr)); + return( hbp ); +} + +struct hblk * GC_freehblk_ptr = 0; /* Search position hint for GC_freehblk */ + +/* + * Free a heap block. + * + * Coalesce the block with its neighbors if possible. + * + * All mark words are assumed to be cleared. + */ +void +GC_freehblk(hbp) +struct hblk *hbp; +{ +struct hblk *next, *prev; +hdr *hhdr, *prevhdr, *nexthdr; +signed_word size; + + + hhdr = HDR(hbp); + size = hhdr->hb_sz; + size = HBLKSIZE * OBJ_SZ_TO_BLOCKS(size); + GC_remove_counts(hbp, (word)size); + hhdr->hb_sz = size; + + /* Check for duplicate deallocation in the easy case */ + if (HBLK_IS_FREE(hhdr)) { + GC_printf1("Duplicate large block deallocation of 0x%lx\n", + (unsigned long) hbp); + } + + GC_ASSERT(IS_MAPPED(hhdr)); + GC_invalidate_map(hhdr); + next = (struct hblk *)((word)hbp + size); + nexthdr = HDR(next); + prev = GC_free_block_ending_at(hbp); + /* Coalesce with successor, if possible */ + if(0 != nexthdr && HBLK_IS_FREE(nexthdr) && IS_MAPPED(nexthdr)) { + GC_remove_from_fl(nexthdr, FL_UNKNOWN); + hhdr -> hb_sz += nexthdr -> hb_sz; + GC_remove_header(next); + } + /* Coalesce with predecessor, if possible. */ + if (0 != prev) { + prevhdr = HDR(prev); + if (IS_MAPPED(prevhdr)) { + GC_remove_from_fl(prevhdr, FL_UNKNOWN); + prevhdr -> hb_sz += hhdr -> hb_sz; + GC_remove_header(hbp); + hbp = prev; + hhdr = prevhdr; + } + } + + GC_large_free_bytes += size; + GC_add_to_fl(hbp, hhdr); +} + diff --git a/support/gc/alloc.c b/support/gc/alloc.c new file mode 100644 index 00000000..1c57951f --- /dev/null +++ b/support/gc/alloc.c @@ -0,0 +1,884 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1998 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +# include "gc_priv.h" + +# include +# ifndef MACOS +# include +# include +# endif + +/* + * Separate free lists are maintained for different sized objects + * up to MAXOBJSZ. + * The call GC_allocobj(i,k) ensures that the freelist for + * kind k objects of size i points to a non-empty + * free list. It returns a pointer to the first entry on the free list. + * In a single-threaded world, GC_allocobj may be called to allocate + * an object of (small) size i as follows: + * + * opp = &(GC_objfreelist[i]); + * if (*opp == 0) GC_allocobj(i, NORMAL); + * ptr = *opp; + * *opp = obj_link(ptr); + * + * Note that this is very fast if the free list is non-empty; it should + * only involve the execution of 4 or 5 simple instructions. + * All composite objects on freelists are cleared, except for + * their first word. + */ + +/* + * The allocator uses GC_allochblk to allocate large chunks of objects. + * These chunks all start on addresses which are multiples of + * HBLKSZ. Each allocated chunk has an associated header, + * which can be located quickly based on the address of the chunk. + * (See headers.c for details.) + * This makes it possible to check quickly whether an + * arbitrary address corresponds to an object administered by the + * allocator. + */ + +word GC_non_gc_bytes = 0; /* Number of bytes not intended to be collected */ + +word GC_gc_no = 0; + +#ifndef SMALL_CONFIG + int GC_incremental = 0; /* By default, stop the world. */ +#endif + +int GC_full_freq = 4; /* Every 5th collection is a full */ + /* collection. */ + +char * GC_copyright[] = +{"Copyright 1988,1989 Hans-J. Boehm and Alan J. Demers ", +"Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. ", +"Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. ", +"THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY", +" EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.", +"See source code for details." }; + +# include "version.h" + +/* some more variables */ + +extern signed_word GC_mem_found; /* Number of reclaimed longwords */ + /* after garbage collection */ + +GC_bool GC_dont_expand = 0; + +word GC_free_space_divisor = 3; + +extern GC_bool GC_collection_in_progress(); + /* Collection is in progress, or was abandoned. */ + +int GC_never_stop_func GC_PROTO((void)) { return(0); } + +CLOCK_TYPE GC_start_time; /* Time at which we stopped world. */ + /* used only in GC_timeout_stop_func. */ + +int GC_n_attempts = 0; /* Number of attempts at finishing */ + /* collection within TIME_LIMIT */ + +#ifdef SMALL_CONFIG +# define GC_timeout_stop_func GC_never_stop_func +#else + int GC_timeout_stop_func GC_PROTO((void)) + { + CLOCK_TYPE current_time; + static unsigned count = 0; + unsigned long time_diff; + + if ((count++ & 3) != 0) return(0); + GET_TIME(current_time); + time_diff = MS_TIME_DIFF(current_time,GC_start_time); + if (time_diff >= TIME_LIMIT) { +# ifdef PRINTSTATS + GC_printf0("Abandoning stopped marking after "); + GC_printf1("%lu msecs", (unsigned long)time_diff); + GC_printf1("(attempt %d)\n", (unsigned long) GC_n_attempts); +# endif + return(1); + } + return(0); + } +#endif /* !SMALL_CONFIG */ + +/* Return the minimum number of words that must be allocated between */ +/* collections to amortize the collection cost. */ +static word min_words_allocd() +{ +# ifdef THREADS + /* We punt, for now. */ + register signed_word stack_size = 10000; +# else + int dummy; + register signed_word stack_size = (ptr_t)(&dummy) - GC_stackbottom; +# endif + word total_root_size; /* includes double stack size, */ + /* since the stack is expensive */ + /* to scan. */ + word scan_size; /* Estimate of memory to be scanned */ + /* during normal GC. */ + + if (stack_size < 0) stack_size = -stack_size; + total_root_size = 2 * stack_size + GC_root_size; + scan_size = BYTES_TO_WORDS(GC_heapsize - GC_large_free_bytes + + (GC_large_free_bytes >> 2) + /* use a bit more of large empty heap */ + + total_root_size); + if (GC_incremental) { + return scan_size / (2 * GC_free_space_divisor); + } else { + return scan_size / GC_free_space_divisor; + } +} + +/* Return the number of words allocated, adjusted for explicit storage */ +/* management, etc.. This number is used in deciding when to trigger */ +/* collections. */ +word GC_adj_words_allocd() +{ + register signed_word result; + register signed_word expl_managed = + BYTES_TO_WORDS((long)GC_non_gc_bytes + - (long)GC_non_gc_bytes_at_gc); + + /* Don't count what was explicitly freed, or newly allocated for */ + /* explicit management. Note that deallocating an explicitly */ + /* managed object should not alter result, assuming the client */ + /* is playing by the rules. */ + result = (signed_word)GC_words_allocd + - (signed_word)GC_mem_freed - expl_managed; + if (result > (signed_word)GC_words_allocd) { + result = GC_words_allocd; + /* probably client bug or unfortunate scheduling */ + } + result += GC_words_finalized; + /* We count objects enqueued for finalization as though they */ + /* had been reallocated this round. Finalization is user */ + /* visible progress. And if we don't count this, we have */ + /* stability problems for programs that finalize all objects. */ + result += GC_words_wasted; + /* This doesn't reflect useful work. But if there is lots of */ + /* new fragmentation, the same is probably true of the heap, */ + /* and the collection will be correspondingly cheaper. */ + if (result < (signed_word)(GC_words_allocd >> 3)) { + /* Always count at least 1/8 of the allocations. We don't want */ + /* to collect too infrequently, since that would inhibit */ + /* coalescing of free storage blocks. */ + /* This also makes us partially robust against client bugs. */ + return(GC_words_allocd >> 3); + } else { + return(result); + } +} + + +/* Clear up a few frames worth of garbage left at the top of the stack. */ +/* This is used to prevent us from accidentally treating garbade left */ +/* on the stack by other parts of the collector as roots. This */ +/* differs from the code in misc.c, which actually tries to keep the */ +/* stack clear of long-lived, client-generated garbage. */ +void GC_clear_a_few_frames() +{ +# define NWORDS 64 + word frames[NWORDS]; + register int i; + + for (i = 0; i < NWORDS; i++) frames[i] = 0; +} + +/* Have we allocated enough to amortize a collection? */ +GC_bool GC_should_collect() +{ + return(GC_adj_words_allocd() >= min_words_allocd()); +} + +void GC_notify_full_gc() +{ + if (GC_start_call_back != (void (*)())0) { + (*GC_start_call_back)(); + } +} + +/* + * Initiate a garbage collection if appropriate. + * Choose judiciously + * between partial, full, and stop-world collections. + * Assumes lock held, signals disabled. + */ +void GC_maybe_gc() +{ + static int n_partial_gcs = 0; + GC_bool is_full_gc = FALSE; + + if (GC_should_collect()) { + if (!GC_incremental) { + GC_notify_full_gc(); + GC_gcollect_inner(); + n_partial_gcs = 0; + return; + } else if (n_partial_gcs >= GC_full_freq) { +# ifdef PRINTSTATS + GC_printf2( + "***>Full mark for collection %lu after %ld allocd bytes\n", + (unsigned long) GC_gc_no+1, + (long)WORDS_TO_BYTES(GC_words_allocd)); +# endif + GC_promote_black_lists(); + (void)GC_reclaim_all((GC_stop_func)0, TRUE); + GC_clear_marks(); + n_partial_gcs = 0; + GC_notify_full_gc(); + is_full_gc = TRUE; + } else { + n_partial_gcs++; + } + /* We try to mark with the world stopped. */ + /* If we run out of time, this turns into */ + /* incremental marking. */ + GET_TIME(GC_start_time); + if (GC_stopped_mark(GC_timeout_stop_func)) { +# ifdef SAVE_CALL_CHAIN + GC_save_callers(GC_last_stack); +# endif + GC_finish_collection(); + } else { + if (!is_full_gc) { + /* Count this as the first attempt */ + GC_n_attempts++; + } + } + } +} + + +/* + * Stop the world garbage collection. Assumes lock held, signals disabled. + * If stop_func is not GC_never_stop_func, then abort if stop_func returns TRUE. + */ +GC_bool GC_try_to_collect_inner(stop_func) +GC_stop_func stop_func; +{ + if (GC_incremental && GC_collection_in_progress()) { +# ifdef PRINTSTATS + GC_printf0( + "GC_try_to_collect_inner: finishing collection in progress\n"); +# endif /* PRINTSTATS */ + /* Just finish collection already in progress. */ + while(GC_collection_in_progress()) { + if (stop_func()) return(FALSE); + GC_collect_a_little_inner(1); + } + } +# ifdef PRINTSTATS + GC_printf2( + "Initiating full world-stop collection %lu after %ld allocd bytes\n", + (unsigned long) GC_gc_no+1, + (long)WORDS_TO_BYTES(GC_words_allocd)); +# endif + GC_promote_black_lists(); + /* Make sure all blocks have been reclaimed, so sweep routines */ + /* don't see cleared mark bits. */ + /* If we're guaranteed to finish, then this is unnecessary. */ + if (stop_func != GC_never_stop_func + && !GC_reclaim_all(stop_func, FALSE)) { + /* Aborted. So far everything is still consistent. */ + return(FALSE); + } + GC_invalidate_mark_state(); /* Flush mark stack. */ + GC_clear_marks(); +# ifdef SAVE_CALL_CHAIN + GC_save_callers(GC_last_stack); +# endif + if (!GC_stopped_mark(stop_func)) { + if (!GC_incremental) { + /* We're partially done and have no way to complete or use */ + /* current work. Reestablish invariants as cheaply as */ + /* possible. */ + GC_invalidate_mark_state(); + GC_unpromote_black_lists(); + } /* else we claim the world is already still consistent. We'll */ + /* finish incrementally. */ + return(FALSE); + } + GC_finish_collection(); + return(TRUE); +} + + + +/* + * Perform n units of garbage collection work. A unit is intended to touch + * roughly GC_RATE pages. Every once in a while, we do more than that. + * This needa to be a fairly large number with our current incremental + * GC strategy, since otherwise we allocate too much during GC, and the + * cleanup gets expensive. + */ +# define GC_RATE 10 +# define MAX_PRIOR_ATTEMPTS 1 + /* Maximum number of prior attempts at world stop marking */ + /* A value of 1 means that we finish the seconf time, no matter */ + /* how long it takes. Doesn't count the initial root scan */ + /* for a full GC. */ + +int GC_deficit = 0; /* The number of extra calls to GC_mark_some */ + /* that we have made. */ + +void GC_collect_a_little_inner(n) +int n; +{ + register int i; + + if (GC_incremental && GC_collection_in_progress()) { + for (i = GC_deficit; i < GC_RATE*n; i++) { + if (GC_mark_some((ptr_t)0)) { + /* Need to finish a collection */ +# ifdef SAVE_CALL_CHAIN + GC_save_callers(GC_last_stack); +# endif + if (GC_n_attempts < MAX_PRIOR_ATTEMPTS) { + GET_TIME(GC_start_time); + if (!GC_stopped_mark(GC_timeout_stop_func)) { + GC_n_attempts++; + break; + } + } else { + (void)GC_stopped_mark(GC_never_stop_func); + } + GC_finish_collection(); + break; + } + } + if (GC_deficit > 0) GC_deficit -= GC_RATE*n; + if (GC_deficit < 0) GC_deficit = 0; + } else { + GC_maybe_gc(); + } +} + +int GC_collect_a_little GC_PROTO(()) +{ + int result; + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + GC_collect_a_little_inner(1); + result = (int)GC_collection_in_progress(); + UNLOCK(); + ENABLE_SIGNALS(); + return(result); +} + +/* + * Assumes lock is held, signals are disabled. + * We stop the world. + * If stop_func() ever returns TRUE, we may fail and return FALSE. + * Increment GC_gc_no if we succeed. + */ +GC_bool GC_stopped_mark(stop_func) +GC_stop_func stop_func; +{ + register int i; + int dummy; +# ifdef PRINTSTATS + CLOCK_TYPE start_time, current_time; +# endif + + STOP_WORLD(); +# ifdef PRINTSTATS + GET_TIME(start_time); + GC_printf1("--> Marking for collection %lu ", + (unsigned long) GC_gc_no + 1); + GC_printf2("after %lu allocd bytes + %lu wasted bytes\n", + (unsigned long) WORDS_TO_BYTES(GC_words_allocd), + (unsigned long) WORDS_TO_BYTES(GC_words_wasted)); +# endif + + /* Mark from all roots. */ + /* Minimize junk left in my registers and on the stack */ + GC_clear_a_few_frames(); + GC_noop(0,0,0,0,0,0); + GC_initiate_gc(); + for(i = 0;;i++) { + if ((*stop_func)()) { +# ifdef PRINTSTATS + GC_printf0("Abandoned stopped marking after "); + GC_printf1("%lu iterations\n", + (unsigned long)i); +# endif + GC_deficit = i; /* Give the mutator a chance. */ + START_WORLD(); + return(FALSE); + } + if (GC_mark_some((ptr_t)(&dummy))) break; + } + + GC_gc_no++; +# ifdef PRINTSTATS + GC_printf2("Collection %lu reclaimed %ld bytes", + (unsigned long) GC_gc_no - 1, + (long)WORDS_TO_BYTES(GC_mem_found)); + GC_printf1(" ---> heapsize = %lu bytes\n", + (unsigned long) GC_heapsize); + /* Printf arguments may be pushed in funny places. Clear the */ + /* space. */ + GC_printf0(""); +# endif + + /* Check all debugged objects for consistency */ + if (GC_debugging_started) { + (*GC_check_heap)(); + } + +# ifdef PRINTTIMES + GET_TIME(current_time); + GC_printf1("World-stopped marking took %lu msecs\n", + MS_TIME_DIFF(current_time,start_time)); +# endif + START_WORLD(); + return(TRUE); +} + + +/* Finish up a collection. Assumes lock is held, signals are disabled, */ +/* but the world is otherwise running. */ +void GC_finish_collection() +{ +# ifdef PRINTTIMES + CLOCK_TYPE start_time; + CLOCK_TYPE finalize_time; + CLOCK_TYPE done_time; + + GET_TIME(start_time); + finalize_time = start_time; +# endif + +# ifdef GATHERSTATS + GC_mem_found = 0; +# endif + if (GC_find_leak) { + /* Mark all objects on the free list. All objects should be */ + /* marked when we're done. */ + { + register word size; /* current object size */ + register ptr_t p; /* pointer to current object */ + register struct hblk * h; /* pointer to block containing *p */ + register hdr * hhdr; + register int word_no; /* "index" of *p in *q */ + int kind; + + for (kind = 0; kind < GC_n_kinds; kind++) { + for (size = 1; size <= MAXOBJSZ; size++) { + for (p= GC_obj_kinds[kind].ok_freelist[size]; + p != 0; p=obj_link(p)){ + h = HBLKPTR(p); + hhdr = HDR(h); + word_no = (((word *)p) - ((word *)h)); + set_mark_bit_from_hdr(hhdr, word_no); + } + } + } + } + GC_start_reclaim(TRUE); + /* The above just checks; it doesn't really reclaim anything. */ + } + + GC_finalize(); +# ifdef STUBBORN_ALLOC + GC_clean_changing_list(); +# endif + +# ifdef PRINTTIMES + GET_TIME(finalize_time); +# endif + + /* Clear free list mark bits, in case they got accidentally marked */ + /* Note: HBLKPTR(p) == pointer to head of block containing *p */ + /* (or GC_find_leak is set and they were intentionally marked.) */ + /* Also subtract memory remaining from GC_mem_found count. */ + /* Note that composite objects on free list are cleared. */ + /* Thus accidentally marking a free list is not a problem; only */ + /* objects on the list itself will be marked, and that's fixed here. */ + { + register word size; /* current object size */ + register ptr_t p; /* pointer to current object */ + register struct hblk * h; /* pointer to block containing *p */ + register hdr * hhdr; + register int word_no; /* "index" of *p in *q */ + int kind; + + for (kind = 0; kind < GC_n_kinds; kind++) { + for (size = 1; size <= MAXOBJSZ; size++) { + for (p= GC_obj_kinds[kind].ok_freelist[size]; + p != 0; p=obj_link(p)){ + h = HBLKPTR(p); + hhdr = HDR(h); + word_no = (((word *)p) - ((word *)h)); + clear_mark_bit_from_hdr(hhdr, word_no); +# ifdef GATHERSTATS + GC_mem_found -= size; +# endif + } + } + } + } + + +# ifdef PRINTSTATS + GC_printf1("Bytes recovered before sweep - f.l. count = %ld\n", + (long)WORDS_TO_BYTES(GC_mem_found)); +# endif + /* Reconstruct free lists to contain everything not marked */ + GC_start_reclaim(FALSE); + +# ifdef PRINTSTATS + GC_printf2( + "Immediately reclaimed %ld bytes in heap of size %lu bytes", + (long)WORDS_TO_BYTES(GC_mem_found), + (unsigned long)GC_heapsize); +# ifdef USE_MUNMAP + GC_printf1("(%lu unmapped)", GC_unmapped_bytes); +# endif + GC_printf2( + "\n%lu (atomic) + %lu (composite) collectable bytes in use\n", + (unsigned long)WORDS_TO_BYTES(GC_atomic_in_use), + (unsigned long)WORDS_TO_BYTES(GC_composite_in_use)); +# endif + + GC_n_attempts = 0; + /* Reset or increment counters for next cycle */ + GC_words_allocd_before_gc += GC_words_allocd; + GC_non_gc_bytes_at_gc = GC_non_gc_bytes; + GC_words_allocd = 0; + GC_words_wasted = 0; + GC_mem_freed = 0; + +# ifdef USE_MUNMAP + GC_unmap_old(); +# endif +# ifdef PRINTTIMES + GET_TIME(done_time); + GC_printf2("Finalize + initiate sweep took %lu + %lu msecs\n", + MS_TIME_DIFF(finalize_time,start_time), + MS_TIME_DIFF(done_time,finalize_time)); +# endif +} + +/* Externally callable routine to invoke full, stop-world collection */ +# if defined(__STDC__) || defined(__cplusplus) + int GC_try_to_collect(GC_stop_func stop_func) +# else + int GC_try_to_collect(stop_func) + GC_stop_func stop_func; +# endif +{ + int result; + DCL_LOCK_STATE; + + GC_INVOKE_FINALIZERS(); + DISABLE_SIGNALS(); + LOCK(); + ENTER_GC(); + if (!GC_is_initialized) GC_init_inner(); + /* Minimize junk left in my registers */ + GC_noop(0,0,0,0,0,0); + result = (int)GC_try_to_collect_inner(stop_func); + EXIT_GC(); + UNLOCK(); + ENABLE_SIGNALS(); + if(result) GC_INVOKE_FINALIZERS(); + return(result); +} + +void GC_gcollect GC_PROTO(()) +{ + GC_notify_full_gc(); + (void)GC_try_to_collect(GC_never_stop_func); +} + +word GC_n_heap_sects = 0; /* Number of sections currently in heap. */ + +/* + * Use the chunk of memory starting at p of size bytes as part of the heap. + * Assumes p is HBLKSIZE aligned, and bytes is a multiple of HBLKSIZE. + */ +void GC_add_to_heap(p, bytes) +struct hblk *p; +word bytes; +{ + word words; + hdr * phdr; + + if (GC_n_heap_sects >= MAX_HEAP_SECTS) { + ABORT("Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS"); + } + if (!GC_install_header(p)) { + /* This is extremely unlikely. Can't add it. This will */ + /* almost certainly result in a 0 return from the allocator, */ + /* which is entirely appropriate. */ + return; + } + GC_heap_sects[GC_n_heap_sects].hs_start = (ptr_t)p; + GC_heap_sects[GC_n_heap_sects].hs_bytes = bytes; + GC_n_heap_sects++; + words = BYTES_TO_WORDS(bytes - HDR_BYTES); + phdr = HDR(p); + phdr -> hb_sz = words; + phdr -> hb_map = (char *)1; /* A value != GC_invalid_map */ + phdr -> hb_flags = 0; + GC_freehblk(p); + GC_heapsize += bytes; + if ((ptr_t)p <= GC_least_plausible_heap_addr + || GC_least_plausible_heap_addr == 0) { + GC_least_plausible_heap_addr = (ptr_t)p - sizeof(word); + /* Making it a little smaller than necessary prevents */ + /* us from getting a false hit from the variable */ + /* itself. There's some unintentional reflection */ + /* here. */ + } + if ((ptr_t)p + bytes >= GC_greatest_plausible_heap_addr) { + GC_greatest_plausible_heap_addr = (ptr_t)p + bytes; + } +} + +# if !defined(NO_DEBUGGING) +void GC_print_heap_sects() +{ + register unsigned i; + + GC_printf1("Total heap size: %lu\n", (unsigned long) GC_heapsize); + for (i = 0; i < GC_n_heap_sects; i++) { + unsigned long start = (unsigned long) GC_heap_sects[i].hs_start; + unsigned long len = (unsigned long) GC_heap_sects[i].hs_bytes; + struct hblk *h; + unsigned nbl = 0; + + GC_printf3("Section %ld from 0x%lx to 0x%lx ", (unsigned long)i, + start, (unsigned long)(start + len)); + for (h = (struct hblk *)start; h < (struct hblk *)(start + len); h++) { + if (GC_is_black_listed(h, HBLKSIZE)) nbl++; + } + GC_printf2("%lu/%lu blacklisted\n", (unsigned long)nbl, + (unsigned long)(len/HBLKSIZE)); + } +} +# endif + +ptr_t GC_least_plausible_heap_addr = (ptr_t)ONES; +ptr_t GC_greatest_plausible_heap_addr = 0; + +ptr_t GC_max(x,y) +ptr_t x, y; +{ + return(x > y? x : y); +} + +ptr_t GC_min(x,y) +ptr_t x, y; +{ + return(x < y? x : y); +} + +# if defined(__STDC__) || defined(__cplusplus) + void GC_set_max_heap_size(GC_word n) +# else + void GC_set_max_heap_size(n) + GC_word n; +# endif +{ + GC_max_heapsize = n; +} + +GC_word GC_max_retries = 0; + +/* + * this explicitly increases the size of the heap. It is used + * internally, but may also be invoked from GC_expand_hp by the user. + * The argument is in units of HBLKSIZE. + * Tiny values of n are rounded up. + * Returns FALSE on failure. + */ +GC_bool GC_expand_hp_inner(n) +word n; +{ + word bytes; + struct hblk * space; + word expansion_slop; /* Number of bytes by which we expect the */ + /* heap to expand soon. */ + + if (n < MINHINCR) n = MINHINCR; + bytes = n * HBLKSIZE; + /* Make sure bytes is a multiple of GC_page_size */ + { + word mask = GC_page_size - 1; + bytes += mask; + bytes &= ~mask; + } + + if (GC_max_heapsize != 0 && GC_heapsize + bytes > GC_max_heapsize) { + /* Exceeded self-imposed limit */ + return(FALSE); + } + space = GET_MEM(bytes); + if( space == 0 ) { + return(FALSE); + } +# ifdef PRINTSTATS + GC_printf2("Increasing heap size by %lu after %lu allocated bytes\n", + (unsigned long)bytes, + (unsigned long)WORDS_TO_BYTES(GC_words_allocd)); +# ifdef UNDEFINED + GC_printf1("Root size = %lu\n", GC_root_size); + GC_print_block_list(); GC_print_hblkfreelist(); + GC_printf0("\n"); +# endif +# endif + expansion_slop = 8 * WORDS_TO_BYTES(min_words_allocd()); + if (5 * HBLKSIZE * MAXHINCR > expansion_slop) { + expansion_slop = 5 * HBLKSIZE * MAXHINCR; + } + if (GC_last_heap_addr == 0 && !((word)space & SIGNB) + || GC_last_heap_addr != 0 && GC_last_heap_addr < (ptr_t)space) { + /* Assume the heap is growing up */ + GC_greatest_plausible_heap_addr = + GC_max(GC_greatest_plausible_heap_addr, + (ptr_t)space + bytes + expansion_slop); + } else { + /* Heap is growing down */ + GC_least_plausible_heap_addr = + GC_min(GC_least_plausible_heap_addr, + (ptr_t)space - expansion_slop); + } + GC_prev_heap_addr = GC_last_heap_addr; + GC_last_heap_addr = (ptr_t)space; + GC_add_to_heap(space, bytes); + return(TRUE); +} + +/* Really returns a bool, but it's externally visible, so that's clumsy. */ +/* Arguments is in bytes. */ +# if defined(__STDC__) || defined(__cplusplus) + int GC_expand_hp(size_t bytes) +# else + int GC_expand_hp(bytes) + size_t bytes; +# endif +{ + int result; + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + if (!GC_is_initialized) GC_init_inner(); + result = (int)GC_expand_hp_inner(divHBLKSZ((word)bytes)); + UNLOCK(); + ENABLE_SIGNALS(); + return(result); +} + +unsigned GC_fail_count = 0; + /* How many consecutive GC/expansion failures? */ + /* Reset by GC_allochblk. */ + +GC_bool GC_collect_or_expand(needed_blocks, ignore_off_page) +word needed_blocks; +GC_bool ignore_off_page; +{ + if (!GC_incremental && !GC_dont_gc && GC_should_collect()) { + GC_notify_full_gc(); + GC_gcollect_inner(); + } else { + word blocks_to_get = GC_heapsize/(HBLKSIZE*GC_free_space_divisor) + + needed_blocks; + + if (blocks_to_get > MAXHINCR) { + word slop; + + if (ignore_off_page) { + slop = 4; + } else { + slop = 2*divHBLKSZ(BL_LIMIT); + if (slop > needed_blocks) slop = needed_blocks; + } + if (needed_blocks + slop > MAXHINCR) { + blocks_to_get = needed_blocks + slop; + } else { + blocks_to_get = MAXHINCR; + } + } + if (!GC_expand_hp_inner(blocks_to_get) + && !GC_expand_hp_inner(needed_blocks)) { + if (GC_fail_count++ < GC_max_retries) { + WARN("Out of Memory! Trying to continue ...\n", 0); + GC_notify_full_gc(); + GC_gcollect_inner(); + } else { + WARN("Out of Memory! Returning NIL!\n", 0); + return(FALSE); + } + } else { +# ifdef PRINTSTATS + if (GC_fail_count) { + GC_printf0("Memory available again ...\n"); + } +# endif + } + } + return(TRUE); +} + +/* + * Make sure the object free list for sz is not empty. + * Return a pointer to the first object on the free list. + * The object MUST BE REMOVED FROM THE FREE LIST BY THE CALLER. + * Assumes we hold the allocator lock and signals are disabled. + * + */ +ptr_t GC_allocobj(sz, kind) +word sz; +int kind; +{ + register ptr_t * flh = &(GC_obj_kinds[kind].ok_freelist[sz]); + + if (sz == 0) return(0); + + while (*flh == 0) { + ENTER_GC(); + /* Do our share of marking work */ + if(GC_incremental && !GC_dont_gc) GC_collect_a_little_inner(1); + /* Sweep blocks for objects of this size */ + GC_continue_reclaim(sz, kind); + EXIT_GC(); + if (*flh == 0) { + GC_new_hblk(sz, kind); + } + if (*flh == 0) { + ENTER_GC(); + if (!GC_collect_or_expand((word)1,FALSE)) { + EXIT_GC(); + return(0); + } + EXIT_GC(); + } + } + + return(*flh); +} diff --git a/support/gc/alpha_mach_dep.s b/support/gc/alpha_mach_dep.s new file mode 100644 index 00000000..35f6af35 --- /dev/null +++ b/support/gc/alpha_mach_dep.s @@ -0,0 +1,60 @@ + # $Id$ + +# define call_push(x) \ + lda $16, 0(x); /* copy x to first argument register */ \ + jsr $26, GC_push_one; /* call GC_push_one, ret addr in $26 */ \ + ldgp $gp, 0($26) /* restore $gp register from $ra */ + + .text + .align 4 + .globl GC_push_regs + .ent GC_push_regs 2 +GC_push_regs: + ldgp $gp, 0($27) # set gp from the procedure value reg + lda $sp, -32($sp) # make stack frame + stq $26, 8($sp) # save return address + .mask 0x04000000, -8 + .frame $sp, 16, $26, 0 + + # call_push($0) # expression eval and int func result + + # call_push($1) # temp regs - not preserved cross calls + # call_push($2) + # call_push($3) + # call_push($4) + # call_push($5) + # call_push($6) + # call_push($7) + # call_push($8) + + call_push($9) # Saved regs + call_push($10) + call_push($11) + call_push($12) + call_push($13) + call_push($14) + + call_push($15) # frame ptr or saved reg + + # call_push($16) # argument regs - not preserved cross calls + # call_push($17) + # call_push($18) + # call_push($19) + # call_push($20) + # call_push($21) + + # call_push($22) # temp regs - not preserved cross calls + # call_push($23) + # call_push($24) + # call_push($25) + + # call_push($26) # return address - expression eval + # call_push($27) # procedure value or temporary reg + # call_push($28) # assembler temp - not presrved + call_push($29) # Global Pointer + # call_push($30) # Stack Pointer + + ldq $26, 8($sp) # restore return address + lda $sp, 32($sp) # pop stack frame + ret $31, ($26), 1 # return ($31 == hardwired zero) + .end GC_push_regs diff --git a/support/gc/barrett_diagram b/support/gc/barrett_diagram new file mode 100644 index 00000000..27e80dc1 --- /dev/null +++ b/support/gc/barrett_diagram @@ -0,0 +1,106 @@ +This is an ASCII diagram of the data structure used to check pointer +validity. It was provided by Dave Barrett , +and should be of use to others attempting to understand the code. +The data structure in GC4.X is essentially the same. -HB + + + + + Data Structure used by GC_base in gc3.7: + 21-Apr-94 + + + + + 63 LOG_TOP_SZ[11] LOG_BOTTOM_SZ[10] LOG_HBLKSIZE[13] + +------------------+----------------+------------------+------------------+ + p:| | TL_HASH(hi) | | HBLKDISPL(p) | + +------------------+----------------+------------------+------------------+ + \-----------------------HBLKPTR(p)-------------------/ + \------------hi-------------------/ + \______ ________/ \________ _______/ \________ _______/ + V V V + | | | + GC_top_index[] | | | + --- +--------------+ | | | + ^ | | | | | + | | | | | | + TOP +--------------+<--+ | | + _SZ +-<| [] | * | | +(items)| +--------------+ if 0 < bi< HBLKSIZE | | + | | | | then large object | | + | | | | starts at the bi'th | | + v | | | HBLK before p. | i | + --- | +--------------+ | (word- | + v | aligned) | + bi= |GET_BI(p){->hash_link}->key==hi | | + v | | + | (bottom_index) \ scratch_alloc'd | | + | ( struct bi ) / by get_index() | | + --- +->+--------------+ | | + ^ | | | | + ^ | | | | + BOTTOM | | ha=GET_HDR_ADDR(p) | | +_SZ(items)+--------------+<----------------------+ +-------+ + | +--<| index[] | | + | | +--------------+ GC_obj_map: v + | | | | from / +-+-+-----+-+-+-+-+ --- + v | | | GC_add < 0| | | | | | | | ^ + --- | +--------------+ _map_entry \ +-+-+-----+-+-+-+-+ | + | | asc_link | +-+-+-----+-+-+-+-+ MAXOBJSZ + | +--------------+ +-->| | | j | | | | | +1 + | | key | | +-+-+-----+-+-+-+-+ | + | +--------------+ | +-+-+-----+-+-+-+-+ | + | | hash_link | | | | | | | | | | v + | +--------------+ | +-+-+-----+-+-+-+-+ --- + | | |<--MAX_OFFSET--->| + | | (bytes) +HDR(p)| GC_find_header(p) | |<--MAP_ENTRIES-->| + | \ from | =HBLKSIZE/WORDSZ + | (hdr) (struct hblkhdr) / alloc_hdr() | (1024 on Alpha) + +-->+----------------------+ | (8/16 bits each) +GET_HDR(p)| word hb_sz (words) | | + +----------------------+ | + | struct hblk *hb_next | | + +----------------------+ | + |mark_proc hb_mark_proc| | + +----------------------+ | + | char * hb_map |>-------------+ + +----------------------+ + | ushort hb_obj_kind | + +----------------------+ + | hb_last_reclaimed | + --- +----------------------+ + ^ | | + MARK_BITS| hb_marks[] | *if hdr is free, hb_sz + DISCARD_WORDS +_SZ(words)| | is the size of a heap chunk (struct hblk) + v | | of at least MININCR*HBLKSIZE bytes (below), + --- +----------------------+ otherwise, size of each object in chunk. + +Dynamic data structures above are interleaved throughout the heap in blocks of +size MININCR * HBLKSIZE bytes as done by gc_scratch_alloc which cannot be +freed; free lists are used (e.g. alloc_hdr). HBLKs's below are collected. + + (struct hblk) + --- +----------------------+ < HBLKSIZE --- --- DISCARD_ + ^ |garbage[DISCARD_WORDS]| aligned ^ ^ HDR_BYTES WORDS + | | | | v (bytes) (words) + | +-----hb_body----------+ < WORDSZ | --- --- + | | | aligned | ^ ^ + | | Object 0 | | hb_sz | + | | | i |(word- (words)| + | | | (bytes)|aligned) v | + | + - - - - - - - - - - -+ --- | --- | + | | | ^ | ^ | + n * | | j (words) | hb_sz BODY_SZ + HBLKSIZE | Object 1 | v v | (words) + (bytes) | |--------------- v MAX_OFFSET + | + - - - - - - - - - - -+ --- (bytes) + | | | !All_INTERIOR_PTRS ^ | + | | | sets j only for hb_sz | + | | Object N | valid object offsets. | | + v | | All objects WORDSZ v v + --- +----------------------+ aligned. --- --- + +DISCARD_WORDS is normally zero. Indeed the collector has not been tested +with another value in ages. diff --git a/support/gc/base_lib b/support/gc/base_lib new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/support/gc/base_lib @@ -0,0 +1 @@ + diff --git a/support/gc/blacklst.c b/support/gc/blacklst.c new file mode 100644 index 00000000..0d623c0f --- /dev/null +++ b/support/gc/blacklst.c @@ -0,0 +1,291 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, August 9, 1995 6:09 pm PDT */ +# include "gc_priv.h" + +/* + * We maintain several hash tables of hblks that have had false hits. + * Each contains one bit per hash bucket; If any page in the bucket + * has had a false hit, we assume that all of them have. + * See the definition of page_hash_table in gc_private.h. + * False hits from the stack(s) are much more dangerous than false hits + * from elsewhere, since the former can pin a large object that spans the + * block, eventhough it does not start on the dangerous block. + */ + +/* + * Externally callable routines are: + + * GC_add_to_black_list_normal + * GC_add_to_black_list_stack + * GC_promote_black_lists + * GC_is_black_listed + * + * All require that the allocator lock is held. + */ + +/* Pointers to individual tables. We replace one table by another by */ +/* switching these pointers. */ +word * GC_old_normal_bl; + /* Nonstack false references seen at last full */ + /* collection. */ +word * GC_incomplete_normal_bl; + /* Nonstack false references seen since last */ + /* full collection. */ +word * GC_old_stack_bl; +word * GC_incomplete_stack_bl; + +word GC_total_stack_black_listed; + +word GC_black_list_spacing = MINHINCR*HBLKSIZE; /* Initial rough guess */ + +void GC_clear_bl(); + +void GC_default_print_heap_obj_proc(p) +ptr_t p; +{ + ptr_t base = GC_base(p); + + GC_err_printf2("start: 0x%lx, appr. length: %ld", base, GC_size(base)); +} + +void (*GC_print_heap_obj)(/* char * s, ptr_t p */) = + GC_default_print_heap_obj_proc; + +void GC_print_source_ptr(p) +ptr_t p; +{ + ptr_t base = GC_base(p); + if (0 == base) { + if (0 == p) { + GC_err_printf0("in register"); + } else { + GC_err_printf0("in root set"); + } + } else { + GC_err_printf0("in object at "); + (*GC_print_heap_obj)(base); + } +} + +void GC_bl_init() +{ +# ifndef ALL_INTERIOR_POINTERS + GC_old_normal_bl = (word *) + GC_scratch_alloc((word)(sizeof (page_hash_table))); + GC_incomplete_normal_bl = (word *)GC_scratch_alloc + ((word)(sizeof(page_hash_table))); + if (GC_old_normal_bl == 0 || GC_incomplete_normal_bl == 0) { + GC_err_printf0("Insufficient memory for black list\n"); + EXIT(); + } + GC_clear_bl(GC_old_normal_bl); + GC_clear_bl(GC_incomplete_normal_bl); +# endif + GC_old_stack_bl = (word *)GC_scratch_alloc((word)(sizeof(page_hash_table))); + GC_incomplete_stack_bl = (word *)GC_scratch_alloc + ((word)(sizeof(page_hash_table))); + if (GC_old_stack_bl == 0 || GC_incomplete_stack_bl == 0) { + GC_err_printf0("Insufficient memory for black list\n"); + EXIT(); + } + GC_clear_bl(GC_old_stack_bl); + GC_clear_bl(GC_incomplete_stack_bl); +} + +void GC_clear_bl(doomed) +word *doomed; +{ + BZERO(doomed, sizeof(page_hash_table)); +} + +void GC_copy_bl(old, new) +word *new, *old; +{ + BCOPY(old, new, sizeof(page_hash_table)); +} + +static word total_stack_black_listed(); + +/* Signal the completion of a collection. Turn the incomplete black */ +/* lists into new black lists, etc. */ +void GC_promote_black_lists() +{ + word * very_old_normal_bl = GC_old_normal_bl; + word * very_old_stack_bl = GC_old_stack_bl; + + GC_old_normal_bl = GC_incomplete_normal_bl; + GC_old_stack_bl = GC_incomplete_stack_bl; +# ifndef ALL_INTERIOR_POINTERS + GC_clear_bl(very_old_normal_bl); +# endif + GC_clear_bl(very_old_stack_bl); + GC_incomplete_normal_bl = very_old_normal_bl; + GC_incomplete_stack_bl = very_old_stack_bl; + GC_total_stack_black_listed = total_stack_black_listed(); +# ifdef PRINTSTATS + GC_printf1("%ld bytes in heap blacklisted for interior pointers\n", + (unsigned long)GC_total_stack_black_listed); +# endif + if (GC_total_stack_black_listed != 0) { + GC_black_list_spacing = + HBLKSIZE*(GC_heapsize/GC_total_stack_black_listed); + } + if (GC_black_list_spacing < 3 * HBLKSIZE) { + GC_black_list_spacing = 3 * HBLKSIZE; + } +} + +void GC_unpromote_black_lists() +{ +# ifndef ALL_INTERIOR_POINTERS + GC_copy_bl(GC_old_normal_bl, GC_incomplete_normal_bl); +# endif + GC_copy_bl(GC_old_stack_bl, GC_incomplete_stack_bl); +} + +# ifndef ALL_INTERIOR_POINTERS +/* P is not a valid pointer reference, but it falls inside */ +/* the plausible heap bounds. */ +/* Add it to the normal incomplete black list if appropriate. */ +#ifdef PRINT_BLACK_LIST + void GC_add_to_black_list_normal(p, source) + ptr_t source; +#else + void GC_add_to_black_list_normal(p) +#endif +word p; +{ + if (!(GC_modws_valid_offsets[p & (sizeof(word)-1)])) return; + { + register int index = PHT_HASH(p); + + if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_normal_bl, index)) { +# ifdef PRINT_BLACK_LIST + if (!get_pht_entry_from_index(GC_incomplete_normal_bl, index)) { + GC_err_printf2( + "Black listing (normal) 0x%lx referenced from 0x%lx ", + (unsigned long) p, (unsigned long) source); + GC_print_source_ptr(source); + GC_err_puts("\n"); + } +# endif + set_pht_entry_from_index(GC_incomplete_normal_bl, index); + } /* else this is probably just an interior pointer to an allocated */ + /* object, and isn't worth black listing. */ + } +} +# endif + +/* And the same for false pointers from the stack. */ +#ifdef PRINT_BLACK_LIST + void GC_add_to_black_list_stack(p, source) + ptr_t source; +#else + void GC_add_to_black_list_stack(p) +#endif +word p; +{ + register int index = PHT_HASH(p); + + if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_stack_bl, index)) { +# ifdef PRINT_BLACK_LIST + if (!get_pht_entry_from_index(GC_incomplete_stack_bl, index)) { + GC_err_printf2( + "Black listing (stack) 0x%lx referenced from 0x%lx ", + (unsigned long)p, (unsigned long)source); + GC_print_source_ptr(source); + GC_err_puts("\n"); + } +# endif + set_pht_entry_from_index(GC_incomplete_stack_bl, index); + } +} + +/* + * Is the block starting at h of size len bytes black listed? If so, + * return the address of the next plausible r such that (r, len) might not + * be black listed. (R may not actually be in the heap. We guarantee only + * that every smaller value of r after h is also black listed.) + * If (h,len) is not black listed, return 0. + * Knows about the structure of the black list hash tables. + */ +struct hblk * GC_is_black_listed(h, len) +struct hblk * h; +word len; +{ + register int index = PHT_HASH((word)h); + register word i; + word nblocks = divHBLKSZ(len); + +# ifndef ALL_INTERIOR_POINTERS + if (get_pht_entry_from_index(GC_old_normal_bl, index) + || get_pht_entry_from_index(GC_incomplete_normal_bl, index)) { + return(h+1); + } +# endif + + for (i = 0; ; ) { + if (GC_old_stack_bl[divWORDSZ(index)] == 0 + && GC_incomplete_stack_bl[divWORDSZ(index)] == 0) { + /* An easy case */ + i += WORDSZ - modWORDSZ(index); + } else { + if (get_pht_entry_from_index(GC_old_stack_bl, index) + || get_pht_entry_from_index(GC_incomplete_stack_bl, index)) { + return(h+i+1); + } + i++; + } + if (i >= nblocks) break; + index = PHT_HASH((word)(h+i)); + } + return(0); +} + + +/* Return the number of blacklisted blocks in a given range. */ +/* Used only for statistical purposes. */ +/* Looks only at the GC_incomplete_stack_bl. */ +word GC_number_stack_black_listed(start, endp1) +struct hblk *start, *endp1; +{ + register struct hblk * h; + word result = 0; + + for (h = start; h < endp1; h++) { + register int index = PHT_HASH((word)h); + + if (get_pht_entry_from_index(GC_old_stack_bl, index)) result++; + } + return(result); +} + + +/* Return the total number of (stack) black-listed bytes. */ +static word total_stack_black_listed() +{ + register unsigned i; + word total = 0; + + for (i = 0; i < GC_n_heap_sects; i++) { + struct hblk * start = (struct hblk *) GC_heap_sects[i].hs_start; + word len = (word) GC_heap_sects[i].hs_bytes; + struct hblk * endp1 = start + len/HBLKSIZE; + + total += GC_number_stack_black_listed(start, endp1); + } + return(total * HBLKSIZE); +} + diff --git a/support/gc/callprocs b/support/gc/callprocs new file mode 100755 index 00000000..a8793f0b --- /dev/null +++ b/support/gc/callprocs @@ -0,0 +1,4 @@ +#!/bin/sh +GC_DEBUG=1 +export GC_DEBUG +$* 2>&1 | awk '{print "0x3e=c\""$0"\""};/^\t##PC##=/ {if ($2 != 0) {print $2"?i"}}' | adb $1 | sed "s/^ >/>/" diff --git a/support/gc/checksums.c b/support/gc/checksums.c new file mode 100644 index 00000000..212655f4 --- /dev/null +++ b/support/gc/checksums.c @@ -0,0 +1,201 @@ +/* + * Copyright (c) 1992-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, March 29, 1995 12:51 pm PST */ +# ifdef CHECKSUMS + +# include "gc_priv.h" + +/* This is debugging code intended to verify the results of dirty bit */ +/* computations. Works only in a single threaded environment. */ +/* We assume that stubborn objects are changed only when they are */ +/* enabled for writing. (Certain kinds of writing are actually */ +/* safe under other conditions.) */ +# define NSUMS 2000 + +# define OFFSET 0x10000 + +typedef struct { + GC_bool new_valid; + word old_sum; + word new_sum; + struct hblk * block; /* Block to which this refers + OFFSET */ + /* to hide it from colector. */ +} page_entry; + +page_entry GC_sums [NSUMS]; + +word GC_checksum(h) +struct hblk *h; +{ + register word *p = (word *)h; + register word *lim = (word *)(h+1); + register word result = 0; + + while (p < lim) { + result += *p++; + } + return(result | 0x80000000 /* doesn't look like pointer */); +} + +# ifdef STUBBORN_ALLOC +/* Check whether a stubborn object from the given block appears on */ +/* the appropriate free list. */ +GC_bool GC_on_free_list(h) +struct hblk *h; +{ + register hdr * hhdr = HDR(h); + register int sz = hhdr -> hb_sz; + ptr_t p; + + if (sz > MAXOBJSZ) return(FALSE); + for (p = GC_sobjfreelist[sz]; p != 0; p = obj_link(p)) { + if (HBLKPTR(p) == h) return(TRUE); + } + return(FALSE); +} +# endif + +int GC_n_dirty_errors; +int GC_n_changed_errors; +int GC_n_clean; +int GC_n_dirty; + +void GC_update_check_page(h, index) +struct hblk *h; +int index; +{ + page_entry *pe = GC_sums + index; + register hdr * hhdr = HDR(h); + + if (pe -> block != 0 && pe -> block != h + OFFSET) ABORT("goofed"); + pe -> old_sum = pe -> new_sum; + pe -> new_sum = GC_checksum(h); +# ifndef MSWIN32 + if (pe -> new_sum != 0 && !GC_page_was_ever_dirty(h)) { + GC_printf1("GC_page_was_ever_dirty(0x%lx) is wrong\n", + (unsigned long)h); + } +# endif + if (GC_page_was_dirty(h)) { + GC_n_dirty++; + } else { + GC_n_clean++; + } + if (pe -> new_valid && pe -> old_sum != pe -> new_sum) { + if (!GC_page_was_dirty(h) || !GC_page_was_ever_dirty(h)) { + /* Set breakpoint here */GC_n_dirty_errors++; + } +# ifdef STUBBORN_ALLOC + if (!IS_FORWARDING_ADDR_OR_NIL(hhdr) + && hhdr -> hb_map != GC_invalid_map + && hhdr -> hb_obj_kind == STUBBORN + && !GC_page_was_changed(h) + && !GC_on_free_list(h)) { + /* if GC_on_free_list(h) then reclaim may have touched it */ + /* without any allocations taking place. */ + /* Set breakpoint here */GC_n_changed_errors++; + } +# endif + } + pe -> new_valid = TRUE; + pe -> block = h + OFFSET; +} + +word GC_bytes_in_used_blocks; + +void GC_add_block(h, dummy) +struct hblk *h; +word dummy; +{ + register hdr * hhdr = HDR(h); + register bytes = WORDS_TO_BYTES(hhdr -> hb_sz); + + bytes += HDR_BYTES + HBLKSIZE-1; + bytes &= ~(HBLKSIZE-1); + GC_bytes_in_used_blocks += bytes; +} + +void GC_check_blocks() +{ + word bytes_in_free_blocks = 0; + struct hblk * h = GC_hblkfreelist; + hdr * hhdr = HDR(h); + word sz; + + GC_bytes_in_used_blocks = 0; + GC_apply_to_all_blocks(GC_add_block, (word)0); + while (h != 0) { + sz = hhdr -> hb_sz; + bytes_in_free_blocks += sz; + h = hhdr -> hb_next; + hhdr = HDR(h); + } + GC_printf2("GC_bytes_in_used_blocks = %ld, bytes_in_free_blocks = %ld ", + GC_bytes_in_used_blocks, bytes_in_free_blocks); + GC_printf1("GC_heapsize = %ld\n", GC_heapsize); + if (GC_bytes_in_used_blocks + bytes_in_free_blocks != GC_heapsize) { + GC_printf0("LOST SOME BLOCKS!!\n"); + } +} + +/* Should be called immediately after GC_read_dirty and GC_read_changed. */ +void GC_check_dirty() +{ + register int index; + register unsigned i; + register struct hblk *h; + register ptr_t start; + + GC_check_blocks(); + + GC_n_dirty_errors = 0; + GC_n_changed_errors = 0; + GC_n_clean = 0; + GC_n_dirty = 0; + + index = 0; + for (i = 0; i < GC_n_heap_sects; i++) { + start = GC_heap_sects[i].hs_start; + for (h = (struct hblk *)start; + h < (struct hblk *)(start + GC_heap_sects[i].hs_bytes); + h++) { + GC_update_check_page(h, index); + index++; + if (index >= NSUMS) goto out; + } + } +out: + GC_printf2("Checked %lu clean and %lu dirty pages\n", + (unsigned long) GC_n_clean, (unsigned long) GC_n_dirty); + if (GC_n_dirty_errors > 0) { + GC_printf1("Found %lu dirty bit errors\n", + (unsigned long)GC_n_dirty_errors); + } + if (GC_n_changed_errors > 0) { + GC_printf1("Found %lu changed bit errors\n", + (unsigned long)GC_n_changed_errors); + GC_printf0("These may be benign (provoked by nonpointer changes)\n"); +# ifdef THREADS + GC_printf0( + "Also expect 1 per thread currently allocating a stubborn obj.\n"); +# endif + } +} + +# else + +extern int GC_quiet; + /* ANSI C doesn't allow translation units to be empty. */ + /* So we guarantee this one is nonempty. */ + +# endif /* CHECKSUMS */ diff --git a/support/gc/clean.mk b/support/gc/clean.mk new file mode 100644 index 00000000..87aceebf --- /dev/null +++ b/support/gc/clean.mk @@ -0,0 +1,24 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + rm -f if_mach if_not_there threadlibs + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f config.cache config.log config.status + rm -f ddconfig.h main.mk *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/support/gc/conf.mk b/support/gc/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/support/gc/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/support/gc/cord/README b/support/gc/cord/README new file mode 100644 index 00000000..62101452 --- /dev/null +++ b/support/gc/cord/README @@ -0,0 +1,31 @@ +Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + +Permission is hereby granted to use or copy this program +for any purpose, provided the above notices are retained on all copies. +Permission to modify the code and to distribute modified code is granted, +provided the above notices are retained, and a notice that the code was +modified is included with the above copyright notice. + +Please send bug reports to Hans-J. Boehm (boehm@sgi.com). + +This is a string packages that uses a tree-based representation. +See cord.h for a description of the functions provided. Ec.h describes +"extensible cords", which are essentially output streams that write +to a cord. These allow for efficient construction of cords without +requiring a bound on the size of a cord. + +de.c is a very dumb text editor that illustrates the use of cords. +It maintains a list of file versions. Each version is simply a +cord representing the file contents. Nonetheless, standard +editing operations are efficient, even on very large files. +(Its 3 line "user manual" can be obtained by invoking it without +arguments. Note that ^R^N and ^R^P move the cursor by +almost a screen. It does not understand tabs, which will show +up as highlighred "I"s. Use the UNIX "expand" program first.) +To build the editor, type "make cord/de" in the gc directory. + +This package assumes an ANSI C compiler such as gcc. It will +not compile with an old-style K&R compiler. diff --git a/support/gc/cord/SCOPTIONS.amiga b/support/gc/cord/SCOPTIONS.amiga new file mode 100644 index 00000000..2a091970 --- /dev/null +++ b/support/gc/cord/SCOPTIONS.amiga @@ -0,0 +1,14 @@ +MATH=STANDARD +CPU=68030 +NOSTACKCHECK +OPTIMIZE +VERBOSE +NOVERSION +NOICONS +OPTIMIZERTIME +INCLUDEDIR=/ +DEFINE AMIGA +LIBRARY=cord.lib +LIBRARY=/gc.lib +IGNORE=100 +IGNORE=161 diff --git a/support/gc/cord/SMakefile.amiga b/support/gc/cord/SMakefile.amiga new file mode 100644 index 00000000..5aef131e --- /dev/null +++ b/support/gc/cord/SMakefile.amiga @@ -0,0 +1,20 @@ +# Makefile for cord.lib +# Michel Schinz 1994/07/20 + +OBJS = cordbscs.o cordprnt.o cordxtra.o + +all: cord.lib cordtest + +cordbscs.o: cordbscs.c +cordprnt.o: cordprnt.c +cordxtra.o: cordxtra.c +cordtest.o: cordtest.c + +cord.lib: $(OBJS) + oml cord.lib r $(OBJS) + +cordtest: cordtest.o cord.lib + sc cordtest.o link + +clean: + delete cord.lib cordtest \#?.o \#?.lnk diff --git a/support/gc/cord/cord.h b/support/gc/cord/cord.h new file mode 100644 index 00000000..584112fd --- /dev/null +++ b/support/gc/cord/cord.h @@ -0,0 +1,327 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Author: Hans-J. Boehm (boehm@parc.xerox.com) + */ +/* Boehm, October 5, 1995 4:20 pm PDT */ + +/* + * Cords are immutable character strings. A number of operations + * on long cords are much more efficient than their strings.h counterpart. + * In particular, concatenation takes constant time independent of the length + * of the arguments. (Cords are represented as trees, with internal + * nodes representing concatenation and leaves consisting of either C + * strings or a functional description of the string.) + * + * The following are reasonable applications of cords. They would perform + * unacceptably if C strings were used: + * - A compiler that produces assembly language output by repeatedly + * concatenating instructions onto a cord representing the output file. + * - A text editor that converts the input file to a cord, and then + * performs editing operations by producing a new cord representing + * the file after echa character change (and keeping the old ones in an + * edit history) + * + * For optimal performance, cords should be built by + * concatenating short sections. + * This interface is designed for maximum compatibility with C strings. + * ASCII NUL characters may be embedded in cords using CORD_from_fn. + * This is handled correctly, but CORD_to_char_star will produce a string + * with embedded NULs when given such a cord. + * + * This interface is fairly big, largely for performance reasons. + * The most basic constants and functions: + * + * CORD - the type fo a cord; + * CORD_EMPTY - empty cord; + * CORD_len(cord) - length of a cord; + * CORD_cat(cord1,cord2) - concatenation of two cords; + * CORD_substr(cord, start, len) - substring (or subcord); + * CORD_pos i; CORD_FOR(i, cord) { ... CORD_pos_fetch(i) ... } - + * examine each character in a cord. CORD_pos_fetch(i) is the char. + * CORD_fetch(int i) - Retrieve i'th character (slowly). + * CORD_cmp(cord1, cord2) - compare two cords. + * CORD_from_file(FILE * f) - turn a read-only file into a cord. + * CORD_to_char_star(cord) - convert to C string. + * (Non-NULL C constant strings are cords.) + * CORD_printf (etc.) - cord version of printf. Use %r for cords. + */ +# ifndef CORD_H + +# define CORD_H +# include +# include +/* Cords have type const char *. This is cheating quite a bit, and not */ +/* 100% portable. But it means that nonempty character string */ +/* constants may be used as cords directly, provided the string is */ +/* never modified in place. The empty cord is represented by, and */ +/* can be written as, 0. */ + +typedef const char * CORD; + +/* An empty cord is always represented as nil */ +# define CORD_EMPTY 0 + +/* Is a nonempty cord represented as a C string? */ +#define CORD_IS_STRING(s) (*(s) != '\0') + +/* Concatenate two cords. If the arguments are C strings, they may */ +/* not be subsequently altered. */ +CORD CORD_cat(CORD x, CORD y); + +/* Concatenate a cord and a C string with known length. Except for the */ +/* empty string case, this is a special case of CORD_cat. Since the */ +/* length is known, it can be faster. */ +/* The string y is shared with the resulting CORD. Hence it should */ +/* not be altered by the caller. */ +CORD CORD_cat_char_star(CORD x, const char * y, size_t leny); + +/* Compute the length of a cord */ +size_t CORD_len(CORD x); + +/* Cords may be represented by functions defining the ith character */ +typedef char (* CORD_fn)(size_t i, void * client_data); + +/* Turn a functional description into a cord. */ +CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len); + +/* Return the substring (subcord really) of x with length at most n, */ +/* starting at position i. (The initial character has position 0.) */ +CORD CORD_substr(CORD x, size_t i, size_t n); + +/* Return the argument, but rebalanced to allow more efficient */ +/* character retrieval, substring operations, and comparisons. */ +/* This is useful only for cords that were built using repeated */ +/* concatenation. Guarantees log time access to the result, unless */ +/* x was obtained through a large number of repeated substring ops */ +/* or the embedded functional descriptions take longer to evaluate. */ +/* May reallocate significant parts of the cord. The argument is not */ +/* modified; only the result is balanced. */ +CORD CORD_balance(CORD x); + +/* The following traverse a cord by applying a function to each */ +/* character. This is occasionally appropriate, especially where */ +/* speed is crucial. But, since C doesn't have nested functions, */ +/* clients of this sort of traversal are clumsy to write. Consider */ +/* the functions that operate on cord positions instead. */ + +/* Function to iteratively apply to individual characters in cord. */ +typedef int (* CORD_iter_fn)(char c, void * client_data); + +/* Function to apply to substrings of a cord. Each substring is a */ +/* a C character string, not a general cord. */ +typedef int (* CORD_batched_iter_fn)(const char * s, void * client_data); +# define CORD_NO_FN ((CORD_batched_iter_fn)0) + +/* Apply f1 to each character in the cord, in ascending order, */ +/* starting at position i. If */ +/* f2 is not CORD_NO_FN, then multiple calls to f1 may be replaced by */ +/* a single call to f2. The parameter f2 is provided only to allow */ +/* some optimization by the client. This terminates when the right */ +/* end of this string is reached, or when f1 or f2 return != 0. In the */ +/* latter case CORD_iter returns != 0. Otherwise it returns 0. */ +/* The specified value of i must be < CORD_len(x). */ +int CORD_iter5(CORD x, size_t i, CORD_iter_fn f1, + CORD_batched_iter_fn f2, void * client_data); + +/* A simpler version that starts at 0, and without f2: */ +int CORD_iter(CORD x, CORD_iter_fn f1, void * client_data); +# define CORD_iter(x, f1, cd) CORD_iter5(x, 0, f1, CORD_NO_FN, cd) + +/* Similar to CORD_iter5, but end-to-beginning. No provisions for */ +/* CORD_batched_iter_fn. */ +int CORD_riter4(CORD x, size_t i, CORD_iter_fn f1, void * client_data); + +/* A simpler version that starts at the end: */ +int CORD_riter(CORD x, CORD_iter_fn f1, void * client_data); + +/* Functions that operate on cord positions. The easy way to traverse */ +/* cords. A cord position is logically a pair consisting of a cord */ +/* and an index into that cord. But it is much faster to retrieve a */ +/* charcter based on a position than on an index. Unfortunately, */ +/* positions are big (order of a few 100 bytes), so allocate them with */ +/* caution. */ +/* Things in cord_pos.h should be treated as opaque, except as */ +/* described below. Also note that */ +/* CORD_pos_fetch, CORD_next and CORD_prev have both macro and function */ +/* definitions. The former may evaluate their argument more than once. */ +# include "private/cord_pos.h" + +/* + Visible definitions from above: + + typedef CORD_pos[1]; + + * Extract the cord from a position: + CORD CORD_pos_to_cord(CORD_pos p); + + * Extract the current index from a position: + size_t CORD_pos_to_index(CORD_pos p); + + * Fetch the character located at the given position: + char CORD_pos_fetch(CORD_pos p); + + * Initialize the position to refer to the given cord and index. + * Note that this is the most expensive function on positions: + void CORD_set_pos(CORD_pos p, CORD x, size_t i); + + * Advance the position to the next character. + * P must be initialized and valid. + * Invalidates p if past end: + void CORD_next(CORD_pos p); + + * Move the position to the preceding character. + * P must be initialized and valid. + * Invalidates p if past beginning: + void CORD_prev(CORD_pos p); + + * Is the position valid, i.e. inside the cord? + int CORD_pos_valid(CORD_pos p); +*/ +# define CORD_FOR(pos, cord) \ + for (CORD_set_pos(pos, cord, 0); CORD_pos_valid(pos); CORD_next(pos)) + + +/* An out of memory handler to call. May be supplied by client. */ +/* Must not return. */ +extern void (* CORD_oom_fn)(void); + +/* Dump the representation of x to stdout in an implementation defined */ +/* manner. Intended for debugging only. */ +void CORD_dump(CORD x); + +/* The following could easily be implemented by the client. They are */ +/* provided in cordxtra.c for convenience. */ + +/* Concatenate a character to the end of a cord. */ +CORD CORD_cat_char(CORD x, char c); + +/* Concatenate n cords. */ +CORD CORD_catn(int n, /* CORD */ ...); + +/* Return the character in CORD_substr(x, i, 1) */ +char CORD_fetch(CORD x, size_t i); + +/* Return < 0, 0, or > 0, depending on whether x < y, x = y, x > y */ +int CORD_cmp(CORD x, CORD y); + +/* A generalization that takes both starting positions for the */ +/* comparison, and a limit on the number of characters to be compared. */ +int CORD_ncmp(CORD x, size_t x_start, CORD y, size_t y_start, size_t len); + +/* Find the first occurrence of s in x at position start or later. */ +/* Return the position of the first character of s in x, or */ +/* CORD_NOT_FOUND if there is none. */ +size_t CORD_str(CORD x, size_t start, CORD s); + +/* Return a cord consisting of i copies of (possibly NUL) c. Dangerous */ +/* in conjunction with CORD_to_char_star. */ +/* The resulting representation takes constant space, independent of i. */ +CORD CORD_chars(char c, size_t i); +# define CORD_nul(i) CORD_chars('\0', (i)) + +/* Turn a file into cord. The file must be seekable. Its contents */ +/* must remain constant. The file may be accessed as an immediate */ +/* result of this call and/or as a result of subsequent accesses to */ +/* the cord. Short files are likely to be immediately read, but */ +/* long files are likely to be read on demand, possibly relying on */ +/* stdio for buffering. */ +/* We must have exclusive access to the descriptor f, i.e. we may */ +/* read it at any time, and expect the file pointer to be */ +/* where we left it. Normally this should be invoked as */ +/* CORD_from_file(fopen(...)) */ +/* CORD_from_file arranges to close the file descriptor when it is no */ +/* longer needed (e.g. when the result becomes inaccessible). */ +/* The file f must be such that ftell reflects the actual character */ +/* position in the file, i.e. the number of characters that can be */ +/* or were read with fread. On UNIX systems this is always true. On */ +/* MS Windows systems, f must be opened in binary mode. */ +CORD CORD_from_file(FILE * f); + +/* Equivalent to the above, except that the entire file will be read */ +/* and the file pointer will be closed immediately. */ +/* The binary mode restriction from above does not apply. */ +CORD CORD_from_file_eager(FILE * f); + +/* Equivalent to the above, except that the file will be read on demand.*/ +/* The binary mode restriction applies. */ +CORD CORD_from_file_lazy(FILE * f); + +/* Turn a cord into a C string. The result shares no structure with */ +/* x, and is thus modifiable. */ +char * CORD_to_char_star(CORD x); + +/* Turn a C string into a CORD. The C string is copied, and so may */ +/* subsequently be modified. */ +CORD CORD_from_char_star(const char *s); + +/* Identical to the above, but the result may share structure with */ +/* the argument and is thus not modifiable. */ +const char * CORD_to_const_char_star(CORD x); + +/* Write a cord to a file, starting at the current position. No */ +/* trailing NULs are newlines are added. */ +/* Returns EOF if a write error occurs, 1 otherwise. */ +int CORD_put(CORD x, FILE * f); + +/* "Not found" result for the following two functions. */ +# define CORD_NOT_FOUND ((size_t)(-1)) + +/* A vague analog of strchr. Returns the position (an integer, not */ +/* a pointer) of the first occurrence of (char) c inside x at position */ +/* i or later. The value i must be < CORD_len(x). */ +size_t CORD_chr(CORD x, size_t i, int c); + +/* A vague analog of strrchr. Returns index of the last occurrence */ +/* of (char) c inside x at position i or earlier. The value i */ +/* must be < CORD_len(x). */ +size_t CORD_rchr(CORD x, size_t i, int c); + + +/* The following are also not primitive, but are implemented in */ +/* cordprnt.c. They provide functionality similar to the ANSI C */ +/* functions with corresponding names, but with the following */ +/* additions and changes: */ +/* 1. A %r conversion specification specifies a CORD argument. Field */ +/* width, precision, etc. have the same semantics as for %s. */ +/* (Note that %c,%C, and %S were already taken.) */ +/* 2. The format string is represented as a CORD. */ +/* 3. CORD_sprintf and CORD_vsprintf assign the result through the 1st */ /* argument. Unlike their ANSI C versions, there is no need to guess */ +/* the correct buffer size. */ +/* 4. Most of the conversions are implement through the native */ +/* vsprintf. Hence they are usually no faster, and */ +/* idiosyncracies of the native printf are preserved. However, */ +/* CORD arguments to CORD_sprintf and CORD_vsprintf are NOT copied; */ +/* the result shares the original structure. This may make them */ +/* very efficient in some unusual applications. */ +/* The format string is copied. */ +/* All functions return the number of characters generated or -1 on */ +/* error. This complies with the ANSI standard, but is inconsistent */ +/* with some older implementations of sprintf. */ + +/* The implementation of these is probably less portable than the rest */ +/* of this package. */ + +#ifndef CORD_NO_IO + +#include + +int CORD_sprintf(CORD * out, CORD format, ...); +int CORD_vsprintf(CORD * out, CORD format, va_list args); +int CORD_fprintf(FILE * f, CORD format, ...); +int CORD_vfprintf(FILE * f, CORD format, va_list args); +int CORD_printf(CORD format, ...); +int CORD_vprintf(CORD format, va_list args); + +#endif /* CORD_NO_IO */ + +# endif /* CORD_H */ diff --git a/support/gc/cord/cordbscs.c b/support/gc/cord/cordbscs.c new file mode 100644 index 00000000..b75f5812 --- /dev/null +++ b/support/gc/cord/cordbscs.c @@ -0,0 +1,916 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Author: Hans-J. Boehm (boehm@parc.xerox.com) + */ +/* Boehm, October 3, 1994 5:19 pm PDT */ +# include "gc.h" +# include "cord.h" +# include +# include +# include + +/* An implementation of the cord primitives. These are the only */ +/* Functions that understand the representation. We perform only */ +/* minimal checks on arguments to these functions. Out of bounds */ +/* arguments to the iteration functions may result in client functions */ +/* invoked on garbage data. In most cases, client functions should be */ +/* programmed defensively enough that this does not result in memory */ +/* smashes. */ + +typedef void (* oom_fn)(void); + +oom_fn CORD_oom_fn = (oom_fn) 0; + +# define OUT_OF_MEMORY { if (CORD_oom_fn != (oom_fn) 0) (*CORD_oom_fn)(); \ + ABORT("Out of memory\n"); } +# define ABORT(msg) { fprintf(stderr, "%s\n", msg); abort(); } + +typedef unsigned long word; + +typedef union { + struct Concatenation { + char null; + char header; + char depth; /* concatenation nesting depth. */ + unsigned char left_len; + /* Length of left child if it is sufficiently */ + /* short; 0 otherwise. */ +# define MAX_LEFT_LEN 255 + word len; + CORD left; /* length(left) > 0 */ + CORD right; /* length(right) > 0 */ + } concatenation; + struct Function { + char null; + char header; + char depth; /* always 0 */ + char left_len; /* always 0 */ + word len; + CORD_fn fn; + void * client_data; + } function; + struct Generic { + char null; + char header; + char depth; + char left_len; + word len; + } generic; + char string[1]; +} CordRep; + +# define CONCAT_HDR 1 + +# define FN_HDR 4 +# define SUBSTR_HDR 6 + /* Substring nodes are a special case of function nodes. */ + /* The client_data field is known to point to a substr_args */ + /* structure, and the function is either CORD_apply_access_fn */ + /* or CORD_index_access_fn. */ + +/* The following may be applied only to function and concatenation nodes: */ +#define IS_CONCATENATION(s) (((CordRep *)s)->generic.header == CONCAT_HDR) + +#define IS_FUNCTION(s) ((((CordRep *)s)->generic.header & FN_HDR) != 0) + +#define IS_SUBSTR(s) (((CordRep *)s)->generic.header == SUBSTR_HDR) + +#define LEN(s) (((CordRep *)s) -> generic.len) +#define DEPTH(s) (((CordRep *)s) -> generic.depth) +#define GEN_LEN(s) (CORD_IS_STRING(s) ? strlen(s) : LEN(s)) + +#define LEFT_LEN(c) ((c) -> left_len != 0? \ + (c) -> left_len \ + : (CORD_IS_STRING((c) -> left) ? \ + (c) -> len - GEN_LEN((c) -> right) \ + : LEN((c) -> left))) + +#define SHORT_LIMIT (sizeof(CordRep) - 1) + /* Cords shorter than this are C strings */ + + +/* Dump the internal representation of x to stdout, with initial */ +/* indentation level n. */ +void CORD_dump_inner(CORD x, unsigned n) +{ + register size_t i; + + for (i = 0; i < (size_t)n; i++) { + fputs(" ", stdout); + } + if (x == 0) { + fputs("NIL\n", stdout); + } else if (CORD_IS_STRING(x)) { + for (i = 0; i <= SHORT_LIMIT; i++) { + if (x[i] == '\0') break; + putchar(x[i]); + } + if (x[i] != '\0') fputs("...", stdout); + putchar('\n'); + } else if (IS_CONCATENATION(x)) { + register struct Concatenation * conc = + &(((CordRep *)x) -> concatenation); + printf("Concatenation: %p (len: %d, depth: %d)\n", + x, (int)(conc -> len), (int)(conc -> depth)); + CORD_dump_inner(conc -> left, n+1); + CORD_dump_inner(conc -> right, n+1); + } else /* function */{ + register struct Function * func = + &(((CordRep *)x) -> function); + if (IS_SUBSTR(x)) printf("(Substring) "); + printf("Function: %p (len: %d): ", x, (int)(func -> len)); + for (i = 0; i < 20 && i < func -> len; i++) { + putchar((*(func -> fn))(i, func -> client_data)); + } + if (i < func -> len) fputs("...", stdout); + putchar('\n'); + } +} + +/* Dump the internal representation of x to stdout */ +void CORD_dump(CORD x) +{ + CORD_dump_inner(x, 0); + fflush(stdout); +} + +CORD CORD_cat_char_star(CORD x, const char * y, size_t leny) +{ + register size_t result_len; + register size_t lenx; + register int depth; + + if (x == CORD_EMPTY) return(y); + if (leny == 0) return(x); + if (CORD_IS_STRING(x)) { + lenx = strlen(x); + result_len = lenx + leny; + if (result_len <= SHORT_LIMIT) { + register char * result = GC_MALLOC_ATOMIC(result_len+1); + + if (result == 0) OUT_OF_MEMORY; + memcpy(result, x, lenx); + memcpy(result + lenx, y, leny); + result[result_len] = '\0'; + return((CORD) result); + } else { + depth = 1; + } + } else { + register CORD right; + register CORD left; + register char * new_right; + register size_t right_len; + + lenx = LEN(x); + + if (leny <= SHORT_LIMIT/2 + && IS_CONCATENATION(x) + && CORD_IS_STRING(right = ((CordRep *)x) -> concatenation.right)) { + /* Merge y into right part of x. */ + if (!CORD_IS_STRING(left = ((CordRep *)x) -> concatenation.left)) { + right_len = lenx - LEN(left); + } else if (((CordRep *)x) -> concatenation.left_len != 0) { + right_len = lenx - ((CordRep *)x) -> concatenation.left_len; + } else { + right_len = strlen(right); + } + result_len = right_len + leny; /* length of new_right */ + if (result_len <= SHORT_LIMIT) { + new_right = GC_MALLOC_ATOMIC(result_len + 1); + memcpy(new_right, right, right_len); + memcpy(new_right + right_len, y, leny); + new_right[result_len] = '\0'; + y = new_right; + leny = result_len; + x = left; + lenx -= right_len; + /* Now fall through to concatenate the two pieces: */ + } + if (CORD_IS_STRING(x)) { + depth = 1; + } else { + depth = DEPTH(x) + 1; + } + } else { + depth = DEPTH(x) + 1; + } + result_len = lenx + leny; + } + { + /* The general case; lenx, result_len is known: */ + register struct Concatenation * result; + + result = GC_NEW(struct Concatenation); + if (result == 0) OUT_OF_MEMORY; + result->header = CONCAT_HDR; + result->depth = depth; + if (lenx <= MAX_LEFT_LEN) result->left_len = lenx; + result->len = result_len; + result->left = x; + result->right = y; + if (depth > MAX_DEPTH) { + return(CORD_balance((CORD)result)); + } else { + return((CORD) result); + } + } +} + + +CORD CORD_cat(CORD x, CORD y) +{ + register size_t result_len; + register int depth; + register size_t lenx; + + if (x == CORD_EMPTY) return(y); + if (y == CORD_EMPTY) return(x); + if (CORD_IS_STRING(y)) { + return(CORD_cat_char_star(x, y, strlen(y))); + } else if (CORD_IS_STRING(x)) { + lenx = strlen(x); + depth = DEPTH(y) + 1; + } else { + register int depthy = DEPTH(y); + + lenx = LEN(x); + depth = DEPTH(x) + 1; + if (depthy >= depth) depth = depthy + 1; + } + result_len = lenx + LEN(y); + { + register struct Concatenation * result; + + result = GC_NEW(struct Concatenation); + if (result == 0) OUT_OF_MEMORY; + result->header = CONCAT_HDR; + result->depth = depth; + if (lenx <= MAX_LEFT_LEN) result->left_len = lenx; + result->len = result_len; + result->left = x; + result->right = y; + return((CORD) result); + } +} + + + +CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len) +{ + if (len <= 0) return(0); + if (len <= SHORT_LIMIT) { + register char * result; + register size_t i; + char buf[SHORT_LIMIT+1]; + register char c; + + for (i = 0; i < len; i++) { + c = (*fn)(i, client_data); + if (c == '\0') goto gen_case; + buf[i] = c; + } + buf[i] = '\0'; + result = GC_MALLOC_ATOMIC(len+1); + if (result == 0) OUT_OF_MEMORY; + strcpy(result, buf); + result[len] = '\0'; + return((CORD) result); + } + gen_case: + { + register struct Function * result; + + result = GC_NEW(struct Function); + if (result == 0) OUT_OF_MEMORY; + result->header = FN_HDR; + /* depth is already 0 */ + result->len = len; + result->fn = fn; + result->client_data = client_data; + return((CORD) result); + } +} + +size_t CORD_len(CORD x) +{ + if (x == 0) { + return(0); + } else { + return(GEN_LEN(x)); + } +} + +struct substr_args { + CordRep * sa_cord; + size_t sa_index; +}; + +char CORD_index_access_fn(size_t i, void * client_data) +{ + register struct substr_args *descr = (struct substr_args *)client_data; + + return(((char *)(descr->sa_cord))[i + descr->sa_index]); +} + +char CORD_apply_access_fn(size_t i, void * client_data) +{ + register struct substr_args *descr = (struct substr_args *)client_data; + register struct Function * fn_cord = &(descr->sa_cord->function); + + return((*(fn_cord->fn))(i + descr->sa_index, fn_cord->client_data)); +} + +/* A version of CORD_substr that simply returns a function node, thus */ +/* postponing its work. The fourth argument is a function that may */ +/* be used for efficient access to the ith character. */ +/* Assumes i >= 0 and i + n < length(x). */ +CORD CORD_substr_closure(CORD x, size_t i, size_t n, CORD_fn f) +{ + register struct substr_args * sa = GC_NEW(struct substr_args); + CORD result; + + if (sa == 0) OUT_OF_MEMORY; + sa->sa_cord = (CordRep *)x; + sa->sa_index = i; + result = CORD_from_fn(f, (void *)sa, n); + ((CordRep *)result) -> function.header = SUBSTR_HDR; + return (result); +} + +# define SUBSTR_LIMIT (10 * SHORT_LIMIT) + /* Substrings of function nodes and flat strings shorter than */ + /* this are flat strings. Othewise we use a functional */ + /* representation, which is significantly slower to access. */ + +/* A version of CORD_substr that assumes i >= 0, n > 0, and i + n < length(x).*/ +CORD CORD_substr_checked(CORD x, size_t i, size_t n) +{ + if (CORD_IS_STRING(x)) { + if (n > SUBSTR_LIMIT) { + return(CORD_substr_closure(x, i, n, CORD_index_access_fn)); + } else { + register char * result = GC_MALLOC_ATOMIC(n+1); + register char * p = result; + + if (result == 0) OUT_OF_MEMORY; + strncpy(result, x+i, n); + result[n] = '\0'; + return(result); + } + } else if (IS_CONCATENATION(x)) { + register struct Concatenation * conc + = &(((CordRep *)x) -> concatenation); + register size_t left_len; + register size_t right_len; + + left_len = LEFT_LEN(conc); + right_len = conc -> len - left_len; + if (i >= left_len) { + if (n == right_len) return(conc -> right); + return(CORD_substr_checked(conc -> right, i - left_len, n)); + } else if (i+n <= left_len) { + if (n == left_len) return(conc -> left); + return(CORD_substr_checked(conc -> left, i, n)); + } else { + /* Need at least one character from each side. */ + register CORD left_part; + register CORD right_part; + register size_t left_part_len = left_len - i; + + if (i == 0) { + left_part = conc -> left; + } else { + left_part = CORD_substr_checked(conc -> left, i, left_part_len); + } + if (i + n == right_len + left_len) { + right_part = conc -> right; + } else { + right_part = CORD_substr_checked(conc -> right, 0, + n - left_part_len); + } + return(CORD_cat(left_part, right_part)); + } + } else /* function */ { + if (n > SUBSTR_LIMIT) { + if (IS_SUBSTR(x)) { + /* Avoid nesting substring nodes. */ + register struct Function * f = &(((CordRep *)x) -> function); + register struct substr_args *descr = + (struct substr_args *)(f -> client_data); + + return(CORD_substr_closure((CORD)descr->sa_cord, + i + descr->sa_index, + n, f -> fn)); + } else { + return(CORD_substr_closure(x, i, n, CORD_apply_access_fn)); + } + } else { + char * result; + register struct Function * f = &(((CordRep *)x) -> function); + char buf[SUBSTR_LIMIT+1]; + register char * p = buf; + register char c; + register int j; + register int lim = i + n; + + for (j = i; j < lim; j++) { + c = (*(f -> fn))(j, f -> client_data); + if (c == '\0') { + return(CORD_substr_closure(x, i, n, CORD_apply_access_fn)); + } + *p++ = c; + } + *p = '\0'; + result = GC_MALLOC_ATOMIC(n+1); + if (result == 0) OUT_OF_MEMORY; + strcpy(result, buf); + return(result); + } + } +} + +CORD CORD_substr(CORD x, size_t i, size_t n) +{ + register size_t len = CORD_len(x); + + if (i >= len || n <= 0) return(0); + /* n < 0 is impossible in a correct C implementation, but */ + /* quite possible under SunOS 4.X. */ + if (i + n > len) n = len - i; +# ifndef __STDC__ + if (i < 0) ABORT("CORD_substr: second arg. negative"); + /* Possible only if both client and C implementation are buggy. */ + /* But empirically this happens frequently. */ +# endif + return(CORD_substr_checked(x, i, n)); +} + +/* See cord.h for definition. We assume i is in range. */ +int CORD_iter5(CORD x, size_t i, CORD_iter_fn f1, + CORD_batched_iter_fn f2, void * client_data) +{ + if (x == 0) return(0); + if (CORD_IS_STRING(x)) { + register const char *p = x+i; + + if (*p == '\0') ABORT("2nd arg to CORD_iter5 too big"); + if (f2 != CORD_NO_FN) { + return((*f2)(p, client_data)); + } else { + while (*p) { + if ((*f1)(*p, client_data)) return(1); + p++; + } + return(0); + } + } else if (IS_CONCATENATION(x)) { + register struct Concatenation * conc + = &(((CordRep *)x) -> concatenation); + + + if (i > 0) { + register size_t left_len = LEFT_LEN(conc); + + if (i >= left_len) { + return(CORD_iter5(conc -> right, i - left_len, f1, f2, + client_data)); + } + } + if (CORD_iter5(conc -> left, i, f1, f2, client_data)) { + return(1); + } + return(CORD_iter5(conc -> right, 0, f1, f2, client_data)); + } else /* function */ { + register struct Function * f = &(((CordRep *)x) -> function); + register size_t j; + register size_t lim = f -> len; + + for (j = i; j < lim; j++) { + if ((*f1)((*(f -> fn))(j, f -> client_data), client_data)) { + return(1); + } + } + return(0); + } +} + +#undef CORD_iter +int CORD_iter(CORD x, CORD_iter_fn f1, void * client_data) +{ + return(CORD_iter5(x, 0, f1, CORD_NO_FN, client_data)); +} + +int CORD_riter4(CORD x, size_t i, CORD_iter_fn f1, void * client_data) +{ + if (x == 0) return(0); + if (CORD_IS_STRING(x)) { + register const char *p = x + i; + register char c; + + for(;;) { + c = *p; + if (c == '\0') ABORT("2nd arg to CORD_riter4 too big"); + if ((*f1)(c, client_data)) return(1); + if (p == x) break; + p--; + } + return(0); + } else if (IS_CONCATENATION(x)) { + register struct Concatenation * conc + = &(((CordRep *)x) -> concatenation); + register CORD left_part = conc -> left; + register size_t left_len; + + left_len = LEFT_LEN(conc); + if (i >= left_len) { + if (CORD_riter4(conc -> right, i - left_len, f1, client_data)) { + return(1); + } + return(CORD_riter4(left_part, left_len - 1, f1, client_data)); + } else { + return(CORD_riter4(left_part, i, f1, client_data)); + } + } else /* function */ { + register struct Function * f = &(((CordRep *)x) -> function); + register size_t j; + + for (j = i; ; j--) { + if ((*f1)((*(f -> fn))(j, f -> client_data), client_data)) { + return(1); + } + if (j == 0) return(0); + } + } +} + +int CORD_riter(CORD x, CORD_iter_fn f1, void * client_data) +{ + return(CORD_riter4(x, CORD_len(x) - 1, f1, client_data)); +} + +/* + * The following functions are concerned with balancing cords. + * Strategy: + * Scan the cord from left to right, keeping the cord scanned so far + * as a forest of balanced trees of exponentialy decreasing length. + * When a new subtree needs to be added to the forest, we concatenate all + * shorter ones to the new tree in the appropriate order, and then insert + * the result into the forest. + * Crucial invariants: + * 1. The concatenation of the forest (in decreasing order) with the + * unscanned part of the rope is equal to the rope being balanced. + * 2. All trees in the forest are balanced. + * 3. forest[i] has depth at most i. + */ + +typedef struct { + CORD c; + size_t len; /* Actual length of c */ +} ForestElement; + +static size_t min_len [ MAX_DEPTH ]; + +static int min_len_init = 0; + +int CORD_max_len; + +typedef ForestElement Forest [ MAX_DEPTH ]; + /* forest[i].len >= fib(i+1) */ + /* The string is the concatenation */ + /* of the forest in order of DECREASING */ + /* indices. */ + +void CORD_init_min_len() +{ + register int i; + register size_t last, previous, current; + + min_len[0] = previous = 1; + min_len[1] = last = 2; + for (i = 2; i < MAX_DEPTH; i++) { + current = last + previous; + if (current < last) /* overflow */ current = last; + min_len[i] = current; + previous = last; + last = current; + } + CORD_max_len = last - 1; + min_len_init = 1; +} + + +void CORD_init_forest(ForestElement * forest, size_t max_len) +{ + register int i; + + for (i = 0; i < MAX_DEPTH; i++) { + forest[i].c = 0; + if (min_len[i] > max_len) return; + } + ABORT("Cord too long"); +} + +/* Add a leaf to the appropriate level in the forest, cleaning */ +/* out lower levels as necessary. */ +/* Also works if x is a balanced tree of concatenations; however */ +/* in this case an extra concatenation node may be inserted above x; */ +/* This node should not be counted in the statement of the invariants. */ +void CORD_add_forest(ForestElement * forest, CORD x, size_t len) +{ + register int i = 0; + register CORD sum = CORD_EMPTY; + register size_t sum_len = 0; + + while (len > min_len[i + 1]) { + if (forest[i].c != 0) { + sum = CORD_cat(forest[i].c, sum); + sum_len += forest[i].len; + forest[i].c = 0; + } + i++; + } + /* Sum has depth at most 1 greter than what would be required */ + /* for balance. */ + sum = CORD_cat(sum, x); + sum_len += len; + /* If x was a leaf, then sum is now balanced. To see this */ + /* consider the two cases in which forest[i-1] either is or is */ + /* not empty. */ + while (sum_len >= min_len[i]) { + if (forest[i].c != 0) { + sum = CORD_cat(forest[i].c, sum); + sum_len += forest[i].len; + /* This is again balanced, since sum was balanced, and has */ + /* allowable depth that differs from i by at most 1. */ + forest[i].c = 0; + } + i++; + } + i--; + forest[i].c = sum; + forest[i].len = sum_len; +} + +CORD CORD_concat_forest(ForestElement * forest, size_t expected_len) +{ + register int i = 0; + CORD sum = 0; + size_t sum_len = 0; + + while (sum_len != expected_len) { + if (forest[i].c != 0) { + sum = CORD_cat(forest[i].c, sum); + sum_len += forest[i].len; + } + i++; + } + return(sum); +} + +/* Insert the frontier of x into forest. Balanced subtrees are */ +/* treated as leaves. This potentially adds one to the depth */ +/* of the final tree. */ +void CORD_balance_insert(CORD x, size_t len, ForestElement * forest) +{ + register int depth; + + if (CORD_IS_STRING(x)) { + CORD_add_forest(forest, x, len); + } else if (IS_CONCATENATION(x) + && ((depth = DEPTH(x)) >= MAX_DEPTH + || len < min_len[depth])) { + register struct Concatenation * conc + = &(((CordRep *)x) -> concatenation); + size_t left_len = LEFT_LEN(conc); + + CORD_balance_insert(conc -> left, left_len, forest); + CORD_balance_insert(conc -> right, len - left_len, forest); + } else /* function or balanced */ { + CORD_add_forest(forest, x, len); + } +} + + +CORD CORD_balance(CORD x) +{ + Forest forest; + register size_t len; + + if (x == 0) return(0); + if (CORD_IS_STRING(x)) return(x); + if (!min_len_init) CORD_init_min_len(); + len = LEN(x); + CORD_init_forest(forest, len); + CORD_balance_insert(x, len, forest); + return(CORD_concat_forest(forest, len)); +} + + +/* Position primitives */ + +/* Private routines to deal with the hard cases only: */ + +/* P contains a prefix of the path to cur_pos. Extend it to a full */ +/* path and set up leaf info. */ +/* Return 0 if past the end of cord, 1 o.w. */ +void CORD__extend_path(register CORD_pos p) +{ + register struct CORD_pe * current_pe = &(p[0].path[p[0].path_len]); + register CORD top = current_pe -> pe_cord; + register size_t pos = p[0].cur_pos; + register size_t top_pos = current_pe -> pe_start_pos; + register size_t top_len = GEN_LEN(top); + + /* Fill in the rest of the path. */ + while(!CORD_IS_STRING(top) && IS_CONCATENATION(top)) { + register struct Concatenation * conc = + &(((CordRep *)top) -> concatenation); + register size_t left_len; + + left_len = LEFT_LEN(conc); + current_pe++; + if (pos >= top_pos + left_len) { + current_pe -> pe_cord = top = conc -> right; + current_pe -> pe_start_pos = top_pos = top_pos + left_len; + top_len -= left_len; + } else { + current_pe -> pe_cord = top = conc -> left; + current_pe -> pe_start_pos = top_pos; + top_len = left_len; + } + p[0].path_len++; + } + /* Fill in leaf description for fast access. */ + if (CORD_IS_STRING(top)) { + p[0].cur_leaf = top; + p[0].cur_start = top_pos; + p[0].cur_end = top_pos + top_len; + } else { + p[0].cur_end = 0; + } + if (pos >= top_pos + top_len) p[0].path_len = CORD_POS_INVALID; +} + +char CORD__pos_fetch(register CORD_pos p) +{ + /* Leaf is a function node */ + struct CORD_pe * pe = &((p)[0].path[(p)[0].path_len]); + CORD leaf = pe -> pe_cord; + register struct Function * f = &(((CordRep *)leaf) -> function); + + if (!IS_FUNCTION(leaf)) ABORT("CORD_pos_fetch: bad leaf"); + return ((*(f -> fn))(p[0].cur_pos - pe -> pe_start_pos, f -> client_data)); +} + +void CORD__next(register CORD_pos p) +{ + register size_t cur_pos = p[0].cur_pos + 1; + register struct CORD_pe * current_pe = &((p)[0].path[(p)[0].path_len]); + register CORD leaf = current_pe -> pe_cord; + + /* Leaf is not a string or we're at end of leaf */ + p[0].cur_pos = cur_pos; + if (!CORD_IS_STRING(leaf)) { + /* Function leaf */ + register struct Function * f = &(((CordRep *)leaf) -> function); + register size_t start_pos = current_pe -> pe_start_pos; + register size_t end_pos = start_pos + f -> len; + + if (cur_pos < end_pos) { + /* Fill cache and return. */ + register size_t i; + register size_t limit = cur_pos + FUNCTION_BUF_SZ; + register CORD_fn fn = f -> fn; + register void * client_data = f -> client_data; + + if (limit > end_pos) { + limit = end_pos; + } + for (i = cur_pos; i < limit; i++) { + p[0].function_buf[i - cur_pos] = + (*fn)(i - start_pos, client_data); + } + p[0].cur_start = cur_pos; + p[0].cur_leaf = p[0].function_buf; + p[0].cur_end = limit; + return; + } + } + /* End of leaf */ + /* Pop the stack until we find two concatenation nodes with the */ + /* same start position: this implies we were in left part. */ + { + while (p[0].path_len > 0 + && current_pe[0].pe_start_pos != current_pe[-1].pe_start_pos) { + p[0].path_len--; + current_pe--; + } + if (p[0].path_len == 0) { + p[0].path_len = CORD_POS_INVALID; + return; + } + } + p[0].path_len--; + CORD__extend_path(p); +} + +void CORD__prev(register CORD_pos p) +{ + register struct CORD_pe * pe = &(p[0].path[p[0].path_len]); + + if (p[0].cur_pos == 0) { + p[0].path_len = CORD_POS_INVALID; + return; + } + p[0].cur_pos--; + if (p[0].cur_pos >= pe -> pe_start_pos) return; + + /* Beginning of leaf */ + + /* Pop the stack until we find two concatenation nodes with the */ + /* different start position: this implies we were in right part. */ + { + register struct CORD_pe * current_pe = &((p)[0].path[(p)[0].path_len]); + + while (p[0].path_len > 0 + && current_pe[0].pe_start_pos == current_pe[-1].pe_start_pos) { + p[0].path_len--; + current_pe--; + } + } + p[0].path_len--; + CORD__extend_path(p); +} + +#undef CORD_pos_fetch +#undef CORD_next +#undef CORD_prev +#undef CORD_pos_to_index +#undef CORD_pos_to_cord +#undef CORD_pos_valid + +char CORD_pos_fetch(register CORD_pos p) +{ + if (p[0].cur_start <= p[0].cur_pos && p[0].cur_pos < p[0].cur_end) { + return(p[0].cur_leaf[p[0].cur_pos - p[0].cur_start]); + } else { + return(CORD__pos_fetch(p)); + } +} + +void CORD_next(CORD_pos p) +{ + if (p[0].cur_pos < p[0].cur_end - 1) { + p[0].cur_pos++; + } else { + CORD__next(p); + } +} + +void CORD_prev(CORD_pos p) +{ + if (p[0].cur_end != 0 && p[0].cur_pos > p[0].cur_start) { + p[0].cur_pos--; + } else { + CORD__prev(p); + } +} + +size_t CORD_pos_to_index(CORD_pos p) +{ + return(p[0].cur_pos); +} + +CORD CORD_pos_to_cord(CORD_pos p) +{ + return(p[0].path[0].pe_cord); +} + +int CORD_pos_valid(CORD_pos p) +{ + return(p[0].path_len != CORD_POS_INVALID); +} + +void CORD_set_pos(CORD_pos p, CORD x, size_t i) +{ + if (x == CORD_EMPTY) { + p[0].path_len = CORD_POS_INVALID; + return; + } + p[0].path[0].pe_cord = x; + p[0].path[0].pe_start_pos = 0; + p[0].path_len = 0; + p[0].cur_pos = i; + CORD__extend_path(p); +} diff --git a/support/gc/cord/cordprnt.c b/support/gc/cord/cordprnt.c new file mode 100644 index 00000000..667560f2 --- /dev/null +++ b/support/gc/cord/cordprnt.c @@ -0,0 +1,389 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* An sprintf implementation that understands cords. This is probably */ +/* not terribly portable. It assumes an ANSI stdarg.h. It further */ +/* assumes that I can make copies of va_list variables, and read */ +/* arguments repeatedly by applyting va_arg to the copies. This */ +/* could be avoided at some performance cost. */ +/* We also assume that unsigned and signed integers of various kinds */ +/* have the same sizes, and can be cast back and forth. */ +/* We assume that void * and char * have the same size. */ +/* All this cruft is needed because we want to rely on the underlying */ +/* sprintf implementation whenever possible. */ +/* Boehm, September 21, 1995 6:00 pm PDT */ + +#include "cord.h" +#include "ec.h" +#include +#include +#include +#include "gc.h" + +#define CONV_SPEC_LEN 50 /* Maximum length of a single */ + /* conversion specification. */ +#define CONV_RESULT_LEN 50 /* Maximum length of any */ + /* conversion with default */ + /* width and prec. */ + + +static int ec_len(CORD_ec x) +{ + return(CORD_len(x[0].ec_cord) + (x[0].ec_bufptr - x[0].ec_buf)); +} + +/* Possible nonumeric precision values. */ +# define NONE -1 +# define VARIABLE -2 +/* Copy the conversion specification from CORD_pos into the buffer buf */ +/* Return negative on error. */ +/* Source initially points one past the leading %. */ +/* It is left pointing at the conversion type. */ +/* Assign field width and precision to *width and *prec. */ +/* If width or prec is *, VARIABLE is assigned. */ +/* Set *left to 1 if left adjustment flag is present. */ +/* Set *long_arg to 1 if long flag ('l' or 'L') is present, or to */ +/* -1 if 'h' is present. */ +static int extract_conv_spec(CORD_pos source, char *buf, + int * width, int *prec, int *left, int * long_arg) +{ + register int result = 0; + register int current_number = 0; + register int saw_period = 0; + register int saw_number; + register int chars_so_far = 0; + register char current; + + *width = NONE; + buf[chars_so_far++] = '%'; + while(CORD_pos_valid(source)) { + if (chars_so_far >= CONV_SPEC_LEN) return(-1); + current = CORD_pos_fetch(source); + buf[chars_so_far++] = current; + switch(current) { + case '*': + saw_number = 1; + current_number = VARIABLE; + break; + case '0': + if (!saw_number) { + /* Zero fill flag; ignore */ + break; + } /* otherwise fall through: */ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + saw_number = 1; + current_number *= 10; + current_number += current - '0'; + break; + case '.': + saw_period = 1; + if(saw_number) { + *width = current_number; + saw_number = 0; + } + current_number = 0; + break; + case 'l': + case 'L': + *long_arg = 1; + current_number = 0; + break; + case 'h': + *long_arg = -1; + current_number = 0; + break; + case ' ': + case '+': + case '#': + current_number = 0; + break; + case '-': + *left = 1; + current_number = 0; + break; + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + case 'c': + case 'C': + case 's': + case 'S': + case 'p': + case 'n': + case 'r': + goto done; + default: + return(-1); + } + CORD_next(source); + } + return(-1); + done: + if (saw_number) { + if (saw_period) { + *prec = current_number; + } else { + *prec = NONE; + *width = current_number; + } + } else { + *prec = NONE; + } + buf[chars_so_far] = '\0'; + return(result); +} + +int CORD_vsprintf(CORD * out, CORD format, va_list args) +{ + CORD_ec result; + register int count; + register char current; + CORD_pos pos; + char conv_spec[CONV_SPEC_LEN + 1]; + + CORD_ec_init(result); + for (CORD_set_pos(pos, format, 0); CORD_pos_valid(pos); CORD_next(pos)) { + current = CORD_pos_fetch(pos); + if (current == '%') { + CORD_next(pos); + if (!CORD_pos_valid(pos)) return(-1); + current = CORD_pos_fetch(pos); + if (current == '%') { + CORD_ec_append(result, current); + } else { + int width, prec; + int left_adj = 0; + int long_arg = 0; + CORD arg; + size_t len; + + if (extract_conv_spec(pos, conv_spec, + &width, &prec, + &left_adj, &long_arg) < 0) { + return(-1); + } + current = CORD_pos_fetch(pos); + switch(current) { + case 'n': + /* Assign length to next arg */ + if (long_arg == 0) { + int * pos_ptr; + pos_ptr = va_arg(args, int *); + *pos_ptr = ec_len(result); + } else if (long_arg > 0) { + long * pos_ptr; + pos_ptr = va_arg(args, long *); + *pos_ptr = ec_len(result); + } else { + short * pos_ptr; + pos_ptr = va_arg(args, short *); + *pos_ptr = ec_len(result); + } + goto done; + case 'r': + /* Append cord and any padding */ + if (width == VARIABLE) width = va_arg(args, int); + if (prec == VARIABLE) prec = va_arg(args, int); + arg = va_arg(args, CORD); + len = CORD_len(arg); + if (prec != NONE && len > prec) { + if (prec < 0) return(-1); + arg = CORD_substr(arg, 0, prec); + len = prec; + } + if (width != NONE && len < width) { + char * blanks = GC_MALLOC_ATOMIC(width-len+1); + + memset(blanks, ' ', width-len); + blanks[width-len] = '\0'; + if (left_adj) { + arg = CORD_cat(arg, blanks); + } else { + arg = CORD_cat(blanks, arg); + } + } + CORD_ec_append_cord(result, arg); + goto done; + case 'c': + if (width == NONE && prec == NONE) { + register char c = va_arg(args, char); + + CORD_ec_append(result, c); + goto done; + } + break; + case 's': + if (width == NONE && prec == NONE) { + char * str = va_arg(args, char *); + register char c; + + while (c = *str++) { + CORD_ec_append(result, c); + } + goto done; + } + break; + default: + break; + } + /* Use standard sprintf to perform conversion */ + { + register char * buf; + va_list vsprintf_args = args; + /* The above does not appear to be sanctioned */ + /* by the ANSI C standard. */ + int max_size = 0; + int res; + + if (width == VARIABLE) width = va_arg(args, int); + if (prec == VARIABLE) prec = va_arg(args, int); + if (width != NONE) max_size = width; + if (prec != NONE && prec > max_size) max_size = prec; + max_size += CONV_RESULT_LEN; + if (max_size >= CORD_BUFSZ) { + buf = GC_MALLOC_ATOMIC(max_size + 1); + } else { + if (CORD_BUFSZ - (result[0].ec_bufptr-result[0].ec_buf) + < max_size) { + CORD_ec_flush_buf(result); + } + buf = result[0].ec_bufptr; + } + switch(current) { + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + case 'c': + if (long_arg <= 0) { + (void) va_arg(args, int); + } else if (long_arg > 0) { + (void) va_arg(args, long); + } + break; + case 's': + case 'p': + (void) va_arg(args, char *); + break; + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + (void) va_arg(args, double); + break; + default: + return(-1); + } + res = vsprintf(buf, conv_spec, vsprintf_args); + len = (size_t)res; + if ((char *)(GC_word)res == buf) { + /* old style vsprintf */ + len = strlen(buf); + } else if (res < 0) { + return(-1); + } + if (buf != result[0].ec_bufptr) { + register char c; + + while (c = *buf++) { + CORD_ec_append(result, c); + } + } else { + result[0].ec_bufptr = buf + len; + } + } + done:; + } + } else { + CORD_ec_append(result, current); + } + } + count = ec_len(result); + *out = CORD_balance(CORD_ec_to_cord(result)); + return(count); +} + +int CORD_sprintf(CORD * out, CORD format, ...) +{ + va_list args; + int result; + + va_start(args, format); + result = CORD_vsprintf(out, format, args); + va_end(args); + return(result); +} + +int CORD_fprintf(FILE * f, CORD format, ...) +{ + va_list args; + int result; + CORD out; + + va_start(args, format); + result = CORD_vsprintf(&out, format, args); + va_end(args); + if (result > 0) CORD_put(out, f); + return(result); +} + +int CORD_vfprintf(FILE * f, CORD format, va_list args) +{ + int result; + CORD out; + + result = CORD_vsprintf(&out, format, args); + if (result > 0) CORD_put(out, f); + return(result); +} + +int CORD_printf(CORD format, ...) +{ + va_list args; + int result; + CORD out; + + va_start(args, format); + result = CORD_vsprintf(&out, format, args); + va_end(args); + if (result > 0) CORD_put(out, stdout); + return(result); +} + +int CORD_vprintf(CORD format, va_list args) +{ + int result; + CORD out; + + result = CORD_vsprintf(&out, format, args); + if (result > 0) CORD_put(out, stdout); + return(result); +} diff --git a/support/gc/cord/cordtest.c b/support/gc/cord/cordtest.c new file mode 100644 index 00000000..d11d7dd4 --- /dev/null +++ b/support/gc/cord/cordtest.c @@ -0,0 +1,228 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, August 24, 1994 11:58 am PDT */ +# include "cord.h" +# include +# include +/* This is a very incomplete test of the cord package. It knows about */ +/* a few internals of the package (e.g. when C strings are returned) */ +/* that real clients shouldn't rely on. */ + +# define ABORT(string) \ +{ int x = 0; fprintf(stderr, "FAILED: %s\n", string); x = 1 / x; abort(); } + +int count; + +int test_fn(char c, void * client_data) +{ + if (client_data != (void *)13) ABORT("bad client data"); + if (count < 64*1024+1) { + if ((count & 1) == 0) { + if (c != 'b') ABORT("bad char"); + } else { + if (c != 'a') ABORT("bad char"); + } + count++; + return(0); + } else { + if (c != 'c') ABORT("bad char"); + count++; + return(1); + } +} + +char id_cord_fn(size_t i, void * client_data) +{ + return((char)i); +} + +void test_basics() +{ + CORD x = CORD_from_char_star("ab"); + register int i; + char c; + CORD y; + CORD_pos p; + + x = CORD_cat(x,x); + if (!CORD_IS_STRING(x)) ABORT("short cord should usually be a string"); + if (strcmp(x, "abab") != 0) ABORT("bad CORD_cat result"); + + for (i = 1; i < 16; i++) { + x = CORD_cat(x,x); + } + x = CORD_cat(x,"c"); + if (CORD_len(x) != 128*1024+1) ABORT("bad length"); + + count = 0; + if (CORD_iter5(x, 64*1024-1, test_fn, CORD_NO_FN, (void *)13) == 0) { + ABORT("CORD_iter5 failed"); + } + if (count != 64*1024 + 2) ABORT("CORD_iter5 failed"); + + count = 0; + CORD_set_pos(p, x, 64*1024-1); + while(CORD_pos_valid(p)) { + (void) test_fn(CORD_pos_fetch(p), (void *)13); + CORD_next(p); + } + if (count != 64*1024 + 2) ABORT("Position based iteration failed"); + + y = CORD_substr(x, 1023, 5); + if (!CORD_IS_STRING(y)) ABORT("short cord should usually be a string"); + if (strcmp(y, "babab") != 0) ABORT("bad CORD_substr result"); + + y = CORD_substr(x, 1024, 8); + if (!CORD_IS_STRING(y)) ABORT("short cord should usually be a string"); + if (strcmp(y, "abababab") != 0) ABORT("bad CORD_substr result"); + + y = CORD_substr(x, 128*1024-1, 8); + if (!CORD_IS_STRING(y)) ABORT("short cord should usually be a string"); + if (strcmp(y, "bc") != 0) ABORT("bad CORD_substr result"); + + x = CORD_balance(x); + if (CORD_len(x) != 128*1024+1) ABORT("bad length"); + + count = 0; + if (CORD_iter5(x, 64*1024-1, test_fn, CORD_NO_FN, (void *)13) == 0) { + ABORT("CORD_iter5 failed"); + } + if (count != 64*1024 + 2) ABORT("CORD_iter5 failed"); + + y = CORD_substr(x, 1023, 5); + if (!CORD_IS_STRING(y)) ABORT("short cord should usually be a string"); + if (strcmp(y, "babab") != 0) ABORT("bad CORD_substr result"); + y = CORD_from_fn(id_cord_fn, 0, 13); + i = 0; + CORD_set_pos(p, y, i); + while(CORD_pos_valid(p)) { + c = CORD_pos_fetch(p); + if(c != i) ABORT("Traversal of function node failed"); + CORD_next(p); i++; + } + if (i != 13) ABORT("Bad apparent length for function node"); +} + +void test_extras() +{ +# if defined(__OS2__) +# define FNAME1 "tmp1" +# define FNAME2 "tmp2" +# elif defined(AMIGA) +# define FNAME1 "T:tmp1" +# define FNAME2 "T:tmp2" +# else +# define FNAME1 "/tmp/cord_test" +# define FNAME2 "/tmp/cord_test2" +# endif + register int i; + CORD y = "abcdefghijklmnopqrstuvwxyz0123456789"; + CORD x = "{}"; + CORD w, z; + FILE *f; + FILE *f1a, *f1b, *f2; + + w = CORD_cat(CORD_cat(y,y),y); + z = CORD_catn(3,y,y,y); + if (CORD_cmp(w,z) != 0) ABORT("CORD_catn comparison wrong"); + for (i = 1; i < 100; i++) { + x = CORD_cat(x, y); + } + z = CORD_balance(x); + if (CORD_cmp(x,z) != 0) ABORT("balanced string comparison wrong"); + if (CORD_cmp(x,CORD_cat(z, CORD_nul(13))) >= 0) ABORT("comparison 2"); + if (CORD_cmp(CORD_cat(x, CORD_nul(13)), z) <= 0) ABORT("comparison 3"); + if (CORD_cmp(x,CORD_cat(z, "13")) >= 0) ABORT("comparison 4"); + if ((f = fopen(FNAME1, "w")) == 0) ABORT("open failed"); + if (CORD_put(z,f) == EOF) ABORT("CORD_put failed"); + if (fclose(f) == EOF) ABORT("fclose failed"); + w = CORD_from_file(f1a = fopen(FNAME1, "rb")); + if (CORD_len(w) != CORD_len(z)) ABORT("file length wrong"); + if (CORD_cmp(w,z) != 0) ABORT("file comparison wrong"); + if (CORD_cmp(CORD_substr(w, 50*36+2, 36), y) != 0) + ABORT("file substr wrong"); + z = CORD_from_file_lazy(f1b = fopen(FNAME1, "rb")); + if (CORD_cmp(w,z) != 0) ABORT("File conversions differ"); + if (CORD_chr(w, 0, '9') != 37) ABORT("CORD_chr failed 1"); + if (CORD_chr(w, 3, 'a') != 38) ABORT("CORD_chr failed 2"); + if (CORD_rchr(w, CORD_len(w) - 1, '}') != 1) ABORT("CORD_rchr failed"); + x = y; + for (i = 1; i < 14; i++) { + x = CORD_cat(x,x); + } + if ((f = fopen(FNAME2, "w")) == 0) ABORT("2nd open failed"); + if (CORD_put(x,f) == EOF) ABORT("CORD_put failed"); + if (fclose(f) == EOF) ABORT("fclose failed"); + w = CORD_from_file(f2 = fopen(FNAME2, "rb")); + if (CORD_len(w) != CORD_len(x)) ABORT("file length wrong"); + if (CORD_cmp(w,x) != 0) ABORT("file comparison wrong"); + if (CORD_cmp(CORD_substr(w, 1000*36, 36), y) != 0) + ABORT("file substr wrong"); + if (strcmp(CORD_to_char_star(CORD_substr(w, 1000*36, 36)), y) != 0) + ABORT("char * file substr wrong"); + if (strcmp(CORD_substr(w, 1000*36, 2), "ab") != 0) + ABORT("short file substr wrong"); + if (CORD_str(x,1,"9a") != 35) ABORT("CORD_str failed 1"); + if (CORD_str(x,0,"9abcdefghijk") != 35) ABORT("CORD_str failed 2"); + if (CORD_str(x,0,"9abcdefghijx") != CORD_NOT_FOUND) + ABORT("CORD_str failed 3"); + if (CORD_str(x,0,"9>") != CORD_NOT_FOUND) ABORT("CORD_str failed 4"); + if (remove(FNAME1) != 0) { + /* On some systems, e.g. OS2, this may fail if f1 is still open. */ + if ((fclose(f1a) == EOF) & (fclose(f1b) == EOF)) + ABORT("fclose(f1) failed"); + if (remove(FNAME1) != 0) ABORT("remove 1 failed"); + } + if (remove(FNAME2) != 0) { + if (fclose(f2) == EOF) ABORT("fclose(f2) failed"); + if (remove(FNAME2) != 0) ABORT("remove 2 failed"); + } +} + +void test_printf() +{ + CORD result; + char result2[200]; + long l; + short s; + CORD x; + + if (CORD_sprintf(&result, "%7.2f%ln", 3.14159F, &l) != 7) + ABORT("CORD_sprintf failed 1"); + if (CORD_cmp(result, " 3.14") != 0)ABORT("CORD_sprintf goofed 1"); + if (l != 7) ABORT("CORD_sprintf goofed 2"); + if (CORD_sprintf(&result, "%-7.2s%hn%c%s", "abcd", &s, 'x', "yz") != 10) + ABORT("CORD_sprintf failed 2"); + if (CORD_cmp(result, "ab xyz") != 0)ABORT("CORD_sprintf goofed 3"); + if (s != 7) ABORT("CORD_sprintf goofed 4"); + x = "abcdefghij"; + x = CORD_cat(x,x); + x = CORD_cat(x,x); + x = CORD_cat(x,x); + if (CORD_sprintf(&result, "->%-120.78r!\n", x) != 124) + ABORT("CORD_sprintf failed 3"); + (void) sprintf(result2, "->%-120.78s!\n", CORD_to_char_star(x)); + if (CORD_cmp(result, result2) != 0)ABORT("CORD_sprintf goofed 5"); +} + +main() +{ +# ifdef THINK_C + printf("cordtest:\n"); +# endif + test_basics(); + test_extras(); + test_printf(); + CORD_fprintf(stderr, "SUCCEEDED\n"); + return(0); +} diff --git a/support/gc/cord/cordxtra.c b/support/gc/cord/cordxtra.c new file mode 100644 index 00000000..b306fbac --- /dev/null +++ b/support/gc/cord/cordxtra.c @@ -0,0 +1,621 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Author: Hans-J. Boehm (boehm@parc.xerox.com) + */ +/* + * These are functions on cords that do not need to understand their + * implementation. They serve also serve as example client code for + * cord_basics. + */ +/* Boehm, December 8, 1995 1:53 pm PST */ +# include +# include +# include +# include +# include "cord.h" +# include "ec.h" +# define I_HIDE_POINTERS /* So we get access to allocation lock. */ + /* We use this for lazy file reading, */ + /* so that we remain independent */ + /* of the threads primitives. */ +# include "gc.h" + +/* For now we assume that pointer reads and writes are atomic, */ +/* i.e. another thread always sees the state before or after */ +/* a write. This might be false on a Motorola M68K with */ +/* pointers that are not 32-bit aligned. But there probably */ +/* aren't too many threads packages running on those. */ +# define ATOMIC_WRITE(x,y) (x) = (y) +# define ATOMIC_READ(x) (*(x)) + +/* The standard says these are in stdio.h, but they aren't always: */ +# ifndef SEEK_SET +# define SEEK_SET 0 +# endif +# ifndef SEEK_END +# define SEEK_END 2 +# endif + +# define BUFSZ 2048 /* Size of stack allocated buffers when */ + /* we want large buffers. */ + +typedef void (* oom_fn)(void); + +# define OUT_OF_MEMORY { if (CORD_oom_fn != (oom_fn) 0) (*CORD_oom_fn)(); \ + ABORT("Out of memory\n"); } +# define ABORT(msg) { fprintf(stderr, "%s\n", msg); abort(); } + +CORD CORD_cat_char(CORD x, char c) +{ + register char * string; + + if (c == '\0') return(CORD_cat(x, CORD_nul(1))); + string = GC_MALLOC_ATOMIC(2); + if (string == 0) OUT_OF_MEMORY; + string[0] = c; + string[1] = '\0'; + return(CORD_cat_char_star(x, string, 1)); +} + +CORD CORD_catn(int nargs, ...) +{ + register CORD result = CORD_EMPTY; + va_list args; + register int i; + + va_start(args, nargs); + for (i = 0; i < nargs; i++) { + register CORD next = va_arg(args, CORD); + result = CORD_cat(result, next); + } + va_end(args); + return(result); +} + +typedef struct { + size_t len; + size_t count; + char * buf; +} CORD_fill_data; + +int CORD_fill_proc(char c, void * client_data) +{ + register CORD_fill_data * d = (CORD_fill_data *)client_data; + register size_t count = d -> count; + + (d -> buf)[count] = c; + d -> count = ++count; + if (count >= d -> len) { + return(1); + } else { + return(0); + } +} + +int CORD_batched_fill_proc(const char * s, void * client_data) +{ + register CORD_fill_data * d = (CORD_fill_data *)client_data; + register size_t count = d -> count; + register size_t max = d -> len; + register char * buf = d -> buf; + register const char * t = s; + + while((buf[count] = *t++) != '\0') { + count++; + if (count >= max) { + d -> count = count; + return(1); + } + } + d -> count = count; + return(0); +} + +/* Fill buf with len characters starting at i. */ +/* Assumes len characters are available. */ +void CORD_fill_buf(CORD x, size_t i, size_t len, char * buf) +{ + CORD_fill_data fd; + + fd.len = len; + fd.buf = buf; + fd.count = 0; + (void)CORD_iter5(x, i, CORD_fill_proc, CORD_batched_fill_proc, &fd); +} + +int CORD_cmp(CORD x, CORD y) +{ + CORD_pos xpos; + CORD_pos ypos; + register size_t avail, yavail; + + if (y == CORD_EMPTY) return(x != CORD_EMPTY); + if (x == CORD_EMPTY) return(-1); + if (CORD_IS_STRING(y) && CORD_IS_STRING(x)) return(strcmp(x,y)); + CORD_set_pos(xpos, x, 0); + CORD_set_pos(ypos, y, 0); + for(;;) { + if (!CORD_pos_valid(xpos)) { + if (CORD_pos_valid(ypos)) { + return(-1); + } else { + return(0); + } + } + if (!CORD_pos_valid(ypos)) { + return(1); + } + if ((avail = CORD_pos_chars_left(xpos)) <= 0 + || (yavail = CORD_pos_chars_left(ypos)) <= 0) { + register char xcurrent = CORD_pos_fetch(xpos); + register char ycurrent = CORD_pos_fetch(ypos); + if (xcurrent != ycurrent) return(xcurrent - ycurrent); + CORD_next(xpos); + CORD_next(ypos); + } else { + /* process as many characters as we can */ + register int result; + + if (avail > yavail) avail = yavail; + result = strncmp(CORD_pos_cur_char_addr(xpos), + CORD_pos_cur_char_addr(ypos), avail); + if (result != 0) return(result); + CORD_pos_advance(xpos, avail); + CORD_pos_advance(ypos, avail); + } + } +} + +int CORD_ncmp(CORD x, size_t x_start, CORD y, size_t y_start, size_t len) +{ + CORD_pos xpos; + CORD_pos ypos; + register size_t count; + register long avail, yavail; + + CORD_set_pos(xpos, x, x_start); + CORD_set_pos(ypos, y, y_start); + for(count = 0; count < len;) { + if (!CORD_pos_valid(xpos)) { + if (CORD_pos_valid(ypos)) { + return(-1); + } else { + return(0); + } + } + if (!CORD_pos_valid(ypos)) { + return(1); + } + if ((avail = CORD_pos_chars_left(xpos)) <= 0 + || (yavail = CORD_pos_chars_left(ypos)) <= 0) { + register char xcurrent = CORD_pos_fetch(xpos); + register char ycurrent = CORD_pos_fetch(ypos); + if (xcurrent != ycurrent) return(xcurrent - ycurrent); + CORD_next(xpos); + CORD_next(ypos); + count++; + } else { + /* process as many characters as we can */ + register int result; + + if (avail > yavail) avail = yavail; + count += avail; + if (count > len) avail -= (count - len); + result = strncmp(CORD_pos_cur_char_addr(xpos), + CORD_pos_cur_char_addr(ypos), (size_t)avail); + if (result != 0) return(result); + CORD_pos_advance(xpos, (size_t)avail); + CORD_pos_advance(ypos, (size_t)avail); + } + } + return(0); +} + +char * CORD_to_char_star(CORD x) +{ + register size_t len = CORD_len(x); + char * result = GC_MALLOC_ATOMIC(len + 1); + + if (result == 0) OUT_OF_MEMORY; + CORD_fill_buf(x, 0, len, result); + result[len] = '\0'; + return(result); +} + +CORD CORD_from_char_star(const char *s) +{ + char * result; + size_t len = strlen(s); + + if (0 == len) return(CORD_EMPTY); + result = GC_MALLOC_ATOMIC(len + 1); + if (result == 0) OUT_OF_MEMORY; + memcpy(result, s, len+1); + return(result); +} + +const char * CORD_to_const_char_star(CORD x) +{ + if (x == 0) return(""); + if (CORD_IS_STRING(x)) return((const char *)x); + return(CORD_to_char_star(x)); +} + +char CORD_fetch(CORD x, size_t i) +{ + CORD_pos xpos; + + CORD_set_pos(xpos, x, i); + if (!CORD_pos_valid(xpos)) ABORT("bad index?"); + return(CORD_pos_fetch(xpos)); +} + + +int CORD_put_proc(char c, void * client_data) +{ + register FILE * f = (FILE *)client_data; + + return(putc(c, f) == EOF); +} + +int CORD_batched_put_proc(const char * s, void * client_data) +{ + register FILE * f = (FILE *)client_data; + + return(fputs(s, f) == EOF); +} + + +int CORD_put(CORD x, FILE * f) +{ + if (CORD_iter5(x, 0, CORD_put_proc, CORD_batched_put_proc, f)) { + return(EOF); + } else { + return(1); + } +} + +typedef struct { + size_t pos; /* Current position in the cord */ + char target; /* Character we're looking for */ +} chr_data; + +int CORD_chr_proc(char c, void * client_data) +{ + register chr_data * d = (chr_data *)client_data; + + if (c == d -> target) return(1); + (d -> pos) ++; + return(0); +} + +int CORD_rchr_proc(char c, void * client_data) +{ + register chr_data * d = (chr_data *)client_data; + + if (c == d -> target) return(1); + (d -> pos) --; + return(0); +} + +int CORD_batched_chr_proc(const char *s, void * client_data) +{ + register chr_data * d = (chr_data *)client_data; + register char * occ = strchr(s, d -> target); + + if (occ == 0) { + d -> pos += strlen(s); + return(0); + } else { + d -> pos += occ - s; + return(1); + } +} + +size_t CORD_chr(CORD x, size_t i, int c) +{ + chr_data d; + + d.pos = i; + d.target = c; + if (CORD_iter5(x, i, CORD_chr_proc, CORD_batched_chr_proc, &d)) { + return(d.pos); + } else { + return(CORD_NOT_FOUND); + } +} + +size_t CORD_rchr(CORD x, size_t i, int c) +{ + chr_data d; + + d.pos = i; + d.target = c; + if (CORD_riter4(x, i, CORD_rchr_proc, &d)) { + return(d.pos); + } else { + return(CORD_NOT_FOUND); + } +} + +/* Find the first occurrence of s in x at position start or later. */ +/* This uses an asymptotically poor algorithm, which should typically */ +/* perform acceptably. We compare the first few characters directly, */ +/* and call CORD_ncmp whenever there is a partial match. */ +/* This has the advantage that we allocate very little, or not at all. */ +/* It's very fast if there are few close misses. */ +size_t CORD_str(CORD x, size_t start, CORD s) +{ + CORD_pos xpos; + size_t xlen = CORD_len(x); + size_t slen; + register size_t start_len; + const char * s_start; + unsigned long s_buf = 0; /* The first few characters of s */ + unsigned long x_buf = 0; /* Start of candidate substring. */ + /* Initialized only to make compilers */ + /* happy. */ + unsigned long mask = 0; + register size_t i; + register size_t match_pos; + + if (s == CORD_EMPTY) return(start); + if (CORD_IS_STRING(s)) { + s_start = s; + slen = strlen(s); + } else { + s_start = CORD_to_char_star(CORD_substr(s, 0, sizeof(unsigned long))); + slen = CORD_len(s); + } + if (xlen < start || xlen - start < slen) return(CORD_NOT_FOUND); + start_len = slen; + if (start_len > sizeof(unsigned long)) start_len = sizeof(unsigned long); + CORD_set_pos(xpos, x, start); + for (i = 0; i < start_len; i++) { + mask <<= 8; + mask |= 0xff; + s_buf <<= 8; + s_buf |= s_start[i]; + x_buf <<= 8; + x_buf |= CORD_pos_fetch(xpos); + CORD_next(xpos); + } + for (match_pos = start; ; match_pos++) { + if ((x_buf & mask) == s_buf) { + if (slen == start_len || + CORD_ncmp(x, match_pos + start_len, + s, start_len, slen - start_len) == 0) { + return(match_pos); + } + } + if ( match_pos == xlen - slen ) { + return(CORD_NOT_FOUND); + } + x_buf <<= 8; + x_buf |= CORD_pos_fetch(xpos); + CORD_next(xpos); + } +} + +void CORD_ec_flush_buf(CORD_ec x) +{ + register size_t len = x[0].ec_bufptr - x[0].ec_buf; + char * s; + + if (len == 0) return; + s = GC_MALLOC_ATOMIC(len+1); + memcpy(s, x[0].ec_buf, len); + s[len] = '\0'; + x[0].ec_cord = CORD_cat_char_star(x[0].ec_cord, s, len); + x[0].ec_bufptr = x[0].ec_buf; +} + +void CORD_ec_append_cord(CORD_ec x, CORD s) +{ + CORD_ec_flush_buf(x); + x[0].ec_cord = CORD_cat(x[0].ec_cord, s); +} + +/*ARGSUSED*/ +char CORD_nul_func(size_t i, void * client_data) +{ + return((char)(unsigned long)client_data); +} + + +CORD CORD_chars(char c, size_t i) +{ + return(CORD_from_fn(CORD_nul_func, (void *)(unsigned long)c, i)); +} + +CORD CORD_from_file_eager(FILE * f) +{ + register int c; + CORD_ec ecord; + + CORD_ec_init(ecord); + for(;;) { + c = getc(f); + if (c == 0) { + /* Append the right number of NULs */ + /* Note that any string of NULs is rpresented in 4 words, */ + /* independent of its length. */ + register size_t count = 1; + + CORD_ec_flush_buf(ecord); + while ((c = getc(f)) == 0) count++; + ecord[0].ec_cord = CORD_cat(ecord[0].ec_cord, CORD_nul(count)); + } + if (c == EOF) break; + CORD_ec_append(ecord, c); + } + (void) fclose(f); + return(CORD_balance(CORD_ec_to_cord(ecord))); +} + +/* The state maintained for a lazily read file consists primarily */ +/* of a large direct-mapped cache of previously read values. */ +/* We could rely more on stdio buffering. That would have 2 */ +/* disadvantages: */ +/* 1) Empirically, not all fseek implementations preserve the */ +/* buffer whenever they could. */ +/* 2) It would fail if 2 different sections of a long cord */ +/* were being read alternately. */ +/* We do use the stdio buffer for read ahead. */ +/* To guarantee thread safety in the presence of atomic pointer */ +/* writes, cache lines are always replaced, and never modified in */ +/* place. */ + +# define LOG_CACHE_SZ 14 +# define CACHE_SZ (1 << LOG_CACHE_SZ) +# define LOG_LINE_SZ 9 +# define LINE_SZ (1 << LOG_LINE_SZ) + +typedef struct { + size_t tag; + char data[LINE_SZ]; + /* data[i%LINE_SZ] = ith char in file if tag = i/LINE_SZ */ +} cache_line; + +typedef struct { + FILE * lf_file; + size_t lf_current; /* Current file pointer value */ + cache_line * volatile lf_cache[CACHE_SZ/LINE_SZ]; +} lf_state; + +# define MOD_CACHE_SZ(n) ((n) & (CACHE_SZ - 1)) +# define DIV_CACHE_SZ(n) ((n) >> LOG_CACHE_SZ) +# define MOD_LINE_SZ(n) ((n) & (LINE_SZ - 1)) +# define DIV_LINE_SZ(n) ((n) >> LOG_LINE_SZ) +# define LINE_START(n) ((n) & ~(LINE_SZ - 1)) + +typedef struct { + lf_state * state; + size_t file_pos; /* Position of needed character. */ + cache_line * new_cache; +} refill_data; + +/* Executed with allocation lock. */ +static char refill_cache(client_data) +refill_data * client_data; +{ + register lf_state * state = client_data -> state; + register size_t file_pos = client_data -> file_pos; + FILE *f = state -> lf_file; + size_t line_start = LINE_START(file_pos); + size_t line_no = DIV_LINE_SZ(MOD_CACHE_SZ(file_pos)); + cache_line * new_cache = client_data -> new_cache; + + if (line_start != state -> lf_current + && fseek(f, line_start, SEEK_SET) != 0) { + ABORT("fseek failed"); + } + if (fread(new_cache -> data, sizeof(char), LINE_SZ, f) + <= file_pos - line_start) { + ABORT("fread failed"); + } + new_cache -> tag = DIV_LINE_SZ(file_pos); + /* Store barrier goes here. */ + ATOMIC_WRITE(state -> lf_cache[line_no], new_cache); + state -> lf_current = line_start + LINE_SZ; + return(new_cache->data[MOD_LINE_SZ(file_pos)]); +} + +char CORD_lf_func(size_t i, void * client_data) +{ + register lf_state * state = (lf_state *)client_data; + register cache_line * volatile * cl_addr = + &(state -> lf_cache[DIV_LINE_SZ(MOD_CACHE_SZ(i))]); + register cache_line * cl = (cache_line *)ATOMIC_READ(cl_addr); + + if (cl == 0 || cl -> tag != DIV_LINE_SZ(i)) { + /* Cache miss */ + refill_data rd; + + rd.state = state; + rd.file_pos = i; + rd.new_cache = GC_NEW_ATOMIC(cache_line); + if (rd.new_cache == 0) OUT_OF_MEMORY; + return((char)(GC_word) + GC_call_with_alloc_lock((GC_fn_type) refill_cache, &rd)); + } + return(cl -> data[MOD_LINE_SZ(i)]); +} + +/*ARGSUSED*/ +void CORD_lf_close_proc(void * obj, void * client_data) +{ + if (fclose(((lf_state *)obj) -> lf_file) != 0) { + ABORT("CORD_lf_close_proc: fclose failed"); + } +} + +CORD CORD_from_file_lazy_inner(FILE * f, size_t len) +{ + register lf_state * state = GC_NEW(lf_state); + register int i; + + if (state == 0) OUT_OF_MEMORY; + if (len != 0) { + /* Dummy read to force buffer allocation. */ + /* This greatly increases the probability */ + /* of avoiding deadlock if buffer allocation */ + /* is redirected to GC_malloc and the */ + /* world is multithreaded. */ + char buf[1]; + + (void) fread(buf, 1, 1, f); + rewind(f); + } + state -> lf_file = f; + for (i = 0; i < CACHE_SZ/LINE_SZ; i++) { + state -> lf_cache[i] = 0; + } + state -> lf_current = 0; + GC_register_finalizer(state, CORD_lf_close_proc, 0, 0, 0); + return(CORD_from_fn(CORD_lf_func, state, len)); +} + +CORD CORD_from_file_lazy(FILE * f) +{ + register long len; + + if (fseek(f, 0l, SEEK_END) != 0) { + ABORT("Bad fd argument - fseek failed"); + } + if ((len = ftell(f)) < 0) { + ABORT("Bad fd argument - ftell failed"); + } + rewind(f); + return(CORD_from_file_lazy_inner(f, (size_t)len)); +} + +# define LAZY_THRESHOLD (128*1024 + 1) + +CORD CORD_from_file(FILE * f) +{ + register long len; + + if (fseek(f, 0l, SEEK_END) != 0) { + ABORT("Bad fd argument - fseek failed"); + } + if ((len = ftell(f)) < 0) { + ABORT("Bad fd argument - ftell failed"); + } + rewind(f); + if (len < LAZY_THRESHOLD) { + return(CORD_from_file_eager(f)); + } else { + return(CORD_from_file_lazy_inner(f, (size_t)len)); + } +} diff --git a/support/gc/cord/de.c b/support/gc/cord/de.c new file mode 100644 index 00000000..18625d2b --- /dev/null +++ b/support/gc/cord/de.c @@ -0,0 +1,604 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Author: Hans-J. Boehm (boehm@parc.xerox.com) + */ +/* + * A really simple-minded text editor based on cords. + * Things it does right: + * No size bounds. + * Inbounded undo. + * Shouldn't crash no matter what file you invoke it on (e.g. /vmunix) + * (Make sure /vmunix is not writable before you try this.) + * Scrolls horizontally. + * Things it does wrong: + * It doesn't handle tabs reasonably (use "expand" first). + * The command set is MUCH too small. + * The redisplay algorithm doesn't let curses do the scrolling. + * The rule for moving the window over the file is suboptimal. + */ +/* Boehm, February 6, 1995 12:27 pm PST */ + +/* Boehm, May 19, 1994 2:20 pm PDT */ +#include +#include "gc.h" +#include "cord.h" + +#ifdef THINK_C +#define MACINTOSH +#include +#endif + +#if defined(__BORLANDC__) && !defined(WIN32) + /* If this is DOS or win16, we'll fail anyway. */ + /* Might as well assume win32. */ +# define WIN32 +#endif + +#if defined(WIN32) +# include +# include "de_win.h" +#elif defined(MACINTOSH) +# include +/* curses emulation. */ +# define initscr() +# define endwin() +# define nonl() +# define noecho() csetmode(C_NOECHO, stdout) +# define cbreak() csetmode(C_CBREAK, stdout) +# define refresh() +# define addch(c) putchar(c) +# define standout() cinverse(1, stdout) +# define standend() cinverse(0, stdout) +# define move(line,col) cgotoxy(col + 1, line + 1, stdout) +# define clrtoeol() ccleol(stdout) +# define de_error(s) { fprintf(stderr, s); getchar(); } +# define LINES 25 +# define COLS 80 +#else +# include +# define de_error(s) { fprintf(stderr, s); sleep(2); } +#endif +#include "de_cmds.h" + +/* List of line number to position mappings, in descending order. */ +/* There may be holes. */ +typedef struct LineMapRep { + int line; + size_t pos; + struct LineMapRep * previous; +} * line_map; + +/* List of file versions, one per edit operation */ +typedef struct HistoryRep { + CORD file_contents; + struct HistoryRep * previous; + line_map map; /* Invalid for first record "now" */ +} * history; + +history now = 0; +CORD current; /* == now -> file_contents. */ +size_t current_len; /* Current file length. */ +line_map current_map = 0; /* Current line no. to pos. map */ +size_t current_map_size = 0; /* Number of current_map entries. */ + /* Not always accurate, but reset */ + /* by prune_map. */ +# define MAX_MAP_SIZE 3000 + +/* Current display position */ +int dis_line = 0; +int dis_col = 0; + +# define ALL -1 +# define NONE - 2 +int need_redisplay = 0; /* Line that needs to be redisplayed. */ + + +/* Current cursor position. Always within file. */ +int line = 0; +int col = 0; +size_t file_pos = 0; /* Character position corresponding to cursor. */ + +/* Invalidate line map for lines > i */ +void invalidate_map(int i) +{ + while(current_map -> line > i) { + current_map = current_map -> previous; + current_map_size--; + } +} + +/* Reduce the number of map entries to save space for huge files. */ +/* This also affects maps in histories. */ +void prune_map() +{ + line_map map = current_map; + int start_line = map -> line; + + current_map_size = 0; + for(; map != 0; map = map -> previous) { + current_map_size++; + if (map -> line < start_line - LINES && map -> previous != 0) { + map -> previous = map -> previous -> previous; + } + } +} +/* Add mapping entry */ +void add_map(int line, size_t pos) +{ + line_map new_map = GC_NEW(struct LineMapRep); + + if (current_map_size >= MAX_MAP_SIZE) prune_map(); + new_map -> line = line; + new_map -> pos = pos; + new_map -> previous = current_map; + current_map = new_map; + current_map_size++; +} + + + +/* Return position of column *c of ith line in */ +/* current file. Adjust *c to be within the line.*/ +/* A 0 pointer is taken as 0 column. */ +/* Returns CORD_NOT_FOUND if i is too big. */ +/* Assumes i > dis_line. */ +size_t line_pos(int i, int *c) +{ + int j; + size_t cur; + size_t next; + line_map map = current_map; + + while (map -> line > i) map = map -> previous; + if (map -> line < i - 2) /* rebuild */ invalidate_map(i); + for (j = map -> line, cur = map -> pos; j < i;) { + cur = CORD_chr(current, cur, '\n'); + if (cur == current_len-1) return(CORD_NOT_FOUND); + cur++; + if (++j > current_map -> line) add_map(j, cur); + } + if (c != 0) { + next = CORD_chr(current, cur, '\n'); + if (next == CORD_NOT_FOUND) next = current_len - 1; + if (next < cur + *c) { + *c = next - cur; + } + cur += *c; + } + return(cur); +} + +void add_hist(CORD s) +{ + history new_file = GC_NEW(struct HistoryRep); + + new_file -> file_contents = current = s; + current_len = CORD_len(s); + new_file -> previous = now; + if (now != 0) now -> map = current_map; + now = new_file; +} + +void del_hist(void) +{ + now = now -> previous; + current = now -> file_contents; + current_map = now -> map; + current_len = CORD_len(current); +} + +/* Current screen_contents; a dynamically allocated array of CORDs */ +CORD * screen = 0; +int screen_size = 0; + +# ifndef WIN32 +/* Replace a line in the curses stdscr. All control characters are */ +/* displayed as upper case characters in standout mode. This isn't */ +/* terribly appropriate for tabs. */ +void replace_line(int i, CORD s) +{ + register int c; + CORD_pos p; + size_t len = CORD_len(s); + + if (screen == 0 || LINES > screen_size) { + screen_size = LINES; + screen = (CORD *)GC_MALLOC(screen_size * sizeof(CORD)); + } +# if !defined(MACINTOSH) + /* A gross workaround for an apparent curses bug: */ + if (i == LINES-1 && len == COLS) { + s = CORD_substr(s, 0, CORD_len(s) - 1); + } +# endif + if (CORD_cmp(screen[i], s) != 0) { + move(i, 0); clrtoeol(); move(i,0); + + CORD_FOR (p, s) { + c = CORD_pos_fetch(p) & 0x7f; + if (iscntrl(c)) { + standout(); addch(c + 0x40); standend(); + } else { + addch(c); + } + } + screen[i] = s; + } +} +#else +# define replace_line(i,s) invalidate_line(i) +#endif + +/* Return up to COLS characters of the line of s starting at pos, */ +/* returning only characters after the given column. */ +CORD retrieve_line(CORD s, size_t pos, unsigned column) +{ + CORD candidate = CORD_substr(s, pos, column + COLS); + /* avoids scanning very long lines */ + int eol = CORD_chr(candidate, 0, '\n'); + int len; + + if (eol == CORD_NOT_FOUND) eol = CORD_len(candidate); + len = (int)eol - (int)column; + if (len < 0) len = 0; + return(CORD_substr(s, pos + column, len)); +} + +# ifdef WIN32 +# define refresh(); + + CORD retrieve_screen_line(int i) + { + register size_t pos; + + invalidate_map(dis_line + LINES); /* Prune search */ + pos = line_pos(dis_line + i, 0); + if (pos == CORD_NOT_FOUND) return(CORD_EMPTY); + return(retrieve_line(current, pos, dis_col)); + } +# endif + +/* Display the visible section of the current file */ +void redisplay(void) +{ + register int i; + + invalidate_map(dis_line + LINES); /* Prune search */ + for (i = 0; i < LINES; i++) { + if (need_redisplay == ALL || need_redisplay == i) { + register size_t pos = line_pos(dis_line + i, 0); + + if (pos == CORD_NOT_FOUND) break; + replace_line(i, retrieve_line(current, pos, dis_col)); + if (need_redisplay == i) goto done; + } + } + for (; i < LINES; i++) replace_line(i, CORD_EMPTY); +done: + refresh(); + need_redisplay = NONE; +} + +int dis_granularity; + +/* Update dis_line, dis_col, and dis_pos to make cursor visible. */ +/* Assumes line, col, dis_line, dis_pos are in bounds. */ +void normalize_display() +{ + int old_line = dis_line; + int old_col = dis_col; + + dis_granularity = 1; + if (LINES > 15 && COLS > 15) dis_granularity = 2; + while (dis_line > line) dis_line -= dis_granularity; + while (dis_col > col) dis_col -= dis_granularity; + while (line >= dis_line + LINES) dis_line += dis_granularity; + while (col >= dis_col + COLS) dis_col += dis_granularity; + if (old_line != dis_line || old_col != dis_col) { + need_redisplay = ALL; + } +} + +# if defined(WIN32) +# elif defined(MACINTOSH) +# define move_cursor(x,y) cgotoxy(x + 1, y + 1, stdout) +# else +# define move_cursor(x,y) move(y,x) +# endif + +/* Adjust display so that cursor is visible; move cursor into position */ +/* Update screen if necessary. */ +void fix_cursor(void) +{ + normalize_display(); + if (need_redisplay != NONE) redisplay(); + move_cursor(col - dis_col, line - dis_line); + refresh(); +# ifndef WIN32 + fflush(stdout); +# endif +} + +/* Make sure line, col, and dis_pos are somewhere inside file. */ +/* Recompute file_pos. Assumes dis_pos is accurate or past eof */ +void fix_pos() +{ + int my_col = col; + + if ((size_t)line > current_len) line = current_len; + file_pos = line_pos(line, &my_col); + if (file_pos == CORD_NOT_FOUND) { + for (line = current_map -> line, file_pos = current_map -> pos; + file_pos < current_len; + line++, file_pos = CORD_chr(current, file_pos, '\n') + 1); + line--; + file_pos = line_pos(line, &col); + } else { + col = my_col; + } +} + +#if defined(WIN32) +# define beep() Beep(1000 /* Hz */, 300 /* msecs */) +#elif defined(MACINTOSH) +# define beep() SysBeep(1) +#else +/* + * beep() is part of some curses packages and not others. + * We try to match the type of the builtin one, if any. + */ +#ifdef __STDC__ + int beep(void) +#else + int beep() +#endif +{ + putc('\007', stderr); + return(0); +} +#endif + +# define NO_PREFIX -1 +# define BARE_PREFIX -2 +int repeat_count = NO_PREFIX; /* Current command prefix. */ + +int locate_mode = 0; /* Currently between 2 ^Ls */ +CORD locate_string = CORD_EMPTY; /* Current search string. */ + +char * arg_file_name; + +#ifdef WIN32 +/* Change the current position to whatever is currently displayed at */ +/* the given SCREEN coordinates. */ +void set_position(int c, int l) +{ + line = l + dis_line; + col = c + dis_col; + fix_pos(); + move_cursor(col - dis_col, line - dis_line); +} +#endif /* WIN32 */ + +/* Perform the command associated with character c. C may be an */ +/* integer > 256 denoting a windows command, one of the above control */ +/* characters, or another ASCII character to be used as either a */ +/* character to be inserted, a repeat count, or a search string, */ +/* depending on the current state. */ +void do_command(int c) +{ + int i; + int need_fix_pos; + FILE * out; + + if ( c == '\r') c = '\n'; + if (locate_mode) { + size_t new_pos; + + if (c == LOCATE) { + locate_mode = 0; + locate_string = CORD_EMPTY; + return; + } + locate_string = CORD_cat_char(locate_string, (char)c); + new_pos = CORD_str(current, file_pos - CORD_len(locate_string) + 1, + locate_string); + if (new_pos != CORD_NOT_FOUND) { + need_redisplay = ALL; + new_pos += CORD_len(locate_string); + for (;;) { + file_pos = line_pos(line + 1, 0); + if (file_pos > new_pos) break; + line++; + } + col = new_pos - line_pos(line, 0); + file_pos = new_pos; + fix_cursor(); + } else { + locate_string = CORD_substr(locate_string, 0, + CORD_len(locate_string) - 1); + beep(); + } + return; + } + if (c == REPEAT) { + repeat_count = BARE_PREFIX; return; + } else if (c < 0x100 && isdigit(c)){ + if (repeat_count == BARE_PREFIX) { + repeat_count = c - '0'; return; + } else if (repeat_count != NO_PREFIX) { + repeat_count = 10 * repeat_count + c - '0'; return; + } + } + if (repeat_count == NO_PREFIX) repeat_count = 1; + if (repeat_count == BARE_PREFIX && (c == UP || c == DOWN)) { + repeat_count = LINES - dis_granularity; + } + if (repeat_count == BARE_PREFIX) repeat_count = 8; + need_fix_pos = 0; + for (i = 0; i < repeat_count; i++) { + switch(c) { + case LOCATE: + locate_mode = 1; + break; + case TOP: + line = col = file_pos = 0; + break; + case UP: + if (line != 0) { + line--; + need_fix_pos = 1; + } + break; + case DOWN: + line++; + need_fix_pos = 1; + break; + case LEFT: + if (col != 0) { + col--; file_pos--; + } + break; + case RIGHT: + if (CORD_fetch(current, file_pos) == '\n') break; + col++; file_pos++; + break; + case UNDO: + del_hist(); + need_redisplay = ALL; need_fix_pos = 1; + break; + case BS: + if (col == 0) { + beep(); + break; + } + col--; file_pos--; + /* fall through: */ + case DEL: + if (file_pos == current_len-1) break; + /* Can't delete trailing newline */ + if (CORD_fetch(current, file_pos) == '\n') { + need_redisplay = ALL; need_fix_pos = 1; + } else { + need_redisplay = line - dis_line; + } + add_hist(CORD_cat( + CORD_substr(current, 0, file_pos), + CORD_substr(current, file_pos+1, current_len))); + invalidate_map(line); + break; + case WRITE: + { + CORD name = CORD_cat(CORD_from_char_star(arg_file_name), + ".new"); + + if ((out = fopen(CORD_to_const_char_star(name), "wb")) == NULL + || CORD_put(current, out) == EOF) { + de_error("Write failed\n"); + need_redisplay = ALL; + } else { + fclose(out); + } + } + break; + default: + { + CORD left_part = CORD_substr(current, 0, file_pos); + CORD right_part = CORD_substr(current, file_pos, current_len); + + add_hist(CORD_cat(CORD_cat_char(left_part, (char)c), + right_part)); + invalidate_map(line); + if (c == '\n') { + col = 0; line++; file_pos++; + need_redisplay = ALL; + } else { + col++; file_pos++; + need_redisplay = line - dis_line; + } + break; + } + } + } + if (need_fix_pos) fix_pos(); + fix_cursor(); + repeat_count = NO_PREFIX; +} + +/* OS independent initialization */ + +void generic_init(void) +{ + FILE * f; + CORD initial; + + if ((f = fopen(arg_file_name, "rb")) == NULL) { + initial = "\n"; + } else { + initial = CORD_from_file(f); + if (initial == CORD_EMPTY + || CORD_fetch(initial, CORD_len(initial)-1) != '\n') { + initial = CORD_cat(initial, "\n"); + } + } + add_map(0,0); + add_hist(initial); + now -> map = current_map; + now -> previous = now; /* Can't back up further: beginning of the world */ + need_redisplay = ALL; + fix_cursor(); +} + +#ifndef WIN32 + +main(argc, argv) +int argc; +char ** argv; +{ + int c; + CORD initial; + +#if defined(MACINTOSH) + console_options.title = "\pDumb Editor"; + cshow(stdout); + GC_init(); + argc = ccommand(&argv); +#endif + + if (argc != 2) goto usage; + arg_file_name = argv[1]; + setvbuf(stdout, GC_MALLOC_ATOMIC(8192), _IOFBF, 8192); + initscr(); + noecho(); nonl(); cbreak(); + generic_init(); + while ((c = getchar()) != QUIT) { + if (c == EOF) break; + do_command(c); + } +done: + move(LINES-1, 0); + clrtoeol(); + refresh(); + nl(); + echo(); + endwin(); + exit(0); +usage: + fprintf(stderr, "Usage: %s file\n", argv[0]); + fprintf(stderr, "Cursor keys: ^B(left) ^F(right) ^P(up) ^N(down)\n"); + fprintf(stderr, "Undo: ^U Write to .new: ^W"); + fprintf(stderr, "Quit:^D Repeat count: ^R[n]\n"); + fprintf(stderr, "Top: ^T Locate (search, find): ^L text ^L\n"); + exit(1); +} + +#endif /* !WIN32 */ diff --git a/support/gc/cord/de_cmds.h b/support/gc/cord/de_cmds.h new file mode 100644 index 00000000..f42ddcf2 --- /dev/null +++ b/support/gc/cord/de_cmds.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, May 19, 1994 2:24 pm PDT */ + +#ifndef DE_CMDS_H + +# define DE_CMDS_H + +# define UP 16 /* ^P */ +# define DOWN 14 /* ^N */ +# define LEFT 2 /* ^B */ +# define RIGHT 6 /* ^F */ +# define DEL 127 /* ^? */ +# define BS 8 /* ^H */ +# define UNDO 21 /* ^U */ +# define WRITE 23 /* ^W */ +# define QUIT 4 /* ^D */ +# define REPEAT 18 /* ^R */ +# define LOCATE 12 /* ^L */ +# define TOP 20 /* ^T */ + +#endif + diff --git a/support/gc/cord/de_win.ICO b/support/gc/cord/de_win.ICO new file mode 100644 index 0000000000000000000000000000000000000000..b20ac3ee16a9c8751e2ee6ce3c757dfb1f687258 GIT binary patch literal 766 zcmeH_p$@_@5Qc9AGl#-%k~f%yw?dKDVds#%0XzVLy2(8OsXz=#GBK76e*TUutjRKk zE`& zOG8S%%P top = line * char_height; + rectp -> bottom = rectp->top + char_height; + rectp -> left = 0; + rectp -> right = win_width; +} + +int caret_visible = 0; /* Caret is currently visible. */ + +int screen_was_painted = 0;/* Screen has been painted at least once. */ + +void update_cursor(void); + +LRESULT CALLBACK WndProc (HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + static FARPROC lpfnAboutBox; + static HANDLE hInstance; + HDC dc; + PAINTSTRUCT ps; + RECT client_area; + RECT this_line; + RECT dummy; + TEXTMETRIC tm; + register int i; + int id; + + switch (message) + { + case WM_CREATE: + hInstance = ( (LPCREATESTRUCT) lParam)->hInstance; + lpfnAboutBox = MakeProcInstance( (FARPROC) AboutBox, hInstance ); + dc = GetDC(hwnd); + SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextMetrics(dc, &tm); + ReleaseDC(hwnd, dc); + char_width = tm.tmAveCharWidth; + char_height = tm.tmHeight + tm.tmExternalLeading; + GetClientRect(hwnd, &client_area); + COLS = (client_area.right - client_area.left)/char_width; + LINES = (client_area.bottom - client_area.top)/char_height; + generic_init(); + return(0); + + case WM_CHAR: + if (wParam == QUIT) { + SendMessage( hwnd, WM_CLOSE, 0, 0L ); + } else { + do_command(wParam); + } + return(0); + + case WM_SETFOCUS: + CreateCaret(hwnd, NULL, char_width, char_height); + ShowCaret(hwnd); + caret_visible = 1; + update_cursor(); + return(0); + + case WM_KILLFOCUS: + HideCaret(hwnd); + DestroyCaret(); + caret_visible = 0; + return(0); + + case WM_LBUTTONUP: + { + unsigned xpos = LOWORD(lParam); /* From left */ + unsigned ypos = HIWORD(lParam); /* from top */ + + set_position( xpos/char_width, ypos/char_height ); + return(0); + } + + case WM_COMMAND: + id = LOWORD(wParam); + if (id & EDIT_CMD_FLAG) { + if (id & REPEAT_FLAG) do_command(REPEAT); + do_command(CHAR_CMD(id)); + return( 0 ); + } else { + switch(id) { + case IDM_FILEEXIT: + SendMessage( hwnd, WM_CLOSE, 0, 0L ); + return( 0 ); + + case IDM_HELPABOUT: + if( DialogBox( hInstance, "ABOUTBOX", + hwnd, lpfnAboutBox ) ); + InvalidateRect( hwnd, NULL, TRUE ); + return( 0 ); + case IDM_HELPCONTENTS: + de_error( + "Cursor keys: ^B(left) ^F(right) ^P(up) ^N(down)\n" + "Undo: ^U Write: ^W Quit:^D Repeat count: ^R[n]\n" + "Top: ^T Locate (search, find): ^L text ^L\n"); + return( 0 ); + } + } + break; + + case WM_CLOSE: + DestroyWindow( hwnd ); + return 0; + + case WM_DESTROY: + PostQuitMessage (0); + GC_win32_free_heap(); + return 0; + + case WM_PAINT: + dc = BeginPaint(hwnd, &ps); + GetClientRect(hwnd, &client_area); + COLS = (client_area.right - client_area.left)/char_width; + LINES = (client_area.bottom - client_area.top)/char_height; + SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + for (i = 0; i < LINES; i++) { + get_line_rect(i, client_area.right, &this_line); + if (IntersectRect(&dummy, &this_line, &ps.rcPaint)) { + CORD raw_line = retrieve_screen_line(i); + size_t len = CORD_len(raw_line); + char * text = CORD_to_char_star(raw_line); + /* May contain embedded NULLs */ + char * plain = plain_chars(text, len); + char * blanks = CORD_to_char_star(CORD_chars(' ', + COLS - len)); + char * control = control_chars(text, len); +# define RED RGB(255,0,0) + + SetBkMode(dc, OPAQUE); + SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT)); + + TextOut(dc, this_line.left, this_line.top, + plain, len); + TextOut(dc, this_line.left + len * char_width, this_line.top, + blanks, COLS - len); + SetBkMode(dc, TRANSPARENT); + SetTextColor(dc, RED); + TextOut(dc, this_line.left, this_line.top, + control, strlen(control)); + } + } + EndPaint(hwnd, &ps); + screen_was_painted = 1; + return 0; + } + return DefWindowProc (hwnd, message, wParam, lParam); +} + +int last_col; +int last_line; + +void move_cursor(int c, int l) +{ + last_col = c; + last_line = l; + + if (caret_visible) update_cursor(); +} + +void update_cursor(void) +{ + SetCaretPos(last_col * char_width, last_line * char_height); + ShowCaret(hwnd); +} + +void invalidate_line(int i) +{ + RECT line; + + if (!screen_was_painted) return; + /* Invalidating a rectangle before painting seems result in a */ + /* major performance problem. */ + get_line_rect(i, COLS*char_width, &line); + InvalidateRect(hwnd, &line, FALSE); +} + +LRESULT CALLBACK AboutBox( HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam ) +{ + switch( message ) + { + case WM_INITDIALOG: + SetFocus( GetDlgItem( hDlg, IDOK ) ); + break; + + case WM_COMMAND: + switch( wParam ) + { + case IDOK: + EndDialog( hDlg, TRUE ); + break; + } + break; + + case WM_CLOSE: + EndDialog( hDlg, TRUE ); + return TRUE; + + } + return FALSE; +} + diff --git a/support/gc/cord/de_win.h b/support/gc/cord/de_win.h new file mode 100644 index 00000000..57a47b45 --- /dev/null +++ b/support/gc/cord/de_win.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, May 19, 1994 2:25 pm PDT */ + +/* cord.h, de_cmds.h, and windows.h should be included before this. */ + + +# define OTHER_FLAG 0x100 +# define EDIT_CMD_FLAG 0x200 +# define REPEAT_FLAG 0x400 + +# define CHAR_CMD(i) ((i) & 0xff) + +/* MENU: DE */ +#define IDM_FILESAVE (EDIT_CMD_FLAG + WRITE) +#define IDM_FILEEXIT (OTHER_FLAG + 1) +#define IDM_HELPABOUT (OTHER_FLAG + 2) +#define IDM_HELPCONTENTS (OTHER_FLAG + 3) + +#define IDM_EDITPDOWN (REPEAT_FLAG + EDIT_CMD_FLAG + DOWN) +#define IDM_EDITPUP (REPEAT_FLAG + EDIT_CMD_FLAG + UP) +#define IDM_EDITUNDO (EDIT_CMD_FLAG + UNDO) +#define IDM_EDITLOCATE (EDIT_CMD_FLAG + LOCATE) +#define IDM_EDITDOWN (EDIT_CMD_FLAG + DOWN) +#define IDM_EDITUP (EDIT_CMD_FLAG + UP) +#define IDM_EDITLEFT (EDIT_CMD_FLAG + LEFT) +#define IDM_EDITRIGHT (EDIT_CMD_FLAG + RIGHT) +#define IDM_EDITBS (EDIT_CMD_FLAG + BS) +#define IDM_EDITDEL (EDIT_CMD_FLAG + DEL) +#define IDM_EDITREPEAT (EDIT_CMD_FLAG + REPEAT) +#define IDM_EDITTOP (EDIT_CMD_FLAG + TOP) + + + + +/* Windows UI stuff */ + +LRESULT CALLBACK WndProc (HWND hwnd, UINT message, + UINT wParam, LONG lParam); + +LRESULT CALLBACK AboutBox( HWND hDlg, UINT message, + UINT wParam, LONG lParam ); + + +/* Screen dimensions. Maintained by de_win.c. */ +extern int LINES; +extern int COLS; + +/* File being edited. */ +extern char * arg_file_name; + +/* Current display position in file. Maintained by de.c */ +extern int dis_line; +extern int dis_col; + +/* Current cursor position in file. */ +extern int line; +extern int col; + +/* + * Calls from de_win.c to de.c + */ + +CORD retrieve_screen_line(int i); + /* Get the contents of i'th screen line. */ + /* Relies on COLS. */ + +void set_position(int x, int y); + /* Set column, row. Upper left of window = (0,0). */ + +void do_command(int); + /* Execute an editor command. */ + /* Agument is a command character or one */ + /* of the IDM_ commands. */ + +void generic_init(void); + /* OS independent initialization */ + + +/* + * Calls from de.c to de_win.c + */ + +void move_cursor(int column, int line); + /* Physically move the cursor on the display, */ + /* so that it appears at */ + /* (column, line). */ + +void invalidate_line(int line); + /* Invalidate line i on the screen. */ + +void de_error(char *s); + /* Display error message. */ \ No newline at end of file diff --git a/support/gc/cord/ec.h b/support/gc/cord/ec.h new file mode 100644 index 00000000..c829b83a --- /dev/null +++ b/support/gc/cord/ec.h @@ -0,0 +1,70 @@ +# ifndef EC_H +# define EC_H + +# ifndef CORD_H +# include "cord.h" +# endif + +/* Extensible cords are strings that may be destructively appended to. */ +/* They allow fast construction of cords from characters that are */ +/* being read from a stream. */ +/* + * A client might look like: + * + * { + * CORD_ec x; + * CORD result; + * char c; + * FILE *f; + * + * ... + * CORD_ec_init(x); + * while(...) { + * c = getc(f); + * ... + * CORD_ec_append(x, c); + * } + * result = CORD_balance(CORD_ec_to_cord(x)); + * + * If a C string is desired as the final result, the call to CORD_balance + * may be replaced by a call to CORD_to_char_star. + */ + +# ifndef CORD_BUFSZ +# define CORD_BUFSZ 128 +# endif + +typedef struct CORD_ec_struct { + CORD ec_cord; + char * ec_bufptr; + char ec_buf[CORD_BUFSZ+1]; +} CORD_ec[1]; + +/* This structure represents the concatenation of ec_cord with */ +/* ec_buf[0 ... (ec_bufptr-ec_buf-1)] */ + +/* Flush the buffer part of the extended chord into ec_cord. */ +/* Note that this is almost the only real function, and it is */ +/* implemented in 6 lines in cordxtra.c */ +void CORD_ec_flush_buf(CORD_ec x); + +/* Convert an extensible cord to a cord. */ +# define CORD_ec_to_cord(x) (CORD_ec_flush_buf(x), (x)[0].ec_cord) + +/* Initialize an extensible cord. */ +# define CORD_ec_init(x) ((x)[0].ec_cord = 0, (x)[0].ec_bufptr = (x)[0].ec_buf) + +/* Append a character to an extensible cord. */ +# define CORD_ec_append(x, c) \ + { \ + if ((x)[0].ec_bufptr == (x)[0].ec_buf + CORD_BUFSZ) { \ + CORD_ec_flush_buf(x); \ + } \ + *((x)[0].ec_bufptr)++ = (c); \ + } + +/* Append a cord to an extensible cord. Structure remains shared with */ +/* original. */ +void CORD_ec_append_cord(CORD_ec x, CORD s); + +# endif /* EC_H */ diff --git a/support/gc/cord/gc.h b/support/gc/cord/gc.h new file mode 100644 index 00000000..eb9a7f60 --- /dev/null +++ b/support/gc/cord/gc.h @@ -0,0 +1,720 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + * Copyright 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* + * Note that this defines a large number of tuning hooks, which can + * safely be ignored in nearly all cases. For normal use it suffices + * to call only GC_MALLOC and perhaps GC_REALLOC. + * For better performance, also look at GC_MALLOC_ATOMIC, and + * GC_enable_incremental. If you need an action to be performed + * immediately before an object is collected, look at GC_register_finalizer. + * If you are using Solaris threads, look at the end of this file. + * Everything else is best ignored unless you encounter performance + * problems. + */ + +#ifndef _GC_H + +# define _GC_H +# define __GC +# include + +#if defined(__CYGWIN32__) && defined(GC_USE_DLL) +#include "libgc_globals.h" +#endif + +#if defined(_MSC_VER) && defined(_DLL) +# ifdef GC_BUILD +# define GC_API __declspec(dllexport) +# else +# define GC_API __declspec(dllimport) +# endif +#endif + +#if defined(__WATCOMC__) && defined(GC_DLL) +# ifdef GC_BUILD +# define GC_API extern __declspec(dllexport) +# else +# define GC_API extern __declspec(dllimport) +# endif +#endif + +#ifndef GC_API +#define GC_API extern +#endif + +# if defined(__STDC__) || defined(__cplusplus) +# define GC_PROTO(args) args + typedef void * GC_PTR; +# else +# define GC_PROTO(args) () + typedef char * GC_PTR; +# endif + +# ifdef __cplusplus + extern "C" { +# endif + + +/* Define word and signed_word to be unsigned and signed types of the */ +/* size as char * or void *. There seems to be no way to do this */ +/* even semi-portably. The following is probably no better/worse */ +/* than almost anything else. */ +/* The ANSI standard suggests that size_t and ptr_diff_t might be */ +/* better choices. But those appear to have incorrect definitions */ +/* on may systems. Notably "typedef int size_t" seems to be both */ +/* frequent and WRONG. */ +typedef unsigned long GC_word; +typedef long GC_signed_word; + +/* Public read-only variables */ + +GC_API GC_word GC_gc_no;/* Counter incremented per collection. */ + /* Includes empty GCs at startup. */ + + +/* Public R/W variables */ + +GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested)); + /* When there is insufficient memory to satisfy */ + /* an allocation request, we return */ + /* (*GC_oom_fn)(). By default this just */ + /* returns 0. */ + /* If it returns, it must return 0 or a valid */ + /* pointer to a previously allocated heap */ + /* object. */ + +GC_API int GC_quiet; /* Disable statistics output. Only matters if */ + /* collector has been compiled with statistics */ + /* enabled. This involves a performance cost, */ + /* and is thus not the default. */ + +GC_API int GC_dont_gc; /* Dont collect unless explicitly requested, e.g. */ + /* because it's not safe. */ + +GC_API int GC_dont_expand; + /* Dont expand heap unless explicitly requested */ + /* or forced to. */ + +GC_API int GC_full_freq; /* Number of partial collections between */ + /* full collections. Matters only if */ + /* GC_incremental is set. */ + +GC_API GC_word GC_non_gc_bytes; + /* Bytes not considered candidates for collection. */ + /* Used only to control scheduling of collections. */ + +GC_API GC_word GC_free_space_divisor; + /* We try to make sure that we allocate at */ + /* least N/GC_free_space_divisor bytes between */ + /* collections, where N is the heap size plus */ + /* a rough estimate of the root set size. */ + /* Initially, GC_free_space_divisor = 4. */ + /* Increasing its value will use less space */ + /* but more collection time. Decreasing it */ + /* will appreciably decrease collection time */ + /* at the expense of space. */ + /* GC_free_space_divisor = 1 will effectively */ + /* disable collections. */ + +GC_API GC_word GC_max_retries; + /* The maximum number of GCs attempted before */ + /* reporting out of memory after heap */ + /* expansion fails. Initially 0. */ + + +/* Public procedures */ +/* + * general purpose allocation routines, with roughly malloc calling conv. + * The atomic versions promise that no relevant pointers are contained + * in the object. The nonatomic versions guarantee that the new object + * is cleared. GC_malloc_stubborn promises that no changes to the object + * will occur after GC_end_stubborn_change has been called on the + * result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object + * that is scanned for pointers to collectable objects, but is not itself + * collectable. GC_malloc_uncollectable and GC_free called on the resulting + * object implicitly update GC_non_gc_bytes appropriately. + */ +GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes)); + +/* The following is only defined if the library has been suitably */ +/* compiled: */ +GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes)); + +/* Explicitly deallocate an object. Dangerous if used incorrectly. */ +/* Requires a pointer to the base of an object. */ +/* If the argument is stubborn, it should not be changeable when freed. */ +/* An object should not be enable for finalization when it is */ +/* explicitly deallocated. */ +/* GC_free(0) is a no-op, as required by ANSI C for free. */ +GC_API void GC_free GC_PROTO((GC_PTR object_addr)); + +/* + * Stubborn objects may be changed only if the collector is explicitly informed. + * The collector is implicitly informed of coming change when such + * an object is first allocated. The following routines inform the + * collector that an object will no longer be changed, or that it will + * once again be changed. Only nonNIL pointer stores into the object + * are considered to be changes. The argument to GC_end_stubborn_change + * must be exacly the value returned by GC_malloc_stubborn or passed to + * GC_change_stubborn. (In the second case it may be an interior pointer + * within 512 bytes of the beginning of the objects.) + * There is a performance penalty for allowing more than + * one stubborn object to be changed at once, but it is acceptable to + * do so. The same applies to dropping stubborn objects that are still + * changeable. + */ +GC_API void GC_change_stubborn GC_PROTO((GC_PTR)); +GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR)); + +/* Return a pointer to the base (lowest address) of an object given */ +/* a pointer to a location within the object. */ +/* Return 0 if displaced_pointer doesn't point to within a valid */ +/* object. */ +GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer)); + +/* Given a pointer to the base of an object, return its size in bytes. */ +/* The returned size may be slightly larger than what was originally */ +/* requested. */ +GC_API size_t GC_size GC_PROTO((GC_PTR object_addr)); + +/* For compatibility with C library. This is occasionally faster than */ +/* a malloc followed by a bcopy. But if you rely on that, either here */ +/* or with the standard C library, your code is broken. In my */ +/* opinion, it shouldn't have been invented, but now we're stuck. -HB */ +/* The resulting object has the same kind as the original. */ +/* If the argument is stubborn, the result will have changes enabled. */ +/* It is an error to have changes enabled for the original object. */ +/* Follows ANSI comventions for NULL old_object. */ +GC_API GC_PTR GC_realloc + GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes)); + +/* Explicitly increase the heap size. */ +/* Returns 0 on failure, 1 on success. */ +GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes)); + +/* Limit the heap size to n bytes. Useful when you're debugging, */ +/* especially on systems that don't handle running out of memory well. */ +/* n == 0 ==> unbounded. This is the default. */ +GC_API void GC_set_max_heap_size GC_PROTO((GC_word n)); + +/* Inform the collector that a certain section of statically allocated */ +/* memory contains no pointers to garbage collected memory. Thus it */ +/* need not be scanned. This is sometimes important if the application */ +/* maps large read/write files into the address space, which could be */ +/* mistaken for dynamic library data segments on some systems. */ +GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish)); + +/* Clear the set of root segments. Wizards only. */ +GC_API void GC_clear_roots GC_PROTO((void)); + +/* Add a root segment. Wizards only. */ +GC_API void GC_add_roots GC_PROTO((char * low_address, + char * high_address_plus_1)); + +/* Add a displacement to the set of those considered valid by the */ +/* collector. GC_register_displacement(n) means that if p was returned */ +/* by GC_malloc, then (char *)p + n will be considered to be a valid */ +/* pointer to n. N must be small and less than the size of p. */ +/* (All pointers to the interior of objects from the stack are */ +/* considered valid in any case. This applies to heap objects and */ +/* static data.) */ +/* Preferably, this should be called before any other GC procedures. */ +/* Calling it later adds to the probability of excess memory */ +/* retention. */ +/* This is a no-op if the collector was compiled with recognition of */ +/* arbitrary interior pointers enabled, which is now the default. */ +GC_API void GC_register_displacement GC_PROTO((GC_word n)); + +/* The following version should be used if any debugging allocation is */ +/* being done. */ +GC_API void GC_debug_register_displacement GC_PROTO((GC_word n)); + +/* Explicitly trigger a full, world-stop collection. */ +GC_API void GC_gcollect GC_PROTO((void)); + +/* Trigger a full world-stopped collection. Abort the collection if */ +/* and when stop_func returns a nonzero value. Stop_func will be */ +/* called frequently, and should be reasonably fast. This works even */ +/* if virtual dirty bits, and hence incremental collection is not */ +/* available for this architecture. Collections can be aborted faster */ +/* than normal pause times for incremental collection. However, */ +/* aborted collections do no useful work; the next collection needs */ +/* to start from the beginning. */ +typedef int (* GC_stop_func) GC_PROTO((void)); +GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func)); + +/* Return the number of bytes in the heap. Excludes collector private */ +/* data structures. Includes empty blocks and fragmentation loss. */ +/* Includes some pages that were allocated but never written. */ +GC_API size_t GC_get_heap_size GC_PROTO((void)); + +/* Return the number of bytes allocated since the last collection. */ +GC_API size_t GC_get_bytes_since_gc GC_PROTO((void)); + +/* Enable incremental/generational collection. */ +/* Not advisable unless dirty bits are */ +/* available or most heap objects are */ +/* pointerfree(atomic) or immutable. */ +/* Don't use in leak finding mode. */ +/* Ignored if GC_dont_gc is true. */ +GC_API void GC_enable_incremental GC_PROTO((void)); + +/* Perform some garbage collection work, if appropriate. */ +/* Return 0 if there is no more work to be done. */ +/* Typically performs an amount of work corresponding roughly */ +/* to marking from one page. May do more work if further */ +/* progress requires it, e.g. if incremental collection is */ +/* disabled. It is reasonable to call this in a wait loop */ +/* until it returns 0. */ +GC_API int GC_collect_a_little GC_PROTO((void)); + +/* Allocate an object of size lb bytes. The client guarantees that */ +/* as long as the object is live, it will be referenced by a pointer */ +/* that points to somewhere within the first 256 bytes of the object. */ +/* (This should normally be declared volatile to prevent the compiler */ +/* from invalidating this assertion.) This routine is only useful */ +/* if a large array is being allocated. It reduces the chance of */ +/* accidentally retaining such an array as a result of scanning an */ +/* integer that happens to be an address inside the array. (Actually, */ +/* it reduces the chance of the allocator not finding space for such */ +/* an array, since it will try hard to avoid introducing such a false */ +/* reference.) On a SunOS 4.X or MS Windows system this is recommended */ +/* for arrays likely to be larger than 100K or so. For other systems, */ +/* or if the collector is not configured to recognize all interior */ +/* pointers, the threshold is normally much higher. */ +GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb)); +GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb)); + +#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720 +# define GC_ADD_CALLER +# define GC_RETURN_ADDR (GC_word)__return_address +#endif + +#ifdef GC_ADD_CALLER +# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__ +# define GC_EXTRA_PARAMS GC_word ra, char * descr_string, int descr_int +#else +# define GC_EXTRAS __FILE__, __LINE__ +# define GC_EXTRA_PARAMS char * descr_string, int descr_int +#endif + +/* Debugging (annotated) allocation. GC_gcollect will check */ +/* objects allocated in this way for overwrites, etc. */ +GC_API GC_PTR GC_debug_malloc + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_atomic + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_uncollectable + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_stubborn + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr)); +GC_API GC_PTR GC_debug_realloc + GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes, + GC_EXTRA_PARAMS)); + +GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR)); +GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR)); +# ifdef GC_DEBUG +# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS) +# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS) +# define GC_MALLOC_UNCOLLECTABLE(sz) GC_debug_malloc_uncollectable(sz, \ + GC_EXTRAS) +# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS) +# define GC_FREE(p) GC_debug_free(p) +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_debug_register_finalizer(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \ + GC_debug_register_finalizer_ignore_self(p, f, d, of, od) +# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS); +# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p) +# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p) +# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \ + GC_general_register_disappearing_link(link, GC_base(obj)) +# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n) +# else +# define GC_MALLOC(sz) GC_malloc(sz) +# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz) +# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz) +# define GC_REALLOC(old, sz) GC_realloc(old, sz) +# define GC_FREE(p) GC_free(p) +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_register_finalizer(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \ + GC_register_finalizer_ignore_self(p, f, d, of, od) +# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz) +# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p) +# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p) +# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \ + GC_general_register_disappearing_link(link, obj) +# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n) +# endif +/* The following are included because they are often convenient, and */ +/* reduce the chance for a misspecifed size argument. But calls may */ +/* expand to something syntactically incorrect if t is a complicated */ +/* type expression. */ +# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t)) +# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t)) +# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t)) +# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t)) + +/* Finalization. Some of these primitives are grossly unsafe. */ +/* The idea is to make them both cheap, and sufficient to build */ +/* a safer layer, closer to PCedar finalization. */ +/* The interface represents my conclusions from a long discussion */ +/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */ +/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */ +/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */ +typedef void (*GC_finalization_proc) + GC_PROTO((GC_PTR obj, GC_PTR client_data)); + +GC_API void GC_register_finalizer + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); +GC_API void GC_debug_register_finalizer + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); + /* When obj is no longer accessible, invoke */ + /* (*fn)(obj, cd). If a and b are inaccessible, and */ + /* a points to b (after disappearing links have been */ + /* made to disappear), then only a will be */ + /* finalized. (If this does not create any new */ + /* pointers to b, then b will be finalized after the */ + /* next collection.) Any finalizable object that */ + /* is reachable from itself by following one or more */ + /* pointers will not be finalized (or collected). */ + /* Thus cycles involving finalizable objects should */ + /* be avoided, or broken by disappearing links. */ + /* All but the last finalizer registered for an object */ + /* is ignored. */ + /* Finalization may be removed by passing 0 as fn. */ + /* Finalizers are implicitly unregistered just before */ + /* they are invoked. */ + /* The old finalizer and client data are stored in */ + /* *ofn and *ocd. */ + /* Fn is never invoked on an accessible object, */ + /* provided hidden pointers are converted to real */ + /* pointers only if the allocation lock is held, and */ + /* such conversions are not performed by finalization */ + /* routines. */ + /* If GC_register_finalizer is aborted as a result of */ + /* a signal, the object may be left with no */ + /* finalization, even if neither the old nor new */ + /* finalizer were NULL. */ + /* Obj should be the nonNULL starting address of an */ + /* object allocated by GC_malloc or friends. */ + /* Note that any garbage collectable object referenced */ + /* by cd will be considered accessible until the */ + /* finalizer is invoked. */ + +/* Another versions of the above follow. It ignores */ +/* self-cycles, i.e. pointers from a finalizable object to */ +/* itself. There is a stylistic argument that this is wrong, */ +/* but it's unavoidable for C++, since the compiler may */ +/* silently introduce these. It's also benign in that specific */ +/* case. */ +GC_API void GC_register_finalizer_ignore_self + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); +GC_API void GC_debug_register_finalizer_ignore_self + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); + +/* The following routine may be used to break cycles between */ +/* finalizable objects, thus causing cyclic finalizable */ +/* objects to be finalized in the correct order. Standard */ +/* use involves calling GC_register_disappearing_link(&p), */ +/* where p is a pointer that is not followed by finalization */ +/* code, and should not be considered in determining */ +/* finalization order. */ +GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */)); + /* Link should point to a field of a heap allocated */ + /* object obj. *link will be cleared when obj is */ + /* found to be inaccessible. This happens BEFORE any */ + /* finalization code is invoked, and BEFORE any */ + /* decisions about finalization order are made. */ + /* This is useful in telling the finalizer that */ + /* some pointers are not essential for proper */ + /* finalization. This may avoid finalization cycles. */ + /* Note that obj may be resurrected by another */ + /* finalizer, and thus the clearing of *link may */ + /* be visible to non-finalization code. */ + /* There's an argument that an arbitrary action should */ + /* be allowed here, instead of just clearing a pointer. */ + /* But this causes problems if that action alters, or */ + /* examines connectivity. */ + /* Returns 1 if link was already registered, 0 */ + /* otherwise. */ + /* Only exists for backward compatibility. See below: */ + +GC_API int GC_general_register_disappearing_link + GC_PROTO((GC_PTR * /* link */, GC_PTR obj)); + /* A slight generalization of the above. *link is */ + /* cleared when obj first becomes inaccessible. This */ + /* can be used to implement weak pointers easily and */ + /* safely. Typically link will point to a location */ + /* holding a disguised pointer to obj. (A pointer */ + /* inside an "atomic" object is effectively */ + /* disguised.) In this way soft */ + /* pointers are broken before any object */ + /* reachable from them are finalized. Each link */ + /* May be registered only once, i.e. with one obj */ + /* value. This was added after a long email discussion */ + /* with John Ellis. */ + /* Obj must be a pointer to the first word of an object */ + /* we allocated. It is unsafe to explicitly deallocate */ + /* the object containing link. Explicitly deallocating */ + /* obj may or may not cause link to eventually be */ + /* cleared. */ +GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */)); + /* Returns 0 if link was not actually registered. */ + /* Undoes a registration by either of the above two */ + /* routines. */ + +/* Auxiliary fns to make finalization work correctly with displaced */ +/* pointers introduced by the debugging allocators. */ +GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data)); +GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data)); + +GC_API int GC_invoke_finalizers GC_PROTO((void)); + /* Run finalizers for all objects that are ready to */ + /* be finalized. Return the number of finalizers */ + /* that were run. Normally this is also called */ + /* implicitly during some allocations. If */ + /* FINALIZE_ON_DEMAND is defined, it must be called */ + /* explicitly. */ + +/* GC_set_warn_proc can be used to redirect or filter warning messages. */ +/* p may not be a NULL pointer. */ +typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg)); +GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p)); + /* Returns old warning procedure. */ + +/* The following is intended to be used by a higher level */ +/* (e.g. cedar-like) finalization facility. It is expected */ +/* that finalization code will arrange for hidden pointers to */ +/* disappear. Otherwise objects can be accessed after they */ +/* have been collected. */ +/* Note that putting pointers in atomic objects or in */ +/* nonpointer slots of "typed" objects is equivalent to */ +/* disguising them in this way, and may have other advantages. */ +# if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS) + typedef GC_word GC_hidden_pointer; +# define HIDE_POINTER(p) (~(GC_hidden_pointer)(p)) +# define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p))) + /* Converting a hidden pointer to a real pointer requires verifying */ + /* that the object still exists. This involves acquiring the */ + /* allocator lock to avoid a race with the collector. */ +# endif /* I_HIDE_POINTERS */ + +typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data)); +GC_API GC_PTR GC_call_with_alloc_lock + GC_PROTO((GC_fn_type fn, GC_PTR client_data)); + +/* Check that p and q point to the same object. */ +/* Fail conspicuously if they don't. */ +/* Returns the first argument. */ +/* Succeeds if neither p nor q points to the heap. */ +/* May succeed if both p and q point to between heap objects. */ +GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q)); + +/* Checked pointer pre- and post- increment operations. Note that */ +/* the second argument is in units of bytes, not multiples of the */ +/* object size. This should either be invoked from a macro, or the */ +/* call should be automatically generated. */ +GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much)); +GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much)); + +/* Check that p is visible */ +/* to the collector as a possibly pointer containing location. */ +/* If it isn't fail conspicuously. */ +/* Returns the argument in all cases. May erroneously succeed */ +/* in hard cases. (This is intended for debugging use with */ +/* untyped allocations. The idea is that it should be possible, though */ +/* slow, to add such a call to all indirect pointer stores.) */ +/* Currently useless for multithreaded worlds. */ +GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p)); + +/* Check that if p is a pointer to a heap page, then it points to */ +/* a valid displacement within a heap object. */ +/* Fail conspicuously if this property does not hold. */ +/* Uninteresting with ALL_INTERIOR_POINTERS. */ +/* Always returns its argument. */ +GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p)); + +/* Safer, but slow, pointer addition. Probably useful mainly with */ +/* a preprocessor. Useful only for heap pointers. */ +#ifdef GC_DEBUG +# define GC_PTR_ADD3(x, n, type_of_result) \ + ((type_of_result)GC_same_obj((x)+(n), (x))) +# define GC_PRE_INCR3(x, n, type_of_result) \ + ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x)) +# define GC_POST_INCR2(x, type_of_result) \ + ((type_of_result)GC_post_incr(&(x), sizeof(*x)) +# ifdef __GNUC__ +# define GC_PTR_ADD(x, n) \ + GC_PTR_ADD3(x, n, typeof(x)) +# define GC_PRE_INCR(x, n) \ + GC_PRE_INCR3(x, n, typeof(x)) +# define GC_POST_INCR(x, n) \ + GC_POST_INCR3(x, typeof(x)) +# else + /* We can't do this right without typeof, which ANSI */ + /* decided was not sufficiently useful. Repeatedly */ + /* mentioning the arguments seems too dangerous to be */ + /* useful. So does not casting the result. */ +# define GC_PTR_ADD(x, n) ((x)+(n)) +# endif +#else /* !GC_DEBUG */ +# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n)) +# define GC_PTR_ADD(x, n) ((x)+(n)) +# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n)) +# define GC_PRE_INCR(x, n) ((x) += (n)) +# define GC_POST_INCR2(x, n, type_of_result) ((x)++) +# define GC_POST_INCR(x, n) ((x)++) +#endif + +/* Safer assignment of a pointer to a nonstack location. */ +#ifdef GC_DEBUG +# ifdef __STDC__ +# define GC_PTR_STORE(p, q) \ + (*(void **)GC_is_visible(p) = GC_is_valid_displacement(q)) +# else +# define GC_PTR_STORE(p, q) \ + (*(char **)GC_is_visible(p) = GC_is_valid_displacement(q)) +# endif +#else /* !GC_DEBUG */ +# define GC_PTR_STORE(p, q) *((p) = (q)) +#endif + +/* Fynctions called to report pointer checking errors */ +GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q)); + +GC_API void (*GC_is_valid_displacement_print_proc) + GC_PROTO((GC_PTR p)); + +GC_API void (*GC_is_visible_print_proc) + GC_PROTO((GC_PTR p)); + +#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) +# define SOLARIS_THREADS +#endif + +#ifdef SOLARIS_THREADS +/* We need to intercept calls to many of the threads primitives, so */ +/* that we can locate thread stacks and stop the world. */ +/* Note also that the collector cannot see thread specific data. */ +/* Thread specific data should generally consist of pointers to */ +/* uncollectable objects, which are deallocated using the destructor */ +/* facility in thr_keycreate. */ +# include +# include + int GC_thr_create(void *stack_base, size_t stack_size, + void *(*start_routine)(void *), void *arg, long flags, + thread_t *new_thread); + int GC_thr_join(thread_t wait_for, thread_t *departed, void **status); + int GC_thr_suspend(thread_t target_thread); + int GC_thr_continue(thread_t target_thread); + void * GC_dlopen(const char *path, int mode); + +# ifdef _SOLARIS_PTHREADS +# include + extern int GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void * (*thread_execp)(void *), void *arg); + extern int GC_pthread_join(pthread_t wait_for, void **status); + +# undef thread_t + +# define pthread_join GC_pthread_join +# define pthread_create GC_pthread_create +#endif + +# define thr_create GC_thr_create +# define thr_join GC_thr_join +# define thr_suspend GC_thr_suspend +# define thr_continue GC_thr_continue +# define dlopen GC_dlopen + +# endif /* SOLARIS_THREADS */ + + +#if defined(IRIX_THREADS) || defined(LINUX_THREADS) +/* We treat these similarly. */ +# include +# include + + int GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void *(*start_routine)(void *), void *arg); + int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset); + int GC_pthread_join(pthread_t thread, void **retval); + +# define pthread_create GC_pthread_create +# define pthread_sigmask GC_pthread_sigmask +# define pthread_join GC_pthread_join + +#endif /* IRIX_THREADS || LINUX_THREADS */ + +# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ + defined(IRIX_THREADS) || defined(LINUX_THREADS) || \ + defined(IRIX_JDK_THREADS) + /* Any flavor of threads except SRC_M3. */ +/* This returns a list of objects, linked through their first */ +/* word. Its use can greatly reduce lock contention problems, since */ +/* the allocation lock can be acquired and released many fewer times. */ +GC_PTR GC_malloc_many(size_t lb); +#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */ + /* in returned list. */ +extern void GC_thr_init(); /* Needed for Solaris/X86 */ + +#endif /* THREADS && !SRC_M3 */ + +/* + * If you are planning on putting + * the collector in a SunOS 5 dynamic library, you need to call GC_INIT() + * from the statically loaded program section. + * This circumvents a Solaris 2.X (X<=4) linker bug. + */ +#if defined(sparc) || defined(__sparc) +# define GC_INIT() { extern end, etext; \ + GC_noop(&end, &etext); } +#else +# if defined(__CYGWIN32__) && defined(GC_USE_DLL) + /* + * Similarly gnu-win32 DLLs need explicit initialization + */ +# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); } +# else +# define GC_INIT() +# endif +#endif + +#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \ + || defined(_WIN32) + /* win32S may not free all resources on process exit. */ + /* This explicitly deallocates the heap. */ + GC_API void GC_win32_free_heap (); +#endif + +#ifdef __cplusplus + } /* end of extern "C" */ +#endif + +#endif /* _GC_H */ diff --git a/support/gc/cord/private/cord_pos.h b/support/gc/cord/private/cord_pos.h new file mode 100644 index 00000000..d2b24bb8 --- /dev/null +++ b/support/gc/cord/private/cord_pos.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, May 19, 1994 2:23 pm PDT */ +# ifndef CORD_POSITION_H + +/* The representation of CORD_position. This is private to the */ +/* implementation, but the size is known to clients. Also */ +/* the implementation of some exported macros relies on it. */ +/* Don't use anything defined here and not in cord.h. */ + +# define MAX_DEPTH 48 + /* The maximum depth of a balanced cord + 1. */ + /* We don't let cords get deeper than MAX_DEPTH. */ + +struct CORD_pe { + CORD pe_cord; + size_t pe_start_pos; +}; + +/* A structure describing an entry on the path from the root */ +/* to current position. */ +typedef struct CORD_Pos { + size_t cur_pos; + int path_len; +# define CORD_POS_INVALID (0x55555555) + /* path_len == INVALID <==> position invalid */ + const char *cur_leaf; /* Current leaf, if it is a string. */ + /* If the current leaf is a function, */ + /* then this may point to function_buf */ + /* containing the next few characters. */ + /* Always points to a valid string */ + /* containing the current character */ + /* unless cur_end is 0. */ + size_t cur_start; /* Start position of cur_leaf */ + size_t cur_end; /* Ending position of cur_leaf */ + /* 0 if cur_leaf is invalid. */ + struct CORD_pe path[MAX_DEPTH + 1]; + /* path[path_len] is the leaf corresponding to cur_pos */ + /* path[0].pe_cord is the cord we point to. */ +# define FUNCTION_BUF_SZ 8 + char function_buf[FUNCTION_BUF_SZ]; /* Space for next few chars */ + /* from function node. */ +} CORD_pos[1]; + +/* Extract the cord from a position: */ +CORD CORD_pos_to_cord(CORD_pos p); + +/* Extract the current index from a position: */ +size_t CORD_pos_to_index(CORD_pos p); + +/* Fetch the character located at the given position: */ +char CORD_pos_fetch(CORD_pos p); + +/* Initialize the position to refer to the give cord and index. */ +/* Note that this is the most expensive function on positions: */ +void CORD_set_pos(CORD_pos p, CORD x, size_t i); + +/* Advance the position to the next character. */ +/* P must be initialized and valid. */ +/* Invalidates p if past end: */ +void CORD_next(CORD_pos p); + +/* Move the position to the preceding character. */ +/* P must be initialized and valid. */ +/* Invalidates p if past beginning: */ +void CORD_prev(CORD_pos p); + +/* Is the position valid, i.e. inside the cord? */ +int CORD_pos_valid(CORD_pos p); + +char CORD__pos_fetch(CORD_pos); +void CORD__next(CORD_pos); +void CORD__prev(CORD_pos); + +#define CORD_pos_fetch(p) \ + (((p)[0].cur_end != 0)? \ + (p)[0].cur_leaf[(p)[0].cur_pos - (p)[0].cur_start] \ + : CORD__pos_fetch(p)) + +#define CORD_next(p) \ + (((p)[0].cur_pos + 1 < (p)[0].cur_end)? \ + (p)[0].cur_pos++ \ + : (CORD__next(p), 0)) + +#define CORD_prev(p) \ + (((p)[0].cur_end != 0 && (p)[0].cur_pos > (p)[0].cur_start)? \ + (p)[0].cur_pos-- \ + : (CORD__prev(p), 0)) + +#define CORD_pos_to_index(p) ((p)[0].cur_pos) + +#define CORD_pos_to_cord(p) ((p)[0].path[0].pe_cord) + +#define CORD_pos_valid(p) ((p)[0].path_len != CORD_POS_INVALID) + +/* Some grubby stuff for performance-critical friends: */ +#define CORD_pos_chars_left(p) ((long)((p)[0].cur_end) - (long)((p)[0].cur_pos)) + /* Number of characters in cache. <= 0 ==> none */ + +#define CORD_pos_advance(p,n) ((p)[0].cur_pos += (n) - 1, CORD_next(p)) + /* Advance position by n characters */ + /* 0 < n < CORD_pos_chars_left(p) */ + +#define CORD_pos_cur_char_addr(p) \ + (p)[0].cur_leaf + ((p)[0].cur_pos - (p)[0].cur_start) + /* address of current character in cache. */ + +#endif diff --git a/support/gc/dbg_mlc.c b/support/gc/dbg_mlc.c new file mode 100644 index 00000000..64832567 --- /dev/null +++ b/support/gc/dbg_mlc.c @@ -0,0 +1,799 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + * Copyright (c) 1997 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +# define I_HIDE_POINTERS +# include "gc_priv.h" +# ifdef KEEP_BACK_PTRS +# include "backptr.h" +# endif + +void GC_default_print_heap_obj_proc(); +GC_API void GC_register_finalizer_no_order + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); + +/* Do we want to and know how to save the call stack at the time of */ +/* an allocation? How much space do we want to use in each object? */ + +# define START_FLAG ((word)0xfedcedcb) +# define END_FLAG ((word)0xbcdecdef) + /* Stored both one past the end of user object, and one before */ + /* the end of the object as seen by the allocator. */ + + +/* Object header */ +typedef struct { +# ifdef KEEP_BACK_PTRS + ptr_t oh_back_ptr; +# define MARKED_FOR_FINALIZATION (ptr_t)(-1) + /* Object was marked because it is finalizable. */ +# ifdef ALIGN_DOUBLE + word oh_dummy; +# endif +# endif + char * oh_string; /* object descriptor string */ + word oh_int; /* object descriptor integers */ +# ifdef NEED_CALLINFO + struct callinfo oh_ci[NFRAMES]; +# endif + word oh_sz; /* Original malloc arg. */ + word oh_sf; /* start flag */ +} oh; +/* The size of the above structure is assumed not to dealign things, */ +/* and to be a multiple of the word length. */ + +#define DEBUG_BYTES (sizeof (oh) + sizeof (word)) +#undef ROUNDED_UP_WORDS +#define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + WORDS_TO_BYTES(1) - 1) + + +#ifdef SAVE_CALL_CHAIN +# define ADD_CALL_CHAIN(base, ra) GC_save_callers(((oh *)(base)) -> oh_ci) +# define PRINT_CALL_CHAIN(base) GC_print_callers(((oh *)(base)) -> oh_ci) +#else +# ifdef GC_ADD_CALLER +# define ADD_CALL_CHAIN(base, ra) ((oh *)(base)) -> oh_ci[0].ci_pc = (ra) +# define PRINT_CALL_CHAIN(base) GC_print_callers(((oh *)(base)) -> oh_ci) +# else +# define ADD_CALL_CHAIN(base, ra) +# define PRINT_CALL_CHAIN(base) +# endif +#endif + +/* Check whether object with base pointer p has debugging info */ +/* p is assumed to point to a legitimate object in our part */ +/* of the heap. */ +GC_bool GC_has_debug_info(p) +ptr_t p; +{ + register oh * ohdr = (oh *)p; + register ptr_t body = (ptr_t)(ohdr + 1); + register word sz = GC_size((ptr_t) ohdr); + + if (HBLKPTR((ptr_t)ohdr) != HBLKPTR((ptr_t)body) + || sz < sizeof (oh)) { + return(FALSE); + } + if (ohdr -> oh_sz == sz) { + /* Object may have had debug info, but has been deallocated */ + return(FALSE); + } + if (ohdr -> oh_sf == (START_FLAG ^ (word)body)) return(TRUE); + if (((word *)ohdr)[BYTES_TO_WORDS(sz)-1] == (END_FLAG ^ (word)body)) { + return(TRUE); + } + return(FALSE); +} + +#ifdef KEEP_BACK_PTRS + /* Store back pointer to source in dest, if that appears to be possible. */ + /* This is not completely safe, since we may mistakenly conclude that */ + /* dest has a debugging wrapper. But the error probability is very */ + /* small, and this shouldn't be used in production code. */ + /* We assume that dest is the real base pointer. Source will usually */ + /* be a pointer to the interior of an object. */ + void GC_store_back_pointer(ptr_t source, ptr_t dest) + { + if (GC_has_debug_info(dest)) { + ((oh *)dest) -> oh_back_ptr = (ptr_t)HIDE_POINTER(source); + } + } + + void GC_marked_for_finalization(ptr_t dest) { + GC_store_back_pointer(MARKED_FOR_FINALIZATION, dest); + } + + /* Store information about the object referencing dest in *base_p */ + /* and *offset_p. */ + /* source is root ==> *base_p = 0, *offset_p = address */ + /* source is heap object ==> *base_p != 0, *offset_p = offset */ + /* Returns 1 on success, 0 if source couldn't be determined. */ + /* Dest can be any address within a heap object. */ + GC_ref_kind GC_get_back_ptr_info(void *dest, void **base_p, size_t *offset_p) + { + oh * hdr = (oh *)GC_base(dest); + ptr_t bp; + ptr_t bp_base; + if (!GC_has_debug_info((ptr_t) hdr)) return GC_NO_SPACE; + bp = hdr -> oh_back_ptr; + if (MARKED_FOR_FINALIZATION == bp) return GC_FINALIZER_REFD; + if (0 == bp) return GC_UNREFERENCED; + bp = REVEAL_POINTER(bp); + bp_base = GC_base(bp); + if (0 == bp_base) { + *base_p = bp; + *offset_p = 0; + return GC_REFD_FROM_ROOT; + } else { + if (GC_has_debug_info(bp_base)) bp_base += sizeof(oh); + *base_p = bp_base; + *offset_p = bp - bp_base; + return GC_REFD_FROM_HEAP; + } + } + + /* Generate a random heap address. */ + /* The resulting address is in the heap, but */ + /* not necessarily inside a valid object. */ + void *GC_generate_random_heap_address(void) + { + int i; + int heap_offset = random() % GC_heapsize; + for (i = 0; i < GC_n_heap_sects; ++ i) { + int size = GC_heap_sects[i].hs_bytes; + if (heap_offset < size) { + return GC_heap_sects[i].hs_start + heap_offset; + } else { + heap_offset -= size; + } + } + ABORT("GC_generate_random_heap_address: size inconsistency"); + /*NOTREACHED*/ + return 0; + } + + /* Generate a random address inside a valid marked heap object. */ + void *GC_generate_random_valid_address(void) + { + ptr_t result; + ptr_t base; + for (;;) { + result = GC_generate_random_heap_address(); + base = GC_base(result); + if (0 == base) continue; + if (!GC_is_marked(base)) continue; + return result; + } + } + + /* Force a garbage collection and generate a backtrace from a */ + /* random heap address. */ + void GC_generate_random_backtrace(void) + { + void * current; + int i; + void * base; + size_t offset; + GC_ref_kind source; + GC_gcollect(); + current = GC_generate_random_valid_address(); + GC_printf1("Chose address 0x%lx in object\n", (unsigned long)current); + GC_print_heap_obj(GC_base(current)); + GC_err_printf0("\n"); + for (i = 0; ; ++i) { + source = GC_get_back_ptr_info(current, &base, &offset); + if (GC_UNREFERENCED == source) { + GC_err_printf0("Reference could not be found\n"); + goto out; + } + if (GC_NO_SPACE == source) { + GC_err_printf0("No debug info in object: Can't find reference\n"); + goto out; + } + GC_err_printf1("Reachable via %d levels of pointers from ", + (unsigned long)i); + switch(source) { + case GC_REFD_FROM_ROOT: + GC_err_printf1("root at 0x%lx\n", (unsigned long)base); + goto out; + case GC_FINALIZER_REFD: + GC_err_printf0("list of finalizable objects\n"); + goto out; + case GC_REFD_FROM_HEAP: + GC_err_printf1("offset %ld in object:\n", (unsigned long)offset); + /* Take GC_base(base) to get real base, i.e. header. */ + GC_print_heap_obj(GC_base(base)); + GC_err_printf0("\n"); + break; + } + current = base; + } + out:; + } + +#endif /* KEEP_BACK_PTRS */ + +/* Store debugging info into p. Return displaced pointer. */ +/* Assumes we don't hold allocation lock. */ +ptr_t GC_store_debug_info(p, sz, string, integer) +register ptr_t p; /* base pointer */ +word sz; /* bytes */ +char * string; +word integer; +{ + register word * result = (word *)((oh *)p + 1); + DCL_LOCK_STATE; + + /* There is some argument that we should dissble signals here. */ + /* But that's expensive. And this way things should only appear */ + /* inconsistent while we're in the handler. */ + LOCK(); +# ifdef KEEP_BACK_PTRS + ((oh *)p) -> oh_back_ptr = 0; +# endif + ((oh *)p) -> oh_string = string; + ((oh *)p) -> oh_int = integer; + ((oh *)p) -> oh_sz = sz; + ((oh *)p) -> oh_sf = START_FLAG ^ (word)result; + ((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] = + result[ROUNDED_UP_WORDS(sz)] = END_FLAG ^ (word)result; + UNLOCK(); + return((ptr_t)result); +} + +/* Check the object with debugging info at ohdr */ +/* return NIL if it's OK. Else return clobbered */ +/* address. */ +ptr_t GC_check_annotated_obj(ohdr) +register oh * ohdr; +{ + register ptr_t body = (ptr_t)(ohdr + 1); + register word gc_sz = GC_size((ptr_t)ohdr); + if (ohdr -> oh_sz + DEBUG_BYTES > gc_sz) { + return((ptr_t)(&(ohdr -> oh_sz))); + } + if (ohdr -> oh_sf != (START_FLAG ^ (word)body)) { + return((ptr_t)(&(ohdr -> oh_sf))); + } + if (((word *)ohdr)[BYTES_TO_WORDS(gc_sz)-1] != (END_FLAG ^ (word)body)) { + return((ptr_t)((word *)ohdr + BYTES_TO_WORDS(gc_sz)-1)); + } + if (((word *)body)[ROUNDED_UP_WORDS(ohdr -> oh_sz)] + != (END_FLAG ^ (word)body)) { + return((ptr_t)((word *)body + ROUNDED_UP_WORDS(ohdr -> oh_sz))); + } + return(0); +} + +void GC_print_obj(p) +ptr_t p; +{ + register oh * ohdr = (oh *)GC_base(p); + + GC_err_printf1("0x%lx (", ((unsigned long)ohdr + sizeof(oh))); + GC_err_puts(ohdr -> oh_string); + GC_err_printf2(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int), + (unsigned long)(ohdr -> oh_sz)); + PRINT_CALL_CHAIN(ohdr); +} + +void GC_debug_print_heap_obj_proc(p) +ptr_t p; +{ + if (GC_has_debug_info(p)) { + GC_print_obj(p); + } else { + GC_default_print_heap_obj_proc(p); + } +} + +void GC_print_smashed_obj(p, clobbered_addr) +ptr_t p, clobbered_addr; +{ + register oh * ohdr = (oh *)GC_base(p); + + GC_err_printf2("0x%lx in object at 0x%lx(", (unsigned long)clobbered_addr, + (unsigned long)p); + if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz)) + || ohdr -> oh_string == 0) { + GC_err_printf1(", appr. sz = %ld)\n", + (GC_size((ptr_t)ohdr) - DEBUG_BYTES)); + } else { + if (ohdr -> oh_string[0] == '\0') { + GC_err_puts("EMPTY(smashed?)"); + } else { + GC_err_puts(ohdr -> oh_string); + } + GC_err_printf2(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int), + (unsigned long)(ohdr -> oh_sz)); + PRINT_CALL_CHAIN(ohdr); + } +} + +void GC_check_heap_proc(); + +void GC_start_debugging() +{ + GC_check_heap = GC_check_heap_proc; + GC_print_heap_obj = GC_debug_print_heap_obj_proc; + GC_debugging_started = TRUE; + GC_register_displacement((word)sizeof(oh)); +} + +# if defined(__STDC__) || defined(__cplusplus) + void GC_debug_register_displacement(GC_word offset) +# else + void GC_debug_register_displacement(offset) + GC_word offset; +# endif +{ + GC_register_displacement(offset); + GC_register_displacement((word)sizeof(oh) + offset); +} + +# ifdef GC_ADD_CALLER +# define EXTRA_ARGS word ra, char * s, int i +# define OPT_RA ra, +# else +# define EXTRA_ARGS char * s, int i +# define OPT_RA +# endif + +# ifdef __STDC__ + GC_PTR GC_debug_malloc(size_t lb, EXTRA_ARGS) +# else + GC_PTR GC_debug_malloc(lb, s, i) + size_t lb; + char * s; + int i; +# ifdef GC_ADD_CALLER + --> GC_ADD_CALLER not implemented for K&R C +# endif +# endif +{ + GC_PTR result = GC_malloc(lb + DEBUG_BYTES); + + if (result == 0) { + GC_err_printf1("GC_debug_malloc(%ld) returning NIL (", + (unsigned long) lb); + GC_err_puts(s); + GC_err_printf1(":%ld)\n", (unsigned long)i); + return(0); + } + if (!GC_debugging_started) { + GC_start_debugging(); + } + ADD_CALL_CHAIN(result, ra); + return (GC_store_debug_info(result, (word)lb, s, (word)i)); +} + +#ifdef STUBBORN_ALLOC +# ifdef __STDC__ + GC_PTR GC_debug_malloc_stubborn(size_t lb, EXTRA_ARGS) +# else + GC_PTR GC_debug_malloc_stubborn(lb, s, i) + size_t lb; + char * s; + int i; +# endif +{ + GC_PTR result = GC_malloc_stubborn(lb + DEBUG_BYTES); + + if (result == 0) { + GC_err_printf1("GC_debug_malloc(%ld) returning NIL (", + (unsigned long) lb); + GC_err_puts(s); + GC_err_printf1(":%ld)\n", (unsigned long)i); + return(0); + } + if (!GC_debugging_started) { + GC_start_debugging(); + } + ADD_CALL_CHAIN(result, ra); + return (GC_store_debug_info(result, (word)lb, s, (word)i)); +} + +void GC_debug_change_stubborn(p) +GC_PTR p; +{ + register GC_PTR q = GC_base(p); + register hdr * hhdr; + + if (q == 0) { + GC_err_printf1("Bad argument: 0x%lx to GC_debug_change_stubborn\n", + (unsigned long) p); + ABORT("GC_debug_change_stubborn: bad arg"); + } + hhdr = HDR(q); + if (hhdr -> hb_obj_kind != STUBBORN) { + GC_err_printf1("GC_debug_change_stubborn arg not stubborn: 0x%lx\n", + (unsigned long) p); + ABORT("GC_debug_change_stubborn: arg not stubborn"); + } + GC_change_stubborn(q); +} + +void GC_debug_end_stubborn_change(p) +GC_PTR p; +{ + register GC_PTR q = GC_base(p); + register hdr * hhdr; + + if (q == 0) { + GC_err_printf1("Bad argument: 0x%lx to GC_debug_end_stubborn_change\n", + (unsigned long) p); + ABORT("GC_debug_end_stubborn_change: bad arg"); + } + hhdr = HDR(q); + if (hhdr -> hb_obj_kind != STUBBORN) { + GC_err_printf1("debug_end_stubborn_change arg not stubborn: 0x%lx\n", + (unsigned long) p); + ABORT("GC_debug_end_stubborn_change: arg not stubborn"); + } + GC_end_stubborn_change(q); +} + +#endif /* STUBBORN_ALLOC */ + +# ifdef __STDC__ + GC_PTR GC_debug_malloc_atomic(size_t lb, EXTRA_ARGS) +# else + GC_PTR GC_debug_malloc_atomic(lb, s, i) + size_t lb; + char * s; + int i; +# endif +{ + GC_PTR result = GC_malloc_atomic(lb + DEBUG_BYTES); + + if (result == 0) { + GC_err_printf1("GC_debug_malloc_atomic(%ld) returning NIL (", + (unsigned long) lb); + GC_err_puts(s); + GC_err_printf1(":%ld)\n", (unsigned long)i); + return(0); + } + if (!GC_debugging_started) { + GC_start_debugging(); + } + ADD_CALL_CHAIN(result, ra); + return (GC_store_debug_info(result, (word)lb, s, (word)i)); +} + +# ifdef __STDC__ + GC_PTR GC_debug_malloc_uncollectable(size_t lb, EXTRA_ARGS) +# else + GC_PTR GC_debug_malloc_uncollectable(lb, s, i) + size_t lb; + char * s; + int i; +# endif +{ + GC_PTR result = GC_malloc_uncollectable(lb + DEBUG_BYTES); + + if (result == 0) { + GC_err_printf1("GC_debug_malloc_uncollectable(%ld) returning NIL (", + (unsigned long) lb); + GC_err_puts(s); + GC_err_printf1(":%ld)\n", (unsigned long)i); + return(0); + } + if (!GC_debugging_started) { + GC_start_debugging(); + } + ADD_CALL_CHAIN(result, ra); + return (GC_store_debug_info(result, (word)lb, s, (word)i)); +} + +#ifdef ATOMIC_UNCOLLECTABLE +# ifdef __STDC__ + GC_PTR GC_debug_malloc_atomic_uncollectable(size_t lb, EXTRA_ARGS) +# else + GC_PTR GC_debug_malloc_atomic_uncollectable(lb, s, i) + size_t lb; + char * s; + int i; +# endif +{ + GC_PTR result = GC_malloc_atomic_uncollectable(lb + DEBUG_BYTES); + + if (result == 0) { + GC_err_printf1( + "GC_debug_malloc_atomic_uncollectable(%ld) returning NIL (", + (unsigned long) lb); + GC_err_puts(s); + GC_err_printf1(":%ld)\n", (unsigned long)i); + return(0); + } + if (!GC_debugging_started) { + GC_start_debugging(); + } + ADD_CALL_CHAIN(result, ra); + return (GC_store_debug_info(result, (word)lb, s, (word)i)); +} +#endif /* ATOMIC_UNCOLLECTABLE */ + +# ifdef __STDC__ + void GC_debug_free(GC_PTR p) +# else + void GC_debug_free(p) + GC_PTR p; +# endif +{ + register GC_PTR base = GC_base(p); + register ptr_t clobbered; + + if (base == 0) { + GC_err_printf1("Attempt to free invalid pointer %lx\n", + (unsigned long)p); + if (p != 0) ABORT("free(invalid pointer)"); + } + if ((ptr_t)p - (ptr_t)base != sizeof(oh)) { + GC_err_printf1( + "GC_debug_free called on pointer %lx wo debugging info\n", + (unsigned long)p); + } else { + clobbered = GC_check_annotated_obj((oh *)base); + if (clobbered != 0) { + if (((oh *)base) -> oh_sz == GC_size(base)) { + GC_err_printf0( + "GC_debug_free: found previously deallocated (?) object at "); + } else { + GC_err_printf0("GC_debug_free: found smashed location at "); + } + GC_print_smashed_obj(p, clobbered); + } + /* Invalidate size */ + ((oh *)base) -> oh_sz = GC_size(base); + } + if (GC_find_leak) { + GC_free(base); + } else { + register hdr * hhdr = HDR(p); + GC_bool uncollectable = FALSE; + + if (hhdr -> hb_obj_kind == UNCOLLECTABLE) { + uncollectable = TRUE; + } +# ifdef ATOMIC_UNCOLLECTABLE + if (hhdr -> hb_obj_kind == AUNCOLLECTABLE) { + uncollectable = TRUE; + } +# endif + if (uncollectable) GC_free(base); + } /* !GC_find_leak */ +} + +# ifdef __STDC__ + GC_PTR GC_debug_realloc(GC_PTR p, size_t lb, EXTRA_ARGS) +# else + GC_PTR GC_debug_realloc(p, lb, s, i) + GC_PTR p; + size_t lb; + char *s; + int i; +# endif +{ + register GC_PTR base = GC_base(p); + register ptr_t clobbered; + register GC_PTR result; + register size_t copy_sz = lb; + register size_t old_sz; + register hdr * hhdr; + + if (p == 0) return(GC_debug_malloc(lb, OPT_RA s, i)); + if (base == 0) { + GC_err_printf1( + "Attempt to reallocate invalid pointer %lx\n", (unsigned long)p); + ABORT("realloc(invalid pointer)"); + } + if ((ptr_t)p - (ptr_t)base != sizeof(oh)) { + GC_err_printf1( + "GC_debug_realloc called on pointer %lx wo debugging info\n", + (unsigned long)p); + return(GC_realloc(p, lb)); + } + hhdr = HDR(base); + switch (hhdr -> hb_obj_kind) { +# ifdef STUBBORN_ALLOC + case STUBBORN: + result = GC_debug_malloc_stubborn(lb, OPT_RA s, i); + break; +# endif + case NORMAL: + result = GC_debug_malloc(lb, OPT_RA s, i); + break; + case PTRFREE: + result = GC_debug_malloc_atomic(lb, OPT_RA s, i); + break; + case UNCOLLECTABLE: + result = GC_debug_malloc_uncollectable(lb, OPT_RA s, i); + break; +# ifdef ATOMIC_UNCOLLECTABLE + case AUNCOLLECTABLE: + result = GC_debug_malloc_atomic_uncollectable(lb, OPT_RA s, i); + break; +# endif + default: + GC_err_printf0("GC_debug_realloc: encountered bad kind\n"); + ABORT("bad kind"); + } + clobbered = GC_check_annotated_obj((oh *)base); + if (clobbered != 0) { + GC_err_printf0("GC_debug_realloc: found smashed location at "); + GC_print_smashed_obj(p, clobbered); + } + old_sz = ((oh *)base) -> oh_sz; + if (old_sz < copy_sz) copy_sz = old_sz; + if (result == 0) return(0); + BCOPY(p, result, copy_sz); + GC_debug_free(p); + return(result); +} + +/* Check all marked objects in the given block for validity */ +/*ARGSUSED*/ +void GC_check_heap_block(hbp, dummy) +register struct hblk *hbp; /* ptr to current heap block */ +word dummy; +{ + register struct hblkhdr * hhdr = HDR(hbp); + register word sz = hhdr -> hb_sz; + register int word_no; + register word *p, *plim; + + p = (word *)(hbp->hb_body); + word_no = HDR_WORDS; + if (sz > MAXOBJSZ) { + plim = p; + } else { + plim = (word *)((((word)hbp) + HBLKSIZE) - WORDS_TO_BYTES(sz)); + } + /* go through all words in block */ + while( p <= plim ) { + if( mark_bit_from_hdr(hhdr, word_no) + && GC_has_debug_info((ptr_t)p)) { + ptr_t clobbered = GC_check_annotated_obj((oh *)p); + + if (clobbered != 0) { + GC_err_printf0( + "GC_check_heap_block: found smashed location at "); + GC_print_smashed_obj((ptr_t)p, clobbered); + } + } + word_no += sz; + p += sz; + } +} + + +/* This assumes that all accessible objects are marked, and that */ +/* I hold the allocation lock. Normally called by collector. */ +void GC_check_heap_proc() +{ +# ifndef SMALL_CONFIG + if (sizeof(oh) & (2 * sizeof(word) - 1) != 0) { + ABORT("Alignment problem: object header has inappropriate size\n"); + } +# endif + GC_apply_to_all_blocks(GC_check_heap_block, (word)0); +} + +struct closure { + GC_finalization_proc cl_fn; + GC_PTR cl_data; +}; + +# ifdef __STDC__ + void * GC_make_closure(GC_finalization_proc fn, void * data) +# else + GC_PTR GC_make_closure(fn, data) + GC_finalization_proc fn; + GC_PTR data; +# endif +{ + struct closure * result = + (struct closure *) GC_malloc(sizeof (struct closure)); + + result -> cl_fn = fn; + result -> cl_data = data; + return((GC_PTR)result); +} + +# ifdef __STDC__ + void GC_debug_invoke_finalizer(void * obj, void * data) +# else + void GC_debug_invoke_finalizer(obj, data) + char * obj; + char * data; +# endif +{ + register struct closure * cl = (struct closure *) data; + + (*(cl -> cl_fn))((GC_PTR)((char *)obj + sizeof(oh)), cl -> cl_data); +} + + +# ifdef __STDC__ + void GC_debug_register_finalizer(GC_PTR obj, GC_finalization_proc fn, + GC_PTR cd, GC_finalization_proc *ofn, + GC_PTR *ocd) +# else + void GC_debug_register_finalizer(obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc *ofn; + GC_PTR *ocd; +# endif +{ + ptr_t base = GC_base(obj); + if (0 == base || (ptr_t)obj - base != sizeof(oh)) { + GC_err_printf1( + "GC_register_finalizer called with non-base-pointer 0x%lx\n", + obj); + } + GC_register_finalizer(base, GC_debug_invoke_finalizer, + GC_make_closure(fn,cd), ofn, ocd); +} + +# ifdef __STDC__ + void GC_debug_register_finalizer_no_order + (GC_PTR obj, GC_finalization_proc fn, + GC_PTR cd, GC_finalization_proc *ofn, + GC_PTR *ocd) +# else + void GC_debug_register_finalizer_no_order + (obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc *ofn; + GC_PTR *ocd; +# endif +{ + ptr_t base = GC_base(obj); + if (0 == base || (ptr_t)obj - base != sizeof(oh)) { + GC_err_printf1( + "GC_register_finalizer_no_order called with non-base-pointer 0x%lx\n", + obj); + } + GC_register_finalizer_no_order(base, GC_debug_invoke_finalizer, + GC_make_closure(fn,cd), ofn, ocd); + } + +# ifdef __STDC__ + void GC_debug_register_finalizer_ignore_self + (GC_PTR obj, GC_finalization_proc fn, + GC_PTR cd, GC_finalization_proc *ofn, + GC_PTR *ocd) +# else + void GC_debug_register_finalizer_ignore_self + (obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc *ofn; + GC_PTR *ocd; +# endif +{ + ptr_t base = GC_base(obj); + if (0 == base || (ptr_t)obj - base != sizeof(oh)) { + GC_err_printf1( + "GC_register_finalizer_ignore_self called with non-base-pointer 0x%lx\n", + obj); + } + GC_register_finalizer_ignore_self(base, GC_debug_invoke_finalizer, + GC_make_closure(fn,cd), ofn, ocd); +} diff --git a/support/gc/dyn_load.c b/support/gc/dyn_load.c new file mode 100644 index 00000000..d3df0a08 --- /dev/null +++ b/support/gc/dyn_load.c @@ -0,0 +1,799 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1997 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Original author: Bill Janssen + * Heavily modified by Hans Boehm and others + */ + +/* + * This is incredibly OS specific code for tracking down data sections in + * dynamic libraries. There appears to be no way of doing this quickly + * without groveling through undocumented data structures. We would argue + * that this is a bug in the design of the dlopen interface. THIS CODE + * MAY BREAK IN FUTURE OS RELEASES. If this matters to you, don't hesitate + * to let your vendor know ... + * + * None of this is safe with dlclose and incremental collection. + * But then not much of anything is safe in the presence of dlclose. + */ +#ifndef MACOS +# include +#endif +#include "gc_priv.h" + +/* BTL: avoid circular redefinition of dlopen if SOLARIS_THREADS defined */ +# if defined(SOLARIS_THREADS) && defined(dlopen) + /* To support threads in Solaris, gc.h interposes on dlopen by */ + /* defining "dlopen" to be "GC_dlopen", which is implemented below. */ + /* However, both GC_FirstDLOpenedLinkMap() and GC_dlopen() use the */ + /* real system dlopen() in their implementation. We first remove */ + /* gc.h's dlopen definition and restore it later, after GC_dlopen(). */ +# undef dlopen +# define GC_must_restore_redefined_dlopen +# else +# undef GC_must_restore_redefined_dlopen +# endif + +#if (defined(DYNAMIC_LOADING) || defined(MSWIN32)) && !defined(PCR) +#if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \ + !defined(MSWIN32) && !(defined(ALPHA) && defined(OSF1)) && \ + !defined(HP_PA) && !(defined(LINUX) && defined(__ELF__)) && \ + !defined(RS6000) && !defined(SCO_ELF) + --> We only know how to find data segments of dynamic libraries for the + --> above. Additional SVR4 variants might not be too + --> hard to add. +#endif + +#include +#ifdef SUNOS5DL +# include +# include +# include +#endif +#ifdef SUNOS4 +# include +# include +# include + /* struct link_map field overrides */ +# define l_next lm_next +# define l_addr lm_addr +# define l_name lm_name +#endif + + +#if defined(SUNOS5DL) && !defined(USE_PROC_FOR_LIBRARIES) + +#ifdef LINT + Elf32_Dyn _DYNAMIC; +#endif + +static struct link_map * +GC_FirstDLOpenedLinkMap() +{ + extern Elf32_Dyn _DYNAMIC; + Elf32_Dyn *dp; + struct r_debug *r; + static struct link_map * cachedResult = 0; + static Elf32_Dyn *dynStructureAddr = 0; + /* BTL: added to avoid Solaris 5.3 ld.so _DYNAMIC bug */ + +# ifdef SUNOS53_SHARED_LIB + /* BTL: Avoid the Solaris 5.3 bug that _DYNAMIC isn't being set */ + /* up properly in dynamically linked .so's. This means we have */ + /* to use its value in the set of original object files loaded */ + /* at program startup. */ + if( dynStructureAddr == 0 ) { + void* startupSyms = dlopen(0, RTLD_LAZY); + dynStructureAddr = (Elf32_Dyn*)dlsym(startupSyms, "_DYNAMIC"); + } +# else + dynStructureAddr = &_DYNAMIC; +# endif + + if( dynStructureAddr == 0) { + return(0); + } + if( cachedResult == 0 ) { + int tag; + for( dp = ((Elf32_Dyn *)(&_DYNAMIC)); (tag = dp->d_tag) != 0; dp++ ) { + if( tag == DT_DEBUG ) { + struct link_map *lm + = ((struct r_debug *)(dp->d_un.d_ptr))->r_map; + if( lm != 0 ) cachedResult = lm->l_next; /* might be NIL */ + break; + } + } + } + return cachedResult; +} + +#endif /* SUNOS5DL ... */ + +#if defined(SUNOS4) && !defined(USE_PROC_FOR_LIBRARIES) + +#ifdef LINT + struct link_dynamic _DYNAMIC; +#endif + +static struct link_map * +GC_FirstDLOpenedLinkMap() +{ + extern struct link_dynamic _DYNAMIC; + + if( &_DYNAMIC == 0) { + return(0); + } + return(_DYNAMIC.ld_un.ld_1->ld_loaded); +} + +/* Return the address of the ld.so allocated common symbol */ +/* with the least address, or 0 if none. */ +static ptr_t GC_first_common() +{ + ptr_t result = 0; + extern struct link_dynamic _DYNAMIC; + struct rtc_symb * curr_symbol; + + if( &_DYNAMIC == 0) { + return(0); + } + curr_symbol = _DYNAMIC.ldd -> ldd_cp; + for (; curr_symbol != 0; curr_symbol = curr_symbol -> rtc_next) { + if (result == 0 + || (ptr_t)(curr_symbol -> rtc_sp -> n_value) < result) { + result = (ptr_t)(curr_symbol -> rtc_sp -> n_value); + } + } + return(result); +} + +#endif /* SUNOS4 ... */ + +# if defined(SUNOS4) || defined(SUNOS5DL) +/* Add dynamic library data sections to the root set. */ +# if !defined(PCR) && !defined(SOLARIS_THREADS) && defined(THREADS) +# ifndef SRC_M3 + --> fix mutual exclusion with dlopen +# endif /* We assume M3 programs don't call dlopen for now */ +# endif + +# ifdef SOLARIS_THREADS + /* Redefine dlopen to guarantee mutual exclusion with */ + /* GC_register_dynamic_libraries. */ + /* assumes that dlopen doesn't need to call GC_malloc */ + /* and friends. */ +# include +# include + +void * GC_dlopen(const char *path, int mode) +{ + void * result; + +# ifndef USE_PROC_FOR_LIBRARIES + mutex_lock(&GC_allocate_ml); +# endif + result = dlopen(path, mode); +# ifndef USE_PROC_FOR_LIBRARIES + mutex_unlock(&GC_allocate_ml); +# endif + return(result); +} +# endif /* SOLARIS_THREADS */ + +/* BTL: added to fix circular dlopen definition if SOLARIS_THREADS defined */ +# if defined(GC_must_restore_redefined_dlopen) +# define dlopen GC_dlopen +# endif + +# ifndef USE_PROC_FOR_LIBRARIES +void GC_register_dynamic_libraries() +{ + struct link_map *lm = GC_FirstDLOpenedLinkMap(); + + + for (lm = GC_FirstDLOpenedLinkMap(); + lm != (struct link_map *) 0; lm = lm->l_next) + { +# ifdef SUNOS4 + struct exec *e; + + e = (struct exec *) lm->lm_addr; + GC_add_roots_inner( + ((char *) (N_DATOFF(*e) + lm->lm_addr)), + ((char *) (N_BSSADDR(*e) + e->a_bss + lm->lm_addr)), + TRUE); +# endif +# ifdef SUNOS5DL + Elf32_Ehdr * e; + Elf32_Phdr * p; + unsigned long offset; + char * start; + register int i; + + e = (Elf32_Ehdr *) lm->l_addr; + p = ((Elf32_Phdr *)(((char *)(e)) + e->e_phoff)); + offset = ((unsigned long)(lm->l_addr)); + for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) { + switch( p->p_type ) { + case PT_LOAD: + { + if( !(p->p_flags & PF_W) ) break; + start = ((char *)(p->p_vaddr)) + offset; + GC_add_roots_inner( + start, + start + p->p_memsz, + TRUE + ); + } + break; + default: + break; + } + } +# endif + } +# ifdef SUNOS4 + { + static ptr_t common_start = 0; + ptr_t common_end; + extern ptr_t GC_find_limit(); + + if (common_start == 0) common_start = GC_first_common(); + if (common_start != 0) { + common_end = GC_find_limit(common_start, TRUE); + GC_add_roots_inner((char *)common_start, (char *)common_end, TRUE); + } + } +# endif +} + +# endif /* !USE_PROC ... */ +# endif /* SUNOS */ + +#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) + +/* Dynamic loading code for Linux running ELF. Somewhat tested on + * Linux/x86, untested but hopefully should work on Linux/Alpha. + * This code was derived from the Solaris/ELF support. Thanks to + * whatever kind soul wrote that. - Patrick Bridges */ + +#include +#include + +/* Newer versions of Linux/Alpha and Linux/x86 define this macro. We + * define it for those older versions that don't. */ +# ifndef ElfW +# if !defined(ELF_CLASS) || ELF_CLASS == ELFCLASS32 +# define ElfW(type) Elf32_##type +# else +# define ElfW(type) Elf64_##type +# endif +# endif + +static struct link_map * +GC_FirstDLOpenedLinkMap() +{ +# ifdef __GNUC__ +# pragma weak _DYNAMIC +# endif + extern ElfW(Dyn) _DYNAMIC[]; + ElfW(Dyn) *dp; + struct r_debug *r; + static struct link_map *cachedResult = 0; + + if( _DYNAMIC == 0) { + return(0); + } + if( cachedResult == 0 ) { + int tag; + for( dp = _DYNAMIC; (tag = dp->d_tag) != 0; dp++ ) { + if( tag == DT_DEBUG ) { + struct link_map *lm + = ((struct r_debug *)(dp->d_un.d_ptr))->r_map; + if( lm != 0 ) cachedResult = lm->l_next; /* might be NIL */ + break; + } + } + } + return cachedResult; +} + + +void GC_register_dynamic_libraries() +{ + struct link_map *lm = GC_FirstDLOpenedLinkMap(); + + + for (lm = GC_FirstDLOpenedLinkMap(); + lm != (struct link_map *) 0; lm = lm->l_next) + { + ElfW(Ehdr) * e; + ElfW(Phdr) * p; + unsigned long offset; + char * start; + register int i; + + e = (ElfW(Ehdr) *) lm->l_addr; + p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff)); + offset = ((unsigned long)(lm->l_addr)); + for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) { + switch( p->p_type ) { + case PT_LOAD: + { + if( !(p->p_flags & PF_W) ) break; + start = ((char *)(p->p_vaddr)) + offset; + GC_add_roots_inner(start, start + p->p_memsz, TRUE); + } + break; + default: + break; + } + } + } +} + +#endif + +#if defined(IRIX5) || defined(USE_PROC_FOR_LIBRARIES) + +#include +#include +#include +#include +#include + +extern void * GC_roots_present(); + /* The type is a lie, since the real type doesn't make sense here, */ + /* and we only test for NULL. */ + +extern ptr_t GC_scratch_last_end_ptr; /* End of GC_scratch_alloc arena */ + +/* We use /proc to track down all parts of the address space that are */ +/* mapped by the process, and throw out regions we know we shouldn't */ +/* worry about. This may also work under other SVR4 variants. */ +void GC_register_dynamic_libraries() +{ + static int fd = -1; + char buf[30]; + static prmap_t * addr_map = 0; + static int current_sz = 0; /* Number of records currently in addr_map */ + static int needed_sz; /* Required size of addr_map */ + register int i; + register long flags; + register ptr_t start; + register ptr_t limit; + ptr_t heap_start = (ptr_t)HEAP_START; + ptr_t heap_end = heap_start; + +# ifdef SUNOS5DL +# define MA_PHYS 0 +# endif /* SUNOS5DL */ + + if (fd < 0) { + sprintf(buf, "/proc/%d", getpid()); + /* The above generates a lint complaint, since pid_t varies. */ + /* It's unclear how to improve this. */ + fd = open(buf, O_RDONLY); + if (fd < 0) { + ABORT("/proc open failed"); + } + } + if (ioctl(fd, PIOCNMAP, &needed_sz) < 0) { + GC_err_printf2("fd = %d, errno = %d\n", fd, errno); + ABORT("/proc PIOCNMAP ioctl failed"); + } + if (needed_sz >= current_sz) { + current_sz = needed_sz * 2 + 1; + /* Expansion, plus room for 0 record */ + addr_map = (prmap_t *)GC_scratch_alloc((word) + (current_sz * sizeof(prmap_t))); + } + if (ioctl(fd, PIOCMAP, addr_map) < 0) { + GC_err_printf4("fd = %d, errno = %d, needed_sz = %d, addr_map = 0x%X\n", + fd, errno, needed_sz, addr_map); + ABORT("/proc PIOCMAP ioctl failed"); + }; + if (GC_n_heap_sects > 0) { + heap_end = GC_heap_sects[GC_n_heap_sects-1].hs_start + + GC_heap_sects[GC_n_heap_sects-1].hs_bytes; + if (heap_end < GC_scratch_last_end_ptr) heap_end = GC_scratch_last_end_ptr; + } + for (i = 0; i < needed_sz; i++) { + flags = addr_map[i].pr_mflags; + if ((flags & (MA_BREAK | MA_STACK | MA_PHYS)) != 0) goto irrelevant; + if ((flags & (MA_READ | MA_WRITE)) != (MA_READ | MA_WRITE)) + goto irrelevant; + /* The latter test is empirically useless. Other than the */ + /* main data and stack segments, everything appears to be */ + /* mapped readable, writable, executable, and shared(!!). */ + /* This makes no sense to me. - HB */ + start = (ptr_t)(addr_map[i].pr_vaddr); + if (GC_roots_present(start)) goto irrelevant; + if (start < heap_end && start >= heap_start) + goto irrelevant; +# ifdef MMAP_STACKS + if (GC_is_thread_stack(start)) goto irrelevant; +# endif /* MMAP_STACKS */ + + limit = start + addr_map[i].pr_size; + if (addr_map[i].pr_off == 0 && strncmp(start, ELFMAG, 4) == 0) { + /* Discard text segments, i.e. 0-offset mappings against */ + /* executable files which appear to have ELF headers. */ + caddr_t arg; + int obj; +# define MAP_IRR_SZ 10 + static ptr_t map_irr[MAP_IRR_SZ]; + /* Known irrelevant map entries */ + static int n_irr = 0; + struct stat buf; + register int i; + + for (i = 0; i < n_irr; i++) { + if (map_irr[i] == start) goto irrelevant; + } + arg = (caddr_t)start; + obj = ioctl(fd, PIOCOPENM, &arg); + if (obj >= 0) { + fstat(obj, &buf); + close(obj); + if ((buf.st_mode & 0111) != 0) { + if (n_irr < MAP_IRR_SZ) { + map_irr[n_irr++] = start; + } + goto irrelevant; + } + } + } + GC_add_roots_inner(start, limit, TRUE); + irrelevant: ; + } + /* Dont keep cached descriptor, for now. Some kernels don't like us */ + /* to keep a /proc file descriptor around during kill -9. */ + if (close(fd) < 0) ABORT("Couldnt close /proc file"); + fd = -1; +} + +# endif /* USE_PROC || IRIX5 */ + +# ifdef MSWIN32 + +# define WIN32_LEAN_AND_MEAN +# define NOSERVICE +# include +# include + + /* We traverse the entire address space and register all segments */ + /* that could possibly have been written to. */ + DWORD GC_allocation_granularity; + + extern GC_bool GC_is_heap_base (ptr_t p); + +# ifdef WIN32_THREADS + extern void GC_get_next_stack(char *start, char **lo, char **hi); +# endif + + void GC_cond_add_roots(char *base, char * limit) + { + char dummy; + char * stack_top + = (char *) ((word)(&dummy) & ~(GC_allocation_granularity-1)); + if (base == limit) return; +# ifdef WIN32_THREADS + { + char * curr_base = base; + char * next_stack_lo; + char * next_stack_hi; + + for(;;) { + GC_get_next_stack(curr_base, &next_stack_lo, &next_stack_hi); + if (next_stack_lo >= limit) break; + GC_add_roots_inner(curr_base, next_stack_lo, TRUE); + curr_base = next_stack_hi; + } + if (curr_base < limit) GC_add_roots_inner(curr_base, limit, TRUE); + } +# else + if (limit > stack_top && base < GC_stackbottom) { + /* Part of the stack; ignore it. */ + return; + } + GC_add_roots_inner(base, limit, TRUE); +# endif + } + + extern GC_bool GC_win32s; + + void GC_register_dynamic_libraries() + { + MEMORY_BASIC_INFORMATION buf; + SYSTEM_INFO sysinfo; + DWORD result; + DWORD protect; + LPVOID p; + char * base; + char * limit, * new_limit; + + if (GC_win32s) return; + GetSystemInfo(&sysinfo); + base = limit = p = sysinfo.lpMinimumApplicationAddress; + GC_allocation_granularity = sysinfo.dwAllocationGranularity; + while (p < sysinfo.lpMaximumApplicationAddress) { + result = VirtualQuery(p, &buf, sizeof(buf)); + if (result != sizeof(buf)) { + ABORT("Weird VirtualQuery result"); + } + new_limit = (char *)p + buf.RegionSize; + protect = buf.Protect; + if (buf.State == MEM_COMMIT + && (protect == PAGE_EXECUTE_READWRITE + || protect == PAGE_READWRITE) + && !GC_is_heap_base(buf.AllocationBase)) { + if ((char *)p == limit) { + limit = new_limit; + } else { + GC_cond_add_roots(base, limit); + base = p; + limit = new_limit; + } + } + if (p > (LPVOID)new_limit /* overflow */) break; + p = (LPVOID)new_limit; + } + GC_cond_add_roots(base, limit); + } + +#endif /* MSWIN32 */ + +#if defined(ALPHA) && defined(OSF1) + +#include + +void GC_register_dynamic_libraries() +{ + int status; + ldr_process_t mypid; + + /* module */ + ldr_module_t moduleid = LDR_NULL_MODULE; + ldr_module_info_t moduleinfo; + size_t moduleinfosize = sizeof(moduleinfo); + size_t modulereturnsize; + + /* region */ + ldr_region_t region; + ldr_region_info_t regioninfo; + size_t regioninfosize = sizeof(regioninfo); + size_t regionreturnsize; + + /* Obtain id of this process */ + mypid = ldr_my_process(); + + /* For each module */ + while (TRUE) { + + /* Get the next (first) module */ + status = ldr_next_module(mypid, &moduleid); + + /* Any more modules? */ + if (moduleid == LDR_NULL_MODULE) + break; /* No more modules */ + + /* Check status AFTER checking moduleid because */ + /* of a bug in the non-shared ldr_next_module stub */ + if (status != 0 ) { + GC_printf1("dynamic_load: status = %ld\n", (long)status); + { + extern char *sys_errlist[]; + extern int sys_nerr; + extern int errno; + if (errno <= sys_nerr) { + GC_printf1("dynamic_load: %s\n", (long)sys_errlist[errno]); + } else { + GC_printf1("dynamic_load: %d\n", (long)errno); + } + } + ABORT("ldr_next_module failed"); + } + + /* Get the module information */ + status = ldr_inq_module(mypid, moduleid, &moduleinfo, + moduleinfosize, &modulereturnsize); + if (status != 0 ) + ABORT("ldr_inq_module failed"); + + /* is module for the main program (i.e. nonshared portion)? */ + if (moduleinfo.lmi_flags & LDR_MAIN) + continue; /* skip the main module */ + +# ifdef VERBOSE + GC_printf("---Module---\n"); + GC_printf("Module ID = %16ld\n", moduleinfo.lmi_modid); + GC_printf("Count of regions = %16d\n", moduleinfo.lmi_nregion); + GC_printf("flags for module = %16lx\n", moduleinfo.lmi_flags); + GC_printf("pathname of module = \"%s\"\n", moduleinfo.lmi_name); +# endif + + /* For each region in this module */ + for (region = 0; region < moduleinfo.lmi_nregion; region++) { + + /* Get the region information */ + status = ldr_inq_region(mypid, moduleid, region, ®ioninfo, + regioninfosize, ®ionreturnsize); + if (status != 0 ) + ABORT("ldr_inq_region failed"); + + /* only process writable (data) regions */ + if (! (regioninfo.lri_prot & LDR_W)) + continue; + +# ifdef VERBOSE + GC_printf("--- Region ---\n"); + GC_printf("Region number = %16ld\n", + regioninfo.lri_region_no); + GC_printf("Protection flags = %016x\n", regioninfo.lri_prot); + GC_printf("Virtual address = %16p\n", regioninfo.lri_vaddr); + GC_printf("Mapped address = %16p\n", regioninfo.lri_mapaddr); + GC_printf("Region size = %16ld\n", regioninfo.lri_size); + GC_printf("Region name = \"%s\"\n", regioninfo.lri_name); +# endif + + /* register region as a garbage collection root */ + GC_add_roots_inner ( + (char *)regioninfo.lri_mapaddr, + (char *)regioninfo.lri_mapaddr + regioninfo.lri_size, + TRUE); + + } + } +} +#endif + +#if defined(HP_PA) + +#include +#include + +extern int errno; +extern char *sys_errlist[]; +extern int sys_nerr; + +void GC_register_dynamic_libraries() +{ + int status; + int index = 1; /* Ordinal position in shared library search list */ + struct shl_descriptor *shl_desc; /* Shared library info, see dl.h */ + + /* For each dynamic library loaded */ + while (TRUE) { + + /* Get info about next shared library */ + status = shl_get(index, &shl_desc); + + /* Check if this is the end of the list or if some error occured */ + if (status != 0) { + if (errno == EINVAL) { + break; /* Moved past end of shared library list --> finished */ + } else { + if (errno <= sys_nerr) { + GC_printf1("dynamic_load: %s\n", (long) sys_errlist[errno]); + } else { + GC_printf1("dynamic_load: %d\n", (long) errno); + } + ABORT("shl_get failed"); + } + } + +# ifdef VERBOSE + GC_printf0("---Shared library---\n"); + GC_printf1("\tfilename = \"%s\"\n", shl_desc->filename); + GC_printf1("\tindex = %d\n", index); + GC_printf1("\thandle = %08x\n", + (unsigned long) shl_desc->handle); + GC_printf1("\ttext seg. start = %08x\n", shl_desc->tstart); + GC_printf1("\ttext seg. end = %08x\n", shl_desc->tend); + GC_printf1("\tdata seg. start = %08x\n", shl_desc->dstart); + GC_printf1("\tdata seg. end = %08x\n", shl_desc->dend); + GC_printf1("\tref. count = %lu\n", shl_desc->ref_count); +# endif + + /* register shared library's data segment as a garbage collection root */ + GC_add_roots_inner((char *) shl_desc->dstart, + (char *) shl_desc->dend, TRUE); + + index++; + } +} +#endif /* HP_PA */ + +#ifdef RS6000 +#pragma alloca +#include +#include +void GC_register_dynamic_libraries() +{ + int len; + char *ldibuf; + int ldibuflen; + struct ld_info *ldi; + + ldibuf = alloca(ldibuflen = 8192); + + while ( (len = loadquery(L_GETINFO,ldibuf,ldibuflen)) < 0) { + if (errno != ENOMEM) { + ABORT("loadquery failed"); + } + ldibuf = alloca(ldibuflen *= 2); + } + + ldi = (struct ld_info *)ldibuf; + while (ldi) { + len = ldi->ldinfo_next; + GC_add_roots_inner( + ldi->ldinfo_dataorg, + (unsigned long)ldi->ldinfo_dataorg + + ldi->ldinfo_datasize, + TRUE); + ldi = len ? (struct ld_info *)((char *)ldi + len) : 0; + } +} +#endif /* RS6000 */ + + + +#else /* !DYNAMIC_LOADING */ + +#ifdef PCR + +# include "il/PCR_IL.h" +# include "th/PCR_ThCtl.h" +# include "mm/PCR_MM.h" + +void GC_register_dynamic_libraries() +{ + /* Add new static data areas of dynamically loaded modules. */ + { + PCR_IL_LoadedFile * p = PCR_IL_GetLastLoadedFile(); + PCR_IL_LoadedSegment * q; + + /* Skip uncommited files */ + while (p != NIL && !(p -> lf_commitPoint)) { + /* The loading of this file has not yet been committed */ + /* Hence its description could be inconsistent. */ + /* Furthermore, it hasn't yet been run. Hence its data */ + /* segments can't possibly reference heap allocated */ + /* objects. */ + p = p -> lf_prev; + } + for (; p != NIL; p = p -> lf_prev) { + for (q = p -> lf_ls; q != NIL; q = q -> ls_next) { + if ((q -> ls_flags & PCR_IL_SegFlags_Traced_MASK) + == PCR_IL_SegFlags_Traced_on) { + GC_add_roots_inner + ((char *)(q -> ls_addr), + (char *)(q -> ls_addr) + q -> ls_bytes, + TRUE); + } + } + } + } +} + + +#else /* !PCR */ + +void GC_register_dynamic_libraries(){} + +int GC_no_dynamic_loading; + +#endif /* !PCR */ +#endif /* !DYNAMIC_LOADING */ diff --git a/support/gc/finalize.c b/support/gc/finalize.c new file mode 100644 index 00000000..2ee927fe --- /dev/null +++ b/support/gc/finalize.c @@ -0,0 +1,758 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, February 1, 1996 1:19 pm PST */ +# define I_HIDE_POINTERS +# include "gc_priv.h" +# include "gc_mark.h" + +# ifdef FINALIZE_ON_DEMAND + int GC_finalize_on_demand = 1; +# else + int GC_finalize_on_demand = 0; +# endif + +# ifdef JAVA_FINALIZATION + int GC_java_finalization = 1; +# else + int GC_java_finalization = 0; +# endif + +/* Type of mark procedure used for marking from finalizable object. */ +/* This procedure normally does not mark the object, only its */ +/* descendents. */ +typedef void finalization_mark_proc(/* ptr_t finalizable_obj_ptr */); + +# define HASH3(addr,size,log_size) \ + ((((word)(addr) >> 3) ^ ((word)(addr) >> (3+(log_size)))) \ + & ((size) - 1)) +#define HASH2(addr,log_size) HASH3(addr, 1 << log_size, log_size) + +struct hash_chain_entry { + word hidden_key; + struct hash_chain_entry * next; +}; + +unsigned GC_finalization_failures = 0; + /* Number of finalization requests that failed for lack of memory. */ + +static struct disappearing_link { + struct hash_chain_entry prolog; +# define dl_hidden_link prolog.hidden_key + /* Field to be cleared. */ +# define dl_next(x) (struct disappearing_link *)((x) -> prolog.next) +# define dl_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y) + + word dl_hidden_obj; /* Pointer to object base */ +} **dl_head = 0; + +static signed_word log_dl_table_size = -1; + /* Binary log of */ + /* current size of array pointed to by dl_head. */ + /* -1 ==> size is 0. */ + +word GC_dl_entries = 0; /* Number of entries currently in disappearing */ + /* link table. */ + +static struct finalizable_object { + struct hash_chain_entry prolog; +# define fo_hidden_base prolog.hidden_key + /* Pointer to object base. */ + /* No longer hidden once object */ + /* is on finalize_now queue. */ +# define fo_next(x) (struct finalizable_object *)((x) -> prolog.next) +# define fo_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y) + GC_finalization_proc fo_fn; /* Finalizer. */ + ptr_t fo_client_data; + word fo_object_size; /* In bytes. */ + finalization_mark_proc * fo_mark_proc; /* Mark-through procedure */ +} **fo_head = 0; + +struct finalizable_object * GC_finalize_now = 0; + /* LIst of objects that should be finalized now. */ + +static signed_word log_fo_table_size = -1; + +word GC_fo_entries = 0; + +# ifdef SRC_M3 +void GC_push_finalizer_structures() +{ + GC_push_all((ptr_t)(&dl_head), (ptr_t)(&dl_head) + sizeof(word)); + GC_push_all((ptr_t)(&fo_head), (ptr_t)(&fo_head) + sizeof(word)); +} +# endif + +/* Double the size of a hash table. *size_ptr is the log of its current */ +/* size. May be a noop. */ +/* *table is a pointer to an array of hash headers. If we succeed, we */ +/* update both *table and *log_size_ptr. */ +/* Lock is held. Signals are disabled. */ +void GC_grow_table(table, log_size_ptr) +struct hash_chain_entry ***table; +signed_word * log_size_ptr; +{ + register word i; + register struct hash_chain_entry *p; + int log_old_size = *log_size_ptr; + register int log_new_size = log_old_size + 1; + word old_size = ((log_old_size == -1)? 0: (1 << log_old_size)); + register word new_size = 1 << log_new_size; + struct hash_chain_entry **new_table = (struct hash_chain_entry **) + GC_generic_malloc_inner_ignore_off_page( + (size_t)new_size * sizeof(struct hash_chain_entry *), NORMAL); + + if (new_table == 0) { + if (table == 0) { + ABORT("Insufficient space for initial table allocation"); + } else { + return; + } + } + for (i = 0; i < old_size; i++) { + p = (*table)[i]; + while (p != 0) { + register ptr_t real_key = (ptr_t)REVEAL_POINTER(p -> hidden_key); + register struct hash_chain_entry *next = p -> next; + register int new_hash = HASH3(real_key, new_size, log_new_size); + + p -> next = new_table[new_hash]; + new_table[new_hash] = p; + p = next; + } + } + *log_size_ptr = log_new_size; + *table = new_table; +} + +# if defined(__STDC__) || defined(__cplusplus) + int GC_register_disappearing_link(GC_PTR * link) +# else + int GC_register_disappearing_link(link) + GC_PTR * link; +# endif +{ + ptr_t base; + + base = (ptr_t)GC_base((GC_PTR)link); + if (base == 0) + ABORT("Bad arg to GC_register_disappearing_link"); + return(GC_general_register_disappearing_link(link, base)); +} + +# if defined(__STDC__) || defined(__cplusplus) + int GC_general_register_disappearing_link(GC_PTR * link, + GC_PTR obj) +# else + int GC_general_register_disappearing_link(link, obj) + GC_PTR * link; + GC_PTR obj; +# endif + +{ + struct disappearing_link *curr_dl; + int index; + struct disappearing_link * new_dl; + DCL_LOCK_STATE; + + if ((word)link & (ALIGNMENT-1)) + ABORT("Bad arg to GC_general_register_disappearing_link"); +# ifdef THREADS + DISABLE_SIGNALS(); + LOCK(); +# endif + if (log_dl_table_size == -1 + || GC_dl_entries > ((word)1 << log_dl_table_size)) { +# ifndef THREADS + DISABLE_SIGNALS(); +# endif + GC_grow_table((struct hash_chain_entry ***)(&dl_head), + &log_dl_table_size); +# ifdef PRINTSTATS + GC_printf1("Grew dl table to %lu entries\n", + (unsigned long)(1 << log_dl_table_size)); +# endif +# ifndef THREADS + ENABLE_SIGNALS(); +# endif + } + index = HASH2(link, log_dl_table_size); + curr_dl = dl_head[index]; + for (curr_dl = dl_head[index]; curr_dl != 0; curr_dl = dl_next(curr_dl)) { + if (curr_dl -> dl_hidden_link == HIDE_POINTER(link)) { + curr_dl -> dl_hidden_obj = HIDE_POINTER(obj); +# ifdef THREADS + UNLOCK(); + ENABLE_SIGNALS(); +# endif + return(1); + } + } +# ifdef THREADS + new_dl = (struct disappearing_link *) + GC_generic_malloc_inner(sizeof(struct disappearing_link),NORMAL); +# else + new_dl = (struct disappearing_link *) + GC_malloc(sizeof(struct disappearing_link)); +# endif + if (new_dl != 0) { + new_dl -> dl_hidden_obj = HIDE_POINTER(obj); + new_dl -> dl_hidden_link = HIDE_POINTER(link); + dl_set_next(new_dl, dl_head[index]); + dl_head[index] = new_dl; + GC_dl_entries++; + } else { + GC_finalization_failures++; + } +# ifdef THREADS + UNLOCK(); + ENABLE_SIGNALS(); +# endif + return(0); +} + +# if defined(__STDC__) || defined(__cplusplus) + int GC_unregister_disappearing_link(GC_PTR * link) +# else + int GC_unregister_disappearing_link(link) + GC_PTR * link; +# endif +{ + struct disappearing_link *curr_dl, *prev_dl; + int index; + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + index = HASH2(link, log_dl_table_size); + if (((unsigned long)link & (ALIGNMENT-1))) goto out; + prev_dl = 0; curr_dl = dl_head[index]; + while (curr_dl != 0) { + if (curr_dl -> dl_hidden_link == HIDE_POINTER(link)) { + if (prev_dl == 0) { + dl_head[index] = dl_next(curr_dl); + } else { + dl_set_next(prev_dl, dl_next(curr_dl)); + } + GC_dl_entries--; + UNLOCK(); + ENABLE_SIGNALS(); + GC_free((GC_PTR)curr_dl); + return(1); + } + prev_dl = curr_dl; + curr_dl = dl_next(curr_dl); + } +out: + UNLOCK(); + ENABLE_SIGNALS(); + return(0); +} + +/* Possible finalization_marker procedures. Note that mark stack */ +/* overflow is handled by the caller, and is not a disaster. */ +GC_API void GC_normal_finalize_mark_proc(p) +ptr_t p; +{ + hdr * hhdr = HDR(p); + + PUSH_OBJ((word *)p, hhdr, GC_mark_stack_top, + &(GC_mark_stack[GC_mark_stack_size])); +} + +/* This only pays very partial attention to the mark descriptor. */ +/* It does the right thing for normal and atomic objects, and treats */ +/* most others as normal. */ +GC_API void GC_ignore_self_finalize_mark_proc(p) +ptr_t p; +{ + hdr * hhdr = HDR(p); + word descr = hhdr -> hb_descr; + ptr_t q, r; + ptr_t scan_limit; + ptr_t target_limit = p + WORDS_TO_BYTES(hhdr -> hb_sz) - 1; + + if ((descr & DS_TAGS) == DS_LENGTH) { + scan_limit = p + descr - sizeof(word); + } else { + scan_limit = target_limit + 1 - sizeof(word); + } + for (q = p; q <= scan_limit; q += ALIGNMENT) { + r = *(ptr_t *)q; + if (r < p || r > target_limit) { + GC_PUSH_ONE_HEAP((word)r, q); + } + } +} + +/*ARGSUSED*/ +GC_API void GC_null_finalize_mark_proc(p) +ptr_t p; +{ +} + + + +/* Register a finalization function. See gc.h for details. */ +/* in the nonthreads case, we try to avoid disabling signals, */ +/* since it can be expensive. Threads packages typically */ +/* make it cheaper. */ +/* The last parameter is a procedure that determines */ +/* marking for finalization ordering. Any objects marked */ +/* by that procedure will be guaranteed to not have been */ +/* finalized when this finalizer is invoked. */ +GC_API void GC_register_finalizer_inner(obj, fn, cd, ofn, ocd, mp) +GC_PTR obj; +GC_finalization_proc fn; +GC_PTR cd; +GC_finalization_proc * ofn; +GC_PTR * ocd; +finalization_mark_proc * mp; +{ + ptr_t base; + struct finalizable_object * curr_fo, * prev_fo; + int index; + struct finalizable_object *new_fo; + DCL_LOCK_STATE; + +# ifdef THREADS + DISABLE_SIGNALS(); + LOCK(); +# endif + if (log_fo_table_size == -1 + || GC_fo_entries > ((word)1 << log_fo_table_size)) { +# ifndef THREADS + DISABLE_SIGNALS(); +# endif + GC_grow_table((struct hash_chain_entry ***)(&fo_head), + &log_fo_table_size); +# ifdef PRINTSTATS + GC_printf1("Grew fo table to %lu entries\n", + (unsigned long)(1 << log_fo_table_size)); +# endif +# ifndef THREADS + ENABLE_SIGNALS(); +# endif + } + /* in the THREADS case signals are disabled and we hold allocation */ + /* lock; otherwise neither is true. Proceed carefully. */ + base = (ptr_t)obj; + index = HASH2(base, log_fo_table_size); + prev_fo = 0; curr_fo = fo_head[index]; + while (curr_fo != 0) { + if (curr_fo -> fo_hidden_base == HIDE_POINTER(base)) { + /* Interruption by a signal in the middle of this */ + /* should be safe. The client may see only *ocd */ + /* updated, but we'll declare that to be his */ + /* problem. */ + if (ocd) *ocd = (GC_PTR) curr_fo -> fo_client_data; + if (ofn) *ofn = curr_fo -> fo_fn; + /* Delete the structure for base. */ + if (prev_fo == 0) { + fo_head[index] = fo_next(curr_fo); + } else { + fo_set_next(prev_fo, fo_next(curr_fo)); + } + if (fn == 0) { + GC_fo_entries--; + /* May not happen if we get a signal. But a high */ + /* estimate will only make the table larger than */ + /* necessary. */ +# ifndef THREADS + GC_free((GC_PTR)curr_fo); +# endif + } else { + curr_fo -> fo_fn = fn; + curr_fo -> fo_client_data = (ptr_t)cd; + curr_fo -> fo_mark_proc = mp; + /* Reinsert it. We deleted it first to maintain */ + /* consistency in the event of a signal. */ + if (prev_fo == 0) { + fo_head[index] = curr_fo; + } else { + fo_set_next(prev_fo, curr_fo); + } + } +# ifdef THREADS + UNLOCK(); + ENABLE_SIGNALS(); +# endif + return; + } + prev_fo = curr_fo; + curr_fo = fo_next(curr_fo); + } + if (ofn) *ofn = 0; + if (ocd) *ocd = 0; + if (fn == 0) { +# ifdef THREADS + UNLOCK(); + ENABLE_SIGNALS(); +# endif + return; + } +# ifdef THREADS + new_fo = (struct finalizable_object *) + GC_generic_malloc_inner(sizeof(struct finalizable_object),NORMAL); +# else + new_fo = (struct finalizable_object *) + GC_malloc(sizeof(struct finalizable_object)); +# endif + if (new_fo != 0) { + new_fo -> fo_hidden_base = (word)HIDE_POINTER(base); + new_fo -> fo_fn = fn; + new_fo -> fo_client_data = (ptr_t)cd; + new_fo -> fo_object_size = GC_size(base); + new_fo -> fo_mark_proc = mp; + fo_set_next(new_fo, fo_head[index]); + GC_fo_entries++; + fo_head[index] = new_fo; + } else { + GC_finalization_failures++; + } +# ifdef THREADS + UNLOCK(); + ENABLE_SIGNALS(); +# endif +} + +# if defined(__STDC__) + void GC_register_finalizer(void * obj, + GC_finalization_proc fn, void * cd, + GC_finalization_proc *ofn, void ** ocd) +# else + void GC_register_finalizer(obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc * ofn; + GC_PTR * ocd; +# endif +{ + GC_register_finalizer_inner(obj, fn, cd, ofn, + ocd, GC_normal_finalize_mark_proc); +} + +# if defined(__STDC__) + void GC_register_finalizer_ignore_self(void * obj, + GC_finalization_proc fn, void * cd, + GC_finalization_proc *ofn, void ** ocd) +# else + void GC_register_finalizer_ignore_self(obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc * ofn; + GC_PTR * ocd; +# endif +{ + GC_register_finalizer_inner(obj, fn, cd, ofn, + ocd, GC_ignore_self_finalize_mark_proc); +} + +# if defined(__STDC__) + void GC_register_finalizer_no_order(void * obj, + GC_finalization_proc fn, void * cd, + GC_finalization_proc *ofn, void ** ocd) +# else + void GC_register_finalizer_no_order(obj, fn, cd, ofn, ocd) + GC_PTR obj; + GC_finalization_proc fn; + GC_PTR cd; + GC_finalization_proc * ofn; + GC_PTR * ocd; +# endif +{ + GC_register_finalizer_inner(obj, fn, cd, ofn, + ocd, GC_null_finalize_mark_proc); +} + +/* Called with world stopped. Cause disappearing links to disappear, */ +/* and invoke finalizers. */ +void GC_finalize() +{ + struct disappearing_link * curr_dl, * prev_dl, * next_dl; + struct finalizable_object * curr_fo, * prev_fo, * next_fo; + ptr_t real_ptr, real_link; + register int i; + int dl_size = (log_dl_table_size == -1 ) ? 0 : (1 << log_dl_table_size); + int fo_size = (log_fo_table_size == -1 ) ? 0 : (1 << log_fo_table_size); + + /* Make disappearing links disappear */ + for (i = 0; i < dl_size; i++) { + curr_dl = dl_head[i]; + prev_dl = 0; + while (curr_dl != 0) { + real_ptr = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_obj); + real_link = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_link); + if (!GC_is_marked(real_ptr)) { + *(word *)real_link = 0; + next_dl = dl_next(curr_dl); + if (prev_dl == 0) { + dl_head[i] = next_dl; + } else { + dl_set_next(prev_dl, next_dl); + } + GC_clear_mark_bit((ptr_t)curr_dl); + GC_dl_entries--; + curr_dl = next_dl; + } else { + prev_dl = curr_dl; + curr_dl = dl_next(curr_dl); + } + } + } + /* Mark all objects reachable via chains of 1 or more pointers */ + /* from finalizable objects. */ +# ifdef PRINTSTATS + if (GC_mark_state != MS_NONE) ABORT("Bad mark state"); +# endif + for (i = 0; i < fo_size; i++) { + for (curr_fo = fo_head[i]; curr_fo != 0; curr_fo = fo_next(curr_fo)) { + real_ptr = (ptr_t)REVEAL_POINTER(curr_fo -> fo_hidden_base); + if (!GC_is_marked(real_ptr)) { + GC_MARKED_FOR_FINALIZATION(real_ptr); + GC_MARK_FO(real_ptr, curr_fo -> fo_mark_proc); + if (GC_is_marked(real_ptr)) { + WARN("Finalization cycle involving %lx\n", real_ptr); + } + } + } + } + /* Enqueue for finalization all objects that are still */ + /* unreachable. */ + GC_words_finalized = 0; + for (i = 0; i < fo_size; i++) { + curr_fo = fo_head[i]; + prev_fo = 0; + while (curr_fo != 0) { + real_ptr = (ptr_t)REVEAL_POINTER(curr_fo -> fo_hidden_base); + if (!GC_is_marked(real_ptr)) { + if (!GC_java_finalization) { + GC_set_mark_bit(real_ptr); + } + /* Delete from hash table */ + next_fo = fo_next(curr_fo); + if (prev_fo == 0) { + fo_head[i] = next_fo; + } else { + fo_set_next(prev_fo, next_fo); + } + GC_fo_entries--; + /* Add to list of objects awaiting finalization. */ + fo_set_next(curr_fo, GC_finalize_now); + GC_finalize_now = curr_fo; + /* unhide object pointer so any future collections will */ + /* see it. */ + curr_fo -> fo_hidden_base = + (word) REVEAL_POINTER(curr_fo -> fo_hidden_base); + GC_words_finalized += + ALIGNED_WORDS(curr_fo -> fo_object_size) + + ALIGNED_WORDS(sizeof(struct finalizable_object)); +# ifdef PRINTSTATS + if (!GC_is_marked((ptr_t)curr_fo)) { + ABORT("GC_finalize: found accessible unmarked object\n"); + } +# endif + curr_fo = next_fo; + } else { + prev_fo = curr_fo; + curr_fo = fo_next(curr_fo); + } + } + } + + if (GC_java_finalization) { + /* make sure we mark everything reachable from objects finalized + using the no_order mark_proc */ + for (curr_fo = GC_finalize_now; + curr_fo != NULL; curr_fo = fo_next(curr_fo)) { + real_ptr = (ptr_t)curr_fo -> fo_hidden_base; + if (!GC_is_marked(real_ptr)) { + if (curr_fo -> fo_mark_proc == GC_null_finalize_mark_proc) { + GC_MARK_FO(real_ptr, GC_normal_finalize_mark_proc); + } + GC_set_mark_bit(real_ptr); + } + } + } + + /* Remove dangling disappearing links. */ + for (i = 0; i < dl_size; i++) { + curr_dl = dl_head[i]; + prev_dl = 0; + while (curr_dl != 0) { + real_link = GC_base((ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_link)); + if (real_link != 0 && !GC_is_marked(real_link)) { + next_dl = dl_next(curr_dl); + if (prev_dl == 0) { + dl_head[i] = next_dl; + } else { + dl_set_next(prev_dl, next_dl); + } + GC_clear_mark_bit((ptr_t)curr_dl); + GC_dl_entries--; + curr_dl = next_dl; + } else { + prev_dl = curr_dl; + curr_dl = dl_next(curr_dl); + } + } + } +} + +#ifndef JAVA_FINALIZATION_NOT_NEEDED + +/* Enqueue all remaining finalizers to be run - Assumes lock is + * held, and signals are disabled */ +void GC_enqueue_all_finalizers() +{ + struct finalizable_object * curr_fo, * prev_fo, * next_fo; + ptr_t real_ptr, real_link; + register int i; + int fo_size; + + fo_size = (log_fo_table_size == -1 ) ? 0 : (1 << log_fo_table_size); + GC_words_finalized = 0; + for (i = 0; i < fo_size; i++) { + curr_fo = fo_head[i]; + prev_fo = 0; + while (curr_fo != 0) { + real_ptr = (ptr_t)REVEAL_POINTER(curr_fo -> fo_hidden_base); + GC_MARK_FO(real_ptr, GC_normal_finalize_mark_proc); + GC_set_mark_bit(real_ptr); + + /* Delete from hash table */ + next_fo = fo_next(curr_fo); + if (prev_fo == 0) { + fo_head[i] = next_fo; + } else { + fo_set_next(prev_fo, next_fo); + } + GC_fo_entries--; + + /* Add to list of objects awaiting finalization. */ + fo_set_next(curr_fo, GC_finalize_now); + GC_finalize_now = curr_fo; + + /* unhide object pointer so any future collections will */ + /* see it. */ + curr_fo -> fo_hidden_base = + (word) REVEAL_POINTER(curr_fo -> fo_hidden_base); + + GC_words_finalized += + ALIGNED_WORDS(curr_fo -> fo_object_size) + + ALIGNED_WORDS(sizeof(struct finalizable_object)); + curr_fo = next_fo; + } + } + + return; +} + +/* Invoke all remaining finalizers that haven't yet been run. + * This is needed for strict compliance with the Java standard, + * which can make the runtime guarantee that all finalizers are run. + * Unfortunately, the Java standard implies we have to keep running + * finalizers until there are no more left, a potential infinite loop. + * YUCK. + * Note that this is even more dangerous than the usual Java + * finalizers, in that objects reachable from static variables + * may have been finalized when these finalizers are run. + * Finalizers run at this point must be prepared to deal with a + * mostly broken world. + * This routine is externally callable, so is called without + * the allocation lock. + */ +GC_API void GC_finalize_all() +{ + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + while (GC_fo_entries > 0) { + GC_enqueue_all_finalizers(); + UNLOCK(); + ENABLE_SIGNALS(); + GC_INVOKE_FINALIZERS(); + DISABLE_SIGNALS(); + LOCK(); + } + UNLOCK(); + ENABLE_SIGNALS(); +} +#endif + +/* Invoke finalizers for all objects that are ready to be finalized. */ +/* Should be called without allocation lock. */ +int GC_invoke_finalizers() +{ + register struct finalizable_object * curr_fo; + register int count = 0; + DCL_LOCK_STATE; + + while (GC_finalize_now != 0) { +# ifdef THREADS + DISABLE_SIGNALS(); + LOCK(); +# endif + curr_fo = GC_finalize_now; +# ifdef THREADS + if (curr_fo != 0) GC_finalize_now = fo_next(curr_fo); + UNLOCK(); + ENABLE_SIGNALS(); + if (curr_fo == 0) break; +# else + GC_finalize_now = fo_next(curr_fo); +# endif + fo_set_next(curr_fo, 0); + (*(curr_fo -> fo_fn))((ptr_t)(curr_fo -> fo_hidden_base), + curr_fo -> fo_client_data); + curr_fo -> fo_client_data = 0; + ++count; +# ifdef UNDEFINED + /* This is probably a bad idea. It throws off accounting if */ + /* nearly all objects are finalizable. O.w. it shouldn't */ + /* matter. */ + GC_free((GC_PTR)curr_fo); +# endif + } + return count; +} + +# ifdef __STDC__ + GC_PTR GC_call_with_alloc_lock(GC_fn_type fn, + GC_PTR client_data) +# else + GC_PTR GC_call_with_alloc_lock(fn, client_data) + GC_fn_type fn; + GC_PTR client_data; +# endif +{ + GC_PTR result; + DCL_LOCK_STATE; + +# ifdef THREADS + DISABLE_SIGNALS(); + LOCK(); + SET_LOCK_HOLDER(); +# endif + result = (*fn)(client_data); +# ifdef THREADS + UNSET_LOCK_HOLDER(); + UNLOCK(); + ENABLE_SIGNALS(); +# endif + return(result); +} diff --git a/support/gc/gc.h b/support/gc/gc.h new file mode 100644 index 00000000..30614095 --- /dev/null +++ b/support/gc/gc.h @@ -0,0 +1,754 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + * Copyright 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* + * Note that this defines a large number of tuning hooks, which can + * safely be ignored in nearly all cases. For normal use it suffices + * to call only GC_MALLOC and perhaps GC_REALLOC. + * For better performance, also look at GC_MALLOC_ATOMIC, and + * GC_enable_incremental. If you need an action to be performed + * immediately before an object is collected, look at GC_register_finalizer. + * If you are using Solaris threads, look at the end of this file. + * Everything else is best ignored unless you encounter performance + * problems. + */ + +#ifndef _GC_H + +# define _GC_H +# define __GC +# include + +#if defined(__CYGWIN32__) && defined(GC_USE_DLL) +#include "libgc_globals.h" +#endif + +#if defined(_MSC_VER) && defined(_DLL) +# ifdef GC_BUILD +# define GC_API __declspec(dllexport) +# else +# define GC_API __declspec(dllimport) +# endif +#endif + +#if defined(__WATCOMC__) && defined(GC_DLL) +# ifdef GC_BUILD +# define GC_API extern __declspec(dllexport) +# else +# define GC_API extern __declspec(dllimport) +# endif +#endif + +#ifndef GC_API +#define GC_API extern +#endif + +# if defined(__STDC__) || defined(__cplusplus) +# define GC_PROTO(args) args + typedef void * GC_PTR; +# else +# define GC_PROTO(args) () + typedef char * GC_PTR; +# endif + +# ifdef __cplusplus + extern "C" { +# endif + + +/* Define word and signed_word to be unsigned and signed types of the */ +/* size as char * or void *. There seems to be no way to do this */ +/* even semi-portably. The following is probably no better/worse */ +/* than almost anything else. */ +/* The ANSI standard suggests that size_t and ptr_diff_t might be */ +/* better choices. But those appear to have incorrect definitions */ +/* on may systems. Notably "typedef int size_t" seems to be both */ +/* frequent and WRONG. */ +typedef unsigned long GC_word; +typedef long GC_signed_word; + +/* Public read-only variables */ + +GC_API GC_word GC_gc_no;/* Counter incremented per collection. */ + /* Includes empty GCs at startup. */ + + +/* Public R/W variables */ + +GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested)); + /* When there is insufficient memory to satisfy */ + /* an allocation request, we return */ + /* (*GC_oom_fn)(). By default this just */ + /* returns 0. */ + /* If it returns, it must return 0 or a valid */ + /* pointer to a previously allocated heap */ + /* object. */ + +GC_API int GC_find_leak; + /* Do not actually garbage collect, but simply */ + /* report inaccessible memory that was not */ + /* deallocated with GC_free. Initial value */ + /* is determined by FIND_LEAK macro. */ + +GC_API int GC_quiet; /* Disable statistics output. Only matters if */ + /* collector has been compiled with statistics */ + /* enabled. This involves a performance cost, */ + /* and is thus not the default. */ + +GC_API int GC_finalize_on_demand; + /* If nonzero, finalizers will only be run in */ + /* response to an eplit GC_invoke_finalizers */ + /* call. The default is determined by whether */ + /* the FINALIZE_ON_DEMAND macro is defined */ + /* when the collector is built. */ + +GC_API int GC_java_finalization; + /* Mark objects reachable from finalizable */ + /* objects in a separate postpass. This makes */ + /* it a bit safer to use non-topologically- */ + /* ordered finalization. Default value is */ + /* determined by JAVA_FINALIZATION macro. */ + +GC_API int GC_dont_gc; /* Dont collect unless explicitly requested, e.g. */ + /* because it's not safe. */ + +GC_API int GC_dont_expand; + /* Dont expand heap unless explicitly requested */ + /* or forced to. */ + +GC_API int GC_full_freq; /* Number of partial collections between */ + /* full collections. Matters only if */ + /* GC_incremental is set. */ + +GC_API GC_word GC_non_gc_bytes; + /* Bytes not considered candidates for collection. */ + /* Used only to control scheduling of collections. */ + +GC_API GC_word GC_free_space_divisor; + /* We try to make sure that we allocate at */ + /* least N/GC_free_space_divisor bytes between */ + /* collections, where N is the heap size plus */ + /* a rough estimate of the root set size. */ + /* Initially, GC_free_space_divisor = 4. */ + /* Increasing its value will use less space */ + /* but more collection time. Decreasing it */ + /* will appreciably decrease collection time */ + /* at the expense of space. */ + /* GC_free_space_divisor = 1 will effectively */ + /* disable collections. */ + +GC_API GC_word GC_max_retries; + /* The maximum number of GCs attempted before */ + /* reporting out of memory after heap */ + /* expansion fails. Initially 0. */ + + +GC_API char *GC_stackbottom; /* Cool end of user stack. */ + /* May be set in the client prior to */ + /* calling any GC_ routines. This */ + /* avoids some overhead, and */ + /* potentially some signals that can */ + /* confuse debuggers. Otherwise the */ + /* collector attempts to set it */ + /* automatically. */ + /* For multithreaded code, this is the */ + /* cold end of the stack for the */ + /* primordial thread. */ + +/* Public procedures */ +/* + * general purpose allocation routines, with roughly malloc calling conv. + * The atomic versions promise that no relevant pointers are contained + * in the object. The nonatomic versions guarantee that the new object + * is cleared. GC_malloc_stubborn promises that no changes to the object + * will occur after GC_end_stubborn_change has been called on the + * result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object + * that is scanned for pointers to collectable objects, but is not itself + * collectable. GC_malloc_uncollectable and GC_free called on the resulting + * object implicitly update GC_non_gc_bytes appropriately. + */ +GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes)); + +/* The following is only defined if the library has been suitably */ +/* compiled: */ +GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes)); + +/* Explicitly deallocate an object. Dangerous if used incorrectly. */ +/* Requires a pointer to the base of an object. */ +/* If the argument is stubborn, it should not be changeable when freed. */ +/* An object should not be enable for finalization when it is */ +/* explicitly deallocated. */ +/* GC_free(0) is a no-op, as required by ANSI C for free. */ +GC_API void GC_free GC_PROTO((GC_PTR object_addr)); + +/* + * Stubborn objects may be changed only if the collector is explicitly informed. + * The collector is implicitly informed of coming change when such + * an object is first allocated. The following routines inform the + * collector that an object will no longer be changed, or that it will + * once again be changed. Only nonNIL pointer stores into the object + * are considered to be changes. The argument to GC_end_stubborn_change + * must be exacly the value returned by GC_malloc_stubborn or passed to + * GC_change_stubborn. (In the second case it may be an interior pointer + * within 512 bytes of the beginning of the objects.) + * There is a performance penalty for allowing more than + * one stubborn object to be changed at once, but it is acceptable to + * do so. The same applies to dropping stubborn objects that are still + * changeable. + */ +GC_API void GC_change_stubborn GC_PROTO((GC_PTR)); +GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR)); + +/* Return a pointer to the base (lowest address) of an object given */ +/* a pointer to a location within the object. */ +/* Return 0 if displaced_pointer doesn't point to within a valid */ +/* object. */ +GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer)); + +/* Given a pointer to the base of an object, return its size in bytes. */ +/* The returned size may be slightly larger than what was originally */ +/* requested. */ +GC_API size_t GC_size GC_PROTO((GC_PTR object_addr)); + +/* For compatibility with C library. This is occasionally faster than */ +/* a malloc followed by a bcopy. But if you rely on that, either here */ +/* or with the standard C library, your code is broken. In my */ +/* opinion, it shouldn't have been invented, but now we're stuck. -HB */ +/* The resulting object has the same kind as the original. */ +/* If the argument is stubborn, the result will have changes enabled. */ +/* It is an error to have changes enabled for the original object. */ +/* Follows ANSI comventions for NULL old_object. */ +GC_API GC_PTR GC_realloc + GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes)); + +/* Explicitly increase the heap size. */ +/* Returns 0 on failure, 1 on success. */ +GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes)); + +/* Limit the heap size to n bytes. Useful when you're debugging, */ +/* especially on systems that don't handle running out of memory well. */ +/* n == 0 ==> unbounded. This is the default. */ +GC_API void GC_set_max_heap_size GC_PROTO((GC_word n)); + +/* Inform the collector that a certain section of statically allocated */ +/* memory contains no pointers to garbage collected memory. Thus it */ +/* need not be scanned. This is sometimes important if the application */ +/* maps large read/write files into the address space, which could be */ +/* mistaken for dynamic library data segments on some systems. */ +GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish)); + +/* Clear the set of root segments. Wizards only. */ +GC_API void GC_clear_roots GC_PROTO((void)); + +/* Add a root segment. Wizards only. */ +GC_API void GC_add_roots GC_PROTO((char * low_address, + char * high_address_plus_1)); + +/* Add a displacement to the set of those considered valid by the */ +/* collector. GC_register_displacement(n) means that if p was returned */ +/* by GC_malloc, then (char *)p + n will be considered to be a valid */ +/* pointer to n. N must be small and less than the size of p. */ +/* (All pointers to the interior of objects from the stack are */ +/* considered valid in any case. This applies to heap objects and */ +/* static data.) */ +/* Preferably, this should be called before any other GC procedures. */ +/* Calling it later adds to the probability of excess memory */ +/* retention. */ +/* This is a no-op if the collector was compiled with recognition of */ +/* arbitrary interior pointers enabled, which is now the default. */ +GC_API void GC_register_displacement GC_PROTO((GC_word n)); + +/* The following version should be used if any debugging allocation is */ +/* being done. */ +GC_API void GC_debug_register_displacement GC_PROTO((GC_word n)); + +/* Explicitly trigger a full, world-stop collection. */ +GC_API void GC_gcollect GC_PROTO((void)); + +/* Trigger a full world-stopped collection. Abort the collection if */ +/* and when stop_func returns a nonzero value. Stop_func will be */ +/* called frequently, and should be reasonably fast. This works even */ +/* if virtual dirty bits, and hence incremental collection is not */ +/* available for this architecture. Collections can be aborted faster */ +/* than normal pause times for incremental collection. However, */ +/* aborted collections do no useful work; the next collection needs */ +/* to start from the beginning. */ +/* Return 0 if the collection was aborted, 1 if it succeeded. */ +typedef int (* GC_stop_func) GC_PROTO((void)); +GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func)); + +/* Return the number of bytes in the heap. Excludes collector private */ +/* data structures. Includes empty blocks and fragmentation loss. */ +/* Includes some pages that were allocated but never written. */ +GC_API size_t GC_get_heap_size GC_PROTO((void)); + +/* Return the number of bytes allocated since the last collection. */ +GC_API size_t GC_get_bytes_since_gc GC_PROTO((void)); + +/* Enable incremental/generational collection. */ +/* Not advisable unless dirty bits are */ +/* available or most heap objects are */ +/* pointerfree(atomic) or immutable. */ +/* Don't use in leak finding mode. */ +/* Ignored if GC_dont_gc is true. */ +GC_API void GC_enable_incremental GC_PROTO((void)); + +/* Perform some garbage collection work, if appropriate. */ +/* Return 0 if there is no more work to be done. */ +/* Typically performs an amount of work corresponding roughly */ +/* to marking from one page. May do more work if further */ +/* progress requires it, e.g. if incremental collection is */ +/* disabled. It is reasonable to call this in a wait loop */ +/* until it returns 0. */ +GC_API int GC_collect_a_little GC_PROTO((void)); + +/* Allocate an object of size lb bytes. The client guarantees that */ +/* as long as the object is live, it will be referenced by a pointer */ +/* that points to somewhere within the first 256 bytes of the object. */ +/* (This should normally be declared volatile to prevent the compiler */ +/* from invalidating this assertion.) This routine is only useful */ +/* if a large array is being allocated. It reduces the chance of */ +/* accidentally retaining such an array as a result of scanning an */ +/* integer that happens to be an address inside the array. (Actually, */ +/* it reduces the chance of the allocator not finding space for such */ +/* an array, since it will try hard to avoid introducing such a false */ +/* reference.) On a SunOS 4.X or MS Windows system this is recommended */ +/* for arrays likely to be larger than 100K or so. For other systems, */ +/* or if the collector is not configured to recognize all interior */ +/* pointers, the threshold is normally much higher. */ +GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb)); +GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb)); + +#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720 +# define GC_ADD_CALLER +# define GC_RETURN_ADDR (GC_word)__return_address +#endif + +#ifdef GC_ADD_CALLER +# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__ +# define GC_EXTRA_PARAMS GC_word ra, char * descr_string, int descr_int +#else +# define GC_EXTRAS __FILE__, __LINE__ +# define GC_EXTRA_PARAMS char * descr_string, int descr_int +#endif + +/* Debugging (annotated) allocation. GC_gcollect will check */ +/* objects allocated in this way for overwrites, etc. */ +GC_API GC_PTR GC_debug_malloc + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_atomic + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_uncollectable + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_stubborn + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr)); +GC_API GC_PTR GC_debug_realloc + GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes, + GC_EXTRA_PARAMS)); + +GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR)); +GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR)); +# ifdef GC_DEBUG +# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS) +# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS) +# define GC_MALLOC_UNCOLLECTABLE(sz) GC_debug_malloc_uncollectable(sz, \ + GC_EXTRAS) +# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS) +# define GC_FREE(p) GC_debug_free(p) +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_debug_register_finalizer(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \ + GC_debug_register_finalizer_ignore_self(p, f, d, of, od) +# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS); +# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p) +# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p) +# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \ + GC_general_register_disappearing_link(link, GC_base(obj)) +# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n) +# else +# define GC_MALLOC(sz) GC_malloc(sz) +# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz) +# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz) +# define GC_REALLOC(old, sz) GC_realloc(old, sz) +# define GC_FREE(p) GC_free(p) +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_register_finalizer(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \ + GC_register_finalizer_ignore_self(p, f, d, of, od) +# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz) +# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p) +# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p) +# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \ + GC_general_register_disappearing_link(link, obj) +# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n) +# endif +/* The following are included because they are often convenient, and */ +/* reduce the chance for a misspecifed size argument. But calls may */ +/* expand to something syntactically incorrect if t is a complicated */ +/* type expression. */ +# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t)) +# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t)) +# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t)) +# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t)) + +/* Finalization. Some of these primitives are grossly unsafe. */ +/* The idea is to make them both cheap, and sufficient to build */ +/* a safer layer, closer to PCedar finalization. */ +/* The interface represents my conclusions from a long discussion */ +/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */ +/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */ +/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */ +typedef void (*GC_finalization_proc) + GC_PROTO((GC_PTR obj, GC_PTR client_data)); + +GC_API void GC_register_finalizer + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); +GC_API void GC_debug_register_finalizer + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); + /* When obj is no longer accessible, invoke */ + /* (*fn)(obj, cd). If a and b are inaccessible, and */ + /* a points to b (after disappearing links have been */ + /* made to disappear), then only a will be */ + /* finalized. (If this does not create any new */ + /* pointers to b, then b will be finalized after the */ + /* next collection.) Any finalizable object that */ + /* is reachable from itself by following one or more */ + /* pointers will not be finalized (or collected). */ + /* Thus cycles involving finalizable objects should */ + /* be avoided, or broken by disappearing links. */ + /* All but the last finalizer registered for an object */ + /* is ignored. */ + /* Finalization may be removed by passing 0 as fn. */ + /* Finalizers are implicitly unregistered just before */ + /* they are invoked. */ + /* The old finalizer and client data are stored in */ + /* *ofn and *ocd. */ + /* Fn is never invoked on an accessible object, */ + /* provided hidden pointers are converted to real */ + /* pointers only if the allocation lock is held, and */ + /* such conversions are not performed by finalization */ + /* routines. */ + /* If GC_register_finalizer is aborted as a result of */ + /* a signal, the object may be left with no */ + /* finalization, even if neither the old nor new */ + /* finalizer were NULL. */ + /* Obj should be the nonNULL starting address of an */ + /* object allocated by GC_malloc or friends. */ + /* Note that any garbage collectable object referenced */ + /* by cd will be considered accessible until the */ + /* finalizer is invoked. */ + +/* Another versions of the above follow. It ignores */ +/* self-cycles, i.e. pointers from a finalizable object to */ +/* itself. There is a stylistic argument that this is wrong, */ +/* but it's unavoidable for C++, since the compiler may */ +/* silently introduce these. It's also benign in that specific */ +/* case. */ +GC_API void GC_register_finalizer_ignore_self + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); +GC_API void GC_debug_register_finalizer_ignore_self + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); + +/* The following routine may be used to break cycles between */ +/* finalizable objects, thus causing cyclic finalizable */ +/* objects to be finalized in the correct order. Standard */ +/* use involves calling GC_register_disappearing_link(&p), */ +/* where p is a pointer that is not followed by finalization */ +/* code, and should not be considered in determining */ +/* finalization order. */ +GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */)); + /* Link should point to a field of a heap allocated */ + /* object obj. *link will be cleared when obj is */ + /* found to be inaccessible. This happens BEFORE any */ + /* finalization code is invoked, and BEFORE any */ + /* decisions about finalization order are made. */ + /* This is useful in telling the finalizer that */ + /* some pointers are not essential for proper */ + /* finalization. This may avoid finalization cycles. */ + /* Note that obj may be resurrected by another */ + /* finalizer, and thus the clearing of *link may */ + /* be visible to non-finalization code. */ + /* There's an argument that an arbitrary action should */ + /* be allowed here, instead of just clearing a pointer. */ + /* But this causes problems if that action alters, or */ + /* examines connectivity. */ + /* Returns 1 if link was already registered, 0 */ + /* otherwise. */ + /* Only exists for backward compatibility. See below: */ + +GC_API int GC_general_register_disappearing_link + GC_PROTO((GC_PTR * /* link */, GC_PTR obj)); + /* A slight generalization of the above. *link is */ + /* cleared when obj first becomes inaccessible. This */ + /* can be used to implement weak pointers easily and */ + /* safely. Typically link will point to a location */ + /* holding a disguised pointer to obj. (A pointer */ + /* inside an "atomic" object is effectively */ + /* disguised.) In this way soft */ + /* pointers are broken before any object */ + /* reachable from them are finalized. Each link */ + /* May be registered only once, i.e. with one obj */ + /* value. This was added after a long email discussion */ + /* with John Ellis. */ + /* Obj must be a pointer to the first word of an object */ + /* we allocated. It is unsafe to explicitly deallocate */ + /* the object containing link. Explicitly deallocating */ + /* obj may or may not cause link to eventually be */ + /* cleared. */ +GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */)); + /* Returns 0 if link was not actually registered. */ + /* Undoes a registration by either of the above two */ + /* routines. */ + +/* Auxiliary fns to make finalization work correctly with displaced */ +/* pointers introduced by the debugging allocators. */ +GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data)); +GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data)); + +GC_API int GC_invoke_finalizers GC_PROTO((void)); + /* Run finalizers for all objects that are ready to */ + /* be finalized. Return the number of finalizers */ + /* that were run. Normally this is also called */ + /* implicitly during some allocations. If */ + /* GC-finalize_on_demand is nonzero, it must be called */ + /* explicitly. */ + +/* GC_set_warn_proc can be used to redirect or filter warning messages. */ +/* p may not be a NULL pointer. */ +typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg)); +GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p)); + /* Returns old warning procedure. */ + +/* The following is intended to be used by a higher level */ +/* (e.g. cedar-like) finalization facility. It is expected */ +/* that finalization code will arrange for hidden pointers to */ +/* disappear. Otherwise objects can be accessed after they */ +/* have been collected. */ +/* Note that putting pointers in atomic objects or in */ +/* nonpointer slots of "typed" objects is equivalent to */ +/* disguising them in this way, and may have other advantages. */ +# if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS) + typedef GC_word GC_hidden_pointer; +# define HIDE_POINTER(p) (~(GC_hidden_pointer)(p)) +# define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p))) + /* Converting a hidden pointer to a real pointer requires verifying */ + /* that the object still exists. This involves acquiring the */ + /* allocator lock to avoid a race with the collector. */ +# endif /* I_HIDE_POINTERS */ + +typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data)); +GC_API GC_PTR GC_call_with_alloc_lock + GC_PROTO((GC_fn_type fn, GC_PTR client_data)); + +/* Check that p and q point to the same object. */ +/* Fail conspicuously if they don't. */ +/* Returns the first argument. */ +/* Succeeds if neither p nor q points to the heap. */ +/* May succeed if both p and q point to between heap objects. */ +GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q)); + +/* Checked pointer pre- and post- increment operations. Note that */ +/* the second argument is in units of bytes, not multiples of the */ +/* object size. This should either be invoked from a macro, or the */ +/* call should be automatically generated. */ +GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much)); +GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much)); + +/* Check that p is visible */ +/* to the collector as a possibly pointer containing location. */ +/* If it isn't fail conspicuously. */ +/* Returns the argument in all cases. May erroneously succeed */ +/* in hard cases. (This is intended for debugging use with */ +/* untyped allocations. The idea is that it should be possible, though */ +/* slow, to add such a call to all indirect pointer stores.) */ +/* Currently useless for multithreaded worlds. */ +GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p)); + +/* Check that if p is a pointer to a heap page, then it points to */ +/* a valid displacement within a heap object. */ +/* Fail conspicuously if this property does not hold. */ +/* Uninteresting with ALL_INTERIOR_POINTERS. */ +/* Always returns its argument. */ +GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p)); + +/* Safer, but slow, pointer addition. Probably useful mainly with */ +/* a preprocessor. Useful only for heap pointers. */ +#ifdef GC_DEBUG +# define GC_PTR_ADD3(x, n, type_of_result) \ + ((type_of_result)GC_same_obj((x)+(n), (x))) +# define GC_PRE_INCR3(x, n, type_of_result) \ + ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x)) +# define GC_POST_INCR2(x, type_of_result) \ + ((type_of_result)GC_post_incr(&(x), sizeof(*x)) +# ifdef __GNUC__ +# define GC_PTR_ADD(x, n) \ + GC_PTR_ADD3(x, n, typeof(x)) +# define GC_PRE_INCR(x, n) \ + GC_PRE_INCR3(x, n, typeof(x)) +# define GC_POST_INCR(x, n) \ + GC_POST_INCR3(x, typeof(x)) +# else + /* We can't do this right without typeof, which ANSI */ + /* decided was not sufficiently useful. Repeatedly */ + /* mentioning the arguments seems too dangerous to be */ + /* useful. So does not casting the result. */ +# define GC_PTR_ADD(x, n) ((x)+(n)) +# endif +#else /* !GC_DEBUG */ +# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n)) +# define GC_PTR_ADD(x, n) ((x)+(n)) +# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n)) +# define GC_PRE_INCR(x, n) ((x) += (n)) +# define GC_POST_INCR2(x, n, type_of_result) ((x)++) +# define GC_POST_INCR(x, n) ((x)++) +#endif + +/* Safer assignment of a pointer to a nonstack location. */ +#ifdef GC_DEBUG +# ifdef __STDC__ +# define GC_PTR_STORE(p, q) \ + (*(void **)GC_is_visible(p) = GC_is_valid_displacement(q)) +# else +# define GC_PTR_STORE(p, q) \ + (*(char **)GC_is_visible(p) = GC_is_valid_displacement(q)) +# endif +#else /* !GC_DEBUG */ +# define GC_PTR_STORE(p, q) *((p) = (q)) +#endif + +/* Fynctions called to report pointer checking errors */ +GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q)); + +GC_API void (*GC_is_valid_displacement_print_proc) + GC_PROTO((GC_PTR p)); + +GC_API void (*GC_is_visible_print_proc) + GC_PROTO((GC_PTR p)); + +#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) +# define SOLARIS_THREADS +#endif + +#ifdef SOLARIS_THREADS +/* We need to intercept calls to many of the threads primitives, so */ +/* that we can locate thread stacks and stop the world. */ +/* Note also that the collector cannot see thread specific data. */ +/* Thread specific data should generally consist of pointers to */ +/* uncollectable objects, which are deallocated using the destructor */ +/* facility in thr_keycreate. */ +# include +# include + int GC_thr_create(void *stack_base, size_t stack_size, + void *(*start_routine)(void *), void *arg, long flags, + thread_t *new_thread); + int GC_thr_join(thread_t wait_for, thread_t *departed, void **status); + int GC_thr_suspend(thread_t target_thread); + int GC_thr_continue(thread_t target_thread); + void * GC_dlopen(const char *path, int mode); + +# ifdef _SOLARIS_PTHREADS +# include + extern int GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void * (*thread_execp)(void *), void *arg); + extern int GC_pthread_join(pthread_t wait_for, void **status); + +# undef thread_t + +# define pthread_join GC_pthread_join +# define pthread_create GC_pthread_create +#endif + +# define thr_create GC_thr_create +# define thr_join GC_thr_join +# define thr_suspend GC_thr_suspend +# define thr_continue GC_thr_continue +# define dlopen GC_dlopen + +# endif /* SOLARIS_THREADS */ + + +#if defined(IRIX_THREADS) || defined(LINUX_THREADS) +/* We treat these similarly. */ +# include +# include + + int GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void *(*start_routine)(void *), void *arg); + int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset); + int GC_pthread_join(pthread_t thread, void **retval); + +# define pthread_create GC_pthread_create +# define pthread_sigmask GC_pthread_sigmask +# define pthread_join GC_pthread_join + +#endif /* IRIX_THREADS || LINUX_THREADS */ + +# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ + defined(IRIX_THREADS) || defined(LINUX_THREADS) || \ + defined(IRIX_JDK_THREADS) + /* Any flavor of threads except SRC_M3. */ +/* This returns a list of objects, linked through their first */ +/* word. Its use can greatly reduce lock contention problems, since */ +/* the allocation lock can be acquired and released many fewer times. */ +/* lb must be large enough to hold the pointer field. */ +GC_PTR GC_malloc_many(size_t lb); +#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */ + /* in returned list. */ +extern void GC_thr_init(); /* Needed for Solaris/X86 */ + +#endif /* THREADS && !SRC_M3 */ + +/* + * If you are planning on putting + * the collector in a SunOS 5 dynamic library, you need to call GC_INIT() + * from the statically loaded program section. + * This circumvents a Solaris 2.X (X<=4) linker bug. + */ +#if defined(sparc) || defined(__sparc) +# define GC_INIT() { extern end, etext; \ + GC_noop(&end, &etext); } +#else +# if defined(__CYGWIN32__) && defined(GC_USE_DLL) + /* + * Similarly gnu-win32 DLLs need explicit initialization + */ +# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); } +# else +# define GC_INIT() +# endif +#endif + +#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \ + || defined(_WIN32) + /* win32S may not free all resources on process exit. */ + /* This explicitly deallocates the heap. */ + GC_API void GC_win32_free_heap (); +#endif + +#ifdef __cplusplus + } /* end of extern "C" */ +#endif + +#endif /* _GC_H */ diff --git a/support/gc/gc.mak b/support/gc/gc.mak new file mode 100644 index 00000000..0fd22b70 --- /dev/null +++ b/support/gc/gc.mak @@ -0,0 +1,2087 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.10 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +!IF "$(CFG)" == "" +CFG=gctest - Win32 Release +!MESSAGE No configuration specified. Defaulting to cord - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "gc - Win32 Release" && "$(CFG)" != "gc - Win32 Debug" &&\ + "$(CFG)" != "gctest - Win32 Release" && "$(CFG)" != "gctest - Win32 Debug" &&\ + "$(CFG)" != "cord - Win32 Release" && "$(CFG)" != "cord - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "gc.mak" CFG="cord - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "gc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "gc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "gctest - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "gctest - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "cord - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "cord - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "gctest - Win32 Debug" + +!IF "$(CFG)" == "gc - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : ".\Release\gc.dll" ".\Release\gc.bsc" + +CLEAN : + -@erase ".\Release\allchblk.obj" + -@erase ".\Release\allchblk.sbr" + -@erase ".\Release\alloc.obj" + -@erase ".\Release\alloc.sbr" + -@erase ".\Release\blacklst.obj" + -@erase ".\Release\blacklst.sbr" + -@erase ".\Release\checksums.obj" + -@erase ".\Release\checksums.sbr" + -@erase ".\Release\dbg_mlc.obj" + -@erase ".\Release\dbg_mlc.sbr" + -@erase ".\Release\dyn_load.obj" + -@erase ".\Release\dyn_load.sbr" + -@erase ".\Release\finalize.obj" + -@erase ".\Release\finalize.sbr" + -@erase ".\Release\gc.bsc" + -@erase ".\Release\gc.dll" + -@erase ".\Release\gc.exp" + -@erase ".\Release\gc.lib" + -@erase ".\Release\headers.obj" + -@erase ".\Release\headers.sbr" + -@erase ".\Release\mach_dep.obj" + -@erase ".\Release\mach_dep.sbr" + -@erase ".\Release\malloc.obj" + -@erase ".\Release\malloc.sbr" + -@erase ".\Release\mallocx.obj" + -@erase ".\Release\mallocx.sbr" + -@erase ".\Release\mark.obj" + -@erase ".\Release\mark.sbr" + -@erase ".\Release\mark_rts.obj" + -@erase ".\Release\mark_rts.sbr" + -@erase ".\Release\misc.obj" + -@erase ".\Release\misc.sbr" + -@erase ".\Release\new_hblk.obj" + -@erase ".\Release\new_hblk.sbr" + -@erase ".\Release\obj_map.obj" + -@erase ".\Release\obj_map.sbr" + -@erase ".\Release\os_dep.obj" + -@erase ".\Release\os_dep.sbr" + -@erase ".\Release\ptr_chck.obj" + -@erase ".\Release\ptr_chck.sbr" + -@erase ".\Release\reclaim.obj" + -@erase ".\Release\reclaim.sbr" + -@erase ".\Release\stubborn.obj" + -@erase ".\Release\stubborn.sbr" + -@erase ".\Release\typd_mlc.obj" + -@erase ".\Release\typd_mlc.sbr" + -@erase ".\Release\win32_threads.obj" + -@erase ".\Release\win32_threads.sbr" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\ + "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ + "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS=.\Release/ + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gc.bsc" +BSC32_SBRS= \ + ".\Release\allchblk.sbr" \ + ".\Release\alloc.sbr" \ + ".\Release\blacklst.sbr" \ + ".\Release\checksums.sbr" \ + ".\Release\dbg_mlc.sbr" \ + ".\Release\dyn_load.sbr" \ + ".\Release\finalize.sbr" \ + ".\Release\headers.sbr" \ + ".\Release\mach_dep.sbr" \ + ".\Release\malloc.sbr" \ + ".\Release\mallocx.sbr" \ + ".\Release\mark.sbr" \ + ".\Release\mark_rts.sbr" \ + ".\Release\misc.sbr" \ + ".\Release\new_hblk.sbr" \ + ".\Release\obj_map.sbr" \ + ".\Release\os_dep.sbr" \ + ".\Release\ptr_chck.sbr" \ + ".\Release\reclaim.sbr" \ + ".\Release\stubborn.sbr" \ + ".\Release\typd_mlc.sbr" \ + ".\Release\win32_threads.sbr" + +".\Release\gc.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /dll /incremental:no\ + /pdb:"$(OUTDIR)/gc.pdb" /machine:I386 /out:"$(OUTDIR)/gc.dll"\ + /implib:"$(OUTDIR)/gc.lib" +LINK32_OBJS= \ + ".\Release\allchblk.obj" \ + ".\Release\alloc.obj" \ + ".\Release\blacklst.obj" \ + ".\Release\checksums.obj" \ + ".\Release\dbg_mlc.obj" \ + ".\Release\dyn_load.obj" \ + ".\Release\finalize.obj" \ + ".\Release\headers.obj" \ + ".\Release\mach_dep.obj" \ + ".\Release\malloc.obj" \ + ".\Release\mallocx.obj" \ + ".\Release\mark.obj" \ + ".\Release\mark_rts.obj" \ + ".\Release\misc.obj" \ + ".\Release\new_hblk.obj" \ + ".\Release\obj_map.obj" \ + ".\Release\os_dep.obj" \ + ".\Release\ptr_chck.obj" \ + ".\Release\reclaim.obj" \ + ".\Release\stubborn.obj" \ + ".\Release\typd_mlc.obj" \ + ".\Release\win32_threads.obj" + +".\Release\gc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +OUTDIR=.\Debug +INTDIR=.\Debug + +ALL : ".\Debug\gc.dll" ".\Debug\gc.bsc" + +CLEAN : + -@erase ".\Debug\allchblk.obj" + -@erase ".\Debug\allchblk.sbr" + -@erase ".\Debug\alloc.obj" + -@erase ".\Debug\alloc.sbr" + -@erase ".\Debug\blacklst.obj" + -@erase ".\Debug\blacklst.sbr" + -@erase ".\Debug\checksums.obj" + -@erase ".\Debug\checksums.sbr" + -@erase ".\Debug\dbg_mlc.obj" + -@erase ".\Debug\dbg_mlc.sbr" + -@erase ".\Debug\dyn_load.obj" + -@erase ".\Debug\dyn_load.sbr" + -@erase ".\Debug\finalize.obj" + -@erase ".\Debug\finalize.sbr" + -@erase ".\Debug\gc.bsc" + -@erase ".\Debug\gc.dll" + -@erase ".\Debug\gc.exp" + -@erase ".\Debug\gc.lib" + -@erase ".\Debug\gc.map" + -@erase ".\Debug\gc.pdb" + -@erase ".\Debug\headers.obj" + -@erase ".\Debug\headers.sbr" + -@erase ".\Debug\mach_dep.obj" + -@erase ".\Debug\mach_dep.sbr" + -@erase ".\Debug\malloc.obj" + -@erase ".\Debug\malloc.sbr" + -@erase ".\Debug\mallocx.obj" + -@erase ".\Debug\mallocx.sbr" + -@erase ".\Debug\mark.obj" + -@erase ".\Debug\mark.sbr" + -@erase ".\Debug\mark_rts.obj" + -@erase ".\Debug\mark_rts.sbr" + -@erase ".\Debug\misc.obj" + -@erase ".\Debug\misc.sbr" + -@erase ".\Debug\new_hblk.obj" + -@erase ".\Debug\new_hblk.sbr" + -@erase ".\Debug\obj_map.obj" + -@erase ".\Debug\obj_map.sbr" + -@erase ".\Debug\os_dep.obj" + -@erase ".\Debug\os_dep.sbr" + -@erase ".\Debug\ptr_chck.obj" + -@erase ".\Debug\ptr_chck.sbr" + -@erase ".\Debug\reclaim.obj" + -@erase ".\Debug\reclaim.sbr" + -@erase ".\Debug\stubborn.obj" + -@erase ".\Debug\stubborn.sbr" + -@erase ".\Debug\typd_mlc.obj" + -@erase ".\Debug\typd_mlc.sbr" + -@erase ".\Debug\vc40.idb" + -@erase ".\Debug\vc40.pdb" + -@erase ".\Debug\win32_threads.obj" + -@erase ".\Debug\win32_threads.sbr" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\ + /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ + "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\ + /Fd"$(INTDIR)/" /c +CPP_OBJS=.\Debug/ +CPP_SBRS=.\Debug/ + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gc.bsc" +BSC32_SBRS= \ + ".\Debug\allchblk.sbr" \ + ".\Debug\alloc.sbr" \ + ".\Debug\blacklst.sbr" \ + ".\Debug\checksums.sbr" \ + ".\Debug\dbg_mlc.sbr" \ + ".\Debug\dyn_load.sbr" \ + ".\Debug\finalize.sbr" \ + ".\Debug\headers.sbr" \ + ".\Debug\mach_dep.sbr" \ + ".\Debug\malloc.sbr" \ + ".\Debug\mallocx.sbr" \ + ".\Debug\mark.sbr" \ + ".\Debug\mark_rts.sbr" \ + ".\Debug\misc.sbr" \ + ".\Debug\new_hblk.sbr" \ + ".\Debug\obj_map.sbr" \ + ".\Debug\os_dep.sbr" \ + ".\Debug\ptr_chck.sbr" \ + ".\Debug\reclaim.sbr" \ + ".\Debug\stubborn.sbr" \ + ".\Debug\typd_mlc.sbr" \ + ".\Debug\win32_threads.sbr" + +".\Debug\gc.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /machine:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /dll /incremental:no\ + /pdb:"$(OUTDIR)/gc.pdb" /map:"$(INTDIR)/gc.map" /debug /machine:I386\ + /out:"$(OUTDIR)/gc.dll" /implib:"$(OUTDIR)/gc.lib" +LINK32_OBJS= \ + ".\Debug\allchblk.obj" \ + ".\Debug\alloc.obj" \ + ".\Debug\blacklst.obj" \ + ".\Debug\checksums.obj" \ + ".\Debug\dbg_mlc.obj" \ + ".\Debug\dyn_load.obj" \ + ".\Debug\finalize.obj" \ + ".\Debug\headers.obj" \ + ".\Debug\mach_dep.obj" \ + ".\Debug\malloc.obj" \ + ".\Debug\mallocx.obj" \ + ".\Debug\mark.obj" \ + ".\Debug\mark_rts.obj" \ + ".\Debug\misc.obj" \ + ".\Debug\new_hblk.obj" \ + ".\Debug\obj_map.obj" \ + ".\Debug\os_dep.obj" \ + ".\Debug\ptr_chck.obj" \ + ".\Debug\reclaim.obj" \ + ".\Debug\stubborn.obj" \ + ".\Debug\typd_mlc.obj" \ + ".\Debug\win32_threads.obj" + +".\Debug\gc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "gctest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "gctest\Release" +# PROP BASE Intermediate_Dir "gctest\Release" +# PROP BASE Target_Dir "gctest" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "gctest\Release" +# PROP Intermediate_Dir "gctest\Release" +# PROP Target_Dir "gctest" +OUTDIR=.\gctest\Release +INTDIR=.\gctest\Release + +ALL : "gc - Win32 Release" ".\Release\gctest.exe" + +CLEAN : + -@erase ".\gctest\Release\test.obj" + -@erase ".\Release\gctest.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c +CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\ + "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS"\ + /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\gctest\Release/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gctest.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"Release/gctest.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:no\ + /pdb:"$(OUTDIR)/gctest.pdb" /machine:I386 /out:"Release/gctest.exe" +LINK32_OBJS= \ + ".\gctest\Release\test.obj" \ + ".\Release\gc.lib" + +".\Release\gctest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "gctest\Debug" +# PROP BASE Intermediate_Dir "gctest\Debug" +# PROP BASE Target_Dir "gctest" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "gctest\Debug" +# PROP Intermediate_Dir "gctest\Debug" +# PROP Target_Dir "gctest" +OUTDIR=.\gctest\Debug +INTDIR=.\gctest\Debug + +ALL : "gc - Win32 Debug" ".\Debug\gctest.exe" ".\gctest\Debug\gctest.bsc" + +CLEAN : + -@erase ".\Debug\gctest.exe" + -@erase ".\gctest\Debug\gctest.bsc" + -@erase ".\gctest\Debug\gctest.map" + -@erase ".\gctest\Debug\gctest.pdb" + -@erase ".\gctest\Debug\test.obj" + -@erase ".\gctest\Debug\test.sbr" + -@erase ".\gctest\Debug\vc40.idb" + -@erase ".\gctest\Debug\vc40.pdb" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\ + /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR"$(INTDIR)/"\ + /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c +CPP_OBJS=.\gctest\Debug/ +CPP_SBRS=.\gctest\Debug/ + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/gctest.bsc" +BSC32_SBRS= \ + ".\gctest\Debug\test.sbr" + +".\gctest\Debug\gctest.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /map /debug /machine:I386 /out:"Debug/gctest.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:no\ + /pdb:"$(OUTDIR)/gctest.pdb" /map:"$(INTDIR)/gctest.map" /debug /machine:I386\ + /out:"Debug/gctest.exe" +LINK32_OBJS= \ + ".\Debug\gc.lib" \ + ".\gctest\Debug\test.obj" + +".\Debug\gctest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "cord - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "cord\Release" +# PROP BASE Intermediate_Dir "cord\Release" +# PROP BASE Target_Dir "cord" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "cord\Release" +# PROP Intermediate_Dir "cord\Release" +# PROP Target_Dir "cord" +OUTDIR=.\cord\Release +INTDIR=.\cord\Release + +ALL : "gc - Win32 Release" ".\Release\de.exe" + +CLEAN : + -@erase ".\cord\Release\cordbscs.obj" + -@erase ".\cord\Release\cordxtra.obj" + -@erase ".\cord\Release\de.obj" + -@erase ".\cord\Release\de_win.obj" + -@erase ".\cord\Release\de_win.res" + -@erase ".\Release\de.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c +CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\ + "ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\cord\Release/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +RSC_PROJ=/l 0x809 /fo"$(INTDIR)/de_win.res" /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/cord.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"Release/de.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)/de.pdb"\ + /machine:I386 /out:"Release/de.exe" +LINK32_OBJS= \ + ".\cord\Release\cordbscs.obj" \ + ".\cord\Release\cordxtra.obj" \ + ".\cord\Release\de.obj" \ + ".\cord\Release\de_win.obj" \ + ".\cord\Release\de_win.res" \ + ".\Release\gc.lib" + +".\Release\de.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "cord\Debug" +# PROP BASE Intermediate_Dir "cord\Debug" +# PROP BASE Target_Dir "cord" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "cord\Debug" +# PROP Intermediate_Dir "cord\Debug" +# PROP Target_Dir "cord" +OUTDIR=.\cord\Debug +INTDIR=.\cord\Debug + +ALL : "gc - Win32 Debug" ".\Debug\de.exe" + +CLEAN : + -@erase ".\cord\Debug\cordbscs.obj" + -@erase ".\cord\Debug\cordxtra.obj" + -@erase ".\cord\Debug\de.obj" + -@erase ".\cord\Debug\de.pdb" + -@erase ".\cord\Debug\de_win.obj" + -@erase ".\cord\Debug\de_win.res" + -@erase ".\cord\Debug\vc40.idb" + -@erase ".\cord\Debug\vc40.pdb" + -@erase ".\Debug\de.exe" + -@erase ".\Debug\de.ilk" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c +CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D\ + "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX\ + /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c +CPP_OBJS=.\cord\Debug/ +CPP_SBRS=.\. + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +MTL=mktyplib.exe +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +RSC_PROJ=/l 0x809 /fo"$(INTDIR)/de_win.res" /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/cord.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Debug/de.exe" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:yes\ + /pdb:"$(OUTDIR)/de.pdb" /debug /machine:I386 /out:"Debug/de.exe" +LINK32_OBJS= \ + ".\cord\Debug\cordbscs.obj" \ + ".\cord\Debug\cordxtra.obj" \ + ".\cord\Debug\de.obj" \ + ".\cord\Debug\de_win.obj" \ + ".\cord\Debug\de_win.res" \ + ".\Debug\gc.lib" + +".\Debug\de.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + +################################################################################ +# Begin Target + +# Name "gc - Win32 Release" +# Name "gc - Win32 Debug" + +!IF "$(CFG)" == "gc - Win32 Release" + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\reclaim.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_RECLA=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_RECLA=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\reclaim.obj" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + +".\Release\reclaim.sbr" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_RECLA=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_RECLA=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\reclaim.obj" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + +".\Debug\reclaim.sbr" : $(SOURCE) $(DEP_CPP_RECLA) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\os_dep.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_OS_DE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OS_DE=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + ".\vd\PCR_VD.h"\ + + +".\Release\os_dep.obj" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + +".\Release\os_dep.sbr" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_OS_DE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OS_DE=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + ".\vd\PCR_VD.h"\ + + +".\Debug\os_dep.obj" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + +".\Debug\os_dep.sbr" : $(SOURCE) $(DEP_CPP_OS_DE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\misc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MISC_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MISC_=\ + ".\il\PCR_IL.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\misc.obj" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + +".\Release\misc.sbr" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MISC_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MISC_=\ + ".\il\PCR_IL.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\misc.obj" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + +".\Debug\misc.sbr" : $(SOURCE) $(DEP_CPP_MISC_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mark_rts.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MARK_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mark_rts.obj" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + +".\Release\mark_rts.sbr" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MARK_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mark_rts.obj" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + +".\Debug\mark_rts.sbr" : $(SOURCE) $(DEP_CPP_MARK_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mach_dep.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MACH_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MACH_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mach_dep.obj" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + +".\Release\mach_dep.sbr" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MACH_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MACH_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mach_dep.obj" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + +".\Debug\mach_dep.sbr" : $(SOURCE) $(DEP_CPP_MACH_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\headers.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_HEADE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_HEADE=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\headers.obj" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + +".\Release\headers.sbr" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_HEADE=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_HEADE=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\headers.obj" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + +".\Debug\headers.sbr" : $(SOURCE) $(DEP_CPP_HEADE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\alloc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_ALLOC=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLOC=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\alloc.obj" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + +".\Release\alloc.sbr" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_ALLOC=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLOC=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\alloc.obj" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + +".\Debug\alloc.sbr" : $(SOURCE) $(DEP_CPP_ALLOC) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\allchblk.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_ALLCH=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLCH=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\allchblk.obj" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + +".\Release\allchblk.sbr" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_ALLCH=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_ALLCH=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\allchblk.obj" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + +".\Debug\allchblk.sbr" : $(SOURCE) $(DEP_CPP_ALLCH) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\stubborn.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_STUBB=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_STUBB=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\stubborn.obj" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + +".\Release\stubborn.sbr" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_STUBB=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_STUBB=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\stubborn.obj" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + +".\Debug\stubborn.sbr" : $(SOURCE) $(DEP_CPP_STUBB) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\obj_map.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_OBJ_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OBJ_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\obj_map.obj" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + +".\Release\obj_map.sbr" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_OBJ_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_OBJ_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\obj_map.obj" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + +".\Debug\obj_map.sbr" : $(SOURCE) $(DEP_CPP_OBJ_M) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\new_hblk.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_NEW_H=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_NEW_H=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\new_hblk.obj" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + +".\Release\new_hblk.sbr" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_NEW_H=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_NEW_H=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\new_hblk.obj" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + +".\Debug\new_hblk.sbr" : $(SOURCE) $(DEP_CPP_NEW_H) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mark.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MARK_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mark.obj" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + +".\Release\mark.sbr" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MARK_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MARK_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mark.obj" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + +".\Debug\mark.sbr" : $(SOURCE) $(DEP_CPP_MARK_C) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\malloc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MALLO=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLO=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\malloc.obj" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + +".\Release\malloc.sbr" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MALLO=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLO=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\malloc.obj" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + +".\Debug\malloc.sbr" : $(SOURCE) $(DEP_CPP_MALLO) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mallocx.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_MALLX=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLX=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\mallocx.obj" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + +".\Release\mallocx.sbr" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_MALLX=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_MALLX=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\mallocx.obj" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + +".\Debug\mallocx.sbr" : $(SOURCE) $(DEP_CPP_MALLX) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\finalize.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_FINAL=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_FINAL=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\finalize.obj" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + +".\Release\finalize.sbr" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_FINAL=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_FINAL=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\finalize.obj" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + +".\Debug\finalize.sbr" : $(SOURCE) $(DEP_CPP_FINAL) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\dbg_mlc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_DBG_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DBG_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\dbg_mlc.obj" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + +".\Release\dbg_mlc.sbr" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_DBG_M=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DBG_M=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\dbg_mlc.obj" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + +".\Debug\dbg_mlc.sbr" : $(SOURCE) $(DEP_CPP_DBG_M) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\blacklst.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_BLACK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_BLACK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\blacklst.obj" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + +".\Release\blacklst.sbr" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_BLACK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_BLACK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\blacklst.obj" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + +".\Debug\blacklst.sbr" : $(SOURCE) $(DEP_CPP_BLACK) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\typd_mlc.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_TYPD_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + ".\gc_typed.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_TYPD_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\typd_mlc.obj" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + +".\Release\typd_mlc.sbr" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_TYPD_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + ".\gc_typed.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_TYPD_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\typd_mlc.obj" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + +".\Debug\typd_mlc.sbr" : $(SOURCE) $(DEP_CPP_TYPD_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\ptr_chck.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_PTR_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_PTR_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\ptr_chck.obj" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + +".\Release\ptr_chck.sbr" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_PTR_C=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_mark.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_PTR_C=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\ptr_chck.obj" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + +".\Debug\ptr_chck.sbr" : $(SOURCE) $(DEP_CPP_PTR_C) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\dyn_load.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_DYN_L=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DYN_L=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\dyn_load.obj" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + +".\Release\dyn_load.sbr" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_DYN_L=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\STAT.H"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_DYN_L=\ + ".\il\PCR_IL.h"\ + ".\mm\PCR_MM.h"\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\dyn_load.obj" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + +".\Debug\dyn_load.sbr" : $(SOURCE) $(DEP_CPP_DYN_L) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\win32_threads.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_WIN32=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_WIN32=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\win32_threads.obj" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + +".\Release\win32_threads.sbr" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_WIN32=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_WIN32=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\win32_threads.obj" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + +".\Debug\win32_threads.sbr" : $(SOURCE) $(DEP_CPP_WIN32) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\checksums.c + +!IF "$(CFG)" == "gc - Win32 Release" + +DEP_CPP_CHECK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_CHECK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Release\checksums.obj" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + +".\Release\checksums.sbr" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gc - Win32 Debug" + +DEP_CPP_CHECK=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_CHECK=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +".\Debug\checksums.obj" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + +".\Debug\checksums.sbr" : $(SOURCE) $(DEP_CPP_CHECK) "$(INTDIR)" + + +!ENDIF + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "gctest - Win32 Release" +# Name "gctest - Win32 Debug" + +!IF "$(CFG)" == "gctest - Win32 Release" + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Project Dependency + +# Project_Dep_Name "gc" + +!IF "$(CFG)" == "gctest - Win32 Release" + +"gc - Win32 Release" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Release" + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + +"gc - Win32 Debug" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Debug" + +!ENDIF + +# End Project Dependency +################################################################################ +# Begin Source File + +SOURCE=.\test.c +DEP_CPP_TEST_=\ + ".\gcconfig.h"\ + ".\gc.h"\ + ".\gc_hdrs.h"\ + ".\gc_priv.h"\ + ".\gc_typed.h"\ + {$(INCLUDE)}"\sys\TYPES.H"\ + +NODEP_CPP_TEST_=\ + ".\th\PCR_Th.h"\ + ".\th\PCR_ThCrSec.h"\ + ".\th\PCR_ThCtl.h"\ + + +!IF "$(CFG)" == "gctest - Win32 Release" + + +".\gctest\Release\test.obj" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "gctest - Win32 Debug" + + +".\gctest\Debug\test.obj" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)" + +".\gctest\Debug\test.sbr" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)" + + +!ENDIF + +# End Source File +# End Target +################################################################################ +# Begin Target + +# Name "cord - Win32 Release" +# Name "cord - Win32 Debug" + +!IF "$(CFG)" == "cord - Win32 Release" + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Project Dependency + +# Project_Dep_Name "gc" + +!IF "$(CFG)" == "cord - Win32 Release" + +"gc - Win32 Release" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Release" + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + +"gc - Win32 Debug" : + $(MAKE) /$(MAKEFLAGS) /F ".\gc.mak" CFG="gc - Win32 Debug" + +!ENDIF + +# End Project Dependency +################################################################################ +# Begin Source File + +SOURCE=.\cord\de_win.c +DEP_CPP_DE_WI=\ + ".\cord\cord.h"\ + ".\cord\de_cmds.h"\ + ".\cord\de_win.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_DE_WI=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\de_win.obj" : $(SOURCE) $(DEP_CPP_DE_WI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\de_win.obj" : $(SOURCE) $(DEP_CPP_DE_WI) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\de.c +DEP_CPP_DE_C2e=\ + ".\cord\cord.h"\ + ".\cord\de_cmds.h"\ + ".\cord\de_win.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_DE_C2e=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\de.obj" : $(SOURCE) $(DEP_CPP_DE_C2e) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\de.obj" : $(SOURCE) $(DEP_CPP_DE_C2e) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\cordxtra.c +DEP_CPP_CORDX=\ + ".\cord\cord.h"\ + ".\cord\ec.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_CORDX=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\cordxtra.obj" : $(SOURCE) $(DEP_CPP_CORDX) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\cordxtra.obj" : $(SOURCE) $(DEP_CPP_CORDX) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\cordbscs.c +DEP_CPP_CORDB=\ + ".\cord\cord.h"\ + ".\cord\private\cord_pos.h"\ + +NODEP_CPP_CORDB=\ + ".\cord\gc.h"\ + + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\cordbscs.obj" : $(SOURCE) $(DEP_CPP_CORDB) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\cordbscs.obj" : $(SOURCE) $(DEP_CPP_CORDB) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cord\de_win.RC + +!IF "$(CFG)" == "cord - Win32 Release" + + +".\cord\Release\de_win.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x809 /fo"$(INTDIR)/de_win.res" /i "cord" /d "NDEBUG" $(SOURCE) + + +!ELSEIF "$(CFG)" == "cord - Win32 Debug" + + +".\cord\Debug\de_win.res" : $(SOURCE) "$(INTDIR)" + $(RSC) /l 0x809 /fo"$(INTDIR)/de_win.res" /i "cord" /d "_DEBUG" $(SOURCE) + + +!ENDIF + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/support/gc/gc.man b/support/gc/gc.man new file mode 100644 index 00000000..5409e706 --- /dev/null +++ b/support/gc/gc.man @@ -0,0 +1,80 @@ +.TH GC_MALLOC 1L "12 February 1996" +.SH NAME +GC_malloc, GC_malloc_atomic, GC_free, GC_realloc, GC_enable_incremental, GC_register_finalizer, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page, GC_set_warn_proc \- Garbage collecting malloc replacement +.SH SYNOPSIS +#include "gc.h" +.br +# define malloc(n) GC_malloc(n) +.br +... malloc(...) ... +.br +.sp +cc ... gc.a +.LP +.SH DESCRIPTION +.I GC_malloc +and +.I GC_free +are plug-in replacements for standard malloc and free. However, +.I +GC_malloc +will attempt to reclaim inaccessible space automatically by invoking a conservative garbage collector at appropriate points. The collector traverses all data structures accessible by following pointers from the machines registers, stack(s), data, and bss segments. Inaccessible structures will be reclaimed. A machine word is considered to be a valid pointer if it is an address inside an object allocated by +.I +GC_malloc +or friends. +.LP +See the documentation in the include file gc_cpp.h for an alternate, C++ specific interface to the garbage collector. +.LP +Unlike the standard implementations of malloc, +.I +GC_malloc +clears the newly allocated storage. +.I +GC_malloc_atomic +does not. Furthermore, it informs the collector that the resulting object will never contain any pointers, and should therefore not be scanned by the collector. +.LP +.I +GC_free +can be used to deallocate objects, but its use is optional, and generally discouraged. +.I +GC_realloc +has the standard realloc semantics. It preserves pointer-free-ness. +.I +GC_register_finalizer +allows for registration of functions that are invoked when an object becomes inaccessible. +.LP +The garbage collector tries to avoid allocating memory at locations that already appear to be referenced before allocation. (Such apparent ``pointers'' are usually large integers and the like that just happen to look like an address.) This may make it hard to allocate very large objects. An attempt to do so may generate a warning. +.LP +.I +GC_malloc_ignore_off_page +and +.I +GC_malloc_atomic_ignore_off_page +inform the collector that the client code will always maintain a pointer to near the beginning of the object (within the first 512 bytes), and that pointers beyond that can be ignored by the collector. This makes it much easier for the collector to place large objects. These are recommended for large object allocation. (Objects expected to be larger than about 100KBytes should be allocated this way.) +.LP +It is also possible to use the collector to find storage leaks in programs destined to be run with standard malloc/free. The collector can be compiled for thread-safe operation. Unlike standard malloc, it is safe to call malloc after a previous malloc call was interrupted by a signal, provided the original malloc call is not resumed. +.LP +The collector may, on rare occasion produce warning messages. On UNIX machines these appear on stderr. Warning messages can be filtered, redirected, or ignored with +.I +GC_set_warn_proc. +This is recommended for production code. See gc.h for details. +.LP +Debugging versions of many of the above routines are provided as macros. Their names are identical to the above, but consist of all capital letters. If GC_DEBUG is defined before gc.h is included, these routines do additional checking, and allow the leak detecting version of the collector to produce slightly more useful output. Without GC_DEBUG defined, they behave exactly like the lower-case versions. +.LP +On some machines, collection will be performed incrementally after a call to +.I +GC_enable_incremental. +This may temporarily write protect pages in the heap. See the README file for more information on how this interacts with system calls that write to the heap. +.LP +Other facilities not discussed here include limited facilities to support incremental collection on machines without appropriate VM support, provisions for providing more explicit object layout information to the garbage collector, more direct support for ``weak'' pointers, support for ``abortable'' garbage collections during idle time, etc. +.LP +.SH "SEE ALSO" +The README and gc.h files in the distribution. More detailed definitions of the functions exported by the collector are given there. (The above list is not complete.) +.LP +Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment", +\fISoftware Practice & Experience\fP, September 1988, pp. 807-820. +.LP +The malloc(3) man page. +.LP +.SH AUTHOR +Hans-J. Boehm (boehm@parc.xerox.com). Some of the code was written by others, most notably Alan Demers. diff --git a/support/gc/gc_alloc.h b/support/gc/gc_alloc.h new file mode 100644 index 00000000..1f1d54af --- /dev/null +++ b/support/gc/gc_alloc.h @@ -0,0 +1,380 @@ +/* + * Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +// +// This is a C++ header file that is intended to replace the SGI STL +// alloc.h. This assumes SGI STL version < 3.0. +// +// This assumes the collector has been compiled with -DATOMIC_UNCOLLECTABLE +// and -DALL_INTERIOR_POINTERS. We also recommend +// -DREDIRECT_MALLOC=GC_uncollectable_malloc. +// +// Some of this could be faster in the explicit deallocation case. In particular, +// we spend too much time clearing objects on the free lists. That could be avoided. +// +// This uses template classes with static members, and hence does not work +// with g++ 2.7.2 and earlier. +// + +#include "gc.h" + +#ifndef GC_ALLOC_H + +#define GC_ALLOC_H +#define __ALLOC_H // Prevent inclusion of the default version. Ugly. +#define __SGI_STL_ALLOC_H +#define __SGI_STL_INTERNAL_ALLOC_H + +#ifndef __ALLOC +# define __ALLOC alloc +#endif + +#include +#include + +// The following is just replicated from the conventional SGI alloc.h: + +template +class simple_alloc { + +public: + static T *allocate(size_t n) + { return 0 == n? 0 : (T*) alloc::allocate(n * sizeof (T)); } + static T *allocate(void) + { return (T*) alloc::allocate(sizeof (T)); } + static void deallocate(T *p, size_t n) + { if (0 != n) alloc::deallocate(p, n * sizeof (T)); } + static void deallocate(T *p) + { alloc::deallocate(p, sizeof (T)); } +}; + +#include "gc.h" + +// The following need to match collector data structures. +// We can't include gc_priv.h, since that pulls in way too much stuff. +// This should eventually be factored out into another include file. + +extern "C" { + extern void ** const GC_objfreelist_ptr; + extern void ** const GC_aobjfreelist_ptr; + extern void ** const GC_uobjfreelist_ptr; + extern void ** const GC_auobjfreelist_ptr; + + extern void GC_incr_words_allocd(size_t words); + extern void GC_incr_mem_freed(size_t words); + + extern char * GC_generic_malloc_words_small(size_t word, int kind); +} + +// Object kinds; must match PTRFREE, NORMAL, UNCOLLECTABLE, and +// AUNCOLLECTABLE in gc_priv.h. + +enum { GC_PTRFREE = 0, GC_NORMAL = 1, GC_UNCOLLECTABLE = 2, + GC_AUNCOLLECTABLE = 3 }; + +enum { GC_max_fast_bytes = 255 }; + +enum { GC_bytes_per_word = sizeof(char *) }; + +enum { GC_byte_alignment = 8 }; + +enum { GC_word_alignment = GC_byte_alignment/GC_bytes_per_word }; + +inline void * &GC_obj_link(void * p) +{ return *(void **)p; } + +// Compute a number of words >= n+1 bytes. +// The +1 allows for pointers one past the end. +inline size_t GC_round_up(size_t n) +{ + return ((n + GC_byte_alignment)/GC_byte_alignment)*GC_word_alignment; +} + +// The same but don't allow for extra byte. +inline size_t GC_round_up_uncollectable(size_t n) +{ + return ((n + GC_byte_alignment - 1)/GC_byte_alignment)*GC_word_alignment; +} + +template +class GC_aux_template { +public: + // File local count of allocated words. Occasionally this is + // added into the global count. A separate count is necessary since the + // real one must be updated with a procedure call. + static size_t GC_words_recently_allocd; + + // Same for uncollectable mmory. Not yet reflected in either + // GC_words_recently_allocd or GC_non_gc_bytes. + static size_t GC_uncollectable_words_recently_allocd; + + // Similar counter for explicitly deallocated memory. + static size_t GC_mem_recently_freed; + + // Again for uncollectable memory. + static size_t GC_uncollectable_mem_recently_freed; + + static void * GC_out_of_line_malloc(size_t nwords, int kind); +}; + +template +size_t GC_aux_template::GC_words_recently_allocd = 0; + +template +size_t GC_aux_template::GC_uncollectable_words_recently_allocd = 0; + +template +size_t GC_aux_template::GC_mem_recently_freed = 0; + +template +size_t GC_aux_template::GC_uncollectable_mem_recently_freed = 0; + +template +void * GC_aux_template::GC_out_of_line_malloc(size_t nwords, int kind) +{ + GC_words_recently_allocd += GC_uncollectable_words_recently_allocd; + GC_non_gc_bytes += + GC_bytes_per_word * GC_uncollectable_words_recently_allocd; + GC_uncollectable_words_recently_allocd = 0; + + GC_mem_recently_freed += GC_uncollectable_mem_recently_freed; + GC_non_gc_bytes -= + GC_bytes_per_word * GC_uncollectable_mem_recently_freed; + GC_uncollectable_mem_recently_freed = 0; + + GC_incr_words_allocd(GC_words_recently_allocd); + GC_words_recently_allocd = 0; + + GC_incr_mem_freed(GC_mem_recently_freed); + GC_mem_recently_freed = 0; + + return GC_generic_malloc_words_small(nwords, kind); +} + +typedef GC_aux_template<0> GC_aux; + +// A fast, single-threaded, garbage-collected allocator +// We assume the first word will be immediately overwritten. +// In this version, deallocation is not a noop, and explicit +// deallocation is likely to help performance. +template +class single_client_gc_alloc_template { + public: + static void * allocate(size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc(n); + flh = GC_objfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_NORMAL); + } + *flh = GC_obj_link(op); + GC_aux::GC_words_recently_allocd += nwords; + return op; + } + static void * ptr_free_allocate(size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_atomic(n); + flh = GC_aobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_PTRFREE); + } + *flh = GC_obj_link(op); + GC_aux::GC_words_recently_allocd += nwords; + return op; + } + static void deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_objfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + memset((char *)p + GC_bytes_per_word, 0, + GC_bytes_per_word * (nwords - 1)); + *flh = p; + GC_aux::GC_mem_recently_freed += nwords; + } + } + static void ptr_free_deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_aobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_mem_recently_freed += nwords; + } + } +}; + +typedef single_client_gc_alloc_template<0> single_client_gc_alloc; + +// Once more, for uncollectable objects. +template +class single_client_alloc_template { + public: + static void * allocate(size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_uncollectable(n); + flh = GC_uobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_UNCOLLECTABLE); + } + *flh = GC_obj_link(op); + GC_aux::GC_uncollectable_words_recently_allocd += nwords; + return op; + } + static void * ptr_free_allocate(size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_atomic_uncollectable(n); + flh = GC_auobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_AUNCOLLECTABLE); + } + *flh = GC_obj_link(op); + GC_aux::GC_uncollectable_words_recently_allocd += nwords; + return op; + } + static void deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_uobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_uncollectable_mem_recently_freed += nwords; + } + } + static void ptr_free_deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_auobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_uncollectable_mem_recently_freed += nwords; + } + } +}; + +typedef single_client_alloc_template<0> single_client_alloc; + +template < int dummy > +class gc_alloc_template { + public: + static void * allocate(size_t n) { return GC_malloc(n); } + static void * ptr_free_allocate(size_t n) + { return GC_malloc_atomic(n); } + static void deallocate(void *, size_t) { } + static void ptr_free_deallocate(void *, size_t) { } +}; + +typedef gc_alloc_template < 0 > gc_alloc; + +template < int dummy > +class alloc_template { + public: + static void * allocate(size_t n) { return GC_malloc_uncollectable(n); } + static void * ptr_free_allocate(size_t n) + { return GC_malloc_atomic_uncollectable(n); } + static void deallocate(void *p, size_t) { GC_free(p); } + static void ptr_free_deallocate(void *p, size_t) { GC_free(p); } +}; + +typedef alloc_template < 0 > alloc; + +#ifdef _SGI_SOURCE + +// We want to specialize simple_alloc so that it does the right thing +// for all pointerfree types. At the moment there is no portable way to +// even approximate that. The following approximation should work for +// SGI compilers, and perhaps some others. + +# define __GC_SPECIALIZE(T,alloc) \ +class simple_alloc { \ +public: \ + static T *allocate(size_t n) \ + { return 0 == n? 0 : \ + (T*) alloc::ptr_free_allocate(n * sizeof (T)); } \ + static T *allocate(void) \ + { return (T*) alloc::ptr_free_allocate(sizeof (T)); } \ + static void deallocate(T *p, size_t n) \ + { if (0 != n) alloc::ptr_free_deallocate(p, n * sizeof (T)); } \ + static void deallocate(T *p) \ + { alloc::ptr_free_deallocate(p, sizeof (T)); } \ +}; + +__GC_SPECIALIZE(char, gc_alloc) +__GC_SPECIALIZE(int, gc_alloc) +__GC_SPECIALIZE(unsigned, gc_alloc) +__GC_SPECIALIZE(float, gc_alloc) +__GC_SPECIALIZE(double, gc_alloc) + +__GC_SPECIALIZE(char, alloc) +__GC_SPECIALIZE(int, alloc) +__GC_SPECIALIZE(unsigned, alloc) +__GC_SPECIALIZE(float, alloc) +__GC_SPECIALIZE(double, alloc) + +__GC_SPECIALIZE(char, single_client_gc_alloc) +__GC_SPECIALIZE(int, single_client_gc_alloc) +__GC_SPECIALIZE(unsigned, single_client_gc_alloc) +__GC_SPECIALIZE(float, single_client_gc_alloc) +__GC_SPECIALIZE(double, single_client_gc_alloc) + +__GC_SPECIALIZE(char, single_client_alloc) +__GC_SPECIALIZE(int, single_client_alloc) +__GC_SPECIALIZE(unsigned, single_client_alloc) +__GC_SPECIALIZE(float, single_client_alloc) +__GC_SPECIALIZE(double, single_client_alloc) + +#ifdef __STL_USE_STD_ALLOCATORS + +???copy stuff from stl_alloc.h or remove it to a different file ??? + +#endif /* __STL_USE_STD_ALLOCATORS */ + +#endif /* _SGI_SOURCE */ + +#endif /* GC_ALLOC_H */ diff --git a/support/gc/gc_cpp.cc b/support/gc/gc_cpp.cc new file mode 100644 index 00000000..547c56f9 --- /dev/null +++ b/support/gc/gc_cpp.cc @@ -0,0 +1,60 @@ +/************************************************************************* +Copyright (c) 1994 by Xerox Corporation. All rights reserved. + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + + Last modified on Sat Nov 19 19:31:14 PST 1994 by ellis + on Sat Jun 8 15:10:00 PST 1994 by boehm + +Permission is hereby granted to copy this code for any purpose, +provided the above notices are retained on all copies. + +This implementation module for gc_c++.h provides an implementation of +the global operators "new" and "delete" that calls the Boehm +allocator. All objects allocated by this implementation will be +non-collectable but part of the root set of the collector. + +You should ensure (using implementation-dependent techniques) that the +linker finds this module before the library that defines the default +built-in "new" and "delete". + +Authors: John R. Ellis and Jesse Hull + +**************************************************************************/ +/* Boehm, December 20, 1994 7:26 pm PST */ + +#include "gc_cpp.h" + +void* operator new( size_t size ) { + return GC_MALLOC_UNCOLLECTABLE( size );} + +void operator delete( void* obj ) { + GC_FREE( obj );} + +#ifdef _MSC_VER +// This new operator is used by VC++ in case of Debug builds ! +void* operator new( size_t size, + int ,//nBlockUse, + const char * szFileName, + int nLine + ) { +# ifndef GC_DEBUG + return GC_malloc_uncollectable( size ); +# else + return GC_debug_malloc_uncollectable(size, szFileName, nLine); +# endif +} +#endif + +#ifdef OPERATOR_NEW_ARRAY + +void* operator new[]( size_t size ) { + return GC_MALLOC_UNCOLLECTABLE( size );} + +void operator delete[]( void* obj ) { + GC_FREE( obj );} + +#endif /* OPERATOR_NEW_ARRAY */ + + diff --git a/support/gc/gc_cpp.h b/support/gc/gc_cpp.h new file mode 100644 index 00000000..ad7df5d7 --- /dev/null +++ b/support/gc/gc_cpp.h @@ -0,0 +1,290 @@ +#ifndef GC_CPP_H +#define GC_CPP_H +/**************************************************************************** +Copyright (c) 1994 by Xerox Corporation. All rights reserved. + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + +Permission is hereby granted to use or copy this program for any +purpose, provided the above notices are retained on all copies. +Permission to modify the code and to distribute modified code is +granted, provided the above notices are retained, and a notice that +the code was modified is included with the above copyright notice. +**************************************************************************** + +C++ Interface to the Boehm Collector + + John R. Ellis and Jesse Hull + Last modified on Mon Jul 24 15:43:42 PDT 1995 by ellis + +This interface provides access to the Boehm collector. It provides +basic facilities similar to those described in "Safe, Efficient +Garbage Collection for C++", by John R. Elis and David L. Detlefs +(ftp.parc.xerox.com:/pub/ellis/gc). + +All heap-allocated objects are either "collectable" or +"uncollectable". Programs must explicitly delete uncollectable +objects, whereas the garbage collector will automatically delete +collectable objects when it discovers them to be inaccessible. +Collectable objects may freely point at uncollectable objects and vice +versa. + +Objects allocated with the built-in "::operator new" are uncollectable. + +Objects derived from class "gc" are collectable. For example: + + class A: public gc {...}; + A* a = new A; // a is collectable. + +Collectable instances of non-class types can be allocated using the GC +placement: + + typedef int A[ 10 ]; + A* a = new (GC) A; + +Uncollectable instances of classes derived from "gc" can be allocated +using the NoGC placement: + + class A: public gc {...}; + A* a = new (NoGC) A; // a is uncollectable. + +Both uncollectable and collectable objects can be explicitly deleted +with "delete", which invokes an object's destructors and frees its +storage immediately. + +A collectable object may have a clean-up function, which will be +invoked when the collector discovers the object to be inaccessible. +An object derived from "gc_cleanup" or containing a member derived +from "gc_cleanup" has a default clean-up function that invokes the +object's destructors. Explicit clean-up functions may be specified as +an additional placement argument: + + A* a = ::new (GC, MyCleanup) A; + +An object is considered "accessible" by the collector if it can be +reached by a path of pointers from static variables, automatic +variables of active functions, or from some object with clean-up +enabled; pointers from an object to itself are ignored. + +Thus, if objects A and B both have clean-up functions, and A points at +B, B is considered accessible. After A's clean-up is invoked and its +storage released, B will then become inaccessible and will have its +clean-up invoked. If A points at B and B points to A, forming a +cycle, then that's considered a storage leak, and neither will be +collectable. See the interface gc.h for low-level facilities for +handling such cycles of objects with clean-up. + +The collector cannot guarrantee that it will find all inaccessible +objects. In practice, it finds almost all of them. + + +Cautions: + +1. Be sure the collector has been augmented with "make c++". + +2. If your compiler supports the new "operator new[]" syntax, then +add -DOPERATOR_NEW_ARRAY to the Makefile. + +If your compiler doesn't support "operator new[]", beware that an +array of type T, where T is derived from "gc", may or may not be +allocated as a collectable object (it depends on the compiler). Use +the explicit GC placement to make the array collectable. For example: + + class A: public gc {...}; + A* a1 = new A[ 10 ]; // collectable or uncollectable? + A* a2 = new (GC) A[ 10 ]; // collectable + +3. The destructors of collectable arrays of objects derived from +"gc_cleanup" will not be invoked properly. For example: + + class A: public gc_cleanup {...}; + A* a = new (GC) A[ 10 ]; // destructors not invoked correctly + +Typically, only the destructor for the first element of the array will +be invoked when the array is garbage-collected. To get all the +destructors of any array executed, you must supply an explicit +clean-up function: + + A* a = new (GC, MyCleanUp) A[ 10 ]; + +(Implementing clean-up of arrays correctly, portably, and in a way +that preserves the correct exception semantics requires a language +extension, e.g. the "gc" keyword.) + +4. Compiler bugs: + +* Solaris 2's CC (SC3.0) doesn't implement t->~T() correctly, so the +destructors of classes derived from gc_cleanup won't be invoked. +You'll have to explicitly register a clean-up function with +new-placement syntax. + +* Evidently cfront 3.0 does not allow destructors to be explicitly +invoked using the ANSI-conforming syntax t->~T(). If you're using +cfront 3.0, you'll have to comment out the class gc_cleanup, which +uses explicit invocation. + +****************************************************************************/ + +#include "gc.h" + +#ifndef THINK_CPLUS +#define _cdecl +#endif + +#if ! defined( OPERATOR_NEW_ARRAY ) \ + && (__BORLANDC__ >= 0x450 || (__GNUC__ >= 2 && __GNUC_MINOR__ >= 6) \ + || __WATCOMC__ >= 1050) +# define OPERATOR_NEW_ARRAY +#endif + +enum GCPlacement {GC, NoGC, PointerFreeGC}; + +class gc {public: + inline void* operator new( size_t size ); + inline void* operator new( size_t size, GCPlacement gcp ); + inline void operator delete( void* obj ); + +#ifdef OPERATOR_NEW_ARRAY + inline void* operator new[]( size_t size ); + inline void* operator new[]( size_t size, GCPlacement gcp ); + inline void operator delete[]( void* obj ); +#endif /* OPERATOR_NEW_ARRAY */ + }; + /* + Instances of classes derived from "gc" will be allocated in the + collected heap by default, unless an explicit NoGC placement is + specified. */ + +class gc_cleanup: virtual public gc {public: + inline gc_cleanup(); + inline virtual ~gc_cleanup(); +private: + inline static void _cdecl cleanup( void* obj, void* clientData );}; + /* + Instances of classes derived from "gc_cleanup" will be allocated + in the collected heap by default. When the collector discovers an + inaccessible object derived from "gc_cleanup" or containing a + member derived from "gc_cleanup", its destructors will be + invoked. */ + +extern "C" {typedef void (*GCCleanUpFunc)( void* obj, void* clientData );} + +inline void* operator new( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup = 0, + void* clientData = 0 ); + /* + Allocates a collectable or uncollected object, according to the + value of "gcp". + + For collectable objects, if "cleanup" is non-null, then when the + allocated object "obj" becomes inaccessible, the collector will + invoke the function "cleanup( obj, clientData )" but will not + invoke the object's destructors. It is an error to explicitly + delete an object allocated with a non-null "cleanup". + + It is an error to specify a non-null "cleanup" with NoGC or for + classes derived from "gc_cleanup" or containing members derived + from "gc_cleanup". */ + +#ifdef OPERATOR_NEW_ARRAY + +inline void* operator new[]( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup = 0, + void* clientData = 0 ); + /* + The operator new for arrays, identical to the above. */ + +#endif /* OPERATOR_NEW_ARRAY */ + +/**************************************************************************** + +Inline implementation + +****************************************************************************/ + +inline void* gc::operator new( size_t size ) { + return GC_MALLOC( size );} + +inline void* gc::operator new( size_t size, GCPlacement gcp ) { + if (gcp == GC) + return GC_MALLOC( size ); + else if (gcp == PointerFreeGC) + return GC_MALLOC_ATOMIC( size ); + else + return GC_MALLOC_UNCOLLECTABLE( size );} + +inline void gc::operator delete( void* obj ) { + GC_FREE( obj );} + + +#ifdef OPERATOR_NEW_ARRAY + +inline void* gc::operator new[]( size_t size ) { + return gc::operator new( size );} + +inline void* gc::operator new[]( size_t size, GCPlacement gcp ) { + return gc::operator new( size, gcp );} + +inline void gc::operator delete[]( void* obj ) { + gc::operator delete( obj );} + +#endif /* OPERATOR_NEW_ARRAY */ + + +inline gc_cleanup::~gc_cleanup() { + GC_REGISTER_FINALIZER_IGNORE_SELF( GC_base(this), 0, 0, 0, 0 );} + +inline void gc_cleanup::cleanup( void* obj, void* displ ) { + ((gc_cleanup*) ((char*) obj + (ptrdiff_t) displ))->~gc_cleanup();} + +inline gc_cleanup::gc_cleanup() { + GC_finalization_proc oldProc; + void* oldData; + void* base = GC_base( (void *) this ); + if (0 == base) return; + GC_REGISTER_FINALIZER_IGNORE_SELF( + base, cleanup, (void*) ((char*) this - (char*) base), + &oldProc, &oldData ); + if (0 != oldProc) { + GC_REGISTER_FINALIZER_IGNORE_SELF( base, oldProc, oldData, 0, 0 );}} + +inline void* operator new( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup, + void* clientData ) +{ + void* obj; + + if (gcp == GC) { + obj = GC_MALLOC( size ); + if (cleanup != 0) + GC_REGISTER_FINALIZER_IGNORE_SELF( + obj, cleanup, clientData, 0, 0 );} + else if (gcp == PointerFreeGC) { + obj = GC_MALLOC_ATOMIC( size );} + else { + obj = GC_MALLOC_UNCOLLECTABLE( size );}; + return obj;} + + +#ifdef OPERATOR_NEW_ARRAY + +inline void* operator new[]( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup, + void* clientData ) +{ + return ::operator new( size, gcp, cleanup, clientData );} + +#endif /* OPERATOR_NEW_ARRAY */ + + +#endif /* GC_CPP_H */ + diff --git a/support/gc/gc_hdrs.h b/support/gc/gc_hdrs.h new file mode 100644 index 00000000..60dc2ad3 --- /dev/null +++ b/support/gc/gc_hdrs.h @@ -0,0 +1,135 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, July 11, 1995 11:54 am PDT */ +# ifndef GC_HEADERS_H +# define GC_HEADERS_H +typedef struct hblkhdr hdr; + +# if CPP_WORDSZ != 32 && CPP_WORDSZ < 36 + --> Get a real machine. +# endif + +/* + * The 2 level tree data structure that is used to find block headers. + * If there are more than 32 bits in a pointer, the top level is a hash + * table. + */ + +# if CPP_WORDSZ > 32 +# define HASH_TL +# endif + +/* Define appropriate out-degrees for each of the two tree levels */ +# ifdef SMALL_CONFIG +# define LOG_BOTTOM_SZ 11 + /* Keep top index size reasonable with smaller blocks. */ +# else +# define LOG_BOTTOM_SZ 10 +# endif +# ifndef HASH_TL +# define LOG_TOP_SZ (WORDSZ - LOG_BOTTOM_SZ - LOG_HBLKSIZE) +# else +# define LOG_TOP_SZ 11 +# endif +# define TOP_SZ (1 << LOG_TOP_SZ) +# define BOTTOM_SZ (1 << LOG_BOTTOM_SZ) + +typedef struct bi { + hdr * index[BOTTOM_SZ]; + /* + * The bottom level index contains one of three kinds of values: + * 0 means we're not responsible for this block, + * or this is a block other than the first one in a free block. + * 1 < (long)X <= MAX_JUMP means the block starts at least + * X * HBLKSIZE bytes before the current address. + * A valid pointer points to a hdr structure. (The above can't be + * valid pointers due to the GET_MEM return convention.) + */ + struct bi * asc_link; /* All indices are linked in */ + /* ascending order... */ + struct bi * desc_link; /* ... and in descending order. */ + word key; /* high order address bits. */ +# ifdef HASH_TL + struct bi * hash_link; /* Hash chain link. */ +# endif +} bottom_index; + +/* extern bottom_index GC_all_nils; - really part of GC_arrays */ + +/* extern bottom_index * GC_top_index []; - really part of GC_arrays */ + /* Each entry points to a bottom_index. */ + /* On a 32 bit machine, it points to */ + /* the index for a set of high order */ + /* bits equal to the index. For longer */ + /* addresses, we hash the high order */ + /* bits to compute the index in */ + /* GC_top_index, and each entry points */ + /* to a hash chain. */ + /* The last entry in each chain is */ + /* GC_all_nils. */ + + +# define MAX_JUMP (HBLKSIZE - 1) + +# define HDR_FROM_BI(bi, p) \ + ((bi)->index[((word)(p) >> LOG_HBLKSIZE) & (BOTTOM_SZ - 1)]) +# ifndef HASH_TL +# define BI(p) (GC_top_index \ + [(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE)]) +# define HDR_INNER(p) HDR_FROM_BI(BI(p),p) +# ifdef SMALL_CONFIG +# define HDR(p) GC_find_header((ptr_t)(p)) +# else +# define HDR(p) HDR_INNER(p) +# endif +# define GET_BI(p, bottom_indx) (bottom_indx) = BI(p) +# define GET_HDR(p, hhdr) (hhdr) = HDR(p) +# define SET_HDR(p, hhdr) HDR_INNER(p) = (hhdr) +# define GET_HDR_ADDR(p, ha) (ha) = &(HDR_INNER(p)) +# else /* hash */ +/* Hash function for tree top level */ +# define TL_HASH(hi) ((hi) & (TOP_SZ - 1)) +/* Set bottom_indx to point to the bottom index for address p */ +# define GET_BI(p, bottom_indx) \ + { \ + register word hi = \ + (word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \ + register bottom_index * _bi = GC_top_index[TL_HASH(hi)]; \ + \ + while (_bi -> key != hi && _bi != GC_all_nils) \ + _bi = _bi -> hash_link; \ + (bottom_indx) = _bi; \ + } +# define GET_HDR_ADDR(p, ha) \ + { \ + register bottom_index * bi; \ + \ + GET_BI(p, bi); \ + (ha) = &(HDR_FROM_BI(bi, p)); \ + } +# define GET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \ + (hhdr) = *_ha; } +# define SET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \ + *_ha = (hhdr); } +# define HDR(p) GC_find_header((ptr_t)(p)) +# endif + +/* Is the result a forwarding address to someplace closer to the */ +/* beginning of the block or NIL? */ +# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((unsigned long) (hhdr) <= MAX_JUMP) + +/* Get an HBLKSIZE aligned address closer to the beginning of the block */ +/* h. Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr). */ +# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (unsigned long)(hhdr)) +# endif /* GC_HEADERS_H */ diff --git a/support/gc/gc_mark.h b/support/gc/gc_mark.h new file mode 100644 index 00000000..4628323f --- /dev/null +++ b/support/gc/gc_mark.h @@ -0,0 +1,280 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +/* Boehm, November 7, 1994 4:56 pm PST */ + +/* + * Declarations of mark stack. Needed by marker and client supplied mark + * routines. To be included after gc_priv.h. + */ +#ifndef GC_MARK_H +# define GC_MARK_H + +/* A client supplied mark procedure. Returns new mark stack pointer. */ +/* Primary effect should be to push new entries on the mark stack. */ +/* Mark stack pointer values are passed and returned explicitly. */ +/* Global variables decribing mark stack are not necessarily valid. */ +/* (This usually saves a few cycles by keeping things in registers.) */ +/* Assumed to scan about PROC_BYTES on average. If it needs to do */ +/* much more work than that, it should do it in smaller pieces by */ +/* pushing itself back on the mark stack. */ +/* Note that it should always do some work (defined as marking some */ +/* objects) before pushing more than one entry on the mark stack. */ +/* This is required to ensure termination in the event of mark stack */ +/* overflows. */ +/* This procedure is always called with at least one empty entry on the */ +/* mark stack. */ +/* Currently we require that mark procedures look for pointers in a */ +/* subset of the places the conservative marker would. It must be safe */ +/* to invoke the normal mark procedure instead. */ +# define PROC_BYTES 100 +/* The real declarations of the following are in gc_priv.h, so that */ +/* we can avoid scanning the following table. */ +/* +typedef struct ms_entry * (*mark_proc)( word * addr, mark_stack_ptr, + mark_stack_limit, env ); + +# define LOG_MAX_MARK_PROCS 6 +# define MAX_MARK_PROCS (1 << LOG_MAX_MARK_PROCS) +extern mark_proc GC_mark_procs[MAX_MARK_PROCS]; +*/ + +extern word GC_n_mark_procs; + +/* Object descriptors on mark stack or in objects. Low order two */ +/* bits are tags distinguishing among the following 4 possibilities */ +/* for the high order 30 bits. */ +#define DS_TAG_BITS 2 +#define DS_TAGS ((1 << DS_TAG_BITS) - 1) +#define DS_LENGTH 0 /* The entire word is a length in bytes that */ + /* must be a multiple of 4. */ +#define DS_BITMAP 1 /* 30 bits are a bitmap describing pointer */ + /* fields. The msb is 1 iff the first word */ + /* is a pointer. */ + /* (This unconventional ordering sometimes */ + /* makes the marker slightly faster.) */ + /* Zeroes indicate definite nonpointers. Ones */ + /* indicate possible pointers. */ + /* Only usable if pointers are word aligned. */ +# define BITMAP_BITS (WORDSZ - DS_TAG_BITS) +#define DS_PROC 2 + /* The objects referenced by this object can be */ + /* pushed on the mark stack by invoking */ + /* PROC(descr). ENV(descr) is passed as the */ + /* last argument. */ +# define PROC(descr) \ + (GC_mark_procs[((descr) >> DS_TAG_BITS) & (MAX_MARK_PROCS-1)]) +# define ENV(descr) \ + ((descr) >> (DS_TAG_BITS + LOG_MAX_MARK_PROCS)) +# define MAX_ENV \ + (((word)1 << (WORDSZ - DS_TAG_BITS - LOG_MAX_MARK_PROCS)) - 1) +# define MAKE_PROC(proc_index, env) \ + (((((env) << LOG_MAX_MARK_PROCS) | (proc_index)) << DS_TAG_BITS) \ + | DS_PROC) +#define DS_PER_OBJECT 3 /* The real descriptor is at the */ + /* byte displacement from the beginning of the */ + /* object given by descr & ~DS_TAGS */ + +typedef struct ms_entry { + word * mse_start; /* First word of object */ + word mse_descr; /* Descriptor; low order two bits are tags, */ + /* identifying the upper 30 bits as one of the */ + /* following: */ +} mse; + +extern word GC_mark_stack_size; + +extern mse * GC_mark_stack_top; + +extern mse * GC_mark_stack; + +word GC_find_start(); + +mse * GC_signal_mark_stack_overflow(); + +# ifdef GATHERSTATS +# define ADD_TO_ATOMIC(sz) GC_atomic_in_use += (sz) +# define ADD_TO_COMPOSITE(sz) GC_composite_in_use += (sz) +# else +# define ADD_TO_ATOMIC(sz) +# define ADD_TO_COMPOSITE(sz) +# endif + +/* Push the object obj with corresponding heap block header hhdr onto */ +/* the mark stack. */ +# define PUSH_OBJ(obj, hhdr, mark_stack_top, mark_stack_limit) \ +{ \ + register word _descr = (hhdr) -> hb_descr; \ + \ + if (_descr == 0) { \ + ADD_TO_ATOMIC((hhdr) -> hb_sz); \ + } else { \ + ADD_TO_COMPOSITE((hhdr) -> hb_sz); \ + mark_stack_top++; \ + if (mark_stack_top >= mark_stack_limit) { \ + mark_stack_top = GC_signal_mark_stack_overflow(mark_stack_top); \ + } \ + mark_stack_top -> mse_start = (obj); \ + mark_stack_top -> mse_descr = _descr; \ + } \ +} + +#ifdef PRINT_BLACK_LIST +# define GC_FIND_START(current, hhdr, source) \ + GC_find_start(current, hhdr, source) +#else +# define GC_FIND_START(current, hhdr, source) \ + GC_find_start(current, hhdr) +#endif + +/* Push the contents of current onto the mark stack if it is a valid */ +/* ptr to a currently unmarked object. Mark it. */ +/* If we assumed a standard-conforming compiler, we could probably */ +/* generate the exit_label transparently. */ +# define PUSH_CONTENTS(current, mark_stack_top, mark_stack_limit, \ + source, exit_label) \ +{ \ + register int displ; /* Displacement in block; first bytes, then words */ \ + register hdr * hhdr; \ + register map_entry_type map_entry; \ + \ + GET_HDR(current,hhdr); \ + if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { \ + current = GC_FIND_START(current, hhdr, (word)source); \ + if (current == 0) goto exit_label; \ + hhdr = HDR(current); \ + } \ + displ = HBLKDISPL(current); \ + map_entry = MAP_ENTRY((hhdr -> hb_map), displ); \ + if (map_entry == OBJ_INVALID) { \ + GC_ADD_TO_BLACK_LIST_NORMAL(current, source); goto exit_label; \ + } \ + displ = BYTES_TO_WORDS(displ); \ + displ -= map_entry; \ + \ + { \ + register word * mark_word_addr = hhdr -> hb_marks + divWORDSZ(displ); \ + register word mark_word = *mark_word_addr; \ + register word mark_bit = (word)1 << modWORDSZ(displ); \ + \ + if (mark_word & mark_bit) { \ + /* Mark bit is already set */ \ + goto exit_label; \ + } \ + GC_STORE_BACK_PTR((ptr_t)source, (ptr_t)HBLKPTR(current) \ + + WORDS_TO_BYTES(displ)); \ + *mark_word_addr = mark_word | mark_bit; \ + } \ + PUSH_OBJ(((word *)(HBLKPTR(current)) + displ), hhdr, \ + mark_stack_top, mark_stack_limit) \ + exit_label: ; \ +} + +#ifdef PRINT_BLACK_LIST +# define PUSH_ONE_CHECKED(p, ip, source) \ + GC_push_one_checked(p, ip, (ptr_t)(source)) +#else +# define PUSH_ONE_CHECKED(p, ip, source) \ + GC_push_one_checked(p, ip) +#endif + +/* + * Push a single value onto mark stack. Mark from the object pointed to by p. + * P is considered valid even if it is an interior pointer. + * Previously marked objects are not pushed. Hence we make progress even + * if the mark stack overflows. + */ +# define GC_PUSH_ONE_STACK(p, source) \ + if ((ptr_t)(p) >= GC_least_plausible_heap_addr \ + && (ptr_t)(p) < GC_greatest_plausible_heap_addr) { \ + PUSH_ONE_CHECKED(p, TRUE, source); \ + } + +/* + * As above, but interior pointer recognition as for + * normal for heap pointers. + */ +# ifdef ALL_INTERIOR_POINTERS +# define AIP TRUE +# else +# define AIP FALSE +# endif +# define GC_PUSH_ONE_HEAP(p,source) \ + if ((ptr_t)(p) >= GC_least_plausible_heap_addr \ + && (ptr_t)(p) < GC_greatest_plausible_heap_addr) { \ + PUSH_ONE_CHECKED(p,AIP,source); \ + } + +/* + * Mark from one finalizable object using the specified + * mark proc. May not mark the object pointed to by + * real_ptr. That is the job of the caller, if appropriate + */ +# define GC_MARK_FO(real_ptr, mark_proc) \ +{ \ + (*(mark_proc))(real_ptr); \ + while (!GC_mark_stack_empty()) GC_mark_from_mark_stack(); \ + if (GC_mark_state != MS_NONE) { \ + GC_set_mark_bit(real_ptr); \ + while (!GC_mark_some((ptr_t)0)); \ + } \ +} + +extern GC_bool GC_mark_stack_too_small; + /* We need a larger mark stack. May be */ + /* set by client supplied mark routines.*/ + +typedef int mark_state_t; /* Current state of marking, as follows:*/ + /* Used to remember where we are during */ + /* concurrent marking. */ + + /* We say something is dirty if it was */ + /* written since the last time we */ + /* retrieved dirty bits. We say it's */ + /* grungy if it was marked dirty in the */ + /* last set of bits we retrieved. */ + + /* Invariant I: all roots and marked */ + /* objects p are either dirty, or point */ + /* to objects q that are either marked */ + /* or a pointer to q appears in a range */ + /* on the mark stack. */ + +# define MS_NONE 0 /* No marking in progress. I holds. */ + /* Mark stack is empty. */ + +# define MS_PUSH_RESCUERS 1 /* Rescuing objects are currently */ + /* being pushed. I holds, except */ + /* that grungy roots may point to */ + /* unmarked objects, as may marked */ + /* grungy objects above scan_ptr. */ + +# define MS_PUSH_UNCOLLECTABLE 2 + /* I holds, except that marked */ + /* uncollectable objects above scan_ptr */ + /* may point to unmarked objects. */ + /* Roots may point to unmarked objects */ + +# define MS_ROOTS_PUSHED 3 /* I holds, mark stack may be nonempty */ + +# define MS_PARTIALLY_INVALID 4 /* I may not hold, e.g. because of M.S. */ + /* overflow. However marked heap */ + /* objects below scan_ptr point to */ + /* marked or stacked objects. */ + +# define MS_INVALID 5 /* I may not hold. */ + +extern mark_state_t GC_mark_state; + +#endif /* GC_MARK_H */ + diff --git a/support/gc/gc_priv.h b/support/gc/gc_priv.h new file mode 100644 index 00000000..5ce52a7a --- /dev/null +++ b/support/gc/gc_priv.h @@ -0,0 +1,1748 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, February 16, 1996 2:30 pm PST */ + + +# ifndef GC_PRIVATE_H +# define GC_PRIVATE_H + +#if defined(mips) && defined(SYSTYPE_BSD) && defined(sony_news) + /* sony RISC NEWS, NEWSOS 4 */ +# define BSD_TIME +/* typedef long ptrdiff_t; -- necessary on some really old systems */ +#endif + +#if defined(mips) && defined(SYSTYPE_BSD43) + /* MIPS RISCOS 4 */ +# define BSD_TIME +#endif + +#ifdef BSD_TIME +# include +# include +# include +#endif /* BSD_TIME */ + +# ifndef GC_H +# include "gc.h" +# endif + +typedef GC_word word; +typedef GC_signed_word signed_word; + +# ifndef CONFIG_H +# include "gcconfig.h" +# endif + +# ifndef HEADERS_H +# include "gc_hdrs.h" +# endif + +typedef int GC_bool; +# define TRUE 1 +# define FALSE 0 + +typedef char * ptr_t; /* A generic pointer to which we can add */ + /* byte displacements. */ + /* Preferably identical to caddr_t, if it */ + /* exists. */ + +#if defined(__STDC__) +# include +# if !(defined( sony_news ) ) +# include +# endif +# define VOLATILE volatile +# define CONST const +#else +# ifdef MSWIN32 +# include +# endif +# define VOLATILE +# define CONST +#endif + +#if 0 /* was once defined for AMIGA */ +# define GC_FAR __far +#else +# define GC_FAR +#endif + +/*********************************/ +/* */ +/* Definitions for conservative */ +/* collector */ +/* */ +/*********************************/ + +/*********************************/ +/* */ +/* Easily changeable parameters */ +/* */ +/*********************************/ + +#define STUBBORN_ALLOC /* Define stubborn allocation primitives */ +#if defined(SRC_M3) || defined(SMALL_CONFIG) +# undef STUBBORN_ALLOC +#endif + + +/* #define ALL_INTERIOR_POINTERS */ + /* Forces all pointers into the interior of an */ + /* object to be considered valid. Also causes the */ + /* sizes of all objects to be inflated by at least */ + /* one byte. This should suffice to guarantee */ + /* that in the presence of a compiler that does */ + /* not perform garbage-collector-unsafe */ + /* optimizations, all portable, strictly ANSI */ + /* conforming C programs should be safely usable */ + /* with malloc replaced by GC_malloc and free */ + /* calls removed. There are several disadvantages: */ + /* 1. There are probably no interesting, portable, */ + /* strictly ANSI conforming C programs. */ + /* 2. This option makes it hard for the collector */ + /* to allocate space that is not ``pointed to'' */ + /* by integers, etc. Under SunOS 4.X with a */ + /* statically linked libc, we empiricaly */ + /* observed that it would be difficult to */ + /* allocate individual objects larger than 100K. */ + /* Even if only smaller objects are allocated, */ + /* more swap space is likely to be needed. */ + /* Fortunately, much of this will never be */ + /* touched. */ + /* If you can easily avoid using this option, do. */ + /* If not, try to keep individual objects small. */ + +#define PRINTSTATS /* Print garbage collection statistics */ + /* For less verbose output, undefine in reclaim.c */ + +#define PRINTTIMES /* Print the amount of time consumed by each garbage */ + /* collection. */ + +#define PRINTBLOCKS /* Print object sizes associated with heap blocks, */ + /* whether the objects are atomic or composite, and */ + /* whether or not the block was found to be empty */ + /* during the reclaim phase. Typically generates */ + /* about one screenful per garbage collection. */ +#undef PRINTBLOCKS + +#ifdef SILENT +# ifdef PRINTSTATS +# undef PRINTSTATS +# endif +# ifdef PRINTTIMES +# undef PRINTTIMES +# endif +# ifdef PRINTNBLOCKS +# undef PRINTNBLOCKS +# endif +#endif + +#if defined(PRINTSTATS) && !defined(GATHERSTATS) +# define GATHERSTATS +#endif + +#ifdef FINALIZE_ON_DEMAND +# define GC_INVOKE_FINALIZERS() +#else +# define GC_INVOKE_FINALIZERS() (void)GC_invoke_finalizers() +#endif + +#define MERGE_SIZES /* Round up some object sizes, so that fewer distinct */ + /* free lists are actually maintained. This applies */ + /* only to the top level routines in misc.c, not to */ + /* user generated code that calls GC_allocobj and */ + /* GC_allocaobj directly. */ + /* Slows down average programs slightly. May however */ + /* substantially reduce fragmentation if allocation */ + /* request sizes are widely scattered. */ + /* May save significant amounts of space for obj_map */ + /* entries. */ + +#ifndef OLD_BLOCK_ALLOC + /* Macros controlling large block allocation strategy. */ +# define EXACT_FIRST /* Make a complete pass through the large object */ + /* free list before splitting a block */ +# define PRESERVE_LAST /* Do not divide last allocated heap segment */ + /* unless we would otherwise need to expand the */ + /* heap. */ +#endif + +/* ALIGN_DOUBLE requires MERGE_SIZES at present. */ +# if defined(ALIGN_DOUBLE) && !defined(MERGE_SIZES) +# define MERGE_SIZES +# endif + +#if defined(ALL_INTERIOR_POINTERS) && !defined(DONT_ADD_BYTE_AT_END) +# define ADD_BYTE_AT_END +#endif + + +# ifndef LARGE_CONFIG +# define MINHINCR 16 /* Minimum heap increment, in blocks of HBLKSIZE */ + /* Must be multiple of largest page size. */ +# define MAXHINCR 512 /* Maximum heap increment, in blocks */ +# else +# define MINHINCR 64 +# define MAXHINCR 4096 +# endif + +# define TIME_LIMIT 50 /* We try to keep pause times from exceeding */ + /* this by much. In milliseconds. */ + +# define BL_LIMIT GC_black_list_spacing + /* If we need a block of N bytes, and we have */ + /* a block of N + BL_LIMIT bytes available, */ + /* and N > BL_LIMIT, */ + /* but all possible positions in it are */ + /* blacklisted, we just use it anyway (and */ + /* print a warning, if warnings are enabled). */ + /* This risks subsequently leaking the block */ + /* due to a false reference. But not using */ + /* the block risks unreasonable immediate */ + /* heap growth. */ + +/*********************************/ +/* */ +/* Stack saving for debugging */ +/* */ +/*********************************/ + +#ifdef SAVE_CALL_CHAIN + +/* + * Number of frames and arguments to save in objects allocated by + * debugging allocator. + */ +# define NFRAMES 6 /* Number of frames to save. Even for */ + /* alignment reasons. */ +# define NARGS 2 /* Mumber of arguments to save for each call. */ + +# define NEED_CALLINFO + +/* Fill in the pc and argument information for up to NFRAMES of my */ +/* callers. Ignore my frame and my callers frame. */ +void GC_save_callers (/* struct callinfo info[NFRAMES] */); + +void GC_print_callers (/* struct callinfo info[NFRAMES] */); + +#else + +# ifdef GC_ADD_CALLER +# define NFRAMES 1 +# define NARGS 0 +# define NEED_CALLINFO +# endif + +#endif + +#ifdef NEED_CALLINFO + struct callinfo { + word ci_pc; +# if NARGS > 0 + word ci_arg[NARGS]; /* bit-wise complement to avoid retention */ +# endif +# if defined(ALIGN_DOUBLE) && (NFRAMES * (NARGS + 1)) % 2 == 1 + /* Likely alignment problem. */ + word ci_dummy; +# endif + }; +#endif + + +/*********************************/ +/* */ +/* OS interface routines */ +/* */ +/*********************************/ + +#ifdef BSD_TIME +# undef CLOCK_TYPE +# undef GET_TIME +# undef MS_TIME_DIFF +# define CLOCK_TYPE struct timeval +# define GET_TIME(x) { struct rusage rusage; \ + getrusage (RUSAGE_SELF, &rusage); \ + x = rusage.ru_utime; } +# define MS_TIME_DIFF(a,b) ((double) (a.tv_sec - b.tv_sec) * 1000.0 \ + + (double) (a.tv_usec - b.tv_usec) / 1000.0) +#else /* !BSD_TIME */ +# include +# if !defined(__STDC__) && defined(SPARC) && defined(SUNOS4) + clock_t clock(); /* Not in time.h, where it belongs */ +# endif +# if defined(FREEBSD) && !defined(CLOCKS_PER_SEC) +# include +# define CLOCKS_PER_SEC CLK_TCK +# endif +# if !defined(CLOCKS_PER_SEC) +# define CLOCKS_PER_SEC 1000000 +/* + * This is technically a bug in the implementation. ANSI requires that + * CLOCKS_PER_SEC be defined. But at least under SunOS4.1.1, it isn't. + * Also note that the combination of ANSI C and POSIX is incredibly gross + * here. The type clock_t is used by both clock() and times(). But on + * some machines these use different notions of a clock tick, CLOCKS_PER_SEC + * seems to apply only to clock. Hence we use it here. On many machines, + * including SunOS, clock actually uses units of microseconds (which are + * not really clock ticks). + */ +# endif +# define CLOCK_TYPE clock_t +# define GET_TIME(x) x = clock() +# define MS_TIME_DIFF(a,b) ((unsigned long) \ + (1000.0*(double)((a)-(b))/(double)CLOCKS_PER_SEC)) +#endif /* !BSD_TIME */ + +/* We use bzero and bcopy internally. They may not be available. */ +# if defined(SPARC) && defined(SUNOS4) +# define BCOPY_EXISTS +# endif +# if defined(M68K) && defined(AMIGA) +# define BCOPY_EXISTS +# endif +# if defined(M68K) && defined(NEXT) +# define BCOPY_EXISTS +# endif +# if defined(VAX) +# define BCOPY_EXISTS +# endif +# if defined(AMIGA) +# include +# define BCOPY_EXISTS +# endif + +# ifndef BCOPY_EXISTS +# include +# define BCOPY(x,y,n) memcpy(y, x, (size_t)(n)) +# define BZERO(x,n) memset(x, 0, (size_t)(n)) +# else +# define BCOPY(x,y,n) bcopy((char *)(x),(char *)(y),(int)(n)) +# define BZERO(x,n) bzero((char *)(x),(int)(n)) +# endif + +/* HBLKSIZE aligned allocation. 0 is taken to mean failure */ +/* space is assumed to be cleared. */ +/* In the case os USE_MMAP, the argument must also be a */ +/* physical page size. */ +/* GET_MEM is currently not assumed to retrieve 0 filled space, */ +/* though we should perhaps take advantage of the case in which */ +/* does. */ +# ifdef PCR + char * real_malloc(); +# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \ + + GC_page_size-1) +# else +# ifdef OS2 + void * os2_alloc(size_t bytes); +# define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \ + + GC_page_size) \ + + GC_page_size-1) +# else +# if defined(AMIGA) || defined(NEXT) || defined(MACOSX) || defined(DOS4GW) +# define GET_MEM(bytes) HBLKPTR((size_t) \ + calloc(1, (size_t)bytes + GC_page_size) \ + + GC_page_size-1) +# else +# ifdef MSWIN32 + extern ptr_t GC_win32_get_mem(); +# define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes) +# else +# ifdef MACOS +# if defined(USE_TEMPORARY_MEMORY) + extern Ptr GC_MacTemporaryNewPtr(size_t size, + Boolean clearMemory); +# define GET_MEM(bytes) HBLKPTR( \ + GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \ + + GC_page_size-1) +# else +# define GET_MEM(bytes) HBLKPTR( \ + NewPtrClear(bytes + GC_page_size) + GC_page_size-1) +# endif +# else + extern ptr_t GC_unix_get_mem(); +# define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes) +# endif +# endif +# endif +# endif +# endif + +/* + * Mutual exclusion between allocator/collector routines. + * Needed if there is more than one allocator thread. + * FASTLOCK() is assumed to try to acquire the lock in a cheap and + * dirty way that is acceptable for a few instructions, e.g. by + * inhibiting preemption. This is assumed to have succeeded only + * if a subsequent call to FASTLOCK_SUCCEEDED() returns TRUE. + * FASTUNLOCK() is called whether or not FASTLOCK_SUCCEEDED(). + * If signals cannot be tolerated with the FASTLOCK held, then + * FASTLOCK should disable signals. The code executed under + * FASTLOCK is otherwise immune to interruption, provided it is + * not restarted. + * DCL_LOCK_STATE declares any local variables needed by LOCK and UNLOCK + * and/or DISABLE_SIGNALS and ENABLE_SIGNALS and/or FASTLOCK. + * (There is currently no equivalent for FASTLOCK.) + */ +# ifdef THREADS +# ifdef PCR_OBSOLETE /* Faster, but broken with multiple lwp's */ +# include "th/PCR_Th.h" +# include "th/PCR_ThCrSec.h" + extern struct PCR_Th_MLRep GC_allocate_ml; +# define DCL_LOCK_STATE PCR_sigset_t GC_old_sig_mask +# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml) +# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml) +# define FASTLOCK() PCR_ThCrSec_EnterSys() + /* Here we cheat (a lot): */ +# define FASTLOCK_SUCCEEDED() (*(int *)(&GC_allocate_ml) == 0) + /* TRUE if nobody currently holds the lock */ +# define FASTUNLOCK() PCR_ThCrSec_ExitSys() +# endif +# ifdef PCR +# include +# include + extern PCR_Th_ML GC_allocate_ml; +# define DCL_LOCK_STATE \ + PCR_ERes GC_fastLockRes; PCR_sigset_t GC_old_sig_mask +# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml) +# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml) +# define FASTLOCK() (GC_fastLockRes = PCR_Th_ML_Try(&GC_allocate_ml)) +# define FASTLOCK_SUCCEEDED() (GC_fastLockRes == PCR_ERes_okay) +# define FASTUNLOCK() {\ + if( FASTLOCK_SUCCEEDED() ) PCR_Th_ML_Release(&GC_allocate_ml); } +# endif +# ifdef SRC_M3 + extern word RT0u__inCritical; +# define LOCK() RT0u__inCritical++ +# define UNLOCK() RT0u__inCritical-- +# endif +# ifdef SOLARIS_THREADS +# include +# include + extern mutex_t GC_allocate_ml; +# define LOCK() mutex_lock(&GC_allocate_ml); +# define UNLOCK() mutex_unlock(&GC_allocate_ml); +# endif +# ifdef LINUX_THREADS +# include +# ifdef __i386__ + inline static int GC_test_and_set(volatile unsigned int *addr) { + int oldval; + /* Note: the "xchg" instruction does not need a "lock" prefix */ + __asm__ __volatile__("xchgl %0, %1" + : "=r"(oldval), "=m"(*(addr)) + : "0"(1), "m"(*(addr))); + return oldval; + } +# else + -- > Need implementation of GC_test_and_set() +# endif +# define GC_clear(addr) (*(addr) = 0) + + extern volatile unsigned int GC_allocate_lock; + /* This is not a mutex because mutexes that obey the (optional) */ + /* POSIX scheduling rules are subject to convoys in high contention */ + /* applications. This is basically a spin lock. */ + extern pthread_t GC_lock_holder; + extern void GC_lock(void); + /* Allocation lock holder. Only set if acquired by client through */ + /* GC_call_with_alloc_lock. */ +# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self() +# define NO_THREAD (pthread_t)(-1) +# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD +# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self())) +# ifdef UNDEFINED +# define LOCK() pthread_mutex_lock(&GC_allocate_ml) +# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml) +# else +# define LOCK() \ + { if (GC_test_and_set(&GC_allocate_lock)) GC_lock(); } +# define UNLOCK() \ + GC_clear(&GC_allocate_lock) +# endif + extern GC_bool GC_collecting; +# define ENTER_GC() \ + { \ + GC_collecting = 1; \ + } +# define EXIT_GC() GC_collecting = 0; +# endif /* LINUX_THREADS */ +# if defined(IRIX_THREADS) || defined(IRIX_JDK_THREADS) +# include +# include + +# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) \ + || !defined(_COMPILER_VERSION) || _COMPILER_VERSION < 700 +# define GC_test_and_set(addr, v) test_and_set(addr,v) +# else +# define GC_test_and_set(addr, v) __test_and_set(addr,v) +# endif + extern unsigned long GC_allocate_lock; + /* This is not a mutex because mutexes that obey the (optional) */ + /* POSIX scheduling rules are subject to convoys in high contention */ + /* applications. This is basically a spin lock. */ + extern pthread_t GC_lock_holder; + extern void GC_lock(void); + /* Allocation lock holder. Only set if acquired by client through */ + /* GC_call_with_alloc_lock. */ +# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self() +# define NO_THREAD (pthread_t)(-1) +# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD +# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self())) +# ifdef UNDEFINED +# define LOCK() pthread_mutex_lock(&GC_allocate_ml) +# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml) +# else +# define LOCK() { if (GC_test_and_set(&GC_allocate_lock, 1)) GC_lock(); } +# if __mips >= 3 && (defined (_ABIN32) || defined(_ABI64)) \ + && defined(_COMPILER_VERSION) && _COMPILER_VERSION >= 700 +# define UNLOCK() __lock_release(&GC_allocate_lock) +# else + /* The function call in the following should prevent the */ + /* compiler from moving assignments to below the UNLOCK. */ + /* This is probably not necessary for ucode or gcc 2.8. */ + /* It may be necessary for Ragnarok and future gcc */ + /* versions. */ +# define UNLOCK() { GC_noop1(&GC_allocate_lock); \ + *(volatile unsigned long *)(&GC_allocate_lock) = 0; } +# endif +# endif + extern GC_bool GC_collecting; +# define ENTER_GC() \ + { \ + GC_collecting = 1; \ + } +# define EXIT_GC() GC_collecting = 0; +# endif /* IRIX_THREADS || IRIX_JDK_THREADS */ +# ifdef WIN32_THREADS +# include + GC_API CRITICAL_SECTION GC_allocate_ml; +# define LOCK() EnterCriticalSection(&GC_allocate_ml); +# define UNLOCK() LeaveCriticalSection(&GC_allocate_ml); +# endif +# ifndef SET_LOCK_HOLDER +# define SET_LOCK_HOLDER() +# define UNSET_LOCK_HOLDER() +# define I_HOLD_LOCK() FALSE + /* Used on platforms were locks can be reacquired, */ + /* so it doesn't matter if we lie. */ +# endif +# else +# define LOCK() +# define UNLOCK() +# endif +# ifndef SET_LOCK_HOLDER +# define SET_LOCK_HOLDER() +# define UNSET_LOCK_HOLDER() +# define I_HOLD_LOCK() FALSE + /* Used on platforms were locks can be reacquired, */ + /* so it doesn't matter if we lie. */ +# endif +# ifndef ENTER_GC +# define ENTER_GC() +# define EXIT_GC() +# endif + +# ifndef DCL_LOCK_STATE +# define DCL_LOCK_STATE +# endif +# ifndef FASTLOCK +# define FASTLOCK() LOCK() +# define FASTLOCK_SUCCEEDED() TRUE +# define FASTUNLOCK() UNLOCK() +# endif + +/* Delay any interrupts or signals that may abort this thread. Data */ +/* structures are in a consistent state outside this pair of calls. */ +/* ANSI C allows both to be empty (though the standard isn't very */ +/* clear on that point). Standard malloc implementations are usually */ +/* neither interruptable nor thread-safe, and thus correspond to */ +/* empty definitions. */ +# ifdef PCR +# define DISABLE_SIGNALS() \ + PCR_Th_SetSigMask(PCR_allSigsBlocked,&GC_old_sig_mask) +# define ENABLE_SIGNALS() \ + PCR_Th_SetSigMask(&GC_old_sig_mask, NIL) +# else +# if defined(SRC_M3) || defined(AMIGA) || defined(SOLARIS_THREADS) \ + || defined(MSWIN32) || defined(MACOS) || defined(DJGPP) \ + || defined(NO_SIGNALS) || defined(IRIX_THREADS) \ + || defined(IRIX_JDK_THREADS) || defined(LINUX_THREADS) + /* Also useful for debugging. */ + /* Should probably use thr_sigsetmask for SOLARIS_THREADS. */ +# define DISABLE_SIGNALS() +# define ENABLE_SIGNALS() +# else +# define DISABLE_SIGNALS() GC_disable_signals() + void GC_disable_signals(); +# define ENABLE_SIGNALS() GC_enable_signals() + void GC_enable_signals(); +# endif +# endif + +/* + * Stop and restart mutator threads. + */ +# ifdef PCR +# include "th/PCR_ThCtl.h" +# define STOP_WORLD() \ + PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_stopNormal, \ + PCR_allSigsBlocked, \ + PCR_waitForever) +# define START_WORLD() \ + PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_null, \ + PCR_allSigsBlocked, \ + PCR_waitForever); +# else +# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ + || defined(IRIX_THREADS) || defined(LINUX_THREADS) \ + || defined(IRIX_JDK_THREADS) + void GC_stop_world(); + void GC_start_world(); +# define STOP_WORLD() GC_stop_world() +# define START_WORLD() GC_start_world() +# else +# define STOP_WORLD() +# define START_WORLD() +# endif +# endif + +/* Abandon ship */ +# ifdef PCR +# define ABORT(s) PCR_Base_Panic(s) +# else +# ifdef SMALL_CONFIG +# define ABORT(msg) abort(); +# else + GC_API void GC_abort(); +# define ABORT(msg) GC_abort(msg); +# endif +# endif + +/* Exit abnormally, but without making a mess (e.g. out of memory) */ +# ifdef PCR +# define EXIT() PCR_Base_Exit(1,PCR_waitForever) +# else +# define EXIT() (void)exit(1) +# endif + +/* Print warning message, e.g. almost out of memory. */ +# define WARN(msg,arg) (*GC_current_warn_proc)(msg, (GC_word)(arg)) +extern GC_warn_proc GC_current_warn_proc; + +/*********************************/ +/* */ +/* Word-size-dependent defines */ +/* */ +/*********************************/ + +#if CPP_WORDSZ == 32 +# define WORDS_TO_BYTES(x) ((x)<<2) +# define BYTES_TO_WORDS(x) ((x)>>2) +# define LOGWL ((word)5) /* log[2] of CPP_WORDSZ */ +# define modWORDSZ(n) ((n) & 0x1f) /* n mod size of word */ +# if ALIGNMENT != 4 +# define UNALIGNED +# endif +#endif + +#if CPP_WORDSZ == 64 +# define WORDS_TO_BYTES(x) ((x)<<3) +# define BYTES_TO_WORDS(x) ((x)>>3) +# define LOGWL ((word)6) /* log[2] of CPP_WORDSZ */ +# define modWORDSZ(n) ((n) & 0x3f) /* n mod size of word */ +# if ALIGNMENT != 8 +# define UNALIGNED +# endif +#endif + +#define WORDSZ ((word)CPP_WORDSZ) +#define SIGNB ((word)1 << (WORDSZ-1)) +#define BYTES_PER_WORD ((word)(sizeof (word))) +#define ONES ((word)(-1)) +#define divWORDSZ(n) ((n) >> LOGWL) /* divide n by size of word */ + +/*********************/ +/* */ +/* Size Parameters */ +/* */ +/*********************/ + +/* heap block size, bytes. Should be power of 2 */ + +#ifndef HBLKSIZE +# ifdef SMALL_CONFIG +# define CPP_LOG_HBLKSIZE 10 +# else +# if CPP_WORDSZ == 32 +# define CPP_LOG_HBLKSIZE 12 +# else +# define CPP_LOG_HBLKSIZE 13 +# endif +# endif +#else +# if HBLKSIZE == 512 +# define CPP_LOG_HBLKSIZE 9 +# endif +# if HBLKSIZE == 1024 +# define CPP_LOG_HBLKSIZE 10 +# endif +# if HBLKSIZE == 2048 +# define CPP_LOG_HBLKSIZE 11 +# endif +# if HBLKSIZE == 4096 +# define CPP_LOG_HBLKSIZE 12 +# endif +# if HBLKSIZE == 8192 +# define CPP_LOG_HBLKSIZE 13 +# endif +# if HBLKSIZE == 16384 +# define CPP_LOG_HBLKSIZE 14 +# endif +# ifndef CPP_LOG_HBLKSIZE + --> fix HBLKSIZE +# endif +# undef HBLKSIZE +#endif +# define CPP_HBLKSIZE (1 << CPP_LOG_HBLKSIZE) +# define LOG_HBLKSIZE ((word)CPP_LOG_HBLKSIZE) +# define HBLKSIZE ((word)CPP_HBLKSIZE) + + +/* max size objects supported by freelist (larger objects may be */ +/* allocated, but less efficiently) */ + +#define CPP_MAXOBJSZ BYTES_TO_WORDS(CPP_HBLKSIZE/2) +#define MAXOBJSZ ((word)CPP_MAXOBJSZ) + +# define divHBLKSZ(n) ((n) >> LOG_HBLKSIZE) + +# define HBLK_PTR_DIFF(p,q) divHBLKSZ((ptr_t)p - (ptr_t)q) + /* Equivalent to subtracting 2 hblk pointers. */ + /* We do it this way because a compiler should */ + /* find it hard to use an integer division */ + /* instead of a shift. The bundled SunOS 4.1 */ + /* o.w. sometimes pessimizes the subtraction to */ + /* involve a call to .div. */ + +# define modHBLKSZ(n) ((n) & (HBLKSIZE-1)) + +# define HBLKPTR(objptr) ((struct hblk *)(((word) (objptr)) & ~(HBLKSIZE-1))) + +# define HBLKDISPL(objptr) (((word) (objptr)) & (HBLKSIZE-1)) + +/* Round up byte allocation requests to integral number of words, etc. */ +# ifdef ADD_BYTE_AT_END +# define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + WORDS_TO_BYTES(1)) +# ifdef ALIGN_DOUBLE +# define ALIGNED_WORDS(n) (BYTES_TO_WORDS((n) + WORDS_TO_BYTES(2)) & ~1) +# else +# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n) +# endif +# define SMALL_OBJ(bytes) ((bytes) < WORDS_TO_BYTES(MAXOBJSZ)) +# define ADD_SLOP(bytes) ((bytes)+1) +# else +# define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + (WORDS_TO_BYTES(1) - 1)) +# ifdef ALIGN_DOUBLE +# define ALIGNED_WORDS(n) \ + (BYTES_TO_WORDS((n) + WORDS_TO_BYTES(2) - 1) & ~1) +# else +# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n) +# endif +# define SMALL_OBJ(bytes) ((bytes) <= WORDS_TO_BYTES(MAXOBJSZ)) +# define ADD_SLOP(bytes) (bytes) +# endif + + +/* + * Hash table representation of sets of pages. This assumes it is + * OK to add spurious entries to sets. + * Used by black-listing code, and perhaps by dirty bit maintenance code. + */ + +# ifdef LARGE_CONFIG +# define LOG_PHT_ENTRIES 17 +# else +# define LOG_PHT_ENTRIES 14 /* Collisions are likely if heap grows */ + /* to more than 16K hblks = 64MB. */ + /* Each hash table occupies 2K bytes. */ +# endif +# define PHT_ENTRIES ((word)1 << LOG_PHT_ENTRIES) +# define PHT_SIZE (PHT_ENTRIES >> LOGWL) +typedef word page_hash_table[PHT_SIZE]; + +# define PHT_HASH(addr) ((((word)(addr)) >> LOG_HBLKSIZE) & (PHT_ENTRIES - 1)) + +# define get_pht_entry_from_index(bl, index) \ + (((bl)[divWORDSZ(index)] >> modWORDSZ(index)) & 1) +# define set_pht_entry_from_index(bl, index) \ + (bl)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index) +# define clear_pht_entry_from_index(bl, index) \ + (bl)[divWORDSZ(index)] &= ~((word)1 << modWORDSZ(index)) + + + +/********************************************/ +/* */ +/* H e a p B l o c k s */ +/* */ +/********************************************/ + +/* heap block header */ +#define HBLKMASK (HBLKSIZE-1) + +#define BITS_PER_HBLK (HBLKSIZE * 8) + +#define MARK_BITS_PER_HBLK (BITS_PER_HBLK/CPP_WORDSZ) + /* upper bound */ + /* We allocate 1 bit/word. Only the first word */ + /* in each object is actually marked. */ + +# ifdef ALIGN_DOUBLE +# define MARK_BITS_SZ (((MARK_BITS_PER_HBLK + 2*CPP_WORDSZ - 1) \ + / (2*CPP_WORDSZ))*2) +# else +# define MARK_BITS_SZ ((MARK_BITS_PER_HBLK + CPP_WORDSZ - 1)/CPP_WORDSZ) +# endif + /* Upper bound on number of mark words per heap block */ + +struct hblkhdr { + word hb_sz; /* If in use, size in words, of objects in the block. */ + /* if free, the size in bytes of the whole block */ + struct hblk * hb_next; /* Link field for hblk free list */ + /* and for lists of chunks waiting to be */ + /* reclaimed. */ + struct hblk * hb_prev; /* Backwards link for free list. */ + word hb_descr; /* object descriptor for marking. See */ + /* mark.h. */ + char* hb_map; /* A pointer to a pointer validity map of the block. */ + /* See GC_obj_map. */ + /* Valid for all blocks with headers. */ + /* Free blocks point to GC_invalid_map. */ + unsigned char hb_obj_kind; + /* Kind of objects in the block. Each kind */ + /* identifies a mark procedure and a set of */ + /* list headers. Sometimes called regions. */ + unsigned char hb_flags; +# define IGNORE_OFF_PAGE 1 /* Ignore pointers that do not */ + /* point to the first page of */ + /* this object. */ +# define WAS_UNMAPPED 2 /* This is a free block, which has */ + /* been unmapped from the address */ + /* space. */ + /* GC_remap must be invoked on it */ + /* before it can be reallocated. */ + /* Only set with USE_MUNMAP. */ + unsigned short hb_last_reclaimed; + /* Value of GC_gc_no when block was */ + /* last allocated or swept. May wrap. */ + /* For a free block, this is maintained */ + /* unly for USE_MUNMAP, and indicates */ + /* when the header was allocated, or */ + /* when the size of the block last */ + /* changed. */ + word hb_marks[MARK_BITS_SZ]; + /* Bit i in the array refers to the */ + /* object starting at the ith word (header */ + /* INCLUDED) in the heap block. */ + /* The lsb of word 0 is numbered 0. */ +}; + +/* heap block body */ + +# define DISCARD_WORDS 0 + /* Number of words to be dropped at the beginning of each block */ + /* Must be a multiple of WORDSZ. May reasonably be nonzero */ + /* on machines that don't guarantee longword alignment of */ + /* pointers, so that the number of false hits is minimized. */ + /* 0 and WORDSZ are probably the only reasonable values. */ + +# define BODY_SZ ((HBLKSIZE-WORDS_TO_BYTES(DISCARD_WORDS))/sizeof(word)) + +struct hblk { +# if (DISCARD_WORDS != 0) + word garbage[DISCARD_WORDS]; +# endif + word hb_body[BODY_SZ]; +}; + +# define HDR_WORDS ((word)DISCARD_WORDS) +# define HDR_BYTES ((word)WORDS_TO_BYTES(DISCARD_WORDS)) + +# define OBJ_SZ_TO_BLOCKS(sz) \ + divHBLKSZ(HDR_BYTES + WORDS_TO_BYTES(sz) + HBLKSIZE-1) + /* Size of block (in units of HBLKSIZE) needed to hold objects of */ + /* given sz (in words). */ + +/* Object free list link */ +# define obj_link(p) (*(ptr_t *)(p)) + +/* The type of mark procedures. This really belongs in gc_mark.h. */ +/* But we put it here, so that we can avoid scanning the mark proc */ +/* table. */ +typedef struct ms_entry * (*mark_proc)(/* word * addr, mark_stack_ptr, + mark_stack_limit, env */); +# define LOG_MAX_MARK_PROCS 6 +# define MAX_MARK_PROCS (1 << LOG_MAX_MARK_PROCS) + +/* Root sets. Logically private to mark_rts.c. But we don't want the */ +/* tables scanned, so we put them here. */ +/* MAX_ROOT_SETS is the maximum number of ranges that can be */ +/* registered as static roots. */ +# ifdef LARGE_CONFIG +# define MAX_ROOT_SETS 4096 +# else +# ifdef PCR +# define MAX_ROOT_SETS 1024 +# else +# ifdef MSWIN32 +# define MAX_ROOT_SETS 512 + /* Under NT, we add only written pages, which can result */ + /* in many small root sets. */ +# else +# define MAX_ROOT_SETS 64 +# endif +# endif +# endif + +# define MAX_EXCLUSIONS (MAX_ROOT_SETS/4) +/* Maximum number of segments that can be excluded from root sets. */ + +/* + * Data structure for excluded static roots. + */ +struct exclusion { + ptr_t e_start; + ptr_t e_end; +}; + +/* Data structure for list of root sets. */ +/* We keep a hash table, so that we can filter out duplicate additions. */ +/* Under Win32, we need to do a better job of filtering overlaps, so */ +/* we resort to sequential search, and pay the price. */ +struct roots { + ptr_t r_start; + ptr_t r_end; +# ifndef MSWIN32 + struct roots * r_next; +# endif + GC_bool r_tmp; + /* Delete before registering new dynamic libraries */ +}; + +#ifndef MSWIN32 + /* Size of hash table index to roots. */ +# define LOG_RT_SIZE 6 +# define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */ +#endif + +/* Lists of all heap blocks and free lists */ +/* as well as other random data structures */ +/* that should not be scanned by the */ +/* collector. */ +/* These are grouped together in a struct */ +/* so that they can be easily skipped by the */ +/* GC_mark routine. */ +/* The ordering is weird to make GC_malloc */ +/* faster by keeping the important fields */ +/* sufficiently close together that a */ +/* single load of a base register will do. */ +/* Scalars that could easily appear to */ +/* be pointers are also put here. */ +/* The main fields should precede any */ +/* conditionally included fields, so that */ +/* gc_inl.h will work even if a different set */ +/* of macros is defined when the client is */ +/* compiled. */ + +struct _GC_arrays { + word _heapsize; + word _max_heapsize; + ptr_t _last_heap_addr; + ptr_t _prev_heap_addr; + word _large_free_bytes; + /* Total bytes contained in blocks on large object free */ + /* list. */ + word _words_allocd_before_gc; + /* Number of words allocated before this */ + /* collection cycle. */ + word _words_allocd; + /* Number of words allocated during this collection cycle */ + word _words_wasted; + /* Number of words wasted due to internal fragmentation */ + /* in large objects, or due to dropping blacklisted */ + /* blocks, since last gc. Approximate. */ + word _words_finalized; + /* Approximate number of words in objects (and headers) */ + /* That became ready for finalization in the last */ + /* collection. */ + word _non_gc_bytes_at_gc; + /* Number of explicitly managed bytes of storage */ + /* at last collection. */ + word _mem_freed; + /* Number of explicitly deallocated words of memory */ + /* since last collection. */ + mark_proc _mark_procs[MAX_MARK_PROCS]; + /* Table of user-defined mark procedures. There is */ + /* a small number of these, which can be referenced */ + /* by DS_PROC mark descriptors. See gc_mark.h. */ + ptr_t _objfreelist[MAXOBJSZ+1]; + /* free list for objects */ + ptr_t _aobjfreelist[MAXOBJSZ+1]; + /* free list for atomic objs */ + + ptr_t _uobjfreelist[MAXOBJSZ+1]; + /* uncollectable but traced objs */ + /* objects on this and auobjfreelist */ + /* are always marked, except during */ + /* garbage collections. */ +# ifdef ATOMIC_UNCOLLECTABLE + ptr_t _auobjfreelist[MAXOBJSZ+1]; +# endif + /* uncollectable but traced objs */ + +# ifdef GATHERSTATS + word _composite_in_use; + /* Number of words in accessible composite */ + /* objects. */ + word _atomic_in_use; + /* Number of words in accessible atomic */ + /* objects. */ +# endif +# ifdef USE_MUNMAP + word _unmapped_bytes; +# endif +# ifdef MERGE_SIZES + unsigned _size_map[WORDS_TO_BYTES(MAXOBJSZ+1)]; + /* Number of words to allocate for a given allocation request in */ + /* bytes. */ +# endif + +# ifdef STUBBORN_ALLOC + ptr_t _sobjfreelist[MAXOBJSZ+1]; +# endif + /* free list for immutable objects */ + ptr_t _obj_map[MAXOBJSZ+1]; + /* If not NIL, then a pointer to a map of valid */ + /* object addresses. _obj_map[sz][i] is j if the */ + /* address block_start+i is a valid pointer */ + /* to an object at */ + /* block_start+i&~3 - WORDS_TO_BYTES(j). */ + /* (If ALL_INTERIOR_POINTERS is defined, then */ + /* instead ((short *)(hb_map[sz])[i] is j if */ + /* block_start+WORDS_TO_BYTES(i) is in the */ + /* interior of an object starting at */ + /* block_start+WORDS_TO_BYTES(i-j)). */ + /* It is OBJ_INVALID if */ + /* block_start+WORDS_TO_BYTES(i) is not */ + /* valid as a pointer to an object. */ + /* We assume all values of j <= OBJ_INVALID. */ + /* The zeroth entry corresponds to large objects.*/ +# ifdef ALL_INTERIOR_POINTERS +# define map_entry_type short +# define OBJ_INVALID 0x7fff +# define MAP_ENTRY(map, bytes) \ + (((map_entry_type *)(map))[BYTES_TO_WORDS(bytes)]) +# define MAP_ENTRIES BYTES_TO_WORDS(HBLKSIZE) +# define MAP_SIZE (MAP_ENTRIES * sizeof(map_entry_type)) +# define OFFSET_VALID(displ) TRUE +# define CPP_MAX_OFFSET (HBLKSIZE - HDR_BYTES - 1) +# define MAX_OFFSET ((word)CPP_MAX_OFFSET) +# else +# define map_entry_type char +# define OBJ_INVALID 0x7f +# define MAP_ENTRY(map, bytes) \ + (map)[bytes] +# define MAP_ENTRIES HBLKSIZE +# define MAP_SIZE MAP_ENTRIES +# define CPP_MAX_OFFSET (WORDS_TO_BYTES(OBJ_INVALID) - 1) +# define MAX_OFFSET ((word)CPP_MAX_OFFSET) +# define VALID_OFFSET_SZ \ + (CPP_MAX_OFFSET > WORDS_TO_BYTES(CPP_MAXOBJSZ)? \ + CPP_MAX_OFFSET+1 \ + : WORDS_TO_BYTES(CPP_MAXOBJSZ)+1) + char _valid_offsets[VALID_OFFSET_SZ]; + /* GC_valid_offsets[i] == TRUE ==> i */ + /* is registered as a displacement. */ +# define OFFSET_VALID(displ) GC_valid_offsets[displ] + char _modws_valid_offsets[sizeof(word)]; + /* GC_valid_offsets[i] ==> */ + /* GC_modws_valid_offsets[i%sizeof(word)] */ +# endif +# ifdef STUBBORN_ALLOC + page_hash_table _changed_pages; + /* Stubborn object pages that were changes since last call to */ + /* GC_read_changed. */ + page_hash_table _prev_changed_pages; + /* Stubborn object pages that were changes before last call to */ + /* GC_read_changed. */ +# endif +# if defined(PROC_VDB) || defined(MPROTECT_VDB) + page_hash_table _grungy_pages; /* Pages that were dirty at last */ + /* GC_read_dirty. */ +# endif +# ifdef MPROTECT_VDB + VOLATILE page_hash_table _dirty_pages; + /* Pages dirtied since last GC_read_dirty. */ +# endif +# ifdef PROC_VDB + page_hash_table _written_pages; /* Pages ever dirtied */ +# endif +# ifdef LARGE_CONFIG +# if CPP_WORDSZ > 32 +# define MAX_HEAP_SECTS 4096 /* overflows at roughly 64 GB */ +# else +# define MAX_HEAP_SECTS 768 /* Separately added heap sections. */ +# endif +# else +# define MAX_HEAP_SECTS 256 +# endif + struct HeapSect { + ptr_t hs_start; word hs_bytes; + } _heap_sects[MAX_HEAP_SECTS]; +# ifdef MSWIN32 + ptr_t _heap_bases[MAX_HEAP_SECTS]; + /* Start address of memory regions obtained from kernel. */ +# endif + struct roots _static_roots[MAX_ROOT_SETS]; +# ifndef MSWIN32 + struct roots * _root_index[RT_SIZE]; +# endif + struct exclusion _excl_table[MAX_EXCLUSIONS]; + /* Block header index; see gc_headers.h */ + bottom_index * _all_nils; + bottom_index * _top_index [TOP_SZ]; +#ifdef SAVE_CALL_CHAIN + struct callinfo _last_stack[NFRAMES]; /* Stack at last garbage collection.*/ + /* Useful for debugging mysterious */ + /* object disappearances. */ + /* In the multithreaded case, we */ + /* currently only save the calling */ + /* stack. */ +#endif +}; + +GC_API GC_FAR struct _GC_arrays GC_arrays; + +# define GC_objfreelist GC_arrays._objfreelist +# define GC_aobjfreelist GC_arrays._aobjfreelist +# define GC_uobjfreelist GC_arrays._uobjfreelist +# ifdef ATOMIC_UNCOLLECTABLE +# define GC_auobjfreelist GC_arrays._auobjfreelist +# endif +# define GC_sobjfreelist GC_arrays._sobjfreelist +# define GC_valid_offsets GC_arrays._valid_offsets +# define GC_modws_valid_offsets GC_arrays._modws_valid_offsets +# ifdef STUBBORN_ALLOC +# define GC_changed_pages GC_arrays._changed_pages +# define GC_prev_changed_pages GC_arrays._prev_changed_pages +# endif +# define GC_obj_map GC_arrays._obj_map +# define GC_last_heap_addr GC_arrays._last_heap_addr +# define GC_prev_heap_addr GC_arrays._prev_heap_addr +# define GC_words_allocd GC_arrays._words_allocd +# define GC_words_wasted GC_arrays._words_wasted +# define GC_large_free_bytes GC_arrays._large_free_bytes +# define GC_words_finalized GC_arrays._words_finalized +# define GC_non_gc_bytes_at_gc GC_arrays._non_gc_bytes_at_gc +# define GC_mem_freed GC_arrays._mem_freed +# define GC_mark_procs GC_arrays._mark_procs +# define GC_heapsize GC_arrays._heapsize +# define GC_max_heapsize GC_arrays._max_heapsize +# define GC_words_allocd_before_gc GC_arrays._words_allocd_before_gc +# define GC_heap_sects GC_arrays._heap_sects +# define GC_last_stack GC_arrays._last_stack +# ifdef USE_MUNMAP +# define GC_unmapped_bytes GC_arrays._unmapped_bytes +# endif +# ifdef MSWIN32 +# define GC_heap_bases GC_arrays._heap_bases +# endif +# define GC_static_roots GC_arrays._static_roots +# define GC_root_index GC_arrays._root_index +# define GC_excl_table GC_arrays._excl_table +# define GC_all_nils GC_arrays._all_nils +# define GC_top_index GC_arrays._top_index +# if defined(PROC_VDB) || defined(MPROTECT_VDB) +# define GC_grungy_pages GC_arrays._grungy_pages +# endif +# ifdef MPROTECT_VDB +# define GC_dirty_pages GC_arrays._dirty_pages +# endif +# ifdef PROC_VDB +# define GC_written_pages GC_arrays._written_pages +# endif +# ifdef GATHERSTATS +# define GC_composite_in_use GC_arrays._composite_in_use +# define GC_atomic_in_use GC_arrays._atomic_in_use +# endif +# ifdef MERGE_SIZES +# define GC_size_map GC_arrays._size_map +# endif + +# define beginGC_arrays ((ptr_t)(&GC_arrays)) +# define endGC_arrays (((ptr_t)(&GC_arrays)) + (sizeof GC_arrays)) + +/* Object kinds: */ +# define MAXOBJKINDS 16 + +extern struct obj_kind { + ptr_t *ok_freelist; /* Array of free listheaders for this kind of object */ + /* Point either to GC_arrays or to storage allocated */ + /* with GC_scratch_alloc. */ + struct hblk **ok_reclaim_list; + /* List headers for lists of blocks waiting to be */ + /* swept. */ + word ok_descriptor; /* Descriptor template for objects in this */ + /* block. */ + GC_bool ok_relocate_descr; + /* Add object size in bytes to descriptor */ + /* template to obtain descriptor. Otherwise */ + /* template is used as is. */ + GC_bool ok_init; /* Clear objects before putting them on the free list. */ +} GC_obj_kinds[MAXOBJKINDS]; + +# define endGC_obj_kinds (((ptr_t)(&GC_obj_kinds)) + (sizeof GC_obj_kinds)) + +# define end_gc_area ((ptr_t)endGC_arrays == (ptr_t)(&GC_obj_kinds) ? \ + endGC_obj_kinds : endGC_arrays) + +/* Predefined kinds: */ +# define PTRFREE 0 +# define NORMAL 1 +# define UNCOLLECTABLE 2 +# ifdef ATOMIC_UNCOLLECTABLE +# define AUNCOLLECTABLE 3 +# define STUBBORN 4 +# define IS_UNCOLLECTABLE(k) (((k) & ~1) == UNCOLLECTABLE) +# else +# define STUBBORN 3 +# define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE) +# endif + +extern int GC_n_kinds; + +GC_API word GC_fo_entries; + +extern word GC_n_heap_sects; /* Number of separately added heap */ + /* sections. */ + +extern word GC_page_size; + +# ifdef MSWIN32 +extern word GC_n_heap_bases; /* See GC_heap_bases. */ +# endif + +extern word GC_total_stack_black_listed; + /* Number of bytes on stack blacklist. */ + +extern word GC_black_list_spacing; + /* Average number of bytes between blacklisted */ + /* blocks. Approximate. */ + /* Counts only blocks that are */ + /* "stack-blacklisted", i.e. that are */ + /* problematic in the interior of an object. */ + +extern char * GC_invalid_map; + /* Pointer to the nowhere valid hblk map */ + /* Blocks pointing to this map are free. */ + +extern struct hblk * GC_hblkfreelist[]; + /* List of completely empty heap blocks */ + /* Linked through hb_next field of */ + /* header structure associated with */ + /* block. */ + +extern GC_bool GC_is_initialized; /* GC_init() has been run. */ + +extern GC_bool GC_objects_are_marked; /* There are marked objects in */ + /* the heap. */ + +#ifndef SMALL_CONFIG + extern GC_bool GC_incremental; + /* Using incremental/generational collection. */ +#else +# define GC_incremental TRUE + /* Hopefully allow optimizer to remove some code. */ +#endif + +extern GC_bool GC_dirty_maintained; + /* Dirty bits are being maintained, */ + /* either for incremental collection, */ + /* or to limit the root set. */ + +extern word GC_root_size; /* Total size of registered root sections */ + +extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */ + +extern ptr_t GC_least_plausible_heap_addr; +extern ptr_t GC_greatest_plausible_heap_addr; + /* Bounds on the heap. Guaranteed valid */ + /* Likely to include future heap expansion. */ + +/* Operations */ +# ifndef abs +# define abs(x) ((x) < 0? (-(x)) : (x)) +# endif + + +/* Marks are in a reserved area in */ +/* each heap block. Each word has one mark bit associated */ +/* with it. Only those corresponding to the beginning of an */ +/* object are used. */ + + +/* Mark bit operations */ + +/* + * Retrieve, set, clear the mark bit corresponding + * to the nth word in a given heap block. + * + * (Recall that bit n corresponds to object beginning at word n + * relative to the beginning of the block, including unused words) + */ + +# define mark_bit_from_hdr(hhdr,n) (((hhdr)->hb_marks[divWORDSZ(n)] \ + >> (modWORDSZ(n))) & (word)1) +# define set_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \ + |= (word)1 << modWORDSZ(n) + +# define clear_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \ + &= ~((word)1 << modWORDSZ(n)) + +/* Important internal collector routines */ + +ptr_t GC_approx_sp(); + +GC_bool GC_should_collect(); +#ifdef PRESERVE_LAST + GC_bool GC_in_last_heap_sect(/* ptr_t */); + /* In last added heap section? If so, avoid breaking up. */ +#endif +void GC_apply_to_all_blocks(/*fn, client_data*/); + /* Invoke fn(hbp, client_data) for each */ + /* allocated heap block. */ +struct hblk * GC_next_used_block(/* struct hblk * h */); + /* Return first in-use block >= h */ +struct hblk * GC_prev_block(/* struct hblk * h */); + /* Return last block <= h. Returned block */ + /* is managed by GC, but may or may not be in */ + /* use. */ +void GC_mark_init(); +void GC_clear_marks(); /* Clear mark bits for all heap objects. */ +void GC_invalidate_mark_state(); /* Tell the marker that marked */ + /* objects may point to unmarked */ + /* ones, and roots may point to */ + /* unmarked objects. */ + /* Reset mark stack. */ +void GC_mark_from_mark_stack(); /* Mark from everything on the mark stack. */ + /* Return after about one pages worth of */ + /* work. */ +GC_bool GC_mark_stack_empty(); +GC_bool GC_mark_some(/* cold_gc_frame */); + /* Perform about one pages worth of marking */ + /* work of whatever kind is needed. Returns */ + /* quickly if no collection is in progress. */ + /* Return TRUE if mark phase finished. */ +void GC_initiate_gc(); /* initiate collection. */ + /* If the mark state is invalid, this */ + /* becomes full colleection. Otherwise */ + /* it's partial. */ +void GC_push_all(/*b,t*/); /* Push everything in a range */ + /* onto mark stack. */ +void GC_push_dirty(/*b,t*/); /* Push all possibly changed */ + /* subintervals of [b,t) onto */ + /* mark stack. */ +#ifndef SMALL_CONFIG + void GC_push_conditional(/* ptr_t b, ptr_t t, GC_bool all*/); +#else +# define GC_push_conditional(b, t, all) GC_push_all(b, t) +#endif + /* Do either of the above, depending */ + /* on the third arg. */ +void GC_push_all_stack(/*b,t*/); /* As above, but consider */ + /* interior pointers as valid */ +void GC_push_all_eager(/*b,t*/); /* Same as GC_push_all_stack, but */ + /* ensures that stack is scanned */ + /* immediately, not just scheduled */ + /* for scanning. */ +#ifndef THREADS + void GC_push_all_stack_partially_eager(/* bottom, top, cold_gc_frame */); + /* Similar to GC_push_all_eager, but only the */ + /* part hotter than cold_gc_frame is scanned */ + /* immediately. Needed to endure that callee- */ + /* save registers are not missed. */ +#else + /* In the threads case, we push part of the current thread stack */ + /* with GC_push_all_eager when we push the registers. This gets the */ + /* callee-save registers that may disappear. The remainder of the */ + /* stacks are scheduled for scanning in *GC_push_other_roots, which */ + /* is thread-package-specific. */ +#endif +void GC_push_current_stack(/* ptr_t cold_gc_frame */); + /* Push enough of the current stack eagerly to */ + /* ensure that callee-save registers saved in */ + /* GC frames are scanned. */ + /* In the non-threads case, schedule entire */ + /* stack for scanning. */ +void GC_push_roots(/* GC_bool all, ptr_t cold_gc_frame */); + /* Push all or dirty roots. */ +extern void (*GC_push_other_roots)(); + /* Push system or application specific roots */ + /* onto the mark stack. In some environments */ + /* (e.g. threads environments) this is */ + /* predfined to be non-zero. A client supplied */ + /* replacement should also call the original */ + /* function. */ +extern void (*GC_start_call_back)(/* void */); + /* Called at start of full collections. */ + /* Not called if 0. Called with allocation */ + /* lock held. */ + /* 0 by default. */ +void GC_push_regs(); /* Push register contents onto mark stack. */ +void GC_remark(); /* Mark from all marked objects. Used */ + /* only if we had to drop something. */ +# if defined(MSWIN32) + void __cdecl GC_push_one(); +# else + void GC_push_one(/*p*/); /* If p points to an object, mark it */ + /* and push contents on the mark stack */ +# endif +void GC_push_one_checked(/*p*/); /* Ditto, omits plausibility test */ +void GC_push_marked(/* struct hblk h, hdr * hhdr */); + /* Push contents of all marked objects in h onto */ + /* mark stack. */ +#ifdef SMALL_CONFIG +# define GC_push_next_marked_dirty(h) GC_push_next_marked(h) +#else + struct hblk * GC_push_next_marked_dirty(/* h */); + /* Invoke GC_push_marked on next dirty block above h. */ + /* Return a pointer just past the end of this block. */ +#endif /* !SMALL_CONFIG */ +struct hblk * GC_push_next_marked(/* h */); + /* Ditto, but also mark from clean pages. */ +struct hblk * GC_push_next_marked_uncollectable(/* h */); + /* Ditto, but mark only from uncollectable pages. */ +GC_bool GC_stopped_mark(); /* Stop world and mark from all roots */ + /* and rescuers. */ +void GC_clear_hdr_marks(/* hhdr */); /* Clear the mark bits in a header */ +void GC_set_hdr_marks(/* hhdr */); /* Set the mark bits in a header */ +void GC_add_roots_inner(); +GC_bool GC_is_static_root(/* ptr_t p */); + /* Is the address p in one of the registered static */ + /* root sections? */ +void GC_register_dynamic_libraries(); + /* Add dynamic library data sections to the root set. */ + +/* Machine dependent startup routines */ +ptr_t GC_get_stack_base(); +void GC_register_data_segments(); + +/* Black listing: */ +void GC_bl_init(); +# ifndef ALL_INTERIOR_POINTERS + void GC_add_to_black_list_normal(/* bits, maybe source */); + /* Register bits as a possible future false */ + /* reference from the heap or static data */ +# ifdef PRINT_BLACK_LIST +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_normal(bits, source) +# else +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_normal(bits) +# endif +# else +# ifdef PRINT_BLACK_LIST +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_stack(bits, source) +# else +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_stack(bits) +# endif +# endif + +void GC_add_to_black_list_stack(/* bits, maybe source */); +struct hblk * GC_is_black_listed(/* h, len */); + /* If there are likely to be false references */ + /* to a block starting at h of the indicated */ + /* length, then return the next plausible */ + /* starting location for h that might avoid */ + /* these false references. */ +void GC_promote_black_lists(); + /* Declare an end to a black listing phase. */ +void GC_unpromote_black_lists(); + /* Approximately undo the effect of the above. */ + /* This actually loses some information, but */ + /* only in a reasonably safe way. */ +word GC_number_stack_black_listed(/*struct hblk *start, struct hblk *endp1 */); + /* Return the number of (stack) blacklisted */ + /* blocks in the range for statistical */ + /* purposes. */ + +ptr_t GC_scratch_alloc(/*bytes*/); + /* GC internal memory allocation for */ + /* small objects. Deallocation is not */ + /* possible. */ + +/* Heap block layout maps: */ +void GC_invalidate_map(/* hdr */); + /* Remove the object map associated */ + /* with the block. This identifies */ + /* the block as invalid to the mark */ + /* routines. */ +GC_bool GC_add_map_entry(/*sz*/); + /* Add a heap block map for objects of */ + /* size sz to obj_map. */ + /* Return FALSE on failure. */ +void GC_register_displacement_inner(/*offset*/); + /* Version of GC_register_displacement */ + /* that assumes lock is already held */ + /* and signals are already disabled. */ + +/* hblk allocation: */ +void GC_new_hblk(/*size_in_words, kind*/); + /* Allocate a new heap block, and build */ + /* a free list in it. */ +struct hblk * GC_allochblk(/*size_in_words, kind*/); + /* Allocate a heap block, clear it if */ + /* for composite objects, inform */ + /* the marker that block is valid */ + /* for objects of indicated size. */ + /* sz < 0 ==> atomic. */ +void GC_freehblk(); /* Deallocate a heap block and mark it */ + /* as invalid. */ + +/* Misc GC: */ +void GC_init_inner(); +GC_bool GC_expand_hp_inner(); +void GC_start_reclaim(/*abort_if_found*/); + /* Restore unmarked objects to free */ + /* lists, or (if abort_if_found is */ + /* TRUE) report them. */ + /* Sweeping of small object pages is */ + /* largely deferred. */ +void GC_continue_reclaim(/*size, kind*/); + /* Sweep pages of the given size and */ + /* kind, as long as possible, and */ + /* as long as the corr. free list is */ + /* empty. */ +void GC_reclaim_or_delete_all(); + /* Arrange for all reclaim lists to be */ + /* empty. Judiciously choose between */ + /* sweeping and discarding each page. */ +GC_bool GC_reclaim_all(/* GC_stop_func f*/); + /* Reclaim all blocks. Abort (in a */ + /* consistent state) if f returns TRUE. */ +GC_bool GC_block_empty(/* hhdr */); /* Block completely unmarked? */ +GC_bool GC_never_stop_func(); /* Returns FALSE. */ +GC_bool GC_try_to_collect_inner(/* GC_stop_func f */); + /* Collect; caller must have acquired */ + /* lock and disabled signals. */ + /* Collection is aborted if f returns */ + /* TRUE. Returns TRUE if it completes */ + /* successfully. */ +# define GC_gcollect_inner() \ + (void) GC_try_to_collect_inner(GC_never_stop_func) +void GC_finish_collection(); /* Finish collection. Mark bits are */ + /* consistent and lock is still held. */ +GC_bool GC_collect_or_expand(/* needed_blocks */); + /* Collect or expand heap in an attempt */ + /* make the indicated number of free */ + /* blocks available. Should be called */ + /* until the blocks are available or */ + /* until it fails by returning FALSE. */ +GC_API void GC_init(); /* Initialize collector. */ +void GC_collect_a_little_inner(/* int n */); + /* Do n units worth of garbage */ + /* collection work, if appropriate. */ + /* A unit is an amount appropriate for */ + /* HBLKSIZE bytes of allocation. */ +ptr_t GC_generic_malloc(/* bytes, kind */); + /* Allocate an object of the given */ + /* kind. By default, there are only */ + /* a few kinds: composite(pointerfree), */ + /* atomic, uncollectable, etc. */ + /* We claim it's possible for clever */ + /* client code that understands GC */ + /* internals to add more, e.g. to */ + /* communicate object layout info */ + /* to the collector. */ +ptr_t GC_generic_malloc_ignore_off_page(/* bytes, kind */); + /* As above, but pointers past the */ + /* first page of the resulting object */ + /* are ignored. */ +ptr_t GC_generic_malloc_inner(/* bytes, kind */); + /* Ditto, but I already hold lock, etc. */ +ptr_t GC_generic_malloc_words_small GC_PROTO((size_t words, int kind)); + /* As above, but size in units of words */ + /* Bypasses MERGE_SIZES. Assumes */ + /* words <= MAXOBJSZ. */ +ptr_t GC_generic_malloc_inner_ignore_off_page(/* bytes, kind */); + /* Allocate an object, where */ + /* the client guarantees that there */ + /* will always be a pointer to the */ + /* beginning of the object while the */ + /* object is live. */ +ptr_t GC_allocobj(/* sz_inn_words, kind */); + /* Make the indicated */ + /* free list nonempty, and return its */ + /* head. */ + +void GC_init_headers(); +GC_bool GC_install_header(/*h*/); + /* Install a header for block h. */ + /* Return FALSE on failure. */ +GC_bool GC_install_counts(/*h, sz*/); + /* Set up forwarding counts for block */ + /* h of size sz. */ + /* Return FALSE on failure. */ +void GC_remove_header(/*h*/); + /* Remove the header for block h. */ +void GC_remove_counts(/*h, sz*/); + /* Remove forwarding counts for h. */ +hdr * GC_find_header(/*p*/); /* Debugging only. */ + +void GC_finalize(); /* Perform all indicated finalization actions */ + /* on unmarked objects. */ + /* Unreachable finalizable objects are enqueued */ + /* for processing by GC_invoke_finalizers. */ + /* Invoked with lock. */ + +void GC_add_to_heap(/*p, bytes*/); + /* Add a HBLKSIZE aligned chunk to the heap. */ + +void GC_print_obj(/* ptr_t p */); + /* P points to somewhere inside an object with */ + /* debugging info. Print a human readable */ + /* description of the object to stderr. */ +extern void (*GC_check_heap)(); + /* Check that all objects in the heap with */ + /* debugging info are intact. Print */ + /* descriptions of any that are not. */ +extern void (*GC_print_heap_obj)(/* ptr_t p */); + /* If possible print s followed by a more */ + /* detailed description of the object */ + /* referred to by p. */ + +/* Memory unmapping: */ +#ifdef USE_MUNMAP + void GC_unmap_old(void); + void GC_merge_unmapped(void); + void GC_unmap(ptr_t start, word bytes); + void GC_remap(ptr_t start, word bytes); + void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2); +#endif + +/* Virtual dirty bit implementation: */ +/* Each implementation exports the following: */ +void GC_read_dirty(); /* Retrieve dirty bits. */ +GC_bool GC_page_was_dirty(/* struct hblk * h */); + /* Read retrieved dirty bits. */ +GC_bool GC_page_was_ever_dirty(/* struct hblk * h */); + /* Could the page contain valid heap pointers? */ +void GC_is_fresh(/* struct hblk * h, word number_of_blocks */); + /* Assert the region currently contains no */ + /* valid pointers. */ +void GC_write_hint(/* struct hblk * h */); + /* h is about to be written. */ +void GC_dirty_init(); + +/* Slow/general mark bit manipulation: */ +GC_API GC_bool GC_is_marked(); +void GC_clear_mark_bit(); +void GC_set_mark_bit(); + +/* Stubborn objects: */ +void GC_read_changed(); /* Analogous to GC_read_dirty */ +GC_bool GC_page_was_changed(/* h */); /* Analogous to GC_page_was_dirty */ +void GC_clean_changing_list(); /* Collect obsolete changing list entries */ +void GC_stubborn_init(); + +/* Debugging print routines: */ +void GC_print_block_list(); +void GC_print_hblkfreelist(); +void GC_print_heap_sects(); +void GC_print_static_roots(); +void GC_dump(); + +#ifdef KEEP_BACK_PTRS + void GC_store_back_pointer(ptr_t source, ptr_t dest); + void GC_marked_for_finalization(ptr_t dest); +# define GC_STORE_BACK_PTR(source, dest) GC_store_back_pointer(source, dest) +# define GC_MARKED_FOR_FINALIZATION(dest) GC_marked_for_finalization(dest) +#else +# define GC_STORE_BACK_PTR(source, dest) +# define GC_MARKED_FOR_FINALIZATION(dest) +#endif + +/* Make arguments appear live to compiler */ +# ifdef __WATCOMC__ + void GC_noop(void*, ...); +# else + GC_API void GC_noop(); +# endif + +void GC_noop1(/* word arg */); + +/* Logging and diagnostic output: */ +GC_API void GC_printf GC_PROTO((char * format, long, long, long, long, long, long)); + /* A version of printf that doesn't allocate, */ + /* is restricted to long arguments, and */ + /* (unfortunately) doesn't use varargs for */ + /* portability. Restricted to 6 args and */ + /* 1K total output length. */ + /* (We use sprintf. Hopefully that doesn't */ + /* allocate for long arguments.) */ +# define GC_printf0(f) GC_printf(f, 0l, 0l, 0l, 0l, 0l, 0l) +# define GC_printf1(f,a) GC_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l) +# define GC_printf2(f,a,b) GC_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l) +# define GC_printf3(f,a,b,c) GC_printf(f, (long)a, (long)b, (long)c, 0l, 0l, 0l) +# define GC_printf4(f,a,b,c,d) GC_printf(f, (long)a, (long)b, (long)c, \ + (long)d, 0l, 0l) +# define GC_printf5(f,a,b,c,d,e) GC_printf(f, (long)a, (long)b, (long)c, \ + (long)d, (long)e, 0l) +# define GC_printf6(f,a,b,c,d,e,g) GC_printf(f, (long)a, (long)b, (long)c, \ + (long)d, (long)e, (long)g) + +void GC_err_printf(/* format, a, b, c, d, e, f */); +# define GC_err_printf0(f) GC_err_puts(f) +# define GC_err_printf1(f,a) GC_err_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l) +# define GC_err_printf2(f,a,b) GC_err_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l) +# define GC_err_printf3(f,a,b,c) GC_err_printf(f, (long)a, (long)b, (long)c, \ + 0l, 0l, 0l) +# define GC_err_printf4(f,a,b,c,d) GC_err_printf(f, (long)a, (long)b, \ + (long)c, (long)d, 0l, 0l) +# define GC_err_printf5(f,a,b,c,d,e) GC_err_printf(f, (long)a, (long)b, \ + (long)c, (long)d, \ + (long)e, 0l) +# define GC_err_printf6(f,a,b,c,d,e,g) GC_err_printf(f, (long)a, (long)b, \ + (long)c, (long)d, \ + (long)e, (long)g) + /* Ditto, writes to stderr. */ + +void GC_err_puts(/* char *s */); + /* Write s to stderr, don't buffer, don't add */ + /* newlines, don't ... */ + + +# ifdef GC_ASSERTIONS +# define GC_ASSERT(expr) if(!(expr)) {\ + GC_err_printf2("Assertion failure: %s:%ld\n", \ + __FILE__, (unsigned long)__LINE__); \ + ABORT("assertion failure"); } +# else +# define GC_ASSERT(expr) +# endif + +# endif /* GC_PRIVATE_H */ diff --git a/support/gc/gc_private.h b/support/gc/gc_private.h new file mode 100644 index 00000000..3dd7c855 --- /dev/null +++ b/support/gc/gc_private.h @@ -0,0 +1 @@ +# include "gc_priv.h" diff --git a/support/gc/gc_typed.h b/support/gc/gc_typed.h new file mode 100644 index 00000000..e4a6b947 --- /dev/null +++ b/support/gc/gc_typed.h @@ -0,0 +1,91 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright 1996 Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* + * Some simple primitives for allocation with explicit type information. + * Facilities for dynamic type inference may be added later. + * Should be used only for extremely performance critical applications, + * or if conservative collector leakage is otherwise a problem (unlikely). + * Note that this is implemented completely separately from the rest + * of the collector, and is not linked in unless referenced. + * This does not currently support GC_DEBUG in any interesting way. + */ +/* Boehm, May 19, 1994 2:13 pm PDT */ + +#ifndef _GC_TYPED_H +# define _GC_TYPED_H +# ifndef _GC_H +# include "gc.h" +# endif + +typedef GC_word * GC_bitmap; + /* The least significant bit of the first word is one if */ + /* the first word in the object may be a pointer. */ + +# define GC_get_bit(bm, index) \ + (((bm)[divWORDSZ(index)] >> modWORDSZ(index)) & 1) +# define GC_set_bit(bm, index) \ + (bm)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index) + +typedef GC_word GC_descr; + +GC_API GC_descr GC_make_descriptor GC_PROTO((GC_bitmap bm, size_t len)); + /* Return a type descriptor for the object whose layout */ + /* is described by the argument. */ + /* The least significant bit of the first word is one */ + /* if the first word in the object may be a pointer. */ + /* The second argument specifies the number of */ + /* meaningful bits in the bitmap. The actual object */ + /* may be larger (but not smaller). Any additional */ + /* words in the object are assumed not to contain */ + /* pointers. */ + /* Returns a conservative approximation in the */ + /* (unlikely) case of insufficient memory to build */ + /* the descriptor. Calls to GC_make_descriptor */ + /* may consume some amount of a finite resource. This */ + /* is intended to be called once per type, not once */ + /* per allocation. */ + +GC_API GC_PTR GC_malloc_explicitly_typed + GC_PROTO((size_t size_in_bytes, GC_descr d)); + /* Allocate an object whose layout is described by d. */ + /* The resulting object MAY NOT BE PASSED TO REALLOC. */ + +GC_API GC_PTR GC_malloc_explicitly_typed_ignore_off_page + GC_PROTO((size_t size_in_bytes, GC_descr d)); + +GC_API GC_PTR GC_calloc_explicitly_typed + GC_PROTO((size_t nelements, + size_t element_size_in_bytes, + GC_descr d)); + /* Allocate an array of nelements elements, each of the */ + /* given size, and with the given descriptor. */ + /* The elemnt size must be a multiple of the byte */ + /* alignment required for pointers. E.g. on a 32-bit */ + /* machine with 16-bit aligned pointers, size_in_bytes */ + /* must be a multiple of 2. */ + +#ifdef GC_DEBUG +# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) GC_MALLOC(bytes) +# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) GC_MALLOC(n*bytes) +#else +# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) \ + GC_malloc_explicitly_typed(bytes, d) +# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) \ + GC_calloc_explicitly_typed(n, bytes, d) +#endif /* !GC_DEBUG */ + + +#endif /* _GC_TYPED_H */ + diff --git a/support/gc/gc_watcom.asm b/support/gc/gc_watcom.asm new file mode 100644 index 00000000..5131ab96 --- /dev/null +++ b/support/gc/gc_watcom.asm @@ -0,0 +1,51 @@ + + name gc_watcom + +.386p + + extrn _edata : byte ; end of DATA (start of BSS) + extrn _end : byte ; end of BSS (start of STACK) + extrn __nullarea : word + + extrn "C",_STACKLOW : dword + extrn "C",_STACKTOP : dword + + +DGROUP group _DATA + +_DATA segment dword public 'DATA' +_DATA ends + +_TEXT segment para public use32 'CODE' + assume cs:_TEXT, ds:DGROUP, ss:DGROUP + + public Get_DATASTART + align 4 +Get_DATASTART proc near + + mov eax,offset DGROUP:__nullarea + ret + +Get_DATASTART endp + + public Get_DATAEND + align 4 +Get_DATAEND proc near + + mov eax,offset DGROUP:_end + ret + +Get_DATAEND endp + + public Get_STACKBOTTOM + align 4 +Get_STACKBOTTOM proc near + + mov eax,_STACKTOP + ret + +Get_STACKBOTTOM endp + +_TEXT ends + + end diff --git a/support/gc/gcc_support.c b/support/gc/gcc_support.c new file mode 100644 index 00000000..e8a7b820 --- /dev/null +++ b/support/gc/gcc_support.c @@ -0,0 +1,516 @@ +/*************************************************************************** + +Interface between g++ and Boehm GC + + Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + + THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + + Permission is hereby granted to copy this code for any purpose, + provided the above notices are retained on all copies. + + Last modified on Sun Jul 16 23:21:14 PDT 1995 by ellis + +This module provides runtime support for implementing the +Ellis/Detlefs GC proposal, "Safe, Efficient Garbage Collection for +C++", within g++, using its -fgc-keyword extension. It defines +versions of __builtin_new, __builtin_new_gc, __builtin_vec_new, +__builtin_vec_new_gc, __builtin_delete, and __builtin_vec_delete that +invoke the Bohem GC. It also implements the WeakPointer.h interface. + +This module assumes the following configuration options of the Boehm GC: + + -DALL_INTERIOR_POINTERS + -DDONT_ADD_BYTE_AT_END + +This module adds its own required padding to the end of objects to +support C/C++ "one-past-the-object" pointer semantics. + +****************************************************************************/ + +#include +#include "gc.h" + +#if defined(__STDC__) +# define PROTO( args ) args +#else +# define PROTO( args ) () +# endif + +#define BITSPERBYTE 8 + /* What's the portable way to do this? */ + + +typedef void (*vfp) PROTO(( void )); +extern vfp __new_handler; +extern void __default_new_handler PROTO(( void )); + + +/* A destructor_proc is the compiler generated procedure representing a +C++ destructor. The "flag" argument is a hidden argument following some +compiler convention. */ + +typedef (*destructor_proc) PROTO(( void* this, int flag )); + + +/*************************************************************************** + +A BI_header is the header the compiler adds to the front of +new-allocated arrays of objects with destructors. The header is +padded out to a double, because that's what the compiler does to +ensure proper alignment of array elements on some architectures. + +int NUM_ARRAY_ELEMENTS (void* o) + returns the number of array elements for array object o. + +char* FIRST_ELEMENT_P (void* o) + returns the address of the first element of array object o. + +***************************************************************************/ + +typedef struct BI_header { + int nelts; + char padding [sizeof( double ) - sizeof( int )]; + /* Better way to do this? */ +} BI_header; + +#define NUM_ARRAY_ELEMENTS( o ) \ + (((BI_header*) o)->nelts) + +#define FIRST_ELEMENT_P( o ) \ + ((char*) o + sizeof( BI_header )) + + +/*************************************************************************** + +The __builtin_new routines add a descriptor word to the end of each +object. The descriptor serves two purposes. + +First, the descriptor acts as padding, implementing C/C++ pointer +semantics. C and C++ allow a valid array pointer to be incremented +one past the end of an object. The extra padding ensures that the +collector will recognize that such a pointer points to the object and +not the next object in memory. + +Second, the descriptor stores three extra pieces of information, +whether an object has a registered finalizer (destructor), whether it +may have any weak pointers referencing it, and for collectible arrays, +the element size of the array. The element size is required for the +array's finalizer to iterate through the elements of the array. (An +alternative design would have the compiler generate a finalizer +procedure for each different array type. But given the overhead of +finalization, there isn't any efficiency to be gained by that.) + +The descriptor must be added to non-collectible as well as collectible +objects, since the Ellis/Detlefs proposal allows "pointer to gc T" to +be assigned to a "pointer to T", which could then be deleted. Thus, +__builtin_delete must determine at runtime whether an object is +collectible, whether it has weak pointers referencing it, and whether +it may have a finalizer that needs unregistering. Though +GC_REGISTER_FINALIZER doesn't care if you ask it to unregister a +finalizer for an object that doesn't have one, it is a non-trivial +procedure that does a hash look-up, etc. The descriptor trades a +little extra space for a significant increase in time on the fast path +through delete. (A similar argument applies to +GC_UNREGISTER_DISAPPEARING_LINK). + +For non-array types, the space for the descriptor could be shrunk to a +single byte for storing the "has finalizer" flag. But this would save +space only on arrays of char (whose size is not a multiple of the word +size) and structs whose largest member is less than a word in size +(very infrequent). And it would require that programmers actually +remember to call "delete[]" instead of "delete" (which they should, +but there are probably lots of buggy programs out there). For the +moment, the space savings seems not worthwhile, especially considering +that the Boehm GC is already quite space competitive with other +malloc's. + + +Given a pointer o to the base of an object: + +Descriptor* DESCRIPTOR (void* o) + returns a pointer to the descriptor for o. + +The implementation of descriptors relies on the fact that the GC +implementation allocates objects in units of the machine's natural +word size (e.g. 32 bits on a SPARC, 64 bits on an Alpha). + +**************************************************************************/ + +typedef struct Descriptor { + unsigned has_weak_pointers: 1; + unsigned has_finalizer: 1; + unsigned element_size: BITSPERBYTE * sizeof( unsigned ) - 2; +} Descriptor; + +#define DESCRIPTOR( o ) \ + ((Descriptor*) ((char*)(o) + GC_size( o ) - sizeof( Descriptor ))) + + +/************************************************************************** + +Implementations of global operator new() and operator delete() + +***************************************************************************/ + + +void* __builtin_new( size ) + size_t size; + /* + For non-gc non-array types, the compiler generates calls to + __builtin_new, which allocates non-collected storage via + GC_MALLOC_UNCOLLECTABLE. This ensures that the non-collected + storage will be part of the collector's root set, required by the + Ellis/Detlefs semantics. */ +{ + vfp handler = __new_handler ? __new_handler : __default_new_handler; + + while (1) { + void* o = GC_MALLOC_UNCOLLECTABLE( size + sizeof( Descriptor ) ); + if (o != 0) return o; + (*handler) ();}} + + +void* __builtin_vec_new( size ) + size_t size; + /* + For non-gc array types, the compiler generates calls to + __builtin_vec_new. */ +{ + return __builtin_new( size );} + + +void* __builtin_new_gc( size ) + size_t size; + /* + For gc non-array types, the compiler generates calls to + __builtin_new_gc, which allocates collected storage via + GC_MALLOC. */ +{ + vfp handler = __new_handler ? __new_handler : __default_new_handler; + + while (1) { + void* o = GC_MALLOC( size + sizeof( Descriptor ) ); + if (o != 0) return o; + (*handler) ();}} + + +void* __builtin_new_gc_a( size ) + size_t size; + /* + For non-pointer-containing gc non-array types, the compiler + generates calls to __builtin_new_gc_a, which allocates collected + storage via GC_MALLOC_ATOMIC. */ +{ + vfp handler = __new_handler ? __new_handler : __default_new_handler; + + while (1) { + void* o = GC_MALLOC_ATOMIC( size + sizeof( Descriptor ) ); + if (o != 0) return o; + (*handler) ();}} + + +void* __builtin_vec_new_gc( size ) + size_t size; + /* + For gc array types, the compiler generates calls to + __builtin_vec_new_gc. */ +{ + return __builtin_new_gc( size );} + + +void* __builtin_vec_new_gc_a( size ) + size_t size; + /* + For non-pointer-containing gc array types, the compiler generates + calls to __builtin_vec_new_gc_a. */ +{ + return __builtin_new_gc_a( size );} + + +static void call_destructor( o, data ) + void* o; + void* data; + /* + call_destructor is the GC finalizer proc registered for non-array + gc objects with destructors. Its client data is the destructor + proc, which it calls with the magic integer 2, a special flag + obeying the compiler convention for destructors. */ +{ + ((destructor_proc) data)( o, 2 );} + + +void* __builtin_new_gc_dtor( o, d ) + void* o; + destructor_proc d; + /* + The compiler generates a call to __builtin_new_gc_dtor to register + the destructor "d" of a non-array gc object "o" as a GC finalizer. + The destructor is registered via + GC_REGISTER_FINALIZER_IGNORE_SELF, which causes the collector to + ignore pointers from the object to itself when determining when + the object can be finalized. This is necessary due to the self + pointers used in the internal representation of multiply-inherited + objects. */ +{ + Descriptor* desc = DESCRIPTOR( o ); + + GC_REGISTER_FINALIZER_IGNORE_SELF( o, call_destructor, d, 0, 0 ); + desc->has_finalizer = 1;} + + +static void call_array_destructor( o, data ) + void* o; + void* data; + /* + call_array_destructor is the GC finalizer proc registered for gc + array objects whose elements have destructors. Its client data is + the destructor proc. It iterates through the elements of the + array in reverse order, calling the destructor on each. */ +{ + int num = NUM_ARRAY_ELEMENTS( o ); + Descriptor* desc = DESCRIPTOR( o ); + size_t size = desc->element_size; + char* first_p = FIRST_ELEMENT_P( o ); + char* p = first_p + (num - 1) * size; + + if (num > 0) { + while (1) { + ((destructor_proc) data)( p, 2 ); + if (p == first_p) break; + p -= size;}}} + + +void* __builtin_vec_new_gc_dtor( first_elem, d, element_size ) + void* first_elem; + destructor_proc d; + size_t element_size; + /* + The compiler generates a call to __builtin_vec_new_gc_dtor to + register the destructor "d" of a gc array object as a GC + finalizer. "first_elem" points to the first element of the array, + *not* the beginning of the object (this makes the generated call + to this function smaller). The elements of the array are of size + "element_size". The destructor is registered as in + _builtin_new_gc_dtor. */ +{ + void* o = (char*) first_elem - sizeof( BI_header ); + Descriptor* desc = DESCRIPTOR( o ); + + GC_REGISTER_FINALIZER_IGNORE_SELF( o, call_array_destructor, d, 0, 0 ); + desc->element_size = element_size; + desc->has_finalizer = 1;} + + +void __builtin_delete( o ) + void* o; + /* + The compiler generates calls to __builtin_delete for operator + delete(). The GC currently requires that any registered + finalizers be unregistered before explicitly freeing an object. + If the object has any weak pointers referencing it, we can't + actually free it now. */ +{ + if (o != 0) { + Descriptor* desc = DESCRIPTOR( o ); + if (desc->has_finalizer) GC_REGISTER_FINALIZER( o, 0, 0, 0, 0 ); + if (! desc->has_weak_pointers) GC_FREE( o );}} + + +void __builtin_vec_delete( o ) + void* o; + /* + The compiler generates calls to __builitn_vec_delete for operator + delete[](). */ +{ + __builtin_delete( o );} + + +/************************************************************************** + +Implementations of the template class WeakPointer from WeakPointer.h + +***************************************************************************/ + +typedef struct WeakPointer { + void* pointer; +} WeakPointer; + + +void* _WeakPointer_New( t ) + void* t; +{ + if (t == 0) { + return 0;} + else { + void* base = GC_base( t ); + WeakPointer* wp = + (WeakPointer*) GC_MALLOC_ATOMIC( sizeof( WeakPointer ) ); + Descriptor* desc = DESCRIPTOR( base ); + + wp->pointer = t; + desc->has_weak_pointers = 1; + GC_general_register_disappearing_link( &wp->pointer, base ); + return wp;}} + + +static void* PointerWithLock( wp ) + WeakPointer* wp; +{ + if (wp == 0 || wp->pointer == 0) { + return 0;} + else { + return (void*) wp->pointer;}} + + +void* _WeakPointer_Pointer( wp ) + WeakPointer* wp; +{ + return (void*) GC_call_with_alloc_lock( PointerWithLock, wp );} + + +typedef struct EqualClosure { + WeakPointer* wp1; + WeakPointer* wp2; +} EqualClosure; + + +static void* EqualWithLock( ec ) + EqualClosure* ec; +{ + if (ec->wp1 == 0 || ec->wp2 == 0) { + return (void*) (ec->wp1 == ec->wp2);} + else { + return (void*) (ec->wp1->pointer == ec->wp2->pointer);}} + + +int _WeakPointer_Equal( wp1, wp2 ) + WeakPointer* wp1; + WeakPointer* wp2; +{ + EqualClosure ec; + + ec.wp1 = wp1; + ec.wp2 = wp2; + return (int) GC_call_with_alloc_lock( EqualWithLock, &ec );} + + +int _WeakPointer_Hash( wp ) + WeakPointer* wp; +{ + return (int) _WeakPointer_Pointer( wp );} + + +/************************************************************************** + +Implementations of the template class CleanUp from WeakPointer.h + +***************************************************************************/ + +typedef struct Closure { + void (*c) PROTO(( void* d, void* t )); + ptrdiff_t t_offset; + void* d; +} Closure; + + +static void _CleanUp_CallClosure( obj, data ) + void* obj; + void* data; +{ + Closure* closure = (Closure*) data; + closure->c( closure->d, (char*) obj + closure->t_offset );} + + +void _CleanUp_Set( t, c, d ) + void* t; + void (*c) PROTO(( void* d, void* t )); + void* d; +{ + void* base = GC_base( t ); + Descriptor* desc = DESCRIPTOR( t ); + + if (c == 0) { + GC_REGISTER_FINALIZER_IGNORE_SELF( base, 0, 0, 0, 0 ); + desc->has_finalizer = 0;} + else { + Closure* closure = (Closure*) GC_MALLOC( sizeof( Closure ) ); + closure->c = c; + closure->t_offset = (char*) t - (char*) base; + closure->d = d; + GC_REGISTER_FINALIZER_IGNORE_SELF( base, _CleanUp_CallClosure, + closure, 0, 0 ); + desc->has_finalizer = 1;}} + + +void _CleanUp_Call( t ) + void* t; +{ + /* ? Aren't we supposed to deactivate weak pointers to t too? + Why? */ + void* base = GC_base( t ); + void* d; + GC_finalization_proc f; + + GC_REGISTER_FINALIZER( base, 0, 0, &f, &d ); + f( base, d );} + + +typedef struct QueueElem { + void* o; + GC_finalization_proc f; + void* d; + struct QueueElem* next; +} QueueElem; + + +void* _CleanUp_Queue_NewHead() +{ + return GC_MALLOC( sizeof( QueueElem ) );} + + +static void _CleanUp_Queue_Enqueue( obj, data ) + void* obj; + void* data; +{ + QueueElem* q = (QueueElem*) data; + QueueElem* head = q->next; + + q->o = obj; + q->next = head->next; + head->next = q;} + + +void _CleanUp_Queue_Set( h, t ) + void* h; + void* t; +{ + QueueElem* head = (QueueElem*) h; + void* base = GC_base( t ); + void* d; + GC_finalization_proc f; + QueueElem* q = (QueueElem*) GC_MALLOC( sizeof( QueueElem ) ); + + GC_REGISTER_FINALIZER( base, _CleanUp_Queue_Enqueue, q, &f, &d ); + q->f = f; + q->d = d; + q->next = head;} + + +int _CleanUp_Queue_Call( h ) + void* h; +{ + QueueElem* head = (QueueElem*) h; + QueueElem* q = head->next; + + if (q == 0) { + return 0;} + else { + head->next = q->next; + q->next = 0; + if (q->f != 0) q->f( q->o, q->d ); + return 1;}} + + + diff --git a/support/gc/gcconfig.h b/support/gc/gcconfig.h new file mode 100644 index 00000000..c9017d37 --- /dev/null +++ b/support/gc/gcconfig.h @@ -0,0 +1,1099 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#ifndef CONFIG_H + +# define CONFIG_H + +/* Machine dependent parameters. Some tuning parameters can be found */ +/* near the top of gc_private.h. */ + +/* Machine specific parts contributed by various people. See README file. */ + +/* First a unified test for Linux: */ +# if defined(linux) || defined(__linux__) +# define LINUX +# endif + +/* Determine the machine type: */ +# if defined(sun) && defined(mc68000) +# define M68K +# define SUNOS4 +# define mach_type_known +# endif +# if defined(hp9000s300) +# define M68K +# define HP +# define mach_type_known +# endif +# if defined(__OpenBSD__) && defined(m68k) +# define M68K +# define OPENBSD +# define mach_type_known +# endif +# if defined(__OpenBSD__) && defined(__sparc__) +# define SPARC +# define OPENBSD +# define mach_type_known +# endif +# if defined(__NetBSD__) && defined(m68k) +# define M68K +# define NETBSD +# define mach_type_known +# endif +# if defined(vax) +# define VAX +# ifdef ultrix +# define ULTRIX +# else +# define BSD +# endif +# define mach_type_known +# endif +# if defined(mips) || defined(__mips) +# define MIPS +# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) +# define ULTRIX +# else +# if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__) +# define IRIX5 /* or IRIX 6.X */ +# else +# define RISCOS /* or IRIX 4.X */ +# endif +# endif +# define mach_type_known +# endif +# if defined(sequent) && defined(i386) +# define I386 +# define SEQUENT +# define mach_type_known +# endif +# if defined(sun) && defined(i386) +# define I386 +# define SUNOS5 +# define mach_type_known +# endif +# if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__) +# define I386 +# define OS2 +# define mach_type_known +# endif +# if defined(ibm032) +# define RT +# define mach_type_known +# endif +# if defined(sun) && (defined(sparc) || defined(__sparc)) +# define SPARC + /* Test for SunOS 5.x */ +# include +# ifdef ECHRNG +# define SUNOS5 +# else +# define SUNOS4 +# endif +# define mach_type_known +# endif +# if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \ + && !defined(__OpenBSD__) +# define SPARC +# define DRSNX +# define mach_type_known +# endif +# if defined(_IBMR2) +# define RS6000 +# define mach_type_known +# endif +# if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386) + /* The above test may need refinement */ +# define I386 +# if defined(_SCO_ELF) +# define SCO_ELF +# else +# define SCO +# endif +# define mach_type_known +# endif +# if defined(_AUX_SOURCE) +# define M68K +# define SYSV +# define mach_type_known +# endif +# if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) \ + || defined(hppa) || defined(__hppa__) +# define HP_PA +# define mach_type_known +# endif +# if defined(LINUX) && (defined(i386) || defined(__i386__)) +# define I386 +# define mach_type_known +# endif +# if defined(LINUX) && defined(powerpc) +# define POWERPC +# define mach_type_known +# endif +# if defined(LINUX) && defined(__mc68000__) +# define M68K +# define mach_type_known +# endif +# if defined(LINUX) && defined(sparc) +# define SPARC +# define mach_type_known +# endif +# if defined(__alpha) || defined(__alpha__) +# define ALPHA +# if !defined(LINUX) +# define OSF1 /* a.k.a Digital Unix */ +# endif +# define mach_type_known +# endif +# if defined(_AMIGA) && !defined(AMIGA) +# define AMIGA +# endif +# ifdef AMIGA +# define M68K +# define mach_type_known +# endif +# if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc) +# define M68K +# define MACOS +# define mach_type_known +# endif +# if defined(__MWERKS__) && defined(__powerc) +# define POWERPC +# define MACOS +# define mach_type_known +# endif +# if defined(macosx) +# define MACOSX +# define POWERPC +# define mach_type_known +# endif +# if defined(NeXT) && defined(mc68000) +# define M68K +# define NEXT +# define mach_type_known +# endif +# if defined(NeXT) && defined(i386) +# define I386 +# define NEXT +# define mach_type_known +# endif +# if defined(__OpenBSD__) && defined(i386) +# define I386 +# define OPENBSD +# define mach_type_known +# endif +# if defined(__FreeBSD__) && defined(i386) +# define I386 +# define FREEBSD +# define mach_type_known +# endif +# if defined(__NetBSD__) && defined(i386) +# define I386 +# define NETBSD +# define mach_type_known +# endif +# if defined(bsdi) && defined(i386) +# define I386 +# define BSDI +# define mach_type_known +# endif +# if !defined(mach_type_known) && defined(__386BSD__) +# define I386 +# define THREE86BSD +# define mach_type_known +# endif +# if defined(_CX_UX) && defined(_M88K) +# define M88K +# define CX_UX +# define mach_type_known +# endif +# if defined(DGUX) +# define M88K + /* DGUX defined */ +# define mach_type_known +# endif +# if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \ + || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__) +# define I386 +# define MSWIN32 /* or Win32s */ +# define mach_type_known +# endif +# if defined(__DJGPP__) +# define I386 +# ifndef DJGPP +# define DJGPP /* MSDOS running the DJGPP port of GCC */ +# endif +# define mach_type_known +# endif +# if defined(__CYGWIN32__) || defined(__CYGWIN__) +# define I386 +# define CYGWIN32 +# define mach_type_known +# endif +# if defined(__BORLANDC__) +# define I386 +# define MSWIN32 +# define mach_type_known +# endif +# if defined(_UTS) && !defined(mach_type_known) +# define S370 +# define UTS4 +# define mach_type_known +# endif +/* Ivan Demakov */ +# if defined(__WATCOMC__) && defined(__386__) +# define I386 +# if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW) +# if defined(__OS2__) +# define OS2 +# else +# if defined(__WINDOWS_386__) || defined(__NT__) +# define MSWIN32 +# else +# define DOS4GW +# endif +# endif +# endif +# define mach_type_known +# endif + +/* Feel free to add more clauses here */ + +/* Or manually define the machine type here. A machine type is */ +/* characterized by the architecture. Some */ +/* machine types are further subdivided by OS. */ +/* the macros ULTRIX, RISCOS, and BSD to distinguish. */ +/* Note that SGI IRIX is treated identically to RISCOS. */ +/* SYSV on an M68K actually means A/UX. */ +/* The distinction in these cases is usually the stack starting address */ +# ifndef mach_type_known + --> unknown machine type +# endif + /* Mapping is: M68K ==> Motorola 680X0 */ + /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */ + /* MACOS and AMIGA variants) */ + /* I386 ==> Intel 386 */ + /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */ + /* FREEBSD, THREE86BSD, MSWIN32, */ + /* BSDI,SUNOS5, NEXT, other variants) */ + /* NS32K ==> Encore Multimax */ + /* MIPS ==> R2000 or R3000 */ + /* (RISCOS, ULTRIX variants) */ + /* VAX ==> DEC VAX */ + /* (BSD, ULTRIX variants) */ + /* RS6000 ==> IBM RS/6000 AIX3.X */ + /* RT ==> IBM PC/RT */ + /* HP_PA ==> HP9000/700 & /800 */ + /* HP/UX */ + /* SPARC ==> SPARC under SunOS */ + /* (SUNOS4, SUNOS5, */ + /* DRSNX variants) */ + /* ALPHA ==> DEC Alpha */ + /* (OSF1 and LINUX variants) */ + /* M88K ==> Motorola 88XX0 */ + /* (CX_UX and DGUX) */ + /* S370 ==> 370-like machine */ + /* running Amdahl UTS4 */ + + +/* + * For each architecture and OS, the following need to be defined: + * + * CPP_WORD_SZ is a simple integer constant representing the word size. + * in bits. We assume byte addressibility, where a byte has 8 bits. + * We also assume CPP_WORD_SZ is either 32 or 64. + * (We care about the length of pointers, not hardware + * bus widths. Thus a 64 bit processor with a C compiler that uses + * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.) + * + * MACH_TYPE is a string representation of the machine type. + * OS_TYPE is analogous for the OS. + * + * ALIGNMENT is the largest N, such that + * all pointer are guaranteed to be aligned on N byte boundaries. + * defining it to be 1 will always work, but perform poorly. + * + * DATASTART is the beginning of the data segment. + * On UNIX systems, the collector will scan the area between DATASTART + * and DATAEND for root pointers. + * + * DATAEND, if not &end. + * + * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice + * the pointer size. + * + * STACKBOTTOM is the cool end of the stack, which is usually the + * highest address in the stack. + * Under PCR or OS/2, we have other ways of finding thread stacks. + * For each machine, the following should: + * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and + * 2) define exactly one of + * STACKBOTTOM (should be defined to be an expression) + * HEURISTIC1 + * HEURISTIC2 + * If either of the last two macros are defined, then STACKBOTTOM is computed + * during collector startup using one of the following two heuristics: + * HEURISTIC1: Take an address inside GC_init's frame, and round it up to + * the next multiple of STACK_GRAN. + * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly + * in small steps (decrement if STACK_GROWS_UP), and read the value + * at each location. Remember the value when the first + * Segmentation violation or Bus error is signalled. Round that + * to the nearest plausible page boundary, and use that instead + * of STACKBOTTOM. + * + * If no expression for STACKBOTTOM can be found, and neither of the above + * heuristics are usable, the collector can still be used with all of the above + * undefined, provided one of the following is done: + * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s) + * without reference to STACKBOTTOM. This is appropriate for use in + * conjunction with thread packages, since there will be multiple stacks. + * (Allocating thread stacks in the heap, and treating them as ordinary + * heap data objects is also possible as a last resort. However, this is + * likely to introduce significant amounts of excess storage retention + * unless the dead parts of the thread stacks are periodically cleared.) + * 2) Client code may set GC_stackbottom before calling any GC_ routines. + * If the author of the client code controls the main program, this is + * easily accomplished by introducing a new main program, setting + * GC_stackbottom to the address of a local variable, and then calling + * the original main program. The new main program would read something + * like: + * + * # include "gc_private.h" + * + * main(argc, argv, envp) + * int argc; + * char **argv, **envp; + * { + * int dummy; + * + * GC_stackbottom = (ptr_t)(&dummy); + * return(real_main(argc, argv, envp)); + * } + * + * + * Each architecture may also define the style of virtual dirty bit + * implementation to be used: + * MPROTECT_VDB: Write protect the heap and catch faults. + * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits. + * + * An architecture may define DYNAMIC_LOADING if dynamic_load.c + * defined GC_register_dynamic_libraries() for the architecture. + */ + + +# define STACK_GRAN 0x1000000 +# ifdef M68K +# define MACH_TYPE "M68K" +# define ALIGNMENT 2 +# ifdef OPENBSD +# define OS_TYPE "OPENBSD" +# define HEURISTIC2 + extern char etext; +# define DATASTART ((ptr_t)(&etext)) +# endif +# ifdef NETBSD +# define OS_TYPE "NETBSD" +# define HEURISTIC2 + extern char etext; +# define DATASTART ((ptr_t)(&etext)) +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# define STACKBOTTOM ((ptr_t)0xf0000000) +# define MPROTECT_VDB +# ifdef __ELF__ +# define DYNAMIC_LOADING + extern char **__environ; +# define DATASTART ((ptr_t)(&__environ)) + /* hideous kludge: __environ is the first */ + /* word in crt0.o, and delimits the start */ + /* of the data segment, no matter which */ + /* ld options were passed through. */ + /* We could use _etext instead, but that */ + /* would include .rodata, which may */ + /* contain large read-only data tables */ + /* that we'd rather not scan. */ + extern int _end; +# define DATAEND (&_end) +# else + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# endif +# endif +# ifdef SUNOS4 +# define OS_TYPE "SUNOS4" + extern char etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff)) +# define HEURISTIC1 /* differs */ +# define DYNAMIC_LOADING +# endif +# ifdef HP +# define OS_TYPE "HP" + extern char etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# define STACKBOTTOM ((ptr_t) 0xffeffffc) + /* empirically determined. seems to work. */ +# include +# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) +# endif +# ifdef SYSV +# define OS_TYPE "SYSV" + extern etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \ + & ~0x3fffff) \ + +((word)&etext & 0x1fff)) + /* This only works for shared-text binaries with magic number 0413. + The other sorts of SysV binaries put the data at the end of the text, + in which case the default of &etext would work. Unfortunately, + handling both would require having the magic-number available. + -- Parag + */ +# define STACKBOTTOM ((ptr_t)0xFFFFFFFE) + /* The stack starts at the top of memory, but */ + /* 0x0 cannot be used as setjump_test complains */ + /* that the stack direction is incorrect. Two */ + /* bytes down from 0x0 should be safe enough. */ + /* --Parag */ +# include +# define GETPAGESIZE() PAGESIZE /* Is this still right? */ +# endif +# ifdef AMIGA +# define OS_TYPE "AMIGA" + /* STACKBOTTOM and DATASTART handled specially */ + /* in os_dep.c */ +# define DATAEND /* not needed */ +# define GETPAGESIZE() 4096 +# endif +# ifdef MACOS +# ifndef __LOWMEM__ +# include +# endif +# define OS_TYPE "MACOS" + /* see os_dep.c for details of global data segments. */ +# define STACKBOTTOM ((ptr_t) LMGetCurStackBase()) +# define DATAEND /* not needed */ +# define GETPAGESIZE() 4096 +# endif +# ifdef NEXT +# define OS_TYPE "NEXT" +# define DATASTART ((ptr_t) get_etext()) +# define STACKBOTTOM ((ptr_t) 0x4000000) +# define DATAEND /* not needed */ +# endif +# endif + +# ifdef POWERPC +# define MACH_TYPE "POWERPC" +# ifdef MACOS +# define ALIGNMENT 2 /* Still necessary? Could it be 4? */ +# ifndef __LOWMEM__ +# include +# endif +# define OS_TYPE "MACOS" + /* see os_dep.c for details of global data segments. */ +# define STACKBOTTOM ((ptr_t) LMGetCurStackBase()) +# define DATAEND /* not needed */ +# endif +# ifdef LINUX +# define ALIGNMENT 4 /* Guess. Can someone verify? */ + /* This was 2, but that didn't sound right. */ +# define OS_TYPE "LINUX" +# define HEURISTIC1 +# undef STACK_GRAN +# define STACK_GRAN 0x10000000 + /* Stack usually starts at 0x80000000 */ +# define DATASTART GC_data_start + extern int _end; +# define DATAEND (&_end) +# endif +# ifdef MACOSX +# define ALIGNMENT 4 +# define OS_TYPE "MACOSX" +# define DATASTART ((ptr_t) get_etext()) +# define STACKBOTTOM ((ptr_t) 0xc0000000) +# define DATAEND /* not needed */ +# endif +# endif + +# ifdef VAX +# define MACH_TYPE "VAX" +# define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */ + extern char etext; +# define DATASTART ((ptr_t)(&etext)) +# ifdef BSD +# define OS_TYPE "BSD" +# define HEURISTIC1 + /* HEURISTIC2 may be OK, but it's hard to test. */ +# endif +# ifdef ULTRIX +# define OS_TYPE "ULTRIX" +# define STACKBOTTOM ((ptr_t) 0x7fffc800) +# endif +# endif + +# ifdef RT +# define MACH_TYPE "RT" +# define ALIGNMENT 4 +# define DATASTART ((ptr_t) 0x10000000) +# define STACKBOTTOM ((ptr_t) 0x1fffd800) +# endif + +# ifdef SPARC +# define MACH_TYPE "SPARC" +# define ALIGNMENT 4 /* Required by hardware */ +# define ALIGN_DOUBLE + extern int etext; +# ifdef SUNOS5 +# define OS_TYPE "SUNOS5" + extern int _etext; + extern int _end; + extern char * GC_SysVGetDataStart(); +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext) +# define DATAEND (&_end) +# ifndef USE_MMAP +# define USE_MMAP +# endif +# ifdef USE_MMAP +# define HEAP_START (ptr_t)0x40000000 +# else +# define HEAP_START DATAEND +# endif +# define PROC_VDB +/* HEURISTIC1 reportedly no longer works under 2.7. Thus we */ +/* switched to HEURISTIC2, eventhough it creates some debugging */ +/* issues. */ +# define HEURISTIC2 +# include +# define GETPAGESIZE() sysconf(_SC_PAGESIZE) + /* getpagesize() appeared to be missing from at least one */ + /* Solaris 5.4 installation. Weird. */ +# define DYNAMIC_LOADING +# endif +# ifdef SUNOS4 +# define OS_TYPE "SUNOS4" + /* [If you have a weak stomach, don't read this.] */ + /* We would like to use: */ +/* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */ + /* This fails occasionally, due to an ancient, but very */ + /* persistent ld bug. &etext is set 32 bytes too high. */ + /* We instead read the text segment size from the a.out */ + /* header, which happens to be mapped into our address space */ + /* at the start of the text segment. The detective work here */ + /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */ + /* Serpette of INRIA. */ + /* This assumes ZMAGIC, i.e. demand-loadable executables. */ +# define TEXTSTART 0x2000 +# define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART)) +# define MPROTECT_VDB +# define HEURISTIC1 +# define DYNAMIC_LOADING +# endif +# ifdef DRSNX +# define CPP_WORDSZ 32 +# define OS_TYPE "DRSNX" + extern char * GC_SysVGetDataStart(); + extern int etext; +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext) +# define MPROTECT_VDB +# define STACKBOTTOM ((ptr_t) 0xdfff0000) +# define DYNAMIC_LOADING +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# ifdef __ELF__ +# define DATASTART GC_data_start +# define DYNAMIC_LOADING +# else + Linux Sparc non elf ? +# endif + extern int _end; +# define DATAEND (&_end) +# define SVR4 +# define STACKBOTTOM ((ptr_t) 0xf0000000) +# endif +# ifdef OPENBSD +# define OS_TYPE "OPENBSD" +# define STACKBOTTOM ((ptr_t) 0xf8000000) +# define DATASTART ((ptr_t)(&etext)) +# endif +# endif + +# ifdef I386 +# define MACH_TYPE "I386" +# define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */ + /* except Borland. The -a4 option fixes */ + /* Borland. */ + /* Ivan Demakov: For Watcom the option is -zp4. */ +# ifndef SMALL_CONFIG +# define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */ + /* improvement on Pentiums. */ +# endif +# ifdef SEQUENT +# define OS_TYPE "SEQUENT" + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# define STACKBOTTOM ((ptr_t) 0x3ffff000) +# endif +# ifdef SUNOS5 +# define OS_TYPE "SUNOS5" + extern int etext, _start; + extern char * GC_SysVGetDataStart(); +# define DATASTART GC_SysVGetDataStart(0x1000, &etext) +# define STACKBOTTOM ((ptr_t)(&_start)) +/** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */ +/*# define PROC_VDB*/ +# define DYNAMIC_LOADING +# ifndef USE_MMAP +# define USE_MMAP +# endif +# ifdef USE_MMAP +# define HEAP_START (ptr_t)0x40000000 +# else +# define HEAP_START DATAEND +# endif +# endif +# ifdef SCO +# define OS_TYPE "SCO" + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \ + & ~0x3fffff) \ + +((word)&etext & 0xfff)) +# define STACKBOTTOM ((ptr_t) 0x7ffffffc) +# endif +# ifdef SCO_ELF +# define OS_TYPE "SCO_ELF" + extern int etext; +# define DATASTART ((ptr_t)(&etext)) +# define STACKBOTTOM ((ptr_t) 0x08048000) +# define DYNAMIC_LOADING +# define ELF_CLASS ELFCLASS32 +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# define HEURISTIC1 +# undef STACK_GRAN +# define STACK_GRAN 0x10000000 + /* STACKBOTTOM is usually 0xc0000000, but this changes with */ + /* different kernel configurations. In particular, systems */ + /* with 2GB physical memory will usually move the user */ + /* address space limit, and hence initial SP to 0x80000000. */ +# if !defined(LINUX_THREADS) || !defined(REDIRECT_MALLOC) +# define MPROTECT_VDB +# else + /* We seem to get random errors in incremental mode, */ + /* possibly because Linux threads is itself a malloc client */ + /* and can't deal with the signals. */ +# endif +# ifdef __ELF__ +# define DYNAMIC_LOADING +# ifdef UNDEFINED /* includes ro data */ + extern int _etext; +# define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff)) +# endif +# include +# if defined(__GLIBC__) && __GLIBC__ >= 2 + extern int __data_start; +# define DATASTART ((ptr_t)(&__data_start)) +# else + extern char **__environ; +# define DATASTART ((ptr_t)(&__environ)) + /* hideous kludge: __environ is the first */ + /* word in crt0.o, and delimits the start */ + /* of the data segment, no matter which */ + /* ld options were passed through. */ + /* We could use _etext instead, but that */ + /* would include .rodata, which may */ + /* contain large read-only data tables */ + /* that we'd rather not scan. */ +# endif + extern int _end; +# define DATAEND (&_end) +# else + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# endif +# endif +# ifdef CYGWIN32 +# define OS_TYPE "CYGWIN32" + extern int _data_start__; + extern int _data_end__; + extern int _bss_start__; + extern int _bss_end__; + /* For binutils 2.9.1, we have */ + /* DATASTART = _data_start__ */ + /* DATAEND = _bss_end__ */ + /* whereas for some earlier versions it was */ + /* DATASTART = _bss_start__ */ + /* DATAEND = _data_end__ */ + /* To get it right for both, we take the */ + /* minumum/maximum of the two. */ +# define MAX(x,y) ((x) > (y) ? (x) : (y)) +# define MIN(x,y) ((x) < (y) ? (x) : (y)) +# define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__)) +# define DATAEND ((ptr_t) MAX(&_data_end__, &_bss_end__)) +# undef STACK_GRAN +# define STACK_GRAN 0x10000 +# define HEURISTIC1 +# endif +# ifdef OS2 +# define OS_TYPE "OS2" + /* STACKBOTTOM and DATASTART are handled specially in */ + /* os_dep.c. OS2 actually has the right */ + /* system call! */ +# define DATAEND /* not needed */ +# endif +# ifdef MSWIN32 +# define OS_TYPE "MSWIN32" + /* STACKBOTTOM and DATASTART are handled specially in */ + /* os_dep.c. */ +# ifndef __WATCOMC__ +# define MPROTECT_VDB +# endif +# define DATAEND /* not needed */ +# endif +# ifdef DJGPP +# define OS_TYPE "DJGPP" +# include "stubinfo.h" + extern int etext; + extern int _stklen; + extern int __djgpp_stack_limit; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff)) +/* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \ + + _stklen)) */ +# define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen)) + /* This may not be right. */ +# endif +# ifdef OPENBSD +# define OS_TYPE "OPENBSD" +# endif +# ifdef FREEBSD +# define OS_TYPE "FREEBSD" +# define MPROTECT_VDB +# endif +# ifdef NETBSD +# define OS_TYPE "NETBSD" +# endif +# ifdef THREE86BSD +# define OS_TYPE "THREE86BSD" +# endif +# ifdef BSDI +# define OS_TYPE "BSDI" +# endif +# if defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD) \ + || defined(THREE86BSD) || defined(BSDI) +# define HEURISTIC2 + extern char etext; +# define DATASTART ((ptr_t)(&etext)) +# endif +# ifdef NEXT +# define OS_TYPE "NEXT" +# define DATASTART ((ptr_t) get_etext()) +# define STACKBOTTOM ((ptr_t)0xc0000000) +# define DATAEND /* not needed */ +# endif +# ifdef DOS4GW +# define OS_TYPE "DOS4GW" + extern long __nullarea; + extern char _end; + extern char *_STACKTOP; + /* Depending on calling conventions Watcom C either precedes + or does not precedes with undescore names of C-variables. + Make sure startup code variables always have the same names. */ + #pragma aux __nullarea "*"; + #pragma aux _end "*"; +# define STACKBOTTOM ((ptr_t) _STACKTOP) + /* confused? me too. */ +# define DATASTART ((ptr_t) &__nullarea) +# define DATAEND ((ptr_t) &_end) +# endif +# endif + +# ifdef NS32K +# define MACH_TYPE "NS32K" +# define ALIGNMENT 4 + extern char **environ; +# define DATASTART ((ptr_t)(&environ)) + /* hideous kludge: environ is the first */ + /* word in crt0.o, and delimits the start */ + /* of the data segment, no matter which */ + /* ld options were passed through. */ +# define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */ +# endif + +# ifdef MIPS +# define MACH_TYPE "MIPS" +# ifndef IRIX5 +# define DATASTART (ptr_t)0x10000000 + /* Could probably be slightly higher since */ + /* startup code allocates lots of stuff. */ +# else + extern int _fdata; +# define DATASTART ((ptr_t)(&_fdata)) +# ifdef USE_MMAP +# define HEAP_START (ptr_t)0x30000000 +# else +# define HEAP_START DATASTART +# endif + /* Lowest plausible heap address. */ + /* In the MMAP case, we map there. */ + /* In either case it is used to identify */ + /* heap sections so they're not */ + /* considered as roots. */ +# endif /* IRIX5 */ +# define HEURISTIC2 +/* # define STACKBOTTOM ((ptr_t)0x7fff8000) sometimes also works. */ +# ifdef ULTRIX +# define OS_TYPE "ULTRIX" +# define ALIGNMENT 4 +# endif +# ifdef RISCOS +# define OS_TYPE "RISCOS" +# define ALIGNMENT 4 /* Required by hardware */ +# endif +# ifdef IRIX5 +# define OS_TYPE "IRIX5" +# define MPROTECT_VDB +# ifdef _MIPS_SZPTR +# define CPP_WORDSZ _MIPS_SZPTR +# define ALIGNMENT (_MIPS_SZPTR/8) +# if CPP_WORDSZ != 64 +# define ALIGN_DOUBLE +# endif +# else +# define ALIGNMENT 4 +# define ALIGN_DOUBLE +# endif +# define DYNAMIC_LOADING +# endif +# endif + +# ifdef RS6000 +# define MACH_TYPE "RS6000" +# define ALIGNMENT 4 +# define DATASTART ((ptr_t)0x20000000) + extern int errno; +# define STACKBOTTOM ((ptr_t)((ulong)&errno)) +# define DYNAMIC_LOADING + /* For really old versions of AIX, this may have to be removed. */ +# endif + +# ifdef HP_PA +# define MACH_TYPE "HP_PA" +# define ALIGNMENT 4 +# define ALIGN_DOUBLE + extern int __data_start; +# define DATASTART ((ptr_t)(&__data_start)) +# if 0 + /* The following appears to work for 7xx systems running HP/UX */ + /* 9.xx Furthermore, it might result in much faster */ + /* collections than HEURISTIC2, which may involve scanning */ + /* segments that directly precede the stack. It is not the */ + /* default, since it may not work on older machine/OS */ + /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */ + /* this.) */ +# define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */ +# else +# define HEURISTIC2 +# endif +# define STACK_GROWS_UP +# define DYNAMIC_LOADING +# include +# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) + /* They misspelled the Posix macro? */ +# endif + +# ifdef ALPHA +# define MACH_TYPE "ALPHA" +# define ALIGNMENT 8 +# ifdef OSF1 +# define OS_TYPE "OSF1" +# define DATASTART ((ptr_t) 0x140000000) + extern _end; +# define DATAEND ((ptr_t) &_end) +# define HEURISTIC2 + /* Normally HEURISTIC2 is too conervative, since */ + /* the text segment immediately follows the stack. */ + /* Hence we give an upper pound. */ + extern int __start; +# define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1))) +# define CPP_WORDSZ 64 +# define MPROTECT_VDB +# define DYNAMIC_LOADING +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# define CPP_WORDSZ 64 +# define STACKBOTTOM ((ptr_t) 0x120000000) +# ifdef __ELF__ +# if 0 + /* __data_start apparently disappeared in some recent releases. */ + extern int __data_start; +# define DATASTART &__data_start +# endif +# define DATASTART GC_data_start +# define DYNAMIC_LOADING +# else +# define DATASTART ((ptr_t) 0x140000000) +# endif + extern int _end; +# define DATAEND (&_end) +# define MPROTECT_VDB + /* Has only been superficially tested. May not */ + /* work on all versions. */ +# endif +# endif + +# ifdef M88K +# define MACH_TYPE "M88K" +# define ALIGNMENT 4 +# define ALIGN_DOUBLE + extern int etext; +# ifdef CX_UX +# define OS_TYPE "CX_UX" +# define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000) +# endif +# ifdef DGUX +# define OS_TYPE "DGUX" + extern char * GC_SysVGetDataStart(); +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext) +# endif +# define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */ +# endif + +# ifdef S370 +# define MACH_TYPE "S370" +# define OS_TYPE "UTS4" +# define ALIGNMENT 4 /* Required by hardware */ + extern int etext; + extern int _etext; + extern int _end; + extern char * GC_SysVGetDataStart(); +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext) +# define DATAEND (&_end) +# define HEURISTIC2 +# endif + +# ifndef STACK_GROWS_UP +# define STACK_GROWS_DOWN +# endif + +# ifndef CPP_WORDSZ +# define CPP_WORDSZ 32 +# endif + +# ifndef OS_TYPE +# define OS_TYPE "" +# endif + +# ifndef DATAEND + extern int end; +# define DATAEND (&end) +# endif + +# if defined(SVR4) && !defined(GETPAGESIZE) +# include +# define GETPAGESIZE() sysconf(_SC_PAGESIZE) +# endif + +# ifndef GETPAGESIZE +# if defined(SUNOS5) || defined(IRIX5) +# include +# endif +# define GETPAGESIZE() getpagesize() +# endif + +# if defined(SUNOS5) || defined(DRSNX) || defined(UTS4) + /* OS has SVR4 generic features. Probably others also qualify. */ +# define SVR4 +# endif + +# if defined(SUNOS5) || defined(DRSNX) + /* OS has SUNOS5 style semi-undocumented interface to dynamic */ + /* loader. */ +# define SUNOS5DL + /* OS has SUNOS5 style signal handlers. */ +# define SUNOS5SIGS +# endif + +# if CPP_WORDSZ != 32 && CPP_WORDSZ != 64 + -> bad word size +# endif + +# ifdef PCR +# undef DYNAMIC_LOADING +# undef STACKBOTTOM +# undef HEURISTIC1 +# undef HEURISTIC2 +# undef PROC_VDB +# undef MPROTECT_VDB +# define PCR_VDB +# endif + +# ifdef SRC_M3 +/* Postponed for now. */ +# undef PROC_VDB +# undef MPROTECT_VDB +# endif + +# ifdef SMALL_CONFIG +/* Presumably not worth the space it takes. */ +# undef PROC_VDB +# undef MPROTECT_VDB +# endif + +# ifdef USE_MUNMAP +# undef MPROTECT_VDB /* Can't deal with address space holes. */ +# endif + +# if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) +# define DEFAULT_VDB +# endif + +# if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) +# define SOLARIS_THREADS +# endif +# if defined(IRIX_THREADS) && !defined(IRIX5) +--> inconsistent configuration +# endif +# if defined(IRIX_JDK_THREADS) && !defined(IRIX5) +--> inconsistent configuration +# endif +# if defined(LINUX_THREADS) && !defined(LINUX) +--> inconsistent configuration +# endif +# if defined(SOLARIS_THREADS) && !defined(SUNOS5) +--> inconsistent configuration +# endif +# if defined(PCR) || defined(SRC_M3) || \ + defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ + defined(IRIX_THREADS) || defined(LINUX_THREADS) || \ + defined(IRIX_JDK_THREADS) +# define THREADS +# endif + +# if defined(HP_PA) || defined(M88K) || defined(POWERPC) \ + || (defined(I386) && defined(OS2)) || defined(UTS4) || defined(LINT) + /* Use setjmp based hack to mark from callee-save registers. */ +# define USE_GENERIC_PUSH_REGS +# endif +# if defined(SPARC) && !defined(LINUX) +# define SAVE_CALL_CHAIN +# define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */ + /* include assembly code to do it well. */ +# endif + +# endif diff --git a/support/gc/headers.c b/support/gc/headers.c new file mode 100644 index 00000000..9564a6a5 --- /dev/null +++ b/support/gc/headers.c @@ -0,0 +1,351 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* + * This implements: + * 1. allocation of heap block headers + * 2. A map from addresses to heap block addresses to heap block headers + * + * Access speed is crucial. We implement an index structure based on a 2 + * level tree. + */ + +# include "gc_priv.h" + +bottom_index * GC_all_bottom_indices = 0; + /* Pointer to first (lowest addr) */ + /* bottom_index. */ + +bottom_index * GC_all_bottom_indices_end = 0; + /* Pointer to last (highest addr) */ + /* bottom_index. */ + +/* Non-macro version of header location routine */ +hdr * GC_find_header(h) +ptr_t h; +{ +# ifdef HASH_TL + register hdr * result; + GET_HDR(h, result); + return(result); +# else + return(HDR_INNER(h)); +# endif +} + +/* Routines to dynamically allocate collector data structures that will */ +/* never be freed. */ + +static ptr_t scratch_free_ptr = 0; + +ptr_t GC_scratch_end_ptr = 0; + +ptr_t GC_scratch_last_end_ptr = 0; + /* End point of last obtained scratch area */ + +ptr_t GC_scratch_alloc(bytes) +register word bytes; +{ + register ptr_t result = scratch_free_ptr; + +# ifdef ALIGN_DOUBLE +# define GRANULARITY (2 * sizeof(word)) +# else +# define GRANULARITY sizeof(word) +# endif + bytes += GRANULARITY-1; + bytes &= ~(GRANULARITY-1); + scratch_free_ptr += bytes; + if (scratch_free_ptr <= GC_scratch_end_ptr) { + return(result); + } + { + word bytes_to_get = MINHINCR * HBLKSIZE; + + if (bytes_to_get <= bytes) { + /* Undo the damage, and get memory directly */ + bytes_to_get = bytes; +# ifdef USE_MMAP + bytes_to_get += GC_page_size - 1; + bytes_to_get &= ~(GC_page_size - 1); +# endif + result = (ptr_t)GET_MEM(bytes_to_get); + scratch_free_ptr -= bytes; + GC_scratch_last_end_ptr = result + bytes; + return(result); + } + result = (ptr_t)GET_MEM(bytes_to_get); + if (result == 0) { +# ifdef PRINTSTATS + GC_printf0("Out of memory - trying to allocate less\n"); +# endif + scratch_free_ptr -= bytes; + bytes_to_get = bytes; +# ifdef USE_MMAP + bytes_to_get += GC_page_size - 1; + bytes_to_get &= ~(GC_page_size - 1); +# endif + return((ptr_t)GET_MEM(bytes_to_get)); + } + scratch_free_ptr = result; + GC_scratch_end_ptr = scratch_free_ptr + bytes_to_get; + GC_scratch_last_end_ptr = GC_scratch_end_ptr; + return(GC_scratch_alloc(bytes)); + } +} + +static hdr * hdr_free_list = 0; + +/* Return an uninitialized header */ +static hdr * alloc_hdr() +{ + register hdr * result; + + if (hdr_free_list == 0) { + result = (hdr *) GC_scratch_alloc((word)(sizeof(hdr))); + } else { + result = hdr_free_list; + hdr_free_list = (hdr *) (result -> hb_next); + } + return(result); +} + +static void free_hdr(hhdr) +hdr * hhdr; +{ + hhdr -> hb_next = (struct hblk *) hdr_free_list; + hdr_free_list = hhdr; +} + +void GC_init_headers() +{ + register unsigned i; + + GC_all_nils = (bottom_index *)GC_scratch_alloc((word)sizeof(bottom_index)); + BZERO(GC_all_nils, sizeof(bottom_index)); + for (i = 0; i < TOP_SZ; i++) { + GC_top_index[i] = GC_all_nils; + } +} + +/* Make sure that there is a bottom level index block for address addr */ +/* Return FALSE on failure. */ +static GC_bool get_index(addr) +word addr; +{ + word hi = (word)(addr) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); + bottom_index * r; + bottom_index * p; + bottom_index ** prev; + bottom_index *pi; + +# ifdef HASH_TL + unsigned i = TL_HASH(hi); + bottom_index * old; + + old = p = GC_top_index[i]; + while(p != GC_all_nils) { + if (p -> key == hi) return(TRUE); + p = p -> hash_link; + } + r = (bottom_index*)GC_scratch_alloc((word)(sizeof (bottom_index))); + if (r == 0) return(FALSE); + BZERO(r, sizeof (bottom_index)); + r -> hash_link = old; + GC_top_index[i] = r; +# else + if (GC_top_index[hi] != GC_all_nils) return(TRUE); + r = (bottom_index*)GC_scratch_alloc((word)(sizeof (bottom_index))); + if (r == 0) return(FALSE); + GC_top_index[hi] = r; + BZERO(r, sizeof (bottom_index)); +# endif + r -> key = hi; + /* Add it to the list of bottom indices */ + prev = &GC_all_bottom_indices; /* pointer to p */ + pi = 0; /* bottom_index preceding p */ + while ((p = *prev) != 0 && p -> key < hi) { + pi = p; + prev = &(p -> asc_link); + } + r -> desc_link = pi; + if (0 == p) { + GC_all_bottom_indices_end = r; + } else { + p -> desc_link = r; + } + r -> asc_link = p; + *prev = r; + return(TRUE); +} + +/* Install a header for block h. */ +/* The header is uninitialized. */ +/* Returns FALSE on failure. */ +GC_bool GC_install_header(h) +register struct hblk * h; +{ + hdr * result; + + if (!get_index((word) h)) return(FALSE); + result = alloc_hdr(); + SET_HDR(h, result); +# ifdef USE_MUNMAP + result -> hb_last_reclaimed = GC_gc_no; +# endif + return(result != 0); +} + +/* Set up forwarding counts for block h of size sz */ +GC_bool GC_install_counts(h, sz) +register struct hblk * h; +register word sz; /* bytes */ +{ + register struct hblk * hbp; + register int i; + + for (hbp = h; (char *)hbp < (char *)h + sz; hbp += BOTTOM_SZ) { + if (!get_index((word) hbp)) return(FALSE); + } + if (!get_index((word)h + sz - 1)) return(FALSE); + for (hbp = h + 1; (char *)hbp < (char *)h + sz; hbp += 1) { + i = HBLK_PTR_DIFF(hbp, h); + SET_HDR(hbp, (hdr *)(i > MAX_JUMP? MAX_JUMP : i)); + } + return(TRUE); +} + +/* Remove the header for block h */ +void GC_remove_header(h) +register struct hblk * h; +{ + hdr ** ha; + + GET_HDR_ADDR(h, ha); + free_hdr(*ha); + *ha = 0; +} + +/* Remove forwarding counts for h */ +void GC_remove_counts(h, sz) +register struct hblk * h; +register word sz; /* bytes */ +{ + register struct hblk * hbp; + + for (hbp = h+1; (char *)hbp < (char *)h + sz; hbp += 1) { + SET_HDR(hbp, 0); + } +} + +/* Apply fn to all allocated blocks */ +/*VARARGS1*/ +void GC_apply_to_all_blocks(fn, client_data) +void (*fn)(/* struct hblk *h, word client_data */); +word client_data; +{ + register int j; + register bottom_index * index_p; + + for (index_p = GC_all_bottom_indices; index_p != 0; + index_p = index_p -> asc_link) { + for (j = BOTTOM_SZ-1; j >= 0;) { + if (!IS_FORWARDING_ADDR_OR_NIL(index_p->index[j])) { + if (index_p->index[j]->hb_map != GC_invalid_map) { + (*fn)(((struct hblk *) + (((index_p->key << LOG_BOTTOM_SZ) + (word)j) + << LOG_HBLKSIZE)), + client_data); + } + j--; + } else if (index_p->index[j] == 0) { + j--; + } else { + j -= (word)(index_p->index[j]); + } + } + } +} + +/* Get the next valid block whose address is at least h */ +/* Return 0 if there is none. */ +struct hblk * GC_next_used_block(h) +struct hblk * h; +{ + register bottom_index * bi; + register word j = ((word)h >> LOG_HBLKSIZE) & (BOTTOM_SZ-1); + + GET_BI(h, bi); + if (bi == GC_all_nils) { + register word hi = (word)h >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); + bi = GC_all_bottom_indices; + while (bi != 0 && bi -> key < hi) bi = bi -> asc_link; + j = 0; + } + while(bi != 0) { + while (j < BOTTOM_SZ) { + hdr * hhdr = bi -> index[j]; + if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + j++; + } else { + if (hhdr->hb_map != GC_invalid_map) { + return((struct hblk *) + (((bi -> key << LOG_BOTTOM_SZ) + j) + << LOG_HBLKSIZE)); + } else { + j += divHBLKSZ(hhdr -> hb_sz); + } + } + } + j = 0; + bi = bi -> asc_link; + } + return(0); +} + +/* Get the last (highest address) block whose address is */ +/* at most h. Return 0 if there is none. */ +/* Unlike the above, this may return a free block. */ +struct hblk * GC_prev_block(h) +struct hblk * h; +{ + register bottom_index * bi; + register signed_word j = ((word)h >> LOG_HBLKSIZE) & (BOTTOM_SZ-1); + + GET_BI(h, bi); + if (bi == GC_all_nils) { + register word hi = (word)h >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); + bi = GC_all_bottom_indices_end; + while (bi != 0 && bi -> key > hi) bi = bi -> desc_link; + j = BOTTOM_SZ - 1; + } + while(bi != 0) { + while (j >= 0) { + hdr * hhdr = bi -> index[j]; + if (0 == hhdr) { + --j; + } else if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + j -= (signed_word)hhdr; + } else { + return((struct hblk *) + (((bi -> key << LOG_BOTTOM_SZ) + j) + << LOG_HBLKSIZE)); + } + } + j = BOTTOM_SZ - 1; + bi = bi -> desc_link; + } + return(0); +} diff --git a/support/gc/if_mach.c b/support/gc/if_mach.c new file mode 100644 index 00000000..af013637 --- /dev/null +++ b/support/gc/if_mach.c @@ -0,0 +1,25 @@ +/* Conditionally execute a command based on machine and OS from gcconfig.h */ + +# include "gcconfig.h" +# include + +int main(argc, argv, envp) +int argc; +char ** argv; +char ** envp; +{ + if (argc < 4) goto Usage; + if (strcmp(MACH_TYPE, argv[1]) != 0) return(0); + if (strcmp(OS_TYPE, "") != 0 && strcmp(argv[2], "") != 0 + && strcmp(OS_TYPE, argv[2]) != 0) return(0); + printf("^^^^Starting command^^^^\n"); + execvp(argv[3], argv+3); + perror("Couldn't execute"); + +Usage: + fprintf(stderr, "Usage: %s mach_type os_type command\n", argv[0]); + fprintf(stderr, "Currently mach_type = %s, os_type = %s\n", + MACH_TYPE, OS_TYPE); + return(1); +} + diff --git a/support/gc/if_not_there.c b/support/gc/if_not_there.c new file mode 100644 index 00000000..a93795f1 --- /dev/null +++ b/support/gc/if_not_there.c @@ -0,0 +1,26 @@ +/* Conditionally execute a command based if the file argv[1] doesn't exist */ +/* Except for execvp, we stick to ANSI C. */ +# include "gcconfig.h" +# include + +int main(argc, argv, envp) +int argc; +char ** argv; +char ** envp; +{ + FILE * f; + if (argc < 3) goto Usage; + if ((f = fopen(argv[1], "rb")) != 0 + || (f = fopen(argv[1], "r")) != 0) { + fclose(f); + return(0); + } + printf("^^^^Starting command^^^^\n"); + execvp(argv[2], argv+2); + exit(1); + +Usage: + fprintf(stderr, "Usage: %s file_name command\n", argv[0]); + return(1); +} + diff --git a/support/gc/include/cord.h b/support/gc/include/cord.h new file mode 100644 index 00000000..584112fd --- /dev/null +++ b/support/gc/include/cord.h @@ -0,0 +1,327 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Author: Hans-J. Boehm (boehm@parc.xerox.com) + */ +/* Boehm, October 5, 1995 4:20 pm PDT */ + +/* + * Cords are immutable character strings. A number of operations + * on long cords are much more efficient than their strings.h counterpart. + * In particular, concatenation takes constant time independent of the length + * of the arguments. (Cords are represented as trees, with internal + * nodes representing concatenation and leaves consisting of either C + * strings or a functional description of the string.) + * + * The following are reasonable applications of cords. They would perform + * unacceptably if C strings were used: + * - A compiler that produces assembly language output by repeatedly + * concatenating instructions onto a cord representing the output file. + * - A text editor that converts the input file to a cord, and then + * performs editing operations by producing a new cord representing + * the file after echa character change (and keeping the old ones in an + * edit history) + * + * For optimal performance, cords should be built by + * concatenating short sections. + * This interface is designed for maximum compatibility with C strings. + * ASCII NUL characters may be embedded in cords using CORD_from_fn. + * This is handled correctly, but CORD_to_char_star will produce a string + * with embedded NULs when given such a cord. + * + * This interface is fairly big, largely for performance reasons. + * The most basic constants and functions: + * + * CORD - the type fo a cord; + * CORD_EMPTY - empty cord; + * CORD_len(cord) - length of a cord; + * CORD_cat(cord1,cord2) - concatenation of two cords; + * CORD_substr(cord, start, len) - substring (or subcord); + * CORD_pos i; CORD_FOR(i, cord) { ... CORD_pos_fetch(i) ... } - + * examine each character in a cord. CORD_pos_fetch(i) is the char. + * CORD_fetch(int i) - Retrieve i'th character (slowly). + * CORD_cmp(cord1, cord2) - compare two cords. + * CORD_from_file(FILE * f) - turn a read-only file into a cord. + * CORD_to_char_star(cord) - convert to C string. + * (Non-NULL C constant strings are cords.) + * CORD_printf (etc.) - cord version of printf. Use %r for cords. + */ +# ifndef CORD_H + +# define CORD_H +# include +# include +/* Cords have type const char *. This is cheating quite a bit, and not */ +/* 100% portable. But it means that nonempty character string */ +/* constants may be used as cords directly, provided the string is */ +/* never modified in place. The empty cord is represented by, and */ +/* can be written as, 0. */ + +typedef const char * CORD; + +/* An empty cord is always represented as nil */ +# define CORD_EMPTY 0 + +/* Is a nonempty cord represented as a C string? */ +#define CORD_IS_STRING(s) (*(s) != '\0') + +/* Concatenate two cords. If the arguments are C strings, they may */ +/* not be subsequently altered. */ +CORD CORD_cat(CORD x, CORD y); + +/* Concatenate a cord and a C string with known length. Except for the */ +/* empty string case, this is a special case of CORD_cat. Since the */ +/* length is known, it can be faster. */ +/* The string y is shared with the resulting CORD. Hence it should */ +/* not be altered by the caller. */ +CORD CORD_cat_char_star(CORD x, const char * y, size_t leny); + +/* Compute the length of a cord */ +size_t CORD_len(CORD x); + +/* Cords may be represented by functions defining the ith character */ +typedef char (* CORD_fn)(size_t i, void * client_data); + +/* Turn a functional description into a cord. */ +CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len); + +/* Return the substring (subcord really) of x with length at most n, */ +/* starting at position i. (The initial character has position 0.) */ +CORD CORD_substr(CORD x, size_t i, size_t n); + +/* Return the argument, but rebalanced to allow more efficient */ +/* character retrieval, substring operations, and comparisons. */ +/* This is useful only for cords that were built using repeated */ +/* concatenation. Guarantees log time access to the result, unless */ +/* x was obtained through a large number of repeated substring ops */ +/* or the embedded functional descriptions take longer to evaluate. */ +/* May reallocate significant parts of the cord. The argument is not */ +/* modified; only the result is balanced. */ +CORD CORD_balance(CORD x); + +/* The following traverse a cord by applying a function to each */ +/* character. This is occasionally appropriate, especially where */ +/* speed is crucial. But, since C doesn't have nested functions, */ +/* clients of this sort of traversal are clumsy to write. Consider */ +/* the functions that operate on cord positions instead. */ + +/* Function to iteratively apply to individual characters in cord. */ +typedef int (* CORD_iter_fn)(char c, void * client_data); + +/* Function to apply to substrings of a cord. Each substring is a */ +/* a C character string, not a general cord. */ +typedef int (* CORD_batched_iter_fn)(const char * s, void * client_data); +# define CORD_NO_FN ((CORD_batched_iter_fn)0) + +/* Apply f1 to each character in the cord, in ascending order, */ +/* starting at position i. If */ +/* f2 is not CORD_NO_FN, then multiple calls to f1 may be replaced by */ +/* a single call to f2. The parameter f2 is provided only to allow */ +/* some optimization by the client. This terminates when the right */ +/* end of this string is reached, or when f1 or f2 return != 0. In the */ +/* latter case CORD_iter returns != 0. Otherwise it returns 0. */ +/* The specified value of i must be < CORD_len(x). */ +int CORD_iter5(CORD x, size_t i, CORD_iter_fn f1, + CORD_batched_iter_fn f2, void * client_data); + +/* A simpler version that starts at 0, and without f2: */ +int CORD_iter(CORD x, CORD_iter_fn f1, void * client_data); +# define CORD_iter(x, f1, cd) CORD_iter5(x, 0, f1, CORD_NO_FN, cd) + +/* Similar to CORD_iter5, but end-to-beginning. No provisions for */ +/* CORD_batched_iter_fn. */ +int CORD_riter4(CORD x, size_t i, CORD_iter_fn f1, void * client_data); + +/* A simpler version that starts at the end: */ +int CORD_riter(CORD x, CORD_iter_fn f1, void * client_data); + +/* Functions that operate on cord positions. The easy way to traverse */ +/* cords. A cord position is logically a pair consisting of a cord */ +/* and an index into that cord. But it is much faster to retrieve a */ +/* charcter based on a position than on an index. Unfortunately, */ +/* positions are big (order of a few 100 bytes), so allocate them with */ +/* caution. */ +/* Things in cord_pos.h should be treated as opaque, except as */ +/* described below. Also note that */ +/* CORD_pos_fetch, CORD_next and CORD_prev have both macro and function */ +/* definitions. The former may evaluate their argument more than once. */ +# include "private/cord_pos.h" + +/* + Visible definitions from above: + + typedef CORD_pos[1]; + + * Extract the cord from a position: + CORD CORD_pos_to_cord(CORD_pos p); + + * Extract the current index from a position: + size_t CORD_pos_to_index(CORD_pos p); + + * Fetch the character located at the given position: + char CORD_pos_fetch(CORD_pos p); + + * Initialize the position to refer to the given cord and index. + * Note that this is the most expensive function on positions: + void CORD_set_pos(CORD_pos p, CORD x, size_t i); + + * Advance the position to the next character. + * P must be initialized and valid. + * Invalidates p if past end: + void CORD_next(CORD_pos p); + + * Move the position to the preceding character. + * P must be initialized and valid. + * Invalidates p if past beginning: + void CORD_prev(CORD_pos p); + + * Is the position valid, i.e. inside the cord? + int CORD_pos_valid(CORD_pos p); +*/ +# define CORD_FOR(pos, cord) \ + for (CORD_set_pos(pos, cord, 0); CORD_pos_valid(pos); CORD_next(pos)) + + +/* An out of memory handler to call. May be supplied by client. */ +/* Must not return. */ +extern void (* CORD_oom_fn)(void); + +/* Dump the representation of x to stdout in an implementation defined */ +/* manner. Intended for debugging only. */ +void CORD_dump(CORD x); + +/* The following could easily be implemented by the client. They are */ +/* provided in cordxtra.c for convenience. */ + +/* Concatenate a character to the end of a cord. */ +CORD CORD_cat_char(CORD x, char c); + +/* Concatenate n cords. */ +CORD CORD_catn(int n, /* CORD */ ...); + +/* Return the character in CORD_substr(x, i, 1) */ +char CORD_fetch(CORD x, size_t i); + +/* Return < 0, 0, or > 0, depending on whether x < y, x = y, x > y */ +int CORD_cmp(CORD x, CORD y); + +/* A generalization that takes both starting positions for the */ +/* comparison, and a limit on the number of characters to be compared. */ +int CORD_ncmp(CORD x, size_t x_start, CORD y, size_t y_start, size_t len); + +/* Find the first occurrence of s in x at position start or later. */ +/* Return the position of the first character of s in x, or */ +/* CORD_NOT_FOUND if there is none. */ +size_t CORD_str(CORD x, size_t start, CORD s); + +/* Return a cord consisting of i copies of (possibly NUL) c. Dangerous */ +/* in conjunction with CORD_to_char_star. */ +/* The resulting representation takes constant space, independent of i. */ +CORD CORD_chars(char c, size_t i); +# define CORD_nul(i) CORD_chars('\0', (i)) + +/* Turn a file into cord. The file must be seekable. Its contents */ +/* must remain constant. The file may be accessed as an immediate */ +/* result of this call and/or as a result of subsequent accesses to */ +/* the cord. Short files are likely to be immediately read, but */ +/* long files are likely to be read on demand, possibly relying on */ +/* stdio for buffering. */ +/* We must have exclusive access to the descriptor f, i.e. we may */ +/* read it at any time, and expect the file pointer to be */ +/* where we left it. Normally this should be invoked as */ +/* CORD_from_file(fopen(...)) */ +/* CORD_from_file arranges to close the file descriptor when it is no */ +/* longer needed (e.g. when the result becomes inaccessible). */ +/* The file f must be such that ftell reflects the actual character */ +/* position in the file, i.e. the number of characters that can be */ +/* or were read with fread. On UNIX systems this is always true. On */ +/* MS Windows systems, f must be opened in binary mode. */ +CORD CORD_from_file(FILE * f); + +/* Equivalent to the above, except that the entire file will be read */ +/* and the file pointer will be closed immediately. */ +/* The binary mode restriction from above does not apply. */ +CORD CORD_from_file_eager(FILE * f); + +/* Equivalent to the above, except that the file will be read on demand.*/ +/* The binary mode restriction applies. */ +CORD CORD_from_file_lazy(FILE * f); + +/* Turn a cord into a C string. The result shares no structure with */ +/* x, and is thus modifiable. */ +char * CORD_to_char_star(CORD x); + +/* Turn a C string into a CORD. The C string is copied, and so may */ +/* subsequently be modified. */ +CORD CORD_from_char_star(const char *s); + +/* Identical to the above, but the result may share structure with */ +/* the argument and is thus not modifiable. */ +const char * CORD_to_const_char_star(CORD x); + +/* Write a cord to a file, starting at the current position. No */ +/* trailing NULs are newlines are added. */ +/* Returns EOF if a write error occurs, 1 otherwise. */ +int CORD_put(CORD x, FILE * f); + +/* "Not found" result for the following two functions. */ +# define CORD_NOT_FOUND ((size_t)(-1)) + +/* A vague analog of strchr. Returns the position (an integer, not */ +/* a pointer) of the first occurrence of (char) c inside x at position */ +/* i or later. The value i must be < CORD_len(x). */ +size_t CORD_chr(CORD x, size_t i, int c); + +/* A vague analog of strrchr. Returns index of the last occurrence */ +/* of (char) c inside x at position i or earlier. The value i */ +/* must be < CORD_len(x). */ +size_t CORD_rchr(CORD x, size_t i, int c); + + +/* The following are also not primitive, but are implemented in */ +/* cordprnt.c. They provide functionality similar to the ANSI C */ +/* functions with corresponding names, but with the following */ +/* additions and changes: */ +/* 1. A %r conversion specification specifies a CORD argument. Field */ +/* width, precision, etc. have the same semantics as for %s. */ +/* (Note that %c,%C, and %S were already taken.) */ +/* 2. The format string is represented as a CORD. */ +/* 3. CORD_sprintf and CORD_vsprintf assign the result through the 1st */ /* argument. Unlike their ANSI C versions, there is no need to guess */ +/* the correct buffer size. */ +/* 4. Most of the conversions are implement through the native */ +/* vsprintf. Hence they are usually no faster, and */ +/* idiosyncracies of the native printf are preserved. However, */ +/* CORD arguments to CORD_sprintf and CORD_vsprintf are NOT copied; */ +/* the result shares the original structure. This may make them */ +/* very efficient in some unusual applications. */ +/* The format string is copied. */ +/* All functions return the number of characters generated or -1 on */ +/* error. This complies with the ANSI standard, but is inconsistent */ +/* with some older implementations of sprintf. */ + +/* The implementation of these is probably less portable than the rest */ +/* of this package. */ + +#ifndef CORD_NO_IO + +#include + +int CORD_sprintf(CORD * out, CORD format, ...); +int CORD_vsprintf(CORD * out, CORD format, va_list args); +int CORD_fprintf(FILE * f, CORD format, ...); +int CORD_vfprintf(FILE * f, CORD format, va_list args); +int CORD_printf(CORD format, ...); +int CORD_vprintf(CORD format, va_list args); + +#endif /* CORD_NO_IO */ + +# endif /* CORD_H */ diff --git a/support/gc/include/ec.h b/support/gc/include/ec.h new file mode 100644 index 00000000..c829b83a --- /dev/null +++ b/support/gc/include/ec.h @@ -0,0 +1,70 @@ +# ifndef EC_H +# define EC_H + +# ifndef CORD_H +# include "cord.h" +# endif + +/* Extensible cords are strings that may be destructively appended to. */ +/* They allow fast construction of cords from characters that are */ +/* being read from a stream. */ +/* + * A client might look like: + * + * { + * CORD_ec x; + * CORD result; + * char c; + * FILE *f; + * + * ... + * CORD_ec_init(x); + * while(...) { + * c = getc(f); + * ... + * CORD_ec_append(x, c); + * } + * result = CORD_balance(CORD_ec_to_cord(x)); + * + * If a C string is desired as the final result, the call to CORD_balance + * may be replaced by a call to CORD_to_char_star. + */ + +# ifndef CORD_BUFSZ +# define CORD_BUFSZ 128 +# endif + +typedef struct CORD_ec_struct { + CORD ec_cord; + char * ec_bufptr; + char ec_buf[CORD_BUFSZ+1]; +} CORD_ec[1]; + +/* This structure represents the concatenation of ec_cord with */ +/* ec_buf[0 ... (ec_bufptr-ec_buf-1)] */ + +/* Flush the buffer part of the extended chord into ec_cord. */ +/* Note that this is almost the only real function, and it is */ +/* implemented in 6 lines in cordxtra.c */ +void CORD_ec_flush_buf(CORD_ec x); + +/* Convert an extensible cord to a cord. */ +# define CORD_ec_to_cord(x) (CORD_ec_flush_buf(x), (x)[0].ec_cord) + +/* Initialize an extensible cord. */ +# define CORD_ec_init(x) ((x)[0].ec_cord = 0, (x)[0].ec_bufptr = (x)[0].ec_buf) + +/* Append a character to an extensible cord. */ +# define CORD_ec_append(x, c) \ + { \ + if ((x)[0].ec_bufptr == (x)[0].ec_buf + CORD_BUFSZ) { \ + CORD_ec_flush_buf(x); \ + } \ + *((x)[0].ec_bufptr)++ = (c); \ + } + +/* Append a cord to an extensible cord. Structure remains shared with */ +/* original. */ +void CORD_ec_append_cord(CORD_ec x, CORD s); + +# endif /* EC_H */ diff --git a/support/gc/include/gc.h b/support/gc/include/gc.h new file mode 100644 index 00000000..eb9a7f60 --- /dev/null +++ b/support/gc/include/gc.h @@ -0,0 +1,720 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + * Copyright 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* + * Note that this defines a large number of tuning hooks, which can + * safely be ignored in nearly all cases. For normal use it suffices + * to call only GC_MALLOC and perhaps GC_REALLOC. + * For better performance, also look at GC_MALLOC_ATOMIC, and + * GC_enable_incremental. If you need an action to be performed + * immediately before an object is collected, look at GC_register_finalizer. + * If you are using Solaris threads, look at the end of this file. + * Everything else is best ignored unless you encounter performance + * problems. + */ + +#ifndef _GC_H + +# define _GC_H +# define __GC +# include + +#if defined(__CYGWIN32__) && defined(GC_USE_DLL) +#include "libgc_globals.h" +#endif + +#if defined(_MSC_VER) && defined(_DLL) +# ifdef GC_BUILD +# define GC_API __declspec(dllexport) +# else +# define GC_API __declspec(dllimport) +# endif +#endif + +#if defined(__WATCOMC__) && defined(GC_DLL) +# ifdef GC_BUILD +# define GC_API extern __declspec(dllexport) +# else +# define GC_API extern __declspec(dllimport) +# endif +#endif + +#ifndef GC_API +#define GC_API extern +#endif + +# if defined(__STDC__) || defined(__cplusplus) +# define GC_PROTO(args) args + typedef void * GC_PTR; +# else +# define GC_PROTO(args) () + typedef char * GC_PTR; +# endif + +# ifdef __cplusplus + extern "C" { +# endif + + +/* Define word and signed_word to be unsigned and signed types of the */ +/* size as char * or void *. There seems to be no way to do this */ +/* even semi-portably. The following is probably no better/worse */ +/* than almost anything else. */ +/* The ANSI standard suggests that size_t and ptr_diff_t might be */ +/* better choices. But those appear to have incorrect definitions */ +/* on may systems. Notably "typedef int size_t" seems to be both */ +/* frequent and WRONG. */ +typedef unsigned long GC_word; +typedef long GC_signed_word; + +/* Public read-only variables */ + +GC_API GC_word GC_gc_no;/* Counter incremented per collection. */ + /* Includes empty GCs at startup. */ + + +/* Public R/W variables */ + +GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested)); + /* When there is insufficient memory to satisfy */ + /* an allocation request, we return */ + /* (*GC_oom_fn)(). By default this just */ + /* returns 0. */ + /* If it returns, it must return 0 or a valid */ + /* pointer to a previously allocated heap */ + /* object. */ + +GC_API int GC_quiet; /* Disable statistics output. Only matters if */ + /* collector has been compiled with statistics */ + /* enabled. This involves a performance cost, */ + /* and is thus not the default. */ + +GC_API int GC_dont_gc; /* Dont collect unless explicitly requested, e.g. */ + /* because it's not safe. */ + +GC_API int GC_dont_expand; + /* Dont expand heap unless explicitly requested */ + /* or forced to. */ + +GC_API int GC_full_freq; /* Number of partial collections between */ + /* full collections. Matters only if */ + /* GC_incremental is set. */ + +GC_API GC_word GC_non_gc_bytes; + /* Bytes not considered candidates for collection. */ + /* Used only to control scheduling of collections. */ + +GC_API GC_word GC_free_space_divisor; + /* We try to make sure that we allocate at */ + /* least N/GC_free_space_divisor bytes between */ + /* collections, where N is the heap size plus */ + /* a rough estimate of the root set size. */ + /* Initially, GC_free_space_divisor = 4. */ + /* Increasing its value will use less space */ + /* but more collection time. Decreasing it */ + /* will appreciably decrease collection time */ + /* at the expense of space. */ + /* GC_free_space_divisor = 1 will effectively */ + /* disable collections. */ + +GC_API GC_word GC_max_retries; + /* The maximum number of GCs attempted before */ + /* reporting out of memory after heap */ + /* expansion fails. Initially 0. */ + + +/* Public procedures */ +/* + * general purpose allocation routines, with roughly malloc calling conv. + * The atomic versions promise that no relevant pointers are contained + * in the object. The nonatomic versions guarantee that the new object + * is cleared. GC_malloc_stubborn promises that no changes to the object + * will occur after GC_end_stubborn_change has been called on the + * result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object + * that is scanned for pointers to collectable objects, but is not itself + * collectable. GC_malloc_uncollectable and GC_free called on the resulting + * object implicitly update GC_non_gc_bytes appropriately. + */ +GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes)); +GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes)); + +/* The following is only defined if the library has been suitably */ +/* compiled: */ +GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes)); + +/* Explicitly deallocate an object. Dangerous if used incorrectly. */ +/* Requires a pointer to the base of an object. */ +/* If the argument is stubborn, it should not be changeable when freed. */ +/* An object should not be enable for finalization when it is */ +/* explicitly deallocated. */ +/* GC_free(0) is a no-op, as required by ANSI C for free. */ +GC_API void GC_free GC_PROTO((GC_PTR object_addr)); + +/* + * Stubborn objects may be changed only if the collector is explicitly informed. + * The collector is implicitly informed of coming change when such + * an object is first allocated. The following routines inform the + * collector that an object will no longer be changed, or that it will + * once again be changed. Only nonNIL pointer stores into the object + * are considered to be changes. The argument to GC_end_stubborn_change + * must be exacly the value returned by GC_malloc_stubborn or passed to + * GC_change_stubborn. (In the second case it may be an interior pointer + * within 512 bytes of the beginning of the objects.) + * There is a performance penalty for allowing more than + * one stubborn object to be changed at once, but it is acceptable to + * do so. The same applies to dropping stubborn objects that are still + * changeable. + */ +GC_API void GC_change_stubborn GC_PROTO((GC_PTR)); +GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR)); + +/* Return a pointer to the base (lowest address) of an object given */ +/* a pointer to a location within the object. */ +/* Return 0 if displaced_pointer doesn't point to within a valid */ +/* object. */ +GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer)); + +/* Given a pointer to the base of an object, return its size in bytes. */ +/* The returned size may be slightly larger than what was originally */ +/* requested. */ +GC_API size_t GC_size GC_PROTO((GC_PTR object_addr)); + +/* For compatibility with C library. This is occasionally faster than */ +/* a malloc followed by a bcopy. But if you rely on that, either here */ +/* or with the standard C library, your code is broken. In my */ +/* opinion, it shouldn't have been invented, but now we're stuck. -HB */ +/* The resulting object has the same kind as the original. */ +/* If the argument is stubborn, the result will have changes enabled. */ +/* It is an error to have changes enabled for the original object. */ +/* Follows ANSI comventions for NULL old_object. */ +GC_API GC_PTR GC_realloc + GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes)); + +/* Explicitly increase the heap size. */ +/* Returns 0 on failure, 1 on success. */ +GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes)); + +/* Limit the heap size to n bytes. Useful when you're debugging, */ +/* especially on systems that don't handle running out of memory well. */ +/* n == 0 ==> unbounded. This is the default. */ +GC_API void GC_set_max_heap_size GC_PROTO((GC_word n)); + +/* Inform the collector that a certain section of statically allocated */ +/* memory contains no pointers to garbage collected memory. Thus it */ +/* need not be scanned. This is sometimes important if the application */ +/* maps large read/write files into the address space, which could be */ +/* mistaken for dynamic library data segments on some systems. */ +GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish)); + +/* Clear the set of root segments. Wizards only. */ +GC_API void GC_clear_roots GC_PROTO((void)); + +/* Add a root segment. Wizards only. */ +GC_API void GC_add_roots GC_PROTO((char * low_address, + char * high_address_plus_1)); + +/* Add a displacement to the set of those considered valid by the */ +/* collector. GC_register_displacement(n) means that if p was returned */ +/* by GC_malloc, then (char *)p + n will be considered to be a valid */ +/* pointer to n. N must be small and less than the size of p. */ +/* (All pointers to the interior of objects from the stack are */ +/* considered valid in any case. This applies to heap objects and */ +/* static data.) */ +/* Preferably, this should be called before any other GC procedures. */ +/* Calling it later adds to the probability of excess memory */ +/* retention. */ +/* This is a no-op if the collector was compiled with recognition of */ +/* arbitrary interior pointers enabled, which is now the default. */ +GC_API void GC_register_displacement GC_PROTO((GC_word n)); + +/* The following version should be used if any debugging allocation is */ +/* being done. */ +GC_API void GC_debug_register_displacement GC_PROTO((GC_word n)); + +/* Explicitly trigger a full, world-stop collection. */ +GC_API void GC_gcollect GC_PROTO((void)); + +/* Trigger a full world-stopped collection. Abort the collection if */ +/* and when stop_func returns a nonzero value. Stop_func will be */ +/* called frequently, and should be reasonably fast. This works even */ +/* if virtual dirty bits, and hence incremental collection is not */ +/* available for this architecture. Collections can be aborted faster */ +/* than normal pause times for incremental collection. However, */ +/* aborted collections do no useful work; the next collection needs */ +/* to start from the beginning. */ +typedef int (* GC_stop_func) GC_PROTO((void)); +GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func)); + +/* Return the number of bytes in the heap. Excludes collector private */ +/* data structures. Includes empty blocks and fragmentation loss. */ +/* Includes some pages that were allocated but never written. */ +GC_API size_t GC_get_heap_size GC_PROTO((void)); + +/* Return the number of bytes allocated since the last collection. */ +GC_API size_t GC_get_bytes_since_gc GC_PROTO((void)); + +/* Enable incremental/generational collection. */ +/* Not advisable unless dirty bits are */ +/* available or most heap objects are */ +/* pointerfree(atomic) or immutable. */ +/* Don't use in leak finding mode. */ +/* Ignored if GC_dont_gc is true. */ +GC_API void GC_enable_incremental GC_PROTO((void)); + +/* Perform some garbage collection work, if appropriate. */ +/* Return 0 if there is no more work to be done. */ +/* Typically performs an amount of work corresponding roughly */ +/* to marking from one page. May do more work if further */ +/* progress requires it, e.g. if incremental collection is */ +/* disabled. It is reasonable to call this in a wait loop */ +/* until it returns 0. */ +GC_API int GC_collect_a_little GC_PROTO((void)); + +/* Allocate an object of size lb bytes. The client guarantees that */ +/* as long as the object is live, it will be referenced by a pointer */ +/* that points to somewhere within the first 256 bytes of the object. */ +/* (This should normally be declared volatile to prevent the compiler */ +/* from invalidating this assertion.) This routine is only useful */ +/* if a large array is being allocated. It reduces the chance of */ +/* accidentally retaining such an array as a result of scanning an */ +/* integer that happens to be an address inside the array. (Actually, */ +/* it reduces the chance of the allocator not finding space for such */ +/* an array, since it will try hard to avoid introducing such a false */ +/* reference.) On a SunOS 4.X or MS Windows system this is recommended */ +/* for arrays likely to be larger than 100K or so. For other systems, */ +/* or if the collector is not configured to recognize all interior */ +/* pointers, the threshold is normally much higher. */ +GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb)); +GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb)); + +#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720 +# define GC_ADD_CALLER +# define GC_RETURN_ADDR (GC_word)__return_address +#endif + +#ifdef GC_ADD_CALLER +# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__ +# define GC_EXTRA_PARAMS GC_word ra, char * descr_string, int descr_int +#else +# define GC_EXTRAS __FILE__, __LINE__ +# define GC_EXTRA_PARAMS char * descr_string, int descr_int +#endif + +/* Debugging (annotated) allocation. GC_gcollect will check */ +/* objects allocated in this way for overwrites, etc. */ +GC_API GC_PTR GC_debug_malloc + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_atomic + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_uncollectable + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API GC_PTR GC_debug_malloc_stubborn + GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS)); +GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr)); +GC_API GC_PTR GC_debug_realloc + GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes, + GC_EXTRA_PARAMS)); + +GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR)); +GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR)); +# ifdef GC_DEBUG +# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS) +# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS) +# define GC_MALLOC_UNCOLLECTABLE(sz) GC_debug_malloc_uncollectable(sz, \ + GC_EXTRAS) +# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS) +# define GC_FREE(p) GC_debug_free(p) +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_debug_register_finalizer(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \ + GC_debug_register_finalizer_ignore_self(p, f, d, of, od) +# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS); +# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p) +# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p) +# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \ + GC_general_register_disappearing_link(link, GC_base(obj)) +# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n) +# else +# define GC_MALLOC(sz) GC_malloc(sz) +# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz) +# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz) +# define GC_REALLOC(old, sz) GC_realloc(old, sz) +# define GC_FREE(p) GC_free(p) +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_register_finalizer(p, f, d, of, od) +# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \ + GC_register_finalizer_ignore_self(p, f, d, of, od) +# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz) +# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p) +# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p) +# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \ + GC_general_register_disappearing_link(link, obj) +# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n) +# endif +/* The following are included because they are often convenient, and */ +/* reduce the chance for a misspecifed size argument. But calls may */ +/* expand to something syntactically incorrect if t is a complicated */ +/* type expression. */ +# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t)) +# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t)) +# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t)) +# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t)) + +/* Finalization. Some of these primitives are grossly unsafe. */ +/* The idea is to make them both cheap, and sufficient to build */ +/* a safer layer, closer to PCedar finalization. */ +/* The interface represents my conclusions from a long discussion */ +/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */ +/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */ +/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */ +typedef void (*GC_finalization_proc) + GC_PROTO((GC_PTR obj, GC_PTR client_data)); + +GC_API void GC_register_finalizer + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); +GC_API void GC_debug_register_finalizer + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); + /* When obj is no longer accessible, invoke */ + /* (*fn)(obj, cd). If a and b are inaccessible, and */ + /* a points to b (after disappearing links have been */ + /* made to disappear), then only a will be */ + /* finalized. (If this does not create any new */ + /* pointers to b, then b will be finalized after the */ + /* next collection.) Any finalizable object that */ + /* is reachable from itself by following one or more */ + /* pointers will not be finalized (or collected). */ + /* Thus cycles involving finalizable objects should */ + /* be avoided, or broken by disappearing links. */ + /* All but the last finalizer registered for an object */ + /* is ignored. */ + /* Finalization may be removed by passing 0 as fn. */ + /* Finalizers are implicitly unregistered just before */ + /* they are invoked. */ + /* The old finalizer and client data are stored in */ + /* *ofn and *ocd. */ + /* Fn is never invoked on an accessible object, */ + /* provided hidden pointers are converted to real */ + /* pointers only if the allocation lock is held, and */ + /* such conversions are not performed by finalization */ + /* routines. */ + /* If GC_register_finalizer is aborted as a result of */ + /* a signal, the object may be left with no */ + /* finalization, even if neither the old nor new */ + /* finalizer were NULL. */ + /* Obj should be the nonNULL starting address of an */ + /* object allocated by GC_malloc or friends. */ + /* Note that any garbage collectable object referenced */ + /* by cd will be considered accessible until the */ + /* finalizer is invoked. */ + +/* Another versions of the above follow. It ignores */ +/* self-cycles, i.e. pointers from a finalizable object to */ +/* itself. There is a stylistic argument that this is wrong, */ +/* but it's unavoidable for C++, since the compiler may */ +/* silently introduce these. It's also benign in that specific */ +/* case. */ +GC_API void GC_register_finalizer_ignore_self + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); +GC_API void GC_debug_register_finalizer_ignore_self + GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR *ocd)); + +/* The following routine may be used to break cycles between */ +/* finalizable objects, thus causing cyclic finalizable */ +/* objects to be finalized in the correct order. Standard */ +/* use involves calling GC_register_disappearing_link(&p), */ +/* where p is a pointer that is not followed by finalization */ +/* code, and should not be considered in determining */ +/* finalization order. */ +GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */)); + /* Link should point to a field of a heap allocated */ + /* object obj. *link will be cleared when obj is */ + /* found to be inaccessible. This happens BEFORE any */ + /* finalization code is invoked, and BEFORE any */ + /* decisions about finalization order are made. */ + /* This is useful in telling the finalizer that */ + /* some pointers are not essential for proper */ + /* finalization. This may avoid finalization cycles. */ + /* Note that obj may be resurrected by another */ + /* finalizer, and thus the clearing of *link may */ + /* be visible to non-finalization code. */ + /* There's an argument that an arbitrary action should */ + /* be allowed here, instead of just clearing a pointer. */ + /* But this causes problems if that action alters, or */ + /* examines connectivity. */ + /* Returns 1 if link was already registered, 0 */ + /* otherwise. */ + /* Only exists for backward compatibility. See below: */ + +GC_API int GC_general_register_disappearing_link + GC_PROTO((GC_PTR * /* link */, GC_PTR obj)); + /* A slight generalization of the above. *link is */ + /* cleared when obj first becomes inaccessible. This */ + /* can be used to implement weak pointers easily and */ + /* safely. Typically link will point to a location */ + /* holding a disguised pointer to obj. (A pointer */ + /* inside an "atomic" object is effectively */ + /* disguised.) In this way soft */ + /* pointers are broken before any object */ + /* reachable from them are finalized. Each link */ + /* May be registered only once, i.e. with one obj */ + /* value. This was added after a long email discussion */ + /* with John Ellis. */ + /* Obj must be a pointer to the first word of an object */ + /* we allocated. It is unsafe to explicitly deallocate */ + /* the object containing link. Explicitly deallocating */ + /* obj may or may not cause link to eventually be */ + /* cleared. */ +GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */)); + /* Returns 0 if link was not actually registered. */ + /* Undoes a registration by either of the above two */ + /* routines. */ + +/* Auxiliary fns to make finalization work correctly with displaced */ +/* pointers introduced by the debugging allocators. */ +GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data)); +GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data)); + +GC_API int GC_invoke_finalizers GC_PROTO((void)); + /* Run finalizers for all objects that are ready to */ + /* be finalized. Return the number of finalizers */ + /* that were run. Normally this is also called */ + /* implicitly during some allocations. If */ + /* FINALIZE_ON_DEMAND is defined, it must be called */ + /* explicitly. */ + +/* GC_set_warn_proc can be used to redirect or filter warning messages. */ +/* p may not be a NULL pointer. */ +typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg)); +GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p)); + /* Returns old warning procedure. */ + +/* The following is intended to be used by a higher level */ +/* (e.g. cedar-like) finalization facility. It is expected */ +/* that finalization code will arrange for hidden pointers to */ +/* disappear. Otherwise objects can be accessed after they */ +/* have been collected. */ +/* Note that putting pointers in atomic objects or in */ +/* nonpointer slots of "typed" objects is equivalent to */ +/* disguising them in this way, and may have other advantages. */ +# if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS) + typedef GC_word GC_hidden_pointer; +# define HIDE_POINTER(p) (~(GC_hidden_pointer)(p)) +# define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p))) + /* Converting a hidden pointer to a real pointer requires verifying */ + /* that the object still exists. This involves acquiring the */ + /* allocator lock to avoid a race with the collector. */ +# endif /* I_HIDE_POINTERS */ + +typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data)); +GC_API GC_PTR GC_call_with_alloc_lock + GC_PROTO((GC_fn_type fn, GC_PTR client_data)); + +/* Check that p and q point to the same object. */ +/* Fail conspicuously if they don't. */ +/* Returns the first argument. */ +/* Succeeds if neither p nor q points to the heap. */ +/* May succeed if both p and q point to between heap objects. */ +GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q)); + +/* Checked pointer pre- and post- increment operations. Note that */ +/* the second argument is in units of bytes, not multiples of the */ +/* object size. This should either be invoked from a macro, or the */ +/* call should be automatically generated. */ +GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much)); +GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much)); + +/* Check that p is visible */ +/* to the collector as a possibly pointer containing location. */ +/* If it isn't fail conspicuously. */ +/* Returns the argument in all cases. May erroneously succeed */ +/* in hard cases. (This is intended for debugging use with */ +/* untyped allocations. The idea is that it should be possible, though */ +/* slow, to add such a call to all indirect pointer stores.) */ +/* Currently useless for multithreaded worlds. */ +GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p)); + +/* Check that if p is a pointer to a heap page, then it points to */ +/* a valid displacement within a heap object. */ +/* Fail conspicuously if this property does not hold. */ +/* Uninteresting with ALL_INTERIOR_POINTERS. */ +/* Always returns its argument. */ +GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p)); + +/* Safer, but slow, pointer addition. Probably useful mainly with */ +/* a preprocessor. Useful only for heap pointers. */ +#ifdef GC_DEBUG +# define GC_PTR_ADD3(x, n, type_of_result) \ + ((type_of_result)GC_same_obj((x)+(n), (x))) +# define GC_PRE_INCR3(x, n, type_of_result) \ + ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x)) +# define GC_POST_INCR2(x, type_of_result) \ + ((type_of_result)GC_post_incr(&(x), sizeof(*x)) +# ifdef __GNUC__ +# define GC_PTR_ADD(x, n) \ + GC_PTR_ADD3(x, n, typeof(x)) +# define GC_PRE_INCR(x, n) \ + GC_PRE_INCR3(x, n, typeof(x)) +# define GC_POST_INCR(x, n) \ + GC_POST_INCR3(x, typeof(x)) +# else + /* We can't do this right without typeof, which ANSI */ + /* decided was not sufficiently useful. Repeatedly */ + /* mentioning the arguments seems too dangerous to be */ + /* useful. So does not casting the result. */ +# define GC_PTR_ADD(x, n) ((x)+(n)) +# endif +#else /* !GC_DEBUG */ +# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n)) +# define GC_PTR_ADD(x, n) ((x)+(n)) +# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n)) +# define GC_PRE_INCR(x, n) ((x) += (n)) +# define GC_POST_INCR2(x, n, type_of_result) ((x)++) +# define GC_POST_INCR(x, n) ((x)++) +#endif + +/* Safer assignment of a pointer to a nonstack location. */ +#ifdef GC_DEBUG +# ifdef __STDC__ +# define GC_PTR_STORE(p, q) \ + (*(void **)GC_is_visible(p) = GC_is_valid_displacement(q)) +# else +# define GC_PTR_STORE(p, q) \ + (*(char **)GC_is_visible(p) = GC_is_valid_displacement(q)) +# endif +#else /* !GC_DEBUG */ +# define GC_PTR_STORE(p, q) *((p) = (q)) +#endif + +/* Fynctions called to report pointer checking errors */ +GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q)); + +GC_API void (*GC_is_valid_displacement_print_proc) + GC_PROTO((GC_PTR p)); + +GC_API void (*GC_is_visible_print_proc) + GC_PROTO((GC_PTR p)); + +#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) +# define SOLARIS_THREADS +#endif + +#ifdef SOLARIS_THREADS +/* We need to intercept calls to many of the threads primitives, so */ +/* that we can locate thread stacks and stop the world. */ +/* Note also that the collector cannot see thread specific data. */ +/* Thread specific data should generally consist of pointers to */ +/* uncollectable objects, which are deallocated using the destructor */ +/* facility in thr_keycreate. */ +# include +# include + int GC_thr_create(void *stack_base, size_t stack_size, + void *(*start_routine)(void *), void *arg, long flags, + thread_t *new_thread); + int GC_thr_join(thread_t wait_for, thread_t *departed, void **status); + int GC_thr_suspend(thread_t target_thread); + int GC_thr_continue(thread_t target_thread); + void * GC_dlopen(const char *path, int mode); + +# ifdef _SOLARIS_PTHREADS +# include + extern int GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void * (*thread_execp)(void *), void *arg); + extern int GC_pthread_join(pthread_t wait_for, void **status); + +# undef thread_t + +# define pthread_join GC_pthread_join +# define pthread_create GC_pthread_create +#endif + +# define thr_create GC_thr_create +# define thr_join GC_thr_join +# define thr_suspend GC_thr_suspend +# define thr_continue GC_thr_continue +# define dlopen GC_dlopen + +# endif /* SOLARIS_THREADS */ + + +#if defined(IRIX_THREADS) || defined(LINUX_THREADS) +/* We treat these similarly. */ +# include +# include + + int GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void *(*start_routine)(void *), void *arg); + int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset); + int GC_pthread_join(pthread_t thread, void **retval); + +# define pthread_create GC_pthread_create +# define pthread_sigmask GC_pthread_sigmask +# define pthread_join GC_pthread_join + +#endif /* IRIX_THREADS || LINUX_THREADS */ + +# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ + defined(IRIX_THREADS) || defined(LINUX_THREADS) || \ + defined(IRIX_JDK_THREADS) + /* Any flavor of threads except SRC_M3. */ +/* This returns a list of objects, linked through their first */ +/* word. Its use can greatly reduce lock contention problems, since */ +/* the allocation lock can be acquired and released many fewer times. */ +GC_PTR GC_malloc_many(size_t lb); +#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */ + /* in returned list. */ +extern void GC_thr_init(); /* Needed for Solaris/X86 */ + +#endif /* THREADS && !SRC_M3 */ + +/* + * If you are planning on putting + * the collector in a SunOS 5 dynamic library, you need to call GC_INIT() + * from the statically loaded program section. + * This circumvents a Solaris 2.X (X<=4) linker bug. + */ +#if defined(sparc) || defined(__sparc) +# define GC_INIT() { extern end, etext; \ + GC_noop(&end, &etext); } +#else +# if defined(__CYGWIN32__) && defined(GC_USE_DLL) + /* + * Similarly gnu-win32 DLLs need explicit initialization + */ +# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); } +# else +# define GC_INIT() +# endif +#endif + +#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \ + || defined(_WIN32) + /* win32S may not free all resources on process exit. */ + /* This explicitly deallocates the heap. */ + GC_API void GC_win32_free_heap (); +#endif + +#ifdef __cplusplus + } /* end of extern "C" */ +#endif + +#endif /* _GC_H */ diff --git a/support/gc/include/gc_alloc.h b/support/gc/include/gc_alloc.h new file mode 100644 index 00000000..1d912db2 --- /dev/null +++ b/support/gc/include/gc_alloc.h @@ -0,0 +1,380 @@ +/* + * Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +// +// This is a C++ header file that is intended to replace the SGI STL +// alloc.h. +// +// This assumes the collector has been compiled with -DATOMIC_UNCOLLECTABLE +// and -DALL_INTERIOR_POINTERS. We also recommend +// -DREDIRECT_MALLOC=GC_uncollectable_malloc. +// +// Some of this could be faster in the explicit deallocation case. In particular, +// we spend too much time clearing objects on the free lists. That could be avoided. +// +// This uses template classes with static members, and hence does not work +// with g++ 2.7.2 and earlier. +// + +#include "gc.h" + +#ifndef GC_ALLOC_H + +#define GC_ALLOC_H +#define __ALLOC_H // Prevent inclusion of the default version. Ugly. +#define __SGI_STL_ALLOC_H +#define __SGI_STL_INTERNAL_ALLOC_H + +#ifndef __ALLOC +# define __ALLOC alloc +#endif + +#include +#include + +// The following is just replicated from the conventional SGI alloc.h: + +template +class simple_alloc { + +public: + static T *allocate(size_t n) + { return 0 == n? 0 : (T*) alloc::allocate(n * sizeof (T)); } + static T *allocate(void) + { return (T*) alloc::allocate(sizeof (T)); } + static void deallocate(T *p, size_t n) + { if (0 != n) alloc::deallocate(p, n * sizeof (T)); } + static void deallocate(T *p) + { alloc::deallocate(p, sizeof (T)); } +}; + +#include "gc.h" + +// The following need to match collector data structures. +// We can't include gc_priv.h, since that pulls in way too much stuff. +// This should eventually be factored out into another include file. + +extern "C" { + extern void ** const GC_objfreelist_ptr; + extern void ** const GC_aobjfreelist_ptr; + extern void ** const GC_uobjfreelist_ptr; + extern void ** const GC_auobjfreelist_ptr; + + extern void GC_incr_words_allocd(size_t words); + extern void GC_incr_mem_freed(size_t words); + + extern char * GC_generic_malloc_words_small(size_t word, int kind); +} + +// Object kinds; must match PTRFREE, NORMAL, UNCOLLECTABLE, and +// AUNCOLLECTABLE in gc_priv.h. + +enum { GC_PTRFREE = 0, GC_NORMAL = 1, GC_UNCOLLECTABLE = 2, + GC_AUNCOLLECTABLE = 3 }; + +enum { GC_max_fast_bytes = 255 }; + +enum { GC_bytes_per_word = sizeof(char *) }; + +enum { GC_byte_alignment = 8 }; + +enum { GC_word_alignment = GC_byte_alignment/GC_bytes_per_word }; + +inline void * &GC_obj_link(void * p) +{ return *(void **)p; } + +// Compute a number of words >= n+1 bytes. +// The +1 allows for pointers one past the end. +inline size_t GC_round_up(size_t n) +{ + return ((n + GC_byte_alignment)/GC_byte_alignment)*GC_word_alignment; +} + +// The same but don't allow for extra byte. +inline size_t GC_round_up_uncollectable(size_t n) +{ + return ((n + GC_byte_alignment - 1)/GC_byte_alignment)*GC_word_alignment; +} + +template +class GC_aux_template { +public: + // File local count of allocated words. Occasionally this is + // added into the global count. A separate count is necessary since the + // real one must be updated with a procedure call. + static size_t GC_words_recently_allocd; + + // Same for uncollectable mmory. Not yet reflected in either + // GC_words_recently_allocd or GC_non_gc_bytes. + static size_t GC_uncollectable_words_recently_allocd; + + // Similar counter for explicitly deallocated memory. + static size_t GC_mem_recently_freed; + + // Again for uncollectable memory. + static size_t GC_uncollectable_mem_recently_freed; + + static void * GC_out_of_line_malloc(size_t nwords, int kind); +}; + +template +size_t GC_aux_template::GC_words_recently_allocd = 0; + +template +size_t GC_aux_template::GC_uncollectable_words_recently_allocd = 0; + +template +size_t GC_aux_template::GC_mem_recently_freed = 0; + +template +size_t GC_aux_template::GC_uncollectable_mem_recently_freed = 0; + +template +void * GC_aux_template::GC_out_of_line_malloc(size_t nwords, int kind) +{ + GC_words_recently_allocd += GC_uncollectable_words_recently_allocd; + GC_non_gc_bytes += + GC_bytes_per_word * GC_uncollectable_words_recently_allocd; + GC_uncollectable_words_recently_allocd = 0; + + GC_mem_recently_freed += GC_uncollectable_mem_recently_freed; + GC_non_gc_bytes -= + GC_bytes_per_word * GC_uncollectable_mem_recently_freed; + GC_uncollectable_mem_recently_freed = 0; + + GC_incr_words_allocd(GC_words_recently_allocd); + GC_words_recently_allocd = 0; + + GC_incr_mem_freed(GC_mem_recently_freed); + GC_mem_recently_freed = 0; + + return GC_generic_malloc_words_small(nwords, kind); +} + +typedef GC_aux_template<0> GC_aux; + +// A fast, single-threaded, garbage-collected allocator +// We assume the first word will be immediately overwritten. +// In this version, deallocation is not a noop, and explicit +// deallocation is likely to help performance. +template +class single_client_gc_alloc_template { + public: + static void * allocate(size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc(n); + flh = GC_objfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_NORMAL); + } + *flh = GC_obj_link(op); + GC_aux::GC_words_recently_allocd += nwords; + return op; + } + static void * ptr_free_allocate(size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_atomic(n); + flh = GC_aobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_PTRFREE); + } + *flh = GC_obj_link(op); + GC_aux::GC_words_recently_allocd += nwords; + return op; + } + static void deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_objfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + memset((char *)p + GC_bytes_per_word, 0, + GC_bytes_per_word * (nwords - 1)); + *flh = p; + GC_aux::GC_mem_recently_freed += nwords; + } + } + static void ptr_free_deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_aobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_mem_recently_freed += nwords; + } + } +}; + +typedef single_client_gc_alloc_template<0> single_client_gc_alloc; + +// Once more, for uncollectable objects. +template +class single_client_alloc_template { + public: + static void * allocate(size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_uncollectable(n); + flh = GC_uobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_UNCOLLECTABLE); + } + *flh = GC_obj_link(op); + GC_aux::GC_uncollectable_words_recently_allocd += nwords; + return op; + } + static void * ptr_free_allocate(size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_atomic_uncollectable(n); + flh = GC_auobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_AUNCOLLECTABLE); + } + *flh = GC_obj_link(op); + GC_aux::GC_uncollectable_words_recently_allocd += nwords; + return op; + } + static void deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_uobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_uncollectable_mem_recently_freed += nwords; + } + } + static void ptr_free_deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_auobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_uncollectable_mem_recently_freed += nwords; + } + } +}; + +typedef single_client_alloc_template<0> single_client_alloc; + +template < int dummy > +class gc_alloc_template { + public: + static void * allocate(size_t n) { return GC_malloc(n); } + static void * ptr_free_allocate(size_t n) + { return GC_malloc_atomic(n); } + static void deallocate(void *, size_t) { } + static void ptr_free_deallocate(void *, size_t) { } +}; + +typedef gc_alloc_template < 0 > gc_alloc; + +template < int dummy > +class alloc_template { + public: + static void * allocate(size_t n) { return GC_malloc_uncollectable(n); } + static void * ptr_free_allocate(size_t n) + { return GC_malloc_atomic_uncollectable(n); } + static void deallocate(void *p, size_t) { GC_free(p); } + static void ptr_free_deallocate(void *p, size_t) { GC_free(p); } +}; + +typedef alloc_template < 0 > alloc; + +#ifdef _SGI_SOURCE + +// We want to specialize simple_alloc so that it does the right thing +// for all pointerfree types. At the moment there is no portable way to +// even approximate that. The following approximation should work for +// SGI compilers, and perhaps some others. + +# define __GC_SPECIALIZE(T,alloc) \ +class simple_alloc { \ +public: \ + static T *allocate(size_t n) \ + { return 0 == n? 0 : \ + (T*) alloc::ptr_free_allocate(n * sizeof (T)); } \ + static T *allocate(void) \ + { return (T*) alloc::ptr_free_allocate(sizeof (T)); } \ + static void deallocate(T *p, size_t n) \ + { if (0 != n) alloc::ptr_free_deallocate(p, n * sizeof (T)); } \ + static void deallocate(T *p) \ + { alloc::ptr_free_deallocate(p, sizeof (T)); } \ +}; + +__GC_SPECIALIZE(char, gc_alloc) +__GC_SPECIALIZE(int, gc_alloc) +__GC_SPECIALIZE(unsigned, gc_alloc) +__GC_SPECIALIZE(float, gc_alloc) +__GC_SPECIALIZE(double, gc_alloc) + +__GC_SPECIALIZE(char, alloc) +__GC_SPECIALIZE(int, alloc) +__GC_SPECIALIZE(unsigned, alloc) +__GC_SPECIALIZE(float, alloc) +__GC_SPECIALIZE(double, alloc) + +__GC_SPECIALIZE(char, single_client_gc_alloc) +__GC_SPECIALIZE(int, single_client_gc_alloc) +__GC_SPECIALIZE(unsigned, single_client_gc_alloc) +__GC_SPECIALIZE(float, single_client_gc_alloc) +__GC_SPECIALIZE(double, single_client_gc_alloc) + +__GC_SPECIALIZE(char, single_client_alloc) +__GC_SPECIALIZE(int, single_client_alloc) +__GC_SPECIALIZE(unsigned, single_client_alloc) +__GC_SPECIALIZE(float, single_client_alloc) +__GC_SPECIALIZE(double, single_client_alloc) + +#ifdef __STL_USE_STD_ALLOCATORS + +???copy stuff from stl_alloc.h or remove it to a different file ??? + +#endif /* __STL_USE_STD_ALLOCATORS */ + +#endif /* _SGI_SOURCE */ + +#endif /* GC_ALLOC_H */ diff --git a/support/gc/include/gc_cpp.h b/support/gc/include/gc_cpp.h new file mode 100644 index 00000000..a591d368 --- /dev/null +++ b/support/gc/include/gc_cpp.h @@ -0,0 +1,288 @@ +#ifndef GC_CPP_H +#define GC_CPP_H +/**************************************************************************** +Copyright (c) 1994 by Xerox Corporation. All rights reserved. + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + +Permission is hereby granted to use or copy this program for any +purpose, provided the above notices are retained on all copies. +Permission to modify the code and to distribute modified code is +granted, provided the above notices are retained, and a notice that +the code was modified is included with the above copyright notice. +**************************************************************************** + +C++ Interface to the Boehm Collector + + John R. Ellis and Jesse Hull + Last modified on Mon Jul 24 15:43:42 PDT 1995 by ellis + +This interface provides access to the Boehm collector. It provides +basic facilities similar to those described in "Safe, Efficient +Garbage Collection for C++", by John R. Elis and David L. Detlefs +(ftp.parc.xerox.com:/pub/ellis/gc). + +All heap-allocated objects are either "collectable" or +"uncollectable". Programs must explicitly delete uncollectable +objects, whereas the garbage collector will automatically delete +collectable objects when it discovers them to be inaccessible. +Collectable objects may freely point at uncollectable objects and vice +versa. + +Objects allocated with the built-in "::operator new" are uncollectable. + +Objects derived from class "gc" are collectable. For example: + + class A: public gc {...}; + A* a = new A; // a is collectable. + +Collectable instances of non-class types can be allocated using the GC +placement: + + typedef int A[ 10 ]; + A* a = new (GC) A; + +Uncollectable instances of classes derived from "gc" can be allocated +using the NoGC placement: + + class A: public gc {...}; + A* a = new (NoGC) A; // a is uncollectable. + +Both uncollectable and collectable objects can be explicitly deleted +with "delete", which invokes an object's destructors and frees its +storage immediately. + +A collectable object may have a clean-up function, which will be +invoked when the collector discovers the object to be inaccessible. +An object derived from "gc_cleanup" or containing a member derived +from "gc_cleanup" has a default clean-up function that invokes the +object's destructors. Explicit clean-up functions may be specified as +an additional placement argument: + + A* a = ::new (GC, MyCleanup) A; + +An object is considered "accessible" by the collector if it can be +reached by a path of pointers from static variables, automatic +variables of active functions, or from some object with clean-up +enabled; pointers from an object to itself are ignored. + +Thus, if objects A and B both have clean-up functions, and A points at +B, B is considered accessible. After A's clean-up is invoked and its +storage released, B will then become inaccessible and will have its +clean-up invoked. If A points at B and B points to A, forming a +cycle, then that's considered a storage leak, and neither will be +collectable. See the interface gc.h for low-level facilities for +handling such cycles of objects with clean-up. + +The collector cannot guarrantee that it will find all inaccessible +objects. In practice, it finds almost all of them. + + +Cautions: + +1. Be sure the collector has been augmented with "make c++". + +2. If your compiler supports the new "operator new[]" syntax, then +add -DOPERATOR_NEW_ARRAY to the Makefile. + +If your compiler doesn't support "operator new[]", beware that an +array of type T, where T is derived from "gc", may or may not be +allocated as a collectable object (it depends on the compiler). Use +the explicit GC placement to make the array collectable. For example: + + class A: public gc {...}; + A* a1 = new A[ 10 ]; // collectable or uncollectable? + A* a2 = new (GC) A[ 10 ]; // collectable + +3. The destructors of collectable arrays of objects derived from +"gc_cleanup" will not be invoked properly. For example: + + class A: public gc_cleanup {...}; + A* a = new (GC) A[ 10 ]; // destructors not invoked correctly + +Typically, only the destructor for the first element of the array will +be invoked when the array is garbage-collected. To get all the +destructors of any array executed, you must supply an explicit +clean-up function: + + A* a = new (GC, MyCleanUp) A[ 10 ]; + +(Implementing clean-up of arrays correctly, portably, and in a way +that preserves the correct exception semantics requires a language +extension, e.g. the "gc" keyword.) + +4. Compiler bugs: + +* Solaris 2's CC (SC3.0) doesn't implement t->~T() correctly, so the +destructors of classes derived from gc_cleanup won't be invoked. +You'll have to explicitly register a clean-up function with +new-placement syntax. + +* Evidently cfront 3.0 does not allow destructors to be explicitly +invoked using the ANSI-conforming syntax t->~T(). If you're using +cfront 3.0, you'll have to comment out the class gc_cleanup, which +uses explicit invocation. + +****************************************************************************/ + +#include "gc.h" + +#ifndef THINK_CPLUS +#define _cdecl +#endif + +#if ! defined( OPERATOR_NEW_ARRAY ) \ + && (__BORLANDC__ >= 0x450 || (__GNUC__ >= 2 && __GNUC_MINOR__ >= 6) \ + || __WATCOMC__ >= 1050) +# define OPERATOR_NEW_ARRAY +#endif + +enum GCPlacement {GC, NoGC, PointerFreeGC}; + +class gc {public: + inline void* operator new( size_t size ); + inline void* operator new( size_t size, GCPlacement gcp ); + inline void operator delete( void* obj ); + +#ifdef OPERATOR_NEW_ARRAY + inline void* operator new[]( size_t size ); + inline void* operator new[]( size_t size, GCPlacement gcp ); + inline void operator delete[]( void* obj ); +#endif /* OPERATOR_NEW_ARRAY */ + }; + /* + Instances of classes derived from "gc" will be allocated in the + collected heap by default, unless an explicit NoGC placement is + specified. */ + +class gc_cleanup: virtual public gc {public: + inline gc_cleanup(); + inline virtual ~gc_cleanup(); +private: + inline static void _cdecl cleanup( void* obj, void* clientData );}; + /* + Instances of classes derived from "gc_cleanup" will be allocated + in the collected heap by default. When the collector discovers an + inaccessible object derived from "gc_cleanup" or containing a + member derived from "gc_cleanup", its destructors will be + invoked. */ + +extern "C" {typedef void (*GCCleanUpFunc)( void* obj, void* clientData );} + +inline void* operator new( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup = 0, + void* clientData = 0 ); + /* + Allocates a collectable or uncollected object, according to the + value of "gcp". + + For collectable objects, if "cleanup" is non-null, then when the + allocated object "obj" becomes inaccessible, the collector will + invoke the function "cleanup( obj, clientData )" but will not + invoke the object's destructors. It is an error to explicitly + delete an object allocated with a non-null "cleanup". + + It is an error to specify a non-null "cleanup" with NoGC or for + classes derived from "gc_cleanup" or containing members derived + from "gc_cleanup". */ + +#ifdef OPERATOR_NEW_ARRAY + +inline void* operator new[]( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup = 0, + void* clientData = 0 ); + /* + The operator new for arrays, identical to the above. */ + +#endif /* OPERATOR_NEW_ARRAY */ + +/**************************************************************************** + +Inline implementation + +****************************************************************************/ + +inline void* gc::operator new( size_t size ) { + return GC_MALLOC( size );} + +inline void* gc::operator new( size_t size, GCPlacement gcp ) { + if (gcp == GC) + return GC_MALLOC( size ); + else + return GC_MALLOC_UNCOLLECTABLE( size );} + +inline void gc::operator delete( void* obj ) { + GC_FREE( obj );} + + +#ifdef OPERATOR_NEW_ARRAY + +inline void* gc::operator new[]( size_t size ) { + return gc::operator new( size );} + +inline void* gc::operator new[]( size_t size, GCPlacement gcp ) { + return gc::operator new( size, gcp );} + +inline void gc::operator delete[]( void* obj ) { + gc::operator delete( obj );} + +#endif /* OPERATOR_NEW_ARRAY */ + + +inline gc_cleanup::~gc_cleanup() { + GC_REGISTER_FINALIZER_IGNORE_SELF( this, 0, 0, 0, 0 );} + +inline void gc_cleanup::cleanup( void* obj, void* displ ) { + ((gc_cleanup*) ((char*) obj + (ptrdiff_t) displ))->~gc_cleanup();} + +inline gc_cleanup::gc_cleanup() { + GC_finalization_proc oldProc; + void* oldData; + void* base = GC_base( (void *) this ); + if (0 == base) return; + GC_REGISTER_FINALIZER_IGNORE_SELF( + base, cleanup, (void*) ((char*) this - (char*) base), + &oldProc, &oldData ); + if (0 != oldProc) { + GC_REGISTER_FINALIZER_IGNORE_SELF( base, oldProc, oldData, 0, 0 );}} + +inline void* operator new( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup, + void* clientData ) +{ + void* obj; + + if (gcp == GC) { + obj = GC_MALLOC( size ); + if (cleanup != 0) + GC_REGISTER_FINALIZER_IGNORE_SELF( + obj, cleanup, clientData, 0, 0 );} + else if (gcp == PointerFreeGC) { + obj = GC_MALLOC_ATOMIC( size );} + else { + obj = GC_MALLOC_UNCOLLECTABLE( size );}; + return obj;} + + +#ifdef OPERATOR_NEW_ARRAY + +inline void* operator new[]( + size_t size, + GCPlacement gcp, + GCCleanUpFunc cleanup, + void* clientData ) +{ + return ::operator new( size, gcp, cleanup, clientData );} + +#endif /* OPERATOR_NEW_ARRAY */ + + +#endif /* GC_CPP_H */ + diff --git a/support/gc/include/gc_inl.h b/support/gc/include/gc_inl.h new file mode 100644 index 00000000..700843bb --- /dev/null +++ b/support/gc/include/gc_inl.h @@ -0,0 +1,103 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, October 3, 1995 2:07 pm PDT */ + +# ifndef GC_PRIVATE_H +# include "private/gc_priv.h" +# endif + +/* USE OF THIS FILE IS NOT RECOMMENDED unless the collector has been */ +/* compiled without -DALL_INTERIOR_POINTERS or with */ +/* -DDONT_ADD_BYTE_AT_END, or the specified size includes a pointerfree */ +/* word at the end. In the standard collector configuration, */ +/* the final word of each object may not be scanned. */ +/* This is most useful for compilers that generate C. */ +/* Manual use is hereby discouraged. */ + +/* Allocate n words (NOT BYTES). X is made to point to the result. */ +/* It is assumed that n < MAXOBJSZ, and */ +/* that n > 0. On machines requiring double word alignment of some */ +/* data, we also assume that n is 1 or even. This bypasses the */ +/* MERGE_SIZES mechanism. In order to minimize the number of distinct */ +/* free lists that are maintained, the caller should ensure that a */ +/* small number of distinct values of n are used. (The MERGE_SIZES */ +/* mechanism normally does this by ensuring that only the leading three */ +/* bits of n may be nonzero. See misc.c for details.) We really */ +/* recommend this only in cases in which n is a constant, and no */ +/* locking is required. */ +/* In that case it may allow the compiler to perform substantial */ +/* additional optimizations. */ +# define GC_MALLOC_WORDS(result,n) \ +{ \ + register ptr_t op; \ + register ptr_t *opp; \ + DCL_LOCK_STATE; \ + \ + opp = &(GC_objfreelist[n]); \ + FASTLOCK(); \ + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { \ + FASTUNLOCK(); \ + (result) = GC_generic_malloc_words_small((n), NORMAL); \ + } else { \ + *opp = obj_link(op); \ + obj_link(op) = 0; \ + GC_words_allocd += (n); \ + FASTUNLOCK(); \ + (result) = (GC_PTR) op; \ + } \ +} + + +/* The same for atomic objects: */ +# define GC_MALLOC_ATOMIC_WORDS(result,n) \ +{ \ + register ptr_t op; \ + register ptr_t *opp; \ + DCL_LOCK_STATE; \ + \ + opp = &(GC_aobjfreelist[n]); \ + FASTLOCK(); \ + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { \ + FASTUNLOCK(); \ + (result) = GC_generic_malloc_words_small((n), PTRFREE); \ + } else { \ + *opp = obj_link(op); \ + obj_link(op) = 0; \ + GC_words_allocd += (n); \ + FASTUNLOCK(); \ + (result) = (GC_PTR) op; \ + } \ +} + +/* And once more for two word initialized objects: */ +# define GC_CONS(result, first, second) \ +{ \ + register ptr_t op; \ + register ptr_t *opp; \ + DCL_LOCK_STATE; \ + \ + opp = &(GC_objfreelist[2]); \ + FASTLOCK(); \ + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { \ + FASTUNLOCK(); \ + op = GC_generic_malloc_words_small(2, NORMAL); \ + } else { \ + *opp = obj_link(op); \ + GC_words_allocd += 2; \ + FASTUNLOCK(); \ + } \ + ((word *)op)[0] = (word)(first); \ + ((word *)op)[1] = (word)(second); \ + (result) = (GC_PTR) op; \ +} diff --git a/support/gc/include/gc_inline.h b/support/gc/include/gc_inline.h new file mode 100644 index 00000000..db62d1d5 --- /dev/null +++ b/support/gc/include/gc_inline.h @@ -0,0 +1 @@ +# include "gc_inl.h" diff --git a/support/gc/include/gc_typed.h b/support/gc/include/gc_typed.h new file mode 100644 index 00000000..e4a6b947 --- /dev/null +++ b/support/gc/include/gc_typed.h @@ -0,0 +1,91 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright 1996 Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* + * Some simple primitives for allocation with explicit type information. + * Facilities for dynamic type inference may be added later. + * Should be used only for extremely performance critical applications, + * or if conservative collector leakage is otherwise a problem (unlikely). + * Note that this is implemented completely separately from the rest + * of the collector, and is not linked in unless referenced. + * This does not currently support GC_DEBUG in any interesting way. + */ +/* Boehm, May 19, 1994 2:13 pm PDT */ + +#ifndef _GC_TYPED_H +# define _GC_TYPED_H +# ifndef _GC_H +# include "gc.h" +# endif + +typedef GC_word * GC_bitmap; + /* The least significant bit of the first word is one if */ + /* the first word in the object may be a pointer. */ + +# define GC_get_bit(bm, index) \ + (((bm)[divWORDSZ(index)] >> modWORDSZ(index)) & 1) +# define GC_set_bit(bm, index) \ + (bm)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index) + +typedef GC_word GC_descr; + +GC_API GC_descr GC_make_descriptor GC_PROTO((GC_bitmap bm, size_t len)); + /* Return a type descriptor for the object whose layout */ + /* is described by the argument. */ + /* The least significant bit of the first word is one */ + /* if the first word in the object may be a pointer. */ + /* The second argument specifies the number of */ + /* meaningful bits in the bitmap. The actual object */ + /* may be larger (but not smaller). Any additional */ + /* words in the object are assumed not to contain */ + /* pointers. */ + /* Returns a conservative approximation in the */ + /* (unlikely) case of insufficient memory to build */ + /* the descriptor. Calls to GC_make_descriptor */ + /* may consume some amount of a finite resource. This */ + /* is intended to be called once per type, not once */ + /* per allocation. */ + +GC_API GC_PTR GC_malloc_explicitly_typed + GC_PROTO((size_t size_in_bytes, GC_descr d)); + /* Allocate an object whose layout is described by d. */ + /* The resulting object MAY NOT BE PASSED TO REALLOC. */ + +GC_API GC_PTR GC_malloc_explicitly_typed_ignore_off_page + GC_PROTO((size_t size_in_bytes, GC_descr d)); + +GC_API GC_PTR GC_calloc_explicitly_typed + GC_PROTO((size_t nelements, + size_t element_size_in_bytes, + GC_descr d)); + /* Allocate an array of nelements elements, each of the */ + /* given size, and with the given descriptor. */ + /* The elemnt size must be a multiple of the byte */ + /* alignment required for pointers. E.g. on a 32-bit */ + /* machine with 16-bit aligned pointers, size_in_bytes */ + /* must be a multiple of 2. */ + +#ifdef GC_DEBUG +# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) GC_MALLOC(bytes) +# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) GC_MALLOC(n*bytes) +#else +# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) \ + GC_malloc_explicitly_typed(bytes, d) +# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) \ + GC_calloc_explicitly_typed(n, bytes, d) +#endif /* !GC_DEBUG */ + + +#endif /* _GC_TYPED_H */ + diff --git a/support/gc/include/javaxfc.h b/support/gc/include/javaxfc.h new file mode 100644 index 00000000..880020c5 --- /dev/null +++ b/support/gc/include/javaxfc.h @@ -0,0 +1,41 @@ +# ifndef GC_H +# include "gc.h" +# endif + +/* + * Invoke all remaining finalizers that haven't yet been run. + * This is needed for strict compliance with the Java standard, + * which can make the runtime guarantee that all finalizers are run. + * This is problematic for several reasons: + * 1) It means that finalizers, and all methods calle by them, + * must be prepared to deal with objects that have been finalized in + * spite of the fact that they are still referenced by statically + * allocated pointer variables. + * 1) It may mean that we get stuck in an infinite loop running + * finalizers which create new finalizable objects, though that's + * probably unlikely. + * Thus this is not recommended for general use. + */ +void GC_finalize_all(); + +/* + * A version of GC_register_finalizer that allows the object to be + * finalized before the objects it references. This is again error + * prone, in that it makes it easy to accidentally reference finalized + * objects. Again, recommended only for JVM implementors. + */ +void GC_register_finalizer_no_order(GC_PTR obj, + GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR * ocd); + +void GC_debug_register_finalizer_no_order(GC_PTR obj, + GC_finalization_proc fn, GC_PTR cd, + GC_finalization_proc *ofn, GC_PTR * ocd); + +#ifdef GC_DEBUG +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_debug_register_finalizer_no_order(p, f, d, of, od) +#else +# define GC_REGISTER_FINALIZER(p, f, d, of, od) \ + GC_register_finalizer_no_order(p, f, d, of, od) +#endif diff --git a/support/gc/include/new_gc_alloc.h b/support/gc/include/new_gc_alloc.h new file mode 100644 index 00000000..57713883 --- /dev/null +++ b/support/gc/include/new_gc_alloc.h @@ -0,0 +1,456 @@ +/* + * Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +// +// This is a revision of gc_alloc.h for SGI STL versions > 3.0 +// Unlike earlier versions, it supplements the standard "alloc.h" +// instead of replacing it. +// +// This is sloppy about variable names used in header files. +// It also doesn't yet understand the new header file names or +// namespaces. +// +// This assumes the collector has been compiled with -DATOMIC_UNCOLLECTABLE +// and -DALL_INTERIOR_POINTERS. We also recommend +// -DREDIRECT_MALLOC=GC_uncollectable_malloc. +// +// Some of this could be faster in the explicit deallocation case. +// In particular, we spend too much time clearing objects on the +// free lists. That could be avoided. +// +// This uses template classes with static members, and hence does not work +// with g++ 2.7.2 and earlier. +// +// Unlike its predecessor, this one simply defines +// gc_alloc +// single_client_gc_alloc +// traceable_alloc +// single_client_traceable_alloc +// +// It does not redefine alloc. Nor does it change the default allocator, +// though the user may wish to do so. (The argument against changing +// the default allocator is that it may introduce subtle link compatibility +// problems. The argument for changing it is that the usual default +// allocator is usually a very bad choice for a garbage collected environment.) +// + +#ifndef GC_ALLOC_H + +#include "gc.h" +#include + +#define GC_ALLOC_H + +#include +#include + +// The following need to match collector data structures. +// We can't include gc_priv.h, since that pulls in way too much stuff. +// This should eventually be factored out into another include file. + +extern "C" { + extern void ** const GC_objfreelist_ptr; + extern void ** const GC_aobjfreelist_ptr; + extern void ** const GC_uobjfreelist_ptr; + extern void ** const GC_auobjfreelist_ptr; + + extern void GC_incr_words_allocd(size_t words); + extern void GC_incr_mem_freed(size_t words); + + extern char * GC_generic_malloc_words_small(size_t word, int kind); +} + +// Object kinds; must match PTRFREE, NORMAL, UNCOLLECTABLE, and +// AUNCOLLECTABLE in gc_priv.h. + +enum { GC_PTRFREE = 0, GC_NORMAL = 1, GC_UNCOLLECTABLE = 2, + GC_AUNCOLLECTABLE = 3 }; + +enum { GC_max_fast_bytes = 255 }; + +enum { GC_bytes_per_word = sizeof(char *) }; + +enum { GC_byte_alignment = 8 }; + +enum { GC_word_alignment = GC_byte_alignment/GC_bytes_per_word }; + +inline void * &GC_obj_link(void * p) +{ return *(void **)p; } + +// Compute a number of words >= n+1 bytes. +// The +1 allows for pointers one past the end. +inline size_t GC_round_up(size_t n) +{ + return ((n + GC_byte_alignment)/GC_byte_alignment)*GC_word_alignment; +} + +// The same but don't allow for extra byte. +inline size_t GC_round_up_uncollectable(size_t n) +{ + return ((n + GC_byte_alignment - 1)/GC_byte_alignment)*GC_word_alignment; +} + +template +class GC_aux_template { +public: + // File local count of allocated words. Occasionally this is + // added into the global count. A separate count is necessary since the + // real one must be updated with a procedure call. + static size_t GC_words_recently_allocd; + + // Same for uncollectable mmory. Not yet reflected in either + // GC_words_recently_allocd or GC_non_gc_bytes. + static size_t GC_uncollectable_words_recently_allocd; + + // Similar counter for explicitly deallocated memory. + static size_t GC_mem_recently_freed; + + // Again for uncollectable memory. + static size_t GC_uncollectable_mem_recently_freed; + + static void * GC_out_of_line_malloc(size_t nwords, int kind); +}; + +template +size_t GC_aux_template::GC_words_recently_allocd = 0; + +template +size_t GC_aux_template::GC_uncollectable_words_recently_allocd = 0; + +template +size_t GC_aux_template::GC_mem_recently_freed = 0; + +template +size_t GC_aux_template::GC_uncollectable_mem_recently_freed = 0; + +template +void * GC_aux_template::GC_out_of_line_malloc(size_t nwords, int kind) +{ + GC_words_recently_allocd += GC_uncollectable_words_recently_allocd; + GC_non_gc_bytes += + GC_bytes_per_word * GC_uncollectable_words_recently_allocd; + GC_uncollectable_words_recently_allocd = 0; + + GC_mem_recently_freed += GC_uncollectable_mem_recently_freed; + GC_non_gc_bytes -= + GC_bytes_per_word * GC_uncollectable_mem_recently_freed; + GC_uncollectable_mem_recently_freed = 0; + + GC_incr_words_allocd(GC_words_recently_allocd); + GC_words_recently_allocd = 0; + + GC_incr_mem_freed(GC_mem_recently_freed); + GC_mem_recently_freed = 0; + + return GC_generic_malloc_words_small(nwords, kind); +} + +typedef GC_aux_template<0> GC_aux; + +// A fast, single-threaded, garbage-collected allocator +// We assume the first word will be immediately overwritten. +// In this version, deallocation is not a noop, and explicit +// deallocation is likely to help performance. +template +class single_client_gc_alloc_template { + public: + static void * allocate(size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc(n); + flh = GC_objfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_NORMAL); + } + *flh = GC_obj_link(op); + GC_aux::GC_words_recently_allocd += nwords; + return op; + } + static void * ptr_free_allocate(size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_atomic(n); + flh = GC_aobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_PTRFREE); + } + *flh = GC_obj_link(op); + GC_aux::GC_words_recently_allocd += nwords; + return op; + } + static void deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_objfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + memset((char *)p + GC_bytes_per_word, 0, + GC_bytes_per_word * (nwords - 1)); + *flh = p; + GC_aux::GC_mem_recently_freed += nwords; + } + } + static void ptr_free_deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_aobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_mem_recently_freed += nwords; + } + } +}; + +typedef single_client_gc_alloc_template<0> single_client_gc_alloc; + +// Once more, for uncollectable objects. +template +class single_client_traceable_alloc_template { + public: + static void * allocate(size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_uncollectable(n); + flh = GC_uobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_UNCOLLECTABLE); + } + *flh = GC_obj_link(op); + GC_aux::GC_uncollectable_words_recently_allocd += nwords; + return op; + } + static void * ptr_free_allocate(size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + void * op; + + if (n > GC_max_fast_bytes) return GC_malloc_atomic_uncollectable(n); + flh = GC_auobjfreelist_ptr + nwords; + if (0 == (op = *flh)) { + return GC_aux::GC_out_of_line_malloc(nwords, GC_AUNCOLLECTABLE); + } + *flh = GC_obj_link(op); + GC_aux::GC_uncollectable_words_recently_allocd += nwords; + return op; + } + static void deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_uobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_uncollectable_mem_recently_freed += nwords; + } + } + static void ptr_free_deallocate(void *p, size_t n) + { + size_t nwords = GC_round_up_uncollectable(n); + void ** flh; + + if (n > GC_max_fast_bytes) { + GC_free(p); + } else { + flh = GC_auobjfreelist_ptr + nwords; + GC_obj_link(p) = *flh; + *flh = p; + GC_aux::GC_uncollectable_mem_recently_freed += nwords; + } + } +}; + +typedef single_client_traceable_alloc_template<0> single_client_traceable_alloc; + +template < int dummy > +class gc_alloc_template { + public: + static void * allocate(size_t n) { return GC_malloc(n); } + static void * ptr_free_allocate(size_t n) + { return GC_malloc_atomic(n); } + static void deallocate(void *, size_t) { } + static void ptr_free_deallocate(void *, size_t) { } +}; + +typedef gc_alloc_template < 0 > gc_alloc; + +template < int dummy > +class traceable_alloc_template { + public: + static void * allocate(size_t n) { return GC_malloc_uncollectable(n); } + static void * ptr_free_allocate(size_t n) + { return GC_malloc_atomic_uncollectable(n); } + static void deallocate(void *p, size_t) { GC_free(p); } + static void ptr_free_deallocate(void *p, size_t) { GC_free(p); } +}; + +typedef traceable_alloc_template < 0 > traceable_alloc; + +#ifdef _SGI_SOURCE + +// We want to specialize simple_alloc so that it does the right thing +// for all pointerfree types. At the moment there is no portable way to +// even approximate that. The following approximation should work for +// SGI compilers, and perhaps some others. + +# define __GC_SPECIALIZE(T,alloc) \ +class simple_alloc { \ +public: \ + static T *allocate(size_t n) \ + { return 0 == n? 0 : \ + (T*) alloc::ptr_free_allocate(n * sizeof (T)); } \ + static T *allocate(void) \ + { return (T*) alloc::ptr_free_allocate(sizeof (T)); } \ + static void deallocate(T *p, size_t n) \ + { if (0 != n) alloc::ptr_free_deallocate(p, n * sizeof (T)); } \ + static void deallocate(T *p) \ + { alloc::ptr_free_deallocate(p, sizeof (T)); } \ +}; + +__GC_SPECIALIZE(char, gc_alloc) +__GC_SPECIALIZE(int, gc_alloc) +__GC_SPECIALIZE(unsigned, gc_alloc) +__GC_SPECIALIZE(float, gc_alloc) +__GC_SPECIALIZE(double, gc_alloc) + +__GC_SPECIALIZE(char, traceable_alloc) +__GC_SPECIALIZE(int, traceable_alloc) +__GC_SPECIALIZE(unsigned, traceable_alloc) +__GC_SPECIALIZE(float, traceable_alloc) +__GC_SPECIALIZE(double, traceable_alloc) + +__GC_SPECIALIZE(char, single_client_gc_alloc) +__GC_SPECIALIZE(int, single_client_gc_alloc) +__GC_SPECIALIZE(unsigned, single_client_gc_alloc) +__GC_SPECIALIZE(float, single_client_gc_alloc) +__GC_SPECIALIZE(double, single_client_gc_alloc) + +__GC_SPECIALIZE(char, single_client_traceable_alloc) +__GC_SPECIALIZE(int, single_client_traceable_alloc) +__GC_SPECIALIZE(unsigned, single_client_traceable_alloc) +__GC_SPECIALIZE(float, single_client_traceable_alloc) +__GC_SPECIALIZE(double, single_client_traceable_alloc) + +#ifdef __STL_USE_STD_ALLOCATORS + +__STL_BEGIN_NAMESPACE + +template +struct _Alloc_traits<_T, gc_alloc > +{ + static const bool _S_instanceless = true; + typedef simple_alloc<_T, gc_alloc > _Alloc_type; + typedef __allocator<_T, gc_alloc > allocator_type; +}; + +inline bool operator==(const gc_alloc&, + const gc_alloc&) +{ + return true; +} + +inline bool operator!=(const gc_alloc&, + const gc_alloc&) +{ + return false; +} + +template +struct _Alloc_traits<_T, single_client_gc_alloc > +{ + static const bool _S_instanceless = true; + typedef simple_alloc<_T, single_client_gc_alloc > _Alloc_type; + typedef __allocator<_T, single_client_gc_alloc > allocator_type; +}; + +inline bool operator==(const single_client_gc_alloc&, + const single_client_gc_alloc&) +{ + return true; +} + +inline bool operator!=(const single_client_gc_alloc&, + const single_client_gc_alloc&) +{ + return false; +} + +template +struct _Alloc_traits<_T, traceable_alloc > +{ + static const bool _S_instanceless = true; + typedef simple_alloc<_T, traceable_alloc > _Alloc_type; + typedef __allocator<_T, traceable_alloc > allocator_type; +}; + +inline bool operator==(const traceable_alloc&, + const traceable_alloc&) +{ + return true; +} + +inline bool operator!=(const traceable_alloc&, + const traceable_alloc&) +{ + return false; +} + +template +struct _Alloc_traits<_T, single_client_traceable_alloc > +{ + static const bool _S_instanceless = true; + typedef simple_alloc<_T, single_client_traceable_alloc > _Alloc_type; + typedef __allocator<_T, single_client_traceable_alloc > allocator_type; +}; + +inline bool operator==(const single_client_traceable_alloc&, + const single_client_traceable_alloc&) +{ + return true; +} + +inline bool operator!=(const single_client_traceable_alloc&, + const single_client_traceable_alloc&) +{ + return false; +} + +__STL_END_NAMESPACE + +#endif /* __STL_USE_STD_ALLOCATORS */ + +#endif /* _SGI_SOURCE */ + +#endif /* GC_ALLOC_H */ diff --git a/support/gc/include/private/cord_pos.h b/support/gc/include/private/cord_pos.h new file mode 100644 index 00000000..d2b24bb8 --- /dev/null +++ b/support/gc/include/private/cord_pos.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, May 19, 1994 2:23 pm PDT */ +# ifndef CORD_POSITION_H + +/* The representation of CORD_position. This is private to the */ +/* implementation, but the size is known to clients. Also */ +/* the implementation of some exported macros relies on it. */ +/* Don't use anything defined here and not in cord.h. */ + +# define MAX_DEPTH 48 + /* The maximum depth of a balanced cord + 1. */ + /* We don't let cords get deeper than MAX_DEPTH. */ + +struct CORD_pe { + CORD pe_cord; + size_t pe_start_pos; +}; + +/* A structure describing an entry on the path from the root */ +/* to current position. */ +typedef struct CORD_Pos { + size_t cur_pos; + int path_len; +# define CORD_POS_INVALID (0x55555555) + /* path_len == INVALID <==> position invalid */ + const char *cur_leaf; /* Current leaf, if it is a string. */ + /* If the current leaf is a function, */ + /* then this may point to function_buf */ + /* containing the next few characters. */ + /* Always points to a valid string */ + /* containing the current character */ + /* unless cur_end is 0. */ + size_t cur_start; /* Start position of cur_leaf */ + size_t cur_end; /* Ending position of cur_leaf */ + /* 0 if cur_leaf is invalid. */ + struct CORD_pe path[MAX_DEPTH + 1]; + /* path[path_len] is the leaf corresponding to cur_pos */ + /* path[0].pe_cord is the cord we point to. */ +# define FUNCTION_BUF_SZ 8 + char function_buf[FUNCTION_BUF_SZ]; /* Space for next few chars */ + /* from function node. */ +} CORD_pos[1]; + +/* Extract the cord from a position: */ +CORD CORD_pos_to_cord(CORD_pos p); + +/* Extract the current index from a position: */ +size_t CORD_pos_to_index(CORD_pos p); + +/* Fetch the character located at the given position: */ +char CORD_pos_fetch(CORD_pos p); + +/* Initialize the position to refer to the give cord and index. */ +/* Note that this is the most expensive function on positions: */ +void CORD_set_pos(CORD_pos p, CORD x, size_t i); + +/* Advance the position to the next character. */ +/* P must be initialized and valid. */ +/* Invalidates p if past end: */ +void CORD_next(CORD_pos p); + +/* Move the position to the preceding character. */ +/* P must be initialized and valid. */ +/* Invalidates p if past beginning: */ +void CORD_prev(CORD_pos p); + +/* Is the position valid, i.e. inside the cord? */ +int CORD_pos_valid(CORD_pos p); + +char CORD__pos_fetch(CORD_pos); +void CORD__next(CORD_pos); +void CORD__prev(CORD_pos); + +#define CORD_pos_fetch(p) \ + (((p)[0].cur_end != 0)? \ + (p)[0].cur_leaf[(p)[0].cur_pos - (p)[0].cur_start] \ + : CORD__pos_fetch(p)) + +#define CORD_next(p) \ + (((p)[0].cur_pos + 1 < (p)[0].cur_end)? \ + (p)[0].cur_pos++ \ + : (CORD__next(p), 0)) + +#define CORD_prev(p) \ + (((p)[0].cur_end != 0 && (p)[0].cur_pos > (p)[0].cur_start)? \ + (p)[0].cur_pos-- \ + : (CORD__prev(p), 0)) + +#define CORD_pos_to_index(p) ((p)[0].cur_pos) + +#define CORD_pos_to_cord(p) ((p)[0].path[0].pe_cord) + +#define CORD_pos_valid(p) ((p)[0].path_len != CORD_POS_INVALID) + +/* Some grubby stuff for performance-critical friends: */ +#define CORD_pos_chars_left(p) ((long)((p)[0].cur_end) - (long)((p)[0].cur_pos)) + /* Number of characters in cache. <= 0 ==> none */ + +#define CORD_pos_advance(p,n) ((p)[0].cur_pos += (n) - 1, CORD_next(p)) + /* Advance position by n characters */ + /* 0 < n < CORD_pos_chars_left(p) */ + +#define CORD_pos_cur_char_addr(p) \ + (p)[0].cur_leaf + ((p)[0].cur_pos - (p)[0].cur_start) + /* address of current character in cache. */ + +#endif diff --git a/support/gc/include/private/gc_hdrs.h b/support/gc/include/private/gc_hdrs.h new file mode 100644 index 00000000..2f2d1bf9 --- /dev/null +++ b/support/gc/include/private/gc_hdrs.h @@ -0,0 +1,133 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, July 11, 1995 11:54 am PDT */ +# ifndef GC_HEADERS_H +# define GC_HEADERS_H +typedef struct hblkhdr hdr; + +# if CPP_WORDSZ != 32 && CPP_WORDSZ < 36 + --> Get a real machine. +# endif + +/* + * The 2 level tree data structure that is used to find block headers. + * If there are more than 32 bits in a pointer, the top level is a hash + * table. + */ + +# if CPP_WORDSZ > 32 +# define HASH_TL +# endif + +/* Define appropriate out-degrees for each of the two tree levels */ +# ifdef SMALL_CONFIG +# define LOG_BOTTOM_SZ 11 + /* Keep top index size reasonable with smaller blocks. */ +# else +# define LOG_BOTTOM_SZ 10 +# endif +# ifndef HASH_TL +# define LOG_TOP_SZ (WORDSZ - LOG_BOTTOM_SZ - LOG_HBLKSIZE) +# else +# define LOG_TOP_SZ 11 +# endif +# define TOP_SZ (1 << LOG_TOP_SZ) +# define BOTTOM_SZ (1 << LOG_BOTTOM_SZ) + +typedef struct bi { + hdr * index[BOTTOM_SZ]; + /* + * The bottom level index contains one of three kinds of values: + * 0 means we're not responsible for this block. + * 1 < (long)X <= MAX_JUMP means the block starts at least + * X * HBLKSIZE bytes before the current address. + * A valid pointer points to a hdr structure. (The above can't be + * valid pointers due to the GET_MEM return convention.) + */ + struct bi * asc_link; /* All indices are linked in */ + /* ascending order. */ + word key; /* high order address bits. */ +# ifdef HASH_TL + struct bi * hash_link; /* Hash chain link. */ +# endif +} bottom_index; + +/* extern bottom_index GC_all_nils; - really part of GC_arrays */ + +/* extern bottom_index * GC_top_index []; - really part of GC_arrays */ + /* Each entry points to a bottom_index. */ + /* On a 32 bit machine, it points to */ + /* the index for a set of high order */ + /* bits equal to the index. For longer */ + /* addresses, we hash the high order */ + /* bits to compute the index in */ + /* GC_top_index, and each entry points */ + /* to a hash chain. */ + /* The last entry in each chain is */ + /* GC_all_nils. */ + + +# define MAX_JUMP (HBLKSIZE - 1) + +# define HDR_FROM_BI(bi, p) \ + ((bi)->index[((word)(p) >> LOG_HBLKSIZE) & (BOTTOM_SZ - 1)]) +# ifndef HASH_TL +# define BI(p) (GC_top_index \ + [(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE)]) +# define HDR_INNER(p) HDR_FROM_BI(BI(p),p) +# ifdef SMALL_CONFIG +# define HDR(p) GC_find_header((ptr_t)(p)) +# else +# define HDR(p) HDR_INNER(p) +# endif +# define GET_BI(p, bottom_indx) (bottom_indx) = BI(p) +# define GET_HDR(p, hhdr) (hhdr) = HDR(p) +# define SET_HDR(p, hhdr) HDR_INNER(p) = (hhdr) +# define GET_HDR_ADDR(p, ha) (ha) = &(HDR_INNER(p)) +# else /* hash */ +/* Hash function for tree top level */ +# define TL_HASH(hi) ((hi) & (TOP_SZ - 1)) +/* Set bottom_indx to point to the bottom index for address p */ +# define GET_BI(p, bottom_indx) \ + { \ + register word hi = \ + (word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \ + register bottom_index * _bi = GC_top_index[TL_HASH(hi)]; \ + \ + while (_bi -> key != hi && _bi != GC_all_nils) \ + _bi = _bi -> hash_link; \ + (bottom_indx) = _bi; \ + } +# define GET_HDR_ADDR(p, ha) \ + { \ + register bottom_index * bi; \ + \ + GET_BI(p, bi); \ + (ha) = &(HDR_FROM_BI(bi, p)); \ + } +# define GET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \ + (hhdr) = *_ha; } +# define SET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \ + *_ha = (hhdr); } +# define HDR(p) GC_find_header((ptr_t)(p)) +# endif + +/* Is the result a forwarding address to someplace closer to the */ +/* beginning of the block or NIL? */ +# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((unsigned long) (hhdr) <= MAX_JUMP) + +/* Get an HBLKSIZE aligned address closer to the beginning of the block */ +/* h. Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr). */ +# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (unsigned long)(hhdr)) +# endif /* GC_HEADERS_H */ diff --git a/support/gc/include/private/gc_priv.h b/support/gc/include/private/gc_priv.h new file mode 100644 index 00000000..df7db8e9 --- /dev/null +++ b/support/gc/include/private/gc_priv.h @@ -0,0 +1,1661 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, February 16, 1996 2:30 pm PST */ + + +# ifndef GC_PRIVATE_H +# define GC_PRIVATE_H + +#if defined(mips) && defined(SYSTYPE_BSD) && defined(sony_news) + /* sony RISC NEWS, NEWSOS 4 */ +# define BSD_TIME +/* typedef long ptrdiff_t; -- necessary on some really old systems */ +#endif + +#if defined(mips) && defined(SYSTYPE_BSD43) + /* MIPS RISCOS 4 */ +# define BSD_TIME +#endif + +#ifdef BSD_TIME +# include +# include +# include +#endif /* BSD_TIME */ + +# ifndef GC_H +# include "gc.h" +# endif + +typedef GC_word word; +typedef GC_signed_word signed_word; + +# ifndef CONFIG_H +# include "gcconfig.h" +# endif + +# ifndef HEADERS_H +# include "gc_hdrs.h" +# endif + +typedef int GC_bool; +# define TRUE 1 +# define FALSE 0 + +typedef char * ptr_t; /* A generic pointer to which we can add */ + /* byte displacements. */ + /* Preferably identical to caddr_t, if it */ + /* exists. */ + +#if defined(__STDC__) +# include +# if !(defined( sony_news ) ) +# include +# endif +# define VOLATILE volatile +# define CONST const +#else +# ifdef MSWIN32 +# include +# endif +# define VOLATILE +# define CONST +#endif + +#ifdef AMIGA +# define GC_FAR __far +#else +# define GC_FAR +#endif + +/*********************************/ +/* */ +/* Definitions for conservative */ +/* collector */ +/* */ +/*********************************/ + +/*********************************/ +/* */ +/* Easily changeable parameters */ +/* */ +/*********************************/ + +#define STUBBORN_ALLOC /* Define stubborn allocation primitives */ +#if defined(SRC_M3) || defined(SMALL_CONFIG) +# undef STUBBORN_ALLOC +#endif + + +/* #define ALL_INTERIOR_POINTERS */ + /* Forces all pointers into the interior of an */ + /* object to be considered valid. Also causes the */ + /* sizes of all objects to be inflated by at least */ + /* one byte. This should suffice to guarantee */ + /* that in the presence of a compiler that does */ + /* not perform garbage-collector-unsafe */ + /* optimizations, all portable, strictly ANSI */ + /* conforming C programs should be safely usable */ + /* with malloc replaced by GC_malloc and free */ + /* calls removed. There are several disadvantages: */ + /* 1. There are probably no interesting, portable, */ + /* strictly ANSI conforming C programs. */ + /* 2. This option makes it hard for the collector */ + /* to allocate space that is not ``pointed to'' */ + /* by integers, etc. Under SunOS 4.X with a */ + /* statically linked libc, we empiricaly */ + /* observed that it would be difficult to */ + /* allocate individual objects larger than 100K. */ + /* Even if only smaller objects are allocated, */ + /* more swap space is likely to be needed. */ + /* Fortunately, much of this will never be */ + /* touched. */ + /* If you can easily avoid using this option, do. */ + /* If not, try to keep individual objects small. */ + +#define PRINTSTATS /* Print garbage collection statistics */ + /* For less verbose output, undefine in reclaim.c */ + +#define PRINTTIMES /* Print the amount of time consumed by each garbage */ + /* collection. */ + +#define PRINTBLOCKS /* Print object sizes associated with heap blocks, */ + /* whether the objects are atomic or composite, and */ + /* whether or not the block was found to be empty */ + /* during the reclaim phase. Typically generates */ + /* about one screenful per garbage collection. */ +#undef PRINTBLOCKS + +#ifdef SILENT +# ifdef PRINTSTATS +# undef PRINTSTATS +# endif +# ifdef PRINTTIMES +# undef PRINTTIMES +# endif +# ifdef PRINTNBLOCKS +# undef PRINTNBLOCKS +# endif +#endif + +#if defined(PRINTSTATS) && !defined(GATHERSTATS) +# define GATHERSTATS +#endif + +#ifdef FINALIZE_ON_DEMAND +# define GC_INVOKE_FINALIZERS() +#else +# define GC_INVOKE_FINALIZERS() (void)GC_invoke_finalizers() +#endif + +#define MERGE_SIZES /* Round up some object sizes, so that fewer distinct */ + /* free lists are actually maintained. This applies */ + /* only to the top level routines in misc.c, not to */ + /* user generated code that calls GC_allocobj and */ + /* GC_allocaobj directly. */ + /* Slows down average programs slightly. May however */ + /* substantially reduce fragmentation if allocation */ + /* request sizes are widely scattered. */ + /* May save significant amounts of space for obj_map */ + /* entries. */ + +#ifndef OLD_BLOCK_ALLOC + /* Macros controlling large block allocation strategy. */ +# define EXACT_FIRST /* Make a complete pass through the large object */ + /* free list before splitting a block */ +# define PRESERVE_LAST /* Do not divide last allocated heap segment */ + /* unless we would otherwise need to expand the */ + /* heap. */ +#endif + +/* ALIGN_DOUBLE requires MERGE_SIZES at present. */ +# if defined(ALIGN_DOUBLE) && !defined(MERGE_SIZES) +# define MERGE_SIZES +# endif + +#if defined(ALL_INTERIOR_POINTERS) && !defined(DONT_ADD_BYTE_AT_END) +# define ADD_BYTE_AT_END +#endif + + +# ifndef LARGE_CONFIG +# define MINHINCR 16 /* Minimum heap increment, in blocks of HBLKSIZE */ + /* Must be multiple of largest page size. */ +# define MAXHINCR 512 /* Maximum heap increment, in blocks */ +# else +# define MINHINCR 64 +# define MAXHINCR 4096 +# endif + +# define TIME_LIMIT 50 /* We try to keep pause times from exceeding */ + /* this by much. In milliseconds. */ + +# define BL_LIMIT GC_black_list_spacing + /* If we need a block of N bytes, and we have */ + /* a block of N + BL_LIMIT bytes available, */ + /* and N > BL_LIMIT, */ + /* but all possible positions in it are */ + /* blacklisted, we just use it anyway (and */ + /* print a warning, if warnings are enabled). */ + /* This risks subsequently leaking the block */ + /* due to a false reference. But not using */ + /* the block risks unreasonable immediate */ + /* heap growth. */ + +/*********************************/ +/* */ +/* Stack saving for debugging */ +/* */ +/*********************************/ + +#ifdef SAVE_CALL_CHAIN + +/* + * Number of frames and arguments to save in objects allocated by + * debugging allocator. + */ +# define NFRAMES 6 /* Number of frames to save. Even for */ + /* alignment reasons. */ +# define NARGS 2 /* Mumber of arguments to save for each call. */ + +# define NEED_CALLINFO + +/* Fill in the pc and argument information for up to NFRAMES of my */ +/* callers. Ignore my frame and my callers frame. */ +void GC_save_callers (/* struct callinfo info[NFRAMES] */); + +void GC_print_callers (/* struct callinfo info[NFRAMES] */); + +#else + +# ifdef GC_ADD_CALLER +# define NFRAMES 1 +# define NARGS 0 +# define NEED_CALLINFO +# endif + +#endif + +#ifdef NEED_CALLINFO + struct callinfo { + word ci_pc; +# if NARGS > 0 + word ci_arg[NARGS]; /* bit-wise complement to avoid retention */ +# endif +# if defined(ALIGN_DOUBLE) && (NFRAMES * (NARGS + 1)) % 2 == 1 + /* Likely alignment problem. */ + word ci_dummy; +# endif + }; +#endif + + +/*********************************/ +/* */ +/* OS interface routines */ +/* */ +/*********************************/ + +#ifdef BSD_TIME +# undef CLOCK_TYPE +# undef GET_TIME +# undef MS_TIME_DIFF +# define CLOCK_TYPE struct timeval +# define GET_TIME(x) { struct rusage rusage; \ + getrusage (RUSAGE_SELF, &rusage); \ + x = rusage.ru_utime; } +# define MS_TIME_DIFF(a,b) ((double) (a.tv_sec - b.tv_sec) * 1000.0 \ + + (double) (a.tv_usec - b.tv_usec) / 1000.0) +#else /* !BSD_TIME */ +# include +# if !defined(__STDC__) && defined(SPARC) && defined(SUNOS4) + clock_t clock(); /* Not in time.h, where it belongs */ +# endif +# if defined(FREEBSD) && !defined(CLOCKS_PER_SEC) +# include +# define CLOCKS_PER_SEC CLK_TCK +# endif +# if !defined(CLOCKS_PER_SEC) +# define CLOCKS_PER_SEC 1000000 +/* + * This is technically a bug in the implementation. ANSI requires that + * CLOCKS_PER_SEC be defined. But at least under SunOS4.1.1, it isn't. + * Also note that the combination of ANSI C and POSIX is incredibly gross + * here. The type clock_t is used by both clock() and times(). But on + * some machines these use different notions of a clock tick, CLOCKS_PER_SEC + * seems to apply only to clock. Hence we use it here. On many machines, + * including SunOS, clock actually uses units of microseconds (which are + * not really clock ticks). + */ +# endif +# define CLOCK_TYPE clock_t +# define GET_TIME(x) x = clock() +# define MS_TIME_DIFF(a,b) ((unsigned long) \ + (1000.0*(double)((a)-(b))/(double)CLOCKS_PER_SEC)) +#endif /* !BSD_TIME */ + +/* We use bzero and bcopy internally. They may not be available. */ +# if defined(SPARC) && defined(SUNOS4) +# define BCOPY_EXISTS +# endif +# if defined(M68K) && defined(AMIGA) +# define BCOPY_EXISTS +# endif +# if defined(M68K) && defined(NEXT) +# define BCOPY_EXISTS +# endif +# if defined(VAX) +# define BCOPY_EXISTS +# endif +# if defined(AMIGA) +# include +# define BCOPY_EXISTS +# endif + +# ifndef BCOPY_EXISTS +# include +# define BCOPY(x,y,n) memcpy(y, x, (size_t)(n)) +# define BZERO(x,n) memset(x, 0, (size_t)(n)) +# else +# define BCOPY(x,y,n) bcopy((char *)(x),(char *)(y),(int)(n)) +# define BZERO(x,n) bzero((char *)(x),(int)(n)) +# endif + +/* HBLKSIZE aligned allocation. 0 is taken to mean failure */ +/* space is assumed to be cleared. */ +/* In the case os USE_MMAP, the argument must also be a */ +/* physical page size. */ +# ifdef PCR + char * real_malloc(); +# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \ + + GC_page_size-1) +# else +# ifdef OS2 + void * os2_alloc(size_t bytes); +# define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \ + + GC_page_size) \ + + GC_page_size-1) +# else +# if defined(AMIGA) || defined(NEXT) || defined(DOS4GW) +# define GET_MEM(bytes) HBLKPTR((size_t) \ + calloc(1, (size_t)bytes + GC_page_size) \ + + GC_page_size-1) +# else +# ifdef MSWIN32 + extern ptr_t GC_win32_get_mem(); +# define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes) +# else +# ifdef MACOS +# if defined(USE_TEMPORARY_MEMORY) + extern Ptr GC_MacTemporaryNewPtr(size_t size, + Boolean clearMemory); +# define GET_MEM(bytes) HBLKPTR( \ + GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \ + + GC_page_size-1) +# else +# define GET_MEM(bytes) HBLKPTR( \ + NewPtrClear(bytes + GC_page_size) + GC_page_size-1) +# endif +# else + extern ptr_t GC_unix_get_mem(); +# define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes) +# endif +# endif +# endif +# endif +# endif + +/* + * Mutual exclusion between allocator/collector routines. + * Needed if there is more than one allocator thread. + * FASTLOCK() is assumed to try to acquire the lock in a cheap and + * dirty way that is acceptable for a few instructions, e.g. by + * inhibiting preemption. This is assumed to have succeeded only + * if a subsequent call to FASTLOCK_SUCCEEDED() returns TRUE. + * FASTUNLOCK() is called whether or not FASTLOCK_SUCCEEDED(). + * If signals cannot be tolerated with the FASTLOCK held, then + * FASTLOCK should disable signals. The code executed under + * FASTLOCK is otherwise immune to interruption, provided it is + * not restarted. + * DCL_LOCK_STATE declares any local variables needed by LOCK and UNLOCK + * and/or DISABLE_SIGNALS and ENABLE_SIGNALS and/or FASTLOCK. + * (There is currently no equivalent for FASTLOCK.) + */ +# ifdef THREADS +# ifdef PCR_OBSOLETE /* Faster, but broken with multiple lwp's */ +# include "th/PCR_Th.h" +# include "th/PCR_ThCrSec.h" + extern struct PCR_Th_MLRep GC_allocate_ml; +# define DCL_LOCK_STATE PCR_sigset_t GC_old_sig_mask +# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml) +# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml) +# define FASTLOCK() PCR_ThCrSec_EnterSys() + /* Here we cheat (a lot): */ +# define FASTLOCK_SUCCEEDED() (*(int *)(&GC_allocate_ml) == 0) + /* TRUE if nobody currently holds the lock */ +# define FASTUNLOCK() PCR_ThCrSec_ExitSys() +# endif +# ifdef PCR +# include +# include + extern PCR_Th_ML GC_allocate_ml; +# define DCL_LOCK_STATE \ + PCR_ERes GC_fastLockRes; PCR_sigset_t GC_old_sig_mask +# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml) +# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml) +# define FASTLOCK() (GC_fastLockRes = PCR_Th_ML_Try(&GC_allocate_ml)) +# define FASTLOCK_SUCCEEDED() (GC_fastLockRes == PCR_ERes_okay) +# define FASTUNLOCK() {\ + if( FASTLOCK_SUCCEEDED() ) PCR_Th_ML_Release(&GC_allocate_ml); } +# endif +# ifdef SRC_M3 + extern word RT0u__inCritical; +# define LOCK() RT0u__inCritical++ +# define UNLOCK() RT0u__inCritical-- +# endif +# ifdef SOLARIS_THREADS +# include +# include + extern mutex_t GC_allocate_ml; +# define LOCK() mutex_lock(&GC_allocate_ml); +# define UNLOCK() mutex_unlock(&GC_allocate_ml); +# endif +# ifdef LINUX_THREADS +# include +# ifdef __i386__ + inline static GC_test_and_set(volatile unsigned int *addr) { + int oldval; + /* Note: the "xchg" instruction does not need a "lock" prefix */ + __asm__ __volatile__("xchgl %0, %1" + : "=r"(oldval), "=m"(*(addr)) + : "0"(1), "m"(*(addr))); + return oldval; + } +# else + -- > Need implementation of GC_test_and_set() +# endif +# define GC_clear(addr) (*(addr) = 0) + + extern volatile unsigned int GC_allocate_lock; + /* This is not a mutex because mutexes that obey the (optional) */ + /* POSIX scheduling rules are subject to convoys in high contention */ + /* applications. This is basically a spin lock. */ + extern pthread_t GC_lock_holder; + extern void GC_lock(void); + /* Allocation lock holder. Only set if acquired by client through */ + /* GC_call_with_alloc_lock. */ +# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self() +# define NO_THREAD (pthread_t)(-1) +# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD +# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self())) +# ifdef UNDEFINED +# define LOCK() pthread_mutex_lock(&GC_allocate_ml) +# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml) +# else +# define LOCK() \ + { if (GC_test_and_set(&GC_allocate_lock)) GC_lock(); } +# define UNLOCK() \ + GC_clear(&GC_allocate_lock) +# endif + extern GC_bool GC_collecting; +# define ENTER_GC() \ + { \ + GC_collecting = 1; \ + } +# define EXIT_GC() GC_collecting = 0; +# endif /* LINUX_THREADS */ +# if defined(IRIX_THREADS) || defined(IRIX_JDK_THREADS) +# include +# include + +# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) +# define GC_test_and_set(addr, v) test_and_set(addr,v) +# else +# define GC_test_and_set(addr, v) __test_and_set(addr,v) +# endif + extern unsigned long GC_allocate_lock; + /* This is not a mutex because mutexes that obey the (optional) */ + /* POSIX scheduling rules are subject to convoys in high contention */ + /* applications. This is basically a spin lock. */ + extern pthread_t GC_lock_holder; + extern void GC_lock(void); + /* Allocation lock holder. Only set if acquired by client through */ + /* GC_call_with_alloc_lock. */ +# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self() +# define NO_THREAD (pthread_t)(-1) +# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD +# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self())) +# ifdef UNDEFINED +# define LOCK() pthread_mutex_lock(&GC_allocate_ml) +# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml) +# else +# define LOCK() { if (GC_test_and_set(&GC_allocate_lock, 1)) GC_lock(); } +# if __mips >= 3 && (defined (_ABIN32) || defined(_ABI64)) +# define UNLOCK() __lock_release(&GC_allocate_lock) +# else +# define UNLOCK() GC_allocate_lock = 0 +# endif +# endif + extern GC_bool GC_collecting; +# define ENTER_GC() \ + { \ + GC_collecting = 1; \ + } +# define EXIT_GC() GC_collecting = 0; +# endif /* IRIX_THREADS || IRIX_JDK_THREADS */ +# ifdef WIN32_THREADS +# include + GC_API CRITICAL_SECTION GC_allocate_ml; +# define LOCK() EnterCriticalSection(&GC_allocate_ml); +# define UNLOCK() LeaveCriticalSection(&GC_allocate_ml); +# endif +# ifndef SET_LOCK_HOLDER +# define SET_LOCK_HOLDER() +# define UNSET_LOCK_HOLDER() +# define I_HOLD_LOCK() FALSE + /* Used on platforms were locks can be reacquired, */ + /* so it doesn't matter if we lie. */ +# endif +# else +# define LOCK() +# define UNLOCK() +# endif +# ifndef SET_LOCK_HOLDER +# define SET_LOCK_HOLDER() +# define UNSET_LOCK_HOLDER() +# define I_HOLD_LOCK() FALSE + /* Used on platforms were locks can be reacquired, */ + /* so it doesn't matter if we lie. */ +# endif +# ifndef ENTER_GC +# define ENTER_GC() +# define EXIT_GC() +# endif + +# ifndef DCL_LOCK_STATE +# define DCL_LOCK_STATE +# endif +# ifndef FASTLOCK +# define FASTLOCK() LOCK() +# define FASTLOCK_SUCCEEDED() TRUE +# define FASTUNLOCK() UNLOCK() +# endif + +/* Delay any interrupts or signals that may abort this thread. Data */ +/* structures are in a consistent state outside this pair of calls. */ +/* ANSI C allows both to be empty (though the standard isn't very */ +/* clear on that point). Standard malloc implementations are usually */ +/* neither interruptable nor thread-safe, and thus correspond to */ +/* empty definitions. */ +# ifdef PCR +# define DISABLE_SIGNALS() \ + PCR_Th_SetSigMask(PCR_allSigsBlocked,&GC_old_sig_mask) +# define ENABLE_SIGNALS() \ + PCR_Th_SetSigMask(&GC_old_sig_mask, NIL) +# else +# if defined(SRC_M3) || defined(AMIGA) || defined(SOLARIS_THREADS) \ + || defined(MSWIN32) || defined(MACOS) || defined(DJGPP) \ + || defined(NO_SIGNALS) || defined(IRIX_THREADS) \ + || defined(IRIX_JDK_THREADS) || defined(LINUX_THREADS) + /* Also useful for debugging. */ + /* Should probably use thr_sigsetmask for SOLARIS_THREADS. */ +# define DISABLE_SIGNALS() +# define ENABLE_SIGNALS() +# else +# define DISABLE_SIGNALS() GC_disable_signals() + void GC_disable_signals(); +# define ENABLE_SIGNALS() GC_enable_signals() + void GC_enable_signals(); +# endif +# endif + +/* + * Stop and restart mutator threads. + */ +# ifdef PCR +# include "th/PCR_ThCtl.h" +# define STOP_WORLD() \ + PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_stopNormal, \ + PCR_allSigsBlocked, \ + PCR_waitForever) +# define START_WORLD() \ + PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_null, \ + PCR_allSigsBlocked, \ + PCR_waitForever); +# else +# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ + || defined(IRIX_THREADS) || defined(LINUX_THREADS) \ + || defined(IRIX_JDK_THREADS) + void GC_stop_world(); + void GC_start_world(); +# define STOP_WORLD() GC_stop_world() +# define START_WORLD() GC_start_world() +# else +# define STOP_WORLD() +# define START_WORLD() +# endif +# endif + +/* Abandon ship */ +# ifdef PCR +# define ABORT(s) PCR_Base_Panic(s) +# else +# ifdef SMALL_CONFIG +# define ABORT(msg) abort(); +# else + GC_API void GC_abort(); +# define ABORT(msg) GC_abort(msg); +# endif +# endif + +/* Exit abnormally, but without making a mess (e.g. out of memory) */ +# ifdef PCR +# define EXIT() PCR_Base_Exit(1,PCR_waitForever) +# else +# define EXIT() (void)exit(1) +# endif + +/* Print warning message, e.g. almost out of memory. */ +# define WARN(msg,arg) (*GC_current_warn_proc)(msg, (GC_word)(arg)) +extern GC_warn_proc GC_current_warn_proc; + +/*********************************/ +/* */ +/* Word-size-dependent defines */ +/* */ +/*********************************/ + +#if CPP_WORDSZ == 32 +# define WORDS_TO_BYTES(x) ((x)<<2) +# define BYTES_TO_WORDS(x) ((x)>>2) +# define LOGWL ((word)5) /* log[2] of CPP_WORDSZ */ +# define modWORDSZ(n) ((n) & 0x1f) /* n mod size of word */ +# if ALIGNMENT != 4 +# define UNALIGNED +# endif +#endif + +#if CPP_WORDSZ == 64 +# define WORDS_TO_BYTES(x) ((x)<<3) +# define BYTES_TO_WORDS(x) ((x)>>3) +# define LOGWL ((word)6) /* log[2] of CPP_WORDSZ */ +# define modWORDSZ(n) ((n) & 0x3f) /* n mod size of word */ +# if ALIGNMENT != 8 +# define UNALIGNED +# endif +#endif + +#define WORDSZ ((word)CPP_WORDSZ) +#define SIGNB ((word)1 << (WORDSZ-1)) +#define BYTES_PER_WORD ((word)(sizeof (word))) +#define ONES ((word)(-1)) +#define divWORDSZ(n) ((n) >> LOGWL) /* divide n by size of word */ + +/*********************/ +/* */ +/* Size Parameters */ +/* */ +/*********************/ + +/* heap block size, bytes. Should be power of 2 */ + +#ifndef HBLKSIZE +# ifdef SMALL_CONFIG +# define CPP_LOG_HBLKSIZE 10 +# else +# if CPP_WORDSZ == 32 +# define CPP_LOG_HBLKSIZE 12 +# else +# define CPP_LOG_HBLKSIZE 13 +# endif +# endif +#else +# if HBLKSIZE == 512 +# define CPP_LOG_HBLKSIZE 9 +# endif +# if HBLKSIZE == 1024 +# define CPP_LOG_HBLKSIZE 10 +# endif +# if HBLKSIZE == 2048 +# define CPP_LOG_HBLKSIZE 11 +# endif +# if HBLKSIZE == 4096 +# define CPP_LOG_HBLKSIZE 12 +# endif +# if HBLKSIZE == 8192 +# define CPP_LOG_HBLKSIZE 13 +# endif +# if HBLKSIZE == 16384 +# define CPP_LOG_HBLKSIZE 14 +# endif +# ifndef CPP_LOG_HBLKSIZE + --> fix HBLKSIZE +# endif +# undef HBLKSIZE +#endif +# define CPP_HBLKSIZE (1 << CPP_LOG_HBLKSIZE) +# define LOG_HBLKSIZE ((word)CPP_LOG_HBLKSIZE) +# define HBLKSIZE ((word)CPP_HBLKSIZE) + + +/* max size objects supported by freelist (larger objects may be */ +/* allocated, but less efficiently) */ + +#define CPP_MAXOBJSZ BYTES_TO_WORDS(CPP_HBLKSIZE/2) +#define MAXOBJSZ ((word)CPP_MAXOBJSZ) + +# define divHBLKSZ(n) ((n) >> LOG_HBLKSIZE) + +# define HBLK_PTR_DIFF(p,q) divHBLKSZ((ptr_t)p - (ptr_t)q) + /* Equivalent to subtracting 2 hblk pointers. */ + /* We do it this way because a compiler should */ + /* find it hard to use an integer division */ + /* instead of a shift. The bundled SunOS 4.1 */ + /* o.w. sometimes pessimizes the subtraction to */ + /* involve a call to .div. */ + +# define modHBLKSZ(n) ((n) & (HBLKSIZE-1)) + +# define HBLKPTR(objptr) ((struct hblk *)(((word) (objptr)) & ~(HBLKSIZE-1))) + +# define HBLKDISPL(objptr) (((word) (objptr)) & (HBLKSIZE-1)) + +/* Round up byte allocation requests to integral number of words, etc. */ +# ifdef ADD_BYTE_AT_END +# define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + WORDS_TO_BYTES(1)) +# ifdef ALIGN_DOUBLE +# define ALIGNED_WORDS(n) (BYTES_TO_WORDS((n) + WORDS_TO_BYTES(2)) & ~1) +# else +# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n) +# endif +# define SMALL_OBJ(bytes) ((bytes) < WORDS_TO_BYTES(MAXOBJSZ)) +# define ADD_SLOP(bytes) ((bytes)+1) +# else +# define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + (WORDS_TO_BYTES(1) - 1)) +# ifdef ALIGN_DOUBLE +# define ALIGNED_WORDS(n) \ + (BYTES_TO_WORDS((n) + WORDS_TO_BYTES(2) - 1) & ~1) +# else +# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n) +# endif +# define SMALL_OBJ(bytes) ((bytes) <= WORDS_TO_BYTES(MAXOBJSZ)) +# define ADD_SLOP(bytes) (bytes) +# endif + + +/* + * Hash table representation of sets of pages. This assumes it is + * OK to add spurious entries to sets. + * Used by black-listing code, and perhaps by dirty bit maintenance code. + */ + +# ifdef LARGE_CONFIG +# define LOG_PHT_ENTRIES 17 +# else +# define LOG_PHT_ENTRIES 14 /* Collisions are likely if heap grows */ + /* to more than 16K hblks = 64MB. */ + /* Each hash table occupies 2K bytes. */ +# endif +# define PHT_ENTRIES ((word)1 << LOG_PHT_ENTRIES) +# define PHT_SIZE (PHT_ENTRIES >> LOGWL) +typedef word page_hash_table[PHT_SIZE]; + +# define PHT_HASH(addr) ((((word)(addr)) >> LOG_HBLKSIZE) & (PHT_ENTRIES - 1)) + +# define get_pht_entry_from_index(bl, index) \ + (((bl)[divWORDSZ(index)] >> modWORDSZ(index)) & 1) +# define set_pht_entry_from_index(bl, index) \ + (bl)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index) +# define clear_pht_entry_from_index(bl, index) \ + (bl)[divWORDSZ(index)] &= ~((word)1 << modWORDSZ(index)) + + + +/********************************************/ +/* */ +/* H e a p B l o c k s */ +/* */ +/********************************************/ + +/* heap block header */ +#define HBLKMASK (HBLKSIZE-1) + +#define BITS_PER_HBLK (HBLKSIZE * 8) + +#define MARK_BITS_PER_HBLK (BITS_PER_HBLK/CPP_WORDSZ) + /* upper bound */ + /* We allocate 1 bit/word. Only the first word */ + /* in each object is actually marked. */ + +# ifdef ALIGN_DOUBLE +# define MARK_BITS_SZ (((MARK_BITS_PER_HBLK + 2*CPP_WORDSZ - 1) \ + / (2*CPP_WORDSZ))*2) +# else +# define MARK_BITS_SZ ((MARK_BITS_PER_HBLK + CPP_WORDSZ - 1)/CPP_WORDSZ) +# endif + /* Upper bound on number of mark words per heap block */ + +struct hblkhdr { + word hb_sz; /* If in use, size in words, of objects in the block. */ + /* if free, the size in bytes of the whole block */ + struct hblk * hb_next; /* Link field for hblk free list */ + /* and for lists of chunks waiting to be */ + /* reclaimed. */ + word hb_descr; /* object descriptor for marking. See */ + /* mark.h. */ + char* hb_map; /* A pointer to a pointer validity map of the block. */ + /* See GC_obj_map. */ + /* Valid for all blocks with headers. */ + /* Free blocks point to GC_invalid_map. */ + unsigned char hb_obj_kind; + /* Kind of objects in the block. Each kind */ + /* identifies a mark procedure and a set of */ + /* list headers. Sometimes called regions. */ + unsigned char hb_flags; +# define IGNORE_OFF_PAGE 1 /* Ignore pointers that do not */ + /* point to the first page of */ + /* this object. */ + unsigned short hb_last_reclaimed; + /* Value of GC_gc_no when block was */ + /* last allocated or swept. May wrap. */ + word hb_marks[MARK_BITS_SZ]; + /* Bit i in the array refers to the */ + /* object starting at the ith word (header */ + /* INCLUDED) in the heap block. */ + /* The lsb of word 0 is numbered 0. */ +}; + +/* heap block body */ + +# define DISCARD_WORDS 0 + /* Number of words to be dropped at the beginning of each block */ + /* Must be a multiple of WORDSZ. May reasonably be nonzero */ + /* on machines that don't guarantee longword alignment of */ + /* pointers, so that the number of false hits is minimized. */ + /* 0 and WORDSZ are probably the only reasonable values. */ + +# define BODY_SZ ((HBLKSIZE-WORDS_TO_BYTES(DISCARD_WORDS))/sizeof(word)) + +struct hblk { +# if (DISCARD_WORDS != 0) + word garbage[DISCARD_WORDS]; +# endif + word hb_body[BODY_SZ]; +}; + +# define HDR_WORDS ((word)DISCARD_WORDS) +# define HDR_BYTES ((word)WORDS_TO_BYTES(DISCARD_WORDS)) + +# define OBJ_SZ_TO_BLOCKS(sz) \ + divHBLKSZ(HDR_BYTES + WORDS_TO_BYTES(sz) + HBLKSIZE-1) + /* Size of block (in units of HBLKSIZE) needed to hold objects of */ + /* given sz (in words). */ + +/* Object free list link */ +# define obj_link(p) (*(ptr_t *)(p)) + +/* The type of mark procedures. This really belongs in gc_mark.h. */ +/* But we put it here, so that we can avoid scanning the mark proc */ +/* table. */ +typedef struct ms_entry * (*mark_proc)(/* word * addr, mark_stack_ptr, + mark_stack_limit, env */); +# define LOG_MAX_MARK_PROCS 6 +# define MAX_MARK_PROCS (1 << LOG_MAX_MARK_PROCS) + +/* Root sets. Logically private to mark_rts.c. But we don't want the */ +/* tables scanned, so we put them here. */ +/* MAX_ROOT_SETS is the maximum number of ranges that can be */ +/* registered as static roots. */ +# ifdef LARGE_CONFIG +# define MAX_ROOT_SETS 4096 +# else +# ifdef PCR +# define MAX_ROOT_SETS 1024 +# else +# ifdef MSWIN32 +# define MAX_ROOT_SETS 512 + /* Under NT, we add only written pages, which can result */ + /* in many small root sets. */ +# else +# define MAX_ROOT_SETS 64 +# endif +# endif +# endif + +# define MAX_EXCLUSIONS (MAX_ROOT_SETS/4) +/* Maximum number of segments that can be excluded from root sets. */ + +/* + * Data structure for excluded static roots. + */ +struct exclusion { + ptr_t e_start; + ptr_t e_end; +}; + +/* Data structure for list of root sets. */ +/* We keep a hash table, so that we can filter out duplicate additions. */ +/* Under Win32, we need to do a better job of filtering overlaps, so */ +/* we resort to sequential search, and pay the price. */ +struct roots { + ptr_t r_start; + ptr_t r_end; +# ifndef MSWIN32 + struct roots * r_next; +# endif + GC_bool r_tmp; + /* Delete before registering new dynamic libraries */ +}; + +#ifndef MSWIN32 + /* Size of hash table index to roots. */ +# define LOG_RT_SIZE 6 +# define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */ +#endif + +/* Lists of all heap blocks and free lists */ +/* as well as other random data structures */ +/* that should not be scanned by the */ +/* collector. */ +/* These are grouped together in a struct */ +/* so that they can be easily skipped by the */ +/* GC_mark routine. */ +/* The ordering is weird to make GC_malloc */ +/* faster by keeping the important fields */ +/* sufficiently close together that a */ +/* single load of a base register will do. */ +/* Scalars that could easily appear to */ +/* be pointers are also put here. */ +/* The main fields should precede any */ +/* conditionally included fields, so that */ +/* gc_inl.h will work even if a different set */ +/* of macros is defined when the client is */ +/* compiled. */ + +struct _GC_arrays { + word _heapsize; + word _max_heapsize; + ptr_t _last_heap_addr; + ptr_t _prev_heap_addr; + word _words_allocd_before_gc; + /* Number of words allocated before this */ + /* collection cycle. */ + word _words_allocd; + /* Number of words allocated during this collection cycle */ + word _words_wasted; + /* Number of words wasted due to internal fragmentation */ + /* in large objects, or due to dropping blacklisted */ + /* blocks, since last gc. Approximate. */ + word _words_finalized; + /* Approximate number of words in objects (and headers) */ + /* That became ready for finalization in the last */ + /* collection. */ + word _non_gc_bytes_at_gc; + /* Number of explicitly managed bytes of storage */ + /* at last collection. */ + word _mem_freed; + /* Number of explicitly deallocated words of memory */ + /* since last collection. */ + mark_proc _mark_procs[MAX_MARK_PROCS]; + /* Table of user-defined mark procedures. There is */ + /* a small number of these, which can be referenced */ + /* by DS_PROC mark descriptors. See gc_mark.h. */ + ptr_t _objfreelist[MAXOBJSZ+1]; + /* free list for objects */ + ptr_t _aobjfreelist[MAXOBJSZ+1]; + /* free list for atomic objs */ + + ptr_t _uobjfreelist[MAXOBJSZ+1]; + /* uncollectable but traced objs */ + /* objects on this and auobjfreelist */ + /* are always marked, except during */ + /* garbage collections. */ +# ifdef ATOMIC_UNCOLLECTABLE + ptr_t _auobjfreelist[MAXOBJSZ+1]; +# endif + /* uncollectable but traced objs */ + +# ifdef GATHERSTATS + word _composite_in_use; + /* Number of words in accessible composite */ + /* objects. */ + word _atomic_in_use; + /* Number of words in accessible atomic */ + /* objects. */ +# endif +# ifdef MERGE_SIZES + unsigned _size_map[WORDS_TO_BYTES(MAXOBJSZ+1)]; + /* Number of words to allocate for a given allocation request in */ + /* bytes. */ +# endif + +# ifdef STUBBORN_ALLOC + ptr_t _sobjfreelist[MAXOBJSZ+1]; +# endif + /* free list for immutable objects */ + ptr_t _obj_map[MAXOBJSZ+1]; + /* If not NIL, then a pointer to a map of valid */ + /* object addresses. _obj_map[sz][i] is j if the */ + /* address block_start+i is a valid pointer */ + /* to an object at */ + /* block_start+i&~3 - WORDS_TO_BYTES(j). */ + /* (If ALL_INTERIOR_POINTERS is defined, then */ + /* instead ((short *)(hbh_map[sz])[i] is j if */ + /* block_start+WORDS_TO_BYTES(i) is in the */ + /* interior of an object starting at */ + /* block_start+WORDS_TO_BYTES(i-j)). */ + /* It is OBJ_INVALID if */ + /* block_start+WORDS_TO_BYTES(i) is not */ + /* valid as a pointer to an object. */ + /* We assume all values of j <= OBJ_INVALID. */ + /* The zeroth entry corresponds to large objects.*/ +# ifdef ALL_INTERIOR_POINTERS +# define map_entry_type short +# define OBJ_INVALID 0x7fff +# define MAP_ENTRY(map, bytes) \ + (((map_entry_type *)(map))[BYTES_TO_WORDS(bytes)]) +# define MAP_ENTRIES BYTES_TO_WORDS(HBLKSIZE) +# define MAP_SIZE (MAP_ENTRIES * sizeof(map_entry_type)) +# define OFFSET_VALID(displ) TRUE +# define CPP_MAX_OFFSET (HBLKSIZE - HDR_BYTES - 1) +# define MAX_OFFSET ((word)CPP_MAX_OFFSET) +# else +# define map_entry_type char +# define OBJ_INVALID 0x7f +# define MAP_ENTRY(map, bytes) \ + (map)[bytes] +# define MAP_ENTRIES HBLKSIZE +# define MAP_SIZE MAP_ENTRIES +# define CPP_MAX_OFFSET (WORDS_TO_BYTES(OBJ_INVALID) - 1) +# define MAX_OFFSET ((word)CPP_MAX_OFFSET) +# define VALID_OFFSET_SZ \ + (CPP_MAX_OFFSET > WORDS_TO_BYTES(CPP_MAXOBJSZ)? \ + CPP_MAX_OFFSET+1 \ + : WORDS_TO_BYTES(CPP_MAXOBJSZ)+1) + char _valid_offsets[VALID_OFFSET_SZ]; + /* GC_valid_offsets[i] == TRUE ==> i */ + /* is registered as a displacement. */ +# define OFFSET_VALID(displ) GC_valid_offsets[displ] + char _modws_valid_offsets[sizeof(word)]; + /* GC_valid_offsets[i] ==> */ + /* GC_modws_valid_offsets[i%sizeof(word)] */ +# endif +# ifdef STUBBORN_ALLOC + page_hash_table _changed_pages; + /* Stubborn object pages that were changes since last call to */ + /* GC_read_changed. */ + page_hash_table _prev_changed_pages; + /* Stubborn object pages that were changes before last call to */ + /* GC_read_changed. */ +# endif +# if defined(PROC_VDB) || defined(MPROTECT_VDB) + page_hash_table _grungy_pages; /* Pages that were dirty at last */ + /* GC_read_dirty. */ +# endif +# ifdef MPROTECT_VDB + VOLATILE page_hash_table _dirty_pages; + /* Pages dirtied since last GC_read_dirty. */ +# endif +# ifdef PROC_VDB + page_hash_table _written_pages; /* Pages ever dirtied */ +# endif +# ifdef LARGE_CONFIG +# if CPP_WORDSZ > 32 +# define MAX_HEAP_SECTS 4096 /* overflows at roughly 64 GB */ +# else +# define MAX_HEAP_SECTS 768 /* Separately added heap sections. */ +# endif +# else +# define MAX_HEAP_SECTS 256 +# endif + struct HeapSect { + ptr_t hs_start; word hs_bytes; + } _heap_sects[MAX_HEAP_SECTS]; +# ifdef MSWIN32 + ptr_t _heap_bases[MAX_HEAP_SECTS]; + /* Start address of memory regions obtained from kernel. */ +# endif + struct roots _static_roots[MAX_ROOT_SETS]; +# ifndef MSWIN32 + struct roots * _root_index[RT_SIZE]; +# endif + struct exclusion _excl_table[MAX_EXCLUSIONS]; + /* Block header index; see gc_headers.h */ + bottom_index * _all_nils; + bottom_index * _top_index [TOP_SZ]; +#ifdef SAVE_CALL_CHAIN + struct callinfo _last_stack[NFRAMES]; /* Stack at last garbage collection.*/ + /* Useful for debugging mysterious */ + /* object disappearances. */ + /* In the multithreaded case, we */ + /* currently only save the calling */ + /* stack. */ +#endif +}; + +GC_API GC_FAR struct _GC_arrays GC_arrays; + +# define GC_objfreelist GC_arrays._objfreelist +# define GC_aobjfreelist GC_arrays._aobjfreelist +# define GC_uobjfreelist GC_arrays._uobjfreelist +# ifdef ATOMIC_UNCOLLECTABLE +# define GC_auobjfreelist GC_arrays._auobjfreelist +# endif +# define GC_sobjfreelist GC_arrays._sobjfreelist +# define GC_valid_offsets GC_arrays._valid_offsets +# define GC_modws_valid_offsets GC_arrays._modws_valid_offsets +# ifdef STUBBORN_ALLOC +# define GC_changed_pages GC_arrays._changed_pages +# define GC_prev_changed_pages GC_arrays._prev_changed_pages +# endif +# define GC_obj_map GC_arrays._obj_map +# define GC_last_heap_addr GC_arrays._last_heap_addr +# define GC_prev_heap_addr GC_arrays._prev_heap_addr +# define GC_words_allocd GC_arrays._words_allocd +# define GC_words_wasted GC_arrays._words_wasted +# define GC_words_finalized GC_arrays._words_finalized +# define GC_non_gc_bytes_at_gc GC_arrays._non_gc_bytes_at_gc +# define GC_mem_freed GC_arrays._mem_freed +# define GC_mark_procs GC_arrays._mark_procs +# define GC_heapsize GC_arrays._heapsize +# define GC_max_heapsize GC_arrays._max_heapsize +# define GC_words_allocd_before_gc GC_arrays._words_allocd_before_gc +# define GC_heap_sects GC_arrays._heap_sects +# define GC_last_stack GC_arrays._last_stack +# ifdef MSWIN32 +# define GC_heap_bases GC_arrays._heap_bases +# endif +# define GC_static_roots GC_arrays._static_roots +# define GC_root_index GC_arrays._root_index +# define GC_excl_table GC_arrays._excl_table +# define GC_all_nils GC_arrays._all_nils +# define GC_top_index GC_arrays._top_index +# if defined(PROC_VDB) || defined(MPROTECT_VDB) +# define GC_grungy_pages GC_arrays._grungy_pages +# endif +# ifdef MPROTECT_VDB +# define GC_dirty_pages GC_arrays._dirty_pages +# endif +# ifdef PROC_VDB +# define GC_written_pages GC_arrays._written_pages +# endif +# ifdef GATHERSTATS +# define GC_composite_in_use GC_arrays._composite_in_use +# define GC_atomic_in_use GC_arrays._atomic_in_use +# endif +# ifdef MERGE_SIZES +# define GC_size_map GC_arrays._size_map +# endif + +# define beginGC_arrays ((ptr_t)(&GC_arrays)) +# define endGC_arrays (((ptr_t)(&GC_arrays)) + (sizeof GC_arrays)) + +/* Object kinds: */ +# define MAXOBJKINDS 16 + +extern struct obj_kind { + ptr_t *ok_freelist; /* Array of free listheaders for this kind of object */ + /* Point either to GC_arrays or to storage allocated */ + /* with GC_scratch_alloc. */ + struct hblk **ok_reclaim_list; + /* List headers for lists of blocks waiting to be */ + /* swept. */ + word ok_descriptor; /* Descriptor template for objects in this */ + /* block. */ + GC_bool ok_relocate_descr; + /* Add object size in bytes to descriptor */ + /* template to obtain descriptor. Otherwise */ + /* template is used as is. */ + GC_bool ok_init; /* Clear objects before putting them on the free list. */ +} GC_obj_kinds[MAXOBJKINDS]; + +# define endGC_obj_kinds (((ptr_t)(&GC_obj_kinds)) + (sizeof GC_obj_kinds)) + +# define end_gc_area ((ptr_t)endGC_arrays == (ptr_t)(&GC_obj_kinds) ? \ + endGC_obj_kinds : endGC_arrays) + +/* Predefined kinds: */ +# define PTRFREE 0 +# define NORMAL 1 +# define UNCOLLECTABLE 2 +# ifdef ATOMIC_UNCOLLECTABLE +# define AUNCOLLECTABLE 3 +# define STUBBORN 4 +# define IS_UNCOLLECTABLE(k) (((k) & ~1) == UNCOLLECTABLE) +# else +# define STUBBORN 3 +# define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE) +# endif + +extern int GC_n_kinds; + +GC_API word GC_fo_entries; + +extern word GC_n_heap_sects; /* Number of separately added heap */ + /* sections. */ + +extern word GC_page_size; + +# ifdef MSWIN32 +extern word GC_n_heap_bases; /* See GC_heap_bases. */ +# endif + +extern word GC_total_stack_black_listed; + /* Number of bytes on stack blacklist. */ + +extern word GC_black_list_spacing; + /* Average number of bytes between blacklisted */ + /* blocks. Approximate. */ + /* Counts only blocks that are */ + /* "stack-blacklisted", i.e. that are */ + /* problematic in the interior of an object. */ + +extern char * GC_invalid_map; + /* Pointer to the nowhere valid hblk map */ + /* Blocks pointing to this map are free. */ + +extern struct hblk * GC_hblkfreelist; + /* List of completely empty heap blocks */ + /* Linked through hb_next field of */ + /* header structure associated with */ + /* block. */ + +extern GC_bool GC_is_initialized; /* GC_init() has been run. */ + +extern GC_bool GC_objects_are_marked; /* There are marked objects in */ + /* the heap. */ + +#ifndef SMALL_CONFIG + extern GC_bool GC_incremental; + /* Using incremental/generational collection. */ +#else +# define GC_incremental TRUE + /* Hopefully allow optimizer to remove some code. */ +#endif + +extern GC_bool GC_dirty_maintained; + /* Dirty bits are being maintained, */ + /* either for incremental collection, */ + /* or to limit the root set. */ + +# ifndef PCR + extern ptr_t GC_stackbottom; /* Cool end of user stack */ +# endif + +extern word GC_root_size; /* Total size of registered root sections */ + +extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */ + +extern ptr_t GC_least_plausible_heap_addr; +extern ptr_t GC_greatest_plausible_heap_addr; + /* Bounds on the heap. Guaranteed valid */ + /* Likely to include future heap expansion. */ + +/* Operations */ +# ifndef abs +# define abs(x) ((x) < 0? (-(x)) : (x)) +# endif + + +/* Marks are in a reserved area in */ +/* each heap block. Each word has one mark bit associated */ +/* with it. Only those corresponding to the beginning of an */ +/* object are used. */ + + +/* Mark bit operations */ + +/* + * Retrieve, set, clear the mark bit corresponding + * to the nth word in a given heap block. + * + * (Recall that bit n corresponds to object beginning at word n + * relative to the beginning of the block, including unused words) + */ + +# define mark_bit_from_hdr(hhdr,n) (((hhdr)->hb_marks[divWORDSZ(n)] \ + >> (modWORDSZ(n))) & (word)1) +# define set_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \ + |= (word)1 << modWORDSZ(n) + +# define clear_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \ + &= ~((word)1 << modWORDSZ(n)) + +/* Important internal collector routines */ + +ptr_t GC_approx_sp(); + +GC_bool GC_should_collect(); +#ifdef PRESERVE_LAST + GC_bool GC_in_last_heap_sect(/* ptr_t */); + /* In last added heap section? If so, avoid breaking up. */ +#endif +void GC_apply_to_all_blocks(/*fn, client_data*/); + /* Invoke fn(hbp, client_data) for each */ + /* allocated heap block. */ +struct hblk * GC_next_block(/* struct hblk * h */); +void GC_mark_init(); +void GC_clear_marks(); /* Clear mark bits for all heap objects. */ +void GC_invalidate_mark_state(); /* Tell the marker that marked */ + /* objects may point to unmarked */ + /* ones, and roots may point to */ + /* unmarked objects. */ + /* Reset mark stack. */ +void GC_mark_from_mark_stack(); /* Mark from everything on the mark stack. */ + /* Return after about one pages worth of */ + /* work. */ +GC_bool GC_mark_stack_empty(); +GC_bool GC_mark_some(); /* Perform about one pages worth of marking */ + /* work of whatever kind is needed. Returns */ + /* quickly if no collection is in progress. */ + /* Return TRUE if mark phase finished. */ +void GC_initiate_gc(); /* initiate collection. */ + /* If the mark state is invalid, this */ + /* becomes full colleection. Otherwise */ + /* it's partial. */ +void GC_push_all(/*b,t*/); /* Push everything in a range */ + /* onto mark stack. */ +void GC_push_dirty(/*b,t*/); /* Push all possibly changed */ + /* subintervals of [b,t) onto */ + /* mark stack. */ +#ifndef SMALL_CONFIG + void GC_push_conditional(/* ptr_t b, ptr_t t, GC_bool all*/); +#else +# define GC_push_conditional(b, t, all) GC_push_all(b, t) +#endif + /* Do either of the above, depending */ + /* on the third arg. */ +void GC_push_all_stack(/*b,t*/); /* As above, but consider */ + /* interior pointers as valid */ +void GC_push_roots(/* GC_bool all */); /* Push all or dirty roots. */ +extern void (*GC_push_other_roots)(); + /* Push system or application specific roots */ + /* onto the mark stack. In some environments */ + /* (e.g. threads environments) this is */ + /* predfined to be non-zero. A client supplied */ + /* replacement should also call the original */ + /* function. */ +extern void (*GC_start_call_back)(/* void */); + /* Called at start of full collections. */ + /* Not called if 0. Called with allocation */ + /* lock held. */ + /* 0 by default. */ +void GC_push_regs(); /* Push register contents onto mark stack. */ +void GC_remark(); /* Mark from all marked objects. Used */ + /* only if we had to drop something. */ +# if defined(MSWIN32) + void __cdecl GC_push_one(); +# else + void GC_push_one(/*p*/); /* If p points to an object, mark it */ + /* and push contents on the mark stack */ +# endif +void GC_push_one_checked(/*p*/); /* Ditto, omits plausibility test */ +void GC_push_marked(/* struct hblk h, hdr * hhdr */); + /* Push contents of all marked objects in h onto */ + /* mark stack. */ +#ifdef SMALL_CONFIG +# define GC_push_next_marked_dirty(h) GC_push_next_marked(h) +#else + struct hblk * GC_push_next_marked_dirty(/* h */); + /* Invoke GC_push_marked on next dirty block above h. */ + /* Return a pointer just past the end of this block. */ +#endif /* !SMALL_CONFIG */ +struct hblk * GC_push_next_marked(/* h */); + /* Ditto, but also mark from clean pages. */ +struct hblk * GC_push_next_marked_uncollectable(/* h */); + /* Ditto, but mark only from uncollectable pages. */ +GC_bool GC_stopped_mark(); /* Stop world and mark from all roots */ + /* and rescuers. */ +void GC_clear_hdr_marks(/* hhdr */); /* Clear the mark bits in a header */ +void GC_set_hdr_marks(/* hhdr */); /* Set the mark bits in a header */ +void GC_add_roots_inner(); +GC_bool GC_is_static_root(/* ptr_t p */); + /* Is the address p in one of the registered static */ + /* root sections? */ +void GC_register_dynamic_libraries(); + /* Add dynamic library data sections to the root set. */ + +/* Machine dependent startup routines */ +ptr_t GC_get_stack_base(); +void GC_register_data_segments(); + +/* Black listing: */ +void GC_bl_init(); +# ifndef ALL_INTERIOR_POINTERS + void GC_add_to_black_list_normal(/* bits, maybe source */); + /* Register bits as a possible future false */ + /* reference from the heap or static data */ +# ifdef PRINT_BLACK_LIST +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_normal(bits, source) +# else +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_normal(bits) +# endif +# else +# ifdef PRINT_BLACK_LIST +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_stack(bits, source) +# else +# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ + GC_add_to_black_list_stack(bits) +# endif +# endif + +void GC_add_to_black_list_stack(/* bits, maybe source */); +struct hblk * GC_is_black_listed(/* h, len */); + /* If there are likely to be false references */ + /* to a block starting at h of the indicated */ + /* length, then return the next plausible */ + /* starting location for h that might avoid */ + /* these false references. */ +void GC_promote_black_lists(); + /* Declare an end to a black listing phase. */ +void GC_unpromote_black_lists(); + /* Approximately undo the effect of the above. */ + /* This actually loses some information, but */ + /* only in a reasonably safe way. */ +word GC_number_stack_black_listed(/*struct hblk *start, struct hblk *endp1 */); + /* Return the number of (stack) blacklisted */ + /* blocks in the range for statistical */ + /* purposes. */ + +ptr_t GC_scratch_alloc(/*bytes*/); + /* GC internal memory allocation for */ + /* small objects. Deallocation is not */ + /* possible. */ + +/* Heap block layout maps: */ +void GC_invalidate_map(/* hdr */); + /* Remove the object map associated */ + /* with the block. This identifies */ + /* the block as invalid to the mark */ + /* routines. */ +GC_bool GC_add_map_entry(/*sz*/); + /* Add a heap block map for objects of */ + /* size sz to obj_map. */ + /* Return FALSE on failure. */ +void GC_register_displacement_inner(/*offset*/); + /* Version of GC_register_displacement */ + /* that assumes lock is already held */ + /* and signals are already disabled. */ + +/* hblk allocation: */ +void GC_new_hblk(/*size_in_words, kind*/); + /* Allocate a new heap block, and build */ + /* a free list in it. */ +struct hblk * GC_allochblk(/*size_in_words, kind*/); + /* Allocate a heap block, clear it if */ + /* for composite objects, inform */ + /* the marker that block is valid */ + /* for objects of indicated size. */ + /* sz < 0 ==> atomic. */ +void GC_freehblk(); /* Deallocate a heap block and mark it */ + /* as invalid. */ + +/* Misc GC: */ +void GC_init_inner(); +GC_bool GC_expand_hp_inner(); +void GC_start_reclaim(/*abort_if_found*/); + /* Restore unmarked objects to free */ + /* lists, or (if abort_if_found is */ + /* TRUE) report them. */ + /* Sweeping of small object pages is */ + /* largely deferred. */ +void GC_continue_reclaim(/*size, kind*/); + /* Sweep pages of the given size and */ + /* kind, as long as possible, and */ + /* as long as the corr. free list is */ + /* empty. */ +void GC_reclaim_or_delete_all(); + /* Arrange for all reclaim lists to be */ + /* empty. Judiciously choose between */ + /* sweeping and discarding each page. */ +GC_bool GC_reclaim_all(/* GC_stop_func f*/); + /* Reclaim all blocks. Abort (in a */ + /* consistent state) if f returns TRUE. */ +GC_bool GC_block_empty(/* hhdr */); /* Block completely unmarked? */ +GC_bool GC_never_stop_func(); /* Returns FALSE. */ +GC_bool GC_try_to_collect_inner(/* GC_stop_func f */); + /* Collect; caller must have acquired */ + /* lock and disabled signals. */ + /* Collection is aborted if f returns */ + /* TRUE. Returns TRUE if it completes */ + /* successfully. */ +# define GC_gcollect_inner() \ + (void) GC_try_to_collect_inner(GC_never_stop_func) +void GC_finish_collection(); /* Finish collection. Mark bits are */ + /* consistent and lock is still held. */ +GC_bool GC_collect_or_expand(/* needed_blocks */); + /* Collect or expand heap in an attempt */ + /* make the indicated number of free */ + /* blocks available. Should be called */ + /* until the blocks are available or */ + /* until it fails by returning FALSE. */ +GC_API void GC_init(); /* Initialize collector. */ +void GC_collect_a_little_inner(/* int n */); + /* Do n units worth of garbage */ + /* collection work, if appropriate. */ + /* A unit is an amount appropriate for */ + /* HBLKSIZE bytes of allocation. */ +ptr_t GC_generic_malloc(/* bytes, kind */); + /* Allocate an object of the given */ + /* kind. By default, there are only */ + /* a few kinds: composite(pointerfree), */ + /* atomic, uncollectable, etc. */ + /* We claim it's possible for clever */ + /* client code that understands GC */ + /* internals to add more, e.g. to */ + /* communicate object layout info */ + /* to the collector. */ +ptr_t GC_generic_malloc_ignore_off_page(/* bytes, kind */); + /* As above, but pointers past the */ + /* first page of the resulting object */ + /* are ignored. */ +ptr_t GC_generic_malloc_inner(/* bytes, kind */); + /* Ditto, but I already hold lock, etc. */ +ptr_t GC_generic_malloc_words_small GC_PROTO((size_t words, int kind)); + /* As above, but size in units of words */ + /* Bypasses MERGE_SIZES. Assumes */ + /* words <= MAXOBJSZ. */ +ptr_t GC_generic_malloc_inner_ignore_off_page(/* bytes, kind */); + /* Allocate an object, where */ + /* the client guarantees that there */ + /* will always be a pointer to the */ + /* beginning of the object while the */ + /* object is live. */ +ptr_t GC_allocobj(/* sz_inn_words, kind */); + /* Make the indicated */ + /* free list nonempty, and return its */ + /* head. */ + +void GC_init_headers(); +GC_bool GC_install_header(/*h*/); + /* Install a header for block h. */ + /* Return FALSE on failure. */ +GC_bool GC_install_counts(/*h, sz*/); + /* Set up forwarding counts for block */ + /* h of size sz. */ + /* Return FALSE on failure. */ +void GC_remove_header(/*h*/); + /* Remove the header for block h. */ +void GC_remove_counts(/*h, sz*/); + /* Remove forwarding counts for h. */ +hdr * GC_find_header(/*p*/); /* Debugging only. */ + +void GC_finalize(); /* Perform all indicated finalization actions */ + /* on unmarked objects. */ + /* Unreachable finalizable objects are enqueued */ + /* for processing by GC_invoke_finalizers. */ + /* Invoked with lock. */ + +void GC_add_to_heap(/*p, bytes*/); + /* Add a HBLKSIZE aligned chunk to the heap. */ + +void GC_print_obj(/* ptr_t p */); + /* P points to somewhere inside an object with */ + /* debugging info. Print a human readable */ + /* description of the object to stderr. */ +extern void (*GC_check_heap)(); + /* Check that all objects in the heap with */ + /* debugging info are intact. Print */ + /* descriptions of any that are not. */ +extern void (*GC_print_heap_obj)(/* ptr_t p */); + /* If possible print s followed by a more */ + /* detailed description of the object */ + /* referred to by p. */ + +/* Virtual dirty bit implementation: */ +/* Each implementation exports the following: */ +void GC_read_dirty(); /* Retrieve dirty bits. */ +GC_bool GC_page_was_dirty(/* struct hblk * h */); + /* Read retrieved dirty bits. */ +GC_bool GC_page_was_ever_dirty(/* struct hblk * h */); + /* Could the page contain valid heap pointers? */ +void GC_is_fresh(/* struct hblk * h, word number_of_blocks */); + /* Assert the region currently contains no */ + /* valid pointers. */ +void GC_write_hint(/* struct hblk * h */); + /* h is about to be written. */ +void GC_dirty_init(); + +/* Slow/general mark bit manipulation: */ +GC_API GC_bool GC_is_marked(); +void GC_clear_mark_bit(); +void GC_set_mark_bit(); + +/* Stubborn objects: */ +void GC_read_changed(); /* Analogous to GC_read_dirty */ +GC_bool GC_page_was_changed(/* h */); /* Analogous to GC_page_was_dirty */ +void GC_clean_changing_list(); /* Collect obsolete changing list entries */ +void GC_stubborn_init(); + +/* Debugging print routines: */ +void GC_print_block_list(); +void GC_print_hblkfreelist(); +void GC_print_heap_sects(); +void GC_print_static_roots(); +void GC_dump(); + +/* Make arguments appear live to compiler */ +# ifdef __WATCOMC__ + void GC_noop(void*, ...); +# else + GC_API void GC_noop(); +# endif + +void GC_noop1(/* word arg */); + +/* Logging and diagnostic output: */ +GC_API void GC_printf GC_PROTO((char * format, long, long, long, long, long, long)); + /* A version of printf that doesn't allocate, */ + /* is restricted to long arguments, and */ + /* (unfortunately) doesn't use varargs for */ + /* portability. Restricted to 6 args and */ + /* 1K total output length. */ + /* (We use sprintf. Hopefully that doesn't */ + /* allocate for long arguments.) */ +# define GC_printf0(f) GC_printf(f, 0l, 0l, 0l, 0l, 0l, 0l) +# define GC_printf1(f,a) GC_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l) +# define GC_printf2(f,a,b) GC_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l) +# define GC_printf3(f,a,b,c) GC_printf(f, (long)a, (long)b, (long)c, 0l, 0l, 0l) +# define GC_printf4(f,a,b,c,d) GC_printf(f, (long)a, (long)b, (long)c, \ + (long)d, 0l, 0l) +# define GC_printf5(f,a,b,c,d,e) GC_printf(f, (long)a, (long)b, (long)c, \ + (long)d, (long)e, 0l) +# define GC_printf6(f,a,b,c,d,e,g) GC_printf(f, (long)a, (long)b, (long)c, \ + (long)d, (long)e, (long)g) + +void GC_err_printf(/* format, a, b, c, d, e, f */); +# define GC_err_printf0(f) GC_err_puts(f) +# define GC_err_printf1(f,a) GC_err_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l) +# define GC_err_printf2(f,a,b) GC_err_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l) +# define GC_err_printf3(f,a,b,c) GC_err_printf(f, (long)a, (long)b, (long)c, \ + 0l, 0l, 0l) +# define GC_err_printf4(f,a,b,c,d) GC_err_printf(f, (long)a, (long)b, \ + (long)c, (long)d, 0l, 0l) +# define GC_err_printf5(f,a,b,c,d,e) GC_err_printf(f, (long)a, (long)b, \ + (long)c, (long)d, \ + (long)e, 0l) +# define GC_err_printf6(f,a,b,c,d,e,g) GC_err_printf(f, (long)a, (long)b, \ + (long)c, (long)d, \ + (long)e, (long)g) + /* Ditto, writes to stderr. */ + +void GC_err_puts(/* char *s */); + /* Write s to stderr, don't buffer, don't add */ + /* newlines, don't ... */ + + +# endif /* GC_PRIVATE_H */ diff --git a/support/gc/include/private/gcconfig.h b/support/gc/include/private/gcconfig.h new file mode 100644 index 00000000..e550e944 --- /dev/null +++ b/support/gc/include/private/gcconfig.h @@ -0,0 +1,1033 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#ifndef CONFIG_H + +# define CONFIG_H + +/* Machine dependent parameters. Some tuning parameters can be found */ +/* near the top of gc_private.h. */ + +/* Machine specific parts contributed by various people. See README file. */ + +/* First a unified test for Linux: */ +# if defined(linux) || defined(__linux__) +# define LINUX +# endif + +/* Determine the machine type: */ +# if defined(sun) && defined(mc68000) +# define M68K +# define SUNOS4 +# define mach_type_known +# endif +# if defined(hp9000s300) +# define M68K +# define HP +# define mach_type_known +# endif +# if defined(__NetBSD__) && defined(m68k) +# define M68K +# define NETBSD +# define mach_type_known +# endif +# if defined(vax) +# define VAX +# ifdef ultrix +# define ULTRIX +# else +# define BSD +# endif +# define mach_type_known +# endif +# if defined(mips) || defined(__mips) +# define MIPS +# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) +# define ULTRIX +# else +# if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__) +# define IRIX5 /* or IRIX 6.X */ +# else +# define RISCOS /* or IRIX 4.X */ +# endif +# endif +# define mach_type_known +# endif +# if defined(sequent) && defined(i386) +# define I386 +# define SEQUENT +# define mach_type_known +# endif +# if defined(sun) && defined(i386) +# define I386 +# define SUNOS5 +# define mach_type_known +# endif +# if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__) +# define I386 +# define OS2 +# define mach_type_known +# endif +# if defined(ibm032) +# define RT +# define mach_type_known +# endif +# if defined(sun) && (defined(sparc) || defined(__sparc)) +# define SPARC + /* Test for SunOS 5.x */ +# include +# ifdef ECHRNG +# define SUNOS5 +# else +# define SUNOS4 +# endif +# define mach_type_known +# endif +# if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) +# define SPARC +# define DRSNX +# define mach_type_known +# endif +# if defined(_IBMR2) +# define RS6000 +# define mach_type_known +# endif +# if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386) + /* The above test may need refinement */ +# define I386 +# if defined(_SCO_ELF) +# define SCO_ELF +# else +# define SCO +# endif +# define mach_type_known +# endif +# if defined(_AUX_SOURCE) +# define M68K +# define SYSV +# define mach_type_known +# endif +# if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) \ + || defined(hppa) || defined(__hppa__) +# define HP_PA +# define mach_type_known +# endif +# if defined(LINUX) && defined(i386) +# define I386 +# define mach_type_known +# endif +# if defined(LINUX) && defined(powerpc) +# define POWERPC +# define mach_type_known +# endif +# if defined(LINUX) && defined(__mc68000__) +# define M68K +# define mach_type_known +# endif +# if defined(linux) && defined(sparc) +# define SPARC +# define LINUX +# define mach_type_known +# endif +# if defined(__alpha) || defined(__alpha__) +# define ALPHA +# if !defined(LINUX) +# define OSF1 /* a.k.a Digital Unix */ +# endif +# define mach_type_known +# endif +# if defined(_AMIGA) +# define M68K +# define AMIGA +# define mach_type_known +# endif +# if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc) +# define M68K +# define MACOS +# define mach_type_known +# endif +# if defined(__MWERKS__) && defined(__powerc) +# define POWERPC +# define MACOS +# define mach_type_known +# endif +# if defined(NeXT) && defined(mc68000) +# define M68K +# define NEXT +# define mach_type_known +# endif +# if defined(NeXT) && defined(i386) +# define I386 +# define NEXT +# define mach_type_known +# endif +# if defined(__FreeBSD__) && defined(i386) +# define I386 +# define FREEBSD +# define mach_type_known +# endif +# if defined(__NetBSD__) && defined(i386) +# define I386 +# define NETBSD +# define mach_type_known +# endif +# if defined(bsdi) && defined(i386) +# define I386 +# define BSDI +# define mach_type_known +# endif +# if !defined(mach_type_known) && defined(__386BSD__) +# define I386 +# define THREE86BSD +# define mach_type_known +# endif +# if defined(_CX_UX) && defined(_M88K) +# define M88K +# define CX_UX +# define mach_type_known +# endif +# if defined(DGUX) +# define M88K + /* DGUX defined */ +# define mach_type_known +# endif +# if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \ + || defined(_WIN32) +# define I386 +# define MSWIN32 /* or Win32s */ +# define mach_type_known +# endif +# if defined(__DJGPP__) +# define I386 +# ifndef DJGPP +# define DJGPP /* MSDOS running the DJGPP port of GCC */ +# endif +# define mach_type_known +# endif +# if defined(__CYGWIN32__) +# define I386 +# define CYGWIN32 +# define mach_type_known +# endif +# if defined(__BORLANDC__) +# define I386 +# define MSWIN32 +# define mach_type_known +# endif +# if defined(_UTS) && !defined(mach_type_known) +# define S370 +# define UTS4 +# define mach_type_known +# endif +/* Ivan Demakov */ +# if defined(__WATCOMC__) && defined(__386__) +# define I386 +# if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW) +# if defined(__OS2__) +# define OS2 +# else +# if defined(__WINDOWS_386__) || defined(__NT__) +# define MSWIN32 +# else +# define DOS4GW +# endif +# endif +# endif +# define mach_type_known +# endif + +/* Feel free to add more clauses here */ + +/* Or manually define the machine type here. A machine type is */ +/* characterized by the architecture. Some */ +/* machine types are further subdivided by OS. */ +/* the macros ULTRIX, RISCOS, and BSD to distinguish. */ +/* Note that SGI IRIX is treated identically to RISCOS. */ +/* SYSV on an M68K actually means A/UX. */ +/* The distinction in these cases is usually the stack starting address */ +# ifndef mach_type_known + --> unknown machine type +# endif + /* Mapping is: M68K ==> Motorola 680X0 */ + /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */ + /* MACOS and AMIGA variants) */ + /* I386 ==> Intel 386 */ + /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */ + /* FREEBSD, THREE86BSD, MSWIN32, */ + /* BSDI,SUNOS5, NEXT, other variants) */ + /* NS32K ==> Encore Multimax */ + /* MIPS ==> R2000 or R3000 */ + /* (RISCOS, ULTRIX variants) */ + /* VAX ==> DEC VAX */ + /* (BSD, ULTRIX variants) */ + /* RS6000 ==> IBM RS/6000 AIX3.X */ + /* RT ==> IBM PC/RT */ + /* HP_PA ==> HP9000/700 & /800 */ + /* HP/UX */ + /* SPARC ==> SPARC under SunOS */ + /* (SUNOS4, SUNOS5, */ + /* DRSNX variants) */ + /* ALPHA ==> DEC Alpha */ + /* (OSF1 and LINUX variants) */ + /* M88K ==> Motorola 88XX0 */ + /* (CX_UX and DGUX) */ + /* S370 ==> 370-like machine */ + /* running Amdahl UTS4 */ + + +/* + * For each architecture and OS, the following need to be defined: + * + * CPP_WORD_SZ is a simple integer constant representing the word size. + * in bits. We assume byte addressibility, where a byte has 8 bits. + * We also assume CPP_WORD_SZ is either 32 or 64. + * (We care about the length of pointers, not hardware + * bus widths. Thus a 64 bit processor with a C compiler that uses + * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.) + * + * MACH_TYPE is a string representation of the machine type. + * OS_TYPE is analogous for the OS. + * + * ALIGNMENT is the largest N, such that + * all pointer are guaranteed to be aligned on N byte boundaries. + * defining it to be 1 will always work, but perform poorly. + * + * DATASTART is the beginning of the data segment. + * On UNIX systems, the collector will scan the area between DATASTART + * and DATAEND for root pointers. + * + * DATAEND, if not &end. + * + * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice + * the pointer size. + * + * STACKBOTTOM is the cool end of the stack, which is usually the + * highest address in the stack. + * Under PCR or OS/2, we have other ways of finding thread stacks. + * For each machine, the following should: + * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and + * 2) define exactly one of + * STACKBOTTOM (should be defined to be an expression) + * HEURISTIC1 + * HEURISTIC2 + * If either of the last two macros are defined, then STACKBOTTOM is computed + * during collector startup using one of the following two heuristics: + * HEURISTIC1: Take an address inside GC_init's frame, and round it up to + * the next multiple of STACK_GRAN. + * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly + * in small steps (decrement if STACK_GROWS_UP), and read the value + * at each location. Remember the value when the first + * Segmentation violation or Bus error is signalled. Round that + * to the nearest plausible page boundary, and use that instead + * of STACKBOTTOM. + * + * If no expression for STACKBOTTOM can be found, and neither of the above + * heuristics are usable, the collector can still be used with all of the above + * undefined, provided one of the following is done: + * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s) + * without reference to STACKBOTTOM. This is appropriate for use in + * conjunction with thread packages, since there will be multiple stacks. + * (Allocating thread stacks in the heap, and treating them as ordinary + * heap data objects is also possible as a last resort. However, this is + * likely to introduce significant amounts of excess storage retention + * unless the dead parts of the thread stacks are periodically cleared.) + * 2) Client code may set GC_stackbottom before calling any GC_ routines. + * If the author of the client code controls the main program, this is + * easily accomplished by introducing a new main program, setting + * GC_stackbottom to the address of a local variable, and then calling + * the original main program. The new main program would read something + * like: + * + * # include "gc_private.h" + * + * main(argc, argv, envp) + * int argc; + * char **argv, **envp; + * { + * int dummy; + * + * GC_stackbottom = (ptr_t)(&dummy); + * return(real_main(argc, argv, envp)); + * } + * + * + * Each architecture may also define the style of virtual dirty bit + * implementation to be used: + * MPROTECT_VDB: Write protect the heap and catch faults. + * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits. + * + * An architecture may define DYNAMIC_LOADING if dynamic_load.c + * defined GC_register_dynamic_libraries() for the architecture. + */ + + +# define STACK_GRAN 0x1000000 +# ifdef M68K +# define MACH_TYPE "M68K" +# define ALIGNMENT 2 +# ifdef NETBSD +# define OS_TYPE "NETBSD" +# define HEURISTIC2 + extern char etext; +# define DATASTART ((ptr_t)(&etext)) +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# define STACKBOTTOM ((ptr_t)0xf0000000) +# define MPROTECT_VDB +# ifdef __ELF__ +# define DYNAMIC_LOADING + extern char **__environ; +# define DATASTART ((ptr_t)(&__environ)) + /* hideous kludge: __environ is the first */ + /* word in crt0.o, and delimits the start */ + /* of the data segment, no matter which */ + /* ld options were passed through. */ + /* We could use _etext instead, but that */ + /* would include .rodata, which may */ + /* contain large read-only data tables */ + /* that we'd rather not scan. */ + extern int _end; +# define DATAEND (&_end) +# else + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# endif +# endif +# ifdef SUNOS4 +# define OS_TYPE "SUNOS4" + extern char etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff)) +# define HEURISTIC1 /* differs */ +# define DYNAMIC_LOADING +# endif +# ifdef HP +# define OS_TYPE "HP" + extern char etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# define STACKBOTTOM ((ptr_t) 0xffeffffc) + /* empirically determined. seems to work. */ +# include +# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) +# endif +# ifdef SYSV +# define OS_TYPE "SYSV" + extern etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \ + & ~0x3fffff) \ + +((word)&etext & 0x1fff)) + /* This only works for shared-text binaries with magic number 0413. + The other sorts of SysV binaries put the data at the end of the text, + in which case the default of &etext would work. Unfortunately, + handling both would require having the magic-number available. + -- Parag + */ +# define STACKBOTTOM ((ptr_t)0xFFFFFFFE) + /* The stack starts at the top of memory, but */ + /* 0x0 cannot be used as setjump_test complains */ + /* that the stack direction is incorrect. Two */ + /* bytes down from 0x0 should be safe enough. */ + /* --Parag */ +# include +# define GETPAGESIZE() PAGESIZE /* Is this still right? */ +# endif +# ifdef AMIGA +# define OS_TYPE "AMIGA" + /* STACKBOTTOM and DATASTART handled specially */ + /* in os_dep.c */ +# define DATAEND /* not needed */ +# define GETPAGESIZE() 4096 +# endif +# ifdef MACOS +# ifndef __LOWMEM__ +# include +# endif +# define OS_TYPE "MACOS" + /* see os_dep.c for details of global data segments. */ +# define STACKBOTTOM ((ptr_t) LMGetCurStackBase()) +# define DATAEND /* not needed */ +# define GETPAGESIZE() 4096 +# endif +# ifdef NEXT +# define OS_TYPE "NEXT" +# define DATASTART ((ptr_t) get_etext()) +# define STACKBOTTOM ((ptr_t) 0x4000000) +# define DATAEND /* not needed */ +# endif +# endif + +# ifdef POWERPC +# define MACH_TYPE "POWERPC" +# define ALIGNMENT 2 +# ifdef MACOS +# ifndef __LOWMEM__ +# include +# endif +# define OS_TYPE "MACOS" + /* see os_dep.c for details of global data segments. */ +# define STACKBOTTOM ((ptr_t) LMGetCurStackBase()) +# define DATAEND /* not needed */ +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# define STACKBOTTOM ((ptr_t)0x80000000) +# define DATASTART GC_data_start + extern int _end; +# define DATAEND (&_end) +# endif +# endif + +# ifdef VAX +# define MACH_TYPE "VAX" +# define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */ + extern char etext; +# define DATASTART ((ptr_t)(&etext)) +# ifdef BSD +# define OS_TYPE "BSD" +# define HEURISTIC1 + /* HEURISTIC2 may be OK, but it's hard to test. */ +# endif +# ifdef ULTRIX +# define OS_TYPE "ULTRIX" +# define STACKBOTTOM ((ptr_t) 0x7fffc800) +# endif +# endif + +# ifdef RT +# define MACH_TYPE "RT" +# define ALIGNMENT 4 +# define DATASTART ((ptr_t) 0x10000000) +# define STACKBOTTOM ((ptr_t) 0x1fffd800) +# endif + +# ifdef SPARC +# define MACH_TYPE "SPARC" +# define ALIGNMENT 4 /* Required by hardware */ +# define ALIGN_DOUBLE + extern int etext; +# ifdef SUNOS5 +# define OS_TYPE "SUNOS5" + extern int _etext; + extern int _end; + extern char * GC_SysVGetDataStart(); +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext) +# define DATAEND (&_end) +# ifndef USE_MMAP +# define USE_MMAP +# endif +# ifdef USE_MMAP +# define HEAP_START (ptr_t)0x40000000 +# else +# define HEAP_START DATAEND +# endif +# define PROC_VDB +/* HEURISTIC1 reportedly no longer works under 2.7. Thus we */ +/* switched to HEURISTIC2, eventhough it creates some debugging */ +/* issues. */ +# define HEURISTIC2 +# include +# define GETPAGESIZE() sysconf(_SC_PAGESIZE) + /* getpagesize() appeared to be missing from at least one */ + /* Solaris 5.4 installation. Weird. */ +# define DYNAMIC_LOADING +# endif +# ifdef SUNOS4 +# define OS_TYPE "SUNOS4" + /* [If you have a weak stomach, don't read this.] */ + /* We would like to use: */ +/* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */ + /* This fails occasionally, due to an ancient, but very */ + /* persistent ld bug. &etext is set 32 bytes too high. */ + /* We instead read the text segment size from the a.out */ + /* header, which happens to be mapped into our address space */ + /* at the start of the text segment. The detective work here */ + /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */ + /* Serpette of INRIA. */ + /* This assumes ZMAGIC, i.e. demand-loadable executables. */ +# define TEXTSTART 0x2000 +# define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART)) +# define MPROTECT_VDB +# define HEURISTIC1 +# define DYNAMIC_LOADING +# endif +# ifdef DRSNX +# define CPP_WORDSZ 32 +# define OS_TYPE "DRSNX" + extern char * GC_SysVGetDataStart(); + extern int etext; +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext) +# define MPROTECT_VDB +# define STACKBOTTOM ((ptr_t) 0xdfff0000) +# define DYNAMIC_LOADING +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# ifdef __ELF__ +# define DATASTART GC_data_start +# define DYNAMIC_LOADING +# else + Linux Sparc non elf ? +# endif + extern int _end; +# define DATAEND (&_end) +# define SVR4 +# define STACKBOTTOM ((ptr_t) 0xf0000000) +# endif +# endif + +# ifdef I386 +# define MACH_TYPE "I386" +# define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */ + /* except Borland. The -a4 option fixes */ + /* Borland. */ + /* Ivan Demakov: For Watcom the option is -zp4. */ +# ifndef SMALL_CONFIG +# define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */ + /* improvement on Pentiums. */ +# endif +# ifdef SEQUENT +# define OS_TYPE "SEQUENT" + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# define STACKBOTTOM ((ptr_t) 0x3ffff000) +# endif +# ifdef SUNOS5 +# define OS_TYPE "SUNOS5" + extern int etext, _start; + extern char * GC_SysVGetDataStart(); +# define DATASTART GC_SysVGetDataStart(0x1000, &etext) +# define STACKBOTTOM ((ptr_t)(&_start)) +/** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */ +/*# define PROC_VDB*/ +# define DYNAMIC_LOADING +# ifndef USE_MMAP +# define USE_MMAP +# endif +# ifdef USE_MMAP +# define HEAP_START (ptr_t)0x40000000 +# else +# define HEAP_START DATAEND +# endif +# endif +# ifdef SCO +# define OS_TYPE "SCO" + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \ + & ~0x3fffff) \ + +((word)&etext & 0xfff)) +# define STACKBOTTOM ((ptr_t) 0x7ffffffc) +# endif +# ifdef SCO_ELF +# define OS_TYPE "SCO_ELF" + extern int etext; +# define DATASTART ((ptr_t)(&etext)) +# define STACKBOTTOM ((ptr_t) 0x08048000) +# define DYNAMIC_LOADING +# define ELF_CLASS ELFCLASS32 +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# define STACKBOTTOM ((ptr_t)0xc0000000) + /* Appears to be 0xe0000000 for at least one 2.1.91 kernel. */ + /* Probably needs to be more flexible, but I don't yet */ + /* fully understand how flexible. */ +# if !defined(LINUX_THREADS) || !defined(REDIRECT_MALLOC) +# define MPROTECT_VDB +# else + /* We seem to get random errors in incremental mode, */ + /* possibly because Linux threads is itself a malloc client */ + /* and can't deal with the signals. */ +# endif +# ifdef __ELF__ +# define DYNAMIC_LOADING +# ifdef UNDEFINED /* includes ro data */ + extern int _etext; +# define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff)) +# endif +# include +# if defined(__GLIBC__) && __GLIBC__ >= 2 + extern int __data_start; +# define DATASTART ((ptr_t)(&__data_start)) +# else + extern char **__environ; +# define DATASTART ((ptr_t)(&__environ)) + /* hideous kludge: __environ is the first */ + /* word in crt0.o, and delimits the start */ + /* of the data segment, no matter which */ + /* ld options were passed through. */ + /* We could use _etext instead, but that */ + /* would include .rodata, which may */ + /* contain large read-only data tables */ + /* that we'd rather not scan. */ +# endif + extern int _end; +# define DATAEND (&_end) +# else + extern int etext; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff)) +# endif +# endif +# ifdef CYGWIN32 +# define OS_TYPE "CYGWIN32" + extern int _data_start__; + extern int _data_end__; + extern int _bss_start__; + extern int _bss_end__; + /* For binutils 2.9.1, we have */ + /* DATASTART = _data_start__ */ + /* DATAEND = _bss_end__ */ + /* whereas for some earlier versions it was */ + /* DATASTART = _bss_start__ */ + /* DATAEND = _data_end__ */ + /* To get it right for both, we take the */ + /* minumum/maximum of the two. */ +# define MAX(x,y) ((x) > (y) ? (x) : (y)) +# define MIN(x,y) ((x) < (y) ? (x) : (y)) +# define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__)) +# define DATAEND ((ptr_t) MAX(&_data_end__, &_bss_end__)) +# undef STACK_GRAN +# define STACK_GRAN 0x10000 +# define HEURISTIC1 +# endif +# ifdef OS2 +# define OS_TYPE "OS2" + /* STACKBOTTOM and DATASTART are handled specially in */ + /* os_dep.c. OS2 actually has the right */ + /* system call! */ +# define DATAEND /* not needed */ +# endif +# ifdef MSWIN32 +# define OS_TYPE "MSWIN32" + /* STACKBOTTOM and DATASTART are handled specially in */ + /* os_dep.c. */ +# ifndef __WATCOMC__ +# define MPROTECT_VDB +# endif +# define DATAEND /* not needed */ +# endif +# ifdef DJGPP +# define OS_TYPE "DJGPP" +# include "stubinfo.h" + extern int etext; + extern int _stklen; +# define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff)) +# define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \ + + _stklen)) + /* This may not be right. */ +# endif +# ifdef FREEBSD +# define OS_TYPE "FREEBSD" +# define MPROTECT_VDB +# endif +# ifdef NETBSD +# define OS_TYPE "NETBSD" +# endif +# ifdef THREE86BSD +# define OS_TYPE "THREE86BSD" +# endif +# ifdef BSDI +# define OS_TYPE "BSDI" +# endif +# if defined(FREEBSD) || defined(NETBSD) \ + || defined(THREE86BSD) || defined(BSDI) +# define HEURISTIC2 + extern char etext; +# define DATASTART ((ptr_t)(&etext)) +# endif +# ifdef NEXT +# define OS_TYPE "NEXT" +# define DATASTART ((ptr_t) get_etext()) +# define STACKBOTTOM ((ptr_t)0xc0000000) +# define DATAEND /* not needed */ +# endif +# ifdef DOS4GW +# define OS_TYPE "DOS4GW" + extern long __nullarea; + extern char _end; + extern char *_STACKTOP; + /* Depending on calling conventions Watcom C either precedes + or does not precedes with undescore names of C-variables. + Make sure startup code variables always have the same names. */ + #pragma aux __nullarea "*"; + #pragma aux _end "*"; +# define STACKBOTTOM ((ptr_t) _STACKTOP) + /* confused? me too. */ +# define DATASTART ((ptr_t) &__nullarea) +# define DATAEND ((ptr_t) &_end) +# endif +# endif + +# ifdef NS32K +# define MACH_TYPE "NS32K" +# define ALIGNMENT 4 + extern char **environ; +# define DATASTART ((ptr_t)(&environ)) + /* hideous kludge: environ is the first */ + /* word in crt0.o, and delimits the start */ + /* of the data segment, no matter which */ + /* ld options were passed through. */ +# define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */ +# endif + +# ifdef MIPS +# define MACH_TYPE "MIPS" +# ifndef IRIX5 +# define DATASTART (ptr_t)0x10000000 + /* Could probably be slightly higher since */ + /* startup code allocates lots of stuff. */ +# else + extern int _fdata; +# define DATASTART ((ptr_t)(&_fdata)) +# ifdef USE_MMAP +# define HEAP_START (ptr_t)0x30000000 +# else +# define HEAP_START DATASTART +# endif + /* Lowest plausible heap address. */ + /* In the MMAP case, we map there. */ + /* In either case it is used to identify */ + /* heap sections so they're not */ + /* considered as roots. */ +# endif /* IRIX5 */ +# define HEURISTIC2 +/* # define STACKBOTTOM ((ptr_t)0x7fff8000) sometimes also works. */ +# ifdef ULTRIX +# define OS_TYPE "ULTRIX" +# define ALIGNMENT 4 +# endif +# ifdef RISCOS +# define OS_TYPE "RISCOS" +# define ALIGNMENT 4 /* Required by hardware */ +# endif +# ifdef IRIX5 +# define OS_TYPE "IRIX5" +# define MPROTECT_VDB +# ifdef _MIPS_SZPTR +# define CPP_WORDSZ _MIPS_SZPTR +# define ALIGNMENT (_MIPS_SZPTR/8) +# if CPP_WORDSZ != 64 +# define ALIGN_DOUBLE +# endif +# else +# define ALIGNMENT 4 +# define ALIGN_DOUBLE +# endif +# define DYNAMIC_LOADING +# endif +# endif + +# ifdef RS6000 +# define MACH_TYPE "RS6000" +# define ALIGNMENT 4 +# define DATASTART ((ptr_t)0x20000000) + extern int errno; +# define STACKBOTTOM ((ptr_t)((ulong)&errno)) +# define DYNAMIC_LOADING + /* For really old versions of AIX, this may have to be removed. */ +# endif + +# ifdef HP_PA +# define MACH_TYPE "HP_PA" +# define ALIGNMENT 4 +# define ALIGN_DOUBLE + extern int __data_start; +# define DATASTART ((ptr_t)(&__data_start)) +# if 0 + /* The following appears to work for 7xx systems running HP/UX */ + /* 9.xx Furthermore, it might result in much faster */ + /* collections than HEURISTIC2, which may involve scanning */ + /* segments that directly precede the stack. It is not the */ + /* default, since it may not work on older machine/OS */ + /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */ + /* this.) */ +# define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */ +# else +# define HEURISTIC2 +# endif +# define STACK_GROWS_UP +# define DYNAMIC_LOADING +# include +# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) + /* They misspelled the Posix macro? */ +# endif + +# ifdef ALPHA +# define MACH_TYPE "ALPHA" +# define ALIGNMENT 8 +# ifdef OSF1 +# define OS_TYPE "OSF1" +# define DATASTART ((ptr_t) 0x140000000) + extern _end; +# define DATAEND ((ptr_t) &_end) +# define HEURISTIC2 + /* Normally HEURISTIC2 is too conervative, since */ + /* the text segment immediately follows the stack. */ + /* Hence we give an upper pound. */ + extern __start; +# define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1))) +# define CPP_WORDSZ 64 +# define MPROTECT_VDB +# define DYNAMIC_LOADING +# endif +# ifdef LINUX +# define OS_TYPE "LINUX" +# define CPP_WORDSZ 64 +# define STACKBOTTOM ((ptr_t) 0x120000000) +# ifdef __ELF__ + extern int __data_start; +# define DATASTART &__data_start +# define DYNAMIC_LOADING +# else +# define DATASTART ((ptr_t) 0x140000000) +# endif + extern int _end; +# define DATAEND (&_end) + /* As of 1.3.90, I couldn't find a way to retrieve the correct */ + /* fault address from a signal handler. */ + /* Hence MPROTECT_VDB is broken. */ +# endif +# endif + +# ifdef M88K +# define MACH_TYPE "M88K" +# define ALIGNMENT 4 +# define ALIGN_DOUBLE + extern int etext; +# ifdef CX_UX +# define OS_TYPE "CX_UX" +# define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000) +# endif +# ifdef DGUX +# define OS_TYPE "DGUX" + extern char * GC_SysVGetDataStart(); +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext) +# endif +# define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */ +# endif + +# ifdef S370 +# define MACH_TYPE "S370" +# define OS_TYPE "UTS4" +# define ALIGNMENT 4 /* Required by hardware */ + extern int etext; + extern int _etext; + extern int _end; + extern char * GC_SysVGetDataStart(); +# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext) +# define DATAEND (&_end) +# define HEURISTIC2 +# endif + +# ifndef STACK_GROWS_UP +# define STACK_GROWS_DOWN +# endif + +# ifndef CPP_WORDSZ +# define CPP_WORDSZ 32 +# endif + +# ifndef OS_TYPE +# define OS_TYPE "" +# endif + +# ifndef DATAEND + extern int end; +# define DATAEND (&end) +# endif + +# if defined(SVR4) && !defined(GETPAGESIZE) +# include +# define GETPAGESIZE() sysconf(_SC_PAGESIZE) +# endif + +# ifndef GETPAGESIZE +# if defined(SUNOS5) || defined(IRIX5) +# include +# endif +# define GETPAGESIZE() getpagesize() +# endif + +# if defined(SUNOS5) || defined(DRSNX) || defined(UTS4) + /* OS has SVR4 generic features. Probably others also qualify. */ +# define SVR4 +# endif + +# if defined(SUNOS5) || defined(DRSNX) + /* OS has SUNOS5 style semi-undocumented interface to dynamic */ + /* loader. */ +# define SUNOS5DL + /* OS has SUNOS5 style signal handlers. */ +# define SUNOS5SIGS +# endif + +# if CPP_WORDSZ != 32 && CPP_WORDSZ != 64 + -> bad word size +# endif + +# ifdef PCR +# undef DYNAMIC_LOADING +# undef STACKBOTTOM +# undef HEURISTIC1 +# undef HEURISTIC2 +# undef PROC_VDB +# undef MPROTECT_VDB +# define PCR_VDB +# endif + +# ifdef SRC_M3 +/* Postponed for now. */ +# undef PROC_VDB +# undef MPROTECT_VDB +# endif + +# ifdef SMALL_CONFIG +/* Presumably not worth the space it takes. */ +# undef PROC_VDB +# undef MPROTECT_VDB +# endif + +# if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) +# define DEFAULT_VDB +# endif + +# if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) +# define SOLARIS_THREADS +# endif +# if defined(IRIX_THREADS) && !defined(IRIX5) +--> inconsistent configuration +# endif +# if defined(IRIX_JDK_THREADS) && !defined(IRIX5) +--> inconsistent configuration +# endif +# if defined(LINUX_THREADS) && !defined(LINUX) +--> inconsistent configuration +# endif +# if defined(SOLARIS_THREADS) && !defined(SUNOS5) +--> inconsistent configuration +# endif +# if defined(PCR) || defined(SRC_M3) || \ + defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ + defined(IRIX_THREADS) || defined(LINUX_THREADS) || \ + defined(IRIX_JDK_THREADS) +# define THREADS +# endif + +# if defined(SPARC) && !defined(LINUX) +# define SAVE_CALL_CHAIN +# define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */ + /* include assembly code to do it well. */ +# endif + +# endif diff --git a/support/gc/include/weakpointer.h b/support/gc/include/weakpointer.h new file mode 100644 index 00000000..84906b00 --- /dev/null +++ b/support/gc/include/weakpointer.h @@ -0,0 +1,221 @@ +#ifndef _weakpointer_h_ +#define _weakpointer_h_ + +/**************************************************************************** + +WeakPointer and CleanUp + + Copyright (c) 1991 by Xerox Corporation. All rights reserved. + + THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + + Permission is hereby granted to copy this code for any purpose, + provided the above notices are retained on all copies. + + Last modified on Mon Jul 17 18:16:01 PDT 1995 by ellis + +****************************************************************************/ + +/**************************************************************************** + +WeakPointer + +A weak pointer is a pointer to a heap-allocated object that doesn't +prevent the object from being garbage collected. Weak pointers can be +used to track which objects haven't yet been reclaimed by the +collector. A weak pointer is deactivated when the collector discovers +its referent object is unreachable by normal pointers (reachability +and deactivation are defined more precisely below). A deactivated weak +pointer remains deactivated forever. + +****************************************************************************/ + + +template< class T > class WeakPointer { +public: + +WeakPointer( T* t = 0 ) + /* Constructs a weak pointer for *t. t may be null. It is an error + if t is non-null and *t is not a collected object. */ + {impl = _WeakPointer_New( t );} + +T* Pointer() + /* wp.Pointer() returns a pointer to the referent object of wp or + null if wp has been deactivated (because its referent object + has been discovered unreachable by the collector). */ + {return (T*) _WeakPointer_Pointer( this->impl );} + +int operator==( WeakPointer< T > wp2 ) + /* Given weak pointers wp1 and wp2, if wp1 == wp2, then wp1 and + wp2 refer to the same object. If wp1 != wp2, then either wp1 + and wp2 don't refer to the same object, or if they do, one or + both of them has been deactivated. (Note: If objects t1 and t2 + are never made reachable by their clean-up functions, then + WeakPointer(t1) == WeakPointer(t2) if and only t1 == t2.) */ + {return _WeakPointer_Equal( this->impl, wp2.impl );} + +int Hash() + /* Returns a hash code suitable for use by multiplicative- and + division-based hash tables. If wp1 == wp2, then wp1.Hash() == + wp2.Hash(). */ + {return _WeakPointer_Hash( this->impl );} + +private: +void* impl; +}; + +/***************************************************************************** + +CleanUp + +A garbage-collected object can have an associated clean-up function +that will be invoked some time after the collector discovers the +object is unreachable via normal pointers. Clean-up functions can be +used to release resources such as open-file handles or window handles +when their containing objects become unreachable. If a C++ object has +a non-empty explicit destructor (i.e. it contains programmer-written +code), the destructor will be automatically registered as the object's +initial clean-up function. + +There is no guarantee that the collector will detect every unreachable +object (though it will find almost all of them). Clients should not +rely on clean-up to cause some action to occur immediately -- clean-up +is only a mechanism for improving resource usage. + +Every object with a clean-up function also has a clean-up queue. When +the collector finds the object is unreachable, it enqueues it on its +queue. The clean-up function is applied when the object is removed +from the queue. By default, objects are enqueued on the garbage +collector's queue, and the collector removes all objects from its +queue after each collection. If a client supplies another queue for +objects, it is his responsibility to remove objects (and cause their +functions to be called) by polling it periodically. + +Clean-up queues allow clean-up functions accessing global data to +synchronize with the main program. Garbage collection can occur at any +time, and clean-ups invoked by the collector might access data in an +inconsistent state. A client can control this by defining an explicit +queue for objects and polling it at safe points. + +The following definitions are used by the specification below: + +Given a pointer t to a collected object, the base object BO(t) is the +value returned by new when it created the object. (Because of multiple +inheritance, t and BO(t) may not be the same address.) + +A weak pointer wp references an object *t if BO(wp.Pointer()) == +BO(t). + +***************************************************************************/ + +template< class T, class Data > class CleanUp { +public: + +static void Set( T* t, void c( Data* d, T* t ), Data* d = 0 ) + /* Sets the clean-up function of object BO(t) to be , + replacing any previously defined clean-up function for BO(t); c + and d can be null, but t cannot. Sets the clean-up queue for + BO(t) to be the collector's queue. When t is removed from its + clean-up queue, its clean-up will be applied by calling c(d, + t). It is an error if *t is not a collected object. */ + {_CleanUp_Set( t, c, d );} + +static void Call( T* t ) + /* Sets the new clean-up function for BO(t) to be null and, if the + old one is non-null, calls it immediately, even if BO(t) is + still reachable. Deactivates any weak pointers to BO(t). */ + {_CleanUp_Call( t );} + +class Queue {public: + Queue() + /* Constructs a new queue. */ + {this->head = _CleanUp_Queue_NewHead();} + + void Set( T* t ) + /* q.Set(t) sets the clean-up queue of BO(t) to be q. */ + {_CleanUp_Queue_Set( this->head, t );} + + int Call() + /* If q is non-empty, q.Call() removes the first object and + calls its clean-up function; does nothing if q is + empty. Returns true if there are more objects in the + queue. */ + {return _CleanUp_Queue_Call( this->head );} + + private: + void* head; + }; +}; + +/********************************************************************** + +Reachability and Clean-up + +An object O is reachable if it can be reached via a non-empty path of +normal pointers from the registers, stacks, global variables, or an +object with a non-null clean-up function (including O itself), +ignoring pointers from an object to itself. + +This definition of reachability ensures that if object B is accessible +from object A (and not vice versa) and if both A and B have clean-up +functions, then A will always be cleaned up before B. Note that as +long as an object with a clean-up function is contained in a cycle of +pointers, it will always be reachable and will never be cleaned up or +collected. + +When the collector finds an unreachable object with a null clean-up +function, it atomically deactivates all weak pointers referencing the +object and recycles its storage. If object B is accessible from object +A via a path of normal pointers, A will be discovered unreachable no +later than B, and a weak pointer to A will be deactivated no later +than a weak pointer to B. + +When the collector finds an unreachable object with a non-null +clean-up function, the collector atomically deactivates all weak +pointers referencing the object, redefines its clean-up function to be +null, and enqueues it on its clean-up queue. The object then becomes +reachable again and remains reachable at least until its clean-up +function executes. + +The clean-up function is assured that its argument is the only +accessible pointer to the object. Nothing prevents the function from +redefining the object's clean-up function or making the object +reachable again (for example, by storing the pointer in a global +variable). + +If the clean-up function does not make its object reachable again and +does not redefine its clean-up function, then the object will be +collected by a subsequent collection (because the object remains +unreachable and now has a null clean-up function). If the clean-up +function does make its object reachable again and a clean-up function +is subsequently redefined for the object, then the new clean-up +function will be invoked the next time the collector finds the object +unreachable. + +Note that a destructor for a collected object cannot safely redefine a +clean-up function for its object, since after the destructor executes, +the object has been destroyed into "raw memory". (In most +implementations, destroying an object mutates its vtbl.) + +Finally, note that calling delete t on a collected object first +deactivates any weak pointers to t and then invokes its clean-up +function (destructor). + +**********************************************************************/ + +extern "C" { + void* _WeakPointer_New( void* t ); + void* _WeakPointer_Pointer( void* wp ); + int _WeakPointer_Equal( void* wp1, void* wp2 ); + int _WeakPointer_Hash( void* wp ); + void _CleanUp_Set( void* t, void (*c)( void* d, void* t ), void* d ); + void _CleanUp_Call( void* t ); + void* _CleanUp_Queue_NewHead (); + void _CleanUp_Queue_Set( void* h, void* t ); + int _CleanUp_Queue_Call( void* h ); +} + +#endif /* _weakpointer_h_ */ + + diff --git a/support/gc/irix_threads.c b/support/gc/irix_threads.c new file mode 100644 index 00000000..5efca211 --- /dev/null +++ b/support/gc/irix_threads.c @@ -0,0 +1,674 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* + * Support code for Irix (>=6.2) Pthreads. This relies on properties + * not guaranteed by the Pthread standard. It may or may not be portable + * to other implementations. + * + * Note that there is a lot of code duplication between linux_threads.c + * and irix_threads.c; any changes made here may need to be reflected + * there too. + */ + +# if defined(IRIX_THREADS) + +# include "gc_priv.h" +# include +# include +# include +# include +# include +# include +# include + +#undef pthread_create +#undef pthread_sigmask +#undef pthread_join + +void GC_thr_init(); + +#if 0 +void GC_print_sig_mask() +{ + sigset_t blocked; + int i; + + if (pthread_sigmask(SIG_BLOCK, NULL, &blocked) != 0) + ABORT("pthread_sigmask"); + GC_printf0("Blocked: "); + for (i = 1; i <= MAXSIG; i++) { + if (sigismember(&blocked, i)) { GC_printf1("%ld ",(long) i); } + } + GC_printf0("\n"); +} +#endif + +/* We use the allocation lock to protect thread-related data structures. */ + +/* The set of all known threads. We intercept thread creation and */ +/* joins. We never actually create detached threads. We allocate all */ +/* new thread stacks ourselves. These allow us to maintain this */ +/* data structure. */ +/* Protected by GC_thr_lock. */ +/* Some of this should be declared volatile, but that's incosnsistent */ +/* with some library routine declarations. */ +typedef struct GC_Thread_Rep { + struct GC_Thread_Rep * next; /* More recently allocated threads */ + /* with a given pthread id come */ + /* first. (All but the first are */ + /* guaranteed to be dead, but we may */ + /* not yet have registered the join.) */ + pthread_t id; + word stop; +# define NOT_STOPPED 0 +# define PLEASE_STOP 1 +# define STOPPED 2 + word flags; +# define FINISHED 1 /* Thread has exited. */ +# define DETACHED 2 /* Thread is intended to be detached. */ +# define CLIENT_OWNS_STACK 4 + /* Stack was supplied by client. */ + ptr_t stack; + ptr_t stack_ptr; /* Valid only when stopped. */ + /* But must be within stack region at */ + /* all times. */ + size_t stack_size; /* 0 for original thread. */ + void * status; /* Used only to avoid premature */ + /* reclamation of any data it might */ + /* reference. */ +} * GC_thread; + +GC_thread GC_lookup_thread(pthread_t id); + +/* + * The only way to suspend threads given the pthread interface is to send + * signals. Unfortunately, this means we have to reserve + * a signal, and intercept client calls to change the signal mask. + */ +# define SIG_SUSPEND (SIGRTMIN + 6) + +pthread_mutex_t GC_suspend_lock = PTHREAD_MUTEX_INITIALIZER; + /* Number of threads stopped so far */ +pthread_cond_t GC_suspend_ack_cv = PTHREAD_COND_INITIALIZER; +pthread_cond_t GC_continue_cv = PTHREAD_COND_INITIALIZER; + +void GC_suspend_handler(int sig) +{ + int dummy; + GC_thread me; + sigset_t all_sigs; + sigset_t old_sigs; + int i; + + if (sig != SIG_SUSPEND) ABORT("Bad signal in suspend_handler"); + me = GC_lookup_thread(pthread_self()); + /* The lookup here is safe, since I'm doing this on behalf */ + /* of a thread which holds the allocation lock in order */ + /* to stop the world. Thus concurrent modification of the */ + /* data structure is impossible. */ + if (PLEASE_STOP != me -> stop) { + /* Misdirected signal. */ + pthread_mutex_unlock(&GC_suspend_lock); + return; + } + pthread_mutex_lock(&GC_suspend_lock); + me -> stack_ptr = (ptr_t)(&dummy); + me -> stop = STOPPED; + pthread_cond_signal(&GC_suspend_ack_cv); + pthread_cond_wait(&GC_continue_cv, &GC_suspend_lock); + pthread_mutex_unlock(&GC_suspend_lock); + /* GC_printf1("Continuing 0x%x\n", pthread_self()); */ +} + + +GC_bool GC_thr_initialized = FALSE; + +size_t GC_min_stack_sz; + +size_t GC_page_sz; + +# define N_FREE_LISTS 25 +ptr_t GC_stack_free_lists[N_FREE_LISTS] = { 0 }; + /* GC_stack_free_lists[i] is free list for stacks of */ + /* size GC_min_stack_sz*2**i. */ + /* Free lists are linked through first word. */ + +/* Return a stack of size at least *stack_size. *stack_size is */ +/* replaced by the actual stack size. */ +/* Caller holds allocation lock. */ +ptr_t GC_stack_alloc(size_t * stack_size) +{ + register size_t requested_sz = *stack_size; + register size_t search_sz = GC_min_stack_sz; + register int index = 0; /* = log2(search_sz/GC_min_stack_sz) */ + register ptr_t result; + + while (search_sz < requested_sz) { + search_sz *= 2; + index++; + } + if ((result = GC_stack_free_lists[index]) == 0 + && (result = GC_stack_free_lists[index+1]) != 0) { + /* Try next size up. */ + search_sz *= 2; index++; + } + if (result != 0) { + GC_stack_free_lists[index] = *(ptr_t *)result; + } else { + result = (ptr_t) GC_scratch_alloc(search_sz + 2*GC_page_sz); + result = (ptr_t)(((word)result + GC_page_sz) & ~(GC_page_sz - 1)); + /* Protect hottest page to detect overflow. */ + /* mprotect(result, GC_page_sz, PROT_NONE); */ + result += GC_page_sz; + } + *stack_size = search_sz; + return(result); +} + +/* Caller holds allocation lock. */ +void GC_stack_free(ptr_t stack, size_t size) +{ + register int index = 0; + register size_t search_sz = GC_min_stack_sz; + + while (search_sz < size) { + search_sz *= 2; + index++; + } + if (search_sz != size) ABORT("Bad stack size"); + *(ptr_t *)stack = GC_stack_free_lists[index]; + GC_stack_free_lists[index] = stack; +} + + + +# define THREAD_TABLE_SZ 128 /* Must be power of 2 */ +volatile GC_thread GC_threads[THREAD_TABLE_SZ]; + +/* Add a thread to GC_threads. We assume it wasn't already there. */ +/* Caller holds allocation lock. */ +GC_thread GC_new_thread(pthread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + GC_thread result; + static struct GC_Thread_Rep first_thread; + static GC_bool first_thread_used = FALSE; + + if (!first_thread_used) { + result = &first_thread; + first_thread_used = TRUE; + /* Dont acquire allocation lock, since we may already hold it. */ + } else { + result = (struct GC_Thread_Rep *) + GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL); + } + if (result == 0) return(0); + result -> id = id; + result -> next = GC_threads[hv]; + GC_threads[hv] = result; + /* result -> flags = 0; */ + /* result -> stop = 0; */ + return(result); +} + +/* Delete a thread from GC_threads. We assume it is there. */ +/* (The code intentionally traps if it wasn't.) */ +/* Caller holds allocation lock. */ +void GC_delete_thread(pthread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + register GC_thread prev = 0; + + while (!pthread_equal(p -> id, id)) { + prev = p; + p = p -> next; + } + if (prev == 0) { + GC_threads[hv] = p -> next; + } else { + prev -> next = p -> next; + } +} + +/* If a thread has been joined, but we have not yet */ +/* been notified, then there may be more than one thread */ +/* in the table with the same pthread id. */ +/* This is OK, but we need a way to delete a specific one. */ +void GC_delete_gc_thread(pthread_t id, GC_thread gc_id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + register GC_thread prev = 0; + + while (p != gc_id) { + prev = p; + p = p -> next; + } + if (prev == 0) { + GC_threads[hv] = p -> next; + } else { + prev -> next = p -> next; + } +} + +/* Return a GC_thread corresponding to a given thread_t. */ +/* Returns 0 if it's not there. */ +/* Caller holds allocation lock or otherwise inhibits */ +/* updates. */ +/* If there is more than one thread with the given id we */ +/* return the most recent one. */ +GC_thread GC_lookup_thread(pthread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + + while (p != 0 && !pthread_equal(p -> id, id)) p = p -> next; + return(p); +} + + +/* Caller holds allocation lock. */ +void GC_stop_world() +{ + pthread_t my_thread = pthread_self(); + register int i; + register GC_thread p; + register int result; + struct timespec timeout; + + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> id != my_thread) { + if (p -> flags & FINISHED) { + p -> stop = STOPPED; + continue; + } + p -> stop = PLEASE_STOP; + result = pthread_kill(p -> id, SIG_SUSPEND); + /* GC_printf1("Sent signal to 0x%x\n", p -> id); */ + switch(result) { + case ESRCH: + /* Not really there anymore. Possible? */ + p -> stop = STOPPED; + break; + case 0: + break; + default: + ABORT("pthread_kill failed"); + } + } + } + } + pthread_mutex_lock(&GC_suspend_lock); + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + while (p -> id != my_thread && p -> stop != STOPPED) { + clock_gettime(CLOCK_REALTIME, &timeout); + timeout.tv_nsec += 50000000; /* 50 msecs */ + if (timeout.tv_nsec >= 1000000000) { + timeout.tv_nsec -= 1000000000; + ++timeout.tv_sec; + } + result = pthread_cond_timedwait(&GC_suspend_ack_cv, + &GC_suspend_lock, + &timeout); + if (result == ETIMEDOUT) { + /* Signal was lost or misdirected. Try again. */ + /* Duplicate signals should be benign. */ + result = pthread_kill(p -> id, SIG_SUSPEND); + } + } + } + } + pthread_mutex_unlock(&GC_suspend_lock); + /* GC_printf1("World stopped 0x%x\n", pthread_self()); */ +} + +/* Caller holds allocation lock. */ +void GC_start_world() +{ + GC_thread p; + unsigned i; + + /* GC_printf0("World starting\n"); */ + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + p -> stop = NOT_STOPPED; + } + } + pthread_mutex_lock(&GC_suspend_lock); + /* All other threads are at pthread_cond_wait in signal handler. */ + /* Otherwise we couldn't have acquired the lock. */ + pthread_mutex_unlock(&GC_suspend_lock); + pthread_cond_broadcast(&GC_continue_cv); +} + +# ifdef MMAP_STACKS +--> not really supported yet. +int GC_is_thread_stack(ptr_t addr) +{ + register int i; + register GC_thread p; + + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> stack_size != 0) { + if (p -> stack <= addr && + addr < p -> stack + p -> stack_size) + return 1; + } + } + } + return 0; +} +# endif + +/* We hold allocation lock. We assume the world is stopped. */ +void GC_push_all_stacks() +{ + register int i; + register GC_thread p; + register ptr_t sp = GC_approx_sp(); + register ptr_t lo, hi; + pthread_t me = pthread_self(); + + if (!GC_thr_initialized) GC_thr_init(); + /* GC_printf1("Pushing stacks from thread 0x%x\n", me); */ + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> flags & FINISHED) continue; + if (pthread_equal(p -> id, me)) { + lo = GC_approx_sp(); + } else { + lo = p -> stack_ptr; + } + if (p -> stack_size != 0) { + hi = p -> stack + p -> stack_size; + } else { + /* The original stack. */ + hi = GC_stackbottom; + } + GC_push_all_stack(lo, hi); + } + } +} + + +/* We hold the allocation lock. */ +void GC_thr_init() +{ + GC_thread t; + struct sigaction act; + + if (GC_thr_initialized) return; + GC_thr_initialized = TRUE; + GC_min_stack_sz = HBLKSIZE; + GC_page_sz = sysconf(_SC_PAGESIZE); + (void) sigaction(SIG_SUSPEND, 0, &act); + if (act.sa_handler != SIG_DFL) + ABORT("Previously installed SIG_SUSPEND handler"); + /* Install handler. */ + act.sa_handler = GC_suspend_handler; + act.sa_flags = SA_RESTART; + (void) sigemptyset(&act.sa_mask); + if (0 != sigaction(SIG_SUSPEND, &act, 0)) + ABORT("Failed to install SIG_SUSPEND handler"); + /* Add the initial thread, so we can stop it. */ + t = GC_new_thread(pthread_self()); + t -> stack_size = 0; + t -> stack_ptr = (ptr_t)(&t); + t -> flags = DETACHED; +} + +int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) +{ + sigset_t fudged_set; + + if (set != NULL && (how == SIG_BLOCK || how == SIG_SETMASK)) { + fudged_set = *set; + sigdelset(&fudged_set, SIG_SUSPEND); + set = &fudged_set; + } + return(pthread_sigmask(how, set, oset)); +} + +struct start_info { + void *(*start_routine)(void *); + void *arg; + word flags; + ptr_t stack; + size_t stack_size; + sem_t registered; /* 1 ==> in our thread table, but */ + /* parent hasn't yet noticed. */ +}; + +void GC_thread_exit_proc(void *arg) +{ + GC_thread me; + + LOCK(); + me = GC_lookup_thread(pthread_self()); + if (me -> flags & DETACHED) { + GC_delete_thread(pthread_self()); + } else { + me -> flags |= FINISHED; + } + UNLOCK(); +} + +int GC_pthread_join(pthread_t thread, void **retval) +{ + int result; + GC_thread thread_gc_id; + + LOCK(); + thread_gc_id = GC_lookup_thread(thread); + /* This is guaranteed to be the intended one, since the thread id */ + /* cant have been recycled by pthreads. */ + UNLOCK(); + result = pthread_join(thread, retval); + /* Some versions of the Irix pthreads library can erroneously */ + /* return EINTR when the call succeeds. */ + if (EINTR == result) result = 0; + LOCK(); + /* Here the pthread thread id may have been recycled. */ + GC_delete_gc_thread(thread, thread_gc_id); + UNLOCK(); + return result; +} + +void * GC_start_routine(void * arg) +{ + struct start_info * si = arg; + void * result; + GC_thread me; + pthread_t my_pthread; + void *(*start)(void *); + void *start_arg; + + my_pthread = pthread_self(); + /* If a GC occurs before the thread is registered, that GC will */ + /* ignore this thread. That's fine, since it will block trying to */ + /* acquire the allocation lock, and won't yet hold interesting */ + /* pointers. */ + LOCK(); + /* We register the thread here instead of in the parent, so that */ + /* we don't need to hold the allocation lock during pthread_create. */ + /* Holding the allocation lock there would make REDIRECT_MALLOC */ + /* impossible. It probably still doesn't work, but we're a little */ + /* closer ... */ + /* This unfortunately means that we have to be careful the parent */ + /* doesn't try to do a pthread_join before we're registered. */ + me = GC_new_thread(my_pthread); + me -> flags = si -> flags; + me -> stack = si -> stack; + me -> stack_size = si -> stack_size; + me -> stack_ptr = (ptr_t)si -> stack + si -> stack_size - sizeof(word); + UNLOCK(); + start = si -> start_routine; + start_arg = si -> arg; + sem_post(&(si -> registered)); + pthread_cleanup_push(GC_thread_exit_proc, 0); + result = (*start)(start_arg); + me -> status = result; + me -> flags |= FINISHED; + pthread_cleanup_pop(1); + /* This involves acquiring the lock, ensuring that we can't exit */ + /* while a collection that thinks we're alive is trying to stop */ + /* us. */ + return(result); +} + +int +GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void *(*start_routine)(void *), void *arg) +{ + int result; + GC_thread t; + void * stack; + size_t stacksize; + pthread_attr_t new_attr; + int detachstate; + word my_flags = 0; + struct start_info * si = GC_malloc(sizeof(struct start_info)); + /* This is otherwise saved only in an area mmapped by the thread */ + /* library, which isn't visible to the collector. */ + + if (0 == si) return(ENOMEM); + sem_init(&(si -> registered), 0, 0); + si -> start_routine = start_routine; + si -> arg = arg; + LOCK(); + if (!GC_thr_initialized) GC_thr_init(); + if (NULL == attr) { + stack = 0; + (void) pthread_attr_init(&new_attr); + } else { + new_attr = *attr; + pthread_attr_getstackaddr(&new_attr, &stack); + } + pthread_attr_getstacksize(&new_attr, &stacksize); + pthread_attr_getdetachstate(&new_attr, &detachstate); + if (stacksize < GC_min_stack_sz) ABORT("Stack too small"); + if (0 == stack) { + stack = (void *)GC_stack_alloc(&stacksize); + if (0 == stack) { + UNLOCK(); + return(ENOMEM); + } + pthread_attr_setstackaddr(&new_attr, stack); + } else { + my_flags |= CLIENT_OWNS_STACK; + } + if (PTHREAD_CREATE_DETACHED == detachstate) my_flags |= DETACHED; + si -> flags = my_flags; + si -> stack = stack; + si -> stack_size = stacksize; + result = pthread_create(new_thread, &new_attr, GC_start_routine, si); + if (0 == new_thread && !(my_flags & CLIENT_OWNS_STACK)) { + GC_stack_free(stack, stacksize); + } + UNLOCK(); + /* Wait until child has been added to the thread table. */ + /* This also ensures that we hold onto si until the child is done */ + /* with it. Thus it doesn't matter whether it is otherwise */ + /* visible to the collector. */ + if (0 != sem_wait(&(si -> registered))) ABORT("sem_wait failed"); + sem_destroy(&(si -> registered)); + /* pthread_attr_destroy(&new_attr); */ + return(result); +} + +GC_bool GC_collecting = 0; /* A hint that we're in the collector and */ + /* holding the allocation lock for an */ + /* extended period. */ + +/* Reasonably fast spin locks. Basically the same implementation */ +/* as STL alloc.h. This isn't really the right way to do this. */ +/* but until the POSIX scheduling mess gets straightened out ... */ + +unsigned long GC_allocate_lock = 0; + +#define SLEEP_THRESHOLD 3 + +void GC_lock() +{ +# define low_spin_max 30 /* spin cycles if we suspect uniprocessor */ +# define high_spin_max 1000 /* spin cycles for multiprocessor */ + static unsigned spin_max = low_spin_max; + unsigned my_spin_max; + static unsigned last_spins = 0; + unsigned my_last_spins; + volatile unsigned junk; +# define PAUSE junk *= junk; junk *= junk; junk *= junk; junk *= junk + int i; + + if (!GC_test_and_set(&GC_allocate_lock, 1)) { + return; + } + junk = 0; + my_spin_max = spin_max; + my_last_spins = last_spins; + for (i = 0; i < my_spin_max; i++) { + if (GC_collecting) goto yield; + if (i < my_last_spins/2 || GC_allocate_lock) { + PAUSE; + continue; + } + if (!GC_test_and_set(&GC_allocate_lock, 1)) { + /* + * got it! + * Spinning worked. Thus we're probably not being scheduled + * against the other process with which we were contending. + * Thus it makes sense to spin longer the next time. + */ + last_spins = i; + spin_max = high_spin_max; + return; + } + } + /* We are probably being scheduled against the other process. Sleep. */ + spin_max = low_spin_max; +yield: + for (i = 0;; ++i) { + if (!GC_test_and_set(&GC_allocate_lock, 1)) { + return; + } + if (i < SLEEP_THRESHOLD) { + sched_yield(); + } else { + struct timespec ts; + + if (i > 26) i = 26; + /* Don't wait for more than about 60msecs, even */ + /* under extreme contention. */ + ts.tv_sec = 0; + ts.tv_nsec = 1 << i; + nanosleep(&ts, 0); + } + } +} + + + +# else + +#ifndef LINT + int GC_no_Irix_threads; +#endif + +# endif /* IRIX_THREADS */ + diff --git a/support/gc/linux_threads.c b/support/gc/linux_threads.c new file mode 100644 index 00000000..8287dce6 --- /dev/null +++ b/support/gc/linux_threads.c @@ -0,0 +1,665 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * Copyright (c) 1998 by Fergus Henderson. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* + * Support code for LinuxThreads, the clone()-based kernel + * thread package for Linux which is included in libc6. + * + * This code relies on implementation details of LinuxThreads, + * (i.e. properties not guaranteed by the Pthread standard): + * + * - the function GC_linux_thread_top_of_stack(void) + * relies on the way LinuxThreads lays out thread stacks + * in the address space. + * + * Note that there is a lot of code duplication between linux_threads.c + * and irix_threads.c; any changes made here may need to be reflected + * there too. + */ + +/* #define DEBUG_THREADS 1 */ + +/* ANSI C requires that a compilation unit contains something */ +# include "gc_priv.h" + +# if defined(LINUX_THREADS) + +# include +# include +# include +# include +# include +# include +# include + +#undef pthread_create +#undef pthread_sigmask +#undef pthread_join + +void GC_thr_init(); + +#if 0 +void GC_print_sig_mask() +{ + sigset_t blocked; + int i; + + if (pthread_sigmask(SIG_BLOCK, NULL, &blocked) != 0) + ABORT("pthread_sigmask"); + GC_printf0("Blocked: "); + for (i = 1; i <= MAXSIG; i++) { + if (sigismember(&blocked, i)) { GC_printf1("%ld ",(long) i); } + } + GC_printf0("\n"); +} +#endif + +/* We use the allocation lock to protect thread-related data structures. */ + +/* The set of all known threads. We intercept thread creation and */ +/* joins. We never actually create detached threads. We allocate all */ +/* new thread stacks ourselves. These allow us to maintain this */ +/* data structure. */ +/* Protected by GC_thr_lock. */ +/* Some of this should be declared volatile, but that's incosnsistent */ +/* with some library routine declarations. */ +typedef struct GC_Thread_Rep { + struct GC_Thread_Rep * next; /* More recently allocated threads */ + /* with a given pthread id come */ + /* first. (All but the first are */ + /* guaranteed to be dead, but we may */ + /* not yet have registered the join.) */ + pthread_t id; + word flags; +# define FINISHED 1 /* Thread has exited. */ +# define DETACHED 2 /* Thread is intended to be detached. */ +# define MAIN_THREAD 4 /* True for the original thread only. */ + + ptr_t stack_end; + ptr_t stack_ptr; /* Valid only when stopped. */ + int signal; + void * status; /* The value returned from the thread. */ + /* Used only to avoid premature */ + /* reclamation of any data it might */ + /* reference. */ +} * GC_thread; + +GC_thread GC_lookup_thread(pthread_t id); + +/* + * The only way to suspend threads given the pthread interface is to send + * signals. We can't use SIGSTOP directly, because we need to get the + * thread to save its stack pointer in the GC thread table before + * suspending. So we have to reserve a signal of our own for this. + * This means we have to intercept client calls to change the signal mask. + * The linuxthreads package already uses SIGUSR1 and SIGUSR2, + * so we need to reuse something else. I chose SIGPWR. + * (Perhaps SIGUNUSED would be a better choice.) + */ +#define SIG_SUSPEND SIGPWR + +#define SIG_RESTART SIGXCPU + +sem_t GC_suspend_ack_sem; + +/* +GC_linux_thread_top_of_stack() relies on implementation details of +LinuxThreads, namely that thread stacks are allocated on 2M boundaries +and grow to no more than 2M. +To make sure that we're using LinuxThreads and not some other thread +package, we generate a dummy reference to `pthread_kill_other_threads_np' +(was `__pthread_initial_thread_bos' but that disappeared), +which is a symbol defined in LinuxThreads, but (hopefully) not in other +thread packages. +*/ +void (*dummy_var_to_force_linux_threads)() = pthread_kill_other_threads_np; + +#define LINUX_THREADS_STACK_SIZE (2 * 1024 * 1024) + +static inline ptr_t GC_linux_thread_top_of_stack(void) +{ + char *sp = GC_approx_sp(); + ptr_t tos = (ptr_t) (((unsigned long)sp | (LINUX_THREADS_STACK_SIZE - 1)) + 1); +#if DEBUG_THREADS + GC_printf1("SP = %lx\n", (unsigned long)sp); + GC_printf1("TOS = %lx\n", (unsigned long)tos); +#endif + return tos; +} + +void GC_suspend_handler(int sig) +{ + int dummy; + pthread_t my_thread = pthread_self(); + GC_thread me; + sigset_t all_sigs; + sigset_t old_sigs; + int i; + sigset_t mask; + + if (sig != SIG_SUSPEND) ABORT("Bad signal in suspend_handler"); + +#if DEBUG_THREADS + GC_printf1("Suspending 0x%x\n", my_thread); +#endif + + me = GC_lookup_thread(my_thread); + /* The lookup here is safe, since I'm doing this on behalf */ + /* of a thread which holds the allocation lock in order */ + /* to stop the world. Thus concurrent modification of the */ + /* data structure is impossible. */ + me -> stack_ptr = (ptr_t)(&dummy); + me -> stack_end = GC_linux_thread_top_of_stack(); + + /* Tell the thread that wants to stop the world that this */ + /* thread has been stopped. Note that sem_post() is */ + /* the only async-signal-safe primitive in LinuxThreads. */ + sem_post(&GC_suspend_ack_sem); + + /* Wait until that thread tells us to restart by sending */ + /* this thread a SIG_RESTART signal. */ + /* SIG_RESTART should be masked at this point. Thus there */ + /* is no race. */ + if (sigfillset(&mask) != 0) ABORT("sigfillset() failed"); + if (sigdelset(&mask, SIG_RESTART) != 0) ABORT("sigdelset() failed"); + do { + me->signal = 0; + sigsuspend(&mask); /* Wait for signal */ + } while (me->signal != SIG_RESTART); + +#if DEBUG_THREADS + GC_printf1("Continuing 0x%x\n", my_thread); +#endif +} + +void GC_restart_handler(int sig) +{ + GC_thread me; + + if (sig != SIG_RESTART) ABORT("Bad signal in suspend_handler"); + + /* Let the GC_suspend_handler() know that we got a SIG_RESTART. */ + /* The lookup here is safe, since I'm doing this on behalf */ + /* of a thread which holds the allocation lock in order */ + /* to stop the world. Thus concurrent modification of the */ + /* data structure is impossible. */ + me = GC_lookup_thread(pthread_self()); + me->signal = SIG_RESTART; + + /* + ** Note: even if we didn't do anything useful here, + ** it would still be necessary to have a signal handler, + ** rather than ignoring the signals, otherwise + ** the signals will not be delivered at all, and + ** will thus not interrupt the sigsuspend() above. + */ + +#if DEBUG_THREADS + GC_printf1("In GC_restart_handler for 0x%x\n", pthread_self()); +#endif +} + +GC_bool GC_thr_initialized = FALSE; + +# define THREAD_TABLE_SZ 128 /* Must be power of 2 */ +volatile GC_thread GC_threads[THREAD_TABLE_SZ]; + +/* Add a thread to GC_threads. We assume it wasn't already there. */ +/* Caller holds allocation lock. */ +GC_thread GC_new_thread(pthread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + GC_thread result; + static struct GC_Thread_Rep first_thread; + static GC_bool first_thread_used = FALSE; + + if (!first_thread_used) { + result = &first_thread; + first_thread_used = TRUE; + /* Dont acquire allocation lock, since we may already hold it. */ + } else { + result = (struct GC_Thread_Rep *) + GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL); + } + if (result == 0) return(0); + result -> id = id; + result -> next = GC_threads[hv]; + GC_threads[hv] = result; + /* result -> flags = 0; */ + return(result); +} + +/* Delete a thread from GC_threads. We assume it is there. */ +/* (The code intentionally traps if it wasn't.) */ +/* Caller holds allocation lock. */ +void GC_delete_thread(pthread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + register GC_thread prev = 0; + + while (!pthread_equal(p -> id, id)) { + prev = p; + p = p -> next; + } + if (prev == 0) { + GC_threads[hv] = p -> next; + } else { + prev -> next = p -> next; + } +} + +/* If a thread has been joined, but we have not yet */ +/* been notified, then there may be more than one thread */ +/* in the table with the same pthread id. */ +/* This is OK, but we need a way to delete a specific one. */ +void GC_delete_gc_thread(pthread_t id, GC_thread gc_id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + register GC_thread prev = 0; + + while (p != gc_id) { + prev = p; + p = p -> next; + } + if (prev == 0) { + GC_threads[hv] = p -> next; + } else { + prev -> next = p -> next; + } +} + +/* Return a GC_thread corresponding to a given thread_t. */ +/* Returns 0 if it's not there. */ +/* Caller holds allocation lock or otherwise inhibits */ +/* updates. */ +/* If there is more than one thread with the given id we */ +/* return the most recent one. */ +GC_thread GC_lookup_thread(pthread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + + while (p != 0 && !pthread_equal(p -> id, id)) p = p -> next; + return(p); +} + +/* Caller holds allocation lock. */ +void GC_stop_world() +{ + pthread_t my_thread = pthread_self(); + register int i; + register GC_thread p; + register int n_live_threads = 0; + register int result; + + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> id != my_thread) { + if (p -> flags & FINISHED) continue; + n_live_threads++; + #if DEBUG_THREADS + GC_printf1("Sending suspend signal to 0x%x\n", p -> id); + #endif + result = pthread_kill(p -> id, SIG_SUSPEND); + switch(result) { + case ESRCH: + /* Not really there anymore. Possible? */ + n_live_threads--; + break; + case 0: + break; + default: + ABORT("pthread_kill failed"); + } + } + } + } + for (i = 0; i < n_live_threads; i++) { + sem_wait(&GC_suspend_ack_sem); + } + #if DEBUG_THREADS + GC_printf1("World stopped 0x%x\n", pthread_self()); + #endif +} + +/* Caller holds allocation lock. */ +void GC_start_world() +{ + pthread_t my_thread = pthread_self(); + register int i; + register GC_thread p; + register int n_live_threads = 0; + register int result; + +# if DEBUG_THREADS + GC_printf0("World starting\n"); +# endif + + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> id != my_thread) { + if (p -> flags & FINISHED) continue; + n_live_threads++; + #if DEBUG_THREADS + GC_printf1("Sending restart signal to 0x%x\n", p -> id); + #endif + result = pthread_kill(p -> id, SIG_RESTART); + switch(result) { + case ESRCH: + /* Not really there anymore. Possible? */ + n_live_threads--; + break; + case 0: + break; + default: + ABORT("pthread_kill failed"); + } + } + } + } + #if DEBUG_THREADS + GC_printf0("World started\n"); + #endif +} + +/* We hold allocation lock. We assume the world is stopped. */ +void GC_push_all_stacks() +{ + register int i; + register GC_thread p; + register ptr_t sp = GC_approx_sp(); + register ptr_t lo, hi; + pthread_t me = pthread_self(); + + if (!GC_thr_initialized) GC_thr_init(); + #if DEBUG_THREADS + GC_printf1("Pushing stacks from thread 0x%lx\n", (unsigned long) me); + #endif + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> flags & FINISHED) continue; + if (pthread_equal(p -> id, me)) { + lo = GC_approx_sp(); + } else { + lo = p -> stack_ptr; + } + if ((p -> flags & MAIN_THREAD) == 0) { + if (pthread_equal(p -> id, me)) { + hi = GC_linux_thread_top_of_stack(); + } else { + hi = p -> stack_end; + } + } else { + /* The original stack. */ + hi = GC_stackbottom; + } + #if DEBUG_THREADS + GC_printf3("Stack for thread 0x%lx = [%lx,%lx)\n", + (unsigned long) p -> id, + (unsigned long) lo, (unsigned long) hi); + #endif + GC_push_all_stack(lo, hi); + } + } +} + + +/* We hold the allocation lock. */ +void GC_thr_init() +{ + GC_thread t; + struct sigaction act; + + if (GC_thr_initialized) return; + GC_thr_initialized = TRUE; + + if (sem_init(&GC_suspend_ack_sem, 0, 0) != 0) + ABORT("sem_init failed"); + + act.sa_flags = SA_RESTART; + if (sigfillset(&act.sa_mask) != 0) { + ABORT("sigfillset() failed"); + } + /* SIG_RESTART is unmasked by the handler when necessary. */ + act.sa_handler = GC_suspend_handler; + if (sigaction(SIG_SUSPEND, &act, NULL) != 0) { + ABORT("Cannot set SIG_SUSPEND handler"); + } + + act.sa_handler = GC_restart_handler; + if (sigaction(SIG_RESTART, &act, NULL) != 0) { + ABORT("Cannot set SIG_SUSPEND handler"); + } + + /* Add the initial thread, so we can stop it. */ + t = GC_new_thread(pthread_self()); + t -> stack_ptr = 0; + t -> flags = DETACHED | MAIN_THREAD; +} + +int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) +{ + sigset_t fudged_set; + + if (set != NULL && (how == SIG_BLOCK || how == SIG_SETMASK)) { + fudged_set = *set; + sigdelset(&fudged_set, SIG_SUSPEND); + set = &fudged_set; + } + return(pthread_sigmask(how, set, oset)); +} + +struct start_info { + void *(*start_routine)(void *); + void *arg; + word flags; + sem_t registered; /* 1 ==> in our thread table, but */ + /* parent hasn't yet noticed. */ +}; + + +void GC_thread_exit_proc(void *arg) +{ + GC_thread me; + struct start_info * si = arg; + + LOCK(); + me = GC_lookup_thread(pthread_self()); + if (me -> flags & DETACHED) { + GC_delete_thread(pthread_self()); + } else { + me -> flags |= FINISHED; + } + UNLOCK(); +} + +int GC_pthread_join(pthread_t thread, void **retval) +{ + int result; + GC_thread thread_gc_id; + + LOCK(); + thread_gc_id = GC_lookup_thread(thread); + /* This is guaranteed to be the intended one, since the thread id */ + /* cant have been recycled by pthreads. */ + UNLOCK(); + result = pthread_join(thread, retval); + LOCK(); + /* Here the pthread thread id may have been recycled. */ + GC_delete_gc_thread(thread, thread_gc_id); + UNLOCK(); + return result; +} + +void * GC_start_routine(void * arg) +{ + struct start_info * si = arg; + void * result; + GC_thread me; + pthread_t my_pthread; + void *(*start)(void *); + void *start_arg; + + my_pthread = pthread_self(); + LOCK(); + me = GC_new_thread(my_pthread); + me -> flags = si -> flags; + me -> stack_ptr = 0; + me -> stack_end = 0; + UNLOCK(); + start = si -> start_routine; + start_arg = si -> arg; + sem_post(&(si -> registered)); + pthread_cleanup_push(GC_thread_exit_proc, si); +# ifdef DEBUG_THREADS + GC_printf1("Starting thread 0x%lx\n", pthread_self()); + GC_printf1("pid = %ld\n", (long) getpid()); + GC_printf1("sp = 0x%lx\n", (long) &arg); + GC_printf1("start_routine = 0x%lx\n", start); +# endif + result = (*start)(start_arg); +#if DEBUG_THREADS + GC_printf1("Finishing thread 0x%x\n", pthread_self()); +#endif + me -> status = result; + me -> flags |= FINISHED; + pthread_cleanup_pop(1); + /* Cleanup acquires lock, ensuring that we can't exit */ + /* while a collection that thinks we're alive is trying to stop */ + /* us. */ + return(result); +} + +int +GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr, + void *(*start_routine)(void *), void *arg) +{ + int result; + GC_thread t; + pthread_t my_new_thread; + void * stack; + size_t stacksize; + pthread_attr_t new_attr; + int detachstate; + word my_flags = 0; + struct start_info * si = GC_malloc(sizeof(struct start_info)); + /* This is otherwise saved only in an area mmapped by the thread */ + /* library, which isn't visible to the collector. */ + + if (0 == si) return(ENOMEM); + sem_init(&(si -> registered), 0, 0); + si -> start_routine = start_routine; + si -> arg = arg; + LOCK(); + if (!GC_thr_initialized) GC_thr_init(); + if (NULL == attr) { + stack = 0; + (void) pthread_attr_init(&new_attr); + } else { + new_attr = *attr; + } + pthread_attr_getdetachstate(&new_attr, &detachstate); + if (PTHREAD_CREATE_DETACHED == detachstate) my_flags |= DETACHED; + si -> flags = my_flags; + UNLOCK(); + result = pthread_create(new_thread, &new_attr, GC_start_routine, si); + /* Wait until child has been added to the thread table. */ + /* This also ensures that we hold onto si until the child is done */ + /* with it. Thus it doesn't matter whether it is otherwise */ + /* visible to the collector. */ + if (0 != sem_wait(&(si -> registered))) ABORT("sem_wait failed"); + sem_destroy(&(si -> registered)); + /* pthread_attr_destroy(&new_attr); */ + /* pthread_attr_destroy(&new_attr); */ + return(result); +} + +GC_bool GC_collecting = 0; + /* A hint that we're in the collector and */ + /* holding the allocation lock for an */ + /* extended period. */ + +/* Reasonably fast spin locks. Basically the same implementation */ +/* as STL alloc.h. This isn't really the right way to do this. */ +/* but until the POSIX scheduling mess gets straightened out ... */ + +volatile unsigned int GC_allocate_lock = 0; + + +void GC_lock() +{ +# define low_spin_max 30 /* spin cycles if we suspect uniprocessor */ +# define high_spin_max 1000 /* spin cycles for multiprocessor */ + static unsigned spin_max = low_spin_max; + unsigned my_spin_max; + static unsigned last_spins = 0; + unsigned my_last_spins; + volatile unsigned junk; +# define PAUSE junk *= junk; junk *= junk; junk *= junk; junk *= junk + int i; + + if (!GC_test_and_set(&GC_allocate_lock)) { + return; + } + junk = 0; + my_spin_max = spin_max; + my_last_spins = last_spins; + for (i = 0; i < my_spin_max; i++) { + if (GC_collecting) goto yield; + if (i < my_last_spins/2 || GC_allocate_lock) { + PAUSE; + continue; + } + if (!GC_test_and_set(&GC_allocate_lock)) { + /* + * got it! + * Spinning worked. Thus we're probably not being scheduled + * against the other process with which we were contending. + * Thus it makes sense to spin longer the next time. + */ + last_spins = i; + spin_max = high_spin_max; + return; + } + } + /* We are probably being scheduled against the other process. Sleep. */ + spin_max = low_spin_max; +yield: + for (i = 0;; ++i) { + if (!GC_test_and_set(&GC_allocate_lock)) { + return; + } +# define SLEEP_THRESHOLD 12 + /* nanosleep(<= 2ms) just spins under Linux. We */ + /* want to be careful to avoid that behavior. */ + if (i < SLEEP_THRESHOLD) { + sched_yield(); + } else { + struct timespec ts; + + if (i > 26) i = 26; + /* Don't wait for more than about 60msecs, even */ + /* under extreme contention. */ + ts.tv_sec = 0; + ts.tv_nsec = 1 << i; + nanosleep(&ts, 0); + } + } +} + +# endif /* LINUX_THREADS */ + diff --git a/support/gc/mach_dep.c b/support/gc/mach_dep.c new file mode 100644 index 00000000..53698604 --- /dev/null +++ b/support/gc/mach_dep.c @@ -0,0 +1,444 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, November 17, 1995 12:13 pm PST */ +# include "gc_priv.h" +# include +# include +# if defined(OS2) || defined(CX_UX) +# define _setjmp(b) setjmp(b) +# define _longjmp(b,v) longjmp(b,v) +# endif +# ifdef AMIGA +# ifndef __GNUC__ +# include +# else +# include +# endif +# endif + +#if defined(__MWERKS__) && !defined(POWERPC) + +asm static void PushMacRegisters() +{ + sub.w #4,sp // reserve space for one parameter. + move.l a2,(sp) + jsr GC_push_one + move.l a3,(sp) + jsr GC_push_one + move.l a4,(sp) + jsr GC_push_one +# if !__option(a6frames) + // perhaps a6 should be pushed if stack frames are not being used. + move.l a6,(sp) + jsr GC_push_one +# endif + // skip a5 (globals), a6 (frame pointer), and a7 (stack pointer) + move.l d2,(sp) + jsr GC_push_one + move.l d3,(sp) + jsr GC_push_one + move.l d4,(sp) + jsr GC_push_one + move.l d5,(sp) + jsr GC_push_one + move.l d6,(sp) + jsr GC_push_one + move.l d7,(sp) + jsr GC_push_one + add.w #4,sp // fix stack. + rts +} + +#endif /* __MWERKS__ */ + +/* Routine to mark from registers that are preserved by the C compiler. */ +/* This must be ported to every new architecture. There is a generic */ +/* version at the end, that is likely, but not guaranteed to work */ +/* on your architecture. Run the test_setjmp program to see whether */ +/* there is any chance it will work. */ + +#ifndef USE_GENERIC_PUSH_REGS +void GC_push_regs() +{ +# ifdef RT + register long TMP_SP; /* must be bound to r11 */ +# endif +# ifdef VAX + /* VAX - generic code below does not work under 4.2 */ + /* r1 through r5 are caller save, and therefore */ + /* on the stack or dead. */ + asm("pushl r11"); asm("calls $1,_GC_push_one"); + asm("pushl r10"); asm("calls $1,_GC_push_one"); + asm("pushl r9"); asm("calls $1,_GC_push_one"); + asm("pushl r8"); asm("calls $1,_GC_push_one"); + asm("pushl r7"); asm("calls $1,_GC_push_one"); + asm("pushl r6"); asm("calls $1,_GC_push_one"); +# endif +# if defined(M68K) && (defined(SUNOS4) || defined(NEXT)) + /* M68K SUNOS - could be replaced by generic code */ + /* a0, a1 and d1 are caller save */ + /* and therefore are on stack or dead. */ + + asm("subqw #0x4,sp"); /* allocate word on top of stack */ + + asm("movl a2,sp@"); asm("jbsr _GC_push_one"); + asm("movl a3,sp@"); asm("jbsr _GC_push_one"); + asm("movl a4,sp@"); asm("jbsr _GC_push_one"); + asm("movl a5,sp@"); asm("jbsr _GC_push_one"); + /* Skip frame pointer and stack pointer */ + asm("movl d1,sp@"); asm("jbsr _GC_push_one"); + asm("movl d2,sp@"); asm("jbsr _GC_push_one"); + asm("movl d3,sp@"); asm("jbsr _GC_push_one"); + asm("movl d4,sp@"); asm("jbsr _GC_push_one"); + asm("movl d5,sp@"); asm("jbsr _GC_push_one"); + asm("movl d6,sp@"); asm("jbsr _GC_push_one"); + asm("movl d7,sp@"); asm("jbsr _GC_push_one"); + + asm("addqw #0x4,sp"); /* put stack back where it was */ +# endif + +# if defined(M68K) && defined(HP) + /* M68K HP - could be replaced by generic code */ + /* a0, a1 and d1 are caller save. */ + + asm("subq.w &0x4,%sp"); /* allocate word on top of stack */ + + asm("mov.l %a2,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %a3,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %a4,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %a5,(%sp)"); asm("jsr _GC_push_one"); + /* Skip frame pointer and stack pointer */ + asm("mov.l %d1,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d2,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d3,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d4,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d5,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d6,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d7,(%sp)"); asm("jsr _GC_push_one"); + + asm("addq.w &0x4,%sp"); /* put stack back where it was */ +# endif /* M68K HP */ + +# if defined(M68K) && defined(AMIGA) + /* AMIGA - could be replaced by generic code */ + /* a0, a1, d0 and d1 are caller save */ + +# ifdef __GNUC__ + asm("subq.w &0x4,%sp"); /* allocate word on top of stack */ + + asm("mov.l %a2,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %a3,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %a4,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %a5,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %a6,(%sp)"); asm("jsr _GC_push_one"); + /* Skip frame pointer and stack pointer */ + asm("mov.l %d2,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d3,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d4,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d5,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d6,(%sp)"); asm("jsr _GC_push_one"); + asm("mov.l %d7,(%sp)"); asm("jsr _GC_push_one"); + + asm("addq.w &0x4,%sp"); /* put stack back where it was */ +# else /* !__GNUC__ */ + GC_push_one(getreg(REG_A2)); + GC_push_one(getreg(REG_A3)); + GC_push_one(getreg(REG_A4)); + GC_push_one(getreg(REG_A5)); + GC_push_one(getreg(REG_A6)); + /* Skip stack pointer */ + GC_push_one(getreg(REG_D2)); + GC_push_one(getreg(REG_D3)); + GC_push_one(getreg(REG_D4)); + GC_push_one(getreg(REG_D5)); + GC_push_one(getreg(REG_D6)); + GC_push_one(getreg(REG_D7)); +# endif /* !__GNUC__ */ +# endif /* AMIGA */ + +# if defined(M68K) && defined(MACOS) +# if defined(THINK_C) +# define PushMacReg(reg) \ + move.l reg,(sp) \ + jsr GC_push_one + asm { + sub.w #4,sp ; reserve space for one parameter. + PushMacReg(a2); + PushMacReg(a3); + PushMacReg(a4); + ; skip a5 (globals), a6 (frame pointer), and a7 (stack pointer) + PushMacReg(d2); + PushMacReg(d3); + PushMacReg(d4); + PushMacReg(d5); + PushMacReg(d6); + PushMacReg(d7); + add.w #4,sp ; fix stack. + } +# undef PushMacReg +# endif /* THINK_C */ +# if defined(__MWERKS__) + PushMacRegisters(); +# endif /* __MWERKS__ */ +# endif /* MACOS */ + +# if defined(I386) &&!defined(OS2) &&!defined(SVR4) &&!defined(MSWIN32) \ + && !defined(SCO) && !defined(SCO_ELF) \ + && !(defined(LINUX) && defined(__ELF__)) \ + && !(defined(__FreeBSD__) && defined(__ELF__)) \ + && !defined(DOS4GW) + /* I386 code, generic code does not appear to work */ + /* It does appear to work under OS2, and asms dont */ + /* This is used for some 38g UNIX variants and for CYGWIN32 */ + asm("pushl %eax"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ecx"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edx"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebp"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %esi"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edi"); asm("call _GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebx"); asm("call _GC_push_one"); asm("addl $4,%esp"); +# endif + +# if ( defined(I386) && defined(LINUX) && defined(__ELF__) ) \ + || ( defined(I386) && defined(__FreeBSD__) && defined(__ELF__) ) + + /* This is modified for Linux with ELF (Note: _ELF_ only) */ + /* This section handles FreeBSD with ELF. */ + asm("pushl %eax"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ecx"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edx"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebp"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %esi"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edi"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebx"); asm("call GC_push_one"); asm("addl $4,%esp"); +# endif + +# if defined(I386) && defined(MSWIN32) && !defined(USE_GENERIC) + /* I386 code, Microsoft variant */ + __asm push eax + __asm call GC_push_one + __asm add esp,4 + __asm push ebx + __asm call GC_push_one + __asm add esp,4 + __asm push ecx + __asm call GC_push_one + __asm add esp,4 + __asm push edx + __asm call GC_push_one + __asm add esp,4 + __asm push ebp + __asm call GC_push_one + __asm add esp,4 + __asm push esi + __asm call GC_push_one + __asm add esp,4 + __asm push edi + __asm call GC_push_one + __asm add esp,4 +# endif + +# if defined(I386) && (defined(SVR4) || defined(SCO) || defined(SCO_ELF)) + /* I386 code, SVR4 variant, generic code does not appear to work */ + asm("pushl %eax"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebx"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ecx"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edx"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %ebp"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %esi"); asm("call GC_push_one"); asm("addl $4,%esp"); + asm("pushl %edi"); asm("call GC_push_one"); asm("addl $4,%esp"); +# endif + +# ifdef NS32K + asm ("movd r3, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); + asm ("movd r4, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); + asm ("movd r5, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); + asm ("movd r6, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); + asm ("movd r7, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4"); +# endif + +# ifdef SPARC + { + word GC_save_regs_in_stack(); + + /* generic code will not work */ + (void)GC_save_regs_in_stack(); + } +# endif + +# ifdef RT + GC_push_one(TMP_SP); /* GC_push_one from r11 */ + + asm("cas r11, r6, r0"); GC_push_one(TMP_SP); /* r6 */ + asm("cas r11, r7, r0"); GC_push_one(TMP_SP); /* through */ + asm("cas r11, r8, r0"); GC_push_one(TMP_SP); /* r10 */ + asm("cas r11, r9, r0"); GC_push_one(TMP_SP); + asm("cas r11, r10, r0"); GC_push_one(TMP_SP); + + asm("cas r11, r12, r0"); GC_push_one(TMP_SP); /* r12 */ + asm("cas r11, r13, r0"); GC_push_one(TMP_SP); /* through */ + asm("cas r11, r14, r0"); GC_push_one(TMP_SP); /* r15 */ + asm("cas r11, r15, r0"); GC_push_one(TMP_SP); +# endif + +# if defined(M68K) && defined(SYSV) + /* Once again similar to SUN and HP, though setjmp appears to work. + --Parag + */ +# ifdef __GNUC__ + asm("subqw #0x4,%sp"); /* allocate word on top of stack */ + + asm("movl %a2,%sp@"); asm("jbsr GC_push_one"); + asm("movl %a3,%sp@"); asm("jbsr GC_push_one"); + asm("movl %a4,%sp@"); asm("jbsr GC_push_one"); + asm("movl %a5,%sp@"); asm("jbsr GC_push_one"); + /* Skip frame pointer and stack pointer */ + asm("movl %d1,%sp@"); asm("jbsr GC_push_one"); + asm("movl %d2,%sp@"); asm("jbsr GC_push_one"); + asm("movl %d3,%sp@"); asm("jbsr GC_push_one"); + asm("movl %d4,%sp@"); asm("jbsr GC_push_one"); + asm("movl %d5,%sp@"); asm("jbsr GC_push_one"); + asm("movl %d6,%sp@"); asm("jbsr GC_push_one"); + asm("movl %d7,%sp@"); asm("jbsr GC_push_one"); + + asm("addqw #0x4,%sp"); /* put stack back where it was */ +# else /* !__GNUC__*/ + asm("subq.w &0x4,%sp"); /* allocate word on top of stack */ + + asm("mov.l %a2,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %a3,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %a4,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %a5,(%sp)"); asm("jsr GC_push_one"); + /* Skip frame pointer and stack pointer */ + asm("mov.l %d1,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %d2,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %d3,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %d4,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %d5,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %d6,(%sp)"); asm("jsr GC_push_one"); + asm("mov.l %d7,(%sp)"); asm("jsr GC_push_one"); + + asm("addq.w &0x4,%sp"); /* put stack back where it was */ +# endif /* !__GNUC__ */ +# endif /* M68K/SYSV */ + + + /* other machines... */ +# if !(defined M68K) && !(defined VAX) && !(defined RT) +# if !(defined SPARC) && !(defined I386) && !(defined NS32K) +# if !defined(POWERPC) && !defined(UTS4) + --> bad news <-- +# endif +# endif +# endif +} +#endif /* !USE_GENERIC_PUSH_REGS */ + +#if defined(USE_GENERIC_PUSH_REGS) +void GC_generic_push_regs(cold_gc_frame) +ptr_t cold_gc_frame; +{ + /* Generic code */ + /* The idea is due to Parag Patel at HP. */ + /* We're not sure whether he would like */ + /* to be he acknowledged for it or not. */ + { + static jmp_buf regs; + register word * i = (word *) regs; + register ptr_t lim = (ptr_t)(regs) + (sizeof regs); + + /* Setjmp on Sun 3s doesn't clear all of the buffer. */ + /* That tends to preserve garbage. Clear it. */ + for (; (char *)i < lim; i++) { + *i = 0; + } +# if defined(POWERPC) || defined(MSWIN32) || defined(UTS4) + (void) setjmp(regs); +# else + (void) _setjmp(regs); +# endif + GC_push_current_stack(cold_gc_frame); + } +} +#endif /* USE_GENERIC_PUSH_REGS */ + +/* On register window machines, we need a way to force registers into */ +/* the stack. Return sp. */ +# ifdef SPARC + asm(" .seg \"text\""); +# ifdef SVR4 + asm(" .globl GC_save_regs_in_stack"); + asm("GC_save_regs_in_stack:"); + asm(" .type GC_save_regs_in_stack,#function"); +# else + asm(" .globl _GC_save_regs_in_stack"); + asm("_GC_save_regs_in_stack:"); +# endif + asm(" ta 0x3 ! ST_FLUSH_WINDOWS"); + asm(" mov %sp,%o0"); + asm(" retl"); + asm(" nop"); +# ifdef SVR4 + asm(" .GC_save_regs_in_stack_end:"); + asm(" .size GC_save_regs_in_stack,.GC_save_regs_in_stack_end-GC_save_regs_in_stack"); +# endif +# ifdef LINT + word GC_save_regs_in_stack() { return(0 /* sp really */);} +# endif +# endif + + +/* GC_clear_stack_inner(arg, limit) clears stack area up to limit and */ +/* returns arg. Stack clearing is crucial on SPARC, so we supply */ +/* an assembly version that's more careful. Assumes limit is hotter */ +/* than sp, and limit is 8 byte aligned. */ +#if defined(ASM_CLEAR_CODE) && !defined(THREADS) +#ifndef SPARC + --> fix it +#endif +# ifdef SUNOS4 + asm(".globl _GC_clear_stack_inner"); + asm("_GC_clear_stack_inner:"); +# else + asm(".globl GC_clear_stack_inner"); + asm("GC_clear_stack_inner:"); + asm(".type GC_save_regs_in_stack,#function"); +# endif + asm("mov %sp,%o2"); /* Save sp */ + asm("add %sp,-8,%o3"); /* p = sp-8 */ + asm("clr %g1"); /* [g0,g1] = 0 */ + asm("add %o1,-0x60,%sp"); /* Move sp out of the way, */ + /* so that traps still work. */ + /* Includes some extra words */ + /* so we can be sloppy below. */ + asm("loop:"); + asm("std %g0,[%o3]"); /* *(long long *)p = 0 */ + asm("cmp %o3,%o1"); + asm("bgu loop "); /* if (p > limit) goto loop */ + asm("add %o3,-8,%o3"); /* p -= 8 (delay slot) */ + asm("retl"); + asm("mov %o2,%sp"); /* Restore sp., delay slot */ + /* First argument = %o0 = return value */ +# ifdef SVR4 + asm(" .GC_clear_stack_inner_end:"); + asm(" .size GC_clear_stack_inner,.GC_clear_stack_inner_end-GC_clear_stack_inner"); +# endif + +# ifdef LINT + /*ARGSUSED*/ + ptr_t GC_clear_stack_inner(arg, limit) + ptr_t arg; word limit; + { return(arg); } +# endif +#endif diff --git a/support/gc/makefile.depend b/support/gc/makefile.depend new file mode 100644 index 00000000..e69de29b diff --git a/support/gc/malloc.c b/support/gc/malloc.c new file mode 100644 index 00000000..66e62d29 --- /dev/null +++ b/support/gc/malloc.c @@ -0,0 +1,443 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, February 7, 1996 4:32 pm PST */ + +#include +#include "gc_priv.h" + +extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */ +void GC_extend_size_map(); /* in misc.c. */ + +/* Allocate reclaim list for kind: */ +/* Return TRUE on success */ +GC_bool GC_alloc_reclaim_list(kind) +register struct obj_kind * kind; +{ + struct hblk ** result = (struct hblk **) + GC_scratch_alloc((MAXOBJSZ+1) * sizeof(struct hblk *)); + if (result == 0) return(FALSE); + BZERO(result, (MAXOBJSZ+1)*sizeof(struct hblk *)); + kind -> ok_reclaim_list = result; + return(TRUE); +} + +/* allocate lb bytes for an object of kind. */ +/* Should not be used to directly to allocate */ +/* objects such as STUBBORN objects that */ +/* require special handling on allocation. */ +/* First a version that assumes we already */ +/* hold lock: */ +ptr_t GC_generic_malloc_inner(lb, k) +register word lb; +register int k; +{ +register word lw; +register ptr_t op; +register ptr_t *opp; + + if( SMALL_OBJ(lb) ) { + register struct obj_kind * kind = GC_obj_kinds + k; +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); + if (lw == 0) lw = 1; +# endif + opp = &(kind -> ok_freelist[lw]); + if( (op = *opp) == 0 ) { +# ifdef MERGE_SIZES + if (GC_size_map[lb] == 0) { + if (!GC_is_initialized) GC_init_inner(); + if (GC_size_map[lb] == 0) GC_extend_size_map(lb); + return(GC_generic_malloc_inner(lb, k)); + } +# else + if (!GC_is_initialized) { + GC_init_inner(); + return(GC_generic_malloc_inner(lb, k)); + } +# endif + if (kind -> ok_reclaim_list == 0) { + if (!GC_alloc_reclaim_list(kind)) goto out; + } + op = GC_allocobj(lw, k); + if (op == 0) goto out; + } + /* Here everything is in a consistent state. */ + /* We assume the following assignment is */ + /* atomic. If we get aborted */ + /* after the assignment, we lose an object, */ + /* but that's benign. */ + /* Volatile declarations may need to be added */ + /* to prevent the compiler from breaking things.*/ + *opp = obj_link(op); + obj_link(op) = 0; + } else { + register struct hblk * h; + register word n_blocks = divHBLKSZ(ADD_SLOP(lb) + + HDR_BYTES + HBLKSIZE-1); + + if (!GC_is_initialized) GC_init_inner(); + /* Do our share of marking work */ + if(GC_incremental && !GC_dont_gc) + GC_collect_a_little_inner((int)n_blocks); + lw = ROUNDED_UP_WORDS(lb); + h = GC_allochblk(lw, k, 0); +# ifdef USE_MUNMAP + if (0 == h) { + GC_merge_unmapped(); + h = GC_allochblk(lw, k, 0); + } +# endif + while (0 == h && GC_collect_or_expand(n_blocks, FALSE)) { + h = GC_allochblk(lw, k, 0); + } + if (h == 0) { + op = 0; + } else { + op = (ptr_t) (h -> hb_body); + GC_words_wasted += BYTES_TO_WORDS(n_blocks * HBLKSIZE) - lw; + } + } + GC_words_allocd += lw; + +out: + return((ptr_t)op); +} + +ptr_t GC_generic_malloc(lb, k) +register word lb; +register int k; +{ + ptr_t result; + DCL_LOCK_STATE; + + GC_INVOKE_FINALIZERS(); + DISABLE_SIGNALS(); + LOCK(); + result = GC_generic_malloc_inner(lb, k); + UNLOCK(); + ENABLE_SIGNALS(); + if (0 == result) { + return((*GC_oom_fn)(lb)); + } else { + return(result); + } +} + + +#define GENERAL_MALLOC(lb,k) \ + (GC_PTR)GC_clear_stack(GC_generic_malloc((word)lb, k)) +/* We make the GC_clear_stack_call a tail call, hoping to get more of */ +/* the stack. */ + +/* Allocate lb bytes of atomic (pointerfree) data */ +# ifdef __STDC__ + GC_PTR GC_malloc_atomic(size_t lb) +# else + GC_PTR GC_malloc_atomic(lb) + size_t lb; +# endif +{ +register ptr_t op; +register ptr_t * opp; +register word lw; +DCL_LOCK_STATE; + + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_aobjfreelist[lw]); + FASTLOCK(); + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { + FASTUNLOCK(); + return(GENERAL_MALLOC((word)lb, PTRFREE)); + } + /* See above comment on signals. */ + *opp = obj_link(op); + GC_words_allocd += lw; + FASTUNLOCK(); + return((GC_PTR) op); + } else { + return(GENERAL_MALLOC((word)lb, PTRFREE)); + } +} + +/* Allocate lb bytes of composite (pointerful) data */ +# ifdef __STDC__ + GC_PTR GC_malloc(size_t lb) +# else + GC_PTR GC_malloc(lb) + size_t lb; +# endif +{ +register ptr_t op; +register ptr_t *opp; +register word lw; +DCL_LOCK_STATE; + + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_objfreelist[lw]); + FASTLOCK(); + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { + FASTUNLOCK(); + return(GENERAL_MALLOC((word)lb, NORMAL)); + } + /* See above comment on signals. */ + *opp = obj_link(op); + obj_link(op) = 0; + GC_words_allocd += lw; + FASTUNLOCK(); + return((GC_PTR) op); + } else { + return(GENERAL_MALLOC((word)lb, NORMAL)); + } +} + +# ifdef REDIRECT_MALLOC +# ifdef __STDC__ + GC_PTR malloc(size_t lb) +# else + GC_PTR malloc(lb) + size_t lb; +# endif + { + /* It might help to manually inline the GC_malloc call here. */ + /* But any decent compiler should reduce the extra procedure call */ + /* to at most a jump instruction in this case. */ +# if defined(I386) && defined(SOLARIS_THREADS) + /* + * Thread initialisation can call malloc before + * we're ready for it. + * It's not clear that this is enough to help matters. + * The thread implementation may well call malloc at other + * inopportune times. + */ + if (!GC_is_initialized) return sbrk(lb); +# endif /* I386 && SOLARIS_THREADS */ + return(REDIRECT_MALLOC(lb)); + } + +# ifdef __STDC__ + GC_PTR calloc(size_t n, size_t lb) +# else + GC_PTR calloc(n, lb) + size_t n, lb; +# endif + { + return(REDIRECT_MALLOC(n*lb)); + } +# endif /* REDIRECT_MALLOC */ + +GC_PTR GC_generic_or_special_malloc(lb,knd) +word lb; +int knd; +{ + switch(knd) { +# ifdef STUBBORN_ALLOC + case STUBBORN: + return(GC_malloc_stubborn((size_t)lb)); +# endif + case PTRFREE: + return(GC_malloc_atomic((size_t)lb)); + case NORMAL: + return(GC_malloc((size_t)lb)); + case UNCOLLECTABLE: + return(GC_malloc_uncollectable((size_t)lb)); +# ifdef ATOMIC_UNCOLLECTABLE + case AUNCOLLECTABLE: + return(GC_malloc_atomic_uncollectable((size_t)lb)); +# endif /* ATOMIC_UNCOLLECTABLE */ + default: + return(GC_generic_malloc(lb,knd)); + } +} + + +/* Change the size of the block pointed to by p to contain at least */ +/* lb bytes. The object may be (and quite likely will be) moved. */ +/* The kind (e.g. atomic) is the same as that of the old. */ +/* Shrinking of large blocks is not implemented well. */ +# ifdef __STDC__ + GC_PTR GC_realloc(GC_PTR p, size_t lb) +# else + GC_PTR GC_realloc(p,lb) + GC_PTR p; + size_t lb; +# endif +{ +register struct hblk * h; +register hdr * hhdr; +register word sz; /* Current size in bytes */ +register word orig_sz; /* Original sz in bytes */ +int obj_kind; + + if (p == 0) return(GC_malloc(lb)); /* Required by ANSI */ + h = HBLKPTR(p); + hhdr = HDR(h); + sz = hhdr -> hb_sz; + obj_kind = hhdr -> hb_obj_kind; + sz = WORDS_TO_BYTES(sz); + orig_sz = sz; + + if (sz > WORDS_TO_BYTES(MAXOBJSZ)) { + /* Round it up to the next whole heap block */ + register word descr; + + sz = (sz+HDR_BYTES+HBLKSIZE-1) + & (~HBLKMASK); + sz -= HDR_BYTES; + hhdr -> hb_sz = BYTES_TO_WORDS(sz); + descr = GC_obj_kinds[obj_kind].ok_descriptor; + if (GC_obj_kinds[obj_kind].ok_relocate_descr) descr += sz; + hhdr -> hb_descr = descr; + if (IS_UNCOLLECTABLE(obj_kind)) GC_non_gc_bytes += (sz - orig_sz); + /* Extra area is already cleared by allochblk. */ + } + if (ADD_SLOP(lb) <= sz) { + if (lb >= (sz >> 1)) { +# ifdef STUBBORN_ALLOC + if (obj_kind == STUBBORN) GC_change_stubborn(p); +# endif + if (orig_sz > lb) { + /* Clear unneeded part of object to avoid bogus pointer */ + /* tracing. */ + /* Safe for stubborn objects. */ + BZERO(((ptr_t)p) + lb, orig_sz - lb); + } + return(p); + } else { + /* shrink */ + GC_PTR result = + GC_generic_or_special_malloc((word)lb, obj_kind); + + if (result == 0) return(0); + /* Could also return original object. But this */ + /* gives the client warning of imminent disaster. */ + BCOPY(p, result, lb); +# ifndef IGNORE_FREE + GC_free(p); +# endif + return(result); + } + } else { + /* grow */ + GC_PTR result = + GC_generic_or_special_malloc((word)lb, obj_kind); + + if (result == 0) return(0); + BCOPY(p, result, sz); +# ifndef IGNORE_FREE + GC_free(p); +# endif + return(result); + } +} + +# ifdef REDIRECT_MALLOC +# ifdef __STDC__ + GC_PTR realloc(GC_PTR p, size_t lb) +# else + GC_PTR realloc(p,lb) + GC_PTR p; + size_t lb; +# endif + { + return(GC_realloc(p, lb)); + } +# endif /* REDIRECT_MALLOC */ + +/* Explicitly deallocate an object p. */ +# ifdef __STDC__ + void GC_free(GC_PTR p) +# else + void GC_free(p) + GC_PTR p; +# endif +{ + register struct hblk *h; + register hdr *hhdr; + register signed_word sz; + register ptr_t * flh; + register int knd; + register struct obj_kind * ok; + DCL_LOCK_STATE; + + if (p == 0) return; + /* Required by ANSI. It's not my fault ... */ + h = HBLKPTR(p); + hhdr = HDR(h); +# if defined(REDIRECT_MALLOC) && \ + (defined(SOLARIS_THREADS) || defined(LINUX_THREADS)) + /* We have to redirect malloc calls during initialization. */ + /* Don't try to deallocate that memory. */ + if (0 == hhdr) return; +# endif + knd = hhdr -> hb_obj_kind; + sz = hhdr -> hb_sz; + ok = &GC_obj_kinds[knd]; + if (sz <= MAXOBJSZ) { +# ifdef THREADS + DISABLE_SIGNALS(); + LOCK(); +# endif + GC_mem_freed += sz; + /* A signal here can make GC_mem_freed and GC_non_gc_bytes */ + /* inconsistent. We claim this is benign. */ + if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= WORDS_TO_BYTES(sz); + /* Its unnecessary to clear the mark bit. If the */ + /* object is reallocated, it doesn't matter. O.w. the */ + /* collector will do it, since it's on a free list. */ + if (ok -> ok_init) { + BZERO((word *)p + 1, WORDS_TO_BYTES(sz-1)); + } + flh = &(ok -> ok_freelist[sz]); + obj_link(p) = *flh; + *flh = (ptr_t)p; +# ifdef THREADS + UNLOCK(); + ENABLE_SIGNALS(); +# endif + } else { + DISABLE_SIGNALS(); + LOCK(); + GC_mem_freed += sz; + if (IS_UNCOLLECTABLE(knd)) GC_non_gc_bytes -= WORDS_TO_BYTES(sz); + GC_freehblk(h); + UNLOCK(); + ENABLE_SIGNALS(); + } +} + +# ifdef REDIRECT_MALLOC +# ifdef __STDC__ + void free(GC_PTR p) +# else + void free(p) + GC_PTR p; +# endif + { +# ifndef IGNORE_FREE + GC_free(p); +# endif + } +# endif /* REDIRECT_MALLOC */ diff --git a/support/gc/mallocx.c b/support/gc/mallocx.c new file mode 100644 index 00000000..8c07fa98 --- /dev/null +++ b/support/gc/mallocx.c @@ -0,0 +1,375 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* + * These are extra allocation routines which are likely to be less + * frequently used than those in malloc.c. They are separate in the + * hope that the .o file will be excluded from statically linked + * executables. We should probably break this up further. + */ + +#include +#include "gc_priv.h" + +extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */ +void GC_extend_size_map(); /* in misc.c. */ +GC_bool GC_alloc_reclaim_list(); /* in malloc.c */ + +/* Some externally visible but unadvertised variables to allow access to */ +/* free lists from inlined allocators without including gc_priv.h */ +/* or introducing dependencies on internal data structure layouts. */ +ptr_t * CONST GC_objfreelist_ptr = GC_objfreelist; +ptr_t * CONST GC_aobjfreelist_ptr = GC_aobjfreelist; +ptr_t * CONST GC_uobjfreelist_ptr = GC_uobjfreelist; +# ifdef ATOMIC_UNCOLLECTABLE + ptr_t * CONST GC_auobjfreelist_ptr = GC_auobjfreelist; +# endif + +/* Allocate a composite object of size n bytes. The caller guarantees */ +/* that pointers past the first page are not relevant. Caller holds */ +/* allocation lock. */ +ptr_t GC_generic_malloc_inner_ignore_off_page(lb, k) +register size_t lb; +register int k; +{ + register struct hblk * h; + register word n_blocks; + register word lw; + register ptr_t op; + + if (lb <= HBLKSIZE) + return(GC_generic_malloc_inner((word)lb, k)); + n_blocks = divHBLKSZ(ADD_SLOP(lb) + HDR_BYTES + HBLKSIZE-1); + if (!GC_is_initialized) GC_init_inner(); + /* Do our share of marking work */ + if(GC_incremental && !GC_dont_gc) + GC_collect_a_little_inner((int)n_blocks); + lw = ROUNDED_UP_WORDS(lb); + h = GC_allochblk(lw, k, IGNORE_OFF_PAGE); +# ifdef USE_MUNMAP + if (0 == h) { + GC_merge_unmapped(); + h = GC_allochblk(lw, k, IGNORE_OFF_PAGE); + } +# endif + while (0 == h && GC_collect_or_expand(n_blocks, TRUE)) { + h = GC_allochblk(lw, k, IGNORE_OFF_PAGE); + } + if (h == 0) { + op = 0; + } else { + op = (ptr_t) (h -> hb_body); + GC_words_wasted += BYTES_TO_WORDS(n_blocks * HBLKSIZE) - lw; + } + GC_words_allocd += lw; + return((ptr_t)op); +} + +ptr_t GC_generic_malloc_ignore_off_page(lb, k) +register size_t lb; +register int k; +{ + register ptr_t result; + DCL_LOCK_STATE; + + GC_INVOKE_FINALIZERS(); + DISABLE_SIGNALS(); + LOCK(); + result = GC_generic_malloc_inner_ignore_off_page(lb,k); + UNLOCK(); + ENABLE_SIGNALS(); + if (0 == result) { + return((*GC_oom_fn)(lb)); + } else { + return(result); + } +} + +# if defined(__STDC__) || defined(__cplusplus) + void * GC_malloc_ignore_off_page(size_t lb) +# else + char * GC_malloc_ignore_off_page(lb) + register size_t lb; +# endif +{ + return((GC_PTR)GC_generic_malloc_ignore_off_page(lb, NORMAL)); +} + +# if defined(__STDC__) || defined(__cplusplus) + void * GC_malloc_atomic_ignore_off_page(size_t lb) +# else + char * GC_malloc_atomic_ignore_off_page(lb) + register size_t lb; +# endif +{ + return((GC_PTR)GC_generic_malloc_ignore_off_page(lb, PTRFREE)); +} + +/* Increment GC_words_allocd from code that doesn't have direct access */ +/* to GC_arrays. */ +# ifdef __STDC__ +void GC_incr_words_allocd(size_t n) +{ + GC_words_allocd += n; +} + +/* The same for GC_mem_freed. */ +void GC_incr_mem_freed(size_t n) +{ + GC_mem_freed += n; +} +# endif /* __STDC__ */ + +/* Analogous to the above, but assumes a small object size, and */ +/* bypasses MERGE_SIZES mechanism. Used by gc_inline.h. */ +#ifdef __STDC__ + ptr_t GC_generic_malloc_words_small(size_t lw, int k) +#else + ptr_t GC_generic_malloc_words_small(lw, k) + register word lw; + register int k; +#endif +{ +register ptr_t op; +register ptr_t *opp; +register struct obj_kind * kind = GC_obj_kinds + k; +DCL_LOCK_STATE; + + GC_INVOKE_FINALIZERS(); + DISABLE_SIGNALS(); + LOCK(); + opp = &(kind -> ok_freelist[lw]); + if( (op = *opp) == 0 ) { + if (!GC_is_initialized) { + GC_init_inner(); + } + if (kind -> ok_reclaim_list != 0 || GC_alloc_reclaim_list(kind)) { + op = GC_clear_stack(GC_allocobj((word)lw, k)); + } + if (op == 0) { + UNLOCK(); + ENABLE_SIGNALS(); + return ((*GC_oom_fn)(WORDS_TO_BYTES(lw))); + } + } + *opp = obj_link(op); + obj_link(op) = 0; + GC_words_allocd += lw; + UNLOCK(); + ENABLE_SIGNALS(); + return((ptr_t)op); +} + +#if defined(THREADS) && !defined(SRC_M3) +/* Return a list of 1 or more objects of the indicated size, linked */ +/* through the first word in the object. This has the advantage that */ +/* it acquires the allocation lock only once, and may greatly reduce */ +/* time wasted contending for the allocation lock. Typical usage would */ +/* be in a thread that requires many items of the same size. It would */ +/* keep its own free list in thread-local storage, and call */ +/* GC_malloc_many or friends to replenish it. (We do not round up */ +/* object sizes, since a call indicates the intention to consume many */ +/* objects of exactly this size.) */ +/* Note that the client should usually clear the link field. */ +ptr_t GC_generic_malloc_many(lb, k) +register word lb; +register int k; +{ +ptr_t op; +register ptr_t p; +ptr_t *opp; +word lw; +register word my_words_allocd; +DCL_LOCK_STATE; + + if (!SMALL_OBJ(lb)) { + op = GC_generic_malloc(lb, k); + if(0 != op) obj_link(op) = 0; + return(op); + } + lw = ALIGNED_WORDS(lb); + GC_INVOKE_FINALIZERS(); + DISABLE_SIGNALS(); + LOCK(); + opp = &(GC_obj_kinds[k].ok_freelist[lw]); + if( (op = *opp) == 0 ) { + if (!GC_is_initialized) { + GC_init_inner(); + } + op = GC_clear_stack(GC_allocobj(lw, k)); + if (op == 0) { + UNLOCK(); + ENABLE_SIGNALS(); + op = (*GC_oom_fn)(lb); + if(0 != op) obj_link(op) = 0; + return(op); + } + } + *opp = 0; + my_words_allocd = 0; + for (p = op; p != 0; p = obj_link(p)) { + my_words_allocd += lw; + if (my_words_allocd >= BODY_SZ) { + *opp = obj_link(p); + obj_link(p) = 0; + break; + } + } + GC_words_allocd += my_words_allocd; + +out: + UNLOCK(); + ENABLE_SIGNALS(); + return(op); + +} + +void * GC_malloc_many(size_t lb) +{ + return(GC_generic_malloc_many(lb, NORMAL)); +} + +/* Note that the "atomic" version of this would be unsafe, since the */ +/* links would not be seen by the collector. */ +# endif + +/* Allocate lb bytes of pointerful, traced, but not collectable data */ +# ifdef __STDC__ + GC_PTR GC_malloc_uncollectable(size_t lb) +# else + GC_PTR GC_malloc_uncollectable(lb) + size_t lb; +# endif +{ +register ptr_t op; +register ptr_t *opp; +register word lw; +DCL_LOCK_STATE; + + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES +# ifdef ADD_BYTE_AT_END + if (lb != 0) lb--; + /* We don't need the extra byte, since this won't be */ + /* collected anyway. */ +# endif + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_uobjfreelist[lw]); + FASTLOCK(); + if( FASTLOCK_SUCCEEDED() && (op = *opp) != 0 ) { + /* See above comment on signals. */ + *opp = obj_link(op); + obj_link(op) = 0; + GC_words_allocd += lw; + /* Mark bit ws already set on free list. It will be */ + /* cleared only temporarily during a collection, as a */ + /* result of the normal free list mark bit clearing. */ + GC_non_gc_bytes += WORDS_TO_BYTES(lw); + FASTUNLOCK(); + return((GC_PTR) op); + } + FASTUNLOCK(); + op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE); + } else { + op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE); + } + if (0 == op) return(0); + /* We don't need the lock here, since we have an undisguised */ + /* pointer. We do need to hold the lock while we adjust */ + /* mark bits. */ + { + register struct hblk * h; + + h = HBLKPTR(op); + lw = HDR(h) -> hb_sz; + + DISABLE_SIGNALS(); + LOCK(); + GC_set_mark_bit(op); + GC_non_gc_bytes += WORDS_TO_BYTES(lw); + UNLOCK(); + ENABLE_SIGNALS(); + return((GC_PTR) op); + } +} + +# ifdef ATOMIC_UNCOLLECTABLE +/* Allocate lb bytes of pointerfree, untraced, uncollectable data */ +/* This is normally roughly equivalent to the system malloc. */ +/* But it may be useful if malloc is redefined. */ +# ifdef __STDC__ + GC_PTR GC_malloc_atomic_uncollectable(size_t lb) +# else + GC_PTR GC_malloc_atomic_uncollectable(lb) + size_t lb; +# endif +{ +register ptr_t op; +register ptr_t *opp; +register word lw; +DCL_LOCK_STATE; + + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES +# ifdef ADD_BYTE_AT_END + if (lb != 0) lb--; + /* We don't need the extra byte, since this won't be */ + /* collected anyway. */ +# endif + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_auobjfreelist[lw]); + FASTLOCK(); + if( FASTLOCK_SUCCEEDED() && (op = *opp) != 0 ) { + /* See above comment on signals. */ + *opp = obj_link(op); + obj_link(op) = 0; + GC_words_allocd += lw; + /* Mark bit was already set while object was on free list. */ + GC_non_gc_bytes += WORDS_TO_BYTES(lw); + FASTUNLOCK(); + return((GC_PTR) op); + } + FASTUNLOCK(); + op = (ptr_t)GC_generic_malloc((word)lb, AUNCOLLECTABLE); + } else { + op = (ptr_t)GC_generic_malloc((word)lb, AUNCOLLECTABLE); + } + if (0 == op) return(0); + /* We don't need the lock here, since we have an undisguised */ + /* pointer. We do need to hold the lock while we adjust */ + /* mark bits. */ + { + register struct hblk * h; + + h = HBLKPTR(op); + lw = HDR(h) -> hb_sz; + + DISABLE_SIGNALS(); + LOCK(); + GC_set_mark_bit(op); + GC_non_gc_bytes += WORDS_TO_BYTES(lw); + UNLOCK(); + ENABLE_SIGNALS(); + return((GC_PTR) op); + } +} + +#endif /* ATOMIC_UNCOLLECTABLE */ diff --git a/support/gc/mark.c b/support/gc/mark.c new file mode 100644 index 00000000..34db472a --- /dev/null +++ b/support/gc/mark.c @@ -0,0 +1,1161 @@ + +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +# include +# include "gc_priv.h" +# include "gc_mark.h" + +/* We put this here to minimize the risk of inlining. */ +/*VARARGS*/ +#ifdef __WATCOMC__ + void GC_noop(void *p, ...) {} +#else + void GC_noop() {} +#endif + +/* Single argument version, robust against whole program analysis. */ +void GC_noop1(x) +word x; +{ + static VOLATILE word sink; + + sink = x; +} + +/* mark_proc GC_mark_procs[MAX_MARK_PROCS] = {0} -- declared in gc_priv.h */ + +word GC_n_mark_procs = 0; + +/* Initialize GC_obj_kinds properly and standard free lists properly. */ +/* This must be done statically since they may be accessed before */ +/* GC_init is called. */ +/* It's done here, since we need to deal with mark descriptors. */ +struct obj_kind GC_obj_kinds[MAXOBJKINDS] = { +/* PTRFREE */ { &GC_aobjfreelist[0], 0 /* filled in dynamically */, + 0 | DS_LENGTH, FALSE, FALSE }, +/* NORMAL */ { &GC_objfreelist[0], 0, +# if defined(ADD_BYTE_AT_END) && ALIGNMENT > DS_TAGS + (word)(-ALIGNMENT) | DS_LENGTH, +# else + 0 | DS_LENGTH, +# endif + TRUE /* add length to descr */, TRUE }, +/* UNCOLLECTABLE */ + { &GC_uobjfreelist[0], 0, + 0 | DS_LENGTH, TRUE /* add length to descr */, TRUE }, +# ifdef ATOMIC_UNCOLLECTABLE + /* AUNCOLLECTABLE */ + { &GC_auobjfreelist[0], 0, + 0 | DS_LENGTH, FALSE /* add length to descr */, FALSE }, +# endif +# ifdef STUBBORN_ALLOC +/*STUBBORN*/ { &GC_sobjfreelist[0], 0, + 0 | DS_LENGTH, TRUE /* add length to descr */, TRUE }, +# endif +}; + +# ifdef ATOMIC_UNCOLLECTABLE +# ifdef STUBBORN_ALLOC + int GC_n_kinds = 5; +# else + int GC_n_kinds = 4; +# endif +# else +# ifdef STUBBORN_ALLOC + int GC_n_kinds = 4; +# else + int GC_n_kinds = 3; +# endif +# endif + + +# ifndef INITIAL_MARK_STACK_SIZE +# define INITIAL_MARK_STACK_SIZE (1*HBLKSIZE) + /* INITIAL_MARK_STACK_SIZE * sizeof(mse) should be a */ + /* multiple of HBLKSIZE. */ +# endif + +/* + * Limits of stack for GC_mark routine. + * All ranges between GC_mark_stack(incl.) and GC_mark_stack_top(incl.) still + * need to be marked from. + */ + +word GC_n_rescuing_pages; /* Number of dirty pages we marked from */ + /* excludes ptrfree pages, etc. */ + +mse * GC_mark_stack; + +word GC_mark_stack_size = 0; + +mse * GC_mark_stack_top; + +static struct hblk * scan_ptr; + +mark_state_t GC_mark_state = MS_NONE; + +GC_bool GC_mark_stack_too_small = FALSE; + +GC_bool GC_objects_are_marked = FALSE; /* Are there collectable marked */ + /* objects in the heap? */ + +/* Is a collection in progress? Note that this can return true in the */ +/* nonincremental case, if a collection has been abandoned and the */ +/* mark state is now MS_INVALID. */ +GC_bool GC_collection_in_progress() +{ + return(GC_mark_state != MS_NONE); +} + +/* clear all mark bits in the header */ +void GC_clear_hdr_marks(hhdr) +register hdr * hhdr; +{ + BZERO(hhdr -> hb_marks, MARK_BITS_SZ*sizeof(word)); +} + +/* Set all mark bits in the header. Used for uncollectable blocks. */ +void GC_set_hdr_marks(hhdr) +register hdr * hhdr; +{ + register int i; + + for (i = 0; i < MARK_BITS_SZ; ++i) { + hhdr -> hb_marks[i] = ONES; + } +} + +/* + * Clear all mark bits associated with block h. + */ +/*ARGSUSED*/ +static void clear_marks_for_block(h, dummy) +struct hblk *h; +word dummy; +{ + register hdr * hhdr = HDR(h); + + if (IS_UNCOLLECTABLE(hhdr -> hb_obj_kind)) return; + /* Mark bit for these is cleared only once the object is */ + /* explicitly deallocated. This either frees the block, or */ + /* the bit is cleared once the object is on the free list. */ + GC_clear_hdr_marks(hhdr); +} + +/* Slow but general routines for setting/clearing/asking about mark bits */ +void GC_set_mark_bit(p) +ptr_t p; +{ + register struct hblk *h = HBLKPTR(p); + register hdr * hhdr = HDR(h); + register int word_no = (word *)p - (word *)h; + + set_mark_bit_from_hdr(hhdr, word_no); +} + +void GC_clear_mark_bit(p) +ptr_t p; +{ + register struct hblk *h = HBLKPTR(p); + register hdr * hhdr = HDR(h); + register int word_no = (word *)p - (word *)h; + + clear_mark_bit_from_hdr(hhdr, word_no); +} + +GC_bool GC_is_marked(p) +ptr_t p; +{ + register struct hblk *h = HBLKPTR(p); + register hdr * hhdr = HDR(h); + register int word_no = (word *)p - (word *)h; + + return(mark_bit_from_hdr(hhdr, word_no)); +} + + +/* + * Clear mark bits in all allocated heap blocks. This invalidates + * the marker invariant, and sets GC_mark_state to reflect this. + * (This implicitly starts marking to reestablish the invariant.) + */ +void GC_clear_marks() +{ + GC_apply_to_all_blocks(clear_marks_for_block, (word)0); + GC_objects_are_marked = FALSE; + GC_mark_state = MS_INVALID; + scan_ptr = 0; +# ifdef GATHERSTATS + /* Counters reflect currently marked objects: reset here */ + GC_composite_in_use = 0; + GC_atomic_in_use = 0; +# endif + +} + +/* Initiate a garbage collection. Initiates a full collection if the */ +/* mark state is invalid. */ +/*ARGSUSED*/ +void GC_initiate_gc() +{ + if (GC_dirty_maintained) GC_read_dirty(); +# ifdef STUBBORN_ALLOC + GC_read_changed(); +# endif +# ifdef CHECKSUMS + { + extern void GC_check_dirty(); + + if (GC_dirty_maintained) GC_check_dirty(); + } +# endif +# ifdef GATHERSTATS + GC_n_rescuing_pages = 0; +# endif + if (GC_mark_state == MS_NONE) { + GC_mark_state = MS_PUSH_RESCUERS; + } else if (GC_mark_state != MS_INVALID) { + ABORT("unexpected state"); + } /* else this is really a full collection, and mark */ + /* bits are invalid. */ + scan_ptr = 0; +} + + +static void alloc_mark_stack(); + +/* Perform a small amount of marking. */ +/* We try to touch roughly a page of memory. */ +/* Return TRUE if we just finished a mark phase. */ +/* Cold_gc_frame is an address inside a GC frame that */ +/* remains valid until all marking is complete. */ +/* A zero value indicates that it's OK to miss some */ +/* register values. */ +GC_bool GC_mark_some(cold_gc_frame) +ptr_t cold_gc_frame; +{ + switch(GC_mark_state) { + case MS_NONE: + return(FALSE); + + case MS_PUSH_RESCUERS: + if (GC_mark_stack_top + >= GC_mark_stack + INITIAL_MARK_STACK_SIZE/4) { + GC_mark_from_mark_stack(); + return(FALSE); + } else { + scan_ptr = GC_push_next_marked_dirty(scan_ptr); + if (scan_ptr == 0) { +# ifdef PRINTSTATS + GC_printf1("Marked from %lu dirty pages\n", + (unsigned long)GC_n_rescuing_pages); +# endif + GC_push_roots(FALSE, cold_gc_frame); + GC_objects_are_marked = TRUE; + if (GC_mark_state != MS_INVALID) { + GC_mark_state = MS_ROOTS_PUSHED; + } + } + } + return(FALSE); + + case MS_PUSH_UNCOLLECTABLE: + if (GC_mark_stack_top + >= GC_mark_stack + INITIAL_MARK_STACK_SIZE/4) { + GC_mark_from_mark_stack(); + return(FALSE); + } else { + scan_ptr = GC_push_next_marked_uncollectable(scan_ptr); + if (scan_ptr == 0) { + GC_push_roots(TRUE, cold_gc_frame); + GC_objects_are_marked = TRUE; + if (GC_mark_state != MS_INVALID) { + GC_mark_state = MS_ROOTS_PUSHED; + } + } + } + return(FALSE); + + case MS_ROOTS_PUSHED: + if (GC_mark_stack_top >= GC_mark_stack) { + GC_mark_from_mark_stack(); + return(FALSE); + } else { + GC_mark_state = MS_NONE; + if (GC_mark_stack_too_small) { + alloc_mark_stack(2*GC_mark_stack_size); + } + return(TRUE); + } + + case MS_INVALID: + case MS_PARTIALLY_INVALID: + if (!GC_objects_are_marked) { + GC_mark_state = MS_PUSH_UNCOLLECTABLE; + return(FALSE); + } + if (GC_mark_stack_top >= GC_mark_stack) { + GC_mark_from_mark_stack(); + return(FALSE); + } + if (scan_ptr == 0 && GC_mark_state == MS_INVALID) { + /* About to start a heap scan for marked objects. */ + /* Mark stack is empty. OK to reallocate. */ + if (GC_mark_stack_too_small) { + alloc_mark_stack(2*GC_mark_stack_size); + } + GC_mark_state = MS_PARTIALLY_INVALID; + } + scan_ptr = GC_push_next_marked(scan_ptr); + if (scan_ptr == 0 && GC_mark_state == MS_PARTIALLY_INVALID) { + GC_push_roots(TRUE, cold_gc_frame); + GC_objects_are_marked = TRUE; + if (GC_mark_state != MS_INVALID) { + GC_mark_state = MS_ROOTS_PUSHED; + } + } + return(FALSE); + default: + ABORT("GC_mark_some: bad state"); + return(FALSE); + } +} + + +GC_bool GC_mark_stack_empty() +{ + return(GC_mark_stack_top < GC_mark_stack); +} + +#ifdef PROF_MARKER + word GC_prof_array[10]; +# define PROF(n) GC_prof_array[n]++ +#else +# define PROF(n) +#endif + +/* Given a pointer to someplace other than a small object page or the */ +/* first page of a large object, return a pointer either to the */ +/* start of the large object or NIL. */ +/* In the latter case black list the address current. */ +/* Returns NIL without black listing if current points to a block */ +/* with IGNORE_OFF_PAGE set. */ +/*ARGSUSED*/ +# ifdef PRINT_BLACK_LIST + word GC_find_start(current, hhdr, source) + word source; +# else + word GC_find_start(current, hhdr) +# define source 0 +# endif +register word current; +register hdr * hhdr; +{ +# ifdef ALL_INTERIOR_POINTERS + if (hhdr != 0) { + register word orig = current; + + current = (word)HBLKPTR(current) + HDR_BYTES; + do { + current = current - HBLKSIZE*(word)hhdr; + hhdr = HDR(current); + } while(IS_FORWARDING_ADDR_OR_NIL(hhdr)); + /* current points to the start of the large object */ + if (hhdr -> hb_flags & IGNORE_OFF_PAGE) return(0); + if ((word *)orig - (word *)current + >= (ptrdiff_t)(hhdr->hb_sz)) { + /* Pointer past the end of the block */ + GC_ADD_TO_BLACK_LIST_NORMAL(orig, source); + return(0); + } + return(current); + } else { + GC_ADD_TO_BLACK_LIST_NORMAL(current, source); + return(0); + } +# else + GC_ADD_TO_BLACK_LIST_NORMAL(current, source); + return(0); +# endif +# undef source +} + +void GC_invalidate_mark_state() +{ + GC_mark_state = MS_INVALID; + GC_mark_stack_top = GC_mark_stack-1; +} + +mse * GC_signal_mark_stack_overflow(msp) +mse * msp; +{ + GC_mark_state = MS_INVALID; + GC_mark_stack_too_small = TRUE; +# ifdef PRINTSTATS + GC_printf1("Mark stack overflow; current size = %lu entries\n", + GC_mark_stack_size); +# endif + return(msp-INITIAL_MARK_STACK_SIZE/8); +} + + +/* + * Mark objects pointed to by the regions described by + * mark stack entries between GC_mark_stack and GC_mark_stack_top, + * inclusive. Assumes the upper limit of a mark stack entry + * is never 0. A mark stack entry never has size 0. + * We try to traverse on the order of a hblk of memory before we return. + * Caller is responsible for calling this until the mark stack is empty. + */ +void GC_mark_from_mark_stack() +{ + mse * GC_mark_stack_reg = GC_mark_stack; + mse * GC_mark_stack_top_reg = GC_mark_stack_top; + mse * mark_stack_limit = &(GC_mark_stack[GC_mark_stack_size]); + int credit = HBLKSIZE; /* Remaining credit for marking work */ + register word * current_p; /* Pointer to current candidate ptr. */ + register word current; /* Candidate pointer. */ + register word * limit; /* (Incl) limit of current candidate */ + /* range */ + register word descr; + register ptr_t greatest_ha = GC_greatest_plausible_heap_addr; + register ptr_t least_ha = GC_least_plausible_heap_addr; +# define SPLIT_RANGE_WORDS 128 /* Must be power of 2. */ + + GC_objects_are_marked = TRUE; +# ifdef OS2 /* Use untweaked version to circumvent compiler problem */ + while (GC_mark_stack_top_reg >= GC_mark_stack_reg && credit >= 0) { +# else + while ((((ptr_t)GC_mark_stack_top_reg - (ptr_t)GC_mark_stack_reg) | credit) + >= 0) { +# endif + current_p = GC_mark_stack_top_reg -> mse_start; + retry: + descr = GC_mark_stack_top_reg -> mse_descr; + if (descr & ((~(WORDS_TO_BYTES(SPLIT_RANGE_WORDS) - 1)) | DS_TAGS)) { + word tag = descr & DS_TAGS; + + switch(tag) { + case DS_LENGTH: + /* Large length. */ + /* Process part of the range to avoid pushing too much on the */ + /* stack. */ + GC_mark_stack_top_reg -> mse_start = + limit = current_p + SPLIT_RANGE_WORDS-1; + GC_mark_stack_top_reg -> mse_descr -= + WORDS_TO_BYTES(SPLIT_RANGE_WORDS-1); + /* Make sure that pointers overlapping the two ranges are */ + /* considered. */ + limit = (word *)((char *)limit + sizeof(word) - ALIGNMENT); + break; + case DS_BITMAP: + GC_mark_stack_top_reg--; + descr &= ~DS_TAGS; + credit -= WORDS_TO_BYTES(WORDSZ/2); /* guess */ + while (descr != 0) { + if ((signed_word)descr < 0) { + current = *current_p; + if ((ptr_t)current >= least_ha && (ptr_t)current < greatest_ha) { + PUSH_CONTENTS(current, GC_mark_stack_top_reg, mark_stack_limit, + current_p, exit1); + } + } + descr <<= 1; + ++ current_p; + } + continue; + case DS_PROC: + GC_mark_stack_top_reg--; + credit -= PROC_BYTES; + GC_mark_stack_top_reg = + (*PROC(descr)) + (current_p, GC_mark_stack_top_reg, + mark_stack_limit, ENV(descr)); + continue; + case DS_PER_OBJECT: + GC_mark_stack_top_reg -> mse_descr = + *(word *)((ptr_t)current_p + descr - tag); + goto retry; + } + } else { + GC_mark_stack_top_reg--; + limit = (word *)(((ptr_t)current_p) + (word)descr); + } + /* The simple case in which we're scanning a range. */ + credit -= (ptr_t)limit - (ptr_t)current_p; + limit -= 1; + while (current_p <= limit) { + current = *current_p; + if ((ptr_t)current >= least_ha && (ptr_t)current < greatest_ha) { + PUSH_CONTENTS(current, GC_mark_stack_top_reg, + mark_stack_limit, current_p, exit2); + } + current_p = (word *)((char *)current_p + ALIGNMENT); + } + } + GC_mark_stack_top = GC_mark_stack_top_reg; +} + +/* Allocate or reallocate space for mark stack of size s words */ +/* May silently fail. */ +static void alloc_mark_stack(n) +word n; +{ + mse * new_stack = (mse *)GC_scratch_alloc(n * sizeof(struct ms_entry)); + + GC_mark_stack_too_small = FALSE; + if (GC_mark_stack_size != 0) { + if (new_stack != 0) { + word displ = (word)GC_mark_stack & (GC_page_size - 1); + signed_word size = GC_mark_stack_size * sizeof(struct ms_entry); + + /* Recycle old space */ + if (0 != displ) displ = GC_page_size - displ; + size = (size - displ) & ~(GC_page_size - 1); + if (size > 0) { + GC_add_to_heap((struct hblk *) + ((word)GC_mark_stack + displ), (word)size); + } + GC_mark_stack = new_stack; + GC_mark_stack_size = n; +# ifdef PRINTSTATS + GC_printf1("Grew mark stack to %lu frames\n", + (unsigned long) GC_mark_stack_size); +# endif + } else { +# ifdef PRINTSTATS + GC_printf1("Failed to grow mark stack to %lu frames\n", + (unsigned long) n); +# endif + } + } else { + if (new_stack == 0) { + GC_err_printf0("No space for mark stack\n"); + EXIT(); + } + GC_mark_stack = new_stack; + GC_mark_stack_size = n; + } + GC_mark_stack_top = GC_mark_stack-1; +} + +void GC_mark_init() +{ + alloc_mark_stack(INITIAL_MARK_STACK_SIZE); +} + +/* + * Push all locations between b and t onto the mark stack. + * b is the first location to be checked. t is one past the last + * location to be checked. + * Should only be used if there is no possibility of mark stack + * overflow. + */ +void GC_push_all(bottom, top) +ptr_t bottom; +ptr_t top; +{ + register word length; + + bottom = (ptr_t)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1)); + top = (ptr_t)(((word) top) & ~(ALIGNMENT-1)); + if (top == 0 || bottom == top) return; + GC_mark_stack_top++; + if (GC_mark_stack_top >= GC_mark_stack + GC_mark_stack_size) { + ABORT("unexpected mark stack overflow"); + } + length = top - bottom; +# if DS_TAGS > ALIGNMENT - 1 + length += DS_TAGS; + length &= ~DS_TAGS; +# endif + GC_mark_stack_top -> mse_start = (word *)bottom; + GC_mark_stack_top -> mse_descr = length; +} + +/* + * Analogous to the above, but push only those pages that may have been + * dirtied. A block h is assumed dirty if dirty_fn(h) != 0. + * We use push_fn to actually push the block. + * Will not overflow mark stack if push_fn pushes a small fixed number + * of entries. (This is invoked only if push_fn pushes a single entry, + * or if it marks each object before pushing it, thus ensuring progress + * in the event of a stack overflow.) + */ +void GC_push_dirty(bottom, top, dirty_fn, push_fn) +ptr_t bottom; +ptr_t top; +int (*dirty_fn)(/* struct hblk * h */); +void (*push_fn)(/* ptr_t bottom, ptr_t top */); +{ + register struct hblk * h; + + bottom = (ptr_t)(((long) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1)); + top = (ptr_t)(((long) top) & ~(ALIGNMENT-1)); + + if (top == 0 || bottom == top) return; + h = HBLKPTR(bottom + HBLKSIZE); + if (top <= (ptr_t) h) { + if ((*dirty_fn)(h-1)) { + (*push_fn)(bottom, top); + } + return; + } + if ((*dirty_fn)(h-1)) { + (*push_fn)(bottom, (ptr_t)h); + } + while ((ptr_t)(h+1) <= top) { + if ((*dirty_fn)(h)) { + if ((word)(GC_mark_stack_top - GC_mark_stack) + > 3 * GC_mark_stack_size / 4) { + /* Danger of mark stack overflow */ + (*push_fn)((ptr_t)h, top); + return; + } else { + (*push_fn)((ptr_t)h, (ptr_t)(h+1)); + } + } + h++; + } + if ((ptr_t)h != top) { + if ((*dirty_fn)(h)) { + (*push_fn)((ptr_t)h, top); + } + } + if (GC_mark_stack_top >= GC_mark_stack + GC_mark_stack_size) { + ABORT("unexpected mark stack overflow"); + } +} + +# ifndef SMALL_CONFIG +void GC_push_conditional(bottom, top, all) +ptr_t bottom; +ptr_t top; +int all; +{ + if (all) { + if (GC_dirty_maintained) { +# ifdef PROC_VDB + /* Pages that were never dirtied cannot contain pointers */ + GC_push_dirty(bottom, top, GC_page_was_ever_dirty, GC_push_all); +# else + GC_push_all(bottom, top); +# endif + } else { + GC_push_all(bottom, top); + } + } else { + GC_push_dirty(bottom, top, GC_page_was_dirty, GC_push_all); + } +} +#endif + +# ifdef MSWIN32 + void __cdecl GC_push_one(p) +# else + void GC_push_one(p) +# endif +word p; +{ + GC_PUSH_ONE_STACK(p, 0); +} + +# ifdef __STDC__ +# define BASE(p) (word)GC_base((void *)(p)) +# else +# define BASE(p) (word)GC_base((char *)(p)) +# endif + +/* As above, but argument passed preliminary test. */ +# if defined(PRINT_BLACK_LIST) || defined(KEEP_BACK_PTRS) + void GC_push_one_checked(p, interior_ptrs, source) + ptr_t source; +# else + void GC_push_one_checked(p, interior_ptrs) +# define source 0 +# endif +register word p; +register GC_bool interior_ptrs; +{ + register word r; + register hdr * hhdr; + register int displ; + + GET_HDR(p, hhdr); + if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + if (hhdr != 0 && interior_ptrs) { + r = BASE(p); + hhdr = HDR(r); + displ = BYTES_TO_WORDS(HBLKDISPL(r)); + } else { + hhdr = 0; + } + } else { + register map_entry_type map_entry; + + displ = HBLKDISPL(p); + map_entry = MAP_ENTRY((hhdr -> hb_map), displ); + if (map_entry == OBJ_INVALID) { +# ifndef ALL_INTERIOR_POINTERS + if (interior_ptrs) { + r = BASE(p); + displ = BYTES_TO_WORDS(HBLKDISPL(r)); + if (r == 0) hhdr = 0; + } else { + hhdr = 0; + } +# else + /* map already reflects interior pointers */ + hhdr = 0; +# endif + } else { + displ = BYTES_TO_WORDS(displ); + displ -= map_entry; + r = (word)((word *)(HBLKPTR(p)) + displ); + } + } + /* If hhdr != 0 then r == GC_base(p), only we did it faster. */ + /* displ is the word index within the block. */ + if (hhdr == 0) { + if (interior_ptrs) { +# ifdef PRINT_BLACK_LIST + GC_add_to_black_list_stack(p, source); +# else + GC_add_to_black_list_stack(p); +# endif + } else { + GC_ADD_TO_BLACK_LIST_NORMAL(p, source); +# undef source /* In case we had to define it. */ + } + } else { + if (!mark_bit_from_hdr(hhdr, displ)) { + set_mark_bit_from_hdr(hhdr, displ); + GC_STORE_BACK_PTR(source, (ptr_t)r); + PUSH_OBJ((word *)r, hhdr, GC_mark_stack_top, + &(GC_mark_stack[GC_mark_stack_size])); + } + } +} + +# ifdef TRACE_BUF + +# define TRACE_ENTRIES 1000 + +struct trace_entry { + char * kind; + word gc_no; + word words_allocd; + word arg1; + word arg2; +} GC_trace_buf[TRACE_ENTRIES]; + +int GC_trace_buf_ptr = 0; + +void GC_add_trace_entry(char *kind, word arg1, word arg2) +{ + GC_trace_buf[GC_trace_buf_ptr].kind = kind; + GC_trace_buf[GC_trace_buf_ptr].gc_no = GC_gc_no; + GC_trace_buf[GC_trace_buf_ptr].words_allocd = GC_words_allocd; + GC_trace_buf[GC_trace_buf_ptr].arg1 = arg1 ^ 0x80000000; + GC_trace_buf[GC_trace_buf_ptr].arg2 = arg2 ^ 0x80000000; + GC_trace_buf_ptr++; + if (GC_trace_buf_ptr >= TRACE_ENTRIES) GC_trace_buf_ptr = 0; +} + +void GC_print_trace(word gc_no, GC_bool lock) +{ + int i; + struct trace_entry *p; + + if (lock) LOCK(); + for (i = GC_trace_buf_ptr-1; i != GC_trace_buf_ptr; i--) { + if (i < 0) i = TRACE_ENTRIES-1; + p = GC_trace_buf + i; + if (p -> gc_no < gc_no || p -> kind == 0) return; + printf("Trace:%s (gc:%d,words:%d) 0x%X, 0x%X\n", + p -> kind, p -> gc_no, p -> words_allocd, + (p -> arg1) ^ 0x80000000, (p -> arg2) ^ 0x80000000); + } + printf("Trace incomplete\n"); + if (lock) UNLOCK(); +} + +# endif /* TRACE_BUF */ + +/* + * A version of GC_push_all that treats all interior pointers as valid + * and scans the entire region immediately, in case the contents + * change. + */ +void GC_push_all_eager(bottom, top) +ptr_t bottom; +ptr_t top; +{ + word * b = (word *)(((long) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1)); + word * t = (word *)(((long) top) & ~(ALIGNMENT-1)); + register word *p; + register word q; + register word *lim; + register ptr_t greatest_ha = GC_greatest_plausible_heap_addr; + register ptr_t least_ha = GC_least_plausible_heap_addr; +# define GC_greatest_plausible_heap_addr greatest_ha +# define GC_least_plausible_heap_addr least_ha + + if (top == 0) return; + /* check all pointers in range and put in push if they appear */ + /* to be valid. */ + lim = t - 1 /* longword */; + for (p = b; p <= lim; p = (word *)(((char *)p) + ALIGNMENT)) { + q = *p; + GC_PUSH_ONE_STACK(q, p); + } +# undef GC_greatest_plausible_heap_addr +# undef GC_least_plausible_heap_addr +} + +#ifndef THREADS +/* + * A version of GC_push_all that treats all interior pointers as valid + * and scans part of the area immediately, to make sure that saved + * register values are not lost. + * Cold_gc_frame delimits the stack section that must be scanned + * eagerly. A zero value indicates that no eager scanning is needed. + */ +void GC_push_all_stack_partially_eager(bottom, top, cold_gc_frame) +ptr_t bottom; +ptr_t top; +ptr_t cold_gc_frame; +{ +# ifdef ALL_INTERIOR_POINTERS +# define EAGER_BYTES 1024 + /* Push the hot end of the stack eagerly, so that register values */ + /* saved inside GC frames are marked before they disappear. */ + /* The rest of the marking can be deferred until later. */ + if (0 == cold_gc_frame) { + GC_push_all_stack(bottom, top); + return; + } +# ifdef STACK_GROWS_DOWN + GC_push_all_eager(bottom, cold_gc_frame); + GC_push_all(cold_gc_frame - sizeof(ptr_t), top); +# else /* STACK_GROWS_UP */ + GC_push_all_eager(cold_gc_frame, top); + GC_push_all(bottom, cold_gc_frame + sizeof(ptr_t)); +# endif /* STACK_GROWS_UP */ +# else + GC_push_all_eager(bottom, top); +# endif +# ifdef TRACE_BUF + GC_add_trace_entry("GC_push_all_stack", bottom, top); +# endif +} +#endif /* !THREADS */ + +void GC_push_all_stack(bottom, top) +ptr_t bottom; +ptr_t top; +{ +# ifdef ALL_INTERIOR_POINTERS + GC_push_all(bottom, top); +# else + GC_push_all_eager(bottom, top); +# endif +} + +#ifndef SMALL_CONFIG +/* Push all objects reachable from marked objects in the given block */ +/* of size 1 objects. */ +void GC_push_marked1(h, hhdr) +struct hblk *h; +register hdr * hhdr; +{ + word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p; + word *plim; + register int i; + register word q; + register word mark_word; + register ptr_t greatest_ha = GC_greatest_plausible_heap_addr; + register ptr_t least_ha = GC_least_plausible_heap_addr; +# define GC_greatest_plausible_heap_addr greatest_ha +# define GC_least_plausible_heap_addr least_ha + + p = (word *)(h->hb_body); + plim = (word *)(((word)h) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + i = 0; + while(mark_word != 0) { + if (mark_word & 1) { + q = p[i]; + GC_PUSH_ONE_HEAP(q, p + i); + } + i++; + mark_word >>= 1; + } + p += WORDSZ; + } +# undef GC_greatest_plausible_heap_addr +# undef GC_least_plausible_heap_addr +} + + +#ifndef UNALIGNED + +/* Push all objects reachable from marked objects in the given block */ +/* of size 2 objects. */ +void GC_push_marked2(h, hhdr) +struct hblk *h; +register hdr * hhdr; +{ + word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p; + word *plim; + register int i; + register word q; + register word mark_word; + register ptr_t greatest_ha = GC_greatest_plausible_heap_addr; + register ptr_t least_ha = GC_least_plausible_heap_addr; +# define GC_greatest_plausible_heap_addr greatest_ha +# define GC_least_plausible_heap_addr least_ha + + p = (word *)(h->hb_body); + plim = (word *)(((word)h) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + i = 0; + while(mark_word != 0) { + if (mark_word & 1) { + q = p[i]; + GC_PUSH_ONE_HEAP(q, p + i); + q = p[i+1]; + GC_PUSH_ONE_HEAP(q, p + i); + } + i += 2; + mark_word >>= 2; + } + p += WORDSZ; + } +# undef GC_greatest_plausible_heap_addr +# undef GC_least_plausible_heap_addr +} + +/* Push all objects reachable from marked objects in the given block */ +/* of size 4 objects. */ +/* There is a risk of mark stack overflow here. But we handle that. */ +/* And only unmarked objects get pushed, so it's not very likely. */ +void GC_push_marked4(h, hhdr) +struct hblk *h; +register hdr * hhdr; +{ + word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p; + word *plim; + register int i; + register word q; + register word mark_word; + register ptr_t greatest_ha = GC_greatest_plausible_heap_addr; + register ptr_t least_ha = GC_least_plausible_heap_addr; +# define GC_greatest_plausible_heap_addr greatest_ha +# define GC_least_plausible_heap_addr least_ha + + p = (word *)(h->hb_body); + plim = (word *)(((word)h) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + i = 0; + while(mark_word != 0) { + if (mark_word & 1) { + q = p[i]; + GC_PUSH_ONE_HEAP(q, p + i); + q = p[i+1]; + GC_PUSH_ONE_HEAP(q, p + i + 1); + q = p[i+2]; + GC_PUSH_ONE_HEAP(q, p + i + 2); + q = p[i+3]; + GC_PUSH_ONE_HEAP(q, p + i + 3); + } + i += 4; + mark_word >>= 4; + } + p += WORDSZ; + } +# undef GC_greatest_plausible_heap_addr +# undef GC_least_plausible_heap_addr +} + +#endif /* UNALIGNED */ + +#endif /* SMALL_CONFIG */ + +/* Push all objects reachable from marked objects in the given block */ +void GC_push_marked(h, hhdr) +struct hblk *h; +register hdr * hhdr; +{ + register int sz = hhdr -> hb_sz; + register word * p; + register int word_no; + register word * lim; + register mse * GC_mark_stack_top_reg; + register mse * mark_stack_limit = &(GC_mark_stack[GC_mark_stack_size]); + + /* Some quick shortcuts: */ + { + struct obj_kind *ok = &(GC_obj_kinds[hhdr -> hb_obj_kind]); + if ((0 | DS_LENGTH) == ok -> ok_descriptor + && FALSE == ok -> ok_relocate_descr) + return; + } + if (GC_block_empty(hhdr)/* nothing marked */) return; +# ifdef GATHERSTATS + GC_n_rescuing_pages++; +# endif + GC_objects_are_marked = TRUE; + if (sz > MAXOBJSZ) { + lim = (word *)(h + 1); + } else { + lim = (word *)(h + 1) - sz; + } + + switch(sz) { +# if !defined(SMALL_CONFIG) + case 1: + GC_push_marked1(h, hhdr); + break; +# endif +# if !defined(SMALL_CONFIG) && !defined(UNALIGNED) + case 2: + GC_push_marked2(h, hhdr); + break; + case 4: + GC_push_marked4(h, hhdr); + break; +# endif + default: + GC_mark_stack_top_reg = GC_mark_stack_top; + for (p = (word *)h + HDR_WORDS, word_no = HDR_WORDS; p <= lim; + p += sz, word_no += sz) { + /* This ignores user specified mark procs. This currently */ + /* doesn't matter, since marking from the whole object */ + /* is always sufficient, and we will eventually use the user */ + /* mark proc to avoid any bogus pointers. */ + if (mark_bit_from_hdr(hhdr, word_no)) { + /* Mark from fields inside the object */ + PUSH_OBJ((word *)p, hhdr, GC_mark_stack_top_reg, mark_stack_limit); +# ifdef GATHERSTATS + /* Subtract this object from total, since it was */ + /* added in twice. */ + GC_composite_in_use -= sz; +# endif + } + } + GC_mark_stack_top = GC_mark_stack_top_reg; + } +} + +#ifndef SMALL_CONFIG +/* Test whether any page in the given block is dirty */ +GC_bool GC_block_was_dirty(h, hhdr) +struct hblk *h; +register hdr * hhdr; +{ + register int sz = hhdr -> hb_sz; + + if (sz < MAXOBJSZ) { + return(GC_page_was_dirty(h)); + } else { + register ptr_t p = (ptr_t)h; + sz += HDR_WORDS; + sz = WORDS_TO_BYTES(sz); + while (p < (ptr_t)h + sz) { + if (GC_page_was_dirty((struct hblk *)p)) return(TRUE); + p += HBLKSIZE; + } + return(FALSE); + } +} +#endif /* SMALL_CONFIG */ + +/* Similar to GC_push_next_marked, but return address of next block */ +struct hblk * GC_push_next_marked(h) +struct hblk *h; +{ + register hdr * hhdr; + + h = GC_next_used_block(h); + if (h == 0) return(0); + hhdr = HDR(h); + GC_push_marked(h, hhdr); + return(h + OBJ_SZ_TO_BLOCKS(hhdr -> hb_sz)); +} + +#ifndef SMALL_CONFIG +/* Identical to above, but mark only from dirty pages */ +struct hblk * GC_push_next_marked_dirty(h) +struct hblk *h; +{ + register hdr * hhdr = HDR(h); + + if (!GC_dirty_maintained) { ABORT("dirty bits not set up"); } + for (;;) { + h = GC_next_used_block(h); + if (h == 0) return(0); + hhdr = HDR(h); +# ifdef STUBBORN_ALLOC + if (hhdr -> hb_obj_kind == STUBBORN) { + if (GC_page_was_changed(h) && GC_block_was_dirty(h, hhdr)) { + break; + } + } else { + if (GC_block_was_dirty(h, hhdr)) break; + } +# else + if (GC_block_was_dirty(h, hhdr)) break; +# endif + h += OBJ_SZ_TO_BLOCKS(hhdr -> hb_sz); + } + GC_push_marked(h, hhdr); + return(h + OBJ_SZ_TO_BLOCKS(hhdr -> hb_sz)); +} +#endif + +/* Similar to above, but for uncollectable pages. Needed since we */ +/* do not clear marks for such pages, even for full collections. */ +struct hblk * GC_push_next_marked_uncollectable(h) +struct hblk *h; +{ + register hdr * hhdr = HDR(h); + + for (;;) { + h = GC_next_used_block(h); + if (h == 0) return(0); + hhdr = HDR(h); + if (hhdr -> hb_obj_kind == UNCOLLECTABLE) break; + h += OBJ_SZ_TO_BLOCKS(hhdr -> hb_sz); + } + GC_push_marked(h, hhdr); + return(h + OBJ_SZ_TO_BLOCKS(hhdr -> hb_sz)); +} + + diff --git a/support/gc/mark_rts.c b/support/gc/mark_rts.c new file mode 100644 index 00000000..2f21ed32 --- /dev/null +++ b/support/gc/mark_rts.c @@ -0,0 +1,484 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, October 9, 1995 1:06 pm PDT */ +# include +# include "gc_priv.h" + +/* Data structure for list of root sets. */ +/* We keep a hash table, so that we can filter out duplicate additions. */ +/* Under Win32, we need to do a better job of filtering overlaps, so */ +/* we resort to sequential search, and pay the price. */ +/* This is really declared in gc_priv.h: +struct roots { + ptr_t r_start; + ptr_t r_end; + # ifndef MSWIN32 + struct roots * r_next; + # endif + GC_bool r_tmp; + -- Delete before registering new dynamic libraries +}; + +struct roots GC_static_roots[MAX_ROOT_SETS]; +*/ + +static int n_root_sets = 0; + + /* GC_static_roots[0..n_root_sets) contains the valid root sets. */ + +# if !defined(NO_DEBUGGING) +/* For debugging: */ +void GC_print_static_roots() +{ + register int i; + size_t total = 0; + + for (i = 0; i < n_root_sets; i++) { + GC_printf2("From 0x%lx to 0x%lx ", + (unsigned long) GC_static_roots[i].r_start, + (unsigned long) GC_static_roots[i].r_end); + if (GC_static_roots[i].r_tmp) { + GC_printf0(" (temporary)\n"); + } else { + GC_printf0("\n"); + } + total += GC_static_roots[i].r_end - GC_static_roots[i].r_start; + } + GC_printf1("Total size: %ld\n", (unsigned long) total); + if (GC_root_size != total) { + GC_printf1("GC_root_size incorrect: %ld!!\n", + (unsigned long) GC_root_size); + } +} +# endif /* NO_DEBUGGING */ + +/* Primarily for debugging support: */ +/* Is the address p in one of the registered static */ +/* root sections? */ +GC_bool GC_is_static_root(p) +ptr_t p; +{ + static int last_root_set = 0; + register int i; + + + if (p >= GC_static_roots[last_root_set].r_start + && p < GC_static_roots[last_root_set].r_end) return(TRUE); + for (i = 0; i < n_root_sets; i++) { + if (p >= GC_static_roots[i].r_start + && p < GC_static_roots[i].r_end) { + last_root_set = i; + return(TRUE); + } + } + return(FALSE); +} + +#ifndef MSWIN32 +/* +# define LOG_RT_SIZE 6 +# define RT_SIZE (1 << LOG_RT_SIZE) -- Power of 2, may be != MAX_ROOT_SETS + + struct roots * GC_root_index[RT_SIZE]; + -- Hash table header. Used only to check whether a range is + -- already present. + -- really defined in gc_priv.h +*/ + +static int rt_hash(addr) +char * addr; +{ + word result = (word) addr; +# if CPP_WORDSZ > 8*LOG_RT_SIZE + result ^= result >> 8*LOG_RT_SIZE; +# endif +# if CPP_WORDSZ > 4*LOG_RT_SIZE + result ^= result >> 4*LOG_RT_SIZE; +# endif + result ^= result >> 2*LOG_RT_SIZE; + result ^= result >> LOG_RT_SIZE; + result &= (RT_SIZE-1); + return(result); +} + +/* Is a range starting at b already in the table? If so return a */ +/* pointer to it, else NIL. */ +struct roots * GC_roots_present(b) +char *b; +{ + register int h = rt_hash(b); + register struct roots *p = GC_root_index[h]; + + while (p != 0) { + if (p -> r_start == (ptr_t)b) return(p); + p = p -> r_next; + } + return(FALSE); +} + +/* Add the given root structure to the index. */ +static void add_roots_to_index(p) +struct roots *p; +{ + register int h = rt_hash(p -> r_start); + + p -> r_next = GC_root_index[h]; + GC_root_index[h] = p; +} + +# else /* MSWIN32 */ + +# define add_roots_to_index(p) + +# endif + + + + +word GC_root_size = 0; + +void GC_add_roots(b, e) +char * b; char * e; +{ + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + GC_add_roots_inner(b, e, FALSE); + UNLOCK(); + ENABLE_SIGNALS(); +} + + +/* Add [b,e) to the root set. Adding the same interval a second time */ +/* is a moderately fast noop, and hence benign. We do not handle */ +/* different but overlapping intervals efficiently. (We do handle */ +/* them correctly.) */ +/* Tmp specifies that the interval may be deleted before */ +/* reregistering dynamic libraries. */ +void GC_add_roots_inner(b, e, tmp) +char * b; char * e; +GC_bool tmp; +{ + struct roots * old; + +# ifdef MSWIN32 + /* Spend the time to ensure that there are no overlapping */ + /* or adjacent intervals. */ + /* This could be done faster with e.g. a */ + /* balanced tree. But the execution time here is */ + /* virtually guaranteed to be dominated by the time it */ + /* takes to scan the roots. */ + { + register int i; + + for (i = 0; i < n_root_sets; i++) { + old = GC_static_roots + i; + if ((ptr_t)b <= old -> r_end && (ptr_t)e >= old -> r_start) { + if ((ptr_t)b < old -> r_start) { + old -> r_start = (ptr_t)b; + GC_root_size += (old -> r_start - (ptr_t)b); + } + if ((ptr_t)e > old -> r_end) { + old -> r_end = (ptr_t)e; + GC_root_size += ((ptr_t)e - old -> r_end); + } + old -> r_tmp &= tmp; + break; + } + } + if (i < n_root_sets) { + /* merge other overlapping intervals */ + struct roots *other; + + for (i++; i < n_root_sets; i++) { + other = GC_static_roots + i; + b = (char *)(other -> r_start); + e = (char *)(other -> r_end); + if ((ptr_t)b <= old -> r_end && (ptr_t)e >= old -> r_start) { + if ((ptr_t)b < old -> r_start) { + old -> r_start = (ptr_t)b; + GC_root_size += (old -> r_start - (ptr_t)b); + } + if ((ptr_t)e > old -> r_end) { + old -> r_end = (ptr_t)e; + GC_root_size += ((ptr_t)e - old -> r_end); + } + old -> r_tmp &= other -> r_tmp; + /* Delete this entry. */ + GC_root_size -= (other -> r_end - other -> r_start); + other -> r_start = GC_static_roots[n_root_sets-1].r_start; + other -> r_end = GC_static_roots[n_root_sets-1].r_end; + n_root_sets--; + } + } + return; + } + } +# else + old = GC_roots_present(b); + if (old != 0) { + if ((ptr_t)e <= old -> r_end) /* already there */ return; + /* else extend */ + GC_root_size += (ptr_t)e - old -> r_end; + old -> r_end = (ptr_t)e; + return; + } +# endif + if (n_root_sets == MAX_ROOT_SETS) { + ABORT("Too many root sets\n"); + } + GC_static_roots[n_root_sets].r_start = (ptr_t)b; + GC_static_roots[n_root_sets].r_end = (ptr_t)e; + GC_static_roots[n_root_sets].r_tmp = tmp; +# ifndef MSWIN32 + GC_static_roots[n_root_sets].r_next = 0; +# endif + add_roots_to_index(GC_static_roots + n_root_sets); + GC_root_size += (ptr_t)e - (ptr_t)b; + n_root_sets++; +} + +void GC_clear_roots GC_PROTO((void)) +{ + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + n_root_sets = 0; + GC_root_size = 0; +# ifndef MSWIN32 + { + register int i; + + for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0; + } +# endif + UNLOCK(); + ENABLE_SIGNALS(); +} + +/* Internal use only; lock held. */ +void GC_remove_tmp_roots() +{ + register int i; + + for (i = 0; i < n_root_sets; ) { + if (GC_static_roots[i].r_tmp) { + GC_root_size -= + (GC_static_roots[i].r_end - GC_static_roots[i].r_start); + GC_static_roots[i].r_start = GC_static_roots[n_root_sets-1].r_start; + GC_static_roots[i].r_end = GC_static_roots[n_root_sets-1].r_end; + GC_static_roots[i].r_tmp = GC_static_roots[n_root_sets-1].r_tmp; + n_root_sets--; + } else { + i++; + } + } +# ifndef MSWIN32 + { + register int i; + + for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0; + for (i = 0; i < n_root_sets; i++) + add_roots_to_index(GC_static_roots + i); + } +# endif + +} + +ptr_t GC_approx_sp() +{ + word dummy; + + return((ptr_t)(&dummy)); +} + +/* + * Data structure for excluded static roots. + * Real declaration is in gc_priv.h. + +struct exclusion { + ptr_t e_start; + ptr_t e_end; +}; + +struct exclusion GC_excl_table[MAX_EXCLUSIONS]; + -- Array of exclusions, ascending + -- address order. +*/ + +size_t GC_excl_table_entries = 0; /* Number of entries in use. */ + +/* Return the first exclusion range that includes an address >= start_addr */ +/* Assumes the exclusion table contains at least one entry (namely the */ +/* GC data structures). */ +struct exclusion * GC_next_exclusion(start_addr) +ptr_t start_addr; +{ + size_t low = 0; + size_t high = GC_excl_table_entries - 1; + size_t mid; + + while (high > low) { + mid = (low + high) >> 1; + /* low <= mid < high */ + if ((word) GC_excl_table[mid].e_end <= (word) start_addr) { + low = mid + 1; + } else { + high = mid; + } + } + if ((word) GC_excl_table[low].e_end <= (word) start_addr) return 0; + return GC_excl_table + low; +} + +void GC_exclude_static_roots(start, finish) +GC_PTR start; +GC_PTR finish; +{ + struct exclusion * next; + size_t next_index, i; + + if (0 == GC_excl_table_entries) { + next = 0; + } else { + next = GC_next_exclusion(start); + } + if (0 != next) { + if ((word)(next -> e_start) < (word) finish) { + /* incomplete error check. */ + ABORT("exclusion ranges overlap"); + } + if ((word)(next -> e_start) == (word) finish) { + /* extend old range backwards */ + next -> e_start = (ptr_t)start; + return; + } + next_index = next - GC_excl_table; + for (i = GC_excl_table_entries; i > next_index; --i) { + GC_excl_table[i] = GC_excl_table[i-1]; + } + } else { + next_index = GC_excl_table_entries; + } + if (GC_excl_table_entries == MAX_EXCLUSIONS) ABORT("Too many exclusions"); + GC_excl_table[next_index].e_start = (ptr_t)start; + GC_excl_table[next_index].e_end = (ptr_t)finish; + ++GC_excl_table_entries; +} + +/* Invoke push_conditional on ranges that are not excluded. */ +void GC_push_conditional_with_exclusions(bottom, top, all) +ptr_t bottom; +ptr_t top; +int all; +{ + struct exclusion * next; + ptr_t excl_start; + + while (bottom < top) { + next = GC_next_exclusion(bottom); + if (0 == next || (excl_start = next -> e_start) >= top) { + GC_push_conditional(bottom, top, all); + return; + } + if (excl_start > bottom) GC_push_conditional(bottom, excl_start, all); + bottom = next -> e_end; + } +} + +/* + * In the absence of threads, push the stack contents. + * In the presence of threads, push enough of the current stack + * to ensure that callee-save registers saved in collector frames have been + * seen. + */ +void GC_push_current_stack(cold_gc_frame) +ptr_t cold_gc_frame; +{ +# if defined(THREADS) + if (0 == cold_gc_frame) return; +# ifdef STACK_GROWS_DOWN + GC_push_all_eager(GC_approx_sp(), cold_gc_frame); +# else + GC_push_all_eager( cold_gc_frame, GC_approx_sp() ); +# endif +# else +# ifdef STACK_GROWS_DOWN + GC_push_all_stack_partially_eager( GC_approx_sp(), GC_stackbottom, + cold_gc_frame ); +# else + GC_push_all_stack_partially_eager( GC_stackbottom, GC_approx_sp(), + cold_gc_frame ); +# endif +# endif /* !THREADS */ +} + +/* + * Call the mark routines (GC_tl_push for a single pointer, GC_push_conditional + * on groups of pointers) on every top level accessible pointer. + * If all is FALSE, arrange to push only possibly altered values. + * Cold_gc_frame is an address inside a GC frame that + * remains valid until all marking is complete. + * A zero value indicates that it's OK to miss some + * register values. + */ +void GC_push_roots(all, cold_gc_frame) +GC_bool all; +ptr_t cold_gc_frame; +{ + register int i; + + /* + * push registers - i.e., call GC_push_one(r) for each + * register contents r. + */ +# ifdef USE_GENERIC_PUSH_REGS + GC_generic_push_regs(cold_gc_frame); +# else + GC_push_regs(); /* usually defined in machine_dep.c */ +# endif + + /* + * Next push static data. This must happen early on, since it's + * not robust against mark stack overflow. + */ + /* Reregister dynamic libraries, in case one got added. */ +# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \ + && !defined(SRC_M3) + GC_remove_tmp_roots(); + GC_register_dynamic_libraries(); +# endif + /* Mark everything in static data areas */ + for (i = 0; i < n_root_sets; i++) { + GC_push_conditional_with_exclusions( + GC_static_roots[i].r_start, + GC_static_roots[i].r_end, all); + } + + /* + * Now traverse stacks. + */ +# if !defined(USE_GENERIC_PUSH_REGS) + GC_push_current_stack(cold_gc_frame); + /* IN the threads case, this only pushes collector frames. */ + /* In the USE_GENERIC_PUSH_REGS case, this is done inside */ + /* GC_push_regs, so that we catch callee-save registers saved */ + /* inside the GC_push_regs frame. */ +# endif + if (GC_push_other_roots != 0) (*GC_push_other_roots)(); + /* In the threads case, this also pushes thread stacks. */ +} + diff --git a/support/gc/mips_sgi_mach_dep.s b/support/gc/mips_sgi_mach_dep.s new file mode 100644 index 00000000..03c4b980 --- /dev/null +++ b/support/gc/mips_sgi_mach_dep.s @@ -0,0 +1,40 @@ +#include +#include + +# define call_push(x) move $4,x; jal GC_push_one + + .text +/* Mark from machine registers that are saved by C compiler */ +# define FRAMESZ 32 +# define RAOFF FRAMESZ-SZREG +# define GPOFF FRAMESZ-(2*SZREG) + NESTED(GC_push_regs, FRAMESZ, ra) + .mask 0x80000000,-SZREG # inform debugger of saved ra loc + move t0,gp + SETUP_GPX(t8) + PTR_SUBU sp,FRAMESZ +# ifdef SETUP_GP64 + SETUP_GP64(GPOFF, GC_push_regs) +# endif + SAVE_GP(GPOFF) + REG_S ra,RAOFF(sp) +# if (_MIPS_SIM == _MIPS_SIM_ABI32) + call_push($2) + call_push($3) +# endif + call_push($16) + call_push($17) + call_push($18) + call_push($19) + call_push($20) + call_push($21) + call_push($22) + call_push($23) + call_push($30) + REG_L ra,RAOFF(sp) +# ifdef RESTORE_GP64 + RESTORE_GP64 +# endif + PTR_ADDU sp,FRAMESZ + j ra + .end GC_push_regs diff --git a/support/gc/mips_ultrix_mach_dep.s b/support/gc/mips_ultrix_mach_dep.s new file mode 100644 index 00000000..178224e3 --- /dev/null +++ b/support/gc/mips_ultrix_mach_dep.s @@ -0,0 +1,26 @@ +# define call_push(x) move $4,x; jal GC_push_one + + .text + # Mark from machine registers that are saved by C compiler + .globl GC_push_regs + .ent GC_push_regs +GC_push_regs: + subu $sp,8 ## Need to save only return address + sw $31,4($sp) + .mask 0x80000000,-4 + .frame $sp,8,$31 + call_push($2) + call_push($3) + call_push($16) + call_push($17) + call_push($18) + call_push($19) + call_push($20) + call_push($21) + call_push($22) + call_push($23) + call_push($30) + lw $31,4($sp) + addu $sp,8 + j $31 + .end GC_push_regs diff --git a/support/gc/misc.c b/support/gc/misc.c new file mode 100644 index 00000000..c3fce63d --- /dev/null +++ b/support/gc/misc.c @@ -0,0 +1,828 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, July 31, 1995 5:02 pm PDT */ + + +#include +#include + +#define I_HIDE_POINTERS /* To make GC_call_with_alloc_lock visible */ +#include "gc_priv.h" + +#ifdef SOLARIS_THREADS +# include +#endif +#ifdef MSWIN32 +# include +#endif + +# ifdef THREADS +# ifdef PCR +# include "il/PCR_IL.h" + PCR_Th_ML GC_allocate_ml; +# else +# ifdef SRC_M3 + /* Critical section counter is defined in the M3 runtime */ + /* That's all we use. */ +# else +# ifdef SOLARIS_THREADS + mutex_t GC_allocate_ml; /* Implicitly initialized. */ +# else +# ifdef WIN32_THREADS + GC_API CRITICAL_SECTION GC_allocate_ml; +# else +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \ + || defined(IRIX_JDK_THREADS) +# ifdef UNDEFINED + pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER; +# endif + pthread_t GC_lock_holder = NO_THREAD; +# else + --> declare allocator lock here +# endif +# endif +# endif +# endif +# endif +# endif + +GC_FAR struct _GC_arrays GC_arrays /* = { 0 } */; + + +GC_bool GC_debugging_started = FALSE; + /* defined here so we don't have to load debug_malloc.o */ + +void (*GC_check_heap)() = (void (*)())0; + +void (*GC_start_call_back)() = (void (*)())0; + +ptr_t GC_stackbottom = 0; + +GC_bool GC_dont_gc = 0; + +GC_bool GC_quiet = 0; + +#ifdef FIND_LEAK + int GC_find_leak = 1; +#else + int GC_find_leak = 0; +#endif + +/*ARGSUSED*/ +GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested)) +{ + return(0); +} + +GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested)) = GC_default_oom_fn; + +extern signed_word GC_mem_found; + +# ifdef MERGE_SIZES + /* Set things up so that GC_size_map[i] >= words(i), */ + /* but not too much bigger */ + /* and so that size_map contains relatively few distinct entries */ + /* This is stolen from Russ Atkinson's Cedar quantization */ + /* alogrithm (but we precompute it). */ + + + void GC_init_size_map() + { + register unsigned i; + + /* Map size 0 to 1. This avoids problems at lower levels. */ + GC_size_map[0] = 1; + /* One word objects don't have to be 2 word aligned. */ + for (i = 1; i < sizeof(word); i++) { + GC_size_map[i] = 1; + } + GC_size_map[sizeof(word)] = ROUNDED_UP_WORDS(sizeof(word)); + for (i = sizeof(word) + 1; i <= 8 * sizeof(word); i++) { +# ifdef ALIGN_DOUBLE + GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1); +# else + GC_size_map[i] = ROUNDED_UP_WORDS(i); +# endif + } + for (i = 8*sizeof(word) + 1; i <= 16 * sizeof(word); i++) { + GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1); + } + /* We leave the rest of the array to be filled in on demand. */ + } + + /* Fill in additional entries in GC_size_map, including the ith one */ + /* We assume the ith entry is currently 0. */ + /* Note that a filled in section of the array ending at n always */ + /* has length at least n/4. */ + void GC_extend_size_map(i) + word i; + { + word orig_word_sz = ROUNDED_UP_WORDS(i); + word word_sz = orig_word_sz; + register word byte_sz = WORDS_TO_BYTES(word_sz); + /* The size we try to preserve. */ + /* Close to to i, unless this would */ + /* introduce too many distinct sizes. */ + word smaller_than_i = byte_sz - (byte_sz >> 3); + word much_smaller_than_i = byte_sz - (byte_sz >> 2); + register word low_limit; /* The lowest indexed entry we */ + /* initialize. */ + register word j; + + if (GC_size_map[smaller_than_i] == 0) { + low_limit = much_smaller_than_i; + while (GC_size_map[low_limit] != 0) low_limit++; + } else { + low_limit = smaller_than_i + 1; + while (GC_size_map[low_limit] != 0) low_limit++; + word_sz = ROUNDED_UP_WORDS(low_limit); + word_sz += word_sz >> 3; + if (word_sz < orig_word_sz) word_sz = orig_word_sz; + } +# ifdef ALIGN_DOUBLE + word_sz += 1; + word_sz &= ~1; +# endif + if (word_sz > MAXOBJSZ) { + word_sz = MAXOBJSZ; + } + /* If we can fit the same number of larger objects in a block, */ + /* do so. */ + { + size_t number_of_objs = BODY_SZ/word_sz; + word_sz = BODY_SZ/number_of_objs; +# ifdef ALIGN_DOUBLE + word_sz &= ~1; +# endif + } + byte_sz = WORDS_TO_BYTES(word_sz); +# ifdef ADD_BYTE_AT_END + /* We need one extra byte; don't fill in GC_size_map[byte_sz] */ + byte_sz--; +# endif + + for (j = low_limit; j <= byte_sz; j++) GC_size_map[j] = word_sz; + } +# endif + + +/* + * The following is a gross hack to deal with a problem that can occur + * on machines that are sloppy about stack frame sizes, notably SPARC. + * Bogus pointers may be written to the stack and not cleared for + * a LONG time, because they always fall into holes in stack frames + * that are not written. We partially address this by clearing + * sections of the stack whenever we get control. + */ +word GC_stack_last_cleared = 0; /* GC_no when we last did this */ +# ifdef THREADS +# define CLEAR_SIZE 2048 +# else +# define CLEAR_SIZE 213 +# endif +# define DEGRADE_RATE 50 + +word GC_min_sp; /* Coolest stack pointer value from which we've */ + /* already cleared the stack. */ + +# ifdef STACK_GROWS_DOWN +# define COOLER_THAN > +# define HOTTER_THAN < +# define MAKE_COOLER(x,y) if ((word)(x)+(y) > (word)(x)) {(x) += (y);} \ + else {(x) = (word)ONES;} +# define MAKE_HOTTER(x,y) (x) -= (y) +# else +# define COOLER_THAN < +# define HOTTER_THAN > +# define MAKE_COOLER(x,y) if ((word)(x)-(y) < (word)(x)) {(x) -= (y);} else {(x) = 0;} +# define MAKE_HOTTER(x,y) (x) += (y) +# endif + +word GC_high_water; + /* "hottest" stack pointer value we have seen */ + /* recently. Degrades over time. */ + +word GC_words_allocd_at_reset; + +#if defined(ASM_CLEAR_CODE) && !defined(THREADS) + extern ptr_t GC_clear_stack_inner(); +#endif + +#if !defined(ASM_CLEAR_CODE) && !defined(THREADS) +/* Clear the stack up to about limit. Return arg. */ +/*ARGSUSED*/ +ptr_t GC_clear_stack_inner(arg, limit) +ptr_t arg; +word limit; +{ + word dummy[CLEAR_SIZE]; + + BZERO(dummy, CLEAR_SIZE*sizeof(word)); + if ((word)(dummy) COOLER_THAN limit) { + (void) GC_clear_stack_inner(arg, limit); + } + /* Make sure the recursive call is not a tail call, and the bzero */ + /* call is not recognized as dead code. */ + GC_noop1((word)dummy); + return(arg); +} +#endif + +/* Clear some of the inaccessible part of the stack. Returns its */ +/* argument, so it can be used in a tail call position, hence clearing */ +/* another frame. */ +ptr_t GC_clear_stack(arg) +ptr_t arg; +{ + register word sp = (word)GC_approx_sp(); /* Hotter than actual sp */ +# ifdef THREADS + word dummy[CLEAR_SIZE]; +# else + register word limit; +# endif + +# define SLOP 400 + /* Extra bytes we clear every time. This clears our own */ + /* activation record, and should cause more frequent */ + /* clearing near the cold end of the stack, a good thing. */ +# define GC_SLOP 4000 + /* We make GC_high_water this much hotter than we really saw */ + /* saw it, to cover for GC noise etc. above our current frame. */ +# define CLEAR_THRESHOLD 100000 + /* We restart the clearing process after this many bytes of */ + /* allocation. Otherwise very heavily recursive programs */ + /* with sparse stacks may result in heaps that grow almost */ + /* without bounds. As the heap gets larger, collection */ + /* frequency decreases, thus clearing frequency would decrease, */ + /* thus more junk remains accessible, thus the heap gets */ + /* larger ... */ +# ifdef THREADS + BZERO(dummy, CLEAR_SIZE*sizeof(word)); +# else + if (GC_gc_no > GC_stack_last_cleared) { + /* Start things over, so we clear the entire stack again */ + if (GC_stack_last_cleared == 0) GC_high_water = (word) GC_stackbottom; + GC_min_sp = GC_high_water; + GC_stack_last_cleared = GC_gc_no; + GC_words_allocd_at_reset = GC_words_allocd; + } + /* Adjust GC_high_water */ + MAKE_COOLER(GC_high_water, WORDS_TO_BYTES(DEGRADE_RATE) + GC_SLOP); + if (sp HOTTER_THAN GC_high_water) { + GC_high_water = sp; + } + MAKE_HOTTER(GC_high_water, GC_SLOP); + limit = GC_min_sp; + MAKE_HOTTER(limit, SLOP); + if (sp COOLER_THAN limit) { + limit &= ~0xf; /* Make it sufficiently aligned for assembly */ + /* implementations of GC_clear_stack_inner. */ + GC_min_sp = sp; + return(GC_clear_stack_inner(arg, limit)); + } else if (WORDS_TO_BYTES(GC_words_allocd - GC_words_allocd_at_reset) + > CLEAR_THRESHOLD) { + /* Restart clearing process, but limit how much clearing we do. */ + GC_min_sp = sp; + MAKE_HOTTER(GC_min_sp, CLEAR_THRESHOLD/4); + if (GC_min_sp HOTTER_THAN GC_high_water) GC_min_sp = GC_high_water; + GC_words_allocd_at_reset = GC_words_allocd; + } +# endif + return(arg); +} + + +/* Return a pointer to the base address of p, given a pointer to a */ +/* an address within an object. Return 0 o.w. */ +# ifdef __STDC__ + GC_PTR GC_base(GC_PTR p) +# else + GC_PTR GC_base(p) + GC_PTR p; +# endif +{ + register word r; + register struct hblk *h; + register bottom_index *bi; + register hdr *candidate_hdr; + register word limit; + + r = (word)p; + if (!GC_is_initialized) return 0; + h = HBLKPTR(r); + GET_BI(r, bi); + candidate_hdr = HDR_FROM_BI(bi, r); + if (candidate_hdr == 0) return(0); + /* If it's a pointer to the middle of a large object, move it */ + /* to the beginning. */ + while (IS_FORWARDING_ADDR_OR_NIL(candidate_hdr)) { + h = FORWARDED_ADDR(h,candidate_hdr); + r = (word)h + HDR_BYTES; + candidate_hdr = HDR(h); + } + if (candidate_hdr -> hb_map == GC_invalid_map) return(0); + /* Make sure r points to the beginning of the object */ + r &= ~(WORDS_TO_BYTES(1) - 1); + { + register int offset = (char *)r - (char *)(HBLKPTR(r)); + register signed_word sz = candidate_hdr -> hb_sz; + +# ifdef ALL_INTERIOR_POINTERS + register map_entry_type map_entry; + + map_entry = MAP_ENTRY((candidate_hdr -> hb_map), offset); + if (map_entry == OBJ_INVALID) { + return(0); + } + r -= WORDS_TO_BYTES(map_entry); + limit = r + WORDS_TO_BYTES(sz); +# else + register int correction; + + offset = BYTES_TO_WORDS(offset - HDR_BYTES); + correction = offset % sz; + r -= (WORDS_TO_BYTES(correction)); + limit = r + WORDS_TO_BYTES(sz); + if (limit > (word)(h + 1) + && sz <= BYTES_TO_WORDS(HBLKSIZE) - HDR_WORDS) { + return(0); + } +# endif + if ((word)p >= limit) return(0); + } + return((GC_PTR)r); +} + + +/* Return the size of an object, given a pointer to its base. */ +/* (For small obects this also happens to work from interior pointers, */ +/* but that shouldn't be relied upon.) */ +# ifdef __STDC__ + size_t GC_size(GC_PTR p) +# else + size_t GC_size(p) + GC_PTR p; +# endif +{ + register int sz; + register hdr * hhdr = HDR(p); + + sz = WORDS_TO_BYTES(hhdr -> hb_sz); + if (sz < 0) { + return(-sz); + } else { + return(sz); + } +} + +size_t GC_get_heap_size GC_PROTO(()) +{ + return ((size_t) GC_heapsize); +} + +size_t GC_get_bytes_since_gc GC_PROTO(()) +{ + return ((size_t) WORDS_TO_BYTES(GC_words_allocd)); +} + +GC_bool GC_is_initialized = FALSE; + +void GC_init() +{ + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + GC_init_inner(); + UNLOCK(); + ENABLE_SIGNALS(); + +} + +#ifdef MSWIN32 + extern void GC_init_win32(); +#endif + +extern void GC_setpagesize(); + +void GC_init_inner() +{ +# ifndef THREADS + word dummy; +# endif + + if (GC_is_initialized) return; + GC_setpagesize(); + GC_exclude_static_roots(beginGC_arrays, end_gc_area); +# ifdef PRINTSTATS + if ((ptr_t)endGC_arrays != (ptr_t)(&GC_obj_kinds)) { + GC_printf0("Reordering linker, didn't exclude obj_kinds\n"); + } +# endif +# ifdef MSWIN32 + GC_init_win32(); +# endif +# if defined(LINUX) && (defined(POWERPC) || defined(ALPHA) || defined(SPARC)) + GC_init_linux_data_start(); +# endif +# ifdef SOLARIS_THREADS + GC_thr_init(); + /* We need dirty bits in order to find live stack sections. */ + GC_dirty_init(); +# endif +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \ + || defined(IRIX_JDK_THREADS) + GC_thr_init(); +# endif +# if !defined(THREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ + || defined(IRIX_THREADS) || defined(LINUX_THREADS) + if (GC_stackbottom == 0) { + GC_stackbottom = GC_get_stack_base(); + } +# endif + if (sizeof (ptr_t) != sizeof(word)) { + ABORT("sizeof (ptr_t) != sizeof(word)\n"); + } + if (sizeof (signed_word) != sizeof(word)) { + ABORT("sizeof (signed_word) != sizeof(word)\n"); + } + if (sizeof (struct hblk) != HBLKSIZE) { + ABORT("sizeof (struct hblk) != HBLKSIZE\n"); + } +# ifndef THREADS +# if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN) + ABORT( + "Only one of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd\n"); +# endif +# if !defined(STACK_GROWS_UP) && !defined(STACK_GROWS_DOWN) + ABORT( + "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd\n"); +# endif +# ifdef STACK_GROWS_DOWN + if ((word)(&dummy) > (word)GC_stackbottom) { + GC_err_printf0( + "STACK_GROWS_DOWN is defd, but stack appears to grow up\n"); +# ifndef UTS4 /* Compiler bug workaround */ + GC_err_printf2("sp = 0x%lx, GC_stackbottom = 0x%lx\n", + (unsigned long) (&dummy), + (unsigned long) GC_stackbottom); +# endif + ABORT("stack direction 3\n"); + } +# else + if ((word)(&dummy) < (word)GC_stackbottom) { + GC_err_printf0( + "STACK_GROWS_UP is defd, but stack appears to grow down\n"); + GC_err_printf2("sp = 0x%lx, GC_stackbottom = 0x%lx\n", + (unsigned long) (&dummy), + (unsigned long) GC_stackbottom); + ABORT("stack direction 4"); + } +# endif +# endif +# if !defined(_AUX_SOURCE) || defined(__GNUC__) + if ((word)(-1) < (word)0) { + GC_err_printf0("The type word should be an unsigned integer type\n"); + GC_err_printf0("It appears to be signed\n"); + ABORT("word"); + } +# endif + if ((signed_word)(-1) >= (signed_word)0) { + GC_err_printf0( + "The type signed_word should be a signed integer type\n"); + GC_err_printf0("It appears to be unsigned\n"); + ABORT("signed_word"); + } + + /* Add initial guess of root sets. Do this first, since sbrk(0) */ + /* might be used. */ + GC_register_data_segments(); + GC_init_headers(); + GC_bl_init(); + GC_mark_init(); + if (!GC_expand_hp_inner((word)MINHINCR)) { + GC_err_printf0("Can't start up: not enough memory\n"); + EXIT(); + } + /* Preallocate large object map. It's otherwise inconvenient to */ + /* deal with failure. */ + if (!GC_add_map_entry((word)0)) { + GC_err_printf0("Can't start up: not enough memory\n"); + EXIT(); + } + GC_register_displacement_inner(0L); +# ifdef MERGE_SIZES + GC_init_size_map(); +# endif +# ifdef PCR + if (PCR_IL_Lock(PCR_Bool_false, PCR_allSigsBlocked, PCR_waitForever) + != PCR_ERes_okay) { + ABORT("Can't lock load state\n"); + } else if (PCR_IL_Unlock() != PCR_ERes_okay) { + ABORT("Can't unlock load state\n"); + } + PCR_IL_Unlock(); + GC_pcr_install(); +# endif + /* Get black list set up */ + GC_gcollect_inner(); +# ifdef STUBBORN_ALLOC + GC_stubborn_init(); +# endif + GC_is_initialized = TRUE; + /* Convince lint that some things are used */ +# ifdef LINT + { + extern char * GC_copyright[]; + extern int GC_read(); + extern void GC_register_finalizer_no_order(); + + GC_noop(GC_copyright, GC_find_header, + GC_push_one, GC_call_with_alloc_lock, GC_read, + GC_dont_expand, +# ifndef NO_DEBUGGING + GC_dump, +# endif + GC_register_finalizer_no_order); + } +# endif +} + +void GC_enable_incremental GC_PROTO(()) +{ +# if !defined(SMALL_CONFIG) + if (!GC_find_leak) { + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + if (GC_incremental) goto out; + GC_setpagesize(); +# ifdef MSWIN32 + { + extern GC_bool GC_is_win32s(); + + /* VirtualProtect is not functional under win32s. */ + if (GC_is_win32s()) goto out; + } +# endif /* MSWIN32 */ +# ifndef SOLARIS_THREADS + GC_dirty_init(); +# endif + if (!GC_is_initialized) { + GC_init_inner(); + } + if (GC_dont_gc) { + /* Can't easily do it. */ + UNLOCK(); + ENABLE_SIGNALS(); + return; + } + if (GC_words_allocd > 0) { + /* There may be unmarked reachable objects */ + GC_gcollect_inner(); + } /* else we're OK in assuming everything's */ + /* clean since nothing can point to an */ + /* unmarked object. */ + GC_read_dirty(); + GC_incremental = TRUE; +out: + UNLOCK(); + ENABLE_SIGNALS(); + } +# endif +} + + +#ifdef MSWIN32 +# define LOG_FILE "gc.log" + + HANDLE GC_stdout = 0, GC_stderr; + int GC_tmp; + DWORD GC_junk; + + void GC_set_files() + { + if (!GC_stdout) { + GC_stdout = CreateFile(LOG_FILE, GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, + NULL); + if (INVALID_HANDLE_VALUE == GC_stdout) ABORT("Open of log file failed"); + } + if (GC_stderr == 0) { + GC_stderr = GC_stdout; + } + } + +#endif + +#if defined(OS2) || defined(MACOS) +FILE * GC_stdout = NULL; +FILE * GC_stderr = NULL; +int GC_tmp; /* Should really be local ... */ + + void GC_set_files() + { + if (GC_stdout == NULL) { + GC_stdout = stdout; + } + if (GC_stderr == NULL) { + GC_stderr = stderr; + } + } +#endif + +#if !defined(OS2) && !defined(MACOS) && !defined(MSWIN32) + int GC_stdout = 1; + int GC_stderr = 2; +# if !defined(AMIGA) +# include +# endif +#endif + +#if !defined(MSWIN32) && !defined(OS2) && !defined(MACOS) +int GC_write(fd, buf, len) +int fd; +char *buf; +size_t len; +{ + register int bytes_written = 0; + register int result; + + while (bytes_written < len) { +# ifdef SOLARIS_THREADS + result = syscall(SYS_write, fd, buf + bytes_written, + len - bytes_written); +# else + result = write(fd, buf + bytes_written, len - bytes_written); +# endif + if (-1 == result) return(result); + bytes_written += result; + } + return(bytes_written); +} +#endif /* UN*X */ + +#ifdef MSWIN32 +# define WRITE(f, buf, len) (GC_set_files(), \ + GC_tmp = WriteFile((f), (buf), \ + (len), &GC_junk, NULL),\ + (GC_tmp? 1 : -1)) +#else +# if defined(OS2) || defined(MACOS) +# define WRITE(f, buf, len) (GC_set_files(), \ + GC_tmp = fwrite((buf), 1, (len), (f)), \ + fflush(f), GC_tmp) +# else +# define WRITE(f, buf, len) GC_write((f), (buf), (len)) +# endif +#endif + +/* A version of printf that is unlikely to call malloc, and is thus safer */ +/* to call from the collector in case malloc has been bound to GC_malloc. */ +/* Assumes that no more than 1023 characters are written at once. */ +/* Assumes that all arguments have been converted to something of the */ +/* same size as long, and that the format conversions expect something */ +/* of that size. */ +void GC_printf(format, a, b, c, d, e, f) +char * format; +long a, b, c, d, e, f; +{ + char buf[1025]; + + if (GC_quiet) return; + buf[1024] = 0x15; + (void) sprintf(buf, format, a, b, c, d, e, f); + if (buf[1024] != 0x15) ABORT("GC_printf clobbered stack"); + if (WRITE(GC_stdout, buf, strlen(buf)) < 0) ABORT("write to stdout failed"); +} + +void GC_err_printf(format, a, b, c, d, e, f) +char * format; +long a, b, c, d, e, f; +{ + char buf[1025]; + + buf[1024] = 0x15; + (void) sprintf(buf, format, a, b, c, d, e, f); + if (buf[1024] != 0x15) ABORT("GC_err_printf clobbered stack"); + if (WRITE(GC_stderr, buf, strlen(buf)) < 0) ABORT("write to stderr failed"); +} + +void GC_err_puts(s) +char *s; +{ + if (WRITE(GC_stderr, s, strlen(s)) < 0) ABORT("write to stderr failed"); +} + +# if defined(__STDC__) || defined(__cplusplus) + void GC_default_warn_proc(char *msg, GC_word arg) +# else + void GC_default_warn_proc(msg, arg) + char *msg; + GC_word arg; +# endif +{ + GC_err_printf1(msg, (unsigned long)arg); +} + +GC_warn_proc GC_current_warn_proc = GC_default_warn_proc; + +# if defined(__STDC__) || defined(__cplusplus) + GC_warn_proc GC_set_warn_proc(GC_warn_proc p) +# else + GC_warn_proc GC_set_warn_proc(p) + GC_warn_proc p; +# endif +{ + GC_warn_proc result; + + LOCK(); + result = GC_current_warn_proc; + GC_current_warn_proc = p; + UNLOCK(); + return(result); +} + + +#ifndef PCR +void GC_abort(msg) +char * msg; +{ + GC_err_printf1("%s\n", msg); + (void) abort(); +} +#endif + +#ifdef NEED_CALLINFO + +void GC_print_callers (info) +struct callinfo info[NFRAMES]; +{ + register int i; + +# if NFRAMES == 1 + GC_err_printf0("\tCaller at allocation:\n"); +# else + GC_err_printf0("\tCall chain at allocation:\n"); +# endif + for (i = 0; i < NFRAMES; i++) { + if (info[i].ci_pc == 0) break; +# if NARGS > 0 + { + int j; + + GC_err_printf0("\t\targs: "); + for (j = 0; j < NARGS; j++) { + if (j != 0) GC_err_printf0(", "); + GC_err_printf2("%d (0x%X)", ~(info[i].ci_arg[j]), + ~(info[i].ci_arg[j])); + } + GC_err_printf0("\n"); + } +# endif + GC_err_printf1("\t\t##PC##= 0x%X\n", info[i].ci_pc); + } +} + +#endif /* SAVE_CALL_CHAIN */ + +# ifdef SRC_M3 +void GC_enable() +{ + GC_dont_gc--; +} + +void GC_disable() +{ + GC_dont_gc++; +} +# endif + +#if !defined(NO_DEBUGGING) + +void GC_dump() +{ + GC_printf0("***Static roots:\n"); + GC_print_static_roots(); + GC_printf0("\n***Heap sections:\n"); + GC_print_heap_sects(); + GC_printf0("\n***Free blocks:\n"); + GC_print_hblkfreelist(); + GC_printf0("\n***Blocks in use:\n"); + GC_print_block_list(); +} + +# endif /* NO_DEBUGGING */ diff --git a/support/gc/new_hblk.c b/support/gc/new_hblk.c new file mode 100644 index 00000000..9f32ae0d --- /dev/null +++ b/support/gc/new_hblk.c @@ -0,0 +1,244 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * This file contains the functions: + * ptr_t GC_build_flXXX(h, old_fl) + * void GC_new_hblk(n) + */ +/* Boehm, May 19, 1994 2:09 pm PDT */ + + +# include +# include "gc_priv.h" + +#ifndef SMALL_CONFIG +/* + * Build a free list for size 1 objects inside hblk h. Set the last link to + * be ofl. Return a pointer tpo the first free list entry. + */ +ptr_t GC_build_fl1(h, ofl) +struct hblk *h; +ptr_t ofl; +{ + register word * p = (word *)h; + register word * lim = (word *)(h + 1); + + p[0] = (word)ofl; + p[1] = (word)(p); + p[2] = (word)(p+1); + p[3] = (word)(p+2); + p += 4; + for (; p < lim; p += 4) { + p[0] = (word)(p-1); + p[1] = (word)(p); + p[2] = (word)(p+1); + p[3] = (word)(p+2); + }; + return((ptr_t)(p-1)); +} + +/* The same for size 2 cleared objects */ +ptr_t GC_build_fl_clear2(h, ofl) +struct hblk *h; +ptr_t ofl; +{ + register word * p = (word *)h; + register word * lim = (word *)(h + 1); + + p[0] = (word)ofl; + p[1] = 0; + p[2] = (word)p; + p[3] = 0; + p += 4; + for (; p < lim; p += 4) { + p[0] = (word)(p-2); + p[1] = 0; + p[2] = (word)p; + p[3] = 0; + }; + return((ptr_t)(p-2)); +} + +/* The same for size 3 cleared objects */ +ptr_t GC_build_fl_clear3(h, ofl) +struct hblk *h; +ptr_t ofl; +{ + register word * p = (word *)h; + register word * lim = (word *)(h + 1) - 2; + + p[0] = (word)ofl; + p[1] = 0; + p[2] = 0; + p += 3; + for (; p < lim; p += 3) { + p[0] = (word)(p-3); + p[1] = 0; + p[2] = 0; + }; + return((ptr_t)(p-3)); +} + +/* The same for size 4 cleared objects */ +ptr_t GC_build_fl_clear4(h, ofl) +struct hblk *h; +ptr_t ofl; +{ + register word * p = (word *)h; + register word * lim = (word *)(h + 1); + + p[0] = (word)ofl; + p[1] = 0; + p[2] = 0; + p[3] = 0; + p += 4; + for (; p < lim; p += 4) { + p[0] = (word)(p-4); + p[1] = 0; + p[2] = 0; + p[3] = 0; + }; + return((ptr_t)(p-4)); +} + +/* The same for size 2 uncleared objects */ +ptr_t GC_build_fl2(h, ofl) +struct hblk *h; +ptr_t ofl; +{ + register word * p = (word *)h; + register word * lim = (word *)(h + 1); + + p[0] = (word)ofl; + p[2] = (word)p; + p += 4; + for (; p < lim; p += 4) { + p[0] = (word)(p-2); + p[2] = (word)p; + }; + return((ptr_t)(p-2)); +} + +/* The same for size 4 uncleared objects */ +ptr_t GC_build_fl4(h, ofl) +struct hblk *h; +ptr_t ofl; +{ + register word * p = (word *)h; + register word * lim = (word *)(h + 1); + + p[0] = (word)ofl; + p[4] = (word)p; + p += 8; + for (; p < lim; p += 8) { + p[0] = (word)(p-4); + p[4] = (word)p; + }; + return((ptr_t)(p-4)); +} + +#endif /* !SMALL_CONFIG */ + +/* + * Allocate a new heapblock for small objects of size n. + * Add all of the heapblock's objects to the free list for objects + * of that size. + * Set all mark bits if objects are uncollectable. + * Will fail to do anything if we are out of memory. + */ +void GC_new_hblk(sz, kind) +register word sz; +int kind; +{ + register word *p, + *prev; + word *last_object; /* points to last object in new hblk */ + register struct hblk *h; /* the new heap block */ + register GC_bool clear = GC_obj_kinds[kind].ok_init; + +# ifdef PRINTSTATS + if ((sizeof (struct hblk)) > HBLKSIZE) { + ABORT("HBLK SZ inconsistency"); + } +# endif + + /* Allocate a new heap block */ + h = GC_allochblk(sz, kind, 0); + if (h == 0) return; + + /* Mark all objects if appropriate. */ + if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h)); + + /* Handle small objects sizes more efficiently. For larger objects */ + /* the difference is less significant. */ +# ifndef SMALL_CONFIG + switch (sz) { + case 1: GC_obj_kinds[kind].ok_freelist[1] = + GC_build_fl1(h, GC_obj_kinds[kind].ok_freelist[1]); + return; + case 2: if (clear) { + GC_obj_kinds[kind].ok_freelist[2] = + GC_build_fl_clear2(h, GC_obj_kinds[kind].ok_freelist[2]); + } else { + GC_obj_kinds[kind].ok_freelist[2] = + GC_build_fl2(h, GC_obj_kinds[kind].ok_freelist[2]); + } + return; + case 3: if (clear) { + GC_obj_kinds[kind].ok_freelist[3] = + GC_build_fl_clear3(h, GC_obj_kinds[kind].ok_freelist[3]); + return; + } else { + /* It's messy to do better than the default here. */ + break; + } + case 4: if (clear) { + GC_obj_kinds[kind].ok_freelist[4] = + GC_build_fl_clear4(h, GC_obj_kinds[kind].ok_freelist[4]); + } else { + GC_obj_kinds[kind].ok_freelist[4] = + GC_build_fl4(h, GC_obj_kinds[kind].ok_freelist[4]); + } + return; + default: + break; + } +# endif /* !SMALL_CONFIG */ + + /* Clear the page if necessary. */ + if (clear) BZERO(h, HBLKSIZE); + + /* Add objects to free list */ + p = &(h -> hb_body[sz]); /* second object in *h */ + prev = &(h -> hb_body[0]); /* One object behind p */ + last_object = (word *)((char *)h + HBLKSIZE); + last_object -= sz; + /* Last place for last object to start */ + + /* make a list of all objects in *h with head as last object */ + while (p <= last_object) { + /* current object's link points to last object */ + obj_link(p) = (ptr_t)prev; + prev = p; + p += sz; + } + p -= sz; /* p now points to last object */ + + /* + * put p (which is now head of list of objects in *h) as first + * pointer in the appropriate free list for this size. + */ + obj_link(h -> hb_body) = GC_obj_kinds[kind].ok_freelist[sz]; + GC_obj_kinds[kind].ok_freelist[sz] = ((ptr_t)p); +} + diff --git a/support/gc/obj_map.c b/support/gc/obj_map.c new file mode 100644 index 00000000..82ebf311 --- /dev/null +++ b/support/gc/obj_map.c @@ -0,0 +1,142 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991, 1992 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, October 9, 1995 1:09 pm PDT */ + +/* Routines for maintaining maps describing heap block + * layouts for various object sizes. Allows fast pointer validity checks + * and fast location of object start locations on machines (such as SPARC) + * with slow division. + */ + +# include "gc_priv.h" + +char * GC_invalid_map = 0; + +/* Invalidate the object map associated with a block. Free blocks */ +/* are identified by invalid maps. */ +void GC_invalidate_map(hhdr) +hdr *hhdr; +{ + register int displ; + + if (GC_invalid_map == 0) { + GC_invalid_map = GC_scratch_alloc(MAP_SIZE); + if (GC_invalid_map == 0) { + GC_err_printf0( + "Cant initialize GC_invalid_map: insufficient memory\n"); + EXIT(); + } + for (displ = 0; displ < HBLKSIZE; displ++) { + MAP_ENTRY(GC_invalid_map, displ) = OBJ_INVALID; + } + } + hhdr -> hb_map = GC_invalid_map; +} + +/* Consider pointers that are offset bytes displaced from the beginning */ +/* of an object to be valid. */ + +# if defined(__STDC__) || defined(__cplusplus) + void GC_register_displacement(GC_word offset) +# else + void GC_register_displacement(offset) + GC_word offset; +# endif +{ +# ifndef ALL_INTERIOR_POINTERS + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + GC_register_displacement_inner(offset); + UNLOCK(); + ENABLE_SIGNALS(); +# endif +} + +void GC_register_displacement_inner(offset) +word offset; +{ +# ifndef ALL_INTERIOR_POINTERS + register unsigned i; + + if (offset > MAX_OFFSET) { + ABORT("Bad argument to GC_register_displacement"); + } + if (!GC_valid_offsets[offset]) { + GC_valid_offsets[offset] = TRUE; + GC_modws_valid_offsets[offset % sizeof(word)] = TRUE; + for (i = 0; i <= MAXOBJSZ; i++) { + if (GC_obj_map[i] != 0) { + if (i == 0) { + GC_obj_map[i][offset + HDR_BYTES] = (char)BYTES_TO_WORDS(offset); + } else { + register unsigned j; + register unsigned lb = WORDS_TO_BYTES(i); + + if (offset < lb) { + for (j = offset + HDR_BYTES; j < HBLKSIZE; j += lb) { + GC_obj_map[i][j] = (char)BYTES_TO_WORDS(offset); + } + } + } + } + } + } +# endif +} + + +/* Add a heap block map for objects of size sz to obj_map. */ +/* Return FALSE on failure. */ +GC_bool GC_add_map_entry(sz) +word sz; +{ + register unsigned obj_start; + register unsigned displ; + register char * new_map; + + if (sz > MAXOBJSZ) sz = 0; + if (GC_obj_map[sz] != 0) { + return(TRUE); + } + new_map = GC_scratch_alloc(MAP_SIZE); + if (new_map == 0) return(FALSE); +# ifdef PRINTSTATS + GC_printf1("Adding block map for size %lu\n", (unsigned long)sz); +# endif + for (displ = 0; displ < HBLKSIZE; displ++) { + MAP_ENTRY(new_map,displ) = OBJ_INVALID; + } + if (sz == 0) { + for(displ = 0; displ <= MAX_OFFSET; displ++) { + if (OFFSET_VALID(displ)) { + MAP_ENTRY(new_map,displ+HDR_BYTES) = BYTES_TO_WORDS(displ); + } + } + } else { + for (obj_start = HDR_BYTES; + obj_start + WORDS_TO_BYTES(sz) <= HBLKSIZE; + obj_start += WORDS_TO_BYTES(sz)) { + for (displ = 0; displ < WORDS_TO_BYTES(sz); displ++) { + if (OFFSET_VALID(displ)) { + MAP_ENTRY(new_map, obj_start + displ) = + BYTES_TO_WORDS(displ); + } + } + } + } + GC_obj_map[sz] = new_map; + return(TRUE); +} diff --git a/support/gc/os_dep.c b/support/gc/os_dep.c new file mode 100644 index 00000000..81f74f3a --- /dev/null +++ b/support/gc/os_dep.c @@ -0,0 +1,2459 @@ +/* + * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1997 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +# include "gc_priv.h" + +# if defined(LINUX) && !defined(POWERPC) +# include +# if (LINUX_VERSION_CODE <= 0x10400) + /* Ugly hack to get struct sigcontext_struct definition. Required */ + /* for some early 1.3.X releases. Will hopefully go away soon. */ + /* in some later Linux releases, asm/sigcontext.h may have to */ + /* be included instead. */ +# define __KERNEL__ +# include +# undef __KERNEL__ +# else + /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */ + /* struct sigcontext. libc6 (glibc2) uses "struct sigcontext" in */ + /* prototypes, so we have to include the top-level sigcontext.h to */ + /* make sure the former gets defined to be the latter if appropriate. */ +# include +# if 2 <= __GLIBC__ +# if 0 == __GLIBC_MINOR__ + /* glibc 2.1 no longer has sigcontext.h. But signal.h */ + /* has the right declaration for glibc 2.1. */ +# include +# endif /* 0 == __GLIBC_MINOR__ */ +# else /* not 2 <= __GLIBC__ */ + /* libc5 doesn't have : go directly with the kernel */ + /* one. Check LINUX_VERSION_CODE to see which we should reference. */ +# include +# endif /* 2 <= __GLIBC__ */ +# endif +# endif +# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) +# include +# if !defined(MSWIN32) && !defined(SUNOS4) +# include +# endif +# endif + +# include +# include + +/* Blatantly OS dependent routines, except for those that are related */ +/* dynamic loading. */ + +# if !defined(THREADS) && !defined(STACKBOTTOM) && defined(HEURISTIC2) +# define NEED_FIND_LIMIT +# endif + +# if defined(IRIX_THREADS) +# define NEED_FIND_LIMIT +# endif + +# if (defined(SUNOS4) & defined(DYNAMIC_LOADING)) && !defined(PCR) +# define NEED_FIND_LIMIT +# endif + +# if (defined(SVR4) || defined(AUX) || defined(DGUX)) && !defined(PCR) +# define NEED_FIND_LIMIT +# endif + +# if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA)) +# define NEED_FIND_LIMIT +# endif + +#ifdef NEED_FIND_LIMIT +# include +#endif + +#ifdef FREEBSD +# include +#endif + +#ifdef AMIGA +# include +# include +# include +# include +#endif + +#ifdef MSWIN32 +# define WIN32_LEAN_AND_MEAN +# define NOSERVICE +# include +#endif + +#ifdef MACOS +# include +#endif + +#ifdef IRIX5 +# include +# include /* for locking */ +#endif +#ifdef USE_MMAP +# include +# include +# include +# include +#endif + +#ifdef SUNOS5SIGS +# include +# undef setjmp +# undef longjmp +# define setjmp(env) sigsetjmp(env, 1) +# define longjmp(env, val) siglongjmp(env, val) +# define jmp_buf sigjmp_buf +#endif + +#ifdef DJGPP + /* Apparently necessary for djgpp 2.01. May casuse problems with */ + /* other versions. */ + typedef long unsigned int caddr_t; +#endif + +#ifdef PCR +# include "il/PCR_IL.h" +# include "th/PCR_ThCtl.h" +# include "mm/PCR_MM.h" +#endif + +#if !defined(NO_EXECUTE_PERMISSION) +# define OPT_PROT_EXEC PROT_EXEC +#else +# define OPT_PROT_EXEC 0 +#endif + +#if defined(LINUX) && (defined(POWERPC) || defined(SPARC) || defined(ALPHA)) + /* The I386 case can be handled without a search. The Alpha case */ + /* used to be handled differently as well, but the rules changed */ + /* for recent Linux versions. This seems to be the easiest way to */ + /* cover all versions. */ + ptr_t GC_data_start; + + extern char * GC_copyright[]; /* Any data symbol would do. */ + + void GC_init_linux_data_start() + { + extern ptr_t GC_find_limit(); + + GC_data_start = GC_find_limit((ptr_t)GC_copyright, FALSE); + } +#endif + +# ifdef OS2 + +# include + +# if !defined(__IBMC__) && !defined(__WATCOMC__) /* e.g. EMX */ + +struct exe_hdr { + unsigned short magic_number; + unsigned short padding[29]; + long new_exe_offset; +}; + +#define E_MAGIC(x) (x).magic_number +#define EMAGIC 0x5A4D +#define E_LFANEW(x) (x).new_exe_offset + +struct e32_exe { + unsigned char magic_number[2]; + unsigned char byte_order; + unsigned char word_order; + unsigned long exe_format_level; + unsigned short cpu; + unsigned short os; + unsigned long padding1[13]; + unsigned long object_table_offset; + unsigned long object_count; + unsigned long padding2[31]; +}; + +#define E32_MAGIC1(x) (x).magic_number[0] +#define E32MAGIC1 'L' +#define E32_MAGIC2(x) (x).magic_number[1] +#define E32MAGIC2 'X' +#define E32_BORDER(x) (x).byte_order +#define E32LEBO 0 +#define E32_WORDER(x) (x).word_order +#define E32LEWO 0 +#define E32_CPU(x) (x).cpu +#define E32CPU286 1 +#define E32_OBJTAB(x) (x).object_table_offset +#define E32_OBJCNT(x) (x).object_count + +struct o32_obj { + unsigned long size; + unsigned long base; + unsigned long flags; + unsigned long pagemap; + unsigned long mapsize; + unsigned long reserved; +}; + +#define O32_FLAGS(x) (x).flags +#define OBJREAD 0x0001L +#define OBJWRITE 0x0002L +#define OBJINVALID 0x0080L +#define O32_SIZE(x) (x).size +#define O32_BASE(x) (x).base + +# else /* IBM's compiler */ + +/* A kludge to get around what appears to be a header file bug */ +# ifndef WORD +# define WORD unsigned short +# endif +# ifndef DWORD +# define DWORD unsigned long +# endif + +# define EXE386 1 +# include +# include + +# endif /* __IBMC__ */ + +# define INCL_DOSEXCEPTIONS +# define INCL_DOSPROCESS +# define INCL_DOSERRORS +# define INCL_DOSMODULEMGR +# define INCL_DOSMEMMGR +# include + + +/* Disable and enable signals during nontrivial allocations */ + +void GC_disable_signals(void) +{ + ULONG nest; + + DosEnterMustComplete(&nest); + if (nest != 1) ABORT("nested GC_disable_signals"); +} + +void GC_enable_signals(void) +{ + ULONG nest; + + DosExitMustComplete(&nest); + if (nest != 0) ABORT("GC_enable_signals"); +} + + +# else + +# if !defined(PCR) && !defined(AMIGA) && !defined(MSWIN32) \ + && !defined(MACOS) && !defined(DJGPP) && !defined(DOS4GW) + +# if defined(sigmask) && !defined(UTS4) + /* Use the traditional BSD interface */ +# define SIGSET_T int +# define SIG_DEL(set, signal) (set) &= ~(sigmask(signal)) +# define SIG_FILL(set) (set) = 0x7fffffff + /* Setting the leading bit appears to provoke a bug in some */ + /* longjmp implementations. Most systems appear not to have */ + /* a signal 32. */ +# define SIGSETMASK(old, new) (old) = sigsetmask(new) +# else + /* Use POSIX/SYSV interface */ +# define SIGSET_T sigset_t +# define SIG_DEL(set, signal) sigdelset(&(set), (signal)) +# define SIG_FILL(set) sigfillset(&set) +# define SIGSETMASK(old, new) sigprocmask(SIG_SETMASK, &(new), &(old)) +# endif + +static GC_bool mask_initialized = FALSE; + +static SIGSET_T new_mask; + +static SIGSET_T old_mask; + +static SIGSET_T dummy; + +#if defined(PRINTSTATS) && !defined(THREADS) +# define CHECK_SIGNALS + int GC_sig_disabled = 0; +#endif + +void GC_disable_signals() +{ + if (!mask_initialized) { + SIG_FILL(new_mask); + + SIG_DEL(new_mask, SIGSEGV); + SIG_DEL(new_mask, SIGILL); + SIG_DEL(new_mask, SIGQUIT); +# ifdef SIGBUS + SIG_DEL(new_mask, SIGBUS); +# endif +# ifdef SIGIOT + SIG_DEL(new_mask, SIGIOT); +# endif +# ifdef SIGEMT + SIG_DEL(new_mask, SIGEMT); +# endif +# ifdef SIGTRAP + SIG_DEL(new_mask, SIGTRAP); +# endif + mask_initialized = TRUE; + } +# ifdef CHECK_SIGNALS + if (GC_sig_disabled != 0) ABORT("Nested disables"); + GC_sig_disabled++; +# endif + SIGSETMASK(old_mask,new_mask); +} + +void GC_enable_signals() +{ +# ifdef CHECK_SIGNALS + if (GC_sig_disabled != 1) ABORT("Unmatched enable"); + GC_sig_disabled--; +# endif + SIGSETMASK(dummy,old_mask); +} + +# endif /* !PCR */ + +# endif /*!OS/2 */ + +/* Ivan Demakov: simplest way (to me) */ +#ifdef DOS4GW + void GC_disable_signals() { } + void GC_enable_signals() { } +#endif + +/* Find the page size */ +word GC_page_size; + +# ifdef MSWIN32 + void GC_setpagesize() + { + SYSTEM_INFO sysinfo; + + GetSystemInfo(&sysinfo); + GC_page_size = sysinfo.dwPageSize; + } + +# else +# if defined(MPROTECT_VDB) || defined(PROC_VDB) || defined(USE_MMAP) \ + || defined(USE_MUNMAP) + void GC_setpagesize() + { + GC_page_size = GETPAGESIZE(); + } +# else + /* It's acceptable to fake it. */ + void GC_setpagesize() + { + GC_page_size = HBLKSIZE; + } +# endif +# endif + +/* + * Find the base of the stack. + * Used only in single-threaded environment. + * With threads, GC_mark_roots needs to know how to do this. + * Called with allocator lock held. + */ +# ifdef MSWIN32 +# define is_writable(prot) ((prot) == PAGE_READWRITE \ + || (prot) == PAGE_WRITECOPY \ + || (prot) == PAGE_EXECUTE_READWRITE \ + || (prot) == PAGE_EXECUTE_WRITECOPY) +/* Return the number of bytes that are writable starting at p. */ +/* The pointer p is assumed to be page aligned. */ +/* If base is not 0, *base becomes the beginning of the */ +/* allocation region containing p. */ +word GC_get_writable_length(ptr_t p, ptr_t *base) +{ + MEMORY_BASIC_INFORMATION buf; + word result; + word protect; + + result = VirtualQuery(p, &buf, sizeof(buf)); + if (result != sizeof(buf)) ABORT("Weird VirtualQuery result"); + if (base != 0) *base = (ptr_t)(buf.AllocationBase); + protect = (buf.Protect & ~(PAGE_GUARD | PAGE_NOCACHE)); + if (!is_writable(protect)) { + return(0); + } + if (buf.State != MEM_COMMIT) return(0); + return(buf.RegionSize); +} + +ptr_t GC_get_stack_base() +{ + int dummy; + ptr_t sp = (ptr_t)(&dummy); + ptr_t trunc_sp = (ptr_t)((word)sp & ~(GC_page_size - 1)); + word size = GC_get_writable_length(trunc_sp, 0); + + return(trunc_sp + size); +} + + +# else + +# ifdef OS2 + +ptr_t GC_get_stack_base() +{ + PTIB ptib; + PPIB ppib; + + if (DosGetInfoBlocks(&ptib, &ppib) != NO_ERROR) { + GC_err_printf0("DosGetInfoBlocks failed\n"); + ABORT("DosGetInfoBlocks failed\n"); + } + return((ptr_t)(ptib -> tib_pstacklimit)); +} + +# else + +# ifdef AMIGA + +ptr_t GC_get_stack_base() +{ + struct Process *proc = (struct Process*)SysBase->ThisTask; + + /* Reference: Amiga Guru Book Pages: 42,567,574 */ + if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS + && proc->pr_CLI != NULL) { + /* first ULONG is StackSize */ + /*longPtr = proc->pr_ReturnAddr; + size = longPtr[0];*/ + + return (char *)proc->pr_ReturnAddr + sizeof(ULONG); + } else { + return (char *)proc->pr_Task.tc_SPUpper; + } +} + +#if 0 /* old version */ +ptr_t GC_get_stack_base() +{ + extern struct WBStartup *_WBenchMsg; + extern long __base; + extern long __stack; + struct Task *task; + struct Process *proc; + struct CommandLineInterface *cli; + long size; + + if ((task = FindTask(0)) == 0) { + GC_err_puts("Cannot find own task structure\n"); + ABORT("task missing"); + } + proc = (struct Process *)task; + cli = BADDR(proc->pr_CLI); + + if (_WBenchMsg != 0 || cli == 0) { + size = (char *)task->tc_SPUpper - (char *)task->tc_SPLower; + } else { + size = cli->cli_DefaultStack * 4; + } + return (ptr_t)(__base + GC_max(size, __stack)); +} +#endif /* 0 */ + +# else /* !AMIGA, !OS2, ... */ + +# ifdef NEED_FIND_LIMIT + /* Some tools to implement HEURISTIC2 */ +# define MIN_PAGE_SIZE 256 /* Smallest conceivable page size, bytes */ + /* static */ jmp_buf GC_jmp_buf; + + /*ARGSUSED*/ + void GC_fault_handler(sig) + int sig; + { + longjmp(GC_jmp_buf, 1); + } + +# ifdef __STDC__ + typedef void (*handler)(int); +# else + typedef void (*handler)(); +# endif + +# if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) + static struct sigaction old_segv_act; +# if defined(_sigargs) /* !Irix6.x */ + static struct sigaction old_bus_act; +# endif +# else + static handler old_segv_handler, old_bus_handler; +# endif + + void GC_setup_temporary_fault_handler() + { +# if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) + struct sigaction act; + + act.sa_handler = GC_fault_handler; + act.sa_flags = SA_RESTART | SA_NODEFER; + /* The presence of SA_NODEFER represents yet another gross */ + /* hack. Under Solaris 2.3, siglongjmp doesn't appear to */ + /* interact correctly with -lthread. We hide the confusion */ + /* by making sure that signal handling doesn't affect the */ + /* signal mask. */ + + (void) sigemptyset(&act.sa_mask); +# ifdef IRIX_THREADS + /* Older versions have a bug related to retrieving and */ + /* and setting a handler at the same time. */ + (void) sigaction(SIGSEGV, 0, &old_segv_act); + (void) sigaction(SIGSEGV, &act, 0); +# else + (void) sigaction(SIGSEGV, &act, &old_segv_act); +# ifdef _sigargs /* Irix 5.x, not 6.x */ + /* Under 5.x, we may get SIGBUS. */ + /* Pthreads doesn't exist under 5.x, so we don't */ + /* have to worry in the threads case. */ + (void) sigaction(SIGBUS, &act, &old_bus_act); +# endif +# endif /* IRIX_THREADS */ +# else + old_segv_handler = signal(SIGSEGV, GC_fault_handler); +# ifdef SIGBUS + old_bus_handler = signal(SIGBUS, GC_fault_handler); +# endif +# endif + } + + void GC_reset_fault_handler() + { +# if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) + (void) sigaction(SIGSEGV, &old_segv_act, 0); +# ifdef _sigargs /* Irix 5.x, not 6.x */ + (void) sigaction(SIGBUS, &old_bus_act, 0); +# endif +# else + (void) signal(SIGSEGV, old_segv_handler); +# ifdef SIGBUS + (void) signal(SIGBUS, old_bus_handler); +# endif +# endif + } + + /* Return the first nonaddressible location > p (up) or */ + /* the smallest location q s.t. [q,p] is addressible (!up). */ + ptr_t GC_find_limit(p, up) + ptr_t p; + GC_bool up; + { + static VOLATILE ptr_t result; + /* Needs to be static, since otherwise it may not be */ + /* preserved across the longjmp. Can safely be */ + /* static since it's only called once, with the */ + /* allocation lock held. */ + + + GC_setup_temporary_fault_handler(); + if (setjmp(GC_jmp_buf) == 0) { + result = (ptr_t)(((word)(p)) + & ~(MIN_PAGE_SIZE-1)); + for (;;) { + if (up) { + result += MIN_PAGE_SIZE; + } else { + result -= MIN_PAGE_SIZE; + } + GC_noop1((word)(*result)); + } + } + GC_reset_fault_handler(); + if (!up) { + result += MIN_PAGE_SIZE; + } + return(result); + } +# endif + + +ptr_t GC_get_stack_base() +{ + word dummy; + ptr_t result; + +# define STACKBOTTOM_ALIGNMENT_M1 ((word)STACK_GRAN - 1) + +# ifdef STACKBOTTOM + return(STACKBOTTOM); +# else +# ifdef HEURISTIC1 +# ifdef STACK_GROWS_DOWN + result = (ptr_t)((((word)(&dummy)) + + STACKBOTTOM_ALIGNMENT_M1) + & ~STACKBOTTOM_ALIGNMENT_M1); +# else + result = (ptr_t)(((word)(&dummy)) + & ~STACKBOTTOM_ALIGNMENT_M1); +# endif +# endif /* HEURISTIC1 */ +# ifdef HEURISTIC2 +# ifdef STACK_GROWS_DOWN + result = GC_find_limit((ptr_t)(&dummy), TRUE); +# ifdef HEURISTIC2_LIMIT + if (result > HEURISTIC2_LIMIT + && (ptr_t)(&dummy) < HEURISTIC2_LIMIT) { + result = HEURISTIC2_LIMIT; + } +# endif +# else + result = GC_find_limit((ptr_t)(&dummy), FALSE); +# ifdef HEURISTIC2_LIMIT + if (result < HEURISTIC2_LIMIT + && (ptr_t)(&dummy) > HEURISTIC2_LIMIT) { + result = HEURISTIC2_LIMIT; + } +# endif +# endif + +# endif /* HEURISTIC2 */ +# ifdef STACK_GROWS_DOWN + if (result == 0) result = (ptr_t)(signed_word)(-sizeof(ptr_t)); +# endif + return(result); +# endif /* STACKBOTTOM */ +} + +# endif /* ! AMIGA */ +# endif /* ! OS2 */ +# endif /* ! MSWIN32 */ + +/* + * Register static data segment(s) as roots. + * If more data segments are added later then they need to be registered + * add that point (as we do with SunOS dynamic loading), + * or GC_mark_roots needs to check for them (as we do with PCR). + * Called with allocator lock held. + */ + +# ifdef OS2 + +void GC_register_data_segments() +{ + PTIB ptib; + PPIB ppib; + HMODULE module_handle; +# define PBUFSIZ 512 + UCHAR path[PBUFSIZ]; + FILE * myexefile; + struct exe_hdr hdrdos; /* MSDOS header. */ + struct e32_exe hdr386; /* Real header for my executable */ + struct o32_obj seg; /* Currrent segment */ + int nsegs; + + + if (DosGetInfoBlocks(&ptib, &ppib) != NO_ERROR) { + GC_err_printf0("DosGetInfoBlocks failed\n"); + ABORT("DosGetInfoBlocks failed\n"); + } + module_handle = ppib -> pib_hmte; + if (DosQueryModuleName(module_handle, PBUFSIZ, path) != NO_ERROR) { + GC_err_printf0("DosQueryModuleName failed\n"); + ABORT("DosGetInfoBlocks failed\n"); + } + myexefile = fopen(path, "rb"); + if (myexefile == 0) { + GC_err_puts("Couldn't open executable "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Failed to open executable\n"); + } + if (fread((char *)(&hdrdos), 1, sizeof hdrdos, myexefile) < sizeof hdrdos) { + GC_err_puts("Couldn't read MSDOS header from "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Couldn't read MSDOS header"); + } + if (E_MAGIC(hdrdos) != EMAGIC) { + GC_err_puts("Executable has wrong DOS magic number: "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Bad DOS magic number"); + } + if (fseek(myexefile, E_LFANEW(hdrdos), SEEK_SET) != 0) { + GC_err_puts("Seek to new header failed in "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Bad DOS magic number"); + } + if (fread((char *)(&hdr386), 1, sizeof hdr386, myexefile) < sizeof hdr386) { + GC_err_puts("Couldn't read MSDOS header from "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Couldn't read OS/2 header"); + } + if (E32_MAGIC1(hdr386) != E32MAGIC1 || E32_MAGIC2(hdr386) != E32MAGIC2) { + GC_err_puts("Executable has wrong OS/2 magic number:"); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Bad OS/2 magic number"); + } + if ( E32_BORDER(hdr386) != E32LEBO || E32_WORDER(hdr386) != E32LEWO) { + GC_err_puts("Executable %s has wrong byte order: "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Bad byte order"); + } + if ( E32_CPU(hdr386) == E32CPU286) { + GC_err_puts("GC can't handle 80286 executables: "); + GC_err_puts(path); GC_err_puts("\n"); + EXIT(); + } + if (fseek(myexefile, E_LFANEW(hdrdos) + E32_OBJTAB(hdr386), + SEEK_SET) != 0) { + GC_err_puts("Seek to object table failed: "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Seek to object table failed"); + } + for (nsegs = E32_OBJCNT(hdr386); nsegs > 0; nsegs--) { + int flags; + if (fread((char *)(&seg), 1, sizeof seg, myexefile) < sizeof seg) { + GC_err_puts("Couldn't read obj table entry from "); + GC_err_puts(path); GC_err_puts("\n"); + ABORT("Couldn't read obj table entry"); + } + flags = O32_FLAGS(seg); + if (!(flags & OBJWRITE)) continue; + if (!(flags & OBJREAD)) continue; + if (flags & OBJINVALID) { + GC_err_printf0("Object with invalid pages?\n"); + continue; + } + GC_add_roots_inner(O32_BASE(seg), O32_BASE(seg)+O32_SIZE(seg), FALSE); + } +} + +# else + +# ifdef MSWIN32 + /* Unfortunately, we have to handle win32s very differently from NT, */ + /* Since VirtualQuery has very different semantics. In particular, */ + /* under win32s a VirtualQuery call on an unmapped page returns an */ + /* invalid result. Under GC_register_data_segments is a noop and */ + /* all real work is done by GC_register_dynamic_libraries. Under */ + /* win32s, we cannot find the data segments associated with dll's. */ + /* We rgister the main data segment here. */ + GC_bool GC_win32s = FALSE; /* We're running under win32s. */ + + GC_bool GC_is_win32s() + { + DWORD v = GetVersion(); + + /* Check that this is not NT, and Windows major version <= 3 */ + return ((v & 0x80000000) && (v & 0xff) <= 3); + } + + void GC_init_win32() + { + GC_win32s = GC_is_win32s(); + } + + /* Return the smallest address a such that VirtualQuery */ + /* returns correct results for all addresses between a and start. */ + /* Assumes VirtualQuery returns correct information for start. */ + ptr_t GC_least_described_address(ptr_t start) + { + MEMORY_BASIC_INFORMATION buf; + SYSTEM_INFO sysinfo; + DWORD result; + LPVOID limit; + ptr_t p; + LPVOID q; + + GetSystemInfo(&sysinfo); + limit = sysinfo.lpMinimumApplicationAddress; + p = (ptr_t)((word)start & ~(GC_page_size - 1)); + for (;;) { + q = (LPVOID)(p - GC_page_size); + if ((ptr_t)q > (ptr_t)p /* underflow */ || q < limit) break; + result = VirtualQuery(q, &buf, sizeof(buf)); + if (result != sizeof(buf) || buf.AllocationBase == 0) break; + p = (ptr_t)(buf.AllocationBase); + } + return(p); + } + + /* Is p the start of either the malloc heap, or of one of our */ + /* heap sections? */ + GC_bool GC_is_heap_base (ptr_t p) + { + + register unsigned i; + +# ifndef REDIRECT_MALLOC + static ptr_t malloc_heap_pointer = 0; + + if (0 == malloc_heap_pointer) { + MEMORY_BASIC_INFORMATION buf; + register DWORD result = VirtualQuery(malloc(1), &buf, sizeof(buf)); + + if (result != sizeof(buf)) { + ABORT("Weird VirtualQuery result"); + } + malloc_heap_pointer = (ptr_t)(buf.AllocationBase); + } + if (p == malloc_heap_pointer) return(TRUE); +# endif + for (i = 0; i < GC_n_heap_bases; i++) { + if (GC_heap_bases[i] == p) return(TRUE); + } + return(FALSE); + } + + void GC_register_root_section(ptr_t static_root) + { + MEMORY_BASIC_INFORMATION buf; + SYSTEM_INFO sysinfo; + DWORD result; + DWORD protect; + LPVOID p; + char * base; + char * limit, * new_limit; + + if (!GC_win32s) return; + p = base = limit = GC_least_described_address(static_root); + GetSystemInfo(&sysinfo); + while (p < sysinfo.lpMaximumApplicationAddress) { + result = VirtualQuery(p, &buf, sizeof(buf)); + if (result != sizeof(buf) || buf.AllocationBase == 0 + || GC_is_heap_base(buf.AllocationBase)) break; + new_limit = (char *)p + buf.RegionSize; + protect = buf.Protect; + if (buf.State == MEM_COMMIT + && is_writable(protect)) { + if ((char *)p == limit) { + limit = new_limit; + } else { + if (base != limit) GC_add_roots_inner(base, limit, FALSE); + base = p; + limit = new_limit; + } + } + if (p > (LPVOID)new_limit /* overflow */) break; + p = (LPVOID)new_limit; + } + if (base != limit) GC_add_roots_inner(base, limit, FALSE); + } + + void GC_register_data_segments() + { + static char dummy; + + GC_register_root_section((ptr_t)(&dummy)); + } +# else +# ifdef AMIGA + + void GC_register_data_segments() + { + struct Process *proc; + struct CommandLineInterface *cli; + BPTR myseglist; + ULONG *data; + + int num; + + +# ifdef __GNUC__ + ULONG dataSegSize; + GC_bool found_segment = FALSE; + extern char __data_size[]; + + dataSegSize=__data_size+8; + /* Can`t find the Location of __data_size, because + it`s possible that is it, inside the segment. */ + +# endif + + proc= (struct Process*)SysBase->ThisTask; + + /* Reference: Amiga Guru Book Pages: 538ff,565,573 + and XOper.asm */ + if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS) { + if (proc->pr_CLI == NULL) { + myseglist = proc->pr_SegList; + } else { + /* ProcLoaded 'Loaded as a command: '*/ + cli = BADDR(proc->pr_CLI); + myseglist = cli->cli_Module; + } + } else { + ABORT("Not a Process."); + } + + if (myseglist == NULL) { + ABORT("Arrrgh.. can't find segments, aborting"); + } + + /* xoper hunks Shell Process */ + + num=0; + for (data = (ULONG *)BADDR(myseglist); data != NULL; + data = (ULONG *)BADDR(data[0])) { + if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) || + ((ULONG) GC_register_data_segments > (ULONG) &data[1] + data[-1])) { +# ifdef __GNUC__ + if (dataSegSize == data[-1]) { + found_segment = TRUE; + } +# endif + GC_add_roots_inner((char *)&data[1], + ((char *)&data[1]) + data[-1], FALSE); + } + ++num; + } /* for */ +# ifdef __GNUC__ + if (!found_segment) { + ABORT("Can`t find correct Segments.\nSolution: Use an newer version of ixemul.library"); + } +# endif + } + +#if 0 /* old version */ + void GC_register_data_segments() + { + extern struct WBStartup *_WBenchMsg; + struct Process *proc; + struct CommandLineInterface *cli; + BPTR myseglist; + ULONG *data; + + if ( _WBenchMsg != 0 ) { + if ((myseglist = _WBenchMsg->sm_Segment) == 0) { + GC_err_puts("No seglist from workbench\n"); + return; + } + } else { + if ((proc = (struct Process *)FindTask(0)) == 0) { + GC_err_puts("Cannot find process structure\n"); + return; + } + if ((cli = BADDR(proc->pr_CLI)) == 0) { + GC_err_puts("No CLI\n"); + return; + } + if ((myseglist = cli->cli_Module) == 0) { + GC_err_puts("No seglist from CLI\n"); + return; + } + } + + for (data = (ULONG *)BADDR(myseglist); data != 0; + data = (ULONG *)BADDR(data[0])) { +# ifdef AMIGA_SKIP_SEG + if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) || + ((ULONG) GC_register_data_segments > (ULONG) &data[1] + data[-1])) { +# else + { +# endif /* AMIGA_SKIP_SEG */ + GC_add_roots_inner((char *)&data[1], + ((char *)&data[1]) + data[-1], FALSE); + } + } + } +#endif /* old version */ + + +# else + +# if (defined(SVR4) || defined(AUX) || defined(DGUX)) && !defined(PCR) +char * GC_SysVGetDataStart(max_page_size, etext_addr) +int max_page_size; +int * etext_addr; +{ + word text_end = ((word)(etext_addr) + sizeof(word) - 1) + & ~(sizeof(word) - 1); + /* etext rounded to word boundary */ + word next_page = ((text_end + (word)max_page_size - 1) + & ~((word)max_page_size - 1)); + word page_offset = (text_end & ((word)max_page_size - 1)); + VOLATILE char * result = (char *)(next_page + page_offset); + /* Note that this isnt equivalent to just adding */ + /* max_page_size to &etext if &etext is at a page boundary */ + + GC_setup_temporary_fault_handler(); + if (setjmp(GC_jmp_buf) == 0) { + /* Try writing to the address. */ + *result = *result; + GC_reset_fault_handler(); + } else { + GC_reset_fault_handler(); + /* We got here via a longjmp. The address is not readable. */ + /* This is known to happen under Solaris 2.4 + gcc, which place */ + /* string constants in the text segment, but after etext. */ + /* Use plan B. Note that we now know there is a gap between */ + /* text and data segments, so plan A bought us something. */ + result = (char *)GC_find_limit((ptr_t)(DATAEND) - MIN_PAGE_SIZE, FALSE); + } + return((char *)result); +} +# endif + + +void GC_register_data_segments() +{ +# if !defined(PCR) && !defined(SRC_M3) && !defined(NEXT) && !defined(MACOS) \ + && !defined(MACOSX) +# if defined(REDIRECT_MALLOC) && defined(SOLARIS_THREADS) + /* As of Solaris 2.3, the Solaris threads implementation */ + /* allocates the data structure for the initial thread with */ + /* sbrk at process startup. It needs to be scanned, so that */ + /* we don't lose some malloc allocated data structures */ + /* hanging from it. We're on thin ice here ... */ + extern caddr_t sbrk(); + + GC_add_roots_inner(DATASTART, (char *)sbrk(0), FALSE); +# else + GC_add_roots_inner(DATASTART, (char *)(DATAEND), FALSE); +# endif +# endif +# if !defined(PCR) && (defined(NEXT) || defined(MACOSX)) + GC_add_roots_inner(DATASTART, (char *) get_end(), FALSE); +# endif +# if defined(MACOS) + { +# if defined(THINK_C) + extern void* GC_MacGetDataStart(void); + /* globals begin above stack and end at a5. */ + GC_add_roots_inner((ptr_t)GC_MacGetDataStart(), + (ptr_t)LMGetCurrentA5(), FALSE); +# else +# if defined(__MWERKS__) +# if !__POWERPC__ + extern void* GC_MacGetDataStart(void); + /* MATTHEW: Function to handle Far Globals (CW Pro 3) */ +# if __option(far_data) + extern void* GC_MacGetDataEnd(void); +# endif + /* globals begin above stack and end at a5. */ + GC_add_roots_inner((ptr_t)GC_MacGetDataStart(), + (ptr_t)LMGetCurrentA5(), FALSE); + /* MATTHEW: Handle Far Globals */ +# if __option(far_data) + /* Far globals follow he QD globals: */ + GC_add_roots_inner((ptr_t)LMGetCurrentA5(), + (ptr_t)GC_MacGetDataEnd(), FALSE); +# endif +# else + extern char __data_start__[], __data_end__[]; + GC_add_roots_inner((ptr_t)&__data_start__, + (ptr_t)&__data_end__, FALSE); +# endif /* __POWERPC__ */ +# endif /* __MWERKS__ */ +# endif /* !THINK_C */ + } +# endif /* MACOS */ + + /* Dynamic libraries are added at every collection, since they may */ + /* change. */ +} + +# endif /* ! AMIGA */ +# endif /* ! MSWIN32 */ +# endif /* ! OS2 */ + +/* + * Auxiliary routines for obtaining memory from OS. + */ + +# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) \ + && !defined(MSWIN32) && !defined(MACOS) && !defined(DOS4GW) + +# ifdef SUNOS4 + extern caddr_t sbrk(); +# endif +# ifdef __STDC__ +# define SBRK_ARG_T ptrdiff_t +# else +# define SBRK_ARG_T int +# endif + +# ifdef RS6000 +/* The compiler seems to generate speculative reads one past the end of */ +/* an allocated object. Hence we need to make sure that the page */ +/* following the last heap page is also mapped. */ +ptr_t GC_unix_get_mem(bytes) +word bytes; +{ + caddr_t cur_brk = (caddr_t)sbrk(0); + caddr_t result; + SBRK_ARG_T lsbs = (word)cur_brk & (GC_page_size-1); + static caddr_t my_brk_val = 0; + + if ((SBRK_ARG_T)bytes < 0) return(0); /* too big */ + if (lsbs != 0) { + if((caddr_t)(sbrk(GC_page_size - lsbs)) == (caddr_t)(-1)) return(0); + } + if (cur_brk == my_brk_val) { + /* Use the extra block we allocated last time. */ + result = (ptr_t)sbrk((SBRK_ARG_T)bytes); + if (result == (caddr_t)(-1)) return(0); + result -= GC_page_size; + } else { + result = (ptr_t)sbrk(GC_page_size + (SBRK_ARG_T)bytes); + if (result == (caddr_t)(-1)) return(0); + } + my_brk_val = result + bytes + GC_page_size; /* Always page aligned */ + return((ptr_t)result); +} + +#else /* Not RS6000 */ + +#if defined(USE_MMAP) +/* Tested only under IRIX5 and Solaris 2 */ + +#ifdef USE_MMAP_FIXED +# define GC_MMAP_FLAGS MAP_FIXED | MAP_PRIVATE + /* Seems to yield better performance on Solaris 2, but can */ + /* be unreliable if something is already mapped at the address. */ +#else +# define GC_MMAP_FLAGS MAP_PRIVATE +#endif + +ptr_t GC_unix_get_mem(bytes) +word bytes; +{ + static GC_bool initialized = FALSE; + static int fd; + void *result; + static ptr_t last_addr = HEAP_START; + + if (!initialized) { + fd = open("/dev/zero", O_RDONLY); + initialized = TRUE; + } + if (bytes & (GC_page_size -1)) ABORT("Bad GET_MEM arg"); + result = mmap(last_addr, bytes, PROT_READ | PROT_WRITE | OPT_PROT_EXEC, + GC_MMAP_FLAGS, fd, 0/* offset */); + if (result == MAP_FAILED) return(0); + last_addr = (ptr_t)result + bytes + GC_page_size - 1; + last_addr = (ptr_t)((word)last_addr & ~(GC_page_size - 1)); + return((ptr_t)result); +} + +#else /* Not RS6000, not USE_MMAP */ +ptr_t GC_unix_get_mem(bytes) +word bytes; +{ + ptr_t result; +# ifdef IRIX5 + /* Bare sbrk isn't thread safe. Play by malloc rules. */ + /* The equivalent may be needed on other systems as well. */ + __LOCK_MALLOC(); +# endif + { + ptr_t cur_brk = (ptr_t)sbrk(0); + SBRK_ARG_T lsbs = (word)cur_brk & (GC_page_size-1); + + if ((SBRK_ARG_T)bytes < 0) return(0); /* too big */ + if (lsbs != 0) { + if((ptr_t)sbrk(GC_page_size - lsbs) == (ptr_t)(-1)) return(0); + } + result = (ptr_t)sbrk((SBRK_ARG_T)bytes); + if (result == (ptr_t)(-1)) result = 0; + } +# ifdef IRIX5 + __UNLOCK_MALLOC(); +# endif + return(result); +} + +#endif /* Not USE_MMAP */ +#endif /* Not RS6000 */ + +# endif /* UN*X */ + +# ifdef OS2 + +void * os2_alloc(size_t bytes) +{ + void * result; + + if (DosAllocMem(&result, bytes, PAG_EXECUTE | PAG_READ | + PAG_WRITE | PAG_COMMIT) + != NO_ERROR) { + return(0); + } + if (result == 0) return(os2_alloc(bytes)); + return(result); +} + +# endif /* OS2 */ + + +# ifdef MSWIN32 +word GC_n_heap_bases = 0; + +ptr_t GC_win32_get_mem(bytes) +word bytes; +{ + ptr_t result; + + if (GC_win32s) { + /* VirtualAlloc doesn't like PAGE_EXECUTE_READWRITE. */ + /* There are also unconfirmed rumors of other */ + /* problems, so we dodge the issue. */ + result = (ptr_t) GlobalAlloc(0, bytes + HBLKSIZE); + result = (ptr_t)(((word)result + HBLKSIZE) & ~(HBLKSIZE-1)); + } else { + result = (ptr_t) VirtualAlloc(NULL, bytes, + MEM_COMMIT | MEM_RESERVE, + PAGE_EXECUTE_READWRITE); + } + if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result"); + /* If I read the documentation correctly, this can */ + /* only happen if HBLKSIZE > 64k or not a power of 2. */ + if (GC_n_heap_bases >= MAX_HEAP_SECTS) ABORT("Too many heap sections"); + GC_heap_bases[GC_n_heap_bases++] = result; + return(result); +} + +void GC_win32_free_heap () +{ + if (GC_win32s) { + while (GC_n_heap_bases > 0) { + GlobalFree (GC_heap_bases[--GC_n_heap_bases]); + GC_heap_bases[GC_n_heap_bases] = 0; + } + } +} + + +# endif + +#ifdef USE_MUNMAP + +/* For now, this only works on some Unix-like systems. If you */ +/* have something else, don't define USE_MUNMAP. */ +/* We assume ANSI C to support this feature. */ +#include +#include +#include +#include +#include + +/* Compute a page aligned starting address for the unmap */ +/* operation on a block of size bytes starting at start. */ +/* Return 0 if the block is too small to make this feasible. */ +ptr_t GC_unmap_start(ptr_t start, word bytes) +{ + ptr_t result = start; + /* Round start to next page boundary. */ + result += GC_page_size - 1; + result = (ptr_t)((word)result & ~(GC_page_size - 1)); + if (result + GC_page_size > start + bytes) return 0; + return result; +} + +/* Compute end address for an unmap operation on the indicated */ +/* block. */ +ptr_t GC_unmap_end(ptr_t start, word bytes) +{ + ptr_t end_addr = start + bytes; + end_addr = (ptr_t)((word)end_addr & ~(GC_page_size - 1)); + return end_addr; +} + +/* We assume that GC_remap is called on exactly the same range */ +/* as a previous call to GC_unmap. It is safe to consistently */ +/* round the endpoints in both places. */ +void GC_unmap(ptr_t start, word bytes) +{ + ptr_t start_addr = GC_unmap_start(start, bytes); + ptr_t end_addr = GC_unmap_end(start, bytes); + word len = end_addr - start_addr; + if (0 == start_addr) return; + if (munmap(start_addr, len) != 0) ABORT("munmap failed"); + GC_unmapped_bytes += len; +} + + +void GC_remap(ptr_t start, word bytes) +{ + static int zero_descr = -1; + ptr_t start_addr = GC_unmap_start(start, bytes); + ptr_t end_addr = GC_unmap_end(start, bytes); + word len = end_addr - start_addr; + ptr_t result; + + if (-1 == zero_descr) zero_descr = open("/dev/zero", O_RDWR); + if (0 == start_addr) return; + result = mmap(start_addr, len, PROT_READ | PROT_WRITE | OPT_PROT_EXEC, + MAP_FIXED | MAP_PRIVATE, zero_descr, 0); + if (result != start_addr) { + ABORT("mmap remapping failed"); + } + GC_unmapped_bytes -= len; +} + +/* Two adjacent blocks have already been unmapped and are about to */ +/* be merged. Unmap the whole block. This typically requires */ +/* that we unmap a small section in the middle that was not previously */ +/* unmapped due to alignment constraints. */ +void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2) +{ + ptr_t start1_addr = GC_unmap_start(start1, bytes1); + ptr_t end1_addr = GC_unmap_end(start1, bytes1); + ptr_t start2_addr = GC_unmap_start(start2, bytes2); + ptr_t end2_addr = GC_unmap_end(start2, bytes2); + ptr_t start_addr = end1_addr; + ptr_t end_addr = start2_addr; + word len; + GC_ASSERT(start1 + bytes1 == start2); + if (0 == start1_addr) start_addr = GC_unmap_start(start1, bytes1 + bytes2); + if (0 == start2_addr) end_addr = GC_unmap_end(start1, bytes1 + bytes2); + if (0 == start_addr) return; + len = end_addr - start_addr; + if (len != 0 && munmap(start_addr, len) != 0) ABORT("munmap failed"); + GC_unmapped_bytes += len; +} + +#endif /* USE_MUNMAP */ + +/* Routine for pushing any additional roots. In THREADS */ +/* environment, this is also responsible for marking from */ +/* thread stacks. In the SRC_M3 case, it also handles */ +/* global variables. */ +#ifndef THREADS +void (*GC_push_other_roots)() = 0; +#else /* THREADS */ + +# ifdef PCR +PCR_ERes GC_push_thread_stack(PCR_Th_T *t, PCR_Any dummy) +{ + struct PCR_ThCtl_TInfoRep info; + PCR_ERes result; + + info.ti_stkLow = info.ti_stkHi = 0; + result = PCR_ThCtl_GetInfo(t, &info); + GC_push_all_stack((ptr_t)(info.ti_stkLow), (ptr_t)(info.ti_stkHi)); + return(result); +} + +/* Push the contents of an old object. We treat this as stack */ +/* data only becasue that makes it robust against mark stack */ +/* overflow. */ +PCR_ERes GC_push_old_obj(void *p, size_t size, PCR_Any data) +{ + GC_push_all_stack((ptr_t)p, (ptr_t)p + size); + return(PCR_ERes_okay); +} + + +void GC_default_push_other_roots() +{ + /* Traverse data allocated by previous memory managers. */ + { + extern struct PCR_MM_ProcsRep * GC_old_allocator; + + if ((*(GC_old_allocator->mmp_enumerate))(PCR_Bool_false, + GC_push_old_obj, 0) + != PCR_ERes_okay) { + ABORT("Old object enumeration failed"); + } + } + /* Traverse all thread stacks. */ + if (PCR_ERes_IsErr( + PCR_ThCtl_ApplyToAllOtherThreads(GC_push_thread_stack,0)) + || PCR_ERes_IsErr(GC_push_thread_stack(PCR_Th_CurrThread(), 0))) { + ABORT("Thread stack marking failed\n"); + } +} + +# endif /* PCR */ + +# ifdef SRC_M3 + +# ifdef ALL_INTERIOR_POINTERS + --> misconfigured +# endif + + +extern void ThreadF__ProcessStacks(); + +void GC_push_thread_stack(start, stop) +word start, stop; +{ + GC_push_all_stack((ptr_t)start, (ptr_t)stop + sizeof(word)); +} + +/* Push routine with M3 specific calling convention. */ +GC_m3_push_root(dummy1, p, dummy2, dummy3) +word *p; +ptr_t dummy1, dummy2; +int dummy3; +{ + word q = *p; + + if ((ptr_t)(q) >= GC_least_plausible_heap_addr + && (ptr_t)(q) < GC_greatest_plausible_heap_addr) { + GC_push_one_checked(q,FALSE); + } +} + +/* M3 set equivalent to RTHeap.TracedRefTypes */ +typedef struct { int elts[1]; } RefTypeSet; +RefTypeSet GC_TracedRefTypes = {{0x1}}; + +/* From finalize.c */ +extern void GC_push_finalizer_structures(); + +/* From stubborn.c: */ +# ifdef STUBBORN_ALLOC + extern GC_PTR * GC_changing_list_start; +# endif + + +void GC_default_push_other_roots() +{ + /* Use the M3 provided routine for finding static roots. */ + /* This is a bit dubious, since it presumes no C roots. */ + /* We handle the collector roots explicitly. */ + { +# ifdef STUBBORN_ALLOC + GC_push_one(GC_changing_list_start); +# endif + GC_push_finalizer_structures(); + RTMain__GlobalMapProc(GC_m3_push_root, 0, GC_TracedRefTypes); + } + if (GC_words_allocd > 0) { + ThreadF__ProcessStacks(GC_push_thread_stack); + } + /* Otherwise this isn't absolutely necessary, and we have */ + /* startup ordering problems. */ +} + +# endif /* SRC_M3 */ + +# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ + || defined(IRIX_THREADS) || defined(LINUX_THREADS) \ + || defined(IRIX_PCR_THREADS) + +extern void GC_push_all_stacks(); + +void GC_default_push_other_roots() +{ + GC_push_all_stacks(); +} + +# endif /* SOLARIS_THREADS || ... */ + +void (*GC_push_other_roots)() = GC_default_push_other_roots; + +#endif + +/* + * Routines for accessing dirty bits on virtual pages. + * We plan to eventaually implement four strategies for doing so: + * DEFAULT_VDB: A simple dummy implementation that treats every page + * as possibly dirty. This makes incremental collection + * useless, but the implementation is still correct. + * PCR_VDB: Use PPCRs virtual dirty bit facility. + * PROC_VDB: Use the /proc facility for reading dirty bits. Only + * works under some SVR4 variants. Even then, it may be + * too slow to be entirely satisfactory. Requires reading + * dirty bits for entire address space. Implementations tend + * to assume that the client is a (slow) debugger. + * MPROTECT_VDB:Protect pages and then catch the faults to keep track of + * dirtied pages. The implementation (and implementability) + * is highly system dependent. This usually fails when system + * calls write to a protected page. We prevent the read system + * call from doing so. It is the clients responsibility to + * make sure that other system calls are similarly protected + * or write only to the stack. + */ + +GC_bool GC_dirty_maintained = FALSE; + +# ifdef DEFAULT_VDB + +/* All of the following assume the allocation lock is held, and */ +/* signals are disabled. */ + +/* The client asserts that unallocated pages in the heap are never */ +/* written. */ + +/* Initialize virtual dirty bit implementation. */ +void GC_dirty_init() +{ + GC_dirty_maintained = TRUE; +} + +/* Retrieve system dirty bits for heap to a local buffer. */ +/* Restore the systems notion of which pages are dirty. */ +void GC_read_dirty() +{} + +/* Is the HBLKSIZE sized page at h marked dirty in the local buffer? */ +/* If the actual page size is different, this returns TRUE if any */ +/* of the pages overlapping h are dirty. This routine may err on the */ +/* side of labelling pages as dirty (and this implementation does). */ +/*ARGSUSED*/ +GC_bool GC_page_was_dirty(h) +struct hblk *h; +{ + return(TRUE); +} + +/* + * The following two routines are typically less crucial. They matter + * most with large dynamic libraries, or if we can't accurately identify + * stacks, e.g. under Solaris 2.X. Otherwise the following default + * versions are adequate. + */ + +/* Could any valid GC heap pointer ever have been written to this page? */ +/*ARGSUSED*/ +GC_bool GC_page_was_ever_dirty(h) +struct hblk *h; +{ + return(TRUE); +} + +/* Reset the n pages starting at h to "was never dirty" status. */ +void GC_is_fresh(h, n) +struct hblk *h; +word n; +{ +} + +/* A call hints that h is about to be written. */ +/* May speed up some dirty bit implementations. */ +/*ARGSUSED*/ +void GC_write_hint(h) +struct hblk *h; +{ +} + +# endif /* DEFAULT_VDB */ + + +# ifdef MPROTECT_VDB + +/* + * See DEFAULT_VDB for interface descriptions. + */ + +/* + * This implementation maintains dirty bits itself by catching write + * faults and keeping track of them. We assume nobody else catches + * SIGBUS or SIGSEGV. We assume no write faults occur in system calls + * except as a result of a read system call. This means clients must + * either ensure that system calls do not touch the heap, or must + * provide their own wrappers analogous to the one for read. + * We assume the page size is a multiple of HBLKSIZE. + * This implementation is currently SunOS 4.X and IRIX 5.X specific, though we + * tried to use portable code where easily possible. It is known + * not to work under a number of other systems. + */ + +# ifndef MSWIN32 + +# include +# include +# include + +# define PROTECT(addr, len) \ + if (mprotect((caddr_t)(addr), (int)(len), \ + PROT_READ | OPT_PROT_EXEC) < 0) { \ + ABORT("mprotect failed"); \ + } +# define UNPROTECT(addr, len) \ + if (mprotect((caddr_t)(addr), (int)(len), \ + PROT_WRITE | PROT_READ | OPT_PROT_EXEC ) < 0) { \ + ABORT("un-mprotect failed"); \ + } + +# else + +# include + + static DWORD protect_junk; +# define PROTECT(addr, len) \ + if (!VirtualProtect((addr), (len), PAGE_EXECUTE_READ, \ + &protect_junk)) { \ + DWORD last_error = GetLastError(); \ + GC_printf1("Last error code: %lx\n", last_error); \ + ABORT("VirtualProtect failed"); \ + } +# define UNPROTECT(addr, len) \ + if (!VirtualProtect((addr), (len), PAGE_EXECUTE_READWRITE, \ + &protect_junk)) { \ + ABORT("un-VirtualProtect failed"); \ + } + +# endif + +#if defined(SUNOS4) || defined(FREEBSD) + typedef void (* SIG_PF)(); +#endif +#if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX) + typedef void (* SIG_PF)(int); +#endif +#if defined(MSWIN32) + typedef LPTOP_LEVEL_EXCEPTION_FILTER SIG_PF; +# undef SIG_DFL +# define SIG_DFL (LPTOP_LEVEL_EXCEPTION_FILTER) (-1) +#endif + +#if defined(IRIX5) || defined(OSF1) + typedef void (* REAL_SIG_PF)(int, int, struct sigcontext *); +#endif +#if defined(SUNOS5SIGS) + typedef void (* REAL_SIG_PF)(int, struct siginfo *, void *); +#endif +#if defined(LINUX) +# include +# if (LINUX_VERSION_CODE >= 0x20100) && !defined(M68K) || defined(ALPHA) + typedef struct sigcontext s_c; +# else + typedef struct sigcontext_struct s_c; +# endif +# ifdef ALPHA + typedef void (* REAL_SIG_PF)(int, int, s_c *); + /* Retrieve fault address from sigcontext structure by decoding */ + /* instruction. */ + char * get_fault_addr(s_c *sc) { + unsigned instr; + word faultaddr; + + instr = *((unsigned *)(sc->sc_pc)); + faultaddr = sc->sc_regs[(instr >> 16) & 0x1f]; + faultaddr += (word) (((int)instr << 16) >> 16); + return (char *)faultaddr; + } +# else /* !ALPHA */ + typedef void (* REAL_SIG_PF)(int, s_c); +# endif /* !ALPHA */ +# endif + +SIG_PF GC_old_bus_handler; +SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */ + +/*ARGSUSED*/ +# if defined (SUNOS4) || defined(FREEBSD) + void GC_write_fault_handler(sig, code, scp, addr) + int sig, code; + struct sigcontext *scp; + char * addr; +# ifdef SUNOS4 +# define SIG_OK (sig == SIGSEGV || sig == SIGBUS) +# define CODE_OK (FC_CODE(code) == FC_PROT \ + || (FC_CODE(code) == FC_OBJERR \ + && FC_ERRNO(code) == FC_PROT)) +# endif +# ifdef FREEBSD +# define SIG_OK (sig == SIGBUS) +# define CODE_OK (code == BUS_PAGE_FAULT) +# endif +# endif +# if defined(IRIX5) || defined(OSF1) +# include + void GC_write_fault_handler(int sig, int code, struct sigcontext *scp) +# define SIG_OK (sig == SIGSEGV) +# ifdef OSF1 +# define CODE_OK (code == 2 /* experimentally determined */) +# endif +# ifdef IRIX5 +# define CODE_OK (code == EACCES) +# endif +# endif +# if defined(LINUX) +# ifdef ALPHA + void GC_write_fault_handler(int sig, int code, s_c * sc) +# else + void GC_write_fault_handler(int sig, s_c sc) +# endif +# define SIG_OK (sig == SIGSEGV) +# define CODE_OK TRUE + /* Empirically c.trapno == 14, but is that useful? */ + /* We assume Intel architecture, so alignment */ + /* faults are not possible. */ +# endif +# if defined(SUNOS5SIGS) + void GC_write_fault_handler(int sig, struct siginfo *scp, void * context) +# define SIG_OK (sig == SIGSEGV) +# define CODE_OK (scp -> si_code == SEGV_ACCERR) +# endif +# if defined(MSWIN32) + LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info) +# define SIG_OK (exc_info -> ExceptionRecord -> ExceptionCode == \ + EXCEPTION_ACCESS_VIOLATION) +# define CODE_OK (exc_info -> ExceptionRecord -> ExceptionInformation[0] == 1) + /* Write fault */ +# endif +{ + register unsigned i; +# ifdef IRIX5 + char * addr = (char *) (size_t) (scp -> sc_badvaddr); +# endif +# if defined(OSF1) && defined(ALPHA) + char * addr = (char *) (scp -> sc_traparg_a0); +# endif +# ifdef SUNOS5SIGS + char * addr = (char *) (scp -> si_addr); +# endif +# ifdef LINUX +# ifdef I386 + char * addr = (char *) (sc.cr2); +# else +# if defined(M68K) + char * addr = NULL; + + struct sigcontext *scp = (struct sigcontext *)(&sc); + + int format = (scp->sc_formatvec >> 12) & 0xf; + unsigned long *framedata = (unsigned long *)(scp + 1); + unsigned long ea; + + if (format == 0xa || format == 0xb) { + /* 68020/030 */ + ea = framedata[2]; + } else if (format == 7) { + /* 68040 */ + ea = framedata[3]; + } else if (format == 4) { + /* 68060 */ + ea = framedata[0]; + if (framedata[1] & 0x08000000) { + /* correct addr on misaligned access */ + ea = (ea+4095)&(~4095); + } + } + addr = (char *)ea; +# else +# ifdef ALPHA + char * addr = get_fault_addr(sc); +# else + --> architecture not supported +# endif +# endif +# endif +# endif +# if defined(MSWIN32) + char * addr = (char *) (exc_info -> ExceptionRecord + -> ExceptionInformation[1]); +# define sig SIGSEGV +# endif + + if (SIG_OK && CODE_OK) { + register struct hblk * h = + (struct hblk *)((word)addr & ~(GC_page_size-1)); + GC_bool in_allocd_block; + +# ifdef SUNOS5SIGS + /* Address is only within the correct physical page. */ + in_allocd_block = FALSE; + for (i = 0; i < divHBLKSZ(GC_page_size); i++) { + if (HDR(h+i) != 0) { + in_allocd_block = TRUE; + } + } +# else + in_allocd_block = (HDR(addr) != 0); +# endif + if (!in_allocd_block) { + /* Heap blocks now begin and end on page boundaries */ + SIG_PF old_handler; + + if (sig == SIGSEGV) { + old_handler = GC_old_segv_handler; + } else { + old_handler = GC_old_bus_handler; + } + if (old_handler == SIG_DFL) { +# ifndef MSWIN32 + GC_err_printf1("Segfault at 0x%lx\n", addr); + ABORT("Unexpected bus error or segmentation fault"); +# else + return(EXCEPTION_CONTINUE_SEARCH); +# endif + } else { +# if defined (SUNOS4) || defined(FREEBSD) + (*old_handler) (sig, code, scp, addr); + return; +# endif +# if defined (SUNOS5SIGS) + (*(REAL_SIG_PF)old_handler) (sig, scp, context); + return; +# endif +# if defined (LINUX) +# ifdef ALPHA + (*(REAL_SIG_PF)old_handler) (sig, code, sc); +# else + (*(REAL_SIG_PF)old_handler) (sig, sc); +# endif + return; +# endif +# if defined (IRIX5) || defined(OSF1) + (*(REAL_SIG_PF)old_handler) (sig, code, scp); + return; +# endif +# ifdef MSWIN32 + return((*old_handler)(exc_info)); +# endif + } + } + for (i = 0; i < divHBLKSZ(GC_page_size); i++) { + register int index = PHT_HASH(h+i); + + set_pht_entry_from_index(GC_dirty_pages, index); + } + UNPROTECT(h, GC_page_size); +# if defined(OSF1) || defined(LINUX) + /* These reset the signal handler each time by default. */ + signal(SIGSEGV, (SIG_PF) GC_write_fault_handler); +# endif + /* The write may not take place before dirty bits are read. */ + /* But then we'll fault again ... */ +# ifdef MSWIN32 + return(EXCEPTION_CONTINUE_EXECUTION); +# else + return; +# endif + } +#ifdef MSWIN32 + return EXCEPTION_CONTINUE_SEARCH; +#else + GC_err_printf1("Segfault at 0x%lx\n", addr); + ABORT("Unexpected bus error or segmentation fault"); +#endif +} + +/* + * We hold the allocation lock. We expect block h to be written + * shortly. + */ +void GC_write_hint(h) +struct hblk *h; +{ + register struct hblk * h_trunc; + register unsigned i; + register GC_bool found_clean; + + if (!GC_dirty_maintained) return; + h_trunc = (struct hblk *)((word)h & ~(GC_page_size-1)); + found_clean = FALSE; + for (i = 0; i < divHBLKSZ(GC_page_size); i++) { + register int index = PHT_HASH(h_trunc+i); + + if (!get_pht_entry_from_index(GC_dirty_pages, index)) { + found_clean = TRUE; + set_pht_entry_from_index(GC_dirty_pages, index); + } + } + if (found_clean) { + UNPROTECT(h_trunc, GC_page_size); + } +} + +void GC_dirty_init() +{ +#if defined(SUNOS5SIGS) || defined(IRIX5) /* || defined(OSF1) */ + struct sigaction act, oldact; +# ifdef IRIX5 + act.sa_flags = SA_RESTART; + act.sa_handler = GC_write_fault_handler; +# else + act.sa_flags = SA_RESTART | SA_SIGINFO; + act.sa_sigaction = GC_write_fault_handler; +# endif + (void)sigemptyset(&act.sa_mask); +#endif +# ifdef PRINTSTATS + GC_printf0("Inititalizing mprotect virtual dirty bit implementation\n"); +# endif + GC_dirty_maintained = TRUE; + if (GC_page_size % HBLKSIZE != 0) { + GC_err_printf0("Page size not multiple of HBLKSIZE\n"); + ABORT("Page size not multiple of HBLKSIZE"); + } +# if defined(SUNOS4) || defined(FREEBSD) + GC_old_bus_handler = signal(SIGBUS, GC_write_fault_handler); + if (GC_old_bus_handler == SIG_IGN) { + GC_err_printf0("Previously ignored bus error!?"); + GC_old_bus_handler = SIG_DFL; + } + if (GC_old_bus_handler != SIG_DFL) { +# ifdef PRINTSTATS + GC_err_printf0("Replaced other SIGBUS handler\n"); +# endif + } +# endif +# if defined(OSF1) || defined(SUNOS4) || defined(LINUX) + GC_old_segv_handler = signal(SIGSEGV, (SIG_PF)GC_write_fault_handler); + if (GC_old_segv_handler == SIG_IGN) { + GC_err_printf0("Previously ignored segmentation violation!?"); + GC_old_segv_handler = SIG_DFL; + } + if (GC_old_segv_handler != SIG_DFL) { +# ifdef PRINTSTATS + GC_err_printf0("Replaced other SIGSEGV handler\n"); +# endif + } +# endif +# if defined(SUNOS5SIGS) || defined(IRIX5) +# if defined(IRIX_THREADS) || defined(IRIX_PCR_THREADS) + sigaction(SIGSEGV, 0, &oldact); + sigaction(SIGSEGV, &act, 0); +# else + sigaction(SIGSEGV, &act, &oldact); +# endif +# if defined(_sigargs) + /* This is Irix 5.x, not 6.x. Irix 5.x does not have */ + /* sa_sigaction. */ + GC_old_segv_handler = oldact.sa_handler; +# else /* Irix 6.x or SUNOS5SIGS */ + if (oldact.sa_flags & SA_SIGINFO) { + GC_old_segv_handler = (SIG_PF)(oldact.sa_sigaction); + } else { + GC_old_segv_handler = oldact.sa_handler; + } +# endif + if (GC_old_segv_handler == SIG_IGN) { + GC_err_printf0("Previously ignored segmentation violation!?"); + GC_old_segv_handler = SIG_DFL; + } + if (GC_old_segv_handler != SIG_DFL) { +# ifdef PRINTSTATS + GC_err_printf0("Replaced other SIGSEGV handler\n"); +# endif + } +# endif +# if defined(MSWIN32) + GC_old_segv_handler = SetUnhandledExceptionFilter(GC_write_fault_handler); + if (GC_old_segv_handler != NULL) { +# ifdef PRINTSTATS + GC_err_printf0("Replaced other UnhandledExceptionFilter\n"); +# endif + } else { + GC_old_segv_handler = SIG_DFL; + } +# endif +} + + + +void GC_protect_heap() +{ + ptr_t start; + word len; + unsigned i; + + for (i = 0; i < GC_n_heap_sects; i++) { + start = GC_heap_sects[i].hs_start; + len = GC_heap_sects[i].hs_bytes; + PROTECT(start, len); + } +} + +/* We assume that either the world is stopped or its OK to lose dirty */ +/* bits while this is happenning (as in GC_enable_incremental). */ +void GC_read_dirty() +{ + BCOPY((word *)GC_dirty_pages, GC_grungy_pages, + (sizeof GC_dirty_pages)); + BZERO((word *)GC_dirty_pages, (sizeof GC_dirty_pages)); + GC_protect_heap(); +} + +GC_bool GC_page_was_dirty(h) +struct hblk * h; +{ + register word index = PHT_HASH(h); + + return(HDR(h) == 0 || get_pht_entry_from_index(GC_grungy_pages, index)); +} + +/* + * Acquiring the allocation lock here is dangerous, since this + * can be called from within GC_call_with_alloc_lock, and the cord + * package does so. On systems that allow nested lock acquisition, this + * happens to work. + * On other systems, SET_LOCK_HOLDER and friends must be suitably defined. + */ + +void GC_begin_syscall() +{ + if (!I_HOLD_LOCK()) LOCK(); +} + +void GC_end_syscall() +{ + if (!I_HOLD_LOCK()) UNLOCK(); +} + +void GC_unprotect_range(addr, len) +ptr_t addr; +word len; +{ + struct hblk * start_block; + struct hblk * end_block; + register struct hblk *h; + ptr_t obj_start; + + if (!GC_incremental) return; + obj_start = GC_base(addr); + if (obj_start == 0) return; + if (GC_base(addr + len - 1) != obj_start) { + ABORT("GC_unprotect_range(range bigger than object)"); + } + start_block = (struct hblk *)((word)addr & ~(GC_page_size - 1)); + end_block = (struct hblk *)((word)(addr + len - 1) & ~(GC_page_size - 1)); + end_block += GC_page_size/HBLKSIZE - 1; + for (h = start_block; h <= end_block; h++) { + register word index = PHT_HASH(h); + + set_pht_entry_from_index(GC_dirty_pages, index); + } + UNPROTECT(start_block, + ((ptr_t)end_block - (ptr_t)start_block) + HBLKSIZE); +} + +#ifndef MSWIN32 +/* Replacement for UNIX system call. */ +/* Other calls that write to the heap */ +/* should be handled similarly. */ +# if defined(__STDC__) && !defined(SUNOS4) +# include + ssize_t read(int fd, void *buf, size_t nbyte) +# else +# ifndef LINT + int read(fd, buf, nbyte) +# else + int GC_read(fd, buf, nbyte) +# endif + int fd; + char *buf; + int nbyte; +# endif +{ + int result; + + GC_begin_syscall(); + GC_unprotect_range(buf, (word)nbyte); +# ifdef IRIX5 + /* Indirect system call may not always be easily available. */ + /* We could call _read, but that would interfere with the */ + /* libpthread interception of read. */ + { + struct iovec iov; + + iov.iov_base = buf; + iov.iov_len = nbyte; + result = readv(fd, &iov, 1); + } +# else + result = syscall(SYS_read, fd, buf, nbyte); +# endif + GC_end_syscall(); + return(result); +} +#endif /* !MSWIN32 */ + +/*ARGSUSED*/ +GC_bool GC_page_was_ever_dirty(h) +struct hblk *h; +{ + return(TRUE); +} + +/* Reset the n pages starting at h to "was never dirty" status. */ +/*ARGSUSED*/ +void GC_is_fresh(h, n) +struct hblk *h; +word n; +{ +} + +# endif /* MPROTECT_VDB */ + +# ifdef PROC_VDB + +/* + * See DEFAULT_VDB for interface descriptions. + */ + +/* + * This implementaion assumes a Solaris 2.X like /proc pseudo-file-system + * from which we can read page modified bits. This facility is far from + * optimal (e.g. we would like to get the info for only some of the + * address space), but it avoids intercepting system calls. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define INITIAL_BUF_SZ 4096 +word GC_proc_buf_size = INITIAL_BUF_SZ; +char *GC_proc_buf; + +#ifdef SOLARIS_THREADS +/* We don't have exact sp values for threads. So we count on */ +/* occasionally declaring stack pages to be fresh. Thus we */ +/* need a real implementation of GC_is_fresh. We can't clear */ +/* entries in GC_written_pages, since that would declare all */ +/* pages with the given hash address to be fresh. */ +# define MAX_FRESH_PAGES 8*1024 /* Must be power of 2 */ + struct hblk ** GC_fresh_pages; /* A direct mapped cache. */ + /* Collisions are dropped. */ + +# define FRESH_PAGE_SLOT(h) (divHBLKSZ((word)(h)) & (MAX_FRESH_PAGES-1)) +# define ADD_FRESH_PAGE(h) \ + GC_fresh_pages[FRESH_PAGE_SLOT(h)] = (h) +# define PAGE_IS_FRESH(h) \ + (GC_fresh_pages[FRESH_PAGE_SLOT(h)] == (h) && (h) != 0) +#endif + +/* Add all pages in pht2 to pht1 */ +void GC_or_pages(pht1, pht2) +page_hash_table pht1, pht2; +{ + register int i; + + for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i]; +} + +int GC_proc_fd; + +void GC_dirty_init() +{ + int fd; + char buf[30]; + + GC_dirty_maintained = TRUE; + if (GC_words_allocd != 0 || GC_words_allocd_before_gc != 0) { + register int i; + + for (i = 0; i < PHT_SIZE; i++) GC_written_pages[i] = (word)(-1); +# ifdef PRINTSTATS + GC_printf1("Allocated words:%lu:all pages may have been written\n", + (unsigned long) + (GC_words_allocd + GC_words_allocd_before_gc)); +# endif + } + sprintf(buf, "/proc/%d", getpid()); + fd = open(buf, O_RDONLY); + if (fd < 0) { + ABORT("/proc open failed"); + } + GC_proc_fd = syscall(SYS_ioctl, fd, PIOCOPENPD, 0); + close(fd); + if (GC_proc_fd < 0) { + ABORT("/proc ioctl failed"); + } + GC_proc_buf = GC_scratch_alloc(GC_proc_buf_size); +# ifdef SOLARIS_THREADS + GC_fresh_pages = (struct hblk **) + GC_scratch_alloc(MAX_FRESH_PAGES * sizeof (struct hblk *)); + if (GC_fresh_pages == 0) { + GC_err_printf0("No space for fresh pages\n"); + EXIT(); + } + BZERO(GC_fresh_pages, MAX_FRESH_PAGES * sizeof (struct hblk *)); +# endif +} + +/* Ignore write hints. They don't help us here. */ +/*ARGSUSED*/ +void GC_write_hint(h) +struct hblk *h; +{ +} + +#ifdef SOLARIS_THREADS +# define READ(fd,buf,nbytes) syscall(SYS_read, fd, buf, nbytes) +#else +# define READ(fd,buf,nbytes) read(fd, buf, nbytes) +#endif + +void GC_read_dirty() +{ + unsigned long ps, np; + int nmaps; + ptr_t vaddr; + struct prasmap * map; + char * bufp; + ptr_t current_addr, limit; + int i; +int dummy; + + BZERO(GC_grungy_pages, (sizeof GC_grungy_pages)); + + bufp = GC_proc_buf; + if (READ(GC_proc_fd, bufp, GC_proc_buf_size) <= 0) { +# ifdef PRINTSTATS + GC_printf1("/proc read failed: GC_proc_buf_size = %lu\n", + GC_proc_buf_size); +# endif + { + /* Retry with larger buffer. */ + word new_size = 2 * GC_proc_buf_size; + char * new_buf = GC_scratch_alloc(new_size); + + if (new_buf != 0) { + GC_proc_buf = bufp = new_buf; + GC_proc_buf_size = new_size; + } + if (syscall(SYS_read, GC_proc_fd, bufp, GC_proc_buf_size) <= 0) { + WARN("Insufficient space for /proc read\n", 0); + /* Punt: */ + memset(GC_grungy_pages, 0xff, sizeof (page_hash_table)); + memset(GC_written_pages, 0xff, sizeof(page_hash_table)); +# ifdef SOLARIS_THREADS + BZERO(GC_fresh_pages, + MAX_FRESH_PAGES * sizeof (struct hblk *)); +# endif + return; + } + } + } + /* Copy dirty bits into GC_grungy_pages */ + nmaps = ((struct prpageheader *)bufp) -> pr_nmap; + /* printf( "nmaps = %d, PG_REFERENCED = %d, PG_MODIFIED = %d\n", + nmaps, PG_REFERENCED, PG_MODIFIED); */ + bufp = bufp + sizeof(struct prpageheader); + for (i = 0; i < nmaps; i++) { + map = (struct prasmap *)bufp; + vaddr = (ptr_t)(map -> pr_vaddr); + ps = map -> pr_pagesize; + np = map -> pr_npage; + /* printf("vaddr = 0x%X, ps = 0x%X, np = 0x%X\n", vaddr, ps, np); */ + limit = vaddr + ps * np; + bufp += sizeof (struct prasmap); + for (current_addr = vaddr; + current_addr < limit; current_addr += ps){ + if ((*bufp++) & PG_MODIFIED) { + register struct hblk * h = (struct hblk *) current_addr; + + while ((ptr_t)h < current_addr + ps) { + register word index = PHT_HASH(h); + + set_pht_entry_from_index(GC_grungy_pages, index); +# ifdef SOLARIS_THREADS + { + register int slot = FRESH_PAGE_SLOT(h); + + if (GC_fresh_pages[slot] == h) { + GC_fresh_pages[slot] = 0; + } + } +# endif + h++; + } + } + } + bufp += sizeof(long) - 1; + bufp = (char *)((unsigned long)bufp & ~(sizeof(long)-1)); + } + /* Update GC_written_pages. */ + GC_or_pages(GC_written_pages, GC_grungy_pages); +# ifdef SOLARIS_THREADS + /* Make sure that old stacks are considered completely clean */ + /* unless written again. */ + GC_old_stacks_are_fresh(); +# endif +} + +#undef READ + +GC_bool GC_page_was_dirty(h) +struct hblk *h; +{ + register word index = PHT_HASH(h); + register GC_bool result; + + result = get_pht_entry_from_index(GC_grungy_pages, index); +# ifdef SOLARIS_THREADS + if (result && PAGE_IS_FRESH(h)) result = FALSE; + /* This happens only if page was declared fresh since */ + /* the read_dirty call, e.g. because it's in an unused */ + /* thread stack. It's OK to treat it as clean, in */ + /* that case. And it's consistent with */ + /* GC_page_was_ever_dirty. */ +# endif + return(result); +} + +GC_bool GC_page_was_ever_dirty(h) +struct hblk *h; +{ + register word index = PHT_HASH(h); + register GC_bool result; + + result = get_pht_entry_from_index(GC_written_pages, index); +# ifdef SOLARIS_THREADS + if (result && PAGE_IS_FRESH(h)) result = FALSE; +# endif + return(result); +} + +/* Caller holds allocation lock. */ +void GC_is_fresh(h, n) +struct hblk *h; +word n; +{ + + register word index; + +# ifdef SOLARIS_THREADS + register word i; + + if (GC_fresh_pages != 0) { + for (i = 0; i < n; i++) { + ADD_FRESH_PAGE(h + i); + } + } +# endif +} + +# endif /* PROC_VDB */ + + +# ifdef PCR_VDB + +# include "vd/PCR_VD.h" + +# define NPAGES (32*1024) /* 128 MB */ + +PCR_VD_DB GC_grungy_bits[NPAGES]; + +ptr_t GC_vd_base; /* Address corresponding to GC_grungy_bits[0] */ + /* HBLKSIZE aligned. */ + +void GC_dirty_init() +{ + GC_dirty_maintained = TRUE; + /* For the time being, we assume the heap generally grows up */ + GC_vd_base = GC_heap_sects[0].hs_start; + if (GC_vd_base == 0) { + ABORT("Bad initial heap segment"); + } + if (PCR_VD_Start(HBLKSIZE, GC_vd_base, NPAGES*HBLKSIZE) + != PCR_ERes_okay) { + ABORT("dirty bit initialization failed"); + } +} + +void GC_read_dirty() +{ + /* lazily enable dirty bits on newly added heap sects */ + { + static int onhs = 0; + int nhs = GC_n_heap_sects; + for( ; onhs < nhs; onhs++ ) { + PCR_VD_WriteProtectEnable( + GC_heap_sects[onhs].hs_start, + GC_heap_sects[onhs].hs_bytes ); + } + } + + + if (PCR_VD_Clear(GC_vd_base, NPAGES*HBLKSIZE, GC_grungy_bits) + != PCR_ERes_okay) { + ABORT("dirty bit read failed"); + } +} + +GC_bool GC_page_was_dirty(h) +struct hblk *h; +{ + if((ptr_t)h < GC_vd_base || (ptr_t)h >= GC_vd_base + NPAGES*HBLKSIZE) { + return(TRUE); + } + return(GC_grungy_bits[h - (struct hblk *)GC_vd_base] & PCR_VD_DB_dirtyBit); +} + +/*ARGSUSED*/ +void GC_write_hint(h) +struct hblk *h; +{ + PCR_VD_WriteProtectDisable(h, HBLKSIZE); + PCR_VD_WriteProtectEnable(h, HBLKSIZE); +} + +# endif /* PCR_VDB */ + +/* + * Call stack save code for debugging. + * Should probably be in mach_dep.c, but that requires reorganization. + */ +#if defined(SPARC) && !defined(LINUX) +# if defined(SUNOS4) +# include +# else +# if defined (DRSNX) +# include +# else +# if defined(OPENBSD) +# include +# else +# include +# endif +# endif +# endif +# if NARGS > 6 + --> We only know how to to get the first 6 arguments +# endif + +#ifdef SAVE_CALL_CHAIN +/* Fill in the pc and argument information for up to NFRAMES of my */ +/* callers. Ignore my frame and my callers frame. */ + +#ifdef OPENBSD +# define FR_SAVFP fr_fp +# define FR_SAVPC fr_pc +#else +# define FR_SAVFP fr_savfp +# define FR_SAVPC fr_savpc +#endif + +void GC_save_callers (info) +struct callinfo info[NFRAMES]; +{ + struct frame *frame; + struct frame *fp; + int nframes = 0; + word GC_save_regs_in_stack(); + + frame = (struct frame *) GC_save_regs_in_stack (); + + for (fp = frame -> FR_SAVFP; fp != 0 && nframes < NFRAMES; + fp = fp -> FR_SAVFP, nframes++) { + register int i; + + info[nframes].ci_pc = fp->FR_SAVPC; + for (i = 0; i < NARGS; i++) { + info[nframes].ci_arg[i] = ~(fp->fr_arg[i]); + } + } + if (nframes < NFRAMES) info[nframes].ci_pc = 0; +} + +#endif /* SAVE_CALL_CHAIN */ +#endif /* SPARC */ + + + diff --git a/support/gc/pc_excludes b/support/gc/pc_excludes new file mode 100644 index 00000000..52da4311 --- /dev/null +++ b/support/gc/pc_excludes @@ -0,0 +1,15 @@ +solaris_threads.c +pcr_interface.c +real_malloc.c +mips_mach_dep.s +rs6000_mach_dep.s +alpha_mach_dep.s +sparc_mach_dep.s +PCR-Makefile +setjmp_t.c +callprocs +gc.man +pc_excludes +barrett_diagram +include/gc_c++.h +include/gc_inline.h \ No newline at end of file diff --git a/support/gc/pcr_interface.c b/support/gc/pcr_interface.c new file mode 100644 index 00000000..4c950933 --- /dev/null +++ b/support/gc/pcr_interface.c @@ -0,0 +1,173 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, February 7, 1996 11:09 am PST */ +# include "gc_priv.h" + +# ifdef PCR +/* + * Note that POSIX PCR requires an ANSI C compiler. Hence we are allowed + * to make the same assumption here. + * We wrap all of the allocator functions to avoid questions of + * compatibility between the prototyped and nonprototyped versions of the f + */ +# include "config/PCR_StdTypes.h" +# include "mm/PCR_MM.h" +# include + +# define MY_MAGIC 17L +# define MY_DEBUGMAGIC 42L + +void * GC_AllocProc(size_t size, PCR_Bool ptrFree, PCR_Bool clear ) +{ + if (ptrFree) { + void * result = (void *)GC_malloc_atomic(size); + if (clear && result != 0) BZERO(result, size); + return(result); + } else { + return((void *)GC_malloc(size)); + } +} + +void * GC_DebugAllocProc(size_t size, PCR_Bool ptrFree, PCR_Bool clear ) +{ + if (ptrFree) { + void * result = (void *)GC_debug_malloc_atomic(size, __FILE__, + __LINE__); + if (clear && result != 0) BZERO(result, size); + return(result); + } else { + return((void *)GC_debug_malloc(size, __FILE__, __LINE__)); + } +} + +# define GC_ReallocProc GC_realloc +void * GC_DebugReallocProc(void * old_object, size_t new_size_in_bytes) +{ + return(GC_debug_realloc(old_object, new_size_in_bytes, __FILE__, __LINE__)); +} + +# define GC_FreeProc GC_free +# define GC_DebugFreeProc GC_debug_free + +typedef struct { + PCR_ERes (*ed_proc)(void *p, size_t size, PCR_Any data); + GC_bool ed_pointerfree; + PCR_ERes ed_fail_code; + PCR_Any ed_client_data; +} enumerate_data; + +void GC_enumerate_block(h, ed) +register struct hblk *h; +enumerate_data * ed; +{ + register hdr * hhdr; + register int sz; + word *p; + word * lim; + + hhdr = HDR(h); + sz = hhdr -> hb_sz; + if (sz >= 0 && ed -> ed_pointerfree + || sz <= 0 && !(ed -> ed_pointerfree)) return; + if (sz < 0) sz = -sz; + lim = (word *)(h+1) - sz; + p = (word *)h; + do { + if (PCR_ERes_IsErr(ed -> ed_fail_code)) return; + ed -> ed_fail_code = + (*(ed -> ed_proc))(p, WORDS_TO_BYTES(sz), ed -> ed_client_data); + p+= sz; + } while (p <= lim); +} + +struct PCR_MM_ProcsRep * GC_old_allocator = 0; + +PCR_ERes GC_EnumerateProc( + PCR_Bool ptrFree, + PCR_ERes (*proc)(void *p, size_t size, PCR_Any data), + PCR_Any data +) +{ + enumerate_data ed; + + ed.ed_proc = proc; + ed.ed_pointerfree = ptrFree; + ed.ed_fail_code = PCR_ERes_okay; + ed.ed_client_data = data; + GC_apply_to_all_blocks(GC_enumerate_block, &ed); + if (ed.ed_fail_code != PCR_ERes_okay) { + return(ed.ed_fail_code); + } else { + /* Also enumerate objects allocated by my predecessors */ + return((*(GC_old_allocator->mmp_enumerate))(ptrFree, proc, data)); + } +} + +void GC_DummyFreeProc(void *p) {} + +void GC_DummyShutdownProc(void) {} + +struct PCR_MM_ProcsRep GC_Rep = { + MY_MAGIC, + GC_AllocProc, + GC_ReallocProc, + GC_DummyFreeProc, /* mmp_free */ + GC_FreeProc, /* mmp_unsafeFree */ + GC_EnumerateProc, + GC_DummyShutdownProc /* mmp_shutdown */ +}; + +struct PCR_MM_ProcsRep GC_DebugRep = { + MY_DEBUGMAGIC, + GC_DebugAllocProc, + GC_DebugReallocProc, + GC_DummyFreeProc, /* mmp_free */ + GC_DebugFreeProc, /* mmp_unsafeFree */ + GC_EnumerateProc, + GC_DummyShutdownProc /* mmp_shutdown */ +}; + +GC_bool GC_use_debug = 0; + +void GC_pcr_install() +{ + PCR_MM_Install((GC_use_debug? &GC_DebugRep : &GC_Rep), &GC_old_allocator); +} + +PCR_ERes +PCR_GC_Setup(void) +{ + return PCR_ERes_okay; +} + +PCR_ERes +PCR_GC_Run(void) +{ + + if( !PCR_Base_TestPCRArg("-nogc") ) { + GC_quiet = ( PCR_Base_TestPCRArg("-gctrace") ? 0 : 1 ); + GC_use_debug = (GC_bool)PCR_Base_TestPCRArg("-debug_alloc"); + GC_init(); + if( !PCR_Base_TestPCRArg("-nogc_incremental") ) { + /* + * awful hack to test whether VD is implemented ... + */ + if( PCR_VD_Start( 0, NIL, 0) != PCR_ERes_FromErr(ENOSYS) ) { + GC_enable_incremental(); + } + } + } + return PCR_ERes_okay; +} + +# endif diff --git a/support/gc/ptr_chck.c b/support/gc/ptr_chck.c new file mode 100644 index 00000000..f3451ee6 --- /dev/null +++ b/support/gc/ptr_chck.c @@ -0,0 +1,326 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, September 19, 1995 1:26 pm PDT */ + +#include "gc_priv.h" +#include "gc_mark.h" + +#ifdef __STDC__ +void GC_default_same_obj_print_proc(GC_PTR p, GC_PTR q) +#else +void GC_default_same_obj_print_proc (p, q) +GC_PTR p, q; +#endif +{ + GC_err_printf2("0x%lx and 0x%lx are not in the same object\n", + (unsigned long)p, (unsigned long)q); + ABORT("GC_same_obj test failed"); +} + +void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR, GC_PTR)) + = GC_default_same_obj_print_proc; + +/* Check that p and q point to the same object. Call */ +/* *GC_same_obj_print_proc if they don't. */ +/* Returns the first argument. (Return value may be hard */ +/* to use,due to typing issues. But if we had a suitable */ +/* preprocessor ...) */ +/* Succeeds if neither p nor q points to the heap. */ +/* We assume this is performance critical. (It shouldn't */ +/* be called by production code, but this can easily make */ +/* debugging intolerably slow.) */ +#ifdef __STDC__ + GC_PTR GC_same_obj(register void *p, register void *q) +#else + GC_PTR GC_same_obj(p, q) + register char *p, *q; +#endif +{ + register struct hblk *h; + register hdr *hhdr; + register ptr_t base, limit; + register word sz; + + if (!GC_is_initialized) GC_init(); + hhdr = HDR((word)p); + if (hhdr == 0) { + if (divHBLKSZ((word)p) != divHBLKSZ((word)q) + && HDR((word)q) != 0) { + goto fail; + } + return(p); + } + /* If it's a pointer to the middle of a large object, move it */ + /* to the beginning. */ + if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + h = HBLKPTR(p) - (word)hhdr; + hhdr = HDR(h); + while (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + h = FORWARDED_ADDR(h, hhdr); + hhdr = HDR(h); + } + limit = (ptr_t)((word *)h + HDR_WORDS + hhdr -> hb_sz); + if ((ptr_t)p >= limit || (ptr_t)q >= limit || (ptr_t)q < (ptr_t)h ) { + goto fail; + } + return(p); + } + sz = WORDS_TO_BYTES(hhdr -> hb_sz); + if (sz > WORDS_TO_BYTES(MAXOBJSZ)) { + base = (ptr_t)HBLKPTR(p); + limit = base + sz; + if ((ptr_t)p >= limit) { + goto fail; + } + } else { +# ifdef ALL_INTERIOR_POINTERS + register map_entry_type map_entry; + register int pdispl; + + pdispl = HBLKDISPL(p); + map_entry = MAP_ENTRY((hhdr -> hb_map), pdispl); + if (map_entry == OBJ_INVALID) { + goto fail; + } else { + base = (char *)((word)p & ~(WORDS_TO_BYTES(1) - 1)); + base -= WORDS_TO_BYTES(map_entry); + } +# else + register int offset = HBLKDISPL(p) - HDR_BYTES; + register word correction = offset % sz; + + if (HBLKPTR(p) != HBLKPTR(q)) { + /* The following computation otherwise fails in this case */ + goto fail; + } + base = (ptr_t)p - correction; +# endif + limit = base + sz; + } + /* [base, limit) delimits the object containing p, if any. */ + /* If p is not inside a valid object, then either q is */ + /* also outside any valid object, or it is outside */ + /* [base, limit). */ + if ((ptr_t)q >= limit || (ptr_t)q < base) { + goto fail; + } + return(p); +fail: + (*GC_same_obj_print_proc)((ptr_t)p, (ptr_t)q); + return(p); +} + +#ifdef __STDC__ +void GC_default_is_valid_displacement_print_proc (GC_PTR p) +#else +void GC_default_is_valid_displacement_print_proc (p) +GC_PTR p; +#endif +{ + GC_err_printf1("0x%lx does not point to valid object displacement\n", + (unsigned long)p); + ABORT("GC_is_valid_displacement test failed"); +} + +void (*GC_is_valid_displacement_print_proc) GC_PROTO((GC_PTR)) = + GC_default_is_valid_displacement_print_proc; + +/* Check that if p is a pointer to a heap page, then it points to */ +/* a valid displacement within a heap object. */ +/* Uninteresting with ALL_INTERIOR_POINTERS. */ +/* Always returns its argument. */ +/* Note that we don't lock, since nothing relevant about the header */ +/* should change while we have a valid object pointer to the block. */ +#ifdef __STDC__ + void * GC_is_valid_displacement(void *p) +#else + char *GC_is_valid_displacement(p) + char *p; +#endif +{ + register hdr *hhdr; + register word pdispl; + register struct hblk *h; + register map_entry_type map_entry; + register word sz; + + if (!GC_is_initialized) GC_init(); + hhdr = HDR((word)p); + if (hhdr == 0) return(p); + h = HBLKPTR(p); +# ifdef ALL_INTERIOR_POINTERS + while (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + h = FORWARDED_ADDR(h, hhdr); + hhdr = HDR(h); + } +# endif + if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + goto fail; + } + sz = WORDS_TO_BYTES(hhdr -> hb_sz); + pdispl = HBLKDISPL(p); + map_entry = MAP_ENTRY((hhdr -> hb_map), pdispl); + if (map_entry == OBJ_INVALID + || sz > MAXOBJSZ && (ptr_t)p >= (ptr_t)h + sz) { + goto fail; + } + return(p); +fail: + (*GC_is_valid_displacement_print_proc)((ptr_t)p); + return(p); +} + +#ifdef __STDC__ +void GC_default_is_visible_print_proc(GC_PTR p) +#else +void GC_default_is_visible_print_proc(p) +GC_PTR p; +#endif +{ + GC_err_printf1("0x%lx is not a GC visible pointer location\n", + (unsigned long)p); + ABORT("GC_is_visible test failed"); +} + +void (*GC_is_visible_print_proc) GC_PROTO((GC_PTR p)) = + GC_default_is_visible_print_proc; + +/* Could p be a stack address? */ +GC_bool GC_on_stack(p) +ptr_t p; +{ +# ifdef THREADS + return(TRUE); +# else + int dummy; +# ifdef STACK_GROWS_DOWN + if ((ptr_t)p >= (ptr_t)(&dummy) && (ptr_t)p < GC_stackbottom ) { + return(TRUE); + } +# else + if ((ptr_t)p <= (ptr_t)(&dummy) && (ptr_t)p > GC_stackbottom ) { + return(TRUE); + } +# endif + return(FALSE); +# endif +} + +/* Check that p is visible */ +/* to the collector as a possibly pointer containing location. */ +/* If it isn't invoke *GC_is_visible_print_proc. */ +/* Returns the argument in all cases. May erroneously succeed */ +/* in hard cases. (This is intended for debugging use with */ +/* untyped allocations. The idea is that it should be possible, though */ +/* slow, to add such a call to all indirect pointer stores.) */ +/* Currently useless for multithreaded worlds. */ +#ifdef __STDC__ + void * GC_is_visible(void *p) +#else + char *GC_is_visible(p) + char *p; +#endif +{ + register hdr *hhdr; + + if ((word)p & (ALIGNMENT - 1)) goto fail; + if (!GC_is_initialized) GC_init(); +# ifdef THREADS + hhdr = HDR((word)p); + if (hhdr != 0 && GC_base(p) == 0) { + goto fail; + } else { + /* May be inside thread stack. We can't do much. */ + return(p); + } +# else + /* Check stack first: */ + if (GC_on_stack(p)) return(p); + hhdr = HDR((word)p); + if (hhdr == 0) { + GC_bool result; + + if (GC_is_static_root(p)) return(p); + /* Else do it again correctly: */ +# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \ + && !defined(SRC_M3) + DISABLE_SIGNALS(); + GC_register_dynamic_libraries(); + result = GC_is_static_root(p); + ENABLE_SIGNALS(); + if (result) return(p); +# endif + goto fail; + } else { + /* p points to the heap. */ + word descr; + ptr_t base = GC_base(p); /* Should be manually inlined? */ + + if (base == 0) goto fail; + if (HBLKPTR(base) != HBLKPTR(p)) hhdr = HDR((word)p); + descr = hhdr -> hb_descr; + retry: + switch(descr & DS_TAGS) { + case DS_LENGTH: + if ((word)((ptr_t)p - (ptr_t)base) > (word)descr) goto fail; + break; + case DS_BITMAP: + if ((ptr_t)p - (ptr_t)base + >= WORDS_TO_BYTES(BITMAP_BITS) + || ((word)p & (sizeof(word) - 1))) goto fail; + if (!((1 << (WORDSZ - ((ptr_t)p - (ptr_t)base) - 1)) + & descr)) goto fail; + break; + case DS_PROC: + /* We could try to decipher this partially. */ + /* For now we just punt. */ + break; + case DS_PER_OBJECT: + descr = *(word *)((ptr_t)base + (descr & ~DS_TAGS)); + goto retry; + } + return(p); + } +# endif +fail: + (*GC_is_visible_print_proc)((ptr_t)p); + return(p); +} + + +GC_PTR GC_pre_incr (p, how_much) +GC_PTR *p; +size_t how_much; +{ + GC_PTR initial = *p; + GC_PTR result = GC_same_obj((GC_PTR)((word)initial + how_much), initial); + +# ifndef ALL_INTERIOR_POINTERS + (void) GC_is_valid_displacement(result); +# endif + return (*p = result); +} + +GC_PTR GC_post_incr (p, how_much) +GC_PTR *p; +size_t how_much; +{ + GC_PTR initial = *p; + GC_PTR result = GC_same_obj((GC_PTR)((word)initial + how_much), initial); + +# ifndef ALL_INTERIOR_POINTERS + (void) GC_is_valid_displacement(result); +# endif + *p = result; + return(initial); +} diff --git a/support/gc/real_malloc.c b/support/gc/real_malloc.c new file mode 100644 index 00000000..dece9fdc --- /dev/null +++ b/support/gc/real_malloc.c @@ -0,0 +1,36 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, May 19, 1994 2:04 pm PDT */ + + +# ifdef PCR +/* + * This definition should go in its own file that includes no other + * header files. Otherwise, we risk not getting the underlying system + * malloc. + */ +# define PCR_NO_RENAME +# include + +# ifdef __STDC__ + char * real_malloc(size_t size) +# else + char * real_malloc() + int size; +# endif +{ + return((char *)malloc(size)); +} +#endif /* PCR */ + diff --git a/support/gc/reclaim.c b/support/gc/reclaim.c new file mode 100644 index 00000000..30859469 --- /dev/null +++ b/support/gc/reclaim.c @@ -0,0 +1,739 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, February 15, 1996 2:41 pm PST */ + +#include +#include "gc_priv.h" + +signed_word GC_mem_found = 0; + /* Number of words of memory reclaimed */ + +static void report_leak(p, sz) +ptr_t p; +word sz; +{ + if (HDR(p) -> hb_obj_kind == PTRFREE) { + GC_err_printf0("Leaked atomic object at "); + } else { + GC_err_printf0("Leaked composite object at "); + } + if (GC_debugging_started && GC_has_debug_info(p)) { + GC_print_obj(p); + } else { + GC_err_printf2("0x%lx (appr. size = %ld)\n", + (unsigned long)p, + (unsigned long)WORDS_TO_BYTES(sz)); + } +} + +# define FOUND_FREE(hblk, word_no) \ + { \ + report_leak((ptr_t)hblk + WORDS_TO_BYTES(word_no), \ + HDR(hblk) -> hb_sz); \ + } + +/* + * reclaim phase + * + */ + + +/* + * Test whether a block is completely empty, i.e. contains no marked + * objects. This does not require the block to be in physical + * memory. + */ + +GC_bool GC_block_empty(hhdr) +register hdr * hhdr; +{ + register word *p = (word *)(&(hhdr -> hb_marks[0])); + register word * plim = + (word *)(&(hhdr -> hb_marks[MARK_BITS_SZ])); + while (p < plim) { + if (*p++) return(FALSE); + } + return(TRUE); +} + +# ifdef GATHERSTATS +# define INCR_WORDS(sz) n_words_found += (sz) +# else +# define INCR_WORDS(sz) +# endif +/* + * Restore unmarked small objects in h of size sz to the object + * free list. Returns the new list. + * Clears unmarked objects. + */ +/*ARGSUSED*/ +ptr_t GC_reclaim_clear(hbp, hhdr, sz, list) +register struct hblk *hbp; /* ptr to current heap block */ +register hdr * hhdr; +register ptr_t list; +register word sz; +{ + register int word_no; + register word *p, *q, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + + p = (word *)(hbp->hb_body); + word_no = HDR_WORDS; + plim = (word *)((((word)hbp) + HBLKSIZE) + - WORDS_TO_BYTES(sz)); + + /* go through all words in block */ + while( p <= plim ) { + if( mark_bit_from_hdr(hhdr, word_no) ) { + p += sz; + } else { + INCR_WORDS(sz); + /* object is available - put on list */ + obj_link(p) = list; + list = ((ptr_t)p); + /* Clear object, advance p to next object in the process */ + q = p + sz; + p++; /* Skip link field */ + while (p < q) { + *p++ = 0; + } + } + word_no += sz; + } +# ifdef GATHERSTATS + GC_mem_found += n_words_found; +# endif + return(list); +} + +#ifndef SMALL_CONFIG + +/* + * A special case for 2 word composite objects (e.g. cons cells): + */ +/*ARGSUSED*/ +ptr_t GC_reclaim_clear2(hbp, hhdr, list) +register struct hblk *hbp; /* ptr to current heap block */ +hdr * hhdr; +register ptr_t list; +{ + register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + register word mark_word; + register int i; +# define DO_OBJ(start_displ) \ + if (!(mark_word & ((word)1 << start_displ))) { \ + p[start_displ] = (word)list; \ + list = (ptr_t)(p+start_displ); \ + p[start_displ+1] = 0; \ + INCR_WORDS(2); \ + } + + p = (word *)(hbp->hb_body); + plim = (word *)(((word)hbp) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + for (i = 0; i < WORDSZ; i += 8) { + DO_OBJ(0); + DO_OBJ(2); + DO_OBJ(4); + DO_OBJ(6); + p += 8; + mark_word >>= 8; + } + } +# ifdef GATHERSTATS + GC_mem_found += n_words_found; +# endif + return(list); +# undef DO_OBJ +} + +/* + * Another special case for 4 word composite objects: + */ +/*ARGSUSED*/ +ptr_t GC_reclaim_clear4(hbp, hhdr, list) +register struct hblk *hbp; /* ptr to current heap block */ +hdr * hhdr; +register ptr_t list; +{ + register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + register word mark_word; +# define DO_OBJ(start_displ) \ + if (!(mark_word & ((word)1 << start_displ))) { \ + p[start_displ] = (word)list; \ + list = (ptr_t)(p+start_displ); \ + p[start_displ+1] = 0; \ + p[start_displ+2] = 0; \ + p[start_displ+3] = 0; \ + INCR_WORDS(4); \ + } + + p = (word *)(hbp->hb_body); + plim = (word *)(((word)hbp) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + DO_OBJ(0); + DO_OBJ(4); + DO_OBJ(8); + DO_OBJ(12); + DO_OBJ(16); + DO_OBJ(20); + DO_OBJ(24); + DO_OBJ(28); +# if CPP_WORDSZ == 64 + DO_OBJ(32); + DO_OBJ(36); + DO_OBJ(40); + DO_OBJ(44); + DO_OBJ(48); + DO_OBJ(52); + DO_OBJ(56); + DO_OBJ(60); +# endif + p += WORDSZ; + } +# ifdef GATHERSTATS + GC_mem_found += n_words_found; +# endif + return(list); +# undef DO_OBJ +} + +#endif /* !SMALL_CONFIG */ + +/* The same thing, but don't clear objects: */ +/*ARGSUSED*/ +ptr_t GC_reclaim_uninit(hbp, hhdr, sz, list) +register struct hblk *hbp; /* ptr to current heap block */ +register hdr * hhdr; +register ptr_t list; +register word sz; +{ + register int word_no; + register word *p, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + + p = (word *)(hbp->hb_body); + word_no = HDR_WORDS; + plim = (word *)((((word)hbp) + HBLKSIZE) + - WORDS_TO_BYTES(sz)); + + /* go through all words in block */ + while( p <= plim ) { + if( !mark_bit_from_hdr(hhdr, word_no) ) { + INCR_WORDS(sz); + /* object is available - put on list */ + obj_link(p) = list; + list = ((ptr_t)p); + } + p += sz; + word_no += sz; + } +# ifdef GATHERSTATS + GC_mem_found += n_words_found; +# endif + return(list); +} + +/* Don't really reclaim objects, just check for unmarked ones: */ +/*ARGSUSED*/ +void GC_reclaim_check(hbp, hhdr, sz) +register struct hblk *hbp; /* ptr to current heap block */ +register hdr * hhdr; +register word sz; +{ + register int word_no; + register word *p, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + + p = (word *)(hbp->hb_body); + word_no = HDR_WORDS; + plim = (word *)((((word)hbp) + HBLKSIZE) + - WORDS_TO_BYTES(sz)); + + /* go through all words in block */ + while( p <= plim ) { + if( !mark_bit_from_hdr(hhdr, word_no) ) { + FOUND_FREE(hbp, word_no); + } + p += sz; + word_no += sz; + } +} + +#ifndef SMALL_CONFIG +/* + * Another special case for 2 word atomic objects: + */ +/*ARGSUSED*/ +ptr_t GC_reclaim_uninit2(hbp, hhdr, list) +register struct hblk *hbp; /* ptr to current heap block */ +hdr * hhdr; +register ptr_t list; +{ + register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + register word mark_word; + register int i; +# define DO_OBJ(start_displ) \ + if (!(mark_word & ((word)1 << start_displ))) { \ + p[start_displ] = (word)list; \ + list = (ptr_t)(p+start_displ); \ + INCR_WORDS(2); \ + } + + p = (word *)(hbp->hb_body); + plim = (word *)(((word)hbp) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + for (i = 0; i < WORDSZ; i += 8) { + DO_OBJ(0); + DO_OBJ(2); + DO_OBJ(4); + DO_OBJ(6); + p += 8; + mark_word >>= 8; + } + } +# ifdef GATHERSTATS + GC_mem_found += n_words_found; +# endif + return(list); +# undef DO_OBJ +} + +/* + * Another special case for 4 word atomic objects: + */ +/*ARGSUSED*/ +ptr_t GC_reclaim_uninit4(hbp, hhdr, list) +register struct hblk *hbp; /* ptr to current heap block */ +hdr * hhdr; +register ptr_t list; +{ + register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + register word mark_word; +# define DO_OBJ(start_displ) \ + if (!(mark_word & ((word)1 << start_displ))) { \ + p[start_displ] = (word)list; \ + list = (ptr_t)(p+start_displ); \ + INCR_WORDS(4); \ + } + + p = (word *)(hbp->hb_body); + plim = (word *)(((word)hbp) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + DO_OBJ(0); + DO_OBJ(4); + DO_OBJ(8); + DO_OBJ(12); + DO_OBJ(16); + DO_OBJ(20); + DO_OBJ(24); + DO_OBJ(28); +# if CPP_WORDSZ == 64 + DO_OBJ(32); + DO_OBJ(36); + DO_OBJ(40); + DO_OBJ(44); + DO_OBJ(48); + DO_OBJ(52); + DO_OBJ(56); + DO_OBJ(60); +# endif + p += WORDSZ; + } +# ifdef GATHERSTATS + GC_mem_found += n_words_found; +# endif + return(list); +# undef DO_OBJ +} + +/* Finally the one word case, which never requires any clearing: */ +/*ARGSUSED*/ +ptr_t GC_reclaim1(hbp, hhdr, list) +register struct hblk *hbp; /* ptr to current heap block */ +hdr * hhdr; +register ptr_t list; +{ + register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]); + register word *p, *plim; +# ifdef GATHERSTATS + register int n_words_found = 0; +# endif + register word mark_word; + register int i; +# define DO_OBJ(start_displ) \ + if (!(mark_word & ((word)1 << start_displ))) { \ + p[start_displ] = (word)list; \ + list = (ptr_t)(p+start_displ); \ + INCR_WORDS(1); \ + } + + p = (word *)(hbp->hb_body); + plim = (word *)(((word)hbp) + HBLKSIZE); + + /* go through all words in block */ + while( p < plim ) { + mark_word = *mark_word_addr++; + for (i = 0; i < WORDSZ; i += 4) { + DO_OBJ(0); + DO_OBJ(1); + DO_OBJ(2); + DO_OBJ(3); + p += 4; + mark_word >>= 4; + } + } +# ifdef GATHERSTATS + GC_mem_found += n_words_found; +# endif + return(list); +# undef DO_OBJ +} + +#endif /* !SMALL_CONFIG */ + +/* + * Restore unmarked small objects in the block pointed to by hbp + * to the appropriate object free list. + * If entirely empty blocks are to be completely deallocated, then + * caller should perform that check. + */ +void GC_reclaim_small_nonempty_block(hbp, report_if_found) +register struct hblk *hbp; /* ptr to current heap block */ +int report_if_found; /* Abort if a reclaimable object is found */ +{ + hdr * hhdr; + register word sz; /* size of objects in current block */ + register struct obj_kind * ok; + register ptr_t * flh; + register int kind; + + hhdr = HDR(hbp); + sz = hhdr -> hb_sz; + hhdr -> hb_last_reclaimed = (unsigned short) GC_gc_no; + kind = hhdr -> hb_obj_kind; + ok = &GC_obj_kinds[kind]; + flh = &(ok -> ok_freelist[sz]); + GC_write_hint(hbp); + + if (report_if_found) { + GC_reclaim_check(hbp, hhdr, sz); + } else if (ok -> ok_init) { + switch(sz) { +# ifndef SMALL_CONFIG + case 1: + *flh = GC_reclaim1(hbp, hhdr, *flh); + break; + case 2: + *flh = GC_reclaim_clear2(hbp, hhdr, *flh); + break; + case 4: + *flh = GC_reclaim_clear4(hbp, hhdr, *flh); + break; +# endif + default: + *flh = GC_reclaim_clear(hbp, hhdr, sz, *flh); + break; + } + } else { + switch(sz) { +# ifndef SMALL_CONFIG + case 1: + *flh = GC_reclaim1(hbp, hhdr, *flh); + break; + case 2: + *flh = GC_reclaim_uninit2(hbp, hhdr, *flh); + break; + case 4: + *flh = GC_reclaim_uninit4(hbp, hhdr, *flh); + break; +# endif + default: + *flh = GC_reclaim_uninit(hbp, hhdr, sz, *flh); + break; + } + } + if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(hhdr); +} + +/* + * Restore an unmarked large object or an entirely empty blocks of small objects + * to the heap block free list. + * Otherwise enqueue the block for later processing + * by GC_reclaim_small_nonempty_block. + * If report_if_found is TRUE, then process any block immediately, and + * simply report free objects; do not actually reclaim them. + */ +void GC_reclaim_block(hbp, report_if_found) +register struct hblk *hbp; /* ptr to current heap block */ +word report_if_found; /* Abort if a reclaimable object is found */ +{ + register hdr * hhdr; + register word sz; /* size of objects in current block */ + register struct obj_kind * ok; + struct hblk ** rlh; + + hhdr = HDR(hbp); + sz = hhdr -> hb_sz; + ok = &GC_obj_kinds[hhdr -> hb_obj_kind]; + + if( sz > MAXOBJSZ ) { /* 1 big object */ + if( !mark_bit_from_hdr(hhdr, HDR_WORDS) ) { + if (report_if_found) { + FOUND_FREE(hbp, HDR_WORDS); + } else { +# ifdef GATHERSTATS + GC_mem_found += sz; +# endif + GC_freehblk(hbp); + } + } + } else { + GC_bool empty = GC_block_empty(hhdr); + if (report_if_found) { + GC_reclaim_small_nonempty_block(hbp, (int)report_if_found); + } else if (empty) { +# ifdef GATHERSTATS + GC_mem_found += BYTES_TO_WORDS(HBLKSIZE); +# endif + GC_freehblk(hbp); + } else { + /* group of smaller objects, enqueue the real work */ + rlh = &(ok -> ok_reclaim_list[sz]); + hhdr -> hb_next = *rlh; + *rlh = hbp; + } + } +} + +#if !defined(NO_DEBUGGING) +/* Routines to gather and print heap block info */ +/* intended for debugging. Otherwise should be called */ +/* with lock. */ +static size_t number_of_blocks; +static size_t total_bytes; + +/* Number of set bits in a word. Not performance critical. */ +static int set_bits(n) +word n; +{ + register word m = n; + register int result = 0; + + while (m > 0) { + if (m & 1) result++; + m >>= 1; + } + return(result); +} + +/* Return the number of set mark bits in the given header */ +int GC_n_set_marks(hhdr) +hdr * hhdr; +{ + register int result = 0; + register int i; + + for (i = 0; i < MARK_BITS_SZ; i++) { + result += set_bits(hhdr -> hb_marks[i]); + } + return(result); +} + +/*ARGSUSED*/ +void GC_print_block_descr(h, dummy) +struct hblk *h; +word dummy; +{ + register hdr * hhdr = HDR(h); + register size_t bytes = WORDS_TO_BYTES(hhdr -> hb_sz); + + GC_printf3("(%lu:%lu,%lu)", (unsigned long)(hhdr -> hb_obj_kind), + (unsigned long)bytes, + (unsigned long)(GC_n_set_marks(hhdr))); + bytes += HDR_BYTES + HBLKSIZE-1; + bytes &= ~(HBLKSIZE-1); + total_bytes += bytes; + number_of_blocks++; +} + +void GC_print_block_list() +{ + GC_printf0("(kind(0=ptrfree,1=normal,2=unc.,3=stubborn):size_in_bytes, #_marks_set)\n"); + number_of_blocks = 0; + total_bytes = 0; + GC_apply_to_all_blocks(GC_print_block_descr, (word)0); + GC_printf2("\nblocks = %lu, bytes = %lu\n", + (unsigned long)number_of_blocks, + (unsigned long)total_bytes); +} + +#endif /* NO_DEBUGGING */ + +/* + * Perform GC_reclaim_block on the entire heap, after first clearing + * small object free lists (if we are not just looking for leaks). + */ +void GC_start_reclaim(report_if_found) +int report_if_found; /* Abort if a GC_reclaimable object is found */ +{ + int kind; + + /* Clear reclaim- and free-lists */ + for (kind = 0; kind < GC_n_kinds; kind++) { + register ptr_t *fop; + register ptr_t *lim; + register struct hblk ** rlp; + register struct hblk ** rlim; + register struct hblk ** rlist = GC_obj_kinds[kind].ok_reclaim_list; + + if (rlist == 0) continue; /* This kind not used. */ + if (!report_if_found) { + lim = &(GC_obj_kinds[kind].ok_freelist[MAXOBJSZ+1]); + for( fop = GC_obj_kinds[kind].ok_freelist; fop < lim; fop++ ) { + *fop = 0; + } + } /* otherwise free list objects are marked, */ + /* and its safe to leave them */ + rlim = rlist + MAXOBJSZ+1; + for( rlp = rlist; rlp < rlim; rlp++ ) { + *rlp = 0; + } + } + +# ifdef PRINTBLOCKS + GC_printf0("GC_reclaim: current block sizes:\n"); + GC_print_block_list(); +# endif + + /* Go through all heap blocks (in hblklist) and reclaim unmarked objects */ + /* or enqueue the block for later processing. */ + GC_apply_to_all_blocks(GC_reclaim_block, (word)report_if_found); + +} + +/* + * Sweep blocks of the indicated object size and kind until either the + * appropriate free list is nonempty, or there are no more blocks to + * sweep. + */ +void GC_continue_reclaim(sz, kind) +word sz; /* words */ +int kind; +{ + register hdr * hhdr; + register struct hblk * hbp; + register struct obj_kind * ok = &(GC_obj_kinds[kind]); + struct hblk ** rlh = ok -> ok_reclaim_list; + ptr_t *flh = &(ok -> ok_freelist[sz]); + + if (rlh == 0) return; /* No blocks of this kind. */ + rlh += sz; + while ((hbp = *rlh) != 0) { + hhdr = HDR(hbp); + *rlh = hhdr -> hb_next; + GC_reclaim_small_nonempty_block(hbp, FALSE); + if (*flh != 0) break; + } +} + +/* + * Reclaim all small blocks waiting to be reclaimed. + * Abort and return FALSE when/if (*stop_func)() returns TRUE. + * If this returns TRUE, then it's safe to restart the world + * with incorrectly cleared mark bits. + * If ignore_old is TRUE, then reclain only blocks that have been + * recently reclaimed, and discard the rest. + * Stop_func may be 0. + */ +GC_bool GC_reclaim_all(stop_func, ignore_old) +GC_stop_func stop_func; +GC_bool ignore_old; +{ + register word sz; + register int kind; + register hdr * hhdr; + register struct hblk * hbp; + register struct obj_kind * ok; + struct hblk ** rlp; + struct hblk ** rlh; +# ifdef PRINTTIMES + CLOCK_TYPE start_time; + CLOCK_TYPE done_time; + + GET_TIME(start_time); +# endif + + for (kind = 0; kind < GC_n_kinds; kind++) { + ok = &(GC_obj_kinds[kind]); + rlp = ok -> ok_reclaim_list; + if (rlp == 0) continue; + for (sz = 1; sz <= MAXOBJSZ; sz++) { + rlh = rlp + sz; + while ((hbp = *rlh) != 0) { + if (stop_func != (GC_stop_func)0 && (*stop_func)()) { + return(FALSE); + } + hhdr = HDR(hbp); + *rlh = hhdr -> hb_next; + if (!ignore_old || hhdr -> hb_last_reclaimed == GC_gc_no - 1) { + /* It's likely we'll need it this time, too */ + /* It's been touched recently, so this */ + /* shouldn't trigger paging. */ + GC_reclaim_small_nonempty_block(hbp, FALSE); + } + } + } + } +# ifdef PRINTTIMES + GET_TIME(done_time); + GC_printf1("Disposing of reclaim lists took %lu msecs\n", + MS_TIME_DIFF(done_time,start_time)); +# endif + return(TRUE); +} diff --git a/support/gc/rs6000_mach_dep.s b/support/gc/rs6000_mach_dep.s new file mode 100644 index 00000000..e0dbe808 --- /dev/null +++ b/support/gc/rs6000_mach_dep.s @@ -0,0 +1,105 @@ + .csect + .set r0,0 + .set r1,1 + .set r2,2 + .set r3,3 + .set r4,4 + .set r5,5 + .set r6,6 + .set r7,7 + .set r8,8 + .set r9,9 + .set r10,10 + .set r11,11 + .set r12,12 + .set r13,13 + .set r14,14 + .set r15,15 + .set r16,16 + .set r17,17 + .set r18,18 + .set r19,19 + .set r20,20 + .set r21,21 + .set r22,22 + .set r23,23 + .set r24,24 + .set r25,25 + .set r26,26 + .set r27,27 + .set r28,28 + .set r29,29 + .set r30,30 + .set r31,31 + + # Mark from machine registers that are saved by C compiler + .globl .GC_push_regs +.GC_push_regs: + .extern .GC_push_one + stu r1,-64(r1) # reserve stack frame + mflr r0 # save link register + st r0,0x48(r1) + oril r3,r2,0x0 # mark from r2 + bl .GC_push_one + cror 15,15,15 + oril r3,r13,0x0 # mark from r13-r31 + bl .GC_push_one + cror 15,15,15 + oril r3,r14,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r15,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r16,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r17,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r18,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r19,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r20,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r21,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r22,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r23,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r24,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r25,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r26,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r27,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r28,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r29,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r30,0x0 + bl .GC_push_one + cror 15,15,15 + oril r3,r31,0x0 + bl .GC_push_one + cror 15,15,15 + l r0,0x48(r1) + mtlr r0 + ai r1,r1,64 + br diff --git a/support/gc/setjmp_t.c b/support/gc/setjmp_t.c new file mode 100644 index 00000000..1c9253e9 --- /dev/null +++ b/support/gc/setjmp_t.c @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, September 21, 1995 5:39 pm PDT */ + +/* Check whether setjmp actually saves registers in jmp_buf. */ +/* If it doesn't, the generic mark_regs code won't work. */ +/* Compilers vary as to whether they will put x in a */ +/* (callee-save) register without -O. The code is */ +/* contrived such that any decent compiler should put x in */ +/* a callee-save register with -O. Thus it is is */ +/* recommended that this be run optimized. (If the machine */ +/* has no callee-save registers, then the generic code is */ +/* safe, but this will not be noticed by this piece of */ +/* code.) */ +#include +#include +#include +#include "gcconfig.h" + +#ifdef OS2 +/* GETPAGESIZE() is set to getpagesize() by default, but that */ +/* doesn't really exist, and the collector doesn't need it. */ +#define INCL_DOSFILEMGR +#define INCL_DOSMISC +#define INCL_DOSERRORS +#include + +int +getpagesize() +{ + ULONG result[1]; + + if (DosQuerySysInfo(QSV_PAGE_SIZE, QSV_PAGE_SIZE, + (void *)result, sizeof(ULONG)) != NO_ERROR) { + fprintf(stderr, "DosQuerySysInfo failed\n"); + result[0] = 4096; + } + return((int)(result[0])); +} +#endif + +struct {char a_a; char * a_b;} a; + +int * nested_sp() +{ + int dummy; + + return(&dummy); +} + +main() +{ + int dummy; + long ps = GETPAGESIZE(); + jmp_buf b; + register int x = (int)strlen("a"); /* 1, slightly disguised */ + static int y = 0; + + printf("This appears to be a %s running %s\n", MACH_TYPE, OS_TYPE); + if (nested_sp() < &dummy) { + printf("Stack appears to grow down, which is the default.\n"); + printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n", + ((unsigned long)(&dummy) + ps) & ~(ps-1)); + } else { + printf("Stack appears to grow up.\n"); + printf("Define STACK_GROWS_UP in gc_private.h\n"); + printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n", + ((unsigned long)(&dummy) + ps) & ~(ps-1)); + } + printf("Note that this may vary between machines of ostensibly\n"); + printf("the same architecture (e.g. Sun 3/50s and 3/80s).\n"); + printf("On many machines the value is not fixed.\n"); + printf("A good guess for ALIGNMENT on this machine is %ld.\n", + (unsigned long)(&(a.a_b))-(unsigned long)(&a)); + + /* Encourage the compiler to keep x in a callee-save register */ + x = 2*x-1; + printf(""); + x = 2*x-1; + setjmp(b); + if (y == 1) { + if (x == 2) { + printf("Generic mark_regs code probably wont work\n"); +# if defined(SPARC) || defined(RS6000) || defined(VAX) || defined(MIPS) || defined(M68K) || defined(I386) || defined(NS32K) || defined(RT) + printf("Assembly code supplied\n"); +# else + printf("Need assembly code\n"); +# endif + } else if (x == 1) { + printf("Generic mark_regs code may work\n"); + } else { + printf("Very strange setjmp implementation\n"); + } + } + y++; + x = 2; + if (y == 1) longjmp(b,1); + return(0); +} + +int g(x) +int x; +{ + return(x); +} diff --git a/support/gc/solaris_pthreads.c b/support/gc/solaris_pthreads.c new file mode 100644 index 00000000..37bb3722 --- /dev/null +++ b/support/gc/solaris_pthreads.c @@ -0,0 +1,172 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* + * Support code for Solaris threads. Provides functionality we wish Sun + * had provided. Relies on some information we probably shouldn't rely on. + * Modified Peter C. for Solaris Posix Threads. + */ +/* Boehm, September 14, 1994 4:44 pm PDT */ +/* $Id$ */ + +# if defined(_SOLARIS_PTHREADS) +# include "gc_priv.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# define _CLASSIC_XOPEN_TYPES +# include +# include +# include "solaris_threads.h" +# include + +#undef pthread_join +#undef pthread_create + +pthread_cond_t GC_prom_join_cv; /* Broadcast when any thread terminates */ +pthread_cond_t GC_create_cv; /* Signalled when a new undetached */ + /* thread starts. */ + +extern bool GC_multithreaded; + +/* We use the allocation lock to protect thread-related data structures. */ + +/* We stop the world using /proc primitives. This makes some */ +/* minimal assumptions about the threads implementation. */ +/* We don't play by the rules, since the rules make this */ +/* impossible (as of Solaris 2.3). Also note that as of */ +/* Solaris 2.3 the various thread and lwp suspension */ +/* primitives failed to stop threads by the time the request */ +/* is completed. */ + + + +int GC_pthread_join(pthread_t wait_for, void **status) +{ + return GC_thr_join((thread_t)wait_for, NULL, status); +} + + +int +GC_pthread_create(pthread_t *new_thread, + const pthread_attr_t *attr_in, + void * (*thread_execp)(void *), void *arg) +{ + int result; + GC_thread t; + pthread_t my_new_thread; + pthread_attr_t attr; + word my_flags = 0; + int flag; + void * stack; + size_t stack_size; + int n; + struct sched_param schedparam; + + (void)pthread_attr_getstacksize(attr_in, &stack_size); + (void)pthread_attr_getstackaddr(attr_in, &stack); + (void)pthread_attr_init(&attr); + + LOCK(); + if (!GC_thr_initialized) { + GC_thr_init(); + } + GC_multithreaded++; + + if (stack == 0) { + if (stack_size == 0) + stack_size = GC_min_stack_sz; + else + stack_size += thr_min_stack(); + + stack = (void *)GC_stack_alloc(&stack_size); + if (stack == 0) { + GC_multithreaded--; + UNLOCK(); + errno = ENOMEM; + return -1; + } + } else { + my_flags |= CLIENT_OWNS_STACK; + } + (void)pthread_attr_setstacksize(&attr, stack_size); + (void)pthread_attr_setstackaddr(&attr, stack); + (void)pthread_attr_getscope(attr_in, &n); + (void)pthread_attr_setscope(&attr, n); + (void)pthread_attr_getschedparam(attr_in, &schedparam); + (void)pthread_attr_setschedparam(&attr, &schedparam); + (void)pthread_attr_getschedpolicy(attr_in, &n); + (void)pthread_attr_setschedpolicy(&attr, n); + (void)pthread_attr_getinheritsched(attr_in, &n); + (void)pthread_attr_setinheritsched(&attr, n); + + (void)pthread_attr_getdetachstate(attr_in, &flag); + if (flag == PTHREAD_CREATE_DETACHED) { + my_flags |= DETACHED; + } + (void)pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + /* + * thr_create can call malloc(), which if redirected will + * attempt to acquire the allocation lock. + * Unlock here to prevent deadlock. + */ + + +#if 0 +#ifdef I386 + UNLOCK(); +#endif +#endif + result = + pthread_create(&my_new_thread, &attr, thread_execp, arg); +#if 0 +#ifdef I386 + LOCK(); +#endif +#endif + if (result == 0) { + t = GC_new_thread(my_new_thread); + t -> flags = my_flags; + if (!(my_flags & DETACHED)) cond_init(&(t->join_cv), USYNC_THREAD, 0); + t -> stack = stack; + t -> stack_size = stack_size; + if (new_thread != 0) *new_thread = my_new_thread; + pthread_cond_signal(&GC_create_cv); + } else { + if (!(my_flags & CLIENT_OWNS_STACK)) { + GC_stack_free(stack, stack_size); + } + GC_multithreaded--; + } + UNLOCK(); + pthread_attr_destroy(&attr); + return(result); +} + +# else + +#ifndef LINT + int GC_no_sunOS_pthreads; +#endif + +# endif /* SOLARIS_THREADS */ + diff --git a/support/gc/solaris_threads.c b/support/gc/solaris_threads.c new file mode 100644 index 00000000..65b2c651 --- /dev/null +++ b/support/gc/solaris_threads.c @@ -0,0 +1,940 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* + * Support code for Solaris threads. Provides functionality we wish Sun + * had provided. Relies on some information we probably shouldn't rely on. + */ +/* Boehm, September 14, 1994 4:44 pm PDT */ + +# if defined(SOLARIS_THREADS) + +# include "gc_priv.h" +# include "solaris_threads.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# define _CLASSIC_XOPEN_TYPES +# include +# include + +/* + * This is the default size of the LWP arrays. If there are more LWPs + * than this when a stop-the-world GC happens, set_max_lwps will be + * called to cope. + * This must be higher than the number of LWPs at startup time. + * The threads library creates a thread early on, so the min. is 3 + */ +# define DEFAULT_MAX_LWPS 4 + +#undef thr_join +#undef thr_create +#undef thr_suspend +#undef thr_continue + +cond_t GC_prom_join_cv; /* Broadcast when any thread terminates */ +cond_t GC_create_cv; /* Signalled when a new undetached */ + /* thread starts. */ + + +#ifdef MMAP_STACKS +static int GC_zfd; +#endif /* MMAP_STACKS */ + +/* We use the allocation lock to protect thread-related data structures. */ + +/* We stop the world using /proc primitives. This makes some */ +/* minimal assumptions about the threads implementation. */ +/* We don't play by the rules, since the rules make this */ +/* impossible (as of Solaris 2.3). Also note that as of */ +/* Solaris 2.3 the various thread and lwp suspension */ +/* primitives failed to stop threads by the time the request */ +/* is completed. */ + + +static sigset_t old_mask; + +/* Sleep for n milliseconds, n < 1000 */ +void GC_msec_sleep(int n) +{ + struct timespec ts; + + ts.tv_sec = 0; + ts.tv_nsec = 1000000*n; + if (syscall(SYS_nanosleep, &ts, 0) < 0) { + ABORT("nanosleep failed"); + } +} +/* Turn off preemption; gross but effective. */ +/* Caller has allocation lock. */ +/* Actually this is not needed under Solaris 2.3 and */ +/* 2.4, but hopefully that'll change. */ +void preempt_off() +{ + sigset_t set; + + (void)sigfillset(&set); + sigdelset(&set, SIGABRT); + syscall(SYS_sigprocmask, SIG_SETMASK, &set, &old_mask); +} + +void preempt_on() +{ + syscall(SYS_sigprocmask, SIG_SETMASK, &old_mask, NULL); +} + +int GC_main_proc_fd = -1; + + +struct lwp_cache_entry { + lwpid_t lc_id; + int lc_descr; /* /proc file descriptor. */ +} GC_lwp_cache_default[DEFAULT_MAX_LWPS]; + +static int max_lwps = DEFAULT_MAX_LWPS; +static struct lwp_cache_entry *GC_lwp_cache = GC_lwp_cache_default; + +static prgregset_t GC_lwp_registers_default[DEFAULT_MAX_LWPS]; +static prgregset_t *GC_lwp_registers = GC_lwp_registers_default; + +/* Return a file descriptor for the /proc entry corresponding */ +/* to the given lwp. The file descriptor may be stale if the */ +/* lwp exited and a new one was forked. */ +static int open_lwp(lwpid_t id) +{ + int result; + static int next_victim = 0; + register int i; + + for (i = 0; i < max_lwps; i++) { + if (GC_lwp_cache[i].lc_id == id) return(GC_lwp_cache[i].lc_descr); + } + result = syscall(SYS_ioctl, GC_main_proc_fd, PIOCOPENLWP, &id); + /* + * If PIOCOPENLWP fails, try closing fds in the cache until it succeeds. + */ + if (result < 0 && errno == EMFILE) { + for (i = 0; i < max_lwps; i++) { + if (GC_lwp_cache[i].lc_id != 0) { + (void)syscall(SYS_close, GC_lwp_cache[i].lc_descr); + result = syscall(SYS_ioctl, GC_main_proc_fd, PIOCOPENLWP, &id); + if (result >= 0 || (result < 0 && errno != EMFILE)) + break; + } + } + } + if (result < 0) { + if (errno == EMFILE) { + ABORT("Too many open files"); + } + return(-1) /* exited? */; + } + if (GC_lwp_cache[next_victim].lc_id != 0) + (void)syscall(SYS_close, GC_lwp_cache[next_victim].lc_descr); + GC_lwp_cache[next_victim].lc_id = id; + GC_lwp_cache[next_victim].lc_descr = result; + if (++next_victim >= max_lwps) + next_victim = 0; + return(result); +} + +static void uncache_lwp(lwpid_t id) +{ + register int i; + + for (i = 0; i < max_lwps; i++) { + if (GC_lwp_cache[i].lc_id == id) { + (void)syscall(SYS_close, GC_lwp_cache[id].lc_descr); + GC_lwp_cache[i].lc_id = 0; + break; + } + } +} + /* Sequence of current lwp ids */ +static lwpid_t GC_current_ids_default[DEFAULT_MAX_LWPS + 1]; +static lwpid_t *GC_current_ids = GC_current_ids_default; + + /* Temporary used below (can be big if large number of LWPs) */ +static lwpid_t last_ids_default[DEFAULT_MAX_LWPS + 1]; +static lwpid_t *last_ids = last_ids_default; + + +#define ROUNDUP(n) WORDS_TO_BYTES(ROUNDED_UP_WORDS(n)) + +static void set_max_lwps(GC_word n) +{ + char *mem; + char *oldmem; + int required_bytes = ROUNDUP(n * sizeof(struct lwp_cache_entry)) + + ROUNDUP(n * sizeof(prgregset_t)) + + ROUNDUP((n + 1) * sizeof(lwpid_t)) + + ROUNDUP((n + 1) * sizeof(lwpid_t)); + + GC_expand_hp_inner(divHBLKSZ((word)required_bytes)); + oldmem = mem = GC_scratch_alloc(required_bytes); + if (0 == mem) ABORT("No space for lwp data structures"); + + /* + * We can either flush the old lwp cache or copy it over. Do the latter. + */ + memcpy(mem, GC_lwp_cache, max_lwps * sizeof(struct lwp_cache_entry)); + GC_lwp_cache = (struct lwp_cache_entry*)mem; + mem += ROUNDUP(n * sizeof(struct lwp_cache_entry)); + + BZERO(GC_lwp_registers, max_lwps * sizeof(GC_lwp_registers[0])); + GC_lwp_registers = (prgregset_t *)mem; + mem += ROUNDUP(n * sizeof(prgregset_t)); + + + GC_current_ids = (lwpid_t *)mem; + mem += ROUNDUP((n + 1) * sizeof(lwpid_t)); + + last_ids = (lwpid_t *)mem; + mem += ROUNDUP((n + 1)* sizeof(lwpid_t)); + + if (mem > oldmem + required_bytes) + ABORT("set_max_lwps buffer overflow"); + + max_lwps = n; +} + + +/* Stop all lwps in process. Assumes preemption is off. */ +/* Caller has allocation lock (and any other locks he may */ +/* need). */ +static void stop_all_lwps() +{ + int lwp_fd; + char buf[30]; + prstatus_t status; + register int i; + GC_bool changed; + lwpid_t me = _lwp_self(); + + if (GC_main_proc_fd == -1) { + sprintf(buf, "/proc/%d", getpid()); + GC_main_proc_fd = syscall(SYS_open, buf, O_RDONLY); + if (GC_main_proc_fd < 0) { + if (errno == EMFILE) + ABORT("/proc open failed: too many open files"); + GC_printf1("/proc open failed: errno %d", errno); + abort(); + } + } + BZERO(GC_lwp_registers, sizeof (prgregset_t) * max_lwps); + for (i = 0; i < max_lwps; i++) + last_ids[i] = 0; + for (;;) { + if (syscall(SYS_ioctl, GC_main_proc_fd, PIOCSTATUS, &status) < 0) + ABORT("Main PIOCSTATUS failed"); + if (status.pr_nlwp < 1) + ABORT("Invalid number of lwps returned by PIOCSTATUS"); + if (status.pr_nlwp >= max_lwps) { + set_max_lwps(status.pr_nlwp*2 + 10); + /* + * The data in the old GC_current_ids and + * GC_lwp_registers has been trashed. Cleaning out last_ids + * will make sure every LWP gets re-examined. + */ + for (i = 0; i < max_lwps; i++) + last_ids[i] = 0; + continue; + } + if (syscall(SYS_ioctl, GC_main_proc_fd, PIOCLWPIDS, GC_current_ids) < 0) + ABORT("PIOCLWPIDS failed"); + changed = FALSE; + for (i = 0; GC_current_ids[i] != 0 && i < max_lwps; i++) { + if (GC_current_ids[i] != last_ids[i]) { + changed = TRUE; + if (GC_current_ids[i] != me) { + /* PIOCSTOP doesn't work without a writable */ + /* descriptor. And that makes the process */ + /* undebuggable. */ + if (_lwp_suspend(GC_current_ids[i]) < 0) { + /* Could happen if the lwp exited */ + uncache_lwp(GC_current_ids[i]); + GC_current_ids[i] = me; /* ignore */ + } + } + } + } + /* + * In the unlikely event something does a fork between the + * PIOCSTATUS and the PIOCLWPIDS. + */ + if (i >= max_lwps) + continue; + /* All lwps in GC_current_ids != me have been suspended. Note */ + /* that _lwp_suspend is idempotent. */ + for (i = 0; GC_current_ids[i] != 0; i++) { + if (GC_current_ids[i] != last_ids[i]) { + if (GC_current_ids[i] != me) { + lwp_fd = open_lwp(GC_current_ids[i]); + if (lwp_fd == -1) + { + GC_current_ids[i] = me; + continue; + } + /* LWP should be stopped. Empirically it sometimes */ + /* isn't, and more frequently the PR_STOPPED flag */ + /* is not set. Wait for PR_STOPPED. */ + if (syscall(SYS_ioctl, lwp_fd, + PIOCSTATUS, &status) < 0) { + /* Possible if the descriptor was stale, or */ + /* we encountered the 2.3 _lwp_suspend bug. */ + uncache_lwp(GC_current_ids[i]); + GC_current_ids[i] = me; /* handle next time. */ + } else { + while (!(status.pr_flags & PR_STOPPED)) { + GC_msec_sleep(1); + if (syscall(SYS_ioctl, lwp_fd, + PIOCSTATUS, &status) < 0) { + ABORT("Repeated PIOCSTATUS failed"); + } + if (status.pr_flags & PR_STOPPED) break; + + GC_msec_sleep(20); + if (syscall(SYS_ioctl, lwp_fd, + PIOCSTATUS, &status) < 0) { + ABORT("Repeated PIOCSTATUS failed"); + } + } + if (status.pr_who != GC_current_ids[i]) { + /* can happen if thread was on death row */ + uncache_lwp(GC_current_ids[i]); + GC_current_ids[i] = me; /* handle next time. */ + continue; + } + /* Save registers where collector can */ + /* find them. */ + BCOPY(status.pr_reg, GC_lwp_registers[i], + sizeof (prgregset_t)); + } + } + } + } + if (!changed) break; + for (i = 0; i < max_lwps; i++) last_ids[i] = GC_current_ids[i]; + } +} + +/* Restart all lwps in process. Assumes preemption is off. */ +static void restart_all_lwps() +{ + int lwp_fd; + register int i; + GC_bool changed; + lwpid_t me = _lwp_self(); +# define PARANOID + + for (i = 0; GC_current_ids[i] != 0; i++) { +# ifdef PARANOID + if (GC_current_ids[i] != me) { + int lwp_fd = open_lwp(GC_current_ids[i]); + prstatus_t status; + + if (lwp_fd < 0) ABORT("open_lwp failed"); + if (syscall(SYS_ioctl, lwp_fd, + PIOCSTATUS, &status) < 0) { + ABORT("PIOCSTATUS failed in restart_all_lwps"); + } + if (memcmp(status.pr_reg, GC_lwp_registers[i], + sizeof (prgregset_t)) != 0) { + int j; + + for(j = 0; j < NGREG; j++) + { + GC_printf3("%i: %x -> %x\n", j, + GC_lwp_registers[i][j], + status.pr_reg[j]); + } + ABORT("Register contents changed"); + } + if (!status.pr_flags & PR_STOPPED) { + ABORT("lwp no longer stopped"); + } +#ifdef SPARC + { + gwindows_t windows; + if (syscall(SYS_ioctl, lwp_fd, + PIOCGWIN, &windows) < 0) { + ABORT("PIOCSTATUS failed in restart_all_lwps"); + } + if (windows.wbcnt > 0) ABORT("unsaved register windows"); + } +#endif + } +# endif /* PARANOID */ + if (GC_current_ids[i] == me) continue; + if (_lwp_continue(GC_current_ids[i]) < 0) { + ABORT("Failed to restart lwp"); + } + } + if (i >= max_lwps) ABORT("Too many lwps"); +} + +GC_bool GC_multithreaded = 0; + +void GC_stop_world() +{ + preempt_off(); + if (GC_multithreaded) + stop_all_lwps(); +} + +void GC_start_world() +{ + if (GC_multithreaded) + restart_all_lwps(); + preempt_on(); +} + +void GC_thr_init(void); + +GC_bool GC_thr_initialized = FALSE; + +size_t GC_min_stack_sz; + +size_t GC_page_sz; + +/* + * stack_head is stored at the top of free stacks + */ +struct stack_head { + struct stack_head *next; + ptr_t base; + thread_t owner; +}; + +# define N_FREE_LISTS 25 +struct stack_head *GC_stack_free_lists[N_FREE_LISTS] = { 0 }; + /* GC_stack_free_lists[i] is free list for stacks of */ + /* size GC_min_stack_sz*2**i. */ + /* Free lists are linked through stack_head stored */ /* at top of stack. */ + +/* Return a stack of size at least *stack_size. *stack_size is */ +/* replaced by the actual stack size. */ +/* Caller holds allocation lock. */ +ptr_t GC_stack_alloc(size_t * stack_size) +{ + register size_t requested_sz = *stack_size; + register size_t search_sz = GC_min_stack_sz; + register int index = 0; /* = log2(search_sz/GC_min_stack_sz) */ + register ptr_t base; + register struct stack_head *result; + + while (search_sz < requested_sz) { + search_sz *= 2; + index++; + } + if ((result = GC_stack_free_lists[index]) == 0 + && (result = GC_stack_free_lists[index+1]) != 0) { + /* Try next size up. */ + search_sz *= 2; index++; + } + if (result != 0) { + base = GC_stack_free_lists[index]->base; + GC_stack_free_lists[index] = GC_stack_free_lists[index]->next; + } else { +#ifdef MMAP_STACKS + base = (ptr_t)mmap(0, search_sz + GC_page_sz, + PROT_READ|PROT_WRITE, MAP_PRIVATE |MAP_NORESERVE, + GC_zfd, 0); + if (base == (ptr_t)-1) + { + *stack_size = 0; + return NULL; + } + + mprotect(base, GC_page_sz, PROT_NONE); + /* Should this use divHBLKSZ(search_sz + GC_page_sz) ? -- cf */ + GC_is_fresh((struct hblk *)base, divHBLKSZ(search_sz)); + base += GC_page_sz; + +#else + base = (ptr_t) GC_scratch_alloc(search_sz + 2*GC_page_sz); + if (base == NULL) + { + *stack_size = 0; + return NULL; + } + + base = (ptr_t)(((word)base + GC_page_sz) & ~(GC_page_sz - 1)); + /* Protect hottest page to detect overflow. */ +# ifdef SOLARIS23_MPROTECT_BUG_FIXED + mprotect(base, GC_page_sz, PROT_NONE); +# endif + GC_is_fresh((struct hblk *)base, divHBLKSZ(search_sz)); + + base += GC_page_sz; +#endif + } + *stack_size = search_sz; + return(base); +} + +/* Caller holds allocationlock. */ +void GC_stack_free(ptr_t stack, size_t size) +{ + register int index = 0; + register size_t search_sz = GC_min_stack_sz; + register struct stack_head *head; + +#ifdef MMAP_STACKS + /* Zero pointers */ + mmap(stack, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_NORESERVE|MAP_FIXED, + GC_zfd, 0); +#endif + while (search_sz < size) { + search_sz *= 2; + index++; + } + if (search_sz != size) ABORT("Bad stack size"); + + head = (struct stack_head *)(stack + search_sz - sizeof(struct stack_head)); + head->next = GC_stack_free_lists[index]; + head->base = stack; + GC_stack_free_lists[index] = head; +} + +void GC_my_stack_limits(); + +/* Notify virtual dirty bit implementation that known empty parts of */ +/* stacks do not contain useful data. */ +/* Caller holds allocation lock. */ +void GC_old_stacks_are_fresh() +{ +/* No point in doing this for MMAP stacks - and pointers are zero'd out */ +/* by the mmap in GC_stack_free */ +#ifndef MMAP_STACKS + register int i; + register struct stack_head *s; + register ptr_t p; + register size_t sz; + register struct hblk * h; + int dummy; + + for (i = 0, sz= GC_min_stack_sz; i < N_FREE_LISTS; + i++, sz *= 2) { + for (s = GC_stack_free_lists[i]; s != 0; s = s->next) { + p = s->base; + h = (struct hblk *)(((word)p + HBLKSIZE-1) & ~(HBLKSIZE-1)); + if ((ptr_t)h == p) { + GC_is_fresh((struct hblk *)p, divHBLKSZ(sz)); + } else { + GC_is_fresh((struct hblk *)p, divHBLKSZ(sz) - 1); + BZERO(p, (ptr_t)h - p); + } + } + } +#endif /* MMAP_STACKS */ + GC_my_stack_limits(); +} + +/* The set of all known threads. We intercept thread creation and */ +/* joins. We never actually create detached threads. We allocate all */ +/* new thread stacks ourselves. These allow us to maintain this */ +/* data structure. */ + +# define THREAD_TABLE_SZ 128 /* Must be power of 2 */ +volatile GC_thread GC_threads[THREAD_TABLE_SZ]; + +/* Add a thread to GC_threads. We assume it wasn't already there. */ +/* Caller holds allocation lock. */ +GC_thread GC_new_thread(thread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + GC_thread result; + static struct GC_Thread_Rep first_thread; + static GC_bool first_thread_used = FALSE; + + if (!first_thread_used) { + result = &first_thread; + first_thread_used = TRUE; + /* Dont acquire allocation lock, since we may already hold it. */ + } else { + result = (struct GC_Thread_Rep *) + GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL); + } + if (result == 0) return(0); + result -> id = id; + result -> next = GC_threads[hv]; + GC_threads[hv] = result; + /* result -> finished = 0; */ + (void) cond_init(&(result->join_cv), USYNC_THREAD, 0); + return(result); +} + +/* Delete a thread from GC_threads. We assume it is there. */ +/* (The code intentionally traps if it wasn't.) */ +/* Caller holds allocation lock. */ +void GC_delete_thread(thread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + register GC_thread prev = 0; + + while (p -> id != id) { + prev = p; + p = p -> next; + } + if (prev == 0) { + GC_threads[hv] = p -> next; + } else { + prev -> next = p -> next; + } +} + +/* Return the GC_thread correpsonding to a given thread_t. */ +/* Returns 0 if it's not there. */ +/* Caller holds allocation lock. */ +GC_thread GC_lookup_thread(thread_t id) +{ + int hv = ((word)id) % THREAD_TABLE_SZ; + register GC_thread p = GC_threads[hv]; + + while (p != 0 && p -> id != id) p = p -> next; + return(p); +} + +# define MAX_ORIG_STACK_SIZE (8 * 1024 * 1024) + +word GC_get_orig_stack_size() { + struct rlimit rl; + static int warned = 0; + int result; + + if (getrlimit(RLIMIT_STACK, &rl) != 0) ABORT("getrlimit failed"); + result = (word)rl.rlim_cur & ~(HBLKSIZE-1); + if (result > MAX_ORIG_STACK_SIZE) { + if (!warned) { + WARN("Large stack limit(%ld): only scanning 8 MB", result); + warned = 1; + } + result = MAX_ORIG_STACK_SIZE; + } + return result; +} + +/* Notify dirty bit implementation of unused parts of my stack. */ +/* Caller holds allocation lock. */ +void GC_my_stack_limits() +{ + int dummy; + register ptr_t hottest = (ptr_t)((word)(&dummy) & ~(HBLKSIZE-1)); + register GC_thread me = GC_lookup_thread(thr_self()); + register size_t stack_size = me -> stack_size; + register ptr_t stack; + + if (stack_size == 0) { + /* original thread */ + /* Empirically, what should be the stack page with lowest */ + /* address is actually inaccessible. */ + stack_size = GC_get_orig_stack_size() - GC_page_sz; + stack = GC_stackbottom - stack_size + GC_page_sz; + } else { + stack = me -> stack; + } + if (stack > hottest || stack + stack_size < hottest) { + ABORT("sp out of bounds"); + } + GC_is_fresh((struct hblk *)stack, divHBLKSZ(hottest - stack)); +} + + +/* We hold allocation lock. We assume the world is stopped. */ +void GC_push_all_stacks() +{ + register int i; + register GC_thread p; + register ptr_t sp = GC_approx_sp(); + register ptr_t bottom, top; + struct rlimit rl; + +# define PUSH(bottom,top) \ + if (GC_dirty_maintained) { \ + GC_push_dirty((bottom), (top), GC_page_was_ever_dirty, \ + GC_push_all_stack); \ + } else { \ + GC_push_all_stack((bottom), (top)); \ + } + GC_push_all_stack((ptr_t)GC_lwp_registers, + (ptr_t)GC_lwp_registers + + max_lwps * sizeof(GC_lwp_registers[0])); + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> stack_size != 0) { + bottom = p -> stack; + top = p -> stack + p -> stack_size; + } else { + /* The original stack. */ + bottom = GC_stackbottom - GC_get_orig_stack_size() + GC_page_sz; + top = GC_stackbottom; + } + if ((word)sp > (word)bottom && (word)sp < (word)top) bottom = sp; + PUSH(bottom, top); + } + } +} + + +int GC_is_thread_stack(ptr_t addr) +{ + register int i; + register GC_thread p; + register ptr_t bottom, top; + struct rlimit rl; + + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (p = GC_threads[i]; p != 0; p = p -> next) { + if (p -> stack_size != 0) { + if (p -> stack <= addr && + addr < p -> stack + p -> stack_size) + return 1; + } + } + } +} + +/* The only thread that ever really performs a thr_join. */ +void * GC_thr_daemon(void * dummy) +{ + void *status; + thread_t departed; + register GC_thread t; + register int i; + register int result; + + for(;;) { + start: + result = thr_join((thread_t)0, &departed, &status); + LOCK(); + if (result != 0) { + /* No more threads; wait for create. */ + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (t = GC_threads[i]; t != 0; t = t -> next) { + if (!(t -> flags & (DETACHED | FINISHED))) { + UNLOCK(); + goto start; /* Thread started just before we */ + /* acquired the lock. */ + } + } + } + cond_wait(&GC_create_cv, &GC_allocate_ml); + UNLOCK(); + } else { + t = GC_lookup_thread(departed); + GC_multithreaded--; + if (!(t -> flags & CLIENT_OWNS_STACK)) { + GC_stack_free(t -> stack, t -> stack_size); + } + if (t -> flags & DETACHED) { + GC_delete_thread(departed); + } else { + t -> status = status; + t -> flags |= FINISHED; + cond_signal(&(t -> join_cv)); + cond_broadcast(&GC_prom_join_cv); + } + UNLOCK(); + } + } +} + +/* We hold the allocation lock, or caller ensures that 2 instances */ +/* cannot be invoked concurrently. */ +void GC_thr_init(void) +{ + GC_thread t; + thread_t tid; + + if (GC_thr_initialized) + return; + GC_thr_initialized = TRUE; + GC_min_stack_sz = ((thr_min_stack() + 32*1024 + HBLKSIZE-1) + & ~(HBLKSIZE - 1)); + GC_page_sz = sysconf(_SC_PAGESIZE); +#ifdef MMAP_STACKS + GC_zfd = open("/dev/zero", O_RDONLY); + if (GC_zfd == -1) + ABORT("Can't open /dev/zero"); +#endif /* MMAP_STACKS */ + cond_init(&GC_prom_join_cv, USYNC_THREAD, 0); + cond_init(&GC_create_cv, USYNC_THREAD, 0); + /* Add the initial thread, so we can stop it. */ + t = GC_new_thread(thr_self()); + t -> stack_size = 0; + t -> flags = DETACHED | CLIENT_OWNS_STACK; + if (thr_create(0 /* stack */, 0 /* stack_size */, GC_thr_daemon, + 0 /* arg */, THR_DETACHED | THR_DAEMON, + &tid /* thread_id */) != 0) { + ABORT("Cant fork daemon"); + } + thr_setprio(tid, 126); +} + +/* We acquire the allocation lock to prevent races with */ +/* stopping/starting world. */ +/* This is no more correct than the underlying Solaris 2.X */ +/* implementation. Under 2.3 THIS IS BROKEN. */ +int GC_thr_suspend(thread_t target_thread) +{ + GC_thread t; + int result; + + LOCK(); + result = thr_suspend(target_thread); + if (result == 0) { + t = GC_lookup_thread(target_thread); + if (t == 0) ABORT("thread unknown to GC"); + t -> flags |= SUSPENDED; + } + UNLOCK(); + return(result); +} + +int GC_thr_continue(thread_t target_thread) +{ + GC_thread t; + int result; + + LOCK(); + result = thr_continue(target_thread); + if (result == 0) { + t = GC_lookup_thread(target_thread); + if (t == 0) ABORT("thread unknown to GC"); + t -> flags &= ~SUSPENDED; + } + UNLOCK(); + return(result); +} + +int GC_thr_join(thread_t wait_for, thread_t *departed, void **status) +{ + register GC_thread t; + int result = 0; + + LOCK(); + if (wait_for == 0) { + register int i; + register GC_bool thread_exists; + + for (;;) { + thread_exists = FALSE; + for (i = 0; i < THREAD_TABLE_SZ; i++) { + for (t = GC_threads[i]; t != 0; t = t -> next) { + if (!(t -> flags & DETACHED)) { + if (t -> flags & FINISHED) { + goto found; + } + thread_exists = TRUE; + } + } + } + if (!thread_exists) { + result = ESRCH; + goto out; + } + cond_wait(&GC_prom_join_cv, &GC_allocate_ml); + } + } else { + t = GC_lookup_thread(wait_for); + if (t == 0 || t -> flags & DETACHED) { + result = ESRCH; + goto out; + } + if (wait_for == thr_self()) { + result = EDEADLK; + goto out; + } + while (!(t -> flags & FINISHED)) { + cond_wait(&(t -> join_cv), &GC_allocate_ml); + } + + } + found: + if (status) *status = t -> status; + if (departed) *departed = t -> id; + cond_destroy(&(t -> join_cv)); + GC_delete_thread(t -> id); + out: + UNLOCK(); + return(result); +} + + +int +GC_thr_create(void *stack_base, size_t stack_size, + void *(*start_routine)(void *), void *arg, long flags, + thread_t *new_thread) +{ + int result; + GC_thread t; + thread_t my_new_thread; + word my_flags = 0; + void * stack = stack_base; + + LOCK(); + if (!GC_thr_initialized) + { + GC_thr_init(); + } + GC_multithreaded++; + if (stack == 0) { + if (stack_size == 0) stack_size = GC_min_stack_sz; + stack = (void *)GC_stack_alloc(&stack_size); + if (stack == 0) { + GC_multithreaded--; + UNLOCK(); + return(ENOMEM); + } + } else { + my_flags |= CLIENT_OWNS_STACK; + } + if (flags & THR_DETACHED) my_flags |= DETACHED; + if (flags & THR_SUSPENDED) my_flags |= SUSPENDED; + result = thr_create(stack, stack_size, start_routine, + arg, flags & ~THR_DETACHED, &my_new_thread); + if (result == 0) { + t = GC_new_thread(my_new_thread); + t -> flags = my_flags; + if (!(my_flags & DETACHED)) cond_init(&(t -> join_cv), USYNC_THREAD, 0); + t -> stack = stack; + t -> stack_size = stack_size; + if (new_thread != 0) *new_thread = my_new_thread; + cond_signal(&GC_create_cv); + } else { + GC_multithreaded--; + if (!(my_flags & CLIENT_OWNS_STACK)) { + GC_stack_free(stack, stack_size); + } + } + UNLOCK(); + return(result); +} + +# else /* SOLARIS_THREADS */ + +#ifndef LINT + int GC_no_sunOS_threads; +#endif +#endif diff --git a/support/gc/solaris_threads.h b/support/gc/solaris_threads.h new file mode 100644 index 00000000..b2cdb36e --- /dev/null +++ b/support/gc/solaris_threads.h @@ -0,0 +1,34 @@ +#ifdef SOLARIS_THREADS + +/* The set of all known threads. We intercept thread creation and */ +/* joins. We never actually create detached threads. We allocate all */ +/* new thread stacks ourselves. These allow us to maintain this */ +/* data structure. */ +/* Protected by GC_thr_lock. */ +/* Some of this should be declared volatile, but that's incosnsistent */ +/* with some library routine declarations. In particular, the */ +/* definition of cond_t doesn't mention volatile! */ + typedef struct GC_Thread_Rep { + struct GC_Thread_Rep * next; + thread_t id; + word flags; +# define FINISHED 1 /* Thread has exited. */ +# define DETACHED 2 /* Thread is intended to be detached. */ +# define CLIENT_OWNS_STACK 4 + /* Stack was supplied by client. */ +# define SUSPENDED 8 /* Currently suspended. */ + ptr_t stack; + size_t stack_size; + cond_t join_cv; + void * status; + } * GC_thread; + extern GC_thread GC_new_thread(thread_t id); + + extern GC_bool GC_thr_initialized; + extern volatile GC_thread GC_threads[]; + extern size_t GC_min_stack_sz; + extern size_t GC_page_sz; + extern void GC_thr_init(void); + +# endif /* SOLARIS_THREADS */ + diff --git a/support/gc/sparc_mach_dep.s b/support/gc/sparc_mach_dep.s new file mode 100644 index 00000000..9831c6ca --- /dev/null +++ b/support/gc/sparc_mach_dep.s @@ -0,0 +1,38 @@ +! SPARCompiler 3.0 and later apparently no longer handles +! asm outside functions. So we need a separate .s file +! This is only set up for SunOS 5, not SunOS 4. +! Assumes this is called before the stack contents are +! examined. + + .seg "text" + .globl GC_save_regs_in_stack + .globl GC_push_regs +GC_save_regs_in_stack: +GC_push_regs: + ta 0x3 ! ST_FLUSH_WINDOWS + mov %sp,%o0 + retl + nop + + .globl GC_clear_stack_inner +GC_clear_stack_inner: + mov %sp,%o2 ! Save sp + add %sp,-8,%o3 ! p = sp-8 + clr %g1 ! [g0,g1] = 0 + add %o1,-0x60,%sp ! Move sp out of the way, + ! so that traps still work. + ! Includes some extra words + ! so we can be sloppy below. +loop: + std %g0,[%o3] ! *(long long *)p = 0 + cmp %o3,%o1 + bgu loop ! if (p > limit) goto loop + add %o3,-8,%o3 ! p -= 8 (delay slot) + retl + mov %o2,%sp ! Restore sp., delay slot + + + + + + diff --git a/support/gc/sparc_sunos4_mach_dep.s b/support/gc/sparc_sunos4_mach_dep.s new file mode 100644 index 00000000..41858073 --- /dev/null +++ b/support/gc/sparc_sunos4_mach_dep.s @@ -0,0 +1,38 @@ +! SPARCompiler 3.0 and later apparently no longer handles +! asm outside functions. So we need a separate .s file +! This is only set up for SunOS 4. +! Assumes this is called before the stack contents are +! examined. + + .seg "text" + .globl _GC_save_regs_in_stack + .globl _GC_push_regs +_GC_save_regs_in_stack: +_GC_push_regs: + ta 0x3 ! ST_FLUSH_WINDOWS + mov %sp,%o0 + retl + nop + + .globl _GC_clear_stack_inner +_GC_clear_stack_inner: + mov %sp,%o2 ! Save sp + add %sp,-8,%o3 ! p = sp-8 + clr %g1 ! [g0,g1] = 0 + add %o1,-0x60,%sp ! Move sp out of the way, + ! so that traps still work. + ! Includes some extra words + ! so we can be sloppy below. +loop: + std %g0,[%o3] ! *(long long *)p = 0 + cmp %o3,%o1 + bgu loop ! if (p > limit) goto loop + add %o3,-8,%o3 ! p -= 8 (delay slot) + retl + mov %o2,%sp ! Restore sp., delay slot + + + + + + diff --git a/support/gc/stubborn.c b/support/gc/stubborn.c new file mode 100644 index 00000000..bef7b98a --- /dev/null +++ b/support/gc/stubborn.c @@ -0,0 +1,317 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* Boehm, July 31, 1995 5:02 pm PDT */ + + +#include "gc_priv.h" + +# ifdef STUBBORN_ALLOC +/* Stubborn object (hard to change, nearly immutable) allocation. */ + +extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */ + +#define GENERAL_MALLOC(lb,k) \ + (GC_PTR)GC_clear_stack(GC_generic_malloc((word)lb, k)) + +/* Data structure representing immutable objects that */ +/* are still being initialized. */ +/* This is a bit baroque in order to avoid acquiring */ +/* the lock twice for a typical allocation. */ + +GC_PTR * GC_changing_list_start; + +# ifdef THREADS + VOLATILE GC_PTR * VOLATILE GC_changing_list_current; +# else + GC_PTR * GC_changing_list_current; +# endif + /* Points at last added element. Also (ab)used for */ + /* synchronization. Updates and reads are assumed atomic. */ + +GC_PTR * GC_changing_list_limit; + /* Points at the last word of the buffer, which is always 0 */ + /* All entries in (GC_changing_list_current, */ + /* GC_changing_list_limit] are 0 */ + + +void GC_stubborn_init() +{ +# define INIT_SIZE 10 + + GC_changing_list_start = (GC_PTR *) + GC_generic_malloc_inner( + (word)(INIT_SIZE * sizeof(GC_PTR)), + PTRFREE); + BZERO(GC_changing_list_start, + INIT_SIZE * sizeof(GC_PTR)); + if (GC_changing_list_start == 0) { + GC_err_printf0("Insufficient space to start up\n"); + ABORT("GC_stubborn_init: put of space"); + } + GC_changing_list_current = GC_changing_list_start; + GC_changing_list_limit = GC_changing_list_start + INIT_SIZE - 1; + * GC_changing_list_limit = 0; +} + +/* Compact and possibly grow GC_uninit_list. The old copy is */ +/* left alone. Lock must be held. */ +/* When called GC_changing_list_current == GC_changing_list_limit */ +/* which is one past the current element. */ +/* When we finish GC_changing_list_current again points one past last */ +/* element. */ +/* Invariant while this is running: GC_changing_list_current */ +/* points at a word containing 0. */ +/* Returns FALSE on failure. */ +GC_bool GC_compact_changing_list() +{ + register GC_PTR *p, *q; + register word count = 0; + word old_size = (char **)GC_changing_list_limit + - (char **)GC_changing_list_start+1; + /* The casts are needed as a workaround for an Amiga bug */ + register word new_size = old_size; + GC_PTR * new_list; + + for (p = GC_changing_list_start; p < GC_changing_list_limit; p++) { + if (*p != 0) count++; + } + if (2 * count > old_size) new_size = 2 * count; + new_list = (GC_PTR *) + GC_generic_malloc_inner( + new_size * sizeof(GC_PTR), PTRFREE); + /* PTRFREE is a lie. But we don't want the collector to */ + /* consider these. We do want the list itself to be */ + /* collectable. */ + if (new_list == 0) return(FALSE); + BZERO(new_list, new_size * sizeof(GC_PTR)); + q = new_list; + for (p = GC_changing_list_start; p < GC_changing_list_limit; p++) { + if (*p != 0) *q++ = *p; + } + GC_changing_list_start = new_list; + GC_changing_list_limit = new_list + new_size - 1; + GC_changing_list_current = q; + return(TRUE); +} + +/* Add p to changing list. Clear p on failure. */ +# define ADD_CHANGING(p) \ + { \ + register struct hblk * h = HBLKPTR(p); \ + register word index = PHT_HASH(h); \ + \ + set_pht_entry_from_index(GC_changed_pages, index); \ + } \ + if (*GC_changing_list_current != 0 \ + && ++GC_changing_list_current == GC_changing_list_limit) { \ + if (!GC_compact_changing_list()) (p) = 0; \ + } \ + *GC_changing_list_current = p; + +void GC_change_stubborn(p) +GC_PTR p; +{ + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + ADD_CHANGING(p); + UNLOCK(); + ENABLE_SIGNALS(); +} + +void GC_end_stubborn_change(p) +GC_PTR p; +{ +# ifdef THREADS + register VOLATILE GC_PTR * my_current = GC_changing_list_current; +# else + register GC_PTR * my_current = GC_changing_list_current; +# endif + register GC_bool tried_quick; + DCL_LOCK_STATE; + + if (*my_current == p) { + /* Hopefully the normal case. */ + /* Compaction could not have been running when we started. */ + *my_current = 0; +# ifdef THREADS + if (my_current == GC_changing_list_current) { + /* Compaction can't have run in the interim. */ + /* We got away with the quick and dirty approach. */ + return; + } + tried_quick = TRUE; +# else + return; +# endif + } else { + tried_quick = FALSE; + } + DISABLE_SIGNALS(); + LOCK(); + my_current = GC_changing_list_current; + for (; my_current >= GC_changing_list_start; my_current--) { + if (*my_current == p) { + *my_current = 0; + UNLOCK(); + ENABLE_SIGNALS(); + return; + } + } + if (!tried_quick) { + GC_err_printf1("Bad arg to GC_end_stubborn_change: 0x%lx\n", + (unsigned long)p); + ABORT("Bad arg to GC_end_stubborn_change"); + } + UNLOCK(); + ENABLE_SIGNALS(); +} + +/* Allocate lb bytes of composite (pointerful) data */ +/* No pointer fields may be changed after a call to */ +/* GC_end_stubborn_change(p) where p is the value */ +/* returned by GC_malloc_stubborn. */ +# ifdef __STDC__ + GC_PTR GC_malloc_stubborn(size_t lb) +# else + GC_PTR GC_malloc_stubborn(lb) + size_t lb; +# endif +{ +register ptr_t op; +register ptr_t *opp; +register word lw; +ptr_t result; +DCL_LOCK_STATE; + + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_sobjfreelist[lw]); + FASTLOCK(); + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { + FASTUNLOCK(); + result = GC_generic_malloc((word)lb, STUBBORN); + goto record; + } + *opp = obj_link(op); + obj_link(op) = 0; + GC_words_allocd += lw; + result = (GC_PTR) op; + ADD_CHANGING(result); + FASTUNLOCK(); + return((GC_PTR)result); + } else { + result = (GC_PTR) + GC_generic_malloc((word)lb, STUBBORN); + } +record: + DISABLE_SIGNALS(); + LOCK(); + ADD_CHANGING(result); + UNLOCK(); + ENABLE_SIGNALS(); + return((GC_PTR)GC_clear_stack(result)); +} + + +/* Functions analogous to GC_read_dirty and GC_page_was_dirty. */ +/* Report pages on which stubborn objects were changed. */ +void GC_read_changed() +{ + register GC_PTR * p = GC_changing_list_start; + register GC_PTR q; + register struct hblk * h; + register word index; + + if (p == 0) /* initializing */ return; + BCOPY(GC_changed_pages, GC_prev_changed_pages, + (sizeof GC_changed_pages)); + BZERO(GC_changed_pages, (sizeof GC_changed_pages)); + for (; p <= GC_changing_list_current; p++) { + if ((q = *p) != 0) { + h = HBLKPTR(q); + index = PHT_HASH(h); + set_pht_entry_from_index(GC_changed_pages, index); + } + } +} + +GC_bool GC_page_was_changed(h) +struct hblk * h; +{ + register word index = PHT_HASH(h); + + return(get_pht_entry_from_index(GC_prev_changed_pages, index)); +} + +/* Remove unreachable entries from changed list. Should only be */ +/* called with mark bits consistent and lock held. */ +void GC_clean_changing_list() +{ + register GC_PTR * p = GC_changing_list_start; + register GC_PTR q; + register ptr_t r; + register unsigned long count = 0; + register unsigned long dropped_count = 0; + + if (p == 0) /* initializing */ return; + for (; p <= GC_changing_list_current; p++) { + if ((q = *p) != 0) { + count++; + r = (ptr_t)GC_base(q); + if (r == 0 || !GC_is_marked(r)) { + *p = 0; + dropped_count++; + } + } + } +# ifdef PRINTSTATS + if (count > 0) { + GC_printf2("%lu entries in changing list: reclaimed %lu\n", + (unsigned long)count, (unsigned long)dropped_count); + } +# endif +} + +#else /* !STUBBORN_ALLOC */ + +# ifdef __STDC__ + GC_PTR GC_malloc_stubborn(size_t lb) +# else + GC_PTR GC_malloc_stubborn(lb) + size_t lb; +# endif +{ + return(GC_malloc(lb)); +} + +/*ARGSUSED*/ +void GC_end_stubborn_change(p) +GC_PTR p; +{ +} + +/*ARGSUSED*/ +void GC_change_stubborn(p) +GC_PTR p; +{ +} + + +#endif diff --git a/support/gc/test.c b/support/gc/test.c new file mode 100644 index 00000000..b65632c9 --- /dev/null +++ b/support/gc/test.c @@ -0,0 +1,1263 @@ +/* + * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ +/* An incomplete test for the garbage collector. */ +/* Some more obscure entry points are not tested at all. */ + +# if defined(mips) && defined(SYSTYPE_BSD43) + /* MIPS RISCOS 4 */ +# else +# include +# endif +# include +# include /* Not normally used, but handy for debugging. */ +# include "gc.h" +# include "gc_typed.h" +# include "gc_priv.h" /* For output, locking, and some statistics */ +# include "gcconfig.h" + +# ifdef MSWIN32 +# include +# endif + +# ifdef PCR +# include "th/PCR_ThCrSec.h" +# include "th/PCR_Th.h" +# undef GC_printf0 +# define GC_printf0 printf +# undef GC_printf1 +# define GC_printf1 printf +# endif + +# ifdef SOLARIS_THREADS +# include +# include +# endif + +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) +# include +# endif + +# ifdef WIN32_THREADS +# include + static CRITICAL_SECTION incr_cs; +# endif +# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) +# define THREADS +# endif + +# ifdef AMIGA + long __stack = 200000; +# endif + +# define FAIL (void)abort() + +/* AT_END may be defined to excercise the interior pointer test */ +/* if the collector is configured with ALL_INTERIOR_POINTERS. */ +/* As it stands, this test should succeed with either */ +/* configuration. In the FIND_LEAK configuration, it should */ +/* find lots of leaks, since we free almost nothing. */ + +struct SEXPR { + struct SEXPR * sexpr_car; + struct SEXPR * sexpr_cdr; +}; + + +typedef struct SEXPR * sexpr; + +# define INT_TO_SEXPR(x) ((sexpr)(unsigned long)(x)) + +# undef nil +# define nil (INT_TO_SEXPR(0)) +# define car(x) ((x) -> sexpr_car) +# define cdr(x) ((x) -> sexpr_cdr) +# define is_nil(x) ((x) == nil) + + +int extra_count = 0; /* Amount of space wasted in cons node */ + +/* Silly implementation of Lisp cons. Intentionally wastes lots of space */ +/* to test collector. */ +sexpr cons (x, y) +sexpr x; +sexpr y; +{ + register sexpr r; + register int *p; + register int my_extra = extra_count; + + r = (sexpr) GC_MALLOC_STUBBORN(sizeof(struct SEXPR) + my_extra); + if (r == 0) { + (void)GC_printf0("Out of memory\n"); + exit(1); + } + for (p = (int *)r; + ((char *)p) < ((char *)r) + my_extra + sizeof(struct SEXPR); p++) { + if (*p) { + (void)GC_printf1("Found nonzero at 0x%lx - allocator is broken\n", + (unsigned long)p); + FAIL; + } + *p = 13; + } +# ifdef AT_END + r = (sexpr)((char *)r + (my_extra & ~7)); +# endif + r -> sexpr_car = x; + r -> sexpr_cdr = y; + my_extra++; + if ( my_extra >= 5000 ) { + extra_count = 0; + } else { + extra_count = my_extra; + } + GC_END_STUBBORN_CHANGE((char *)r); + return(r); +} + +sexpr small_cons (x, y) +sexpr x; +sexpr y; +{ + register sexpr r; + + r = (sexpr) GC_MALLOC(sizeof(struct SEXPR)); + if (r == 0) { + (void)GC_printf0("Out of memory\n"); + exit(1); + } + r -> sexpr_car = x; + r -> sexpr_cdr = y; + return(r); +} + +sexpr small_cons_uncollectable (x, y) +sexpr x; +sexpr y; +{ + register sexpr r; + + r = (sexpr) GC_MALLOC_UNCOLLECTABLE(sizeof(struct SEXPR)); +assert(GC_is_marked(r)); + if (r == 0) { + (void)GC_printf0("Out of memory\n"); + exit(1); + } + r -> sexpr_car = x; + r -> sexpr_cdr = (sexpr)(~(unsigned long)y); + return(r); +} + +/* Return reverse(x) concatenated with y */ +sexpr reverse1(x, y) +sexpr x, y; +{ + if (is_nil(x)) { + return(y); + } else { + return( reverse1(cdr(x), cons(car(x), y)) ); + } +} + +sexpr reverse(x) +sexpr x; +{ + return( reverse1(x, nil) ); +} + +sexpr ints(low, up) +int low, up; +{ + if (low > up) { + return(nil); + } else { + return(small_cons(small_cons(INT_TO_SEXPR(low), nil), ints(low+1, up))); + } +} + +/* To check uncollectable allocation we build lists with disguised cdr */ +/* pointers, and make sure they don't go away. */ +sexpr uncollectable_ints(low, up) +int low, up; +{ + if (low > up) { + return(nil); + } else { + return(small_cons_uncollectable(small_cons(INT_TO_SEXPR(low), nil), + uncollectable_ints(low+1, up))); + } +} + +void check_ints(list, low, up) +sexpr list; +int low, up; +{ + if ((int)(GC_word)(car(car(list))) != low) { + (void)GC_printf0( + "List reversal produced incorrect list - collector is broken\n"); + FAIL; + } + if (low == up) { + if (cdr(list) != nil) { + (void)GC_printf0("List too long - collector is broken\n"); + FAIL; + } + } else { + check_ints(cdr(list), low+1, up); + } +} + +# define UNCOLLECTABLE_CDR(x) (sexpr)(~(unsigned long)(cdr(x))) + +void check_uncollectable_ints(list, low, up) +sexpr list; +int low, up; +{ +assert(GC_is_marked(list)); + if ((int)(GC_word)(car(car(list))) != low) { + (void)GC_printf0( + "Uncollectable list corrupted - collector is broken\n"); + FAIL; + } + if (low == up) { + if (UNCOLLECTABLE_CDR(list) != nil) { + (void)GC_printf0("Uncollectable list too long - collector is broken\n"); + FAIL; + } + } else { + check_uncollectable_ints(UNCOLLECTABLE_CDR(list), low+1, up); + } +} + +/* Not used, but useful for debugging: */ +void print_int_list(x) +sexpr x; +{ + if (is_nil(x)) { + (void)GC_printf0("NIL\n"); + } else { + (void)GC_printf1("(%ld)", (long)(car(car(x)))); + if (!is_nil(cdr(x))) { + (void)GC_printf0(", "); + (void)print_int_list(cdr(x)); + } else { + (void)GC_printf0("\n"); + } + } +} + +/* Try to force a to be strangely aligned */ +struct { + char dummy; + sexpr aa; +} A; +#define a A.aa + +/* + * A tiny list reversal test to check thread creation. + */ +#ifdef THREADS + +# ifdef WIN32_THREADS + unsigned __stdcall tiny_reverse_test(void * arg) +# else + void * tiny_reverse_test(void * arg) +# endif +{ + check_ints(reverse(reverse(ints(1,10))), 1, 10); + return 0; +} + +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \ + || defined(SOLARIS_PTHREADS) + void fork_a_thread() + { + pthread_t t; + int code; + if ((code = pthread_create(&t, 0, tiny_reverse_test, 0)) != 0) { + (void)GC_printf1("Small thread creation failed %lu\n", + (unsigned long)code); + FAIL; + } + if ((code = pthread_join(t, 0)) != 0) { + (void)GC_printf1("Small thread join failed %lu\n", + (unsigned long)code); + FAIL; + } + } + +# elif defined(WIN32_THREADS) + void fork_a_thread() + { + unsigned thread_id; + HANDLE h; + h = (HANDLE)_beginthreadex(NULL, 0, tiny_reverse_test, + 0, 0, &thread_id); + if (h == (HANDLE)-1) { + (void)GC_printf1("Small thread creation failed %lu\n", + (unsigned long)GetLastError()); + FAIL; + } + if (WaitForSingleObject(h, INFINITE) != WAIT_OBJECT_0) { + (void)GC_printf1("Small thread wait failed %lu\n", + (unsigned long)GetLastError()); + FAIL; + } + } + +/* # elif defined(SOLARIS_THREADS) */ + +# else + +# define fork_a_thread() + +# endif + +#else + +# define fork_a_thread() + +#endif + +/* + * Repeatedly reverse lists built out of very different sized cons cells. + * Check that we didn't lose anything. + */ +void reverse_test() +{ + int i; + sexpr b; + sexpr c; + sexpr d; + sexpr e; + sexpr *f, *g, *h; +# if defined(MSWIN32) || defined(MACOS) + /* Win32S only allows 128K stacks */ +# define BIG 1000 +# else +# if defined PCR + /* PCR default stack is 100K. Stack frames are up to 120 bytes. */ +# define BIG 700 +# else +# define BIG 4500 +# endif +# endif + + A.dummy = 17; + a = ints(1, 49); + b = ints(1, 50); + c = ints(1, BIG); + d = uncollectable_ints(1, 100); + e = uncollectable_ints(1, 1); + /* Check that realloc updates object descriptors correctly */ + f = (sexpr *)GC_MALLOC(4 * sizeof(sexpr)); + f = (sexpr *)GC_REALLOC((GC_PTR)f, 6 * sizeof(sexpr)); + f[5] = ints(1,17); + g = (sexpr *)GC_MALLOC(513 * sizeof(sexpr)); + g = (sexpr *)GC_REALLOC((GC_PTR)g, 800 * sizeof(sexpr)); + g[799] = ints(1,18); + h = (sexpr *)GC_MALLOC(1025 * sizeof(sexpr)); + h = (sexpr *)GC_REALLOC((GC_PTR)h, 2000 * sizeof(sexpr)); + h[1999] = ints(1,19); + /* Try to force some collections and reuse of small list elements */ + for (i = 0; i < 10; i++) { + (void)ints(1, BIG); + } + /* Superficially test interior pointer recognition on stack */ + c = (sexpr)((char *)c + sizeof(char *)); + d = (sexpr)((char *)d + sizeof(char *)); + +# ifdef __STDC__ + GC_FREE((void *)e); +# else + GC_FREE((char *)e); +# endif + check_ints(b,1,50); + check_ints(a,1,49); + for (i = 0; i < 50; i++) { + check_ints(b,1,50); + b = reverse(reverse(b)); + } + check_ints(b,1,50); + check_ints(a,1,49); + for (i = 0; i < 60; i++) { + if (i % 10 == 0) fork_a_thread(); + /* This maintains the invariant that a always points to a list of */ + /* 49 integers. Thus this is thread safe without locks, */ + /* assuming atomic pointer assignments. */ + a = reverse(reverse(a)); +# if !defined(AT_END) && !defined(THREADS) + /* This is not thread safe, since realloc explicitly deallocates */ + if (i & 1) { + a = (sexpr)GC_REALLOC((GC_PTR)a, 500); + } else { + a = (sexpr)GC_REALLOC((GC_PTR)a, 8200); + } +# endif + } + check_ints(a,1,49); + check_ints(b,1,50); + c = (sexpr)((char *)c - sizeof(char *)); + d = (sexpr)((char *)d - sizeof(char *)); + check_ints(c,1,BIG); + check_uncollectable_ints(d, 1, 100); + check_ints(f[5], 1,17); + check_ints(g[799], 1,18); + check_ints(h[1999], 1,19); +# ifndef THREADS + a = 0; +# endif + b = c = 0; +} + +/* + * The rest of this builds balanced binary trees, checks that they don't + * disappear, and tests finalization. + */ +typedef struct treenode { + int level; + struct treenode * lchild; + struct treenode * rchild; +} tn; + +int finalizable_count = 0; +int finalized_count = 0; +VOLATILE int dropped_something = 0; + +# ifdef __STDC__ + void finalizer(void * obj, void * client_data) +# else + void finalizer(obj, client_data) + char * obj; + char * client_data; +# endif +{ + tn * t = (tn *)obj; + +# ifdef PCR + PCR_ThCrSec_EnterSys(); +# endif +# ifdef SOLARIS_THREADS + static mutex_t incr_lock; + mutex_lock(&incr_lock); +# endif +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) + static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_lock(&incr_lock); +# endif +# ifdef WIN32_THREADS + EnterCriticalSection(&incr_cs); +# endif + if ((int)(GC_word)client_data != t -> level) { + (void)GC_printf0("Wrong finalization data - collector is broken\n"); + FAIL; + } + finalized_count++; +# ifdef PCR + PCR_ThCrSec_ExitSys(); +# endif +# ifdef SOLARIS_THREADS + mutex_unlock(&incr_lock); +# endif +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) + pthread_mutex_unlock(&incr_lock); +# endif +# ifdef WIN32_THREADS + LeaveCriticalSection(&incr_cs); +# endif +} + +size_t counter = 0; + +# define MAX_FINALIZED 8000 + +# if !defined(MACOS) + GC_FAR GC_word live_indicators[MAX_FINALIZED] = {0}; +#else + /* Too big for THINK_C. have to allocate it dynamically. */ + GC_word *live_indicators = 0; +#endif + +int live_indicators_count = 0; + +tn * mktree(n) +int n; +{ + tn * result = (tn *)GC_MALLOC(sizeof(tn)); + +#if defined(MACOS) + /* get around static data limitations. */ + if (!live_indicators) + live_indicators = + (GC_word*)NewPtrClear(MAX_FINALIZED * sizeof(GC_word)); + if (!live_indicators) { + (void)GC_printf0("Out of memory\n"); + exit(1); + } +#endif + if (n == 0) return(0); + if (result == 0) { + (void)GC_printf0("Out of memory\n"); + exit(1); + } + result -> level = n; + result -> lchild = mktree(n-1); + result -> rchild = mktree(n-1); + if (counter++ % 17 == 0 && n >= 2) { + tn * tmp = result -> lchild -> rchild; + + result -> lchild -> rchild = result -> rchild -> lchild; + result -> rchild -> lchild = tmp; + } + if (counter++ % 119 == 0) { + int my_index; + + { +# ifdef PCR + PCR_ThCrSec_EnterSys(); +# endif +# ifdef SOLARIS_THREADS + static mutex_t incr_lock; + mutex_lock(&incr_lock); +# endif +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) + static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_lock(&incr_lock); +# endif +# ifdef WIN32_THREADS + EnterCriticalSection(&incr_cs); +# endif + /* Losing a count here causes erroneous report of failure. */ + finalizable_count++; + my_index = live_indicators_count++; +# ifdef PCR + PCR_ThCrSec_ExitSys(); +# endif +# ifdef SOLARIS_THREADS + mutex_unlock(&incr_lock); +# endif +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) + pthread_mutex_unlock(&incr_lock); +# endif +# ifdef WIN32_THREADS + LeaveCriticalSection(&incr_cs); +# endif + } + + GC_REGISTER_FINALIZER((GC_PTR)result, finalizer, (GC_PTR)(GC_word)n, + (GC_finalization_proc *)0, (GC_PTR *)0); + if (my_index >= MAX_FINALIZED) { + GC_printf0("live_indicators overflowed\n"); + FAIL; + } + live_indicators[my_index] = 13; + if (GC_GENERAL_REGISTER_DISAPPEARING_LINK( + (GC_PTR *)(&(live_indicators[my_index])), + (GC_PTR)result) != 0) { + GC_printf0("GC_general_register_disappearing_link failed\n"); + FAIL; + } + if (GC_unregister_disappearing_link( + (GC_PTR *) + (&(live_indicators[my_index]))) == 0) { + GC_printf0("GC_unregister_disappearing_link failed\n"); + FAIL; + } + if (GC_GENERAL_REGISTER_DISAPPEARING_LINK( + (GC_PTR *)(&(live_indicators[my_index])), + (GC_PTR)result) != 0) { + GC_printf0("GC_general_register_disappearing_link failed 2\n"); + FAIL; + } + } + return(result); +} + +void chktree(t,n) +tn *t; +int n; +{ + if (n == 0 && t != 0) { + (void)GC_printf0("Clobbered a leaf - collector is broken\n"); + FAIL; + } + if (n == 0) return; + if (t -> level != n) { + (void)GC_printf1("Lost a node at level %lu - collector is broken\n", + (unsigned long)n); + FAIL; + } + if (counter++ % 373 == 0) (void) GC_MALLOC(counter%5001); + chktree(t -> lchild, n-1); + if (counter++ % 73 == 0) (void) GC_MALLOC(counter%373); + chktree(t -> rchild, n-1); +} + +# if defined(SOLARIS_THREADS) && !defined(_SOLARIS_PTHREADS) +thread_key_t fl_key; + +void * alloc8bytes() +{ +# if defined(SMALL_CONFIG) || defined(GC_DEBUG) + return(GC_MALLOC(8)); +# else + void ** my_free_list_ptr; + void * my_free_list; + + if (thr_getspecific(fl_key, (void **)(&my_free_list_ptr)) != 0) { + (void)GC_printf0("thr_getspecific failed\n"); + FAIL; + } + if (my_free_list_ptr == 0) { + my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *); + if (thr_setspecific(fl_key, my_free_list_ptr) != 0) { + (void)GC_printf0("thr_setspecific failed\n"); + FAIL; + } + } + my_free_list = *my_free_list_ptr; + if (my_free_list == 0) { + my_free_list = GC_malloc_many(8); + if (my_free_list == 0) { + (void)GC_printf0("alloc8bytes out of memory\n"); + FAIL; + } + } + *my_free_list_ptr = GC_NEXT(my_free_list); + GC_NEXT(my_free_list) = 0; + return(my_free_list); +# endif +} + +#else + +# if defined(_SOLARIS_PTHREADS) || defined(IRIX_THREADS) \ + || defined(LINUX_THREADS) +pthread_key_t fl_key; + +void * alloc8bytes() +{ +# ifdef SMALL_CONFIG + return(GC_malloc(8)); +# else + void ** my_free_list_ptr; + void * my_free_list; + + my_free_list_ptr = (void **)pthread_getspecific(fl_key); + if (my_free_list_ptr == 0) { + my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *); + if (pthread_setspecific(fl_key, my_free_list_ptr) != 0) { + (void)GC_printf0("pthread_setspecific failed\n"); + FAIL; + } + } + my_free_list = *my_free_list_ptr; + if (my_free_list == 0) { + my_free_list = GC_malloc_many(8); + if (my_free_list == 0) { + (void)GC_printf0("alloc8bytes out of memory\n"); + FAIL; + } + } + *my_free_list_ptr = GC_NEXT(my_free_list); + GC_NEXT(my_free_list) = 0; + return(my_free_list); +# endif +} + +# else +# define alloc8bytes() GC_MALLOC_ATOMIC(8) +# endif +#endif + +void alloc_small(n) +int n; +{ + register int i; + + for (i = 0; i < n; i += 8) { + if (alloc8bytes() == 0) { + (void)GC_printf0("Out of memory\n"); + FAIL; + } + } +} + +# if defined(THREADS) && defined(GC_DEBUG) +# define TREE_HEIGHT 15 +# else +# define TREE_HEIGHT 16 +# endif +void tree_test() +{ + tn * root; + register int i; + + root = mktree(TREE_HEIGHT); + alloc_small(5000000); + chktree(root, TREE_HEIGHT); + if (finalized_count && ! dropped_something) { + (void)GC_printf0("Premature finalization - collector is broken\n"); + FAIL; + } + dropped_something = 1; + GC_noop(root); /* Root needs to remain live until */ + /* dropped_something is set. */ + root = mktree(TREE_HEIGHT); + chktree(root, TREE_HEIGHT); + for (i = TREE_HEIGHT; i >= 0; i--) { + root = mktree(i); + chktree(root, i); + } + alloc_small(5000000); +} + +unsigned n_tests = 0; + +GC_word bm_huge[10] = { + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0x00ffffff, +}; + + +/* A very simple test of explicitly typed allocation */ +void typed_test() +{ + GC_word * old, * new; + GC_word bm3 = 0x3; + GC_word bm2 = 0x2; + GC_word bm_large = 0xf7ff7fff; + GC_descr d1 = GC_make_descriptor(&bm3, 2); + GC_descr d2 = GC_make_descriptor(&bm2, 2); +# ifndef LINT + GC_descr dummy = GC_make_descriptor(&bm_large, 32); +# endif + GC_descr d3 = GC_make_descriptor(&bm_large, 32); + GC_descr d4 = GC_make_descriptor(bm_huge, 320); + GC_word * x = (GC_word *)GC_malloc_explicitly_typed(2000, d4); + register int i; + + old = 0; + for (i = 0; i < 4000; i++) { + new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d1); + new[0] = 17; + new[1] = (GC_word)old; + old = new; + new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d2); + new[0] = 17; + new[1] = (GC_word)old; + old = new; + new = (GC_word *) GC_malloc_explicitly_typed(33 * sizeof(GC_word), d3); + new[0] = 17; + new[1] = (GC_word)old; + old = new; + new = (GC_word *) GC_calloc_explicitly_typed(4, 2 * sizeof(GC_word), + d1); + new[0] = 17; + new[1] = (GC_word)old; + old = new; + if (i & 0xff) { + new = (GC_word *) GC_calloc_explicitly_typed(7, 3 * sizeof(GC_word), + d2); + } else { + new = (GC_word *) GC_calloc_explicitly_typed(1001, + 3 * sizeof(GC_word), + d2); + } + new[0] = 17; + new[1] = (GC_word)old; + old = new; + } + for (i = 0; i < 20000; i++) { + if (new[0] != 17) { + (void)GC_printf1("typed alloc failed at %lu\n", + (unsigned long)i); + FAIL; + } + new[0] = 0; + old = new; + new = (GC_word *)(old[1]); + } + GC_gcollect(); + GC_noop(x); +} + +int fail_count = 0; + +#ifndef __STDC__ +/*ARGSUSED*/ +void fail_proc1(x) +GC_PTR x; +{ + fail_count++; +} + +#else + +/*ARGSUSED*/ +void fail_proc1(GC_PTR x) +{ + fail_count++; +} + +#endif /* __STDC__ */ + +#ifdef THREADS +# define TEST_FAIL_COUNT(n) 1 +#else +# define TEST_FAIL_COUNT(n) (fail_count >= (n)) +#endif + +void run_one_test() +{ + char *x; +# ifdef LINT + char *y = 0; +# else + char *y = (char *)(size_t)fail_proc1; +# endif + DCL_LOCK_STATE; + +# ifdef FIND_LEAK + (void)GC_printf0( + "This test program is not designed for leak detection mode\n"); + (void)GC_printf0("Expect lots of problems.\n"); +# endif + if (GC_size(GC_malloc(7)) != 8 + || GC_size(GC_malloc(15)) != 16) { + (void)GC_printf0("GC_size produced unexpected results\n"); + FAIL; + } + if (GC_size(GC_malloc(0)) != 4 && GC_size(GC_malloc(0)) != 8) { + (void)GC_printf0("GC_malloc(0) failed\n"); + FAIL; + } + if (GC_size(GC_malloc_uncollectable(0)) != 4 + && GC_size(GC_malloc_uncollectable(0)) != 8) { + (void)GC_printf0("GC_malloc_uncollectable(0) failed\n"); + FAIL; + } + GC_is_valid_displacement_print_proc = fail_proc1; + GC_is_visible_print_proc = fail_proc1; + x = GC_malloc(16); + if (GC_base(x + 13) != x) { + (void)GC_printf0("GC_base(heap ptr) produced incorrect result\n"); + FAIL; + } +# ifndef PCR + if (GC_base(y) != 0) { + (void)GC_printf0("GC_base(fn_ptr) produced incorrect result\n"); + FAIL; + } +# endif + if (GC_same_obj(x+5, x) != x + 5) { + (void)GC_printf0("GC_same_obj produced incorrect result\n"); + FAIL; + } + if (GC_is_visible(y) != y || GC_is_visible(x) != x) { + (void)GC_printf0("GC_is_visible produced incorrect result\n"); + FAIL; + } + if (!TEST_FAIL_COUNT(1)) { +# if!(defined(RS6000) || defined(POWERPC)) + /* ON RS6000s function pointers point to a descriptor in the */ + /* data segment, so there should have been no failures. */ + (void)GC_printf0("GC_is_visible produced wrong failure indication\n"); + FAIL; +# endif + } + if (GC_is_valid_displacement(y) != y + || GC_is_valid_displacement(x) != x + || GC_is_valid_displacement(x + 3) != x + 3) { + (void)GC_printf0( + "GC_is_valid_displacement produced incorrect result\n"); + FAIL; + } +# ifndef ALL_INTERIOR_POINTERS +# if defined(RS6000) || defined(POWERPC) + if (!TEST_FAIL_COUNT(1)) { +# else + if (!TEST_FAIL_COUNT(2)) { +# endif + (void)GC_printf0("GC_is_valid_displacement produced wrong failure indication\n"); + FAIL; + } +# endif + /* Test floating point alignment */ + *(double *)GC_MALLOC(sizeof(double)) = 1.0; + *(double *)GC_MALLOC(sizeof(double)) = 1.0; + /* Repeated list reversal test. */ + reverse_test(); +# ifdef PRINTSTATS + GC_printf0("-------------Finished reverse_test\n"); +# endif + typed_test(); +# ifdef PRINTSTATS + GC_printf0("-------------Finished typed_test\n"); +# endif + tree_test(); + LOCK(); + n_tests++; + UNLOCK(); + /* GC_printf1("Finished %x\n", pthread_self()); */ +} + +void check_heap_stats() +{ + unsigned long max_heap_sz; + register int i; + int still_live; + int late_finalize_count = 0; + + if (sizeof(char *) > 4) { + max_heap_sz = 15000000; + } else { + max_heap_sz = 11000000; + } +# ifdef GC_DEBUG + max_heap_sz *= 2; +# ifdef SPARC + max_heap_sz *= 2; +# endif +# endif + /* Garbage collect repeatedly so that all inaccessible objects */ + /* can be finalized. */ + while (GC_collect_a_little()) { } + for (i = 0; i < 16; i++) { + GC_gcollect(); + late_finalize_count += GC_invoke_finalizers(); + } + (void)GC_printf1("Completed %lu tests\n", (unsigned long)n_tests); + (void)GC_printf2("Finalized %lu/%lu objects - ", + (unsigned long)finalized_count, + (unsigned long)finalizable_count); +# ifdef FINALIZE_ON_DEMAND + if (finalized_count != late_finalize_count) { + (void)GC_printf0("Demand finalization error\n"); + FAIL; + } +# endif + if (finalized_count > finalizable_count + || finalized_count < finalizable_count/2) { + (void)GC_printf0("finalization is probably broken\n"); + FAIL; + } else { + (void)GC_printf0("finalization is probably ok\n"); + } + still_live = 0; + for (i = 0; i < MAX_FINALIZED; i++) { + if (live_indicators[i] != 0) { + still_live++; + } + } + i = finalizable_count - finalized_count - still_live; + if (0 != i) { + (void)GC_printf2 + ("%lu disappearing links remain and %lu more objects were not finalized\n", + (unsigned long) still_live, (unsigned long)i); + if (i > 10) { + GC_printf0("\tVery suspicious!\n"); + } else { + GC_printf0("\tSlightly suspicious, but probably OK.\n"); + } + } + (void)GC_printf1("Total number of bytes allocated is %lu\n", + (unsigned long) + WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc)); + (void)GC_printf1("Final heap size is %lu bytes\n", + (unsigned long)GC_get_heap_size()); + if (WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc) + < 33500000*n_tests) { + (void)GC_printf0("Incorrect execution - missed some allocations\n"); + FAIL; + } + if (GC_get_heap_size() > max_heap_sz*n_tests) { + (void)GC_printf0("Unexpected heap growth - collector may be broken\n"); + FAIL; + } + (void)GC_printf0("Collector appears to work\n"); +} + +#if defined(MACOS) +void SetMinimumStack(long minSize) +{ + long newApplLimit; + + if (minSize > LMGetDefltStack()) + { + newApplLimit = (long) GetApplLimit() + - (minSize - LMGetDefltStack()); + SetApplLimit((Ptr) newApplLimit); + MaxApplZone(); + } +} + +#define cMinStackSpace (512L * 1024L) + +#endif + +#ifdef __STDC__ + void warn_proc(char *msg, GC_word p) +#else + void warn_proc(msg, p) + char *msg; + GC_word p; +#endif +{ + GC_printf1(msg, (unsigned long)p); + FAIL; +} + + +#if !defined(PCR) && !defined(SOLARIS_THREADS) && !defined(WIN32_THREADS) \ + && !defined(IRIX_THREADS) && !defined(LINUX_THREADS) || defined(LINT) +#ifdef MSWIN32 + int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n) +#else + int main() +#endif +{ +# if defined(DJGPP) + int dummy; +# endif + n_tests = 0; + +# if defined(DJGPP) + /* No good way to determine stack base from library; do it */ + /* manually on this platform. */ + GC_stackbottom = (GC_PTR)(&dummy); +# endif +# if defined(MACOS) + /* Make sure we have lots and lots of stack space. */ + SetMinimumStack(cMinStackSpace); + /* Cheat and let stdio initialize toolbox for us. */ + printf("Testing GC Macintosh port.\n"); +# endif + GC_INIT(); /* Only needed if gc is dynamic library. */ + (void) GC_set_warn_proc(warn_proc); +# if defined(MPROTECT_VDB) || defined(PROC_VDB) + GC_enable_incremental(); + (void) GC_printf0("Switched to incremental mode\n"); +# if defined(MPROTECT_VDB) + (void)GC_printf0("Emulating dirty bits with mprotect/signals\n"); +# else + (void)GC_printf0("Reading dirty bits from /proc\n"); +# endif +# endif + run_one_test(); + check_heap_stats(); + (void)fflush(stdout); +# ifdef LINT + /* Entry points we should be testing, but aren't. */ + /* Some can be tested by defining GC_DEBUG at the top of this file */ + /* This is a bit SunOS4 specific. */ + GC_noop(GC_expand_hp, GC_add_roots, GC_clear_roots, + GC_register_disappearing_link, + GC_register_finalizer_ignore_self, + GC_debug_register_displacement, + GC_print_obj, GC_debug_change_stubborn, + GC_debug_end_stubborn_change, GC_debug_malloc_uncollectable, + GC_debug_free, GC_debug_realloc, GC_generic_malloc_words_small, + GC_init, GC_make_closure, GC_debug_invoke_finalizer, + GC_page_was_ever_dirty, GC_is_fresh, + GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page, + GC_set_max_heap_size, GC_get_bytes_since_gc, + GC_pre_incr, GC_post_incr); +# endif +# ifdef MSWIN32 + GC_win32_free_heap(); +# endif + return(0); +} +# endif + +#ifdef WIN32_THREADS + +unsigned __stdcall thr_run_one_test(void *arg) +{ + run_one_test(); + return 0; +} + +#define NTEST 2 + +int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n) +{ +# if NTEST > 0 + HANDLE h[NTEST]; +# endif + int i; + unsigned thread_id; +# if 0 + GC_enable_incremental(); +# endif + InitializeCriticalSection(&incr_cs); + (void) GC_set_warn_proc(warn_proc); + for (i = 0; i < NTEST; i++) { + h[i] = (HANDLE)_beginthreadex(NULL, 0, thr_run_one_test, 0, 0, &thread_id); + if (h[i] == (HANDLE)-1) { + (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError()); + FAIL; + } + } + run_one_test(); + for (i = 0; i < NTEST; i++) + if (WaitForSingleObject(h[i], INFINITE) != WAIT_OBJECT_0) { + (void)GC_printf1("Thread wait failed %lu\n", (unsigned long)GetLastError()); + FAIL; + } + check_heap_stats(); + (void)fflush(stdout); + return(0); +} + +#endif /* WIN32_THREADS */ + + +#ifdef PCR +test() +{ + PCR_Th_T * th1; + PCR_Th_T * th2; + int code; + + n_tests = 0; + /* GC_enable_incremental(); */ + (void) GC_set_warn_proc(warn_proc); + th1 = PCR_Th_Fork(run_one_test, 0); + th2 = PCR_Th_Fork(run_one_test, 0); + run_one_test(); + if (PCR_Th_T_Join(th1, &code, NIL, PCR_allSigsBlocked, PCR_waitForever) + != PCR_ERes_okay || code != 0) { + (void)GC_printf0("Thread 1 failed\n"); + } + if (PCR_Th_T_Join(th2, &code, NIL, PCR_allSigsBlocked, PCR_waitForever) + != PCR_ERes_okay || code != 0) { + (void)GC_printf0("Thread 2 failed\n"); + } + check_heap_stats(); + (void)fflush(stdout); + return(0); +} +#endif + +#if defined(SOLARIS_THREADS) || defined(IRIX_THREADS) || defined(LINUX_THREADS) +void * thr_run_one_test(void * arg) +{ + run_one_test(); + return(0); +} + +#ifdef GC_DEBUG +# define GC_free GC_debug_free +#endif + +#ifdef SOLARIS_THREADS +main() +{ + thread_t th1; + thread_t th2; + int code; + + n_tests = 0; + GC_INIT(); /* Only needed if gc is dynamic library. */ + GC_enable_incremental(); + (void) GC_set_warn_proc(warn_proc); + if (thr_keycreate(&fl_key, GC_free) != 0) { + (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code); + FAIL; + } + if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, 0, &th1)) != 0) { + (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code); + FAIL; + } + if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, THR_NEW_LWP, &th2)) != 0) { + (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code); + FAIL; + } + run_one_test(); + if ((code = thr_join(th1, 0, 0)) != 0) { + (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code); + FAIL; + } + if (thr_join(th2, 0, 0) != 0) { + (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code); + FAIL; + } + check_heap_stats(); + (void)fflush(stdout); + return(0); +} +#else /* pthreads */ +main() +{ + pthread_t th1; + pthread_t th2; + pthread_attr_t attr; + int code; + +# ifdef IRIX_THREADS + /* Force a larger stack to be preallocated */ + /* Since the initial cant always grow later. */ + *((volatile char *)&code - 1024*1024) = 0; /* Require 1 Mb */ +# endif /* IRIX_THREADS */ + pthread_attr_init(&attr); +# ifdef IRIX_THREADS + pthread_attr_setstacksize(&attr, 1000000); +# endif + n_tests = 0; +# ifdef MPROTECT_VDB + GC_enable_incremental(); + (void) GC_printf0("Switched to incremental mode\n"); + (void) GC_printf0("Emulating dirty bits with mprotect/signals\n"); +# endif + (void) GC_set_warn_proc(warn_proc); + if (pthread_key_create(&fl_key, 0) != 0) { + (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code); + FAIL; + } + if ((code = pthread_create(&th1, &attr, thr_run_one_test, 0)) != 0) { + (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code); + FAIL; + } + if ((code = pthread_create(&th2, &attr, thr_run_one_test, 0)) != 0) { + (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code); + FAIL; + } + run_one_test(); + if ((code = pthread_join(th1, 0)) != 0) { + (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code); + FAIL; + } + if (pthread_join(th2, 0) != 0) { + (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code); + FAIL; + } + check_heap_stats(); + (void)fflush(stdout); + pthread_attr_destroy(&attr); + GC_printf1("Completed %d collections\n", GC_gc_no); + return(0); +} +#endif /* pthreads */ +#endif /* SOLARIS_THREADS || IRIX_THREADS || LINUX_THREADS */ diff --git a/support/gc/test_cpp.cc b/support/gc/test_cpp.cc new file mode 100644 index 00000000..3160b098 --- /dev/null +++ b/support/gc/test_cpp.cc @@ -0,0 +1,265 @@ +/**************************************************************************** +Copyright (c) 1994 by Xerox Corporation. All rights reserved. + +THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + +Permission is hereby granted to use or copy this program for any +purpose, provided the above notices are retained on all copies. +Permission to modify the code and to distribute modified code is +granted, provided the above notices are retained, and a notice that +the code was modified is included with the above copyright notice. +**************************************************************************** +Last modified on Mon Jul 10 21:06:03 PDT 1995 by ellis + modified on December 20, 1994 7:27 pm PST by boehm + +usage: test_cpp number-of-iterations + +This program tries to test the specific C++ functionality provided by +gc_c++.h that isn't tested by the more general test routines of the +collector. + +A recommended value for number-of-iterations is 10, which will take a +few minutes to complete. + +***************************************************************************/ + +#include "gc_cpp.h" +#include +#include +#include +#ifndef __GNUC__ +# include "gc_alloc.h" +#endif +extern "C" { +#include "gc_priv.h" +} +#ifdef MSWIN32 +# include +#endif + + +#define my_assert( e ) \ + if (! (e)) { \ + GC_printf1( "Assertion failure in " __FILE__ ", line %d: " #e "\n", \ + __LINE__ ); \ + exit( 1 ); } + + +class A {public: + /* An uncollectable class. */ + + A( int iArg ): i( iArg ) {} + void Test( int iArg ) { + my_assert( i == iArg );} + int i;}; + + +class B: public gc, public A {public: + /* A collectable class. */ + + B( int j ): A( j ) {} + ~B() { + my_assert( deleting );} + static void Deleting( int on ) { + deleting = on;} + static int deleting;}; + +int B::deleting = 0; + + +class C: public gc_cleanup, public A {public: + /* A collectable class with cleanup and virtual multiple inheritance. */ + + C( int levelArg ): A( levelArg ), level( levelArg ) { + nAllocated++; + if (level > 0) { + left = new C( level - 1 ); + right = new C( level - 1 );} + else { + left = right = 0;}} + ~C() { + this->A::Test( level ); + nFreed++; + my_assert( level == 0 ? + left == 0 && right == 0 : + level == left->level + 1 && level == right->level + 1 ); + left = right = 0; + level = -123456;} + static void Test() { + my_assert( nFreed <= nAllocated && nFreed >= .8 * nAllocated );} + + static int nFreed; + static int nAllocated; + int level; + C* left; + C* right;}; + +int C::nFreed = 0; +int C::nAllocated = 0; + + +class D: public gc {public: + /* A collectable class with a static member function to be used as + an explicit clean-up function supplied to ::new. */ + + D( int iArg ): i( iArg ) { + nAllocated++;} + static void CleanUp( void* obj, void* data ) { + D* self = (D*) obj; + nFreed++; + my_assert( self->i == (int) (long) data );} + static void Test() { + my_assert( nFreed >= .8 * nAllocated );} + + int i; + static int nFreed; + static int nAllocated;}; + +int D::nFreed = 0; +int D::nAllocated = 0; + + +class E: public gc_cleanup {public: + /* A collectable class with clean-up for use by F. */ + + E() { + nAllocated++;} + ~E() { + nFreed++;} + + static int nFreed; + static int nAllocated;}; + +int E::nFreed = 0; +int E::nAllocated = 0; + + +class F: public E {public: + /* A collectable class with clean-up, a base with clean-up, and a + member with clean-up. */ + + F() { + nAllocated++;} + ~F() { + nFreed++;} + static void Test() { + my_assert( nFreed >= .8 * nAllocated ); + my_assert( 2 * nFreed == E::nFreed );} + + E e; + static int nFreed; + static int nAllocated;}; + +int F::nFreed = 0; +int F::nAllocated = 0; + + +long Disguise( void* p ) { + return ~ (long) p;} + +void* Undisguise( long i ) { + return (void*) ~ i;} + + +#ifdef MSWIN32 +int APIENTRY WinMain( + HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int cmdShow ) +{ + int argc; + char* argv[ 3 ]; + + for (argc = 1; argc < sizeof( argv ) / sizeof( argv[ 0 ] ); argc++) { + argv[ argc ] = strtok( argc == 1 ? cmd : 0, " \t" ); + if (0 == argv[ argc ]) break;} + +#else +# ifdef MACOS + int main() { +# else + int main( int argc, char* argv[] ) { +# endif +#endif + +# if defined(MACOS) // MacOS + char* argv_[] = {"test_cpp", "10"}; // doesn't + argv = argv_; // have a + argc = sizeof(argv_)/sizeof(argv_[0]); // commandline +# endif + int i, iters, n; +# if !defined(__GNUC__) && !defined(MACOS) + int *x = (int *)alloc::allocate(sizeof(int)); + + *x = 29; + x -= 3; +# endif + if (argc != 2 || (0 >= (n = atoi( argv[ 1 ] )))) { + GC_printf0( "usage: test_cpp number-of-iterations\n" ); + exit( 1 );} + + for (iters = 1; iters <= n; iters++) { + GC_printf1( "Starting iteration %d\n", iters ); + + /* Allocate some uncollectable As and disguise their pointers. + Later we'll check to see if the objects are still there. We're + checking to make sure these objects really are uncollectable. */ + long as[ 1000 ]; + long bs[ 1000 ]; + for (i = 0; i < 1000; i++) { + as[ i ] = Disguise( new (NoGC) A( i ) ); + bs[ i ] = Disguise( new (NoGC) B( i ) );} + + /* Allocate a fair number of finalizable Cs, Ds, and Fs. + Later we'll check to make sure they've gone away. */ + for (i = 0; i < 1000; i++) { + C* c = new C( 2 ); + C c1( 2 ); /* stack allocation should work too */ + D* d = ::new (GC, D::CleanUp, (void*) i) D( i ); + F* f = new F; + if (0 == i % 10) delete c;} + + /* Allocate a very large number of collectable As and Bs and + drop the references to them immediately, forcing many + collections. */ + for (i = 0; i < 1000000; i++) { + A* a = new (GC) A( i ); + B* b = new B( i ); + b = new (GC) B( i ); + if (0 == i % 10) { + B::Deleting( 1 ); + delete b; + B::Deleting( 0 );} +# ifdef FINALIZE_ON_DEMAND + GC_invoke_finalizers(); +# endif + } + + /* Make sure the uncollectable As and Bs are still there. */ + for (i = 0; i < 1000; i++) { + A* a = (A*) Undisguise( as[ i ] ); + B* b = (B*) Undisguise( bs[ i ] ); + a->Test( i ); + delete a; + b->Test( i ); + B::Deleting( 1 ); + delete b; + B::Deleting( 0 ); +# ifdef FINALIZE_ON_DEMAND + GC_invoke_finalizers(); +# endif + + } + + /* Make sure most of the finalizable Cs, Ds, and Fs have + gone away. */ + C::Test(); + D::Test(); + F::Test();} + +# if !defined(__GNUC__) && !defined(MACOS) + my_assert (29 == x[3]); +# endif + GC_printf0( "The test appears to have succeeded.\n" ); + return( 0 );} + + diff --git a/support/gc/threadlibs.c b/support/gc/threadlibs.c new file mode 100644 index 00000000..4a0a6cfc --- /dev/null +++ b/support/gc/threadlibs.c @@ -0,0 +1,14 @@ +# include "gcconfig.h" +# include + +int main() +{ +# if defined(IRIX_THREADS) || defined(LINUX_THREADS) + printf("-lpthread\n"); +# endif +# ifdef SOLARIS_THREADS + printf("-lthread -ldl\n"); +# endif + return 0; +} + diff --git a/support/gc/typd_mlc.c b/support/gc/typd_mlc.c new file mode 100644 index 00000000..74f455d9 --- /dev/null +++ b/support/gc/typd_mlc.c @@ -0,0 +1,814 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +/* Boehm, July 31, 1995 5:02 pm PDT */ + + +/* + * Some simple primitives for allocation with explicit type information. + * Simple objects are allocated such that they contain a GC_descr at the + * end (in the last allocated word). This descriptor may be a procedure + * which then examines an extended descriptor passed as its environment. + * + * Arrays are treated as simple objects if they have sufficiently simple + * structure. Otherwise they are allocated from an array kind that supplies + * a special mark procedure. These arrays contain a pointer to a + * complex_descriptor as their last word. + * This is done because the environment field is too small, and the collector + * must trace the complex_descriptor. + * + * Note that descriptors inside objects may appear cleared, if we encounter a + * false refrence to an object on a free list. In the GC_descr case, this + * is OK, since a 0 descriptor corresponds to examining no fields. + * In the complex_descriptor case, we explicitly check for that case. + * + * MAJOR PARTS OF THIS CODE HAVE NOT BEEN TESTED AT ALL and are not testable, + * since they are not accessible through the current interface. + */ + +#include "gc_priv.h" +#include "gc_mark.h" +#include "gc_typed.h" + +# ifdef ADD_BYTE_AT_END +# define EXTRA_BYTES (sizeof(word) - 1) +# else +# define EXTRA_BYTES (sizeof(word)) +# endif + +GC_bool GC_explicit_typing_initialized = FALSE; + +int GC_explicit_kind; /* Object kind for objects with indirect */ + /* (possibly extended) descriptors. */ + +int GC_array_kind; /* Object kind for objects with complex */ + /* descriptors and GC_array_mark_proc. */ + +/* Extended descriptors. GC_typed_mark_proc understands these. */ +/* These are used for simple objects that are larger than what */ +/* can be described by a BITMAP_BITS sized bitmap. */ +typedef struct { + word ed_bitmap; /* lsb corresponds to first word. */ + GC_bool ed_continued; /* next entry is continuation. */ +} ext_descr; + +/* Array descriptors. GC_array_mark_proc understands these. */ +/* We may eventually need to add provisions for headers and */ +/* trailers. Hence we provide for tree structured descriptors, */ +/* though we don't really use them currently. */ +typedef union ComplexDescriptor { + struct LeafDescriptor { /* Describes simple array */ + word ld_tag; +# define LEAF_TAG 1 + word ld_size; /* bytes per element */ + /* multiple of ALIGNMENT */ + word ld_nelements; /* Number of elements. */ + GC_descr ld_descriptor; /* A simple length, bitmap, */ + /* or procedure descriptor. */ + } ld; + struct ComplexArrayDescriptor { + word ad_tag; +# define ARRAY_TAG 2 + word ad_nelements; + union ComplexDescriptor * ad_element_descr; + } ad; + struct SequenceDescriptor { + word sd_tag; +# define SEQUENCE_TAG 3 + union ComplexDescriptor * sd_first; + union ComplexDescriptor * sd_second; + } sd; +} complex_descriptor; +#define TAG ld.ld_tag + +ext_descr * GC_ext_descriptors; /* Points to array of extended */ + /* descriptors. */ + +word GC_ed_size = 0; /* Current size of above arrays. */ +# define ED_INITIAL_SIZE 100; + +word GC_avail_descr = 0; /* Next available slot. */ + +int GC_typed_mark_proc_index; /* Indices of my mark */ +int GC_array_mark_proc_index; /* procedures. */ + +/* Add a multiword bitmap to GC_ext_descriptors arrays. Return */ +/* starting index. */ +/* Returns -1 on failure. */ +/* Caller does not hold allocation lock. */ +signed_word GC_add_ext_descriptor(bm, nbits) +GC_bitmap bm; +word nbits; +{ + register size_t nwords = divWORDSZ(nbits + WORDSZ-1); + register signed_word result; + register word i; + register word last_part; + register int extra_bits; + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + while (GC_avail_descr + nwords >= GC_ed_size) { + ext_descr * new; + size_t new_size; + word ed_size = GC_ed_size; + + UNLOCK(); + ENABLE_SIGNALS(); + if (ed_size == 0) { + new_size = ED_INITIAL_SIZE; + } else { + new_size = 2 * ed_size; + if (new_size > MAX_ENV) return(-1); + } + new = (ext_descr *) GC_malloc_atomic(new_size * sizeof(ext_descr)); + if (new == 0) return(-1); + DISABLE_SIGNALS(); + LOCK(); + if (ed_size == GC_ed_size) { + if (GC_avail_descr != 0) { + BCOPY(GC_ext_descriptors, new, + GC_avail_descr * sizeof(ext_descr)); + } + GC_ed_size = new_size; + GC_ext_descriptors = new; + } /* else another thread already resized it in the meantime */ + } + result = GC_avail_descr; + for (i = 0; i < nwords-1; i++) { + GC_ext_descriptors[result + i].ed_bitmap = bm[i]; + GC_ext_descriptors[result + i].ed_continued = TRUE; + } + last_part = bm[i]; + /* Clear irrelevant bits. */ + extra_bits = nwords * WORDSZ - nbits; + last_part <<= extra_bits; + last_part >>= extra_bits; + GC_ext_descriptors[result + i].ed_bitmap = last_part; + GC_ext_descriptors[result + i].ed_continued = FALSE; + GC_avail_descr += nwords; + UNLOCK(); + ENABLE_SIGNALS(); + return(result); +} + +/* Table of bitmap descriptors for n word long all pointer objects. */ +GC_descr GC_bm_table[WORDSZ/2]; + +/* Return a descriptor for the concatenation of 2 nwords long objects, */ +/* each of which is described by descriptor. */ +/* The result is known to be short enough to fit into a bitmap */ +/* descriptor. */ +/* Descriptor is a DS_LENGTH or DS_BITMAP descriptor. */ +GC_descr GC_double_descr(descriptor, nwords) +register GC_descr descriptor; +register word nwords; +{ + if (descriptor && DS_TAGS == DS_LENGTH) { + descriptor = GC_bm_table[BYTES_TO_WORDS((word)descriptor)]; + }; + descriptor |= (descriptor & ~DS_TAGS) >> nwords; + return(descriptor); +} + +complex_descriptor * GC_make_sequence_descriptor(); + +/* Build a descriptor for an array with nelements elements, */ +/* each of which can be described by a simple descriptor. */ +/* We try to optimize some common cases. */ +/* If the result is COMPLEX, then a complex_descr* is returned */ +/* in *complex_d. */ +/* If the result is LEAF, then we built a LeafDescriptor in */ +/* the structure pointed to by leaf. */ +/* The tag in the leaf structure is not set. */ +/* If the result is SIMPLE, then a GC_descr */ +/* is returned in *simple_d. */ +/* If the result is NO_MEM, then */ +/* we failed to allocate the descriptor. */ +/* The implementation knows that DS_LENGTH is 0. */ +/* *leaf, *complex_d, and *simple_d may be used as temporaries */ +/* during the construction. */ +# define COMPLEX 2 +# define LEAF 1 +# define SIMPLE 0 +# define NO_MEM (-1) +int GC_make_array_descriptor(nelements, size, descriptor, + simple_d, complex_d, leaf) +word size; +word nelements; +GC_descr descriptor; +GC_descr *simple_d; +complex_descriptor **complex_d; +struct LeafDescriptor * leaf; +{ +# define OPT_THRESHOLD 50 + /* For larger arrays, we try to combine descriptors of adjacent */ + /* descriptors to speed up marking, and to reduce the amount */ + /* of space needed on the mark stack. */ + if ((descriptor & DS_TAGS) == DS_LENGTH) { + if ((word)descriptor == size) { + *simple_d = nelements * descriptor; + return(SIMPLE); + } else if ((word)descriptor == 0) { + *simple_d = (GC_descr)0; + return(SIMPLE); + } + } + if (nelements <= OPT_THRESHOLD) { + if (nelements <= 1) { + if (nelements == 1) { + *simple_d = descriptor; + return(SIMPLE); + } else { + *simple_d = (GC_descr)0; + return(SIMPLE); + } + } + } else if (size <= BITMAP_BITS/2 + && (descriptor & DS_TAGS) != DS_PROC + && (size & (sizeof(word)-1)) == 0) { + int result = + GC_make_array_descriptor(nelements/2, 2*size, + GC_double_descr(descriptor, + BYTES_TO_WORDS(size)), + simple_d, complex_d, leaf); + if ((nelements & 1) == 0) { + return(result); + } else { + struct LeafDescriptor * one_element = + (struct LeafDescriptor *) + GC_malloc_atomic(sizeof(struct LeafDescriptor)); + + if (result == NO_MEM || one_element == 0) return(NO_MEM); + one_element -> ld_tag = LEAF_TAG; + one_element -> ld_size = size; + one_element -> ld_nelements = 1; + one_element -> ld_descriptor = descriptor; + switch(result) { + case SIMPLE: + { + struct LeafDescriptor * beginning = + (struct LeafDescriptor *) + GC_malloc_atomic(sizeof(struct LeafDescriptor)); + if (beginning == 0) return(NO_MEM); + beginning -> ld_tag = LEAF_TAG; + beginning -> ld_size = size; + beginning -> ld_nelements = 1; + beginning -> ld_descriptor = *simple_d; + *complex_d = GC_make_sequence_descriptor( + (complex_descriptor *)beginning, + (complex_descriptor *)one_element); + break; + } + case LEAF: + { + struct LeafDescriptor * beginning = + (struct LeafDescriptor *) + GC_malloc_atomic(sizeof(struct LeafDescriptor)); + if (beginning == 0) return(NO_MEM); + beginning -> ld_tag = LEAF_TAG; + beginning -> ld_size = leaf -> ld_size; + beginning -> ld_nelements = leaf -> ld_nelements; + beginning -> ld_descriptor = leaf -> ld_descriptor; + *complex_d = GC_make_sequence_descriptor( + (complex_descriptor *)beginning, + (complex_descriptor *)one_element); + break; + } + case COMPLEX: + *complex_d = GC_make_sequence_descriptor( + *complex_d, + (complex_descriptor *)one_element); + break; + } + return(COMPLEX); + } + } + { + leaf -> ld_size = size; + leaf -> ld_nelements = nelements; + leaf -> ld_descriptor = descriptor; + return(LEAF); + } +} + +complex_descriptor * GC_make_sequence_descriptor(first, second) +complex_descriptor * first; +complex_descriptor * second; +{ + struct SequenceDescriptor * result = + (struct SequenceDescriptor *) + GC_malloc(sizeof(struct SequenceDescriptor)); + /* Can't result in overly conservative marking, since tags are */ + /* very small integers. Probably faster than maintaining type */ + /* info. */ + if (result != 0) { + result -> sd_tag = SEQUENCE_TAG; + result -> sd_first = first; + result -> sd_second = second; + } + return((complex_descriptor *)result); +} + +#ifdef UNDEFINED +complex_descriptor * GC_make_complex_array_descriptor(nelements, descr) +word nelements; +complex_descriptor * descr; +{ + struct ComplexArrayDescriptor * result = + (struct ComplexArrayDescriptor *) + GC_malloc(sizeof(struct ComplexArrayDescriptor)); + + if (result != 0) { + result -> ad_tag = ARRAY_TAG; + result -> ad_nelements = nelements; + result -> ad_element_descr = descr; + } + return((complex_descriptor *)result); +} +#endif + +ptr_t * GC_eobjfreelist; + +ptr_t * GC_arobjfreelist; + +mse * GC_typed_mark_proc(); + +mse * GC_array_mark_proc(); + +GC_descr GC_generic_array_descr; + +/* Caller does not hold allocation lock. */ +void GC_init_explicit_typing() +{ + register int i; + DCL_LOCK_STATE; + + +# ifdef PRINTSTATS + if (sizeof(struct LeafDescriptor) % sizeof(word) != 0) + ABORT("Bad leaf descriptor size"); +# endif + DISABLE_SIGNALS(); + LOCK(); + if (GC_explicit_typing_initialized) { + UNLOCK(); + ENABLE_SIGNALS(); + return; + } + GC_explicit_typing_initialized = TRUE; + /* Set up object kind with simple indirect descriptor. */ + GC_eobjfreelist = (ptr_t *) + GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE); + if (GC_eobjfreelist == 0) ABORT("Couldn't allocate GC_eobjfreelist"); + BZERO(GC_eobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t)); + GC_explicit_kind = GC_n_kinds++; + GC_obj_kinds[GC_explicit_kind].ok_freelist = GC_eobjfreelist; + GC_obj_kinds[GC_explicit_kind].ok_reclaim_list = 0; + GC_obj_kinds[GC_explicit_kind].ok_descriptor = + (((word)WORDS_TO_BYTES(-1)) | DS_PER_OBJECT); + GC_obj_kinds[GC_explicit_kind].ok_relocate_descr = TRUE; + GC_obj_kinds[GC_explicit_kind].ok_init = TRUE; + /* Descriptors are in the last word of the object. */ + GC_typed_mark_proc_index = GC_n_mark_procs; + GC_mark_procs[GC_typed_mark_proc_index] = GC_typed_mark_proc; + GC_n_mark_procs++; + /* Moving this up breaks DEC AXP compiler. */ + /* Set up object kind with array descriptor. */ + GC_arobjfreelist = (ptr_t *) + GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE); + if (GC_arobjfreelist == 0) ABORT("Couldn't allocate GC_arobjfreelist"); + BZERO(GC_arobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t)); + if (GC_n_mark_procs >= MAX_MARK_PROCS) + ABORT("No slot for array mark proc"); + GC_array_mark_proc_index = GC_n_mark_procs++; + if (GC_n_kinds >= MAXOBJKINDS) + ABORT("No kind available for array objects"); + GC_array_kind = GC_n_kinds++; + GC_obj_kinds[GC_array_kind].ok_freelist = GC_arobjfreelist; + GC_obj_kinds[GC_array_kind].ok_reclaim_list = 0; + GC_obj_kinds[GC_array_kind].ok_descriptor = + MAKE_PROC(GC_array_mark_proc_index, 0);; + GC_obj_kinds[GC_array_kind].ok_relocate_descr = FALSE; + GC_obj_kinds[GC_array_kind].ok_init = TRUE; + /* Descriptors are in the last word of the object. */ + GC_mark_procs[GC_array_mark_proc_index] = GC_array_mark_proc; + for (i = 0; i < WORDSZ/2; i++) { + GC_descr d = (((word)(-1)) >> (WORDSZ - i)) << (WORDSZ - i); + d |= DS_BITMAP; + GC_bm_table[i] = d; + } + GC_generic_array_descr = MAKE_PROC(GC_array_mark_proc_index, 0); + UNLOCK(); + ENABLE_SIGNALS(); +} + +mse * GC_typed_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env) +register word * addr; +register mse * mark_stack_ptr; +mse * mark_stack_limit; +word env; +{ + register word bm = GC_ext_descriptors[env].ed_bitmap; + register word * current_p = addr; + register word current; + register ptr_t greatest_ha = GC_greatest_plausible_heap_addr; + register ptr_t least_ha = GC_least_plausible_heap_addr; + + for (; bm != 0; bm >>= 1, current_p++) { + if (bm & 1) { + current = *current_p; + if ((ptr_t)current >= least_ha && (ptr_t)current <= greatest_ha) { + PUSH_CONTENTS(current, mark_stack_ptr, + mark_stack_limit, current_p, exit1); + } + } + } + if (GC_ext_descriptors[env].ed_continued) { + /* Push an entry with the rest of the descriptor back onto the */ + /* stack. Thus we never do too much work at once. Note that */ + /* we also can't overflow the mark stack unless we actually */ + /* mark something. */ + mark_stack_ptr++; + if (mark_stack_ptr >= mark_stack_limit) { + mark_stack_ptr = GC_signal_mark_stack_overflow(mark_stack_ptr); + } + mark_stack_ptr -> mse_start = addr + WORDSZ; + mark_stack_ptr -> mse_descr = + MAKE_PROC(GC_typed_mark_proc_index, env+1); + } + return(mark_stack_ptr); +} + +/* Return the size of the object described by d. It would be faster to */ +/* store this directly, or to compute it as part of */ +/* GC_push_complex_descriptor, but hopefully it doesn't matter. */ +word GC_descr_obj_size(d) +register complex_descriptor *d; +{ + switch(d -> TAG) { + case LEAF_TAG: + return(d -> ld.ld_nelements * d -> ld.ld_size); + case ARRAY_TAG: + return(d -> ad.ad_nelements + * GC_descr_obj_size(d -> ad.ad_element_descr)); + case SEQUENCE_TAG: + return(GC_descr_obj_size(d -> sd.sd_first) + + GC_descr_obj_size(d -> sd.sd_second)); + default: + ABORT("Bad complex descriptor"); + /*NOTREACHED*/ return 0; /*NOTREACHED*/ + } +} + +/* Push descriptors for the object at addr with complex descriptor d */ +/* onto the mark stack. Return 0 if the mark stack overflowed. */ +mse * GC_push_complex_descriptor(addr, d, msp, msl) +word * addr; +register complex_descriptor *d; +register mse * msp; +mse * msl; +{ + register ptr_t current = (ptr_t) addr; + register word nelements; + register word sz; + register word i; + + switch(d -> TAG) { + case LEAF_TAG: + { + register GC_descr descr = d -> ld.ld_descriptor; + + nelements = d -> ld.ld_nelements; + if (msl - msp <= (ptrdiff_t)nelements) return(0); + sz = d -> ld.ld_size; + for (i = 0; i < nelements; i++) { + msp++; + msp -> mse_start = (word *)current; + msp -> mse_descr = descr; + current += sz; + } + return(msp); + } + case ARRAY_TAG: + { + register complex_descriptor *descr = d -> ad.ad_element_descr; + + nelements = d -> ad.ad_nelements; + sz = GC_descr_obj_size(descr); + for (i = 0; i < nelements; i++) { + msp = GC_push_complex_descriptor((word *)current, descr, + msp, msl); + if (msp == 0) return(0); + current += sz; + } + return(msp); + } + case SEQUENCE_TAG: + { + sz = GC_descr_obj_size(d -> sd.sd_first); + msp = GC_push_complex_descriptor((word *)current, d -> sd.sd_first, + msp, msl); + if (msp == 0) return(0); + current += sz; + msp = GC_push_complex_descriptor((word *)current, d -> sd.sd_second, + msp, msl); + return(msp); + } + default: + ABORT("Bad complex descriptor"); + /*NOTREACHED*/ return 0; /*NOTREACHED*/ + } +} + +/*ARGSUSED*/ +mse * GC_array_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env) +register word * addr; +register mse * mark_stack_ptr; +mse * mark_stack_limit; +word env; +{ + register hdr * hhdr = HDR(addr); + register word sz = hhdr -> hb_sz; + register complex_descriptor * descr = (complex_descriptor *)(addr[sz-1]); + mse * orig_mark_stack_ptr = mark_stack_ptr; + mse * new_mark_stack_ptr; + + if (descr == 0) { + /* Found a reference to a free list entry. Ignore it. */ + return(orig_mark_stack_ptr); + } + /* In use counts were already updated when array descriptor was */ + /* pushed. Here we only replace it by subobject descriptors, so */ + /* no update is necessary. */ + new_mark_stack_ptr = GC_push_complex_descriptor(addr, descr, + mark_stack_ptr, + mark_stack_limit-1); + if (new_mark_stack_ptr == 0) { + /* Doesn't fit. Conservatively push the whole array as a unit */ + /* and request a mark stack expansion. */ + /* This cannot cause a mark stack overflow, since it replaces */ + /* the original array entry. */ + GC_mark_stack_too_small = TRUE; + new_mark_stack_ptr = orig_mark_stack_ptr + 1; + new_mark_stack_ptr -> mse_start = addr; + new_mark_stack_ptr -> mse_descr = WORDS_TO_BYTES(sz) | DS_LENGTH; + } else { + /* Push descriptor itself */ + new_mark_stack_ptr++; + new_mark_stack_ptr -> mse_start = addr + sz - 1; + new_mark_stack_ptr -> mse_descr = sizeof(word) | DS_LENGTH; + } + return(new_mark_stack_ptr); +} + +#if defined(__STDC__) || defined(__cplusplus) + GC_descr GC_make_descriptor(GC_bitmap bm, size_t len) +#else + GC_descr GC_make_descriptor(bm, len) + GC_bitmap bm; + size_t len; +#endif +{ + register signed_word last_set_bit = len - 1; + register word result; + register int i; +# define HIGH_BIT (((word)1) << (WORDSZ - 1)) + + if (!GC_explicit_typing_initialized) GC_init_explicit_typing(); + while (last_set_bit >= 0 && !GC_get_bit(bm, last_set_bit)) last_set_bit --; + if (last_set_bit < 0) return(0 /* no pointers */); +# if ALIGNMENT == CPP_WORDSZ/8 + { + register GC_bool all_bits_set = TRUE; + for (i = 0; i < last_set_bit; i++) { + if (!GC_get_bit(bm, i)) { + all_bits_set = FALSE; + break; + } + } + if (all_bits_set) { + /* An initial section contains all pointers. Use length descriptor. */ + return(WORDS_TO_BYTES(last_set_bit+1) | DS_LENGTH); + } + } +# endif + if (last_set_bit < BITMAP_BITS) { + /* Hopefully the common case. */ + /* Build bitmap descriptor (with bits reversed) */ + result = HIGH_BIT; + for (i = last_set_bit - 1; i >= 0; i--) { + result >>= 1; + if (GC_get_bit(bm, i)) result |= HIGH_BIT; + } + result |= DS_BITMAP; + return(result); + } else { + signed_word index; + + index = GC_add_ext_descriptor(bm, (word)last_set_bit+1); + if (index == -1) return(WORDS_TO_BYTES(last_set_bit+1) | DS_LENGTH); + /* Out of memory: use conservative */ + /* approximation. */ + result = MAKE_PROC(GC_typed_mark_proc_index, (word)index); + return(result); + } +} + +ptr_t GC_clear_stack(); + +#define GENERAL_MALLOC(lb,k) \ + (GC_PTR)GC_clear_stack(GC_generic_malloc((word)lb, k)) + +#define GENERAL_MALLOC_IOP(lb,k) \ + (GC_PTR)GC_clear_stack(GC_generic_malloc_ignore_off_page(lb, k)) + +#if defined(__STDC__) || defined(__cplusplus) + void * GC_malloc_explicitly_typed(size_t lb, GC_descr d) +#else + char * GC_malloc_explicitly_typed(lb, d) + size_t lb; + GC_descr d; +#endif +{ +register ptr_t op; +register ptr_t * opp; +register word lw; +DCL_LOCK_STATE; + + lb += EXTRA_BYTES; + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_eobjfreelist[lw]); + FASTLOCK(); + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { + FASTUNLOCK(); + op = (ptr_t)GENERAL_MALLOC((word)lb, GC_explicit_kind); + if (0 == op) return(0); +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; /* May have been uninitialized. */ +# endif + } else { + *opp = obj_link(op); + GC_words_allocd += lw; + FASTUNLOCK(); + } + } else { + op = (ptr_t)GENERAL_MALLOC((word)lb, GC_explicit_kind); + if (op != NULL) + lw = BYTES_TO_WORDS(GC_size(op)); + } + if (op != NULL) + ((word *)op)[lw - 1] = d; + return((GC_PTR) op); +} + +#if defined(__STDC__) || defined(__cplusplus) + void * GC_malloc_explicitly_typed_ignore_off_page(size_t lb, GC_descr d) +#else + char * GC_malloc_explicitly_typed_ignore_off_page(lb, d) + size_t lb; + GC_descr d; +#endif +{ +register ptr_t op; +register ptr_t * opp; +register word lw; +DCL_LOCK_STATE; + + lb += EXTRA_BYTES; + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_eobjfreelist[lw]); + FASTLOCK(); + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { + FASTUNLOCK(); + op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind); +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; /* May have been uninitialized. */ +# endif + } else { + *opp = obj_link(op); + GC_words_allocd += lw; + FASTUNLOCK(); + } + } else { + op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind); + if (op != NULL) + lw = BYTES_TO_WORDS(GC_size(op)); + } + if (op != NULL) + ((word *)op)[lw - 1] = d; + return((GC_PTR) op); +} + +#if defined(__STDC__) || defined(__cplusplus) + void * GC_calloc_explicitly_typed(size_t n, + size_t lb, + GC_descr d) +#else + char * GC_calloc_explicitly_typed(n, lb, d) + size_t n; + size_t lb; + GC_descr d; +#endif +{ +register ptr_t op; +register ptr_t * opp; +register word lw; +GC_descr simple_descr; +complex_descriptor *complex_descr; +register int descr_type; +struct LeafDescriptor leaf; +DCL_LOCK_STATE; + + descr_type = GC_make_array_descriptor((word)n, (word)lb, d, + &simple_descr, &complex_descr, &leaf); + switch(descr_type) { + case NO_MEM: return(0); + case SIMPLE: return(GC_malloc_explicitly_typed(n*lb, simple_descr)); + case LEAF: + lb *= n; + lb += sizeof(struct LeafDescriptor) + EXTRA_BYTES; + break; + case COMPLEX: + lb *= n; + lb += EXTRA_BYTES; + break; + } + if( SMALL_OBJ(lb) ) { +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; +# else + lw = ALIGNED_WORDS(lb); +# endif + opp = &(GC_arobjfreelist[lw]); + FASTLOCK(); + if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { + FASTUNLOCK(); + op = (ptr_t)GENERAL_MALLOC((word)lb, GC_array_kind); + if (0 == op) return(0); +# ifdef MERGE_SIZES + lw = GC_size_map[lb]; /* May have been uninitialized. */ +# endif + } else { + *opp = obj_link(op); + GC_words_allocd += lw; + FASTUNLOCK(); + } + } else { + op = (ptr_t)GENERAL_MALLOC((word)lb, GC_array_kind); + if (0 == op) return(0); + lw = BYTES_TO_WORDS(GC_size(op)); + } + if (descr_type == LEAF) { + /* Set up the descriptor inside the object itself. */ + VOLATILE struct LeafDescriptor * lp = + (struct LeafDescriptor *) + ((word *)op + + lw - (BYTES_TO_WORDS(sizeof(struct LeafDescriptor)) + 1)); + + lp -> ld_tag = LEAF_TAG; + lp -> ld_size = leaf.ld_size; + lp -> ld_nelements = leaf.ld_nelements; + lp -> ld_descriptor = leaf.ld_descriptor; + ((VOLATILE word *)op)[lw - 1] = (word)lp; + } else { + extern unsigned GC_finalization_failures; + unsigned ff = GC_finalization_failures; + + ((word *)op)[lw - 1] = (word)complex_descr; + /* Make sure the descriptor is cleared once there is any danger */ + /* it may have been collected. */ + (void) + GC_general_register_disappearing_link((GC_PTR *) + ((word *)op+lw-1), + (GC_PTR) op); + if (ff != GC_finalization_failures) { + /* Couldn't register it due to lack of memory. Punt. */ + /* This will probably fail too, but gives the recovery code */ + /* a chance. */ + return(GC_malloc(n*lb)); + } + } + return((GC_PTR) op); +} diff --git a/support/gc/version.h b/support/gc/version.h new file mode 100644 index 00000000..97ac5f5e --- /dev/null +++ b/support/gc/version.h @@ -0,0 +1,11 @@ +#define GC_VERSION_MAJOR 5 +#define GC_VERSION_MINOR 0 +#define GC_ALPHA_VERSION 3 + +# define GC_NOT_ALPHA 0xff + +#ifndef GC_NO_VERSION_VAR + +unsigned GC_version = ((GC_VERSION_MAJOR << 16) | (GC_VERSION_MINOR << 8) | GC_ALPHA_VERSION); + +#endif /* GC_NO_VERSION_VAR */ diff --git a/support/gc/weakpointer.h b/support/gc/weakpointer.h new file mode 100644 index 00000000..84906b00 --- /dev/null +++ b/support/gc/weakpointer.h @@ -0,0 +1,221 @@ +#ifndef _weakpointer_h_ +#define _weakpointer_h_ + +/**************************************************************************** + +WeakPointer and CleanUp + + Copyright (c) 1991 by Xerox Corporation. All rights reserved. + + THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + + Permission is hereby granted to copy this code for any purpose, + provided the above notices are retained on all copies. + + Last modified on Mon Jul 17 18:16:01 PDT 1995 by ellis + +****************************************************************************/ + +/**************************************************************************** + +WeakPointer + +A weak pointer is a pointer to a heap-allocated object that doesn't +prevent the object from being garbage collected. Weak pointers can be +used to track which objects haven't yet been reclaimed by the +collector. A weak pointer is deactivated when the collector discovers +its referent object is unreachable by normal pointers (reachability +and deactivation are defined more precisely below). A deactivated weak +pointer remains deactivated forever. + +****************************************************************************/ + + +template< class T > class WeakPointer { +public: + +WeakPointer( T* t = 0 ) + /* Constructs a weak pointer for *t. t may be null. It is an error + if t is non-null and *t is not a collected object. */ + {impl = _WeakPointer_New( t );} + +T* Pointer() + /* wp.Pointer() returns a pointer to the referent object of wp or + null if wp has been deactivated (because its referent object + has been discovered unreachable by the collector). */ + {return (T*) _WeakPointer_Pointer( this->impl );} + +int operator==( WeakPointer< T > wp2 ) + /* Given weak pointers wp1 and wp2, if wp1 == wp2, then wp1 and + wp2 refer to the same object. If wp1 != wp2, then either wp1 + and wp2 don't refer to the same object, or if they do, one or + both of them has been deactivated. (Note: If objects t1 and t2 + are never made reachable by their clean-up functions, then + WeakPointer(t1) == WeakPointer(t2) if and only t1 == t2.) */ + {return _WeakPointer_Equal( this->impl, wp2.impl );} + +int Hash() + /* Returns a hash code suitable for use by multiplicative- and + division-based hash tables. If wp1 == wp2, then wp1.Hash() == + wp2.Hash(). */ + {return _WeakPointer_Hash( this->impl );} + +private: +void* impl; +}; + +/***************************************************************************** + +CleanUp + +A garbage-collected object can have an associated clean-up function +that will be invoked some time after the collector discovers the +object is unreachable via normal pointers. Clean-up functions can be +used to release resources such as open-file handles or window handles +when their containing objects become unreachable. If a C++ object has +a non-empty explicit destructor (i.e. it contains programmer-written +code), the destructor will be automatically registered as the object's +initial clean-up function. + +There is no guarantee that the collector will detect every unreachable +object (though it will find almost all of them). Clients should not +rely on clean-up to cause some action to occur immediately -- clean-up +is only a mechanism for improving resource usage. + +Every object with a clean-up function also has a clean-up queue. When +the collector finds the object is unreachable, it enqueues it on its +queue. The clean-up function is applied when the object is removed +from the queue. By default, objects are enqueued on the garbage +collector's queue, and the collector removes all objects from its +queue after each collection. If a client supplies another queue for +objects, it is his responsibility to remove objects (and cause their +functions to be called) by polling it periodically. + +Clean-up queues allow clean-up functions accessing global data to +synchronize with the main program. Garbage collection can occur at any +time, and clean-ups invoked by the collector might access data in an +inconsistent state. A client can control this by defining an explicit +queue for objects and polling it at safe points. + +The following definitions are used by the specification below: + +Given a pointer t to a collected object, the base object BO(t) is the +value returned by new when it created the object. (Because of multiple +inheritance, t and BO(t) may not be the same address.) + +A weak pointer wp references an object *t if BO(wp.Pointer()) == +BO(t). + +***************************************************************************/ + +template< class T, class Data > class CleanUp { +public: + +static void Set( T* t, void c( Data* d, T* t ), Data* d = 0 ) + /* Sets the clean-up function of object BO(t) to be , + replacing any previously defined clean-up function for BO(t); c + and d can be null, but t cannot. Sets the clean-up queue for + BO(t) to be the collector's queue. When t is removed from its + clean-up queue, its clean-up will be applied by calling c(d, + t). It is an error if *t is not a collected object. */ + {_CleanUp_Set( t, c, d );} + +static void Call( T* t ) + /* Sets the new clean-up function for BO(t) to be null and, if the + old one is non-null, calls it immediately, even if BO(t) is + still reachable. Deactivates any weak pointers to BO(t). */ + {_CleanUp_Call( t );} + +class Queue {public: + Queue() + /* Constructs a new queue. */ + {this->head = _CleanUp_Queue_NewHead();} + + void Set( T* t ) + /* q.Set(t) sets the clean-up queue of BO(t) to be q. */ + {_CleanUp_Queue_Set( this->head, t );} + + int Call() + /* If q is non-empty, q.Call() removes the first object and + calls its clean-up function; does nothing if q is + empty. Returns true if there are more objects in the + queue. */ + {return _CleanUp_Queue_Call( this->head );} + + private: + void* head; + }; +}; + +/********************************************************************** + +Reachability and Clean-up + +An object O is reachable if it can be reached via a non-empty path of +normal pointers from the registers, stacks, global variables, or an +object with a non-null clean-up function (including O itself), +ignoring pointers from an object to itself. + +This definition of reachability ensures that if object B is accessible +from object A (and not vice versa) and if both A and B have clean-up +functions, then A will always be cleaned up before B. Note that as +long as an object with a clean-up function is contained in a cycle of +pointers, it will always be reachable and will never be cleaned up or +collected. + +When the collector finds an unreachable object with a null clean-up +function, it atomically deactivates all weak pointers referencing the +object and recycles its storage. If object B is accessible from object +A via a path of normal pointers, A will be discovered unreachable no +later than B, and a weak pointer to A will be deactivated no later +than a weak pointer to B. + +When the collector finds an unreachable object with a non-null +clean-up function, the collector atomically deactivates all weak +pointers referencing the object, redefines its clean-up function to be +null, and enqueues it on its clean-up queue. The object then becomes +reachable again and remains reachable at least until its clean-up +function executes. + +The clean-up function is assured that its argument is the only +accessible pointer to the object. Nothing prevents the function from +redefining the object's clean-up function or making the object +reachable again (for example, by storing the pointer in a global +variable). + +If the clean-up function does not make its object reachable again and +does not redefine its clean-up function, then the object will be +collected by a subsequent collection (because the object remains +unreachable and now has a null clean-up function). If the clean-up +function does make its object reachable again and a clean-up function +is subsequently redefined for the object, then the new clean-up +function will be invoked the next time the collector finds the object +unreachable. + +Note that a destructor for a collected object cannot safely redefine a +clean-up function for its object, since after the destructor executes, +the object has been destroyed into "raw memory". (In most +implementations, destroying an object mutates its vtbl.) + +Finally, note that calling delete t on a collected object first +deactivates any weak pointers to t and then invokes its clean-up +function (destructor). + +**********************************************************************/ + +extern "C" { + void* _WeakPointer_New( void* t ); + void* _WeakPointer_Pointer( void* wp ); + int _WeakPointer_Equal( void* wp1, void* wp2 ); + int _WeakPointer_Hash( void* wp ); + void _CleanUp_Set( void* t, void (*c)( void* d, void* t ), void* d ); + void _CleanUp_Call( void* t ); + void* _CleanUp_Queue_NewHead (); + void _CleanUp_Queue_Set( void* h, void* t ); + int _CleanUp_Queue_Call( void* h ); +} + +#endif /* _weakpointer_h_ */ + + diff --git a/support/gc/win32_threads.c b/support/gc/win32_threads.c new file mode 100644 index 00000000..f6f74bd1 --- /dev/null +++ b/support/gc/win32_threads.c @@ -0,0 +1,209 @@ +#ifdef WIN32_THREADS + +#include "gc_priv.h" + +#define STRICT +#include + +#define MAX_THREADS 64 + +struct thread_entry { + LONG in_use; + DWORD id; + HANDLE handle; + void *stack; /* The cold end of the stack. */ + /* 0 ==> entry not valid. */ + /* !in_use ==> stack == 0 */ + CONTEXT context; + GC_bool suspended; +}; + +volatile GC_bool GC_please_stop = FALSE; + +volatile struct thread_entry thread_table[MAX_THREADS]; + +void GC_stop_world() +{ + DWORD thread_id = GetCurrentThreadId(); + int i; + + GC_please_stop = TRUE; + for (i = 0; i < MAX_THREADS; i++) + if (thread_table[i].stack != 0 + && thread_table[i].id != thread_id) { + if (SuspendThread(thread_table[i].handle) == (DWORD)-1) + ABORT("SuspendThread failed"); + thread_table[i].suspended = TRUE; + } +} + +void GC_start_world() +{ + DWORD thread_id = GetCurrentThreadId(); + int i; + for (i = 0; i < MAX_THREADS; i++) + if (thread_table[i].stack != 0 && thread_table[i].suspended + && thread_table[i].id != thread_id) { + if (ResumeThread(thread_table[i].handle) == (DWORD)-1) + ABORT("ResumeThread failed"); + thread_table[i].suspended = FALSE; + } + GC_please_stop = FALSE; +} + +ptr_t GC_current_stackbottom() +{ + DWORD thread_id = GetCurrentThreadId(); + int i; + for (i = 0; i < MAX_THREADS; i++) + if (thread_table[i].stack && thread_table[i].id == thread_id) + return thread_table[i].stack; + ABORT("no thread table entry for current thread"); +} + +ptr_t GC_get_lo_stack_addr(ptr_t s) +{ + ptr_t bottom; + MEMORY_BASIC_INFORMATION info; + VirtualQuery(s, &info, sizeof(info)); + do { + bottom = info.BaseAddress; + VirtualQuery(bottom - 1, &info, sizeof(info)); + } while ((info.Protect & PAGE_READWRITE) && !(info.Protect & PAGE_GUARD)); + return(bottom); +} + +void GC_push_all_stacks() +{ + DWORD thread_id = GetCurrentThreadId(); + int i; + for (i = 0; i < MAX_THREADS; i++) + if (thread_table[i].stack) { + ptr_t bottom = GC_get_lo_stack_addr(thread_table[i].stack); + if (thread_table[i].id == thread_id) + GC_push_all(&i, thread_table[i].stack); + else { + thread_table[i].context.ContextFlags + = (CONTEXT_INTEGER|CONTEXT_CONTROL); + if (!GetThreadContext(thread_table[i].handle, + &thread_table[i].context)) + ABORT("GetThreadContext failed"); + if (thread_table[i].context.Esp >= (DWORD)thread_table[i].stack + || thread_table[i].context.Esp < (DWORD)bottom) + ABORT("Thread stack pointer out of range"); + GC_push_one ((word) thread_table[i].context.Edi); + GC_push_one ((word) thread_table[i].context.Esi); + GC_push_one ((word) thread_table[i].context.Ebx); + GC_push_one ((word) thread_table[i].context.Edx); + GC_push_one ((word) thread_table[i].context.Ecx); + GC_push_one ((word) thread_table[i].context.Eax); + GC_push_all_stack(thread_table[i].context.Esp, thread_table[i].stack); + } + } +} + +void GC_get_next_stack(char *start, char **lo, char **hi) +{ + int i; +# define ADDR_LIMIT (char *)(-1L) + char * current_min = ADDR_LIMIT; + + for (i = 0; i < MAX_THREADS; i++) { + char * s = (char *)thread_table[i].stack; + + if (0 != s && s > start && s < current_min) { + current_min = s; + } + } + *hi = current_min; + if (current_min == ADDR_LIMIT) { + *lo = ADDR_LIMIT; + return; + } + *lo = GC_get_lo_stack_addr(current_min); + if (*lo < start) *lo = start; +} + +LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info); + +/* + * This isn't generally safe, since DllMain is not premptible. + * If another thread holds the lock while this runs we're in trouble. + * Pontus Rydin suggests wrapping the thread start routine instead. + */ +BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved) +{ + switch (reason) { + case DLL_PROCESS_ATTACH: + InitializeCriticalSection(&GC_allocate_ml); + GC_init(); /* Force initialization before thread attach. */ + /* fall through */ + case DLL_THREAD_ATTACH: + { + int i; + /* It appears to be unsafe to acquire a lock here, since this */ + /* code is apparently not preeemptible on some systems. */ + /* (This is based on complaints, not on Microsoft's official */ + /* documentation, which says this should perform "only simple */ + /* inititalization tasks".) */ + /* Hence we make do with nonblocking synchronization. */ + + /* The following should be a noop according to the win32 */ + /* documentation. There is empirical evidence that it */ + /* isn't. - HB */ +# ifndef SMALL_CONFIG + if (GC_incremental) SetUnhandledExceptionFilter(GC_write_fault_handler); +# endif + + for (i = 0; InterlockedExchange(&thread_table[i].in_use,1) != 0; i++) { + /* Compare-and-swap would make this cleaner, but that's not */ + /* supported before Windows 98 and NT 4.0. In Windows 2000, */ + /* InterlockedExchange is supposed to be replaced by */ + /* InterlockedExchangePointer, but that's not really what I */ + /* want here. */ + if (i == MAX_THREADS - 1) + ABORT("too many threads"); + } + thread_table[i].id = GetCurrentThreadId(); + if (!DuplicateHandle(GetCurrentProcess(), + GetCurrentThread(), + GetCurrentProcess(), + &thread_table[i].handle, + 0, + 0, + DUPLICATE_SAME_ACCESS)) { + DWORD last_error = GetLastError(); + GC_printf1("Last error code: %lx\n", last_error); + ABORT("DuplicateHandle failed"); + } + thread_table[i].stack = GC_get_stack_base(); + /* If this thread is being created while we are trying to stop */ + /* the world, wait here. Hopefully this can't happen on any */ + /* systems that don't allow us to block here. */ + while (GC_please_stop) Sleep(20); + } + break; + case DLL_PROCESS_DETACH: + case DLL_THREAD_DETACH: + { + int i; + DWORD thread_id = GetCurrentThreadId(); + LOCK(); + for (i = 0; + thread_table[i].stack == 0 || thread_table[i].id != thread_id; + i++) { + if (i == MAX_THREADS - 1) + ABORT("thread not found on detach"); + } + thread_table[i].stack = 0; + thread_table[i].in_use = FALSE; + CloseHandle(thread_table[i].handle); + BZERO(&thread_table[i].context, sizeof(CONTEXT)); + UNLOCK(); + } + break; + } + return TRUE; +} + +#endif /* WIN32_THREADS */ -- 2.47.2