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 > Kick Assembler Thread 2
2009-07-21 17:20
Slammer

Registered: Feb 2004
Posts: 416
Kick Assembler Thread 2

The previous thread took a little long to load, so this is a new fresh one..
 
... 590 posts hidden. Click here to view all posts....
 
2011-12-31 11:04
Slammer

Registered: Feb 2004
Posts: 416
Then i suggest you use pseudo commands. Here is an example of how to do:
// Use it like this
         :irqEnd #$60 ; #irq2

// The macro
.pseudocommand irqEnd nextIrqYpos ; nextIrq ; extraArg {
	.if (nextIrqYpos.getType()!=AT_NONE) {
		:mov nextIrqYpos ; $d012
	}	
	.if (nextIrq.getType()!=AT_NONE) {
		:mov16 nextIrq ; $fffe
	}	
	.if (SAVE01==extraArg.getValue()) {
		:mov _ds_irq01 ; $01
	}
	lda _ds_irqa
	ldx _ds_irqx
	ldy _ds_irqy
	rti
}


The above have optional parameters for next ypos, next irq address, and an option to save $01. (The mov commands are 'pc style' pseudo commands that moves data)
2012-02-04 13:45
Slammer

Registered: Feb 2004
Posts: 416
Conjuror: Finally found some time to make a new release. Made the following functions on user defined structs:
getStructName() - returns the structure name
getNoOfFields() - returns the number of defined fields
getFieldNames() - returns a list of field names
get(fieldName) - returns a field value by field name.
get(index)     - returns a field value by field index 
set(index, value) - sets a field by field name
set(fieldName, value) - sets a fields by field index

2012-02-05 02:36
Conjuror

Registered: Aug 2004
Posts: 168
Slammer,

Great work! thanks. This will really help with more flexible code creation.

Nice to see the ternary operator in there too.

2012-02-08 12:56
McKrackeN

Registered: Feb 2011
Posts: 20
Hey ppl! I have a newbie question: is there a way to use constants inside a macro?

For instance, I need to be able to do something like this:


.const MyConst = $d012

.macro myMacro(val)
{
        ldy #val
	sty MyConst
}


But I get an error when compiling.

Thanks in advance! :)
2012-02-08 15:55
Slammer

Registered: Feb 2004
Posts: 416
Constants are visible after you have defined them. So the example you give, will work if you declare your const before you use the macro:

:MyMacro($32) 	// This won't work
.const MyConst = $d012
:MyMacro($32) 	// This will work
.macro myMacro(val)
{
    ldy #val
    sty MyConst
}

However, labels can be seen in the whole scope so they can be used before they are declared:

:MyMacro($32) 	// This will work
.label MyLabel = $d012
.macro myMacro(val)
{
    ldy #val
    sty MyLabel
}
2012-02-08 16:29
McKrackeN

Registered: Feb 2011
Posts: 20
Thanks for your help!

I think i'm declaring the constant before using the macro but i'm still getting the compiler error.

I have two separate files. One called system.asm and the other test.asm.
// System.asm

.const MyConst = $d012

.macro myMacro(val)
{
        ldy #val
	sty MyConst
}


Then in the test.asm:

// test.asm
.import source "system.asm"

// some code

:myMacro(0)

2012-02-08 22:35
Slammer

Registered: Feb 2004
Posts: 416
I Just tried it and it works fine here. My guess is that you define the macro+constant inside one scope and execute your macro outside the scope. Eg. if you start you system.asm file with a .filenamespace directive.



2012-02-08 22:43
McKrackeN

Registered: Feb 2011
Posts: 20
Yes!! That's it!! Thanks for your help and for this amazing compiler!!
2012-02-10 22:38
TWW

Registered: Jul 2009
Posts: 541
How would I go about doing a:

.fill 256,invert(data.get(i))

i.e. invert the data filled into memory on the fly?
2012-02-19 12:39
Slammer

Registered: Feb 2004
Posts: 416
Suppose by invert you mean exclusive or you can:
.fill 256,data.get(i)^$ff
Previous - 1 | ... | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | ... | 61 - 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
Mason/Unicess
Thunder.Bird/HF/MYD!..
Spinball/Excess
Martin Piper
Guests online: 185
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 Bromance  (9.6)
10 Memento Mori  (9.6)
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 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.5)
2 Black Beard  (9.4)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Irata  (8.5)

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