From 5d036749f5a530c7343b9ad4aa07cfd5162a140a Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 9 Jan 2021 19:09:16 +0100 Subject: [PATCH] started work on disassemble command integration --- src/mon_m65/,aliases_mon.s | 2 +- src/mon_m65/bsmon.s | 59 ++++------------------- src/mon_m65/mon_command_disassemble.s | 50 +++++++++++++++++++ src/mon_m65/mon_helper_memory.s | 69 +++++++++++++++------------ src/mon_m65/mon_helper_print.s | 20 ++++---- 5 files changed, 109 insertions(+), 91 deletions(-) create mode 100644 src/mon_m65/mon_command_disassemble.s diff --git a/src/mon_m65/,aliases_mon.s b/src/mon_m65/,aliases_mon.s index c13403e3..015623fb 100644 --- a/src/mon_m65/,aliases_mon.s +++ b/src/mon_m65/,aliases_mon.s @@ -11,7 +11,7 @@ ; ******************** !addr Bank = 2 ; XXX remove this -!addr Adr_Mode = 2 ; $00 = C64 address, $80 = M65 flat address ; XXX adapt the implementation +!addr Adr_Mode = 2 ; $00 = 64K address, $80 = M65 flat address ; XXX adapt the implementation !addr PCH = 3 !addr PCL = 4 !addr SR = 5 diff --git a/src/mon_m65/bsmon.s b/src/mon_m65/bsmon.s index 20eb2adc..84155460 100644 --- a/src/mon_m65/bsmon.s +++ b/src/mon_m65/bsmon.s @@ -15,14 +15,19 @@ Mon_Call: JSR Print_Commands -; clear register for monitor call +; set default addressing mode to 64K LDA #0 + STA Adr_Mode + +; clear register for monitor call + LDX #6 @loop STA AC,X DEX BPL @loop + ; set default PC to monitor exit point LDA # negative - -@loop JSR CR_Erase ; prepare empty line - JSR STOP - LBEQ Main - JSR Dis_Code ; disassemble one line - INC Op_Size - LDA Op_Size - JSR Add_LPC ; advance address - LDA Long_CT - SEC - SBC Op_Size - STA Long_CT - BCS @loop - JMP Main - ; ******* Dis_Code: ; ******* @@ -1397,8 +1360,7 @@ Print_Code: ; detect long branches -@long LDA #KEY_YELLOW - JSR CHROUT +@long JSR Print_Attr_Bold LDX Op_Code LDA LEN_ADM,X CMP #%10100000 ; long branch mode @@ -1475,8 +1437,7 @@ Print_Code: @mne4 JSR Print_Blank @mne5 JSR Print_Blank - LDA #KEY_WHITE - JSR CHROUT + JSR Print_Attr_NoBold ; check for accumulator operand diff --git a/src/mon_m65/mon_command_disassemble.s b/src/mon_m65/mon_command_disassemble.s new file mode 100644 index 00000000..40dcb33f --- /dev/null +++ b/src/mon_m65/mon_command_disassemble.s @@ -0,0 +1,50 @@ + +; Based on BSM (Bit Shifter's Monitor) + +Mon_Disassemble: + + lda Adr_Mode + pha ; store addressing mode, in case no parameter is given + lda #$00 + sta Adr_Mode ; by default use C64-style addressing + + jsr Get_Addr_To_LAC ; get 1st parameter (start address) + beq @nopar + pla ; drop previous addressing mode + jsr LAC_To_LPC ; Long_PC = start address + jsr Get_Addr_To_LAC ; get 2nd parameter (end address) + bne @range + +@nopar: + + pla ; retrieve old addressing mode + sta Adr_Mode + + lda #$20 ; by default disassemble 32 addresses + sta Long_CT+0 + lda #$00 + sta Long_CT+1 + sta Long_CT+2 + sta Long_CT+3 + bra @loop + +@range: + + jsr LAC_Minus_LPC ; Long_CT = range + +bcc Mon_Error ; -> negative + +@loop: + + jsr CR_Erase ; prepare empty line + jsr STOP + +beq Main + jsr Dis_Code ; disassemble one line + inc Op_Size + lda Op_Size + jsr Add_LPC ; advance address + lda Long_CT + sec + sbc Op_Size + sta Long_CT + bcs @loop + jmp Main diff --git a/src/mon_m65/mon_helper_memory.s b/src/mon_m65/mon_helper_memory.s index 7be5de6d..d6194d68 100644 --- a/src/mon_m65/mon_helper_memory.s +++ b/src/mon_m65/mon_helper_memory.s @@ -4,6 +4,9 @@ Get_From_Memory: + ; XXX consider temporarily switching off $C000-$CFFF ROM + ; XXX consider using long mode for addresses below $8000 always + phx phy phz @@ -12,59 +15,63 @@ Get_From_Memory: clc tza - adc Long_PC+0 - sta Long_TMP+0 + adc Long_PC+0 + sta Long_TMP+0 - ldx #$01 + ldx #$01 @1: - lda Long_PC+0,x - adc #$00 - sta Long_TMP+0,x + lda Long_PC+0,x + adc #$00 + sta Long_TMP+0,x inx - cpx #$04 - bne @1 + cpx #$04 + bne @1 - ldz #$00 + ldz #$00 ; Check addressing mode - bbs7 Adr_Mode, @mode_flat + bbs7 Adr_Mode, @mode_flat @mode_64k: - lda Long_TMP+1 - bne @read ; branch if no need to handle shadow memory (not zero page) - lda Long_TMP+0 + lda #$00 ; make sure this is 64K address + sta Long_TMP+2 + sta Long_TMP+3 + + lda Long_TMP+1 + bne @read ; branch if no need to handle shadow memory (not zero page) + lda Long_TMP+0 dec dec - cmp #$8E - bcs @read ; branch if no need to handle shadow memory (0, 1, or above $8F) + cmp #$8E + bcs @read ; branch if no need to handle shadow memory (0, 1, or above $8F) @2: - sta Long_TMP+0 - bra @read_shadow + sta Long_TMP+0 + bra @read_shadow @mode_flat: - lda Long_TMP+3 - ora Long_TMP+2 - ora Long_TMP+1 - bne @read_flat + lda Long_TMP+3 + ora Long_TMP+2 + ora Long_TMP+1 + bne @read_flat - lda Long_TMP+0 + lda Long_TMP+0 dec dec - cmp #$8E - bcs @read_flat - bra @2 + cmp #$8E + bcs @read_flat + bra @2 @read_shadow: - lda #MEMCONF_SHADOW_BZP_1 - sta Long_TMP+1 - lda #MEMCONF_SHADOW_BZP_2 - sta Long_TMP+2 - lda #MEMCONF_SHADOW_BZP_3 - sta Long_TMP+3 + lda #MEMCONF_SHADOW_BZP_1 + sta Long_TMP+1 + lda #MEMCONF_SHADOW_BZP_2 + sta Long_TMP+2 + lda #MEMCONF_SHADOW_BZP_3 + sta Long_TMP+3 @read_flat: +nop diff --git a/src/mon_m65/mon_helper_print.s b/src/mon_m65/mon_helper_print.s index 4ad15ce9..716ae3e5 100644 --- a/src/mon_m65/mon_helper_print.s +++ b/src/mon_m65/mon_helper_print.s @@ -4,24 +4,24 @@ Print_Attr_Bold: - jsr Print_Attr_Common1 - lda #'s' - bra Print_Attr_Common2 + jsr Print_Attr_Common1 + lda #'s' + bra Print_Attr_Common2 Print_Attr_NoBold: - jsr Print_Attr_Common1 - lda #'u' + jsr Print_Attr_Common1 + lda #'u' ; FALLTROUGH Print_Attr_Common2: - jmp CHROUT + jmp CHROUT Print_Attr_Common1: - lda #$00 - sta QTSW ; make sure quote mode is disabled - lda #KEY_ESC - jmp CHROUT + lda #$00 + sta QTSW ; make sure quote mode is disabled + lda #KEY_ESC + jmp CHROUT