Set breakpoint with MSX debugger

Página 1/5
| 2 | 3 | 4 | 5

Por blake

Rookie (17)

Imagen del blake

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 sesión o register para postear comentarios

Por Manuel

Ascended (19691)

Imagen del Manuel

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?

Por blake

Rookie (17)

Imagen del blake

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?

Por ToriHino

Paladin (927)

Imagen del ToriHino

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.

Por blake

Rookie (17)

Imagen del blake

22-10-2021, 08:33

Thank you so much @ToriHino.

Por blake

Rookie (17)

Imagen del blake

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 

Por samsaga2

Resident (62)

Imagen del samsaga2

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).

Por albs_br

Champion (499)

Imagen del albs_br

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)

Por inchl

Expert (105)

Imagen del inchl

25-01-2022, 17:25

Since a couple of days all breakpoints that are set in the debugger (click in left border) will no longer work. Custom breakpoints (like the write to a I/O port) do work. Once I got it working by removing all openmsx stuff from my laptop and do a reinstall. But now even that solution no longer works....

Debugging code requires setting multiple breakpoints, requires step back, step forward....new breakpoints,... run until breakpoint etc... I need this working again!

anyone same problem?... anyone a solution?...

Por MsxKun

Paragon (1134)

Imagen del MsxKun

25-01-2022, 17:37

I noticed something some day ago while I was trying to set a breakpoint into a ROM file. If the breakpoint was between $4000 and $7FFF (16k ROM), the breakpoint didn't appear (the red dot), but if it was outside the ROM space, it worked fine.
Also... when you load Track&Field2 ROM and go to the debugger, it only shows a bit of code and when you scroll it freezes. Trying to pause the execution makes it dissappear, crash. Also with Track&Field 1 ROM. Even if the code is not being executed. Tried Game Master on Slot 1 and T&F on slot 2. Strange behaviour. Game Master alone, no problem. Another ROM, no problem.
First time I see this.
That happened on the linux openMSX supplied with Ubuntu. OpenMSX for Raspberry OS (0.16 I think) works fine.

Add-on: Editing some bytes on the ROM fixed the crash problem. don't ask me why Question

Por Manuel

Ascended (19691)

Imagen del Manuel

25-01-2022, 22:03

Did openMSX crash or the debugger? Which versions were these?

Página 1/5
| 2 | 3 | 4 | 5