From d6c6b56e336e337fdb99f24efe8ddd1ace8efe30 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 16 Jan 2021 21:23:33 +0100 Subject: [PATCH] initial port of monitor 'H' command --- src/mon_m65/bsmon.s | 51 +--------------- src/mon_m65/mon_command_hunt.s | 77 ++++++++++++++++++++++++ src/mon_m65/mon_helper_get_addr_to_lac.s | 6 ++ 3 files changed, 84 insertions(+), 50 deletions(-) create mode 100644 src/mon_m65/mon_command_hunt.s diff --git a/src/mon_m65/bsmon.s b/src/mon_m65/bsmon.s index 9e29ca4c..e8f68cda 100644 --- a/src/mon_m65/bsmon.s +++ b/src/mon_m65/bsmon.s @@ -195,7 +195,7 @@ Jump_Table: !word Mon_Disassemble ; D !word Mon_Fill ; F !word Mon_Go ; G XXX to be debugged/adapted - !word Mon_Hunt ; H XXX to be debugged/adapted + !word Mon_Hunt ; H XXX to be bugfixed !word Mon_JSR ; J XXX to be debugged/adapted !word Mon_Memory ; M !word Mon_Register ; R @@ -550,55 +550,6 @@ Dump_Row: PLZ RTS -; ******* -Mon_Hunt: -; ******* - - JSR Get_Param_Range ; Long_PC = start - LBCS Mon_Error ; Long_CT = count - LDY #0 - JSR Get_Char - CMP #KEY_APOSTROPHE - BNE @bin - JSR Get_Char ; string hunt - CMP #0 - LBEQ Mon_Error ; null string - -@lpstr STA Mon_Data,Y - INY - JSR Get_Char - BEQ @hunt - CPY #32 ;max. string length - BNE @lpstr - BRA @hunt - -@bin JSR Got_LAC -@lpbin LDA Long_AC - STA Mon_Data,Y - INY - JSR Get_LAC - BCS @hunt - CPY #32 ;max. data length - BNE @lpbin - -@hunt STY Long_DA ; hunt length - JSR Print_CR - -@lpstart LDY #0 -@lpins JSR Fetch - CMP Mon_Data,Y - BNE @next - INY - CPY Long_DA - BNE @lpins - JSR Print_LPC_Addr ; match -@next JSR STOP - LBEQ Main - JSR Inc_LPC - JSR Dec_LCT - BPL @lpstart - JMP Main - ; ******** Load_Save: ; ******** diff --git a/src/mon_m65/mon_command_hunt.s b/src/mon_m65/mon_command_hunt.s new file mode 100644 index 00000000..fa679c1c --- /dev/null +++ b/src/mon_m65/mon_command_hunt.s @@ -0,0 +1,77 @@ + +; Based on BSM (Bit Shifter's Monitor) + + +Mon_Hunt: + + jsr Get_Param_Range ; Long_PC = start + +bcs Mon_Error ; Long_CT = count + + ldy #$00 + jsr Get_Char + cmp #KEY_APOSTROPHE + bne @bin + jsr Get_Char ; string hunt + cmp #$00 + +beq Mon_Error ; null string + +@lpstr: + + sta Mon_Data,Y + iny + jsr Get_Char + beq @hunt + cpy #32 ; max string length + bne @lpstr + bra @hunt + +@bin: + + jsr Got_Addr_To_LAC + +@lpbin: + + lda Long_AC + sta Mon_Data,Y + iny + jsr Get_Addr_To_LAC + beq @hunt + lda Long_AC+1 + ora Long_AC+2 + ora Long_AC+3 + +beq Mon_Error ; value above $FF + + cpy #32 ; max data length + bne @lpbin + +@hunt: + + sty Long_DA ; hunt length + jsr Print_CR + +@lpstart: + + lda Src_Addr_Mode + ora Dst_Addr_Mode + sta Addr_Mode ; combined addressing mode + + ldy #$00 + +@lpins: + + jsr Fetch + cmp Mon_Data,Y + bne @next + iny + cpy Long_DA + bne @lpins + jsr Print_LPC_Addr ; match + +@next: + + jsr STOP + +beq Main + jsr Inc_LPC + jsr Dec_LCT + bpl @lpstart + jmp Main diff --git a/src/mon_m65/mon_helper_get_addr_to_lac.s b/src/mon_m65/mon_helper_get_addr_to_lac.s index a2a17a3f..d57c3e55 100644 --- a/src/mon_m65/mon_helper_get_addr_to_lac.s +++ b/src/mon_m65/mon_helper_get_addr_to_lac.s @@ -2,6 +2,12 @@ ; Based on BSM (Bit Shifter's Monitor) +Got_Addr_To_LAC: ; to be used when first byte already fetched + + dec Buf_Index + + ; FALLTROUGH + Get_Addr_To_LAC: phx