diff --git a/STATUS.md b/STATUS.md index b68d16e2..ef7fdd6e 100644 --- a/STATUS.md +++ b/STATUS.md @@ -407,6 +407,7 @@ Note: this is likely to change in the future, possibly in an incompatible way! | Address | Name | Status | Remarks | | :-------: | :------- | :------: | :--------------------------------------------------------------------: | +| ? | MONITOR | WIP | launches a machine language monitor | | ? | PRHEX | DONE | print hex value from .A | | `$FF7D` | PRIMM | DONE | print immediate, address compatible with C128 and C65 ROMs | | `$FFF8` | | DONE | reset vector for usage within hypervisor, starts in legacy mode | diff --git a/doc/Extended-BASIC.md b/doc/Extended-BASIC.md index a6294845..cad3279c 100644 --- a/doc/Extended-BASIC.md +++ b/doc/Extended-BASIC.md @@ -98,6 +98,10 @@ Displays BASIC memory usage information: * `STRS` - bytes occupied by strings, also the ones belonging to arrays * `FREE` - unused space +### `MONITOR` (MEGA65) + +Invokes a machine language monitor + ### `SYSINFO` (MEGA65) Displays various system information. diff --git a/src/basic/,imports.s b/src/basic/,imports.s index 1024c047..2e144cc4 100644 --- a/src/basic/,imports.s +++ b/src/basic/,imports.s @@ -19,6 +19,7 @@ ;; #ALIAS# printf = KERNAL_0.printf ;; #ALIAS# PRIMM = KERNAL_0.PRIMM +;; #ALIAS# MONITOR = KERNAL_0.MONITOR ;; #ALIAS# plot_set = KERNAL_0.plot_set ;; #ALIAS# print_hex_byte = KERNAL_0.print_hex_byte diff --git a/src/basic/basic_commands_01/cmd_old.s b/src/basic/basic_commands_01/cmd_old.s index 6d2d4f9d..38524cd8 100644 --- a/src/basic/basic_commands_01/cmd_old.s +++ b/src/basic/basic_commands_01/cmd_old.s @@ -7,9 +7,7 @@ cmd_old: ; First make sure we are in direct mode - ldx CURLIN+1 - inx - +bne do_DIRECT_MODE_ONLY_error + jsr helper_ensure_direct_mode ; Now try to restore program linkage and VARTAB diff --git a/src/basic/basic_commands_01/helper_ensure_direct_mode.s b/src/basic/basic_commands_01/helper_ensure_direct_mode.s new file mode 100644 index 00000000..f16f4ab4 --- /dev/null +++ b/src/basic/basic_commands_01/helper_ensure_direct_mode.s @@ -0,0 +1,12 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE + + +helper_ensure_direct_mode: + + ldx CURLIN+1 + inx + +bne do_DIRECT_MODE_ONLY_error + + rts diff --git a/src/basic/basic_commands_04/cmd_monitor.s b/src/basic/basic_commands_04/cmd_monitor.s index ddf52c04..46ba3215 100644 --- a/src/basic/basic_commands_04/cmd_monitor.s +++ b/src/basic/basic_commands_04/cmd_monitor.s @@ -4,6 +4,7 @@ cmd_monitor: - ; XXX implement this + jsr helper_ensure_native_mode + jsr helper_ensure_direct_mode - jmp do_NOT_IMPLEMENTED_error + jmp MONITOR diff --git a/src/basic/board_m65/mega65_map_helpers.s b/src/basic/board_m65/mega65_map_helpers.s index aee56e15..6cdfea00 100644 --- a/src/basic/board_m65/mega65_map_helpers.s +++ b/src/basic/board_m65/mega65_map_helpers.s @@ -23,6 +23,6 @@ map_BASIC_1: taz lda #$20 - ldx #$C2 ; $4000 <- map 16KB from $22000 + ldx #$C2 ; $4000 <- map 16KB from $26000 jmp map_end diff --git a/src/kernal/board_m65/mega65_map_helpers.s b/src/kernal/board_m65/mega65_map_helpers.s index 65abcf12..0aa629bf 100644 --- a/src/kernal/board_m65/mega65_map_helpers.s +++ b/src/kernal/board_m65/mega65_map_helpers.s @@ -62,7 +62,7 @@ map_KERNAL_1: tay taz - ldx #$42 ; $4000 <- map 8KB from $20000 + ldx #$42 ; $4000 <- map 8KB from $24000 bra map_end @@ -85,7 +85,7 @@ map_DOS_1: ldx #$C1 ; $4000 <- map 16KB ROM from $20000 map - bra map_end_no_eom ; no EOM, we do not want interrupts within DOS! + bra map_end_no_eom ; no EOM, we do not want interrupts within DOS! map_NORMAL_from_DOS_1: @@ -99,3 +99,21 @@ map_NORMAL_from_DOS_1: tab bra map_NORMAL_common + +map_MON_1: + + php + pha + phx + phy + phz + + lda #$00 + tay + taz + + lda #$E0 + ldx #$42 ; $4000 <- map 8KB from $30000 + + map + bra map_end diff --git a/src/kernal/board_m65/mega65_monitor.s b/src/kernal/board_m65/mega65_monitor.s new file mode 100644 index 00000000..6e2133aa --- /dev/null +++ b/src/kernal/board_m65/mega65_monitor.s @@ -0,0 +1,9 @@ +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE + + +MONITOR: + + jsr map_MON_1 + ; XXX call the monitor here + jmp map_NORMAL diff --git a/src/kernal/jumptable_m65/jmonitor.s b/src/kernal/jumptable_m65/jmonitor.s new file mode 100644 index 00000000..18471ee9 --- /dev/null +++ b/src/kernal/jumptable_m65/jmonitor.s @@ -0,0 +1,10 @@ +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE + + +; Launches the machine language monitor + + +JMONITOR: + + jmp MONITOR diff --git a/src/mon_m65/bsmon.s b/src/mon_m65/bsmon.s index fec0079a..dcdc7b36 100644 --- a/src/mon_m65/bsmon.s +++ b/src/mon_m65/bsmon.s @@ -60,17 +60,8 @@ ; operating system variables -!addr STATUS = $90 -!addr VERCK = $93 -!addr FNLEN = $b7 -!addr SA = $b9 -!addr FA = $ba -!addr FNADR = $bb - !addr MODE_80 = $d7 ; 80 column / 40 volumn flag -!addr Buffer = $0200 ; input buffer - !addr IIRQ = $0314 !addr IBRK = $0316 !addr EXMON = $032e @@ -244,7 +235,7 @@ Main_A ; **** @loop JSR CHRIN - STA Buffer,X + STA BUF,X INX CPX #80 BCS Mon_Error ; input too long @@ -253,7 +244,7 @@ Main_A LDA #0 STA Buf_Index - STA Buffer-1,X ; terminate buffer + STA BUF-1,X ; terminate buffer @getcomm JSR Get_Char BEQ Main CMP #' ' @@ -287,7 +278,7 @@ Mon_Error Mon_Select ; ******** - STA VERCK + STA VERCKK CPX #22 LBCS Load_Save TXA @@ -858,7 +849,7 @@ Load_Save ; STY BA ; STY FNLEN ; STY FNBANK - ; STY STATUS + ; STY IOSTATUS ; LDA #>Mon_Data ; STA FNADR+1 ; LDA #