diff --git a/strings/Release/init.lst b/strings/Release/init.lst index 86f2720..91064c0 100644 --- a/strings/Release/init.lst +++ b/strings/Release/init.lst @@ -1,4 +1,4 @@ -Zilog eZ80 Macro Assembler Version 4.3 (19073001) RELISTED23-May-23 23:10:10 page: 1 +Zilog eZ80 Macro Assembler Version 4.3 (19073001) RELISTED11-Jun-23 17:34:51 page: 1 PC Object I Line Source @@ -117,7 +117,7 @@ PC Object I Line Source A 20 ; A 21 ; Start in mixed mode. Assumes MBASE is set to A 22 ; -000000 C3 50 00 A 23 JP _start ; Jump to start +000000 C3 51 00 A 23 JP _start ; Jump to start 000003 A 24 DS 5 A 25 000008 49CF A 26 RST_08: RST.LIS 08h ; API call @@ -146,43 +146,43 @@ PC Object I Line Source 000043 00 A 49 DB 00h ; MOS header ve 000044 00 A 50 DB 00h ; Flag for run A 51 -000045 47554E5A 49502E42 A 52 _exec_name: DB "GUNZIP.BIN", 0 ; The e -00004D 494E00 +000045 53545249 4E47532E A 52 _exec_name: DB "STRINGS.BIN", 0 ; T +00004D 42494E00 A 53 A 54 ; A 55 ; And the code follows on immediately after the A 56 ; -000050 5BFDE5 A 57 _start: PUSH.LIL IY ; Prese +000051 5BFDE5 A 57 _start: PUSH.LIL IY ; Prese A 58 -000053 FD210000 A 59 LD IY, 0 ; Preserve -000057 FD39 A 60 ADD IY, SP -000059 5BFDE5 A 61 PUSH.LIL IY -00005C 310080 A 62 LD SP, 8000h ; And set t +000054 FD210000 A 59 LD IY, 0 ; Preserve +000058 FD39 A 60 ADD IY, SP +00005A 5BFDE5 A 61 PUSH.LIL IY +00005D 310080 A 62 LD SP, 8000h ; And set t A 63 -00005F F5 A 64 PUSH AF ; Preserve -000060 5BC5 A 65 PUSH.LIL BC -000062 5BD5 A 66 PUSH.LIL DE -000064 5BDDE5 A 67 PUSH.LIL IX +000060 F5 A 64 PUSH AF ; Preserve +000061 5BC5 A 65 PUSH.LIL BC +000063 5BD5 A 66 PUSH.LIL DE +000065 5BDDE5 A 67 PUSH.LIL IX A 68 -000067 ED6E A 69 LD A, MB ; Segment b -000069 DD21 14 01 A 70 LD IX, argv_ptrs ; The a -00006D CD 00 01 A 71 CALL _set_aix24 ; Conve -000070 5BDDE5 A 72 PUSH.LIL IX -000073 CD 90 00 A 73 CALL _parse_params ; P -000076 5BDDE1 A 74 POP.LIL IX ; IX: argv -000079 0600 A 75 LD B, 0 ; C: argc -00007B CD 48 01 A 76 CALL _main ; Start +000068 ED6E A 69 LD A, MB ; Segment b +00006A DD21 15 01 A 70 LD IX, argv_ptrs ; The a +00006E CD 01 01 A 71 CALL _set_aix24 ; Conve +000071 5BDDE5 A 72 PUSH.LIL IX +000074 CD 91 00 A 73 CALL _parse_params ; P +000077 5BDDE1 A 74 POP.LIL IX ; IX: argv +00007A 0600 A 75 LD B, 0 ; C: argc +00007C CD 49 01 A 76 CALL _main ; Start A 77 -00007E 5BDDE1 A 78 POP.LIL IX ; Restore t -000081 5BD1 A 79 POP.LIL DE -000083 5BC1 A 80 POP.LIL BC -000085 F1 A 81 POP AF +00007F 5BDDE1 A 78 POP.LIL IX ; Restore t +000082 5BD1 A 79 POP.LIL DE +000084 5BC1 A 80 POP.LIL BC +000086 F1 A 81 POP AF A 82 -000086 5BFDE1 A 83 POP.LIL IY ; Get the p -000089 FDF9 A 84 LD SP, IY ; Restore t +000087 5BFDE1 A 83 POP.LIL IY ; Get the p +00008A FDF9 A 84 LD SP, IY ; Restore t A 85 -00008B 5BFDE1 A 86 POP.LIL IY ; Restore I -00008E 49C9 A 87 RET.L ; Return to +00008C 5BFDE1 A 86 POP.LIL IY ; Restore I +00008F 49C9 A 87 RET.L ; Return to A 88 A 89 ; Parse the parameter string into a C array A 90 ; Parameters @@ -192,40 +192,40 @@ PC Object I Line Source A 94 ; Returns: A 95 ; - C: Number of parameters parsed A 96 ; -000090 01 45 00 A 97 _parse_params: LD BC, _exec_name -000093 CD EE 00 A 98 CALL _set_abc24 ; Conve -000096 5BDD0F00 A 99 LD.LIL (IX+0), BC ; ARGV[ -00009A 5BDD23 A 100 INC.LIL IX -00009D 5BDD23 A 101 INC.LIL IX -0000A0 5BDD23 A 102 INC.LIL IX -0000A3 CD E5 00 A 103 CALL _skip_spaces ; S +000091 01 45 00 A 97 _parse_params: LD BC, _exec_name +000094 CD EF 00 A 98 CALL _set_abc24 ; Conve +000097 5BDD0F00 A 99 LD.LIL (IX+0), BC ; ARGV[ +00009B 5BDD23 A 100 INC.LIL IX +00009E 5BDD23 A 101 INC.LIL IX +0000A1 5BDD23 A 102 INC.LIL IX +0000A4 CD E6 00 A 103 CALL _skip_spaces ; S A 104 ; -0000A6 010100 A 105 LD BC, 1 ; C: ARGC = -0000A9 060F A 106 LD B, argv_ptrs_max - 1 ; B +0000A7 010100 A 105 LD BC, 1 ; C: ARGC = +0000AA 060F A 106 LD B, argv_ptrs_max - 1 ; B A 107 ; -0000AB C5 A 108 _parse_params_1: PUSH BC ; S -0000AC 5BE5 A 109 PUSH.LIL HL ; Stack sta -0000AE CD D4 00 A 110 CALL _get_token ; Get t -0000B1 79 A 111 LD A, C ; A: Length -0000B2 5BD1 A 112 POP.LIL DE ; Start add -0000B4 C1 A 113 POP BC ; ARGC -0000B5 B7 A 114 OR A ; Check for A=0 -0000B6 C8 A 115 RET Z +0000AC C5 A 108 _parse_params_1: PUSH BC ; S +0000AD 5BE5 A 109 PUSH.LIL HL ; Stack sta +0000AF CD D5 00 A 110 CALL _get_token ; Get t +0000B2 79 A 111 LD A, C ; A: Length +0000B3 5BD1 A 112 POP.LIL DE ; Start add +0000B5 C1 A 113 POP BC ; ARGC +0000B6 B7 A 114 OR A ; Check for A=0 +0000B7 C8 A 115 RET Z A 116 ; -0000B7 5BDD1F00 A 117 LD.LIL (IX+0), DE ; Store -0000BB 5BE5 A 118 PUSH.LIL HL ; DE=HL -0000BD 5BD1 A 119 POP.LIL DE -0000BF CD E5 00 A 120 CALL _skip_spaces ; A -0000C2 AF A 121 XOR A -0000C3 5B12 A 122 LD.LIL (DE), A ; Zero- -0000C5 5BDD23 A 123 INC.LIL IX -0000C8 5BDD23 A 124 INC.LIL IX -0000CB 5BDD23 A 125 INC.LIL IX ; Advance t -0000CE 0C A 126 INC C ; Increment ARG -0000CF 79 A 127 LD A, C ; Check for -0000D0 B8 A 128 CP B -0000D1 38 D8 A 129 JR C, _parse_params_1 ; And l -0000D3 C9 A 130 RET +0000B8 5BDD1F00 A 117 LD.LIL (IX+0), DE ; Store +0000BC 5BE5 A 118 PUSH.LIL HL ; DE=HL +0000BE 5BD1 A 119 POP.LIL DE +0000C0 CD E6 00 A 120 CALL _skip_spaces ; A +0000C3 AF A 121 XOR A +0000C4 5B12 A 122 LD.LIL (DE), A ; Zero- +0000C6 5BDD23 A 123 INC.LIL IX +0000C9 5BDD23 A 124 INC.LIL IX +0000CC 5BDD23 A 125 INC.LIL IX ; Advance t +0000CF 0C A 126 INC C ; Increment ARG +0000D0 79 A 127 LD A, C ; Check for +0000D1 B8 A 128 CP B +0000D2 38 D8 A 129 JR C, _parse_params_1 ; And l +0000D4 C9 A 130 RET A 131 A 132 ; Get the next token A 133 ; Parameters: @@ -234,17 +234,17 @@ PC Object I Line Source A 136 ; - HL: Address of first character after token A 137 ; - C: Length of token (in characters) A 138 ; -0000D4 0E00 A 139 _get_token: LD C, 0 ; Initi -0000D6 5B7E A 140 $$: LD.LIL A, (HL) ; Get t -0000D8 B7 A 141 OR A ; Exit if 0 (en -0000D9 C8 A 142 RET Z -0000DA FE0D A 143 CP 13 ; Exit if CR (e -0000DC C8 A 144 RET Z -0000DD FE20 A 145 CP ' ' ; Exit if space -0000DF C8 A 146 RET Z -0000E0 5B23 A 147 INC.LIL HL ; Advance t -0000E2 0C A 148 INC C ; Increment -0000E3 18 F1 A 149 JR $B +0000D5 0E00 A 139 _get_token: LD C, 0 ; Initi +0000D7 5B7E A 140 $$: LD.LIL A, (HL) ; Get t +0000D9 B7 A 141 OR A ; Exit if 0 (en +0000DA C8 A 142 RET Z +0000DB FE0D A 143 CP 13 ; Exit if CR (e +0000DD C8 A 144 RET Z +0000DE FE20 A 145 CP ' ' ; Exit if space +0000E0 C8 A 146 RET Z +0000E1 5B23 A 147 INC.LIL HL ; Advance t +0000E3 0C A 148 INC C ; Increment +0000E4 18 F1 A 149 JR $B A 150 A 151 ; Skip spaces in the parameter string A 152 ; Parameters: @@ -253,11 +253,11 @@ PC Object I Line Source A 155 ; - HL: Address of next none-space character A 156 ; F: Z if at end of string, otherwise NZ if A 157 ; -0000E5 5B7E A 158 _skip_spaces: LD.LIL A, (HL) -0000E7 FE20 A 159 CP ' ' ; Exit if not s -0000E9 C0 A 160 RET NZ -0000EA 5B23 A 161 INC.LIL HL ; Advance t -0000EC 18 F7 A 162 JR _skip_spaces ; Incre +0000E6 5B7E A 158 _skip_spaces: LD.LIL A, (HL) +0000E8 FE20 A 159 CP ' ' ; Exit if not s +0000EA C0 A 160 RET NZ +0000EB 5B23 A 161 INC.LIL HL ; Advance t +0000ED 18 F7 A 162 JR _skip_spaces ; Incre A 163 A 164 ; Set the MSB of BC (U) to A A 165 ; Parameters: @@ -266,14 +266,14 @@ PC Object I Line Source A 168 ; Returns: A 169 ; - BCU A 170 ; -0000EE 5BE5 A 171 _set_abc24: PUSH.LIL HL ; Prese -0000F0 5BC5 A 172 PUSH.LIL BC ; Stick BC -0000F2 5B210200 00 A 173 LD.LIL HL, 2 ; HL: S -0000F7 5B39 A 174 ADD.LIL HL, SP -0000F9 5B77 A 175 LD.LIL (HL), A ; Store -0000FB 5BC1 A 176 POP.LIL BC ; Fetch amm -0000FD 5BE1 A 177 POP.LIL HL ; Restore H -0000FF C9 A 178 RET +0000EF 5BE5 A 171 _set_abc24: PUSH.LIL HL ; Prese +0000F1 5BC5 A 172 PUSH.LIL BC ; Stick BC +0000F3 5B210200 00 A 173 LD.LIL HL, 2 ; HL: S +0000F8 5B39 A 174 ADD.LIL HL, SP +0000FA 5B77 A 175 LD.LIL (HL), A ; Store +0000FC 5BC1 A 176 POP.LIL BC ; Fetch amm +0000FE 5BE1 A 177 POP.LIL HL ; Restore H +000100 C9 A 178 RET A 179 A 180 ; Set the MSB of BC (U) to A A 181 ; Parameters: @@ -282,23 +282,23 @@ PC Object I Line Source A 184 ; Returns: A 185 ; - IXU A 186 ; -000100 5BDDE5 A 187 _set_aix24: PUSH.LIL IX ; Stick -000103 5BDD2102 0000 A 188 LD.LIL IX, 2 ; IX: S -000109 5BDD39 A 189 ADD.LIL IX, SP -00010C 5BDD7700 A 190 LD.LIL (IX), A ; Store -000110 5BDDE1 A 191 POP.LIL IX ; Fetch amm -000113 C9 A 192 RET +000101 5BDDE5 A 187 _set_aix24: PUSH.LIL IX ; Stick +000104 5BDD2102 0000 A 188 LD.LIL IX, 2 ; IX: S +00010A 5BDD39 A 189 ADD.LIL IX, SP +00010D 5BDD7700 A 190 LD.LIL (IX), A ; Store +000111 5BDDE1 A 191 POP.LIL IX ; Fetch amm +000114 C9 A 192 RET A 193 A 194 ; Storage for the argv array pointers A 195 ; -000114 000000 000000 A 196 argv_ptrs: BLKP argv_ptrs_max, 0 -00011A 000000 000000 -000120 000000 000000 -000126 000000 000000 -00012C 000000 000000 -000132 000000 000000 -000138 000000 000000 -00013E 000000 000000 +000115 000000 000000 A 196 argv_ptrs: BLKP argv_ptrs_max, 0 +00011B 000000 000000 +000121 000000 000000 +000127 000000 000000 +00012D 000000 000000 +000133 000000 000000 +000139 000000 000000 +00013F 000000 000000 A 197 A 198 END diff --git a/strings/Release/init.obj b/strings/Release/init.obj index 7615212..8ae2dfc 100644 Binary files a/strings/Release/init.obj and b/strings/Release/init.obj differ diff --git a/strings/Release/main.lst b/strings/Release/main.lst index 39aee34..94e461b 100644 --- a/strings/Release/main.lst +++ b/strings/Release/main.lst @@ -1,4 +1,4 @@ -Zilog eZ80 Macro Assembler Version 4.3 (19073001) RELISTED23-May-23 23:10:10 page: 1 +Zilog eZ80 Macro Assembler Version 4.3 (19073001) RELISTED11-Jun-23 17:34:52 page: 1 PC Object I Line Source @@ -12,11 +12,15 @@ PC Object I Line Source A 8 ; labels are case sensitive A 9 ; code is a reserved word and can't be used as A 10 ; numeric evaluations are done differently - ch - A 11 ; - A 12 - A 13 - A 14 .ASSUME ADL = 0 - A 15 + A 11 ; reserved word INCLUDE needs to be in upper ca + A 12 ; assembly source MUST be .asm, can't use e.g. + A 13 ; supports defb as a synonym for db, but NOT de + A 14 ; labels can't start with @ + A 15 ; + A 16 + A 17 + A 18 .ASSUME ADL = 0 + A 19 B 0 INCLUDE "equs.inc" B 1 ; B 2 ; Title: Memory Dump - Equs @@ -337,262 +341,283 @@ PC Object I Line Source B 223 LD A, function B 224 RST.LIS 08h B 225 ENDMACRO - A 18 - A 19 SEGMENT CODE - A 20 - A 21 XDEF _main + B 226 ; A 22 - A 23 - A 24 ; Error: Invalid parameter - A 25 ; -000144 211300 A 26 _err_invalid_param: LD HL, 19 ; T -000147 C9 A 27 RET - A 28 - A 29 - A 30 ; ASCII - A 31 ; - 00000003 A 32 CtrlC: equ 03h - A 33 CR: equ 0Dh - A 34 LF: equ 0Ah - 0000001A A 35 CtrlZ: equ 1Ah - A 36 ; - A 37 -000148 A 38 _main: -000148 79 A 39 ld a,c ;AGON - number of parameters -000149 3D A 40 dec a -00014A CA 3B 02 A 41 jp z,okusage -00014D FE03 A 42 cp 3 ;too many parameters -00014F D2 41 02 A 43 jp nc,badusage - A 44 -000152 5BDD2703 A 45 LD.LIL HL,(IX+3) ; HLU: pointer -000156 5B7E A 46 LD.LIL a,(HL) ;24 bit -000158 FE2D A 47 cp '-' -00015A 20 20 A 48 jr nz,openit -00015C 5B23 A 49 INC.LIL HL -00015E 5B7E A 50 LD.LIL a,(HL) ;24 bit -000160 FE6E A 51 cp 'n' -000162 C2 41 02 A 52 jp nz,badusage -000165 5B23 A 53 INC.LIL HL -000167 5B7E A 54 LD.LIL a,(HL) ;24 bit -000169 FE31 A 55 cp '1' -00016B DA 41 02 A 56 jp c,badusage -00016E FE3A A 57 cp '9'+1 -000170 D2 41 02 A 58 jp nc,badusage -000173 D630 A 59 sub '0' -000175 32 48 03 A 60 ld (stringlength),a -000178 5BDD2706 A 61 LD.LIL HL,(IX+6) ; HLU: pointer -00017C A 62 openit: -00017C 0E01 A 63 ld c,fa_read ;open read-only -00017E 5BDDE5 A 64 push.lil ix - A 65 MOSCALL mos_fopen -000185 5BDDE1 A 66 pop.lil ix -000188 B7 A 67 or a -000189 20 0E A 68 jr nz,open_ok - A 69 ; call inline_print - A 70 ; db "File not found.",CR,LF,0 - A 71 ; jr exit -00018B 210400 A 72 ld hl,4 ;file not found/could not find -00018E C9 A 73 ret ;exit - A 74 ; - A 75 ; - A 76 ; Close and exit routines - A 77 ; - A 78 -00018F A 79 close: - A 80 ;C: Filehandle, or 0 to close all open files - A 81 ;returns number of still open files - how about - A 82 -00018F 0E00 A 83 ld c,0 - A 84 MOSCALL mos_fclose - A 85 -000195 A 86 exit: -000195 210000 A 87 ld hl,0 ;for Agon - successful exit -000198 C9 A 88 ret - A 89 ; - A 90 ; -000199 A 91 open_ok: - A 92 -000199 32 49 03 A 93 ld (in_handle),a ;store the file handle - A 94 MOSCALL mos_sysvars ;get the sysvars locati -0001A0 DD7E19 A 95 ld a,(IX+sysvar_vkeycount) ;fetch keycount -0001A3 32 55 03 A 96 ld (keycount),a ;store to compare again -0001A6 A 97 stringlp: -0001A6 CD 0C 02 A 98 call getbyte -0001A9 CD F7 01 A 99 call unprintable -0001AC 28 39 A 100 jr z,noprint - A 101 ;store character and check next is also printab -0001AE 11 4A 03 A 102 ld de,buffer -0001B1 12 A 103 ld (de),a -0001B2 0601 A 104 ld b,1 ;lets see if we can kee -0001B4 A 105 innerlp: -0001B4 3A 48 03 A 106 ld a,(stringlength) -0001B7 B8 A 107 cp b -0001B8 28 14 A 108 jr z,printbuff - A 109 MOSCALL mos_feof ;check for end of file -0001BE B7 A 110 or a -0001BF 20 2D A 111 jr nz,donefile -0001C1 CD 0C 02 A 112 call getbyte ;fetch next byte -0001C4 CD F7 01 A 113 call unprintable -0001C7 28 1E A 114 jr z,noprint ;if unprintable, don't -0001C9 13 A 115 inc de -0001CA 12 A 116 ld (de),a -0001CB 04 A 117 inc b -0001CC 18 E6 A 118 jr innerlp - A 119 - A 120 -0001CE A 121 printbuff: - A 122 ; push bc ;preserve length -0001CE 11 4A 03 A 123 ld de,buffer -0001D1 A 124 $$: -0001D1 1A A 125 ld a,(de) -0001D2 D7 A 126 rst 10h -0001D3 13 A 127 inc de -0001D4 10 FB A 128 djnz $b - A 129 ; pop bc - A 130 ;now keep printing until unprintable again -0001D6 A 131 allgood_lp -0001D6 CD 0C 02 A 132 call getbyte -0001D9 CD F7 01 A 133 call unprintable -0001DC 28 03 A 134 jr z,endstring -0001DE D7 A 135 rst 10h -0001DF 18 F5 A 136 jr allgood_lp -0001E1 A 137 endstring: -0001E1 CD 00 02 A 138 call inline_print -0001E4 0D0A00 A 139 db CR,LF,0 ;newline at end - TEST -0001E7 A 140 noprint: - A 141 MOSCALL mos_feof ;check for end of file -0001EB B7 A 142 or a -0001EC 28 B8 A 143 jr z,stringlp -0001EE A 144 donefile: -0001EE CD 00 02 A 145 call inline_print -0001F1 0D0A00 A 146 db CR,LF,0 -0001F4 C3 8F 01 A 147 jp close - A 148 - A 149 - A 150 ; Entry: - A 151 ; A is a character to test - A 152 ; Exit: - A 153 ; Z flag is unprintable -0001F7 A 154 unprintable: -0001F7 FE20 A 155 cp ' ' -0001F9 38 03 A 156 jr c,$f -0001FB FE7F A 157 cp 127 -0001FD D8 A 158 ret c ;always nz -0001FE AF A 159 $$: xor a ;sets 0 flag -0001FF C9 A 160 ret - A 161 ; - A 162 ; Prints string directly after the call - A 163 ; -000200 E1 A 164 inline_print: pop hl -000201 CD 07 02 A 165 call print_string -000204 E9 A 166 jp (hl) - A 167 ; - A 168 ; more efficient print string for strings > 1 c -000205 A 169 $$: -000205 D7 A 170 rst 10h ;Agon uses this to print the charac -000206 23 A 171 inc hl -000207 7E A 172 print_string: ld a,(hl) -000208 B7 A 173 or a -000209 20 FA A 174 jr nz,$b -00020B C9 A 175 ret - A 176 ; - A 177 ; -00020C A 178 getbyte: -00020C CD 18 02 A 179 call ck_ctrlC -00020F 3A 49 03 A 180 ld a,(in_handle) -000212 4F A 181 ld c,a - A 182 MOSCALL mos_fgetc ;carry flag on last byt -000217 C9 A 183 ret - A 184 - A 185 ; Check for ctrl-C. If so, clean stack and exit - A 186 ; -000218 A 187 ck_ctrlC: -000218 3E01 A 188 ld a,1 ; modified below by self modify -00021A 3D A 189 dec a -00021B E60F A 190 and 15 -00021D 32 19 02 A 191 ld (ck_ctrlC+1),a ; update LD A instructi -000220 C0 A 192 ret nz ; check every 16 calls only - A 193 MOSCALL mos_sysvars ;get the sysvars locati -000225 5BDD7E19 A 194 ld.lil a,(IX+sysvar_vkeycount) ;check if a -000229 21 55 03 A 195 ld hl,keycount -00022C BE A 196 cp (hl) ;compare against keycount for c -00022D C8 A 197 ret z -00022E 77 A 198 ld (hl),a ;update keycount -00022F 5BDD7E05 A 199 ld.lil a,(IX+sysvar_keyascii) ;fetch char -000233 FE03 A 200 cp 3 ;is it ctr-C -000235 C0 A 201 ret nz -000236 E1 A 202 pop hl ;clean up stack -000237 E1 A 203 pop hl -000238 C3 8F 01 A 204 jp close - A 205 -00023B CD 47 02 A 206 okusage: call usage -00023E C3 95 01 A 207 jp exit - A 208 -000241 CD 47 02 A 209 badusage: call usage -000244 C3 44 01 A 210 jp _err_invalid_param - A 211 ; - A 212 ; usage -- show syntax - A 213 ; -000247 CD 00 02 A 214 usage: call inline_print -00024A 0D0A7374 72696E67 A 215 db CR,LF,'strings utility for Agon by Shaw -000252 73207574 696C6974 -00025A 7920666F 72204167 -000262 6F6E2062 79205368 -00026A 61776E20 53696A6E -000272 73747261 2032332D -00027A 4D61792D 32303233 -000282 0D0A0D0A -000286 55736167 653A0D0A A 216 db 'Usage:',CR,LF -00028E 20202073 7472696E A 217 db ' strings [-nX] ',CR,LF -000296 6773205B 2D6E585D -00029E 203C6669 6C653E0D -0002A6 0A -0002A7 4F707469 6F6E616C A 218 db 'Optional parameter n specifies minimum -0002AF 20706172 616D6574 -0002B7 6572206E 20737065 -0002BF 63696669 6573206D -0002C7 696E696D 756D2073 -0002CF 7472696E 67206C65 -0002D7 6E677468 20583D31 -0002DF 2E2E390D 0A -0002E4 20446566 61756C74 A 219 db ' Default string length 4. Ctrl-C to ab -0002EC 20737472 696E6720 -0002F4 6C656E67 74682034 -0002FC 2E204374 726C2D43 -000304 20746F20 61626F72 -00030C 742E0D0A -000310 53746F72 6520696E A 220 db 'Store in /mos directory. Requires MOS -000318 202F6D6F 73206469 -000320 72656374 6F72792E -000328 20526571 75697265 -000330 73204D4F 5320312E -000338 3033206F 72206C61 -000340 7465722E 0D0A00 -000347 C9 A 221 ret - A 222 - A 223 ; - A 224 ; data storage . . . - A 225 ; -000348 A 226 stringlength: -000348 04 A 227 db 4 ;default of 4 characters - A 228 ; uninitialized storage/BSS but can't use that - A 229 ; - A 230 ; RAM - A 231 ; - A 232 DEFINE LORAM, SPACE = ROM - A 233 ; ORDER __VECTORS, CODE, LORAM - A 234 SEGMENT LORAM - A 235 - A 236 ; SEGMENT BSS - A 237 ; SEGMENT CODE - A 238 -000349 A 239 in_handle: DS 1 ;Only needs 1 byte handle -00034A A 240 buffer: DS 10 ;Space to buffer incoming s -000354 A 241 curbyte: DS 1 ;current byte in the buffer -000355 A 242 keycount: DS 1 ;current key count - A 243 end + A 23 SEGMENT CODE + A 24 + A 25 XDEF _main + A 26 + A 27 + A 28 ; Error: Invalid parameter + A 29 ; +000145 211300 A 30 _err_invalid_param: LD HL, 19 ; T +000148 C9 A 31 RET + A 32 + A 33 + A 34 ; ASCII + A 35 ; + 00000003 A 36 CtrlC: equ 03h + A 37 CR: equ 0Dh + A 38 LF: equ 0Ah + 0000001A A 39 CtrlZ: equ 1Ah + A 40 ; + A 41 +000149 A 42 _main: +000149 79 A 43 ld a,c ;AGON - number of parameters +00014A 3D A 44 dec a +00014B CA 59 02 A 45 jp z,okusage +00014E FE03 A 46 cp 3 ;too many parameters +000150 D2 5F 02 A 47 jp nc,badusage + A 48 +000153 5BDD2703 A 49 LD.LIL HL,(IX+3) ; HLU: pointer +000157 5B7E A 50 LD.LIL a,(HL) ;24 bit +000159 FE2D A 51 cp '-' +00015B 20 3D A 52 jr nz,openit +00015D 5B23 A 53 INC.LIL HL +00015F 5B7E A 54 LD.LIL a,(HL) ;24 bit +000161 FE6E A 55 cp 'n' +000163 C2 5F 02 A 56 jp nz,badusage +000166 5B23 A 57 INC.LIL HL +000168 5B7E A 58 LD.LIL a,(HL) ;24 bit +00016A FE31 A 59 cp '1' +00016C DA 5F 02 A 60 jp c,badusage +00016F FE3A A 61 cp '9'+1 +000171 D2 5F 02 A 62 jp nc,badusage +000174 D630 A 63 sub '0' +000176 5F A 64 ld e,a +000177 32 8A 03 A 65 ld (stringlength),a +00017A 5B23 A 66 INC.LIL HL +00017C 5B7E A 67 LD.LIL a,(HL) ;24 bit +00017E FE21 A 68 cp ' '+1 +000180 38 14 A 69 jr c,lengthdone +000182 FE30 A 70 cp '0' +000184 DA 5F 02 A 71 jp c,badusage +000187 FE3A A 72 cp '9'+1 +000189 D2 5F 02 A 73 jp nc,badusage +00018C D630 A 74 sub '0' +00018E 160A A 75 ld d,10 +000190 ED5C A 76 mlt de +000192 83 A 77 add a,e +000193 32 8A 03 A 78 ld (stringlength),a +000196 A 79 lengthdone: + A 80 +000196 5BDD2706 A 81 LD.LIL HL,(IX+6) ; HLU: pointer +00019A A 82 openit: +00019A 0E01 A 83 ld c,fa_read ;open read-only +00019C 5BDDE5 A 84 push.lil ix + A 85 MOSCALL mos_fopen +0001A3 5BDDE1 A 86 pop.lil ix +0001A6 B7 A 87 or a +0001A7 20 0E A 88 jr nz,open_ok + A 89 ; call inline_print + A 90 ; db "File not found.",CR,LF,0 + A 91 ; jr exit +0001A9 210400 A 92 ld hl,4 ;file not found/could not find +0001AC C9 A 93 ret ;exit + A 94 ; + A 95 ; + A 96 ; Close and exit routines + A 97 ; + A 98 +0001AD A 99 close: + A 100 ;C: Filehandle, or 0 to close all open files + A 101 ;returns number of still open files - how about + A 102 +0001AD 0E00 A 103 ld c,0 + A 104 MOSCALL mos_fclose + A 105 +0001B3 A 106 exit: +0001B3 210000 A 107 ld hl,0 ;for Agon - successful exit +0001B6 C9 A 108 ret + A 109 ; + A 110 ; +0001B7 A 111 open_ok: + A 112 +0001B7 32 8B 03 A 113 ld (in_handle),a ;store the file handle + A 114 MOSCALL mos_sysvars ;get the sysvars locati +0001BE DD7E19 A 115 ld a,(IX+sysvar_vkeycount) ;fetch keycount +0001C1 32 F1 03 A 116 ld (keycount),a ;store to compare again +0001C4 A 117 stringlp: +0001C4 CD 2A 02 A 118 call getbyte +0001C7 CD 15 02 A 119 call unprintable +0001CA 28 39 A 120 jr z,noprint + A 121 ;store character and check next is also printab +0001CC 11 8C 03 A 122 ld de,buffer +0001CF 12 A 123 ld (de),a +0001D0 0601 A 124 ld b,1 ;lets see if we can kee +0001D2 A 125 innerlp: +0001D2 3A 8A 03 A 126 ld a,(stringlength) +0001D5 B8 A 127 cp b +0001D6 28 14 A 128 jr z,printbuff + A 129 MOSCALL mos_feof ;check for end of file +0001DC B7 A 130 or a +0001DD 20 2D A 131 jr nz,donefile +0001DF CD 2A 02 A 132 call getbyte ;fetch next byte +0001E2 CD 15 02 A 133 call unprintable +0001E5 28 1E A 134 jr z,noprint ;if unprintable, don't +0001E7 13 A 135 inc de +0001E8 12 A 136 ld (de),a +0001E9 04 A 137 inc b +0001EA 18 E6 A 138 jr innerlp + A 139 + A 140 +0001EC A 141 printbuff: + A 142 ; push bc ;preserve length +0001EC 11 8C 03 A 143 ld de,buffer +0001EF A 144 $$: +0001EF 1A A 145 ld a,(de) +0001F0 D7 A 146 rst 10h +0001F1 13 A 147 inc de +0001F2 10 FB A 148 djnz $b + A 149 ; pop bc + A 150 ;now keep printing until unprintable again +0001F4 A 151 allgood_lp +0001F4 CD 2A 02 A 152 call getbyte +0001F7 CD 15 02 A 153 call unprintable +0001FA 28 03 A 154 jr z,endstring +0001FC D7 A 155 rst 10h +0001FD 18 F5 A 156 jr allgood_lp +0001FF A 157 endstring: +0001FF CD 1E 02 A 158 call inline_print +000202 0D0A00 A 159 db CR,LF,0 ;newline at end - TEST +000205 A 160 noprint: + A 161 MOSCALL mos_feof ;check for end of file +000209 B7 A 162 or a +00020A 28 B8 A 163 jr z,stringlp +00020C A 164 donefile: +00020C CD 1E 02 A 165 call inline_print +00020F 0D0A00 A 166 db CR,LF,0 +000212 C3 AD 01 A 167 jp close + A 168 + A 169 + A 170 ; Entry: + A 171 ; A is a character to test + A 172 ; Exit: + A 173 ; Z flag is unprintable +000215 A 174 unprintable: +000215 FE20 A 175 cp ' ' +000217 38 03 A 176 jr c,$f +000219 FE7F A 177 cp 127 +00021B D8 A 178 ret c ;always nz +00021C AF A 179 $$: xor a ;sets 0 flag +00021D C9 A 180 ret + A 181 ; + A 182 ; Prints string directly after the call + A 183 ; +00021E E1 A 184 inline_print: pop hl +00021F CD 25 02 A 185 call print_string +000222 E9 A 186 jp (hl) + A 187 ; + A 188 ; more efficient print string for strings > 1 c +000223 A 189 $$: +000223 D7 A 190 rst 10h ;Agon uses this to print the charac +000224 23 A 191 inc hl +000225 7E A 192 print_string: ld a,(hl) +000226 B7 A 193 or a +000227 20 FA A 194 jr nz,$b +000229 C9 A 195 ret + A 196 ; + A 197 ; +00022A A 198 getbyte: +00022A CD 36 02 A 199 call ck_ctrlC +00022D 3A 8B 03 A 200 ld a,(in_handle) +000230 4F A 201 ld c,a + A 202 MOSCALL mos_fgetc ;carry flag on last byt +000235 C9 A 203 ret + A 204 + A 205 ; Check for ctrl-C. If so, clean stack and exit + A 206 ; +000236 A 207 ck_ctrlC: +000236 3E01 A 208 ld a,1 ; modified below by self modify +000238 3D A 209 dec a +000239 E60F A 210 and 15 +00023B 32 37 02 A 211 ld (ck_ctrlC+1),a ; update LD A instructi +00023E C0 A 212 ret nz ; check every 16 calls only + A 213 MOSCALL mos_sysvars ;get the sysvars locati +000243 5BDD7E19 A 214 ld.lil a,(IX+sysvar_vkeycount) ;check if a +000247 21 F1 03 A 215 ld hl,keycount +00024A BE A 216 cp (hl) ;compare against keycount for c +00024B C8 A 217 ret z +00024C 77 A 218 ld (hl),a ;update keycount +00024D 5BDD7E05 A 219 ld.lil a,(IX+sysvar_keyascii) ;fetch char +000251 FE03 A 220 cp 3 ;is it ctr-C +000253 C0 A 221 ret nz +000254 E1 A 222 pop hl ;clean up stack +000255 E1 A 223 pop hl +000256 C3 AD 01 A 224 jp close + A 225 +000259 CD 65 02 A 226 okusage: call usage +00025C C3 B3 01 A 227 jp exit + A 228 +00025F CD 65 02 A 229 badusage: call usage +000262 C3 45 01 A 230 jp _err_invalid_param + A 231 ; + A 232 ; usage -- show syntax + A 233 ; +000265 CD 1E 02 A 234 usage: call inline_print +000268 0D0A7374 72696E67 A 235 db CR,LF,'strings utility for Agon by Shaw +000270 73207574 696C6974 +000278 7920666F 72204167 +000280 6F6E2062 79205368 +000288 61776E20 53696A6E +000290 73747261 2031312D +000298 4A756E2D 32303233 +0002A0 0D0A0D0A +0002A4 55736167 653A0D0A A 236 db 'Usage:',CR,LF +0002AC 20202073 7472696E A 237 db ' strings [-nX] ',CR,LF,CR,LF +0002B4 6773205B 2D6E585D +0002BC 203C6669 6C653E0D +0002C4 0A0D0A +0002C7 4F707469 6F6E616C A 238 db 'Optional parameter n for minimum strin +0002CF 20706172 616D6574 +0002D7 6572206E 20666F72 +0002DF 206D696E 696D756D +0002E7 20737472 696E6720 +0002EF 6C656E67 74682058 +0002F7 203D2031 20757020 +0002FF 746F2039 390D0A +000306 20446566 61756C74 A 239 db ' Default string length 4 (equivalent t +00030E 20737472 696E6720 +000316 6C656E67 74682034 +00031E 20286571 75697661 +000326 6C656E74 20746F20 +00032E 2D6E3429 2E204374 +000336 726C2D43 20746F20 +00033E 61626F72 742E0D0A +000346 53746F72 65207374 A 240 db 'Store strings.bin in /mos directory. M +00034E 72696E67 732E6269 +000356 6E20696E 202F6D6F +00035E 73206469 72656374 +000366 6F72792E 204D696E +00036E 696D756D 204D4F53 +000376 20766572 73696F6E +00037E 20312E30 332E0D0A +000386 0D0A00 +000389 C9 A 241 ret + A 242 + A 243 ; + A 244 ; data storage . . . + A 245 ; +00038A A 246 stringlength: +00038A 04 A 247 db 4 ;default of 4 characters + A 248 ; uninitialized storage/BSS but can't use that + A 249 ; + A 250 ; RAM + A 251 ; + A 252 DEFINE LORAM, SPACE = ROM + A 253 ; ORDER __VECTORS, CODE, LORAM + A 254 SEGMENT LORAM + A 255 + A 256 ; SEGMENT BSS + A 257 ; SEGMENT CODE + A 258 +00038B A 259 in_handle: DS 1 ;Only needs 1 byte handle +00038C A 260 buffer: DS 100 ;Space to buffer incoming s +0003F0 A 261 curbyte: DS 1 ;current byte in the buffer +0003F1 A 262 keycount: DS 1 ;current key count + A 263 end Errors: 0 Warnings: 0 -Lines Assembled: 583 +Lines Assembled: 604 diff --git a/strings/Release/main.obj b/strings/Release/main.obj index 301b0ad..9b9cf55 100644 Binary files a/strings/Release/main.obj and b/strings/Release/main.obj differ diff --git a/strings/Release/strings.bin b/strings/Release/strings.bin index 786c78e..6b4f094 100644 Binary files a/strings/Release/strings.bin and b/strings/Release/strings.bin differ diff --git a/strings/Release/strings.hex b/strings/Release/strings.hex index 646d095..a46d230 100644 --- a/strings/Release/strings.hex +++ b/strings/Release/strings.hex @@ -1,19 +1,20 @@ :020000040004F6 -:03000000C35000EA +:03000000C35100E9 :0300080049CFC914 :0300100049D7C904 :03003800FBED4D90 -:400040004D4F53000047554E5A49502E42494E005BFDE5FD210000FD395BFDE5310080F55BC55BD55BDDE5ED6EDD211401CD00015BDDE5CD90005BDDE10600CD48015BDDA9 -:40008000E15BD15BC1F15BFDE1FDF95BFDE149C9014500CDEE005BDD0F005BDD235BDD235BDD23CDE500010100060FC55BE5CDD400795BD1C1B7C85BDD1F005BE55BD1CD6F -:4000C000E500AF5B125BDD235BDD235BDD230C79B838D8C90E005B7EB7C8FE0DC8FE20C85B230C18F15B7EFE20C05B2318F75BE55BC55B210200005B395B775BC15BE1C97D -:400100005BDDE55BDD210200005BDD395BDD77005BDDE1C9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045 -:4001400000000000211300C9793DCA3B02FE03D241025BDD27035B7EFE2D20205B235B7EFE6EC241025B235B7EFE31DA4102FE3AD24102D6303248035BDD27060E015BDD22 -:40018000E53E0A49CF5BDDE1B7200E210400C90E003E0B49CF210000C93249033E0849CFDD7E19325503CD0C02CDF7012839114A031206013A4803B828143E0E49CFB720AF -:4001C0002DCD0C02CDF701281E13120418E6114A031AD71310FBCD0C02CDF7012803D718F5CD00020D0A003E0E49CFB728B8CD00020D0A00C38F01FE203803FE7FD8AFC969 -:40020000E1CD0702E9D7237EB720FAC9CD18023A49034F3E0C49CFC93E013DE60F321902C03E0849CF5BDD7E19215503BEC8775BDD7E05FE03C0E1E1C38F01CD4702C39505 -:4002400001CD4702C34401CD00020D0A737472696E6773207574696C69747920666F722041676F6E20627920536861776E2053696A6E737472612032332D4D61792D32303D -:4002800032330D0A0D0A55736167653A0D0A202020737472696E6773205B2D6E585D203C66696C653E0D0A4F7074696F6E616C20706172616D65746572206E20737065635F -:4002C0006966696573206D696E696D756D20737472696E67206C656E67746820583D312E2E390D0A2044656661756C7420737472696E67206C656E67746820342E20437450 -:40030000726C2D4320746F2061626F72742E0D0A53746F726520696E202F6D6F73206469726563746F72792E205265717569726573204D4F5320312E3033206F72206C61DB -:090340007465722E0D0A00C90457 +:400040004D4F530000535452494E47532E42494E005BFDE5FD210000FD395BFDE5310080F55BC55BD55BDDE5ED6EDD211501CD01015BDDE5CD91005BDDE10600CD49015B35 +:40008000DDE15BD15BC1F15BFDE1FDF95BFDE149C9014500CDEF005BDD0F005BDD235BDD235BDD23CDE600010100060FC55BE5CDD500795BD1C1B7C85BDD1F005BE55BD15C +:4000C000CDE600AF5B125BDD235BDD235BDD230C79B838D8C90E005B7EB7C8FE0DC8FE20C85B230C18F15B7EFE20C05B2318F75BE55BC55B210200005B395B775BC15BE178 +:40010000C95BDDE55BDD210200005BDD395BDD77005BDDE1C9000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C +:400140000000000000211300C9793DCA5902FE03D25F025BDD27035B7EFE2D203D5B235B7EFE6EC25F025B235B7EFE31DA5F02FE3AD25F02D6305F328A035B235B7EFE2104 +:400180003814FE30DA5F02FE3AD25F02D630160AED5C83328A035BDD27060E015BDDE53E0A49CF5BDDE1B7200E210400C90E003E0B49CF210000C9328B033E0849CFDD7EBF +:4001C0001932F103CD2A02CD15022839118C031206013A8A03B828143E0E49CFB7202DCD2A02CD1502281E13120418E6118C031AD71310FBCD2A02CD15022803D718F5CDF4 +:400200001E020D0A003E0E49CFB728B8CD1E020D0A00C3AD01FE203803FE7FD8AFC9E1CD2502E9D7237EB720FAC9CD36023A8B034F3E0C49CFC93E013DE60F323702C03E00 +:400240000849CF5BDD7E1921F103BEC8775BDD7E05FE03C0E1E1C3AD01CD6502C3B301CD6502C34501CD1E020D0A737472696E6773207574696C69747920666F7220416775 +:400280006F6E20627920536861776E2053696A6E737472612031312D4A756E2D323032330D0A0D0A55736167653A0D0A202020737472696E6773205B2D6E585D203C666933 +:4002C0006C653E0D0A0D0A4F7074696F6E616C20706172616D65746572206E20666F72206D696E696D756D20737472696E67206C656E6774682058203D2031207570207471 +:400300006F2039390D0A2044656661756C7420737472696E67206C656E677468203420286571756976616C656E7420746F202D6E34292E204374726C2D4320746F20616239 +:400340006F72742E0D0A53746F726520737472696E67732E62696E20696E202F6D6F73206469726563746F72792E204D696E696D756D204D4F532076657273696F6E20310B +:0B0380002E30332E0D0A0D0A00C904B8 :00000001FF diff --git a/strings/Release/strings.lod b/strings/Release/strings.lod index e6fc6b6..8c3b8e6 100644 Binary files a/strings/Release/strings.lod and b/strings/Release/strings.lod differ diff --git a/strings/Release/strings.map b/strings/Release/strings.map index 67ffe3e..bb9cd19 100644 --- a/strings/Release/strings.map +++ b/strings/Release/strings.map @@ -4,7 +4,7 @@ Copyright (C) 1999-2008 Zilog, Inc. All Rights Reserved LINK MAP: -DATE: Tue May 23 23:10:10 2023 +DATE: Sun Jun 11 17:34:51 2023 PROCESSOR: assembler FILES: .\init.obj .\main.obj @@ -72,10 +72,10 @@ SPACE ALLOCATION: Space Base Top Size Used Unused ------------------ ----------- ----------- --------- --------- --------- -RAM D:040000 D:040355 80000H 356H 7FCAAH - ( 524288 854 523434) -ROM C:000000 C:000355 20000H 356H 1FCAAH - ( 131072 854 130218) +RAM D:040000 D:0403F1 80000H 3F2H 7FC0EH + ( 524288 1010 523278) +ROM C:000000 C:0003F1 20000H 3F2H 1FC0EH + ( 131072 1010 130062) SEGMENTS WITHIN SPACE: @@ -83,33 +83,33 @@ SEGMENTS WITHIN SPACE: RAM Type Base Top Size ------------------ ------------------- ----------- ----------- --------- -__VECTORS * segment copy * D:040000 D:040143 144h -CODE * segment copy * D:040144 D:040348 205h -LORAM * segment copy * D:040349 D:040355 dh +__VECTORS * segment copy * D:040000 D:040144 145h +CODE * segment copy * D:040145 D:04038A 246h +LORAM * segment copy * D:04038B D:0403F1 67h ROM Type Base Top Size ------------------ ------------------- ----------- ----------- --------- -__VECTORS normal data C:000000 C:000143 144h -CODE normal data C:000144 C:000348 205h -LORAM normal data C:000349 C:000355 dh +__VECTORS normal data C:000000 C:000144 145h +CODE normal data C:000145 C:00038A 246h +LORAM normal data C:00038B C:0003F1 67h SEGMENTS WITHIN MODULES: ======================== -Module: D:\agon\agon-projects-main\ASM\strings\init.asm (File: init.obj) Version: 1:0 05/23/2023 23:10:10 +Module: D:\agon\agon-projects-main\ASM\strings\init.asm (File: init.obj) Version: 1:0 06/11/2023 17:34:51 Name Base Top Size --------------------------------------- ----------- ----------- --------- - Segment: __VECTORS C:000000 C:000143 144h + Segment: __VECTORS C:000000 C:000144 145h -Module: D:\agon\agon-projects-main\ASM\strings\main.asm (File: main.obj) Version: 1:0 05/23/2023 23:10:10 +Module: D:\agon\agon-projects-main\ASM\strings\main.asm (File: main.obj) Version: 1:0 06/11/2023 17:34:51 Name Base Top Size --------------------------------------- ----------- ----------- --------- - Segment: CODE C:000144 C:000348 205h - Segment: LORAM C:000349 C:000355 dh + Segment: CODE C:000145 C:00038A 246h + Segment: LORAM C:00038B C:0003F1 67h EXTERNAL DEFINITIONS: ===================== @@ -137,7 +137,7 @@ __FLASH_ADDR_U_INIT_PARAM 00000000 (User Defined) __FLASH_CTL_INIT_PARAM 00000028 (User Defined) __RAM_ADDR_U_INIT_PARAM 000000FF (User Defined) __RAM_CTL_INIT_PARAM 00000080 (User Defined) -_main C:000148 main CODE +_main C:000149 main CODE _SYS_CLK_FREQ 01194000 (User Defined) 23 external symbol(s). @@ -173,8 +173,8 @@ _SYS_CLK_FREQ Defined LINKER OUTPUT CHECKSUM =============== -strings.hex 011C00 -strings.lod 011C00 +strings.hex 013522 +strings.lod 013522