diff --git a/printm.s b/printm.s index afb119c..a00334f 100644 --- a/printm.s +++ b/printm.s @@ -5,7 +5,7 @@ .feature leading_dot_in_identifiers .PC02 ; 65C02 -/* Version 31 +/* Version 32 printm - a modular micro printf replacement for 65C02 Michael Pohoreski Copyleft {c} Feb, 2016 @@ -99,12 +99,12 @@ don't need "every" feature. Seriously, when was the last time you _needed_ octal? :-) printm() has manually been optimized for size. In gcc parlance, `-Os`. -With everything enabled printm() takes up $1CB = 459 bytes +With everything enabled printm() takes up $1C9 = 457 bytes (Plus 2 bytes in zero page.) Whoa! I thought you said this was micro!? -With all 15 features turned OFF the core routines use $87 = 98 bytes. +With all 15 features turned OFF the core routines use $62 = 98 bytes. With the common setting (default) features: BinAsc, Dec2, Dec3, Dec5, Hex2, Hex4, and StrA @@ -122,21 +122,21 @@ To toggle features on / off change USE_* to 0 or 1: ; core _PrintDec routine. ; ; Feature Size Bytes Total Notes -USE_BIN_ASC = 0 ; $7E 126 \. $85 (134 bytes) -USE_BIN_INV = 0 ; $7E 126 / -USE_DEC_2 = 0 ; $C7 199 \ -USE_DEC_3 = 0 ; $C7 199 \.$F0 (240 bytes) -USE_DEC_5 = 0 ; $C7 199 / -USE_DEC_BYTE = 0 ; $DF 223 / sets ENABLE_DEC -USE_HEX_2 = 0 ; $99 153 \. $9E (158 bytes) -USE_HEX_4 = 0 ; $99 153 / -USE_OCT_3 = 0 ; $97 151 \. $9D (157 bytes) -USE_OCT_6 = 0 ; $97 151 / -USE_PTR_2 = 0 ; $B1 177 \. $B7 (183 bytes) sets ENABLE_HEX -USE_PTR_4 = 0 ; $B1 177 / -USE_STR_A = 0 ; $78 120 \ -USE_STR_C = 0 ; $78 120 > $A6 (166 bytes) -USE_STR_PASCAL = 0 ; $7A 122 / +USE_BIN_ASC = 1 ; $7E 126 \. $85 (134 bytes) +USE_BIN_INV = 1 ; $7E 126 / +USE_DEC_2 = 1 ; $C7 199 \ +USE_DEC_3 = 1 ; $C7 199 \.$F0 (240 bytes) +USE_DEC_5 = 1 ; $C7 199 / +USE_DEC_BYTE = 1 ; $DF 223 / sets ENABLE_DEC +USE_HEX_2 = 1 ; $99 153 \. $9E (158 bytes) +USE_HEX_4 = 1 ; $99 153 / +USE_OCT_3 = 1 ; $97 151 \. $9D (157 bytes) +USE_OCT_6 = 1 ; $97 151 / +USE_PTR_2 = 1 ; $B1 177 \. $B7 (183 bytes) sets ENABLE_HEX +USE_PTR_4 = 1 ; $B1 177 / +USE_STR_A = 1 ; $78 120 \ +USE_STR_C = 1 ; $78 120 > $A6 (166 bytes) +USE_STR_PASCAL = 1 ; $7A 122 / /* @@ -144,162 +144,159 @@ Demo + Library text dump: 4000:20 58 FC A9 20 85 E6 A9 4008:D5 8D 00 20 A9 AA 8D 01 -4010:20 AD D6 41 A2 00 A0 00 -4018:20 11 F4 18 A5 26 6D D4 -4020:41 85 26 AA A4 27 8E D8 -4028:41 8C D9 41 8E DA 41 8C -4030:DB 41 AD 00 20 A0 00 91 -4038:26 8D DC 41 9C DD 41 8D -4040:F8 41 8D FC 41 20 A1 41 -4048:8D DE 41 9C DF 41 A0 00 -4050:20 B1 41 A2 D2 A0 41 20 -4058:10 43 A0 01 20 B1 41 A2 -4060:F6 A0 41 20 10 43 A0 02 -4068:20 B1 41 A2 FA A0 41 20 -4070:10 43 A0 03 20 B1 41 A2 -4078:25 A0 42 20 10 43 A0 04 -4080:20 B1 41 A2 29 A0 42 20 -4088:10 43 A0 05 20 B1 41 A2 -4090:2D A0 42 20 10 43 A0 06 -4098:20 B1 41 A2 31 A0 42 20 -40A0:10 43 A0 07 20 B1 41 A2 -40A8:61 A0 42 20 10 43 A0 08 -40B0:20 B1 41 A2 65 A0 42 20 -40B8:10 43 A0 09 20 B1 41 A2 -40C0:69 A0 42 20 10 43 A0 0A -40C8:20 B1 41 A2 6F A0 42 20 -40D0:10 43 A0 0B 20 B1 41 A2 -40D8:85 A0 42 20 10 43 A0 0C -40E0:20 B1 41 A2 89 A0 42 20 -40E8:10 43 A0 0D 20 B1 41 A2 -40F0:D9 A0 42 20 10 43 A0 0E -40F8:20 B1 41 A2 D3 A0 42 20 -4100:10 43 A0 0F 20 B1 41 A2 -4108:DD A0 42 20 10 43 A9 11 -4110:20 5B FB A2 E1 A0 42 20 -4118:90 41 AD 0F 43 85 FF 20 -4120:DA FD AD 0E 43 85 FE 20 -4128:DA FD 20 AC 41 20 4D 41 -4130:A2 F3 A0 42 20 90 41 AE -4138:A0 43 86 FE 64 FF 8A 20 -4140:DA FD 20 AC 41 20 4D 41 -4148:A9 8D 4C ED FD 9C B6 44 -4150:9C B7 44 9C B8 44 A2 10 +4010:20 AD D5 41 A2 00 A0 00 +4018:20 11 F4 18 A5 26 6D D3 +4020:41 85 26 AA A4 27 8E D7 +4028:41 8C D8 41 8E D9 41 8C +4030:DA 41 AD 00 20 A0 00 91 +4038:26 8D DB 41 9C DC 41 8D +4040:F7 41 8D FB 41 20 A0 41 +4048:8D DD 41 9C DE 41 A0 00 +4050:20 B0 41 A2 D1 A0 41 20 +4058:0F 43 A0 01 20 B0 41 A2 +4060:F5 A0 41 20 0F 43 A0 02 +4068:20 B0 41 A2 F9 A0 41 20 +4070:0F 43 A0 03 20 B0 41 A2 +4078:24 A0 42 20 0F 43 A0 04 +4080:20 B0 41 A2 28 A0 42 20 +4088:0F 43 A0 05 20 B0 41 A2 +4090:2C A0 42 20 0F 43 A0 06 +4098:20 B0 41 A2 30 A0 42 20 +40A0:0F 43 A0 07 20 B0 41 A2 +40A8:60 A0 42 20 0F 43 A0 08 +40B0:20 B0 41 A2 64 A0 42 20 +40B8:0F 43 A0 09 20 B0 41 A2 +40C0:68 A0 42 20 0F 43 A0 0A +40C8:20 B0 41 A2 6E A0 42 20 +40D0:0F 43 A0 0B 20 B0 41 A2 +40D8:84 A0 42 20 0F 43 A0 0C +40E0:20 B0 41 A2 88 A0 42 20 +40E8:0F 43 A0 0D 20 B0 41 A2 +40F0:D8 A0 42 20 0F 43 A0 0E +40F8:20 B0 41 A2 D2 A0 42 20 +4100:0F 43 A0 0F 20 B0 41 A2 +4108:DC A0 42 20 0F 43 A9 11 +4110:20 5B FB A2 E0 A0 42 20 +4118:8F 41 AD 0E 43 85 FF 20 +4120:DA FD AD 0D 43 85 FE 20 +4128:DA FD 20 AB 41 20 4D 41 +4130:A2 F2 A0 42 20 8F 41 AE +4138:6E 43 86 FE 64 FF 8A 20 +4140:DA FD 20 AB 41 20 4D 41 +4148:A9 8D 4C ED FD 9C A3 44 +4150:9C A4 44 9C A5 44 A2 10 4158:F8 06 FE 26 FF A0 FD B9 -4160:B9 43 79 B9 43 99 B9 43 +4160:A6 43 79 A6 43 99 A6 43 4168:C8 D0 F4 CA D0 EB D8 A2 -4170:05 88 B9 B9 43 4A 4A 4A +4170:05 88 B9 A6 43 4A 4A 4A 4178:4A 18 69 B0 20 ED FD CA -4180:B9 B9 43 29 0F 18 69 B0 -4188:20 ED FD 88 CA 10 E3 60 -4190:86 FC 84 FD A0 00 B1 FC -4198:F0 06 20 ED FD C8 D0 F6 -41A0:60 A2 08 85 FE 06 FE 6A -41A8:CA D0 FA 60 A9 A0 4C ED -41B0:FD 98 20 C1 FB A6 28 A4 -41B8:29 8E 99 44 8C 9A 44 60 -41C0:D8 BD 23 A0 D9 BD 64 A0 -41C8:A4 BD 78 BA 40 A0 25 FE -41D0:3F 00 C0 41 27 00 BF 00 -41D8:DE C0 DE C0 1A DA 1A DA -41E0:C2 E9 EE A0 C1 D3 C3 BA -41E8:A0 25 00 C2 E9 EE A0 C9 -41F0:CE D6 BA A0 3F 00 E0 41 -41F8:1A DA EB 41 1A DA C4 E5 -4200:E3 B2 BA A0 23 00 C4 E5 -4208:E3 B3 BA A0 64 00 C4 E5 -4210:E3 B5 BA A0 75 00 C2 F9 -4218:F4 E5 BD 62 A0 62 A0 62 -4220:A0 62 A0 62 00 FE 41 63 -4228:00 06 42 E7 03 0E 42 69 -4230:FF 16 42 80 00 FF 00 00 -4238:00 01 00 7F 00 C8 E5 F8 -4240:B2 BA A0 24 00 C8 E5 F8 -4248:B4 BA A0 78 00 D0 F4 F2 -4250:B2 BA A0 78 BA 40 00 D0 -4258:F4 F2 B4 BA A0 78 BA 26 -4260:00 3D 42 34 12 45 42 34 -4268:12 4D 42 00 20 00 20 57 -4270:42 00 20 00 20 CF E3 F4 -4278:B3 BA A0 6F 00 CF E3 F4 -4280:B6 BA A0 4F 00 75 42 B6 -4288:01 7D 42 DF 32 C8 C5 CC -4290:CC CF 00 D7 CF D2 CC C4 -4298:00 C8 CF CD 45 0D D0 E1 -42A0:F3 E3 E1 EC A0 CC E5 EE -42A8:A0 B1 B3 C3 A0 A0 A0 A0 -42B0:A0 BA A0 A7 73 A7 AC A7 -42B8:73 A7 00 C1 F0 F0 EC E5 -42C0:A0 BA A0 A7 61 A7 00 D0 -42C8:E1 F3 E3 E1 EC BA A0 A7 -42D0:70 A7 00 AB 42 8D 42 93 -42D8:42 BB 42 99 42 C7 42 9D -42E0:42 F0 F2 E9 EE F4 ED A8 -42E8:A9 AE F3 E9 FA E5 A0 BD -42F0:A0 A4 00 A0 E2 F9 F4 E5 -42F8:F3 8D A0 A0 A0 A0 AE E6 -4300:E5 E1 F4 F5 F2 E5 F3 A0 -4308:BD A0 A4 A0 A0 00 DB 01 -4310:8E A6 44 8C A7 44 9C A4 -4318:44 20 9F 44 8E 99 43 8C -4320:9A 43 80 74 A9 04 2C A9 -4328:02 8D 54 43 20 9F 44 8E -4330:BC 44 8C BD 44 A2 00 AD -4338:BC 44 29 0F C9 0A 90 02 -4340:69 06 69 B0 9D B6 44 A0 -4348:04 4E BD 44 6E BC 44 88 -4350:D0 F7 E8 E0 04 D0 E0 CA -4358:30 36 BD B6 44 20 98 44 -4360:80 F5 A9 04 2C A9 02 8D -4368:54 43 20 9F 44 A0 00 B1 -4370:FE AA C8 B1 FE A8 80 B7 -4378:20 9F 44 A0 00 B1 FE 10 -4380:0A 20 98 44 C8 D0 F6 E6 -4388:FF 80 F2 09 80 20 98 44 -4390:EE 99 43 D0 03 EE 9A 43 -4398:AD DE C0 F0 12 30 EE A2 -43A0:0F CA 30 EC DD BE 44 D0 -43A8:F8 8A 0A AA 7C CD 44 60 -43B0:A9 05 2C A9 03 2C A9 02 -43B8:8D 09 44 20 9F 44 8E BC -43C0:44 8C BD 44 9C B6 44 9C -43C8:B7 44 9C B8 44 A2 10 F8 -43D0:0E BC 44 2E BD 44 A0 FD -43D8:B9 B9 43 79 B9 43 99 B9 -43E0:43 C8 D0 F4 CA D0 E9 D8 -43E8:A2 05 88 B9 B9 43 4A 4A -43F0:4A 4A 18 69 B0 9D B6 44 -43F8:CA B9 B9 43 29 0F 18 69 -4400:B0 9D B6 44 88 CA 10 E3 -4408:A2 00 4C 57 43 A9 31 2C -4410:A9 B1 8D 22 44 20 9F 44 -4418:A0 08 8A 0A AA A9 B0 90 -4420:02 A9 B1 20 98 44 88 D0 -4428:F1 4C 90 43 20 9F 44 8A -4430:10 0A A9 AD 20 98 44 8A -4438:49 FF AA E8 A0 00 A9 03 -4440:8D 09 44 4C BE 43 A9 06 -4448:2C A9 03 8D 6C 44 20 9F -4450:44 A2 00 A5 FE 29 07 18 -4458:69 B0 9D B6 44 A0 03 46 -4460:FF 66 FE 88 D0 F9 E8 E0 -4468:06 D0 E8 A2 06 4C 57 43 -4470:20 9F 44 A0 00 B1 FE F0 -4478:B0 20 98 44 C8 D0 F6 E6 -4480:FF 80 F2 20 9F 44 A0 00 -4488:B1 FE F0 9D AA C8 B1 FE -4490:20 98 44 CA D0 F7 F0 91 -4498:8D DE C0 EE 99 44 60 20 -44A0:A3 44 AA A0 00 B9 DE C0 -44A8:EE A4 44 D0 03 EE A7 44 -44B0:A8 86 FE 84 FF 60 00 00 -44B8:00 00 00 00 00 00 3F 25 -44C0:62 75 64 23 78 24 26 40 -44C8:4F 6F 70 73 61 0D 44 10 -44D0:44 2C 44 B0 43 B3 43 B6 -44D8:43 24 43 27 43 62 43 65 -44E0:43 46 44 49 44 83 44 70 -44E8:44 78 43 +4180:B9 A6 43 29 0F 18 69 B0 +4188:20 ED FD CA 10 E3 60 86 +4190:FC 84 FD A0 00 B1 FC F0 +4198:06 20 ED FD C8 D0 F6 60 +41A0:A2 08 85 FE 06 FE 6A CA +41A8:D0 FA 60 A9 A0 4C ED FD +41B0:98 20 C1 FB A6 28 A4 29 +41B8:8E 86 44 8C 87 44 60 D8 +41C0:BD 23 A0 D9 BD 64 A0 A4 +41C8:BD 78 BA 40 A0 25 FE 3F +41D0:00 BF 41 27 00 BF 00 DE +41D8:C0 DE C0 1A DA 1A DA C2 +41E0:E9 EE A0 C1 D3 C3 BA A0 +41E8:25 00 C2 E9 EE A0 C9 CE +41F0:D6 BA A0 3F 00 DF 41 1A +41F8:DA EA 41 1A DA C4 E5 E3 +4200:B2 BA A0 23 00 C4 E5 E3 +4208:B3 BA A0 64 00 C4 E5 E3 +4210:B5 BA A0 75 00 C2 F9 F4 +4218:E5 BD 62 A0 62 A0 62 A0 +4220:62 A0 62 00 FD 41 63 00 +4228:05 42 E7 03 0D 42 69 FF +4230:15 42 80 00 FF 00 00 00 +4238:01 00 7F 00 C8 E5 F8 B2 +4240:BA A0 24 00 C8 E5 F8 B4 +4248:BA A0 78 00 D0 F4 F2 B2 +4250:BA A0 78 BA 40 00 D0 F4 +4258:F2 B4 BA A0 78 BA 26 00 +4260:3C 42 34 12 44 42 34 12 +4268:4C 42 00 20 00 20 56 42 +4270:00 20 00 20 CF E3 F4 B3 +4278:BA A0 6F 00 CF E3 F4 B6 +4280:BA A0 4F 00 74 42 B6 01 +4288:7C 42 DF 32 C8 C5 CC CC +4290:CF 00 D7 CF D2 CC C4 00 +4298:C8 CF CD 45 0D D0 E1 F3 +42A0:E3 E1 EC A0 CC E5 EE A0 +42A8:B1 B3 C3 A0 A0 A0 A0 A0 +42B0:BA A0 A7 73 A7 AC A7 73 +42B8:A7 00 C1 F0 F0 EC E5 A0 +42C0:BA A0 A7 61 A7 00 D0 E1 +42C8:F3 E3 E1 EC BA A0 A7 70 +42D0:A7 00 AA 42 8C 42 92 42 +42D8:BA 42 98 42 C6 42 9C 42 +42E0:F0 F2 E9 EE F4 ED A8 A9 +42E8:AE F3 E9 FA E5 A0 BD A0 +42F0:A4 00 A0 E2 F9 F4 E5 F3 +42F8:8D A0 A0 A0 A0 AE E6 E5 +4300:E1 F4 F5 F2 E5 F3 A0 BD +4308:A0 A4 A0 A0 00 C9 01 8E +4310:93 44 8C 94 44 9C 91 44 +4318:20 8C 44 8E 67 43 8C 68 +4320:43 80 43 38 A9 18 20 8C +4328:44 90 03 20 60 44 8A 20 +4330:60 44 80 2A 38 A9 18 20 +4338:8C 44 A0 00 B1 FE 90 EF +4340:AA C8 B1 FE 80 E5 20 8C +4348:44 A0 00 B1 FE 10 0A 20 +4350:85 44 C8 D0 F6 E6 FF 80 +4358:F2 09 80 20 85 44 EE 67 +4360:43 D0 03 EE 68 43 AD DE +4368:C0 F0 12 30 EE A2 0F CA +4370:30 EC DD AB 44 D0 F8 8A +4378:0A AA 7C BA 44 60 A9 02 +4380:2C A9 01 2C A9 00 8D B7 +4388:43 20 8C 44 8E A9 44 8C +4390:AA 44 9C A3 44 9C A4 44 +4398:9C A5 44 A2 10 F8 0E A9 +43A0:44 2E AA 44 A0 FD B9 A6 +43A8:43 79 A6 43 99 A6 43 C8 +43B0:D0 F4 CA D0 E9 D8 A0 03 +43B8:F0 0A B9 A3 44 20 6D 44 +43C0:20 85 44 88 B9 A3 44 20 +43C8:60 44 88 10 F7 80 8F A9 +43D0:31 2C A9 B1 8D E4 43 20 +43D8:8C 44 A0 08 8A 0A AA A9 +43E0:B0 90 02 A9 B1 20 85 44 +43E8:88 D0 F1 4C 5E 43 20 8C +43F0:44 8A 10 0A A9 AD 20 85 +43F8:44 8A 49 FF AA E8 A0 00 +4400:A9 01 8D B7 43 4C 8C 43 +4408:A9 06 2C A9 03 8D 2A 44 +4410:20 8C 44 A2 00 A5 FE 29 +4418:07 18 69 B0 9D A3 44 A0 +4420:03 46 FF 66 FE 88 D0 F9 +4428:E8 E0 06 D0 E8 CA 30 BB +4430:BD A3 44 20 85 44 80 F5 +4438:20 8C 44 A0 00 B1 FE F0 +4440:AA 20 85 44 C8 D0 F6 E6 +4448:FF 80 F2 20 8C 44 A0 00 +4450:B1 FE F0 97 AA C8 B1 FE +4458:20 85 44 CA D0 F7 F0 8B +4460:20 6D 44 A5 FE 20 85 44 +4468:A5 FF 4C 85 44 48 4A 4A +4470:4A 4A 20 78 44 85 FE 68 +4478:29 0F C9 0A 90 02 69 06 +4480:69 B0 85 FF 60 8D DE C0 +4488:EE 86 44 60 20 90 44 AA +4490:A0 00 B9 DE C0 EE 91 44 +4498:D0 03 EE 94 44 A8 86 FE +44A0:84 FF 60 00 00 00 00 00 +44A8:00 00 00 3F 25 62 75 64 +44B0:23 78 24 26 40 4F 6F 70 +44B8:73 61 CF 43 D2 43 EE 43 +44C0:7E 43 81 43 84 43 23 43 +44C8:25 43 34 43 36 43 08 44 +44D0:0B 44 4B 44 38 44 46 43 */ @@ -1036,7 +1033,6 @@ DEBUG .sprintf( "PrintHex2() @ %X", * ) HexWidth: CPX #4 ; _nHexWidth NOTE: self-modifying! BNE _HexDigit - ; Intentional fall into reverse BCD .endif ; OLD_PRINT_HEX .endif @@ -1149,8 +1145,6 @@ _Done ; ====================================================================== .if ENABLE_DEC -NEW_PRINT_DEC = 1 ; TODO: FIXME: DEBUG: - .if USE_DEC_5 DEBUG .sprintf( "PrintDec5() @ %X", * ) PrintDec5: @@ -1207,7 +1201,7 @@ DEBUG .sprintf( "PrintDec2() @ %X", * ) BNE @Dec2BCD CLD -.if NEW_PRINT_DEC +.if 1 ; NEW_PRINT_DEC DecWidth: LDY #3 ; was Y, default to 6 digits BEQ @EvenBCD @@ -1223,7 +1217,6 @@ DEBUG .sprintf( "PrintDec2() @ %X", * ) DEY BPL @EvenBCD BRA NextFormat ; always -;JMP NextFormat .else LDX #5 ; was Y, default to 6 digits @BCD2Char: ; NOTE: Digits are reversed! @@ -1347,7 +1340,7 @@ DEBUG .sprintf( "PrintOct3() @ %X", * ) JSR NxtArgYX ; X = low byte LDX #0 - @Oct2Asc: + _Oct2Asc: LDA _temp AND #7 CLC @@ -1362,14 +1355,12 @@ DEBUG .sprintf( "PrintOct3() @ %X", * ) BNE @OctShr INX - CPX #6 - BNE @Oct2Asc OctWidth: - LDX #6 ; _nOctDigits NOTE: self-modifying! + CPX #6 ; _nOctDigits NOTE: self-modifying! + BNE _Oct2Asc ; Intentional fall into reverse BCD ; On Entry: X number of chars to print in buffer _bcd ; ====================================================================== -;.if ENABLE_DEC || ENABLE_OCT PrintReverseBCD DEX BMI _JumpNextFormat @@ -1426,6 +1417,7 @@ DEBUG .sprintf( "PrintStrP() @ %X", * ) ; Utility ; ---------------------------------------------------------------------- +.if ENABLE_HEX || ENABLE_DEC ; Converts A to Hex digits, prints them PrintHexByte: .out .sprintf( "PrintHexByte @ %X", * ) @@ -1455,7 +1447,7 @@ _HexNib: ADC #'0' + $80 ; inverse=remove #$80 STA _temp+1 RTS - +.endif ; ====================================================================== ;