Set breakpoint with MSX debugger

By blake

Rookie (17)

blake's picture

22-10-2021, 00:23

Hello all,

I have a newbie question. I made a very simple program (for next loop) to learn the openMSX debugger. However I cannot figure out how to set a breakpoint at the very start of the program, so that I can step through code.

The way I have it now is that the debugger shows me a "frozen" state when the program has reached "halt" command. But that is too late. I'd like to have a breakpoint at the very start (label 'Execute') and step through code from there, like I can with Champ. Is that possible? I use vasm as assembler.

    org &4000
    db "AB"
    dw Execute
    dw 0, 0, 0, 0, 0, 0

RomSize equ &4000

Execute:
    ld a, &0a
NextI:
    ld (varI), a
    dec a
    jr nz, NextI

Finished:
    ; ret
    di
    halt

varI:  
    db 0
    
ProgEnd:
	ds &4000 + RomSize - ProgEnd, 255

Login or register to post comments

By Manuel

Ascended (18237)

Manuel's picture

22-10-2021, 00:29

Did you try to set a breakpoint (click on the left border of the line where to break) at the start of the code in the disassembly view, in the slot of the program ROM?

By blake

Rookie (17)

blake's picture

22-10-2021, 01:22

Ah, I clicked not far enough to the left. Now a red dot appears and after rebooting the emulator, I'm able to step from the beginning. Thank you Manuel.

I noticed something odd though, probably a bug in the code. The line ld (varI), a seems to be ignored. The address &401D assigned to varI stays 0 and does not get the value of the accumulator. Did I do something wrong here?

By ToriHino

Paladin (730)

ToriHino's picture

22-10-2021, 07:15

If you're creating a ROM, than you can't write to address &401D since that is part of your ROM. You need to use the RAM page for that (starting typically from &8000, &C000 or &E000 depending on the amount of RAM available).
See this link for more detailed information.

By blake

Rookie (17)

blake's picture

22-10-2021, 08:33

Thank you so much @ToriHino.

By blake

Rookie (17)

blake's picture

22-10-2021, 14:26

For completeness, I post the working code, with suggested fix from @ToriHino here, in case someone else runs into the same issue.

    org &4000
    db "AB"
    dw Execute
    dw 0, 0, 0, 0, 0, 0

RomSize equ &4000

Execute:
    ld a, &0a
NextI:
    ld (&c000), a     ; &c000 is in ram, outside rom space
    dec a
    jr nz, NextI

Finished:
    ; ret
    di
    halt


ProgEnd:
	ds &4000 + RomSize - ProgEnd, 255 

By samsaga2

Resident (62)

samsaga2's picture

23-10-2021, 15:40

A tip to set breakpoints.

Add 'debug set_watchpoint read_io 0x2E' to your openmsx tcl script. And you can set a breakpoint directly in the assembler code calling 'in a,(0x2e)'. Very useful when you are doing rom mapping (it's a pain to set breakpoints in another page).

By albs_br

Champion (341)

albs_br's picture

23-10-2021, 18:06

You can define a segment to RAM, and set variables with names, like this:

    org &4000
    db "AB"
    dw Execute
    dw 0, 0, 0, 0, 0, 0

RomSize equ &4000

Execute:
    ld a, &0a
NextI:
    ld (var_1), a
    dec a
    jr nz, NextI

Finished:
    ; ret
    di
    halt


ProgEnd:
	ds &4000 + RomSize - ProgEnd, 255 


; variables in RAM memory
    org &C000

var_1:	rb 1        ; RB (reserve byte - 8 bits)
var_2:	rw 1        ; RW (reserve word - 16 bits)

array_1:    rb 32      ; reserve 32 bytes (array_1 is the address of the first byte)