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....
 
2016-03-08 20:12
Slammer

Registered: Feb 2004
Posts: 416
TWW: $ means the number is written in hexadecimal, just like % means its in binary. So the following 3 executions gives the same result:
  	:pseudo_test $1234
	:pesudo_test 4660
	:pesudo_test %1001000110100
just as this is the same:
	lda $1234
	lda 4660
	lda %1001000110100
On the inside of the pseudocommand all arguments are filled with pairs of (argumenttype, value). If no argument is given, the argumenttype is AT_NONE. If you want to test if no argument is given you could do something like this
.pseudocommand pseudo_test arg1 {
	.if (arg1.getType()==AT_NONE) .print "No argument is given"
	else .if (arg1.getType()==AT_ABSOLUTE) .print "the argument is absolute: "+ arg1.getValue()
	else .print "the argument is something else!"
}

:pseudo_test
:pseudo_test 4660
:pseudo_test $1234
:pseudo_test ($30),y
This will give:
  No argument is given
  the argument is absolute: 4660
  the argument is absolute: 4660
  the argument is something else! 
So by testing for AT_NONE you can see if an argument is given or not.
2016-03-08 20:20
Slammer

Registered: Feb 2004
Posts: 416
Agemixer: Currently there are no 'break', 'goto' or 'continue' directives to modify the flow of loops. Also, there are no lamdaexpression. This migth change, especially with 'break' and 'continue' and perhaps with lambda expressions (just for the fun of implementing it :-) )
2016-03-08 20:23
Slammer

Registered: Feb 2004
Posts: 416
Agemixer: If you can reconstruct the error, then send it to me and i will look at it. It might be that the loop is not terminating?
2016-03-09 05:57
Agemixer

Registered: Dec 2002
Posts: 38
I couldn't just reproduce it same way but this does the same:

.for (var i=0; i<=10; i=i+0.1) { .if (i>5) .eval i=5 .print "i="+i }

...and the error:

parsing
flex pass 1
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3210)
	at java.util.Arrays.copyOf(Arrays.java:3181)
...


Anyway, not sure if this helps, but something like this triggered it, and IIRC the pow[] was in .for loop comparison though. But that example is gone. (perhaps integer .var comparison vs float .var failed? Even if i<=x, just an assumption..)

.var x = pow(2,fractionbits)   // generate some LUT...
.var diffi  .var wanha=0 
.for(var i=0;i<=x;i++)
   {.eval freq = round(Base_Freq * pow(2,[i/x/12]))
   .eval diffi = myfreq - wanha   .eval wanha = freq
   // ..sorry not everything revealed here.. =)
   }


Anyway i think it could just have been human error :)
2016-03-09 06:25
Agemixer

Registered: Dec 2002
Posts: 38
Then an another little puzzle, which could ease up the programming a bit for sure... (atleast if you branch a lot =)

When a relative branch exceeds its short branch limits in multiple places in the code, it could get annoying to replace it with long jumps, but optimize back a bit later if not needed... So i wanted to automate some long branch generation a bit, instead of several compile time complaints. BUT! Is this possible to do properly in kickassembler? As i know kick can do multiple passes depending on your code, until all variables are known and all code generated properly? :)

What do you think? How this should be done? My idea is this (and it halfway works already!)


.const BEQ=$f0 .const BNE=BEQ^$20
.const BMI=$30 .const BPL=BMI^$20
.const BCC=$90 .const BCS=BCC^$20

.pseudocommand far OPCODE;OPERAND {
  .var PC = *
  .var branch = OPERAND.getValue()-PC
//.if (branch ?? InvalidNumber) { .print "label not found yet" } //...should this work?
  .if ( branch < -126 || branch > 129 ) {
  .byte OPCODE.getValue()^$20, 3 // [BEQ] *+5, jmp long_branch
  jmp OPERAND
  .print"FAR BRANCH at location $"+toHexString(PC)
  } else {
  .byte OPCODE.getValue(), branch-2 // [BNE] short_branch
  // For the above .byte code, is there possible to feed OPCODE for pseudocommand like those argument types for operand?
  }
}

   .pc=$2000  // some testing...

before:
     .fill 127,[NOP]
     :far BNE; before // this branch works
     :far BCC; after  // this branch gives "Error: the condition must be able to evaluate in first parse)"
     .fill 128,[NOP]
after:
2016-03-13 14:08
Slammer

Registered: Feb 2004
Posts: 416
Quote:
.for (var i=0; i<=10; i=i+0.1) { .if (i>5) .eval i=5 .print "i="+i }

The error in the above example is happening due to an endless loop (but I guess you knew thats why you made the example). I dont think i have alot to go on but if you get the error againg let me know. (NB. all numbers in KickAss is pratically doubles, so I dont think it got anything todo with int vs float comparison)

Regarding the branch thing. I had the same thouht once but concluded that this kind of functionality have to be implemented in a 'trial and error' kind of way. When deciding if the branch is a short or a long one you should know the target address of the branch. But the target address of the branch could depend on wether its a short or a long branch, so this is a problem. Further more several branches could be dependand on each others decitions (short vs far) so this makes it more complicated. This is a thing for the assembler to support by first assuming short jumps and then reassemble with long jumps until all branches fits. I have a note on the which list for implementing this as jne, jeq, jmi, jpl, etc but this is a biggie so it wont be this year.
2016-03-13 14:16
Jammer

Registered: Nov 2002
Posts: 1289
Question about functions/macros. There's clear division which does what in manual. How about piece of code that is mix of assembler and script conditions/variables - should I define the one below as macro or function?

	.if(usefreqtable1)
	{
		.if(usefreqlo1)
		{
			ldx #$00
		checkch1freq:
			lda ch1freq, x
			cmp #$fe
			bne updatech1freq
			ldx #$00
			stx checkch1freq - 1
			jmp checkch1freq
		updatech1freq:
			sta $d401
			
			.if([usefreqhisweeptable1] || [constfreqhisweep1 != $00])
			{
				sta dofreqhisweep1 + 1
			}
			
			inx
			lda ch1freq, x
			sta $d400
			
			.if([usefreqlosweeptable1] || [constfreqlosweep1 != $00])
			{
				sta dofreqlosweep1 + 1
			}
			
			inx
			stx checkch1freq - 1
		}
		else
		{
			ldx #$00
		checkch1freq:
			lda ch1freq, x
			cmp #$fe
			bne updatech1freq
			ldx #$00
			stx checkch1freq - 1
			jmp checkch1freq
		updatech1freq:
			sta $d401
			
			.if([usefreqhisweeptable1] || [constfreqhisweep1 != $00])
			{
				sta dofreqhisweep1 + 1
			}
			
			inc checkch1freq - 1

			.if([usefreqlosweeptable1] || [constfreqlosweep1 != $00])
			{
				lda #$00
				sta dofreqlosweep1 + 1
			}
		}
	}
2016-03-13 15:49
Slammer

Registered: Feb 2004
Posts: 416
It would have to be a macro (or pseudo command). Commands that produces bytes to the resulting .prg file (like mnemonics and .byte/.word etc) can't be in functions.

Edit: Otherwise you could make some really tricky stuff like:
lda #myByteProducingFunc(27)
2016-03-13 15:58
Jammer

Registered: Nov 2002
Posts: 1289
I've tried to define that portion of code both as macro and function. Macro resulted in error due to non-assembly instructions. Function compiled without error but most probably as regular assembly that's not really a subroutine. Ok, I see that it has to be totally reorganized ;)
2016-03-13 16:36
Slammer

Registered: Feb 2004
Posts: 416
If you are reporting error please post complete examples. When you post cutout pieces of code I have no chance of verifying if its an error or not.

I dont think I understand what you are writing. Are you sure its not when you put it in a function you get an error for using asm directives? ( = directives that produce bytes to the output)
Previous - 1 | ... | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | ... | 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
Urban Space Cowboy
Krill/Plush
cadaver/covertbitops
Steel/SCS&TRC/G★P
The Syndrom/TIA/Pret..
curtcool
Guests online: 143
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 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
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 Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Newscopy  (9.1)
5 Elwix  (9.1)

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