Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Code based breakpoints using ca65 and VICE
2009-08-06 07:54
JackAsser

Registered: Jun 2002
Posts: 1989
Code based breakpoints using ca65 and VICE

Recent discussions about debugging etc made me do this, much like Doynax's stuff:

Macro for ca65:
.macro breakpoint name
    .ident (.concat("br_", .string(name))):
    .export .ident(.concat("br_", .string(name)))
.endmacro

Link line in your Makefile:
ca65 -C link -m map -Ln symbols $(OBJS) && sed 's/al [0-9A-F]* \.br_\([a-z]*\)/\0\nbreak \.br_\1/' < symbols > symbols2

Basically it tells ca65 to emit all labels into a file called symbols. The sed-script then locates all symbols starting with br_ and adds a breakpoint command after it.

To run in VICE:
x64 -moncommands symbols2 whateva.d64

This enables you to add breakpoints directly into your sourcecode like:

breakpoint flashcolors
inc $d020
jmp *-3


Have fun with future debugging! :)

 
... 27 posts hidden. Click here to view all posts....
 
2009-08-13 10:52
Dragnet

Registered: Nov 2006
Posts: 16
Hola,

Hey, neat feature! :)

But it would be even nicer if KickAss allowed command line arguments to be passed into the code, allowing the functionality to be truly generic...

For example, I use a unique "compile.bat" file to compile a given part (in a separate dir), with content like this:

java -jar c:/c64/KickAssembler35/kickass.jar foo.asm -showmem -vicesymbols -libdir "c:/c64/includes" -log foo.log


Then, if I was allowed to add additional user-defined arguments, say something like "-break_filename foo.txt", then the scenario would then become something like:

.var brkFile = createFile(getCommandLineArgument("-break_filename")) 

.macro break(file) {
  .eval file.writeln("break " + toHexString(*))
}

..

ldx #$ff
:break(brkFile)
lda #$00

:)

Regards / Dragnet
2009-08-13 11:17
doynax
Account closed

Registered: Oct 2004
Posts: 212
Quoting Dragnet
But it would be even nicer if KickAss allowed command line arguments to be passed into the code, allowing the functionality to be truly generic...
Can't you just use an environment variable or something?
2009-08-13 13:08
Dragnet

Registered: Nov 2006
Posts: 16
Quote: Quoting Dragnet
But it would be even nicer if KickAss allowed command line arguments to be passed into the code, allowing the functionality to be truly generic...
Can't you just use an environment variable or something?


Well, not if I want to "inject" values into the KickAss script/macro code from the environment/command line - the problem is merely how to reference such values from within KickAss, e.g. using a getCommandLineArgument function or something of the like...

/Dragnet
2009-08-13 13:19
doynax
Account closed

Registered: Oct 2004
Posts: 212
Quote: Well, not if I want to "inject" values into the KickAss script/macro code from the environment/command line - the problem is merely how to reference such values from within KickAss, e.g. using a getCommandLineArgument function or something of the like...

/Dragnet


As I understand it KickAss exposes a full Java VM, so you should be able to SET a variable in your batch script just call System.getenv().get("BREAKPOINTS").

Or something along those lines anyway, though to be honest I have as little experience with Java as with KickAss.
2009-08-13 14:40
Slammer

Registered: Feb 2004
Posts: 416
No, Kick Assembler has a script language that is working much like java (but it isn't java). So Dragnet is right, a getCommandLineArgument function would be nice. I will put it on the todo list. However, a getEnvironmentVar() would also do the trick.
2009-08-13 18:16
Dragnet

Registered: Nov 2006
Posts: 16
Quote: No, Kick Assembler has a script language that is working much like java (but it isn't java). So Dragnet is right, a getCommandLineArgument function would be nice. I will put it on the todo list. However, a getEnvironmentVar() would also do the trick.

I'm probably opening up a can of worms here and being *very* nit-picking, I know, but using environment variables like this is in my humble view something not to do in the general case; here, however, the effect is arguably the same since the environment var can be set from the .bat script as well, but you are in effect forcing use of the Singleton pattern (blah blah...) instead of letting the user decide which instance (= values) to use (blah blah)... 8^)

So, to make a long boring story short, Slammer: do the getCommandLineArgument method first, then and only then consider the environment thing... How many lines of code will it take to implement in KickAss/Java - 10, max? :)

Regards /Dragnet
2009-08-14 06:14
Mr. SID

Registered: Jan 2003
Posts: 421
You could just use k2asm:

ldx #$00
{
	lda text,x
	beq _break
	sta $0400,x
	inx
	bne _cont
}
rts

text:		
.encoding "screencodes.enc"
#pybegin			
import os
print '.enc "ASSEMBLED BY USER ' + os.getenv('USER').upper() + '",0'
#pyend


It also allows access to the commandline options, but you need to run the preprocess manually for that, I guess.
The possibilities are endless, if you actually have a full language available. There's a python library for everything...
2009-08-14 07:13
Frantic

Registered: Mar 2003
Posts: 1627
Then again... Any script language could easily make some sort of pre parsing of any text file, before this text file is sent to an assembler. What is so great about having it "in" the assembler itself? It is still executed in a completely separate pass, before any labels are resolved and so on, isn't it?
2009-08-14 10:18
Slammer

Registered: Feb 2004
Posts: 416
I thinks it's a great advantage to be able to write sine curves and small graphic converters in the middle of your sourcefile.

I guess k2asm does it by a prepass (but im only guessing) while Kick Assembler assembles both the script and the Assembler commands together. The strength of the ladder is that the script and the asm code can interact both ways.

Notice that Mr. Sid didn't solve the original problem (generating breakpoints). In the Kick Assembler example it was done by:
.eval file.writeln("break " +  toHexString(*))

where the * refers to the current memory position, this couldn't have been done in a prepass.

However, Including a preparse script in an assembler is a cool thing, relative to no script, since it makes people aware of the of the advantages of scripting.
2009-08-14 11:03
Frantic

Registered: Mar 2003
Posts: 1627
@Slamsky: Just to clarify, I was referring to k2asm in my post..

...and now I just implemented some shit so I can just write ".bpc("if .A == $83")" in my code, and the VICE monitor will break on this line, if the specified condition holds true (if register A is equal to $83 at that point in the program). Very nice. :) If I just write ".bp", it will break unconditionally on this line.

I am using DreamAss for the current project.
Previous - 1 | 2 | 3 | 4 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Falcon soft
tlr
CA$H/TRiAD
Bob/Censor Design
void256
Mason/Unicess
Dano/Padua
Guests online: 157
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.047 sec.