Hi there,
I've recently switched to KickAssembler from DASM, principally for the very useful symbol table generation for VICE. I have a standard bit of code in a DASM macro that generates a BASIC stub which I have converted to KA syntax successfully, aside from one element (I realise KA has built-in BASIC stub generator functions, but they don't do the LIST tricks I like to use).
At the point the DASM macro embeds the SYS address for the BASIC stub, it does this:
IFNCONST .MLCODE
DS.B 4 ; 1st pass - assign space for digits
ELSE
DC.B [.MLCODE]d ; 2nd pass - embed digits
ENDIF
On the first pass the value of .MLCODE (the code start address immediately following the BASIC stub) is not yet known so DASM simply assigns 4 bytes of storage for it. On the second pass the address has been resolved and so DASM embeds it as the ASCII representation of the address value (the 'd' suffix converts the address to displayable numerics).
It is this that I can't quite persuade KA to do for me:
.pc = $1200 "BASIC Stub" // 8K+ Expanded VIC - BASIC starts at 4608
{
.byte $00 // Start-of-BASIC marker
.word nextline // Pointer to next BASIC line (Lo/Hi)
.word $0000 // Line number
.byte $9e // 'SYS'
*SOMETHING* // Start address ASCII characters
nextline: .byte $00,$00,$00 // End of BASIC line and program
begin:
}
I've tried a variety of directive combinations at *SOMETHING* to embed the address of 'begin:' as a 4-digit representation of the address it points to, but with no success - is this actually possible?
Switching From DASM to KickAssembler
Moderator: Moderators
Switching From DASM to KickAssembler
I've emailed the KickAssembler person/people with this question - posting here too in case anyone with KA expertise knows if this is possible to do.
Re: Switching From DASM to KickAssembler
Ha. Solved it. Might be a better way, but this works.
Code: Select all
.pc = $1200 "BASIC Stub" // 8K+ Expanded VIC - BASIC starts at 4608
{
.byte 0 // Start of BASIC program
.word nextline // Pointer to next BASIC line (Lo/Hi)
.word 0 // Line number
.byte $9e // 'SYS'
.var x=toIntString(begin) // Convert address of 'begin' to a string
.byte x.charAt(0) // Insert address characters for SYS
.byte x.charAt(1)
.byte x.charAt(2)
.byte x.charAt(3)
.byte 0 // End of BASIC line
nextline: .word 0 // End of BASIC program
begin:
}
Re: Switching From DASM to KickAssembler
Don't ya just hate that? You pound your head against a wall forever trying to figure something out, then when you finally give up and ask somebody else, the answer instantly pops into your head before they can even answer your question.
Good work btw.
Good work btw.

Ray..
Re: Switching From DASM to KickAssembler
Yah, struggled with this all morning before finally caving and sending the email / posting here. Within half-an-hour I'd twigged what KA was doing differently during symbol resolution, and found a way to pick the digits out of the function result using the built-in functions. Here's the finished version wrapped as a macro and doing the same thing the DASM version does.
Code: Select all
// BASIC Stub generator macro (KickAssembler)
// Copyright (C) 2014
// Expansion: 0,3,8 (Unexpanded, 3K at $0400, 8K+ at $1200)
// ListMessage: string to display if program is LISTed
.macro BASICStub(Expansion,ListMessage)
{
.if (Expansion == 0)
{
.pc = $1000 "BASIC Stub" // Unexpanded VIC - BASIC starts at 4096
}
else .if (Expansion == 3)
{
.pc = $0400 "BASIC Stub" // 3K Expanded VIC - BASIC starts at 1024
}
else
{
.pc = $1200 "BASIC Stub" // 8K+ Expanded VIC - BASIC starts at 4608
}
.byte 0 // Start of BASIC program
.word nextline // Pointer to next BASIC line (Lo/Hi)
.word 0 // Line number
.byte $9e // 'SYS'
.var x=toIntString(begin) // Convert address of 'begin' to a string
.byte x.charAt(0) // Insert address characters for SYS
.byte x.charAt(1)
.byte x.charAt(2)
.byte x.charAt(3)
.word $8f3a // Colon and 'REM'
.fill 13,$14 // {DEL} control characters to hide start of BASIC line
.text ListMessage // Message for LIST
.byte 0 // End of BASIC line
nextline: .word 0 // End of BASIC program
begin:
}
Re: Switching From DASM to KickAssembler
Had an informative dialogue with Mads Nielsen, the author of KickAssembler over the last couple of days. The upshot of which is this new version of BASICStub, using the much neater .fill directive instead of the .byte technique.
Code: Select all
// VIC-20 BASIC stub generator macro (KickAssembler)
// Copyright (C) 2014
// Expansion: 0,3,8 (Unexpanded, 3K at $0400, 8K+ at $1200)
// ListMessage: string to display if program is LISTed
.macro BASICStub(Expansion,ListMessage)
{
.if (Expansion == 0) // Determine BASIC start address
{
.pc = $1000 "BASIC Stub" // Unexpanded VIC - BASIC starts at 4096
}
else .if (Expansion == 3)
{
.pc = $0400 "BASIC Stub" // 3K Expanded VIC - BASIC starts at 1024
}
else
{
.pc = $1200 "BASIC Stub" // 8K+ Expanded VIC - BASIC starts at 4608
}
.byte 0 // Start of BASIC program
.word nextline // Pointer to next BASIC line (Lo/Hi)
.word 0 // Line number
.byte $9e // 'SYS'
.fill 4, toIntString(begin,4).charAt(i) // Address of 'begin' as numeric string
.word $8f3a // Colon and 'REM'
.fill 13,$14 // {DEL} control characters to hide start of BASIC line
.text ListMessage // Message for LIST
.byte 0 // End of BASIC line
nextline: .word 0 // End of BASIC program
begin: .pc = * "Code" // Start of 6502 code
}
Re: Switching From DASM to KickAssembler
Just wanted to thank you for posting this. It got me started using KickAssembler om my Vic20 project, as that was what I was already using for my C64 projects. 
