Browse code

Stopped incorrectly recognising hex strings longer than four chars

Andrew Alderwick authored on 20/10/2021 16:32:32
Showing 1 changed files
... ...
@@ -371,10 +371,13 @@ include projects/library/file-read-chunks.tal
371 371
 	#57 SUB
372 372
 	JMP2r
373 373
 
374
-@asma-parse-hex-string ( -- value* 06 if valid hex and length > 2
374
+@asma-parse-hex-string ( -- value* 06 if valid hex and 2 < length <= 4
375 375
                          OR value* 03 if valid hex and length <= 2
376 376
                          OR 00 otherwise )
377
-	;asma/token LDA2 DUP2 ,strlen JSR #0002 GTH2 ROT ROT
377
+	;asma/token LDA2 DUP2 ,strlen JSR ( token* length^ )
378
+	DUP2 #0004 GTH2 ,&fail2 JCN
379
+	&resume
380
+	#0002 GTH2 ROT ROT
378 381
 	LIT2r 0000
379 382
 
380 383
 	&loop
... ...
@@ -393,21 +396,24 @@ include projects/library/file-read-chunks.tal
393 396
 	,&loop JMP
394 397
 
395 398
 	&fail
396
-	POP POP2 POP2r
397
-	DUP EOR
399
+	POP2r
400
+	&fail2
401
+	POP2 POP2
402
+	#00
398 403
 	JMP2r
399 404
 
400 405
 %asma-SHORT-FLAG { #20 }
401 406
 %asma-RETURN-FLAG { #40 }
402 407
 %asma-KEEP-FLAG { #80 }
403 408
 
409
+include projects/library/string.tal
410
+
404 411
 @asma-traverse-tree ( incoming-ptr* -- binary-ptr* 00 if key found
405 412
                                     OR node-incoming-ptr* 01 if key not found )
406 413
 	;asma/token LDA2
407 414
 	( fall through to traverse-tree )
408 415
 
409 416
 include projects/library/binary-tree.tal
410
-include projects/library/string.tal
411 417
 
412 418
 @asma-parse-opcode ( -- byte 00 if valid opcode
413 419
                      OR 01 otherwise )